ixgbe_api.c revision 1.4 1 /******************************************************************************
2
3 Copyright (c) 2001-2010, Intel Corporation
4 All rights reserved.
5
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions are met:
8
9 1. Redistributions of source code must retain the above copyright notice,
10 this list of conditions and the following disclaimer.
11
12 2. Redistributions in binary form must reproduce the above copyright
13 notice, this list of conditions and the following disclaimer in the
14 documentation and/or other materials provided with the distribution.
15
16 3. Neither the name of the Intel Corporation nor the names of its
17 contributors may be used to endorse or promote products derived from
18 this software without specific prior written permission.
19
20 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 POSSIBILITY OF SUCH DAMAGE.
31
32 ******************************************************************************/
33 /*$FreeBSD: src/sys/dev/ixgbe/ixgbe_api.c,v 1.11 2010/11/26 22:46:32 jfv Exp $*/
34 /*$NetBSD: ixgbe_api.c,v 1.4 2015/02/24 14:49:28 msaitoh Exp $*/
35
36 #include "ixgbe_api.h"
37 #include "ixgbe_common.h"
38
39 extern s32 ixgbe_init_ops_82598(struct ixgbe_hw *hw);
40 extern s32 ixgbe_init_ops_82599(struct ixgbe_hw *hw);
41 extern s32 ixgbe_init_ops_vf(struct ixgbe_hw *hw);
42
43 /**
44 * ixgbe_init_shared_code - Initialize the shared code
45 * @hw: pointer to hardware structure
46 *
47 * This will assign function pointers and assign the MAC type and PHY code.
48 * Does not touch the hardware. This function must be called prior to any
49 * other function in the shared code. The ixgbe_hw structure should be
50 * memset to 0 prior to calling this function. The following fields in
51 * hw structure should be filled in prior to calling this function:
52 * back, device_id, vendor_id, subsystem_device_id,
53 * subsystem_vendor_id, and revision_id
54 **/
55 s32 ixgbe_init_shared_code(struct ixgbe_hw *hw)
56 {
57 s32 status;
58
59 DEBUGFUNC("ixgbe_init_shared_code");
60
61 /*
62 * Set the mac type
63 */
64 ixgbe_set_mac_type(hw);
65
66 switch (hw->mac.type) {
67 case ixgbe_mac_82598EB:
68 status = ixgbe_init_ops_82598(hw);
69 break;
70 case ixgbe_mac_82599EB:
71 status = ixgbe_init_ops_82599(hw);
72 break;
73 case ixgbe_mac_82599_vf:
74 status = ixgbe_init_ops_vf(hw);
75 break;
76 default:
77 status = IXGBE_ERR_DEVICE_NOT_SUPPORTED;
78 break;
79 }
80
81 return status;
82 }
83
84 /**
85 * ixgbe_set_mac_type - Sets MAC type
86 * @hw: pointer to the HW structure
87 *
88 * This function sets the mac type of the adapter based on the
89 * vendor ID and device ID stored in the hw structure.
90 **/
91 s32 ixgbe_set_mac_type(struct ixgbe_hw *hw)
92 {
93 s32 ret_val = IXGBE_SUCCESS;
94
95 DEBUGFUNC("ixgbe_set_mac_type\n");
96
97 if (hw->vendor_id == IXGBE_INTEL_VENDOR_ID) {
98 switch (hw->device_id) {
99 case IXGBE_DEV_ID_82598:
100 case IXGBE_DEV_ID_82598_BX:
101 case IXGBE_DEV_ID_82598AF_SINGLE_PORT:
102 case IXGBE_DEV_ID_82598AF_DUAL_PORT:
103 case IXGBE_DEV_ID_82598AT:
104 case IXGBE_DEV_ID_82598AT2:
105 case IXGBE_DEV_ID_82598EB_CX4:
106 case IXGBE_DEV_ID_82598_CX4_DUAL_PORT:
107 case IXGBE_DEV_ID_82598_DA_DUAL_PORT:
108 case IXGBE_DEV_ID_82598_SR_DUAL_PORT_EM:
109 case IXGBE_DEV_ID_82598EB_XF_LR:
110 case IXGBE_DEV_ID_82598EB_SFP_LOM:
111 hw->mac.type = ixgbe_mac_82598EB;
112 break;
113 case IXGBE_DEV_ID_82599_KX4:
114 case IXGBE_DEV_ID_82599_KX4_MEZZ:
115 case IXGBE_DEV_ID_82599_XAUI_LOM:
116 case IXGBE_DEV_ID_82599_COMBO_BACKPLANE:
117 case IXGBE_DEV_ID_82599_SFP:
118 case IXGBE_DEV_ID_82599_BACKPLANE_FCOE:
119 case IXGBE_DEV_ID_82599_SFP_FCOE:
120 case IXGBE_DEV_ID_82599_SFP_SF2:
121 case IXGBE_DEV_ID_82599_SFP_SF_QP:
122 case IXGBE_DEV_ID_82599EN_SFP:
123 case IXGBE_DEV_ID_82599_CX4:
124 case IXGBE_DEV_ID_82599_T3_LOM:
125 hw->mac.type = ixgbe_mac_82599EB;
126 break;
127 case IXGBE_DEV_ID_82599_VF:
128 hw->mac.type = ixgbe_mac_82599_vf;
129 break;
130 default:
131 ret_val = IXGBE_ERR_DEVICE_NOT_SUPPORTED;
132 break;
133 }
134 } else {
135 ret_val = IXGBE_ERR_DEVICE_NOT_SUPPORTED;
136 }
137
138 DEBUGOUT2("ixgbe_set_mac_type found mac: %d, returns: %d\n",
139 hw->mac.type, ret_val);
140 return ret_val;
141 }
142
143 /**
144 * ixgbe_init_hw - Initialize the hardware
145 * @hw: pointer to hardware structure
146 *
147 * Initialize the hardware by resetting and then starting the hardware
148 **/
149 s32 ixgbe_init_hw(struct ixgbe_hw *hw)
150 {
151 return ixgbe_call_func(hw, hw->mac.ops.init_hw, (hw),
152 IXGBE_NOT_IMPLEMENTED);
153 }
154
155 /**
156 * ixgbe_reset_hw - Performs a hardware reset
157 * @hw: pointer to hardware structure
158 *
159 * Resets the hardware by resetting the transmit and receive units, masks and
160 * clears all interrupts, performs a PHY reset, and performs a MAC reset
161 **/
162 s32 ixgbe_reset_hw(struct ixgbe_hw *hw)
163 {
164 return ixgbe_call_func(hw, hw->mac.ops.reset_hw, (hw),
165 IXGBE_NOT_IMPLEMENTED);
166 }
167
168 /**
169 * ixgbe_start_hw - Prepares hardware for Rx/Tx
170 * @hw: pointer to hardware structure
171 *
172 * Starts the hardware by filling the bus info structure and media type,
173 * clears all on chip counters, initializes receive address registers,
174 * multicast table, VLAN filter table, calls routine to setup link and
175 * flow control settings, and leaves transmit and receive units disabled
176 * and uninitialized.
177 **/
178 s32 ixgbe_start_hw(struct ixgbe_hw *hw)
179 {
180 return ixgbe_call_func(hw, hw->mac.ops.start_hw, (hw),
181 IXGBE_NOT_IMPLEMENTED);
182 }
183
184 /**
185 * ixgbe_enable_relaxed_ordering - Enables tx relaxed ordering,
186 * which is disabled by default in ixgbe_start_hw();
187 *
188 * @hw: pointer to hardware structure
189 *
190 * Enable relaxed ordering;
191 **/
192 void ixgbe_enable_relaxed_ordering(struct ixgbe_hw *hw)
193 {
194 if (hw->mac.ops.enable_relaxed_ordering)
195 hw->mac.ops.enable_relaxed_ordering(hw);
196 }
197
198 /**
199 * ixgbe_clear_hw_cntrs - Clear hardware counters
200 * @hw: pointer to hardware structure
201 *
202 * Clears all hardware statistics counters by reading them from the hardware
203 * Statistics counters are clear on read.
204 **/
205 s32 ixgbe_clear_hw_cntrs(struct ixgbe_hw *hw)
206 {
207 return ixgbe_call_func(hw, hw->mac.ops.clear_hw_cntrs, (hw),
208 IXGBE_NOT_IMPLEMENTED);
209 }
210
211 /**
212 * ixgbe_get_media_type - Get media type
213 * @hw: pointer to hardware structure
214 *
215 * Returns the media type (fiber, copper, backplane)
216 **/
217 enum ixgbe_media_type ixgbe_get_media_type(struct ixgbe_hw *hw)
218 {
219 return ixgbe_call_func(hw, hw->mac.ops.get_media_type, (hw),
220 ixgbe_media_type_unknown);
221 }
222
223 /**
224 * ixgbe_get_mac_addr - Get MAC address
225 * @hw: pointer to hardware structure
226 * @mac_addr: Adapter MAC address
227 *
228 * Reads the adapter's MAC address from the first Receive Address Register
229 * (RAR0) A reset of the adapter must have been performed prior to calling
230 * this function in order for the MAC address to have been loaded from the
231 * EEPROM into RAR0
232 **/
233 s32 ixgbe_get_mac_addr(struct ixgbe_hw *hw, u8 *mac_addr)
234 {
235 return ixgbe_call_func(hw, hw->mac.ops.get_mac_addr,
236 (hw, mac_addr), IXGBE_NOT_IMPLEMENTED);
237 }
238
239 /**
240 * ixgbe_get_san_mac_addr - Get SAN MAC address
241 * @hw: pointer to hardware structure
242 * @san_mac_addr: SAN MAC address
243 *
244 * Reads the SAN MAC address from the EEPROM, if it's available. This is
245 * per-port, so set_lan_id() must be called before reading the addresses.
246 **/
247 s32 ixgbe_get_san_mac_addr(struct ixgbe_hw *hw, u8 *san_mac_addr)
248 {
249 return ixgbe_call_func(hw, hw->mac.ops.get_san_mac_addr,
250 (hw, san_mac_addr), IXGBE_NOT_IMPLEMENTED);
251 }
252
253 /**
254 * ixgbe_set_san_mac_addr - Write a SAN MAC address
255 * @hw: pointer to hardware structure
256 * @san_mac_addr: SAN MAC address
257 *
258 * Writes A SAN MAC address to the EEPROM.
259 **/
260 s32 ixgbe_set_san_mac_addr(struct ixgbe_hw *hw, u8 *san_mac_addr)
261 {
262 return ixgbe_call_func(hw, hw->mac.ops.set_san_mac_addr,
263 (hw, san_mac_addr), IXGBE_NOT_IMPLEMENTED);
264 }
265
266 /**
267 * ixgbe_get_device_caps - Get additional device capabilities
268 * @hw: pointer to hardware structure
269 * @device_caps: the EEPROM word for device capabilities
270 *
271 * Reads the extra device capabilities from the EEPROM
272 **/
273 s32 ixgbe_get_device_caps(struct ixgbe_hw *hw, u16 *device_caps)
274 {
275 return ixgbe_call_func(hw, hw->mac.ops.get_device_caps,
276 (hw, device_caps), IXGBE_NOT_IMPLEMENTED);
277 }
278
279 /**
280 * ixgbe_get_wwn_prefix - Get alternative WWNN/WWPN prefix from the EEPROM
281 * @hw: pointer to hardware structure
282 * @wwnn_prefix: the alternative WWNN prefix
283 * @wwpn_prefix: the alternative WWPN prefix
284 *
285 * This function will read the EEPROM from the alternative SAN MAC address
286 * block to check the support for the alternative WWNN/WWPN prefix support.
287 **/
288 s32 ixgbe_get_wwn_prefix(struct ixgbe_hw *hw, u16 *wwnn_prefix,
289 u16 *wwpn_prefix)
290 {
291 return ixgbe_call_func(hw, hw->mac.ops.get_wwn_prefix,
292 (hw, wwnn_prefix, wwpn_prefix),
293 IXGBE_NOT_IMPLEMENTED);
294 }
295
296 /**
297 * ixgbe_get_fcoe_boot_status - Get FCOE boot status from EEPROM
298 * @hw: pointer to hardware structure
299 * @bs: the fcoe boot status
300 *
301 * This function will read the FCOE boot status from the iSCSI FCOE block
302 **/
303 s32 ixgbe_get_fcoe_boot_status(struct ixgbe_hw *hw, u16 *bs)
304 {
305 return ixgbe_call_func(hw, hw->mac.ops.get_fcoe_boot_status,
306 (hw, bs),
307 IXGBE_NOT_IMPLEMENTED);
308 }
309
310 /**
311 * ixgbe_get_bus_info - Set PCI bus info
312 * @hw: pointer to hardware structure
313 *
314 * Sets the PCI bus info (speed, width, type) within the ixgbe_hw structure
315 **/
316 s32 ixgbe_get_bus_info(struct ixgbe_hw *hw)
317 {
318 return ixgbe_call_func(hw, hw->mac.ops.get_bus_info, (hw),
319 IXGBE_NOT_IMPLEMENTED);
320 }
321
322 /**
323 * ixgbe_get_num_of_tx_queues - Get Tx queues
324 * @hw: pointer to hardware structure
325 *
326 * Returns the number of transmit queues for the given adapter.
327 **/
328 u32 ixgbe_get_num_of_tx_queues(struct ixgbe_hw *hw)
329 {
330 return hw->mac.max_tx_queues;
331 }
332
333 /**
334 * ixgbe_get_num_of_rx_queues - Get Rx queues
335 * @hw: pointer to hardware structure
336 *
337 * Returns the number of receive queues for the given adapter.
338 **/
339 u32 ixgbe_get_num_of_rx_queues(struct ixgbe_hw *hw)
340 {
341 return hw->mac.max_rx_queues;
342 }
343
344 /**
345 * ixgbe_stop_adapter - Disable Rx/Tx units
346 * @hw: pointer to hardware structure
347 *
348 * Sets the adapter_stopped flag within ixgbe_hw struct. Clears interrupts,
349 * disables transmit and receive units. The adapter_stopped flag is used by
350 * the shared code and drivers to determine if the adapter is in a stopped
351 * state and should not touch the hardware.
352 **/
353 s32 ixgbe_stop_adapter(struct ixgbe_hw *hw)
354 {
355 return ixgbe_call_func(hw, hw->mac.ops.stop_adapter, (hw),
356 IXGBE_NOT_IMPLEMENTED);
357 }
358
359 /**
360 * ixgbe_read_pba_string - Reads part number string from EEPROM
361 * @hw: pointer to hardware structure
362 * @pba_num: stores the part number string from the EEPROM
363 * @pba_num_size: part number string buffer length
364 *
365 * Reads the part number string from the EEPROM.
366 **/
367 s32 ixgbe_read_pba_string(struct ixgbe_hw *hw, u8 *pba_num, u32 pba_num_size)
368 {
369 return ixgbe_read_pba_string_generic(hw, pba_num, pba_num_size);
370 }
371
372 /**
373 * ixgbe_read_pba_length - Reads part number string length from EEPROM
374 * @hw: pointer to hardware structure
375 * @pba_num_size: part number string buffer length
376 *
377 * Reads the part number length from the EEPROM.
378 * Returns expected buffer size in pba_num_size.
379 **/
380 s32 ixgbe_read_pba_length(struct ixgbe_hw *hw, u32 *pba_num_size)
381 {
382 return ixgbe_read_pba_length_generic(hw, pba_num_size);
383 }
384
385 /**
386 * ixgbe_read_pba_num - Reads part number from EEPROM
387 * @hw: pointer to hardware structure
388 * @pba_num: stores the part number from the EEPROM
389 *
390 * Reads the part number from the EEPROM.
391 **/
392 s32 ixgbe_read_pba_num(struct ixgbe_hw *hw, u32 *pba_num)
393 {
394 return ixgbe_read_pba_num_generic(hw, pba_num);
395 }
396
397 /**
398 * ixgbe_identify_phy - Get PHY type
399 * @hw: pointer to hardware structure
400 *
401 * Determines the physical layer module found on the current adapter.
402 **/
403 s32 ixgbe_identify_phy(struct ixgbe_hw *hw)
404 {
405 s32 status = IXGBE_SUCCESS;
406
407 if (hw->phy.type == ixgbe_phy_unknown) {
408 status = ixgbe_call_func(hw, hw->phy.ops.identify, (hw),
409 IXGBE_NOT_IMPLEMENTED);
410 }
411
412 return status;
413 }
414
415 /**
416 * ixgbe_reset_phy - Perform a PHY reset
417 * @hw: pointer to hardware structure
418 **/
419 s32 ixgbe_reset_phy(struct ixgbe_hw *hw)
420 {
421 s32 status = IXGBE_SUCCESS;
422
423 if (hw->phy.type == ixgbe_phy_unknown) {
424 if (ixgbe_identify_phy(hw) != IXGBE_SUCCESS)
425 status = IXGBE_ERR_PHY;
426 }
427
428 if (status == IXGBE_SUCCESS) {
429 status = ixgbe_call_func(hw, hw->phy.ops.reset, (hw),
430 IXGBE_NOT_IMPLEMENTED);
431 }
432 return status;
433 }
434
435 /**
436 * ixgbe_get_phy_firmware_version -
437 * @hw: pointer to hardware structure
438 * @firmware_version: pointer to firmware version
439 **/
440 s32 ixgbe_get_phy_firmware_version(struct ixgbe_hw *hw, u16 *firmware_version)
441 {
442 s32 status = IXGBE_SUCCESS;
443
444 status = ixgbe_call_func(hw, hw->phy.ops.get_firmware_version,
445 (hw, firmware_version),
446 IXGBE_NOT_IMPLEMENTED);
447 return status;
448 }
449
450 /**
451 * ixgbe_read_phy_reg - Read PHY register
452 * @hw: pointer to hardware structure
453 * @reg_addr: 32 bit address of PHY register to read
454 * @phy_data: Pointer to read data from PHY register
455 *
456 * Reads a value from a specified PHY register
457 **/
458 s32 ixgbe_read_phy_reg(struct ixgbe_hw *hw, u32 reg_addr, u32 device_type,
459 u16 *phy_data)
460 {
461 if (hw->phy.id == 0)
462 ixgbe_identify_phy(hw);
463
464 return ixgbe_call_func(hw, hw->phy.ops.read_reg, (hw, reg_addr,
465 device_type, phy_data), IXGBE_NOT_IMPLEMENTED);
466 }
467
468 /**
469 * ixgbe_write_phy_reg - Write PHY register
470 * @hw: pointer to hardware structure
471 * @reg_addr: 32 bit PHY register to write
472 * @phy_data: Data to write to the PHY register
473 *
474 * Writes a value to specified PHY register
475 **/
476 s32 ixgbe_write_phy_reg(struct ixgbe_hw *hw, u32 reg_addr, u32 device_type,
477 u16 phy_data)
478 {
479 if (hw->phy.id == 0)
480 ixgbe_identify_phy(hw);
481
482 return ixgbe_call_func(hw, hw->phy.ops.write_reg, (hw, reg_addr,
483 device_type, phy_data), IXGBE_NOT_IMPLEMENTED);
484 }
485
486 /**
487 * ixgbe_setup_phy_link - Restart PHY autoneg
488 * @hw: pointer to hardware structure
489 *
490 * Restart autonegotiation and PHY and waits for completion.
491 **/
492 s32 ixgbe_setup_phy_link(struct ixgbe_hw *hw)
493 {
494 return ixgbe_call_func(hw, hw->phy.ops.setup_link, (hw),
495 IXGBE_NOT_IMPLEMENTED);
496 }
497
498 /**
499 * ixgbe_check_phy_link - Determine link and speed status
500 * @hw: pointer to hardware structure
501 *
502 * Reads a PHY register to determine if link is up and the current speed for
503 * the PHY.
504 **/
505 s32 ixgbe_check_phy_link(struct ixgbe_hw *hw, ixgbe_link_speed *speed,
506 bool *link_up)
507 {
508 return ixgbe_call_func(hw, hw->phy.ops.check_link, (hw, speed,
509 link_up), IXGBE_NOT_IMPLEMENTED);
510 }
511
512 /**
513 * ixgbe_setup_phy_link_speed - Set auto advertise
514 * @hw: pointer to hardware structure
515 * @speed: new link speed
516 * @autoneg: TRUE if autonegotiation enabled
517 *
518 * Sets the auto advertised capabilities
519 **/
520 s32 ixgbe_setup_phy_link_speed(struct ixgbe_hw *hw, ixgbe_link_speed speed,
521 bool autoneg,
522 bool autoneg_wait_to_complete)
523 {
524 return ixgbe_call_func(hw, hw->phy.ops.setup_link_speed, (hw, speed,
525 autoneg, autoneg_wait_to_complete),
526 IXGBE_NOT_IMPLEMENTED);
527 }
528
529 /**
530 * ixgbe_check_link - Get link and speed status
531 * @hw: pointer to hardware structure
532 *
533 * Reads the links register to determine if link is up and the current speed
534 **/
535 s32 ixgbe_check_link(struct ixgbe_hw *hw, ixgbe_link_speed *speed,
536 bool *link_up, bool link_up_wait_to_complete)
537 {
538 return ixgbe_call_func(hw, hw->mac.ops.check_link, (hw, speed,
539 link_up, link_up_wait_to_complete),
540 IXGBE_NOT_IMPLEMENTED);
541 }
542
543 /**
544 * ixgbe_disable_tx_laser - Disable Tx laser
545 * @hw: pointer to hardware structure
546 *
547 * If the driver needs to disable the laser on SFI optics.
548 **/
549 void ixgbe_disable_tx_laser(struct ixgbe_hw *hw)
550 {
551 if (hw->mac.ops.disable_tx_laser)
552 hw->mac.ops.disable_tx_laser(hw);
553 }
554
555 /**
556 * ixgbe_enable_tx_laser - Enable Tx laser
557 * @hw: pointer to hardware structure
558 *
559 * If the driver needs to enable the laser on SFI optics.
560 **/
561 void ixgbe_enable_tx_laser(struct ixgbe_hw *hw)
562 {
563 if (hw->mac.ops.enable_tx_laser)
564 hw->mac.ops.enable_tx_laser(hw);
565 }
566
567 /**
568 * ixgbe_flap_tx_laser - flap Tx laser to start autotry process
569 * @hw: pointer to hardware structure
570 *
571 * When the driver changes the link speeds that it can support then
572 * flap the tx laser to alert the link partner to start autotry
573 * process on its end.
574 **/
575 void ixgbe_flap_tx_laser(struct ixgbe_hw *hw)
576 {
577 if (hw->mac.ops.flap_tx_laser)
578 hw->mac.ops.flap_tx_laser(hw);
579 }
580
581 /**
582 * ixgbe_setup_link - Set link speed
583 * @hw: pointer to hardware structure
584 * @speed: new link speed
585 * @autoneg: TRUE if autonegotiation enabled
586 *
587 * Configures link settings. Restarts the link.
588 * Performs autonegotiation if needed.
589 **/
590 s32 ixgbe_setup_link(struct ixgbe_hw *hw, ixgbe_link_speed speed,
591 bool autoneg,
592 bool autoneg_wait_to_complete)
593 {
594 return ixgbe_call_func(hw, hw->mac.ops.setup_link, (hw, speed,
595 autoneg, autoneg_wait_to_complete),
596 IXGBE_NOT_IMPLEMENTED);
597 }
598
599 /**
600 * ixgbe_get_link_capabilities - Returns link capabilities
601 * @hw: pointer to hardware structure
602 *
603 * Determines the link capabilities of the current configuration.
604 **/
605 s32 ixgbe_get_link_capabilities(struct ixgbe_hw *hw, ixgbe_link_speed *speed,
606 bool *autoneg)
607 {
608 return ixgbe_call_func(hw, hw->mac.ops.get_link_capabilities, (hw,
609 speed, autoneg), IXGBE_NOT_IMPLEMENTED);
610 }
611
612 /**
613 * ixgbe_led_on - Turn on LEDs
614 * @hw: pointer to hardware structure
615 * @index: led number to turn on
616 *
617 * Turns on the software controllable LEDs.
618 **/
619 s32 ixgbe_led_on(struct ixgbe_hw *hw, u32 index)
620 {
621 return ixgbe_call_func(hw, hw->mac.ops.led_on, (hw, index),
622 IXGBE_NOT_IMPLEMENTED);
623 }
624
625 /**
626 * ixgbe_led_off - Turn off LEDs
627 * @hw: pointer to hardware structure
628 * @index: led number to turn off
629 *
630 * Turns off the software controllable LEDs.
631 **/
632 s32 ixgbe_led_off(struct ixgbe_hw *hw, u32 index)
633 {
634 return ixgbe_call_func(hw, hw->mac.ops.led_off, (hw, index),
635 IXGBE_NOT_IMPLEMENTED);
636 }
637
638 /**
639 * ixgbe_blink_led_start - Blink LEDs
640 * @hw: pointer to hardware structure
641 * @index: led number to blink
642 *
643 * Blink LED based on index.
644 **/
645 s32 ixgbe_blink_led_start(struct ixgbe_hw *hw, u32 index)
646 {
647 return ixgbe_call_func(hw, hw->mac.ops.blink_led_start, (hw, index),
648 IXGBE_NOT_IMPLEMENTED);
649 }
650
651 /**
652 * ixgbe_blink_led_stop - Stop blinking LEDs
653 * @hw: pointer to hardware structure
654 *
655 * Stop blinking LED based on index.
656 **/
657 s32 ixgbe_blink_led_stop(struct ixgbe_hw *hw, u32 index)
658 {
659 return ixgbe_call_func(hw, hw->mac.ops.blink_led_stop, (hw, index),
660 IXGBE_NOT_IMPLEMENTED);
661 }
662
663 /**
664 * ixgbe_init_eeprom_params - Initialize EEPROM parameters
665 * @hw: pointer to hardware structure
666 *
667 * Initializes the EEPROM parameters ixgbe_eeprom_info within the
668 * ixgbe_hw struct in order to set up EEPROM access.
669 **/
670 s32 ixgbe_init_eeprom_params(struct ixgbe_hw *hw)
671 {
672 return ixgbe_call_func(hw, hw->eeprom.ops.init_params, (hw),
673 IXGBE_NOT_IMPLEMENTED);
674 }
675
676
677 /**
678 * ixgbe_write_eeprom - Write word to EEPROM
679 * @hw: pointer to hardware structure
680 * @offset: offset within the EEPROM to be written to
681 * @data: 16 bit word to be written to the EEPROM
682 *
683 * Writes 16 bit value to EEPROM. If ixgbe_eeprom_update_checksum is not
684 * called after this function, the EEPROM will most likely contain an
685 * invalid checksum.
686 **/
687 s32 ixgbe_write_eeprom(struct ixgbe_hw *hw, u16 offset, u16 data)
688 {
689 return ixgbe_call_func(hw, hw->eeprom.ops.write, (hw, offset, data),
690 IXGBE_NOT_IMPLEMENTED);
691 }
692
693 /**
694 * ixgbe_read_eeprom - Read word from EEPROM
695 * @hw: pointer to hardware structure
696 * @offset: offset within the EEPROM to be read
697 * @data: read 16 bit value from EEPROM
698 *
699 * Reads 16 bit value from EEPROM
700 **/
701 s32 ixgbe_read_eeprom(struct ixgbe_hw *hw, u16 offset, u16 *data)
702 {
703 return ixgbe_call_func(hw, hw->eeprom.ops.read, (hw, offset, data),
704 IXGBE_NOT_IMPLEMENTED);
705 }
706
707 /**
708 * ixgbe_validate_eeprom_checksum - Validate EEPROM checksum
709 * @hw: pointer to hardware structure
710 * @checksum_val: calculated checksum
711 *
712 * Performs checksum calculation and validates the EEPROM checksum
713 **/
714 s32 ixgbe_validate_eeprom_checksum(struct ixgbe_hw *hw, u16 *checksum_val)
715 {
716 return ixgbe_call_func(hw, hw->eeprom.ops.validate_checksum,
717 (hw, checksum_val), IXGBE_NOT_IMPLEMENTED);
718 }
719
720 /**
721 * ixgbe_eeprom_update_checksum - Updates the EEPROM checksum
722 * @hw: pointer to hardware structure
723 **/
724 s32 ixgbe_update_eeprom_checksum(struct ixgbe_hw *hw)
725 {
726 return ixgbe_call_func(hw, hw->eeprom.ops.update_checksum, (hw),
727 IXGBE_NOT_IMPLEMENTED);
728 }
729
730 /**
731 * ixgbe_insert_mac_addr - Find a RAR for this mac address
732 * @hw: pointer to hardware structure
733 * @addr: Address to put into receive address register
734 * @vmdq: VMDq pool to assign
735 *
736 * Puts an ethernet address into a receive address register, or
737 * finds the rar that it is aleady in; adds to the pool list
738 **/
739 s32 ixgbe_insert_mac_addr(struct ixgbe_hw *hw, u8 *addr, u32 vmdq)
740 {
741 return ixgbe_call_func(hw, hw->mac.ops.insert_mac_addr,
742 (hw, addr, vmdq),
743 IXGBE_NOT_IMPLEMENTED);
744 }
745
746 /**
747 * ixgbe_set_rar - Set Rx address register
748 * @hw: pointer to hardware structure
749 * @index: Receive address register to write
750 * @addr: Address to put into receive address register
751 * @vmdq: VMDq "set"
752 * @enable_addr: set flag that address is active
753 *
754 * Puts an ethernet address into a receive address register.
755 **/
756 s32 ixgbe_set_rar(struct ixgbe_hw *hw, u32 index, u8 *addr, u32 vmdq,
757 u32 enable_addr)
758 {
759 return ixgbe_call_func(hw, hw->mac.ops.set_rar, (hw, index, addr, vmdq,
760 enable_addr), IXGBE_NOT_IMPLEMENTED);
761 }
762
763 /**
764 * ixgbe_clear_rar - Clear Rx address register
765 * @hw: pointer to hardware structure
766 * @index: Receive address register to write
767 *
768 * Puts an ethernet address into a receive address register.
769 **/
770 s32 ixgbe_clear_rar(struct ixgbe_hw *hw, u32 index)
771 {
772 return ixgbe_call_func(hw, hw->mac.ops.clear_rar, (hw, index),
773 IXGBE_NOT_IMPLEMENTED);
774 }
775
776 /**
777 * ixgbe_set_vmdq - Associate a VMDq index with a receive address
778 * @hw: pointer to hardware structure
779 * @rar: receive address register index to associate with VMDq index
780 * @vmdq: VMDq set or pool index
781 **/
782 s32 ixgbe_set_vmdq(struct ixgbe_hw *hw, u32 rar, u32 vmdq)
783 {
784 return ixgbe_call_func(hw, hw->mac.ops.set_vmdq, (hw, rar, vmdq),
785 IXGBE_NOT_IMPLEMENTED);
786 }
787
788 /**
789 * ixgbe_clear_vmdq - Disassociate a VMDq index from a receive address
790 * @hw: pointer to hardware structure
791 * @rar: receive address register index to disassociate with VMDq index
792 * @vmdq: VMDq set or pool index
793 **/
794 s32 ixgbe_clear_vmdq(struct ixgbe_hw *hw, u32 rar, u32 vmdq)
795 {
796 return ixgbe_call_func(hw, hw->mac.ops.clear_vmdq, (hw, rar, vmdq),
797 IXGBE_NOT_IMPLEMENTED);
798 }
799
800 /**
801 * ixgbe_init_rx_addrs - Initializes receive address filters.
802 * @hw: pointer to hardware structure
803 *
804 * Places the MAC address in receive address register 0 and clears the rest
805 * of the receive address registers. Clears the multicast table. Assumes
806 * the receiver is in reset when the routine is called.
807 **/
808 s32 ixgbe_init_rx_addrs(struct ixgbe_hw *hw)
809 {
810 return ixgbe_call_func(hw, hw->mac.ops.init_rx_addrs, (hw),
811 IXGBE_NOT_IMPLEMENTED);
812 }
813
814 /**
815 * ixgbe_get_num_rx_addrs - Returns the number of RAR entries.
816 * @hw: pointer to hardware structure
817 **/
818 u32 ixgbe_get_num_rx_addrs(struct ixgbe_hw *hw)
819 {
820 return hw->mac.num_rar_entries;
821 }
822
823 /**
824 * ixgbe_update_uc_addr_list - Updates the MAC's list of secondary addresses
825 * @hw: pointer to hardware structure
826 * @addr_list: the list of new multicast addresses
827 * @addr_count: number of addresses
828 * @func: iterator function to walk the multicast address list
829 *
830 * The given list replaces any existing list. Clears the secondary addrs from
831 * receive address registers. Uses unused receive address registers for the
832 * first secondary addresses, and falls back to promiscuous mode as needed.
833 **/
834 s32 ixgbe_update_uc_addr_list(struct ixgbe_hw *hw, u8 *addr_list,
835 u32 addr_count, ixgbe_mc_addr_itr func)
836 {
837 return ixgbe_call_func(hw, hw->mac.ops.update_uc_addr_list, (hw,
838 addr_list, addr_count, func),
839 IXGBE_NOT_IMPLEMENTED);
840 }
841
842 /**
843 * ixgbe_update_mc_addr_list - Updates the MAC's list of multicast addresses
844 * @hw: pointer to hardware structure
845 * @mc_addr_list: the list of new multicast addresses
846 * @mc_addr_count: number of addresses
847 * @func: iterator function to walk the multicast address list
848 *
849 * The given list replaces any existing list. Clears the MC addrs from receive
850 * address registers and the multicast table. Uses unused receive address
851 * registers for the first multicast addresses, and hashes the rest into the
852 * multicast table.
853 **/
854 s32 ixgbe_update_mc_addr_list(struct ixgbe_hw *hw, u8 *mc_addr_list,
855 u32 mc_addr_count, ixgbe_mc_addr_itr func)
856 {
857 return ixgbe_call_func(hw, hw->mac.ops.update_mc_addr_list, (hw,
858 mc_addr_list, mc_addr_count, func),
859 IXGBE_NOT_IMPLEMENTED);
860 }
861
862 /**
863 * ixgbe_enable_mc - Enable multicast address in RAR
864 * @hw: pointer to hardware structure
865 *
866 * Enables multicast address in RAR and the use of the multicast hash table.
867 **/
868 s32 ixgbe_enable_mc(struct ixgbe_hw *hw)
869 {
870 return ixgbe_call_func(hw, hw->mac.ops.enable_mc, (hw),
871 IXGBE_NOT_IMPLEMENTED);
872 }
873
874 /**
875 * ixgbe_disable_mc - Disable multicast address in RAR
876 * @hw: pointer to hardware structure
877 *
878 * Disables multicast address in RAR and the use of the multicast hash table.
879 **/
880 s32 ixgbe_disable_mc(struct ixgbe_hw *hw)
881 {
882 return ixgbe_call_func(hw, hw->mac.ops.disable_mc, (hw),
883 IXGBE_NOT_IMPLEMENTED);
884 }
885
886 /**
887 * ixgbe_clear_vfta - Clear VLAN filter table
888 * @hw: pointer to hardware structure
889 *
890 * Clears the VLAN filer table, and the VMDq index associated with the filter
891 **/
892 s32 ixgbe_clear_vfta(struct ixgbe_hw *hw)
893 {
894 return ixgbe_call_func(hw, hw->mac.ops.clear_vfta, (hw),
895 IXGBE_NOT_IMPLEMENTED);
896 }
897
898 /**
899 * ixgbe_set_vfta - Set VLAN filter table
900 * @hw: pointer to hardware structure
901 * @vlan: VLAN id to write to VLAN filter
902 * @vind: VMDq output index that maps queue to VLAN id in VFTA
903 * @vlan_on: boolean flag to turn on/off VLAN in VFTA
904 *
905 * Turn on/off specified VLAN in the VLAN filter table.
906 **/
907 s32 ixgbe_set_vfta(struct ixgbe_hw *hw, u32 vlan, u32 vind, bool vlan_on)
908 {
909 return ixgbe_call_func(hw, hw->mac.ops.set_vfta, (hw, vlan, vind,
910 vlan_on), IXGBE_NOT_IMPLEMENTED);
911 }
912
913 /**
914 * ixgbe_fc_enable - Enable flow control
915 * @hw: pointer to hardware structure
916 * @packetbuf_num: packet buffer number (0-7)
917 *
918 * Configures the flow control settings based on SW configuration.
919 **/
920 s32 ixgbe_fc_enable(struct ixgbe_hw *hw, s32 packetbuf_num)
921 {
922 return ixgbe_call_func(hw, hw->mac.ops.fc_enable, (hw, packetbuf_num),
923 IXGBE_NOT_IMPLEMENTED);
924 }
925
926 /**
927 * ixgbe_read_analog_reg8 - Reads 8 bit analog register
928 * @hw: pointer to hardware structure
929 * @reg: analog register to read
930 * @val: read value
931 *
932 * Performs write operation to analog register specified.
933 **/
934 s32 ixgbe_read_analog_reg8(struct ixgbe_hw *hw, u32 reg, u8 *val)
935 {
936 return ixgbe_call_func(hw, hw->mac.ops.read_analog_reg8, (hw, reg,
937 val), IXGBE_NOT_IMPLEMENTED);
938 }
939
940 /**
941 * ixgbe_write_analog_reg8 - Writes 8 bit analog register
942 * @hw: pointer to hardware structure
943 * @reg: analog register to write
944 * @val: value to write
945 *
946 * Performs write operation to Atlas analog register specified.
947 **/
948 s32 ixgbe_write_analog_reg8(struct ixgbe_hw *hw, u32 reg, u8 val)
949 {
950 return ixgbe_call_func(hw, hw->mac.ops.write_analog_reg8, (hw, reg,
951 val), IXGBE_NOT_IMPLEMENTED);
952 }
953
954 /**
955 * ixgbe_init_uta_tables - Initializes Unicast Table Arrays.
956 * @hw: pointer to hardware structure
957 *
958 * Initializes the Unicast Table Arrays to zero on device load. This
959 * is part of the Rx init addr execution path.
960 **/
961 s32 ixgbe_init_uta_tables(struct ixgbe_hw *hw)
962 {
963 return ixgbe_call_func(hw, hw->mac.ops.init_uta_tables, (hw),
964 IXGBE_NOT_IMPLEMENTED);
965 }
966
967 /**
968 * ixgbe_read_i2c_byte - Reads 8 bit word over I2C at specified device address
969 * @hw: pointer to hardware structure
970 * @byte_offset: byte offset to read
971 * @data: value read
972 *
973 * Performs byte read operation to SFP module's EEPROM over I2C interface.
974 **/
975 s32 ixgbe_read_i2c_byte(struct ixgbe_hw *hw, u8 byte_offset, u8 dev_addr,
976 u8 *data)
977 {
978 return ixgbe_call_func(hw, hw->phy.ops.read_i2c_byte, (hw, byte_offset,
979 dev_addr, data), IXGBE_NOT_IMPLEMENTED);
980 }
981
982 /**
983 * ixgbe_write_i2c_byte - Writes 8 bit word over I2C
984 * @hw: pointer to hardware structure
985 * @byte_offset: byte offset to write
986 * @data: value to write
987 *
988 * Performs byte write operation to SFP module's EEPROM over I2C interface
989 * at a specified device address.
990 **/
991 s32 ixgbe_write_i2c_byte(struct ixgbe_hw *hw, u8 byte_offset, u8 dev_addr,
992 u8 data)
993 {
994 return ixgbe_call_func(hw, hw->phy.ops.write_i2c_byte, (hw, byte_offset,
995 dev_addr, data), IXGBE_NOT_IMPLEMENTED);
996 }
997
998 /**
999 * ixgbe_write_i2c_eeprom - Writes 8 bit EEPROM word over I2C interface
1000 * @hw: pointer to hardware structure
1001 * @byte_offset: EEPROM byte offset to write
1002 * @eeprom_data: value to write
1003 *
1004 * Performs byte write operation to SFP module's EEPROM over I2C interface.
1005 **/
1006 s32 ixgbe_write_i2c_eeprom(struct ixgbe_hw *hw,
1007 u8 byte_offset, u8 eeprom_data)
1008 {
1009 return ixgbe_call_func(hw, hw->phy.ops.write_i2c_eeprom,
1010 (hw, byte_offset, eeprom_data),
1011 IXGBE_NOT_IMPLEMENTED);
1012 }
1013
1014 /**
1015 * ixgbe_read_i2c_eeprom - Reads 8 bit EEPROM word over I2C interface
1016 * @hw: pointer to hardware structure
1017 * @byte_offset: EEPROM byte offset to read
1018 * @eeprom_data: value read
1019 *
1020 * Performs byte read operation to SFP module's EEPROM over I2C interface.
1021 **/
1022 s32 ixgbe_read_i2c_eeprom(struct ixgbe_hw *hw, u8 byte_offset, u8 *eeprom_data)
1023 {
1024 return ixgbe_call_func(hw, hw->phy.ops.read_i2c_eeprom,
1025 (hw, byte_offset, eeprom_data),
1026 IXGBE_NOT_IMPLEMENTED);
1027 }
1028
1029 /**
1030 * ixgbe_get_supported_physical_layer - Returns physical layer type
1031 * @hw: pointer to hardware structure
1032 *
1033 * Determines physical layer capabilities of the current configuration.
1034 **/
1035 u32 ixgbe_get_supported_physical_layer(struct ixgbe_hw *hw)
1036 {
1037 return ixgbe_call_func(hw, hw->mac.ops.get_supported_physical_layer,
1038 (hw), IXGBE_PHYSICAL_LAYER_UNKNOWN);
1039 }
1040
1041 /**
1042 * ixgbe_enable_rx_dma - Enables Rx DMA unit, dependant on device specifics
1043 * @hw: pointer to hardware structure
1044 * @regval: bitfield to write to the Rx DMA register
1045 *
1046 * Enables the Rx DMA unit of the device.
1047 **/
1048 s32 ixgbe_enable_rx_dma(struct ixgbe_hw *hw, u32 regval)
1049 {
1050 return ixgbe_call_func(hw, hw->mac.ops.enable_rx_dma,
1051 (hw, regval), IXGBE_NOT_IMPLEMENTED);
1052 }
1053
1054 /**
1055 * ixgbe_acquire_swfw_semaphore - Acquire SWFW semaphore
1056 * @hw: pointer to hardware structure
1057 * @mask: Mask to specify which semaphore to acquire
1058 *
1059 * Acquires the SWFW semaphore through SW_FW_SYNC register for the specified
1060 * function (CSR, PHY0, PHY1, EEPROM, Flash)
1061 **/
1062 s32 ixgbe_acquire_swfw_semaphore(struct ixgbe_hw *hw, u16 mask)
1063 {
1064 return ixgbe_call_func(hw, hw->mac.ops.acquire_swfw_sync,
1065 (hw, mask), IXGBE_NOT_IMPLEMENTED);
1066 }
1067
1068 /**
1069 * ixgbe_release_swfw_semaphore - Release SWFW semaphore
1070 * @hw: pointer to hardware structure
1071 * @mask: Mask to specify which semaphore to release
1072 *
1073 * Releases the SWFW semaphore through SW_FW_SYNC register for the specified
1074 * function (CSR, PHY0, PHY1, EEPROM, Flash)
1075 **/
1076 void ixgbe_release_swfw_semaphore(struct ixgbe_hw *hw, u16 mask)
1077 {
1078 if (hw->mac.ops.release_swfw_sync)
1079 hw->mac.ops.release_swfw_sync(hw, mask);
1080 }
1081
1082