Skip to content

Commit

Permalink
Merge pull request #1416 from yishaih/mlx5_misc
Browse files Browse the repository at this point in the history
mlx5: Misc. items
  • Loading branch information
yishaih committed Jan 3, 2024
2 parents 331d5a0 + 5afb79f commit e32e337
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
20 changes: 16 additions & 4 deletions providers/mlx5/dr_action.c
Expand Up @@ -684,6 +684,7 @@ int dr_actions_build_ste_arr(struct mlx5dv_dr_matcher *matcher,
switch (action_type) {
case DR_ACTION_TYP_DROP:
attr.final_icm_addr = nic_dmn->drop_icm_addr;
attr.hit_gvmi = nic_dmn->drop_icm_addr >> 48;
break;
case DR_ACTION_TYP_FT:
{
Expand Down Expand Up @@ -872,10 +873,21 @@ int dr_actions_build_ste_arr(struct mlx5dv_dr_matcher *matcher,
dr_dbg(dmn, "Destination vport belongs to a different domain\n");
goto out_invalid_arg;
}
attr.hit_gvmi = action->vport.caps->vhca_gvmi;
attr.final_icm_addr = rx_rule ?
action->vport.caps->icm_address_rx :
action->vport.caps->icm_address_tx;
if (unlikely(rx_rule && action->vport.caps->num == WIRE_PORT)) {
if (dmn->type == MLX5DV_DR_DOMAIN_TYPE_NIC_RX) {
dr_dbg(dmn, "Forwarding to uplink vport on RX is not allowed\n");
goto out_invalid_arg;
}

/* silently drop the packets for RX side of FDB */
attr.final_icm_addr = nic_dmn->drop_icm_addr;
attr.hit_gvmi = nic_dmn->drop_icm_addr >> 48;
} else {
attr.hit_gvmi = action->vport.caps->vhca_gvmi;
attr.final_icm_addr = rx_rule ?
action->vport.caps->icm_address_rx :
action->vport.caps->icm_address_tx;
}
break;
case DR_ACTION_TYP_DEST_ARRAY:
if (action->dest_array.dmn != dmn) {
Expand Down
12 changes: 8 additions & 4 deletions providers/mlx5/dr_ptrn.c
Expand Up @@ -54,12 +54,13 @@ static bool dr_ptrn_compare_modify_hdr(size_t cur_num_of_actions,
}

static bool dr_ptrn_compare_pattern(enum dr_ptrn_type type,
enum dr_ptrn_type cur_type,
size_t cur_num_of_actions,
__be64 cur_hw_action[],
size_t num_of_actions,
__be64 hw_action[])
{
if (cur_num_of_actions != num_of_actions)
if ((cur_num_of_actions != num_of_actions) || (cur_type != type))
return false;

switch (type) {
Expand Down Expand Up @@ -87,6 +88,7 @@ dr_ptrn_find_cached_pattern(struct dr_ptrn_mngr *mngr,

list_for_each_safe(&mngr->ptrn_list, cached_pattern, tmp, list) {
if (dr_ptrn_compare_pattern(type,
cached_pattern->type,
cached_pattern->rewrite_param.num_of_actions,
(__be64 *)cached_pattern->rewrite_param.data,
num_of_actions,
Expand All @@ -101,8 +103,8 @@ dr_ptrn_find_cached_pattern(struct dr_ptrn_mngr *mngr,
}

static struct dr_ptrn_obj *
dr_ptrn_alloc_pattern(struct dr_ptrn_mngr *mngr,
uint16_t num_of_actions, uint8_t *data)
dr_ptrn_alloc_pattern(struct dr_ptrn_mngr *mngr, uint16_t num_of_actions,
uint8_t *data, enum dr_ptrn_type type)
{
struct dr_ptrn_obj *pattern;
struct dr_icm_chunk *chunk;
Expand Down Expand Up @@ -135,6 +137,8 @@ dr_ptrn_alloc_pattern(struct dr_ptrn_mngr *mngr,
goto free_pattern;
}

pattern->type = type;

memcpy(pattern->rewrite_param.data, data, num_of_actions * DR_MODIFY_ACTION_SIZE);
pattern->rewrite_param.chunk = chunk;
pattern->rewrite_param.index = index;
Expand Down Expand Up @@ -178,7 +182,7 @@ dr_ptrn_cache_get_pattern(struct dr_ptrn_mngr *mngr,
(__be64 *)data);
if (!pattern) {
/* Alloc and add new pattern to cache */
pattern = dr_ptrn_alloc_pattern(mngr, num_of_actions, data);
pattern = dr_ptrn_alloc_pattern(mngr, num_of_actions, data, type);
if (!pattern)
goto out_unlock;

Expand Down
1 change: 1 addition & 0 deletions providers/mlx5/mlx5dv_dr.h
Expand Up @@ -1243,6 +1243,7 @@ struct dr_ptrn_obj {
struct dr_rewrite_param rewrite_param;
atomic_int refcount;
struct list_node list;
enum dr_ptrn_type type;
};

struct dr_arg_obj {
Expand Down

0 comments on commit e32e337

Please sign in to comment.