diff mbox series

[net-next,11/13] ice: introduce eswitch capable flag

Message ID 20221114125755.13659-12-michal.swiatkowski@linux.intel.com
State Awaiting Upstream
Headers show
Series resource management using devlink reload | expand

Commit Message

Michal Swiatkowski Nov. 14, 2022, 12:57 p.m. UTC
The flag is used to check if hardware support eswitch mode. Block going
to switchdev if the flag is unset.

It can be also use to turn the eswitch feature off to save MSI-X
interrupt.

Signed-off-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
---
 drivers/net/ethernet/intel/ice/ice.h         | 1 +
 drivers/net/ethernet/intel/ice/ice_eswitch.c | 6 ++++++
 drivers/net/ethernet/intel/ice/ice_main.c    | 5 ++++-
 3 files changed, 11 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/net/ethernet/intel/ice/ice.h b/drivers/net/ethernet/intel/ice/ice.h
index 62219f995cf2..df1f6d85cd43 100644
--- a/drivers/net/ethernet/intel/ice/ice.h
+++ b/drivers/net/ethernet/intel/ice/ice.h
@@ -501,6 +501,7 @@  enum ice_pf_flags {
 	ICE_FLAG_PLUG_AUX_DEV,
 	ICE_FLAG_MTU_CHANGED,
 	ICE_FLAG_GNSS,			/* GNSS successfully initialized */
+	ICE_FLAG_ESWITCH_CAPABLE,	/* switchdev mode can be supported */
 	ICE_PF_FLAGS_NBITS		/* must be last */
 };
 
diff --git a/drivers/net/ethernet/intel/ice/ice_eswitch.c b/drivers/net/ethernet/intel/ice/ice_eswitch.c
index f9f15acae90a..8532d5c47bad 100644
--- a/drivers/net/ethernet/intel/ice/ice_eswitch.c
+++ b/drivers/net/ethernet/intel/ice/ice_eswitch.c
@@ -554,6 +554,12 @@  ice_eswitch_mode_set(struct devlink *devlink, u16 mode,
 		return -EOPNOTSUPP;
 	}
 
+	if (!test_bit(ICE_FLAG_ESWITCH_CAPABLE, pf->flags)) {
+		dev_info(ice_pf_to_dev(pf), "There is no support for switchdev in hardware");
+		NL_SET_ERR_MSG_MOD(extack, "There is no support for switchdev in hardware");
+		return -EOPNOTSUPP;
+	}
+
 	switch (mode) {
 	case DEVLINK_ESWITCH_MODE_LEGACY:
 		dev_info(ice_pf_to_dev(pf), "PF %d changed eswitch mode to legacy",
diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c
index 9766032e95ec..0dfc427e623a 100644
--- a/drivers/net/ethernet/intel/ice/ice_main.c
+++ b/drivers/net/ethernet/intel/ice/ice_main.c
@@ -3739,8 +3739,10 @@  static void ice_set_pf_caps(struct ice_pf *pf)
 	if (func_caps->common_cap.dcb)
 		set_bit(ICE_FLAG_DCB_CAPABLE, pf->flags);
 	clear_bit(ICE_FLAG_SRIOV_CAPABLE, pf->flags);
+	clear_bit(ICE_FLAG_ESWITCH_CAPABLE, pf->flags);
 	if (func_caps->common_cap.sr_iov_1_1) {
 		set_bit(ICE_FLAG_SRIOV_CAPABLE, pf->flags);
+		set_bit(ICE_FLAG_ESWITCH_CAPABLE, pf->flags);
 		pf->vfs.num_supported = min_t(int, func_caps->num_allocd_vfs,
 					      ICE_MAX_SRIOV_VFS);
 	}
@@ -3881,7 +3883,8 @@  static int ice_ena_msix_range(struct ice_pf *pf)
 		v_other += ICE_FDIR_MSIX;
 
 	/* switchdev */
-	v_other += ICE_ESWITCH_MSIX;
+	if (test_bit(ICE_FLAG_ESWITCH_CAPABLE, pf->flags))
+		v_other += ICE_ESWITCH_MSIX;
 
 	v_wanted = v_other;