e1000_param.c 21 KB

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