📄 kcompat.h
字号:
#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_E1000E_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(adapter->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)/* we ignore GFP here */#define dma_alloc_coherent(dv, sz, dma, gfp) \ pci_alloc_consistent(pdev, (sz), (dma))#define dma_free_coherent(dv, sz, addr, dma_addr) \ pci_free_consistent(pdev, (sz), (addr), (dma_addr))#ifndef might_sleep#define might_sleep()#endif#endif /* <= 2.5.0 *//*****************************************************************************//* 2.5.28 => 2.4.23 */#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,5,28) )static inline void _kc_synchronize_irq(void){ synchronize_irq();}#undef synchronize_irq#define synchronize_irq(X) _kc_synchronize_irq()#include <linux/tqueue.h>#define work_struct tq_struct#undef INIT_WORK#define INIT_WORK(a,b) INIT_TQUEUE(a,(void (*)(void *))b,a)#undef container_of#define container_of list_entry#define schedule_work schedule_task#define flush_scheduled_work flush_scheduled_tasks#endif /* 2.5.28 => 2.4.17 *//*****************************************************************************//* 2.6.0 => 2.5.28 */#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) )#define MODULE_INFO(version, _version)#ifndef CONFIG_E1000_DISABLE_PACKET_SPLIT#define CONFIG_E1000_DISABLE_PACKET_SPLIT 1#endif#ifndef CONFIG_IGB_DISABLE_PACKET_SPLIT#define CONFIG_IGB_DISABLE_PACKET_SPLIT 1#endif#define pci_set_consistent_dma_mask(dev,mask) 1#undef dev_put#define dev_put(dev) __dev_put(dev)#ifndef skb_fill_page_desc#define skb_fill_page_desc _kc_skb_fill_page_descextern void _kc_skb_fill_page_desc(struct sk_buff *skb, int i, struct page *page, int off, int size);#endif#ifndef pci_dma_mapping_error#define pci_dma_mapping_error _kc_pci_dma_mapping_errorstatic inline int _kc_pci_dma_mapping_error(dma_addr_t dma_addr){ return dma_addr == 0;}#endif#undef ALIGN#define ALIGN(x,a) (((x)+(a)-1)&~((a)-1))/* find_first_bit and find_next bit are not defined for most * 2.4 kernels (except for the redhat 2.4.21 kernels */#include <linux/bitops.h>#define BITOP_WORD(nr) ((nr) / BITS_PER_LONG)#undef find_next_bit#define find_next_bit _kc_find_next_bitextern unsigned long _kc_find_next_bit(const unsigned long *addr, unsigned long size, unsigned long offset);#define find_first_bit(addr, size) find_next_bit((addr), (size), 0)#endif /* 2.6.0 => 2.5.28 *//*****************************************************************************//* 2.6.4 => 2.6.0 */#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,4) )#define MODULE_VERSION(_version) MODULE_INFO(version, _version)#endif /* 2.6.4 => 2.6.0 *//*****************************************************************************//* 2.6.5 => 2.6.0 */#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,5) )#define pci_dma_sync_single_for_cpu pci_dma_sync_single#define pci_dma_sync_single_for_device pci_dma_sync_single_for_cpu#endif /* 2.6.5 => 2.6.0 *//*****************************************************************************/#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,6) )/* taken from 2.6 include/linux/bitmap.h */#undef bitmap_zero#define bitmap_zero _kc_bitmap_zerostatic inline void _kc_bitmap_zero(unsigned long *dst, int nbits){ if (nbits <= BITS_PER_LONG) *dst = 0UL; else { int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long); memset(dst, 0, len); }}#endif /* < 2.6.6 *//*****************************************************************************/#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,7) )#undef if_mii#define if_mii _kc_if_miistatic inline struct mii_ioctl_data *_kc_if_mii(struct ifreq *rq){ return (struct mii_ioctl_data *) &rq->ifr_ifru;}#endif /* < 2.6.7 *//*****************************************************************************/#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,8) )#define msleep(x) do { set_current_state(TASK_UNINTERRUPTIBLE); \ schedule_timeout((x * HZ)/1000 + 2); \ } while (0)#endif /* < 2.6.8 *//*****************************************************************************/#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,9))#include <net/dsfield.h>#define __iomem#ifndef kcalloc#define kcalloc(n, size, flags) _kc_kzalloc(((n) * (size)), flags)extern void *_kc_kzalloc(size_t size, int flags);#endif#define MSEC_PER_SEC 1000Lstatic inline unsigned int _kc_jiffies_to_msecs(const unsigned long j){#if HZ <= MSEC_PER_SEC && !(MSEC_PER_SEC % HZ) return (MSEC_PER_SEC / HZ) * j;#elif HZ > MSEC_PER_SEC && !(HZ % MSEC_PER_SEC) return (j + (HZ / MSEC_PER_SEC) - 1)/(HZ / MSEC_PER_SEC);#else return (j * MSEC_PER_SEC) / HZ;#endif}static inline unsigned long _kc_msecs_to_jiffies(const unsigned int m){ if (m > _kc_jiffies_to_msecs(MAX_JIFFY_OFFSET)) return MAX_JIFFY_OFFSET;#if HZ <= MSEC_PER_SEC && !(MSEC_PER_SEC % HZ) return (m + (MSEC_PER_SEC / HZ) - 1) / (MSEC_PER_SEC / HZ);#elif HZ > MSEC_PER_SEC && !(HZ % MSEC_PER_SEC) return m * (HZ / MSEC_PER_SEC);#else return (m * HZ + MSEC_PER_SEC - 1) / MSEC_PER_SEC;#endif}#define msleep_interruptible _kc_msleep_interruptiblestatic inline unsigned long _kc_msleep_interruptible(unsigned int msecs){ unsigned long timeout = _kc_msecs_to_jiffies(msecs) + 1; while (timeout && !signal_pending(current)) { __set_current_state(TASK_INTERRUPTIBLE); timeout = schedule_timeout(timeout); } return _kc_jiffies_to_msecs(timeout);}/* Basic mode control register. */#define BMCR_SPEED1000 0x0040 /* MSB of Speed (1000) */#endif /* < 2.6.9 *//*****************************************************************************/#if ( LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,6) && \ LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10) )#ifdef pci_save_state#undef pci_save_state#endif#define pci_save_state(X) { \ int i; \ if (adapter->pci_state) { \ for (i = 0; i < 16; i++) { \ pci_read_config_dword((X), \ i * 4, \ &adapter->pci_state[i]); \ } \ } \}#ifdef pci_restore_state#undef pci_restore_state#endif#define pci_restore_state(X) { \ int i; \ if (adapter->pci_state) { \ for (i = 0; i < 16; i++) { \
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -