param.c 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  1. /*******************************************************************************
  2. Intel PRO/1000 Linux driver
  3. Copyright(c) 1999 - 2007 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 <linux/netdevice.h>
  22. #include "e1000.h"
  23. /* This is the only thing that needs to be changed to adjust the
  24. * maximum number of ports that the driver can manage.
  25. */
  26. #define E1000_MAX_NIC 32
  27. #define OPTION_UNSET -1
  28. #define OPTION_DISABLED 0
  29. #define OPTION_ENABLED 1
  30. #define COPYBREAK_DEFAULT 256
  31. unsigned int copybreak = COPYBREAK_DEFAULT;
  32. module_param(copybreak, uint, 0644);
  33. MODULE_PARM_DESC(copybreak,
  34. "Maximum size of packet that is copied to a new buffer on receive");
  35. /* All parameters are treated the same, as an integer array of values.
  36. * This macro just reduces the need to repeat the same declaration code
  37. * over and over (plus this helps to avoid typo bugs).
  38. */
  39. #define E1000_PARAM_INIT { [0 ... E1000_MAX_NIC] = OPTION_UNSET }
  40. #define E1000_PARAM(X, desc) \
  41. static int __devinitdata X[E1000_MAX_NIC+1] = E1000_PARAM_INIT; \
  42. static int num_##X; \
  43. module_param_array_named(X, X, int, &num_##X, 0); \
  44. MODULE_PARM_DESC(X, desc);
  45. /* Transmit Interrupt Delay in units of 1.024 microseconds
  46. * Tx interrupt delay needs to typically be set to something non zero
  47. *
  48. * Valid Range: 0-65535
  49. */
  50. E1000_PARAM(TxIntDelay, "Transmit Interrupt Delay");
  51. #define DEFAULT_TIDV 8
  52. #define MAX_TXDELAY 0xFFFF
  53. #define MIN_TXDELAY 0
  54. /* Transmit Absolute Interrupt Delay in units of 1.024 microseconds
  55. *
  56. * Valid Range: 0-65535
  57. */
  58. E1000_PARAM(TxAbsIntDelay, "Transmit Absolute Interrupt Delay");
  59. #define DEFAULT_TADV 32
  60. #define MAX_TXABSDELAY 0xFFFF
  61. #define MIN_TXABSDELAY 0
  62. /* Receive Interrupt Delay in units of 1.024 microseconds
  63. * hardware will likely hang if you set this to anything but zero.
  64. *
  65. * Valid Range: 0-65535
  66. */
  67. E1000_PARAM(RxIntDelay, "Receive Interrupt Delay");
  68. #define DEFAULT_RDTR 0
  69. #define MAX_RXDELAY 0xFFFF
  70. #define MIN_RXDELAY 0
  71. /* Receive Absolute Interrupt Delay in units of 1.024 microseconds
  72. *
  73. * Valid Range: 0-65535
  74. */
  75. E1000_PARAM(RxAbsIntDelay, "Receive Absolute Interrupt Delay");
  76. #define DEFAULT_RADV 8
  77. #define MAX_RXABSDELAY 0xFFFF
  78. #define MIN_RXABSDELAY 0
  79. /* Interrupt Throttle Rate (interrupts/sec)
  80. *
  81. * Valid Range: 100-100000 (0=off, 1=dynamic, 3=dynamic conservative)
  82. */
  83. E1000_PARAM(InterruptThrottleRate, "Interrupt Throttling Rate");
  84. #define DEFAULT_ITR 3
  85. #define MAX_ITR 100000
  86. #define MIN_ITR 100
  87. /* Enable Smart Power Down of the PHY
  88. *
  89. * Valid Range: 0, 1
  90. *
  91. * Default Value: 0 (disabled)
  92. */
  93. E1000_PARAM(SmartPowerDownEnable, "Enable PHY smart power down");
  94. /* Enable Kumeran Lock Loss workaround
  95. *
  96. * Valid Range: 0, 1
  97. *
  98. * Default Value: 1 (enabled)
  99. */
  100. E1000_PARAM(KumeranLockLoss, "Enable Kumeran lock loss workaround");
  101. struct e1000_option {
  102. enum { enable_option, range_option, list_option } type;
  103. char *name;
  104. char *err;
  105. int def;
  106. union {
  107. struct { /* range_option info */
  108. int min;
  109. int max;
  110. } r;
  111. struct { /* list_option info */
  112. int nr;
  113. struct e1000_opt_list { int i; char *str; } *p;
  114. } l;
  115. } arg;
  116. };
  117. static int __devinit e1000_validate_option(int *value,
  118. struct e1000_option *opt,
  119. struct e1000_adapter *adapter)
  120. {
  121. if (*value == OPTION_UNSET) {
  122. *value = opt->def;
  123. return 0;
  124. }
  125. switch (opt->type) {
  126. case enable_option:
  127. switch (*value) {
  128. case OPTION_ENABLED:
  129. ndev_info(adapter->netdev, "%s Enabled\n", opt->name);
  130. return 0;
  131. case OPTION_DISABLED:
  132. ndev_info(adapter->netdev, "%s Disabled\n", opt->name);
  133. return 0;
  134. }
  135. break;
  136. case range_option:
  137. if (*value >= opt->arg.r.min && *value <= opt->arg.r.max) {
  138. ndev_info(adapter->netdev,
  139. "%s set to %i\n", opt->name, *value);
  140. return 0;
  141. }
  142. break;
  143. case list_option: {
  144. int i;
  145. struct e1000_opt_list *ent;
  146. for (i = 0; i < opt->arg.l.nr; i++) {
  147. ent = &opt->arg.l.p[i];
  148. if (*value == ent->i) {
  149. if (ent->str[0] != '\0')
  150. ndev_info(adapter->netdev, "%s\n",
  151. ent->str);
  152. return 0;
  153. }
  154. }
  155. }
  156. break;
  157. default:
  158. BUG();
  159. }
  160. ndev_info(adapter->netdev, "Invalid %s value specified (%i) %s\n",
  161. opt->name, *value, opt->err);
  162. *value = opt->def;
  163. return -1;
  164. }
  165. /**
  166. * e1000e_check_options - Range Checking for Command Line Parameters
  167. * @adapter: board private structure
  168. *
  169. * This routine checks all command line parameters for valid user
  170. * input. If an invalid value is given, or if no user specified
  171. * value exists, a default value is used. The final value is stored
  172. * in a variable in the adapter structure.
  173. **/
  174. void __devinit e1000e_check_options(struct e1000_adapter *adapter)
  175. {
  176. struct e1000_hw *hw = &adapter->hw;
  177. struct net_device *netdev = adapter->netdev;
  178. int bd = adapter->bd_number;
  179. if (bd >= E1000_MAX_NIC) {
  180. ndev_notice(netdev,
  181. "Warning: no configuration for board #%i\n", bd);
  182. ndev_notice(netdev, "Using defaults for all values\n");
  183. }
  184. { /* Transmit Interrupt Delay */
  185. struct e1000_option opt = {
  186. .type = range_option,
  187. .name = "Transmit Interrupt Delay",
  188. .err = "using default of "
  189. __MODULE_STRING(DEFAULT_TIDV),
  190. .def = DEFAULT_TIDV,
  191. .arg = { .r = { .min = MIN_TXDELAY,
  192. .max = MAX_TXDELAY } }
  193. };
  194. if (num_TxIntDelay > bd) {
  195. adapter->tx_int_delay = TxIntDelay[bd];
  196. e1000_validate_option(&adapter->tx_int_delay, &opt,
  197. adapter);
  198. } else {
  199. adapter->tx_int_delay = opt.def;
  200. }
  201. }
  202. { /* Transmit Absolute Interrupt Delay */
  203. struct e1000_option opt = {
  204. .type = range_option,
  205. .name = "Transmit Absolute Interrupt Delay",
  206. .err = "using default of "
  207. __MODULE_STRING(DEFAULT_TADV),
  208. .def = DEFAULT_TADV,
  209. .arg = { .r = { .min = MIN_TXABSDELAY,
  210. .max = MAX_TXABSDELAY } }
  211. };
  212. if (num_TxAbsIntDelay > bd) {
  213. adapter->tx_abs_int_delay = TxAbsIntDelay[bd];
  214. e1000_validate_option(&adapter->tx_abs_int_delay, &opt,
  215. adapter);
  216. } else {
  217. adapter->tx_abs_int_delay = opt.def;
  218. }
  219. }
  220. { /* Receive Interrupt Delay */
  221. struct e1000_option opt = {
  222. .type = range_option,
  223. .name = "Receive Interrupt Delay",
  224. .err = "using default of "
  225. __MODULE_STRING(DEFAULT_RDTR),
  226. .def = DEFAULT_RDTR,
  227. .arg = { .r = { .min = MIN_RXDELAY,
  228. .max = MAX_RXDELAY } }
  229. };
  230. /* modify min and default if 82573 for slow ping w/a,
  231. * a value greater than 8 needs to be set for RDTR */
  232. if (adapter->flags & FLAG_HAS_ASPM) {
  233. opt.def = 32;
  234. opt.arg.r.min = 8;
  235. }
  236. if (num_RxIntDelay > bd) {
  237. adapter->rx_int_delay = RxIntDelay[bd];
  238. e1000_validate_option(&adapter->rx_int_delay, &opt,
  239. adapter);
  240. } else {
  241. adapter->rx_int_delay = opt.def;
  242. }
  243. }
  244. { /* Receive Absolute Interrupt Delay */
  245. struct e1000_option opt = {
  246. .type = range_option,
  247. .name = "Receive Absolute Interrupt Delay",
  248. .err = "using default of "
  249. __MODULE_STRING(DEFAULT_RADV),
  250. .def = DEFAULT_RADV,
  251. .arg = { .r = { .min = MIN_RXABSDELAY,
  252. .max = MAX_RXABSDELAY } }
  253. };
  254. if (num_RxAbsIntDelay > bd) {
  255. adapter->rx_abs_int_delay = RxAbsIntDelay[bd];
  256. e1000_validate_option(&adapter->rx_abs_int_delay, &opt,
  257. adapter);
  258. } else {
  259. adapter->rx_abs_int_delay = opt.def;
  260. }
  261. }
  262. { /* Interrupt Throttling Rate */
  263. struct e1000_option opt = {
  264. .type = range_option,
  265. .name = "Interrupt Throttling Rate (ints/sec)",
  266. .err = "using default of "
  267. __MODULE_STRING(DEFAULT_ITR),
  268. .def = DEFAULT_ITR,
  269. .arg = { .r = { .min = MIN_ITR,
  270. .max = MAX_ITR } }
  271. };
  272. if (num_InterruptThrottleRate > bd) {
  273. adapter->itr = InterruptThrottleRate[bd];
  274. switch (adapter->itr) {
  275. case 0:
  276. ndev_info(netdev, "%s turned off\n",
  277. opt.name);
  278. break;
  279. case 1:
  280. ndev_info(netdev,
  281. "%s set to dynamic mode\n",
  282. opt.name);
  283. adapter->itr_setting = adapter->itr;
  284. adapter->itr = 20000;
  285. break;
  286. case 3:
  287. ndev_info(netdev,
  288. "%s set to dynamic conservative mode\n",
  289. opt.name);
  290. adapter->itr_setting = adapter->itr;
  291. adapter->itr = 20000;
  292. break;
  293. default:
  294. e1000_validate_option(&adapter->itr, &opt,
  295. adapter);
  296. /*
  297. * save the setting, because the dynamic bits
  298. * change itr. clear the lower two bits
  299. * because they are used as control
  300. */
  301. adapter->itr_setting = adapter->itr & ~3;
  302. break;
  303. }
  304. } else {
  305. adapter->itr_setting = opt.def;
  306. adapter->itr = 20000;
  307. }
  308. }
  309. { /* Smart Power Down */
  310. struct e1000_option opt = {
  311. .type = enable_option,
  312. .name = "PHY Smart Power Down",
  313. .err = "defaulting to Disabled",
  314. .def = OPTION_DISABLED
  315. };
  316. if (num_SmartPowerDownEnable > bd) {
  317. int spd = SmartPowerDownEnable[bd];
  318. e1000_validate_option(&spd, &opt, adapter);
  319. if ((adapter->flags & FLAG_HAS_SMART_POWER_DOWN)
  320. && spd)
  321. adapter->flags |= FLAG_SMART_POWER_DOWN;
  322. }
  323. }
  324. { /* Kumeran Lock Loss Workaround */
  325. struct e1000_option opt = {
  326. .type = enable_option,
  327. .name = "Kumeran Lock Loss Workaround",
  328. .err = "defaulting to Enabled",
  329. .def = OPTION_ENABLED
  330. };
  331. if (num_KumeranLockLoss > bd) {
  332. int kmrn_lock_loss = KumeranLockLoss[bd];
  333. e1000_validate_option(&kmrn_lock_loss, &opt, adapter);
  334. if (hw->mac.type == e1000_ich8lan)
  335. e1000e_set_kmrn_lock_loss_workaround_ich8lan(hw,
  336. kmrn_lock_loss);
  337. } else {
  338. if (hw->mac.type == e1000_ich8lan)
  339. e1000e_set_kmrn_lock_loss_workaround_ich8lan(hw,
  340. opt.def);
  341. }
  342. }
  343. }