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