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