Skip to content

Commit 44ba608

Browse files
Michal Swiatkowskianguy11
authored andcommitted
ice: do switchdev slow-path Rx using PF VSI
Add an ICE_RX_FLAG_MULTIDEV flag to Rx ring. If it is set try to find correct port representor. Do it based on src_vsi value stored in flex descriptor. Ids of representor pointers stored in xarray are equal to corresponding src_vsi value. Thanks to that we can directly get correct representor if we have src_vsi value. Set multidev flag during ring configuration. If the mode is switchdev, change the ring descriptor to the one that contains src_vsi value. PF netdev should be reconfigured, do it by calling ice_down() and ice_up() if the netdev was up before configuring switchdev. Reviewed-by: Marcin Szycik <marcin.szycik@linux.intel.com> Signed-off-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com> Tested-by: Sujai Buvaneswaran <sujai.buvaneswaran@intel.com> Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
1 parent 6235cb6 commit 44ba608

File tree

5 files changed

+62
-1
lines changed

5 files changed

+62
-1
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,14 @@ static int ice_setup_rx_ctx(struct ice_rx_ring *ring)
452452
/* Rx queue threshold in units of 64 */
453453
rlan_ctx.lrxqthresh = 1;
454454

455+
/* PF acts as uplink for switchdev; set flex descriptor with src_vsi
456+
* metadata and flags to allow redirecting to PR netdev
457+
*/
458+
if (ice_is_eswitch_mode_switchdev(vsi->back)) {
459+
ring->flags |= ICE_RX_FLAGS_MULTIDEV;
460+
rxdid = ICE_RXDID_FLEX_NIC_2;
461+
}
462+
455463
/* Enable Flexible Descriptors in the queue context which
456464
* allows this driver to select a specific receive descriptor format
457465
* increasing context priority to pick up profile ID; default is 0x01;

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

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,13 @@ static int ice_eswitch_setup_env(struct ice_pf *pf)
2121
{
2222
struct ice_vsi *uplink_vsi = pf->eswitch.uplink_vsi;
2323
struct net_device *netdev = uplink_vsi->netdev;
24+
bool if_running = netif_running(netdev);
2425
struct ice_vsi_vlan_ops *vlan_ops;
2526

27+
if (if_running && !test_and_set_bit(ICE_VSI_DOWN, uplink_vsi->state))
28+
if (ice_down(uplink_vsi))
29+
return -ENODEV;
30+
2631
ice_remove_vsi_fltr(&pf->hw, uplink_vsi->idx);
2732

2833
netif_addr_lock_bh(netdev);
@@ -51,8 +56,13 @@ static int ice_eswitch_setup_env(struct ice_pf *pf)
5156
if (ice_vsi_update_local_lb(uplink_vsi, true))
5257
goto err_override_local_lb;
5358

59+
if (if_running && ice_up(uplink_vsi))
60+
goto err_up;
61+
5462
return 0;
5563

64+
err_up:
65+
ice_vsi_update_local_lb(uplink_vsi, false);
5666
err_override_local_lb:
5767
ice_vsi_update_security(uplink_vsi, ice_vsi_ctx_clear_allow_override);
5868
err_override_uplink:
@@ -69,6 +79,9 @@ static int ice_eswitch_setup_env(struct ice_pf *pf)
6979
ice_fltr_add_mac_and_broadcast(uplink_vsi,
7080
uplink_vsi->port_info->mac.perm_addr,
7181
ICE_FWD_TO_VSI);
82+
if (if_running)
83+
ice_up(uplink_vsi);
84+
7285
return -ENODEV;
7386
}
7487

@@ -493,3 +506,26 @@ void ice_eswitch_rebuild(struct ice_pf *pf)
493506
xa_for_each(&pf->eswitch.reprs, id, repr)
494507
ice_eswitch_detach(pf, repr->vf);
495508
}
509+
510+
/**
511+
* ice_eswitch_get_target - get netdev based on src_vsi from descriptor
512+
* @rx_ring: ring used to receive the packet
513+
* @rx_desc: descriptor used to get src_vsi value
514+
*
515+
* Get src_vsi value from descriptor and load correct representor. If it isn't
516+
* found return rx_ring->netdev.
517+
*/
518+
struct net_device *ice_eswitch_get_target(struct ice_rx_ring *rx_ring,
519+
union ice_32b_rx_flex_desc *rx_desc)
520+
{
521+
struct ice_eswitch *eswitch = &rx_ring->vsi->back->eswitch;
522+
struct ice_32b_rx_flex_desc_nic_2 *desc;
523+
struct ice_repr *repr;
524+
525+
desc = (struct ice_32b_rx_flex_desc_nic_2 *)rx_desc;
526+
repr = xa_load(&eswitch->reprs, le16_to_cpu(desc->src_vsi));
527+
if (!repr)
528+
return rx_ring->netdev;
529+
530+
return repr->netdev;
531+
}

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ void ice_eswitch_set_target_vsi(struct sk_buff *skb,
2626
struct ice_tx_offload_params *off);
2727
netdev_tx_t
2828
ice_eswitch_port_start_xmit(struct sk_buff *skb, struct net_device *netdev);
29+
struct net_device *ice_eswitch_get_target(struct ice_rx_ring *rx_ring,
30+
union ice_32b_rx_flex_desc *rx_desc);
2931
#else /* CONFIG_ICE_SWITCHDEV */
3032
static inline void ice_eswitch_detach(struct ice_pf *pf, struct ice_vf *vf) { }
3133

@@ -76,5 +78,12 @@ ice_eswitch_port_start_xmit(struct sk_buff *skb, struct net_device *netdev)
7678
{
7779
return NETDEV_TX_BUSY;
7880
}
81+
82+
static inline struct net_device *
83+
ice_eswitch_get_target(struct ice_rx_ring *rx_ring,
84+
union ice_32b_rx_flex_desc *rx_desc)
85+
{
86+
return rx_ring->netdev;
87+
}
7988
#endif /* CONFIG_ICE_SWITCHDEV */
8089
#endif /* _ICE_ESWITCH_H_ */

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,7 @@ struct ice_rx_ring {
365365
u8 ptp_rx;
366366
#define ICE_RX_FLAGS_RING_BUILD_SKB BIT(1)
367367
#define ICE_RX_FLAGS_CRC_STRIP_DIS BIT(2)
368+
#define ICE_RX_FLAGS_MULTIDEV BIT(3)
368369
u8 flags;
369370
/* CL5 - 5th cacheline starts here */
370371
struct xdp_rxq_info xdp_rxq;

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,14 @@ ice_process_skb_fields(struct ice_rx_ring *rx_ring,
236236
ice_rx_hash_to_skb(rx_ring, rx_desc, skb, ptype);
237237

238238
/* modifies the skb - consumes the enet header */
239-
skb->protocol = eth_type_trans(skb, rx_ring->netdev);
239+
if (unlikely(rx_ring->flags & ICE_RX_FLAGS_MULTIDEV)) {
240+
struct net_device *netdev = ice_eswitch_get_target(rx_ring,
241+
rx_desc);
242+
243+
skb->protocol = eth_type_trans(skb, netdev);
244+
} else {
245+
skb->protocol = eth_type_trans(skb, rx_ring->netdev);
246+
}
240247

241248
ice_rx_csum(rx_ring, skb, rx_desc, ptype);
242249

0 commit comments

Comments
 (0)