ixgb_param.c 12 KB

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