git: be7bdd6616c0 - main - net/wifi-firmware-*: add support to set loader tunable

From: Bjoern A. Zeeb <bz_at_FreeBSD.org>
Date: Sun, 10 Nov 2024 23:22:41 UTC
The branch main has been updated by bz:

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

commit be7bdd6616c0980dfa2f8e91bd52d7f3b5f969e1
Author:     Bjoern A. Zeeb <bz@FreeBSD.org>
AuthorDate: 2024-11-07 22:37:33 +0000
Commit:     Bjoern A. Zeeb <bz@FreeBSD.org>
CommitDate: 2024-11-10 23:20:15 +0000

    net/wifi-firmware-*: add support to set loader tunable
    
    For drivers which currently need to set the
    compat.linuxkpi.skb.mem_limit tunable add an option to the build
    to create it automatically for each FLAVOR.   There is no harm
    if it is there multiple times setting it to the same value (apart
    from file including and parsing overhead in loader -- however that
    works).
    
    Add the option to the rtw88 and rtw89 wifi-firmware Makefile.
    
    Having it with the firmware package has multiple advantages:
    - the user does not have to do any manual configuration anymore
    - we do not have to configure setting it into the release builds
    - bsdinstall does not need to know about it to set for the installed
      system (depending on driver).
    
    Bump PORTREVISION.
    
    Sponsored by:   The FreeBSD Foundation
    MFC after:      1 minute
    X-MFC for:      releng 14.2
    Differential Revision: https://reviews.freebsd.org/D47481
---
 net/wifi-firmware-kmod/Makefile.inc   | 18 +++++++++++++++++-
 net/wifi-firmware-rtw88-kmod/Makefile |  2 ++
 net/wifi-firmware-rtw89-kmod/Makefile |  2 ++
 3 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/net/wifi-firmware-kmod/Makefile.inc b/net/wifi-firmware-kmod/Makefile.inc
index f592ac252d75..c8de13d05776 100644
--- a/net/wifi-firmware-kmod/Makefile.inc
+++ b/net/wifi-firmware-kmod/Makefile.inc
@@ -1,5 +1,6 @@
 PORTNAME=	wifi-firmware-${FWDRV}-kmod
 PORTVERSION=	${FWDRV_VERSION}
+PORTREVISION=	1
 CATEGORIES=	net
 MASTER_SITES=	https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/plain/ \
 		https://ams.source.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/plain/ \
@@ -84,6 +85,8 @@ USES=		uidfix
 # OSVERSION seems to not add the _USES_install bits from kmod.mk.
 USES+=		kmod
 
+BOOT_LOADERCONFD=	/boot/loader.conf.d
+
 .include <bsd.port.pre.mk>
 
 .if (${OSVERSION} >= 1500014) || (${OSVERSION} < 1500000 && ${OSVERSION} >= 1402000)
@@ -106,6 +109,12 @@ post-extract:
 	@${CP} ${DISTDIR}/${DIST_SUBDIR}/WHENCE${DISTURL_SUFFIX} ${WRKSRC}/WHENCE.in
 	@${SED} -e "s@%%XXX%%@${WHENCE_REGEX:Q}@g" ${FILESDIR}/WHENCE.awk.in > ${WRKSRC}/WHENCE.awk
 	@${AWK} -f ${WRKSRC}/WHENCE.awk ${WRKSRC}/WHENCE.in > ${WRKSRC}/WHENCE
+	# Do we need to set a tunable?
+.if defined(COMPAT_LINUXKPI_SKB_MEM_LIMIT) && ${COMPAT_LINUXKPI_SKB_MEM_LIMIT} > 0
+	@${MKDIR} ${WRKSRC}/${BOOT_LOADERCONFD}
+	@${ECHO_CMD} "compat.linuxkpi.skb.mem_limit=${COMPAT_LINUXKPI_SKB_MEM_LIMIT}" > ${WRKSRC}/${BOOT_LOADERCONFD}/${FLAVOR}.conf
+	@${ECHO_CMD} "${BOOT_LOADERCONFD}/${FLAVOR}.conf" >> ${PLIST}
+.endif
 ################################################################################
 .if (${OSVERSION} >= 1500014) || (${OSVERSION} < 1500000 && ${OSVERSION} >= 1402000)
 .for _f in ${DISTFILES_${FLAVOR}}
@@ -117,7 +126,7 @@ post-extract:
 	(cd ${WRKSRC}/fw/ && ${FIND} . -type d -mindepth 1 | \
 	    ${AWK} -vB="${BOOTFWDIR}/" '{ sub("^./", "@dir "B); print; }') >> ${PLIST}.tmp
 	# Remove possibly duplicate @dir entries
-	@${SORT} -u ${PLIST}.tmp > ${PLIST}
+	@${SORT} -u ${PLIST}.tmp >> ${PLIST}
 .else
 ################################################################################
 # Build kernel modules.
@@ -157,4 +166,11 @@ do-install:
 	(cd ${WRKSRC}/fw/ && ${COPYTREE_SHARE} . ${STAGEDIR}/${BOOTFWDIR})
 .endif
 
+.if defined(COMPAT_LINUXKPI_SKB_MEM_LIMIT) && ${COMPAT_LINUXKPI_SKB_MEM_LIMIT} > 0
+post-install:
+	@${MKDIR} ${STAGEDIR}/${BOOT_LOADERCONFD}
+	@${INSTALL_DATA} ${WRKSRC}/${BOOT_LOADERCONFD}/${FLAVOR}.conf ${STAGEDIR}/${BOOT_LOADERCONFD}/${FLAVOR}.conf
+.endif
+
+
 .include <bsd.port.post.mk>
diff --git a/net/wifi-firmware-rtw88-kmod/Makefile b/net/wifi-firmware-rtw88-kmod/Makefile
index 5c855868ae36..dfd374718937 100644
--- a/net/wifi-firmware-rtw88-kmod/Makefile
+++ b/net/wifi-firmware-rtw88-kmod/Makefile
@@ -13,6 +13,8 @@ LICENSE_NAME=	Realtek firmware license (${FWDRV})
 
 WHENCE_REGEX=	rtw88 -.*
 
+COMPAT_LINUXKPI_SKB_MEM_LIMIT=	1
+
 # The flavor/firmware lists below are generated by a script
 # also helping to generate the fwget(8) definitions.
 # { sys/contrib/dev/rtw88/zzz_fw_ports_fwget.sh }
diff --git a/net/wifi-firmware-rtw89-kmod/Makefile b/net/wifi-firmware-rtw89-kmod/Makefile
index 83e77567b43b..abe723dfd687 100644
--- a/net/wifi-firmware-rtw89-kmod/Makefile
+++ b/net/wifi-firmware-rtw89-kmod/Makefile
@@ -10,6 +10,8 @@ LICENSE_NAME=	Realtek firmware license (${FWDRV})
 
 WHENCE_REGEX=	rtw89 -.*
 
+COMPAT_LINUXKPI_SKB_MEM_LIMIT=	1
+
 # The flavor/firmware lists below are generated by a script
 # also helping to generate the fwget(8) definitions.
 # { sys/contrib/dev/rtw89/zzz_fw_ports_fwget.sh }