1
0
mirror of git://projects.qi-hardware.com/openwrt-xburst.git synced 2024-11-27 18:15:00 +02:00

run indent on ar2313 driver

git-svn-id: svn://svn.openwrt.org/openwrt/trunk@6366 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
nbd 2007-02-25 20:06:27 +00:00
parent 5f23843ea6
commit f0ba23e399
3 changed files with 673 additions and 639 deletions

View File

@ -136,7 +136,8 @@
#define AR2313_BUFSIZE (AR2313_MTU + ETH_HLEN + CRC_LEN + RX_OFFSET)
#ifdef MODULE
MODULE_AUTHOR("Sameer Dekate <sdekate@arubanetworks.com>, Imre Kaloz <kaloz@openwrt.org>, Felix Fietkau <nbd@openwrt.org>");
MODULE_AUTHOR
("Sameer Dekate <sdekate@arubanetworks.com>, Imre Kaloz <kaloz@openwrt.org>, Felix Fietkau <nbd@openwrt.org>");
MODULE_DESCRIPTION("AR2313 Ethernet driver");
#endif
@ -144,7 +145,8 @@ MODULE_DESCRIPTION("AR2313 Ethernet driver");
// prototypes
static short armiiread(struct net_device *dev, short phy, short reg);
static void armiiwrite(struct net_device *dev, short phy, short reg, short data);
static void armiiwrite(struct net_device *dev, short phy, short reg,
short data);
#ifdef TX_TIMEOUT
static void ar2313_tx_timeout(struct net_device *dev);
#endif
@ -163,12 +165,13 @@ int __init ar2313_probe(struct platform_device *pdev)
struct ar2313_private *sp;
struct resource *res;
unsigned long ar_eth_base;
char buf[64] ;
char buf[64];
dev = alloc_etherdev(sizeof(struct ar2313_private));
if (dev == NULL) {
printk(KERN_ERR "ar2313: Unable to allocate net_device structure!\n");
printk(KERN_ERR
"ar2313: Unable to allocate net_device structure!\n");
return -ENOMEM;
}
@ -212,10 +215,11 @@ int __init ar2313_probe(struct platform_device *pdev)
tasklet_init(&sp->rx_tasklet, rx_tasklet_func, (unsigned long) dev);
tasklet_disable(&sp->rx_tasklet);
sp->eth_regs = ioremap_nocache(virt_to_phys(ar_eth_base), sizeof(*sp->eth_regs));
sp->eth_regs =
ioremap_nocache(virt_to_phys(ar_eth_base), sizeof(*sp->eth_regs));
if (!sp->eth_regs) {
printk("Can't remap eth registers\n");
return(-ENXIO);
return (-ENXIO);
}
/*
@ -226,28 +230,32 @@ int __init ar2313_probe(struct platform_device *pdev)
if (virt_to_phys(ar_eth_base) == virt_to_phys(sp->phy_regs))
sp->phy_regs = sp->eth_regs;
else {
sp->phy_regs = ioremap_nocache(virt_to_phys(sp->cfg->phy_base), sizeof(*sp->phy_regs));
sp->phy_regs =
ioremap_nocache(virt_to_phys(sp->cfg->phy_base),
sizeof(*sp->phy_regs));
if (!sp->phy_regs) {
printk("Can't remap phy registers\n");
return(-ENXIO);
return (-ENXIO);
}
}
sp->dma_regs = ioremap_nocache(virt_to_phys(ar_eth_base + 0x1000), sizeof(*sp->dma_regs));
sp->dma_regs =
ioremap_nocache(virt_to_phys(ar_eth_base + 0x1000),
sizeof(*sp->dma_regs));
dev->base_addr = (unsigned int) sp->dma_regs;
if (!sp->dma_regs) {
printk("Can't remap DMA registers\n");
return(-ENXIO);
return (-ENXIO);
}
sp->int_regs = ioremap_nocache(virt_to_phys(sp->cfg->reset_base), 4);
if (!sp->int_regs) {
printk("Can't remap INTERRUPT registers\n");
return(-ENXIO);
return (-ENXIO);
}
strncpy(sp->name, "Atheros AR231x", sizeof (sp->name) - 1);
sp->name [sizeof (sp->name) - 1] = '\0';
strncpy(sp->name, "Atheros AR231x", sizeof(sp->name) - 1);
sp->name[sizeof(sp->name) - 1] = '\0';
memcpy(dev->dev_addr, sp->cfg->macaddr, 6);
sp->board_idx = BOARD_IDX_STATIC;
@ -259,7 +267,7 @@ int __init ar2313_probe(struct platform_device *pdev)
return -ENODEV;
}
if (register_netdev(dev)){
if (register_netdev(dev)) {
printk("%s: register_netdev failed\n", __func__);
return -1;
}
@ -267,8 +275,7 @@ int __init ar2313_probe(struct platform_device *pdev)
printk("%s: %s: %02x:%02x:%02x:%02x:%02x:%02x, irq %d\n",
dev->name, sp->name,
dev->dev_addr[0], dev->dev_addr[1], dev->dev_addr[2],
dev->dev_addr[3], dev->dev_addr[4], dev->dev_addr[5],
dev->irq);
dev->dev_addr[3], dev->dev_addr[4], dev->dev_addr[5], dev->irq);
/* start link poll timer */
ar2313_setup_timer(dev);
@ -280,21 +287,22 @@ int __init ar2313_probe(struct platform_device *pdev)
static void ar2313_dump_regs(struct net_device *dev)
{
unsigned int *ptr, i;
struct ar2313_private *sp = (struct ar2313_private *)dev->priv;
struct ar2313_private *sp = (struct ar2313_private *) dev->priv;
ptr = (unsigned int *)sp->eth_regs;
for(i=0; i< (sizeof(ETHERNET_STRUCT)/ sizeof(unsigned int)); i++, ptr++) {
printk("ENET: %08x = %08x\n", (int)ptr, *ptr);
ptr = (unsigned int *) sp->eth_regs;
for (i = 0; i < (sizeof(ETHERNET_STRUCT) / sizeof(unsigned int));
i++, ptr++) {
printk("ENET: %08x = %08x\n", (int) ptr, *ptr);
}
ptr = (unsigned int *)sp->dma_regs;
for(i=0; i< (sizeof(DMA)/ sizeof(unsigned int)); i++, ptr++) {
printk("DMA: %08x = %08x\n", (int)ptr, *ptr);
ptr = (unsigned int *) sp->dma_regs;
for (i = 0; i < (sizeof(DMA) / sizeof(unsigned int)); i++, ptr++) {
printk("DMA: %08x = %08x\n", (int) ptr, *ptr);
}
ptr = (unsigned int *)sp->int_regs;
for(i=0; i< (sizeof(INTERRUPT)/ sizeof(unsigned int)); i++, ptr++){
printk("INT: %08x = %08x\n", (int)ptr, *ptr);
ptr = (unsigned int *) sp->int_regs;
for (i = 0; i < (sizeof(INTERRUPT) / sizeof(unsigned int)); i++, ptr++) {
printk("INT: %08x = %08x\n", (int) ptr, *ptr);
}
for (i = 0; i < AR2313_DESCR_ENTRIES; i++) {
@ -306,10 +314,9 @@ static void ar2313_dump_regs(struct net_device *dev)
#endif
#ifdef TX_TIMEOUT
static void
ar2313_tx_timeout(struct net_device *dev)
static void ar2313_tx_timeout(struct net_device *dev)
{
struct ar2313_private *sp = (struct ar2313_private *)dev->priv;
struct ar2313_private *sp = (struct ar2313_private *) dev->priv;
unsigned long flags;
#if DEBUG_TX
@ -322,14 +329,13 @@ ar2313_tx_timeout(struct net_device *dev)
#endif
#if DEBUG_MC
static void
printMcList(struct net_device *dev)
static void printMcList(struct net_device *dev)
{
struct dev_mc_list *list = dev->mc_list;
int num=0, i;
while(list){
int num = 0, i;
while (list) {
printk("%d MC ADDR ", num);
for(i=0;i<list->dmi_addrlen;i++) {
for (i = 0; i < list->dmi_addrlen; i++) {
printk(":%02x", list->dmi_addr[i]);
}
list = list->next;
@ -342,14 +348,13 @@ printMcList(struct net_device *dev)
* Set or clear the multicast filter for this adaptor.
* THIS IS ABSOLUTE CRAP, disabled
*/
static void
ar2313_multicast_list(struct net_device *dev)
static void ar2313_multicast_list(struct net_device *dev)
{
/*
* Always listen to broadcasts and
* treat IFF bits independently
*/
struct ar2313_private *sp = (struct ar2313_private *)dev->priv;
struct ar2313_private *sp = (struct ar2313_private *) dev->priv;
unsigned int recognise;
recognise = sp->eth_regs->mac_control;
@ -363,9 +368,10 @@ ar2313_multicast_list(struct net_device *dev)
if ((dev->flags & IFF_ALLMULTI) || (dev->mc_count > 15)) {
#if DEBUG_MC
printMcList(dev);
printk("%s: all MULTICAST mc_count %d\n", __FUNCTION__, dev->mc_count);
printk("%s: all MULTICAST mc_count %d\n", __FUNCTION__,
dev->mc_count);
#endif
recognise |= MAC_CONTROL_PM;/* all multicast */
recognise |= MAC_CONTROL_PM; /* all multicast */
} else if (dev->mc_count > 0) {
#if DEBUG_MC
printMcList(dev);
@ -374,7 +380,8 @@ ar2313_multicast_list(struct net_device *dev)
recognise |= MAC_CONTROL_PM; /* for the time being */
}
#if DEBUG_MC
printk("%s: setting %08x to %08x\n", __FUNCTION__, (int)sp->eth_regs, recognise);
printk("%s: setting %08x to %08x\n", __FUNCTION__, (int) sp->eth_regs,
recognise);
#endif
sp->eth_regs->mac_control = recognise;
@ -449,7 +456,7 @@ static void ar2313_free_descriptors(struct net_device *dev)
{
struct ar2313_private *sp = dev->priv;
if (sp->rx_ring != NULL) {
kfree((void*)KSEG0ADDR(sp->rx_ring));
kfree((void *) KSEG0ADDR(sp->rx_ring));
sp->rx_ring = NULL;
sp->tx_ring = NULL;
}
@ -463,23 +470,24 @@ static int ar2313_allocate_descriptors(struct net_device *dev)
int j;
ar2313_descr_t *space;
if(sp->rx_ring != NULL){
if (sp->rx_ring != NULL) {
printk("%s: already done.\n", __FUNCTION__);
return 0;
}
size = (sizeof(ar2313_descr_t) * (AR2313_DESCR_ENTRIES * AR2313_QUEUES));
size =
(sizeof(ar2313_descr_t) * (AR2313_DESCR_ENTRIES * AR2313_QUEUES));
space = kmalloc(size, GFP_KERNEL);
if (space == NULL)
return 1;
/* invalidate caches */
dma_cache_inv((unsigned int)space, size);
dma_cache_inv((unsigned int) space, size);
/* now convert pointer to KSEG1 */
space = (ar2313_descr_t *)KSEG1ADDR(space);
space = (ar2313_descr_t *) KSEG1ADDR(space);
memset((void *)space, 0, size);
memset((void *) space, 0, size);
sp->rx_ring = space;
space += AR2313_DESCR_ENTRIES;
@ -493,7 +501,9 @@ static int ar2313_allocate_descriptors(struct net_device *dev)
td->status = 0;
td->devcs = DMA_TX1_CHAINED;
td->addr = 0;
td->descr = virt_to_phys(&sp->tx_ring[(j+1) & (AR2313_DESCR_ENTRIES-1)]);
td->descr =
virt_to_phys(&sp->
tx_ring[(j + 1) & (AR2313_DESCR_ENTRIES - 1)]);
}
return 0;
@ -512,8 +522,10 @@ static void ar2313_init_cleanup(struct net_device *dev)
ar2313_free_descriptors(dev);
if (sp->eth_regs) iounmap((void*)sp->eth_regs);
if (sp->dma_regs) iounmap((void*)sp->dma_regs);
if (sp->eth_regs)
iounmap((void *) sp->eth_regs);
if (sp->dma_regs)
iounmap((void *) sp->dma_regs);
if (sp->rx_skb) {
for (j = 0; j < AR2313_DESCR_ENTRIES; j++) {
@ -567,8 +579,8 @@ static void ar2313_link_timer_fn(unsigned long data)
// Loop faster when we don't have link.
// This was needed to speed up the AP bootstrap time.
if(sp->link == 0) {
mod_timer(&sp->link_timer, jiffies + HZ/2);
if (sp->link == 0) {
mod_timer(&sp->link_timer, jiffies + HZ / 2);
} else {
mod_timer(&sp->link_timer, jiffies + LINK_TIMER);
}
@ -582,7 +594,8 @@ static void ar2313_check_link(struct net_device *dev)
phyData = armiiread(dev, sp->phy, MII_BMSR);
if (sp->phyData != phyData) {
if (phyData & BMSR_LSTATUS) {
/* link is present, ready link partner ability to deterine duplexity */
/* link is present, ready link partner ability to deterine
duplexity */
int duplex = 0;
u16 reg;
@ -591,23 +604,25 @@ static void ar2313_check_link(struct net_device *dev)
if (reg & BMCR_ANENABLE) {
/* auto neg enabled */
reg = armiiread(dev, sp->phy, MII_LPA);
duplex = (reg & (LPA_100FULL|LPA_10FULL))? 1:0;
duplex = (reg & (LPA_100FULL | LPA_10FULL)) ? 1 : 0;
} else {
/* no auto neg, just read duplex config */
duplex = (reg & BMCR_FULLDPLX)? 1:0;
duplex = (reg & BMCR_FULLDPLX) ? 1 : 0;
}
printk(KERN_INFO "%s: Configuring MAC for %s duplex\n", dev->name,
(duplex)? "full":"half");
printk(KERN_INFO "%s: Configuring MAC for %s duplex\n",
dev->name, (duplex) ? "full" : "half");
if (duplex) {
/* full duplex */
sp->eth_regs->mac_control = ((sp->eth_regs->mac_control | MAC_CONTROL_F) &
~MAC_CONTROL_DRO);
sp->eth_regs->mac_control =
((sp->eth_regs->
mac_control | MAC_CONTROL_F) & ~MAC_CONTROL_DRO);
} else {
/* half duplex */
sp->eth_regs->mac_control = ((sp->eth_regs->mac_control | MAC_CONTROL_DRO) &
~MAC_CONTROL_F);
sp->eth_regs->mac_control =
((sp->eth_regs->
mac_control | MAC_CONTROL_DRO) & ~MAC_CONTROL_F);
}
} else {
/* no link */
@ -617,10 +632,9 @@ static void ar2313_check_link(struct net_device *dev)
}
}
static int
ar2313_reset_reg(struct net_device *dev)
static int ar2313_reset_reg(struct net_device *dev)
{
struct ar2313_private *sp = (struct ar2313_private *)dev->priv;
struct ar2313_private *sp = (struct ar2313_private *) dev->priv;
unsigned int ethsal, ethsah;
unsigned int flags;
@ -635,17 +649,18 @@ ar2313_reset_reg(struct net_device *dev)
sp->dma_regs->bus_mode = (DMA_BUS_MODE_SWR);
mdelay(10);
sp->dma_regs->bus_mode = ((32 << DMA_BUS_MODE_PBL_SHIFT) | DMA_BUS_MODE_BLE);
sp->dma_regs->bus_mode =
((32 << DMA_BUS_MODE_PBL_SHIFT) | DMA_BUS_MODE_BLE);
/* enable interrupts */
sp->dma_regs->intr_ena = (DMA_STATUS_AIS |
DMA_STATUS_NIS |
DMA_STATUS_RI |
DMA_STATUS_TI |
DMA_STATUS_FBE);
DMA_STATUS_TI | DMA_STATUS_FBE);
sp->dma_regs->xmt_base = virt_to_phys(sp->tx_ring);
sp->dma_regs->rcv_base = virt_to_phys(sp->rx_ring);
sp->dma_regs->control = (DMA_CONTROL_SR | DMA_CONTROL_ST | DMA_CONTROL_SF);
sp->dma_regs->control =
(DMA_CONTROL_SR | DMA_CONTROL_ST | DMA_CONTROL_SF);
sp->eth_regs->flow_control = (FLOW_CONTROL_FCE);
sp->eth_regs->vlan_tag = (0x8100);
@ -662,27 +677,27 @@ ar2313_reset_reg(struct net_device *dev)
sp->eth_regs->mac_control = flags;
/* Set all Ethernet station address registers to their initial values */
ethsah = ((((u_int)(dev->dev_addr[5]) << 8) & (u_int)0x0000FF00) |
(((u_int)(dev->dev_addr[4]) << 0) & (u_int)0x000000FF));
ethsah = ((((u_int) (dev->dev_addr[5]) << 8) & (u_int) 0x0000FF00) |
(((u_int) (dev->dev_addr[4]) << 0) & (u_int) 0x000000FF));
ethsal = ((((u_int)(dev->dev_addr[3]) << 24) & (u_int)0xFF000000) |
(((u_int)(dev->dev_addr[2]) << 16) & (u_int)0x00FF0000) |
(((u_int)(dev->dev_addr[1]) << 8) & (u_int)0x0000FF00) |
(((u_int)(dev->dev_addr[0]) << 0) & (u_int)0x000000FF) );
ethsal = ((((u_int) (dev->dev_addr[3]) << 24) & (u_int) 0xFF000000) |
(((u_int) (dev->dev_addr[2]) << 16) & (u_int) 0x00FF0000) |
(((u_int) (dev->dev_addr[1]) << 8) & (u_int) 0x0000FF00) |
(((u_int) (dev->dev_addr[0]) << 0) & (u_int) 0x000000FF));
sp->eth_regs->mac_addr[0] = ethsah;
sp->eth_regs->mac_addr[1] = ethsal;
mdelay(10);
return(0);
return (0);
}
static int ar2313_init(struct net_device *dev)
{
struct ar2313_private *sp = dev->priv;
int ecode=0;
int ecode = 0;
/*
* Allocate descriptors
@ -697,8 +712,10 @@ static int ar2313_init(struct net_device *dev)
/*
* Get the memory for the skb rings.
*/
if(sp->rx_skb == NULL) {
sp->rx_skb = kmalloc(sizeof(struct sk_buff *) * AR2313_DESCR_ENTRIES, GFP_KERNEL);
if (sp->rx_skb == NULL) {
sp->rx_skb =
kmalloc(sizeof(struct sk_buff *) * AR2313_DESCR_ENTRIES,
GFP_KERNEL);
if (!(sp->rx_skb)) {
printk("%s: %s: rx_skb kmalloc failed\n",
dev->name, __FUNCTION__);
@ -708,8 +725,10 @@ static int ar2313_init(struct net_device *dev)
}
memset(sp->rx_skb, 0, sizeof(struct sk_buff *) * AR2313_DESCR_ENTRIES);
if(sp->tx_skb == NULL) {
sp->tx_skb = kmalloc(sizeof(struct sk_buff *) * AR2313_DESCR_ENTRIES, GFP_KERNEL);
if (sp->tx_skb == NULL) {
sp->tx_skb =
kmalloc(sizeof(struct sk_buff *) * AR2313_DESCR_ENTRIES,
GFP_KERNEL);
if (!(sp->tx_skb)) {
printk("%s: %s: tx_skb kmalloc failed\n",
dev->name, __FUNCTION__);
@ -749,7 +768,10 @@ static int ar2313_init(struct net_device *dev)
/*
* Get the IRQ
*/
ecode = request_irq(dev->irq, &ar2313_interrupt, IRQF_SHARED | IRQF_DISABLED | IRQF_SAMPLE_RANDOM, dev->name, dev);
ecode =
request_irq(dev->irq, &ar2313_interrupt,
IRQF_SHARED | IRQF_DISABLED | IRQF_SAMPLE_RANDOM,
dev->name, dev);
if (ecode) {
printk(KERN_WARNING "%s: %s: Requested IRQ %d is busy\n",
dev->name, __FUNCTION__, dev->irq);
@ -776,7 +798,7 @@ static int ar2313_init(struct net_device *dev)
static void ar2313_load_rx_ring(struct net_device *dev, int nr_bufs)
{
struct ar2313_private *sp = ((struct net_device *)dev)->priv;
struct ar2313_private *sp = ((struct net_device *) dev)->priv;
short i, idx;
idx = sp->rx_skbprd;
@ -791,11 +813,11 @@ static void ar2313_load_rx_ring(struct net_device *dev, int nr_bufs)
#endif /* DEBUG */
break;
}
// partha: create additional room for the second GRE fragment
skb = alloc_skb(AR2313_BUFSIZE+128, GFP_ATOMIC);
skb = alloc_skb(AR2313_BUFSIZE + 128, GFP_ATOMIC);
if (!skb) {
printk("\n\n\n\n %s: No memory in system\n\n\n\n", __FUNCTION__);
printk("\n\n\n\n %s: No memory in system\n\n\n\n",
__FUNCTION__);
break;
}
// partha: create additional room in the front for tx pkt capture
@ -808,13 +830,15 @@ static void ar2313_load_rx_ring(struct net_device *dev, int nr_bufs)
skb_reserve(skb, RX_OFFSET);
sp->rx_skb[idx] = skb;
rd = (ar2313_descr_t *) &sp->rx_ring[idx];
rd = (ar2313_descr_t *) & sp->rx_ring[idx];
/* initialize dma descriptor */
rd->devcs = ((AR2313_BUFSIZE << DMA_RX1_BSIZE_SHIFT) |
DMA_RX1_CHAINED);
rd->addr = virt_to_phys(skb->data);
rd->descr = virt_to_phys(&sp->rx_ring[(idx+1) & (AR2313_DESCR_ENTRIES-1)]);
rd->descr =
virt_to_phys(&sp->
rx_ring[(idx + 1) & (AR2313_DESCR_ENTRIES - 1)]);
rd->status = DMA_RX_OWN;
idx = DSC_NEXT(idx);
@ -822,7 +846,8 @@ static void ar2313_load_rx_ring(struct net_device *dev, int nr_bufs)
if (!i) {
#if DEBUG_ERR
printk(KERN_INFO "Out of memory when allocating standard receive buffers\n");
printk(KERN_INFO
"Out of memory when allocating standard receive buffers\n");
#endif /* DEBUG */
} else {
sp->rx_skbprd = idx;
@ -845,8 +870,9 @@ static int ar2313_rx_int(struct net_device *dev)
idx = sp->cur_rx;
/* process at most the entire ring and then wait for another interrupt */
while(1) {
/* process at most the entire ring and then wait for another interrupt
*/
while (1) {
rxdesc = &sp->rx_ring[idx];
status = rxdesc->status;
@ -860,17 +886,16 @@ static int ar2313_rx_int(struct net_device *dev)
rval = 1;
break;
}
#if DEBUG_RX
printk("index %d\n", idx);
printk("RX status %08x\n", rxdesc->status);
printk("RX devcs %08x\n", rxdesc->devcs );
printk("RX addr %08x\n", rxdesc->addr );
printk("RX descr %08x\n", rxdesc->descr );
printk("RX devcs %08x\n", rxdesc->devcs);
printk("RX addr %08x\n", rxdesc->addr);
printk("RX descr %08x\n", rxdesc->descr);
#endif
if ((status & (DMA_RX_ERROR|DMA_RX_ERR_LENGTH)) &&
(!(status & DMA_RX_LONG))){
if ((status & (DMA_RX_ERROR | DMA_RX_ERR_LENGTH)) &&
(!(status & DMA_RX_LONG))) {
#if DEBUG_RX
printk("%s: rx ERROR %08x\n", __FUNCTION__, status);
#endif
@ -878,12 +903,16 @@ static int ar2313_rx_int(struct net_device *dev)
sp->stats.rx_dropped++;
/* add statistics counters */
if (status & DMA_RX_ERR_CRC) sp->stats.rx_crc_errors++;
if (status & DMA_RX_ERR_COL) sp->stats.rx_over_errors++;
if (status & DMA_RX_ERR_CRC)
sp->stats.rx_crc_errors++;
if (status & DMA_RX_ERR_COL)
sp->stats.rx_over_errors++;
if (status & DMA_RX_ERR_LENGTH)
sp->stats.rx_length_errors++;
if (status & DMA_RX_ERR_RUNT) sp->stats.rx_over_errors++;
if (status & DMA_RX_ERR_DESC) sp->stats.rx_over_errors++;
if (status & DMA_RX_ERR_RUNT)
sp->stats.rx_over_errors++;
if (status & DMA_RX_ERR_DESC)
sp->stats.rx_over_errors++;
} else {
/* alloc new buffer. */
@ -892,7 +921,8 @@ static int ar2313_rx_int(struct net_device *dev)
skb = sp->rx_skb[idx];
/* set skb */
skb_put(skb, ((status >> DMA_RX_LEN_SHIFT) & 0x3fff) - CRC_LEN);
skb_put(skb,
((status >> DMA_RX_LEN_SHIFT) & 0x3fff) - CRC_LEN);
sp->stats.rx_bytes += skb->len;
skb->protocol = eth_type_trans(skb, dev);
@ -901,7 +931,7 @@ static int ar2313_rx_int(struct net_device *dev)
skb_new->dev = dev;
/* 16 bit align */
skb_reserve(skb_new, RX_OFFSET+32);
skb_reserve(skb_new, RX_OFFSET + 32);
/* reset descriptor's curr_addr */
rxdesc->addr = virt_to_phys(skb_new->data);
@ -931,7 +961,7 @@ static void ar2313_tx_int(struct net_device *dev)
u32 idx;
struct sk_buff *skb;
ar2313_descr_t *txdesc;
unsigned int status=0;
unsigned int status = 0;
idx = sp->tx_csm;
@ -940,9 +970,10 @@ static void ar2313_tx_int(struct net_device *dev)
txdesc = &sp->tx_ring[idx];
#if DEBUG_TX
printk("%s: TXINT: csm=%d idx=%d prd=%d status=%x devcs=%x addr=%08x descr=%x\n",
dev->name, sp->tx_csm, idx, sp->tx_prd,
txdesc->status, txdesc->devcs, txdesc->addr, txdesc->descr);
printk
("%s: TXINT: csm=%d idx=%d prd=%d status=%x devcs=%x addr=%08x descr=%x\n",
dev->name, sp->tx_csm, idx, sp->tx_prd, txdesc->status,
txdesc->devcs, txdesc->addr, txdesc->descr);
#endif /* DEBUG */
if ((status = txdesc->status) & DMA_TX_OWN) {
@ -950,23 +981,23 @@ static void ar2313_tx_int(struct net_device *dev)
break;
}
/* done with this descriptor */
dma_unmap_single(NULL, txdesc->addr, txdesc->devcs & DMA_TX1_BSIZE_MASK, DMA_TO_DEVICE);
dma_unmap_single(NULL, txdesc->addr,
txdesc->devcs & DMA_TX1_BSIZE_MASK,
DMA_TO_DEVICE);
txdesc->status = 0;
if (status & DMA_TX_ERROR){
if (status & DMA_TX_ERROR) {
sp->stats.tx_errors++;
sp->stats.tx_dropped++;
if(status & DMA_TX_ERR_UNDER)
if (status & DMA_TX_ERR_UNDER)
sp->stats.tx_fifo_errors++;
if(status & DMA_TX_ERR_HB)
if (status & DMA_TX_ERR_HB)
sp->stats.tx_heartbeat_errors++;
if(status & (DMA_TX_ERR_LOSS |
DMA_TX_ERR_LINK))
if (status & (DMA_TX_ERR_LOSS | DMA_TX_ERR_LINK))
sp->stats.tx_carrier_errors++;
if (status & (DMA_TX_ERR_LATE|
if (status & (DMA_TX_ERR_LATE |
DMA_TX_ERR_COL |
DMA_TX_ERR_JABBER |
DMA_TX_ERR_DEFER))
DMA_TX_ERR_JABBER | DMA_TX_ERR_DEFER))
sp->stats.tx_aborted_errors++;
} else {
/* transmit OK */
@ -986,8 +1017,7 @@ static void ar2313_tx_int(struct net_device *dev)
}
static void
rx_tasklet_func(unsigned long data)
static void rx_tasklet_func(unsigned long data)
{
struct net_device *dev = (struct net_device *) data;
struct ar2313_private *sp = dev->priv;
@ -998,8 +1028,7 @@ rx_tasklet_func(unsigned long data)
if (ar2313_rx_int(dev)) {
tasklet_hi_schedule(&sp->rx_tasklet);
}
else {
} else {
unsigned long flags;
spin_lock_irqsave(&sp->lock, flags);
sp->dma_regs->intr_ena |= DMA_STATUS_RI;
@ -1007,8 +1036,7 @@ rx_tasklet_func(unsigned long data)
}
}
static void
rx_schedule(struct net_device *dev)
static void rx_schedule(struct net_device *dev)
{
struct ar2313_private *sp = dev->priv;
@ -1019,7 +1047,7 @@ rx_schedule(struct net_device *dev)
static irqreturn_t ar2313_interrupt(int irq, void *dev_id)
{
struct net_device *dev = (struct net_device *)dev_id;
struct net_device *dev = (struct net_device *) dev_id;
struct ar2313_private *sp = dev->priv;
unsigned int status, enabled;
@ -1167,7 +1195,7 @@ static int ar2313_start_xmit(struct sk_buff *skb, struct net_device *dev)
/* Setup the transmit descriptor. */
td->devcs = ((skb->len << DMA_TX1_BSIZE_SHIFT) |
(DMA_TX1_LS|DMA_TX1_IC|DMA_TX1_CHAINED));
(DMA_TX1_LS | DMA_TX1_IC | DMA_TX1_CHAINED));
td->addr = dma_map_single(NULL, skb->data, skb->len, DMA_TO_DEVICE);
td->status = DMA_TX_OWN;
@ -1177,9 +1205,9 @@ static int ar2313_start_xmit(struct sk_buff *skb, struct net_device *dev)
#if DEBUG_TX
printk("index %d\n", idx);
printk("TX status %08x\n", td->status);
printk("TX devcs %08x\n", td->devcs );
printk("TX addr %08x\n", td->addr );
printk("TX descr %08x\n", td->descr );
printk("TX devcs %08x\n", td->devcs);
printk("TX addr %08x\n", td->addr);
printk("TX descr %08x\n", td->descr);
#endif
sp->tx_skb[idx] = skb;
@ -1189,7 +1217,8 @@ static int ar2313_start_xmit(struct sk_buff *skb, struct net_device *dev)
return 0;
}
static int netdev_get_ecmd(struct net_device *dev, struct ethtool_cmd *ecmd)
static int netdev_get_ecmd(struct net_device *dev,
struct ethtool_cmd *ecmd)
{
struct ar2313_private *np = dev->priv;
u32 tmp;
@ -1226,12 +1255,12 @@ static int netdev_get_ecmd(struct net_device *dev, struct ethtool_cmd *ecmd)
if (ecmd->autoneg == AUTONEG_ENABLE) {
tmp = armiiread(dev, np->phy, MII_LPA);
if (tmp & (LPA_100FULL|LPA_10FULL)) {
if (tmp & (LPA_100FULL | LPA_10FULL)) {
ecmd->duplex = DUPLEX_FULL;
} else {
ecmd->duplex = DUPLEX_HALF;
}
if (tmp & (LPA_100FULL|LPA_100HALF)) {
if (tmp & (LPA_100FULL | LPA_100HALF)) {
ecmd->speed = SPEED_100;
} else {
ecmd->speed = SPEED_10;
@ -1254,7 +1283,8 @@ static int netdev_get_ecmd(struct net_device *dev, struct ethtool_cmd *ecmd)
return 0;
}
static int netdev_set_ecmd(struct net_device *dev, struct ethtool_cmd *ecmd)
static int netdev_set_ecmd(struct net_device *dev,
struct ethtool_cmd *ecmd)
{
struct ar2313_private *np = dev->priv;
u32 tmp;
@ -1267,7 +1297,8 @@ static int netdev_set_ecmd(struct net_device *dev, struct ethtool_cmd *ecmd)
return -EINVAL;
if (ecmd->transceiver != XCVR_INTERNAL)
return -EINVAL;
if (ecmd->autoneg != AUTONEG_DISABLE && ecmd->autoneg != AUTONEG_ENABLE)
if (ecmd->autoneg != AUTONEG_DISABLE
&& ecmd->autoneg != AUTONEG_ENABLE)
return -EINVAL;
/* ignore phy_address, maxtxpkt, maxrxpkt for now */
@ -1286,8 +1317,8 @@ static int netdev_set_ecmd(struct net_device *dev, struct ethtool_cmd *ecmd)
if (ecmd->duplex == DUPLEX_FULL)
tmp |= BMCR_FULLDPLX;
printk("%s: Hard coding %d/%s\n", dev->name,
(ecmd->speed == SPEED_100)? 100:10,
(ecmd->duplex == DUPLEX_FULL)? "full":"half");
(ecmd->speed == SPEED_100) ? 100 : 10,
(ecmd->duplex == DUPLEX_FULL) ? "full" : "half");
}
armiiwrite(dev, np->phy, MII_BMCR, tmp);
np->phyData = 0;
@ -1299,12 +1330,12 @@ static int netdev_ethtool_ioctl(struct net_device *dev, void *useraddr)
struct ar2313_private *np = dev->priv;
u32 cmd;
if (get_user(cmd, (u32 *)useraddr))
if (get_user(cmd, (u32 *) useraddr))
return -EFAULT;
switch (cmd) {
/* get settings */
case ETHTOOL_GSET: {
case ETHTOOL_GSET:{
struct ethtool_cmd ecmd = { ETHTOOL_GSET };
spin_lock_irq(&np->lock);
netdev_get_ecmd(dev, &ecmd);
@ -1314,7 +1345,7 @@ static int netdev_ethtool_ioctl(struct net_device *dev, void *useraddr)
return 0;
}
/* set settings */
case ETHTOOL_SSET: {
case ETHTOOL_SSET:{
struct ethtool_cmd ecmd;
int r;
if (copy_from_user(&ecmd, useraddr, sizeof(ecmd)))
@ -1325,7 +1356,7 @@ static int netdev_ethtool_ioctl(struct net_device *dev, void *useraddr)
return r;
}
/* restart autonegotiation */
case ETHTOOL_NWAY_RST: {
case ETHTOOL_NWAY_RST:{
int tmp;
int r = -EINVAL;
/* if autoneg is off, it's an error */
@ -1338,9 +1369,10 @@ static int netdev_ethtool_ioctl(struct net_device *dev, void *useraddr)
return r;
}
/* get link status */
case ETHTOOL_GLINK: {
struct ethtool_value edata = {ETHTOOL_GLINK};
edata.data = (armiiread(dev, np->phy, MII_BMSR)&BMSR_LSTATUS) ? 1:0;
case ETHTOOL_GLINK:{
struct ethtool_value edata = { ETHTOOL_GLINK };
edata.data =
(armiiread(dev, np->phy, MII_BMSR) & BMSR_LSTATUS) ? 1 : 0;
if (copy_to_user(useraddr, &edata, sizeof(edata)))
return -EFAULT;
return 0;
@ -1352,7 +1384,7 @@ static int netdev_ethtool_ioctl(struct net_device *dev, void *useraddr)
static int ar2313_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
{
struct mii_ioctl_data *data = (struct mii_ioctl_data *)&ifr->ifr_data;
struct mii_ioctl_data *data = (struct mii_ioctl_data *) &ifr->ifr_data;
switch (cmd) {
@ -1375,12 +1407,14 @@ static int ar2313_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
return 0;
case SIOCSIFHWADDR:
if (copy_from_user(dev->dev_addr, ifr->ifr_data, sizeof(dev->dev_addr)))
if (copy_from_user
(dev->dev_addr, ifr->ifr_data, sizeof(dev->dev_addr)))
return -EFAULT;
return 0;
case SIOCGIFHWADDR:
if (copy_to_user(ifr->ifr_data, dev->dev_addr, sizeof(dev->dev_addr)))
if (copy_to_user
(ifr->ifr_data, dev->dev_addr, sizeof(dev->dev_addr)))
return -EFAULT;
return 0;
@ -1401,10 +1435,9 @@ static struct net_device_stats *ar2313_get_stats(struct net_device *dev)
#define MII_ADDR(phy, reg) \
((reg << MII_ADDR_REG_SHIFT) | (phy << MII_ADDR_PHY_SHIFT))
static short
armiiread(struct net_device *dev, short phy, short reg)
static short armiiread(struct net_device *dev, short phy, short reg)
{
struct ar2313_private *sp = (struct ar2313_private *)dev->priv;
struct ar2313_private *sp = (struct ar2313_private *) dev->priv;
volatile ETHERNET_STRUCT *ethernet = sp->phy_regs;
ethernet->mii_addr = MII_ADDR(phy, reg);
@ -1415,11 +1448,10 @@ armiiread(struct net_device *dev, short phy, short reg)
static void
armiiwrite(struct net_device *dev, short phy, short reg, short data)
{
struct ar2313_private *sp = (struct ar2313_private *)dev->priv;
struct ar2313_private *sp = (struct ar2313_private *) dev->priv;
volatile ETHERNET_STRUCT *ethernet = sp->phy_regs;
while (ethernet->mii_addr & MII_ADDR_BUSY);
ethernet->mii_data = data << MII_DATA_SHIFT;
ethernet->mii_addr = MII_ADDR(phy, reg) | MII_ADDR_WRITE;
}

View File

@ -22,7 +22,7 @@
#define DSC_RING_ENTRIES_SIZE (AR2313_DESCR_ENTRIES * sizeof(struct desc))
#define DSC_NEXT(idx) ((idx + 1) & (AR2313_DESCR_ENTRIES - 1))
static inline int tx_space (u32 csm, u32 prd)
static inline int tx_space(u32 csm, u32 prd)
{
return (csm - prd - 1) & (AR2313_DESCR_ENTRIES - 1);
}
@ -52,7 +52,7 @@ static inline int tx_space (u32 csm, u32 prd)
//
typedef struct {
volatile unsigned int mac_control; /* 0x00 */
volatile unsigned int mac_addr[2]; /* 0x04 - 0x08*/
volatile unsigned int mac_addr[2]; /* 0x04 - 0x08 */
volatile unsigned int mcast_table[2]; /* 0x0c - 0x10 */
volatile unsigned int mii_addr; /* 0x14 */
volatile unsigned int mii_data; /* 0x18 */
@ -105,8 +105,7 @@ typedef struct {
* Frequently accessed variables are put at the beginning of the
* struct to help the compiler generate better/shorter code.
*/
struct ar2313_private
{
struct ar2313_private {
struct net_device *dev;
int version;
u32 mb[2];
@ -184,7 +183,8 @@ static irqreturn_t ar2313_interrupt(int irq, void *dev_id);
static int ar2313_open(struct net_device *dev);
static int ar2313_start_xmit(struct sk_buff *skb, struct net_device *dev);
static int ar2313_close(struct net_device *dev);
static int ar2313_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd);
static int ar2313_ioctl(struct net_device *dev, struct ifreq *ifr,
int cmd);
static void ar2313_init_cleanup(struct net_device *dev);
static int ar2313_setup_timer(struct net_device *dev);
static void ar2313_link_timer_fn(unsigned long data);

View File

@ -75,7 +75,7 @@
#define MAC_CONTROL_RE AR_BIT(2) /* receive enable */
#define MAC_CONTROL_TE AR_BIT(3) /* transmit enable */
#define MAC_CONTROL_DC AR_BIT(5) /* Deferral check*/
#define MAC_CONTROL_DC AR_BIT(5) /* Deferral check */
#define MAC_CONTROL_ASTP AR_BIT(8) /* Auto pad strip */
#define MAC_CONTROL_DRTY AR_BIT(10) /* Disable retry */
#define MAC_CONTROL_DBF AR_BIT(11) /* Disable bcast frames */
@ -85,13 +85,16 @@
#define MAC_CONTROL_HO AR_BIT(15) /* Hash only filtering */
#define MAC_CONTROL_PB AR_BIT(16) /* Pass Bad frames */
#define MAC_CONTROL_IF AR_BIT(17) /* Inverse filtering */
#define MAC_CONTROL_PR AR_BIT(18) /* promiscuous mode (valid frames only) */
#define MAC_CONTROL_PR AR_BIT(18) /* promiscuous mode (valid frames
only) */
#define MAC_CONTROL_PM AR_BIT(19) /* pass multicast */
#define MAC_CONTROL_F AR_BIT(20) /* full-duplex */
#define MAC_CONTROL_DRO AR_BIT(23) /* Disable Receive Own */
#define MAC_CONTROL_HBD AR_BIT(28) /* heart-beat disabled (MUST BE SET) */
#define MAC_CONTROL_HBD AR_BIT(28) /* heart-beat disabled (MUST BE
SET) */
#define MAC_CONTROL_BLE AR_BIT(30) /* big endian mode */
#define MAC_CONTROL_RA AR_BIT(31) /* receive all (valid and invalid frames) */
#define MAC_CONTROL_RA AR_BIT(31) /* receive all (valid and invalid
frames) */
#define MII_ADDR_BUSY AR_BIT(0)
#define MII_ADDR_WRITE AR_BIT(1)
@ -137,4 +140,3 @@ typedef struct {
#endif // __ARUBA_DMA_H__