[LEDE-DEV] [PATCH 7/7] ag71xx: support for descriptors in SRAM

2017-12-07 Thread Rosen Penev
A good performance improvement. As I have not tested this, I'm keeping the 
Qualcomm default to no.
Original commit below:

From: Ben Menchaca 
Date: Fri, 7 Jun 2013 15:25:00 -0500
Subject: [ag71xx] support for descriptors in SRAM

Adds support to the ag71xx to use SRAM for descriptors for a limited
number of ag71xx instances.  This is a significant performance
improvement over using non-cacheable RAM (~4% overall bridging
performance).

Signed-off-by: Ben Menchaca 
Signed-off-by: Rosen Penev 
---
 target/linux/ar71xx/config-4.4 |  1 +
 target/linux/ar71xx/config-4.9 |  1 +
 .../drivers/net/ethernet/atheros/ag71xx/Kconfig|  8 +++
 .../drivers/net/ethernet/atheros/ag71xx/ag71xx.h   |  1 +
 .../net/ethernet/atheros/ag71xx/ag71xx_main.c  | 57 +++---
 5 files changed, 60 insertions(+), 8 deletions(-)

diff --git a/target/linux/ar71xx/config-4.4 b/target/linux/ar71xx/config-4.4
index 3ba3853..3bfcd17 100644
--- a/target/linux/ar71xx/config-4.4
+++ b/target/linux/ar71xx/config-4.4
@@ -2,6 +2,7 @@ CONFIG_AG71XX=y
 CONFIG_AG71XX_AR8216_SUPPORT=y
 # CONFIG_AG71XX_DEBUG is not set
 # CONFIG_AG71XX_DEBUG_FS is not set
+# CONFIG_AG71XX_SRAM_DESCRIPTORS is not set
 CONFIG_AR8216_PHY=y
 CONFIG_AR8216_PHY_LEDS=y
 CONFIG_ARCH_BINFMT_ELF_STATE=y
diff --git a/target/linux/ar71xx/config-4.9 b/target/linux/ar71xx/config-4.9
index 1d47246..7ef78b3 100644
--- a/target/linux/ar71xx/config-4.9
+++ b/target/linux/ar71xx/config-4.9
@@ -2,6 +2,7 @@ CONFIG_AG71XX=y
 CONFIG_AG71XX_AR8216_SUPPORT=y
 # CONFIG_AG71XX_DEBUG is not set
 # CONFIG_AG71XX_DEBUG_FS is not set
+# CONFIG_AG71XX_SRAM_DESCRIPTORS is not set
 CONFIG_AR8216_PHY=y
 CONFIG_AR8216_PHY_LEDS=y
 CONFIG_ARCH_BINFMT_ELF_STATE=y
diff --git 
a/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/Kconfig 
b/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/Kconfig
index 42d544f..b859b2b 100644
--- a/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/Kconfig
+++ b/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/Kconfig
@@ -8,6 +8,14 @@ config AG71XX
 
 if AG71XX
 
+config AG71XX_SRAM_DESCRIPTORS
+bool "Atheros AR71xx built-in ethernet driver SRAM descriptor rings"
+default n
+help
+  Atheros AR71xx built-in ethernet driver normally uses non-cached RAM
+  for descriptor rings.  If set to 'y', this option puts those rings in
+  SRAM, improving performance.
+
 config AG71XX_DEBUG
bool "Atheros AR71xx built-in ethernet driver debugging"
default n
diff --git 
a/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx.h 
b/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx.h
index f85e43d..1b2026b 100644
--- a/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx.h
+++ b/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx.h
@@ -115,6 +115,7 @@ struct ag71xx_ring {
dma_addr_t  descs_dma;
u16 desc_split;
u16 order;
+   void __iomem*iomem;
 };
 
 struct ag71xx_mdio {
diff --git 
a/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c 
b/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c
index 8ce777c..74bf524 100644
--- 
a/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c
+++ 
b/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c
@@ -13,6 +13,10 @@
 
 #include "ag71xx.h"
 
+#ifndef UNUSED
+#define UNUSED(__x)(void)(__x)
+#endif
+
 static int ag71xx_gmac_num = 0;
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(4,2,0)
@@ -39,6 +43,17 @@ MODULE_PARM_DESC(msg_level, "Message level 
(-1=defaults,0=none,...,16=all)");
 
 #define ETH_SWITCH_HEADER_LEN  2
 
+#ifdef CONFIG_AG71XX_SRAM_DESCRIPTORS
+#define MAX_AG71XX_USING_SRAM  2
+#define MAX_AG71XX_SRAM_RINGS  (MAX_AG71XX_USING_SRAM) * 2
+static unsigned long ag71xx_ring_bufs[MAX_AG71XX_SRAM_RINGS] = {
+   0x1d00UL,
+   0x1d001000UL,
+   0x1d002000UL,
+   0x1d003000UL
+};
+#endif /* CONFIG_AG71XX_SRAM_DESCRIPTORS */
+
 static int ag71xx_tx_packets(struct ag71xx *ag, bool flush);
 
 static inline unsigned int ag71xx_max_frame_len(unsigned int mtu)
@@ -103,12 +118,17 @@ static void ag71xx_ring_free(struct ag71xx_ring *ring)
 {
kfree(ring->buf);
 
-   if (ring->descs_cpu)
-   dma_free_coherent(NULL, ring->size * ring->desc_size,
- ring->descs_cpu, ring->descs_dma);
+   if (ring->descs_cpu) {
+   if (ring->iomem) {
+   iounmap(ring->iomem);
+   } else {
+   dma_free_coherent(NULL, ring->size * ring->desc_size,
+ ring->descs_cpu, ring->descs_dma);
+  

[LEDE-DEV] [PATCH 3/7] ag71xx: optimized iomapped register access

2017-12-07 Thread Rosen Penev
Seems to remove a few instructions. Original message below:

From: Ben Menchaca 
Date: Tue, 11 Jun 2013 15:50:17 -0500
Subject: [ag71xx] optimize iomapped register access

Add register accessors that remove the per-register range check that
was done previously.  Additionally, we separate the write from the
subsequent read that is designed to flush the write; this can now be
called separately.

Signed-off-by: Ben Menchaca 
Signed-off-by: Rosen Penev 
---
 .../drivers/net/ethernet/atheros/ag71xx/ag71xx.h   | 23 +++
 .../net/ethernet/atheros/ag71xx/ag71xx_main.c  | 26 +++---
 2 files changed, 41 insertions(+), 8 deletions(-)

diff --git 
a/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx.h 
b/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx.h
index c39beaf..39237aa 100644
--- a/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx.h
+++ b/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx.h
@@ -163,6 +163,12 @@ struct ag71xx {
struct ag71xx_ring  rx_ring cacheline_aligned;
struct ag71xx_ring  tx_ring cacheline_aligned;
 
+   void __iomem*rx_ctrl_reg;
+   void __iomem*rx_status_reg;
+   void __iomem*tx_ctrl_reg;
+   void __iomem*tx_status_reg;
+   void __iomem*int_status_reg;
+
unsigned intmax_frame_len;
unsigned intdesc_pktlen_mask;
unsigned intrx_buf_size;
@@ -400,6 +406,17 @@ static inline void ag71xx_check_reg_offset(struct ag71xx 
*ag, unsigned reg)
}
 }
 
+static inline void ag71xx_wr_fast(void  __iomem *r, u32 value)
+{
+   __raw_writel(value, r);
+}
+
+static inline void ag71xx_wr_flush(void  __iomem *r)
+{
+   (void)__raw_readl(r);
+}
+
+
 static inline void ag71xx_wr(struct ag71xx *ag, unsigned reg, u32 value)
 {
ag71xx_check_reg_offset(ag, reg);
@@ -409,6 +426,12 @@ static inline void ag71xx_wr(struct ag71xx *ag, unsigned 
reg, u32 value)
(void) __raw_readl(ag->mac_base + reg);
 }
 
+static inline u32 ag71xx_rr_fast(void  __iomem *r)
+{
+   return __raw_readl(r);
+}
+
+
 static inline u32 ag71xx_rr(struct ag71xx *ag, unsigned reg)
 {
ag71xx_check_reg_offset(ag, reg);
diff --git 
a/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c 
b/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c
index 7760952..ffbe646 100644
--- 
a/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c
+++ 
b/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c
@@ -842,8 +842,8 @@ static netdev_tx_t ag71xx_hard_start_xmit(struct sk_buff 
*skb,
DBG("%s: packet injected into TX queue\n", ag->dev->name);
 
/* enable TX engine */
-   ag71xx_wr(ag, AG71XX_REG_TX_CTRL, TX_CTRL_TXE);
-
+   ag71xx_wr_fast(ag->tx_ctrl_reg, TX_CTRL_TXE);
+   ag71xx_wr_flush(ag->tx_ctrl_reg);
return NETDEV_TX_OK;
 
 err_drop_unmap:
@@ -994,7 +994,7 @@ static int ag71xx_tx_packets(struct ag71xx *ag, bool flush)
ring->dirty += n;
 
while (n > 0) {
-   ag71xx_wr(ag, AG71XX_REG_TX_STATUS, TX_STATUS_PS);
+   ag71xx_wr_fast(ag->tx_status_reg, TX_STATUS_PS);
n--;
}
}
@@ -1048,7 +1048,7 @@ static int ag71xx_rx_packets(struct ag71xx *ag, int limit)
break;
}
 
-   ag71xx_wr(ag, AG71XX_REG_RX_STATUS, RX_STATUS_PR);
+   ag71xx_wr_fast(ag->rx_status_reg, RX_STATUS_PR);
 
pktlen = desc->ctrl & pktlen_mask;
pktlen -= ETH_FCS_LEN;
@@ -1087,6 +1087,8 @@ next:
ring->curr++;
}
 
+   ag71xx_wr_flush(ag->rx_status_reg);
+
ag71xx_ring_rx_refill(ag);
 
while ((skb = __skb_dequeue()) != NULL) {
@@ -1123,13 +1125,15 @@ static int ag71xx_poll(struct napi_struct *napi, int 
limit)
if (rx_ring->buf[rx_ring->dirty % rx_ring_size].rx_buf == NULL)
goto oom;
 
-   status = ag71xx_rr(ag, AG71XX_REG_RX_STATUS);
+   status = ag71xx_rr_fast(ag->rx_status_reg);
if (unlikely(status & RX_STATUS_OF)) {
-   ag71xx_wr(ag, AG71XX_REG_RX_STATUS, RX_STATUS_OF);
+   ag71xx_wr_fast(ag->rx_status_reg, RX_STATUS_OF);
+   ag71xx_wr_flush(ag->rx_status_reg);
dev->stats.rx_fifo_errors++;
 
/* restart RX */
-   ag71xx_wr(ag, AG71XX_REG_RX_CTRL, RX_CTRL_RXE);
+   ag71xx_wr_fast(ag->rx_ctrl_reg, RX_CTRL_RXE);
+   ag71xx_wr_flush(ag->rx_ctrl_reg);
}
 
if (rx_done < limit) {
@@ -1172,7 +1176,7 @@ static irqreturn_t ag71xx_interrupt(int irq, void *dev_id)
struct 

[LEDE-DEV] [PATCH 6/7] ag71xx: Put ring_size in ag71xx_ring struct.

2017-12-07 Thread Rosen Penev
Less verbose code. Should help when porting some of the other patches.

Signed-off-by: Rosen Penev 
---
 .../drivers/net/ethernet/atheros/ag71xx/ag71xx.h   |  1 +
 .../net/ethernet/atheros/ag71xx/ag71xx_main.c  | 40 +-
 2 files changed, 17 insertions(+), 24 deletions(-)

diff --git 
a/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx.h 
b/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx.h
index 9964993..f85e43d 100644
--- a/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx.h
+++ b/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx.h
@@ -106,6 +106,7 @@ struct ag71xx_ring {
/* "Hot" fields in the data path. */
unsigned intcurr;
unsigned intdirty;
+   u16 size;
 
/* "Cold" fields - not used in the data path. */
struct ag71xx_buf   *buf;
diff --git 
a/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c 
b/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c
index c1d754f..8ce777c 100644
--- 
a/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c
+++ 
b/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c
@@ -101,18 +101,15 @@ static inline void ag71xx_dump_intr(struct ag71xx *ag, 
char *label, u32 intr)
 
 static void ag71xx_ring_free(struct ag71xx_ring *ring)
 {
-   int ring_size = BIT(ring->order);
kfree(ring->buf);
 
if (ring->descs_cpu)
-   dma_free_coherent(NULL, ring_size * ring->desc_size,
+   dma_free_coherent(NULL, ring->size * ring->desc_size,
  ring->descs_cpu, ring->descs_dma);
 }
 
 static int ag71xx_ring_alloc(struct ag71xx_ring *ring)
 {
-   int ring_size = BIT(ring->order);
-
ring->desc_size = sizeof(struct ag71xx_desc);
if (ring->desc_size % cache_line_size()) {
DBG("ag71xx: ring %p, desc size %u rounded to %u\n",
@@ -121,12 +118,12 @@ static int ag71xx_ring_alloc(struct ag71xx_ring *ring)
ring->desc_size = roundup(ring->desc_size, cache_line_size());
}
 
-   ring->descs_cpu = dma_alloc_coherent(NULL, ring_size * ring->desc_size,
+   ring->descs_cpu = dma_alloc_coherent(NULL, ring->size * ring->desc_size,
 >descs_dma, GFP_ATOMIC);
if (!ring->descs_cpu)
return -ENOMEM;
 
-   ring->buf = kzalloc(ring_size * sizeof(*ring->buf), GFP_KERNEL);
+   ring->buf = kzalloc(ring->size * sizeof(*ring->buf), GFP_KERNEL);
if (!ring->buf)
return -ENOMEM;
 
@@ -168,15 +165,14 @@ static void ag71xx_ring_tx_clean(struct ag71xx *ag)
 static void ag71xx_ring_tx_init(struct ag71xx *ag)
 {
struct ag71xx_ring *ring = >tx_ring;
-   int ring_size = BIT(ring->order);
-   int ring_mask = ring_size - 1;
-   int i;
+   int i, next;
 
-   for (i = 0; i < ring_size; i++) {
+   for (i = 0; i < ring->size; i++) {
struct ag71xx_desc *desc = ag71xx_ring_desc(ring, i);
 
+   next = (i >= ring->size - 1) ? 0 : (i + 1);
desc->next = (u32) (ring->descs_dma +
-   ring->desc_size * ((i + 1) & ring_mask));
+   ring->desc_size * next);
 
desc->ctrl = DESC_EMPTY;
ring->buf[i].skb = NULL;
@@ -193,13 +189,12 @@ static void ag71xx_ring_tx_init(struct ag71xx *ag)
 static void ag71xx_ring_rx_clean(struct ag71xx *ag)
 {
struct ag71xx_ring *ring = >rx_ring;
-   int ring_size = BIT(ring->order);
int i;
 
if (!ring->buf)
return;
 
-   for (i = 0; i < ring_size; i++)
+   for (i = 0; i < ring->size; i++)
if (ring->buf[i].rx_buf) {
dma_unmap_single(>dev->dev, ring->buf[i].dma_addr,
 ag->rx_buf_size, DMA_FROM_DEVICE);
@@ -251,24 +246,24 @@ static bool ag71xx_fill_rx_buf(struct ag71xx *ag, struct 
ag71xx_buf *buf,
 static int ag71xx_ring_rx_init(struct ag71xx *ag)
 {
struct ag71xx_ring *ring = >rx_ring;
-   int ring_size = BIT(ring->order);
int ring_mask = BIT(ring->order) - 1;
-   unsigned int i;
+   unsigned int i, next;
int ret;
int offset = ag71xx_buffer_offset(ag);
 
ret = 0;
-   for (i = 0; i < ring_size; i++) {
+   for (i = 0; i < ring->size; i++) {
struct ag71xx_desc *desc = ag71xx_ring_desc(ring, i);
 
+   next = (i >= ring->size - 1) ? 0 : (i + 1);
desc->next = (u32) (ring->descs_dma +
-   ring->desc_size * ((i + 1) & ring_mask));
+   ring->desc_size * next);
 
DBG("ag71xx: RX desc at %p, next is %08x\n",
desc, desc->next);
}
 
-   for 

[LEDE-DEV] [PATCH 4/7] ag71xx: Remove unnecessary goto statement.

2017-12-07 Thread Rosen Penev
Tightens up the ag71xx_ring_alloc function and makes it easier to read.

Signed-off-by: Rosen Penev 
---
 .../drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c   | 17 -
 1 file changed, 4 insertions(+), 13 deletions(-)

diff --git 
a/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c 
b/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c
index ffbe646..7518352 100644
--- 
a/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c
+++ 
b/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c
@@ -112,26 +112,17 @@ static void ag71xx_ring_free(struct ag71xx_ring *ring)
 static int ag71xx_ring_alloc(struct ag71xx_ring *ring)
 {
int ring_size = BIT(ring->order);
-   int err;
 
ring->descs_cpu = dma_alloc_coherent(NULL, ring_size * AG71XX_DESC_SIZE,
 >descs_dma, GFP_ATOMIC);
-   if (!ring->descs_cpu) {
-   err = -ENOMEM;
-   goto err;
-   }
-
+   if (!ring->descs_cpu)
+   return -ENOMEM;
 
ring->buf = kzalloc(ring_size * sizeof(*ring->buf), GFP_KERNEL);
-   if (!ring->buf) {
-   err = -ENOMEM;
-   goto err;
-   }
+   if (!ring->buf)
+   return -ENOMEM;
 
return 0;
-
-err:
-   return err;
 }
 
 static void ag71xx_ring_tx_clean(struct ag71xx *ag)
-- 
2.7.4


___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


[LEDE-DEV] [PATCH 2/7] ag71xx: add method to count ag71xx probes

2017-12-07 Thread Rosen Penev
This patch is preparation for ag71xx usage of external, on-die
resources.  Since these resources are limited, we need to track how
many instances we have probed.

Signed-off-by: Ben Menchaca 
Signed-off-by: Rosen Penev dev = dev;
ag->msg_enable = netif_msg_init(ag71xx_msg_level,
AG71XX_DEFAULT_MSG_ENABLE);
+   ag->gmac_num = ag71xx_gmac_num++;
spin_lock_init(>lock);
 
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mac_base");
-- 
2.7.4


___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


[LEDE-DEV] [PATCH 5/7] ag71xx: Replace AG71XX_DESC_SIZE macro with a struct member.

2017-12-07 Thread Rosen Penev
Moves the code more in line with QCA code. Also reduces variable to a u16 
instead of s32.

QCA code has the roundup component behind a Makefile config. Not sure if 
enabled by default so I opted to keep current behavior.

Signed-off-by: Rosen Penev 
---
 .../files/drivers/net/ethernet/atheros/ag71xx/ag71xx.h   |  6 ++
 .../drivers/net/ethernet/atheros/ag71xx/ag71xx_debugfs.c |  2 +-
 .../drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c| 16 
 3 files changed, 15 insertions(+), 9 deletions(-)

diff --git 
a/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx.h 
b/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx.h
index 39237aa..9964993 100644
--- a/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx.h
+++ b/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx.h
@@ -90,9 +90,6 @@ struct ag71xx_desc {
u32 pad;
 } __attribute__((aligned(4)));
 
-#define AG71XX_DESC_SIZE   roundup(sizeof(struct ag71xx_desc), \
-   L1_CACHE_BYTES)
-
 struct ag71xx_buf {
union {
struct sk_buff  *skb;
@@ -112,6 +109,7 @@ struct ag71xx_ring {
 
/* "Cold" fields - not used in the data path. */
struct ag71xx_buf   *buf;
+   u16 desc_size;
u8  *descs_cpu;
dma_addr_t  descs_dma;
u16 desc_split;
@@ -230,7 +228,7 @@ static inline int ag71xx_desc_empty(struct ag71xx_desc 
*desc)
 static inline struct ag71xx_desc *
 ag71xx_ring_desc(struct ag71xx_ring *ring, int idx)
 {
-   return (struct ag71xx_desc *) >descs_cpu[idx * AG71XX_DESC_SIZE];
+   return (struct ag71xx_desc *) >descs_cpu[idx * ring->desc_size];
 }
 
 static inline int
diff --git 
a/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_debugfs.c
 
b/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_debugfs.c
index c86803c..143689b 100644
--- 
a/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_debugfs.c
+++ 
b/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_debugfs.c
@@ -186,7 +186,7 @@ static ssize_t read_file_ring(struct file *file, char 
__user *user_buf,
for (i = 0; i < ring_size; i++) {
struct ag71xx_buf *ab = >buf[i];
struct ag71xx_desc *desc = ag71xx_ring_desc(ring, i);
-   u32 desc_dma = ((u32) ring->descs_dma) + i * AG71XX_DESC_SIZE;
+   u32 desc_dma = ((u32) ring->descs_dma) + i * ring->desc_size;
 
len += snprintf(buf + len, buflen - len,
"%3d %c%c%c %08x %08x %08x %08x %c %10lu\n",
diff --git 
a/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c 
b/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c
index 7518352..c1d754f 100644
--- 
a/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c
+++ 
b/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c
@@ -105,7 +105,7 @@ static void ag71xx_ring_free(struct ag71xx_ring *ring)
kfree(ring->buf);
 
if (ring->descs_cpu)
-   dma_free_coherent(NULL, ring_size * AG71XX_DESC_SIZE,
+   dma_free_coherent(NULL, ring_size * ring->desc_size,
  ring->descs_cpu, ring->descs_dma);
 }
 
@@ -113,7 +113,15 @@ static int ag71xx_ring_alloc(struct ag71xx_ring *ring)
 {
int ring_size = BIT(ring->order);
 
-   ring->descs_cpu = dma_alloc_coherent(NULL, ring_size * AG71XX_DESC_SIZE,
+   ring->desc_size = sizeof(struct ag71xx_desc);
+   if (ring->desc_size % cache_line_size()) {
+   DBG("ag71xx: ring %p, desc size %u rounded to %u\n",
+   ring, ring->desc_size,
+   roundup(ring->desc_size, cache_line_size()));
+   ring->desc_size = roundup(ring->desc_size, cache_line_size());
+   }
+
+   ring->descs_cpu = dma_alloc_coherent(NULL, ring_size * ring->desc_size,
 >descs_dma, GFP_ATOMIC);
if (!ring->descs_cpu)
return -ENOMEM;
@@ -168,7 +176,7 @@ static void ag71xx_ring_tx_init(struct ag71xx *ag)
struct ag71xx_desc *desc = ag71xx_ring_desc(ring, i);
 
desc->next = (u32) (ring->descs_dma +
-   AG71XX_DESC_SIZE * ((i + 1) & ring_mask));
+   ring->desc_size * ((i + 1) & ring_mask));
 
desc->ctrl = DESC_EMPTY;
ring->buf[i].skb = NULL;
@@ -254,7 +262,7 @@ static int ag71xx_ring_rx_init(struct ag71xx *ag)
struct ag71xx_desc *desc = ag71xx_ring_desc(ring, i);
 
desc->next = (u32) (ring->descs_dma +
-   AG71XX_DESC_SIZE * ((i + 1) & ring_mask));
+   ring->desc_size * ((i + 1) & ring_mask));

[LEDE-DEV] [PATCH 1/7] ag71xx: Reorder some more structs based on warmth.

2017-12-07 Thread Rosen Penev
Should help slightly.

Signed-off-by: Rosen Penev 
---
 .../ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx.h  | 10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git 
a/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx.h 
b/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx.h
index 5ead6b3..f9ef17d 100644
--- a/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx.h
+++ b/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx.h
@@ -106,13 +106,16 @@ struct ag71xx_buf {
 };
 
 struct ag71xx_ring {
+   /* "Hot" fields in the data path. */
+   unsigned intcurr;
+   unsigned intdirty;
+
+   /* "Cold" fields - not used in the data path. */
struct ag71xx_buf   *buf;
u8  *descs_cpu;
dma_addr_t  descs_dma;
u16 desc_split;
u16 order;
-   unsigned intcurr;
-   unsigned intdirty;
 };
 
 struct ag71xx_mdio {
@@ -166,14 +169,15 @@ struct ag71xx {
 
struct net_device   *dev;
struct platform_device  *pdev;
+   /* Serialises access to regs */
spinlock_t  lock;
struct napi_struct  napi;
-   u32 msg_enable;
 
/*
 * From this point onwards we're not looking at per-packet fields.
 */
void __iomem*mac_base;
+   u32 msg_enable;
 
struct ag71xx_desc  *stop_desc;
dma_addr_t  stop_desc_dma;
-- 
2.7.4


___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


Re: [LEDE-DEV] [PATCH 2/2] download.mk: introduce a new variable SKIPHASH

2017-12-07 Thread Ted Hess

Ack from me for PKG_HASH=none. Much easier to use.

/ted

-Original Message- 
From: Jo-Philipp Wich 
Sent: Thursday, December 07, 2017 9:56 AM 
To: lede-dev@lists.infradead.org 
Subject: Re: [LEDE-DEV] [PATCH 2/2] download.mk: introduce a new variable SKIPHASH 


Hi Baptiste,

we've been discussing this patch again on IRC today and I came up with
an alternate suggestion that does not require a new variable.

-- 8< --
diff --git a/scripts/download.pl b/scripts/download.pl
index 775408934a..ad9c480c67 100755
--- a/scripts/download.pl
+++ b/scripts/download.pl
@@ -88,7 +88,7 @@ sub download_cmd($) {
}

my $hash_cmd = hash_cmd();
-$hash_cmd or die "Cannot find appropriate hash command, ensure the
provided hash is either a MD5 or SHA256 checksum.\n";
+$hash_cmd or ($file_hash eq "none") or die "Cannot find appropriate
hash command, ensure the provided hash is either a MD5 or SHA256
checksum.\n";

sub download
{
-- >8 --

Using the change above one can issue a

 "make package/mypackage/download PKG_HASH=none"

to download ignoring the Makefile checksum while preserving the error
semantics of unset PKG_HASH cases.

Ideally I'd like to push the "none" variant but wanted to share the idea
on the list first to see what others think about it.

Regards,
Jo

___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev

___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


Re: [LEDE-DEV] [PATCH 2/2] download.mk: introduce a new variable SKIPHASH

2017-12-07 Thread Stijn Tintel
On 07-12-17 15:56, Jo-Philipp Wich wrote:
> Hi Baptiste,
>
> we've been discussing this patch again on IRC today and I came up with
> an alternate suggestion that does not require a new variable.
>
> -- 8< --
> diff --git a/scripts/download.pl b/scripts/download.pl
> index 775408934a..ad9c480c67 100755
> --- a/scripts/download.pl
> +++ b/scripts/download.pl
> @@ -88,7 +88,7 @@ sub download_cmd($) {
>  }
>
>  my $hash_cmd = hash_cmd();
> -$hash_cmd or die "Cannot find appropriate hash command, ensure the
> provided hash is either a MD5 or SHA256 checksum.\n";
> +$hash_cmd or ($file_hash eq "none") or die "Cannot find appropriate
> hash command, ensure the provided hash is either a MD5 or SHA256
> checksum.\n";
>
>  sub download
>  {
> -- >8 --
>
> Using the change above one can issue a
>
>   "make package/mypackage/download PKG_HASH=none"
>
> to download ignoring the Makefile checksum while preserving the error
> semantics of unset PKG_HASH cases.
>
> Ideally I'd like to push the "none" variant but wanted to share the idea
> on the list first to see what others think about it.
>
I prefer this over using an extra variable.

Acked-by: Stijn Tintel 


___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


Re: [LEDE-DEV] [PATCH 2/2] download.mk: introduce a new variable SKIPHASH

2017-12-07 Thread Jo-Philipp Wich
Hi Baptiste,

we've been discussing this patch again on IRC today and I came up with
an alternate suggestion that does not require a new variable.

-- 8< --
diff --git a/scripts/download.pl b/scripts/download.pl
index 775408934a..ad9c480c67 100755
--- a/scripts/download.pl
+++ b/scripts/download.pl
@@ -88,7 +88,7 @@ sub download_cmd($) {
 }

 my $hash_cmd = hash_cmd();
-$hash_cmd or die "Cannot find appropriate hash command, ensure the
provided hash is either a MD5 or SHA256 checksum.\n";
+$hash_cmd or ($file_hash eq "none") or die "Cannot find appropriate
hash command, ensure the provided hash is either a MD5 or SHA256
checksum.\n";

 sub download
 {
-- >8 --

Using the change above one can issue a

  "make package/mypackage/download PKG_HASH=none"

to download ignoring the Makefile checksum while preserving the error
semantics of unset PKG_HASH cases.

Ideally I'd like to push the "none" variant but wanted to share the idea
on the list first to see what others think about it.

Regards,
Jo

___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


[LEDE-DEV] [FINAL CALL] Merging the 'OpenWrt merge' patches

2017-12-07 Thread Felix Fietkau
Hi,

Are there any remaining concerns about those 'OpenWrt merge' patches
that have been sitting in my staging tree for a while now?

If not, I plan on pushing them to master this weekend.

- Felix

___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


Re: [LEDE-DEV] [PATCH resend 3/3] hostapd: bump PKG_RELEASE

2017-12-07 Thread Timo Sigurdsson
Hi Stijn,

Stijn Tintel schrieb am 07.12.2017 12:05:

> On 07-12-17 12:04, Timo Sigurdsson wrote:
>> Hi,
>>
>> Stijn Tintel schrieb am 07.12.2017 01:35:
>>
>>> On 14-11-17 21:41, Timo Sigurdsson wrote:
 Increase PKG_RELEASE after latest changes to hostapd, so downstream
 users can fetch updates via opkg.

>>> You should have bumped PKG_RELEASE in the previous commit. I've done
>>> that in my staging tree.
>>>
>> thanks for the fixup. I'll send patches later tonight backporting these two
>> commits
>> to the 17.04 branch.
>>
> If they can be cherry-picked that is the preferred method, then there is
> no need to send patches. I can look into it tonight.
> 
even better so! Thanks.

Regards,

Timo

___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


Re: [LEDE-DEV] [PATCH resend 3/3] hostapd: bump PKG_RELEASE

2017-12-07 Thread Stijn Tintel
On 07-12-17 12:04, Timo Sigurdsson wrote:
> Hi,
>
> Stijn Tintel schrieb am 07.12.2017 01:35:
>
>> On 14-11-17 21:41, Timo Sigurdsson wrote:
>>> Increase PKG_RELEASE after latest changes to hostapd, so downstream
>>> users can fetch updates via opkg.
>>>
>> You should have bumped PKG_RELEASE in the previous commit. I've done
>> that in my staging tree.
>>
> thanks for the fixup. I'll send patches later tonight backporting these two 
> commits
> to the 17.04 branch.
>
If they can be cherry-picked that is the preferred method, then there is
no need to send patches. I can look into it tonight.

Stijn

___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


Re: [LEDE-DEV] [PATCH resend 3/3] hostapd: bump PKG_RELEASE

2017-12-07 Thread Timo Sigurdsson
Hi,

Stijn Tintel schrieb am 07.12.2017 01:35:

> On 14-11-17 21:41, Timo Sigurdsson wrote:
>> Increase PKG_RELEASE after latest changes to hostapd, so downstream
>> users can fetch updates via opkg.
>>
> You should have bumped PKG_RELEASE in the previous commit. I've done
> that in my staging tree.
> 

thanks for the fixup. I'll send patches later tonight backporting these two 
commits
to the 17.04 branch.

Regards,

Timo

___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev