git: 59b9210de67f - main - net/realtek-re-kmod: update to v1.97 release.

From: Alex Dupre <ale_at_FreeBSD.org>
Date: Thu, 15 Sep 2022 15:33:39 UTC
The branch main has been updated by ale:

URL: https://cgit.FreeBSD.org/ports/commit/?id=59b9210de67ff58e3a993aea4eaeb9f55d6b9645

commit 59b9210de67ff58e3a993aea4eaeb9f55d6b9645
Author:     Alex Dupre <ale@FreeBSD.org>
AuthorDate: 2022-09-15 15:32:25 +0000
Commit:     Alex Dupre <ale@FreeBSD.org>
CommitDate: 2022-09-15 15:32:25 +0000

    net/realtek-re-kmod: update to v1.97 release.
---
 net/realtek-re-kmod/Makefile                  |  11 +-
 net/realtek-re-kmod/distinfo                  |   6 +-
 net/realtek-re-kmod/files/patch-if__re.c      | 389 --------------------------
 net/realtek-re-kmod/files/patch-optional-dash |  20 --
 net/realtek-re-kmod/pkg-descr                 |   7 +-
 5 files changed, 15 insertions(+), 418 deletions(-)

diff --git a/net/realtek-re-kmod/Makefile b/net/realtek-re-kmod/Makefile
index c5c4999e2c1f..60fd1587507b 100644
--- a/net/realtek-re-kmod/Makefile
+++ b/net/realtek-re-kmod/Makefile
@@ -1,20 +1,23 @@
 PORTNAME=	re
-PORTVERSION=	196.04
+PORTVERSION=	197.00
 DISTVERSIONPREFIX=	v
 CATEGORIES=	net
-MASTER_SITES=	LOCAL/ale
 PKGNAMEPREFIX=	realtek-
 PKGNAMESUFFIX=	-kmod
-DISTNAME=	rtl_bsd_drv_${DISTVERSIONPREFIX}${PORTVERSION}
 
 MAINTAINER=	ale@FreeBSD.org
 COMMENT=	Kernel driver for Realtek PCIe Ethernet Controllers
-WWW=		https://www.realtek.com/en/component/zoo/category/network-interface-controllers-10-100-1000m-gigabit-ethernet-pci-express-software
+WWW=		https://github.com/alexdupre/rtl_bsd_drv
 
 LICENSE=	BSD4CLAUSE
 
 USES=		kmod tar:tgz uidfix
 
+USE_GITHUB=	yes
+GH_ACCOUNT=	alexdupre
+GH_PROJECT=	rtl_bsd_drv
+GH_TAGNAME=	1dff2e4
+
 PLIST_FILES=	${KMODDIR}/if_re.ko
 
 .include <bsd.port.mk>
diff --git a/net/realtek-re-kmod/distinfo b/net/realtek-re-kmod/distinfo
index 2a289846845f..51af6a46b38e 100644
--- a/net/realtek-re-kmod/distinfo
+++ b/net/realtek-re-kmod/distinfo
@@ -1,3 +1,3 @@
-TIMESTAMP = 1594744100
-SHA256 (rtl_bsd_drv_v196.04.tgz) = 1bffd5cc81da797474bd097cc88c03aac288970a0b7e7185b92a74070e9998a7
-SIZE (rtl_bsd_drv_v196.04.tgz) = 114985
+TIMESTAMP = 1662998501
+SHA256 (alexdupre-rtl_bsd_drv-v197.00-1dff2e4_GH0.tar.gz) = 6745b3dda49d6e3ec2d5bf927fa7bac6f54e90f7de391892f82f13818ccd4ed4
+SIZE (alexdupre-rtl_bsd_drv-v197.00-1dff2e4_GH0.tar.gz) = 132937
diff --git a/net/realtek-re-kmod/files/patch-if__re.c b/net/realtek-re-kmod/files/patch-if__re.c
deleted file mode 100644
index a9c2c8ffc6ba..000000000000
--- a/net/realtek-re-kmod/files/patch-if__re.c
+++ /dev/null
@@ -1,389 +0,0 @@
---- if_re.c.orig	2020-06-18 16:22:59 UTC
-+++ if_re.c
-@@ -62,8 +62,8 @@ __FBSDID("$FreeBSD: src/sys/dev/re/if_re.c,v " RE_VERS
- #include <sys/malloc.h>
- #include <sys/kernel.h>
- #include <sys/socket.h>
-+#include <sys/sysctl.h>
- #include <sys/taskqueue.h>
--#include <sys/random.h>
- 
- #include <net/if.h>
- #include <net/if_var.h>
-@@ -85,7 +85,7 @@ __FBSDID("$FreeBSD: src/sys/dev/re/if_re.c,v " RE_VERS
- #include <sys/endian.h>
- 
- #include <dev/mii/mii.h>
--#include <dev/re/if_rereg.h>
-+#include "if_rereg.h"
- #ifdef ENABLE_FIBER_SUPPORT
- #include <dev/re/if_fiber.h>
- #endif //ENABLE_FIBER_SUPPORT
-@@ -258,34 +258,48 @@ static void re_hw_start_unlock_8125(struct re_softc *s
- static void re_hw_start_unlock_8125(struct re_softc *sc);
- 
- /* Tunables. */
-+SYSCTL_NODE(_hw, OID_AUTO, re, CTLFLAG_RW | CTLFLAG_MPSAFE, 0, "");
- static int msi_disable = 1;
--TUNABLE_INT("hw.re.msi_disable", &msi_disable);
-+SYSCTL_INT(_hw_re, OID_AUTO, msi_disable, CTLFLAG_RDTUN, &msi_disable, 0,
-+    "");
- static int msix_disable = 0;
--TUNABLE_INT("hw.re.msix_disable", &msix_disable);
-+SYSCTL_INT(_hw_re, OID_AUTO, msix_disable, CTLFLAG_RDTUN, &msix_disable, 0,
-+    "");
- static int prefer_iomap = 0;
--TUNABLE_INT("hw.re.prefer_iomap", &prefer_iomap);
-+SYSCTL_INT(_hw_re, OID_AUTO, prefer_iomap, CTLFLAG_RDTUN, &prefer_iomap, 0,
-+    "");
- #ifdef ENABLE_EEE
- static int eee_enable = 1;
- #else
- static int eee_enable = 0;
- #endif
--TUNABLE_INT("hw.re.eee_enable", &eee_enable);
-+SYSCTL_INT(_hw_re, OID_AUTO, eee_enable, CTLFLAG_RDTUN, &eee_enable, 0,
-+    "");
- static int phy_power_saving = 1;
--TUNABLE_INT("hw.re.phy_power_saving", &phy_power_saving);
-+SYSCTL_INT(_hw_re, OID_AUTO, phy_power_saving, CTLFLAG_RDTUN,
-+    &phy_power_saving, 0,
-+    "");
- static int phy_mdix_mode = RE_ETH_PHY_AUTO_MDI_MDIX;
--TUNABLE_INT("hw.re.phy_mdix_mode", &phy_mdix_mode);
-+SYSCTL_INT(_hw_re, OID_AUTO, phy_mdix_mode, CTLFLAG_RDTUN, &phy_mdix_mode, 0,
-+    "");
- #ifdef ENABLE_S5WOL
- static int s5wol = 1;
- #else
- static int s5wol = 0;
--TUNABLE_INT("hw.re.s5wol", &s5wol);
-+SYSCTL_INT(_hw_re, OID_AUTO, s5wol, CTLFLAG_RDTUN, &s5wol, 0,
-+    "");
- #endif
- #ifdef ENABLE_S0_MAGIC_PACKET
- static int s0_magic_packet = 1;
- #else
- static int s0_magic_packet = 0;
- #endif
--TUNABLE_INT("hw.re.s0_magic_packet", &s0_magic_packet);
-+SYSCTL_INT(_hw_re, OID_AUTO, s0_magic_packet, CTLFLAG_RDTUN,
-+    &s0_magic_packet, 0,
-+    "");
-+static int max_rx_mbuf_sz = MJUM9BYTES;
-+SYSCTL_INT(_hw_re, OID_AUTO, max_rx_mbuf_sz, CTLFLAG_RDTUN, &max_rx_mbuf_sz, 0,
-+    "");
- 
- #define RE_CSUM_FEATURES    (CSUM_IP | CSUM_TCP | CSUM_UDP)
- 
-@@ -306,9 +320,13 @@ static driver_t re_driver = {
-         sizeof(struct re_softc)
- };
- 
-+#if __FreeBSD_version >= 1400058
-+DRIVER_MODULE(if_re, pci, re_driver, 0, 0);
-+#else
- static devclass_t re_devclass;
- 
- DRIVER_MODULE(if_re, pci, re_driver, re_devclass, 0, 0);
-+#endif
- 
- static void
- ClearAndSetEthPhyBit(
-@@ -874,9 +892,7 @@ static void re_release_rx_buf(struct re_softc *sc)
- 
- static void re_release_rx_buf(struct re_softc *sc)
- {
--        struct ifnet		*ifp;
-         int i;
--        ifp = RE_GET_IFNET(sc);
- 
-         if (sc->re_desc.re_rx_mtag) {
-                 for (i = 0; i < RE_RX_BUF_NUM; i++) {
-@@ -899,9 +915,7 @@ static void re_release_tx_buf(struct re_softc *sc)
- }
- static void re_release_tx_buf(struct re_softc *sc)
- {
--        struct ifnet		*ifp;
-         int i;
--        ifp = RE_GET_IFNET(sc);
- 
-         if (sc->re_desc.re_tx_mtag) {
-                 for (i = 0; i < RE_TX_BUF_NUM; i++) {
-@@ -930,6 +944,7 @@ static int re_alloc_buf(struct re_softc *sc)
-         int error =0;
-         int i,size;
- 
-+	RE_UNLOCK(sc);
-         error = bus_dma_tag_create(sc->re_parent_tag, 1, 0,
-                                    BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL,
-                                    NULL, MCLBYTES* RE_NTXSEGS, RE_NTXSEGS, 4096, 0,
-@@ -938,6 +953,7 @@ static int re_alloc_buf(struct re_softc *sc)
-         if (error) {
-                 //device_printf(dev,"re_tx_mtag fail\n");
-                 //goto fail;
-+		RE_LOCK(sc);
-                 return error;
-         }
- 
-@@ -955,9 +971,11 @@ static int re_alloc_buf(struct re_softc *sc)
-         if (error) {
-                 //device_printf(dev,"re_rx_mtag fail\n");
-                 //goto fail;
-+		RE_LOCK(sc);
-                 return error;
-         }
- 
-+	RE_LOCK(sc);
-         if (sc->re_rx_mbuf_sz <= MCLBYTES)
-                 size = MCLBYTES;
-         else if (sc->re_rx_mbuf_sz <=  MJUMPAGESIZE)
-@@ -3428,16 +3446,6 @@ is_valid_ether_addr(const u_int8_t * addr)
-         return !is_multicast_ether_addr(addr) && !is_zero_ether_addr(addr);
- }
- 
--static inline void
--random_ether_addr(u_int8_t * dst)
--{
--        if (read_random(dst, 6) == 0)
--                arc4rand(dst, 6, 0);
--
--        dst[0] &= 0xfe;
--        dst[0] |= 0x02;
--}
--
- static void re_disable_now_is_oob(struct re_softc *sc)
- {
-         if (sc->re_hw_supp_now_is_oob_ver == 1)
-@@ -3889,7 +3897,7 @@ static void re_get_hw_mac_address(struct re_softc *sc,
- 
-         if (!is_valid_ether_addr(eaddr)) {
-                 device_printf(dev,"Invalid ether addr: %6D\n", eaddr, ":");
--                random_ether_addr(eaddr);
-+                ether_gen_addr(sc->re_ifp, (struct ether_addr *)eaddr);
-                 device_printf(dev,"Random ether addr: %6D\n", eaddr, ":");
-         }
- 
-@@ -4291,9 +4299,9 @@ static void re_init_software_variable(struct re_softc 
- 
-         sc->re_rx_mbuf_sz = sc->max_jumbo_frame_size + ETHER_VLAN_ENCAP_LEN + ETHER_HDR_LEN + ETHER_CRC_LEN + RE_ETHER_ALIGN + 1;
- 
--        if (sc->re_rx_mbuf_sz > MJUM9BYTES) {
--                sc->max_jumbo_frame_size -= (sc->re_rx_mbuf_sz - MJUM9BYTES);
--                sc->re_rx_mbuf_sz = MJUM9BYTES;
-+        if (sc->re_rx_mbuf_sz > max_rx_mbuf_sz) {
-+                sc->max_jumbo_frame_size -= (sc->re_rx_mbuf_sz - max_rx_mbuf_sz);
-+                sc->re_rx_mbuf_sz = max_rx_mbuf_sz;
-         }
- 
-         switch(sc->re_type) {
-@@ -7073,12 +7081,11 @@ static void re_init_unlock(void *xsc)  	/* Software & 
-         return;
- }
- 
--static void re_init(void *xsc)  	/* Software & Hardware Initialize */
-+static void re_init_locked(void *xsc)
- {
-         struct re_softc		*sc = xsc;
-         struct ifnet		*ifp;
- 
--        RE_LOCK(sc);
-         ifp = RE_GET_IFNET(sc);
- 
-         if (re_link_ok(sc)) {
-@@ -7089,7 +7096,14 @@ static void re_init(void *xsc)  	/* Software & Hardwar
- 
-         sc->re_link_chg_det = 1;
-         re_start_timer(sc);
-+}
- 
-+static void re_init(void *xsc)  	/* Software & Hardware Initialize */
-+{
-+        struct re_softc		*sc = xsc;
-+
-+        RE_LOCK(sc);
-+	re_init_locked(sc);
-         RE_UNLOCK(sc);
- }
- 
-@@ -8153,7 +8167,9 @@ struct re_softc		*sc;
- static void re_rxeof(sc)	/* Receive Data OK/ERR handler */
- struct re_softc		*sc;
- {
-+#if OS_VER < VERSION(4,9)
-         struct ether_header	*eh;
-+#endif
-         struct mbuf		*m;
-         struct ifnet		*ifp;
-         union RxDesc *rxptr;
-@@ -8270,7 +8286,9 @@ struct re_softc		*sc;
-                         }
-                 }
- 
-+#if OS_VER < VERSION(4,9)
-                 eh = mtod(m, struct ether_header *);
-+#endif
- #if OS_VER < VERSION(11,0)
-                 ifp->if_ipackets++;
- #else
-@@ -8438,7 +8456,7 @@ static void re_int_task(void *arg, int npending)
-                         if ((status & RE_ISR_FIFO_OFLOW) &&
-                             (!(status & (RE_ISR_RX_OK | RE_ISR_TX_OK | RE_ISR_RX_OVERRUN)))) {
-                                 re_reset(sc);
--                                re_init(sc);
-+                                re_init_locked(sc);
-                                 sc->rx_fifo_overflow = 0;
-                                 CSR_WRITE_2(sc, RE_ISR, RE_ISR_FIFO_OFLOW);
-                         }
-@@ -8449,7 +8467,7 @@ static void re_int_task(void *arg, int npending)
- 
-         if (status & RE_ISR_SYSTEM_ERR) {
-                 re_reset(sc);
--                re_init(sc);
-+                re_init_locked(sc);
-         }
- 
-         switch(sc->re_type) {
-@@ -8514,7 +8532,7 @@ static void re_int_task_8125(void *arg, int npending)
- 
-         if (status & RE_ISR_SYSTEM_ERR) {
-                 re_reset(sc);
--                re_init(sc);
-+                re_init_locked(sc);
-         }
- 
-         RE_UNLOCK(sc);
-@@ -8560,11 +8578,8 @@ struct re_softc		*sc;
- static void re_set_rx_packet_filter_in_sleep_state(sc)
- struct re_softc		*sc;
- {
--        struct ifnet		*ifp;
-         u_int32_t		rxfilt;
- 
--        ifp = RE_GET_IFNET(sc);
--
-         rxfilt = CSR_READ_4(sc, RE_RXCFG);
- 
-         rxfilt &= ~(RE_RXCFG_RX_ALLPHYS | RE_RXCFG_RX_INDIV | RE_RXCFG_RX_MULTI | RE_RXCFG_RX_BROAD | RE_RXCFG_RX_RUNT | RE_RXCFG_RX_ERRPKT);
-@@ -8614,6 +8629,22 @@ struct re_softc		*sc;
-         return;
- }
- 
-+#if OS_VER >= VERSION(13,0)
-+static u_int
-+re_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
-+{
-+	uint32_t h, *hashes = arg;
-+
-+	h = ether_crc32_be(LLADDR(sdl), ETHER_ADDR_LEN) >> 26;
-+	if (h < 32)
-+		hashes[0] |= (1 << h);
-+	else
-+		hashes[1] |= (1 << (h - 32));
-+
-+	return (1);
-+}
-+#endif
-+
- /*
-  * Program the 64-bit multicast hash filter.
-  */
-@@ -8623,7 +8654,9 @@ struct re_softc		*sc;
-         struct ifnet		*ifp;
-         int			h = 0;
-         u_int32_t		hashes[2] = { 0, 0 };
-+#if OS_VER < VERSION(13,0)
-         struct ifmultiaddr	*ifma;
-+#endif
-         u_int32_t		rxfilt;
-         int			mcnt = 0;
- 
-@@ -8640,7 +8673,12 @@ struct re_softc		*sc;
-         }
- 
-         /* now program new ones */
--#if OS_VER > VERSION(6,0)
-+#if OS_VER >= VERSION(13,0)
-+	mcnt = if_foreach_llmaddr(ifp, re_hash_maddr, hashes);
-+#else
-+#if OS_VER >= VERSION(12,0)
-+	if_maddr_rlock(ifp);
-+#elif OS_VER > VERSION(6,0)
-         IF_ADDR_LOCK(ifp);
- #endif
- #if OS_VER < VERSION(4,9)
-@@ -8662,9 +8700,12 @@ struct re_softc		*sc;
-                         hashes[1] |= (1 << (h - 32));
-                 mcnt++;
-         }
--#if OS_VER > VERSION(6,0)
-+#if OS_VER >= VERSION(12,0)
-+	if_maddr_runlock(ifp);
-+#elif OS_VER > VERSION(6,0)
-         IF_ADDR_UNLOCK(ifp);
- #endif
-+#endif
- 
-         if (mcnt) {
-                 if ((sc->re_if_flags & RL_FLAG_PCIE) != 0) {
-@@ -8720,7 +8761,7 @@ caddr_t			data;
-                                 error =re_alloc_buf(sc);
- 
-                                 if (error == 0) {
--                                        re_init(sc);
-+                                        re_init_locked(sc);
-                                 }
-                                 RE_UNLOCK(sc);
- 
-@@ -8743,7 +8784,7 @@ caddr_t			data;
-         case SIOCSIFFLAGS:
-                 RE_LOCK(sc);
-                 if (ifp->if_flags & IFF_UP) {
--                        re_init(sc);
-+                        re_init_locked(sc);
-                 } else if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
-                         re_stop(sc);
-                 }
-@@ -30784,13 +30825,12 @@ static u_int8_t re_calc_efuse_dummy_bit(u_int16_t reg)
- 
- static u_int8_t re_calc_efuse_dummy_bit(u_int16_t reg)
- {
--        int s,a,b;
-+        int s,a;
-         u_int8_t dummyBitPos = 0;
- 
- 
-         s=reg% 32;
-         a=s % 16;
--        b=s/16;
- 
-         if (s/16) {
-                 dummyBitPos = (u_int8_t)(16-a);
-@@ -31395,19 +31435,16 @@ static void OOB_mutex_unlock(struct re_softc *sc)
- static void OOB_mutex_unlock(struct re_softc *sc)
- {
-         u_int16_t ocp_reg_mutex_ib;
--        u_int16_t ocp_reg_mutex_oob;
-         u_int16_t ocp_reg_mutex_prio;
- 
-         switch (sc->re_type) {
-         case MACFG_63:
-         case MACFG_64:
-         case MACFG_65:
--                ocp_reg_mutex_oob = 0x16;
-                 ocp_reg_mutex_ib = 0x17;
-                 ocp_reg_mutex_prio = 0x9C;
-                 break;
-         case MACFG_66:
--                ocp_reg_mutex_oob = 0x06;
-                 ocp_reg_mutex_ib = 0x07;
-                 ocp_reg_mutex_prio = 0x9C;
-                 break;
-@@ -31418,7 +31455,6 @@ static void OOB_mutex_unlock(struct re_softc *sc)
-         case MACFG_71:
-         case MACFG_72:
-         default:
--                ocp_reg_mutex_oob = 0x110;
-                 ocp_reg_mutex_ib = 0x114;
-                 ocp_reg_mutex_prio = 0x11C;
-                 break;
diff --git a/net/realtek-re-kmod/files/patch-optional-dash b/net/realtek-re-kmod/files/patch-optional-dash
deleted file mode 100644
index 7f7895c5b9ae..000000000000
--- a/net/realtek-re-kmod/files/patch-optional-dash
+++ /dev/null
@@ -1,20 +0,0 @@
---- if_re.c.orig	2022-01-17 17:01:39 UTC
-+++ if_re.c
-@@ -4351,6 +4351,7 @@
-                 sc->re_dash = re_check_dash(sc);
- 
-         if (sc->re_dash) {
-+#if defined(__amd64__) || defined(__i386__)
-                 if (HW_DASH_SUPPORT_TYPE_3(sc)) {
-                         u_int64_t CmacMemPhysAddress;
-                         bus_space_handle_t cmac_ioaddr;
-@@ -4370,6 +4371,9 @@
-                                         sc->re_mapped_cmac_handle = cmac_ioaddr;
-                         }
-                 }
-+#else
-+                sc->re_dash = 0;
-+#endif
-         }
- 
-         switch(sc->re_type) {
diff --git a/net/realtek-re-kmod/pkg-descr b/net/realtek-re-kmod/pkg-descr
index ea1d6410ea60..8f2ccbde49e5 100644
--- a/net/realtek-re-kmod/pkg-descr
+++ b/net/realtek-re-kmod/pkg-descr
@@ -1,14 +1,15 @@
 Realtek PCIe FE / GBE / 2.5G / Gaming Ethernet Family Controller
 kernel driver.
 
-This is the official driver from Realtek and can be loaded instead of
+This is the official driver from Realtek with a few patches to
+improve stability and performance. It can be loaded instead of
 the FreeBSD driver built into the GENERIC kernel if you experience
 issues with it (eg. watchdog timeouts), or your card is not supported.
 
 Supported devices:
 
 * 2.5G Gigabit Ethernet
-  - RTL8125 / RTL8125B(S)
+  - RTL8125 / RTL8125B(S)(G)
 
 * 10/100/1000M Gigabit Ethernet
   - RTL8111B / RTL8111C / RTL8111D / RTL8111E / RTL8111F / RTL8111G(S)
@@ -20,3 +21,5 @@ Supported devices:
 * 10/100M Fast Ethernet
   - RTL8101E / RTL8102E / RTL8103E / RTL8105E / RTL8106E / RTL8107E
   - RTL8401 / RTL8402
+
+See also: https://www.realtek.com/en/component/zoo/category/network-interface-controllers-10-100-1000m-gigabit-ethernet-pci-express-software