ixgb_param.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472
  1. /*******************************************************************************
  2. Intel PRO/10GbE Linux driver
  3. Copyright(c) 1999 - 2006 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] = IXGB_PARAM_INIT; \
  36. static int num_##X = 0; \
  37. module_param_array_named(X, X, int, &num_##X, 0); \
  38. MODULE_PARM_DESC(X, desc);
  39. /* Transmit Descriptor Count
  40. *
  41. * Valid Range: 64-4096
  42. *
  43. * Default Value: 256
  44. */
  45. IXGB_PARAM(TxDescriptors, "Number of transmit descriptors");
  46. /* Receive Descriptor Count
  47. *
  48. * Valid Range: 64-4096
  49. *
  50. * Default Value: 1024
  51. */
  52. IXGB_PARAM(RxDescriptors, "Number of receive descriptors");
  53. /* User Specified Flow Control Override
  54. *
  55. * Valid Range: 0-3
  56. * - 0 - No Flow Control
  57. * - 1 - Rx only, respond to PAUSE frames but do not generate them
  58. * - 2 - Tx only, generate PAUSE frames but ignore them on receive
  59. * - 3 - Full Flow Control Support
  60. *
  61. * Default Value: 2 - Tx only (silicon bug avoidance)
  62. */
  63. IXGB_PARAM(FlowControl, "Flow Control setting");
  64. /* XsumRX - Receive Checksum Offload Enable/Disable
  65. *
  66. * Valid Range: 0, 1
  67. * - 0 - disables all checksum offload
  68. * - 1 - enables receive IP/TCP/UDP checksum offload
  69. * on 82597 based NICs
  70. *
  71. * Default Value: 1
  72. */
  73. IXGB_PARAM(XsumRX, "Disable or enable Receive Checksum offload");
  74. /* Transmit Interrupt Delay in units of 0.8192 microseconds
  75. *
  76. * Valid Range: 0-65535
  77. *
  78. * Default Value: 32
  79. */
  80. IXGB_PARAM(TxIntDelay, "Transmit Interrupt Delay");
  81. /* Receive Interrupt Delay in units of 0.8192 microseconds
  82. *
  83. * Valid Range: 0-65535
  84. *
  85. * Default Value: 72
  86. */
  87. IXGB_PARAM(RxIntDelay, "Receive Interrupt Delay");
  88. /* Receive Flow control high threshold (when we send a pause frame)
  89. * (FCRTH)
  90. *
  91. * Valid Range: 1,536 - 262,136 (0x600 - 0x3FFF8, 8 byte granularity)
  92. *
  93. * Default Value: 196,608 (0x30000)
  94. */
  95. IXGB_PARAM(RxFCHighThresh, "Receive Flow Control High Threshold");
  96. /* Receive Flow control low threshold (when we send a resume frame)
  97. * (FCRTL)
  98. *
  99. * Valid Range: 64 - 262,136 (0x40 - 0x3FFF8, 8 byte granularity)
  100. * must be less than high threshold by at least 8 bytes
  101. *
  102. * Default Value: 163,840 (0x28000)
  103. */
  104. IXGB_PARAM(RxFCLowThresh, "Receive Flow Control Low Threshold");
  105. /* Flow control request timeout (how long to pause the link partner's tx)
  106. * (PAP 15:0)
  107. *
  108. * Valid Range: 1 - 65535
  109. *
  110. * Default Value: 65535 (0xffff) (we'll send an xon if we recover)
  111. */
  112. IXGB_PARAM(FCReqTimeout, "Flow Control Request Timeout");
  113. /* Interrupt Delay Enable
  114. *
  115. * Valid Range: 0, 1
  116. *
  117. * - 0 - disables transmit interrupt delay
  118. * - 1 - enables transmmit interrupt delay
  119. *
  120. * Default Value: 1
  121. */
  122. IXGB_PARAM(IntDelayEnable, "Transmit Interrupt Delay Enable");
  123. #define DEFAULT_TIDV 32
  124. #define MAX_TIDV 0xFFFF
  125. #define MIN_TIDV 0
  126. #define DEFAULT_RDTR 72
  127. #define MAX_RDTR 0xFFFF
  128. #define MIN_RDTR 0
  129. #define XSUMRX_DEFAULT OPTION_ENABLED
  130. #define DEFAULT_FCRTL 0x28000
  131. #define DEFAULT_FCRTH 0x30000
  132. #define MIN_FCRTL 0
  133. #define MAX_FCRTL 0x3FFE8
  134. #define MIN_FCRTH 8
  135. #define MAX_FCRTH 0x3FFF0
  136. #define MIN_FCPAUSE 1
  137. #define MAX_FCPAUSE 0xffff
  138. #define DEFAULT_FCPAUSE 0xFFFF /* this may be too long */
  139. struct ixgb_option {
  140. enum { enable_option, range_option, list_option } type;
  141. char *name;
  142. char *err;
  143. int def;
  144. union {
  145. struct { /* range_option info */
  146. int min;
  147. int max;
  148. } r;
  149. struct { /* list_option info */
  150. int nr;
  151. struct ixgb_opt_list {
  152. int i;
  153. char *str;
  154. } *p;
  155. } l;
  156. } arg;
  157. };
  158. static int __devinit
  159. ixgb_validate_option(int *value, struct ixgb_option *opt)
  160. {
  161. if(*value == OPTION_UNSET) {
  162. *value = opt->def;
  163. return 0;
  164. }
  165. switch (opt->type) {
  166. case enable_option:
  167. switch (*value) {
  168. case OPTION_ENABLED:
  169. printk(KERN_INFO "%s Enabled\n", opt->name);
  170. return 0;
  171. case OPTION_DISABLED:
  172. printk(KERN_INFO "%s Disabled\n", opt->name);
  173. return 0;
  174. }
  175. break;
  176. case range_option:
  177. if(*value >= opt->arg.r.min && *value <= opt->arg.r.max) {
  178. printk(KERN_INFO "%s set to %i\n", opt->name, *value);
  179. return 0;
  180. }
  181. break;
  182. case list_option: {
  183. int i;
  184. struct ixgb_opt_list *ent;
  185. for(i = 0; i < opt->arg.l.nr; i++) {
  186. ent = &opt->arg.l.p[i];
  187. if(*value == ent->i) {
  188. if(ent->str[0] != '\0')
  189. printk(KERN_INFO "%s\n", ent->str);
  190. return 0;
  191. }
  192. }
  193. }
  194. break;
  195. default:
  196. BUG();
  197. }
  198. printk(KERN_INFO "Invalid %s specified (%i) %s\n",
  199. opt->name, *value, opt->err);
  200. *value = opt->def;
  201. return -1;
  202. }
  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. tx_ring->count = ALIGN(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. rx_ring->count = ALIGN(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 = ARRAY_SIZE(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. }