|
8 | 8 | #include <linux/init.h> |
9 | 9 | #include <linux/version.h> |
10 | 10 | #include <linux/in.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) */ |
11 | 16 |
|
12 | 17 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31) |
13 | 18 | #include <linux/mdio.h> |
|
16 | 21 | #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0) */ |
17 | 22 | #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31) */ |
18 | 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 |
| 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 | + |
| 34 | + #define from_tasklet(var, callback_tasklet, tasklet_fieldname) \ |
| 35 | + container_of((struct tasklet_struct *)callback_tasklet, typeof(*var), tasklet_fieldname) |
| 36 | + |
| 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) |
| 40 | +#if LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0) |
| 41 | + /* Iterate through singly-linked GSO fragments of an skb. */ |
| 42 | + #define skb_list_walk_safe(first, skb, next_skb) \ |
| 43 | + for ((skb) = (first), (next_skb) = (skb) ? (skb)->next : NULL; (skb); \ |
| 44 | + (skb) = (next_skb), (next_skb) = (skb) ? (skb)->next : NULL) |
| 45 | +#if LINUX_VERSION_CODE < KERNEL_VERSION(5,4,0) |
| 46 | + #ifndef __has_attribute |
| 47 | + # define __has_attribute(x) 0 |
| 48 | + #endif |
| 49 | + |
| 50 | + #if __has_attribute(__fallthrough__) |
| 51 | + # define fallthrough __attribute__((__fallthrough__)) |
| 52 | + #else |
| 53 | + # define fallthrough do {} while (0) /* fallthrough */ |
| 54 | + #endif |
| 55 | + |
| 56 | + #define MDIO_EEE_2_5GT 0x0001 /* 2.5GT EEE cap */ |
| 57 | +#if LINUX_VERSION_CODE < KERNEL_VERSION(5,2,0) |
| 58 | +#if LINUX_VERSION_CODE < KERNEL_VERSION(5,1,0) |
| 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 */ |
19 | 61 | #if LINUX_VERSION_CODE < KERNEL_VERSION(5,0,0) |
20 | 62 | #if LINUX_VERSION_CODE < KERNEL_VERSION(4,20,0) |
21 | 63 | #if LINUX_VERSION_CODE < KERNEL_VERSION(4,12,0) |
|
58 | 100 | #define BITS_PER_BYTE 8 |
59 | 101 | #define reinit_completion(x) ((x)->done = 0) |
60 | 102 | #if LINUX_VERSION_CODE < KERNEL_VERSION(3,12,0) |
| 103 | +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,11,0) |
| 104 | + #define DEVICE_ATTR_RW(_name) \ |
| 105 | + struct device_attribute dev_attr_##_name = __ATTR(_name, 0644, _name##_show, _name##_store) |
| 106 | + #define DEVICE_ATTR_RO(_name) \ |
| 107 | + struct device_attribute dev_attr_##_name = __ATTR_RO(_name) |
61 | 108 | #if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0) |
62 | 109 | #define NETIF_F_HW_VLAN_CTAG_RX NETIF_F_HW_VLAN_RX |
63 | 110 | #define NETIF_F_HW_VLAN_CTAG_TX NETIF_F_HW_VLAN_TX |
64 | 111 | #if LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0) |
65 | | - #define USB_DEVICE_INTERFACE_CLASS(vend, prod, iclass) \ |
66 | | - 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) |
67 | 118 |
|
68 | 119 | #if LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0) |
69 | 120 | #ifndef SPEED_UNKNOWN |
|
462 | 513 | } |
463 | 514 | #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0) */ |
464 | 515 | #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0) */ |
| 516 | +#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(3,11,0) */ |
465 | 517 | static inline bool usb_device_no_sg_constraint(struct usb_device *udev) |
466 | 518 | { |
467 | 519 | return 0; |
|
487 | 539 | #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0) */ |
488 | 540 | #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,0,0) */ |
489 | 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 | + } |
490 | 546 | #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,5,0) */ |
491 | 547 | #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,9,0) */ |
492 | 548 | #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,10,0) */ |
493 | 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 |
494 | 557 | static inline void linkmode_set_bit(int nr, volatile unsigned long *addr) |
495 | 558 | { |
496 | 559 | __set_bit(nr, addr); |
|
515 | 578 | else |
516 | 579 | linkmode_clear_bit(nr, addr); |
517 | 580 | } |
518 | | - |
519 | 581 | #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(5,0,0) */ |
| 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) */ |
| 588 | +#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(5,4,0) */ |
| 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) */ |
| 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) */ |
520 | 616 |
|
521 | 617 | #ifndef FALSE |
522 | 618 | #define TRUE 1 |
|
0 commit comments