net: Add MOXA ART SoCs ethernet driver
Subsystems (3)
PATCH 1/1 net: Add MOXA ART SoCs ethernet driver
The MOXA UC-711X hardware(s) has an ethernet controller that seem to be developed internally. The IC used is "RTL8201CP".
Since there is no public documentation, this driver is mostly the one published by MOXA that has been heavily cleaned up / ported from linux 2.6.9.
---
Notes:
Applies to next-20130716
.../devicetree/bindings/net/moxa,moxart-mac.txt | 25 + drivers/net/ethernet/Kconfig | 1 + drivers/net/ethernet/Makefile | 1 + drivers/net/ethernet/moxa/Kconfig | 30 ++ drivers/net/ethernet/moxa/Makefile | 6 + drivers/net/ethernet/moxa/moxart_ether.c | 544 +++++++++++++++++++++ drivers/net/ethernet/moxa/moxart_ether.h | 525 ++++++++++++++++++++ 7 files changed, 1132 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/moxa,moxart-mac.txt create mode 100644 drivers/net/ethernet/moxa/Kconfig create mode 100644 drivers/net/ethernet/moxa/Makefile create mode 100644 drivers/net/ethernet/moxa/moxart_ether.c create mode 100644 drivers/net/ethernet/moxa/moxart_ether.h
Documentation/devicetree/bindings/net/moxa,moxart-mac.txt new file +25 -0
@@ -0,0 +1,25 @@ +MOXA ART Ethernet Controller + +Required properties: + +- compatible : Should be "moxa,moxart-mac" +- reg : Should contain registers location and length + index 0 : main register + index 1 : mac address (stored on flash) +- interrupts : Should contain the mac interrupt number + +Example: + + mac0: mac at 90900000 { + compatible = "moxa,moxart-mac"; + reg = <0x90900000 0x100>, + <0x80000050 0x6>; + interrupts = <25 0>; + }; + + mac1: mac at 92000000 { + compatible = "moxa,moxart-mac"; + reg = <0x92000000 0x100>, + <0x80000056 0x6>; + interrupts = <27 0>; + };
drivers/net/ethernet/Kconfig +1 -0
@@ -90,6 +90,7 @@ source "drivers/net/ethernet/marvell/Kconfig" source "drivers/net/ethernet/mellanox/Kconfig" source "drivers/net/ethernet/micrel/Kconfig" source "drivers/net/ethernet/microchip/Kconfig" +source "drivers/net/ethernet/moxa/Kconfig" source "drivers/net/ethernet/myricom/Kconfig" config FEALNX
drivers/net/ethernet/Makefile +1 -0
@@ -42,6 +42,7 @@ obj-$(CONFIG_NET_VENDOR_MARVELL) += marvell/ obj-$(CONFIG_NET_VENDOR_MELLANOX) += mellanox/ obj-$(CONFIG_NET_VENDOR_MICREL) += micrel/ obj-$(CONFIG_NET_VENDOR_MICROCHIP) += microchip/ +obj-$(CONFIG_NET_VENDOR_MOXART) += moxa/ obj-$(CONFIG_NET_VENDOR_MYRI) += myricom/ obj-$(CONFIG_FEALNX) += fealnx.o obj-$(CONFIG_NET_VENDOR_NATSEMI) += natsemi/
drivers/net/ethernet/moxa/Kconfig new file +30 -0
@@ -0,0 +1,30 @@ +# +# MOXART device configuration +# + +config NET_VENDOR_MOXART + bool "MOXA ART devices" + default y + depends on (ARM && ARCH_MOXART) + ---help--- + If you have a network (Ethernet) card belonging to this class, say Y + and read the Ethernet-HOWTO, available from + <http://www.tldp.org/docs.html#howto>. + + Note that the answer to this question doesn't directly affect the + kernel: saying N will just cause the configurator to skip all + the questions about MOXA ART devices. If you say Y, you will be asked + for your specific card in the following questions. + +if NET_VENDOR_MOXART + +config ARM_MOXART_ETHER + tristate "MOXART Ethernet support" + depends on ARM && ARCH_MOXART + select NET_CORE + ---help--- + If you wish to compile a kernel for a hardware with MOXA ART SoC and + want to use the internal ethernet then you should answer Y to this. + + +endif # NET_VENDOR_MOXART
drivers/net/ethernet/moxa/Makefile new file +6 -0
@@ -0,0 +1,6 @@ +# +# Makefile for the MOXART network device drivers. +# + +obj-$(CONFIG_ARM_MOXART_ETHER) += moxart_ether.o +
drivers/net/ethernet/moxa/moxart_ether.c new file +544 -0
544 lines not on this page · raw message
drivers/net/ethernet/moxa/moxart_ether.h new file +525 -0
525 lines not on this page · raw message
Signature · 1 line
1.8.2.1
I think this driver may have a bug.
After some time running ping successfully, the message "no TX space for packet" is printed resulting in 100% packet loss.
The message is printed from .ndo_start_xmit and I think it may be because of how priv->tx_desc_now is now set up in moxart_mac_setup_desc_ring.
I will take a look at this and try to fix the issue.
Best regards,
Jonas
Hello Jonas,
A bunch of comments inline.
2013/7/18 Jonas Jensen <[email protected]>:
Quoted 32 lines
The MOXA UC-711X hardware(s) has an ethernet controller that seem to be developed internally. The IC used is "RTL8201CP".
Since there is no public documentation, this driver is mostly the one published by MOXA that has been heavily cleaned up / ported from linux 2.6.9.
Signed-off-by Jonas Jensen <[email protected]>---
Notes:
Applies to next-20130716.../devicetree/bindings/net/moxa,moxart-mac.txt | 25 + drivers/net/ethernet/Kconfig | 1 + drivers/net/ethernet/Makefile | 1 + drivers/net/ethernet/moxa/Kconfig | 30 ++ drivers/net/ethernet/moxa/Makefile | 6 + drivers/net/ethernet/moxa/moxart_ether.c | 544 +++++++++++++++++++++ drivers/net/ethernet/moxa/moxart_ether.h | 525 ++++++++++++++++++++ 7 files changed, 1132 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/moxa,moxart-mac.txt create mode 100644 drivers/net/ethernet/moxa/Kconfig create mode 100644 drivers/net/ethernet/moxa/Makefile create mode 100644 drivers/net/ethernet/moxa/moxart_ether.c create mode 100644 drivers/net/ethernet/moxa/moxart_ether.hDocumentation/devicetree/bindings/net/moxa,moxart-mac.txt new file +0
-0
Documentation/devicetree/bindings/net/moxa,moxart-mac.txt line 8
Quoted 8 lines
Documentation/devicetree/bindings/net/moxa,moxart-mac.txt new file +8
-0@@ -0,0 +1,25 @@ +MOXA ART Ethernet Controller + +Required properties: + +- compatible : Should be "moxa,moxart-mac" +- reg : Should contain registers location and length + index 0 : main register + index 1 : mac address (stored on flash)
That is kind of unusual, since the MAC register is within the range of the MAC base register, just read the MAC from the base register and use that to fill in dev->dev_addr in your ndo_open() callback.
[snip]
Quoted 22 lines
Documentation/devicetree/bindings/net/moxa,moxart-mac.txt new file +22
-0+static void moxart_mac_setup_desc_ring(struct net_device *ndev) +{ + struct moxart_mac_priv_t *priv = netdev_priv(ndev); + struct tx_desc_t *txdesc; + struct rx_desc_t *rxdesc; + unsigned char *virtbuf; + unsigned int phybuf; + int i; + + virtbuf = priv->virt_tx_buf_baseaddr; + phybuf = priv->phy_tx_buf_baseaddr; + for (i = 0; i < TX_DESC_NUM; i++, + virtbuf += TX_BUF_SIZE, phybuf += TX_BUF_SIZE) { + txdesc = &priv->virt_tx_desc_baseaddr[i]; + memset(txdesc, 0, sizeof(struct tx_desc_t)); + txdesc->txdes2.phy_tx_buf_baseaddr = phybuf; + txdesc->txdes2.virt_tx_buf_baseaddr = virtbuf; + } + priv->virt_tx_desc_baseaddr[TX_DESC_NUM - 1].txdes1.ubit.edotr = 1; + priv->tx_desc_now = 0; + + virtbuf = priv->virt_rx_buf_baseaddr;
Documentation/devicetree/bindings/net/moxa,moxart-mac.txt
Quoted 10 lines
Documentation/devicetree/bindings/net/moxa,moxart-mac.txt new file +10
-0+ phybuf = priv->phy_rx_buf_baseaddr; + for (i = 0; i < RX_DESC_NUM; i++, + virtbuf += RX_BUF_SIZE, phybuf += RX_BUF_SIZE) { + rxdesc = &priv->virt_rx_desc_baseaddr[i]; + memset(rxdesc, 0, sizeof(struct rx_desc_t)); + rxdesc->rxdes0.ubit.rx_dma_own = 1; + rxdesc->rxdes1.ubit.rx_buf_size = RX_BUF_SIZE; + rxdesc->rxdes2.phy_rx_buf_baseaddr = phybuf; + rxdesc->rxdes2.virt_rx_buf_baseaddr = virtbuf; + }
Your RX path is supposed to be preallocating SKBs, create a DMA mapping for them and then only SKB refilling would then happen when you process a SKB in your RX handler. I do not see you doing it here.
Quoted 11 lines
Documentation/devicetree/bindings/net/moxa,moxart-mac.txt new file +11
-0+ priv->virt_rx_desc_baseaddr[RX_DESC_NUM - 1].rxdes1.ubit.edorr = 1; + priv->rx_desc_now = 0; + + /* reset the MAC controler TX/RX desciptor base address */ + writel(priv->phy_tx_desc_baseaddr, priv->base + TXR_BADR_REG_OFFSET); + writel(priv->phy_rx_desc_baseaddr, priv->base + RXR_BADR_REG_OFFSET); +} + +static int moxart_mac_open(struct net_device *ndev) +{ + struct moxart_mac_priv_t *priv = netdev_priv(ndev);
Documentation/devicetree/bindings/net/moxa,moxart-mac.txt
Quoted 10 lines
Documentation/devicetree/bindings/net/moxa,moxart-mac.txt new file +10
-0+ + if (!is_valid_ether_addr(ndev->dev_addr)) + return -EADDRNOTAVAIL; + + spin_lock_irq(&priv->txlock); + moxart_mac_reset(ndev); + moxart_update_mac_address(ndev); + moxart_mac_setup_desc_ring(ndev); + moxart_mac_enable(ndev); + spin_unlock_irq(&priv->txlock);
Unless you did not properly disable interrupts at the MAC level, taking a spinlock here does not seem to be required at all since the various steps you call are done in the correct order.
Quoted 13 lines
Documentation/devicetree/bindings/net/moxa,moxart-mac.txt new file +13
-0+ netif_start_queue(ndev); + + netdev_dbg(ndev, "%s: IMR=0x%x, MACCR=0x%x\n", + __func__, readl(priv->base + IMR_REG_OFFSET), + readl(priv->base + MACCR_REG_OFFSET)); + + return 0; +} + +static int moxart_mac_stop(struct net_device *ndev) +{ + struct moxart_mac_priv_t *priv = netdev_priv(ndev); +
Documentation/devicetree/bindings/net/moxa,moxart-mac.txt
Quoted 10 lines
Documentation/devicetree/bindings/net/moxa,moxart-mac.txt new file +10
-0+ netif_stop_queue(ndev); + spin_lock_irq(&priv->txlock); + + /* disable all interrupts */ + writel(0, priv->base + IMR_REG_OFFSET); + + /* disable all functions */ + writel(0, priv->base + MACCR_REG_OFFSET); + + spin_unlock_irq(&priv->txlock);
Same here, the serialisation is not required here once you have disabled the interrupts at the MAC level. You should also free the RX buffers and the potentially remaining transmit SKBs.
Documentation/devicetree/bindings/net/moxa,moxart-mac.txt
Quoted 13 lines
Documentation/devicetree/bindings/net/moxa,moxart-mac.txt new file +13
-0+ + return 0; +} + +static void moxart_mac_recv(struct work_struct *ptr) +{ + struct net_device *ndev = (struct net_device *) ptr; + struct moxart_mac_priv_t *priv = netdev_priv((struct net_device *)ptr); + struct rx_desc_t *rxdesc; + struct sk_buff *skb; + unsigned int ui, len; + int rxnow = priv->rx_desc_now; + int loops = RX_DESC_NUM;
This screams to me: implement NAPI. You are doing all of the processing in an interrupt handler, which runs in hard IRQ context, this is bad for latency. This very specific function won't change that much once you convert it to NAPI.
Quoted 11 lines
Documentation/devicetree/bindings/net/moxa,moxart-mac.txt new file +11
-0+ +repeat_recv: + rxdesc = &priv->virt_rx_desc_baseaddr[rxnow]; + ui = rxdesc->rxdes0.ui; + + if (ui & RXDMA_OWN) + return; + + if (ui & (RX_ERR | CRC_ERR | FTL | RUNT | RX_ODD_NB)) { + netdev_err(ndev, "%s: packet error\n", __func__); + priv->stats.rx_dropped++;
Documentation/devicetree/bindings/net/moxa,moxart-mac.txt
Quoted 10 lines
Documentation/devicetree/bindings/net/moxa,moxart-mac.txt new file +10
-0+ priv->stats.rx_errors++; + goto recv_finish; + } + + len = ui & RFL_MASK; + + if (len > RX_BUF_SIZE) + len = RX_BUF_SIZE; + + skb = dev_alloc_skb(len + 2);
You should use netdev_alloc_skb_ip_align() here.
Documentation/devicetree/bindings/net/moxa,moxart-mac.txt
Quoted 7 lines
Documentation/devicetree/bindings/net/moxa,moxart-mac.txt new file +7
-0+ if (skb == NULL) { + netdev_err(ndev, "%s: dev_alloc_skb failed\n", __func__); + priv->stats.rx_dropped++; + goto recv_finish; + } + + skb_reserve(skb, 2);
And remove this.
Quoted 1 line
+
skb->dev= ndev;
eth_type_trans() already does this for you.
Quoted 1 line
+
memcpy(skb_put(skb, len), rxdesc->rxdes2.virt_rx_buf_baseaddr, len);
You should use a dma_unmap_single() operation here.
Documentation/devicetree/bindings/net/moxa,moxart-mac.txt
Quoted 2 lines
Documentation/devicetree/bindings/net/moxa,moxart-mac.txt new file +2
-0+ netif_rx(skb); + skb->protocol = eth_type_trans(skb, ndev);
I think these two steps are inverted, you should first call eth_type_trans().
Documentation/devicetree/bindings/net/moxa,moxart-mac.txt
Quoted 13 lines
Documentation/devicetree/bindings/net/moxa,moxart-mac.txt new file +13
-0+ ndev->last_rx = jiffies; + priv->stats.rx_packets++; + priv->stats.rx_bytes += len; + if (ui & MULTICAST_RXDES0) + priv->stats.multicast++; + +recv_finish: + rxdesc->rxdes0.ui = RXDMA_OWN; + rxnow++; + rxnow &= RX_DESC_NUM_MASK; + priv->rx_desc_now = rxnow; + if (loops-- > 0) + goto repeat_recv;
Better code this with a while() loop directly, using gotos here is silly and I believe this might be bad for your CPU branch predictor as well.
Documentation/devicetree/bindings/net/moxa,moxart-mac.txt
Quoted 10 lines
Documentation/devicetree/bindings/net/moxa,moxart-mac.txt new file +10
-0+} + +static irqreturn_t moxart_mac_interrupt(int irq, void *dev_id) +{ + struct net_device *ndev = (struct net_device *) dev_id; + struct moxart_mac_priv_t *priv = netdev_priv(ndev); + unsigned int ists = readl(priv->base + ISR_REG_OFFSET); + + if (ists & RPKT_FINISH) + moxart_mac_recv((void *) ndev);
Unnecessary void * casting here.
Quoted 8 lines
Documentation/devicetree/bindings/net/moxa,moxart-mac.txt new file +8
-0+ + return IRQ_HANDLED; +} + +static int moxart_mac_start_xmit(struct sk_buff *skb, struct net_device *ndev) +{ + struct moxart_mac_priv_t *priv = netdev_priv(ndev); + struct tx_desc_t *txdesc;
Documentation/devicetree/bindings/net/moxa,moxart-mac.txt
Quoted 10 lines
Documentation/devicetree/bindings/net/moxa,moxart-mac.txt new file +10
-0+ int len; + int txnow = priv->tx_desc_now; + + spin_lock_irq(&priv->txlock); + txdesc = &priv->virt_tx_desc_baseaddr[txnow]; + if (txdesc->txdes0.ubit.tx_dma_own) { + netdev_err(ndev, "%s: no TX space for packet\n", __func__); + priv->stats.tx_dropped++; + goto xmit_final; + }
You should return NETDEV_TX_BUSY here if there are no TX descriptors available.
Documentation/devicetree/bindings/net/moxa,moxart-mac.txt
Quoted 3 lines
Documentation/devicetree/bindings/net/moxa,moxart-mac.txt new file +3
-0+ + len = skb->len > TX_BUF_SIZE ? TX_BUF_SIZE : skb->len; + memcpy(txdesc->txdes2.virt_tx_buf_baseaddr, skb->data, len);
This looks wrong, you should get a TX descriptor for this SKB, and then perform a DMA mapping of skb->data for skb->len to that specific TX descriptor address and set the transmit descriptor control words as you do below.
Quoted 13 lines
Documentation/devicetree/bindings/net/moxa,moxart-mac.txt new file +13
-0+ + if (skb->len < ETH_ZLEN) { + memset(&txdesc->txdes2.virt_tx_buf_baseaddr[skb->len], + 0, ETH_ZLEN - skb->len); + len = ETH_ZLEN; + } + + txdesc->txdes1.ubit.lts = 1; + txdesc->txdes1.ubit.fts = 1; + txdesc->txdes1.ubit.tx2_fic = 0; + txdesc->txdes1.ubit.tx_ic = 0; + txdesc->txdes1.ubit.tx_buf_size = len; + txdesc->txdes0.ui = TXDMA_OWN;
Documentation/devicetree/bindings/net/moxa,moxart-mac.txt
Quoted 10 lines
Documentation/devicetree/bindings/net/moxa,moxart-mac.txt new file +10
-0+ + /* start to send packet */ + writel(0xffffffff, priv->base + TXPD_REG_OFFSET); + + txnow++; + txnow &= TX_DESC_NUM_MASK; + priv->tx_desc_now = txnow; + ndev->trans_start = jiffies; + priv->stats.tx_packets++; + priv->stats.tx_bytes += len;
Incrementing statistics must happen in the transmit completion handler. At this point there is no guarantee that the hardware really processed your packet (your DMA engine could signal an error like no carrier or anything like that).
Documentation/devicetree/bindings/net/moxa,moxart-mac.txt
Quoted 4 lines
Documentation/devicetree/bindings/net/moxa,moxart-mac.txt new file +4
-0+ +xmit_final: + spin_unlock_irq(&priv->txlock); + dev_kfree_skb_any(skb);
This looks wrong, transmit buffer reclaim should happen once transmission is complete. Your interrupt handler do not handle the XPKT_FINISH_M bit which seems to indicate transmit completion of buffers.
[snip]
Quoted 29 lines
Documentation/devicetree/bindings/net/moxa,moxart-mac.txt new file +29
-0+ +static int moxart_mac_probe(struct platform_device *pdev) +{ + struct device *p_dev = &pdev->dev; + struct device_node *node = p_dev->of_node; + struct net_device *ndev; + struct moxart_mac_priv_t *priv; + struct resource *res; + unsigned int irq; + void *tmp; + + ndev = alloc_etherdev(sizeof(struct moxart_mac_priv_t)); + if (!ndev) + return -ENOMEM; + + irq = irq_of_parse_and_map(node, 0); + + priv = netdev_priv(ndev); + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + ndev->base_addr = res->start; + priv->base = devm_ioremap_resource(p_dev, res); + if (IS_ERR(priv->base)) { + dev_err(p_dev, "%s: devm_ioremap_resource res_mac failed\n", + __func__); + goto init_fail; + } + + res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
Documentation/devicetree/bindings/net/moxa,moxart-mac.txt
Quoted 10 lines
Documentation/devicetree/bindings/net/moxa,moxart-mac.txt new file +10
-0+ + /* the flash driver (physmap_of) requests the same region + * so use ioremap instead of devm_ioremap_resource + */ + priv->flash_base = ioremap(res->start, resource_size(res)); + if (IS_ERR(priv->flash_base)) { + dev_err(p_dev, "%s: devm_ioremap_resource res_flash failed\n", + __func__); + goto init_fail; + }
As stated above from the Device Tree binding documentation, this is unnecessary, since you have a get_mac() function.
Quoted 32 lines
Documentation/devicetree/bindings/net/moxa,moxart-mac.txt new file +32
-0+ + spin_lock_init(&priv->txlock); + + tmp = dma_alloc_coherent(NULL, sizeof(struct tx_desc_t) * TX_DESC_NUM, + (dma_addr_t *) &priv->phy_tx_desc_baseaddr, + GFP_DMA | GFP_KERNEL); + priv->virt_tx_desc_baseaddr = (struct tx_desc_t *) tmp; + if (priv->virt_tx_desc_baseaddr == NULL || + (priv->phy_tx_desc_baseaddr & 0x0f)) { + netdev_err(ndev, "TX descriptor alloc failed\n"); + goto init_fail; + } + + tmp = dma_alloc_coherent(NULL, sizeof(struct rx_desc_t) * RX_DESC_NUM, + (dma_addr_t *)&priv->phy_rx_desc_baseaddr, + GFP_DMA | GFP_KERNEL); + priv->virt_rx_desc_baseaddr = (struct rx_desc_t *) tmp; + if (priv->virt_rx_desc_baseaddr == NULL || + (priv->phy_rx_desc_baseaddr & 0x0f)) { + netdev_err(ndev, "RX descriptor alloc failed\n"); + goto init_fail; + } + + tmp = dma_alloc_coherent(NULL, TX_BUF_SIZE * TX_DESC_NUM, + (dma_addr_t *)&priv->phy_tx_buf_baseaddr, + GFP_DMA | GFP_KERNEL); + priv->virt_tx_buf_baseaddr = (unsigned char *) tmp; + if (priv->virt_tx_buf_baseaddr == NULL || + (priv->phy_tx_buf_baseaddr & 0x03)) { + netdev_err(ndev, "TX buffer alloc failed\n"); + goto init_fail; + }
Documentation/devicetree/bindings/net/moxa,moxart-mac.txt
Quoted 10 lines
Documentation/devicetree/bindings/net/moxa,moxart-mac.txt new file +10
-0+ + tmp = dma_alloc_coherent(NULL, RX_BUF_SIZE * RX_DESC_NUM, + (dma_addr_t *)&priv->phy_rx_buf_baseaddr, + GFP_DMA | GFP_KERNEL); + priv->virt_rx_buf_baseaddr = (unsigned char *) tmp; + if (priv->virt_rx_buf_baseaddr == NULL || + (priv->phy_rx_buf_baseaddr & 0x03)) { + netdev_err(ndev, "RX buffer alloc failed\n"); + goto init_fail; + }
This pool of buffers looks unnecessary, as stated above, you should rather perform DMA map_single/unmap_single operations instead. --
Florian
Hi Florian,
Thanks for your help on IRC with this. I think most of the issues you pointed out should be fixed. Comments on still unresolved below:
Quoted 6 lines · Florian Fainelli
Quoted 6 lines
+++
b/Documentation/devicetree/bindings/net/moxa,moxart-mac.txtDocumentation/devicetree/bindings/net/moxa,moxart-mac.txt new file +4
-0@@ -0,0 +1,25 @@ +MOXA ART Ethernet Controller + +Required properties: +
Quoted 8 lines
Documentation/devicetree/bindings/net/moxa,moxart-mac.txt line 8
Quoted 4 lines
Documentation/devicetree/bindings/net/moxa,moxart-mac.txt new file +4
-0+- compatible : Should be "moxa,moxart-mac" +- reg : Should contain registers location and length + index 0 : main register + index 1 : mac address (stored on flash)That is kind of unusual, since the MAC register is within the range of the MAC base register, just read the MAC from the base register and use that to fill in
dev->dev_addrin yourndo_open()callback.
It is, but MAC is zeroed out in controller register after boot. That's why it has to be read from flash memory (bootloader section), and the reason it needs to map flash memory at all.
Quoted 7 lines
Quoted 7 lines
drivers/net/ethernet/moxa/moxart_ether.c new file +7
-0+ + res =platform_get_resource (pdev,IORESOURCE_MEM ,1 ); + +/* the flash driver (physmap_of) requests the same region +* so use ioremap instead of devm_ioremap_resource +*/ + priv->flash_base =ioremap (res->start,resource_size (res));
Quoted 8 lines
drivers/net/ethernet/moxa/moxart_ether.c line 429
Quoted 5 lines
drivers/net/ethernet/moxa/moxart_ether.c new file +5
-0+if (IS_ERR (priv->flash_base)) { +dev_err (p_dev,"%s: devm_ioremap_resource res_flash failed\n" , + __func__); + goto init_fail; + }As stated above from the Device Tree binding documentation, this is unnecessary, since you have a
get_mac()function.
This is what the node looks like right now:
mac0: mac at 90900000 {
compatible = "moxa,moxart-mac";
reg = <0x90900000 0x100>,
<0x80000050 0x6>;
interrupts = <25 0>;
};
Bootloader starts at 0x80000000, looks like MAC is stored in code. I currently see no way around mapping both registers.
Best regards,
Jonas
PATCH v2 1/1 net: Add MOXA ART SoCs ethernet driver
In reply to Jonas JensenThe MOXA UC-711X hardware(s) has an ethernet controller that seem to be developed internally. The IC used is "RTL8201CP".
Since there is no public documentation, this driver is mostly the one published by MOXA that has been heavily cleaned up / ported from linux 2.6.9.
---
Notes:
According to issues pointed out by Florian:
One more thing is now known about the controller:
It requires descriptors to be located in continuous memory.
.. which is why the driver allocates buffers with kmalloc, and memory is reused in RX path to build new skb:s (build_skb), before giving packet to stack.
Changes since v1:
1. use NAPI RX polling
2. preallocate SKBs / use build_skb
3. increment stats only on success
4. return NETDEV_TX_BUSY on TX ring busy
5. use dma_map_single / set descriptors (no memcpy)
6. free skb:s, unmap DMA on transfer complete
7. general code cleanup
Applies to next-20130726
.../devicetree/bindings/net/moxa,moxart-mac.txt | 25 + drivers/net/ethernet/Kconfig | 1 + drivers/net/ethernet/Makefile | 1 + drivers/net/ethernet/moxa/Kconfig | 30 ++ drivers/net/ethernet/moxa/Makefile | 7 + drivers/net/ethernet/moxa/moxart_ether.c | 586 +++++++++++++++++++++ drivers/net/ethernet/moxa/moxart_ether.h | 513 ++++++++++++++++++ 7 files changed, 1163 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/moxa,moxart-mac.txt create mode 100644 drivers/net/ethernet/moxa/Kconfig create mode 100644 drivers/net/ethernet/moxa/Makefile create mode 100644 drivers/net/ethernet/moxa/moxart_ether.c create mode 100644 drivers/net/ethernet/moxa/moxart_ether.h
Documentation/devicetree/bindings/net/moxa,moxart-mac.txt new file +25 -0
@@ -0,0 +1,25 @@ +MOXA ART Ethernet Controller + +Required properties: + +- compatible : Must be "moxa,moxart-mac" +- reg : Should contain registers location and length + index 0 : main register + index 1 : mac address (stored on flash) +- interrupts : Should contain the mac interrupt number + +Example: + + mac0: mac at 90900000 { + compatible = "moxa,moxart-mac"; + reg = <0x90900000 0x100>, + <0x80000050 0x6>; + interrupts = <25 0>; + }; + + mac1: mac at 92000000 { + compatible = "moxa,moxart-mac"; + reg = <0x92000000 0x100>, + <0x80000056 0x6>; + interrupts = <27 0>; + };
drivers/net/ethernet/Kconfig +1 -0
@@ -90,6 +90,7 @@ source "drivers/net/ethernet/marvell/Kconfig" source "drivers/net/ethernet/mellanox/Kconfig" source "drivers/net/ethernet/micrel/Kconfig" source "drivers/net/ethernet/microchip/Kconfig" +source "drivers/net/ethernet/moxa/Kconfig" source "drivers/net/ethernet/myricom/Kconfig" config FEALNX
drivers/net/ethernet/Makefile +1 -0
@@ -42,6 +42,7 @@ obj-$(CONFIG_NET_VENDOR_MARVELL) += marvell/ obj-$(CONFIG_NET_VENDOR_MELLANOX) += mellanox/ obj-$(CONFIG_NET_VENDOR_MICREL) += micrel/ obj-$(CONFIG_NET_VENDOR_MICROCHIP) += microchip/ +obj-$(CONFIG_NET_VENDOR_MOXART) += moxa/ obj-$(CONFIG_NET_VENDOR_MYRI) += myricom/ obj-$(CONFIG_FEALNX) += fealnx.o obj-$(CONFIG_NET_VENDOR_NATSEMI) += natsemi/
drivers/net/ethernet/moxa/Kconfig new file +30 -0
@@ -0,0 +1,30 @@ +# +# MOXART device configuration +# + +config NET_VENDOR_MOXART + bool "MOXA ART devices" + default y + depends on (ARM && ARCH_MOXART) + ---help--- + If you have a network (Ethernet) card belonging to this class, say Y + and read the Ethernet-HOWTO, available from + <http://www.tldp.org/docs.html#howto>. + + Note that the answer to this question doesn't directly affect the + kernel: saying N will just cause the configurator to skip all + the questions about MOXA ART devices. If you say Y, you will be asked + for your specific card in the following questions. + +if NET_VENDOR_MOXART + +config ARM_MOXART_ETHER + tristate "MOXART Ethernet support" + depends on ARM && ARCH_MOXART + select NET_CORE + ---help--- + If you wish to compile a kernel for a hardware with MOXA ART SoC and + want to use the internal ethernet then you should answer Y to this. + + +endif # NET_VENDOR_MOXART
drivers/net/ethernet/moxa/Makefile new file +7 -0
@@ -0,0 +1,7 @@ +# +# Makefile for the MOXART network device drivers. +# + +obj-$(CONFIG_ARM_MOXART_ETHER) += moxart_ether.o + +CFLAGS_moxart_ether.o := -DDEBUG
drivers/net/ethernet/moxa/moxart_ether.c new file +586 -0
586 lines not on this page · raw message
drivers/net/ethernet/moxa/moxart_ether.h new file +513 -0
513 lines not on this page · raw message
Signature · 1 line
1.8.2.1
David Miller
maintainerFrom: Jonas Jensen <[email protected]>
Date: Fri, 26 Jul 2013 14:48:10 +0200
Review
Quoted 2 lines
(quoted diff) +2
-0+ +CFLAGS_moxart_ether.o := -DDEBUG
This is not appropriate, please remove this.
PATCH v3 1/1 net: Add MOXA ART SoCs ethernet driver
In reply to Jonas JensenThe MOXA UC-711X hardware(s) has an ethernet controller that seem to be developed internally. The IC used is "RTL8201CP".
Since there is no public documentation, this driver is mostly the one published by MOXA that has been heavily cleaned up / ported from linux 2.6.9.
---
Notes:
Changes since v2:
1. Makefile: remove debug flag
Applies to next-20130731
.../devicetree/bindings/net/moxa,moxart-mac.txt | 25 + drivers/net/ethernet/Kconfig | 1 + drivers/net/ethernet/Makefile | 1 + drivers/net/ethernet/moxa/Kconfig | 30 ++ drivers/net/ethernet/moxa/Makefile | 5 + drivers/net/ethernet/moxa/moxart_ether.c | 586 +++++++++++++++++++++ drivers/net/ethernet/moxa/moxart_ether.h | 513 ++++++++++++++++++ 7 files changed, 1161 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/moxa,moxart-mac.txt create mode 100644 drivers/net/ethernet/moxa/Kconfig create mode 100644 drivers/net/ethernet/moxa/Makefile create mode 100644 drivers/net/ethernet/moxa/moxart_ether.c create mode 100644 drivers/net/ethernet/moxa/moxart_ether.h
Documentation/devicetree/bindings/net/moxa,moxart-mac.txt new file +25 -0
@@ -0,0 +1,25 @@ +MOXA ART Ethernet Controller + +Required properties: + +- compatible : Must be "moxa,moxart-mac" +- reg : Should contain registers location and length + index 0 : main register + index 1 : mac address (stored on flash) +- interrupts : Should contain the mac interrupt number + +Example: + + mac0: mac at 90900000 { + compatible = "moxa,moxart-mac"; + reg = <0x90900000 0x100>, + <0x80000050 0x6>; + interrupts = <25 0>; + }; + + mac1: mac at 92000000 { + compatible = "moxa,moxart-mac"; + reg = <0x92000000 0x100>, + <0x80000056 0x6>; + interrupts = <27 0>; + };
drivers/net/ethernet/Kconfig +1 -0
@@ -90,6 +90,7 @@ source "drivers/net/ethernet/marvell/Kconfig" source "drivers/net/ethernet/mellanox/Kconfig" source "drivers/net/ethernet/micrel/Kconfig" source "drivers/net/ethernet/microchip/Kconfig" +source "drivers/net/ethernet/moxa/Kconfig" source "drivers/net/ethernet/myricom/Kconfig" config FEALNX
drivers/net/ethernet/Makefile +1 -0
@@ -42,6 +42,7 @@ obj-$(CONFIG_NET_VENDOR_MARVELL) += marvell/ obj-$(CONFIG_NET_VENDOR_MELLANOX) += mellanox/ obj-$(CONFIG_NET_VENDOR_MICREL) += micrel/ obj-$(CONFIG_NET_VENDOR_MICROCHIP) += microchip/ +obj-$(CONFIG_NET_VENDOR_MOXART) += moxa/ obj-$(CONFIG_NET_VENDOR_MYRI) += myricom/ obj-$(CONFIG_FEALNX) += fealnx.o obj-$(CONFIG_NET_VENDOR_NATSEMI) += natsemi/
drivers/net/ethernet/moxa/Kconfig new file +30 -0
@@ -0,0 +1,30 @@ +# +# MOXART device configuration +# + +config NET_VENDOR_MOXART + bool "MOXA ART devices" + default y + depends on (ARM && ARCH_MOXART) + ---help--- + If you have a network (Ethernet) card belonging to this class, say Y + and read the Ethernet-HOWTO, available from + <http://www.tldp.org/docs.html#howto>. + + Note that the answer to this question doesn't directly affect the + kernel: saying N will just cause the configurator to skip all + the questions about MOXA ART devices. If you say Y, you will be asked + for your specific card in the following questions. + +if NET_VENDOR_MOXART + +config ARM_MOXART_ETHER + tristate "MOXART Ethernet support" + depends on ARM && ARCH_MOXART + select NET_CORE + ---help--- + If you wish to compile a kernel for a hardware with MOXA ART SoC and + want to use the internal ethernet then you should answer Y to this. + + +endif # NET_VENDOR_MOXART
drivers/net/ethernet/moxa/Makefile new file +5 -0
@@ -0,0 +1,5 @@ +# +# Makefile for the MOXART network device drivers. +# + +obj-$(CONFIG_ARM_MOXART_ETHER) += moxart_ether.o
drivers/net/ethernet/moxa/moxart_ether.c new file +586 -0
586 lines not on this page · raw message
drivers/net/ethernet/moxa/moxart_ether.h new file +513 -0
513 lines not on this page · raw message
Signature · 1 line
1.8.2.1
Quoted 2 lines · Jonas Jensen
The MOXA UC-711X hardware(s) has an ethernet controller that seem to be developed internally. The IC used is "RTL8201CP".
Just some simple comments...
drivers/net/ethernet/moxa/moxart_ether.c
Quoted 1 line
drivers/net/ethernet/moxa/moxart_ether.c +0
-0
[]
Quoted 1 line
+static int
moxart_rx_poll(struct napi_struct *napi, int budget)
[]
drivers/net/ethernet/moxa/moxart_ether.c line 214
Quoted 1 line
drivers/net/ethernet/moxa/moxart_ether.c +1
-0+while (1 ) {
[]
drivers/net/ethernet/moxa/moxart_ether.c line 222
Quoted 2 lines
drivers/net/ethernet/moxa/moxart_ether.c +2
-0+if (ui & (RX_ERR |CRC_ERR |FTL |RUNT |RX_ODD_NB )) { +netdev_err (ndev,"packet error\n" );
This is generally a bad idea as it can flood the log. It's probably better to remove it. If you really want logging, then at least use net_ratelimit(). Generally, the stats are enough.
drivers/net/ethernet/moxa/moxart_ether.c line 224
Quoted 2 lines
drivers/net/ethernet/moxa/moxart_ether.c +2
-0+ priv->stats.rx_dropped++; + priv->stats.rx_errors++;
[]
Quoted 1 line
+static int
moxart_mac_start_xmit(struct sk_buff *skb, struct net_device *ndev)
[]
drivers/net/ethernet/moxa/moxart_ether.c line 324
Quoted 3 lines
drivers/net/ethernet/moxa/moxart_ether.c +3
-0+if (txdesc->txdes0.ubit.tx_dma_own) { +netdev_err (ndev,"no TX space for packet\n" ); + priv->stats.tx_dropped++;
here too.
Quoted 1 line
+static int
moxart_mac_probe(struct platform_device *pdev)
[]
drivers/net/ethernet/moxa/moxart_ether.c line 512
Quoted 13 lines
drivers/net/ethernet/moxa/moxart_ether.c +13
-0+ priv->tx_buf_base =kmalloc (priv->tx_buf_size *TX_DESC_NUM , +GFP_ATOMIC ); +if (!priv->tx_buf_base) { +netdev_err (ndev,"TX buffer alloc failed\n" ); + goto init_fail; + } + + priv->rx_buf_base =kmalloc (priv->rx_buf_size *RX_DESC_NUM , +GFP_ATOMIC ); +if (!priv->rx_buf_base) { +netdev_err (ndev,"RX buffer alloc failed\n" ); + goto init_fail; + }
Extra OOM messages aren't useful, there's a generic OOM and a dump_stack from the kernel.
drivers/net/ethernet/moxa/moxart_ether.c line 543
Quoted 4 lines
drivers/net/ethernet/moxa/moxart_ether.c +4
-0+netdev_dbg (ndev,"%s: IRQ=%d address=%02x:%02x:%02x:%02x:%02x:%02x\n" , + __func__, ndev->irq, + ndev->dev_addr[0 ], ndev->dev_addr[1 ], ndev->dev_addr[2 ], + ndev->dev_addr[3 ], ndev->dev_addr[4 ], ndev->dev_addr[5 ]);
There's a mac address helper you can use:
netdev_dbg(ndev, "%s: IRQ=%d address=%pM\n" __func__, ndev->irq, ndev->dev_addr);
David Miller
maintainerFrom: Joe Perches <[email protected]>
Date: Wed, 31 Jul 2013 11:56:38 -0700
Quoted 8 lines
drivers/net/ethernet/moxa/moxart_ether.c line 222
Quoted 2 lines
drivers/net/ethernet/moxa/moxart_ether.c new file +2
-0+if (ui & (RX_ERR |CRC_ERR |FTL |RUNT |RX_ODD_NB )) { +netdev_err (ndev,"packet error\n" );This is generally a bad idea as it can flood the log. It's probably better to remove it. If you really want logging, then at least use
net_ratelimit(). Generally, the stats are enough.
...
Quoted 10 lines
drivers/net/ethernet/moxa/moxart_ether.c line 224
Quoted 2 lines
drivers/net/ethernet/moxa/moxart_ether.c new file +2
-0+ priv->stats.rx_dropped++; + priv->stats.rx_errors++;[]
Quoted 1 line
+static int
moxart_mac_start_xmit(struct sk_buff *skb, struct net_device *ndev)[]
drivers/net/ethernet/moxa/moxart_ether.c line 324
Quoted 3 lines
drivers/net/ethernet/moxa/moxart_ether.c new file +3
-0+if (txdesc->txdes0.ubit.tx_dma_own) { +netdev_err (ndev,"no TX space for packet\n" ); + priv->stats.tx_dropped++;here too.
Agreed, these should not be logged, the statistics are sufficient.
PATCH v4 1/1 net: Add MOXA ART SoCs ethernet driver
In reply to Jonas JensenThe MOXA UC-711X hardware(s) has an ethernet controller that seem to be developed internally. The IC used is "RTL8201CP".
Since there is no public documentation, this driver is mostly the one published by MOXA that has been heavily cleaned up / ported from linux 2.6.9.
---
Notes:
Thanks, changes from your feedback is enclosed.
I have since found a problem occurring on high load. Please point out
anything the driver can do differently to eliminate it.
The error only occurs during external ping, i.e. ping -s 50000 from
10.0.1.200 to hardware.
After the error, ping reports 100% packet loss from the hardware, but
it's still possible to ping in outgoing direction.
Changes since v3:
1. don't flood the log, use net_dbg_ratelimited(), not netdev_err()
2. free TX skb:s after stats increment tx_bytes, not before
3. don't print extra message on alloc failure
4. use %pM extended format printk specifier
5. increment rx_errors if build_skb() fails
Applies to next-20130731
Interestingly, on the old port, 1980 is the largest allowed size,
ping segfaults between sizes 1976 to 1980:
uname -a
Linux Moxa 2.6.9-uc0 #230 Fri Mar 5 11:04:24 CST 2010 armv4tl unknown
root at Moxa:/# ping -s 1981 10.0.1.200
ping: packet size too large.
root at Moxa:/# ping -s 1980 10.0.1.200
Segmentation fault
root at Moxa:/# ping -s 1976 10.0.1.200
Segmentation fault
root at Moxa:/# ping -s 1975 10.0.1.200
PING (10.0.1.200): 1975 data bytes
1983 bytes from 10.0.1.200: icmp_seq=0 ttl=64 time=6.9 ms
1983 bytes from 10.0.1.200: icmp_seq=1 ttl=64 time=16.2 ms
uname -a
Linux (none) 3.11.0-rc3-next-20130731+ #200 PREEMPT Thu Aug 1 10:09:16 CEST 2013
armv4l GNU/Linux
ping -s 50000 10.0.1.200
PING 10.0.1.200 (10.0.1.200): 50000 data bytes
50008 bytes from 10.0.1.200: seq=0 ttl=64 time=36.294 ms
50008 bytes from 10.0.1.200: seq=1 ttl=64 time=35.708 ms
50008 bytes from 10.0.1.200: seq=2 ttl=64 time=35.763 ms
50008 bytes from 10.0.1.200: seq=3 ttl=64 time=35.703 ms
50008 bytes from 10.0.1.200: seq=4 ttl=64 time=35.789 ms
50008 bytes from 10.0.1.200: seq=5 ttl=64 time=35.647 ms
50008 bytes from 10.0.1.200: seq=6 ttl=64 time=36.012 ms
50008 bytes from 10.0.1.200: seq=7 ttl=64 time=35.650 ms
50008 bytes from 10.0.1.200: seq=8 ttl=64 time=35.700 ms
50008 bytes from 10.0.1.200: seq=9 ttl=64 time=35.845 ms
50008 bytes from 10.0.1.200: seq=10 ttl=64 time=35.886 ms
^C
--- 10.0.1.200 ping statistics ---
11 packets transmitted, 11 packets received, 0% packet loss
round-trip min/avg/max = 35.647/35.817/36.294 ms
ping -s 50000 10.0.1.200
PING 10.0.1.200 (10.0.1.200): 50000 data bytes
50008 bytes from 10.0.1.200: seq=0 ttl=64 time=35.694 ms
ping: recvfrom: Bad address
[ 33.340000] BUG: Bad page state in process ping pfn:019c0
[ 33.350000] page:c082e800 count:-59 mapcount:0 mapping: (null) index:0x0
[ 33.360000] page flags: 0x0()
[ 33.360000] CPU: 0 PID: 229 Comm: ping Not tainted 3.11.0-rc3-next-20130731+ #198
[ 33.390000] [<c000c680>] (unwind_backtrace+0x0/0xf0) from [<c000b294>] (show_stack+0x10/0x14)
[ 33.400000] [<c000b294>] (show_stack+0x10/0x14) from [<c0060404>] (bad_page+0xa8/0x108)
[ 33.410000] [<c0060404>] (bad_page+0xa8/0x108) from [<c00609dc>] (get_page_from_freelist+0x474/0x594)
[ 33.420000] [<c00609dc>] (get_page_from_freelist+0x474/0x594) from [<c0061424>] (__alloc_pages_nodemask+0xcc/0x794)
[ 33.430000] [<c0061424>] (__alloc_pages_nodemask+0xcc/0x794) from [<c00852d0>] (new_slab+0x64/0x2dc)
[ 33.440000] [<c00852d0>] (new_slab+0x64/0x2dc) from [<c021b17c>] (__slab_alloc.isra.57.constprop.59+0x4cc/0x5f0)
[ 33.450000] [<c021b17c>] (__slab_alloc.isra.57.constprop.59+0x4cc/0x5f0) from [<c0086f20>] (__kmalloc_track_caller+0x120/0x180)
[ 33.460000] [<c0086f20>] (__kmalloc_track_caller+0x120/0x180) from [<c01a33c4>] (__kmalloc_reserve.isra.16+0x24/0x70)
[ 33.470000] [<c01a33c4>] (__kmalloc_reserve.isra.16+0x24/0x70) from [<c01a34bc>] (__alloc_skb+0x5c/0x148)
[ 33.480000] [<c01a34bc>] (__alloc_skb+0x5c/0x148) from [<c01a00d8>] (sock_wmalloc+0x38/0x88)
[ 33.490000] [<c01a00d8>] (sock_wmalloc+0x38/0x88) from [<c01d3dfc>] (__ip_append_data+0x8cc/0x980)
[ 33.500000] [<c01d3dfc>] (__ip_append_data+0x8cc/0x980) from [<c01d59b4>] (ip_append_data+0x94/0xbc)
[ 33.510000] [<c01d59b4>] (ip_append_data+0x94/0xbc) from [<c01f6350>] (raw_sendmsg+0x2e8/0x858)
[ 33.520000] [<c01f6350>] (raw_sendmsg+0x2e8/0x858) from [<c020247c>] (inet_sendmsg+0x3c/0x70)
[ 33.530000] [<c020247c>] (inet_sendmsg+0x3c/0x70) from [<c019c5c4>] (sock_sendmsg+0x78/0x8c)
[ 33.540000] [<c019c5c4>] (sock_sendmsg+0x78/0x8c) from [<c019d830>] (SyS_sendto+0xb4/0xd4)
[ 33.550000] [<c019d830>] (SyS_sendto+0xb4/0xd4) from [<c0009080>] (ret_fast_syscall+0x0/0x44)
[ 33.560000] BUG: Bad page state in process ping pfn:019c4
[ 33.560000] page:c082e880 count:-38 mapcount:0 mapping: (null) index:0x0
[ 33.570000] page flags: 0x0()
[ 33.570000] CPU: 0 PID: 229 Comm: ping Tainted: G B 3.11.0-rc3-next-20130731+ #198
[ 33.580000] [<c000c680>] (unwind_backtrace+0x0/0xf0) from [<c000b294>] (show_stack+0x10/0x14)
[ 33.590000] [<c000b294>] (show_stack+0x10/0x14) from [<c0060404>] (bad_page+0xa8/0x108)
[ 33.600000] [<c0060404>] (bad_page+0xa8/0x108) from [<c00609dc>] (get_page_from_freelist+0x474/0x594)
[ 33.610000] [<c00609dc>] (get_page_from_freelist+0x474/0x594) from [<c0061424>] (__alloc_pages_nodemask+0xcc/0x794)
[ 33.620000] [<c0061424>] (__alloc_pages_nodemask+0xcc/0x794) from [<c00852d0>] (new_slab+0x64/0x2dc)
[ 33.630000] [<c00852d0>] (new_slab+0x64/0x2dc) from [<c021b17c>] (__slab_alloc.isra.57.constprop.59+0x4cc/0x5f0)
[ 33.640000] [<c021b17c>] (__slab_alloc.isra.57.constprop.59+0x4cc/0x5f0) from [<c0086f20>] (__kmalloc_track_caller+0x120/0x180)
[ 33.650000] [<c0086f20>] (__kmalloc_track_caller+0x120/0x180) from [<c01a33c4>] (__kmalloc_reserve.isra.16+0x24/0x70)
[ 33.660000] [<c01a33c4>] (__kmalloc_reserve.isra.16+0x24/0x70) from [<c01a34bc>] (__alloc_skb+0x5c/0x148)
[ 33.670000] [<c01a34bc>] (__alloc_skb+0x5c/0x148) from [<c01a00d8>] (sock_wmalloc+0x38/0x88)
[ 33.680000] [<c01a00d8>] (sock_wmalloc+0x38/0x88) from [<c01d3dfc>] (__ip_append_data+0x8cc/0x980)
[ 33.690000] [<c01d3dfc>] (__ip_append_data+0x8cc/0x980) from [<c01d59b4>] (ip_append_data+0x94/0xbc)
[ 33.700000] [<c01d59b4>] (ip_append_data+0x94/0xbc) from [<c01f6350>] (raw_sendmsg+0x2e8/0x858)
[ 33.710000] [<c01f6350>] (raw_sendmsg+0x2e8/0x858) from [<c020247c>] (inet_sendmsg+0x3c/0x70)
[ 33.720000] [<c020247c>] (inet_sendmsg+0x3c/0x70) from [<c019c5c4>] (sock_sendmsg+0x78/0x8c)
[ 33.730000] [<c019c5c4>] (sock_sendmsg+0x78/0x8c) from [<c019d830>] (SyS_sendto+0xb4/0xd4)
[ 33.740000] [<c019d830>] (SyS_sendto+0xb4/0xd4) from [<c0009080>] (ret_fast_syscall+0x0/0x44)
...
http://ideone.com/2FkfMB.../devicetree/bindings/net/moxa,moxart-mac.txt | 25 + drivers/net/ethernet/Kconfig | 1 + drivers/net/ethernet/Makefile | 1 + drivers/net/ethernet/moxa/Kconfig | 30 ++ drivers/net/ethernet/moxa/Makefile | 5 + drivers/net/ethernet/moxa/moxart_ether.c | 577 +++++++++++++++++++++ drivers/net/ethernet/moxa/moxart_ether.h | 513 ++++++++++++++++++ 7 files changed, 1152 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/moxa,moxart-mac.txt create mode 100644 drivers/net/ethernet/moxa/Kconfig create mode 100644 drivers/net/ethernet/moxa/Makefile create mode 100644 drivers/net/ethernet/moxa/moxart_ether.c create mode 100644 drivers/net/ethernet/moxa/moxart_ether.h
Documentation/devicetree/bindings/net/moxa,moxart-mac.txt new file +25 -0
@@ -0,0 +1,25 @@ +MOXA ART Ethernet Controller + +Required properties: + +- compatible : Must be "moxa,moxart-mac" +- reg : Should contain registers location and length + index 0 : main register + index 1 : mac address (stored on flash) +- interrupts : Should contain the mac interrupt number + +Example: + + mac0: mac at 90900000 { + compatible = "moxa,moxart-mac"; + reg = <0x90900000 0x100>, + <0x80000050 0x6>; + interrupts = <25 0>; + }; + + mac1: mac at 92000000 { + compatible = "moxa,moxart-mac"; + reg = <0x92000000 0x100>, + <0x80000056 0x6>; + interrupts = <27 0>; + };
drivers/net/ethernet/Kconfig +1 -0
@@ -90,6 +90,7 @@ source "drivers/net/ethernet/marvell/Kconfig" source "drivers/net/ethernet/mellanox/Kconfig" source "drivers/net/ethernet/micrel/Kconfig" source "drivers/net/ethernet/microchip/Kconfig" +source "drivers/net/ethernet/moxa/Kconfig" source "drivers/net/ethernet/myricom/Kconfig" config FEALNX
drivers/net/ethernet/Makefile +1 -0
@@ -42,6 +42,7 @@ obj-$(CONFIG_NET_VENDOR_MARVELL) += marvell/ obj-$(CONFIG_NET_VENDOR_MELLANOX) += mellanox/ obj-$(CONFIG_NET_VENDOR_MICREL) += micrel/ obj-$(CONFIG_NET_VENDOR_MICROCHIP) += microchip/ +obj-$(CONFIG_NET_VENDOR_MOXART) += moxa/ obj-$(CONFIG_NET_VENDOR_MYRI) += myricom/ obj-$(CONFIG_FEALNX) += fealnx.o obj-$(CONFIG_NET_VENDOR_NATSEMI) += natsemi/
drivers/net/ethernet/moxa/Kconfig new file +30 -0
@@ -0,0 +1,30 @@ +# +# MOXART device configuration +# + +config NET_VENDOR_MOXART + bool "MOXA ART devices" + default y + depends on (ARM && ARCH_MOXART) + ---help--- + If you have a network (Ethernet) card belonging to this class, say Y + and read the Ethernet-HOWTO, available from + <http://www.tldp.org/docs.html#howto>. + + Note that the answer to this question doesn't directly affect the + kernel: saying N will just cause the configurator to skip all + the questions about MOXA ART devices. If you say Y, you will be asked + for your specific card in the following questions. + +if NET_VENDOR_MOXART + +config ARM_MOXART_ETHER + tristate "MOXART Ethernet support" + depends on ARM && ARCH_MOXART + select NET_CORE + ---help--- + If you wish to compile a kernel for a hardware with MOXA ART SoC and + want to use the internal ethernet then you should answer Y to this. + + +endif # NET_VENDOR_MOXART
drivers/net/ethernet/moxa/Makefile new file +5 -0
@@ -0,0 +1,5 @@ +# +# Makefile for the MOXART network device drivers. +# + +obj-$(CONFIG_ARM_MOXART_ETHER) += moxart_ether.o
drivers/net/ethernet/moxa/moxart_ether.c new file +577 -0
577 lines not on this page · raw message
drivers/net/ethernet/moxa/moxart_ether.h new file +513 -0
513 lines not on this page · raw message
Signature · 1 line
1.8.2.1
David Miller
maintainerFrom: Jonas Jensen <[email protected]>
Date: Thu, 1 Aug 2013 11:39:28 +0200
Quoted 5 lines
I have since found a problem occurring on high load. Please point out anything the driver can do differently to eliminate it.
The error only occurs during external ping, i.e. ping -s 50000 from 10.0.1.200 to hardware.
Looks like pure memory corruption.
Quoted 8 lines · Jonas Jensen
The MOXA UC-711X hardware(s) has an ethernet controller that seem to be developed internally. The IC used is "RTL8201CP".
Since there is no public documentation, this driver is mostly the one published by MOXA that has been heavily cleaned up / ported from linux 2.6.9.
Signed-off-by Jonas Jensen <[email protected]>---
[...]
Documentation/devicetree/bindings/net/moxa,moxart-mac.txt line 7
Quoted 13 lines
Documentation/devicetree/bindings/net/moxa,moxart-mac.txt new file +7
-0@@ -0,0 +1,25 @@ +MOXA ART Ethernet Controller + +Required properties: + +- compatible : Must be "moxa,moxart-mac" +- reg : Should contain registers location and length + index 0 : main register
I assume there's more than one register in the main register bank?
Are there any other register banks not used by this driver?
Documentation/devicetree/bindings/net/moxa,moxart-mac.txt line 8
Quoted 1 line
Documentation/devicetree/bindings/net/moxa,moxart-mac.txt new file +1
-0+ index 1 : mac address (stored on flash)
Is that flash a part of the MAC unit?
Is it only 6 bytes long (judging by the examples), or is the th only portion used by the driver?
If it's bigger, I'd prefer to describe the whole of flash. This driver will know the offset within it, and can choose to map only the protion it wants to use. Another driver may choose to do more interesting things. We need to describe the hardware, not how we expect it to be used...
If it's not associated with the MAC, I'm not sure this is the best way of describing the linkage...
Documentation/devicetree/bindings/net/moxa,moxart-mac.txt line 9
Quoted 1 line
Documentation/devicetree/bindings/net/moxa,moxart-mac.txt new file +1
-0+- interrupts : Should contain the mac interrupt number
Is there no need to link this to a phy, or is it a fixed-link device?
Quoted 16 lines
Documentation/devicetree/bindings/net/moxa,moxart-mac.txt new file +16
-0+ +Example: + + mac0: mac at 90900000 { + compatible = "moxa,moxart-mac"; + reg = <0x90900000 0x100>, + <0x80000050 0x6>; + interrupts = <25 0>; + }; + + mac1: mac at 92000000 { + compatible = "moxa,moxart-mac"; + reg = <0x92000000 0x100>, + <0x80000056 0x6>; + interrupts = <27 0>; + };
[...]
Quoted 43 lines
drivers/net/ethernet/moxa/moxart_ether.h new file +37
-0@@ -0,0 +1,513 @@ +/* MOXA ART Ethernet (RTL8201CP) driver. +* +* Copyright (C) 2013 Jonas Jensen +* +* Jonas Jensen <[email protected]> +* +* Based on code from +* Moxa Technology Co., Ltd. <www.moxa.com> +* +* This file is licensed under the terms of the GNU General Public +* License version 2. This program is licensed "as is" without any +* warranty of any kind, whether express or implied. +*/ + +#ifndef _MOXART_ETHERNET_H +#define _MOXART_ETHERNET_H + +#define TX_DESC_NUM 64 +#define TX_DESC_NUM_MASK (TX_DESC_NUM-1) +#define TX_NEXT(N) (((N) + 1) & (TX_DESC_NUM_MASK)) +#define TX_BUF_SIZE 1600 + +#define RX_DESC_NUM 64 +#define RX_DESC_NUM_MASK (RX_DESC_NUM-1) +#define RX_NEXT(N) (((N) + 1) & (RX_DESC_NUM_MASK)) +#define RX_BUF_SIZE 1600 + +struct tx_desc_t { + union { +#define TXDMA_OWN BIT(31) +#define TXPKT_EXSCOL BIT(1) +#define TXPKT_LATECOL BIT(0) + unsigned int ui; + + struct { + /* is aborted due to late collision */ + unsigned int tx_pkt_late_col:1;
drivers/net/ethernet/moxa/moxart_ether.h line 47
Quoted 10 lines
drivers/net/ethernet/moxa/moxart_ether.h new file +10
-0+ +/* is aborted after 16 collisions */ + unsigned int rx_pkt_exs_col:1; + + unsigned int reserved1:29; + +/* is owned by the MAC controller */ + unsigned int tx_dma_own:1; + } ubit; + } txdes0;
Unless I've misunderstood the later code, this is the format of data shared with the device? Bitfields aren't portable, and you can't rely on the padding here being what you expect...
Similarly, the other structures below used in this way below seem scary to me.
Quoted 365 lines
drivers/net/ethernet/moxa/moxart_ether.h new file +365
-0+ +union { +#define EDOTR BIT(31) +#define TXIC BIT(30) +#define TX2FIC BIT(29) +#define FTS BIT(28) +#define LTS BIT(27) +#define TXBUF_SIZE_MASK 0x7ff +#define TXBUF_SIZE_MAX (TXBUF_SIZE_MASK+1) +unsigned int ui; + +struct { +/* transmit buffer size in byte */ +unsigned int tx_buf_size:11 ; + +unsigned int reserved2:16 ; + +/* is the last descriptor of a Tx packet */ +unsigned int lts:1 ; + +/* is the first descriptor of a Tx packet */ +unsigned int fts:1 ; + +/* transmit to FIFO interrupt on completion */ +unsigned int tx2_fic:1 ; + +/* transmit interrupt on completion */ +unsigned int tx_ic:1 ; + +/* end descriptor of transmit ring */ +unsigned int edotr:1 ; + } ubit; + } txdes1; + +struct { +/* transmit buffer physical base address */ +unsigned int addr_phys; + +/* transmit buffer virtual base address */ +unsigned char *addr_virt; + } txdes2; +}; + +struct rx_desc_t { +union { +#define RXDMA_OWN BIT(31) +#define FRS BIT(29) +#define LRS BIT(28) +#define RX_ODD_NB BIT(22) +#define RUNT BIT(21) +#define FTL BIT(20) +#define CRC_ERR BIT(19) +#define RX_ERR BIT(18) +#define BROADCAST_RXDES0 BIT(17) +#define MULTICAST_RXDES0 BIT(16) +#define RFL_MASK 0x7ff +#define RFL_MAX (RFL_MASK+1) +unsigned int ui; + +struct { +/* receive frame length */ +unsigned int recv_frame_len:11 ; +unsigned int reserved1:5 ; + +/* multicast frame */ +unsigned int multicast:1 ; + +/* broadcast frame */ +unsigned int broadcast:1 ; +unsigned int rx_err:1 ;/* receive error */ +unsigned int crc_err:1 ;/* CRC error */ +unsigned int ftl:1 ;/* frame too long */ + +/* runt packet, less than 64 bytes */ +unsigned int runt:1 ; + +/* receive odd nibbles */ +unsigned int rx_odd_nb:1 ; +unsigned int reserved2:5 ; + +/* last receive segment descriptor */ +unsigned int lrs:1 ; + +/* first receive segment descriptor */ +unsigned int frs:1 ; + +unsigned int reserved3:1 ; +unsigned int rx_dma_own:1 ;/* RXDMA onwership */ + } ubit; + } rxdes0; + +union { +#define EDORR BIT(31) +#define RXBUF_SIZE_MASK 0x7ff +#define RXBUF_SIZE_MAX (RXBUF_SIZE_MASK+1) +unsigned int ui; + +struct { +/* receive buffer size */ +unsigned int rx_buf_size:11 ; + +unsigned int reserved4:20 ; + +/* end descriptor of receive ring */ +unsigned int edorr:1 ; + } ubit; + } rxdes1; + +struct { +/* receive buffer physical base address */ +unsigned int addr_phys; + +/* receive buffer virtual base address */ +unsigned char *addr_virt; + } rxdes2; +}; + +struct mac_control_reg_t { + +/* RXDMA has received packets into RX buffer successfully */ +#define RPKT_FINISH BIT(0) +/* receive buffer unavailable */ +#define NORXBUF BIT(1) +/* TXDMA has moved data into the TX FIFO */ +#define XPKT_FINISH BIT(2) +/* transmit buffer unavailable */ +#define NOTXBUF BIT(3) +/* packets transmitted to ethernet successfully */ +#define XPKT_OK_INT_STS BIT(4) +/* packets transmitted to ethernet lost due to late +* collision or excessive collision +*/ +#define XPKT_LOST_INT_STS BIT(5) +/* packets received into RX FIFO successfully */ +#define RPKT_SAV BIT(6) +/* received packet lost due to RX FIFO full */ +#define RPKT_LOST_INT_STS BIT(7) +#define AHB_ERR BIT(8)/* AHB error */ +#define PHYSTS_CHG BIT(9)/* PHY link status change */ +unsigned int isr;/* interrupt status, 0x0 */ + +#define RPKT_FINISH_M BIT(0)/* interrupt mask of ISR[0] */ +#define NORXBUF_M BIT(1)/* interrupt mask of ISR[1] */ +#define XPKT_FINISH_M BIT(2)/* interrupt mask of ISR[2] */ +#define NOTXBUF_M BIT(3)/* interrupt mask of ISR[3] */ +#define XPKT_OK_M BIT(4)/* interrupt mask of ISR[4] */ +#define XPKT_LOST_M BIT(5)/* interrupt mask of ISR[5] */ +#define RPKT_SAV_M BIT(6)/* interrupt mask of ISR[6] */ +#define RPKT_LOST_M BIT(7)/* interrupt mask of ISR[7] */ +#define AHB_ERR_M BIT(8)/* interrupt mask of ISR[8] */ +#define PHYSTS_CHG_M BIT(9)/* interrupt mask of ISR[9] */ +unsigned int imr;/* interrupt mask, 0x4 */ + +/* the most significant 2 bytes of MAC address */ +#define MAC_MADR_MASK 0xffff +/* MAC most significant address, 0x8 */ +unsigned int mac_madr; + +/* MAC least significant address, 0xc */ +unsigned int mac_ldar; + +/* multicast address hash table 0, 0x10 */ +unsigned int matht0; + +/* multicast address hash table 1, 0x14 */ +unsigned int matht1; + +/* transmit poll demand, 0x18 */ +unsigned int txpd; + +/* receive poll demand, 0x1c */ +unsigned int rxpd; + +/* transmit ring base address, 0x20 */ +unsigned int txr_badr; + +/* receive ring base address, 0x24 */ +unsigned int rxr_badr; + +/* defines the period of TX cycle time */ +#define TXINT_TIME_SEL BIT(15) +#define TXINT_THR_MASK 0x7000 +#define TXINT_CNT_MASK 0xf00 +/* defines the period of RX cycle time */ +#define RXINT_TIME_SEL BIT(7) +#define RXINT_THR_MASK 0x70 +#define RXINT_CNT_MASK 0xF +/* interrupt timer control, 0x28 */ +unsigned int itc; + +/* defines the period of TX poll time */ +#define TXPOLL_TIME_SEL BIT(12) +#define TXPOLL_CNT_MASK 0xf00 +#define TXPOLL_CNT_SHIFT_BIT 8 +/* defines the period of RX poll time */ +#define RXPOLL_TIME_SEL BIT(4) +#define RXPOLL_CNT_MASK 0xF +#define RXPOLL_CNT_SHIFT_BIT 0 +/* automatic polling timer control, 0x2c */ +unsigned int aptc; + +/* enable RX FIFO threshold arbitration */ +#define RX_THR_EN BIT(9) +#define RXFIFO_HTHR_MASK 0x1c0 +#define RXFIFO_LTHR_MASK 0x38 +/* use INCR16 burst command in AHB bus */ +#define INCR16_EN BIT(2) +/* use INCR8 burst command in AHB bus */ +#define INCR8_EN BIT(1) +/* use INCR4 burst command in AHB bus */ +#define INCR4_EN BIT(0) +/* DMA burst length and arbitration control, 0x30 */ +unsigned int dblac; + +unsigned int reserved1[21 ];/* 0x34 - 0x84 */ + +#define RX_BROADPKT BIT(17)/* receive boradcast packet */ +/* receive all multicast packet */ +#define RX_MULTIPKT BIT(16) +#define FULLDUP BIT(15)/* full duplex */ +/* append CRC to transmitted packet */ +#define CRC_APD BIT(14) +/* do not check incoming packet's destination address */ +#define RCV_ALL BIT(12) +/* store incoming packet even if its length is great than 1518 bytes */ +#define RX_FTL BIT(11) +/* store incoming packet even if its length is less than 64 bytes */ +#define RX_RUNT BIT(10) +/* enable storing incoming packet if the packet passes hash table +* address filtering and is a multicast packet +*/ +#define HT_MULTI_EN BIT(9) +#define RCV_EN BIT(8)/* receiver enable */ +/* enable packet reception when transmitting packet in half duplex mode */ +#define ENRX_IN_HALFTX BIT(6) +#define XMT_EN BIT(5)/* transmitter enable */ +/* disable CRC check when receiving packets */ +#define CRC_DIS BIT(4) +#define LOOP_EN BIT(3)/* internal loop-back */ +/* software reset, last 64 AHB bus clocks */ +#define SW_RST BIT(2) +#define RDMA_EN BIT(1)/* enable receive DMA chan */ +#define XDMA_EN BIT(0)/* enable transmit DMA chan */ +unsigned int maccr;/* MAC control, 0x88 */ + +#define COL_EXCEED BIT(11)/* collisions exceeds 16 */ +/* transmitter detects late collision */ +#define LATE_COL BIT(10) +/* packet transmitted to ethernet lost due to late collision +* or excessive collision +*/ +#define XPKT_LOST BIT(9) +/* packets transmitted to ethernet successfully */ +#define XPKT_OK BIT(8) +/* receiver detects a runt packet */ +#define RUNT_MAC_STS BIT(7) +/* receiver detects a frame that is too long */ +#define FTL_MAC_STS BIT(6) +#define CRC_ERR_MAC_STS BIT(5) +/* received packets list due to RX FIFO full */ +#define RPKT_LOST BIT(4) +/* packets received into RX FIFO successfully */ +#define RPKT_SAVE BIT(3) +/* incoming packet dropped due to collision */ +#define COL BIT(2) +#define MCPU_BROADCAST BIT(1) +#define MCPU_MULTICAST BIT(0) +unsigned int macsr;/* MAC status, 0x8c */ + +/* initialize a write sequence to PHY by setting this bit to 1 +* this bit would be auto cleared after the write operation is finished. +*/ +#define MIIWR BIT(27) +#define MIIRD BIT(26) +#define REGAD_MASK 0x3e00000 +#define PHYAD_MASK 0x1f0000 +#define MIIRDATA_MASK 0xffff +unsigned int phycr;/* PHY control, 0x90 */ + +#define MIIWDATA_MASK 0xffff +unsigned int phywdata;/* PHY write data, 0x94 */ + +#define PAUSE_TIME_MASK 0xffff0000 +#define FC_HIGH_MASK 0xf000 +#define FC_LOW_MASK 0xf00 +#define RX_PAUSE BIT(4)/* receive pause frame */ +/* packet transmission is paused due to receive */ +#define TXPAUSED BIT(3) +/* pause frame */ +/* enable flow control threshold mode. */ +#define FCTHR_EN BIT(2) +#define TX_PAUSE BIT(1)/* transmit pause frame */ +#define FC_EN BIT(0)/* flow control mode enable */ +unsigned int fcr;/* flow control, 0x98 */ + +#define BK_LOW_MASK 0xf00 +#define BKJAM_LEN_MASK 0xf0 +#define BK_MODE BIT(1)/* back pressure address mode */ +#define BK_EN BIT(0)/* back pressure mode enable */ +unsigned int bpr;/* back pressure, 0x9c */ + +unsigned int reserved2[9 ];/* 0xa0 - 0xc0 */ + +#define TEST_SEED_MASK 0x3fff +unsigned int ts;/* test seed, 0xc4 */ + +#define TXD_REQ BIT(31)/* TXDMA request */ +#define RXD_REQ BIT(30)/* RXDMA request */ +#define DARB_TXGNT BIT(29)/* TXDMA grant */ +#define DARB_RXGNT BIT(28)/* RXDMA grant */ +#define TXFIFO_EMPTY BIT(27)/* TX FIFO is empty */ +#define RXFIFO_EMPTY BIT(26)/* RX FIFO is empty */ +#define TXDMA2_SM_MASK 0x7000 +#define TXDMA1_SM_MASK 0xf00 +#define RXDMA2_SM_MASK 0x70 +#define RXDMA1_SM_MASK 0xF +unsigned int dmafifos;/* DMA/FIFO state, 0xc8 */ + +#define SINGLE_PKT BIT(26)/* single packet mode */ +/* automatic polling timer test mode */ +#define PTIMER_TEST BIT(25) +#define ITIMER_TEST BIT(24)/* interrupt timer test mode */ +#define TEST_SEED_SEL BIT(22)/* test seed select */ +#define SEED_SEL BIT(21)/* seed select */ +#define TEST_MODE BIT(20)/* transmission test mode */ +#define TEST_TIME_MASK 0xffc00 +#define TEST_EXCEL_MASK 0x3e0 +unsigned int tm;/* test mode, 0xcc */ + +unsigned int reserved3;/* 0xd0 */ + +#define TX_MCOL_MASK 0xffff0000 +#define TX_MCOL_SHIFT_BIT 16 +#define TX_SCOL_MASK 0xffff +#define TX_SCOL_SHIFT_BIT 0 +/* TX_MCOL and TX_SCOL counter, 0xd4 */ +unsigned int txmcol_xscol; + +#define RPF_MASK 0xffff0000 +#define RPF_SHIFT_BIT 16 +#define AEP_MASK 0xffff +#define AEP_SHIFT_BIT 0 +unsigned int rpf_aep;/* RPF and AEP counter, 0xd8 */ + +#define XM_MASK 0xffff0000 +#define XM_SHIFT_BIT 16 +#define PG_MASK 0xffff +#define PG_SHIFT_BIT 0 +unsigned int xm_pg;/* XM and PG counter, 0xdc */ + +#define RUNT_CNT_MASK 0xffff0000 +#define RUNT_CNT_SHIFT_BIT 16 +#define TLCC_MASK 0xffff +#define TLCC_SHIFT_BIT 0 +/* RUNT_CNT and TLCC counter, 0xe0 */ +unsigned int runtcnt_tlcc; + +#define CRCER_CNT_MASK 0xffff0000 +#define CRCER_CNT_SHIFT_BIT 16 +#define FTL_CNT_MASK 0xffff +#define FTL_CNT_SHIFT_BIT 0 +/* CRCER_CNT and FTL_CNT counter, 0xe4 */ +unsigned int crcercnt_ftlcnt; + +#define RLC_MASK 0xffff0000
drivers/net/ethernet/moxa/moxart_ether.h line 422
Quoted 10 lines
drivers/net/ethernet/moxa/moxart_ether.h new file +10
-0+#define RLC_SHIFT_BIT 16 +#define RCC_MASK 0xffff +#define RCC_SHIFT_BIT 0 +unsigned int rlc_rcc;/* RLC and RCC counter, 0xe8 */ + +unsigned int broc;/* BROC counter, 0xec */ +unsigned int mulca;/* MULCA counter, 0xf0 */ +unsigned int rp;/* RP counter, 0xf4 */ +unsigned int xp;/* XP counter, 0xf8 */ +};
I don't think you can rely on the fields to be the size you expect (int is not necessarily 32 bits), and nor can you expect them to have the padding you expect (a 64 bit arch could pad ints to 64 bits). I think it would be better to just #define the offsets explicitly, which will be safe and easy to verify.
Thanks,
Mark.
2013/8/2 Mark Rutland <[email protected]>:
Quoted 37 lines · Jonas Jensen
Quoted 8 lines
The MOXA UC-711X hardware(s) has an ethernet controller that seem to be developed internally. The IC used is "RTL8201CP".
Since there is no public documentation, this driver is mostly the one published by MOXA that has been heavily cleaned up / ported from linux 2.6.9.
Signed-off-by Jonas Jensen <[email protected]>---
[...]
Documentation/devicetree/bindings/net/moxa,moxart-mac.txt line 7
Quoted 13 lines
Documentation/devicetree/bindings/net/moxa,moxart-mac.txt new file +7
-0@@ -0,0 +1,25 @@ +MOXA ART Ethernet Controller + +Required properties: + +- compatible : Must be "moxa,moxart-mac" +- reg : Should contain registers location and length + index 0 : main registerI assume there's more than one register in the main register bank?
Are there any other register banks not used by this driver?
Documentation/devicetree/bindings/net/moxa,moxart-mac.txt line 8
Quoted 1 line
Documentation/devicetree/bindings/net/moxa,moxart-mac.txt new file +1
-0+ index 1 : mac address (stored on flash)Is that flash a part of the MAC unit?
Is it only 6 bytes long (judging by the examples), or is the th only portion used by the driver?
Quoted 8 lines
If it's bigger, I'd prefer to describe the whole of flash. This driver will know the offset within it, and can choose to map only the protion it wants to use. Another driver may choose to do more interesting things. We need to describe the hardware, not how we expect it to be used...
If it's not associated with the MAC, I'm not sure this is the best way of describing the linkage...
I also do not quite like it, this is very unusual. Here is how you could potentially solve this:
- generate a random ethernet MAC adddress and later on let user-space fetch the MAC address from the flash and set it correctly
- have some early code in arch/arm/mach-moxart which fetches the MAC address from the flash and then update the ethernet node local-mac-address property accordingly
Ideally, fetching the MAC address from whatever backend storage is something that should really be left to user-space...
Quoted 469 lines
Documentation/devicetree/bindings/net/moxa,moxart-mac.txt line 9
Quoted 2 lines
Documentation/devicetree/bindings/net/moxa,moxart-mac.txt new file +1
-0+- interrupts : Should contain the mac interrupt numberIs there no need to link this to a phy, or is it a fixed-link device?
Quoted 16 lines
Documentation/devicetree/bindings/net/moxa,moxart-mac.txt new file +16
-0+ +Example: + + mac0: mac at 90900000 { + compatible = "moxa,moxart-mac"; + reg = <0x90900000 0x100>, + <0x80000050 0x6>; + interrupts = <25 0>; + }; + + mac1: mac at 92000000 { + compatible = "moxa,moxart-mac"; + reg = <0x92000000 0x100>, + <0x80000056 0x6>; + interrupts = <27 0>; + };[...]
Quoted 43 lines
drivers/net/ethernet/moxa/moxart_ether.h new file +37
-0@@ -0,0 +1,513 @@ +/* MOXA ART Ethernet (RTL8201CP) driver. +* +* Copyright (C) 2013 Jonas Jensen +* +* Jonas Jensen <[email protected]> +* +* Based on code from +* Moxa Technology Co., Ltd. <www.moxa.com> +* +* This file is licensed under the terms of the GNU General Public +* License version 2. This program is licensed "as is" without any +* warranty of any kind, whether express or implied. +*/ + +#ifndef _MOXART_ETHERNET_H +#define _MOXART_ETHERNET_H + +#define TX_DESC_NUM 64 +#define TX_DESC_NUM_MASK (TX_DESC_NUM-1) +#define TX_NEXT(N) (((N) + 1) & (TX_DESC_NUM_MASK)) +#define TX_BUF_SIZE 1600 + +#define RX_DESC_NUM 64 +#define RX_DESC_NUM_MASK (RX_DESC_NUM-1) +#define RX_NEXT(N) (((N) + 1) & (RX_DESC_NUM_MASK)) +#define RX_BUF_SIZE 1600 + +struct tx_desc_t { + union { +#define TXDMA_OWN BIT(31) +#define TXPKT_EXSCOL BIT(1) +#define TXPKT_LATECOL BIT(0) + unsigned int ui; + + struct { + /* is aborted due to late collision */ + unsigned int tx_pkt_late_col:1;drivers/net/ethernet/moxa/moxart_ether.h line 47
Quoted 10 lines
drivers/net/ethernet/moxa/moxart_ether.h new file +10
-0+ +/* is aborted after 16 collisions */ + unsigned int rx_pkt_exs_col:1; + + unsigned int reserved1:29; + +/* is owned by the MAC controller */ + unsigned int tx_dma_own:1; + } ubit; + } txdes0;Unless I've misunderstood the later code, this is the format of data shared with the device? Bitfields aren't portable, and you can't rely on the padding here being what you expect...
Similarly, the other structures below used in this way below seem scary to me.
Quoted 365 lines
drivers/net/ethernet/moxa/moxart_ether.h new file +365
-0+ +union { +#define EDOTR BIT(31) +#define TXIC BIT(30) +#define TX2FIC BIT(29) +#define FTS BIT(28) +#define LTS BIT(27) +#define TXBUF_SIZE_MASK 0x7ff +#define TXBUF_SIZE_MAX (TXBUF_SIZE_MASK+1) +unsigned int ui; + +struct { +/* transmit buffer size in byte */ +unsigned int tx_buf_size:11 ; + +unsigned int reserved2:16 ; + +/* is the last descriptor of a Tx packet */ +unsigned int lts:1 ; + +/* is the first descriptor of a Tx packet */ +unsigned int fts:1 ; + +/* transmit to FIFO interrupt on completion */ +unsigned int tx2_fic:1 ; + +/* transmit interrupt on completion */ +unsigned int tx_ic:1 ; + +/* end descriptor of transmit ring */ +unsigned int edotr:1 ; + } ubit; + } txdes1; + +struct { +/* transmit buffer physical base address */ +unsigned int addr_phys; + +/* transmit buffer virtual base address */ +unsigned char *addr_virt; + } txdes2; +}; + +struct rx_desc_t { +union { +#define RXDMA_OWN BIT(31) +#define FRS BIT(29) +#define LRS BIT(28) +#define RX_ODD_NB BIT(22) +#define RUNT BIT(21) +#define FTL BIT(20) +#define CRC_ERR BIT(19) +#define RX_ERR BIT(18) +#define BROADCAST_RXDES0 BIT(17) +#define MULTICAST_RXDES0 BIT(16) +#define RFL_MASK 0x7ff +#define RFL_MAX (RFL_MASK+1) +unsigned int ui; + +struct { +/* receive frame length */ +unsigned int recv_frame_len:11 ; +unsigned int reserved1:5 ; + +/* multicast frame */ +unsigned int multicast:1 ; + +/* broadcast frame */ +unsigned int broadcast:1 ; +unsigned int rx_err:1 ;/* receive error */ +unsigned int crc_err:1 ;/* CRC error */ +unsigned int ftl:1 ;/* frame too long */ + +/* runt packet, less than 64 bytes */ +unsigned int runt:1 ; + +/* receive odd nibbles */ +unsigned int rx_odd_nb:1 ; +unsigned int reserved2:5 ; + +/* last receive segment descriptor */ +unsigned int lrs:1 ; + +/* first receive segment descriptor */ +unsigned int frs:1 ; + +unsigned int reserved3:1 ; +unsigned int rx_dma_own:1 ;/* RXDMA onwership */ + } ubit; + } rxdes0; + +union { +#define EDORR BIT(31) +#define RXBUF_SIZE_MASK 0x7ff +#define RXBUF_SIZE_MAX (RXBUF_SIZE_MASK+1) +unsigned int ui; + +struct { +/* receive buffer size */ +unsigned int rx_buf_size:11 ; + +unsigned int reserved4:20 ; + +/* end descriptor of receive ring */ +unsigned int edorr:1 ; + } ubit; + } rxdes1; + +struct { +/* receive buffer physical base address */ +unsigned int addr_phys; + +/* receive buffer virtual base address */ +unsigned char *addr_virt; + } rxdes2; +}; + +struct mac_control_reg_t { + +/* RXDMA has received packets into RX buffer successfully */ +#define RPKT_FINISH BIT(0) +/* receive buffer unavailable */ +#define NORXBUF BIT(1) +/* TXDMA has moved data into the TX FIFO */ +#define XPKT_FINISH BIT(2) +/* transmit buffer unavailable */ +#define NOTXBUF BIT(3) +/* packets transmitted to ethernet successfully */ +#define XPKT_OK_INT_STS BIT(4) +/* packets transmitted to ethernet lost due to late +* collision or excessive collision +*/ +#define XPKT_LOST_INT_STS BIT(5) +/* packets received into RX FIFO successfully */ +#define RPKT_SAV BIT(6) +/* received packet lost due to RX FIFO full */ +#define RPKT_LOST_INT_STS BIT(7) +#define AHB_ERR BIT(8)/* AHB error */ +#define PHYSTS_CHG BIT(9)/* PHY link status change */ +unsigned int isr;/* interrupt status, 0x0 */ + +#define RPKT_FINISH_M BIT(0)/* interrupt mask of ISR[0] */ +#define NORXBUF_M BIT(1)/* interrupt mask of ISR[1] */ +#define XPKT_FINISH_M BIT(2)/* interrupt mask of ISR[2] */ +#define NOTXBUF_M BIT(3)/* interrupt mask of ISR[3] */ +#define XPKT_OK_M BIT(4)/* interrupt mask of ISR[4] */ +#define XPKT_LOST_M BIT(5)/* interrupt mask of ISR[5] */ +#define RPKT_SAV_M BIT(6)/* interrupt mask of ISR[6] */ +#define RPKT_LOST_M BIT(7)/* interrupt mask of ISR[7] */ +#define AHB_ERR_M BIT(8)/* interrupt mask of ISR[8] */ +#define PHYSTS_CHG_M BIT(9)/* interrupt mask of ISR[9] */ +unsigned int imr;/* interrupt mask, 0x4 */ + +/* the most significant 2 bytes of MAC address */ +#define MAC_MADR_MASK 0xffff +/* MAC most significant address, 0x8 */ +unsigned int mac_madr; + +/* MAC least significant address, 0xc */ +unsigned int mac_ldar; + +/* multicast address hash table 0, 0x10 */ +unsigned int matht0; + +/* multicast address hash table 1, 0x14 */ +unsigned int matht1; + +/* transmit poll demand, 0x18 */ +unsigned int txpd; + +/* receive poll demand, 0x1c */ +unsigned int rxpd; + +/* transmit ring base address, 0x20 */ +unsigned int txr_badr; + +/* receive ring base address, 0x24 */ +unsigned int rxr_badr; + +/* defines the period of TX cycle time */ +#define TXINT_TIME_SEL BIT(15) +#define TXINT_THR_MASK 0x7000 +#define TXINT_CNT_MASK 0xf00 +/* defines the period of RX cycle time */ +#define RXINT_TIME_SEL BIT(7) +#define RXINT_THR_MASK 0x70 +#define RXINT_CNT_MASK 0xF +/* interrupt timer control, 0x28 */ +unsigned int itc; + +/* defines the period of TX poll time */ +#define TXPOLL_TIME_SEL BIT(12) +#define TXPOLL_CNT_MASK 0xf00 +#define TXPOLL_CNT_SHIFT_BIT 8 +/* defines the period of RX poll time */ +#define RXPOLL_TIME_SEL BIT(4) +#define RXPOLL_CNT_MASK 0xF +#define RXPOLL_CNT_SHIFT_BIT 0 +/* automatic polling timer control, 0x2c */ +unsigned int aptc; + +/* enable RX FIFO threshold arbitration */ +#define RX_THR_EN BIT(9) +#define RXFIFO_HTHR_MASK 0x1c0 +#define RXFIFO_LTHR_MASK 0x38 +/* use INCR16 burst command in AHB bus */ +#define INCR16_EN BIT(2) +/* use INCR8 burst command in AHB bus */ +#define INCR8_EN BIT(1) +/* use INCR4 burst command in AHB bus */ +#define INCR4_EN BIT(0) +/* DMA burst length and arbitration control, 0x30 */ +unsigned int dblac; + +unsigned int reserved1[21 ];/* 0x34 - 0x84 */ + +#define RX_BROADPKT BIT(17)/* receive boradcast packet */ +/* receive all multicast packet */ +#define RX_MULTIPKT BIT(16) +#define FULLDUP BIT(15)/* full duplex */ +/* append CRC to transmitted packet */ +#define CRC_APD BIT(14) +/* do not check incoming packet's destination address */ +#define RCV_ALL BIT(12) +/* store incoming packet even if its length is great than 1518 bytes */ +#define RX_FTL BIT(11) +/* store incoming packet even if its length is less than 64 bytes */ +#define RX_RUNT BIT(10) +/* enable storing incoming packet if the packet passes hash table +* address filtering and is a multicast packet +*/ +#define HT_MULTI_EN BIT(9) +#define RCV_EN BIT(8)/* receiver enable */ +/* enable packet reception when transmitting packet in half duplex mode */ +#define ENRX_IN_HALFTX BIT(6) +#define XMT_EN BIT(5)/* transmitter enable */ +/* disable CRC check when receiving packets */ +#define CRC_DIS BIT(4) +#define LOOP_EN BIT(3)/* internal loop-back */ +/* software reset, last 64 AHB bus clocks */ +#define SW_RST BIT(2) +#define RDMA_EN BIT(1)/* enable receive DMA chan */ +#define XDMA_EN BIT(0)/* enable transmit DMA chan */ +unsigned int maccr;/* MAC control, 0x88 */ + +#define COL_EXCEED BIT(11)/* collisions exceeds 16 */ +/* transmitter detects late collision */ +#define LATE_COL BIT(10) +/* packet transmitted to ethernet lost due to late collision +* or excessive collision +*/ +#define XPKT_LOST BIT(9) +/* packets transmitted to ethernet successfully */ +#define XPKT_OK BIT(8) +/* receiver detects a runt packet */ +#define RUNT_MAC_STS BIT(7) +/* receiver detects a frame that is too long */ +#define FTL_MAC_STS BIT(6) +#define CRC_ERR_MAC_STS BIT(5) +/* received packets list due to RX FIFO full */ +#define RPKT_LOST BIT(4) +/* packets received into RX FIFO successfully */ +#define RPKT_SAVE BIT(3) +/* incoming packet dropped due to collision */ +#define COL BIT(2) +#define MCPU_BROADCAST BIT(1) +#define MCPU_MULTICAST BIT(0) +unsigned int macsr;/* MAC status, 0x8c */ + +/* initialize a write sequence to PHY by setting this bit to 1 +* this bit would be auto cleared after the write operation is finished. +*/ +#define MIIWR BIT(27) +#define MIIRD BIT(26) +#define REGAD_MASK 0x3e00000 +#define PHYAD_MASK 0x1f0000 +#define MIIRDATA_MASK 0xffff +unsigned int phycr;/* PHY control, 0x90 */ + +#define MIIWDATA_MASK 0xffff +unsigned int phywdata;/* PHY write data, 0x94 */ + +#define PAUSE_TIME_MASK 0xffff0000 +#define FC_HIGH_MASK 0xf000 +#define FC_LOW_MASK 0xf00 +#define RX_PAUSE BIT(4)/* receive pause frame */ +/* packet transmission is paused due to receive */ +#define TXPAUSED BIT(3) +/* pause frame */ +/* enable flow control threshold mode. */ +#define FCTHR_EN BIT(2) +#define TX_PAUSE BIT(1)/* transmit pause frame */ +#define FC_EN BIT(0)/* flow control mode enable */ +unsigned int fcr;/* flow control, 0x98 */ + +#define BK_LOW_MASK 0xf00 +#define BKJAM_LEN_MASK 0xf0 +#define BK_MODE BIT(1)/* back pressure address mode */ +#define BK_EN BIT(0)/* back pressure mode enable */ +unsigned int bpr;/* back pressure, 0x9c */ + +unsigned int reserved2[9 ];/* 0xa0 - 0xc0 */ + +#define TEST_SEED_MASK 0x3fff +unsigned int ts;/* test seed, 0xc4 */ + +#define TXD_REQ BIT(31)/* TXDMA request */ +#define RXD_REQ BIT(30)/* RXDMA request */ +#define DARB_TXGNT BIT(29)/* TXDMA grant */ +#define DARB_RXGNT BIT(28)/* RXDMA grant */ +#define TXFIFO_EMPTY BIT(27)/* TX FIFO is empty */ +#define RXFIFO_EMPTY BIT(26)/* RX FIFO is empty */ +#define TXDMA2_SM_MASK 0x7000 +#define TXDMA1_SM_MASK 0xf00 +#define RXDMA2_SM_MASK 0x70 +#define RXDMA1_SM_MASK 0xF +unsigned int dmafifos;/* DMA/FIFO state, 0xc8 */ + +#define SINGLE_PKT BIT(26)/* single packet mode */ +/* automatic polling timer test mode */ +#define PTIMER_TEST BIT(25) +#define ITIMER_TEST BIT(24)/* interrupt timer test mode */ +#define TEST_SEED_SEL BIT(22)/* test seed select */ +#define SEED_SEL BIT(21)/* seed select */ +#define TEST_MODE BIT(20)/* transmission test mode */ +#define TEST_TIME_MASK 0xffc00 +#define TEST_EXCEL_MASK 0x3e0 +unsigned int tm;/* test mode, 0xcc */ + +unsigned int reserved3;/* 0xd0 */ + +#define TX_MCOL_MASK 0xffff0000 +#define TX_MCOL_SHIFT_BIT 16 +#define TX_SCOL_MASK 0xffff +#define TX_SCOL_SHIFT_BIT 0 +/* TX_MCOL and TX_SCOL counter, 0xd4 */ +unsigned int txmcol_xscol; + +#define RPF_MASK 0xffff0000 +#define RPF_SHIFT_BIT 16 +#define AEP_MASK 0xffff +#define AEP_SHIFT_BIT 0 +unsigned int rpf_aep;/* RPF and AEP counter, 0xd8 */ + +#define XM_MASK 0xffff0000 +#define XM_SHIFT_BIT 16 +#define PG_MASK 0xffff +#define PG_SHIFT_BIT 0 +unsigned int xm_pg;/* XM and PG counter, 0xdc */ + +#define RUNT_CNT_MASK 0xffff0000 +#define RUNT_CNT_SHIFT_BIT 16 +#define TLCC_MASK 0xffff +#define TLCC_SHIFT_BIT 0 +/* RUNT_CNT and TLCC counter, 0xe0 */ +unsigned int runtcnt_tlcc; + +#define CRCER_CNT_MASK 0xffff0000 +#define CRCER_CNT_SHIFT_BIT 16 +#define FTL_CNT_MASK 0xffff +#define FTL_CNT_SHIFT_BIT 0 +/* CRCER_CNT and FTL_CNT counter, 0xe4 */ +unsigned int crcercnt_ftlcnt; + +#define RLC_MASK 0xffff0000drivers/net/ethernet/moxa/moxart_ether.h line 422
Quoted 10 lines
drivers/net/ethernet/moxa/moxart_ether.h new file +10
-0+#define RLC_SHIFT_BIT 16 +#define RCC_MASK 0xffff +#define RCC_SHIFT_BIT 0 +unsigned int rlc_rcc;/* RLC and RCC counter, 0xe8 */ + +unsigned int broc;/* BROC counter, 0xec */ +unsigned int mulca;/* MULCA counter, 0xf0 */ +unsigned int rp;/* RP counter, 0xf4 */ +unsigned int xp;/* XP counter, 0xf8 */ +};I don't think you can rely on the fields to be the size you expect (int is not necessarily 32 bits), and nor can you expect them to have the padding you expect (a 64 bit arch could pad ints to 64 bits). I think it would be better to just #define the offsets explicitly, which will be safe and easy to verify.
Thanks,
Mark.
Signature · 1 line
Florian
PATCH v5 1/1 net: Add MOXA ART SoCs ethernet driver
In reply to Jonas JensenThe MOXA UC-711X hardware(s) has an ethernet controller that seem to be developed internally. The IC used is "RTL8201CP".
Since there is no public documentation, this driver is mostly the one published by MOXA that has been heavily cleaned up / ported from linux 2.6.9.
---
Notes:
The flash mapped in v4 is not part of the MAC controller, leaving it to user-space per Florian and Mark's comments.
Changes since v4:
1. don't rely on structs for register offsets
2. don't map flash storage register
3. remove code related to flash storage
4. reformat header file, use single line comments
5. move devm_request_irq() earlier in probe path
6. save return values in probe fail path
7. check/handle irq_of_parse_and_map() return value
device tree bindings document:
8. remove references to flash storage register
Applies to next-20130808
.../devicetree/bindings/net/moxa,moxart-mac.txt | 21 + drivers/net/ethernet/Kconfig | 1 + drivers/net/ethernet/Makefile | 1 + drivers/net/ethernet/moxa/Kconfig | 30 ++ drivers/net/ethernet/moxa/Makefile | 5 + drivers/net/ethernet/moxa/moxart_ether.c | 559 +++++++++++++++++++++ drivers/net/ethernet/moxa/moxart_ether.h | 330 ++++++++++++ 7 files changed, 947 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/moxa,moxart-mac.txt create mode 100644 drivers/net/ethernet/moxa/Kconfig create mode 100644 drivers/net/ethernet/moxa/Makefile create mode 100644 drivers/net/ethernet/moxa/moxart_ether.c create mode 100644 drivers/net/ethernet/moxa/moxart_ether.h
Documentation/devicetree/bindings/net/moxa,moxart-mac.txt new file +21 -0
@@ -0,0 +1,21 @@ +MOXA ART Ethernet Controller + +Required properties: + +- compatible : Must be "moxa,moxart-mac" +- reg : Should contain register location and length +- interrupts : Should contain the mac interrupt number + +Example: + + mac0: mac at 90900000 { + compatible = "moxa,moxart-mac"; + reg = <0x90900000 0x100>; + interrupts = <25 0>; + }; + + mac1: mac at 92000000 { + compatible = "moxa,moxart-mac"; + reg = <0x92000000 0x100>; + interrupts = <27 0>; + };
drivers/net/ethernet/Kconfig +1 -0
@@ -90,6 +90,7 @@ source "drivers/net/ethernet/marvell/Kconfig" source "drivers/net/ethernet/mellanox/Kconfig" source "drivers/net/ethernet/micrel/Kconfig" source "drivers/net/ethernet/microchip/Kconfig" +source "drivers/net/ethernet/moxa/Kconfig" source "drivers/net/ethernet/myricom/Kconfig" config FEALNX
drivers/net/ethernet/Makefile +1 -0
@@ -42,6 +42,7 @@ obj-$(CONFIG_NET_VENDOR_MARVELL) += marvell/ obj-$(CONFIG_NET_VENDOR_MELLANOX) += mellanox/ obj-$(CONFIG_NET_VENDOR_MICREL) += micrel/ obj-$(CONFIG_NET_VENDOR_MICROCHIP) += microchip/ +obj-$(CONFIG_NET_VENDOR_MOXART) += moxa/ obj-$(CONFIG_NET_VENDOR_MYRI) += myricom/ obj-$(CONFIG_FEALNX) += fealnx.o obj-$(CONFIG_NET_VENDOR_NATSEMI) += natsemi/
drivers/net/ethernet/moxa/Kconfig new file +30 -0
@@ -0,0 +1,30 @@ +# +# MOXART device configuration +# + +config NET_VENDOR_MOXART + bool "MOXA ART devices" + default y + depends on (ARM && ARCH_MOXART) + ---help--- + If you have a network (Ethernet) card belonging to this class, say Y + and read the Ethernet-HOWTO, available from + <http://www.tldp.org/docs.html#howto>. + + Note that the answer to this question doesn't directly affect the + kernel: saying N will just cause the configurator to skip all + the questions about MOXA ART devices. If you say Y, you will be asked + for your specific card in the following questions. + +if NET_VENDOR_MOXART + +config ARM_MOXART_ETHER + tristate "MOXART Ethernet support" + depends on ARM && ARCH_MOXART + select NET_CORE + ---help--- + If you wish to compile a kernel for a hardware with MOXA ART SoC and + want to use the internal ethernet then you should answer Y to this. + + +endif # NET_VENDOR_MOXART
drivers/net/ethernet/moxa/Makefile new file +5 -0
@@ -0,0 +1,5 @@ +# +# Makefile for the MOXART network device drivers. +# + +obj-$(CONFIG_ARM_MOXART_ETHER) += moxart_ether.o
drivers/net/ethernet/moxa/moxart_ether.c new file +559 -0
559 lines not on this page · raw message
drivers/net/ethernet/moxa/moxart_ether.h new file +330 -0
330 lines not on this page · raw message
Signature · 1 line
1.8.2.1
From: Jonas Jensen <[email protected]>
Date: Thu, 8 Aug 2013 13:34:54 +0200
Quoted 8 lines
The MOXA UC-711X hardware(s) has an ethernet controller that seem to be developed internally. The IC used is "RTL8201CP".
Since there is no public documentation, this driver is mostly the one published by MOXA that has been heavily cleaned up / ported from linux 2.6.9.
Signed-off-by Jonas Jensen <[email protected]>
Applied to net-next, thanks.