Skip to content

Commit 5a0d7dc

Browse files
committed
Merge tag 'mlx5-updates-2019-08-01' of git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux
Saeed Mahameed says: ==================== mlx5-updates-2019-08-01 Misc updates for mlx5 netdev driver: 1) Ingress rate support for E-Switch vports from Eli. 2) Gavi introduces flow counters bulk allocation and pool, To improve the performance of flow counter acquisition. 3) From Tariq, micro improvements for tx path 4) From Shay, small improvement for XDP TX MPWQE inline flow. 5) Aya provides some cleanups for tx devlink health reporters. 6) Saeed, refactor checksum handling into a single function. 7) Tonghao, allows dropping specific tunnel packets. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents a9e21be + 6830b46 commit 5a0d7dc

File tree

28 files changed

+875
-347
lines changed

28 files changed

+875
-347
lines changed

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,7 @@ enum {
359359
MLX5E_SQ_STATE_IPSEC,
360360
MLX5E_SQ_STATE_AM,
361361
MLX5E_SQ_STATE_TLS,
362+
MLX5E_SQ_STATE_VLAN_NEED_L2_INLINE,
362363
};
363364

364365
struct mlx5e_sq_wqe_info {
@@ -483,8 +484,6 @@ struct mlx5e_xdp_mpwqe {
483484
struct mlx5e_tx_wqe *wqe;
484485
u8 ds_count;
485486
u8 pkt_count;
486-
u8 max_ds_count;
487-
u8 complete;
488487
u8 inline_on;
489488
};
490489

@@ -1134,7 +1133,6 @@ void mlx5e_build_rq_params(struct mlx5_core_dev *mdev,
11341133
struct mlx5e_params *params);
11351134
void mlx5e_build_rss_params(struct mlx5e_rss_params *rss_params,
11361135
u16 num_channels);
1137-
u8 mlx5e_params_calculate_tx_min_inline(struct mlx5_core_dev *mdev);
11381136
void mlx5e_rx_dim_work(struct work_struct *work);
11391137
void mlx5e_tx_dim_work(struct work_struct *work);
11401138

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#ifndef __MLX5E_EN_REPORTER_H
55
#define __MLX5E_EN_REPORTER_H
66

7-
#include <linux/mlx5/driver.h>
87
#include "en.h"
98

109
int mlx5e_tx_reporter_create(struct mlx5e_priv *priv);

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

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/* SPDX-License-Identifier: GPL-2.0 */
22
/* Copyright (c) 2019 Mellanox Technologies. */
33

4-
#include <net/devlink.h>
54
#include "reporter.h"
65
#include "lib/eq.h"
76

@@ -117,7 +116,7 @@ static int mlx5_tx_health_report(struct devlink_health_reporter *tx_reporter,
117116
char *err_str,
118117
struct mlx5e_tx_err_ctx *err_ctx)
119118
{
120-
if (IS_ERR_OR_NULL(tx_reporter)) {
119+
if (!tx_reporter) {
121120
netdev_err(err_ctx->sq->channel->netdev, err_str);
122121
return err_ctx->recover(err_ctx->sq);
123122
}
@@ -289,23 +288,27 @@ static const struct devlink_health_reporter_ops mlx5_tx_reporter_ops = {
289288

290289
int mlx5e_tx_reporter_create(struct mlx5e_priv *priv)
291290
{
291+
struct devlink_health_reporter *reporter;
292292
struct mlx5_core_dev *mdev = priv->mdev;
293293
struct devlink *devlink = priv_to_devlink(mdev);
294294

295-
priv->tx_reporter =
295+
reporter =
296296
devlink_health_reporter_create(devlink, &mlx5_tx_reporter_ops,
297297
MLX5_REPORTER_TX_GRACEFUL_PERIOD,
298298
true, priv);
299-
if (IS_ERR(priv->tx_reporter))
299+
if (IS_ERR(reporter)) {
300300
netdev_warn(priv->netdev,
301301
"Failed to create tx reporter, err = %ld\n",
302-
PTR_ERR(priv->tx_reporter));
303-
return IS_ERR_OR_NULL(priv->tx_reporter);
302+
PTR_ERR(reporter));
303+
return PTR_ERR(reporter);
304+
}
305+
priv->tx_reporter = reporter;
306+
return 0;
304307
}
305308

306309
void mlx5e_tx_reporter_destroy(struct mlx5e_priv *priv)
307310
{
308-
if (IS_ERR_OR_NULL(priv->tx_reporter))
311+
if (!priv->tx_reporter)
309312
return;
310313

311314
devlink_health_reporter_destroy(priv->tx_reporter);

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

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
#include "en.h"
88

9-
#define MLX5E_SQ_NOPS_ROOM MLX5_SEND_WQE_MAX_WQEBBS
9+
#define MLX5E_SQ_NOPS_ROOM (MLX5_SEND_WQE_MAX_WQEBBS - 1)
1010
#define MLX5E_SQ_STOP_ROOM (MLX5_SEND_WQE_MAX_WQEBBS +\
1111
MLX5E_SQ_NOPS_ROOM)
1212

@@ -117,9 +117,27 @@ mlx5e_notify_hw(struct mlx5_wq_cyc *wq, u16 pc, void __iomem *uar_map,
117117
mlx5_write64((__be32 *)ctrl, uar_map);
118118
}
119119

120-
static inline bool mlx5e_transport_inline_tx_wqe(struct mlx5e_tx_wqe *wqe)
120+
static inline bool mlx5e_transport_inline_tx_wqe(struct mlx5_wqe_ctrl_seg *cseg)
121121
{
122-
return !!wqe->ctrl.tisn;
122+
return cseg && !!cseg->tisn;
123+
}
124+
125+
static inline u8
126+
mlx5e_tx_wqe_inline_mode(struct mlx5e_txqsq *sq, struct mlx5_wqe_ctrl_seg *cseg,
127+
struct sk_buff *skb)
128+
{
129+
u8 mode;
130+
131+
if (mlx5e_transport_inline_tx_wqe(cseg))
132+
return MLX5_INLINE_MODE_TCP_UDP;
133+
134+
mode = sq->min_inline_mode;
135+
136+
if (skb_vlan_tag_present(skb) &&
137+
test_bit(MLX5E_SQ_STATE_VLAN_NEED_L2_INLINE, &sq->state))
138+
mode = max_t(u8, MLX5_INLINE_MODE_L2, mode);
139+
140+
return mode;
123141
}
124142

125143
static inline void mlx5e_cq_arm(struct mlx5e_cq *cq)

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

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -179,33 +179,19 @@ static void mlx5e_xdp_mpwqe_session_start(struct mlx5e_xdpsq *sq)
179179
struct mlx5e_xdp_mpwqe *session = &sq->mpwqe;
180180
struct mlx5e_xdpsq_stats *stats = sq->stats;
181181
struct mlx5_wq_cyc *wq = &sq->wq;
182-
u8 wqebbs;
183-
u16 pi;
184-
185-
mlx5e_xdpsq_fetch_wqe(sq, &session->wqe);
186-
187-
prefetchw(session->wqe->data);
188-
session->ds_count = MLX5E_XDP_TX_EMPTY_DS_COUNT;
189-
session->pkt_count = 0;
190-
session->complete = 0;
182+
u16 pi, contig_wqebbs;
191183

192184
pi = mlx5_wq_cyc_ctr2ix(wq, sq->pc);
185+
contig_wqebbs = mlx5_wq_cyc_get_contig_wqebbs(wq, pi);
193186

194-
/* The mult of MLX5_SEND_WQE_MAX_WQEBBS * MLX5_SEND_WQEBB_NUM_DS
195-
* (16 * 4 == 64) does not fit in the 6-bit DS field of Ctrl Segment.
196-
* We use a bound lower that MLX5_SEND_WQE_MAX_WQEBBS to let a
197-
* full-session WQE be cache-aligned.
198-
*/
199-
#if L1_CACHE_BYTES < 128
200-
#define MLX5E_XDP_MPW_MAX_WQEBBS (MLX5_SEND_WQE_MAX_WQEBBS - 1)
201-
#else
202-
#define MLX5E_XDP_MPW_MAX_WQEBBS (MLX5_SEND_WQE_MAX_WQEBBS - 2)
203-
#endif
187+
if (unlikely(contig_wqebbs < MLX5_SEND_WQE_MAX_WQEBBS))
188+
mlx5e_fill_xdpsq_frag_edge(sq, wq, pi, contig_wqebbs);
204189

205-
wqebbs = min_t(u16, mlx5_wq_cyc_get_contig_wqebbs(wq, pi),
206-
MLX5E_XDP_MPW_MAX_WQEBBS);
190+
session->wqe = mlx5e_xdpsq_fetch_wqe(sq, &pi);
207191

208-
session->max_ds_count = MLX5_SEND_WQEBB_NUM_DS * wqebbs;
192+
prefetchw(session->wqe->data);
193+
session->ds_count = MLX5E_XDP_TX_EMPTY_DS_COUNT;
194+
session->pkt_count = 0;
209195

210196
mlx5e_xdp_update_inline_state(sq);
211197

@@ -244,7 +230,7 @@ static int mlx5e_xmit_xdp_frame_check_mpwqe(struct mlx5e_xdpsq *sq)
244230
{
245231
if (unlikely(!sq->mpwqe.wqe)) {
246232
if (unlikely(!mlx5e_wqc_has_room_for(&sq->wq, sq->cc, sq->pc,
247-
MLX5_SEND_WQE_MAX_WQEBBS))) {
233+
MLX5E_XDPSQ_STOP_ROOM))) {
248234
/* SQ is full, ring doorbell */
249235
mlx5e_xmit_xdp_doorbell(sq);
250236
sq->stats->full++;
@@ -285,8 +271,8 @@ static bool mlx5e_xmit_xdp_frame_mpwqe(struct mlx5e_xdpsq *sq,
285271

286272
mlx5e_xdp_mpwqe_add_dseg(sq, xdptxd, stats);
287273

288-
if (unlikely(session->complete ||
289-
session->ds_count == session->max_ds_count))
274+
if (unlikely(mlx5e_xdp_no_room_for_inline_pkt(session) ||
275+
session->ds_count == MLX5E_XDP_MPW_MAX_NUM_DS))
290276
mlx5e_xdp_mpwqe_complete(sq);
291277

292278
mlx5e_xdpi_fifo_push(&sq->db.xdpi_fifo, xdpi);

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

Lines changed: 52 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,26 @@
4040
(sizeof(struct mlx5e_tx_wqe) / MLX5_SEND_WQE_DS)
4141
#define MLX5E_XDP_TX_DS_COUNT (MLX5E_XDP_TX_EMPTY_DS_COUNT + 1 /* SG DS */)
4242

43+
#define MLX5E_XDPSQ_STOP_ROOM (MLX5E_SQ_STOP_ROOM)
44+
45+
#define MLX5E_XDP_INLINE_WQE_SZ_THRSD (256 - sizeof(struct mlx5_wqe_inline_seg))
46+
#define MLX5E_XDP_INLINE_WQE_MAX_DS_CNT \
47+
DIV_ROUND_UP(MLX5E_XDP_INLINE_WQE_SZ_THRSD, MLX5_SEND_WQE_DS)
48+
49+
/* The mult of MLX5_SEND_WQE_MAX_WQEBBS * MLX5_SEND_WQEBB_NUM_DS
50+
* (16 * 4 == 64) does not fit in the 6-bit DS field of Ctrl Segment.
51+
* We use a bound lower that MLX5_SEND_WQE_MAX_WQEBBS to let a
52+
* full-session WQE be cache-aligned.
53+
*/
54+
#if L1_CACHE_BYTES < 128
55+
#define MLX5E_XDP_MPW_MAX_WQEBBS (MLX5_SEND_WQE_MAX_WQEBBS - 1)
56+
#else
57+
#define MLX5E_XDP_MPW_MAX_WQEBBS (MLX5_SEND_WQE_MAX_WQEBBS - 2)
58+
#endif
59+
60+
#define MLX5E_XDP_MPW_MAX_NUM_DS \
61+
(MLX5E_XDP_MPW_MAX_WQEBBS * MLX5_SEND_WQEBB_NUM_DS)
62+
4363
struct mlx5e_xsk_param;
4464
int mlx5e_xdp_max_mtu(struct mlx5e_params *params, struct mlx5e_xsk_param *xsk);
4565
bool mlx5e_xdp_handle(struct mlx5e_rq *rq, struct mlx5e_dma_info *di,
@@ -114,6 +134,30 @@ static inline void mlx5e_xdp_update_inline_state(struct mlx5e_xdpsq *sq)
114134
session->inline_on = 1;
115135
}
116136

137+
static inline bool
138+
mlx5e_xdp_no_room_for_inline_pkt(struct mlx5e_xdp_mpwqe *session)
139+
{
140+
return session->inline_on &&
141+
session->ds_count + MLX5E_XDP_INLINE_WQE_MAX_DS_CNT > MLX5E_XDP_MPW_MAX_NUM_DS;
142+
}
143+
144+
static inline void
145+
mlx5e_fill_xdpsq_frag_edge(struct mlx5e_xdpsq *sq, struct mlx5_wq_cyc *wq,
146+
u16 pi, u16 nnops)
147+
{
148+
struct mlx5e_xdp_wqe_info *edge_wi, *wi = &sq->db.wqe_info[pi];
149+
150+
edge_wi = wi + nnops;
151+
/* fill sq frag edge with nops to avoid wqe wrapping two pages */
152+
for (; wi < edge_wi; wi++) {
153+
wi->num_wqebbs = 1;
154+
wi->num_pkts = 0;
155+
mlx5e_post_nop(wq, sq->sqn, &sq->pc);
156+
}
157+
158+
sq->stats->nops += nnops;
159+
}
160+
117161
static inline void
118162
mlx5e_xdp_mpwqe_add_dseg(struct mlx5e_xdpsq *sq,
119163
struct mlx5e_xdp_xmit_data *xdptxd,
@@ -126,20 +170,12 @@ mlx5e_xdp_mpwqe_add_dseg(struct mlx5e_xdpsq *sq,
126170

127171
session->pkt_count++;
128172

129-
#define MLX5E_XDP_INLINE_WQE_SZ_THRSD (256 - sizeof(struct mlx5_wqe_inline_seg))
130-
131173
if (session->inline_on && dma_len <= MLX5E_XDP_INLINE_WQE_SZ_THRSD) {
132174
struct mlx5_wqe_inline_seg *inline_dseg =
133175
(struct mlx5_wqe_inline_seg *)dseg;
134176
u16 ds_len = sizeof(*inline_dseg) + dma_len;
135177
u16 ds_cnt = DIV_ROUND_UP(ds_len, MLX5_SEND_WQE_DS);
136178

137-
if (unlikely(session->ds_count + ds_cnt > session->max_ds_count)) {
138-
/* Not enough space for inline wqe, send with memory pointer */
139-
session->complete = true;
140-
goto no_inline;
141-
}
142-
143179
inline_dseg->byte_count = cpu_to_be32(dma_len | MLX5_INLINE_SEG);
144180
memcpy(inline_dseg->data, xdptxd->data, dma_len);
145181

@@ -148,21 +184,23 @@ mlx5e_xdp_mpwqe_add_dseg(struct mlx5e_xdpsq *sq,
148184
return;
149185
}
150186

151-
no_inline:
152187
dseg->addr = cpu_to_be64(xdptxd->dma_addr);
153188
dseg->byte_count = cpu_to_be32(dma_len);
154189
dseg->lkey = sq->mkey_be;
155190
session->ds_count++;
156191
}
157192

158-
static inline void mlx5e_xdpsq_fetch_wqe(struct mlx5e_xdpsq *sq,
159-
struct mlx5e_tx_wqe **wqe)
193+
static inline struct mlx5e_tx_wqe *
194+
mlx5e_xdpsq_fetch_wqe(struct mlx5e_xdpsq *sq, u16 *pi)
160195
{
161196
struct mlx5_wq_cyc *wq = &sq->wq;
162-
u16 pi = mlx5_wq_cyc_ctr2ix(wq, sq->pc);
197+
struct mlx5e_tx_wqe *wqe;
198+
199+
*pi = mlx5_wq_cyc_ctr2ix(wq, sq->pc);
200+
wqe = mlx5_wq_cyc_get_wqe(wq, *pi);
201+
memset(wqe, 0, sizeof(*wqe));
163202

164-
*wqe = mlx5_wq_cyc_get_wqe(wq, pi);
165-
memset(*wqe, 0, sizeof(**wqe));
203+
return wqe;
166204
}
167205

168206
static inline void

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

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -180,15 +180,3 @@ int mlx5e_refresh_tirs(struct mlx5e_priv *priv, bool enable_uc_lb)
180180

181181
return err;
182182
}
183-
184-
u8 mlx5e_params_calculate_tx_min_inline(struct mlx5_core_dev *mdev)
185-
{
186-
u8 min_inline_mode;
187-
188-
mlx5_query_min_inline(mdev, &min_inline_mode);
189-
if (min_inline_mode == MLX5_INLINE_MODE_NONE &&
190-
!MLX5_CAP_ETH(mdev, wqe_vlan_insert))
191-
min_inline_mode = MLX5_INLINE_MODE_L2;
192-
193-
return min_inline_mode;
194-
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1101,7 +1101,7 @@ void mlx5e_dcbnl_delete_app(struct mlx5e_priv *priv)
11011101
static void mlx5e_trust_update_tx_min_inline_mode(struct mlx5e_priv *priv,
11021102
struct mlx5e_params *params)
11031103
{
1104-
params->tx_min_inline_mode = mlx5e_params_calculate_tx_min_inline(priv->mdev);
1104+
mlx5_query_min_inline(priv->mdev, &params->tx_min_inline_mode);
11051105
if (priv->dcbx_dp.trust_state == MLX5_QPTS_TRUST_DSCP &&
11061106
params->tx_min_inline_mode == MLX5_INLINE_MODE_L2)
11071107
params->tx_min_inline_mode = MLX5_INLINE_MODE_IP;

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,6 +1131,8 @@ static int mlx5e_alloc_txqsq(struct mlx5e_channel *c,
11311131
sq->stats = &c->priv->channel_stats[c->ix].sq[tc];
11321132
sq->stop_room = MLX5E_SQ_STOP_ROOM;
11331133
INIT_WORK(&sq->recover_work, mlx5e_tx_err_cqe_work);
1134+
if (!MLX5_CAP_ETH(mdev, wqe_vlan_insert))
1135+
set_bit(MLX5E_SQ_STATE_VLAN_NEED_L2_INLINE, &sq->state);
11341136
if (MLX5_IPSEC_DEV(c->priv->mdev))
11351137
set_bit(MLX5E_SQ_STATE_IPSEC, &sq->state);
11361138
if (mlx5_accel_is_tls_device(c->priv->mdev)) {
@@ -2323,7 +2325,7 @@ int mlx5e_open_channels(struct mlx5e_priv *priv,
23232325
goto err_close_channels;
23242326
}
23252327

2326-
if (!IS_ERR_OR_NULL(priv->tx_reporter))
2328+
if (priv->tx_reporter)
23272329
devlink_health_reporter_state_update(priv->tx_reporter,
23282330
DEVLINK_HEALTH_REPORTER_STATE_HEALTHY);
23292331

@@ -4777,7 +4779,7 @@ void mlx5e_build_nic_params(struct mlx5_core_dev *mdev,
47774779
mlx5e_set_tx_cq_mode_params(params, MLX5_CQ_PERIOD_MODE_START_FROM_EQE);
47784780

47794781
/* TX inline */
4780-
params->tx_min_inline_mode = mlx5e_params_calculate_tx_min_inline(mdev);
4782+
mlx5_query_min_inline(mdev, &params->tx_min_inline_mode);
47814783

47824784
/* RSS */
47834785
mlx5e_build_rss_params(rss_params, params->num_channels);

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,6 +1156,23 @@ mlx5e_rep_setup_tc_cls_flower(struct mlx5e_priv *priv,
11561156
}
11571157
}
11581158

1159+
static
1160+
int mlx5e_rep_setup_tc_cls_matchall(struct mlx5e_priv *priv,
1161+
struct tc_cls_matchall_offload *ma)
1162+
{
1163+
switch (ma->command) {
1164+
case TC_CLSMATCHALL_REPLACE:
1165+
return mlx5e_tc_configure_matchall(priv, ma);
1166+
case TC_CLSMATCHALL_DESTROY:
1167+
return mlx5e_tc_delete_matchall(priv, ma);
1168+
case TC_CLSMATCHALL_STATS:
1169+
mlx5e_tc_stats_matchall(priv, ma);
1170+
return 0;
1171+
default:
1172+
return -EOPNOTSUPP;
1173+
}
1174+
}
1175+
11591176
static int mlx5e_rep_setup_tc_cb(enum tc_setup_type type, void *type_data,
11601177
void *cb_priv)
11611178
{
@@ -1165,6 +1182,8 @@ static int mlx5e_rep_setup_tc_cb(enum tc_setup_type type, void *type_data,
11651182
switch (type) {
11661183
case TC_SETUP_CLSFLOWER:
11671184
return mlx5e_rep_setup_tc_cls_flower(priv, type_data, flags);
1185+
case TC_SETUP_CLSMATCHALL:
1186+
return mlx5e_rep_setup_tc_cls_matchall(priv, type_data);
11681187
default:
11691188
return -EOPNOTSUPP;
11701189
}

0 commit comments

Comments
 (0)