Commit 74b0247f authored by Ralf Baechle's avatar Ralf Baechle Committed by Jeff Garzik

[PATCH] sb1250-mac: Whitespace cleanup.

Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>

 drivers/net/sb1250-mac.c | 1030 +++++++++++++++++++++++------------------------
 1 files changed, 515 insertions(+), 515 deletions(-)
Signed-off-by: default avatarJeff Garzik <jgarzik@pobox.com>
parent 2039973a
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
...@@ -127,7 +127,7 @@ typedef enum { sbmac_duplex_auto, sbmac_duplex_half, ...@@ -127,7 +127,7 @@ typedef enum { sbmac_duplex_auto, sbmac_duplex_half,
typedef enum { sbmac_fc_auto, sbmac_fc_disabled, sbmac_fc_frame, typedef enum { sbmac_fc_auto, sbmac_fc_disabled, sbmac_fc_frame,
sbmac_fc_collision, sbmac_fc_carrier } sbmac_fc_t; sbmac_fc_collision, sbmac_fc_carrier } sbmac_fc_t;
typedef enum { sbmac_state_uninit, sbmac_state_off, sbmac_state_on, typedef enum { sbmac_state_uninit, sbmac_state_off, sbmac_state_on,
sbmac_state_broken } sbmac_state_t; sbmac_state_broken } sbmac_state_t;
...@@ -147,8 +147,8 @@ typedef enum { sbmac_state_uninit, sbmac_state_off, sbmac_state_on, ...@@ -147,8 +147,8 @@ typedef enum { sbmac_state_uninit, sbmac_state_off, sbmac_state_on,
#define ETHER_ALIGN 2 #define ETHER_ALIGN 2
#define ETHER_ADDR_LEN 6 #define ETHER_ADDR_LEN 6
#define ENET_PACKET_SIZE 1518 #define ENET_PACKET_SIZE 1518
/*#define ENET_PACKET_SIZE 9216 */ /*#define ENET_PACKET_SIZE 9216 */
/********************************************************************** /**********************************************************************
* DMA Descriptor structure * DMA Descriptor structure
...@@ -166,12 +166,12 @@ typedef unsigned long paddr_t; ...@@ -166,12 +166,12 @@ typedef unsigned long paddr_t;
********************************************************************* */ ********************************************************************* */
typedef struct sbmacdma_s { typedef struct sbmacdma_s {
/* /*
* This stuff is used to identify the channel and the registers * This stuff is used to identify the channel and the registers
* associated with it. * associated with it.
*/ */
struct sbmac_softc *sbdma_eth; /* back pointer to associated MAC */ struct sbmac_softc *sbdma_eth; /* back pointer to associated MAC */
int sbdma_channel; /* channel number */ int sbdma_channel; /* channel number */
int sbdma_txdir; /* direction (1=transmit) */ int sbdma_txdir; /* direction (1=transmit) */
...@@ -186,16 +186,16 @@ typedef struct sbmacdma_s { ...@@ -186,16 +186,16 @@ typedef struct sbmacdma_s {
volatile void __iomem *sbdma_dscrbase; /* Descriptor base address */ volatile void __iomem *sbdma_dscrbase; /* Descriptor base address */
volatile void __iomem *sbdma_dscrcnt; /* Descriptor count register */ volatile void __iomem *sbdma_dscrcnt; /* Descriptor count register */
volatile void __iomem *sbdma_curdscr; /* current descriptor address */ volatile void __iomem *sbdma_curdscr; /* current descriptor address */
/* /*
* This stuff is for maintenance of the ring * This stuff is for maintenance of the ring
*/ */
sbdmadscr_t *sbdma_dscrtable; /* base of descriptor table */ sbdmadscr_t *sbdma_dscrtable; /* base of descriptor table */
sbdmadscr_t *sbdma_dscrtable_end; /* end of descriptor table */ sbdmadscr_t *sbdma_dscrtable_end; /* end of descriptor table */
struct sk_buff **sbdma_ctxtable; /* context table, one per descr */ struct sk_buff **sbdma_ctxtable; /* context table, one per descr */
paddr_t sbdma_dscrtable_phys; /* and also the phys addr */ paddr_t sbdma_dscrtable_phys; /* and also the phys addr */
sbdmadscr_t *sbdma_addptr; /* next dscr for sw to add */ sbdmadscr_t *sbdma_addptr; /* next dscr for sw to add */
sbdmadscr_t *sbdma_remptr; /* next dscr for sw to remove */ sbdmadscr_t *sbdma_remptr; /* next dscr for sw to remove */
...@@ -207,15 +207,15 @@ typedef struct sbmacdma_s { ...@@ -207,15 +207,15 @@ typedef struct sbmacdma_s {
********************************************************************* */ ********************************************************************* */
struct sbmac_softc { struct sbmac_softc {
/* /*
* Linux-specific things * Linux-specific things
*/ */
struct net_device *sbm_dev; /* pointer to linux device */ struct net_device *sbm_dev; /* pointer to linux device */
spinlock_t sbm_lock; /* spin lock */ spinlock_t sbm_lock; /* spin lock */
struct timer_list sbm_timer; /* for monitoring MII */ struct timer_list sbm_timer; /* for monitoring MII */
struct net_device_stats sbm_stats; struct net_device_stats sbm_stats;
int sbm_devflags; /* current device flags */ int sbm_devflags; /* current device flags */
int sbm_phy_oldbmsr; int sbm_phy_oldbmsr;
...@@ -223,16 +223,16 @@ struct sbmac_softc { ...@@ -223,16 +223,16 @@ struct sbmac_softc {
int sbm_phy_oldk1stsr; int sbm_phy_oldk1stsr;
int sbm_phy_oldlinkstat; int sbm_phy_oldlinkstat;
int sbm_buffersize; int sbm_buffersize;
unsigned char sbm_phys[2]; unsigned char sbm_phys[2];
/* /*
* Controller-specific things * Controller-specific things
*/ */
volatile void __iomem *sbm_base; /* MAC's base address */ volatile void __iomem *sbm_base; /* MAC's base address */
sbmac_state_t sbm_state; /* current state */ sbmac_state_t sbm_state; /* current state */
volatile void __iomem *sbm_macenable; /* MAC Enable Register */ volatile void __iomem *sbm_macenable; /* MAC Enable Register */
volatile void __iomem *sbm_maccfg; /* MAC Configuration Register */ volatile void __iomem *sbm_maccfg; /* MAC Configuration Register */
volatile void __iomem *sbm_fifocfg; /* FIFO configuration register */ volatile void __iomem *sbm_fifocfg; /* FIFO configuration register */
...@@ -241,13 +241,13 @@ struct sbmac_softc { ...@@ -241,13 +241,13 @@ struct sbmac_softc {
volatile void __iomem *sbm_isr; /* Interrupt status register */ volatile void __iomem *sbm_isr; /* Interrupt status register */
volatile void __iomem *sbm_imr; /* Interrupt mask register */ volatile void __iomem *sbm_imr; /* Interrupt mask register */
volatile void __iomem *sbm_mdio; /* MDIO register */ volatile void __iomem *sbm_mdio; /* MDIO register */
sbmac_speed_t sbm_speed; /* current speed */ sbmac_speed_t sbm_speed; /* current speed */
sbmac_duplex_t sbm_duplex; /* current duplex */ sbmac_duplex_t sbm_duplex; /* current duplex */
sbmac_fc_t sbm_fc; /* current flow control setting */ sbmac_fc_t sbm_fc; /* current flow control setting */
unsigned char sbm_hwaddr[ETHER_ADDR_LEN]; unsigned char sbm_hwaddr[ETHER_ADDR_LEN];
sbmacdma_t sbm_txdma; /* for now, only use channel 0 */ sbmacdma_t sbm_txdma; /* for now, only use channel 0 */
sbmacdma_t sbm_rxdma; sbmacdma_t sbm_rxdma;
int rx_hw_checksum; int rx_hw_checksum;
...@@ -444,13 +444,13 @@ static uint64_t sbmac_orig_hwaddr[MAX_UNITS]; ...@@ -444,13 +444,13 @@ static uint64_t sbmac_orig_hwaddr[MAX_UNITS];
/********************************************************************** /**********************************************************************
* SBMAC_MII_SYNC(s) * SBMAC_MII_SYNC(s)
* *
* Synchronize with the MII - send a pattern of bits to the MII * Synchronize with the MII - send a pattern of bits to the MII
* that will guarantee that it is ready to accept a command. * that will guarantee that it is ready to accept a command.
* *
* Input parameters: * Input parameters:
* s - sbmac structure * s - sbmac structure
* *
* Return value: * Return value:
* nothing * nothing
********************************************************************* */ ********************************************************************* */
...@@ -462,11 +462,11 @@ static void sbmac_mii_sync(struct sbmac_softc *s) ...@@ -462,11 +462,11 @@ static void sbmac_mii_sync(struct sbmac_softc *s)
int mac_mdio_genc; int mac_mdio_genc;
mac_mdio_genc = __raw_readq(s->sbm_mdio) & M_MAC_GENC; mac_mdio_genc = __raw_readq(s->sbm_mdio) & M_MAC_GENC;
bits = M_MAC_MDIO_DIR_OUTPUT | M_MAC_MDIO_OUT; bits = M_MAC_MDIO_DIR_OUTPUT | M_MAC_MDIO_OUT;
__raw_writeq(bits | mac_mdio_genc, s->sbm_mdio); __raw_writeq(bits | mac_mdio_genc, s->sbm_mdio);
for (cnt = 0; cnt < 32; cnt++) { for (cnt = 0; cnt < 32; cnt++) {
__raw_writeq(bits | M_MAC_MDC | mac_mdio_genc, s->sbm_mdio); __raw_writeq(bits | M_MAC_MDC | mac_mdio_genc, s->sbm_mdio);
__raw_writeq(bits | mac_mdio_genc, s->sbm_mdio); __raw_writeq(bits | mac_mdio_genc, s->sbm_mdio);
...@@ -475,11 +475,11 @@ static void sbmac_mii_sync(struct sbmac_softc *s) ...@@ -475,11 +475,11 @@ static void sbmac_mii_sync(struct sbmac_softc *s)
/********************************************************************** /**********************************************************************
* SBMAC_MII_SENDDATA(s,data,bitcnt) * SBMAC_MII_SENDDATA(s,data,bitcnt)
* *
* Send some bits to the MII. The bits to be sent are right- * Send some bits to the MII. The bits to be sent are right-
* justified in the 'data' parameter. * justified in the 'data' parameter.
* *
* Input parameters: * Input parameters:
* s - sbmac structure * s - sbmac structure
* data - data to send * data - data to send
* bitcnt - number of bits to send * bitcnt - number of bits to send
...@@ -493,12 +493,12 @@ static void sbmac_mii_senddata(struct sbmac_softc *s,unsigned int data, int bitc ...@@ -493,12 +493,12 @@ static void sbmac_mii_senddata(struct sbmac_softc *s,unsigned int data, int bitc
int mac_mdio_genc; int mac_mdio_genc;
mac_mdio_genc = __raw_readq(s->sbm_mdio) & M_MAC_GENC; mac_mdio_genc = __raw_readq(s->sbm_mdio) & M_MAC_GENC;
bits = M_MAC_MDIO_DIR_OUTPUT; bits = M_MAC_MDIO_DIR_OUTPUT;
__raw_writeq(bits | mac_mdio_genc, s->sbm_mdio); __raw_writeq(bits | mac_mdio_genc, s->sbm_mdio);
curmask = 1 << (bitcnt - 1); curmask = 1 << (bitcnt - 1);
for (i = 0; i < bitcnt; i++) { for (i = 0; i < bitcnt; i++) {
if (data & curmask) if (data & curmask)
bits |= M_MAC_MDIO_OUT; bits |= M_MAC_MDIO_OUT;
...@@ -514,14 +514,14 @@ static void sbmac_mii_senddata(struct sbmac_softc *s,unsigned int data, int bitc ...@@ -514,14 +514,14 @@ static void sbmac_mii_senddata(struct sbmac_softc *s,unsigned int data, int bitc
/********************************************************************** /**********************************************************************
* SBMAC_MII_READ(s,phyaddr,regidx) * SBMAC_MII_READ(s,phyaddr,regidx)
* *
* Read a PHY register. * Read a PHY register.
* *
* Input parameters: * Input parameters:
* s - sbmac structure * s - sbmac structure
* phyaddr - PHY's address * phyaddr - PHY's address
* regidx = index of register to read * regidx = index of register to read
* *
* Return value: * Return value:
* value read, or 0 if an error occurred. * value read, or 0 if an error occurred.
********************************************************************* */ ********************************************************************* */
...@@ -537,9 +537,9 @@ static unsigned int sbmac_mii_read(struct sbmac_softc *s,int phyaddr,int regidx) ...@@ -537,9 +537,9 @@ static unsigned int sbmac_mii_read(struct sbmac_softc *s,int phyaddr,int regidx)
* Synchronize ourselves so that the PHY knows the next * Synchronize ourselves so that the PHY knows the next
* thing coming down is a command * thing coming down is a command
*/ */
sbmac_mii_sync(s); sbmac_mii_sync(s);
/* /*
* Send the data to the PHY. The sequence is * Send the data to the PHY. The sequence is
* a "start" command (2 bits) * a "start" command (2 bits)
...@@ -547,55 +547,55 @@ static unsigned int sbmac_mii_read(struct sbmac_softc *s,int phyaddr,int regidx) ...@@ -547,55 +547,55 @@ static unsigned int sbmac_mii_read(struct sbmac_softc *s,int phyaddr,int regidx)
* the PHY addr (5 bits) * the PHY addr (5 bits)
* the register index (5 bits) * the register index (5 bits)
*/ */
sbmac_mii_senddata(s,MII_COMMAND_START, 2); sbmac_mii_senddata(s,MII_COMMAND_START, 2);
sbmac_mii_senddata(s,MII_COMMAND_READ, 2); sbmac_mii_senddata(s,MII_COMMAND_READ, 2);
sbmac_mii_senddata(s,phyaddr, 5); sbmac_mii_senddata(s,phyaddr, 5);
sbmac_mii_senddata(s,regidx, 5); sbmac_mii_senddata(s,regidx, 5);
mac_mdio_genc = __raw_readq(s->sbm_mdio) & M_MAC_GENC; mac_mdio_genc = __raw_readq(s->sbm_mdio) & M_MAC_GENC;
/* /*
* Switch the port around without a clock transition. * Switch the port around without a clock transition.
*/ */
__raw_writeq(M_MAC_MDIO_DIR_INPUT | mac_mdio_genc, s->sbm_mdio); __raw_writeq(M_MAC_MDIO_DIR_INPUT | mac_mdio_genc, s->sbm_mdio);
/* /*
* Send out a clock pulse to signal we want the status * Send out a clock pulse to signal we want the status
*/ */
__raw_writeq(M_MAC_MDIO_DIR_INPUT | M_MAC_MDC | mac_mdio_genc, s->sbm_mdio); __raw_writeq(M_MAC_MDIO_DIR_INPUT | M_MAC_MDC | mac_mdio_genc, s->sbm_mdio);
__raw_writeq(M_MAC_MDIO_DIR_INPUT | mac_mdio_genc, s->sbm_mdio); __raw_writeq(M_MAC_MDIO_DIR_INPUT | mac_mdio_genc, s->sbm_mdio);
/* /*
* If an error occurred, the PHY will signal '1' back * If an error occurred, the PHY will signal '1' back
*/ */
error = __raw_readq(s->sbm_mdio) & M_MAC_MDIO_IN; error = __raw_readq(s->sbm_mdio) & M_MAC_MDIO_IN;
/* /*
* Issue an 'idle' clock pulse, but keep the direction * Issue an 'idle' clock pulse, but keep the direction
* the same. * the same.
*/ */
__raw_writeq(M_MAC_MDIO_DIR_INPUT | M_MAC_MDC | mac_mdio_genc, s->sbm_mdio); __raw_writeq(M_MAC_MDIO_DIR_INPUT | M_MAC_MDC | mac_mdio_genc, s->sbm_mdio);
__raw_writeq(M_MAC_MDIO_DIR_INPUT | mac_mdio_genc, s->sbm_mdio); __raw_writeq(M_MAC_MDIO_DIR_INPUT | mac_mdio_genc, s->sbm_mdio);
regval = 0; regval = 0;
for (idx = 0; idx < 16; idx++) { for (idx = 0; idx < 16; idx++) {
regval <<= 1; regval <<= 1;
if (error == 0) { if (error == 0) {
if (__raw_readq(s->sbm_mdio) & M_MAC_MDIO_IN) if (__raw_readq(s->sbm_mdio) & M_MAC_MDIO_IN)
regval |= 1; regval |= 1;
} }
__raw_writeq(M_MAC_MDIO_DIR_INPUT|M_MAC_MDC | mac_mdio_genc, s->sbm_mdio); __raw_writeq(M_MAC_MDIO_DIR_INPUT|M_MAC_MDC | mac_mdio_genc, s->sbm_mdio);
__raw_writeq(M_MAC_MDIO_DIR_INPUT | mac_mdio_genc, s->sbm_mdio); __raw_writeq(M_MAC_MDIO_DIR_INPUT | mac_mdio_genc, s->sbm_mdio);
} }
/* Switch back to output */ /* Switch back to output */
__raw_writeq(M_MAC_MDIO_DIR_OUTPUT | mac_mdio_genc, s->sbm_mdio); __raw_writeq(M_MAC_MDIO_DIR_OUTPUT | mac_mdio_genc, s->sbm_mdio);
if (error == 0) if (error == 0)
return regval; return regval;
return 0; return 0;
...@@ -604,15 +604,15 @@ static unsigned int sbmac_mii_read(struct sbmac_softc *s,int phyaddr,int regidx) ...@@ -604,15 +604,15 @@ static unsigned int sbmac_mii_read(struct sbmac_softc *s,int phyaddr,int regidx)
/********************************************************************** /**********************************************************************
* SBMAC_MII_WRITE(s,phyaddr,regidx,regval) * SBMAC_MII_WRITE(s,phyaddr,regidx,regval)
* *
* Write a value to a PHY register. * Write a value to a PHY register.
* *
* Input parameters: * Input parameters:
* s - sbmac structure * s - sbmac structure
* phyaddr - PHY to use * phyaddr - PHY to use
* regidx - register within the PHY * regidx - register within the PHY
* regval - data to write to register * regval - data to write to register
* *
* Return value: * Return value:
* nothing * nothing
********************************************************************* */ ********************************************************************* */
...@@ -623,7 +623,7 @@ static void sbmac_mii_write(struct sbmac_softc *s,int phyaddr,int regidx, ...@@ -623,7 +623,7 @@ static void sbmac_mii_write(struct sbmac_softc *s,int phyaddr,int regidx,
int mac_mdio_genc; int mac_mdio_genc;
sbmac_mii_sync(s); sbmac_mii_sync(s);
sbmac_mii_senddata(s,MII_COMMAND_START,2); sbmac_mii_senddata(s,MII_COMMAND_START,2);
sbmac_mii_senddata(s,MII_COMMAND_WRITE,2); sbmac_mii_senddata(s,MII_COMMAND_WRITE,2);
sbmac_mii_senddata(s,phyaddr, 5); sbmac_mii_senddata(s,phyaddr, 5);
...@@ -640,18 +640,18 @@ static void sbmac_mii_write(struct sbmac_softc *s,int phyaddr,int regidx, ...@@ -640,18 +640,18 @@ static void sbmac_mii_write(struct sbmac_softc *s,int phyaddr,int regidx,
/********************************************************************** /**********************************************************************
* SBDMA_INITCTX(d,s,chan,txrx,maxdescr) * SBDMA_INITCTX(d,s,chan,txrx,maxdescr)
* *
* Initialize a DMA channel context. Since there are potentially * Initialize a DMA channel context. Since there are potentially
* eight DMA channels per MAC, it's nice to do this in a standard * eight DMA channels per MAC, it's nice to do this in a standard
* way. * way.
* *
* Input parameters: * Input parameters:
* d - sbmacdma_t structure (DMA channel context) * d - sbmacdma_t structure (DMA channel context)
* s - sbmac_softc structure (pointer to a MAC) * s - sbmac_softc structure (pointer to a MAC)
* chan - channel number (0..1 right now) * chan - channel number (0..1 right now)
* txrx - Identifies DMA_TX or DMA_RX for channel direction * txrx - Identifies DMA_TX or DMA_RX for channel direction
* maxdescr - number of descriptors * maxdescr - number of descriptors
* *
* Return value: * Return value:
* nothing * nothing
********************************************************************* */ ********************************************************************* */
...@@ -662,14 +662,14 @@ static void sbdma_initctx(sbmacdma_t *d, ...@@ -662,14 +662,14 @@ static void sbdma_initctx(sbmacdma_t *d,
int txrx, int txrx,
int maxdescr) int maxdescr)
{ {
/* /*
* Save away interesting stuff in the structure * Save away interesting stuff in the structure
*/ */
d->sbdma_eth = s; d->sbdma_eth = s;
d->sbdma_channel = chan; d->sbdma_channel = chan;
d->sbdma_txdir = txrx; d->sbdma_txdir = txrx;
#if 0 #if 0
/* RMON clearing */ /* RMON clearing */
s->sbe_idx =(s->sbm_base - A_MAC_BASE_0)/MAC_SPACING; s->sbe_idx =(s->sbm_base - A_MAC_BASE_0)/MAC_SPACING;
...@@ -697,28 +697,28 @@ static void sbdma_initctx(sbmacdma_t *d, ...@@ -697,28 +697,28 @@ static void sbdma_initctx(sbmacdma_t *d,
__raw_writeq(0, IOADDR(A_MAC_REGISTER(s->sbe_idx, R_MAC_RMON_RX_CODE_ERROR))); __raw_writeq(0, IOADDR(A_MAC_REGISTER(s->sbe_idx, R_MAC_RMON_RX_CODE_ERROR)));
__raw_writeq(0, IOADDR(A_MAC_REGISTER(s->sbe_idx, R_MAC_RMON_RX_ALIGN_ERROR))); __raw_writeq(0, IOADDR(A_MAC_REGISTER(s->sbe_idx, R_MAC_RMON_RX_ALIGN_ERROR)));
/* /*
* initialize register pointers * initialize register pointers
*/ */
d->sbdma_config0 = d->sbdma_config0 =
s->sbm_base + R_MAC_DMA_REGISTER(txrx,chan,R_MAC_DMA_CONFIG0); s->sbm_base + R_MAC_DMA_REGISTER(txrx,chan,R_MAC_DMA_CONFIG0);
d->sbdma_config1 = d->sbdma_config1 =
s->sbm_base + R_MAC_DMA_REGISTER(txrx,chan,R_MAC_DMA_CONFIG1); s->sbm_base + R_MAC_DMA_REGISTER(txrx,chan,R_MAC_DMA_CONFIG1);
d->sbdma_dscrbase = d->sbdma_dscrbase =
s->sbm_base + R_MAC_DMA_REGISTER(txrx,chan,R_MAC_DMA_DSCR_BASE); s->sbm_base + R_MAC_DMA_REGISTER(txrx,chan,R_MAC_DMA_DSCR_BASE);
d->sbdma_dscrcnt = d->sbdma_dscrcnt =
s->sbm_base + R_MAC_DMA_REGISTER(txrx,chan,R_MAC_DMA_DSCR_CNT); s->sbm_base + R_MAC_DMA_REGISTER(txrx,chan,R_MAC_DMA_DSCR_CNT);
d->sbdma_curdscr = d->sbdma_curdscr =
s->sbm_base + R_MAC_DMA_REGISTER(txrx,chan,R_MAC_DMA_CUR_DSCRADDR); s->sbm_base + R_MAC_DMA_REGISTER(txrx,chan,R_MAC_DMA_CUR_DSCRADDR);
/* /*
* Allocate memory for the ring * Allocate memory for the ring
*/ */
d->sbdma_maxdescr = maxdescr; d->sbdma_maxdescr = maxdescr;
d->sbdma_dscrtable = (sbdmadscr_t *) d->sbdma_dscrtable = (sbdmadscr_t *)
kmalloc((d->sbdma_maxdescr+1)*sizeof(sbdmadscr_t), GFP_KERNEL); kmalloc((d->sbdma_maxdescr+1)*sizeof(sbdmadscr_t), GFP_KERNEL);
/* /*
...@@ -727,22 +727,22 @@ static void sbdma_initctx(sbmacdma_t *d, ...@@ -727,22 +727,22 @@ static void sbdma_initctx(sbmacdma_t *d,
*/ */
d->sbdma_dscrtable = (sbdmadscr_t *) d->sbdma_dscrtable = (sbdmadscr_t *)
ALIGN((unsigned long)d->sbdma_dscrtable, sizeof(sbdmadscr_t)); ALIGN((unsigned long)d->sbdma_dscrtable, sizeof(sbdmadscr_t));
memset(d->sbdma_dscrtable,0,d->sbdma_maxdescr*sizeof(sbdmadscr_t)); memset(d->sbdma_dscrtable,0,d->sbdma_maxdescr*sizeof(sbdmadscr_t));
d->sbdma_dscrtable_end = d->sbdma_dscrtable + d->sbdma_maxdescr; d->sbdma_dscrtable_end = d->sbdma_dscrtable + d->sbdma_maxdescr;
d->sbdma_dscrtable_phys = virt_to_phys(d->sbdma_dscrtable); d->sbdma_dscrtable_phys = virt_to_phys(d->sbdma_dscrtable);
/* /*
* And context table * And context table
*/ */
d->sbdma_ctxtable = (struct sk_buff **) d->sbdma_ctxtable = (struct sk_buff **)
kmalloc(d->sbdma_maxdescr*sizeof(struct sk_buff *), GFP_KERNEL); kmalloc(d->sbdma_maxdescr*sizeof(struct sk_buff *), GFP_KERNEL);
memset(d->sbdma_ctxtable,0,d->sbdma_maxdescr*sizeof(struct sk_buff *)); memset(d->sbdma_ctxtable,0,d->sbdma_maxdescr*sizeof(struct sk_buff *));
#ifdef CONFIG_SBMAC_COALESCE #ifdef CONFIG_SBMAC_COALESCE
/* /*
* Setup Rx/Tx DMA coalescing defaults * Setup Rx/Tx DMA coalescing defaults
...@@ -753,7 +753,7 @@ static void sbdma_initctx(sbmacdma_t *d, ...@@ -753,7 +753,7 @@ static void sbdma_initctx(sbmacdma_t *d,
} else { } else {
d->sbdma_int_pktcnt = 1; d->sbdma_int_pktcnt = 1;
} }
if ( int_timeout ) { if ( int_timeout ) {
d->sbdma_int_timeout = int_timeout; d->sbdma_int_timeout = int_timeout;
} else { } else {
...@@ -765,13 +765,13 @@ static void sbdma_initctx(sbmacdma_t *d, ...@@ -765,13 +765,13 @@ static void sbdma_initctx(sbmacdma_t *d,
/********************************************************************** /**********************************************************************
* SBDMA_CHANNEL_START(d) * SBDMA_CHANNEL_START(d)
* *
* Initialize the hardware registers for a DMA channel. * Initialize the hardware registers for a DMA channel.
* *
* Input parameters: * Input parameters:
* d - DMA channel to init (context must be previously init'd * d - DMA channel to init (context must be previously init'd
* rxtx - DMA_RX or DMA_TX depending on what type of channel * rxtx - DMA_RX or DMA_TX depending on what type of channel
* *
* Return value: * Return value:
* nothing * nothing
********************************************************************* */ ********************************************************************* */
...@@ -781,7 +781,7 @@ static void sbdma_channel_start(sbmacdma_t *d, int rxtx ) ...@@ -781,7 +781,7 @@ static void sbdma_channel_start(sbmacdma_t *d, int rxtx )
/* /*
* Turn on the DMA channel * Turn on the DMA channel
*/ */
#ifdef CONFIG_SBMAC_COALESCE #ifdef CONFIG_SBMAC_COALESCE
__raw_writeq(V_DMA_INT_TIMEOUT(d->sbdma_int_timeout) | __raw_writeq(V_DMA_INT_TIMEOUT(d->sbdma_int_timeout) |
0, d->sbdma_config1); 0, d->sbdma_config1);
...@@ -807,12 +807,12 @@ static void sbdma_channel_start(sbmacdma_t *d, int rxtx ) ...@@ -807,12 +807,12 @@ static void sbdma_channel_start(sbmacdma_t *d, int rxtx )
/********************************************************************** /**********************************************************************
* SBDMA_CHANNEL_STOP(d) * SBDMA_CHANNEL_STOP(d)
* *
* Initialize the hardware registers for a DMA channel. * Initialize the hardware registers for a DMA channel.
* *
* Input parameters: * Input parameters:
* d - DMA channel to init (context must be previously init'd * d - DMA channel to init (context must be previously init'd
* *
* Return value: * Return value:
* nothing * nothing
********************************************************************* */ ********************************************************************* */
...@@ -822,17 +822,17 @@ static void sbdma_channel_stop(sbmacdma_t *d) ...@@ -822,17 +822,17 @@ static void sbdma_channel_stop(sbmacdma_t *d)
/* /*
* Turn off the DMA channel * Turn off the DMA channel
*/ */
__raw_writeq(0, d->sbdma_config1); __raw_writeq(0, d->sbdma_config1);
__raw_writeq(0, d->sbdma_dscrbase); __raw_writeq(0, d->sbdma_dscrbase);
__raw_writeq(0, d->sbdma_config0); __raw_writeq(0, d->sbdma_config0);
/* /*
* Zero ring pointers * Zero ring pointers
*/ */
d->sbdma_addptr = NULL; d->sbdma_addptr = NULL;
d->sbdma_remptr = NULL; d->sbdma_remptr = NULL;
} }
...@@ -841,25 +841,25 @@ static void sbdma_align_skb(struct sk_buff *skb,int power2,int offset) ...@@ -841,25 +841,25 @@ static void sbdma_align_skb(struct sk_buff *skb,int power2,int offset)
{ {
unsigned long addr; unsigned long addr;
unsigned long newaddr; unsigned long newaddr;
addr = (unsigned long) skb->data; addr = (unsigned long) skb->data;
newaddr = (addr + power2 - 1) & ~(power2 - 1); newaddr = (addr + power2 - 1) & ~(power2 - 1);
skb_reserve(skb,newaddr-addr+offset); skb_reserve(skb,newaddr-addr+offset);
} }
/********************************************************************** /**********************************************************************
* SBDMA_ADD_RCVBUFFER(d,sb) * SBDMA_ADD_RCVBUFFER(d,sb)
* *
* Add a buffer to the specified DMA channel. For receive channels, * Add a buffer to the specified DMA channel. For receive channels,
* this queues a buffer for inbound packets. * this queues a buffer for inbound packets.
* *
* Input parameters: * Input parameters:
* d - DMA channel descriptor * d - DMA channel descriptor
* sb - sk_buff to add, or NULL if we should allocate one * sb - sk_buff to add, or NULL if we should allocate one
* *
* Return value: * Return value:
* 0 if buffer could not be added (ring is full) * 0 if buffer could not be added (ring is full)
* 1 if buffer added successfully * 1 if buffer added successfully
...@@ -872,24 +872,24 @@ static int sbdma_add_rcvbuffer(sbmacdma_t *d,struct sk_buff *sb) ...@@ -872,24 +872,24 @@ static int sbdma_add_rcvbuffer(sbmacdma_t *d,struct sk_buff *sb)
sbdmadscr_t *nextdsc; sbdmadscr_t *nextdsc;
struct sk_buff *sb_new = NULL; struct sk_buff *sb_new = NULL;
int pktsize = ENET_PACKET_SIZE; int pktsize = ENET_PACKET_SIZE;
/* get pointer to our current place in the ring */ /* get pointer to our current place in the ring */
dsc = d->sbdma_addptr; dsc = d->sbdma_addptr;
nextdsc = SBDMA_NEXTBUF(d,sbdma_addptr); nextdsc = SBDMA_NEXTBUF(d,sbdma_addptr);
/* /*
* figure out if the ring is full - if the next descriptor * figure out if the ring is full - if the next descriptor
* is the same as the one that we're going to remove from * is the same as the one that we're going to remove from
* the ring, the ring is full * the ring, the ring is full
*/ */
if (nextdsc == d->sbdma_remptr) { if (nextdsc == d->sbdma_remptr) {
return -ENOSPC; return -ENOSPC;
} }
/* /*
* Allocate a sk_buff if we don't already have one. * Allocate a sk_buff if we don't already have one.
* If we do have an sk_buff, reset it so that it's empty. * If we do have an sk_buff, reset it so that it's empty.
* *
* Note: sk_buffs don't seem to be guaranteed to have any sort * Note: sk_buffs don't seem to be guaranteed to have any sort
...@@ -898,7 +898,7 @@ static int sbdma_add_rcvbuffer(sbmacdma_t *d,struct sk_buff *sb) ...@@ -898,7 +898,7 @@ static int sbdma_add_rcvbuffer(sbmacdma_t *d,struct sk_buff *sb)
* *
* 1. the data does not start in the middle of a cache line. * 1. the data does not start in the middle of a cache line.
* 2. The data does not end in the middle of a cache line * 2. The data does not end in the middle of a cache line
* 3. The buffer can be aligned such that the IP addresses are * 3. The buffer can be aligned such that the IP addresses are
* naturally aligned. * naturally aligned.
* *
* Remember, the SOCs MAC writes whole cache lines at a time, * Remember, the SOCs MAC writes whole cache lines at a time,
...@@ -906,7 +906,7 @@ static int sbdma_add_rcvbuffer(sbmacdma_t *d,struct sk_buff *sb) ...@@ -906,7 +906,7 @@ static int sbdma_add_rcvbuffer(sbmacdma_t *d,struct sk_buff *sb)
* data portion starts in the middle of a cache line, the SOC * data portion starts in the middle of a cache line, the SOC
* DMA will trash the beginning (and ending) portions. * DMA will trash the beginning (and ending) portions.
*/ */
if (sb == NULL) { if (sb == NULL) {
sb_new = dev_alloc_skb(ENET_PACKET_SIZE + SMP_CACHE_BYTES * 2 + ETHER_ALIGN); sb_new = dev_alloc_skb(ENET_PACKET_SIZE + SMP_CACHE_BYTES * 2 + ETHER_ALIGN);
if (sb_new == NULL) { if (sb_new == NULL) {
...@@ -922,16 +922,16 @@ static int sbdma_add_rcvbuffer(sbmacdma_t *d,struct sk_buff *sb) ...@@ -922,16 +922,16 @@ static int sbdma_add_rcvbuffer(sbmacdma_t *d,struct sk_buff *sb)
} }
else { else {
sb_new = sb; sb_new = sb;
/* /*
* nothing special to reinit buffer, it's already aligned * nothing special to reinit buffer, it's already aligned
* and sb->data already points to a good place. * and sb->data already points to a good place.
*/ */
} }
/* /*
* fill in the descriptor * fill in the descriptor
*/ */
#ifdef CONFIG_SBMAC_COALESCE #ifdef CONFIG_SBMAC_COALESCE
/* /*
* Do not interrupt per DMA transfer. * Do not interrupt per DMA transfer.
...@@ -946,38 +946,38 @@ static int sbdma_add_rcvbuffer(sbmacdma_t *d,struct sk_buff *sb) ...@@ -946,38 +946,38 @@ static int sbdma_add_rcvbuffer(sbmacdma_t *d,struct sk_buff *sb)
/* receiving: no options */ /* receiving: no options */
dsc->dscr_b = 0; dsc->dscr_b = 0;
/* /*
* fill in the context * fill in the context
*/ */
d->sbdma_ctxtable[dsc-d->sbdma_dscrtable] = sb_new; d->sbdma_ctxtable[dsc-d->sbdma_dscrtable] = sb_new;
/* /*
* point at next packet * point at next packet
*/ */
d->sbdma_addptr = nextdsc; d->sbdma_addptr = nextdsc;
/* /*
* Give the buffer to the DMA engine. * Give the buffer to the DMA engine.
*/ */
__raw_writeq(1, d->sbdma_dscrcnt); __raw_writeq(1, d->sbdma_dscrcnt);
return 0; /* we did it */ return 0; /* we did it */
} }
/********************************************************************** /**********************************************************************
* SBDMA_ADD_TXBUFFER(d,sb) * SBDMA_ADD_TXBUFFER(d,sb)
* *
* Add a transmit buffer to the specified DMA channel, causing a * Add a transmit buffer to the specified DMA channel, causing a
* transmit to start. * transmit to start.
* *
* Input parameters: * Input parameters:
* d - DMA channel descriptor * d - DMA channel descriptor
* sb - sk_buff to add * sb - sk_buff to add
* *
* Return value: * Return value:
* 0 transmit queued successfully * 0 transmit queued successfully
* otherwise error code * otherwise error code
...@@ -991,70 +991,70 @@ static int sbdma_add_txbuffer(sbmacdma_t *d,struct sk_buff *sb) ...@@ -991,70 +991,70 @@ static int sbdma_add_txbuffer(sbmacdma_t *d,struct sk_buff *sb)
uint64_t phys; uint64_t phys;
uint64_t ncb; uint64_t ncb;
int length; int length;
/* get pointer to our current place in the ring */ /* get pointer to our current place in the ring */
dsc = d->sbdma_addptr; dsc = d->sbdma_addptr;
nextdsc = SBDMA_NEXTBUF(d,sbdma_addptr); nextdsc = SBDMA_NEXTBUF(d,sbdma_addptr);
/* /*
* figure out if the ring is full - if the next descriptor * figure out if the ring is full - if the next descriptor
* is the same as the one that we're going to remove from * is the same as the one that we're going to remove from
* the ring, the ring is full * the ring, the ring is full
*/ */
if (nextdsc == d->sbdma_remptr) { if (nextdsc == d->sbdma_remptr) {
return -ENOSPC; return -ENOSPC;
} }
/* /*
* Under Linux, it's not necessary to copy/coalesce buffers * Under Linux, it's not necessary to copy/coalesce buffers
* like it is on NetBSD. We think they're all contiguous, * like it is on NetBSD. We think they're all contiguous,
* but that may not be true for GBE. * but that may not be true for GBE.
*/ */
length = sb->len; length = sb->len;
/* /*
* fill in the descriptor. Note that the number of cache * fill in the descriptor. Note that the number of cache
* blocks in the descriptor is the number of blocks * blocks in the descriptor is the number of blocks
* *spanned*, so we need to add in the offset (if any) * *spanned*, so we need to add in the offset (if any)
* while doing the calculation. * while doing the calculation.
*/ */
phys = virt_to_phys(sb->data); phys = virt_to_phys(sb->data);
ncb = NUMCACHEBLKS(length+(phys & (SMP_CACHE_BYTES - 1))); ncb = NUMCACHEBLKS(length+(phys & (SMP_CACHE_BYTES - 1)));
dsc->dscr_a = phys | dsc->dscr_a = phys |
V_DMA_DSCRA_A_SIZE(ncb) | V_DMA_DSCRA_A_SIZE(ncb) |
#ifndef CONFIG_SBMAC_COALESCE #ifndef CONFIG_SBMAC_COALESCE
M_DMA_DSCRA_INTERRUPT | M_DMA_DSCRA_INTERRUPT |
#endif #endif
M_DMA_ETHTX_SOP; M_DMA_ETHTX_SOP;
/* transmitting: set outbound options and length */ /* transmitting: set outbound options and length */
dsc->dscr_b = V_DMA_DSCRB_OPTIONS(K_DMA_ETHTX_APPENDCRC_APPENDPAD) | dsc->dscr_b = V_DMA_DSCRB_OPTIONS(K_DMA_ETHTX_APPENDCRC_APPENDPAD) |
V_DMA_DSCRB_PKT_SIZE(length); V_DMA_DSCRB_PKT_SIZE(length);
/* /*
* fill in the context * fill in the context
*/ */
d->sbdma_ctxtable[dsc-d->sbdma_dscrtable] = sb; d->sbdma_ctxtable[dsc-d->sbdma_dscrtable] = sb;
/* /*
* point at next packet * point at next packet
*/ */
d->sbdma_addptr = nextdsc; d->sbdma_addptr = nextdsc;
/* /*
* Give the buffer to the DMA engine. * Give the buffer to the DMA engine.
*/ */
__raw_writeq(1, d->sbdma_dscrcnt); __raw_writeq(1, d->sbdma_dscrcnt);
return 0; /* we did it */ return 0; /* we did it */
} }
...@@ -1063,12 +1063,12 @@ static int sbdma_add_txbuffer(sbmacdma_t *d,struct sk_buff *sb) ...@@ -1063,12 +1063,12 @@ static int sbdma_add_txbuffer(sbmacdma_t *d,struct sk_buff *sb)
/********************************************************************** /**********************************************************************
* SBDMA_EMPTYRING(d) * SBDMA_EMPTYRING(d)
* *
* Free all allocated sk_buffs on the specified DMA channel; * Free all allocated sk_buffs on the specified DMA channel;
* *
* Input parameters: * Input parameters:
* d - DMA channel * d - DMA channel
* *
* Return value: * Return value:
* nothing * nothing
********************************************************************* */ ********************************************************************* */
...@@ -1077,7 +1077,7 @@ static void sbdma_emptyring(sbmacdma_t *d) ...@@ -1077,7 +1077,7 @@ static void sbdma_emptyring(sbmacdma_t *d)
{ {
int idx; int idx;
struct sk_buff *sb; struct sk_buff *sb;
for (idx = 0; idx < d->sbdma_maxdescr; idx++) { for (idx = 0; idx < d->sbdma_maxdescr; idx++) {
sb = d->sbdma_ctxtable[idx]; sb = d->sbdma_ctxtable[idx];
if (sb) { if (sb) {
...@@ -1090,13 +1090,13 @@ static void sbdma_emptyring(sbmacdma_t *d) ...@@ -1090,13 +1090,13 @@ static void sbdma_emptyring(sbmacdma_t *d)
/********************************************************************** /**********************************************************************
* SBDMA_FILLRING(d) * SBDMA_FILLRING(d)
* *
* Fill the specified DMA channel (must be receive channel) * Fill the specified DMA channel (must be receive channel)
* with sk_buffs * with sk_buffs
* *
* Input parameters: * Input parameters:
* d - DMA channel * d - DMA channel
* *
* Return value: * Return value:
* nothing * nothing
********************************************************************* */ ********************************************************************* */
...@@ -1104,7 +1104,7 @@ static void sbdma_emptyring(sbmacdma_t *d) ...@@ -1104,7 +1104,7 @@ static void sbdma_emptyring(sbmacdma_t *d)
static void sbdma_fillring(sbmacdma_t *d) static void sbdma_fillring(sbmacdma_t *d)
{ {
int idx; int idx;
for (idx = 0; idx < SBMAC_MAX_RXDESCR-1; idx++) { for (idx = 0; idx < SBMAC_MAX_RXDESCR-1; idx++) {
if (sbdma_add_rcvbuffer(d,NULL) != 0) if (sbdma_add_rcvbuffer(d,NULL) != 0)
break; break;
...@@ -1114,16 +1114,16 @@ static void sbdma_fillring(sbmacdma_t *d) ...@@ -1114,16 +1114,16 @@ static void sbdma_fillring(sbmacdma_t *d)
/********************************************************************** /**********************************************************************
* SBDMA_RX_PROCESS(sc,d) * SBDMA_RX_PROCESS(sc,d)
* *
* Process "completed" receive buffers on the specified DMA channel. * Process "completed" receive buffers on the specified DMA channel.
* Note that this isn't really ideal for priority channels, since * Note that this isn't really ideal for priority channels, since
* it processes all of the packets on a given channel before * it processes all of the packets on a given channel before
* returning. * returning.
* *
* Input parameters: * Input parameters:
* sc - softc structure * sc - softc structure
* d - DMA channel context * d - DMA channel context
* *
* Return value: * Return value:
* nothing * nothing
********************************************************************* */ ********************************************************************* */
...@@ -1135,56 +1135,56 @@ static void sbdma_rx_process(struct sbmac_softc *sc,sbmacdma_t *d) ...@@ -1135,56 +1135,56 @@ static void sbdma_rx_process(struct sbmac_softc *sc,sbmacdma_t *d)
sbdmadscr_t *dsc; sbdmadscr_t *dsc;
struct sk_buff *sb; struct sk_buff *sb;
int len; int len;
for (;;) { for (;;) {
/* /*
* figure out where we are (as an index) and where * figure out where we are (as an index) and where
* the hardware is (also as an index) * the hardware is (also as an index)
* *
* This could be done faster if (for example) the * This could be done faster if (for example) the
* descriptor table was page-aligned and contiguous in * descriptor table was page-aligned and contiguous in
* both virtual and physical memory -- you could then * both virtual and physical memory -- you could then
* just compare the low-order bits of the virtual address * just compare the low-order bits of the virtual address
* (sbdma_remptr) and the physical address (sbdma_curdscr CSR) * (sbdma_remptr) and the physical address (sbdma_curdscr CSR)
*/ */
curidx = d->sbdma_remptr - d->sbdma_dscrtable; curidx = d->sbdma_remptr - d->sbdma_dscrtable;
hwidx = (int) (((__raw_readq(d->sbdma_curdscr) & M_DMA_CURDSCR_ADDR) - hwidx = (int) (((__raw_readq(d->sbdma_curdscr) & M_DMA_CURDSCR_ADDR) -
d->sbdma_dscrtable_phys) / sizeof(sbdmadscr_t)); d->sbdma_dscrtable_phys) / sizeof(sbdmadscr_t));
/* /*
* If they're the same, that means we've processed all * If they're the same, that means we've processed all
* of the descriptors up to (but not including) the one that * of the descriptors up to (but not including) the one that
* the hardware is working on right now. * the hardware is working on right now.
*/ */
if (curidx == hwidx) if (curidx == hwidx)
break; break;
/* /*
* Otherwise, get the packet's sk_buff ptr back * Otherwise, get the packet's sk_buff ptr back
*/ */
dsc = &(d->sbdma_dscrtable[curidx]); dsc = &(d->sbdma_dscrtable[curidx]);
sb = d->sbdma_ctxtable[curidx]; sb = d->sbdma_ctxtable[curidx];
d->sbdma_ctxtable[curidx] = NULL; d->sbdma_ctxtable[curidx] = NULL;
len = (int)G_DMA_DSCRB_PKT_SIZE(dsc->dscr_b) - 4; len = (int)G_DMA_DSCRB_PKT_SIZE(dsc->dscr_b) - 4;
/* /*
* Check packet status. If good, process it. * Check packet status. If good, process it.
* If not, silently drop it and put it back on the * If not, silently drop it and put it back on the
* receive ring. * receive ring.
*/ */
if (!(dsc->dscr_a & M_DMA_ETHRX_BAD)) { if (!(dsc->dscr_a & M_DMA_ETHRX_BAD)) {
/* /*
* Add a new buffer to replace the old one. If we fail * Add a new buffer to replace the old one. If we fail
* to allocate a buffer, we're going to drop this * to allocate a buffer, we're going to drop this
* packet and put it right back on the receive ring. * packet and put it right back on the receive ring.
*/ */
if (sbdma_add_rcvbuffer(d,NULL) == -ENOBUFS) { if (sbdma_add_rcvbuffer(d,NULL) == -ENOBUFS) {
sc->sbm_stats.rx_dropped++; sc->sbm_stats.rx_dropped++;
sbdma_add_rcvbuffer(d,sb); /* re-add old buffer */ sbdma_add_rcvbuffer(d,sb); /* re-add old buffer */
...@@ -1193,7 +1193,7 @@ static void sbdma_rx_process(struct sbmac_softc *sc,sbmacdma_t *d) ...@@ -1193,7 +1193,7 @@ static void sbdma_rx_process(struct sbmac_softc *sc,sbmacdma_t *d)
* Set length into the packet * Set length into the packet
*/ */
skb_put(sb,len); skb_put(sb,len);
/* /*
* Buffer has been replaced on the * Buffer has been replaced on the
* receive ring. Pass the buffer to * receive ring. Pass the buffer to
...@@ -1212,7 +1212,7 @@ static void sbdma_rx_process(struct sbmac_softc *sc,sbmacdma_t *d) ...@@ -1212,7 +1212,7 @@ static void sbdma_rx_process(struct sbmac_softc *sc,sbmacdma_t *d)
sb->ip_summed = CHECKSUM_NONE; sb->ip_summed = CHECKSUM_NONE;
} }
} }
netif_rx(sb); netif_rx(sb);
} }
} else { } else {
...@@ -1223,14 +1223,14 @@ static void sbdma_rx_process(struct sbmac_softc *sc,sbmacdma_t *d) ...@@ -1223,14 +1223,14 @@ static void sbdma_rx_process(struct sbmac_softc *sc,sbmacdma_t *d)
sc->sbm_stats.rx_errors++; sc->sbm_stats.rx_errors++;
sbdma_add_rcvbuffer(d,sb); sbdma_add_rcvbuffer(d,sb);
} }
/* /*
* .. and advance to the next buffer. * .. and advance to the next buffer.
*/ */
d->sbdma_remptr = SBDMA_NEXTBUF(d,sbdma_remptr); d->sbdma_remptr = SBDMA_NEXTBUF(d,sbdma_remptr);
} }
} }
...@@ -1238,17 +1238,17 @@ static void sbdma_rx_process(struct sbmac_softc *sc,sbmacdma_t *d) ...@@ -1238,17 +1238,17 @@ static void sbdma_rx_process(struct sbmac_softc *sc,sbmacdma_t *d)
/********************************************************************** /**********************************************************************
* SBDMA_TX_PROCESS(sc,d) * SBDMA_TX_PROCESS(sc,d)
* *
* Process "completed" transmit buffers on the specified DMA channel. * Process "completed" transmit buffers on the specified DMA channel.
* This is normally called within the interrupt service routine. * This is normally called within the interrupt service routine.
* Note that this isn't really ideal for priority channels, since * Note that this isn't really ideal for priority channels, since
* it processes all of the packets on a given channel before * it processes all of the packets on a given channel before
* returning. * returning.
* *
* Input parameters: * Input parameters:
* sc - softc structure * sc - softc structure
* d - DMA channel context * d - DMA channel context
* *
* Return value: * Return value:
* nothing * nothing
********************************************************************* */ ********************************************************************* */
...@@ -1262,19 +1262,19 @@ static void sbdma_tx_process(struct sbmac_softc *sc,sbmacdma_t *d) ...@@ -1262,19 +1262,19 @@ static void sbdma_tx_process(struct sbmac_softc *sc,sbmacdma_t *d)
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&(sc->sbm_lock), flags); spin_lock_irqsave(&(sc->sbm_lock), flags);
for (;;) { for (;;) {
/* /*
* figure out where we are (as an index) and where * figure out where we are (as an index) and where
* the hardware is (also as an index) * the hardware is (also as an index)
* *
* This could be done faster if (for example) the * This could be done faster if (for example) the
* descriptor table was page-aligned and contiguous in * descriptor table was page-aligned and contiguous in
* both virtual and physical memory -- you could then * both virtual and physical memory -- you could then
* just compare the low-order bits of the virtual address * just compare the low-order bits of the virtual address
* (sbdma_remptr) and the physical address (sbdma_curdscr CSR) * (sbdma_remptr) and the physical address (sbdma_curdscr CSR)
*/ */
curidx = d->sbdma_remptr - d->sbdma_dscrtable; curidx = d->sbdma_remptr - d->sbdma_dscrtable;
hwidx = (int) (((__raw_readq(d->sbdma_curdscr) & M_DMA_CURDSCR_ADDR) - hwidx = (int) (((__raw_readq(d->sbdma_curdscr) & M_DMA_CURDSCR_ADDR) -
d->sbdma_dscrtable_phys) / sizeof(sbdmadscr_t)); d->sbdma_dscrtable_phys) / sizeof(sbdmadscr_t));
...@@ -1284,75 +1284,75 @@ static void sbdma_tx_process(struct sbmac_softc *sc,sbmacdma_t *d) ...@@ -1284,75 +1284,75 @@ static void sbdma_tx_process(struct sbmac_softc *sc,sbmacdma_t *d)
* of the descriptors up to (but not including) the one that * of the descriptors up to (but not including) the one that
* the hardware is working on right now. * the hardware is working on right now.
*/ */
if (curidx == hwidx) if (curidx == hwidx)
break; break;
/* /*
* Otherwise, get the packet's sk_buff ptr back * Otherwise, get the packet's sk_buff ptr back
*/ */
dsc = &(d->sbdma_dscrtable[curidx]); dsc = &(d->sbdma_dscrtable[curidx]);
sb = d->sbdma_ctxtable[curidx]; sb = d->sbdma_ctxtable[curidx];
d->sbdma_ctxtable[curidx] = NULL; d->sbdma_ctxtable[curidx] = NULL;
/* /*
* Stats * Stats
*/ */
sc->sbm_stats.tx_bytes += sb->len; sc->sbm_stats.tx_bytes += sb->len;
sc->sbm_stats.tx_packets++; sc->sbm_stats.tx_packets++;
/* /*
* for transmits, we just free buffers. * for transmits, we just free buffers.
*/ */
dev_kfree_skb_irq(sb); dev_kfree_skb_irq(sb);
/* /*
* .. and advance to the next buffer. * .. and advance to the next buffer.
*/ */
d->sbdma_remptr = SBDMA_NEXTBUF(d,sbdma_remptr); d->sbdma_remptr = SBDMA_NEXTBUF(d,sbdma_remptr);
} }
/* /*
* Decide if we should wake up the protocol or not. * Decide if we should wake up the protocol or not.
* Other drivers seem to do this when we reach a low * Other drivers seem to do this when we reach a low
* watermark on the transmit queue. * watermark on the transmit queue.
*/ */
netif_wake_queue(d->sbdma_eth->sbm_dev); netif_wake_queue(d->sbdma_eth->sbm_dev);
spin_unlock_irqrestore(&(sc->sbm_lock), flags); spin_unlock_irqrestore(&(sc->sbm_lock), flags);
} }
/********************************************************************** /**********************************************************************
* SBMAC_INITCTX(s) * SBMAC_INITCTX(s)
* *
* Initialize an Ethernet context structure - this is called * Initialize an Ethernet context structure - this is called
* once per MAC on the 1250. Memory is allocated here, so don't * once per MAC on the 1250. Memory is allocated here, so don't
* call it again from inside the ioctl routines that bring the * call it again from inside the ioctl routines that bring the
* interface up/down * interface up/down
* *
* Input parameters: * Input parameters:
* s - sbmac context structure * s - sbmac context structure
* *
* Return value: * Return value:
* 0 * 0
********************************************************************* */ ********************************************************************* */
static int sbmac_initctx(struct sbmac_softc *s) static int sbmac_initctx(struct sbmac_softc *s)
{ {
/* /*
* figure out the addresses of some ports * figure out the addresses of some ports
*/ */
s->sbm_macenable = s->sbm_base + R_MAC_ENABLE; s->sbm_macenable = s->sbm_base + R_MAC_ENABLE;
s->sbm_maccfg = s->sbm_base + R_MAC_CFG; s->sbm_maccfg = s->sbm_base + R_MAC_CFG;
s->sbm_fifocfg = s->sbm_base + R_MAC_THRSH_CFG; s->sbm_fifocfg = s->sbm_base + R_MAC_THRSH_CFG;
...@@ -1369,29 +1369,29 @@ static int sbmac_initctx(struct sbmac_softc *s) ...@@ -1369,29 +1369,29 @@ static int sbmac_initctx(struct sbmac_softc *s)
s->sbm_phy_oldanlpar = 0; s->sbm_phy_oldanlpar = 0;
s->sbm_phy_oldk1stsr = 0; s->sbm_phy_oldk1stsr = 0;
s->sbm_phy_oldlinkstat = 0; s->sbm_phy_oldlinkstat = 0;
/* /*
* Initialize the DMA channels. Right now, only one per MAC is used * Initialize the DMA channels. Right now, only one per MAC is used
* Note: Only do this _once_, as it allocates memory from the kernel! * Note: Only do this _once_, as it allocates memory from the kernel!
*/ */
sbdma_initctx(&(s->sbm_txdma),s,0,DMA_TX,SBMAC_MAX_TXDESCR); sbdma_initctx(&(s->sbm_txdma),s,0,DMA_TX,SBMAC_MAX_TXDESCR);
sbdma_initctx(&(s->sbm_rxdma),s,0,DMA_RX,SBMAC_MAX_RXDESCR); sbdma_initctx(&(s->sbm_rxdma),s,0,DMA_RX,SBMAC_MAX_RXDESCR);
/* /*
* initial state is OFF * initial state is OFF
*/ */
s->sbm_state = sbmac_state_off; s->sbm_state = sbmac_state_off;
/* /*
* Initial speed is (XXX TEMP) 10MBit/s HDX no FC * Initial speed is (XXX TEMP) 10MBit/s HDX no FC
*/ */
s->sbm_speed = sbmac_speed_10; s->sbm_speed = sbmac_speed_10;
s->sbm_duplex = sbmac_duplex_half; s->sbm_duplex = sbmac_duplex_half;
s->sbm_fc = sbmac_fc_disabled; s->sbm_fc = sbmac_fc_disabled;
return 0; return 0;
} }
...@@ -1402,7 +1402,7 @@ static void sbdma_uninitctx(struct sbmacdma_s *d) ...@@ -1402,7 +1402,7 @@ static void sbdma_uninitctx(struct sbmacdma_s *d)
kfree(d->sbdma_dscrtable); kfree(d->sbdma_dscrtable);
d->sbdma_dscrtable = NULL; d->sbdma_dscrtable = NULL;
} }
if (d->sbdma_ctxtable) { if (d->sbdma_ctxtable) {
kfree(d->sbdma_ctxtable); kfree(d->sbdma_ctxtable);
d->sbdma_ctxtable = NULL; d->sbdma_ctxtable = NULL;
...@@ -1419,12 +1419,12 @@ static void sbmac_uninitctx(struct sbmac_softc *sc) ...@@ -1419,12 +1419,12 @@ static void sbmac_uninitctx(struct sbmac_softc *sc)
/********************************************************************** /**********************************************************************
* SBMAC_CHANNEL_START(s) * SBMAC_CHANNEL_START(s)
* *
* Start packet processing on this MAC. * Start packet processing on this MAC.
* *
* Input parameters: * Input parameters:
* s - sbmac structure * s - sbmac structure
* *
* Return value: * Return value:
* nothing * nothing
********************************************************************* */ ********************************************************************* */
...@@ -1435,46 +1435,46 @@ static void sbmac_channel_start(struct sbmac_softc *s) ...@@ -1435,46 +1435,46 @@ static void sbmac_channel_start(struct sbmac_softc *s)
volatile void __iomem *port; volatile void __iomem *port;
uint64_t cfg,fifo,framecfg; uint64_t cfg,fifo,framecfg;
int idx, th_value; int idx, th_value;
/* /*
* Don't do this if running * Don't do this if running
*/ */
if (s->sbm_state == sbmac_state_on) if (s->sbm_state == sbmac_state_on)
return; return;
/* /*
* Bring the controller out of reset, but leave it off. * Bring the controller out of reset, but leave it off.
*/ */
__raw_writeq(0, s->sbm_macenable); __raw_writeq(0, s->sbm_macenable);
/* /*
* Ignore all received packets * Ignore all received packets
*/ */
__raw_writeq(0, s->sbm_rxfilter); __raw_writeq(0, s->sbm_rxfilter);
/* /*
* Calculate values for various control registers. * Calculate values for various control registers.
*/ */
cfg = M_MAC_RETRY_EN | cfg = M_MAC_RETRY_EN |
M_MAC_TX_HOLD_SOP_EN | M_MAC_TX_HOLD_SOP_EN |
V_MAC_TX_PAUSE_CNT_16K | V_MAC_TX_PAUSE_CNT_16K |
M_MAC_AP_STAT_EN | M_MAC_AP_STAT_EN |
M_MAC_FAST_SYNC | M_MAC_FAST_SYNC |
M_MAC_SS_EN | M_MAC_SS_EN |
0; 0;
/* /*
* Be sure that RD_THRSH+WR_THRSH <= 32 for pass1 pars * Be sure that RD_THRSH+WR_THRSH <= 32 for pass1 pars
* and make sure that RD_THRSH + WR_THRSH <=128 for pass2 and above * and make sure that RD_THRSH + WR_THRSH <=128 for pass2 and above
* Use a larger RD_THRSH for gigabit * Use a larger RD_THRSH for gigabit
*/ */
if (periph_rev >= 2) if (periph_rev >= 2)
th_value = 64; th_value = 64;
else else
th_value = 28; th_value = 28;
fifo = V_MAC_TX_WR_THRSH(4) | /* Must be '4' or '8' */ fifo = V_MAC_TX_WR_THRSH(4) | /* Must be '4' or '8' */
...@@ -1492,29 +1492,29 @@ static void sbmac_channel_start(struct sbmac_softc *s) ...@@ -1492,29 +1492,29 @@ static void sbmac_channel_start(struct sbmac_softc *s)
V_MAC_BACKOFF_SEL(1); V_MAC_BACKOFF_SEL(1);
/* /*
* Clear out the hash address map * Clear out the hash address map
*/ */
port = s->sbm_base + R_MAC_HASH_BASE; port = s->sbm_base + R_MAC_HASH_BASE;
for (idx = 0; idx < MAC_HASH_COUNT; idx++) { for (idx = 0; idx < MAC_HASH_COUNT; idx++) {
__raw_writeq(0, port); __raw_writeq(0, port);
port += sizeof(uint64_t); port += sizeof(uint64_t);
} }
/* /*
* Clear out the exact-match table * Clear out the exact-match table
*/ */
port = s->sbm_base + R_MAC_ADDR_BASE; port = s->sbm_base + R_MAC_ADDR_BASE;
for (idx = 0; idx < MAC_ADDR_COUNT; idx++) { for (idx = 0; idx < MAC_ADDR_COUNT; idx++) {
__raw_writeq(0, port); __raw_writeq(0, port);
port += sizeof(uint64_t); port += sizeof(uint64_t);
} }
/* /*
* Clear out the DMA Channel mapping table registers * Clear out the DMA Channel mapping table registers
*/ */
port = s->sbm_base + R_MAC_CHUP0_BASE; port = s->sbm_base + R_MAC_CHUP0_BASE;
for (idx = 0; idx < MAC_CHMAP_COUNT; idx++) { for (idx = 0; idx < MAC_CHMAP_COUNT; idx++) {
__raw_writeq(0, port); __raw_writeq(0, port);
...@@ -1527,14 +1527,14 @@ static void sbmac_channel_start(struct sbmac_softc *s) ...@@ -1527,14 +1527,14 @@ static void sbmac_channel_start(struct sbmac_softc *s)
__raw_writeq(0, port); __raw_writeq(0, port);
port += sizeof(uint64_t); port += sizeof(uint64_t);
} }
/* /*
* Program the hardware address. It goes into the hardware-address * Program the hardware address. It goes into the hardware-address
* register as well as the first filter register. * register as well as the first filter register.
*/ */
reg = sbmac_addr2reg(s->sbm_hwaddr); reg = sbmac_addr2reg(s->sbm_hwaddr);
port = s->sbm_base + R_MAC_ADDR_BASE; port = s->sbm_base + R_MAC_ADDR_BASE;
__raw_writeq(reg, port); __raw_writeq(reg, port);
port = s->sbm_base + R_MAC_ETHERNET_ADDR; port = s->sbm_base + R_MAC_ETHERNET_ADDR;
...@@ -1549,48 +1549,48 @@ static void sbmac_channel_start(struct sbmac_softc *s) ...@@ -1549,48 +1549,48 @@ static void sbmac_channel_start(struct sbmac_softc *s)
#else #else
__raw_writeq(reg, port); __raw_writeq(reg, port);
#endif #endif
/* /*
* Set the receive filter for no packets, and write values * Set the receive filter for no packets, and write values
* to the various config registers * to the various config registers
*/ */
__raw_writeq(0, s->sbm_rxfilter); __raw_writeq(0, s->sbm_rxfilter);
__raw_writeq(0, s->sbm_imr); __raw_writeq(0, s->sbm_imr);
__raw_writeq(framecfg, s->sbm_framecfg); __raw_writeq(framecfg, s->sbm_framecfg);
__raw_writeq(fifo, s->sbm_fifocfg); __raw_writeq(fifo, s->sbm_fifocfg);
__raw_writeq(cfg, s->sbm_maccfg); __raw_writeq(cfg, s->sbm_maccfg);
/* /*
* Initialize DMA channels (rings should be ok now) * Initialize DMA channels (rings should be ok now)
*/ */
sbdma_channel_start(&(s->sbm_rxdma), DMA_RX); sbdma_channel_start(&(s->sbm_rxdma), DMA_RX);
sbdma_channel_start(&(s->sbm_txdma), DMA_TX); sbdma_channel_start(&(s->sbm_txdma), DMA_TX);
/* /*
* Configure the speed, duplex, and flow control * Configure the speed, duplex, and flow control
*/ */
sbmac_set_speed(s,s->sbm_speed); sbmac_set_speed(s,s->sbm_speed);
sbmac_set_duplex(s,s->sbm_duplex,s->sbm_fc); sbmac_set_duplex(s,s->sbm_duplex,s->sbm_fc);
/* /*
* Fill the receive ring * Fill the receive ring
*/ */
sbdma_fillring(&(s->sbm_rxdma)); sbdma_fillring(&(s->sbm_rxdma));
/* /*
* Turn on the rest of the bits in the enable register * Turn on the rest of the bits in the enable register
*/ */
__raw_writeq(M_MAC_RXDMA_EN0 | __raw_writeq(M_MAC_RXDMA_EN0 |
M_MAC_TXDMA_EN0 | M_MAC_TXDMA_EN0 |
M_MAC_RX_ENABLE | M_MAC_RX_ENABLE |
M_MAC_TX_ENABLE, s->sbm_macenable); M_MAC_TX_ENABLE, s->sbm_macenable);
#ifdef CONFIG_SBMAC_COALESCE #ifdef CONFIG_SBMAC_COALESCE
...@@ -1606,44 +1606,44 @@ static void sbmac_channel_start(struct sbmac_softc *s) ...@@ -1606,44 +1606,44 @@ static void sbmac_channel_start(struct sbmac_softc *s)
__raw_writeq((M_MAC_INT_CHANNEL << S_MAC_TX_CH0) | __raw_writeq((M_MAC_INT_CHANNEL << S_MAC_TX_CH0) |
(M_MAC_INT_CHANNEL << S_MAC_RX_CH0), s->sbm_imr); (M_MAC_INT_CHANNEL << S_MAC_RX_CH0), s->sbm_imr);
#endif #endif
/* /*
* Enable receiving unicasts and broadcasts * Enable receiving unicasts and broadcasts
*/ */
__raw_writeq(M_MAC_UCAST_EN | M_MAC_BCAST_EN, s->sbm_rxfilter); __raw_writeq(M_MAC_UCAST_EN | M_MAC_BCAST_EN, s->sbm_rxfilter);
/* /*
* we're running now. * we're running now.
*/ */
s->sbm_state = sbmac_state_on; s->sbm_state = sbmac_state_on;
/* /*
* Program multicast addresses * Program multicast addresses
*/ */
sbmac_setmulti(s); sbmac_setmulti(s);
/* /*
* If channel was in promiscuous mode before, turn that on * If channel was in promiscuous mode before, turn that on
*/ */
if (s->sbm_devflags & IFF_PROMISC) { if (s->sbm_devflags & IFF_PROMISC) {
sbmac_promiscuous_mode(s,1); sbmac_promiscuous_mode(s,1);
} }
} }
/********************************************************************** /**********************************************************************
* SBMAC_CHANNEL_STOP(s) * SBMAC_CHANNEL_STOP(s)
* *
* Stop packet processing on this MAC. * Stop packet processing on this MAC.
* *
* Input parameters: * Input parameters:
* s - sbmac structure * s - sbmac structure
* *
* Return value: * Return value:
* nothing * nothing
********************************************************************* */ ********************************************************************* */
...@@ -1651,49 +1651,49 @@ static void sbmac_channel_start(struct sbmac_softc *s) ...@@ -1651,49 +1651,49 @@ static void sbmac_channel_start(struct sbmac_softc *s)
static void sbmac_channel_stop(struct sbmac_softc *s) static void sbmac_channel_stop(struct sbmac_softc *s)
{ {
/* don't do this if already stopped */ /* don't do this if already stopped */
if (s->sbm_state == sbmac_state_off) if (s->sbm_state == sbmac_state_off)
return; return;
/* don't accept any packets, disable all interrupts */ /* don't accept any packets, disable all interrupts */
__raw_writeq(0, s->sbm_rxfilter); __raw_writeq(0, s->sbm_rxfilter);
__raw_writeq(0, s->sbm_imr); __raw_writeq(0, s->sbm_imr);
/* Turn off ticker */ /* Turn off ticker */
/* XXX */ /* XXX */
/* turn off receiver and transmitter */ /* turn off receiver and transmitter */
__raw_writeq(0, s->sbm_macenable); __raw_writeq(0, s->sbm_macenable);
/* We're stopped now. */ /* We're stopped now. */
s->sbm_state = sbmac_state_off; s->sbm_state = sbmac_state_off;
/* /*
* Stop DMA channels (rings should be ok now) * Stop DMA channels (rings should be ok now)
*/ */
sbdma_channel_stop(&(s->sbm_rxdma)); sbdma_channel_stop(&(s->sbm_rxdma));
sbdma_channel_stop(&(s->sbm_txdma)); sbdma_channel_stop(&(s->sbm_txdma));
/* Empty the receive and transmit rings */ /* Empty the receive and transmit rings */
sbdma_emptyring(&(s->sbm_rxdma)); sbdma_emptyring(&(s->sbm_rxdma));
sbdma_emptyring(&(s->sbm_txdma)); sbdma_emptyring(&(s->sbm_txdma));
} }
/********************************************************************** /**********************************************************************
* SBMAC_SET_CHANNEL_STATE(state) * SBMAC_SET_CHANNEL_STATE(state)
* *
* Set the channel's state ON or OFF * Set the channel's state ON or OFF
* *
* Input parameters: * Input parameters:
* state - new state * state - new state
* *
* Return value: * Return value:
* old state * old state
********************************************************************* */ ********************************************************************* */
...@@ -1701,43 +1701,43 @@ static sbmac_state_t sbmac_set_channel_state(struct sbmac_softc *sc, ...@@ -1701,43 +1701,43 @@ static sbmac_state_t sbmac_set_channel_state(struct sbmac_softc *sc,
sbmac_state_t state) sbmac_state_t state)
{ {
sbmac_state_t oldstate = sc->sbm_state; sbmac_state_t oldstate = sc->sbm_state;
/* /*
* If same as previous state, return * If same as previous state, return
*/ */
if (state == oldstate) { if (state == oldstate) {
return oldstate; return oldstate;
} }
/* /*
* If new state is ON, turn channel on * If new state is ON, turn channel on
*/ */
if (state == sbmac_state_on) { if (state == sbmac_state_on) {
sbmac_channel_start(sc); sbmac_channel_start(sc);
} }
else { else {
sbmac_channel_stop(sc); sbmac_channel_stop(sc);
} }
/* /*
* Return previous state * Return previous state
*/ */
return oldstate; return oldstate;
} }
/********************************************************************** /**********************************************************************
* SBMAC_PROMISCUOUS_MODE(sc,onoff) * SBMAC_PROMISCUOUS_MODE(sc,onoff)
* *
* Turn on or off promiscuous mode * Turn on or off promiscuous mode
* *
* Input parameters: * Input parameters:
* sc - softc * sc - softc
* onoff - 1 to turn on, 0 to turn off * onoff - 1 to turn on, 0 to turn off
* *
* Return value: * Return value:
* nothing * nothing
********************************************************************* */ ********************************************************************* */
...@@ -1745,15 +1745,15 @@ static sbmac_state_t sbmac_set_channel_state(struct sbmac_softc *sc, ...@@ -1745,15 +1745,15 @@ static sbmac_state_t sbmac_set_channel_state(struct sbmac_softc *sc,
static void sbmac_promiscuous_mode(struct sbmac_softc *sc,int onoff) static void sbmac_promiscuous_mode(struct sbmac_softc *sc,int onoff)
{ {
uint64_t reg; uint64_t reg;
if (sc->sbm_state != sbmac_state_on) if (sc->sbm_state != sbmac_state_on)
return; return;
if (onoff) { if (onoff) {
reg = __raw_readq(sc->sbm_rxfilter); reg = __raw_readq(sc->sbm_rxfilter);
reg |= M_MAC_ALLPKT_EN; reg |= M_MAC_ALLPKT_EN;
__raw_writeq(reg, sc->sbm_rxfilter); __raw_writeq(reg, sc->sbm_rxfilter);
} }
else { else {
reg = __raw_readq(sc->sbm_rxfilter); reg = __raw_readq(sc->sbm_rxfilter);
reg &= ~M_MAC_ALLPKT_EN; reg &= ~M_MAC_ALLPKT_EN;
...@@ -1763,12 +1763,12 @@ static void sbmac_promiscuous_mode(struct sbmac_softc *sc,int onoff) ...@@ -1763,12 +1763,12 @@ static void sbmac_promiscuous_mode(struct sbmac_softc *sc,int onoff)
/********************************************************************** /**********************************************************************
* SBMAC_SETIPHDR_OFFSET(sc,onoff) * SBMAC_SETIPHDR_OFFSET(sc,onoff)
* *
* Set the iphdr offset as 15 assuming ethernet encapsulation * Set the iphdr offset as 15 assuming ethernet encapsulation
* *
* Input parameters: * Input parameters:
* sc - softc * sc - softc
* *
* Return value: * Return value:
* nothing * nothing
********************************************************************* */ ********************************************************************* */
...@@ -1776,12 +1776,12 @@ static void sbmac_promiscuous_mode(struct sbmac_softc *sc,int onoff) ...@@ -1776,12 +1776,12 @@ static void sbmac_promiscuous_mode(struct sbmac_softc *sc,int onoff)
static void sbmac_set_iphdr_offset(struct sbmac_softc *sc) static void sbmac_set_iphdr_offset(struct sbmac_softc *sc)
{ {
uint64_t reg; uint64_t reg;
/* Hard code the off set to 15 for now */ /* Hard code the off set to 15 for now */
reg = __raw_readq(sc->sbm_rxfilter); reg = __raw_readq(sc->sbm_rxfilter);
reg &= ~M_MAC_IPHDR_OFFSET | V_MAC_IPHDR_OFFSET(15); reg &= ~M_MAC_IPHDR_OFFSET | V_MAC_IPHDR_OFFSET(15);
__raw_writeq(reg, sc->sbm_rxfilter); __raw_writeq(reg, sc->sbm_rxfilter);
/* read system identification to determine revision */ /* read system identification to determine revision */
if (periph_rev >= 2) { if (periph_rev >= 2) {
sc->rx_hw_checksum = ENABLE; sc->rx_hw_checksum = ENABLE;
...@@ -1793,13 +1793,13 @@ static void sbmac_set_iphdr_offset(struct sbmac_softc *sc) ...@@ -1793,13 +1793,13 @@ static void sbmac_set_iphdr_offset(struct sbmac_softc *sc)
/********************************************************************** /**********************************************************************
* SBMAC_ADDR2REG(ptr) * SBMAC_ADDR2REG(ptr)
* *
* Convert six bytes into the 64-bit register value that * Convert six bytes into the 64-bit register value that
* we typically write into the SBMAC's address/mcast registers * we typically write into the SBMAC's address/mcast registers
* *
* Input parameters: * Input parameters:
* ptr - pointer to 6 bytes * ptr - pointer to 6 bytes
* *
* Return value: * Return value:
* register value * register value
********************************************************************* */ ********************************************************************* */
...@@ -1807,35 +1807,35 @@ static void sbmac_set_iphdr_offset(struct sbmac_softc *sc) ...@@ -1807,35 +1807,35 @@ static void sbmac_set_iphdr_offset(struct sbmac_softc *sc)
static uint64_t sbmac_addr2reg(unsigned char *ptr) static uint64_t sbmac_addr2reg(unsigned char *ptr)
{ {
uint64_t reg = 0; uint64_t reg = 0;
ptr += 6; ptr += 6;
reg |= (uint64_t) *(--ptr); reg |= (uint64_t) *(--ptr);
reg <<= 8; reg <<= 8;
reg |= (uint64_t) *(--ptr); reg |= (uint64_t) *(--ptr);
reg <<= 8; reg <<= 8;
reg |= (uint64_t) *(--ptr); reg |= (uint64_t) *(--ptr);
reg <<= 8; reg <<= 8;
reg |= (uint64_t) *(--ptr); reg |= (uint64_t) *(--ptr);
reg <<= 8; reg <<= 8;
reg |= (uint64_t) *(--ptr); reg |= (uint64_t) *(--ptr);
reg <<= 8; reg <<= 8;
reg |= (uint64_t) *(--ptr); reg |= (uint64_t) *(--ptr);
return reg; return reg;
} }
/********************************************************************** /**********************************************************************
* SBMAC_SET_SPEED(s,speed) * SBMAC_SET_SPEED(s,speed)
* *
* Configure LAN speed for the specified MAC. * Configure LAN speed for the specified MAC.
* Warning: must be called when MAC is off! * Warning: must be called when MAC is off!
* *
* Input parameters: * Input parameters:
* s - sbmac structure * s - sbmac structure
* speed - speed to set MAC to (see sbmac_speed_t enum) * speed - speed to set MAC to (see sbmac_speed_t enum)
* *
* Return value: * Return value:
* 1 if successful * 1 if successful
* 0 indicates invalid parameters * 0 indicates invalid parameters
...@@ -1849,31 +1849,31 @@ static int sbmac_set_speed(struct sbmac_softc *s,sbmac_speed_t speed) ...@@ -1849,31 +1849,31 @@ static int sbmac_set_speed(struct sbmac_softc *s,sbmac_speed_t speed)
/* /*
* Save new current values * Save new current values
*/ */
s->sbm_speed = speed; s->sbm_speed = speed;
if (s->sbm_state == sbmac_state_on) if (s->sbm_state == sbmac_state_on)
return 0; /* save for next restart */ return 0; /* save for next restart */
/* /*
* Read current register values * Read current register values
*/ */
cfg = __raw_readq(s->sbm_maccfg); cfg = __raw_readq(s->sbm_maccfg);
framecfg = __raw_readq(s->sbm_framecfg); framecfg = __raw_readq(s->sbm_framecfg);
/* /*
* Mask out the stuff we want to change * Mask out the stuff we want to change
*/ */
cfg &= ~(M_MAC_BURST_EN | M_MAC_SPEED_SEL); cfg &= ~(M_MAC_BURST_EN | M_MAC_SPEED_SEL);
framecfg &= ~(M_MAC_IFG_RX | M_MAC_IFG_TX | M_MAC_IFG_THRSH | framecfg &= ~(M_MAC_IFG_RX | M_MAC_IFG_TX | M_MAC_IFG_THRSH |
M_MAC_SLOT_SIZE); M_MAC_SLOT_SIZE);
/* /*
* Now add in the new bits * Now add in the new bits
*/ */
switch (speed) { switch (speed) {
case sbmac_speed_10: case sbmac_speed_10:
framecfg |= V_MAC_IFG_RX_10 | framecfg |= V_MAC_IFG_RX_10 |
...@@ -1882,7 +1882,7 @@ static int sbmac_set_speed(struct sbmac_softc *s,sbmac_speed_t speed) ...@@ -1882,7 +1882,7 @@ static int sbmac_set_speed(struct sbmac_softc *s,sbmac_speed_t speed)
V_MAC_SLOT_SIZE_10; V_MAC_SLOT_SIZE_10;
cfg |= V_MAC_SPEED_SEL_10MBPS; cfg |= V_MAC_SPEED_SEL_10MBPS;
break; break;
case sbmac_speed_100: case sbmac_speed_100:
framecfg |= V_MAC_IFG_RX_100 | framecfg |= V_MAC_IFG_RX_100 |
V_MAC_IFG_TX_100 | V_MAC_IFG_TX_100 |
...@@ -1890,7 +1890,7 @@ static int sbmac_set_speed(struct sbmac_softc *s,sbmac_speed_t speed) ...@@ -1890,7 +1890,7 @@ static int sbmac_set_speed(struct sbmac_softc *s,sbmac_speed_t speed)
V_MAC_SLOT_SIZE_100; V_MAC_SLOT_SIZE_100;
cfg |= V_MAC_SPEED_SEL_100MBPS ; cfg |= V_MAC_SPEED_SEL_100MBPS ;
break; break;
case sbmac_speed_1000: case sbmac_speed_1000:
framecfg |= V_MAC_IFG_RX_1000 | framecfg |= V_MAC_IFG_RX_1000 |
V_MAC_IFG_TX_1000 | V_MAC_IFG_TX_1000 |
...@@ -1898,34 +1898,34 @@ static int sbmac_set_speed(struct sbmac_softc *s,sbmac_speed_t speed) ...@@ -1898,34 +1898,34 @@ static int sbmac_set_speed(struct sbmac_softc *s,sbmac_speed_t speed)
V_MAC_SLOT_SIZE_1000; V_MAC_SLOT_SIZE_1000;
cfg |= V_MAC_SPEED_SEL_1000MBPS | M_MAC_BURST_EN; cfg |= V_MAC_SPEED_SEL_1000MBPS | M_MAC_BURST_EN;
break; break;
case sbmac_speed_auto: /* XXX not implemented */ case sbmac_speed_auto: /* XXX not implemented */
/* fall through */ /* fall through */
default: default:
return 0; return 0;
} }
/* /*
* Send the bits back to the hardware * Send the bits back to the hardware
*/ */
__raw_writeq(framecfg, s->sbm_framecfg); __raw_writeq(framecfg, s->sbm_framecfg);
__raw_writeq(cfg, s->sbm_maccfg); __raw_writeq(cfg, s->sbm_maccfg);
return 1; return 1;
} }
/********************************************************************** /**********************************************************************
* SBMAC_SET_DUPLEX(s,duplex,fc) * SBMAC_SET_DUPLEX(s,duplex,fc)
* *
* Set Ethernet duplex and flow control options for this MAC * Set Ethernet duplex and flow control options for this MAC
* Warning: must be called when MAC is off! * Warning: must be called when MAC is off!
* *
* Input parameters: * Input parameters:
* s - sbmac structure * s - sbmac structure
* duplex - duplex setting (see sbmac_duplex_t) * duplex - duplex setting (see sbmac_duplex_t)
* fc - flow control setting (see sbmac_fc_t) * fc - flow control setting (see sbmac_fc_t)
* *
* Return value: * Return value:
* 1 if ok * 1 if ok
* 0 if an invalid parameter combination was specified * 0 if an invalid parameter combination was specified
...@@ -1934,67 +1934,67 @@ static int sbmac_set_speed(struct sbmac_softc *s,sbmac_speed_t speed) ...@@ -1934,67 +1934,67 @@ static int sbmac_set_speed(struct sbmac_softc *s,sbmac_speed_t speed)
static int sbmac_set_duplex(struct sbmac_softc *s,sbmac_duplex_t duplex,sbmac_fc_t fc) static int sbmac_set_duplex(struct sbmac_softc *s,sbmac_duplex_t duplex,sbmac_fc_t fc)
{ {
uint64_t cfg; uint64_t cfg;
/* /*
* Save new current values * Save new current values
*/ */
s->sbm_duplex = duplex; s->sbm_duplex = duplex;
s->sbm_fc = fc; s->sbm_fc = fc;
if (s->sbm_state == sbmac_state_on) if (s->sbm_state == sbmac_state_on)
return 0; /* save for next restart */ return 0; /* save for next restart */
/* /*
* Read current register values * Read current register values
*/ */
cfg = __raw_readq(s->sbm_maccfg); cfg = __raw_readq(s->sbm_maccfg);
/* /*
* Mask off the stuff we're about to change * Mask off the stuff we're about to change
*/ */
cfg &= ~(M_MAC_FC_SEL | M_MAC_FC_CMD | M_MAC_HDX_EN); cfg &= ~(M_MAC_FC_SEL | M_MAC_FC_CMD | M_MAC_HDX_EN);
switch (duplex) { switch (duplex) {
case sbmac_duplex_half: case sbmac_duplex_half:
switch (fc) { switch (fc) {
case sbmac_fc_disabled: case sbmac_fc_disabled:
cfg |= M_MAC_HDX_EN | V_MAC_FC_CMD_DISABLED; cfg |= M_MAC_HDX_EN | V_MAC_FC_CMD_DISABLED;
break; break;
case sbmac_fc_collision: case sbmac_fc_collision:
cfg |= M_MAC_HDX_EN | V_MAC_FC_CMD_ENABLED; cfg |= M_MAC_HDX_EN | V_MAC_FC_CMD_ENABLED;
break; break;
case sbmac_fc_carrier: case sbmac_fc_carrier:
cfg |= M_MAC_HDX_EN | V_MAC_FC_CMD_ENAB_FALSECARR; cfg |= M_MAC_HDX_EN | V_MAC_FC_CMD_ENAB_FALSECARR;
break; break;
case sbmac_fc_auto: /* XXX not implemented */ case sbmac_fc_auto: /* XXX not implemented */
/* fall through */ /* fall through */
case sbmac_fc_frame: /* not valid in half duplex */ case sbmac_fc_frame: /* not valid in half duplex */
default: /* invalid selection */ default: /* invalid selection */
return 0; return 0;
} }
break; break;
case sbmac_duplex_full: case sbmac_duplex_full:
switch (fc) { switch (fc) {
case sbmac_fc_disabled: case sbmac_fc_disabled:
cfg |= V_MAC_FC_CMD_DISABLED; cfg |= V_MAC_FC_CMD_DISABLED;
break; break;
case sbmac_fc_frame: case sbmac_fc_frame:
cfg |= V_MAC_FC_CMD_ENABLED; cfg |= V_MAC_FC_CMD_ENABLED;
break; break;
case sbmac_fc_collision: /* not valid in full duplex */ case sbmac_fc_collision: /* not valid in full duplex */
case sbmac_fc_carrier: /* not valid in full duplex */ case sbmac_fc_carrier: /* not valid in full duplex */
case sbmac_fc_auto: /* XXX not implemented */ case sbmac_fc_auto: /* XXX not implemented */
/* fall through */ /* fall through */
default: default:
return 0; return 0;
} }
...@@ -2003,13 +2003,13 @@ static int sbmac_set_duplex(struct sbmac_softc *s,sbmac_duplex_t duplex,sbmac_fc ...@@ -2003,13 +2003,13 @@ static int sbmac_set_duplex(struct sbmac_softc *s,sbmac_duplex_t duplex,sbmac_fc
/* XXX not implemented */ /* XXX not implemented */
break; break;
} }
/* /*
* Send the bits back to the hardware * Send the bits back to the hardware
*/ */
__raw_writeq(cfg, s->sbm_maccfg); __raw_writeq(cfg, s->sbm_maccfg);
return 1; return 1;
} }
...@@ -2018,12 +2018,12 @@ static int sbmac_set_duplex(struct sbmac_softc *s,sbmac_duplex_t duplex,sbmac_fc ...@@ -2018,12 +2018,12 @@ static int sbmac_set_duplex(struct sbmac_softc *s,sbmac_duplex_t duplex,sbmac_fc
/********************************************************************** /**********************************************************************
* SBMAC_INTR() * SBMAC_INTR()
* *
* Interrupt handler for MAC interrupts * Interrupt handler for MAC interrupts
* *
* Input parameters: * Input parameters:
* MAC structure * MAC structure
* *
* Return value: * Return value:
* nothing * nothing
********************************************************************* */ ********************************************************************* */
...@@ -2035,27 +2035,27 @@ static irqreturn_t sbmac_intr(int irq,void *dev_instance,struct pt_regs *rgs) ...@@ -2035,27 +2035,27 @@ static irqreturn_t sbmac_intr(int irq,void *dev_instance,struct pt_regs *rgs)
int handled = 0; int handled = 0;
for (;;) { for (;;) {
/* /*
* Read the ISR (this clears the bits in the real * Read the ISR (this clears the bits in the real
* register, except for counter addr) * register, except for counter addr)
*/ */
isr = __raw_readq(sc->sbm_isr) & ~M_MAC_COUNTER_ADDR; isr = __raw_readq(sc->sbm_isr) & ~M_MAC_COUNTER_ADDR;
if (isr == 0) if (isr == 0)
break; break;
handled = 1; handled = 1;
/* /*
* Transmits on channel 0 * Transmits on channel 0
*/ */
if (isr & (M_MAC_INT_CHANNEL << S_MAC_TX_CH0)) { if (isr & (M_MAC_INT_CHANNEL << S_MAC_TX_CH0)) {
sbdma_tx_process(sc,&(sc->sbm_txdma)); sbdma_tx_process(sc,&(sc->sbm_txdma));
} }
/* /*
* Receives on channel 0 * Receives on channel 0
*/ */
...@@ -2075,8 +2075,8 @@ static irqreturn_t sbmac_intr(int irq,void *dev_instance,struct pt_regs *rgs) ...@@ -2075,8 +2075,8 @@ static irqreturn_t sbmac_intr(int irq,void *dev_instance,struct pt_regs *rgs)
* EOP_SEEN here takes care of this case. * EOP_SEEN here takes care of this case.
* (EOP_SEEN is part of M_MAC_INT_CHANNEL << S_MAC_RX_CH0) * (EOP_SEEN is part of M_MAC_INT_CHANNEL << S_MAC_RX_CH0)
*/ */
if (isr & (M_MAC_INT_CHANNEL << S_MAC_RX_CH0)) { if (isr & (M_MAC_INT_CHANNEL << S_MAC_RX_CH0)) {
sbdma_rx_process(sc,&(sc->sbm_rxdma)); sbdma_rx_process(sc,&(sc->sbm_rxdma));
} }
...@@ -2087,29 +2087,29 @@ static irqreturn_t sbmac_intr(int irq,void *dev_instance,struct pt_regs *rgs) ...@@ -2087,29 +2087,29 @@ static irqreturn_t sbmac_intr(int irq,void *dev_instance,struct pt_regs *rgs)
/********************************************************************** /**********************************************************************
* SBMAC_START_TX(skb,dev) * SBMAC_START_TX(skb,dev)
* *
* Start output on the specified interface. Basically, we * Start output on the specified interface. Basically, we
* queue as many buffers as we can until the ring fills up, or * queue as many buffers as we can until the ring fills up, or
* we run off the end of the queue, whichever comes first. * we run off the end of the queue, whichever comes first.
* *
* Input parameters: * Input parameters:
* *
* *
* Return value: * Return value:
* nothing * nothing
********************************************************************* */ ********************************************************************* */
static int sbmac_start_tx(struct sk_buff *skb, struct net_device *dev) static int sbmac_start_tx(struct sk_buff *skb, struct net_device *dev)
{ {
struct sbmac_softc *sc = netdev_priv(dev); struct sbmac_softc *sc = netdev_priv(dev);
/* lock eth irq */ /* lock eth irq */
spin_lock_irq (&sc->sbm_lock); spin_lock_irq (&sc->sbm_lock);
/* /*
* Put the buffer on the transmit ring. If we * Put the buffer on the transmit ring. If we
* don't have room, stop the queue. * don't have room, stop the queue.
*/ */
if (sbdma_add_txbuffer(&(sc->sbm_txdma),skb)) { if (sbdma_add_txbuffer(&(sc->sbm_txdma),skb)) {
/* XXX save skb that we could not send */ /* XXX save skb that we could not send */
netif_stop_queue(dev); netif_stop_queue(dev);
...@@ -2117,24 +2117,24 @@ static int sbmac_start_tx(struct sk_buff *skb, struct net_device *dev) ...@@ -2117,24 +2117,24 @@ static int sbmac_start_tx(struct sk_buff *skb, struct net_device *dev)
return 1; return 1;
} }
dev->trans_start = jiffies; dev->trans_start = jiffies;
spin_unlock_irq (&sc->sbm_lock); spin_unlock_irq (&sc->sbm_lock);
return 0; return 0;
} }
/********************************************************************** /**********************************************************************
* SBMAC_SETMULTI(sc) * SBMAC_SETMULTI(sc)
* *
* Reprogram the multicast table into the hardware, given * Reprogram the multicast table into the hardware, given
* the list of multicasts associated with the interface * the list of multicasts associated with the interface
* structure. * structure.
* *
* Input parameters: * Input parameters:
* sc - softc * sc - softc
* *
* Return value: * Return value:
* nothing * nothing
********************************************************************* */ ********************************************************************* */
...@@ -2146,52 +2146,52 @@ static void sbmac_setmulti(struct sbmac_softc *sc) ...@@ -2146,52 +2146,52 @@ static void sbmac_setmulti(struct sbmac_softc *sc)
int idx; int idx;
struct dev_mc_list *mclist; struct dev_mc_list *mclist;
struct net_device *dev = sc->sbm_dev; struct net_device *dev = sc->sbm_dev;
/* /*
* Clear out entire multicast table. We do this by nuking * Clear out entire multicast table. We do this by nuking
* the entire hash table and all the direct matches except * the entire hash table and all the direct matches except
* the first one, which is used for our station address * the first one, which is used for our station address
*/ */
for (idx = 1; idx < MAC_ADDR_COUNT; idx++) { for (idx = 1; idx < MAC_ADDR_COUNT; idx++) {
port = sc->sbm_base + R_MAC_ADDR_BASE+(idx*sizeof(uint64_t)); port = sc->sbm_base + R_MAC_ADDR_BASE+(idx*sizeof(uint64_t));
__raw_writeq(0, port); __raw_writeq(0, port);
} }
for (idx = 0; idx < MAC_HASH_COUNT; idx++) { for (idx = 0; idx < MAC_HASH_COUNT; idx++) {
port = sc->sbm_base + R_MAC_HASH_BASE+(idx*sizeof(uint64_t)); port = sc->sbm_base + R_MAC_HASH_BASE+(idx*sizeof(uint64_t));
__raw_writeq(0, port); __raw_writeq(0, port);
} }
/* /*
* Clear the filter to say we don't want any multicasts. * Clear the filter to say we don't want any multicasts.
*/ */
reg = __raw_readq(sc->sbm_rxfilter); reg = __raw_readq(sc->sbm_rxfilter);
reg &= ~(M_MAC_MCAST_INV | M_MAC_MCAST_EN); reg &= ~(M_MAC_MCAST_INV | M_MAC_MCAST_EN);
__raw_writeq(reg, sc->sbm_rxfilter); __raw_writeq(reg, sc->sbm_rxfilter);
if (dev->flags & IFF_ALLMULTI) { if (dev->flags & IFF_ALLMULTI) {
/* /*
* Enable ALL multicasts. Do this by inverting the * Enable ALL multicasts. Do this by inverting the
* multicast enable bit. * multicast enable bit.
*/ */
reg = __raw_readq(sc->sbm_rxfilter); reg = __raw_readq(sc->sbm_rxfilter);
reg |= (M_MAC_MCAST_INV | M_MAC_MCAST_EN); reg |= (M_MAC_MCAST_INV | M_MAC_MCAST_EN);
__raw_writeq(reg, sc->sbm_rxfilter); __raw_writeq(reg, sc->sbm_rxfilter);
return; return;
} }
/*
/*
* Progam new multicast entries. For now, only use the * Progam new multicast entries. For now, only use the
* perfect filter. In the future we'll need to use the * perfect filter. In the future we'll need to use the
* hash filter if the perfect filter overflows * hash filter if the perfect filter overflows
*/ */
/* XXX only using perfect filter for now, need to use hash /* XXX only using perfect filter for now, need to use hash
* XXX if the table overflows */ * XXX if the table overflows */
idx = 1; /* skip station address */ idx = 1; /* skip station address */
mclist = dev->mc_list; mclist = dev->mc_list;
while (mclist && (idx < MAC_ADDR_COUNT)) { while (mclist && (idx < MAC_ADDR_COUNT)) {
...@@ -2201,12 +2201,12 @@ static void sbmac_setmulti(struct sbmac_softc *sc) ...@@ -2201,12 +2201,12 @@ static void sbmac_setmulti(struct sbmac_softc *sc)
idx++; idx++;
mclist = mclist->next; mclist = mclist->next;
} }
/* /*
* Enable the "accept multicast bits" if we programmed at least one * Enable the "accept multicast bits" if we programmed at least one
* multicast. * multicast.
*/ */
if (idx > 1) { if (idx > 1) {
reg = __raw_readq(sc->sbm_rxfilter); reg = __raw_readq(sc->sbm_rxfilter);
reg |= M_MAC_MCAST_EN; reg |= M_MAC_MCAST_EN;
...@@ -2219,12 +2219,12 @@ static void sbmac_setmulti(struct sbmac_softc *sc) ...@@ -2219,12 +2219,12 @@ static void sbmac_setmulti(struct sbmac_softc *sc)
#if defined(SBMAC_ETH0_HWADDR) || defined(SBMAC_ETH1_HWADDR) || defined(SBMAC_ETH2_HWADDR) #if defined(SBMAC_ETH0_HWADDR) || defined(SBMAC_ETH1_HWADDR) || defined(SBMAC_ETH2_HWADDR)
/********************************************************************** /**********************************************************************
* SBMAC_PARSE_XDIGIT(str) * SBMAC_PARSE_XDIGIT(str)
* *
* Parse a hex digit, returning its value * Parse a hex digit, returning its value
* *
* Input parameters: * Input parameters:
* str - character * str - character
* *
* Return value: * Return value:
* hex value, or -1 if invalid * hex value, or -1 if invalid
********************************************************************* */ ********************************************************************* */
...@@ -2232,7 +2232,7 @@ static void sbmac_setmulti(struct sbmac_softc *sc) ...@@ -2232,7 +2232,7 @@ static void sbmac_setmulti(struct sbmac_softc *sc)
static int sbmac_parse_xdigit(char str) static int sbmac_parse_xdigit(char str)
{ {
int digit; int digit;
if ((str >= '0') && (str <= '9')) if ((str >= '0') && (str <= '9'))
digit = str - '0'; digit = str - '0';
else if ((str >= 'a') && (str <= 'f')) else if ((str >= 'a') && (str <= 'f'))
...@@ -2241,20 +2241,20 @@ static int sbmac_parse_xdigit(char str) ...@@ -2241,20 +2241,20 @@ static int sbmac_parse_xdigit(char str)
digit = str - 'A' + 10; digit = str - 'A' + 10;
else else
return -1; return -1;
return digit; return digit;
} }
/********************************************************************** /**********************************************************************
* SBMAC_PARSE_HWADDR(str,hwaddr) * SBMAC_PARSE_HWADDR(str,hwaddr)
* *
* Convert a string in the form xx:xx:xx:xx:xx:xx into a 6-byte * Convert a string in the form xx:xx:xx:xx:xx:xx into a 6-byte
* Ethernet address. * Ethernet address.
* *
* Input parameters: * Input parameters:
* str - string * str - string
* hwaddr - pointer to hardware address * hwaddr - pointer to hardware address
* *
* Return value: * Return value:
* 0 if ok, else -1 * 0 if ok, else -1
********************************************************************* */ ********************************************************************* */
...@@ -2263,7 +2263,7 @@ static int sbmac_parse_hwaddr(char *str, unsigned char *hwaddr) ...@@ -2263,7 +2263,7 @@ static int sbmac_parse_hwaddr(char *str, unsigned char *hwaddr)
{ {
int digit1,digit2; int digit1,digit2;
int idx = 6; int idx = 6;
while (*str && (idx > 0)) { while (*str && (idx > 0)) {
digit1 = sbmac_parse_xdigit(*str); digit1 = sbmac_parse_xdigit(*str);
if (digit1 < 0) if (digit1 < 0)
...@@ -2271,7 +2271,7 @@ static int sbmac_parse_hwaddr(char *str, unsigned char *hwaddr) ...@@ -2271,7 +2271,7 @@ static int sbmac_parse_hwaddr(char *str, unsigned char *hwaddr)
str++; str++;
if (!*str) if (!*str)
return -1; return -1;
if ((*str == ':') || (*str == '-')) { if ((*str == ':') || (*str == '-')) {
digit2 = digit1; digit2 = digit1;
digit1 = 0; digit1 = 0;
...@@ -2282,10 +2282,10 @@ static int sbmac_parse_hwaddr(char *str, unsigned char *hwaddr) ...@@ -2282,10 +2282,10 @@ static int sbmac_parse_hwaddr(char *str, unsigned char *hwaddr)
return -1; return -1;
str++; str++;
} }
*hwaddr++ = (digit1 << 4) | digit2; *hwaddr++ = (digit1 << 4) | digit2;
idx--; idx--;
if (*str == '-') if (*str == '-')
str++; str++;
if (*str == ':') if (*str == ':')
...@@ -2306,12 +2306,12 @@ static int sb1250_change_mtu(struct net_device *_dev, int new_mtu) ...@@ -2306,12 +2306,12 @@ static int sb1250_change_mtu(struct net_device *_dev, int new_mtu)
/********************************************************************** /**********************************************************************
* SBMAC_INIT(dev) * SBMAC_INIT(dev)
* *
* Attach routine - init hardware and hook ourselves into linux * Attach routine - init hardware and hook ourselves into linux
* *
* Input parameters: * Input parameters:
* dev - net_device structure * dev - net_device structure
* *
* Return value: * Return value:
* status * status
********************************************************************* */ ********************************************************************* */
...@@ -2323,53 +2323,53 @@ static int sbmac_init(struct net_device *dev, int idx) ...@@ -2323,53 +2323,53 @@ static int sbmac_init(struct net_device *dev, int idx)
uint64_t ea_reg; uint64_t ea_reg;
int i; int i;
int err; int err;
sc = netdev_priv(dev); sc = netdev_priv(dev);
/* Determine controller base address */ /* Determine controller base address */
sc->sbm_base = IOADDR(dev->base_addr); sc->sbm_base = IOADDR(dev->base_addr);
sc->sbm_dev = dev; sc->sbm_dev = dev;
sc->sbe_idx = idx; sc->sbe_idx = idx;
eaddr = sc->sbm_hwaddr; eaddr = sc->sbm_hwaddr;
/* /*
* Read the ethernet address. The firwmare left this programmed * Read the ethernet address. The firwmare left this programmed
* for us in the ethernet address register for each mac. * for us in the ethernet address register for each mac.
*/ */
ea_reg = __raw_readq(sc->sbm_base + R_MAC_ETHERNET_ADDR); ea_reg = __raw_readq(sc->sbm_base + R_MAC_ETHERNET_ADDR);
__raw_writeq(0, sc->sbm_base + R_MAC_ETHERNET_ADDR); __raw_writeq(0, sc->sbm_base + R_MAC_ETHERNET_ADDR);
for (i = 0; i < 6; i++) { for (i = 0; i < 6; i++) {
eaddr[i] = (uint8_t) (ea_reg & 0xFF); eaddr[i] = (uint8_t) (ea_reg & 0xFF);
ea_reg >>= 8; ea_reg >>= 8;
} }
for (i = 0; i < 6; i++) { for (i = 0; i < 6; i++) {
dev->dev_addr[i] = eaddr[i]; dev->dev_addr[i] = eaddr[i];
} }
/* /*
* Init packet size * Init packet size
*/ */
sc->sbm_buffersize = ENET_PACKET_SIZE + SMP_CACHE_BYTES * 2 + ETHER_ALIGN; sc->sbm_buffersize = ENET_PACKET_SIZE + SMP_CACHE_BYTES * 2 + ETHER_ALIGN;
/* /*
* Initialize context (get pointers to registers and stuff), then * Initialize context (get pointers to registers and stuff), then
* allocate the memory for the descriptor tables. * allocate the memory for the descriptor tables.
*/ */
sbmac_initctx(sc); sbmac_initctx(sc);
/* /*
* Set up Linux device callins * Set up Linux device callins
*/ */
spin_lock_init(&(sc->sbm_lock)); spin_lock_init(&(sc->sbm_lock));
dev->open = sbmac_open; dev->open = sbmac_open;
dev->hard_start_xmit = sbmac_start_tx; dev->hard_start_xmit = sbmac_start_tx;
dev->stop = sbmac_close; dev->stop = sbmac_close;
...@@ -2399,10 +2399,10 @@ static int sbmac_init(struct net_device *dev, int idx) ...@@ -2399,10 +2399,10 @@ static int sbmac_init(struct net_device *dev, int idx)
* was being displayed) * was being displayed)
*/ */
printk(KERN_INFO printk(KERN_INFO
"%s: SiByte Ethernet at 0x%08lX, address: %02X:%02X:%02X:%02X:%02X:%02X\n", "%s: SiByte Ethernet at 0x%08lX, address: %02X:%02X:%02X:%02X:%02X:%02X\n",
dev->name, dev->base_addr, dev->name, dev->base_addr,
eaddr[0],eaddr[1],eaddr[2],eaddr[3],eaddr[4],eaddr[5]); eaddr[0],eaddr[1],eaddr[2],eaddr[3],eaddr[4],eaddr[5]);
return 0; return 0;
...@@ -2416,12 +2416,12 @@ static int sbmac_init(struct net_device *dev, int idx) ...@@ -2416,12 +2416,12 @@ static int sbmac_init(struct net_device *dev, int idx)
static int sbmac_open(struct net_device *dev) static int sbmac_open(struct net_device *dev)
{ {
struct sbmac_softc *sc = netdev_priv(dev); struct sbmac_softc *sc = netdev_priv(dev);
if (debug > 1) { if (debug > 1) {
printk(KERN_DEBUG "%s: sbmac_open() irq %d.\n", dev->name, dev->irq); printk(KERN_DEBUG "%s: sbmac_open() irq %d.\n", dev->name, dev->irq);
} }
/* /*
* map/route interrupt (clear status first, in case something * map/route interrupt (clear status first, in case something
* weird is pending; we haven't initialized the mac registers * weird is pending; we haven't initialized the mac registers
* yet) * yet)
...@@ -2432,35 +2432,35 @@ static int sbmac_open(struct net_device *dev) ...@@ -2432,35 +2432,35 @@ static int sbmac_open(struct net_device *dev)
return -EBUSY; return -EBUSY;
/* /*
* Configure default speed * Configure default speed
*/ */
sbmac_mii_poll(sc,noisy_mii); sbmac_mii_poll(sc,noisy_mii);
/* /*
* Turn on the channel * Turn on the channel
*/ */
sbmac_set_channel_state(sc,sbmac_state_on); sbmac_set_channel_state(sc,sbmac_state_on);
/* /*
* XXX Station address is in dev->dev_addr * XXX Station address is in dev->dev_addr
*/ */
if (dev->if_port == 0) if (dev->if_port == 0)
dev->if_port = 0; dev->if_port = 0;
netif_start_queue(dev); netif_start_queue(dev);
sbmac_set_rx_mode(dev); sbmac_set_rx_mode(dev);
/* Set the timer to check for link beat. */ /* Set the timer to check for link beat. */
init_timer(&sc->sbm_timer); init_timer(&sc->sbm_timer);
sc->sbm_timer.expires = jiffies + 2 * HZ/100; sc->sbm_timer.expires = jiffies + 2 * HZ/100;
sc->sbm_timer.data = (unsigned long)dev; sc->sbm_timer.data = (unsigned long)dev;
sc->sbm_timer.function = &sbmac_timer; sc->sbm_timer.function = &sbmac_timer;
add_timer(&sc->sbm_timer); add_timer(&sc->sbm_timer);
return 0; return 0;
} }
...@@ -2578,20 +2578,20 @@ static void sbmac_timer(unsigned long data) ...@@ -2578,20 +2578,20 @@ static void sbmac_timer(unsigned long data)
int mii_status; int mii_status;
spin_lock_irq (&sc->sbm_lock); spin_lock_irq (&sc->sbm_lock);
/* make IFF_RUNNING follow the MII status bit "Link established" */ /* make IFF_RUNNING follow the MII status bit "Link established" */
mii_status = sbmac_mii_read(sc, sc->sbm_phys[0], MII_BMSR); mii_status = sbmac_mii_read(sc, sc->sbm_phys[0], MII_BMSR);
if ( (mii_status & BMSR_LINKSTAT) != (sc->sbm_phy_oldlinkstat) ) { if ( (mii_status & BMSR_LINKSTAT) != (sc->sbm_phy_oldlinkstat) ) {
sc->sbm_phy_oldlinkstat = mii_status & BMSR_LINKSTAT; sc->sbm_phy_oldlinkstat = mii_status & BMSR_LINKSTAT;
if (mii_status & BMSR_LINKSTAT) { if (mii_status & BMSR_LINKSTAT) {
netif_carrier_on(dev); netif_carrier_on(dev);
} }
else { else {
netif_carrier_off(dev); netif_carrier_off(dev);
} }
} }
/* /*
* Poll the PHY to see what speed we should be running at * Poll the PHY to see what speed we should be running at
*/ */
...@@ -2609,9 +2609,9 @@ static void sbmac_timer(unsigned long data) ...@@ -2609,9 +2609,9 @@ static void sbmac_timer(unsigned long data)
sbmac_channel_start(sc); sbmac_channel_start(sc);
} }
} }
spin_unlock_irq (&sc->sbm_lock); spin_unlock_irq (&sc->sbm_lock);
sc->sbm_timer.expires = jiffies + next_tick; sc->sbm_timer.expires = jiffies + next_tick;
add_timer(&sc->sbm_timer); add_timer(&sc->sbm_timer);
} }
...@@ -2620,13 +2620,13 @@ static void sbmac_timer(unsigned long data) ...@@ -2620,13 +2620,13 @@ static void sbmac_timer(unsigned long data)
static void sbmac_tx_timeout (struct net_device *dev) static void sbmac_tx_timeout (struct net_device *dev)
{ {
struct sbmac_softc *sc = netdev_priv(dev); struct sbmac_softc *sc = netdev_priv(dev);
spin_lock_irq (&sc->sbm_lock); spin_lock_irq (&sc->sbm_lock);
dev->trans_start = jiffies; dev->trans_start = jiffies;
sc->sbm_stats.tx_errors++; sc->sbm_stats.tx_errors++;
spin_unlock_irq (&sc->sbm_lock); spin_unlock_irq (&sc->sbm_lock);
printk (KERN_WARNING "%s: Transmit timed out\n",dev->name); printk (KERN_WARNING "%s: Transmit timed out\n",dev->name);
...@@ -2639,13 +2639,13 @@ static struct net_device_stats *sbmac_get_stats(struct net_device *dev) ...@@ -2639,13 +2639,13 @@ static struct net_device_stats *sbmac_get_stats(struct net_device *dev)
{ {
struct sbmac_softc *sc = netdev_priv(dev); struct sbmac_softc *sc = netdev_priv(dev);
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&sc->sbm_lock, flags); spin_lock_irqsave(&sc->sbm_lock, flags);
/* XXX update other stats here */ /* XXX update other stats here */
spin_unlock_irqrestore(&sc->sbm_lock, flags); spin_unlock_irqrestore(&sc->sbm_lock, flags);
return &sc->sbm_stats; return &sc->sbm_stats;
} }
...@@ -2662,8 +2662,8 @@ static void sbmac_set_rx_mode(struct net_device *dev) ...@@ -2662,8 +2662,8 @@ static void sbmac_set_rx_mode(struct net_device *dev)
/* /*
* Promiscuous changed. * Promiscuous changed.
*/ */
if (dev->flags & IFF_PROMISC) { if (dev->flags & IFF_PROMISC) {
/* Unconditionally log net taps. */ /* Unconditionally log net taps. */
msg_flag = 1; msg_flag = 1;
sbmac_promiscuous_mode(sc,1); sbmac_promiscuous_mode(sc,1);
...@@ -2674,18 +2674,18 @@ static void sbmac_set_rx_mode(struct net_device *dev) ...@@ -2674,18 +2674,18 @@ static void sbmac_set_rx_mode(struct net_device *dev)
} }
} }
spin_unlock_irqrestore(&sc->sbm_lock, flags); spin_unlock_irqrestore(&sc->sbm_lock, flags);
if (msg_flag) { if (msg_flag) {
printk(KERN_NOTICE "%s: Promiscuous mode %sabled.\n", printk(KERN_NOTICE "%s: Promiscuous mode %sabled.\n",
dev->name,(msg_flag==1)?"en":"dis"); dev->name,(msg_flag==1)?"en":"dis");
} }
/* /*
* Program the multicasts. Do this every time. * Program the multicasts. Do this every time.
*/ */
sbmac_setmulti(sc); sbmac_setmulti(sc);
} }
static int sbmac_mii_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) static int sbmac_mii_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
...@@ -2694,10 +2694,10 @@ static int sbmac_mii_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) ...@@ -2694,10 +2694,10 @@ static int sbmac_mii_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
u16 *data = (u16 *)&rq->ifr_ifru; u16 *data = (u16 *)&rq->ifr_ifru;
unsigned long flags; unsigned long flags;
int retval; int retval;
spin_lock_irqsave(&sc->sbm_lock, flags); spin_lock_irqsave(&sc->sbm_lock, flags);
retval = 0; retval = 0;
switch(cmd) { switch(cmd) {
case SIOCDEVPRIVATE: /* Get the address of the PHY in use. */ case SIOCDEVPRIVATE: /* Get the address of the PHY in use. */
data[0] = sc->sbm_phys[0] & 0x1f; data[0] = sc->sbm_phys[0] & 0x1f;
...@@ -2719,7 +2719,7 @@ static int sbmac_mii_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) ...@@ -2719,7 +2719,7 @@ static int sbmac_mii_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
default: default:
retval = -EOPNOTSUPP; retval = -EOPNOTSUPP;
} }
spin_unlock_irqrestore(&sc->sbm_lock, flags); spin_unlock_irqrestore(&sc->sbm_lock, flags);
return retval; return retval;
} }
...@@ -2750,7 +2750,7 @@ static int sbmac_close(struct net_device *dev) ...@@ -2750,7 +2750,7 @@ static int sbmac_close(struct net_device *dev)
sbdma_emptyring(&(sc->sbm_txdma)); sbdma_emptyring(&(sc->sbm_txdma));
sbdma_emptyring(&(sc->sbm_rxdma)); sbdma_emptyring(&(sc->sbm_rxdma));
return 0; return 0;
} }
...@@ -2781,7 +2781,7 @@ sbmac_init_module(void) ...@@ -2781,7 +2781,7 @@ sbmac_init_module(void)
struct net_device *dev; struct net_device *dev;
unsigned long port; unsigned long port;
int chip_max_units; int chip_max_units;
/* /*
* For bringup when not using the firmware, we can pre-fill * For bringup when not using the firmware, we can pre-fill
* the MAC addresses using the environment variables * the MAC addresses using the environment variables
...@@ -2827,7 +2827,7 @@ sbmac_init_module(void) ...@@ -2827,7 +2827,7 @@ sbmac_init_module(void)
port = A_MAC_CHANNEL_BASE(idx); port = A_MAC_CHANNEL_BASE(idx);
/* /*
* The R_MAC_ETHERNET_ADDR register will be set to some nonzero * The R_MAC_ETHERNET_ADDR register will be set to some nonzero
* value for us by the firmware if we're going to use this MAC. * value for us by the firmware if we're going to use this MAC.
* If we find a zero, skip this MAC. * If we find a zero, skip this MAC.
...@@ -2845,7 +2845,7 @@ sbmac_init_module(void) ...@@ -2845,7 +2845,7 @@ sbmac_init_module(void)
*/ */
dev = alloc_etherdev(sizeof(struct sbmac_softc)); dev = alloc_etherdev(sizeof(struct sbmac_softc));
if (!dev) if (!dev)
return -ENOMEM; /* return ENOMEM */ return -ENOMEM; /* return ENOMEM */
printk(KERN_DEBUG "sbmac: configuring MAC at %lx\n", port); printk(KERN_DEBUG "sbmac: configuring MAC at %lx\n", port);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment