Skip to content

Commit e4a3d6a

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-01-06 Victor adds restoring of advanced rules after reset. Wojciech improves usage of switchdev control VSI by utilizing the device's advanced rules for forwarding. Christophe Jaillet removes some unneeded calls to zero bitmaps, changes some bitmap operations that don't need to be atomic, and converts a kfree() to a more appropriate bitmap_free(). * '100GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/next-queue: ice: Use bitmap_free() to free bitmap ice: Optimize a few bitmap operations ice: Slightly simply ice_find_free_recp_res_idx ice: improve switchdev's slow-path ice: replay advanced rules after reset ==================== Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents 8947c39 + 0dbc416 commit e4a3d6a

File tree

13 files changed

+263
-180
lines changed

13 files changed

+263
-180
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4603,7 +4603,7 @@ static int ice_replay_pre_init(struct ice_hw *hw)
46034603
* will allow adding rules entries back to filt_rules list,
46044604
* which is operational list.
46054605
*/
4606-
for (i = 0; i < ICE_SW_LKUP_LAST; i++)
4606+
for (i = 0; i < ICE_MAX_NUM_RECIPES; i++)
46074607
list_replace_init(&sw->recp_list[i].filt_rules,
46084608
&sw->recp_list[i].filt_replay_rules);
46094609
ice_sched_replay_agg_vsi_preinit(hw);

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

Lines changed: 95 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,100 @@
99
#include "ice_devlink.h"
1010
#include "ice_tc_lib.h"
1111

12+
/**
13+
* ice_eswitch_add_vf_mac_rule - add adv rule with VF's MAC
14+
* @pf: pointer to PF struct
15+
* @vf: pointer to VF struct
16+
* @mac: VF's MAC address
17+
*
18+
* This function adds advanced rule that forwards packets with
19+
* VF's MAC address (src MAC) to the corresponding switchdev ctrl VSI queue.
20+
*/
21+
int
22+
ice_eswitch_add_vf_mac_rule(struct ice_pf *pf, struct ice_vf *vf, const u8 *mac)
23+
{
24+
struct ice_vsi *ctrl_vsi = pf->switchdev.control_vsi;
25+
struct ice_adv_rule_info rule_info = { 0 };
26+
struct ice_adv_lkup_elem *list;
27+
struct ice_hw *hw = &pf->hw;
28+
const u16 lkups_cnt = 1;
29+
int err;
30+
31+
list = kcalloc(lkups_cnt, sizeof(*list), GFP_ATOMIC);
32+
if (!list)
33+
return -ENOMEM;
34+
35+
list[0].type = ICE_MAC_OFOS;
36+
ether_addr_copy(list[0].h_u.eth_hdr.src_addr, mac);
37+
eth_broadcast_addr(list[0].m_u.eth_hdr.src_addr);
38+
39+
rule_info.sw_act.flag |= ICE_FLTR_TX;
40+
rule_info.sw_act.vsi_handle = ctrl_vsi->idx;
41+
rule_info.sw_act.fltr_act = ICE_FWD_TO_Q;
42+
rule_info.rx = false;
43+
rule_info.sw_act.fwd_id.q_id = hw->func_caps.common_cap.rxq_first_id +
44+
ctrl_vsi->rxq_map[vf->vf_id];
45+
rule_info.flags_info.act |= ICE_SINGLE_ACT_LB_ENABLE;
46+
rule_info.flags_info.act_valid = true;
47+
48+
err = ice_add_adv_rule(hw, list, lkups_cnt, &rule_info,
49+
vf->repr->mac_rule);
50+
if (err)
51+
dev_err(ice_pf_to_dev(pf), "Unable to add VF mac rule in switchdev mode for VF %d",
52+
vf->vf_id);
53+
else
54+
vf->repr->rule_added = true;
55+
56+
kfree(list);
57+
return err;
58+
}
59+
60+
/**
61+
* ice_eswitch_replay_vf_mac_rule - replay adv rule with VF's MAC
62+
* @vf: pointer to vF struct
63+
*
64+
* This function replays VF's MAC rule after reset.
65+
*/
66+
void ice_eswitch_replay_vf_mac_rule(struct ice_vf *vf)
67+
{
68+
int err;
69+
70+
if (!ice_is_switchdev_running(vf->pf))
71+
return;
72+
73+
if (is_valid_ether_addr(vf->hw_lan_addr.addr)) {
74+
err = ice_eswitch_add_vf_mac_rule(vf->pf, vf,
75+
vf->hw_lan_addr.addr);
76+
if (err) {
77+
dev_err(ice_pf_to_dev(vf->pf), "Failed to add MAC %pM for VF %d\n, error %d\n",
78+
vf->hw_lan_addr.addr, vf->vf_id, err);
79+
return;
80+
}
81+
vf->num_mac++;
82+
83+
ether_addr_copy(vf->dev_lan_addr.addr, vf->hw_lan_addr.addr);
84+
}
85+
}
86+
87+
/**
88+
* ice_eswitch_del_vf_mac_rule - delete adv rule with VF's MAC
89+
* @vf: pointer to the VF struct
90+
*
91+
* Delete the advanced rule that was used to forward packets with the VF's MAC
92+
* address (src MAC) to the corresponding switchdev ctrl VSI queue.
93+
*/
94+
void ice_eswitch_del_vf_mac_rule(struct ice_vf *vf)
95+
{
96+
if (!ice_is_switchdev_running(vf->pf))
97+
return;
98+
99+
if (!vf->repr->rule_added)
100+
return;
101+
102+
ice_rem_adv_rule_by_id(&vf->pf->hw, vf->repr->mac_rule);
103+
vf->repr->rule_added = false;
104+
}
105+
12106
/**
13107
* ice_eswitch_setup_env - configure switchdev HW filters
14108
* @pf: pointer to PF struct
@@ -21,7 +115,6 @@ static int ice_eswitch_setup_env(struct ice_pf *pf)
21115
struct ice_vsi *uplink_vsi = pf->switchdev.uplink_vsi;
22116
struct net_device *uplink_netdev = uplink_vsi->netdev;
23117
struct ice_vsi *ctrl_vsi = pf->switchdev.control_vsi;
24-
struct ice_port_info *pi = pf->hw.port_info;
25118
bool rule_added = false;
26119

27120
ice_vsi_manage_vlan_stripping(ctrl_vsi, false);
@@ -42,29 +135,17 @@ static int ice_eswitch_setup_env(struct ice_pf *pf)
42135
rule_added = true;
43136
}
44137

45-
if (ice_cfg_dflt_vsi(pi->hw, ctrl_vsi->idx, true, ICE_FLTR_TX))
46-
goto err_def_tx;
47-
48138
if (ice_vsi_update_security(uplink_vsi, ice_vsi_ctx_set_allow_override))
49139
goto err_override_uplink;
50140

51141
if (ice_vsi_update_security(ctrl_vsi, ice_vsi_ctx_set_allow_override))
52142
goto err_override_control;
53143

54-
if (ice_fltr_update_flags_dflt_rule(ctrl_vsi, pi->dflt_tx_vsi_rule_id,
55-
ICE_FLTR_TX,
56-
ICE_SINGLE_ACT_LB_ENABLE))
57-
goto err_update_action;
58-
59144
return 0;
60145

61-
err_update_action:
62-
ice_vsi_update_security(ctrl_vsi, ice_vsi_ctx_clear_allow_override);
63146
err_override_control:
64147
ice_vsi_update_security(uplink_vsi, ice_vsi_ctx_clear_allow_override);
65148
err_override_uplink:
66-
ice_cfg_dflt_vsi(pi->hw, ctrl_vsi->idx, false, ICE_FLTR_TX);
67-
err_def_tx:
68149
if (rule_added)
69150
ice_clear_dflt_vsi(uplink_vsi->vsw);
70151
err_def_rx:
@@ -167,21 +248,11 @@ static int ice_eswitch_setup_reprs(struct ice_pf *pf)
167248
netif_keep_dst(vf->repr->netdev);
168249
}
169250

170-
kfree(ctrl_vsi->target_netdevs);
171-
172-
ctrl_vsi->target_netdevs = kcalloc(max_vsi_num + 1,
173-
sizeof(*ctrl_vsi->target_netdevs),
174-
GFP_KERNEL);
175-
if (!ctrl_vsi->target_netdevs)
176-
goto err;
177-
178251
ice_for_each_vf(pf, i) {
179252
struct ice_repr *repr = pf->vf[i].repr;
180253
struct ice_vsi *vsi = repr->src_vsi;
181254
struct metadata_dst *dst;
182255

183-
ctrl_vsi->target_netdevs[vsi->vsi_num] = repr->netdev;
184-
185256
dst = repr->dst;
186257
dst->u.port_info.port_id = vsi->vsi_num;
187258
dst->u.port_info.lower_dev = repr->netdev;
@@ -214,7 +285,6 @@ ice_eswitch_release_reprs(struct ice_pf *pf, struct ice_vsi *ctrl_vsi)
214285
{
215286
int i;
216287

217-
kfree(ctrl_vsi->target_netdevs);
218288
ice_for_each_vf(pf, i) {
219289
struct ice_vsi *vsi = pf->vf[i].repr->src_vsi;
220290
struct ice_vf *vf = &pf->vf[i];
@@ -320,7 +390,6 @@ static void ice_eswitch_release_env(struct ice_pf *pf)
320390

321391
ice_vsi_update_security(ctrl_vsi, ice_vsi_ctx_clear_allow_override);
322392
ice_vsi_update_security(uplink_vsi, ice_vsi_ctx_clear_allow_override);
323-
ice_cfg_dflt_vsi(&pf->hw, ctrl_vsi->idx, false, ICE_FLTR_TX);
324393
ice_clear_dflt_vsi(uplink_vsi->vsw);
325394
ice_fltr_add_mac_and_broadcast(uplink_vsi,
326395
uplink_vsi->port_info->mac.perm_addr,
@@ -374,24 +443,6 @@ static void ice_eswitch_napi_disable(struct ice_pf *pf)
374443
napi_disable(&pf->vf[i].repr->q_vector->napi);
375444
}
376445

377-
/**
378-
* ice_eswitch_set_rxdid - configure rxdid on all Rx queues from VSI
379-
* @vsi: VSI to setup rxdid on
380-
* @rxdid: flex descriptor id
381-
*/
382-
static void ice_eswitch_set_rxdid(struct ice_vsi *vsi, u32 rxdid)
383-
{
384-
struct ice_hw *hw = &vsi->back->hw;
385-
int i;
386-
387-
ice_for_each_rxq(vsi, i) {
388-
struct ice_rx_ring *ring = vsi->rx_rings[i];
389-
u16 pf_q = vsi->rxq_map[ring->q_index];
390-
391-
ice_write_qrxflxp_cntxt(hw, pf_q, rxdid, 0x3, true);
392-
}
393-
}
394-
395446
/**
396447
* ice_eswitch_enable_switchdev - configure eswitch in switchdev mode
397448
* @pf: pointer to PF structure
@@ -425,8 +476,6 @@ static int ice_eswitch_enable_switchdev(struct ice_pf *pf)
425476

426477
ice_eswitch_napi_enable(pf);
427478

428-
ice_eswitch_set_rxdid(ctrl_vsi, ICE_RXDID_FLEX_NIC_2);
429-
430479
return 0;
431480

432481
err_setup_reprs:
@@ -448,6 +497,7 @@ static void ice_eswitch_disable_switchdev(struct ice_pf *pf)
448497

449498
ice_eswitch_napi_disable(pf);
450499
ice_eswitch_release_env(pf);
500+
ice_rem_adv_rule_for_vsi(&pf->hw, ctrl_vsi->idx);
451501
ice_eswitch_release_reprs(pf, ctrl_vsi);
452502
ice_vsi_release(ctrl_vsi);
453503
ice_repr_rem_from_all_vfs(pf);
@@ -496,34 +546,6 @@ ice_eswitch_mode_set(struct devlink *devlink, u16 mode,
496546
return 0;
497547
}
498548

499-
/**
500-
* ice_eswitch_get_target_netdev - return port representor netdev
501-
* @rx_ring: pointer to Rx ring
502-
* @rx_desc: pointer to Rx descriptor
503-
*
504-
* When working in switchdev mode context (when control VSI is used), this
505-
* function returns netdev of appropriate port representor. For non-switchdev
506-
* context, regular netdev associated with Rx ring is returned.
507-
*/
508-
struct net_device *
509-
ice_eswitch_get_target_netdev(struct ice_rx_ring *rx_ring,
510-
union ice_32b_rx_flex_desc *rx_desc)
511-
{
512-
struct ice_32b_rx_flex_desc_nic_2 *desc;
513-
struct ice_vsi *vsi = rx_ring->vsi;
514-
struct ice_vsi *control_vsi;
515-
u16 target_vsi_id;
516-
517-
control_vsi = vsi->back->switchdev.control_vsi;
518-
if (vsi != control_vsi)
519-
return rx_ring->netdev;
520-
521-
desc = (struct ice_32b_rx_flex_desc_nic_2 *)rx_desc;
522-
target_vsi_id = le16_to_cpu(desc->src_vsi);
523-
524-
return vsi->target_netdevs[target_vsi_id];
525-
}
526-
527549
/**
528550
* ice_eswitch_mode_get - get current eswitch mode
529551
* @devlink: pointer to devlink structure
@@ -648,7 +670,6 @@ int ice_eswitch_rebuild(struct ice_pf *pf)
648670
return status;
649671

650672
ice_eswitch_napi_enable(pf);
651-
ice_eswitch_set_rxdid(ctrl_vsi, ICE_RXDID_FLEX_NIC_2);
652673
ice_eswitch_start_all_tx_queues(pf);
653674

654675
return 0;

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

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@ bool ice_is_eswitch_mode_switchdev(struct ice_pf *pf);
2020
void ice_eswitch_update_repr(struct ice_vsi *vsi);
2121

2222
void ice_eswitch_stop_all_tx_queues(struct ice_pf *pf);
23-
24-
struct net_device *
25-
ice_eswitch_get_target_netdev(struct ice_rx_ring *rx_ring,
26-
union ice_32b_rx_flex_desc *rx_desc);
23+
int
24+
ice_eswitch_add_vf_mac_rule(struct ice_pf *pf, struct ice_vf *vf,
25+
const u8 *mac);
26+
void ice_eswitch_replay_vf_mac_rule(struct ice_vf *vf);
27+
void ice_eswitch_del_vf_mac_rule(struct ice_vf *vf);
2728

2829
void ice_eswitch_set_target_vsi(struct sk_buff *skb,
2930
struct ice_tx_offload_params *off);
@@ -33,6 +34,15 @@ ice_eswitch_port_start_xmit(struct sk_buff *skb, struct net_device *netdev);
3334
static inline void ice_eswitch_release(struct ice_pf *pf) { }
3435

3536
static inline void ice_eswitch_stop_all_tx_queues(struct ice_pf *pf) { }
37+
static inline void ice_eswitch_replay_vf_mac_rule(struct ice_vf *vf) { }
38+
static inline void ice_eswitch_del_vf_mac_rule(struct ice_vf *vf) { }
39+
40+
static inline int
41+
ice_eswitch_add_vf_mac_rule(struct ice_pf *pf, struct ice_vf *vf,
42+
const u8 *mac)
43+
{
44+
return -EOPNOTSUPP;
45+
}
3646

3747
static inline void
3848
ice_eswitch_set_target_vsi(struct sk_buff *skb,
@@ -67,13 +77,6 @@ static inline bool ice_is_eswitch_mode_switchdev(struct ice_pf *pf)
6777
return false;
6878
}
6979

70-
static inline struct net_device *
71-
ice_eswitch_get_target_netdev(struct ice_rx_ring *rx_ring,
72-
union ice_32b_rx_flex_desc *rx_desc)
73-
{
74-
return rx_ring->netdev;
75-
}
76-
7780
static inline netdev_tx_t
7881
ice_eswitch_port_start_xmit(struct sk_buff *skb, struct net_device *netdev)
7982
{

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4440,7 +4440,7 @@ ice_update_fd_swap(struct ice_hw *hw, u16 prof_id, struct ice_fv_word *es)
44404440
for (j = 0; j < ICE_FD_SRC_DST_PAIR_COUNT; j++)
44414441
if (es[i].prot_id == ice_fd_pairs[j].prot_id &&
44424442
es[i].off == ice_fd_pairs[j].off) {
4443-
set_bit(j, pair_list);
4443+
__set_bit(j, pair_list);
44444444
pair_start[j] = i;
44454445
}
44464446
}
@@ -4710,7 +4710,7 @@ ice_add_prof(struct ice_hw *hw, enum ice_block blk, u64 id, u8 ptypes[],
47104710
if (test_bit(ptg, ptgs_used))
47114711
continue;
47124712

4713-
set_bit(ptg, ptgs_used);
4713+
__set_bit(ptg, ptgs_used);
47144714
/* Check to see there are any attributes for
47154715
* this PTYPE, and add them if found.
47164716
*/
@@ -5339,7 +5339,7 @@ ice_adj_prof_priorities(struct ice_hw *hw, enum ice_block blk, u16 vsig,
53395339
}
53405340

53415341
/* keep track of used ptgs */
5342-
set_bit(t->tcam[i].ptg, ptgs_used);
5342+
__set_bit(t->tcam[i].ptg, ptgs_used);
53435343
}
53445344
}
53455345

0 commit comments

Comments
 (0)