@@ -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 */
};
@@ -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",
@@ -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;
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(-)