Commit ab7f4e5d authored by Chas Williams's avatar Chas Williams Committed by David S. Miller

[ATM]: more cleanup in HE driver

parent 03286272
......@@ -77,14 +77,6 @@
#include <linux/atmdev.h>
#include <linux/atm.h>
#include <linux/sonet.h>
#ifndef ATM_OC12_PCR
#define ATM_OC12_PCR (622080000/1080*1040/8/53)
#endif
#ifdef BUS_INT_WAR
void sn_add_polled_interrupt(int irq, int interval);
void sn_delete_polled_interrupt(int irq);
#endif
#define USE_TASKLET
#define USE_HE_FIND_VCC
......@@ -171,22 +163,17 @@ static short sdh = 1;
static struct atmdev_ops he_ops =
{
open: he_open,
close: he_close,
ioctl: he_ioctl,
send: he_send,
sg_send: he_sg_send,
phy_put: he_phy_put,
phy_get: he_phy_get,
proc_read: he_proc_read,
owner: THIS_MODULE
.open = he_open,
.close = he_close,
.ioctl = he_ioctl,
.send = he_send,
.sg_send = he_sg_send,
.phy_put = he_phy_put,
.phy_get = he_phy_get,
.proc_read = he_proc_read,
.owner = THIS_MODULE
};
/* see the comments in he.h about global_lock */
#define HE_SPIN_LOCK(dev, flags) spin_lock_irqsave(&(dev)->global_lock, flags)
#define HE_SPIN_UNLOCK(dev, flags) spin_unlock_irqrestore(&(dev)->global_lock, flags)
#define he_writel(dev, val, reg) do { writel(val, (dev)->membase + (reg)); wmb(); } while (0)
#define he_readl(dev, reg) readl((dev)->membase + (reg))
......@@ -233,26 +220,26 @@ he_readl_internal(struct he_dev *he_dev, unsigned addr, unsigned flags)
/* figure 2.2 connection id */
#define he_mkcid(dev, vpi, vci) (((vpi<<(dev)->vcibits) | vci) & 0x1fff)
#define he_mkcid(dev, vpi, vci) (((vpi << (dev)->vcibits) | vci) & 0x1fff)
/* 2.5.1 per connection transmit state registers */
#define he_writel_tsr0(dev, val, cid) \
he_writel_tcm(dev, val, CONFIG_TSRA | (cid<<3) | 0)
he_writel_tcm(dev, val, CONFIG_TSRA | (cid << 3) | 0)
#define he_readl_tsr0(dev, cid) \
he_readl_tcm(dev, CONFIG_TSRA | (cid<<3) | 0)
he_readl_tcm(dev, CONFIG_TSRA | (cid << 3) | 0)
#define he_writel_tsr1(dev, val, cid) \
he_writel_tcm(dev, val, CONFIG_TSRA | (cid<<3) | 1)
he_writel_tcm(dev, val, CONFIG_TSRA | (cid << 3) | 1)
#define he_writel_tsr2(dev, val, cid) \
he_writel_tcm(dev, val, CONFIG_TSRA | (cid<<3) | 2)
he_writel_tcm(dev, val, CONFIG_TSRA | (cid << 3) | 2)
#define he_writel_tsr3(dev, val, cid) \
he_writel_tcm(dev, val, CONFIG_TSRA | (cid<<3) | 3)
he_writel_tcm(dev, val, CONFIG_TSRA | (cid << 3) | 3)
#define he_writel_tsr4(dev, val, cid) \
he_writel_tcm(dev, val, CONFIG_TSRA | (cid<<3) | 4)
he_writel_tcm(dev, val, CONFIG_TSRA | (cid << 3) | 4)
/* from page 2-20
*
......@@ -263,43 +250,43 @@ he_readl_internal(struct he_dev *he_dev, unsigned addr, unsigned flags)
*/
#define he_writel_tsr4_upper(dev, val, cid) \
he_writel_internal(dev, val, CONFIG_TSRA | (cid<<3) | 4, \
he_writel_internal(dev, val, CONFIG_TSRA | (cid << 3) | 4, \
CON_CTL_TCM \
| CON_BYTE_DISABLE_2 \
| CON_BYTE_DISABLE_1 \
| CON_BYTE_DISABLE_0)
#define he_readl_tsr4(dev, cid) \
he_readl_tcm(dev, CONFIG_TSRA | (cid<<3) | 4)
he_readl_tcm(dev, CONFIG_TSRA | (cid << 3) | 4)
#define he_writel_tsr5(dev, val, cid) \
he_writel_tcm(dev, val, CONFIG_TSRA | (cid<<3) | 5)
he_writel_tcm(dev, val, CONFIG_TSRA | (cid << 3) | 5)
#define he_writel_tsr6(dev, val, cid) \
he_writel_tcm(dev, val, CONFIG_TSRA | (cid<<3) | 6)
he_writel_tcm(dev, val, CONFIG_TSRA | (cid << 3) | 6)
#define he_writel_tsr7(dev, val, cid) \
he_writel_tcm(dev, val, CONFIG_TSRA | (cid<<3) | 7)
he_writel_tcm(dev, val, CONFIG_TSRA | (cid << 3) | 7)
#define he_writel_tsr8(dev, val, cid) \
he_writel_tcm(dev, val, CONFIG_TSRB | (cid<<2) | 0)
he_writel_tcm(dev, val, CONFIG_TSRB | (cid << 2) | 0)
#define he_writel_tsr9(dev, val, cid) \
he_writel_tcm(dev, val, CONFIG_TSRB | (cid<<2) | 1)
he_writel_tcm(dev, val, CONFIG_TSRB | (cid << 2) | 1)
#define he_writel_tsr10(dev, val, cid) \
he_writel_tcm(dev, val, CONFIG_TSRB | (cid<<2) | 2)
he_writel_tcm(dev, val, CONFIG_TSRB | (cid << 2) | 2)
#define he_writel_tsr11(dev, val, cid) \
he_writel_tcm(dev, val, CONFIG_TSRB | (cid<<2) | 3)
he_writel_tcm(dev, val, CONFIG_TSRB | (cid << 2) | 3)
#define he_writel_tsr12(dev, val, cid) \
he_writel_tcm(dev, val, CONFIG_TSRC | (cid<<1) | 0)
he_writel_tcm(dev, val, CONFIG_TSRC | (cid << 1) | 0)
#define he_writel_tsr13(dev, val, cid) \
he_writel_tcm(dev, val, CONFIG_TSRC | (cid<<1) | 1)
he_writel_tcm(dev, val, CONFIG_TSRC | (cid << 1) | 1)
#define he_writel_tsr14(dev, val, cid) \
......@@ -315,30 +302,30 @@ he_readl_internal(struct he_dev *he_dev, unsigned addr, unsigned flags)
/* 2.7.1 per connection receive state registers */
#define he_writel_rsr0(dev, val, cid) \
he_writel_rcm(dev, val, 0x00000 | (cid<<3) | 0)
he_writel_rcm(dev, val, 0x00000 | (cid << 3) | 0)
#define he_readl_rsr0(dev, cid) \
he_readl_rcm(dev, 0x00000 | (cid<<3) | 0)
he_readl_rcm(dev, 0x00000 | (cid << 3) | 0)
#define he_writel_rsr1(dev, val, cid) \
he_writel_rcm(dev, val, 0x00000 | (cid<<3) | 1)
he_writel_rcm(dev, val, 0x00000 | (cid << 3) | 1)
#define he_writel_rsr2(dev, val, cid) \
he_writel_rcm(dev, val, 0x00000 | (cid<<3) | 2)
he_writel_rcm(dev, val, 0x00000 | (cid << 3) | 2)
#define he_writel_rsr3(dev, val, cid) \
he_writel_rcm(dev, val, 0x00000 | (cid<<3) | 3)
he_writel_rcm(dev, val, 0x00000 | (cid << 3) | 3)
#define he_writel_rsr4(dev, val, cid) \
he_writel_rcm(dev, val, 0x00000 | (cid<<3) | 4)
he_writel_rcm(dev, val, 0x00000 | (cid << 3) | 4)
#define he_writel_rsr5(dev, val, cid) \
he_writel_rcm(dev, val, 0x00000 | (cid<<3) | 5)
he_writel_rcm(dev, val, 0x00000 | (cid << 3) | 5)
#define he_writel_rsr6(dev, val, cid) \
he_writel_rcm(dev, val, 0x00000 | (cid<<3) | 6)
he_writel_rcm(dev, val, 0x00000 | (cid << 3) | 6)
#define he_writel_rsr7(dev, val, cid) \
he_writel_rcm(dev, val, 0x00000 | (cid<<3) | 7)
he_writel_rcm(dev, val, 0x00000 | (cid << 3) | 7)
static __inline__ struct atm_vcc*
he_find_vcc(struct he_dev *he_dev, unsigned cid)
......@@ -349,7 +336,7 @@ he_find_vcc(struct he_dev *he_dev, unsigned cid)
int vci;
vpi = cid >> he_dev->vcibits;
vci = cid & ((1<<he_dev->vcibits)-1);
vci = cid & ((1 << he_dev->vcibits) - 1);
spin_lock_irqsave(&he_dev->atm_dev->lock, flags);
for (vcc = he_dev->atm_dev->vccs; vcc; vcc = vcc->next)
......@@ -443,112 +430,112 @@ he_remove_one (struct pci_dev *pci_dev)
static unsigned
rate_to_atmf(unsigned rate) /* cps to atm forum format */
{
#define NONZERO (1<<14)
#define NONZERO (1 << 14)
unsigned exp = 0;
unsigned exp = 0;
if (rate == 0)
return(0);
if (rate == 0)
return 0;
rate <<= 9;
while (rate > 0x3ff) {
++exp;
rate >>= 1;
}
rate <<= 9;
while (rate > 0x3ff) {
++exp;
rate >>= 1;
}
return (NONZERO | (exp << 9) | (rate & 0x1ff));
return (NONZERO | (exp << 9) | (rate & 0x1ff));
}
static void __init
he_init_rx_lbfp0(struct he_dev *he_dev)
{
unsigned i, lbm_offset, lbufd_index, lbuf_addr, lbuf_count;
unsigned lbufs_per_row = he_dev->cells_per_row / he_dev->cells_per_lbuf;
unsigned lbuf_bufsize = he_dev->cells_per_lbuf * ATM_CELL_PAYLOAD;
unsigned row_offset = he_dev->r0_startrow * he_dev->bytes_per_row;
unsigned i, lbm_offset, lbufd_index, lbuf_addr, lbuf_count;
unsigned lbufs_per_row = he_dev->cells_per_row / he_dev->cells_per_lbuf;
unsigned lbuf_bufsize = he_dev->cells_per_lbuf * ATM_CELL_PAYLOAD;
unsigned row_offset = he_dev->r0_startrow * he_dev->bytes_per_row;
lbufd_index = 0;
lbm_offset = he_readl(he_dev, RCMLBM_BA);
lbm_offset = he_readl(he_dev, RCMLBM_BA);
he_writel(he_dev, lbufd_index, RLBF0_H);
for (i = 0, lbuf_count = 0; i < he_dev->r0_numbuffs; ++i) {
for (i = 0, lbuf_count = 0; i < he_dev->r0_numbuffs; ++i) {
lbufd_index += 2;
lbuf_addr = (row_offset + (lbuf_count * lbuf_bufsize)) / 32;
lbuf_addr = (row_offset + (lbuf_count * lbuf_bufsize)) / 32;
he_writel_rcm(he_dev, lbuf_addr, lbm_offset);
he_writel_rcm(he_dev, lbufd_index, lbm_offset + 1);
if (++lbuf_count == lbufs_per_row) {
lbuf_count = 0;
row_offset += he_dev->bytes_per_row;
}
if (++lbuf_count == lbufs_per_row) {
lbuf_count = 0;
row_offset += he_dev->bytes_per_row;
}
lbm_offset += 4;
}
he_writel(he_dev, lbufd_index - 2, RLBF0_T);
}
he_writel(he_dev, lbufd_index - 2, RLBF0_T);
he_writel(he_dev, he_dev->r0_numbuffs, RLBF0_C);
}
static void __init
he_init_rx_lbfp1(struct he_dev *he_dev)
{
unsigned i, lbm_offset, lbufd_index, lbuf_addr, lbuf_count;
unsigned lbufs_per_row = he_dev->cells_per_row / he_dev->cells_per_lbuf;
unsigned lbuf_bufsize = he_dev->cells_per_lbuf * ATM_CELL_PAYLOAD;
unsigned row_offset = he_dev->r1_startrow * he_dev->bytes_per_row;
unsigned i, lbm_offset, lbufd_index, lbuf_addr, lbuf_count;
unsigned lbufs_per_row = he_dev->cells_per_row / he_dev->cells_per_lbuf;
unsigned lbuf_bufsize = he_dev->cells_per_lbuf * ATM_CELL_PAYLOAD;
unsigned row_offset = he_dev->r1_startrow * he_dev->bytes_per_row;
lbufd_index = 1;
lbm_offset = he_readl(he_dev, RCMLBM_BA) + (2 * lbufd_index);
lbm_offset = he_readl(he_dev, RCMLBM_BA) + (2 * lbufd_index);
he_writel(he_dev, lbufd_index, RLBF1_H);
for (i = 0, lbuf_count = 0; i < he_dev->r1_numbuffs; ++i) {
for (i = 0, lbuf_count = 0; i < he_dev->r1_numbuffs; ++i) {
lbufd_index += 2;
lbuf_addr = (row_offset + (lbuf_count * lbuf_bufsize)) / 32;
lbuf_addr = (row_offset + (lbuf_count * lbuf_bufsize)) / 32;
he_writel_rcm(he_dev, lbuf_addr, lbm_offset);
he_writel_rcm(he_dev, lbufd_index, lbm_offset + 1);
if (++lbuf_count == lbufs_per_row) {
lbuf_count = 0;
row_offset += he_dev->bytes_per_row;
}
if (++lbuf_count == lbufs_per_row) {
lbuf_count = 0;
row_offset += he_dev->bytes_per_row;
}
lbm_offset += 4;
}
he_writel(he_dev, lbufd_index - 2, RLBF1_T);
}
he_writel(he_dev, lbufd_index - 2, RLBF1_T);
he_writel(he_dev, he_dev->r1_numbuffs, RLBF1_C);
}
static void __init
he_init_tx_lbfp(struct he_dev *he_dev)
{
unsigned i, lbm_offset, lbufd_index, lbuf_addr, lbuf_count;
unsigned lbufs_per_row = he_dev->cells_per_row / he_dev->cells_per_lbuf;
unsigned lbuf_bufsize = he_dev->cells_per_lbuf * ATM_CELL_PAYLOAD;
unsigned row_offset = he_dev->tx_startrow * he_dev->bytes_per_row;
unsigned i, lbm_offset, lbufd_index, lbuf_addr, lbuf_count;
unsigned lbufs_per_row = he_dev->cells_per_row / he_dev->cells_per_lbuf;
unsigned lbuf_bufsize = he_dev->cells_per_lbuf * ATM_CELL_PAYLOAD;
unsigned row_offset = he_dev->tx_startrow * he_dev->bytes_per_row;
lbufd_index = he_dev->r0_numbuffs + he_dev->r1_numbuffs;
lbm_offset = he_readl(he_dev, RCMLBM_BA) + (2 * lbufd_index);
lbm_offset = he_readl(he_dev, RCMLBM_BA) + (2 * lbufd_index);
he_writel(he_dev, lbufd_index, TLBF_H);
for (i = 0, lbuf_count = 0; i < he_dev->tx_numbuffs; ++i) {
for (i = 0, lbuf_count = 0; i < he_dev->tx_numbuffs; ++i) {
lbufd_index += 1;
lbuf_addr = (row_offset + (lbuf_count * lbuf_bufsize)) / 32;
lbuf_addr = (row_offset + (lbuf_count * lbuf_bufsize)) / 32;
he_writel_rcm(he_dev, lbuf_addr, lbm_offset);
he_writel_rcm(he_dev, lbufd_index, lbm_offset + 1);
if (++lbuf_count == lbufs_per_row) {
lbuf_count = 0;
row_offset += he_dev->bytes_per_row;
}
if (++lbuf_count == lbufs_per_row) {
lbuf_count = 0;
row_offset += he_dev->bytes_per_row;
}
lbm_offset += 2;
}
he_writel(he_dev, lbufd_index - 1, TLBF_T);
}
he_writel(he_dev, lbufd_index - 1, TLBF_T);
}
static int __init
......@@ -678,7 +665,7 @@ he_init_cs_block_rcm(struct he_dev *he_dev)
unsigned rate_atmf, exp, man;
unsigned long long rate_cps;
int mult, buf, buf_limit = 4;
int mult, buf, buf_limit = 4;
rategrid = kmalloc( sizeof(unsigned) * 16 * 16, GFP_KERNEL);
if (!rategrid)
......@@ -757,30 +744,31 @@ he_init_cs_block_rcm(struct he_dev *he_dev)
*/
#ifdef notdef
buf = rate_cps * he_dev->tx_numbuffs /
buf = rate_cps * he_dev->tx_numbuffs /
(he_dev->atm_dev->link_rate * 2);
#else
/* this is pretty, but avoids _divdu3 and is mostly correct */
buf = 0;
mult = he_dev->atm_dev->link_rate / ATM_OC3_PCR;
if (rate_cps > (68 * mult))
buf = 1;
if (rate_cps > (136 * mult))
buf = 2;
if (rate_cps > (204 * mult))
buf = 3;
if (rate_cps > (272 * mult))
mult = he_dev->atm_dev->link_rate / ATM_OC3_PCR;
if (rate_cps > (272 * mult))
buf = 4;
else if (rate_cps > (204 * mult))
buf = 3;
else if (rate_cps > (136 * mult))
buf = 2;
else if (rate_cps > (68 * mult))
buf = 1;
else
buf = 0;
#endif
if (buf > buf_limit)
if (buf > buf_limit)
buf = buf_limit;
reg = (reg<<16) | ((i<<8) | buf);
reg = (reg << 16) | ((i << 8) | buf);
#define RTGTBL_OFFSET 0x400
if (rate_atmf & 0x1)
he_writel_rcm(he_dev, reg,
CONFIG_RCMABR + RTGTBL_OFFSET + (rate_atmf>>1));
CONFIG_RCMABR + RTGTBL_OFFSET + (rate_atmf >> 1));
++rate_atmf;
}
......@@ -839,7 +827,7 @@ he_init_group(struct he_dev *he_dev, int group)
he_dev->rbps_base[i].phys = dma_handle;
}
he_dev->rbps_tail = &he_dev->rbps_base[CONFIG_RBPS_SIZE-1];
he_dev->rbps_tail = &he_dev->rbps_base[CONFIG_RBPS_SIZE - 1];
he_writel(he_dev, he_dev->rbps_phys, G0_RBPS_S + (group * 32));
he_writel(he_dev, RBPS_MASK(he_dev->rbps_tail),
......@@ -848,7 +836,7 @@ he_init_group(struct he_dev *he_dev, int group)
G0_RBPS_BS + (group * 32));
he_writel(he_dev,
RBP_THRESH(CONFIG_RBPS_THRESH) |
RBP_QSIZE(CONFIG_RBPS_SIZE-1) |
RBP_QSIZE(CONFIG_RBPS_SIZE - 1) |
RBP_INT_ENB,
G0_RBPS_QI + (group * 32));
#else /* !USE_RBPS */
......@@ -902,7 +890,7 @@ he_init_group(struct he_dev *he_dev, int group)
he_dev->rbpl_base[i].status = RBP_LOANED | (i << RBP_INDEX_OFF);
he_dev->rbpl_base[i].phys = dma_handle;
}
he_dev->rbpl_tail = &he_dev->rbpl_base[CONFIG_RBPL_SIZE-1];
he_dev->rbpl_tail = &he_dev->rbpl_base[CONFIG_RBPL_SIZE - 1];
he_writel(he_dev, he_dev->rbpl_phys, G0_RBPL_S + (group * 32));
he_writel(he_dev, RBPL_MASK(he_dev->rbpl_tail),
......@@ -911,7 +899,7 @@ he_init_group(struct he_dev *he_dev, int group)
G0_RBPL_BS + (group * 32));
he_writel(he_dev,
RBP_THRESH(CONFIG_RBPL_THRESH) |
RBP_QSIZE(CONFIG_RBPL_SIZE-1) |
RBP_QSIZE(CONFIG_RBPL_SIZE - 1) |
RBP_INT_ENB,
G0_RBPL_QI + (group * 32));
......@@ -929,7 +917,7 @@ he_init_group(struct he_dev *he_dev, int group)
he_writel(he_dev, he_dev->rbrq_phys, G0_RBRQ_ST + (group * 16));
he_writel(he_dev, 0, G0_RBRQ_H + (group * 16));
he_writel(he_dev,
RBRQ_THRESH(CONFIG_RBRQ_THRESH) | RBRQ_SIZE(CONFIG_RBRQ_SIZE-1),
RBRQ_THRESH(CONFIG_RBRQ_THRESH) | RBRQ_SIZE(CONFIG_RBRQ_SIZE - 1),
G0_RBRQ_Q + (group * 16));
if (irq_coalesce) {
hprintk("coalescing interrupts\n");
......@@ -967,7 +955,7 @@ he_init_irq(struct he_dev *he_dev)
/* 2.9.3.5 tail offset for each interrupt queue is located after the
end of the interrupt queue */
he_dev->irq_base = pci_alloc_consistent(he_dev->pci_dev,
he_dev->irq_base = pci_alloc_consistent(he_dev->pci_dev,
(CONFIG_IRQ_SIZE+1) * sizeof(struct he_irq), &he_dev->irq_phys);
if (he_dev->irq_base == NULL) {
hprintk("failed to allocate irq\n");
......@@ -979,7 +967,7 @@ he_init_irq(struct he_dev *he_dev)
he_dev->irq_head = he_dev->irq_base;
he_dev->irq_tail = he_dev->irq_base;
for (i=0; i < CONFIG_IRQ_SIZE; ++i)
for (i = 0; i < CONFIG_IRQ_SIZE; ++i)
he_dev->irq_base[i].isw = ITYPE_INVALID;
he_writel(he_dev, he_dev->irq_phys, IRQ0_BASE);
......@@ -1014,23 +1002,18 @@ he_init_irq(struct he_dev *he_dev)
if (request_irq(he_dev->pci_dev->irq, he_irq_handler, SA_INTERRUPT|SA_SHIRQ, DEV_LABEL, he_dev)) {
hprintk("irq %d already in use\n", he_dev->pci_dev->irq);
return -EINVAL;
}
}
he_dev->irq = he_dev->pci_dev->irq;
#ifdef BUS_INT_WAR
HPRINTK("sn_add_polled_interrupt(irq %d, 1)\n", he_dev->irq);
sn_add_polled_interrupt(he_dev->irq, 1);
#endif
return 0;
}
static int __init
he_start(struct atm_dev *dev)
{
struct he_dev *he_dev;
struct pci_dev *pci_dev;
struct he_dev *he_dev;
struct pci_dev *pci_dev;
u16 command;
u32 gen_cntl_0, host_cntl, lb_swap;
......@@ -1040,8 +1023,8 @@ he_start(struct atm_dev *dev)
unsigned int status, reg;
int i, group;
he_dev = HE_DEV(dev);
pci_dev = he_dev->pci_dev;
he_dev = HE_DEV(dev);
pci_dev = he_dev->pci_dev;
he_dev->membase = pci_dev->resource[0].start;
HPRINTK("membase = 0x%lx irq = %d.\n", he_dev->membase, pci_dev->irq);
......@@ -1108,7 +1091,7 @@ he_start(struct atm_dev *dev)
hprintk("can't set up page mapping\n");
return -EINVAL;
}
/* 4.4 card reset */
he_writel(he_dev, 0x0, RESET_CNTL);
he_writel(he_dev, 0xff, RESET_CNTL);
......@@ -1138,12 +1121,12 @@ he_start(struct atm_dev *dev)
pci_write_config_dword(pci_dev, GEN_CNTL_0, gen_cntl_0);
/* 4.7 read prom contents */
for (i=0; i<PROD_ID_LEN; ++i)
for (i = 0; i < PROD_ID_LEN; ++i)
he_dev->prod_id[i] = read_prom_byte(he_dev, PROD_ID + i);
he_dev->media = read_prom_byte(he_dev, MEDIA);
for (i=0; i<6; ++i)
for (i = 0; i < 6; ++i)
dev->esi[i] = read_prom_byte(he_dev, MAC_ADDR + i);
hprintk("%s%s, %x:%x:%x:%x:%x:%x\n",
......@@ -1323,15 +1306,15 @@ he_start(struct atm_dev *dev)
he_writel(he_dev, 0x0, TXAAL5_PROTO);
he_writel(he_dev, PHY_INT_ENB |
(he_is622(he_dev) ? PTMR_PRE(67-1) : PTMR_PRE(50-1)),
(he_is622(he_dev) ? PTMR_PRE(67 - 1) : PTMR_PRE(50 - 1)),
RH_CONFIG);
/* 5.1.3 initialize connection memory */
for (i=0; i < TCM_MEM_SIZE; ++i)
for (i = 0; i < TCM_MEM_SIZE; ++i)
he_writel_tcm(he_dev, 0, i);
for (i=0; i < RCM_MEM_SIZE; ++i)
for (i = 0; i < RCM_MEM_SIZE; ++i)
he_writel_rcm(he_dev, 0, i);
/*
......@@ -1512,7 +1495,7 @@ he_start(struct atm_dev *dev)
}
he_dev->tpd_head = he_dev->tpd_base;
he_dev->tpd_end = &he_dev->tpd_base[CONFIG_NUMTPDS-1];
he_dev->tpd_end = &he_dev->tpd_base[CONFIG_NUMTPDS - 1];
#endif
if (he_init_group(he_dev, 0) != 0)
......@@ -1608,8 +1591,8 @@ he_start(struct atm_dev *dev)
he_dev->irq_peak = 0;
he_dev->rbrq_peak = 0;
he_dev->rbpl_peak = 0;
he_dev->tbrq_peak = 0;
he_dev->rbpl_peak = 0;
he_dev->tbrq_peak = 0;
HPRINTK("hell bent for leather!\n");
......@@ -1652,12 +1635,8 @@ he_stop(struct he_dev *he_dev)
he_dev->atm_dev->phy->stop(he_dev->atm_dev);
#endif /* CONFIG_ATM_HE_USE_SUNI */
if (he_dev->irq) {
#ifdef BUS_INT_WAR
sn_delete_polled_interrupt(he_dev->irq);
#endif
if (he_dev->irq)
free_irq(he_dev->irq, he_dev);
}
if (he_dev->irq_base)
pci_free_consistent(he_dev->pci_dev, (CONFIG_IRQ_SIZE+1)
......@@ -1669,7 +1648,7 @@ he_stop(struct he_dev *he_dev)
if (he_dev->rbpl_base) {
#ifdef USE_RBPL_POOL
for (i=0; i<CONFIG_RBPL_SIZE; ++i) {
for (i = 0; i < CONFIG_RBPL_SIZE; ++i) {
void *cpuaddr = he_dev->rbpl_virt[i].virt;
dma_addr_t dma_handle = he_dev->rbpl_base[i].phys;
......@@ -1691,7 +1670,7 @@ he_stop(struct he_dev *he_dev)
#ifdef USE_RBPS
if (he_dev->rbps_base) {
#ifdef USE_RBPS_POOL
for (i=0; i<CONFIG_RBPS_SIZE; ++i) {
for (i = 0; i < CONFIG_RBPS_SIZE; ++i) {
void *cpuaddr = he_dev->rbps_virt[i].virt;
dma_addr_t dma_handle = he_dev->rbps_base[i].phys;
......@@ -1790,7 +1769,7 @@ __alloc_tpd(struct he_dev *he_dev)
}
#define AAL5_LEN(buf,len) \
((((unsigned char *)(buf))[(len)-6]<<8) | \
((((unsigned char *)(buf))[(len)-6] << 8) | \
(((unsigned char *)(buf))[(len)-5]))
/* 2.10.1.2 receive
......@@ -1800,7 +1779,7 @@ __alloc_tpd(struct he_dev *he_dev)
*/
#define TCP_CKSUM(buf,len) \
((((unsigned char *)(buf))[(len)-2]<<8) | \
((((unsigned char *)(buf))[(len)-2] << 8) | \
(((unsigned char *)(buf))[(len-1)]))
static int
......@@ -2123,7 +2102,7 @@ he_service_rbpl(struct he_dev *he_dev, int group)
if (moved) {
he_writel(he_dev, RBPL_MASK(he_dev->rbpl_tail), G0_RBPL_T);
#ifdef CONFIG_IA64_SGI_SN2
(void) he_readl(he_dev, G0_RBPL_T);
(void) he_readl(he_dev, G0_RBPL_T);
#endif
}
}
......@@ -2155,7 +2134,7 @@ he_service_rbps(struct he_dev *he_dev, int group)
if (moved) {
he_writel(he_dev, RBPS_MASK(he_dev->rbps_tail), G0_RBPS_T);
#ifdef CONFIG_IA64_SGI_SN2
(void) he_readl(he_dev, G0_RBPS_T);
(void) he_readl(he_dev, G0_RBPS_T);
#endif
}
}
......@@ -2171,7 +2150,7 @@ he_tasklet(unsigned long data)
HPRINTK("tasklet (0x%lx)\n", data);
#ifdef USE_TASKLET
HE_SPIN_LOCK(he_dev, flags);
spin_lock_irqsave(&he_dev->global_lock, flags);
#endif
while (he_dev->irq_head != he_dev->irq_tail) {
......@@ -2209,10 +2188,10 @@ he_tasklet(unsigned long data)
case ITYPE_PHY:
HPRINTK("phy interrupt\n");
#ifdef CONFIG_ATM_HE_USE_SUNI
HE_SPIN_UNLOCK(he_dev, flags);
spin_unlock_irqrestore(&he_dev->global_lock, flags);
if (he_dev->atm_dev->phy && he_dev->atm_dev->phy->interrupt)
he_dev->atm_dev->phy->interrupt(he_dev->atm_dev);
HE_SPIN_LOCK(he_dev, flags);
spin_lock_irqsave(&he_dev->global_lock, flags);
#endif
break;
case ITYPE_OTHER:
......@@ -2257,7 +2236,7 @@ he_tasklet(unsigned long data)
(void) he_readl(he_dev, INT_FIFO); /* 8.1.2 controller errata */
}
#ifdef USE_TASKLET
HE_SPIN_UNLOCK(he_dev, flags);
spin_unlock_irqrestore(&he_dev->global_lock, flags);
#endif
}
......@@ -2271,7 +2250,7 @@ he_irq_handler(int irq, void *dev_id, struct pt_regs *regs)
if (he_dev == NULL)
return IRQ_NONE;
HE_SPIN_LOCK(he_dev, flags);
spin_lock_irqsave(&he_dev->global_lock, flags);
he_dev->irq_tail = (struct he_irq *) (((unsigned long)he_dev->irq_base) |
(*he_dev->irq_tailoffset << 2));
......@@ -2301,7 +2280,7 @@ he_irq_handler(int irq, void *dev_id, struct pt_regs *regs)
(void) he_readl(he_dev, INT_FIFO);
#endif
}
HE_SPIN_UNLOCK(he_dev, flags);
spin_unlock_irqrestore(&he_dev->global_lock, flags);
return IRQ_RETVAL(handled);
}
......@@ -2416,11 +2395,11 @@ he_open(struct atm_vcc *vcc, short vpi, int vci)
if (vcc->qos.txtp.traffic_class != ATM_NONE) {
int pcr_goal;
pcr_goal = atm_pcr_goal(&vcc->qos.txtp);
if (pcr_goal == 0)
pcr_goal = he_dev->atm_dev->link_rate;
if (pcr_goal < 0) /* means round down, technically */
pcr_goal = -pcr_goal;
pcr_goal = atm_pcr_goal(&vcc->qos.txtp);
if (pcr_goal == 0)
pcr_goal = he_dev->atm_dev->link_rate;
if (pcr_goal < 0) /* means round down, technically */
pcr_goal = -pcr_goal;
HPRINTK("open tx cid 0x%x pcr_goal %d\n", cid, pcr_goal);
......@@ -2438,9 +2417,9 @@ he_open(struct atm_vcc *vcc, short vpi, int vci)
goto open_failed;
}
HE_SPIN_LOCK(he_dev, flags);
spin_lock_irqsave(&he_dev->global_lock, flags);
tsr0 = he_readl_tsr0(he_dev, cid);
HE_SPIN_UNLOCK(he_dev, flags);
spin_unlock_irqrestore(&he_dev->global_lock, flags);
if (TSR0_CONN_STATE(tsr0) != 0) {
hprintk("cid 0x%x not idle (tsr0 = 0x%x)\n", cid, tsr0);
......@@ -2467,7 +2446,7 @@ he_open(struct atm_vcc *vcc, short vpi, int vci)
goto open_failed;
}
HE_SPIN_LOCK(he_dev, flags); /* also protects he_dev->cs_stper[] */
spin_lock_irqsave(&he_dev->global_lock, flags); /* also protects he_dev->cs_stper[] */
/* find an unused cs_stper register */
for (reg = 0; reg < HE_NUM_CS_STPER; ++reg)
......@@ -2477,7 +2456,7 @@ he_open(struct atm_vcc *vcc, short vpi, int vci)
if (reg == HE_NUM_CS_STPER) {
err = -EBUSY;
HE_SPIN_UNLOCK(he_dev, flags);
spin_unlock_irqrestore(&he_dev->global_lock, flags);
goto open_failed;
}
......@@ -2495,7 +2474,7 @@ he_open(struct atm_vcc *vcc, short vpi, int vci)
he_writel_mbox(he_dev, rate_to_atmf(period/2),
CS_STPER0 + reg);
HE_SPIN_UNLOCK(he_dev, flags);
spin_unlock_irqrestore(&he_dev->global_lock, flags);
tsr0 = TSR0_CBR | TSR0_GROUP(0) | tsr0_aal |
TSR0_RC_INDEX(reg);
......@@ -2506,7 +2485,7 @@ he_open(struct atm_vcc *vcc, short vpi, int vci)
goto open_failed;
}
HE_SPIN_LOCK(he_dev, flags);
spin_lock_irqsave(&he_dev->global_lock, flags);
he_writel_tsr0(he_dev, tsr0, cid);
he_writel_tsr4(he_dev, tsr4 | 1, cid);
......@@ -2528,7 +2507,7 @@ he_open(struct atm_vcc *vcc, short vpi, int vci)
#ifdef CONFIG_IA64_SGI_SN2
(void) he_readl_tsr0(he_dev, cid);
#endif
HE_SPIN_UNLOCK(he_dev, flags);
spin_unlock_irqrestore(&he_dev->global_lock, flags);
}
if (vcc->qos.rxtp.traffic_class != ATM_NONE) {
......@@ -2549,11 +2528,11 @@ he_open(struct atm_vcc *vcc, short vpi, int vci)
goto open_failed;
}
HE_SPIN_LOCK(he_dev, flags);
spin_lock_irqsave(&he_dev->global_lock, flags);
rsr0 = he_readl_rsr0(he_dev, cid);
if (rsr0 & RSR0_OPEN_CONN) {
HE_SPIN_UNLOCK(he_dev, flags);
spin_unlock_irqrestore(&he_dev->global_lock, flags);
hprintk("cid 0x%x not idle (rsr0 = 0x%x)\n", cid, rsr0);
err = -EBUSY;
......@@ -2578,14 +2557,14 @@ he_open(struct atm_vcc *vcc, short vpi, int vci)
he_writel_rsr4(he_dev, rsr4, cid);
he_writel_rsr1(he_dev, rsr1, cid);
/* 5.1.11 last parameter initialized should be
the open/closed indication in rsr0 */
the open/closed indication in rsr0 */
he_writel_rsr0(he_dev,
rsr0 | RSR0_START_PDU | RSR0_OPEN_CONN | aal, cid);
#ifdef CONFIG_IA64_SGI_SN2
(void) he_readl_rsr0(he_dev, cid);
#endif
HE_SPIN_UNLOCK(he_dev, flags);
spin_unlock_irqrestore(&he_dev->global_lock, flags);
#ifndef USE_HE_FIND_VCC
HE_LOOKUP_VCC(he_dev, cid) = vcc;
......@@ -2631,7 +2610,7 @@ he_close(struct atm_vcc *vcc)
/* wait for previous close (if any) to finish */
HE_SPIN_LOCK(he_dev, flags);
spin_lock_irqsave(&he_dev->global_lock, flags);
while (he_readl(he_dev, RCC_STAT) & RCC_BUSY) {
HPRINTK("close cid 0x%x RCC_BUSY\n", cid);
udelay(250);
......@@ -2645,7 +2624,7 @@ he_close(struct atm_vcc *vcc)
(void) he_readl_rsr0(he_dev, cid);
#endif
he_writel_mbox(he_dev, cid, RXCON_CLOSE);
HE_SPIN_UNLOCK(he_dev, flags);
spin_unlock_irqrestore(&he_dev->global_lock, flags);
timeout = schedule_timeout(30*HZ);
......@@ -2693,7 +2672,7 @@ he_close(struct atm_vcc *vcc)
/* 2.3.1.1 generic close operations with flush */
HE_SPIN_LOCK(he_dev, flags);
spin_lock_irqsave(&he_dev->global_lock, flags);
he_writel_tsr4_upper(he_dev, TSR4_FLUSH_CONN, cid);
/* also clears TSR4_SESSION_ENDED */
#ifdef CONFIG_IA64_SGI_SN2
......@@ -2724,7 +2703,7 @@ he_close(struct atm_vcc *vcc)
add_wait_queue(&he_vcc->tx_waitq, &wait);
set_current_state(TASK_UNINTERRUPTIBLE);
__enqueue_tpd(he_dev, tpd, cid);
HE_SPIN_UNLOCK(he_dev, flags);
spin_unlock_irqrestore(&he_dev->global_lock, flags);
timeout = schedule_timeout(30*HZ);
......@@ -2736,7 +2715,7 @@ he_close(struct atm_vcc *vcc)
goto close_tx_incomplete;
}
HE_SPIN_LOCK(he_dev, flags);
spin_lock_irqsave(&he_dev->global_lock, flags);
while (!((tsr4 = he_readl_tsr4(he_dev, cid)) & TSR4_SESSION_ENDED)) {
HPRINTK("close tx cid 0x%x !TSR4_SESSION_ENDED (tsr4 = 0x%x)\n", cid, tsr4);
udelay(250);
......@@ -2761,7 +2740,7 @@ he_close(struct atm_vcc *vcc)
he_dev->total_bw -= he_dev->cs_stper[reg].pcr;
}
HE_SPIN_UNLOCK(he_dev, flags);
spin_unlock_irqrestore(&he_dev->global_lock, flags);
HPRINTK("close tx cid 0x%x complete\n", cid);
}
......@@ -2818,7 +2797,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
return -EINVAL;
}
#endif
HE_SPIN_LOCK(he_dev, flags);
spin_lock_irqsave(&he_dev->global_lock, flags);
tpd = __alloc_tpd(he_dev);
if (tpd == NULL) {
......@@ -2827,7 +2806,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
else
dev_kfree_skb_any(skb);
atomic_inc(&vcc->stats->tx_err);
HE_SPIN_UNLOCK(he_dev, flags);
spin_unlock_irqrestore(&he_dev->global_lock, flags);
return -ENOMEM;
}
......@@ -2869,7 +2848,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
else
dev_kfree_skb_any(skb);
atomic_inc(&vcc->stats->tx_err);
HE_SPIN_UNLOCK(he_dev, flags);
spin_unlock_irqrestore(&he_dev->global_lock, flags);
return -ENOMEM;
}
tpd->status |= TPD_USERCELL;
......@@ -2884,7 +2863,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
}
tpd->iovec[slot-1].len |= TPD_LST;
tpd->iovec[slot - 1].len |= TPD_LST;
#else
tpd->address0 = pci_map_single(he_dev->pci_dev, skb->data, skb->len, PCI_DMA_TODEVICE);
tpd->length0 = skb->len | TPD_LST;
......@@ -2897,7 +2876,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
ATM_SKB(skb)->vcc = vcc;
__enqueue_tpd(he_dev, tpd, cid);
HE_SPIN_UNLOCK(he_dev, flags);
spin_unlock_irqrestore(&he_dev->global_lock, flags);
atomic_inc(&vcc->stats->tx);
......@@ -2919,7 +2898,7 @@ he_ioctl(struct atm_dev *atm_dev, unsigned int cmd, void *arg)
copy_from_user(&reg, (struct he_ioctl_reg *) arg,
sizeof(struct he_ioctl_reg));
HE_SPIN_LOCK(he_dev, flags);
spin_lock_irqsave(&he_dev->global_lock, flags);
switch (reg.type) {
case HE_REGTYPE_PCI:
reg.val = he_readl(he_dev, reg.addr);
......@@ -2940,7 +2919,7 @@ he_ioctl(struct atm_dev *atm_dev, unsigned int cmd, void *arg)
err = -EINVAL;
break;
}
HE_SPIN_UNLOCK(he_dev, flags);
spin_unlock_irqrestore(&he_dev->global_lock, flags);
if (err == 0)
copy_to_user((struct he_ioctl_reg *) arg, &reg,
sizeof(struct he_ioctl_reg));
......@@ -2966,15 +2945,15 @@ he_phy_put(struct atm_dev *atm_dev, unsigned char val, unsigned long addr)
HPRINTK("phy_put(val 0x%x, addr 0x%lx)\n", val, addr);
HE_SPIN_LOCK(he_dev, flags);
he_writel(he_dev, val, FRAMER + (addr*4));
spin_lock_irqsave(&he_dev->global_lock, flags);
he_writel(he_dev, val, FRAMER + (addr*4));
#ifdef CONFIG_IA64_SGI_SN2
(void) he_readl(he_dev, FRAMER + (addr*4));
#endif
HE_SPIN_UNLOCK(he_dev, flags);
spin_unlock_irqrestore(&he_dev->global_lock, flags);
}
static unsigned char
he_phy_get(struct atm_dev *atm_dev, unsigned long addr)
{
......@@ -2982,9 +2961,9 @@ he_phy_get(struct atm_dev *atm_dev, unsigned long addr)
struct he_dev *he_dev = HE_DEV(atm_dev);
unsigned reg;
HE_SPIN_LOCK(he_dev, flags);
reg = he_readl(he_dev, FRAMER + (addr*4));
HE_SPIN_UNLOCK(he_dev, flags);
spin_lock_irqsave(&he_dev->global_lock, flags);
reg = he_readl(he_dev, FRAMER + (addr*4));
spin_unlock_irqrestore(&he_dev->global_lock, flags);
HPRINTK("phy_get(addr 0x%lx) =0x%x\n", addr, reg);
return reg;
......@@ -2999,7 +2978,7 @@ he_proc_read(struct atm_dev *dev, loff_t *pos, char *page)
#ifdef notdef
struct he_rbrq *rbrq_tail;
struct he_tpdrq *tpdrq_head;
int rbpl_head, rbpl_tail;
int rbpl_head, rbpl_tail;
#endif
static long mcc = 0, oec = 0, dcc = 0, cec = 0;
......@@ -3015,12 +2994,12 @@ he_proc_read(struct atm_dev *dev, loff_t *pos, char *page)
if (!left--)
return sprintf(page, "Mismatched Cells VPI/VCI Not Open Dropped Cells RCM Dropped Cells\n");
HE_SPIN_LOCK(he_dev, flags);
spin_lock_irqsave(&he_dev->global_lock, flags);
mcc += he_readl(he_dev, MCC);
oec += he_readl(he_dev, OEC);
dcc += he_readl(he_dev, DCC);
cec += he_readl(he_dev, CEC);
HE_SPIN_UNLOCK(he_dev, flags);
spin_unlock_irqrestore(&he_dev->global_lock, flags);
if (!left--)
return sprintf(page, "%16ld %16ld %13ld %17ld\n\n",
......@@ -3044,8 +3023,8 @@ he_proc_read(struct atm_dev *dev, loff_t *pos, char *page)
#ifdef notdef
rbpl_head = RBPL_MASK(he_readl(he_dev, G0_RBPL_S));
rbpl_tail = RBPL_MASK(he_readl(he_dev, G0_RBPL_T));
rbpl_head = RBPL_MASK(he_readl(he_dev, G0_RBPL_S));
rbpl_tail = RBPL_MASK(he_readl(he_dev, G0_RBPL_T));
inuse = rbpl_head - rbpl_tail;
if (inuse < 0)
......@@ -3090,32 +3069,31 @@ read_prom_byte(struct he_dev *he_dev, int addr)
he_writel(he_dev, val, HOST_CNTL);
/* Send READ instruction */
for (i=0; i<sizeof(readtab)/sizeof(readtab[0]); i++) {
for (i = 0; i < sizeof(readtab)/sizeof(readtab[0]); i++) {
he_writel(he_dev, val | readtab[i], HOST_CNTL);
udelay(EEPROM_DELAY);
}
/* Next, we need to send the byte address to read from */
for (i=7; i>=0; i--) {
/* Next, we need to send the byte address to read from */
for (i = 7; i >= 0; i--) {
he_writel(he_dev, val | clocktab[j++] | (((addr >> i) & 1) << 9), HOST_CNTL);
udelay(EEPROM_DELAY);
he_writel(he_dev, val | clocktab[j++] | (((addr >> i) & 1) << 9), HOST_CNTL);
udelay(EEPROM_DELAY);
}
j=0;
j = 0;
val &= 0xFFFFF7FF; /* Turn off write enable */
he_writel(he_dev, val, HOST_CNTL);
/* Now, we can read data from the EEPROM by clocking it in */
for (i=7; i>=0; i--) {
for (i = 7; i >= 0; i--) {
he_writel(he_dev, val | clocktab[j++], HOST_CNTL);
udelay(EEPROM_DELAY);
tmp_read = he_readl(he_dev, HOST_CNTL);
byte_read |= (unsigned char)
((tmp_read & ID_DOUT)
>> ID_DOFFSET << i);
udelay(EEPROM_DELAY);
tmp_read = he_readl(he_dev, HOST_CNTL);
byte_read |= (unsigned char)
((tmp_read & ID_DOUT) >> ID_DOFFSET << i);
he_writel(he_dev, val | clocktab[j++], HOST_CNTL);
udelay(EEPROM_DELAY);
}
......@@ -3123,7 +3101,7 @@ read_prom_byte(struct he_dev *he_dev, int addr)
he_writel(he_dev, val | ID_CS, HOST_CNTL);
udelay(EEPROM_DELAY);
return (byte_read);
return byte_read;
}
MODULE_LICENSE("GPL");
......@@ -3145,7 +3123,7 @@ MODULE_PARM_DESC(sdh, "use SDH framing (default 0)");
static struct pci_device_id he_pci_tbl[] __devinitdata = {
{ PCI_VENDOR_ID_FORE, PCI_DEVICE_ID_FORE_HE, PCI_ANY_ID, PCI_ANY_ID,
0, 0, 0 },
{ 0, }
{ 0, }
};
static struct pci_driver he_driver = {
......@@ -3157,12 +3135,12 @@ static struct pci_driver he_driver = {
static int __init he_init(void)
{
return pci_module_init(&he_driver);
return pci_module_init(&he_driver);
}
static void __exit he_cleanup(void)
{
pci_unregister_driver(&he_driver);
pci_unregister_driver(&he_driver);
}
module_init(he_init);
......
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