Skip to content

Commit

Permalink
Merge pull request #1371 from yishaih/mlx5_dr
Browse files Browse the repository at this point in the history
mlx5: DR, Few extensions and improvements
  • Loading branch information
yishaih committed Jul 25, 2023
2 parents 3951cf8 + 50122fb commit aba30bd
Show file tree
Hide file tree
Showing 13 changed files with 185 additions and 80 deletions.
41 changes: 36 additions & 5 deletions providers/mlx5/dr_action.c
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,28 @@ dr_action_validate_and_get_next_state(enum dr_action_domain action_domain,
return 0;
}

static int dr_action_send_modify_header_args(struct mlx5dv_dr_action *action,
uint8_t send_ring_idx)
{
int ret;

if (!(action->rewrite.args_send_qp & (1 << send_ring_idx))) {
ret = dr_send_postsend_args(action->rewrite.dmn,
dr_arg_get_object_id(action->rewrite.ptrn_arg.arg),
action->rewrite.param.num_of_actions,
action->rewrite.param.data,
send_ring_idx);
if (ret) {
dr_dbg(action->rewrite.dmn, "Failed writing args object\n");
return ret;
}

action->rewrite.args_send_qp |= 1 << send_ring_idx;
}

return 0;
}

#define WITH_VLAN_NUM_HW_ACTIONS 6

int dr_actions_build_ste_arr(struct mlx5dv_dr_matcher *matcher,
Expand All @@ -631,7 +653,8 @@ int dr_actions_build_ste_arr(struct mlx5dv_dr_matcher *matcher,
uint32_t num_actions,
uint8_t *ste_arr,
uint32_t *new_hw_ste_arr_sz,
struct cross_dmn_params *cross_dmn_p)
struct cross_dmn_params *cross_dmn_p,
uint8_t send_ring_idx)
{
struct dr_domain_rx_tx *nic_dmn = nic_matcher->nic_tbl->nic_dmn;
bool rx_rule = nic_dmn->type == DR_DOMAIN_NIC_TYPE_RX;
Expand Down Expand Up @@ -670,10 +693,10 @@ int dr_actions_build_ste_arr(struct mlx5dv_dr_matcher *matcher,
dr_dbg(dmn, "Destination table belongs to a different domain\n");
goto out_invalid_arg;
}
if (dest_tbl->level <= matcher->tbl->level) {
dr_dbg(dmn, "Destination table level should be higher than source table\n");
goto out_invalid_arg;
}

if (dest_tbl->level <= matcher->tbl->level)
dr_dbg(dmn, "Destination table level not higher than source\n");

attr.final_icm_addr = rx_rule ?
dr_icm_pool_get_chunk_icm_addr(dest_tbl->rx.s_anchor->chunk) :
dr_icm_pool_get_chunk_icm_addr(dest_tbl->tx.s_anchor->chunk);
Expand Down Expand Up @@ -754,6 +777,10 @@ int dr_actions_build_ste_arr(struct mlx5dv_dr_matcher *matcher,
action->rewrite.ptrn_arg.ptrn->rewrite_param.num_of_actions;
attr.decap_pat_idx =
action->rewrite.ptrn_arg.ptrn->rewrite_param.index;
if (dmn->info.use_mqs) {
if (dr_action_send_modify_header_args(action, send_ring_idx))
goto out_errno;
}
} else {
attr.decap_index = action->rewrite.param.index;
attr.decap_actions = action->rewrite.param.num_of_actions;
Expand All @@ -780,6 +807,10 @@ int dr_actions_build_ste_arr(struct mlx5dv_dr_matcher *matcher,
attr.modify_actions =
action->rewrite.ptrn_arg.ptrn->rewrite_param.
num_of_actions;
if (dmn->info.use_mqs) {
if (dr_action_send_modify_header_args(action, send_ring_idx))
goto out_errno;
}
} else {
attr.modify_actions = action->rewrite.param.num_of_actions;
attr.modify_index = action->rewrite.param.index;
Expand Down
14 changes: 8 additions & 6 deletions providers/mlx5/dr_arg.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,14 @@ struct dr_arg_obj *dr_arg_get_obj(struct dr_arg_mngr *mngr,
return NULL;
}

/* write it into the hw */
ret = dr_send_postsend_args(mngr->dmn, dr_arg_get_object_id(arg_obj),
num_of_actions, data);
if (ret) {
dr_dbg(mngr->dmn, "Failed writing args object\n");
goto put_obj;
if (!mngr->dmn->info.use_mqs) {
/* write it into the hw */
ret = dr_send_postsend_args(mngr->dmn, dr_arg_get_object_id(arg_obj),
num_of_actions, data, 0);
if (ret) {
dr_dbg(mngr->dmn, "Failed writing args object\n");
goto put_obj;
}
}

return arg_obj;
Expand Down
1 change: 1 addition & 0 deletions providers/mlx5/dr_domain.c
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,7 @@ static int dr_domain_check_icm_memory_caps(struct mlx5dv_dr_domain *dmn)
max_req_chunks_log = max_req_bytes_log - DR_STE_LOG_SIZE;
dmn->info.max_log_sw_icm_sz =
min_t(uint32_t, DR_CHUNK_SIZE_1024K, max_req_chunks_log);
dmn->info.max_log_sw_icm_rehash_sz = dmn->info.max_log_sw_icm_sz;

if (dmn->info.caps.sw_format_ver >= MLX5_HW_CONNECTX_6DX) {
if (dmn->info.caps.log_modify_pattern_icm_size < DR_CHUNK_SIZE_4K +
Expand Down
2 changes: 1 addition & 1 deletion providers/mlx5/dr_matcher.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ static bool dr_mask_is_tnl_geneve_set(struct dr_match_misc *misc)

static bool dr_mask_is_ib_l4_set(struct dr_match_misc *misc)
{
return misc->bth_opcode || misc->bth_dst_qp;
return misc->bth_opcode || misc->bth_dst_qp || misc->bth_a;
}

static int dr_matcher_supp_geneve_tlv_option(struct dr_devx_caps *caps)
Expand Down
48 changes: 21 additions & 27 deletions providers/mlx5/dr_rule.c
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,8 @@ static int dr_rule_rehash_copy_htbl(struct mlx5dv_dr_matcher *matcher,
struct dr_matcher_rx_tx *nic_matcher,
struct dr_ste_htbl *cur_htbl,
struct dr_ste_htbl *new_htbl,
struct list_head *update_list)
struct list_head *update_list,
uint8_t lock_index)
{
struct dr_ste *cur_ste;
int cur_entries;
Expand All @@ -383,6 +384,15 @@ static int dr_rule_rehash_copy_htbl(struct mlx5dv_dr_matcher *matcher,
update_list);
if (err)
goto clean_copy;

/* In order to decrease memory allocation of ste_info struct send
* the current table raw now.
*/
err = dr_rule_send_update_list(update_list, matcher->tbl->dmn, false, lock_index);
if (err) {
dr_dbg(matcher->tbl->dmn, "Failed updating table to HW\n");
goto clean_copy;
}
}

clean_copy:
Expand All @@ -399,7 +409,6 @@ static struct dr_ste_htbl *dr_rule_rehash_htbl_common(struct mlx5dv_dr_matcher *
{
struct dr_domain_rx_tx *nic_dmn = nic_matcher->nic_tbl->nic_dmn;
struct mlx5dv_dr_domain *dmn = matcher->tbl->dmn;
struct dr_ste_send_info *del_ste_info, *tmp_ste_info;
uint8_t formated_ste[DR_STE_SIZE] = {};
struct dr_ste_send_info *ste_info;
struct dr_htbl_connect_info info;
Expand Down Expand Up @@ -442,7 +451,8 @@ static struct dr_ste_htbl *dr_rule_rehash_htbl_common(struct mlx5dv_dr_matcher *
nic_matcher,
cur_htbl,
new_htbl,
&rehash_table_send_list);
&rehash_table_send_list,
lock_index);
if (err)
goto free_new_htbl;

Expand All @@ -454,17 +464,6 @@ static struct dr_ste_htbl *dr_rule_rehash_htbl_common(struct mlx5dv_dr_matcher *
goto free_new_htbl;
}

/*
* Writing to the hw is done in regular order of rehash_table_send_list,
* in order to have the origin data written before the miss address of
* collision entries, if exists.
*/
if (dr_rule_send_update_list(&rehash_table_send_list, dmn, false,
lock_index)) {
dr_dbg(dmn, "Failed updating table to HW\n");
goto free_ste_list;
}

/* Connect previous hash table to current */
if (ste_location == 1) {
/* The previous table is an anchor, anchors size is always one STE */
Expand Down Expand Up @@ -499,14 +498,6 @@ static struct dr_ste_htbl *dr_rule_rehash_htbl_common(struct mlx5dv_dr_matcher *

return new_htbl;

free_ste_list:
/* Clean all ste_info's from the new table */
list_for_each_safe(&rehash_table_send_list, del_ste_info, tmp_ste_info,
send_list) {
list_del(&del_ste_info->send_list);
free(del_ste_info);
}

free_new_htbl:
dr_ste_htbl_free(new_htbl);
free_ste_info:
Expand Down Expand Up @@ -578,7 +569,8 @@ static struct dr_ste_htbl *dr_rule_rehash(struct mlx5dv_dr_rule *rule,
enum dr_icm_chunk_size new_size;

new_size = dr_icm_next_higher_chunk(cur_htbl->chunk_size);
new_size = min_t(uint32_t, new_size, dmn->info.max_log_sw_icm_sz);
new_size = min_t(uint32_t, new_size,
dmn->info.max_log_sw_icm_rehash_sz);

if (new_size == cur_htbl->chunk_size)
return NULL; /* Skip rehash, we already at the max size */
Expand Down Expand Up @@ -1375,15 +1367,17 @@ dr_rule_create_rule_nic(struct mlx5dv_dr_rule *rule,
if (ret)
return ret;

/* Set the lock index, and use the relative lock */
dr_rule_lock(nic_rule, hw_ste_arr);

/* Set the actions values/addresses inside the ste array */
ret = dr_actions_build_ste_arr(matcher, nic_matcher, actions,
num_actions, hw_ste_arr,
&new_hw_ste_arr_sz,
&cross_dmn_p);
&cross_dmn_p,
nic_rule->lock_index);
if (ret)
return ret;

dr_rule_lock(nic_rule, hw_ste_arr);
goto out_unlock;

cur_htbl = nic_matcher->s_htbl;

Expand Down
20 changes: 7 additions & 13 deletions providers/mlx5/dr_send.c
Original file line number Diff line number Diff line change
Expand Up @@ -1001,15 +1001,14 @@ int dr_send_postsend_pattern(struct mlx5dv_dr_domain *dmn,
}

int dr_send_postsend_args(struct mlx5dv_dr_domain *dmn, uint64_t arg_id,
uint16_t num_of_actions, uint8_t *actions_data)
uint16_t num_of_actions, uint8_t *actions_data,
uint32_t ring_index)
{
struct postsend_info send_info = {};
int data_len, iter = 0, cur_sent;
uint64_t addr;
int num_qps;
int i, ret;
int ret;

num_qps = dmn->info.use_mqs ? DR_MAX_SEND_RINGS : 1;
addr = (uintptr_t)actions_data;
data_len = num_of_actions * DR_MODIFY_ACTION_SIZE;

Expand All @@ -1021,15 +1020,10 @@ int dr_send_postsend_args(struct mlx5dv_dr_domain *dmn, uint64_t arg_id,
send_info.write.lkey = 0;
send_info.remote_addr = arg_id + iter;

/* To avoid race between action creation and its use in other QP
* write it in all QP's.
*/
for (i = 0; i < num_qps; i++) {
ret = dr_postsend_icm_data(dmn, &send_info, i);
if (ret) {
errno = ret;
goto out;
}
ret = dr_postsend_icm_data(dmn, &send_info, ring_index);
if (ret) {
errno = ret;
goto out;
}

iter++;
Expand Down

0 comments on commit aba30bd

Please sign in to comment.