On Sun, 30 Jan 2022 00:43:46 +0800 Joseph CHAMG wrote: > + rdptr = skb_put(skb, rxlen - 4); > + ret = regmap_noinc_read(db->regmap_dm, DM_SPI_MRCMD, rdptr, rxlen); > + if (ret) { should be counted as rx_error > + dev_kfree_skb(skb); > + return ret; > + } > + > + ret = regmap_write(db->regmap_dm, DM9051_ISR, 0xff); /* to stop mrcmd */ > + if (ret) > + return ret; leaks skb, also should be counted as rx_error > + skb->protocol = eth_type_trans(skb, db->ndev); > + if (db->ndev->features & NETIF_F_RXCSUM) > + skb_checksum_none_assert(skb); > + netif_rx_ni(skb); > + db->ndev->stats.rx_bytes += rxlen; > + db->ndev->stats.rx_packets++; > + scanrr++; > + } while (!ret); > + > + return scanrr; > +} > + > +/* transmit a packet, > + * return value, > + * 0 - succeed > + * -ETIMEDOUT - timeout error > + */ > +static int dm9051_single_tx(struct board_info *db, u8 *buff, unsigned int len) > +{ > + int ret; > + > + ret = dm9051_map_xmitpoll(db); > + if (ret) > + return ret; > + > + ret = regmap_noinc_write(db->regmap_dm, DM_SPI_MWCMD, buff, len); > + if (ret) > + return ret; > + > + ret = regmap_bulk_write(db->regmap_dmbulk, DM9051_TXPLL, &len, 2); > + if (ret < 0) > + return ret; > + > + return regmap_write(db->regmap_dm, DM9051_TCR, TCR_TXREQ); > +} > + > +static int dm9051_loop_tx(struct board_info *db) > +{ > + struct net_device *ndev = db->ndev; > + int ntx = 0; > + int ret; > + > + while (!skb_queue_empty(&db->txq)) { > + struct sk_buff *skb; > + > + skb = skb_dequeue(&db->txq); > + if (skb) { > + ntx++; > + ret = dm9051_single_tx(db, skb->data, skb->len); > + dev_kfree_skb(skb); > + if (ret < 0) > + return 0; Should be counted as tx error? > + ndev->stats.tx_bytes += skb->len; > + ndev->stats.tx_packets++; > + } > + > + if (netif_queue_stopped(ndev) && > + (skb_queue_len(&db->txq) < DM9051_TX_QUE_LO_WATER)) > + netif_wake_queue(ndev); > + } > + > + return ntx;