Skip to content

Commit 84a8d93

Browse files
committed
Merge branch '100GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/next-queue
Tony Nguyen says: ==================== 100GbE Intel Wired LAN Driver Updates 2022-07-28 This series contains updates to ice driver only. Michal allows for VF true promiscuous mode to be set for multiple VFs and adds clearing of promiscuous filters when VF trust is removed. Maciej refactors ice_set_features() to track/check changed features instead of constantly checking against netdev features and adds support for NETIF_F_LOOPBACK. * '100GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/next-queue: ice: allow toggling loopback mode via ndo_set_features callback ice: compress branches in ice_set_features() ice: Fix promiscuous mode not turning off ice: Introduce enabling promiscuous mode on multiple VF's ==================== Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents ed3849e + 44ece4e commit 84a8d93

12 files changed

+269
-202
lines changed

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

-2
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

+4-4
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

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

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

+24-43
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

+4-7
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

+54-32
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);
@@ -3358,6 +3358,7 @@ static void ice_set_netdev_features(struct net_device *netdev)
33583358
netdev->features |= netdev->hw_features;
33593359

33603360
netdev->hw_features |= NETIF_F_HW_TC;
3361+
netdev->hw_features |= NETIF_F_LOOPBACK;
33613362

33623363
/* encap and VLAN devices inherit default, csumo and tso features */
33633364
netdev->hw_enc_features |= dflt_features | csumo_features |
@@ -5912,6 +5913,32 @@ ice_set_vlan_features(struct net_device *netdev, netdev_features_t features)
59125913
return 0;
59135914
}
59145915

5916+
/**
5917+
* ice_set_loopback - turn on/off loopback mode on underlying PF
5918+
* @vsi: ptr to VSI
5919+
* @ena: flag to indicate the on/off setting
5920+
*/
5921+
static int ice_set_loopback(struct ice_vsi *vsi, bool ena)
5922+
{
5923+
bool if_running = netif_running(vsi->netdev);
5924+
int ret;
5925+
5926+
if (if_running && !test_and_set_bit(ICE_VSI_DOWN, vsi->state)) {
5927+
ret = ice_down(vsi);
5928+
if (ret) {
5929+
netdev_err(vsi->netdev, "Preparing device to toggle loopback failed\n");
5930+
return ret;
5931+
}
5932+
}
5933+
ret = ice_aq_set_mac_loopback(&vsi->back->hw, ena, NULL);
5934+
if (ret)
5935+
netdev_err(vsi->netdev, "Failed to toggle loopback state\n");
5936+
if (if_running)
5937+
ret = ice_up(vsi);
5938+
5939+
return ret;
5940+
}
5941+
59155942
/**
59165943
* ice_set_features - set the netdev feature flags
59175944
* @netdev: ptr to the netdev being adjusted
@@ -5920,44 +5947,41 @@ ice_set_vlan_features(struct net_device *netdev, netdev_features_t features)
59205947
static int
59215948
ice_set_features(struct net_device *netdev, netdev_features_t features)
59225949
{
5950+
netdev_features_t changed = netdev->features ^ features;
59235951
struct ice_netdev_priv *np = netdev_priv(netdev);
59245952
struct ice_vsi *vsi = np->vsi;
59255953
struct ice_pf *pf = vsi->back;
59265954
int ret = 0;
59275955

59285956
/* Don't set any netdev advanced features with device in Safe Mode */
5929-
if (ice_is_safe_mode(vsi->back)) {
5930-
dev_err(ice_pf_to_dev(vsi->back), "Device is in Safe Mode - not enabling advanced netdev features\n");
5957+
if (ice_is_safe_mode(pf)) {
5958+
dev_err(ice_pf_to_dev(pf),
5959+
"Device is in Safe Mode - not enabling advanced netdev features\n");
59315960
return ret;
59325961
}
59335962

59345963
/* Do not change setting during reset */
59355964
if (ice_is_reset_in_progress(pf->state)) {
5936-
dev_err(ice_pf_to_dev(vsi->back), "Device is resetting, changing advanced netdev features temporarily unavailable.\n");
5965+
dev_err(ice_pf_to_dev(pf),
5966+
"Device is resetting, changing advanced netdev features temporarily unavailable.\n");
59375967
return -EBUSY;
59385968
}
59395969

59405970
/* Multiple features can be changed in one call so keep features in
59415971
* separate if/else statements to guarantee each feature is checked
59425972
*/
5943-
if (features & NETIF_F_RXHASH && !(netdev->features & NETIF_F_RXHASH))
5944-
ice_vsi_manage_rss_lut(vsi, true);
5945-
else if (!(features & NETIF_F_RXHASH) &&
5946-
netdev->features & NETIF_F_RXHASH)
5947-
ice_vsi_manage_rss_lut(vsi, false);
5973+
if (changed & NETIF_F_RXHASH)
5974+
ice_vsi_manage_rss_lut(vsi, !!(features & NETIF_F_RXHASH));
59485975

59495976
ret = ice_set_vlan_features(netdev, features);
59505977
if (ret)
59515978
return ret;
59525979

5953-
if ((features & NETIF_F_NTUPLE) &&
5954-
!(netdev->features & NETIF_F_NTUPLE)) {
5955-
ice_vsi_manage_fdir(vsi, true);
5956-
ice_init_arfs(vsi);
5957-
} else if (!(features & NETIF_F_NTUPLE) &&
5958-
(netdev->features & NETIF_F_NTUPLE)) {
5959-
ice_vsi_manage_fdir(vsi, false);
5960-
ice_clear_arfs(vsi);
5980+
if (changed & NETIF_F_NTUPLE) {
5981+
bool ena = !!(features & NETIF_F_NTUPLE);
5982+
5983+
ice_vsi_manage_fdir(vsi, ena);
5984+
ena ? ice_init_arfs(vsi) : ice_clear_arfs(vsi);
59615985
}
59625986

59635987
/* don't turn off hw_tc_offload when ADQ is already enabled */
@@ -5966,13 +5990,17 @@ ice_set_features(struct net_device *netdev, netdev_features_t features)
59665990
return -EACCES;
59675991
}
59685992

5969-
if ((features & NETIF_F_HW_TC) &&
5970-
!(netdev->features & NETIF_F_HW_TC))
5971-
set_bit(ICE_FLAG_CLS_FLOWER, pf->flags);
5972-
else
5973-
clear_bit(ICE_FLAG_CLS_FLOWER, pf->flags);
5993+
if (changed & NETIF_F_HW_TC) {
5994+
bool ena = !!(features & NETIF_F_HW_TC);
59745995

5975-
return 0;
5996+
ena ? set_bit(ICE_FLAG_CLS_FLOWER, pf->flags) :
5997+
clear_bit(ICE_FLAG_CLS_FLOWER, pf->flags);
5998+
}
5999+
6000+
if (changed & NETIF_F_LOOPBACK)
6001+
ret = ice_set_loopback(vsi, !!(features & NETIF_F_LOOPBACK));
6002+
6003+
return ret;
59766004
}
59776005

59786006
/**
@@ -6994,12 +7022,6 @@ static void ice_rebuild(struct ice_pf *pf, enum ice_reset_req reset_type)
69947022
goto err_init_ctrlq;
69957023
}
69967024

6997-
if (pf->first_sw->dflt_vsi_ena)
6998-
dev_info(dev, "Clearing default VSI, re-enable after reset completes\n");
6999-
/* clear the default VSI configuration if it exists */
7000-
pf->first_sw->dflt_vsi = NULL;
7001-
pf->first_sw->dflt_vsi_ena = false;
7002-
70037025
ice_clear_pxe_mode(hw);
70047026

70057027
err = ice_init_nvm(hw);

0 commit comments

Comments
 (0)