Skip to content

Commit b3be918

Browse files
gnitkaanguy11
authored andcommitted
ice: rebuild switchdev when resetting all VFs
As resetting all VFs behaves mostly like creating new VFs also eswitch infrastructure has to be recreated. The easiest way to do that is to rebuild eswitch after resetting VFs. Implement helper functions to start and stop all representors queues. This is used to disable traffic on port representors. In rebuild path: - NAPI has to be disabled - eswitch environment has to be set up - new port representors have to be created, because the old one had pointer to not existing VFs - new control plane VSI ring should be remapped - NAPI hast to be enabled - rxdid has to be set to FLEX_NIC_2, because this descriptor id support source_vsi, which is needed on control plane VSI queues - port representors queues have to be started Signed-off-by: Grzegorz Nitka <grzegorz.nitka@intel.com> Tested-by: Sandeep Penigalapati <sandeep.penigalapati@intel.com> Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
1 parent 1c54c83 commit b3be918

File tree

6 files changed

+130
-1
lines changed

6 files changed

+130
-1
lines changed

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

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,18 @@ ice_eswitch_vsi_setup(struct ice_pf *pf, struct ice_port_info *pi)
290290
return ice_vsi_setup(pf, pi, ICE_VSI_SWITCHDEV_CTRL, ICE_INVAL_VFID);
291291
}
292292

293+
/**
294+
* ice_eswitch_napi_del - remove NAPI handle for all port representors
295+
* @pf: pointer to PF structure
296+
*/
297+
static void ice_eswitch_napi_del(struct ice_pf *pf)
298+
{
299+
int i;
300+
301+
ice_for_each_vf(pf, i)
302+
netif_napi_del(&pf->vf[i].repr->q_vector->napi);
303+
}
304+
293305
/**
294306
* ice_eswitch_napi_enable - enable NAPI for all port representors
295307
* @pf: pointer to PF structure
@@ -492,3 +504,74 @@ int ice_eswitch_configure(struct ice_pf *pf)
492504
pf->switchdev.is_running = true;
493505
return 0;
494506
}
507+
508+
/**
509+
* ice_eswitch_start_all_tx_queues - start Tx queues of all port representors
510+
* @pf: pointer to PF structure
511+
*/
512+
static void ice_eswitch_start_all_tx_queues(struct ice_pf *pf)
513+
{
514+
struct ice_repr *repr;
515+
int i;
516+
517+
if (test_bit(ICE_DOWN, pf->state))
518+
return;
519+
520+
ice_for_each_vf(pf, i) {
521+
repr = pf->vf[i].repr;
522+
if (repr)
523+
ice_repr_start_tx_queues(repr);
524+
}
525+
}
526+
527+
/**
528+
* ice_eswitch_stop_all_tx_queues - stop Tx queues of all port representors
529+
* @pf: pointer to PF structure
530+
*/
531+
void ice_eswitch_stop_all_tx_queues(struct ice_pf *pf)
532+
{
533+
struct ice_repr *repr;
534+
int i;
535+
536+
if (test_bit(ICE_DOWN, pf->state))
537+
return;
538+
539+
ice_for_each_vf(pf, i) {
540+
repr = pf->vf[i].repr;
541+
if (repr)
542+
ice_repr_stop_tx_queues(repr);
543+
}
544+
}
545+
546+
/**
547+
* ice_eswitch_rebuild - rebuild eswitch
548+
* @pf: pointer to PF structure
549+
*/
550+
int ice_eswitch_rebuild(struct ice_pf *pf)
551+
{
552+
struct ice_vsi *ctrl_vsi = pf->switchdev.control_vsi;
553+
int status;
554+
555+
ice_eswitch_napi_disable(pf);
556+
ice_eswitch_napi_del(pf);
557+
558+
status = ice_eswitch_setup_env(pf);
559+
if (status)
560+
return status;
561+
562+
status = ice_eswitch_setup_reprs(pf);
563+
if (status)
564+
return status;
565+
566+
ice_eswitch_remap_rings_to_vectors(pf);
567+
568+
status = ice_vsi_open(ctrl_vsi);
569+
if (status)
570+
return status;
571+
572+
ice_eswitch_napi_enable(pf);
573+
ice_eswitch_set_rxdid(ctrl_vsi, ICE_RXDID_FLEX_NIC_2);
574+
ice_eswitch_start_all_tx_queues(pf);
575+
576+
return 0;
577+
}

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#ifdef CONFIG_ICE_SWITCHDEV
1010
void ice_eswitch_release(struct ice_pf *pf);
1111
int ice_eswitch_configure(struct ice_pf *pf);
12+
int ice_eswitch_rebuild(struct ice_pf *pf);
1213

1314
int ice_eswitch_mode_get(struct devlink *devlink, u16 *mode);
1415
int
@@ -17,16 +18,25 @@ ice_eswitch_mode_set(struct devlink *devlink, u16 mode,
1718
bool ice_is_eswitch_mode_switchdev(struct ice_pf *pf);
1819

1920
void ice_eswitch_update_repr(struct ice_vsi *vsi);
21+
22+
void ice_eswitch_stop_all_tx_queues(struct ice_pf *pf);
2023
#else /* CONFIG_ICE_SWITCHDEV */
2124
static inline void ice_eswitch_release(struct ice_pf *pf) { }
2225

26+
static inline void ice_eswitch_stop_all_tx_queues(struct ice_pf *pf) { }
27+
2328
static inline void ice_eswitch_update_repr(struct ice_vsi *vsi) { }
2429

2530
static inline int ice_eswitch_configure(struct ice_pf *pf)
2631
{
2732
return -EOPNOTSUPP;
2833
}
2934

35+
static inline int ice_eswitch_rebuild(struct ice_pf *pf)
36+
{
37+
return -EOPNOTSUPP;
38+
}
39+
3040
static inline int ice_eswitch_mode_get(struct devlink *devlink, u16 *mode)
3141
{
3242
return DEVLINK_ESWITCH_MODE_LEGACY;

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
*/
2020
#define CREATE_TRACE_POINTS
2121
#include "ice_trace.h"
22+
#include "ice_eswitch.h"
2223

2324
#define DRV_SUMMARY "Intel(R) Ethernet Connection E800 Series Linux Driver"
2425
static const char ice_driver_string[] = DRV_SUMMARY;
@@ -5992,9 +5993,11 @@ int ice_down(struct ice_vsi *vsi)
59925993
/* Caller of this function is expected to set the
59935994
* vsi->state ICE_DOWN bit
59945995
*/
5995-
if (vsi->netdev) {
5996+
if (vsi->netdev && vsi->type == ICE_VSI_PF) {
59965997
netif_carrier_off(vsi->netdev);
59975998
netif_tx_disable(vsi->netdev);
5999+
} else if (vsi->type == ICE_VSI_SWITCHDEV_CTRL) {
6000+
ice_eswitch_stop_all_tx_queues(vsi->back);
59986001
}
59996002

60006003
ice_vsi_dis_irq(vsi);
@@ -6440,6 +6443,12 @@ static void ice_rebuild(struct ice_pf *pf, enum ice_reset_req reset_type)
64406443
goto err_vsi_rebuild;
64416444
}
64426445

6446+
err = ice_vsi_rebuild_by_type(pf, ICE_VSI_SWITCHDEV_CTRL);
6447+
if (err) {
6448+
dev_err(dev, "Switchdev CTRL VSI rebuild failed: %d\n", err);
6449+
goto err_vsi_rebuild;
6450+
}
6451+
64436452
/* If Flow Director is active */
64446453
if (test_bit(ICE_FLAG_FD_ENA, pf->flags)) {
64456454
err = ice_vsi_rebuild_by_type(pf, ICE_VSI_CTRL);

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,26 @@ void ice_repr_rem_from_all_vfs(struct ice_pf *pf)
266266
}
267267
}
268268

269+
/**
270+
* ice_repr_start_tx_queues - start Tx queues of port representor
271+
* @repr: pointer to repr structure
272+
*/
273+
void ice_repr_start_tx_queues(struct ice_repr *repr)
274+
{
275+
netif_carrier_on(repr->netdev);
276+
netif_tx_start_all_queues(repr->netdev);
277+
}
278+
279+
/**
280+
* ice_repr_stop_tx_queues - stop Tx queues of port representor
281+
* @repr: pointer to repr structure
282+
*/
283+
void ice_repr_stop_tx_queues(struct ice_repr *repr)
284+
{
285+
netif_carrier_off(repr->netdev);
286+
netif_tx_stop_all_queues(repr->netdev);
287+
}
288+
269289
/**
270290
* ice_repr_set_traffic_vsi - set traffic VSI for port representor
271291
* @repr: repr on with VSI will be set

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ struct ice_repr {
1818
int ice_repr_add_for_all_vfs(struct ice_pf *pf);
1919
void ice_repr_rem_from_all_vfs(struct ice_pf *pf);
2020

21+
void ice_repr_start_tx_queues(struct ice_repr *repr);
22+
void ice_repr_stop_tx_queues(struct ice_repr *repr);
23+
2124
void ice_repr_set_traffic_vsi(struct ice_repr *repr, struct ice_vsi *vsi);
2225

2326
struct ice_repr *ice_netdev_to_repr(struct net_device *netdev);

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1587,6 +1587,10 @@ bool ice_reset_all_vfs(struct ice_pf *pf, bool is_vflr)
15871587
ice_vf_post_vsi_rebuild(vf);
15881588
}
15891589

1590+
if (ice_is_eswitch_mode_switchdev(pf))
1591+
if (ice_eswitch_rebuild(pf))
1592+
dev_warn(dev, "eswitch rebuild failed\n");
1593+
15901594
ice_flush(hw);
15911595
clear_bit(ICE_VF_DIS, pf->state);
15921596

0 commit comments

Comments
 (0)