1 /*******************************************************************************
3 Intel(R) Gigabit Ethernet Linux driver
4 Copyright(c) 2007-2012 Intel Corporation.
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.
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
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.
19 The full GNU General Public License is included in this distribution in
20 the file called "COPYING".
23 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
24 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26 *******************************************************************************/
31 /*****************************************************************************/
32 #if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,4,8) )
33 /* From lib/vsprintf.c */
34 #include <asm/div64.h>
36 static int skip_atoi(const char **s)
41 i = i*10 + *((*s)++) - '0';
45 #define _kc_ZEROPAD 1 /* pad with zero */
46 #define _kc_SIGN 2 /* unsigned/signed long */
47 #define _kc_PLUS 4 /* show plus */
48 #define _kc_SPACE 8 /* space if plus */
49 #define _kc_LEFT 16 /* left justified */
50 #define _kc_SPECIAL 32 /* 0x */
51 #define _kc_LARGE 64 /* use 'ABCDEF' instead of 'abcdef' */
53 static char * number(char * buf, char * end, long long num, int base, int size, int precision, int type)
57 const char small_digits[] = "0123456789abcdefghijklmnopqrstuvwxyz";
58 const char large_digits[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
61 digits = (type & _kc_LARGE) ? large_digits : small_digits;
64 if (base < 2 || base > 36)
66 c = (type & _kc_ZEROPAD) ? '0' : ' ';
68 if (type & _kc_SIGN) {
73 } else if (type & _kc_PLUS) {
76 } else if (type & _kc_SPACE) {
81 if (type & _kc_SPECIAL) {
91 tmp[i++] = digits[do_div(num,base)];
95 if (!(type&(_kc_ZEROPAD+_kc_LEFT))) {
107 if (type & _kc_SPECIAL) {
112 } else if (base==16) {
121 if (!(type & _kc_LEFT)) {
128 while (i < precision--) {
146 int _kc_vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
149 unsigned long long num;
154 int flags; /* flags to number() */
156 int field_width; /* width of output field */
157 int precision; /* min. # of digits for integers; max
158 number of chars for from string */
159 int qualifier; /* 'h', 'l', or 'L' for integer fields */
160 /* 'z' support added 23/7/1999 S.H. */
161 /* 'z' changed to 'Z' --davidm 1/25/99 */
164 end = buf + size - 1;
168 size = end - buf + 1;
171 for (; *fmt ; ++fmt) {
182 ++fmt; /* this also skips first '%' */
184 case '-': flags |= _kc_LEFT; goto repeat;
185 case '+': flags |= _kc_PLUS; goto repeat;
186 case ' ': flags |= _kc_SPACE; goto repeat;
187 case '#': flags |= _kc_SPECIAL; goto repeat;
188 case '0': flags |= _kc_ZEROPAD; goto repeat;
191 /* get field width */
194 field_width = skip_atoi(&fmt);
195 else if (*fmt == '*') {
197 /* it's the next argument */
198 field_width = va_arg(args, int);
199 if (field_width < 0) {
200 field_width = -field_width;
205 /* get the precision */
210 precision = skip_atoi(&fmt);
211 else if (*fmt == '*') {
213 /* it's the next argument */
214 precision = va_arg(args, int);
220 /* get the conversion qualifier */
222 if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L' || *fmt =='Z') {
232 if (!(flags & _kc_LEFT)) {
233 while (--field_width > 0) {
239 c = (unsigned char) va_arg(args, int);
243 while (--field_width > 0) {
251 s = va_arg(args, char *);
255 len = strnlen(s, precision);
257 if (!(flags & _kc_LEFT)) {
258 while (len < field_width--) {
264 for (i = 0; i < len; ++i) {
269 while (len < field_width--) {
277 if (field_width == -1) {
278 field_width = 2*sizeof(void *);
279 flags |= _kc_ZEROPAD;
281 str = number(str, end,
282 (unsigned long) va_arg(args, void *),
283 16, field_width, precision, flags);
289 * What does C99 say about the overflow case here? */
290 if (qualifier == 'l') {
291 long * ip = va_arg(args, long *);
293 } else if (qualifier == 'Z') {
294 size_t * ip = va_arg(args, size_t *);
297 int * ip = va_arg(args, int *);
308 /* integer number formats - set up the flags and "break" */
338 if (qualifier == 'L')
339 num = va_arg(args, long long);
340 else if (qualifier == 'l') {
341 num = va_arg(args, unsigned long);
342 if (flags & _kc_SIGN)
343 num = (signed long) num;
344 } else if (qualifier == 'Z') {
345 num = va_arg(args, size_t);
346 } else if (qualifier == 'h') {
347 num = (unsigned short) va_arg(args, int);
348 if (flags & _kc_SIGN)
349 num = (signed short) num;
351 num = va_arg(args, unsigned int);
352 if (flags & _kc_SIGN)
353 num = (signed int) num;
355 str = number(str, end, num, base,
356 field_width, precision, flags);
361 /* don't write out a null byte if the buf size is zero */
363 /* the trailing null byte doesn't count towards the total
369 int _kc_snprintf(char * buf, size_t size, const char *fmt, ...)
375 i = _kc_vsnprintf(buf,size,fmt,args);
381 /*****************************************************************************/
382 #if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,4,13) )
384 /**************************************/
385 /* PCI DMA MAPPING */
387 #if defined(CONFIG_HIGHMEM)
389 #ifndef PCI_DRAM_OFFSET
390 #define PCI_DRAM_OFFSET 0
394 _kc_pci_map_page(struct pci_dev *dev, struct page *page, unsigned long offset,
395 size_t size, int direction)
397 return (((u64) (page - mem_map) << PAGE_SHIFT) + offset +
401 #else /* CONFIG_HIGHMEM */
404 _kc_pci_map_page(struct pci_dev *dev, struct page *page, unsigned long offset,
405 size_t size, int direction)
407 return pci_map_single(dev, (void *)page_address(page) + offset, size,
411 #endif /* CONFIG_HIGHMEM */
414 _kc_pci_unmap_page(struct pci_dev *dev, u64 dma_addr, size_t size,
417 return pci_unmap_single(dev, dma_addr, size, direction);
420 #endif /* 2.4.13 => 2.4.3 */
422 /*****************************************************************************/
423 #if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,4,3) )
425 /**************************************/
429 _kc_pci_set_dma_mask(struct pci_dev *dev, dma_addr_t mask)
431 if (!pci_dma_supported(dev, mask))
433 dev->dma_mask = mask;
438 _kc_pci_request_regions(struct pci_dev *dev, char *res_name)
442 for (i = 0; i < 6; i++) {
443 if (pci_resource_len(dev, i) == 0)
446 if (pci_resource_flags(dev, i) & IORESOURCE_IO) {
447 if (!request_region(pci_resource_start(dev, i), pci_resource_len(dev, i), res_name)) {
448 pci_release_regions(dev);
451 } else if (pci_resource_flags(dev, i) & IORESOURCE_MEM) {
452 if (!request_mem_region(pci_resource_start(dev, i), pci_resource_len(dev, i), res_name)) {
453 pci_release_regions(dev);
462 _kc_pci_release_regions(struct pci_dev *dev)
466 for (i = 0; i < 6; i++) {
467 if (pci_resource_len(dev, i) == 0)
470 if (pci_resource_flags(dev, i) & IORESOURCE_IO)
471 release_region(pci_resource_start(dev, i), pci_resource_len(dev, i));
473 else if (pci_resource_flags(dev, i) & IORESOURCE_MEM)
474 release_mem_region(pci_resource_start(dev, i), pci_resource_len(dev, i));
478 /**************************************/
479 /* NETWORK DRIVER API */
482 _kc_alloc_etherdev(int sizeof_priv)
484 struct net_device *dev;
487 alloc_size = sizeof(*dev) + sizeof_priv + IFNAMSIZ + 31;
488 dev = kzalloc(alloc_size, GFP_KERNEL);
493 dev->priv = (void *) (((unsigned long)(dev + 1) + 31) & ~31);
501 _kc_is_valid_ether_addr(u8 *addr)
503 const char zaddr[6] = { 0, };
505 return !(addr[0] & 1) && memcmp(addr, zaddr, 6);
508 #endif /* 2.4.3 => 2.4.0 */
510 /*****************************************************************************/
511 #if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,4,6) )
514 _kc_pci_set_power_state(struct pci_dev *dev, int state)
520 _kc_pci_enable_wake(struct pci_dev *pdev, u32 state, int enable)
525 #endif /* 2.4.6 => 2.4.3 */
527 /*****************************************************************************/
528 #if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) )
529 void _kc_skb_fill_page_desc(struct sk_buff *skb, int i, struct page *page,
532 skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
534 frag->page_offset = off;
536 skb_shinfo(skb)->nr_frags = i + 1;
540 * Original Copyright:
541 * find_next_bit.c: fallback find next bit implementation
543 * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
544 * Written by David Howells (dhowells@redhat.com)
548 * find_next_bit - find the next set bit in a memory region
549 * @addr: The address to base the search on
550 * @offset: The bitnumber to start searching at
551 * @size: The maximum size to search
553 unsigned long find_next_bit(const unsigned long *addr, unsigned long size,
554 unsigned long offset)
556 const unsigned long *p = addr + BITOP_WORD(offset);
557 unsigned long result = offset & ~(BITS_PER_LONG-1);
563 offset %= BITS_PER_LONG;
566 tmp &= (~0UL << offset);
567 if (size < BITS_PER_LONG)
571 size -= BITS_PER_LONG;
572 result += BITS_PER_LONG;
574 while (size & ~(BITS_PER_LONG-1)) {
577 result += BITS_PER_LONG;
578 size -= BITS_PER_LONG;
585 tmp &= (~0UL >> (BITS_PER_LONG - size));
586 if (tmp == 0UL) /* Are any bits set? */
587 return result + size; /* Nope. */
589 return result + ffs(tmp);
592 size_t _kc_strlcpy(char *dest, const char *src, size_t size)
594 size_t ret = strlen(src);
597 size_t len = (ret >= size) ? size - 1 : ret;
598 memcpy(dest, src, len);
604 #endif /* 2.6.0 => 2.4.6 */
606 /*****************************************************************************/
607 #if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,4) )
608 int _kc_scnprintf(char * buf, size_t size, const char *fmt, ...)
614 i = vsnprintf(buf, size, fmt, args);
616 return (i >= size) ? (size - 1) : i;
620 /*****************************************************************************/
621 #if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10) )
622 DECLARE_BITMAP(_kcompat_node_online_map, MAX_NUMNODES) = {1};
623 #endif /* < 2.6.10 */
625 /*****************************************************************************/
626 #if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,13) )
627 char *_kc_kstrdup(const char *s, unsigned int gfp)
636 buf = kmalloc(len, gfp);
641 #endif /* < 2.6.13 */
643 /*****************************************************************************/
644 #if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14) )
645 void *_kc_kzalloc(size_t size, int flags)
647 void *ret = kmalloc(size, flags);
649 memset(ret, 0, size);
652 #endif /* <= 2.6.13 */
654 /*****************************************************************************/
655 #if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) )
656 int _kc_skb_pad(struct sk_buff *skb, int pad)
660 /* If the skbuff is non linear tailroom is always zero.. */
661 if(!skb_cloned(skb) && skb_tailroom(skb) >= pad) {
662 memset(skb->data+skb->len, 0, pad);
666 ntail = skb->data_len + pad - (skb->end - skb->tail);
667 if (likely(skb_cloned(skb) || ntail > 0)) {
668 if (pskb_expand_head(skb, 0, ntail, GFP_ATOMIC));
673 if (skb_is_nonlinear(skb) &&
674 !__pskb_pull_tail(skb, skb->data_len))
678 memset(skb->data + skb->len, 0, pad);
686 #if (!(RHEL_RELEASE_CODE && RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(5,4)))
687 int _kc_pci_save_state(struct pci_dev *pdev)
689 struct net_device *netdev = pci_get_drvdata(pdev);
690 struct adapter_struct *adapter = netdev_priv(netdev);
691 int size = PCI_CONFIG_SPACE_LEN, i;
692 u16 pcie_cap_offset, pcie_link_status;
694 #if ( LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) )
695 /* no ->dev for 2.4 kernels */
696 WARN_ON(pdev->dev.driver_data == NULL);
698 pcie_cap_offset = pci_find_capability(pdev, PCI_CAP_ID_EXP);
699 if (pcie_cap_offset) {
700 if (!pci_read_config_word(pdev,
701 pcie_cap_offset + PCIE_LINK_STATUS,
703 size = PCIE_CONFIG_SPACE_LEN;
705 pci_config_space_ich8lan();
707 if (adapter->config_space == NULL)
709 WARN_ON(adapter->config_space != NULL);
711 adapter->config_space = kmalloc(size, GFP_KERNEL);
712 if (!adapter->config_space) {
713 printk(KERN_ERR "Out of memory in pci_save_state\n");
716 for (i = 0; i < (size / 4); i++)
717 pci_read_config_dword(pdev, i * 4, &adapter->config_space[i]);
721 void _kc_pci_restore_state(struct pci_dev *pdev)
723 struct net_device *netdev = pci_get_drvdata(pdev);
724 struct adapter_struct *adapter = netdev_priv(netdev);
725 int size = PCI_CONFIG_SPACE_LEN, i;
727 u16 pcie_link_status;
729 if (adapter->config_space != NULL) {
730 pcie_cap_offset = pci_find_capability(pdev, PCI_CAP_ID_EXP);
731 if (pcie_cap_offset &&
732 !pci_read_config_word(pdev,
733 pcie_cap_offset + PCIE_LINK_STATUS,
735 size = PCIE_CONFIG_SPACE_LEN;
737 pci_config_space_ich8lan();
738 for (i = 0; i < (size / 4); i++)
739 pci_write_config_dword(pdev, i * 4, adapter->config_space[i]);
741 kfree(adapter->config_space);
742 adapter->config_space = NULL;
746 #endif /* !(RHEL_RELEASE_CODE >= RHEL 5.4) */
749 void _kc_free_netdev(struct net_device *netdev)
751 struct adapter_struct *adapter = netdev_priv(netdev);
753 if (adapter->config_space != NULL)
754 kfree(adapter->config_space);
756 if (netdev->reg_state == NETREG_UNINITIALIZED) {
757 kfree((char *)netdev - netdev->padded);
759 BUG_ON(netdev->reg_state != NETREG_UNREGISTERED);
760 netdev->reg_state = NETREG_RELEASED;
761 class_device_put(&netdev->class_dev);
764 kfree((char *)netdev - netdev->padded);
769 void *_kc_kmemdup(const void *src, size_t len, unsigned gfp)
773 p = kzalloc(len, gfp);
778 #endif /* <= 2.6.19 */
780 /*****************************************************************************/
781 #if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22) )
782 /* hexdump code taken from lib/hexdump.c */
783 static void _kc_hex_dump_to_buffer(const void *buf, size_t len, int rowsize,
784 int groupsize, unsigned char *linebuf,
785 size_t linebuflen, bool ascii)
792 if (rowsize != 16 && rowsize != 32)
797 if (len > rowsize) /* limit to one line at a time */
799 if ((len % groupsize) != 0) /* no mixed size output */
804 const u64 *ptr8 = buf;
805 int ngroups = len / groupsize;
807 for (j = 0; j < ngroups; j++)
808 lx += scnprintf((char *)(linebuf + lx), linebuflen - lx,
809 "%s%16.16llx", j ? " " : "",
810 (unsigned long long)*(ptr8 + j));
811 ascii_column = 17 * ngroups + 2;
816 const u32 *ptr4 = buf;
817 int ngroups = len / groupsize;
819 for (j = 0; j < ngroups; j++)
820 lx += scnprintf((char *)(linebuf + lx), linebuflen - lx,
821 "%s%8.8x", j ? " " : "", *(ptr4 + j));
822 ascii_column = 9 * ngroups + 2;
827 const u16 *ptr2 = buf;
828 int ngroups = len / groupsize;
830 for (j = 0; j < ngroups; j++)
831 lx += scnprintf((char *)(linebuf + lx), linebuflen - lx,
832 "%s%4.4x", j ? " " : "", *(ptr2 + j));
833 ascii_column = 5 * ngroups + 2;
838 for (j = 0; (j < len) && (lx + 3) <= linebuflen; j++) {
840 linebuf[lx++] = hex_asc(ch >> 4);
841 linebuf[lx++] = hex_asc(ch & 0x0f);
847 ascii_column = 3 * rowsize + 2;
853 while (lx < (linebuflen - 1) && lx < (ascii_column - 1))
855 for (j = 0; (j < len) && (lx + 2) < linebuflen; j++)
856 linebuf[lx++] = (isascii(ptr[j]) && isprint(ptr[j])) ? ptr[j]
859 linebuf[lx++] = '\0';
862 void _kc_print_hex_dump(const char *level,
863 const char *prefix_str, int prefix_type,
864 int rowsize, int groupsize,
865 const void *buf, size_t len, bool ascii)
868 int i, linelen, remaining = len;
869 unsigned char linebuf[200];
871 if (rowsize != 16 && rowsize != 32)
874 for (i = 0; i < len; i += rowsize) {
875 linelen = min(remaining, rowsize);
876 remaining -= rowsize;
877 _kc_hex_dump_to_buffer(ptr + i, linelen, rowsize, groupsize,
878 linebuf, sizeof(linebuf), ascii);
880 switch (prefix_type) {
881 case DUMP_PREFIX_ADDRESS:
882 printk("%s%s%*p: %s\n", level, prefix_str,
883 (int)(2 * sizeof(void *)), ptr + i, linebuf);
885 case DUMP_PREFIX_OFFSET:
886 printk("%s%s%.8x: %s\n", level, prefix_str, i, linebuf);
889 printk("%s%s%s\n", level, prefix_str, linebuf);
894 #endif /* < 2.6.22 */
896 /*****************************************************************************/
897 #if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) )
899 struct net_device *napi_to_poll_dev(struct napi_struct *napi)
901 struct adapter_q_vector *q_vector = container_of(napi,
902 struct adapter_q_vector,
904 return &q_vector->poll_dev;
907 int __kc_adapter_clean(struct net_device *netdev, int *budget)
910 int work_to_do = min(*budget, netdev->quota);
911 /* kcompat.h netif_napi_add puts napi struct in "fake netdev->priv" */
912 struct napi_struct *napi = netdev->priv;
913 work_done = napi->poll(napi, work_to_do);
914 *budget -= work_done;
915 netdev->quota -= work_done;
916 return (work_done >= work_to_do) ? 1 : 0;
919 #endif /* <= 2.6.24 */
921 /*****************************************************************************/
922 #if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26) )
923 void _kc_pci_disable_link_state(struct pci_dev *pdev, int state)
925 struct pci_dev *parent = pdev->bus->self;
932 pos = pci_find_capability(parent, PCI_CAP_ID_EXP);
934 pci_read_config_word(parent, pos + PCI_EXP_LNKCTL, &link_state);
935 link_state &= ~state;
936 pci_write_config_word(parent, pos + PCI_EXP_LNKCTL, link_state);
939 #endif /* < 2.6.26 */
941 /*****************************************************************************/
942 #if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27) )
944 void _kc_netif_tx_stop_all_queues(struct net_device *netdev)
946 struct adapter_struct *adapter = netdev_priv(netdev);
949 netif_stop_queue(netdev);
950 if (netif_is_multiqueue(netdev))
951 for (i = 0; i < adapter->num_tx_queues; i++)
952 netif_stop_subqueue(netdev, i);
954 void _kc_netif_tx_wake_all_queues(struct net_device *netdev)
956 struct adapter_struct *adapter = netdev_priv(netdev);
959 netif_wake_queue(netdev);
960 if (netif_is_multiqueue(netdev))
961 for (i = 0; i < adapter->num_tx_queues; i++)
962 netif_wake_subqueue(netdev, i);
964 void _kc_netif_tx_start_all_queues(struct net_device *netdev)
966 struct adapter_struct *adapter = netdev_priv(netdev);
969 netif_start_queue(netdev);
970 if (netif_is_multiqueue(netdev))
971 for (i = 0; i < adapter->num_tx_queues; i++)
972 netif_start_subqueue(netdev, i);
974 #endif /* HAVE_TX_MQ */
976 #ifndef __WARN_printf
977 void __kc_warn_slowpath(const char *file, int line, const char *fmt, ...)
981 printk(KERN_WARNING "------------[ cut here ]------------\n");
982 printk(KERN_WARNING "WARNING: at %s:%d %s()\n", file, line);
989 #endif /* __WARN_printf */
990 #endif /* < 2.6.27 */
992 /*****************************************************************************/
993 #if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28) )
996 _kc_pci_prepare_to_sleep(struct pci_dev *dev)
998 pci_power_t target_state;
1001 target_state = pci_choose_state(dev, PMSG_SUSPEND);
1003 pci_enable_wake(dev, target_state, true);
1005 error = pci_set_power_state(dev, target_state);
1008 pci_enable_wake(dev, target_state, false);
1014 _kc_pci_wake_from_d3(struct pci_dev *dev, bool enable)
1018 err = pci_enable_wake(dev, PCI_D3cold, enable);
1022 err = pci_enable_wake(dev, PCI_D3hot, enable);
1028 void _kc_skb_add_rx_frag(struct sk_buff *skb, int i, struct page *page,
1031 skb_fill_page_desc(skb, i, page, off, size);
1033 skb->data_len += size;
1034 skb->truesize += size;
1036 #endif /* < 2.6.28 */
1038 #if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35) )
1040 #ifndef CONFIG_NETDEVICES_MULTIQUEUE
1041 void _kc_netif_set_real_num_tx_queues(struct net_device *dev, unsigned int txq)
1043 unsigned int real_num = dev->real_num_tx_queues;
1044 struct Qdisc *qdisc;
1047 if (unlikely(txq > dev->num_tx_queues))
1049 else if (txq > real_num)
1050 dev->real_num_tx_queues = txq;
1051 else if ( txq < real_num) {
1052 dev->real_num_tx_queues = txq;
1053 for (i = txq; i < dev->num_tx_queues; i++) {
1054 qdisc = netdev_get_tx_queue(dev, i)->qdisc;
1056 spin_lock_bh(qdisc_lock(qdisc));
1058 spin_unlock_bh(qdisc_lock(qdisc));
1063 #endif /* CONFIG_NETDEVICES_MULTIQUEUE */
1064 #endif /* HAVE_TX_MQ */
1065 #endif /* < 2.6.35 */
1067 /*****************************************************************************/
1068 #if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36) )
1069 static const u32 _kc_flags_dup_features =
1070 (ETH_FLAG_LRO | ETH_FLAG_NTUPLE | ETH_FLAG_RXHASH);
1072 u32 _kc_ethtool_op_get_flags(struct net_device *dev)
1074 return dev->features & _kc_flags_dup_features;
1077 int _kc_ethtool_op_set_flags(struct net_device *dev, u32 data, u32 supported)
1079 if (data & ~supported)
1082 dev->features = ((dev->features & ~_kc_flags_dup_features) |
1083 (data & _kc_flags_dup_features));
1086 #endif /* < 2.6.36 */
1088 /*****************************************************************************/
1089 #if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38) )
1090 #ifdef HAVE_NETDEV_SELECT_QUEUE
1092 static u32 _kc_simple_tx_hashrnd;
1093 static u32 _kc_simple_tx_hashrnd_initialized;
1095 u16 ___kc_skb_tx_hash(struct net_device *dev, const struct sk_buff *skb,
1100 if (skb_rx_queue_recorded(skb)) {
1101 hash = skb_get_rx_queue(skb);
1102 while (unlikely(hash >= num_tx_queues))
1103 hash -= num_tx_queues;
1107 if (unlikely(!_kc_simple_tx_hashrnd_initialized)) {
1108 get_random_bytes(&_kc_simple_tx_hashrnd, 4);
1109 _kc_simple_tx_hashrnd_initialized = 1;
1112 if (skb->sk && skb->sk->sk_hash)
1113 hash = skb->sk->sk_hash;
1115 #ifdef NETIF_F_RXHASH
1116 hash = (__force u16) skb->protocol ^ skb->rxhash;
1118 hash = skb->protocol;
1121 hash = jhash_1word(hash, _kc_simple_tx_hashrnd);
1123 return (u16) (((u64) hash * num_tx_queues) >> 32);
1125 #endif /* HAVE_NETDEV_SELECT_QUEUE */
1126 #endif /* < 2.6.38 */
1128 /******************************************************************************/
1129 #if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39) )
1130 #if (!(RHEL_RELEASE_CODE && RHEL_RELEASE_CODE > RHEL_RELEASE_VERSION(6,0)))
1131 #endif /* !(RHEL_RELEASE_CODE > RHEL_RELEASE_VERSION(6,0)) */
1132 #endif /* < 2.6.39 */