Skip to content

Commit 1db1f21

Browse files
dtatuleaSaeed Mahameed
authored andcommitted
net/mlx5e: Use query_special_contexts cmd only once per mdev
Don't query the firmware so many times (num rqs * num wqes * wqe frags) because it slows down linearly the interface creation time when the product is larger. Do it only once per mdev and store the result in mlx5e_param. Due to helper function being called from different files, move it to an appropriate location. Rename the function with a proper prefix and add a small cleanup. This fix applies only for legacy rq. Fixes: 1b1e486 ("net/mlx5e: Use query_special_contexts for mkeys") Signed-off-by: Dragos Tatulea <dtatulea@nvidia.com> Reviewed-by: Or Har-Toov <ohartoov@nvidia.com> Reviewed-by: Tariq Toukan <tariqt@nvidia.com> Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
1 parent 341a80d commit 1db1f21

4 files changed

Lines changed: 26 additions & 21 deletions

File tree

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@ struct mlx5e_params {
327327
unsigned int sw_mtu;
328328
int hard_mtu;
329329
bool ptp_rx;
330+
__be32 terminate_lkey_be;
330331
};
331332

332333
static inline u8 mlx5e_get_dcb_num_tc(struct mlx5e_params *params)

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

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -727,26 +727,6 @@ static void mlx5e_rq_free_shampo(struct mlx5e_rq *rq)
727727
mlx5e_rq_shampo_hd_free(rq);
728728
}
729729

730-
static __be32 mlx5e_get_terminate_scatter_list_mkey(struct mlx5_core_dev *dev)
731-
{
732-
u32 out[MLX5_ST_SZ_DW(query_special_contexts_out)] = {};
733-
u32 in[MLX5_ST_SZ_DW(query_special_contexts_in)] = {};
734-
int res;
735-
736-
if (!MLX5_CAP_GEN(dev, terminate_scatter_list_mkey))
737-
return MLX5_TERMINATE_SCATTER_LIST_LKEY;
738-
739-
MLX5_SET(query_special_contexts_in, in, opcode,
740-
MLX5_CMD_OP_QUERY_SPECIAL_CONTEXTS);
741-
res = mlx5_cmd_exec_inout(dev, query_special_contexts, in, out);
742-
if (res)
743-
return MLX5_TERMINATE_SCATTER_LIST_LKEY;
744-
745-
res = MLX5_GET(query_special_contexts_out, out,
746-
terminate_scatter_list_mkey);
747-
return cpu_to_be32(res);
748-
}
749-
750730
static int mlx5e_alloc_rq(struct mlx5e_params *params,
751731
struct mlx5e_xsk_param *xsk,
752732
struct mlx5e_rq_param *rqp,
@@ -908,7 +888,7 @@ static int mlx5e_alloc_rq(struct mlx5e_params *params,
908888
/* check if num_frags is not a pow of two */
909889
if (rq->wqe.info.num_frags < (1 << rq->wqe.info.log_num_frags)) {
910890
wqe->data[f].byte_count = 0;
911-
wqe->data[f].lkey = mlx5e_get_terminate_scatter_list_mkey(mdev);
891+
wqe->data[f].lkey = params->terminate_lkey_be;
912892
wqe->data[f].addr = 0;
913893
}
914894
}
@@ -5007,6 +4987,8 @@ void mlx5e_build_nic_params(struct mlx5e_priv *priv, struct mlx5e_xsk *xsk, u16
50074987
/* RQ */
50084988
mlx5e_build_rq_params(mdev, params);
50094989

4990+
params->terminate_lkey_be = mlx5_core_get_terminate_scatter_list_mkey(mdev);
4991+
50104992
params->packet_merge.timeout = mlx5e_choose_lro_timeout(mdev, MLX5E_DEFAULT_LRO_TIMEOUT);
50114993

50124994
/* CQ moderation params */

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

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

3333
#include <linux/kernel.h>
3434
#include <linux/mlx5/driver.h>
35+
#include <linux/mlx5/qp.h>
3536
#include "mlx5_core.h"
3637

3738
int mlx5_core_create_mkey(struct mlx5_core_dev *dev, u32 *mkey, u32 *in,
@@ -122,3 +123,23 @@ int mlx5_core_destroy_psv(struct mlx5_core_dev *dev, int psv_num)
122123
return mlx5_cmd_exec_in(dev, destroy_psv, in);
123124
}
124125
EXPORT_SYMBOL(mlx5_core_destroy_psv);
126+
127+
__be32 mlx5_core_get_terminate_scatter_list_mkey(struct mlx5_core_dev *dev)
128+
{
129+
u32 out[MLX5_ST_SZ_DW(query_special_contexts_out)] = {};
130+
u32 in[MLX5_ST_SZ_DW(query_special_contexts_in)] = {};
131+
u32 mkey;
132+
133+
if (!MLX5_CAP_GEN(dev, terminate_scatter_list_mkey))
134+
return MLX5_TERMINATE_SCATTER_LIST_LKEY;
135+
136+
MLX5_SET(query_special_contexts_in, in, opcode,
137+
MLX5_CMD_OP_QUERY_SPECIAL_CONTEXTS);
138+
if (mlx5_cmd_exec_inout(dev, query_special_contexts, in, out))
139+
return MLX5_TERMINATE_SCATTER_LIST_LKEY;
140+
141+
mkey = MLX5_GET(query_special_contexts_out, out,
142+
terminate_scatter_list_mkey);
143+
return cpu_to_be32(mkey);
144+
}
145+
EXPORT_SYMBOL(mlx5_core_get_terminate_scatter_list_mkey);

include/linux/mlx5/driver.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,6 +1093,7 @@ void mlx5_cmdif_debugfs_cleanup(struct mlx5_core_dev *dev);
10931093
int mlx5_core_create_psv(struct mlx5_core_dev *dev, u32 pdn,
10941094
int npsvs, u32 *sig_index);
10951095
int mlx5_core_destroy_psv(struct mlx5_core_dev *dev, int psv_num);
1096+
__be32 mlx5_core_get_terminate_scatter_list_mkey(struct mlx5_core_dev *dev);
10961097
void mlx5_core_put_rsc(struct mlx5_core_rsc_common *common);
10971098
int mlx5_query_odp_caps(struct mlx5_core_dev *dev,
10981099
struct mlx5_odp_caps *odp_caps);

0 commit comments

Comments
 (0)