* [PATCH net-next] net: bcmgenet: collect Rx discarded packet count @ 2015-03-10 19:18 Petri Gynther 2015-03-10 19:43 ` Florian Fainelli 0 siblings, 1 reply; 4+ messages in thread From: Petri Gynther @ 2015-03-10 19:18 UTC (permalink / raw) To: netdev; +Cc: davem, f.fainelli, jaedon.shin Bits 31:16 of RDMA_PROD_INDEX contain Rx discarded packet count, which are the Rx packets that had to be dropped by MAC hardware since there was no room on the Rx queue. Add code to collect this information into the netdev stats. Signed-off-by: Petri Gynther <pgynther@google.com> --- drivers/net/ethernet/broadcom/genet/bcmgenet.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c index 275be56..7aa1834 100644 --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c @@ -1384,9 +1384,19 @@ static unsigned int bcmgenet_desc_rx(struct bcmgenet_priv *priv, int len, err; unsigned int rxpktprocessed = 0, rxpkttoprocess; unsigned int p_index; + unsigned int discards; unsigned int chksum_ok = 0; p_index = bcmgenet_rdma_ring_readl(priv, index, RDMA_PROD_INDEX); + + discards = (p_index >> DMA_P_INDEX_DISCARD_CNT_SHIFT) & + DMA_P_INDEX_DISCARD_CNT_MASK; + if (discards > 0) { + bcmgenet_rdma_ring_writel(priv, index, 0, RDMA_PROD_INDEX); + dev->stats.rx_missed_errors += discards; + dev->stats.rx_errors += discards; + } + p_index &= DMA_P_INDEX_MASK; if (likely(p_index >= ring->c_index)) -- 2.2.0.rc0.207.ga3a616c ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] net: bcmgenet: collect Rx discarded packet count 2015-03-10 19:18 [PATCH net-next] net: bcmgenet: collect Rx discarded packet count Petri Gynther @ 2015-03-10 19:43 ` Florian Fainelli 2015-03-10 20:52 ` Petri Gynther 0 siblings, 1 reply; 4+ messages in thread From: Florian Fainelli @ 2015-03-10 19:43 UTC (permalink / raw) To: Petri Gynther, netdev; +Cc: davem, jaedon.shin On 10/03/15 12:18, Petri Gynther wrote: > Bits 31:16 of RDMA_PROD_INDEX contain Rx discarded packet count, which > are the Rx packets that had to be dropped by MAC hardware since there > was no room on the Rx queue. Add code to collect this information into > the netdev stats. > > Signed-off-by: Petri Gynther <pgynther@google.com> > --- > drivers/net/ethernet/broadcom/genet/bcmgenet.c | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c > index 275be56..7aa1834 100644 > --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c > +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c > @@ -1384,9 +1384,19 @@ static unsigned int bcmgenet_desc_rx(struct bcmgenet_priv *priv, > int len, err; > unsigned int rxpktprocessed = 0, rxpkttoprocess; > unsigned int p_index; > + unsigned int discards; > unsigned int chksum_ok = 0; > > p_index = bcmgenet_rdma_ring_readl(priv, index, RDMA_PROD_INDEX); > + > + discards = (p_index >> DMA_P_INDEX_DISCARD_CNT_SHIFT) & > + DMA_P_INDEX_DISCARD_CNT_MASK; > + if (discards > 0) { > + bcmgenet_rdma_ring_writel(priv, index, 0, RDMA_PROD_INDEX); This adds an expensive register write (~300ns on MIPS, ~200ns on ARM) in the hot-path, and the counter saturation happens at 0xffff, which I would prefer we deal with explicitly, even though that means missing a bunch of discard events once we have already saturated, rather than resetting this counter *and* the producer index for every NAPI round we get called. You could also deal with this counter in the ethtool gstats functions and perform the saturation handle there, since this is a slow path already. > + dev->stats.rx_missed_errors += discards; > + dev->stats.rx_errors += discards; > + } > + > p_index &= DMA_P_INDEX_MASK; > > if (likely(p_index >= ring->c_index)) > -- Florian ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] net: bcmgenet: collect Rx discarded packet count 2015-03-10 19:43 ` Florian Fainelli @ 2015-03-10 20:52 ` Petri Gynther 2015-03-10 21:29 ` David Miller 0 siblings, 1 reply; 4+ messages in thread From: Petri Gynther @ 2015-03-10 20:52 UTC (permalink / raw) To: Florian Fainelli; +Cc: netdev, David Miller, Jaedon Shin Hi Florian, On Tue, Mar 10, 2015 at 12:43 PM, Florian Fainelli <f.fainelli@gmail.com> wrote: > On 10/03/15 12:18, Petri Gynther wrote: >> Bits 31:16 of RDMA_PROD_INDEX contain Rx discarded packet count, which >> are the Rx packets that had to be dropped by MAC hardware since there >> was no room on the Rx queue. Add code to collect this information into >> the netdev stats. >> >> Signed-off-by: Petri Gynther <pgynther@google.com> >> --- >> drivers/net/ethernet/broadcom/genet/bcmgenet.c | 10 ++++++++++ >> 1 file changed, 10 insertions(+) >> >> diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c >> index 275be56..7aa1834 100644 >> --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c >> +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c >> @@ -1384,9 +1384,19 @@ static unsigned int bcmgenet_desc_rx(struct bcmgenet_priv *priv, >> int len, err; >> unsigned int rxpktprocessed = 0, rxpkttoprocess; >> unsigned int p_index; >> + unsigned int discards; >> unsigned int chksum_ok = 0; >> >> p_index = bcmgenet_rdma_ring_readl(priv, index, RDMA_PROD_INDEX); >> + >> + discards = (p_index >> DMA_P_INDEX_DISCARD_CNT_SHIFT) & >> + DMA_P_INDEX_DISCARD_CNT_MASK; >> + if (discards > 0) { >> + bcmgenet_rdma_ring_writel(priv, index, 0, RDMA_PROD_INDEX); > > This adds an expensive register write (~300ns on MIPS, ~200ns on ARM) in > the hot-path, and the counter saturation happens at 0xffff, which I > would prefer we deal with explicitly, even though that means missing a > bunch of discard events once we have already saturated, rather than > resetting this counter *and* the producer index for every NAPI round we > get called. > > You could also deal with this counter in the ethtool gstats functions > and perform the saturation handle there, since this is a slow path already. > It is a rare event that discards > 0. Thus, the extra register write happens very infrequently. And, writing 0 to RDMA_PROD_INDEX does not reset the producer index bits 15:0 that are used in Rx processing. >> + dev->stats.rx_missed_errors += discards; >> + dev->stats.rx_errors += discards; >> + } >> + >> p_index &= DMA_P_INDEX_MASK; >> >> if (likely(p_index >= ring->c_index)) >> > > > -- > Florian ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] net: bcmgenet: collect Rx discarded packet count 2015-03-10 20:52 ` Petri Gynther @ 2015-03-10 21:29 ` David Miller 0 siblings, 0 replies; 4+ messages in thread From: David Miller @ 2015-03-10 21:29 UTC (permalink / raw) To: pgynther; +Cc: f.fainelli, netdev, jaedon.shin From: Petri Gynther <pgynther@google.com> Date: Tue, 10 Mar 2015 13:52:32 -0700 > It is a rare event that discards > 0. Thus, the extra register write > happens very infrequently. > > And, writing 0 to RDMA_PROD_INDEX does not reset the producer index > bits 15:0 that are used in Rx processing. You can defer the write until you see the 0xffff saturation value. Or, perhaps, half the saturation value. Anything is better than doing it on any discard, because this overhead will make whatever is causing the cpu to be backlogged even worse. ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-03-10 21:29 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2015-03-10 19:18 [PATCH net-next] net: bcmgenet: collect Rx discarded packet count Petri Gynther 2015-03-10 19:43 ` Florian Fainelli 2015-03-10 20:52 ` Petri Gynther 2015-03-10 21:29 ` David Miller
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.