mirror of
https://github.com/openvswitch/ovs
synced 2025-08-31 14:25:26 +00:00
dpif-netdev/mfex: Add ipv4 profile based hashing.
For packets which don't already have a hash calculated, miniflow_hash_5tuple() calculates the hash of a packet using the previously built miniflow. This commit adds IPv4 profile specific hashing which uses fixed offsets into the packet to improve hashing performance. Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com> Co-authored-by: Harry van Haaren <harry.van.haaren@intel.com> Signed-off-by: Ilya Maximets <i.maximets@ovn.org> Co-authored-by: Ilya Maximets <i.maximets@ovn.org> Signed-off-by: Kumar Amber <kumar.amber@intel.com> Acked-by: Cian Ferriter <cian.ferriter@intel.com> Acked-by: David Marchand <david.marchand@redhat.com> Signed-off-by: Ian Stokes <ian.stokes@intel.com>
This commit is contained in:
@@ -1085,6 +1085,38 @@ dp_packet_l4_checksum_bad(const struct dp_packet *p)
|
|||||||
DP_PACKET_OL_RX_L4_CKSUM_BAD;
|
DP_PACKET_OL_RX_L4_CKSUM_BAD;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void ALWAYS_INLINE
|
||||||
|
dp_packet_update_rss_hash_ipv4_tcp_udp(struct dp_packet *packet)
|
||||||
|
{
|
||||||
|
if (dp_packet_rss_valid(packet)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const uint8_t *pkt = dp_packet_data(packet);
|
||||||
|
const uint16_t l3_ofs = packet->l3_ofs;
|
||||||
|
const void *ipv4_src = &pkt[l3_ofs + offsetof(struct ip_header, ip_src)];
|
||||||
|
const void *ipv4_dst = &pkt[l3_ofs + offsetof(struct ip_header, ip_dst)];
|
||||||
|
const void *l4_ports = &pkt[packet->l4_ofs];
|
||||||
|
uint32_t ip_src, ip_dst, ports;
|
||||||
|
uint32_t hash = 0;
|
||||||
|
|
||||||
|
memcpy(&ip_src, ipv4_src, sizeof ip_src);
|
||||||
|
memcpy(&ip_dst, ipv4_dst, sizeof ip_dst);
|
||||||
|
memcpy(&ports, l4_ports, sizeof ports);
|
||||||
|
|
||||||
|
/* IPv4 Src and Dst. */
|
||||||
|
hash = hash_add(hash, ip_src);
|
||||||
|
hash = hash_add(hash, ip_dst);
|
||||||
|
/* IPv4 proto. */
|
||||||
|
hash = hash_add(hash,
|
||||||
|
pkt[l3_ofs + offsetof(struct ip_header, ip_proto)]);
|
||||||
|
/* L4 ports. */
|
||||||
|
hash = hash_add(hash, ports);
|
||||||
|
hash = hash_finish(hash, 42);
|
||||||
|
|
||||||
|
dp_packet_set_rss_hash(packet, hash);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@@ -48,6 +48,7 @@
|
|||||||
#include "dpif-netdev-private-dpcls.h"
|
#include "dpif-netdev-private-dpcls.h"
|
||||||
#include "dpif-netdev-private-extract.h"
|
#include "dpif-netdev-private-extract.h"
|
||||||
#include "dpif-netdev-private-flow.h"
|
#include "dpif-netdev-private-flow.h"
|
||||||
|
#include "dp-packet.h"
|
||||||
|
|
||||||
/* AVX512-BW level permutex2var_epi8 emulation. */
|
/* AVX512-BW level permutex2var_epi8 emulation. */
|
||||||
static inline __m512i
|
static inline __m512i
|
||||||
@@ -577,6 +578,7 @@ mfex_avx512_process(struct dp_packet_batch *packets,
|
|||||||
/* Process TCP flags, and store to blocks. */
|
/* Process TCP flags, and store to blocks. */
|
||||||
const struct tcp_header *tcp = (void *)&pkt[38];
|
const struct tcp_header *tcp = (void *)&pkt[38];
|
||||||
mfex_handle_tcp_flags(tcp, &blocks[7]);
|
mfex_handle_tcp_flags(tcp, &blocks[7]);
|
||||||
|
dp_packet_update_rss_hash_ipv4_tcp_udp(packet);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case PROFILE_ETH_VLAN_IPV4_UDP: {
|
case PROFILE_ETH_VLAN_IPV4_UDP: {
|
||||||
@@ -588,6 +590,7 @@ mfex_avx512_process(struct dp_packet_batch *packets,
|
|||||||
UDP_HEADER_LEN)) {
|
UDP_HEADER_LEN)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
dp_packet_update_rss_hash_ipv4_tcp_udp(packet);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case PROFILE_ETH_IPV4_TCP: {
|
case PROFILE_ETH_IPV4_TCP: {
|
||||||
@@ -602,6 +605,7 @@ mfex_avx512_process(struct dp_packet_batch *packets,
|
|||||||
TCP_HEADER_LEN)) {
|
TCP_HEADER_LEN)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
dp_packet_update_rss_hash_ipv4_tcp_udp(packet);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case PROFILE_ETH_IPV4_UDP: {
|
case PROFILE_ETH_IPV4_UDP: {
|
||||||
@@ -612,7 +616,7 @@ mfex_avx512_process(struct dp_packet_batch *packets,
|
|||||||
UDP_HEADER_LEN)) {
|
UDP_HEADER_LEN)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
dp_packet_update_rss_hash_ipv4_tcp_udp(packet);
|
||||||
} break;
|
} break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@@ -1017,6 +1017,9 @@ miniflow_extract(struct dp_packet *packet, struct miniflow *dst)
|
|||||||
miniflow_push_be16(mf, tp_dst, tcp->tcp_dst);
|
miniflow_push_be16(mf, tp_dst, tcp->tcp_dst);
|
||||||
miniflow_push_be16(mf, ct_tp_src, ct_tp_src);
|
miniflow_push_be16(mf, ct_tp_src, ct_tp_src);
|
||||||
miniflow_push_be16(mf, ct_tp_dst, ct_tp_dst);
|
miniflow_push_be16(mf, ct_tp_dst, ct_tp_dst);
|
||||||
|
if (dl_type == htons(ETH_TYPE_IP)) {
|
||||||
|
dp_packet_update_rss_hash_ipv4_tcp_udp(packet);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (OVS_LIKELY(nw_proto == IPPROTO_UDP)) {
|
} else if (OVS_LIKELY(nw_proto == IPPROTO_UDP)) {
|
||||||
@@ -1027,6 +1030,9 @@ miniflow_extract(struct dp_packet *packet, struct miniflow *dst)
|
|||||||
miniflow_push_be16(mf, tp_dst, udp->udp_dst);
|
miniflow_push_be16(mf, tp_dst, udp->udp_dst);
|
||||||
miniflow_push_be16(mf, ct_tp_src, ct_tp_src);
|
miniflow_push_be16(mf, ct_tp_src, ct_tp_src);
|
||||||
miniflow_push_be16(mf, ct_tp_dst, ct_tp_dst);
|
miniflow_push_be16(mf, ct_tp_dst, ct_tp_dst);
|
||||||
|
if (dl_type == htons(ETH_TYPE_IP)) {
|
||||||
|
dp_packet_update_rss_hash_ipv4_tcp_udp(packet);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (OVS_LIKELY(nw_proto == IPPROTO_SCTP)) {
|
} else if (OVS_LIKELY(nw_proto == IPPROTO_SCTP)) {
|
||||||
if (OVS_LIKELY(size >= SCTP_HEADER_LEN)) {
|
if (OVS_LIKELY(size >= SCTP_HEADER_LEN)) {
|
||||||
|
Reference in New Issue
Block a user