commit:     95809b7071235e3b3d637432575a9e8e43e597f6
Author:     Jay Faulkner <jay <AT> jvf <DOT> cc>
AuthorDate: Thu Sep 12 03:33:53 2024 +0000
Commit:     Eli Schwartz <eschwartz <AT> gentoo <DOT> org>
CommitDate: Fri Sep 20 03:06:20 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=95809b70

net-misc/r8152: add 2.18.1, update metadata

This introduces the next version of r8152, but also includes a change in
source. It is no longer possible to download the r8152 sources directly
from realtek without passing a captcha challenge. So, I imported the
tarballs directly into a new github project, documented the source and
the SHA256, and am now using releases from that as the source.

Signed-off-by: Jay Faulkner <jay <AT> jvf.cc>
Closes: https://github.com/gentoo/gentoo/pull/38573
[Eli: dropped stable keyword for bump]
Signed-off-by: Eli Schwartz <eschwartz <AT> gentoo.org>

 net-misc/r8152/Manifest                            |   1 +
 .../r8152/files/r8152-2.18.1-kernel-6.9-fix.patch  | 134 +++++++++++++++++++++
 net-misc/r8152/metadata.xml                        |  10 +-
 net-misc/r8152/r8152-2.18.1.ebuild                 |  55 +++++++++
 4 files changed, 198 insertions(+), 2 deletions(-)

diff --git a/net-misc/r8152/Manifest b/net-misc/r8152/Manifest
index cb9a42a0c0e3..60c6ab7c9d0c 100644
--- a/net-misc/r8152/Manifest
+++ b/net-misc/r8152/Manifest
@@ -1 +1,2 @@
 DIST r8152-2.17.1.tar.bz2 75156 BLAKE2B 
05b55ea17a579add9a9abee89db490685086bfe29aeea6cbfbdbb63a81dbee4d1cac151822c178e52febe4bee14a3b5deb20737f671fcdbc6dd6d01938b1d18c
 SHA512 
e465b524ee8aaed12da8258195fb8a4c9fea0862812c1ab268e31ad6ec61444c4f4332d643124063b389fd1df7a271c6c057537d4cbe67188a1a2262b4793f42
+DIST r8152-2.18.1.tar.gz 109919 BLAKE2B 
59fa24b599a7378109e162689ef4ff305dc0d3a7f3bc77059d9e2f142e0b4fd01b38fcfdfe7bc1f3aa13805302522632e4305990133d53266d7c268e1f2284c0
 SHA512 
c99f482bd69b2263943bdb26a8fea40eed09ca21f8f42436937dc5c83239f0fe48a386ea4f2ddf90a193c808503a3709ea9637793d476774107c4757b56c4223

diff --git a/net-misc/r8152/files/r8152-2.18.1-kernel-6.9-fix.patch 
b/net-misc/r8152/files/r8152-2.18.1-kernel-6.9-fix.patch
new file mode 100644
index 000000000000..155a5aa1100b
--- /dev/null
+++ b/net-misc/r8152/files/r8152-2.18.1-kernel-6.9-fix.patch
@@ -0,0 +1,134 @@
+From 32d026ab6b601cfe2882818921ba379cfbc3031e Mon Sep 17 00:00:00 2001
+From: Jay Faulkner <[email protected]>
+Date: Wed, 11 Sep 2024 20:30:33 -0700
+Subject: [PATCH] Forward ported version of kernel 6.9.x fix patch
+
+Original version sourced from below; has been forward-ported from
+From: https://github.com/wget/realtek-r8152-linux/pull/41
+From a5b3b4a882a3a637ccfa447dc7d2e84eac9ef0fc Mon Sep 17 00:00:00 2001
+From: "oleg.hoefling" <[email protected]>
+---
+ r8152.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++----
+ 1 file changed, 46 insertions(+), 4 deletions(-)
+
+diff --git a/r8152.c b/r8152.c
+index cee3b23..4063525 100644
+--- a/r8152.c
++++ b/r8152.c
+@@ -1006,7 +1006,10 @@ struct r8152 {
+               int (*up)(struct r8152 *tp);
+               int (*down)(struct r8152 *tp);
+               void (*unload)(struct r8152 *tp);
+-#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,9,0)
++        int (*eee_get)(struct r8152 *tp, struct ethtool_keee *eee);
++        int (*eee_set)(struct r8152 *tp, struct ethtool_keee *eee);
++#elif LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)
+               int (*eee_get)(struct r8152 *tp, struct ethtool_eee *eee);
+               int (*eee_set)(struct r8152 *tp, struct ethtool_eee *eee);
+ #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0) */
+@@ -23342,8 +23345,13 @@ static void rtl8152_get_strings(struct net_device 
*dev, u32 stringset, u8 *data)
+       }
+ }
+ 
++
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,9,0)
++static int r8152_get_eee(struct r8152 *tp, struct ethtool_keee *eee)
++#else
+ static int r8152_get_eee(struct r8152 *tp, struct ethtool_eee *eee)
++#endif
+ {
+       u32 lp, adv, supported = 0;
+       int ret;
+@@ -23369,17 +23377,33 @@ static int r8152_get_eee(struct r8152 *tp, struct 
ethtool_eee *eee)
+ 
+       eee->eee_enabled = tp->eee_en;
+       eee->eee_active = !!(supported & adv & lp);
+-      eee->supported = supported;
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,9,0)
++      ethtool_convert_legacy_u32_to_link_mode(eee->supported, supported);
++      ethtool_convert_legacy_u32_to_link_mode(eee->advertised, tp->eee_adv);
++      ethtool_convert_legacy_u32_to_link_mode(eee->lp_advertised, lp);
++#else
++    eee->supported = supported;
+       eee->advertised = mmd_eee_adv_to_ethtool_adv_t(tp->eee_adv);
+       eee->lp_advertised = lp;
++#endif
+ 
+ out:
+       return (ret < 0) ? ret : 0;
+ }
+ 
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,9,0)
++static int r8152_set_eee(struct r8152 *tp, struct ethtool_keee *eee)
++#else
+ static int r8152_set_eee(struct r8152 *tp, struct ethtool_eee *eee)
++#endif
+ {
+-      u16 val = ethtool_adv_to_mmd_eee_adv_t(eee->advertised);
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,9,0)
++    u32 advertised = 0;
++    ethtool_convert_link_mode_to_legacy_u32(&advertised, eee->advertised);
++    u16 val = ethtool_adv_to_mmd_eee_adv_t(advertised);
++#else
++    u16 val = ethtool_adv_to_mmd_eee_adv_t(eee->advertised);
++#endif
+ 
+       tp->eee_en = eee->eee_enabled;
+       tp->eee_adv = val;
+@@ -23387,7 +23411,11 @@ static int r8152_set_eee(struct r8152 *tp, struct 
ethtool_eee *eee)
+       return rtl_eee_enable(tp, tp->eee_en);
+ }
+ 
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,9,0)
++static int r8153_get_eee(struct r8152 *tp, struct ethtool_keee *eee)
++#else
+ static int r8153_get_eee(struct r8152 *tp, struct ethtool_eee *eee)
++#endif
+ {
+       u32 lp, adv, supported = 0;
+       u16 val;
+@@ -23410,16 +23438,26 @@ static int r8153_get_eee(struct r8152 *tp, struct 
ethtool_eee *eee)
+ 
+       eee->eee_enabled = tp->eee_en;
+       eee->eee_active = !!(supported & adv & lp);
+-      eee->supported = supported;
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,9,0)
++      ethtool_convert_legacy_u32_to_link_mode(eee->supported, supported);
++      ethtool_convert_legacy_u32_to_link_mode(eee->advertised, tp->eee_adv);
++      ethtool_convert_legacy_u32_to_link_mode(eee->lp_advertised, lp);
++#else
++    eee->supported = supported;
+       eee->advertised = mmd_eee_adv_to_ethtool_adv_t(tp->eee_adv);
+       eee->lp_advertised = lp;
++#endif
+ 
+ out:
+       return (ret < 0) ? ret : 0;
+ }
+ 
+ static int
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,9,0)
++rtl_ethtool_get_eee(struct net_device *net, struct ethtool_keee *edata)
++#else
+ rtl_ethtool_get_eee(struct net_device *net, struct ethtool_eee *edata)
++#endif
+ {
+       struct r8152 *tp = netdev_priv(net);
+       int ret;
+@@ -23446,7 +23484,11 @@ out:
+ }
+ 
+ static int
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,9,0)
++rtl_ethtool_set_eee(struct net_device *net, struct ethtool_keee *edata)
++#else
+ rtl_ethtool_set_eee(struct net_device *net, struct ethtool_eee *edata)
++#endif
+ {
+       struct r8152 *tp = netdev_priv(net);
+       int ret;
+-- 
+2.46.0
+

diff --git a/net-misc/r8152/metadata.xml b/net-misc/r8152/metadata.xml
index b840941c9ce9..932424f746ed 100644
--- a/net-misc/r8152/metadata.xml
+++ b/net-misc/r8152/metadata.xml
@@ -9,9 +9,15 @@
                <email>[email protected]</email>
                <name>Proxy Maintainers</name>
        </maintainer>
-       <longdescription>Official Realtek r8152 linux driver. The following 
cards are currently supported:
-RTL8156 RTL8156B(S)(G) RTL8153 RTL8153B RTL8154 RTL8154B 
RTL8152B</longdescription>
+       <longdescription>
+               Official Realtek r8152 linux driver. Supports most realtek
+               USB network cards, including: RTL8157, RTL8156(,B), 
RTL8153(,B,C,D,E),
+               RTL8154(,B), RTL8152B.
+       </longdescription>
        <use>
                <flag name="center-tap-short">Enable support for center tap 
short</flag>
        </use>
+       <upstream>
+               <remote-id 
type="github">jayofdoom/realtek-r8152-unchanged</remote-id>
+       </upstream>
 </pkgmetadata>

diff --git a/net-misc/r8152/r8152-2.18.1.ebuild 
b/net-misc/r8152/r8152-2.18.1.ebuild
new file mode 100644
index 000000000000..ca03338e82f4
--- /dev/null
+++ b/net-misc/r8152/r8152-2.18.1.ebuild
@@ -0,0 +1,55 @@
+# Copyright 1999-2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+inherit linux-mod-r1 udev
+
+DESCRIPTION="r8152 driver for Realtek USB FE / GBE / 2.5G Gaming Ethernet 
Family Controller"
+# Using github readme as homepage as the realtek page has changed location 
twice in six months.
+HOMEPAGE="https://github.com/jayofdoom/realtek-r8152-unchanged";
+SRC_URI="https://github.com/jayofdoom/realtek-r8152-unchanged/archive/refs/tags/v${PV}.tar.gz
 -> ${P}.tar.gz"
+S="${WORKDIR}/realtek-r8152-unchanged-${PV}"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="~amd64 ~x86"
+
+RDEPEND="virtual/udev"
+DEPEND="${RDEPEND}"
+
+IUSE="+center-tap-short"
+
+# Many of the patches are sourced from pull requests to
+# https://github.com/wget/realtek-r8152-linux/ -- we do not use this repo
+# as the official upstream as it does not keep a clear deliniation between
+# shipped realtek code and patches. It is the source used by the AUR package.
+PATCHES=(
+       "${FILESDIR}"/${PN}-2.16.3-kernel-6.4.10-fix.patch
+       "${FILESDIR}"/${PN}-2.16.3-asus-c5000-support.patch
+       "${FILESDIR}"/${PN}-2.18.1-kernel-6.9-fix.patch
+)
+
+src_compile() {
+       local modlist=( ${PN}=kernel/net/usb:. )
+       local modargs=(
+               KERNELDIR="${KV_OUT_DIR}"
+               CONFIG_CTAP_SHORT="$(usex center-tap-short on off)"
+       )
+
+       linux-mod-r1_src_compile
+}
+
+src_install() {
+       linux-mod-r1_src_install
+       udev_dorules 50-usb-realtek-net.rules
+}
+
+pkg_postinst() {
+       linux-mod-r1_pkg_postinst
+       udev_reload
+}
+
+pkg_postrm() {
+       udev_reload
+}

Reply via email to