diff options
author | PJ Waskiewicz <peter.p.waskiewicz.jr@intel.com> | 2009-02-27 10:44:30 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-03-01 03:24:33 -0500 |
commit | 11afc1b1fd802c11dc0fa986c210602c177f1e21 (patch) | |
tree | 16f46e5acf0aa7b5ec8b1a0cc07a0c89ac002642 /drivers/net/ixgbe/ixgbe_common.c | |
parent | 8010dc306ba39a8cdb3993d1e809fcb7dfdf089a (diff) |
ixgbe: Add hardware specific initialization code for 82599 devices
This patch adds the hardware initialization code specific to 82599. This
is similar to the 82598 hardware initialization code. It also includes all
changes to the existing hardware init code to support 82599.
Signed-off-by: Peter P Waskiewicz Jr <peter.p.waskiewicz.jr@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ixgbe/ixgbe_common.c')
-rw-r--r-- | drivers/net/ixgbe/ixgbe_common.c | 319 |
1 files changed, 319 insertions, 0 deletions
diff --git a/drivers/net/ixgbe/ixgbe_common.c b/drivers/net/ixgbe/ixgbe_common.c index 5ae93989784f..26ee8a04646e 100644 --- a/drivers/net/ixgbe/ixgbe_common.c +++ b/drivers/net/ixgbe/ixgbe_common.c | |||
@@ -29,6 +29,7 @@ | |||
29 | #include <linux/delay.h> | 29 | #include <linux/delay.h> |
30 | #include <linux/sched.h> | 30 | #include <linux/sched.h> |
31 | 31 | ||
32 | #include "ixgbe.h" | ||
32 | #include "ixgbe_common.h" | 33 | #include "ixgbe_common.h" |
33 | #include "ixgbe_phy.h" | 34 | #include "ixgbe_phy.h" |
34 | 35 | ||
@@ -251,6 +252,81 @@ s32 ixgbe_get_mac_addr_generic(struct ixgbe_hw *hw, u8 *mac_addr) | |||
251 | } | 252 | } |
252 | 253 | ||
253 | /** | 254 | /** |
255 | * ixgbe_get_bus_info_generic - Generic set PCI bus info | ||
256 | * @hw: pointer to hardware structure | ||
257 | * | ||
258 | * Sets the PCI bus info (speed, width, type) within the ixgbe_hw structure | ||
259 | **/ | ||
260 | s32 ixgbe_get_bus_info_generic(struct ixgbe_hw *hw) | ||
261 | { | ||
262 | struct ixgbe_adapter *adapter = hw->back; | ||
263 | struct ixgbe_mac_info *mac = &hw->mac; | ||
264 | u16 link_status; | ||
265 | |||
266 | hw->bus.type = ixgbe_bus_type_pci_express; | ||
267 | |||
268 | /* Get the negotiated link width and speed from PCI config space */ | ||
269 | pci_read_config_word(adapter->pdev, IXGBE_PCI_LINK_STATUS, | ||
270 | &link_status); | ||
271 | |||
272 | switch (link_status & IXGBE_PCI_LINK_WIDTH) { | ||
273 | case IXGBE_PCI_LINK_WIDTH_1: | ||
274 | hw->bus.width = ixgbe_bus_width_pcie_x1; | ||
275 | break; | ||
276 | case IXGBE_PCI_LINK_WIDTH_2: | ||
277 | hw->bus.width = ixgbe_bus_width_pcie_x2; | ||
278 | break; | ||
279 | case IXGBE_PCI_LINK_WIDTH_4: | ||
280 | hw->bus.width = ixgbe_bus_width_pcie_x4; | ||
281 | break; | ||
282 | case IXGBE_PCI_LINK_WIDTH_8: | ||
283 | hw->bus.width = ixgbe_bus_width_pcie_x8; | ||
284 | break; | ||
285 | default: | ||
286 | hw->bus.width = ixgbe_bus_width_unknown; | ||
287 | break; | ||
288 | } | ||
289 | |||
290 | switch (link_status & IXGBE_PCI_LINK_SPEED) { | ||
291 | case IXGBE_PCI_LINK_SPEED_2500: | ||
292 | hw->bus.speed = ixgbe_bus_speed_2500; | ||
293 | break; | ||
294 | case IXGBE_PCI_LINK_SPEED_5000: | ||
295 | hw->bus.speed = ixgbe_bus_speed_5000; | ||
296 | break; | ||
297 | default: | ||
298 | hw->bus.speed = ixgbe_bus_speed_unknown; | ||
299 | break; | ||
300 | } | ||
301 | |||
302 | mac->ops.set_lan_id(hw); | ||
303 | |||
304 | return 0; | ||
305 | } | ||
306 | |||
307 | /** | ||
308 | * ixgbe_set_lan_id_multi_port_pcie - Set LAN id for PCIe multiple port devices | ||
309 | * @hw: pointer to the HW structure | ||
310 | * | ||
311 | * Determines the LAN function id by reading memory-mapped registers | ||
312 | * and swaps the port value if requested. | ||
313 | **/ | ||
314 | void ixgbe_set_lan_id_multi_port_pcie(struct ixgbe_hw *hw) | ||
315 | { | ||
316 | struct ixgbe_bus_info *bus = &hw->bus; | ||
317 | u32 reg; | ||
318 | |||
319 | reg = IXGBE_READ_REG(hw, IXGBE_STATUS); | ||
320 | bus->func = (reg & IXGBE_STATUS_LAN_ID) >> IXGBE_STATUS_LAN_ID_SHIFT; | ||
321 | bus->lan_id = bus->func; | ||
322 | |||
323 | /* check for a port swap */ | ||
324 | reg = IXGBE_READ_REG(hw, IXGBE_FACTPS); | ||
325 | if (reg & IXGBE_FACTPS_LFS) | ||
326 | bus->func ^= 0x1; | ||
327 | } | ||
328 | |||
329 | /** | ||
254 | * ixgbe_stop_adapter_generic - Generic stop Tx/Rx units | 330 | * ixgbe_stop_adapter_generic - Generic stop Tx/Rx units |
255 | * @hw: pointer to hardware structure | 331 | * @hw: pointer to hardware structure |
256 | * | 332 | * |
@@ -390,6 +466,73 @@ s32 ixgbe_init_eeprom_params_generic(struct ixgbe_hw *hw) | |||
390 | } | 466 | } |
391 | 467 | ||
392 | /** | 468 | /** |
469 | * ixgbe_write_eeprom_generic - Writes 16 bit value to EEPROM | ||
470 | * @hw: pointer to hardware structure | ||
471 | * @offset: offset within the EEPROM to be written to | ||
472 | * @data: 16 bit word to be written to the EEPROM | ||
473 | * | ||
474 | * If ixgbe_eeprom_update_checksum is not called after this function, the | ||
475 | * EEPROM will most likely contain an invalid checksum. | ||
476 | **/ | ||
477 | s32 ixgbe_write_eeprom_generic(struct ixgbe_hw *hw, u16 offset, u16 data) | ||
478 | { | ||
479 | s32 status; | ||
480 | u8 write_opcode = IXGBE_EEPROM_WRITE_OPCODE_SPI; | ||
481 | |||
482 | hw->eeprom.ops.init_params(hw); | ||
483 | |||
484 | if (offset >= hw->eeprom.word_size) { | ||
485 | status = IXGBE_ERR_EEPROM; | ||
486 | goto out; | ||
487 | } | ||
488 | |||
489 | /* Prepare the EEPROM for writing */ | ||
490 | status = ixgbe_acquire_eeprom(hw); | ||
491 | |||
492 | if (status == 0) { | ||
493 | if (ixgbe_ready_eeprom(hw) != 0) { | ||
494 | ixgbe_release_eeprom(hw); | ||
495 | status = IXGBE_ERR_EEPROM; | ||
496 | } | ||
497 | } | ||
498 | |||
499 | if (status == 0) { | ||
500 | ixgbe_standby_eeprom(hw); | ||
501 | |||
502 | /* Send the WRITE ENABLE command (8 bit opcode ) */ | ||
503 | ixgbe_shift_out_eeprom_bits(hw, IXGBE_EEPROM_WREN_OPCODE_SPI, | ||
504 | IXGBE_EEPROM_OPCODE_BITS); | ||
505 | |||
506 | ixgbe_standby_eeprom(hw); | ||
507 | |||
508 | /* | ||
509 | * Some SPI eeproms use the 8th address bit embedded in the | ||
510 | * opcode | ||
511 | */ | ||
512 | if ((hw->eeprom.address_bits == 8) && (offset >= 128)) | ||
513 | write_opcode |= IXGBE_EEPROM_A8_OPCODE_SPI; | ||
514 | |||
515 | /* Send the Write command (8-bit opcode + addr) */ | ||
516 | ixgbe_shift_out_eeprom_bits(hw, write_opcode, | ||
517 | IXGBE_EEPROM_OPCODE_BITS); | ||
518 | ixgbe_shift_out_eeprom_bits(hw, (u16)(offset*2), | ||
519 | hw->eeprom.address_bits); | ||
520 | |||
521 | /* Send the data */ | ||
522 | data = (data >> 8) | (data << 8); | ||
523 | ixgbe_shift_out_eeprom_bits(hw, data, 16); | ||
524 | ixgbe_standby_eeprom(hw); | ||
525 | |||
526 | msleep(hw->eeprom.semaphore_delay); | ||
527 | /* Done with writing - release the EEPROM */ | ||
528 | ixgbe_release_eeprom(hw); | ||
529 | } | ||
530 | |||
531 | out: | ||
532 | return status; | ||
533 | } | ||
534 | |||
535 | /** | ||
393 | * ixgbe_read_eeprom_bit_bang_generic - Read EEPROM word using bit-bang | 536 | * ixgbe_read_eeprom_bit_bang_generic - Read EEPROM word using bit-bang |
394 | * @hw: pointer to hardware structure | 537 | * @hw: pointer to hardware structure |
395 | * @offset: offset within the EEPROM to be read | 538 | * @offset: offset within the EEPROM to be read |
@@ -1487,6 +1630,101 @@ s32 ixgbe_disable_mc_generic(struct ixgbe_hw *hw) | |||
1487 | } | 1630 | } |
1488 | 1631 | ||
1489 | /** | 1632 | /** |
1633 | * ixgbe_fc_enable - Enable flow control | ||
1634 | * @hw: pointer to hardware structure | ||
1635 | * @packetbuf_num: packet buffer number (0-7) | ||
1636 | * | ||
1637 | * Enable flow control according to the current settings. | ||
1638 | **/ | ||
1639 | s32 ixgbe_fc_enable(struct ixgbe_hw *hw, s32 packetbuf_num) | ||
1640 | { | ||
1641 | s32 ret_val = 0; | ||
1642 | u32 mflcn_reg; | ||
1643 | u32 fccfg_reg; | ||
1644 | u32 reg; | ||
1645 | |||
1646 | mflcn_reg = IXGBE_READ_REG(hw, IXGBE_MFLCN); | ||
1647 | mflcn_reg &= ~(IXGBE_MFLCN_RFCE | IXGBE_MFLCN_RPFCE); | ||
1648 | |||
1649 | fccfg_reg = IXGBE_READ_REG(hw, IXGBE_FCCFG); | ||
1650 | fccfg_reg &= ~(IXGBE_FCCFG_TFCE_802_3X | IXGBE_FCCFG_TFCE_PRIORITY); | ||
1651 | |||
1652 | /* | ||
1653 | * The possible values of fc.current_mode are: | ||
1654 | * 0: Flow control is completely disabled | ||
1655 | * 1: Rx flow control is enabled (we can receive pause frames, | ||
1656 | * but not send pause frames). | ||
1657 | * 2: Tx flow control is enabled (we can send pause frames but | ||
1658 | * we do not support receiving pause frames). | ||
1659 | * 3: Both Rx and Tx flow control (symmetric) are enabled. | ||
1660 | * other: Invalid. | ||
1661 | */ | ||
1662 | switch (hw->fc.current_mode) { | ||
1663 | case ixgbe_fc_none: | ||
1664 | /* Flow control completely disabled by software override. */ | ||
1665 | break; | ||
1666 | case ixgbe_fc_rx_pause: | ||
1667 | /* | ||
1668 | * Rx Flow control is enabled and Tx Flow control is | ||
1669 | * disabled by software override. Since there really | ||
1670 | * isn't a way to advertise that we are capable of RX | ||
1671 | * Pause ONLY, we will advertise that we support both | ||
1672 | * symmetric and asymmetric Rx PAUSE. Later, we will | ||
1673 | * disable the adapter's ability to send PAUSE frames. | ||
1674 | */ | ||
1675 | mflcn_reg |= IXGBE_MFLCN_RFCE; | ||
1676 | break; | ||
1677 | case ixgbe_fc_tx_pause: | ||
1678 | /* | ||
1679 | * Tx Flow control is enabled, and Rx Flow control is | ||
1680 | * disabled by software override. | ||
1681 | */ | ||
1682 | fccfg_reg |= IXGBE_FCCFG_TFCE_802_3X; | ||
1683 | break; | ||
1684 | case ixgbe_fc_full: | ||
1685 | /* Flow control (both Rx and Tx) is enabled by SW override. */ | ||
1686 | mflcn_reg |= IXGBE_MFLCN_RFCE; | ||
1687 | fccfg_reg |= IXGBE_FCCFG_TFCE_802_3X; | ||
1688 | break; | ||
1689 | default: | ||
1690 | hw_dbg(hw, "Flow control param set incorrectly\n"); | ||
1691 | ret_val = -IXGBE_ERR_CONFIG; | ||
1692 | goto out; | ||
1693 | break; | ||
1694 | } | ||
1695 | |||
1696 | /* Enable 802.3x based flow control settings. */ | ||
1697 | IXGBE_WRITE_REG(hw, IXGBE_MFLCN, mflcn_reg); | ||
1698 | IXGBE_WRITE_REG(hw, IXGBE_FCCFG, fccfg_reg); | ||
1699 | |||
1700 | /* Set up and enable Rx high/low water mark thresholds, enable XON. */ | ||
1701 | if (hw->fc.current_mode & ixgbe_fc_tx_pause) { | ||
1702 | if (hw->fc.send_xon) | ||
1703 | IXGBE_WRITE_REG(hw, IXGBE_FCRTL_82599(packetbuf_num), | ||
1704 | (hw->fc.low_water | IXGBE_FCRTL_XONE)); | ||
1705 | else | ||
1706 | IXGBE_WRITE_REG(hw, IXGBE_FCRTL_82599(packetbuf_num), | ||
1707 | hw->fc.low_water); | ||
1708 | |||
1709 | IXGBE_WRITE_REG(hw, IXGBE_FCRTH_82599(packetbuf_num), | ||
1710 | (hw->fc.high_water | IXGBE_FCRTH_FCEN)); | ||
1711 | } | ||
1712 | |||
1713 | /* Configure pause time (2 TCs per register) */ | ||
1714 | reg = IXGBE_READ_REG(hw, IXGBE_FCTTV(packetbuf_num)); | ||
1715 | if ((packetbuf_num & 1) == 0) | ||
1716 | reg = (reg & 0xFFFF0000) | hw->fc.pause_time; | ||
1717 | else | ||
1718 | reg = (reg & 0x0000FFFF) | (hw->fc.pause_time << 16); | ||
1719 | IXGBE_WRITE_REG(hw, IXGBE_FCTTV(packetbuf_num / 2), reg); | ||
1720 | |||
1721 | IXGBE_WRITE_REG(hw, IXGBE_FCRTV, (hw->fc.pause_time >> 1)); | ||
1722 | |||
1723 | out: | ||
1724 | return ret_val; | ||
1725 | } | ||
1726 | |||
1727 | /** | ||
1490 | * ixgbe_fc_autoneg - Configure flow control | 1728 | * ixgbe_fc_autoneg - Configure flow control |
1491 | * @hw: pointer to hardware structure | 1729 | * @hw: pointer to hardware structure |
1492 | * | 1730 | * |
@@ -1625,6 +1863,74 @@ out: | |||
1625 | } | 1863 | } |
1626 | 1864 | ||
1627 | /** | 1865 | /** |
1866 | * ixgbe_setup_fc_generic - Set up flow control | ||
1867 | * @hw: pointer to hardware structure | ||
1868 | * | ||
1869 | * Sets up flow control. | ||
1870 | **/ | ||
1871 | s32 ixgbe_setup_fc_generic(struct ixgbe_hw *hw, s32 packetbuf_num) | ||
1872 | { | ||
1873 | s32 ret_val = 0; | ||
1874 | ixgbe_link_speed speed; | ||
1875 | bool link_up; | ||
1876 | |||
1877 | /* Validate the packetbuf configuration */ | ||
1878 | if (packetbuf_num < 0 || packetbuf_num > 7) { | ||
1879 | hw_dbg(hw, "Invalid packet buffer number [%d], expected range " | ||
1880 | "is 0-7\n", packetbuf_num); | ||
1881 | ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS; | ||
1882 | goto out; | ||
1883 | } | ||
1884 | |||
1885 | /* | ||
1886 | * Validate the water mark configuration. Zero water marks are invalid | ||
1887 | * because it causes the controller to just blast out fc packets. | ||
1888 | */ | ||
1889 | if (!hw->fc.low_water || !hw->fc.high_water || !hw->fc.pause_time) { | ||
1890 | hw_dbg(hw, "Invalid water mark configuration\n"); | ||
1891 | ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS; | ||
1892 | goto out; | ||
1893 | } | ||
1894 | |||
1895 | /* | ||
1896 | * Validate the requested mode. Strict IEEE mode does not allow | ||
1897 | * ixgbe_fc_rx_pause because it will cause testing anomalies. | ||
1898 | */ | ||
1899 | if (hw->fc.strict_ieee && hw->fc.requested_mode == ixgbe_fc_rx_pause) { | ||
1900 | hw_dbg(hw, "ixgbe_fc_rx_pause not valid in strict " | ||
1901 | "IEEE mode\n"); | ||
1902 | ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS; | ||
1903 | goto out; | ||
1904 | } | ||
1905 | |||
1906 | /* | ||
1907 | * 10gig parts do not have a word in the EEPROM to determine the | ||
1908 | * default flow control setting, so we explicitly set it to full. | ||
1909 | */ | ||
1910 | if (hw->fc.requested_mode == ixgbe_fc_default) | ||
1911 | hw->fc.requested_mode = ixgbe_fc_full; | ||
1912 | |||
1913 | /* | ||
1914 | * Save off the requested flow control mode for use later. Depending | ||
1915 | * on the link partner's capabilities, we may or may not use this mode. | ||
1916 | */ | ||
1917 | hw->fc.current_mode = hw->fc.requested_mode; | ||
1918 | |||
1919 | /* Decide whether to use autoneg or not. */ | ||
1920 | hw->mac.ops.check_link(hw, &speed, &link_up, false); | ||
1921 | if (hw->phy.multispeed_fiber && (speed == IXGBE_LINK_SPEED_1GB_FULL)) | ||
1922 | ret_val = ixgbe_fc_autoneg(hw); | ||
1923 | |||
1924 | if (ret_val) | ||
1925 | goto out; | ||
1926 | |||
1927 | ret_val = ixgbe_fc_enable(hw, packetbuf_num); | ||
1928 | |||
1929 | out: | ||
1930 | return ret_val; | ||
1931 | } | ||
1932 | |||
1933 | /** | ||
1628 | * ixgbe_disable_pcie_master - Disable PCI-express master access | 1934 | * ixgbe_disable_pcie_master - Disable PCI-express master access |
1629 | * @hw: pointer to hardware structure | 1935 | * @hw: pointer to hardware structure |
1630 | * | 1936 | * |
@@ -1732,3 +2038,16 @@ void ixgbe_release_swfw_sync(struct ixgbe_hw *hw, u16 mask) | |||
1732 | ixgbe_release_eeprom_semaphore(hw); | 2038 | ixgbe_release_eeprom_semaphore(hw); |
1733 | } | 2039 | } |
1734 | 2040 | ||
2041 | /** | ||
2042 | * ixgbe_enable_rx_dma_generic - Enable the Rx DMA unit | ||
2043 | * @hw: pointer to hardware structure | ||
2044 | * @regval: register value to write to RXCTRL | ||
2045 | * | ||
2046 | * Enables the Rx DMA unit | ||
2047 | **/ | ||
2048 | s32 ixgbe_enable_rx_dma_generic(struct ixgbe_hw *hw, u32 regval) | ||
2049 | { | ||
2050 | IXGBE_WRITE_REG(hw, IXGBE_RXCTRL, regval); | ||
2051 | |||
2052 | return 0; | ||
2053 | } | ||