Skip to content

Commit def52db

Browse files
pbrkrPaolo Abeni
authored andcommitted
net: ravb: Count packets instead of descriptors in R-Car RX path
The units of "work done" in the RX path should be packets instead of descriptors. Descriptors which are used by the hardware to record error conditions or are empty in the case of a DMA mapping error should not count towards our RX work budget. Also make the limit variable unsigned as it can never be negative. Fixes: c156633 ("Renesas Ethernet AVB driver proper") Signed-off-by: Paul Barker <[email protected]> Reviewed-by: Sergey Shtylyov <[email protected]> Reviewed-by: Niklas Söderlund <[email protected]> Signed-off-by: Paolo Abeni <[email protected]>
1 parent 9466794 commit def52db

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

drivers/net/ethernet/renesas/ravb_main.c

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -892,29 +892,24 @@ static bool ravb_rx_rcar(struct net_device *ndev, int *quota, int q)
892892
struct ravb_private *priv = netdev_priv(ndev);
893893
const struct ravb_hw_info *info = priv->info;
894894
int entry = priv->cur_rx[q] % priv->num_rx_ring[q];
895-
int boguscnt = (priv->dirty_rx[q] + priv->num_rx_ring[q]) -
896-
priv->cur_rx[q];
897895
struct net_device_stats *stats = &priv->stats[q];
898896
struct ravb_ex_rx_desc *desc;
897+
unsigned int limit, i;
899898
struct sk_buff *skb;
900899
dma_addr_t dma_addr;
901900
struct timespec64 ts;
901+
int rx_packets = 0;
902902
u8 desc_status;
903903
u16 pkt_len;
904-
int limit;
905904

906-
boguscnt = min(boguscnt, *quota);
907-
limit = boguscnt;
905+
limit = priv->dirty_rx[q] + priv->num_rx_ring[q] - priv->cur_rx[q];
908906
desc = &priv->rx_ring[q].ex_desc[entry];
909-
while (desc->die_dt != DT_FEMPTY) {
907+
for (i = 0; i < limit && rx_packets < *quota && desc->die_dt != DT_FEMPTY; i++) {
910908
/* Descriptor type must be checked before all other reads */
911909
dma_rmb();
912910
desc_status = desc->msc;
913911
pkt_len = le16_to_cpu(desc->ds_cc) & RX_DS;
914912

915-
if (--boguscnt < 0)
916-
break;
917-
918913
/* We use 0-byte descriptors to mark the DMA mapping errors */
919914
if (!pkt_len)
920915
continue;
@@ -960,7 +955,7 @@ static bool ravb_rx_rcar(struct net_device *ndev, int *quota, int q)
960955
if (ndev->features & NETIF_F_RXCSUM)
961956
ravb_rx_csum(skb);
962957
napi_gro_receive(&priv->napi[q], skb);
963-
stats->rx_packets++;
958+
rx_packets++;
964959
stats->rx_bytes += pkt_len;
965960
}
966961

@@ -995,9 +990,9 @@ static bool ravb_rx_rcar(struct net_device *ndev, int *quota, int q)
995990
desc->die_dt = DT_FEMPTY;
996991
}
997992

998-
*quota -= limit - (++boguscnt);
999-
1000-
return boguscnt <= 0;
993+
stats->rx_packets += rx_packets;
994+
*quota -= rx_packets;
995+
return *quota == 0;
1001996
}
1002997

1003998
/* Packet receive function for Ethernet AVB */

0 commit comments

Comments
 (0)