DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Zhang, Qi Z" <qi.z.zhang@intel.com>
To: "Wiles, Keith" <keith.wiles@intel.com>
Cc: "Richardson, Bruce" <bruce.richardson@intel.com>,
	dev <dev@dpdk.org>, "Lu, Wenzhuo" <wenzhuo.lu@intel.com>,
	"Iremonger, Bernard" <bernard.iremonger@intel.com>,
	"stable@dpdk.org" <stable@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH] app/testpmd: improve MAC swap performance
Date: Tue, 27 Nov 2018 01:06:15 +0000	[thread overview]
Message-ID: <039ED4275CED7440929022BC67E70611532EB088@SHSMSX103.ccr.corp.intel.com> (raw)
In-Reply-To: <21DA84FC-B5A5-4987-868F-C6AA85724D5F@intel.com>



> -----Original Message-----
> From: Wiles, Keith
> Sent: Saturday, November 24, 2018 8:24 AM
> To: Zhang, Qi Z <qi.z.zhang@intel.com>
> Cc: Richardson, Bruce <bruce.richardson@intel.com>; dev <dev@dpdk.org>; Lu,
> Wenzhuo <wenzhuo.lu@intel.com>; Iremonger, Bernard
> <bernard.iremonger@intel.com>; stable@dpdk.org
> Subject: Re: [PATCH] app/testpmd: improve MAC swap performance
> 
> 
> 
> > On Nov 23, 2018, at 4:43 PM, Wiles, Keith <keith.wiles@intel.com> wrote:
> >
> >
> >
> >> On Nov 19, 2018, at 10:45 PM, Zhang, Qi Z <qi.z.zhang@intel.com> wrote:
> >>
> >> The patch optimizes the mac swap operation by taking advantage of SSE
> >> instructions, it only impacts x86 platform.
> >>
> >> Cc: stable@dpdk.org
> >>
> >> Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
> >> ---
> >> app/test-pmd/macswap.c | 16 +++++++++++++++-
> >> 1 file changed, 15 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/app/test-pmd/macswap.c b/app/test-pmd/macswap.c index
> >> a8384d5b8..0722782b0 100644
> >> --- a/app/test-pmd/macswap.c
> >> +++ b/app/test-pmd/macswap.c
> >> @@ -78,7 +78,6 @@ pkt_burst_mac_swap(struct fwd_stream *fs)
> >> 	struct rte_port  *txp;
> >> 	struct rte_mbuf  *mb;
> >> 	struct ether_hdr *eth_hdr;
> >> -	struct ether_addr addr;
> >> 	uint16_t nb_rx;
> >> 	uint16_t nb_tx;
> >> 	uint16_t i;
> >> @@ -95,6 +94,15 @@ pkt_burst_mac_swap(struct fwd_stream *fs)
> >> 	start_tsc = rte_rdtsc();
> >> #endif
> >>
> >> +#ifdef RTE_ARCH_X86
> >> +	__m128i addr;
> >> +	__m128i shfl_msk = _mm_set_epi8(15, 14, 13, 12,
> >> +					5, 4, 3, 2,
> >> +					1, 0, 11, 10,
> >> +					9, 8, 7, 6);
> >
> > I was playing around with these mask values and I was not able to make it
> work as I expected.
> > I ended up with different values in the mask.
> >
> > _mm_set_epi8(15, 14, 13, 12, 5, 4, 3, 2, 1, 0, 11, 10, 9, 8, 7, 6);
> >
> > After dumping the memory for a large number of tests this one seems correct,
> can you verify your mask is correct?
> 
> Sorry, I do not know why I thought the code was not the same, but your
> example is correct my mistake.

Thanks for review and verify this!

Regards
Qi

> >
> >> +#else
> >> +	struct ether_addr addr;
> >> +#endif
> >> 	/*
> >> 	 * Receive a burst of packets and forward them.
> >> 	 */
> >> @@ -123,9 +131,15 @@ pkt_burst_mac_swap(struct fwd_stream *fs)
> >> 		eth_hdr = rte_pktmbuf_mtod(mb, struct ether_hdr *);
> >>
> >> 		/* Swap dest and src mac addresses. */
> >> +#ifdef RTE_ARCH_X86
> >> +		addr = _mm_loadu_si128((__m128i *)eth_hdr);
> >> +		addr = _mm_shuffle_epi8(addr, shfl_msk);
> >> +		_mm_storeu_si128((__m128i *)eth_hdr, addr); #else
> >> 		ether_addr_copy(&eth_hdr->d_addr, &addr);
> >> 		ether_addr_copy(&eth_hdr->s_addr, &eth_hdr->d_addr);
> >> 		ether_addr_copy(&addr, &eth_hdr->s_addr);
> >> +#endif
> >>
> >> 		mb->ol_flags &= IND_ATTACHED_MBUF | EXT_ATTACHED_MBUF;
> >> 		mb->ol_flags |= ol_flags;
> >> --
> >> 2.13.6
> >>
> >
> > Regards,
> > Keith
> 
> Regards,
> Keith

      reply	other threads:[~2018-11-27  1:06 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-20  4:45 Qi Zhang
2018-11-20  9:16 ` Ananyev, Konstantin
2018-11-20 14:48   ` Wiles, Keith
2018-11-20 16:58   ` Zhang, Qi Z
2018-11-20 17:26     ` Ananyev, Konstantin
2018-11-20 22:53     ` Ananyev, Konstantin
2018-11-21 21:24       ` Zhang, Qi Z
2018-11-23 22:43 ` Wiles, Keith
2018-11-23 22:43 ` Wiles, Keith
2018-11-24 16:24   ` Wiles, Keith
2018-11-27  1:06     ` Zhang, Qi Z [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=039ED4275CED7440929022BC67E70611532EB088@SHSMSX103.ccr.corp.intel.com \
    --to=qi.z.zhang@intel.com \
    --cc=bernard.iremonger@intel.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=keith.wiles@intel.com \
    --cc=stable@dpdk.org \
    --cc=wenzhuo.lu@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).