Xenomai  3.1
kcompat.h
1 /*******************************************************************************
2 
3 
4  Copyright(c) 1999 - 2006 Intel Corporation. All rights reserved.
5 
6  This program is free software; you can redistribute it and/or modify it
7  under the terms of the GNU General Public License as published by the Free
8  Software Foundation; either version 2 of the License, or (at your option)
9  any later version.
10 
11  This program is distributed in the hope that it will be useful, but WITHOUT
12  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14  more details.
15 
16  You should have received a copy of the GNU General Public License along with
17  this program; if not, write to the Free Software Foundation, Inc., 59
18  Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 
20  The full GNU General Public License is included in this distribution in the
21  file called LICENSE.
22 
23  Contact Information:
24  Linux NICS <linux.nics@intel.com>
25  e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
26  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
27 
28 *******************************************************************************/
29 
30 #ifndef _KCOMPAT_H_
31 #define _KCOMPAT_H_
32 
33 #include <linux/version.h>
34 #include <linux/types.h>
35 #include <linux/errno.h>
36 #include <linux/module.h>
37 #include <linux/pci.h>
38 #include <linux/netdevice.h>
39 #include <linux/ioport.h>
40 #include <linux/slab.h>
41 #include <linux/pagemap.h>
42 #include <linux/list.h>
43 #include <linux/sched.h>
44 #include <asm/io.h>
45 
46 #include <rtnet_port.h>
47 
48 #ifndef IRQ_HANDLED
49 #define irqreturn_t void
50 #define IRQ_HANDLED
51 #define IRQ_NONE
52 #endif
53 
54 #ifndef SET_NETDEV_DEV
55 #define SET_NETDEV_DEV(net, pdev)
56 #endif
57 
58 /* Useful settings for rtnet */
59 #undef MAX_SKB_FRAGS
60 #undef NETIF_F_TSO
61 #undef E1000_COUNT_ICR
62 #undef NETIF_F_HW_VLAN_TX
63 #undef CONFIG_NET_POLL_CONTROLLER
64 #undef ETHTOOL_OPS_COMPAT
65 #undef ETHTOOL_GPERMADDR
66 
67 #ifndef HAVE_FREE_NETDEV
68 #define free_netdev(x) kfree(x)
69 #endif
70 
71 #undef E1000_NAPI
72 #undef CONFIG_E1000_NAPI
73 
74 #undef CONFIG_E1000_DISABLE_PACKET_SPLIT
75 #define CONFIG_E1000_DISABLE_PACKET_SPLIT 1
76 
77 
78 #ifdef DISABLE_PCI_MSI
79 #undef CONFIG_PCI_MSI
80 #endif
81 
82 #ifdef DISABLE_PM
83 #undef CONFIG_PM
84 #endif
85 #undef CONFIG_PM
86 
87 #ifndef module_param
88 #define module_param(v,t,p) MODULE_PARM(v, "i");
89 #endif
90 
91 #ifndef DMA_64BIT_MASK
92 #define DMA_64BIT_MASK 0xffffffffffffffffULL
93 #endif
94 
95 #ifndef DMA_32BIT_MASK
96 #define DMA_32BIT_MASK 0x00000000ffffffffULL
97 #endif
98 
99 /*****************************************************************************/
100 #ifndef unlikely
101 #define unlikely(_x) _x
102 #define likely(_x) _x
103 #endif
104 /*****************************************************************************/
105 
106 #ifndef PCI_DEVICE
107 #define PCI_DEVICE(vend,dev) \
108  .vendor = (vend), .device = (dev), \
109  .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID
110 #endif
111 
112 /*****************************************************************************/
113 /* Installations with ethtool version without eeprom, adapter id, or statistics
114  * support */
115 #ifndef ETHTOOL_GSTATS
116 #define ETHTOOL_GSTATS 0x1d
117 #undef ethtool_drvinfo
118 #define ethtool_drvinfo k_ethtool_drvinfo
119 struct k_ethtool_drvinfo {
120  uint32_t cmd;
121  char driver[32];
122  char version[32];
123  char fw_version[32];
124  char bus_info[32];
125  char reserved1[32];
126  char reserved2[16];
127  uint32_t n_stats;
128  uint32_t testinfo_len;
129  uint32_t eedump_len;
130  uint32_t regdump_len;
131 };
132 
133 struct ethtool_stats {
134  uint32_t cmd;
135  uint32_t n_stats;
136  uint64_t data[0];
137 };
138 
139 #ifndef ETHTOOL_PHYS_ID
140 #define ETHTOOL_PHYS_ID 0x1c
141 #ifndef ETHTOOL_GSTRINGS
142 #define ETHTOOL_GSTRINGS 0x1b
143 enum ethtool_stringset {
144  ETH_SS_TEST = 0,
145  ETH_SS_STATS,
146 };
147 struct ethtool_gstrings {
148  u32 cmd; /* ETHTOOL_GSTRINGS */
149  u32 string_set; /* string set id e.c. ETH_SS_TEST, etc*/
150  u32 len; /* number of strings in the string set */
151  u8 data[0];
152 };
153 #ifndef ETHTOOL_TEST
154 #define ETHTOOL_TEST 0x1a
155 enum ethtool_test_flags {
156  ETH_TEST_FL_OFFLINE = (1 << 0),
157  ETH_TEST_FL_FAILED = (1 << 1),
158 };
159 struct ethtool_test {
160  uint32_t cmd;
161  uint32_t flags;
162  uint32_t reserved;
163  uint32_t len;
164  uint64_t data[0];
165 };
166 #ifndef ETHTOOL_GEEPROM
167 #define ETHTOOL_GEEPROM 0xb
168 #undef ETHTOOL_GREGS
169 struct ethtool_eeprom {
170  uint32_t cmd;
171  uint32_t magic;
172  uint32_t offset;
173  uint32_t len;
174  uint8_t data[0];
175 };
176 
177 struct ethtool_value {
178  uint32_t cmd;
179  uint32_t data;
180 };
181 
182 #ifndef ETHTOOL_GLINK
183 #define ETHTOOL_GLINK 0xa
184 #endif /* Ethtool version without link support */
185 #endif /* Ethtool version without eeprom support */
186 #endif /* Ethtool version without test support */
187 #endif /* Ethtool version without strings support */
188 #endif /* Ethtool version wihtout adapter id support */
189 #endif /* Ethtool version without statistics support */
190 
191 #ifndef ETHTOOL_GREGS
192 #define ETHTOOL_GREGS 0x00000004 /* Get NIC registers */
193 #define ethtool_regs _kc_ethtool_regs
194 /* for passing big chunks of data */
195 struct _kc_ethtool_regs {
196  u32 cmd;
197  u32 version; /* driver-specific, indicates different chips/revs */
198  u32 len; /* bytes */
199  u8 data[0];
200 };
201 #endif
202 #ifndef ETHTOOL_GMSGLVL
203 #define ETHTOOL_GMSGLVL 0x00000007 /* Get driver message level */
204 #endif
205 #ifndef ETHTOOL_SMSGLVL
206 #define ETHTOOL_SMSGLVL 0x00000008 /* Set driver msg level, priv. */
207 #endif
208 #ifndef ETHTOOL_NWAY_RST
209 #define ETHTOOL_NWAY_RST 0x00000009 /* Restart autonegotiation, priv */
210 #endif
211 #ifndef ETHTOOL_GLINK
212 #define ETHTOOL_GLINK 0x0000000a /* Get link status */
213 #endif
214 #ifndef ETHTOOL_GEEPROM
215 #define ETHTOOL_GEEPROM 0x0000000b /* Get EEPROM data */
216 #endif
217 #ifndef ETHTOOL_SEEPROM
218 #define ETHTOOL_SEEPROM 0x0000000c /* Set EEPROM data */
219 #endif
220 #ifndef ETHTOOL_GCOALESCE
221 #define ETHTOOL_GCOALESCE 0x0000000e /* Get coalesce config */
222 /* for configuring coalescing parameters of chip */
223 #define ethtool_coalesce _kc_ethtool_coalesce
224 struct _kc_ethtool_coalesce {
225  u32 cmd; /* ETHTOOL_{G,S}COALESCE */
226 
227  /* How many usecs to delay an RX interrupt after
228  * a packet arrives. If 0, only rx_max_coalesced_frames
229  * is used.
230  */
231  u32 rx_coalesce_usecs;
232 
233  /* How many packets to delay an RX interrupt after
234  * a packet arrives. If 0, only rx_coalesce_usecs is
235  * used. It is illegal to set both usecs and max frames
236  * to zero as this would cause RX interrupts to never be
237  * generated.
238  */
239  u32 rx_max_coalesced_frames;
240 
241  /* Same as above two parameters, except that these values
242  * apply while an IRQ is being serviced by the host. Not
243  * all cards support this feature and the values are ignored
244  * in that case.
245  */
246  u32 rx_coalesce_usecs_irq;
247  u32 rx_max_coalesced_frames_irq;
248 
249  /* How many usecs to delay a TX interrupt after
250  * a packet is sent. If 0, only tx_max_coalesced_frames
251  * is used.
252  */
253  u32 tx_coalesce_usecs;
254 
255  /* How many packets to delay a TX interrupt after
256  * a packet is sent. If 0, only tx_coalesce_usecs is
257  * used. It is illegal to set both usecs and max frames
258  * to zero as this would cause TX interrupts to never be
259  * generated.
260  */
261  u32 tx_max_coalesced_frames;
262 
263  /* Same as above two parameters, except that these values
264  * apply while an IRQ is being serviced by the host. Not
265  * all cards support this feature and the values are ignored
266  * in that case.
267  */
268  u32 tx_coalesce_usecs_irq;
269  u32 tx_max_coalesced_frames_irq;
270 
271  /* How many usecs to delay in-memory statistics
272  * block updates. Some drivers do not have an in-memory
273  * statistic block, and in such cases this value is ignored.
274  * This value must not be zero.
275  */
276  u32 stats_block_coalesce_usecs;
277 
278  /* Adaptive RX/TX coalescing is an algorithm implemented by
279  * some drivers to improve latency under low packet rates and
280  * improve throughput under high packet rates. Some drivers
281  * only implement one of RX or TX adaptive coalescing. Anything
282  * not implemented by the driver causes these values to be
283  * silently ignored.
284  */
285  u32 use_adaptive_rx_coalesce;
286  u32 use_adaptive_tx_coalesce;
287 
288  /* When the packet rate (measured in packets per second)
289  * is below pkt_rate_low, the {rx,tx}_*_low parameters are
290  * used.
291  */
292  u32 pkt_rate_low;
293  u32 rx_coalesce_usecs_low;
294  u32 rx_max_coalesced_frames_low;
295  u32 tx_coalesce_usecs_low;
296  u32 tx_max_coalesced_frames_low;
297 
298  /* When the packet rate is below pkt_rate_high but above
299  * pkt_rate_low (both measured in packets per second) the
300  * normal {rx,tx}_* coalescing parameters are used.
301  */
302 
303  /* When the packet rate is (measured in packets per second)
304  * is above pkt_rate_high, the {rx,tx}_*_high parameters are
305  * used.
306  */
307  u32 pkt_rate_high;
308  u32 rx_coalesce_usecs_high;
309  u32 rx_max_coalesced_frames_high;
310  u32 tx_coalesce_usecs_high;
311  u32 tx_max_coalesced_frames_high;
312 
313  /* How often to do adaptive coalescing packet rate sampling,
314  * measured in seconds. Must not be zero.
315  */
316  u32 rate_sample_interval;
317 };
318 #endif
319 #ifndef ETHTOOL_SCOALESCE
320 #define ETHTOOL_SCOALESCE 0x0000000f /* Set coalesce config. */
321 #endif
322 #ifndef ETHTOOL_GRINGPARAM
323 #define ETHTOOL_GRINGPARAM 0x00000010 /* Get ring parameters */
324 /* for configuring RX/TX ring parameters */
325 #define ethtool_ringparam _kc_ethtool_ringparam
326 struct _kc_ethtool_ringparam {
327  u32 cmd; /* ETHTOOL_{G,S}RINGPARAM */
328 
329  /* Read only attributes. These indicate the maximum number
330  * of pending RX/TX ring entries the driver will allow the
331  * user to set.
332  */
333  u32 rx_max_pending;
334  u32 rx_mini_max_pending;
335  u32 rx_jumbo_max_pending;
336  u32 tx_max_pending;
337 
338  /* Values changeable by the user. The valid values are
339  * in the range 1 to the "*_max_pending" counterpart above.
340  */
341  u32 rx_pending;
342  u32 rx_mini_pending;
343  u32 rx_jumbo_pending;
344  u32 tx_pending;
345 };
346 #endif
347 #ifndef ETHTOOL_SRINGPARAM
348 #define ETHTOOL_SRINGPARAM 0x00000011 /* Set ring parameters, priv. */
349 #endif
350 #ifndef ETHTOOL_GPAUSEPARAM
351 #define ETHTOOL_GPAUSEPARAM 0x00000012 /* Get pause parameters */
352 /* for configuring link flow control parameters */
353 #define ethtool_pauseparam _kc_ethtool_pauseparam
354 struct _kc_ethtool_pauseparam {
355  u32 cmd; /* ETHTOOL_{G,S}PAUSEPARAM */
356 
357  /* If the link is being auto-negotiated (via ethtool_cmd.autoneg
358  * being true) the user may set 'autonet' here non-zero to have the
359  * pause parameters be auto-negotiated too. In such a case, the
360  * {rx,tx}_pause values below determine what capabilities are
361  * advertised.
362  *
363  * If 'autoneg' is zero or the link is not being auto-negotiated,
364  * then {rx,tx}_pause force the driver to use/not-use pause
365  * flow control.
366  */
367  u32 autoneg;
368  u32 rx_pause;
369  u32 tx_pause;
370 };
371 #endif
372 #ifndef ETHTOOL_SPAUSEPARAM
373 #define ETHTOOL_SPAUSEPARAM 0x00000013 /* Set pause parameters. */
374 #endif
375 #ifndef ETHTOOL_GRXCSUM
376 #define ETHTOOL_GRXCSUM 0x00000014 /* Get RX hw csum enable (ethtool_value) */
377 #endif
378 #ifndef ETHTOOL_SRXCSUM
379 #define ETHTOOL_SRXCSUM 0x00000015 /* Set RX hw csum enable (ethtool_value) */
380 #endif
381 #ifndef ETHTOOL_GTXCSUM
382 #define ETHTOOL_GTXCSUM 0x00000016 /* Get TX hw csum enable (ethtool_value) */
383 #endif
384 #ifndef ETHTOOL_STXCSUM
385 #define ETHTOOL_STXCSUM 0x00000017 /* Set TX hw csum enable (ethtool_value) */
386 #endif
387 #ifndef ETHTOOL_GSG
388 #define ETHTOOL_GSG 0x00000018 /* Get scatter-gather enable
389  * (ethtool_value) */
390 #endif
391 #ifndef ETHTOOL_SSG
392 #define ETHTOOL_SSG 0x00000019 /* Set scatter-gather enable
393  * (ethtool_value). */
394 #endif
395 #ifndef ETHTOOL_TEST
396 #define ETHTOOL_TEST 0x0000001a /* execute NIC self-test, priv. */
397 #endif
398 #ifndef ETHTOOL_GSTRINGS
399 #define ETHTOOL_GSTRINGS 0x0000001b /* get specified string set */
400 #endif
401 #ifndef ETHTOOL_PHYS_ID
402 #define ETHTOOL_PHYS_ID 0x0000001c /* identify the NIC */
403 #endif
404 #ifndef ETHTOOL_GSTATS
405 #define ETHTOOL_GSTATS 0x0000001d /* get NIC-specific statistics */
406 #endif
407 #ifndef ETHTOOL_GTSO
408 #define ETHTOOL_GTSO 0x0000001e /* Get TSO enable (ethtool_value) */
409 #endif
410 #ifndef ETHTOOL_STSO
411 #define ETHTOOL_STSO 0x0000001f /* Set TSO enable (ethtool_value) */
412 #endif
413 
414 #ifndef NET_IP_ALIGN
415 #define NET_IP_ALIGN 2
416 #endif
417 
418 #ifndef NETDEV_TX_OK
419 #define NETDEV_TX_OK 0 /* driver took care of the packet */
420 #endif
421 
422 #ifndef NETDEV_TX_BUSY
423 #define NETDEV_TX_BUSY 1 /* driver tx path was busy */
424 #endif
425 
426 #ifndef NETDEV_TX_LOCKED
427 #define NETDEV_TX_LOCKED -1 /* driver tx lock was already taken */
428 #endif
429 
430 /* if we do not have the infrastructure to detect if skb_header is cloned *
431  * just return false in all cases */
432 #ifndef SKB_DATAREF_SHIFT
433 #define skb_header_cloned(x) 0
434 #endif /* SKB_DATAREF_SHIFT not defined */
435 
436 #ifndef WARN_ON
437 #define WARN_ON(x)
438 #endif
439 
440 #define USE_DRIVER_SHUTDOWN_HANDLER
441 
442 #ifndef SA_PROBEIRQ
443 #define SA_PROBEIRQ 0
444 #endif
445 
446 #endif /* _KCOMPAT_H_ */