git: f7ea19958b03 - main - Convert mlx5_en to SIOCSIFCAPNV

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Tue, 24 May 2022 20:59:45 UTC
The branch main has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=f7ea19958b0313ed44c73a602708d57595f594bb

commit f7ea19958b0313ed44c73a602708d57595f594bb
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2021-10-19 17:56:55 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2022-05-24 20:59:32 +0000

    Convert mlx5_en to SIOCSIFCAPNV
    
    Reviewed by:    hselasky, jhb, kp (previous version)
    Sponsored by:   NVIDIA Networking
    MFC after:      3 weeks
    Differential revision:  https://reviews.freebsd.org/D32551
---
 sys/dev/mlx5/mlx5_en/mlx5_en_main.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/sys/dev/mlx5/mlx5_en/mlx5_en_main.c b/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
index 32d5d761674f..3a5b44406076 100644
--- a/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
+++ b/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
@@ -3434,6 +3434,7 @@ mlx5e_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
 	struct ifi2creq i2c;
 	struct ifrsskey *ifrk;
 	struct ifrsshash *ifrh;
+	struct siocsifcapnv_driver_data *drv_ioctl_data, drv_ioctl_data_d = {};
 	int error = 0;
 	int mask = 0;
 	int size_read = 0;
@@ -3512,10 +3513,22 @@ mlx5e_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
 		ifr = (struct ifreq *)data;
 		error = ifmedia_ioctl(ifp, ifr, &priv->media, command);
 		break;
+	case SIOCGIFCAPNV:
+		error = 0;
+		break;
 	case SIOCSIFCAP:
 		ifr = (struct ifreq *)data;
+		drv_ioctl_data = &drv_ioctl_data_d;
+		drv_ioctl_data->reqcap = ifr->ifr_reqcap;
+		PRIV_LOCK(priv);
+		drv_ioctl_data->reqcap2 = ifp->if_capabilities2;
+		drv_ioctl_data->nvcap = NULL;
+		goto siocsifcap_driver;
+	case SIOCSIFCAPNV:
+		drv_ioctl_data = (struct siocsifcapnv_driver_data *)data;
 		PRIV_LOCK(priv);
-		mask = ifr->ifr_reqcap ^ ifp->if_capenable;
+siocsifcap_driver:
+		mask = drv_ioctl_data->reqcap ^ ifp->if_capenable;
 
 		if (mask & IFCAP_TXCSUM) {
 			ifp->if_capenable ^= IFCAP_TXCSUM;
@@ -4518,6 +4531,7 @@ mlx5e_create_ifp(struct mlx5_core_dev *mdev)
 	/*
          * Set driver features
          */
+	ifp->if_capabilities |= IFCAP_NV;
 	ifp->if_capabilities |= IFCAP_HWCSUM | IFCAP_HWCSUM_IPV6;
 	ifp->if_capabilities |= IFCAP_VLAN_MTU | IFCAP_VLAN_HWTAGGING;
 	ifp->if_capabilities |= IFCAP_VLAN_HWCSUM | IFCAP_VLAN_HWFILTER;
@@ -4541,6 +4555,7 @@ mlx5e_create_ifp(struct mlx5_core_dev *mdev)
 	ifp->if_hw_tsomaxsegsize = MLX5E_MAX_TX_MBUF_SIZE;
 
 	ifp->if_capenable = ifp->if_capabilities;
+	ifp->if_capenable2 = ifp->if_capabilities2;
 	ifp->if_hwassist = 0;
 	if (ifp->if_capenable & IFCAP_TSO)
 		ifp->if_hwassist |= CSUM_TSO;