Xenomai  3.0-rc7
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 #ifndef CONFIG_PCI_MSI
129 #define pci_enable_msi(a) -ENOTSUPP
130 #define pci_disable_msi(a) do {} while (0)
131 #define pci_enable_msix(a, b, c) -ENOTSUPP
132 #define pci_disable_msix(a) do {} while (0)
133 #define msi_remove_pci_irq_vectors(a) do {} while (0)
134 #endif /* CONFIG_PCI_MSI */
135 #ifdef DISABLE_PM
136 #undef CONFIG_PM
137 #endif
138 
139 #ifdef DISABLE_NET_POLL_CONTROLLER
140 #undef CONFIG_NET_POLL_CONTROLLER
141 #endif
142 
143 #ifndef PMSG_SUSPEND
144 #define PMSG_SUSPEND 3
145 #endif
146 
147 /* generic boolean compatibility */
148 #undef TRUE
149 #undef FALSE
150 #define TRUE true
151 #define FALSE false
152 #ifdef GCC_VERSION
153 #if ( GCC_VERSION < 3000 )
154 #define _Bool char
155 #endif
156 #endif
157 #ifndef bool
158 #define bool _Bool
159 #define true 1
160 #define false 0
161 #endif
162 
163 
164 #ifndef module_param
165 #define module_param(v,t,p) MODULE_PARM(v, "i");
166 #endif
167 
168 #ifndef DMA_64BIT_MASK
169 #define DMA_64BIT_MASK 0xffffffffffffffffULL
170 #endif
171 
172 #ifndef DMA_32BIT_MASK
173 #define DMA_32BIT_MASK 0x00000000ffffffffULL
174 #endif
175 
176 #ifndef PCI_CAP_ID_EXP
177 #define PCI_CAP_ID_EXP 0x10
178 #endif
179 
180 #ifndef mmiowb
181 #ifdef CONFIG_IA64
182 #define mmiowb() asm volatile ("mf.a" ::: "memory")
183 #else
184 #define mmiowb()
185 #endif
186 #endif
187 
188 #ifndef SET_NETDEV_DEV
189 #define SET_NETDEV_DEV(net, pdev)
190 #endif
191 
192 #ifndef HAVE_FREE_NETDEV
193 #define free_netdev(x) kfree(x)
194 #endif
195 
196 #ifdef HAVE_POLL_CONTROLLER
197 #define CONFIG_NET_POLL_CONTROLLER
198 #endif
199 
200 #ifndef NETDEV_TX_OK
201 #define NETDEV_TX_OK 0
202 #endif
203 
204 #ifndef NETDEV_TX_BUSY
205 #define NETDEV_TX_BUSY 1
206 #endif
207 
208 #ifndef NETDEV_TX_LOCKED
209 #define NETDEV_TX_LOCKED -1
210 #endif
211 
212 #ifndef SKB_DATAREF_SHIFT
213 /* if we do not have the infrastructure to detect if skb_header is cloned
214  just return false in all cases */
215 #define skb_header_cloned(x) 0
216 #endif
217 
218 #ifndef NETIF_F_GSO
219 #define gso_size tso_size
220 #define gso_segs tso_segs
221 #endif
222 
223 #ifndef CHECKSUM_PARTIAL
224 #define CHECKSUM_PARTIAL CHECKSUM_HW
225 #define CHECKSUM_COMPLETE CHECKSUM_HW
226 #endif
227 
228 #ifndef __read_mostly
229 #define __read_mostly
230 #endif
231 
232 #ifndef MII_RESV1
233 #define MII_RESV1 0x17 /* Reserved... */
234 #endif
235 
236 #ifndef unlikely
237 #define unlikely(_x) _x
238 #define likely(_x) _x
239 #endif
240 
241 #ifndef WARN_ON
242 #define WARN_ON(x)
243 #endif
244 
245 #ifndef PCI_DEVICE
246 #define PCI_DEVICE(vend,dev) \
247  .vendor = (vend), .device = (dev), \
248  .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID
249 #endif
250 
251 #ifndef num_online_cpus
252 #define num_online_cpus() smp_num_cpus
253 #endif
254 
255 #ifndef _LINUX_RANDOM_H
256 #include <linux/random.h>
257 #endif
258 
259 #ifndef DECLARE_BITMAP
260 #ifndef BITS_TO_LONGS
261 #define BITS_TO_LONGS(bits) (((bits)+BITS_PER_LONG-1)/BITS_PER_LONG)
262 #endif
263 #define DECLARE_BITMAP(name,bits) long name[BITS_TO_LONGS(bits)]
264 #endif
265 
266 #ifndef VLAN_HLEN
267 #define VLAN_HLEN 4
268 #endif
269 
270 #ifndef VLAN_ETH_HLEN
271 #define VLAN_ETH_HLEN 18
272 #endif
273 
274 #ifndef VLAN_ETH_FRAME_LEN
275 #define VLAN_ETH_FRAME_LEN 1518
276 #endif
277 
278 
279 /*****************************************************************************/
280 /* Installations with ethtool version without eeprom, adapter id, or statistics
281  * support */
282 
283 #ifndef ETH_GSTRING_LEN
284 #define ETH_GSTRING_LEN 32
285 #endif
286 
287 #ifndef ETHTOOL_GSTATS
288 #define ETHTOOL_GSTATS 0x1d
289 #undef ethtool_drvinfo
290 #define ethtool_drvinfo k_ethtool_drvinfo
291 struct k_ethtool_drvinfo {
292  u32 cmd;
293  char driver[32];
294  char version[32];
295  char fw_version[32];
296  char bus_info[32];
297  char reserved1[32];
298  char reserved2[16];
299  u32 n_stats;
300  u32 testinfo_len;
301  u32 eedump_len;
302  u32 regdump_len;
303 };
304 
305 struct ethtool_stats {
306  u32 cmd;
307  u32 n_stats;
308  u64 data[0];
309 };
310 #endif /* ETHTOOL_GSTATS */
311 
312 #ifndef ETHTOOL_PHYS_ID
313 #define ETHTOOL_PHYS_ID 0x1c
314 #endif /* ETHTOOL_PHYS_ID */
315 
316 #ifndef ETHTOOL_GSTRINGS
317 #define ETHTOOL_GSTRINGS 0x1b
318 enum ethtool_stringset {
319  ETH_SS_TEST = 0,
320  ETH_SS_STATS,
321 };
322 struct ethtool_gstrings {
323  u32 cmd; /* ETHTOOL_GSTRINGS */
324  u32 string_set; /* string set id e.c. ETH_SS_TEST, etc*/
325  u32 len; /* number of strings in the string set */
326  u8 data[0];
327 };
328 #endif /* ETHTOOL_GSTRINGS */
329 
330 #ifndef ETHTOOL_TEST
331 #define ETHTOOL_TEST 0x1a
332 enum ethtool_test_flags {
333  ETH_TEST_FL_OFFLINE = (1 << 0),
334  ETH_TEST_FL_FAILED = (1 << 1),
335 };
336 struct ethtool_test {
337  u32 cmd;
338  u32 flags;
339  u32 reserved;
340  u32 len;
341  u64 data[0];
342 };
343 #endif /* ETHTOOL_TEST */
344 
345 #ifndef ETHTOOL_GEEPROM
346 #define ETHTOOL_GEEPROM 0xb
347 #undef ETHTOOL_GREGS
348 struct ethtool_eeprom {
349  u32 cmd;
350  u32 magic;
351  u32 offset;
352  u32 len;
353  u8 data[0];
354 };
355 
356 struct ethtool_value {
357  u32 cmd;
358  u32 data;
359 };
360 #endif /* ETHTOOL_GEEPROM */
361 
362 #ifndef ETHTOOL_GLINK
363 #define ETHTOOL_GLINK 0xa
364 #endif /* ETHTOOL_GLINK */
365 
366 #ifndef ETHTOOL_GREGS
367 #define ETHTOOL_GREGS 0x00000004 /* Get NIC registers */
368 #define ethtool_regs _kc_ethtool_regs
369 /* for passing big chunks of data */
370 struct _kc_ethtool_regs {
371  u32 cmd;
372  u32 version; /* driver-specific, indicates different chips/revs */
373  u32 len; /* bytes */
374  u8 data[0];
375 };
376 #endif /* ETHTOOL_GREGS */
377 
378 #ifndef ETHTOOL_GMSGLVL
379 #define ETHTOOL_GMSGLVL 0x00000007 /* Get driver message level */
380 #endif
381 #ifndef ETHTOOL_SMSGLVL
382 #define ETHTOOL_SMSGLVL 0x00000008 /* Set driver msg level, priv. */
383 #endif
384 #ifndef ETHTOOL_NWAY_RST
385 #define ETHTOOL_NWAY_RST 0x00000009 /* Restart autonegotiation, priv */
386 #endif
387 #ifndef ETHTOOL_GLINK
388 #define ETHTOOL_GLINK 0x0000000a /* Get link status */
389 #endif
390 #ifndef ETHTOOL_GEEPROM
391 #define ETHTOOL_GEEPROM 0x0000000b /* Get EEPROM data */
392 #endif
393 #ifndef ETHTOOL_SEEPROM
394 #define ETHTOOL_SEEPROM 0x0000000c /* Set EEPROM data */
395 #endif
396 #ifndef ETHTOOL_GCOALESCE
397 #define ETHTOOL_GCOALESCE 0x0000000e /* Get coalesce config */
398 /* for configuring coalescing parameters of chip */
399 #define ethtool_coalesce _kc_ethtool_coalesce
400 struct _kc_ethtool_coalesce {
401  u32 cmd; /* ETHTOOL_{G,S}COALESCE */
402 
403  /* How many usecs to delay an RX interrupt after
404  * a packet arrives. If 0, only rx_max_coalesced_frames
405  * is used.
406  */
407  u32 rx_coalesce_usecs;
408 
409  /* How many packets to delay an RX interrupt after
410  * a packet arrives. If 0, only rx_coalesce_usecs is
411  * used. It is illegal to set both usecs and max frames
412  * to zero as this would cause RX interrupts to never be
413  * generated.
414  */
415  u32 rx_max_coalesced_frames;
416 
417  /* Same as above two parameters, except that these values
418  * apply while an IRQ is being serviced by the host. Not
419  * all cards support this feature and the values are ignored
420  * in that case.
421  */
422  u32 rx_coalesce_usecs_irq;
423  u32 rx_max_coalesced_frames_irq;
424 
425  /* How many usecs to delay a TX interrupt after
426  * a packet is sent. If 0, only tx_max_coalesced_frames
427  * is used.
428  */
429  u32 tx_coalesce_usecs;
430 
431  /* How many packets to delay a TX interrupt after
432  * a packet is sent. If 0, only tx_coalesce_usecs is
433  * used. It is illegal to set both usecs and max frames
434  * to zero as this would cause TX interrupts to never be
435  * generated.
436  */
437  u32 tx_max_coalesced_frames;
438 
439  /* Same as above two parameters, except that these values
440  * apply while an IRQ is being serviced by the host. Not
441  * all cards support this feature and the values are ignored
442  * in that case.
443  */
444  u32 tx_coalesce_usecs_irq;
445  u32 tx_max_coalesced_frames_irq;
446 
447  /* How many usecs to delay in-memory statistics
448  * block updates. Some drivers do not have an in-memory
449  * statistic block, and in such cases this value is ignored.
450  * This value must not be zero.
451  */
452  u32 stats_block_coalesce_usecs;
453 
454  /* Adaptive RX/TX coalescing is an algorithm implemented by
455  * some drivers to improve latency under low packet rates and
456  * improve throughput under high packet rates. Some drivers
457  * only implement one of RX or TX adaptive coalescing. Anything
458  * not implemented by the driver causes these values to be
459  * silently ignored.
460  */
461  u32 use_adaptive_rx_coalesce;
462  u32 use_adaptive_tx_coalesce;
463 
464  /* When the packet rate (measured in packets per second)
465  * is below pkt_rate_low, the {rx,tx}_*_low parameters are
466  * used.
467  */
468  u32 pkt_rate_low;
469  u32 rx_coalesce_usecs_low;
470  u32 rx_max_coalesced_frames_low;
471  u32 tx_coalesce_usecs_low;
472  u32 tx_max_coalesced_frames_low;
473 
474  /* When the packet rate is below pkt_rate_high but above
475  * pkt_rate_low (both measured in packets per second) the
476  * normal {rx,tx}_* coalescing parameters are used.
477  */
478 
479  /* When the packet rate is (measured in packets per second)
480  * is above pkt_rate_high, the {rx,tx}_*_high parameters are
481  * used.
482  */
483  u32 pkt_rate_high;
484  u32 rx_coalesce_usecs_high;
485  u32 rx_max_coalesced_frames_high;
486  u32 tx_coalesce_usecs_high;
487  u32 tx_max_coalesced_frames_high;
488 
489  /* How often to do adaptive coalescing packet rate sampling,
490  * measured in seconds. Must not be zero.
491  */
492  u32 rate_sample_interval;
493 };
494 #endif /* ETHTOOL_GCOALESCE */
495 
496 #ifndef ETHTOOL_SCOALESCE
497 #define ETHTOOL_SCOALESCE 0x0000000f /* Set coalesce config. */
498 #endif
499 #ifndef ETHTOOL_GRINGPARAM
500 #define ETHTOOL_GRINGPARAM 0x00000010 /* Get ring parameters */
501 /* for configuring RX/TX ring parameters */
502 #define ethtool_ringparam _kc_ethtool_ringparam
503 struct _kc_ethtool_ringparam {
504  u32 cmd; /* ETHTOOL_{G,S}RINGPARAM */
505 
506  /* Read only attributes. These indicate the maximum number
507  * of pending RX/TX ring entries the driver will allow the
508  * user to set.
509  */
510  u32 rx_max_pending;
511  u32 rx_mini_max_pending;
512  u32 rx_jumbo_max_pending;
513  u32 tx_max_pending;
514 
515  /* Values changeable by the user. The valid values are
516  * in the range 1 to the "*_max_pending" counterpart above.
517  */
518  u32 rx_pending;
519  u32 rx_mini_pending;
520  u32 rx_jumbo_pending;
521  u32 tx_pending;
522 };
523 #endif /* ETHTOOL_GRINGPARAM */
524 
525 #ifndef ETHTOOL_SRINGPARAM
526 #define ETHTOOL_SRINGPARAM 0x00000011 /* Set ring parameters, priv. */
527 #endif
528 #ifndef ETHTOOL_GPAUSEPARAM
529 #define ETHTOOL_GPAUSEPARAM 0x00000012 /* Get pause parameters */
530 /* for configuring link flow control parameters */
531 #define ethtool_pauseparam _kc_ethtool_pauseparam
532 struct _kc_ethtool_pauseparam {
533  u32 cmd; /* ETHTOOL_{G,S}PAUSEPARAM */
534 
535  /* If the link is being auto-negotiated (via ethtool_cmd.autoneg
536  * being true) the user may set 'autoneg' here non-zero to have the
537  * pause parameters be auto-negotiated too. In such a case, the
538  * {rx,tx}_pause values below determine what capabilities are
539  * advertised.
540  *
541  * If 'autoneg' is zero or the link is not being auto-negotiated,
542  * then {rx,tx}_pause force the driver to use/not-use pause
543  * flow control.
544  */
545  u32 autoneg;
546  u32 rx_pause;
547  u32 tx_pause;
548 };
549 #endif /* ETHTOOL_GPAUSEPARAM */
550 
551 #ifndef ETHTOOL_SPAUSEPARAM
552 #define ETHTOOL_SPAUSEPARAM 0x00000013 /* Set pause parameters. */
553 #endif
554 #ifndef ETHTOOL_GRXCSUM
555 #define ETHTOOL_GRXCSUM 0x00000014 /* Get RX hw csum enable (ethtool_value) */
556 #endif
557 #ifndef ETHTOOL_SRXCSUM
558 #define ETHTOOL_SRXCSUM 0x00000015 /* Set RX hw csum enable (ethtool_value) */
559 #endif
560 #ifndef ETHTOOL_GTXCSUM
561 #define ETHTOOL_GTXCSUM 0x00000016 /* Get TX hw csum enable (ethtool_value) */
562 #endif
563 #ifndef ETHTOOL_STXCSUM
564 #define ETHTOOL_STXCSUM 0x00000017 /* Set TX hw csum enable (ethtool_value) */
565 #endif
566 #ifndef ETHTOOL_GSG
567 #define ETHTOOL_GSG 0x00000018 /* Get scatter-gather enable
568  * (ethtool_value) */
569 #endif
570 #ifndef ETHTOOL_SSG
571 #define ETHTOOL_SSG 0x00000019 /* Set scatter-gather enable
572  * (ethtool_value). */
573 #endif
574 #ifndef ETHTOOL_TEST
575 #define ETHTOOL_TEST 0x0000001a /* execute NIC self-test, priv. */
576 #endif
577 #ifndef ETHTOOL_GSTRINGS
578 #define ETHTOOL_GSTRINGS 0x0000001b /* get specified string set */
579 #endif
580 #ifndef ETHTOOL_PHYS_ID
581 #define ETHTOOL_PHYS_ID 0x0000001c /* identify the NIC */
582 #endif
583 #ifndef ETHTOOL_GSTATS
584 #define ETHTOOL_GSTATS 0x0000001d /* get NIC-specific statistics */
585 #endif
586 #ifndef ETHTOOL_GTSO
587 #define ETHTOOL_GTSO 0x0000001e /* Get TSO enable (ethtool_value) */
588 #endif
589 #ifndef ETHTOOL_STSO
590 #define ETHTOOL_STSO 0x0000001f /* Set TSO enable (ethtool_value) */
591 #endif
592 
593 #ifndef ETHTOOL_BUSINFO_LEN
594 #define ETHTOOL_BUSINFO_LEN 32
595 #endif
596 
597 #ifndef HAVE_PCI_SET_MWI
598 #define pci_set_mwi(X) pci_write_config_word(X, \
599  PCI_COMMAND, adapter->hw.bus.pci_cmd_word | \
600  PCI_COMMAND_INVALIDATE);
601 #define pci_clear_mwi(X) pci_write_config_word(X, \
602  PCI_COMMAND, adapter->hw.bus.pci_cmd_word & \
603  ~PCI_COMMAND_INVALIDATE);
604 #endif
605 
606 
607 #undef HAVE_PCI_ERS
608 
609 #endif /* _KCOMPAT_H_ */