1 /*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright (c) 2007-2012 Intel Corporation. All rights reserved.
24 */
25
26 /*
27 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
28 */
29
30 /* IntelVersion: 1.129.2.1 v3_3_14_3_BHSW1 */
31
32 #include "igb_api.h"
33
34 /*
35 * e1000_init_mac_params - Initialize MAC function pointers
36 * @hw: pointer to the HW structure
37 *
38 * This function initializes the function pointers for the MAC
39 * set of functions. Called by drivers or by e1000_setup_init_funcs.
40 */
41 s32
42 e1000_init_mac_params(struct e1000_hw *hw)
43 {
44 s32 ret_val = E1000_SUCCESS;
45
46 if (hw->mac.ops.init_params) {
47 ret_val = hw->mac.ops.init_params(hw);
48 if (ret_val) {
49 DEBUGOUT("MAC Initialization Error\n");
50 goto out;
51 }
52 } else {
53 DEBUGOUT("mac.init_mac_params was NULL\n");
54 ret_val = -E1000_ERR_CONFIG;
55 }
56
57 out:
58 return (ret_val);
59 }
60
61 /*
62 * e1000_init_nvm_params - Initialize NVM function pointers
63 * @hw: pointer to the HW structure
64 *
65 * This function initializes the function pointers for the NVM
66 * set of functions. Called by drivers or by e1000_setup_init_funcs.
67 */
68 s32
69 e1000_init_nvm_params(struct e1000_hw *hw)
70 {
71 s32 ret_val = E1000_SUCCESS;
72
73 if (hw->nvm.ops.init_params) {
74 ret_val = hw->nvm.ops.init_params(hw);
75 if (ret_val) {
76 DEBUGOUT("NVM Initialization Error\n");
77 goto out;
78 }
79 } else {
80 DEBUGOUT("nvm.init_nvm_params was NULL\n");
81 ret_val = -E1000_ERR_CONFIG;
82 }
83
84 out:
85 return (ret_val);
86 }
87
88 /*
89 * e1000_init_phy_params - Initialize PHY function pointers
90 * @hw: pointer to the HW structure
91 *
92 * This function initializes the function pointers for the PHY
93 * set of functions. Called by drivers or by e1000_setup_init_funcs.
94 */
95 s32
96 e1000_init_phy_params(struct e1000_hw *hw)
97 {
98 s32 ret_val = E1000_SUCCESS;
99
100 if (hw->phy.ops.init_params) {
101 ret_val = hw->phy.ops.init_params(hw);
102 if (ret_val) {
103 DEBUGOUT("PHY Initialization Error\n");
104 goto out;
105 }
106 } else {
107 DEBUGOUT("phy.init_phy_params was NULL\n");
108 ret_val = -E1000_ERR_CONFIG;
109 }
110
111 out:
112 return (ret_val);
113 }
114
115 /*
116 * e1000_set_mac_type - Sets MAC type
117 * @hw: pointer to the HW structure
118 *
119 * This function sets the mac type of the adapter based on the
120 * device ID stored in the hw structure.
121 * MUST BE FIRST FUNCTION CALLED (explicitly or through
122 * e1000_setup_init_funcs()).
123 */
124 s32
125 e1000_set_mac_type(struct e1000_hw *hw)
126 {
127 struct e1000_mac_info *mac = &hw->mac;
128 s32 ret_val = E1000_SUCCESS;
129
130 DEBUGFUNC("e1000_set_mac_type");
131
132 switch (hw->device_id) {
133 case E1000_DEV_ID_82575EB_COPPER:
134 case E1000_DEV_ID_82575EB_FIBER_SERDES:
135 case E1000_DEV_ID_82575GB_QUAD_COPPER:
136 mac->type = e1000_82575;
137 break;
138 case E1000_DEV_ID_82576:
139 case E1000_DEV_ID_82576_FIBER:
140 case E1000_DEV_ID_82576_SERDES:
141 case E1000_DEV_ID_82576_QUAD_COPPER:
142 case E1000_DEV_ID_82576_QUAD_COPPER_ET2:
143 case E1000_DEV_ID_82576_NS:
144 case E1000_DEV_ID_82576_NS_SERDES:
145 case E1000_DEV_ID_82576_SERDES_QUAD:
146 mac->type = e1000_82576;
147 break;
148 case E1000_DEV_ID_82580_COPPER:
149 case E1000_DEV_ID_82580_FIBER:
150 case E1000_DEV_ID_82580_SERDES:
151 case E1000_DEV_ID_82580_SGMII:
152 case E1000_DEV_ID_82580_COPPER_DUAL:
153 mac->type = e1000_82580;
154 break;
155 case E1000_DEV_ID_I350_COPPER:
156 mac->type = e1000_i350;
157 break;
158 default:
159 /* Should never have loaded on this device */
160 ret_val = -E1000_ERR_MAC_INIT;
161 break;
162 }
163
164 return (ret_val);
165 }
166
167 /*
168 * e1000_setup_init_funcs - Initializes function pointers
169 * @hw: pointer to the HW structure
170 * @init_device: true will initialize the rest of the function pointers
171 * getting the device ready for use. false will only set
172 * MAC type and the function pointers for the other init
173 * functions. Passing false will not generate any hardware
174 * reads or writes.
175 *
176 * This function must be called by a driver in order to use the rest
177 * of the 'shared' code files. Called by drivers only.
178 */
179 s32
180 e1000_setup_init_funcs(struct e1000_hw *hw, bool init_device)
181 {
182 s32 ret_val;
183
184 /* Can't do much good without knowing the MAC type. */
185 ret_val = e1000_set_mac_type(hw);
186 if (ret_val) {
187 DEBUGOUT("ERROR: MAC type could not be set properly.\n");
188 goto out;
189 }
190
191 if (!hw->hw_addr) {
192 DEBUGOUT("ERROR: Registers not mapped\n");
193 ret_val = -E1000_ERR_CONFIG;
194 goto out;
195 }
196
197 /*
198 * Init function pointers to generic implementations. We do this first
199 * allowing a driver module to override it afterward.
200 */
201 e1000_init_mac_ops_generic(hw);
202 e1000_init_phy_ops_generic(hw);
203 e1000_init_nvm_ops_generic(hw);
204
205 /*
206 * Set up the init function pointers. These are functions within the
207 * adapter family file that sets up function pointers for the rest of
208 * the functions in that family.
209 */
210 switch (hw->mac.type) {
211 case e1000_82575:
212 case e1000_82576:
213 case e1000_82580:
214 case e1000_i350:
215 e1000_init_function_pointers_82575(hw);
216 break;
217 default:
218 DEBUGOUT("Hardware not supported\n");
219 ret_val = -E1000_ERR_CONFIG;
220 break;
221 }
222
223 /*
224 * Initialize the rest of the function pointers. These require some
225 * register reads/writes in some cases.
226 */
227 if (!(ret_val) && init_device) {
228 ret_val = e1000_init_mac_params(hw);
229 if (ret_val)
230 goto out;
231
232 ret_val = e1000_init_nvm_params(hw);
233 if (ret_val)
234 goto out;
235
236 ret_val = e1000_init_phy_params(hw);
237 if (ret_val)
238 goto out;
239
240 }
241
242 out:
243 return (ret_val);
244 }
245
246 /*
247 * e1000_get_bus_info - Obtain bus information for adapter
248 * @hw: pointer to the HW structure
249 *
250 * This will obtain information about the HW bus for which the
251 * adapter is attached and stores it in the hw structure. This is a
252 * function pointer entry point called by drivers.
253 */
254 s32
255 e1000_get_bus_info(struct e1000_hw *hw)
256 {
257 if (hw->mac.ops.get_bus_info)
258 return (hw->mac.ops.get_bus_info(hw));
259
260 return (E1000_SUCCESS);
261 }
262
263 /*
264 * e1000_clear_vfta - Clear VLAN filter table
265 * @hw: pointer to the HW structure
266 *
267 * This clears the VLAN filter table on the adapter. This is a function
268 * pointer entry point called by drivers.
269 */
270 void
271 e1000_clear_vfta(struct e1000_hw *hw)
272 {
273 if (hw->mac.ops.clear_vfta)
274 hw->mac.ops.clear_vfta(hw);
275 }
276
277 /*
278 * e1000_write_vfta - Write value to VLAN filter table
279 * @hw: pointer to the HW structure
280 * @offset: the 32-bit offset in which to write the value to.
281 * @value: the 32-bit value to write at location offset.
282 *
283 * This writes a 32-bit value to a 32-bit offset in the VLAN filter
284 * table. This is a function pointer entry point called by drivers.
285 */
286 void
287 e1000_write_vfta(struct e1000_hw *hw, u32 offset, u32 value)
288 {
289 if (hw->mac.ops.write_vfta)
290 hw->mac.ops.write_vfta(hw, offset, value);
291 }
292
293 /*
294 * e1000_update_mc_addr_list - Update Multicast addresses
295 * @hw: pointer to the HW structure
296 * @mc_addr_list: array of multicast addresses to program
297 * @mc_addr_count: number of multicast addresses to program
298 *
299 * Updates the Multicast Table Array.
300 * The caller must have a packed mc_addr_list of multicast addresses.
301 */
302 void
303 e1000_update_mc_addr_list(struct e1000_hw *hw, u8 *mc_addr_list,
304 u32 mc_addr_count)
305 {
306 if (hw->mac.ops.update_mc_addr_list)
307 hw->mac.ops.update_mc_addr_list(hw,
308 mc_addr_list, mc_addr_count);
309 }
310
311 /*
312 * e1000_force_mac_fc - Force MAC flow control
313 * @hw: pointer to the HW structure
314 *
315 * Force the MAC's flow control settings. Currently no func pointer exists
316 * and all implementations are handled in the generic version of this
317 * function.
318 */
319 s32
320 e1000_force_mac_fc(struct e1000_hw *hw)
321 {
322 return (e1000_force_mac_fc_generic(hw));
323 }
324
325 /*
326 * e1000_check_for_link - Check/Store link connection
327 * @hw: pointer to the HW structure
328 *
329 * This checks the link condition of the adapter and stores the
330 * results in the hw->mac structure. This is a function pointer entry
331 * point called by drivers.
332 */
333 s32
334 e1000_check_for_link(struct e1000_hw *hw)
335 {
336 if (hw->mac.ops.check_for_link)
337 return (hw->mac.ops.check_for_link(hw));
338
339 return (-E1000_ERR_CONFIG);
340 }
341
342 /*
343 * e1000_check_mng_mode - Check management mode
344 * @hw: pointer to the HW structure
345 *
346 * This checks if the adapter has manageability enabled.
347 * This is a function pointer entry point called by drivers.
348 */
349 bool
350 e1000_check_mng_mode(struct e1000_hw *hw)
351 {
352 if (hw->mac.ops.check_mng_mode)
353 return (hw->mac.ops.check_mng_mode(hw));
354
355 return (false);
356 }
357
358 /*
359 * e1000_mng_write_dhcp_info - Writes DHCP info to host interface
360 * @hw: pointer to the HW structure
361 * @buffer: pointer to the host interface
362 * @length: size of the buffer
363 *
364 * Writes the DHCP information to the host interface.
365 */
366 s32
367 e1000_mng_write_dhcp_info(struct e1000_hw *hw, u8 *buffer, u16 length)
368 {
369 return (e1000_mng_write_dhcp_info_generic(hw, buffer, length));
370 }
371
372 /*
373 * e1000_reset_hw - Reset hardware
374 * @hw: pointer to the HW structure
375 *
376 * This resets the hardware into a known state. This is a function pointer
377 * entry point called by drivers.
378 */
379 s32
380 e1000_reset_hw(struct e1000_hw *hw)
381 {
382 if (hw->mac.ops.reset_hw)
383 return (hw->mac.ops.reset_hw(hw));
384
385 return (-E1000_ERR_CONFIG);
386 }
387
388 /*
389 * e1000_init_hw - Initialize hardware
390 * @hw: pointer to the HW structure
391 *
392 * This inits the hardware readying it for operation. This is a function
393 * pointer entry point called by drivers.
394 */
395 s32
396 e1000_init_hw(struct e1000_hw *hw)
397 {
398 if (hw->mac.ops.init_hw)
399 return (hw->mac.ops.init_hw(hw));
400
401 return (-E1000_ERR_CONFIG);
402 }
403
404 /*
405 * e1000_setup_link - Configures link and flow control
406 * @hw: pointer to the HW structure
407 *
408 * This configures link and flow control settings for the adapter. This
409 * is a function pointer entry point called by drivers. While modules can
410 * also call this, they probably call their own version of this function.
411 */
412 s32
413 e1000_setup_link(struct e1000_hw *hw)
414 {
415 if (hw->mac.ops.setup_link)
416 return (hw->mac.ops.setup_link(hw));
417
418 return (-E1000_ERR_CONFIG);
419 }
420
421 /*
422 * e1000_get_speed_and_duplex - Returns current speed and duplex
423 * @hw: pointer to the HW structure
424 * @speed: pointer to a 16-bit value to store the speed
425 * @duplex: pointer to a 16-bit value to store the duplex.
426 *
427 * This returns the speed and duplex of the adapter in the two 'out'
428 * variables passed in. This is a function pointer entry point called
429 * by drivers.
430 */
431 s32
432 e1000_get_speed_and_duplex(struct e1000_hw *hw, u16 *speed, u16 *duplex)
433 {
434 if (hw->mac.ops.get_link_up_info)
435 return (hw->mac.ops.get_link_up_info(hw, speed, duplex));
436
437 return (-E1000_ERR_CONFIG);
438 }
439
440 /*
441 * e1000_setup_led - Configures SW controllable LED
442 * @hw: pointer to the HW structure
443 *
444 * This prepares the SW controllable LED for use and saves the current state
445 * of the LED so it can be later restored. This is a function pointer entry
446 * point called by drivers.
447 */
448 s32
449 e1000_setup_led(struct e1000_hw *hw)
450 {
451 if (hw->mac.ops.setup_led)
452 return (hw->mac.ops.setup_led(hw));
453
454 return (E1000_SUCCESS);
455 }
456
457 /*
458 * e1000_cleanup_led - Restores SW controllable LED
459 * @hw: pointer to the HW structure
460 *
461 * This restores the SW controllable LED to the value saved off by
462 * e1000_setup_led. This is a function pointer entry point called by drivers.
463 */
464 s32
465 e1000_cleanup_led(struct e1000_hw *hw)
466 {
467 if (hw->mac.ops.cleanup_led)
468 return (hw->mac.ops.cleanup_led(hw));
469
470 return (E1000_SUCCESS);
471 }
472
473 /*
474 * e1000_blink_led - Blink SW controllable LED
475 * @hw: pointer to the HW structure
476 *
477 * This starts the adapter LED blinking. Request the LED to be setup first
478 * and cleaned up after. This is a function pointer entry point called by
479 * drivers.
480 */
481 s32
482 e1000_blink_led(struct e1000_hw *hw)
483 {
484 if (hw->mac.ops.blink_led)
485 return (hw->mac.ops.blink_led(hw));
486
487 return (E1000_SUCCESS);
488 }
489
490 /*
491 * e1000_id_led_init - store LED configurations in SW
492 * @hw: pointer to the HW structure
493 *
494 * Initializes the LED config in SW. This is a function pointer entry point
495 * called by drivers.
496 */
497 s32
498 e1000_id_led_init(struct e1000_hw *hw)
499 {
500 if (hw->mac.ops.id_led_init)
501 return (hw->mac.ops.id_led_init(hw));
502
503 return (E1000_SUCCESS);
504 }
505
506 /*
507 * e1000_led_on - Turn on SW controllable LED
508 * @hw: pointer to the HW structure
509 *
510 * Turns the SW defined LED on. This is a function pointer entry point
511 * called by drivers.
512 */
513 s32
514 e1000_led_on(struct e1000_hw *hw)
515 {
516 if (hw->mac.ops.led_on)
517 return (hw->mac.ops.led_on(hw));
518
519 return (E1000_SUCCESS);
520 }
521
522 /*
523 * e1000_led_off - Turn off SW controllable LED
524 * @hw: pointer to the HW structure
525 *
526 * Turns the SW defined LED off. This is a function pointer entry point
527 * called by drivers.
528 */
529 s32
530 e1000_led_off(struct e1000_hw *hw)
531 {
532 if (hw->mac.ops.led_off)
533 return (hw->mac.ops.led_off(hw));
534
535 return (E1000_SUCCESS);
536 }
537
538 /*
539 * e1000_reset_adaptive - Reset adaptive IFS
540 * @hw: pointer to the HW structure
541 *
542 * Resets the adaptive IFS. Currently no func pointer exists and all
543 * implementations are handled in the generic version of this function.
544 */
545 void
546 e1000_reset_adaptive(struct e1000_hw *hw)
547 {
548 e1000_reset_adaptive_generic(hw);
549 }
550
551 /*
552 * e1000_update_adaptive - Update adaptive IFS
553 * @hw: pointer to the HW structure
554 *
555 * Updates adapter IFS. Currently no func pointer exists and all
556 * implementations are handled in the generic version of this function.
557 */
558 void
559 e1000_update_adaptive(struct e1000_hw *hw)
560 {
561 e1000_update_adaptive_generic(hw);
562 }
563
564 /*
565 * e1000_disable_pcie_master - Disable PCI-Express master access
566 * @hw: pointer to the HW structure
567 *
568 * Disables PCI-Express master access and verifies there are no pending
569 * requests. Currently no func pointer exists and all implementations are
570 * handled in the generic version of this function.
571 */
572 s32
573 e1000_disable_pcie_master(struct e1000_hw *hw)
574 {
575 return (e1000_disable_pcie_master_generic(hw));
576 }
577
578 /*
579 * e1000_config_collision_dist - Configure collision distance
580 * @hw: pointer to the HW structure
581 *
582 * Configures the collision distance to the default value and is used
583 * during link setup.
584 */
585 void
586 e1000_config_collision_dist(struct e1000_hw *hw)
587 {
588 if (hw->mac.ops.config_collision_dist)
589 hw->mac.ops.config_collision_dist(hw);
590 }
591
592 /*
593 * e1000_rar_set - Sets a receive address register
594 * @hw: pointer to the HW structure
595 * @addr: address to set the RAR to
596 * @index: the RAR to set
597 *
598 * Sets a Receive Address Register (RAR) to the specified address.
599 */
600 void
601 e1000_rar_set(struct e1000_hw *hw, u8 *addr, u32 index)
602 {
603 if (hw->mac.ops.rar_set)
604 hw->mac.ops.rar_set(hw, addr, index);
605 }
606
607 /*
608 * e1000_validate_mdi_setting - Ensures valid MDI/MDIX SW state
609 * @hw: pointer to the HW structure
610 *
611 * Ensures that the MDI/MDIX SW state is valid.
612 */
613 s32
614 e1000_validate_mdi_setting(struct e1000_hw *hw)
615 {
616 if (hw->mac.ops.validate_mdi_setting)
617 return (hw->mac.ops.validate_mdi_setting(hw));
618
619 return (E1000_SUCCESS);
620 }
621
622 /*
623 * e1000_mta_set - Sets multicast table bit
624 * @hw: pointer to the HW structure
625 * @hash_value: Multicast hash value.
626 *
627 * This sets the bit in the multicast table corresponding to the
628 * hash value. This is a function pointer entry point called by drivers.
629 */
630 void
631 e1000_mta_set(struct e1000_hw *hw, u32 hash_value)
632 {
633 if (hw->mac.ops.mta_set)
634 hw->mac.ops.mta_set(hw, hash_value);
635 }
636
637 /*
638 * e1000_hash_mc_addr - Determines address location in multicast table
639 * @hw: pointer to the HW structure
640 * @mc_addr: Multicast address to hash.
641 *
642 * This hashes an address to determine its location in the multicast
643 * table. Currently no func pointer exists and all implementations
644 * are handled in the generic version of this function.
645 */
646 u32
647 e1000_hash_mc_addr(struct e1000_hw *hw, u8 *mc_addr)
648 {
649 return (e1000_hash_mc_addr_generic(hw, mc_addr));
650 }
651
652 /*
653 * e1000_enable_tx_pkt_filtering - Enable packet filtering on TX
654 * @hw: pointer to the HW structure
655 *
656 * Enables packet filtering on transmit packets if manageability is enabled
657 * and host interface is enabled.
658 * Currently no func pointer exists and all implementations are handled in the
659 * generic version of this function.
660 */
661 bool
662 e1000_enable_tx_pkt_filtering(struct e1000_hw *hw)
663 {
664 return (e1000_enable_tx_pkt_filtering_generic(hw));
665 }
666
667 /*
668 * e1000_mng_host_if_write - Writes to the manageability host interface
669 * @hw: pointer to the HW structure
670 * @buffer: pointer to the host interface buffer
671 * @length: size of the buffer
672 * @offset: location in the buffer to write to
673 * @sum: sum of the data (not checksum)
674 *
675 * This function writes the buffer content at the offset given on the host if.
676 * It also does alignment considerations to do the writes in most efficient
677 * way. Also fills up the sum of the buffer in *buffer parameter.
678 */
679 s32
680 e1000_mng_host_if_write(struct e1000_hw *hw, u8 *buffer, u16 length,
681 u16 offset, u8 *sum)
682 {
683 if (hw->mac.ops.mng_host_if_write)
684 return (hw->mac.ops.mng_host_if_write(hw, buffer, length,
685 offset, sum));
686
687 return (E1000_NOT_IMPLEMENTED);
688 }
689
690 /*
691 * e1000_mng_write_cmd_header - Writes manageability command header
692 * @hw: pointer to the HW structure
693 * @hdr: pointer to the host interface command header
694 *
695 * Writes the command header after does the checksum calculation.
696 */
697 s32
698 e1000_mng_write_cmd_header(struct e1000_hw *hw,
699 struct e1000_host_mng_command_header *hdr)
700 {
701 if (hw->mac.ops.mng_write_cmd_header)
702 return (hw->mac.ops.mng_write_cmd_header(hw, hdr));
703
704 return (E1000_NOT_IMPLEMENTED);
705 }
706
707 /*
708 * e1000_mng_enable_host_if - Checks host interface is enabled
709 * @hw: pointer to the HW structure
710 *
711 * Returns E1000_success upon success, else E1000_ERR_HOST_INTERFACE_COMMAND
712 *
713 * This function checks whether the HOST IF is enabled for command operation
714 * and also checks whether the previous command is completed. It busy waits
715 * in case of previous command is not completed.
716 */
717 s32
718 e1000_mng_enable_host_if(struct e1000_hw *hw)
719 {
720 if (hw->mac.ops.mng_enable_host_if)
721 return (hw->mac.ops.mng_enable_host_if(hw));
722
723 return (E1000_NOT_IMPLEMENTED);
724 }
725
726 /*
727 * e1000_wait_autoneg - Waits for autonegotiation completion
728 * @hw: pointer to the HW structure
729 *
730 * Waits for autoneg to complete. Currently no func pointer exists and all
731 * implementations are handled in the generic version of this function.
732 */
733 s32
734 e1000_wait_autoneg(struct e1000_hw *hw)
735 {
736 if (hw->mac.ops.wait_autoneg)
737 return (hw->mac.ops.wait_autoneg(hw));
738
739 return (E1000_SUCCESS);
740 }
741
742 /*
743 * e1000_check_reset_block - Verifies PHY can be reset
744 * @hw: pointer to the HW structure
745 *
746 * Checks if the PHY is in a state that can be reset or if manageability
747 * has it tied up. This is a function pointer entry point called by drivers.
748 */
749 s32
750 e1000_check_reset_block(struct e1000_hw *hw)
751 {
752 if (hw->phy.ops.check_reset_block)
753 return (hw->phy.ops.check_reset_block(hw));
754
755 return (E1000_SUCCESS);
756 }
757
758 /*
759 * e1000_read_phy_reg - Reads PHY register
760 * @hw: pointer to the HW structure
761 * @offset: the register to read
762 * @data: the buffer to store the 16-bit read.
763 *
764 * Reads the PHY register and returns the value in data.
765 * This is a function pointer entry point called by drivers.
766 */
767 s32
768 e1000_read_phy_reg(struct e1000_hw *hw, u32 offset, u16 *data)
769 {
770 if (hw->phy.ops.read_reg)
771 return (hw->phy.ops.read_reg(hw, offset, data));
772
773 return (E1000_SUCCESS);
774 }
775
776 /*
777 * e1000_write_phy_reg - Writes PHY register
778 * @hw: pointer to the HW structure
779 * @offset: the register to write
780 * @data: the value to write.
781 *
782 * Writes the PHY register at offset with the value in data.
783 * This is a function pointer entry point called by drivers.
784 */
785 s32
786 e1000_write_phy_reg(struct e1000_hw *hw, u32 offset, u16 data)
787 {
788 if (hw->phy.ops.write_reg)
789 return (hw->phy.ops.write_reg(hw, offset, data));
790
791 return (E1000_SUCCESS);
792 }
793
794 /*
795 * e1000_release_phy - Generic release PHY
796 * @hw: pointer to the HW structure
797 *
798 * Return if silicon family does not require a semaphore when accessing the
799 * PHY.
800 */
801 void
802 e1000_release_phy(struct e1000_hw *hw)
803 {
804 if (hw->phy.ops.release)
805 hw->phy.ops.release(hw);
806 }
807
808 /*
809 * e1000_acquire_phy - Generic acquire PHY
810 * @hw: pointer to the HW structure
811 *
812 * Return success if silicon family does not require a semaphore when
813 * accessing the PHY.
814 */
815 s32
816 e1000_acquire_phy(struct e1000_hw *hw)
817 {
818 if (hw->phy.ops.acquire)
819 return (hw->phy.ops.acquire(hw));
820
821 return (E1000_SUCCESS);
822 }
823
824 /*
825 * e1000_read_kmrn_reg - Reads register using Kumeran interface
826 * @hw: pointer to the HW structure
827 * @offset: the register to read
828 * @data: the location to store the 16-bit value read.
829 *
830 * Reads a register out of the Kumeran interface. Currently no func pointer
831 * exists and all implementations are handled in the generic version of
832 * this function.
833 */
834 s32
835 e1000_read_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 *data)
836 {
837 return (e1000_read_kmrn_reg_generic(hw, offset, data));
838 }
839
840 /*
841 * e1000_write_kmrn_reg - Writes register using Kumeran interface
842 * @hw: pointer to the HW structure
843 * @offset: the register to write
844 * @data: the value to write.
845 *
846 * Writes a register to the Kumeran interface. Currently no func pointer
847 * exists and all implementations are handled in the generic version of
848 * this function.
849 */
850 s32
851 e1000_write_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 data)
852 {
853 return (e1000_write_kmrn_reg_generic(hw, offset, data));
854 }
855
856 /*
857 * e1000_get_cable_length - Retrieves cable length estimation
858 * @hw: pointer to the HW structure
859 *
860 * This function estimates the cable length and stores them in
861 * hw->phy.min_length and hw->phy.max_length. This is a function pointer
862 * entry point called by drivers.
863 */
864 s32
865 e1000_get_cable_length(struct e1000_hw *hw)
866 {
867 if (hw->phy.ops.get_cable_length)
868 return (hw->phy.ops.get_cable_length(hw));
869
870 return (E1000_SUCCESS);
871 }
872
873 /*
874 * e1000_get_phy_info - Retrieves PHY information from registers
875 * @hw: pointer to the HW structure
876 *
877 * This function gets some information from various PHY registers and
878 * populates hw->phy values with it. This is a function pointer entry
879 * point called by drivers.
880 */
881 s32
882 e1000_get_phy_info(struct e1000_hw *hw)
883 {
884 if (hw->phy.ops.get_info)
885 return (hw->phy.ops.get_info(hw));
886
887 return (E1000_SUCCESS);
888 }
889
890 /*
891 * e1000_phy_hw_reset - Hard PHY reset
892 * @hw: pointer to the HW structure
893 *
894 * Performs a hard PHY reset. This is a function pointer entry point called
895 * by drivers.
896 */
897 s32
898 e1000_phy_hw_reset(struct e1000_hw *hw)
899 {
900 if (hw->phy.ops.reset)
901 return (hw->phy.ops.reset(hw));
902
903 return (E1000_SUCCESS);
904 }
905
906 /*
907 * e1000_phy_commit - Soft PHY reset
908 * @hw: pointer to the HW structure
909 *
910 * Performs a soft PHY reset on those that apply. This is a function pointer
911 * entry point called by drivers.
912 */
913 s32
914 e1000_phy_commit(struct e1000_hw *hw)
915 {
916 if (hw->phy.ops.commit)
917 return (hw->phy.ops.commit(hw));
918
919 return (E1000_SUCCESS);
920 }
921
922 /*
923 * e1000_set_d0_lplu_state - Sets low power link up state for D0
924 * @hw: pointer to the HW structure
925 * @active: boolean used to enable/disable lplu
926 *
927 * Success returns 0, Failure returns 1
928 *
929 * The low power link up (lplu) state is set to the power management level D0
930 * and SmartSpeed is disabled when active is true, else clear lplu for D0
931 * and enable Smartspeed. LPLU and Smartspeed are mutually exclusive. LPLU
932 * is used during Dx states where the power conservation is most important.
933 * During driver activity, SmartSpeed should be enabled so performance is
934 * maintained. This is a function pointer entry point called by drivers.
935 */
936 s32
937 e1000_set_d0_lplu_state(struct e1000_hw *hw, bool active)
938 {
939 if (hw->phy.ops.set_d0_lplu_state)
940 return (hw->phy.ops.set_d0_lplu_state(hw, active));
941
942 return (E1000_SUCCESS);
943 }
944
945 /*
946 * e1000_set_d3_lplu_state - Sets low power link up state for D3
947 * @hw: pointer to the HW structure
948 * @active: boolean used to enable/disable lplu
949 *
950 * Success returns 0, Failure returns 1
951 *
952 * The low power link up (lplu) state is set to the power management level D3
953 * and SmartSpeed is disabled when active is true, else clear lplu for D3
954 * and enable Smartspeed. LPLU and Smartspeed are mutually exclusive. LPLU
955 * is used during Dx states where the power conservation is most important.
956 * During driver activity, SmartSpeed should be enabled so performance is
957 * maintained. This is a function pointer entry point called by drivers.
958 */
959 s32
960 e1000_set_d3_lplu_state(struct e1000_hw *hw, bool active)
961 {
962 if (hw->phy.ops.set_d3_lplu_state)
963 return (hw->phy.ops.set_d3_lplu_state(hw, active));
964
965 return (E1000_SUCCESS);
966 }
967
968 /*
969 * e1000_read_mac_addr - Reads MAC address
970 * @hw: pointer to the HW structure
971 *
972 * Reads the MAC address out of the adapter and stores it in the HW structure.
973 * Currently no func pointer exists and all implementations are handled in the
974 * generic version of this function.
975 */
976 s32
977 e1000_read_mac_addr(struct e1000_hw *hw)
978 {
979 if (hw->mac.ops.read_mac_addr)
980 return (hw->mac.ops.read_mac_addr(hw));
981
982 return (e1000_read_mac_addr_generic(hw));
983 }
984
985 /*
986 * e1000_read_pba_num - Read device part number
987 * @hw: pointer to the HW structure
988 * @pba_num: pointer to device part number
989 *
990 * Reads the product board assembly (PBA) number from the EEPROM and stores
991 * the value in pba_num.
992 * Currently no func pointer exists and all implementations are handled in the
993 * generic version of this function.
994 */
995 s32
996 e1000_read_pba_num(struct e1000_hw *hw, u32 *pba_num)
997 {
998 return (e1000_read_pba_num_generic(hw, pba_num));
999 }
1000
1001 /*
1002 * e1000_validate_nvm_checksum - Verifies NVM (EEPROM) checksum
1003 * @hw: pointer to the HW structure
1004 *
1005 * Validates the NVM checksum is correct. This is a function pointer entry
1006 * point called by drivers.
1007 */
1008 s32
1009 e1000_validate_nvm_checksum(struct e1000_hw *hw)
1010 {
1011 if (hw->nvm.ops.validate)
1012 return (hw->nvm.ops.validate(hw));
1013
1014 return (-E1000_ERR_CONFIG);
1015 }
1016
1017 /*
1018 * e1000_update_nvm_checksum - Updates NVM (EEPROM) checksum
1019 * @hw: pointer to the HW structure
1020 *
1021 * Updates the NVM checksum. Currently no func pointer exists and all
1022 * implementations are handled in the generic version of this function.
1023 */
1024 s32
1025 e1000_update_nvm_checksum(struct e1000_hw *hw)
1026 {
1027 if (hw->nvm.ops.update)
1028 return (hw->nvm.ops.update(hw));
1029
1030 return (-E1000_ERR_CONFIG);
1031 }
1032
1033 /*
1034 * e1000_reload_nvm - Reloads EEPROM
1035 * @hw: pointer to the HW structure
1036 *
1037 * Reloads the EEPROM by setting the "Reinitialize from EEPROM" bit in the
1038 * extended control register.
1039 */
1040 void
1041 e1000_reload_nvm(struct e1000_hw *hw)
1042 {
1043 if (hw->nvm.ops.reload)
1044 hw->nvm.ops.reload(hw);
1045 }
1046
1047 /*
1048 * e1000_read_nvm - Reads NVM (EEPROM)
1049 * @hw: pointer to the HW structure
1050 * @offset: the word offset to read
1051 * @words: number of 16-bit words to read
1052 * @data: pointer to the properly sized buffer for the data.
1053 *
1054 * Reads 16-bit chunks of data from the NVM (EEPROM). This is a function
1055 * pointer entry point called by drivers.
1056 */
1057 s32
1058 e1000_read_nvm(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
1059 {
1060 if (hw->nvm.ops.read)
1061 return (hw->nvm.ops.read(hw, offset, words, data));
1062
1063 return (-E1000_ERR_CONFIG);
1064 }
1065
1066 /*
1067 * e1000_write_nvm - Writes to NVM (EEPROM)
1068 * @hw: pointer to the HW structure
1069 * @offset: the word offset to read
1070 * @words: number of 16-bit words to write
1071 * @data: pointer to the properly sized buffer for the data.
1072 *
1073 * Writes 16-bit chunks of data to the NVM (EEPROM). This is a function
1074 * pointer entry point called by drivers.
1075 */
1076 s32
1077 e1000_write_nvm(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
1078 {
1079 if (hw->nvm.ops.write)
1080 return (hw->nvm.ops.write(hw, offset, words, data));
1081
1082 return (E1000_SUCCESS);
1083 }
1084
1085 /*
1086 * e1000_write_8bit_ctrl_reg - Writes 8bit Control register
1087 * @hw: pointer to the HW structure
1088 * @reg: 32bit register offset
1089 * @offset: the register to write
1090 * @data: the value to write.
1091 *
1092 * Writes the PHY register at offset with the value in data.
1093 * This is a function pointer entry point called by drivers.
1094 */
1095 s32
1096 e1000_write_8bit_ctrl_reg(struct e1000_hw *hw, u32 reg, u32 offset, u8 data)
1097 {
1098 return (e1000_write_8bit_ctrl_reg_generic(hw, reg, offset, data));
1099 }
1100
1101 /*
1102 * e1000_power_up_phy - Restores link in case of PHY power down
1103 * @hw: pointer to the HW structure
1104 *
1105 * The phy may be powered down to save power, to turn off link when the
1106 * driver is unloaded, or wake on lan is not enabled (among others).
1107 */
1108 void
1109 e1000_power_up_phy(struct e1000_hw *hw)
1110 {
1111 if (hw->phy.ops.power_up)
1112 hw->phy.ops.power_up(hw);
1113
1114 (void) e1000_setup_link(hw);
1115 }
1116
1117 /*
1118 * e1000_power_down_phy - Power down PHY
1119 * @hw: pointer to the HW structure
1120 *
1121 * The phy may be powered down to save power, to turn off link when the
1122 * driver is unloaded, or wake on lan is not enabled (among others).
1123 */
1124 void
1125 e1000_power_down_phy(struct e1000_hw *hw)
1126 {
1127 if (hw->phy.ops.power_down)
1128 hw->phy.ops.power_down(hw);
1129 }
1130
1131 /*
1132 * e1000_shutdown_fiber_serdes_link - Remove link during power down
1133 * @hw: pointer to the HW structure
1134 *
1135 * Shutdown the optics and PCS on driver unload.
1136 */
1137 void
1138 e1000_shutdown_fiber_serdes_link(struct e1000_hw *hw)
1139 {
1140 if (hw->mac.ops.shutdown_serdes)
1141 hw->mac.ops.shutdown_serdes(hw);
1142 }