/* * Cadence MACB/GEM Ethernet Controller driver * * Copyright (C) 2004-2006 Atmel Corporation * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt#include<linux/clk.h>#include<linux/module.h>#include<linux/moduleparam.h>#include<linux/kernel.h>#include<linux/types.h>#include<linux/slab.h>#include<linux/init.h>#include<linux/interrupt.h>#include<linux/netdevice.h>#include<linux/etherdevice.h>#include<linux/dma-mapping.h>#include<linux/platform_data/macb.h>#include<linux/platform_device.h>#include<linux/phy.h>#include<linux/of.h>#include<linux/of_device.h>#include<linux/of_net.h>#include"macb.h"#define RX_BUFFER_SIZE 128#define RX_RING_SIZE 512#define RX_RING_BYTES (sizeof(struct dma_desc) * RX_RING_SIZE)/* Make the IP header word-aligned (the ethernet header is 14 bytes) */#define RX_OFFSET 2#define TX_RING_SIZE 128#define DEF_TX_RING_PENDING (TX_RING_SIZE - 1)#define TX_RING_BYTES (sizeof(struct dma_desc) * TX_RING_SIZE)#define TX_RING_GAP(bp) \ (TX_RING_SIZE - (bp)->tx_pending)#define TX_BUFFS_AVAIL(bp) \ (((bp)->tx_tail <= (bp)->tx_head) ? \ (bp)->tx_tail + (bp)->tx_pending - (bp)->tx_head : \ (bp)->tx_tail - (bp)->tx_head - TX_RING_GAP(bp))#define NEXT_TX(n) (((n) + 1) &