The patch removes magic numbers from miniflow_bits and calculates the bits at compile time. This also makes it easier to handle any ABI changes.
Signed-off-by: Kumar Amber <[email protected]> --- lib/dpif-netdev-extract-avx512.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/lib/dpif-netdev-extract-avx512.c b/lib/dpif-netdev-extract-avx512.c index 6ae15a4db..e77bb3214 100644 --- a/lib/dpif-netdev-extract-avx512.c +++ b/lib/dpif-netdev-extract-avx512.c @@ -256,6 +256,19 @@ _mm512_maskz_permutexvar_epi8_wrap(__mmask64 kmask, __m512i idx, __m512i a) #define PKT_MIN_ETH_IPv4_TCP (PKT_OFFSET_L4_IPv4 + TCP_HEADER_LEN) #define PKT_MIN_ETH_VLAN_IPv4_TCP (PKT_OFFSET_L4_VLAN_IPv4 + TCP_HEADER_LEN) +/* MF bits. */ +#define MF_BIT(field) (MAP_1 << ((offsetof(struct flow, field) / 8) % \ + MAP_T_BITS)) + +#define MF_ETH (MF_BIT(dp_hash) | MF_BIT(in_port) | MF_BIT(packet_type)\ + | MF_BIT(dl_dst) | MF_BIT(dl_src)| MF_BIT(dl_type)) + +#define MF_ETH_VLAN (MF_ETH | MF_BIT(vlans)) +#define MF_IPV4_UDP (MF_BIT(nw_src) | MF_BIT(ipv6_label) | MF_BIT(tp_src) | \ + MF_BIT(tp_dst)) + +#define MF_IPV4_TCP (MF_IPV4_UDP | MF_BIT(tcp_flags) | MF_BIT(arp_tha.ea[2])) + /* This union allows initializing static data as u8, but easily loading it * into AVX512 registers too. The union ensures proper alignment for the zmm. */ @@ -353,7 +366,7 @@ static const struct mfex_profile mfex_profiles[PROFILE_COUNT] = .strip_mask.u8_data = { PATTERN_STRIP_IPV4_MASK }, .store_kmsk = PATTERN_IPV4_UDP_KMASK, - .mf_bits = { 0x18a0000000000000, 0x0000000000040401}, + .mf_bits = { MF_ETH, MF_IPV4_UDP}, .dp_pkt_offs = { 0, UINT16_MAX, PKT_OFFSET_L2, PKT_OFFSET_L4_IPv4, }, @@ -376,7 +389,7 @@ static const struct mfex_profile mfex_profiles[PROFILE_COUNT] = .strip_mask.u8_data = { PATTERN_STRIP_IPV4_MASK }, .store_kmsk = PATTERN_IPV4_TCP_KMASK, - .mf_bits = { 0x18a0000000000000, 0x0000000000044401}, + .mf_bits = { MF_ETH, MF_IPV4_TCP}, .dp_pkt_offs = { 0, UINT16_MAX, PKT_OFFSET_L2, PKT_OFFSET_L4_IPv4, }, @@ -395,7 +408,7 @@ static const struct mfex_profile mfex_profiles[PROFILE_COUNT] = .strip_mask.u8_data = { PATTERN_STRIP_DOT1Q_IPV4_MASK }, .store_kmsk = PATTERN_DT1Q_IPV4_UDP_KMASK, - .mf_bits = { 0x38a0000000000000, 0x0000000000040401}, + .mf_bits = { MF_ETH_VLAN, MF_IPV4_UDP}, .dp_pkt_offs = { PKT_OFFSET_L2, UINT16_MAX, PKT_OFFSET_L3_VLAN, PKT_OFFSET_L4_VLAN_IPv4, @@ -421,7 +434,7 @@ static const struct mfex_profile mfex_profiles[PROFILE_COUNT] = .strip_mask.u8_data = { PATTERN_STRIP_DOT1Q_IPV4_MASK }, .store_kmsk = PATTERN_DT1Q_IPV4_TCP_KMASK, - .mf_bits = { 0x38a0000000000000, 0x0000000000044401}, + .mf_bits = { MF_ETH_VLAN, MF_IPV4_TCP}, .dp_pkt_offs = { PKT_OFFSET_L2, UINT16_MAX, PKT_OFFSET_L3_VLAN, PKT_OFFSET_L4_VLAN_IPv4, -- 2.25.1 _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
