Re: [PATCH 3/3] net: ethernet: add driver for Aurora VLSI NB8800 Ethernet controller
Florian Fainelliwrites: +static void nb8800_set_rx_mode(struct net_device *dev) +{ + struct nb8800_priv *priv = netdev_priv(dev); + struct netdev_hw_addr *ha; + int af_en; + + if ((dev->flags & (IFF_PROMISC | IFF_ALLMULTI)) || + netdev_mc_count(dev) > 64) >>> >>> 64, that's pretty generous for a perfect match filter, nice. >> >> That's bogus; I forgot to delete it. The hardware uses a 64-entry hash >> table, and whoever wrote the old driver apparently didn't understand how >> it works. > > Might be best to put the interface in promiscuous mode until you have > proper multicast support. Since this is for a Set-Top box chip, having > proper multicast support still seems like something highly desirable. The code below should work correctly with any number of multicast addresses. + phydev = phy_find_first(bus); + if (!phydev || phy_read(phydev, MII_BMSR) <= 0) { >>> >>> What is this additional MII_MBSR read used for? >> >> On one of my boards, phylib misdetects a phy on the second ethernet port >> even though there is none. Perhaps I should revisit that problem and >> look for a better solution. > > I think that would be best, if you are currently using the Generic PHY > driver, consider writing a specific driver which would take care of > quirky behavior. The problem is that there is no PHY, yet for some reason reading the ID registers appears to succeed. -- Måns Rullgård m...@mansr.com -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 3/3] net: ethernet: add driver for Aurora VLSI NB8800 Ethernet controller
On 23/10/15 08:20, Måns Rullgård wrote: > Florian Fainelliwrites: > >> On 22/10/15 07:02, Mans Rullgard wrote: >>> This adds a driver for the Aurora VLSI NB8800 Ethernet controller. >>> It is an almost complete rewrite of a driver originally found in >>> a Sigma Designs 2.6.22 tree. >> >> Some reviews here and there, mostly related to how you use the PHY library. > > Thanks. > >>> + nb8800_tx_dma_start(dev, next); >>> + >>> + if (!skb->xmit_more && !timer_pending(>tx_reclaim_timer)) >>> + mod_timer(>tx_reclaim_timer, jiffies + HZ / 20); >> >> You do not have a TX completion interrupt? Using a timer to reclaim TX >> buffers is really not great for latency. > > There is an interrupt, but dev_kfree_skb() can't be called from > interrupt context, and running a tasklet for each packet has too much > overhead. Someone suggested I use this approach. If there's a better > way, I'm all ears. But dev_kfree_skb_irq() works in interrupt context. Typically, what you would do, depending on your number or RX/TX queue is reclaim transmitted buffers in NAPI (softirq) context. In your case, what you could do is use the RX or TX interrupt as an indication to schedule your napi poll routine and you would cleanup TX buffers first (cheap, and makes room for RX packets) and if there are RX packets to process, process them. No need for the tasklet then. > >>> + >>> + if (atomic_read(>tx_free) <= NB8800_DESC_LOW) >>> + netif_stop_queue(dev); >>> + >>> + return NETDEV_TX_OK; >>> +} >>> + >>> +static void nb8800_tx_reclaim(unsigned long data) >>> +{ >>> + struct net_device *dev = (struct net_device *)data; >>> + struct nb8800_priv *priv = netdev_priv(dev); >>> + int packets = 0, bytes = 0; >>> + int reclaimed = 0; >>> + int dirty, limit; >>> + >>> + dirty = xchg(>tx_dirty, -1); >>> + if (dirty < 0) >>> + return; >>> + >>> + limit = priv->tx_reclaim_limit; >>> + if (dirty == limit) >>> + goto end; >>> + >>> + while (dirty != limit) { >>> + struct nb8800_dma_desc *tx = >tx_descs[dirty]; >>> + struct tx_buf *tx_buf = >tx_bufs[dirty]; >>> + struct sk_buff *skb = tx_buf->skb; >>> + struct tx_skb_data *skb_data = (struct tx_skb_data *)skb->cb; >>> + int frags = tx_buf->frags; >>> + >>> + packets++; >>> + bytes += skb->len; >>> + >>> + dma_unmap_single(>dev, skb_data->dma_addr, >>> +skb_data->dma_len, DMA_TO_DEVICE); >>> + dev_kfree_skb(skb); >>> + >>> + tx->report = 0; >>> + tx_buf->skb = NULL; >>> + tx_buf->frags = 0; >>> + >>> + dirty = (dirty + frags) & (TX_DESC_COUNT - 1); >>> + reclaimed += frags; >>> + } >>> + >>> + priv->stats.tx_packets += packets; >>> + priv->stats.tx_bytes += bytes; >>> + >>> + smp_mb__before_atomic(); >>> + atomic_add(reclaimed, >tx_free); >>> + >>> + netif_wake_queue(dev); >> >> You can only wake up your queue if you have successfully reclaimed >> transmitted buffers, otherwise this is giving false information to the >> stack that there is room to push more packets. > > The code is correct, if a bit unclear. I'll clean it up so it's obvious. That's fine as-is, I missed the goto end at the beginning. > >>> +static void nb8800_mac_config(struct net_device *dev) >>> +{ >>> + struct nb8800_priv *priv = netdev_priv(dev); >>> + >>> + if (priv->duplex) >>> + nb8800_clear_bits(b, priv, NB8800_MAC_MODE, HALF_DUPLEX); >>> + else >>> + nb8800_set_bits(b, priv, NB8800_MAC_MODE, HALF_DUPLEX); >>> + >>> + if (priv->speed == SPEED_1000) { >>> + nb8800_set_bits(b, priv, NB8800_MAC_MODE, >>> + RGMII_MODE | GMAC_MODE); >>> + nb8800_writeb(priv, NB8800_IC_THRESHOLD, 3); >> >> What is the IC_THRESHOLD value for? Is this some form of interrupt >> coalescing? If so, there is a proper ethtool interface to configure that. > > It has something to do with some clocks, and this value is quite > possibly wrong; it's what the original driver did. I'll do some tests. > >>> + nb8800_writeb(priv, NB8800_SLOT_TIME, 255); >>> + } else { >>> + nb8800_clear_bits(b, priv, NB8800_MAC_MODE, >>> + RGMII_MODE | GMAC_MODE); >>> + nb8800_writeb(priv, NB8800_IC_THRESHOLD, 1); >>> + nb8800_writeb(priv, NB8800_SLOT_TIME, 127); >> >> What about if you link at 10Mbits/sec, would the slot time value still >> make sense here? > > The documentation says the exact meaning on this register is different > between gigabit and 10/100, so using the same value for 10 and 100 makes > sense. Again, the values used here are from the original driver. Fair enough. > >>> +static void nb8800_set_rx_mode(struct net_device *dev) >>> +{ >>> + struct nb8800_priv *priv = netdev_priv(dev); >>> + struct netdev_hw_addr *ha; >>> + int af_en; >>>
Re: [PATCH 3/3] net: ethernet: add driver for Aurora VLSI NB8800 Ethernet controller
Florian Fainelliwrites: > On 22/10/15 07:02, Mans Rullgard wrote: >> This adds a driver for the Aurora VLSI NB8800 Ethernet controller. >> It is an almost complete rewrite of a driver originally found in >> a Sigma Designs 2.6.22 tree. > > Some reviews here and there, mostly related to how you use the PHY library. Thanks. >> +nb8800_tx_dma_start(dev, next); >> + >> +if (!skb->xmit_more && !timer_pending(>tx_reclaim_timer)) >> +mod_timer(>tx_reclaim_timer, jiffies + HZ / 20); > > You do not have a TX completion interrupt? Using a timer to reclaim TX > buffers is really not great for latency. There is an interrupt, but dev_kfree_skb() can't be called from interrupt context, and running a tasklet for each packet has too much overhead. Someone suggested I use this approach. If there's a better way, I'm all ears. >> + >> +if (atomic_read(>tx_free) <= NB8800_DESC_LOW) >> +netif_stop_queue(dev); >> + >> +return NETDEV_TX_OK; >> +} >> + >> +static void nb8800_tx_reclaim(unsigned long data) >> +{ >> +struct net_device *dev = (struct net_device *)data; >> +struct nb8800_priv *priv = netdev_priv(dev); >> +int packets = 0, bytes = 0; >> +int reclaimed = 0; >> +int dirty, limit; >> + >> +dirty = xchg(>tx_dirty, -1); >> +if (dirty < 0) >> +return; >> + >> +limit = priv->tx_reclaim_limit; >> +if (dirty == limit) >> +goto end; >> + >> +while (dirty != limit) { >> +struct nb8800_dma_desc *tx = >tx_descs[dirty]; >> +struct tx_buf *tx_buf = >tx_bufs[dirty]; >> +struct sk_buff *skb = tx_buf->skb; >> +struct tx_skb_data *skb_data = (struct tx_skb_data *)skb->cb; >> +int frags = tx_buf->frags; >> + >> +packets++; >> +bytes += skb->len; >> + >> +dma_unmap_single(>dev, skb_data->dma_addr, >> + skb_data->dma_len, DMA_TO_DEVICE); >> +dev_kfree_skb(skb); >> + >> +tx->report = 0; >> +tx_buf->skb = NULL; >> +tx_buf->frags = 0; >> + >> +dirty = (dirty + frags) & (TX_DESC_COUNT - 1); >> +reclaimed += frags; >> +} >> + >> +priv->stats.tx_packets += packets; >> +priv->stats.tx_bytes += bytes; >> + >> +smp_mb__before_atomic(); >> +atomic_add(reclaimed, >tx_free); >> + >> +netif_wake_queue(dev); > > You can only wake up your queue if you have successfully reclaimed > transmitted buffers, otherwise this is giving false information to the > stack that there is room to push more packets. The code is correct, if a bit unclear. I'll clean it up so it's obvious. >> +static void nb8800_mac_config(struct net_device *dev) >> +{ >> +struct nb8800_priv *priv = netdev_priv(dev); >> + >> +if (priv->duplex) >> +nb8800_clear_bits(b, priv, NB8800_MAC_MODE, HALF_DUPLEX); >> +else >> +nb8800_set_bits(b, priv, NB8800_MAC_MODE, HALF_DUPLEX); >> + >> +if (priv->speed == SPEED_1000) { >> +nb8800_set_bits(b, priv, NB8800_MAC_MODE, >> +RGMII_MODE | GMAC_MODE); >> +nb8800_writeb(priv, NB8800_IC_THRESHOLD, 3); > > What is the IC_THRESHOLD value for? Is this some form of interrupt > coalescing? If so, there is a proper ethtool interface to configure that. It has something to do with some clocks, and this value is quite possibly wrong; it's what the original driver did. I'll do some tests. >> +nb8800_writeb(priv, NB8800_SLOT_TIME, 255); >> +} else { >> +nb8800_clear_bits(b, priv, NB8800_MAC_MODE, >> + RGMII_MODE | GMAC_MODE); >> +nb8800_writeb(priv, NB8800_IC_THRESHOLD, 1); >> +nb8800_writeb(priv, NB8800_SLOT_TIME, 127); > > What about if you link at 10Mbits/sec, would the slot time value still > make sense here? The documentation says the exact meaning on this register is different between gigabit and 10/100, so using the same value for 10 and 100 makes sense. Again, the values used here are from the original driver. >> +static void nb8800_set_rx_mode(struct net_device *dev) >> +{ >> +struct nb8800_priv *priv = netdev_priv(dev); >> +struct netdev_hw_addr *ha; >> +int af_en; >> + >> +if ((dev->flags & (IFF_PROMISC | IFF_ALLMULTI)) || >> +netdev_mc_count(dev) > 64) > > 64, that's pretty generous for a perfect match filter, nice. That's bogus; I forgot to delete it. The hardware uses a 64-entry hash table, and whoever wrote the old driver apparently didn't understand how it works. >> +static void nb8800_tangox_init(struct net_device *dev) >> +{ >> +struct nb8800_priv *priv = netdev_priv(dev); >> +u32 val; >> + >> +val = nb8800_readb(priv, NB8800_TANGOX_PAD_MODE) & 0x78; >> +if (priv->phydev->supported & PHY_1000BT_FEATURES) >> +val |= 1; >> +nb8800_writeb(priv, NB8800_TANGOX_PAD_MODE,
Re: [PATCH 3/3] net: ethernet: add driver for Aurora VLSI NB8800 Ethernet controller
David Millerwrites: > From: Mans Rullgard > Date: Thu, 22 Oct 2015 15:02:38 +0100 > >> This adds a driver for the Aurora VLSI NB8800 Ethernet controller. >> It is an almost complete rewrite of a driver originally found in >> a Sigma Designs 2.6.22 tree. >> >> Signed-off-by: Mans Rullgard > > The netdev list is going to have to see patches #1 and #2 as well as > your cover letter in order to review and integrate this driver > properly. Patch 1 only added the "aurora" DT vendor prefix. Patch 2 was the DT binding for this device. I'll include netdev when I send an updated version. -- Måns Rullgård m...@mansr.com -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 3/3] net: ethernet: add driver for Aurora VLSI NB8800 Ethernet controller
Hi Mans, [auto build test WARNING on net/master -- if it's inappropriate base, please suggest rules for selecting the more suitable base] url: https://github.com/0day-ci/linux/commits/Mans-Rullgard/devicetree-add-vendor-prefix-for-Aurora-VLSI/20151022-220753 config: sparc64-allyesconfig (attached as .config) reproduce: wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree make.cross ARCH=sparc64 All warnings (new ones prefixed by >>): drivers/net/ethernet/aurora/nb8800.c: In function 'nb8800_xmit': drivers/net/ethernet/aurora/nb8800.c:381:14: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] cpsz = (8 - (u32)skb->data) & 7; ^ drivers/net/ethernet/aurora/nb8800.c: In function 'nb8800_probe': >> drivers/net/ethernet/aurora/nb8800.c:1006:2: warning: format '%x' expects >> argument of type 'unsigned int', but argument 3 has type 'resource_size_t' >> [-Wformat=] dev_info(>dev, "AU-NB8800 Ethernet at 0x%x\n", res->start); ^ vim +1006 drivers/net/ethernet/aurora/nb8800.c 990 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 991 if (!res) { 992 dev_err(>dev, "No MMIO base\n"); 993 return -EINVAL; 994 } 995 996 irq = platform_get_irq(pdev, 0); 997 if (irq <= 0) { 998 dev_err(>dev, "No IRQ\n"); 999 return -EINVAL; 1000 } 1001 1002 base = devm_ioremap_resource(>dev, res); 1003 if (IS_ERR(base)) 1004 return PTR_ERR(base); 1005 > 1006 dev_info(>dev, "AU-NB8800 Ethernet at 0x%x\n", > res->start); 1007 1008 dev = alloc_etherdev(sizeof(*priv)); 1009 if (!dev) 1010 return -ENOMEM; 1011 1012 platform_set_drvdata(pdev, dev); 1013 SET_NETDEV_DEV(dev, >dev); 1014 --- 0-DAY kernel test infrastructureOpen Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation .config.gz Description: Binary data
Re: [PATCH 3/3] net: ethernet: add driver for Aurora VLSI NB8800 Ethernet controller
On 22/10/15 07:02, Mans Rullgard wrote: > This adds a driver for the Aurora VLSI NB8800 Ethernet controller. > It is an almost complete rewrite of a driver originally found in > a Sigma Designs 2.6.22 tree. Some reviews here and there, mostly related to how you use the PHY library. [snip] > + buf->page = virt_to_head_page(data); > + buf->offset = data - page_address(buf->page); > + > + rx->s_addr = dma_map_page(>dev, buf->page, buf->offset, > + RX_BUF_SIZE, DMA_FROM_DEVICE); Missing dma_mapping_error() check here? [snip] > + dma_len = skb->len - cpsz; > + dma_addr = dma_map_single(>dev, skb->data + cpsz, > + dma_len, DMA_TO_DEVICE); Ditto, missing dma_mapping_error() check. [snip] > + nb8800_tx_dma_start(dev, next); > + > + if (!skb->xmit_more && !timer_pending(>tx_reclaim_timer)) > + mod_timer(>tx_reclaim_timer, jiffies + HZ / 20); You do not have a TX completion interrupt? Using a timer to reclaim TX buffers is really not great for latency. > + > + if (atomic_read(>tx_free) <= NB8800_DESC_LOW) > + netif_stop_queue(dev); > + > + return NETDEV_TX_OK; > +} > + > +static void nb8800_tx_reclaim(unsigned long data) > +{ > + struct net_device *dev = (struct net_device *)data; > + struct nb8800_priv *priv = netdev_priv(dev); > + int packets = 0, bytes = 0; > + int reclaimed = 0; > + int dirty, limit; > + > + dirty = xchg(>tx_dirty, -1); > + if (dirty < 0) > + return; > + > + limit = priv->tx_reclaim_limit; > + if (dirty == limit) > + goto end; > + > + while (dirty != limit) { > + struct nb8800_dma_desc *tx = >tx_descs[dirty]; > + struct tx_buf *tx_buf = >tx_bufs[dirty]; > + struct sk_buff *skb = tx_buf->skb; > + struct tx_skb_data *skb_data = (struct tx_skb_data *)skb->cb; > + int frags = tx_buf->frags; > + > + packets++; > + bytes += skb->len; > + > + dma_unmap_single(>dev, skb_data->dma_addr, > + skb_data->dma_len, DMA_TO_DEVICE); > + dev_kfree_skb(skb); > + > + tx->report = 0; > + tx_buf->skb = NULL; > + tx_buf->frags = 0; > + > + dirty = (dirty + frags) & (TX_DESC_COUNT - 1); > + reclaimed += frags; > + } > + > + priv->stats.tx_packets += packets; > + priv->stats.tx_bytes += bytes; > + > + smp_mb__before_atomic(); > + atomic_add(reclaimed, >tx_free); > + > + netif_wake_queue(dev); You can only wake up your queue if you have successfully reclaimed transmitted buffers, otherwise this is giving false information to the stack that there is room to push more packets. [snip] > +static irqreturn_t nb8800_isr(int irq, void *dev_id) > +{ > + struct net_device *dev = dev_id; > + struct nb8800_priv *priv = netdev_priv(dev); > + u32 val; > + > + /* tx interrupt */ > + val = nb8800_readl(priv, NB8800_TXC_SR); > + if (val) { > + nb8800_writel(priv, NB8800_TXC_SR, val); > + > + if (likely(val & TSR_TI)) > + nb8800_tx_done(dev); Ok, so there is a TX interrupt, so what is the timer used for? > + > + if (unlikely(val & TSR_DE)) > + netdev_err(dev, "TX DMA error\n"); > + > + if (unlikely(val & TSR_TO)) > + netdev_err(dev, "TX Status FIFO overflow\n"); > + } > + > + /* rx interrupt */ > + val = nb8800_readl(priv, NB8800_RXC_SR); > + if (val) { > + nb8800_writel(priv, NB8800_RXC_SR, val); > + > + if (likely(val & RSR_RI)) > + napi_schedule_irqoff(>napi); > + > + if (unlikely(val & RSR_DE)) > + netdev_err(dev, "RX DMA error\n"); > + > + if (unlikely(val & RSR_RO)) { > + int i; > + > + netdev_err(dev, "RX Status FIFO overflow\n"); > + > + for (i = 0; i < 4; i++) > + nb8800_readl(priv, NB8800_RX_FIFO_SR); > + } > + } > + > + /* wake on lan */ > + val = nb8800_readb(priv, NB8800_WAKEUP); > + if (val == 1) { > + nb8800_writeb(priv, NB8800_SLEEP_MODE, 0); > + nb8800_writeb(priv, NB8800_WAKEUP, 0); It is nice to account for such wake-up events by calling pm_wakeup_event(). Since you do not support configuring Wake-on-LAN yet, you might as well drop this, unless such interrupt needs to be cleared? > + } > + > + return IRQ_HANDLED; > +} > + > +static void nb8800_mac_config(struct net_device *dev) > +{ > + struct nb8800_priv *priv = netdev_priv(dev); > + > + if (priv->duplex) > + nb8800_clear_bits(b, priv, NB8800_MAC_MODE, HALF_DUPLEX); > + else > + nb8800_set_bits(b, priv, NB8800_MAC_MODE, HALF_DUPLEX); > + >
Re: [PATCH 3/3] net: ethernet: add driver for Aurora VLSI NB8800 Ethernet controller
From: Mans RullgardDate: Thu, 22 Oct 2015 15:02:38 +0100 > This adds a driver for the Aurora VLSI NB8800 Ethernet controller. > It is an almost complete rewrite of a driver originally found in > a Sigma Designs 2.6.22 tree. > > Signed-off-by: Mans Rullgard The netdev list is going to have to see patches #1 and #2 as well as your cover letter in order to review and integrate this driver properly. -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 3/3] net: ethernet: add driver for Aurora VLSI NB8800 Ethernet controller
Hi Mans, [auto build test WARNING on net/master -- if it's inappropriate base, please suggest rules for selecting the more suitable base] url: https://github.com/0day-ci/linux/commits/Mans-Rullgard/devicetree-add-vendor-prefix-for-Aurora-VLSI/20151022-220753 config: x86_64-allmodconfig (attached as .config) reproduce: # save the attached .config to linux build tree make ARCH=x86_64 All warnings (new ones prefixed by >>): drivers/net/ethernet/aurora/nb8800.c: In function 'nb8800_xmit': >> drivers/net/ethernet/aurora/nb8800.c:381:14: warning: cast from pointer to >> integer of different size [-Wpointer-to-int-cast] cpsz = (8 - (u32)skb->data) & 7; ^ In file included from include/linux/dma-mapping.h:5:0, from include/linux/skbuff.h:34, from include/linux/if_ether.h:23, from include/linux/etherdevice.h:25, from drivers/net/ethernet/aurora/nb8800.c:24: drivers/net/ethernet/aurora/nb8800.c: In function 'nb8800_probe': >> drivers/net/ethernet/aurora/nb8800.c:1006:23: warning: format '%x' expects >> argument of type 'unsigned int', but argument 3 has type 'resource_size_t >> {aka long long unsigned int}' [-Wformat=] dev_info(>dev, "AU-NB8800 Ethernet at 0x%x\n", res->start); ^ include/linux/device.h:1166:51: note: in definition of macro 'dev_info' #define dev_info(dev, fmt, arg...) _dev_info(dev, fmt, ##arg) ^ vim +381 drivers/net/ethernet/aurora/nb8800.c 365 366 static int nb8800_xmit(struct sk_buff *skb, struct net_device *dev) 367 { 368 struct nb8800_priv *priv = netdev_priv(dev); 369 struct tx_skb_data *skb_data; 370 struct tx_buf *tx_buf; 371 dma_addr_t dma_addr; 372 unsigned int dma_len; 373 int cpsz, next; 374 int frags; 375 376 if (atomic_read(>tx_free) <= NB8800_DESC_LOW) { 377 netif_stop_queue(dev); 378 return NETDEV_TX_BUSY; 379 } 380 > 381 cpsz = (8 - (u32)skb->data) & 7; 382 383 frags = cpsz ? 2 : 1; 384 atomic_sub(frags, >tx_free); 385 386 dma_len = skb->len - cpsz; 387 dma_addr = dma_map_single(>dev, skb->data + cpsz, 388dma_len, DMA_TO_DEVICE); 389 --- 0-DAY kernel test infrastructureOpen Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation .config.gz Description: Binary data
[PATCH 3/3] net: ethernet: add driver for Aurora VLSI NB8800 Ethernet controller
This adds a driver for the Aurora VLSI NB8800 Ethernet controller. It is an almost complete rewrite of a driver originally found in a Sigma Designs 2.6.22 tree. Signed-off-by: Mans Rullgard--- drivers/net/ethernet/Kconfig |1 + drivers/net/ethernet/Makefile|1 + drivers/net/ethernet/aurora/Kconfig | 20 + drivers/net/ethernet/aurora/Makefile |1 + drivers/net/ethernet/aurora/nb8800.c | 1173 ++ drivers/net/ethernet/aurora/nb8800.h | 257 6 files changed, 1453 insertions(+) create mode 100644 drivers/net/ethernet/aurora/Kconfig create mode 100644 drivers/net/ethernet/aurora/Makefile create mode 100644 drivers/net/ethernet/aurora/nb8800.c create mode 100644 drivers/net/ethernet/aurora/nb8800.h diff --git a/drivers/net/ethernet/Kconfig b/drivers/net/ethernet/Kconfig index 05aa759..8310163 100644 --- a/drivers/net/ethernet/Kconfig +++ b/drivers/net/ethernet/Kconfig @@ -29,6 +29,7 @@ source "drivers/net/ethernet/apm/Kconfig" source "drivers/net/ethernet/apple/Kconfig" source "drivers/net/ethernet/arc/Kconfig" source "drivers/net/ethernet/atheros/Kconfig" +source "drivers/net/ethernet/aurora/Kconfig" source "drivers/net/ethernet/cadence/Kconfig" source "drivers/net/ethernet/adi/Kconfig" source "drivers/net/ethernet/broadcom/Kconfig" diff --git a/drivers/net/ethernet/Makefile b/drivers/net/ethernet/Makefile index ddfc808..b435fb0 100644 --- a/drivers/net/ethernet/Makefile +++ b/drivers/net/ethernet/Makefile @@ -15,6 +15,7 @@ obj-$(CONFIG_NET_XGENE) += apm/ obj-$(CONFIG_NET_VENDOR_APPLE) += apple/ obj-$(CONFIG_NET_VENDOR_ARC) += arc/ obj-$(CONFIG_NET_VENDOR_ATHEROS) += atheros/ +obj-$(CONFIG_NET_VENDOR_AURORA) += aurora/ obj-$(CONFIG_NET_CADENCE) += cadence/ obj-$(CONFIG_NET_BFIN) += adi/ obj-$(CONFIG_NET_VENDOR_BROADCOM) += broadcom/ diff --git a/drivers/net/ethernet/aurora/Kconfig b/drivers/net/ethernet/aurora/Kconfig new file mode 100644 index 000..a3c7106 --- /dev/null +++ b/drivers/net/ethernet/aurora/Kconfig @@ -0,0 +1,20 @@ +config NET_VENDOR_AURORA + bool "Aurora VLSI devices" + help + If you have a network (Ethernet) device belonging to this class, + say Y. + + Note that the answer to this question doesn't directly affect the + kernel: saying N will just cause the configurator to skip all + questions about Aurora devices. If you say Y, you will be asked + for your specific device in the following questions. + +if NET_VENDOR_AURORA + +config AURORA_NB8800 + tristate "Aurora AU-NB8800 support" + select PHYLIB + help +Support for the AU-NB8800 gigabit Ethernet controller. + +endif diff --git a/drivers/net/ethernet/aurora/Makefile b/drivers/net/ethernet/aurora/Makefile new file mode 100644 index 000..6cb528a --- /dev/null +++ b/drivers/net/ethernet/aurora/Makefile @@ -0,0 +1 @@ +obj-$(CONFIG_AURORA_NB8800) += nb8800.o diff --git a/drivers/net/ethernet/aurora/nb8800.c b/drivers/net/ethernet/aurora/nb8800.c new file mode 100644 index 000..aeebc2f --- /dev/null +++ b/drivers/net/ethernet/aurora/nb8800.c @@ -0,0 +1,1173 @@ +/* + * Copyright (C) 2015 Mans Rullgard + * + * Mostly rewritten, based on driver from Sigma Designs. Original + * copyright notice below. + * + * + * Driver for tangox SMP864x/SMP865x/SMP867x/SMP868x builtin Ethernet Mac. + * + * Copyright (C) 2005 Maxime Bizon + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "nb8800.h" + +static void nb8800_tx_reclaim(unsigned long data); + +static inline u8 nb8800_readb(struct nb8800_priv *priv, int reg) +{ + return readb(priv->base + reg); +} + +static inline u32 nb8800_readl(struct nb8800_priv *priv, int reg) +{ + return readl(priv->base + reg); +} + +static inline void nb8800_writeb(struct nb8800_priv *priv, int reg, u8 val) +{ + writeb(val, priv->base + reg); +} + +static inline void nb8800_writew(struct nb8800_priv *priv, int reg, u16 val) +{ + writew(val, priv->base + reg); +} + +static inline void nb8800_writel(struct nb8800_priv *priv, int reg, u32 val) +{ + writel(val, priv->base + reg); +} + +#define nb8800_set_bits(sz, priv, reg, bits) do { \ + u32 __o = nb8800_read##sz(priv, reg); \ +