From 6380450097d3e78a07ea558c9a99085654f8b98c Mon Sep 17 00:00:00 2001 From: acoul Date: Fri, 30 Oct 2015 19:26:37 +0200 Subject: [PATCH] linux/ath25: revert ar231x ethernet update --- .../patches-4.1/310-modernize_ethernet.patch | 538 ------------------ 1 file changed, 538 deletions(-) delete mode 100644 target/linux/ath25/patches-4.1/310-modernize_ethernet.patch diff --git a/target/linux/ath25/patches-4.1/310-modernize_ethernet.patch b/target/linux/ath25/patches-4.1/310-modernize_ethernet.patch deleted file mode 100644 index bdff50c597..0000000000 --- a/target/linux/ath25/patches-4.1/310-modernize_ethernet.patch +++ /dev/null @@ -1,538 +0,0 @@ ---- a/drivers/net/ethernet/atheros/ar231x/ar231x.h -+++ b/drivers/net/ethernet/atheros/ar231x/ar231x.h -@@ -19,21 +19,18 @@ - - #include - #include --#include - #include - --/* probe link timer - 5 secs */ --#define LINK_TIMER (5*HZ) -+/* probe link timer - 2 secs */ -+#define LINK_TIMER (2*HZ) - --#define IS_DMA_TX_INT(X) (((X) & (DMA_STATUS_TI)) != 0) --#define IS_DMA_RX_INT(X) (((X) & (DMA_STATUS_RI)) != 0) --#define IS_DRIVER_OWNED(X) (((X) & (DMA_TX_OWN)) == 0) -- --#define AR2313_TX_TIMEOUT (HZ/4) -+#define AR2313_QUEUES 1 -+#define AR2313_RXDSC_ENTRIES 64 -+#define CRC_LEN 4 -+#define AR2313_RX_BUFSIZE 1518 - - /* Rings */ --#define DSC_RING_ENTRIES_SIZE (AR2313_DESCR_ENTRIES * sizeof(struct desc)) --#define DSC_NEXT(idx) ((idx + 1) & (AR2313_DESCR_ENTRIES - 1)) -+#define DSC_NEXT(idx) ((idx + 1) & (AR2313_RXDSC_ENTRIES - 1)) - - #define AR2313_MBGET 2 - #define AR2313_MBSET 3 -@@ -147,12 +144,14 @@ - #define DMA_CONTROL_ST BIT(13) /* start transmit */ - #define DMA_CONTROL_SF BIT(21) /* store and forward */ - --typedef struct { -- volatile unsigned int status; /* OWN, Device control and status. */ -- volatile unsigned int devcs; /* pkt Control bits + Length */ -- volatile unsigned int addr; /* Current Address. */ -- volatile unsigned int descr; /* Next descriptor in chain. */ --} ar231x_descr_t; -+struct ar231x_descr { -+ u32 status; /* OWN, Device control and status. */ -+ u32 devcs; /* Packet control bitmap + Length. */ -+ u32 buffer_ptr; /* Pointer to packet buffer. */ -+ u32 next_dsc_ptr; /* Pointer to next descriptor in chain. */ -+ u32 addr; -+ u32 descr; -+}; - - /** - * New Combo structure for Both Eth0 AND eth1 -@@ -160,54 +159,40 @@ typedef struct { - * Don't directly access MII related regs since phy chip could be actually - * connected to another ethernet block. - */ --typedef struct { -- volatile unsigned int mac_control; /* 0x00 */ -- volatile unsigned int mac_addr[2]; /* 0x04 - 0x08 */ -- volatile unsigned int mcast_table[2]; /* 0x0c - 0x10 */ -- volatile unsigned int __mii_addr; /* 0x14 */ -- volatile unsigned int __mii_data; /* 0x18 */ -- volatile unsigned int flow_control; /* 0x1c */ -- volatile unsigned int vlan_tag; /* 0x20 */ -- volatile unsigned int pad[7]; /* 0x24 - 0x3c */ -- volatile unsigned int ucast_table[8]; /* 0x40-0x5c */ --} ETHERNET_STRUCT; -- --typedef struct { -- volatile unsigned int mii_addr; -- volatile unsigned int mii_data; --} MII; -- --/******************************************************************** -- * Interrupt controller -- ********************************************************************/ -- --typedef struct { -- volatile unsigned int wdog_control; /* 0x08 */ -- volatile unsigned int wdog_timer; /* 0x0c */ -- volatile unsigned int misc_status; /* 0x10 */ -- volatile unsigned int misc_mask; /* 0x14 */ -- volatile unsigned int global_status; /* 0x18 */ -- volatile unsigned int reserved; /* 0x1c */ -- volatile unsigned int reset_control; /* 0x20 */ --} INTERRUPT; -+struct ar231x_ethernet { -+ u32 mac_control; /* 0x00 */ -+ u32 mac_addr[2]; /* 0x04 - 0x08 */ -+ u32 mcast_table[2]; /* 0x0c - 0x10 */ -+ u32 __mii_addr; /* 0x14 */ -+ u32 __mii_data; /* 0x18 */ -+ u32 flow_control; /* 0x1c */ -+ u32 vlan_tag; /* 0x20 */ -+ u32 pad[7]; /* 0x24 - 0x3c */ -+ u32 ucast_table[8]; /* 0x40-0x5c */ -+}; -+ -+struct ar231x_mii { -+ u32 mii_addr; -+ u32 mii_data; -+}; - - /******************************************************************** - * DMA controller - ********************************************************************/ --typedef struct { -- volatile unsigned int bus_mode; /* 0x00 (CSR0) */ -- volatile unsigned int xmt_poll; /* 0x04 (CSR1) */ -- volatile unsigned int rcv_poll; /* 0x08 (CSR2) */ -- volatile unsigned int rcv_base; /* 0x0c (CSR3) */ -- volatile unsigned int xmt_base; /* 0x10 (CSR4) */ -- volatile unsigned int status; /* 0x14 (CSR5) */ -- volatile unsigned int control; /* 0x18 (CSR6) */ -- volatile unsigned int intr_ena; /* 0x1c (CSR7) */ -- volatile unsigned int rcv_missed; /* 0x20 (CSR8) */ -- volatile unsigned int reserved[11]; /* 0x24-0x4c (CSR9-19) */ -- volatile unsigned int cur_tx_buf_addr; /* 0x50 (CSR20) */ -- volatile unsigned int cur_rx_buf_addr; /* 0x50 (CSR21) */ --} DMA; -+struct ar231x_dma { -+ u32 bus_mode; /* 0x00 (CSR0) */ -+ u32 xmt_poll; /* 0x04 (CSR1) */ -+ u32 rcv_poll; /* 0x08 (CSR2) */ -+ u32 rcv_base; /* 0x0c (CSR3) */ -+ u32 xmt_base; /* 0x10 (CSR4) */ -+ u32 status; /* 0x14 (CSR5) */ -+ u32 control; /* 0x18 (CSR6) */ -+ u32 intr_ena; /* 0x1c (CSR7) */ -+ u32 rcv_missed; /* 0x20 (CSR8) */ -+ u32 reserved[11]; /* 0x24-0x4c (CSR9-19) */ -+ u32 cur_tx_buf_addr; /* 0x50 (CSR20) */ -+ u32 cur_rx_buf_addr; /* 0x50 (CSR21) */ -+}; - - /** - * Struct private for the Sibyte. -@@ -221,19 +206,18 @@ typedef struct { - */ - struct ar231x_private { - struct net_device *dev; -- int version; - u32 mb[2]; - -- volatile MII *phy_regs; -- volatile ETHERNET_STRUCT *eth_regs; -- volatile DMA *dma_regs; -+ struct ar231x_mii *phy_regs; -+ struct ar231x_ethernet *eth_regs; -+ struct ar231x_dma *dma_regs; - struct ar231x_eth *cfg; - - spinlock_t lock; /* Serialise access to device */ - - /* RX and TX descriptors, must be adjacent */ -- ar231x_descr_t *rx_ring; -- ar231x_descr_t *tx_ring; -+ struct ar231x_descr *rx_ring; -+ struct ar231x_descr *tx_ring; - - struct sk_buff **rx_skb; - struct sk_buff **tx_skb; ---- a/drivers/net/ethernet/atheros/ar231x/ar231x.c -+++ b/drivers/net/ethernet/atheros/ar231x/ar231x.c -@@ -34,86 +34,8 @@ - #include - #include - --#define AR2313_MTU 1692 --#define AR2313_PRIOS 1 --#define AR2313_QUEUES (2*AR2313_PRIOS) --#define AR2313_DESCR_ENTRIES 64 -- --#ifndef min --#define min(a, b) (((a) < (b)) ? (a) : (b)) --#endif -- --#ifndef SMP_CACHE_BYTES --#define SMP_CACHE_BYTES L1_CACHE_BYTES --#endif -- --#define AR2313_MBOX_SET_BIT 0x8 -- - #include "ar231x.h" - --/** -- * New interrupt handler strategy: -- * -- * An old interrupt handler worked using the traditional method of -- * replacing an skbuff with a new one when a packet arrives. However -- * the rx rings do not need to contain a static number of buffer -- * descriptors, thus it makes sense to move the memory allocation out -- * of the main interrupt handler and do it in a bottom half handler -- * and only allocate new buffers when the number of buffers in the -- * ring is below a certain threshold. In order to avoid starving the -- * NIC under heavy load it is however necessary to force allocation -- * when hitting a minimum threshold. The strategy for alloction is as -- * follows: -- * -- * RX_LOW_BUF_THRES - allocate buffers in the bottom half -- * RX_PANIC_LOW_THRES - we are very low on buffers, allocate -- * the buffers in the interrupt handler -- * RX_RING_THRES - maximum number of buffers in the rx ring -- * -- * One advantagous side effect of this allocation approach is that the -- * entire rx processing can be done without holding any spin lock -- * since the rx rings and registers are totally independent of the tx -- * ring and its registers. This of course includes the kmalloc's of -- * new skb's. Thus start_xmit can run in parallel with rx processing -- * and the memory allocation on SMP systems. -- * -- * Note that running the skb reallocation in a bottom half opens up -- * another can of races which needs to be handled properly. In -- * particular it can happen that the interrupt handler tries to run -- * the reallocation while the bottom half is either running on another -- * CPU or was interrupted on the same CPU. To get around this the -- * driver uses bitops to prevent the reallocation routines from being -- * reentered. -- * -- * TX handling can also be done without holding any spin lock, wheee -- * this is fun! since tx_csm is only written to by the interrupt -- * handler. -- */ -- --/** -- * Threshold values for RX buffer allocation - the low water marks for -- * when to start refilling the rings are set to 75% of the ring -- * sizes. It seems to make sense to refill the rings entirely from the -- * intrrupt handler once it gets below the panic threshold, that way -- * we don't risk that the refilling is moved to another CPU when the -- * one running the interrupt handler just got the slab code hot in its -- * cache. -- */ --#define RX_RING_SIZE AR2313_DESCR_ENTRIES --#define RX_PANIC_THRES (RX_RING_SIZE/4) --#define RX_LOW_THRES ((3*RX_RING_SIZE)/4) --#define CRC_LEN 4 --#define RX_OFFSET 2 -- --#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE) --#define VLAN_HDR 4 --#else --#define VLAN_HDR 0 --#endif -- --#define AR2313_BUFSIZE (AR2313_MTU + VLAN_HDR + ETH_HLEN + CRC_LEN + \ -- RX_OFFSET) -- - #ifdef MODULE - MODULE_LICENSE("GPL"); - MODULE_AUTHOR("Sameer Dekate , Imre Kaloz , Felix Fietkau "); -@@ -283,15 +205,13 @@ static int ar231x_probe(struct platform_ - } - - /* start link poll timer */ -- ar231x_setup_timer(dev); -- -- return 0; -+ return ar231x_setup_timer(dev); - } - - static void ar231x_multicast_list(struct net_device *dev) - { - struct ar231x_private *sp = netdev_priv(dev); -- unsigned int filter; -+ u32 filter; - - filter = sp->eth_regs->mac_control; - -@@ -379,35 +299,35 @@ static int ar231x_allocate_descriptors(s - struct ar231x_private *sp = netdev_priv(dev); - int size; - int j; -- ar231x_descr_t *space; -+ struct ar231x_descr *space; - - if (sp->rx_ring != NULL) { - printk("%s: already done.\n", __func__); - return 0; - } - -- size = sizeof(ar231x_descr_t) * (AR2313_DESCR_ENTRIES * AR2313_QUEUES); -+ size = sizeof(struct ar231x_descr) * (AR2313_RXDSC_ENTRIES * AR2313_QUEUES); - space = kmalloc(size, GFP_KERNEL); - if (space == NULL) - return 1; - - /* invalidate caches */ -- dma_cache_inv((unsigned int)space, size); -+ dma_cache_inv((u32)space, size); - - /* now convert pointer to KSEG1 */ -- space = (ar231x_descr_t *)KSEG1ADDR(space); -+ space = (struct ar231x_descr *)KSEG1ADDR(space); - - memset((void *)space, 0, size); - - sp->rx_ring = space; -- space += AR2313_DESCR_ENTRIES; -+ space += AR2313_RXDSC_ENTRIES; - - sp->tx_ring = space; -- space += AR2313_DESCR_ENTRIES; -+ space += AR2313_RXDSC_ENTRIES; - - /* Initialize the transmit Descriptors */ -- for (j = 0; j < AR2313_DESCR_ENTRIES; j++) { -- ar231x_descr_t *td = &sp->tx_ring[j]; -+ for (j = 0; j < AR2313_RXDSC_ENTRIES; j++) { -+ struct ar231x_descr *td = &sp->tx_ring[j]; - - td->status = 0; - td->devcs = DMA_TX1_CHAINED; -@@ -438,7 +358,7 @@ static void ar231x_init_cleanup(struct n - iounmap((void *)sp->phy_regs); - - if (sp->rx_skb) { -- for (j = 0; j < AR2313_DESCR_ENTRIES; j++) { -+ for (j = 0; j < AR2313_RXDSC_ENTRIES; j++) { - skb = sp->rx_skb[j]; - if (skb) { - sp->rx_skb[j] = NULL; -@@ -450,7 +370,7 @@ static void ar231x_init_cleanup(struct n - } - - if (sp->tx_skb) { -- for (j = 0; j < AR2313_DESCR_ENTRIES; j++) { -+ for (j = 0; j < AR2313_RXDSC_ENTRIES; j++) { - skb = sp->tx_skb[j]; - if (skb) { - sp->tx_skb[j] = NULL; -@@ -552,8 +472,8 @@ static void ar231x_check_link(struct net - static int ar231x_reset_reg(struct net_device *dev) - { - struct ar231x_private *sp = netdev_priv(dev); -- unsigned int ethsal, ethsah; -- unsigned int flags; -+ u32 ethsal, ethsah; -+ u32 flags; - - sp->cfg->reset_set(sp->cfg->reset_mac); - mdelay(10); -@@ -579,7 +499,9 @@ static int ar231x_reset_reg(struct net_d - (DMA_CONTROL_SR | DMA_CONTROL_ST | DMA_CONTROL_SF); - - sp->eth_regs->flow_control = (FLOW_CONTROL_FCE); -+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE) - sp->eth_regs->vlan_tag = (0x8100); -+#endif - - /* Enable Ethernet Interface */ - flags = (MAC_CONTROL_TE | /* transmit enable */ -@@ -625,7 +547,7 @@ static int ar231x_init(struct net_device - /* Get the memory for the skb rings */ - if (sp->rx_skb == NULL) { - sp->rx_skb = -- kmalloc(sizeof(struct sk_buff *) * AR2313_DESCR_ENTRIES, -+ kmalloc(sizeof(struct sk_buff *) * AR2313_RXDSC_ENTRIES, - GFP_KERNEL); - if (!(sp->rx_skb)) { - printk("%s: %s: rx_skb kmalloc failed\n", -@@ -634,11 +556,11 @@ static int ar231x_init(struct net_device - goto init_error; - } - } -- memset(sp->rx_skb, 0, sizeof(struct sk_buff *) * AR2313_DESCR_ENTRIES); -+ memset(sp->rx_skb, 0, sizeof(struct sk_buff *) * AR2313_RXDSC_ENTRIES); - - if (sp->tx_skb == NULL) { - sp->tx_skb = -- kmalloc(sizeof(struct sk_buff *) * AR2313_DESCR_ENTRIES, -+ kmalloc(sizeof(struct sk_buff *) * AR2313_RXDSC_ENTRIES, - GFP_KERNEL); - if (!(sp->tx_skb)) { - printk("%s: %s: tx_skb kmalloc failed\n", -@@ -647,7 +569,7 @@ static int ar231x_init(struct net_device - goto init_error; - } - } -- memset(sp->tx_skb, 0, sizeof(struct sk_buff *) * AR2313_DESCR_ENTRIES); -+ memset(sp->tx_skb, 0, sizeof(struct sk_buff *) * AR2313_RXDSC_ENTRIES); - - /** - * Set tx_csm before we start receiving interrupts, otherwise -@@ -667,7 +589,7 @@ static int ar231x_init(struct net_device - * We load the ring here as there seem to be no way to tell the - * firmware to wipe the ring without re-initializing it. - */ -- ar231x_load_rx_ring(dev, RX_RING_SIZE); -+ ar231x_load_rx_ring(dev, AR2313_RXDSC_ENTRIES); - - /* Init hardware */ - ar231x_reset_reg(dev); -@@ -706,12 +628,12 @@ static void ar231x_load_rx_ring(struct n - - for (i = 0; i < nr_bufs; i++) { - struct sk_buff *skb; -- ar231x_descr_t *rd; -+ struct ar231x_descr *rd; - - if (sp->rx_skb[idx]) - break; - -- skb = netdev_alloc_skb_ip_align(dev, AR2313_BUFSIZE); -+ skb = netdev_alloc_skb_ip_align(dev, AR2313_RX_BUFSIZE); - if (!skb) { - printk("\n\n\n\n %s: No memory in system\n\n\n\n", - __func__); -@@ -722,10 +644,10 @@ static void ar231x_load_rx_ring(struct n - skb->dev = dev; - sp->rx_skb[idx] = skb; - -- rd = (ar231x_descr_t *)&sp->rx_ring[idx]; -+ rd = (struct ar231x_descr *)&sp->rx_ring[idx]; - - /* initialize dma descriptor */ -- rd->devcs = ((AR2313_BUFSIZE << DMA_RX1_BSIZE_SHIFT) | -+ rd->devcs = ((AR2313_RX_BUFSIZE << DMA_RX1_BSIZE_SHIFT) | - DMA_RX1_CHAINED); - rd->addr = virt_to_phys(skb->data); - rd->descr = virt_to_phys(&sp->rx_ring[DSC_NEXT(idx)]); -@@ -744,8 +666,8 @@ static int ar231x_rx_int(struct net_devi - { - struct ar231x_private *sp = netdev_priv(dev); - struct sk_buff *skb, *skb_new; -- ar231x_descr_t *rxdesc; -- unsigned int status; -+ struct ar231x_descr *rxdesc; -+ u32 status; - u32 idx; - int pkts = 0; - int rval; -@@ -787,7 +709,7 @@ static int ar231x_rx_int(struct net_devi - } else { - /* alloc new buffer. */ - skb_new = netdev_alloc_skb_ip_align(dev, -- AR2313_BUFSIZE); -+ AR2313_RX_BUFSIZE); - if (skb_new != NULL) { - skb = sp->rx_skb[idx]; - /* set skb */ -@@ -810,7 +732,7 @@ static int ar231x_rx_int(struct net_devi - } - } - -- rxdesc->devcs = ((AR2313_BUFSIZE << DMA_RX1_BSIZE_SHIFT) | -+ rxdesc->devcs = ((AR2313_RX_BUFSIZE << DMA_RX1_BSIZE_SHIFT) | - DMA_RX1_CHAINED); - rxdesc->status = DMA_RX_OWN; - -@@ -827,8 +749,8 @@ static void ar231x_tx_int(struct net_dev - struct ar231x_private *sp = netdev_priv(dev); - u32 idx; - struct sk_buff *skb; -- ar231x_descr_t *txdesc; -- unsigned int status = 0; -+ struct ar231x_descr *txdesc; -+ u32 status = 0; - - idx = sp->tx_csm; - -@@ -905,7 +827,7 @@ static irqreturn_t ar231x_interrupt(int - { - struct net_device *dev = (struct net_device *)dev_id; - struct ar231x_private *sp = netdev_priv(dev); -- unsigned int status, enabled; -+ u32 status, enabled; - - /* clear interrupt */ - /* Don't clear RI bit if currently disabled */ -@@ -939,7 +861,7 @@ static irqreturn_t ar231x_interrupt(int - static int ar231x_open(struct net_device *dev) - { - struct ar231x_private *sp = netdev_priv(dev); -- unsigned int ethsal, ethsah; -+ u32 ethsal, ethsah; - - /* reset the hardware, in case the MAC address changed */ - ethsah = (((u_int) (dev->dev_addr[5]) << 8) & (u_int) 0x0000FF00) | -@@ -992,9 +914,9 @@ static void ar231x_halt(struct net_devic - sp->cfg->reset_set(sp->cfg->reset_phy); - - /* free buffers on tx ring */ -- for (j = 0; j < AR2313_DESCR_ENTRIES; j++) { -+ for (j = 0; j < AR2313_RXDSC_ENTRIES; j++) { - struct sk_buff *skb; -- ar231x_descr_t *txdesc; -+ struct ar231x_descr *txdesc; - - txdesc = &sp->tx_ring[j]; - txdesc->descr = 0; -@@ -1043,7 +965,7 @@ static int ar231x_close(struct net_devic - static int ar231x_start_xmit(struct sk_buff *skb, struct net_device *dev) - { - struct ar231x_private *sp = netdev_priv(dev); -- ar231x_descr_t *td; -+ struct ar231x_descr *td; - u32 idx; - - idx = sp->tx_prd; -@@ -1095,7 +1017,7 @@ static int ar231x_ioctl(struct net_devic - static void ar231x_adjust_link(struct net_device *dev) - { - struct ar231x_private *sp = netdev_priv(dev); -- unsigned int mc; -+ u32 mc; - - if (!sp->phy_dev->link) - return; -@@ -1120,7 +1042,7 @@ ar231x_mdiobus_read(struct mii_bus *bus, - { - struct net_device *const dev = bus->priv; - struct ar231x_private *sp = netdev_priv(dev); -- volatile MII *ethernet = sp->phy_regs; -+ struct ar231x_mii *ethernet = sp->phy_regs; - - ethernet->mii_addr = MII_ADDR(phy_addr, regnum); - while (ethernet->mii_addr & MII_ADDR_BUSY) -@@ -1133,7 +1055,7 @@ ar231x_mdiobus_write(struct mii_bus *bus - { - struct net_device *const dev = bus->priv; - struct ar231x_private *sp = netdev_priv(dev); -- volatile MII *ethernet = sp->phy_regs; -+ struct ar231x_mii *ethernet = sp->phy_regs; - - while (ethernet->mii_addr & MII_ADDR_BUSY) - ; -@@ -1147,9 +1069,7 @@ static int ar231x_mdiobus_reset(struct m - { - struct net_device *const dev = bus->priv; - -- ar231x_reset_reg(dev); -- -- return 0; -+ return ar231x_reset_reg(dev); - } - - static int ar231x_mdiobus_probe(struct net_device *dev) -- 2.35.1