diff mbox series

[net-next,7/7] net: korina: Make driver COMPILE_TESTable

Message ID 20210413204818.23350-8-tsbogend@alpha.franken.de (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series net: Korina improvements | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for net-next
netdev/subject_prefix success Link
netdev/cc_maintainers warning 7 maintainers not CCed: rppt@kernel.org vvidic@valentin-vidic.from.hr cristian.ciocaltea@gmail.com akpm@linux-foundation.org masahiroy@kernel.org vincent.stehle@laposte.net arnd@arndb.de
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit fail Errors and warnings before: 0 this patch: 6
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 269 lines checked
netdev/build_allmodconfig_warn fail Errors and warnings before: 0 this patch: 20
netdev/header_inline success Link

Commit Message

Thomas Bogendoerfer April 13, 2021, 8:48 p.m. UTC
Move structs/defines for ethernet/dma register into driver, since they
are only used for this driver and remove any MIPS specific includes.
This makes it possible to COMPILE_TEST the driver.

Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
---
 drivers/net/ethernet/Kconfig  |   2 +-
 drivers/net/ethernet/korina.c | 245 ++++++++++++++++++++++++++++++++--
 2 files changed, 236 insertions(+), 11 deletions(-)

Comments

kernel test robot April 14, 2021, 2:06 a.m. UTC | #1
Hi Thomas,

I love your patch! Perhaps something to improve:

[auto build test WARNING on net-next/master]

url:    https://github.com/0day-ci/linux/commits/Thomas-Bogendoerfer/net-Korina-improvements/20210414-045102
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git 8ef7adc6beb2ef0bce83513dc9e4505e7b21e8c2
config: sparc-allyesconfig (attached as .config)
compiler: sparc64-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/c92cee3d78d891046f2668b2d82c375899d387a4
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Thomas-Bogendoerfer/net-Korina-improvements/20210414-045102
        git checkout c92cee3d78d891046f2668b2d82c375899d387a4
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=sparc 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   drivers/net/ethernet/korina.c: In function 'korina_rx':
>> drivers/net/ethernet/korina.c:675:10: warning: conversion from 'long unsigned int' to 'u32' {aka 'unsigned int'} changes value from '18446744073709551613' to '4294967293' [-Woverflow]
     675 |   writel(~DMA_STAT_DONE, &lp->rx_dma_regs->dmas);
   drivers/net/ethernet/korina.c:681:10: warning: conversion from 'long unsigned int' to 'u32' {aka 'unsigned int'} changes value from '18446744073709551591' to '4294967271' [-Woverflow]
     681 |   writel(~(DMA_STAT_HALT | DMA_STAT_ERR),
         |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


vim +675 drivers/net/ethernet/korina.c

ef11291bcd5f96 drivers/net/korina.c          Florian Fainelli    2008-03-19  586  
ef11291bcd5f96 drivers/net/korina.c          Florian Fainelli    2008-03-19  587  static int korina_rx(struct net_device *dev, int limit)
ef11291bcd5f96 drivers/net/korina.c          Florian Fainelli    2008-03-19  588  {
ef11291bcd5f96 drivers/net/korina.c          Florian Fainelli    2008-03-19  589  	struct korina_private *lp = netdev_priv(dev);
ef11291bcd5f96 drivers/net/korina.c          Florian Fainelli    2008-03-19  590  	struct dma_desc *rd = &lp->rd_ring[lp->rx_next_done];
ef11291bcd5f96 drivers/net/korina.c          Florian Fainelli    2008-03-19  591  	struct sk_buff *skb, *skb_new;
4cf83b664fc14f drivers/net/korina.c          Phil Sutter         2009-01-14  592  	u32 devcs, pkt_len, dmas;
69e8eeb0eae052 drivers/net/ethernet/korina.c Thomas Bogendoerfer 2021-04-13  593  	dma_addr_t ca;
ef11291bcd5f96 drivers/net/korina.c          Florian Fainelli    2008-03-19  594  	int count;
ef11291bcd5f96 drivers/net/korina.c          Florian Fainelli    2008-03-19  595  
ef11291bcd5f96 drivers/net/korina.c          Florian Fainelli    2008-03-19  596  	for (count = 0; count < limit; count++) {
4cf83b664fc14f drivers/net/korina.c          Phil Sutter         2009-01-14  597  		skb = lp->rx_skb[lp->rx_next_done];
4cf83b664fc14f drivers/net/korina.c          Phil Sutter         2009-01-14  598  		skb_new = NULL;
ef11291bcd5f96 drivers/net/korina.c          Florian Fainelli    2008-03-19  599  
ef11291bcd5f96 drivers/net/korina.c          Florian Fainelli    2008-03-19  600  		devcs = rd->devcs;
ef11291bcd5f96 drivers/net/korina.c          Florian Fainelli    2008-03-19  601  
4cf83b664fc14f drivers/net/korina.c          Phil Sutter         2009-01-14  602  		if ((KORINA_RBSIZE - (u32)DMA_COUNT(rd->control)) == 0)
4cf83b664fc14f drivers/net/korina.c          Phil Sutter         2009-01-14  603  			break;
4cf83b664fc14f drivers/net/korina.c          Phil Sutter         2009-01-14  604  
69e8eeb0eae052 drivers/net/ethernet/korina.c Thomas Bogendoerfer 2021-04-13  605  		ca = rd->ca;
69e8eeb0eae052 drivers/net/ethernet/korina.c Thomas Bogendoerfer 2021-04-13  606  
364a97f5d1ae31 drivers/net/ethernet/korina.c Roman Yeryomin      2017-09-17  607  		/* check that this is a whole packet
364a97f5d1ae31 drivers/net/ethernet/korina.c Roman Yeryomin      2017-09-17  608  		 * WARNING: DMA_FD bit incorrectly set
364a97f5d1ae31 drivers/net/ethernet/korina.c Roman Yeryomin      2017-09-17  609  		 * in Rc32434 (errata ref #077) */
364a97f5d1ae31 drivers/net/ethernet/korina.c Roman Yeryomin      2017-09-17  610  		if (!(devcs & ETH_RX_LD))
364a97f5d1ae31 drivers/net/ethernet/korina.c Roman Yeryomin      2017-09-17  611  			goto next;
364a97f5d1ae31 drivers/net/ethernet/korina.c Roman Yeryomin      2017-09-17  612  
364a97f5d1ae31 drivers/net/ethernet/korina.c Roman Yeryomin      2017-09-17  613  		if (!(devcs & ETH_RX_ROK)) {
ef11291bcd5f96 drivers/net/korina.c          Florian Fainelli    2008-03-19  614  			/* Update statistics counters */
364a97f5d1ae31 drivers/net/ethernet/korina.c Roman Yeryomin      2017-09-17  615  			dev->stats.rx_errors++;
364a97f5d1ae31 drivers/net/ethernet/korina.c Roman Yeryomin      2017-09-17  616  			dev->stats.rx_dropped++;
ef11291bcd5f96 drivers/net/korina.c          Florian Fainelli    2008-03-19  617  			if (devcs & ETH_RX_CRC)
ef11291bcd5f96 drivers/net/korina.c          Florian Fainelli    2008-03-19  618  				dev->stats.rx_crc_errors++;
ef11291bcd5f96 drivers/net/korina.c          Florian Fainelli    2008-03-19  619  			if (devcs & ETH_RX_LE)
ef11291bcd5f96 drivers/net/korina.c          Florian Fainelli    2008-03-19  620  				dev->stats.rx_length_errors++;
ef11291bcd5f96 drivers/net/korina.c          Florian Fainelli    2008-03-19  621  			if (devcs & ETH_RX_OVR)
b1011b375be106 drivers/net/korina.c          Phil Sutter         2010-05-29  622  				dev->stats.rx_fifo_errors++;
ef11291bcd5f96 drivers/net/korina.c          Florian Fainelli    2008-03-19  623  			if (devcs & ETH_RX_CV)
ef11291bcd5f96 drivers/net/korina.c          Florian Fainelli    2008-03-19  624  				dev->stats.rx_frame_errors++;
ef11291bcd5f96 drivers/net/korina.c          Florian Fainelli    2008-03-19  625  			if (devcs & ETH_RX_CES)
364a97f5d1ae31 drivers/net/ethernet/korina.c Roman Yeryomin      2017-09-17  626  				dev->stats.rx_frame_errors++;
364a97f5d1ae31 drivers/net/ethernet/korina.c Roman Yeryomin      2017-09-17  627  
364a97f5d1ae31 drivers/net/ethernet/korina.c Roman Yeryomin      2017-09-17  628  			goto next;
364a97f5d1ae31 drivers/net/ethernet/korina.c Roman Yeryomin      2017-09-17  629  		}
ef11291bcd5f96 drivers/net/korina.c          Florian Fainelli    2008-03-19  630  
ef11291bcd5f96 drivers/net/korina.c          Florian Fainelli    2008-03-19  631  		/* Malloc up new buffer. */
89d71a66c40d62 drivers/net/korina.c          Eric Dumazet        2009-10-13  632  		skb_new = netdev_alloc_skb_ip_align(dev, KORINA_RBSIZE);
ef11291bcd5f96 drivers/net/korina.c          Florian Fainelli    2008-03-19  633  		if (!skb_new)
ef11291bcd5f96 drivers/net/korina.c          Florian Fainelli    2008-03-19  634  			break;
69e8eeb0eae052 drivers/net/ethernet/korina.c Thomas Bogendoerfer 2021-04-13  635  
69e8eeb0eae052 drivers/net/ethernet/korina.c Thomas Bogendoerfer 2021-04-13  636  		ca = dma_map_single(lp->dmadev, skb_new->data, KORINA_RBSIZE,
69e8eeb0eae052 drivers/net/ethernet/korina.c Thomas Bogendoerfer 2021-04-13  637  				    DMA_FROM_DEVICE);
69e8eeb0eae052 drivers/net/ethernet/korina.c Thomas Bogendoerfer 2021-04-13  638  		if (dma_mapping_error(lp->dmadev, ca)) {
69e8eeb0eae052 drivers/net/ethernet/korina.c Thomas Bogendoerfer 2021-04-13  639  			dev_kfree_skb_any(skb_new);
69e8eeb0eae052 drivers/net/ethernet/korina.c Thomas Bogendoerfer 2021-04-13  640  			break;
69e8eeb0eae052 drivers/net/ethernet/korina.c Thomas Bogendoerfer 2021-04-13  641  		}
69e8eeb0eae052 drivers/net/ethernet/korina.c Thomas Bogendoerfer 2021-04-13  642  
69e8eeb0eae052 drivers/net/ethernet/korina.c Thomas Bogendoerfer 2021-04-13  643  		pkt_len = RCVPKT_LENGTH(devcs);
69e8eeb0eae052 drivers/net/ethernet/korina.c Thomas Bogendoerfer 2021-04-13  644  		dma_unmap_single(lp->dmadev, rd->ca, pkt_len, DMA_FROM_DEVICE);
69e8eeb0eae052 drivers/net/ethernet/korina.c Thomas Bogendoerfer 2021-04-13  645  
ef11291bcd5f96 drivers/net/korina.c          Florian Fainelli    2008-03-19  646  		/* Do not count the CRC */
ef11291bcd5f96 drivers/net/korina.c          Florian Fainelli    2008-03-19  647  		skb_put(skb, pkt_len - 4);
ef11291bcd5f96 drivers/net/korina.c          Florian Fainelli    2008-03-19  648  		skb->protocol = eth_type_trans(skb, dev);
ef11291bcd5f96 drivers/net/korina.c          Florian Fainelli    2008-03-19  649  
ef11291bcd5f96 drivers/net/korina.c          Florian Fainelli    2008-03-19  650  		/* Pass the packet to upper layers */
247c78f2bed0c4 drivers/net/ethernet/korina.c Roman Yeryomin      2017-09-17  651  		napi_gro_receive(&lp->napi, skb);
ef11291bcd5f96 drivers/net/korina.c          Florian Fainelli    2008-03-19  652  		dev->stats.rx_packets++;
ef11291bcd5f96 drivers/net/korina.c          Florian Fainelli    2008-03-19  653  		dev->stats.rx_bytes += pkt_len;
ef11291bcd5f96 drivers/net/korina.c          Florian Fainelli    2008-03-19  654  
ef11291bcd5f96 drivers/net/korina.c          Florian Fainelli    2008-03-19  655  		/* Update the mcast stats */
ef11291bcd5f96 drivers/net/korina.c          Florian Fainelli    2008-03-19  656  		if (devcs & ETH_RX_MP)
ef11291bcd5f96 drivers/net/korina.c          Florian Fainelli    2008-03-19  657  			dev->stats.multicast++;
ef11291bcd5f96 drivers/net/korina.c          Florian Fainelli    2008-03-19  658  
ef11291bcd5f96 drivers/net/korina.c          Florian Fainelli    2008-03-19  659  		lp->rx_skb[lp->rx_next_done] = skb_new;
ef11291bcd5f96 drivers/net/korina.c          Florian Fainelli    2008-03-19  660  
364a97f5d1ae31 drivers/net/ethernet/korina.c Roman Yeryomin      2017-09-17  661  next:
ef11291bcd5f96 drivers/net/korina.c          Florian Fainelli    2008-03-19  662  		rd->devcs = 0;
ef11291bcd5f96 drivers/net/korina.c          Florian Fainelli    2008-03-19  663  
ef11291bcd5f96 drivers/net/korina.c          Florian Fainelli    2008-03-19  664  		/* Restore descriptor's curr_addr */
69e8eeb0eae052 drivers/net/ethernet/korina.c Thomas Bogendoerfer 2021-04-13  665  		rd->ca = ca;
ef11291bcd5f96 drivers/net/korina.c          Florian Fainelli    2008-03-19  666  
ef11291bcd5f96 drivers/net/korina.c          Florian Fainelli    2008-03-19  667  		rd->control = DMA_COUNT(KORINA_RBSIZE) |
ef11291bcd5f96 drivers/net/korina.c          Florian Fainelli    2008-03-19  668  			DMA_DESC_COD | DMA_DESC_IOD;
ef11291bcd5f96 drivers/net/korina.c          Florian Fainelli    2008-03-19  669  		lp->rd_ring[(lp->rx_next_done - 1) &
ef11291bcd5f96 drivers/net/korina.c          Florian Fainelli    2008-03-19  670  			KORINA_RDS_MASK].control &=
ef11291bcd5f96 drivers/net/korina.c          Florian Fainelli    2008-03-19  671  			~DMA_DESC_COD;
ef11291bcd5f96 drivers/net/korina.c          Florian Fainelli    2008-03-19  672  
ef11291bcd5f96 drivers/net/korina.c          Florian Fainelli    2008-03-19  673  		lp->rx_next_done = (lp->rx_next_done + 1) & KORINA_RDS_MASK;
ef11291bcd5f96 drivers/net/korina.c          Florian Fainelli    2008-03-19  674  		rd = &lp->rd_ring[lp->rx_next_done];
ef11291bcd5f96 drivers/net/korina.c          Florian Fainelli    2008-03-19 @675  		writel(~DMA_STAT_DONE, &lp->rx_dma_regs->dmas);
ef11291bcd5f96 drivers/net/korina.c          Florian Fainelli    2008-03-19  676  	}
ef11291bcd5f96 drivers/net/korina.c          Florian Fainelli    2008-03-19  677  
ef11291bcd5f96 drivers/net/korina.c          Florian Fainelli    2008-03-19  678  	dmas = readl(&lp->rx_dma_regs->dmas);
ef11291bcd5f96 drivers/net/korina.c          Florian Fainelli    2008-03-19  679  
ef11291bcd5f96 drivers/net/korina.c          Florian Fainelli    2008-03-19  680  	if (dmas & DMA_STAT_HALT) {
ef11291bcd5f96 drivers/net/korina.c          Florian Fainelli    2008-03-19  681  		writel(~(DMA_STAT_HALT | DMA_STAT_ERR),
ef11291bcd5f96 drivers/net/korina.c          Florian Fainelli    2008-03-19  682  				&lp->rx_dma_regs->dmas);
ef11291bcd5f96 drivers/net/korina.c          Florian Fainelli    2008-03-19  683  
ef11291bcd5f96 drivers/net/korina.c          Florian Fainelli    2008-03-19  684  		lp->dma_halt_cnt++;
ef11291bcd5f96 drivers/net/korina.c          Florian Fainelli    2008-03-19  685  		rd->devcs = 0;
69e8eeb0eae052 drivers/net/ethernet/korina.c Thomas Bogendoerfer 2021-04-13  686  		writel(korina_rx_dma(lp, rd - lp->rd_ring),
69e8eeb0eae052 drivers/net/ethernet/korina.c Thomas Bogendoerfer 2021-04-13  687  		       &lp->rx_dma_regs->dmandptr);
ef11291bcd5f96 drivers/net/korina.c          Florian Fainelli    2008-03-19  688  	}
ef11291bcd5f96 drivers/net/korina.c          Florian Fainelli    2008-03-19  689  
ef11291bcd5f96 drivers/net/korina.c          Florian Fainelli    2008-03-19  690  	return count;
ef11291bcd5f96 drivers/net/korina.c          Florian Fainelli    2008-03-19  691  }
ef11291bcd5f96 drivers/net/korina.c          Florian Fainelli    2008-03-19  692  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
kernel test robot April 14, 2021, 2:37 a.m. UTC | #2
Hi Thomas,

I love your patch! Yet something to improve:

[auto build test ERROR on net-next/master]

url:    https://github.com/0day-ci/linux/commits/Thomas-Bogendoerfer/net-Korina-improvements/20210414-045102
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git 8ef7adc6beb2ef0bce83513dc9e4505e7b21e8c2
config: riscv-allmodconfig (attached as .config)
compiler: riscv64-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/c92cee3d78d891046f2668b2d82c375899d387a4
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Thomas-Bogendoerfer/net-Korina-improvements/20210414-045102
        git checkout c92cee3d78d891046f2668b2d82c375899d387a4
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=riscv 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>, old ones prefixed by <<):

>> ERROR: modpost: "idt_cpu_freq" [drivers/net/ethernet/korina.ko] undefined!

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
diff mbox series

Patch

diff --git a/drivers/net/ethernet/Kconfig b/drivers/net/ethernet/Kconfig
index ad04660b97b8..c61368968cee 100644
--- a/drivers/net/ethernet/Kconfig
+++ b/drivers/net/ethernet/Kconfig
@@ -97,7 +97,7 @@  config JME
 
 config KORINA
 	tristate "Korina (IDT RC32434) Ethernet support"
-	depends on MIKROTIK_RB532
+	depends on MIKROTIK_RB532 || COMPILE_TEST
 	help
 	  If you have a Mikrotik RouterBoard 500 or IDT RC32434
 	  based system say Y. Otherwise say N.
diff --git a/drivers/net/ethernet/korina.c b/drivers/net/ethernet/korina.c
index d7972965eb14..98aa7f007f8e 100644
--- a/drivers/net/ethernet/korina.c
+++ b/drivers/net/ethernet/korina.c
@@ -55,20 +55,244 @@ 
 #include <linux/crc32.h>
 #include <linux/pgtable.h>
 
-#include <asm/bootinfo.h>
-#include <asm/bitops.h>
-#include <asm/io.h>
-#include <asm/dma.h>
-
-#include <asm/mach-rc32434/rb.h>
-#include <asm/mach-rc32434/rc32434.h>
-#include <asm/mach-rc32434/eth.h>
-#include <asm/mach-rc32434/dma_v.h>
-
 #define DRV_NAME	"korina"
 #define DRV_VERSION	"0.20"
 #define DRV_RELDATE	"15Sep2017"
 
+struct eth_regs {
+	u32 ethintfc;
+	u32 ethfifott;
+	u32 etharc;
+	u32 ethhash0;
+	u32 ethhash1;
+	u32 ethu0[4];		/* Reserved. */
+	u32 ethpfs;
+	u32 ethmcp;
+	u32 eth_u1[10];		/* Reserved. */
+	u32 ethspare;
+	u32 eth_u2[42];		/* Reserved. */
+	u32 ethsal0;
+	u32 ethsah0;
+	u32 ethsal1;
+	u32 ethsah1;
+	u32 ethsal2;
+	u32 ethsah2;
+	u32 ethsal3;
+	u32 ethsah3;
+	u32 ethrbc;
+	u32 ethrpc;
+	u32 ethrupc;
+	u32 ethrfc;
+	u32 ethtbc;
+	u32 ethgpf;
+	u32 eth_u9[50];		/* Reserved. */
+	u32 ethmac1;
+	u32 ethmac2;
+	u32 ethipgt;
+	u32 ethipgr;
+	u32 ethclrt;
+	u32 ethmaxf;
+	u32 eth_u10;		/* Reserved. */
+	u32 ethmtest;
+	u32 miimcfg;
+	u32 miimcmd;
+	u32 miimaddr;
+	u32 miimwtd;
+	u32 miimrdd;
+	u32 miimind;
+	u32 eth_u11;		/* Reserved. */
+	u32 eth_u12;		/* Reserved. */
+	u32 ethcfsa0;
+	u32 ethcfsa1;
+	u32 ethcfsa2;
+};
+
+/* Ethernet interrupt registers */
+#define ETH_INT_FC_EN		BIT(0)
+#define ETH_INT_FC_ITS		BIT(1)
+#define ETH_INT_FC_RIP		BIT(2)
+#define ETH_INT_FC_JAM		BIT(3)
+#define ETH_INT_FC_OVR		BIT(4)
+#define ETH_INT_FC_UND		BIT(5)
+#define ETH_INT_FC_IOC		0x000000c0
+
+/* Ethernet FIFO registers */
+#define ETH_FIFI_TT_TTH_BIT	0
+#define ETH_FIFO_TT_TTH		0x0000007f
+
+/* Ethernet ARC/multicast registers */
+#define ETH_ARC_PRO		BIT(0)
+#define ETH_ARC_AM		BIT(1)
+#define ETH_ARC_AFM		BIT(2)
+#define ETH_ARC_AB		BIT(3)
+
+/* Ethernet SAL registers */
+#define ETH_SAL_BYTE_5		0x000000ff
+#define ETH_SAL_BYTE_4		0x0000ff00
+#define ETH_SAL_BYTE_3		0x00ff0000
+#define ETH_SAL_BYTE_2		0xff000000
+
+/* Ethernet SAH registers */
+#define ETH_SAH_BYTE1		0x000000ff
+#define ETH_SAH_BYTE0		0x0000ff00
+
+/* Ethernet GPF register */
+#define ETH_GPF_PTV		0x0000ffff
+
+/* Ethernet PFG register */
+#define ETH_PFS_PFD		BIT(0)
+
+/* Ethernet CFSA[0-3] registers */
+#define ETH_CFSA0_CFSA4		0x000000ff
+#define ETH_CFSA0_CFSA5		0x0000ff00
+#define ETH_CFSA1_CFSA2		0x000000ff
+#define ETH_CFSA1_CFSA3		0x0000ff00
+#define ETH_CFSA1_CFSA0		0x000000ff
+#define ETH_CFSA1_CFSA1		0x0000ff00
+
+/* Ethernet MAC1 registers */
+#define ETH_MAC1_RE		BIT(0)
+#define ETH_MAC1_PAF		BIT(1)
+#define ETH_MAC1_RFC		BIT(2)
+#define ETH_MAC1_TFC		BIT(3)
+#define ETH_MAC1_LB		BIT(4)
+#define ETH_MAC1_MR		BIT(31)
+
+/* Ethernet MAC2 registers */
+#define ETH_MAC2_FD		BIT(0)
+#define ETH_MAC2_FLC		BIT(1)
+#define ETH_MAC2_HFE		BIT(2)
+#define ETH_MAC2_DC		BIT(3)
+#define ETH_MAC2_CEN		BIT(4)
+#define ETH_MAC2_PE		BIT(5)
+#define ETH_MAC2_VPE		BIT(6)
+#define ETH_MAC2_APE		BIT(7)
+#define ETH_MAC2_PPE		BIT(8)
+#define ETH_MAC2_LPE		BIT(9)
+#define ETH_MAC2_NB		BIT(12)
+#define ETH_MAC2_BP		BIT(13)
+#define ETH_MAC2_ED		BIT(14)
+
+/* Ethernet IPGT register */
+#define ETH_IPGT		0x0000007f
+
+/* Ethernet IPGR registers */
+#define ETH_IPGR_IPGR2		0x0000007f
+#define ETH_IPGR_IPGR1		0x00007f00
+
+/* Ethernet CLRT registers */
+#define ETH_CLRT_MAX_RET	0x0000000f
+#define ETH_CLRT_COL_WIN	0x00003f00
+
+/* Ethernet MAXF register */
+#define ETH_MAXF		0x0000ffff
+
+/* Ethernet test registers */
+#define ETH_TEST_REG		BIT(2)
+#define ETH_MCP_DIV		0x000000ff
+
+/* MII registers */
+#define ETH_MII_CFG_RSVD	0x0000000c
+#define ETH_MII_CMD_RD		BIT(0)
+#define ETH_MII_CMD_SCN		BIT(1)
+#define ETH_MII_REG_ADDR	0x0000001f
+#define ETH_MII_PHY_ADDR	0x00001f00
+#define ETH_MII_WTD_DATA	0x0000ffff
+#define ETH_MII_RDD_DATA	0x0000ffff
+#define ETH_MII_IND_BSY		BIT(0)
+#define ETH_MII_IND_SCN		BIT(1)
+#define ETH_MII_IND_NV		BIT(2)
+
+/* Values for the DEVCS field of the Ethernet DMA Rx and Tx descriptors. */
+#define ETH_RX_FD		BIT(0)
+#define ETH_RX_LD		BIT(1)
+#define ETH_RX_ROK		BIT(2)
+#define ETH_RX_FM		BIT(3)
+#define ETH_RX_MP		BIT(4)
+#define ETH_RX_BP		BIT(5)
+#define ETH_RX_VLT		BIT(6)
+#define ETH_RX_CF		BIT(7)
+#define ETH_RX_OVR		BIT(8)
+#define ETH_RX_CRC		BIT(9)
+#define ETH_RX_CV		BIT(10)
+#define ETH_RX_DB		BIT(11)
+#define ETH_RX_LE		BIT(12)
+#define ETH_RX_LOR		BIT(13)
+#define ETH_RX_CES		BIT(14)
+#define ETH_RX_LEN_BIT		16
+#define ETH_RX_LEN		0xffff0000
+
+#define ETH_TX_FD		BIT(0)
+#define ETH_TX_LD		BIT(1)
+#define ETH_TX_OEN		BIT(2)
+#define ETH_TX_PEN		BIT(3)
+#define ETH_TX_CEN		BIT(4)
+#define ETH_TX_HEN		BIT(5)
+#define ETH_TX_TOK		BIT(6)
+#define ETH_TX_MP		BIT(7)
+#define ETH_TX_BP		BIT(8)
+#define ETH_TX_UND		BIT(9)
+#define ETH_TX_OF		BIT(10)
+#define ETH_TX_ED		BIT(11)
+#define ETH_TX_EC		BIT(12)
+#define ETH_TX_LC		BIT(13)
+#define ETH_TX_TD		BIT(14)
+#define ETH_TX_CRC		BIT(15)
+#define ETH_TX_LE		BIT(16)
+#define ETH_TX_CC		0x001E0000
+
+/* DMA descriptor (in physical memory). */
+struct dma_desc {
+	u32 control;			/* Control. use DMAD_* */
+	u32 ca;				/* Current Address. */
+	u32 devcs;			/* Device control and status. */
+	u32 link;			/* Next descriptor in chain. */
+};
+
+#define DMA_DESC_COUNT_BIT		0
+#define DMA_DESC_COUNT_MSK		0x0003ffff
+#define DMA_DESC_DS_BIT			20
+#define DMA_DESC_DS_MSK			0x00300000
+
+#define DMA_DESC_DEV_CMD_BIT		22
+#define DMA_DESC_DEV_CMD_MSK		0x01c00000
+
+/* DMA descriptors interrupts */
+#define DMA_DESC_COF			BIT(25) /* Chain on finished */
+#define DMA_DESC_COD			BIT(26) /* Chain on done */
+#define DMA_DESC_IOF			BIT(27) /* Interrupt on finished */
+#define DMA_DESC_IOD			BIT(28) /* Interrupt on done */
+#define DMA_DESC_TERM			BIT(29) /* Terminated */
+#define DMA_DESC_DONE			BIT(30) /* Done */
+#define DMA_DESC_FINI			BIT(31) /* Finished */
+
+/* DMA register (within Internal Register Map).  */
+struct dma_reg {
+	u32 dmac;		/* Control. */
+	u32 dmas;		/* Status. */
+	u32 dmasm;		/* Mask. */
+	u32 dmadptr;		/* Descriptor pointer. */
+	u32 dmandptr;		/* Next descriptor pointer. */
+};
+
+/* DMA channels specific registers */
+#define DMA_CHAN_RUN_BIT		BIT(0)
+#define DMA_CHAN_DONE_BIT		BIT(1)
+#define DMA_CHAN_MODE_BIT		BIT(2)
+#define DMA_CHAN_MODE_MSK		0x0000000c
+#define	 DMA_CHAN_MODE_AUTO		0
+#define	 DMA_CHAN_MODE_BURST		1
+#define	 DMA_CHAN_MODE_XFRT		2
+#define	 DMA_CHAN_MODE_RSVD		3
+#define DMA_CHAN_ACT_BIT		BIT(4)
+
+/* DMA status registers */
+#define DMA_STAT_FINI			BIT(0)
+#define DMA_STAT_DONE			BIT(1)
+#define DMA_STAT_CHAIN			BIT(2)
+#define DMA_STAT_ERR			BIT(3)
+#define DMA_STAT_HALT			BIT(4)
+
 #define STATION_ADDRESS_HIGH(dev) (((dev)->dev_addr[0] << 8) | \
 				   ((dev)->dev_addr[1]))
 #define STATION_ADDRESS_LOW(dev)  (((dev)->dev_addr[2] << 24) | \
@@ -98,6 +322,7 @@  enum chain_status {
 	desc_empty
 };
 
+#define DMA_COUNT(count)	((count) & DMA_DESC_COUNT_MSK)
 #define IS_DMA_FINISHED(X)	(((X) & (DMA_DESC_FINI)) != 0)
 #define IS_DMA_DONE(X)		(((X) & (DMA_DESC_DONE)) != 0)
 #define RCVPKT_LENGTH(X)	(((X) & ETH_RX_LEN) >> ETH_RX_LEN_BIT)