Skip to content

Commit c9448e8

Browse files
committed
Merge tag 'mlx5-updates-2020-11-03' of git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux
Saeed Mahameed says: ==================== mlx5-updates-2020-11-03 This series includes updates to mlx5 software steering component. 1) Few improvements in the DR area, such as removing unneeded checks, renaming to better general names, refactor in some places, etc. 2) Software steering (DR) Memory management improvements This patch series contains SW Steering memory management improvements: using buddy allocator instead of an existing bucket allocator, and several other optimizations. The buddy system is a memory allocation and management algorithm that manages memory in power of two increments. The algorithm is well-known and well-described, such as here: https://en.wikipedia.org/wiki/Buddy_memory_allocation Linux uses this algorithm for managing and allocating physical pages, as described here: https://www.kernel.org/doc/gorman/html/understand/understand009.html In our case, although the algorithm in principal is similar to the Linux physical page allocator, the "building blocks" and the circumstances are different: in SW steering, buddy allocator doesn't really allocates a memory, but rather manages ICM (Interconnect Context Memory) that was previously allocated and registered. The ICM memory that is used in SW steering is always power of 2 (order), so buddy system is a good fit for this. Patches in this series: [PATH 4] net/mlx5: DR, Add buddy allocator utilities This patch adds a modified implementation of a well-known buddy allocator, adjusted for SW steering needs: the algorithm in principal is similar to the Linux physical page allocator, but in our case buddy allocator doesn't really allocate a memory, but rather manages ICM memory that was previously allocated and registered. [PATH 5] net/mlx5: DR, Handle ICM memory via buddy allocation instead of bucket management This patch changes ICM management of SW steering to use buddy-system mechanism Instead of the previous bucket management. [PATH 6] net/mlx5: DR, Sync chunks only during free This patch makes syncing happen only when freeing memory chunks. [PATH 7] net/mlx5: DR, ICM memory pools sync optimization This patch adds tracking of pool's "hot" memory and makes the check whether steering sync is required much shorter and faster. [PATH 8] net/mlx5: DR, Free buddy ICM memory if it is unused This patch adds tracking buddy's used ICM memory, and frees the buddy if all its memory becomes unused. 3) Misc code cleanups * tag 'mlx5-updates-2020-11-03' of git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux: net: mlx5: Replace in_irq() usage net/mlx5: Cleanup kernel-doc warnings net/mlx4: Cleanup kernel-doc warnings net/mlx5e: Validate stop_room size upon user input net/mlx5: DR, Free unused buddy ICM memory net/mlx5: DR, ICM memory pools sync optimization net/mlx5: DR, Sync chunks only during free net/mlx5: DR, Handle ICM memory via buddy allocation instead of buckets net/mlx5: DR, Add buddy allocator utilities net/mlx5: DR, Rename matcher functions to be more HW agnostic net/mlx5: DR, Rename builders HW specific names net/mlx5: DR, Remove unused member of action struct ==================== Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents c1aedf0 + 5144368 commit c9448e8

File tree

19 files changed

+591
-467
lines changed

19 files changed

+591
-467
lines changed

drivers/net/ethernet/mellanox/mlx4/fw_qos.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ int mlx4_SET_VPORT_QOS_get(struct mlx4_dev *dev, u8 port, u8 vport,
135135
* @dev: mlx4_dev.
136136
* @port: Physical port number.
137137
* @vport: Vport id.
138-
* @out_param: Array of mlx4_vport_qos_param which holds the requested values.
138+
* @in_param: Array of mlx4_vport_qos_param which holds the requested values.
139139
*
140140
* Returns 0 on success or a negative mlx4_core errno code.
141141
**/

drivers/net/ethernet/mellanox/mlx5/core/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ mlx5_core-$(CONFIG_MLX5_EN_TLS) += en_accel/tls.o en_accel/tls_rxtx.o en_accel/t
8181

8282
mlx5_core-$(CONFIG_MLX5_SW_STEERING) += steering/dr_domain.o steering/dr_table.o \
8383
steering/dr_matcher.o steering/dr_rule.o \
84-
steering/dr_icm_pool.o \
84+
steering/dr_icm_pool.o steering/dr_buddy.o \
8585
steering/dr_ste.o steering/dr_send.o \
8686
steering/dr_cmd.o steering/dr_fw.o \
8787
steering/dr_action.o steering/fs_dr.o

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

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
/* Copyright (c) 2019 Mellanox Technologies. */
33

44
#include "en/params.h"
5+
#include "en/txrx.h"
6+
#include "en_accel/tls_rxtx.h"
57

68
static inline bool mlx5e_rx_is_xdp(struct mlx5e_params *params,
79
struct mlx5e_xsk_param *xsk)
@@ -152,3 +154,35 @@ u16 mlx5e_get_rq_headroom(struct mlx5_core_dev *mdev,
152154

153155
return is_linear_skb ? mlx5e_get_linear_rq_headroom(params, xsk) : 0;
154156
}
157+
158+
u16 mlx5e_calc_sq_stop_room(struct mlx5_core_dev *mdev, struct mlx5e_params *params)
159+
{
160+
bool is_mpwqe = MLX5E_GET_PFLAG(params, MLX5E_PFLAG_SKB_TX_MPWQE);
161+
u16 stop_room;
162+
163+
stop_room = mlx5e_tls_get_stop_room(mdev, params);
164+
stop_room += mlx5e_stop_room_for_wqe(MLX5_SEND_WQE_MAX_WQEBBS);
165+
if (is_mpwqe)
166+
/* A MPWQE can take up to the maximum-sized WQE + all the normal
167+
* stop room can be taken if a new packet breaks the active
168+
* MPWQE session and allocates its WQEs right away.
169+
*/
170+
stop_room += mlx5e_stop_room_for_wqe(MLX5_SEND_WQE_MAX_WQEBBS);
171+
172+
return stop_room;
173+
}
174+
175+
int mlx5e_validate_params(struct mlx5e_priv *priv, struct mlx5e_params *params)
176+
{
177+
size_t sq_size = 1 << params->log_sq_size;
178+
u16 stop_room;
179+
180+
stop_room = mlx5e_calc_sq_stop_room(priv->mdev, params);
181+
if (stop_room >= sq_size) {
182+
netdev_err(priv->netdev, "Stop room %hu is bigger than the SQ size %zu\n",
183+
stop_room, sq_size);
184+
return -EINVAL;
185+
}
186+
187+
return 0;
188+
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ struct mlx5e_sq_param {
3030
u32 sqc[MLX5_ST_SZ_DW(sqc)];
3131
struct mlx5_wq_param wq;
3232
bool is_mpw;
33+
u16 stop_room;
3334
};
3435

3536
struct mlx5e_channel_param {
@@ -124,4 +125,7 @@ void mlx5e_build_xdpsq_param(struct mlx5e_priv *priv,
124125
struct mlx5e_params *params,
125126
struct mlx5e_sq_param *param);
126127

128+
u16 mlx5e_calc_sq_stop_room(struct mlx5_core_dev *mdev, struct mlx5e_params *params);
129+
int mlx5e_validate_params(struct mlx5e_priv *priv, struct mlx5e_params *params);
130+
127131
#endif /* __MLX5_EN_PARAMS_H__ */

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,20 @@ struct mlx5e_dump_wqe {
1313
(DIV_ROUND_UP(sizeof(struct mlx5e_dump_wqe), MLX5_SEND_WQE_BB))
1414

1515
static u8
16-
mlx5e_ktls_dumps_num_wqes(struct mlx5e_txqsq *sq, unsigned int nfrags,
16+
mlx5e_ktls_dumps_num_wqes(struct mlx5e_params *params, unsigned int nfrags,
1717
unsigned int sync_len)
1818
{
1919
/* Given the MTU and sync_len, calculates an upper bound for the
2020
* number of DUMP WQEs needed for the TX resync of a record.
2121
*/
22-
return nfrags + DIV_ROUND_UP(sync_len, sq->hw_mtu);
22+
return nfrags + DIV_ROUND_UP(sync_len, MLX5E_SW2HW_MTU(params, params->sw_mtu));
2323
}
2424

25-
u16 mlx5e_ktls_get_stop_room(struct mlx5e_txqsq *sq)
25+
u16 mlx5e_ktls_get_stop_room(struct mlx5e_params *params)
2626
{
2727
u16 num_dumps, stop_room = 0;
2828

29-
num_dumps = mlx5e_ktls_dumps_num_wqes(sq, MAX_SKB_FRAGS, TLS_MAX_PAYLOAD_SIZE);
29+
num_dumps = mlx5e_ktls_dumps_num_wqes(params, MAX_SKB_FRAGS, TLS_MAX_PAYLOAD_SIZE);
3030

3131
stop_room += mlx5e_stop_room_for_wqe(MLX5E_TLS_SET_STATIC_PARAMS_WQEBBS);
3232
stop_room += mlx5e_stop_room_for_wqe(MLX5E_TLS_SET_PROGRESS_PARAMS_WQEBBS);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ struct mlx5e_accel_tx_tls_state {
1414
u32 tls_tisn;
1515
};
1616

17-
u16 mlx5e_ktls_get_stop_room(struct mlx5e_txqsq *sq);
17+
u16 mlx5e_ktls_get_stop_room(struct mlx5e_params *params);
1818

1919
bool mlx5e_ktls_handle_tx_skb(struct tls_context *tls_ctx, struct mlx5e_txqsq *sq,
2020
struct sk_buff *skb, int datalen,

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -385,15 +385,13 @@ void mlx5e_tls_handle_rx_skb_metadata(struct mlx5e_rq *rq, struct sk_buff *skb,
385385
*cqe_bcnt -= MLX5E_METADATA_ETHER_LEN;
386386
}
387387

388-
u16 mlx5e_tls_get_stop_room(struct mlx5e_txqsq *sq)
388+
u16 mlx5e_tls_get_stop_room(struct mlx5_core_dev *mdev, struct mlx5e_params *params)
389389
{
390-
struct mlx5_core_dev *mdev = sq->channel->mdev;
391-
392390
if (!mlx5_accel_is_tls_device(mdev))
393391
return 0;
394392

395393
if (mlx5_accel_is_ktls_device(mdev))
396-
return mlx5e_ktls_get_stop_room(sq);
394+
return mlx5e_ktls_get_stop_room(params);
397395

398396
/* FPGA */
399397
/* Resync SKB. */

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
#include "en.h"
4444
#include "en/txrx.h"
4545

46-
u16 mlx5e_tls_get_stop_room(struct mlx5e_txqsq *sq);
46+
u16 mlx5e_tls_get_stop_room(struct mlx5_core_dev *mdev, struct mlx5e_params *params);
4747

4848
bool mlx5e_tls_handle_tx_skb(struct net_device *netdev, struct mlx5e_txqsq *sq,
4949
struct sk_buff *skb, struct mlx5e_accel_tx_tls_state *state);
@@ -71,7 +71,7 @@ mlx5e_accel_is_tls(struct mlx5_cqe64 *cqe, struct sk_buff *skb) { return false;
7171
static inline void
7272
mlx5e_tls_handle_rx_skb(struct mlx5e_rq *rq, struct sk_buff *skb,
7373
struct mlx5_cqe64 *cqe, u32 *cqe_bcnt) {}
74-
static inline u16 mlx5e_tls_get_stop_room(struct mlx5e_txqsq *sq)
74+
static inline u16 mlx5e_tls_get_stop_room(struct mlx5_core_dev *mdev, struct mlx5e_params *params)
7575
{
7676
return 0;
7777
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232

3333
#include "en.h"
3434
#include "en/port.h"
35+
#include "en/params.h"
3536
#include "en/xsk/pool.h"
3637
#include "lib/clock.h"
3738

@@ -369,6 +370,10 @@ int mlx5e_ethtool_set_ringparam(struct mlx5e_priv *priv,
369370
new_channels.params.log_rq_mtu_frames = log_rq_size;
370371
new_channels.params.log_sq_size = log_sq_size;
371372

373+
err = mlx5e_validate_params(priv, &new_channels.params);
374+
if (err)
375+
goto unlock;
376+
372377
if (!test_bit(MLX5E_STATE_OPENED, &priv->state)) {
373378
priv->channels.params = new_channels.params;
374379
goto unlock;

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

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,28 +1121,6 @@ static int mlx5e_alloc_txqsq_db(struct mlx5e_txqsq *sq, int numa)
11211121
return 0;
11221122
}
11231123

1124-
static int mlx5e_calc_sq_stop_room(struct mlx5e_txqsq *sq, u8 log_sq_size)
1125-
{
1126-
int sq_size = 1 << log_sq_size;
1127-
1128-
sq->stop_room = mlx5e_tls_get_stop_room(sq);
1129-
sq->stop_room += mlx5e_stop_room_for_wqe(MLX5_SEND_WQE_MAX_WQEBBS);
1130-
if (test_bit(MLX5E_SQ_STATE_MPWQE, &sq->state))
1131-
/* A MPWQE can take up to the maximum-sized WQE + all the normal
1132-
* stop room can be taken if a new packet breaks the active
1133-
* MPWQE session and allocates its WQEs right away.
1134-
*/
1135-
sq->stop_room += mlx5e_stop_room_for_wqe(MLX5_SEND_WQE_MAX_WQEBBS);
1136-
1137-
if (WARN_ON(sq->stop_room >= sq_size)) {
1138-
netdev_err(sq->channel->netdev, "Stop room %hu is bigger than the SQ size %d\n",
1139-
sq->stop_room, sq_size);
1140-
return -ENOSPC;
1141-
}
1142-
1143-
return 0;
1144-
}
1145-
11461124
static void mlx5e_tx_err_cqe_work(struct work_struct *recover_work);
11471125
static int mlx5e_alloc_txqsq(struct mlx5e_channel *c,
11481126
int txq_ix,
@@ -1176,9 +1154,7 @@ static int mlx5e_alloc_txqsq(struct mlx5e_channel *c,
11761154
set_bit(MLX5E_SQ_STATE_TLS, &sq->state);
11771155
if (param->is_mpw)
11781156
set_bit(MLX5E_SQ_STATE_MPWQE, &sq->state);
1179-
err = mlx5e_calc_sq_stop_room(sq, params->log_sq_size);
1180-
if (err)
1181-
return err;
1157+
sq->stop_room = param->stop_room;
11821158

11831159
param->wq.db_numa_node = cpu_to_node(c->cpu);
11841160
err = mlx5_wq_cyc_create(mdev, &param->wq, sqc_wq, wq, &sq->wq_ctrl);
@@ -2225,6 +2201,7 @@ static void mlx5e_build_sq_param(struct mlx5e_priv *priv,
22252201
MLX5_SET(wq, wq, log_wq_sz, params->log_sq_size);
22262202
MLX5_SET(sqc, sqc, allow_swp, allow_swp);
22272203
param->is_mpw = MLX5E_GET_PFLAG(params, MLX5E_PFLAG_SKB_TX_MPWQE);
2204+
param->stop_room = mlx5e_calc_sq_stop_room(priv->mdev, params);
22282205
mlx5e_build_tx_cq_param(priv, params, &param->cqp);
22292206
}
22302207

@@ -3999,6 +3976,9 @@ int mlx5e_change_mtu(struct net_device *netdev, int new_mtu,
39993976

40003977
new_channels.params = *params;
40013978
new_channels.params.sw_mtu = new_mtu;
3979+
err = mlx5e_validate_params(priv, &new_channels.params);
3980+
if (err)
3981+
goto out;
40023982

40033983
if (params->xdp_prog &&
40043984
!mlx5e_rx_is_linear_skb(&new_channels.params, NULL)) {

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

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -189,19 +189,21 @@ u32 mlx5_eq_poll_irq_disabled(struct mlx5_eq_comp *eq)
189189
return count_eqe;
190190
}
191191

192-
static void mlx5_eq_async_int_lock(struct mlx5_eq_async *eq, unsigned long *flags)
192+
static void mlx5_eq_async_int_lock(struct mlx5_eq_async *eq, bool recovery,
193+
unsigned long *flags)
193194
__acquires(&eq->lock)
194195
{
195-
if (in_irq())
196+
if (!recovery)
196197
spin_lock(&eq->lock);
197198
else
198199
spin_lock_irqsave(&eq->lock, *flags);
199200
}
200201

201-
static void mlx5_eq_async_int_unlock(struct mlx5_eq_async *eq, unsigned long *flags)
202+
static void mlx5_eq_async_int_unlock(struct mlx5_eq_async *eq, bool recovery,
203+
unsigned long *flags)
202204
__releases(&eq->lock)
203205
{
204-
if (in_irq())
206+
if (!recovery)
205207
spin_unlock(&eq->lock);
206208
else
207209
spin_unlock_irqrestore(&eq->lock, *flags);
@@ -223,11 +225,13 @@ static int mlx5_eq_async_int(struct notifier_block *nb,
223225
struct mlx5_eqe *eqe;
224226
unsigned long flags;
225227
int num_eqes = 0;
228+
bool recovery;
226229

227230
dev = eq->dev;
228231
eqt = dev->priv.eq_table;
229232

230-
mlx5_eq_async_int_lock(eq_async, &flags);
233+
recovery = action == ASYNC_EQ_RECOVER;
234+
mlx5_eq_async_int_lock(eq_async, recovery, &flags);
231235

232236
eqe = next_eqe_sw(eq);
233237
if (!eqe)
@@ -249,9 +253,9 @@ static int mlx5_eq_async_int(struct notifier_block *nb,
249253

250254
out:
251255
eq_update_ci(eq, 1);
252-
mlx5_eq_async_int_unlock(eq_async, &flags);
256+
mlx5_eq_async_int_unlock(eq_async, recovery, &flags);
253257

254-
return unlikely(action == ASYNC_EQ_RECOVER) ? num_eqes : 0;
258+
return unlikely(recovery) ? num_eqes : 0;
255259
}
256260

257261
void mlx5_cmd_eq_recover(struct mlx5_core_dev *dev)

drivers/net/ethernet/mellanox/mlx5/core/fpga/sdk.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,12 @@
4747
/**
4848
* enum mlx5_fpga_access_type - Enumerated the different methods possible for
4949
* accessing the device memory address space
50+
*
51+
* @MLX5_FPGA_ACCESS_TYPE_I2C: Use the slow CX-FPGA I2C bus
52+
* @MLX5_FPGA_ACCESS_TYPE_DONTCARE: Use the fastest available method
5053
*/
5154
enum mlx5_fpga_access_type {
52-
/** Use the slow CX-FPGA I2C bus */
5355
MLX5_FPGA_ACCESS_TYPE_I2C = 0x0,
54-
/** Use the fastest available method */
5556
MLX5_FPGA_ACCESS_TYPE_DONTCARE = 0x0,
5657
};
5758

@@ -113,6 +114,7 @@ struct mlx5_fpga_conn_attr {
113114
* subsequent receives.
114115
*/
115116
void (*recv_cb)(void *cb_arg, struct mlx5_fpga_dma_buf *buf);
117+
/** @cb_arg: A context to be passed to recv_cb callback */
116118
void *cb_arg;
117119
};
118120

@@ -145,7 +147,7 @@ void mlx5_fpga_sbu_conn_destroy(struct mlx5_fpga_conn *conn);
145147

146148
/**
147149
* mlx5_fpga_sbu_conn_sendmsg() - Queue the transmission of a packet
148-
* @fdev: An FPGA SBU connection
150+
* @conn: An FPGA SBU connection
149151
* @buf: The packet buffer
150152
*
151153
* Queues a packet for transmission over an FPGA SBU connection.

0 commit comments

Comments
 (0)