Skip to content

Commit 0a324f3

Browse files
moshelazerdavem330
authored andcommitted
net/mlx5_core: Support MANAGE_PAGES and QUERY_PAGES firmware command changes
In the previous QUERY_PAGES command version we used one command to get the required amount of boot, init and post init pages. The new version uses the op_mod field to specify whether the query is for the required amount of boot, init or post init pages. In addition the output field size for the required amount of pages increased from 16 to 32 bits. In MANAGE_PAGES command the input_num_entries and output_num_entries fields sizes changed from 16 to 32 bits and the PAS tables offset changed to 0x10. In the pages request event the num_pages field also changed to 32 bits. In the HCA-capabilities-layout the size and location of max_qp_mcg field has been changed to support 24 bits. This patch isn't compatible with firmware versions < 5; however, it turns out that the first GA firmware we will publish will not support previous versions so this should be OK. Signed-off-by: Moshe Lazer <[email protected]> Signed-off-by: Eli Cohen <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 15718ea commit 0a324f3

File tree

6 files changed

+41
-49
lines changed

6 files changed

+41
-49
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
#include "mlx5_core.h"
4747

4848
enum {
49-
CMD_IF_REV = 4,
49+
CMD_IF_REV = 5,
5050
};
5151

5252
enum {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ static int mlx5_eq_int(struct mlx5_core_dev *dev, struct mlx5_eq *eq)
268268
case MLX5_EVENT_TYPE_PAGE_REQUEST:
269269
{
270270
u16 func_id = be16_to_cpu(eqe->data.req_pages.func_id);
271-
s16 npages = be16_to_cpu(eqe->data.req_pages.num_pages);
271+
s32 npages = be32_to_cpu(eqe->data.req_pages.num_pages);
272272

273273
mlx5_core_dbg(dev, "page request for func 0x%x, napges %d\n", func_id, npages);
274274
mlx5_core_req_pages_handler(dev, func_id, npages);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ int mlx5_cmd_query_hca_cap(struct mlx5_core_dev *dev,
113113
caps->log_max_srq = out->hca_cap.log_max_srqs & 0x1f;
114114
caps->local_ca_ack_delay = out->hca_cap.local_ca_ack_delay & 0x1f;
115115
caps->log_max_mcg = out->hca_cap.log_max_mcg;
116-
caps->max_qp_mcg = be16_to_cpu(out->hca_cap.max_qp_mcg);
116+
caps->max_qp_mcg = be32_to_cpu(out->hca_cap.max_qp_mcg) & 0xffffff;
117117
caps->max_ra_res_qp = 1 << (out->hca_cap.log_max_ra_res_qp & 0x3f);
118118
caps->max_ra_req_qp = 1 << (out->hca_cap.log_max_ra_req_qp & 0x3f);
119119
caps->max_srq_wqes = 1 << out->hca_cap.log_max_srq_sz;

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

Lines changed: 26 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,16 @@ enum {
4343
MLX5_PAGES_TAKE = 2
4444
};
4545

46+
enum {
47+
MLX5_BOOT_PAGES = 1,
48+
MLX5_INIT_PAGES = 2,
49+
MLX5_POST_INIT_PAGES = 3
50+
};
51+
4652
struct mlx5_pages_req {
4753
struct mlx5_core_dev *dev;
4854
u32 func_id;
49-
s16 npages;
55+
s32 npages;
5056
struct work_struct work;
5157
};
5258

@@ -64,27 +70,23 @@ struct mlx5_query_pages_inbox {
6470

6571
struct mlx5_query_pages_outbox {
6672
struct mlx5_outbox_hdr hdr;
67-
__be16 num_boot_pages;
73+
__be16 rsvd;
6874
__be16 func_id;
69-
__be16 init_pages;
70-
__be16 num_pages;
75+
__be32 num_pages;
7176
};
7277

7378
struct mlx5_manage_pages_inbox {
7479
struct mlx5_inbox_hdr hdr;
75-
__be16 rsvd0;
80+
__be16 rsvd;
7681
__be16 func_id;
77-
__be16 rsvd1;
78-
__be16 num_entries;
79-
u8 rsvd2[16];
82+
__be32 num_entries;
8083
__be64 pas[0];
8184
};
8285

8386
struct mlx5_manage_pages_outbox {
8487
struct mlx5_outbox_hdr hdr;
85-
u8 rsvd0[2];
86-
__be16 num_entries;
87-
u8 rsvd1[20];
88+
__be32 num_entries;
89+
u8 rsvd[4];
8890
__be64 pas[0];
8991
};
9092

@@ -146,7 +148,7 @@ static struct page *remove_page(struct mlx5_core_dev *dev, u64 addr)
146148
}
147149

148150
static int mlx5_cmd_query_pages(struct mlx5_core_dev *dev, u16 *func_id,
149-
s16 *pages, s16 *init_pages, u16 *boot_pages)
151+
s32 *npages, int boot)
150152
{
151153
struct mlx5_query_pages_inbox in;
152154
struct mlx5_query_pages_outbox out;
@@ -155,22 +157,16 @@ static int mlx5_cmd_query_pages(struct mlx5_core_dev *dev, u16 *func_id,
155157
memset(&in, 0, sizeof(in));
156158
memset(&out, 0, sizeof(out));
157159
in.hdr.opcode = cpu_to_be16(MLX5_CMD_OP_QUERY_PAGES);
160+
in.hdr.opmod = boot ? cpu_to_be16(MLX5_BOOT_PAGES) : cpu_to_be16(MLX5_INIT_PAGES);
161+
158162
err = mlx5_cmd_exec(dev, &in, sizeof(in), &out, sizeof(out));
159163
if (err)
160164
return err;
161165

162166
if (out.hdr.status)
163167
return mlx5_cmd_status_to_err(&out.hdr);
164168

165-
if (pages)
166-
*pages = be16_to_cpu(out.num_pages);
167-
168-
if (init_pages)
169-
*init_pages = be16_to_cpu(out.init_pages);
170-
171-
if (boot_pages)
172-
*boot_pages = be16_to_cpu(out.num_boot_pages);
173-
169+
*npages = be32_to_cpu(out.num_pages);
174170
*func_id = be16_to_cpu(out.func_id);
175171

176172
return err;
@@ -224,7 +220,7 @@ static int give_pages(struct mlx5_core_dev *dev, u16 func_id, int npages,
224220
in->hdr.opcode = cpu_to_be16(MLX5_CMD_OP_MANAGE_PAGES);
225221
in->hdr.opmod = cpu_to_be16(MLX5_PAGES_GIVE);
226222
in->func_id = cpu_to_be16(func_id);
227-
in->num_entries = cpu_to_be16(npages);
223+
in->num_entries = cpu_to_be32(npages);
228224
err = mlx5_cmd_exec(dev, in, inlen, &out, sizeof(out));
229225
mlx5_core_dbg(dev, "err %d\n", err);
230226
if (err) {
@@ -292,7 +288,7 @@ static int reclaim_pages(struct mlx5_core_dev *dev, u32 func_id, int npages,
292288
in.hdr.opcode = cpu_to_be16(MLX5_CMD_OP_MANAGE_PAGES);
293289
in.hdr.opmod = cpu_to_be16(MLX5_PAGES_TAKE);
294290
in.func_id = cpu_to_be16(func_id);
295-
in.num_entries = cpu_to_be16(npages);
291+
in.num_entries = cpu_to_be32(npages);
296292
mlx5_core_dbg(dev, "npages %d, outlen %d\n", npages, outlen);
297293
err = mlx5_cmd_exec(dev, &in, sizeof(in), out, outlen);
298294
if (err) {
@@ -306,7 +302,7 @@ static int reclaim_pages(struct mlx5_core_dev *dev, u32 func_id, int npages,
306302
goto out_free;
307303
}
308304

309-
num_claimed = be16_to_cpu(out->num_entries);
305+
num_claimed = be32_to_cpu(out->num_entries);
310306
if (nclaimed)
311307
*nclaimed = num_claimed;
312308

@@ -345,7 +341,7 @@ static void pages_work_handler(struct work_struct *work)
345341
}
346342

347343
void mlx5_core_req_pages_handler(struct mlx5_core_dev *dev, u16 func_id,
348-
s16 npages)
344+
s32 npages)
349345
{
350346
struct mlx5_pages_req *req;
351347

@@ -364,20 +360,18 @@ void mlx5_core_req_pages_handler(struct mlx5_core_dev *dev, u16 func_id,
364360

365361
int mlx5_satisfy_startup_pages(struct mlx5_core_dev *dev, int boot)
366362
{
367-
u16 uninitialized_var(boot_pages);
368-
s16 uninitialized_var(init_pages);
369363
u16 uninitialized_var(func_id);
364+
s32 uninitialized_var(npages);
370365
int err;
371366

372-
err = mlx5_cmd_query_pages(dev, &func_id, NULL, &init_pages,
373-
&boot_pages);
367+
err = mlx5_cmd_query_pages(dev, &func_id, &npages, boot);
374368
if (err)
375369
return err;
376370

371+
mlx5_core_dbg(dev, "requested %d %s pages for func_id 0x%x\n",
372+
npages, boot ? "boot" : "init", func_id);
377373

378-
mlx5_core_dbg(dev, "requested %d init pages and %d boot pages for func_id 0x%x\n",
379-
init_pages, boot_pages, func_id);
380-
return give_pages(dev, func_id, boot ? boot_pages : init_pages, 0);
374+
return give_pages(dev, func_id, npages, 0);
381375
}
382376

383377
static int optimal_reclaimed_pages(void)

include/linux/mlx5/device.h

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -309,21 +309,20 @@ struct mlx5_hca_cap {
309309
__be16 max_desc_sz_rq;
310310
u8 rsvd21[2];
311311
__be16 max_desc_sz_sq_dc;
312-
u8 rsvd22[4];
313-
__be16 max_qp_mcg;
314-
u8 rsvd23;
312+
__be32 max_qp_mcg;
313+
u8 rsvd22[3];
315314
u8 log_max_mcg;
316-
u8 rsvd24;
315+
u8 rsvd23;
317316
u8 log_max_pd;
318-
u8 rsvd25;
317+
u8 rsvd24;
319318
u8 log_max_xrcd;
320-
u8 rsvd26[42];
319+
u8 rsvd25[42];
321320
__be16 log_uar_page_sz;
322-
u8 rsvd27[28];
321+
u8 rsvd26[28];
323322
u8 log_msx_atomic_size_qp;
324-
u8 rsvd28[2];
323+
u8 rsvd27[2];
325324
u8 log_msx_atomic_size_dc;
326-
u8 rsvd29[76];
325+
u8 rsvd28[76];
327326
};
328327

329328

@@ -472,9 +471,8 @@ struct mlx5_eqe_cmd {
472471
struct mlx5_eqe_page_req {
473472
u8 rsvd0[2];
474473
__be16 func_id;
475-
u8 rsvd1[2];
476-
__be16 num_pages;
477-
__be32 rsvd2[5];
474+
__be32 num_pages;
475+
__be32 rsvd1[5];
478476
};
479477

480478
union ev_data {

include/linux/mlx5/driver.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ struct mlx5_caps {
358358
u32 reserved_lkey;
359359
u8 local_ca_ack_delay;
360360
u8 log_max_mcg;
361-
u16 max_qp_mcg;
361+
u32 max_qp_mcg;
362362
int min_page_sz;
363363
};
364364

@@ -691,7 +691,7 @@ void mlx5_pagealloc_cleanup(struct mlx5_core_dev *dev);
691691
int mlx5_pagealloc_start(struct mlx5_core_dev *dev);
692692
void mlx5_pagealloc_stop(struct mlx5_core_dev *dev);
693693
void mlx5_core_req_pages_handler(struct mlx5_core_dev *dev, u16 func_id,
694-
s16 npages);
694+
s32 npages);
695695
int mlx5_satisfy_startup_pages(struct mlx5_core_dev *dev, int boot);
696696
int mlx5_reclaim_startup_pages(struct mlx5_core_dev *dev);
697697
void mlx5_register_debugfs(void);

0 commit comments

Comments
 (0)