Message ID | 1456360619-24390-9-git-send-email-troy.kisky@boundarydevices.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
From: Troy Kisky <troy.kisky@boundarydevices.com> Sent: Thursday, February 25, 2016 8:37 AM > To: netdev@vger.kernel.org; davem@davemloft.net; b38611@freescale.com > Cc: fabio.estevam@freescale.com; l.stach@pengutronix.de; andrew@lunn.ch; > tremyfr@gmail.com; linux@arm.linux.org.uk; linux-arm- > kernel@lists.infradead.org; laci@boundarydevices.com; shawnguo@kernel.org; > johannes@sipsolutions.net; stillcompiling@gmail.com; > sergei.shtylyov@cogentembedded.com; arnd@arndb.de; Troy Kisky > <troy.kisky@boundarydevices.com> > Subject: [PATCH net-next V2 08/16] net: fec: eliminate calls to > fec_enet_get_prevdesc > > This shrinks the code a little. > > Signed-off-by: Troy Kisky <troy.kisky@boundarydevices.com> > --- > drivers/net/ethernet/freescale/fec_main.c | 37 +++++++++---------------------- > 1 file changed, 11 insertions(+), 26 deletions(-) > > diff --git a/drivers/net/ethernet/freescale/fec_main.c > b/drivers/net/ethernet/freescale/fec_main.c > index 6ceb5f9..b5ed287 100644 > --- a/drivers/net/ethernet/freescale/fec_main.c > +++ b/drivers/net/ethernet/freescale/fec_main.c > @@ -758,6 +758,7 @@ static void fec_enet_bd_init(struct net_device *dev) > struct bufdesc *bdp; > unsigned int i; > unsigned int q; > + unsigned status; Should be unsigned int status; > > for (q = 0; q < fep->num_rx_queues; q++) { > /* Initialize the receive buffer descriptors. */ @@ -765,19 > +766,13 @@ static void fec_enet_bd_init(struct net_device *dev) > bdp = rxq->bd.base; > > for (i = 0; i < rxq->bd.ring_size; i++) { > - > /* Initialize the BD for every fragment in the page. */ > - if (bdp->cbd_bufaddr) > - bdp->cbd_sc = > cpu_to_fec16(BD_ENET_RX_EMPTY); > - else > - bdp->cbd_sc = cpu_to_fec16(0); > + status = bdp->cbd_bufaddr ? BD_ENET_RX_EMPTY : 0; > + if (bdp == rxq->bd.last) > + status |= BD_SC_WRAP; > + bdp->cbd_sc = cpu_to_fec16(status); > bdp = fec_enet_get_nextdesc(bdp, &rxq->bd); > } > - > - /* Set the last buffer to wrap */ > - bdp = fec_enet_get_prevdesc(bdp, &rxq->bd); > - bdp->cbd_sc |= cpu_to_fec16(BD_SC_WRAP); > - > rxq->bd.cur = rxq->bd.base; > } > > @@ -789,18 +784,16 @@ static void fec_enet_bd_init(struct net_device *dev) > > for (i = 0; i < txq->bd.ring_size; i++) { > /* Initialize the BD for every fragment in the page. */ > - bdp->cbd_sc = cpu_to_fec16(0); > if (txq->tx_skbuff[i]) { > dev_kfree_skb_any(txq->tx_skbuff[i]); > txq->tx_skbuff[i] = NULL; > } > bdp->cbd_bufaddr = cpu_to_fec32(0); > + bdp->cbd_sc = cpu_to_fec16((bdp == txq->bd.last) ? > + BD_SC_WRAP : 0); > bdp = fec_enet_get_nextdesc(bdp, &txq->bd); > } > - > - /* Set the last buffer to wrap */ > bdp = fec_enet_get_prevdesc(bdp, &txq->bd); > - bdp->cbd_sc |= cpu_to_fec16(BD_SC_WRAP); > txq->dirty_tx = bdp; > } > } > @@ -2717,19 +2710,16 @@ fec_enet_alloc_rxq_buffers(struct net_device > *ndev, unsigned int queue) > } > > rxq->rx_skbuff[i] = skb; > - bdp->cbd_sc = cpu_to_fec16(BD_ENET_RX_EMPTY); > > if (fep->bufdesc_ex) { > struct bufdesc_ex *ebdp = (struct bufdesc_ex *)bdp; > ebdp->cbd_esc = cpu_to_fec32(BD_ENET_RX_INT); > } > + bdp->cbd_sc = cpu_to_fec16(BD_ENET_RX_EMPTY | > + ((bdp == rxq->bd.last) ? BD_SC_WRAP : 0)); > > bdp = fec_enet_get_nextdesc(bdp, &rxq->bd); > } > - > - /* Set the last buffer to wrap. */ > - bdp = fec_enet_get_prevdesc(bdp, &rxq->bd); > - bdp->cbd_sc |= cpu_to_fec16(BD_SC_WRAP); > return 0; > > err_alloc: > @@ -2752,21 +2742,16 @@ fec_enet_alloc_txq_buffers(struct net_device > *ndev, unsigned int queue) > if (!txq->tx_bounce[i]) > goto err_alloc; > > - bdp->cbd_sc = cpu_to_fec16(0); > bdp->cbd_bufaddr = cpu_to_fec32(0); > > if (fep->bufdesc_ex) { > struct bufdesc_ex *ebdp = (struct bufdesc_ex *)bdp; > ebdp->cbd_esc = cpu_to_fec32(BD_ENET_TX_INT); > } > - > + bdp->cbd_sc = cpu_to_fec16((bdp == txq->bd.last) ? > + BD_SC_WRAP : 0); > bdp = fec_enet_get_nextdesc(bdp, &txq->bd); > } > - > - /* Set the last buffer to wrap. */ > - bdp = fec_enet_get_prevdesc(bdp, &txq->bd); > - bdp->cbd_sc |= cpu_to_fec16(BD_SC_WRAP); > - > return 0; > > err_alloc: > -- > 2.5.0
On 3/4/2016 2:33 AM, Fugang Duan wrote: > From: Troy Kisky <troy.kisky@boundarydevices.com> Sent: Thursday, February 25, 2016 8:37 AM >> To: netdev@vger.kernel.org; davem@davemloft.net; b38611@freescale.com >> Cc: fabio.estevam@freescale.com; l.stach@pengutronix.de; andrew@lunn.ch; >> tremyfr@gmail.com; linux@arm.linux.org.uk; linux-arm- >> kernel@lists.infradead.org; laci@boundarydevices.com; shawnguo@kernel.org; >> johannes@sipsolutions.net; stillcompiling@gmail.com; >> sergei.shtylyov@cogentembedded.com; arnd@arndb.de; Troy Kisky >> <troy.kisky@boundarydevices.com> >> Subject: [PATCH net-next V2 08/16] net: fec: eliminate calls to >> fec_enet_get_prevdesc >> >> This shrinks the code a little. >> >> Signed-off-by: Troy Kisky <troy.kisky@boundarydevices.com> >> --- >> drivers/net/ethernet/freescale/fec_main.c | 37 +++++++++---------------------- >> 1 file changed, 11 insertions(+), 26 deletions(-) >> >> diff --git a/drivers/net/ethernet/freescale/fec_main.c >> b/drivers/net/ethernet/freescale/fec_main.c >> index 6ceb5f9..b5ed287 100644 >> --- a/drivers/net/ethernet/freescale/fec_main.c >> +++ b/drivers/net/ethernet/freescale/fec_main.c >> @@ -758,6 +758,7 @@ static void fec_enet_bd_init(struct net_device *dev) >> struct bufdesc *bdp; >> unsigned int i; >> unsigned int q; >> + unsigned status; > > Should be unsigned int status; > Fine Thanks
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c index 6ceb5f9..b5ed287 100644 --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c @@ -758,6 +758,7 @@ static void fec_enet_bd_init(struct net_device *dev) struct bufdesc *bdp; unsigned int i; unsigned int q; + unsigned status; for (q = 0; q < fep->num_rx_queues; q++) { /* Initialize the receive buffer descriptors. */ @@ -765,19 +766,13 @@ static void fec_enet_bd_init(struct net_device *dev) bdp = rxq->bd.base; for (i = 0; i < rxq->bd.ring_size; i++) { - /* Initialize the BD for every fragment in the page. */ - if (bdp->cbd_bufaddr) - bdp->cbd_sc = cpu_to_fec16(BD_ENET_RX_EMPTY); - else - bdp->cbd_sc = cpu_to_fec16(0); + status = bdp->cbd_bufaddr ? BD_ENET_RX_EMPTY : 0; + if (bdp == rxq->bd.last) + status |= BD_SC_WRAP; + bdp->cbd_sc = cpu_to_fec16(status); bdp = fec_enet_get_nextdesc(bdp, &rxq->bd); } - - /* Set the last buffer to wrap */ - bdp = fec_enet_get_prevdesc(bdp, &rxq->bd); - bdp->cbd_sc |= cpu_to_fec16(BD_SC_WRAP); - rxq->bd.cur = rxq->bd.base; } @@ -789,18 +784,16 @@ static void fec_enet_bd_init(struct net_device *dev) for (i = 0; i < txq->bd.ring_size; i++) { /* Initialize the BD for every fragment in the page. */ - bdp->cbd_sc = cpu_to_fec16(0); if (txq->tx_skbuff[i]) { dev_kfree_skb_any(txq->tx_skbuff[i]); txq->tx_skbuff[i] = NULL; } bdp->cbd_bufaddr = cpu_to_fec32(0); + bdp->cbd_sc = cpu_to_fec16((bdp == txq->bd.last) ? + BD_SC_WRAP : 0); bdp = fec_enet_get_nextdesc(bdp, &txq->bd); } - - /* Set the last buffer to wrap */ bdp = fec_enet_get_prevdesc(bdp, &txq->bd); - bdp->cbd_sc |= cpu_to_fec16(BD_SC_WRAP); txq->dirty_tx = bdp; } } @@ -2717,19 +2710,16 @@ fec_enet_alloc_rxq_buffers(struct net_device *ndev, unsigned int queue) } rxq->rx_skbuff[i] = skb; - bdp->cbd_sc = cpu_to_fec16(BD_ENET_RX_EMPTY); if (fep->bufdesc_ex) { struct bufdesc_ex *ebdp = (struct bufdesc_ex *)bdp; ebdp->cbd_esc = cpu_to_fec32(BD_ENET_RX_INT); } + bdp->cbd_sc = cpu_to_fec16(BD_ENET_RX_EMPTY | + ((bdp == rxq->bd.last) ? BD_SC_WRAP : 0)); bdp = fec_enet_get_nextdesc(bdp, &rxq->bd); } - - /* Set the last buffer to wrap. */ - bdp = fec_enet_get_prevdesc(bdp, &rxq->bd); - bdp->cbd_sc |= cpu_to_fec16(BD_SC_WRAP); return 0; err_alloc: @@ -2752,21 +2742,16 @@ fec_enet_alloc_txq_buffers(struct net_device *ndev, unsigned int queue) if (!txq->tx_bounce[i]) goto err_alloc; - bdp->cbd_sc = cpu_to_fec16(0); bdp->cbd_bufaddr = cpu_to_fec32(0); if (fep->bufdesc_ex) { struct bufdesc_ex *ebdp = (struct bufdesc_ex *)bdp; ebdp->cbd_esc = cpu_to_fec32(BD_ENET_TX_INT); } - + bdp->cbd_sc = cpu_to_fec16((bdp == txq->bd.last) ? + BD_SC_WRAP : 0); bdp = fec_enet_get_nextdesc(bdp, &txq->bd); } - - /* Set the last buffer to wrap. */ - bdp = fec_enet_get_prevdesc(bdp, &txq->bd); - bdp->cbd_sc |= cpu_to_fec16(BD_SC_WRAP); - return 0; err_alloc:
This shrinks the code a little. Signed-off-by: Troy Kisky <troy.kisky@boundarydevices.com> --- drivers/net/ethernet/freescale/fec_main.c | 37 +++++++++---------------------- 1 file changed, 11 insertions(+), 26 deletions(-)