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
203
204#include <linux/bitops.h>
205#include <linux/compiler.h>
206#include <linux/delay.h>
207#include <linux/dma-mapping.h>
208#include <linux/eisa.h>
209#include <linux/errno.h>
210#include <linux/fddidevice.h>
211#include <linux/interrupt.h>
212#include <linux/ioport.h>
213#include <linux/kernel.h>
214#include <linux/module.h>
215#include <linux/netdevice.h>
216#include <linux/pci.h>
217#include <linux/skbuff.h>
218#include <linux/slab.h>
219#include <linux/string.h>
220#include <linux/tc.h>
221
222#include <asm/byteorder.h>
223#include <asm/io.h>
224
225#include "defxx.h"
226
227
228#define DRV_NAME "defxx"
229#define DRV_VERSION "v1.12"
230#define DRV_RELDATE "2021/03/10"
231
232static const char version[] =
233 DRV_NAME ": " DRV_VERSION " " DRV_RELDATE
234 " Lawrence V. Stefani and others\n";
235
236#define DYNAMIC_BUFFERS 1
237
238#define SKBUFF_RX_COPYBREAK 200
239
240
241
242
243#define NEW_SKB_SIZE (PI_RCV_DATA_K_SIZE_MAX+128)
244
245#ifdef CONFIG_EISA
246#define DFX_BUS_EISA(dev) (dev->bus == &eisa_bus_type)
247#else
248#define DFX_BUS_EISA(dev) 0
249#endif
250
251#ifdef CONFIG_TC
252#define DFX_BUS_TC(dev) (dev->bus == &tc_bus_type)
253#else
254#define DFX_BUS_TC(dev) 0
255#endif
256
257#if defined(CONFIG_EISA) || defined(CONFIG_PCI)
258#define dfx_use_mmio bp->mmio
259#else
260#define dfx_use_mmio true
261#endif
262
263
264
265static void dfx_bus_init(struct net_device *dev);
266static void dfx_bus_uninit(struct net_device *dev);
267static void dfx_bus_config_check(DFX_board_t *bp);
268
269static int dfx_driver_init(struct net_device *dev,
270 const char *print_name,
271 resource_size_t bar_start);
272static int dfx_adap_init(DFX_board_t *bp, int get_buffers);
273
274static int dfx_open(struct net_device *dev);
275static int dfx_close(struct net_device *dev);
276
277static void dfx_int_pr_halt_id(DFX_board_t *bp);
278static void dfx_int_type_0_process(DFX_board_t *bp);
279static void dfx_int_common(struct net_device *dev);
280static irqreturn_t dfx_interrupt(int irq, void *dev_id);
281
282static struct net_device_stats *dfx_ctl_get_stats(struct net_device *dev);
283static void dfx_ctl_set_multicast_list(struct net_device *dev);
284static int dfx_ctl_set_mac_address(struct net_device *dev, void *addr);
285static int dfx_ctl_update_cam(DFX_board_t *bp);
286static int dfx_ctl_update_filters(DFX_board_t *bp);
287
288static int dfx_hw_dma_cmd_req(DFX_board_t *bp);
289static 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);
290static void dfx_hw_adap_reset(DFX_board_t *bp, PI_UINT32 type);
291static int dfx_hw_adap_state_rd(DFX_board_t *bp);
292static int dfx_hw_dma_uninit(DFX_board_t *bp, PI_UINT32 type);
293
294static int dfx_rcv_init(DFX_board_t *bp, int get_buffers);
295static void dfx_rcv_queue_process(DFX_board_t *bp);
296#ifdef DYNAMIC_BUFFERS
297static void dfx_rcv_flush(DFX_board_t *bp);
298#else
299static inline void dfx_rcv_flush(DFX_board_t *bp) {}
300#endif
301
302static netdev_tx_t dfx_xmt_queue_pkt(struct sk_buff *skb,
303 struct net_device *dev);
304static int dfx_xmt_done(DFX_board_t *bp);
305static void dfx_xmt_flush(DFX_board_t *bp);
306
307
308
309static struct pci_driver dfx_pci_driver;
310static struct eisa_driver dfx_eisa_driver;
311static struct tc_driver dfx_tc_driver;
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364static inline void dfx_writel(DFX_board_t *bp, int offset, u32 data)
365{
366 writel(data, bp->base.mem + offset);
367 mb();
368}
369
370static inline void dfx_outl(DFX_board_t *bp, int offset, u32 data)
371{
372 outl(data, bp->base.port + offset);
373}
374
375static void dfx_port_write_long(DFX_board_t *bp, int offset, u32 data)
376{
377 struct device __maybe_unused *bdev = bp->bus_dev;
378
379 if (dfx_use_mmio)
380 dfx_writel(bp, offset, data);
381 else
382 dfx_outl(bp, offset, data);
383}
384
385
386static inline void dfx_readl(DFX_board_t *bp, int offset, u32 *data)
387{
388 mb();
389 *data = readl(bp->base.mem + offset);
390}
391
392static inline void dfx_inl(DFX_board_t *bp, int offset, u32 *data)
393{
394 *data = inl(bp->base.port + offset);
395}
396
397static void dfx_port_read_long(DFX_board_t *bp, int offset, u32 *data)
398{
399 struct device __maybe_unused *bdev = bp->bus_dev;
400
401 if (dfx_use_mmio)
402 dfx_readl(bp, offset, data);
403 else
404 dfx_inl(bp, offset, data);
405}
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431static void dfx_get_bars(DFX_board_t *bp,
432 resource_size_t *bar_start, resource_size_t *bar_len)
433{
434 struct device *bdev = bp->bus_dev;
435 int dfx_bus_pci = dev_is_pci(bdev);
436 int dfx_bus_eisa = DFX_BUS_EISA(bdev);
437 int dfx_bus_tc = DFX_BUS_TC(bdev);
438
439 if (dfx_bus_pci) {
440 int num = dfx_use_mmio ? 0 : 1;
441
442 bar_start[0] = pci_resource_start(to_pci_dev(bdev), num);
443 bar_len[0] = pci_resource_len(to_pci_dev(bdev), num);
444 bar_start[2] = bar_start[1] = 0;
445 bar_len[2] = bar_len[1] = 0;
446 }
447 if (dfx_bus_eisa) {
448 unsigned long base_addr = to_eisa_device(bdev)->base_addr;
449 resource_size_t bar_lo;
450 resource_size_t bar_hi;
451
452 if (dfx_use_mmio) {
453 bar_lo = inb(base_addr + PI_ESIC_K_MEM_ADD_LO_CMP_2);
454 bar_lo <<= 8;
455 bar_lo |= inb(base_addr + PI_ESIC_K_MEM_ADD_LO_CMP_1);
456 bar_lo <<= 8;
457 bar_lo |= inb(base_addr + PI_ESIC_K_MEM_ADD_LO_CMP_0);
458 bar_lo <<= 8;
459 bar_start[0] = bar_lo;
460 bar_hi = inb(base_addr + PI_ESIC_K_MEM_ADD_HI_CMP_2);
461 bar_hi <<= 8;
462 bar_hi |= inb(base_addr + PI_ESIC_K_MEM_ADD_HI_CMP_1);
463 bar_hi <<= 8;
464 bar_hi |= inb(base_addr + PI_ESIC_K_MEM_ADD_HI_CMP_0);
465 bar_hi <<= 8;
466 bar_len[0] = ((bar_hi - bar_lo) | PI_MEM_ADD_MASK_M) +
467 1;
468 } else {
469 bar_start[0] = base_addr;
470 bar_len[0] = PI_ESIC_K_CSR_IO_LEN;
471 }
472 bar_start[1] = base_addr + PI_DEFEA_K_BURST_HOLDOFF;
473 bar_len[1] = PI_ESIC_K_BURST_HOLDOFF_LEN;
474 bar_start[2] = base_addr + PI_ESIC_K_ESIC_CSR;
475 bar_len[2] = PI_ESIC_K_ESIC_CSR_LEN;
476 }
477 if (dfx_bus_tc) {
478 bar_start[0] = to_tc_dev(bdev)->resource.start +
479 PI_TC_K_CSR_OFFSET;
480 bar_len[0] = PI_TC_K_CSR_LEN;
481 bar_start[2] = bar_start[1] = 0;
482 bar_len[2] = bar_len[1] = 0;
483 }
484}
485
486static const struct net_device_ops dfx_netdev_ops = {
487 .ndo_open = dfx_open,
488 .ndo_stop = dfx_close,
489 .ndo_start_xmit = dfx_xmt_queue_pkt,
490 .ndo_get_stats = dfx_ctl_get_stats,
491 .ndo_set_rx_mode = dfx_ctl_set_multicast_list,
492 .ndo_set_mac_address = dfx_ctl_set_mac_address,
493};
494
495static void dfx_register_res_err(const char *print_name, bool mmio,
496 unsigned long start, unsigned long len)
497{
498 pr_err("%s: Cannot reserve %s resource 0x%lx @ 0x%lx, aborting\n",
499 print_name, mmio ? "MMIO" : "I/O", len, start);
500}
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530static int dfx_register(struct device *bdev)
531{
532 static int version_disp;
533 int dfx_bus_pci = dev_is_pci(bdev);
534 int dfx_bus_eisa = DFX_BUS_EISA(bdev);
535 const char *print_name = dev_name(bdev);
536 struct net_device *dev;
537 DFX_board_t *bp;
538 resource_size_t bar_start[3] = {0};
539 resource_size_t bar_len[3] = {0};
540 int alloc_size;
541 struct resource *region;
542 int err = 0;
543
544 if (!version_disp) {
545 version_disp = 1;
546 printk(version);
547 }
548
549 dev = alloc_fddidev(sizeof(*bp));
550 if (!dev) {
551 printk(KERN_ERR "%s: Unable to allocate fddidev, aborting\n",
552 print_name);
553 return -ENOMEM;
554 }
555
556
557 if (dfx_bus_pci) {
558 err = pci_enable_device(to_pci_dev(bdev));
559 if (err) {
560 pr_err("%s: Cannot enable PCI device, aborting\n",
561 print_name);
562 goto err_out;
563 }
564 }
565
566 SET_NETDEV_DEV(dev, bdev);
567
568 bp = netdev_priv(dev);
569 bp->bus_dev = bdev;
570 dev_set_drvdata(bdev, dev);
571
572 bp->mmio = true;
573
574 dfx_get_bars(bp, bar_start, bar_len);
575 if (bar_len[0] == 0 ||
576 (dfx_bus_eisa && dfx_use_mmio && bar_start[0] == 0)) {
577 bp->mmio = false;
578 dfx_get_bars(bp, bar_start, bar_len);
579 }
580
581 if (dfx_use_mmio) {
582 region = request_mem_region(bar_start[0], bar_len[0],
583 bdev->driver->name);
584 if (!region && (dfx_bus_eisa || dfx_bus_pci)) {
585 bp->mmio = false;
586 dfx_get_bars(bp, bar_start, bar_len);
587 }
588 }
589 if (!dfx_use_mmio)
590 region = request_region(bar_start[0], bar_len[0],
591 bdev->driver->name);
592 if (!region) {
593 dfx_register_res_err(print_name, dfx_use_mmio,
594 bar_start[0], bar_len[0]);
595 err = -EBUSY;
596 goto err_out_disable;
597 }
598 if (bar_start[1] != 0) {
599 region = request_region(bar_start[1], bar_len[1],
600 bdev->driver->name);
601 if (!region) {
602 dfx_register_res_err(print_name, 0,
603 bar_start[1], bar_len[1]);
604 err = -EBUSY;
605 goto err_out_csr_region;
606 }
607 }
608 if (bar_start[2] != 0) {
609 region = request_region(bar_start[2], bar_len[2],
610 bdev->driver->name);
611 if (!region) {
612 dfx_register_res_err(print_name, 0,
613 bar_start[2], bar_len[2]);
614 err = -EBUSY;
615 goto err_out_bh_region;
616 }
617 }
618
619
620 if (dfx_use_mmio) {
621 bp->base.mem = ioremap(bar_start[0], bar_len[0]);
622 if (!bp->base.mem) {
623 printk(KERN_ERR "%s: Cannot map MMIO\n", print_name);
624 err = -ENOMEM;
625 goto err_out_esic_region;
626 }
627 } else {
628 bp->base.port = bar_start[0];
629 dev->base_addr = bar_start[0];
630 }
631
632
633 dev->netdev_ops = &dfx_netdev_ops;
634
635 if (dfx_bus_pci)
636 pci_set_master(to_pci_dev(bdev));
637
638 if (dfx_driver_init(dev, print_name, bar_start[0]) != DFX_K_SUCCESS) {
639 err = -ENODEV;
640 goto err_out_unmap;
641 }
642
643 err = register_netdev(dev);
644 if (err)
645 goto err_out_kfree;
646
647 printk("%s: registered as %s\n", print_name, dev->name);
648 return 0;
649
650err_out_kfree:
651 alloc_size = sizeof(PI_DESCR_BLOCK) +
652 PI_CMD_REQ_K_SIZE_MAX + PI_CMD_RSP_K_SIZE_MAX +
653#ifndef DYNAMIC_BUFFERS
654 (bp->rcv_bufs_to_post * PI_RCV_DATA_K_SIZE_MAX) +
655#endif
656 sizeof(PI_CONSUMER_BLOCK) +
657 (PI_ALIGN_K_DESC_BLK - 1);
658 if (bp->kmalloced)
659 dma_free_coherent(bdev, alloc_size,
660 bp->kmalloced, bp->kmalloced_dma);
661
662err_out_unmap:
663 if (dfx_use_mmio)
664 iounmap(bp->base.mem);
665
666err_out_esic_region:
667 if (bar_start[2] != 0)
668 release_region(bar_start[2], bar_len[2]);
669
670err_out_bh_region:
671 if (bar_start[1] != 0)
672 release_region(bar_start[1], bar_len[1]);
673
674err_out_csr_region:
675 if (dfx_use_mmio)
676 release_mem_region(bar_start[0], bar_len[0]);
677 else
678 release_region(bar_start[0], bar_len[0]);
679
680err_out_disable:
681 if (dfx_bus_pci)
682 pci_disable_device(to_pci_dev(bdev));
683
684err_out:
685 free_netdev(dev);
686 return err;
687}
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721static void dfx_bus_init(struct net_device *dev)
722{
723 DFX_board_t *bp = netdev_priv(dev);
724 struct device *bdev = bp->bus_dev;
725 int dfx_bus_pci = dev_is_pci(bdev);
726 int dfx_bus_eisa = DFX_BUS_EISA(bdev);
727 int dfx_bus_tc = DFX_BUS_TC(bdev);
728 u8 val;
729
730 DBG_printk("In dfx_bus_init...\n");
731
732
733 bp->dev = dev;
734
735
736
737 if (dfx_bus_tc)
738 dev->irq = to_tc_dev(bdev)->interrupt;
739 if (dfx_bus_eisa) {
740 unsigned long base_addr = to_eisa_device(bdev)->base_addr;
741
742
743 outb(0, base_addr + PI_ESIC_K_SLOT_CNTRL);
744
745
746 val = inb(base_addr + PI_ESIC_K_IO_CONFIG_STAT_0);
747 val &= PI_CONFIG_STAT_0_M_IRQ;
748 val >>= PI_CONFIG_STAT_0_V_IRQ;
749
750 switch (val) {
751 case PI_CONFIG_STAT_0_IRQ_K_9:
752 dev->irq = 9;
753 break;
754
755 case PI_CONFIG_STAT_0_IRQ_K_10:
756 dev->irq = 10;
757 break;
758
759 case PI_CONFIG_STAT_0_IRQ_K_11:
760 dev->irq = 11;
761 break;
762
763 case PI_CONFIG_STAT_0_IRQ_K_15:
764 dev->irq = 15;
765 break;
766 }
767
768
769
770
771
772
773
774
775
776
777
778
779
780 val = 0;
781 outb(val, base_addr + PI_ESIC_K_IO_ADD_CMP_0_1);
782 val = PI_DEFEA_K_CSR_IO;
783 outb(val, base_addr + PI_ESIC_K_IO_ADD_CMP_0_0);
784
785 val = PI_IO_CMP_M_SLOT;
786 outb(val, base_addr + PI_ESIC_K_IO_ADD_MASK_0_1);
787 val = (PI_ESIC_K_CSR_IO_LEN - 1) & ~3;
788 outb(val, base_addr + PI_ESIC_K_IO_ADD_MASK_0_0);
789
790 val = 0;
791 outb(val, base_addr + PI_ESIC_K_IO_ADD_CMP_1_1);
792 val = PI_DEFEA_K_BURST_HOLDOFF;
793 outb(val, base_addr + PI_ESIC_K_IO_ADD_CMP_1_0);
794
795 val = PI_IO_CMP_M_SLOT;
796 outb(val, base_addr + PI_ESIC_K_IO_ADD_MASK_1_1);
797 val = (PI_ESIC_K_BURST_HOLDOFF_LEN - 1) & ~3;
798 outb(val, base_addr + PI_ESIC_K_IO_ADD_MASK_1_0);
799
800
801 val = PI_FUNCTION_CNTRL_M_IOCS1;
802 if (dfx_use_mmio)
803 val |= PI_FUNCTION_CNTRL_M_MEMCS1;
804 else
805 val |= PI_FUNCTION_CNTRL_M_IOCS0;
806 outb(val, base_addr + PI_ESIC_K_FUNCTION_CNTRL);
807
808
809
810
811
812 val = PI_SLOT_CNTRL_M_ENB;
813 outb(val, base_addr + PI_ESIC_K_SLOT_CNTRL);
814
815
816
817
818
819 val = inb(base_addr + PI_DEFEA_K_BURST_HOLDOFF);
820 if (dfx_use_mmio)
821 val |= PI_BURST_HOLDOFF_M_MEM_MAP;
822 else
823 val &= ~PI_BURST_HOLDOFF_M_MEM_MAP;
824 outb(val, base_addr + PI_DEFEA_K_BURST_HOLDOFF);
825
826
827 val = inb(base_addr + PI_ESIC_K_IO_CONFIG_STAT_0);
828 val |= PI_CONFIG_STAT_0_M_INT_ENB;
829 outb(val, base_addr + PI_ESIC_K_IO_CONFIG_STAT_0);
830 }
831 if (dfx_bus_pci) {
832 struct pci_dev *pdev = to_pci_dev(bdev);
833
834
835
836 dev->irq = pdev->irq;
837
838
839
840 pci_read_config_byte(pdev, PCI_LATENCY_TIMER, &val);
841 if (val < PFI_K_LAT_TIMER_MIN) {
842 val = PFI_K_LAT_TIMER_DEF;
843 pci_write_config_byte(pdev, PCI_LATENCY_TIMER, val);
844 }
845
846
847 val = PFI_MODE_M_PDQ_INT_ENB | PFI_MODE_M_DMA_ENB;
848 dfx_port_write_long(bp, PFI_K_REG_MODE_CTRL, val);
849 }
850}
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880static void dfx_bus_uninit(struct net_device *dev)
881{
882 DFX_board_t *bp = netdev_priv(dev);
883 struct device *bdev = bp->bus_dev;
884 int dfx_bus_pci = dev_is_pci(bdev);
885 int dfx_bus_eisa = DFX_BUS_EISA(bdev);
886 u8 val;
887
888 DBG_printk("In dfx_bus_uninit...\n");
889
890
891
892 if (dfx_bus_eisa) {
893 unsigned long base_addr = to_eisa_device(bdev)->base_addr;
894
895
896 val = inb(base_addr + PI_ESIC_K_IO_CONFIG_STAT_0);
897 val &= ~PI_CONFIG_STAT_0_M_INT_ENB;
898 outb(val, base_addr + PI_ESIC_K_IO_CONFIG_STAT_0);
899
900
901 outb(0, base_addr + PI_ESIC_K_SLOT_CNTRL);
902
903
904 outb(0, base_addr + PI_ESIC_K_FUNCTION_CNTRL);
905 }
906 if (dfx_bus_pci) {
907
908 dfx_port_write_long(bp, PFI_K_REG_MODE_CTRL, 0);
909 }
910}
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943static void dfx_bus_config_check(DFX_board_t *bp)
944{
945 struct device __maybe_unused *bdev = bp->bus_dev;
946 int dfx_bus_eisa = DFX_BUS_EISA(bdev);
947 int status;
948 u32 host_data;
949
950 DBG_printk("In dfx_bus_config_check...\n");
951
952
953
954 if (dfx_bus_eisa) {
955
956
957
958
959
960
961
962 if (to_eisa_device(bdev)->id.driver_data == DEFEA_PROD_ID_2) {
963
964
965
966
967 status = dfx_hw_port_ctrl_req(bp,
968 PI_PCTRL_M_SUB_CMD,
969 PI_SUB_CMD_K_PDQ_REV_GET,
970 0,
971 &host_data);
972 if ((status != DFX_K_SUCCESS) || (host_data == 2))
973 {
974
975
976
977
978
979
980
981
982 switch (bp->burst_size)
983 {
984 case PI_PDATA_B_DMA_BURST_SIZE_32:
985 case PI_PDATA_B_DMA_BURST_SIZE_16:
986 bp->burst_size = PI_PDATA_B_DMA_BURST_SIZE_8;
987 break;
988
989 default:
990 break;
991 }
992
993
994
995 bp->full_duplex_enb = PI_SNMP_K_FALSE;
996 }
997 }
998 }
999 }
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039static int dfx_driver_init(struct net_device *dev, const char *print_name,
1040 resource_size_t bar_start)
1041{
1042 DFX_board_t *bp = netdev_priv(dev);
1043 struct device *bdev = bp->bus_dev;
1044 int dfx_bus_pci = dev_is_pci(bdev);
1045 int dfx_bus_eisa = DFX_BUS_EISA(bdev);
1046 int dfx_bus_tc = DFX_BUS_TC(bdev);
1047 int alloc_size;
1048 char *top_v, *curr_v;
1049 dma_addr_t top_p, curr_p;
1050 u32 data;
1051 __le32 le32;
1052 char *board_name = NULL;
1053
1054 DBG_printk("In dfx_driver_init...\n");
1055
1056
1057
1058 dfx_bus_init(dev);
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069 bp->full_duplex_enb = PI_SNMP_K_FALSE;
1070 bp->req_ttrt = 8 * 12500;
1071 bp->burst_size = PI_PDATA_B_DMA_BURST_SIZE_DEF;
1072 bp->rcv_bufs_to_post = RCV_BUFS_DEF;
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083 dfx_bus_config_check(bp);
1084
1085
1086
1087 dfx_port_write_long(bp, PI_PDQ_K_REG_HOST_INT_ENB, PI_HOST_INT_K_DISABLE_ALL_INTS);
1088
1089
1090
1091 (void) dfx_hw_dma_uninit(bp, PI_PDATA_A_RESET_M_SKIP_ST);
1092
1093
1094
1095 if (dfx_hw_port_ctrl_req(bp, PI_PCTRL_M_MLA, PI_PDATA_A_MLA_K_LO, 0,
1096 &data) != DFX_K_SUCCESS) {
1097 printk("%s: Could not read adapter factory MAC address!\n",
1098 print_name);
1099 return DFX_K_FAILURE;
1100 }
1101 le32 = cpu_to_le32(data);
1102 memcpy(&bp->factory_mac_addr[0], &le32, sizeof(u32));
1103
1104 if (dfx_hw_port_ctrl_req(bp, PI_PCTRL_M_MLA, PI_PDATA_A_MLA_K_HI, 0,
1105 &data) != DFX_K_SUCCESS) {
1106 printk("%s: Could not read adapter factory MAC address!\n",
1107 print_name);
1108 return DFX_K_FAILURE;
1109 }
1110 le32 = cpu_to_le32(data);
1111 memcpy(&bp->factory_mac_addr[4], &le32, sizeof(u16));
1112
1113
1114
1115
1116
1117
1118
1119
1120 dev_addr_set(dev, bp->factory_mac_addr);
1121 if (dfx_bus_tc)
1122 board_name = "DEFTA";
1123 if (dfx_bus_eisa)
1124 board_name = "DEFEA";
1125 if (dfx_bus_pci)
1126 board_name = "DEFPA";
1127 pr_info("%s: %s at %s addr = 0x%llx, IRQ = %d, Hardware addr = %pMF\n",
1128 print_name, board_name, dfx_use_mmio ? "MMIO" : "I/O",
1129 (long long)bar_start, dev->irq, dev->dev_addr);
1130
1131
1132
1133
1134
1135
1136 alloc_size = sizeof(PI_DESCR_BLOCK) +
1137 PI_CMD_REQ_K_SIZE_MAX +
1138 PI_CMD_RSP_K_SIZE_MAX +
1139#ifndef DYNAMIC_BUFFERS
1140 (bp->rcv_bufs_to_post * PI_RCV_DATA_K_SIZE_MAX) +
1141#endif
1142 sizeof(PI_CONSUMER_BLOCK) +
1143 (PI_ALIGN_K_DESC_BLK - 1);
1144 bp->kmalloced = top_v = dma_alloc_coherent(bp->bus_dev, alloc_size,
1145 &bp->kmalloced_dma,
1146 GFP_ATOMIC);
1147 if (top_v == NULL)
1148 return DFX_K_FAILURE;
1149
1150 top_p = bp->kmalloced_dma;
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164 curr_p = ALIGN(top_p, PI_ALIGN_K_DESC_BLK);
1165 curr_v = top_v + (curr_p - top_p);
1166
1167
1168
1169 bp->descr_block_virt = (PI_DESCR_BLOCK *) curr_v;
1170 bp->descr_block_phys = curr_p;
1171 curr_v += sizeof(PI_DESCR_BLOCK);
1172 curr_p += sizeof(PI_DESCR_BLOCK);
1173
1174
1175
1176 bp->cmd_req_virt = (PI_DMA_CMD_REQ *) curr_v;
1177 bp->cmd_req_phys = curr_p;
1178 curr_v += PI_CMD_REQ_K_SIZE_MAX;
1179 curr_p += PI_CMD_REQ_K_SIZE_MAX;
1180
1181
1182
1183 bp->cmd_rsp_virt = (PI_DMA_CMD_RSP *) curr_v;
1184 bp->cmd_rsp_phys = curr_p;
1185 curr_v += PI_CMD_RSP_K_SIZE_MAX;
1186 curr_p += PI_CMD_RSP_K_SIZE_MAX;
1187
1188
1189
1190 bp->rcv_block_virt = curr_v;
1191 bp->rcv_block_phys = curr_p;
1192
1193#ifndef DYNAMIC_BUFFERS
1194 curr_v += (bp->rcv_bufs_to_post * PI_RCV_DATA_K_SIZE_MAX);
1195 curr_p += (bp->rcv_bufs_to_post * PI_RCV_DATA_K_SIZE_MAX);
1196#endif
1197
1198
1199
1200 bp->cons_block_virt = (PI_CONSUMER_BLOCK *) curr_v;
1201 bp->cons_block_phys = curr_p;
1202
1203
1204
1205 DBG_printk("%s: Descriptor block virt = %p, phys = %pad\n",
1206 print_name, bp->descr_block_virt, &bp->descr_block_phys);
1207 DBG_printk("%s: Command Request buffer virt = %p, phys = %pad\n",
1208 print_name, bp->cmd_req_virt, &bp->cmd_req_phys);
1209 DBG_printk("%s: Command Response buffer virt = %p, phys = %pad\n",
1210 print_name, bp->cmd_rsp_virt, &bp->cmd_rsp_phys);
1211 DBG_printk("%s: Receive buffer block virt = %p, phys = %pad\n",
1212 print_name, bp->rcv_block_virt, &bp->rcv_block_phys);
1213 DBG_printk("%s: Consumer block virt = %p, phys = %pad\n",
1214 print_name, bp->cons_block_virt, &bp->cons_block_phys);
1215
1216 return DFX_K_SUCCESS;
1217}
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253static int dfx_adap_init(DFX_board_t *bp, int get_buffers)
1254 {
1255 DBG_printk("In dfx_adap_init...\n");
1256
1257
1258
1259 dfx_port_write_long(bp, PI_PDQ_K_REG_HOST_INT_ENB, PI_HOST_INT_K_DISABLE_ALL_INTS);
1260
1261
1262
1263 if (dfx_hw_dma_uninit(bp, bp->reset_type) != DFX_K_SUCCESS)
1264 {
1265 printk("%s: Could not uninitialize/reset adapter!\n", bp->dev->name);
1266 return DFX_K_FAILURE;
1267 }
1268
1269
1270
1271
1272
1273
1274 dfx_port_write_long(bp, PI_PDQ_K_REG_TYPE_0_STATUS, PI_HOST_INT_K_ACK_ALL_TYPE_0);
1275
1276
1277
1278
1279
1280
1281
1282
1283 bp->cmd_req_reg.lword = 0;
1284 bp->cmd_rsp_reg.lword = 0;
1285 bp->rcv_xmt_reg.lword = 0;
1286
1287
1288
1289 memset(bp->cons_block_virt, 0, sizeof(PI_CONSUMER_BLOCK));
1290
1291
1292
1293 if (dfx_hw_port_ctrl_req(bp,
1294 PI_PCTRL_M_SUB_CMD,
1295 PI_SUB_CMD_K_BURST_SIZE_SET,
1296 bp->burst_size,
1297 NULL) != DFX_K_SUCCESS)
1298 {
1299 printk("%s: Could not set adapter burst size!\n", bp->dev->name);
1300 return DFX_K_FAILURE;
1301 }
1302
1303
1304
1305
1306
1307
1308
1309
1310 if (dfx_hw_port_ctrl_req(bp,
1311 PI_PCTRL_M_CONS_BLOCK,
1312 bp->cons_block_phys,
1313 0,
1314 NULL) != DFX_K_SUCCESS)
1315 {
1316 printk("%s: Could not set consumer block address!\n", bp->dev->name);
1317 return DFX_K_FAILURE;
1318 }
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330 if (dfx_hw_port_ctrl_req(bp, PI_PCTRL_M_INIT,
1331 (u32)(bp->descr_block_phys |
1332 PI_PDATA_A_INIT_M_BSWAP_INIT),
1333 0, NULL) != DFX_K_SUCCESS) {
1334 printk("%s: Could not set descriptor block address!\n",
1335 bp->dev->name);
1336 return DFX_K_FAILURE;
1337 }
1338
1339
1340
1341 bp->cmd_req_virt->cmd_type = PI_CMD_K_CHARS_SET;
1342 bp->cmd_req_virt->char_set.item[0].item_code = PI_ITEM_K_FLUSH_TIME;
1343 bp->cmd_req_virt->char_set.item[0].value = 3;
1344 bp->cmd_req_virt->char_set.item[0].item_index = 0;
1345 bp->cmd_req_virt->char_set.item[1].item_code = PI_ITEM_K_EOL;
1346 if (dfx_hw_dma_cmd_req(bp) != DFX_K_SUCCESS)
1347 {
1348 printk("%s: DMA command request failed!\n", bp->dev->name);
1349 return DFX_K_FAILURE;
1350 }
1351
1352
1353
1354 bp->cmd_req_virt->cmd_type = PI_CMD_K_SNMP_SET;
1355 bp->cmd_req_virt->snmp_set.item[0].item_code = PI_ITEM_K_FDX_ENB_DIS;
1356 bp->cmd_req_virt->snmp_set.item[0].value = bp->full_duplex_enb;
1357 bp->cmd_req_virt->snmp_set.item[0].item_index = 0;
1358 bp->cmd_req_virt->snmp_set.item[1].item_code = PI_ITEM_K_MAC_T_REQ;
1359 bp->cmd_req_virt->snmp_set.item[1].value = bp->req_ttrt;
1360 bp->cmd_req_virt->snmp_set.item[1].item_index = 0;
1361 bp->cmd_req_virt->snmp_set.item[2].item_code = PI_ITEM_K_EOL;
1362 if (dfx_hw_dma_cmd_req(bp) != DFX_K_SUCCESS)
1363 {
1364 printk("%s: DMA command request failed!\n", bp->dev->name);
1365 return DFX_K_FAILURE;
1366 }
1367
1368
1369
1370 if (dfx_ctl_update_cam(bp) != DFX_K_SUCCESS)
1371 {
1372 printk("%s: Adapter CAM update failed!\n", bp->dev->name);
1373 return DFX_K_FAILURE;
1374 }
1375
1376
1377
1378 if (dfx_ctl_update_filters(bp) != DFX_K_SUCCESS)
1379 {
1380 printk("%s: Adapter filters update failed!\n", bp->dev->name);
1381 return DFX_K_FAILURE;
1382 }
1383
1384
1385
1386
1387
1388
1389 if (get_buffers)
1390 dfx_rcv_flush(bp);
1391
1392
1393
1394 if (dfx_rcv_init(bp, get_buffers))
1395 {
1396 printk("%s: Receive buffer allocation failed\n", bp->dev->name);
1397 if (get_buffers)
1398 dfx_rcv_flush(bp);
1399 return DFX_K_FAILURE;
1400 }
1401
1402
1403
1404 bp->cmd_req_virt->cmd_type = PI_CMD_K_START;
1405 if (dfx_hw_dma_cmd_req(bp) != DFX_K_SUCCESS)
1406 {
1407 printk("%s: Start command failed\n", bp->dev->name);
1408 if (get_buffers)
1409 dfx_rcv_flush(bp);
1410 return DFX_K_FAILURE;
1411 }
1412
1413
1414
1415 dfx_port_write_long(bp, PI_PDQ_K_REG_HOST_INT_ENB, PI_HOST_INT_K_ENABLE_DEF_INTS);
1416 return DFX_K_SUCCESS;
1417 }
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450static int dfx_open(struct net_device *dev)
1451{
1452 DFX_board_t *bp = netdev_priv(dev);
1453 int ret;
1454
1455 DBG_printk("In dfx_open...\n");
1456
1457
1458
1459 ret = request_irq(dev->irq, dfx_interrupt, IRQF_SHARED, dev->name,
1460 dev);
1461 if (ret) {
1462 printk(KERN_ERR "%s: Requested IRQ %d is busy\n", dev->name, dev->irq);
1463 return ret;
1464 }
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477 dev_addr_set(dev, bp->factory_mac_addr);
1478
1479
1480
1481 memset(bp->uc_table, 0, sizeof(bp->uc_table));
1482 memset(bp->mc_table, 0, sizeof(bp->mc_table));
1483 bp->uc_count = 0;
1484 bp->mc_count = 0;
1485
1486
1487
1488 bp->ind_group_prom = PI_FSTATE_K_BLOCK;
1489 bp->group_prom = PI_FSTATE_K_BLOCK;
1490
1491 spin_lock_init(&bp->lock);
1492
1493
1494
1495 bp->reset_type = PI_PDATA_A_RESET_M_SKIP_ST;
1496 if (dfx_adap_init(bp, 1) != DFX_K_SUCCESS)
1497 {
1498 printk(KERN_ERR "%s: Adapter open failed!\n", dev->name);
1499 free_irq(dev->irq, dev);
1500 return -EAGAIN;
1501 }
1502
1503
1504 netif_start_queue(dev);
1505 return 0;
1506}
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541static int dfx_close(struct net_device *dev)
1542{
1543 DFX_board_t *bp = netdev_priv(dev);
1544
1545 DBG_printk("In dfx_close...\n");
1546
1547
1548
1549 dfx_port_write_long(bp, PI_PDQ_K_REG_HOST_INT_ENB, PI_HOST_INT_K_DISABLE_ALL_INTS);
1550
1551
1552
1553 (void) dfx_hw_dma_uninit(bp, PI_PDATA_A_RESET_M_SKIP_ST);
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564 dfx_xmt_flush(bp);
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577 bp->cmd_req_reg.lword = 0;
1578 bp->cmd_rsp_reg.lword = 0;
1579 bp->rcv_xmt_reg.lword = 0;
1580
1581
1582
1583 memset(bp->cons_block_virt, 0, sizeof(PI_CONSUMER_BLOCK));
1584
1585
1586
1587 dfx_rcv_flush(bp);
1588
1589
1590
1591 netif_stop_queue(dev);
1592
1593
1594
1595 free_irq(dev->irq, dev);
1596
1597 return 0;
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
1628static void dfx_int_pr_halt_id(DFX_board_t *bp)
1629 {
1630 PI_UINT32 port_status;
1631 PI_UINT32 halt_id;
1632
1633
1634
1635 dfx_port_read_long(bp, PI_PDQ_K_REG_PORT_STATUS, &port_status);
1636
1637
1638
1639 halt_id = (port_status & PI_PSTATUS_M_HALT_ID) >> PI_PSTATUS_V_HALT_ID;
1640 switch (halt_id)
1641 {
1642 case PI_HALT_ID_K_SELFTEST_TIMEOUT:
1643 printk("%s: Halt ID: Selftest Timeout\n", bp->dev->name);
1644 break;
1645
1646 case PI_HALT_ID_K_PARITY_ERROR:
1647 printk("%s: Halt ID: Host Bus Parity Error\n", bp->dev->name);
1648 break;
1649
1650 case PI_HALT_ID_K_HOST_DIR_HALT:
1651 printk("%s: Halt ID: Host-Directed Halt\n", bp->dev->name);
1652 break;
1653
1654 case PI_HALT_ID_K_SW_FAULT:
1655 printk("%s: Halt ID: Adapter Software Fault\n", bp->dev->name);
1656 break;
1657
1658 case PI_HALT_ID_K_HW_FAULT:
1659 printk("%s: Halt ID: Adapter Hardware Fault\n", bp->dev->name);
1660 break;
1661
1662 case PI_HALT_ID_K_PC_TRACE:
1663 printk("%s: Halt ID: FDDI Network PC Trace Path Test\n", bp->dev->name);
1664 break;
1665
1666 case PI_HALT_ID_K_DMA_ERROR:
1667 printk("%s: Halt ID: Adapter DMA Error\n", bp->dev->name);
1668 break;
1669
1670 case PI_HALT_ID_K_IMAGE_CRC_ERROR:
1671 printk("%s: Halt ID: Firmware Image CRC Error\n", bp->dev->name);
1672 break;
1673
1674 case PI_HALT_ID_K_BUS_EXCEPTION:
1675 printk("%s: Halt ID: 68000 Bus Exception\n", bp->dev->name);
1676 break;
1677
1678 default:
1679 printk("%s: Halt ID: Unknown (code = %X)\n", bp->dev->name, halt_id);
1680 break;
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
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732static void dfx_int_type_0_process(DFX_board_t *bp)
1733
1734 {
1735 PI_UINT32 type_0_status;
1736 PI_UINT32 state;
1737
1738
1739
1740
1741
1742
1743
1744 dfx_port_read_long(bp, PI_PDQ_K_REG_TYPE_0_STATUS, &type_0_status);
1745 dfx_port_write_long(bp, PI_PDQ_K_REG_TYPE_0_STATUS, type_0_status);
1746
1747
1748
1749 if (type_0_status & (PI_TYPE_0_STAT_M_NXM |
1750 PI_TYPE_0_STAT_M_PM_PAR_ERR |
1751 PI_TYPE_0_STAT_M_BUS_PAR_ERR))
1752 {
1753
1754
1755 if (type_0_status & PI_TYPE_0_STAT_M_NXM)
1756 printk("%s: Non-Existent Memory Access Error\n", bp->dev->name);
1757
1758
1759
1760 if (type_0_status & PI_TYPE_0_STAT_M_PM_PAR_ERR)
1761 printk("%s: Packet Memory Parity Error\n", bp->dev->name);
1762
1763
1764
1765 if (type_0_status & PI_TYPE_0_STAT_M_BUS_PAR_ERR)
1766 printk("%s: Host Bus Parity Error\n", bp->dev->name);
1767
1768
1769
1770 bp->link_available = PI_K_FALSE;
1771 bp->reset_type = 0;
1772 printk("%s: Resetting adapter...\n", bp->dev->name);
1773 if (dfx_adap_init(bp, 0) != DFX_K_SUCCESS)
1774 {
1775 printk("%s: Adapter reset failed! Disabling adapter interrupts.\n", bp->dev->name);
1776 dfx_port_write_long(bp, PI_PDQ_K_REG_HOST_INT_ENB, PI_HOST_INT_K_DISABLE_ALL_INTS);
1777 return;
1778 }
1779 printk("%s: Adapter reset successful!\n", bp->dev->name);
1780 return;
1781 }
1782
1783
1784
1785 if (type_0_status & PI_TYPE_0_STAT_M_XMT_FLUSH)
1786 {
1787
1788
1789 bp->link_available = PI_K_FALSE;
1790 dfx_xmt_flush(bp);
1791 (void) dfx_hw_port_ctrl_req(bp,
1792 PI_PCTRL_M_XMT_DATA_FLUSH_DONE,
1793 0,
1794 0,
1795 NULL);
1796 }
1797
1798
1799
1800 if (type_0_status & PI_TYPE_0_STAT_M_STATE_CHANGE)
1801 {
1802
1803
1804 state = dfx_hw_adap_state_rd(bp);
1805 if (state == PI_STATE_K_HALTED)
1806 {
1807
1808
1809
1810
1811
1812
1813 printk("%s: Controller has transitioned to HALTED state!\n", bp->dev->name);
1814 dfx_int_pr_halt_id(bp);
1815
1816
1817
1818 bp->link_available = PI_K_FALSE;
1819 bp->reset_type = 0;
1820 printk("%s: Resetting adapter...\n", bp->dev->name);
1821 if (dfx_adap_init(bp, 0) != DFX_K_SUCCESS)
1822 {
1823 printk("%s: Adapter reset failed! Disabling adapter interrupts.\n", bp->dev->name);
1824 dfx_port_write_long(bp, PI_PDQ_K_REG_HOST_INT_ENB, PI_HOST_INT_K_DISABLE_ALL_INTS);
1825 return;
1826 }
1827 printk("%s: Adapter reset successful!\n", bp->dev->name);
1828 }
1829 else if (state == PI_STATE_K_LINK_AVAIL)
1830 {
1831 bp->link_available = PI_K_TRUE;
1832 }
1833 }
1834 }
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877static void dfx_int_common(struct net_device *dev)
1878{
1879 DFX_board_t *bp = netdev_priv(dev);
1880 PI_UINT32 port_status;
1881
1882
1883
1884 if(dfx_xmt_done(bp))
1885 netif_wake_queue(dev);
1886
1887
1888
1889 dfx_rcv_queue_process(bp);
1890
1891
1892
1893
1894
1895
1896
1897
1898 dfx_port_write_long(bp, PI_PDQ_K_REG_TYPE_2_PROD, bp->rcv_xmt_reg.lword);
1899
1900
1901
1902 dfx_port_read_long(bp, PI_PDQ_K_REG_PORT_STATUS, &port_status);
1903
1904
1905
1906 if (port_status & PI_PSTATUS_M_TYPE_0_PENDING)
1907 dfx_int_type_0_process(bp);
1908 }
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947static irqreturn_t dfx_interrupt(int irq, void *dev_id)
1948{
1949 struct net_device *dev = dev_id;
1950 DFX_board_t *bp = netdev_priv(dev);
1951 struct device *bdev = bp->bus_dev;
1952 int dfx_bus_pci = dev_is_pci(bdev);
1953 int dfx_bus_eisa = DFX_BUS_EISA(bdev);
1954 int dfx_bus_tc = DFX_BUS_TC(bdev);
1955
1956
1957
1958 if (dfx_bus_pci) {
1959 u32 status;
1960
1961 dfx_port_read_long(bp, PFI_K_REG_STATUS, &status);
1962 if (!(status & PFI_STATUS_M_PDQ_INT))
1963 return IRQ_NONE;
1964
1965 spin_lock(&bp->lock);
1966
1967
1968 dfx_port_write_long(bp, PFI_K_REG_MODE_CTRL,
1969 PFI_MODE_M_DMA_ENB);
1970
1971
1972 dfx_int_common(dev);
1973
1974
1975 dfx_port_write_long(bp, PFI_K_REG_STATUS,
1976 PFI_STATUS_M_PDQ_INT);
1977 dfx_port_write_long(bp, PFI_K_REG_MODE_CTRL,
1978 (PFI_MODE_M_PDQ_INT_ENB |
1979 PFI_MODE_M_DMA_ENB));
1980
1981 spin_unlock(&bp->lock);
1982 }
1983 if (dfx_bus_eisa) {
1984 unsigned long base_addr = to_eisa_device(bdev)->base_addr;
1985 u8 status;
1986
1987 status = inb(base_addr + PI_ESIC_K_IO_CONFIG_STAT_0);
1988 if (!(status & PI_CONFIG_STAT_0_M_PEND))
1989 return IRQ_NONE;
1990
1991 spin_lock(&bp->lock);
1992
1993
1994 status &= ~PI_CONFIG_STAT_0_M_INT_ENB;
1995 outb(status, base_addr + PI_ESIC_K_IO_CONFIG_STAT_0);
1996
1997
1998 dfx_int_common(dev);
1999
2000
2001 status = inb(base_addr + PI_ESIC_K_IO_CONFIG_STAT_0);
2002 status |= PI_CONFIG_STAT_0_M_INT_ENB;
2003 outb(status, base_addr + PI_ESIC_K_IO_CONFIG_STAT_0);
2004
2005 spin_unlock(&bp->lock);
2006 }
2007 if (dfx_bus_tc) {
2008 u32 status;
2009
2010 dfx_port_read_long(bp, PI_PDQ_K_REG_PORT_STATUS, &status);
2011 if (!(status & (PI_PSTATUS_M_RCV_DATA_PENDING |
2012 PI_PSTATUS_M_XMT_DATA_PENDING |
2013 PI_PSTATUS_M_SMT_HOST_PENDING |
2014 PI_PSTATUS_M_UNSOL_PENDING |
2015 PI_PSTATUS_M_CMD_RSP_PENDING |
2016 PI_PSTATUS_M_CMD_REQ_PENDING |
2017 PI_PSTATUS_M_TYPE_0_PENDING)))
2018 return IRQ_NONE;
2019
2020 spin_lock(&bp->lock);
2021
2022
2023 dfx_int_common(dev);
2024
2025 spin_unlock(&bp->lock);
2026 }
2027
2028 return IRQ_HANDLED;
2029}
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075static struct net_device_stats *dfx_ctl_get_stats(struct net_device *dev)
2076 {
2077 DFX_board_t *bp = netdev_priv(dev);
2078
2079
2080
2081 bp->stats.gen.rx_packets = bp->rcv_total_frames;
2082 bp->stats.gen.tx_packets = bp->xmt_total_frames;
2083 bp->stats.gen.rx_bytes = bp->rcv_total_bytes;
2084 bp->stats.gen.tx_bytes = bp->xmt_total_bytes;
2085 bp->stats.gen.rx_errors = bp->rcv_crc_errors +
2086 bp->rcv_frame_status_errors +
2087 bp->rcv_length_errors;
2088 bp->stats.gen.tx_errors = bp->xmt_length_errors;
2089 bp->stats.gen.rx_dropped = bp->rcv_discards;
2090 bp->stats.gen.tx_dropped = bp->xmt_discards;
2091 bp->stats.gen.multicast = bp->rcv_multicast_frames;
2092 bp->stats.gen.collisions = 0;
2093
2094
2095
2096 bp->cmd_req_virt->cmd_type = PI_CMD_K_SMT_MIB_GET;
2097 if (dfx_hw_dma_cmd_req(bp) != DFX_K_SUCCESS)
2098 return (struct net_device_stats *)&bp->stats;
2099
2100
2101
2102 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));
2103 bp->stats.smt_op_version_id = bp->cmd_rsp_virt->smt_mib_get.smt_op_version_id;
2104 bp->stats.smt_hi_version_id = bp->cmd_rsp_virt->smt_mib_get.smt_hi_version_id;
2105 bp->stats.smt_lo_version_id = bp->cmd_rsp_virt->smt_mib_get.smt_lo_version_id;
2106 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));
2107 bp->stats.smt_mib_version_id = bp->cmd_rsp_virt->smt_mib_get.smt_mib_version_id;
2108 bp->stats.smt_mac_cts = bp->cmd_rsp_virt->smt_mib_get.smt_mac_ct;
2109 bp->stats.smt_non_master_cts = bp->cmd_rsp_virt->smt_mib_get.smt_non_master_ct;
2110 bp->stats.smt_master_cts = bp->cmd_rsp_virt->smt_mib_get.smt_master_ct;
2111 bp->stats.smt_available_paths = bp->cmd_rsp_virt->smt_mib_get.smt_available_paths;
2112 bp->stats.smt_config_capabilities = bp->cmd_rsp_virt->smt_mib_get.smt_config_capabilities;
2113 bp->stats.smt_config_policy = bp->cmd_rsp_virt->smt_mib_get.smt_config_policy;
2114 bp->stats.smt_connection_policy = bp->cmd_rsp_virt->smt_mib_get.smt_connection_policy;
2115 bp->stats.smt_t_notify = bp->cmd_rsp_virt->smt_mib_get.smt_t_notify;
2116 bp->stats.smt_stat_rpt_policy = bp->cmd_rsp_virt->smt_mib_get.smt_stat_rpt_policy;
2117 bp->stats.smt_trace_max_expiration = bp->cmd_rsp_virt->smt_mib_get.smt_trace_max_expiration;
2118 bp->stats.smt_bypass_present = bp->cmd_rsp_virt->smt_mib_get.smt_bypass_present;
2119 bp->stats.smt_ecm_state = bp->cmd_rsp_virt->smt_mib_get.smt_ecm_state;
2120 bp->stats.smt_cf_state = bp->cmd_rsp_virt->smt_mib_get.smt_cf_state;
2121 bp->stats.smt_remote_disconnect_flag = bp->cmd_rsp_virt->smt_mib_get.smt_remote_disconnect_flag;
2122 bp->stats.smt_station_status = bp->cmd_rsp_virt->smt_mib_get.smt_station_status;
2123 bp->stats.smt_peer_wrap_flag = bp->cmd_rsp_virt->smt_mib_get.smt_peer_wrap_flag;
2124 bp->stats.smt_time_stamp = bp->cmd_rsp_virt->smt_mib_get.smt_msg_time_stamp.ls;
2125 bp->stats.smt_transition_time_stamp = bp->cmd_rsp_virt->smt_mib_get.smt_transition_time_stamp.ls;
2126 bp->stats.mac_frame_status_functions = bp->cmd_rsp_virt->smt_mib_get.mac_frame_status_functions;
2127 bp->stats.mac_t_max_capability = bp->cmd_rsp_virt->smt_mib_get.mac_t_max_capability;
2128 bp->stats.mac_tvx_capability = bp->cmd_rsp_virt->smt_mib_get.mac_tvx_capability;
2129 bp->stats.mac_available_paths = bp->cmd_rsp_virt->smt_mib_get.mac_available_paths;
2130 bp->stats.mac_current_path = bp->cmd_rsp_virt->smt_mib_get.mac_current_path;
2131 memcpy(bp->stats.mac_upstream_nbr, &bp->cmd_rsp_virt->smt_mib_get.mac_upstream_nbr, FDDI_K_ALEN);
2132 memcpy(bp->stats.mac_downstream_nbr, &bp->cmd_rsp_virt->smt_mib_get.mac_downstream_nbr, FDDI_K_ALEN);
2133 memcpy(bp->stats.mac_old_upstream_nbr, &bp->cmd_rsp_virt->smt_mib_get.mac_old_upstream_nbr, FDDI_K_ALEN);
2134 memcpy(bp->stats.mac_old_downstream_nbr, &bp->cmd_rsp_virt->smt_mib_get.mac_old_downstream_nbr, FDDI_K_ALEN);
2135 bp->stats.mac_dup_address_test = bp->cmd_rsp_virt->smt_mib_get.mac_dup_address_test;
2136 bp->stats.mac_requested_paths = bp->cmd_rsp_virt->smt_mib_get.mac_requested_paths;
2137 bp->stats.mac_downstream_port_type = bp->cmd_rsp_virt->smt_mib_get.mac_downstream_port_type;
2138 memcpy(bp->stats.mac_smt_address, &bp->cmd_rsp_virt->smt_mib_get.mac_smt_address, FDDI_K_ALEN);
2139 bp->stats.mac_t_req = bp->cmd_rsp_virt->smt_mib_get.mac_t_req;
2140 bp->stats.mac_t_neg = bp->cmd_rsp_virt->smt_mib_get.mac_t_neg;
2141 bp->stats.mac_t_max = bp->cmd_rsp_virt->smt_mib_get.mac_t_max;
2142 bp->stats.mac_tvx_value = bp->cmd_rsp_virt->smt_mib_get.mac_tvx_value;
2143 bp->stats.mac_frame_error_threshold = bp->cmd_rsp_virt->smt_mib_get.mac_frame_error_threshold;
2144 bp->stats.mac_frame_error_ratio = bp->cmd_rsp_virt->smt_mib_get.mac_frame_error_ratio;
2145 bp->stats.mac_rmt_state = bp->cmd_rsp_virt->smt_mib_get.mac_rmt_state;
2146 bp->stats.mac_da_flag = bp->cmd_rsp_virt->smt_mib_get.mac_da_flag;
2147 bp->stats.mac_una_da_flag = bp->cmd_rsp_virt->smt_mib_get.mac_unda_flag;
2148 bp->stats.mac_frame_error_flag = bp->cmd_rsp_virt->smt_mib_get.mac_frame_error_flag;
2149 bp->stats.mac_ma_unitdata_available = bp->cmd_rsp_virt->smt_mib_get.mac_ma_unitdata_available;
2150 bp->stats.mac_hardware_present = bp->cmd_rsp_virt->smt_mib_get.mac_hardware_present;
2151 bp->stats.mac_ma_unitdata_enable = bp->cmd_rsp_virt->smt_mib_get.mac_ma_unitdata_enable;
2152 bp->stats.path_tvx_lower_bound = bp->cmd_rsp_virt->smt_mib_get.path_tvx_lower_bound;
2153 bp->stats.path_t_max_lower_bound = bp->cmd_rsp_virt->smt_mib_get.path_t_max_lower_bound;
2154 bp->stats.path_max_t_req = bp->cmd_rsp_virt->smt_mib_get.path_max_t_req;
2155 memcpy(bp->stats.path_configuration, &bp->cmd_rsp_virt->smt_mib_get.path_configuration, sizeof(bp->cmd_rsp_virt->smt_mib_get.path_configuration));
2156 bp->stats.port_my_type[0] = bp->cmd_rsp_virt->smt_mib_get.port_my_type[0];
2157 bp->stats.port_my_type[1] = bp->cmd_rsp_virt->smt_mib_get.port_my_type[1];
2158 bp->stats.port_neighbor_type[0] = bp->cmd_rsp_virt->smt_mib_get.port_neighbor_type[0];
2159 bp->stats.port_neighbor_type[1] = bp->cmd_rsp_virt->smt_mib_get.port_neighbor_type[1];
2160 bp->stats.port_connection_policies[0] = bp->cmd_rsp_virt->smt_mib_get.port_connection_policies[0];
2161 bp->stats.port_connection_policies[1] = bp->cmd_rsp_virt->smt_mib_get.port_connection_policies[1];
2162 bp->stats.port_mac_indicated[0] = bp->cmd_rsp_virt->smt_mib_get.port_mac_indicated[0];
2163 bp->stats.port_mac_indicated[1] = bp->cmd_rsp_virt->smt_mib_get.port_mac_indicated[1];
2164 bp->stats.port_current_path[0] = bp->cmd_rsp_virt->smt_mib_get.port_current_path[0];
2165 bp->stats.port_current_path[1] = bp->cmd_rsp_virt->smt_mib_get.port_current_path[1];
2166 memcpy(&bp->stats.port_requested_paths[0*3], &bp->cmd_rsp_virt->smt_mib_get.port_requested_paths[0], 3);
2167 memcpy(&bp->stats.port_requested_paths[1*3], &bp->cmd_rsp_virt->smt_mib_get.port_requested_paths[1], 3);
2168 bp->stats.port_mac_placement[0] = bp->cmd_rsp_virt->smt_mib_get.port_mac_placement[0];
2169 bp->stats.port_mac_placement[1] = bp->cmd_rsp_virt->smt_mib_get.port_mac_placement[1];
2170 bp->stats.port_available_paths[0] = bp->cmd_rsp_virt->smt_mib_get.port_available_paths[0];
2171 bp->stats.port_available_paths[1] = bp->cmd_rsp_virt->smt_mib_get.port_available_paths[1];
2172 bp->stats.port_pmd_class[0] = bp->cmd_rsp_virt->smt_mib_get.port_pmd_class[0];
2173 bp->stats.port_pmd_class[1] = bp->cmd_rsp_virt->smt_mib_get.port_pmd_class[1];
2174 bp->stats.port_connection_capabilities[0] = bp->cmd_rsp_virt->smt_mib_get.port_connection_capabilities[0];
2175 bp->stats.port_connection_capabilities[1] = bp->cmd_rsp_virt->smt_mib_get.port_connection_capabilities[1];
2176 bp->stats.port_bs_flag[0] = bp->cmd_rsp_virt->smt_mib_get.port_bs_flag[0];
2177 bp->stats.port_bs_flag[1] = bp->cmd_rsp_virt->smt_mib_get.port_bs_flag[1];
2178 bp->stats.port_ler_estimate[0] = bp->cmd_rsp_virt->smt_mib_get.port_ler_estimate[0];
2179 bp->stats.port_ler_estimate[1] = bp->cmd_rsp_virt->smt_mib_get.port_ler_estimate[1];
2180 bp->stats.port_ler_cutoff[0] = bp->cmd_rsp_virt->smt_mib_get.port_ler_cutoff[0];
2181 bp->stats.port_ler_cutoff[1] = bp->cmd_rsp_virt->smt_mib_get.port_ler_cutoff[1];
2182 bp->stats.port_ler_alarm[0] = bp->cmd_rsp_virt->smt_mib_get.port_ler_alarm[0];
2183 bp->stats.port_ler_alarm[1] = bp->cmd_rsp_virt->smt_mib_get.port_ler_alarm[1];
2184 bp->stats.port_connect_state[0] = bp->cmd_rsp_virt->smt_mib_get.port_connect_state[0];
2185 bp->stats.port_connect_state[1] = bp->cmd_rsp_virt->smt_mib_get.port_connect_state[1];
2186 bp->stats.port_pcm_state[0] = bp->cmd_rsp_virt->smt_mib_get.port_pcm_state[0];
2187 bp->stats.port_pcm_state[1] = bp->cmd_rsp_virt->smt_mib_get.port_pcm_state[1];
2188 bp->stats.port_pc_withhold[0] = bp->cmd_rsp_virt->smt_mib_get.port_pc_withhold[0];
2189 bp->stats.port_pc_withhold[1] = bp->cmd_rsp_virt->smt_mib_get.port_pc_withhold[1];
2190 bp->stats.port_ler_flag[0] = bp->cmd_rsp_virt->smt_mib_get.port_ler_flag[0];
2191 bp->stats.port_ler_flag[1] = bp->cmd_rsp_virt->smt_mib_get.port_ler_flag[1];
2192 bp->stats.port_hardware_present[0] = bp->cmd_rsp_virt->smt_mib_get.port_hardware_present[0];
2193 bp->stats.port_hardware_present[1] = bp->cmd_rsp_virt->smt_mib_get.port_hardware_present[1];
2194
2195
2196
2197 bp->cmd_req_virt->cmd_type = PI_CMD_K_CNTRS_GET;
2198 if (dfx_hw_dma_cmd_req(bp) != DFX_K_SUCCESS)
2199 return (struct net_device_stats *)&bp->stats;
2200
2201
2202
2203 bp->stats.mac_frame_cts = bp->cmd_rsp_virt->cntrs_get.cntrs.frame_cnt.ls;
2204 bp->stats.mac_copied_cts = bp->cmd_rsp_virt->cntrs_get.cntrs.copied_cnt.ls;
2205 bp->stats.mac_transmit_cts = bp->cmd_rsp_virt->cntrs_get.cntrs.transmit_cnt.ls;
2206 bp->stats.mac_error_cts = bp->cmd_rsp_virt->cntrs_get.cntrs.error_cnt.ls;
2207 bp->stats.mac_lost_cts = bp->cmd_rsp_virt->cntrs_get.cntrs.lost_cnt.ls;
2208 bp->stats.port_lct_fail_cts[0] = bp->cmd_rsp_virt->cntrs_get.cntrs.lct_rejects[0].ls;
2209 bp->stats.port_lct_fail_cts[1] = bp->cmd_rsp_virt->cntrs_get.cntrs.lct_rejects[1].ls;
2210 bp->stats.port_lem_reject_cts[0] = bp->cmd_rsp_virt->cntrs_get.cntrs.lem_rejects[0].ls;
2211 bp->stats.port_lem_reject_cts[1] = bp->cmd_rsp_virt->cntrs_get.cntrs.lem_rejects[1].ls;
2212 bp->stats.port_lem_cts[0] = bp->cmd_rsp_virt->cntrs_get.cntrs.link_errors[0].ls;
2213 bp->stats.port_lem_cts[1] = bp->cmd_rsp_virt->cntrs_get.cntrs.link_errors[1].ls;
2214
2215 return (struct net_device_stats *)&bp->stats;
2216 }
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262static void dfx_ctl_set_multicast_list(struct net_device *dev)
2263{
2264 DFX_board_t *bp = netdev_priv(dev);
2265 int i;
2266 struct netdev_hw_addr *ha;
2267
2268
2269
2270 if (dev->flags & IFF_PROMISC)
2271 bp->ind_group_prom = PI_FSTATE_K_PASS;
2272
2273
2274
2275 else
2276 {
2277 bp->ind_group_prom = PI_FSTATE_K_BLOCK;
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298 if (netdev_mc_count(dev) > (PI_CMD_ADDR_FILTER_K_SIZE - bp->uc_count))
2299 {
2300 bp->group_prom = PI_FSTATE_K_PASS;
2301 bp->mc_count = 0;
2302 }
2303 else
2304 {
2305 bp->group_prom = PI_FSTATE_K_BLOCK;
2306 bp->mc_count = netdev_mc_count(dev);
2307 }
2308
2309
2310
2311 i = 0;
2312 netdev_for_each_mc_addr(ha, dev)
2313 memcpy(&bp->mc_table[i++ * FDDI_K_ALEN],
2314 ha->addr, FDDI_K_ALEN);
2315
2316 if (dfx_ctl_update_cam(bp) != DFX_K_SUCCESS)
2317 {
2318 DBG_printk("%s: Could not update multicast address table!\n", dev->name);
2319 }
2320 else
2321 {
2322 DBG_printk("%s: Multicast address table updated! Added %d addresses.\n", dev->name, bp->mc_count);
2323 }
2324 }
2325
2326
2327
2328 if (dfx_ctl_update_filters(bp) != DFX_K_SUCCESS)
2329 {
2330 DBG_printk("%s: Could not update adapter filters!\n", dev->name);
2331 }
2332 else
2333 {
2334 DBG_printk("%s: Adapter filters updated!\n", dev->name);
2335 }
2336 }
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375static int dfx_ctl_set_mac_address(struct net_device *dev, void *addr)
2376 {
2377 struct sockaddr *p_sockaddr = (struct sockaddr *)addr;
2378 DFX_board_t *bp = netdev_priv(dev);
2379
2380
2381
2382 dev_addr_set(dev, p_sockaddr->sa_data);
2383 memcpy(&bp->uc_table[0], p_sockaddr->sa_data, FDDI_K_ALEN);
2384 bp->uc_count = 1;
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398 if ((bp->uc_count + bp->mc_count) > PI_CMD_ADDR_FILTER_K_SIZE)
2399 {
2400 bp->group_prom = PI_FSTATE_K_PASS;
2401 bp->mc_count = 0;
2402
2403
2404
2405 if (dfx_ctl_update_filters(bp) != DFX_K_SUCCESS)
2406 {
2407 DBG_printk("%s: Could not update adapter filters!\n", dev->name);
2408 }
2409 else
2410 {
2411 DBG_printk("%s: Adapter filters updated!\n", dev->name);
2412 }
2413 }
2414
2415
2416
2417 if (dfx_ctl_update_cam(bp) != DFX_K_SUCCESS)
2418 {
2419 DBG_printk("%s: Could not set new MAC address!\n", dev->name);
2420 }
2421 else
2422 {
2423 DBG_printk("%s: Adapter CAM updated with new MAC address\n", dev->name);
2424 }
2425 return 0;
2426 }
2427
2428
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
2462static int dfx_ctl_update_cam(DFX_board_t *bp)
2463 {
2464 int i;
2465 PI_LAN_ADDR *p_addr;
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480 memset(bp->cmd_req_virt, 0, PI_CMD_REQ_K_SIZE_MAX);
2481 bp->cmd_req_virt->cmd_type = PI_CMD_K_ADDR_FILTER_SET;
2482 p_addr = &bp->cmd_req_virt->addr_filter_set.entry[0];
2483
2484
2485
2486 for (i=0; i < (int)bp->uc_count; i++)
2487 {
2488 if (i < PI_CMD_ADDR_FILTER_K_SIZE)
2489 {
2490 memcpy(p_addr, &bp->uc_table[i*FDDI_K_ALEN], FDDI_K_ALEN);
2491 p_addr++;
2492 }
2493 }
2494
2495
2496
2497 for (i=0; i < (int)bp->mc_count; i++)
2498 {
2499 if ((i + bp->uc_count) < PI_CMD_ADDR_FILTER_K_SIZE)
2500 {
2501 memcpy(p_addr, &bp->mc_table[i*FDDI_K_ALEN], FDDI_K_ALEN);
2502 p_addr++;
2503 }
2504 }
2505
2506
2507
2508 if (dfx_hw_dma_cmd_req(bp) != DFX_K_SUCCESS)
2509 return DFX_K_FAILURE;
2510 return DFX_K_SUCCESS;
2511 }
2512
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
2545static int dfx_ctl_update_filters(DFX_board_t *bp)
2546 {
2547 int i = 0;
2548
2549
2550
2551 bp->cmd_req_virt->cmd_type = PI_CMD_K_FILTERS_SET;
2552
2553
2554
2555 bp->cmd_req_virt->filter_set.item[i].item_code = PI_ITEM_K_BROADCAST;
2556 bp->cmd_req_virt->filter_set.item[i++].value = PI_FSTATE_K_PASS;
2557
2558
2559
2560 bp->cmd_req_virt->filter_set.item[i].item_code = PI_ITEM_K_IND_GROUP_PROM;
2561 bp->cmd_req_virt->filter_set.item[i++].value = bp->ind_group_prom;
2562
2563
2564
2565 bp->cmd_req_virt->filter_set.item[i].item_code = PI_ITEM_K_GROUP_PROM;
2566 bp->cmd_req_virt->filter_set.item[i++].value = bp->group_prom;
2567
2568
2569
2570 bp->cmd_req_virt->filter_set.item[i].item_code = PI_ITEM_K_EOL;
2571
2572
2573
2574 if (dfx_hw_dma_cmd_req(bp) != DFX_K_SUCCESS)
2575 return DFX_K_FAILURE;
2576 return DFX_K_SUCCESS;
2577 }
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620static int dfx_hw_dma_cmd_req(DFX_board_t *bp)
2621 {
2622 int status;
2623 int timeout_cnt;
2624
2625
2626
2627 status = dfx_hw_adap_state_rd(bp);
2628 if ((status == PI_STATE_K_RESET) ||
2629 (status == PI_STATE_K_HALTED) ||
2630 (status == PI_STATE_K_DMA_UNAVAIL) ||
2631 (status == PI_STATE_K_UPGRADE))
2632 return DFX_K_OUTSTATE;
2633
2634
2635
2636 bp->descr_block_virt->cmd_rsp[bp->cmd_rsp_reg.index.prod].long_0 = (u32) (PI_RCV_DESCR_M_SOP |
2637 ((PI_CMD_RSP_K_SIZE_MAX / PI_ALIGN_K_CMD_RSP_BUFF) << PI_RCV_DESCR_V_SEG_LEN));
2638 bp->descr_block_virt->cmd_rsp[bp->cmd_rsp_reg.index.prod].long_1 = bp->cmd_rsp_phys;
2639
2640
2641
2642 bp->cmd_rsp_reg.index.prod += 1;
2643 bp->cmd_rsp_reg.index.prod &= PI_CMD_RSP_K_NUM_ENTRIES-1;
2644 dfx_port_write_long(bp, PI_PDQ_K_REG_CMD_RSP_PROD, bp->cmd_rsp_reg.lword);
2645
2646
2647
2648 bp->descr_block_virt->cmd_req[bp->cmd_req_reg.index.prod].long_0 = (u32) (PI_XMT_DESCR_M_SOP |
2649 PI_XMT_DESCR_M_EOP | (PI_CMD_REQ_K_SIZE_MAX << PI_XMT_DESCR_V_SEG_LEN));
2650 bp->descr_block_virt->cmd_req[bp->cmd_req_reg.index.prod].long_1 = bp->cmd_req_phys;
2651
2652
2653
2654 bp->cmd_req_reg.index.prod += 1;
2655 bp->cmd_req_reg.index.prod &= PI_CMD_REQ_K_NUM_ENTRIES-1;
2656 dfx_port_write_long(bp, PI_PDQ_K_REG_CMD_REQ_PROD, bp->cmd_req_reg.lword);
2657
2658
2659
2660
2661
2662
2663 for (timeout_cnt = 20000; timeout_cnt > 0; timeout_cnt--)
2664 {
2665 if (bp->cmd_req_reg.index.prod == (u8)(bp->cons_block_virt->cmd_req))
2666 break;
2667 udelay(100);
2668 }
2669 if (timeout_cnt == 0)
2670 return DFX_K_HW_TIMEOUT;
2671
2672
2673
2674 bp->cmd_req_reg.index.comp += 1;
2675 bp->cmd_req_reg.index.comp &= PI_CMD_REQ_K_NUM_ENTRIES-1;
2676 dfx_port_write_long(bp, PI_PDQ_K_REG_CMD_REQ_PROD, bp->cmd_req_reg.lword);
2677
2678
2679
2680
2681
2682
2683 for (timeout_cnt = 20000; timeout_cnt > 0; timeout_cnt--)
2684 {
2685 if (bp->cmd_rsp_reg.index.prod == (u8)(bp->cons_block_virt->cmd_rsp))
2686 break;
2687 udelay(100);
2688 }
2689 if (timeout_cnt == 0)
2690 return DFX_K_HW_TIMEOUT;
2691
2692
2693
2694 bp->cmd_rsp_reg.index.comp += 1;
2695 bp->cmd_rsp_reg.index.comp &= PI_CMD_RSP_K_NUM_ENTRIES-1;
2696 dfx_port_write_long(bp, PI_PDQ_K_REG_CMD_RSP_PROD, bp->cmd_rsp_reg.lword);
2697 return DFX_K_SUCCESS;
2698 }
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734static int dfx_hw_port_ctrl_req(
2735 DFX_board_t *bp,
2736 PI_UINT32 command,
2737 PI_UINT32 data_a,
2738 PI_UINT32 data_b,
2739 PI_UINT32 *host_data
2740 )
2741
2742 {
2743 PI_UINT32 port_cmd;
2744 int timeout_cnt;
2745
2746
2747
2748 port_cmd = (PI_UINT32) (command | PI_PCTRL_M_CMD_ERROR);
2749
2750
2751
2752 dfx_port_write_long(bp, PI_PDQ_K_REG_PORT_DATA_A, data_a);
2753 dfx_port_write_long(bp, PI_PDQ_K_REG_PORT_DATA_B, data_b);
2754 dfx_port_write_long(bp, PI_PDQ_K_REG_PORT_CTRL, port_cmd);
2755
2756
2757
2758 if (command == PI_PCTRL_M_BLAST_FLASH)
2759 timeout_cnt = 600000;
2760 else
2761 timeout_cnt = 20000;
2762
2763 for (; timeout_cnt > 0; timeout_cnt--)
2764 {
2765 dfx_port_read_long(bp, PI_PDQ_K_REG_PORT_CTRL, &port_cmd);
2766 if (!(port_cmd & PI_PCTRL_M_CMD_ERROR))
2767 break;
2768 udelay(100);
2769 }
2770 if (timeout_cnt == 0)
2771 return DFX_K_HW_TIMEOUT;
2772
2773
2774
2775
2776
2777
2778
2779 if (host_data != NULL)
2780 dfx_port_read_long(bp, PI_PDQ_K_REG_HOST_DATA, host_data);
2781 return DFX_K_SUCCESS;
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
2811
2812
2813
2814
2815
2816
2817
2818static void dfx_hw_adap_reset(
2819 DFX_board_t *bp,
2820 PI_UINT32 type
2821 )
2822
2823 {
2824
2825
2826 dfx_port_write_long(bp, PI_PDQ_K_REG_PORT_DATA_A, type);
2827 dfx_port_write_long(bp, PI_PDQ_K_REG_PORT_RESET, PI_RESET_M_ASSERT_RESET);
2828
2829
2830
2831 udelay(20);
2832
2833
2834
2835 dfx_port_write_long(bp, PI_PDQ_K_REG_PORT_RESET, 0);
2836 }
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866static int dfx_hw_adap_state_rd(DFX_board_t *bp)
2867 {
2868 PI_UINT32 port_status;
2869
2870 dfx_port_read_long(bp, PI_PDQ_K_REG_PORT_STATUS, &port_status);
2871 return (port_status & PI_PSTATUS_M_STATE) >> PI_PSTATUS_V_STATE;
2872 }
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906static int dfx_hw_dma_uninit(DFX_board_t *bp, PI_UINT32 type)
2907 {
2908 int timeout_cnt;
2909
2910
2911
2912 dfx_hw_adap_reset(bp, type);
2913
2914
2915
2916 for (timeout_cnt = 100000; timeout_cnt > 0; timeout_cnt--)
2917 {
2918 if (dfx_hw_adap_state_rd(bp) == PI_STATE_K_DMA_UNAVAIL)
2919 break;
2920 udelay(100);
2921 }
2922 if (timeout_cnt == 0)
2923 return DFX_K_HW_TIMEOUT;
2924 return DFX_K_SUCCESS;
2925 }
2926
2927
2928
2929
2930
2931#ifdef DYNAMIC_BUFFERS
2932static void my_skb_align(struct sk_buff *skb, int n)
2933{
2934 unsigned long x = (unsigned long)skb->data;
2935 unsigned long v;
2936
2937 v = ALIGN(x, n);
2938
2939 skb_reserve(skb, v - x);
2940}
2941#endif
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
2978static int dfx_rcv_init(DFX_board_t *bp, int get_buffers)
2979 {
2980 int i, j;
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000 if (get_buffers) {
3001#ifdef DYNAMIC_BUFFERS
3002 for (i = 0; i < (int)(bp->rcv_bufs_to_post); i++)
3003 for (j = 0; (i + j) < (int)PI_RCV_DATA_K_NUM_ENTRIES; j += bp->rcv_bufs_to_post)
3004 {
3005 struct sk_buff *newskb;
3006 dma_addr_t dma_addr;
3007
3008 newskb = __netdev_alloc_skb(bp->dev, NEW_SKB_SIZE,
3009 GFP_NOIO);
3010 if (!newskb)
3011 return -ENOMEM;
3012
3013
3014
3015
3016
3017 my_skb_align(newskb, 128);
3018 dma_addr = dma_map_single(bp->bus_dev,
3019 newskb->data,
3020 PI_RCV_DATA_K_SIZE_MAX,
3021 DMA_FROM_DEVICE);
3022 if (dma_mapping_error(bp->bus_dev, dma_addr)) {
3023 dev_kfree_skb(newskb);
3024 return -ENOMEM;
3025 }
3026 bp->descr_block_virt->rcv_data[i + j].long_0 =
3027 (u32)(PI_RCV_DESCR_M_SOP |
3028 ((PI_RCV_DATA_K_SIZE_MAX /
3029 PI_ALIGN_K_RCV_DATA_BUFF) <<
3030 PI_RCV_DESCR_V_SEG_LEN));
3031 bp->descr_block_virt->rcv_data[i + j].long_1 =
3032 (u32)dma_addr;
3033
3034
3035
3036
3037
3038 bp->p_rcv_buff_va[i+j] = (char *) newskb;
3039 }
3040#else
3041 for (i=0; i < (int)(bp->rcv_bufs_to_post); i++)
3042 for (j=0; (i + j) < (int)PI_RCV_DATA_K_NUM_ENTRIES; j += bp->rcv_bufs_to_post)
3043 {
3044 bp->descr_block_virt->rcv_data[i+j].long_0 = (u32) (PI_RCV_DESCR_M_SOP |
3045 ((PI_RCV_DATA_K_SIZE_MAX / PI_ALIGN_K_RCV_DATA_BUFF) << PI_RCV_DESCR_V_SEG_LEN));
3046 bp->descr_block_virt->rcv_data[i+j].long_1 = (u32) (bp->rcv_block_phys + (i * PI_RCV_DATA_K_SIZE_MAX));
3047 bp->p_rcv_buff_va[i+j] = (bp->rcv_block_virt + (i * PI_RCV_DATA_K_SIZE_MAX));
3048 }
3049#endif
3050 }
3051
3052
3053
3054 bp->rcv_xmt_reg.index.rcv_prod = bp->rcv_bufs_to_post;
3055 dfx_port_write_long(bp, PI_PDQ_K_REG_TYPE_2_PROD, bp->rcv_xmt_reg.lword);
3056 return 0;
3057 }
3058
3059
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
3089
3090
3091
3092static void dfx_rcv_queue_process(
3093 DFX_board_t *bp
3094 )
3095
3096 {
3097 PI_TYPE_2_CONSUMER *p_type_2_cons;
3098 char *p_buff;
3099 u32 descr, pkt_len;
3100 struct sk_buff *skb = NULL;
3101
3102
3103
3104 p_type_2_cons = (PI_TYPE_2_CONSUMER *)(&bp->cons_block_virt->xmt_rcv_data);
3105 while (bp->rcv_xmt_reg.index.rcv_comp != p_type_2_cons->index.rcv_cons)
3106 {
3107
3108 dma_addr_t dma_addr;
3109 int entry;
3110
3111 entry = bp->rcv_xmt_reg.index.rcv_comp;
3112#ifdef DYNAMIC_BUFFERS
3113 p_buff = (char *) (((struct sk_buff *)bp->p_rcv_buff_va[entry])->data);
3114#else
3115 p_buff = bp->p_rcv_buff_va[entry];
3116#endif
3117 dma_addr = bp->descr_block_virt->rcv_data[entry].long_1;
3118 dma_sync_single_for_cpu(bp->bus_dev,
3119 dma_addr + RCV_BUFF_K_DESCR,
3120 sizeof(u32),
3121 DMA_FROM_DEVICE);
3122 memcpy(&descr, p_buff + RCV_BUFF_K_DESCR, sizeof(u32));
3123
3124 if (descr & PI_FMC_DESCR_M_RCC_FLUSH)
3125 {
3126 if (descr & PI_FMC_DESCR_M_RCC_CRC)
3127 bp->rcv_crc_errors++;
3128 else
3129 bp->rcv_frame_status_errors++;
3130 }
3131 else
3132 {
3133 int rx_in_place = 0;
3134
3135
3136
3137 pkt_len = (u32)((descr & PI_FMC_DESCR_M_LEN) >> PI_FMC_DESCR_V_LEN);
3138 pkt_len -= 4;
3139 if (!IN_RANGE(pkt_len, FDDI_K_LLC_ZLEN, FDDI_K_LLC_LEN))
3140 bp->rcv_length_errors++;
3141 else{
3142#ifdef DYNAMIC_BUFFERS
3143 struct sk_buff *newskb = NULL;
3144
3145 if (pkt_len > SKBUFF_RX_COPYBREAK) {
3146 dma_addr_t new_dma_addr;
3147
3148 newskb = netdev_alloc_skb(bp->dev,
3149 NEW_SKB_SIZE);
3150 if (newskb){
3151 my_skb_align(newskb, 128);
3152 new_dma_addr = dma_map_single(
3153 bp->bus_dev,
3154 newskb->data,
3155 PI_RCV_DATA_K_SIZE_MAX,
3156 DMA_FROM_DEVICE);
3157 if (dma_mapping_error(
3158 bp->bus_dev,
3159 new_dma_addr)) {
3160 dev_kfree_skb(newskb);
3161 newskb = NULL;
3162 }
3163 }
3164 if (newskb) {
3165 rx_in_place = 1;
3166
3167 skb = (struct sk_buff *)bp->p_rcv_buff_va[entry];
3168 dma_unmap_single(bp->bus_dev,
3169 dma_addr,
3170 PI_RCV_DATA_K_SIZE_MAX,
3171 DMA_FROM_DEVICE);
3172 skb_reserve(skb, RCV_BUFF_K_PADDING);
3173 bp->p_rcv_buff_va[entry] = (char *)newskb;
3174 bp->descr_block_virt->rcv_data[entry].long_1 = (u32)new_dma_addr;
3175 }
3176 }
3177 if (!newskb)
3178#endif
3179
3180
3181 skb = netdev_alloc_skb(bp->dev,
3182 pkt_len + 3);
3183 if (skb == NULL)
3184 {
3185 printk("%s: Could not allocate receive buffer. Dropping packet.\n", bp->dev->name);
3186 bp->rcv_discards++;
3187 break;
3188 }
3189 else {
3190 if (!rx_in_place) {
3191
3192 dma_sync_single_for_cpu(
3193 bp->bus_dev,
3194 dma_addr +
3195 RCV_BUFF_K_PADDING,
3196 pkt_len + 3,
3197 DMA_FROM_DEVICE);
3198
3199 skb_copy_to_linear_data(skb,
3200 p_buff + RCV_BUFF_K_PADDING,
3201 pkt_len + 3);
3202 }
3203
3204 skb_reserve(skb,3);
3205 skb_put(skb, pkt_len);
3206 skb->protocol = fddi_type_trans(skb, bp->dev);
3207 bp->rcv_total_bytes += skb->len;
3208 netif_rx(skb);
3209
3210
3211 bp->rcv_total_frames++;
3212 if (*(p_buff + RCV_BUFF_K_DA) & 0x01)
3213 bp->rcv_multicast_frames++;
3214 }
3215 }
3216 }
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226 bp->rcv_xmt_reg.index.rcv_prod += 1;
3227 bp->rcv_xmt_reg.index.rcv_comp += 1;
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
3257
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
3293static netdev_tx_t dfx_xmt_queue_pkt(struct sk_buff *skb,
3294 struct net_device *dev)
3295 {
3296 DFX_board_t *bp = netdev_priv(dev);
3297 u8 prod;
3298 PI_XMT_DESCR *p_xmt_descr;
3299 XMT_DRIVER_DESCR *p_xmt_drv_descr;
3300 dma_addr_t dma_addr;
3301 unsigned long flags;
3302
3303 netif_stop_queue(dev);
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314 if (!IN_RANGE(skb->len, FDDI_K_LLC_ZLEN, FDDI_K_LLC_LEN))
3315 {
3316 printk("%s: Invalid packet length - %u bytes\n",
3317 dev->name, skb->len);
3318 bp->xmt_length_errors++;
3319 netif_wake_queue(dev);
3320 dev_kfree_skb(skb);
3321 return NETDEV_TX_OK;
3322 }
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335 if (bp->link_available == PI_K_FALSE)
3336 {
3337 if (dfx_hw_adap_state_rd(bp) == PI_STATE_K_LINK_AVAIL)
3338 bp->link_available = PI_K_TRUE;
3339 else
3340 {
3341 bp->xmt_discards++;
3342 dev_kfree_skb(skb);
3343 netif_wake_queue(dev);
3344 return NETDEV_TX_OK;
3345 }
3346 }
3347
3348
3349
3350 skb_push(skb, 3);
3351 skb->data[0] = DFX_PRH0_BYTE;
3352 skb->data[1] = DFX_PRH1_BYTE;
3353 skb->data[2] = DFX_PRH2_BYTE;
3354
3355 dma_addr = dma_map_single(bp->bus_dev, skb->data, skb->len,
3356 DMA_TO_DEVICE);
3357 if (dma_mapping_error(bp->bus_dev, dma_addr)) {
3358 skb_pull(skb, 3);
3359 return NETDEV_TX_BUSY;
3360 }
3361
3362 spin_lock_irqsave(&bp->lock, flags);
3363
3364
3365
3366 prod = bp->rcv_xmt_reg.index.xmt_prod;
3367 p_xmt_descr = &(bp->descr_block_virt->xmt_data[prod]);
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380 p_xmt_drv_descr = &(bp->xmt_drv_descr_blk[prod++]);
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409 p_xmt_descr->long_0 = (u32) (PI_XMT_DESCR_M_SOP | PI_XMT_DESCR_M_EOP | ((skb->len) << PI_XMT_DESCR_V_SEG_LEN));
3410 p_xmt_descr->long_1 = (u32)dma_addr;
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423 if (prod == bp->rcv_xmt_reg.index.xmt_comp)
3424 {
3425 skb_pull(skb,3);
3426 spin_unlock_irqrestore(&bp->lock, flags);
3427 return NETDEV_TX_BUSY;
3428 }
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446 p_xmt_drv_descr->p_skb = skb;
3447
3448
3449
3450 bp->rcv_xmt_reg.index.xmt_prod = prod;
3451 dfx_port_write_long(bp, PI_PDQ_K_REG_TYPE_2_PROD, bp->rcv_xmt_reg.lword);
3452 spin_unlock_irqrestore(&bp->lock, flags);
3453 netif_wake_queue(dev);
3454 return NETDEV_TX_OK;
3455 }
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490static int dfx_xmt_done(DFX_board_t *bp)
3491 {
3492 XMT_DRIVER_DESCR *p_xmt_drv_descr;
3493 PI_TYPE_2_CONSUMER *p_type_2_cons;
3494 u8 comp;
3495 int freed = 0;
3496
3497
3498
3499 p_type_2_cons = (PI_TYPE_2_CONSUMER *)(&bp->cons_block_virt->xmt_rcv_data);
3500 while (bp->rcv_xmt_reg.index.xmt_comp != p_type_2_cons->index.xmt_cons)
3501 {
3502
3503
3504 p_xmt_drv_descr = &(bp->xmt_drv_descr_blk[bp->rcv_xmt_reg.index.xmt_comp]);
3505
3506
3507
3508 bp->xmt_total_frames++;
3509 bp->xmt_total_bytes += p_xmt_drv_descr->p_skb->len;
3510
3511
3512 comp = bp->rcv_xmt_reg.index.xmt_comp;
3513 dma_unmap_single(bp->bus_dev,
3514 bp->descr_block_virt->xmt_data[comp].long_1,
3515 p_xmt_drv_descr->p_skb->len,
3516 DMA_TO_DEVICE);
3517 dev_consume_skb_irq(p_xmt_drv_descr->p_skb);
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530 bp->rcv_xmt_reg.index.xmt_comp += 1;
3531 freed++;
3532 }
3533 return freed;
3534 }
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563#ifdef DYNAMIC_BUFFERS
3564static void dfx_rcv_flush( DFX_board_t *bp )
3565 {
3566 int i, j;
3567
3568 for (i = 0; i < (int)(bp->rcv_bufs_to_post); i++)
3569 for (j = 0; (i + j) < (int)PI_RCV_DATA_K_NUM_ENTRIES; j += bp->rcv_bufs_to_post)
3570 {
3571 struct sk_buff *skb;
3572 skb = (struct sk_buff *)bp->p_rcv_buff_va[i+j];
3573 if (skb) {
3574 dma_unmap_single(bp->bus_dev,
3575 bp->descr_block_virt->rcv_data[i+j].long_1,
3576 PI_RCV_DATA_K_SIZE_MAX,
3577 DMA_FROM_DEVICE);
3578 dev_kfree_skb(skb);
3579 }
3580 bp->p_rcv_buff_va[i+j] = NULL;
3581 }
3582
3583 }
3584#endif
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622static void dfx_xmt_flush( DFX_board_t *bp )
3623 {
3624 u32 prod_cons;
3625 XMT_DRIVER_DESCR *p_xmt_drv_descr;
3626 u8 comp;
3627
3628
3629
3630 while (bp->rcv_xmt_reg.index.xmt_comp != bp->rcv_xmt_reg.index.xmt_prod)
3631 {
3632
3633
3634 p_xmt_drv_descr = &(bp->xmt_drv_descr_blk[bp->rcv_xmt_reg.index.xmt_comp]);
3635
3636
3637 comp = bp->rcv_xmt_reg.index.xmt_comp;
3638 dma_unmap_single(bp->bus_dev,
3639 bp->descr_block_virt->xmt_data[comp].long_1,
3640 p_xmt_drv_descr->p_skb->len,
3641 DMA_TO_DEVICE);
3642 dev_kfree_skb(p_xmt_drv_descr->p_skb);
3643
3644
3645
3646 bp->xmt_discards++;
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659 bp->rcv_xmt_reg.index.xmt_comp += 1;
3660 }
3661
3662
3663
3664 prod_cons = (u32)(bp->cons_block_virt->xmt_rcv_data & ~PI_CONS_M_XMT_INDEX);
3665 prod_cons |= (u32)(bp->rcv_xmt_reg.index.xmt_prod << PI_CONS_V_XMT_INDEX);
3666 bp->cons_block_virt->xmt_rcv_data = prod_cons;
3667 }
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695static void dfx_unregister(struct device *bdev)
3696{
3697 struct net_device *dev = dev_get_drvdata(bdev);
3698 DFX_board_t *bp = netdev_priv(dev);
3699 int dfx_bus_pci = dev_is_pci(bdev);
3700 resource_size_t bar_start[3] = {0};
3701 resource_size_t bar_len[3] = {0};
3702 int alloc_size;
3703
3704 unregister_netdev(dev);
3705
3706 alloc_size = sizeof(PI_DESCR_BLOCK) +
3707 PI_CMD_REQ_K_SIZE_MAX + PI_CMD_RSP_K_SIZE_MAX +
3708#ifndef DYNAMIC_BUFFERS
3709 (bp->rcv_bufs_to_post * PI_RCV_DATA_K_SIZE_MAX) +
3710#endif
3711 sizeof(PI_CONSUMER_BLOCK) +
3712 (PI_ALIGN_K_DESC_BLK - 1);
3713 if (bp->kmalloced)
3714 dma_free_coherent(bdev, alloc_size,
3715 bp->kmalloced, bp->kmalloced_dma);
3716
3717 dfx_bus_uninit(dev);
3718
3719 dfx_get_bars(bp, bar_start, bar_len);
3720 if (bar_start[2] != 0)
3721 release_region(bar_start[2], bar_len[2]);
3722 if (bar_start[1] != 0)
3723 release_region(bar_start[1], bar_len[1]);
3724 if (dfx_use_mmio) {
3725 iounmap(bp->base.mem);
3726 release_mem_region(bar_start[0], bar_len[0]);
3727 } else
3728 release_region(bar_start[0], bar_len[0]);
3729
3730 if (dfx_bus_pci)
3731 pci_disable_device(to_pci_dev(bdev));
3732
3733 free_netdev(dev);
3734}
3735
3736
3737static int __maybe_unused dfx_dev_register(struct device *);
3738static int __maybe_unused dfx_dev_unregister(struct device *);
3739
3740#ifdef CONFIG_PCI
3741static int dfx_pci_register(struct pci_dev *, const struct pci_device_id *);
3742static void dfx_pci_unregister(struct pci_dev *);
3743
3744static const struct pci_device_id dfx_pci_table[] = {
3745 { PCI_DEVICE(PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_FDDI) },
3746 { }
3747};
3748MODULE_DEVICE_TABLE(pci, dfx_pci_table);
3749
3750static struct pci_driver dfx_pci_driver = {
3751 .name = DRV_NAME,
3752 .id_table = dfx_pci_table,
3753 .probe = dfx_pci_register,
3754 .remove = dfx_pci_unregister,
3755};
3756
3757static int dfx_pci_register(struct pci_dev *pdev,
3758 const struct pci_device_id *ent)
3759{
3760 return dfx_register(&pdev->dev);
3761}
3762
3763static void dfx_pci_unregister(struct pci_dev *pdev)
3764{
3765 dfx_unregister(&pdev->dev);
3766}
3767#endif
3768
3769#ifdef CONFIG_EISA
3770static const struct eisa_device_id dfx_eisa_table[] = {
3771 { "DEC3001", DEFEA_PROD_ID_1 },
3772 { "DEC3002", DEFEA_PROD_ID_2 },
3773 { "DEC3003", DEFEA_PROD_ID_3 },
3774 { "DEC3004", DEFEA_PROD_ID_4 },
3775 { }
3776};
3777MODULE_DEVICE_TABLE(eisa, dfx_eisa_table);
3778
3779static struct eisa_driver dfx_eisa_driver = {
3780 .id_table = dfx_eisa_table,
3781 .driver = {
3782 .name = DRV_NAME,
3783 .bus = &eisa_bus_type,
3784 .probe = dfx_dev_register,
3785 .remove = dfx_dev_unregister,
3786 },
3787};
3788#endif
3789
3790#ifdef CONFIG_TC
3791static struct tc_device_id const dfx_tc_table[] = {
3792 { "DEC ", "PMAF-FA " },
3793 { "DEC ", "PMAF-FD " },
3794 { "DEC ", "PMAF-FS " },
3795 { "DEC ", "PMAF-FU " },
3796 { }
3797};
3798MODULE_DEVICE_TABLE(tc, dfx_tc_table);
3799
3800static struct tc_driver dfx_tc_driver = {
3801 .id_table = dfx_tc_table,
3802 .driver = {
3803 .name = DRV_NAME,
3804 .bus = &tc_bus_type,
3805 .probe = dfx_dev_register,
3806 .remove = dfx_dev_unregister,
3807 },
3808};
3809#endif
3810
3811static int __maybe_unused dfx_dev_register(struct device *dev)
3812{
3813 int status;
3814
3815 status = dfx_register(dev);
3816 if (!status)
3817 get_device(dev);
3818 return status;
3819}
3820
3821static int __maybe_unused dfx_dev_unregister(struct device *dev)
3822{
3823 put_device(dev);
3824 dfx_unregister(dev);
3825 return 0;
3826}
3827
3828
3829static int dfx_init(void)
3830{
3831 int status;
3832
3833 status = pci_register_driver(&dfx_pci_driver);
3834 if (!status)
3835 status = eisa_driver_register(&dfx_eisa_driver);
3836 if (!status)
3837 status = tc_register_driver(&dfx_tc_driver);
3838 return status;
3839}
3840
3841static void dfx_cleanup(void)
3842{
3843 tc_unregister_driver(&dfx_tc_driver);
3844 eisa_driver_unregister(&dfx_eisa_driver);
3845 pci_unregister_driver(&dfx_pci_driver);
3846}
3847
3848module_init(dfx_init);
3849module_exit(dfx_cleanup);
3850MODULE_AUTHOR("Lawrence V. Stefani");
3851MODULE_DESCRIPTION("DEC FDDIcontroller TC/EISA/PCI (DEFTA/DEFEA/DEFPA) driver "
3852 DRV_VERSION " " DRV_RELDATE);
3853MODULE_LICENSE("GPL");
3854