1 /*******************************************************************************
3 Intel 10 Gigabit PCI Express Linux driver
4 Copyright(c) 1999 - 2010 Intel Corporation.
6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License,
8 version 2, as published by the Free Software Foundation.
10 This program is distributed in the hope it will be useful, but WITHOUT
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 You should have received a copy of the GNU General Public License along with
16 this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
19 The full GNU General Public License is included in this distribution in
20 the file called "COPYING".
23 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
24 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26 *******************************************************************************/
28 #include <linux/pci.h>
29 #include <linux/delay.h>
30 #include <linux/sched.h>
33 #include "ixgbe_phy.h"
34 #include "ixgbe_mbx.h"
36 #define IXGBE_82599_MAX_TX_QUEUES 128
37 #define IXGBE_82599_MAX_RX_QUEUES 128
38 #define IXGBE_82599_RAR_ENTRIES 128
39 #define IXGBE_82599_MC_TBL_SIZE 128
40 #define IXGBE_82599_VFT_TBL_SIZE 128
42 void ixgbe_flap_tx_laser_multispeed_fiber(struct ixgbe_hw
*hw
);
43 s32
ixgbe_setup_mac_link_multispeed_fiber(struct ixgbe_hw
*hw
,
44 ixgbe_link_speed speed
,
46 bool autoneg_wait_to_complete
);
47 static s32
ixgbe_setup_mac_link_smartspeed(struct ixgbe_hw
*hw
,
48 ixgbe_link_speed speed
,
50 bool autoneg_wait_to_complete
);
51 s32
ixgbe_start_mac_link_82599(struct ixgbe_hw
*hw
,
52 bool autoneg_wait_to_complete
);
53 s32
ixgbe_setup_mac_link_82599(struct ixgbe_hw
*hw
,
54 ixgbe_link_speed speed
,
56 bool autoneg_wait_to_complete
);
57 static s32
ixgbe_get_copper_link_capabilities_82599(struct ixgbe_hw
*hw
,
58 ixgbe_link_speed
*speed
,
60 static s32
ixgbe_setup_copper_link_82599(struct ixgbe_hw
*hw
,
61 ixgbe_link_speed speed
,
63 bool autoneg_wait_to_complete
);
64 static s32
ixgbe_verify_fw_version_82599(struct ixgbe_hw
*hw
);
66 static void ixgbe_init_mac_link_ops_82599(struct ixgbe_hw
*hw
)
68 struct ixgbe_mac_info
*mac
= &hw
->mac
;
69 if (hw
->phy
.multispeed_fiber
) {
70 /* Set up dual speed SFP+ support */
71 mac
->ops
.setup_link
= &ixgbe_setup_mac_link_multispeed_fiber
;
72 mac
->ops
.flap_tx_laser
= &ixgbe_flap_tx_laser_multispeed_fiber
;
74 mac
->ops
.flap_tx_laser
= NULL
;
75 if ((mac
->ops
.get_media_type(hw
) ==
76 ixgbe_media_type_backplane
) &&
77 (hw
->phy
.smart_speed
== ixgbe_smart_speed_auto
||
78 hw
->phy
.smart_speed
== ixgbe_smart_speed_on
))
79 mac
->ops
.setup_link
= &ixgbe_setup_mac_link_smartspeed
;
81 mac
->ops
.setup_link
= &ixgbe_setup_mac_link_82599
;
85 static s32
ixgbe_setup_sfp_modules_82599(struct ixgbe_hw
*hw
)
88 u16 list_offset
, data_offset
, data_value
;
90 if (hw
->phy
.sfp_type
!= ixgbe_sfp_type_unknown
) {
91 ixgbe_init_mac_link_ops_82599(hw
);
93 hw
->phy
.ops
.reset
= NULL
;
95 ret_val
= ixgbe_get_sfp_init_sequence_offsets(hw
, &list_offset
,
101 /* PHY config will finish before releasing the semaphore */
102 ret_val
= ixgbe_acquire_swfw_sync(hw
, IXGBE_GSSR_MAC_CSR_SM
);
104 ret_val
= IXGBE_ERR_SWFW_SYNC
;
108 hw
->eeprom
.ops
.read(hw
, ++data_offset
, &data_value
);
109 while (data_value
!= 0xffff) {
110 IXGBE_WRITE_REG(hw
, IXGBE_CORECTL
, data_value
);
111 IXGBE_WRITE_FLUSH(hw
);
112 hw
->eeprom
.ops
.read(hw
, ++data_offset
, &data_value
);
114 /* Now restart DSP by setting Restart_AN */
115 IXGBE_WRITE_REG(hw
, IXGBE_AUTOC
,
116 (IXGBE_READ_REG(hw
, IXGBE_AUTOC
) | IXGBE_AUTOC_AN_RESTART
));
118 /* Release the semaphore */
119 ixgbe_release_swfw_sync(hw
, IXGBE_GSSR_MAC_CSR_SM
);
120 /* Delay obtaining semaphore again to allow FW access */
121 msleep(hw
->eeprom
.semaphore_delay
);
129 * ixgbe_get_pcie_msix_count_82599 - Gets MSI-X vector count
130 * @hw: pointer to hardware structure
132 * Read PCIe configuration space, and get the MSI-X vector count from
133 * the capabilities table.
135 static u32
ixgbe_get_pcie_msix_count_82599(struct ixgbe_hw
*hw
)
137 struct ixgbe_adapter
*adapter
= hw
->back
;
139 pci_read_config_word(adapter
->pdev
, IXGBE_PCIE_MSIX_82599_CAPS
,
141 msix_count
&= IXGBE_PCIE_MSIX_TBL_SZ_MASK
;
143 /* MSI-X count is zero-based in HW, so increment to give proper value */
149 static s32
ixgbe_get_invariants_82599(struct ixgbe_hw
*hw
)
151 struct ixgbe_mac_info
*mac
= &hw
->mac
;
153 ixgbe_init_mac_link_ops_82599(hw
);
155 mac
->mcft_size
= IXGBE_82599_MC_TBL_SIZE
;
156 mac
->vft_size
= IXGBE_82599_VFT_TBL_SIZE
;
157 mac
->num_rar_entries
= IXGBE_82599_RAR_ENTRIES
;
158 mac
->max_rx_queues
= IXGBE_82599_MAX_RX_QUEUES
;
159 mac
->max_tx_queues
= IXGBE_82599_MAX_TX_QUEUES
;
160 mac
->max_msix_vectors
= ixgbe_get_pcie_msix_count_82599(hw
);
166 * ixgbe_init_phy_ops_82599 - PHY/SFP specific init
167 * @hw: pointer to hardware structure
169 * Initialize any function pointers that were not able to be
170 * set during get_invariants because the PHY/SFP type was
171 * not known. Perform the SFP init if necessary.
174 static s32
ixgbe_init_phy_ops_82599(struct ixgbe_hw
*hw
)
176 struct ixgbe_mac_info
*mac
= &hw
->mac
;
177 struct ixgbe_phy_info
*phy
= &hw
->phy
;
180 /* Identify the PHY or SFP module */
181 ret_val
= phy
->ops
.identify(hw
);
183 /* Setup function pointers based on detected SFP module and speeds */
184 ixgbe_init_mac_link_ops_82599(hw
);
186 /* If copper media, overwrite with copper function pointers */
187 if (mac
->ops
.get_media_type(hw
) == ixgbe_media_type_copper
) {
188 mac
->ops
.setup_link
= &ixgbe_setup_copper_link_82599
;
189 mac
->ops
.get_link_capabilities
=
190 &ixgbe_get_copper_link_capabilities_82599
;
193 /* Set necessary function pointers based on phy type */
194 switch (hw
->phy
.type
) {
196 phy
->ops
.check_link
= &ixgbe_check_phy_link_tnx
;
197 phy
->ops
.get_firmware_version
=
198 &ixgbe_get_phy_firmware_version_tnx
;
208 * ixgbe_get_link_capabilities_82599 - Determines link capabilities
209 * @hw: pointer to hardware structure
210 * @speed: pointer to link speed
211 * @negotiation: true when autoneg or autotry is enabled
213 * Determines the link capabilities by reading the AUTOC register.
215 static s32
ixgbe_get_link_capabilities_82599(struct ixgbe_hw
*hw
,
216 ixgbe_link_speed
*speed
,
223 * Determine link capabilities based on the stored value of AUTOC,
224 * which represents EEPROM defaults. If AUTOC value has not been
225 * stored, use the current register value.
227 if (hw
->mac
.orig_link_settings_stored
)
228 autoc
= hw
->mac
.orig_autoc
;
230 autoc
= IXGBE_READ_REG(hw
, IXGBE_AUTOC
);
232 switch (autoc
& IXGBE_AUTOC_LMS_MASK
) {
233 case IXGBE_AUTOC_LMS_1G_LINK_NO_AN
:
234 *speed
= IXGBE_LINK_SPEED_1GB_FULL
;
235 *negotiation
= false;
238 case IXGBE_AUTOC_LMS_10G_LINK_NO_AN
:
239 *speed
= IXGBE_LINK_SPEED_10GB_FULL
;
240 *negotiation
= false;
243 case IXGBE_AUTOC_LMS_1G_AN
:
244 *speed
= IXGBE_LINK_SPEED_1GB_FULL
;
248 case IXGBE_AUTOC_LMS_10G_SERIAL
:
249 *speed
= IXGBE_LINK_SPEED_10GB_FULL
;
250 *negotiation
= false;
253 case IXGBE_AUTOC_LMS_KX4_KX_KR
:
254 case IXGBE_AUTOC_LMS_KX4_KX_KR_1G_AN
:
255 *speed
= IXGBE_LINK_SPEED_UNKNOWN
;
256 if (autoc
& IXGBE_AUTOC_KR_SUPP
)
257 *speed
|= IXGBE_LINK_SPEED_10GB_FULL
;
258 if (autoc
& IXGBE_AUTOC_KX4_SUPP
)
259 *speed
|= IXGBE_LINK_SPEED_10GB_FULL
;
260 if (autoc
& IXGBE_AUTOC_KX_SUPP
)
261 *speed
|= IXGBE_LINK_SPEED_1GB_FULL
;
265 case IXGBE_AUTOC_LMS_KX4_KX_KR_SGMII
:
266 *speed
= IXGBE_LINK_SPEED_100_FULL
;
267 if (autoc
& IXGBE_AUTOC_KR_SUPP
)
268 *speed
|= IXGBE_LINK_SPEED_10GB_FULL
;
269 if (autoc
& IXGBE_AUTOC_KX4_SUPP
)
270 *speed
|= IXGBE_LINK_SPEED_10GB_FULL
;
271 if (autoc
& IXGBE_AUTOC_KX_SUPP
)
272 *speed
|= IXGBE_LINK_SPEED_1GB_FULL
;
276 case IXGBE_AUTOC_LMS_SGMII_1G_100M
:
277 *speed
= IXGBE_LINK_SPEED_1GB_FULL
| IXGBE_LINK_SPEED_100_FULL
;
278 *negotiation
= false;
282 status
= IXGBE_ERR_LINK_SETUP
;
287 if (hw
->phy
.multispeed_fiber
) {
288 *speed
|= IXGBE_LINK_SPEED_10GB_FULL
|
289 IXGBE_LINK_SPEED_1GB_FULL
;
298 * ixgbe_get_copper_link_capabilities_82599 - Determines link capabilities
299 * @hw: pointer to hardware structure
300 * @speed: pointer to link speed
301 * @autoneg: boolean auto-negotiation value
303 * Determines the link capabilities by reading the AUTOC register.
305 static s32
ixgbe_get_copper_link_capabilities_82599(struct ixgbe_hw
*hw
,
306 ixgbe_link_speed
*speed
,
309 s32 status
= IXGBE_ERR_LINK_SETUP
;
315 status
= hw
->phy
.ops
.read_reg(hw
, MDIO_SPEED
, MDIO_MMD_PMAPMD
,
319 if (speed_ability
& MDIO_SPEED_10G
)
320 *speed
|= IXGBE_LINK_SPEED_10GB_FULL
;
321 if (speed_ability
& MDIO_PMA_SPEED_1000
)
322 *speed
|= IXGBE_LINK_SPEED_1GB_FULL
;
329 * ixgbe_get_media_type_82599 - Get media type
330 * @hw: pointer to hardware structure
332 * Returns the media type (fiber, copper, backplane)
334 static enum ixgbe_media_type
ixgbe_get_media_type_82599(struct ixgbe_hw
*hw
)
336 enum ixgbe_media_type media_type
;
338 /* Detect if there is a copper PHY attached. */
339 if (hw
->phy
.type
== ixgbe_phy_cu_unknown
||
340 hw
->phy
.type
== ixgbe_phy_tn
) {
341 media_type
= ixgbe_media_type_copper
;
345 switch (hw
->device_id
) {
346 case IXGBE_DEV_ID_82599_KX4
:
347 case IXGBE_DEV_ID_82599_KX4_MEZZ
:
348 case IXGBE_DEV_ID_82599_COMBO_BACKPLANE
:
349 case IXGBE_DEV_ID_82599_KR
:
350 case IXGBE_DEV_ID_82599_XAUI_LOM
:
351 /* Default device ID is mezzanine card KX/KX4 */
352 media_type
= ixgbe_media_type_backplane
;
354 case IXGBE_DEV_ID_82599_SFP
:
355 case IXGBE_DEV_ID_82599_SFP_EM
:
356 media_type
= ixgbe_media_type_fiber
;
358 case IXGBE_DEV_ID_82599_CX4
:
359 media_type
= ixgbe_media_type_cx4
;
362 media_type
= ixgbe_media_type_unknown
;
370 * ixgbe_start_mac_link_82599 - Setup MAC link settings
371 * @hw: pointer to hardware structure
372 * @autoneg_wait_to_complete: true when waiting for completion is needed
374 * Configures link settings based on values in the ixgbe_hw struct.
375 * Restarts the link. Performs autonegotiation if needed.
377 s32
ixgbe_start_mac_link_82599(struct ixgbe_hw
*hw
,
378 bool autoneg_wait_to_complete
)
386 autoc_reg
= IXGBE_READ_REG(hw
, IXGBE_AUTOC
);
387 autoc_reg
|= IXGBE_AUTOC_AN_RESTART
;
388 IXGBE_WRITE_REG(hw
, IXGBE_AUTOC
, autoc_reg
);
390 /* Only poll for autoneg to complete if specified to do so */
391 if (autoneg_wait_to_complete
) {
392 if ((autoc_reg
& IXGBE_AUTOC_LMS_MASK
) ==
393 IXGBE_AUTOC_LMS_KX4_KX_KR
||
394 (autoc_reg
& IXGBE_AUTOC_LMS_MASK
) ==
395 IXGBE_AUTOC_LMS_KX4_KX_KR_1G_AN
||
396 (autoc_reg
& IXGBE_AUTOC_LMS_MASK
) ==
397 IXGBE_AUTOC_LMS_KX4_KX_KR_SGMII
) {
398 links_reg
= 0; /* Just in case Autoneg time = 0 */
399 for (i
= 0; i
< IXGBE_AUTO_NEG_TIME
; i
++) {
400 links_reg
= IXGBE_READ_REG(hw
, IXGBE_LINKS
);
401 if (links_reg
& IXGBE_LINKS_KX_AN_COMP
)
405 if (!(links_reg
& IXGBE_LINKS_KX_AN_COMP
)) {
406 status
= IXGBE_ERR_AUTONEG_NOT_COMPLETE
;
407 hw_dbg(hw
, "Autoneg did not complete.\n");
412 /* Add delay to filter out noises during initial link setup */
419 * ixgbe_flap_tx_laser_multispeed_fiber - Flap Tx laser
420 * @hw: pointer to hardware structure
422 * When the driver changes the link speeds that it can support,
423 * it sets autotry_restart to true to indicate that we need to
424 * initiate a new autotry session with the link partner. To do
425 * so, we set the speed then disable and re-enable the tx laser, to
426 * alert the link partner that it also needs to restart autotry on its
427 * end. This is consistent with true clause 37 autoneg, which also
428 * involves a loss of signal.
430 void ixgbe_flap_tx_laser_multispeed_fiber(struct ixgbe_hw
*hw
)
432 u32 esdp_reg
= IXGBE_READ_REG(hw
, IXGBE_ESDP
);
434 hw_dbg(hw
, "ixgbe_flap_tx_laser_multispeed_fiber\n");
436 if (hw
->mac
.autotry_restart
) {
437 /* Disable tx laser; allow 100us to go dark per spec */
438 esdp_reg
|= IXGBE_ESDP_SDP3
;
439 IXGBE_WRITE_REG(hw
, IXGBE_ESDP
, esdp_reg
);
440 IXGBE_WRITE_FLUSH(hw
);
443 /* Enable tx laser; allow 100ms to light up */
444 esdp_reg
&= ~IXGBE_ESDP_SDP3
;
445 IXGBE_WRITE_REG(hw
, IXGBE_ESDP
, esdp_reg
);
446 IXGBE_WRITE_FLUSH(hw
);
449 hw
->mac
.autotry_restart
= false;
454 * ixgbe_setup_mac_link_multispeed_fiber - Set MAC link speed
455 * @hw: pointer to hardware structure
456 * @speed: new link speed
457 * @autoneg: true if autonegotiation enabled
458 * @autoneg_wait_to_complete: true when waiting for completion is needed
460 * Set the link speed in the AUTOC register and restarts link.
462 s32
ixgbe_setup_mac_link_multispeed_fiber(struct ixgbe_hw
*hw
,
463 ixgbe_link_speed speed
,
465 bool autoneg_wait_to_complete
)
468 ixgbe_link_speed phy_link_speed
;
469 ixgbe_link_speed highest_link_speed
= IXGBE_LINK_SPEED_UNKNOWN
;
471 u32 esdp_reg
= IXGBE_READ_REG(hw
, IXGBE_ESDP
);
472 bool link_up
= false;
476 /* Mask off requested but non-supported speeds */
477 hw
->mac
.ops
.get_link_capabilities(hw
, &phy_link_speed
, &negotiation
);
478 speed
&= phy_link_speed
;
481 * Try each speed one by one, highest priority first. We do this in
482 * software because 10gb fiber doesn't support speed autonegotiation.
484 if (speed
& IXGBE_LINK_SPEED_10GB_FULL
) {
486 highest_link_speed
= IXGBE_LINK_SPEED_10GB_FULL
;
488 /* If we already have link at this speed, just jump out */
489 hw
->mac
.ops
.check_link(hw
, &phy_link_speed
, &link_up
, false);
491 if ((phy_link_speed
== IXGBE_LINK_SPEED_10GB_FULL
) && link_up
)
494 /* Set the module link speed */
495 esdp_reg
|= (IXGBE_ESDP_SDP5_DIR
| IXGBE_ESDP_SDP5
);
496 IXGBE_WRITE_REG(hw
, IXGBE_ESDP
, esdp_reg
);
497 IXGBE_WRITE_FLUSH(hw
);
499 /* Allow module to change analog characteristics (1G->10G) */
502 status
= ixgbe_setup_mac_link_82599(hw
,
503 IXGBE_LINK_SPEED_10GB_FULL
,
505 autoneg_wait_to_complete
);
509 /* Flap the tx laser if it has not already been done */
510 hw
->mac
.ops
.flap_tx_laser(hw
);
513 * Wait for the controller to acquire link. Per IEEE 802.3ap,
514 * Section 73.10.2, we may have to wait up to 500ms if KR is
515 * attempted. 82599 uses the same timing for 10g SFI.
518 for (i
= 0; i
< 5; i
++) {
519 /* Wait for the link partner to also set speed */
522 /* If we have link, just jump out */
523 hw
->mac
.ops
.check_link(hw
, &phy_link_speed
,
530 if (speed
& IXGBE_LINK_SPEED_1GB_FULL
) {
532 if (highest_link_speed
== IXGBE_LINK_SPEED_UNKNOWN
)
533 highest_link_speed
= IXGBE_LINK_SPEED_1GB_FULL
;
535 /* If we already have link at this speed, just jump out */
536 hw
->mac
.ops
.check_link(hw
, &phy_link_speed
, &link_up
, false);
538 if ((phy_link_speed
== IXGBE_LINK_SPEED_1GB_FULL
) && link_up
)
541 /* Set the module link speed */
542 esdp_reg
&= ~IXGBE_ESDP_SDP5
;
543 esdp_reg
|= IXGBE_ESDP_SDP5_DIR
;
544 IXGBE_WRITE_REG(hw
, IXGBE_ESDP
, esdp_reg
);
545 IXGBE_WRITE_FLUSH(hw
);
547 /* Allow module to change analog characteristics (10G->1G) */
550 status
= ixgbe_setup_mac_link_82599(hw
,
551 IXGBE_LINK_SPEED_1GB_FULL
,
553 autoneg_wait_to_complete
);
557 /* Flap the tx laser if it has not already been done */
558 hw
->mac
.ops
.flap_tx_laser(hw
);
560 /* Wait for the link partner to also set speed */
563 /* If we have link, just jump out */
564 hw
->mac
.ops
.check_link(hw
, &phy_link_speed
, &link_up
, false);
570 * We didn't get link. Configure back to the highest speed we tried,
571 * (if there was more than one). We call ourselves back with just the
572 * single highest speed that the user requested.
575 status
= ixgbe_setup_mac_link_multispeed_fiber(hw
,
578 autoneg_wait_to_complete
);
581 /* Set autoneg_advertised value based on input link speed */
582 hw
->phy
.autoneg_advertised
= 0;
584 if (speed
& IXGBE_LINK_SPEED_10GB_FULL
)
585 hw
->phy
.autoneg_advertised
|= IXGBE_LINK_SPEED_10GB_FULL
;
587 if (speed
& IXGBE_LINK_SPEED_1GB_FULL
)
588 hw
->phy
.autoneg_advertised
|= IXGBE_LINK_SPEED_1GB_FULL
;
594 * ixgbe_setup_mac_link_smartspeed - Set MAC link speed using SmartSpeed
595 * @hw: pointer to hardware structure
596 * @speed: new link speed
597 * @autoneg: true if autonegotiation enabled
598 * @autoneg_wait_to_complete: true when waiting for completion is needed
600 * Implements the Intel SmartSpeed algorithm.
602 static s32
ixgbe_setup_mac_link_smartspeed(struct ixgbe_hw
*hw
,
603 ixgbe_link_speed speed
, bool autoneg
,
604 bool autoneg_wait_to_complete
)
607 ixgbe_link_speed link_speed
;
609 bool link_up
= false;
610 u32 autoc_reg
= IXGBE_READ_REG(hw
, IXGBE_AUTOC
);
612 hw_dbg(hw
, "ixgbe_setup_mac_link_smartspeed.\n");
614 /* Set autoneg_advertised value based on input link speed */
615 hw
->phy
.autoneg_advertised
= 0;
617 if (speed
& IXGBE_LINK_SPEED_10GB_FULL
)
618 hw
->phy
.autoneg_advertised
|= IXGBE_LINK_SPEED_10GB_FULL
;
620 if (speed
& IXGBE_LINK_SPEED_1GB_FULL
)
621 hw
->phy
.autoneg_advertised
|= IXGBE_LINK_SPEED_1GB_FULL
;
623 if (speed
& IXGBE_LINK_SPEED_100_FULL
)
624 hw
->phy
.autoneg_advertised
|= IXGBE_LINK_SPEED_100_FULL
;
627 * Implement Intel SmartSpeed algorithm. SmartSpeed will reduce the
628 * autoneg advertisement if link is unable to be established at the
629 * highest negotiated rate. This can sometimes happen due to integrity
630 * issues with the physical media connection.
633 /* First, try to get link with full advertisement */
634 hw
->phy
.smart_speed_active
= false;
635 for (j
= 0; j
< IXGBE_SMARTSPEED_MAX_RETRIES
; j
++) {
636 status
= ixgbe_setup_mac_link_82599(hw
, speed
, autoneg
,
637 autoneg_wait_to_complete
);
642 * Wait for the controller to acquire link. Per IEEE 802.3ap,
643 * Section 73.10.2, we may have to wait up to 500ms if KR is
644 * attempted, or 200ms if KX/KX4/BX/BX4 is attempted, per
645 * Table 9 in the AN MAS.
647 for (i
= 0; i
< 5; i
++) {
650 /* If we have link, just jump out */
651 hw
->mac
.ops
.check_link(hw
, &link_speed
,
659 * We didn't get link. If we advertised KR plus one of KX4/KX
660 * (or BX4/BX), then disable KR and try again.
662 if (((autoc_reg
& IXGBE_AUTOC_KR_SUPP
) == 0) ||
663 ((autoc_reg
& IXGBE_AUTOC_KX4_KX_SUPP_MASK
) == 0))
666 /* Turn SmartSpeed on to disable KR support */
667 hw
->phy
.smart_speed_active
= true;
668 status
= ixgbe_setup_mac_link_82599(hw
, speed
, autoneg
,
669 autoneg_wait_to_complete
);
674 * Wait for the controller to acquire link. 600ms will allow for
675 * the AN link_fail_inhibit_timer as well for multiple cycles of
676 * parallel detect, both 10g and 1g. This allows for the maximum
677 * connect attempts as defined in the AN MAS table 73-7.
679 for (i
= 0; i
< 6; i
++) {
682 /* If we have link, just jump out */
683 hw
->mac
.ops
.check_link(hw
, &link_speed
,
689 /* We didn't get link. Turn SmartSpeed back off. */
690 hw
->phy
.smart_speed_active
= false;
691 status
= ixgbe_setup_mac_link_82599(hw
, speed
, autoneg
,
692 autoneg_wait_to_complete
);
699 * ixgbe_check_mac_link_82599 - Determine link and speed status
700 * @hw: pointer to hardware structure
701 * @speed: pointer to link speed
702 * @link_up: true when link is up
703 * @link_up_wait_to_complete: bool used to wait for link up or not
705 * Reads the links register to determine if link is up and the current speed
707 static s32
ixgbe_check_mac_link_82599(struct ixgbe_hw
*hw
,
708 ixgbe_link_speed
*speed
,
710 bool link_up_wait_to_complete
)
715 links_reg
= IXGBE_READ_REG(hw
, IXGBE_LINKS
);
716 if (link_up_wait_to_complete
) {
717 for (i
= 0; i
< IXGBE_LINK_UP_TIME
; i
++) {
718 if (links_reg
& IXGBE_LINKS_UP
) {
725 links_reg
= IXGBE_READ_REG(hw
, IXGBE_LINKS
);
728 if (links_reg
& IXGBE_LINKS_UP
)
734 if ((links_reg
& IXGBE_LINKS_SPEED_82599
) ==
735 IXGBE_LINKS_SPEED_10G_82599
)
736 *speed
= IXGBE_LINK_SPEED_10GB_FULL
;
737 else if ((links_reg
& IXGBE_LINKS_SPEED_82599
) ==
738 IXGBE_LINKS_SPEED_1G_82599
)
739 *speed
= IXGBE_LINK_SPEED_1GB_FULL
;
741 *speed
= IXGBE_LINK_SPEED_100_FULL
;
743 /* if link is down, zero out the current_mode */
744 if (*link_up
== false) {
745 hw
->fc
.current_mode
= ixgbe_fc_none
;
746 hw
->fc
.fc_was_autonegged
= false;
753 * ixgbe_setup_mac_link_82599 - Set MAC link speed
754 * @hw: pointer to hardware structure
755 * @speed: new link speed
756 * @autoneg: true if autonegotiation enabled
757 * @autoneg_wait_to_complete: true when waiting for completion is needed
759 * Set the link speed in the AUTOC register and restarts link.
761 s32
ixgbe_setup_mac_link_82599(struct ixgbe_hw
*hw
,
762 ixgbe_link_speed speed
, bool autoneg
,
763 bool autoneg_wait_to_complete
)
766 u32 autoc
= IXGBE_READ_REG(hw
, IXGBE_AUTOC
);
767 u32 autoc2
= IXGBE_READ_REG(hw
, IXGBE_AUTOC2
);
768 u32 start_autoc
= autoc
;
770 u32 link_mode
= autoc
& IXGBE_AUTOC_LMS_MASK
;
771 u32 pma_pmd_1g
= autoc
& IXGBE_AUTOC_1G_PMA_PMD_MASK
;
772 u32 pma_pmd_10g_serial
= autoc2
& IXGBE_AUTOC2_10G_SERIAL_PMA_PMD_MASK
;
775 ixgbe_link_speed link_capabilities
= IXGBE_LINK_SPEED_UNKNOWN
;
777 /* Check to see if speed passed in is supported. */
778 hw
->mac
.ops
.get_link_capabilities(hw
, &link_capabilities
, &autoneg
);
779 speed
&= link_capabilities
;
781 if (speed
== IXGBE_LINK_SPEED_UNKNOWN
) {
782 status
= IXGBE_ERR_LINK_SETUP
;
786 /* Use stored value (EEPROM defaults) of AUTOC to find KR/KX4 support*/
787 if (hw
->mac
.orig_link_settings_stored
)
788 orig_autoc
= hw
->mac
.orig_autoc
;
793 if (link_mode
== IXGBE_AUTOC_LMS_KX4_KX_KR
||
794 link_mode
== IXGBE_AUTOC_LMS_KX4_KX_KR_1G_AN
||
795 link_mode
== IXGBE_AUTOC_LMS_KX4_KX_KR_SGMII
) {
796 /* Set KX4/KX/KR support according to speed requested */
797 autoc
&= ~(IXGBE_AUTOC_KX4_KX_SUPP_MASK
| IXGBE_AUTOC_KR_SUPP
);
798 if (speed
& IXGBE_LINK_SPEED_10GB_FULL
)
799 if (orig_autoc
& IXGBE_AUTOC_KX4_SUPP
)
800 autoc
|= IXGBE_AUTOC_KX4_SUPP
;
801 if ((orig_autoc
& IXGBE_AUTOC_KR_SUPP
) &&
802 (hw
->phy
.smart_speed_active
== false))
803 autoc
|= IXGBE_AUTOC_KR_SUPP
;
804 if (speed
& IXGBE_LINK_SPEED_1GB_FULL
)
805 autoc
|= IXGBE_AUTOC_KX_SUPP
;
806 } else if ((pma_pmd_1g
== IXGBE_AUTOC_1G_SFI
) &&
807 (link_mode
== IXGBE_AUTOC_LMS_1G_LINK_NO_AN
||
808 link_mode
== IXGBE_AUTOC_LMS_1G_AN
)) {
809 /* Switch from 1G SFI to 10G SFI if requested */
810 if ((speed
== IXGBE_LINK_SPEED_10GB_FULL
) &&
811 (pma_pmd_10g_serial
== IXGBE_AUTOC2_10G_SFI
)) {
812 autoc
&= ~IXGBE_AUTOC_LMS_MASK
;
813 autoc
|= IXGBE_AUTOC_LMS_10G_SERIAL
;
815 } else if ((pma_pmd_10g_serial
== IXGBE_AUTOC2_10G_SFI
) &&
816 (link_mode
== IXGBE_AUTOC_LMS_10G_SERIAL
)) {
817 /* Switch from 10G SFI to 1G SFI if requested */
818 if ((speed
== IXGBE_LINK_SPEED_1GB_FULL
) &&
819 (pma_pmd_1g
== IXGBE_AUTOC_1G_SFI
)) {
820 autoc
&= ~IXGBE_AUTOC_LMS_MASK
;
822 autoc
|= IXGBE_AUTOC_LMS_1G_AN
;
824 autoc
|= IXGBE_AUTOC_LMS_1G_LINK_NO_AN
;
828 if (autoc
!= start_autoc
) {
830 autoc
|= IXGBE_AUTOC_AN_RESTART
;
831 IXGBE_WRITE_REG(hw
, IXGBE_AUTOC
, autoc
);
833 /* Only poll for autoneg to complete if specified to do so */
834 if (autoneg_wait_to_complete
) {
835 if (link_mode
== IXGBE_AUTOC_LMS_KX4_KX_KR
||
836 link_mode
== IXGBE_AUTOC_LMS_KX4_KX_KR_1G_AN
||
837 link_mode
== IXGBE_AUTOC_LMS_KX4_KX_KR_SGMII
) {
838 links_reg
= 0; /*Just in case Autoneg time=0*/
839 for (i
= 0; i
< IXGBE_AUTO_NEG_TIME
; i
++) {
841 IXGBE_READ_REG(hw
, IXGBE_LINKS
);
842 if (links_reg
& IXGBE_LINKS_KX_AN_COMP
)
846 if (!(links_reg
& IXGBE_LINKS_KX_AN_COMP
)) {
848 IXGBE_ERR_AUTONEG_NOT_COMPLETE
;
849 hw_dbg(hw
, "Autoneg did not "
855 /* Add delay to filter out noises during initial link setup */
864 * ixgbe_setup_copper_link_82599 - Set the PHY autoneg advertised field
865 * @hw: pointer to hardware structure
866 * @speed: new link speed
867 * @autoneg: true if autonegotiation enabled
868 * @autoneg_wait_to_complete: true if waiting is needed to complete
870 * Restarts link on PHY and MAC based on settings passed in.
872 static s32
ixgbe_setup_copper_link_82599(struct ixgbe_hw
*hw
,
873 ixgbe_link_speed speed
,
875 bool autoneg_wait_to_complete
)
879 /* Setup the PHY according to input speed */
880 status
= hw
->phy
.ops
.setup_link_speed(hw
, speed
, autoneg
,
881 autoneg_wait_to_complete
);
883 ixgbe_start_mac_link_82599(hw
, autoneg_wait_to_complete
);
889 * ixgbe_reset_hw_82599 - Perform hardware reset
890 * @hw: pointer to hardware structure
892 * Resets the hardware by resetting the transmit and receive units, masks
893 * and clears all interrupts, perform a PHY reset, and perform a link (MAC)
896 static s32
ixgbe_reset_hw_82599(struct ixgbe_hw
*hw
)
904 /* Call adapter stop to disable tx/rx and clear interrupts */
905 hw
->mac
.ops
.stop_adapter(hw
);
907 /* PHY ops must be identified and initialized prior to reset */
909 /* Init PHY and function pointers, perform SFP setup */
910 status
= hw
->phy
.ops
.init(hw
);
912 if (status
== IXGBE_ERR_SFP_NOT_SUPPORTED
)
915 /* Setup SFP module if there is one present. */
916 if (hw
->phy
.sfp_setup_needed
) {
917 status
= hw
->mac
.ops
.setup_sfp(hw
);
918 hw
->phy
.sfp_setup_needed
= false;
922 if (hw
->phy
.reset_disable
== false && hw
->phy
.ops
.reset
!= NULL
)
923 hw
->phy
.ops
.reset(hw
);
926 * Prevent the PCI-E bus from from hanging by disabling PCI-E master
927 * access and verify no pending requests before reset
929 status
= ixgbe_disable_pcie_master(hw
);
931 status
= IXGBE_ERR_MASTER_REQUESTS_PENDING
;
932 hw_dbg(hw
, "PCI-E Master disable polling has failed.\n");
936 * Issue global reset to the MAC. This needs to be a SW reset.
937 * If link reset is used, it might reset the MAC when mng is using it
939 ctrl
= IXGBE_READ_REG(hw
, IXGBE_CTRL
);
940 IXGBE_WRITE_REG(hw
, IXGBE_CTRL
, (ctrl
| IXGBE_CTRL_RST
));
941 IXGBE_WRITE_FLUSH(hw
);
943 /* Poll for reset bit to self-clear indicating reset is complete */
944 for (i
= 0; i
< 10; i
++) {
946 ctrl
= IXGBE_READ_REG(hw
, IXGBE_CTRL
);
947 if (!(ctrl
& IXGBE_CTRL_RST
))
950 if (ctrl
& IXGBE_CTRL_RST
) {
951 status
= IXGBE_ERR_RESET_FAILED
;
952 hw_dbg(hw
, "Reset polling failed to complete.\n");
958 * Store the original AUTOC/AUTOC2 values if they have not been
959 * stored off yet. Otherwise restore the stored original
960 * values since the reset operation sets back to defaults.
962 autoc
= IXGBE_READ_REG(hw
, IXGBE_AUTOC
);
963 autoc2
= IXGBE_READ_REG(hw
, IXGBE_AUTOC2
);
964 if (hw
->mac
.orig_link_settings_stored
== false) {
965 hw
->mac
.orig_autoc
= autoc
;
966 hw
->mac
.orig_autoc2
= autoc2
;
967 hw
->mac
.orig_link_settings_stored
= true;
969 if (autoc
!= hw
->mac
.orig_autoc
)
970 IXGBE_WRITE_REG(hw
, IXGBE_AUTOC
, (hw
->mac
.orig_autoc
|
971 IXGBE_AUTOC_AN_RESTART
));
973 if ((autoc2
& IXGBE_AUTOC2_UPPER_MASK
) !=
974 (hw
->mac
.orig_autoc2
& IXGBE_AUTOC2_UPPER_MASK
)) {
975 autoc2
&= ~IXGBE_AUTOC2_UPPER_MASK
;
976 autoc2
|= (hw
->mac
.orig_autoc2
&
977 IXGBE_AUTOC2_UPPER_MASK
);
978 IXGBE_WRITE_REG(hw
, IXGBE_AUTOC2
, autoc2
);
983 * Store MAC address from RAR0, clear receive address registers, and
984 * clear the multicast table. Also reset num_rar_entries to 128,
985 * since we modify this value when programming the SAN MAC address.
987 hw
->mac
.num_rar_entries
= 128;
988 hw
->mac
.ops
.init_rx_addrs(hw
);
990 /* Store the permanent mac address */
991 hw
->mac
.ops
.get_mac_addr(hw
, hw
->mac
.perm_addr
);
993 /* Store the permanent SAN mac address */
994 hw
->mac
.ops
.get_san_mac_addr(hw
, hw
->mac
.san_addr
);
996 /* Add the SAN MAC address to the RAR only if it's a valid address */
997 if (ixgbe_validate_mac_addr(hw
->mac
.san_addr
) == 0) {
998 hw
->mac
.ops
.set_rar(hw
, hw
->mac
.num_rar_entries
- 1,
999 hw
->mac
.san_addr
, 0, IXGBE_RAH_AV
);
1001 /* Reserve the last RAR for the SAN MAC address */
1002 hw
->mac
.num_rar_entries
--;
1005 /* Store the alternative WWNN/WWPN prefix */
1006 hw
->mac
.ops
.get_wwn_prefix(hw
, &hw
->mac
.wwnn_prefix
,
1007 &hw
->mac
.wwpn_prefix
);
1014 * ixgbe_clear_vmdq_82599 - Disassociate a VMDq pool index from a rx address
1015 * @hw: pointer to hardware struct
1016 * @rar: receive address register index to disassociate
1017 * @vmdq: VMDq pool index to remove from the rar
1019 static s32
ixgbe_clear_vmdq_82599(struct ixgbe_hw
*hw
, u32 rar
, u32 vmdq
)
1021 u32 mpsar_lo
, mpsar_hi
;
1022 u32 rar_entries
= hw
->mac
.num_rar_entries
;
1024 if (rar
< rar_entries
) {
1025 mpsar_lo
= IXGBE_READ_REG(hw
, IXGBE_MPSAR_LO(rar
));
1026 mpsar_hi
= IXGBE_READ_REG(hw
, IXGBE_MPSAR_HI(rar
));
1028 if (!mpsar_lo
&& !mpsar_hi
)
1031 if (vmdq
== IXGBE_CLEAR_VMDQ_ALL
) {
1033 IXGBE_WRITE_REG(hw
, IXGBE_MPSAR_LO(rar
), 0);
1037 IXGBE_WRITE_REG(hw
, IXGBE_MPSAR_HI(rar
), 0);
1040 } else if (vmdq
< 32) {
1041 mpsar_lo
&= ~(1 << vmdq
);
1042 IXGBE_WRITE_REG(hw
, IXGBE_MPSAR_LO(rar
), mpsar_lo
);
1044 mpsar_hi
&= ~(1 << (vmdq
- 32));
1045 IXGBE_WRITE_REG(hw
, IXGBE_MPSAR_HI(rar
), mpsar_hi
);
1048 /* was that the last pool using this rar? */
1049 if (mpsar_lo
== 0 && mpsar_hi
== 0 && rar
!= 0)
1050 hw
->mac
.ops
.clear_rar(hw
, rar
);
1052 hw_dbg(hw
, "RAR index %d is out of range.\n", rar
);
1060 * ixgbe_set_vmdq_82599 - Associate a VMDq pool index with a rx address
1061 * @hw: pointer to hardware struct
1062 * @rar: receive address register index to associate with a VMDq index
1063 * @vmdq: VMDq pool index
1065 static s32
ixgbe_set_vmdq_82599(struct ixgbe_hw
*hw
, u32 rar
, u32 vmdq
)
1068 u32 rar_entries
= hw
->mac
.num_rar_entries
;
1070 if (rar
< rar_entries
) {
1072 mpsar
= IXGBE_READ_REG(hw
, IXGBE_MPSAR_LO(rar
));
1074 IXGBE_WRITE_REG(hw
, IXGBE_MPSAR_LO(rar
), mpsar
);
1076 mpsar
= IXGBE_READ_REG(hw
, IXGBE_MPSAR_HI(rar
));
1077 mpsar
|= 1 << (vmdq
- 32);
1078 IXGBE_WRITE_REG(hw
, IXGBE_MPSAR_HI(rar
), mpsar
);
1081 hw_dbg(hw
, "RAR index %d is out of range.\n", rar
);
1087 * ixgbe_set_vfta_82599 - Set VLAN filter table
1088 * @hw: pointer to hardware structure
1089 * @vlan: VLAN id to write to VLAN filter
1090 * @vind: VMDq output index that maps queue to VLAN id in VFVFB
1091 * @vlan_on: boolean flag to turn on/off VLAN in VFVF
1093 * Turn on/off specified VLAN in the VLAN filter table.
1095 static s32
ixgbe_set_vfta_82599(struct ixgbe_hw
*hw
, u32 vlan
, u32 vind
,
1102 u32 first_empty_slot
;
1106 return IXGBE_ERR_PARAM
;
1109 * this is a 2 part operation - first the VFTA, then the
1110 * VLVF and VLVFB if vind is set
1114 * The VFTA is a bitstring made up of 128 32-bit registers
1115 * that enable the particular VLAN id, much like the MTA:
1116 * bits[11-5]: which register
1117 * bits[4-0]: which bit in the register
1119 regindex
= (vlan
>> 5) & 0x7F;
1120 bitindex
= vlan
& 0x1F;
1121 bits
= IXGBE_READ_REG(hw
, IXGBE_VFTA(regindex
));
1123 bits
|= (1 << bitindex
);
1125 bits
&= ~(1 << bitindex
);
1126 IXGBE_WRITE_REG(hw
, IXGBE_VFTA(regindex
), bits
);
1132 * make sure the vlan is in VLVF
1133 * set the vind bit in the matching VLVFB
1135 * clear the pool bit and possibly the vind
1137 vt_ctl
= IXGBE_READ_REG(hw
, IXGBE_VT_CTL
);
1138 if (!(vt_ctl
& IXGBE_VT_CTL_VT_ENABLE
))
1141 /* find the vlanid or the first empty slot */
1142 first_empty_slot
= 0;
1144 for (vlvf_index
= 1; vlvf_index
< IXGBE_VLVF_ENTRIES
; vlvf_index
++) {
1145 bits
= IXGBE_READ_REG(hw
, IXGBE_VLVF(vlvf_index
));
1146 if (!bits
&& !first_empty_slot
)
1147 first_empty_slot
= vlvf_index
;
1148 else if ((bits
& 0x0FFF) == vlan
)
1152 if (vlvf_index
>= IXGBE_VLVF_ENTRIES
) {
1153 if (first_empty_slot
)
1154 vlvf_index
= first_empty_slot
;
1156 hw_dbg(hw
, "No space in VLVF.\n");
1162 /* set the pool bit */
1164 bits
= IXGBE_READ_REG(hw
,
1165 IXGBE_VLVFB(vlvf_index
* 2));
1166 bits
|= (1 << vind
);
1168 IXGBE_VLVFB(vlvf_index
* 2), bits
);
1170 bits
= IXGBE_READ_REG(hw
,
1171 IXGBE_VLVFB((vlvf_index
* 2) + 1));
1172 bits
|= (1 << (vind
- 32));
1174 IXGBE_VLVFB((vlvf_index
* 2) + 1), bits
);
1177 /* clear the pool bit */
1179 bits
= IXGBE_READ_REG(hw
,
1180 IXGBE_VLVFB(vlvf_index
* 2));
1181 bits
&= ~(1 << vind
);
1183 IXGBE_VLVFB(vlvf_index
* 2), bits
);
1184 bits
|= IXGBE_READ_REG(hw
,
1185 IXGBE_VLVFB((vlvf_index
* 2) + 1));
1187 bits
= IXGBE_READ_REG(hw
,
1188 IXGBE_VLVFB((vlvf_index
* 2) + 1));
1189 bits
&= ~(1 << (vind
- 32));
1191 IXGBE_VLVFB((vlvf_index
* 2) + 1), bits
);
1192 bits
|= IXGBE_READ_REG(hw
,
1193 IXGBE_VLVFB(vlvf_index
* 2));
1198 IXGBE_WRITE_REG(hw
, IXGBE_VLVF(vlvf_index
),
1199 (IXGBE_VLVF_VIEN
| vlan
));
1200 /* if bits is non-zero then some pools/VFs are still
1201 * using this VLAN ID. Force the VFTA entry to on */
1202 bits
= IXGBE_READ_REG(hw
, IXGBE_VFTA(regindex
));
1203 bits
|= (1 << bitindex
);
1204 IXGBE_WRITE_REG(hw
, IXGBE_VFTA(regindex
), bits
);
1207 IXGBE_WRITE_REG(hw
, IXGBE_VLVF(vlvf_index
), 0);
1214 * ixgbe_clear_vfta_82599 - Clear VLAN filter table
1215 * @hw: pointer to hardware structure
1217 * Clears the VLAN filer table, and the VMDq index associated with the filter
1219 static s32
ixgbe_clear_vfta_82599(struct ixgbe_hw
*hw
)
1223 for (offset
= 0; offset
< hw
->mac
.vft_size
; offset
++)
1224 IXGBE_WRITE_REG(hw
, IXGBE_VFTA(offset
), 0);
1226 for (offset
= 0; offset
< IXGBE_VLVF_ENTRIES
; offset
++) {
1227 IXGBE_WRITE_REG(hw
, IXGBE_VLVF(offset
), 0);
1228 IXGBE_WRITE_REG(hw
, IXGBE_VLVFB(offset
* 2), 0);
1229 IXGBE_WRITE_REG(hw
, IXGBE_VLVFB((offset
* 2) + 1), 0);
1236 * ixgbe_init_uta_tables_82599 - Initialize the Unicast Table Array
1237 * @hw: pointer to hardware structure
1239 static s32
ixgbe_init_uta_tables_82599(struct ixgbe_hw
*hw
)
1242 hw_dbg(hw
, " Clearing UTA\n");
1244 for (i
= 0; i
< 128; i
++)
1245 IXGBE_WRITE_REG(hw
, IXGBE_UTA(i
), 0);
1251 * ixgbe_reinit_fdir_tables_82599 - Reinitialize Flow Director tables.
1252 * @hw: pointer to hardware structure
1254 s32
ixgbe_reinit_fdir_tables_82599(struct ixgbe_hw
*hw
)
1257 u32 fdirctrl
= IXGBE_READ_REG(hw
, IXGBE_FDIRCTRL
);
1258 fdirctrl
&= ~IXGBE_FDIRCTRL_INIT_DONE
;
1261 * Before starting reinitialization process,
1262 * FDIRCMD.CMD must be zero.
1264 for (i
= 0; i
< IXGBE_FDIRCMD_CMD_POLL
; i
++) {
1265 if (!(IXGBE_READ_REG(hw
, IXGBE_FDIRCMD
) &
1266 IXGBE_FDIRCMD_CMD_MASK
))
1270 if (i
>= IXGBE_FDIRCMD_CMD_POLL
) {
1271 hw_dbg(hw
,"Flow Director previous command isn't complete, "
1272 "aborting table re-initialization. \n");
1273 return IXGBE_ERR_FDIR_REINIT_FAILED
;
1276 IXGBE_WRITE_REG(hw
, IXGBE_FDIRFREE
, 0);
1277 IXGBE_WRITE_FLUSH(hw
);
1279 * 82599 adapters flow director init flow cannot be restarted,
1280 * Workaround 82599 silicon errata by performing the following steps
1281 * before re-writing the FDIRCTRL control register with the same value.
1282 * - write 1 to bit 8 of FDIRCMD register &
1283 * - write 0 to bit 8 of FDIRCMD register
1285 IXGBE_WRITE_REG(hw
, IXGBE_FDIRCMD
,
1286 (IXGBE_READ_REG(hw
, IXGBE_FDIRCMD
) |
1287 IXGBE_FDIRCMD_CLEARHT
));
1288 IXGBE_WRITE_FLUSH(hw
);
1289 IXGBE_WRITE_REG(hw
, IXGBE_FDIRCMD
,
1290 (IXGBE_READ_REG(hw
, IXGBE_FDIRCMD
) &
1291 ~IXGBE_FDIRCMD_CLEARHT
));
1292 IXGBE_WRITE_FLUSH(hw
);
1294 * Clear FDIR Hash register to clear any leftover hashes
1295 * waiting to be programmed.
1297 IXGBE_WRITE_REG(hw
, IXGBE_FDIRHASH
, 0x00);
1298 IXGBE_WRITE_FLUSH(hw
);
1300 IXGBE_WRITE_REG(hw
, IXGBE_FDIRCTRL
, fdirctrl
);
1301 IXGBE_WRITE_FLUSH(hw
);
1303 /* Poll init-done after we write FDIRCTRL register */
1304 for (i
= 0; i
< IXGBE_FDIR_INIT_DONE_POLL
; i
++) {
1305 if (IXGBE_READ_REG(hw
, IXGBE_FDIRCTRL
) &
1306 IXGBE_FDIRCTRL_INIT_DONE
)
1310 if (i
>= IXGBE_FDIR_INIT_DONE_POLL
) {
1311 hw_dbg(hw
, "Flow Director Signature poll time exceeded!\n");
1312 return IXGBE_ERR_FDIR_REINIT_FAILED
;
1315 /* Clear FDIR statistics registers (read to clear) */
1316 IXGBE_READ_REG(hw
, IXGBE_FDIRUSTAT
);
1317 IXGBE_READ_REG(hw
, IXGBE_FDIRFSTAT
);
1318 IXGBE_READ_REG(hw
, IXGBE_FDIRMATCH
);
1319 IXGBE_READ_REG(hw
, IXGBE_FDIRMISS
);
1320 IXGBE_READ_REG(hw
, IXGBE_FDIRLEN
);
1326 * ixgbe_init_fdir_signature_82599 - Initialize Flow Director signature filters
1327 * @hw: pointer to hardware structure
1328 * @pballoc: which mode to allocate filters with
1330 s32
ixgbe_init_fdir_signature_82599(struct ixgbe_hw
*hw
, u32 pballoc
)
1337 * Before enabling Flow Director, the Rx Packet Buffer size
1338 * must be reduced. The new value is the current size minus
1339 * flow director memory usage size.
1341 pbsize
= (1 << (IXGBE_FDIR_PBALLOC_SIZE_SHIFT
+ pballoc
));
1342 IXGBE_WRITE_REG(hw
, IXGBE_RXPBSIZE(0),
1343 (IXGBE_READ_REG(hw
, IXGBE_RXPBSIZE(0)) - pbsize
));
1346 * The defaults in the HW for RX PB 1-7 are not zero and so should be
1347 * intialized to zero for non DCB mode otherwise actual total RX PB
1348 * would be bigger than programmed and filter space would run into
1351 for (i
= 1; i
< 8; i
++)
1352 IXGBE_WRITE_REG(hw
, IXGBE_RXPBSIZE(i
), 0);
1354 /* Send interrupt when 64 filters are left */
1355 fdirctrl
|= 4 << IXGBE_FDIRCTRL_FULL_THRESH_SHIFT
;
1357 /* Set the maximum length per hash bucket to 0xA filters */
1358 fdirctrl
|= 0xA << IXGBE_FDIRCTRL_MAX_LENGTH_SHIFT
;
1361 case IXGBE_FDIR_PBALLOC_64K
:
1362 /* 8k - 1 signature filters */
1363 fdirctrl
|= IXGBE_FDIRCTRL_PBALLOC_64K
;
1365 case IXGBE_FDIR_PBALLOC_128K
:
1366 /* 16k - 1 signature filters */
1367 fdirctrl
|= IXGBE_FDIRCTRL_PBALLOC_128K
;
1369 case IXGBE_FDIR_PBALLOC_256K
:
1370 /* 32k - 1 signature filters */
1371 fdirctrl
|= IXGBE_FDIRCTRL_PBALLOC_256K
;
1375 return IXGBE_ERR_CONFIG
;
1378 /* Move the flexible bytes to use the ethertype - shift 6 words */
1379 fdirctrl
|= (0x6 << IXGBE_FDIRCTRL_FLEX_SHIFT
);
1381 fdirctrl
|= IXGBE_FDIRCTRL_REPORT_STATUS
;
1383 /* Prime the keys for hashing */
1384 IXGBE_WRITE_REG(hw
, IXGBE_FDIRHKEY
,
1385 htonl(IXGBE_ATR_BUCKET_HASH_KEY
));
1386 IXGBE_WRITE_REG(hw
, IXGBE_FDIRSKEY
,
1387 htonl(IXGBE_ATR_SIGNATURE_HASH_KEY
));
1390 * Poll init-done after we write the register. Estimated times:
1391 * 10G: PBALLOC = 11b, timing is 60us
1392 * 1G: PBALLOC = 11b, timing is 600us
1393 * 100M: PBALLOC = 11b, timing is 6ms
1395 * Multiple these timings by 4 if under full Rx load
1397 * So we'll poll for IXGBE_FDIR_INIT_DONE_POLL times, sleeping for
1398 * 1 msec per poll time. If we're at line rate and drop to 100M, then
1399 * this might not finish in our poll time, but we can live with that
1402 IXGBE_WRITE_REG(hw
, IXGBE_FDIRCTRL
, fdirctrl
);
1403 IXGBE_WRITE_FLUSH(hw
);
1404 for (i
= 0; i
< IXGBE_FDIR_INIT_DONE_POLL
; i
++) {
1405 if (IXGBE_READ_REG(hw
, IXGBE_FDIRCTRL
) &
1406 IXGBE_FDIRCTRL_INIT_DONE
)
1410 if (i
>= IXGBE_FDIR_INIT_DONE_POLL
)
1411 hw_dbg(hw
, "Flow Director Signature poll time exceeded!\n");
1417 * ixgbe_init_fdir_perfect_82599 - Initialize Flow Director perfect filters
1418 * @hw: pointer to hardware structure
1419 * @pballoc: which mode to allocate filters with
1421 s32
ixgbe_init_fdir_perfect_82599(struct ixgbe_hw
*hw
, u32 pballoc
)
1428 * Before enabling Flow Director, the Rx Packet Buffer size
1429 * must be reduced. The new value is the current size minus
1430 * flow director memory usage size.
1432 pbsize
= (1 << (IXGBE_FDIR_PBALLOC_SIZE_SHIFT
+ pballoc
));
1433 IXGBE_WRITE_REG(hw
, IXGBE_RXPBSIZE(0),
1434 (IXGBE_READ_REG(hw
, IXGBE_RXPBSIZE(0)) - pbsize
));
1437 * The defaults in the HW for RX PB 1-7 are not zero and so should be
1438 * intialized to zero for non DCB mode otherwise actual total RX PB
1439 * would be bigger than programmed and filter space would run into
1442 for (i
= 1; i
< 8; i
++)
1443 IXGBE_WRITE_REG(hw
, IXGBE_RXPBSIZE(i
), 0);
1445 /* Send interrupt when 64 filters are left */
1446 fdirctrl
|= 4 << IXGBE_FDIRCTRL_FULL_THRESH_SHIFT
;
1448 /* Initialize the drop queue to Rx queue 127 */
1449 fdirctrl
|= (127 << IXGBE_FDIRCTRL_DROP_Q_SHIFT
);
1452 case IXGBE_FDIR_PBALLOC_64K
:
1453 /* 2k - 1 perfect filters */
1454 fdirctrl
|= IXGBE_FDIRCTRL_PBALLOC_64K
;
1456 case IXGBE_FDIR_PBALLOC_128K
:
1457 /* 4k - 1 perfect filters */
1458 fdirctrl
|= IXGBE_FDIRCTRL_PBALLOC_128K
;
1460 case IXGBE_FDIR_PBALLOC_256K
:
1461 /* 8k - 1 perfect filters */
1462 fdirctrl
|= IXGBE_FDIRCTRL_PBALLOC_256K
;
1466 return IXGBE_ERR_CONFIG
;
1469 /* Turn perfect match filtering on */
1470 fdirctrl
|= IXGBE_FDIRCTRL_PERFECT_MATCH
;
1471 fdirctrl
|= IXGBE_FDIRCTRL_REPORT_STATUS
;
1473 /* Move the flexible bytes to use the ethertype - shift 6 words */
1474 fdirctrl
|= (0x6 << IXGBE_FDIRCTRL_FLEX_SHIFT
);
1476 /* Prime the keys for hashing */
1477 IXGBE_WRITE_REG(hw
, IXGBE_FDIRHKEY
,
1478 htonl(IXGBE_ATR_BUCKET_HASH_KEY
));
1479 IXGBE_WRITE_REG(hw
, IXGBE_FDIRSKEY
,
1480 htonl(IXGBE_ATR_SIGNATURE_HASH_KEY
));
1483 * Poll init-done after we write the register. Estimated times:
1484 * 10G: PBALLOC = 11b, timing is 60us
1485 * 1G: PBALLOC = 11b, timing is 600us
1486 * 100M: PBALLOC = 11b, timing is 6ms
1488 * Multiple these timings by 4 if under full Rx load
1490 * So we'll poll for IXGBE_FDIR_INIT_DONE_POLL times, sleeping for
1491 * 1 msec per poll time. If we're at line rate and drop to 100M, then
1492 * this might not finish in our poll time, but we can live with that
1496 /* Set the maximum length per hash bucket to 0xA filters */
1497 fdirctrl
|= (0xA << IXGBE_FDIRCTRL_MAX_LENGTH_SHIFT
);
1499 IXGBE_WRITE_REG(hw
, IXGBE_FDIRCTRL
, fdirctrl
);
1500 IXGBE_WRITE_FLUSH(hw
);
1501 for (i
= 0; i
< IXGBE_FDIR_INIT_DONE_POLL
; i
++) {
1502 if (IXGBE_READ_REG(hw
, IXGBE_FDIRCTRL
) &
1503 IXGBE_FDIRCTRL_INIT_DONE
)
1507 if (i
>= IXGBE_FDIR_INIT_DONE_POLL
)
1508 hw_dbg(hw
, "Flow Director Perfect poll time exceeded!\n");
1515 * ixgbe_atr_compute_hash_82599 - Compute the hashes for SW ATR
1516 * @stream: input bitstream to compute the hash on
1517 * @key: 32-bit hash key
1519 static u16
ixgbe_atr_compute_hash_82599(struct ixgbe_atr_input
*atr_input
,
1523 * The algorithm is as follows:
1524 * Hash[15:0] = Sum { S[n] x K[n+16] }, n = 0...350
1525 * where Sum {A[n]}, n = 0...n is bitwise XOR of A[0], A[1]...A[n]
1526 * and A[n] x B[n] is bitwise AND between same length strings
1528 * K[n] is 16 bits, defined as:
1529 * for n modulo 32 >= 15, K[n] = K[n % 32 : (n % 32) - 15]
1530 * for n modulo 32 < 15, K[n] =
1531 * K[(n % 32:0) | (31:31 - (14 - (n % 32)))]
1533 * S[n] is 16 bits, defined as:
1534 * for n >= 15, S[n] = S[n:n - 15]
1535 * for n < 15, S[n] = S[(n:0) | (350:350 - (14 - n))]
1537 * To simplify for programming, the algorithm is implemented
1538 * in software this way:
1540 * Key[31:0], Stream[335:0]
1542 * tmp_key[11 * 32 - 1:0] = 11{Key[31:0] = key concatenated 11 times
1543 * int_key[350:0] = tmp_key[351:1]
1544 * int_stream[365:0] = Stream[14:0] | Stream[335:0] | Stream[335:321]
1547 * for (i = 0; i < 351; i++) {
1549 * hash ^= int_stream[(i + 15):i];
1559 u8
*stream
= (u8
*)atr_input
;
1560 u8 int_key
[44]; /* upper-most bit unused */
1561 u8 hash_str
[46]; /* upper-most 2 bits unused */
1562 u16 hash_result
= 0;
1566 * Initialize the fill member to prevent warnings
1569 tmp_key
.fill
[0] = 0;
1571 /* First load the temporary key stream */
1572 for (i
= 0; i
< 6; i
++) {
1573 u64 fillkey
= ((u64
)key
<< 32) | key
;
1574 tmp_key
.fill
[i
] = fillkey
;
1578 * Set the interim key for the hashing. Bit 352 is unused, so we must
1579 * shift and compensate when building the key.
1582 int_key
[0] = tmp_key
.key_stream
[0] >> 1;
1583 for (i
= 1, j
= 0; i
< 44; i
++) {
1584 unsigned int this_key
= tmp_key
.key_stream
[j
] << 7;
1586 int_key
[i
] = (u8
)(this_key
| (tmp_key
.key_stream
[j
] >> 1));
1590 * Set the interim bit string for the hashing. Bits 368 and 367 are
1591 * unused, so shift and compensate when building the string.
1593 hash_str
[0] = (stream
[40] & 0x7f) >> 1;
1594 for (i
= 1, j
= 40; i
< 46; i
++) {
1595 unsigned int this_str
= stream
[j
] << 7;
1599 hash_str
[i
] = (u8
)(this_str
| (stream
[j
] >> 1));
1603 * Now compute the hash. i is the index into hash_str, j is into our
1604 * key stream, k is counting the number of bits, and h interates within
1607 for (i
= 45, j
= 43, k
= 0; k
< 351 && i
>= 2 && j
>= 0; i
--, j
--) {
1608 for (h
= 0; h
< 8 && k
< 351; h
++, k
++) {
1609 if (int_key
[j
] & (1 << h
)) {
1611 * Key bit is set, XOR in the current 16-bit
1612 * string. Example of processing:
1614 * tmp = (hash_str[i - 2] & 0 << 16) |
1615 * (hash_str[i - 1] & 0xff << 8) |
1616 * (hash_str[i] & 0xff >> 0)
1617 * So tmp = hash_str[15 + k:k], since the
1618 * i + 2 clause rolls off the 16-bit value
1620 * tmp = (hash_str[i - 2] & 0x7f << 9) |
1621 * (hash_str[i - 1] & 0xff << 1) |
1622 * (hash_str[i] & 0x80 >> 7)
1624 int tmp
= (hash_str
[i
] >> h
);
1625 tmp
|= (hash_str
[i
- 1] << (8 - h
));
1626 tmp
|= (int)(hash_str
[i
- 2] & ((1 << h
) - 1))
1628 hash_result
^= (u16
)tmp
;
1637 * ixgbe_atr_set_vlan_id_82599 - Sets the VLAN id in the ATR input stream
1638 * @input: input stream to modify
1639 * @vlan: the VLAN id to load
1641 s32
ixgbe_atr_set_vlan_id_82599(struct ixgbe_atr_input
*input
, u16 vlan
)
1643 input
->byte_stream
[IXGBE_ATR_VLAN_OFFSET
+ 1] = vlan
>> 8;
1644 input
->byte_stream
[IXGBE_ATR_VLAN_OFFSET
] = vlan
& 0xff;
1650 * ixgbe_atr_set_src_ipv4_82599 - Sets the source IPv4 address
1651 * @input: input stream to modify
1652 * @src_addr: the IP address to load
1654 s32
ixgbe_atr_set_src_ipv4_82599(struct ixgbe_atr_input
*input
, u32 src_addr
)
1656 input
->byte_stream
[IXGBE_ATR_SRC_IPV4_OFFSET
+ 3] = src_addr
>> 24;
1657 input
->byte_stream
[IXGBE_ATR_SRC_IPV4_OFFSET
+ 2] =
1658 (src_addr
>> 16) & 0xff;
1659 input
->byte_stream
[IXGBE_ATR_SRC_IPV4_OFFSET
+ 1] =
1660 (src_addr
>> 8) & 0xff;
1661 input
->byte_stream
[IXGBE_ATR_SRC_IPV4_OFFSET
] = src_addr
& 0xff;
1667 * ixgbe_atr_set_dst_ipv4_82599 - Sets the destination IPv4 address
1668 * @input: input stream to modify
1669 * @dst_addr: the IP address to load
1671 s32
ixgbe_atr_set_dst_ipv4_82599(struct ixgbe_atr_input
*input
, u32 dst_addr
)
1673 input
->byte_stream
[IXGBE_ATR_DST_IPV4_OFFSET
+ 3] = dst_addr
>> 24;
1674 input
->byte_stream
[IXGBE_ATR_DST_IPV4_OFFSET
+ 2] =
1675 (dst_addr
>> 16) & 0xff;
1676 input
->byte_stream
[IXGBE_ATR_DST_IPV4_OFFSET
+ 1] =
1677 (dst_addr
>> 8) & 0xff;
1678 input
->byte_stream
[IXGBE_ATR_DST_IPV4_OFFSET
] = dst_addr
& 0xff;
1684 * ixgbe_atr_set_src_ipv6_82599 - Sets the source IPv6 address
1685 * @input: input stream to modify
1686 * @src_addr_1: the first 4 bytes of the IP address to load
1687 * @src_addr_2: the second 4 bytes of the IP address to load
1688 * @src_addr_3: the third 4 bytes of the IP address to load
1689 * @src_addr_4: the fourth 4 bytes of the IP address to load
1691 s32
ixgbe_atr_set_src_ipv6_82599(struct ixgbe_atr_input
*input
,
1692 u32 src_addr_1
, u32 src_addr_2
,
1693 u32 src_addr_3
, u32 src_addr_4
)
1695 input
->byte_stream
[IXGBE_ATR_SRC_IPV6_OFFSET
] = src_addr_4
& 0xff;
1696 input
->byte_stream
[IXGBE_ATR_SRC_IPV6_OFFSET
+ 1] =
1697 (src_addr_4
>> 8) & 0xff;
1698 input
->byte_stream
[IXGBE_ATR_SRC_IPV6_OFFSET
+ 2] =
1699 (src_addr_4
>> 16) & 0xff;
1700 input
->byte_stream
[IXGBE_ATR_SRC_IPV6_OFFSET
+ 3] = src_addr_4
>> 24;
1702 input
->byte_stream
[IXGBE_ATR_SRC_IPV6_OFFSET
+ 4] = src_addr_3
& 0xff;
1703 input
->byte_stream
[IXGBE_ATR_SRC_IPV6_OFFSET
+ 5] =
1704 (src_addr_3
>> 8) & 0xff;
1705 input
->byte_stream
[IXGBE_ATR_SRC_IPV6_OFFSET
+ 6] =
1706 (src_addr_3
>> 16) & 0xff;
1707 input
->byte_stream
[IXGBE_ATR_SRC_IPV6_OFFSET
+ 7] = src_addr_3
>> 24;
1709 input
->byte_stream
[IXGBE_ATR_SRC_IPV6_OFFSET
+ 8] = src_addr_2
& 0xff;
1710 input
->byte_stream
[IXGBE_ATR_SRC_IPV6_OFFSET
+ 9] =
1711 (src_addr_2
>> 8) & 0xff;
1712 input
->byte_stream
[IXGBE_ATR_SRC_IPV6_OFFSET
+ 10] =
1713 (src_addr_2
>> 16) & 0xff;
1714 input
->byte_stream
[IXGBE_ATR_SRC_IPV6_OFFSET
+ 11] = src_addr_2
>> 24;
1716 input
->byte_stream
[IXGBE_ATR_SRC_IPV6_OFFSET
+ 12] = src_addr_1
& 0xff;
1717 input
->byte_stream
[IXGBE_ATR_SRC_IPV6_OFFSET
+ 13] =
1718 (src_addr_1
>> 8) & 0xff;
1719 input
->byte_stream
[IXGBE_ATR_SRC_IPV6_OFFSET
+ 14] =
1720 (src_addr_1
>> 16) & 0xff;
1721 input
->byte_stream
[IXGBE_ATR_SRC_IPV6_OFFSET
+ 15] = src_addr_1
>> 24;
1727 * ixgbe_atr_set_dst_ipv6_82599 - Sets the destination IPv6 address
1728 * @input: input stream to modify
1729 * @dst_addr_1: the first 4 bytes of the IP address to load
1730 * @dst_addr_2: the second 4 bytes of the IP address to load
1731 * @dst_addr_3: the third 4 bytes of the IP address to load
1732 * @dst_addr_4: the fourth 4 bytes of the IP address to load
1734 s32
ixgbe_atr_set_dst_ipv6_82599(struct ixgbe_atr_input
*input
,
1735 u32 dst_addr_1
, u32 dst_addr_2
,
1736 u32 dst_addr_3
, u32 dst_addr_4
)
1738 input
->byte_stream
[IXGBE_ATR_DST_IPV6_OFFSET
] = dst_addr_4
& 0xff;
1739 input
->byte_stream
[IXGBE_ATR_DST_IPV6_OFFSET
+ 1] =
1740 (dst_addr_4
>> 8) & 0xff;
1741 input
->byte_stream
[IXGBE_ATR_DST_IPV6_OFFSET
+ 2] =
1742 (dst_addr_4
>> 16) & 0xff;
1743 input
->byte_stream
[IXGBE_ATR_DST_IPV6_OFFSET
+ 3] = dst_addr_4
>> 24;
1745 input
->byte_stream
[IXGBE_ATR_DST_IPV6_OFFSET
+ 4] = dst_addr_3
& 0xff;
1746 input
->byte_stream
[IXGBE_ATR_DST_IPV6_OFFSET
+ 5] =
1747 (dst_addr_3
>> 8) & 0xff;
1748 input
->byte_stream
[IXGBE_ATR_DST_IPV6_OFFSET
+ 6] =
1749 (dst_addr_3
>> 16) & 0xff;
1750 input
->byte_stream
[IXGBE_ATR_DST_IPV6_OFFSET
+ 7] = dst_addr_3
>> 24;
1752 input
->byte_stream
[IXGBE_ATR_DST_IPV6_OFFSET
+ 8] = dst_addr_2
& 0xff;
1753 input
->byte_stream
[IXGBE_ATR_DST_IPV6_OFFSET
+ 9] =
1754 (dst_addr_2
>> 8) & 0xff;
1755 input
->byte_stream
[IXGBE_ATR_DST_IPV6_OFFSET
+ 10] =
1756 (dst_addr_2
>> 16) & 0xff;
1757 input
->byte_stream
[IXGBE_ATR_DST_IPV6_OFFSET
+ 11] = dst_addr_2
>> 24;
1759 input
->byte_stream
[IXGBE_ATR_DST_IPV6_OFFSET
+ 12] = dst_addr_1
& 0xff;
1760 input
->byte_stream
[IXGBE_ATR_DST_IPV6_OFFSET
+ 13] =
1761 (dst_addr_1
>> 8) & 0xff;
1762 input
->byte_stream
[IXGBE_ATR_DST_IPV6_OFFSET
+ 14] =
1763 (dst_addr_1
>> 16) & 0xff;
1764 input
->byte_stream
[IXGBE_ATR_DST_IPV6_OFFSET
+ 15] = dst_addr_1
>> 24;
1770 * ixgbe_atr_set_src_port_82599 - Sets the source port
1771 * @input: input stream to modify
1772 * @src_port: the source port to load
1774 s32
ixgbe_atr_set_src_port_82599(struct ixgbe_atr_input
*input
, u16 src_port
)
1776 input
->byte_stream
[IXGBE_ATR_SRC_PORT_OFFSET
+ 1] = src_port
>> 8;
1777 input
->byte_stream
[IXGBE_ATR_SRC_PORT_OFFSET
] = src_port
& 0xff;
1783 * ixgbe_atr_set_dst_port_82599 - Sets the destination port
1784 * @input: input stream to modify
1785 * @dst_port: the destination port to load
1787 s32
ixgbe_atr_set_dst_port_82599(struct ixgbe_atr_input
*input
, u16 dst_port
)
1789 input
->byte_stream
[IXGBE_ATR_DST_PORT_OFFSET
+ 1] = dst_port
>> 8;
1790 input
->byte_stream
[IXGBE_ATR_DST_PORT_OFFSET
] = dst_port
& 0xff;
1796 * ixgbe_atr_set_flex_byte_82599 - Sets the flexible bytes
1797 * @input: input stream to modify
1798 * @flex_bytes: the flexible bytes to load
1800 s32
ixgbe_atr_set_flex_byte_82599(struct ixgbe_atr_input
*input
, u16 flex_byte
)
1802 input
->byte_stream
[IXGBE_ATR_FLEX_BYTE_OFFSET
+ 1] = flex_byte
>> 8;
1803 input
->byte_stream
[IXGBE_ATR_FLEX_BYTE_OFFSET
] = flex_byte
& 0xff;
1809 * ixgbe_atr_set_vm_pool_82599 - Sets the Virtual Machine pool
1810 * @input: input stream to modify
1811 * @vm_pool: the Virtual Machine pool to load
1813 s32
ixgbe_atr_set_vm_pool_82599(struct ixgbe_atr_input
*input
,
1816 input
->byte_stream
[IXGBE_ATR_VM_POOL_OFFSET
] = vm_pool
;
1822 * ixgbe_atr_set_l4type_82599 - Sets the layer 4 packet type
1823 * @input: input stream to modify
1824 * @l4type: the layer 4 type value to load
1826 s32
ixgbe_atr_set_l4type_82599(struct ixgbe_atr_input
*input
, u8 l4type
)
1828 input
->byte_stream
[IXGBE_ATR_L4TYPE_OFFSET
] = l4type
;
1834 * ixgbe_atr_get_vlan_id_82599 - Gets the VLAN id from the ATR input stream
1835 * @input: input stream to search
1836 * @vlan: the VLAN id to load
1838 static s32
ixgbe_atr_get_vlan_id_82599(struct ixgbe_atr_input
*input
, u16
*vlan
)
1840 *vlan
= input
->byte_stream
[IXGBE_ATR_VLAN_OFFSET
];
1841 *vlan
|= input
->byte_stream
[IXGBE_ATR_VLAN_OFFSET
+ 1] << 8;
1847 * ixgbe_atr_get_src_ipv4_82599 - Gets the source IPv4 address
1848 * @input: input stream to search
1849 * @src_addr: the IP address to load
1851 static s32
ixgbe_atr_get_src_ipv4_82599(struct ixgbe_atr_input
*input
,
1854 *src_addr
= input
->byte_stream
[IXGBE_ATR_SRC_IPV4_OFFSET
];
1855 *src_addr
|= input
->byte_stream
[IXGBE_ATR_SRC_IPV4_OFFSET
+ 1] << 8;
1856 *src_addr
|= input
->byte_stream
[IXGBE_ATR_SRC_IPV4_OFFSET
+ 2] << 16;
1857 *src_addr
|= input
->byte_stream
[IXGBE_ATR_SRC_IPV4_OFFSET
+ 3] << 24;
1863 * ixgbe_atr_get_dst_ipv4_82599 - Gets the destination IPv4 address
1864 * @input: input stream to search
1865 * @dst_addr: the IP address to load
1867 static s32
ixgbe_atr_get_dst_ipv4_82599(struct ixgbe_atr_input
*input
,
1870 *dst_addr
= input
->byte_stream
[IXGBE_ATR_DST_IPV4_OFFSET
];
1871 *dst_addr
|= input
->byte_stream
[IXGBE_ATR_DST_IPV4_OFFSET
+ 1] << 8;
1872 *dst_addr
|= input
->byte_stream
[IXGBE_ATR_DST_IPV4_OFFSET
+ 2] << 16;
1873 *dst_addr
|= input
->byte_stream
[IXGBE_ATR_DST_IPV4_OFFSET
+ 3] << 24;
1879 * ixgbe_atr_get_src_ipv6_82599 - Gets the source IPv6 address
1880 * @input: input stream to search
1881 * @src_addr_1: the first 4 bytes of the IP address to load
1882 * @src_addr_2: the second 4 bytes of the IP address to load
1883 * @src_addr_3: the third 4 bytes of the IP address to load
1884 * @src_addr_4: the fourth 4 bytes of the IP address to load
1886 static s32
ixgbe_atr_get_src_ipv6_82599(struct ixgbe_atr_input
*input
,
1887 u32
*src_addr_1
, u32
*src_addr_2
,
1888 u32
*src_addr_3
, u32
*src_addr_4
)
1890 *src_addr_1
= input
->byte_stream
[IXGBE_ATR_SRC_IPV6_OFFSET
+ 12];
1891 *src_addr_1
= input
->byte_stream
[IXGBE_ATR_SRC_IPV6_OFFSET
+ 13] << 8;
1892 *src_addr_1
= input
->byte_stream
[IXGBE_ATR_SRC_IPV6_OFFSET
+ 14] << 16;
1893 *src_addr_1
= input
->byte_stream
[IXGBE_ATR_SRC_IPV6_OFFSET
+ 15] << 24;
1895 *src_addr_2
= input
->byte_stream
[IXGBE_ATR_SRC_IPV6_OFFSET
+ 8];
1896 *src_addr_2
= input
->byte_stream
[IXGBE_ATR_SRC_IPV6_OFFSET
+ 9] << 8;
1897 *src_addr_2
= input
->byte_stream
[IXGBE_ATR_SRC_IPV6_OFFSET
+ 10] << 16;
1898 *src_addr_2
= input
->byte_stream
[IXGBE_ATR_SRC_IPV6_OFFSET
+ 11] << 24;
1900 *src_addr_3
= input
->byte_stream
[IXGBE_ATR_SRC_IPV6_OFFSET
+ 4];
1901 *src_addr_3
= input
->byte_stream
[IXGBE_ATR_SRC_IPV6_OFFSET
+ 5] << 8;
1902 *src_addr_3
= input
->byte_stream
[IXGBE_ATR_SRC_IPV6_OFFSET
+ 6] << 16;
1903 *src_addr_3
= input
->byte_stream
[IXGBE_ATR_SRC_IPV6_OFFSET
+ 7] << 24;
1905 *src_addr_4
= input
->byte_stream
[IXGBE_ATR_SRC_IPV6_OFFSET
];
1906 *src_addr_4
= input
->byte_stream
[IXGBE_ATR_SRC_IPV6_OFFSET
+ 1] << 8;
1907 *src_addr_4
= input
->byte_stream
[IXGBE_ATR_SRC_IPV6_OFFSET
+ 2] << 16;
1908 *src_addr_4
= input
->byte_stream
[IXGBE_ATR_SRC_IPV6_OFFSET
+ 3] << 24;
1914 * ixgbe_atr_get_dst_ipv6_82599 - Gets the destination IPv6 address
1915 * @input: input stream to search
1916 * @dst_addr_1: the first 4 bytes of the IP address to load
1917 * @dst_addr_2: the second 4 bytes of the IP address to load
1918 * @dst_addr_3: the third 4 bytes of the IP address to load
1919 * @dst_addr_4: the fourth 4 bytes of the IP address to load
1921 s32
ixgbe_atr_get_dst_ipv6_82599(struct ixgbe_atr_input
*input
,
1922 u32
*dst_addr_1
, u32
*dst_addr_2
,
1923 u32
*dst_addr_3
, u32
*dst_addr_4
)
1925 *dst_addr_1
= input
->byte_stream
[IXGBE_ATR_DST_IPV6_OFFSET
+ 12];
1926 *dst_addr_1
= input
->byte_stream
[IXGBE_ATR_DST_IPV6_OFFSET
+ 13] << 8;
1927 *dst_addr_1
= input
->byte_stream
[IXGBE_ATR_DST_IPV6_OFFSET
+ 14] << 16;
1928 *dst_addr_1
= input
->byte_stream
[IXGBE_ATR_DST_IPV6_OFFSET
+ 15] << 24;
1930 *dst_addr_2
= input
->byte_stream
[IXGBE_ATR_DST_IPV6_OFFSET
+ 8];
1931 *dst_addr_2
= input
->byte_stream
[IXGBE_ATR_DST_IPV6_OFFSET
+ 9] << 8;
1932 *dst_addr_2
= input
->byte_stream
[IXGBE_ATR_DST_IPV6_OFFSET
+ 10] << 16;
1933 *dst_addr_2
= input
->byte_stream
[IXGBE_ATR_DST_IPV6_OFFSET
+ 11] << 24;
1935 *dst_addr_3
= input
->byte_stream
[IXGBE_ATR_DST_IPV6_OFFSET
+ 4];
1936 *dst_addr_3
= input
->byte_stream
[IXGBE_ATR_DST_IPV6_OFFSET
+ 5] << 8;
1937 *dst_addr_3
= input
->byte_stream
[IXGBE_ATR_DST_IPV6_OFFSET
+ 6] << 16;
1938 *dst_addr_3
= input
->byte_stream
[IXGBE_ATR_DST_IPV6_OFFSET
+ 7] << 24;
1940 *dst_addr_4
= input
->byte_stream
[IXGBE_ATR_DST_IPV6_OFFSET
];
1941 *dst_addr_4
= input
->byte_stream
[IXGBE_ATR_DST_IPV6_OFFSET
+ 1] << 8;
1942 *dst_addr_4
= input
->byte_stream
[IXGBE_ATR_DST_IPV6_OFFSET
+ 2] << 16;
1943 *dst_addr_4
= input
->byte_stream
[IXGBE_ATR_DST_IPV6_OFFSET
+ 3] << 24;
1949 * ixgbe_atr_get_src_port_82599 - Gets the source port
1950 * @input: input stream to modify
1951 * @src_port: the source port to load
1953 * Even though the input is given in big-endian, the FDIRPORT registers
1954 * expect the ports to be programmed in little-endian. Hence the need to swap
1955 * endianness when retrieving the data. This can be confusing since the
1956 * internal hash engine expects it to be big-endian.
1958 static s32
ixgbe_atr_get_src_port_82599(struct ixgbe_atr_input
*input
,
1961 *src_port
= input
->byte_stream
[IXGBE_ATR_SRC_PORT_OFFSET
] << 8;
1962 *src_port
|= input
->byte_stream
[IXGBE_ATR_SRC_PORT_OFFSET
+ 1];
1968 * ixgbe_atr_get_dst_port_82599 - Gets the destination port
1969 * @input: input stream to modify
1970 * @dst_port: the destination port to load
1972 * Even though the input is given in big-endian, the FDIRPORT registers
1973 * expect the ports to be programmed in little-endian. Hence the need to swap
1974 * endianness when retrieving the data. This can be confusing since the
1975 * internal hash engine expects it to be big-endian.
1977 static s32
ixgbe_atr_get_dst_port_82599(struct ixgbe_atr_input
*input
,
1980 *dst_port
= input
->byte_stream
[IXGBE_ATR_DST_PORT_OFFSET
] << 8;
1981 *dst_port
|= input
->byte_stream
[IXGBE_ATR_DST_PORT_OFFSET
+ 1];
1987 * ixgbe_atr_get_flex_byte_82599 - Gets the flexible bytes
1988 * @input: input stream to modify
1989 * @flex_bytes: the flexible bytes to load
1991 static s32
ixgbe_atr_get_flex_byte_82599(struct ixgbe_atr_input
*input
,
1994 *flex_byte
= input
->byte_stream
[IXGBE_ATR_FLEX_BYTE_OFFSET
];
1995 *flex_byte
|= input
->byte_stream
[IXGBE_ATR_FLEX_BYTE_OFFSET
+ 1] << 8;
2001 * ixgbe_atr_get_vm_pool_82599 - Gets the Virtual Machine pool
2002 * @input: input stream to modify
2003 * @vm_pool: the Virtual Machine pool to load
2005 s32
ixgbe_atr_get_vm_pool_82599(struct ixgbe_atr_input
*input
,
2008 *vm_pool
= input
->byte_stream
[IXGBE_ATR_VM_POOL_OFFSET
];
2014 * ixgbe_atr_get_l4type_82599 - Gets the layer 4 packet type
2015 * @input: input stream to modify
2016 * @l4type: the layer 4 type value to load
2018 static s32
ixgbe_atr_get_l4type_82599(struct ixgbe_atr_input
*input
,
2021 *l4type
= input
->byte_stream
[IXGBE_ATR_L4TYPE_OFFSET
];
2027 * ixgbe_atr_add_signature_filter_82599 - Adds a signature hash filter
2028 * @hw: pointer to hardware structure
2029 * @stream: input bitstream
2030 * @queue: queue index to direct traffic to
2032 s32
ixgbe_fdir_add_signature_filter_82599(struct ixgbe_hw
*hw
,
2033 struct ixgbe_atr_input
*input
,
2039 u16 bucket_hash
, sig_hash
;
2042 bucket_hash
= ixgbe_atr_compute_hash_82599(input
,
2043 IXGBE_ATR_BUCKET_HASH_KEY
);
2045 /* bucket_hash is only 15 bits */
2046 bucket_hash
&= IXGBE_ATR_HASH_MASK
;
2048 sig_hash
= ixgbe_atr_compute_hash_82599(input
,
2049 IXGBE_ATR_SIGNATURE_HASH_KEY
);
2051 /* Get the l4type in order to program FDIRCMD properly */
2052 /* lowest 2 bits are FDIRCMD.L4TYPE, third lowest bit is FDIRCMD.IPV6 */
2053 ixgbe_atr_get_l4type_82599(input
, &l4type
);
2056 * The lower 32-bits of fdirhashcmd is for FDIRHASH, the upper 32-bits
2057 * is for FDIRCMD. Then do a 64-bit register write from FDIRHASH.
2059 fdirhash
= sig_hash
<< IXGBE_FDIRHASH_SIG_SW_INDEX_SHIFT
| bucket_hash
;
2061 fdircmd
= (IXGBE_FDIRCMD_CMD_ADD_FLOW
| IXGBE_FDIRCMD_FILTER_UPDATE
|
2062 IXGBE_FDIRCMD_LAST
| IXGBE_FDIRCMD_QUEUE_EN
);
2064 switch (l4type
& IXGBE_ATR_L4TYPE_MASK
) {
2065 case IXGBE_ATR_L4TYPE_TCP
:
2066 fdircmd
|= IXGBE_FDIRCMD_L4TYPE_TCP
;
2068 case IXGBE_ATR_L4TYPE_UDP
:
2069 fdircmd
|= IXGBE_FDIRCMD_L4TYPE_UDP
;
2071 case IXGBE_ATR_L4TYPE_SCTP
:
2072 fdircmd
|= IXGBE_FDIRCMD_L4TYPE_SCTP
;
2075 hw_dbg(hw
, "Error on l4type input\n");
2076 return IXGBE_ERR_CONFIG
;
2079 if (l4type
& IXGBE_ATR_L4TYPE_IPV6_MASK
)
2080 fdircmd
|= IXGBE_FDIRCMD_IPV6
;
2082 fdircmd
|= ((u64
)queue
<< IXGBE_FDIRCMD_RX_QUEUE_SHIFT
);
2083 fdirhashcmd
= ((fdircmd
<< 32) | fdirhash
);
2085 IXGBE_WRITE_REG64(hw
, IXGBE_FDIRHASH
, fdirhashcmd
);
2091 * ixgbe_fdir_add_perfect_filter_82599 - Adds a perfect filter
2092 * @hw: pointer to hardware structure
2093 * @input: input bitstream
2094 * @input_masks: bitwise masks for relevant fields
2095 * @soft_id: software index into the silicon hash tables for filter storage
2096 * @queue: queue index to direct traffic to
2098 * Note that the caller to this function must lock before calling, since the
2099 * hardware writes must be protected from one another.
2101 s32
ixgbe_fdir_add_perfect_filter_82599(struct ixgbe_hw
*hw
,
2102 struct ixgbe_atr_input
*input
,
2103 struct ixgbe_atr_input_masks
*input_masks
,
2104 u16 soft_id
, u8 queue
)
2108 u32 src_ipv4
= 0, dst_ipv4
= 0;
2109 u32 src_ipv6_1
, src_ipv6_2
, src_ipv6_3
, src_ipv6_4
;
2110 u16 src_port
, dst_port
, vlan_id
, flex_bytes
;
2115 /* Get our input values */
2116 ixgbe_atr_get_l4type_82599(input
, &l4type
);
2119 * Check l4type formatting, and bail out before we touch the hardware
2120 * if there's a configuration issue
2122 switch (l4type
& IXGBE_ATR_L4TYPE_MASK
) {
2123 case IXGBE_ATR_L4TYPE_TCP
:
2124 fdircmd
|= IXGBE_FDIRCMD_L4TYPE_TCP
;
2126 case IXGBE_ATR_L4TYPE_UDP
:
2127 fdircmd
|= IXGBE_FDIRCMD_L4TYPE_UDP
;
2129 case IXGBE_ATR_L4TYPE_SCTP
:
2130 fdircmd
|= IXGBE_FDIRCMD_L4TYPE_SCTP
;
2133 hw_dbg(hw
, "Error on l4type input\n");
2134 return IXGBE_ERR_CONFIG
;
2137 bucket_hash
= ixgbe_atr_compute_hash_82599(input
,
2138 IXGBE_ATR_BUCKET_HASH_KEY
);
2140 /* bucket_hash is only 15 bits */
2141 bucket_hash
&= IXGBE_ATR_HASH_MASK
;
2143 ixgbe_atr_get_vlan_id_82599(input
, &vlan_id
);
2144 ixgbe_atr_get_src_port_82599(input
, &src_port
);
2145 ixgbe_atr_get_dst_port_82599(input
, &dst_port
);
2146 ixgbe_atr_get_flex_byte_82599(input
, &flex_bytes
);
2148 fdirhash
= soft_id
<< IXGBE_FDIRHASH_SIG_SW_INDEX_SHIFT
| bucket_hash
;
2150 /* Now figure out if we're IPv4 or IPv6 */
2151 if (l4type
& IXGBE_ATR_L4TYPE_IPV6_MASK
) {
2153 ixgbe_atr_get_src_ipv6_82599(input
, &src_ipv6_1
, &src_ipv6_2
,
2154 &src_ipv6_3
, &src_ipv6_4
);
2156 IXGBE_WRITE_REG(hw
, IXGBE_FDIRSIPv6(0), src_ipv6_1
);
2157 IXGBE_WRITE_REG(hw
, IXGBE_FDIRSIPv6(1), src_ipv6_2
);
2158 IXGBE_WRITE_REG(hw
, IXGBE_FDIRSIPv6(2), src_ipv6_3
);
2159 /* The last 4 bytes is the same register as IPv4 */
2160 IXGBE_WRITE_REG(hw
, IXGBE_FDIRIPSA
, src_ipv6_4
);
2162 fdircmd
|= IXGBE_FDIRCMD_IPV6
;
2163 fdircmd
|= IXGBE_FDIRCMD_IPv6DMATCH
;
2166 ixgbe_atr_get_src_ipv4_82599(input
, &src_ipv4
);
2167 IXGBE_WRITE_REG(hw
, IXGBE_FDIRIPSA
, src_ipv4
);
2170 ixgbe_atr_get_dst_ipv4_82599(input
, &dst_ipv4
);
2171 IXGBE_WRITE_REG(hw
, IXGBE_FDIRIPDA
, dst_ipv4
);
2173 IXGBE_WRITE_REG(hw
, IXGBE_FDIRVLAN
, (vlan_id
|
2174 (flex_bytes
<< IXGBE_FDIRVLAN_FLEX_SHIFT
)));
2175 IXGBE_WRITE_REG(hw
, IXGBE_FDIRPORT
, (src_port
|
2176 (dst_port
<< IXGBE_FDIRPORT_DESTINATION_SHIFT
)));
2179 * Program the relevant mask registers. If src/dst_port or src/dst_addr
2180 * are zero, then assume a full mask for that field. Also assume that
2181 * a VLAN of 0 is unspecified, so mask that out as well. L4type
2182 * cannot be masked out in this implementation.
2184 * This also assumes IPv4 only. IPv6 masking isn't supported at this
2188 IXGBE_WRITE_REG(hw
, IXGBE_FDIRSIP4M
, 0xffffffff);
2190 IXGBE_WRITE_REG(hw
, IXGBE_FDIRSIP4M
, input_masks
->src_ip_mask
);
2193 IXGBE_WRITE_REG(hw
, IXGBE_FDIRDIP4M
, 0xffffffff);
2195 IXGBE_WRITE_REG(hw
, IXGBE_FDIRDIP4M
, input_masks
->dst_ip_mask
);
2197 switch (l4type
& IXGBE_ATR_L4TYPE_MASK
) {
2198 case IXGBE_ATR_L4TYPE_TCP
:
2200 IXGBE_WRITE_REG(hw
, IXGBE_FDIRTCPM
, 0xffff);
2202 IXGBE_WRITE_REG(hw
, IXGBE_FDIRTCPM
,
2203 input_masks
->src_port_mask
);
2206 IXGBE_WRITE_REG(hw
, IXGBE_FDIRTCPM
,
2207 (IXGBE_READ_REG(hw
, IXGBE_FDIRTCPM
) |
2210 IXGBE_WRITE_REG(hw
, IXGBE_FDIRTCPM
,
2211 (IXGBE_READ_REG(hw
, IXGBE_FDIRTCPM
) |
2212 (input_masks
->dst_port_mask
<< 16)));
2214 case IXGBE_ATR_L4TYPE_UDP
:
2216 IXGBE_WRITE_REG(hw
, IXGBE_FDIRUDPM
, 0xffff);
2218 IXGBE_WRITE_REG(hw
, IXGBE_FDIRUDPM
,
2219 input_masks
->src_port_mask
);
2222 IXGBE_WRITE_REG(hw
, IXGBE_FDIRUDPM
,
2223 (IXGBE_READ_REG(hw
, IXGBE_FDIRUDPM
) |
2226 IXGBE_WRITE_REG(hw
, IXGBE_FDIRUDPM
,
2227 (IXGBE_READ_REG(hw
, IXGBE_FDIRUDPM
) |
2228 (input_masks
->src_port_mask
<< 16)));
2231 /* this already would have failed above */
2235 /* Program the last mask register, FDIRM */
2236 if (input_masks
->vlan_id_mask
|| !vlan_id
)
2237 /* Mask both VLAN and VLANP - bits 0 and 1 */
2240 if (input_masks
->data_mask
|| !flex_bytes
)
2241 /* Flex bytes need masking, so mask the whole thing - bit 4 */
2244 /* Now mask VM pool and destination IPv6 - bits 5 and 2 */
2247 IXGBE_WRITE_REG(hw
, IXGBE_FDIRM
, fdirm
);
2249 fdircmd
|= IXGBE_FDIRCMD_CMD_ADD_FLOW
;
2250 fdircmd
|= IXGBE_FDIRCMD_FILTER_UPDATE
;
2251 fdircmd
|= IXGBE_FDIRCMD_LAST
;
2252 fdircmd
|= IXGBE_FDIRCMD_QUEUE_EN
;
2253 fdircmd
|= queue
<< IXGBE_FDIRCMD_RX_QUEUE_SHIFT
;
2255 IXGBE_WRITE_REG(hw
, IXGBE_FDIRHASH
, fdirhash
);
2256 IXGBE_WRITE_REG(hw
, IXGBE_FDIRCMD
, fdircmd
);
2261 * ixgbe_read_analog_reg8_82599 - Reads 8 bit Omer analog register
2262 * @hw: pointer to hardware structure
2263 * @reg: analog register to read
2266 * Performs read operation to Omer analog register specified.
2268 static s32
ixgbe_read_analog_reg8_82599(struct ixgbe_hw
*hw
, u32 reg
, u8
*val
)
2272 IXGBE_WRITE_REG(hw
, IXGBE_CORECTL
, IXGBE_CORECTL_WRITE_CMD
|
2274 IXGBE_WRITE_FLUSH(hw
);
2276 core_ctl
= IXGBE_READ_REG(hw
, IXGBE_CORECTL
);
2277 *val
= (u8
)core_ctl
;
2283 * ixgbe_write_analog_reg8_82599 - Writes 8 bit Omer analog register
2284 * @hw: pointer to hardware structure
2285 * @reg: atlas register to write
2286 * @val: value to write
2288 * Performs write operation to Omer analog register specified.
2290 static s32
ixgbe_write_analog_reg8_82599(struct ixgbe_hw
*hw
, u32 reg
, u8 val
)
2294 core_ctl
= (reg
<< 8) | val
;
2295 IXGBE_WRITE_REG(hw
, IXGBE_CORECTL
, core_ctl
);
2296 IXGBE_WRITE_FLUSH(hw
);
2303 * ixgbe_start_hw_82599 - Prepare hardware for Tx/Rx
2304 * @hw: pointer to hardware structure
2306 * Starts the hardware using the generic start_hw function.
2307 * Then performs device-specific:
2308 * Clears the rate limiter registers.
2310 static s32
ixgbe_start_hw_82599(struct ixgbe_hw
*hw
)
2315 ret_val
= ixgbe_start_hw_generic(hw
);
2317 /* Clear the rate limiters */
2318 for (q_num
= 0; q_num
< hw
->mac
.max_tx_queues
; q_num
++) {
2319 IXGBE_WRITE_REG(hw
, IXGBE_RTTDQSEL
, q_num
);
2320 IXGBE_WRITE_REG(hw
, IXGBE_RTTBCNRC
, 0);
2322 IXGBE_WRITE_FLUSH(hw
);
2324 /* We need to run link autotry after the driver loads */
2325 hw
->mac
.autotry_restart
= true;
2328 ret_val
= ixgbe_verify_fw_version_82599(hw
);
2334 * ixgbe_identify_phy_82599 - Get physical layer module
2335 * @hw: pointer to hardware structure
2337 * Determines the physical layer module found on the current adapter.
2339 static s32
ixgbe_identify_phy_82599(struct ixgbe_hw
*hw
)
2341 s32 status
= IXGBE_ERR_PHY_ADDR_INVALID
;
2342 status
= ixgbe_identify_phy_generic(hw
);
2344 status
= ixgbe_identify_sfp_module_generic(hw
);
2349 * ixgbe_get_supported_physical_layer_82599 - Returns physical layer type
2350 * @hw: pointer to hardware structure
2352 * Determines physical layer capabilities of the current configuration.
2354 static u32
ixgbe_get_supported_physical_layer_82599(struct ixgbe_hw
*hw
)
2356 u32 physical_layer
= IXGBE_PHYSICAL_LAYER_UNKNOWN
;
2357 u32 autoc
= IXGBE_READ_REG(hw
, IXGBE_AUTOC
);
2358 u32 autoc2
= IXGBE_READ_REG(hw
, IXGBE_AUTOC2
);
2359 u32 pma_pmd_10g_serial
= autoc2
& IXGBE_AUTOC2_10G_SERIAL_PMA_PMD_MASK
;
2360 u32 pma_pmd_10g_parallel
= autoc
& IXGBE_AUTOC_10G_PMA_PMD_MASK
;
2361 u32 pma_pmd_1g
= autoc
& IXGBE_AUTOC_1G_PMA_PMD_MASK
;
2362 u16 ext_ability
= 0;
2363 u8 comp_codes_10g
= 0;
2365 hw
->phy
.ops
.identify(hw
);
2367 if (hw
->phy
.type
== ixgbe_phy_tn
||
2368 hw
->phy
.type
== ixgbe_phy_cu_unknown
) {
2369 hw
->phy
.ops
.read_reg(hw
, MDIO_PMA_EXTABLE
, MDIO_MMD_PMAPMD
,
2371 if (ext_ability
& MDIO_PMA_EXTABLE_10GBT
)
2372 physical_layer
|= IXGBE_PHYSICAL_LAYER_10GBASE_T
;
2373 if (ext_ability
& MDIO_PMA_EXTABLE_1000BT
)
2374 physical_layer
|= IXGBE_PHYSICAL_LAYER_1000BASE_T
;
2375 if (ext_ability
& MDIO_PMA_EXTABLE_100BTX
)
2376 physical_layer
|= IXGBE_PHYSICAL_LAYER_100BASE_TX
;
2380 switch (autoc
& IXGBE_AUTOC_LMS_MASK
) {
2381 case IXGBE_AUTOC_LMS_1G_AN
:
2382 case IXGBE_AUTOC_LMS_1G_LINK_NO_AN
:
2383 if (pma_pmd_1g
== IXGBE_AUTOC_1G_KX_BX
) {
2384 physical_layer
= IXGBE_PHYSICAL_LAYER_1000BASE_KX
|
2385 IXGBE_PHYSICAL_LAYER_1000BASE_BX
;
2388 /* SFI mode so read SFP module */
2391 case IXGBE_AUTOC_LMS_10G_LINK_NO_AN
:
2392 if (pma_pmd_10g_parallel
== IXGBE_AUTOC_10G_CX4
)
2393 physical_layer
= IXGBE_PHYSICAL_LAYER_10GBASE_CX4
;
2394 else if (pma_pmd_10g_parallel
== IXGBE_AUTOC_10G_KX4
)
2395 physical_layer
= IXGBE_PHYSICAL_LAYER_10GBASE_KX4
;
2396 else if (pma_pmd_10g_parallel
== IXGBE_AUTOC_10G_XAUI
)
2397 physical_layer
= IXGBE_PHYSICAL_LAYER_10GBASE_XAUI
;
2400 case IXGBE_AUTOC_LMS_10G_SERIAL
:
2401 if (pma_pmd_10g_serial
== IXGBE_AUTOC2_10G_KR
) {
2402 physical_layer
= IXGBE_PHYSICAL_LAYER_10GBASE_KR
;
2404 } else if (pma_pmd_10g_serial
== IXGBE_AUTOC2_10G_SFI
)
2407 case IXGBE_AUTOC_LMS_KX4_KX_KR
:
2408 case IXGBE_AUTOC_LMS_KX4_KX_KR_1G_AN
:
2409 if (autoc
& IXGBE_AUTOC_KX_SUPP
)
2410 physical_layer
|= IXGBE_PHYSICAL_LAYER_1000BASE_KX
;
2411 if (autoc
& IXGBE_AUTOC_KX4_SUPP
)
2412 physical_layer
|= IXGBE_PHYSICAL_LAYER_10GBASE_KX4
;
2413 if (autoc
& IXGBE_AUTOC_KR_SUPP
)
2414 physical_layer
|= IXGBE_PHYSICAL_LAYER_10GBASE_KR
;
2423 /* SFP check must be done last since DA modules are sometimes used to
2424 * test KR mode - we need to id KR mode correctly before SFP module.
2425 * Call identify_sfp because the pluggable module may have changed */
2426 hw
->phy
.ops
.identify_sfp(hw
);
2427 if (hw
->phy
.sfp_type
== ixgbe_sfp_type_not_present
)
2430 switch (hw
->phy
.type
) {
2431 case ixgbe_phy_tw_tyco
:
2432 case ixgbe_phy_tw_unknown
:
2433 physical_layer
= IXGBE_PHYSICAL_LAYER_SFP_PLUS_CU
;
2435 case ixgbe_phy_sfp_avago
:
2436 case ixgbe_phy_sfp_ftl
:
2437 case ixgbe_phy_sfp_intel
:
2438 case ixgbe_phy_sfp_unknown
:
2439 hw
->phy
.ops
.read_i2c_eeprom(hw
,
2440 IXGBE_SFF_10GBE_COMP_CODES
, &comp_codes_10g
);
2441 if (comp_codes_10g
& IXGBE_SFF_10GBASESR_CAPABLE
)
2442 physical_layer
= IXGBE_PHYSICAL_LAYER_10GBASE_SR
;
2443 else if (comp_codes_10g
& IXGBE_SFF_10GBASELR_CAPABLE
)
2444 physical_layer
= IXGBE_PHYSICAL_LAYER_10GBASE_LR
;
2451 return physical_layer
;
2455 * ixgbe_enable_rx_dma_82599 - Enable the Rx DMA unit on 82599
2456 * @hw: pointer to hardware structure
2457 * @regval: register value to write to RXCTRL
2459 * Enables the Rx DMA unit for 82599
2461 static s32
ixgbe_enable_rx_dma_82599(struct ixgbe_hw
*hw
, u32 regval
)
2463 #define IXGBE_MAX_SECRX_POLL 30
2468 * Workaround for 82599 silicon errata when enabling the Rx datapath.
2469 * If traffic is incoming before we enable the Rx unit, it could hang
2470 * the Rx DMA unit. Therefore, make sure the security engine is
2471 * completely disabled prior to enabling the Rx unit.
2473 secrxreg
= IXGBE_READ_REG(hw
, IXGBE_SECRXCTRL
);
2474 secrxreg
|= IXGBE_SECRXCTRL_RX_DIS
;
2475 IXGBE_WRITE_REG(hw
, IXGBE_SECRXCTRL
, secrxreg
);
2476 for (i
= 0; i
< IXGBE_MAX_SECRX_POLL
; i
++) {
2477 secrxreg
= IXGBE_READ_REG(hw
, IXGBE_SECRXSTAT
);
2478 if (secrxreg
& IXGBE_SECRXSTAT_SECRX_RDY
)
2484 /* For informational purposes only */
2485 if (i
>= IXGBE_MAX_SECRX_POLL
)
2486 hw_dbg(hw
, "Rx unit being enabled before security "
2487 "path fully disabled. Continuing with init.\n");
2489 IXGBE_WRITE_REG(hw
, IXGBE_RXCTRL
, regval
);
2490 secrxreg
= IXGBE_READ_REG(hw
, IXGBE_SECRXCTRL
);
2491 secrxreg
&= ~IXGBE_SECRXCTRL_RX_DIS
;
2492 IXGBE_WRITE_REG(hw
, IXGBE_SECRXCTRL
, secrxreg
);
2493 IXGBE_WRITE_FLUSH(hw
);
2499 * ixgbe_get_device_caps_82599 - Get additional device capabilities
2500 * @hw: pointer to hardware structure
2501 * @device_caps: the EEPROM word with the extra device capabilities
2503 * This function will read the EEPROM location for the device capabilities,
2504 * and return the word through device_caps.
2506 static s32
ixgbe_get_device_caps_82599(struct ixgbe_hw
*hw
, u16
*device_caps
)
2508 hw
->eeprom
.ops
.read(hw
, IXGBE_DEVICE_CAPS
, device_caps
);
2514 * ixgbe_get_san_mac_addr_offset_82599 - SAN MAC address offset for 82599
2515 * @hw: pointer to hardware structure
2516 * @san_mac_offset: SAN MAC address offset
2518 * This function will read the EEPROM location for the SAN MAC address
2519 * pointer, and returns the value at that location. This is used in both
2520 * get and set mac_addr routines.
2522 static s32
ixgbe_get_san_mac_addr_offset_82599(struct ixgbe_hw
*hw
,
2523 u16
*san_mac_offset
)
2526 * First read the EEPROM pointer to see if the MAC addresses are
2529 hw
->eeprom
.ops
.read(hw
, IXGBE_SAN_MAC_ADDR_PTR
, san_mac_offset
);
2535 * ixgbe_get_san_mac_addr_82599 - SAN MAC address retrieval for 82599
2536 * @hw: pointer to hardware structure
2537 * @san_mac_addr: SAN MAC address
2539 * Reads the SAN MAC address from the EEPROM, if it's available. This is
2540 * per-port, so set_lan_id() must be called before reading the addresses.
2541 * set_lan_id() is called by identify_sfp(), but this cannot be relied
2542 * upon for non-SFP connections, so we must call it here.
2544 static s32
ixgbe_get_san_mac_addr_82599(struct ixgbe_hw
*hw
, u8
*san_mac_addr
)
2546 u16 san_mac_data
, san_mac_offset
;
2550 * First read the EEPROM pointer to see if the MAC addresses are
2551 * available. If they're not, no point in calling set_lan_id() here.
2553 ixgbe_get_san_mac_addr_offset_82599(hw
, &san_mac_offset
);
2555 if ((san_mac_offset
== 0) || (san_mac_offset
== 0xFFFF)) {
2557 * No addresses available in this EEPROM. It's not an
2558 * error though, so just wipe the local address and return.
2560 for (i
= 0; i
< 6; i
++)
2561 san_mac_addr
[i
] = 0xFF;
2563 goto san_mac_addr_out
;
2566 /* make sure we know which port we need to program */
2567 hw
->mac
.ops
.set_lan_id(hw
);
2568 /* apply the port offset to the address offset */
2569 (hw
->bus
.func
) ? (san_mac_offset
+= IXGBE_SAN_MAC_ADDR_PORT1_OFFSET
) :
2570 (san_mac_offset
+= IXGBE_SAN_MAC_ADDR_PORT0_OFFSET
);
2571 for (i
= 0; i
< 3; i
++) {
2572 hw
->eeprom
.ops
.read(hw
, san_mac_offset
, &san_mac_data
);
2573 san_mac_addr
[i
* 2] = (u8
)(san_mac_data
);
2574 san_mac_addr
[i
* 2 + 1] = (u8
)(san_mac_data
>> 8);
2583 * ixgbe_verify_fw_version_82599 - verify fw version for 82599
2584 * @hw: pointer to hardware structure
2586 * Verifies that installed the firmware version is 0.6 or higher
2587 * for SFI devices. All 82599 SFI devices should have version 0.6 or higher.
2589 * Returns IXGBE_ERR_EEPROM_VERSION if the FW is not present or
2590 * if the FW version is not supported.
2592 static s32
ixgbe_verify_fw_version_82599(struct ixgbe_hw
*hw
)
2594 s32 status
= IXGBE_ERR_EEPROM_VERSION
;
2595 u16 fw_offset
, fw_ptp_cfg_offset
;
2598 /* firmware check is only necessary for SFI devices */
2599 if (hw
->phy
.media_type
!= ixgbe_media_type_fiber
) {
2601 goto fw_version_out
;
2604 /* get the offset to the Firmware Module block */
2605 hw
->eeprom
.ops
.read(hw
, IXGBE_FW_PTR
, &fw_offset
);
2607 if ((fw_offset
== 0) || (fw_offset
== 0xFFFF))
2608 goto fw_version_out
;
2610 /* get the offset to the Pass Through Patch Configuration block */
2611 hw
->eeprom
.ops
.read(hw
, (fw_offset
+
2612 IXGBE_FW_PASSTHROUGH_PATCH_CONFIG_PTR
),
2613 &fw_ptp_cfg_offset
);
2615 if ((fw_ptp_cfg_offset
== 0) || (fw_ptp_cfg_offset
== 0xFFFF))
2616 goto fw_version_out
;
2618 /* get the firmware version */
2619 hw
->eeprom
.ops
.read(hw
, (fw_ptp_cfg_offset
+
2620 IXGBE_FW_PATCH_VERSION_4
),
2623 if (fw_version
> 0x5)
2631 * ixgbe_get_wwn_prefix_82599 - Get alternative WWNN/WWPN prefix from
2633 * @hw: pointer to hardware structure
2634 * @wwnn_prefix: the alternative WWNN prefix
2635 * @wwpn_prefix: the alternative WWPN prefix
2637 * This function will read the EEPROM from the alternative SAN MAC address
2638 * block to check the support for the alternative WWNN/WWPN prefix support.
2640 static s32
ixgbe_get_wwn_prefix_82599(struct ixgbe_hw
*hw
, u16
*wwnn_prefix
,
2644 u16 alt_san_mac_blk_offset
;
2646 /* clear output first */
2647 *wwnn_prefix
= 0xFFFF;
2648 *wwpn_prefix
= 0xFFFF;
2650 /* check if alternative SAN MAC is supported */
2651 hw
->eeprom
.ops
.read(hw
, IXGBE_ALT_SAN_MAC_ADDR_BLK_PTR
,
2652 &alt_san_mac_blk_offset
);
2654 if ((alt_san_mac_blk_offset
== 0) ||
2655 (alt_san_mac_blk_offset
== 0xFFFF))
2656 goto wwn_prefix_out
;
2658 /* check capability in alternative san mac address block */
2659 offset
= alt_san_mac_blk_offset
+ IXGBE_ALT_SAN_MAC_ADDR_CAPS_OFFSET
;
2660 hw
->eeprom
.ops
.read(hw
, offset
, &caps
);
2661 if (!(caps
& IXGBE_ALT_SAN_MAC_ADDR_CAPS_ALTWWN
))
2662 goto wwn_prefix_out
;
2664 /* get the corresponding prefix for WWNN/WWPN */
2665 offset
= alt_san_mac_blk_offset
+ IXGBE_ALT_SAN_MAC_ADDR_WWNN_OFFSET
;
2666 hw
->eeprom
.ops
.read(hw
, offset
, wwnn_prefix
);
2668 offset
= alt_san_mac_blk_offset
+ IXGBE_ALT_SAN_MAC_ADDR_WWPN_OFFSET
;
2669 hw
->eeprom
.ops
.read(hw
, offset
, wwpn_prefix
);
2675 static struct ixgbe_mac_operations mac_ops_82599
= {
2676 .init_hw
= &ixgbe_init_hw_generic
,
2677 .reset_hw
= &ixgbe_reset_hw_82599
,
2678 .start_hw
= &ixgbe_start_hw_82599
,
2679 .clear_hw_cntrs
= &ixgbe_clear_hw_cntrs_generic
,
2680 .get_media_type
= &ixgbe_get_media_type_82599
,
2681 .get_supported_physical_layer
= &ixgbe_get_supported_physical_layer_82599
,
2682 .enable_rx_dma
= &ixgbe_enable_rx_dma_82599
,
2683 .get_mac_addr
= &ixgbe_get_mac_addr_generic
,
2684 .get_san_mac_addr
= &ixgbe_get_san_mac_addr_82599
,
2685 .get_device_caps
= &ixgbe_get_device_caps_82599
,
2686 .get_wwn_prefix
= &ixgbe_get_wwn_prefix_82599
,
2687 .stop_adapter
= &ixgbe_stop_adapter_generic
,
2688 .get_bus_info
= &ixgbe_get_bus_info_generic
,
2689 .set_lan_id
= &ixgbe_set_lan_id_multi_port_pcie
,
2690 .read_analog_reg8
= &ixgbe_read_analog_reg8_82599
,
2691 .write_analog_reg8
= &ixgbe_write_analog_reg8_82599
,
2692 .setup_link
= &ixgbe_setup_mac_link_82599
,
2693 .check_link
= &ixgbe_check_mac_link_82599
,
2694 .get_link_capabilities
= &ixgbe_get_link_capabilities_82599
,
2695 .led_on
= &ixgbe_led_on_generic
,
2696 .led_off
= &ixgbe_led_off_generic
,
2697 .blink_led_start
= &ixgbe_blink_led_start_generic
,
2698 .blink_led_stop
= &ixgbe_blink_led_stop_generic
,
2699 .set_rar
= &ixgbe_set_rar_generic
,
2700 .clear_rar
= &ixgbe_clear_rar_generic
,
2701 .set_vmdq
= &ixgbe_set_vmdq_82599
,
2702 .clear_vmdq
= &ixgbe_clear_vmdq_82599
,
2703 .init_rx_addrs
= &ixgbe_init_rx_addrs_generic
,
2704 .update_uc_addr_list
= &ixgbe_update_uc_addr_list_generic
,
2705 .update_mc_addr_list
= &ixgbe_update_mc_addr_list_generic
,
2706 .enable_mc
= &ixgbe_enable_mc_generic
,
2707 .disable_mc
= &ixgbe_disable_mc_generic
,
2708 .clear_vfta
= &ixgbe_clear_vfta_82599
,
2709 .set_vfta
= &ixgbe_set_vfta_82599
,
2710 .fc_enable
= &ixgbe_fc_enable_generic
,
2711 .init_uta_tables
= &ixgbe_init_uta_tables_82599
,
2712 .setup_sfp
= &ixgbe_setup_sfp_modules_82599
,
2715 static struct ixgbe_eeprom_operations eeprom_ops_82599
= {
2716 .init_params
= &ixgbe_init_eeprom_params_generic
,
2717 .read
= &ixgbe_read_eeprom_generic
,
2718 .write
= &ixgbe_write_eeprom_generic
,
2719 .validate_checksum
= &ixgbe_validate_eeprom_checksum_generic
,
2720 .update_checksum
= &ixgbe_update_eeprom_checksum_generic
,
2723 static struct ixgbe_phy_operations phy_ops_82599
= {
2724 .identify
= &ixgbe_identify_phy_82599
,
2725 .identify_sfp
= &ixgbe_identify_sfp_module_generic
,
2726 .init
= &ixgbe_init_phy_ops_82599
,
2727 .reset
= &ixgbe_reset_phy_generic
,
2728 .read_reg
= &ixgbe_read_phy_reg_generic
,
2729 .write_reg
= &ixgbe_write_phy_reg_generic
,
2730 .setup_link
= &ixgbe_setup_phy_link_generic
,
2731 .setup_link_speed
= &ixgbe_setup_phy_link_speed_generic
,
2732 .read_i2c_byte
= &ixgbe_read_i2c_byte_generic
,
2733 .write_i2c_byte
= &ixgbe_write_i2c_byte_generic
,
2734 .read_i2c_eeprom
= &ixgbe_read_i2c_eeprom_generic
,
2735 .write_i2c_eeprom
= &ixgbe_write_i2c_eeprom_generic
,
2738 struct ixgbe_info ixgbe_82599_info
= {
2739 .mac
= ixgbe_mac_82599EB
,
2740 .get_invariants
= &ixgbe_get_invariants_82599
,
2741 .mac_ops
= &mac_ops_82599
,
2742 .eeprom_ops
= &eeprom_ops_82599
,
2743 .phy_ops
= &phy_ops_82599
,
2744 .mbx_ops
= &mbx_ops_82599
,