Skip to content

Commit 146d2f1

Browse files
majdmellanoxdledford
authored andcommitted
IB/mlx5: Allocate a Transport Domain for each ucontext
Transport Domain groups several TIS and TIR object. By grouping these object, it defines wheather local loopback packets that are sent from the TIS objects in the group are received by the TIR objects in the same group. Allocate a Transport Domain(TD) for each user context to be used in the future by Raw Packet QP for Self-Loopback Control. Signed-off-by: Majd Dibbiny <[email protected]> Reviewed-by: Matan Barak <[email protected]> Signed-off-by: Doug Ledford <[email protected]>
1 parent a14c2d4 commit 146d2f1

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

drivers/infiniband/hw/mlx5/main.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -942,6 +942,13 @@ static struct ib_ucontext *mlx5_ib_alloc_ucontext(struct ib_device *ibdev,
942942
context->ibucontext.invalidate_range = &mlx5_ib_invalidate_range;
943943
#endif
944944

945+
if (MLX5_CAP_GEN(dev->mdev, log_max_transport_domain)) {
946+
err = mlx5_core_alloc_transport_domain(dev->mdev,
947+
&context->tdn);
948+
if (err)
949+
goto out_uars;
950+
}
951+
945952
INIT_LIST_HEAD(&context->db_page_list);
946953
mutex_init(&context->db_page_mutex);
947954

@@ -964,7 +971,7 @@ static struct ib_ucontext *mlx5_ib_alloc_ucontext(struct ib_device *ibdev,
964971

965972
err = ib_copy_to_udata(udata, &resp, resp.response_length);
966973
if (err)
967-
goto out_uars;
974+
goto out_td;
968975

969976
uuari->ver = ver;
970977
uuari->num_low_latency_uuars = req.num_low_latency_uuars;
@@ -974,6 +981,10 @@ static struct ib_ucontext *mlx5_ib_alloc_ucontext(struct ib_device *ibdev,
974981

975982
return &context->ibucontext;
976983

984+
out_td:
985+
if (MLX5_CAP_GEN(dev->mdev, log_max_transport_domain))
986+
mlx5_core_dealloc_transport_domain(dev->mdev, context->tdn);
987+
977988
out_uars:
978989
for (i--; i >= 0; i--)
979990
mlx5_cmd_free_uar(dev->mdev, uars[i].index);
@@ -998,6 +1009,9 @@ static int mlx5_ib_dealloc_ucontext(struct ib_ucontext *ibcontext)
9981009
struct mlx5_uuar_info *uuari = &context->uuari;
9991010
int i;
10001011

1012+
if (MLX5_CAP_GEN(dev->mdev, log_max_transport_domain))
1013+
mlx5_core_dealloc_transport_domain(dev->mdev, context->tdn);
1014+
10011015
for (i = 0; i < uuari->num_uars; i++) {
10021016
if (mlx5_cmd_free_uar(dev->mdev, uuari->uars[i].index))
10031017
mlx5_ib_warn(dev, "failed to free UAR 0x%x\n", uuari->uars[i].index);

drivers/infiniband/hw/mlx5/mlx5_ib.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
#include <linux/mlx5/qp.h>
4343
#include <linux/mlx5/srq.h>
4444
#include <linux/types.h>
45+
#include <linux/mlx5/transobj.h>
4546

4647
#define mlx5_ib_dbg(dev, format, arg...) \
4748
pr_debug("%s:%s:%d:(pid %d): " format, (dev)->ib_dev.name, __func__, \
@@ -110,6 +111,8 @@ struct mlx5_ib_ucontext {
110111
struct mutex db_page_mutex;
111112
struct mlx5_uuar_info uuari;
112113
u8 cqe_version;
114+
/* Transport Domain number */
115+
u32 tdn;
113116
};
114117

115118
static inline struct mlx5_ib_ucontext *to_mucontext(struct ib_ucontext *ibucontext)

0 commit comments

Comments
 (0)