Skip to content

Commit a70ed9d

Browse files
author
Saeed Mahameed
committed
Merge branch 'mlx5-next' of git://git.kernel.org/pub/scm/linux/kernel/git/mellanox/linux
This series adds some HW bits and definitions for mlx5 driver, to be used by downstream features in both rdma and netdev branches. * 'mlx5-next' of git://git.kernel.org/pub/scm/linux/kernel/git/mellanox/linux: net/mlx5: HW bit for goto chain offload support net/mlx5: Expose link speed directly net/mlx5: Introduce TLS and IPSec objects enums net/mlx5: Introduce egress acl forward-to-vport capability net/mlx5: Expose raw packet pacing APIs net/mlx5e: Replace zero-length array with flexible-array member net/mlx5: fix spelling mistake "reserverd" -> "reserved" Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
2 parents 34a568a + e0ebd8e commit a70ed9d

9 files changed

Lines changed: 136 additions & 56 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ struct mlx5e_tx_wqe {
204204

205205
struct mlx5e_rx_wqe_ll {
206206
struct mlx5_wqe_srq_next_seg next;
207-
struct mlx5_wqe_data_seg data[0];
207+
struct mlx5_wqe_data_seg data[];
208208
};
209209

210210
struct mlx5e_rx_wqe_cyc {

‎drivers/net/ethernet/mellanox/mlx5/core/fpga/ipsec.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ struct mlx5_fpga_ipsec_cmd_context {
5757
struct completion complete;
5858
struct mlx5_fpga_device *dev;
5959
struct list_head list; /* Item in pending_cmds */
60-
u8 command[0];
60+
u8 command[];
6161
};
6262

6363
struct mlx5_fpga_esp_xfrm;

‎drivers/net/ethernet/mellanox/mlx5/core/fs_counters.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ struct mlx5_fc_bulk {
470470
u32 base_id;
471471
int bulk_len;
472472
unsigned long *bitmask;
473-
struct mlx5_fc fcs[0];
473+
struct mlx5_fc fcs[];
474474
};
475475

476476
static void mlx5_fc_init(struct mlx5_fc *counter, struct mlx5_fc_bulk *bulk,

‎drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ struct mlx5i_priv {
5656
u32 qkey;
5757
u16 pkey_index;
5858
struct mlx5i_pkey_qpn_ht *qpn_htbl;
59-
char *mlx5e_priv[0];
59+
char *mlx5e_priv[];
6060
};
6161

6262
int mlx5i_create_tis(struct mlx5_core_dev *mdev, u32 underlay_qpn, u32 *tisn);
@@ -107,7 +107,7 @@ struct mlx5i_tx_wqe {
107107
struct mlx5_wqe_datagram_seg datagram;
108108
struct mlx5_wqe_eth_pad pad;
109109
struct mlx5_wqe_eth_seg eth;
110-
struct mlx5_wqe_data_seg data[0];
110+
struct mlx5_wqe_data_seg data[];
111111
};
112112

113113
static inline void mlx5i_sq_fetch_wqe(struct mlx5e_txqsq *sq,

‎drivers/net/ethernet/mellanox/mlx5/core/lib/crypto.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ int mlx5_create_encryption_key(struct mlx5_core_dev *mdev,
4242

4343
MLX5_SET(encryption_key_obj, obj, key_size, general_obj_key_size);
4444
MLX5_SET(encryption_key_obj, obj, key_type,
45-
MLX5_GENERAL_OBJECT_TYPE_ENCRYPTION_KEY_TYPE_DEK);
45+
MLX5_GENERAL_OBJECT_TYPE_ENCRYPTION_KEY_TYPE_TLS);
4646
MLX5_SET(general_obj_in_cmd_hdr, in, opcode,
4747
MLX5_CMD_OP_CREATE_GENERAL_OBJECT);
4848
MLX5_SET(general_obj_in_cmd_hdr, in, obj_type,

‎drivers/net/ethernet/mellanox/mlx5/core/rl.c‎

Lines changed: 98 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -101,22 +101,39 @@ int mlx5_destroy_scheduling_element_cmd(struct mlx5_core_dev *dev, u8 hierarchy,
101101
return mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
102102
}
103103

104+
static bool mlx5_rl_are_equal_raw(struct mlx5_rl_entry *entry, void *rl_in,
105+
u16 uid)
106+
{
107+
return (!memcmp(entry->rl_raw, rl_in, sizeof(entry->rl_raw)) &&
108+
entry->uid == uid);
109+
}
110+
104111
/* Finds an entry where we can register the given rate
105112
* If the rate already exists, return the entry where it is registered,
106113
* otherwise return the first available entry.
107114
* If the table is full, return NULL
108115
*/
109116
static struct mlx5_rl_entry *find_rl_entry(struct mlx5_rl_table *table,
110-
struct mlx5_rate_limit *rl)
117+
void *rl_in, u16 uid, bool dedicated)
111118
{
112119
struct mlx5_rl_entry *ret_entry = NULL;
113120
bool empty_found = false;
114121
int i;
115122

116123
for (i = 0; i < table->max_size; i++) {
117-
if (mlx5_rl_are_equal(&table->rl_entry[i].rl, rl))
118-
return &table->rl_entry[i];
119-
if (!empty_found && !table->rl_entry[i].rl.rate) {
124+
if (dedicated) {
125+
if (!table->rl_entry[i].refcount)
126+
return &table->rl_entry[i];
127+
continue;
128+
}
129+
130+
if (table->rl_entry[i].refcount) {
131+
if (table->rl_entry[i].dedicated)
132+
continue;
133+
if (mlx5_rl_are_equal_raw(&table->rl_entry[i], rl_in,
134+
uid))
135+
return &table->rl_entry[i];
136+
} else if (!empty_found) {
120137
empty_found = true;
121138
ret_entry = &table->rl_entry[i];
122139
}
@@ -126,18 +143,19 @@ static struct mlx5_rl_entry *find_rl_entry(struct mlx5_rl_table *table,
126143
}
127144

128145
static int mlx5_set_pp_rate_limit_cmd(struct mlx5_core_dev *dev,
129-
u16 index,
130-
struct mlx5_rate_limit *rl)
146+
struct mlx5_rl_entry *entry, bool set)
131147
{
132-
u32 in[MLX5_ST_SZ_DW(set_pp_rate_limit_in)] = {0};
133-
u32 out[MLX5_ST_SZ_DW(set_pp_rate_limit_out)] = {0};
148+
u32 in[MLX5_ST_SZ_DW(set_pp_rate_limit_in)] = {};
149+
u32 out[MLX5_ST_SZ_DW(set_pp_rate_limit_out)] = {};
150+
void *pp_context;
134151

152+
pp_context = MLX5_ADDR_OF(set_pp_rate_limit_in, in, ctx);
135153
MLX5_SET(set_pp_rate_limit_in, in, opcode,
136154
MLX5_CMD_OP_SET_PP_RATE_LIMIT);
137-
MLX5_SET(set_pp_rate_limit_in, in, rate_limit_index, index);
138-
MLX5_SET(set_pp_rate_limit_in, in, rate_limit, rl->rate);
139-
MLX5_SET(set_pp_rate_limit_in, in, burst_upper_bound, rl->max_burst_sz);
140-
MLX5_SET(set_pp_rate_limit_in, in, typical_packet_size, rl->typical_pkt_sz);
155+
MLX5_SET(set_pp_rate_limit_in, in, uid, entry->uid);
156+
MLX5_SET(set_pp_rate_limit_in, in, rate_limit_index, entry->index);
157+
if (set)
158+
memcpy(pp_context, entry->rl_raw, sizeof(entry->rl_raw));
141159
return mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
142160
}
143161

@@ -158,23 +176,25 @@ bool mlx5_rl_are_equal(struct mlx5_rate_limit *rl_0,
158176
}
159177
EXPORT_SYMBOL(mlx5_rl_are_equal);
160178

161-
int mlx5_rl_add_rate(struct mlx5_core_dev *dev, u16 *index,
162-
struct mlx5_rate_limit *rl)
179+
int mlx5_rl_add_rate_raw(struct mlx5_core_dev *dev, void *rl_in, u16 uid,
180+
bool dedicated_entry, u16 *index)
163181
{
164182
struct mlx5_rl_table *table = &dev->priv.rl_table;
165183
struct mlx5_rl_entry *entry;
166184
int err = 0;
185+
u32 rate;
167186

187+
rate = MLX5_GET(set_pp_rate_limit_context, rl_in, rate_limit);
168188
mutex_lock(&table->rl_lock);
169189

170-
if (!rl->rate || !mlx5_rl_is_in_range(dev, rl->rate)) {
190+
if (!rate || !mlx5_rl_is_in_range(dev, rate)) {
171191
mlx5_core_err(dev, "Invalid rate: %u, should be %u to %u\n",
172-
rl->rate, table->min_rate, table->max_rate);
192+
rate, table->min_rate, table->max_rate);
173193
err = -EINVAL;
174194
goto out;
175195
}
176196

177-
entry = find_rl_entry(table, rl);
197+
entry = find_rl_entry(table, rl_in, uid, dedicated_entry);
178198
if (!entry) {
179199
mlx5_core_err(dev, "Max number of %u rates reached\n",
180200
table->max_size);
@@ -185,49 +205,96 @@ int mlx5_rl_add_rate(struct mlx5_core_dev *dev, u16 *index,
185205
/* rate already configured */
186206
entry->refcount++;
187207
} else {
208+
memcpy(entry->rl_raw, rl_in, sizeof(entry->rl_raw));
209+
entry->uid = uid;
188210
/* new rate limit */
189-
err = mlx5_set_pp_rate_limit_cmd(dev, entry->index, rl);
211+
err = mlx5_set_pp_rate_limit_cmd(dev, entry, true);
190212
if (err) {
191-
mlx5_core_err(dev, "Failed configuring rate limit(err %d): rate %u, max_burst_sz %u, typical_pkt_sz %u\n",
192-
err, rl->rate, rl->max_burst_sz,
193-
rl->typical_pkt_sz);
213+
mlx5_core_err(
214+
dev,
215+
"Failed configuring rate limit(err %d): rate %u, max_burst_sz %u, typical_pkt_sz %u\n",
216+
err, rate,
217+
MLX5_GET(set_pp_rate_limit_context, rl_in,
218+
burst_upper_bound),
219+
MLX5_GET(set_pp_rate_limit_context, rl_in,
220+
typical_packet_size));
194221
goto out;
195222
}
196-
entry->rl = *rl;
223+
197224
entry->refcount = 1;
225+
entry->dedicated = dedicated_entry;
198226
}
199227
*index = entry->index;
200228

201229
out:
202230
mutex_unlock(&table->rl_lock);
203231
return err;
204232
}
233+
EXPORT_SYMBOL(mlx5_rl_add_rate_raw);
234+
235+
void mlx5_rl_remove_rate_raw(struct mlx5_core_dev *dev, u16 index)
236+
{
237+
struct mlx5_rl_table *table = &dev->priv.rl_table;
238+
struct mlx5_rl_entry *entry;
239+
240+
mutex_lock(&table->rl_lock);
241+
entry = &table->rl_entry[index - 1];
242+
entry->refcount--;
243+
if (!entry->refcount)
244+
/* need to remove rate */
245+
mlx5_set_pp_rate_limit_cmd(dev, entry, false);
246+
mutex_unlock(&table->rl_lock);
247+
}
248+
EXPORT_SYMBOL(mlx5_rl_remove_rate_raw);
249+
250+
int mlx5_rl_add_rate(struct mlx5_core_dev *dev, u16 *index,
251+
struct mlx5_rate_limit *rl)
252+
{
253+
u8 rl_raw[MLX5_ST_SZ_BYTES(set_pp_rate_limit_context)] = {};
254+
255+
MLX5_SET(set_pp_rate_limit_context, rl_raw, rate_limit, rl->rate);
256+
MLX5_SET(set_pp_rate_limit_context, rl_raw, burst_upper_bound,
257+
rl->max_burst_sz);
258+
MLX5_SET(set_pp_rate_limit_context, rl_raw, typical_packet_size,
259+
rl->typical_pkt_sz);
260+
261+
return mlx5_rl_add_rate_raw(dev, rl_raw,
262+
MLX5_CAP_QOS(dev, packet_pacing_uid) ?
263+
MLX5_SHARED_RESOURCE_UID : 0,
264+
false, index);
265+
}
205266
EXPORT_SYMBOL(mlx5_rl_add_rate);
206267

207268
void mlx5_rl_remove_rate(struct mlx5_core_dev *dev, struct mlx5_rate_limit *rl)
208269
{
270+
u8 rl_raw[MLX5_ST_SZ_BYTES(set_pp_rate_limit_context)] = {};
209271
struct mlx5_rl_table *table = &dev->priv.rl_table;
210272
struct mlx5_rl_entry *entry = NULL;
211-
struct mlx5_rate_limit reset_rl = {0};
212273

213274
/* 0 is a reserved value for unlimited rate */
214275
if (rl->rate == 0)
215276
return;
216277

278+
MLX5_SET(set_pp_rate_limit_context, rl_raw, rate_limit, rl->rate);
279+
MLX5_SET(set_pp_rate_limit_context, rl_raw, burst_upper_bound,
280+
rl->max_burst_sz);
281+
MLX5_SET(set_pp_rate_limit_context, rl_raw, typical_packet_size,
282+
rl->typical_pkt_sz);
283+
217284
mutex_lock(&table->rl_lock);
218-
entry = find_rl_entry(table, rl);
285+
entry = find_rl_entry(table, rl_raw,
286+
MLX5_CAP_QOS(dev, packet_pacing_uid) ?
287+
MLX5_SHARED_RESOURCE_UID : 0, false);
219288
if (!entry || !entry->refcount) {
220289
mlx5_core_warn(dev, "Rate %u, max_burst_sz %u typical_pkt_sz %u are not configured\n",
221290
rl->rate, rl->max_burst_sz, rl->typical_pkt_sz);
222291
goto out;
223292
}
224293

225294
entry->refcount--;
226-
if (!entry->refcount) {
295+
if (!entry->refcount)
227296
/* need to remove rate */
228-
mlx5_set_pp_rate_limit_cmd(dev, entry->index, &reset_rl);
229-
entry->rl = reset_rl;
230-
}
297+
mlx5_set_pp_rate_limit_cmd(dev, entry, false);
231298

232299
out:
233300
mutex_unlock(&table->rl_lock);
@@ -273,14 +340,13 @@ int mlx5_init_rl_table(struct mlx5_core_dev *dev)
273340
void mlx5_cleanup_rl_table(struct mlx5_core_dev *dev)
274341
{
275342
struct mlx5_rl_table *table = &dev->priv.rl_table;
276-
struct mlx5_rate_limit rl = {0};
277343
int i;
278344

279345
/* Clear all configured rates */
280346
for (i = 0; i < table->max_size; i++)
281-
if (table->rl_entry[i].rl.rate)
282-
mlx5_set_pp_rate_limit_cmd(dev, table->rl_entry[i].index,
283-
&rl);
347+
if (table->rl_entry[i].refcount)
348+
mlx5_set_pp_rate_limit_cmd(dev, &table->rl_entry[i],
349+
false);
284350

285351
kfree(dev->priv.rl_table.rl_entry);
286352
}

‎include/linux/mlx5/driver.h‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -518,9 +518,11 @@ struct mlx5_rate_limit {
518518
};
519519

520520
struct mlx5_rl_entry {
521-
struct mlx5_rate_limit rl;
522-
u16 index;
523-
u16 refcount;
521+
u8 rl_raw[MLX5_ST_SZ_BYTES(set_pp_rate_limit_context)];
522+
u16 index;
523+
u64 refcount;
524+
u16 uid;
525+
u8 dedicated : 1;
524526
};
525527

526528
struct mlx5_rl_table {
@@ -1008,6 +1010,9 @@ int mlx5_rl_add_rate(struct mlx5_core_dev *dev, u16 *index,
10081010
struct mlx5_rate_limit *rl);
10091011
void mlx5_rl_remove_rate(struct mlx5_core_dev *dev, struct mlx5_rate_limit *rl);
10101012
bool mlx5_rl_is_in_range(struct mlx5_core_dev *dev, u32 rate);
1013+
int mlx5_rl_add_rate_raw(struct mlx5_core_dev *dev, void *rl_in, u16 uid,
1014+
bool dedicated_entry, u16 *index);
1015+
void mlx5_rl_remove_rate_raw(struct mlx5_core_dev *dev, u16 index);
10111016
bool mlx5_rl_are_equal(struct mlx5_rate_limit *rl_0,
10121017
struct mlx5_rate_limit *rl_1);
10131018
int mlx5_alloc_bfreg(struct mlx5_core_dev *mdev, struct mlx5_sq_bfreg *bfreg,

‎include/linux/mlx5/mlx5_ifc.h‎

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,8 @@ struct mlx5_ifc_flow_table_prop_layout_bits {
414414
u8 reserved_at_16[0x1];
415415
u8 table_miss_action_domain[0x1];
416416
u8 termination_table[0x1];
417-
u8 reserved_at_19[0x7];
417+
u8 reformat_and_fwd_to_table[0x1];
418+
u8 reserved_at_1a[0x6];
418419
u8 reserved_at_20[0x2];
419420
u8 log_max_ft_size[0x6];
420421
u8 log_max_modify_header_context[0x8];
@@ -741,7 +742,7 @@ struct mlx5_ifc_flow_table_eswitch_cap_bits {
741742
u8 flow_source[0x1];
742743
u8 reserved_at_18[0x2];
743744
u8 multi_fdb_encap[0x1];
744-
u8 reserved_at_1b[0x1];
745+
u8 egress_acl_forward_to_vport[0x1];
745746
u8 fdb_multi_path_to_table[0x1];
746747
u8 reserved_at_1d[0x3];
747748

@@ -813,7 +814,9 @@ struct mlx5_ifc_qos_cap_bits {
813814
u8 reserved_at_4[0x1];
814815
u8 packet_pacing_burst_bound[0x1];
815816
u8 packet_pacing_typical_size[0x1];
816-
u8 reserved_at_7[0x19];
817+
u8 reserved_at_7[0x4];
818+
u8 packet_pacing_uid[0x1];
819+
u8 reserved_at_c[0x14];
817820

818821
u8 reserved_at_20[0x20];
819822

@@ -8265,9 +8268,20 @@ struct mlx5_ifc_set_pp_rate_limit_out_bits {
82658268
u8 reserved_at_40[0x40];
82668269
};
82678270

8271+
struct mlx5_ifc_set_pp_rate_limit_context_bits {
8272+
u8 rate_limit[0x20];
8273+
8274+
u8 burst_upper_bound[0x20];
8275+
8276+
u8 reserved_at_40[0x10];
8277+
u8 typical_packet_size[0x10];
8278+
8279+
u8 reserved_at_60[0x120];
8280+
};
8281+
82688282
struct mlx5_ifc_set_pp_rate_limit_in_bits {
82698283
u8 opcode[0x10];
8270-
u8 reserved_at_10[0x10];
8284+
u8 uid[0x10];
82718285

82728286
u8 reserved_at_20[0x10];
82738287
u8 op_mod[0x10];
@@ -8277,14 +8291,7 @@ struct mlx5_ifc_set_pp_rate_limit_in_bits {
82778291

82788292
u8 reserved_at_60[0x20];
82798293

8280-
u8 rate_limit[0x20];
8281-
8282-
u8 burst_upper_bound[0x20];
8283-
8284-
u8 reserved_at_c0[0x10];
8285-
u8 typical_packet_size[0x10];
8286-
8287-
u8 reserved_at_e0[0x120];
8294+
struct mlx5_ifc_set_pp_rate_limit_context_bits ctx;
82888295
};
82898296

82908297
struct mlx5_ifc_access_register_out_bits {
@@ -8420,7 +8427,8 @@ struct mlx5_ifc_ptys_reg_bits {
84208427
u8 proto_mask[0x3];
84218428

84228429
u8 an_status[0x4];
8423-
u8 reserved_at_24[0x1c];
8430+
u8 reserved_at_24[0xc];
8431+
u8 data_rate_oper[0x10];
84248432

84258433
u8 ext_eth_proto_capability[0x20];
84268434

@@ -10486,7 +10494,8 @@ enum {
1048610494
};
1048710495

1048810496
enum {
10489-
MLX5_GENERAL_OBJECT_TYPE_ENCRYPTION_KEY_TYPE_DEK = 0x1,
10497+
MLX5_GENERAL_OBJECT_TYPE_ENCRYPTION_KEY_TYPE_TLS = 0x1,
10498+
MLX5_GENERAL_OBJECT_TYPE_ENCRYPTION_KEY_TYPE_IPSEC = 0x2,
1049010499
};
1049110500

1049210501
struct mlx5_ifc_tls_static_params_bits {

0 commit comments

Comments
 (0)