Skip to content

Commit c8ff576

Browse files
committed
Merge tag 'mlx5-fixes-2022-02-01' of git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux
Saeed Mahameed says: ==================== mlx5 fixes 2022-02-01 This series provides bug fixes to mlx5 driver. Please pull and let me know if there is any problem. Sorry about the long series, but I had to move the top two patches from net-next to net to help avoiding a build break when kspp branch is merged into linus-next on next merge window. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents 3aa430d + ad51857 commit c8ff576

File tree

17 files changed

+102
-55
lines changed

17 files changed

+102
-55
lines changed

drivers/net/ethernet/mellanox/mlx5/core/en.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ static inline int mlx5e_get_max_num_channels(struct mlx5_core_dev *mdev)
224224
struct mlx5e_tx_wqe {
225225
struct mlx5_wqe_ctrl_seg ctrl;
226226
struct mlx5_wqe_eth_seg eth;
227-
struct mlx5_wqe_data_seg data[0];
227+
struct mlx5_wqe_data_seg data[];
228228
};
229229

230230
struct mlx5e_rx_wqe_ll {
@@ -241,8 +241,8 @@ struct mlx5e_umr_wqe {
241241
struct mlx5_wqe_umr_ctrl_seg uctrl;
242242
struct mlx5_mkey_seg mkc;
243243
union {
244-
struct mlx5_mtt inline_mtts[0];
245-
struct mlx5_klm inline_klms[0];
244+
DECLARE_FLEX_ARRAY(struct mlx5_mtt, inline_mtts);
245+
DECLARE_FLEX_ARRAY(struct mlx5_klm, inline_klms);
246246
};
247247
};
248248

drivers/net/ethernet/mellanox/mlx5/core/en/qos.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,8 @@ static int mlx5e_htb_convert_rate(struct mlx5e_priv *priv, u64 rate,
570570

571571
static void mlx5e_htb_convert_ceil(struct mlx5e_priv *priv, u64 ceil, u32 *max_average_bw)
572572
{
573-
*max_average_bw = div_u64(ceil, BYTES_IN_MBIT);
573+
/* Hardware treats 0 as "unlimited", set at least 1. */
574+
*max_average_bw = max_t(u32, div_u64(ceil, BYTES_IN_MBIT), 1);
574575

575576
qos_dbg(priv->mdev, "Convert: ceil %llu -> max_average_bw %u\n",
576577
ceil, *max_average_bw);

drivers/net/ethernet/mellanox/mlx5/core/en/rep/bond.c

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -183,18 +183,7 @@ void mlx5e_rep_bond_unslave(struct mlx5_eswitch *esw,
183183

184184
static bool mlx5e_rep_is_lag_netdev(struct net_device *netdev)
185185
{
186-
struct mlx5e_rep_priv *rpriv;
187-
struct mlx5e_priv *priv;
188-
189-
/* A given netdev is not a representor or not a slave of LAG configuration */
190-
if (!mlx5e_eswitch_rep(netdev) || !netif_is_lag_port(netdev))
191-
return false;
192-
193-
priv = netdev_priv(netdev);
194-
rpriv = priv->ppriv;
195-
196-
/* Egress acl forward to vport is supported only non-uplink representor */
197-
return rpriv->rep->vport != MLX5_VPORT_UPLINK;
186+
return netif_is_lag_port(netdev) && mlx5e_eswitch_vf_rep(netdev);
198187
}
199188

200189
static void mlx5e_rep_changelowerstate_event(struct net_device *netdev, void *ptr)
@@ -210,9 +199,6 @@ static void mlx5e_rep_changelowerstate_event(struct net_device *netdev, void *pt
210199
u16 fwd_vport_num;
211200
int err;
212201

213-
if (!mlx5e_rep_is_lag_netdev(netdev))
214-
return;
215-
216202
info = ptr;
217203
lag_info = info->lower_state_info;
218204
/* This is not an event of a representor becoming active slave */
@@ -266,9 +252,6 @@ static void mlx5e_rep_changeupper_event(struct net_device *netdev, void *ptr)
266252
struct net_device *lag_dev;
267253
struct mlx5e_priv *priv;
268254

269-
if (!mlx5e_rep_is_lag_netdev(netdev))
270-
return;
271-
272255
priv = netdev_priv(netdev);
273256
rpriv = priv->ppriv;
274257
lag_dev = info->upper_dev;
@@ -293,6 +276,19 @@ static int mlx5e_rep_esw_bond_netevent(struct notifier_block *nb,
293276
unsigned long event, void *ptr)
294277
{
295278
struct net_device *netdev = netdev_notifier_info_to_dev(ptr);
279+
struct mlx5e_rep_priv *rpriv;
280+
struct mlx5e_rep_bond *bond;
281+
struct mlx5e_priv *priv;
282+
283+
if (!mlx5e_rep_is_lag_netdev(netdev))
284+
return NOTIFY_DONE;
285+
286+
bond = container_of(nb, struct mlx5e_rep_bond, nb);
287+
priv = netdev_priv(netdev);
288+
rpriv = mlx5_eswitch_get_uplink_priv(priv->mdev->priv.eswitch, REP_ETH);
289+
/* Verify VF representor is on the same device of the bond handling the netevent. */
290+
if (rpriv->uplink_priv.bond != bond)
291+
return NOTIFY_DONE;
296292

297293
switch (event) {
298294
case NETDEV_CHANGELOWERSTATE:

drivers/net/ethernet/mellanox/mlx5/core/en/rep/bridge.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ void mlx5e_rep_bridge_init(struct mlx5e_priv *priv)
491491
}
492492

493493
br_offloads->netdev_nb.notifier_call = mlx5_esw_bridge_switchdev_port_event;
494-
err = register_netdevice_notifier(&br_offloads->netdev_nb);
494+
err = register_netdevice_notifier_net(&init_net, &br_offloads->netdev_nb);
495495
if (err) {
496496
esw_warn(mdev, "Failed to register bridge offloads netdevice notifier (err=%d)\n",
497497
err);
@@ -509,7 +509,9 @@ void mlx5e_rep_bridge_init(struct mlx5e_priv *priv)
509509
err_register_swdev:
510510
destroy_workqueue(br_offloads->wq);
511511
err_alloc_wq:
512+
rtnl_lock();
512513
mlx5_esw_bridge_cleanup(esw);
514+
rtnl_unlock();
513515
}
514516

515517
void mlx5e_rep_bridge_cleanup(struct mlx5e_priv *priv)
@@ -524,7 +526,7 @@ void mlx5e_rep_bridge_cleanup(struct mlx5e_priv *priv)
524526
return;
525527

526528
cancel_delayed_work_sync(&br_offloads->update_work);
527-
unregister_netdevice_notifier(&br_offloads->netdev_nb);
529+
unregister_netdevice_notifier_net(&init_net, &br_offloads->netdev_nb);
528530
unregister_switchdev_blocking_notifier(&br_offloads->nb_blk);
529531
unregister_switchdev_notifier(&br_offloads->nb);
530532
destroy_workqueue(br_offloads->wq);

drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,11 @@ static inline u16 mlx5e_txqsq_get_next_pi(struct mlx5e_txqsq *sq, u16 size)
167167
return pi;
168168
}
169169

170+
static inline u16 mlx5e_shampo_get_cqe_header_index(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe)
171+
{
172+
return be16_to_cpu(cqe->shampo.header_entry_index) & (rq->mpwqe.shampo->hd_per_wq - 1);
173+
}
174+
170175
struct mlx5e_shampo_umr {
171176
u16 len;
172177
};

drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,8 +341,10 @@ mlx5e_xmit_xdp_frame(struct mlx5e_xdpsq *sq, struct mlx5e_xmit_data *xdptxd,
341341

342342
/* copy the inline part if required */
343343
if (sq->min_inline_mode != MLX5_INLINE_MODE_NONE) {
344-
memcpy(eseg->inline_hdr.start, xdptxd->data, MLX5E_XDP_MIN_INLINE);
344+
memcpy(eseg->inline_hdr.start, xdptxd->data, sizeof(eseg->inline_hdr.start));
345345
eseg->inline_hdr.sz = cpu_to_be16(MLX5E_XDP_MIN_INLINE);
346+
memcpy(dseg, xdptxd->data + sizeof(eseg->inline_hdr.start),
347+
MLX5E_XDP_MIN_INLINE - sizeof(eseg->inline_hdr.start));
346348
dma_len -= MLX5E_XDP_MIN_INLINE;
347349
dma_addr += MLX5E_XDP_MIN_INLINE;
348350
dseg++;

drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_rxtx.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,20 @@ static void mlx5e_ipsec_set_swp(struct sk_buff *skb,
157157
/* Tunnel mode */
158158
if (mode == XFRM_MODE_TUNNEL) {
159159
eseg->swp_inner_l3_offset = skb_inner_network_offset(skb) / 2;
160-
eseg->swp_inner_l4_offset = skb_inner_transport_offset(skb) / 2;
161160
if (xo->proto == IPPROTO_IPV6)
162161
eseg->swp_flags |= MLX5_ETH_WQE_SWP_INNER_L3_IPV6;
163-
if (inner_ip_hdr(skb)->protocol == IPPROTO_UDP)
162+
163+
switch (xo->inner_ipproto) {
164+
case IPPROTO_UDP:
164165
eseg->swp_flags |= MLX5_ETH_WQE_SWP_INNER_L4_UDP;
166+
fallthrough;
167+
case IPPROTO_TCP:
168+
/* IP | ESP | IP | [TCP | UDP] */
169+
eseg->swp_inner_l4_offset = skb_inner_transport_offset(skb) / 2;
170+
break;
171+
default:
172+
break;
173+
}
165174
return;
166175
}
167176

drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_rxtx.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,14 +131,17 @@ static inline bool
131131
mlx5e_ipsec_txwqe_build_eseg_csum(struct mlx5e_txqsq *sq, struct sk_buff *skb,
132132
struct mlx5_wqe_eth_seg *eseg)
133133
{
134-
struct xfrm_offload *xo = xfrm_offload(skb);
134+
u8 inner_ipproto;
135135

136136
if (!mlx5e_ipsec_eseg_meta(eseg))
137137
return false;
138138

139139
eseg->cs_flags = MLX5_ETH_WQE_L3_CSUM;
140-
if (xo->inner_ipproto) {
141-
eseg->cs_flags |= MLX5_ETH_WQE_L4_INNER_CSUM | MLX5_ETH_WQE_L3_INNER_CSUM;
140+
inner_ipproto = xfrm_offload(skb)->inner_ipproto;
141+
if (inner_ipproto) {
142+
eseg->cs_flags |= MLX5_ETH_WQE_L3_INNER_CSUM;
143+
if (inner_ipproto == IPPROTO_TCP || inner_ipproto == IPPROTO_UDP)
144+
eseg->cs_flags |= MLX5_ETH_WQE_L4_INNER_CSUM;
142145
} else if (likely(skb->ip_summed == CHECKSUM_PARTIAL)) {
143146
eseg->cs_flags |= MLX5_ETH_WQE_L4_CSUM;
144147
sq->stats->csum_partial_inner++;

drivers/net/ethernet/mellanox/mlx5/core/en_rx.c

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,7 +1117,7 @@ static void mlx5e_shampo_update_ipv6_udp_hdr(struct mlx5e_rq *rq, struct ipv6hdr
11171117
static void mlx5e_shampo_update_fin_psh_flags(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe,
11181118
struct tcphdr *skb_tcp_hd)
11191119
{
1120-
u16 header_index = be16_to_cpu(cqe->shampo.header_entry_index);
1120+
u16 header_index = mlx5e_shampo_get_cqe_header_index(rq, cqe);
11211121
struct tcphdr *last_tcp_hd;
11221122
void *last_hd_addr;
11231123

@@ -1871,7 +1871,7 @@ mlx5e_skb_from_cqe_mpwrq_linear(struct mlx5e_rq *rq, struct mlx5e_mpw_info *wi,
18711871
return skb;
18721872
}
18731873

1874-
static void
1874+
static struct sk_buff *
18751875
mlx5e_skb_from_cqe_shampo(struct mlx5e_rq *rq, struct mlx5e_mpw_info *wi,
18761876
struct mlx5_cqe64 *cqe, u16 header_index)
18771877
{
@@ -1895,7 +1895,7 @@ mlx5e_skb_from_cqe_shampo(struct mlx5e_rq *rq, struct mlx5e_mpw_info *wi,
18951895
skb = mlx5e_build_linear_skb(rq, hdr, frag_size, rx_headroom, head_size);
18961896

18971897
if (unlikely(!skb))
1898-
return;
1898+
return NULL;
18991899

19001900
/* queue up for recycling/reuse */
19011901
page_ref_inc(head->page);
@@ -1907,7 +1907,7 @@ mlx5e_skb_from_cqe_shampo(struct mlx5e_rq *rq, struct mlx5e_mpw_info *wi,
19071907
ALIGN(head_size, sizeof(long)));
19081908
if (unlikely(!skb)) {
19091909
rq->stats->buff_alloc_err++;
1910-
return;
1910+
return NULL;
19111911
}
19121912

19131913
prefetchw(skb->data);
@@ -1918,9 +1918,7 @@ mlx5e_skb_from_cqe_shampo(struct mlx5e_rq *rq, struct mlx5e_mpw_info *wi,
19181918
skb->tail += head_size;
19191919
skb->len += head_size;
19201920
}
1921-
rq->hw_gro_data->skb = skb;
1922-
NAPI_GRO_CB(skb)->count = 1;
1923-
skb_shinfo(skb)->gso_size = mpwrq_get_cqe_byte_cnt(cqe) - head_size;
1921+
return skb;
19241922
}
19251923

19261924
static void
@@ -1973,13 +1971,14 @@ mlx5e_free_rx_shampo_hd_entry(struct mlx5e_rq *rq, u16 header_index)
19731971
static void mlx5e_handle_rx_cqe_mpwrq_shampo(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe)
19741972
{
19751973
u16 data_bcnt = mpwrq_get_cqe_byte_cnt(cqe) - cqe->shampo.header_size;
1976-
u16 header_index = be16_to_cpu(cqe->shampo.header_entry_index);
1974+
u16 header_index = mlx5e_shampo_get_cqe_header_index(rq, cqe);
19771975
u32 wqe_offset = be32_to_cpu(cqe->shampo.data_offset);
19781976
u16 cstrides = mpwrq_get_cqe_consumed_strides(cqe);
19791977
u32 data_offset = wqe_offset & (PAGE_SIZE - 1);
19801978
u32 cqe_bcnt = mpwrq_get_cqe_byte_cnt(cqe);
19811979
u16 wqe_id = be16_to_cpu(cqe->wqe_id);
19821980
u32 page_idx = wqe_offset >> PAGE_SHIFT;
1981+
u16 head_size = cqe->shampo.header_size;
19831982
struct sk_buff **skb = &rq->hw_gro_data->skb;
19841983
bool flush = cqe->shampo.flush;
19851984
bool match = cqe->shampo.match;
@@ -2011,9 +2010,16 @@ static void mlx5e_handle_rx_cqe_mpwrq_shampo(struct mlx5e_rq *rq, struct mlx5_cq
20112010
}
20122011

20132012
if (!*skb) {
2014-
mlx5e_skb_from_cqe_shampo(rq, wi, cqe, header_index);
2013+
if (likely(head_size))
2014+
*skb = mlx5e_skb_from_cqe_shampo(rq, wi, cqe, header_index);
2015+
else
2016+
*skb = mlx5e_skb_from_cqe_mpwrq_nonlinear(rq, wi, cqe_bcnt, data_offset,
2017+
page_idx);
20152018
if (unlikely(!*skb))
20162019
goto free_hd_entry;
2020+
2021+
NAPI_GRO_CB(*skb)->count = 1;
2022+
skb_shinfo(*skb)->gso_size = cqe_bcnt - head_size;
20172023
} else {
20182024
NAPI_GRO_CB(*skb)->count++;
20192025
if (NAPI_GRO_CB(*skb)->count == 2 &&
@@ -2027,8 +2033,10 @@ static void mlx5e_handle_rx_cqe_mpwrq_shampo(struct mlx5e_rq *rq, struct mlx5_cq
20272033
}
20282034
}
20292035

2030-
di = &wi->umr.dma_info[page_idx];
2031-
mlx5e_fill_skb_data(*skb, rq, di, data_bcnt, data_offset);
2036+
if (likely(head_size)) {
2037+
di = &wi->umr.dma_info[page_idx];
2038+
mlx5e_fill_skb_data(*skb, rq, di, data_bcnt, data_offset);
2039+
}
20322040

20332041
mlx5e_shampo_complete_rx_cqe(rq, cqe, cqe_bcnt, *skb);
20342042
if (flush)

drivers/net/ethernet/mellanox/mlx5/core/en_tc.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1414,7 +1414,8 @@ mlx5e_tc_add_fdb_flow(struct mlx5e_priv *priv,
14141414
if (err)
14151415
goto err_out;
14161416

1417-
if (!attr->chain && esw_attr->int_port) {
1417+
if (!attr->chain && esw_attr->int_port &&
1418+
attr->action & MLX5_FLOW_CONTEXT_ACTION_FWD_DEST) {
14181419
/* If decap route device is internal port, change the
14191420
* source vport value in reg_c0 back to uplink just in
14201421
* case the rule performs goto chain > 0. If we have a miss
@@ -3191,6 +3192,18 @@ actions_match_supported(struct mlx5e_priv *priv,
31913192
return false;
31923193
}
31933194

3195+
if (!(~actions &
3196+
(MLX5_FLOW_CONTEXT_ACTION_FWD_DEST | MLX5_FLOW_CONTEXT_ACTION_DROP))) {
3197+
NL_SET_ERR_MSG_MOD(extack, "Rule cannot support forward+drop action");
3198+
return false;
3199+
}
3200+
3201+
if (actions & MLX5_FLOW_CONTEXT_ACTION_MOD_HDR &&
3202+
actions & MLX5_FLOW_CONTEXT_ACTION_DROP) {
3203+
NL_SET_ERR_MSG_MOD(extack, "Drop with modify header action is not supported");
3204+
return false;
3205+
}
3206+
31943207
if (actions & MLX5_FLOW_CONTEXT_ACTION_MOD_HDR &&
31953208
!modify_header_match_supported(priv, &parse_attr->spec, flow_action,
31963209
actions, ct_flow, ct_clear, extack))

0 commit comments

Comments
 (0)