56 #include <linux/module.h>
57 #include <linux/kernel.h>
59 #include <linux/pci.h>
60 #include <linux/errno.h>
61 #include <linux/types.h>
62 #include <linux/string.h>
66 #include <linux/sched.h>
70 #include <linux/bitmap.h>
71 #include <linux/slab.h>
73 #include <asm/byteorder.h>
74 #include <asm/uaccess.h>
76 #include <linux/atmdev.h>
77 #include <linux/atm.h>
78 #include <linux/sonet.h>
80 #undef USE_SCATTERGATHER
81 #undef USE_CHECKSUM_HW
88 #define hprintk(fmt,args...) printk(KERN_ERR DEV_LABEL "%d: " fmt, he_dev->number , ##args)
91 #define HPRINTK(fmt,args...) printk(KERN_DEBUG DEV_LABEL "%d: " fmt, he_dev->number , ##args)
93 #define HPRINTK(fmt,args...) do { } while (0)
101 static int he_ioctl(
struct atm_dev *
dev,
unsigned int cmd,
void __user *
arg);
103 static void he_tasklet(
unsigned long data);
107 static void he_phy_put(
struct atm_dev *,
unsigned char,
unsigned long);
108 static unsigned char he_phy_get(
struct atm_dev *,
unsigned long);
114 static struct he_dev *he_devs;
115 static bool disable64;
116 static short nvpibits = -1;
117 static short nvcibits = -1;
118 static short rx_skb_reserve = 16;
119 static bool irq_coalesce = 1;
123 static unsigned int readtab[] = {
144 static unsigned int clocktab[] = {
170 .phy_put = he_phy_put,
171 .phy_get = he_phy_get,
172 .proc_read = he_proc_read,
176 #define he_writel(dev, val, reg) do { writel(val, (dev)->membase + (reg)); wmb(); } while (0)
177 #define he_readl(dev, reg) readl((dev)->membase + (reg))
191 #define he_writel_rcm(dev, val, reg) \
192 he_writel_internal(dev, val, reg, CON_CTL_RCM)
194 #define he_writel_tcm(dev, val, reg) \
195 he_writel_internal(dev, val, reg, CON_CTL_TCM)
197 #define he_writel_mbox(dev, val, reg) \
198 he_writel_internal(dev, val, reg, CON_CTL_MBOX)
208 #define he_readl_rcm(dev, reg) \
209 he_readl_internal(dev, reg, CON_CTL_RCM)
211 #define he_readl_tcm(dev, reg) \
212 he_readl_internal(dev, reg, CON_CTL_TCM)
214 #define he_readl_mbox(dev, reg) \
215 he_readl_internal(dev, reg, CON_CTL_MBOX)
220 #define he_mkcid(dev, vpi, vci) (((vpi << (dev)->vcibits) | vci) & 0x1fff)
224 #define he_writel_tsr0(dev, val, cid) \
225 he_writel_tcm(dev, val, CONFIG_TSRA | (cid << 3) | 0)
226 #define he_readl_tsr0(dev, cid) \
227 he_readl_tcm(dev, CONFIG_TSRA | (cid << 3) | 0)
229 #define he_writel_tsr1(dev, val, cid) \
230 he_writel_tcm(dev, val, CONFIG_TSRA | (cid << 3) | 1)
232 #define he_writel_tsr2(dev, val, cid) \
233 he_writel_tcm(dev, val, CONFIG_TSRA | (cid << 3) | 2)
235 #define he_writel_tsr3(dev, val, cid) \
236 he_writel_tcm(dev, val, CONFIG_TSRA | (cid << 3) | 3)
238 #define he_writel_tsr4(dev, val, cid) \
239 he_writel_tcm(dev, val, CONFIG_TSRA | (cid << 3) | 4)
249 #define he_writel_tsr4_upper(dev, val, cid) \
250 he_writel_internal(dev, val, CONFIG_TSRA | (cid << 3) | 4, \
252 | CON_BYTE_DISABLE_2 \
253 | CON_BYTE_DISABLE_1 \
254 | CON_BYTE_DISABLE_0)
256 #define he_readl_tsr4(dev, cid) \
257 he_readl_tcm(dev, CONFIG_TSRA | (cid << 3) | 4)
259 #define he_writel_tsr5(dev, val, cid) \
260 he_writel_tcm(dev, val, CONFIG_TSRA | (cid << 3) | 5)
262 #define he_writel_tsr6(dev, val, cid) \
263 he_writel_tcm(dev, val, CONFIG_TSRA | (cid << 3) | 6)
265 #define he_writel_tsr7(dev, val, cid) \
266 he_writel_tcm(dev, val, CONFIG_TSRA | (cid << 3) | 7)
269 #define he_writel_tsr8(dev, val, cid) \
270 he_writel_tcm(dev, val, CONFIG_TSRB | (cid << 2) | 0)
272 #define he_writel_tsr9(dev, val, cid) \
273 he_writel_tcm(dev, val, CONFIG_TSRB | (cid << 2) | 1)
275 #define he_writel_tsr10(dev, val, cid) \
276 he_writel_tcm(dev, val, CONFIG_TSRB | (cid << 2) | 2)
278 #define he_writel_tsr11(dev, val, cid) \
279 he_writel_tcm(dev, val, CONFIG_TSRB | (cid << 2) | 3)
282 #define he_writel_tsr12(dev, val, cid) \
283 he_writel_tcm(dev, val, CONFIG_TSRC | (cid << 1) | 0)
285 #define he_writel_tsr13(dev, val, cid) \
286 he_writel_tcm(dev, val, CONFIG_TSRC | (cid << 1) | 1)
289 #define he_writel_tsr14(dev, val, cid) \
290 he_writel_tcm(dev, val, CONFIG_TSRD | cid)
292 #define he_writel_tsr14_upper(dev, val, cid) \
293 he_writel_internal(dev, val, CONFIG_TSRD | cid, \
295 | CON_BYTE_DISABLE_2 \
296 | CON_BYTE_DISABLE_1 \
297 | CON_BYTE_DISABLE_0)
301 #define he_writel_rsr0(dev, val, cid) \
302 he_writel_rcm(dev, val, 0x00000 | (cid << 3) | 0)
303 #define he_readl_rsr0(dev, cid) \
304 he_readl_rcm(dev, 0x00000 | (cid << 3) | 0)
306 #define he_writel_rsr1(dev, val, cid) \
307 he_writel_rcm(dev, val, 0x00000 | (cid << 3) | 1)
309 #define he_writel_rsr2(dev, val, cid) \
310 he_writel_rcm(dev, val, 0x00000 | (cid << 3) | 2)
312 #define he_writel_rsr3(dev, val, cid) \
313 he_writel_rcm(dev, val, 0x00000 | (cid << 3) | 3)
315 #define he_writel_rsr4(dev, val, cid) \
316 he_writel_rcm(dev, val, 0x00000 | (cid << 3) | 4)
318 #define he_writel_rsr5(dev, val, cid) \
319 he_writel_rcm(dev, val, 0x00000 | (cid << 3) | 5)
321 #define he_writel_rsr6(dev, val, cid) \
322 he_writel_rcm(dev, val, 0x00000 | (cid << 3) | 6)
324 #define he_writel_rsr7(dev, val, cid) \
325 he_writel_rcm(dev, val, 0x00000 | (cid << 3) | 7)
338 vci = cid & ((1 << he_dev->
vcibits) - 1);
344 vcc->
vci == vci && vcc->
vpi == vpi &&
366 goto init_one_failure;
372 goto init_one_failure;
374 pci_set_drvdata(pci_dev, atm_dev);
376 he_dev = kzalloc(
sizeof(
struct he_dev),
380 goto init_one_failure;
384 he_dev->
atm_dev->dev_data = he_dev;
390 if (he_start(atm_dev)) {
393 goto init_one_failure;
397 he_dev->
next = he_devs;
410 he_remove_one (
struct pci_dev *pci_dev)
412 struct atm_dev *atm_dev;
413 struct he_dev *he_dev;
415 atm_dev = pci_get_drvdata(pci_dev);
424 pci_set_drvdata(pci_dev,
NULL);
430 rate_to_atmf(
unsigned rate)
432 #define NONZERO (1 << 14)
440 while (rate > 0x3ff) {
445 return (NONZERO | (exp << 9) | (rate & 0x1ff));
449 he_init_rx_lbfp0(
struct he_dev *he_dev)
451 unsigned i, lbm_offset, lbufd_index, lbuf_addr, lbuf_count;
461 for (i = 0, lbuf_count = 0; i < he_dev->
r0_numbuffs; ++
i) {
463 lbuf_addr = (row_offset + (lbuf_count * lbuf_bufsize)) / 32;
468 if (++lbuf_count == lbufs_per_row) {
480 he_init_rx_lbfp1(
struct he_dev *he_dev)
482 unsigned i, lbm_offset, lbufd_index, lbuf_addr, lbuf_count;
492 for (i = 0, lbuf_count = 0; i < he_dev->
r1_numbuffs; ++
i) {
494 lbuf_addr = (row_offset + (lbuf_count * lbuf_bufsize)) / 32;
499 if (++lbuf_count == lbufs_per_row) {
511 he_init_tx_lbfp(
struct he_dev *he_dev)
513 unsigned i, lbm_offset, lbufd_index, lbuf_addr, lbuf_count;
523 for (i = 0, lbuf_count = 0; i < he_dev->
tx_numbuffs; ++
i) {
525 lbuf_addr = (row_offset + (lbuf_count * lbuf_bufsize)) / 32;
530 if (++lbuf_count == lbufs_per_row) {
541 he_init_tpdrq(
struct he_dev *he_dev)
546 hprintk(
"failed to alloc tpdrq\n");
563 he_init_cs_block(
struct he_dev *he_dev)
570 for (reg = 0; reg < 0x20; ++
reg)
575 clock =
he_is622(he_dev) ? 66667000 : 50000000;
576 rate = he_dev->
atm_dev->link_rate;
577 delta = rate / 16 / 2;
579 for (reg = 0; reg < 0x10; ++
reg) {
653 for (reg = 0; reg < 0x8; ++
reg)
659 he_init_cs_block_rcm(
struct he_dev *he_dev)
661 unsigned (*rategrid)[16][16];
665 unsigned rate_atmf,
exp, man;
666 unsigned long long rate_cps;
675 for (reg = 0x0; reg < 0xff; ++
reg)
680 for (reg = 0x100; reg < 0x1ff; ++
reg)
691 rate = he_dev->
atm_dev->link_rate;
701 for (j = 0; j < 16; j++) {
702 (*rategrid)[0][
j] =
rate;
706 for (i = 1; i < 16; i++)
707 for (j = 0; j < 16; j++)
709 (*rategrid)[
i][
j] = (*rategrid)[i - 1][
j] / 4;
711 (*rategrid)[
i][
j] = (*rategrid)[i - 1][
j] / 2;
722 while (rate_atmf < 0x400) {
723 man = (rate_atmf & 0x1f) << 4;
724 exp = rate_atmf >> 5;
730 rate_cps = (
unsigned long long) (1 << exp) * (man + 512) >> 9;
735 for (i = 255; i > 0; i--)
736 if ((*rategrid)[i/16][i%16] >= rate_cps)
747 (he_dev->
atm_dev->link_rate * 2);
751 if (rate_cps > (272 * mult))
753 else if (rate_cps > (204 * mult))
755 else if (rate_cps > (136 * mult))
757 else if (rate_cps > (68 * mult))
764 reg = (reg << 16) | ((i << 8) |
buf);
766 #define RTGTBL_OFFSET 0x400
780 he_init_group(
struct he_dev *he_dev,
int group)
796 hprintk(
"unable to allocate rbpl bitmap table\n");
805 hprintk(
"unable to allocate rbpl virt table\n");
806 goto out_free_rbpl_table;
813 hprintk(
"unable to create rbpl pool\n");
814 goto out_free_rbpl_virt;
820 hprintk(
"failed to alloc rbpl_base\n");
821 goto out_destroy_rbpl_pool;
859 hprintk(
"failed to allocate rbrq\n");
871 hprintk(
"coalescing interrupts\n");
883 hprintk(
"failed to allocate tbrq\n");
884 goto out_free_rbpq_base;
903 pci_pool_free(he_dev->rbpl_pool, heb, heb->mapping);
908 out_destroy_rbpl_pool:
909 pci_pool_destroy(he_dev->rbpl_pool);
911 kfree(he_dev->rbpl_virt);
913 kfree(he_dev->rbpl_table);
919 he_init_irq(
struct he_dev *he_dev)
928 if (he_dev->irq_base ==
NULL) {
929 hprintk(
"failed to allocate irq\n");
932 he_dev->irq_tailoffset = (
unsigned *)
934 *he_dev->irq_tailoffset = 0;
935 he_dev->irq_head = he_dev->irq_base;
936 he_dev->irq_tail = he_dev->irq_base;
972 hprintk(
"irq %d already in use\n", he_dev->pci_dev->irq);
976 he_dev->irq = he_dev->pci_dev->irq;
982 he_start(
struct atm_dev *
dev)
984 struct he_dev *he_dev;
986 unsigned long membase;
989 u32 gen_cntl_0, host_cntl, lb_swap;
1000 HPRINTK(
"membase = 0x%lx irq = %d.\n", membase, pci_dev->
irq);
1007 if (pci_read_config_dword(pci_dev,
GEN_CNTL_0, &gen_cntl_0) != 0) {
1008 hprintk(
"can't read GEN_CNTL_0\n");
1012 if (pci_write_config_dword(pci_dev,
GEN_CNTL_0, gen_cntl_0) != 0) {
1013 hprintk(
"can't write GEN_CNTL_0.\n");
1017 if (pci_read_config_word(pci_dev,
PCI_COMMAND, &command) != 0) {
1018 hprintk(
"can't read PCI_COMMAND.\n");
1023 if (pci_write_config_word(pci_dev,
PCI_COMMAND, command) != 0) {
1024 hprintk(
"can't enable memory.\n");
1029 hprintk(
"can't read cache line size?\n");
1033 if (cache_size < 16) {
1036 hprintk(
"can't set cache line size to %d\n", cache_size);
1040 hprintk(
"can't read latency timer?\n");
1052 #define LAT_TIMER 209
1053 if (timer < LAT_TIMER) {
1054 HPRINTK(
"latency timer was %d, setting to %d\n", timer, LAT_TIMER);
1057 hprintk(
"can't set latency timer to %d\n", timer);
1061 hprintk(
"can't set up page mapping\n");
1083 if (disable64 == 1) {
1084 hprintk(
"disabling 64-bit pci bus transfers\n");
1089 hprintk(
"64-bit transfers enabled\n");
1091 pci_write_config_dword(pci_dev,
GEN_CNTL_0, gen_cntl_0);
1097 he_dev->
media = read_prom_byte(he_dev,
MEDIA);
1099 for (i = 0; i < 6; ++
i)
1100 dev->
esi[i] = read_prom_byte(he_dev,
MAC_ADDR + i);
1102 hprintk(
"%s%s, %x:%x:%x:%x:%x:%x\n",
1104 he_dev->
media & 0x40 ?
"SM" :
"MM",
1136 if ((err = he_init_irq(he_dev)) != 0)
1145 pci_write_config_dword(pci_dev,
GEN_CNTL_0, gen_cntl_0);
1185 if (nvpibits != -1 && nvcibits != -1 && nvpibits+nvcibits !=
HE_MAXCIDBITS) {
1190 if (nvpibits != -1) {
1195 if (nvcibits != -1) {
1356 he_init_rx_lbfp0(he_dev);
1357 he_init_rx_lbfp1(he_dev);
1366 he_init_tx_lbfp(he_dev);
1431 he_init_cs_block(he_dev);
1435 if (he_init_cs_block_rcm(he_dev) < 0)
1440 he_init_tpdrq(he_dev);
1445 hprintk(
"unable to create tpd pci_pool\n");
1451 if (he_init_group(he_dev, 0) != 0)
1485 hprintk(
"failed to allocate host status page\n");
1493 #ifdef CONFIG_ATM_HE_USE_SUNI
1537 HPRINTK(
"hell bent for leather!\n");
1543 he_stop(
struct he_dev *he_dev)
1555 pci_read_config_dword(pci_dev,
GEN_CNTL_0, &gen_cntl_0);
1557 pci_write_config_dword(pci_dev,
GEN_CNTL_0, gen_cntl_0);
1559 tasklet_disable(&he_dev->
tasklet);
1572 #ifdef CONFIG_ATM_HE_USE_SUNI
1590 pci_pool_free(he_dev->rbpl_pool, heb, heb->mapping);
1593 *
sizeof(
struct he_rbp), he_dev->rbpl_base, he_dev->rbpl_phys);
1596 kfree(he_dev->rbpl_virt);
1597 kfree(he_dev->rbpl_table);
1599 if (he_dev->rbpl_pool)
1600 pci_pool_destroy(he_dev->rbpl_pool);
1602 if (he_dev->rbrq_base)
1604 he_dev->rbrq_base, he_dev->rbrq_phys);
1606 if (he_dev->tbrq_base)
1608 he_dev->tbrq_base, he_dev->tbrq_phys);
1610 if (he_dev->tpdrq_base)
1612 he_dev->tpdrq_base, he_dev->tpdrq_phys);
1614 if (he_dev->tpd_pool)
1615 pci_pool_destroy(he_dev->tpd_pool);
1617 if (he_dev->pci_dev) {
1628 __alloc_tpd(
struct he_dev *he_dev)
1639 tpd->
iovec[0].addr = 0; tpd->
iovec[0].len = 0;
1640 tpd->
iovec[1].addr = 0; tpd->
iovec[1].len = 0;
1641 tpd->
iovec[2].addr = 0; tpd->
iovec[2].len = 0;
1646 #define AAL5_LEN(buf,len) \
1647 ((((unsigned char *)(buf))[(len)-6] << 8) | \
1648 (((unsigned char *)(buf))[(len)-5]))
1656 #define TCP_CKSUM(buf,len) \
1657 ((((unsigned char *)(buf))[(len)-2] << 8) | \
1658 (((unsigned char *)(buf))[(len-1)]))
1661 he_service_rbrq(
struct he_dev *he_dev,
int group)
1665 he_dev->
hsp->group[
group].rbrq_tail);
1666 unsigned cid, lastcid = -1;
1672 int pdus_assembled = 0;
1676 while (he_dev->
rbrq_head != rbrq_tail) {
1679 HPRINTK(
"%p rbrq%d 0x%x len=%d cid=0x%x %s%s%s%s%s%s\n",
1696 vcc = __find_vcc(he_dev, cid);
1700 hprintk(
"vcc/he_vcc == NULL (cid 0x%x)\n", cid);
1707 goto next_rbrq_entry;
1711 hprintk(
"HBUF_ERR! (cid 0x%x)\n", cid);
1713 goto return_host_buffers;
1723 HPRINTK(
"wake_up rx_waitq (cid 0x%x)\n", cid);
1725 goto return_host_buffers;
1729 goto next_rbrq_entry;
1740 goto return_host_buffers;
1747 goto return_host_buffers;
1750 if (rx_skb_reserve > 0)
1751 skb_reserve(skb, rx_skb_reserve);
1753 __net_timestamp(skb);
1758 switch (vcc->
qos.aal) {
1762 skb_set_tail_pointer(skb, skb->
len);
1768 skb_set_tail_pointer(skb, skb->
len);
1769 #ifdef USE_CHECKSUM_HW
1779 #ifdef should_never_happen
1780 if (skb->
len > vcc->
qos.rxtp.max_sdu)
1781 hprintk(
"pdu_len (%d) > vcc->qos.rxtp.max_sdu (%d)! cid 0x%x\n", skb->
len, vcc->
qos.rxtp.max_sdu, cid);
1788 vcc->
push(vcc, skb);
1793 return_host_buffers:
1798 INIT_LIST_HEAD(&he_vcc->
buffers);
1817 return pdus_assembled;
1821 he_service_tbrq(
struct he_dev *he_dev,
int group)
1825 he_dev->
hsp->group[
group].tbrq_tail);
1827 int slot, updated = 0;
1832 while (he_dev->
tbrq_head != tbrq_tail) {
1850 hprintk(
"unable to locate tpd for dma buffer %x\n",
1852 goto next_tbrq_entry;
1856 HPRINTK(
"wake_up(tx_waitq) cid 0x%x\n",
1861 goto next_tbrq_entry;
1865 if (tpd->
iovec[slot].addr)
1866 pci_unmap_single(he_dev->
pci_dev,
1867 tpd->
iovec[slot].addr,
1876 if (tpd->
vcc && tpd->
vcc->pop)
1900 he_service_rbpl(
struct he_dev *he_dev,
int group)
1902 struct he_rbp *new_tail;
1903 struct he_rbp *rbpl_head;
1909 rbpl_head = (
struct he_rbp *) ((
unsigned long)he_dev->
rbpl_base |
1913 new_tail = (
struct he_rbp *) ((
unsigned long)he_dev->
rbpl_base |
1917 if (new_tail == rbpl_head)
1947 he_tasklet(
unsigned long data)
1949 unsigned long flags;
1950 struct he_dev *he_dev = (
struct he_dev *) data;
1954 HPRINTK(
"tasklet (0x%lx)\n", data);
1965 HPRINTK(
"rbrq%d threshold\n", group);
1968 if (he_service_rbrq(he_dev, group))
1969 he_service_rbpl(he_dev, group);
1972 HPRINTK(
"tbrq%d threshold\n", group);
1975 he_service_tbrq(he_dev, group);
1978 he_service_rbpl(he_dev, group);
1985 #ifdef CONFIG_ATM_HE_USE_SUNI
1986 spin_unlock_irqrestore(&he_dev->
global_lock, flags);
1993 switch (type|group) {
2007 he_service_rbrq(he_dev, 0);
2008 he_service_rbpl(he_dev, 0);
2009 he_service_tbrq(he_dev, 0);
2030 spin_unlock_irqrestore(&he_dev->
global_lock, flags);
2034 he_irq_handler(
int irq,
void *
dev_id)
2036 unsigned long flags;
2037 struct he_dev *he_dev = (
struct he_dev * )dev_id;
2049 HPRINTK(
"tailoffset not updated?\n");
2057 hprintk(
"spurious (or shared) interrupt?\n");
2062 tasklet_schedule(&he_dev->
tasklet);
2066 spin_unlock_irqrestore(&he_dev->
global_lock, flags);
2072 __enqueue_tpd(
struct he_dev *he_dev,
struct he_tpd *tpd,
unsigned cid)
2076 HPRINTK(
"tpdrq %p cid 0x%x -> tpdrq_tail %p\n",
2098 hprintk(
"tpdrq full (cid 0x%x)\n", cid);
2106 if (tpd->
iovec[slot].addr)
2107 pci_unmap_single(he_dev->
pci_dev,
2108 tpd->
iovec[slot].addr,
2139 unsigned long flags;
2140 struct he_dev *he_dev =
HE_DEV(vcc->
dev);
2144 short vpi = vcc->
vpi;
2150 HPRINTK(
"open vcc %p %d.%d\n", vcc, vpi, vci);
2157 if (he_vcc ==
NULL) {
2158 hprintk(
"unable to allocate he_vcc during open\n");
2162 INIT_LIST_HEAD(&he_vcc->
buffers);
2176 pcr_goal = he_dev->
atm_dev->link_rate;
2178 pcr_goal = -pcr_goal;
2180 HPRINTK(
"open tx cid 0x%x pcr_goal %d\n", cid, pcr_goal);
2182 switch (vcc->
qos.aal) {
2198 spin_unlock_irqrestore(&he_dev->
global_lock, flags);
2201 hprintk(
"cid 0x%x not idle (tsr0 = 0x%x)\n", cid, tsr0);
2206 switch (vcc->
qos.txtp.traffic_class) {
2219 > (he_dev->
atm_dev->link_rate * 9 / 10))
2229 if (he_dev->
cs_stper[reg].inuse == 0 ||
2230 he_dev->
cs_stper[reg].pcr == pcr_goal)
2233 if (reg == HE_NUM_CS_STPER) {
2235 spin_unlock_irqrestore(&he_dev->
global_lock, flags);
2245 clock =
he_is622(he_dev) ? 66667000 : 50000000;
2246 period = clock / pcr_goal;
2248 HPRINTK(
"rc_index = %d period = %d\n",
2253 spin_unlock_irqrestore(&he_dev->
global_lock, flags);
2269 TSR1_PCR(rate_to_atmf(pcr_goal)), cid);
2284 spin_unlock_irqrestore(&he_dev->
global_lock, flags);
2290 HPRINTK(
"open rx cid 0x%x (rx_waitq %p)\n", cid,
2293 switch (vcc->
qos.aal) {
2309 spin_unlock_irqrestore(&he_dev->
global_lock, flags);
2311 hprintk(
"cid 0x%x not idle (rsr0 = 0x%x)\n", cid, rsr0);
2318 rsr0 = vcc->
qos.rxtp.traffic_class ==
ATM_UBR ?
2321 #ifdef USE_CHECKSUM_HW
2334 spin_unlock_irqrestore(&he_dev->
global_lock, flags);
2352 unsigned long flags;
2354 struct he_dev *he_dev =
HE_DEV(vcc->
dev);
2357 struct he_vcc *he_vcc =
HE_VCC(vcc);
2358 #define MAX_RETRY 30
2359 int retry = 0, sleep = 1, tx_inuse;
2369 HPRINTK(
"close rx cid 0x%x\n", cid);
2377 HPRINTK(
"close cid 0x%x RCC_BUSY\n", cid);
2387 spin_unlock_irqrestore(&he_dev->
global_lock, flags);
2395 hprintk(
"close rx timeout cid 0x%x\n", cid);
2397 HPRINTK(
"close rx cid 0x%x complete\n", cid);
2402 volatile unsigned tsr4, tsr0;
2405 HPRINTK(
"close tx cid 0x%x\n", cid);
2416 while (((tx_inuse =
atomic_read(&sk_atm(vcc)->sk_wmem_alloc)) > 1) &&
2417 (retry < MAX_RETRY)) {
2426 hprintk(
"close tx cid 0x%x tx_inuse = %d\n", cid, tx_inuse);
2434 switch (vcc->
qos.txtp.traffic_class) {
2446 tpd = __alloc_tpd(he_dev);
2448 hprintk(
"close tx he_alloc_tpd failed cid 0x%x\n", cid);
2449 goto close_tx_incomplete;
2458 __enqueue_tpd(he_dev, tpd, cid);
2459 spin_unlock_irqrestore(&he_dev->
global_lock, flags);
2469 hprintk(
"close tx timeout cid 0x%x\n", cid);
2470 goto close_tx_incomplete;
2474 HPRINTK(
"close tx cid 0x%x !TSR4_SESSION_ENDED (tsr4 = 0x%x)\n", cid, tsr4);
2479 HPRINTK(
"close tx cid 0x%x TSR0_CONN_STATE != 0 (tsr0 = 0x%x)\n", cid, tsr0);
2483 close_tx_incomplete:
2485 if (vcc->
qos.txtp.traffic_class ==
ATM_CBR) {
2488 HPRINTK(
"cs_stper reg = %d\n", reg);
2490 if (he_dev->
cs_stper[reg].inuse == 0)
2491 hprintk(
"cs_stper[%d].inuse = 0!\n", reg);
2497 spin_unlock_irqrestore(&he_dev->
global_lock, flags);
2499 HPRINTK(
"close tx cid 0x%x complete\n", cid);
2510 unsigned long flags;
2511 struct he_dev *he_dev =
HE_DEV(vcc->
dev);
2514 #ifdef USE_SCATTERGATHER
2518 #define HE_TPD_BUFSIZE 0xffff
2522 if ((skb->
len > HE_TPD_BUFSIZE) ||
2524 hprintk(
"buffer too large (or small) -- %d bytes\n", skb->
len );
2533 #ifndef USE_SCATTERGATHER
2534 if (skb_shinfo(skb)->nr_frags) {
2535 hprintk(
"no scatter/gather support\n");
2546 tpd = __alloc_tpd(he_dev);
2553 spin_unlock_irqrestore(&he_dev->
global_lock, flags);
2560 char *pti_clp = (
void *) (skb->
data + 3);
2572 #ifdef USE_SCATTERGATHER
2575 tpd->
iovec[
slot].len = skb_headlen(skb);
2578 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
2581 if (slot == TPD_MAXIOV) {
2587 __enqueue_tpd(he_dev, tpd, cid);
2588 tpd = __alloc_tpd(he_dev);
2595 spin_unlock_irqrestore(&he_dev->
global_lock, flags);
2622 __enqueue_tpd(he_dev, tpd, cid);
2623 spin_unlock_irqrestore(&he_dev->
global_lock, flags);
2631 he_ioctl(
struct atm_dev *atm_dev,
unsigned int cmd,
void __user *
arg)
2633 unsigned long flags;
2634 struct he_dev *he_dev =
HE_DEV(atm_dev);
2655 reg.val =
he_readl(he_dev, reg.addr);
2673 spin_unlock_irqrestore(&he_dev->
global_lock, flags);
2680 #ifdef CONFIG_ATM_HE_USE_SUNI
2681 if (atm_dev->
phy && atm_dev->
phy->ioctl)
2682 err = atm_dev->
phy->ioctl(atm_dev, cmd, arg);
2693 he_phy_put(
struct atm_dev *atm_dev,
unsigned char val,
unsigned long addr)
2695 unsigned long flags;
2696 struct he_dev *he_dev =
HE_DEV(atm_dev);
2698 HPRINTK(
"phy_put(val 0x%x, addr 0x%lx)\n", val, addr);
2703 spin_unlock_irqrestore(&he_dev->
global_lock, flags);
2707 static unsigned char
2708 he_phy_get(
struct atm_dev *atm_dev,
unsigned long addr)
2710 unsigned long flags;
2711 struct he_dev *he_dev =
HE_DEV(atm_dev);
2716 spin_unlock_irqrestore(&he_dev->
global_lock, flags);
2718 HPRINTK(
"phy_get(addr 0x%lx) =0x%x\n", addr, reg);
2723 he_proc_read(
struct atm_dev *dev, loff_t *
pos,
char *
page)
2725 unsigned long flags;
2726 struct he_dev *he_dev =
HE_DEV(dev);
2731 int rbpl_head, rbpl_tail;
2733 static long mcc = 0, oec = 0, dcc = 0, cec = 0;
2738 return sprintf(page,
"ATM he driver\n");
2741 return sprintf(page,
"%s%s\n\n",
2745 return sprintf(page,
"Mismatched Cells VPI/VCI Not Open Dropped Cells RCM Dropped Cells\n");
2752 spin_unlock_irqrestore(&he_dev->
global_lock, flags);
2755 return sprintf(page,
"%16ld %16ld %13ld %17ld\n\n",
2756 mcc, oec, dcc, cec);
2759 return sprintf(page,
"irq_size = %d inuse = ? peak = %d\n",
2760 CONFIG_IRQ_SIZE, he_dev->
irq_peak);
2763 return sprintf(page,
"tpdrq_size = %d inuse = ?\n",
2767 return sprintf(page,
"rbrq_size = %d inuse = ? peak = %d\n",
2771 return sprintf(page,
"tbrq_size = %d peak = %d\n",
2779 inuse = rbpl_head - rbpl_tail;
2781 inuse += CONFIG_RBPL_SIZE *
sizeof(
struct he_rbp);
2782 inuse /=
sizeof(
struct he_rbp);
2785 return sprintf(page,
"rbpl_size = %d inuse = %d\n\n",
2786 CONFIG_RBPL_SIZE, inuse);
2790 return sprintf(page,
"rate controller periods (cbr)\n pcr #vc\n");
2794 return sprintf(page,
"cs_stper%-2d %8ld %3d\n", i,
2799 return sprintf(page,
"total bw (cbr): %d (limit %d)\n",
2807 static u8 read_prom_byte(
struct he_dev *he_dev,
int addr)
2809 u32 val = 0, tmp_read = 0;
2827 for (i = 7; i >= 0; i--) {
2840 for (i = 7; i >= 0; i--) {
2844 byte_read |= (
unsigned char)
2881 .probe = he_init_one,
2883 .id_table = he_pci_tbl,
2886 static int __init he_init(
void)
2888 return pci_register_driver(&he_driver);
2891 static void __exit he_cleanup(
void)