Skip to content

Commit 4bd5e02

Browse files
Kaaameanguy11
authored andcommitted
i40e: Set RX_ONLY mode for unicast promiscuous on VLAN
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 <[email protected]> Signed-off-by: Aleksandr Loktionov <[email protected]> Signed-off-by: Arkadiusz Kubalewski <[email protected]> Tested-by: Andrew Bowers <[email protected]> Signed-off-by: Tony Nguyen <[email protected]>
1 parent 3cda505 commit 4bd5e02

File tree

2 files changed

+28
-9
lines changed

2 files changed

+28
-9
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -981,7 +981,7 @@ struct i40e_aqc_set_vsi_promiscuous_modes {
981981
#define I40E_AQC_SET_VSI_PROMISC_BROADCAST 0x04
982982
#define I40E_AQC_SET_VSI_DEFAULT 0x08
983983
#define I40E_AQC_SET_VSI_PROMISC_VLAN 0x10
984-
#define I40E_AQC_SET_VSI_PROMISC_TX 0x8000
984+
#define I40E_AQC_SET_VSI_PROMISC_RX_ONLY 0x8000
985985
__le16 seid;
986986
__le16 vlan_tag;
987987
#define I40E_AQC_SET_VSI_VLAN_VALID 0x8000

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

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

1969+
/**
1970+
* i40e_is_aq_api_ver_ge
1971+
* @aq: pointer to AdminQ info containing HW API version to compare
1972+
* @maj: API major value
1973+
* @min: API minor value
1974+
*
1975+
* Assert whether current HW API version is greater/equal than provided.
1976+
**/
1977+
static bool i40e_is_aq_api_ver_ge(struct i40e_adminq_info *aq, u16 maj,
1978+
u16 min)
1979+
{
1980+
return (aq->api_maj_ver > maj ||
1981+
(aq->api_maj_ver == maj && aq->api_min_ver >= min));
1982+
}
1983+
19691984
/**
19701985
* i40e_aq_add_vsi
19711986
* @hw: pointer to the hw struct
@@ -2091,18 +2106,16 @@ i40e_status i40e_aq_set_vsi_unicast_promiscuous(struct i40e_hw *hw,
20912106

20922107
if (set) {
20932108
flags |= I40E_AQC_SET_VSI_PROMISC_UNICAST;
2094-
if (rx_only_promisc &&
2095-
(((hw->aq.api_maj_ver == 1) && (hw->aq.api_min_ver >= 5)) ||
2096-
(hw->aq.api_maj_ver > 1)))
2097-
flags |= I40E_AQC_SET_VSI_PROMISC_TX;
2109+
if (rx_only_promisc && i40e_is_aq_api_ver_ge(&hw->aq, 1, 5))
2110+
flags |= I40E_AQC_SET_VSI_PROMISC_RX_ONLY;
20982111
}
20992112

21002113
cmd->promiscuous_flags = cpu_to_le16(flags);
21012114

21022115
cmd->valid_flags = cpu_to_le16(I40E_AQC_SET_VSI_PROMISC_UNICAST);
2103-
if (((hw->aq.api_maj_ver >= 1) && (hw->aq.api_min_ver >= 5)) ||
2104-
(hw->aq.api_maj_ver > 1))
2105-
cmd->valid_flags |= cpu_to_le16(I40E_AQC_SET_VSI_PROMISC_TX);
2116+
if (i40e_is_aq_api_ver_ge(&hw->aq, 1, 5))
2117+
cmd->valid_flags |=
2118+
cpu_to_le16(I40E_AQC_SET_VSI_PROMISC_RX_ONLY);
21062119

21072120
cmd->seid = cpu_to_le16(seid);
21082121
status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
@@ -2199,11 +2212,17 @@ enum i40e_status_code i40e_aq_set_vsi_uc_promisc_on_vlan(struct i40e_hw *hw,
21992212
i40e_fill_default_direct_cmd_desc(&desc,
22002213
i40e_aqc_opc_set_vsi_promiscuous_modes);
22012214

2202-
if (enable)
2215+
if (enable) {
22032216
flags |= I40E_AQC_SET_VSI_PROMISC_UNICAST;
2217+
if (i40e_is_aq_api_ver_ge(&hw->aq, 1, 5))
2218+
flags |= I40E_AQC_SET_VSI_PROMISC_RX_ONLY;
2219+
}
22042220

22052221
cmd->promiscuous_flags = cpu_to_le16(flags);
22062222
cmd->valid_flags = cpu_to_le16(I40E_AQC_SET_VSI_PROMISC_UNICAST);
2223+
if (i40e_is_aq_api_ver_ge(&hw->aq, 1, 5))
2224+
cmd->valid_flags |=
2225+
cpu_to_le16(I40E_AQC_SET_VSI_PROMISC_RX_ONLY);
22072226
cmd->seid = cpu_to_le16(seid);
22082227
cmd->vlan_tag = cpu_to_le16(vid | I40E_AQC_SET_VSI_VLAN_VALID);
22092228

0 commit comments

Comments
 (0)