📄 kcompat.h
字号:
/* When the packet rate is (measured in packets per second) * is above pkt_rate_high, the {rx,tx}_*_high parameters are * used. */ u32 pkt_rate_high; u32 rx_coalesce_usecs_high; u32 rx_max_coalesced_frames_high; u32 tx_coalesce_usecs_high; u32 tx_max_coalesced_frames_high; /* How often to do adaptive coalescing packet rate sampling, * measured in seconds. Must not be zero. */ u32 rate_sample_interval;};#endif /* ETHTOOL_GCOALESCE */#ifndef ETHTOOL_SCOALESCE#define ETHTOOL_SCOALESCE 0x0000000f /* Set coalesce config. */#endif#ifndef ETHTOOL_GRINGPARAM#define ETHTOOL_GRINGPARAM 0x00000010 /* Get ring parameters *//* for configuring RX/TX ring parameters */#define ethtool_ringparam _kc_ethtool_ringparamstruct _kc_ethtool_ringparam { u32 cmd; /* ETHTOOL_{G,S}RINGPARAM */ /* Read only attributes. These indicate the maximum number * of pending RX/TX ring entries the driver will allow the * user to set. */ u32 rx_max_pending; u32 rx_mini_max_pending; u32 rx_jumbo_max_pending; u32 tx_max_pending; /* Values changeable by the user. The valid values are * in the range 1 to the "*_max_pending" counterpart above. */ u32 rx_pending; u32 rx_mini_pending; u32 rx_jumbo_pending; u32 tx_pending;};#endif /* ETHTOOL_GRINGPARAM */#ifndef ETHTOOL_SRINGPARAM#define ETHTOOL_SRINGPARAM 0x00000011 /* Set ring parameters, priv. */#endif#ifndef ETHTOOL_GPAUSEPARAM#define ETHTOOL_GPAUSEPARAM 0x00000012 /* Get pause parameters *//* for configuring link flow control parameters */#define ethtool_pauseparam _kc_ethtool_pauseparamstruct _kc_ethtool_pauseparam { u32 cmd; /* ETHTOOL_{G,S}PAUSEPARAM */ /* If the link is being auto-negotiated (via ethtool_cmd.autoneg * being true) the user may set 'autoneg' here non-zero to have the * pause parameters be auto-negotiated too. In such a case, the * {rx,tx}_pause values below determine what capabilities are * advertised. * * If 'autoneg' is zero or the link is not being auto-negotiated, * then {rx,tx}_pause force the driver to use/not-use pause * flow control. */ u32 autoneg; u32 rx_pause; u32 tx_pause;};#endif /* ETHTOOL_GPAUSEPARAM */#ifndef ETHTOOL_SPAUSEPARAM#define ETHTOOL_SPAUSEPARAM 0x00000013 /* Set pause parameters. */#endif#ifndef ETHTOOL_GRXCSUM#define ETHTOOL_GRXCSUM 0x00000014 /* Get RX hw csum enable (ethtool_value) */#endif#ifndef ETHTOOL_SRXCSUM#define ETHTOOL_SRXCSUM 0x00000015 /* Set RX hw csum enable (ethtool_value) */#endif#ifndef ETHTOOL_GTXCSUM#define ETHTOOL_GTXCSUM 0x00000016 /* Get TX hw csum enable (ethtool_value) */#endif#ifndef ETHTOOL_STXCSUM#define ETHTOOL_STXCSUM 0x00000017 /* Set TX hw csum enable (ethtool_value) */#endif#ifndef ETHTOOL_GSG#define ETHTOOL_GSG 0x00000018 /* Get scatter-gather enable * (ethtool_value) */#endif#ifndef ETHTOOL_SSG#define ETHTOOL_SSG 0x00000019 /* Set scatter-gather enable * (ethtool_value). */#endif#ifndef ETHTOOL_TEST#define ETHTOOL_TEST 0x0000001a /* execute NIC self-test, priv. */#endif#ifndef ETHTOOL_GSTRINGS#define ETHTOOL_GSTRINGS 0x0000001b /* get specified string set */#endif#ifndef ETHTOOL_PHYS_ID#define ETHTOOL_PHYS_ID 0x0000001c /* identify the NIC */#endif#ifndef ETHTOOL_GSTATS#define ETHTOOL_GSTATS 0x0000001d /* get NIC-specific statistics */#endif#ifndef ETHTOOL_GTSO#define ETHTOOL_GTSO 0x0000001e /* Get TSO enable (ethtool_value) */#endif#ifndef ETHTOOL_STSO#define ETHTOOL_STSO 0x0000001f /* Set TSO enable (ethtool_value) */#endif#ifndef ETHTOOL_BUSINFO_LEN#define ETHTOOL_BUSINFO_LEN 32#endif/*****************************************************************************//* 2.4.3 => 2.4.0 */#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,4,3) )/**************************************//* PCI DRIVER API */#ifndef pci_set_dma_mask#define pci_set_dma_mask _kc_pci_set_dma_maskextern int _kc_pci_set_dma_mask(struct pci_dev *dev, dma_addr_t mask);#endif#ifndef pci_request_regions#define pci_request_regions _kc_pci_request_regionsextern int _kc_pci_request_regions(struct pci_dev *pdev, char *res_name);#endif#ifndef pci_release_regions#define pci_release_regions _kc_pci_release_regionsextern void _kc_pci_release_regions(struct pci_dev *pdev);#endif/**************************************//* NETWORK DRIVER API */#ifndef alloc_etherdev#define alloc_etherdev _kc_alloc_etherdevextern struct net_device * _kc_alloc_etherdev(int sizeof_priv);#endif#ifndef is_valid_ether_addr#define is_valid_ether_addr _kc_is_valid_ether_addrextern int _kc_is_valid_ether_addr(u8 *addr);#endif/**************************************//* MISCELLANEOUS */#ifndef INIT_TQUEUE#define INIT_TQUEUE(_tq, _routine, _data) \ do { \ INIT_LIST_HEAD(&(_tq)->list); \ (_tq)->sync = 0; \ (_tq)->routine = _routine; \ (_tq)->data = _data; \ } while (0)#endif#endif /* 2.4.3 => 2.4.0 *//*****************************************************************************/#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,4,5) )/* Generic MII registers. */#define MII_BMCR 0x00 /* Basic mode control register */#define MII_BMSR 0x01 /* Basic mode status register */#define MII_PHYSID1 0x02 /* PHYS ID 1 */#define MII_PHYSID2 0x03 /* PHYS ID 2 */#define MII_ADVERTISE 0x04 /* Advertisement control reg */#define MII_LPA 0x05 /* Link partner ability reg */#define MII_EXPANSION 0x06 /* Expansion register *//* Basic mode control register. */#define BMCR_FULLDPLX 0x0100 /* Full duplex */#define BMCR_ANENABLE 0x1000 /* Enable auto negotiation *//* Basic mode status register. */#define BMSR_ERCAP 0x0001 /* Ext-reg capability */#define BMSR_ANEGCAPABLE 0x0008 /* Able to do auto-negotiation */#define BMSR_10HALF 0x0800 /* Can do 10mbps, half-duplex */#define BMSR_10FULL 0x1000 /* Can do 10mbps, full-duplex */#define BMSR_100HALF 0x2000 /* Can do 100mbps, half-duplex */#define BMSR_100FULL 0x4000 /* Can do 100mbps, full-duplex *//* Advertisement control register. */#define ADVERTISE_CSMA 0x0001 /* Only selector supported */#define ADVERTISE_10HALF 0x0020 /* Try for 10mbps half-duplex */#define ADVERTISE_10FULL 0x0040 /* Try for 10mbps full-duplex */#define ADVERTISE_100HALF 0x0080 /* Try for 100mbps half-duplex */#define ADVERTISE_100FULL 0x0100 /* Try for 100mbps full-duplex */#define ADVERTISE_ALL (ADVERTISE_10HALF | ADVERTISE_10FULL | \ ADVERTISE_100HALF | ADVERTISE_100FULL)/* Expansion register for auto-negotiation. */#define EXPANSION_ENABLENPAGE 0x0004 /* This enables npage words */#endif/*****************************************************************************//* 2.4.6 => 2.4.3 */#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,4,6) )#ifndef pci_set_power_state#define pci_set_power_state _kc_pci_set_power_stateextern int _kc_pci_set_power_state(struct pci_dev *dev, int state);#endif#ifndef pci_save_state#define pci_save_state _kc_pci_save_stateextern int _kc_pci_save_state(struct pci_dev *dev, u32 *buffer);#endif#ifndef pci_restore_state#define pci_restore_state _kc_pci_restore_stateextern int _kc_pci_restore_state(struct pci_dev *pdev, u32 *buffer);#endif#ifndef pci_enable_wake#define pci_enable_wake _kc_pci_enable_wakeextern int _kc_pci_enable_wake(struct pci_dev *pdev, u32 state, int enable);#endif#ifndef pci_disable_device#define pci_disable_device _kc_pci_disable_deviceextern void _kc_pci_disable_device(struct pci_dev *pdev);#endif/* PCI PM entry point syntax changed, so don't support suspend/resume */#undef CONFIG_PM#endif /* 2.4.6 => 2.4.3 */#ifndef HAVE_PCI_SET_MWI#define pci_set_mwi(X) pci_write_config_word(X, \ PCI_COMMAND, adapter->hw.bus.pci_cmd_word | \ PCI_COMMAND_INVALIDATE);#define pci_clear_mwi(X) pci_write_config_word(X, \ PCI_COMMAND, adapter->hw.bus.pci_cmd_word & \ ~PCI_COMMAND_INVALIDATE);#endif/*****************************************************************************//* 2.4.10 => 2.4.9 */#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,4,10) )/**************************************//* MODULE API */#ifndef MODULE_LICENSE #define MODULE_LICENSE(X)#endif/**************************************//* OTHER */#undef min#define min(x,y) ({ \ const typeof(x) _x = (x); \ const typeof(y) _y = (y); \ (void) (&_x == &_y); \ _x < _y ? _x : _y; })#undef max#define max(x,y) ({ \ const typeof(x) _x = (x); \ const typeof(y) _y = (y); \ (void) (&_x == &_y); \ _x > _y ? _x : _y; })#ifndef list_for_each_safe#define list_for_each_safe(pos, n, head) \ for (pos = (head)->next, n = pos->next; pos != (head); \ pos = n, n = pos->next)#endif#endif /* 2.4.10 -> 2.4.6 *//*****************************************************************************//* 2.4.13 => 2.4.10 */#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,4,13) )/**************************************//* PCI DMA MAPPING */#ifndef virt_to_page #define virt_to_page(v) (mem_map + (virt_to_phys(v) >> PAGE_SHIFT))#endif#ifndef pci_map_page#define pci_map_page _kc_pci_map_pageextern u64 _kc_pci_map_page(struct pci_dev *dev, struct page *page, unsigned long offset, size_t size, int direction);#endif#ifndef pci_unmap_page#define pci_unmap_page _kc_pci_unmap_pageextern void _kc_pci_unmap_page(struct pci_dev *dev, u64 dma_addr, size_t size, int direction);#endif/* pci_set_dma_mask takes dma_addr_t, which is only 32-bits prior to 2.4.13 */#undef DMA_32BIT_MASK#define DMA_32BIT_MASK 0xffffffff#undef DMA_64BIT_MASK#define DMA_64BIT_MASK 0xffffffff/**************************************//* OTHER */#ifndef cpu_relax#define cpu_relax() rep_nop()#endif#endif /* 2.4.13 => 2.4.10 *//*****************************************************************************//* 2.4.17 => 2.4.12 */#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,4,17) )#ifndef __devexit_p #define __devexit_p(x) &(x)#endif#endif /* 2.4.17 => 2.4.13 *//*****************************************************************************//* 2.4.20 => 2.4.19 */#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,4,20) )/* we won't support NAPI on less than 2.4.20 */#ifdef NAPI#undef CONFIG_E1000_NAPI#undef CONFIG_IXGB_NAPI#endif#endif /* 2.4.20 => 2.4.19 *//*****************************************************************************//* 2.4.22 => 2.4.17 */#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,4,22) )#define pci_name(x) ((x)->slot_name)#endif/*****************************************************************************//* 2.4.22 => 2.4.17 */#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,4,22) )#endif/*****************************************************************************//*****************************************************************************//* 2.4.23 => 2.4.22 */#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,4,23) )/*****************************************************************************/#ifdef NAPI#ifndef netif_poll_disable#define netif_poll_disable(x) _kc_netif_poll_disable(x)static inline void _kc_netif_poll_disable(struct net_device *netdev){ while (test_and_set_bit(__LINK_STATE_RX_SCHED, &netdev->state)) { /* No hurry */ current->state = TASK_INTERRUPTIBLE; schedule_timeout(1); }}#endif#ifndef netif_poll_enable#define netif_poll_enable(x) _kc_netif_poll_enable(x)static inline void _kc_netif_poll_enable(struct net_device *netdev){ clear_bit(__LINK_STATE_RX_SCHED, &netdev->state);}#endif#endif /* NAPI */#ifndef netif_tx_disable#define netif_tx_disable(x) _kc_netif_tx_disable(x)static inline void _kc_netif_tx_disable(struct net_device *dev){ spin_lock_bh(&dev->xmit_lock); netif_stop_queue(dev); spin_unlock_bh(&dev->xmit_lock);}#endif#endif /* 2.4.23 => 2.4.22 *//*****************************************************************************//* 2.6.4 => 2.6.0 */#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,4,25) || \ ( LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) && \ LINUX_VERSION_CODE < KERNEL_VERSION(2,6,4) ) )#define ETHTOOL_OPS_COMPAT#endif /* 2.6.4 => 2.6.0 *//*****************************************************************************//* 2.5.71 => 2.4.x */#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,5,71) )#include <net/sock.h>#define sk_protocol protocol#define pci_get_device pci_find_device#endif /* 2.5.70 => 2.4.x *//*****************************************************************************//* < 2.4.27 or 2.6.0 <= 2.6.5 */#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,4,27) || \ ( LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) && \ LINUX_VERSION_CODE < KERNEL_VERSION(2,6,5) ) )#ifndef netif_msg_init#define netif_msg_init _kc_netif_msg_initstatic inline u32 _kc_netif_msg_init(int debug_value, int default_msg_enable_bits){ /* use default */ if (debug_value < 0 || debug_value >= (sizeof(u32) * 8)) return default_msg_enable_bits; if (debug_value == 0) /* no output */ return 0; /* set low N bits */ return (1 << debug_value) -1;}#endif#endif /* < 2.4.27 or 2.6.0 <= 2.6.5 *//*****************************************************************************/#if (( LINUX_VERSION_CODE < KERNEL_VERSION(2,4,27) ) || \ (( LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) ) && \ ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,3) )))#define netdev_priv(x) x->priv#endif/*****************************************************************************//* <= 2.5.0 */#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) )#undef pci_register_driver#define pci_register_driver pci_module_init#define dev_err(__unused_dev, format, arg...) \ printk(KERN_ERR "%s: " format, pci_name(pdev) , ## arg)/* hlist_* code - double linked lists */struct hlist_head { struct hlist_node *first;};struct hlist_node { struct hlist_node *next, **pprev;};static inline void __hlist_del(struct hlist_node *n){ struct hlist_node *next = n->next; struct hlist_node **pprev = n->pprev; *pprev = next; if (next) next->pprev = pprev;}static inline void hlist_del(struct hlist_node *n){ __hlist_del(n); n->next = NULL; n->pprev = NULL;}static inline void hlist_add_head(struct hlist_node *n, struct hlist_head *h){ struct hlist_node *first = h->first; n->next = first; if (first) first->pprev = &n->next; h->first = n; n->pprev = &h->first;}static inline int hlist_empty(const struct hlist_head *h){ return !h->first;}#define HLIST_HEAD_INIT { .first = NULL }#define HLIST_HEAD(name) struct hlist_head name = { .first = NULL }#define INIT_HLIST_HEAD(ptr) ((ptr)->first = NULL)static inline void INIT_HLIST_NODE(struct hlist_node *h){ h->next = NULL; h->pprev = NULL;}#define hlist_entry(ptr, type, member) container_of(ptr,type,member)#define hlist_for_each_entry(tpos, pos, head, member) \ for (pos = (head)->first; \ pos && ({ prefetch(pos->next); 1;}) && \ ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \ pos = pos->next)#define hlist_for_each_entry_safe(tpos, pos, n, head, member) \ for (pos = (head)->first; \ pos && ({ n = pos->next; 1; }) && \ ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \ pos = n)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -