All of lore.kernel.org
 help / color / mirror / Atom feed
* [net-next, PATCH 1/2] net: socionext: Use descriptor info instead of MMIO reads on Rx
@ 2018-08-09  8:02 Ilias Apalodimas
  2018-08-09  8:02 ` [net-next, PATCH 2/2] net: socionext: Increase descriptors to 256 Ilias Apalodimas
  2018-08-09 15:37 ` [net-next, PATCH 1/2] net: socionext: Use descriptor info instead of MMIO reads on Rx Arnd Bergmann
  0 siblings, 2 replies; 4+ messages in thread
From: Ilias Apalodimas @ 2018-08-09  8:02 UTC (permalink / raw)
  To: netdev, jaswinder.singh; +Cc: arnd, Ilias Apalodimas

MMIO reads for remaining packets in queue occur (at least)twice per
invocation of netsec_process_rx(). We can use the packet descriptor to
identify if it's owned by the hardware and break out, avoiding the more
expensive MMIO read operations. This has a ~2% increase on the pps of the
Rx path when tested with 64byte packets

Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
---
 drivers/net/ethernet/socionext/netsec.c | 19 +++++--------------
 1 file changed, 5 insertions(+), 14 deletions(-)

diff --git a/drivers/net/ethernet/socionext/netsec.c b/drivers/net/ethernet/socionext/netsec.c
index 01589b6..ae32909 100644
--- a/drivers/net/ethernet/socionext/netsec.c
+++ b/drivers/net/ethernet/socionext/netsec.c
@@ -657,8 +657,6 @@ static struct sk_buff *netsec_get_rx_pkt_data(struct netsec_priv *priv,
 	/* move tail ahead */
 	dring->tail = (dring->tail + 1) % DESC_NUM;
 
-	dring->pkt_cnt--;
-
 	return skb;
 }
 
@@ -731,25 +729,18 @@ static int netsec_process_rx(struct netsec_priv *priv, int budget)
 	struct netsec_desc_ring *dring = &priv->desc_ring[NETSEC_RING_RX];
 	struct net_device *ndev = priv->ndev;
 	struct netsec_rx_pkt_info rx_info;
-	int done = 0, rx_num = 0;
+	int done = 0;
 	struct netsec_desc desc;
 	struct sk_buff *skb;
 	u16 len;
 
 	while (done < budget) {
-		if (!rx_num) {
-			rx_num = netsec_read(priv, NETSEC_REG_NRM_RX_PKTCNT);
-			dring->pkt_cnt += rx_num;
-
-			/* move head 'rx_num' */
-			dring->head = (dring->head + rx_num) % DESC_NUM;
+		u16 idx = dring->tail;
+		struct netsec_de *de = dring->vaddr + (DESC_SZ * idx);
 
-			rx_num = dring->pkt_cnt;
-			if (!rx_num)
-				break;
-		}
+		if (de->attr & (1U << NETSEC_RX_PKT_OWN_FIELD))
+			break;
 		done++;
-		rx_num--;
 		skb = netsec_get_rx_pkt_data(priv, &rx_info, &desc, &len);
 		if (unlikely(!skb) || rx_info.err_flag) {
 			netif_err(priv, drv, priv->ndev,
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [net-next, PATCH 2/2] net: socionext: Increase descriptors to 256
  2018-08-09  8:02 [net-next, PATCH 1/2] net: socionext: Use descriptor info instead of MMIO reads on Rx Ilias Apalodimas
@ 2018-08-09  8:02 ` Ilias Apalodimas
  2018-08-09 15:37 ` [net-next, PATCH 1/2] net: socionext: Use descriptor info instead of MMIO reads on Rx Arnd Bergmann
  1 sibling, 0 replies; 4+ messages in thread
From: Ilias Apalodimas @ 2018-08-09  8:02 UTC (permalink / raw)
  To: netdev, jaswinder.singh; +Cc: arnd, Ilias Apalodimas

Increasing descriptors to 256 from 128 and adjusting the NAPI weight
to 64 increases performace on Rx by ~20% on 64byte packets

Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
---
 drivers/net/ethernet/socionext/netsec.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/socionext/netsec.c b/drivers/net/ethernet/socionext/netsec.c
index ae32909..5d2007b 100644
--- a/drivers/net/ethernet/socionext/netsec.c
+++ b/drivers/net/ethernet/socionext/netsec.c
@@ -232,8 +232,7 @@
 #define NETSEC_EEPROM_PKT_ME_ADDRESS		0x20
 #define NETSEC_EEPROM_PKT_ME_SIZE		0x24
 
-#define DESC_NUM	128
-#define NAPI_BUDGET	(DESC_NUM / 2)
+#define DESC_NUM	256
 
 #define DESC_SZ	sizeof(struct netsec_de)
 
@@ -1655,7 +1654,7 @@ static int netsec_probe(struct platform_device *pdev)
 	dev_info(&pdev->dev, "hardware revision %d.%d\n",
 		 hw_ver >> 16, hw_ver & 0xffff);
 
-	netif_napi_add(ndev, &priv->napi, netsec_napi_poll, NAPI_BUDGET);
+	netif_napi_add(ndev, &priv->napi, netsec_napi_poll, NAPI_POLL_WEIGHT);
 
 	ndev->netdev_ops = &netsec_netdev_ops;
 	ndev->ethtool_ops = &netsec_ethtool_ops;
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [net-next, PATCH 1/2] net: socionext: Use descriptor info instead of MMIO reads on Rx
  2018-08-09  8:02 [net-next, PATCH 1/2] net: socionext: Use descriptor info instead of MMIO reads on Rx Ilias Apalodimas
  2018-08-09  8:02 ` [net-next, PATCH 2/2] net: socionext: Increase descriptors to 256 Ilias Apalodimas
@ 2018-08-09 15:37 ` Arnd Bergmann
  2018-08-09 19:05   ` Ilias Apalodimas
  1 sibling, 1 reply; 4+ messages in thread
From: Arnd Bergmann @ 2018-08-09 15:37 UTC (permalink / raw)
  To: Ilias Apalodimas; +Cc: Networking, Jassi Brar

On Thu, Aug 9, 2018 at 10:02 AM Ilias Apalodimas
<ilias.apalodimas@linaro.org> wrote:
>
> MMIO reads for remaining packets in queue occur (at least)twice per
> invocation of netsec_process_rx(). We can use the packet descriptor to
> identify if it's owned by the hardware and break out, avoiding the more
> expensive MMIO read operations. This has a ~2% increase on the pps of the
> Rx path when tested with 64byte packets
>
> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
> ---
>  drivers/net/ethernet/socionext/netsec.c | 19 +++++--------------
>  1 file changed, 5 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/net/ethernet/socionext/netsec.c b/drivers/net/ethernet/socionext/netsec.c
> index 01589b6..ae32909 100644
> --- a/drivers/net/ethernet/socionext/netsec.c
> +++ b/drivers/net/ethernet/socionext/netsec.c
> @@ -657,8 +657,6 @@ static struct sk_buff *netsec_get_rx_pkt_data(struct netsec_priv *priv,

> +               if (de->attr & (1U << NETSEC_RX_PKT_OWN_FIELD))
> +                       break;
>                 done++;

Should this use READ_ONCE() to prevent the compiler from moving the
access around? I see that netsec_get_rx_pkt_data() has a dma_rmb()
before reading the data, which prevents the CPU from doing something
wrong here, but not the compiler.

        Arnd

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [net-next, PATCH 1/2] net: socionext: Use descriptor info instead of MMIO reads on Rx
  2018-08-09 15:37 ` [net-next, PATCH 1/2] net: socionext: Use descriptor info instead of MMIO reads on Rx Arnd Bergmann
@ 2018-08-09 19:05   ` Ilias Apalodimas
  0 siblings, 0 replies; 4+ messages in thread
From: Ilias Apalodimas @ 2018-08-09 19:05 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: Networking, Jassi Brar

On Thu, Aug 09, 2018 at 05:37:15PM +0200, Arnd Bergmann wrote:
> On Thu, Aug 9, 2018 at 10:02 AM Ilias Apalodimas
> <ilias.apalodimas@linaro.org> wrote:
> >
> > MMIO reads for remaining packets in queue occur (at least)twice per
> > invocation of netsec_process_rx(). We can use the packet descriptor to
> > identify if it's owned by the hardware and break out, avoiding the more
> > expensive MMIO read operations. This has a ~2% increase on the pps of the
> > Rx path when tested with 64byte packets
> >
> > Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
> > ---
> >  drivers/net/ethernet/socionext/netsec.c | 19 +++++--------------
> >  1 file changed, 5 insertions(+), 14 deletions(-)
> >
> > diff --git a/drivers/net/ethernet/socionext/netsec.c b/drivers/net/ethernet/socionext/netsec.c
> > index 01589b6..ae32909 100644
> > --- a/drivers/net/ethernet/socionext/netsec.c
> > +++ b/drivers/net/ethernet/socionext/netsec.c
> > @@ -657,8 +657,6 @@ static struct sk_buff *netsec_get_rx_pkt_data(struct netsec_priv *priv,
> 
> > +               if (de->attr & (1U << NETSEC_RX_PKT_OWN_FIELD))
> > +                       break;
> >                 done++;
> 
> Should this use READ_ONCE() to prevent the compiler from moving the
> access around? I see that netsec_get_rx_pkt_data() has a dma_rmb()
> before reading the data, which prevents the CPU from doing something
> wrong here, but not the compiler.
> 
>         Arnd
As we discussed i'll send a V2 with the dma_rmb() right after the desc status
read

Thnaks
Ilias

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-08-09 21:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-09  8:02 [net-next, PATCH 1/2] net: socionext: Use descriptor info instead of MMIO reads on Rx Ilias Apalodimas
2018-08-09  8:02 ` [net-next, PATCH 2/2] net: socionext: Increase descriptors to 256 Ilias Apalodimas
2018-08-09 15:37 ` [net-next, PATCH 1/2] net: socionext: Use descriptor info instead of MMIO reads on Rx Arnd Bergmann
2018-08-09 19:05   ` Ilias Apalodimas

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.