summaryrefslogtreecommitdiffstats
path: root/bsd_eth_drivers/if_em/e1000_api.c
blob: 320a3409d786eac3881fc2ea971d088a393a0339 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
/*******************************************************************************

  Copyright (c) 2001-2007, Intel Corporation 
  All rights reserved.
  
  Redistribution and use in source and binary forms, with or without 
  modification, are permitted provided that the following conditions are met:
  
   1. Redistributions of source code must retain the above copyright notice, 
      this list of conditions and the following disclaimer.
  
   2. Redistributions in binary form must reproduce the above copyright 
      notice, this list of conditions and the following disclaimer in the 
      documentation and/or other materials provided with the distribution.
  
   3. Neither the name of the Intel Corporation nor the names of its 
      contributors may be used to endorse or promote products derived from 
      this software without specific prior written permission.
  
  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  POSSIBILITY OF SUCH DAMAGE.

*******************************************************************************/
/*$FreeBSD: src/sys/dev/em/e1000_api.c,v 1.3 2007/05/16 00:14:23 jfv Exp $*/


#include "e1000_api.h"
#include "e1000_mac.h"
#include "e1000_nvm.h"
#include "e1000_phy.h"

#ifndef NO_82542_SUPPORT
extern void    e1000_init_function_pointers_82542(struct e1000_hw *hw);
#endif
extern void    e1000_init_function_pointers_82543(struct e1000_hw *hw);
extern void    e1000_init_function_pointers_82540(struct e1000_hw *hw);
extern void    e1000_init_function_pointers_82571(struct e1000_hw *hw);
extern void    e1000_init_function_pointers_82541(struct e1000_hw *hw);
extern void    e1000_init_function_pointers_80003es2lan(struct e1000_hw *hw);
#ifndef NO_ICH8LAN_SUPPORT
extern void    e1000_init_function_pointers_ich8lan(struct e1000_hw *hw);
#endif
extern void    e1000_init_function_pointers_82575(struct e1000_hw *hw);

/**
 *  e1000_init_mac_params - Initialize MAC function pointers
 *  @hw: pointer to the HW structure
 *
 *  This function initializes the function pointers for the MAC
 *  set of functions.  Called by drivers or by e1000_setup_init_funcs.
 **/
s32
e1000_init_mac_params(struct e1000_hw *hw)
{
	s32 ret_val = E1000_SUCCESS;

	if (hw->func.init_mac_params != NULL) {
		ret_val = hw->func.init_mac_params(hw);
		if (ret_val) {
			DEBUGOUT("MAC Initialization Error\n");
			goto out;
		}
	} else {
		DEBUGOUT("mac.init_mac_params was NULL\n");
		ret_val = -E1000_ERR_CONFIG;
	}

out:
	return ret_val;
}

/**
 *  e1000_init_nvm_params - Initialize NVM function pointers
 *  @hw: pointer to the HW structure
 *
 *  This function initializes the function pointers for the NVM
 *  set of functions.  Called by drivers or by e1000_setup_init_funcs.
 **/
s32
e1000_init_nvm_params(struct e1000_hw *hw)
{
	s32 ret_val = E1000_SUCCESS;

	if (hw->func.init_nvm_params != NULL) {
		ret_val = hw->func.init_nvm_params(hw);
		if (ret_val) {
			DEBUGOUT("NVM Initialization Error\n");
			goto out;
		}
	} else {
		DEBUGOUT("nvm.init_nvm_params was NULL\n");
		ret_val = -E1000_ERR_CONFIG;
	}

out:
	return ret_val;
}

/**
 *  e1000_init_phy_params - Initialize PHY function pointers
 *  @hw: pointer to the HW structure
 *
 *  This function initializes the function pointers for the PHY
 *  set of functions.  Called by drivers or by e1000_setup_init_funcs.
 **/
s32
e1000_init_phy_params(struct e1000_hw *hw)
{
	s32 ret_val = E1000_SUCCESS;

	if (hw->func.init_phy_params != NULL) {
		ret_val = hw->func.init_phy_params(hw);
		if (ret_val) {
			DEBUGOUT("PHY Initialization Error\n");
			goto out;
		}
	} else {
		DEBUGOUT("phy.init_phy_params was NULL\n");
		ret_val =  -E1000_ERR_CONFIG;
	}

out:
	return ret_val;
}

/**
 *  e1000_set_mac_type - Sets MAC type
 *  @hw: pointer to the HW structure
 *
 *  This function sets the mac type of the adapter based on the
 *  device ID stored in the hw structure.
 *  MUST BE FIRST FUNCTION CALLED (explicitly or through
 *  e1000_setup_init_funcs()).
 **/
s32
e1000_set_mac_type(struct e1000_hw *hw)
{
	struct e1000_mac_info *mac = &hw->mac;
	s32 ret_val = E1000_SUCCESS;

	DEBUGFUNC("e1000_set_mac_type");

	switch (hw->device_id) {
#ifndef NO_82542_SUPPORT
	case E1000_DEV_ID_82542:
		mac->type = e1000_82542;
		break;
#endif
	case E1000_DEV_ID_82543GC_FIBER:
	case E1000_DEV_ID_82543GC_COPPER:
		mac->type = e1000_82543;
		break;
	case E1000_DEV_ID_82544EI_COPPER:
	case E1000_DEV_ID_82544EI_FIBER:
	case E1000_DEV_ID_82544GC_COPPER:
	case E1000_DEV_ID_82544GC_LOM:
		mac->type = e1000_82544;
		break;
	case E1000_DEV_ID_82540EM:
	case E1000_DEV_ID_82540EM_LOM:
	case E1000_DEV_ID_82540EP:
	case E1000_DEV_ID_82540EP_LOM:
	case E1000_DEV_ID_82540EP_LP:
		mac->type = e1000_82540;
		break;
	case E1000_DEV_ID_82545EM_COPPER:
	case E1000_DEV_ID_82545EM_FIBER:
		mac->type = e1000_82545;
		break;
	case E1000_DEV_ID_82545GM_COPPER:
	case E1000_DEV_ID_82545GM_FIBER:
	case E1000_DEV_ID_82545GM_SERDES:
		mac->type = e1000_82545_rev_3;
		break;
	case E1000_DEV_ID_82546EB_COPPER:
	case E1000_DEV_ID_82546EB_FIBER:
	case E1000_DEV_ID_82546EB_QUAD_COPPER:
		mac->type = e1000_82546;
		break;
	case E1000_DEV_ID_82546GB_COPPER:
	case E1000_DEV_ID_82546GB_FIBER:
	case E1000_DEV_ID_82546GB_SERDES:
	case E1000_DEV_ID_82546GB_PCIE:
	case E1000_DEV_ID_82546GB_QUAD_COPPER:
	case E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3:
		mac->type = e1000_82546_rev_3;
		break;
	case E1000_DEV_ID_82541EI:
	case E1000_DEV_ID_82541EI_MOBILE:
	case E1000_DEV_ID_82541ER_LOM:
		mac->type = e1000_82541;
		break;
	case E1000_DEV_ID_82541ER:
	case E1000_DEV_ID_82541GI:
	case E1000_DEV_ID_82541GI_LF:
	case E1000_DEV_ID_82541GI_MOBILE:
		mac->type = e1000_82541_rev_2;
		break;
	case E1000_DEV_ID_82547EI:
	case E1000_DEV_ID_82547EI_MOBILE:
		mac->type = e1000_82547;
		break;
	case E1000_DEV_ID_82547GI:
		mac->type = e1000_82547_rev_2;
		break;
	case E1000_DEV_ID_82571EB_COPPER:
	case E1000_DEV_ID_82571EB_FIBER:
	case E1000_DEV_ID_82571EB_SERDES:
	case E1000_DEV_ID_82571EB_SERDES_DUAL:
	case E1000_DEV_ID_82571EB_SERDES_QUAD:
	case E1000_DEV_ID_82571EB_QUAD_COPPER:
	case E1000_DEV_ID_82571EB_QUAD_FIBER:
	case E1000_DEV_ID_82571EB_QUAD_COPPER_LP:
		mac->type = e1000_82571;
		break;
	case E1000_DEV_ID_82572EI:
	case E1000_DEV_ID_82572EI_COPPER:
	case E1000_DEV_ID_82572EI_FIBER:
	case E1000_DEV_ID_82572EI_SERDES:
		mac->type = e1000_82572;
		break;
	case E1000_DEV_ID_82573E:
	case E1000_DEV_ID_82573E_IAMT:
	case E1000_DEV_ID_82573L:
		mac->type = e1000_82573;
		break;
	case E1000_DEV_ID_80003ES2LAN_COPPER_DPT:
	case E1000_DEV_ID_80003ES2LAN_SERDES_DPT:
	case E1000_DEV_ID_80003ES2LAN_COPPER_SPT:
	case E1000_DEV_ID_80003ES2LAN_SERDES_SPT:
		mac->type = e1000_80003es2lan;
		break;
#ifndef NO_ICH8LAN_SUPPORT
	case E1000_DEV_ID_ICH8_IFE:
	case E1000_DEV_ID_ICH8_IFE_GT:
	case E1000_DEV_ID_ICH8_IFE_G:
	case E1000_DEV_ID_ICH8_IGP_M:
	case E1000_DEV_ID_ICH8_IGP_M_AMT:
	case E1000_DEV_ID_ICH8_IGP_AMT:
	case E1000_DEV_ID_ICH8_IGP_C:
		mac->type = e1000_ich8lan;
		break;
	case E1000_DEV_ID_ICH9_IFE:
	case E1000_DEV_ID_ICH9_IFE_GT:
	case E1000_DEV_ID_ICH9_IFE_G:
	case E1000_DEV_ID_ICH9_IGP_AMT:
	case E1000_DEV_ID_ICH9_IGP_C:
		mac->type = e1000_ich9lan;
		break;
#endif
	case E1000_DEV_ID_82575EB_COPPER:
	case E1000_DEV_ID_82575EB_FIBER_SERDES:
	case E1000_DEV_ID_82575EM_COPPER:
	case E1000_DEV_ID_82575EM_FIBER_SERDES:
	case E1000_DEV_ID_82575GB_QUAD_COPPER:
		mac->type = e1000_82575;
		break;
	default:
		/* Should never have loaded on this device */
		ret_val = -E1000_ERR_MAC_INIT;
		break;
	}

	return ret_val;
}

/**
 *  e1000_setup_init_funcs - Initializes function pointers
 *  @hw: pointer to the HW structure
 *  @init_device: TRUE will initialize the rest of the function pointers
 *                 getting the device ready for use.  FALSE will only set
 *                 MAC type and the function pointers for the other init
 *                 functions.  Passing FALSE will not generate any hardware
 *                 reads or writes.
 *
 *  This function must be called by a driver in order to use the rest
 *  of the 'shared' code files. Called by drivers only.
 **/
s32
e1000_setup_init_funcs(struct e1000_hw *hw, boolean_t init_device)
{
	s32 ret_val;

	/* Can't do much good without knowing the MAC type.
	 */
	ret_val = e1000_set_mac_type(hw);
	if (ret_val) {
		DEBUGOUT("ERROR: MAC type could not be set properly.\n");
		goto out;
	}

	if (!hw->hw_addr) {
		DEBUGOUT("ERROR: Registers not mapped\n");
		ret_val = -E1000_ERR_CONFIG;
		goto out;
	}

	/* Init some generic function pointers that are currently all pointing
	 * to generic implementations. We do this first allowing a driver
	 * module to override it afterwards.
	 */
	hw->func.config_collision_dist = e1000_config_collision_dist_generic;
	hw->func.rar_set = e1000_rar_set_generic;
	hw->func.validate_mdi_setting = e1000_validate_mdi_setting_generic;
	hw->func.mng_host_if_write = e1000_mng_host_if_write_generic;
	hw->func.mng_write_cmd_header = e1000_mng_write_cmd_header_generic;
	hw->func.mng_enable_host_if = e1000_mng_enable_host_if_generic;
	hw->func.wait_autoneg = e1000_wait_autoneg_generic;
	hw->func.reload_nvm = e1000_reload_nvm_generic;

	/* Set up the init function pointers. These are functions within the
	 * adapter family file that sets up function pointers for the rest of
	 * the functions in that family.
	 */
	switch (hw->mac.type) {
#ifndef NO_82542_SUPPORT
	case e1000_82542:
		e1000_init_function_pointers_82542(hw);
		break;
#endif
	case e1000_82543:
	case e1000_82544:
		e1000_init_function_pointers_82543(hw);
		break;
	case e1000_82540:
	case e1000_82545:
	case e1000_82545_rev_3:
	case e1000_82546:
	case e1000_82546_rev_3:
		e1000_init_function_pointers_82540(hw);
		break;
	case e1000_82541:
	case e1000_82541_rev_2:
	case e1000_82547:
	case e1000_82547_rev_2:
		e1000_init_function_pointers_82541(hw);
		break;
	case e1000_82571:
	case e1000_82572:
	case e1000_82573:
		e1000_init_function_pointers_82571(hw);
		break;
	case e1000_80003es2lan:
		e1000_init_function_pointers_80003es2lan(hw);
		break;
#ifndef NO_ICH8LAN_SUPPORT
	case e1000_ich8lan:
	case e1000_ich9lan:
		e1000_init_function_pointers_ich8lan(hw);
		break;
#endif
	case e1000_82575:
		e1000_init_function_pointers_82575(hw);
		break;
	default:
		DEBUGOUT("Hardware not supported\n");
		ret_val = -E1000_ERR_CONFIG;
		break;
	}

	/* Initialize the rest of the function pointers. These require some
	 * register reads/writes in some cases.
	 */
	if ((ret_val == E1000_SUCCESS) && (init_device == TRUE)) {
		ret_val = e1000_init_mac_params(hw);
		if (ret_val)
			goto out;

		ret_val = e1000_init_nvm_params(hw);
		if (ret_val)
			goto out;

		ret_val = e1000_init_phy_params(hw);
		if (ret_val)
			goto out;

	}

out:
	return ret_val;
}

/**
 *  e1000_remove_device - Free device specific structure
 *  @hw: pointer to the HW structure
 *
 *  If a device specific structure was allocated, this function will
 *  free it. This is a function pointer entry point called by drivers.
 **/
void
e1000_remove_device(struct e1000_hw *hw)
{
	if (hw->func.remove_device != NULL)
		hw->func.remove_device(hw);
}

/**
 *  e1000_get_bus_info - Obtain bus information for adapter
 *  @hw: pointer to the HW structure
 *
 *  This will obtain information about the HW bus for which the
 *  adaper is attached and stores it in the hw structure. This is a
 *  function pointer entry point called by drivers.
 **/
s32
e1000_get_bus_info(struct e1000_hw *hw)
{
	if (hw->func.get_bus_info != NULL)
		return hw->func.get_bus_info(hw);
	else
		return E1000_SUCCESS;
}

/**
 *  e1000_clear_vfta - Clear VLAN filter table
 *  @hw: pointer to the HW structure
 *
 *  This clears the VLAN filter table on the adapter. This is a function
 *  pointer entry point called by drivers.
 **/
void
e1000_clear_vfta(struct e1000_hw *hw)
{
	if (hw->func.clear_vfta != NULL)
		hw->func.clear_vfta (hw);
}

/**
 *  e1000_write_vfta - Write value to VLAN filter table
 *  @hw: pointer to the HW structure
 *  @offset: the 32-bit offset in which to write the value to.
 *  @value: the 32-bit value to write at location offset.
 *
 *  This writes a 32-bit value to a 32-bit offset in the VLAN filter
 *  table. This is a function pointer entry point called by drivers.
 **/
void
e1000_write_vfta(struct e1000_hw *hw, u32 offset, u32 value)
{
	if (hw->func.write_vfta != NULL)
		hw->func.write_vfta(hw, offset, value);
}

/**
 *  e1000_mc_addr_list_update - Update Multicast addresses
 *  @hw: pointer to the HW structure
 *  @mc_addr_list: array of multicast addresses to program
 *  @mc_addr_count: number of multicast addresses to program
 *  @rar_used_count: the first RAR register free to program
 *  @rar_count: total number of supported Receive Address Registers
 *
 *  Updates the Receive Address Registers and Multicast Table Array.
 *  The caller must have a packed mc_addr_list of multicast addresses.
 *  The parameter rar_count will usually be hw->mac.rar_entry_count
 *  unless there are workarounds that change this.  Currently no func pointer
 *  exists and all implementations are handled in the generic version of this
 *  function.
 **/
void
e1000_mc_addr_list_update(struct e1000_hw *hw,
                          u8 *mc_addr_list,
                          u32 mc_addr_count,
                          u32 rar_used_count,
                          u32 rar_count)
{
	if (hw->func.mc_addr_list_update != NULL)
		hw->func.mc_addr_list_update(hw,
		                             mc_addr_list,
		                             mc_addr_count,
		                             rar_used_count,
		                             rar_count);
}

/**
 *  e1000_force_mac_fc - Force MAC flow control
 *  @hw: pointer to the HW structure
 *
 *  Force the MAC's flow control settings. Currently no func pointer exists
 *  and all implementations are handled in the generic version of this
 *  function.
 **/
s32
e1000_force_mac_fc(struct e1000_hw *hw)
{
	return e1000_force_mac_fc_generic(hw);
}

/**
 *  e1000_check_for_link - Check/Store link connection
 *  @hw: pointer to the HW structure
 *
 *  This checks the link condition of the adapter and stores the
 *  results in the hw->mac structure. This is a function pointer entry
 *  point called by drivers.
 **/
s32
e1000_check_for_link(struct e1000_hw *hw)
{
	if (hw->func.check_for_link != NULL)
		return hw->func.check_for_link(hw);
	else
		return -E1000_ERR_CONFIG;
}

/**
 *  e1000_check_mng_mode - Check management mode
 *  @hw: pointer to the HW structure
 *
 *  This checks if the adapter has manageability enabled.
 *  This is a function pointer entry point called by drivers.
 **/
boolean_t
e1000_check_mng_mode(struct e1000_hw *hw)
{
	if (hw->func.check_mng_mode != NULL)
		return hw->func.check_mng_mode(hw);
	else
		return FALSE;
}

/**
 *  e1000_mng_write_dhcp_info - Writes DHCP info to host interface
 *  @hw: pointer to the HW structure
 *  @buffer: pointer to the host interface
 *  @length: size of the buffer
 *
 *  Writes the DHCP information to the host interface.
 **/
s32
e1000_mng_write_dhcp_info(struct e1000_hw *hw, u8 *buffer, u16 length)
{
	return e1000_mng_write_dhcp_info_generic(hw, buffer, length);
}

/**
 *  e1000_reset_hw - Reset hardware
 *  @hw: pointer to the HW structure
 *
 *  This resets the hardware into a known state. This is a function pointer
 *  entry point called by drivers.
 **/
s32
e1000_reset_hw(struct e1000_hw *hw)
{
	if (hw->func.reset_hw != NULL)
		return hw->func.reset_hw(hw);
	else
		return -E1000_ERR_CONFIG;
}

/**
 *  e1000_init_hw - Initialize hardware
 *  @hw: pointer to the HW structure
 *
 *  This inits the hardware readying it for operation. This is a function
 *  pointer entry point called by drivers.
 **/
s32
e1000_init_hw(struct e1000_hw *hw)
{
	if (hw->func.init_hw != NULL)
		return hw->func.init_hw(hw);
	else
		return -E1000_ERR_CONFIG;
}

/**
 *  e1000_setup_link - Configures link and flow control
 *  @hw: pointer to the HW structure
 *
 *  This configures link and flow control settings for the adapter. This
 *  is a function pointer entry point called by drivers. While modules can
 *  also call this, they probably call their own version of this function.
 **/
s32
e1000_setup_link(struct e1000_hw *hw)
{
	if (hw->func.setup_link != NULL)
		return hw->func.setup_link(hw);
	else
		return -E1000_ERR_CONFIG;
}

/**
 *  e1000_get_speed_and_duplex - Returns current speed and duplex
 *  @hw: pointer to the HW structure
 *  @speed: pointer to a 16-bit value to store the speed
 *  @duplex: pointer to a 16-bit value to store the duplex.
 *
 *  This returns the speed and duplex of the adapter in the two 'out'
 *  variables passed in. This is a function pointer entry point called
 *  by drivers.
 **/
s32
e1000_get_speed_and_duplex(struct e1000_hw *hw, u16 *speed, u16 *duplex)
{
	if (hw->func.get_link_up_info != NULL)
		return hw->func.get_link_up_info(hw, speed, duplex);
	else
		return -E1000_ERR_CONFIG;
}

/**
 *  e1000_setup_led - Configures SW controllable LED
 *  @hw: pointer to the HW structure
 *
 *  This prepares the SW controllable LED for use and saves the current state
 *  of the LED so it can be later restored. This is a function pointer entry
 *  point called by drivers.
 **/
s32
e1000_setup_led(struct e1000_hw *hw)
{
	if (hw->func.setup_led != NULL)
		return hw->func.setup_led(hw);
	else
		return E1000_SUCCESS;
}

/**
 *  e1000_cleanup_led - Restores SW controllable LED
 *  @hw: pointer to the HW structure
 *
 *  This restores the SW controllable LED to the value saved off by
 *  e1000_setup_led. This is a function pointer entry point called by drivers.
 **/
s32
e1000_cleanup_led(struct e1000_hw *hw)
{
	if (hw->func.cleanup_led != NULL)
		return hw->func.cleanup_led(hw);
	else
		return E1000_SUCCESS;
}

/**
 *  e1000_blink_led - Blink SW controllable LED
 *  @hw: pointer to the HW structure
 *
 *  This starts the adapter LED blinking. Request the LED to be setup first
 *  and cleaned up after. This is a function pointer entry point called by
 *  drivers.
 **/
s32
e1000_blink_led(struct e1000_hw *hw)
{
	if (hw->func.blink_led != NULL)
		return hw->func.blink_led(hw);
	else
		return E1000_SUCCESS;
}

/**
 *  e1000_led_on - Turn on SW controllable LED
 *  @hw: pointer to the HW structure
 *
 *  Turns the SW defined LED on. This is a function pointer entry point
 *  called by drivers.
 **/
s32
e1000_led_on(struct e1000_hw *hw)
{
	if (hw->func.led_on != NULL)
		return hw->func.led_on(hw);
	else
		return E1000_SUCCESS;
}

/**
 *  e1000_led_off - Turn off SW controllable LED
 *  @hw: pointer to the HW structure
 *
 *  Turns the SW defined LED off. This is a function pointer entry point
 *  called by drivers.
 **/
s32
e1000_led_off(struct e1000_hw *hw)
{
	if (hw->func.led_off != NULL)
		return hw->func.led_off(hw);
	else
		return E1000_SUCCESS;
}

/**
 *  e1000_reset_adaptive - Reset adaptive IFS
 *  @hw: pointer to the HW structure
 *
 *  Resets the adaptive IFS. Currently no func pointer exists and all
 *  implementations are handled in the generic version of this function.
 **/
void
e1000_reset_adaptive(struct e1000_hw *hw)
{
	e1000_reset_adaptive_generic(hw);
}

/**
 *  e1000_update_adaptive - Update adaptive IFS
 *  @hw: pointer to the HW structure
 *
 *  Updates adapter IFS. Currently no func pointer exists and all
 *  implementations are handled in the generic version of this function.
 **/
void
e1000_update_adaptive(struct e1000_hw *hw)
{
	e1000_update_adaptive_generic(hw);
}

/**
 *  e1000_disable_pcie_master - Disable PCI-Express master access
 *  @hw: pointer to the HW structure
 *
 *  Disables PCI-Express master access and verifies there are no pending
 *  requests. Currently no func pointer exists and all implementations are
 *  handled in the generic version of this function.
 **/
s32
e1000_disable_pcie_master(struct e1000_hw *hw)
{
	return e1000_disable_pcie_master_generic(hw);
}

/**
 *  e1000_config_collision_dist - Configure collision distance
 *  @hw: pointer to the HW structure
 *
 *  Configures the collision distance to the default value and is used
 *  during link setup.
 **/
void
e1000_config_collision_dist(struct e1000_hw *hw)
{
	if (hw->func.config_collision_dist != NULL)
		hw->func.config_collision_dist(hw);
}

/**
 *  e1000_rar_set - Sets a receive address register
 *  @hw: pointer to the HW structure
 *  @addr: address to set the RAR to
 *  @index: the RAR to set
 *
 *  Sets a Receive Address Register (RAR) to the specified address.
 **/
void
e1000_rar_set(struct e1000_hw *hw, u8 *addr, u32 index)
{
	if (hw->func.rar_set != NULL)
		hw->func.rar_set(hw, addr, index);
}

/**
 *  e1000_validate_mdi_setting - Ensures valid MDI/MDIX SW state
 *  @hw: pointer to the HW structure
 *
 *  Ensures that the MDI/MDIX SW state is valid.
 **/
s32
e1000_validate_mdi_setting(struct e1000_hw *hw)
{
	if (hw->func.validate_mdi_setting != NULL)
		return hw->func.validate_mdi_setting(hw);
	else
		return E1000_SUCCESS;
}

/**
 *  e1000_mta_set - Sets multicast table bit
 *  @hw: pointer to the HW structure
 *  @hash_value: Multicast hash value.
 *
 *  This sets the bit in the multicast table corresponding to the
 *  hash value.  This is a function pointer entry point called by drivers.
 **/
void
e1000_mta_set(struct e1000_hw *hw, u32 hash_value)
{
	if (hw->func.mta_set != NULL)
		hw->func.mta_set(hw, hash_value);
}

/**
 *  e1000_hash_mc_addr - Determines address location in multicast table
 *  @hw: pointer to the HW structure
 *  @mc_addr: Multicast address to hash.
 *
 *  This hashes an address to determine its location in the multicast
 *  table. Currently no func pointer exists and all implementations
 *  are handled in the generic version of this function.
 **/
u32
e1000_hash_mc_addr(struct e1000_hw *hw, u8 *mc_addr)
{
	return e1000_hash_mc_addr_generic(hw, mc_addr);
}

/**
 *  e1000_enable_tx_pkt_filtering - Enable packet filtering on TX
 *  @hw: pointer to the HW structure
 *
 *  Enables packet filtering on transmit packets if manageability is enabled
 *  and host interface is enabled.
 *  Currently no func pointer exists and all implementations are handled in the
 *  generic version of this function.
 **/
boolean_t
e1000_enable_tx_pkt_filtering(struct e1000_hw *hw)
{
	return e1000_enable_tx_pkt_filtering_generic(hw);
}

/**
 *  e1000_mng_host_if_write - Writes to the manageability host interface
 *  @hw: pointer to the HW structure
 *  @buffer: pointer to the host interface buffer
 *  @length: size of the buffer
 *  @offset: location in the buffer to write to
 *  @sum: sum of the data (not checksum)
 *
 *  This function writes the buffer content at the offset given on the host if.
 *  It also does alignment considerations to do the writes in most efficient
 *  way.  Also fills up the sum of the buffer in *buffer parameter.
 **/
s32
e1000_mng_host_if_write(struct e1000_hw * hw, u8 *buffer, u16 length,
                        u16 offset, u8 *sum)
{
	if (hw->func.mng_host_if_write != NULL)
		return hw->func.mng_host_if_write(hw, buffer, length, offset,
		                                  sum);
	else
		return E1000_NOT_IMPLEMENTED;
}

/**
 *  e1000_mng_write_cmd_header - Writes manageability command header
 *  @hw: pointer to the HW structure
 *  @hdr: pointer to the host interface command header
 *
 *  Writes the command header after does the checksum calculation.
 **/
s32
e1000_mng_write_cmd_header(struct e1000_hw *hw,
                           struct e1000_host_mng_command_header *hdr)
{
	if (hw->func.mng_write_cmd_header != NULL)
		return hw->func.mng_write_cmd_header(hw, hdr);
	else
		return E1000_NOT_IMPLEMENTED;
}

/**
 *  e1000_mng_enable_host_if - Checks host interface is enabled
 *  @hw: pointer to the HW structure
 *
 *  Returns E1000_success upon success, else E1000_ERR_HOST_INTERFACE_COMMAND
 *
 *  This function checks whether the HOST IF is enabled for command operaton
 *  and also checks whether the previous command is completed.  It busy waits
 *  in case of previous command is not completed.
 **/
s32
e1000_mng_enable_host_if(struct e1000_hw * hw)
{
	if (hw->func.mng_enable_host_if != NULL)
		return hw->func.mng_enable_host_if(hw);
	else
		return E1000_NOT_IMPLEMENTED;
}

/**
 *  e1000_wait_autoneg - Waits for autonegotiation completion
 *  @hw: pointer to the HW structure
 *
 *  Waits for autoneg to complete. Currently no func pointer exists and all
 *  implementations are handled in the generic version of this function.
 **/
s32
e1000_wait_autoneg(struct e1000_hw *hw)
{
	if (hw->func.wait_autoneg != NULL)
		return hw->func.wait_autoneg(hw);
	else
		return E1000_SUCCESS;
}

/**
 *  e1000_check_reset_block - Verifies PHY can be reset
 *  @hw: pointer to the HW structure
 *
 *  Checks if the PHY is in a state that can be reset or if manageability
 *  has it tied up. This is a function pointer entry point called by drivers.
 **/
s32
e1000_check_reset_block(struct e1000_hw *hw)
{
	if (hw->func.check_reset_block != NULL)
		return hw->func.check_reset_block(hw);
	else
		return E1000_SUCCESS;
}

/**
 *  e1000_read_phy_reg - Reads PHY register
 *  @hw: pointer to the HW structure
 *  @offset: the register to read
 *  @data: the buffer to store the 16-bit read.
 *
 *  Reads the PHY register and returns the value in data.
 *  This is a function pointer entry point called by drivers.
 **/
s32
e1000_read_phy_reg(struct e1000_hw *hw, u32 offset, u16 *data)
{
	if (hw->func.read_phy_reg != NULL)
		return hw->func.read_phy_reg(hw, offset, data);
	else
		return E1000_SUCCESS;
}

/**
 *  e1000_write_phy_reg - Writes PHY register
 *  @hw: pointer to the HW structure
 *  @offset: the register to write
 *  @data: the value to write.
 *
 *  Writes the PHY register at offset with the value in data.
 *  This is a function pointer entry point called by drivers.
 **/
s32
e1000_write_phy_reg(struct e1000_hw *hw, u32 offset, u16 data)
{
	if (hw->func.write_phy_reg != NULL)
		return hw->func.write_phy_reg(hw, offset, data);
	else
		return E1000_SUCCESS;
}

/**
 *  e1000_read_kmrn_reg - Reads register using Kumeran interface
 *  @hw: pointer to the HW structure
 *  @offset: the register to read
 *  @data: the location to store the 16-bit value read.
 *
 *  Reads a register out of the Kumeran interface. Currently no func pointer
 *  exists and all implementations are handled in the generic version of
 *  this function.
 **/
s32
e1000_read_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 *data)
{
	return e1000_read_kmrn_reg_generic(hw, offset, data);
}

/**
 *  e1000_write_kmrn_reg - Writes register using Kumeran interface
 *  @hw: pointer to the HW structure
 *  @offset: the register to write
 *  @data: the value to write.
 *
 *  Writes a register to the Kumeran interface. Currently no func pointer
 *  exists and all implementations are handled in the generic version of
 *  this function.
 **/
s32
e1000_write_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 data)
{
	return e1000_write_kmrn_reg_generic(hw, offset, data);
}

/**
 *  e1000_get_cable_length - Retrieves cable length estimation
 *  @hw: pointer to the HW structure
 *
 *  This function estimates the cable length and stores them in
 *  hw->phy.min_length and hw->phy.max_length. This is a function pointer
 *  entry point called by drivers.
 **/
s32
e1000_get_cable_length(struct e1000_hw *hw)
{
	if (hw->func.get_cable_length != NULL)
		return hw->func.get_cable_length(hw);
	else
		return E1000_SUCCESS;
}

/**
 *  e1000_get_phy_info - Retrieves PHY information from registers
 *  @hw: pointer to the HW structure
 *
 *  This function gets some information from various PHY registers and
 *  populates hw->phy values with it. This is a function pointer entry
 *  point called by drivers.
 **/
s32
e1000_get_phy_info(struct e1000_hw *hw)
{
	if (hw->func.get_phy_info != NULL)
		return hw->func.get_phy_info(hw);
	else
		return E1000_SUCCESS;
}

/**
 *  e1000_phy_hw_reset - Hard PHY reset
 *  @hw: pointer to the HW structure
 *
 *  Performs a hard PHY reset. This is a function pointer entry point called
 *  by drivers.
 **/
s32
e1000_phy_hw_reset(struct e1000_hw *hw)
{
	if (hw->func.reset_phy != NULL)
		return hw->func.reset_phy(hw);
	else
		return E1000_SUCCESS;
}

/**
 *  e1000_phy_commit - Soft PHY reset
 *  @hw: pointer to the HW structure
 *
 *  Performs a soft PHY reset on those that apply. This is a function pointer
 *  entry point called by drivers.
 **/
s32
e1000_phy_commit(struct e1000_hw *hw)
{
	if (hw->func.commit_phy != NULL)
		return hw->func.commit_phy(hw);
	else
		return E1000_SUCCESS;
}

/**
 *  e1000_set_d3_lplu_state - Sets low power link up state for D0
 *  @hw: pointer to the HW structure
 *  @active: boolean used to enable/disable lplu
 *
 *  Success returns 0, Failure returns 1
 *
 *  The low power link up (lplu) state is set to the power management level D0
 *  and SmartSpeed is disabled when active is true, else clear lplu for D0
 *  and enable Smartspeed.  LPLU and Smartspeed are mutually exclusive.  LPLU
 *  is used during Dx states where the power conservation is most important.
 *  During driver activity, SmartSpeed should be enabled so performance is
 *  maintained.  This is a function pointer entry point called by drivers.
 **/
s32
e1000_set_d0_lplu_state(struct e1000_hw *hw, boolean_t active)
{
	if (hw->func.set_d0_lplu_state != NULL)
		return hw->func.set_d0_lplu_state(hw, active);
	else
		return E1000_SUCCESS;
}

/**
 *  e1000_set_d3_lplu_state - Sets low power link up state for D3
 *  @hw: pointer to the HW structure
 *  @active: boolean used to enable/disable lplu
 *
 *  Success returns 0, Failure returns 1
 *
 *  The low power link up (lplu) state is set to the power management level D3
 *  and SmartSpeed is disabled when active is true, else clear lplu for D3
 *  and enable Smartspeed.  LPLU and Smartspeed are mutually exclusive.  LPLU
 *  is used during Dx states where the power conservation is most important.
 *  During driver activity, SmartSpeed should be enabled so performance is
 *  maintained.  This is a function pointer entry point called by drivers.
 **/
s32
e1000_set_d3_lplu_state(struct e1000_hw *hw, boolean_t active)
{
	if (hw->func.set_d3_lplu_state != NULL)
		return hw->func.set_d3_lplu_state(hw, active);
	else
		return E1000_SUCCESS;
}

/**
 *  e1000_read_mac_addr - Reads MAC address
 *  @hw: pointer to the HW structure
 *
 *  Reads the MAC address out of the adapter and stores it in the HW structure.
 *  Currently no func pointer exists and all implementations are handled in the
 *  generic version of this function.
 **/
s32
e1000_read_mac_addr(struct e1000_hw *hw)
{
	return e1000_read_mac_addr_generic(hw);
}

/**
 *  e1000_read_part_num - Read device part number
 *  @hw: pointer to the HW structure
 *  @part_num: pointer to device part number
 *
 *  Reads the product board assembly (PBA) number from the EEPROM and stores
 *  the value in part_num.
 *  Currently no func pointer exists and all implementations are handled in the
 *  generic version of this function.
 **/
s32
e1000_read_part_num(struct e1000_hw *hw, u32 *part_num)
{
	return e1000_read_part_num_generic(hw, part_num);
}

/**
 *  e1000_validate_nvm_checksum - Verifies NVM (EEPROM) checksum
 *  @hw: pointer to the HW structure
 *
 *  Validates the NVM checksum is correct. This is a function pointer entry
 *  point called by drivers.
 **/
s32
e1000_validate_nvm_checksum(struct e1000_hw *hw)
{
	if (hw->func.validate_nvm != NULL)
		return hw->func.validate_nvm(hw);
	else
		return -E1000_ERR_CONFIG;
}

/**
 *  e1000_update_nvm_checksum - Updates NVM (EEPROM) checksum
 *  @hw: pointer to the HW structure
 *
 *  Updates the NVM checksum. Currently no func pointer exists and all
 *  implementations are handled in the generic version of this function.
 **/
s32
e1000_update_nvm_checksum(struct e1000_hw *hw)
{
	if (hw->func.update_nvm != NULL)
		return hw->func.update_nvm(hw);
	else
		return -E1000_ERR_CONFIG;
}

/**
 *  e1000_reload_nvm - Reloads EEPROM
 *  @hw: pointer to the HW structure
 *
 *  Reloads the EEPROM by setting the "Reinitialize from EEPROM" bit in the
 *  extended control register.
 **/
void
e1000_reload_nvm(struct e1000_hw *hw)
{
	if (hw->func.reload_nvm != NULL)
		hw->func.reload_nvm(hw);
}

/**
 *  e1000_read_nvm - Reads NVM (EEPROM)
 *  @hw: pointer to the HW structure
 *  @offset: the word offset to read
 *  @words: number of 16-bit words to read
 *  @data: pointer to the properly sized buffer for the data.
 *
 *  Reads 16-bit chunks of data from the NVM (EEPROM). This is a function
 *  pointer entry point called by drivers.
 **/
s32
e1000_read_nvm(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
{
	if (hw->func.read_nvm != NULL)
		return hw->func.read_nvm(hw, offset, words, data);
	else
		return -E1000_ERR_CONFIG;
}

/**
 *  e1000_write_nvm - Writes to NVM (EEPROM)
 *  @hw: pointer to the HW structure
 *  @offset: the word offset to read
 *  @words: number of 16-bit words to write
 *  @data: pointer to the properly sized buffer for the data.
 *
 *  Writes 16-bit chunks of data to the NVM (EEPROM). This is a function
 *  pointer entry point called by drivers.
 **/
s32
e1000_write_nvm(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
{
	if (hw->func.write_nvm != NULL)
		return hw->func.write_nvm(hw, offset, words, data);
	else
		return E1000_SUCCESS;
}

/**
 *  e1000_write_8bit_ctrl_reg - Writes 8bit Control register
 *  @hw: pointer to the HW structure
 *  @reg: 32bit register offset
 *  @offset: the register to write
 *  @data: the value to write.
 *
 *  Writes the PHY register at offset with the value in data.
 *  This is a function pointer entry point called by drivers.
 **/
s32
e1000_write_8bit_ctrl_reg(struct e1000_hw *hw, u32 reg, u32 offset, u8 data)
{
	return e1000_write_8bit_ctrl_reg_generic(hw, reg, offset, data);
}