Skip to content

Commit

Permalink
mlx5: DR, Replace the check for valid STE entry
Browse files Browse the repository at this point in the history
Validity check is done by reading the next lu_type from the STE, this
check can be replaced by checking the refcount.
This will make the check independent on internal STE structure.

Signed-off-by: Alex Vesker <valex@mellanox.com>
Reviewed-by: Erez Shitrit <erezsh@mellanox.com>
Signed-off-by: Yishai Hadas <yishaih@mellanox.com>
  • Loading branch information
alexvesker authored and yishaih committed Jul 15, 2020
1 parent e055d8c commit 8a3e900
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 26 deletions.
6 changes: 3 additions & 3 deletions providers/mlx5/dr_rule.c
Expand Up @@ -263,7 +263,7 @@ static struct dr_ste *dr_rule_rehash_copy_ste(struct mlx5dv_dr_matcher *matcher,
new_idx = dr_ste_calc_hash_index(hw_ste, new_htbl);
new_ste = &new_htbl->ste_arr[new_idx];

if (dr_ste_not_used_ste(new_ste)) {
if (dr_ste_is_not_used(new_ste)) {
dr_htbl_get(new_htbl);
list_add_tail(dr_ste_get_miss_list(new_ste), &new_ste->miss_list_node);
} else {
Expand Down Expand Up @@ -349,7 +349,7 @@ static int dr_rule_rehash_copy_htbl(struct mlx5dv_dr_matcher *matcher,

for (i = 0; i < cur_entries; i++) {
cur_ste = &cur_htbl->ste_arr[i];
if (dr_ste_not_used_ste(cur_ste)) /* Empty, nothing to copy */
if (dr_ste_is_not_used(cur_ste)) /* Empty, nothing to copy */
continue;

err = dr_rule_rehash_copy_miss_list(matcher,
Expand Down Expand Up @@ -810,7 +810,7 @@ static struct dr_ste *dr_rule_handle_ste_branch(struct mlx5dv_dr_rule *rule,
miss_list = &cur_htbl->chunk->miss_list[index];
ste = &cur_htbl->ste_arr[index];

if (dr_ste_not_used_ste(ste)) {
if (dr_ste_is_not_used(ste)) {
if (dr_rule_handle_empty_entry(matcher, nic_matcher, cur_htbl,
ste, ste_location,
hw_ste, miss_list,
Expand Down
2 changes: 1 addition & 1 deletion providers/mlx5/dr_send.c
Expand Up @@ -721,7 +721,7 @@ int dr_send_postsend_htbl(struct mlx5dv_dr_domain *dmn, struct dr_ste_htbl *htbl

/* Copy all ste's on the data buffer, need to add the bit_mask */
for (j = 0; j < num_stes_per_iter; j++) {
if (dr_ste_is_not_valid_entry(htbl->ste_arr[ste_index + j].hw_ste)) {
if (dr_ste_is_not_used(&htbl->ste_arr[ste_index + j])) {
memcpy(data + (j * DR_STE_SIZE),
formated_ste, DR_STE_SIZE);
} else {
Expand Down
20 changes: 0 additions & 20 deletions providers/mlx5/dr_ste.c
Expand Up @@ -546,26 +546,6 @@ void dr_ste_always_miss_addr(struct dr_ste *ste, uint64_t miss_addr)
dr_ste_set_always_miss((struct dr_hw_ste_format *)ste->hw_ste);
}

/*
* The assumption here is that we don't update the ste->hw_ste if it is not
* used ste, so it will be all zero, checking the next_lu_type.
*/
bool dr_ste_is_not_valid_entry(uint8_t *p_hw_ste)
{
struct dr_hw_ste_format *hw_ste = (struct dr_hw_ste_format *)p_hw_ste;

if (DR_STE_GET(general, hw_ste, next_lu_type) ==
DR_STE_LU_TYPE_NOP)
return true;

return false;
}

bool dr_ste_not_used_ste(struct dr_ste *ste)
{
return !atomic_load(&ste->refcount);
}

/* Init one ste as a pattern for ste data array */
void dr_ste_set_formated_ste(uint16_t gvmi,
struct dr_domain_rx_tx *nic_dmn,
Expand Down
7 changes: 5 additions & 2 deletions providers/mlx5/mlx5dv_dr.h
Expand Up @@ -308,7 +308,6 @@ uint64_t dr_ste_get_miss_addr(uint8_t *hw_ste);
void dr_ste_set_hit_addr(uint8_t *hw_ste, uint64_t icm_addr, uint32_t ht_size);
void dr_ste_always_miss_addr(struct dr_ste *ste, uint64_t miss_addr);
void dr_ste_set_bit_mask(uint8_t *hw_ste_p, uint8_t *bit_mask);
bool dr_ste_not_used_ste(struct dr_ste *ste);
bool dr_ste_is_last_in_rule(struct dr_matcher_rx_tx *nic_matcher,
uint8_t ste_location);
void dr_ste_rx_set_flow_tag(uint8_t *hw_ste_p, uint32_t flow_tag);
Expand Down Expand Up @@ -341,6 +340,11 @@ static inline void dr_ste_get(struct dr_ste *ste)
atomic_fetch_add(&ste->refcount, 1);
}

static inline bool dr_ste_is_not_used(struct dr_ste *ste)
{
return !atomic_load(&ste->refcount);
}

void dr_ste_set_hit_addr_by_next_htbl(uint8_t *hw_ste,
struct dr_ste_htbl *next_htbl);
bool dr_ste_equal_tag(void *src, void *dst);
Expand Down Expand Up @@ -949,7 +953,6 @@ void dr_icm_pool_destroy(struct dr_icm_pool *pool);
struct dr_icm_chunk *dr_icm_alloc_chunk(struct dr_icm_pool *pool,
enum dr_icm_chunk_size chunk_size);
void dr_icm_free_chunk(struct dr_icm_chunk *chunk);
bool dr_ste_is_not_valid_entry(uint8_t *p_hw_ste);
int dr_ste_htbl_init_and_postsend(struct mlx5dv_dr_domain *dmn,
struct dr_domain_rx_tx *nic_dmn,
struct dr_ste_htbl *htbl,
Expand Down

0 comments on commit 8a3e900

Please sign in to comment.