6 #include <linux/module.h>
7 #include <linux/kernel.h>
10 #include <linux/errno.h>
11 #include <linux/atm.h>
12 #include <linux/atmdev.h>
13 #include <linux/sonet.h>
15 #include <linux/time.h>
17 #include <linux/uio.h>
20 #include <linux/bitops.h>
21 #include <linux/slab.h>
24 #include <asm/uaccess.h>
25 #include <asm/string.h>
26 #include <asm/byteorder.h>
33 #if !defined(__i386__) && !defined(__x86_64__)
34 #ifndef ioremap_nocache
35 #define ioremap_nocache(X,Y) ioremap(X,Y)
65 #define DPRINTK(format,args...) printk(KERN_DEBUG format,##args)
67 #define DPRINTK(format,args...)
71 #ifndef CONFIG_ATM_ENI_TUNE_BURST
72 #define CONFIG_ATM_ENI_BURST_TX_8W
73 #define CONFIG_ATM_ENI_BURST_RX_4W
77 #ifndef CONFIG_ATM_ENI_DEBUG
85 static void event_dump(
void)
97 #define NULLCHECK(x) \
98 if ((unsigned long) (x) < 0x30) \
99 printk(KERN_CRIT #x "==0x%lx\n",(unsigned long) (x))
108 static const char *ev[EV];
109 static unsigned long ev_a[EV],ev_b[EV];
113 static void EVENT(
const char *
s,
unsigned long a,
unsigned long b)
122 static void event_dump(
void)
126 for (n = 0; n < EV; n++) {
129 printk(ev[i] ? ev[i] :
"(null)",ev_a[i],ev_b[i]);
144 #define NEPJOK(a0,a1,b) \
145 ((a0) < (a1) ? (b) <= (a0) || (b) > (a1) : (b) <= (a0) && (b) > (a1))
146 #define EEPJOK(a0,a1,b) \
147 ((a0) < (a1) ? (b) < (a0) || (b) >= (a1) : (b) < (a0) && (b) >= (a1))
148 #define NEPMOK(a0,d,b,c) NEPJOK(a0,(a0+d) & (c-1),b)
149 #define EEPMOK(a0,d,b,c) EEPJOK(a0,(a0+d) & (c-1),b)
152 static int tx_complete = 0,dma_complete = 0,queued = 0,requeued = 0,
153 backlogged = 0,rx_enqueued = 0,rx_dequeued = 0,pushed = 0,submitted = 0,
159 #define eni_in(r) readl(eni_dev->reg+(r)*4)
160 #define eni_out(v,r) writel((v),eni_dev->reg+(r)*4)
170 for (i = 0; i < eni_dev->
free_len; i++)
188 if (eni_dev->
tx[i].send)
190 eni_dev->
tx[i].send,eni_dev->
tx[i].words*4);
192 for (i = 0; i < 1024; i++)
201 static void eni_put_free(
struct eni_dev *eni_dev,
void __iomem *
start,
207 DPRINTK(
"init 0x%lx+%ld(0x%lx)\n",start,size,size);
217 for (order = 0; !(((
unsigned long)start | size) & (1 <<
order)); order++);
234 static void __iomem *eni_alloc_mem(
struct eni_dev *eni_dev,
unsigned long *size)
244 for (order = 0; (1 <<
order) < *size; order++);
245 DPRINTK(
"trying: %ld->%d\n",*size,order);
248 for (i = 0; i < len; i++)
249 if (list[i].order == order) {
254 else if (best_order > list[i].order && list[i].order > order) {
255 best_order = list[
i].
order;
258 if (best_order == 65)
return NULL;
260 list[
index] = list[--len];
263 eni_put_free(eni_dev,start+*size,(1 << best_order)-*size);
264 DPRINTK(
"%ld bytes (order %d) at 0x%lx\n",*size,order,start);
271 static void eni_free_mem(
struct eni_dev *eni_dev,
void __iomem *start,
280 for (order = -1;
size; order++) size >>= 1;
281 DPRINTK(
"eni_free_mem: %p+0x%lx (order %d)\n",start,size,order);
282 for (i = 0; i < len; i++)
283 if (((
unsigned long) list[i].start) == ((
unsigned long)start^(1 << order)) &&
284 list[i].order == order) {
285 DPRINTK(
"match[%d]: 0x%lx/0x%lx(0x%x), %d/%d\n",i,
286 list[i].start,start,1 << order,list[i].order,order);
287 list[
i] = list[--len];
288 start = (
void __iomem *) ((
unsigned long) start & ~(
unsigned long) (1 << order));
308 #define ENI_VCC_NOS ((struct atm_vcc *) 1)
314 struct eni_dev *eni_dev;
325 "mismatch\n",dev->
number);
333 EVENT(
"---dump ends here---\n",0,0);
343 unsigned long skip,
unsigned long size,
unsigned long eff)
345 struct eni_dev *eni_dev;
362 "mis-aligned RX data (0x%lx)\n",vcc->
dev->number,
363 vcc->
vci,(
unsigned long) paddr);
369 if ((eff && skip) || 1) {
376 if (!eff) size +=
skip;
381 DPRINTK(
"strange things happen ...\n");
382 EVENT(
"strange things happen ... (skip=%ld,eff=%ld)\n",
389 init = 4-((paddr & 15) >> 2);
390 if (init > words) init =
words;
397 #ifdef CONFIG_ATM_ENI_BURST_RX_16W
403 paddr += (words & ~15) << 2;
407 #ifdef CONFIG_ATM_ENI_BURST_RX_8W
413 paddr += (words & ~7) << 2;
417 #ifdef CONFIG_ATM_ENI_BURST_RX_4W
423 paddr += (words & ~3) << 2;
427 #ifdef CONFIG_ATM_ENI_BURST_RX_2W
433 paddr += (words & ~1) << 2;
465 for (i = 0; i <
j; i++) {
482 pci_unmap_single(eni_dev->
pci_dev,paddr,skb->
len,
491 struct eni_vcc *eni_vcc;
494 EVENT(
"discard (size=%ld)\n",size,0);
495 while (do_rx_dma(vcc,
NULL,1,size,0))
EVENT(
"BUSY LOOP",0,0);
507 static int rx_aal0(
struct atm_vcc *vcc)
509 struct eni_vcc *eni_vcc;
537 DPRINTK(
"got len %ld\n",length);
538 if (do_rx_dma(vcc,skb,1,length >> 2,length >> 2))
return 1;
544 static int rx_aal5(
struct atm_vcc *vcc)
546 struct eni_vcc *eni_vcc;
551 EVENT(
"rx_aal5\n",0,0);
560 if (descr & MID_RED_T) {
561 EVENT(
"empty cell (descr=0x%lx)\n",descr,0);
567 static unsigned long silence = 0;
569 if (
time_after(jiffies, silence) || silence == 0) {
571 "discarding PDU(s) with CRC error\n",
576 EVENT(
"CRC error (descr=0x%lx,size=%ld)\n",descr,
586 (eni_vcc->
words-1)))*4) & 0xffff;
588 if (length && length <= (size << 2)-8 && length <=
591 EVENT(
"bad PDU (descr=0x08%lx,length=%ld)\n",descr,
594 "(VCI=%d,length=%ld,size=%ld (descr 0x%lx))\n",
595 vcc->
dev->number,vcc->
vci,length,size << 2,descr);
606 DPRINTK(
"got len %ld\n",length);
607 if (do_rx_dma(vcc,skb,1,size,eff))
return 1;
613 static inline int rx_vcc(
struct atm_vcc *vcc)
617 struct eni_vcc *eni_vcc;
621 EVENT(
"rx_vcc(1)\n",0,0);
624 EVENT(
"rx_vcc(2: host dsc=0x%lx, nic dsc=0x%lx)\n",
638 EVENT(
"rx_vcc(3)\n",0,0);
641 EVENT(
"rx_vcc(4: host dsc=0x%lx, nic dsc=0x%lx)\n",
652 static void poll_rx(
struct atm_dev *dev)
654 struct eni_dev *eni_dev;
658 while ((curr = eni_dev->
fast)) {
659 EVENT(
"poll_rx.fast\n",0,0);
660 if (rx_vcc(curr))
return;
666 while ((curr = eni_dev->
slow)) {
667 EVENT(
"poll_rx.slow\n",0,0);
668 if (rx_vcc(curr))
return;
677 static void get_service(
struct atm_dev *dev)
679 struct eni_dev *eni_dev;
688 vcc = eni_dev->
rx_map[vci & 1023];
691 "found\n",dev->
number,vci);
695 EVENT(
"getting from service\n",0,0);
697 EVENT(
"double service\n",0,0);
698 DPRINTK(
"Grr, servicing VCC %ld twice\n",vci);
721 static void dequeue_rx(
struct atm_dev *dev)
723 struct eni_dev *eni_dev;
724 struct eni_vcc *eni_vcc;
738 EVENT(
"nothing to dequeue\n",0,0);
748 vci_dsc = eni_dev->
vci+vcc->
vci*16;
752 EVENT(
"requeuing\n",0,0);
762 EVENT(
"pushing (len=%ld)\n",skb->
len,0);
764 *(
unsigned long *) skb->
data =
776 static int open_rx_first(
struct atm_vcc *vcc)
778 struct eni_dev *eni_dev;
779 struct eni_vcc *eni_vcc;
786 if (vcc->
qos.rxtp.traffic_class ==
ATM_NONE)
return 0;
787 size = vcc->
qos.rxtp.max_sdu*eni_dev->
rx_mult/100;
791 eni_vcc->
recv = eni_alloc_mem(eni_dev,&size);
793 eni_vcc->
words = size >> 2;
805 static int open_rx_second(
struct atm_vcc *vcc)
808 struct eni_dev *eni_dev;
809 struct eni_vcc *eni_vcc;
816 if (!eni_vcc->
rx)
return 0;
818 here = eni_dev->
vci+vcc->
vci*16;
820 size = eni_vcc->
words >> 8;
821 for (order = -1;
size; order++) size >>= 1;
826 "in use\n",vcc->
dev->number,vcc->
vci);
836 static void close_rx(
struct atm_vcc *vcc)
840 struct eni_dev *eni_dev;
841 struct eni_vcc *eni_vcc;
844 if (!eni_vcc->
rx)
return;
847 here = eni_dev->
vci+vcc->
vci*16;
858 DPRINTK(
"eni_close: waiting for RX ...\n");
859 EVENT(
"RX closing\n",0,0);
867 if (!eni_vcc->
rxing)
break;
869 EVENT(
"drain PDUs (rx %ld, serv %ld)\n",eni_vcc->
rxing,
880 tasklet_disable(&eni_dev->
task);
883 tasklet_enable(&eni_dev->
task);
885 EVENT(
"drain discard (host 0x%lx, nic 0x%lx)\n",
895 eni_free_mem(eni_dev,eni_vcc->
recv,eni_vcc->
words << 2);
900 static int start_rx(
struct atm_dev *dev)
902 struct eni_dev *eni_dev;
916 skb_queue_head_init(&eni_dev->
rx_queue);
934 DPRINTK(
"put_dma: 0x%lx+0x%x\n",(
unsigned long) paddr,size);
935 EVENT(
"put_dma: 0x%lx+0x%lx\n",(
unsigned long) paddr,size);
943 init = 4-(paddr & 3);
944 if (init > size || size < 7) init =
size;
945 DPRINTK(
"put_dma: %lx DMA: %d/%d bytes\n",
946 (
unsigned long) paddr,init,size);
955 if (words && (paddr & 31)) {
956 init = 8-((paddr & 31) >> 2);
957 if (init > words) init = words;
958 DPRINTK(
"put_dma: %lx DMA: %d/%d words\n",
959 (
unsigned long) paddr,init,words);
966 #ifdef CONFIG_ATM_ENI_BURST_TX_16W
968 DPRINTK(
"put_dma: %lx DMA: %d*16/%d words\n",
969 (
unsigned long) paddr,words >> 4,words);
973 paddr += (words & ~15) << 2;
977 #ifdef CONFIG_ATM_ENI_BURST_TX_8W
979 DPRINTK(
"put_dma: %lx DMA: %d*8/%d words\n",
980 (
unsigned long) paddr,words >> 3,words);
984 paddr += (words & ~7) << 2;
988 #ifdef CONFIG_ATM_ENI_BURST_TX_4W
990 DPRINTK(
"put_dma: %lx DMA: %d*4/%d words\n",
991 (
unsigned long) paddr,words >> 2,words);
995 paddr += (words & ~3) << 2;
999 #ifdef CONFIG_ATM_ENI_BURST_TX_2W
1001 DPRINTK(
"put_dma: %lx DMA: %d*2/%d words\n",
1002 (
unsigned long) paddr,words >> 1,words);
1005 dma[(*j)++] =
paddr;
1006 paddr += (words & ~1) << 2;
1011 DPRINTK(
"put_dma: %lx DMA: %d words\n",(
unsigned long) paddr,
1015 dma[(*j)++] =
paddr;
1016 paddr += words << 2;
1019 DPRINTK(
"put_dma: %lx DMA: %d bytes\n",(
unsigned long) paddr,
1023 dma[(*j)++] =
paddr;
1031 struct eni_dev *eni_dev;
1032 struct eni_vcc *eni_vcc;
1041 EVENT(
"do_tx: skb=0x%lx, %ld bytes\n",(
unsigned long) skb,skb->
len);
1051 unsigned int hack = *((
char *) skb->
data)-
'0';
1060 if ((
unsigned long) skb->
data & 3)
1062 "TX data\n",vcc->
dev->number,vcc->
vci);
1089 DPRINTK(DEV_LABEL
"(itf %d): TX full (size %d)\n",
1090 vcc->
dev->number,size);
1098 DPRINTK(
"iovcnt = %d\n",skb_shinfo(skb)->nr_frags);
1099 if (!skb_shinfo(skb)->nr_frags) dma_size += 5;
1100 else dma_size += 5*(skb_shinfo(skb)->nr_frags+1);
1121 if (!skb_shinfo(skb)->nr_frags)
1122 if (aal5) put_dma(tx->
index,eni_dev->
dma,&j,paddr,skb->
len);
1123 else put_dma(tx->
index,eni_dev->
dma,&j,paddr+4,skb->
len-4);
1125 DPRINTK(
"doing direct send\n");
1126 for (i = -1; i < skb_shinfo(skb)->nr_frags; i++)
1128 put_dma(tx->
index,eni_dev->
dma,&j,(
unsigned long)
1132 put_dma(tx->
index,eni_dev->
dma,&j,(
unsigned long)
1133 skb_frag_page(&skb_shinfo(skb)->frags[i]) +
1135 skb_frag_size(&skb_shinfo(skb)->frags[i]));
1138 put_dma(tx->
index, eni_dev->
dma, &j, eni_dev->
zero.dma,
1139 4 - (skb->
len & 3));
1146 DPRINTK(
"DMA at end: %d\n",j);
1154 (aal5 ? 0 : (skb->
data[3] & 0xf)) |
1162 for (i = 0; i <
j; i++) {
1171 DPRINTK(
"dma_wr set to %d, tx_pos is now %ld\n",dma_wr,tx->
tx_pos);
1179 static void poll_tx(
struct atm_dev *dev)
1187 for (i = NR_CHAN-1; i >= 0; i--) {
1192 if (res ==
enq_ok)
continue;
1193 DPRINTK(
"re-queuing TX PDU\n");
1203 static void dequeue_tx(
struct atm_dev *dev)
1205 struct eni_dev *eni_dev;
1228 if (vcc->
pop) vcc->
pop(vcc,skb);
1237 static struct eni_tx *alloc_tx(
struct eni_dev *eni_dev,
int ubr)
1241 for (i = !ubr; i <
NR_CHAN; i++)
1242 if (!eni_dev->
tx[i].send)
return eni_dev->
tx+
i;
1247 static int comp_tx(
struct eni_dev *eni_dev,
int *pcr,
int reserved,
int *pre,
1248 int *res,
int unlimited)
1250 static const int pre_div[] = { 4,16,128,2048 };
1253 if (unlimited) *pre = *res = 0;
1258 for (*pre = 0; *pre < 3; (*pre)++)
1259 if (
TS_CLOCK/pre_div[*pre]/64 <= *pcr)
break;
1260 div = pre_div[*pre]**pcr;
1268 for (*pre = 3; *pre >= 0; (*pre)--)
1269 if (
TS_CLOCK/pre_div[*pre]/64 > -*pcr)
break;
1270 if (*pre < 3) (*pre)++;
1271 div = pre_div[*pre]*-*pcr;
1275 if (*res < 0) *res = 0;
1278 *pcr =
TS_CLOCK/pre_div[*pre]/(*res+1);
1279 DPRINTK(
"out pcr: %d (%d:%d)\n",*pcr,*pre,*res);
1285 int set_rsv,
int set_shp)
1288 struct eni_vcc *eni_vcc =
ENI_VCC(vcc);
1292 int rate,ubr,unlimited,new_tx;
1298 unlimited = ubr && (!rate || rate <= -
ATM_OC3_PCR ||
1308 eni_vcc->
tx = eni_dev->
ubr;
1314 new_tx = !eni_vcc->
tx;
1316 if (!new_tx) tx = eni_vcc->
tx;
1318 mem = eni_alloc_mem(eni_dev,&size);
1320 tx = alloc_tx(eni_dev,unlimited);
1322 eni_free_mem(eni_dev,mem,size);
1328 tx->
words = size >> 2;
1329 skb_queue_head_init(&tx->
backlog);
1330 for (order = 0; size > (1 << (order+10)); order++);
1337 error = comp_tx(eni_dev,&rate,tx->
reserved,&pre,&res,unlimited);
1343 if (!error && set_rsv && !set_shp && rate < tx->
shaping)
1345 if (!error && !set_rsv && rate > tx->
reserved && !ubr)
1350 eni_free_mem(eni_dev,mem,size);
1355 if (set_rsv && !ubr) {
1360 if (set_shp || (unlimited && new_tx)) {
1361 if (unlimited && new_tx) eni_dev->
ubr =
tx;
1366 if (set_shp) eni_vcc->
tx =
tx;
1372 static int open_tx_first(
struct atm_vcc *vcc)
1375 if (vcc->
qos.txtp.traffic_class ==
ATM_NONE)
return 0;
1377 return reserve_or_set_tx(vcc,&vcc->
qos.txtp,1,1);
1381 static int open_tx_second(
struct atm_vcc *vcc)
1387 static void close_tx(
struct atm_vcc *vcc)
1390 struct eni_dev *eni_dev;
1391 struct eni_vcc *eni_vcc;
1394 if (!eni_vcc->
tx)
return;
1397 DPRINTK(
"eni_close: waiting for TX ...\n");
1403 tasklet_disable(&eni_dev->
task);
1404 txing = skb_peek(&eni_vcc->
tx->backlog) || eni_vcc->
txing;
1405 tasklet_enable(&eni_dev->
task);
1413 if (eni_vcc->
tx != eni_dev->
ubr) {
1422 eni_free_mem(eni_dev,eni_vcc->
tx->send,eni_vcc->
tx->words << 2);
1423 eni_vcc->
tx->send =
NULL;
1424 eni_dev->
tx_bw += eni_vcc->
tx->reserved;
1430 static int start_tx(
struct atm_dev *dev)
1432 struct eni_dev *eni_dev;
1441 skb_queue_head_init(&eni_dev->
tx_queue);
1443 for (i = 0; i <
NR_CHAN; i++) {
1445 eni_dev->
tx[
i].index =
i;
1456 static void foo(
void)
1459 "tx_complete=%d,dma_complete=%d,queued=%d,requeued=%d,sub=%d,\n"
1460 "backlogged=%d,rx_enqueued=%d,rx_dequeued=%d,putting=%d,pushed=%d\n",
1461 tx_complete,dma_complete,queued,requeued,submitted,backlogged,
1462 rx_enqueued,rx_dequeued,putting,pushed);
1469 static void bug_int(
struct atm_dev *dev,
unsigned long reason)
1477 "mismatch\n",dev->
number);
1480 "overflow\n",dev->
number);
1481 EVENT(
"---dump ends here---\n",0,0);
1490 struct eni_dev *eni_dev;
1497 DPRINTK(DEV_LABEL
": int 0x%lx\n",(
unsigned long) reason);
1505 EVENT(
"stat overflow\n",0,0);
1509 EVENT(
"SUNI int\n",0,0);
1510 dev->
phy->interrupt(dev);
1515 spin_lock(&eni_dev->
lock);
1517 spin_unlock(&eni_dev->
lock);
1518 tasklet_schedule(&eni_dev->
task);
1523 static void eni_tasklet(
unsigned long data)
1526 struct eni_dev *eni_dev =
ENI_DEV(dev);
1527 unsigned long flags;
1530 DPRINTK(
"eni_tasklet (dev %p)\n",dev);
1533 spin_unlock_irqrestore(&eni_dev->
lock,flags);
1535 EVENT(
"INT: RX DMA complete, starting dequeue_rx\n",0,0);
1537 EVENT(
"dequeue_rx done, starting poll_rx\n",0,0);
1539 EVENT(
"poll_rx done\n",0,0);
1543 EVENT(
"INT: service, starting get_service\n",0,0);
1545 EVENT(
"get_service done, starting poll_rx\n",0,0);
1547 EVENT(
"poll_rx done\n",0,0);
1550 EVENT(
"INT: TX DMA COMPLETE\n",0,0);
1554 EVENT(
"INT: TX COMPLETE\n",0,0);
1559 if (events & (MID_DMA_ERR_ACK | MID_TX_IDENT_MISM |
MID_TX_DMA_OVFL)) {
1560 EVENT(
"bug interrupt\n",0,0);
1561 bug_int(dev,events);
1571 "MMF",
"SMF",
"MMF",
"03?",
1572 "UTP",
"05?",
"06?",
"07?",
1573 "TAXI",
"09?",
"10?",
"11?",
1574 "12?",
"13?",
"14?",
"15?",
1575 "MMF",
"SMF",
"18?",
"19?",
1576 "UTP",
"21?",
"22?",
"23?",
1577 "24?",
"25?",
"26?",
"27?",
1578 "28?",
"29?",
"30?",
"31?"
1582 #define SET_SEPROM \
1583 ({ if (!error && !pci_error) { \
1584 pci_error = pci_write_config_byte(eni_dev->pci_dev,PCI_TONGA_CTRL,tonga); \
1587 #define GET_SEPROM \
1588 ({ if (!error && !pci_error) { \
1589 pci_error = pci_read_config_byte(eni_dev->pci_dev,PCI_TONGA_CTRL,&tonga); \
1596 struct eni_dev *eni_dev;
1597 unsigned char tonga;
1598 int error,failed,pci_error;
1602 error = pci_error = 0;
1605 for (i = 0; i <
ESI_LEN && !error && !pci_error; i++) {
1617 for (j = 7; j >= 0; j--) {
1637 if (failed) error = -
EIO;
1640 for (j = 7; j >= 0; j--) {
1647 if (tonga & SEPROM_DATA) dev->
esi[
i] |= 1;
1659 if (!(tonga & SEPROM_DATA)) error = -
EIO;
1666 tonga &= ~SEPROM_DATA;
1675 "(0x%02x)\n",dev->
number,pci_error);
1700 struct eni_dev *eni_dev;
1702 unsigned long real_base;
1713 eni_dev->
irq = pci_dev->
irq;
1714 if ((error = pci_write_config_word(pci_dev,
PCI_COMMAND,
1718 "(0x%02x)\n",dev->
number,error);
1726 "mapping\n",dev->
number);
1732 if (!eni_dev->
asic) {
1737 "(itf %d): bad magic - expected 0x%x, got 0x%x\n",
1750 if (
readl(eni_dev->
ram+i) != 0x55555555) last =
i;
1753 if (
readl(eni_dev->
ram+i) != 0xAAAAAAAA) last =
i;
1758 if (
readl(eni_dev->
ram+i) != i)
break;
1762 printk(
"mem=%dkB (",eni_dev->
mem >> 10);
1771 error = eni_dev->
asic ? get_esi_asic(dev) : get_esi_fpga(dev,base);
1775 printk(
"%s%02X",i ?
"-" :
"",dev->
esi[i]);
1791 static void eni_do_release(
struct atm_dev *dev)
1795 dev->
phy->stop(dev);
1802 struct eni_dev *eni_dev;
1805 unsigned long buffer_mem;
1821 "master (0x%02x)\n",dev->
number,error);
1827 "(0x%02x)\n",dev->
number,error);
1831 eni_dev->
vci = eni_dev->
ram;
1836 DPRINTK(
"vci 0x%lx,rx 0x%lx, tx 0x%lx,srv 0x%lx,buf 0x%lx\n",
1843 buffer_mem = eni_dev->
mem - (buf - eni_dev->
ram);
1854 eni_put_free(eni_dev,buf,buffer_mem);
1866 error = start_tx(dev);
1868 error = start_rx(dev);
1870 error = dev->
phy->start(dev);
1890 static void eni_close(
struct atm_vcc *vcc)
1897 DPRINTK(
"eni_close: done waiting\n");
1906 static int eni_open(
struct atm_vcc *vcc)
1908 struct eni_vcc *eni_vcc;
1910 short vpi = vcc->
vpi;
1914 EVENT(
"eni_open\n",0,0);
1921 DPRINTK(DEV_LABEL
"(itf %d): open %d.%d\n",vcc->
dev->number,vcc->
vpi,
1925 if (!eni_vcc)
return -
ENOMEM;
1928 if ((error = open_rx_first(vcc))) {
1932 if ((error = open_tx_first(vcc))) {
1938 if ((error = open_rx_second(vcc))) {
1942 if ((error = open_tx_second(vcc))) {
1952 static int eni_change_qos(
struct atm_vcc *vcc,
struct atm_qos *qos,
int flgs)
1962 if (rate < 0) rate = -
rate;
1964 if ((flgs &
ATM_MF_DEC_RSV) && rate && rate < tx->reserved) rsv = 1;
1966 if ((flgs &
ATM_MF_DEC_SHP) && rate && rate < tx->shaping) shp = 1;
1968 if (!rsv && !shp)
return 0;
1969 error = reserve_or_set_tx(vcc,&qos->
txtp,rsv,shp);
1970 if (error)
return error;
1976 tasklet_disable(&eni_dev->
task);
1977 skb_queue_walk(&eni_dev->
tx_queue, skb) {
1980 if (
ATM_SKB(skb)->vcc != vcc)
continue;
1986 tasklet_enable(&eni_dev->
task);
1991 static int eni_ioctl(
struct atm_dev *dev,
unsigned int cmd,
void __user *
arg)
1993 struct eni_dev *eni_dev =
ENI_DEV(dev);
1998 "instead of obsolete ioctl ENI_MEMDUMP\n",dev->
number);
2010 mult.tx > 65536 ||
mult.rx > 65536)
2021 if ((ci.vpi_bits == 0 || ci.vpi_bits ==
ATM_CI_MAX) &&
2027 return dev->
phy->ioctl(dev,cmd,arg);
2031 static int eni_getsockopt(
struct atm_vcc *vcc,
int level,
int optname,
2032 void __user *optval,
int optlen)
2038 static int eni_setsockopt(
struct atm_vcc *vcc,
int level,
int optname,
2039 void __user *optval,
unsigned int optlen)
2051 if (vcc->
pop) vcc->
pop(vcc,skb);
2052 else dev_kfree_skb(skb);
2057 if (vcc->
pop) vcc->
pop(vcc,skb);
2062 if (vcc->
pop) vcc->
pop(vcc,skb);
2063 else dev_kfree_skb(skb);
2073 if (res ==
enq_ok)
return 0;
2080 static void eni_phy_put(
struct atm_dev *dev,
unsigned char value,
2088 static unsigned char eni_phy_get(
struct atm_dev *dev,
unsigned long addr)
2094 static int eni_proc_read(
struct atm_dev *dev,loff_t *
pos,
char *
page)
2098 static const char *signal[] = {
"LOST",
"unknown",
"okay" };
2099 struct eni_dev *eni_dev =
ENI_DEV(dev);
2105 return sprintf(page,DEV_LABEL
"(itf %d) signal %s, %dkB, "
2106 "%d cps remaining\n",dev->
number,signal[(
int) dev->
signal],
2107 eni_dev->
mem >> 10,eni_dev->
tx_bw);
2109 return sprintf(page,
"%4sBursts: TX"
2110 #
if !defined(CONFIG_ATM_ENI_BURST_TX_16W) && \
2112 !defined(CONFIG_ATM_ENI_BURST_TX_4W) && \
2113 !defined(CONFIG_ATM_ENI_BURST_TX_2W)
2116 #ifdef CONFIG_ATM_ENI_BURST_TX_16W
2122 #ifdef CONFIG_ATM_ENI_BURST_TX_4W
2125 #ifdef CONFIG_ATM_ENI_BURST_TX_2W
2129 #
if !defined(CONFIG_ATM_ENI_BURST_RX_16W) && \
2130 !defined(CONFIG_ATM_ENI_BURST_RX_8W) && \
2132 !defined(CONFIG_ATM_ENI_BURST_RX_2W)
2135 #ifdef CONFIG_ATM_ENI_BURST_RX_16W
2138 #ifdef CONFIG_ATM_ENI_BURST_RX_8W
2144 #ifdef CONFIG_ATM_ENI_BURST_RX_2W
2147 #ifndef CONFIG_ATM_ENI_TUNE_BURST
2152 return sprintf(page,
"%4sBuffer multipliers: tx %d%%, rx %d%%\n",
2154 for (i = 0; i <
NR_CHAN; i++) {
2157 if (!tx->
send)
continue;
2159 return sprintf(page,
"tx[%d]: 0x%ld-0x%ld "
2160 "(%6ld bytes), rsv %d cps, shp %d cps%s\n",i,
2161 (
unsigned long) (tx->
send - eni_dev->
ram),
2164 tx == eni_dev->
ubr ?
" (UBR)" :
"");
2166 if (--left)
continue;
2167 return sprintf(page,
"%10sbacklog %u packets\n",
"",
2175 struct eni_vcc *eni_vcc;
2179 if (vcc->
dev != dev)
2182 if (--left)
continue;
2185 length +=
sprintf(page+length,
"0x%ld-0x%ld "
2187 (
unsigned long) (eni_vcc->
recv - eni_dev->
ram),
2190 if (eni_vcc->
tx) length +=
sprintf(page+length,
", ");
2193 length +=
sprintf(page+length,
"tx[%d], txing %d bytes",
2194 eni_vcc->
tx->index,eni_vcc->
txing);
2201 for (i = 0; i < eni_dev->
free_len; i++) {
2205 if (--left)
continue;
2207 return sprintf(page,
"free %p-%p (%6d bytes)\n",
2219 .getsockopt = eni_getsockopt,
2220 .setsockopt = eni_setsockopt,
2222 .phy_put = eni_phy_put,
2223 .phy_get = eni_phy_get,
2224 .change_qos = eni_change_qos,
2225 .proc_read = eni_proc_read
2229 static int __devinit eni_init_one(
struct pci_dev *pci_dev,
2233 struct eni_dev *eni_dev;
2234 struct eni_zero *
zero;
2246 zero = &eni_dev->
zero;
2253 goto err_free_consistent;
2256 pci_set_drvdata(pci_dev, dev);
2260 rc = eni_do_init(dev);
2262 goto err_unregister;
2264 rc = eni_start(dev);
2266 goto err_eni_release;
2268 eni_dev->
more = eni_boards;
2274 eni_do_release(dev);
2277 err_free_consistent:
2295 static void __devexit eni_remove_one(
struct pci_dev *pdev)
2297 struct atm_dev *dev = pci_get_drvdata(pdev);
2298 struct eni_dev *ed =
ENI_DEV(dev);
2299 struct eni_zero *zero = &ed->
zero;
2301 eni_do_release(dev);
2311 .id_table = eni_pci_tbl,
2312 .probe = eni_init_one,
2317 static int __init eni_init(
void)
2321 if (
sizeof(skb->cb) <
sizeof(
struct eni_skb_prv)) {
2322 printk(
KERN_ERR "eni_detect: skb->cb is too small (%Zd < %Zd)\n",
2326 return pci_register_driver(&eni_driver);