Xenomai  3.0.8
kcompat.h
1 /*******************************************************************************
2 
3  Intel PRO/1000 Linux driver
4  Copyright(c) 1999 - 2008 Intel Corporation.
5 
6  This program is free software; you can redistribute it and/or modify it
7  under the terms and conditions of the GNU General Public License,
8  version 2, as published by the Free Software Foundation.
9 
10  This program is distributed in the hope it will be useful, but WITHOUT
11  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13  more details.
14 
15  You should have received a copy of the GNU General Public License along with
16  this program; if not, write to the Free Software Foundation, Inc.,
17  51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
18 
19  The full GNU General Public License is included in this distribution in
20  the file called "COPYING".
21 
22  Contact Information:
23  Linux NICS <linux.nics@intel.com>
24  e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
25  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26 
27 *******************************************************************************/
28 
29 #ifndef _KCOMPAT_H_
30 #define _KCOMPAT_H_
31 
32 #include <linux/version.h>
33 #include <linux/init.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/etherdevice.h>
40 #include <linux/skbuff.h>
41 #include <linux/ioport.h>
42 #include <linux/slab.h>
43 #include <linux/list.h>
44 #include <linux/delay.h>
45 #include <linux/sched.h>
46 #include <linux/in.h>
47 #include <linux/ip.h>
48 #include <linux/udp.h>
49 #include <linux/mii.h>
50 #include <asm/io.h>
51 
52 #include <rtnet_port.h>
53 /* NAPI enable/disable flags here */
54 
55 
56 #ifdef _E1000_H_
57 #ifdef CONFIG_E1000_NAPI
58 #define NAPI
59 #endif
60 #ifdef E1000_NAPI
61 #undef NAPI
62 #define NAPI
63 #endif
64 #ifdef E1000_NO_NAPI
65 #undef NAPI
66 #endif
67 #endif
68 
69 #ifdef _IGB_H_
70 #define NAPI
71 #endif
72 
73 #ifdef _IXGB_H_
74 #ifdef CONFIG_IXGB_NAPI
75 #define NAPI
76 #endif
77 #ifdef IXGB_NAPI
78 #undef NAPI
79 #define NAPI
80 #endif
81 #ifdef IXGB_NO_NAPI
82 #undef NAPI
83 #endif
84 #endif
85 
86 
87 #ifdef DRIVER_E1000
88 #define adapter_struct e1000_adapter
89 #endif
90 
91 
92 // RTNET settings
93 #ifdef NAPI
94 #undef NAPI
95 #endif
96 
97 #undef NETIF_F_TSO
98 #undef NETIF_F_HW_VLAN_TX
99 #undef CONFIG_NET_POLL_CONTROLLER
100 #ifdef ETHTOOL_GPERMADDR
101 #undef ETHTOOL_GPERMADDR
102 #endif
103 
104 
105 /* and finally set defines so that the code sees the changes */
106 #ifdef NAPI
107 #ifndef CONFIG_E1000_NAPI
108 #define CONFIG_E1000_NAPI
109 #endif
110 #ifndef CONFIG_IXGB_NAPI
111 #define CONFIG_IXGB_NAPI
112 #endif
113 #else
114 #undef CONFIG_E1000_NAPI
115 #undef CONFIG_IXGB_NAPI
116 #endif
117 
118 /* packet split disable/enable */
119 #ifdef DISABLE_PACKET_SPLIT
120 #undef CONFIG_E1000_DISABLE_PACKET_SPLIT
121 #define CONFIG_E1000_DISABLE_PACKET_SPLIT
122 #endif
123 
124 /* MSI compatibility code for all kernels and drivers */
125 #ifdef DISABLE_PCI_MSI
126 #undef CONFIG_PCI_MSI
127 #endif
128 
129 #ifdef DISABLE_PM
130 #undef CONFIG_PM
131 #endif
132 
133 #ifdef DISABLE_NET_POLL_CONTROLLER
134 #undef CONFIG_NET_POLL_CONTROLLER
135 #endif
136 
137 #ifndef PMSG_SUSPEND
138 #define PMSG_SUSPEND 3
139 #endif
140 
141 /* generic boolean compatibility */
142 #undef TRUE
143 #undef FALSE
144 #define TRUE true
145 #define FALSE false
146 #ifdef GCC_VERSION
147 #if ( GCC_VERSION < 3000 )
148 #define _Bool char
149 #endif
150 #endif
151 #ifndef bool
152 #define bool _Bool
153 #define true 1
154 #define false 0
155 #endif
156 
157 
158 #ifndef module_param
159 #define module_param(v,t,p) MODULE_PARM(v, "i");
160 #endif
161 
162 #ifndef DMA_64BIT_MASK
163 #define DMA_64BIT_MASK 0xffffffffffffffffULL
164 #endif
165 
166 #ifndef DMA_32BIT_MASK
167 #define DMA_32BIT_MASK 0x00000000ffffffffULL
168 #endif
169 
170 #ifndef PCI_CAP_ID_EXP
171 #define PCI_CAP_ID_EXP 0x10
172 #endif
173 
174 #ifndef mmiowb
175 #ifdef CONFIG_IA64
176 #define mmiowb() asm volatile ("mf.a" ::: "memory")
177 #else
178 #define mmiowb()
179 #endif
180 #endif
181 
182 #ifndef SET_NETDEV_DEV
183 #define SET_NETDEV_DEV(net, pdev)
184 #endif
185 
186 #ifndef HAVE_FREE_NETDEV
187 #define free_netdev(x) kfree(x)
188 #endif
189 
190 #ifdef HAVE_POLL_CONTROLLER
191 #define CONFIG_NET_POLL_CONTROLLER
192 #endif
193 
194 #ifndef NETDEV_TX_OK
195 #define NETDEV_TX_OK 0
196 #endif
197 
198 #ifndef NETDEV_TX_BUSY
199 #define NETDEV_TX_BUSY 1
200 #endif
201 
202 #ifndef NETDEV_TX_LOCKED
203 #define NETDEV_TX_LOCKED -1
204 #endif
205 
206 #ifndef SKB_DATAREF_SHIFT
207 /* if we do not have the infrastructure to detect if skb_header is cloned
208  just return false in all cases */
209 #define skb_header_cloned(x) 0
210 #endif
211 
212 #ifndef NETIF_F_GSO
213 #define gso_size tso_size
214 #define gso_segs tso_segs
215 #endif
216 
217 #ifndef CHECKSUM_PARTIAL
218 #define CHECKSUM_PARTIAL CHECKSUM_HW
219 #define CHECKSUM_COMPLETE CHECKSUM_HW
220 #endif
221 
222 #ifndef __read_mostly
223 #define __read_mostly
224 #endif
225 
226 #ifndef MII_RESV1
227 #define MII_RESV1 0x17 /* Reserved... */
228 #endif
229 
230 #ifndef unlikely
231 #define unlikely(_x) _x
232 #define likely(_x) _x
233 #endif
234 
235 #ifndef WARN_ON
236 #define WARN_ON(x)
237 #endif
238 
239 #ifndef PCI_DEVICE
240 #define PCI_DEVICE(vend,dev) \
241  .vendor = (vend), .device = (dev), \
242  .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID
243 #endif
244 
245 #ifndef num_online_cpus
246 #define num_online_cpus() smp_num_cpus
247 #endif
248 
249 #ifndef _LINUX_RANDOM_H
250 #include <linux/random.h>
251 #endif
252 
253 #ifndef DECLARE_BITMAP
254 #ifndef BITS_TO_LONGS
255 #define BITS_TO_LONGS(bits) (((bits)+BITS_PER_LONG-1)/BITS_PER_LONG)
256 #endif
257 #define DECLARE_BITMAP(name,bits) long name[BITS_TO_LONGS(bits)]
258 #endif
259 
260 #ifndef VLAN_HLEN
261 #define VLAN_HLEN 4
262 #endif
263 
264 #ifndef VLAN_ETH_HLEN
265 #define VLAN_ETH_HLEN 18
266 #endif
267 
268 #ifndef VLAN_ETH_FRAME_LEN
269 #define VLAN_ETH_FRAME_LEN 1518
270 #endif
271 
272 
273 /*****************************************************************************/
274 /* Installations with ethtool version without eeprom, adapter id, or statistics
275  * support */
276 
277 #ifndef ETH_GSTRING_LEN
278 #define ETH_GSTRING_LEN 32
279 #endif
280 
281 #ifndef ETHTOOL_GSTATS
282 #define ETHTOOL_GSTATS 0x1d
283 #undef ethtool_drvinfo
284 #define ethtool_drvinfo k_ethtool_drvinfo
285 struct k_ethtool_drvinfo {
286  u32 cmd;
287  char driver[32];
288  char version[32];
289  char fw_version[32];
290  char bus_info[32];
291  char reserved1[32];
292  char reserved2[16];
293  u32 n_stats;
294  u32 testinfo_len;
295  u32 eedump_len;
296  u32 regdump_len;
297 };
298 
299 struct ethtool_stats {
300  u32 cmd;
301  u32 n_stats;
302  u64 data[0];
303 };
304 #endif /* ETHTOOL_GSTATS */
305 
306 #ifndef ETHTOOL_PHYS_ID
307 #define ETHTOOL_PHYS_ID 0x1c
308 #endif /* ETHTOOL_PHYS_ID */
309 
310 #ifndef ETHTOOL_GSTRINGS
311 #define ETHTOOL_GSTRINGS 0x1b
312 enum ethtool_stringset {
313  ETH_SS_TEST = 0,
314  ETH_SS_STATS,
315 };
316 struct ethtool_gstrings {
317  u32 cmd; /* ETHTOOL_GSTRINGS */
318  u32 string_set; /* string set id e.c. ETH_SS_TEST, etc*/
319  u32 len; /* number of strings in the string set */
320  u8 data[0];
321 };
322 #endif /* ETHTOOL_GSTRINGS */
323 
324 #ifndef ETHTOOL_TEST
325 #define ETHTOOL_TEST 0x1a
326 enum ethtool_test_flags {
327  ETH_TEST_FL_OFFLINE = (1 << 0),
328  ETH_TEST_FL_FAILED = (1 << 1),
329 };
330 struct ethtool_test {
331  u32 cmd;
332  u32 flags;
333  u32 reserved;
334  u32 len;
335  u64 data[0];
336 };
337 #endif /* ETHTOOL_TEST */
338 
339 #ifndef ETHTOOL_GEEPROM
340 #define ETHTOOL_GEEPROM 0xb
341 #undef ETHTOOL_GREGS
342 struct ethtool_eeprom {
343  u32 cmd;
344  u32 magic;
345  u32 offset;
346  u32 len;
347  u8 data[0];
348 };
349 
350 struct ethtool_value {
351  u32 cmd;
352  u32 data;
353 };
354 #endif /* ETHTOOL_GEEPROM */
355 
356 #ifndef ETHTOOL_GLINK
357 #define ETHTOOL_GLINK 0xa
358 #endif /* ETHTOOL_GLINK */
359 
360 #ifndef ETHTOOL_GREGS
361 #define ETHTOOL_GREGS 0x00000004 /* Get NIC registers */
362 #define ethtool_regs _kc_ethtool_regs
363 /* for passing big chunks of data */
364 struct _kc_ethtool_regs {
365  u32 cmd;
366  u32 version; /* driver-specific, indicates different chips/revs */
367  u32 len; /* bytes */
368  u8 data[0];
369 };
370 #endif /* ETHTOOL_GREGS */
371 
372 #ifndef ETHTOOL_GMSGLVL
373 #define ETHTOOL_GMSGLVL 0x00000007 /* Get driver message level */
374 #endif
375 #ifndef ETHTOOL_SMSGLVL
376 #define ETHTOOL_SMSGLVL 0x00000008 /* Set driver msg level, priv. */
377 #endif
378 #ifndef ETHTOOL_NWAY_RST
379 #define ETHTOOL_NWAY_RST 0x00000009 /* Restart autonegotiation, priv */
380 #endif
381 #ifndef ETHTOOL_GLINK
382 #define ETHTOOL_GLINK 0x0000000a /* Get link status */
383 #endif
384 #ifndef ETHTOOL_GEEPROM
385 #define ETHTOOL_GEEPROM 0x0000000b /* Get EEPROM data */
386 #endif
387 #ifndef ETHTOOL_SEEPROM
388 #define ETHTOOL_SEEPROM 0x0000000c /* Set EEPROM data */
389 #endif
390 #ifndef ETHTOOL_GCOALESCE
391 #define ETHTOOL_GCOALESCE 0x0000000e /* Get coalesce config */
392 /* for configuring coalescing parameters of chip */
393 #define ethtool_coalesce _kc_ethtool_coalesce
394 struct _kc_ethtool_coalesce {
395  u32 cmd; /* ETHTOOL_{G,S}COALESCE */
396 
397  /* How many usecs to delay an RX interrupt after
398  * a packet arrives. If 0, only rx_max_coalesced_frames
399  * is used.
400  */
401  u32 rx_coalesce_usecs;
402 
403  /* How many packets to delay an RX interrupt after
404  * a packet arrives. If 0, only rx_coalesce_usecs is
405  * used. It is illegal to set both usecs and max frames
406  * to zero as this would cause RX interrupts to never be
407  * generated.
408  */
409  u32 rx_max_coalesced_frames;
410 
411  /* Same as above two parameters, except that these values
412  * apply while an IRQ is being serviced by the host. Not
413  * all cards support this feature and the values are ignored
414  * in that case.
415  */
416  u32 rx_coalesce_usecs_irq;
417  u32 rx_max_coalesced_frames_irq;
418 
419  /* How many usecs to delay a TX interrupt after
420  * a packet is sent. If 0, only tx_max_coalesced_frames
421  * is used.
422  */
423  u32 tx_coalesce_usecs;
424 
425  /* How many packets to delay a TX interrupt after
426  * a packet is sent. If 0, only tx_coalesce_usecs is
427  * used. It is illegal to set both usecs and max frames
428  * to zero as this would cause TX interrupts to never be
429  * generated.
430  */
431  u32 tx_max_coalesced_frames;
432 
433  /* Same as above two parameters, except that these values
434  * apply while an IRQ is being serviced by the host. Not
435  * all cards support this feature and the values are ignored
436  * in that case.
437  */
438  u32 tx_coalesce_usecs_irq;
439  u32 tx_max_coalesced_frames_irq;
440 
441  /* How many usecs to delay in-memory statistics
442  * block updates. Some drivers do not have an in-memory
443  * statistic block, and in such cases this value is ignored.
444  * This value must not be zero.
445  */
446  u32 stats_block_coalesce_usecs;
447 
448  /* Adaptive RX/TX coalescing is an algorithm implemented by
449  * some drivers to improve latency under low packet rates and
450  * improve throughput under high packet rates. Some drivers
451  * only implement one of RX or TX adaptive coalescing. Anything
452  * not implemented by the driver causes these values to be
453  * silently ignored.
454  */
455  u32 use_adaptive_rx_coalesce;
456  u32 use_adaptive_tx_coalesce;
457 
458  /* When the packet rate (measured in packets per second)
459  * is below pkt_rate_low, the {rx,tx}_*_low parameters are
460  * used.
461  */
462  u32 pkt_rate_low;
463  u32 rx_coalesce_usecs_low;
464  u32 rx_max_coalesced_frames_low;
465  u32 tx_coalesce_usecs_low;
466  u32 tx_max_coalesced_frames_low;
467 
468  /* When the packet rate is below pkt_rate_high but above
469  * pkt_rate_low (both measured in packets per second) the
470  * normal {rx,tx}_* coalescing parameters are used.
471  */
472 
473  /* When the packet rate is (measured in packets per second)
474  * is above pkt_rate_high, the {rx,tx}_*_high parameters are
475  * used.
476  */
477  u32 pkt_rate_high;
478  u32 rx_coalesce_usecs_high;
479  u32 rx_max_coalesced_frames_high;
480  u32 tx_coalesce_usecs_high;
481  u32 tx_max_coalesced_frames_high;
482 
483  /* How often to do adaptive coalescing packet rate sampling,
484  * measured in seconds. Must not be zero.
485  */
486  u32 rate_sample_interval;
487 };
488 #endif /* ETHTOOL_GCOALESCE */
489 
490 #ifndef ETHTOOL_SCOALESCE
491 #define ETHTOOL_SCOALESCE 0x0000000f /* Set coalesce config. */
492 #endif
493 #ifndef ETHTOOL_GRINGPARAM
494 #define ETHTOOL_GRINGPARAM 0x00000010 /* Get ring parameters */
495 /* for configuring RX/TX ring parameters */
496 #define ethtool_ringparam _kc_ethtool_ringparam
497 struct _kc_ethtool_ringparam {
498  u32 cmd; /* ETHTOOL_{G,S}RINGPARAM */
499 
500  /* Read only attributes. These indicate the maximum number
501  * of pending RX/TX ring entries the driver will allow the
502  * user to set.
503  */
504  u32 rx_max_pending;
505  u32 rx_mini_max_pending;
506  u32 rx_jumbo_max_pending;
507  u32 tx_max_pending;
508 
509  /* Values changeable by the user. The valid values are
510  * in the range 1 to the "*_max_pending" counterpart above.
511  */
512  u32 rx_pending;
513  u32 rx_mini_pending;
514  u32 rx_jumbo_pending;
515  u32 tx_pending;
516 };
517 #endif /* ETHTOOL_GRINGPARAM */
518 
519 #ifndef ETHTOOL_SRINGPARAM
520 #define ETHTOOL_SRINGPARAM 0x00000011 /* Set ring parameters, priv. */
521 #endif
522 #ifndef ETHTOOL_GPAUSEPARAM
523 #define ETHTOOL_GPAUSEPARAM 0x00000012 /* Get pause parameters */
524 /* for configuring link flow control parameters */
525 #define ethtool_pauseparam _kc_ethtool_pauseparam
526 struct _kc_ethtool_pauseparam {
527  u32 cmd; /* ETHTOOL_{G,S}PAUSEPARAM */
528 
529  /* If the link is being auto-negotiated (via ethtool_cmd.autoneg
530  * being true) the user may set 'autoneg' here non-zero to have the
531  * pause parameters be auto-negotiated too. In such a case, the
532  * {rx,tx}_pause values below determine what capabilities are
533  * advertised.
534  *
535  * If 'autoneg' is zero or the link is not being auto-negotiated,
536  * then {rx,tx}_pause force the driver to use/not-use pause
537  * flow control.
538  */
539  u32 autoneg;
540  u32 rx_pause;
541  u32 tx_pause;
542 };
543 #endif /* ETHTOOL_GPAUSEPARAM */
544 
545 #ifndef ETHTOOL_SPAUSEPARAM
546 #define ETHTOOL_SPAUSEPARAM 0x00000013 /* Set pause parameters. */
547 #endif
548 #ifndef ETHTOOL_GRXCSUM
549 #define ETHTOOL_GRXCSUM 0x00000014 /* Get RX hw csum enable (ethtool_value) */
550 #endif
551 #ifndef ETHTOOL_SRXCSUM
552 #define ETHTOOL_SRXCSUM 0x00000015 /* Set RX hw csum enable (ethtool_value) */
553 #endif
554 #ifndef ETHTOOL_GTXCSUM
555 #define ETHTOOL_GTXCSUM 0x00000016 /* Get TX hw csum enable (ethtool_value) */
556 #endif
557 #ifndef ETHTOOL_STXCSUM
558 #define ETHTOOL_STXCSUM 0x00000017 /* Set TX hw csum enable (ethtool_value) */
559 #endif
560 #ifndef ETHTOOL_GSG
561 #define ETHTOOL_GSG 0x00000018 /* Get scatter-gather enable
562  * (ethtool_value) */
563 #endif
564 #ifndef ETHTOOL_SSG
565 #define ETHTOOL_SSG 0x00000019 /* Set scatter-gather enable
566  * (ethtool_value). */
567 #endif
568 #ifndef ETHTOOL_TEST
569 #define ETHTOOL_TEST 0x0000001a /* execute NIC self-test, priv. */
570 #endif
571 #ifndef ETHTOOL_GSTRINGS
572 #define ETHTOOL_GSTRINGS 0x0000001b /* get specified string set */
573 #endif
574 #ifndef ETHTOOL_PHYS_ID
575 #define ETHTOOL_PHYS_ID 0x0000001c /* identify the NIC */
576 #endif
577 #ifndef ETHTOOL_GSTATS
578 #define ETHTOOL_GSTATS 0x0000001d /* get NIC-specific statistics */
579 #endif
580 #ifndef ETHTOOL_GTSO
581 #define ETHTOOL_GTSO 0x0000001e /* Get TSO enable (ethtool_value) */
582 #endif
583 #ifndef ETHTOOL_STSO
584 #define ETHTOOL_STSO 0x0000001f /* Set TSO enable (ethtool_value) */
585 #endif
586 
587 #ifndef ETHTOOL_BUSINFO_LEN
588 #define ETHTOOL_BUSINFO_LEN 32
589 #endif
590 
591 #ifndef HAVE_PCI_SET_MWI
592 #define pci_set_mwi(X) pci_write_config_word(X, \
593  PCI_COMMAND, adapter->hw.bus.pci_cmd_word | \
594  PCI_COMMAND_INVALIDATE);
595 #define pci_clear_mwi(X) pci_write_config_word(X, \
596  PCI_COMMAND, adapter->hw.bus.pci_cmd_word & \
597  ~PCI_COMMAND_INVALIDATE);
598 #endif
599 
600 
601 #undef HAVE_PCI_ERS
602 
603 #endif /* _KCOMPAT_H_ */