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