patch-2_6_7-vs1_9_1_12
[linux-2.6.git] / drivers / net / e1000 / e1000_param.c
1 /*******************************************************************************
2
3   
4   Copyright(c) 1999 - 2004 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   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 /* Module Parameters are always initialized to -1, so that the driver
42  * can tell the difference between no user specified value or the
43  * user asking for the default value.
44  * The true default values are loaded in when e1000_check_options is called.
45  *
46  * This is a GCC extension to ANSI C.
47  * See the item "Labeled Elements in Initializers" in the section
48  * "Extensions to the C Language Family" of the GCC documentation.
49  */
50
51 #define E1000_PARAM_INIT { [0 ... E1000_MAX_NIC] = OPTION_UNSET }
52
53 /* All parameters are treated the same, as an integer array of values.
54  * This macro just reduces the need to repeat the same declaration code
55  * over and over (plus this helps to avoid typo bugs).
56  */
57
58 #define E1000_PARAM(X, S) \
59 static const int __devinitdata X[E1000_MAX_NIC + 1] = E1000_PARAM_INIT; \
60 MODULE_PARM(X, "1-" __MODULE_STRING(E1000_MAX_NIC) "i"); \
61 MODULE_PARM_DESC(X, S);
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: 1
191  */
192
193 E1000_PARAM(InterruptThrottleRate, "Interrupt Throttling Rate");
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                    1
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 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                 bd = E1000_MAX_NIC;
309         }
310
311         { /* Transmit Descriptor Count */
312                 struct e1000_option opt = {
313                         .type = range_option,
314                         .name = "Transmit Descriptors",
315                         .err  = "using default of "
316                                 __MODULE_STRING(E1000_DEFAULT_TXD),
317                         .def  = E1000_DEFAULT_TXD,
318                         .arg  = { .r = { .min = E1000_MIN_TXD }}
319                 };
320                 struct e1000_desc_ring *tx_ring = &adapter->tx_ring;
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                 tx_ring->count = TxDescriptors[bd];
326                 e1000_validate_option(&tx_ring->count, &opt, adapter);
327                 E1000_ROUNDUP(tx_ring->count, REQ_TX_DESCRIPTOR_MULTIPLE);
328         }
329         { /* Receive Descriptor Count */
330                 struct e1000_option opt = {
331                         .type = range_option,
332                         .name = "Receive Descriptors",
333                         .err  = "using default of "
334                                 __MODULE_STRING(E1000_DEFAULT_RXD),
335                         .def  = E1000_DEFAULT_RXD,
336                         .arg  = { .r = { .min = E1000_MIN_RXD }}
337                 };
338                 struct e1000_desc_ring *rx_ring = &adapter->rx_ring;
339                 e1000_mac_type mac_type = adapter->hw.mac_type;
340                 opt.arg.r.max = mac_type < e1000_82544 ? E1000_MAX_RXD :
341                         E1000_MAX_82544_RXD;
342
343                 rx_ring->count = RxDescriptors[bd];
344                 e1000_validate_option(&rx_ring->count, &opt, adapter);
345                 E1000_ROUNDUP(rx_ring->count, REQ_RX_DESCRIPTOR_MULTIPLE);
346         }
347         { /* Checksum Offload Enable/Disable */
348                 struct e1000_option opt = {
349                         .type = enable_option,
350                         .name = "Checksum Offload",
351                         .err  = "defaulting to Enabled",
352                         .def  = OPTION_ENABLED
353                 };
354
355                 int rx_csum = XsumRX[bd];
356                 e1000_validate_option(&rx_csum, &opt, adapter);
357                 adapter->rx_csum = rx_csum;
358         }
359         { /* Flow Control */
360
361                 struct e1000_opt_list fc_list[] =
362                         {{ e1000_fc_none,    "Flow Control Disabled" },
363                          { e1000_fc_rx_pause,"Flow Control Receive Only" },
364                          { e1000_fc_tx_pause,"Flow Control Transmit Only" },
365                          { e1000_fc_full,    "Flow Control Enabled" },
366                          { e1000_fc_default, "Flow Control Hardware Default" }};
367
368                 struct e1000_option opt = {
369                         .type = list_option,
370                         .name = "Flow Control",
371                         .err  = "reading default settings from EEPROM",
372                         .def  = e1000_fc_default,
373                         .arg  = { .l = { .nr = ARRAY_SIZE(fc_list),
374                                          .p = fc_list }}
375                 };
376
377                 int fc = FlowControl[bd];
378                 e1000_validate_option(&fc, &opt, adapter);
379                 adapter->hw.fc = adapter->hw.original_fc = fc;
380         }
381         { /* Transmit Interrupt Delay */
382                 struct e1000_option opt = {
383                         .type = range_option,
384                         .name = "Transmit Interrupt Delay",
385                         .err  = "using default of " __MODULE_STRING(DEFAULT_TIDV),
386                         .def  = DEFAULT_TIDV,
387                         .arg  = { .r = { .min = MIN_TXDELAY,
388                                          .max = MAX_TXDELAY }}
389                 };
390
391                 adapter->tx_int_delay = TxIntDelay[bd];
392                 e1000_validate_option(&adapter->tx_int_delay, &opt, adapter);
393         }
394         { /* Transmit Absolute Interrupt Delay */
395                 struct e1000_option opt = {
396                         .type = range_option,
397                         .name = "Transmit Absolute Interrupt Delay",
398                         .err  = "using default of " __MODULE_STRING(DEFAULT_TADV),
399                         .def  = DEFAULT_TADV,
400                         .arg  = { .r = { .min = MIN_TXABSDELAY,
401                                          .max = MAX_TXABSDELAY }}
402                 };
403
404                 adapter->tx_abs_int_delay = TxAbsIntDelay[bd];
405                 e1000_validate_option(&adapter->tx_abs_int_delay, &opt, adapter);
406         }
407         { /* Receive Interrupt Delay */
408                 struct e1000_option opt = {
409                         .type = range_option,
410                         .name = "Receive Interrupt Delay",
411                         .err  = "using default of " __MODULE_STRING(DEFAULT_RDTR),
412                         .def  = DEFAULT_RDTR,
413                         .arg  = { .r = { .min = MIN_RXDELAY,
414                                          .max = MAX_RXDELAY }}
415                 };
416
417                 adapter->rx_int_delay = RxIntDelay[bd];
418                 e1000_validate_option(&adapter->rx_int_delay, &opt, adapter);
419         }
420         { /* Receive Absolute Interrupt Delay */
421                 struct e1000_option opt = {
422                         .type = range_option,
423                         .name = "Receive Absolute Interrupt Delay",
424                         .err  = "using default of " __MODULE_STRING(DEFAULT_RADV),
425                         .def  = DEFAULT_RADV,
426                         .arg  = { .r = { .min = MIN_RXABSDELAY,
427                                          .max = MAX_RXABSDELAY }}
428                 };
429
430                 adapter->rx_abs_int_delay = RxAbsIntDelay[bd];
431                 e1000_validate_option(&adapter->rx_abs_int_delay, &opt, adapter);
432         }
433         { /* Interrupt Throttling Rate */
434                 struct e1000_option opt = {
435                         .type = range_option,
436                         .name = "Interrupt Throttling Rate (ints/sec)",
437                         .err  = "using default of " __MODULE_STRING(DEFAULT_ITR),
438                         .def  = DEFAULT_ITR,
439                         .arg  = { .r = { .min = MIN_ITR,
440                                          .max = MAX_ITR }}
441                 };
442
443                 adapter->itr = InterruptThrottleRate[bd];
444                 switch(adapter->itr) {
445                 case -1:
446                         adapter->itr = 1;
447                         break;
448                 case 0:
449                         DPRINTK(PROBE, INFO, "%s turned off\n", opt.name);
450                         break;
451                 case 1:
452                         DPRINTK(PROBE, INFO,
453                                 "%s set to dynamic mode\n", opt.name);
454                         break;
455                 default:
456                         e1000_validate_option(&adapter->itr, &opt, adapter);
457                         break;
458                 }
459         }
460
461         switch(adapter->hw.media_type) {
462         case e1000_media_type_fiber:
463         case e1000_media_type_internal_serdes:
464                 e1000_check_fiber_options(adapter);
465                 break;
466         case e1000_media_type_copper:
467                 e1000_check_copper_options(adapter);
468                 break;
469         default:
470                 BUG();
471         }
472 }
473
474 /**
475  * e1000_check_fiber_options - Range Checking for Link Options, Fiber Version
476  * @adapter: board private structure
477  *
478  * Handles speed and duplex options on fiber adapters
479  **/
480
481 static void __devinit
482 e1000_check_fiber_options(struct e1000_adapter *adapter)
483 {
484         int bd = adapter->bd_number;
485         bd = bd > E1000_MAX_NIC ? E1000_MAX_NIC : bd;
486
487         if((Speed[bd] != OPTION_UNSET)) {
488                 DPRINTK(PROBE, INFO, "Speed not valid for fiber adapters, "
489                        "parameter ignored\n");
490         }
491         if((Duplex[bd] != OPTION_UNSET)) {
492                 DPRINTK(PROBE, INFO, "Duplex not valid for fiber adapters, "
493                        "parameter ignored\n");
494         }
495         if((AutoNeg[bd] != OPTION_UNSET) && (AutoNeg[bd] != 0x20)) {
496                 DPRINTK(PROBE, INFO, "AutoNeg other than Full/1000 is "
497                        "not valid for fiber adapters, parameter ignored\n");
498         }
499 }
500
501 /**
502  * e1000_check_copper_options - Range Checking for Link Options, Copper Version
503  * @adapter: board private structure
504  *
505  * Handles speed and duplex options on copper adapters
506  **/
507
508 static void __devinit
509 e1000_check_copper_options(struct e1000_adapter *adapter)
510 {
511         int speed, dplx;
512         int bd = adapter->bd_number;
513         bd = bd > E1000_MAX_NIC ? E1000_MAX_NIC : bd;
514
515         { /* Speed */
516                 struct e1000_opt_list speed_list[] = {{          0, "" },
517                                                       {   SPEED_10, "" },
518                                                       {  SPEED_100, "" },
519                                                       { SPEED_1000, "" }};
520
521                 struct e1000_option opt = {
522                         .type = list_option,
523                         .name = "Speed",
524                         .err  = "parameter ignored",
525                         .def  = 0,
526                         .arg  = { .l = { .nr = ARRAY_SIZE(speed_list),
527                                          .p = speed_list }}
528                 };
529
530                 speed = Speed[bd];
531                 e1000_validate_option(&speed, &opt, adapter);
532         }
533         { /* Duplex */
534                 struct e1000_opt_list dplx_list[] = {{           0, "" },
535                                                      { HALF_DUPLEX, "" },
536                                                      { FULL_DUPLEX, "" }};
537
538                 struct e1000_option opt = {
539                         .type = list_option,
540                         .name = "Duplex",
541                         .err  = "parameter ignored",
542                         .def  = 0,
543                         .arg  = { .l = { .nr = ARRAY_SIZE(dplx_list),
544                                          .p = dplx_list }}
545                 };
546
547                 dplx = Duplex[bd];
548                 e1000_validate_option(&dplx, &opt, adapter);
549         }
550
551         if(AutoNeg[bd] != OPTION_UNSET && (speed != 0 || dplx != 0)) {
552                 DPRINTK(PROBE, INFO,
553                        "AutoNeg specified along with Speed or Duplex, "
554                        "parameter ignored\n");
555                 adapter->hw.autoneg_advertised = AUTONEG_ADV_DEFAULT;
556         } else { /* Autoneg */
557                 struct e1000_opt_list an_list[] =
558                         #define AA "AutoNeg advertising "
559                         {{ 0x01, AA "10/HD" },
560                          { 0x02, AA "10/FD" },
561                          { 0x03, AA "10/FD, 10/HD" },
562                          { 0x04, AA "100/HD" },
563                          { 0x05, AA "100/HD, 10/HD" },
564                          { 0x06, AA "100/HD, 10/FD" },
565                          { 0x07, AA "100/HD, 10/FD, 10/HD" },
566                          { 0x08, AA "100/FD" },
567                          { 0x09, AA "100/FD, 10/HD" },
568                          { 0x0a, AA "100/FD, 10/FD" },
569                          { 0x0b, AA "100/FD, 10/FD, 10/HD" },
570                          { 0x0c, AA "100/FD, 100/HD" },
571                          { 0x0d, AA "100/FD, 100/HD, 10/HD" },
572                          { 0x0e, AA "100/FD, 100/HD, 10/FD" },
573                          { 0x0f, AA "100/FD, 100/HD, 10/FD, 10/HD" },
574                          { 0x20, AA "1000/FD" },
575                          { 0x21, AA "1000/FD, 10/HD" },
576                          { 0x22, AA "1000/FD, 10/FD" },
577                          { 0x23, AA "1000/FD, 10/FD, 10/HD" },
578                          { 0x24, AA "1000/FD, 100/HD" },
579                          { 0x25, AA "1000/FD, 100/HD, 10/HD" },
580                          { 0x26, AA "1000/FD, 100/HD, 10/FD" },
581                          { 0x27, AA "1000/FD, 100/HD, 10/FD, 10/HD" },
582                          { 0x28, AA "1000/FD, 100/FD" },
583                          { 0x29, AA "1000/FD, 100/FD, 10/HD" },
584                          { 0x2a, AA "1000/FD, 100/FD, 10/FD" },
585                          { 0x2b, AA "1000/FD, 100/FD, 10/FD, 10/HD" },
586                          { 0x2c, AA "1000/FD, 100/FD, 100/HD" },
587                          { 0x2d, AA "1000/FD, 100/FD, 100/HD, 10/HD" },
588                          { 0x2e, AA "1000/FD, 100/FD, 100/HD, 10/FD" },
589                          { 0x2f, AA "1000/FD, 100/FD, 100/HD, 10/FD, 10/HD" }};
590
591                 struct e1000_option opt = {
592                         .type = list_option,
593                         .name = "AutoNeg",
594                         .err  = "parameter ignored",
595                         .def  = AUTONEG_ADV_DEFAULT,
596                         .arg  = { .l = { .nr = ARRAY_SIZE(an_list),
597                                          .p = an_list }}
598                 };
599
600                 int an = AutoNeg[bd];
601                 e1000_validate_option(&an, &opt, adapter);
602                 adapter->hw.autoneg_advertised = an;
603         }
604
605         switch (speed + dplx) {
606         case 0:
607                 adapter->hw.autoneg = adapter->fc_autoneg = 1;
608                 if(Speed[bd] != OPTION_UNSET || Duplex[bd] != OPTION_UNSET)
609                         DPRINTK(PROBE, INFO,
610                                "Speed and duplex autonegotiation enabled\n");
611                 break;
612         case HALF_DUPLEX:
613                 DPRINTK(PROBE, INFO, "Half Duplex specified without Speed\n");
614                 DPRINTK(PROBE, INFO,
615                         "Using Autonegotiation at Half Duplex only\n");
616                 adapter->hw.autoneg = adapter->fc_autoneg = 1;
617                 adapter->hw.autoneg_advertised = ADVERTISE_10_HALF |
618                                                  ADVERTISE_100_HALF;
619                 break;
620         case FULL_DUPLEX:
621                 DPRINTK(PROBE, INFO, "Full Duplex specified without Speed\n");
622                 DPRINTK(PROBE, INFO,
623                         "Using Autonegotiation at Full Duplex only\n");
624                 adapter->hw.autoneg = adapter->fc_autoneg = 1;
625                 adapter->hw.autoneg_advertised = ADVERTISE_10_FULL |
626                                                  ADVERTISE_100_FULL |
627                                                  ADVERTISE_1000_FULL;
628                 break;
629         case SPEED_10:
630                 DPRINTK(PROBE, INFO,
631                         "10 Mbps Speed specified without Duplex\n");
632                 DPRINTK(PROBE, INFO, "Using Autonegotiation at 10 Mbps only\n");
633                 adapter->hw.autoneg = adapter->fc_autoneg = 1;
634                 adapter->hw.autoneg_advertised = ADVERTISE_10_HALF |
635                                                  ADVERTISE_10_FULL;
636                 break;
637         case SPEED_10 + HALF_DUPLEX:
638                 DPRINTK(PROBE, INFO, "Forcing to 10 Mbps Half Duplex\n");
639                 adapter->hw.autoneg = adapter->fc_autoneg = 0;
640                 adapter->hw.forced_speed_duplex = e1000_10_half;
641                 adapter->hw.autoneg_advertised = 0;
642                 break;
643         case SPEED_10 + FULL_DUPLEX:
644                 DPRINTK(PROBE, INFO, "Forcing to 10 Mbps Full Duplex\n");
645                 adapter->hw.autoneg = adapter->fc_autoneg = 0;
646                 adapter->hw.forced_speed_duplex = e1000_10_full;
647                 adapter->hw.autoneg_advertised = 0;
648                 break;
649         case SPEED_100:
650                 DPRINTK(PROBE, INFO,
651                         "100 Mbps Speed specified without Duplex\n");
652                 DPRINTK(PROBE, INFO,
653                         "Using Autonegotiation at 100 Mbps only\n");
654                 adapter->hw.autoneg = adapter->fc_autoneg = 1;
655                 adapter->hw.autoneg_advertised = ADVERTISE_100_HALF |
656                                                  ADVERTISE_100_FULL;
657                 break;
658         case SPEED_100 + HALF_DUPLEX:
659                 DPRINTK(PROBE, INFO, "Forcing to 100 Mbps Half Duplex\n");
660                 adapter->hw.autoneg = adapter->fc_autoneg = 0;
661                 adapter->hw.forced_speed_duplex = e1000_100_half;
662                 adapter->hw.autoneg_advertised = 0;
663                 break;
664         case SPEED_100 + FULL_DUPLEX:
665                 DPRINTK(PROBE, INFO, "Forcing to 100 Mbps Full Duplex\n");
666                 adapter->hw.autoneg = adapter->fc_autoneg = 0;
667                 adapter->hw.forced_speed_duplex = e1000_100_full;
668                 adapter->hw.autoneg_advertised = 0;
669                 break;
670         case SPEED_1000:
671                 DPRINTK(PROBE, INFO,
672                         "1000 Mbps Speed specified without Duplex\n");
673                 DPRINTK(PROBE, INFO,
674                        "Using Autonegotiation at 1000 Mbps Full Duplex only\n");
675                 adapter->hw.autoneg = adapter->fc_autoneg = 1;
676                 adapter->hw.autoneg_advertised = ADVERTISE_1000_FULL;
677                 break;
678         case SPEED_1000 + HALF_DUPLEX:
679                 DPRINTK(PROBE, INFO,
680                         "Half Duplex is not supported at 1000 Mbps\n");
681                 DPRINTK(PROBE, INFO,
682                        "Using Autonegotiation at 1000 Mbps Full Duplex only\n");
683                 adapter->hw.autoneg = adapter->fc_autoneg = 1;
684                 adapter->hw.autoneg_advertised = ADVERTISE_1000_FULL;
685                 break;
686         case SPEED_1000 + FULL_DUPLEX:
687                 DPRINTK(PROBE, INFO,
688                        "Using Autonegotiation at 1000 Mbps Full Duplex only\n");
689                 adapter->hw.autoneg = adapter->fc_autoneg = 1;
690                 adapter->hw.autoneg_advertised = ADVERTISE_1000_FULL;
691                 break;
692         default:
693                 BUG();
694         }
695
696         /* Speed, AutoNeg and MDI/MDI-X must all play nice */
697         if (e1000_validate_mdi_setting(&(adapter->hw)) < 0) {
698                 DPRINTK(PROBE, INFO,
699                        "Speed, AutoNeg and MDI-X specifications are "
700                        "incompatible. Setting MDI-X to a compatible value.\n");
701         }
702 }
703