Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch '100GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/next-queue

Tony Nguyen says:

====================
ice: use less resources in switchdev

Michal Swiatkowski says:

Switchdev is using one queue per created port representor. This can
quickly lead to Rx queue shortage, as with subfunction support user
can create high number of PRs.

Save one MSI-X and 'number of PRs' * 1 queues.
Refactor switchdev slow-path to use less resources (even no additional
resources). Do this by removing control plane VSI and move its
functionality to PF VSI. Even with current solution PF is acting like
uplink and can't be used simultaneously for other use cases (adding
filters can break slow-path).

In short, do Tx via PF VSI and Rx packets using PF resources. Rx needs
additional code in interrupt handler to choose correct PR netdev.
Previous solution had to queue filters, it was way more elegant but
needed one queue per PRs. Beside that this refactor mostly simplifies
switchdev configuration.

* '100GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/next-queue:
ice: count representor stats
ice: do switchdev slow-path Rx using PF VSI
ice: change repr::id values
ice: remove switchdev control plane VSI
ice: control default Tx rule in lag
ice: default Tx rule instead of to queue
ice: do Tx through PF netdev in slow-path
ice: remove eswitch changing queues algorithm
====================

Link: https://lore.kernel.org/r/20240325202623.1012287-1-anthony.l.nguyen@intel.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+229 -486
-7
drivers/net/ethernet/intel/ice/ice.h
··· 522 522 }; 523 523 524 524 struct ice_eswitch { 525 - struct ice_vsi *control_vsi; 526 525 struct ice_vsi *uplink_vsi; 527 526 struct ice_esw_br_offloads *br_offloads; 528 527 struct xarray reprs; 529 528 bool is_running; 530 - /* struct to allow cp queues management optimization */ 531 - struct { 532 - int to_reach; 533 - int value; 534 - bool is_reaching; 535 - } qs; 536 529 }; 537 530 538 531 struct ice_agg_node {
+9 -35
drivers/net/ethernet/intel/ice/ice_base.c
··· 264 264 } 265 265 266 266 /** 267 - * ice_eswitch_calc_txq_handle 268 - * @ring: pointer to ring which unique index is needed 269 - * 270 - * To correctly work with many netdevs ring->q_index of Tx rings on switchdev 271 - * VSI can repeat. Hardware ring setup requires unique q_index. Calculate it 272 - * here by finding index in vsi->tx_rings of this ring. 273 - * 274 - * Return ICE_INVAL_Q_INDEX when index wasn't found. Should never happen, 275 - * because VSI is get from ring->vsi, so it has to be present in this VSI. 276 - */ 277 - static u16 ice_eswitch_calc_txq_handle(struct ice_tx_ring *ring) 278 - { 279 - const struct ice_vsi *vsi = ring->vsi; 280 - int i; 281 - 282 - ice_for_each_txq(vsi, i) { 283 - if (vsi->tx_rings[i] == ring) 284 - return i; 285 - } 286 - 287 - return ICE_INVAL_Q_INDEX; 288 - } 289 - 290 - /** 291 267 * ice_cfg_xps_tx_ring - Configure XPS for a Tx ring 292 268 * @ring: The Tx ring to configure 293 269 * ··· 328 352 /* Firmware expects vmvf_num to be absolute VF ID */ 329 353 tlan_ctx->vmvf_num = hw->func_caps.vf_base_id + vsi->vf->vf_id; 330 354 tlan_ctx->vmvf_type = ICE_TLAN_CTX_VMVF_TYPE_VF; 331 - break; 332 - case ICE_VSI_SWITCHDEV_CTRL: 333 - tlan_ctx->vmvf_type = ICE_TLAN_CTX_VMVF_TYPE_VMQ; 334 355 break; 335 356 default: 336 357 return; ··· 451 478 452 479 /* Rx queue threshold in units of 64 */ 453 480 rlan_ctx.lrxqthresh = 1; 481 + 482 + /* PF acts as uplink for switchdev; set flex descriptor with src_vsi 483 + * metadata and flags to allow redirecting to PR netdev 484 + */ 485 + if (ice_is_eswitch_mode_switchdev(vsi->back)) { 486 + ring->flags |= ICE_RX_FLAGS_MULTIDEV; 487 + rxdid = ICE_RXDID_FLEX_NIC_2; 488 + } 454 489 455 490 /* Enable Flexible Descriptors in the queue context which 456 491 * allows this driver to select a specific receive descriptor format ··· 900 919 /* Add unique software queue handle of the Tx queue per 901 920 * TC into the VSI Tx ring 902 921 */ 903 - if (vsi->type == ICE_VSI_SWITCHDEV_CTRL) { 904 - ring->q_handle = ice_eswitch_calc_txq_handle(ring); 905 - 906 - if (ring->q_handle == ICE_INVAL_Q_INDEX) 907 - return -ENODEV; 908 - } else { 909 - ring->q_handle = ice_calc_txq_handle(vsi, ring, tc); 910 - } 922 + ring->q_handle = ice_calc_txq_handle(vsi, ring, tc); 911 923 912 924 if (ch) 913 925 status = ice_ena_vsi_txq(vsi->port_info, ch->ch_vsi->idx, 0,
+1 -3
drivers/net/ethernet/intel/ice/ice_dcb_lib.c
··· 291 291 292 292 switch (vsi->type) { 293 293 case ICE_VSI_CHNL: 294 - case ICE_VSI_SWITCHDEV_CTRL: 295 294 case ICE_VSI_PF: 296 295 if (ena) 297 296 ice_ena_vsi(vsi, locked); ··· 775 776 /* no need to proceed with remaining cfg if it is CHNL 776 777 * or switchdev VSI 777 778 */ 778 - if (vsi->type == ICE_VSI_CHNL || 779 - vsi->type == ICE_VSI_SWITCHDEV_CTRL) 779 + if (vsi->type == ICE_VSI_CHNL) 780 780 continue; 781 781 782 782 ice_vsi_map_rings_to_vectors(vsi);
+62 -300
drivers/net/ethernet/intel/ice/ice_eswitch.c
··· 11 11 #include "ice_tc_lib.h" 12 12 13 13 /** 14 - * ice_eswitch_del_sp_rules - delete adv rules added on PRs 15 - * @pf: pointer to the PF struct 16 - * 17 - * Delete all advanced rules that were used to forward packets with the 18 - * device's VSI index to the corresponding eswitch ctrl VSI queue. 19 - */ 20 - static void ice_eswitch_del_sp_rules(struct ice_pf *pf) 21 - { 22 - struct ice_repr *repr; 23 - unsigned long id; 24 - 25 - xa_for_each(&pf->eswitch.reprs, id, repr) { 26 - if (repr->sp_rule.rid) 27 - ice_rem_adv_rule_by_id(&pf->hw, &repr->sp_rule); 28 - } 29 - } 30 - 31 - /** 32 - * ice_eswitch_add_sp_rule - add adv rule with device's VSI index 33 - * @pf: pointer to PF struct 34 - * @repr: pointer to the repr struct 35 - * 36 - * This function adds advanced rule that forwards packets with 37 - * device's VSI index to the corresponding eswitch ctrl VSI queue. 38 - */ 39 - static int ice_eswitch_add_sp_rule(struct ice_pf *pf, struct ice_repr *repr) 40 - { 41 - struct ice_vsi *ctrl_vsi = pf->eswitch.control_vsi; 42 - struct ice_adv_rule_info rule_info = { 0 }; 43 - struct ice_adv_lkup_elem *list; 44 - struct ice_hw *hw = &pf->hw; 45 - const u16 lkups_cnt = 1; 46 - int err; 47 - 48 - list = kcalloc(lkups_cnt, sizeof(*list), GFP_ATOMIC); 49 - if (!list) 50 - return -ENOMEM; 51 - 52 - ice_rule_add_src_vsi_metadata(list); 53 - 54 - rule_info.sw_act.flag = ICE_FLTR_TX; 55 - rule_info.sw_act.vsi_handle = ctrl_vsi->idx; 56 - rule_info.sw_act.fltr_act = ICE_FWD_TO_Q; 57 - rule_info.sw_act.fwd_id.q_id = hw->func_caps.common_cap.rxq_first_id + 58 - ctrl_vsi->rxq_map[repr->q_id]; 59 - rule_info.flags_info.act |= ICE_SINGLE_ACT_LB_ENABLE; 60 - rule_info.flags_info.act_valid = true; 61 - rule_info.tun_type = ICE_SW_TUN_AND_NON_TUN; 62 - rule_info.src_vsi = repr->src_vsi->idx; 63 - 64 - err = ice_add_adv_rule(hw, list, lkups_cnt, &rule_info, 65 - &repr->sp_rule); 66 - if (err) 67 - dev_err(ice_pf_to_dev(pf), "Unable to add slow-path rule for eswitch for PR %d", 68 - repr->id); 69 - 70 - kfree(list); 71 - return err; 72 - } 73 - 74 - static int 75 - ice_eswitch_add_sp_rules(struct ice_pf *pf) 76 - { 77 - struct ice_repr *repr; 78 - unsigned long id; 79 - int err; 80 - 81 - xa_for_each(&pf->eswitch.reprs, id, repr) { 82 - err = ice_eswitch_add_sp_rule(pf, repr); 83 - if (err) { 84 - ice_eswitch_del_sp_rules(pf); 85 - return err; 86 - } 87 - } 88 - 89 - return 0; 90 - } 91 - 92 - /** 93 14 * ice_eswitch_setup_env - configure eswitch HW filters 94 15 * @pf: pointer to PF struct 95 16 * ··· 20 99 static int ice_eswitch_setup_env(struct ice_pf *pf) 21 100 { 22 101 struct ice_vsi *uplink_vsi = pf->eswitch.uplink_vsi; 23 - struct ice_vsi *ctrl_vsi = pf->eswitch.control_vsi; 24 102 struct net_device *netdev = uplink_vsi->netdev; 103 + bool if_running = netif_running(netdev); 25 104 struct ice_vsi_vlan_ops *vlan_ops; 26 - bool rule_added = false; 105 + 106 + if (if_running && !test_and_set_bit(ICE_VSI_DOWN, uplink_vsi->state)) 107 + if (ice_down(uplink_vsi)) 108 + return -ENODEV; 27 109 28 110 ice_remove_vsi_fltr(&pf->hw, uplink_vsi->idx); 29 111 ··· 36 112 netif_addr_unlock_bh(netdev); 37 113 38 114 if (ice_vsi_add_vlan_zero(uplink_vsi)) 115 + goto err_vlan_zero; 116 + 117 + if (ice_cfg_dflt_vsi(uplink_vsi->port_info, uplink_vsi->idx, true, 118 + ICE_FLTR_RX)) 39 119 goto err_def_rx; 40 120 41 - if (!ice_is_dflt_vsi_in_use(uplink_vsi->port_info)) { 42 - if (ice_set_dflt_vsi(uplink_vsi)) 43 - goto err_def_rx; 44 - rule_added = true; 45 - } 121 + if (ice_cfg_dflt_vsi(uplink_vsi->port_info, uplink_vsi->idx, true, 122 + ICE_FLTR_TX)) 123 + goto err_def_tx; 46 124 47 125 vlan_ops = ice_get_compat_vsi_vlan_ops(uplink_vsi); 48 126 if (vlan_ops->dis_rx_filtering(uplink_vsi)) 49 - goto err_dis_rx; 127 + goto err_vlan_filtering; 50 128 51 129 if (ice_vsi_update_security(uplink_vsi, ice_vsi_ctx_set_allow_override)) 52 130 goto err_override_uplink; 53 131 54 - if (ice_vsi_update_security(ctrl_vsi, ice_vsi_ctx_set_allow_override)) 55 - goto err_override_control; 56 - 57 132 if (ice_vsi_update_local_lb(uplink_vsi, true)) 58 133 goto err_override_local_lb; 59 134 135 + if (if_running && ice_up(uplink_vsi)) 136 + goto err_up; 137 + 60 138 return 0; 61 139 140 + err_up: 141 + ice_vsi_update_local_lb(uplink_vsi, false); 62 142 err_override_local_lb: 63 - ice_vsi_update_security(ctrl_vsi, ice_vsi_ctx_clear_allow_override); 64 - err_override_control: 65 143 ice_vsi_update_security(uplink_vsi, ice_vsi_ctx_clear_allow_override); 66 144 err_override_uplink: 67 145 vlan_ops->ena_rx_filtering(uplink_vsi); 68 - err_dis_rx: 69 - if (rule_added) 70 - ice_clear_dflt_vsi(uplink_vsi); 146 + err_vlan_filtering: 147 + ice_cfg_dflt_vsi(uplink_vsi->port_info, uplink_vsi->idx, false, 148 + ICE_FLTR_TX); 149 + err_def_tx: 150 + ice_cfg_dflt_vsi(uplink_vsi->port_info, uplink_vsi->idx, false, 151 + ICE_FLTR_RX); 71 152 err_def_rx: 153 + ice_vsi_del_vlan_zero(uplink_vsi); 154 + err_vlan_zero: 72 155 ice_fltr_add_mac_and_broadcast(uplink_vsi, 73 156 uplink_vsi->port_info->mac.perm_addr, 74 157 ICE_FWD_TO_VSI); 158 + if (if_running) 159 + ice_up(uplink_vsi); 160 + 75 161 return -ENODEV; 76 - } 77 - 78 - /** 79 - * ice_eswitch_remap_rings_to_vectors - reconfigure rings of eswitch ctrl VSI 80 - * @eswitch: pointer to eswitch struct 81 - * 82 - * In eswitch number of allocated Tx/Rx rings is equal. 83 - * 84 - * This function fills q_vectors structures associated with representor and 85 - * move each ring pairs to port representor netdevs. Each port representor 86 - * will have dedicated 1 Tx/Rx ring pair, so number of rings pair is equal to 87 - * number of VFs. 88 - */ 89 - static void ice_eswitch_remap_rings_to_vectors(struct ice_eswitch *eswitch) 90 - { 91 - struct ice_vsi *vsi = eswitch->control_vsi; 92 - unsigned long repr_id = 0; 93 - int q_id; 94 - 95 - ice_for_each_txq(vsi, q_id) { 96 - struct ice_q_vector *q_vector; 97 - struct ice_tx_ring *tx_ring; 98 - struct ice_rx_ring *rx_ring; 99 - struct ice_repr *repr; 100 - 101 - repr = xa_find(&eswitch->reprs, &repr_id, U32_MAX, 102 - XA_PRESENT); 103 - if (!repr) 104 - break; 105 - 106 - repr_id += 1; 107 - repr->q_id = q_id; 108 - q_vector = repr->q_vector; 109 - tx_ring = vsi->tx_rings[q_id]; 110 - rx_ring = vsi->rx_rings[q_id]; 111 - 112 - q_vector->vsi = vsi; 113 - q_vector->reg_idx = vsi->q_vectors[0]->reg_idx; 114 - 115 - q_vector->num_ring_tx = 1; 116 - q_vector->tx.tx_ring = tx_ring; 117 - tx_ring->q_vector = q_vector; 118 - tx_ring->next = NULL; 119 - tx_ring->netdev = repr->netdev; 120 - /* In switchdev mode, from OS stack perspective, there is only 121 - * one queue for given netdev, so it needs to be indexed as 0. 122 - */ 123 - tx_ring->q_index = 0; 124 - 125 - q_vector->num_ring_rx = 1; 126 - q_vector->rx.rx_ring = rx_ring; 127 - rx_ring->q_vector = q_vector; 128 - rx_ring->next = NULL; 129 - rx_ring->netdev = repr->netdev; 130 - } 131 162 } 132 163 133 164 /** ··· 104 225 repr->dst = NULL; 105 226 ice_fltr_add_mac_and_broadcast(vsi, repr->parent_mac, 106 227 ICE_FWD_TO_VSI); 107 - 108 - netif_napi_del(&repr->q_vector->napi); 109 228 } 110 229 111 230 /** ··· 113 236 */ 114 237 static int ice_eswitch_setup_repr(struct ice_pf *pf, struct ice_repr *repr) 115 238 { 116 - struct ice_vsi *ctrl_vsi = pf->eswitch.control_vsi; 239 + struct ice_vsi *uplink_vsi = pf->eswitch.uplink_vsi; 117 240 struct ice_vsi *vsi = repr->src_vsi; 118 241 struct metadata_dst *dst; 119 242 ··· 129 252 if (ice_vsi_add_vlan_zero(vsi)) 130 253 goto err_update_security; 131 254 132 - netif_napi_add(repr->netdev, &repr->q_vector->napi, 133 - ice_napi_poll); 134 - 135 - netif_keep_dst(repr->netdev); 255 + netif_keep_dst(uplink_vsi->netdev); 136 256 137 257 dst = repr->dst; 138 258 dst->u.port_info.port_id = vsi->vsi_num; 139 - dst->u.port_info.lower_dev = repr->netdev; 140 - ice_repr_set_traffic_vsi(repr, ctrl_vsi); 259 + dst->u.port_info.lower_dev = uplink_vsi->netdev; 141 260 142 261 return 0; 143 262 ··· 191 318 netdev_tx_t 192 319 ice_eswitch_port_start_xmit(struct sk_buff *skb, struct net_device *netdev) 193 320 { 194 - struct ice_netdev_priv *np; 195 - struct ice_repr *repr; 196 - struct ice_vsi *vsi; 321 + struct ice_repr *repr = ice_netdev_to_repr(netdev); 322 + unsigned int len = skb->len; 323 + int ret; 197 324 198 - np = netdev_priv(netdev); 199 - vsi = np->vsi; 200 - 201 - if (!vsi || !ice_is_switchdev_running(vsi->back)) 202 - return NETDEV_TX_BUSY; 203 - 204 - if (ice_is_reset_in_progress(vsi->back->state) || 205 - test_bit(ICE_VF_DIS, vsi->back->state)) 206 - return NETDEV_TX_BUSY; 207 - 208 - repr = ice_netdev_to_repr(netdev); 209 325 skb_dst_drop(skb); 210 326 dst_hold((struct dst_entry *)repr->dst); 211 327 skb_dst_set(skb, (struct dst_entry *)repr->dst); 212 - skb->queue_mapping = repr->q_id; 328 + skb->dev = repr->dst->u.port_info.lower_dev; 213 329 214 - return ice_start_xmit(skb, netdev); 330 + ret = dev_queue_xmit(skb); 331 + ice_repr_inc_tx_stats(repr, len, ret); 332 + 333 + return ret; 215 334 } 216 335 217 336 /** ··· 239 374 static void ice_eswitch_release_env(struct ice_pf *pf) 240 375 { 241 376 struct ice_vsi *uplink_vsi = pf->eswitch.uplink_vsi; 242 - struct ice_vsi *ctrl_vsi = pf->eswitch.control_vsi; 243 377 struct ice_vsi_vlan_ops *vlan_ops; 244 378 245 379 vlan_ops = ice_get_compat_vsi_vlan_ops(uplink_vsi); 246 380 247 381 ice_vsi_update_local_lb(uplink_vsi, false); 248 - ice_vsi_update_security(ctrl_vsi, ice_vsi_ctx_clear_allow_override); 249 382 ice_vsi_update_security(uplink_vsi, ice_vsi_ctx_clear_allow_override); 250 383 vlan_ops->ena_rx_filtering(uplink_vsi); 251 384 ice_clear_dflt_vsi(uplink_vsi); ··· 253 390 } 254 391 255 392 /** 256 - * ice_eswitch_vsi_setup - configure eswitch control VSI 257 - * @pf: pointer to PF structure 258 - * @pi: pointer to port_info structure 259 - */ 260 - static struct ice_vsi * 261 - ice_eswitch_vsi_setup(struct ice_pf *pf, struct ice_port_info *pi) 262 - { 263 - struct ice_vsi_cfg_params params = {}; 264 - 265 - params.type = ICE_VSI_SWITCHDEV_CTRL; 266 - params.pi = pi; 267 - params.flags = ICE_VSI_FLAG_INIT; 268 - 269 - return ice_vsi_setup(pf, &params); 270 - } 271 - 272 - /** 273 - * ice_eswitch_napi_enable - enable NAPI for all port representors 274 - * @reprs: xarray of reprs 275 - */ 276 - static void ice_eswitch_napi_enable(struct xarray *reprs) 277 - { 278 - struct ice_repr *repr; 279 - unsigned long id; 280 - 281 - xa_for_each(reprs, id, repr) 282 - napi_enable(&repr->q_vector->napi); 283 - } 284 - 285 - /** 286 - * ice_eswitch_napi_disable - disable NAPI for all port representors 287 - * @reprs: xarray of reprs 288 - */ 289 - static void ice_eswitch_napi_disable(struct xarray *reprs) 290 - { 291 - struct ice_repr *repr; 292 - unsigned long id; 293 - 294 - xa_for_each(reprs, id, repr) 295 - napi_disable(&repr->q_vector->napi); 296 - } 297 - 298 - /** 299 393 * ice_eswitch_enable_switchdev - configure eswitch in switchdev mode 300 394 * @pf: pointer to PF structure 301 395 */ 302 396 static int ice_eswitch_enable_switchdev(struct ice_pf *pf) 303 397 { 304 - struct ice_vsi *ctrl_vsi, *uplink_vsi; 398 + struct ice_vsi *uplink_vsi; 305 399 306 400 uplink_vsi = ice_get_main_vsi(pf); 307 401 if (!uplink_vsi) ··· 270 450 return -EINVAL; 271 451 } 272 452 273 - pf->eswitch.control_vsi = ice_eswitch_vsi_setup(pf, pf->hw.port_info); 274 - if (!pf->eswitch.control_vsi) 275 - return -ENODEV; 276 - 277 - ctrl_vsi = pf->eswitch.control_vsi; 278 - /* cp VSI is createad with 1 queue as default */ 279 - pf->eswitch.qs.value = 1; 280 453 pf->eswitch.uplink_vsi = uplink_vsi; 281 454 282 455 if (ice_eswitch_setup_env(pf)) 283 - goto err_vsi; 456 + return -ENODEV; 284 457 285 458 if (ice_eswitch_br_offloads_init(pf)) 286 459 goto err_br_offloads; ··· 284 471 285 472 err_br_offloads: 286 473 ice_eswitch_release_env(pf); 287 - err_vsi: 288 - ice_vsi_release(ctrl_vsi); 289 474 return -ENODEV; 290 475 } 291 476 ··· 293 482 */ 294 483 static void ice_eswitch_disable_switchdev(struct ice_pf *pf) 295 484 { 296 - struct ice_vsi *ctrl_vsi = pf->eswitch.control_vsi; 297 - 298 485 ice_eswitch_br_offloads_deinit(pf); 299 486 ice_eswitch_release_env(pf); 300 - ice_vsi_release(ctrl_vsi); 301 487 302 488 pf->eswitch.is_running = false; 303 - pf->eswitch.qs.is_reaching = false; 304 489 } 305 490 306 491 /** ··· 337 530 338 531 dev_info(ice_pf_to_dev(pf), "PF %d changed eswitch mode to switchdev", 339 532 pf->hw.pf_id); 340 - xa_init_flags(&pf->eswitch.reprs, XA_FLAGS_ALLOC); 533 + xa_init(&pf->eswitch.reprs); 341 534 NL_SET_ERR_MSG_MOD(extack, "Changed eswitch mode to switchdev"); 342 535 break; 343 536 } ··· 409 602 410 603 static void ice_eswitch_stop_reprs(struct ice_pf *pf) 411 604 { 412 - ice_eswitch_del_sp_rules(pf); 413 605 ice_eswitch_stop_all_tx_queues(pf); 414 - ice_eswitch_napi_disable(&pf->eswitch.reprs); 415 606 } 416 607 417 608 static void ice_eswitch_start_reprs(struct ice_pf *pf) 418 609 { 419 - ice_eswitch_napi_enable(&pf->eswitch.reprs); 420 610 ice_eswitch_start_all_tx_queues(pf); 421 - ice_eswitch_add_sp_rules(pf); 422 - } 423 - 424 - static void 425 - ice_eswitch_cp_change_queues(struct ice_eswitch *eswitch, int change) 426 - { 427 - struct ice_vsi *cp = eswitch->control_vsi; 428 - int queues = 0; 429 - 430 - if (eswitch->qs.is_reaching) { 431 - if (eswitch->qs.to_reach >= eswitch->qs.value + change) { 432 - queues = eswitch->qs.to_reach; 433 - eswitch->qs.is_reaching = false; 434 - } else { 435 - queues = 0; 436 - } 437 - } else if ((change > 0 && cp->alloc_txq <= eswitch->qs.value) || 438 - change < 0) { 439 - queues = cp->alloc_txq + change; 440 - } 441 - 442 - if (queues) { 443 - cp->req_txq = queues; 444 - cp->req_rxq = queues; 445 - ice_vsi_close(cp); 446 - ice_vsi_rebuild(cp, ICE_VSI_FLAG_NO_INIT); 447 - ice_vsi_open(cp); 448 - } else if (!change) { 449 - /* change == 0 means that VSI wasn't open, open it here */ 450 - ice_vsi_open(cp); 451 - } 452 - 453 - eswitch->qs.value += change; 454 - ice_eswitch_remap_rings_to_vectors(eswitch); 455 611 } 456 612 457 613 int 458 614 ice_eswitch_attach(struct ice_pf *pf, struct ice_vf *vf) 459 615 { 460 616 struct ice_repr *repr; 461 - int change = 1; 462 617 int err; 463 618 464 619 if (pf->eswitch_mode == DEVLINK_ESWITCH_MODE_LEGACY) ··· 430 661 err = ice_eswitch_enable_switchdev(pf); 431 662 if (err) 432 663 return err; 433 - /* Control plane VSI is created with 1 queue as default */ 434 - pf->eswitch.qs.to_reach -= 1; 435 - change = 0; 436 664 } 437 665 438 666 ice_eswitch_stop_reprs(pf); ··· 444 678 if (err) 445 679 goto err_setup_repr; 446 680 447 - err = xa_alloc(&pf->eswitch.reprs, &repr->id, repr, 448 - XA_LIMIT(1, INT_MAX), GFP_KERNEL); 681 + err = xa_insert(&pf->eswitch.reprs, repr->id, repr, GFP_KERNEL); 449 682 if (err) 450 683 goto err_xa_alloc; 451 684 452 685 vf->repr_id = repr->id; 453 686 454 - ice_eswitch_cp_change_queues(&pf->eswitch, change); 455 687 ice_eswitch_start_reprs(pf); 456 688 457 689 return 0; ··· 479 715 480 716 if (xa_empty(&pf->eswitch.reprs)) 481 717 ice_eswitch_disable_switchdev(pf); 482 - else 483 - ice_eswitch_cp_change_queues(&pf->eswitch, -1); 484 718 485 719 ice_eswitch_release_repr(pf, repr); 486 720 ice_repr_rem_vf(repr); ··· 500 738 * ice_eswitch_rebuild - rebuild eswitch 501 739 * @pf: pointer to PF structure 502 740 */ 503 - int ice_eswitch_rebuild(struct ice_pf *pf) 741 + void ice_eswitch_rebuild(struct ice_pf *pf) 504 742 { 505 743 struct ice_repr *repr; 506 744 unsigned long id; 507 - int err; 508 745 509 746 if (!ice_is_switchdev_running(pf)) 510 - return 0; 511 - 512 - err = ice_vsi_rebuild(pf->eswitch.control_vsi, ICE_VSI_FLAG_INIT); 513 - if (err) 514 - return err; 747 + return; 515 748 516 749 xa_for_each(&pf->eswitch.reprs, id, repr) 517 750 ice_eswitch_detach(pf, repr->vf); 518 - 519 - return 0; 520 751 } 521 752 522 753 /** 523 - * ice_eswitch_reserve_cp_queues - reserve control plane VSI queues 524 - * @pf: pointer to PF structure 525 - * @change: how many more (or less) queues is needed 754 + * ice_eswitch_get_target - get netdev based on src_vsi from descriptor 755 + * @rx_ring: ring used to receive the packet 756 + * @rx_desc: descriptor used to get src_vsi value 526 757 * 527 - * Remember to call ice_eswitch_attach/detach() the "change" times. 758 + * Get src_vsi value from descriptor and load correct representor. If it isn't 759 + * found return rx_ring->netdev. 528 760 */ 529 - void ice_eswitch_reserve_cp_queues(struct ice_pf *pf, int change) 761 + struct net_device *ice_eswitch_get_target(struct ice_rx_ring *rx_ring, 762 + union ice_32b_rx_flex_desc *rx_desc) 530 763 { 531 - if (pf->eswitch.qs.value + change < 0) 532 - return; 764 + struct ice_eswitch *eswitch = &rx_ring->vsi->back->eswitch; 765 + struct ice_32b_rx_flex_desc_nic_2 *desc; 766 + struct ice_repr *repr; 533 767 534 - pf->eswitch.qs.to_reach = pf->eswitch.qs.value + change; 535 - pf->eswitch.qs.is_reaching = true; 768 + desc = (struct ice_32b_rx_flex_desc_nic_2 *)rx_desc; 769 + repr = xa_load(&eswitch->reprs, le16_to_cpu(desc->src_vsi)); 770 + if (!repr) 771 + return rx_ring->netdev; 772 + 773 + return repr->netdev; 536 774 }
+9 -4
drivers/net/ethernet/intel/ice/ice_eswitch.h
··· 10 10 void ice_eswitch_detach(struct ice_pf *pf, struct ice_vf *vf); 11 11 int 12 12 ice_eswitch_attach(struct ice_pf *pf, struct ice_vf *vf); 13 - int ice_eswitch_rebuild(struct ice_pf *pf); 13 + void ice_eswitch_rebuild(struct ice_pf *pf); 14 14 15 15 int ice_eswitch_mode_get(struct devlink *devlink, u16 *mode); 16 16 int ··· 26 26 struct ice_tx_offload_params *off); 27 27 netdev_tx_t 28 28 ice_eswitch_port_start_xmit(struct sk_buff *skb, struct net_device *netdev); 29 - void ice_eswitch_reserve_cp_queues(struct ice_pf *pf, int change); 29 + struct net_device *ice_eswitch_get_target(struct ice_rx_ring *rx_ring, 30 + union ice_32b_rx_flex_desc *rx_desc); 30 31 #else /* CONFIG_ICE_SWITCHDEV */ 31 32 static inline void ice_eswitch_detach(struct ice_pf *pf, struct ice_vf *vf) { } 32 33 ··· 79 78 return NETDEV_TX_BUSY; 80 79 } 81 80 82 - static inline void 83 - ice_eswitch_reserve_cp_queues(struct ice_pf *pf, int change) { } 81 + static inline struct net_device * 82 + ice_eswitch_get_target(struct ice_rx_ring *rx_ring, 83 + union ice_32b_rx_flex_desc *rx_desc) 84 + { 85 + return rx_ring->netdev; 86 + } 84 87 #endif /* CONFIG_ICE_SWITCHDEV */ 85 88 #endif /* _ICE_ESWITCH_H_ */
+38 -15
drivers/net/ethernet/intel/ice/ice_lag.c
··· 202 202 * @act: rule action 203 203 * @recipe_id: recipe id for the new rule 204 204 * @rule_idx: pointer to rule index 205 + * @direction: ICE_FLTR_RX or ICE_FLTR_TX 205 206 * @add: boolean on whether we are adding filters 206 207 */ 207 208 static int 208 209 ice_lag_cfg_fltr(struct ice_lag *lag, u32 act, u16 recipe_id, u16 *rule_idx, 209 - bool add) 210 + u8 direction, bool add) 210 211 { 211 212 struct ice_sw_rule_lkup_rx_tx *s_rule; 212 213 u16 s_rule_sz, vsi_num; ··· 232 231 233 232 act |= FIELD_PREP(ICE_SINGLE_ACT_VSI_ID_M, vsi_num); 234 233 235 - s_rule->hdr.type = cpu_to_le16(ICE_AQC_SW_RULES_T_LKUP_RX); 236 234 s_rule->recipe_id = cpu_to_le16(recipe_id); 237 - s_rule->src = cpu_to_le16(hw->port_info->lport); 235 + if (direction == ICE_FLTR_RX) { 236 + s_rule->hdr.type = 237 + cpu_to_le16(ICE_AQC_SW_RULES_T_LKUP_RX); 238 + s_rule->src = cpu_to_le16(hw->port_info->lport); 239 + } else { 240 + s_rule->hdr.type = 241 + cpu_to_le16(ICE_AQC_SW_RULES_T_LKUP_TX); 242 + s_rule->src = cpu_to_le16(vsi_num); 243 + } 238 244 s_rule->act = cpu_to_le32(act); 239 245 s_rule->hdr_len = cpu_to_le16(DUMMY_ETH_HDR_LEN); 240 246 opc = ice_aqc_opc_add_sw_rules; ··· 274 266 { 275 267 u32 act = ICE_SINGLE_ACT_VSI_FORWARDING | 276 268 ICE_SINGLE_ACT_VALID_BIT | ICE_SINGLE_ACT_LAN_ENABLE; 269 + int err; 277 270 278 - return ice_lag_cfg_fltr(lag, act, lag->pf_recipe, 279 - &lag->pf_rule_id, add); 271 + err = ice_lag_cfg_fltr(lag, act, lag->pf_recipe, &lag->pf_rx_rule_id, 272 + ICE_FLTR_RX, add); 273 + if (err) 274 + goto err_rx; 275 + 276 + act = ICE_SINGLE_ACT_VSI_FORWARDING | ICE_SINGLE_ACT_VALID_BIT | 277 + ICE_SINGLE_ACT_LB_ENABLE; 278 + err = ice_lag_cfg_fltr(lag, act, lag->pf_recipe, &lag->pf_tx_rule_id, 279 + ICE_FLTR_TX, add); 280 + if (err) 281 + goto err_tx; 282 + 283 + return 0; 284 + 285 + err_tx: 286 + ice_lag_cfg_fltr(lag, act, lag->pf_recipe, &lag->pf_rx_rule_id, 287 + ICE_FLTR_RX, !add); 288 + err_rx: 289 + return err; 280 290 } 281 291 282 292 /** ··· 310 284 ICE_SINGLE_ACT_DROP; 311 285 312 286 return ice_lag_cfg_fltr(lag, act, lag->lport_recipe, 313 - &lag->lport_rule_idx, add); 287 + &lag->lport_rule_idx, ICE_FLTR_RX, add); 314 288 } 315 289 316 290 /** ··· 336 310 dev = ice_pf_to_dev(lag->pf); 337 311 338 312 /* interface not active - remove old default VSI rule */ 339 - if (bonding_info->slave.state && lag->pf_rule_id) { 313 + if (bonding_info->slave.state && lag->pf_rx_rule_id) { 340 314 if (ice_lag_cfg_dflt_fltr(lag, false)) 341 315 dev_err(dev, "Error removing old default VSI filter\n"); 342 316 if (ice_lag_cfg_drop_fltr(lag, true)) ··· 345 319 } 346 320 347 321 /* interface becoming active - add new default VSI rule */ 348 - if (!bonding_info->slave.state && !lag->pf_rule_id) { 322 + if (!bonding_info->slave.state && !lag->pf_rx_rule_id) { 349 323 if (ice_lag_cfg_dflt_fltr(lag, true)) 350 324 dev_err(dev, "Error adding new default VSI filter\n"); 351 325 if (lag->lport_rule_idx && ice_lag_cfg_drop_fltr(lag, false)) ··· 740 714 741 715 pf = lag->pf; 742 716 ice_for_each_vsi(pf, i) 743 - if (pf->vsi[i] && (pf->vsi[i]->type == ICE_VSI_VF || 744 - pf->vsi[i]->type == ICE_VSI_SWITCHDEV_CTRL)) 717 + if (pf->vsi[i] && pf->vsi[i]->type == ICE_VSI_VF) 745 718 ice_lag_move_single_vf_nodes(lag, oldport, newport, i); 746 719 } 747 720 ··· 978 953 979 954 pf = lag->pf; 980 955 ice_for_each_vsi(pf, i) 981 - if (pf->vsi[i] && (pf->vsi[i]->type == ICE_VSI_VF || 982 - pf->vsi[i]->type == ICE_VSI_SWITCHDEV_CTRL)) 956 + if (pf->vsi[i] && pf->vsi[i]->type == ICE_VSI_VF) 983 957 ice_for_each_traffic_class(tc) 984 958 ice_lag_reclaim_vf_tc(lag, src_hw, i, tc); 985 959 } ··· 2000 1976 2001 1977 pf = lag->pf; 2002 1978 ice_for_each_vsi(pf, i) 2003 - if (pf->vsi[i] && (pf->vsi[i]->type == ICE_VSI_VF || 2004 - pf->vsi[i]->type == ICE_VSI_SWITCHDEV_CTRL)) 1979 + if (pf->vsi[i] && pf->vsi[i]->type == ICE_VSI_VF) 2005 1980 ice_for_each_traffic_class(tc) 2006 1981 ice_lag_move_vf_nodes_tc_sync(lag, dest_hw, i, 2007 1982 tc); ··· 2172 2149 2173 2150 ice_lag_cfg_cp_fltr(lag, true); 2174 2151 2175 - if (lag->pf_rule_id) 2152 + if (lag->pf_rx_rule_id) 2176 2153 if (ice_lag_cfg_dflt_fltr(lag, true)) 2177 2154 dev_err(ice_pf_to_dev(pf), "Error adding default VSI rule in rebuild\n"); 2178 2155
+2 -1
drivers/net/ethernet/intel/ice/ice_lag.h
··· 43 43 u8 primary:1; /* this is primary */ 44 44 u16 pf_recipe; 45 45 u16 lport_recipe; 46 - u16 pf_rule_id; 46 + u16 pf_rx_rule_id; 47 + u16 pf_tx_rule_id; 47 48 u16 cp_rule_idx; 48 49 u16 lport_rule_idx; 49 50 u8 role;
+1 -48
drivers/net/ethernet/intel/ice/ice_lib.c
··· 27 27 return "ICE_VSI_CHNL"; 28 28 case ICE_VSI_LB: 29 29 return "ICE_VSI_LB"; 30 - case ICE_VSI_SWITCHDEV_CTRL: 31 - return "ICE_VSI_SWITCHDEV_CTRL"; 32 30 default: 33 31 return "unknown"; 34 32 } ··· 142 144 { 143 145 switch (vsi->type) { 144 146 case ICE_VSI_PF: 145 - case ICE_VSI_SWITCHDEV_CTRL: 146 147 case ICE_VSI_CTRL: 147 148 case ICE_VSI_LB: 148 149 /* a user could change the values of num_[tr]x_desc using ··· 207 210 vsi->num_q_vectors = min_t(int, pf->num_lan_msix, 208 211 max_t(int, vsi->alloc_rxq, 209 212 vsi->alloc_txq)); 210 - break; 211 - case ICE_VSI_SWITCHDEV_CTRL: 212 - /* The number of queues for ctrl VSI is equal to number of PRs 213 - * Each ring is associated to the corresponding VF_PR netdev. 214 - * Tx and Rx rings are always equal 215 - */ 216 - if (vsi->req_txq && vsi->req_rxq) { 217 - vsi->alloc_txq = vsi->req_txq; 218 - vsi->alloc_rxq = vsi->req_rxq; 219 - } else { 220 - vsi->alloc_txq = 1; 221 - vsi->alloc_rxq = 1; 222 - } 223 - 224 - vsi->num_q_vectors = 1; 225 213 break; 226 214 case ICE_VSI_VF: 227 215 if (vf->num_req_qs) ··· 504 522 return IRQ_HANDLED; 505 523 } 506 524 507 - static irqreturn_t ice_eswitch_msix_clean_rings(int __always_unused irq, void *data) 508 - { 509 - struct ice_q_vector *q_vector = (struct ice_q_vector *)data; 510 - struct ice_pf *pf = q_vector->vsi->back; 511 - struct ice_repr *repr; 512 - unsigned long id; 513 - 514 - if (!q_vector->tx.tx_ring && !q_vector->rx.rx_ring) 515 - return IRQ_HANDLED; 516 - 517 - xa_for_each(&pf->eswitch.reprs, id, repr) 518 - napi_schedule(&repr->q_vector->napi); 519 - 520 - return IRQ_HANDLED; 521 - } 522 - 523 525 /** 524 526 * ice_vsi_alloc_stat_arrays - Allocate statistics arrays 525 527 * @vsi: VSI pointer ··· 566 600 } 567 601 568 602 switch (vsi->type) { 569 - case ICE_VSI_SWITCHDEV_CTRL: 570 - /* Setup eswitch MSIX irq handler for VSI */ 571 - vsi->irq_handler = ice_eswitch_msix_clean_rings; 572 - break; 573 603 case ICE_VSI_PF: 574 604 /* Setup default MSIX irq handler for VSI */ 575 605 vsi->irq_handler = ice_msix_clean_rings; ··· 895 933 max_rss_size); 896 934 vsi->rss_lut_type = ICE_LUT_PF; 897 935 break; 898 - case ICE_VSI_SWITCHDEV_CTRL: 899 - vsi->rss_table_size = ICE_LUT_VSI_SIZE; 900 - vsi->rss_size = min_t(u16, num_online_cpus(), max_rss_size); 901 - vsi->rss_lut_type = ICE_LUT_VSI; 902 - break; 903 936 case ICE_VSI_VF: 904 937 /* VF VSI will get a small RSS table. 905 938 * For VSI_LUT, LUT size should be set to 64 bytes. ··· 1220 1263 case ICE_VSI_PF: 1221 1264 ctxt->flags = ICE_AQ_VSI_TYPE_PF; 1222 1265 break; 1223 - case ICE_VSI_SWITCHDEV_CTRL: 1224 1266 case ICE_VSI_CHNL: 1225 1267 ctxt->flags = ICE_AQ_VSI_TYPE_VMDQ2; 1226 1268 break; ··· 2101 2145 case ICE_VSI_CHNL: 2102 2146 case ICE_VSI_LB: 2103 2147 case ICE_VSI_PF: 2104 - case ICE_VSI_SWITCHDEV_CTRL: 2105 2148 max_agg_nodes = ICE_MAX_PF_AGG_NODES; 2106 2149 agg_node_id_start = ICE_PF_AGG_NODE_ID_START; 2107 2150 agg_node_iter = &pf->pf_agg_node[0]; ··· 2272 2317 2273 2318 switch (vsi->type) { 2274 2319 case ICE_VSI_CTRL: 2275 - case ICE_VSI_SWITCHDEV_CTRL: 2276 2320 case ICE_VSI_PF: 2277 2321 ret = ice_vsi_alloc_q_vectors(vsi); 2278 2322 if (ret) ··· 2704 2750 } else { 2705 2751 ice_vsi_close(vsi); 2706 2752 } 2707 - } else if (vsi->type == ICE_VSI_CTRL || 2708 - vsi->type == ICE_VSI_SWITCHDEV_CTRL) { 2753 + } else if (vsi->type == ICE_VSI_CTRL) { 2709 2754 ice_vsi_close(vsi); 2710 2755 } 2711 2756 }
+2 -8
drivers/net/ethernet/intel/ice/ice_main.c
··· 7055 7055 7056 7056 WARN_ON(!test_bit(ICE_VSI_DOWN, vsi->state)); 7057 7057 7058 - if (vsi->netdev && vsi->type == ICE_VSI_PF) { 7058 + if (vsi->netdev) { 7059 7059 vlan_err = ice_vsi_del_vlan_zero(vsi); 7060 7060 ice_ptp_link_change(vsi->back, vsi->back->hw.pf_id, false); 7061 7061 netif_carrier_off(vsi->netdev); 7062 7062 netif_tx_disable(vsi->netdev); 7063 - } else if (vsi->type == ICE_VSI_SWITCHDEV_CTRL) { 7064 - ice_eswitch_stop_all_tx_queues(vsi->back); 7065 7063 } 7066 7064 7067 7065 ice_vsi_dis_irq(vsi); ··· 7542 7544 goto err_vsi_rebuild; 7543 7545 } 7544 7546 7545 - err = ice_eswitch_rebuild(pf); 7546 - if (err) { 7547 - dev_err(dev, "Switchdev rebuild failed: %d\n", err); 7548 - goto err_vsi_rebuild; 7549 - } 7547 + ice_eswitch_rebuild(pf); 7550 7548 7551 7549 if (reset_type == ICE_RESET_PFR) { 7552 7550 err = ice_rebuild_channels(pf);
+72 -48
drivers/net/ethernet/intel/ice/ice_repr.c
··· 42 42 } 43 43 44 44 /** 45 + * ice_repr_inc_tx_stats - increment Tx statistic by one packet 46 + * @repr: repr to increment stats on 47 + * @len: length of the packet 48 + * @xmit_status: value returned by xmit function 49 + */ 50 + void ice_repr_inc_tx_stats(struct ice_repr *repr, unsigned int len, 51 + int xmit_status) 52 + { 53 + struct ice_repr_pcpu_stats *stats; 54 + 55 + if (unlikely(xmit_status != NET_XMIT_SUCCESS && 56 + xmit_status != NET_XMIT_CN)) { 57 + this_cpu_inc(repr->stats->tx_drops); 58 + return; 59 + } 60 + 61 + stats = this_cpu_ptr(repr->stats); 62 + u64_stats_update_begin(&stats->syncp); 63 + stats->tx_packets++; 64 + stats->tx_bytes += len; 65 + u64_stats_update_end(&stats->syncp); 66 + } 67 + 68 + /** 69 + * ice_repr_inc_rx_stats - increment Rx statistic by one packet 70 + * @netdev: repr netdev to increment stats on 71 + * @len: length of the packet 72 + */ 73 + void ice_repr_inc_rx_stats(struct net_device *netdev, unsigned int len) 74 + { 75 + struct ice_repr *repr = ice_netdev_to_repr(netdev); 76 + struct ice_repr_pcpu_stats *stats; 77 + 78 + stats = this_cpu_ptr(repr->stats); 79 + u64_stats_update_begin(&stats->syncp); 80 + stats->rx_packets++; 81 + stats->rx_bytes += len; 82 + u64_stats_update_end(&stats->syncp); 83 + } 84 + 85 + /** 45 86 * ice_repr_get_stats64 - get VF stats for VFPR use 46 87 * @netdev: pointer to port representor netdev 47 88 * @stats: pointer to struct where stats can be stored ··· 117 76 * ice_netdev_to_repr - Get port representor for given netdevice 118 77 * @netdev: pointer to port representor netdev 119 78 */ 120 - struct ice_repr *ice_netdev_to_repr(struct net_device *netdev) 79 + struct ice_repr *ice_netdev_to_repr(const struct net_device *netdev) 121 80 { 122 81 struct ice_netdev_priv *np = netdev_priv(netdev); 123 82 ··· 180 139 * ice_repr_sp_stats64 - get slow path stats for port representor 181 140 * @dev: network interface device structure 182 141 * @stats: netlink stats structure 183 - * 184 - * RX/TX stats are being swapped here to be consistent with VF stats. In slow 185 - * path, port representor receives data when the corresponding VF is sending it 186 - * (and vice versa), TX and RX bytes/packets are effectively swapped on port 187 - * representor. 188 142 */ 189 143 static int 190 144 ice_repr_sp_stats64(const struct net_device *dev, 191 145 struct rtnl_link_stats64 *stats) 192 146 { 193 - struct ice_netdev_priv *np = netdev_priv(dev); 194 - int vf_id = np->repr->vf->vf_id; 195 - struct ice_tx_ring *tx_ring; 196 - struct ice_rx_ring *rx_ring; 197 - u64 pkts, bytes; 147 + struct ice_repr *repr = ice_netdev_to_repr(dev); 148 + int i; 198 149 199 - tx_ring = np->vsi->tx_rings[vf_id]; 200 - ice_fetch_u64_stats_per_ring(&tx_ring->ring_stats->syncp, 201 - tx_ring->ring_stats->stats, 202 - &pkts, &bytes); 203 - stats->rx_packets = pkts; 204 - stats->rx_bytes = bytes; 150 + for_each_possible_cpu(i) { 151 + u64 tbytes, tpkts, tdrops, rbytes, rpkts; 152 + struct ice_repr_pcpu_stats *repr_stats; 153 + unsigned int start; 205 154 206 - rx_ring = np->vsi->rx_rings[vf_id]; 207 - ice_fetch_u64_stats_per_ring(&rx_ring->ring_stats->syncp, 208 - rx_ring->ring_stats->stats, 209 - &pkts, &bytes); 210 - stats->tx_packets = pkts; 211 - stats->tx_bytes = bytes; 212 - stats->tx_dropped = rx_ring->ring_stats->rx_stats.alloc_page_failed + 213 - rx_ring->ring_stats->rx_stats.alloc_buf_failed; 155 + repr_stats = per_cpu_ptr(repr->stats, i); 156 + do { 157 + start = u64_stats_fetch_begin(&repr_stats->syncp); 158 + tbytes = repr_stats->tx_bytes; 159 + tpkts = repr_stats->tx_packets; 160 + tdrops = repr_stats->tx_drops; 161 + rbytes = repr_stats->rx_bytes; 162 + rpkts = repr_stats->rx_packets; 163 + } while (u64_stats_fetch_retry(&repr_stats->syncp, start)); 214 164 165 + stats->tx_bytes += tbytes; 166 + stats->tx_packets += tpkts; 167 + stats->tx_dropped += tdrops; 168 + stats->rx_bytes += rbytes; 169 + stats->rx_packets += rpkts; 170 + } 215 171 return 0; 216 172 } 217 173 ··· 329 291 */ 330 292 static void ice_repr_rem(struct ice_repr *repr) 331 293 { 332 - kfree(repr->q_vector); 294 + free_percpu(repr->stats); 333 295 free_netdev(repr->netdev); 334 296 kfree(repr); 335 297 } ··· 369 331 static struct ice_repr * 370 332 ice_repr_add(struct ice_pf *pf, struct ice_vsi *src_vsi, const u8 *parent_mac) 371 333 { 372 - struct ice_q_vector *q_vector; 373 334 struct ice_netdev_priv *np; 374 335 struct ice_repr *repr; 375 336 int err; ··· 383 346 goto err_alloc; 384 347 } 385 348 349 + repr->stats = netdev_alloc_pcpu_stats(struct ice_repr_pcpu_stats); 350 + if (!repr->stats) { 351 + err = -ENOMEM; 352 + goto err_stats; 353 + } 354 + 386 355 repr->src_vsi = src_vsi; 356 + repr->id = src_vsi->vsi_num; 387 357 np = netdev_priv(repr->netdev); 388 358 np->repr = repr; 389 - 390 - q_vector = kzalloc(sizeof(*q_vector), GFP_KERNEL); 391 - if (!q_vector) { 392 - err = -ENOMEM; 393 - goto err_alloc_q_vector; 394 - } 395 - repr->q_vector = q_vector; 396 - repr->q_id = repr->id; 397 359 398 360 ether_addr_copy(repr->parent_mac, parent_mac); 399 361 400 362 return repr; 401 363 402 - err_alloc_q_vector: 364 + err_stats: 403 365 free_netdev(repr->netdev); 404 366 err_alloc: 405 367 kfree(repr); ··· 474 438 { 475 439 netif_carrier_off(repr->netdev); 476 440 netif_tx_stop_all_queues(repr->netdev); 477 - } 478 - 479 - /** 480 - * ice_repr_set_traffic_vsi - set traffic VSI for port representor 481 - * @repr: repr on with VSI will be set 482 - * @vsi: pointer to VSI that will be used by port representor to pass traffic 483 - */ 484 - void ice_repr_set_traffic_vsi(struct ice_repr *repr, struct ice_vsi *vsi) 485 - { 486 - struct ice_netdev_priv *np = netdev_priv(repr->netdev); 487 - 488 - np->vsi = vsi; 489 441 }
+15 -9
drivers/net/ethernet/intel/ice/ice_repr.h
··· 6 6 7 7 #include <net/dst_metadata.h> 8 8 9 + struct ice_repr_pcpu_stats { 10 + struct u64_stats_sync syncp; 11 + u64 rx_packets; 12 + u64 rx_bytes; 13 + u64 tx_packets; 14 + u64 tx_bytes; 15 + u64 tx_drops; 16 + }; 17 + 9 18 struct ice_repr { 10 19 struct ice_vsi *src_vsi; 11 20 struct ice_vf *vf; 12 - struct ice_q_vector *q_vector; 13 21 struct net_device *netdev; 14 22 struct metadata_dst *dst; 15 23 struct ice_esw_br_port *br_port; 16 - int q_id; 24 + struct ice_repr_pcpu_stats __percpu *stats; 17 25 u32 id; 18 26 u8 parent_mac[ETH_ALEN]; 19 - #ifdef CONFIG_ICE_SWITCHDEV 20 - /* info about slow path rule */ 21 - struct ice_rule_query_data sp_rule; 22 - #endif 23 27 }; 24 28 25 29 struct ice_repr *ice_repr_add_vf(struct ice_vf *vf); ··· 32 28 void ice_repr_start_tx_queues(struct ice_repr *repr); 33 29 void ice_repr_stop_tx_queues(struct ice_repr *repr); 34 30 35 - void ice_repr_set_traffic_vsi(struct ice_repr *repr, struct ice_vsi *vsi); 36 - 37 - struct ice_repr *ice_netdev_to_repr(struct net_device *netdev); 31 + struct ice_repr *ice_netdev_to_repr(const struct net_device *netdev); 38 32 bool ice_is_port_repr_netdev(const struct net_device *netdev); 39 33 40 34 struct ice_repr *ice_repr_get_by_vsi(struct ice_vsi *vsi); 35 + 36 + void ice_repr_inc_tx_stats(struct ice_repr *repr, unsigned int len, 37 + int xmit_status); 38 + void ice_repr_inc_rx_stats(struct net_device *netdev, unsigned int len); 41 39 #endif
-3
drivers/net/ethernet/intel/ice/ice_sriov.c
··· 170 170 else 171 171 dev_warn(dev, "VFs are assigned - not disabling SR-IOV\n"); 172 172 173 - ice_eswitch_reserve_cp_queues(pf, -ice_get_num_vfs(pf)); 174 - 175 173 mutex_lock(&vfs->table_lock); 176 174 177 175 ice_for_each_vf(pf, bkt, vf) { ··· 895 897 goto err_unroll_sriov; 896 898 } 897 899 898 - ice_eswitch_reserve_cp_queues(pf, num_vfs); 899 900 ret = ice_start_vfs(pf); 900 901 if (ret) { 901 902 dev_err(dev, "Failed to start %d VFs, err %d\n", num_vfs, ret);
+4
drivers/net/ethernet/intel/ice/ice_switch.c
··· 2446 2446 fi->lan_en = true; 2447 2447 } 2448 2448 } 2449 + 2450 + if (fi->flag & ICE_FLTR_TX_ONLY) 2451 + fi->lan_en = false; 2449 2452 } 2450 2453 2451 2454 /** ··· 3824 3821 } else if (f_info.flag & ICE_FLTR_TX) { 3825 3822 f_info.src_id = ICE_SRC_ID_VSI; 3826 3823 f_info.src = hw_vsi_id; 3824 + f_info.flag |= ICE_FLTR_TX_ONLY; 3827 3825 } 3828 3826 f_list_entry.fltr_info = f_info; 3829 3827
+3 -2
drivers/net/ethernet/intel/ice/ice_switch.h
··· 8 8 9 9 #define ICE_SW_CFG_MAX_BUF_LEN 2048 10 10 #define ICE_DFLT_VSI_INVAL 0xff 11 - #define ICE_FLTR_RX BIT(0) 12 - #define ICE_FLTR_TX BIT(1) 11 + #define ICE_FLTR_RX BIT(0) 12 + #define ICE_FLTR_TX BIT(1) 13 + #define ICE_FLTR_TX_ONLY BIT(2) 13 14 #define ICE_VSI_INVAL_ID 0xffff 14 15 #define ICE_INVAL_Q_HANDLE 0xFFFF 15 16
+1
drivers/net/ethernet/intel/ice/ice_txrx.h
··· 365 365 u8 ptp_rx; 366 366 #define ICE_RX_FLAGS_RING_BUILD_SKB BIT(1) 367 367 #define ICE_RX_FLAGS_CRC_STRIP_DIS BIT(2) 368 + #define ICE_RX_FLAGS_MULTIDEV BIT(3) 368 369 u8 flags; 369 370 /* CL5 - 5th cacheline starts here */ 370 371 struct xdp_rxq_info xdp_rxq;
+10 -1
drivers/net/ethernet/intel/ice/ice_txrx_lib.c
··· 236 236 ice_rx_hash_to_skb(rx_ring, rx_desc, skb, ptype); 237 237 238 238 /* 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 + if (ice_is_port_repr_netdev(netdev)) 244 + ice_repr_inc_rx_stats(netdev, skb->len); 245 + skb->protocol = eth_type_trans(skb, netdev); 246 + } else { 247 + skb->protocol = eth_type_trans(skb, rx_ring->netdev); 248 + } 240 249 241 250 ice_rx_csum(rx_ring, skb, rx_desc, ptype); 242 251
-1
drivers/net/ethernet/intel/ice/ice_type.h
··· 150 150 ICE_VSI_CTRL = 3, /* equates to ICE_VSI_PF with 1 queue pair */ 151 151 ICE_VSI_CHNL = 4, 152 152 ICE_VSI_LB = 6, 153 - ICE_VSI_SWITCHDEV_CTRL = 7, 154 153 }; 155 154 156 155 struct ice_link_status {
-1
drivers/net/ethernet/intel/ice/ice_vsi_vlan_ops.c
··· 72 72 73 73 switch (vsi->type) { 74 74 case ICE_VSI_PF: 75 - case ICE_VSI_SWITCHDEV_CTRL: 76 75 ice_pf_vsi_init_vlan_ops(vsi); 77 76 break; 78 77 case ICE_VSI_VF: