e1000_param.c 20 KB

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