Skip to content

Commit

Permalink
common/mlx5: fix duplicate read of general capabilities
Browse files Browse the repository at this point in the history
[ upstream commit e8ffd7c26637b9119694368f16d2eb1341767fc6 ]

General object types support is indicated in bitmap general_obj_types,
which is part of HCA capabilities list.
This bitmap was read multiple times, and each time a different bit was
extracted.

Previous patch optimized the code, reading the bitmap once into a local
variable, and then extracting the required bits.
However, it missed few of them which still read the bitmap for
themselves. In addition, for other readings, it moved them to use local
variable without removing the old reading, and they are read twice.

This patch moves them all to use the local variable and removes all
duplications.

Fixes: 876d470 ("common/mlx5: optimize read of general capabilities")

Signed-off-by: Michael Baum <michaelba@nvidia.com>
Acked-by: Suanming Mou <suanmingm@nvidia.com>
  • Loading branch information
michaelbaum1 authored and kevintraynor committed Mar 5, 2024
1 parent 5c8bbc6 commit 8373858
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions drivers/common/mlx5/mlx5_devx_cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -868,18 +868,6 @@ mlx5_devx_cmd_query_hca_attr(void *ctx,
attr->max_geneve_tlv_option_data_len = MLX5_GET(cmd_hca_cap, hcattr,
max_geneve_tlv_option_data_len);
attr->qos.sup = MLX5_GET(cmd_hca_cap, hcattr, qos);
attr->qos.flow_meter_aso_sup = !!(MLX5_GET64(cmd_hca_cap, hcattr,
general_obj_types) &
MLX5_GENERAL_OBJ_TYPES_CAP_FLOW_METER_ASO);
attr->vdpa.valid = !!(MLX5_GET64(cmd_hca_cap, hcattr,
general_obj_types) &
MLX5_GENERAL_OBJ_TYPES_CAP_VIRTQ_NET_Q);
attr->vdpa.queue_counters_valid = !!(MLX5_GET64(cmd_hca_cap, hcattr,
general_obj_types) &
MLX5_GENERAL_OBJ_TYPES_CAP_VIRTIO_Q_COUNTERS);
attr->parse_graph_flex_node = !!(MLX5_GET64(cmd_hca_cap, hcattr,
general_obj_types) &
MLX5_GENERAL_OBJ_TYPES_CAP_PARSE_GRAPH_FLEX_NODE);
attr->wqe_index_ignore = MLX5_GET(cmd_hca_cap, hcattr,
wqe_index_ignore_cap);
attr->cross_channel = MLX5_GET(cmd_hca_cap, hcattr, cd);
Expand All @@ -903,6 +891,9 @@ mlx5_devx_cmd_query_hca_attr(void *ctx,
/* Read the general_obj_types bitmap and extract the relevant bits. */
general_obj_types_supported = MLX5_GET64(cmd_hca_cap, hcattr,
general_obj_types);
attr->qos.flow_meter_aso_sup =
!!(general_obj_types_supported &
MLX5_GENERAL_OBJ_TYPES_CAP_FLOW_METER_ASO);
attr->vdpa.valid = !!(general_obj_types_supported &
MLX5_GENERAL_OBJ_TYPES_CAP_VIRTQ_NET_Q);
attr->vdpa.queue_counters_valid =
Expand Down Expand Up @@ -965,8 +956,7 @@ mlx5_devx_cmd_query_hca_attr(void *ctx,
attr->crypto = MLX5_GET(cmd_hca_cap, hcattr, crypto);
if (attr->crypto)
attr->aes_xts = MLX5_GET(cmd_hca_cap, hcattr, aes_xts);
attr->ct_offload = !!(MLX5_GET64(cmd_hca_cap, hcattr,
general_obj_types) &
attr->ct_offload = !!(general_obj_types_supported &
MLX5_GENERAL_OBJ_TYPES_CAP_CONN_TRACK_OFFLOAD);
attr->rq_delay_drop = MLX5_GET(cmd_hca_cap, hcattr, rq_delay_drop);
if (hca_cap_2_sup) {
Expand Down

0 comments on commit 8373858

Please sign in to comment.