e1000_param.c 21 KB

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