From: Jakub Kicinski <kubakici@wp.pl>
To: David Laight <David.Laight@ACULAB.COM>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"oss-drivers@netronome.com" <oss-drivers@netronome.com>
Subject: Re: [PATCH net-next 9/9] nfp: eliminate an if statement in calculation of completed frames
Date: Wed, 17 May 2017 10:36:37 -0700 [thread overview]
Message-ID: <20170517103637.2dd8b49d@cakuba.netronome.com> (raw)
In-Reply-To: <063D6719AE5E284EB5DD2968C1650D6DCFFF7B93@AcuExch.aculab.com>
On Wed, 17 May 2017 11:07:19 +0000, David Laight wrote:
> From: Jakub Kicinski
> > Sent: 16 May 2017 01:55
> > Given that our rings are always a power of 2, we can simplify the
> > calculation of number of completed TX descriptors by using masking
> > instead of if statement based on whether the index have wrapped
> > or not.
> >
> > Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
> > ---
> > drivers/net/ethernet/netronome/nfp/nfp_net_common.c | 10 ++--------
> > 1 file changed, 2 insertions(+), 8 deletions(-)
> >
> > diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
> > b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
> > index c64514f8ee65..da83e17b8b20 100644
> > --- a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
> > +++ b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
> > @@ -940,10 +940,7 @@ static void nfp_net_tx_complete(struct nfp_net_tx_ring *tx_ring)
> > if (qcp_rd_p == tx_ring->qcp_rd_p)
> > return;
> >
> > - if (qcp_rd_p > tx_ring->qcp_rd_p)
> > - todo = qcp_rd_p - tx_ring->qcp_rd_p;
> > - else
> > - todo = qcp_rd_p + tx_ring->cnt - tx_ring->qcp_rd_p;
> > + todo = D_IDX(tx_ring, qcp_rd_p + tx_ring->cnt - tx_ring->qcp_rd_p);
>
> I'm not sure you need to add tx_ring->cnt here.
> I bet D_IDX() masks it away.
True, feel free to send a fix, or I will queue up a correction after
other work I have pending.
> > while (todo--) {
> > idx = D_IDX(tx_ring, tx_ring->rd_p++);
>
> That '++' looks suspicious.
> I think you need to decide whether you are incrementing pointers into the ring
> or indexes into it.
> Sometimes it is safer to use a non-wrapping index and mask when accessing the entry.
> entry_ptr = &ring[idx & (RING_SIZE - 1)]
> Ring full is then (read_idx == write_idx + RING_SIZE),
> ring empty (read_idx == write_idx).
> So the index just wrap at (probably)_2^32.
I may be missing the point. I use a mix of the two, actually, the
software pointers are free running (non-wrapping) but the HW QCP
pointers wrap. Because HW pointers wrap I always keep one entry on
the rings empty, see nfp_net_tx_full().
next prev parent reply other threads:[~2017-05-17 17:36 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-16 0:55 [PATCH net-next 0/9] nfp: LSO, checksum and XDP datapath updates Jakub Kicinski
2017-05-16 0:55 ` [PATCH net-next 1/9] nfp: don't enable TSO on the device when disabled Jakub Kicinski
2017-05-16 0:55 ` [PATCH net-next 2/9] nfp: rename l4_offset in struct nfp_net_tx_desc to lso_hdrlen Jakub Kicinski
2017-05-16 0:55 ` [PATCH net-next 3/9] nfp: support LSO2 capability Jakub Kicinski
2017-05-16 6:56 ` [oss-drivers] " Simon Horman
2017-05-16 0:55 ` [PATCH net-next 4/9] nfp: don't assume RSS and IRQ moderation are always enabled Jakub Kicinski
2017-05-16 0:55 ` [PATCH net-next 5/9] nfp: version independent support for chained RSS metadata Jakub Kicinski
2017-05-16 0:55 ` [PATCH net-next 6/9] nfp: add CHECKSUM_COMPLETE support Jakub Kicinski
2017-05-16 0:55 ` [PATCH net-next 7/9] nfp: complete the XDP TX ring only when it's full Jakub Kicinski
2017-05-16 0:55 ` [PATCH net-next 8/9] nfp: add a helper for wrapping descriptor index Jakub Kicinski
2017-05-16 7:08 ` [oss-drivers] " Simon Horman
2017-05-16 7:38 ` Jakub Kicinski
2017-05-16 8:22 ` Simon Horman
2017-05-16 0:55 ` [PATCH net-next 9/9] nfp: eliminate an if statement in calculation of completed frames Jakub Kicinski
2017-05-16 6:57 ` [oss-drivers] " Simon Horman
2017-05-17 11:07 ` David Laight
2017-05-17 17:36 ` Jakub Kicinski [this message]
2017-05-19 9:18 ` David Laight
2017-05-16 16:59 ` [PATCH net-next 0/9] nfp: LSO, checksum and XDP datapath updates David Miller
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=20170517103637.2dd8b49d@cakuba.netronome.com \
--to=kubakici@wp.pl \
--cc=David.Laight@ACULAB.COM \
--cc=netdev@vger.kernel.org \
--cc=oss-drivers@netronome.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).