ixgb_param.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476
  1. /*******************************************************************************
  2. Copyright(c) 1999 - 2005 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: Read flow control settings from the EEPROM
  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: 256 (0x100)
  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 FLOW_CONTROL_FULL ixgb_fc_full
  130. #define FLOW_CONTROL_DEFAULT FLOW_CONTROL_FULL
  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 DEFAULT_FCPAUSE 0x100 /* this may be too long */
  138. #define MIN_FCPAUSE 1
  139. #define MAX_FCPAUSE 0xffff
  140. struct ixgb_option {
  141. enum { enable_option, range_option, list_option } type;
  142. char *name;
  143. 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(int *value, 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. #define LIST_LEN(l) (sizeof(l) / sizeof(l[0]))
  205. /**
  206. * ixgb_check_options - Range Checking for Command Line Parameters
  207. * @adapter: board private structure
  208. *
  209. * This routine checks all command line parameters for valid user
  210. * input. If an invalid value is given, or if no user specified
  211. * value exists, a default value is used. The final value is stored
  212. * in a variable in the adapter structure.
  213. **/
  214. void __devinit
  215. ixgb_check_options(struct ixgb_adapter *adapter)
  216. {
  217. int bd = adapter->bd_number;
  218. if(bd >= IXGB_MAX_NIC) {
  219. printk(KERN_NOTICE
  220. "Warning: no configuration for board #%i\n", bd);
  221. printk(KERN_NOTICE "Using defaults for all values\n");
  222. }
  223. { /* Transmit Descriptor Count */
  224. struct ixgb_option opt = {
  225. .type = range_option,
  226. .name = "Transmit Descriptors",
  227. .err = "using default of " __MODULE_STRING(DEFAULT_TXD),
  228. .def = DEFAULT_TXD,
  229. .arg = { .r = { .min = MIN_TXD,
  230. .max = MAX_TXD}}
  231. };
  232. struct ixgb_desc_ring *tx_ring = &adapter->tx_ring;
  233. if(num_TxDescriptors > bd) {
  234. tx_ring->count = TxDescriptors[bd];
  235. ixgb_validate_option(&tx_ring->count, &opt);
  236. } else {
  237. tx_ring->count = opt.def;
  238. }
  239. IXGB_ROUNDUP(tx_ring->count, IXGB_REQ_TX_DESCRIPTOR_MULTIPLE);
  240. }
  241. { /* Receive Descriptor Count */
  242. struct ixgb_option opt = {
  243. .type = range_option,
  244. .name = "Receive Descriptors",
  245. .err = "using default of " __MODULE_STRING(DEFAULT_RXD),
  246. .def = DEFAULT_RXD,
  247. .arg = { .r = { .min = MIN_RXD,
  248. .max = MAX_RXD}}
  249. };
  250. struct ixgb_desc_ring *rx_ring = &adapter->rx_ring;
  251. if(num_RxDescriptors > bd) {
  252. rx_ring->count = RxDescriptors[bd];
  253. ixgb_validate_option(&rx_ring->count, &opt);
  254. } else {
  255. rx_ring->count = opt.def;
  256. }
  257. IXGB_ROUNDUP(rx_ring->count, IXGB_REQ_RX_DESCRIPTOR_MULTIPLE);
  258. }
  259. { /* Receive Checksum Offload Enable */
  260. struct ixgb_option opt = {
  261. .type = enable_option,
  262. .name = "Receive Checksum Offload",
  263. .err = "defaulting to Enabled",
  264. .def = OPTION_ENABLED
  265. };
  266. if(num_XsumRX > bd) {
  267. int rx_csum = XsumRX[bd];
  268. ixgb_validate_option(&rx_csum, &opt);
  269. adapter->rx_csum = rx_csum;
  270. } else {
  271. adapter->rx_csum = opt.def;
  272. }
  273. }
  274. { /* Flow Control */
  275. struct ixgb_opt_list fc_list[] =
  276. {{ ixgb_fc_none, "Flow Control Disabled" },
  277. { ixgb_fc_rx_pause,"Flow Control Receive Only" },
  278. { ixgb_fc_tx_pause,"Flow Control Transmit Only" },
  279. { ixgb_fc_full, "Flow Control Enabled" },
  280. { ixgb_fc_default, "Flow Control Hardware Default" }};
  281. struct ixgb_option opt = {
  282. .type = list_option,
  283. .name = "Flow Control",
  284. .err = "reading default settings from EEPROM",
  285. .def = ixgb_fc_full,
  286. .arg = { .l = { .nr = LIST_LEN(fc_list),
  287. .p = fc_list }}
  288. };
  289. if(num_FlowControl > bd) {
  290. int fc = FlowControl[bd];
  291. ixgb_validate_option(&fc, &opt);
  292. adapter->hw.fc.type = fc;
  293. } else {
  294. adapter->hw.fc.type = opt.def;
  295. }
  296. }
  297. { /* Receive Flow Control High Threshold */
  298. struct ixgb_option opt = {
  299. .type = range_option,
  300. .name = "Rx Flow Control High Threshold",
  301. .err = "using default of " __MODULE_STRING(DEFAULT_FCRTH),
  302. .def = DEFAULT_FCRTH,
  303. .arg = { .r = { .min = MIN_FCRTH,
  304. .max = MAX_FCRTH}}
  305. };
  306. if(num_RxFCHighThresh > bd) {
  307. adapter->hw.fc.high_water = RxFCHighThresh[bd];
  308. ixgb_validate_option(&adapter->hw.fc.high_water, &opt);
  309. } else {
  310. adapter->hw.fc.high_water = opt.def;
  311. }
  312. if(!(adapter->hw.fc.type & ixgb_fc_rx_pause) )
  313. printk (KERN_INFO
  314. "Ignoring RxFCHighThresh when no RxFC\n");
  315. }
  316. { /* Receive Flow Control Low Threshold */
  317. struct ixgb_option opt = {
  318. .type = range_option,
  319. .name = "Rx Flow Control Low Threshold",
  320. .err = "using default of " __MODULE_STRING(DEFAULT_FCRTL),
  321. .def = DEFAULT_FCRTL,
  322. .arg = { .r = { .min = MIN_FCRTL,
  323. .max = MAX_FCRTL}}
  324. };
  325. if(num_RxFCLowThresh > bd) {
  326. adapter->hw.fc.low_water = RxFCLowThresh[bd];
  327. ixgb_validate_option(&adapter->hw.fc.low_water, &opt);
  328. } else {
  329. adapter->hw.fc.low_water = opt.def;
  330. }
  331. if(!(adapter->hw.fc.type & ixgb_fc_rx_pause) )
  332. printk (KERN_INFO
  333. "Ignoring RxFCLowThresh when no RxFC\n");
  334. }
  335. { /* Flow Control Pause Time Request*/
  336. struct ixgb_option opt = {
  337. .type = range_option,
  338. .name = "Flow Control Pause Time Request",
  339. .err = "using default of "__MODULE_STRING(DEFAULT_FCPAUSE),
  340. .def = DEFAULT_FCPAUSE,
  341. .arg = { .r = { .min = MIN_FCPAUSE,
  342. .max = MAX_FCPAUSE}}
  343. };
  344. if(num_FCReqTimeout > bd) {
  345. int pause_time = FCReqTimeout[bd];
  346. ixgb_validate_option(&pause_time, &opt);
  347. adapter->hw.fc.pause_time = pause_time;
  348. } else {
  349. adapter->hw.fc.pause_time = opt.def;
  350. }
  351. if(!(adapter->hw.fc.type & ixgb_fc_rx_pause) )
  352. printk (KERN_INFO
  353. "Ignoring FCReqTimeout when no RxFC\n");
  354. }
  355. /* high low and spacing check for rx flow control thresholds */
  356. if (adapter->hw.fc.type & ixgb_fc_rx_pause) {
  357. /* high must be greater than low */
  358. if (adapter->hw.fc.high_water < (adapter->hw.fc.low_water + 8)) {
  359. /* set defaults */
  360. printk (KERN_INFO
  361. "RxFCHighThresh must be >= (RxFCLowThresh + 8), "
  362. "Using Defaults\n");
  363. adapter->hw.fc.high_water = DEFAULT_FCRTH;
  364. adapter->hw.fc.low_water = DEFAULT_FCRTL;
  365. }
  366. }
  367. { /* Receive Interrupt Delay */
  368. struct ixgb_option opt = {
  369. .type = range_option,
  370. .name = "Receive Interrupt Delay",
  371. .err = "using default of " __MODULE_STRING(DEFAULT_RDTR),
  372. .def = DEFAULT_RDTR,
  373. .arg = { .r = { .min = MIN_RDTR,
  374. .max = MAX_RDTR}}
  375. };
  376. if(num_RxIntDelay > bd) {
  377. adapter->rx_int_delay = RxIntDelay[bd];
  378. ixgb_validate_option(&adapter->rx_int_delay, &opt);
  379. } else {
  380. adapter->rx_int_delay = opt.def;
  381. }
  382. }
  383. { /* Transmit Interrupt Delay */
  384. struct ixgb_option opt = {
  385. .type = range_option,
  386. .name = "Transmit Interrupt Delay",
  387. .err = "using default of " __MODULE_STRING(DEFAULT_TIDV),
  388. .def = DEFAULT_TIDV,
  389. .arg = { .r = { .min = MIN_TIDV,
  390. .max = MAX_TIDV}}
  391. };
  392. if(num_TxIntDelay > bd) {
  393. adapter->tx_int_delay = TxIntDelay[bd];
  394. ixgb_validate_option(&adapter->tx_int_delay, &opt);
  395. } else {
  396. adapter->tx_int_delay = opt.def;
  397. }
  398. }
  399. { /* Transmit Interrupt Delay Enable */
  400. struct ixgb_option opt = {
  401. .type = enable_option,
  402. .name = "Tx Interrupt Delay Enable",
  403. .err = "defaulting to Enabled",
  404. .def = OPTION_ENABLED
  405. };
  406. if(num_IntDelayEnable > bd) {
  407. int ide = IntDelayEnable[bd];
  408. ixgb_validate_option(&ide, &opt);
  409. adapter->tx_int_delay_enable = ide;
  410. } else {
  411. adapter->tx_int_delay_enable = opt.def;
  412. }
  413. }
  414. }