Gentoo Archives: gentoo-commits

From: Pacho Ramos <pacho@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: net-misc/r8168/files/, net-misc/r8168/
Date: Thu, 26 May 2022 09:44:12
Message-Id: 1653558232.ae9bc85fa88f2bbd5e806d623a2bb902987f744b.pacho@gentoo
1 commit: ae9bc85fa88f2bbd5e806d623a2bb902987f744b
2 Author: Pacho Ramos <pacho <AT> gentoo <DOT> org>
3 AuthorDate: Thu May 26 09:23:50 2022 +0000
4 Commit: Pacho Ramos <pacho <AT> gentoo <DOT> org>
5 CommitDate: Thu May 26 09:43:52 2022 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=ae9bc85f
7
8 net-misc/r8168: add 8.050.02
9
10 Also fix build with kernel 5.18
11
12 Thanks-to: Peter Levine
13 Closes: https://bugs.gentoo.org/847154
14 Signed-off-by: Pacho Ramos <pacho <AT> gentoo.org>
15
16 net-misc/r8168/Manifest | 1 +
17 net-misc/r8168/files/r8168-8.050.02-5.18-fix.patch | 51 ++++++++++++++++++++++
18 net-misc/r8168/r8168-8.050.02.ebuild | 40 +++++++++++++++++
19 3 files changed, 92 insertions(+)
20
21 diff --git a/net-misc/r8168/Manifest b/net-misc/r8168/Manifest
22 index 497e72dd1f42..256b1a5092df 100644
23 --- a/net-misc/r8168/Manifest
24 +++ b/net-misc/r8168/Manifest
25 @@ -1,2 +1,3 @@
26 DIST r8168-8.049.02.tar.bz2 113195 BLAKE2B ee34ac7249d732a867384fdd2c87321a513e7b2770c79d0c13666edca7d4bf752d853d7f91554d7ee716b3f30ec5f3a69aed96221a79a60282f0b6d2f70f05d6 SHA512 8ccb69ab533cde6ff88f0e8af2dd66f7e6ce9467020a727d47748c5109b64d6d14eee6bc151db5ddbe70a476a2def5f2faf3871902b335074f43dd05484d39e0
27 DIST r8168-8.050.00.tar.bz2 115418 BLAKE2B b3e24d0548494f1904b5d3341994bdda35a05a71dce85a64c9e87cbde7f40807b0b1bcd78401928ff7625e67606918d5c844e8254cbbab62ed3f8e8058a3f15b SHA512 04043fd01ea877ea9f422b8f2319630b8664a49b41363039fc725ed382dc5afb732dda59ba63021a94c50b12ed2f0b3585cd668d969bc06fdc40d08420dbdb95
28 +DIST r8168-8.050.02.tar.bz2 115331 BLAKE2B 37690019e6b8642929e167df426e1a5e3c4d805ab812541018fa950084061ad971648b867dc5723e611c43fecb0f04d5915bb8199006ac50640aef5a9c2eb41c SHA512 54d7080b598933c7d24ca513019c6c971f7472320d474ab4ed4148d859886f942e52896d0b98046a780319f708847596e6bc081a88a9c11e075593c97eb831b2
29
30 diff --git a/net-misc/r8168/files/r8168-8.050.02-5.18-fix.patch b/net-misc/r8168/files/r8168-8.050.02-5.18-fix.patch
31 new file mode 100644
32 index 000000000000..442fa1c3eadf
33 --- /dev/null
34 +++ b/net-misc/r8168/files/r8168-8.050.02-5.18-fix.patch
35 @@ -0,0 +1,51 @@
36 +Functions like 'pci_dma_sync_single_for_device', 'pci_set_dma_mask', and 'pci_set_consistent_dma_mask'
37 +no longer exist in 5.18.0.
38 +Fix similar to https://www.mail-archive.com/linux-kernel@×××××××××××.org/msg2238850.html
39 +
40 +--- a/src/r8168_n.c
41 ++++ b/src/r8168_n.c
42 +@@ -3698,7 +3698,11 @@
43 + txd->opts2 = 0;
44 + while (1) {
45 + memset(tmpAddr, pattern++, len - 14);
46 ++#if LINUX_VERSION_CODE < KERNEL_VERSION(5,18,0)
47 + pci_dma_sync_single_for_device(tp->pci_dev,
48 ++#else
49 ++ dma_sync_single_for_device(&tp->pci_dev->dev,
50 ++#endif
51 + le64_to_cpu(mapping),
52 + len, DMA_TO_DEVICE);
53 + txd->opts1 = cpu_to_le32(DescOwn | FirstFrag | LastFrag | len);
54 +@@ -3726,7 +3730,11 @@
55 + if (rx_len == len) {
56 + dma_sync_single_for_cpu(tp_to_dev(tp), le64_to_cpu(rxd->addr), tp->rx_buf_sz, DMA_FROM_DEVICE);
57 + i = memcmp(skb->data, rx_skb->data, rx_len);
58 ++#if LINUX_VERSION_CODE < KERNEL_VERSION(5,18,0)
59 + pci_dma_sync_single_for_device(tp->pci_dev, le64_to_cpu(rxd->addr), tp->rx_buf_sz, DMA_FROM_DEVICE);
60 ++#else
61 ++ dma_sync_single_for_device(&tp->pci_dev->dev, le64_to_cpu(rxd->addr), tp->rx_buf_sz, DMA_FROM_DEVICE);
62 ++#endif
63 + if (i == 0) {
64 + // dev_printk(KERN_INFO, tp_to_dev(tp), "loopback test finished\n",rx_len,len);
65 + break;
66 +@@ -26408,11 +26416,20 @@
67 +
68 + if ((sizeof(dma_addr_t) > 4) &&
69 + use_dac &&
70 ++#if LINUX_VERSION_CODE < KERNEL_VERSION(5,18,0)
71 + !pci_set_dma_mask(pdev, DMA_BIT_MASK(64)) &&
72 + !pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64))) {
73 ++#else
74 ++ !dma_set_mask(&pdev->dev, DMA_BIT_MASK(64)) &&
75 ++ !dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(64))) {
76 ++#endif
77 + dev->features |= NETIF_F_HIGHDMA;
78 + } else {
79 ++#if LINUX_VERSION_CODE < KERNEL_VERSION(5,18,0)
80 + rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
81 ++#else
82 ++ rc = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32));
83 ++#endif
84 + if (rc < 0) {
85 + #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,0)
86 + if (netif_msg_probe(tp))
87
88 diff --git a/net-misc/r8168/r8168-8.050.02.ebuild b/net-misc/r8168/r8168-8.050.02.ebuild
89 new file mode 100644
90 index 000000000000..33393afdbf6a
91 --- /dev/null
92 +++ b/net-misc/r8168/r8168-8.050.02.ebuild
93 @@ -0,0 +1,40 @@
94 +# Copyright 1999-2022 Gentoo Authors
95 +# Distributed under the terms of the GNU General Public License v2
96 +
97 +EAPI=8
98 +
99 +inherit linux-info linux-mod
100 +
101 +DESCRIPTION="r8168 driver for Realtek 8111/8168 PCI-E NICs"
102 +HOMEPAGE="https://www.realtek.com/en/component/zoo/category/network-interface-controllers-10-100-1000m-gigabit-ethernet-pci-express-software"
103 +
104 +# "GBE Ethernet LINUX driver r8168 for kernel up to 5.17" from above link,
105 +# we need to mirror it to avoid users from needing to fill a captcha to
106 +# download
107 +SRC_URI="https://dev.gentoo.org/~pacho/${PN}/${P}.tar.bz2"
108 +
109 +LICENSE="GPL-2"
110 +SLOT="0"
111 +KEYWORDS="~amd64 ~x86"
112 +
113 +MODULE_NAMES="r8168(net:${S}/src)"
114 +BUILD_TARGETS="modules"
115 +IUSE="use-firmware"
116 +
117 +CONFIG_CHECK="~!R8169"
118 +WARNING_R8169="CONFIG_R8169 is enabled. ${P} will not be loaded unless kernel driver Realtek 8169 PCI Gigabit Ethernet (CONFIG_R8169) is DISABLED."
119 +
120 +PATCHES=(
121 + "${FILESDIR}/r8168-8.050.02-5.18-fix.patch"
122 +)
123 +
124 +pkg_setup() {
125 + linux-mod_pkg_setup
126 + BUILD_PARAMS="KERNELDIR=${KV_DIR}"
127 + BUILD_PARAMS+=" ENABLE_USE_FIRMWARE_FILE=$(usex use-firmware y n)"
128 +}
129 +
130 +src_install() {
131 + linux-mod_src_install
132 + einstalldocs
133 +}