From 2cf7a0faf483c0c29b409194919276d5eef53751 Mon Sep 17 00:00:00 2001 From: Shahed Shaikh Date: Sat, 8 Sep 2018 13:30:57 -0700 Subject: [PATCH] net/qede/base: use trust mode for forced MAC limitations MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit When trust mode is set to ON, VF can change it's MAC address inspite PF has set a forced MAC for that VF from HV. Earlier similar functionality is provided by module parameter "allow_vf_mac_change_mode" of qed. This change makes few changes in behavior of VF shadow config - - Let driver track the VF mac in shadow config as long as trust mode is OFF. - Once trust mode is ON, we should not care about MACs in shadow config (because we never intend to fall back because of lack of restore implementation). - Delete existing shadow MAC (this helps when trust mode is turned OFF, and VF tries to add new MAC – it won’t fail that time since we have a clean slate). - Skip addition and deletion of MACs in shadow configs. Signed-off-by: Shahed Shaikh --- drivers/net/qede/base/ecore_iov_api.h | 7 ++++++ drivers/net/qede/base/ecore_sriov.c | 36 ++++++++++++++++++++------- 2 files changed, 34 insertions(+), 9 deletions(-) diff --git a/drivers/net/qede/base/ecore_iov_api.h b/drivers/net/qede/base/ecore_iov_api.h index 29001d7118..d398478b5b 100644 --- a/drivers/net/qede/base/ecore_iov_api.h +++ b/drivers/net/qede/base/ecore_iov_api.h @@ -84,6 +84,13 @@ struct ecore_public_vf_info { */ u8 forced_mac[ETH_ALEN]; u16 forced_vlan; + + /* Trusted VFs can configure promiscuous mode and + * set MAC address inspite PF has set forced MAC. + * Also store shadow promisc configuration if needed. + */ + bool is_trusted_configured; + bool is_trusted_request; }; struct ecore_iov_vf_init_params { diff --git a/drivers/net/qede/base/ecore_sriov.c b/drivers/net/qede/base/ecore_sriov.c index f7ebf7adf1..9e4a57babb 100644 --- a/drivers/net/qede/base/ecore_sriov.c +++ b/drivers/net/qede/base/ecore_sriov.c @@ -1968,7 +1968,8 @@ ecore_iov_configure_vport_forced(struct ecore_hwfn *p_hwfn, return ECORE_INVAL; if ((events & (1 << MAC_ADDR_FORCED)) || - p_hwfn->pf_params.eth_pf_params.allow_vf_mac_change) { + p_hwfn->pf_params.eth_pf_params.allow_vf_mac_change || + p_vf->p_vf_info.is_trusted_configured) { /* Since there's no way [currently] of removing the MAC, * we can always assume this means we need to force it. */ @@ -1989,7 +1990,8 @@ ecore_iov_configure_vport_forced(struct ecore_hwfn *p_hwfn, return rc; } - if (p_hwfn->pf_params.eth_pf_params.allow_vf_mac_change) + if (p_hwfn->pf_params.eth_pf_params.allow_vf_mac_change || + p_vf->p_vf_info.is_trusted_configured) p_vf->configured_features |= 1 << VFPF_BULLETIN_MAC_ADDR; else @@ -3351,6 +3353,15 @@ ecore_iov_vf_update_mac_shadow(struct ecore_hwfn *p_hwfn, if (p_vf->bulletin.p_virt->valid_bitmap & (1 << MAC_ADDR_FORCED)) return ECORE_SUCCESS; + /* Since we don't have the implementation of the logic for removing + * a forced MAC and restoring shadow MAC, let's not worry about + * processing shadow copies of MAC as long as VF trust mode is ON, + * to keep things simple. + */ + if (p_hwfn->pf_params.eth_pf_params.allow_vf_mac_change || + p_vf->p_vf_info.is_trusted_configured) + return ECORE_SUCCESS; + /* First remove entries and then add new ones */ if (p_params->opcode == ECORE_FILTER_REMOVE) { for (i = 0; i < ECORE_ETH_VF_NUM_MAC_FILTERS; i++) { @@ -4415,17 +4426,23 @@ void ecore_iov_bulletin_set_forced_mac(struct ecore_hwfn *p_hwfn, return; } - if (p_hwfn->pf_params.eth_pf_params.allow_vf_mac_change) + if (p_hwfn->pf_params.eth_pf_params.allow_vf_mac_change || + vf_info->p_vf_info.is_trusted_configured) { feature = 1 << VFPF_BULLETIN_MAC_ADDR; - else + /* Trust mode will disable Forced MAC */ + vf_info->bulletin.p_virt->valid_bitmap &= + ~(1 << MAC_ADDR_FORCED); + } else { feature = 1 << MAC_ADDR_FORCED; + /* Forced MAC will disable MAC_ADDR */ + vf_info->bulletin.p_virt->valid_bitmap &= + ~(1 << VFPF_BULLETIN_MAC_ADDR); + } - OSAL_MEMCPY(vf_info->bulletin.p_virt->mac, mac, ETH_ALEN); + OSAL_MEMCPY(vf_info->bulletin.p_virt->mac, + mac, ETH_ALEN); vf_info->bulletin.p_virt->valid_bitmap |= feature; - /* Forced MAC will disable MAC_ADDR */ - vf_info->bulletin.p_virt->valid_bitmap &= - ~(1 << VFPF_BULLETIN_MAC_ADDR); ecore_iov_configure_vport_forced(p_hwfn, vf_info, feature); } @@ -4460,7 +4477,8 @@ enum _ecore_status_t ecore_iov_bulletin_set_mac(struct ecore_hwfn *p_hwfn, vf_info->bulletin.p_virt->valid_bitmap |= feature; - if (p_hwfn->pf_params.eth_pf_params.allow_vf_mac_change) + if (p_hwfn->pf_params.eth_pf_params.allow_vf_mac_change || + vf_info->p_vf_info.is_trusted_configured) ecore_iov_configure_vport_forced(p_hwfn, vf_info, feature); return ECORE_SUCCESS; -- 2.20.1