Re: [PATCH net-next 2/2 v10] net: ethernet: Add a driver for Gemini gigabit ethernet

2018-01-10 Thread Linus Walleij
On Wed, Jan 10, 2018 at 9:43 PM, David Miller  wrote:

> Actually I had to revert these two patches, this stuff doesn't even
> build.

Sorry about that, I did build it before sending out but I guess not on enough
architectures :(

I will iterate with the help of the zeroday build servers, my own machines
just don't suffice.

Yours,
Linus Walleij


Re: [PATCH net-next 2/2 v10] net: ethernet: Add a driver for Gemini gigabit ethernet

2018-01-10 Thread David Miller

Actually I had to revert these two patches, this stuff doesn't even
build.

[davem@dhcp-10-15-49-227 net-next]$ make -s -j16
In file included from ./include/linux/printk.h:329:0,
 from ./include/linux/kernel.h:14,
 from ./include/linux/list.h:9,
 from ./include/linux/module.h:9,
 from drivers/net/ethernet/cortina/gemini.c:16:
drivers/net/ethernet/cortina/gemini.c: In function ‘geth_freeq_alloc_map_page’:
drivers/net/ethernet/cortina/gemini.c:821:21: warning: format ‘%x’ expects 
argument of type ‘unsigned int’, but argument 5 has type ‘dma_addr_t {aka long 
long unsigned int}’ [-Wformat=]
  dev_dbg(geth->dev, "page %d, DMA addr: %08x, page %p\n",
 ^
./include/linux/dynamic_debug.h:135:39: note: in definition of macro 
‘dynamic_dev_dbg’
   __dynamic_dev_dbg(, dev, fmt, \
   ^~~
drivers/net/ethernet/cortina/gemini.c:821:2: note: in expansion of macro 
‘dev_dbg’
  dev_dbg(geth->dev, "page %d, DMA addr: %08x, page %p\n",
  ^~~
drivers/net/ethernet/cortina/gemini.c: In function ‘gmac_rx’:
drivers/net/ethernet/cortina/gemini.c:1410:50: warning: format ‘%x’ expects 
argument of type ‘unsigned int’, but argument 3 has type ‘dma_addr_t {aka long 
long unsigned int}’ [-Wformat=]
dev_err(geth->dev, "could not find mapping %08x (page = %08x, page off = 
%08x)\n",
   ~~~^
   %08llx
drivers/net/ethernet/cortina/gemini.c:1410:63: warning: format ‘%x’ expects 
argument of type ‘unsigned int’, but argument 4 has type ‘long long unsigned 
int’ [-Wformat=]
dev_err(geth->dev, "could not find mapping %08x (page = %08x, page off = 
%08x)\n",
~~~^
%08llx
drivers/net/ethernet/cortina/gemini.c: In function ‘gemini_ethernet_port_probe’:
drivers/net/ethernet/cortina/gemini.c:2456:28: warning: format ‘%x’ expects 
argument of type ‘unsigned int’, but argument 4 has type ‘resource_size_t {aka 
long long unsigned int}’ [-Wformat=]
"irq %d, DMA @ 0x%08x, GMAC @ 0x%08x\n",
 ~~~^
 %08llx
port->irq, dmares->start,
   ~
drivers/net/ethernet/cortina/gemini.c:2456:43: warning: format ‘%x’ expects 
argument of type ‘unsigned int’, but argument 5 has type ‘resource_size_t {aka 
long long unsigned int}’ [-Wformat=]
"irq %d, DMA @ 0x%08x, GMAC @ 0x%08x\n",
~~~^
%08llx
drivers/net/ethernet/cortina/gemini.c:2458:8:
gmacres->start);
~~  
In file included from drivers/net/ethernet/cortina/gemini.c:16:0:
drivers/net/ethernet/cortina/gemini.c: At top level:
./include/linux/module.h:129:42: error: redefinition of ‘__inittest’
  static inline initcall_t __maybe_unused __inittest(void)  \
  ^
./include/linux/device.h:1513:1: note: in expansion of macro ‘module_init’
 module_init(__driver##_init); \
 ^~~
./include/linux/platform_device.h:228:2: note: in expansion of macro 
‘module_driver’
  module_driver(__platform_driver, platform_driver_register, \
  ^
drivers/net/ethernet/cortina/gemini.c:2567:1: note: in expansion of macro 
‘module_platform_driver’
 module_platform_driver(gemini_ethernet_driver);
 ^~
./include/linux/module.h:129:42: note: previous definition of ‘__inittest’ was 
here
  static inline initcall_t __maybe_unused __inittest(void)  \
  ^
./include/linux/device.h:1513:1: note: in expansion of macro ‘module_init’
 module_init(__driver##_init); \
 ^~~
./include/linux/platform_device.h:228:2: note: in expansion of macro 
‘module_driver’
  module_driver(__platform_driver, platform_driver_register, \
  ^
drivers/net/ethernet/cortina/gemini.c:2495:1: note: in expansion of macro 
‘module_platform_driver’
 module_platform_driver(gemini_ethernet_port_driver);
 ^~
./include/linux/module.h:131:6: error: redefinition of ‘init_module’
  int init_module(void) __attribute__((alias(#initfn)));
  ^
./include/linux/device.h:1513:1: note: in expansion of macro ‘module_init’
 module_init(__driver##_init); \
 ^~~
./include/linux/platform_device.h:228:2: note: in expansion of macro 
‘module_driver’
  module_driver(__platform_driver, platform_driver_register, \
  ^
drivers/net/ethernet/cortina/gemini.c:2567:1: note: in expansion of macro 
‘module_platform_driver’
 module_platform_driver(gemini_ethernet_driver);
 ^~
./include/linux/module.h:131:6: note: previous definition of ‘init_module’ was 
here
  int init_module(void) __attribute__((alias(#initfn)));
  ^
./include/linux/device.h:1513:1: note: in 

Re: [PATCH net-next 2/2 v10] net: ethernet: Add a driver for Gemini gigabit ethernet

2018-01-10 Thread David Miller
From: Linus Walleij 
Date: Tue,  9 Jan 2018 23:10:53 +0100

> The Gemini ethernet has been around for years as an out-of-tree
> patch used with the NAS boxen and routers built on StorLink
> SL3512 and SL3516, later Storm Semiconductor, later Cortina
> Systems. These ASICs are still being deployed and brand new
> off-the-shelf systems using it can easily be acquired.
> 
> The full name of the IP block is "Net Engine and Gigabit
> Ethernet MAC" commonly just called "GMAC".
> 
> The hardware block contains a common TCP Offload Enginer (TOE)
> that can be used by both MACs. The current driver does not use
> it.
> 
> Cc: Tobias Waldvogel 
> Signed-off-by: Michał Mirosław 
> Signed-off-by: Linus Walleij 

Applied.


[PATCH net-next 2/2 v10] net: ethernet: Add a driver for Gemini gigabit ethernet

2018-01-09 Thread Linus Walleij
The Gemini ethernet has been around for years as an out-of-tree
patch used with the NAS boxen and routers built on StorLink
SL3512 and SL3516, later Storm Semiconductor, later Cortina
Systems. These ASICs are still being deployed and brand new
off-the-shelf systems using it can easily be acquired.

The full name of the IP block is "Net Engine and Gigabit
Ethernet MAC" commonly just called "GMAC".

The hardware block contains a common TCP Offload Enginer (TOE)
that can be used by both MACs. The current driver does not use
it.

Cc: Tobias Waldvogel 
Signed-off-by: Michał Mirosław 
Signed-off-by: Linus Walleij 
---
Changes from v9:
- Get rid of dma_to_pfn() when looking up pages from their
  physical address.
- Replace the freeq_page_tab with a linear array of page
  pointers and mapping info that can be searched backwards
  to find the corresponding page for a mapping that comes
  in from the hardware.
- Drop the lock around resizing the queue after disabling
  IRQs: the lock should just protect these registers anyway.

Changes from v8:
- Remove dependency guards in Kconfig to get a wider compile
  coverage for the driver to detect broken APIs etc.

Changes from v7:
- Dropped all the typedefs and use structs and unions
  directly in the code.
- Pile all local variables in inverse christmas-tree descending
  order. Rewrite code and move assignments to make this strict.
- Cut the uppercase type names in the process.
- Drop a whole bunch of unused unions and types. If we want to
  unionize these registers when we add functioality then do so
  later.
- Do not disallow mapping 0 however unlikely.
- Do not issue any nasty BUG_ON() for unaligned allocations, but
  fail gracefully instead.
- Update stats on linearized TX fragments even if mapping fails.
- Update RX stats on the (rare) failed SKB from NAPI frags too.
- Set up the mask correctly in the IFF_ALLMULTI RX mode case.
- Pick up the DT node name changes.
- Fix up a bunch of typing: explicit unsigned int, switch to
  u32 where we certainly deal with that.
- Drop a whole slew of pointless unlikely() markups.
- Fix some UTF-8 flunky.
- Fixed a few thousand checkpatch errors/warnings. Kept a very
  few select ones I didn't find reasonable.

Changes from v6:
- Drop all arch support code using the old board files.
- Adapted for device tree probing
- Getting all resources using devm_* accessors where applicable
- Split in parent ethernet device and two per-port devices
  that get spawn from the parent. This is necessary with
  device tree and other aspects of the PHY device model and
  device tree structure that requires a 1:1 mapping between
  a device and PHY to work properly.
- Grab clocks and reset handles as resources from the clock
  and reset subsystems infrastructure instead of open coding
  access to system devices.
- Let the pin control subsystem deal with setting up the
  multplexing and clock skew/delay settings of the RGMII
  lines.
- A separate SoC driver was created to deal with setting up
  bus arbitration and will be merged separately.
- Tested with the D-Link DNS-313 NAS box with a Realtek RTL8211B
  transciever.
- Rename and move code around to fit better with the new device
  handling with a top level device and two children.
- Order code as net vendor Cortina and adapter Gemini. We have
  confirmed with Faraday that this network device is not from
  them (which was initially suspected).
- Rebased onto v4.15-rc1

Changes from v5:
 - merge arch setup code into the patch
 - move platform data include to include/linux/platform_data/gemini_gmac.h
 - use new hw_features instead of ethtool_ops for offload setting
 - add some #ifdefs for build testing on other arches
 - a bit of cleanups

Changes from v4:
 - rebased on upcoming 2.6.38 (removal of page_to_dma() and per-txq stats)
 - removed setting last_rx and trans_start as that's handled by net core
 - changed __raw_read/writel() to read/writel()
 - added setting of AHB_WEIGHT register (didn't improve anything, I'm afraid)
 - fixed DMA unmapping bug
 - added limit of packet size for TX offload (HW checks only 13 bits of 
mtu_size field)
 - reduced RX_MAX_ALLOC_ORDER as it caused a lot of order 4 allocation failures
   under load
 - cleanups

Changes from v3:
 - fixed remaining tx_queue_len misuse bugs
 - bulk RX DMA page map/unmap
 - whitespace changes to make checkpatch happier (please ignore remaining
   complaints - long lines in .c and typedefs/whitespace/long lines in .h)

Changes from v2:
 - converted to page buffers and napi_gro_frags()
 - later IRQ acking and NAPI exits
 - larger rings by default
 - tx-interrupt coalescing
 - MTU changing
 - jumbo frames support
 - ringparam and coalesce settings via ethtool
 - more fixes/cleanups

Changes from v1:
 - fixed stats (now using u64_stats_sync; no-op on UP anyway)
 - pre-load mdio-gpio if built as module
 - disable TX checksum offload by default (unreliable HW)
 -