[GFS2] Fix up merge of Linus' kernel into GFS2
[pandora-kernel.git] / drivers / net / e1000 / e1000_param.c
1 /*******************************************************************************
2
3   
4   Copyright(c) 1999 - 2006 Intel Corporation. All rights reserved.
5   
6   This program is free software; you can redistribute it and/or modify it 
7   under the terms of the GNU General Public License as published by the Free 
8   Software Foundation; either version 2 of the License, or (at your option) 
9   any later version.
10   
11   This program is distributed in the hope that it will be useful, but WITHOUT 
12   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
13   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for 
14   more details.
15   
16   You should have received a copy of the GNU General Public License along with
17   this program; if not, write to the Free Software Foundation, Inc., 59 
18   Temple Place - Suite 330, Boston, MA  02111-1307, USA.
19   
20   The full GNU General Public License is included in this distribution in the
21   file called LICENSE.
22   
23   Contact Information:
24   Linux NICS <linux.nics@intel.com>
25   e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
26   Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
27
28 *******************************************************************************/
29
30 #include "e1000.h"
31
32 /* This is the only thing that needs to be changed to adjust the
33  * maximum number of ports that the driver can manage.
34  */
35
36 #define E1000_MAX_NIC 32
37
38 #define OPTION_UNSET   -1
39 #define OPTION_DISABLED 0
40 #define OPTION_ENABLED  1
41
42 /* All parameters are treated the same, as an integer array of values.
43  * This macro just reduces the need to repeat the same declaration code
44  * over and over (plus this helps to avoid typo bugs).
45  */
46
47 #define E1000_PARAM_INIT { [0 ... E1000_MAX_NIC] = OPTION_UNSET }
48 /* Module Parameters are always initialized to -1, so that the driver
49  * can tell the difference between no user specified value or the
50  * user asking for the default value.
51  * The true default values are loaded in when e1000_check_options is called.
52  *
53  * This is a GCC extension to ANSI C.
54  * See the item "Labeled Elements in Initializers" in the section
55  * "Extensions to the C Language Family" of the GCC documentation.
56  */
57
58 #define E1000_PARAM(X, desc) \
59         static int __devinitdata X[E1000_MAX_NIC+1] = E1000_PARAM_INIT; \
60         static int num_##X = 0; \
61         module_param_array_named(X, X, int, &num_##X, 0); \
62         MODULE_PARM_DESC(X, desc);
63
64 /* Transmit Descriptor Count
65  *
66  * Valid Range: 80-256 for 82542 and 82543 gigabit ethernet controllers
67  * Valid Range: 80-4096 for 82544 and newer
68  *
69  * Default Value: 256
70  */
71
72 E1000_PARAM(TxDescriptors, "Number of transmit descriptors");
73
74 /* Receive Descriptor Count
75  *
76  * Valid Range: 80-256 for 82542 and 82543 gigabit ethernet controllers
77  * Valid Range: 80-4096 for 82544 and newer
78  *
79  * Default Value: 256
80  */
81
82 E1000_PARAM(RxDescriptors, "Number of receive descriptors");
83
84 /* User Specified Speed Override
85  *
86  * Valid Range: 0, 10, 100, 1000
87  *  - 0    - auto-negotiate at all supported speeds
88  *  - 10   - only link at 10 Mbps
89  *  - 100  - only link at 100 Mbps
90  *  - 1000 - only link at 1000 Mbps
91  *
92  * Default Value: 0
93  */
94
95 E1000_PARAM(Speed, "Speed setting");
96
97 /* User Specified Duplex Override
98  *
99  * Valid Range: 0-2
100  *  - 0 - auto-negotiate for duplex
101  *  - 1 - only link at half duplex
102  *  - 2 - only link at full duplex
103  *
104  * Default Value: 0
105  */
106
107 E1000_PARAM(Duplex, "Duplex setting");
108
109 /* Auto-negotiation Advertisement Override
110  *
111  * Valid Range: 0x01-0x0F, 0x20-0x2F (copper); 0x20 (fiber)
112  *
113  * The AutoNeg value is a bit mask describing which speed and duplex
114  * combinations should be advertised during auto-negotiation.
115  * The supported speed and duplex modes are listed below
116  *
117  * Bit           7     6     5      4      3     2     1      0
118  * Speed (Mbps)  N/A   N/A   1000   N/A    100   100   10     10
119  * Duplex                    Full          Full  Half  Full   Half
120  *
121  * Default Value: 0x2F (copper); 0x20 (fiber)
122  */
123
124 E1000_PARAM(AutoNeg, "Advertised auto-negotiation setting");
125
126 /* User Specified Flow Control Override
127  *
128  * Valid Range: 0-3
129  *  - 0 - No Flow Control
130  *  - 1 - Rx only, respond to PAUSE frames but do not generate them
131  *  - 2 - Tx only, generate PAUSE frames but ignore them on receive
132  *  - 3 - Full Flow Control Support
133  *
134  * Default Value: Read flow control settings from the EEPROM
135  */
136
137 E1000_PARAM(FlowControl, "Flow Control setting");
138
139 /* XsumRX - Receive Checksum Offload Enable/Disable
140  *
141  * Valid Range: 0, 1
142  *  - 0 - disables all checksum offload
143  *  - 1 - enables receive IP/TCP/UDP checksum offload
144  *        on 82543 and newer -based NICs
145  *
146  * Default Value: 1
147  */
148
149 E1000_PARAM(XsumRX, "Disable or enable Receive Checksum offload");
150
151 /* Transmit Interrupt Delay in units of 1.024 microseconds
152  *
153  * Valid Range: 0-65535
154  *
155  * Default Value: 64
156  */
157
158 E1000_PARAM(TxIntDelay, "Transmit Interrupt Delay");
159
160 /* Transmit Absolute Interrupt Delay in units of 1.024 microseconds
161  *
162  * Valid Range: 0-65535
163  *
164  * Default Value: 0
165  */
166
167 E1000_PARAM(TxAbsIntDelay, "Transmit Absolute Interrupt Delay");
168
169 /* Receive Interrupt Delay in units of 1.024 microseconds
170  *
171  * Valid Range: 0-65535
172  *
173  * Default Value: 0
174  */
175
176 E1000_PARAM(RxIntDelay, "Receive Interrupt Delay");
177
178 /* Receive Absolute Interrupt Delay in units of 1.024 microseconds
179  *
180  * Valid Range: 0-65535
181  *
182  * Default Value: 128
183  */
184
185 E1000_PARAM(RxAbsIntDelay, "Receive Absolute Interrupt Delay");
186
187 /* Interrupt Throttle Rate (interrupts/sec)
188  *
189  * Valid Range: 100-100000 (0=off, 1=dynamic)
190  *
191  * Default Value: 8000
192  */
193
194 E1000_PARAM(InterruptThrottleRate, "Interrupt Throttling Rate");
195
196 /* Enable Smart Power Down of the PHY
197  *
198  * Valid Range: 0, 1
199  *
200  * Default Value: 0 (disabled)
201  */
202
203 E1000_PARAM(SmartPowerDownEnable, "Enable PHY smart power down");
204
205 /* Enable Kumeran Lock Loss workaround
206  *
207  * Valid Range: 0, 1
208  *
209  * Default Value: 1 (enabled)
210  */
211
212 E1000_PARAM(KumeranLockLoss, "Enable Kumeran lock loss workaround");
213
214 #define AUTONEG_ADV_DEFAULT  0x2F
215 #define AUTONEG_ADV_MASK     0x2F
216 #define FLOW_CONTROL_DEFAULT FLOW_CONTROL_FULL
217
218 #define DEFAULT_RDTR                   0
219 #define MAX_RXDELAY               0xFFFF
220 #define MIN_RXDELAY                    0
221
222 #define DEFAULT_RADV                 128
223 #define MAX_RXABSDELAY            0xFFFF
224 #define MIN_RXABSDELAY                 0
225
226 #define DEFAULT_TIDV                  64
227 #define MAX_TXDELAY               0xFFFF
228 #define MIN_TXDELAY                    0
229
230 #define DEFAULT_TADV                  64
231 #define MAX_TXABSDELAY            0xFFFF
232 #define MIN_TXABSDELAY                 0
233
234 #define DEFAULT_ITR                 8000
235 #define MAX_ITR                   100000
236 #define MIN_ITR                      100
237
238 struct e1000_option {
239         enum { enable_option, range_option, list_option } type;
240         char *name;
241         char *err;
242         int  def;
243         union {
244                 struct { /* range_option info */
245                         int min;
246                         int max;
247                 } r;
248                 struct { /* list_option info */
249                         int nr;
250                         struct e1000_opt_list { int i; char *str; } *p;
251                 } l;
252         } arg;
253 };
254
255 static int __devinit
256 e1000_validate_option(int *value, struct e1000_option *opt,
257                 struct e1000_adapter *adapter)
258 {
259         if (*value == OPTION_UNSET) {
260                 *value = opt->def;
261                 return 0;
262         }
263
264         switch (opt->type) {
265         case enable_option:
266                 switch (*value) {
267                 case OPTION_ENABLED:
268                         DPRINTK(PROBE, INFO, "%s Enabled\n", opt->name);
269                         return 0;
270                 case OPTION_DISABLED:
271                         DPRINTK(PROBE, INFO, "%s Disabled\n", opt->name);
272                         return 0;
273                 }
274                 break;
275         case range_option:
276                 if (*value >= opt->arg.r.min && *value <= opt->arg.r.max) {
277                         DPRINTK(PROBE, INFO,
278                                         "%s set to %i\n", opt->name, *value);
279                         return 0;
280                 }
281                 break;
282         case list_option: {
283                 int i;
284                 struct e1000_opt_list *ent;
285
286                 for (i = 0; i < opt->arg.l.nr; i++) {
287                         ent = &opt->arg.l.p[i];
288                         if (*value == ent->i) {
289                                 if (ent->str[0] != '\0')
290                                         DPRINTK(PROBE, INFO, "%s\n", ent->str);
291                                 return 0;
292                         }
293                 }
294         }
295                 break;
296         default:
297                 BUG();
298         }
299
300         DPRINTK(PROBE, INFO, "Invalid %s value specified (%i) %s\n",
301                opt->name, *value, opt->err);
302         *value = opt->def;
303         return -1;
304 }
305
306 static void e1000_check_fiber_options(struct e1000_adapter *adapter);
307 static void e1000_check_copper_options(struct e1000_adapter *adapter);
308
309 /**
310  * e1000_check_options - Range Checking for Command Line Parameters
311  * @adapter: board private structure
312  *
313  * This routine checks all command line parameters for valid user
314  * input.  If an invalid value is given, or if no user specified
315  * value exists, a default value is used.  The final value is stored
316  * in a variable in the adapter structure.
317  **/
318
319 void __devinit
320 e1000_check_options(struct e1000_adapter *adapter)
321 {
322         int bd = adapter->bd_number;
323         if (bd >= E1000_MAX_NIC) {
324                 DPRINTK(PROBE, NOTICE,
325                        "Warning: no configuration for board #%i\n", bd);
326                 DPRINTK(PROBE, NOTICE, "Using defaults for all values\n");
327         }
328
329         { /* Transmit Descriptor Count */
330                 struct e1000_option opt = {
331                         .type = range_option,
332                         .name = "Transmit Descriptors",
333                         .err  = "using default of "
334                                 __MODULE_STRING(E1000_DEFAULT_TXD),
335                         .def  = E1000_DEFAULT_TXD,
336                         .arg  = { .r = { .min = E1000_MIN_TXD }}
337                 };
338                 struct e1000_tx_ring *tx_ring = adapter->tx_ring;
339                 int i;
340                 e1000_mac_type mac_type = adapter->hw.mac_type;
341                 opt.arg.r.max = mac_type < e1000_82544 ?
342                         E1000_MAX_TXD : E1000_MAX_82544_TXD;
343
344                 if (num_TxDescriptors > bd) {
345                         tx_ring->count = TxDescriptors[bd];
346                         e1000_validate_option(&tx_ring->count, &opt, adapter);
347                         E1000_ROUNDUP(tx_ring->count,
348                                                 REQ_TX_DESCRIPTOR_MULTIPLE);
349                 } else {
350                         tx_ring->count = opt.def;
351                 }
352                 for (i = 0; i < adapter->num_tx_queues; i++)
353                         tx_ring[i].count = tx_ring->count;
354         }
355         { /* Receive Descriptor Count */
356                 struct e1000_option opt = {
357                         .type = range_option,
358                         .name = "Receive Descriptors",
359                         .err  = "using default of "
360                                 __MODULE_STRING(E1000_DEFAULT_RXD),
361                         .def  = E1000_DEFAULT_RXD,
362                         .arg  = { .r = { .min = E1000_MIN_RXD }}
363                 };
364                 struct e1000_rx_ring *rx_ring = adapter->rx_ring;
365                 int i;
366                 e1000_mac_type mac_type = adapter->hw.mac_type;
367                 opt.arg.r.max = mac_type < e1000_82544 ? E1000_MAX_RXD :
368                         E1000_MAX_82544_RXD;
369
370                 if (num_RxDescriptors > bd) {
371                         rx_ring->count = RxDescriptors[bd];
372                         e1000_validate_option(&rx_ring->count, &opt, adapter);
373                         E1000_ROUNDUP(rx_ring->count,
374                                                 REQ_RX_DESCRIPTOR_MULTIPLE);
375                 } else {
376                         rx_ring->count = opt.def;
377                 }
378                 for (i = 0; i < adapter->num_rx_queues; i++)
379                         rx_ring[i].count = rx_ring->count;
380         }
381         { /* Checksum Offload Enable/Disable */
382                 struct e1000_option opt = {
383                         .type = enable_option,
384                         .name = "Checksum Offload",
385                         .err  = "defaulting to Enabled",
386                         .def  = OPTION_ENABLED
387                 };
388
389                 if (num_XsumRX > bd) {
390                         int rx_csum = XsumRX[bd];
391                         e1000_validate_option(&rx_csum, &opt, adapter);
392                         adapter->rx_csum = rx_csum;
393                 } else {
394                         adapter->rx_csum = opt.def;
395                 }
396         }
397         { /* Flow Control */
398
399                 struct e1000_opt_list fc_list[] =
400                         {{ e1000_fc_none,    "Flow Control Disabled" },
401                          { e1000_fc_rx_pause,"Flow Control Receive Only" },
402                          { e1000_fc_tx_pause,"Flow Control Transmit Only" },
403                          { e1000_fc_full,    "Flow Control Enabled" },
404                          { e1000_fc_default, "Flow Control Hardware Default" }};
405
406                 struct e1000_option opt = {
407                         .type = list_option,
408                         .name = "Flow Control",
409                         .err  = "reading default settings from EEPROM",
410                         .def  = e1000_fc_default,
411                         .arg  = { .l = { .nr = ARRAY_SIZE(fc_list),
412                                          .p = fc_list }}
413                 };
414
415                 if (num_FlowControl > bd) {
416                         int fc = FlowControl[bd];
417                         e1000_validate_option(&fc, &opt, adapter);
418                         adapter->hw.fc = adapter->hw.original_fc = fc;
419                 } else {
420                         adapter->hw.fc = adapter->hw.original_fc = opt.def;
421                 }
422         }
423         { /* Transmit Interrupt Delay */
424                 struct e1000_option opt = {
425                         .type = range_option,
426                         .name = "Transmit Interrupt Delay",
427                         .err  = "using default of " __MODULE_STRING(DEFAULT_TIDV),
428                         .def  = DEFAULT_TIDV,
429                         .arg  = { .r = { .min = MIN_TXDELAY,
430                                          .max = MAX_TXDELAY }}
431                 };
432
433                 if (num_TxIntDelay > bd) {
434                         adapter->tx_int_delay = TxIntDelay[bd];
435                         e1000_validate_option(&adapter->tx_int_delay, &opt,
436                                               adapter);
437                 } else {
438                         adapter->tx_int_delay = opt.def;
439                 }
440         }
441         { /* Transmit Absolute Interrupt Delay */
442                 struct e1000_option opt = {
443                         .type = range_option,
444                         .name = "Transmit Absolute Interrupt Delay",
445                         .err  = "using default of " __MODULE_STRING(DEFAULT_TADV),
446                         .def  = DEFAULT_TADV,
447                         .arg  = { .r = { .min = MIN_TXABSDELAY,
448                                          .max = MAX_TXABSDELAY }}
449                 };
450
451                 if (num_TxAbsIntDelay > bd) {
452                         adapter->tx_abs_int_delay = TxAbsIntDelay[bd];
453                         e1000_validate_option(&adapter->tx_abs_int_delay, &opt,
454                                               adapter);
455                 } else {
456                         adapter->tx_abs_int_delay = opt.def;
457                 }
458         }
459         { /* Receive Interrupt Delay */
460                 struct e1000_option opt = {
461                         .type = range_option,
462                         .name = "Receive Interrupt Delay",
463                         .err  = "using default of " __MODULE_STRING(DEFAULT_RDTR),
464                         .def  = DEFAULT_RDTR,
465                         .arg  = { .r = { .min = MIN_RXDELAY,
466                                          .max = MAX_RXDELAY }}
467                 };
468
469                 if (num_RxIntDelay > bd) {
470                         adapter->rx_int_delay = RxIntDelay[bd];
471                         e1000_validate_option(&adapter->rx_int_delay, &opt,
472                                               adapter);
473                 } else {
474                         adapter->rx_int_delay = opt.def;
475                 }
476         }
477         { /* Receive Absolute Interrupt Delay */
478                 struct e1000_option opt = {
479                         .type = range_option,
480                         .name = "Receive Absolute Interrupt Delay",
481                         .err  = "using default of " __MODULE_STRING(DEFAULT_RADV),
482                         .def  = DEFAULT_RADV,
483                         .arg  = { .r = { .min = MIN_RXABSDELAY,
484                                          .max = MAX_RXABSDELAY }}
485                 };
486
487                 if (num_RxAbsIntDelay > bd) {
488                         adapter->rx_abs_int_delay = RxAbsIntDelay[bd];
489                         e1000_validate_option(&adapter->rx_abs_int_delay, &opt,
490                                               adapter);
491                 } else {
492                         adapter->rx_abs_int_delay = opt.def;
493                 }
494         }
495         { /* Interrupt Throttling Rate */
496                 struct e1000_option opt = {
497                         .type = range_option,
498                         .name = "Interrupt Throttling Rate (ints/sec)",
499                         .err  = "using default of " __MODULE_STRING(DEFAULT_ITR),
500                         .def  = DEFAULT_ITR,
501                         .arg  = { .r = { .min = MIN_ITR,
502                                          .max = MAX_ITR }}
503                 };
504
505                 if (num_InterruptThrottleRate > bd) {
506                         adapter->itr = InterruptThrottleRate[bd];
507                         switch (adapter->itr) {
508                         case 0:
509                                 DPRINTK(PROBE, INFO, "%s turned off\n",
510                                         opt.name);
511                                 break;
512                         case 1:
513                                 DPRINTK(PROBE, INFO, "%s set to dynamic mode\n",
514                                         opt.name);
515                                 break;
516                         default:
517                                 e1000_validate_option(&adapter->itr, &opt,
518                                                       adapter);
519                                 break;
520                         }
521                 } else {
522                         adapter->itr = opt.def;
523                 }
524         }
525         { /* Smart Power Down */
526                 struct e1000_option opt = {
527                         .type = enable_option,
528                         .name = "PHY Smart Power Down",
529                         .err  = "defaulting to Disabled",
530                         .def  = OPTION_DISABLED
531                 };
532
533                 if (num_SmartPowerDownEnable > bd) {
534                         int spd = SmartPowerDownEnable[bd];
535                         e1000_validate_option(&spd, &opt, adapter);
536                         adapter->smart_power_down = spd;
537                 } else {
538                         adapter->smart_power_down = opt.def;
539                 }
540         }
541         { /* Kumeran Lock Loss Workaround */
542                 struct e1000_option opt = {
543                         .type = enable_option,
544                         .name = "Kumeran Lock Loss Workaround",
545                         .err  = "defaulting to Enabled",
546                         .def  = OPTION_ENABLED
547                 };
548
549                 if (num_KumeranLockLoss > bd) {
550                         int kmrn_lock_loss = KumeranLockLoss[bd];
551                         e1000_validate_option(&kmrn_lock_loss, &opt, adapter);
552                         adapter->hw.kmrn_lock_loss_workaround_disabled = !kmrn_lock_loss;
553                 } else {
554                         adapter->hw.kmrn_lock_loss_workaround_disabled = !opt.def;
555                 }
556         }
557
558         switch (adapter->hw.media_type) {
559         case e1000_media_type_fiber:
560         case e1000_media_type_internal_serdes:
561                 e1000_check_fiber_options(adapter);
562                 break;
563         case e1000_media_type_copper:
564                 e1000_check_copper_options(adapter);
565                 break;
566         default:
567                 BUG();
568         }
569 }
570
571 /**
572  * e1000_check_fiber_options - Range Checking for Link Options, Fiber Version
573  * @adapter: board private structure
574  *
575  * Handles speed and duplex options on fiber adapters
576  **/
577
578 static void __devinit
579 e1000_check_fiber_options(struct e1000_adapter *adapter)
580 {
581         int bd = adapter->bd_number;
582         if (num_Speed > bd) {
583                 DPRINTK(PROBE, INFO, "Speed not valid for fiber adapters, "
584                        "parameter ignored\n");
585         }
586
587         if (num_Duplex > bd) {
588                 DPRINTK(PROBE, INFO, "Duplex not valid for fiber adapters, "
589                        "parameter ignored\n");
590         }
591
592         if ((num_AutoNeg > bd) && (AutoNeg[bd] != 0x20)) {
593                 DPRINTK(PROBE, INFO, "AutoNeg other than 1000/Full is "
594                                  "not valid for fiber adapters, "
595                                  "parameter ignored\n");
596         }
597 }
598
599 /**
600  * e1000_check_copper_options - Range Checking for Link Options, Copper Version
601  * @adapter: board private structure
602  *
603  * Handles speed and duplex options on copper adapters
604  **/
605
606 static void __devinit
607 e1000_check_copper_options(struct e1000_adapter *adapter)
608 {
609         int speed, dplx, an;
610         int bd = adapter->bd_number;
611
612         { /* Speed */
613                 struct e1000_opt_list speed_list[] = {{          0, "" },
614                                                       {   SPEED_10, "" },
615                                                       {  SPEED_100, "" },
616                                                       { SPEED_1000, "" }};
617
618                 struct e1000_option opt = {
619                         .type = list_option,
620                         .name = "Speed",
621                         .err  = "parameter ignored",
622                         .def  = 0,
623                         .arg  = { .l = { .nr = ARRAY_SIZE(speed_list),
624                                          .p = speed_list }}
625                 };
626
627                 if (num_Speed > bd) {
628                         speed = Speed[bd];
629                         e1000_validate_option(&speed, &opt, adapter);
630                 } else {
631                         speed = opt.def;
632                 }
633         }
634         { /* Duplex */
635                 struct e1000_opt_list dplx_list[] = {{           0, "" },
636                                                      { HALF_DUPLEX, "" },
637                                                      { FULL_DUPLEX, "" }};
638
639                 struct e1000_option opt = {
640                         .type = list_option,
641                         .name = "Duplex",
642                         .err  = "parameter ignored",
643                         .def  = 0,
644                         .arg  = { .l = { .nr = ARRAY_SIZE(dplx_list),
645                                          .p = dplx_list }}
646                 };
647
648                 if (e1000_check_phy_reset_block(&adapter->hw)) {
649                         DPRINTK(PROBE, INFO,
650                                 "Link active due to SoL/IDER Session. "
651                                 "Speed/Duplex/AutoNeg parameter ignored.\n");
652                         return;
653                 }
654                 if (num_Duplex > bd) {
655                         dplx = Duplex[bd];
656                         e1000_validate_option(&dplx, &opt, adapter);
657                 } else {
658                         dplx = opt.def;
659                 }
660         }
661
662         if ((num_AutoNeg > bd) && (speed != 0 || dplx != 0)) {
663                 DPRINTK(PROBE, INFO,
664                        "AutoNeg specified along with Speed or Duplex, "
665                        "parameter ignored\n");
666                 adapter->hw.autoneg_advertised = AUTONEG_ADV_DEFAULT;
667         } else { /* Autoneg */
668                 struct e1000_opt_list an_list[] =
669                         #define AA "AutoNeg advertising "
670                         {{ 0x01, AA "10/HD" },
671                          { 0x02, AA "10/FD" },
672                          { 0x03, AA "10/FD, 10/HD" },
673                          { 0x04, AA "100/HD" },
674                          { 0x05, AA "100/HD, 10/HD" },
675                          { 0x06, AA "100/HD, 10/FD" },
676                          { 0x07, AA "100/HD, 10/FD, 10/HD" },
677                          { 0x08, AA "100/FD" },
678                          { 0x09, AA "100/FD, 10/HD" },
679                          { 0x0a, AA "100/FD, 10/FD" },
680                          { 0x0b, AA "100/FD, 10/FD, 10/HD" },
681                          { 0x0c, AA "100/FD, 100/HD" },
682                          { 0x0d, AA "100/FD, 100/HD, 10/HD" },
683                          { 0x0e, AA "100/FD, 100/HD, 10/FD" },
684                          { 0x0f, AA "100/FD, 100/HD, 10/FD, 10/HD" },
685                          { 0x20, AA "1000/FD" },
686                          { 0x21, AA "1000/FD, 10/HD" },
687                          { 0x22, AA "1000/FD, 10/FD" },
688                          { 0x23, AA "1000/FD, 10/FD, 10/HD" },
689                          { 0x24, AA "1000/FD, 100/HD" },
690                          { 0x25, AA "1000/FD, 100/HD, 10/HD" },
691                          { 0x26, AA "1000/FD, 100/HD, 10/FD" },
692                          { 0x27, AA "1000/FD, 100/HD, 10/FD, 10/HD" },
693                          { 0x28, AA "1000/FD, 100/FD" },
694                          { 0x29, AA "1000/FD, 100/FD, 10/HD" },
695                          { 0x2a, AA "1000/FD, 100/FD, 10/FD" },
696                          { 0x2b, AA "1000/FD, 100/FD, 10/FD, 10/HD" },
697                          { 0x2c, AA "1000/FD, 100/FD, 100/HD" },
698                          { 0x2d, AA "1000/FD, 100/FD, 100/HD, 10/HD" },
699                          { 0x2e, AA "1000/FD, 100/FD, 100/HD, 10/FD" },
700                          { 0x2f, AA "1000/FD, 100/FD, 100/HD, 10/FD, 10/HD" }};
701
702                 struct e1000_option opt = {
703                         .type = list_option,
704                         .name = "AutoNeg",
705                         .err  = "parameter ignored",
706                         .def  = AUTONEG_ADV_DEFAULT,
707                         .arg  = { .l = { .nr = ARRAY_SIZE(an_list),
708                                          .p = an_list }}
709                 };
710
711                 if (num_AutoNeg > bd) {
712                         an = AutoNeg[bd];
713                         e1000_validate_option(&an, &opt, adapter);
714                 } else {
715                         an = opt.def;
716                 }
717                 adapter->hw.autoneg_advertised = an;
718         }
719
720         switch (speed + dplx) {
721         case 0:
722                 adapter->hw.autoneg = adapter->fc_autoneg = 1;
723                 if ((num_Speed > bd) && (speed != 0 || dplx != 0))
724                         DPRINTK(PROBE, INFO,
725                                "Speed and duplex autonegotiation enabled\n");
726                 break;
727         case HALF_DUPLEX:
728                 DPRINTK(PROBE, INFO, "Half Duplex specified without Speed\n");
729                 DPRINTK(PROBE, INFO, "Using Autonegotiation at "
730                         "Half Duplex only\n");
731                 adapter->hw.autoneg = adapter->fc_autoneg = 1;
732                 adapter->hw.autoneg_advertised = ADVERTISE_10_HALF |
733                                                  ADVERTISE_100_HALF;
734                 break;
735         case FULL_DUPLEX:
736                 DPRINTK(PROBE, INFO, "Full Duplex specified without Speed\n");
737                 DPRINTK(PROBE, INFO, "Using Autonegotiation at "
738                         "Full Duplex only\n");
739                 adapter->hw.autoneg = adapter->fc_autoneg = 1;
740                 adapter->hw.autoneg_advertised = ADVERTISE_10_FULL |
741                                                  ADVERTISE_100_FULL |
742                                                  ADVERTISE_1000_FULL;
743                 break;
744         case SPEED_10:
745                 DPRINTK(PROBE, INFO, "10 Mbps Speed specified "
746                         "without Duplex\n");
747                 DPRINTK(PROBE, INFO, "Using Autonegotiation at 10 Mbps only\n");
748                 adapter->hw.autoneg = adapter->fc_autoneg = 1;
749                 adapter->hw.autoneg_advertised = ADVERTISE_10_HALF |
750                                                  ADVERTISE_10_FULL;
751                 break;
752         case SPEED_10 + HALF_DUPLEX:
753                 DPRINTK(PROBE, INFO, "Forcing to 10 Mbps Half Duplex\n");
754                 adapter->hw.autoneg = adapter->fc_autoneg = 0;
755                 adapter->hw.forced_speed_duplex = e1000_10_half;
756                 adapter->hw.autoneg_advertised = 0;
757                 break;
758         case SPEED_10 + FULL_DUPLEX:
759                 DPRINTK(PROBE, INFO, "Forcing to 10 Mbps Full Duplex\n");
760                 adapter->hw.autoneg = adapter->fc_autoneg = 0;
761                 adapter->hw.forced_speed_duplex = e1000_10_full;
762                 adapter->hw.autoneg_advertised = 0;
763                 break;
764         case SPEED_100:
765                 DPRINTK(PROBE, INFO, "100 Mbps Speed specified "
766                         "without Duplex\n");
767                 DPRINTK(PROBE, INFO, "Using Autonegotiation at "
768                         "100 Mbps only\n");
769                 adapter->hw.autoneg = adapter->fc_autoneg = 1;
770                 adapter->hw.autoneg_advertised = ADVERTISE_100_HALF |
771                                                  ADVERTISE_100_FULL;
772                 break;
773         case SPEED_100 + HALF_DUPLEX:
774                 DPRINTK(PROBE, INFO, "Forcing to 100 Mbps Half Duplex\n");
775                 adapter->hw.autoneg = adapter->fc_autoneg = 0;
776                 adapter->hw.forced_speed_duplex = e1000_100_half;
777                 adapter->hw.autoneg_advertised = 0;
778                 break;
779         case SPEED_100 + FULL_DUPLEX:
780                 DPRINTK(PROBE, INFO, "Forcing to 100 Mbps Full Duplex\n");
781                 adapter->hw.autoneg = adapter->fc_autoneg = 0;
782                 adapter->hw.forced_speed_duplex = e1000_100_full;
783                 adapter->hw.autoneg_advertised = 0;
784                 break;
785         case SPEED_1000:
786                 DPRINTK(PROBE, INFO, "1000 Mbps Speed specified without "
787                         "Duplex\n");
788                 DPRINTK(PROBE, INFO,
789                         "Using Autonegotiation at 1000 Mbps "
790                         "Full Duplex only\n");
791                 adapter->hw.autoneg = adapter->fc_autoneg = 1;
792                 adapter->hw.autoneg_advertised = ADVERTISE_1000_FULL;
793                 break;
794         case SPEED_1000 + HALF_DUPLEX:
795                 DPRINTK(PROBE, INFO,
796                         "Half Duplex is not supported at 1000 Mbps\n");
797                 DPRINTK(PROBE, INFO,
798                         "Using Autonegotiation at 1000 Mbps "
799                         "Full Duplex only\n");
800                 adapter->hw.autoneg = adapter->fc_autoneg = 1;
801                 adapter->hw.autoneg_advertised = ADVERTISE_1000_FULL;
802                 break;
803         case SPEED_1000 + FULL_DUPLEX:
804                 DPRINTK(PROBE, INFO,
805                        "Using Autonegotiation at 1000 Mbps Full Duplex only\n");
806                 adapter->hw.autoneg = adapter->fc_autoneg = 1;
807                 adapter->hw.autoneg_advertised = ADVERTISE_1000_FULL;
808                 break;
809         default:
810                 BUG();
811         }
812
813         /* Speed, AutoNeg and MDI/MDI-X must all play nice */
814         if (e1000_validate_mdi_setting(&(adapter->hw)) < 0) {
815                 DPRINTK(PROBE, INFO,
816                         "Speed, AutoNeg and MDI-X specifications are "
817                         "incompatible. Setting MDI-X to a compatible value.\n");
818         }
819 }
820