Skip to content

Commit d739342

Browse files
mwilczyanguy11
authored andcommitted
ice: Introduce enabling promiscuous mode on multiple VF's
In current implementation default VSI switch filter is only able to forward traffic to a single VSI. This limits promiscuous mode with private flag 'vf-true-promisc-support' to a single VF. Enabling it on the second VF won't work. Also allmulticast support doesn't seem to be properly implemented when vf-true-promisc-support is true. Use standard ice_add_rule_internal() function that already implements forwarding to multiple VSI's instead of constructing AQ call manually. Add switch filter for allmulticast mode when vf-true-promisc-support is enabled. The same filter is added regardless of the flag - it doesn't matter for this case. Remove unnecessary fields in switch structure. From now on book keeping will be done by ice_add_rule_internal(). Refactor unnecessarily passed function arguments. To test: 1) Create 2 VM's, and two VF's. Attach VF's to VM's. 2) Enable promiscuous mode on both of them and check if traffic is seen on both of them. Signed-off-by: Michal Wilczynski <[email protected]> Tested-by: Marek Szlosek <[email protected]> Signed-off-by: Tony Nguyen <[email protected]>
1 parent 623cd87 commit d739342

File tree

12 files changed

+155
-169
lines changed

12 files changed

+155
-169
lines changed

drivers/net/ethernet/intel/ice/ice.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,6 @@ struct ice_sw {
248248
struct ice_pf *pf;
249249
u16 sw_id; /* switch ID for this switch */
250250
u16 bridge_mode; /* VEB/VEPA/Port Virtualizer */
251-
struct ice_vsi *dflt_vsi; /* default VSI for this switch */
252-
u8 dflt_vsi_ena:1; /* true if above dflt_vsi is enabled */
253251
};
254252

255253
enum ice_pf_state {

drivers/net/ethernet/intel/ice/ice_eswitch.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ static int ice_eswitch_setup_env(struct ice_pf *pf)
133133
if (ice_vsi_add_vlan_zero(uplink_vsi))
134134
goto err_def_rx;
135135

136-
if (!ice_is_dflt_vsi_in_use(uplink_vsi->vsw)) {
137-
if (ice_set_dflt_vsi(uplink_vsi->vsw, uplink_vsi))
136+
if (!ice_is_dflt_vsi_in_use(uplink_vsi->port_info)) {
137+
if (ice_set_dflt_vsi(uplink_vsi))
138138
goto err_def_rx;
139139
rule_added = true;
140140
}
@@ -151,7 +151,7 @@ static int ice_eswitch_setup_env(struct ice_pf *pf)
151151
ice_vsi_update_security(uplink_vsi, ice_vsi_ctx_clear_allow_override);
152152
err_override_uplink:
153153
if (rule_added)
154-
ice_clear_dflt_vsi(uplink_vsi->vsw);
154+
ice_clear_dflt_vsi(uplink_vsi);
155155
err_def_rx:
156156
ice_fltr_add_mac_and_broadcast(uplink_vsi,
157157
uplink_vsi->port_info->mac.perm_addr,
@@ -411,7 +411,7 @@ static void ice_eswitch_release_env(struct ice_pf *pf)
411411

412412
ice_vsi_update_security(ctrl_vsi, ice_vsi_ctx_clear_allow_override);
413413
ice_vsi_update_security(uplink_vsi, ice_vsi_ctx_clear_allow_override);
414-
ice_clear_dflt_vsi(uplink_vsi->vsw);
414+
ice_clear_dflt_vsi(uplink_vsi);
415415
ice_fltr_add_mac_and_broadcast(uplink_vsi,
416416
uplink_vsi->port_info->mac.perm_addr,
417417
ICE_FWD_TO_VSI);

drivers/net/ethernet/intel/ice/ice_ethtool.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1292,7 +1292,7 @@ static int ice_set_priv_flags(struct net_device *netdev, u32 flags)
12921292
* promiscuous mode because it's not supported
12931293
*/
12941294
if (test_bit(ICE_FLAG_VF_TRUE_PROMISC_ENA, change_flags) &&
1295-
ice_is_any_vf_in_promisc(pf)) {
1295+
ice_is_any_vf_in_unicast_promisc(pf)) {
12961296
dev_err(dev, "Changing vf-true-promisc-support flag while VF(s) are in promiscuous mode not supported\n");
12971297
/* toggle bit back to previous state */
12981298
change_bit(ICE_FLAG_VF_TRUE_PROMISC_ENA, pf->flags);

drivers/net/ethernet/intel/ice/ice_lib.c

Lines changed: 24 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -3006,8 +3006,8 @@ int ice_vsi_release(struct ice_vsi *vsi)
30063006
}
30073007
}
30083008

3009-
if (ice_is_vsi_dflt_vsi(pf->first_sw, vsi))
3010-
ice_clear_dflt_vsi(pf->first_sw);
3009+
if (ice_is_vsi_dflt_vsi(vsi))
3010+
ice_clear_dflt_vsi(vsi);
30113011
ice_fltr_remove_all(vsi);
30123012
ice_rm_vsi_lan_cfg(vsi->port_info, vsi->idx);
30133013
err = ice_rm_vsi_rdma_cfg(vsi->port_info, vsi->idx);
@@ -3690,116 +3690,97 @@ void ice_update_rx_ring_stats(struct ice_rx_ring *rx_ring, u64 pkts, u64 bytes)
36903690

36913691
/**
36923692
* ice_is_dflt_vsi_in_use - check if the default forwarding VSI is being used
3693-
* @sw: switch to check if its default forwarding VSI is free
3693+
* @pi: port info of the switch with default VSI
36943694
*
3695-
* Return true if the default forwarding VSI is already being used, else returns
3696-
* false signalling that it's available to use.
3695+
* Return true if the there is a single VSI in default forwarding VSI list
36973696
*/
3698-
bool ice_is_dflt_vsi_in_use(struct ice_sw *sw)
3697+
bool ice_is_dflt_vsi_in_use(struct ice_port_info *pi)
36993698
{
3700-
return (sw->dflt_vsi && sw->dflt_vsi_ena);
3699+
bool exists = false;
3700+
3701+
ice_check_if_dflt_vsi(pi, 0, &exists);
3702+
return exists;
37013703
}
37023704

37033705
/**
37043706
* ice_is_vsi_dflt_vsi - check if the VSI passed in is the default VSI
3705-
* @sw: switch for the default forwarding VSI to compare against
37063707
* @vsi: VSI to compare against default forwarding VSI
37073708
*
37083709
* If this VSI passed in is the default forwarding VSI then return true, else
37093710
* return false
37103711
*/
3711-
bool ice_is_vsi_dflt_vsi(struct ice_sw *sw, struct ice_vsi *vsi)
3712+
bool ice_is_vsi_dflt_vsi(struct ice_vsi *vsi)
37123713
{
3713-
return (sw->dflt_vsi == vsi && sw->dflt_vsi_ena);
3714+
return ice_check_if_dflt_vsi(vsi->port_info, vsi->idx, NULL);
37143715
}
37153716

37163717
/**
37173718
* ice_set_dflt_vsi - set the default forwarding VSI
3718-
* @sw: switch used to assign the default forwarding VSI
37193719
* @vsi: VSI getting set as the default forwarding VSI on the switch
37203720
*
37213721
* If the VSI passed in is already the default VSI and it's enabled just return
37223722
* success.
37233723
*
3724-
* If there is already a default VSI on the switch and it's enabled then return
3725-
* -EEXIST since there can only be one default VSI per switch.
3726-
*
3727-
* Otherwise try to set the VSI passed in as the switch's default VSI and
3728-
* return the result.
3724+
* Otherwise try to set the VSI passed in as the switch's default VSI and
3725+
* return the result.
37293726
*/
3730-
int ice_set_dflt_vsi(struct ice_sw *sw, struct ice_vsi *vsi)
3727+
int ice_set_dflt_vsi(struct ice_vsi *vsi)
37313728
{
37323729
struct device *dev;
37333730
int status;
37343731

3735-
if (!sw || !vsi)
3732+
if (!vsi)
37363733
return -EINVAL;
37373734

37383735
dev = ice_pf_to_dev(vsi->back);
37393736

37403737
/* the VSI passed in is already the default VSI */
3741-
if (ice_is_vsi_dflt_vsi(sw, vsi)) {
3738+
if (ice_is_vsi_dflt_vsi(vsi)) {
37423739
dev_dbg(dev, "VSI %d passed in is already the default forwarding VSI, nothing to do\n",
37433740
vsi->vsi_num);
37443741
return 0;
37453742
}
37463743

3747-
/* another VSI is already the default VSI for this switch */
3748-
if (ice_is_dflt_vsi_in_use(sw)) {
3749-
dev_err(dev, "Default forwarding VSI %d already in use, disable it and try again\n",
3750-
sw->dflt_vsi->vsi_num);
3751-
return -EEXIST;
3752-
}
3753-
3754-
status = ice_cfg_dflt_vsi(&vsi->back->hw, vsi->idx, true, ICE_FLTR_RX);
3744+
status = ice_cfg_dflt_vsi(vsi->port_info, vsi->idx, true, ICE_FLTR_RX);
37553745
if (status) {
37563746
dev_err(dev, "Failed to set VSI %d as the default forwarding VSI, error %d\n",
37573747
vsi->vsi_num, status);
37583748
return status;
37593749
}
37603750

3761-
sw->dflt_vsi = vsi;
3762-
sw->dflt_vsi_ena = true;
3763-
37643751
return 0;
37653752
}
37663753

37673754
/**
37683755
* ice_clear_dflt_vsi - clear the default forwarding VSI
3769-
* @sw: switch used to clear the default VSI
3756+
* @vsi: VSI to remove from filter list
37703757
*
37713758
* If the switch has no default VSI or it's not enabled then return error.
37723759
*
37733760
* Otherwise try to clear the default VSI and return the result.
37743761
*/
3775-
int ice_clear_dflt_vsi(struct ice_sw *sw)
3762+
int ice_clear_dflt_vsi(struct ice_vsi *vsi)
37763763
{
3777-
struct ice_vsi *dflt_vsi;
37783764
struct device *dev;
37793765
int status;
37803766

3781-
if (!sw)
3767+
if (!vsi)
37823768
return -EINVAL;
37833769

3784-
dev = ice_pf_to_dev(sw->pf);
3785-
3786-
dflt_vsi = sw->dflt_vsi;
3770+
dev = ice_pf_to_dev(vsi->back);
37873771

37883772
/* there is no default VSI configured */
3789-
if (!ice_is_dflt_vsi_in_use(sw))
3773+
if (!ice_is_dflt_vsi_in_use(vsi->port_info))
37903774
return -ENODEV;
37913775

3792-
status = ice_cfg_dflt_vsi(&dflt_vsi->back->hw, dflt_vsi->idx, false,
3776+
status = ice_cfg_dflt_vsi(vsi->port_info, vsi->idx, false,
37933777
ICE_FLTR_RX);
37943778
if (status) {
37953779
dev_err(dev, "Failed to clear the default forwarding VSI %d, error %d\n",
3796-
dflt_vsi->vsi_num, status);
3780+
vsi->vsi_num, status);
37973781
return -EIO;
37983782
}
37993783

3800-
sw->dflt_vsi = NULL;
3801-
sw->dflt_vsi_ena = false;
3802-
38033784
return 0;
38043785
}
38053786

drivers/net/ethernet/intel/ice/ice_lib.h

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,10 @@ int ice_vsi_cfg_mac_fltr(struct ice_vsi *vsi, const u8 *macaddr, bool set);
102102

103103
bool ice_is_safe_mode(struct ice_pf *pf);
104104
bool ice_is_rdma_ena(struct ice_pf *pf);
105-
bool ice_is_dflt_vsi_in_use(struct ice_sw *sw);
106-
107-
bool ice_is_vsi_dflt_vsi(struct ice_sw *sw, struct ice_vsi *vsi);
108-
109-
int ice_set_dflt_vsi(struct ice_sw *sw, struct ice_vsi *vsi);
110-
111-
int ice_clear_dflt_vsi(struct ice_sw *sw);
105+
bool ice_is_dflt_vsi_in_use(struct ice_port_info *pi);
106+
bool ice_is_vsi_dflt_vsi(struct ice_vsi *vsi);
107+
int ice_set_dflt_vsi(struct ice_vsi *vsi);
108+
int ice_clear_dflt_vsi(struct ice_vsi *vsi);
112109
int ice_set_min_bw_limit(struct ice_vsi *vsi, u64 min_tx_rate);
113110
int ice_set_max_bw_limit(struct ice_vsi *vsi, u64 max_tx_rate);
114111
int ice_get_link_speed_kbps(struct ice_vsi *vsi);

drivers/net/ethernet/intel/ice/ice_main.c

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -410,8 +410,8 @@ static int ice_vsi_sync_fltr(struct ice_vsi *vsi)
410410
clear_bit(ICE_VSI_PROMISC_CHANGED, vsi->state);
411411
if (vsi->current_netdev_flags & IFF_PROMISC) {
412412
/* Apply Rx filter rule to get traffic from wire */
413-
if (!ice_is_dflt_vsi_in_use(pf->first_sw)) {
414-
err = ice_set_dflt_vsi(pf->first_sw, vsi);
413+
if (!ice_is_dflt_vsi_in_use(vsi->port_info)) {
414+
err = ice_set_dflt_vsi(vsi);
415415
if (err && err != -EEXIST) {
416416
netdev_err(netdev, "Error %d setting default VSI %i Rx rule\n",
417417
err, vsi->vsi_num);
@@ -424,8 +424,8 @@ static int ice_vsi_sync_fltr(struct ice_vsi *vsi)
424424
}
425425
} else {
426426
/* Clear Rx filter to remove traffic from wire */
427-
if (ice_is_vsi_dflt_vsi(pf->first_sw, vsi)) {
428-
err = ice_clear_dflt_vsi(pf->first_sw);
427+
if (ice_is_vsi_dflt_vsi(vsi)) {
428+
err = ice_clear_dflt_vsi(vsi);
429429
if (err) {
430430
netdev_err(netdev, "Error %d clearing default VSI %i Rx rule\n",
431431
err, vsi->vsi_num);
@@ -6990,12 +6990,6 @@ static void ice_rebuild(struct ice_pf *pf, enum ice_reset_req reset_type)
69906990
goto err_init_ctrlq;
69916991
}
69926992

6993-
if (pf->first_sw->dflt_vsi_ena)
6994-
dev_info(dev, "Clearing default VSI, re-enable after reset completes\n");
6995-
/* clear the default VSI configuration if it exists */
6996-
pf->first_sw->dflt_vsi = NULL;
6997-
pf->first_sw->dflt_vsi_ena = false;
6998-
69996993
ice_clear_pxe_mode(hw);
70006994

70016995
err = ice_init_nvm(hw);

0 commit comments

Comments
 (0)