|
|
|
@ -11,7 +11,7 @@ Signed-off-by: Felix Fietkau <nbd@openwrt.org> |
|
|
|
|
|
|
|
|
|
--- a/drivers/net/ethernet/broadcom/bgmac.c
|
|
|
|
|
+++ b/drivers/net/ethernet/broadcom/bgmac.c
|
|
|
|
|
@@ -545,18 +545,26 @@ static void bgmac_dma_ring_desc_free(str
|
|
|
|
|
@@ -562,18 +562,26 @@ static void bgmac_dma_ring_desc_free(str
|
|
|
|
|
ring->dma_base);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -44,7 +44,7 @@ Signed-off-by: Felix Fietkau <nbd@openwrt.org> |
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int bgmac_dma_alloc(struct bgmac *bgmac)
|
|
|
|
|
@@ -604,8 +612,6 @@ static int bgmac_dma_alloc(struct bgmac
|
|
|
|
|
@@ -621,8 +629,6 @@ static int bgmac_dma_alloc(struct bgmac
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < BGMAC_MAX_RX_RINGS; i++) {
|
|
|
|
@ -53,7 +53,7 @@ Signed-off-by: Felix Fietkau <nbd@openwrt.org> |
|
|
|
|
ring = &bgmac->rx_ring[i];
|
|
|
|
|
ring->num_slots = BGMAC_RX_RING_SLOTS;
|
|
|
|
|
ring->mmio_base = ring_base[i];
|
|
|
|
|
@@ -628,15 +634,6 @@ static int bgmac_dma_alloc(struct bgmac
|
|
|
|
|
@@ -645,15 +651,6 @@ static int bgmac_dma_alloc(struct bgmac
|
|
|
|
|
ring->index_base = lower_32_bits(ring->dma_base);
|
|
|
|
|
else
|
|
|
|
|
ring->index_base = 0;
|
|
|
|
@ -69,7 +69,7 @@ Signed-off-by: Felix Fietkau <nbd@openwrt.org> |
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
@@ -646,10 +643,10 @@ err_dma_free:
|
|
|
|
|
@@ -663,10 +660,10 @@ err_dma_free:
|
|
|
|
|
return -ENOMEM;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -82,7 +82,7 @@ Signed-off-by: Felix Fietkau <nbd@openwrt.org> |
|
|
|
|
|
|
|
|
|
for (i = 0; i < BGMAC_MAX_TX_RINGS; i++) {
|
|
|
|
|
ring = &bgmac->tx_ring[i];
|
|
|
|
|
@@ -681,8 +678,13 @@ static void bgmac_dma_init(struct bgmac
|
|
|
|
|
@@ -698,8 +695,13 @@ static void bgmac_dma_init(struct bgmac
|
|
|
|
|
if (ring->unaligned)
|
|
|
|
|
bgmac_dma_rx_enable(bgmac, ring);
|
|
|
|
|
|
|
|
|
@ -90,23 +90,27 @@ Signed-off-by: Felix Fietkau <nbd@openwrt.org> |
|
|
|
|
+ for (j = 0; j < ring->num_slots; j++) {
|
|
|
|
|
+ err = bgmac_dma_rx_skb_for_slot(bgmac, &ring->slots[j]);
|
|
|
|
|
+ if (err)
|
|
|
|
|
+ return err;
|
|
|
|
|
+ goto error;
|
|
|
|
|
+
|
|
|
|
|
bgmac_dma_rx_setup_desc(bgmac, ring, j);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
bgmac_write(bgmac, ring->mmio_base + BGMAC_DMA_RX_INDEX,
|
|
|
|
|
ring->index_base +
|
|
|
|
|
@@ -691,6 +693,8 @@ static void bgmac_dma_init(struct bgmac
|
|
|
|
|
@@ -708,6 +710,12 @@ static void bgmac_dma_init(struct bgmac
|
|
|
|
|
ring->start = 0;
|
|
|
|
|
ring->end = 0;
|
|
|
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ return 0;
|
|
|
|
|
+
|
|
|
|
|
+error:
|
|
|
|
|
+ bgmac_dma_cleanup(bgmac);
|
|
|
|
|
+ return err;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**************************************************
|
|
|
|
|
@@ -1166,11 +1170,8 @@ static void bgmac_enable(struct bgmac *b
|
|
|
|
|
@@ -1183,11 +1191,8 @@ static void bgmac_enable(struct bgmac *b
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* http://bcm-v4.sipsolutions.net/mac-gbit/gmac/chipinit */
|
|
|
|
@ -119,7 +123,7 @@ Signed-off-by: Felix Fietkau <nbd@openwrt.org> |
|
|
|
|
/* 1 interrupt per received frame */
|
|
|
|
|
bgmac_write(bgmac, BGMAC_INT_RECV_LAZY, 1 << BGMAC_IRL_FC_SHIFT);
|
|
|
|
|
|
|
|
|
|
@@ -1188,16 +1189,7 @@ static void bgmac_chip_init(struct bgmac
|
|
|
|
|
@@ -1205,16 +1210,7 @@ static void bgmac_chip_init(struct bgmac
|
|
|
|
|
|
|
|
|
|
bgmac_write(bgmac, BGMAC_RXMAX_LENGTH, 32 + ETHER_MAX_LEN);
|
|
|
|
|
|
|
|
|
@ -137,14 +141,14 @@ Signed-off-by: Felix Fietkau <nbd@openwrt.org> |
|
|
|
|
|
|
|
|
|
bgmac_enable(bgmac);
|
|
|
|
|
}
|
|
|
|
|
@@ -1257,8 +1249,13 @@ static int bgmac_open(struct net_device
|
|
|
|
|
@@ -1274,23 +1270,27 @@ static int bgmac_open(struct net_device
|
|
|
|
|
int err = 0;
|
|
|
|
|
|
|
|
|
|
bgmac_chip_reset(bgmac);
|
|
|
|
|
+
|
|
|
|
|
+ err = bgmac_dma_init(bgmac);
|
|
|
|
|
+ if (err)
|
|
|
|
|
+ goto err_out;
|
|
|
|
|
+ return err;
|
|
|
|
|
+
|
|
|
|
|
/* Specs say about reclaiming rings here, but we do that in DMA init */
|
|
|
|
|
- bgmac_chip_init(bgmac, true);
|
|
|
|
@ -152,18 +156,25 @@ Signed-off-by: Felix Fietkau <nbd@openwrt.org> |
|
|
|
|
|
|
|
|
|
err = request_irq(bgmac->core->irq, bgmac_interrupt, IRQF_SHARED,
|
|
|
|
|
KBUILD_MODNAME, net_dev);
|
|
|
|
|
@@ -1271,8 +1268,10 @@ static int bgmac_open(struct net_device
|
|
|
|
|
if (err < 0) {
|
|
|
|
|
bgmac_err(bgmac, "IRQ request error: %d!\n", err);
|
|
|
|
|
- goto err_out;
|
|
|
|
|
+ bgmac_dma_cleanup(bgmac);
|
|
|
|
|
+ return err;
|
|
|
|
|
}
|
|
|
|
|
napi_enable(&bgmac->napi);
|
|
|
|
|
|
|
|
|
|
phy_start(bgmac->phy_dev);
|
|
|
|
|
|
|
|
|
|
netif_carrier_on(net_dev);
|
|
|
|
|
-
|
|
|
|
|
-err_out:
|
|
|
|
|
- return err;
|
|
|
|
|
+ return 0;
|
|
|
|
|
|
|
|
|
|
err_out:
|
|
|
|
|
+ bgmac_dma_cleanup(bgmac);
|
|
|
|
|
return err;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -1289,6 +1288,7 @@ static int bgmac_stop(struct net_device
|
|
|
|
|
static int bgmac_stop(struct net_device *net_dev)
|
|
|
|
|
@@ -1306,6 +1306,7 @@ static int bgmac_stop(struct net_device
|
|
|
|
|
free_irq(bgmac->core->irq, net_dev);
|
|
|
|
|
|
|
|
|
|
bgmac_chip_reset(bgmac);
|
|
|
|
|