e1000_param.c 23 KB

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