kernel: update bgmac patches to the latest version submitted

Signed-off-by: Felix Fietkau <nbd@openwrt.org>

SVN-Revision: 45431
This commit is contained in:
Felix Fietkau 2015-04-14 12:17:20 +00:00
parent cd4fd05648
commit 5c9c670616
10 changed files with 102 additions and 80 deletions

View File

@ -25,22 +25,24 @@ Signed-off-by: Felix Fietkau <nbd@openwrt.org>
int i; int i;
if (skb->len > BGMAC_DESC_CTL1_LEN) { if (skb->len > BGMAC_DESC_CTL1_LEN) {
@@ -158,13 +157,7 @@ static netdev_tx_t bgmac_dma_tx_add(stru @@ -159,12 +158,10 @@ static netdev_tx_t bgmac_dma_tx_add(stru
skb_checksum_help(skb);
nr_frags = skb_shinfo(skb)->nr_frags; nr_frags = skb_shinfo(skb)->nr_frags;
-
- if (ring->start <= ring->end) - if (ring->start <= ring->end)
- free_slots = ring->start - ring->end + BGMAC_TX_RING_SLOTS; - free_slots = ring->start - ring->end + BGMAC_TX_RING_SLOTS;
- else - else
- free_slots = ring->start - ring->end; - free_slots = ring->start - ring->end;
- -
- if (free_slots <= nr_frags + 1) { - if (free_slots <= nr_frags + 1) {
+ /* ring->end - ring->start will return the number of valid slots,
+ * even when ring->end overflows
+ */
+ if (ring->end - ring->start + nr_frags + 1 >= BGMAC_TX_RING_SLOTS) { + if (ring->end - ring->start + nr_frags + 1 >= BGMAC_TX_RING_SLOTS) {
bgmac_err(bgmac, "TX ring is full, queue should be stopped!\n"); bgmac_err(bgmac, "TX ring is full, queue should be stopped!\n");
netif_stop_queue(net_dev); netif_stop_queue(net_dev);
return NETDEV_TX_BUSY; return NETDEV_TX_BUSY;
@@ -200,7 +193,7 @@ static netdev_tx_t bgmac_dma_tx_add(stru @@ -200,7 +197,7 @@ static netdev_tx_t bgmac_dma_tx_add(stru
} }
slot->skb = skb; slot->skb = skb;
@ -49,7 +51,7 @@ Signed-off-by: Felix Fietkau <nbd@openwrt.org>
netdev_sent_queue(net_dev, skb->len); netdev_sent_queue(net_dev, skb->len);
wmb(); wmb();
@@ -208,13 +201,12 @@ static netdev_tx_t bgmac_dma_tx_add(stru @@ -208,13 +205,12 @@ static netdev_tx_t bgmac_dma_tx_add(stru
/* Increase ring->end to point empty slot. We tell hardware the first /* Increase ring->end to point empty slot. We tell hardware the first
* slot it should *not* read. * slot it should *not* read.
*/ */
@ -66,7 +68,7 @@ Signed-off-by: Felix Fietkau <nbd@openwrt.org>
netif_stop_queue(net_dev); netif_stop_queue(net_dev);
return NETDEV_TX_OK; return NETDEV_TX_OK;
@@ -256,17 +248,17 @@ static void bgmac_dma_tx_free(struct bgm @@ -256,17 +252,17 @@ static void bgmac_dma_tx_free(struct bgm
empty_slot &= BGMAC_DMA_TX_STATDPTR; empty_slot &= BGMAC_DMA_TX_STATDPTR;
empty_slot /= sizeof(struct bgmac_dma_desc); empty_slot /= sizeof(struct bgmac_dma_desc);
@ -93,7 +95,7 @@ Signed-off-by: Felix Fietkau <nbd@openwrt.org>
if (ctl1 & BGMAC_DESC_CTL0_SOF) if (ctl1 & BGMAC_DESC_CTL0_SOF)
/* Unmap no longer used buffer */ /* Unmap no longer used buffer */
dma_unmap_single(dma_dev, slot->dma_addr, len, dma_unmap_single(dma_dev, slot->dma_addr, len,
@@ -284,10 +276,8 @@ static void bgmac_dma_tx_free(struct bgm @@ -284,10 +280,8 @@ static void bgmac_dma_tx_free(struct bgm
slot->skb = NULL; slot->skb = NULL;
} }

View File

@ -15,7 +15,7 @@ Signed-off-by: Felix Fietkau <nbd@openwrt.org>
--- a/drivers/net/ethernet/broadcom/bgmac.c --- a/drivers/net/ethernet/broadcom/bgmac.c
+++ b/drivers/net/ethernet/broadcom/bgmac.c +++ b/drivers/net/ethernet/broadcom/bgmac.c
@@ -1105,8 +1105,6 @@ static void bgmac_chip_reset(struct bgma @@ -1109,8 +1109,6 @@ static void bgmac_chip_reset(struct bgma
bgmac_phy_init(bgmac); bgmac_phy_init(bgmac);
netdev_reset_queue(bgmac->net_dev); netdev_reset_queue(bgmac->net_dev);
@ -24,7 +24,7 @@ Signed-off-by: Felix Fietkau <nbd@openwrt.org>
} }
static void bgmac_chip_intrs_on(struct bgmac *bgmac) static void bgmac_chip_intrs_on(struct bgmac *bgmac)
@@ -1221,14 +1219,13 @@ static irqreturn_t bgmac_interrupt(int i @@ -1225,14 +1223,13 @@ static irqreturn_t bgmac_interrupt(int i
if (!int_status) if (!int_status)
return IRQ_NONE; return IRQ_NONE;
@ -42,7 +42,7 @@ Signed-off-by: Felix Fietkau <nbd@openwrt.org>
napi_schedule(&bgmac->napi); napi_schedule(&bgmac->napi);
return IRQ_HANDLED; return IRQ_HANDLED;
@@ -1237,25 +1234,17 @@ static irqreturn_t bgmac_interrupt(int i @@ -1241,25 +1238,17 @@ static irqreturn_t bgmac_interrupt(int i
static int bgmac_poll(struct napi_struct *napi, int weight) static int bgmac_poll(struct napi_struct *napi, int weight)
{ {
struct bgmac *bgmac = container_of(napi, struct bgmac, napi); struct bgmac *bgmac = container_of(napi, struct bgmac, napi);

View File

@ -10,7 +10,7 @@ Signed-off-by: Felix Fietkau <nbd@openwrt.org>
--- a/drivers/net/ethernet/broadcom/bgmac.c --- a/drivers/net/ethernet/broadcom/bgmac.c
+++ b/drivers/net/ethernet/broadcom/bgmac.c +++ b/drivers/net/ethernet/broadcom/bgmac.c
@@ -342,13 +342,13 @@ static int bgmac_dma_rx_skb_for_slot(str @@ -346,13 +346,13 @@ static int bgmac_dma_rx_skb_for_slot(str
return -ENOMEM; return -ENOMEM;
/* Poison - if everything goes fine, hardware will overwrite it */ /* Poison - if everything goes fine, hardware will overwrite it */
@ -27,7 +27,7 @@ Signed-off-by: Felix Fietkau <nbd@openwrt.org>
if (dma_mapping_error(dma_dev, dma_addr)) { if (dma_mapping_error(dma_dev, dma_addr)) {
bgmac_err(bgmac, "DMA mapping error\n"); bgmac_err(bgmac, "DMA mapping error\n");
put_page(virt_to_head_page(buf)); put_page(virt_to_head_page(buf));
@@ -399,7 +399,7 @@ static int bgmac_dma_rx_read(struct bgma @@ -403,7 +403,7 @@ static int bgmac_dma_rx_read(struct bgma
while (ring->start != ring->end) { while (ring->start != ring->end) {
struct device *dma_dev = bgmac->core->dma_dev; struct device *dma_dev = bgmac->core->dma_dev;
struct bgmac_slot_info *slot = &ring->slots[ring->start]; struct bgmac_slot_info *slot = &ring->slots[ring->start];
@ -36,7 +36,7 @@ Signed-off-by: Felix Fietkau <nbd@openwrt.org>
struct sk_buff *skb; struct sk_buff *skb;
void *buf = slot->buf; void *buf = slot->buf;
u16 len, flags; u16 len, flags;
@@ -450,8 +450,10 @@ static int bgmac_dma_rx_read(struct bgma @@ -454,8 +454,10 @@ static int bgmac_dma_rx_read(struct bgma
BGMAC_RX_BUF_SIZE, DMA_FROM_DEVICE); BGMAC_RX_BUF_SIZE, DMA_FROM_DEVICE);
skb = build_skb(buf, BGMAC_RX_ALLOC_SIZE); skb = build_skb(buf, BGMAC_RX_ALLOC_SIZE);

View File

@ -1,19 +1,40 @@
From: Felix Fietkau <nbd@openwrt.org> From: Felix Fietkau <nbd@openwrt.org>
Date: Sun, 12 Apr 2015 22:23:07 +0200 Date: Sun, 12 Apr 2015 22:23:07 +0200
Subject: [PATCH] bgmac: simplify rx DMA error handling Subject: [PATCH] bgmac: simplify/optimize rx DMA error handling
Unmap the DMA buffer before checking it. If an error occurs, free the Allocate a new buffer before processing the completed one. If allocation
buffer and allocate a new one. If allocation or mapping fails, retry as fails, reuse the old buffer.
long as there is NAPI poll budget left (count every attempt instead of
every frame).
Signed-off-by: Felix Fietkau <nbd@openwrt.org> Signed-off-by: Felix Fietkau <nbd@openwrt.org>
--- ---
--- a/drivers/net/ethernet/broadcom/bgmac.c --- a/drivers/net/ethernet/broadcom/bgmac.c
+++ b/drivers/net/ethernet/broadcom/bgmac.c +++ b/drivers/net/ethernet/broadcom/bgmac.c
@@ -404,51 +404,33 @@ static int bgmac_dma_rx_read(struct bgma @@ -386,6 +386,19 @@ static void bgmac_dma_rx_setup_desc(stru
dma_desc->ctl1 = cpu_to_le32(ctl1);
}
+static void bgmac_dma_rx_poison_buf(struct device *dma_dev,
+ struct bgmac_slot_info *slot)
+{
+ struct bgmac_rx_header *rx = slot->buf + BGMAC_RX_BUF_OFFSET;
+
+ dma_sync_single_for_cpu(dma_dev, slot->dma_addr, BGMAC_RX_BUF_SIZE,
+ DMA_FROM_DEVICE);
+ rx->len = cpu_to_le16(0xdead);
+ rx->flags = cpu_to_le16(0xbeef);
+ dma_sync_single_for_device(dma_dev, slot->dma_addr, BGMAC_RX_BUF_SIZE,
+ DMA_FROM_DEVICE);
+}
+
static int bgmac_dma_rx_read(struct bgmac *bgmac, struct bgmac_dma_ring *ring,
int weight)
{
@@ -406,53 +419,35 @@ static int bgmac_dma_rx_read(struct bgma
struct bgmac_rx_header *rx = slot->buf + BGMAC_RX_BUF_OFFSET;
struct sk_buff *skb;
void *buf = slot->buf; void *buf = slot->buf;
+ dma_addr_t dma_addr = slot->dma_addr;
u16 len, flags; u16 len, flags;
- /* Unmap buffer to make it accessible to the CPU */ - /* Unmap buffer to make it accessible to the CPU */
@ -23,19 +44,19 @@ Signed-off-by: Felix Fietkau <nbd@openwrt.org>
- /* Get info from the header */ - /* Get info from the header */
- len = le16_to_cpu(rx->len); - len = le16_to_cpu(rx->len);
- flags = le16_to_cpu(rx->flags); - flags = le16_to_cpu(rx->flags);
+ if (++handled >= weight - 1) /* Should never be greater */ -
+ break;
do { do {
- dma_addr_t old_dma_addr = slot->dma_addr; - dma_addr_t old_dma_addr = slot->dma_addr;
- int err; - int err;
+ if (!slot->dma_addr) + /* Prepare new skb as replacement */
+ if (bgmac_dma_rx_skb_for_slot(bgmac, slot)) {
+ bgmac_dma_rx_poison_buf(dma_dev, slot);
+ break; + break;
+ }
+ +
+ /* Unmap buffer to make it accessible to the CPU */ + /* Unmap buffer to make it accessible to the CPU */
+ dma_unmap_single(dma_dev, slot->dma_addr, + dma_unmap_single(dma_dev, dma_addr,
+ BGMAC_RX_BUF_SIZE, DMA_FROM_DEVICE); + BGMAC_RX_BUF_SIZE, DMA_FROM_DEVICE);
+ slot->dma_addr = 0;
+ +
+ /* Get info from the header */ + /* Get info from the header */
+ len = le16_to_cpu(rx->len); + len = le16_to_cpu(rx->len);
@ -78,28 +99,16 @@ Signed-off-by: Felix Fietkau <nbd@openwrt.org>
skb = build_skb(buf, BGMAC_RX_ALLOC_SIZE); skb = build_skb(buf, BGMAC_RX_ALLOC_SIZE);
skb_put(skb, BGMAC_RX_FRAME_OFFSET + skb_put(skb, BGMAC_RX_FRAME_OFFSET +
BGMAC_RX_BUF_OFFSET + len); BGMAC_RX_BUF_OFFSET + len);
@@ -458,14 +440,16 @@ static int bgmac_dma_rx_read(struct bgma @@ -465,6 +460,8 @@ static int bgmac_dma_rx_read(struct bgma
skb_checksum_none_assert(skb); handled++;
skb->protocol = eth_type_trans(skb, bgmac->net_dev);
napi_gro_receive(&bgmac->napi, skb);
- handled++;
} while (0); } while (0);
+ /* Prepare new skb as replacement */
+ if (bgmac_dma_rx_skb_for_slot(bgmac, slot))
+ continue;
+
+ bgmac_dma_rx_setup_desc(bgmac, ring, ring->start); + bgmac_dma_rx_setup_desc(bgmac, ring, ring->start);
+ +
if (++ring->start >= BGMAC_RX_RING_SLOTS) if (++ring->start >= BGMAC_RX_RING_SLOTS)
ring->start = 0; ring->start = 0;
-
- if (handled >= weight) /* Should never be greater */
- break;
}
return handled; @@ -532,14 +529,14 @@ static void bgmac_dma_rx_ring_free(struc
@@ -528,14 +512,14 @@ static void bgmac_dma_rx_ring_free(struc
for (i = 0; i < ring->num_slots; i++) { for (i = 0; i < ring->num_slots; i++) {
slot = &ring->slots[i]; slot = &ring->slots[i];

View File

@ -11,7 +11,7 @@ Signed-off-by: Felix Fietkau <nbd@openwrt.org>
--- a/drivers/net/ethernet/broadcom/bgmac.c --- a/drivers/net/ethernet/broadcom/bgmac.c
+++ b/drivers/net/ethernet/broadcom/bgmac.c +++ b/drivers/net/ethernet/broadcom/bgmac.c
@@ -428,6 +428,13 @@ static int bgmac_dma_rx_read(struct bgma @@ -445,6 +445,13 @@ static int bgmac_dma_rx_read(struct bgma
break; break;
} }

View File

@ -11,7 +11,7 @@ Signed-off-by: Felix Fietkau <nbd@openwrt.org>
--- a/drivers/net/ethernet/broadcom/bgmac.c --- a/drivers/net/ethernet/broadcom/bgmac.c
+++ b/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); ring->dma_base);
} }
@ -44,7 +44,7 @@ Signed-off-by: Felix Fietkau <nbd@openwrt.org>
} }
static int bgmac_dma_alloc(struct bgmac *bgmac) 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++) { 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 = &bgmac->rx_ring[i];
ring->num_slots = BGMAC_RX_RING_SLOTS; ring->num_slots = BGMAC_RX_RING_SLOTS;
ring->mmio_base = ring_base[i]; 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); ring->index_base = lower_32_bits(ring->dma_base);
else else
ring->index_base = 0; ring->index_base = 0;
@ -69,7 +69,7 @@ Signed-off-by: Felix Fietkau <nbd@openwrt.org>
} }
return 0; return 0;
@@ -646,10 +643,10 @@ err_dma_free: @@ -663,10 +660,10 @@ err_dma_free:
return -ENOMEM; return -ENOMEM;
} }
@ -82,7 +82,7 @@ Signed-off-by: Felix Fietkau <nbd@openwrt.org>
for (i = 0; i < BGMAC_MAX_TX_RINGS; i++) { for (i = 0; i < BGMAC_MAX_TX_RINGS; i++) {
ring = &bgmac->tx_ring[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) if (ring->unaligned)
bgmac_dma_rx_enable(bgmac, ring); 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++) { + for (j = 0; j < ring->num_slots; j++) {
+ err = bgmac_dma_rx_skb_for_slot(bgmac, &ring->slots[j]); + err = bgmac_dma_rx_skb_for_slot(bgmac, &ring->slots[j]);
+ if (err) + if (err)
+ return err; + goto error;
+ +
bgmac_dma_rx_setup_desc(bgmac, ring, j); bgmac_dma_rx_setup_desc(bgmac, ring, j);
+ } + }
bgmac_write(bgmac, ring->mmio_base + BGMAC_DMA_RX_INDEX, bgmac_write(bgmac, ring->mmio_base + BGMAC_DMA_RX_INDEX,
ring->index_base + 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->start = 0;
ring->end = 0; ring->end = 0;
} }
+ +
+ return 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 */ /* 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 */ /* 1 interrupt per received frame */
bgmac_write(bgmac, BGMAC_INT_RECV_LAZY, 1 << BGMAC_IRL_FC_SHIFT); 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); 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); 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; int err = 0;
bgmac_chip_reset(bgmac); bgmac_chip_reset(bgmac);
+ +
+ err = bgmac_dma_init(bgmac); + err = bgmac_dma_init(bgmac);
+ if (err) + if (err)
+ goto err_out; + return err;
+ +
/* Specs say about reclaiming rings here, but we do that in DMA init */ /* Specs say about reclaiming rings here, but we do that in DMA init */
- bgmac_chip_init(bgmac, true); - 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, err = request_irq(bgmac->core->irq, bgmac_interrupt, IRQF_SHARED,
KBUILD_MODNAME, net_dev); 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); phy_start(bgmac->phy_dev);
netif_carrier_on(net_dev); netif_carrier_on(net_dev);
-
-err_out:
- return err;
+ return 0; + 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); free_irq(bgmac->core->irq, net_dev);
bgmac_chip_reset(bgmac); bgmac_chip_reset(bgmac);

View File

@ -17,7 +17,7 @@ Signed-off-by: Felix Fietkau <nbd@openwrt.org>
--- a/drivers/net/ethernet/broadcom/bgmac.c --- a/drivers/net/ethernet/broadcom/bgmac.c
+++ b/drivers/net/ethernet/broadcom/bgmac.c +++ b/drivers/net/ethernet/broadcom/bgmac.c
@@ -362,6 +362,16 @@ static int bgmac_dma_rx_skb_for_slot(str @@ -366,6 +366,16 @@ static int bgmac_dma_rx_skb_for_slot(str
return 0; return 0;
} }
@ -34,7 +34,7 @@ Signed-off-by: Felix Fietkau <nbd@openwrt.org>
static void bgmac_dma_rx_setup_desc(struct bgmac *bgmac, static void bgmac_dma_rx_setup_desc(struct bgmac *bgmac,
struct bgmac_dma_ring *ring, int desc_idx) struct bgmac_dma_ring *ring, int desc_idx)
{ {
@@ -380,6 +390,8 @@ static void bgmac_dma_rx_setup_desc(stru @@ -384,6 +394,8 @@ static void bgmac_dma_rx_setup_desc(stru
dma_desc->addr_high = cpu_to_le32(upper_32_bits(ring->slots[desc_idx].dma_addr)); dma_desc->addr_high = cpu_to_le32(upper_32_bits(ring->slots[desc_idx].dma_addr));
dma_desc->ctl0 = cpu_to_le32(ctl0); dma_desc->ctl0 = cpu_to_le32(ctl0);
dma_desc->ctl1 = cpu_to_le32(ctl1); dma_desc->ctl1 = cpu_to_le32(ctl1);
@ -42,8 +42,8 @@ Signed-off-by: Felix Fietkau <nbd@openwrt.org>
+ ring->end = desc_idx; + ring->end = desc_idx;
} }
static int bgmac_dma_rx_read(struct bgmac *bgmac, struct bgmac_dma_ring *ring, static void bgmac_dma_rx_poison_buf(struct device *dma_dev,
@@ -394,9 +406,7 @@ static int bgmac_dma_rx_read(struct bgma @@ -411,9 +423,7 @@ static int bgmac_dma_rx_read(struct bgma
end_slot &= BGMAC_DMA_RX_STATDPTR; end_slot &= BGMAC_DMA_RX_STATDPTR;
end_slot /= sizeof(struct bgmac_dma_desc); end_slot /= sizeof(struct bgmac_dma_desc);
@ -54,8 +54,8 @@ Signed-off-by: Felix Fietkau <nbd@openwrt.org>
struct device *dma_dev = bgmac->core->dma_dev; struct device *dma_dev = bgmac->core->dma_dev;
struct bgmac_slot_info *slot = &ring->slots[ring->start]; struct bgmac_slot_info *slot = &ring->slots[ring->start];
struct bgmac_rx_header *rx = slot->buf + BGMAC_RX_BUF_OFFSET; struct bgmac_rx_header *rx = slot->buf + BGMAC_RX_BUF_OFFSET;
@@ -459,6 +469,8 @@ static int bgmac_dma_rx_read(struct bgma @@ -476,6 +486,8 @@ static int bgmac_dma_rx_read(struct bgma
ring->start = 0; break;
} }
+ bgmac_dma_rx_update_index(bgmac, ring); + bgmac_dma_rx_update_index(bgmac, ring);
@ -63,7 +63,7 @@ Signed-off-by: Felix Fietkau <nbd@openwrt.org>
return handled; return handled;
} }
@@ -678,6 +690,8 @@ static int bgmac_dma_init(struct bgmac * @@ -695,6 +707,8 @@ static int bgmac_dma_init(struct bgmac *
if (ring->unaligned) if (ring->unaligned)
bgmac_dma_rx_enable(bgmac, ring); bgmac_dma_rx_enable(bgmac, ring);
@ -72,7 +72,7 @@ Signed-off-by: Felix Fietkau <nbd@openwrt.org>
for (j = 0; j < ring->num_slots; j++) { for (j = 0; j < ring->num_slots; j++) {
err = bgmac_dma_rx_skb_for_slot(bgmac, &ring->slots[j]); err = bgmac_dma_rx_skb_for_slot(bgmac, &ring->slots[j]);
if (err) if (err)
@@ -686,12 +700,7 @@ static int bgmac_dma_init(struct bgmac * @@ -703,12 +717,7 @@ static int bgmac_dma_init(struct bgmac *
bgmac_dma_rx_setup_desc(bgmac, ring, j); bgmac_dma_rx_setup_desc(bgmac, ring, j);
} }

View File

@ -19,7 +19,7 @@ Signed-off-by: Felix Fietkau <nbd@openwrt.org>
ctl0 |= BGMAC_DESC_CTL0_EOT; ctl0 |= BGMAC_DESC_CTL0_EOT;
ctl1 = len & BGMAC_DESC_CTL1_LEN; ctl1 = len & BGMAC_DESC_CTL1_LEN;
@@ -378,7 +378,7 @@ static void bgmac_dma_rx_setup_desc(stru @@ -382,7 +382,7 @@ static void bgmac_dma_rx_setup_desc(stru
struct bgmac_dma_desc *dma_desc = ring->cpu_base + desc_idx; struct bgmac_dma_desc *dma_desc = ring->cpu_base + desc_idx;
u32 ctl0 = 0, ctl1 = 0; u32 ctl0 = 0, ctl1 = 0;
@ -28,7 +28,7 @@ Signed-off-by: Felix Fietkau <nbd@openwrt.org>
ctl0 |= BGMAC_DESC_CTL0_EOT; ctl0 |= BGMAC_DESC_CTL0_EOT;
ctl1 |= BGMAC_RX_BUF_SIZE & BGMAC_DESC_CTL1_LEN; ctl1 |= BGMAC_RX_BUF_SIZE & BGMAC_DESC_CTL1_LEN;
/* Is there any BGMAC device that requires extension? */ /* Is there any BGMAC device that requires extension? */
@@ -504,7 +504,7 @@ static void bgmac_dma_tx_ring_free(struc @@ -521,7 +521,7 @@ static void bgmac_dma_tx_ring_free(struc
struct bgmac_slot_info *slot; struct bgmac_slot_info *slot;
int i; int i;
@ -37,7 +37,7 @@ Signed-off-by: Felix Fietkau <nbd@openwrt.org>
int len = dma_desc[i].ctl1 & BGMAC_DESC_CTL1_LEN; int len = dma_desc[i].ctl1 & BGMAC_DESC_CTL1_LEN;
slot = &ring->slots[i]; slot = &ring->slots[i];
@@ -529,7 +529,7 @@ static void bgmac_dma_rx_ring_free(struc @@ -546,7 +546,7 @@ static void bgmac_dma_rx_ring_free(struc
struct bgmac_slot_info *slot; struct bgmac_slot_info *slot;
int i; int i;
@ -46,7 +46,7 @@ Signed-off-by: Felix Fietkau <nbd@openwrt.org>
slot = &ring->slots[i]; slot = &ring->slots[i];
if (!slot->dma_addr) if (!slot->dma_addr)
continue; continue;
@@ -543,7 +543,8 @@ static void bgmac_dma_rx_ring_free(struc @@ -560,7 +560,8 @@ static void bgmac_dma_rx_ring_free(struc
} }
static void bgmac_dma_ring_desc_free(struct bgmac *bgmac, static void bgmac_dma_ring_desc_free(struct bgmac *bgmac,
@ -56,7 +56,7 @@ Signed-off-by: Felix Fietkau <nbd@openwrt.org>
{ {
struct device *dma_dev = bgmac->core->dma_dev; struct device *dma_dev = bgmac->core->dma_dev;
int size; int size;
@@ -552,7 +553,7 @@ static void bgmac_dma_ring_desc_free(str @@ -569,7 +570,7 @@ static void bgmac_dma_ring_desc_free(str
return; return;
/* Free ring of descriptors */ /* Free ring of descriptors */
@ -65,7 +65,7 @@ Signed-off-by: Felix Fietkau <nbd@openwrt.org>
dma_free_coherent(dma_dev, size, ring->cpu_base, dma_free_coherent(dma_dev, size, ring->cpu_base,
ring->dma_base); ring->dma_base);
} }
@@ -573,10 +574,12 @@ static void bgmac_dma_free(struct bgmac @@ -590,10 +591,12 @@ static void bgmac_dma_free(struct bgmac
int i; int i;
for (i = 0; i < BGMAC_MAX_TX_RINGS; i++) for (i = 0; i < BGMAC_MAX_TX_RINGS; i++)
@ -80,7 +80,7 @@ Signed-off-by: Felix Fietkau <nbd@openwrt.org>
} }
static int bgmac_dma_alloc(struct bgmac *bgmac) static int bgmac_dma_alloc(struct bgmac *bgmac)
@@ -599,11 +602,10 @@ static int bgmac_dma_alloc(struct bgmac @@ -616,11 +619,10 @@ static int bgmac_dma_alloc(struct bgmac
for (i = 0; i < BGMAC_MAX_TX_RINGS; i++) { for (i = 0; i < BGMAC_MAX_TX_RINGS; i++) {
ring = &bgmac->tx_ring[i]; ring = &bgmac->tx_ring[i];
@ -93,7 +93,7 @@ Signed-off-by: Felix Fietkau <nbd@openwrt.org>
ring->cpu_base = dma_zalloc_coherent(dma_dev, size, ring->cpu_base = dma_zalloc_coherent(dma_dev, size,
&ring->dma_base, &ring->dma_base,
GFP_KERNEL); GFP_KERNEL);
@@ -625,11 +627,10 @@ static int bgmac_dma_alloc(struct bgmac @@ -642,11 +644,10 @@ static int bgmac_dma_alloc(struct bgmac
for (i = 0; i < BGMAC_MAX_RX_RINGS; i++) { for (i = 0; i < BGMAC_MAX_RX_RINGS; i++) {
ring = &bgmac->rx_ring[i]; ring = &bgmac->rx_ring[i];
@ -106,7 +106,7 @@ Signed-off-by: Felix Fietkau <nbd@openwrt.org>
ring->cpu_base = dma_zalloc_coherent(dma_dev, size, ring->cpu_base = dma_zalloc_coherent(dma_dev, size,
&ring->dma_base, &ring->dma_base,
GFP_KERNEL); GFP_KERNEL);
@@ -692,7 +693,7 @@ static int bgmac_dma_init(struct bgmac * @@ -709,7 +710,7 @@ static int bgmac_dma_init(struct bgmac *
ring->start = 0; ring->start = 0;
ring->end = 0; ring->end = 0;
@ -114,7 +114,7 @@ Signed-off-by: Felix Fietkau <nbd@openwrt.org>
+ for (j = 0; j < BGMAC_RX_RING_SLOTS; j++) { + for (j = 0; j < BGMAC_RX_RING_SLOTS; j++) {
err = bgmac_dma_rx_skb_for_slot(bgmac, &ring->slots[j]); err = bgmac_dma_rx_skb_for_slot(bgmac, &ring->slots[j]);
if (err) if (err)
return err; goto error;
--- a/drivers/net/ethernet/broadcom/bgmac.h --- a/drivers/net/ethernet/broadcom/bgmac.h
+++ b/drivers/net/ethernet/broadcom/bgmac.h +++ b/drivers/net/ethernet/broadcom/bgmac.h
@@ -419,11 +419,10 @@ struct bgmac_dma_ring { @@ -419,11 +419,10 @@ struct bgmac_dma_ring {

View File

@ -12,7 +12,7 @@ Signed-off-by: Felix Fietkau <nbd@openwrt.org>
--- a/drivers/net/ethernet/broadcom/bgmac.c --- a/drivers/net/ethernet/broadcom/bgmac.c
+++ b/drivers/net/ethernet/broadcom/bgmac.c +++ b/drivers/net/ethernet/broadcom/bgmac.c
@@ -1605,8 +1605,11 @@ static int bgmac_probe(struct bcma_devic @@ -1623,8 +1623,11 @@ static int bgmac_probe(struct bcma_devic
ns_core = bcma_find_core_unit(core->bus, ns_core = bcma_find_core_unit(core->bus,
BCMA_CORE_MAC_GBIT, BCMA_CORE_MAC_GBIT,
ns_gmac); ns_gmac);

View File

@ -12,7 +12,7 @@ Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
#include <bcm47xx_nvram.h> #include <bcm47xx_nvram.h>
static const struct bcma_device_id bgmac_bcma_tbl[] = { static const struct bcma_device_id bgmac_bcma_tbl[] = {
@@ -1520,6 +1521,17 @@ static void bgmac_mii_unregister(struct @@ -1538,6 +1539,17 @@ static void bgmac_mii_unregister(struct
mdiobus_free(mii_bus); mdiobus_free(mii_bus);
} }
@ -30,7 +30,7 @@ Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
/************************************************** /**************************************************
* BCMA bus ops * BCMA bus ops
**************************************************/ **************************************************/
@@ -1646,6 +1658,16 @@ static int bgmac_probe(struct bcma_devic @@ -1664,6 +1676,16 @@ static int bgmac_probe(struct bcma_devic
net_dev->hw_features = net_dev->features; net_dev->hw_features = net_dev->features;
net_dev->vlan_features = net_dev->features; net_dev->vlan_features = net_dev->features;
@ -47,7 +47,7 @@ Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
err = register_netdev(bgmac->net_dev); err = register_netdev(bgmac->net_dev);
if (err) { if (err) {
bgmac_err(bgmac, "Cannot register net device\n"); bgmac_err(bgmac, "Cannot register net device\n");
@@ -1672,6 +1694,10 @@ static void bgmac_remove(struct bcma_dev @@ -1690,6 +1712,10 @@ static void bgmac_remove(struct bcma_dev
{ {
struct bgmac *bgmac = bcma_get_drvdata(core); struct bgmac *bgmac = bcma_get_drvdata(core);