#define ETH_SWITCH_HEADER_LEN 2
-static int ag71xx_tx_packets(struct ag71xx *ag, bool flush);
+static int ag71xx_tx_packets(struct ag71xx *ag, bool flush, int budget);
static inline unsigned int ag71xx_max_frame_len(unsigned int mtu)
{
mii_reg = ag71xx_rr(ag, AG71XX_REG_MII_CFG);
rx_ds = ag71xx_rr(ag, AG71XX_REG_RX_DESC);
- ag71xx_tx_packets(ag, true);
+ ag71xx_tx_packets(ag, true, 0);
reset_control_assert(ag->mac_reset);
udelay(10);
napi_schedule(&ag->napi);
}
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,6,0)
static void ag71xx_tx_timeout(struct net_device *dev, unsigned int txqueue)
-#else
-static void ag71xx_tx_timeout(struct net_device *dev)
-#endif
{
struct ag71xx *ag = netdev_priv(dev);
return false;
}
-static int ag71xx_tx_packets(struct ag71xx *ag, bool flush)
+static int ag71xx_tx_packets(struct ag71xx *ag, bool flush, int budget)
{
struct ag71xx_ring *ring = &ag->tx_ring;
bool dma_stuck = false;
if (!skb)
continue;
- dev_kfree_skb_any(skb);
+ napi_consume_skb(skb, budget);
ring->buf[i].skb = NULL;
bytes_compl += ring->buf[i].len;
dev->stats.rx_packets++;
dev->stats.rx_bytes += pktlen;
- skb = build_skb(ring->buf[i].rx_buf, ag71xx_buffer_size(ag));
+ skb = napi_build_skb(ring->buf[i].rx_buf, ag71xx_buffer_size(ag));
if (!skb) {
skb_free_frag(ring->buf[i].rx_buf);
goto next;
int tx_done;
int rx_done;
- tx_done = ag71xx_tx_packets(ag, false);
+ tx_done = ag71xx_tx_packets(ag, false, limit);
DBG("%s: processing RX ring\n", dev->name);
rx_done = ag71xx_rx_packets(ag, limit);
struct net_device *dev;
struct resource *res;
struct ag71xx *ag;
- const void *mac_addr;
u32 max_frame_len;
int tx_size, err;
return -ENOMEM;
}
+ /* ensure that HW is in manual polling mode before interrupts are
+ * activated. Otherwise ag71xx_interrupt might call napi_schedule
+ * before it is initialized by netif_napi_add.
+ */
+ ag71xx_int_disable(ag, AG71XX_INT_POLL);
+
dev->irq = platform_get_irq(pdev, 0);
err = devm_request_irq(&pdev->dev, dev->irq, ag71xx_interrupt,
0x0, dev_name(&pdev->dev), dev);
ag->stop_desc->ctrl = 0;
ag->stop_desc->next = (u32) ag->stop_desc_dma;
- mac_addr = of_get_mac_address(np);
- if (IS_ERR_OR_NULL(mac_addr) || !is_valid_ether_addr(mac_addr)) {
+ of_get_mac_address(np, dev->dev_addr);
+ if (!is_valid_ether_addr(dev->dev_addr)) {
dev_err(&pdev->dev, "invalid MAC address, using random address\n");
eth_random_addr(dev->dev_addr);
- } else {
- memcpy(dev->dev_addr, mac_addr, ETH_ALEN);
}
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,10,0)
err = of_get_phy_mode(np, &ag->phy_if_mode);
if (err < 0) {
-#else
- ag->phy_if_mode = of_get_phy_mode(np);
- if (ag->phy_if_mode < 0) {
-#endif
dev_err(&pdev->dev, "missing phy-mode property in DT\n");
return ag->phy_if_mode;
}