r8168: add kernel 5.18 support

This commit is contained in:
lean 2022-07-08 20:28:09 +08:00
parent 71124f92a6
commit 4865875187
2 changed files with 48 additions and 1 deletions

View File

@ -0,0 +1,47 @@
--- a/src/r8168_n.c
+++ b/src/r8168_n.c
@@ -3715,7 +3715,11 @@
txd->opts2 = 0;
while (1) {
memset(tmpAddr, pattern++, len - 14);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5,18,0)
pci_dma_sync_single_for_device(tp->pci_dev,
+#else
+ dma_sync_single_for_device(tp_to_dev(tp),
+#endif
le64_to_cpu(mapping),
len, DMA_TO_DEVICE);
txd->opts1 = cpu_to_le32(DescOwn | FirstFrag | LastFrag | len);
@@ -3743,7 +3747,11 @@
if (rx_len == len) {
dma_sync_single_for_cpu(tp_to_dev(tp), le64_to_cpu(rxd->addr), tp->rx_buf_sz, DMA_FROM_DEVICE);
i = memcmp(skb->data, rx_skb->data, rx_len);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5,18,0)
pci_dma_sync_single_for_device(tp->pci_dev, le64_to_cpu(rxd->addr), tp->rx_buf_sz, DMA_FROM_DEVICE);
+#else
+ dma_sync_single_for_device(tp_to_dev(tp), le64_to_cpu(rxd->addr), tp->rx_buf_sz, DMA_FROM_DEVICE);
+#endif
if (i == 0) {
// dev_printk(KERN_INFO, tp_to_dev(tp), "loopback test finished\n",rx_len,len);
break;
@@ -26464,11 +26472,20 @@
if ((sizeof(dma_addr_t) > 4) &&
use_dac &&
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5,18,0)
!pci_set_dma_mask(pdev, DMA_BIT_MASK(64)) &&
!pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64))) {
+#else
+ !dma_set_mask(&pdev->dev, DMA_BIT_MASK(64)) &&
+ !dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(64))) {
+#endif
dev->features |= NETIF_F_HIGHDMA;
} else {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5,18,0)
rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
+#else
+ rc = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32));
+#endif
if (rc < 0) {
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,0)
if (netif_msg_probe(tp))

View File

@ -2,7 +2,7 @@ define Device/generic
DEVICE_VENDOR := Generic DEVICE_VENDOR := Generic
DEVICE_MODEL := x86/64 DEVICE_MODEL := x86/64
DEVICE_PACKAGES += kmod-amazon-ena kmod-bnx2 kmod-e1000e kmod-e1000 \ DEVICE_PACKAGES += kmod-amazon-ena kmod-bnx2 kmod-e1000e kmod-e1000 \
kmod-forcedeth kmod-igb kmod-ixgbe kmod-amd-xgbe kmod-r8169 kmod-fs-vfat kmod-forcedeth kmod-igb kmod-ixgbe kmod-amd-xgbe kmod-r8168 kmod-fs-vfat
GRUB2_VARIANT := generic GRUB2_VARIANT := generic
endef endef
TARGET_DEVICES += generic TARGET_DEVICES += generic