ixgb_param.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473
  1. /*******************************************************************************
  2. Intel PRO/10GbE Linux driver
  3. Copyright(c) 1999 - 2008 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 "ixgb.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 IXGB_MAX_NIC 8
  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 IXGB_PARAM_INIT { [0 ... IXGB_MAX_NIC] = OPTION_UNSET }
  34. #define IXGB_PARAM(X, desc) \
  35. static int __devinitdata X[IXGB_MAX_NIC+1] \
  36. = IXGB_PARAM_INIT; \
  37. static unsigned int num_##X = 0; \
  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: 64-4096
  43. *
  44. * Default Value: 256
  45. */
  46. IXGB_PARAM(TxDescriptors, "Number of transmit descriptors");
  47. /* Receive Descriptor Count
  48. *
  49. * Valid Range: 64-4096
  50. *
  51. * Default Value: 1024
  52. */
  53. IXGB_PARAM(RxDescriptors, "Number of receive descriptors");
  54. /* User Specified Flow Control Override
  55. *
  56. * Valid Range: 0-3
  57. * - 0 - No Flow Control
  58. * - 1 - Rx only, respond to PAUSE frames but do not generate them
  59. * - 2 - Tx only, generate PAUSE frames but ignore them on receive
  60. * - 3 - Full Flow Control Support
  61. *
  62. * Default Value: 2 - Tx only (silicon bug avoidance)
  63. */
  64. IXGB_PARAM(FlowControl, "Flow Control setting");
  65. /* XsumRX - Receive Checksum Offload Enable/Disable
  66. *
  67. * Valid Range: 0, 1
  68. * - 0 - disables all checksum offload
  69. * - 1 - enables receive IP/TCP/UDP checksum offload
  70. * on 82597 based NICs
  71. *
  72. * Default Value: 1
  73. */
  74. IXGB_PARAM(XsumRX, "Disable or enable Receive Checksum offload");
  75. /* Transmit Interrupt Delay in units of 0.8192 microseconds
  76. *
  77. * Valid Range: 0-65535
  78. *
  79. * Default Value: 32
  80. */
  81. IXGB_PARAM(TxIntDelay, "Transmit Interrupt Delay");
  82. /* Receive Interrupt Delay in units of 0.8192 microseconds
  83. *
  84. * Valid Range: 0-65535
  85. *
  86. * Default Value: 72
  87. */
  88. IXGB_PARAM(RxIntDelay, "Receive Interrupt Delay");
  89. /* Receive Flow control high threshold (when we send a pause frame)
  90. * (FCRTH)
  91. *
  92. * Valid Range: 1,536 - 262,136 (0x600 - 0x3FFF8, 8 byte granularity)
  93. *
  94. * Default Value: 196,608 (0x30000)
  95. */
  96. IXGB_PARAM(RxFCHighThresh, "Receive Flow Control High Threshold");
  97. /* Receive Flow control low threshold (when we send a resume frame)
  98. * (FCRTL)
  99. *
  100. * Valid Range: 64 - 262,136 (0x40 - 0x3FFF8, 8 byte granularity)
  101. * must be less than high threshold by at least 8 bytes
  102. *
  103. * Default Value: 163,840 (0x28000)
  104. */
  105. IXGB_PARAM(RxFCLowThresh, "Receive Flow Control Low Threshold");
  106. /* Flow control request timeout (how long to pause the link partner's tx)
  107. * (PAP 15:0)
  108. *
  109. * Valid Range: 1 - 65535
  110. *
  111. * Default Value: 65535 (0xffff) (we'll send an xon if we recover)
  112. */
  113. IXGB_PARAM(FCReqTimeout, "Flow Control Request Timeout");
  114. /* Interrupt Delay Enable
  115. *
  116. * Valid Range: 0, 1
  117. *
  118. * - 0 - disables transmit interrupt delay
  119. * - 1 - enables transmmit interrupt delay
  120. *
  121. * Default Value: 1
  122. */
  123. IXGB_PARAM(IntDelayEnable, "Transmit Interrupt Delay Enable");
  124. #define DEFAULT_TIDV 32
  125. #define MAX_TIDV 0xFFFF
  126. #define MIN_TIDV 0
  127. #define DEFAULT_RDTR 72
  128. #define MAX_RDTR 0xFFFF
  129. #define MIN_RDTR 0
  130. #define XSUMRX_DEFAULT OPTION_ENABLED
  131. #define DEFAULT_FCRTL 0x28000
  132. #define DEFAULT_FCRTH 0x30000
  133. #define MIN_FCRTL 0
  134. #define MAX_FCRTL 0x3FFE8
  135. #define MIN_FCRTH 8
  136. #define MAX_FCRTH 0x3FFF0
  137. #define MIN_FCPAUSE 1
  138. #define MAX_FCPAUSE 0xffff
  139. #define DEFAULT_FCPAUSE 0xFFFF /* this may be too long */
  140. struct ixgb_option {
  141. enum { enable_option, range_option, list_option } type;
  142. const char *name;
  143. const char *err;
  144. int def;
  145. union {
  146. struct { /* range_option info */
  147. int min;
  148. int max;
  149. } r;
  150. struct { /* list_option info */
  151. int nr;
  152. struct ixgb_opt_list {
  153. int i;
  154. char *str;
  155. } *p;
  156. } l;
  157. } arg;
  158. };
  159. static int __devinit
  160. ixgb_validate_option(unsigned int *value, const struct ixgb_option *opt)
  161. {
  162. if (*value == OPTION_UNSET) {
  163. *value = opt->def;
  164. return 0;
  165. }
  166. switch (opt->type) {
  167. case enable_option:
  168. switch (*value) {
  169. case OPTION_ENABLED:
  170. printk(KERN_INFO "%s Enabled\n", opt->name);
  171. return 0;
  172. case OPTION_DISABLED:
  173. printk(KERN_INFO "%s Disabled\n", opt->name);
  174. return 0;
  175. }
  176. break;
  177. case range_option:
  178. if (*value >= opt->arg.r.min && *value <= opt->arg.r.max) {
  179. printk(KERN_INFO "%s set to %i\n", opt->name, *value);
  180. return 0;
  181. }
  182. break;
  183. case list_option: {
  184. int i;
  185. struct ixgb_opt_list *ent;
  186. for (i = 0; i < opt->arg.l.nr; i++) {
  187. ent = &opt->arg.l.p[i];
  188. if (*value == ent->i) {
  189. if (ent->str[0] != '\0')
  190. printk(KERN_INFO "%s\n", ent->str);
  191. return 0;
  192. }
  193. }
  194. }
  195. break;
  196. default:
  197. BUG();
  198. }
  199. printk(KERN_INFO "Invalid %s specified (%i) %s\n",
  200. opt->name, *value, opt->err);
  201. *value = opt->def;
  202. return -1;
  203. }
  204. /**
  205. * ixgb_check_options - Range Checking for Command Line Parameters
  206. * @adapter: board private structure
  207. *
  208. * This routine checks all command line parameters for valid user
  209. * input. If an invalid value is given, or if no user specified
  210. * value exists, a default value is used. The final value is stored
  211. * in a variable in the adapter structure.
  212. **/
  213. void __devinit
  214. ixgb_check_options(struct ixgb_adapter *adapter)
  215. {
  216. int bd = adapter->bd_number;
  217. if (bd >= IXGB_MAX_NIC) {
  218. printk(KERN_NOTICE
  219. "Warning: no configuration for board #%i\n", bd);
  220. printk(KERN_NOTICE "Using defaults for all values\n");
  221. }
  222. { /* Transmit Descriptor Count */
  223. const struct ixgb_option opt = {
  224. .type = range_option,
  225. .name = "Transmit Descriptors",
  226. .err = "using default of " __MODULE_STRING(DEFAULT_TXD),
  227. .def = DEFAULT_TXD,
  228. .arg = { .r = { .min = MIN_TXD,
  229. .max = MAX_TXD}}
  230. };
  231. struct ixgb_desc_ring *tx_ring = &adapter->tx_ring;
  232. if (num_TxDescriptors > bd) {
  233. tx_ring->count = TxDescriptors[bd];
  234. ixgb_validate_option(&tx_ring->count, &opt);
  235. } else {
  236. tx_ring->count = opt.def;
  237. }
  238. tx_ring->count = ALIGN(tx_ring->count, IXGB_REQ_TX_DESCRIPTOR_MULTIPLE);
  239. }
  240. { /* Receive Descriptor Count */
  241. const struct ixgb_option opt = {
  242. .type = range_option,
  243. .name = "Receive Descriptors",
  244. .err = "using default of " __MODULE_STRING(DEFAULT_RXD),
  245. .def = DEFAULT_RXD,
  246. .arg = { .r = { .min = MIN_RXD,
  247. .max = MAX_RXD}}
  248. };
  249. struct ixgb_desc_ring *rx_ring = &adapter->rx_ring;
  250. if (num_RxDescriptors > bd) {
  251. rx_ring->count = RxDescriptors[bd];
  252. ixgb_validate_option(&rx_ring->count, &opt);
  253. } else {
  254. rx_ring->count = opt.def;
  255. }
  256. rx_ring->count = ALIGN(rx_ring->count, IXGB_REQ_RX_DESCRIPTOR_MULTIPLE);
  257. }
  258. { /* Receive Checksum Offload Enable */
  259. const struct ixgb_option opt = {
  260. .type = enable_option,
  261. .name = "Receive Checksum Offload",
  262. .err = "defaulting to Enabled",
  263. .def = OPTION_ENABLED
  264. };
  265. if (num_XsumRX > bd) {
  266. unsigned int rx_csum = XsumRX[bd];
  267. ixgb_validate_option(&rx_csum, &opt);
  268. adapter->rx_csum = rx_csum;
  269. } else {
  270. adapter->rx_csum = opt.def;
  271. }
  272. }
  273. { /* Flow Control */
  274. struct ixgb_opt_list fc_list[] =
  275. {{ ixgb_fc_none, "Flow Control Disabled" },
  276. { ixgb_fc_rx_pause,"Flow Control Receive Only" },
  277. { ixgb_fc_tx_pause,"Flow Control Transmit Only" },
  278. { ixgb_fc_full, "Flow Control Enabled" },
  279. { ixgb_fc_default, "Flow Control Hardware Default" }};
  280. const struct ixgb_option opt = {
  281. .type = list_option,
  282. .name = "Flow Control",
  283. .err = "reading default settings from EEPROM",
  284. .def = ixgb_fc_tx_pause,
  285. .arg = { .l = { .nr = ARRAY_SIZE(fc_list),
  286. .p = fc_list }}
  287. };
  288. if (num_FlowControl > bd) {
  289. unsigned int fc = FlowControl[bd];
  290. ixgb_validate_option(&fc, &opt);
  291. adapter->hw.fc.type = fc;
  292. } else {
  293. adapter->hw.fc.type = opt.def;
  294. }
  295. }
  296. { /* Receive Flow Control High Threshold */
  297. const struct ixgb_option opt = {
  298. .type = range_option,
  299. .name = "Rx Flow Control High Threshold",
  300. .err = "using default of " __MODULE_STRING(DEFAULT_FCRTH),
  301. .def = DEFAULT_FCRTH,
  302. .arg = { .r = { .min = MIN_FCRTH,
  303. .max = MAX_FCRTH}}
  304. };
  305. if (num_RxFCHighThresh > bd) {
  306. adapter->hw.fc.high_water = RxFCHighThresh[bd];
  307. ixgb_validate_option(&adapter->hw.fc.high_water, &opt);
  308. } else {
  309. adapter->hw.fc.high_water = opt.def;
  310. }
  311. if (!(adapter->hw.fc.type & ixgb_fc_tx_pause) )
  312. printk(KERN_INFO
  313. "Ignoring RxFCHighThresh when no RxFC\n");
  314. }
  315. { /* Receive Flow Control Low Threshold */
  316. const struct ixgb_option opt = {
  317. .type = range_option,
  318. .name = "Rx Flow Control Low Threshold",
  319. .err = "using default of " __MODULE_STRING(DEFAULT_FCRTL),
  320. .def = DEFAULT_FCRTL,
  321. .arg = { .r = { .min = MIN_FCRTL,
  322. .max = MAX_FCRTL}}
  323. };
  324. if (num_RxFCLowThresh > bd) {
  325. adapter->hw.fc.low_water = RxFCLowThresh[bd];
  326. ixgb_validate_option(&adapter->hw.fc.low_water, &opt);
  327. } else {
  328. adapter->hw.fc.low_water = opt.def;
  329. }
  330. if (!(adapter->hw.fc.type & ixgb_fc_tx_pause) )
  331. printk(KERN_INFO
  332. "Ignoring RxFCLowThresh when no RxFC\n");
  333. }
  334. { /* Flow Control Pause Time Request*/
  335. const struct ixgb_option opt = {
  336. .type = range_option,
  337. .name = "Flow Control Pause Time Request",
  338. .err = "using default of "__MODULE_STRING(DEFAULT_FCPAUSE),
  339. .def = DEFAULT_FCPAUSE,
  340. .arg = { .r = { .min = MIN_FCPAUSE,
  341. .max = MAX_FCPAUSE}}
  342. };
  343. if (num_FCReqTimeout > bd) {
  344. unsigned int pause_time = FCReqTimeout[bd];
  345. ixgb_validate_option(&pause_time, &opt);
  346. adapter->hw.fc.pause_time = pause_time;
  347. } else {
  348. adapter->hw.fc.pause_time = opt.def;
  349. }
  350. if (!(adapter->hw.fc.type & ixgb_fc_tx_pause) )
  351. printk(KERN_INFO
  352. "Ignoring FCReqTimeout when no RxFC\n");
  353. }
  354. /* high low and spacing check for rx flow control thresholds */
  355. if (adapter->hw.fc.type & ixgb_fc_tx_pause) {
  356. /* high must be greater than low */
  357. if (adapter->hw.fc.high_water < (adapter->hw.fc.low_water + 8)) {
  358. /* set defaults */
  359. printk(KERN_INFO
  360. "RxFCHighThresh must be >= (RxFCLowThresh + 8), "
  361. "Using Defaults\n");
  362. adapter->hw.fc.high_water = DEFAULT_FCRTH;
  363. adapter->hw.fc.low_water = DEFAULT_FCRTL;
  364. }
  365. }
  366. { /* Receive Interrupt Delay */
  367. const struct ixgb_option opt = {
  368. .type = range_option,
  369. .name = "Receive Interrupt Delay",
  370. .err = "using default of " __MODULE_STRING(DEFAULT_RDTR),
  371. .def = DEFAULT_RDTR,
  372. .arg = { .r = { .min = MIN_RDTR,
  373. .max = MAX_RDTR}}
  374. };
  375. if (num_RxIntDelay > bd) {
  376. adapter->rx_int_delay = RxIntDelay[bd];
  377. ixgb_validate_option(&adapter->rx_int_delay, &opt);
  378. } else {
  379. adapter->rx_int_delay = opt.def;
  380. }
  381. }
  382. { /* Transmit Interrupt Delay */
  383. const struct ixgb_option opt = {
  384. .type = range_option,
  385. .name = "Transmit Interrupt Delay",
  386. .err = "using default of " __MODULE_STRING(DEFAULT_TIDV),
  387. .def = DEFAULT_TIDV,
  388. .arg = { .r = { .min = MIN_TIDV,
  389. .max = MAX_TIDV}}
  390. };
  391. if (num_TxIntDelay > bd) {
  392. adapter->tx_int_delay = TxIntDelay[bd];
  393. ixgb_validate_option(&adapter->tx_int_delay, &opt);
  394. } else {
  395. adapter->tx_int_delay = opt.def;
  396. }
  397. }
  398. { /* Transmit Interrupt Delay Enable */
  399. const struct ixgb_option opt = {
  400. .type = enable_option,
  401. .name = "Tx Interrupt Delay Enable",
  402. .err = "defaulting to Enabled",
  403. .def = OPTION_ENABLED
  404. };
  405. if (num_IntDelayEnable > bd) {
  406. unsigned int ide = IntDelayEnable[bd];
  407. ixgb_validate_option(&ide, &opt);
  408. adapter->tx_int_delay_enable = ide;
  409. } else {
  410. adapter->tx_int_delay_enable = opt.def;
  411. }
  412. }
  413. }