1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2001-2018
5 #include "ixgbe_type.h"
6 #include "ixgbe_82598.h"
8 #include "ixgbe_common.h"
11 #define IXGBE_82598_MAX_TX_QUEUES 32
12 #define IXGBE_82598_MAX_RX_QUEUES 64
13 #define IXGBE_82598_RAR_ENTRIES 16
14 #define IXGBE_82598_MC_TBL_SIZE 128
15 #define IXGBE_82598_VFT_TBL_SIZE 128
16 #define IXGBE_82598_RX_PB_SIZE 512
18 STATIC s32 ixgbe_get_link_capabilities_82598(struct ixgbe_hw *hw,
19 ixgbe_link_speed *speed,
21 STATIC enum ixgbe_media_type ixgbe_get_media_type_82598(struct ixgbe_hw *hw);
22 STATIC s32 ixgbe_start_mac_link_82598(struct ixgbe_hw *hw,
23 bool autoneg_wait_to_complete);
24 STATIC s32 ixgbe_check_mac_link_82598(struct ixgbe_hw *hw,
25 ixgbe_link_speed *speed, bool *link_up,
26 bool link_up_wait_to_complete);
27 STATIC s32 ixgbe_setup_mac_link_82598(struct ixgbe_hw *hw,
28 ixgbe_link_speed speed,
29 bool autoneg_wait_to_complete);
30 STATIC s32 ixgbe_setup_copper_link_82598(struct ixgbe_hw *hw,
31 ixgbe_link_speed speed,
32 bool autoneg_wait_to_complete);
33 STATIC s32 ixgbe_reset_hw_82598(struct ixgbe_hw *hw);
34 STATIC s32 ixgbe_clear_vmdq_82598(struct ixgbe_hw *hw, u32 rar, u32 vmdq);
35 STATIC s32 ixgbe_clear_vfta_82598(struct ixgbe_hw *hw);
36 STATIC void ixgbe_set_rxpba_82598(struct ixgbe_hw *hw, int num_pb,
37 u32 headroom, int strategy);
38 STATIC s32 ixgbe_read_i2c_sff8472_82598(struct ixgbe_hw *hw, u8 byte_offset,
41 * ixgbe_set_pcie_completion_timeout - set pci-e completion timeout
42 * @hw: pointer to the HW structure
44 * The defaults for 82598 should be in the range of 50us to 50ms,
45 * however the hardware default for these parts is 500us to 1ms which is less
46 * than the 10ms recommended by the pci-e spec. To address this we need to
47 * increase the value to either 10ms to 250ms for capability version 1 config,
48 * or 16ms to 55ms for version 2.
50 void ixgbe_set_pcie_completion_timeout(struct ixgbe_hw *hw)
52 u32 gcr = IXGBE_READ_REG(hw, IXGBE_GCR);
55 /* only take action if timeout value is defaulted to 0 */
56 if (gcr & IXGBE_GCR_CMPL_TMOUT_MASK)
60 * if capababilities version is type 1 we can write the
61 * timeout of 10ms to 250ms through the GCR register
63 if (!(gcr & IXGBE_GCR_CAP_VER2)) {
64 gcr |= IXGBE_GCR_CMPL_TMOUT_10ms;
69 * for version 2 capabilities we need to write the config space
70 * directly in order to set the completion timeout value for
73 pcie_devctl2 = IXGBE_READ_PCIE_WORD(hw, IXGBE_PCI_DEVICE_CONTROL2);
74 pcie_devctl2 |= IXGBE_PCI_DEVICE_CONTROL2_16ms;
75 IXGBE_WRITE_PCIE_WORD(hw, IXGBE_PCI_DEVICE_CONTROL2, pcie_devctl2);
77 /* disable completion timeout resend */
78 gcr &= ~IXGBE_GCR_CMPL_TMOUT_RESEND;
79 IXGBE_WRITE_REG(hw, IXGBE_GCR, gcr);
83 * ixgbe_init_ops_82598 - Inits func ptrs and MAC type
84 * @hw: pointer to hardware structure
86 * Initialize the function pointers and assign the MAC type for 82598.
87 * Does not touch the hardware.
89 s32 ixgbe_init_ops_82598(struct ixgbe_hw *hw)
91 struct ixgbe_mac_info *mac = &hw->mac;
92 struct ixgbe_phy_info *phy = &hw->phy;
95 DEBUGFUNC("ixgbe_init_ops_82598");
97 ret_val = ixgbe_init_phy_ops_generic(hw);
98 ret_val = ixgbe_init_ops_generic(hw);
101 phy->ops.init = ixgbe_init_phy_ops_82598;
104 mac->ops.start_hw = ixgbe_start_hw_82598;
105 mac->ops.enable_relaxed_ordering = ixgbe_enable_relaxed_ordering_82598;
106 mac->ops.reset_hw = ixgbe_reset_hw_82598;
107 mac->ops.get_media_type = ixgbe_get_media_type_82598;
108 mac->ops.get_supported_physical_layer =
109 ixgbe_get_supported_physical_layer_82598;
110 mac->ops.read_analog_reg8 = ixgbe_read_analog_reg8_82598;
111 mac->ops.write_analog_reg8 = ixgbe_write_analog_reg8_82598;
112 mac->ops.set_lan_id = ixgbe_set_lan_id_multi_port_pcie_82598;
113 mac->ops.enable_rx_dma = ixgbe_enable_rx_dma_82598;
115 /* RAR, Multicast, VLAN */
116 mac->ops.set_vmdq = ixgbe_set_vmdq_82598;
117 mac->ops.clear_vmdq = ixgbe_clear_vmdq_82598;
118 mac->ops.set_vfta = ixgbe_set_vfta_82598;
119 mac->ops.set_vlvf = NULL;
120 mac->ops.clear_vfta = ixgbe_clear_vfta_82598;
123 mac->ops.fc_enable = ixgbe_fc_enable_82598;
125 mac->mcft_size = IXGBE_82598_MC_TBL_SIZE;
126 mac->vft_size = IXGBE_82598_VFT_TBL_SIZE;
127 mac->num_rar_entries = IXGBE_82598_RAR_ENTRIES;
128 mac->rx_pb_size = IXGBE_82598_RX_PB_SIZE;
129 mac->max_rx_queues = IXGBE_82598_MAX_RX_QUEUES;
130 mac->max_tx_queues = IXGBE_82598_MAX_TX_QUEUES;
131 mac->max_msix_vectors = ixgbe_get_pcie_msix_count_generic(hw);
134 phy->ops.read_i2c_eeprom = ixgbe_read_i2c_eeprom_82598;
135 phy->ops.read_i2c_sff8472 = ixgbe_read_i2c_sff8472_82598;
138 mac->ops.check_link = ixgbe_check_mac_link_82598;
139 mac->ops.setup_link = ixgbe_setup_mac_link_82598;
140 mac->ops.flap_tx_laser = NULL;
141 mac->ops.get_link_capabilities = ixgbe_get_link_capabilities_82598;
142 mac->ops.setup_rxpba = ixgbe_set_rxpba_82598;
144 /* Manageability interface */
145 mac->ops.set_fw_drv_ver = NULL;
147 mac->ops.get_rtrup2tc = NULL;
153 * ixgbe_init_phy_ops_82598 - PHY/SFP specific init
154 * @hw: pointer to hardware structure
156 * Initialize any function pointers that were not able to be
157 * set during init_shared_code because the PHY/SFP type was
158 * not known. Perform the SFP init if necessary.
161 s32 ixgbe_init_phy_ops_82598(struct ixgbe_hw *hw)
163 struct ixgbe_mac_info *mac = &hw->mac;
164 struct ixgbe_phy_info *phy = &hw->phy;
165 s32 ret_val = IXGBE_SUCCESS;
166 u16 list_offset, data_offset;
168 DEBUGFUNC("ixgbe_init_phy_ops_82598");
170 /* Identify the PHY */
171 phy->ops.identify(hw);
173 /* Overwrite the link function pointers if copper PHY */
174 if (mac->ops.get_media_type(hw) == ixgbe_media_type_copper) {
175 mac->ops.setup_link = ixgbe_setup_copper_link_82598;
176 mac->ops.get_link_capabilities =
177 ixgbe_get_copper_link_capabilities_generic;
180 switch (hw->phy.type) {
182 phy->ops.setup_link = ixgbe_setup_phy_link_tnx;
183 phy->ops.check_link = ixgbe_check_phy_link_tnx;
184 phy->ops.get_firmware_version =
185 ixgbe_get_phy_firmware_version_tnx;
188 phy->ops.reset = ixgbe_reset_phy_nl;
190 /* Call SFP+ identify routine to get the SFP+ module type */
191 ret_val = phy->ops.identify_sfp(hw);
192 if (ret_val != IXGBE_SUCCESS)
194 else if (hw->phy.sfp_type == ixgbe_sfp_type_unknown) {
195 ret_val = IXGBE_ERR_SFP_NOT_SUPPORTED;
199 /* Check to see if SFP+ module is supported */
200 ret_val = ixgbe_get_sfp_init_sequence_offsets(hw,
203 if (ret_val != IXGBE_SUCCESS) {
204 ret_val = IXGBE_ERR_SFP_NOT_SUPPORTED;
217 * ixgbe_start_hw_82598 - Prepare hardware for Tx/Rx
218 * @hw: pointer to hardware structure
220 * Starts the hardware using the generic start_hw function.
221 * Disables relaxed ordering Then set pcie completion timeout
224 s32 ixgbe_start_hw_82598(struct ixgbe_hw *hw)
228 s32 ret_val = IXGBE_SUCCESS;
230 DEBUGFUNC("ixgbe_start_hw_82598");
232 ret_val = ixgbe_start_hw_generic(hw);
236 /* Disable relaxed ordering */
237 for (i = 0; ((i < hw->mac.max_tx_queues) &&
238 (i < IXGBE_DCA_MAX_QUEUES_82598)); i++) {
239 regval = IXGBE_READ_REG(hw, IXGBE_DCA_TXCTRL(i));
240 regval &= ~IXGBE_DCA_TXCTRL_DESC_WRO_EN;
241 IXGBE_WRITE_REG(hw, IXGBE_DCA_TXCTRL(i), regval);
244 for (i = 0; ((i < hw->mac.max_rx_queues) &&
245 (i < IXGBE_DCA_MAX_QUEUES_82598)); i++) {
246 regval = IXGBE_READ_REG(hw, IXGBE_DCA_RXCTRL(i));
247 regval &= ~(IXGBE_DCA_RXCTRL_DATA_WRO_EN |
248 IXGBE_DCA_RXCTRL_HEAD_WRO_EN);
249 IXGBE_WRITE_REG(hw, IXGBE_DCA_RXCTRL(i), regval);
252 /* set the completion timeout for interface */
253 ixgbe_set_pcie_completion_timeout(hw);
259 * ixgbe_get_link_capabilities_82598 - Determines link capabilities
260 * @hw: pointer to hardware structure
261 * @speed: pointer to link speed
262 * @autoneg: boolean auto-negotiation value
264 * Determines the link capabilities by reading the AUTOC register.
266 STATIC s32 ixgbe_get_link_capabilities_82598(struct ixgbe_hw *hw,
267 ixgbe_link_speed *speed,
270 s32 status = IXGBE_SUCCESS;
273 DEBUGFUNC("ixgbe_get_link_capabilities_82598");
276 * Determine link capabilities based on the stored value of AUTOC,
277 * which represents EEPROM defaults. If AUTOC value has not been
278 * stored, use the current register value.
280 if (hw->mac.orig_link_settings_stored)
281 autoc = hw->mac.orig_autoc;
283 autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC);
285 switch (autoc & IXGBE_AUTOC_LMS_MASK) {
286 case IXGBE_AUTOC_LMS_1G_LINK_NO_AN:
287 *speed = IXGBE_LINK_SPEED_1GB_FULL;
291 case IXGBE_AUTOC_LMS_10G_LINK_NO_AN:
292 *speed = IXGBE_LINK_SPEED_10GB_FULL;
296 case IXGBE_AUTOC_LMS_1G_AN:
297 *speed = IXGBE_LINK_SPEED_1GB_FULL;
301 case IXGBE_AUTOC_LMS_KX4_AN:
302 case IXGBE_AUTOC_LMS_KX4_AN_1G_AN:
303 *speed = IXGBE_LINK_SPEED_UNKNOWN;
304 if (autoc & IXGBE_AUTOC_KX4_SUPP)
305 *speed |= IXGBE_LINK_SPEED_10GB_FULL;
306 if (autoc & IXGBE_AUTOC_KX_SUPP)
307 *speed |= IXGBE_LINK_SPEED_1GB_FULL;
312 status = IXGBE_ERR_LINK_SETUP;
320 * ixgbe_get_media_type_82598 - Determines media type
321 * @hw: pointer to hardware structure
323 * Returns the media type (fiber, copper, backplane)
325 STATIC enum ixgbe_media_type ixgbe_get_media_type_82598(struct ixgbe_hw *hw)
327 enum ixgbe_media_type media_type;
329 DEBUGFUNC("ixgbe_get_media_type_82598");
331 /* Detect if there is a copper PHY attached. */
332 switch (hw->phy.type) {
333 case ixgbe_phy_cu_unknown:
335 media_type = ixgbe_media_type_copper;
341 /* Media type for I82598 is based on device ID */
342 switch (hw->device_id) {
343 case IXGBE_DEV_ID_82598:
344 case IXGBE_DEV_ID_82598_BX:
345 /* Default device ID is mezzanine card KX/KX4 */
346 media_type = ixgbe_media_type_backplane;
348 case IXGBE_DEV_ID_82598AF_DUAL_PORT:
349 case IXGBE_DEV_ID_82598AF_SINGLE_PORT:
350 case IXGBE_DEV_ID_82598_DA_DUAL_PORT:
351 case IXGBE_DEV_ID_82598_SR_DUAL_PORT_EM:
352 case IXGBE_DEV_ID_82598EB_XF_LR:
353 case IXGBE_DEV_ID_82598EB_SFP_LOM:
354 media_type = ixgbe_media_type_fiber;
356 case IXGBE_DEV_ID_82598EB_CX4:
357 case IXGBE_DEV_ID_82598_CX4_DUAL_PORT:
358 media_type = ixgbe_media_type_cx4;
360 case IXGBE_DEV_ID_82598AT:
361 case IXGBE_DEV_ID_82598AT2:
362 media_type = ixgbe_media_type_copper;
365 media_type = ixgbe_media_type_unknown;
373 * ixgbe_fc_enable_82598 - Enable flow control
374 * @hw: pointer to hardware structure
376 * Enable flow control according to the current settings.
378 s32 ixgbe_fc_enable_82598(struct ixgbe_hw *hw)
380 s32 ret_val = IXGBE_SUCCESS;
389 DEBUGFUNC("ixgbe_fc_enable_82598");
391 /* Validate the water mark configuration */
392 if (!hw->fc.pause_time) {
393 ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS;
397 /* Low water mark of zero causes XOFF floods */
398 for (i = 0; i < IXGBE_DCB_MAX_TRAFFIC_CLASS; i++) {
399 if ((hw->fc.current_mode & ixgbe_fc_tx_pause) &&
400 hw->fc.high_water[i]) {
401 if (!hw->fc.low_water[i] ||
402 hw->fc.low_water[i] >= hw->fc.high_water[i]) {
403 DEBUGOUT("Invalid water mark configuration\n");
404 ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS;
411 * On 82598 having Rx FC on causes resets while doing 1G
412 * so if it's on turn it off once we know link_speed. For
413 * more details see 82598 Specification update.
415 hw->mac.ops.check_link(hw, &link_speed, &link_up, false);
416 if (link_up && link_speed == IXGBE_LINK_SPEED_1GB_FULL) {
417 switch (hw->fc.requested_mode) {
419 hw->fc.requested_mode = ixgbe_fc_tx_pause;
421 case ixgbe_fc_rx_pause:
422 hw->fc.requested_mode = ixgbe_fc_none;
430 /* Negotiate the fc mode to use */
431 ixgbe_fc_autoneg(hw);
433 /* Disable any previous flow control settings */
434 fctrl_reg = IXGBE_READ_REG(hw, IXGBE_FCTRL);
435 fctrl_reg &= ~(IXGBE_FCTRL_RFCE | IXGBE_FCTRL_RPFCE);
437 rmcs_reg = IXGBE_READ_REG(hw, IXGBE_RMCS);
438 rmcs_reg &= ~(IXGBE_RMCS_TFCE_PRIORITY | IXGBE_RMCS_TFCE_802_3X);
441 * The possible values of fc.current_mode are:
442 * 0: Flow control is completely disabled
443 * 1: Rx flow control is enabled (we can receive pause frames,
444 * but not send pause frames).
445 * 2: Tx flow control is enabled (we can send pause frames but
446 * we do not support receiving pause frames).
447 * 3: Both Rx and Tx flow control (symmetric) are enabled.
450 switch (hw->fc.current_mode) {
453 * Flow control is disabled by software override or autoneg.
454 * The code below will actually disable it in the HW.
457 case ixgbe_fc_rx_pause:
459 * Rx Flow control is enabled and Tx Flow control is
460 * disabled by software override. Since there really
461 * isn't a way to advertise that we are capable of RX
462 * Pause ONLY, we will advertise that we support both
463 * symmetric and asymmetric Rx PAUSE. Later, we will
464 * disable the adapter's ability to send PAUSE frames.
466 fctrl_reg |= IXGBE_FCTRL_RFCE;
468 case ixgbe_fc_tx_pause:
470 * Tx Flow control is enabled, and Rx Flow control is
471 * disabled by software override.
473 rmcs_reg |= IXGBE_RMCS_TFCE_802_3X;
476 /* Flow control (both Rx and Tx) is enabled by SW override. */
477 fctrl_reg |= IXGBE_FCTRL_RFCE;
478 rmcs_reg |= IXGBE_RMCS_TFCE_802_3X;
481 DEBUGOUT("Flow control param set incorrectly\n");
482 ret_val = IXGBE_ERR_CONFIG;
487 /* Set 802.3x based flow control settings. */
488 fctrl_reg |= IXGBE_FCTRL_DPF;
489 IXGBE_WRITE_REG(hw, IXGBE_FCTRL, fctrl_reg);
490 IXGBE_WRITE_REG(hw, IXGBE_RMCS, rmcs_reg);
492 /* Set up and enable Rx high/low water mark thresholds, enable XON. */
493 for (i = 0; i < IXGBE_DCB_MAX_TRAFFIC_CLASS; i++) {
494 if ((hw->fc.current_mode & ixgbe_fc_tx_pause) &&
495 hw->fc.high_water[i]) {
496 fcrtl = (hw->fc.low_water[i] << 10) | IXGBE_FCRTL_XONE;
497 fcrth = (hw->fc.high_water[i] << 10) | IXGBE_FCRTH_FCEN;
498 IXGBE_WRITE_REG(hw, IXGBE_FCRTL(i), fcrtl);
499 IXGBE_WRITE_REG(hw, IXGBE_FCRTH(i), fcrth);
501 IXGBE_WRITE_REG(hw, IXGBE_FCRTL(i), 0);
502 IXGBE_WRITE_REG(hw, IXGBE_FCRTH(i), 0);
507 /* Configure pause time (2 TCs per register) */
508 reg = hw->fc.pause_time * 0x00010001;
509 for (i = 0; i < (IXGBE_DCB_MAX_TRAFFIC_CLASS / 2); i++)
510 IXGBE_WRITE_REG(hw, IXGBE_FCTTV(i), reg);
512 /* Configure flow control refresh threshold value */
513 IXGBE_WRITE_REG(hw, IXGBE_FCRTV, hw->fc.pause_time / 2);
520 * ixgbe_start_mac_link_82598 - Configures MAC link settings
521 * @hw: pointer to hardware structure
522 * @autoneg_wait_to_complete: true when waiting for completion is needed
524 * Configures link settings based on values in the ixgbe_hw struct.
525 * Restarts the link. Performs autonegotiation if needed.
527 STATIC s32 ixgbe_start_mac_link_82598(struct ixgbe_hw *hw,
528 bool autoneg_wait_to_complete)
533 s32 status = IXGBE_SUCCESS;
535 DEBUGFUNC("ixgbe_start_mac_link_82598");
538 autoc_reg = IXGBE_READ_REG(hw, IXGBE_AUTOC);
539 autoc_reg |= IXGBE_AUTOC_AN_RESTART;
540 IXGBE_WRITE_REG(hw, IXGBE_AUTOC, autoc_reg);
542 /* Only poll for autoneg to complete if specified to do so */
543 if (autoneg_wait_to_complete) {
544 if ((autoc_reg & IXGBE_AUTOC_LMS_MASK) ==
545 IXGBE_AUTOC_LMS_KX4_AN ||
546 (autoc_reg & IXGBE_AUTOC_LMS_MASK) ==
547 IXGBE_AUTOC_LMS_KX4_AN_1G_AN) {
548 links_reg = 0; /* Just in case Autoneg time = 0 */
549 for (i = 0; i < IXGBE_AUTO_NEG_TIME; i++) {
550 links_reg = IXGBE_READ_REG(hw, IXGBE_LINKS);
551 if (links_reg & IXGBE_LINKS_KX_AN_COMP)
555 if (!(links_reg & IXGBE_LINKS_KX_AN_COMP)) {
556 status = IXGBE_ERR_AUTONEG_NOT_COMPLETE;
557 DEBUGOUT("Autonegotiation did not complete.\n");
562 /* Add delay to filter out noises during initial link setup */
569 * ixgbe_validate_link_ready - Function looks for phy link
570 * @hw: pointer to hardware structure
572 * Function indicates success when phy link is available. If phy is not ready
573 * within 5 seconds of MAC indicating link, the function returns error.
575 STATIC s32 ixgbe_validate_link_ready(struct ixgbe_hw *hw)
580 if (hw->device_id != IXGBE_DEV_ID_82598AT2)
581 return IXGBE_SUCCESS;
584 timeout < IXGBE_VALIDATE_LINK_READY_TIMEOUT; timeout++) {
585 hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_STATUS,
586 IXGBE_MDIO_AUTO_NEG_DEV_TYPE, &an_reg);
588 if ((an_reg & IXGBE_MII_AUTONEG_COMPLETE) &&
589 (an_reg & IXGBE_MII_AUTONEG_LINK_UP))
595 if (timeout == IXGBE_VALIDATE_LINK_READY_TIMEOUT) {
596 DEBUGOUT("Link was indicated but link is down\n");
597 return IXGBE_ERR_LINK_SETUP;
600 return IXGBE_SUCCESS;
604 * ixgbe_check_mac_link_82598 - Get link/speed status
605 * @hw: pointer to hardware structure
606 * @speed: pointer to link speed
607 * @link_up: true is link is up, false otherwise
608 * @link_up_wait_to_complete: bool used to wait for link up or not
610 * Reads the links register to determine if link is up and the current speed
612 STATIC s32 ixgbe_check_mac_link_82598(struct ixgbe_hw *hw,
613 ixgbe_link_speed *speed, bool *link_up,
614 bool link_up_wait_to_complete)
618 u16 link_reg, adapt_comp_reg;
620 DEBUGFUNC("ixgbe_check_mac_link_82598");
623 * SERDES PHY requires us to read link status from undocumented
624 * register 0xC79F. Bit 0 set indicates link is up/ready; clear
625 * indicates link down. OxC00C is read to check that the XAUI lanes
626 * are active. Bit 0 clear indicates active; set indicates inactive.
628 if (hw->phy.type == ixgbe_phy_nl) {
629 hw->phy.ops.read_reg(hw, 0xC79F, IXGBE_TWINAX_DEV, &link_reg);
630 hw->phy.ops.read_reg(hw, 0xC79F, IXGBE_TWINAX_DEV, &link_reg);
631 hw->phy.ops.read_reg(hw, 0xC00C, IXGBE_TWINAX_DEV,
633 if (link_up_wait_to_complete) {
634 for (i = 0; i < hw->mac.max_link_up_time; i++) {
635 if ((link_reg & 1) &&
636 ((adapt_comp_reg & 1) == 0)) {
643 hw->phy.ops.read_reg(hw, 0xC79F,
646 hw->phy.ops.read_reg(hw, 0xC00C,
651 if ((link_reg & 1) && ((adapt_comp_reg & 1) == 0))
657 if (*link_up == false)
661 links_reg = IXGBE_READ_REG(hw, IXGBE_LINKS);
662 if (link_up_wait_to_complete) {
663 for (i = 0; i < hw->mac.max_link_up_time; i++) {
664 if (links_reg & IXGBE_LINKS_UP) {
671 links_reg = IXGBE_READ_REG(hw, IXGBE_LINKS);
674 if (links_reg & IXGBE_LINKS_UP)
680 if (links_reg & IXGBE_LINKS_SPEED)
681 *speed = IXGBE_LINK_SPEED_10GB_FULL;
683 *speed = IXGBE_LINK_SPEED_1GB_FULL;
685 if ((hw->device_id == IXGBE_DEV_ID_82598AT2) && (*link_up == true) &&
686 (ixgbe_validate_link_ready(hw) != IXGBE_SUCCESS))
690 return IXGBE_SUCCESS;
694 * ixgbe_setup_mac_link_82598 - Set MAC link speed
695 * @hw: pointer to hardware structure
696 * @speed: new link speed
697 * @autoneg_wait_to_complete: true when waiting for completion is needed
699 * Set the link speed in the AUTOC register and restarts link.
701 STATIC s32 ixgbe_setup_mac_link_82598(struct ixgbe_hw *hw,
702 ixgbe_link_speed speed,
703 bool autoneg_wait_to_complete)
705 bool autoneg = false;
706 s32 status = IXGBE_SUCCESS;
707 ixgbe_link_speed link_capabilities = IXGBE_LINK_SPEED_UNKNOWN;
708 u32 curr_autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC);
709 u32 autoc = curr_autoc;
710 u32 link_mode = autoc & IXGBE_AUTOC_LMS_MASK;
712 DEBUGFUNC("ixgbe_setup_mac_link_82598");
714 /* Check to see if speed passed in is supported. */
715 ixgbe_get_link_capabilities(hw, &link_capabilities, &autoneg);
716 speed &= link_capabilities;
718 if (speed == IXGBE_LINK_SPEED_UNKNOWN)
719 status = IXGBE_ERR_LINK_SETUP;
721 /* Set KX4/KX support according to speed requested */
722 else if (link_mode == IXGBE_AUTOC_LMS_KX4_AN ||
723 link_mode == IXGBE_AUTOC_LMS_KX4_AN_1G_AN) {
724 autoc &= ~IXGBE_AUTOC_KX4_KX_SUPP_MASK;
725 if (speed & IXGBE_LINK_SPEED_10GB_FULL)
726 autoc |= IXGBE_AUTOC_KX4_SUPP;
727 if (speed & IXGBE_LINK_SPEED_1GB_FULL)
728 autoc |= IXGBE_AUTOC_KX_SUPP;
729 if (autoc != curr_autoc)
730 IXGBE_WRITE_REG(hw, IXGBE_AUTOC, autoc);
733 if (status == IXGBE_SUCCESS) {
735 * Setup and restart the link based on the new values in
736 * ixgbe_hw This will write the AUTOC register based on the new
739 status = ixgbe_start_mac_link_82598(hw,
740 autoneg_wait_to_complete);
748 * ixgbe_setup_copper_link_82598 - Set the PHY autoneg advertised field
749 * @hw: pointer to hardware structure
750 * @speed: new link speed
751 * @autoneg_wait_to_complete: true if waiting is needed to complete
753 * Sets the link speed in the AUTOC register in the MAC and restarts link.
755 STATIC s32 ixgbe_setup_copper_link_82598(struct ixgbe_hw *hw,
756 ixgbe_link_speed speed,
757 bool autoneg_wait_to_complete)
761 DEBUGFUNC("ixgbe_setup_copper_link_82598");
763 /* Setup the PHY according to input speed */
764 status = hw->phy.ops.setup_link_speed(hw, speed,
765 autoneg_wait_to_complete);
767 ixgbe_start_mac_link_82598(hw, autoneg_wait_to_complete);
773 * ixgbe_reset_hw_82598 - Performs hardware reset
774 * @hw: pointer to hardware structure
776 * Resets the hardware by resetting the transmit and receive units, masks and
777 * clears all interrupts, performing a PHY reset, and performing a link (MAC)
780 STATIC s32 ixgbe_reset_hw_82598(struct ixgbe_hw *hw)
782 s32 status = IXGBE_SUCCESS;
783 s32 phy_status = IXGBE_SUCCESS;
790 DEBUGFUNC("ixgbe_reset_hw_82598");
792 /* Call adapter stop to disable tx/rx and clear interrupts */
793 status = hw->mac.ops.stop_adapter(hw);
794 if (status != IXGBE_SUCCESS)
798 * Power up the Atlas Tx lanes if they are currently powered down.
799 * Atlas Tx lanes are powered down for MAC loopback tests, but
800 * they are not automatically restored on reset.
802 hw->mac.ops.read_analog_reg8(hw, IXGBE_ATLAS_PDN_LPBK, &analog_val);
803 if (analog_val & IXGBE_ATLAS_PDN_TX_REG_EN) {
804 /* Enable Tx Atlas so packets can be transmitted again */
805 hw->mac.ops.read_analog_reg8(hw, IXGBE_ATLAS_PDN_LPBK,
807 analog_val &= ~IXGBE_ATLAS_PDN_TX_REG_EN;
808 hw->mac.ops.write_analog_reg8(hw, IXGBE_ATLAS_PDN_LPBK,
811 hw->mac.ops.read_analog_reg8(hw, IXGBE_ATLAS_PDN_10G,
813 analog_val &= ~IXGBE_ATLAS_PDN_TX_10G_QL_ALL;
814 hw->mac.ops.write_analog_reg8(hw, IXGBE_ATLAS_PDN_10G,
817 hw->mac.ops.read_analog_reg8(hw, IXGBE_ATLAS_PDN_1G,
819 analog_val &= ~IXGBE_ATLAS_PDN_TX_1G_QL_ALL;
820 hw->mac.ops.write_analog_reg8(hw, IXGBE_ATLAS_PDN_1G,
823 hw->mac.ops.read_analog_reg8(hw, IXGBE_ATLAS_PDN_AN,
825 analog_val &= ~IXGBE_ATLAS_PDN_TX_AN_QL_ALL;
826 hw->mac.ops.write_analog_reg8(hw, IXGBE_ATLAS_PDN_AN,
831 if (hw->phy.reset_disable == false) {
832 /* PHY ops must be identified and initialized prior to reset */
834 /* Init PHY and function pointers, perform SFP setup */
835 phy_status = hw->phy.ops.init(hw);
836 if (phy_status == IXGBE_ERR_SFP_NOT_SUPPORTED)
838 if (phy_status == IXGBE_ERR_SFP_NOT_PRESENT)
841 hw->phy.ops.reset(hw);
846 * Issue global reset to the MAC. This needs to be a SW reset.
847 * If link reset is used, it might reset the MAC when mng is using it
849 ctrl = IXGBE_READ_REG(hw, IXGBE_CTRL) | IXGBE_CTRL_RST;
850 IXGBE_WRITE_REG(hw, IXGBE_CTRL, ctrl);
851 IXGBE_WRITE_FLUSH(hw);
853 /* Poll for reset bit to self-clear indicating reset is complete */
854 for (i = 0; i < 10; i++) {
856 ctrl = IXGBE_READ_REG(hw, IXGBE_CTRL);
857 if (!(ctrl & IXGBE_CTRL_RST))
860 if (ctrl & IXGBE_CTRL_RST) {
861 status = IXGBE_ERR_RESET_FAILED;
862 DEBUGOUT("Reset polling failed to complete.\n");
868 * Double resets are required for recovery from certain error
869 * conditions. Between resets, it is necessary to stall to allow time
870 * for any pending HW events to complete.
872 if (hw->mac.flags & IXGBE_FLAGS_DOUBLE_RESET_REQUIRED) {
873 hw->mac.flags &= ~IXGBE_FLAGS_DOUBLE_RESET_REQUIRED;
877 gheccr = IXGBE_READ_REG(hw, IXGBE_GHECCR);
878 gheccr &= ~((1 << 21) | (1 << 18) | (1 << 9) | (1 << 6));
879 IXGBE_WRITE_REG(hw, IXGBE_GHECCR, gheccr);
882 * Store the original AUTOC value if it has not been
883 * stored off yet. Otherwise restore the stored original
884 * AUTOC value since the reset operation sets back to deaults.
886 autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC);
887 if (hw->mac.orig_link_settings_stored == false) {
888 hw->mac.orig_autoc = autoc;
889 hw->mac.orig_link_settings_stored = true;
890 } else if (autoc != hw->mac.orig_autoc) {
891 IXGBE_WRITE_REG(hw, IXGBE_AUTOC, hw->mac.orig_autoc);
894 /* Store the permanent mac address */
895 hw->mac.ops.get_mac_addr(hw, hw->mac.perm_addr);
898 * Store MAC address from RAR0, clear receive address registers, and
899 * clear the multicast table
901 hw->mac.ops.init_rx_addrs(hw);
904 if (phy_status != IXGBE_SUCCESS)
911 * ixgbe_set_vmdq_82598 - Associate a VMDq set index with a rx address
912 * @hw: pointer to hardware struct
913 * @rar: receive address register index to associate with a VMDq index
914 * @vmdq: VMDq set index
916 s32 ixgbe_set_vmdq_82598(struct ixgbe_hw *hw, u32 rar, u32 vmdq)
919 u32 rar_entries = hw->mac.num_rar_entries;
921 DEBUGFUNC("ixgbe_set_vmdq_82598");
923 /* Make sure we are using a valid rar index range */
924 if (rar >= rar_entries) {
925 DEBUGOUT1("RAR index %d is out of range.\n", rar);
926 return IXGBE_ERR_INVALID_ARGUMENT;
929 rar_high = IXGBE_READ_REG(hw, IXGBE_RAH(rar));
930 rar_high &= ~IXGBE_RAH_VIND_MASK;
931 rar_high |= ((vmdq << IXGBE_RAH_VIND_SHIFT) & IXGBE_RAH_VIND_MASK);
932 IXGBE_WRITE_REG(hw, IXGBE_RAH(rar), rar_high);
933 return IXGBE_SUCCESS;
937 * ixgbe_clear_vmdq_82598 - Disassociate a VMDq set index from an rx address
938 * @hw: pointer to hardware struct
939 * @rar: receive address register index to associate with a VMDq index
940 * @vmdq: VMDq clear index (not used in 82598, but elsewhere)
942 STATIC s32 ixgbe_clear_vmdq_82598(struct ixgbe_hw *hw, u32 rar, u32 vmdq)
945 u32 rar_entries = hw->mac.num_rar_entries;
947 UNREFERENCED_1PARAMETER(vmdq);
949 /* Make sure we are using a valid rar index range */
950 if (rar >= rar_entries) {
951 DEBUGOUT1("RAR index %d is out of range.\n", rar);
952 return IXGBE_ERR_INVALID_ARGUMENT;
955 rar_high = IXGBE_READ_REG(hw, IXGBE_RAH(rar));
956 if (rar_high & IXGBE_RAH_VIND_MASK) {
957 rar_high &= ~IXGBE_RAH_VIND_MASK;
958 IXGBE_WRITE_REG(hw, IXGBE_RAH(rar), rar_high);
961 return IXGBE_SUCCESS;
965 * ixgbe_set_vfta_82598 - Set VLAN filter table
966 * @hw: pointer to hardware structure
967 * @vlan: VLAN id to write to VLAN filter
968 * @vind: VMDq output index that maps queue to VLAN id in VFTA
969 * @vlan_on: boolean flag to turn on/off VLAN in VFTA
970 * @vlvf_bypass: boolean flag - unused
972 * Turn on/off specified VLAN in the VLAN filter table.
974 s32 ixgbe_set_vfta_82598(struct ixgbe_hw *hw, u32 vlan, u32 vind,
975 bool vlan_on, bool vlvf_bypass)
982 UNREFERENCED_1PARAMETER(vlvf_bypass);
984 DEBUGFUNC("ixgbe_set_vfta_82598");
987 return IXGBE_ERR_PARAM;
989 /* Determine 32-bit word position in array */
990 regindex = (vlan >> 5) & 0x7F; /* upper seven bits */
992 /* Determine the location of the (VMD) queue index */
993 vftabyte = ((vlan >> 3) & 0x03); /* bits (4:3) indicating byte array */
994 bitindex = (vlan & 0x7) << 2; /* lower 3 bits indicate nibble */
996 /* Set the nibble for VMD queue index */
997 bits = IXGBE_READ_REG(hw, IXGBE_VFTAVIND(vftabyte, regindex));
998 bits &= (~(0x0F << bitindex));
999 bits |= (vind << bitindex);
1000 IXGBE_WRITE_REG(hw, IXGBE_VFTAVIND(vftabyte, regindex), bits);
1002 /* Determine the location of the bit for this VLAN id */
1003 bitindex = vlan & 0x1F; /* lower five bits */
1005 bits = IXGBE_READ_REG(hw, IXGBE_VFTA(regindex));
1007 /* Turn on this VLAN id */
1008 bits |= (1 << bitindex);
1010 /* Turn off this VLAN id */
1011 bits &= ~(1 << bitindex);
1012 IXGBE_WRITE_REG(hw, IXGBE_VFTA(regindex), bits);
1014 return IXGBE_SUCCESS;
1018 * ixgbe_clear_vfta_82598 - Clear VLAN filter table
1019 * @hw: pointer to hardware structure
1021 * Clears the VLAN filer table, and the VMDq index associated with the filter
1023 STATIC s32 ixgbe_clear_vfta_82598(struct ixgbe_hw *hw)
1028 DEBUGFUNC("ixgbe_clear_vfta_82598");
1030 for (offset = 0; offset < hw->mac.vft_size; offset++)
1031 IXGBE_WRITE_REG(hw, IXGBE_VFTA(offset), 0);
1033 for (vlanbyte = 0; vlanbyte < 4; vlanbyte++)
1034 for (offset = 0; offset < hw->mac.vft_size; offset++)
1035 IXGBE_WRITE_REG(hw, IXGBE_VFTAVIND(vlanbyte, offset),
1038 return IXGBE_SUCCESS;
1042 * ixgbe_read_analog_reg8_82598 - Reads 8 bit Atlas analog register
1043 * @hw: pointer to hardware structure
1044 * @reg: analog register to read
1047 * Performs read operation to Atlas analog register specified.
1049 s32 ixgbe_read_analog_reg8_82598(struct ixgbe_hw *hw, u32 reg, u8 *val)
1053 DEBUGFUNC("ixgbe_read_analog_reg8_82598");
1055 IXGBE_WRITE_REG(hw, IXGBE_ATLASCTL,
1056 IXGBE_ATLASCTL_WRITE_CMD | (reg << 8));
1057 IXGBE_WRITE_FLUSH(hw);
1059 atlas_ctl = IXGBE_READ_REG(hw, IXGBE_ATLASCTL);
1060 *val = (u8)atlas_ctl;
1062 return IXGBE_SUCCESS;
1066 * ixgbe_write_analog_reg8_82598 - Writes 8 bit Atlas analog register
1067 * @hw: pointer to hardware structure
1068 * @reg: atlas register to write
1069 * @val: value to write
1071 * Performs write operation to Atlas analog register specified.
1073 s32 ixgbe_write_analog_reg8_82598(struct ixgbe_hw *hw, u32 reg, u8 val)
1077 DEBUGFUNC("ixgbe_write_analog_reg8_82598");
1079 atlas_ctl = (reg << 8) | val;
1080 IXGBE_WRITE_REG(hw, IXGBE_ATLASCTL, atlas_ctl);
1081 IXGBE_WRITE_FLUSH(hw);
1084 return IXGBE_SUCCESS;
1088 * ixgbe_read_i2c_phy_82598 - Reads 8 bit word over I2C interface.
1089 * @hw: pointer to hardware structure
1090 * @dev_addr: address to read from
1091 * @byte_offset: byte offset to read from dev_addr
1092 * @eeprom_data: value read
1094 * Performs 8 byte read operation to SFP module's EEPROM over I2C interface.
1096 STATIC s32 ixgbe_read_i2c_phy_82598(struct ixgbe_hw *hw, u8 dev_addr,
1097 u8 byte_offset, u8 *eeprom_data)
1099 s32 status = IXGBE_SUCCESS;
1106 DEBUGFUNC("ixgbe_read_i2c_phy_82598");
1108 if (IXGBE_READ_REG(hw, IXGBE_STATUS) & IXGBE_STATUS_LAN_ID_1)
1109 gssr = IXGBE_GSSR_PHY1_SM;
1111 gssr = IXGBE_GSSR_PHY0_SM;
1113 if (hw->mac.ops.acquire_swfw_sync(hw, gssr) != IXGBE_SUCCESS)
1114 return IXGBE_ERR_SWFW_SYNC;
1116 if (hw->phy.type == ixgbe_phy_nl) {
1118 * NetLogic phy SDA/SCL registers are at addresses 0xC30A to
1119 * 0xC30D. These registers are used to talk to the SFP+
1120 * module's EEPROM through the SDA/SCL (I2C) interface.
1122 sfp_addr = (dev_addr << 8) + byte_offset;
1123 sfp_addr = (sfp_addr | IXGBE_I2C_EEPROM_READ_MASK);
1124 hw->phy.ops.write_reg_mdi(hw,
1125 IXGBE_MDIO_PMA_PMD_SDA_SCL_ADDR,
1126 IXGBE_MDIO_PMA_PMD_DEV_TYPE,
1130 for (i = 0; i < 100; i++) {
1131 hw->phy.ops.read_reg_mdi(hw,
1132 IXGBE_MDIO_PMA_PMD_SDA_SCL_STAT,
1133 IXGBE_MDIO_PMA_PMD_DEV_TYPE,
1135 sfp_stat = sfp_stat & IXGBE_I2C_EEPROM_STATUS_MASK;
1136 if (sfp_stat != IXGBE_I2C_EEPROM_STATUS_IN_PROGRESS)
1141 if (sfp_stat != IXGBE_I2C_EEPROM_STATUS_PASS) {
1142 DEBUGOUT("EEPROM read did not pass.\n");
1143 status = IXGBE_ERR_SFP_NOT_PRESENT;
1148 hw->phy.ops.read_reg_mdi(hw, IXGBE_MDIO_PMA_PMD_SDA_SCL_DATA,
1149 IXGBE_MDIO_PMA_PMD_DEV_TYPE, &sfp_data);
1151 *eeprom_data = (u8)(sfp_data >> 8);
1153 status = IXGBE_ERR_PHY;
1157 hw->mac.ops.release_swfw_sync(hw, gssr);
1162 * ixgbe_read_i2c_eeprom_82598 - Reads 8 bit word over I2C interface.
1163 * @hw: pointer to hardware structure
1164 * @byte_offset: EEPROM byte offset to read
1165 * @eeprom_data: value read
1167 * Performs 8 byte read operation to SFP module's EEPROM over I2C interface.
1169 s32 ixgbe_read_i2c_eeprom_82598(struct ixgbe_hw *hw, u8 byte_offset,
1172 return ixgbe_read_i2c_phy_82598(hw, IXGBE_I2C_EEPROM_DEV_ADDR,
1173 byte_offset, eeprom_data);
1177 * ixgbe_read_i2c_sff8472_82598 - Reads 8 bit word over I2C interface.
1178 * @hw: pointer to hardware structure
1179 * @byte_offset: byte offset at address 0xA2
1180 * @sff8472_data: value read
1182 * Performs 8 byte read operation to SFP module's SFF-8472 data over I2C
1184 STATIC s32 ixgbe_read_i2c_sff8472_82598(struct ixgbe_hw *hw, u8 byte_offset,
1187 return ixgbe_read_i2c_phy_82598(hw, IXGBE_I2C_EEPROM_DEV_ADDR2,
1188 byte_offset, sff8472_data);
1192 * ixgbe_get_supported_physical_layer_82598 - Returns physical layer type
1193 * @hw: pointer to hardware structure
1195 * Determines physical layer capabilities of the current configuration.
1197 u64 ixgbe_get_supported_physical_layer_82598(struct ixgbe_hw *hw)
1199 u64 physical_layer = IXGBE_PHYSICAL_LAYER_UNKNOWN;
1200 u32 autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC);
1201 u32 pma_pmd_10g = autoc & IXGBE_AUTOC_10G_PMA_PMD_MASK;
1202 u32 pma_pmd_1g = autoc & IXGBE_AUTOC_1G_PMA_PMD_MASK;
1203 u16 ext_ability = 0;
1205 DEBUGFUNC("ixgbe_get_supported_physical_layer_82598");
1207 hw->phy.ops.identify(hw);
1209 /* Copper PHY must be checked before AUTOC LMS to determine correct
1210 * physical layer because 10GBase-T PHYs use LMS = KX4/KX */
1211 switch (hw->phy.type) {
1213 case ixgbe_phy_cu_unknown:
1214 hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_EXT_ABILITY,
1215 IXGBE_MDIO_PMA_PMD_DEV_TYPE, &ext_ability);
1216 if (ext_ability & IXGBE_MDIO_PHY_10GBASET_ABILITY)
1217 physical_layer |= IXGBE_PHYSICAL_LAYER_10GBASE_T;
1218 if (ext_ability & IXGBE_MDIO_PHY_1000BASET_ABILITY)
1219 physical_layer |= IXGBE_PHYSICAL_LAYER_1000BASE_T;
1220 if (ext_ability & IXGBE_MDIO_PHY_100BASETX_ABILITY)
1221 physical_layer |= IXGBE_PHYSICAL_LAYER_100BASE_TX;
1227 switch (autoc & IXGBE_AUTOC_LMS_MASK) {
1228 case IXGBE_AUTOC_LMS_1G_AN:
1229 case IXGBE_AUTOC_LMS_1G_LINK_NO_AN:
1230 if (pma_pmd_1g == IXGBE_AUTOC_1G_KX)
1231 physical_layer = IXGBE_PHYSICAL_LAYER_1000BASE_KX;
1233 physical_layer = IXGBE_PHYSICAL_LAYER_1000BASE_BX;
1235 case IXGBE_AUTOC_LMS_10G_LINK_NO_AN:
1236 if (pma_pmd_10g == IXGBE_AUTOC_10G_CX4)
1237 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_CX4;
1238 else if (pma_pmd_10g == IXGBE_AUTOC_10G_KX4)
1239 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_KX4;
1241 physical_layer = IXGBE_PHYSICAL_LAYER_UNKNOWN;
1243 case IXGBE_AUTOC_LMS_KX4_AN:
1244 case IXGBE_AUTOC_LMS_KX4_AN_1G_AN:
1245 if (autoc & IXGBE_AUTOC_KX_SUPP)
1246 physical_layer |= IXGBE_PHYSICAL_LAYER_1000BASE_KX;
1247 if (autoc & IXGBE_AUTOC_KX4_SUPP)
1248 physical_layer |= IXGBE_PHYSICAL_LAYER_10GBASE_KX4;
1254 if (hw->phy.type == ixgbe_phy_nl) {
1255 hw->phy.ops.identify_sfp(hw);
1257 switch (hw->phy.sfp_type) {
1258 case ixgbe_sfp_type_da_cu:
1259 physical_layer = IXGBE_PHYSICAL_LAYER_SFP_PLUS_CU;
1261 case ixgbe_sfp_type_sr:
1262 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_SR;
1264 case ixgbe_sfp_type_lr:
1265 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_LR;
1268 physical_layer = IXGBE_PHYSICAL_LAYER_UNKNOWN;
1273 switch (hw->device_id) {
1274 case IXGBE_DEV_ID_82598_DA_DUAL_PORT:
1275 physical_layer = IXGBE_PHYSICAL_LAYER_SFP_PLUS_CU;
1277 case IXGBE_DEV_ID_82598AF_DUAL_PORT:
1278 case IXGBE_DEV_ID_82598AF_SINGLE_PORT:
1279 case IXGBE_DEV_ID_82598_SR_DUAL_PORT_EM:
1280 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_SR;
1282 case IXGBE_DEV_ID_82598EB_XF_LR:
1283 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_LR;
1290 return physical_layer;
1294 * ixgbe_set_lan_id_multi_port_pcie_82598 - Set LAN id for PCIe multiple
1296 * @hw: pointer to the HW structure
1298 * Calls common function and corrects issue with some single port devices
1299 * that enable LAN1 but not LAN0.
1301 void ixgbe_set_lan_id_multi_port_pcie_82598(struct ixgbe_hw *hw)
1303 struct ixgbe_bus_info *bus = &hw->bus;
1307 DEBUGFUNC("ixgbe_set_lan_id_multi_port_pcie_82598");
1309 ixgbe_set_lan_id_multi_port_pcie(hw);
1311 /* check if LAN0 is disabled */
1312 hw->eeprom.ops.read(hw, IXGBE_PCIE_GENERAL_PTR, &pci_gen);
1313 if ((pci_gen != 0) && (pci_gen != 0xFFFF)) {
1315 hw->eeprom.ops.read(hw, pci_gen + IXGBE_PCIE_CTRL2, &pci_ctrl2);
1317 /* if LAN0 is completely disabled force function to 0 */
1318 if ((pci_ctrl2 & IXGBE_PCIE_CTRL2_LAN_DISABLE) &&
1319 !(pci_ctrl2 & IXGBE_PCIE_CTRL2_DISABLE_SELECT) &&
1320 !(pci_ctrl2 & IXGBE_PCIE_CTRL2_DUMMY_ENABLE)) {
1328 * ixgbe_enable_relaxed_ordering_82598 - enable relaxed ordering
1329 * @hw: pointer to hardware structure
1332 void ixgbe_enable_relaxed_ordering_82598(struct ixgbe_hw *hw)
1337 DEBUGFUNC("ixgbe_enable_relaxed_ordering_82598");
1339 /* Enable relaxed ordering */
1340 for (i = 0; ((i < hw->mac.max_tx_queues) &&
1341 (i < IXGBE_DCA_MAX_QUEUES_82598)); i++) {
1342 regval = IXGBE_READ_REG(hw, IXGBE_DCA_TXCTRL(i));
1343 regval |= IXGBE_DCA_TXCTRL_DESC_WRO_EN;
1344 IXGBE_WRITE_REG(hw, IXGBE_DCA_TXCTRL(i), regval);
1347 for (i = 0; ((i < hw->mac.max_rx_queues) &&
1348 (i < IXGBE_DCA_MAX_QUEUES_82598)); i++) {
1349 regval = IXGBE_READ_REG(hw, IXGBE_DCA_RXCTRL(i));
1350 regval |= IXGBE_DCA_RXCTRL_DATA_WRO_EN |
1351 IXGBE_DCA_RXCTRL_HEAD_WRO_EN;
1352 IXGBE_WRITE_REG(hw, IXGBE_DCA_RXCTRL(i), regval);
1358 * ixgbe_set_rxpba_82598 - Initialize RX packet buffer
1359 * @hw: pointer to hardware structure
1360 * @num_pb: number of packet buffers to allocate
1361 * @headroom: reserve n KB of headroom
1362 * @strategy: packet buffer allocation strategy
1364 STATIC void ixgbe_set_rxpba_82598(struct ixgbe_hw *hw, int num_pb,
1365 u32 headroom, int strategy)
1367 u32 rxpktsize = IXGBE_RXPBSIZE_64KB;
1369 UNREFERENCED_1PARAMETER(headroom);
1374 /* Setup Rx packet buffer sizes */
1376 case PBA_STRATEGY_WEIGHTED:
1377 /* Setup the first four at 80KB */
1378 rxpktsize = IXGBE_RXPBSIZE_80KB;
1380 IXGBE_WRITE_REG(hw, IXGBE_RXPBSIZE(i), rxpktsize);
1381 /* Setup the last four at 48KB...don't re-init i */
1382 rxpktsize = IXGBE_RXPBSIZE_48KB;
1384 case PBA_STRATEGY_EQUAL:
1386 /* Divide the remaining Rx packet buffer evenly among the TCs */
1387 for (; i < IXGBE_MAX_PACKET_BUFFERS; i++)
1388 IXGBE_WRITE_REG(hw, IXGBE_RXPBSIZE(i), rxpktsize);
1392 /* Setup Tx packet buffer sizes */
1393 for (i = 0; i < IXGBE_MAX_PACKET_BUFFERS; i++)
1394 IXGBE_WRITE_REG(hw, IXGBE_TXPBSIZE(i), IXGBE_TXPBSIZE_40KB);
1398 * ixgbe_enable_rx_dma_82598 - Enable the Rx DMA unit
1399 * @hw: pointer to hardware structure
1400 * @regval: register value to write to RXCTRL
1402 * Enables the Rx DMA unit
1404 s32 ixgbe_enable_rx_dma_82598(struct ixgbe_hw *hw, u32 regval)
1406 DEBUGFUNC("ixgbe_enable_rx_dma_82598");
1408 IXGBE_WRITE_REG(hw, IXGBE_RXCTRL, regval);
1410 return IXGBE_SUCCESS;