From cce92367e31a5ad38122d4560b74fb566709af41 Mon Sep 17 00:00:00 2001 From: Gordon Tetlow Date: Thu, 19 Mar 2020 16:41:29 +0000 Subject: [PATCH] Fix packet forwarding performance in mlx5en(4) driver. Approved by: so Security: FreeBSD-EN-20:05.mlx5en --- sys/dev/mlx5/mlx5_en/mlx5_en_tx.c | 3 ++- sys/netinet/ip_output.c | 2 ++ sys/netinet6/ip6_output.c | 2 ++ sys/sys/mbuf.h | 4 +++- 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c b/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c index 7dcae0853ce..9a759bbb303 100644 --- a/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c +++ b/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c @@ -609,7 +609,8 @@ mlx5e_xmit(struct ifnet *ifp, struct mbuf *mb) struct mlx5e_sq *sq; int ret; - if (mb->m_pkthdr.snd_tag != NULL) { + if ((mb->m_pkthdr.csum_flags & CSUM_SND_TAG) != 0 && + (mb->m_pkthdr.snd_tag != NULL)) { sq = mlx5e_select_queue_by_send_tag(ifp, mb); if (unlikely(sq == NULL)) { /* Check for route change */ diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c index 559565fe860..7990e214a5d 100644 --- a/sys/netinet/ip_output.c +++ b/sys/netinet/ip_output.c @@ -653,6 +653,7 @@ ip_output(struct mbuf *m, struct mbuf *opt, struct route *ro, int flags, in_pcboutput_txrtlmt(inp, ifp, m); /* stamp send tag on mbuf */ m->m_pkthdr.snd_tag = inp->inp_snd_tag; + m->m_pkthdr.csum_flags |= CSUM_SND_TAG; } else { m->m_pkthdr.snd_tag = NULL; } @@ -705,6 +706,7 @@ ip_output(struct mbuf *m, struct mbuf *opt, struct route *ro, int flags, in_pcboutput_txrtlmt(inp, ifp, m); /* stamp send tag on mbuf */ m->m_pkthdr.snd_tag = inp->inp_snd_tag; + m->m_pkthdr.csum_flags |= CSUM_SND_TAG; } else { m->m_pkthdr.snd_tag = NULL; } diff --git a/sys/netinet6/ip6_output.c b/sys/netinet6/ip6_output.c index 6ede0ef5af8..d594858c63c 100644 --- a/sys/netinet6/ip6_output.c +++ b/sys/netinet6/ip6_output.c @@ -966,6 +966,7 @@ ip6_output(struct mbuf *m0, struct ip6_pktopts *opt, in_pcboutput_txrtlmt(inp, ifp, m); /* stamp send tag on mbuf */ m->m_pkthdr.snd_tag = inp->inp_snd_tag; + m->m_pkthdr.csum_flags |= CSUM_SND_TAG; } else { m->m_pkthdr.snd_tag = NULL; } @@ -1081,6 +1082,7 @@ ip6_output(struct mbuf *m0, struct ip6_pktopts *opt, in_pcboutput_txrtlmt(inp, ifp, m); /* stamp send tag on mbuf */ m->m_pkthdr.snd_tag = inp->inp_snd_tag; + m->m_pkthdr.csum_flags |= CSUM_SND_TAG; } else { m->m_pkthdr.snd_tag = NULL; } diff --git a/sys/sys/mbuf.h b/sys/sys/mbuf.h index 827a01e3ba7..8cb87db21aa 100644 --- a/sys/sys/mbuf.h +++ b/sys/sys/mbuf.h @@ -519,6 +519,8 @@ struct mbuf { #define CSUM_L5_VALID 0x20000000 /* checksum is correct */ #define CSUM_COALESCED 0x40000000 /* contains merged segments */ +#define CSUM_SND_TAG 0x80000000 /* Packet header has send tag */ + /* * CSUM flag description for use with printf(9) %b identifier. */ @@ -528,7 +530,7 @@ struct mbuf { "\12CSUM_IP6_UDP\13CSUM_IP6_TCP\14CSUM_IP6_SCTP\15CSUM_IP6_TSO" \ "\16CSUM_IP6_ISCSI" \ "\31CSUM_L3_CALC\32CSUM_L3_VALID\33CSUM_L4_CALC\34CSUM_L4_VALID" \ - "\35CSUM_L5_CALC\36CSUM_L5_VALID\37CSUM_COALESCED" + "\35CSUM_L5_CALC\36CSUM_L5_VALID\37CSUM_COALESCED\40CSUM_SND_TAG" /* CSUM flags compatibility mappings. */ #define CSUM_IP_CHECKED CSUM_L3_CALC -- 2.45.0