net: ethernet: add driver for Aurora VLSI NB8800 Ethernet controller
Subsystems (2)
PATCH v8 1/1 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.
---
Changes:
- make some variables unsigned
--- 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 | 1552 ++++++++++++++++++++++++++++++++++ drivers/net/ethernet/aurora/nb8800.h | 316 +++++++ 6 files changed, 1891 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
drivers/net/ethernet/Kconfig +1 -0
@@ -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"
drivers/net/ethernet/Makefile +1 -0
@@ -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/
drivers/net/ethernet/aurora/Kconfig new file +20 -0
@@ -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
drivers/net/ethernet/aurora/Makefile new file +1 -0
@@ -0,0 +1 @@ +obj-$(CONFIG_AURORA_NB8800) += nb8800.o
drivers/net/ethernet/aurora/nb8800.c new file +1552 -0
1,552 lines not on this page · raw message
drivers/net/ethernet/aurora/nb8800.h new file +316 -0
316 lines not on this page · raw message
Signature · 1 line
2.6.3
From: Mans Rullgard <[email protected]>
Date: Thu, 19 Nov 2015 13:02:59 +0000
Quoted 5 lines
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 <[email protected]>
Applied, thank you.
drivers/net/ethernet/aurora/nb8800.c line 221
Quoted 4 lines · Mans Rullgard
drivers/net/ethernet/aurora/nb8800.c new file +4
-0+if (dma_mapping_error (&dev->dev, dma_addr)) { +skb_free_frag (data); +return -ENOMEM ; + }
I'm back-porting this driver to 4.1
skb_free_frag() was introduced in 4.2 by 181edb2bfa22b IIUC.
+static inline void skb_free_frag(void *addr)
+{
+ __free_page_frag(addr);
+}
Should I just copy the definition of __free_page_frag() ?
/*
* Frees a page fragment allocated out of either a compound or order 0 page. */
void __free_page_frag(void *addr)
{
struct page *page = virt_to_head_page(addr);
if (unlikely(put_page_testzero(page)))
__free_pages_ok(page, compound_order(page));
}Regards.
Quoted 16 lines · Mason
drivers/net/ethernet/aurora/nb8800.c line 221
Quoted 4 lines · Mans Rullgard
drivers/net/ethernet/aurora/nb8800.c new file +4
-0+if (dma_mapping_error (&dev->dev, dma_addr)) { +skb_free_frag (data); +return -ENOMEM ; + }I'm back-porting this driver to 4.1
skb_free_frag()was introduced in 4.2 by181edb2bfa22bIIUC.drivers/net/ethernet/aurora/nb8800.c new file +4
-0+static inline void skb_free_frag (void *addr) +{ +__free_page_frag (addr); +}
Quoted 1 line
Should I just copy the definition of
__free_page_frag()?
Looks like it ought to work. Try and find out. Not that you'll ever hit that error condition unless you fake it.
Quoted 13 lines
/*
* Frees a page fragment allocated out of either a compound or order 0 page. */
void__free_page_frag(void *addr){ struct page *page = virt_to_head_page(addr); if (unlikely(put_page_testzero(page))) __free_pages_ok(page, compound_order(page)); }Regards.
Signature · 2 lines
Måns Rullgård [email protected]
Quoted 18 lines · Måns Rullgård
Quoted 16 lines · Mason
drivers/net/ethernet/aurora/nb8800.c line 221
Quoted 4 lines · Mans Rullgard
drivers/net/ethernet/aurora/nb8800.c new file +4
-0+if (dma_mapping_error (&dev->dev, dma_addr)) { +skb_free_frag (data); +return -ENOMEM ; + }I'm back-porting this driver to 4.1
skb_free_frag()was introduced in 4.2 by181edb2bfa22bIIUC.drivers/net/ethernet/aurora/nb8800.c new file +4
-0+static inline void skb_free_frag (void *addr) +{ +__free_page_frag (addr); +}
Quoted 4 lines
Quoted 1 line
Should I just copy the definition of
__free_page_frag()?Looks like it ought to work. Try and find out. Not that you'll ever hit that error condition unless you fake it.
Turns out __free_pages_ok() is static and I'd rather not touch mm/page_alloc.c in my back-port.
Since you say the error condition is rare, I think I'll go with the code that 181edb2bfa22b replaced (put_page, IIUC).
#include <linux/version.h>
#if LINUX_VERSION_CODE < KERNEL_VERSION(4,2,0) #define skb_free_frag(data) put_page(virt_to_head_page(data)) #else
#error DELETE ME NOW (see commit 181edb2bfa22b) #endif
Alexander, does that look correct?
Regards.
Quoted 31 lines · Mason
Quoted 18 lines · Måns Rullgård
Quoted 16 lines · Mason
drivers/net/ethernet/aurora/nb8800.c line 221
Quoted 4 lines · Mans Rullgard
drivers/net/ethernet/aurora/nb8800.c new file +4
-0+if (dma_mapping_error (&dev->dev, dma_addr)) { +skb_free_frag (data); +return -ENOMEM ; + }I'm back-porting this driver to 4.1
skb_free_frag()was introduced in 4.2 by181edb2bfa22bIIUC.drivers/net/ethernet/aurora/nb8800.c new file +4
-0+static inline void skb_free_frag (void *addr) +{ +__free_page_frag (addr); +}Quoted 4 lines
Quoted 1 line
Should I just copy the definition of
__free_page_frag()?Looks like it ought to work. Try and find out. Not that you'll ever hit that error condition unless you fake it.
Turns out
__free_pages_ok()is static and I'd rather not touchmm/page_alloc.cin my back-port.Since you say the error condition is rare, I think I'll go with the code that
181edb2bfa22breplaced (put_page, IIUC).
Quoted 6 lines
#include <
linux/version.h>
#ifLINUX_VERSION_CODE<KERNEL_VERSION(4,2,0)#defineskb_free_frag(data)put_page(virt_to_head_page(data)) #else
#error DELETE ME NOW (see commit181edb2bfa22b) #endif
You can simply put_page(page) instead since we already have the virt_to_head_page() a few lines up.
Signature · 2 lines
Måns Rullgård [email protected]
Quoted 40 lines · Måns Rullgård
Quoted 31 lines · Mason
Quoted 18 lines · Måns Rullgård
Quoted 16 lines · Mason
drivers/net/ethernet/aurora/nb8800.c line 221
Quoted 4 lines · Mans Rullgard
drivers/net/ethernet/aurora/nb8800.c new file +4
-0+if (dma_mapping_error (&dev->dev, dma_addr)) { +skb_free_frag (data); +return -ENOMEM ; + }I'm back-porting this driver to 4.1
skb_free_frag()was introduced in 4.2 by181edb2bfa22bIIUC.drivers/net/ethernet/aurora/nb8800.c new file +4
-0+static inline void skb_free_frag (void *addr) +{ +__free_page_frag (addr); +}Quoted 4 lines
Quoted 1 line
Should I just copy the definition of
__free_page_frag()?Looks like it ought to work. Try and find out. Not that you'll ever hit that error condition unless you fake it.
Turns out
__free_pages_ok()is static and I'd rather not touchmm/page_alloc.cin my back-port.Since you say the error condition is rare, I think I'll go with the code that
181edb2bfa22breplaced (put_page, IIUC).Quoted 6 lines
#include <
linux/version.h>
#ifLINUX_VERSION_CODE<KERNEL_VERSION(4,2,0)#defineskb_free_frag(data)put_page(virt_to_head_page(data)) #else
#error DELETE ME NOW (see commit181edb2bfa22b) #endif
Quoted 2 lines
You can simply
put_page(page)instead since we already have thevirt_to_head_page()a few lines up.
What you could do is use __free_pages instead of __free_pages_ok. Generally you will want to use __free_pages instead of put_page just to avoid a bunch of unnecessary tests and function pointer accesses.
The result would look something like:
static inline void skb_free_frag(void *addr)
{
struct page *page = virt_to_head_page(addr);
__free_pages(page, compound_order(page));
}Hope that helps.
- Alex
Quoted 41 lines · Alexander Duyck
Quoted 40 lines · Måns Rullgård
Quoted 37 lines · Mason
Quoted 18 lines · Måns Rullgård
Quoted 16 lines · Mason
drivers/net/ethernet/aurora/nb8800.c line 221
Quoted 4 lines · Mans Rullgard
drivers/net/ethernet/aurora/nb8800.c new file +4
-0+if (dma_mapping_error (&dev->dev, dma_addr)) { +skb_free_frag (data); +return -ENOMEM ; + }I'm back-porting this driver to 4.1
skb_free_frag()was introduced in 4.2 by181edb2bfa22bIIUC.drivers/net/ethernet/aurora/nb8800.c new file +4
-0+static inline void skb_free_frag (void *addr) +{ +__free_page_frag (addr); +}Quoted 4 lines
Quoted 1 line
Should I just copy the definition of
__free_page_frag()?Looks like it ought to work. Try and find out. Not that you'll ever hit that error condition unless you fake it.
Turns out
__free_pages_ok()is static and I'd rather not touchmm/page_alloc.cin my back-port.Since you say the error condition is rare, I think I'll go with the code that
181edb2bfa22breplaced (put_page, IIUC).#include <
linux/version.h>
#ifLINUX_VERSION_CODE<KERNEL_VERSION(4,2,0)#defineskb_free_frag(data)put_page(virt_to_head_page(data)) #else
#error DELETE ME NOW (see commit181edb2bfa22b) #endif
Quoted 6 lines
Quoted 2 lines
You can simply
put_page(page)instead since we already have thevirt_to_head_page()a few lines up.What you could do is use
__free_pagesinstead of__free_pages_ok. Generally you will want to use__free_pagesinstead ofput_pagejust to avoid a bunch of unnecessary tests and function pointer accesses.
Note that this is on a should-never-happen error path, so there's no need to be counting cycles.
Signature · 2 lines
Måns Rullgård [email protected]
Quoted 47 lines · Måns Rullgård
Quoted 45 lines · Alexander Duyck
Quoted 42 lines · Måns Rullgård
Quoted 31 lines · Mason
Quoted 18 lines · Måns Rullgård
Quoted 16 lines · Mason
Review
Quoted 4 lines · Mans Rullgard
(quoted diff) +4
-0+ if (dma_mapping_error(&dev->dev, dma_addr)) { + skb_free_frag(data); + return -ENOMEM; + }I'm back-porting this driver to 4.1
skb_free_frag()was introduced in 4.2 by181edb2bfa22bIIUC.(quoted diff) +4
-0+static inline void skb_free_frag(void *addr) +{ + __free_page_frag(addr); +}Quoted 4 lines
Quoted 1 line
Should I just copy the definition of
__free_page_frag()?Looks like it ought to work. Try and find out. Not that you'll ever hit that error condition unless you fake it.
Turns out
__free_pages_ok()is static and I'd rather not touchmm/page_alloc.cin my back-port.Since you say the error condition is rare, I think I'll go with the code that
181edb2bfa22breplaced (put_page, IIUC).Quoted 6 lines
#include <
linux/version.h>
#ifLINUX_VERSION_CODE<KERNEL_VERSION(4,2,0)#defineskb_free_frag(data)put_page(virt_to_head_page(data)) #else
#error DELETE ME NOW (see commit181edb2bfa22b) #endifYou can simply
put_page(page)instead since we already have thevirt_to_head_page()a few lines up.
Quoted 6 lines
Quoted 3 lines
What you could do is use
__free_pagesinstead of__free_pages_ok. Generally you will want to use__free_pagesinstead ofput_pagejust to avoid a bunch of unnecessary tests and function pointer accesses.Note that this is on a should-never-happen error path, so there's no need to be counting cycles.
Per Mans' advice, I have locally committed this patch:
drivers/net/ethernet/aurora/nb8800.c +7 -0
@@ -39,6 +39,13 @@#include "nb8800.h" +#include <linux/version.h> +#if LINUX_VERSION_CODE <KERNEL_VERSION (4 ,2 ,0 ) +#define skb_free_frag (data) put_page(page) +#else +#error DELETE ME NOW (see commit 181edb2bfa22) +#endif +static void nb8800_tx_done (struct net_device *dev);static int nb8800_dma_stop (struct net_device *dev);
Regards.
Quoted 65 lines · Mason
Quoted 47 lines · Måns Rullgård
Quoted 45 lines · Alexander Duyck
Quoted 42 lines · Måns Rullgård
Quoted 31 lines · Mason
Quoted 18 lines · Måns Rullgård
Quoted 16 lines · Mason
Review
Quoted 4 lines · Mans Rullgard
(quoted diff) +4
-0+ if (dma_mapping_error(&dev->dev, dma_addr)) { + skb_free_frag(data); + return -ENOMEM; + }I'm back-porting this driver to 4.1
skb_free_frag()was introduced in 4.2 by181edb2bfa22bIIUC.(quoted diff) +4
-0+static inline void skb_free_frag(void *addr) +{ + __free_page_frag(addr); +}Quoted 4 lines
Quoted 1 line
Should I just copy the definition of
__free_page_frag()?Looks like it ought to work. Try and find out. Not that you'll ever hit that error condition unless you fake it.
Turns out
__free_pages_ok()is static and I'd rather not touchmm/page_alloc.cin my back-port.Since you say the error condition is rare, I think I'll go with the code that
181edb2bfa22breplaced (put_page, IIUC).Quoted 6 lines
#include <
linux/version.h>
#ifLINUX_VERSION_CODE<KERNEL_VERSION(4,2,0)#defineskb_free_frag(data)put_page(virt_to_head_page(data)) #else
#error DELETE ME NOW (see commit181edb2bfa22b) #endifYou can simply
put_page(page)instead since we already have thevirt_to_head_page()a few lines up.Quoted 6 lines
Quoted 3 lines
What you could do is use
__free_pagesinstead of__free_pages_ok. Generally you will want to use__free_pagesinstead ofput_pagejust to avoid a bunch of unnecessary tests and function pointer accesses.Note that this is on a should-never-happen error path, so there's no need to be counting cycles.
Per Mans' advice, I have locally committed this patch:
drivers/net/ethernet/aurora/nb8800.c +0
-0@@ -39,6 +39,13 @@#include "nb8800.h"
drivers/net/ethernet/aurora/nb8800.c line 50
Quoted 10 lines
drivers/net/ethernet/aurora/nb8800.c +7
-0+#include <linux/version.h> +#if LINUX_VERSION_CODE <KERNEL_VERSION (4 ,2 ,0 ) +#define skb_free_frag (data) put_page(page) +#else +#error DELETE ME NOW (see commit 181edb2bfa22) +#endif +static void nb8800_tx_done (struct net_device *dev);static int nb8800_dma_stop (struct net_device *dev);
That works only by accident due to how local variables are named. If you want a macro to emulate the new function, your first suggestion is better. I thought you were going to change the actual function.
Signature · 2 lines
Måns Rullgård [email protected]
[ Using different address for Alexander ]
Quoted 28 lines · Mason
drivers/net/ethernet/aurora/nb8800.c line 221
Quoted 4 lines · Mans Rullgard
drivers/net/ethernet/aurora/nb8800.c new file +4
-0+if (dma_mapping_error (&dev->dev, dma_addr)) { +skb_free_frag (data); +return -ENOMEM ; + }I'm back-porting this driver to 4.1
skb_free_frag()was introduced in 4.2 by181edb2bfa22bIIUC.drivers/net/ethernet/aurora/nb8800.c new file +4
-0+static inline void skb_free_frag (void *addr) +{ +__free_page_frag (addr); +}Should I just copy the definition of
__free_page_frag()?/*
* Frees a page fragment allocated out of either a compound or order 0 page. */
void__free_page_frag(void *addr){ struct page *page = virt_to_head_page(addr); if (unlikely(put_page_testzero(page))) __free_pages_ok(page, compound_order(page)); }