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