]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/dev/ixgb/ixgb_hw.c
Partial merge of the SPDX changes
[FreeBSD/FreeBSD.git] / sys / dev / ixgb / ixgb_hw.c
1 /*******************************************************************************
2   SPDX-License-Identifier: BSD-3-Clause
3
4   Copyright (c) 2001-2004, Intel Corporation
5   All rights reserved.
6   
7   Redistribution and use in source and binary forms, with or without
8   modification, are permitted provided that the following conditions are met:
9   
10    1. Redistributions of source code must retain the above copyright notice,
11       this list of conditions and the following disclaimer.
12   
13    2. Redistributions in binary form must reproduce the above copyright
14       notice, this list of conditions and the following disclaimer in the
15       documentation and/or other materials provided with the distribution.
16   
17    3. Neither the name of the Intel Corporation nor the names of its
18       contributors may be used to endorse or promote products derived from
19       this software without specific prior written permission.
20   
21   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24   ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31   POSSIBILITY OF SUCH DAMAGE.
32
33 *******************************************************************************/
34
35 /*$FreeBSD$*/
36
37 /* ixgb_hw.c
38  * Shared functions for accessing and configuring the adapter
39  */
40
41 #include <dev/ixgb/ixgb_hw.h> 
42 #include <dev/ixgb/ixgb_ids.h> 
43
44 /*  Local function prototypes */
45
46 static uint32_t ixgb_hash_mc_addr(struct ixgb_hw *hw,
47                             uint8_t *mc_addr);
48
49 static void ixgb_mta_set(struct ixgb_hw *hw,
50                     uint32_t hash_value);
51
52 static void ixgb_get_bus_info(struct ixgb_hw *hw);
53
54 static boolean_t ixgb_link_reset(struct ixgb_hw *hw);
55
56 static void ixgb_optics_reset(struct ixgb_hw *hw);
57
58 static ixgb_phy_type ixgb_identify_phy(struct ixgb_hw *hw);
59
60 uint32_t ixgb_mac_reset (struct ixgb_hw* hw);
61
62 uint32_t ixgb_mac_reset (struct ixgb_hw* hw)
63 {
64     uint32_t ctrl_reg;
65
66     /* Setup up hardware to known state with RESET.
67      * SWDPIN settings as per Kemano EPS.
68      */
69     ctrl_reg =  IXGB_CTRL0_RST |
70                 IXGB_CTRL0_SDP3_DIR |   /* All pins are Output=1 */
71                 IXGB_CTRL0_SDP2_DIR |
72                 IXGB_CTRL0_SDP1_DIR |
73                 IXGB_CTRL0_SDP0_DIR |
74                 IXGB_CTRL0_SDP3     |   /* Initial value 1101   */
75                 IXGB_CTRL0_SDP2     |
76                 IXGB_CTRL0_SDP0;
77
78 #ifdef HP_ZX1
79     /* Workaround for 82597EX reset errata */
80     IXGB_WRITE_REG_IO(hw, CTRL0, ctrl_reg);
81 #else
82     IXGB_WRITE_REG(hw, CTRL0, ctrl_reg);
83 #endif
84
85     /* Delay a few ms just to allow the reset to complete */
86     msec_delay(IXGB_DELAY_AFTER_RESET);
87     ctrl_reg = IXGB_READ_REG(hw, CTRL0);
88 #if DBG
89     /* Make sure the self-clearing global reset bit did self clear */
90     ASSERT(!(ctrl_reg & IXGB_CTRL0_RST));
91 #endif
92
93     if (hw->phy_type == ixgb_phy_type_txn17401) {
94         /* Now reset the optics.  This reset is required to ensure link with
95          * the Kemano 003 optical module (TXN17401), as per instructions from
96          * the board designer.
97          */
98         ixgb_optics_reset(hw);
99     }
100
101     return ctrl_reg;
102 }
103
104
105 /******************************************************************************
106  * Reset the transmit and receive units; mask and clear all interrupts.
107  *
108  * hw - Struct containing variables accessed by shared code
109  *****************************************************************************/
110 boolean_t
111 ixgb_adapter_stop(struct ixgb_hw *hw)
112 {
113     uint32_t ctrl_reg;
114     uint32_t icr_reg;
115
116     DEBUGFUNC("ixgb_adapter_stop");
117
118     /* If we are stopped or resetting exit gracefully and wait to be
119      * started again before accessing the hardware.
120      */
121     if(hw->adapter_stopped) {
122         DEBUGOUT("Exiting because the adapter is already stopped!!!\n");
123         return FALSE;
124     }
125
126     /* Set the Adapter Stopped flag so other driver functions stop
127      * touching the Hardware.
128      */
129     hw->adapter_stopped = TRUE;
130
131     /* Clear interrupt mask to stop board from generating interrupts */
132     DEBUGOUT("Masking off all interrupts\n");
133     IXGB_WRITE_REG(hw, IMC, 0xFFFFFFFF);
134
135     /* Disable the Transmit and Receive units.  Then delay to allow
136      * any pending transactions to complete before we hit the MAC with
137      * the global reset.
138      */
139     IXGB_WRITE_REG(hw, RCTL, IXGB_READ_REG(hw, RCTL) & ~IXGB_RCTL_RXEN);
140     IXGB_WRITE_REG(hw, TCTL, IXGB_READ_REG(hw, TCTL) & ~IXGB_TCTL_TXEN);
141     msec_delay(IXGB_DELAY_BEFORE_RESET);
142
143     /* Issue a global reset to the MAC.  This will reset the chip's
144      * transmit, receive, DMA, and link units.  It will not effect
145      * the current PCI configuration.  The global reset bit is self-
146      * clearing, and should clear within a microsecond.
147      */
148     DEBUGOUT("Issuing a global reset to MAC\n");
149
150     ctrl_reg = ixgb_mac_reset(hw);
151
152     /* Clear interrupt mask to stop board from generating interrupts */
153     DEBUGOUT("Masking off all interrupts\n");
154     IXGB_WRITE_REG(hw, IMC, 0xffffffff);
155
156     /* Clear any pending interrupt events. */
157     icr_reg = IXGB_READ_REG(hw, ICR);
158
159     return (ctrl_reg & IXGB_CTRL0_RST);
160 }
161
162
163 /******************************************************************************
164  * Identifies the vendor of the optics module on the adapter.  The SR adapters
165  * support two different types of XPAK optics, so it is necessary to determine
166  * which optics are present before applying any optics-specific workarounds.
167  *
168  * hw - Struct containing variables accessed by shared code.
169  *
170  * Returns: the vendor of the XPAK optics module.
171  *****************************************************************************/
172 static ixgb_xpak_vendor
173 ixgb_identify_xpak_vendor(struct ixgb_hw *hw)
174 {
175     uint32_t            i;
176     uint16_t            vendor_name[5];
177     ixgb_xpak_vendor    xpak_vendor;
178
179     DEBUGFUNC("ixgb_identify_xpak_vendor");
180
181     /* Read the first few bytes of the vendor string from the XPAK NVR
182      * registers.  These are standard XENPAK/XPAK registers, so all XPAK
183      * devices should implement them. */
184     for (i = 0; i < 5; i++) {
185         vendor_name[i] = ixgb_read_phy_reg( hw,
186                                             MDIO_PMA_PMD_XPAK_VENDOR_NAME + i,
187                                             IXGB_PHY_ADDRESS,
188                                             MDIO_PMA_PMD_DID    );
189     }
190
191     /* Determine the actual vendor */
192     if (vendor_name[0] == 'I' &&
193         vendor_name[1] == 'N' &&
194         vendor_name[2] == 'T' &&
195         vendor_name[3] == 'E' &&
196         vendor_name[4] == 'L') {
197         xpak_vendor = ixgb_xpak_vendor_intel;
198     }
199     else {
200         xpak_vendor = ixgb_xpak_vendor_infineon;
201     }
202
203     return (xpak_vendor);
204 }
205
206
207 /******************************************************************************
208  * Determine the physical layer module on the adapter.
209  *
210  * hw - Struct containing variables accessed by shared code.  The device_id
211  *      field must be (correctly) populated before calling this routine.
212  *
213  * Returns: the phy type of the adapter.
214  *****************************************************************************/
215 static ixgb_phy_type
216 ixgb_identify_phy(struct ixgb_hw *hw)
217 {
218     ixgb_phy_type       phy_type;
219     ixgb_xpak_vendor    xpak_vendor;
220
221     DEBUGFUNC("ixgb_identify_phy");
222
223     /* Infer the transceiver/phy type from the device id */
224     switch (hw->device_id) {
225         case IXGB_DEVICE_ID_82597EX:
226             DEBUGOUT("Identified TXN17401 optics\n");
227             phy_type = ixgb_phy_type_txn17401;
228             break;
229
230         case IXGB_DEVICE_ID_82597EX_SR:
231             /* The SR adapters carry two different types of XPAK optics
232              * modules; read the vendor identifier to determine the exact
233              * type of optics. */
234             xpak_vendor = ixgb_identify_xpak_vendor(hw);
235             if (xpak_vendor == ixgb_xpak_vendor_intel) {
236                 DEBUGOUT("Identified TXN17201 optics\n");
237                 phy_type = ixgb_phy_type_txn17201;
238             }
239             else {
240                 DEBUGOUT("Identified G6005 optics\n");
241                 phy_type = ixgb_phy_type_g6005;
242             }
243             break;
244
245
246         default:
247             DEBUGOUT("Unknown physical layer module\n");
248             phy_type = ixgb_phy_type_unknown;
249             break;
250     }
251
252     return (phy_type);
253 }
254
255 /******************************************************************************
256  * Performs basic configuration of the adapter.
257  *
258  * hw - Struct containing variables accessed by shared code
259  *
260  * Resets the controller.
261  * Reads and validates the EEPROM.
262  * Initializes the receive address registers.
263  * Initializes the multicast table.
264  * Clears all on-chip counters.
265  * Calls routine to setup flow control settings.
266  * Leaves the transmit and receive units disabled and uninitialized.
267  *
268  * Returns:
269  *      TRUE if successful,
270  *      FALSE if unrecoverable problems were encountered.
271  *****************************************************************************/
272 boolean_t
273 ixgb_init_hw(struct ixgb_hw *hw)
274 {
275     uint32_t i;
276     uint32_t ctrl_reg;
277     boolean_t status;
278
279     DEBUGFUNC("ixgb_init_hw");
280
281     /* Issue a global reset to the MAC.  This will reset the chip's
282      * transmit, receive, DMA, and link units.  It will not effect
283      * the current PCI configuration.  The global reset bit is self-
284      * clearing, and should clear within a microsecond.
285      */
286     DEBUGOUT("Issuing a global reset to MAC\n");
287
288     ctrl_reg = ixgb_mac_reset(hw);
289
290     DEBUGOUT("Issuing an EE reset to MAC\n");
291 #ifdef HP_ZX1
292     /* Workaround for 82597EX reset errata */
293     IXGB_WRITE_REG_IO(hw, CTRL1, IXGB_CTRL1_EE_RST);
294 #else
295     IXGB_WRITE_REG(hw, CTRL1, IXGB_CTRL1_EE_RST);
296 #endif
297
298     /* Delay a few ms just to allow the reset to complete */
299     msec_delay(IXGB_DELAY_AFTER_EE_RESET);
300
301     if (ixgb_get_eeprom_data(hw) == FALSE) {
302         return(FALSE);
303     }
304
305     /* Use the device id to determine the type of phy/transceiver. */
306     hw->device_id = ixgb_get_ee_device_id(hw);
307     hw->phy_type  = ixgb_identify_phy(hw);
308
309     /* Setup the receive addresses.
310      * Receive Address Registers (RARs 0 - 15).
311      */
312     ixgb_init_rx_addrs(hw);
313
314     /*
315      * Check that a valid MAC address has been set.
316      * If it is not valid, we fail hardware init.
317      */
318     if (!mac_addr_valid(hw->curr_mac_addr)) {
319             DEBUGOUT("MAC address invalid after ixgb_init_rx_addrs\n");
320             return(FALSE);
321     }
322
323     /* tell the routines in this file they can access hardware again */
324     hw->adapter_stopped = FALSE;
325
326     /* Fill in the bus_info structure */
327     ixgb_get_bus_info(hw);
328
329     /* Zero out the Multicast HASH table */
330     DEBUGOUT("Zeroing the MTA\n");
331     for(i = 0; i < IXGB_MC_TBL_SIZE; i++)
332         IXGB_WRITE_REG_ARRAY(hw, MTA, i, 0);
333
334     /* Zero out the VLAN Filter Table Array */
335     ixgb_clear_vfta(hw);
336
337     /* Zero all of the hardware counters */
338     ixgb_clear_hw_cntrs(hw);
339
340     /* Call a subroutine to setup flow control. */
341     status = ixgb_setup_fc(hw);
342
343     /* 82597EX errata: Call check-for-link in case lane deskew is locked */
344     ixgb_check_for_link(hw);
345
346     return (status);
347 }
348
349 /******************************************************************************
350  * Initializes receive address filters.
351  *
352  * hw - Struct containing variables accessed by shared code
353  *
354  * Places the MAC address in receive address register 0 and clears the rest
355  * of the receive addresss registers. Clears the multicast table. Assumes
356  * the receiver is in reset when the routine is called.
357  *****************************************************************************/
358 void
359 ixgb_init_rx_addrs(struct ixgb_hw *hw)
360 {
361     uint32_t i;
362
363     DEBUGFUNC("ixgb_init_rx_addrs");
364
365     /*
366      * If the current mac address is valid, assume it is a software override
367      * to the permanent address.
368      * Otherwise, use the permanent address from the eeprom.
369      */
370     if (!mac_addr_valid(hw->curr_mac_addr)) {
371
372            /* Get the MAC address from the eeprom for later reference */
373            ixgb_get_ee_mac_addr(hw, hw->curr_mac_addr);
374
375            DEBUGOUT3(" Keeping Permanent MAC Addr =%.2X %.2X %.2X ",
376                                             hw->curr_mac_addr[0],
377                                             hw->curr_mac_addr[1],
378                                             hw->curr_mac_addr[2]);
379            DEBUGOUT3("%.2X %.2X %.2X\n",
380                                             hw->curr_mac_addr[3],
381                                             hw->curr_mac_addr[4],
382                                             hw->curr_mac_addr[5]);
383     } else {
384
385             /* Setup the receive address. */
386             DEBUGOUT("Overriding MAC Address in RAR[0]\n");
387             DEBUGOUT3(" New MAC Addr =%.2X %.2X %.2X ",
388                                         hw->curr_mac_addr[0],
389                                         hw->curr_mac_addr[1],
390                                         hw->curr_mac_addr[2]);
391             DEBUGOUT3("%.2X %.2X %.2X\n",
392                                         hw->curr_mac_addr[3],
393                                         hw->curr_mac_addr[4],
394                                         hw->curr_mac_addr[5]);
395
396
397             ixgb_rar_set(hw, hw->curr_mac_addr, 0);
398     }
399
400     /* Zero out the other 15 receive addresses. */
401     DEBUGOUT("Clearing RAR[1-15]\n");
402     for(i = 1; i < IXGB_RAR_ENTRIES; i++) {
403         IXGB_WRITE_REG_ARRAY(hw, RA, (i << 1), 0);
404         IXGB_WRITE_REG_ARRAY(hw, RA, ((i << 1) + 1), 0);
405     }
406
407     return;
408 }
409
410 /******************************************************************************
411  * Updates the MAC's list of multicast addresses.
412  *
413  * hw - Struct containing variables accessed by shared code
414  * mc_addr_list - the list of new multicast addresses
415  * mc_addr_count - number of addresses
416  * pad - number of bytes between addresses in the list
417  *
418  * The given list replaces any existing list. Clears the last 15 receive
419  * address registers and the multicast table. Uses receive address registers
420  * for the first 15 multicast addresses, and hashes the rest into the
421  * multicast table.
422  *****************************************************************************/
423 void
424 ixgb_mc_addr_list_update(struct ixgb_hw *hw,
425                           uint8_t *mc_addr_list,
426                           uint32_t mc_addr_count,
427                           uint32_t pad)
428 {
429     uint32_t hash_value;
430     uint32_t i;
431     uint32_t rar_used_count = 1;        /* RAR[0] is used for our MAC address */
432
433     DEBUGFUNC("ixgb_mc_addr_list_update");
434
435     /* Set the new number of MC addresses that we are being requested to use. */
436     hw->num_mc_addrs = mc_addr_count;
437
438     /* Clear RAR[1-15] */
439     DEBUGOUT(" Clearing RAR[1-15]\n");
440     for(i = rar_used_count; i < IXGB_RAR_ENTRIES; i++) {
441         IXGB_WRITE_REG_ARRAY(hw, RA, (i << 1), 0);
442         IXGB_WRITE_REG_ARRAY(hw, RA, ((i << 1) + 1), 0);
443     }
444
445     /* Clear the MTA */
446     DEBUGOUT(" Clearing MTA\n");
447     for(i = 0; i < IXGB_MC_TBL_SIZE; i++) {
448         IXGB_WRITE_REG_ARRAY(hw, MTA, i, 0);
449     }
450
451     /* Add the new addresses */
452     for(i = 0; i < mc_addr_count; i++) {
453         DEBUGOUT(" Adding the multicast addresses:\n");
454         DEBUGOUT7(" MC Addr #%d =%.2X %.2X %.2X %.2X %.2X %.2X\n", i,
455                   mc_addr_list[i * (IXGB_ETH_LENGTH_OF_ADDRESS + pad)],
456                   mc_addr_list[i * (IXGB_ETH_LENGTH_OF_ADDRESS + pad) + 1],
457                   mc_addr_list[i * (IXGB_ETH_LENGTH_OF_ADDRESS + pad) + 2],
458                   mc_addr_list[i * (IXGB_ETH_LENGTH_OF_ADDRESS + pad) + 3],
459                   mc_addr_list[i * (IXGB_ETH_LENGTH_OF_ADDRESS + pad) + 4],
460                   mc_addr_list[i * (IXGB_ETH_LENGTH_OF_ADDRESS + pad) + 5]);
461
462         /* Place this multicast address in the RAR if there is room, *
463          * else put it in the MTA
464          */
465         if(rar_used_count < IXGB_RAR_ENTRIES) {
466             ixgb_rar_set(hw,
467                           mc_addr_list + (i * (IXGB_ETH_LENGTH_OF_ADDRESS + pad)),
468                           rar_used_count);
469             DEBUGOUT1("Added a multicast address to RAR[%d]\n", i);
470             rar_used_count++;
471         } else {
472              hash_value = ixgb_hash_mc_addr(hw,
473                                         mc_addr_list +
474                                         (i * (IXGB_ETH_LENGTH_OF_ADDRESS + pad)));
475
476             DEBUGOUT1(" Hash value = 0x%03X\n", hash_value);
477
478             ixgb_mta_set(hw, hash_value);
479         }
480     }
481
482     DEBUGOUT("MC Update Complete\n");
483     return;
484 }
485
486 /******************************************************************************
487  * Hashes an address to determine its location in the multicast table
488  *
489  * hw - Struct containing variables accessed by shared code
490  * mc_addr - the multicast address to hash
491  *
492  * Returns:
493  *      The hash value
494  *****************************************************************************/
495 static uint32_t
496 ixgb_hash_mc_addr(struct ixgb_hw *hw,
497                    uint8_t *mc_addr)
498 {
499     uint32_t hash_value = 0;
500
501     DEBUGFUNC("ixgb_hash_mc_addr");
502
503     /* The portion of the address that is used for the hash table is
504      * determined by the mc_filter_type setting.
505      */
506     switch (hw->mc_filter_type) {
507         /* [0] [1] [2] [3] [4] [5]
508          * 01  AA  00  12  34  56
509          * LSB                 MSB - According to H/W docs */
510         case 0:
511             /* [47:36] i.e. 0x563 for above example address */
512             hash_value = ((mc_addr[4] >> 4) | (((uint16_t) mc_addr[5]) << 4));
513             break;
514         case 1:                   /* [46:35] i.e. 0xAC6 for above example address */
515             hash_value = ((mc_addr[4] >> 3) | (((uint16_t) mc_addr[5]) << 5));
516             break;
517         case 2:                   /* [45:34] i.e. 0x5D8 for above example address */
518             hash_value = ((mc_addr[4] >> 2) | (((uint16_t) mc_addr[5]) << 6));
519             break;
520         case 3:                   /* [43:32] i.e. 0x634 for above example address */
521             hash_value = ((mc_addr[4]) | (((uint16_t) mc_addr[5]) << 8));
522             break;
523         default:
524             /* Invalid mc_filter_type, what should we do? */
525             DEBUGOUT("MC filter type param set incorrectly\n");
526             ASSERT(0);
527             break;
528     }
529
530     hash_value &= 0xFFF;
531     return (hash_value);
532 }
533
534 /******************************************************************************
535  * Sets the bit in the multicast table corresponding to the hash value.
536  *
537  * hw - Struct containing variables accessed by shared code
538  * hash_value - Multicast address hash value
539  *****************************************************************************/
540 static void
541 ixgb_mta_set(struct ixgb_hw *hw,
542               uint32_t hash_value)
543 {
544     uint32_t hash_bit, hash_reg;
545     uint32_t mta_reg;
546
547     /* The MTA is a register array of 128 32-bit registers.
548      * It is treated like an array of 4096 bits.  We want to set
549      * bit BitArray[hash_value]. So we figure out what register
550      * the bit is in, read it, OR in the new bit, then write
551      * back the new value.  The register is determined by the
552      * upper 7 bits of the hash value and the bit within that
553      * register are determined by the lower 5 bits of the value.
554      */
555     hash_reg = (hash_value >> 5) & 0x7F;
556     hash_bit = hash_value & 0x1F;
557
558     mta_reg = IXGB_READ_REG_ARRAY(hw, MTA, hash_reg);
559
560     mta_reg |= (1 << hash_bit);
561
562     IXGB_WRITE_REG_ARRAY(hw, MTA, hash_reg, mta_reg);
563
564     return;
565 }
566
567 /******************************************************************************
568  * Puts an ethernet address into a receive address register.
569  *
570  * hw - Struct containing variables accessed by shared code
571  * addr - Address to put into receive address register
572  * index - Receive address register to write
573  *****************************************************************************/
574 void
575 ixgb_rar_set(struct ixgb_hw *hw,
576               uint8_t *addr,
577               uint32_t index)
578 {
579     uint32_t rar_low, rar_high;
580
581     DEBUGFUNC("ixgb_rar_set");
582
583     /* HW expects these in little endian so we reverse the byte order
584      * from network order (big endian) to little endian
585      */
586     rar_low = ((uint32_t) addr[0] |
587                ((uint32_t) addr[1] << 8) |
588                ((uint32_t) addr[2] << 16) |
589                ((uint32_t) addr[3] << 24));
590
591     rar_high = ((uint32_t) addr[4] |
592                 ((uint32_t) addr[5] << 8) |
593                 IXGB_RAH_AV);
594
595     IXGB_WRITE_REG_ARRAY(hw, RA, (index << 1), rar_low);
596     IXGB_WRITE_REG_ARRAY(hw, RA, ((index << 1) + 1), rar_high);
597     return;
598 }
599
600 /******************************************************************************
601  * Writes a value to the specified offset in the VLAN filter table.
602  *
603  * hw - Struct containing variables accessed by shared code
604  * offset - Offset in VLAN filer table to write
605  * value - Value to write into VLAN filter table
606  *****************************************************************************/
607 void
608 ixgb_write_vfta(struct ixgb_hw *hw,
609                  uint32_t offset,
610                  uint32_t value)
611 {
612     IXGB_WRITE_REG_ARRAY(hw, VFTA, offset, value);
613     return;
614 }
615
616 /******************************************************************************
617  * Clears the VLAN filer table
618  *
619  * hw - Struct containing variables accessed by shared code
620  *****************************************************************************/
621 void
622 ixgb_clear_vfta(struct ixgb_hw *hw)
623 {
624     uint32_t offset;
625
626     for(offset = 0; offset < IXGB_VLAN_FILTER_TBL_SIZE; offset++)
627         IXGB_WRITE_REG_ARRAY(hw, VFTA, offset, 0);
628     return;
629 }
630
631 /******************************************************************************
632  * Configures the flow control settings based on SW configuration.
633  *
634  * hw - Struct containing variables accessed by shared code
635  *****************************************************************************/
636
637 boolean_t
638 ixgb_setup_fc(struct ixgb_hw *hw)
639 {
640     uint32_t ctrl_reg;
641     uint32_t pap_reg = 0;   /* by default, assume no pause time */
642     boolean_t status = TRUE;
643
644     DEBUGFUNC("ixgb_setup_fc");
645
646     /* Get the current control reg 0 settings */
647     ctrl_reg = IXGB_READ_REG(hw, CTRL0);
648
649     /* Clear the Receive Pause Enable and Transmit Pause Enable bits */
650     ctrl_reg &= ~(IXGB_CTRL0_RPE | IXGB_CTRL0_TPE);
651
652     /* The possible values of the "flow_control" parameter are:
653      *      0:  Flow control is completely disabled
654      *      1:  Rx flow control is enabled (we can receive pause frames
655      *          but not send pause frames).
656      *      2:  Tx flow control is enabled (we can send pause frames
657      *          but we do not support receiving pause frames).
658      *      3:  Both Rx and TX flow control (symmetric) are enabled.
659      *  other:  Invalid.
660      */
661     switch (hw->fc.type) {
662     case ixgb_fc_none:        /* 0 */
663         /* Set CMDC bit to disable Rx Flow control*/
664         ctrl_reg |= (IXGB_CTRL0_CMDC);
665         break;
666     case ixgb_fc_rx_pause:    /* 1 */
667         /* RX Flow control is enabled, and TX Flow control is
668          * disabled.
669          */
670         ctrl_reg |= (IXGB_CTRL0_RPE);
671         break;
672     case ixgb_fc_tx_pause:    /* 2 */
673         /* TX Flow control is enabled, and RX Flow control is
674          * disabled, by a software over-ride.
675          */
676         ctrl_reg |= (IXGB_CTRL0_TPE);
677         pap_reg = hw->fc.pause_time;
678         break;
679     case ixgb_fc_full:        /* 3 */
680         /* Flow control (both RX and TX) is enabled by a software
681          * over-ride.
682          */
683         ctrl_reg |= (IXGB_CTRL0_RPE | IXGB_CTRL0_TPE);
684         pap_reg = hw->fc.pause_time;
685         break;
686     default:
687         /* We should never get here.  The value should be 0-3. */
688         DEBUGOUT("Flow control param set incorrectly\n");
689         ASSERT(0);
690         break;
691     }
692
693     /* Write the new settings */
694     IXGB_WRITE_REG(hw, CTRL0, ctrl_reg);
695
696     if (pap_reg != 0) {
697         IXGB_WRITE_REG(hw, PAP, pap_reg);
698     }
699
700     /* Set the flow control receive threshold registers.  Normally,
701      * these registers will be set to a default threshold that may be
702      * adjusted later by the driver's runtime code.  However, if the
703      * ability to transmit pause frames in not enabled, then these
704      * registers will be set to 0.
705      */
706     if(!(hw->fc.type & ixgb_fc_tx_pause)) {
707         IXGB_WRITE_REG(hw, FCRTL, 0);
708         IXGB_WRITE_REG(hw, FCRTH, 0);
709     } else {
710        /* We need to set up the Receive Threshold high and low water
711         * marks as well as (optionally) enabling the transmission of XON frames.
712         */
713         if(hw->fc.send_xon) {
714             IXGB_WRITE_REG(hw, FCRTL,
715                             (hw->fc.low_water | IXGB_FCRTL_XONE));
716         } else {
717             IXGB_WRITE_REG(hw, FCRTL, hw->fc.low_water);
718         }
719         IXGB_WRITE_REG(hw, FCRTH, hw->fc.high_water);
720     }
721     return (status);
722 }
723
724 /******************************************************************************
725  * Reads a word from a device over the Management Data Interface (MDI) bus.
726  * This interface is used to manage Physical layer devices.
727  *
728  * hw          - Struct containing variables accessed by hw code
729  * reg_address - Offset of device register being read.
730  * phy_address - Address of device on MDI.
731  *
732  * Returns:  Data word (16 bits) from MDI device.
733  *
734  * The 82597EX has support for several MDI access methods.  This routine
735  * uses the new protocol MDI Single Command and Address Operation.
736  * This requires that first an address cycle command is sent, followed by a
737  * read command.
738  *****************************************************************************/
739 uint16_t
740 ixgb_read_phy_reg(struct ixgb_hw *hw,
741                         uint32_t reg_address,
742                         uint32_t phy_address,
743                         uint32_t device_type)
744 {
745     uint32_t i;
746     uint32_t data;
747     uint32_t command = 0;
748
749     ASSERT(reg_address <= IXGB_MAX_PHY_REG_ADDRESS);
750     ASSERT(phy_address <= IXGB_MAX_PHY_ADDRESS);
751     ASSERT(device_type <= IXGB_MAX_PHY_DEV_TYPE);
752
753     /* Setup and write the address cycle command */
754     command = ((reg_address << IXGB_MSCA_NP_ADDR_SHIFT)  |
755                (device_type << IXGB_MSCA_DEV_TYPE_SHIFT) |
756                (phy_address << IXGB_MSCA_PHY_ADDR_SHIFT) |
757                (IXGB_MSCA_ADDR_CYCLE | IXGB_MSCA_MDI_COMMAND));
758
759     IXGB_WRITE_REG(hw, MSCA, command);
760
761     /**************************************************************
762     ** Check every 10 usec to see if the address cycle completed
763     ** The COMMAND bit will clear when the operation is complete.
764     ** This may take as long as 64 usecs (we'll wait 100 usecs max)
765     ** from the CPU Write to the Ready bit assertion.
766     **************************************************************/
767
768     for (i = 0; i < 10; i++)
769     {
770         usec_delay(10);
771
772         command = IXGB_READ_REG(hw, MSCA);
773
774         if ((command & IXGB_MSCA_MDI_COMMAND) == 0)
775             break;
776     }
777
778     ASSERT((command & IXGB_MSCA_MDI_COMMAND) == 0);
779
780     /* Address cycle complete, setup and write the read command */
781     command = ((reg_address << IXGB_MSCA_NP_ADDR_SHIFT)  |
782                (device_type << IXGB_MSCA_DEV_TYPE_SHIFT) |
783                (phy_address << IXGB_MSCA_PHY_ADDR_SHIFT) |
784                (IXGB_MSCA_READ | IXGB_MSCA_MDI_COMMAND));
785
786     IXGB_WRITE_REG(hw, MSCA, command);
787
788     /**************************************************************
789     ** Check every 10 usec to see if the read command completed
790     ** The COMMAND bit will clear when the operation is complete.
791     ** The read may take as long as 64 usecs (we'll wait 100 usecs max)
792     ** from the CPU Write to the Ready bit assertion.
793     **************************************************************/
794
795     for (i = 0; i < 10; i++)
796     {
797         usec_delay(10);
798
799         command = IXGB_READ_REG(hw, MSCA);
800
801         if ((command & IXGB_MSCA_MDI_COMMAND) == 0)
802             break;
803     }
804
805     ASSERT((command & IXGB_MSCA_MDI_COMMAND) == 0);
806
807     /* Operation is complete, get the data from the MDIO Read/Write Data
808      * register and return.
809      */
810     data = IXGB_READ_REG(hw, MSRWD);
811     data >>= IXGB_MSRWD_READ_DATA_SHIFT;
812     return((uint16_t) data);
813 }
814
815 /******************************************************************************
816  * Writes a word to a device over the Management Data Interface (MDI) bus.
817  * This interface is used to manage Physical layer devices.
818  *
819  * hw          - Struct containing variables accessed by hw code
820  * reg_address - Offset of device register being read.
821  * phy_address - Address of device on MDI.
822  * device_type - Also known as the Device ID or DID.
823  * data        - 16-bit value to be written
824  *
825  * Returns:  void.
826  *
827  * The 82597EX has support for several MDI access methods.  This routine
828  * uses the new protocol MDI Single Command and Address Operation.
829  * This requires that first an address cycle command is sent, followed by a
830  * write command.
831  *****************************************************************************/
832 void
833 ixgb_write_phy_reg(struct ixgb_hw *hw,
834                         uint32_t reg_address,
835                         uint32_t phy_address,
836                         uint32_t device_type,
837                         uint16_t data)
838 {
839     uint32_t i;
840     uint32_t command = 0;
841
842     ASSERT(reg_address <= IXGB_MAX_PHY_REG_ADDRESS);
843     ASSERT(phy_address <= IXGB_MAX_PHY_ADDRESS);
844     ASSERT(device_type <= IXGB_MAX_PHY_DEV_TYPE);
845
846     /* Put the data in the MDIO Read/Write Data register */
847     IXGB_WRITE_REG(hw, MSRWD, (uint32_t)data);
848
849     /* Setup and write the address cycle command */
850     command = ((reg_address << IXGB_MSCA_NP_ADDR_SHIFT)  |
851                (device_type << IXGB_MSCA_DEV_TYPE_SHIFT) |
852                (phy_address << IXGB_MSCA_PHY_ADDR_SHIFT) |
853                (IXGB_MSCA_ADDR_CYCLE | IXGB_MSCA_MDI_COMMAND));
854
855     IXGB_WRITE_REG(hw, MSCA, command);
856
857     /**************************************************************
858     ** Check every 10 usec to see if the address cycle completed
859     ** The COMMAND bit will clear when the operation is complete.
860     ** This may take as long as 64 usecs (we'll wait 100 usecs max)
861     ** from the CPU Write to the Ready bit assertion.
862     **************************************************************/
863
864     for (i = 0; i < 10; i++)
865     {
866         usec_delay(10);
867
868         command = IXGB_READ_REG(hw, MSCA);
869
870         if ((command & IXGB_MSCA_MDI_COMMAND) == 0)
871             break;
872     }
873
874     ASSERT((command & IXGB_MSCA_MDI_COMMAND) == 0);
875
876     /* Address cycle complete, setup and write the write command */
877     command = ((reg_address << IXGB_MSCA_NP_ADDR_SHIFT)  |
878                (device_type << IXGB_MSCA_DEV_TYPE_SHIFT) |
879                (phy_address << IXGB_MSCA_PHY_ADDR_SHIFT) |
880                (IXGB_MSCA_WRITE | IXGB_MSCA_MDI_COMMAND));
881
882     IXGB_WRITE_REG(hw, MSCA, command);
883
884     /**************************************************************
885     ** Check every 10 usec to see if the read command completed
886     ** The COMMAND bit will clear when the operation is complete.
887     ** The write may take as long as 64 usecs (we'll wait 100 usecs max)
888     ** from the CPU Write to the Ready bit assertion.
889     **************************************************************/
890
891     for (i = 0; i < 10; i++)
892     {
893         usec_delay(10);
894
895         command = IXGB_READ_REG(hw, MSCA);
896
897         if ((command & IXGB_MSCA_MDI_COMMAND) == 0)
898             break;
899     }
900
901     ASSERT((command & IXGB_MSCA_MDI_COMMAND) == 0);
902
903     /* Operation is complete, return. */
904 }
905
906
907 /******************************************************************************
908  * Checks to see if the link status of the hardware has changed.
909  *
910  * hw - Struct containing variables accessed by hw code
911  *
912  * Called by any function that needs to check the link status of the adapter.
913  *****************************************************************************/
914 void
915 ixgb_check_for_link(struct ixgb_hw *hw)
916 {
917     uint32_t status_reg;
918     uint32_t xpcss_reg;
919
920     DEBUGFUNC("ixgb_check_for_link");
921
922     xpcss_reg = IXGB_READ_REG(hw, XPCSS);
923     status_reg = IXGB_READ_REG(hw, STATUS);
924
925     if ((xpcss_reg & IXGB_XPCSS_ALIGN_STATUS) &&
926         (status_reg & IXGB_STATUS_LU)) {
927        hw->link_up = TRUE;
928     } else if (!(xpcss_reg & IXGB_XPCSS_ALIGN_STATUS) &&
929            (status_reg & IXGB_STATUS_LU)) {
930         DEBUGOUT("XPCSS Not Aligned while Status:LU is set.\n");
931         hw->link_up = ixgb_link_reset(hw);
932     } else {
933         /*
934          * 82597EX errata.  Since the lane deskew problem may prevent
935          * link, reset the link before reporting link down.
936          */
937         hw->link_up = ixgb_link_reset(hw);
938     }
939     /*  Anything else for 10 Gig?? */
940 }
941
942 /******************************************************************************
943  * Check for a bad link condition that may have occurred.
944  * The indication is that the RFC / LFC registers may be incrementing
945  * continually.  A full adapter reset is required to recover.
946  *
947  * hw - Struct containing variables accessed by hw code
948  *
949  * Called by any function that needs to check the link status of the adapter.
950  *****************************************************************************/
951 boolean_t ixgb_check_for_bad_link(struct ixgb_hw *hw)
952 {
953     uint32_t newLFC, newRFC;
954     boolean_t bad_link_returncode = FALSE;
955
956     if (hw->phy_type == ixgb_phy_type_txn17401) {
957         newLFC = IXGB_READ_REG(hw, LFC);
958         newRFC = IXGB_READ_REG(hw, RFC);
959         if ((hw->lastLFC + 250 < newLFC) || (hw->lastRFC + 250 < newRFC)) {
960             DEBUGOUT("BAD LINK! too many LFC/RFC since last check\n");
961             bad_link_returncode = TRUE;
962         }
963         hw->lastLFC = newLFC;
964         hw->lastRFC = newRFC;
965     }
966
967     return bad_link_returncode;
968 }
969
970
971 /******************************************************************************
972  * Clears all hardware statistics counters.
973  *
974  * hw - Struct containing variables accessed by shared code
975  *****************************************************************************/
976 void
977 ixgb_clear_hw_cntrs(struct ixgb_hw *hw)
978 {
979     volatile uint32_t temp_reg;
980
981     DEBUGFUNC("ixgb_clear_hw_cntrs");
982
983     /* if we are stopped or resetting exit gracefully */
984     if(hw->adapter_stopped) {
985         DEBUGOUT("Exiting because the adapter is stopped!!!\n");
986         return;
987     }
988
989     temp_reg = IXGB_READ_REG(hw, TPRL);
990     temp_reg = IXGB_READ_REG(hw, TPRH);
991     temp_reg = IXGB_READ_REG(hw, GPRCL);
992     temp_reg = IXGB_READ_REG(hw, GPRCH);
993     temp_reg = IXGB_READ_REG(hw, BPRCL);
994     temp_reg = IXGB_READ_REG(hw, BPRCH);
995     temp_reg = IXGB_READ_REG(hw, MPRCL);
996     temp_reg = IXGB_READ_REG(hw, MPRCH);
997     temp_reg = IXGB_READ_REG(hw, UPRCL);
998     temp_reg = IXGB_READ_REG(hw, UPRCH);
999     temp_reg = IXGB_READ_REG(hw, VPRCL);
1000     temp_reg = IXGB_READ_REG(hw, VPRCH);
1001     temp_reg = IXGB_READ_REG(hw, JPRCL);
1002     temp_reg = IXGB_READ_REG(hw, JPRCH);
1003     temp_reg = IXGB_READ_REG(hw, GORCL);
1004     temp_reg = IXGB_READ_REG(hw, GORCH);
1005     temp_reg = IXGB_READ_REG(hw, TORL);
1006     temp_reg = IXGB_READ_REG(hw, TORH);
1007     temp_reg = IXGB_READ_REG(hw, RNBC);
1008     temp_reg = IXGB_READ_REG(hw, RUC);
1009     temp_reg = IXGB_READ_REG(hw, ROC);
1010     temp_reg = IXGB_READ_REG(hw, RLEC);
1011     temp_reg = IXGB_READ_REG(hw, CRCERRS);
1012     temp_reg = IXGB_READ_REG(hw, ICBC);
1013     temp_reg = IXGB_READ_REG(hw, ECBC);
1014     temp_reg = IXGB_READ_REG(hw, MPC);
1015     temp_reg = IXGB_READ_REG(hw, TPTL);
1016     temp_reg = IXGB_READ_REG(hw, TPTH);
1017     temp_reg = IXGB_READ_REG(hw, GPTCL);
1018     temp_reg = IXGB_READ_REG(hw, GPTCH);
1019     temp_reg = IXGB_READ_REG(hw, BPTCL);
1020     temp_reg = IXGB_READ_REG(hw, BPTCH);
1021     temp_reg = IXGB_READ_REG(hw, MPTCL);
1022     temp_reg = IXGB_READ_REG(hw, MPTCH);
1023     temp_reg = IXGB_READ_REG(hw, UPTCL);
1024     temp_reg = IXGB_READ_REG(hw, UPTCH);
1025     temp_reg = IXGB_READ_REG(hw, VPTCL);
1026     temp_reg = IXGB_READ_REG(hw, VPTCH);
1027     temp_reg = IXGB_READ_REG(hw, JPTCL);
1028     temp_reg = IXGB_READ_REG(hw, JPTCH);
1029     temp_reg = IXGB_READ_REG(hw, GOTCL);
1030     temp_reg = IXGB_READ_REG(hw, GOTCH);
1031     temp_reg = IXGB_READ_REG(hw, TOTL);
1032     temp_reg = IXGB_READ_REG(hw, TOTH);
1033     temp_reg = IXGB_READ_REG(hw, DC);
1034     temp_reg = IXGB_READ_REG(hw, PLT64C);
1035     temp_reg = IXGB_READ_REG(hw, TSCTC);
1036     temp_reg = IXGB_READ_REG(hw, TSCTFC);
1037     temp_reg = IXGB_READ_REG(hw, IBIC);
1038     temp_reg = IXGB_READ_REG(hw, RFC);
1039     temp_reg = IXGB_READ_REG(hw, LFC);
1040     temp_reg = IXGB_READ_REG(hw, PFRC);
1041     temp_reg = IXGB_READ_REG(hw, PFTC);
1042     temp_reg = IXGB_READ_REG(hw, MCFRC);
1043     temp_reg = IXGB_READ_REG(hw, MCFTC);
1044     temp_reg = IXGB_READ_REG(hw, XONRXC);
1045     temp_reg = IXGB_READ_REG(hw, XONTXC);
1046     temp_reg = IXGB_READ_REG(hw, XOFFRXC);
1047     temp_reg = IXGB_READ_REG(hw, XOFFTXC);
1048     temp_reg = IXGB_READ_REG(hw, RJC);
1049     return;
1050 }
1051
1052
1053 /******************************************************************************
1054  * Turns on the software controllable LED
1055  *
1056  * hw - Struct containing variables accessed by shared code
1057  *****************************************************************************/
1058 void
1059 ixgb_led_on(struct ixgb_hw *hw)
1060 {
1061     uint32_t ctrl0_reg = IXGB_READ_REG(hw, CTRL0);
1062
1063     /* To turn on the LED, clear software-definable pin 0 (SDP0). */
1064     ctrl0_reg &= ~IXGB_CTRL0_SDP0;
1065     IXGB_WRITE_REG(hw, CTRL0, ctrl0_reg);
1066     return;
1067 }
1068
1069 /******************************************************************************
1070  * Turns off the software controllable LED
1071  *
1072  * hw - Struct containing variables accessed by shared code
1073  *****************************************************************************/
1074 void
1075 ixgb_led_off(struct ixgb_hw *hw)
1076 {
1077     uint32_t ctrl0_reg = IXGB_READ_REG(hw, CTRL0);
1078
1079     /* To turn off the LED, set software-definable pin 0 (SDP0). */
1080     ctrl0_reg |= IXGB_CTRL0_SDP0;
1081     IXGB_WRITE_REG(hw, CTRL0, ctrl0_reg);
1082     return;
1083 }
1084
1085
1086 /******************************************************************************
1087  * Gets the current PCI bus type, speed, and width of the hardware
1088  *
1089  * hw - Struct containing variables accessed by shared code
1090  *****************************************************************************/
1091 static void
1092 ixgb_get_bus_info(struct ixgb_hw *hw)
1093 {
1094     uint32_t status_reg;
1095
1096     status_reg = IXGB_READ_REG(hw, STATUS);
1097
1098     hw->bus.type = (status_reg & IXGB_STATUS_PCIX_MODE) ?
1099         ixgb_bus_type_pcix : ixgb_bus_type_pci;
1100
1101     if (hw->bus.type == ixgb_bus_type_pci) {
1102         hw->bus.speed = (status_reg & IXGB_STATUS_PCI_SPD) ?
1103             ixgb_bus_speed_66 : ixgb_bus_speed_33;
1104     } else {
1105         switch (status_reg & IXGB_STATUS_PCIX_SPD_MASK) {
1106         case IXGB_STATUS_PCIX_SPD_66:
1107             hw->bus.speed = ixgb_bus_speed_66;
1108             break;
1109         case IXGB_STATUS_PCIX_SPD_100:
1110             hw->bus.speed = ixgb_bus_speed_100;
1111             break;
1112         case IXGB_STATUS_PCIX_SPD_133:
1113             hw->bus.speed = ixgb_bus_speed_133;
1114             break;
1115         default:
1116             hw->bus.speed = ixgb_bus_speed_reserved;
1117             break;
1118         }
1119     }
1120
1121     hw->bus.width = (status_reg & IXGB_STATUS_BUS64) ?
1122         ixgb_bus_width_64 : ixgb_bus_width_32;
1123
1124     return;
1125 }
1126
1127
1128
1129 /******************************************************************************
1130  * Tests a MAC address to ensure it is a valid Individual Address
1131  *
1132  * mac_addr - pointer to MAC address.
1133  *
1134  *****************************************************************************/
1135 boolean_t
1136 mac_addr_valid(uint8_t *mac_addr)
1137 {
1138     boolean_t       is_valid                = TRUE;
1139     DEBUGFUNC("mac_addr_valid");
1140
1141
1142     /* Make sure it is not a multicast address */
1143     if (IS_MULTICAST(mac_addr)) {
1144         DEBUGOUT("MAC address is multicast\n");
1145         is_valid = FALSE;
1146     }
1147     /* Not a broadcast address */
1148     else if (IS_BROADCAST(mac_addr)) {
1149         DEBUGOUT("MAC address is broadcast\n");
1150         is_valid = FALSE;
1151     }
1152     /* Reject the zero address */
1153     else if (mac_addr[0] == 0 &&
1154              mac_addr[1] == 0 &&
1155              mac_addr[2] == 0 &&
1156              mac_addr[3] == 0 &&
1157              mac_addr[4] == 0 &&
1158              mac_addr[5] == 0) {
1159         DEBUGOUT("MAC address is all zeros\n");
1160         is_valid = FALSE;
1161     }
1162     return (is_valid);
1163 }
1164
1165 /******************************************************************************
1166  * Resets the 10GbE link.  Waits the settle time and returns the state of
1167  * the link.
1168  *
1169  * hw - Struct containing variables accessed by shared code
1170  *****************************************************************************/
1171 boolean_t
1172 ixgb_link_reset(struct ixgb_hw *hw)
1173 {
1174     boolean_t link_status = FALSE;
1175     uint8_t   wait_retries = MAX_RESET_ITERATIONS;
1176     uint8_t   lrst_retries = MAX_RESET_ITERATIONS;
1177
1178
1179     do {
1180        /* Reset the link */
1181        IXGB_WRITE_REG(hw, CTRL0, IXGB_READ_REG(hw, CTRL0) | IXGB_CTRL0_LRST);
1182
1183        /* Wait for link-up and lane re-alignment */
1184        do {
1185            usec_delay(IXGB_DELAY_USECS_AFTER_LINK_RESET);
1186            link_status = ((IXGB_READ_REG(hw, STATUS) & IXGB_STATUS_LU) &&
1187                (IXGB_READ_REG(hw, XPCSS) & IXGB_XPCSS_ALIGN_STATUS)) ?
1188                TRUE : FALSE;
1189        } while (!link_status && -- wait_retries);
1190
1191     } while (!link_status && --lrst_retries);
1192
1193     return link_status;
1194 }
1195
1196
1197
1198 /******************************************************************************
1199  * Resets the 10GbE optics module.
1200  *
1201  * hw - Struct containing variables accessed by shared code
1202  *****************************************************************************/
1203 void
1204 ixgb_optics_reset(struct ixgb_hw *hw)
1205 {
1206     if (hw->phy_type == ixgb_phy_type_txn17401) {
1207         uint16_t mdio_reg;
1208
1209         ixgb_write_phy_reg( hw,
1210                             MDIO_PMA_PMD_CR1,
1211                             IXGB_PHY_ADDRESS,
1212                             MDIO_PMA_PMD_DID,
1213                             MDIO_PMA_PMD_CR1_RESET);
1214
1215         mdio_reg = ixgb_read_phy_reg( hw,
1216                             MDIO_PMA_PMD_CR1,
1217                             IXGB_PHY_ADDRESS,
1218                             MDIO_PMA_PMD_DID);
1219     }
1220
1221     return;
1222 }
1223