Skip to content

Commit

Permalink
mlx5: DR, Add new action of type dest_devx_tir
Browse files Browse the repository at this point in the history
This action enables us to create rules that steer packets to a DEVX TIR
object.

Signed-off-by: Muhammad Sammar <muhammads@mellanox.com>
Reviewed-by: Alex Vesker <valex@mellanox.com>
Signed-off-by: Yishai Hadas <yishaih@mellanox.com>
  • Loading branch information
Muhammad Sammar authored and yishaih committed Jul 14, 2020
1 parent f6448c1 commit ba78fed
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 16 deletions.
2 changes: 2 additions & 0 deletions debian/ibverbs-providers.symbols
Expand Up @@ -22,6 +22,7 @@ libmlx5.so.1 ibverbs-providers #MINVER#
MLX5_1.12@MLX5_1.12 28
MLX5_1.13@MLX5_1.13 29
MLX5_1.14@MLX5_1.14 30
MLX5_1.15@MLX5_1.15 31
mlx5dv_init_obj@MLX5_1.0 13
mlx5dv_init_obj@MLX5_1.2 15
mlx5dv_query_device@MLX5_1.0 13
Expand Down Expand Up @@ -103,6 +104,7 @@ libmlx5.so.1 ibverbs-providers #MINVER#
mlx5dv_dr_domain_set_reclaim_device_memory@MLX5_1.14 30
mlx5dv_modify_qp_lag_port@MLX5_1.14 30
mlx5dv_query_qp_lag_port@MLX5_1.14 30
mlx5dv_dr_action_create_dest_devx_tir@MLX5_1.15 31
libefa.so.1 ibverbs-providers #MINVER#
* Build-Depends-Package: libibverbs-dev
EFA_1.0@EFA_1.0 24
Expand Down
2 changes: 1 addition & 1 deletion providers/mlx5/CMakeLists.txt
Expand Up @@ -11,7 +11,7 @@ if (MLX5_MW_DEBUG)
endif()

rdma_shared_provider(mlx5 libmlx5.map
1 1.14.${PACKAGE_VERSION}
1 1.15.${PACKAGE_VERSION}
buf.c
cq.c
dbrec.c
Expand Down
44 changes: 34 additions & 10 deletions providers/mlx5/dr_action.c
Expand Up @@ -598,14 +598,14 @@ int dr_actions_build_ste_arr(struct mlx5dv_dr_matcher *matcher,
action->dest_tbl->tx.s_anchor->chunk->icm_addr;
break;
case DR_ACTION_TYP_QP:
{
struct mlx5_qp *mlx5_qp = to_mqp(action->qp);
if (action->dest_qp.is_qp)
attr.final_icm_addr = to_mqp(action->dest_qp.qp)->tir_icm_addr;
else
attr.final_icm_addr = action->dest_qp.devx_tir->rx_icm_addr;

if (!mlx5_qp->tir_icm_addr) {
dr_dbg(dmn, "Unsupported QP for action\n");
goto out_invalid_arg;
}
attr.final_icm_addr = mlx5_qp->tir_icm_addr;
if (!attr.final_icm_addr) {
dr_dbg(dmn, "Unsupported TIR/QP for action\n");
goto out_invalid_arg;
}
break;
case DR_ACTION_TYP_CTR:
Expand Down Expand Up @@ -742,8 +742,13 @@ int dr_actions_build_attr(struct mlx5dv_dr_matcher *matcher,
attr[i].action = actions[i]->rewrite.flow_action;
break;
case DR_ACTION_TYP_QP:
attr[i].type = MLX5DV_FLOW_ACTION_DEST_IBV_QP;
attr[i].qp = actions[i]->qp;
if (actions[i]->dest_qp.is_qp) {
attr[i].type = MLX5DV_FLOW_ACTION_DEST_IBV_QP;
attr[i].qp = actions[i]->dest_qp.qp;
} else {
attr[i].type = MLX5DV_FLOW_ACTION_DEST_DEVX;
attr[i].obj = actions[i]->dest_qp.devx_tir;
}
break;
case DR_ACTION_TYP_CTR:
attr[i].type = MLX5DV_FLOW_ACTION_COUNTERS_DEVX;
Expand Down Expand Up @@ -913,8 +918,27 @@ mlx5dv_dr_action_create_dest_ibv_qp(struct ibv_qp *ibqp)
if (!action)
return NULL;

action->qp = ibqp;
action->dest_qp.is_qp = true;
action->dest_qp.qp = ibqp;

return action;
}

struct mlx5dv_dr_action *
mlx5dv_dr_action_create_dest_devx_tir(struct mlx5dv_devx_obj *devx_obj)
{
struct mlx5dv_dr_action *action;

if (devx_obj->type != MLX5_DEVX_TIR) {
errno = EINVAL;
return NULL;
}

action = dr_action_create_generic(DR_ACTION_TYP_QP);
if (!action)
return NULL;

action->dest_qp.devx_tir = devx_obj;
return action;
}

Expand Down
12 changes: 9 additions & 3 deletions providers/mlx5/dr_dbg.c
Expand Up @@ -69,6 +69,7 @@ enum dr_dump_rec_type {
DR_DUMP_REC_TYPE_ACTION_VPORT = 3408,
DR_DUMP_REC_TYPE_ACTION_DECAP_L2 = 3409,
DR_DUMP_REC_TYPE_ACTION_DECAP_L3 = 3410,
DR_DUMP_REC_TYPE_ACTION_DEVX_TIR = 3411,
DR_DUMP_REC_TYPE_ACTION_METER = 3414,
};

Expand Down Expand Up @@ -104,9 +105,14 @@ static int dr_dump_rule_action_mem(FILE *f, const uint64_t rule_id,
(uint64_t)(uintptr_t)action->dest_tbl);
break;
case DR_ACTION_TYP_QP:
ret = fprintf(f, "%d,0x%" PRIx64 ",0x%" PRIx64 ",0x%x\n",
DR_DUMP_REC_TYPE_ACTION_QP, action_id, rule_id,
action->qp->qp_num);
if (action->dest_qp.is_qp)
ret = fprintf(f, "%d,0x%" PRIx64 ",0x%" PRIx64 ",0x%x\n",
DR_DUMP_REC_TYPE_ACTION_QP, action_id,
rule_id, action->dest_qp.qp->qp_num);
else
ret = fprintf(f, "%d,0x%" PRIx64 ",0x%" PRIx64 ",0x%" PRIx64 "\n",
DR_DUMP_REC_TYPE_ACTION_DEVX_TIR, action_id,
rule_id, action->dest_qp.devx_tir->rx_icm_addr);
break;
case DR_ACTION_TYP_CTR:
ret = fprintf(f, "%d,0x%" PRIx64 ",0x%" PRIx64 ",0x%x\n",
Expand Down
5 changes: 5 additions & 0 deletions providers/mlx5/libmlx5.map
Expand Up @@ -141,3 +141,8 @@ MLX5_1.14 {
mlx5dv_modify_qp_lag_port;
mlx5dv_query_qp_lag_port;
} MLX5_1.13;

MLX5_1.15 {
global:
mlx5dv_dr_action_create_dest_devx_tir;
} MLX5_1.14;
1 change: 1 addition & 0 deletions providers/mlx5/man/CMakeLists.txt
Expand Up @@ -57,6 +57,7 @@ rdma_alias_man_pages(
mlx5dv_devx_umem_reg.3 mlx5dv_devx_umem_dereg.3
mlx5dv_dr_flow.3 mlx5dv_dr_action_create_dest_table.3
mlx5dv_dr_flow.3 mlx5dv_dr_action_create_dest_ibv_qp.3
mlx5dv_dr_flow.3 mlx5dv_dr_action_create_dest_devx_tir.3
mlx5dv_dr_flow.3 mlx5dv_dr_action_create_dest_vport.3
mlx5dv_dr_flow.3 mlx5dv_dr_action_create_flow_counter.3
mlx5dv_dr_flow.3 mlx5dv_dr_action_create_drop.3
Expand Down
6 changes: 5 additions & 1 deletion providers/mlx5/man/mlx5dv_dr_flow.3.md
Expand Up @@ -24,7 +24,7 @@ mlx5dv_dr_action_create_default_miss - Create default miss action

mlx5dv_dr_action_create_tag - Create tag actions

mlx5dv_dr_action_create_dest_ibv_qp, mlx5dv_dr_action_create_dest_table, mlx5dv_dr_action_create_dest_vport - Create packet destination actions
mlx5dv_dr_action_create_dest_ibv_qp, mlx5dv_dr_action_create_dest_table, mlx5dv_dr_action_create_dest_vport, mlx5dv_dr_action_create_dest_devx_tir - Create packet destination actions

mlx5dv_dr_action_create_packet_reformat - Create packet reformat actions

Expand Down Expand Up @@ -94,6 +94,9 @@ struct mlx5dv_dr_action *mlx5dv_dr_action_create_dest_vport(
struct mlx5dv_dr_domain *domain,
uint32_t vport);

struct mlx5dv_dr_action *mlx5dv_dr_action_create_dest_devx_tir(
struct mlx5dv_devx_obj *devx_obj);

struct mlx5dv_dr_action *mlx5dv_dr_action_create_packet_reformat(
struct mlx5dv_dr_domain *domain,
uint32_t flags,
Expand Down Expand Up @@ -187,6 +190,7 @@ Action: Destination
*mlx5dv_dr_action_create_dest_ibv_qp* creates a terminating action delivering the packet to a QP, defined by **ibqp**. Valid only on domain type NIC_RX.
*mlx5dv_dr_action_create_dest_table* creates a forwarding action to another flow table, defined by **table**. The destination **table** must be from the same domain with a level higher than zero.
*mlx5dv_dr_action_create_dest_vport* creates a forwarding action to a **vport** on the same **domain**. Valid only on domain type FDB.
*mlx5dv_dr_action_create_dest_devx_tir* creates a terminating action delivering the packet to a TIR, defined by **devx_obj**. Valid only on domain type NIC_RX.
Action: Packet Reformat
*mlx5dv_dr_action_create_packet_reformat* create a packet reformat context and action in the **domain**. The **reformat_type**, **data_sz** and **data** are defined in *man mlx5dv_create_flow_action_packet_reformat*.
Expand Down
3 changes: 3 additions & 0 deletions providers/mlx5/mlx5dv.h
Expand Up @@ -1497,6 +1497,9 @@ struct mlx5dv_dr_action *
mlx5dv_dr_action_create_dest_vport(struct mlx5dv_dr_domain *domain,
uint32_t vport);

struct mlx5dv_dr_action *
mlx5dv_dr_action_create_dest_devx_tir(struct mlx5dv_devx_obj *devx_obj);

struct mlx5dv_dr_action *mlx5dv_dr_action_create_drop(void);

struct mlx5dv_dr_action *mlx5dv_dr_action_create_default_miss(void);
Expand Down
8 changes: 7 additions & 1 deletion providers/mlx5/mlx5dv_dr.h
Expand Up @@ -734,7 +734,13 @@ struct mlx5dv_dr_action {
struct dr_devx_vport_cap *caps;
uint32_t num;
} vport;
struct ibv_qp *qp;
struct {
bool is_qp;
union {
struct mlx5dv_devx_obj *devx_tir;
struct ibv_qp *qp;
};
} dest_qp;
struct mlx5dv_devx_obj *devx_obj;
uint32_t flow_tag;
};
Expand Down

0 comments on commit ba78fed

Please sign in to comment.