628
* ixgbe_write_eeprom_buffer_bit_bang_generic - Write EEPROM using bit-bang
629
* @hw: pointer to hardware structure
630
* @offset: offset within the EEPROM to write
631
* @words: number of words
632
* @data: 16 bit word(s) to write to EEPROM
634
* Reads 16 bit word(s) from EEPROM through bit-bang method
636
s32 ixgbe_write_eeprom_buffer_bit_bang_generic(struct ixgbe_hw *hw, u16 offset,
637
u16 words, u16 *data)
642
hw->eeprom.ops.init_params(hw);
645
status = IXGBE_ERR_INVALID_ARGUMENT;
649
if (offset + words > hw->eeprom.word_size) {
650
status = IXGBE_ERR_EEPROM;
655
* The EEPROM page size cannot be queried from the chip. We do lazy
656
* initialization. It is worth to do that when we write large buffer.
658
if ((hw->eeprom.word_page_size == 0) &&
659
(words > IXGBE_EEPROM_PAGE_SIZE_MAX))
660
ixgbe_detect_eeprom_page_size_generic(hw, offset);
663
* We cannot hold synchronization semaphores for too long
664
* to avoid other entity starvation. However it is more efficient
665
* to read in bursts than synchronizing access for each word.
667
for (i = 0; i < words; i += IXGBE_EEPROM_RD_BUFFER_MAX_COUNT) {
668
count = (words - i) / IXGBE_EEPROM_RD_BUFFER_MAX_COUNT > 0 ?
669
IXGBE_EEPROM_RD_BUFFER_MAX_COUNT : (words - i);
670
status = ixgbe_write_eeprom_buffer_bit_bang(hw, offset + i,
682
* ixgbe_write_eeprom_buffer_bit_bang - Writes 16 bit word(s) to EEPROM
683
* @hw: pointer to hardware structure
684
* @offset: offset within the EEPROM to be written to
685
* @words: number of word(s)
686
* @data: 16 bit word(s) to be written to the EEPROM
688
* If ixgbe_eeprom_update_checksum is not called after this function, the
689
* EEPROM will most likely contain an invalid checksum.
691
static s32 ixgbe_write_eeprom_buffer_bit_bang(struct ixgbe_hw *hw, u16 offset,
692
u16 words, u16 *data)
698
u8 write_opcode = IXGBE_EEPROM_WRITE_OPCODE_SPI;
700
/* Prepare the EEPROM for writing */
701
status = ixgbe_acquire_eeprom(hw);
704
if (ixgbe_ready_eeprom(hw) != 0) {
705
ixgbe_release_eeprom(hw);
706
status = IXGBE_ERR_EEPROM;
711
for (i = 0; i < words; i++) {
712
ixgbe_standby_eeprom(hw);
714
/* Send the WRITE ENABLE command (8 bit opcode ) */
715
ixgbe_shift_out_eeprom_bits(hw,
716
IXGBE_EEPROM_WREN_OPCODE_SPI,
717
IXGBE_EEPROM_OPCODE_BITS);
719
ixgbe_standby_eeprom(hw);
722
* Some SPI eeproms use the 8th address bit embedded
725
if ((hw->eeprom.address_bits == 8) &&
726
((offset + i) >= 128))
727
write_opcode |= IXGBE_EEPROM_A8_OPCODE_SPI;
729
/* Send the Write command (8-bit opcode + addr) */
730
ixgbe_shift_out_eeprom_bits(hw, write_opcode,
731
IXGBE_EEPROM_OPCODE_BITS);
732
ixgbe_shift_out_eeprom_bits(hw, (u16)((offset + i) * 2),
733
hw->eeprom.address_bits);
735
page_size = hw->eeprom.word_page_size;
737
/* Send the data in burst via SPI*/
740
word = (word >> 8) | (word << 8);
741
ixgbe_shift_out_eeprom_bits(hw, word, 16);
746
/* do not wrap around page */
747
if (((offset + i) & (page_size - 1)) ==
750
} while (++i < words);
752
ixgbe_standby_eeprom(hw);
753
usleep_range(10000, 20000);
755
/* Done with writing - release the EEPROM */
756
ixgbe_release_eeprom(hw);
549
763
* ixgbe_write_eeprom_generic - Writes 16 bit value to EEPROM
550
764
* @hw: pointer to hardware structure
551
765
* @offset: offset within the EEPROM to be written to
621
897
* Reads 16 bit value from EEPROM through bit-bang method
623
899
s32 ixgbe_read_eeprom_bit_bang_generic(struct ixgbe_hw *hw, u16 offset,
628
u8 read_opcode = IXGBE_EEPROM_READ_OPCODE_SPI;
630
hw->eeprom.ops.init_params(hw);
632
if (offset >= hw->eeprom.word_size) {
633
status = IXGBE_ERR_EEPROM;
637
/* Prepare the EEPROM for reading */
638
status = ixgbe_acquire_eeprom(hw);
641
if (ixgbe_ready_eeprom(hw) != 0) {
642
ixgbe_release_eeprom(hw);
643
status = IXGBE_ERR_EEPROM;
904
hw->eeprom.ops.init_params(hw);
906
if (offset >= hw->eeprom.word_size) {
907
status = IXGBE_ERR_EEPROM;
911
status = ixgbe_read_eeprom_buffer_bit_bang(hw, offset, 1, data);
918
* ixgbe_read_eerd_buffer_generic - Read EEPROM word(s) using EERD
919
* @hw: pointer to hardware structure
920
* @offset: offset of word in the EEPROM to read
921
* @words: number of word(s)
922
* @data: 16 bit word(s) from the EEPROM
924
* Reads a 16 bit word(s) from the EEPROM using the EERD register.
926
s32 ixgbe_read_eerd_buffer_generic(struct ixgbe_hw *hw, u16 offset,
927
u16 words, u16 *data)
933
hw->eeprom.ops.init_params(hw);
936
status = IXGBE_ERR_INVALID_ARGUMENT;
940
if (offset >= hw->eeprom.word_size) {
941
status = IXGBE_ERR_EEPROM;
945
for (i = 0; i < words; i++) {
946
eerd = ((offset + i) << IXGBE_EEPROM_RW_ADDR_SHIFT) +
947
IXGBE_EEPROM_RW_REG_START;
949
IXGBE_WRITE_REG(hw, IXGBE_EERD, eerd);
950
status = ixgbe_poll_eerd_eewr_done(hw, IXGBE_NVM_POLL_READ);
953
data[i] = (IXGBE_READ_REG(hw, IXGBE_EERD) >>
954
IXGBE_EEPROM_RW_REG_DATA);
956
hw_dbg(hw, "Eeprom read timed out\n");
648
ixgbe_standby_eeprom(hw);
651
* Some SPI eeproms use the 8th address bit embedded in the
654
if ((hw->eeprom.address_bits == 8) && (offset >= 128))
655
read_opcode |= IXGBE_EEPROM_A8_OPCODE_SPI;
657
/* Send the READ command (opcode + addr) */
658
ixgbe_shift_out_eeprom_bits(hw, read_opcode,
659
IXGBE_EEPROM_OPCODE_BITS);
660
ixgbe_shift_out_eeprom_bits(hw, (u16)(offset*2),
661
hw->eeprom.address_bits);
664
word_in = ixgbe_shift_in_eeprom_bits(hw, 16);
665
*data = (word_in >> 8) | (word_in << 8);
667
/* End this read operation */
668
ixgbe_release_eeprom(hw);
965
* ixgbe_detect_eeprom_page_size_generic - Detect EEPROM page size
966
* @hw: pointer to hardware structure
967
* @offset: offset within the EEPROM to be used as a scratch pad
969
* Discover EEPROM page size by writing marching data at given offset.
970
* This function is called only when we are writing a new large buffer
971
* at given offset so the data would be overwritten anyway.
973
static s32 ixgbe_detect_eeprom_page_size_generic(struct ixgbe_hw *hw,
976
u16 data[IXGBE_EEPROM_PAGE_SIZE_MAX];
980
for (i = 0; i < IXGBE_EEPROM_PAGE_SIZE_MAX; i++)
983
hw->eeprom.word_page_size = IXGBE_EEPROM_PAGE_SIZE_MAX;
984
status = ixgbe_write_eeprom_buffer_bit_bang(hw, offset,
985
IXGBE_EEPROM_PAGE_SIZE_MAX, data);
986
hw->eeprom.word_page_size = 0;
990
status = ixgbe_read_eeprom_buffer_bit_bang(hw, offset, 1, data);
995
* When writing in burst more than the actual page size
996
* EEPROM address wraps around current page.
998
hw->eeprom.word_page_size = IXGBE_EEPROM_PAGE_SIZE_MAX - data[0];
1000
hw_dbg(hw, "Detected EEPROM page size = %d words.",
1001
hw->eeprom.word_page_size);
683
1014
s32 ixgbe_read_eerd_generic(struct ixgbe_hw *hw, u16 offset, u16 *data)
1016
return ixgbe_read_eerd_buffer_generic(hw, offset, 1, data);
1020
* ixgbe_write_eewr_buffer_generic - Write EEPROM word(s) using EEWR
1021
* @hw: pointer to hardware structure
1022
* @offset: offset of word in the EEPROM to write
1023
* @words: number of words
1024
* @data: word(s) write to the EEPROM
1026
* Write a 16 bit word(s) to the EEPROM using the EEWR register.
1028
s32 ixgbe_write_eewr_buffer_generic(struct ixgbe_hw *hw, u16 offset,
1029
u16 words, u16 *data)
688
1035
hw->eeprom.ops.init_params(hw);
1038
status = IXGBE_ERR_INVALID_ARGUMENT;
690
1042
if (offset >= hw->eeprom.word_size) {
691
1043
status = IXGBE_ERR_EEPROM;
695
eerd = (offset << IXGBE_EEPROM_RW_ADDR_SHIFT) +
696
IXGBE_EEPROM_RW_REG_START;
698
IXGBE_WRITE_REG(hw, IXGBE_EERD, eerd);
699
status = ixgbe_poll_eerd_eewr_done(hw, IXGBE_NVM_POLL_READ);
702
*data = (IXGBE_READ_REG(hw, IXGBE_EERD) >>
703
IXGBE_EEPROM_RW_REG_DATA);
705
hw_dbg(hw, "Eeprom read timed out\n");
1047
for (i = 0; i < words; i++) {
1048
eewr = ((offset + i) << IXGBE_EEPROM_RW_ADDR_SHIFT) |
1049
(data[i] << IXGBE_EEPROM_RW_REG_DATA) |
1050
IXGBE_EEPROM_RW_REG_START;
1052
status = ixgbe_poll_eerd_eewr_done(hw, IXGBE_NVM_POLL_WRITE);
1054
hw_dbg(hw, "Eeprom write EEWR timed out\n");
1058
IXGBE_WRITE_REG(hw, IXGBE_EEWR, eewr);
1060
status = ixgbe_poll_eerd_eewr_done(hw, IXGBE_NVM_POLL_WRITE);
1062
hw_dbg(hw, "Eeprom write EEWR timed out\n");
1072
* ixgbe_write_eewr_generic - Write EEPROM word using EEWR
1073
* @hw: pointer to hardware structure
1074
* @offset: offset of word in the EEPROM to write
1075
* @data: word write to the EEPROM
1077
* Write a 16 bit word to the EEPROM using the EEWR register.
1079
s32 ixgbe_write_eewr_generic(struct ixgbe_hw *hw, u16 offset, u16 data)
1081
return ixgbe_write_eewr_buffer_generic(hw, offset, 1, &data);
712
1085
* ixgbe_poll_eerd_eewr_done - Poll EERD read or EEWR write status
713
1086
* @hw: pointer to hardware structure
714
1087
* @ee_reg: EEPROM flag for polling
1404
* ixgbe_add_uc_addr - Adds a secondary unicast address.
1405
* @hw: pointer to hardware structure
1406
* @addr: new address
1408
* Adds it to unused receive address register or goes into promiscuous mode.
1410
static void ixgbe_add_uc_addr(struct ixgbe_hw *hw, u8 *addr, u32 vmdq)
1412
u32 rar_entries = hw->mac.num_rar_entries;
1415
hw_dbg(hw, " UC Addr = %.2X %.2X %.2X %.2X %.2X %.2X\n",
1416
addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]);
1419
* Place this address in the RAR if there is room,
1420
* else put the controller into promiscuous mode
1422
if (hw->addr_ctrl.rar_used_count < rar_entries) {
1423
rar = hw->addr_ctrl.rar_used_count -
1424
hw->addr_ctrl.mc_addr_in_rar_count;
1425
hw->mac.ops.set_rar(hw, rar, addr, vmdq, IXGBE_RAH_AV);
1426
hw_dbg(hw, "Added a secondary address to RAR[%d]\n", rar);
1427
hw->addr_ctrl.rar_used_count++;
1429
hw->addr_ctrl.overflow_promisc++;
1432
hw_dbg(hw, "ixgbe_add_uc_addr Complete\n");
1436
* ixgbe_update_uc_addr_list_generic - Updates MAC list of secondary addresses
1437
* @hw: pointer to hardware structure
1438
* @netdev: pointer to net device structure
1440
* The given list replaces any existing list. Clears the secondary addrs from
1441
* receive address registers. Uses unused receive address registers for the
1442
* first secondary addresses, and falls back to promiscuous mode as needed.
1444
* Drivers using secondary unicast addresses must set user_set_promisc when
1445
* manually putting the device into promiscuous mode.
1447
s32 ixgbe_update_uc_addr_list_generic(struct ixgbe_hw *hw,
1448
struct net_device *netdev)
1451
u32 old_promisc_setting = hw->addr_ctrl.overflow_promisc;
1454
struct netdev_hw_addr *ha;
1457
* Clear accounting of old secondary address list,
1458
* don't count RAR[0]
1460
uc_addr_in_use = hw->addr_ctrl.rar_used_count - 1;
1461
hw->addr_ctrl.rar_used_count -= uc_addr_in_use;
1462
hw->addr_ctrl.overflow_promisc = 0;
1464
/* Zero out the other receive addresses */
1465
hw_dbg(hw, "Clearing RAR[1-%d]\n", uc_addr_in_use + 1);
1466
for (i = 0; i < uc_addr_in_use; i++) {
1467
IXGBE_WRITE_REG(hw, IXGBE_RAL(1+i), 0);
1468
IXGBE_WRITE_REG(hw, IXGBE_RAH(1+i), 0);
1471
/* Add the new addresses */
1472
netdev_for_each_uc_addr(ha, netdev) {
1473
hw_dbg(hw, " Adding the secondary addresses:\n");
1474
ixgbe_add_uc_addr(hw, ha->addr, 0);
1477
if (hw->addr_ctrl.overflow_promisc) {
1478
/* enable promisc if not already in overflow or set by user */
1479
if (!old_promisc_setting && !hw->addr_ctrl.user_set_promisc) {
1480
hw_dbg(hw, " Entering address overflow promisc mode\n");
1481
fctrl = IXGBE_READ_REG(hw, IXGBE_FCTRL);
1482
fctrl |= IXGBE_FCTRL_UPE;
1483
IXGBE_WRITE_REG(hw, IXGBE_FCTRL, fctrl);
1484
hw->addr_ctrl.uc_set_promisc = true;
1487
/* only disable if set by overflow, not by user */
1488
if ((old_promisc_setting && hw->addr_ctrl.uc_set_promisc) &&
1489
!(hw->addr_ctrl.user_set_promisc)) {
1490
hw_dbg(hw, " Leaving address overflow promisc mode\n");
1491
fctrl = IXGBE_READ_REG(hw, IXGBE_FCTRL);
1492
fctrl &= ~IXGBE_FCTRL_UPE;
1493
IXGBE_WRITE_REG(hw, IXGBE_FCTRL, fctrl);
1494
hw->addr_ctrl.uc_set_promisc = false;
1498
hw_dbg(hw, "ixgbe_update_uc_addr_list_generic Complete\n");
1503
1773
* ixgbe_mta_vector - Determines bit-vector in multicast table to set
1504
1774
* @hw: pointer to hardware structure
1505
1775
* @mc_addr: the multicast address
1807
2066
* So use link_up_wait_to_complete=false.
1809
2068
hw->mac.ops.check_link(hw, &speed, &link_up, false);
1811
if (hw->fc.disable_fc_autoneg || (!link_up)) {
2070
ret_val = IXGBE_ERR_FLOW_CONTROL;
2074
switch (hw->phy.media_type) {
2075
/* Autoneg flow control on fiber adapters */
2076
case ixgbe_media_type_fiber:
2077
if (speed == IXGBE_LINK_SPEED_1GB_FULL)
2078
ret_val = ixgbe_fc_autoneg_fiber(hw);
2081
/* Autoneg flow control on backplane adapters */
2082
case ixgbe_media_type_backplane:
2083
ret_val = ixgbe_fc_autoneg_backplane(hw);
2086
/* Autoneg flow control on copper adapters */
2087
case ixgbe_media_type_copper:
2088
if (ixgbe_device_supports_autoneg_fc(hw) == 0)
2089
ret_val = ixgbe_fc_autoneg_copper(hw);
2098
hw->fc.fc_was_autonegged = true;
1812
2100
hw->fc.fc_was_autonegged = false;
1813
2101
hw->fc.current_mode = hw->fc.requested_mode;
2107
* ixgbe_fc_autoneg_fiber - Enable flow control on 1 gig fiber
2108
* @hw: pointer to hardware structure
2110
* Enable flow control according on 1 gig fiber.
2112
static s32 ixgbe_fc_autoneg_fiber(struct ixgbe_hw *hw)
2114
u32 pcs_anadv_reg, pcs_lpab_reg, linkstat;
2118
* On multispeed fiber at 1g, bail out if
2119
* - link is up but AN did not complete, or if
2120
* - link is up and AN completed but timed out
2123
linkstat = IXGBE_READ_REG(hw, IXGBE_PCS1GLSTA);
2124
if (((linkstat & IXGBE_PCS1GLSTA_AN_COMPLETE) == 0) ||
2125
((linkstat & IXGBE_PCS1GLSTA_AN_TIMED_OUT) == 1)) {
2126
ret_val = IXGBE_ERR_FC_NOT_NEGOTIATED;
2130
pcs_anadv_reg = IXGBE_READ_REG(hw, IXGBE_PCS1GANA);
2131
pcs_lpab_reg = IXGBE_READ_REG(hw, IXGBE_PCS1GANLP);
2133
ret_val = ixgbe_negotiate_fc(hw, pcs_anadv_reg,
2134
pcs_lpab_reg, IXGBE_PCS1GANA_SYM_PAUSE,
2135
IXGBE_PCS1GANA_ASM_PAUSE,
2136
IXGBE_PCS1GANA_SYM_PAUSE,
2137
IXGBE_PCS1GANA_ASM_PAUSE);
2144
* ixgbe_fc_autoneg_backplane - Enable flow control IEEE clause 37
2145
* @hw: pointer to hardware structure
2147
* Enable flow control according to IEEE clause 37.
2149
static s32 ixgbe_fc_autoneg_backplane(struct ixgbe_hw *hw)
2151
u32 links2, anlp1_reg, autoc_reg, links;
1818
2155
* On backplane, bail out if
1819
2156
* - backplane autoneg was not completed, or if
1820
2157
* - we are 82599 and link partner is not AN enabled
1822
if (hw->phy.media_type == ixgbe_media_type_backplane) {
1823
links = IXGBE_READ_REG(hw, IXGBE_LINKS);
1824
if ((links & IXGBE_LINKS_KX_AN_COMP) == 0) {
1825
hw->fc.fc_was_autonegged = false;
1826
hw->fc.current_mode = hw->fc.requested_mode;
1830
if (hw->mac.type == ixgbe_mac_82599EB) {
1831
links2 = IXGBE_READ_REG(hw, IXGBE_LINKS2);
1832
if ((links2 & IXGBE_LINKS2_AN_SUPPORTED) == 0) {
1833
hw->fc.fc_was_autonegged = false;
1834
hw->fc.current_mode = hw->fc.requested_mode;
1841
* On multispeed fiber at 1g, bail out if
1842
* - link is up but AN did not complete, or if
1843
* - link is up and AN completed but timed out
1845
if (hw->phy.multispeed_fiber && (speed == IXGBE_LINK_SPEED_1GB_FULL)) {
1846
linkstat = IXGBE_READ_REG(hw, IXGBE_PCS1GLSTA);
1847
if (((linkstat & IXGBE_PCS1GLSTA_AN_COMPLETE) == 0) ||
1848
((linkstat & IXGBE_PCS1GLSTA_AN_TIMED_OUT) == 1)) {
1849
hw->fc.fc_was_autonegged = false;
1850
hw->fc.current_mode = hw->fc.requested_mode;
1857
* - copper or CX4 adapters
1858
* - fiber adapters running at 10gig
1860
if ((hw->phy.media_type == ixgbe_media_type_copper) ||
1861
(hw->phy.media_type == ixgbe_media_type_cx4) ||
1862
((hw->phy.media_type == ixgbe_media_type_fiber) &&
1863
(speed == IXGBE_LINK_SPEED_10GB_FULL))) {
2159
links = IXGBE_READ_REG(hw, IXGBE_LINKS);
2160
if ((links & IXGBE_LINKS_KX_AN_COMP) == 0) {
1864
2161
hw->fc.fc_was_autonegged = false;
1865
2162
hw->fc.current_mode = hw->fc.requested_mode;
2163
ret_val = IXGBE_ERR_FC_NOT_NEGOTIATED;
2167
if (hw->mac.type == ixgbe_mac_82599EB) {
2168
links2 = IXGBE_READ_REG(hw, IXGBE_LINKS2);
2169
if ((links2 & IXGBE_LINKS2_AN_SUPPORTED) == 0) {
2170
hw->fc.fc_was_autonegged = false;
2171
hw->fc.current_mode = hw->fc.requested_mode;
2172
ret_val = IXGBE_ERR_FC_NOT_NEGOTIATED;
1870
* Read the AN advertisement and LP ability registers and resolve
2177
* Read the 10g AN autoc and LP ability registers and resolve
1871
2178
* local flow control settings accordingly
1873
if ((speed == IXGBE_LINK_SPEED_1GB_FULL) &&
1874
(hw->phy.media_type != ixgbe_media_type_backplane)) {
1875
pcs_anadv_reg = IXGBE_READ_REG(hw, IXGBE_PCS1GANA);
1876
pcs_lpab_reg = IXGBE_READ_REG(hw, IXGBE_PCS1GANLP);
1877
if ((pcs_anadv_reg & IXGBE_PCS1GANA_SYM_PAUSE) &&
1878
(pcs_lpab_reg & IXGBE_PCS1GANA_SYM_PAUSE)) {
1880
* Now we need to check if the user selected Rx ONLY
1881
* of pause frames. In this case, we had to advertise
1882
* FULL flow control because we could not advertise RX
1883
* ONLY. Hence, we must now check to see if we need to
1884
* turn OFF the TRANSMISSION of PAUSE frames.
1886
if (hw->fc.requested_mode == ixgbe_fc_full) {
1887
hw->fc.current_mode = ixgbe_fc_full;
1888
hw_dbg(hw, "Flow Control = FULL.\n");
1890
hw->fc.current_mode = ixgbe_fc_rx_pause;
1891
hw_dbg(hw, "Flow Control=RX PAUSE only\n");
1893
} else if (!(pcs_anadv_reg & IXGBE_PCS1GANA_SYM_PAUSE) &&
1894
(pcs_anadv_reg & IXGBE_PCS1GANA_ASM_PAUSE) &&
1895
(pcs_lpab_reg & IXGBE_PCS1GANA_SYM_PAUSE) &&
1896
(pcs_lpab_reg & IXGBE_PCS1GANA_ASM_PAUSE)) {
1897
hw->fc.current_mode = ixgbe_fc_tx_pause;
1898
hw_dbg(hw, "Flow Control = TX PAUSE frames only.\n");
1899
} else if ((pcs_anadv_reg & IXGBE_PCS1GANA_SYM_PAUSE) &&
1900
(pcs_anadv_reg & IXGBE_PCS1GANA_ASM_PAUSE) &&
1901
!(pcs_lpab_reg & IXGBE_PCS1GANA_SYM_PAUSE) &&
1902
(pcs_lpab_reg & IXGBE_PCS1GANA_ASM_PAUSE)) {
1903
hw->fc.current_mode = ixgbe_fc_rx_pause;
1904
hw_dbg(hw, "Flow Control = RX PAUSE frames only.\n");
1906
hw->fc.current_mode = ixgbe_fc_none;
1907
hw_dbg(hw, "Flow Control = NONE.\n");
1911
if (hw->phy.media_type == ixgbe_media_type_backplane) {
2180
autoc_reg = IXGBE_READ_REG(hw, IXGBE_AUTOC);
2181
anlp1_reg = IXGBE_READ_REG(hw, IXGBE_ANLP1);
2183
ret_val = ixgbe_negotiate_fc(hw, autoc_reg,
2184
anlp1_reg, IXGBE_AUTOC_SYM_PAUSE, IXGBE_AUTOC_ASM_PAUSE,
2185
IXGBE_ANLP1_SYM_PAUSE, IXGBE_ANLP1_ASM_PAUSE);
2192
* ixgbe_fc_autoneg_copper - Enable flow control IEEE clause 37
2193
* @hw: pointer to hardware structure
2195
* Enable flow control according to IEEE clause 37.
2197
static s32 ixgbe_fc_autoneg_copper(struct ixgbe_hw *hw)
2199
u16 technology_ability_reg = 0;
2200
u16 lp_technology_ability_reg = 0;
2202
hw->phy.ops.read_reg(hw, MDIO_AN_ADVERTISE,
2204
&technology_ability_reg);
2205
hw->phy.ops.read_reg(hw, MDIO_AN_LPA,
2207
&lp_technology_ability_reg);
2209
return ixgbe_negotiate_fc(hw, (u32)technology_ability_reg,
2210
(u32)lp_technology_ability_reg,
2211
IXGBE_TAF_SYM_PAUSE, IXGBE_TAF_ASM_PAUSE,
2212
IXGBE_TAF_SYM_PAUSE, IXGBE_TAF_ASM_PAUSE);
2216
* ixgbe_negotiate_fc - Negotiate flow control
2217
* @hw: pointer to hardware structure
2218
* @adv_reg: flow control advertised settings
2219
* @lp_reg: link partner's flow control settings
2220
* @adv_sym: symmetric pause bit in advertisement
2221
* @adv_asm: asymmetric pause bit in advertisement
2222
* @lp_sym: symmetric pause bit in link partner advertisement
2223
* @lp_asm: asymmetric pause bit in link partner advertisement
2225
* Find the intersection between advertised settings and link partner's
2226
* advertised settings
2228
static s32 ixgbe_negotiate_fc(struct ixgbe_hw *hw, u32 adv_reg, u32 lp_reg,
2229
u32 adv_sym, u32 adv_asm, u32 lp_sym, u32 lp_asm)
2231
if ((!(adv_reg)) || (!(lp_reg)))
2232
return IXGBE_ERR_FC_NOT_NEGOTIATED;
2234
if ((adv_reg & adv_sym) && (lp_reg & lp_sym)) {
1913
* Read the 10g AN autoc and LP ability registers and resolve
1914
* local flow control settings accordingly
2236
* Now we need to check if the user selected Rx ONLY
2237
* of pause frames. In this case, we had to advertise
2238
* FULL flow control because we could not advertise RX
2239
* ONLY. Hence, we must now check to see if we need to
2240
* turn OFF the TRANSMISSION of PAUSE frames.
1916
autoc_reg = IXGBE_READ_REG(hw, IXGBE_AUTOC);
1917
anlp1_reg = IXGBE_READ_REG(hw, IXGBE_ANLP1);
1919
if ((autoc_reg & IXGBE_AUTOC_SYM_PAUSE) &&
1920
(anlp1_reg & IXGBE_ANLP1_SYM_PAUSE)) {
1922
* Now we need to check if the user selected Rx ONLY
1923
* of pause frames. In this case, we had to advertise
1924
* FULL flow control because we could not advertise RX
1925
* ONLY. Hence, we must now check to see if we need to
1926
* turn OFF the TRANSMISSION of PAUSE frames.
1928
if (hw->fc.requested_mode == ixgbe_fc_full) {
1929
hw->fc.current_mode = ixgbe_fc_full;
1930
hw_dbg(hw, "Flow Control = FULL.\n");
1932
hw->fc.current_mode = ixgbe_fc_rx_pause;
1933
hw_dbg(hw, "Flow Control=RX PAUSE only\n");
1935
} else if (!(autoc_reg & IXGBE_AUTOC_SYM_PAUSE) &&
1936
(autoc_reg & IXGBE_AUTOC_ASM_PAUSE) &&
1937
(anlp1_reg & IXGBE_ANLP1_SYM_PAUSE) &&
1938
(anlp1_reg & IXGBE_ANLP1_ASM_PAUSE)) {
1939
hw->fc.current_mode = ixgbe_fc_tx_pause;
1940
hw_dbg(hw, "Flow Control = TX PAUSE frames only.\n");
1941
} else if ((autoc_reg & IXGBE_AUTOC_SYM_PAUSE) &&
1942
(autoc_reg & IXGBE_AUTOC_ASM_PAUSE) &&
1943
!(anlp1_reg & IXGBE_ANLP1_SYM_PAUSE) &&
1944
(anlp1_reg & IXGBE_ANLP1_ASM_PAUSE)) {
2242
if (hw->fc.requested_mode == ixgbe_fc_full) {
2243
hw->fc.current_mode = ixgbe_fc_full;
2244
hw_dbg(hw, "Flow Control = FULL.\n");
1945
2246
hw->fc.current_mode = ixgbe_fc_rx_pause;
1946
hw_dbg(hw, "Flow Control = RX PAUSE frames only.\n");
1948
hw->fc.current_mode = ixgbe_fc_none;
1949
hw_dbg(hw, "Flow Control = NONE.\n");
2247
hw_dbg(hw, "Flow Control=RX PAUSE frames only\n");
2249
} else if (!(adv_reg & adv_sym) && (adv_reg & adv_asm) &&
2250
(lp_reg & lp_sym) && (lp_reg & lp_asm)) {
2251
hw->fc.current_mode = ixgbe_fc_tx_pause;
2252
hw_dbg(hw, "Flow Control = TX PAUSE frames only.\n");
2253
} else if ((adv_reg & adv_sym) && (adv_reg & adv_asm) &&
2254
!(lp_reg & lp_sym) && (lp_reg & lp_asm)) {
2255
hw->fc.current_mode = ixgbe_fc_rx_pause;
2256
hw_dbg(hw, "Flow Control = RX PAUSE frames only.\n");
2258
hw->fc.current_mode = ixgbe_fc_none;
2259
hw_dbg(hw, "Flow Control = NONE.\n");
1952
/* Record that current_mode is the result of a successful autoneg */
1953
hw->fc.fc_was_autonegged = true;
2054
2385
reg |= (IXGBE_PCS1GANA_ASM_PAUSE);
2055
2386
reg &= ~(IXGBE_PCS1GANA_SYM_PAUSE);
2387
if (hw->phy.media_type == ixgbe_media_type_backplane) {
2388
reg_bp |= (IXGBE_AUTOC_ASM_PAUSE);
2389
reg_bp &= ~(IXGBE_AUTOC_SYM_PAUSE);
2390
} else if (hw->phy.media_type == ixgbe_media_type_copper) {
2391
reg_cu |= (IXGBE_TAF_ASM_PAUSE);
2392
reg_cu &= ~(IXGBE_TAF_SYM_PAUSE);
2057
2395
case ixgbe_fc_full:
2058
2396
/* Flow control (both Rx and Tx) is enabled by SW override. */
2059
2397
reg |= (IXGBE_PCS1GANA_SYM_PAUSE | IXGBE_PCS1GANA_ASM_PAUSE);
2065
#endif /* CONFIG_DCB */
2067
hw_dbg(hw, "Flow control param set incorrectly\n");
2068
ret_val = IXGBE_ERR_CONFIG;
2073
IXGBE_WRITE_REG(hw, IXGBE_PCS1GANA, reg);
2074
reg = IXGBE_READ_REG(hw, IXGBE_PCS1GLCTL);
2076
/* Disable AN timeout */
2077
if (hw->fc.strict_ieee)
2078
reg &= ~IXGBE_PCS1GLCTL_AN_1G_TIMEOUT_EN;
2080
IXGBE_WRITE_REG(hw, IXGBE_PCS1GLCTL, reg);
2081
hw_dbg(hw, "Set up FC; PCS1GLCTL = 0x%08X\n", reg);
2084
* Set up the 10G flow control advertisement registers so the HW
2085
* can do fc autoneg once the cable is plugged in. If we end up
2086
* using 1g instead, this is harmless.
2088
reg = IXGBE_READ_REG(hw, IXGBE_AUTOC);
2091
* The possible values of fc.requested_mode are:
2092
* 0: Flow control is completely disabled
2093
* 1: Rx flow control is enabled (we can receive pause frames,
2094
* but not send pause frames).
2095
* 2: Tx flow control is enabled (we can send pause frames but
2096
* we do not support receiving pause frames).
2097
* 3: Both Rx and Tx flow control (symmetric) are enabled.
2100
switch (hw->fc.requested_mode) {
2102
/* Flow control completely disabled by software override. */
2103
reg &= ~(IXGBE_AUTOC_SYM_PAUSE | IXGBE_AUTOC_ASM_PAUSE);
2105
case ixgbe_fc_rx_pause:
2107
* Rx Flow control is enabled and Tx Flow control is
2108
* disabled by software override. Since there really
2109
* isn't a way to advertise that we are capable of RX
2110
* Pause ONLY, we will advertise that we support both
2111
* symmetric and asymmetric Rx PAUSE. Later, we will
2112
* disable the adapter's ability to send PAUSE frames.
2114
reg |= (IXGBE_AUTOC_SYM_PAUSE | IXGBE_AUTOC_ASM_PAUSE);
2116
case ixgbe_fc_tx_pause:
2118
* Tx Flow control is enabled, and Rx Flow control is
2119
* disabled by software override.
2121
reg |= (IXGBE_AUTOC_ASM_PAUSE);
2122
reg &= ~(IXGBE_AUTOC_SYM_PAUSE);
2125
/* Flow control (both Rx and Tx) is enabled by SW override. */
2126
reg |= (IXGBE_AUTOC_SYM_PAUSE | IXGBE_AUTOC_ASM_PAUSE);
2132
#endif /* CONFIG_DCB */
2134
hw_dbg(hw, "Flow control param set incorrectly\n");
2135
ret_val = IXGBE_ERR_CONFIG;
2140
* AUTOC restart handles negotiation of 1G and 10G. There is
2141
* no need to set the PCS1GCTL register.
2143
reg |= IXGBE_AUTOC_AN_RESTART;
2144
IXGBE_WRITE_REG(hw, IXGBE_AUTOC, reg);
2398
if (hw->phy.media_type == ixgbe_media_type_backplane)
2399
reg_bp |= (IXGBE_AUTOC_SYM_PAUSE |
2400
IXGBE_AUTOC_ASM_PAUSE);
2401
else if (hw->phy.media_type == ixgbe_media_type_copper)
2402
reg_cu |= (IXGBE_TAF_SYM_PAUSE | IXGBE_TAF_ASM_PAUSE);
2408
#endif /* CONFIG_DCB */
2410
hw_dbg(hw, "Flow control param set incorrectly\n");
2411
ret_val = IXGBE_ERR_CONFIG;
2416
if (hw->mac.type != ixgbe_mac_X540) {
2418
* Enable auto-negotiation between the MAC & PHY;
2419
* the MAC will advertise clause 37 flow control.
2421
IXGBE_WRITE_REG(hw, IXGBE_PCS1GANA, reg);
2422
reg = IXGBE_READ_REG(hw, IXGBE_PCS1GLCTL);
2424
/* Disable AN timeout */
2425
if (hw->fc.strict_ieee)
2426
reg &= ~IXGBE_PCS1GLCTL_AN_1G_TIMEOUT_EN;
2428
IXGBE_WRITE_REG(hw, IXGBE_PCS1GLCTL, reg);
2429
hw_dbg(hw, "Set up FC; PCS1GLCTL = 0x%08X\n", reg);
2433
* AUTOC restart handles negotiation of 1G and 10G on backplane
2434
* and copper. There is no need to set the PCS1GCTL register.
2437
if (hw->phy.media_type == ixgbe_media_type_backplane) {
2438
reg_bp |= IXGBE_AUTOC_AN_RESTART;
2439
IXGBE_WRITE_REG(hw, IXGBE_AUTOC, reg_bp);
2440
} else if ((hw->phy.media_type == ixgbe_media_type_copper) &&
2441
(ixgbe_device_supports_autoneg_fc(hw) == 0)) {
2442
hw->phy.ops.write_reg(hw, MDIO_AN_ADVERTISE,
2443
MDIO_MMD_AN, reg_cu);
2145
2446
hw_dbg(hw, "Set up FC; IXGBE_AUTOC = 0x%08X\n", reg);
2148
2448
return ret_val;