Skip to content

Commit

Permalink
mlx5: DR, Call ste_builder directly with tag pointer
Browse files Browse the repository at this point in the history
Instead of getting the tag in each function, call the builder directly
with the tag. This will allow to use the same function for building the
tag and the bitmask.

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 8a3e900 commit 77f2d0a
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 71 deletions.
103 changes: 33 additions & 70 deletions providers/mlx5/dr_ste.c
Expand Up @@ -189,6 +189,13 @@ static uint16_t dr_ste_conv_bit_to_byte_mask(uint8_t *bit_mask)
return byte_mask;
}

static uint8_t *dr_ste_get_tag(uint8_t *hw_ste_p)
{
struct dr_hw_ste_format *hw_ste = (struct dr_hw_ste_format *)hw_ste_p;

return hw_ste->tag;
}

void dr_ste_set_bit_mask(uint8_t *hw_ste_p, uint8_t *bit_mask)
{
struct dr_hw_ste_format *hw_ste = (struct dr_hw_ste_format *)hw_ste_p;
Expand Down Expand Up @@ -779,7 +786,7 @@ int dr_ste_build_ste_arr(struct mlx5dv_dr_matcher *matcher,

dr_ste_set_bit_mask(ste_arr, sb->bit_mask);

ret = sb->ste_build_tag_func(value, sb, ste_arr);
ret = sb->ste_build_tag_func(value, sb, dr_ste_get_tag(ste_arr));
if (ret)
return ret;

Expand Down Expand Up @@ -1078,11 +1085,9 @@ void dr_ste_copy_param(uint8_t match_criteria,

static int dr_ste_build_eth_l2_src_des_tag(struct dr_match_param *value,
struct dr_ste_build *sb,
uint8_t *hw_ste_p)
uint8_t *tag)
{
struct dr_hw_ste_format *hw_ste = (struct dr_hw_ste_format *)hw_ste_p;
struct dr_match_spec *spec = sb->inner ? &value->inner : &value->outer;
uint8_t *tag = hw_ste->tag;

DR_STE_SET_TAG(eth_l2_src_dst, tag, dmac_47_16, spec, dmac_47_16);
DR_STE_SET_TAG(eth_l2_src_dst, tag, dmac_15_0, spec, dmac_15_0);
Expand Down Expand Up @@ -1155,11 +1160,9 @@ static void dr_ste_build_eth_l3_ipv6_dst_bit_mask(struct dr_match_param *value,

static int dr_ste_build_eth_l3_ipv6_dst_tag(struct dr_match_param *value,
struct dr_ste_build *sb,
uint8_t *hw_ste_p)
uint8_t *tag)
{
struct dr_hw_ste_format *hw_ste = (struct dr_hw_ste_format *)hw_ste_p;
struct dr_match_spec *spec = sb->inner ? &value->inner : &value->outer;
uint8_t *tag = hw_ste->tag;

DR_STE_SET_TAG(eth_l3_ipv6_dst, tag, dst_ip_127_96, spec, dst_ip_127_96);
DR_STE_SET_TAG(eth_l3_ipv6_dst, tag, dst_ip_95_64, spec, dst_ip_95_64);
Expand Down Expand Up @@ -1195,11 +1198,9 @@ static void dr_ste_build_eth_l3_ipv6_src_bit_mask(struct dr_match_param *value,

static int dr_ste_build_eth_l3_ipv6_src_tag(struct dr_match_param *value,
struct dr_ste_build *sb,
uint8_t *hw_ste_p)
uint8_t *tag)
{
struct dr_hw_ste_format *hw_ste = (struct dr_hw_ste_format *)hw_ste_p;
struct dr_match_spec *spec = sb->inner ? &value->inner : &value->outer;
uint8_t *tag = hw_ste->tag;

DR_STE_SET_TAG(eth_l3_ipv6_src, tag, src_ip_127_96, spec, src_ip_127_96);
DR_STE_SET_TAG(eth_l3_ipv6_src, tag, src_ip_95_64, spec, src_ip_95_64);
Expand Down Expand Up @@ -1247,11 +1248,9 @@ static void dr_ste_build_eth_l3_ipv4_5_tuple_bit_mask(struct dr_match_param *val

static int dr_ste_build_eth_l3_ipv4_5_tuple_tag(struct dr_match_param *value,
struct dr_ste_build *sb,
uint8_t *hw_ste_p)
uint8_t *tag)
{
struct dr_hw_ste_format *hw_ste = (struct dr_hw_ste_format *)hw_ste_p;
struct dr_match_spec *spec = sb->inner ? &value->inner : &value->outer;
uint8_t *tag = hw_ste->tag;

DR_STE_SET_TAG(eth_l3_ipv4_5_tuple, tag, destination_address, spec, dst_ip_31_0);
DR_STE_SET_TAG(eth_l3_ipv4_5_tuple, tag, source_address, spec, src_ip_31_0);
Expand Down Expand Up @@ -1331,12 +1330,10 @@ dr_ste_build_eth_l2_src_or_dst_bit_mask(struct dr_match_param *value,
}

static int dr_ste_build_eth_l2_src_or_dst_tag(struct dr_match_param *value,
bool inner, uint8_t *hw_ste_p)
bool inner, uint8_t *tag)
{
struct dr_hw_ste_format *hw_ste = (struct dr_hw_ste_format *)hw_ste_p;
struct dr_match_spec *spec = inner ? &value->inner : &value->outer;
struct dr_match_misc *misc_spec = &value->misc;
uint8_t *tag = hw_ste->tag;

DR_STE_SET_TAG(eth_l2_src, tag, first_vlan_id, spec, first_vid);
DR_STE_SET_TAG(eth_l2_src, tag, first_cfi, spec, first_cfi);
Expand Down Expand Up @@ -1406,16 +1403,14 @@ static void dr_ste_build_eth_l2_src_bit_mask(struct dr_match_param *value,

static int dr_ste_build_eth_l2_src_tag(struct dr_match_param *value,
struct dr_ste_build *sb,
uint8_t *hw_ste_p)
uint8_t *tag)
{
struct dr_hw_ste_format *hw_ste = (struct dr_hw_ste_format *)hw_ste_p;
struct dr_match_spec *spec = sb->inner ? &value->inner : &value->outer;
uint8_t *tag = hw_ste->tag;

DR_STE_SET_TAG(eth_l2_src, tag, smac_47_16, spec, smac_47_16);
DR_STE_SET_TAG(eth_l2_src, tag, smac_15_0, spec, smac_15_0);

return dr_ste_build_eth_l2_src_or_dst_tag(value, sb->inner, hw_ste_p);
return dr_ste_build_eth_l2_src_or_dst_tag(value, sb->inner, tag);
}

void dr_ste_build_eth_l2_src(struct dr_ste_build *sb,
Expand Down Expand Up @@ -1444,16 +1439,14 @@ static void dr_ste_build_eth_l2_dst_bit_mask(struct dr_match_param *value,

static int dr_ste_build_eth_l2_dst_tag(struct dr_match_param *value,
struct dr_ste_build *sb,
uint8_t *hw_ste_p)
uint8_t *tag)
{
struct dr_hw_ste_format *hw_ste = (struct dr_hw_ste_format *)hw_ste_p;
struct dr_match_spec *spec = sb->inner ? &value->inner : &value->outer;
uint8_t *tag = hw_ste->tag;

DR_STE_SET_TAG(eth_l2_dst, tag, dmac_47_16, spec, dmac_47_16);
DR_STE_SET_TAG(eth_l2_dst, tag, dmac_15_0, spec, dmac_15_0);

return dr_ste_build_eth_l2_src_or_dst_tag(value, sb->inner, hw_ste_p);
return dr_ste_build_eth_l2_src_or_dst_tag(value, sb->inner, tag);
}

void dr_ste_build_eth_l2_dst(struct dr_ste_build *sb,
Expand Down Expand Up @@ -1498,12 +1491,10 @@ static void dr_ste_build_eth_l2_tnl_bit_mask(struct dr_match_param *value,

static int dr_ste_build_eth_l2_tnl_tag(struct dr_match_param *value,
struct dr_ste_build *sb,
uint8_t *hw_ste_p)
uint8_t *tag)
{
struct dr_hw_ste_format *hw_ste = (struct dr_hw_ste_format *)hw_ste_p;
struct dr_match_spec *spec = sb->inner ? &value->inner : &value->outer;
struct dr_match_misc *misc = &value->misc;
uint8_t *tag = hw_ste->tag;

DR_STE_SET_TAG(eth_l2_tnl, tag, dmac_47_16, spec, dmac_47_16);
DR_STE_SET_TAG(eth_l2_tnl, tag, dmac_15_0, spec, dmac_15_0);
Expand Down Expand Up @@ -1565,11 +1556,9 @@ static void dr_ste_build_eth_l3_ipv4_misc_bit_mask(struct dr_match_param *value,

static int dr_ste_build_eth_l3_ipv4_misc_tag(struct dr_match_param *value,
struct dr_ste_build *sb,
uint8_t *hw_ste_p)
uint8_t *tag)
{
struct dr_hw_ste_format *hw_ste = (struct dr_hw_ste_format *)hw_ste_p;
struct dr_match_spec *spec = sb->inner ? &value->inner : &value->outer;
uint8_t *tag = hw_ste->tag;

DR_STE_SET_TAG(eth_l3_ipv4_misc, tag, time_to_live, spec, ip_ttl_hoplimit);

Expand Down Expand Up @@ -1620,12 +1609,10 @@ static void dr_ste_build_ipv6_l3_l4_bit_mask(struct dr_match_param *value,

static int dr_ste_build_ipv6_l3_l4_tag(struct dr_match_param *value,
struct dr_ste_build *sb,
uint8_t *hw_ste_p)
uint8_t *tag)
{
struct dr_hw_ste_format *hw_ste = (struct dr_hw_ste_format *)hw_ste_p;
struct dr_match_spec *spec = sb->inner ? &value->inner : &value->outer;
struct dr_match_misc *misc = &value->misc;
uint8_t *tag = hw_ste->tag;

DR_STE_SET_TAG(eth_l4, tag, dst_port, spec, tcp_dport);
DR_STE_SET_TAG(eth_l4, tag, src_port, spec, tcp_sport);
Expand Down Expand Up @@ -1667,7 +1654,7 @@ void dr_ste_build_ipv6_l3_l4(struct dr_ste_build *sb,

static int dr_ste_build_empty_always_hit_tag(struct dr_match_param *value,
struct dr_ste_build *sb,
uint8_t *hw_ste_p)
uint8_t *tag)
{
return 0;
}
Expand All @@ -1693,11 +1680,9 @@ static void dr_ste_build_mpls_bit_mask(struct dr_match_param *value,

static int dr_ste_build_mpls_tag(struct dr_match_param *value,
struct dr_ste_build *sb,
uint8_t *hw_ste_p)
uint8_t *tag)
{
struct dr_hw_ste_format *hw_ste = (struct dr_hw_ste_format *)hw_ste_p;
struct dr_match_misc2 *misc2_mask = &value->misc2;
uint8_t *tag = hw_ste->tag;

if (sb->inner)
DR_STE_SET_MPLS_TAG(mpls, misc2_mask, inner, tag);
Expand Down Expand Up @@ -1735,11 +1720,9 @@ static void dr_ste_build_gre_bit_mask(struct dr_match_param *value,

static int dr_ste_build_gre_tag(struct dr_match_param *value,
struct dr_ste_build *sb,
uint8_t *hw_ste_p)
uint8_t *tag)
{
struct dr_hw_ste_format *hw_ste = (struct dr_hw_ste_format *)hw_ste_p;
struct dr_match_misc *misc = &value->misc;
uint8_t *tag = hw_ste->tag;

DR_STE_SET_TAG(gre, tag, gre_protocol, misc, gre_protocol);

Expand Down Expand Up @@ -1800,11 +1783,9 @@ static void dr_ste_build_flex_parser_0_bit_mask(struct dr_match_param *value,

static int dr_ste_build_flex_parser_0_tag(struct dr_match_param *value,
struct dr_ste_build *sb,
uint8_t *hw_ste_p)
uint8_t *tag)
{
struct dr_hw_ste_format *hw_ste = (struct dr_hw_ste_format *)hw_ste_p;
struct dr_match_misc2 *misc_2_mask = &value->misc2;
uint8_t *tag = hw_ste->tag;

if (DR_STE_IS_OUTER_MPLS_OVER_GRE_SET(misc_2_mask)) {
DR_STE_SET_TAG(flex_parser_0, tag, parser_3_label,
Expand Down Expand Up @@ -1924,12 +1905,10 @@ static int dr_ste_build_flex_parser_1_bit_mask(struct dr_match_param *mask,

static int dr_ste_build_flex_parser_1_tag(struct dr_match_param *value,
struct dr_ste_build *sb,
uint8_t *hw_ste_p)
uint8_t *tag)
{
struct dr_hw_ste_format *hw_ste = (struct dr_hw_ste_format *)hw_ste_p;
struct dr_match_misc3 *misc_3 = &value->misc3;
bool is_ipv4 = DR_MASK_IS_FLEX_PARSER_ICMPV4_SET(misc_3);
uint8_t *tag = hw_ste->tag;
uint32_t icmp_header_data;
uint32_t icmp_type;
uint32_t icmp_code;
Expand Down Expand Up @@ -2029,11 +2008,9 @@ static void dr_ste_build_general_purpose_bit_mask(struct dr_match_param *value,

static int dr_ste_build_general_purpose_tag(struct dr_match_param *value,
struct dr_ste_build *sb,
uint8_t *hw_ste_p)
uint8_t *tag)
{
struct dr_hw_ste_format *hw_ste = (struct dr_hw_ste_format *)hw_ste_p;
struct dr_match_misc2 *misc_2_mask = &value->misc2;
uint8_t *tag = hw_ste->tag;

DR_STE_SET_TAG(general_purpose, tag, general_purpose_lookup_field,
misc_2_mask, metadata_reg_a);
Expand Down Expand Up @@ -2074,11 +2051,9 @@ static void dr_ste_build_eth_l4_misc_bit_mask(struct dr_match_param *value,

static int dr_ste_build_eth_l4_misc_tag(struct dr_match_param *value,
struct dr_ste_build *sb,
uint8_t *hw_ste_p)
uint8_t *tag)
{
struct dr_hw_ste_format *hw_ste = (struct dr_hw_ste_format *)hw_ste_p;
struct dr_match_misc3 *misc3 = &value->misc3;
uint8_t *tag = hw_ste->tag;

if (sb->inner) {
DR_STE_SET_TAG(eth_l4_misc, tag, seq_num, misc3, inner_tcp_seq_num);
Expand Down Expand Up @@ -2124,11 +2099,9 @@ dr_ste_build_flex_parser_tnl_vxlan_gpe_bit_mask(struct dr_match_param *value,
static int
dr_ste_build_flex_parser_tnl_vxlan_gpe_tag(struct dr_match_param *value,
struct dr_ste_build *sb,
uint8_t *hw_ste_p)
uint8_t *tag)
{
struct dr_hw_ste_format *hw_ste = (struct dr_hw_ste_format *)hw_ste_p;
struct dr_match_misc3 *misc3 = &value->misc3;
uint8_t *tag = hw_ste->tag;

DR_STE_SET_TAG(flex_parser_tnl_vxlan_gpe, tag,
outer_vxlan_gpe_flags, misc3,
Expand Down Expand Up @@ -2179,11 +2152,9 @@ dr_ste_build_flex_parser_tnl_geneve_bit_mask(struct dr_match_param *value,
static int
dr_ste_build_flex_parser_tnl_geneve_tag(struct dr_match_param *value,
struct dr_ste_build *sb,
uint8_t *hw_ste_p)
uint8_t *tag)
{
struct dr_hw_ste_format *hw_ste = (struct dr_hw_ste_format *)hw_ste_p;
struct dr_match_misc *misc = &value->misc;
uint8_t *tag = hw_ste->tag;

DR_STE_SET_TAG(flex_parser_tnl_geneve, tag,
geneve_protocol_type, misc, geneve_protocol_type);
Expand Down Expand Up @@ -2229,11 +2200,9 @@ dr_ste_build_flex_parser_tnl_gtpu_bit_mask(struct dr_match_param *value,
static int
dr_ste_build_flex_parser_tnl_gtpu_tag(struct dr_match_param *value,
struct dr_ste_build *sb,
uint8_t *hw_ste_p)
uint8_t *tag)
{
struct dr_hw_ste_format *hw_ste = (struct dr_hw_ste_format *)hw_ste_p;
struct dr_match_misc3 *misc3 = &value->misc3;
uint8_t *tag = hw_ste->tag;

DR_STE_SET_TAG(flex_parser_tnl_gtpu, tag,
gtpu_flags, misc3,
Expand Down Expand Up @@ -2277,11 +2246,9 @@ static void dr_ste_build_register_0_bit_mask(struct dr_match_param *value,

static int dr_ste_build_register_0_tag(struct dr_match_param *value,
struct dr_ste_build *sb,
uint8_t *hw_ste_p)
uint8_t *tag)
{
struct dr_hw_ste_format *hw_ste = (struct dr_hw_ste_format *)hw_ste_p;
struct dr_match_misc2 *misc2 = &value->misc2;
uint8_t *tag = hw_ste->tag;

DR_STE_SET_TAG(register_0, tag, register_0_h, misc2, metadata_reg_c_0);
DR_STE_SET_TAG(register_0, tag, register_0_l, misc2, metadata_reg_c_1);
Expand Down Expand Up @@ -2321,11 +2288,9 @@ static void dr_ste_build_register_1_bit_mask(struct dr_match_param *value,

static int dr_ste_build_register_1_tag(struct dr_match_param *value,
struct dr_ste_build *sb,
uint8_t *hw_ste_p)
uint8_t *tag)
{
struct dr_hw_ste_format *hw_ste = (struct dr_hw_ste_format *)hw_ste_p;
struct dr_match_misc2 *misc2 = &value->misc2;
uint8_t *tag = hw_ste->tag;

DR_STE_SET_TAG(register_1, tag, register_2_h, misc2, metadata_reg_c_4);
DR_STE_SET_TAG(register_1, tag, register_2_l, misc2, metadata_reg_c_5);
Expand Down Expand Up @@ -2365,13 +2330,11 @@ static int dr_ste_build_src_gvmi_qpn_bit_mask(struct dr_match_param *value,

static int dr_ste_build_src_gvmi_qpn_tag(struct dr_match_param *value,
struct dr_ste_build *sb,
uint8_t *hw_ste_p)
uint8_t *tag)
{
struct dr_hw_ste_format *hw_ste = (struct dr_hw_ste_format *)hw_ste_p;
struct dr_match_misc *misc = &value->misc;
struct dr_devx_vport_cap *vport_cap;
uint8_t *bit_mask = sb->bit_mask;
uint8_t *tag = hw_ste->tag;
bool source_gvmi_set;

DR_STE_SET_TAG(src_gvmi_qp, tag, source_qp, misc, source_sqn);
Expand Down
2 changes: 1 addition & 1 deletion providers/mlx5/mlx5dv_dr.h
Expand Up @@ -280,7 +280,7 @@ struct dr_ste_build {
uint8_t bit_mask[DR_STE_SIZE_MASK];
int (*ste_build_tag_func)(struct dr_match_param *spec,
struct dr_ste_build *sb,
uint8_t *hw_ste_p);
uint8_t *tag);
};

struct dr_ste_htbl *dr_ste_htbl_alloc(struct dr_icm_pool *pool,
Expand Down

0 comments on commit 77f2d0a

Please sign in to comment.