diff mbox series

[net-next,v3,04/14] sfc: evaluate vdpa support based on FW capability CLIENT_CMD_VF_PROXY

Message ID 20230406065706.59664-5-gautam.dawar@amd.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series sfc: add vDPA support for EF100 devices | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 18 this patch: 18
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 18 this patch: 18
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 18 this patch: 18
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 131 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Gautam Dawar April 6, 2023, 6:56 a.m. UTC
Add and update vdpa_supported field to struct efx_nic to true if
running Firmware supports CLIENT_CMD_VF_PROXY capability. This is
required to ensure DMA isolation between MCDI command buffer and guest
buffers.
Also, split efx_ef100_init_datapath_caps() into a generic API that vDPA
can use, and the netdev (TSO) specific code is moved to a new function
efx_ef100_update_tso_features()

Signed-off-by: Gautam Dawar <gautam.dawar@amd.com>
---
 drivers/net/ethernet/sfc/ef100_netdev.c | 26 +++++++++++++--
 drivers/net/ethernet/sfc/ef100_nic.c    | 43 +++++++++++++------------
 drivers/net/ethernet/sfc/ef100_nic.h    |  6 ++--
 3 files changed, 49 insertions(+), 26 deletions(-)

Comments

kernel test robot April 6, 2023, 1:12 p.m. UTC | #1
Hi Gautam,

kernel test robot noticed the following build errors:

[auto build test ERROR on net-next/main]

url:    https://github.com/intel-lab-lkp/linux/commits/Gautam-Dawar/sfc-add-function-personality-support-for-EF100-devices/20230406-151436
patch link:    https://lore.kernel.org/r/20230406065706.59664-5-gautam.dawar%40amd.com
patch subject: [PATCH net-next v3 04/14] sfc: evaluate vdpa support based on FW capability CLIENT_CMD_VF_PROXY
config: openrisc-randconfig-r025-20230403 (https://download.01.org/0day-ci/archive/20230406/202304062157.jUftzJPl-lkp@intel.com/config)
compiler: or1k-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/1648cc5a817ed0b133554de429e9516dfdc18ddf
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Gautam-Dawar/sfc-add-function-personality-support-for-EF100-devices/20230406-151436
        git checkout 1648cc5a817ed0b133554de429e9516dfdc18ddf
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=openrisc olddefconfig
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=openrisc SHELL=/bin/bash drivers/net/ethernet/sfc/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Link: https://lore.kernel.org/oe-kbuild-all/202304062157.jUftzJPl-lkp@intel.com/

All errors (new ones prefixed by >>):

   drivers/net/ethernet/sfc/ef100_nic.c: In function 'efx_ef100_init_datapath_caps':
>> drivers/net/ethernet/sfc/ef100_nic.c:211:25: error: 'struct ef100_nic_data' has no member named 'vdpa_supported'
     211 |                 nic_data->vdpa_supported = efx->type->is_vf &&
         |                         ^~


vim +211 drivers/net/ethernet/sfc/ef100_nic.c

   164	
   165	static int efx_ef100_init_datapath_caps(struct efx_nic *efx)
   166	{
   167		MCDI_DECLARE_BUF(outbuf, MC_CMD_GET_CAPABILITIES_V7_OUT_LEN);
   168		struct ef100_nic_data *nic_data = efx->nic_data;
   169		u8 vi_window_mode;
   170		size_t outlen;
   171		int rc;
   172	
   173		BUILD_BUG_ON(MC_CMD_GET_CAPABILITIES_IN_LEN != 0);
   174	
   175		rc = efx_mcdi_rpc(efx, MC_CMD_GET_CAPABILITIES, NULL, 0,
   176				  outbuf, sizeof(outbuf), &outlen);
   177		if (rc)
   178			return rc;
   179		if (outlen < MC_CMD_GET_CAPABILITIES_V4_OUT_LEN) {
   180			netif_err(efx, drv, efx->net_dev,
   181				  "unable to read datapath firmware capabilities\n");
   182			return -EIO;
   183		}
   184	
   185		nic_data->datapath_caps = MCDI_DWORD(outbuf,
   186						     GET_CAPABILITIES_OUT_FLAGS1);
   187		nic_data->datapath_caps2 = MCDI_DWORD(outbuf,
   188						      GET_CAPABILITIES_V2_OUT_FLAGS2);
   189		if (outlen < MC_CMD_GET_CAPABILITIES_V7_OUT_LEN)
   190			nic_data->datapath_caps3 = 0;
   191		else
   192			nic_data->datapath_caps3 = MCDI_DWORD(outbuf,
   193							      GET_CAPABILITIES_V7_OUT_FLAGS3);
   194	
   195		vi_window_mode = MCDI_BYTE(outbuf,
   196					   GET_CAPABILITIES_V3_OUT_VI_WINDOW_MODE);
   197		rc = efx_mcdi_window_mode_to_stride(efx, vi_window_mode);
   198		if (rc)
   199			return rc;
   200	
   201		efx->num_mac_stats = MCDI_WORD(outbuf,
   202					       GET_CAPABILITIES_V4_OUT_MAC_STATS_NUM_STATS);
   203		netif_dbg(efx, probe, efx->net_dev,
   204			  "firmware reports num_mac_stats = %u\n",
   205			  efx->num_mac_stats);
   206	
   207		/* Current EF100 hardware supports vDPA on VFs only, requires MCDI v2
   208		 * and Firmware's capability to proxy MCDI commands from PF to VF
   209		 */
   210		if (IS_ENABLED(CONFIG_SFC_VDPA)) {
 > 211			nic_data->vdpa_supported = efx->type->is_vf &&
   212						   (efx->type->mcdi_max_ver > 1) &&
   213					efx_ef100_has_cap(nic_data->datapath_caps3,
   214							  CLIENT_CMD_VF_PROXY);
   215		}
   216	
   217		return 0;
   218	}
   219
diff mbox series

Patch

diff --git a/drivers/net/ethernet/sfc/ef100_netdev.c b/drivers/net/ethernet/sfc/ef100_netdev.c
index d916877b5a9a..5d93e870d9b7 100644
--- a/drivers/net/ethernet/sfc/ef100_netdev.c
+++ b/drivers/net/ethernet/sfc/ef100_netdev.c
@@ -355,6 +355,28 @@  void ef100_remove_netdev(struct efx_probe_data *probe_data)
 	efx->state = STATE_PROBED;
 }
 
+static void efx_ef100_update_tso_features(struct efx_nic *efx)
+{
+	struct ef100_nic_data *nic_data = efx->nic_data;
+	struct net_device *net_dev = efx->net_dev;
+	netdev_features_t tso;
+
+	if (!efx_ef100_has_cap(nic_data->datapath_caps2, TX_TSO_V3))
+		return;
+
+	tso = NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_GSO_PARTIAL |
+	      NETIF_F_GSO_UDP_TUNNEL | NETIF_F_GSO_UDP_TUNNEL_CSUM |
+	      NETIF_F_GSO_GRE | NETIF_F_GSO_GRE_CSUM;
+
+	net_dev->features |= tso;
+	net_dev->hw_features |= tso;
+	net_dev->hw_enc_features |= tso;
+	/* EF100 HW can only offload outer checksums if they are UDP,
+	 * so for GRE_CSUM we have to use GSO_PARTIAL.
+	 */
+	net_dev->gso_partial_features |= NETIF_F_GSO_GRE_CSUM;
+}
+
 int ef100_probe_netdev(struct efx_probe_data *probe_data)
 {
 	struct efx_nic *efx = &probe_data->efx;
@@ -387,9 +409,7 @@  int ef100_probe_netdev(struct efx_probe_data *probe_data)
 			       ESE_EF100_DP_GZ_TSO_MAX_HDR_NUM_SEGS_DEFAULT);
 	efx->mdio.dev = net_dev;
 
-	rc = efx_ef100_init_datapath_caps(efx);
-	if (rc < 0)
-		goto fail;
+	efx_ef100_update_tso_features(efx);
 
 	rc = ef100_phy_probe(efx);
 	if (rc)
diff --git a/drivers/net/ethernet/sfc/ef100_nic.c b/drivers/net/ethernet/sfc/ef100_nic.c
index 54b2ee7a5be6..498b398175d7 100644
--- a/drivers/net/ethernet/sfc/ef100_nic.c
+++ b/drivers/net/ethernet/sfc/ef100_nic.c
@@ -162,7 +162,7 @@  int ef100_get_mac_address(struct efx_nic *efx, u8 *mac_address,
 	return 0;
 }
 
-int efx_ef100_init_datapath_caps(struct efx_nic *efx)
+static int efx_ef100_init_datapath_caps(struct efx_nic *efx)
 {
 	MCDI_DECLARE_BUF(outbuf, MC_CMD_GET_CAPABILITIES_V7_OUT_LEN);
 	struct ef100_nic_data *nic_data = efx->nic_data;
@@ -198,25 +198,22 @@  int efx_ef100_init_datapath_caps(struct efx_nic *efx)
 	if (rc)
 		return rc;
 
-	if (efx_ef100_has_cap(nic_data->datapath_caps2, TX_TSO_V3)) {
-		struct net_device *net_dev = efx->net_dev;
-		netdev_features_t tso = NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_GSO_PARTIAL |
-					NETIF_F_GSO_UDP_TUNNEL | NETIF_F_GSO_UDP_TUNNEL_CSUM |
-					NETIF_F_GSO_GRE | NETIF_F_GSO_GRE_CSUM;
-
-		net_dev->features |= tso;
-		net_dev->hw_features |= tso;
-		net_dev->hw_enc_features |= tso;
-		/* EF100 HW can only offload outer checksums if they are UDP,
-		 * so for GRE_CSUM we have to use GSO_PARTIAL.
-		 */
-		net_dev->gso_partial_features |= NETIF_F_GSO_GRE_CSUM;
-	}
 	efx->num_mac_stats = MCDI_WORD(outbuf,
 				       GET_CAPABILITIES_V4_OUT_MAC_STATS_NUM_STATS);
 	netif_dbg(efx, probe, efx->net_dev,
 		  "firmware reports num_mac_stats = %u\n",
 		  efx->num_mac_stats);
+
+	/* Current EF100 hardware supports vDPA on VFs only, requires MCDI v2
+	 * and Firmware's capability to proxy MCDI commands from PF to VF
+	 */
+	if (IS_ENABLED(CONFIG_SFC_VDPA)) {
+		nic_data->vdpa_supported = efx->type->is_vf &&
+					   (efx->type->mcdi_max_ver > 1) &&
+				efx_ef100_has_cap(nic_data->datapath_caps3,
+						  CLIENT_CMD_VF_PROXY);
+	}
+
 	return 0;
 }
 
@@ -820,14 +817,12 @@  int efx_ef100_set_bar_config(struct efx_nic *efx,
 	if (WARN_ON_ONCE(nic_data->bar_config > EF100_BAR_CONFIG_VDPA))
 		return -EINVAL;
 
-	/* Current EF100 hardware supports vDPA on VFs only */
-	if (IS_ENABLED(CONFIG_SFC_VDPA) &&
-	    new_config == EF100_BAR_CONFIG_VDPA &&
-	    !efx->type->is_vf) {
-		pci_err(efx->pci_dev, "vdpa over PF not supported : %s",
-			efx->name);
+#ifdef CONFIG_SFC_VDPA
+	if (new_config == EF100_BAR_CONFIG_VDPA && !nic_data->vdpa_supported) {
+		pci_err(efx->pci_dev, "vdpa not supported on %s", efx->name);
 		return -EOPNOTSUPP;
 	}
+#endif
 
 	mutex_lock(&nic_data->bar_config_lock);
 	old_config = nic_data->bar_config;
@@ -1203,6 +1198,12 @@  static int ef100_probe_main(struct efx_nic *efx)
 		goto fail;
 	}
 
+	rc = efx_ef100_init_datapath_caps(efx);
+	if (rc) {
+		pci_info(efx->pci_dev, "Unable to initialize datapath caps\n");
+		goto fail;
+	}
+
 	return 0;
 fail:
 	return rc;
diff --git a/drivers/net/ethernet/sfc/ef100_nic.h b/drivers/net/ethernet/sfc/ef100_nic.h
index 02e5ab4e9f1f..a01e9d643ccd 100644
--- a/drivers/net/ethernet/sfc/ef100_nic.h
+++ b/drivers/net/ethernet/sfc/ef100_nic.h
@@ -77,6 +77,9 @@  struct ef100_nic_data {
 	u32 datapath_caps3;
 	unsigned int pf_index;
 	u16 warm_boot_count;
+#ifdef CONFIG_SFC_VDPA
+	bool vdpa_supported; /* true if vdpa is supported on this PCIe FN */
+#endif
 	u8 port_id[ETH_ALEN];
 	DECLARE_BITMAP(evq_phases, EFX_MAX_CHANNELS);
 	enum ef100_bar_config bar_config;
@@ -96,9 +99,8 @@  struct ef100_nic_data {
 };
 
 #define efx_ef100_has_cap(caps, flag) \
-	(!!((caps) & BIT_ULL(MC_CMD_GET_CAPABILITIES_V4_OUT_ ## flag ## _LBN)))
+	(!!((caps) & BIT_ULL(MC_CMD_GET_CAPABILITIES_V7_OUT_ ## flag ## _LBN)))
 
-int efx_ef100_init_datapath_caps(struct efx_nic *efx);
 int ef100_phy_probe(struct efx_nic *efx);
 int ef100_filter_table_probe(struct efx_nic *efx);