forked from Minki/linux
RDMA/mlx5: Return ODP type per MR
Provide an ODP explicit/implicit type as part of 'rdma -dd resource show mr' dump. For example: $ rdma -dd resource show mr dev mlx5_0 mrn 1 rkey 0xa99a lkey 0xa99a mrlen 50000000 pdn 9 pid 7372 comm ibv_rc_pingpong drv_odp explicit For non-ODP MRs, we won't print "drv_odp ..." at all. Link: https://lore.kernel.org/r/20191016062308.11886-4-leon@kernel.org Signed-off-by: Erez Alfasi <ereza@mellanox.com> Signed-off-by: Leon Romanovsky <leonro@mellanox.com> Reviewed-by: Jason Gunthorpe <jgg@mellanox.com> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
This commit is contained in:
parent
fb91069088
commit
e1b95ae0b0
@ -183,6 +183,19 @@ static int _rdma_nl_put_driver_u64(struct sk_buff *msg, const char *name,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int rdma_nl_put_driver_string(struct sk_buff *msg, const char *name,
|
||||
const char *str)
|
||||
{
|
||||
if (put_driver_name_print_type(msg, name,
|
||||
RDMA_NLDEV_PRINT_TYPE_UNSPEC))
|
||||
return -EMSGSIZE;
|
||||
if (nla_put_string(msg, RDMA_NLDEV_ATTR_DRIVER_STRING, str))
|
||||
return -EMSGSIZE;
|
||||
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(rdma_nl_put_driver_string);
|
||||
|
||||
int rdma_nl_put_driver_u32(struct sk_buff *msg, const char *name, u32 value)
|
||||
{
|
||||
return _rdma_nl_put_driver_u32(msg, name, RDMA_NLDEV_PRINT_TYPE_UNSPEC,
|
||||
|
@ -3,7 +3,7 @@ obj-$(CONFIG_MLX5_INFINIBAND) += mlx5_ib.o
|
||||
|
||||
mlx5_ib-y := main.o cq.o doorbell.o qp.o mem.o srq_cmd.o \
|
||||
srq.o mr.o ah.o mad.o gsi.o ib_virt.o cmd.o \
|
||||
cong.o
|
||||
cong.o restrack.o
|
||||
mlx5_ib-$(CONFIG_INFINIBAND_ON_DEMAND_PAGING) += odp.o
|
||||
mlx5_ib-$(CONFIG_MLX5_ESWITCH) += ib_rep.o
|
||||
mlx5_ib-$(CONFIG_INFINIBAND_USER_ACCESS) += devx.o
|
||||
|
@ -6271,6 +6271,7 @@ static const struct ib_device_ops mlx5_ib_dev_ops = {
|
||||
.disassociate_ucontext = mlx5_ib_disassociate_ucontext,
|
||||
.drain_rq = mlx5_ib_drain_rq,
|
||||
.drain_sq = mlx5_ib_drain_sq,
|
||||
.fill_res_entry = mlx5_ib_fill_res_entry,
|
||||
.get_dev_fw_str = get_dev_fw_str,
|
||||
.get_dma_mr = mlx5_ib_get_dma_mr,
|
||||
.get_link_layer = mlx5_ib_port_link_layer,
|
||||
|
@ -626,6 +626,7 @@ struct mlx5_ib_mr {
|
||||
struct mlx5_async_work cb_work;
|
||||
atomic_t num_pending_prefetch;
|
||||
struct ib_odp_counters odp_stats;
|
||||
bool is_odp_implicit;
|
||||
};
|
||||
|
||||
static inline bool is_odp_mr(struct mlx5_ib_mr *mr)
|
||||
@ -1339,6 +1340,8 @@ struct mlx5_core_dev *mlx5_ib_get_native_port_mdev(struct mlx5_ib_dev *dev,
|
||||
u8 *native_port_num);
|
||||
void mlx5_ib_put_native_port_mdev(struct mlx5_ib_dev *dev,
|
||||
u8 port_num);
|
||||
int mlx5_ib_fill_res_entry(struct sk_buff *msg,
|
||||
struct rdma_restrack_entry *res);
|
||||
|
||||
#if IS_ENABLED(CONFIG_INFINIBAND_USER_ACCESS)
|
||||
int mlx5_ib_devx_create(struct mlx5_ib_dev *dev, bool is_user);
|
||||
|
@ -543,6 +543,8 @@ struct mlx5_ib_mr *mlx5_ib_alloc_implicit_mr(struct mlx5_ib_pd *pd,
|
||||
atomic_set(&imr->num_leaf_free, 0);
|
||||
atomic_set(&imr->num_pending_prefetch, 0);
|
||||
|
||||
imr->is_odp_implicit = true;
|
||||
|
||||
return imr;
|
||||
}
|
||||
|
||||
|
48
drivers/infiniband/hw/mlx5/restrack.c
Normal file
48
drivers/infiniband/hw/mlx5/restrack.c
Normal file
@ -0,0 +1,48 @@
|
||||
// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB
|
||||
/*
|
||||
* Copyright (c) 2019, Mellanox Technologies inc. All rights reserved.
|
||||
*/
|
||||
|
||||
#include <uapi/rdma/rdma_netlink.h>
|
||||
#include <rdma/ib_umem_odp.h>
|
||||
#include <rdma/restrack.h>
|
||||
#include "mlx5_ib.h"
|
||||
|
||||
static int fill_res_mr_entry(struct sk_buff *msg,
|
||||
struct rdma_restrack_entry *res)
|
||||
{
|
||||
struct ib_mr *ibmr = container_of(res, struct ib_mr, res);
|
||||
struct mlx5_ib_mr *mr = to_mmr(ibmr);
|
||||
struct nlattr *table_attr;
|
||||
|
||||
if (!(mr->access_flags & IB_ACCESS_ON_DEMAND))
|
||||
return 0;
|
||||
|
||||
table_attr = nla_nest_start(msg, RDMA_NLDEV_ATTR_DRIVER);
|
||||
if (!table_attr)
|
||||
goto err;
|
||||
|
||||
if (mr->is_odp_implicit) {
|
||||
if (rdma_nl_put_driver_string(msg, "odp", "implicit"))
|
||||
goto err;
|
||||
} else {
|
||||
if (rdma_nl_put_driver_string(msg, "odp", "explicit"))
|
||||
goto err;
|
||||
}
|
||||
|
||||
nla_nest_end(msg, table_attr);
|
||||
return 0;
|
||||
|
||||
err:
|
||||
nla_nest_cancel(msg, table_attr);
|
||||
return -EMSGSIZE;
|
||||
}
|
||||
|
||||
int mlx5_ib_fill_res_entry(struct sk_buff *msg,
|
||||
struct rdma_restrack_entry *res)
|
||||
{
|
||||
if (res->type == RDMA_RESTRACK_MR)
|
||||
return fill_res_mr_entry(msg, res);
|
||||
|
||||
return 0;
|
||||
}
|
@ -156,6 +156,9 @@ int rdma_nl_put_driver_u32_hex(struct sk_buff *msg, const char *name,
|
||||
int rdma_nl_put_driver_u64(struct sk_buff *msg, const char *name, u64 value);
|
||||
int rdma_nl_put_driver_u64_hex(struct sk_buff *msg, const char *name,
|
||||
u64 value);
|
||||
int rdma_nl_put_driver_string(struct sk_buff *msg, const char *name,
|
||||
const char *str);
|
||||
|
||||
struct rdma_restrack_entry *rdma_restrack_get_byid(struct ib_device *dev,
|
||||
enum rdma_restrack_type type,
|
||||
u32 id);
|
||||
|
Loading…
Reference in New Issue
Block a user