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