|
8 | 8 | #include <linux/init.h> |
9 | 9 | #include <linux/version.h> |
10 | 10 | #include <linux/in.h> |
11 | | -#include <acpi/acpi.h> |
| 11 | +#include <linux/acpi.h> |
| 12 | + |
| 13 | +#if defined(RTL8152_S5_WOL) && defined(CONFIG_PM) |
| 14 | +#include <linux/reboot.h> |
| 15 | +#endif /* defined(RTL8152_S5_WOL) && defined(CONFIG_PM) */ |
12 | 16 |
|
13 | 17 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31) |
14 | 18 | #include <linux/mdio.h> |
|
17 | 21 | #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0) */ |
18 | 22 | #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31) */ |
19 | 23 |
|
| 24 | +#if LINUX_VERSION_CODE < KERNEL_VERSION(5,15,0) |
| 25 | +#if LINUX_VERSION_CODE < KERNEL_VERSION(5,12,0) |
| 26 | + #define PHY_MAC_INTERRUPT PHY_IGNORE_INTERRUPT |
20 | 27 | #if LINUX_VERSION_CODE < KERNEL_VERSION(5,9,0) |
| 28 | + #ifdef CONFIG_PM |
| 29 | + #define pm_ptr(_ptr) (_ptr) |
| 30 | + #else |
| 31 | + #define pm_ptr(_ptr) NULL |
| 32 | + #endif |
| 33 | + |
21 | 34 | #define from_tasklet(var, callback_tasklet, tasklet_fieldname) \ |
22 | 35 | container_of((struct tasklet_struct *)callback_tasklet, typeof(*var), tasklet_fieldname) |
23 | 36 |
|
24 | 37 | #define tasklet_setup(t, fun) tasklet_init(t, fun, (unsigned long)t) |
| 38 | +#if LINUX_VERSION_CODE < KERNEL_VERSION(5,8,0) |
| 39 | +#if LINUX_VERSION_CODE < KERNEL_VERSION(5,7,0) |
25 | 40 | #if LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0) |
26 | 41 | /* Iterate through singly-linked GSO fragments of an skb. */ |
27 | 42 | #define skb_list_walk_safe(first, skb, next_skb) \ |
28 | 43 | for ((skb) = (first), (next_skb) = (skb) ? (skb)->next : NULL; (skb); \ |
29 | 44 | (skb) = (next_skb), (next_skb) = (skb) ? (skb)->next : NULL) |
30 | 45 | #if LINUX_VERSION_CODE < KERNEL_VERSION(5,4,0) |
31 | 46 | #ifndef __has_attribute |
32 | | - # define __GCC4_has_attribute___fallthrough__ 0 |
| 47 | + # define __has_attribute(x) 0 |
33 | 48 | #endif |
34 | 49 |
|
35 | 50 | #if __has_attribute(__fallthrough__) |
|
38 | 53 | # define fallthrough do {} while (0) /* fallthrough */ |
39 | 54 | #endif |
40 | 55 |
|
41 | | - #define MDIO_EEE_2_5GT 0x0001 /* 2.5GT EEE cap */ |
| 56 | + #define MDIO_EEE_2_5GT 0x0001 /* 2.5GT EEE cap */ |
| 57 | +#if LINUX_VERSION_CODE < KERNEL_VERSION(5,2,0) |
42 | 58 | #if LINUX_VERSION_CODE < KERNEL_VERSION(5,1,0) |
43 | | - #define MDIO_AN_10GBT_CTRL_ADV2_5G 0x0080 /* Advertise 2.5GBASE-T */ |
44 | | - #define MDIO_AN_10GBT_STAT_LP2_5G 0x0020 /* LP is 2.5GBT capable */ |
45 | | - |
| 59 | + #define MDIO_AN_10GBT_CTRL_ADV2_5G 0x0080 /* Advertise 2.5GBASE-T */ |
| 60 | + #define MDIO_AN_10GBT_STAT_LP2_5G 0x0020 /* LP is 2.5GBT capable */ |
46 | 61 | #if LINUX_VERSION_CODE < KERNEL_VERSION(5,0,0) |
47 | 62 | #if LINUX_VERSION_CODE < KERNEL_VERSION(4,20,0) |
48 | 63 | #if LINUX_VERSION_CODE < KERNEL_VERSION(4,12,0) |
|
94 | 109 | #define NETIF_F_HW_VLAN_CTAG_RX NETIF_F_HW_VLAN_RX |
95 | 110 | #define NETIF_F_HW_VLAN_CTAG_TX NETIF_F_HW_VLAN_TX |
96 | 111 | #if LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0) |
97 | | - #define USB_DEVICE_INTERFACE_CLASS(vend, prod, iclass) \ |
98 | | - USB_DEVICE_AND_INTERFACE_INFO(vend, prod, iclass, 0xff, 0) |
| 112 | + #define USB_DEVICE_INTERFACE_CLASS(vend, prod, cl) \ |
| 113 | + .match_flags = USB_DEVICE_ID_MATCH_DEVICE | \ |
| 114 | + USB_DEVICE_ID_MATCH_INT_CLASS, \ |
| 115 | + .idVendor = (vend), \ |
| 116 | + .idProduct = (prod), \ |
| 117 | + .bInterfaceClass = (cl) |
99 | 118 |
|
100 | 119 | #if LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0) |
101 | 120 | #ifndef SPEED_UNKNOWN |
|
520 | 539 | #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0) */ |
521 | 540 | #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,0,0) */ |
522 | 541 | #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */ |
| 542 | + static inline int eth_platform_get_mac_address(struct device *dev, u8 *mac_addr) |
| 543 | + { |
| 544 | + return -EOPNOTSUPP; |
| 545 | + } |
523 | 546 | #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,5,0) */ |
524 | 547 | #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,9,0) */ |
525 | 548 | #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,10,0) */ |
526 | 549 | #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,12,0) */ |
| 550 | +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,19,10) && \ |
| 551 | + !(LINUX_VERSION_CODE >= KERNEL_VERSION(4,14,217) && LINUX_VERSION_CODE < KERNEL_VERSION(4,15,0)) |
| 552 | + static inline void skb_mark_not_on_list(struct sk_buff *skb) |
| 553 | + { |
| 554 | + skb->next = NULL; |
| 555 | + } |
| 556 | +#endif |
527 | 557 | static inline void linkmode_set_bit(int nr, volatile unsigned long *addr) |
528 | 558 | { |
529 | 559 | __set_bit(nr, addr); |
|
548 | 578 | else |
549 | 579 | linkmode_clear_bit(nr, addr); |
550 | 580 | } |
551 | | - |
552 | | -#if LINUX_VERSION_CODE < KERNEL_VERSION(4,14,217) || LINUX_VERSION_CODE < KERNEL_VERSION(4,19,10) |
553 | | - static inline void skb_mark_not_on_list(struct sk_buff *skb) |
554 | | - { |
555 | | - skb->next = NULL; |
556 | | - } |
557 | | -#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,14,217) || LINUX_VERSION_CODE < KERNEL_VERSION(4,19,10) */ |
558 | 581 | #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(5,0,0) */ |
559 | 582 | #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(5,1,0) */ |
| 583 | +// static inline u16 pci_dev_id(struct pci_dev *dev) |
| 584 | +// { |
| 585 | +// return PCI_DEVID(dev->bus->number, dev->devfn); |
| 586 | +// } |
| 587 | +#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(5,2,0) */ |
560 | 588 | #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(5,4,0) */ |
561 | 589 | #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0) */ |
| 590 | + static inline void tcp_v6_gso_csum_prep(struct sk_buff *skb) |
| 591 | + { |
| 592 | + struct ipv6hdr *ipv6h = ipv6_hdr(skb); |
| 593 | + struct tcphdr *th = tcp_hdr(skb); |
| 594 | + |
| 595 | + ipv6h->payload_len = 0; |
| 596 | + th->check = ~tcp_v6_check(0, &ipv6h->saddr, &ipv6h->daddr, 0); |
| 597 | + } |
| 598 | +#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(5,7,0) */ |
| 599 | + static inline void fsleep(unsigned long usecs) |
| 600 | + { |
| 601 | + if (usecs <= 10) |
| 602 | + udelay(usecs); |
| 603 | + else if (usecs <= 20000) |
| 604 | + usleep_range(usecs, 2 * usecs); |
| 605 | + else |
| 606 | + msleep(DIV_ROUND_UP(usecs, 1000)); |
| 607 | + } |
| 608 | +#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(5,8,0) */ |
562 | 609 | #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(5,9,0) */ |
| 610 | +#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(5,12,0) */ |
| 611 | + static inline void eth_hw_addr_set(struct net_device *dev, const u8 *addr) |
| 612 | + { |
| 613 | + memcpy(dev->dev_addr, addr, 6); |
| 614 | + } |
| 615 | +#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(5,15,0) */ |
563 | 616 |
|
564 | 617 | #ifndef FALSE |
565 | 618 | #define TRUE 1 |
|
0 commit comments