[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <063D6719AE5E284EB5DD2968C1650D6D17257A93@AcuExch.aculab.com>
Date: Thu, 5 Jun 2014 09:06:45 +0000
From: David Laight <David.Laight@...LAB.COM>
To: 'Fugang Duan' <b38611@...escale.com>,
"davem@...emloft.net" <davem@...emloft.net>
CC: "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
"shawn.guo@...aro.org" <shawn.guo@...aro.org>,
"R49496@...escale.com" <R49496@...escale.com>,
"ezequiel.garcia@...e-electrons.com"
<ezequiel.garcia@...e-electrons.com>,
"bhutchings@...arflare.com" <bhutchings@...arflare.com>,
"stephen@...workplumber.org" <stephen@...workplumber.org>,
"b20596@...escale.com" <b20596@...escale.com>,
"eric.dumazet@...il.com" <eric.dumazet@...il.com>
Subject: RE: [PATCH v3 1/6] net: fec: Factorize the .xmit transmit function
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@...escale.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
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists