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#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
34
35#include <linux/pci_ids.h>
36#include "ixgb_hw.h"
37#include "ixgb_ids.h"
38
39#include <linux/etherdevice.h>
40
41
42
43static u32 ixgb_hash_mc_addr(struct ixgb_hw *hw, u8 * mc_addr);
44
45static void ixgb_mta_set(struct ixgb_hw *hw, u32 hash_value);
46
47static void ixgb_get_bus_info(struct ixgb_hw *hw);
48
49static bool ixgb_link_reset(struct ixgb_hw *hw);
50
51static void ixgb_optics_reset(struct ixgb_hw *hw);
52
53static void ixgb_optics_reset_bcm(struct ixgb_hw *hw);
54
55static ixgb_phy_type ixgb_identify_phy(struct ixgb_hw *hw);
56
57static void ixgb_clear_hw_cntrs(struct ixgb_hw *hw);
58
59static void ixgb_clear_vfta(struct ixgb_hw *hw);
60
61static void ixgb_init_rx_addrs(struct ixgb_hw *hw);
62
63static u16 ixgb_read_phy_reg(struct ixgb_hw *hw,
64 u32 reg_address,
65 u32 phy_address,
66 u32 device_type);
67
68static bool ixgb_setup_fc(struct ixgb_hw *hw);
69
70static bool mac_addr_valid(u8 *mac_addr);
71
72static u32 ixgb_mac_reset(struct ixgb_hw *hw)
73{
74 u32 ctrl_reg;
75
76 ctrl_reg = IXGB_CTRL0_RST |
77 IXGB_CTRL0_SDP3_DIR |
78 IXGB_CTRL0_SDP2_DIR |
79 IXGB_CTRL0_SDP1_DIR |
80 IXGB_CTRL0_SDP0_DIR |
81 IXGB_CTRL0_SDP3 |
82 IXGB_CTRL0_SDP2 |
83 IXGB_CTRL0_SDP0;
84
85#ifdef HP_ZX1
86
87 IXGB_WRITE_REG_IO(hw, CTRL0, ctrl_reg);
88#else
89 IXGB_WRITE_REG(hw, CTRL0, ctrl_reg);
90#endif
91
92
93 msleep(IXGB_DELAY_AFTER_RESET);
94 ctrl_reg = IXGB_READ_REG(hw, CTRL0);
95#ifdef DBG
96
97 ASSERT(!(ctrl_reg & IXGB_CTRL0_RST));
98#endif
99
100 if (hw->subsystem_vendor_id == PCI_VENDOR_ID_SUN) {
101 ctrl_reg =
102 IXGB_CTRL1_GPI0_EN |
103 IXGB_CTRL1_SDP6_DIR |
104 IXGB_CTRL1_SDP7_DIR |
105 IXGB_CTRL1_SDP6 |
106 IXGB_CTRL1_SDP7;
107 IXGB_WRITE_REG(hw, CTRL1, ctrl_reg);
108 ixgb_optics_reset_bcm(hw);
109 }
110
111 if (hw->phy_type == ixgb_phy_type_txn17401)
112 ixgb_optics_reset(hw);
113
114 return ctrl_reg;
115}
116
117
118
119
120
121
122bool
123ixgb_adapter_stop(struct ixgb_hw *hw)
124{
125 u32 ctrl_reg;
126 u32 icr_reg;
127
128 ENTER();
129
130
131
132
133 if (hw->adapter_stopped) {
134 pr_debug("Exiting because the adapter is already stopped!!!\n");
135 return false;
136 }
137
138
139
140
141 hw->adapter_stopped = true;
142
143
144 pr_debug("Masking off all interrupts\n");
145 IXGB_WRITE_REG(hw, IMC, 0xFFFFFFFF);
146
147
148
149
150
151 IXGB_WRITE_REG(hw, RCTL, IXGB_READ_REG(hw, RCTL) & ~IXGB_RCTL_RXEN);
152 IXGB_WRITE_REG(hw, TCTL, IXGB_READ_REG(hw, TCTL) & ~IXGB_TCTL_TXEN);
153 IXGB_WRITE_FLUSH(hw);
154 msleep(IXGB_DELAY_BEFORE_RESET);
155
156
157
158
159
160
161 pr_debug("Issuing a global reset to MAC\n");
162
163 ctrl_reg = ixgb_mac_reset(hw);
164
165
166 pr_debug("Masking off all interrupts\n");
167 IXGB_WRITE_REG(hw, IMC, 0xffffffff);
168
169
170 icr_reg = IXGB_READ_REG(hw, ICR);
171
172 return ctrl_reg & IXGB_CTRL0_RST;
173}
174
175
176
177
178
179
180
181
182
183
184
185static ixgb_xpak_vendor
186ixgb_identify_xpak_vendor(struct ixgb_hw *hw)
187{
188 u32 i;
189 u16 vendor_name[5];
190 ixgb_xpak_vendor xpak_vendor;
191
192 ENTER();
193
194
195
196
197 for (i = 0; i < 5; i++) {
198 vendor_name[i] = ixgb_read_phy_reg(hw,
199 MDIO_PMA_PMD_XPAK_VENDOR_NAME
200 + i, IXGB_PHY_ADDRESS,
201 MDIO_MMD_PMAPMD);
202 }
203
204
205 if (vendor_name[0] == 'I' &&
206 vendor_name[1] == 'N' &&
207 vendor_name[2] == 'T' &&
208 vendor_name[3] == 'E' && vendor_name[4] == 'L') {
209 xpak_vendor = ixgb_xpak_vendor_intel;
210 } else {
211 xpak_vendor = ixgb_xpak_vendor_infineon;
212 }
213
214 return xpak_vendor;
215}
216
217
218
219
220
221
222
223
224
225static ixgb_phy_type
226ixgb_identify_phy(struct ixgb_hw *hw)
227{
228 ixgb_phy_type phy_type;
229 ixgb_xpak_vendor xpak_vendor;
230
231 ENTER();
232
233
234 switch (hw->device_id) {
235 case IXGB_DEVICE_ID_82597EX:
236 pr_debug("Identified TXN17401 optics\n");
237 phy_type = ixgb_phy_type_txn17401;
238 break;
239
240 case IXGB_DEVICE_ID_82597EX_SR:
241
242
243
244 xpak_vendor = ixgb_identify_xpak_vendor(hw);
245 if (xpak_vendor == ixgb_xpak_vendor_intel) {
246 pr_debug("Identified TXN17201 optics\n");
247 phy_type = ixgb_phy_type_txn17201;
248 } else {
249 pr_debug("Identified G6005 optics\n");
250 phy_type = ixgb_phy_type_g6005;
251 }
252 break;
253 case IXGB_DEVICE_ID_82597EX_LR:
254 pr_debug("Identified G6104 optics\n");
255 phy_type = ixgb_phy_type_g6104;
256 break;
257 case IXGB_DEVICE_ID_82597EX_CX4:
258 pr_debug("Identified CX4\n");
259 xpak_vendor = ixgb_identify_xpak_vendor(hw);
260 if (xpak_vendor == ixgb_xpak_vendor_intel) {
261 pr_debug("Identified TXN17201 optics\n");
262 phy_type = ixgb_phy_type_txn17201;
263 } else {
264 pr_debug("Identified G6005 optics\n");
265 phy_type = ixgb_phy_type_g6005;
266 }
267 break;
268 default:
269 pr_debug("Unknown physical layer module\n");
270 phy_type = ixgb_phy_type_unknown;
271 break;
272 }
273
274
275 if (hw->subsystem_vendor_id == PCI_VENDOR_ID_SUN)
276 phy_type = ixgb_phy_type_bcm;
277
278 return phy_type;
279}
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298bool
299ixgb_init_hw(struct ixgb_hw *hw)
300{
301 u32 i;
302 u32 ctrl_reg;
303 bool status;
304
305 ENTER();
306
307
308
309
310
311
312 pr_debug("Issuing a global reset to MAC\n");
313
314 ctrl_reg = ixgb_mac_reset(hw);
315
316 pr_debug("Issuing an EE reset to MAC\n");
317#ifdef HP_ZX1
318
319 IXGB_WRITE_REG_IO(hw, CTRL1, IXGB_CTRL1_EE_RST);
320#else
321 IXGB_WRITE_REG(hw, CTRL1, IXGB_CTRL1_EE_RST);
322#endif
323
324
325 msleep(IXGB_DELAY_AFTER_EE_RESET);
326
327 if (!ixgb_get_eeprom_data(hw))
328 return false;
329
330
331 hw->device_id = ixgb_get_ee_device_id(hw);
332 hw->phy_type = ixgb_identify_phy(hw);
333
334
335
336
337 ixgb_init_rx_addrs(hw);
338
339
340
341
342
343 if (!mac_addr_valid(hw->curr_mac_addr)) {
344 pr_debug("MAC address invalid after ixgb_init_rx_addrs\n");
345 return(false);
346 }
347
348
349 hw->adapter_stopped = false;
350
351
352 ixgb_get_bus_info(hw);
353
354
355 pr_debug("Zeroing the MTA\n");
356 for (i = 0; i < IXGB_MC_TBL_SIZE; i++)
357 IXGB_WRITE_REG_ARRAY(hw, MTA, i, 0);
358
359
360 ixgb_clear_vfta(hw);
361
362
363 ixgb_clear_hw_cntrs(hw);
364
365
366 status = ixgb_setup_fc(hw);
367
368
369 ixgb_check_for_link(hw);
370
371 return status;
372}
373
374
375
376
377
378
379
380
381
382
383static void
384ixgb_init_rx_addrs(struct ixgb_hw *hw)
385{
386 u32 i;
387
388 ENTER();
389
390
391
392
393
394
395 if (!mac_addr_valid(hw->curr_mac_addr)) {
396
397
398 ixgb_get_ee_mac_addr(hw, hw->curr_mac_addr);
399
400 pr_debug("Keeping Permanent MAC Addr = %pM\n",
401 hw->curr_mac_addr);
402 } else {
403
404
405 pr_debug("Overriding MAC Address in RAR[0]\n");
406 pr_debug("New MAC Addr = %pM\n", hw->curr_mac_addr);
407
408 ixgb_rar_set(hw, hw->curr_mac_addr, 0);
409 }
410
411
412 pr_debug("Clearing RAR[1-15]\n");
413 for (i = 1; i < IXGB_RAR_ENTRIES; i++) {
414
415 IXGB_WRITE_REG_ARRAY(hw, RA, ((i << 1) + 1), 0);
416 IXGB_WRITE_REG_ARRAY(hw, RA, (i << 1), 0);
417 }
418}
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433void
434ixgb_mc_addr_list_update(struct ixgb_hw *hw,
435 u8 *mc_addr_list,
436 u32 mc_addr_count,
437 u32 pad)
438{
439 u32 hash_value;
440 u32 i;
441 u32 rar_used_count = 1;
442 u8 *mca;
443
444 ENTER();
445
446
447 hw->num_mc_addrs = mc_addr_count;
448
449
450 pr_debug("Clearing RAR[1-15]\n");
451 for (i = rar_used_count; i < IXGB_RAR_ENTRIES; i++) {
452 IXGB_WRITE_REG_ARRAY(hw, RA, (i << 1), 0);
453 IXGB_WRITE_REG_ARRAY(hw, RA, ((i << 1) + 1), 0);
454 }
455
456
457 pr_debug("Clearing MTA\n");
458 for (i = 0; i < IXGB_MC_TBL_SIZE; i++)
459 IXGB_WRITE_REG_ARRAY(hw, MTA, i, 0);
460
461
462 mca = mc_addr_list;
463 for (i = 0; i < mc_addr_count; i++) {
464 pr_debug("Adding the multicast addresses:\n");
465 pr_debug("MC Addr #%d = %pM\n", i, mca);
466
467
468
469
470 if (rar_used_count < IXGB_RAR_ENTRIES) {
471 ixgb_rar_set(hw, mca, rar_used_count);
472 pr_debug("Added a multicast address to RAR[%d]\n", i);
473 rar_used_count++;
474 } else {
475 hash_value = ixgb_hash_mc_addr(hw, mca);
476
477 pr_debug("Hash value = 0x%03X\n", hash_value);
478
479 ixgb_mta_set(hw, hash_value);
480 }
481
482 mca += ETH_ALEN + pad;
483 }
484
485 pr_debug("MC Update Complete\n");
486}
487
488
489
490
491
492
493
494
495
496
497static u32
498ixgb_hash_mc_addr(struct ixgb_hw *hw,
499 u8 *mc_addr)
500{
501 u32 hash_value = 0;
502
503 ENTER();
504
505
506
507
508 switch (hw->mc_filter_type) {
509
510
511
512 case 0:
513
514 hash_value =
515 ((mc_addr[4] >> 4) | (((u16) mc_addr[5]) << 4));
516 break;
517 case 1:
518 hash_value =
519 ((mc_addr[4] >> 3) | (((u16) mc_addr[5]) << 5));
520 break;
521 case 2:
522 hash_value =
523 ((mc_addr[4] >> 2) | (((u16) mc_addr[5]) << 6));
524 break;
525 case 3:
526 hash_value = ((mc_addr[4]) | (((u16) mc_addr[5]) << 8));
527 break;
528 default:
529
530 pr_debug("MC filter type param set incorrectly\n");
531 ASSERT(0);
532 break;
533 }
534
535 hash_value &= 0xFFF;
536 return hash_value;
537}
538
539
540
541
542
543
544
545static void
546ixgb_mta_set(struct ixgb_hw *hw,
547 u32 hash_value)
548{
549 u32 hash_bit, hash_reg;
550 u32 mta_reg;
551
552
553
554
555
556
557
558
559
560 hash_reg = (hash_value >> 5) & 0x7F;
561 hash_bit = hash_value & 0x1F;
562
563 mta_reg = IXGB_READ_REG_ARRAY(hw, MTA, hash_reg);
564
565 mta_reg |= (1 << hash_bit);
566
567 IXGB_WRITE_REG_ARRAY(hw, MTA, hash_reg, mta_reg);
568}
569
570
571
572
573
574
575
576
577void
578ixgb_rar_set(struct ixgb_hw *hw,
579 u8 *addr,
580 u32 index)
581{
582 u32 rar_low, rar_high;
583
584 ENTER();
585
586
587
588
589 rar_low = ((u32) addr[0] |
590 ((u32)addr[1] << 8) |
591 ((u32)addr[2] << 16) |
592 ((u32)addr[3] << 24));
593
594 rar_high = ((u32) addr[4] |
595 ((u32)addr[5] << 8) |
596 IXGB_RAH_AV);
597
598 IXGB_WRITE_REG_ARRAY(hw, RA, (index << 1), rar_low);
599 IXGB_WRITE_REG_ARRAY(hw, RA, ((index << 1) + 1), rar_high);
600}
601
602
603
604
605
606
607
608
609void
610ixgb_write_vfta(struct ixgb_hw *hw,
611 u32 offset,
612 u32 value)
613{
614 IXGB_WRITE_REG_ARRAY(hw, VFTA, offset, value);
615}
616
617
618
619
620
621
622static void
623ixgb_clear_vfta(struct ixgb_hw *hw)
624{
625 u32 offset;
626
627 for (offset = 0; offset < IXGB_VLAN_FILTER_TBL_SIZE; offset++)
628 IXGB_WRITE_REG_ARRAY(hw, VFTA, offset, 0);
629}
630
631
632
633
634
635
636
637static bool
638ixgb_setup_fc(struct ixgb_hw *hw)
639{
640 u32 ctrl_reg;
641 u32 pap_reg = 0;
642 bool status = true;
643
644 ENTER();
645
646
647 ctrl_reg = IXGB_READ_REG(hw, CTRL0);
648
649
650 ctrl_reg &= ~(IXGB_CTRL0_RPE | IXGB_CTRL0_TPE);
651
652
653
654
655
656
657
658
659
660
661 switch (hw->fc.type) {
662 case ixgb_fc_none:
663
664 ctrl_reg |= (IXGB_CTRL0_CMDC);
665 break;
666 case ixgb_fc_rx_pause:
667
668
669
670 ctrl_reg |= (IXGB_CTRL0_RPE);
671 break;
672 case ixgb_fc_tx_pause:
673
674
675
676 ctrl_reg |= (IXGB_CTRL0_TPE);
677 pap_reg = hw->fc.pause_time;
678 break;
679 case ixgb_fc_full:
680
681
682
683 ctrl_reg |= (IXGB_CTRL0_RPE | IXGB_CTRL0_TPE);
684 pap_reg = hw->fc.pause_time;
685 break;
686 default:
687
688 pr_debug("Flow control param set incorrectly\n");
689 ASSERT(0);
690 break;
691 }
692
693
694 IXGB_WRITE_REG(hw, CTRL0, ctrl_reg);
695
696 if (pap_reg != 0)
697 IXGB_WRITE_REG(hw, PAP, pap_reg);
698
699
700
701
702
703
704
705 if (!(hw->fc.type & ixgb_fc_tx_pause)) {
706 IXGB_WRITE_REG(hw, FCRTL, 0);
707 IXGB_WRITE_REG(hw, FCRTH, 0);
708 } else {
709
710
711
712 if (hw->fc.send_xon) {
713 IXGB_WRITE_REG(hw, FCRTL,
714 (hw->fc.low_water | IXGB_FCRTL_XONE));
715 } else {
716 IXGB_WRITE_REG(hw, FCRTL, hw->fc.low_water);
717 }
718 IXGB_WRITE_REG(hw, FCRTH, hw->fc.high_water);
719 }
720 return status;
721}
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738static u16
739ixgb_read_phy_reg(struct ixgb_hw *hw,
740 u32 reg_address,
741 u32 phy_address,
742 u32 device_type)
743{
744 u32 i;
745 u32 data;
746 u32 command = 0;
747
748 ASSERT(reg_address <= IXGB_MAX_PHY_REG_ADDRESS);
749 ASSERT(phy_address <= IXGB_MAX_PHY_ADDRESS);
750 ASSERT(device_type <= IXGB_MAX_PHY_DEV_TYPE);
751
752
753 command = ((reg_address << IXGB_MSCA_NP_ADDR_SHIFT) |
754 (device_type << IXGB_MSCA_DEV_TYPE_SHIFT) |
755 (phy_address << IXGB_MSCA_PHY_ADDR_SHIFT) |
756 (IXGB_MSCA_ADDR_CYCLE | IXGB_MSCA_MDI_COMMAND));
757
758 IXGB_WRITE_REG(hw, MSCA, command);
759
760
761
762
763
764
765
766
767 for (i = 0; i < 10; i++)
768 {
769 udelay(10);
770
771 command = IXGB_READ_REG(hw, MSCA);
772
773 if ((command & IXGB_MSCA_MDI_COMMAND) == 0)
774 break;
775 }
776
777 ASSERT((command & IXGB_MSCA_MDI_COMMAND) == 0);
778
779
780 command = ((reg_address << IXGB_MSCA_NP_ADDR_SHIFT) |
781 (device_type << IXGB_MSCA_DEV_TYPE_SHIFT) |
782 (phy_address << IXGB_MSCA_PHY_ADDR_SHIFT) |
783 (IXGB_MSCA_READ | IXGB_MSCA_MDI_COMMAND));
784
785 IXGB_WRITE_REG(hw, MSCA, command);
786
787
788
789
790
791
792
793
794 for (i = 0; i < 10; i++)
795 {
796 udelay(10);
797
798 command = IXGB_READ_REG(hw, MSCA);
799
800 if ((command & IXGB_MSCA_MDI_COMMAND) == 0)
801 break;
802 }
803
804 ASSERT((command & IXGB_MSCA_MDI_COMMAND) == 0);
805
806
807
808
809 data = IXGB_READ_REG(hw, MSRWD);
810 data >>= IXGB_MSRWD_READ_DATA_SHIFT;
811 return((u16) data);
812}
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831static void
832ixgb_write_phy_reg(struct ixgb_hw *hw,
833 u32 reg_address,
834 u32 phy_address,
835 u32 device_type,
836 u16 data)
837{
838 u32 i;
839 u32 command = 0;
840
841 ASSERT(reg_address <= IXGB_MAX_PHY_REG_ADDRESS);
842 ASSERT(phy_address <= IXGB_MAX_PHY_ADDRESS);
843 ASSERT(device_type <= IXGB_MAX_PHY_DEV_TYPE);
844
845
846 IXGB_WRITE_REG(hw, MSRWD, (u32)data);
847
848
849 command = ((reg_address << IXGB_MSCA_NP_ADDR_SHIFT) |
850 (device_type << IXGB_MSCA_DEV_TYPE_SHIFT) |
851 (phy_address << IXGB_MSCA_PHY_ADDR_SHIFT) |
852 (IXGB_MSCA_ADDR_CYCLE | IXGB_MSCA_MDI_COMMAND));
853
854 IXGB_WRITE_REG(hw, MSCA, command);
855
856
857
858
859
860
861
862
863 for (i = 0; i < 10; i++)
864 {
865 udelay(10);
866
867 command = IXGB_READ_REG(hw, MSCA);
868
869 if ((command & IXGB_MSCA_MDI_COMMAND) == 0)
870 break;
871 }
872
873 ASSERT((command & IXGB_MSCA_MDI_COMMAND) == 0);
874
875
876 command = ((reg_address << IXGB_MSCA_NP_ADDR_SHIFT) |
877 (device_type << IXGB_MSCA_DEV_TYPE_SHIFT) |
878 (phy_address << IXGB_MSCA_PHY_ADDR_SHIFT) |
879 (IXGB_MSCA_WRITE | IXGB_MSCA_MDI_COMMAND));
880
881 IXGB_WRITE_REG(hw, MSCA, command);
882
883
884
885
886
887
888
889
890 for (i = 0; i < 10; i++)
891 {
892 udelay(10);
893
894 command = IXGB_READ_REG(hw, MSCA);
895
896 if ((command & IXGB_MSCA_MDI_COMMAND) == 0)
897 break;
898 }
899
900 ASSERT((command & IXGB_MSCA_MDI_COMMAND) == 0);
901
902
903}
904
905
906
907
908
909
910
911
912void
913ixgb_check_for_link(struct ixgb_hw *hw)
914{
915 u32 status_reg;
916 u32 xpcss_reg;
917
918 ENTER();
919
920 xpcss_reg = IXGB_READ_REG(hw, XPCSS);
921 status_reg = IXGB_READ_REG(hw, STATUS);
922
923 if ((xpcss_reg & IXGB_XPCSS_ALIGN_STATUS) &&
924 (status_reg & IXGB_STATUS_LU)) {
925 hw->link_up = true;
926 } else if (!(xpcss_reg & IXGB_XPCSS_ALIGN_STATUS) &&
927 (status_reg & IXGB_STATUS_LU)) {
928 pr_debug("XPCSS Not Aligned while Status:LU is set\n");
929 hw->link_up = ixgb_link_reset(hw);
930 } else {
931
932
933
934
935 hw->link_up = ixgb_link_reset(hw);
936 }
937
938}
939
940
941
942
943
944
945
946
947
948
949bool ixgb_check_for_bad_link(struct ixgb_hw *hw)
950{
951 u32 newLFC, newRFC;
952 bool bad_link_returncode = false;
953
954 if (hw->phy_type == ixgb_phy_type_txn17401) {
955 newLFC = IXGB_READ_REG(hw, LFC);
956 newRFC = IXGB_READ_REG(hw, RFC);
957 if ((hw->lastLFC + 250 < newLFC)
958 || (hw->lastRFC + 250 < newRFC)) {
959 pr_debug("BAD LINK! too many LFC/RFC since last check\n");
960 bad_link_returncode = true;
961 }
962 hw->lastLFC = newLFC;
963 hw->lastRFC = newRFC;
964 }
965
966 return bad_link_returncode;
967}
968
969
970
971
972
973
974static void
975ixgb_clear_hw_cntrs(struct ixgb_hw *hw)
976{
977 volatile u32 temp_reg;
978
979 ENTER();
980
981
982 if (hw->adapter_stopped) {
983 pr_debug("Exiting because the adapter is stopped!!!\n");
984 return;
985 }
986
987 temp_reg = IXGB_READ_REG(hw, TPRL);
988 temp_reg = IXGB_READ_REG(hw, TPRH);
989 temp_reg = IXGB_READ_REG(hw, GPRCL);
990 temp_reg = IXGB_READ_REG(hw, GPRCH);
991 temp_reg = IXGB_READ_REG(hw, BPRCL);
992 temp_reg = IXGB_READ_REG(hw, BPRCH);
993 temp_reg = IXGB_READ_REG(hw, MPRCL);
994 temp_reg = IXGB_READ_REG(hw, MPRCH);
995 temp_reg = IXGB_READ_REG(hw, UPRCL);
996 temp_reg = IXGB_READ_REG(hw, UPRCH);
997 temp_reg = IXGB_READ_REG(hw, VPRCL);
998 temp_reg = IXGB_READ_REG(hw, VPRCH);
999 temp_reg = IXGB_READ_REG(hw, JPRCL);
1000 temp_reg = IXGB_READ_REG(hw, JPRCH);
1001 temp_reg = IXGB_READ_REG(hw, GORCL);
1002 temp_reg = IXGB_READ_REG(hw, GORCH);
1003 temp_reg = IXGB_READ_REG(hw, TORL);
1004 temp_reg = IXGB_READ_REG(hw, TORH);
1005 temp_reg = IXGB_READ_REG(hw, RNBC);
1006 temp_reg = IXGB_READ_REG(hw, RUC);
1007 temp_reg = IXGB_READ_REG(hw, ROC);
1008 temp_reg = IXGB_READ_REG(hw, RLEC);
1009 temp_reg = IXGB_READ_REG(hw, CRCERRS);
1010 temp_reg = IXGB_READ_REG(hw, ICBC);
1011 temp_reg = IXGB_READ_REG(hw, ECBC);
1012 temp_reg = IXGB_READ_REG(hw, MPC);
1013 temp_reg = IXGB_READ_REG(hw, TPTL);
1014 temp_reg = IXGB_READ_REG(hw, TPTH);
1015 temp_reg = IXGB_READ_REG(hw, GPTCL);
1016 temp_reg = IXGB_READ_REG(hw, GPTCH);
1017 temp_reg = IXGB_READ_REG(hw, BPTCL);
1018 temp_reg = IXGB_READ_REG(hw, BPTCH);
1019 temp_reg = IXGB_READ_REG(hw, MPTCL);
1020 temp_reg = IXGB_READ_REG(hw, MPTCH);
1021 temp_reg = IXGB_READ_REG(hw, UPTCL);
1022 temp_reg = IXGB_READ_REG(hw, UPTCH);
1023 temp_reg = IXGB_READ_REG(hw, VPTCL);
1024 temp_reg = IXGB_READ_REG(hw, VPTCH);
1025 temp_reg = IXGB_READ_REG(hw, JPTCL);
1026 temp_reg = IXGB_READ_REG(hw, JPTCH);
1027 temp_reg = IXGB_READ_REG(hw, GOTCL);
1028 temp_reg = IXGB_READ_REG(hw, GOTCH);
1029 temp_reg = IXGB_READ_REG(hw, TOTL);
1030 temp_reg = IXGB_READ_REG(hw, TOTH);
1031 temp_reg = IXGB_READ_REG(hw, DC);
1032 temp_reg = IXGB_READ_REG(hw, PLT64C);
1033 temp_reg = IXGB_READ_REG(hw, TSCTC);
1034 temp_reg = IXGB_READ_REG(hw, TSCTFC);
1035 temp_reg = IXGB_READ_REG(hw, IBIC);
1036 temp_reg = IXGB_READ_REG(hw, RFC);
1037 temp_reg = IXGB_READ_REG(hw, LFC);
1038 temp_reg = IXGB_READ_REG(hw, PFRC);
1039 temp_reg = IXGB_READ_REG(hw, PFTC);
1040 temp_reg = IXGB_READ_REG(hw, MCFRC);
1041 temp_reg = IXGB_READ_REG(hw, MCFTC);
1042 temp_reg = IXGB_READ_REG(hw, XONRXC);
1043 temp_reg = IXGB_READ_REG(hw, XONTXC);
1044 temp_reg = IXGB_READ_REG(hw, XOFFRXC);
1045 temp_reg = IXGB_READ_REG(hw, XOFFTXC);
1046 temp_reg = IXGB_READ_REG(hw, RJC);
1047}
1048
1049
1050
1051
1052
1053
1054void
1055ixgb_led_on(struct ixgb_hw *hw)
1056{
1057 u32 ctrl0_reg = IXGB_READ_REG(hw, CTRL0);
1058
1059
1060 ctrl0_reg &= ~IXGB_CTRL0_SDP0;
1061 IXGB_WRITE_REG(hw, CTRL0, ctrl0_reg);
1062}
1063
1064
1065
1066
1067
1068
1069void
1070ixgb_led_off(struct ixgb_hw *hw)
1071{
1072 u32 ctrl0_reg = IXGB_READ_REG(hw, CTRL0);
1073
1074
1075 ctrl0_reg |= IXGB_CTRL0_SDP0;
1076 IXGB_WRITE_REG(hw, CTRL0, ctrl0_reg);
1077}
1078
1079
1080
1081
1082
1083
1084static void
1085ixgb_get_bus_info(struct ixgb_hw *hw)
1086{
1087 u32 status_reg;
1088
1089 status_reg = IXGB_READ_REG(hw, STATUS);
1090
1091 hw->bus.type = (status_reg & IXGB_STATUS_PCIX_MODE) ?
1092 ixgb_bus_type_pcix : ixgb_bus_type_pci;
1093
1094 if (hw->bus.type == ixgb_bus_type_pci) {
1095 hw->bus.speed = (status_reg & IXGB_STATUS_PCI_SPD) ?
1096 ixgb_bus_speed_66 : ixgb_bus_speed_33;
1097 } else {
1098 switch (status_reg & IXGB_STATUS_PCIX_SPD_MASK) {
1099 case IXGB_STATUS_PCIX_SPD_66:
1100 hw->bus.speed = ixgb_bus_speed_66;
1101 break;
1102 case IXGB_STATUS_PCIX_SPD_100:
1103 hw->bus.speed = ixgb_bus_speed_100;
1104 break;
1105 case IXGB_STATUS_PCIX_SPD_133:
1106 hw->bus.speed = ixgb_bus_speed_133;
1107 break;
1108 default:
1109 hw->bus.speed = ixgb_bus_speed_reserved;
1110 break;
1111 }
1112 }
1113
1114 hw->bus.width = (status_reg & IXGB_STATUS_BUS64) ?
1115 ixgb_bus_width_64 : ixgb_bus_width_32;
1116}
1117
1118
1119
1120
1121
1122
1123
1124static bool
1125mac_addr_valid(u8 *mac_addr)
1126{
1127 bool is_valid = true;
1128 ENTER();
1129
1130
1131 if (is_multicast_ether_addr(mac_addr)) {
1132 pr_debug("MAC address is multicast\n");
1133 is_valid = false;
1134 }
1135
1136 else if (is_broadcast_ether_addr(mac_addr)) {
1137 pr_debug("MAC address is broadcast\n");
1138 is_valid = false;
1139 }
1140
1141 else if (is_zero_ether_addr(mac_addr)) {
1142 pr_debug("MAC address is all zeros\n");
1143 is_valid = false;
1144 }
1145 return is_valid;
1146}
1147
1148
1149
1150
1151
1152
1153
1154static bool
1155ixgb_link_reset(struct ixgb_hw *hw)
1156{
1157 bool link_status = false;
1158 u8 wait_retries = MAX_RESET_ITERATIONS;
1159 u8 lrst_retries = MAX_RESET_ITERATIONS;
1160
1161 do {
1162
1163 IXGB_WRITE_REG(hw, CTRL0,
1164 IXGB_READ_REG(hw, CTRL0) | IXGB_CTRL0_LRST);
1165
1166
1167 do {
1168 udelay(IXGB_DELAY_USECS_AFTER_LINK_RESET);
1169 link_status =
1170 ((IXGB_READ_REG(hw, STATUS) & IXGB_STATUS_LU)
1171 && (IXGB_READ_REG(hw, XPCSS) &
1172 IXGB_XPCSS_ALIGN_STATUS)) ? true : false;
1173 } while (!link_status && --wait_retries);
1174
1175 } while (!link_status && --lrst_retries);
1176
1177 return link_status;
1178}
1179
1180
1181
1182
1183
1184
1185static void
1186ixgb_optics_reset(struct ixgb_hw *hw)
1187{
1188 if (hw->phy_type == ixgb_phy_type_txn17401) {
1189 u16 mdio_reg;
1190
1191 ixgb_write_phy_reg(hw,
1192 MDIO_CTRL1,
1193 IXGB_PHY_ADDRESS,
1194 MDIO_MMD_PMAPMD,
1195 MDIO_CTRL1_RESET);
1196
1197 mdio_reg = ixgb_read_phy_reg(hw,
1198 MDIO_CTRL1,
1199 IXGB_PHY_ADDRESS,
1200 MDIO_MMD_PMAPMD);
1201 }
1202}
1203
1204
1205
1206
1207
1208
1209
1210#define IXGB_BCM8704_USER_PMD_TX_CTRL_REG 0xC803
1211#define IXGB_BCM8704_USER_PMD_TX_CTRL_REG_VAL 0x0164
1212#define IXGB_BCM8704_USER_CTRL_REG 0xC800
1213#define IXGB_BCM8704_USER_CTRL_REG_VAL 0x7FBF
1214#define IXGB_BCM8704_USER_DEV3_ADDR 0x0003
1215#define IXGB_SUN_PHY_ADDRESS 0x0000
1216#define IXGB_SUN_PHY_RESET_DELAY 305
1217
1218static void
1219ixgb_optics_reset_bcm(struct ixgb_hw *hw)
1220{
1221 u32 ctrl = IXGB_READ_REG(hw, CTRL0);
1222 ctrl &= ~IXGB_CTRL0_SDP2;
1223 ctrl |= IXGB_CTRL0_SDP3;
1224 IXGB_WRITE_REG(hw, CTRL0, ctrl);
1225 IXGB_WRITE_FLUSH(hw);
1226
1227
1228 msleep(IXGB_SUN_PHY_RESET_DELAY);
1229
1230
1231
1232 ixgb_write_phy_reg(hw,
1233 IXGB_BCM8704_USER_PMD_TX_CTRL_REG,
1234 IXGB_SUN_PHY_ADDRESS,
1235 IXGB_BCM8704_USER_DEV3_ADDR,
1236 IXGB_BCM8704_USER_PMD_TX_CTRL_REG_VAL);
1237
1238 ixgb_read_phy_reg(hw,
1239 IXGB_BCM8704_USER_PMD_TX_CTRL_REG,
1240 IXGB_SUN_PHY_ADDRESS,
1241 IXGB_BCM8704_USER_DEV3_ADDR);
1242 ixgb_read_phy_reg(hw,
1243 IXGB_BCM8704_USER_PMD_TX_CTRL_REG,
1244 IXGB_SUN_PHY_ADDRESS,
1245 IXGB_BCM8704_USER_DEV3_ADDR);
1246
1247 ixgb_write_phy_reg(hw,
1248 IXGB_BCM8704_USER_CTRL_REG,
1249 IXGB_SUN_PHY_ADDRESS,
1250 IXGB_BCM8704_USER_DEV3_ADDR,
1251 IXGB_BCM8704_USER_CTRL_REG_VAL);
1252 ixgb_read_phy_reg(hw,
1253 IXGB_BCM8704_USER_CTRL_REG,
1254 IXGB_SUN_PHY_ADDRESS,
1255 IXGB_BCM8704_USER_DEV3_ADDR);
1256 ixgb_read_phy_reg(hw,
1257 IXGB_BCM8704_USER_CTRL_REG,
1258 IXGB_SUN_PHY_ADDRESS,
1259 IXGB_BCM8704_USER_DEV3_ADDR);
1260
1261
1262 msleep(IXGB_SUN_PHY_RESET_DELAY);
1263}
1264