Skip to content

Commit 7d3115e

Browse files
selvintxavierjgunthorpe
authored andcommitted
RDMA/bnxt_re: Optimize the bnxt_re_init_hwrm_hdr usage
As of now bnxt_re_init_hwrm_hdr is taking only the opcode from the caller. compl_ring and target_id field is always -1. These fields might be changed when newer features are added. For now, removing these parameters as they are hard coded. Also, remove the rdev field which is not used. Also, initialize the structure bnxt_fw_msg during declaration itself. Link: https://lore.kernel.org/r/[email protected] Suggested-by: Leon Romanovsky <[email protected]> Signed-off-by: Selvin Xavier <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent 390bf42 commit 7d3115e

File tree

1 file changed

+19
-29
lines changed
  • drivers/infiniband/hw/bnxt_re

1 file changed

+19
-29
lines changed

drivers/infiniband/hw/bnxt_re/main.c

Lines changed: 19 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -321,12 +321,11 @@ static int bnxt_re_register_netdev(struct bnxt_re_dev *rdev)
321321
return rc;
322322
}
323323

324-
static void bnxt_re_init_hwrm_hdr(struct bnxt_re_dev *rdev, struct input *hdr,
325-
u16 opcd, u16 crid, u16 trid)
324+
static void bnxt_re_init_hwrm_hdr(struct input *hdr, u16 opcd)
326325
{
327326
hdr->req_type = cpu_to_le16(opcd);
328-
hdr->cmpl_ring = cpu_to_le16(crid);
329-
hdr->target_id = cpu_to_le16(trid);
327+
hdr->cmpl_ring = cpu_to_le16(-1);
328+
hdr->target_id = cpu_to_le16(-1);
330329
}
331330

332331
static void bnxt_re_fill_fw_msg(struct bnxt_fw_msg *fw_msg, void *msg,
@@ -344,9 +343,9 @@ static int bnxt_re_net_ring_free(struct bnxt_re_dev *rdev,
344343
u16 fw_ring_id, int type)
345344
{
346345
struct bnxt_en_dev *en_dev;
347-
struct hwrm_ring_free_input req = {0};
346+
struct hwrm_ring_free_input req = {};
348347
struct hwrm_ring_free_output resp;
349-
struct bnxt_fw_msg fw_msg;
348+
struct bnxt_fw_msg fw_msg = {};
350349
int rc = -EINVAL;
351350

352351
if (!rdev)
@@ -360,9 +359,7 @@ static int bnxt_re_net_ring_free(struct bnxt_re_dev *rdev,
360359
if (test_bit(BNXT_RE_FLAG_ERR_DEVICE_DETACHED, &rdev->flags))
361360
return 0;
362361

363-
memset(&fw_msg, 0, sizeof(fw_msg));
364-
365-
bnxt_re_init_hwrm_hdr(rdev, (void *)&req, HWRM_RING_FREE, -1, -1);
362+
bnxt_re_init_hwrm_hdr((void *)&req, HWRM_RING_FREE);
366363
req.ring_type = type;
367364
req.ring_id = cpu_to_le16(fw_ring_id);
368365
bnxt_re_fill_fw_msg(&fw_msg, (void *)&req, sizeof(req), (void *)&resp,
@@ -379,16 +376,15 @@ static int bnxt_re_net_ring_alloc(struct bnxt_re_dev *rdev,
379376
u16 *fw_ring_id)
380377
{
381378
struct bnxt_en_dev *en_dev = rdev->en_dev;
382-
struct hwrm_ring_alloc_input req = {0};
379+
struct hwrm_ring_alloc_input req = {};
383380
struct hwrm_ring_alloc_output resp;
384-
struct bnxt_fw_msg fw_msg;
381+
struct bnxt_fw_msg fw_msg = {};
385382
int rc = -EINVAL;
386383

387384
if (!en_dev)
388385
return rc;
389386

390-
memset(&fw_msg, 0, sizeof(fw_msg));
391-
bnxt_re_init_hwrm_hdr(rdev, (void *)&req, HWRM_RING_ALLOC, -1, -1);
387+
bnxt_re_init_hwrm_hdr((void *)&req, HWRM_RING_ALLOC);
392388
req.enables = 0;
393389
req.page_tbl_addr = cpu_to_le64(ring_attr->dma_arr[0]);
394390
if (ring_attr->pages > 1) {
@@ -417,7 +413,7 @@ static int bnxt_re_net_stats_ctx_free(struct bnxt_re_dev *rdev,
417413
struct bnxt_en_dev *en_dev = rdev->en_dev;
418414
struct hwrm_stat_ctx_free_input req = {};
419415
struct hwrm_stat_ctx_free_output resp = {};
420-
struct bnxt_fw_msg fw_msg;
416+
struct bnxt_fw_msg fw_msg = {};
421417
int rc = -EINVAL;
422418

423419
if (!en_dev)
@@ -426,9 +422,7 @@ static int bnxt_re_net_stats_ctx_free(struct bnxt_re_dev *rdev,
426422
if (test_bit(BNXT_RE_FLAG_ERR_DEVICE_DETACHED, &rdev->flags))
427423
return 0;
428424

429-
memset(&fw_msg, 0, sizeof(fw_msg));
430-
431-
bnxt_re_init_hwrm_hdr(rdev, (void *)&req, HWRM_STAT_CTX_FREE, -1, -1);
425+
bnxt_re_init_hwrm_hdr((void *)&req, HWRM_STAT_CTX_FREE);
432426
req.stat_ctx_id = cpu_to_le32(fw_stats_ctx_id);
433427
bnxt_re_fill_fw_msg(&fw_msg, (void *)&req, sizeof(req), (void *)&resp,
434428
sizeof(resp), DFLT_HWRM_CMD_TIMEOUT);
@@ -445,20 +439,18 @@ static int bnxt_re_net_stats_ctx_alloc(struct bnxt_re_dev *rdev,
445439
u32 *fw_stats_ctx_id)
446440
{
447441
struct bnxt_qplib_chip_ctx *chip_ctx = rdev->chip_ctx;
448-
struct hwrm_stat_ctx_alloc_output resp = {0};
449-
struct hwrm_stat_ctx_alloc_input req = {0};
442+
struct hwrm_stat_ctx_alloc_output resp = {};
443+
struct hwrm_stat_ctx_alloc_input req = {};
450444
struct bnxt_en_dev *en_dev = rdev->en_dev;
451-
struct bnxt_fw_msg fw_msg;
445+
struct bnxt_fw_msg fw_msg = {};
452446
int rc = -EINVAL;
453447

454448
*fw_stats_ctx_id = INVALID_STATS_CTX_ID;
455449

456450
if (!en_dev)
457451
return rc;
458452

459-
memset(&fw_msg, 0, sizeof(fw_msg));
460-
461-
bnxt_re_init_hwrm_hdr(rdev, (void *)&req, HWRM_STAT_CTX_ALLOC, -1, -1);
453+
bnxt_re_init_hwrm_hdr((void *)&req, HWRM_STAT_CTX_ALLOC);
462454
req.update_period_ms = cpu_to_le32(1000);
463455
req.stats_dma_addr = cpu_to_le64(dma_map);
464456
req.stats_dma_length = cpu_to_le16(chip_ctx->hw_stats_size);
@@ -1045,15 +1037,13 @@ static int bnxt_re_setup_qos(struct bnxt_re_dev *rdev)
10451037
static void bnxt_re_query_hwrm_intf_version(struct bnxt_re_dev *rdev)
10461038
{
10471039
struct bnxt_en_dev *en_dev = rdev->en_dev;
1048-
struct hwrm_ver_get_output resp = {0};
1049-
struct hwrm_ver_get_input req = {0};
1040+
struct hwrm_ver_get_output resp = {};
1041+
struct hwrm_ver_get_input req = {};
10501042
struct bnxt_qplib_chip_ctx *cctx;
1051-
struct bnxt_fw_msg fw_msg;
1043+
struct bnxt_fw_msg fw_msg = {};
10521044
int rc = 0;
10531045

1054-
memset(&fw_msg, 0, sizeof(fw_msg));
1055-
bnxt_re_init_hwrm_hdr(rdev, (void *)&req,
1056-
HWRM_VER_GET, -1, -1);
1046+
bnxt_re_init_hwrm_hdr((void *)&req, HWRM_VER_GET);
10571047
req.hwrm_intf_maj = HWRM_VERSION_MAJOR;
10581048
req.hwrm_intf_min = HWRM_VERSION_MINOR;
10591049
req.hwrm_intf_upd = HWRM_VERSION_UPDATE;

0 commit comments

Comments
 (0)