All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Laight <David.Laight@ACULAB.COM>
To: 'Fugang Duan' <b38611@freescale.com>,
	"davem@davemloft.net" <davem@davemloft.net>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"shawn.guo@linaro.org" <shawn.guo@linaro.org>,
	"R49496@freescale.com" <R49496@freescale.com>,
	"ezequiel.garcia@free-electrons.com"
	<ezequiel.garcia@free-electrons.com>,
	"bhutchings@solarflare.com" <bhutchings@solarflare.com>,
	"stephen@networkplumber.org" <stephen@networkplumber.org>,
	"b20596@freescale.com" <b20596@freescale.com>,
	"eric.dumazet@gmail.com" <eric.dumazet@gmail.com>
Subject: RE: [PATCH v3 1/6] net: fec: Factorize the .xmit transmit function
Date: Thu, 5 Jun 2014 09:06:45 +0000	[thread overview]
Message-ID: <063D6719AE5E284EB5DD2968C1650D6D17257A93@AcuExch.aculab.com> (raw)
In-Reply-To: <1401951572-6538-2-git-send-email-b38611@freescale.com>

From: Fugang Duan
> Make the code more readable and easy to support other features like
> SG, TSO, moving the common transmit function to one api.
> 
> And the patch also factorize the getting BD index to it own function.
> 
> Signed-off-by: Fugang Duan <B38611@freescale.com>
> ---
>  drivers/net/ethernet/freescale/fec_main.c |   87 ++++++++++++++++++-----------
>  1 files changed, 54 insertions(+), 33 deletions(-)
> 
> diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
> index 802be17..32c2276 100644
> --- a/drivers/net/ethernet/freescale/fec_main.c
> +++ b/drivers/net/ethernet/freescale/fec_main.c
> @@ -287,6 +287,25 @@ struct bufdesc *fec_enet_get_prevdesc(struct bufdesc *bdp, struct fec_enet_priva
>  		return (new_bd < base) ? (new_bd + ring_size) : new_bd;
>  }
> 
> +static inline
> +int fec_enet_get_bd_index(struct bufdesc *bdp, struct fec_enet_private *fep)
> +{
> +	struct bufdesc *base;
> +	int index;
> +
> +	if (bdp >= fep->tx_bd_base)
> +		base = fep->tx_bd_base;
> +	else
> +		base = fep->rx_bd_base;

You really don't want the above conditional.
It is known from the call site - but the compiler can't determine that
and remove the test.
You may not want to rely on the tx and rx descriptors being allocated
as a single entity - particularly now that they (probably) consume
more than a single page.

> +
> +	if (fep->bufdesc_ex)
> +		index = (struct bufdesc_ex *)bdp - (struct bufdesc_ex *)base;
> +	else
> +		index = bdp - base;

Save the sizeof the descriptor structure as (say) fep->bufdesc_size
(Possibly replacing bufdesc_ex)
and then just calculate:
	index = ((const char *)bdp - (const char *)base)/fep->bufdesc_size;

	David

  reply	other threads:[~2014-06-05  9:07 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-05  6:59 [PATCH v3 0/6] net: fec: Enable Software TSO to improve the tx performance Fugang Duan
2014-06-05  6:59 ` [PATCH v3 1/6] net: fec: Factorize the .xmit transmit function Fugang Duan
2014-06-05  9:06   ` David Laight [this message]
2014-06-05  9:34     ` fugang.duan
2014-06-05  9:58       ` David Laight
2014-06-05 10:21         ` fugang.duan
2014-06-05 22:17           ` David Miller
2014-06-05  6:59 ` [PATCH v3 2/6] net: fec: Enable IP header hardware checksum Fugang Duan
2014-06-05  6:59 ` [PATCH v3 3/6] net: fec: Factorize feature setting Fugang Duan
2014-06-05  6:59 ` [PATCH v3 4/6] net: fec: Increase buffer descriptor entry number Fugang Duan
2014-06-05  6:59 ` [PATCH v3 5/6] net: fec: Add Scatter/gather support Fugang Duan
2014-06-05  6:59 ` [PATCH v3 6/6] net: fec: Add software TSO support Fugang Duan

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=063D6719AE5E284EB5DD2968C1650D6D17257A93@AcuExch.aculab.com \
    --to=david.laight@aculab.com \
    --cc=R49496@freescale.com \
    --cc=b20596@freescale.com \
    --cc=b38611@freescale.com \
    --cc=bhutchings@solarflare.com \
    --cc=davem@davemloft.net \
    --cc=eric.dumazet@gmail.com \
    --cc=ezequiel.garcia@free-electrons.com \
    --cc=netdev@vger.kernel.org \
    --cc=shawn.guo@linaro.org \
    --cc=stephen@networkplumber.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.