Skip to content

Commit 04efb36

Browse files
Kaaamegregkh
authored andcommitted
i40e: Set RX_ONLY mode for unicast promiscuous on VLAN
[ Upstream commit 4bd5e02 ] Trusted VF with unicast promiscuous mode set, could listen to TX traffic of other VFs. Set unicast promiscuous mode to RX traffic, if VSI has port VLAN configured. Rename misleading I40E_AQC_SET_VSI_PROMISC_TX bit to I40E_AQC_SET_VSI_PROMISC_RX_ONLY. Aligned unicast promiscuous with VLAN to the one without VLAN. Fixes: 6c41a76 ("i40e: Add promiscuous on VLAN support") Fixes: 3b12008 ("i40e: When in promisc mode apply promisc mode to Tx Traffic as well") Signed-off-by: Przemyslaw Patynowski <przemyslawx.patynowski@intel.com> Signed-off-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com> Signed-off-by: Arkadiusz Kubalewski <arkadiusz.kubalewski@intel.com> Tested-by: Andrew Bowers <andrewx.bowers@intel.com> Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent b9d4cab commit 04efb36

2 files changed

Lines changed: 28 additions & 9 deletions

File tree

drivers/net/ethernet/intel/i40e/i40e_adminq_cmd.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1206,7 +1206,7 @@ struct i40e_aqc_set_vsi_promiscuous_modes {
12061206
#define I40E_AQC_SET_VSI_PROMISC_BROADCAST 0x04
12071207
#define I40E_AQC_SET_VSI_DEFAULT 0x08
12081208
#define I40E_AQC_SET_VSI_PROMISC_VLAN 0x10
1209-
#define I40E_AQC_SET_VSI_PROMISC_TX 0x8000
1209+
#define I40E_AQC_SET_VSI_PROMISC_RX_ONLY 0x8000
12101210
__le16 seid;
12111211
#define I40E_AQC_VSI_PROM_CMD_SEID_MASK 0x3FF
12121212
__le16 vlan_tag;

drivers/net/ethernet/intel/i40e/i40e_common.c

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1970,6 +1970,21 @@ i40e_status i40e_aq_set_phy_debug(struct i40e_hw *hw, u8 cmd_flags,
19701970
return status;
19711971
}
19721972

1973+
/**
1974+
* i40e_is_aq_api_ver_ge
1975+
* @aq: pointer to AdminQ info containing HW API version to compare
1976+
* @maj: API major value
1977+
* @min: API minor value
1978+
*
1979+
* Assert whether current HW API version is greater/equal than provided.
1980+
**/
1981+
static bool i40e_is_aq_api_ver_ge(struct i40e_adminq_info *aq, u16 maj,
1982+
u16 min)
1983+
{
1984+
return (aq->api_maj_ver > maj ||
1985+
(aq->api_maj_ver == maj && aq->api_min_ver >= min));
1986+
}
1987+
19731988
/**
19741989
* i40e_aq_add_vsi
19751990
* @hw: pointer to the hw struct
@@ -2095,18 +2110,16 @@ i40e_status i40e_aq_set_vsi_unicast_promiscuous(struct i40e_hw *hw,
20952110

20962111
if (set) {
20972112
flags |= I40E_AQC_SET_VSI_PROMISC_UNICAST;
2098-
if (rx_only_promisc &&
2099-
(((hw->aq.api_maj_ver == 1) && (hw->aq.api_min_ver >= 5)) ||
2100-
(hw->aq.api_maj_ver > 1)))
2101-
flags |= I40E_AQC_SET_VSI_PROMISC_TX;
2113+
if (rx_only_promisc && i40e_is_aq_api_ver_ge(&hw->aq, 1, 5))
2114+
flags |= I40E_AQC_SET_VSI_PROMISC_RX_ONLY;
21022115
}
21032116

21042117
cmd->promiscuous_flags = cpu_to_le16(flags);
21052118

21062119
cmd->valid_flags = cpu_to_le16(I40E_AQC_SET_VSI_PROMISC_UNICAST);
2107-
if (((hw->aq.api_maj_ver >= 1) && (hw->aq.api_min_ver >= 5)) ||
2108-
(hw->aq.api_maj_ver > 1))
2109-
cmd->valid_flags |= cpu_to_le16(I40E_AQC_SET_VSI_PROMISC_TX);
2120+
if (i40e_is_aq_api_ver_ge(&hw->aq, 1, 5))
2121+
cmd->valid_flags |=
2122+
cpu_to_le16(I40E_AQC_SET_VSI_PROMISC_RX_ONLY);
21102123

21112124
cmd->seid = cpu_to_le16(seid);
21122125
status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
@@ -2203,11 +2216,17 @@ enum i40e_status_code i40e_aq_set_vsi_uc_promisc_on_vlan(struct i40e_hw *hw,
22032216
i40e_fill_default_direct_cmd_desc(&desc,
22042217
i40e_aqc_opc_set_vsi_promiscuous_modes);
22052218

2206-
if (enable)
2219+
if (enable) {
22072220
flags |= I40E_AQC_SET_VSI_PROMISC_UNICAST;
2221+
if (i40e_is_aq_api_ver_ge(&hw->aq, 1, 5))
2222+
flags |= I40E_AQC_SET_VSI_PROMISC_RX_ONLY;
2223+
}
22082224

22092225
cmd->promiscuous_flags = cpu_to_le16(flags);
22102226
cmd->valid_flags = cpu_to_le16(I40E_AQC_SET_VSI_PROMISC_UNICAST);
2227+
if (i40e_is_aq_api_ver_ge(&hw->aq, 1, 5))
2228+
cmd->valid_flags |=
2229+
cpu_to_le16(I40E_AQC_SET_VSI_PROMISC_RX_ONLY);
22112230
cmd->seid = cpu_to_le16(seid);
22122231
cmd->vlan_tag = cpu_to_le16(vid | I40E_AQC_SET_VSI_VLAN_VALID);
22132232

0 commit comments

Comments
 (0)