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#include <linux/module.h>
198#include <linux/kernel.h>
199#include <linux/string.h>
200#include <linux/errno.h>
201#include <linux/ioport.h>
202#include <linux/slab.h>
203#include <linux/interrupt.h>
204#include <linux/pci.h>
205#include <linux/delay.h>
206#include <linux/init.h>
207#include <linux/netdevice.h>
208#include <linux/fddidevice.h>
209#include <linux/skbuff.h>
210
211#include <asm/byteorder.h>
212#include <asm/bitops.h>
213#include <asm/io.h>
214
215#include "defxx.h"
216
217
218
219static char version[] __devinitdata =
220 "defxx.c:v1.06 2003/08/04 Lawrence V. Stefani and others\n";
221
222#define DYNAMIC_BUFFERS 1
223
224#define SKBUFF_RX_COPYBREAK 200
225
226
227
228
229#define NEW_SKB_SIZE (PI_RCV_DATA_K_SIZE_MAX+128)
230
231
232
233static void dfx_bus_init(struct net_device *dev);
234static void dfx_bus_config_check(DFX_board_t *bp);
235
236static int dfx_driver_init(struct net_device *dev);
237static int dfx_adap_init(DFX_board_t *bp, int get_buffers);
238
239static int dfx_open(struct net_device *dev);
240static int dfx_close(struct net_device *dev);
241
242static void dfx_int_pr_halt_id(DFX_board_t *bp);
243static void dfx_int_type_0_process(DFX_board_t *bp);
244static void dfx_int_common(struct net_device *dev);
245static void dfx_interrupt(int irq, void *dev_id, struct pt_regs *regs);
246
247static struct net_device_stats *dfx_ctl_get_stats(struct net_device *dev);
248static void dfx_ctl_set_multicast_list(struct net_device *dev);
249static int dfx_ctl_set_mac_address(struct net_device *dev, void *addr);
250static int dfx_ctl_update_cam(DFX_board_t *bp);
251static int dfx_ctl_update_filters(DFX_board_t *bp);
252
253static int dfx_hw_dma_cmd_req(DFX_board_t *bp);
254static 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);
255static void dfx_hw_adap_reset(DFX_board_t *bp, PI_UINT32 type);
256static int dfx_hw_adap_state_rd(DFX_board_t *bp);
257static int dfx_hw_dma_uninit(DFX_board_t *bp, PI_UINT32 type);
258
259static int dfx_rcv_init(DFX_board_t *bp, int get_buffers);
260static void dfx_rcv_queue_process(DFX_board_t *bp);
261static void dfx_rcv_flush(DFX_board_t *bp);
262
263static int dfx_xmt_queue_pkt(struct sk_buff *skb, struct net_device *dev);
264static int dfx_xmt_done(DFX_board_t *bp);
265static void dfx_xmt_flush(DFX_board_t *bp);
266
267
268
269static struct net_device *root_dfx_eisa_dev;
270
271
272
273
274
275
276
277
278
279
280
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
325static inline void dfx_port_write_byte(
326 DFX_board_t *bp,
327 int offset,
328 u8 data
329 )
330
331 {
332 u16 port = bp->base_addr + offset;
333
334 outb(data, port);
335 }
336
337static inline void dfx_port_read_byte(
338 DFX_board_t *bp,
339 int offset,
340 u8 *data
341 )
342
343 {
344 u16 port = bp->base_addr + offset;
345
346 *data = inb(port);
347 }
348
349static inline void dfx_port_write_long(
350 DFX_board_t *bp,
351 int offset,
352 u32 data
353 )
354
355 {
356 u16 port = bp->base_addr + offset;
357
358 outl(data, port);
359 }
360
361static inline void dfx_port_read_long(
362 DFX_board_t *bp,
363 int offset,
364 u32 *data
365 )
366
367 {
368 u16 port = bp->base_addr + offset;
369
370 *data = inl(port);
371 }
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403static int __devinit dfx_init_one_pci_or_eisa(struct pci_dev *pdev, long ioaddr)
404{
405 struct net_device *dev;
406 DFX_board_t *bp;
407 int alloc_size;
408 int err;
409
410#ifndef MODULE
411 static int version_disp;
412
413 if (!version_disp)
414 {
415 version_disp = 1;
416 printk(version);
417 }
418#endif
419
420 dev = alloc_fddidev(sizeof(*bp));
421 if (!dev) {
422 printk (KERN_ERR "defxx: unable to allocate fddidev, aborting\n");
423 return -ENOMEM;
424 }
425
426
427 if (pdev != NULL) {
428 err = pci_enable_device (pdev);
429 if (err) goto err_out;
430 ioaddr = pci_resource_start (pdev, 1);
431 }
432
433 SET_MODULE_OWNER(dev);
434 SET_NETDEV_DEV(dev, &pdev->dev);
435
436 bp = dev->priv;
437
438 if (!request_region (ioaddr, pdev ? PFI_K_CSR_IO_LEN : PI_ESIC_K_CSR_IO_LEN, dev->name)) {
439 printk (KERN_ERR "%s: Cannot reserve I/O resource 0x%x @ 0x%lx, aborting\n",
440 dev->name, PFI_K_CSR_IO_LEN, ioaddr);
441 err = -EBUSY;
442 goto err_out;
443 }
444
445
446
447 dev->base_addr = ioaddr;
448
449 dev->get_stats = dfx_ctl_get_stats;
450 dev->open = dfx_open;
451 dev->stop = dfx_close;
452 dev->hard_start_xmit = dfx_xmt_queue_pkt;
453 dev->set_multicast_list = dfx_ctl_set_multicast_list;
454 dev->set_mac_address = dfx_ctl_set_mac_address;
455
456 if (pdev == NULL) {
457
458 bp->bus_type = DFX_BUS_TYPE_EISA;
459 bp->next = root_dfx_eisa_dev;
460 root_dfx_eisa_dev = dev;
461 } else {
462
463 bp->bus_type = DFX_BUS_TYPE_PCI;
464 bp->pci_dev = pdev;
465 pci_set_drvdata (pdev, dev);
466 pci_set_master (pdev);
467 }
468
469 if (dfx_driver_init(dev) != DFX_K_SUCCESS) {
470 err = -ENODEV;
471 goto err_out_region;
472 }
473
474 err = register_netdev(dev);
475 if (err)
476 goto err_out_kfree;
477
478 return 0;
479
480err_out_kfree:
481 alloc_size = sizeof(PI_DESCR_BLOCK) +
482 PI_CMD_REQ_K_SIZE_MAX + PI_CMD_RSP_K_SIZE_MAX +
483#ifndef DYNAMIC_BUFFERS
484 (bp->rcv_bufs_to_post * PI_RCV_DATA_K_SIZE_MAX) +
485#endif
486 sizeof(PI_CONSUMER_BLOCK) +
487 (PI_ALIGN_K_DESC_BLK - 1);
488 if (bp->kmalloced)
489 pci_free_consistent(pdev, alloc_size,
490 bp->kmalloced, bp->kmalloced_dma);
491err_out_region:
492 release_region(ioaddr, pdev ? PFI_K_CSR_IO_LEN : PI_ESIC_K_CSR_IO_LEN);
493err_out:
494 kfree(dev);
495 return err;
496}
497
498static int __devinit dfx_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
499{
500 return dfx_init_one_pci_or_eisa(pdev, 0);
501}
502
503static int __init dfx_eisa_init(void)
504{
505 int rc = -ENODEV;
506 int i;
507 u16 port;
508 u32 slot_id;
509
510 DBG_printk("In dfx_eisa_init...\n");
511
512
513
514 for (i=0; i < DFX_MAX_EISA_SLOTS; i++)
515 {
516 port = (i << 12) + PI_ESIC_K_SLOT_ID;
517 slot_id = inl(port);
518 if ((slot_id & 0xF0FFFFFF) == DEFEA_PRODUCT_ID)
519 {
520 port = (i << 12);
521
522 if (dfx_init_one_pci_or_eisa(NULL, port) == 0) rc = 0;
523 }
524 }
525 return rc;
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
558
559static void __devinit dfx_bus_init(struct net_device *dev)
560{
561 DFX_board_t *bp = dev->priv;
562 u8 val;
563
564 DBG_printk("In dfx_bus_init...\n");
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581 bp->base_addr = dev->base_addr;
582
583
584 bp->dev = dev;
585
586
587
588 if (bp->bus_type == DFX_BUS_TYPE_EISA)
589 {
590
591
592 dfx_port_read_byte(bp, PI_ESIC_K_IO_CONFIG_STAT_0, &val);
593 switch ((val & PI_CONFIG_STAT_0_M_IRQ) >> PI_CONFIG_STAT_0_V_IRQ)
594 {
595 case PI_CONFIG_STAT_0_IRQ_K_9:
596 dev->irq = 9;
597 break;
598
599 case PI_CONFIG_STAT_0_IRQ_K_10:
600 dev->irq = 10;
601 break;
602
603 case PI_CONFIG_STAT_0_IRQ_K_11:
604 dev->irq = 11;
605 break;
606
607 case PI_CONFIG_STAT_0_IRQ_K_15:
608 dev->irq = 15;
609 break;
610 }
611
612
613
614 dfx_port_write_byte(bp, PI_ESIC_K_FUNCTION_CNTRL, PI_ESIC_K_FUNCTION_CNTRL_IO_ENB);
615
616
617
618 val = ((dev->base_addr >> 12) << PI_IO_CMP_V_SLOT);
619 dfx_port_write_byte(bp, PI_ESIC_K_IO_CMP_0_1, val);
620 dfx_port_write_byte(bp, PI_ESIC_K_IO_CMP_1_1, val);
621
622
623
624 dfx_port_write_byte(bp, PI_ESIC_K_SLOT_CNTRL, PI_SLOT_CNTRL_M_ENB);
625
626
627
628
629
630
631 dfx_port_read_byte(bp, PI_ESIC_K_BURST_HOLDOFF, &val);
632 dfx_port_write_byte(bp, PI_ESIC_K_BURST_HOLDOFF, (val & ~PI_BURST_HOLDOFF_M_MEM_MAP));
633
634
635
636 dfx_port_read_byte(bp, PI_ESIC_K_IO_CONFIG_STAT_0, &val);
637 dfx_port_write_byte(bp, PI_ESIC_K_IO_CONFIG_STAT_0, (val | PI_CONFIG_STAT_0_M_INT_ENB));
638 }
639 else
640 {
641 struct pci_dev *pdev = bp->pci_dev;
642
643
644
645 dev->irq = pdev->irq;
646
647
648
649 pci_read_config_byte(pdev, PCI_LATENCY_TIMER, &val);
650 if (val < PFI_K_LAT_TIMER_MIN)
651 {
652 val = PFI_K_LAT_TIMER_DEF;
653 pci_write_config_byte(pdev, PCI_LATENCY_TIMER, val);
654 }
655
656
657
658 dfx_port_write_long(bp, PFI_K_REG_MODE_CTRL, (PFI_MODE_M_PDQ_INT_ENB | PFI_MODE_M_DMA_ENB));
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
692
693static void __devinit dfx_bus_config_check(DFX_board_t *bp)
694{
695 int status;
696 u32 slot_id;
697 u32 host_data;
698
699 DBG_printk("In dfx_bus_config_check...\n");
700
701
702
703 if (bp->bus_type == DFX_BUS_TYPE_EISA)
704 {
705 dfx_port_read_long(bp, PI_ESIC_K_SLOT_ID, &slot_id);
706
707
708
709
710
711
712
713
714
715 if (slot_id == DEFEA_PROD_ID_2)
716 {
717
718
719
720
721
722 status = dfx_hw_port_ctrl_req(bp,
723 PI_PCTRL_M_SUB_CMD,
724 PI_SUB_CMD_K_PDQ_REV_GET,
725 0,
726 &host_data);
727 if ((status != DFX_K_SUCCESS) || (host_data == 2))
728 {
729
730
731
732
733
734
735
736
737 switch (bp->burst_size)
738 {
739 case PI_PDATA_B_DMA_BURST_SIZE_32:
740 case PI_PDATA_B_DMA_BURST_SIZE_16:
741 bp->burst_size = PI_PDATA_B_DMA_BURST_SIZE_8;
742 break;
743
744 default:
745 break;
746 }
747
748
749
750 bp->full_duplex_enb = PI_SNMP_K_FALSE;
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
792
793static int __devinit dfx_driver_init(struct net_device *dev)
794{
795 DFX_board_t *bp = dev->priv;
796 int alloc_size;
797 char *top_v, *curr_v;
798 dma_addr_t top_p, curr_p;
799 u32 data;
800
801 DBG_printk("In dfx_driver_init...\n");
802
803
804
805 dfx_bus_init(dev);
806
807
808
809
810
811
812
813
814
815
816 bp->full_duplex_enb = PI_SNMP_K_FALSE;
817 bp->req_ttrt = 8 * 12500;
818 bp->burst_size = PI_PDATA_B_DMA_BURST_SIZE_DEF;
819 bp->rcv_bufs_to_post = RCV_BUFS_DEF;
820
821
822
823
824
825
826
827
828
829
830 dfx_bus_config_check(bp);
831
832
833
834 dfx_port_write_long(bp, PI_PDQ_K_REG_HOST_INT_ENB, PI_HOST_INT_K_DISABLE_ALL_INTS);
835
836
837
838 (void) dfx_hw_dma_uninit(bp, PI_PDATA_A_RESET_M_SKIP_ST);
839
840
841
842 if (dfx_hw_port_ctrl_req(bp,
843 PI_PCTRL_M_MLA,
844 PI_PDATA_A_MLA_K_LO,
845 0,
846 &data) != DFX_K_SUCCESS)
847 {
848 printk("%s: Could not read adapter factory MAC address!\n", dev->name);
849 return(DFX_K_FAILURE);
850 }
851 memcpy(&bp->factory_mac_addr[0], &data, sizeof(u32));
852
853 if (dfx_hw_port_ctrl_req(bp,
854 PI_PCTRL_M_MLA,
855 PI_PDATA_A_MLA_K_HI,
856 0,
857 &data) != DFX_K_SUCCESS)
858 {
859 printk("%s: Could not read adapter factory MAC address!\n", dev->name);
860 return(DFX_K_FAILURE);
861 }
862 memcpy(&bp->factory_mac_addr[4], &data, sizeof(u16));
863
864
865
866
867
868
869
870
871 memcpy(dev->dev_addr, bp->factory_mac_addr, FDDI_K_ALEN);
872 if (bp->bus_type == DFX_BUS_TYPE_EISA)
873 printk("%s: DEFEA at I/O addr = 0x%lX, IRQ = %d, Hardware addr = %02X-%02X-%02X-%02X-%02X-%02X\n",
874 dev->name,
875 dev->base_addr,
876 dev->irq,
877 dev->dev_addr[0],
878 dev->dev_addr[1],
879 dev->dev_addr[2],
880 dev->dev_addr[3],
881 dev->dev_addr[4],
882 dev->dev_addr[5]);
883 else
884 printk("%s: DEFPA at I/O addr = 0x%lX, IRQ = %d, Hardware addr = %02X-%02X-%02X-%02X-%02X-%02X\n",
885 dev->name,
886 dev->base_addr,
887 dev->irq,
888 dev->dev_addr[0],
889 dev->dev_addr[1],
890 dev->dev_addr[2],
891 dev->dev_addr[3],
892 dev->dev_addr[4],
893 dev->dev_addr[5]);
894
895
896
897
898
899
900 alloc_size = sizeof(PI_DESCR_BLOCK) +
901 PI_CMD_REQ_K_SIZE_MAX +
902 PI_CMD_RSP_K_SIZE_MAX +
903#ifndef DYNAMIC_BUFFERS
904 (bp->rcv_bufs_to_post * PI_RCV_DATA_K_SIZE_MAX) +
905#endif
906 sizeof(PI_CONSUMER_BLOCK) +
907 (PI_ALIGN_K_DESC_BLK - 1);
908 bp->kmalloced = top_v = pci_alloc_consistent(bp->pci_dev, alloc_size,
909 &bp->kmalloced_dma);
910 if (top_v == NULL)
911 {
912 printk("%s: Could not allocate memory for host buffers and structures!\n", dev->name);
913 return(DFX_K_FAILURE);
914 }
915 memset(top_v, 0, alloc_size);
916 top_p = bp->kmalloced_dma;
917
918
919
920
921
922
923
924
925
926
927
928
929
930 curr_p = ALIGN(top_p, PI_ALIGN_K_DESC_BLK);
931 curr_v = top_v + (curr_p - top_p);
932
933
934
935 bp->descr_block_virt = (PI_DESCR_BLOCK *) curr_v;
936 bp->descr_block_phys = curr_p;
937 curr_v += sizeof(PI_DESCR_BLOCK);
938 curr_p += sizeof(PI_DESCR_BLOCK);
939
940
941
942 bp->cmd_req_virt = (PI_DMA_CMD_REQ *) curr_v;
943 bp->cmd_req_phys = curr_p;
944 curr_v += PI_CMD_REQ_K_SIZE_MAX;
945 curr_p += PI_CMD_REQ_K_SIZE_MAX;
946
947
948
949 bp->cmd_rsp_virt = (PI_DMA_CMD_RSP *) curr_v;
950 bp->cmd_rsp_phys = curr_p;
951 curr_v += PI_CMD_RSP_K_SIZE_MAX;
952 curr_p += PI_CMD_RSP_K_SIZE_MAX;
953
954
955
956 bp->rcv_block_virt = curr_v;
957 bp->rcv_block_phys = curr_p;
958
959#ifndef DYNAMIC_BUFFERS
960 curr_v += (bp->rcv_bufs_to_post * PI_RCV_DATA_K_SIZE_MAX);
961 curr_p += (bp->rcv_bufs_to_post * PI_RCV_DATA_K_SIZE_MAX);
962#endif
963
964
965
966 bp->cons_block_virt = (PI_CONSUMER_BLOCK *) curr_v;
967 bp->cons_block_phys = curr_p;
968
969
970
971 DBG_printk("%s: Descriptor block virt = %0lX, phys = %0X\n", dev->name, (long)bp->descr_block_virt, bp->descr_block_phys);
972 DBG_printk("%s: Command Request buffer virt = %0lX, phys = %0X\n", dev->name, (long)bp->cmd_req_virt, bp->cmd_req_phys);
973 DBG_printk("%s: Command Response buffer virt = %0lX, phys = %0X\n", dev->name, (long)bp->cmd_rsp_virt, bp->cmd_rsp_phys);
974 DBG_printk("%s: Receive buffer block virt = %0lX, phys = %0X\n", dev->name, (long)bp->rcv_block_virt, bp->rcv_block_phys);
975 DBG_printk("%s: Consumer block virt = %0lX, phys = %0X\n", dev->name, (long)bp->cons_block_virt, bp->cons_block_phys);
976
977 return(DFX_K_SUCCESS);
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
1012
1013
1014static int dfx_adap_init(DFX_board_t *bp, int get_buffers)
1015 {
1016 DBG_printk("In dfx_adap_init...\n");
1017
1018
1019
1020 dfx_port_write_long(bp, PI_PDQ_K_REG_HOST_INT_ENB, PI_HOST_INT_K_DISABLE_ALL_INTS);
1021
1022
1023
1024 if (dfx_hw_dma_uninit(bp, bp->reset_type) != DFX_K_SUCCESS)
1025 {
1026 printk("%s: Could not uninitialize/reset adapter!\n", bp->dev->name);
1027 return(DFX_K_FAILURE);
1028 }
1029
1030
1031
1032
1033
1034
1035 dfx_port_write_long(bp, PI_PDQ_K_REG_TYPE_0_STATUS, PI_HOST_INT_K_ACK_ALL_TYPE_0);
1036
1037
1038
1039
1040
1041
1042
1043
1044 bp->cmd_req_reg.lword = 0;
1045 bp->cmd_rsp_reg.lword = 0;
1046 bp->rcv_xmt_reg.lword = 0;
1047
1048
1049
1050 memset(bp->cons_block_virt, 0, sizeof(PI_CONSUMER_BLOCK));
1051
1052
1053
1054 if (dfx_hw_port_ctrl_req(bp,
1055 PI_PCTRL_M_SUB_CMD,
1056 PI_SUB_CMD_K_BURST_SIZE_SET,
1057 bp->burst_size,
1058 NULL) != DFX_K_SUCCESS)
1059 {
1060 printk("%s: Could not set adapter burst size!\n", bp->dev->name);
1061 return(DFX_K_FAILURE);
1062 }
1063
1064
1065
1066
1067
1068
1069
1070
1071 if (dfx_hw_port_ctrl_req(bp,
1072 PI_PCTRL_M_CONS_BLOCK,
1073 bp->cons_block_phys,
1074 0,
1075 NULL) != DFX_K_SUCCESS)
1076 {
1077 printk("%s: Could not set consumer block address!\n", bp->dev->name);
1078 return(DFX_K_FAILURE);
1079 }
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094 if (dfx_hw_port_ctrl_req(bp,
1095 PI_PCTRL_M_INIT,
1096 (u32) (bp->descr_block_phys | PI_PDATA_A_INIT_M_BSWAP_DATA),
1097 0,
1098 NULL) != DFX_K_SUCCESS)
1099 {
1100 printk("%s: Could not set descriptor block address!\n", bp->dev->name);
1101 return(DFX_K_FAILURE);
1102 }
1103
1104
1105
1106 bp->cmd_req_virt->cmd_type = PI_CMD_K_CHARS_SET;
1107 bp->cmd_req_virt->char_set.item[0].item_code = PI_ITEM_K_FLUSH_TIME;
1108 bp->cmd_req_virt->char_set.item[0].value = 3;
1109 bp->cmd_req_virt->char_set.item[0].item_index = 0;
1110 bp->cmd_req_virt->char_set.item[1].item_code = PI_ITEM_K_EOL;
1111 if (dfx_hw_dma_cmd_req(bp) != DFX_K_SUCCESS)
1112 {
1113 printk("%s: DMA command request failed!\n", bp->dev->name);
1114 return(DFX_K_FAILURE);
1115 }
1116
1117
1118
1119 bp->cmd_req_virt->cmd_type = PI_CMD_K_SNMP_SET;
1120 bp->cmd_req_virt->snmp_set.item[0].item_code = PI_ITEM_K_FDX_ENB_DIS;
1121 bp->cmd_req_virt->snmp_set.item[0].value = bp->full_duplex_enb;
1122 bp->cmd_req_virt->snmp_set.item[0].item_index = 0;
1123 bp->cmd_req_virt->snmp_set.item[1].item_code = PI_ITEM_K_MAC_T_REQ;
1124 bp->cmd_req_virt->snmp_set.item[1].value = bp->req_ttrt;
1125 bp->cmd_req_virt->snmp_set.item[1].item_index = 0;
1126 bp->cmd_req_virt->snmp_set.item[2].item_code = PI_ITEM_K_EOL;
1127 if (dfx_hw_dma_cmd_req(bp) != DFX_K_SUCCESS)
1128 {
1129 printk("%s: DMA command request failed!\n", bp->dev->name);
1130 return(DFX_K_FAILURE);
1131 }
1132
1133
1134
1135 if (dfx_ctl_update_cam(bp) != DFX_K_SUCCESS)
1136 {
1137 printk("%s: Adapter CAM update failed!\n", bp->dev->name);
1138 return(DFX_K_FAILURE);
1139 }
1140
1141
1142
1143 if (dfx_ctl_update_filters(bp) != DFX_K_SUCCESS)
1144 {
1145 printk("%s: Adapter filters update failed!\n", bp->dev->name);
1146 return(DFX_K_FAILURE);
1147 }
1148
1149
1150
1151
1152
1153
1154 if (get_buffers)
1155 dfx_rcv_flush(bp);
1156
1157
1158
1159 if (dfx_rcv_init(bp, get_buffers))
1160 {
1161 printk("%s: Receive buffer allocation failed\n", bp->dev->name);
1162 if (get_buffers)
1163 dfx_rcv_flush(bp);
1164 return(DFX_K_FAILURE);
1165 }
1166
1167
1168
1169 bp->cmd_req_virt->cmd_type = PI_CMD_K_START;
1170 if (dfx_hw_dma_cmd_req(bp) != DFX_K_SUCCESS)
1171 {
1172 printk("%s: Start command failed\n", bp->dev->name);
1173 if (get_buffers)
1174 dfx_rcv_flush(bp);
1175 return(DFX_K_FAILURE);
1176 }
1177
1178
1179
1180 dfx_port_write_long(bp, PI_PDQ_K_REG_HOST_INT_ENB, PI_HOST_INT_K_ENABLE_DEF_INTS);
1181 return(DFX_K_SUCCESS);
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
1213
1214
1215static int dfx_open(struct net_device *dev)
1216{
1217 int ret;
1218 DFX_board_t *bp = dev->priv;
1219
1220 DBG_printk("In dfx_open...\n");
1221
1222
1223
1224 ret = request_irq(dev->irq, (void *)dfx_interrupt, SA_SHIRQ, dev->name, dev);
1225 if (ret) {
1226 printk(KERN_ERR "%s: Requested IRQ %d is busy\n", dev->name, dev->irq);
1227 return ret;
1228 }
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241 memcpy(dev->dev_addr, bp->factory_mac_addr, FDDI_K_ALEN);
1242
1243
1244
1245 memset(bp->uc_table, 0, sizeof(bp->uc_table));
1246 memset(bp->mc_table, 0, sizeof(bp->mc_table));
1247 bp->uc_count = 0;
1248 bp->mc_count = 0;
1249
1250
1251
1252 bp->ind_group_prom = PI_FSTATE_K_BLOCK;
1253 bp->group_prom = PI_FSTATE_K_BLOCK;
1254
1255 spin_lock_init(&bp->lock);
1256
1257
1258
1259 bp->reset_type = PI_PDATA_A_RESET_M_SKIP_ST;
1260 if (dfx_adap_init(bp, 1) != DFX_K_SUCCESS)
1261 {
1262 printk(KERN_ERR "%s: Adapter open failed!\n", dev->name);
1263 free_irq(dev->irq, dev);
1264 return -EAGAIN;
1265 }
1266
1267
1268 netif_start_queue(dev);
1269 return(0);
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
1303
1304
1305static int dfx_close(struct net_device *dev)
1306{
1307 DFX_board_t *bp = dev->priv;
1308
1309 DBG_printk("In dfx_close...\n");
1310
1311
1312
1313 dfx_port_write_long(bp, PI_PDQ_K_REG_HOST_INT_ENB, PI_HOST_INT_K_DISABLE_ALL_INTS);
1314
1315
1316
1317 (void) dfx_hw_dma_uninit(bp, PI_PDATA_A_RESET_M_SKIP_ST);
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328 dfx_xmt_flush(bp);
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341 bp->cmd_req_reg.lword = 0;
1342 bp->cmd_rsp_reg.lword = 0;
1343 bp->rcv_xmt_reg.lword = 0;
1344
1345
1346
1347 memset(bp->cons_block_virt, 0, sizeof(PI_CONSUMER_BLOCK));
1348
1349
1350
1351 dfx_rcv_flush(bp);
1352
1353
1354
1355 netif_stop_queue(dev);
1356
1357
1358
1359 free_irq(dev->irq, dev);
1360
1361 return(0);
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
1390
1391
1392static void dfx_int_pr_halt_id(DFX_board_t *bp)
1393 {
1394 PI_UINT32 port_status;
1395 PI_UINT32 halt_id;
1396
1397
1398
1399 dfx_port_read_long(bp, PI_PDQ_K_REG_PORT_STATUS, &port_status);
1400
1401
1402
1403 halt_id = (port_status & PI_PSTATUS_M_HALT_ID) >> PI_PSTATUS_V_HALT_ID;
1404 switch (halt_id)
1405 {
1406 case PI_HALT_ID_K_SELFTEST_TIMEOUT:
1407 printk("%s: Halt ID: Selftest Timeout\n", bp->dev->name);
1408 break;
1409
1410 case PI_HALT_ID_K_PARITY_ERROR:
1411 printk("%s: Halt ID: Host Bus Parity Error\n", bp->dev->name);
1412 break;
1413
1414 case PI_HALT_ID_K_HOST_DIR_HALT:
1415 printk("%s: Halt ID: Host-Directed Halt\n", bp->dev->name);
1416 break;
1417
1418 case PI_HALT_ID_K_SW_FAULT:
1419 printk("%s: Halt ID: Adapter Software Fault\n", bp->dev->name);
1420 break;
1421
1422 case PI_HALT_ID_K_HW_FAULT:
1423 printk("%s: Halt ID: Adapter Hardware Fault\n", bp->dev->name);
1424 break;
1425
1426 case PI_HALT_ID_K_PC_TRACE:
1427 printk("%s: Halt ID: FDDI Network PC Trace Path Test\n", bp->dev->name);
1428 break;
1429
1430 case PI_HALT_ID_K_DMA_ERROR:
1431 printk("%s: Halt ID: Adapter DMA Error\n", bp->dev->name);
1432 break;
1433
1434 case PI_HALT_ID_K_IMAGE_CRC_ERROR:
1435 printk("%s: Halt ID: Firmware Image CRC Error\n", bp->dev->name);
1436 break;
1437
1438 case PI_HALT_ID_K_BUS_EXCEPTION:
1439 printk("%s: Halt ID: 68000 Bus Exception\n", bp->dev->name);
1440 break;
1441
1442 default:
1443 printk("%s: Halt ID: Unknown (code = %X)\n", bp->dev->name, halt_id);
1444 break;
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
1494
1495
1496static void dfx_int_type_0_process(DFX_board_t *bp)
1497
1498 {
1499 PI_UINT32 type_0_status;
1500 PI_UINT32 state;
1501
1502
1503
1504
1505
1506
1507
1508 dfx_port_read_long(bp, PI_PDQ_K_REG_TYPE_0_STATUS, &type_0_status);
1509 dfx_port_write_long(bp, PI_PDQ_K_REG_TYPE_0_STATUS, type_0_status);
1510
1511
1512
1513 if (type_0_status & (PI_TYPE_0_STAT_M_NXM |
1514 PI_TYPE_0_STAT_M_PM_PAR_ERR |
1515 PI_TYPE_0_STAT_M_BUS_PAR_ERR))
1516 {
1517
1518
1519 if (type_0_status & PI_TYPE_0_STAT_M_NXM)
1520 printk("%s: Non-Existent Memory Access Error\n", bp->dev->name);
1521
1522
1523
1524 if (type_0_status & PI_TYPE_0_STAT_M_PM_PAR_ERR)
1525 printk("%s: Packet Memory Parity Error\n", bp->dev->name);
1526
1527
1528
1529 if (type_0_status & PI_TYPE_0_STAT_M_BUS_PAR_ERR)
1530 printk("%s: Host Bus Parity Error\n", bp->dev->name);
1531
1532
1533
1534 bp->link_available = PI_K_FALSE;
1535 bp->reset_type = 0;
1536 printk("%s: Resetting adapter...\n", bp->dev->name);
1537 if (dfx_adap_init(bp, 0) != DFX_K_SUCCESS)
1538 {
1539 printk("%s: Adapter reset failed! Disabling adapter interrupts.\n", bp->dev->name);
1540 dfx_port_write_long(bp, PI_PDQ_K_REG_HOST_INT_ENB, PI_HOST_INT_K_DISABLE_ALL_INTS);
1541 return;
1542 }
1543 printk("%s: Adapter reset successful!\n", bp->dev->name);
1544 return;
1545 }
1546
1547
1548
1549 if (type_0_status & PI_TYPE_0_STAT_M_XMT_FLUSH)
1550 {
1551
1552
1553 bp->link_available = PI_K_FALSE;
1554 dfx_xmt_flush(bp);
1555 (void) dfx_hw_port_ctrl_req(bp,
1556 PI_PCTRL_M_XMT_DATA_FLUSH_DONE,
1557 0,
1558 0,
1559 NULL);
1560 }
1561
1562
1563
1564 if (type_0_status & PI_TYPE_0_STAT_M_STATE_CHANGE)
1565 {
1566
1567
1568 state = dfx_hw_adap_state_rd(bp);
1569 if (state == PI_STATE_K_HALTED)
1570 {
1571
1572
1573
1574
1575
1576
1577 printk("%s: Controller has transitioned to HALTED state!\n", bp->dev->name);
1578 dfx_int_pr_halt_id(bp);
1579
1580
1581
1582 bp->link_available = PI_K_FALSE;
1583 bp->reset_type = 0;
1584 printk("%s: Resetting adapter...\n", bp->dev->name);
1585 if (dfx_adap_init(bp, 0) != DFX_K_SUCCESS)
1586 {
1587 printk("%s: Adapter reset failed! Disabling adapter interrupts.\n", bp->dev->name);
1588 dfx_port_write_long(bp, PI_PDQ_K_REG_HOST_INT_ENB, PI_HOST_INT_K_DISABLE_ALL_INTS);
1589 return;
1590 }
1591 printk("%s: Adapter reset successful!\n", bp->dev->name);
1592 }
1593 else if (state == PI_STATE_K_LINK_AVAIL)
1594 {
1595 bp->link_available = PI_K_TRUE;
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
1639
1640
1641static void dfx_int_common(struct net_device *dev)
1642{
1643 DFX_board_t *bp = dev->priv;
1644 PI_UINT32 port_status;
1645
1646
1647
1648 if(dfx_xmt_done(bp))
1649 netif_wake_queue(dev);
1650
1651
1652
1653 dfx_rcv_queue_process(bp);
1654
1655
1656
1657
1658
1659
1660
1661
1662 dfx_port_write_long(bp, PI_PDQ_K_REG_TYPE_2_PROD, bp->rcv_xmt_reg.lword);
1663
1664
1665
1666 dfx_port_read_long(bp, PI_PDQ_K_REG_PORT_STATUS, &port_status);
1667
1668
1669
1670 if (port_status & PI_PSTATUS_M_TYPE_0_PENDING)
1671 dfx_int_type_0_process(bp);
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
1709
1710
1711static void dfx_interrupt(int irq, void *dev_id, struct pt_regs *regs)
1712 {
1713 struct net_device *dev = dev_id;
1714 DFX_board_t *bp;
1715 u8 tmp;
1716
1717
1718
1719 bp = dev->priv;
1720
1721 spin_lock(&bp->lock);
1722
1723
1724
1725
1726
1727 if (bp->bus_type == DFX_BUS_TYPE_PCI)
1728 {
1729
1730
1731 dfx_port_write_long(bp, PFI_K_REG_MODE_CTRL, PFI_MODE_M_DMA_ENB);
1732
1733
1734
1735 dfx_int_common(dev);
1736
1737
1738
1739 dfx_port_write_long(bp, PFI_K_REG_STATUS, PFI_STATUS_M_PDQ_INT);
1740 dfx_port_write_long(bp, PFI_K_REG_MODE_CTRL,
1741 (PFI_MODE_M_PDQ_INT_ENB + PFI_MODE_M_DMA_ENB));
1742 }
1743 else
1744 {
1745
1746
1747 dfx_port_read_byte(bp, PI_ESIC_K_IO_CONFIG_STAT_0, &tmp);
1748 tmp &= ~PI_CONFIG_STAT_0_M_INT_ENB;
1749 dfx_port_write_byte(bp, PI_ESIC_K_IO_CONFIG_STAT_0, tmp);
1750
1751
1752
1753 dfx_int_common(dev);
1754
1755
1756
1757 dfx_port_read_byte(bp, PI_ESIC_K_IO_CONFIG_STAT_0, &tmp);
1758 tmp |= PI_CONFIG_STAT_0_M_INT_ENB;
1759 dfx_port_write_byte(bp, PI_ESIC_K_IO_CONFIG_STAT_0, tmp);
1760 }
1761
1762 spin_unlock(&bp->lock);
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
1807
1808
1809static struct net_device_stats *dfx_ctl_get_stats(struct net_device *dev)
1810 {
1811 DFX_board_t *bp = dev->priv;
1812
1813
1814
1815 bp->stats.rx_packets = bp->rcv_total_frames;
1816 bp->stats.tx_packets = bp->xmt_total_frames;
1817 bp->stats.rx_bytes = bp->rcv_total_bytes;
1818 bp->stats.tx_bytes = bp->xmt_total_bytes;
1819 bp->stats.rx_errors = (u32)(bp->rcv_crc_errors + bp->rcv_frame_status_errors + bp->rcv_length_errors);
1820 bp->stats.tx_errors = bp->xmt_length_errors;
1821 bp->stats.rx_dropped = bp->rcv_discards;
1822 bp->stats.tx_dropped = bp->xmt_discards;
1823 bp->stats.multicast = bp->rcv_multicast_frames;
1824 bp->stats.transmit_collision = 0;
1825
1826
1827
1828 bp->cmd_req_virt->cmd_type = PI_CMD_K_SMT_MIB_GET;
1829 if (dfx_hw_dma_cmd_req(bp) != DFX_K_SUCCESS)
1830 return((struct net_device_stats *) &bp->stats);
1831
1832
1833
1834 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));
1835 bp->stats.smt_op_version_id = bp->cmd_rsp_virt->smt_mib_get.smt_op_version_id;
1836 bp->stats.smt_hi_version_id = bp->cmd_rsp_virt->smt_mib_get.smt_hi_version_id;
1837 bp->stats.smt_lo_version_id = bp->cmd_rsp_virt->smt_mib_get.smt_lo_version_id;
1838 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));
1839 bp->stats.smt_mib_version_id = bp->cmd_rsp_virt->smt_mib_get.smt_mib_version_id;
1840 bp->stats.smt_mac_cts = bp->cmd_rsp_virt->smt_mib_get.smt_mac_ct;
1841 bp->stats.smt_non_master_cts = bp->cmd_rsp_virt->smt_mib_get.smt_non_master_ct;
1842 bp->stats.smt_master_cts = bp->cmd_rsp_virt->smt_mib_get.smt_master_ct;
1843 bp->stats.smt_available_paths = bp->cmd_rsp_virt->smt_mib_get.smt_available_paths;
1844 bp->stats.smt_config_capabilities = bp->cmd_rsp_virt->smt_mib_get.smt_config_capabilities;
1845 bp->stats.smt_config_policy = bp->cmd_rsp_virt->smt_mib_get.smt_config_policy;
1846 bp->stats.smt_connection_policy = bp->cmd_rsp_virt->smt_mib_get.smt_connection_policy;
1847 bp->stats.smt_t_notify = bp->cmd_rsp_virt->smt_mib_get.smt_t_notify;
1848 bp->stats.smt_stat_rpt_policy = bp->cmd_rsp_virt->smt_mib_get.smt_stat_rpt_policy;
1849 bp->stats.smt_trace_max_expiration = bp->cmd_rsp_virt->smt_mib_get.smt_trace_max_expiration;
1850 bp->stats.smt_bypass_present = bp->cmd_rsp_virt->smt_mib_get.smt_bypass_present;
1851 bp->stats.smt_ecm_state = bp->cmd_rsp_virt->smt_mib_get.smt_ecm_state;
1852 bp->stats.smt_cf_state = bp->cmd_rsp_virt->smt_mib_get.smt_cf_state;
1853 bp->stats.smt_remote_disconnect_flag = bp->cmd_rsp_virt->smt_mib_get.smt_remote_disconnect_flag;
1854 bp->stats.smt_station_status = bp->cmd_rsp_virt->smt_mib_get.smt_station_status;
1855 bp->stats.smt_peer_wrap_flag = bp->cmd_rsp_virt->smt_mib_get.smt_peer_wrap_flag;
1856 bp->stats.smt_time_stamp = bp->cmd_rsp_virt->smt_mib_get.smt_msg_time_stamp.ls;
1857 bp->stats.smt_transition_time_stamp = bp->cmd_rsp_virt->smt_mib_get.smt_transition_time_stamp.ls;
1858 bp->stats.mac_frame_status_functions = bp->cmd_rsp_virt->smt_mib_get.mac_frame_status_functions;
1859 bp->stats.mac_t_max_capability = bp->cmd_rsp_virt->smt_mib_get.mac_t_max_capability;
1860 bp->stats.mac_tvx_capability = bp->cmd_rsp_virt->smt_mib_get.mac_tvx_capability;
1861 bp->stats.mac_available_paths = bp->cmd_rsp_virt->smt_mib_get.mac_available_paths;
1862 bp->stats.mac_current_path = bp->cmd_rsp_virt->smt_mib_get.mac_current_path;
1863 memcpy(bp->stats.mac_upstream_nbr, &bp->cmd_rsp_virt->smt_mib_get.mac_upstream_nbr, FDDI_K_ALEN);
1864 memcpy(bp->stats.mac_downstream_nbr, &bp->cmd_rsp_virt->smt_mib_get.mac_downstream_nbr, FDDI_K_ALEN);
1865 memcpy(bp->stats.mac_old_upstream_nbr, &bp->cmd_rsp_virt->smt_mib_get.mac_old_upstream_nbr, FDDI_K_ALEN);
1866 memcpy(bp->stats.mac_old_downstream_nbr, &bp->cmd_rsp_virt->smt_mib_get.mac_old_downstream_nbr, FDDI_K_ALEN);
1867 bp->stats.mac_dup_address_test = bp->cmd_rsp_virt->smt_mib_get.mac_dup_address_test;
1868 bp->stats.mac_requested_paths = bp->cmd_rsp_virt->smt_mib_get.mac_requested_paths;
1869 bp->stats.mac_downstream_port_type = bp->cmd_rsp_virt->smt_mib_get.mac_downstream_port_type;
1870 memcpy(bp->stats.mac_smt_address, &bp->cmd_rsp_virt->smt_mib_get.mac_smt_address, FDDI_K_ALEN);
1871 bp->stats.mac_t_req = bp->cmd_rsp_virt->smt_mib_get.mac_t_req;
1872 bp->stats.mac_t_neg = bp->cmd_rsp_virt->smt_mib_get.mac_t_neg;
1873 bp->stats.mac_t_max = bp->cmd_rsp_virt->smt_mib_get.mac_t_max;
1874 bp->stats.mac_tvx_value = bp->cmd_rsp_virt->smt_mib_get.mac_tvx_value;
1875 bp->stats.mac_frame_error_threshold = bp->cmd_rsp_virt->smt_mib_get.mac_frame_error_threshold;
1876 bp->stats.mac_frame_error_ratio = bp->cmd_rsp_virt->smt_mib_get.mac_frame_error_ratio;
1877 bp->stats.mac_rmt_state = bp->cmd_rsp_virt->smt_mib_get.mac_rmt_state;
1878 bp->stats.mac_da_flag = bp->cmd_rsp_virt->smt_mib_get.mac_da_flag;
1879 bp->stats.mac_una_da_flag = bp->cmd_rsp_virt->smt_mib_get.mac_unda_flag;
1880 bp->stats.mac_frame_error_flag = bp->cmd_rsp_virt->smt_mib_get.mac_frame_error_flag;
1881 bp->stats.mac_ma_unitdata_available = bp->cmd_rsp_virt->smt_mib_get.mac_ma_unitdata_available;
1882 bp->stats.mac_hardware_present = bp->cmd_rsp_virt->smt_mib_get.mac_hardware_present;
1883 bp->stats.mac_ma_unitdata_enable = bp->cmd_rsp_virt->smt_mib_get.mac_ma_unitdata_enable;
1884 bp->stats.path_tvx_lower_bound = bp->cmd_rsp_virt->smt_mib_get.path_tvx_lower_bound;
1885 bp->stats.path_t_max_lower_bound = bp->cmd_rsp_virt->smt_mib_get.path_t_max_lower_bound;
1886 bp->stats.path_max_t_req = bp->cmd_rsp_virt->smt_mib_get.path_max_t_req;
1887 memcpy(bp->stats.path_configuration, &bp->cmd_rsp_virt->smt_mib_get.path_configuration, sizeof(bp->cmd_rsp_virt->smt_mib_get.path_configuration));
1888 bp->stats.port_my_type[0] = bp->cmd_rsp_virt->smt_mib_get.port_my_type[0];
1889 bp->stats.port_my_type[1] = bp->cmd_rsp_virt->smt_mib_get.port_my_type[1];
1890 bp->stats.port_neighbor_type[0] = bp->cmd_rsp_virt->smt_mib_get.port_neighbor_type[0];
1891 bp->stats.port_neighbor_type[1] = bp->cmd_rsp_virt->smt_mib_get.port_neighbor_type[1];
1892 bp->stats.port_connection_policies[0] = bp->cmd_rsp_virt->smt_mib_get.port_connection_policies[0];
1893 bp->stats.port_connection_policies[1] = bp->cmd_rsp_virt->smt_mib_get.port_connection_policies[1];
1894 bp->stats.port_mac_indicated[0] = bp->cmd_rsp_virt->smt_mib_get.port_mac_indicated[0];
1895 bp->stats.port_mac_indicated[1] = bp->cmd_rsp_virt->smt_mib_get.port_mac_indicated[1];
1896 bp->stats.port_current_path[0] = bp->cmd_rsp_virt->smt_mib_get.port_current_path[0];
1897 bp->stats.port_current_path[1] = bp->cmd_rsp_virt->smt_mib_get.port_current_path[1];
1898 memcpy(&bp->stats.port_requested_paths[0*3], &bp->cmd_rsp_virt->smt_mib_get.port_requested_paths[0], 3);
1899 memcpy(&bp->stats.port_requested_paths[1*3], &bp->cmd_rsp_virt->smt_mib_get.port_requested_paths[1], 3);
1900 bp->stats.port_mac_placement[0] = bp->cmd_rsp_virt->smt_mib_get.port_mac_placement[0];
1901 bp->stats.port_mac_placement[1] = bp->cmd_rsp_virt->smt_mib_get.port_mac_placement[1];
1902 bp->stats.port_available_paths[0] = bp->cmd_rsp_virt->smt_mib_get.port_available_paths[0];
1903 bp->stats.port_available_paths[1] = bp->cmd_rsp_virt->smt_mib_get.port_available_paths[1];
1904 bp->stats.port_pmd_class[0] = bp->cmd_rsp_virt->smt_mib_get.port_pmd_class[0];
1905 bp->stats.port_pmd_class[1] = bp->cmd_rsp_virt->smt_mib_get.port_pmd_class[1];
1906 bp->stats.port_connection_capabilities[0] = bp->cmd_rsp_virt->smt_mib_get.port_connection_capabilities[0];
1907 bp->stats.port_connection_capabilities[1] = bp->cmd_rsp_virt->smt_mib_get.port_connection_capabilities[1];
1908 bp->stats.port_bs_flag[0] = bp->cmd_rsp_virt->smt_mib_get.port_bs_flag[0];
1909 bp->stats.port_bs_flag[1] = bp->cmd_rsp_virt->smt_mib_get.port_bs_flag[1];
1910 bp->stats.port_ler_estimate[0] = bp->cmd_rsp_virt->smt_mib_get.port_ler_estimate[0];
1911 bp->stats.port_ler_estimate[1] = bp->cmd_rsp_virt->smt_mib_get.port_ler_estimate[1];
1912 bp->stats.port_ler_cutoff[0] = bp->cmd_rsp_virt->smt_mib_get.port_ler_cutoff[0];
1913 bp->stats.port_ler_cutoff[1] = bp->cmd_rsp_virt->smt_mib_get.port_ler_cutoff[1];
1914 bp->stats.port_ler_alarm[0] = bp->cmd_rsp_virt->smt_mib_get.port_ler_alarm[0];
1915 bp->stats.port_ler_alarm[1] = bp->cmd_rsp_virt->smt_mib_get.port_ler_alarm[1];
1916 bp->stats.port_connect_state[0] = bp->cmd_rsp_virt->smt_mib_get.port_connect_state[0];
1917 bp->stats.port_connect_state[1] = bp->cmd_rsp_virt->smt_mib_get.port_connect_state[1];
1918 bp->stats.port_pcm_state[0] = bp->cmd_rsp_virt->smt_mib_get.port_pcm_state[0];
1919 bp->stats.port_pcm_state[1] = bp->cmd_rsp_virt->smt_mib_get.port_pcm_state[1];
1920 bp->stats.port_pc_withhold[0] = bp->cmd_rsp_virt->smt_mib_get.port_pc_withhold[0];
1921 bp->stats.port_pc_withhold[1] = bp->cmd_rsp_virt->smt_mib_get.port_pc_withhold[1];
1922 bp->stats.port_ler_flag[0] = bp->cmd_rsp_virt->smt_mib_get.port_ler_flag[0];
1923 bp->stats.port_ler_flag[1] = bp->cmd_rsp_virt->smt_mib_get.port_ler_flag[1];
1924 bp->stats.port_hardware_present[0] = bp->cmd_rsp_virt->smt_mib_get.port_hardware_present[0];
1925 bp->stats.port_hardware_present[1] = bp->cmd_rsp_virt->smt_mib_get.port_hardware_present[1];
1926
1927
1928
1929 bp->cmd_req_virt->cmd_type = PI_CMD_K_CNTRS_GET;
1930 if (dfx_hw_dma_cmd_req(bp) != DFX_K_SUCCESS)
1931 return((struct net_device_stats *) &bp->stats);
1932
1933
1934
1935 bp->stats.mac_frame_cts = bp->cmd_rsp_virt->cntrs_get.cntrs.frame_cnt.ls;
1936 bp->stats.mac_copied_cts = bp->cmd_rsp_virt->cntrs_get.cntrs.copied_cnt.ls;
1937 bp->stats.mac_transmit_cts = bp->cmd_rsp_virt->cntrs_get.cntrs.transmit_cnt.ls;
1938 bp->stats.mac_error_cts = bp->cmd_rsp_virt->cntrs_get.cntrs.error_cnt.ls;
1939 bp->stats.mac_lost_cts = bp->cmd_rsp_virt->cntrs_get.cntrs.lost_cnt.ls;
1940 bp->stats.port_lct_fail_cts[0] = bp->cmd_rsp_virt->cntrs_get.cntrs.lct_rejects[0].ls;
1941 bp->stats.port_lct_fail_cts[1] = bp->cmd_rsp_virt->cntrs_get.cntrs.lct_rejects[1].ls;
1942 bp->stats.port_lem_reject_cts[0] = bp->cmd_rsp_virt->cntrs_get.cntrs.lem_rejects[0].ls;
1943 bp->stats.port_lem_reject_cts[1] = bp->cmd_rsp_virt->cntrs_get.cntrs.lem_rejects[1].ls;
1944 bp->stats.port_lem_cts[0] = bp->cmd_rsp_virt->cntrs_get.cntrs.link_errors[0].ls;
1945 bp->stats.port_lem_cts[1] = bp->cmd_rsp_virt->cntrs_get.cntrs.link_errors[1].ls;
1946
1947 return((struct net_device_stats *) &bp->stats);
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
1992
1993
1994static void dfx_ctl_set_multicast_list(struct net_device *dev)
1995 {
1996 DFX_board_t *bp = dev->priv;
1997 int i;
1998 struct dev_mc_list *dmi;
1999
2000
2001
2002 if (dev->flags & IFF_PROMISC)
2003 bp->ind_group_prom = PI_FSTATE_K_PASS;
2004
2005
2006
2007 else
2008 {
2009 bp->ind_group_prom = PI_FSTATE_K_BLOCK;
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030 if (dev->mc_count > (PI_CMD_ADDR_FILTER_K_SIZE - bp->uc_count))
2031 {
2032 bp->group_prom = PI_FSTATE_K_PASS;
2033 bp->mc_count = 0;
2034 }
2035 else
2036 {
2037 bp->group_prom = PI_FSTATE_K_BLOCK;
2038 bp->mc_count = dev->mc_count;
2039 }
2040
2041
2042
2043 dmi = dev->mc_list;
2044 for (i=0; i < bp->mc_count; i++)
2045 {
2046 memcpy(&bp->mc_table[i*FDDI_K_ALEN], dmi->dmi_addr, FDDI_K_ALEN);
2047 dmi = dmi->next;
2048 }
2049 if (dfx_ctl_update_cam(bp) != DFX_K_SUCCESS)
2050 {
2051 DBG_printk("%s: Could not update multicast address table!\n", dev->name);
2052 }
2053 else
2054 {
2055 DBG_printk("%s: Multicast address table updated! Added %d addresses.\n", dev->name, bp->mc_count);
2056 }
2057 }
2058
2059
2060
2061 if (dfx_ctl_update_filters(bp) != DFX_K_SUCCESS)
2062 {
2063 DBG_printk("%s: Could not update adapter filters!\n", dev->name);
2064 }
2065 else
2066 {
2067 DBG_printk("%s: Adapter filters updated!\n", dev->name);
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
2106
2107
2108static int dfx_ctl_set_mac_address(struct net_device *dev, void *addr)
2109 {
2110 DFX_board_t *bp = dev->priv;
2111 struct sockaddr *p_sockaddr = (struct sockaddr *)addr;
2112
2113
2114
2115 memcpy(dev->dev_addr, p_sockaddr->sa_data, FDDI_K_ALEN);
2116 memcpy(&bp->uc_table[0], p_sockaddr->sa_data, FDDI_K_ALEN);
2117 bp->uc_count = 1;
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131 if ((bp->uc_count + bp->mc_count) > PI_CMD_ADDR_FILTER_K_SIZE)
2132 {
2133 bp->group_prom = PI_FSTATE_K_PASS;
2134 bp->mc_count = 0;
2135
2136
2137
2138 if (dfx_ctl_update_filters(bp) != DFX_K_SUCCESS)
2139 {
2140 DBG_printk("%s: Could not update adapter filters!\n", dev->name);
2141 }
2142 else
2143 {
2144 DBG_printk("%s: Adapter filters updated!\n", dev->name);
2145 }
2146 }
2147
2148
2149
2150 if (dfx_ctl_update_cam(bp) != DFX_K_SUCCESS)
2151 {
2152 DBG_printk("%s: Could not set new MAC address!\n", dev->name);
2153 }
2154 else
2155 {
2156 DBG_printk("%s: Adapter CAM updated with new MAC address\n", dev->name);
2157 }
2158 return(0);
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
2193
2194
2195static int dfx_ctl_update_cam(DFX_board_t *bp)
2196 {
2197 int i;
2198 PI_LAN_ADDR *p_addr;
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213 memset(bp->cmd_req_virt, 0, PI_CMD_REQ_K_SIZE_MAX);
2214 bp->cmd_req_virt->cmd_type = PI_CMD_K_ADDR_FILTER_SET;
2215 p_addr = &bp->cmd_req_virt->addr_filter_set.entry[0];
2216
2217
2218
2219 for (i=0; i < (int)bp->uc_count; i++)
2220 {
2221 if (i < PI_CMD_ADDR_FILTER_K_SIZE)
2222 {
2223 memcpy(p_addr, &bp->uc_table[i*FDDI_K_ALEN], FDDI_K_ALEN);
2224 p_addr++;
2225 }
2226 }
2227
2228
2229
2230 for (i=0; i < (int)bp->mc_count; i++)
2231 {
2232 if ((i + bp->uc_count) < PI_CMD_ADDR_FILTER_K_SIZE)
2233 {
2234 memcpy(p_addr, &bp->mc_table[i*FDDI_K_ALEN], FDDI_K_ALEN);
2235 p_addr++;
2236 }
2237 }
2238
2239
2240
2241 if (dfx_hw_dma_cmd_req(bp) != DFX_K_SUCCESS)
2242 return(DFX_K_FAILURE);
2243 return(DFX_K_SUCCESS);
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
2276
2277
2278static int dfx_ctl_update_filters(DFX_board_t *bp)
2279 {
2280 int i = 0;
2281
2282
2283
2284 bp->cmd_req_virt->cmd_type = PI_CMD_K_FILTERS_SET;
2285
2286
2287
2288 bp->cmd_req_virt->filter_set.item[i].item_code = PI_ITEM_K_BROADCAST;
2289 bp->cmd_req_virt->filter_set.item[i++].value = PI_FSTATE_K_PASS;
2290
2291
2292
2293 bp->cmd_req_virt->filter_set.item[i].item_code = PI_ITEM_K_IND_GROUP_PROM;
2294 bp->cmd_req_virt->filter_set.item[i++].value = bp->ind_group_prom;
2295
2296
2297
2298 bp->cmd_req_virt->filter_set.item[i].item_code = PI_ITEM_K_GROUP_PROM;
2299 bp->cmd_req_virt->filter_set.item[i++].value = bp->group_prom;
2300
2301
2302
2303 bp->cmd_req_virt->filter_set.item[i].item_code = PI_ITEM_K_EOL;
2304
2305
2306
2307 if (dfx_hw_dma_cmd_req(bp) != DFX_K_SUCCESS)
2308 return(DFX_K_FAILURE);
2309 return(DFX_K_SUCCESS);
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
2351
2352
2353static int dfx_hw_dma_cmd_req(DFX_board_t *bp)
2354 {
2355 int status;
2356 int timeout_cnt;
2357
2358
2359
2360 status = dfx_hw_adap_state_rd(bp);
2361 if ((status == PI_STATE_K_RESET) ||
2362 (status == PI_STATE_K_HALTED) ||
2363 (status == PI_STATE_K_DMA_UNAVAIL) ||
2364 (status == PI_STATE_K_UPGRADE))
2365 return(DFX_K_OUTSTATE);
2366
2367
2368
2369 bp->descr_block_virt->cmd_rsp[bp->cmd_rsp_reg.index.prod].long_0 = (u32) (PI_RCV_DESCR_M_SOP |
2370 ((PI_CMD_RSP_K_SIZE_MAX / PI_ALIGN_K_CMD_RSP_BUFF) << PI_RCV_DESCR_V_SEG_LEN));
2371 bp->descr_block_virt->cmd_rsp[bp->cmd_rsp_reg.index.prod].long_1 = bp->cmd_rsp_phys;
2372
2373
2374
2375 bp->cmd_rsp_reg.index.prod += 1;
2376 bp->cmd_rsp_reg.index.prod &= PI_CMD_RSP_K_NUM_ENTRIES-1;
2377 dfx_port_write_long(bp, PI_PDQ_K_REG_CMD_RSP_PROD, bp->cmd_rsp_reg.lword);
2378
2379
2380
2381 bp->descr_block_virt->cmd_req[bp->cmd_req_reg.index.prod].long_0 = (u32) (PI_XMT_DESCR_M_SOP |
2382 PI_XMT_DESCR_M_EOP | (PI_CMD_REQ_K_SIZE_MAX << PI_XMT_DESCR_V_SEG_LEN));
2383 bp->descr_block_virt->cmd_req[bp->cmd_req_reg.index.prod].long_1 = bp->cmd_req_phys;
2384
2385
2386
2387 bp->cmd_req_reg.index.prod += 1;
2388 bp->cmd_req_reg.index.prod &= PI_CMD_REQ_K_NUM_ENTRIES-1;
2389 dfx_port_write_long(bp, PI_PDQ_K_REG_CMD_REQ_PROD, bp->cmd_req_reg.lword);
2390
2391
2392
2393
2394
2395
2396 for (timeout_cnt = 20000; timeout_cnt > 0; timeout_cnt--)
2397 {
2398 if (bp->cmd_req_reg.index.prod == (u8)(bp->cons_block_virt->cmd_req))
2399 break;
2400 udelay(100);
2401 }
2402 if (timeout_cnt == 0)
2403 return(DFX_K_HW_TIMEOUT);
2404
2405
2406
2407 bp->cmd_req_reg.index.comp += 1;
2408 bp->cmd_req_reg.index.comp &= PI_CMD_REQ_K_NUM_ENTRIES-1;
2409 dfx_port_write_long(bp, PI_PDQ_K_REG_CMD_REQ_PROD, bp->cmd_req_reg.lword);
2410
2411
2412
2413
2414
2415
2416 for (timeout_cnt = 20000; timeout_cnt > 0; timeout_cnt--)
2417 {
2418 if (bp->cmd_rsp_reg.index.prod == (u8)(bp->cons_block_virt->cmd_rsp))
2419 break;
2420 udelay(100);
2421 }
2422 if (timeout_cnt == 0)
2423 return(DFX_K_HW_TIMEOUT);
2424
2425
2426
2427 bp->cmd_rsp_reg.index.comp += 1;
2428 bp->cmd_rsp_reg.index.comp &= PI_CMD_RSP_K_NUM_ENTRIES-1;
2429 dfx_port_write_long(bp, PI_PDQ_K_REG_CMD_RSP_PROD, bp->cmd_rsp_reg.lword);
2430 return(DFX_K_SUCCESS);
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
2465
2466
2467static int dfx_hw_port_ctrl_req(
2468 DFX_board_t *bp,
2469 PI_UINT32 command,
2470 PI_UINT32 data_a,
2471 PI_UINT32 data_b,
2472 PI_UINT32 *host_data
2473 )
2474
2475 {
2476 PI_UINT32 port_cmd;
2477 int timeout_cnt;
2478
2479
2480
2481 port_cmd = (PI_UINT32) (command | PI_PCTRL_M_CMD_ERROR);
2482
2483
2484
2485 dfx_port_write_long(bp, PI_PDQ_K_REG_PORT_DATA_A, data_a);
2486 dfx_port_write_long(bp, PI_PDQ_K_REG_PORT_DATA_B, data_b);
2487 dfx_port_write_long(bp, PI_PDQ_K_REG_PORT_CTRL, port_cmd);
2488
2489
2490
2491 if (command == PI_PCTRL_M_BLAST_FLASH)
2492 timeout_cnt = 600000;
2493 else
2494 timeout_cnt = 20000;
2495
2496 for (; timeout_cnt > 0; timeout_cnt--)
2497 {
2498 dfx_port_read_long(bp, PI_PDQ_K_REG_PORT_CTRL, &port_cmd);
2499 if (!(port_cmd & PI_PCTRL_M_CMD_ERROR))
2500 break;
2501 udelay(100);
2502 }
2503 if (timeout_cnt == 0)
2504 return(DFX_K_HW_TIMEOUT);
2505
2506
2507
2508
2509
2510
2511
2512 if (host_data != NULL)
2513 dfx_port_read_long(bp, PI_PDQ_K_REG_HOST_DATA, host_data);
2514 return(DFX_K_SUCCESS);
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
2549
2550
2551static void dfx_hw_adap_reset(
2552 DFX_board_t *bp,
2553 PI_UINT32 type
2554 )
2555
2556 {
2557
2558
2559 dfx_port_write_long(bp, PI_PDQ_K_REG_PORT_DATA_A, type);
2560 dfx_port_write_long(bp, PI_PDQ_K_REG_PORT_RESET, PI_RESET_M_ASSERT_RESET);
2561
2562
2563
2564 udelay(20);
2565
2566
2567
2568 dfx_port_write_long(bp, PI_PDQ_K_REG_PORT_RESET, 0);
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
2597
2598
2599static int dfx_hw_adap_state_rd(DFX_board_t *bp)
2600 {
2601 PI_UINT32 port_status;
2602
2603 dfx_port_read_long(bp, PI_PDQ_K_REG_PORT_STATUS, &port_status);
2604 return((port_status & PI_PSTATUS_M_STATE) >> PI_PSTATUS_V_STATE);
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
2637
2638
2639static int dfx_hw_dma_uninit(DFX_board_t *bp, PI_UINT32 type)
2640 {
2641 int timeout_cnt;
2642
2643
2644
2645 dfx_hw_adap_reset(bp, type);
2646
2647
2648
2649 for (timeout_cnt = 100000; timeout_cnt > 0; timeout_cnt--)
2650 {
2651 if (dfx_hw_adap_state_rd(bp) == PI_STATE_K_DMA_UNAVAIL)
2652 break;
2653 udelay(100);
2654 }
2655 if (timeout_cnt == 0)
2656 return(DFX_K_HW_TIMEOUT);
2657 return(DFX_K_SUCCESS);
2658 }
2659
2660
2661
2662
2663
2664
2665static void my_skb_align(struct sk_buff *skb, int n)
2666{
2667 unsigned long x=(unsigned long)skb->data;
2668 unsigned long v;
2669
2670 v=(x+n-1)&~(n-1);
2671
2672 skb_reserve(skb, v-x);
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
2709
2710
2711static int dfx_rcv_init(DFX_board_t *bp, int get_buffers)
2712 {
2713 int i, j;
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733 if (get_buffers) {
2734#ifdef DYNAMIC_BUFFERS
2735 for (i = 0; i < (int)(bp->rcv_bufs_to_post); i++)
2736 for (j = 0; (i + j) < (int)PI_RCV_DATA_K_NUM_ENTRIES; j += bp->rcv_bufs_to_post)
2737 {
2738 struct sk_buff *newskb = __dev_alloc_skb(NEW_SKB_SIZE, GFP_NOIO);
2739 if (!newskb)
2740 return -ENOMEM;
2741 bp->descr_block_virt->rcv_data[i+j].long_0 = (u32) (PI_RCV_DESCR_M_SOP |
2742 ((PI_RCV_DATA_K_SIZE_MAX / PI_ALIGN_K_RCV_DATA_BUFF) << PI_RCV_DESCR_V_SEG_LEN));
2743
2744
2745
2746
2747
2748 my_skb_align(newskb, 128);
2749 bp->descr_block_virt->rcv_data[i + j].long_1 =
2750 (u32)pci_map_single(bp->pci_dev, newskb->data,
2751 NEW_SKB_SIZE,
2752 PCI_DMA_FROMDEVICE);
2753
2754
2755
2756
2757 bp->p_rcv_buff_va[i+j] = (char *) newskb;
2758 }
2759#else
2760 for (i=0; i < (int)(bp->rcv_bufs_to_post); i++)
2761 for (j=0; (i + j) < (int)PI_RCV_DATA_K_NUM_ENTRIES; j += bp->rcv_bufs_to_post)
2762 {
2763 bp->descr_block_virt->rcv_data[i+j].long_0 = (u32) (PI_RCV_DESCR_M_SOP |
2764 ((PI_RCV_DATA_K_SIZE_MAX / PI_ALIGN_K_RCV_DATA_BUFF) << PI_RCV_DESCR_V_SEG_LEN));
2765 bp->descr_block_virt->rcv_data[i+j].long_1 = (u32) (bp->rcv_block_phys + (i * PI_RCV_DATA_K_SIZE_MAX));
2766 bp->p_rcv_buff_va[i+j] = (char *) (bp->rcv_block_virt + (i * PI_RCV_DATA_K_SIZE_MAX));
2767 }
2768#endif
2769 }
2770
2771
2772
2773 bp->rcv_xmt_reg.index.rcv_prod = bp->rcv_bufs_to_post;
2774 dfx_port_write_long(bp, PI_PDQ_K_REG_TYPE_2_PROD, bp->rcv_xmt_reg.lword);
2775 return 0;
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
2806
2807
2808
2809
2810
2811static void dfx_rcv_queue_process(
2812 DFX_board_t *bp
2813 )
2814
2815 {
2816 PI_TYPE_2_CONSUMER *p_type_2_cons;
2817 char *p_buff;
2818 u32 descr, pkt_len;
2819 struct sk_buff *skb;
2820
2821
2822
2823 p_type_2_cons = (PI_TYPE_2_CONSUMER *)(&bp->cons_block_virt->xmt_rcv_data);
2824 while (bp->rcv_xmt_reg.index.rcv_comp != p_type_2_cons->index.rcv_cons)
2825 {
2826
2827
2828 int entry;
2829
2830 entry = bp->rcv_xmt_reg.index.rcv_comp;
2831#ifdef DYNAMIC_BUFFERS
2832 p_buff = (char *) (((struct sk_buff *)bp->p_rcv_buff_va[entry])->data);
2833#else
2834 p_buff = (char *) bp->p_rcv_buff_va[entry];
2835#endif
2836 memcpy(&descr, p_buff + RCV_BUFF_K_DESCR, sizeof(u32));
2837
2838 if (descr & PI_FMC_DESCR_M_RCC_FLUSH)
2839 {
2840 if (descr & PI_FMC_DESCR_M_RCC_CRC)
2841 bp->rcv_crc_errors++;
2842 else
2843 bp->rcv_frame_status_errors++;
2844 }
2845 else
2846 {
2847 int rx_in_place = 0;
2848
2849
2850
2851 pkt_len = (u32)((descr & PI_FMC_DESCR_M_LEN) >> PI_FMC_DESCR_V_LEN);
2852 pkt_len -= 4;
2853 if (!IN_RANGE(pkt_len, FDDI_K_LLC_ZLEN, FDDI_K_LLC_LEN))
2854 bp->rcv_length_errors++;
2855 else{
2856#ifdef DYNAMIC_BUFFERS
2857 if (pkt_len > SKBUFF_RX_COPYBREAK) {
2858 struct sk_buff *newskb;
2859
2860 newskb = dev_alloc_skb(NEW_SKB_SIZE);
2861 if (newskb){
2862 rx_in_place = 1;
2863
2864 my_skb_align(newskb, 128);
2865 skb = (struct sk_buff *)bp->p_rcv_buff_va[entry];
2866 pci_unmap_single(bp->pci_dev,
2867 bp->descr_block_virt->rcv_data[entry].long_1,
2868 NEW_SKB_SIZE,
2869 PCI_DMA_FROMDEVICE);
2870 skb_reserve(skb, RCV_BUFF_K_PADDING);
2871 bp->p_rcv_buff_va[entry] = (char *)newskb;
2872 bp->descr_block_virt->rcv_data[entry].long_1 =
2873 (u32)pci_map_single(bp->pci_dev,
2874 newskb->data,
2875 NEW_SKB_SIZE,
2876 PCI_DMA_FROMDEVICE);
2877 } else
2878 skb = NULL;
2879 } else
2880#endif
2881 skb = dev_alloc_skb(pkt_len+3);
2882 if (skb == NULL)
2883 {
2884 printk("%s: Could not allocate receive buffer. Dropping packet.\n", bp->dev->name);
2885 bp->rcv_discards++;
2886 break;
2887 }
2888 else {
2889#ifndef DYNAMIC_BUFFERS
2890 if (! rx_in_place)
2891#endif
2892 {
2893
2894
2895 memcpy(skb->data, p_buff + RCV_BUFF_K_PADDING, pkt_len+3);
2896 }
2897
2898 skb_reserve(skb,3);
2899 skb_put(skb, pkt_len);
2900 skb->dev = bp->dev;
2901
2902 skb->protocol = fddi_type_trans(skb, bp->dev);
2903 bp->rcv_total_bytes += skb->len;
2904 netif_rx(skb);
2905
2906
2907 bp->dev->last_rx = jiffies;
2908 bp->rcv_total_frames++;
2909 if (*(p_buff + RCV_BUFF_K_DA) & 0x01)
2910 bp->rcv_multicast_frames++;
2911 }
2912 }
2913 }
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923 bp->rcv_xmt_reg.index.rcv_prod += 1;
2924 bp->rcv_xmt_reg.index.rcv_comp += 1;
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
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990static int dfx_xmt_queue_pkt(
2991 struct sk_buff *skb,
2992 struct net_device *dev
2993 )
2994
2995 {
2996 DFX_board_t *bp = dev->priv;
2997 u8 prod;
2998 PI_XMT_DESCR *p_xmt_descr;
2999 XMT_DRIVER_DESCR *p_xmt_drv_descr;
3000 unsigned long flags;
3001
3002 netif_stop_queue(dev);
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013 if (!IN_RANGE(skb->len, FDDI_K_LLC_ZLEN, FDDI_K_LLC_LEN))
3014 {
3015 printk("%s: Invalid packet length - %u bytes\n",
3016 dev->name, skb->len);
3017 bp->xmt_length_errors++;
3018 netif_wake_queue(dev);
3019 dev_kfree_skb(skb);
3020 return(0);
3021 }
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034 if (bp->link_available == PI_K_FALSE)
3035 {
3036 if (dfx_hw_adap_state_rd(bp) == PI_STATE_K_LINK_AVAIL)
3037 bp->link_available = PI_K_TRUE;
3038 else
3039 {
3040 bp->xmt_discards++;
3041 dev_kfree_skb(skb);
3042 netif_wake_queue(dev);
3043 return(0);
3044 }
3045 }
3046
3047 spin_lock_irqsave(&bp->lock, flags);
3048
3049
3050
3051 prod = bp->rcv_xmt_reg.index.xmt_prod;
3052 p_xmt_descr = &(bp->descr_block_virt->xmt_data[prod]);
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065 p_xmt_drv_descr = &(bp->xmt_drv_descr_blk[prod++]);
3066
3067
3068
3069 skb_push(skb,3);
3070 skb->data[0] = DFX_PRH0_BYTE;
3071 skb->data[1] = DFX_PRH1_BYTE;
3072 skb->data[2] = DFX_PRH2_BYTE;
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101 p_xmt_descr->long_0 = (u32) (PI_XMT_DESCR_M_SOP | PI_XMT_DESCR_M_EOP | ((skb->len) << PI_XMT_DESCR_V_SEG_LEN));
3102 p_xmt_descr->long_1 = (u32)pci_map_single(bp->pci_dev, skb->data,
3103 skb->len, PCI_DMA_TODEVICE);
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116 if (prod == bp->rcv_xmt_reg.index.xmt_comp)
3117 {
3118 skb_pull(skb,3);
3119 spin_unlock_irqrestore(&bp->lock, flags);
3120 return(1);
3121 }
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139 p_xmt_drv_descr->p_skb = skb;
3140
3141
3142
3143 bp->rcv_xmt_reg.index.xmt_prod = prod;
3144 dfx_port_write_long(bp, PI_PDQ_K_REG_TYPE_2_PROD, bp->rcv_xmt_reg.lword);
3145 spin_unlock_irqrestore(&bp->lock, flags);
3146 netif_wake_queue(dev);
3147 return(0);
3148 }
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183static int dfx_xmt_done(DFX_board_t *bp)
3184 {
3185 XMT_DRIVER_DESCR *p_xmt_drv_descr;
3186 PI_TYPE_2_CONSUMER *p_type_2_cons;
3187 u8 comp;
3188 int freed = 0;
3189
3190
3191
3192 p_type_2_cons = (PI_TYPE_2_CONSUMER *)(&bp->cons_block_virt->xmt_rcv_data);
3193 while (bp->rcv_xmt_reg.index.xmt_comp != p_type_2_cons->index.xmt_cons)
3194 {
3195
3196
3197 p_xmt_drv_descr = &(bp->xmt_drv_descr_blk[bp->rcv_xmt_reg.index.xmt_comp]);
3198
3199
3200
3201 bp->xmt_total_frames++;
3202 bp->xmt_total_bytes += p_xmt_drv_descr->p_skb->len;
3203
3204
3205 comp = bp->rcv_xmt_reg.index.xmt_comp;
3206 pci_unmap_single(bp->pci_dev,
3207 bp->descr_block_virt->xmt_data[comp].long_1,
3208 p_xmt_drv_descr->p_skb->len,
3209 PCI_DMA_TODEVICE);
3210 dev_kfree_skb_irq(p_xmt_drv_descr->p_skb);
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223 bp->rcv_xmt_reg.index.xmt_comp += 1;
3224 freed++;
3225 }
3226 return freed;
3227 }
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256#ifdef DYNAMIC_BUFFERS
3257static void dfx_rcv_flush( DFX_board_t *bp )
3258 {
3259 int i, j;
3260
3261 for (i = 0; i < (int)(bp->rcv_bufs_to_post); i++)
3262 for (j = 0; (i + j) < (int)PI_RCV_DATA_K_NUM_ENTRIES; j += bp->rcv_bufs_to_post)
3263 {
3264 struct sk_buff *skb;
3265 skb = (struct sk_buff *)bp->p_rcv_buff_va[i+j];
3266 if (skb)
3267 dev_kfree_skb(skb);
3268 bp->p_rcv_buff_va[i+j] = NULL;
3269 }
3270
3271 }
3272#else
3273static inline void dfx_rcv_flush( DFX_board_t *bp )
3274{
3275}
3276#endif
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314static void dfx_xmt_flush( DFX_board_t *bp )
3315 {
3316 u32 prod_cons;
3317 XMT_DRIVER_DESCR *p_xmt_drv_descr;
3318 u8 comp;
3319
3320
3321
3322 while (bp->rcv_xmt_reg.index.xmt_comp != bp->rcv_xmt_reg.index.xmt_prod)
3323 {
3324
3325
3326 p_xmt_drv_descr = &(bp->xmt_drv_descr_blk[bp->rcv_xmt_reg.index.xmt_comp]);
3327
3328
3329 comp = bp->rcv_xmt_reg.index.xmt_comp;
3330 pci_unmap_single(bp->pci_dev,
3331 bp->descr_block_virt->xmt_data[comp].long_1,
3332 p_xmt_drv_descr->p_skb->len,
3333 PCI_DMA_TODEVICE);
3334 dev_kfree_skb(p_xmt_drv_descr->p_skb);
3335
3336
3337
3338 bp->xmt_discards++;
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351 bp->rcv_xmt_reg.index.xmt_comp += 1;
3352 }
3353
3354
3355
3356 prod_cons = (u32)(bp->cons_block_virt->xmt_rcv_data & ~PI_CONS_M_XMT_INDEX);
3357 prod_cons |= (u32)(bp->rcv_xmt_reg.index.xmt_prod << PI_CONS_V_XMT_INDEX);
3358 bp->cons_block_virt->xmt_rcv_data = prod_cons;
3359 }
3360
3361static void __devexit dfx_remove_one_pci_or_eisa(struct pci_dev *pdev, struct net_device *dev)
3362{
3363 DFX_board_t *bp = dev->priv;
3364 int alloc_size;
3365
3366 unregister_netdev(dev);
3367 release_region(dev->base_addr, pdev ? PFI_K_CSR_IO_LEN : PI_ESIC_K_CSR_IO_LEN );
3368
3369 alloc_size = sizeof(PI_DESCR_BLOCK) +
3370 PI_CMD_REQ_K_SIZE_MAX + PI_CMD_RSP_K_SIZE_MAX +
3371#ifndef DYNAMIC_BUFFERS
3372 (bp->rcv_bufs_to_post * PI_RCV_DATA_K_SIZE_MAX) +
3373#endif
3374 sizeof(PI_CONSUMER_BLOCK) +
3375 (PI_ALIGN_K_DESC_BLK - 1);
3376 if (bp->kmalloced)
3377 pci_free_consistent(pdev, alloc_size, bp->kmalloced,
3378 bp->kmalloced_dma);
3379 free_netdev(dev);
3380}
3381
3382static void __devexit dfx_remove_one (struct pci_dev *pdev)
3383{
3384 struct net_device *dev = pci_get_drvdata(pdev);
3385
3386 dfx_remove_one_pci_or_eisa(pdev, dev);
3387 pci_set_drvdata(pdev, NULL);
3388}
3389
3390static struct pci_device_id dfx_pci_tbl[] = {
3391 { PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_FDDI, PCI_ANY_ID, PCI_ANY_ID, },
3392 { 0, }
3393};
3394MODULE_DEVICE_TABLE(pci, dfx_pci_tbl);
3395
3396static struct pci_driver dfx_driver = {
3397 .name = "defxx",
3398 .probe = dfx_init_one,
3399 .remove = __devexit_p(dfx_remove_one),
3400 .id_table = dfx_pci_tbl,
3401};
3402
3403static int dfx_have_pci;
3404static int dfx_have_eisa;
3405
3406
3407static void __exit dfx_eisa_cleanup(void)
3408{
3409 struct net_device *dev = root_dfx_eisa_dev;
3410
3411 while (dev)
3412 {
3413 struct net_device *tmp;
3414 DFX_board_t *bp;
3415
3416 bp = (DFX_board_t*)dev->priv;
3417 tmp = bp->next;
3418 dfx_remove_one_pci_or_eisa(NULL, dev);
3419 dev = tmp;
3420 }
3421}
3422
3423static int __init dfx_init(void)
3424{
3425 int rc_pci, rc_eisa;
3426
3427
3428#ifdef MODULE
3429 printk(version);
3430#endif
3431
3432 rc_pci = pci_module_init(&dfx_driver);
3433 if (rc_pci >= 0) dfx_have_pci = 1;
3434
3435 rc_eisa = dfx_eisa_init();
3436 if (rc_eisa >= 0) dfx_have_eisa = 1;
3437
3438 return ((rc_eisa < 0) ? 0 : rc_eisa) + ((rc_pci < 0) ? 0 : rc_pci);
3439}
3440
3441static void __exit dfx_cleanup(void)
3442{
3443 if (dfx_have_pci)
3444 pci_unregister_driver(&dfx_driver);
3445 if (dfx_have_eisa)
3446 dfx_eisa_cleanup();
3447
3448}
3449
3450module_init(dfx_init);
3451module_exit(dfx_cleanup);
3452MODULE_LICENSE("GPL");
3453
3454
3455
3456
3457
3458
3459
3460