1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202#error Please convert me to Documentation/DMA-mapping.txt
203
204
205
206#include <linux/module.h>
207
208#include <linux/kernel.h>
209#include <linux/sched.h>
210#include <linux/string.h>
211#include <linux/errno.h>
212#include <linux/ioport.h>
213#include <linux/slab.h>
214#include <linux/interrupt.h>
215#include <linux/pci.h>
216#include <linux/delay.h>
217#include <linux/init.h>
218#include <linux/netdevice.h>
219#include <asm/byteorder.h>
220#include <asm/bitops.h>
221#include <asm/io.h>
222
223#include <linux/fddidevice.h>
224#include <linux/skbuff.h>
225
226#include "defxx.h"
227
228
229
230static char version[] __devinitdata =
231 "defxx.c:v1.05e 2001/02/03 Lawrence V. Stefani and others\n";
232
233#define DYNAMIC_BUFFERS 1
234
235#define SKBUFF_RX_COPYBREAK 200
236
237
238
239
240#define NEW_SKB_SIZE (PI_RCV_DATA_K_SIZE_MAX+128)
241
242
243
244static void dfx_bus_init(struct net_device *dev);
245static void dfx_bus_config_check(DFX_board_t *bp);
246
247static int dfx_driver_init(struct net_device *dev);
248static int dfx_adap_init(DFX_board_t *bp, int get_buffers);
249
250static int dfx_open(struct net_device *dev);
251static int dfx_close(struct net_device *dev);
252
253static void dfx_int_pr_halt_id(DFX_board_t *bp);
254static void dfx_int_type_0_process(DFX_board_t *bp);
255static void dfx_int_common(struct net_device *dev);
256static void dfx_interrupt(int irq, void *dev_id, struct pt_regs *regs);
257
258static struct net_device_stats *dfx_ctl_get_stats(struct net_device *dev);
259static void dfx_ctl_set_multicast_list(struct net_device *dev);
260static int dfx_ctl_set_mac_address(struct net_device *dev, void *addr);
261static int dfx_ctl_update_cam(DFX_board_t *bp);
262static int dfx_ctl_update_filters(DFX_board_t *bp);
263
264static int dfx_hw_dma_cmd_req(DFX_board_t *bp);
265static int dfx_hw_port_ctrl_req(DFX_board_t *bp, PI_UINT32 command, PI_UINT32 data_a, PI_UINT32 data_b, PI_UINT32 *host_data);
266static void dfx_hw_adap_reset(DFX_board_t *bp, PI_UINT32 type);
267static int dfx_hw_adap_state_rd(DFX_board_t *bp);
268static int dfx_hw_dma_uninit(DFX_board_t *bp, PI_UINT32 type);
269
270static int dfx_rcv_init(DFX_board_t *bp, int get_buffers);
271static void dfx_rcv_queue_process(DFX_board_t *bp);
272static void dfx_rcv_flush(DFX_board_t *bp);
273
274static int dfx_xmt_queue_pkt(struct sk_buff *skb, struct net_device *dev);
275static int dfx_xmt_done(DFX_board_t *bp);
276static void dfx_xmt_flush(DFX_board_t *bp);
277
278
279
280static struct net_device *root_dfx_eisa_dev;
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336static inline void dfx_port_write_byte(
337 DFX_board_t *bp,
338 int offset,
339 u8 data
340 )
341
342 {
343 u16 port = bp->base_addr + offset;
344
345 outb(data, port);
346 }
347
348static inline void dfx_port_read_byte(
349 DFX_board_t *bp,
350 int offset,
351 u8 *data
352 )
353
354 {
355 u16 port = bp->base_addr + offset;
356
357 *data = inb(port);
358 }
359
360static inline void dfx_port_write_long(
361 DFX_board_t *bp,
362 int offset,
363 u32 data
364 )
365
366 {
367 u16 port = bp->base_addr + offset;
368
369 outl(data, port);
370 }
371
372static inline void dfx_port_read_long(
373 DFX_board_t *bp,
374 int offset,
375 u32 *data
376 )
377
378 {
379 u16 port = bp->base_addr + offset;
380
381 *data = inl(port);
382 }
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414static int __devinit dfx_init_one_pci_or_eisa(struct pci_dev *pdev, long ioaddr)
415{
416 struct net_device *dev;
417 DFX_board_t *bp;
418 int err;
419
420#ifndef MODULE
421 static int version_disp;
422
423 if (!version_disp)
424 {
425 version_disp = 1;
426 printk(version);
427 }
428#endif
429
430
431
432
433
434 dev = init_fddidev(NULL, sizeof(*bp));
435 if (!dev) {
436 printk (KERN_ERR "defxx: unable to allocate fddidev, aborting\n");
437 return -ENOMEM;
438 }
439
440
441 if (pdev != NULL) {
442 err = pci_enable_device (pdev);
443 if (err) goto err_out;
444 ioaddr = pci_resource_start (pdev, 1);
445 }
446
447 SET_MODULE_OWNER(dev);
448
449 bp = dev->priv;
450
451 if (!request_region (ioaddr, pdev ? PFI_K_CSR_IO_LEN : PI_ESIC_K_CSR_IO_LEN, dev->name)) {
452 printk (KERN_ERR "%s: Cannot reserve I/O resource 0x%x @ 0x%lx, aborting\n",
453 dev->name, PFI_K_CSR_IO_LEN, ioaddr);
454 err = -EBUSY;
455 goto err_out;
456 }
457
458
459
460 dev->base_addr = ioaddr;
461
462 dev->get_stats = dfx_ctl_get_stats;
463 dev->open = dfx_open;
464 dev->stop = dfx_close;
465 dev->hard_start_xmit = dfx_xmt_queue_pkt;
466 dev->set_multicast_list = dfx_ctl_set_multicast_list;
467 dev->set_mac_address = dfx_ctl_set_mac_address;
468
469 if (pdev == NULL) {
470
471 bp->bus_type = DFX_BUS_TYPE_EISA;
472 bp->next = root_dfx_eisa_dev;
473 root_dfx_eisa_dev = dev;
474 } else {
475
476 bp->bus_type = DFX_BUS_TYPE_PCI;
477 bp->pci_dev = pdev;
478 pci_set_drvdata (pdev, dev);
479 pci_set_master (pdev);
480 }
481
482 if (dfx_driver_init(dev) != DFX_K_SUCCESS) {
483 err = -ENODEV;
484 goto err_out_region;
485 }
486
487 return 0;
488
489err_out_region:
490 release_region(ioaddr, pdev ? PFI_K_CSR_IO_LEN : PI_ESIC_K_CSR_IO_LEN);
491err_out:
492 unregister_netdev(dev);
493 kfree(dev);
494 return err;
495}
496
497static int __devinit dfx_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
498{
499 return dfx_init_one_pci_or_eisa(pdev, 0);
500}
501
502static int __init dfx_eisa_init(void)
503{
504 int rc = -ENODEV;
505 int i;
506 u16 port;
507 u32 slot_id;
508
509 DBG_printk("In dfx_eisa_init...\n");
510
511
512
513 for (i=0; i < DFX_MAX_EISA_SLOTS; i++)
514 {
515 port = (i << 12) + PI_ESIC_K_SLOT_ID;
516 slot_id = inl(port);
517 if ((slot_id & 0xF0FFFFFF) == DEFEA_PRODUCT_ID)
518 {
519 port = (i << 12);
520
521 if (dfx_init_one_pci_or_eisa(NULL, port) == 0) rc = 0;
522 }
523 }
524 return rc;
525}
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558static void __devinit dfx_bus_init(struct net_device *dev)
559{
560 DFX_board_t *bp = dev->priv;
561 u8 val;
562
563 DBG_printk("In dfx_bus_init...\n");
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580 bp->base_addr = dev->base_addr;
581
582
583 bp->dev = dev;
584
585
586
587 if (bp->bus_type == DFX_BUS_TYPE_EISA)
588 {
589
590
591 dfx_port_read_byte(bp, PI_ESIC_K_IO_CONFIG_STAT_0, &val);
592 switch ((val & PI_CONFIG_STAT_0_M_IRQ) >> PI_CONFIG_STAT_0_V_IRQ)
593 {
594 case PI_CONFIG_STAT_0_IRQ_K_9:
595 dev->irq = 9;
596 break;
597
598 case PI_CONFIG_STAT_0_IRQ_K_10:
599 dev->irq = 10;
600 break;
601
602 case PI_CONFIG_STAT_0_IRQ_K_11:
603 dev->irq = 11;
604 break;
605
606 case PI_CONFIG_STAT_0_IRQ_K_15:
607 dev->irq = 15;
608 break;
609 }
610
611
612
613 dfx_port_write_byte(bp, PI_ESIC_K_FUNCTION_CNTRL, PI_ESIC_K_FUNCTION_CNTRL_IO_ENB);
614
615
616
617 val = ((dev->base_addr >> 12) << PI_IO_CMP_V_SLOT);
618 dfx_port_write_byte(bp, PI_ESIC_K_IO_CMP_0_1, val);
619 dfx_port_write_byte(bp, PI_ESIC_K_IO_CMP_1_1, val);
620
621
622
623 dfx_port_write_byte(bp, PI_ESIC_K_SLOT_CNTRL, PI_SLOT_CNTRL_M_ENB);
624
625
626
627
628
629
630 dfx_port_read_byte(bp, PI_ESIC_K_BURST_HOLDOFF, &val);
631 dfx_port_write_byte(bp, PI_ESIC_K_BURST_HOLDOFF, (val & ~PI_BURST_HOLDOFF_M_MEM_MAP));
632
633
634
635 dfx_port_read_byte(bp, PI_ESIC_K_IO_CONFIG_STAT_0, &val);
636 dfx_port_write_byte(bp, PI_ESIC_K_IO_CONFIG_STAT_0, (val | PI_CONFIG_STAT_0_M_INT_ENB));
637 }
638 else
639 {
640 struct pci_dev *pdev = bp->pci_dev;
641
642
643
644 dev->irq = pdev->irq;
645
646
647
648 pci_read_config_byte(pdev, PCI_LATENCY_TIMER, &val);
649 if (val < PFI_K_LAT_TIMER_MIN)
650 {
651 val = PFI_K_LAT_TIMER_DEF;
652 pci_write_config_byte(pdev, PCI_LATENCY_TIMER, val);
653 }
654
655
656
657 dfx_port_write_long(bp, PFI_K_REG_MODE_CTRL, (PFI_MODE_M_PDQ_INT_ENB | PFI_MODE_M_DMA_ENB));
658 }
659 }
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692static void __devinit dfx_bus_config_check(DFX_board_t *bp)
693{
694 int status;
695 u32 slot_id;
696 u32 host_data;
697
698 DBG_printk("In dfx_bus_config_check...\n");
699
700
701
702 if (bp->bus_type == DFX_BUS_TYPE_EISA)
703 {
704 dfx_port_read_long(bp, PI_ESIC_K_SLOT_ID, &slot_id);
705
706
707
708
709
710
711
712
713
714 if (slot_id == DEFEA_PROD_ID_2)
715 {
716
717
718
719
720
721 status = dfx_hw_port_ctrl_req(bp,
722 PI_PCTRL_M_SUB_CMD,
723 PI_SUB_CMD_K_PDQ_REV_GET,
724 0,
725 &host_data);
726 if ((status != DFX_K_SUCCESS) || (host_data == 2))
727 {
728
729
730
731
732
733
734
735
736 switch (bp->burst_size)
737 {
738 case PI_PDATA_B_DMA_BURST_SIZE_32:
739 case PI_PDATA_B_DMA_BURST_SIZE_16:
740 bp->burst_size = PI_PDATA_B_DMA_BURST_SIZE_8;
741 break;
742
743 default:
744 break;
745 }
746
747
748
749 bp->full_duplex_enb = PI_SNMP_K_FALSE;
750 }
751 }
752 }
753 }
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792static int __devinit dfx_driver_init(struct net_device *dev)
793{
794 DFX_board_t *bp = dev->priv;
795 int alloc_size;
796 char *top_v, *curr_v;
797 u32 top_p, curr_p;
798 u32 data;
799
800 DBG_printk("In dfx_driver_init...\n");
801
802
803
804 dfx_bus_init(dev);
805
806
807
808
809
810
811
812
813
814
815 bp->full_duplex_enb = PI_SNMP_K_FALSE;
816 bp->req_ttrt = 8 * 12500;
817 bp->burst_size = PI_PDATA_B_DMA_BURST_SIZE_DEF;
818 bp->rcv_bufs_to_post = RCV_BUFS_DEF;
819
820
821
822
823
824
825
826
827
828
829 dfx_bus_config_check(bp);
830
831
832
833 dfx_port_write_long(bp, PI_PDQ_K_REG_HOST_INT_ENB, PI_HOST_INT_K_DISABLE_ALL_INTS);
834
835
836
837 (void) dfx_hw_dma_uninit(bp, PI_PDATA_A_RESET_M_SKIP_ST);
838
839
840
841 if (dfx_hw_port_ctrl_req(bp,
842 PI_PCTRL_M_MLA,
843 PI_PDATA_A_MLA_K_LO,
844 0,
845 &data) != DFX_K_SUCCESS)
846 {
847 printk("%s: Could not read adapter factory MAC address!\n", dev->name);
848 return(DFX_K_FAILURE);
849 }
850 memcpy(&bp->factory_mac_addr[0], &data, sizeof(u32));
851
852 if (dfx_hw_port_ctrl_req(bp,
853 PI_PCTRL_M_MLA,
854 PI_PDATA_A_MLA_K_HI,
855 0,
856 &data) != DFX_K_SUCCESS)
857 {
858 printk("%s: Could not read adapter factory MAC address!\n", dev->name);
859 return(DFX_K_FAILURE);
860 }
861 memcpy(&bp->factory_mac_addr[4], &data, sizeof(u16));
862
863
864
865
866
867
868
869
870 memcpy(dev->dev_addr, bp->factory_mac_addr, FDDI_K_ALEN);
871 if (bp->bus_type == DFX_BUS_TYPE_EISA)
872 printk("%s: DEFEA at I/O addr = 0x%lX, IRQ = %d, Hardware addr = %02X-%02X-%02X-%02X-%02X-%02X\n",
873 dev->name,
874 dev->base_addr,
875 dev->irq,
876 dev->dev_addr[0],
877 dev->dev_addr[1],
878 dev->dev_addr[2],
879 dev->dev_addr[3],
880 dev->dev_addr[4],
881 dev->dev_addr[5]);
882 else
883 printk("%s: DEFPA at I/O addr = 0x%lX, IRQ = %d, Hardware addr = %02X-%02X-%02X-%02X-%02X-%02X\n",
884 dev->name,
885 dev->base_addr,
886 dev->irq,
887 dev->dev_addr[0],
888 dev->dev_addr[1],
889 dev->dev_addr[2],
890 dev->dev_addr[3],
891 dev->dev_addr[4],
892 dev->dev_addr[5]);
893
894
895
896
897
898
899 alloc_size = sizeof(PI_DESCR_BLOCK) +
900 PI_CMD_REQ_K_SIZE_MAX +
901 PI_CMD_RSP_K_SIZE_MAX +
902#ifndef DYNAMIC_BUFFERS
903 (bp->rcv_bufs_to_post * PI_RCV_DATA_K_SIZE_MAX) +
904#endif
905 sizeof(PI_CONSUMER_BLOCK) +
906 (PI_ALIGN_K_DESC_BLK - 1);
907 bp->kmalloced = top_v = (char *) kmalloc(alloc_size, GFP_KERNEL);
908 if (top_v == NULL)
909 {
910 printk("%s: Could not allocate memory for host buffers and structures!\n", dev->name);
911 return(DFX_K_FAILURE);
912 }
913 memset(top_v, 0, alloc_size);
914 top_p = virt_to_bus(top_v);
915
916
917
918
919
920
921
922
923
924
925
926
927
928 curr_p = (u32) (ALIGN(top_p, PI_ALIGN_K_DESC_BLK));
929 curr_v = top_v + (curr_p - top_p);
930
931
932
933 bp->descr_block_virt = (PI_DESCR_BLOCK *) curr_v;
934 bp->descr_block_phys = curr_p;
935 curr_v += sizeof(PI_DESCR_BLOCK);
936 curr_p += sizeof(PI_DESCR_BLOCK);
937
938
939
940 bp->cmd_req_virt = (PI_DMA_CMD_REQ *) curr_v;
941 bp->cmd_req_phys = curr_p;
942 curr_v += PI_CMD_REQ_K_SIZE_MAX;
943 curr_p += PI_CMD_REQ_K_SIZE_MAX;
944
945
946
947 bp->cmd_rsp_virt = (PI_DMA_CMD_RSP *) curr_v;
948 bp->cmd_rsp_phys = curr_p;
949 curr_v += PI_CMD_RSP_K_SIZE_MAX;
950 curr_p += PI_CMD_RSP_K_SIZE_MAX;
951
952
953
954 bp->rcv_block_virt = curr_v;
955 bp->rcv_block_phys = curr_p;
956
957#ifndef DYNAMIC_BUFFERS
958 curr_v += (bp->rcv_bufs_to_post * PI_RCV_DATA_K_SIZE_MAX);
959 curr_p += (bp->rcv_bufs_to_post * PI_RCV_DATA_K_SIZE_MAX);
960#endif
961
962
963
964 bp->cons_block_virt = (PI_CONSUMER_BLOCK *) curr_v;
965 bp->cons_block_phys = curr_p;
966
967
968
969 DBG_printk("%s: Descriptor block virt = %0lX, phys = %0X\n", dev->name, (long)bp->descr_block_virt, bp->descr_block_phys);
970 DBG_printk("%s: Command Request buffer virt = %0lX, phys = %0X\n", dev->name, (long)bp->cmd_req_virt, bp->cmd_req_phys);
971 DBG_printk("%s: Command Response buffer virt = %0lX, phys = %0X\n", dev->name, (long)bp->cmd_rsp_virt, bp->cmd_rsp_phys);
972 DBG_printk("%s: Receive buffer block virt = %0lX, phys = %0X\n", dev->name, (long)bp->rcv_block_virt, bp->rcv_block_phys);
973 DBG_printk("%s: Consumer block virt = %0lX, phys = %0X\n", dev->name, (long)bp->cons_block_virt, bp->cons_block_phys);
974
975 return(DFX_K_SUCCESS);
976 }
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012static int dfx_adap_init(DFX_board_t *bp, int get_buffers)
1013 {
1014 DBG_printk("In dfx_adap_init...\n");
1015
1016
1017
1018 dfx_port_write_long(bp, PI_PDQ_K_REG_HOST_INT_ENB, PI_HOST_INT_K_DISABLE_ALL_INTS);
1019
1020
1021
1022 if (dfx_hw_dma_uninit(bp, bp->reset_type) != DFX_K_SUCCESS)
1023 {
1024 printk("%s: Could not uninitialize/reset adapter!\n", bp->dev->name);
1025 return(DFX_K_FAILURE);
1026 }
1027
1028
1029
1030
1031
1032
1033 dfx_port_write_long(bp, PI_PDQ_K_REG_TYPE_0_STATUS, PI_HOST_INT_K_ACK_ALL_TYPE_0);
1034
1035
1036
1037
1038
1039
1040
1041
1042 bp->cmd_req_reg.lword = 0;
1043 bp->cmd_rsp_reg.lword = 0;
1044 bp->rcv_xmt_reg.lword = 0;
1045
1046
1047
1048 memset(bp->cons_block_virt, 0, sizeof(PI_CONSUMER_BLOCK));
1049
1050
1051
1052 if (dfx_hw_port_ctrl_req(bp,
1053 PI_PCTRL_M_SUB_CMD,
1054 PI_SUB_CMD_K_BURST_SIZE_SET,
1055 bp->burst_size,
1056 NULL) != DFX_K_SUCCESS)
1057 {
1058 printk("%s: Could not set adapter burst size!\n", bp->dev->name);
1059 return(DFX_K_FAILURE);
1060 }
1061
1062
1063
1064
1065
1066
1067
1068
1069 if (dfx_hw_port_ctrl_req(bp,
1070 PI_PCTRL_M_CONS_BLOCK,
1071 bp->cons_block_phys,
1072 0,
1073 NULL) != DFX_K_SUCCESS)
1074 {
1075 printk("%s: Could not set consumer block address!\n", bp->dev->name);
1076 return(DFX_K_FAILURE);
1077 }
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092 if (dfx_hw_port_ctrl_req(bp,
1093 PI_PCTRL_M_INIT,
1094 (u32) (bp->descr_block_phys | PI_PDATA_A_INIT_M_BSWAP_DATA),
1095 0,
1096 NULL) != DFX_K_SUCCESS)
1097 {
1098 printk("%s: Could not set descriptor block address!\n", bp->dev->name);
1099 return(DFX_K_FAILURE);
1100 }
1101
1102
1103
1104 bp->cmd_req_virt->cmd_type = PI_CMD_K_CHARS_SET;
1105 bp->cmd_req_virt->char_set.item[0].item_code = PI_ITEM_K_FLUSH_TIME;
1106 bp->cmd_req_virt->char_set.item[0].value = 3;
1107 bp->cmd_req_virt->char_set.item[0].item_index = 0;
1108 bp->cmd_req_virt->char_set.item[1].item_code = PI_ITEM_K_EOL;
1109 if (dfx_hw_dma_cmd_req(bp) != DFX_K_SUCCESS)
1110 {
1111 printk("%s: DMA command request failed!\n", bp->dev->name);
1112 return(DFX_K_FAILURE);
1113 }
1114
1115
1116
1117 bp->cmd_req_virt->cmd_type = PI_CMD_K_SNMP_SET;
1118 bp->cmd_req_virt->snmp_set.item[0].item_code = PI_ITEM_K_FDX_ENB_DIS;
1119 bp->cmd_req_virt->snmp_set.item[0].value = bp->full_duplex_enb;
1120 bp->cmd_req_virt->snmp_set.item[0].item_index = 0;
1121 bp->cmd_req_virt->snmp_set.item[1].item_code = PI_ITEM_K_MAC_T_REQ;
1122 bp->cmd_req_virt->snmp_set.item[1].value = bp->req_ttrt;
1123 bp->cmd_req_virt->snmp_set.item[1].item_index = 0;
1124 bp->cmd_req_virt->snmp_set.item[2].item_code = PI_ITEM_K_EOL;
1125 if (dfx_hw_dma_cmd_req(bp) != DFX_K_SUCCESS)
1126 {
1127 printk("%s: DMA command request failed!\n", bp->dev->name);
1128 return(DFX_K_FAILURE);
1129 }
1130
1131
1132
1133 if (dfx_ctl_update_cam(bp) != DFX_K_SUCCESS)
1134 {
1135 printk("%s: Adapter CAM update failed!\n", bp->dev->name);
1136 return(DFX_K_FAILURE);
1137 }
1138
1139
1140
1141 if (dfx_ctl_update_filters(bp) != DFX_K_SUCCESS)
1142 {
1143 printk("%s: Adapter filters update failed!\n", bp->dev->name);
1144 return(DFX_K_FAILURE);
1145 }
1146
1147
1148
1149
1150
1151
1152 if (get_buffers)
1153 dfx_rcv_flush(bp);
1154
1155
1156
1157 if (dfx_rcv_init(bp, get_buffers))
1158 {
1159 printk("%s: Receive buffer allocation failed\n", bp->dev->name);
1160 if (get_buffers)
1161 dfx_rcv_flush(bp);
1162 return(DFX_K_FAILURE);
1163 }
1164
1165
1166
1167 bp->cmd_req_virt->cmd_type = PI_CMD_K_START;
1168 if (dfx_hw_dma_cmd_req(bp) != DFX_K_SUCCESS)
1169 {
1170 printk("%s: Start command failed\n", bp->dev->name);
1171 if (get_buffers)
1172 dfx_rcv_flush(bp);
1173 return(DFX_K_FAILURE);
1174 }
1175
1176
1177
1178 dfx_port_write_long(bp, PI_PDQ_K_REG_HOST_INT_ENB, PI_HOST_INT_K_ENABLE_DEF_INTS);
1179 return(DFX_K_SUCCESS);
1180 }
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213static int dfx_open(struct net_device *dev)
1214{
1215 int ret;
1216 DFX_board_t *bp = dev->priv;
1217
1218 DBG_printk("In dfx_open...\n");
1219
1220
1221
1222 ret = request_irq(dev->irq, (void *)dfx_interrupt, SA_SHIRQ, dev->name, dev);
1223 if (ret) {
1224 printk(KERN_ERR "%s: Requested IRQ %d is busy\n", dev->name, dev->irq);
1225 return ret;
1226 }
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239 memcpy(dev->dev_addr, bp->factory_mac_addr, FDDI_K_ALEN);
1240
1241
1242
1243 memset(bp->uc_table, 0, sizeof(bp->uc_table));
1244 memset(bp->mc_table, 0, sizeof(bp->mc_table));
1245 bp->uc_count = 0;
1246 bp->mc_count = 0;
1247
1248
1249
1250 bp->ind_group_prom = PI_FSTATE_K_BLOCK;
1251 bp->group_prom = PI_FSTATE_K_BLOCK;
1252
1253 spin_lock_init(&bp->lock);
1254
1255
1256
1257 bp->reset_type = PI_PDATA_A_RESET_M_SKIP_ST;
1258 if (dfx_adap_init(bp, 1) != DFX_K_SUCCESS)
1259 {
1260 printk(KERN_ERR "%s: Adapter open failed!\n", dev->name);
1261 free_irq(dev->irq, dev);
1262 return -EAGAIN;
1263 }
1264
1265
1266 netif_start_queue(dev);
1267 return(0);
1268}
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303static int dfx_close(struct net_device *dev)
1304{
1305 DFX_board_t *bp = dev->priv;
1306
1307 DBG_printk("In dfx_close...\n");
1308
1309
1310
1311 dfx_port_write_long(bp, PI_PDQ_K_REG_HOST_INT_ENB, PI_HOST_INT_K_DISABLE_ALL_INTS);
1312
1313
1314
1315 (void) dfx_hw_dma_uninit(bp, PI_PDATA_A_RESET_M_SKIP_ST);
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326 dfx_xmt_flush(bp);
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339 bp->cmd_req_reg.lword = 0;
1340 bp->cmd_rsp_reg.lword = 0;
1341 bp->rcv_xmt_reg.lword = 0;
1342
1343
1344
1345 memset(bp->cons_block_virt, 0, sizeof(PI_CONSUMER_BLOCK));
1346
1347
1348
1349 dfx_rcv_flush(bp);
1350
1351
1352
1353 netif_stop_queue(dev);
1354
1355
1356
1357 free_irq(dev->irq, dev);
1358
1359 return(0);
1360}
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390static void dfx_int_pr_halt_id(DFX_board_t *bp)
1391 {
1392 PI_UINT32 port_status;
1393 PI_UINT32 halt_id;
1394
1395
1396
1397 dfx_port_read_long(bp, PI_PDQ_K_REG_PORT_STATUS, &port_status);
1398
1399
1400
1401 halt_id = (port_status & PI_PSTATUS_M_HALT_ID) >> PI_PSTATUS_V_HALT_ID;
1402 switch (halt_id)
1403 {
1404 case PI_HALT_ID_K_SELFTEST_TIMEOUT:
1405 printk("%s: Halt ID: Selftest Timeout\n", bp->dev->name);
1406 break;
1407
1408 case PI_HALT_ID_K_PARITY_ERROR:
1409 printk("%s: Halt ID: Host Bus Parity Error\n", bp->dev->name);
1410 break;
1411
1412 case PI_HALT_ID_K_HOST_DIR_HALT:
1413 printk("%s: Halt ID: Host-Directed Halt\n", bp->dev->name);
1414 break;
1415
1416 case PI_HALT_ID_K_SW_FAULT:
1417 printk("%s: Halt ID: Adapter Software Fault\n", bp->dev->name);
1418 break;
1419
1420 case PI_HALT_ID_K_HW_FAULT:
1421 printk("%s: Halt ID: Adapter Hardware Fault\n", bp->dev->name);
1422 break;
1423
1424 case PI_HALT_ID_K_PC_TRACE:
1425 printk("%s: Halt ID: FDDI Network PC Trace Path Test\n", bp->dev->name);
1426 break;
1427
1428 case PI_HALT_ID_K_DMA_ERROR:
1429 printk("%s: Halt ID: Adapter DMA Error\n", bp->dev->name);
1430 break;
1431
1432 case PI_HALT_ID_K_IMAGE_CRC_ERROR:
1433 printk("%s: Halt ID: Firmware Image CRC Error\n", bp->dev->name);
1434 break;
1435
1436 case PI_HALT_ID_K_BUS_EXCEPTION:
1437 printk("%s: Halt ID: 68000 Bus Exception\n", bp->dev->name);
1438 break;
1439
1440 default:
1441 printk("%s: Halt ID: Unknown (code = %X)\n", bp->dev->name, halt_id);
1442 break;
1443 }
1444 }
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494static void dfx_int_type_0_process(DFX_board_t *bp)
1495
1496 {
1497 PI_UINT32 type_0_status;
1498 PI_UINT32 state;
1499
1500
1501
1502
1503
1504
1505
1506 dfx_port_read_long(bp, PI_PDQ_K_REG_TYPE_0_STATUS, &type_0_status);
1507 dfx_port_write_long(bp, PI_PDQ_K_REG_TYPE_0_STATUS, type_0_status);
1508
1509
1510
1511 if (type_0_status & (PI_TYPE_0_STAT_M_NXM |
1512 PI_TYPE_0_STAT_M_PM_PAR_ERR |
1513 PI_TYPE_0_STAT_M_BUS_PAR_ERR))
1514 {
1515
1516
1517 if (type_0_status & PI_TYPE_0_STAT_M_NXM)
1518 printk("%s: Non-Existent Memory Access Error\n", bp->dev->name);
1519
1520
1521
1522 if (type_0_status & PI_TYPE_0_STAT_M_PM_PAR_ERR)
1523 printk("%s: Packet Memory Parity Error\n", bp->dev->name);
1524
1525
1526
1527 if (type_0_status & PI_TYPE_0_STAT_M_BUS_PAR_ERR)
1528 printk("%s: Host Bus Parity Error\n", bp->dev->name);
1529
1530
1531
1532 bp->link_available = PI_K_FALSE;
1533 bp->reset_type = 0;
1534 printk("%s: Resetting adapter...\n", bp->dev->name);
1535 if (dfx_adap_init(bp, 0) != DFX_K_SUCCESS)
1536 {
1537 printk("%s: Adapter reset failed! Disabling adapter interrupts.\n", bp->dev->name);
1538 dfx_port_write_long(bp, PI_PDQ_K_REG_HOST_INT_ENB, PI_HOST_INT_K_DISABLE_ALL_INTS);
1539 return;
1540 }
1541 printk("%s: Adapter reset successful!\n", bp->dev->name);
1542 return;
1543 }
1544
1545
1546
1547 if (type_0_status & PI_TYPE_0_STAT_M_XMT_FLUSH)
1548 {
1549
1550
1551 bp->link_available = PI_K_FALSE;
1552 dfx_xmt_flush(bp);
1553 (void) dfx_hw_port_ctrl_req(bp,
1554 PI_PCTRL_M_XMT_DATA_FLUSH_DONE,
1555 0,
1556 0,
1557 NULL);
1558 }
1559
1560
1561
1562 if (type_0_status & PI_TYPE_0_STAT_M_STATE_CHANGE)
1563 {
1564
1565
1566 state = dfx_hw_adap_state_rd(bp);
1567 if (state == PI_STATE_K_HALTED)
1568 {
1569
1570
1571
1572
1573
1574
1575 printk("%s: Controller has transitioned to HALTED state!\n", bp->dev->name);
1576 dfx_int_pr_halt_id(bp);
1577
1578
1579
1580 bp->link_available = PI_K_FALSE;
1581 bp->reset_type = 0;
1582 printk("%s: Resetting adapter...\n", bp->dev->name);
1583 if (dfx_adap_init(bp, 0) != DFX_K_SUCCESS)
1584 {
1585 printk("%s: Adapter reset failed! Disabling adapter interrupts.\n", bp->dev->name);
1586 dfx_port_write_long(bp, PI_PDQ_K_REG_HOST_INT_ENB, PI_HOST_INT_K_DISABLE_ALL_INTS);
1587 return;
1588 }
1589 printk("%s: Adapter reset successful!\n", bp->dev->name);
1590 }
1591 else if (state == PI_STATE_K_LINK_AVAIL)
1592 {
1593 bp->link_available = PI_K_TRUE;
1594 }
1595 }
1596 }
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639static void dfx_int_common(struct net_device *dev)
1640{
1641 DFX_board_t *bp = dev->priv;
1642 PI_UINT32 port_status;
1643
1644
1645
1646 if(dfx_xmt_done(bp))
1647 netif_wake_queue(dev);
1648
1649
1650
1651 dfx_rcv_queue_process(bp);
1652
1653
1654
1655
1656
1657
1658
1659
1660 dfx_port_write_long(bp, PI_PDQ_K_REG_TYPE_2_PROD, bp->rcv_xmt_reg.lword);
1661
1662
1663
1664 dfx_port_read_long(bp, PI_PDQ_K_REG_PORT_STATUS, &port_status);
1665
1666
1667
1668 if (port_status & PI_PSTATUS_M_TYPE_0_PENDING)
1669 dfx_int_type_0_process(bp);
1670 }
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709static void dfx_interrupt(int irq, void *dev_id, struct pt_regs *regs)
1710 {
1711 struct net_device *dev = dev_id;
1712 DFX_board_t *bp;
1713 u8 tmp;
1714
1715
1716
1717 bp = dev->priv;
1718
1719 spin_lock(&bp->lock);
1720
1721
1722
1723
1724
1725 if (bp->bus_type == DFX_BUS_TYPE_PCI)
1726 {
1727
1728
1729 dfx_port_write_long(bp, PFI_K_REG_MODE_CTRL, PFI_MODE_M_DMA_ENB);
1730
1731
1732
1733 dfx_int_common(dev);
1734
1735
1736
1737 dfx_port_write_long(bp, PFI_K_REG_STATUS, PFI_STATUS_M_PDQ_INT);
1738 dfx_port_write_long(bp, PFI_K_REG_MODE_CTRL,
1739 (PFI_MODE_M_PDQ_INT_ENB + PFI_MODE_M_DMA_ENB));
1740 }
1741 else
1742 {
1743
1744
1745 dfx_port_read_byte(bp, PI_ESIC_K_IO_CONFIG_STAT_0, &tmp);
1746 tmp &= ~PI_CONFIG_STAT_0_M_INT_ENB;
1747 dfx_port_write_byte(bp, PI_ESIC_K_IO_CONFIG_STAT_0, tmp);
1748
1749
1750
1751 dfx_int_common(dev);
1752
1753
1754
1755 dfx_port_read_byte(bp, PI_ESIC_K_IO_CONFIG_STAT_0, &tmp);
1756 tmp |= PI_CONFIG_STAT_0_M_INT_ENB;
1757 dfx_port_write_byte(bp, PI_ESIC_K_IO_CONFIG_STAT_0, tmp);
1758 }
1759
1760 spin_unlock(&bp->lock);
1761 }
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807static struct net_device_stats *dfx_ctl_get_stats(struct net_device *dev)
1808 {
1809 DFX_board_t *bp = dev->priv;
1810
1811
1812
1813 bp->stats.rx_packets = bp->rcv_total_frames;
1814 bp->stats.tx_packets = bp->xmt_total_frames;
1815 bp->stats.rx_bytes = bp->rcv_total_bytes;
1816 bp->stats.tx_bytes = bp->xmt_total_bytes;
1817 bp->stats.rx_errors = (u32)(bp->rcv_crc_errors + bp->rcv_frame_status_errors + bp->rcv_length_errors);
1818 bp->stats.tx_errors = bp->xmt_length_errors;
1819 bp->stats.rx_dropped = bp->rcv_discards;
1820 bp->stats.tx_dropped = bp->xmt_discards;
1821 bp->stats.multicast = bp->rcv_multicast_frames;
1822 bp->stats.transmit_collision = 0;
1823
1824
1825
1826 bp->cmd_req_virt->cmd_type = PI_CMD_K_SMT_MIB_GET;
1827 if (dfx_hw_dma_cmd_req(bp) != DFX_K_SUCCESS)
1828 return((struct net_device_stats *) &bp->stats);
1829
1830
1831
1832 memcpy(bp->stats.smt_station_id, &bp->cmd_rsp_virt->smt_mib_get.smt_station_id, sizeof(bp->cmd_rsp_virt->smt_mib_get.smt_station_id));
1833 bp->stats.smt_op_version_id = bp->cmd_rsp_virt->smt_mib_get.smt_op_version_id;
1834 bp->stats.smt_hi_version_id = bp->cmd_rsp_virt->smt_mib_get.smt_hi_version_id;
1835 bp->stats.smt_lo_version_id = bp->cmd_rsp_virt->smt_mib_get.smt_lo_version_id;
1836 memcpy(bp->stats.smt_user_data, &bp->cmd_rsp_virt->smt_mib_get.smt_user_data, sizeof(bp->cmd_rsp_virt->smt_mib_get.smt_user_data));
1837 bp->stats.smt_mib_version_id = bp->cmd_rsp_virt->smt_mib_get.smt_mib_version_id;
1838 bp->stats.smt_mac_cts = bp->cmd_rsp_virt->smt_mib_get.smt_mac_ct;
1839 bp->stats.smt_non_master_cts = bp->cmd_rsp_virt->smt_mib_get.smt_non_master_ct;
1840 bp->stats.smt_master_cts = bp->cmd_rsp_virt->smt_mib_get.smt_master_ct;
1841 bp->stats.smt_available_paths = bp->cmd_rsp_virt->smt_mib_get.smt_available_paths;
1842 bp->stats.smt_config_capabilities = bp->cmd_rsp_virt->smt_mib_get.smt_config_capabilities;
1843 bp->stats.smt_config_policy = bp->cmd_rsp_virt->smt_mib_get.smt_config_policy;
1844 bp->stats.smt_connection_policy = bp->cmd_rsp_virt->smt_mib_get.smt_connection_policy;
1845 bp->stats.smt_t_notify = bp->cmd_rsp_virt->smt_mib_get.smt_t_notify;
1846 bp->stats.smt_stat_rpt_policy = bp->cmd_rsp_virt->smt_mib_get.smt_stat_rpt_policy;
1847 bp->stats.smt_trace_max_expiration = bp->cmd_rsp_virt->smt_mib_get.smt_trace_max_expiration;
1848 bp->stats.smt_bypass_present = bp->cmd_rsp_virt->smt_mib_get.smt_bypass_present;
1849 bp->stats.smt_ecm_state = bp->cmd_rsp_virt->smt_mib_get.smt_ecm_state;
1850 bp->stats.smt_cf_state = bp->cmd_rsp_virt->smt_mib_get.smt_cf_state;
1851 bp->stats.smt_remote_disconnect_flag = bp->cmd_rsp_virt->smt_mib_get.smt_remote_disconnect_flag;
1852 bp->stats.smt_station_status = bp->cmd_rsp_virt->smt_mib_get.smt_station_status;
1853 bp->stats.smt_peer_wrap_flag = bp->cmd_rsp_virt->smt_mib_get.smt_peer_wrap_flag;
1854 bp->stats.smt_time_stamp = bp->cmd_rsp_virt->smt_mib_get.smt_msg_time_stamp.ls;
1855 bp->stats.smt_transition_time_stamp = bp->cmd_rsp_virt->smt_mib_get.smt_transition_time_stamp.ls;
1856 bp->stats.mac_frame_status_functions = bp->cmd_rsp_virt->smt_mib_get.mac_frame_status_functions;
1857 bp->stats.mac_t_max_capability = bp->cmd_rsp_virt->smt_mib_get.mac_t_max_capability;
1858 bp->stats.mac_tvx_capability = bp->cmd_rsp_virt->smt_mib_get.mac_tvx_capability;
1859 bp->stats.mac_available_paths = bp->cmd_rsp_virt->smt_mib_get.mac_available_paths;
1860 bp->stats.mac_current_path = bp->cmd_rsp_virt->smt_mib_get.mac_current_path;
1861 memcpy(bp->stats.mac_upstream_nbr, &bp->cmd_rsp_virt->smt_mib_get.mac_upstream_nbr, FDDI_K_ALEN);
1862 memcpy(bp->stats.mac_downstream_nbr, &bp->cmd_rsp_virt->smt_mib_get.mac_downstream_nbr, FDDI_K_ALEN);
1863 memcpy(bp->stats.mac_old_upstream_nbr, &bp->cmd_rsp_virt->smt_mib_get.mac_old_upstream_nbr, FDDI_K_ALEN);
1864 memcpy(bp->stats.mac_old_downstream_nbr, &bp->cmd_rsp_virt->smt_mib_get.mac_old_downstream_nbr, FDDI_K_ALEN);
1865 bp->stats.mac_dup_address_test = bp->cmd_rsp_virt->smt_mib_get.mac_dup_address_test;
1866 bp->stats.mac_requested_paths = bp->cmd_rsp_virt->smt_mib_get.mac_requested_paths;
1867 bp->stats.mac_downstream_port_type = bp->cmd_rsp_virt->smt_mib_get.mac_downstream_port_type;
1868 memcpy(bp->stats.mac_smt_address, &bp->cmd_rsp_virt->smt_mib_get.mac_smt_address, FDDI_K_ALEN);
1869 bp->stats.mac_t_req = bp->cmd_rsp_virt->smt_mib_get.mac_t_req;
1870 bp->stats.mac_t_neg = bp->cmd_rsp_virt->smt_mib_get.mac_t_neg;
1871 bp->stats.mac_t_max = bp->cmd_rsp_virt->smt_mib_get.mac_t_max;
1872 bp->stats.mac_tvx_value = bp->cmd_rsp_virt->smt_mib_get.mac_tvx_value;
1873 bp->stats.mac_frame_error_threshold = bp->cmd_rsp_virt->smt_mib_get.mac_frame_error_threshold;
1874 bp->stats.mac_frame_error_ratio = bp->cmd_rsp_virt->smt_mib_get.mac_frame_error_ratio;
1875 bp->stats.mac_rmt_state = bp->cmd_rsp_virt->smt_mib_get.mac_rmt_state;
1876 bp->stats.mac_da_flag = bp->cmd_rsp_virt->smt_mib_get.mac_da_flag;
1877 bp->stats.mac_una_da_flag = bp->cmd_rsp_virt->smt_mib_get.mac_unda_flag;
1878 bp->stats.mac_frame_error_flag = bp->cmd_rsp_virt->smt_mib_get.mac_frame_error_flag;
1879 bp->stats.mac_ma_unitdata_available = bp->cmd_rsp_virt->smt_mib_get.mac_ma_unitdata_available;
1880 bp->stats.mac_hardware_present = bp->cmd_rsp_virt->smt_mib_get.mac_hardware_present;
1881 bp->stats.mac_ma_unitdata_enable = bp->cmd_rsp_virt->smt_mib_get.mac_ma_unitdata_enable;
1882 bp->stats.path_tvx_lower_bound = bp->cmd_rsp_virt->smt_mib_get.path_tvx_lower_bound;
1883 bp->stats.path_t_max_lower_bound = bp->cmd_rsp_virt->smt_mib_get.path_t_max_lower_bound;
1884 bp->stats.path_max_t_req = bp->cmd_rsp_virt->smt_mib_get.path_max_t_req;
1885 memcpy(bp->stats.path_configuration, &bp->cmd_rsp_virt->smt_mib_get.path_configuration, sizeof(bp->cmd_rsp_virt->smt_mib_get.path_configuration));
1886 bp->stats.port_my_type[0] = bp->cmd_rsp_virt->smt_mib_get.port_my_type[0];
1887 bp->stats.port_my_type[1] = bp->cmd_rsp_virt->smt_mib_get.port_my_type[1];
1888 bp->stats.port_neighbor_type[0] = bp->cmd_rsp_virt->smt_mib_get.port_neighbor_type[0];
1889 bp->stats.port_neighbor_type[1] = bp->cmd_rsp_virt->smt_mib_get.port_neighbor_type[1];
1890 bp->stats.port_connection_policies[0] = bp->cmd_rsp_virt->smt_mib_get.port_connection_policies[0];
1891 bp->stats.port_connection_policies[1] = bp->cmd_rsp_virt->smt_mib_get.port_connection_policies[1];
1892 bp->stats.port_mac_indicated[0] = bp->cmd_rsp_virt->smt_mib_get.port_mac_indicated[0];
1893 bp->stats.port_mac_indicated[1] = bp->cmd_rsp_virt->smt_mib_get.port_mac_indicated[1];
1894 bp->stats.port_current_path[0] = bp->cmd_rsp_virt->smt_mib_get.port_current_path[0];
1895 bp->stats.port_current_path[1] = bp->cmd_rsp_virt->smt_mib_get.port_current_path[1];
1896 memcpy(&bp->stats.port_requested_paths[0*3], &bp->cmd_rsp_virt->smt_mib_get.port_requested_paths[0], 3);
1897 memcpy(&bp->stats.port_requested_paths[1*3], &bp->cmd_rsp_virt->smt_mib_get.port_requested_paths[1], 3);
1898 bp->stats.port_mac_placement[0] = bp->cmd_rsp_virt->smt_mib_get.port_mac_placement[0];
1899 bp->stats.port_mac_placement[1] = bp->cmd_rsp_virt->smt_mib_get.port_mac_placement[1];
1900 bp->stats.port_available_paths[0] = bp->cmd_rsp_virt->smt_mib_get.port_available_paths[0];
1901 bp->stats.port_available_paths[1] = bp->cmd_rsp_virt->smt_mib_get.port_available_paths[1];
1902 bp->stats.port_pmd_class[0] = bp->cmd_rsp_virt->smt_mib_get.port_pmd_class[0];
1903 bp->stats.port_pmd_class[1] = bp->cmd_rsp_virt->smt_mib_get.port_pmd_class[1];
1904 bp->stats.port_connection_capabilities[0] = bp->cmd_rsp_virt->smt_mib_get.port_connection_capabilities[0];
1905 bp->stats.port_connection_capabilities[1] = bp->cmd_rsp_virt->smt_mib_get.port_connection_capabilities[1];
1906 bp->stats.port_bs_flag[0] = bp->cmd_rsp_virt->smt_mib_get.port_bs_flag[0];
1907 bp->stats.port_bs_flag[1] = bp->cmd_rsp_virt->smt_mib_get.port_bs_flag[1];
1908 bp->stats.port_ler_estimate[0] = bp->cmd_rsp_virt->smt_mib_get.port_ler_estimate[0];
1909 bp->stats.port_ler_estimate[1] = bp->cmd_rsp_virt->smt_mib_get.port_ler_estimate[1];
1910 bp->stats.port_ler_cutoff[0] = bp->cmd_rsp_virt->smt_mib_get.port_ler_cutoff[0];
1911 bp->stats.port_ler_cutoff[1] = bp->cmd_rsp_virt->smt_mib_get.port_ler_cutoff[1];
1912 bp->stats.port_ler_alarm[0] = bp->cmd_rsp_virt->smt_mib_get.port_ler_alarm[0];
1913 bp->stats.port_ler_alarm[1] = bp->cmd_rsp_virt->smt_mib_get.port_ler_alarm[1];
1914 bp->stats.port_connect_state[0] = bp->cmd_rsp_virt->smt_mib_get.port_connect_state[0];
1915 bp->stats.port_connect_state[1] = bp->cmd_rsp_virt->smt_mib_get.port_connect_state[1];
1916 bp->stats.port_pcm_state[0] = bp->cmd_rsp_virt->smt_mib_get.port_pcm_state[0];
1917 bp->stats.port_pcm_state[1] = bp->cmd_rsp_virt->smt_mib_get.port_pcm_state[1];
1918 bp->stats.port_pc_withhold[0] = bp->cmd_rsp_virt->smt_mib_get.port_pc_withhold[0];
1919 bp->stats.port_pc_withhold[1] = bp->cmd_rsp_virt->smt_mib_get.port_pc_withhold[1];
1920 bp->stats.port_ler_flag[0] = bp->cmd_rsp_virt->smt_mib_get.port_ler_flag[0];
1921 bp->stats.port_ler_flag[1] = bp->cmd_rsp_virt->smt_mib_get.port_ler_flag[1];
1922 bp->stats.port_hardware_present[0] = bp->cmd_rsp_virt->smt_mib_get.port_hardware_present[0];
1923 bp->stats.port_hardware_present[1] = bp->cmd_rsp_virt->smt_mib_get.port_hardware_present[1];
1924
1925
1926
1927 bp->cmd_req_virt->cmd_type = PI_CMD_K_CNTRS_GET;
1928 if (dfx_hw_dma_cmd_req(bp) != DFX_K_SUCCESS)
1929 return((struct net_device_stats *) &bp->stats);
1930
1931
1932
1933 bp->stats.mac_frame_cts = bp->cmd_rsp_virt->cntrs_get.cntrs.frame_cnt.ls;
1934 bp->stats.mac_copied_cts = bp->cmd_rsp_virt->cntrs_get.cntrs.copied_cnt.ls;
1935 bp->stats.mac_transmit_cts = bp->cmd_rsp_virt->cntrs_get.cntrs.transmit_cnt.ls;
1936 bp->stats.mac_error_cts = bp->cmd_rsp_virt->cntrs_get.cntrs.error_cnt.ls;
1937 bp->stats.mac_lost_cts = bp->cmd_rsp_virt->cntrs_get.cntrs.lost_cnt.ls;
1938 bp->stats.port_lct_fail_cts[0] = bp->cmd_rsp_virt->cntrs_get.cntrs.lct_rejects[0].ls;
1939 bp->stats.port_lct_fail_cts[1] = bp->cmd_rsp_virt->cntrs_get.cntrs.lct_rejects[1].ls;
1940 bp->stats.port_lem_reject_cts[0] = bp->cmd_rsp_virt->cntrs_get.cntrs.lem_rejects[0].ls;
1941 bp->stats.port_lem_reject_cts[1] = bp->cmd_rsp_virt->cntrs_get.cntrs.lem_rejects[1].ls;
1942 bp->stats.port_lem_cts[0] = bp->cmd_rsp_virt->cntrs_get.cntrs.link_errors[0].ls;
1943 bp->stats.port_lem_cts[1] = bp->cmd_rsp_virt->cntrs_get.cntrs.link_errors[1].ls;
1944
1945 return((struct net_device_stats *) &bp->stats);
1946 }
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992static void dfx_ctl_set_multicast_list(struct net_device *dev)
1993 {
1994 DFX_board_t *bp = dev->priv;
1995 int i;
1996 struct dev_mc_list *dmi;
1997
1998
1999
2000 if (dev->flags & IFF_PROMISC)
2001 bp->ind_group_prom = PI_FSTATE_K_PASS;
2002
2003
2004
2005 else
2006 {
2007 bp->ind_group_prom = PI_FSTATE_K_BLOCK;
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028 if (dev->mc_count > (PI_CMD_ADDR_FILTER_K_SIZE - bp->uc_count))
2029 {
2030 bp->group_prom = PI_FSTATE_K_PASS;
2031 bp->mc_count = 0;
2032 }
2033 else
2034 {
2035 bp->group_prom = PI_FSTATE_K_BLOCK;
2036 bp->mc_count = dev->mc_count;
2037 }
2038
2039
2040
2041 dmi = dev->mc_list;
2042 for (i=0; i < bp->mc_count; i++)
2043 {
2044 memcpy(&bp->mc_table[i*FDDI_K_ALEN], dmi->dmi_addr, FDDI_K_ALEN);
2045 dmi = dmi->next;
2046 }
2047 if (dfx_ctl_update_cam(bp) != DFX_K_SUCCESS)
2048 {
2049 DBG_printk("%s: Could not update multicast address table!\n", dev->name);
2050 }
2051 else
2052 {
2053 DBG_printk("%s: Multicast address table updated! Added %d addresses.\n", dev->name, bp->mc_count);
2054 }
2055 }
2056
2057
2058
2059 if (dfx_ctl_update_filters(bp) != DFX_K_SUCCESS)
2060 {
2061 DBG_printk("%s: Could not update adapter filters!\n", dev->name);
2062 }
2063 else
2064 {
2065 DBG_printk("%s: Adapter filters updated!\n", dev->name);
2066 }
2067 }
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106static int dfx_ctl_set_mac_address(struct net_device *dev, void *addr)
2107 {
2108 DFX_board_t *bp = dev->priv;
2109 struct sockaddr *p_sockaddr = (struct sockaddr *)addr;
2110
2111
2112
2113 memcpy(dev->dev_addr, p_sockaddr->sa_data, FDDI_K_ALEN);
2114 memcpy(&bp->uc_table[0], p_sockaddr->sa_data, FDDI_K_ALEN);
2115 bp->uc_count = 1;
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129 if ((bp->uc_count + bp->mc_count) > PI_CMD_ADDR_FILTER_K_SIZE)
2130 {
2131 bp->group_prom = PI_FSTATE_K_PASS;
2132 bp->mc_count = 0;
2133
2134
2135
2136 if (dfx_ctl_update_filters(bp) != DFX_K_SUCCESS)
2137 {
2138 DBG_printk("%s: Could not update adapter filters!\n", dev->name);
2139 }
2140 else
2141 {
2142 DBG_printk("%s: Adapter filters updated!\n", dev->name);
2143 }
2144 }
2145
2146
2147
2148 if (dfx_ctl_update_cam(bp) != DFX_K_SUCCESS)
2149 {
2150 DBG_printk("%s: Could not set new MAC address!\n", dev->name);
2151 }
2152 else
2153 {
2154 DBG_printk("%s: Adapter CAM updated with new MAC address\n", dev->name);
2155 }
2156 return(0);
2157 }
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193static int dfx_ctl_update_cam(DFX_board_t *bp)
2194 {
2195 int i;
2196 PI_LAN_ADDR *p_addr;
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211 memset(bp->cmd_req_virt, 0, PI_CMD_REQ_K_SIZE_MAX);
2212 bp->cmd_req_virt->cmd_type = PI_CMD_K_ADDR_FILTER_SET;
2213 p_addr = &bp->cmd_req_virt->addr_filter_set.entry[0];
2214
2215
2216
2217 for (i=0; i < (int)bp->uc_count; i++)
2218 {
2219 if (i < PI_CMD_ADDR_FILTER_K_SIZE)
2220 {
2221 memcpy(p_addr, &bp->uc_table[i*FDDI_K_ALEN], FDDI_K_ALEN);
2222 p_addr++;
2223 }
2224 }
2225
2226
2227
2228 for (i=0; i < (int)bp->mc_count; i++)
2229 {
2230 if ((i + bp->uc_count) < PI_CMD_ADDR_FILTER_K_SIZE)
2231 {
2232 memcpy(p_addr, &bp->mc_table[i*FDDI_K_ALEN], FDDI_K_ALEN);
2233 p_addr++;
2234 }
2235 }
2236
2237
2238
2239 if (dfx_hw_dma_cmd_req(bp) != DFX_K_SUCCESS)
2240 return(DFX_K_FAILURE);
2241 return(DFX_K_SUCCESS);
2242 }
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276static int dfx_ctl_update_filters(DFX_board_t *bp)
2277 {
2278 int i = 0;
2279
2280
2281
2282 bp->cmd_req_virt->cmd_type = PI_CMD_K_FILTERS_SET;
2283
2284
2285
2286 bp->cmd_req_virt->filter_set.item[i].item_code = PI_ITEM_K_BROADCAST;
2287 bp->cmd_req_virt->filter_set.item[i++].value = PI_FSTATE_K_PASS;
2288
2289
2290
2291 bp->cmd_req_virt->filter_set.item[i].item_code = PI_ITEM_K_IND_GROUP_PROM;
2292 bp->cmd_req_virt->filter_set.item[i++].value = bp->ind_group_prom;
2293
2294
2295
2296 bp->cmd_req_virt->filter_set.item[i].item_code = PI_ITEM_K_GROUP_PROM;
2297 bp->cmd_req_virt->filter_set.item[i++].value = bp->group_prom;
2298
2299
2300
2301 bp->cmd_req_virt->filter_set.item[i].item_code = PI_ITEM_K_EOL;
2302
2303
2304
2305 if (dfx_hw_dma_cmd_req(bp) != DFX_K_SUCCESS)
2306 return(DFX_K_FAILURE);
2307 return(DFX_K_SUCCESS);
2308 }
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351static int dfx_hw_dma_cmd_req(DFX_board_t *bp)
2352 {
2353 int status;
2354 int timeout_cnt;
2355
2356
2357
2358 status = dfx_hw_adap_state_rd(bp);
2359 if ((status == PI_STATE_K_RESET) ||
2360 (status == PI_STATE_K_HALTED) ||
2361 (status == PI_STATE_K_DMA_UNAVAIL) ||
2362 (status == PI_STATE_K_UPGRADE))
2363 return(DFX_K_OUTSTATE);
2364
2365
2366
2367 bp->descr_block_virt->cmd_rsp[bp->cmd_rsp_reg.index.prod].long_0 = (u32) (PI_RCV_DESCR_M_SOP |
2368 ((PI_CMD_RSP_K_SIZE_MAX / PI_ALIGN_K_CMD_RSP_BUFF) << PI_RCV_DESCR_V_SEG_LEN));
2369 bp->descr_block_virt->cmd_rsp[bp->cmd_rsp_reg.index.prod].long_1 = bp->cmd_rsp_phys;
2370
2371
2372
2373 bp->cmd_rsp_reg.index.prod += 1;
2374 bp->cmd_rsp_reg.index.prod &= PI_CMD_RSP_K_NUM_ENTRIES-1;
2375 dfx_port_write_long(bp, PI_PDQ_K_REG_CMD_RSP_PROD, bp->cmd_rsp_reg.lword);
2376
2377
2378
2379 bp->descr_block_virt->cmd_req[bp->cmd_req_reg.index.prod].long_0 = (u32) (PI_XMT_DESCR_M_SOP |
2380 PI_XMT_DESCR_M_EOP | (PI_CMD_REQ_K_SIZE_MAX << PI_XMT_DESCR_V_SEG_LEN));
2381 bp->descr_block_virt->cmd_req[bp->cmd_req_reg.index.prod].long_1 = bp->cmd_req_phys;
2382
2383
2384
2385 bp->cmd_req_reg.index.prod += 1;
2386 bp->cmd_req_reg.index.prod &= PI_CMD_REQ_K_NUM_ENTRIES-1;
2387 dfx_port_write_long(bp, PI_PDQ_K_REG_CMD_REQ_PROD, bp->cmd_req_reg.lword);
2388
2389
2390
2391
2392
2393
2394 for (timeout_cnt = 20000; timeout_cnt > 0; timeout_cnt--)
2395 {
2396 if (bp->cmd_req_reg.index.prod == (u8)(bp->cons_block_virt->cmd_req))
2397 break;
2398 udelay(100);
2399 }
2400 if (timeout_cnt == 0)
2401 return(DFX_K_HW_TIMEOUT);
2402
2403
2404
2405 bp->cmd_req_reg.index.comp += 1;
2406 bp->cmd_req_reg.index.comp &= PI_CMD_REQ_K_NUM_ENTRIES-1;
2407 dfx_port_write_long(bp, PI_PDQ_K_REG_CMD_REQ_PROD, bp->cmd_req_reg.lword);
2408
2409
2410
2411
2412
2413
2414 for (timeout_cnt = 20000; timeout_cnt > 0; timeout_cnt--)
2415 {
2416 if (bp->cmd_rsp_reg.index.prod == (u8)(bp->cons_block_virt->cmd_rsp))
2417 break;
2418 udelay(100);
2419 }
2420 if (timeout_cnt == 0)
2421 return(DFX_K_HW_TIMEOUT);
2422
2423
2424
2425 bp->cmd_rsp_reg.index.comp += 1;
2426 bp->cmd_rsp_reg.index.comp &= PI_CMD_RSP_K_NUM_ENTRIES-1;
2427 dfx_port_write_long(bp, PI_PDQ_K_REG_CMD_RSP_PROD, bp->cmd_rsp_reg.lword);
2428 return(DFX_K_SUCCESS);
2429 }
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465static int dfx_hw_port_ctrl_req(
2466 DFX_board_t *bp,
2467 PI_UINT32 command,
2468 PI_UINT32 data_a,
2469 PI_UINT32 data_b,
2470 PI_UINT32 *host_data
2471 )
2472
2473 {
2474 PI_UINT32 port_cmd;
2475 int timeout_cnt;
2476
2477
2478
2479 port_cmd = (PI_UINT32) (command | PI_PCTRL_M_CMD_ERROR);
2480
2481
2482
2483 dfx_port_write_long(bp, PI_PDQ_K_REG_PORT_DATA_A, data_a);
2484 dfx_port_write_long(bp, PI_PDQ_K_REG_PORT_DATA_B, data_b);
2485 dfx_port_write_long(bp, PI_PDQ_K_REG_PORT_CTRL, port_cmd);
2486
2487
2488
2489 if (command == PI_PCTRL_M_BLAST_FLASH)
2490 timeout_cnt = 600000;
2491 else
2492 timeout_cnt = 20000;
2493
2494 for (; timeout_cnt > 0; timeout_cnt--)
2495 {
2496 dfx_port_read_long(bp, PI_PDQ_K_REG_PORT_CTRL, &port_cmd);
2497 if (!(port_cmd & PI_PCTRL_M_CMD_ERROR))
2498 break;
2499 udelay(100);
2500 }
2501 if (timeout_cnt == 0)
2502 return(DFX_K_HW_TIMEOUT);
2503
2504
2505
2506
2507
2508
2509
2510 if (host_data != NULL)
2511 dfx_port_read_long(bp, PI_PDQ_K_REG_HOST_DATA, host_data);
2512 return(DFX_K_SUCCESS);
2513 }
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549static void dfx_hw_adap_reset(
2550 DFX_board_t *bp,
2551 PI_UINT32 type
2552 )
2553
2554 {
2555
2556
2557 dfx_port_write_long(bp, PI_PDQ_K_REG_PORT_DATA_A, type);
2558 dfx_port_write_long(bp, PI_PDQ_K_REG_PORT_RESET, PI_RESET_M_ASSERT_RESET);
2559
2560
2561
2562 udelay(20);
2563
2564
2565
2566 dfx_port_write_long(bp, PI_PDQ_K_REG_PORT_RESET, 0);
2567 }
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597static int dfx_hw_adap_state_rd(DFX_board_t *bp)
2598 {
2599 PI_UINT32 port_status;
2600
2601 dfx_port_read_long(bp, PI_PDQ_K_REG_PORT_STATUS, &port_status);
2602 return((port_status & PI_PSTATUS_M_STATE) >> PI_PSTATUS_V_STATE);
2603 }
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637static int dfx_hw_dma_uninit(DFX_board_t *bp, PI_UINT32 type)
2638 {
2639 int timeout_cnt;
2640
2641
2642
2643 dfx_hw_adap_reset(bp, type);
2644
2645
2646
2647 for (timeout_cnt = 100000; timeout_cnt > 0; timeout_cnt--)
2648 {
2649 if (dfx_hw_adap_state_rd(bp) == PI_STATE_K_DMA_UNAVAIL)
2650 break;
2651 udelay(100);
2652 }
2653 if (timeout_cnt == 0)
2654 return(DFX_K_HW_TIMEOUT);
2655 return(DFX_K_SUCCESS);
2656 }
2657
2658
2659
2660
2661
2662
2663static void my_skb_align(struct sk_buff *skb, int n)
2664{
2665 u32 x=(u32)skb->data;
2666 u32 v;
2667
2668 v=(x+n-1)&~(n-1);
2669
2670 skb_reserve(skb, v-x);
2671}
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709static int dfx_rcv_init(DFX_board_t *bp, int get_buffers)
2710 {
2711 int i, j;
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731 if (get_buffers) {
2732#ifdef DYNAMIC_BUFFERS
2733 for (i = 0; i < (int)(bp->rcv_bufs_to_post); i++)
2734 for (j = 0; (i + j) < (int)PI_RCV_DATA_K_NUM_ENTRIES; j += bp->rcv_bufs_to_post)
2735 {
2736 struct sk_buff *newskb = __dev_alloc_skb(NEW_SKB_SIZE, GFP_NOIO);
2737 if (!newskb)
2738 return -ENOMEM;
2739 bp->descr_block_virt->rcv_data[i+j].long_0 = (u32) (PI_RCV_DESCR_M_SOP |
2740 ((PI_RCV_DATA_K_SIZE_MAX / PI_ALIGN_K_RCV_DATA_BUFF) << PI_RCV_DESCR_V_SEG_LEN));
2741
2742
2743
2744
2745
2746 my_skb_align(newskb, 128);
2747 bp->descr_block_virt->rcv_data[i+j].long_1 = virt_to_bus(newskb->data);
2748
2749
2750
2751
2752 bp->p_rcv_buff_va[i+j] = (char *) newskb;
2753 }
2754#else
2755 for (i=0; i < (int)(bp->rcv_bufs_to_post); i++)
2756 for (j=0; (i + j) < (int)PI_RCV_DATA_K_NUM_ENTRIES; j += bp->rcv_bufs_to_post)
2757 {
2758 bp->descr_block_virt->rcv_data[i+j].long_0 = (u32) (PI_RCV_DESCR_M_SOP |
2759 ((PI_RCV_DATA_K_SIZE_MAX / PI_ALIGN_K_RCV_DATA_BUFF) << PI_RCV_DESCR_V_SEG_LEN));
2760 bp->descr_block_virt->rcv_data[i+j].long_1 = (u32) (bp->rcv_block_phys + (i * PI_RCV_DATA_K_SIZE_MAX));
2761 bp->p_rcv_buff_va[i+j] = (char *) (bp->rcv_block_virt + (i * PI_RCV_DATA_K_SIZE_MAX));
2762 }
2763#endif
2764 }
2765
2766
2767
2768 bp->rcv_xmt_reg.index.rcv_prod = bp->rcv_bufs_to_post;
2769 dfx_port_write_long(bp, PI_PDQ_K_REG_TYPE_2_PROD, bp->rcv_xmt_reg.lword);
2770 return 0;
2771 }
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806static void dfx_rcv_queue_process(
2807 DFX_board_t *bp
2808 )
2809
2810 {
2811 PI_TYPE_2_CONSUMER *p_type_2_cons;
2812 char *p_buff;
2813 u32 descr, pkt_len;
2814 struct sk_buff *skb;
2815
2816
2817
2818 p_type_2_cons = (PI_TYPE_2_CONSUMER *)(&bp->cons_block_virt->xmt_rcv_data);
2819 while (bp->rcv_xmt_reg.index.rcv_comp != p_type_2_cons->index.rcv_cons)
2820 {
2821
2822
2823 int entry;
2824
2825 entry = bp->rcv_xmt_reg.index.rcv_comp;
2826#ifdef DYNAMIC_BUFFERS
2827 p_buff = (char *) (((struct sk_buff *)bp->p_rcv_buff_va[entry])->data);
2828#else
2829 p_buff = (char *) bp->p_rcv_buff_va[entry];
2830#endif
2831 memcpy(&descr, p_buff + RCV_BUFF_K_DESCR, sizeof(u32));
2832
2833 if (descr & PI_FMC_DESCR_M_RCC_FLUSH)
2834 {
2835 if (descr & PI_FMC_DESCR_M_RCC_CRC)
2836 bp->rcv_crc_errors++;
2837 else
2838 bp->rcv_frame_status_errors++;
2839 }
2840 else
2841 {
2842 int rx_in_place = 0;
2843
2844
2845
2846 pkt_len = (u32)((descr & PI_FMC_DESCR_M_LEN) >> PI_FMC_DESCR_V_LEN);
2847 pkt_len -= 4;
2848 if (!IN_RANGE(pkt_len, FDDI_K_LLC_ZLEN, FDDI_K_LLC_LEN))
2849 bp->rcv_length_errors++;
2850 else{
2851#ifdef DYNAMIC_BUFFERS
2852 if (pkt_len > SKBUFF_RX_COPYBREAK) {
2853 struct sk_buff *newskb;
2854
2855 newskb = dev_alloc_skb(NEW_SKB_SIZE);
2856 if (newskb){
2857 rx_in_place = 1;
2858
2859 my_skb_align(newskb, 128);
2860 skb = (struct sk_buff *)bp->p_rcv_buff_va[entry];
2861 skb_reserve(skb, RCV_BUFF_K_PADDING);
2862 bp->p_rcv_buff_va[entry] = (char *)newskb;
2863 bp->descr_block_virt->rcv_data[entry].long_1 = virt_to_bus(newskb->data);
2864 } else
2865 skb = NULL;
2866 } else
2867#endif
2868 skb = dev_alloc_skb(pkt_len+3);
2869 if (skb == NULL)
2870 {
2871 printk("%s: Could not allocate receive buffer. Dropping packet.\n", bp->dev->name);
2872 bp->rcv_discards++;
2873 break;
2874 }
2875 else {
2876#ifndef DYNAMIC_BUFFERS
2877 if (! rx_in_place)
2878#endif
2879 {
2880
2881
2882 memcpy(skb->data, p_buff + RCV_BUFF_K_PADDING, pkt_len+3);
2883 }
2884
2885 skb_reserve(skb,3);
2886 skb_put(skb, pkt_len);
2887 skb->dev = bp->dev;
2888
2889 skb->protocol = fddi_type_trans(skb, bp->dev);
2890 bp->rcv_total_bytes += skb->len;
2891 netif_rx(skb);
2892
2893
2894 bp->dev->last_rx = jiffies;
2895 bp->rcv_total_frames++;
2896 if (*(p_buff + RCV_BUFF_K_DA) & 0x01)
2897 bp->rcv_multicast_frames++;
2898 }
2899 }
2900 }
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910 bp->rcv_xmt_reg.index.rcv_prod += 1;
2911 bp->rcv_xmt_reg.index.rcv_comp += 1;
2912 }
2913 }
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977static int dfx_xmt_queue_pkt(
2978 struct sk_buff *skb,
2979 struct net_device *dev
2980 )
2981
2982 {
2983 DFX_board_t *bp = dev->priv;
2984 u8 prod;
2985 PI_XMT_DESCR *p_xmt_descr;
2986 XMT_DRIVER_DESCR *p_xmt_drv_descr;
2987 unsigned long flags;
2988
2989 netif_stop_queue(dev);
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000 if (!IN_RANGE(skb->len, FDDI_K_LLC_ZLEN, FDDI_K_LLC_LEN))
3001 {
3002 printk("%s: Invalid packet length - %u bytes\n",
3003 dev->name, skb->len);
3004 bp->xmt_length_errors++;
3005 netif_wake_queue(dev);
3006 dev_kfree_skb(skb);
3007 return(0);
3008 }
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021 if (bp->link_available == PI_K_FALSE)
3022 {
3023 if (dfx_hw_adap_state_rd(bp) == PI_STATE_K_LINK_AVAIL)
3024 bp->link_available = PI_K_TRUE;
3025 else
3026 {
3027 bp->xmt_discards++;
3028 dev_kfree_skb(skb);
3029 netif_wake_queue(dev);
3030 return(0);
3031 }
3032 }
3033
3034 spin_lock_irqsave(&bp->lock, flags);
3035
3036
3037
3038 prod = bp->rcv_xmt_reg.index.xmt_prod;
3039 p_xmt_descr = &(bp->descr_block_virt->xmt_data[prod]);
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052 p_xmt_drv_descr = &(bp->xmt_drv_descr_blk[prod++]);
3053
3054
3055
3056 skb_push(skb,3);
3057 skb->data[0] = DFX_PRH0_BYTE;
3058 skb->data[1] = DFX_PRH1_BYTE;
3059 skb->data[2] = DFX_PRH2_BYTE;
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088 p_xmt_descr->long_0 = (u32) (PI_XMT_DESCR_M_SOP | PI_XMT_DESCR_M_EOP | ((skb->len) << PI_XMT_DESCR_V_SEG_LEN));
3089 p_xmt_descr->long_1 = (u32) virt_to_bus(skb->data);
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102 if (prod == bp->rcv_xmt_reg.index.xmt_comp)
3103 {
3104 skb_pull(skb,3);
3105 spin_unlock_irqrestore(&bp->lock, flags);
3106 return(1);
3107 }
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125 p_xmt_drv_descr->p_skb = skb;
3126
3127
3128
3129 bp->rcv_xmt_reg.index.xmt_prod = prod;
3130 dfx_port_write_long(bp, PI_PDQ_K_REG_TYPE_2_PROD, bp->rcv_xmt_reg.lword);
3131 spin_unlock_irqrestore(&bp->lock, flags);
3132 netif_wake_queue(dev);
3133 return(0);
3134 }
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169static int dfx_xmt_done(DFX_board_t *bp)
3170 {
3171 XMT_DRIVER_DESCR *p_xmt_drv_descr;
3172 PI_TYPE_2_CONSUMER *p_type_2_cons;
3173 int freed = 0;
3174
3175
3176
3177 p_type_2_cons = (PI_TYPE_2_CONSUMER *)(&bp->cons_block_virt->xmt_rcv_data);
3178 while (bp->rcv_xmt_reg.index.xmt_comp != p_type_2_cons->index.xmt_cons)
3179 {
3180
3181
3182 p_xmt_drv_descr = &(bp->xmt_drv_descr_blk[bp->rcv_xmt_reg.index.xmt_comp]);
3183
3184
3185
3186 bp->xmt_total_frames++;
3187 bp->xmt_total_bytes += p_xmt_drv_descr->p_skb->len;
3188
3189
3190
3191 dev_kfree_skb_irq(p_xmt_drv_descr->p_skb);
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204 bp->rcv_xmt_reg.index.xmt_comp += 1;
3205 freed++;
3206 }
3207 return freed;
3208 }
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237#ifdef DYNAMIC_BUFFERS
3238static void dfx_rcv_flush( DFX_board_t *bp )
3239 {
3240 int i, j;
3241
3242 for (i = 0; i < (int)(bp->rcv_bufs_to_post); i++)
3243 for (j = 0; (i + j) < (int)PI_RCV_DATA_K_NUM_ENTRIES; j += bp->rcv_bufs_to_post)
3244 {
3245 struct sk_buff *skb;
3246 skb = (struct sk_buff *)bp->p_rcv_buff_va[i+j];
3247 if (skb)
3248 dev_kfree_skb(skb);
3249 bp->p_rcv_buff_va[i+j] = NULL;
3250 }
3251
3252 }
3253#else
3254static inline void dfx_rcv_flush( DFX_board_t *bp )
3255{
3256}
3257#endif
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295static void dfx_xmt_flush( DFX_board_t *bp )
3296 {
3297 u32 prod_cons;
3298 XMT_DRIVER_DESCR *p_xmt_drv_descr;
3299
3300
3301
3302 while (bp->rcv_xmt_reg.index.xmt_comp != bp->rcv_xmt_reg.index.xmt_prod)
3303 {
3304
3305
3306 p_xmt_drv_descr = &(bp->xmt_drv_descr_blk[bp->rcv_xmt_reg.index.xmt_comp]);
3307
3308
3309
3310 dev_kfree_skb(p_xmt_drv_descr->p_skb);
3311
3312
3313
3314 bp->xmt_discards++;
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327 bp->rcv_xmt_reg.index.xmt_comp += 1;
3328 }
3329
3330
3331
3332 prod_cons = (u32)(bp->cons_block_virt->xmt_rcv_data & ~PI_CONS_M_XMT_INDEX);
3333 prod_cons |= (u32)(bp->rcv_xmt_reg.index.xmt_prod << PI_CONS_V_XMT_INDEX);
3334 bp->cons_block_virt->xmt_rcv_data = prod_cons;
3335 }
3336
3337static void __devexit dfx_remove_one_pci_or_eisa(struct pci_dev *pdev, struct net_device *dev)
3338{
3339 DFX_board_t *bp = dev->priv;
3340
3341 unregister_netdev(dev);
3342 release_region(dev->base_addr, pdev ? PFI_K_CSR_IO_LEN : PI_ESIC_K_CSR_IO_LEN );
3343 if (bp->kmalloced) kfree(bp->kmalloced);
3344 kfree(dev);
3345}
3346
3347static void __devexit dfx_remove_one (struct pci_dev *pdev)
3348{
3349 struct net_device *dev = pci_get_drvdata(pdev);
3350
3351 dfx_remove_one_pci_or_eisa(pdev, dev);
3352 pci_set_drvdata(pdev, NULL);
3353}
3354
3355static struct pci_device_id dfx_pci_tbl[] __devinitdata = {
3356 { PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_FDDI, PCI_ANY_ID, PCI_ANY_ID, },
3357 { 0, }
3358};
3359MODULE_DEVICE_TABLE(pci, dfx_pci_tbl);
3360
3361static struct pci_driver dfx_driver = {
3362 .name = "defxx",
3363 .probe = dfx_init_one,
3364 .remove = __devexit_p(dfx_remove_one),
3365 .id_table = dfx_pci_tbl,
3366};
3367
3368static int dfx_have_pci;
3369static int dfx_have_eisa;
3370
3371
3372static void __exit dfx_eisa_cleanup(void)
3373{
3374 struct net_device *dev = root_dfx_eisa_dev;
3375
3376 while (dev)
3377 {
3378 struct net_device *tmp;
3379 DFX_board_t *bp;
3380
3381 bp = (DFX_board_t*)dev->priv;
3382 tmp = bp->next;
3383 dfx_remove_one_pci_or_eisa(NULL, dev);
3384 dev = tmp;
3385 }
3386}
3387
3388static int __init dfx_init(void)
3389{
3390 int rc_pci, rc_eisa;
3391
3392
3393#ifdef MODULE
3394 printk(version);
3395#endif
3396
3397 rc_pci = pci_module_init(&dfx_driver);
3398 if (rc_pci >= 0) dfx_have_pci = 1;
3399
3400 rc_eisa = dfx_eisa_init();
3401 if (rc_eisa >= 0) dfx_have_eisa = 1;
3402
3403 return ((rc_eisa < 0) ? 0 : rc_eisa) + ((rc_pci < 0) ? 0 : rc_pci);
3404}
3405
3406static void __exit dfx_cleanup(void)
3407{
3408 if (dfx_have_pci)
3409 pci_unregister_driver(&dfx_driver);
3410 if (dfx_have_eisa)
3411 dfx_eisa_cleanup();
3412
3413}
3414
3415module_init(dfx_init);
3416module_exit(dfx_cleanup);
3417MODULE_LICENSE("GPL");
3418
3419
3420
3421
3422
3423
3424
3425