[newlib 62/65] Kernel-side infrastructure to implement nvlist-based set/get ifcaps

Sebastian Huber sebastian.huber at embedded-brains.de
Thu Jul 7 11:59:09 UTC 2022


From: Konstantin Belousov <kib at FreeBSD.org>

Reviewed by:	hselasky, jhb, kp (previous version)
Sponsored by:	NVIDIA Networking
MFC after:	3 weeks
Differential revision:	https://reviews.freebsd.org/D32551
---
 newlib/libc/sys/rtems/include/net/if.h     | 48 +++++++++++++++++++++-
 newlib/libc/sys/rtems/include/sys/sockio.h |  3 ++
 2 files changed, 49 insertions(+), 2 deletions(-)

diff --git a/newlib/libc/sys/rtems/include/net/if.h b/newlib/libc/sys/rtems/include/net/if.h
index c15013005..7649102c1 100644
--- a/newlib/libc/sys/rtems/include/net/if.h
+++ b/newlib/libc/sys/rtems/include/net/if.h
@@ -236,7 +236,7 @@ struct if_data {
 #define	IFCAP_TOE4		0x04000	/* interface can offload TCP */
 #define	IFCAP_TOE6		0x08000	/* interface can offload TCP6 */
 #define	IFCAP_VLAN_HWFILTER	0x10000 /* interface hw can filter vlan tag */
-/* 	available		0x20000 */
+#define	IFCAP_NV		0x20000 /* can do SIOCGIFCAPNV/SIOCSIFCAPNV */
 #define	IFCAP_VLAN_HWTSO	0x40000 /* can do IFCAP_TSO on VLANs */
 #define	IFCAP_LINKSTATE		0x80000 /* the runtime link state is dynamic */
 #define	IFCAP_NETMAP		0x100000 /* netmap mode supported/enabled */
@@ -260,7 +260,40 @@ struct if_data {
 #define	IFCAP_TOE	(IFCAP_TOE4 | IFCAP_TOE6)
 #define	IFCAP_TXTLS	(IFCAP_TXTLS4 | IFCAP_TXTLS6)
 
-#define	IFCAP_CANTCHANGE	(IFCAP_NETMAP)
+#define	IFCAP_CANTCHANGE	(IFCAP_NETMAP | IFCAP_NV)
+#define	IFCAP_ALLCAPS		0xffffffff
+
+#define	IFCAP_RXCSUM_NAME	"RXCSUM"
+#define	IFCAP_TXCSUM_NAME	"TXCSUM"
+#define	IFCAP_NETCONS_NAME	"NETCONS"
+#define	IFCAP_VLAN_MTU_NAME	"VLAN_MTU"
+#define	IFCAP_VLAN_HWTAGGING_NAME "VLAN_HWTAGGING"
+#define	IFCAP_JUMBO_MTU_NAME	"JUMBO_MTU"
+#define	IFCAP_POLLING_NAME	"POLLING"
+#define	IFCAP_VLAN_HWCSUM_NAME	"VLAN_HWCSUM"
+#define	IFCAP_TSO4_NAME		"TSO4"
+#define	IFCAP_TSO6_NAME		"TSO6"
+#define	IFCAP_LRO_NAME		"LRO"
+#define	IFCAP_WOL_UCAST_NAME	"WOL_UCAST"
+#define	IFCAP_WOL_MCAST_NAME	"WOL_MCAST"
+#define	IFCAP_WOL_MAGIC_NAME	"WOL_MAGIC"
+#define	IFCAP_TOE4_NAME		"TOE4"
+#define	IFCAP_TOE6_NAME		"TOE6"
+#define	IFCAP_VLAN_HWFILTER_NAME "VLAN_HWFILTER"
+#define	IFCAP_VLAN_HWTSO_NAME	"VLAN_HWTSO"
+#define	IFCAP_LINKSTATE_NAME	"LINKSTATE"
+#define	IFCAP_NETMAP_NAME	"NETMAP"
+#define	IFCAP_RXCSUM_IPV6_NAME	"RXCSUM_IPV6"
+#define	IFCAP_TXCSUM_IPV6_NAME	"TXCSUM_IPV6"
+#define	IFCAP_HWSTATS_NAME	"HWSTATS"
+#define	IFCAP_TXRTLMT_NAME	"TXRTLMT"
+#define	IFCAP_HWRXTSTMP_NAME	"HWRXTSTMP"
+#define	IFCAP_MEXTPG_NAME	"MEXTPG"
+#define	IFCAP_TXTLS4_NAME	"TXTLS4"
+#define	IFCAP_TXTLS6_NAME	"TXTLS6"
+#define	IFCAP_VXLAN_HWCSUM_NAME	"VXLAN_HWCSUM"
+#define	IFCAP_VXLAN_HWTSO_NAME	"VXLAN_HWTSO"
+#define	IFCAP_TXTLS_RTLMT_NAME	"TXTLS_RTLMT"
 
 #define	IFQ_MAXLEN	50
 #define	IFNET_SLOWHZ	1		/* granularity is 1 second */
@@ -387,6 +420,15 @@ struct ifreq_buffer {
 	void	*buffer;
 };
 
+struct ifreq_nv_req {
+	u_int	buf_length;	/* Total size of buffer,
+				   u_int for ABI struct ifreq */
+	u_int	length;		/* Length of the filled part */
+	void	*buffer;	/* Buffer itself, containing packed nv */
+};
+
+#define	IFR_CAP_NV_MAXBUFSIZE	(2 * 1024 * 1024)
+
 /*
  * Interface request structure used for socket
  * ioctl's.  All interface ioctl's must have parameter
@@ -411,6 +453,7 @@ struct ifreq {
 		int	ifru_cap[2];
 		u_int	ifru_fib;
 		u_char	ifru_vlan_pcp;
+		struct	ifreq_nv_req ifru_nv;
 	} ifr_ifru;
 #define	ifr_addr	ifr_ifru.ifru_addr	/* address */
 #define	ifr_dstaddr	ifr_ifru.ifru_dstaddr	/* other end of p-to-p link */
@@ -434,6 +477,7 @@ struct ifreq {
 #define	ifr_fib		ifr_ifru.ifru_fib	/* interface fib */
 #define	ifr_vlan_pcp	ifr_ifru.ifru_vlan_pcp	/* VLAN priority */
 #define	ifr_lan_pcp	ifr_ifru.ifru_vlan_pcp	/* VLAN priority */
+#define	ifr_cap_nv	ifr_ifru.ifru_nv	/* nv-based cap interface */
 };
 
 #define	_SIZEOF_ADDR_IFREQ(ifr) \
diff --git a/newlib/libc/sys/rtems/include/sys/sockio.h b/newlib/libc/sys/rtems/include/sys/sockio.h
index 93b8af28e..b9ed4a439 100644
--- a/newlib/libc/sys/rtems/include/sys/sockio.h
+++ b/newlib/libc/sys/rtems/include/sys/sockio.h
@@ -147,4 +147,7 @@
 
 #define	SIOCGIFDOWNREASON	_IOWR('i', 154, struct ifdownreason)
 
+#define	SIOCSIFCAPNV	_IOW('i', 155, struct ifreq)	/* set IF features */
+#define	SIOCGIFCAPNV	_IOWR('i', 156, struct ifreq)	/* get IF features */
+
 #endif /* !_SYS_SOCKIO_H_ */
-- 
2.35.3



More information about the devel mailing list