ixgb_main.c 60 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251
  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. /* Change Log
  22. * 1.0.96 04/19/05
  23. * - Make needlessly global code static -- bunk@stusta.de
  24. * - ethtool cleanup -- shemminger@osdl.org
  25. * - Support for MODULE_VERSION -- linville@tuxdriver.com
  26. * - add skb_header_cloned check to the tso path -- herbert@apana.org.au
  27. * 1.0.88 01/05/05
  28. * - include fix to the condition that determines when to quit NAPI - Robert Olsson
  29. * - use netif_poll_{disable/enable} to synchronize between NAPI and i/f up/down
  30. * 1.0.84 10/26/04
  31. * - reset buffer_info->dma in Tx resource cleanup logic
  32. * 1.0.83 10/12/04
  33. * - sparse cleanup - shemminger@osdl.org
  34. * - fix tx resource cleanup logic
  35. */
  36. char ixgb_driver_name[] = "ixgb";
  37. static char ixgb_driver_string[] = "Intel(R) PRO/10GbE Network Driver";
  38. #ifndef CONFIG_IXGB_NAPI
  39. #define DRIVERNAPI
  40. #else
  41. #define DRIVERNAPI "-NAPI"
  42. #endif
  43. #define DRV_VERSION "1.0.104-k4"DRIVERNAPI
  44. char ixgb_driver_version[] = DRV_VERSION;
  45. static char ixgb_copyright[] = "Copyright (c) 1999-2005 Intel Corporation.";
  46. /* ixgb_pci_tbl - PCI Device ID Table
  47. *
  48. * Wildcard entries (PCI_ANY_ID) should come last
  49. * Last entry must be all 0s
  50. *
  51. * { Vendor ID, Device ID, SubVendor ID, SubDevice ID,
  52. * Class, Class Mask, private data (not used) }
  53. */
  54. static struct pci_device_id ixgb_pci_tbl[] = {
  55. {INTEL_VENDOR_ID, IXGB_DEVICE_ID_82597EX,
  56. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
  57. {INTEL_VENDOR_ID, IXGB_DEVICE_ID_82597EX_CX4,
  58. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
  59. {INTEL_VENDOR_ID, IXGB_DEVICE_ID_82597EX_SR,
  60. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
  61. {INTEL_VENDOR_ID, IXGB_DEVICE_ID_82597EX_LR,
  62. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
  63. /* required last entry */
  64. {0,}
  65. };
  66. MODULE_DEVICE_TABLE(pci, ixgb_pci_tbl);
  67. /* Local Function Prototypes */
  68. int ixgb_up(struct ixgb_adapter *adapter);
  69. void ixgb_down(struct ixgb_adapter *adapter, boolean_t kill_watchdog);
  70. void ixgb_reset(struct ixgb_adapter *adapter);
  71. int ixgb_setup_tx_resources(struct ixgb_adapter *adapter);
  72. int ixgb_setup_rx_resources(struct ixgb_adapter *adapter);
  73. void ixgb_free_tx_resources(struct ixgb_adapter *adapter);
  74. void ixgb_free_rx_resources(struct ixgb_adapter *adapter);
  75. void ixgb_update_stats(struct ixgb_adapter *adapter);
  76. static int ixgb_init_module(void);
  77. static void ixgb_exit_module(void);
  78. static int ixgb_probe(struct pci_dev *pdev, const struct pci_device_id *ent);
  79. static void __devexit ixgb_remove(struct pci_dev *pdev);
  80. static int ixgb_sw_init(struct ixgb_adapter *adapter);
  81. static int ixgb_open(struct net_device *netdev);
  82. static int ixgb_close(struct net_device *netdev);
  83. static void ixgb_configure_tx(struct ixgb_adapter *adapter);
  84. static void ixgb_configure_rx(struct ixgb_adapter *adapter);
  85. static void ixgb_setup_rctl(struct ixgb_adapter *adapter);
  86. static void ixgb_clean_tx_ring(struct ixgb_adapter *adapter);
  87. static void ixgb_clean_rx_ring(struct ixgb_adapter *adapter);
  88. static void ixgb_set_multi(struct net_device *netdev);
  89. static void ixgb_watchdog(unsigned long data);
  90. static int ixgb_xmit_frame(struct sk_buff *skb, struct net_device *netdev);
  91. static struct net_device_stats *ixgb_get_stats(struct net_device *netdev);
  92. static int ixgb_change_mtu(struct net_device *netdev, int new_mtu);
  93. static int ixgb_set_mac(struct net_device *netdev, void *p);
  94. static irqreturn_t ixgb_intr(int irq, void *data, struct pt_regs *regs);
  95. static boolean_t ixgb_clean_tx_irq(struct ixgb_adapter *adapter);
  96. #ifdef CONFIG_IXGB_NAPI
  97. static int ixgb_clean(struct net_device *netdev, int *budget);
  98. static boolean_t ixgb_clean_rx_irq(struct ixgb_adapter *adapter,
  99. int *work_done, int work_to_do);
  100. #else
  101. static boolean_t ixgb_clean_rx_irq(struct ixgb_adapter *adapter);
  102. #endif
  103. static void ixgb_alloc_rx_buffers(struct ixgb_adapter *adapter);
  104. void ixgb_set_ethtool_ops(struct net_device *netdev);
  105. static void ixgb_tx_timeout(struct net_device *dev);
  106. static void ixgb_tx_timeout_task(struct net_device *dev);
  107. static void ixgb_vlan_rx_register(struct net_device *netdev,
  108. struct vlan_group *grp);
  109. static void ixgb_vlan_rx_add_vid(struct net_device *netdev, uint16_t vid);
  110. static void ixgb_vlan_rx_kill_vid(struct net_device *netdev, uint16_t vid);
  111. static void ixgb_restore_vlan(struct ixgb_adapter *adapter);
  112. #ifdef CONFIG_NET_POLL_CONTROLLER
  113. /* for netdump / net console */
  114. static void ixgb_netpoll(struct net_device *dev);
  115. #endif
  116. /* Exported from other modules */
  117. extern void ixgb_check_options(struct ixgb_adapter *adapter);
  118. static struct pci_driver ixgb_driver = {
  119. .name = ixgb_driver_name,
  120. .id_table = ixgb_pci_tbl,
  121. .probe = ixgb_probe,
  122. .remove = __devexit_p(ixgb_remove),
  123. };
  124. MODULE_AUTHOR("Intel Corporation, <linux.nics@intel.com>");
  125. MODULE_DESCRIPTION("Intel(R) PRO/10GbE Network Driver");
  126. MODULE_LICENSE("GPL");
  127. MODULE_VERSION(DRV_VERSION);
  128. #define DEFAULT_DEBUG_LEVEL_SHIFT 3
  129. static int debug = DEFAULT_DEBUG_LEVEL_SHIFT;
  130. module_param(debug, int, 0);
  131. MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)");
  132. /* some defines for controlling descriptor fetches in h/w */
  133. #define RXDCTL_WTHRESH_DEFAULT 16 /* chip writes back at this many or RXT0 */
  134. #define RXDCTL_PTHRESH_DEFAULT 0 /* chip considers prefech below
  135. * this */
  136. #define RXDCTL_HTHRESH_DEFAULT 0 /* chip will only prefetch if tail
  137. * is pushed this many descriptors
  138. * from head */
  139. /**
  140. * ixgb_init_module - Driver Registration Routine
  141. *
  142. * ixgb_init_module is the first routine called when the driver is
  143. * loaded. All it does is register with the PCI subsystem.
  144. **/
  145. static int __init
  146. ixgb_init_module(void)
  147. {
  148. printk(KERN_INFO "%s - version %s\n",
  149. ixgb_driver_string, ixgb_driver_version);
  150. printk(KERN_INFO "%s\n", ixgb_copyright);
  151. return pci_module_init(&ixgb_driver);
  152. }
  153. module_init(ixgb_init_module);
  154. /**
  155. * ixgb_exit_module - Driver Exit Cleanup Routine
  156. *
  157. * ixgb_exit_module is called just before the driver is removed
  158. * from memory.
  159. **/
  160. static void __exit
  161. ixgb_exit_module(void)
  162. {
  163. pci_unregister_driver(&ixgb_driver);
  164. }
  165. module_exit(ixgb_exit_module);
  166. /**
  167. * ixgb_irq_disable - Mask off interrupt generation on the NIC
  168. * @adapter: board private structure
  169. **/
  170. static inline void
  171. ixgb_irq_disable(struct ixgb_adapter *adapter)
  172. {
  173. atomic_inc(&adapter->irq_sem);
  174. IXGB_WRITE_REG(&adapter->hw, IMC, ~0);
  175. IXGB_WRITE_FLUSH(&adapter->hw);
  176. synchronize_irq(adapter->pdev->irq);
  177. }
  178. /**
  179. * ixgb_irq_enable - Enable default interrupt generation settings
  180. * @adapter: board private structure
  181. **/
  182. static inline void
  183. ixgb_irq_enable(struct ixgb_adapter *adapter)
  184. {
  185. if(atomic_dec_and_test(&adapter->irq_sem)) {
  186. IXGB_WRITE_REG(&adapter->hw, IMS,
  187. IXGB_INT_RXT0 | IXGB_INT_RXDMT0 | IXGB_INT_TXDW |
  188. IXGB_INT_LSC);
  189. IXGB_WRITE_FLUSH(&adapter->hw);
  190. }
  191. }
  192. int
  193. ixgb_up(struct ixgb_adapter *adapter)
  194. {
  195. struct net_device *netdev = adapter->netdev;
  196. int err;
  197. int max_frame = netdev->mtu + ENET_HEADER_SIZE + ENET_FCS_LENGTH;
  198. struct ixgb_hw *hw = &adapter->hw;
  199. /* hardware has been reset, we need to reload some things */
  200. ixgb_rar_set(hw, netdev->dev_addr, 0);
  201. ixgb_set_multi(netdev);
  202. ixgb_restore_vlan(adapter);
  203. ixgb_configure_tx(adapter);
  204. ixgb_setup_rctl(adapter);
  205. ixgb_configure_rx(adapter);
  206. ixgb_alloc_rx_buffers(adapter);
  207. /* disable interrupts and get the hardware into a known state */
  208. IXGB_WRITE_REG(&adapter->hw, IMC, 0xffffffff);
  209. #ifdef CONFIG_PCI_MSI
  210. {
  211. boolean_t pcix = (IXGB_READ_REG(&adapter->hw, STATUS) &
  212. IXGB_STATUS_PCIX_MODE) ? TRUE : FALSE;
  213. adapter->have_msi = TRUE;
  214. if (!pcix)
  215. adapter->have_msi = FALSE;
  216. else if((err = pci_enable_msi(adapter->pdev))) {
  217. DPRINTK(PROBE, ERR,
  218. "Unable to allocate MSI interrupt Error: %d\n", err);
  219. adapter->have_msi = FALSE;
  220. /* proceed to try to request regular interrupt */
  221. }
  222. }
  223. #endif
  224. if((err = request_irq(adapter->pdev->irq, &ixgb_intr,
  225. SA_SHIRQ | SA_SAMPLE_RANDOM,
  226. netdev->name, netdev))) {
  227. DPRINTK(PROBE, ERR,
  228. "Unable to allocate interrupt Error: %d\n", err);
  229. return err;
  230. }
  231. if((hw->max_frame_size != max_frame) ||
  232. (hw->max_frame_size !=
  233. (IXGB_READ_REG(hw, MFS) >> IXGB_MFS_SHIFT))) {
  234. hw->max_frame_size = max_frame;
  235. IXGB_WRITE_REG(hw, MFS, hw->max_frame_size << IXGB_MFS_SHIFT);
  236. if(hw->max_frame_size >
  237. IXGB_MAX_ENET_FRAME_SIZE_WITHOUT_FCS + ENET_FCS_LENGTH) {
  238. uint32_t ctrl0 = IXGB_READ_REG(hw, CTRL0);
  239. if(!(ctrl0 & IXGB_CTRL0_JFE)) {
  240. ctrl0 |= IXGB_CTRL0_JFE;
  241. IXGB_WRITE_REG(hw, CTRL0, ctrl0);
  242. }
  243. }
  244. }
  245. mod_timer(&adapter->watchdog_timer, jiffies);
  246. #ifdef CONFIG_IXGB_NAPI
  247. netif_poll_enable(netdev);
  248. #endif
  249. ixgb_irq_enable(adapter);
  250. return 0;
  251. }
  252. void
  253. ixgb_down(struct ixgb_adapter *adapter, boolean_t kill_watchdog)
  254. {
  255. struct net_device *netdev = adapter->netdev;
  256. ixgb_irq_disable(adapter);
  257. free_irq(adapter->pdev->irq, netdev);
  258. #ifdef CONFIG_PCI_MSI
  259. if(adapter->have_msi == TRUE)
  260. pci_disable_msi(adapter->pdev);
  261. #endif
  262. if(kill_watchdog)
  263. del_timer_sync(&adapter->watchdog_timer);
  264. #ifdef CONFIG_IXGB_NAPI
  265. netif_poll_disable(netdev);
  266. #endif
  267. adapter->link_speed = 0;
  268. adapter->link_duplex = 0;
  269. netif_carrier_off(netdev);
  270. netif_stop_queue(netdev);
  271. ixgb_reset(adapter);
  272. ixgb_clean_tx_ring(adapter);
  273. ixgb_clean_rx_ring(adapter);
  274. }
  275. void
  276. ixgb_reset(struct ixgb_adapter *adapter)
  277. {
  278. ixgb_adapter_stop(&adapter->hw);
  279. if(!ixgb_init_hw(&adapter->hw))
  280. DPRINTK(PROBE, ERR, "ixgb_init_hw failed.\n");
  281. }
  282. /**
  283. * ixgb_probe - Device Initialization Routine
  284. * @pdev: PCI device information struct
  285. * @ent: entry in ixgb_pci_tbl
  286. *
  287. * Returns 0 on success, negative on failure
  288. *
  289. * ixgb_probe initializes an adapter identified by a pci_dev structure.
  290. * The OS initialization, configuring of the adapter private structure,
  291. * and a hardware reset occur.
  292. **/
  293. static int __devinit
  294. ixgb_probe(struct pci_dev *pdev,
  295. const struct pci_device_id *ent)
  296. {
  297. struct net_device *netdev = NULL;
  298. struct ixgb_adapter *adapter;
  299. static int cards_found = 0;
  300. unsigned long mmio_start;
  301. int mmio_len;
  302. int pci_using_dac;
  303. int i;
  304. int err;
  305. if((err = pci_enable_device(pdev)))
  306. return err;
  307. if(!(err = pci_set_dma_mask(pdev, DMA_64BIT_MASK)) &&
  308. !(err = pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK))) {
  309. pci_using_dac = 1;
  310. } else {
  311. if((err = pci_set_dma_mask(pdev, DMA_32BIT_MASK)) ||
  312. (err = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK))) {
  313. printk(KERN_ERR
  314. "ixgb: No usable DMA configuration, aborting\n");
  315. goto err_dma_mask;
  316. }
  317. pci_using_dac = 0;
  318. }
  319. if((err = pci_request_regions(pdev, ixgb_driver_name)))
  320. goto err_request_regions;
  321. pci_set_master(pdev);
  322. netdev = alloc_etherdev(sizeof(struct ixgb_adapter));
  323. if(!netdev) {
  324. err = -ENOMEM;
  325. goto err_alloc_etherdev;
  326. }
  327. SET_MODULE_OWNER(netdev);
  328. SET_NETDEV_DEV(netdev, &pdev->dev);
  329. pci_set_drvdata(pdev, netdev);
  330. adapter = netdev_priv(netdev);
  331. adapter->netdev = netdev;
  332. adapter->pdev = pdev;
  333. adapter->hw.back = adapter;
  334. adapter->msg_enable = netif_msg_init(debug, DEFAULT_DEBUG_LEVEL_SHIFT);
  335. mmio_start = pci_resource_start(pdev, BAR_0);
  336. mmio_len = pci_resource_len(pdev, BAR_0);
  337. adapter->hw.hw_addr = ioremap(mmio_start, mmio_len);
  338. if(!adapter->hw.hw_addr) {
  339. err = -EIO;
  340. goto err_ioremap;
  341. }
  342. for(i = BAR_1; i <= BAR_5; i++) {
  343. if(pci_resource_len(pdev, i) == 0)
  344. continue;
  345. if(pci_resource_flags(pdev, i) & IORESOURCE_IO) {
  346. adapter->hw.io_base = pci_resource_start(pdev, i);
  347. break;
  348. }
  349. }
  350. netdev->open = &ixgb_open;
  351. netdev->stop = &ixgb_close;
  352. netdev->hard_start_xmit = &ixgb_xmit_frame;
  353. netdev->get_stats = &ixgb_get_stats;
  354. netdev->set_multicast_list = &ixgb_set_multi;
  355. netdev->set_mac_address = &ixgb_set_mac;
  356. netdev->change_mtu = &ixgb_change_mtu;
  357. ixgb_set_ethtool_ops(netdev);
  358. netdev->tx_timeout = &ixgb_tx_timeout;
  359. netdev->watchdog_timeo = 5 * HZ;
  360. #ifdef CONFIG_IXGB_NAPI
  361. netdev->poll = &ixgb_clean;
  362. netdev->weight = 64;
  363. #endif
  364. netdev->vlan_rx_register = ixgb_vlan_rx_register;
  365. netdev->vlan_rx_add_vid = ixgb_vlan_rx_add_vid;
  366. netdev->vlan_rx_kill_vid = ixgb_vlan_rx_kill_vid;
  367. #ifdef CONFIG_NET_POLL_CONTROLLER
  368. netdev->poll_controller = ixgb_netpoll;
  369. #endif
  370. strcpy(netdev->name, pci_name(pdev));
  371. netdev->mem_start = mmio_start;
  372. netdev->mem_end = mmio_start + mmio_len;
  373. netdev->base_addr = adapter->hw.io_base;
  374. adapter->bd_number = cards_found;
  375. adapter->link_speed = 0;
  376. adapter->link_duplex = 0;
  377. /* setup the private structure */
  378. if((err = ixgb_sw_init(adapter)))
  379. goto err_sw_init;
  380. netdev->features = NETIF_F_SG |
  381. NETIF_F_HW_CSUM |
  382. NETIF_F_HW_VLAN_TX |
  383. NETIF_F_HW_VLAN_RX |
  384. NETIF_F_HW_VLAN_FILTER;
  385. #ifdef NETIF_F_TSO
  386. netdev->features |= NETIF_F_TSO;
  387. #endif
  388. #ifdef NETIF_F_LLTX
  389. netdev->features |= NETIF_F_LLTX;
  390. #endif
  391. if(pci_using_dac)
  392. netdev->features |= NETIF_F_HIGHDMA;
  393. /* make sure the EEPROM is good */
  394. if(!ixgb_validate_eeprom_checksum(&adapter->hw)) {
  395. DPRINTK(PROBE, ERR, "The EEPROM Checksum Is Not Valid\n");
  396. err = -EIO;
  397. goto err_eeprom;
  398. }
  399. ixgb_get_ee_mac_addr(&adapter->hw, netdev->dev_addr);
  400. memcpy(netdev->perm_addr, netdev->dev_addr, netdev->addr_len);
  401. if(!is_valid_ether_addr(netdev->perm_addr)) {
  402. DPRINTK(PROBE, ERR, "Invalid MAC Address\n");
  403. err = -EIO;
  404. goto err_eeprom;
  405. }
  406. adapter->part_num = ixgb_get_ee_pba_number(&adapter->hw);
  407. init_timer(&adapter->watchdog_timer);
  408. adapter->watchdog_timer.function = &ixgb_watchdog;
  409. adapter->watchdog_timer.data = (unsigned long)adapter;
  410. INIT_WORK(&adapter->tx_timeout_task,
  411. (void (*)(void *))ixgb_tx_timeout_task, netdev);
  412. strcpy(netdev->name, "eth%d");
  413. if((err = register_netdev(netdev)))
  414. goto err_register;
  415. /* we're going to reset, so assume we have no link for now */
  416. netif_carrier_off(netdev);
  417. netif_stop_queue(netdev);
  418. DPRINTK(PROBE, INFO, "Intel(R) PRO/10GbE Network Connection\n");
  419. ixgb_check_options(adapter);
  420. /* reset the hardware with the new settings */
  421. ixgb_reset(adapter);
  422. cards_found++;
  423. return 0;
  424. err_register:
  425. err_sw_init:
  426. err_eeprom:
  427. iounmap(adapter->hw.hw_addr);
  428. err_ioremap:
  429. free_netdev(netdev);
  430. err_alloc_etherdev:
  431. pci_release_regions(pdev);
  432. err_request_regions:
  433. err_dma_mask:
  434. pci_disable_device(pdev);
  435. return err;
  436. }
  437. /**
  438. * ixgb_remove - Device Removal Routine
  439. * @pdev: PCI device information struct
  440. *
  441. * ixgb_remove is called by the PCI subsystem to alert the driver
  442. * that it should release a PCI device. The could be caused by a
  443. * Hot-Plug event, or because the driver is going to be removed from
  444. * memory.
  445. **/
  446. static void __devexit
  447. ixgb_remove(struct pci_dev *pdev)
  448. {
  449. struct net_device *netdev = pci_get_drvdata(pdev);
  450. struct ixgb_adapter *adapter = netdev_priv(netdev);
  451. unregister_netdev(netdev);
  452. iounmap(adapter->hw.hw_addr);
  453. pci_release_regions(pdev);
  454. free_netdev(netdev);
  455. }
  456. /**
  457. * ixgb_sw_init - Initialize general software structures (struct ixgb_adapter)
  458. * @adapter: board private structure to initialize
  459. *
  460. * ixgb_sw_init initializes the Adapter private data structure.
  461. * Fields are initialized based on PCI device information and
  462. * OS network device settings (MTU size).
  463. **/
  464. static int __devinit
  465. ixgb_sw_init(struct ixgb_adapter *adapter)
  466. {
  467. struct ixgb_hw *hw = &adapter->hw;
  468. struct net_device *netdev = adapter->netdev;
  469. struct pci_dev *pdev = adapter->pdev;
  470. /* PCI config space info */
  471. hw->vendor_id = pdev->vendor;
  472. hw->device_id = pdev->device;
  473. hw->subsystem_vendor_id = pdev->subsystem_vendor;
  474. hw->subsystem_id = pdev->subsystem_device;
  475. adapter->rx_buffer_len = IXGB_RXBUFFER_2048;
  476. hw->max_frame_size = netdev->mtu + ENET_HEADER_SIZE + ENET_FCS_LENGTH;
  477. if((hw->device_id == IXGB_DEVICE_ID_82597EX)
  478. || (hw->device_id == IXGB_DEVICE_ID_82597EX_CX4)
  479. || (hw->device_id == IXGB_DEVICE_ID_82597EX_LR)
  480. || (hw->device_id == IXGB_DEVICE_ID_82597EX_SR))
  481. hw->mac_type = ixgb_82597;
  482. else {
  483. /* should never have loaded on this device */
  484. DPRINTK(PROBE, ERR, "unsupported device id\n");
  485. }
  486. /* enable flow control to be programmed */
  487. hw->fc.send_xon = 1;
  488. atomic_set(&adapter->irq_sem, 1);
  489. spin_lock_init(&adapter->tx_lock);
  490. return 0;
  491. }
  492. /**
  493. * ixgb_open - Called when a network interface is made active
  494. * @netdev: network interface device structure
  495. *
  496. * Returns 0 on success, negative value on failure
  497. *
  498. * The open entry point is called when a network interface is made
  499. * active by the system (IFF_UP). At this point all resources needed
  500. * for transmit and receive operations are allocated, the interrupt
  501. * handler is registered with the OS, the watchdog timer is started,
  502. * and the stack is notified that the interface is ready.
  503. **/
  504. static int
  505. ixgb_open(struct net_device *netdev)
  506. {
  507. struct ixgb_adapter *adapter = netdev_priv(netdev);
  508. int err;
  509. /* allocate transmit descriptors */
  510. if((err = ixgb_setup_tx_resources(adapter)))
  511. goto err_setup_tx;
  512. /* allocate receive descriptors */
  513. if((err = ixgb_setup_rx_resources(adapter)))
  514. goto err_setup_rx;
  515. if((err = ixgb_up(adapter)))
  516. goto err_up;
  517. return 0;
  518. err_up:
  519. ixgb_free_rx_resources(adapter);
  520. err_setup_rx:
  521. ixgb_free_tx_resources(adapter);
  522. err_setup_tx:
  523. ixgb_reset(adapter);
  524. return err;
  525. }
  526. /**
  527. * ixgb_close - Disables a network interface
  528. * @netdev: network interface device structure
  529. *
  530. * Returns 0, this is not allowed to fail
  531. *
  532. * The close entry point is called when an interface is de-activated
  533. * by the OS. The hardware is still under the drivers control, but
  534. * needs to be disabled. A global MAC reset is issued to stop the
  535. * hardware, and all transmit and receive resources are freed.
  536. **/
  537. static int
  538. ixgb_close(struct net_device *netdev)
  539. {
  540. struct ixgb_adapter *adapter = netdev_priv(netdev);
  541. ixgb_down(adapter, TRUE);
  542. ixgb_free_tx_resources(adapter);
  543. ixgb_free_rx_resources(adapter);
  544. return 0;
  545. }
  546. /**
  547. * ixgb_setup_tx_resources - allocate Tx resources (Descriptors)
  548. * @adapter: board private structure
  549. *
  550. * Return 0 on success, negative on failure
  551. **/
  552. int
  553. ixgb_setup_tx_resources(struct ixgb_adapter *adapter)
  554. {
  555. struct ixgb_desc_ring *txdr = &adapter->tx_ring;
  556. struct pci_dev *pdev = adapter->pdev;
  557. int size;
  558. size = sizeof(struct ixgb_buffer) * txdr->count;
  559. txdr->buffer_info = vmalloc(size);
  560. if(!txdr->buffer_info) {
  561. DPRINTK(PROBE, ERR,
  562. "Unable to allocate transmit descriptor ring memory\n");
  563. return -ENOMEM;
  564. }
  565. memset(txdr->buffer_info, 0, size);
  566. /* round up to nearest 4K */
  567. txdr->size = txdr->count * sizeof(struct ixgb_tx_desc);
  568. IXGB_ROUNDUP(txdr->size, 4096);
  569. txdr->desc = pci_alloc_consistent(pdev, txdr->size, &txdr->dma);
  570. if(!txdr->desc) {
  571. vfree(txdr->buffer_info);
  572. DPRINTK(PROBE, ERR,
  573. "Unable to allocate transmit descriptor memory\n");
  574. return -ENOMEM;
  575. }
  576. memset(txdr->desc, 0, txdr->size);
  577. txdr->next_to_use = 0;
  578. txdr->next_to_clean = 0;
  579. return 0;
  580. }
  581. /**
  582. * ixgb_configure_tx - Configure 82597 Transmit Unit after Reset.
  583. * @adapter: board private structure
  584. *
  585. * Configure the Tx unit of the MAC after a reset.
  586. **/
  587. static void
  588. ixgb_configure_tx(struct ixgb_adapter *adapter)
  589. {
  590. uint64_t tdba = adapter->tx_ring.dma;
  591. uint32_t tdlen = adapter->tx_ring.count * sizeof(struct ixgb_tx_desc);
  592. uint32_t tctl;
  593. struct ixgb_hw *hw = &adapter->hw;
  594. /* Setup the Base and Length of the Tx Descriptor Ring
  595. * tx_ring.dma can be either a 32 or 64 bit value
  596. */
  597. IXGB_WRITE_REG(hw, TDBAL, (tdba & 0x00000000ffffffffULL));
  598. IXGB_WRITE_REG(hw, TDBAH, (tdba >> 32));
  599. IXGB_WRITE_REG(hw, TDLEN, tdlen);
  600. /* Setup the HW Tx Head and Tail descriptor pointers */
  601. IXGB_WRITE_REG(hw, TDH, 0);
  602. IXGB_WRITE_REG(hw, TDT, 0);
  603. /* don't set up txdctl, it induces performance problems if configured
  604. * incorrectly */
  605. /* Set the Tx Interrupt Delay register */
  606. IXGB_WRITE_REG(hw, TIDV, adapter->tx_int_delay);
  607. /* Program the Transmit Control Register */
  608. tctl = IXGB_TCTL_TCE | IXGB_TCTL_TXEN | IXGB_TCTL_TPDE;
  609. IXGB_WRITE_REG(hw, TCTL, tctl);
  610. /* Setup Transmit Descriptor Settings for this adapter */
  611. adapter->tx_cmd_type =
  612. IXGB_TX_DESC_TYPE
  613. | (adapter->tx_int_delay_enable ? IXGB_TX_DESC_CMD_IDE : 0);
  614. }
  615. /**
  616. * ixgb_setup_rx_resources - allocate Rx resources (Descriptors)
  617. * @adapter: board private structure
  618. *
  619. * Returns 0 on success, negative on failure
  620. **/
  621. int
  622. ixgb_setup_rx_resources(struct ixgb_adapter *adapter)
  623. {
  624. struct ixgb_desc_ring *rxdr = &adapter->rx_ring;
  625. struct pci_dev *pdev = adapter->pdev;
  626. int size;
  627. size = sizeof(struct ixgb_buffer) * rxdr->count;
  628. rxdr->buffer_info = vmalloc(size);
  629. if(!rxdr->buffer_info) {
  630. DPRINTK(PROBE, ERR,
  631. "Unable to allocate receive descriptor ring\n");
  632. return -ENOMEM;
  633. }
  634. memset(rxdr->buffer_info, 0, size);
  635. /* Round up to nearest 4K */
  636. rxdr->size = rxdr->count * sizeof(struct ixgb_rx_desc);
  637. IXGB_ROUNDUP(rxdr->size, 4096);
  638. rxdr->desc = pci_alloc_consistent(pdev, rxdr->size, &rxdr->dma);
  639. if(!rxdr->desc) {
  640. vfree(rxdr->buffer_info);
  641. DPRINTK(PROBE, ERR,
  642. "Unable to allocate receive descriptors\n");
  643. return -ENOMEM;
  644. }
  645. memset(rxdr->desc, 0, rxdr->size);
  646. rxdr->next_to_clean = 0;
  647. rxdr->next_to_use = 0;
  648. return 0;
  649. }
  650. /**
  651. * ixgb_setup_rctl - configure the receive control register
  652. * @adapter: Board private structure
  653. **/
  654. static void
  655. ixgb_setup_rctl(struct ixgb_adapter *adapter)
  656. {
  657. uint32_t rctl;
  658. rctl = IXGB_READ_REG(&adapter->hw, RCTL);
  659. rctl &= ~(3 << IXGB_RCTL_MO_SHIFT);
  660. rctl |=
  661. IXGB_RCTL_BAM | IXGB_RCTL_RDMTS_1_2 |
  662. IXGB_RCTL_RXEN | IXGB_RCTL_CFF |
  663. (adapter->hw.mc_filter_type << IXGB_RCTL_MO_SHIFT);
  664. rctl |= IXGB_RCTL_SECRC;
  665. switch (adapter->rx_buffer_len) {
  666. case IXGB_RXBUFFER_2048:
  667. default:
  668. rctl |= IXGB_RCTL_BSIZE_2048;
  669. break;
  670. case IXGB_RXBUFFER_4096:
  671. rctl |= IXGB_RCTL_BSIZE_4096;
  672. break;
  673. case IXGB_RXBUFFER_8192:
  674. rctl |= IXGB_RCTL_BSIZE_8192;
  675. break;
  676. case IXGB_RXBUFFER_16384:
  677. rctl |= IXGB_RCTL_BSIZE_16384;
  678. break;
  679. }
  680. IXGB_WRITE_REG(&adapter->hw, RCTL, rctl);
  681. }
  682. /**
  683. * ixgb_configure_rx - Configure 82597 Receive Unit after Reset.
  684. * @adapter: board private structure
  685. *
  686. * Configure the Rx unit of the MAC after a reset.
  687. **/
  688. static void
  689. ixgb_configure_rx(struct ixgb_adapter *adapter)
  690. {
  691. uint64_t rdba = adapter->rx_ring.dma;
  692. uint32_t rdlen = adapter->rx_ring.count * sizeof(struct ixgb_rx_desc);
  693. struct ixgb_hw *hw = &adapter->hw;
  694. uint32_t rctl;
  695. uint32_t rxcsum;
  696. uint32_t rxdctl;
  697. /* make sure receives are disabled while setting up the descriptors */
  698. rctl = IXGB_READ_REG(hw, RCTL);
  699. IXGB_WRITE_REG(hw, RCTL, rctl & ~IXGB_RCTL_RXEN);
  700. /* set the Receive Delay Timer Register */
  701. IXGB_WRITE_REG(hw, RDTR, adapter->rx_int_delay);
  702. /* Setup the Base and Length of the Rx Descriptor Ring */
  703. IXGB_WRITE_REG(hw, RDBAL, (rdba & 0x00000000ffffffffULL));
  704. IXGB_WRITE_REG(hw, RDBAH, (rdba >> 32));
  705. IXGB_WRITE_REG(hw, RDLEN, rdlen);
  706. /* Setup the HW Rx Head and Tail Descriptor Pointers */
  707. IXGB_WRITE_REG(hw, RDH, 0);
  708. IXGB_WRITE_REG(hw, RDT, 0);
  709. /* set up pre-fetching of receive buffers so we get some before we
  710. * run out (default hardware behavior is to run out before fetching
  711. * more). This sets up to fetch if HTHRESH rx descriptors are avail
  712. * and the descriptors in hw cache are below PTHRESH. This avoids
  713. * the hardware behavior of fetching <=512 descriptors in a single
  714. * burst that pre-empts all other activity, usually causing fifo
  715. * overflows. */
  716. /* use WTHRESH to burst write 16 descriptors or burst when RXT0 */
  717. rxdctl = RXDCTL_WTHRESH_DEFAULT << IXGB_RXDCTL_WTHRESH_SHIFT |
  718. RXDCTL_HTHRESH_DEFAULT << IXGB_RXDCTL_HTHRESH_SHIFT |
  719. RXDCTL_PTHRESH_DEFAULT << IXGB_RXDCTL_PTHRESH_SHIFT;
  720. IXGB_WRITE_REG(hw, RXDCTL, rxdctl);
  721. /* Enable Receive Checksum Offload for TCP and UDP */
  722. if(adapter->rx_csum == TRUE) {
  723. rxcsum = IXGB_READ_REG(hw, RXCSUM);
  724. rxcsum |= IXGB_RXCSUM_TUOFL;
  725. IXGB_WRITE_REG(hw, RXCSUM, rxcsum);
  726. }
  727. /* Enable Receives */
  728. IXGB_WRITE_REG(hw, RCTL, rctl);
  729. }
  730. /**
  731. * ixgb_free_tx_resources - Free Tx Resources
  732. * @adapter: board private structure
  733. *
  734. * Free all transmit software resources
  735. **/
  736. void
  737. ixgb_free_tx_resources(struct ixgb_adapter *adapter)
  738. {
  739. struct pci_dev *pdev = adapter->pdev;
  740. ixgb_clean_tx_ring(adapter);
  741. vfree(adapter->tx_ring.buffer_info);
  742. adapter->tx_ring.buffer_info = NULL;
  743. pci_free_consistent(pdev, adapter->tx_ring.size,
  744. adapter->tx_ring.desc, adapter->tx_ring.dma);
  745. adapter->tx_ring.desc = NULL;
  746. }
  747. static inline void
  748. ixgb_unmap_and_free_tx_resource(struct ixgb_adapter *adapter,
  749. struct ixgb_buffer *buffer_info)
  750. {
  751. struct pci_dev *pdev = adapter->pdev;
  752. if (buffer_info->dma)
  753. pci_unmap_page(pdev, buffer_info->dma, buffer_info->length,
  754. PCI_DMA_TODEVICE);
  755. if (buffer_info->skb)
  756. dev_kfree_skb_any(buffer_info->skb);
  757. buffer_info->skb = NULL;
  758. buffer_info->dma = 0;
  759. buffer_info->time_stamp = 0;
  760. /* these fields must always be initialized in tx
  761. * buffer_info->length = 0;
  762. * buffer_info->next_to_watch = 0; */
  763. }
  764. /**
  765. * ixgb_clean_tx_ring - Free Tx Buffers
  766. * @adapter: board private structure
  767. **/
  768. static void
  769. ixgb_clean_tx_ring(struct ixgb_adapter *adapter)
  770. {
  771. struct ixgb_desc_ring *tx_ring = &adapter->tx_ring;
  772. struct ixgb_buffer *buffer_info;
  773. unsigned long size;
  774. unsigned int i;
  775. /* Free all the Tx ring sk_buffs */
  776. for(i = 0; i < tx_ring->count; i++) {
  777. buffer_info = &tx_ring->buffer_info[i];
  778. ixgb_unmap_and_free_tx_resource(adapter, buffer_info);
  779. }
  780. size = sizeof(struct ixgb_buffer) * tx_ring->count;
  781. memset(tx_ring->buffer_info, 0, size);
  782. /* Zero out the descriptor ring */
  783. memset(tx_ring->desc, 0, tx_ring->size);
  784. tx_ring->next_to_use = 0;
  785. tx_ring->next_to_clean = 0;
  786. IXGB_WRITE_REG(&adapter->hw, TDH, 0);
  787. IXGB_WRITE_REG(&adapter->hw, TDT, 0);
  788. }
  789. /**
  790. * ixgb_free_rx_resources - Free Rx Resources
  791. * @adapter: board private structure
  792. *
  793. * Free all receive software resources
  794. **/
  795. void
  796. ixgb_free_rx_resources(struct ixgb_adapter *adapter)
  797. {
  798. struct ixgb_desc_ring *rx_ring = &adapter->rx_ring;
  799. struct pci_dev *pdev = adapter->pdev;
  800. ixgb_clean_rx_ring(adapter);
  801. vfree(rx_ring->buffer_info);
  802. rx_ring->buffer_info = NULL;
  803. pci_free_consistent(pdev, rx_ring->size, rx_ring->desc, rx_ring->dma);
  804. rx_ring->desc = NULL;
  805. }
  806. /**
  807. * ixgb_clean_rx_ring - Free Rx Buffers
  808. * @adapter: board private structure
  809. **/
  810. static void
  811. ixgb_clean_rx_ring(struct ixgb_adapter *adapter)
  812. {
  813. struct ixgb_desc_ring *rx_ring = &adapter->rx_ring;
  814. struct ixgb_buffer *buffer_info;
  815. struct pci_dev *pdev = adapter->pdev;
  816. unsigned long size;
  817. unsigned int i;
  818. /* Free all the Rx ring sk_buffs */
  819. for(i = 0; i < rx_ring->count; i++) {
  820. buffer_info = &rx_ring->buffer_info[i];
  821. if(buffer_info->skb) {
  822. pci_unmap_single(pdev,
  823. buffer_info->dma,
  824. buffer_info->length,
  825. PCI_DMA_FROMDEVICE);
  826. dev_kfree_skb(buffer_info->skb);
  827. buffer_info->skb = NULL;
  828. }
  829. }
  830. size = sizeof(struct ixgb_buffer) * rx_ring->count;
  831. memset(rx_ring->buffer_info, 0, size);
  832. /* Zero out the descriptor ring */
  833. memset(rx_ring->desc, 0, rx_ring->size);
  834. rx_ring->next_to_clean = 0;
  835. rx_ring->next_to_use = 0;
  836. IXGB_WRITE_REG(&adapter->hw, RDH, 0);
  837. IXGB_WRITE_REG(&adapter->hw, RDT, 0);
  838. }
  839. /**
  840. * ixgb_set_mac - Change the Ethernet Address of the NIC
  841. * @netdev: network interface device structure
  842. * @p: pointer to an address structure
  843. *
  844. * Returns 0 on success, negative on failure
  845. **/
  846. static int
  847. ixgb_set_mac(struct net_device *netdev, void *p)
  848. {
  849. struct ixgb_adapter *adapter = netdev_priv(netdev);
  850. struct sockaddr *addr = p;
  851. if(!is_valid_ether_addr(addr->sa_data))
  852. return -EADDRNOTAVAIL;
  853. memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
  854. ixgb_rar_set(&adapter->hw, addr->sa_data, 0);
  855. return 0;
  856. }
  857. /**
  858. * ixgb_set_multi - Multicast and Promiscuous mode set
  859. * @netdev: network interface device structure
  860. *
  861. * The set_multi entry point is called whenever the multicast address
  862. * list or the network interface flags are updated. This routine is
  863. * responsible for configuring the hardware for proper multicast,
  864. * promiscuous mode, and all-multi behavior.
  865. **/
  866. static void
  867. ixgb_set_multi(struct net_device *netdev)
  868. {
  869. struct ixgb_adapter *adapter = netdev_priv(netdev);
  870. struct ixgb_hw *hw = &adapter->hw;
  871. struct dev_mc_list *mc_ptr;
  872. uint32_t rctl;
  873. int i;
  874. /* Check for Promiscuous and All Multicast modes */
  875. rctl = IXGB_READ_REG(hw, RCTL);
  876. if(netdev->flags & IFF_PROMISC) {
  877. rctl |= (IXGB_RCTL_UPE | IXGB_RCTL_MPE);
  878. } else if(netdev->flags & IFF_ALLMULTI) {
  879. rctl |= IXGB_RCTL_MPE;
  880. rctl &= ~IXGB_RCTL_UPE;
  881. } else {
  882. rctl &= ~(IXGB_RCTL_UPE | IXGB_RCTL_MPE);
  883. }
  884. if(netdev->mc_count > IXGB_MAX_NUM_MULTICAST_ADDRESSES) {
  885. rctl |= IXGB_RCTL_MPE;
  886. IXGB_WRITE_REG(hw, RCTL, rctl);
  887. } else {
  888. uint8_t mta[netdev->mc_count * IXGB_ETH_LENGTH_OF_ADDRESS];
  889. IXGB_WRITE_REG(hw, RCTL, rctl);
  890. for(i = 0, mc_ptr = netdev->mc_list; mc_ptr;
  891. i++, mc_ptr = mc_ptr->next)
  892. memcpy(&mta[i * IXGB_ETH_LENGTH_OF_ADDRESS],
  893. mc_ptr->dmi_addr, IXGB_ETH_LENGTH_OF_ADDRESS);
  894. ixgb_mc_addr_list_update(hw, mta, netdev->mc_count, 0);
  895. }
  896. }
  897. /**
  898. * ixgb_watchdog - Timer Call-back
  899. * @data: pointer to netdev cast into an unsigned long
  900. **/
  901. static void
  902. ixgb_watchdog(unsigned long data)
  903. {
  904. struct ixgb_adapter *adapter = (struct ixgb_adapter *)data;
  905. struct net_device *netdev = adapter->netdev;
  906. struct ixgb_desc_ring *txdr = &adapter->tx_ring;
  907. ixgb_check_for_link(&adapter->hw);
  908. if (ixgb_check_for_bad_link(&adapter->hw)) {
  909. /* force the reset path */
  910. netif_stop_queue(netdev);
  911. }
  912. if(adapter->hw.link_up) {
  913. if(!netif_carrier_ok(netdev)) {
  914. DPRINTK(LINK, INFO,
  915. "NIC Link is Up 10000 Mbps Full Duplex\n");
  916. adapter->link_speed = 10000;
  917. adapter->link_duplex = FULL_DUPLEX;
  918. netif_carrier_on(netdev);
  919. netif_wake_queue(netdev);
  920. }
  921. } else {
  922. if(netif_carrier_ok(netdev)) {
  923. adapter->link_speed = 0;
  924. adapter->link_duplex = 0;
  925. DPRINTK(LINK, INFO, "NIC Link is Down\n");
  926. netif_carrier_off(netdev);
  927. netif_stop_queue(netdev);
  928. }
  929. }
  930. ixgb_update_stats(adapter);
  931. if(!netif_carrier_ok(netdev)) {
  932. if(IXGB_DESC_UNUSED(txdr) + 1 < txdr->count) {
  933. /* We've lost link, so the controller stops DMA,
  934. * but we've got queued Tx work that's never going
  935. * to get done, so reset controller to flush Tx.
  936. * (Do the reset outside of interrupt context). */
  937. schedule_work(&adapter->tx_timeout_task);
  938. }
  939. }
  940. /* Force detection of hung controller every watchdog period */
  941. adapter->detect_tx_hung = TRUE;
  942. /* generate an interrupt to force clean up of any stragglers */
  943. IXGB_WRITE_REG(&adapter->hw, ICS, IXGB_INT_TXDW);
  944. /* Reset the timer */
  945. mod_timer(&adapter->watchdog_timer, jiffies + 2 * HZ);
  946. }
  947. #define IXGB_TX_FLAGS_CSUM 0x00000001
  948. #define IXGB_TX_FLAGS_VLAN 0x00000002
  949. #define IXGB_TX_FLAGS_TSO 0x00000004
  950. static inline int
  951. ixgb_tso(struct ixgb_adapter *adapter, struct sk_buff *skb)
  952. {
  953. #ifdef NETIF_F_TSO
  954. struct ixgb_context_desc *context_desc;
  955. unsigned int i;
  956. uint8_t ipcss, ipcso, tucss, tucso, hdr_len;
  957. uint16_t ipcse, tucse, mss;
  958. int err;
  959. if(likely(skb_shinfo(skb)->tso_size)) {
  960. if (skb_header_cloned(skb)) {
  961. err = pskb_expand_head(skb, 0, 0, GFP_ATOMIC);
  962. if (err)
  963. return err;
  964. }
  965. hdr_len = ((skb->h.raw - skb->data) + (skb->h.th->doff << 2));
  966. mss = skb_shinfo(skb)->tso_size;
  967. skb->nh.iph->tot_len = 0;
  968. skb->nh.iph->check = 0;
  969. skb->h.th->check = ~csum_tcpudp_magic(skb->nh.iph->saddr,
  970. skb->nh.iph->daddr,
  971. 0, IPPROTO_TCP, 0);
  972. ipcss = skb->nh.raw - skb->data;
  973. ipcso = (void *)&(skb->nh.iph->check) - (void *)skb->data;
  974. ipcse = skb->h.raw - skb->data - 1;
  975. tucss = skb->h.raw - skb->data;
  976. tucso = (void *)&(skb->h.th->check) - (void *)skb->data;
  977. tucse = 0;
  978. i = adapter->tx_ring.next_to_use;
  979. context_desc = IXGB_CONTEXT_DESC(adapter->tx_ring, i);
  980. context_desc->ipcss = ipcss;
  981. context_desc->ipcso = ipcso;
  982. context_desc->ipcse = cpu_to_le16(ipcse);
  983. context_desc->tucss = tucss;
  984. context_desc->tucso = tucso;
  985. context_desc->tucse = cpu_to_le16(tucse);
  986. context_desc->mss = cpu_to_le16(mss);
  987. context_desc->hdr_len = hdr_len;
  988. context_desc->status = 0;
  989. context_desc->cmd_type_len = cpu_to_le32(
  990. IXGB_CONTEXT_DESC_TYPE
  991. | IXGB_CONTEXT_DESC_CMD_TSE
  992. | IXGB_CONTEXT_DESC_CMD_IP
  993. | IXGB_CONTEXT_DESC_CMD_TCP
  994. | IXGB_CONTEXT_DESC_CMD_IDE
  995. | (skb->len - (hdr_len)));
  996. if(++i == adapter->tx_ring.count) i = 0;
  997. adapter->tx_ring.next_to_use = i;
  998. return 1;
  999. }
  1000. #endif
  1001. return 0;
  1002. }
  1003. static inline boolean_t
  1004. ixgb_tx_csum(struct ixgb_adapter *adapter, struct sk_buff *skb)
  1005. {
  1006. struct ixgb_context_desc *context_desc;
  1007. unsigned int i;
  1008. uint8_t css, cso;
  1009. if(likely(skb->ip_summed == CHECKSUM_HW)) {
  1010. css = skb->h.raw - skb->data;
  1011. cso = (skb->h.raw + skb->csum) - skb->data;
  1012. i = adapter->tx_ring.next_to_use;
  1013. context_desc = IXGB_CONTEXT_DESC(adapter->tx_ring, i);
  1014. context_desc->tucss = css;
  1015. context_desc->tucso = cso;
  1016. context_desc->tucse = 0;
  1017. /* zero out any previously existing data in one instruction */
  1018. *(uint32_t *)&(context_desc->ipcss) = 0;
  1019. context_desc->status = 0;
  1020. context_desc->hdr_len = 0;
  1021. context_desc->mss = 0;
  1022. context_desc->cmd_type_len =
  1023. cpu_to_le32(IXGB_CONTEXT_DESC_TYPE
  1024. | IXGB_TX_DESC_CMD_IDE);
  1025. if(++i == adapter->tx_ring.count) i = 0;
  1026. adapter->tx_ring.next_to_use = i;
  1027. return TRUE;
  1028. }
  1029. return FALSE;
  1030. }
  1031. #define IXGB_MAX_TXD_PWR 14
  1032. #define IXGB_MAX_DATA_PER_TXD (1<<IXGB_MAX_TXD_PWR)
  1033. static inline int
  1034. ixgb_tx_map(struct ixgb_adapter *adapter, struct sk_buff *skb,
  1035. unsigned int first)
  1036. {
  1037. struct ixgb_desc_ring *tx_ring = &adapter->tx_ring;
  1038. struct ixgb_buffer *buffer_info;
  1039. int len = skb->len;
  1040. unsigned int offset = 0, size, count = 0, i;
  1041. unsigned int mss = skb_shinfo(skb)->tso_size;
  1042. unsigned int nr_frags = skb_shinfo(skb)->nr_frags;
  1043. unsigned int f;
  1044. len -= skb->data_len;
  1045. i = tx_ring->next_to_use;
  1046. while(len) {
  1047. buffer_info = &tx_ring->buffer_info[i];
  1048. size = min(len, IXGB_MAX_JUMBO_FRAME_SIZE);
  1049. /* Workaround for premature desc write-backs
  1050. * in TSO mode. Append 4-byte sentinel desc */
  1051. if(unlikely(mss && !nr_frags && size == len && size > 8))
  1052. size -= 4;
  1053. buffer_info->length = size;
  1054. buffer_info->dma =
  1055. pci_map_single(adapter->pdev,
  1056. skb->data + offset,
  1057. size,
  1058. PCI_DMA_TODEVICE);
  1059. buffer_info->time_stamp = jiffies;
  1060. buffer_info->next_to_watch = 0;
  1061. len -= size;
  1062. offset += size;
  1063. count++;
  1064. if(++i == tx_ring->count) i = 0;
  1065. }
  1066. for(f = 0; f < nr_frags; f++) {
  1067. struct skb_frag_struct *frag;
  1068. frag = &skb_shinfo(skb)->frags[f];
  1069. len = frag->size;
  1070. offset = 0;
  1071. while(len) {
  1072. buffer_info = &tx_ring->buffer_info[i];
  1073. size = min(len, IXGB_MAX_JUMBO_FRAME_SIZE);
  1074. /* Workaround for premature desc write-backs
  1075. * in TSO mode. Append 4-byte sentinel desc */
  1076. if(unlikely(mss && (f == (nr_frags-1)) && (size == len)
  1077. && (size > 8)))
  1078. size -= 4;
  1079. buffer_info->length = size;
  1080. buffer_info->dma =
  1081. pci_map_page(adapter->pdev,
  1082. frag->page,
  1083. frag->page_offset + offset,
  1084. size,
  1085. PCI_DMA_TODEVICE);
  1086. buffer_info->time_stamp = jiffies;
  1087. buffer_info->next_to_watch = 0;
  1088. len -= size;
  1089. offset += size;
  1090. count++;
  1091. if(++i == tx_ring->count) i = 0;
  1092. }
  1093. }
  1094. i = (i == 0) ? tx_ring->count - 1 : i - 1;
  1095. tx_ring->buffer_info[i].skb = skb;
  1096. tx_ring->buffer_info[first].next_to_watch = i;
  1097. return count;
  1098. }
  1099. static inline void
  1100. ixgb_tx_queue(struct ixgb_adapter *adapter, int count, int vlan_id,int tx_flags)
  1101. {
  1102. struct ixgb_desc_ring *tx_ring = &adapter->tx_ring;
  1103. struct ixgb_tx_desc *tx_desc = NULL;
  1104. struct ixgb_buffer *buffer_info;
  1105. uint32_t cmd_type_len = adapter->tx_cmd_type;
  1106. uint8_t status = 0;
  1107. uint8_t popts = 0;
  1108. unsigned int i;
  1109. if(tx_flags & IXGB_TX_FLAGS_TSO) {
  1110. cmd_type_len |= IXGB_TX_DESC_CMD_TSE;
  1111. popts |= (IXGB_TX_DESC_POPTS_IXSM | IXGB_TX_DESC_POPTS_TXSM);
  1112. }
  1113. if(tx_flags & IXGB_TX_FLAGS_CSUM)
  1114. popts |= IXGB_TX_DESC_POPTS_TXSM;
  1115. if(tx_flags & IXGB_TX_FLAGS_VLAN) {
  1116. cmd_type_len |= IXGB_TX_DESC_CMD_VLE;
  1117. }
  1118. i = tx_ring->next_to_use;
  1119. while(count--) {
  1120. buffer_info = &tx_ring->buffer_info[i];
  1121. tx_desc = IXGB_TX_DESC(*tx_ring, i);
  1122. tx_desc->buff_addr = cpu_to_le64(buffer_info->dma);
  1123. tx_desc->cmd_type_len =
  1124. cpu_to_le32(cmd_type_len | buffer_info->length);
  1125. tx_desc->status = status;
  1126. tx_desc->popts = popts;
  1127. tx_desc->vlan = cpu_to_le16(vlan_id);
  1128. if(++i == tx_ring->count) i = 0;
  1129. }
  1130. tx_desc->cmd_type_len |= cpu_to_le32(IXGB_TX_DESC_CMD_EOP
  1131. | IXGB_TX_DESC_CMD_RS );
  1132. /* Force memory writes to complete before letting h/w
  1133. * know there are new descriptors to fetch. (Only
  1134. * applicable for weak-ordered memory model archs,
  1135. * such as IA-64). */
  1136. wmb();
  1137. tx_ring->next_to_use = i;
  1138. IXGB_WRITE_REG(&adapter->hw, TDT, i);
  1139. }
  1140. /* Tx Descriptors needed, worst case */
  1141. #define TXD_USE_COUNT(S) (((S) >> IXGB_MAX_TXD_PWR) + \
  1142. (((S) & (IXGB_MAX_DATA_PER_TXD - 1)) ? 1 : 0))
  1143. #define DESC_NEEDED TXD_USE_COUNT(IXGB_MAX_DATA_PER_TXD) + \
  1144. MAX_SKB_FRAGS * TXD_USE_COUNT(PAGE_SIZE) + 1 \
  1145. /* one more for TSO workaround */ + 1
  1146. static int
  1147. ixgb_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
  1148. {
  1149. struct ixgb_adapter *adapter = netdev_priv(netdev);
  1150. unsigned int first;
  1151. unsigned int tx_flags = 0;
  1152. unsigned long flags;
  1153. int vlan_id = 0;
  1154. int tso;
  1155. if(skb->len <= 0) {
  1156. dev_kfree_skb_any(skb);
  1157. return 0;
  1158. }
  1159. #ifdef NETIF_F_LLTX
  1160. local_irq_save(flags);
  1161. if (!spin_trylock(&adapter->tx_lock)) {
  1162. /* Collision - tell upper layer to requeue */
  1163. local_irq_restore(flags);
  1164. return NETDEV_TX_LOCKED;
  1165. }
  1166. #else
  1167. spin_lock_irqsave(&adapter->tx_lock, flags);
  1168. #endif
  1169. if(unlikely(IXGB_DESC_UNUSED(&adapter->tx_ring) < DESC_NEEDED)) {
  1170. netif_stop_queue(netdev);
  1171. spin_unlock_irqrestore(&adapter->tx_lock, flags);
  1172. return NETDEV_TX_BUSY;
  1173. }
  1174. #ifndef NETIF_F_LLTX
  1175. spin_unlock_irqrestore(&adapter->tx_lock, flags);
  1176. #endif
  1177. if(adapter->vlgrp && vlan_tx_tag_present(skb)) {
  1178. tx_flags |= IXGB_TX_FLAGS_VLAN;
  1179. vlan_id = vlan_tx_tag_get(skb);
  1180. }
  1181. first = adapter->tx_ring.next_to_use;
  1182. tso = ixgb_tso(adapter, skb);
  1183. if (tso < 0) {
  1184. dev_kfree_skb_any(skb);
  1185. #ifdef NETIF_F_LLTX
  1186. spin_unlock_irqrestore(&adapter->tx_lock, flags);
  1187. #endif
  1188. return NETDEV_TX_OK;
  1189. }
  1190. if (likely(tso))
  1191. tx_flags |= IXGB_TX_FLAGS_TSO;
  1192. else if(ixgb_tx_csum(adapter, skb))
  1193. tx_flags |= IXGB_TX_FLAGS_CSUM;
  1194. ixgb_tx_queue(adapter, ixgb_tx_map(adapter, skb, first), vlan_id,
  1195. tx_flags);
  1196. netdev->trans_start = jiffies;
  1197. #ifdef NETIF_F_LLTX
  1198. /* Make sure there is space in the ring for the next send. */
  1199. if(unlikely(IXGB_DESC_UNUSED(&adapter->tx_ring) < DESC_NEEDED))
  1200. netif_stop_queue(netdev);
  1201. spin_unlock_irqrestore(&adapter->tx_lock, flags);
  1202. #endif
  1203. return NETDEV_TX_OK;
  1204. }
  1205. /**
  1206. * ixgb_tx_timeout - Respond to a Tx Hang
  1207. * @netdev: network interface device structure
  1208. **/
  1209. static void
  1210. ixgb_tx_timeout(struct net_device *netdev)
  1211. {
  1212. struct ixgb_adapter *adapter = netdev_priv(netdev);
  1213. /* Do the reset outside of interrupt context */
  1214. schedule_work(&adapter->tx_timeout_task);
  1215. }
  1216. static void
  1217. ixgb_tx_timeout_task(struct net_device *netdev)
  1218. {
  1219. struct ixgb_adapter *adapter = netdev_priv(netdev);
  1220. adapter->tx_timeout_count++;
  1221. ixgb_down(adapter, TRUE);
  1222. ixgb_up(adapter);
  1223. }
  1224. /**
  1225. * ixgb_get_stats - Get System Network Statistics
  1226. * @netdev: network interface device structure
  1227. *
  1228. * Returns the address of the device statistics structure.
  1229. * The statistics are actually updated from the timer callback.
  1230. **/
  1231. static struct net_device_stats *
  1232. ixgb_get_stats(struct net_device *netdev)
  1233. {
  1234. struct ixgb_adapter *adapter = netdev_priv(netdev);
  1235. return &adapter->net_stats;
  1236. }
  1237. /**
  1238. * ixgb_change_mtu - Change the Maximum Transfer Unit
  1239. * @netdev: network interface device structure
  1240. * @new_mtu: new value for maximum frame size
  1241. *
  1242. * Returns 0 on success, negative on failure
  1243. **/
  1244. static int
  1245. ixgb_change_mtu(struct net_device *netdev, int new_mtu)
  1246. {
  1247. struct ixgb_adapter *adapter = netdev_priv(netdev);
  1248. int max_frame = new_mtu + ENET_HEADER_SIZE + ENET_FCS_LENGTH;
  1249. int old_max_frame = netdev->mtu + ENET_HEADER_SIZE + ENET_FCS_LENGTH;
  1250. if((max_frame < IXGB_MIN_ENET_FRAME_SIZE_WITHOUT_FCS + ENET_FCS_LENGTH)
  1251. || (max_frame > IXGB_MAX_JUMBO_FRAME_SIZE + ENET_FCS_LENGTH)) {
  1252. DPRINTK(PROBE, ERR, "Invalid MTU setting %d\n", new_mtu);
  1253. return -EINVAL;
  1254. }
  1255. if((max_frame <= IXGB_MAX_ENET_FRAME_SIZE_WITHOUT_FCS + ENET_FCS_LENGTH)
  1256. || (max_frame <= IXGB_RXBUFFER_2048)) {
  1257. adapter->rx_buffer_len = IXGB_RXBUFFER_2048;
  1258. } else if(max_frame <= IXGB_RXBUFFER_4096) {
  1259. adapter->rx_buffer_len = IXGB_RXBUFFER_4096;
  1260. } else if(max_frame <= IXGB_RXBUFFER_8192) {
  1261. adapter->rx_buffer_len = IXGB_RXBUFFER_8192;
  1262. } else {
  1263. adapter->rx_buffer_len = IXGB_RXBUFFER_16384;
  1264. }
  1265. netdev->mtu = new_mtu;
  1266. if(old_max_frame != max_frame && netif_running(netdev)) {
  1267. ixgb_down(adapter, TRUE);
  1268. ixgb_up(adapter);
  1269. }
  1270. return 0;
  1271. }
  1272. /**
  1273. * ixgb_update_stats - Update the board statistics counters.
  1274. * @adapter: board private structure
  1275. **/
  1276. void
  1277. ixgb_update_stats(struct ixgb_adapter *adapter)
  1278. {
  1279. struct net_device *netdev = adapter->netdev;
  1280. if((netdev->flags & IFF_PROMISC) || (netdev->flags & IFF_ALLMULTI) ||
  1281. (netdev->mc_count > IXGB_MAX_NUM_MULTICAST_ADDRESSES)) {
  1282. u64 multi = IXGB_READ_REG(&adapter->hw, MPRCL);
  1283. u32 bcast_l = IXGB_READ_REG(&adapter->hw, BPRCL);
  1284. u32 bcast_h = IXGB_READ_REG(&adapter->hw, BPRCH);
  1285. u64 bcast = ((u64)bcast_h << 32) | bcast_l;
  1286. multi |= ((u64)IXGB_READ_REG(&adapter->hw, MPRCH) << 32);
  1287. /* fix up multicast stats by removing broadcasts */
  1288. if(multi >= bcast)
  1289. multi -= bcast;
  1290. adapter->stats.mprcl += (multi & 0xFFFFFFFF);
  1291. adapter->stats.mprch += (multi >> 32);
  1292. adapter->stats.bprcl += bcast_l;
  1293. adapter->stats.bprch += bcast_h;
  1294. } else {
  1295. adapter->stats.mprcl += IXGB_READ_REG(&adapter->hw, MPRCL);
  1296. adapter->stats.mprch += IXGB_READ_REG(&adapter->hw, MPRCH);
  1297. adapter->stats.bprcl += IXGB_READ_REG(&adapter->hw, BPRCL);
  1298. adapter->stats.bprch += IXGB_READ_REG(&adapter->hw, BPRCH);
  1299. }
  1300. adapter->stats.tprl += IXGB_READ_REG(&adapter->hw, TPRL);
  1301. adapter->stats.tprh += IXGB_READ_REG(&adapter->hw, TPRH);
  1302. adapter->stats.gprcl += IXGB_READ_REG(&adapter->hw, GPRCL);
  1303. adapter->stats.gprch += IXGB_READ_REG(&adapter->hw, GPRCH);
  1304. adapter->stats.uprcl += IXGB_READ_REG(&adapter->hw, UPRCL);
  1305. adapter->stats.uprch += IXGB_READ_REG(&adapter->hw, UPRCH);
  1306. adapter->stats.vprcl += IXGB_READ_REG(&adapter->hw, VPRCL);
  1307. adapter->stats.vprch += IXGB_READ_REG(&adapter->hw, VPRCH);
  1308. adapter->stats.jprcl += IXGB_READ_REG(&adapter->hw, JPRCL);
  1309. adapter->stats.jprch += IXGB_READ_REG(&adapter->hw, JPRCH);
  1310. adapter->stats.gorcl += IXGB_READ_REG(&adapter->hw, GORCL);
  1311. adapter->stats.gorch += IXGB_READ_REG(&adapter->hw, GORCH);
  1312. adapter->stats.torl += IXGB_READ_REG(&adapter->hw, TORL);
  1313. adapter->stats.torh += IXGB_READ_REG(&adapter->hw, TORH);
  1314. adapter->stats.rnbc += IXGB_READ_REG(&adapter->hw, RNBC);
  1315. adapter->stats.ruc += IXGB_READ_REG(&adapter->hw, RUC);
  1316. adapter->stats.roc += IXGB_READ_REG(&adapter->hw, ROC);
  1317. adapter->stats.rlec += IXGB_READ_REG(&adapter->hw, RLEC);
  1318. adapter->stats.crcerrs += IXGB_READ_REG(&adapter->hw, CRCERRS);
  1319. adapter->stats.icbc += IXGB_READ_REG(&adapter->hw, ICBC);
  1320. adapter->stats.ecbc += IXGB_READ_REG(&adapter->hw, ECBC);
  1321. adapter->stats.mpc += IXGB_READ_REG(&adapter->hw, MPC);
  1322. adapter->stats.tptl += IXGB_READ_REG(&adapter->hw, TPTL);
  1323. adapter->stats.tpth += IXGB_READ_REG(&adapter->hw, TPTH);
  1324. adapter->stats.gptcl += IXGB_READ_REG(&adapter->hw, GPTCL);
  1325. adapter->stats.gptch += IXGB_READ_REG(&adapter->hw, GPTCH);
  1326. adapter->stats.bptcl += IXGB_READ_REG(&adapter->hw, BPTCL);
  1327. adapter->stats.bptch += IXGB_READ_REG(&adapter->hw, BPTCH);
  1328. adapter->stats.mptcl += IXGB_READ_REG(&adapter->hw, MPTCL);
  1329. adapter->stats.mptch += IXGB_READ_REG(&adapter->hw, MPTCH);
  1330. adapter->stats.uptcl += IXGB_READ_REG(&adapter->hw, UPTCL);
  1331. adapter->stats.uptch += IXGB_READ_REG(&adapter->hw, UPTCH);
  1332. adapter->stats.vptcl += IXGB_READ_REG(&adapter->hw, VPTCL);
  1333. adapter->stats.vptch += IXGB_READ_REG(&adapter->hw, VPTCH);
  1334. adapter->stats.jptcl += IXGB_READ_REG(&adapter->hw, JPTCL);
  1335. adapter->stats.jptch += IXGB_READ_REG(&adapter->hw, JPTCH);
  1336. adapter->stats.gotcl += IXGB_READ_REG(&adapter->hw, GOTCL);
  1337. adapter->stats.gotch += IXGB_READ_REG(&adapter->hw, GOTCH);
  1338. adapter->stats.totl += IXGB_READ_REG(&adapter->hw, TOTL);
  1339. adapter->stats.toth += IXGB_READ_REG(&adapter->hw, TOTH);
  1340. adapter->stats.dc += IXGB_READ_REG(&adapter->hw, DC);
  1341. adapter->stats.plt64c += IXGB_READ_REG(&adapter->hw, PLT64C);
  1342. adapter->stats.tsctc += IXGB_READ_REG(&adapter->hw, TSCTC);
  1343. adapter->stats.tsctfc += IXGB_READ_REG(&adapter->hw, TSCTFC);
  1344. adapter->stats.ibic += IXGB_READ_REG(&adapter->hw, IBIC);
  1345. adapter->stats.rfc += IXGB_READ_REG(&adapter->hw, RFC);
  1346. adapter->stats.lfc += IXGB_READ_REG(&adapter->hw, LFC);
  1347. adapter->stats.pfrc += IXGB_READ_REG(&adapter->hw, PFRC);
  1348. adapter->stats.pftc += IXGB_READ_REG(&adapter->hw, PFTC);
  1349. adapter->stats.mcfrc += IXGB_READ_REG(&adapter->hw, MCFRC);
  1350. adapter->stats.mcftc += IXGB_READ_REG(&adapter->hw, MCFTC);
  1351. adapter->stats.xonrxc += IXGB_READ_REG(&adapter->hw, XONRXC);
  1352. adapter->stats.xontxc += IXGB_READ_REG(&adapter->hw, XONTXC);
  1353. adapter->stats.xoffrxc += IXGB_READ_REG(&adapter->hw, XOFFRXC);
  1354. adapter->stats.xofftxc += IXGB_READ_REG(&adapter->hw, XOFFTXC);
  1355. adapter->stats.rjc += IXGB_READ_REG(&adapter->hw, RJC);
  1356. /* Fill out the OS statistics structure */
  1357. adapter->net_stats.rx_packets = adapter->stats.gprcl;
  1358. adapter->net_stats.tx_packets = adapter->stats.gptcl;
  1359. adapter->net_stats.rx_bytes = adapter->stats.gorcl;
  1360. adapter->net_stats.tx_bytes = adapter->stats.gotcl;
  1361. adapter->net_stats.multicast = adapter->stats.mprcl;
  1362. adapter->net_stats.collisions = 0;
  1363. /* ignore RLEC as it reports errors for padded (<64bytes) frames
  1364. * with a length in the type/len field */
  1365. adapter->net_stats.rx_errors =
  1366. /* adapter->stats.rnbc + */ adapter->stats.crcerrs +
  1367. adapter->stats.ruc +
  1368. adapter->stats.roc /*+ adapter->stats.rlec */ +
  1369. adapter->stats.icbc +
  1370. adapter->stats.ecbc + adapter->stats.mpc;
  1371. /* see above
  1372. * adapter->net_stats.rx_length_errors = adapter->stats.rlec;
  1373. */
  1374. adapter->net_stats.rx_crc_errors = adapter->stats.crcerrs;
  1375. adapter->net_stats.rx_fifo_errors = adapter->stats.mpc;
  1376. adapter->net_stats.rx_missed_errors = adapter->stats.mpc;
  1377. adapter->net_stats.rx_over_errors = adapter->stats.mpc;
  1378. adapter->net_stats.tx_errors = 0;
  1379. adapter->net_stats.rx_frame_errors = 0;
  1380. adapter->net_stats.tx_aborted_errors = 0;
  1381. adapter->net_stats.tx_carrier_errors = 0;
  1382. adapter->net_stats.tx_fifo_errors = 0;
  1383. adapter->net_stats.tx_heartbeat_errors = 0;
  1384. adapter->net_stats.tx_window_errors = 0;
  1385. }
  1386. #define IXGB_MAX_INTR 10
  1387. /**
  1388. * ixgb_intr - Interrupt Handler
  1389. * @irq: interrupt number
  1390. * @data: pointer to a network interface device structure
  1391. * @pt_regs: CPU registers structure
  1392. **/
  1393. static irqreturn_t
  1394. ixgb_intr(int irq, void *data, struct pt_regs *regs)
  1395. {
  1396. struct net_device *netdev = data;
  1397. struct ixgb_adapter *adapter = netdev_priv(netdev);
  1398. struct ixgb_hw *hw = &adapter->hw;
  1399. uint32_t icr = IXGB_READ_REG(hw, ICR);
  1400. #ifndef CONFIG_IXGB_NAPI
  1401. unsigned int i;
  1402. #endif
  1403. if(unlikely(!icr))
  1404. return IRQ_NONE; /* Not our interrupt */
  1405. if(unlikely(icr & (IXGB_INT_RXSEQ | IXGB_INT_LSC))) {
  1406. mod_timer(&adapter->watchdog_timer, jiffies);
  1407. }
  1408. #ifdef CONFIG_IXGB_NAPI
  1409. if(netif_rx_schedule_prep(netdev)) {
  1410. /* Disable interrupts and register for poll. The flush
  1411. of the posted write is intentionally left out.
  1412. */
  1413. atomic_inc(&adapter->irq_sem);
  1414. IXGB_WRITE_REG(&adapter->hw, IMC, ~0);
  1415. __netif_rx_schedule(netdev);
  1416. }
  1417. #else
  1418. /* yes, that is actually a & and it is meant to make sure that
  1419. * every pass through this for loop checks both receive and
  1420. * transmit queues for completed descriptors, intended to
  1421. * avoid starvation issues and assist tx/rx fairness. */
  1422. for(i = 0; i < IXGB_MAX_INTR; i++)
  1423. if(!ixgb_clean_rx_irq(adapter) &
  1424. !ixgb_clean_tx_irq(adapter))
  1425. break;
  1426. #endif
  1427. return IRQ_HANDLED;
  1428. }
  1429. #ifdef CONFIG_IXGB_NAPI
  1430. /**
  1431. * ixgb_clean - NAPI Rx polling callback
  1432. * @adapter: board private structure
  1433. **/
  1434. static int
  1435. ixgb_clean(struct net_device *netdev, int *budget)
  1436. {
  1437. struct ixgb_adapter *adapter = netdev_priv(netdev);
  1438. int work_to_do = min(*budget, netdev->quota);
  1439. int tx_cleaned;
  1440. int work_done = 0;
  1441. tx_cleaned = ixgb_clean_tx_irq(adapter);
  1442. ixgb_clean_rx_irq(adapter, &work_done, work_to_do);
  1443. *budget -= work_done;
  1444. netdev->quota -= work_done;
  1445. /* if no Tx and not enough Rx work done, exit the polling mode */
  1446. if((!tx_cleaned && (work_done == 0)) || !netif_running(netdev)) {
  1447. netif_rx_complete(netdev);
  1448. ixgb_irq_enable(adapter);
  1449. return 0;
  1450. }
  1451. return 1;
  1452. }
  1453. #endif
  1454. /**
  1455. * ixgb_clean_tx_irq - Reclaim resources after transmit completes
  1456. * @adapter: board private structure
  1457. **/
  1458. static boolean_t
  1459. ixgb_clean_tx_irq(struct ixgb_adapter *adapter)
  1460. {
  1461. struct ixgb_desc_ring *tx_ring = &adapter->tx_ring;
  1462. struct net_device *netdev = adapter->netdev;
  1463. struct ixgb_tx_desc *tx_desc, *eop_desc;
  1464. struct ixgb_buffer *buffer_info;
  1465. unsigned int i, eop;
  1466. boolean_t cleaned = FALSE;
  1467. i = tx_ring->next_to_clean;
  1468. eop = tx_ring->buffer_info[i].next_to_watch;
  1469. eop_desc = IXGB_TX_DESC(*tx_ring, eop);
  1470. while(eop_desc->status & IXGB_TX_DESC_STATUS_DD) {
  1471. for(cleaned = FALSE; !cleaned; ) {
  1472. tx_desc = IXGB_TX_DESC(*tx_ring, i);
  1473. buffer_info = &tx_ring->buffer_info[i];
  1474. if (tx_desc->popts
  1475. & (IXGB_TX_DESC_POPTS_TXSM |
  1476. IXGB_TX_DESC_POPTS_IXSM))
  1477. adapter->hw_csum_tx_good++;
  1478. ixgb_unmap_and_free_tx_resource(adapter, buffer_info);
  1479. *(uint32_t *)&(tx_desc->status) = 0;
  1480. cleaned = (i == eop);
  1481. if(++i == tx_ring->count) i = 0;
  1482. }
  1483. eop = tx_ring->buffer_info[i].next_to_watch;
  1484. eop_desc = IXGB_TX_DESC(*tx_ring, eop);
  1485. }
  1486. tx_ring->next_to_clean = i;
  1487. spin_lock(&adapter->tx_lock);
  1488. if(cleaned && netif_queue_stopped(netdev) && netif_carrier_ok(netdev) &&
  1489. (IXGB_DESC_UNUSED(tx_ring) > IXGB_TX_QUEUE_WAKE)) {
  1490. netif_wake_queue(netdev);
  1491. }
  1492. spin_unlock(&adapter->tx_lock);
  1493. if(adapter->detect_tx_hung) {
  1494. /* detect a transmit hang in hardware, this serializes the
  1495. * check with the clearing of time_stamp and movement of i */
  1496. adapter->detect_tx_hung = FALSE;
  1497. if (tx_ring->buffer_info[eop].dma &&
  1498. time_after(jiffies, tx_ring->buffer_info[eop].time_stamp + HZ)
  1499. && !(IXGB_READ_REG(&adapter->hw, STATUS) &
  1500. IXGB_STATUS_TXOFF)) {
  1501. /* detected Tx unit hang */
  1502. DPRINTK(DRV, ERR, "Detected Tx Unit Hang\n"
  1503. " TDH <%x>\n"
  1504. " TDT <%x>\n"
  1505. " next_to_use <%x>\n"
  1506. " next_to_clean <%x>\n"
  1507. "buffer_info[next_to_clean]\n"
  1508. " time_stamp <%lx>\n"
  1509. " next_to_watch <%x>\n"
  1510. " jiffies <%lx>\n"
  1511. " next_to_watch.status <%x>\n",
  1512. IXGB_READ_REG(&adapter->hw, TDH),
  1513. IXGB_READ_REG(&adapter->hw, TDT),
  1514. tx_ring->next_to_use,
  1515. tx_ring->next_to_clean,
  1516. tx_ring->buffer_info[eop].time_stamp,
  1517. eop,
  1518. jiffies,
  1519. eop_desc->status);
  1520. netif_stop_queue(netdev);
  1521. }
  1522. }
  1523. return cleaned;
  1524. }
  1525. /**
  1526. * ixgb_rx_checksum - Receive Checksum Offload for 82597.
  1527. * @adapter: board private structure
  1528. * @rx_desc: receive descriptor
  1529. * @sk_buff: socket buffer with received data
  1530. **/
  1531. static inline void
  1532. ixgb_rx_checksum(struct ixgb_adapter *adapter,
  1533. struct ixgb_rx_desc *rx_desc,
  1534. struct sk_buff *skb)
  1535. {
  1536. /* Ignore Checksum bit is set OR
  1537. * TCP Checksum has not been calculated
  1538. */
  1539. if((rx_desc->status & IXGB_RX_DESC_STATUS_IXSM) ||
  1540. (!(rx_desc->status & IXGB_RX_DESC_STATUS_TCPCS))) {
  1541. skb->ip_summed = CHECKSUM_NONE;
  1542. return;
  1543. }
  1544. /* At this point we know the hardware did the TCP checksum */
  1545. /* now look at the TCP checksum error bit */
  1546. if(rx_desc->errors & IXGB_RX_DESC_ERRORS_TCPE) {
  1547. /* let the stack verify checksum errors */
  1548. skb->ip_summed = CHECKSUM_NONE;
  1549. adapter->hw_csum_rx_error++;
  1550. } else {
  1551. /* TCP checksum is good */
  1552. skb->ip_summed = CHECKSUM_UNNECESSARY;
  1553. adapter->hw_csum_rx_good++;
  1554. }
  1555. }
  1556. /**
  1557. * ixgb_clean_rx_irq - Send received data up the network stack,
  1558. * @adapter: board private structure
  1559. **/
  1560. static boolean_t
  1561. #ifdef CONFIG_IXGB_NAPI
  1562. ixgb_clean_rx_irq(struct ixgb_adapter *adapter, int *work_done, int work_to_do)
  1563. #else
  1564. ixgb_clean_rx_irq(struct ixgb_adapter *adapter)
  1565. #endif
  1566. {
  1567. struct ixgb_desc_ring *rx_ring = &adapter->rx_ring;
  1568. struct net_device *netdev = adapter->netdev;
  1569. struct pci_dev *pdev = adapter->pdev;
  1570. struct ixgb_rx_desc *rx_desc, *next_rxd;
  1571. struct ixgb_buffer *buffer_info, *next_buffer, *next2_buffer;
  1572. uint32_t length;
  1573. unsigned int i, j;
  1574. boolean_t cleaned = FALSE;
  1575. i = rx_ring->next_to_clean;
  1576. rx_desc = IXGB_RX_DESC(*rx_ring, i);
  1577. buffer_info = &rx_ring->buffer_info[i];
  1578. while(rx_desc->status & IXGB_RX_DESC_STATUS_DD) {
  1579. struct sk_buff *skb, *next_skb;
  1580. u8 status;
  1581. #ifdef CONFIG_IXGB_NAPI
  1582. if(*work_done >= work_to_do)
  1583. break;
  1584. (*work_done)++;
  1585. #endif
  1586. status = rx_desc->status;
  1587. skb = buffer_info->skb;
  1588. buffer_info->skb = NULL;
  1589. prefetch(skb->data);
  1590. if(++i == rx_ring->count) i = 0;
  1591. next_rxd = IXGB_RX_DESC(*rx_ring, i);
  1592. prefetch(next_rxd);
  1593. if((j = i + 1) == rx_ring->count) j = 0;
  1594. next2_buffer = &rx_ring->buffer_info[j];
  1595. prefetch(next2_buffer);
  1596. next_buffer = &rx_ring->buffer_info[i];
  1597. next_skb = next_buffer->skb;
  1598. prefetch(next_skb);
  1599. cleaned = TRUE;
  1600. pci_unmap_single(pdev,
  1601. buffer_info->dma,
  1602. buffer_info->length,
  1603. PCI_DMA_FROMDEVICE);
  1604. length = le16_to_cpu(rx_desc->length);
  1605. if(unlikely(!(status & IXGB_RX_DESC_STATUS_EOP))) {
  1606. /* All receives must fit into a single buffer */
  1607. IXGB_DBG("Receive packet consumed multiple buffers "
  1608. "length<%x>\n", length);
  1609. dev_kfree_skb_irq(skb);
  1610. goto rxdesc_done;
  1611. }
  1612. if (unlikely(rx_desc->errors
  1613. & (IXGB_RX_DESC_ERRORS_CE | IXGB_RX_DESC_ERRORS_SE
  1614. | IXGB_RX_DESC_ERRORS_P |
  1615. IXGB_RX_DESC_ERRORS_RXE))) {
  1616. dev_kfree_skb_irq(skb);
  1617. goto rxdesc_done;
  1618. }
  1619. /* code added for copybreak, this should improve
  1620. * performance for small packets with large amounts
  1621. * of reassembly being done in the stack */
  1622. #define IXGB_CB_LENGTH 256
  1623. if (length < IXGB_CB_LENGTH) {
  1624. struct sk_buff *new_skb =
  1625. dev_alloc_skb(length + NET_IP_ALIGN);
  1626. if (new_skb) {
  1627. skb_reserve(new_skb, NET_IP_ALIGN);
  1628. new_skb->dev = netdev;
  1629. memcpy(new_skb->data - NET_IP_ALIGN,
  1630. skb->data - NET_IP_ALIGN,
  1631. length + NET_IP_ALIGN);
  1632. /* save the skb in buffer_info as good */
  1633. buffer_info->skb = skb;
  1634. skb = new_skb;
  1635. }
  1636. }
  1637. /* end copybreak code */
  1638. /* Good Receive */
  1639. skb_put(skb, length);
  1640. /* Receive Checksum Offload */
  1641. ixgb_rx_checksum(adapter, rx_desc, skb);
  1642. skb->protocol = eth_type_trans(skb, netdev);
  1643. #ifdef CONFIG_IXGB_NAPI
  1644. if(adapter->vlgrp && (status & IXGB_RX_DESC_STATUS_VP)) {
  1645. vlan_hwaccel_receive_skb(skb, adapter->vlgrp,
  1646. le16_to_cpu(rx_desc->special) &
  1647. IXGB_RX_DESC_SPECIAL_VLAN_MASK);
  1648. } else {
  1649. netif_receive_skb(skb);
  1650. }
  1651. #else /* CONFIG_IXGB_NAPI */
  1652. if(adapter->vlgrp && (status & IXGB_RX_DESC_STATUS_VP)) {
  1653. vlan_hwaccel_rx(skb, adapter->vlgrp,
  1654. le16_to_cpu(rx_desc->special) &
  1655. IXGB_RX_DESC_SPECIAL_VLAN_MASK);
  1656. } else {
  1657. netif_rx(skb);
  1658. }
  1659. #endif /* CONFIG_IXGB_NAPI */
  1660. netdev->last_rx = jiffies;
  1661. rxdesc_done:
  1662. /* clean up descriptor, might be written over by hw */
  1663. rx_desc->status = 0;
  1664. /* use prefetched values */
  1665. rx_desc = next_rxd;
  1666. buffer_info = next_buffer;
  1667. }
  1668. rx_ring->next_to_clean = i;
  1669. ixgb_alloc_rx_buffers(adapter);
  1670. return cleaned;
  1671. }
  1672. /**
  1673. * ixgb_alloc_rx_buffers - Replace used receive buffers
  1674. * @adapter: address of board private structure
  1675. **/
  1676. static void
  1677. ixgb_alloc_rx_buffers(struct ixgb_adapter *adapter)
  1678. {
  1679. struct ixgb_desc_ring *rx_ring = &adapter->rx_ring;
  1680. struct net_device *netdev = adapter->netdev;
  1681. struct pci_dev *pdev = adapter->pdev;
  1682. struct ixgb_rx_desc *rx_desc;
  1683. struct ixgb_buffer *buffer_info;
  1684. struct sk_buff *skb;
  1685. unsigned int i;
  1686. int num_group_tail_writes;
  1687. long cleancount;
  1688. i = rx_ring->next_to_use;
  1689. buffer_info = &rx_ring->buffer_info[i];
  1690. cleancount = IXGB_DESC_UNUSED(rx_ring);
  1691. num_group_tail_writes = IXGB_RX_BUFFER_WRITE;
  1692. /* leave three descriptors unused */
  1693. while(--cleancount > 2) {
  1694. /* recycle! its good for you */
  1695. if (!(skb = buffer_info->skb))
  1696. skb = dev_alloc_skb(adapter->rx_buffer_len
  1697. + NET_IP_ALIGN);
  1698. else {
  1699. skb_trim(skb, 0);
  1700. goto map_skb;
  1701. }
  1702. if (unlikely(!skb)) {
  1703. /* Better luck next round */
  1704. adapter->alloc_rx_buff_failed++;
  1705. break;
  1706. }
  1707. /* Make buffer alignment 2 beyond a 16 byte boundary
  1708. * this will result in a 16 byte aligned IP header after
  1709. * the 14 byte MAC header is removed
  1710. */
  1711. skb_reserve(skb, NET_IP_ALIGN);
  1712. skb->dev = netdev;
  1713. buffer_info->skb = skb;
  1714. buffer_info->length = adapter->rx_buffer_len;
  1715. map_skb:
  1716. buffer_info->dma = pci_map_single(pdev,
  1717. skb->data,
  1718. adapter->rx_buffer_len,
  1719. PCI_DMA_FROMDEVICE);
  1720. rx_desc = IXGB_RX_DESC(*rx_ring, i);
  1721. rx_desc->buff_addr = cpu_to_le64(buffer_info->dma);
  1722. /* guarantee DD bit not set now before h/w gets descriptor
  1723. * this is the rest of the workaround for h/w double
  1724. * writeback. */
  1725. rx_desc->status = 0;
  1726. if(++i == rx_ring->count) i = 0;
  1727. buffer_info = &rx_ring->buffer_info[i];
  1728. }
  1729. if (likely(rx_ring->next_to_use != i)) {
  1730. rx_ring->next_to_use = i;
  1731. if (unlikely(i-- == 0))
  1732. i = (rx_ring->count - 1);
  1733. /* Force memory writes to complete before letting h/w
  1734. * know there are new descriptors to fetch. (Only
  1735. * applicable for weak-ordered memory model archs, such
  1736. * as IA-64). */
  1737. wmb();
  1738. IXGB_WRITE_REG(&adapter->hw, RDT, i);
  1739. }
  1740. }
  1741. /**
  1742. * ixgb_vlan_rx_register - enables or disables vlan tagging/stripping.
  1743. *
  1744. * @param netdev network interface device structure
  1745. * @param grp indicates to enable or disable tagging/stripping
  1746. **/
  1747. static void
  1748. ixgb_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp)
  1749. {
  1750. struct ixgb_adapter *adapter = netdev_priv(netdev);
  1751. uint32_t ctrl, rctl;
  1752. ixgb_irq_disable(adapter);
  1753. adapter->vlgrp = grp;
  1754. if(grp) {
  1755. /* enable VLAN tag insert/strip */
  1756. ctrl = IXGB_READ_REG(&adapter->hw, CTRL0);
  1757. ctrl |= IXGB_CTRL0_VME;
  1758. IXGB_WRITE_REG(&adapter->hw, CTRL0, ctrl);
  1759. /* enable VLAN receive filtering */
  1760. rctl = IXGB_READ_REG(&adapter->hw, RCTL);
  1761. rctl |= IXGB_RCTL_VFE;
  1762. rctl &= ~IXGB_RCTL_CFIEN;
  1763. IXGB_WRITE_REG(&adapter->hw, RCTL, rctl);
  1764. } else {
  1765. /* disable VLAN tag insert/strip */
  1766. ctrl = IXGB_READ_REG(&adapter->hw, CTRL0);
  1767. ctrl &= ~IXGB_CTRL0_VME;
  1768. IXGB_WRITE_REG(&adapter->hw, CTRL0, ctrl);
  1769. /* disable VLAN filtering */
  1770. rctl = IXGB_READ_REG(&adapter->hw, RCTL);
  1771. rctl &= ~IXGB_RCTL_VFE;
  1772. IXGB_WRITE_REG(&adapter->hw, RCTL, rctl);
  1773. }
  1774. ixgb_irq_enable(adapter);
  1775. }
  1776. static void
  1777. ixgb_vlan_rx_add_vid(struct net_device *netdev, uint16_t vid)
  1778. {
  1779. struct ixgb_adapter *adapter = netdev_priv(netdev);
  1780. uint32_t vfta, index;
  1781. /* add VID to filter table */
  1782. index = (vid >> 5) & 0x7F;
  1783. vfta = IXGB_READ_REG_ARRAY(&adapter->hw, VFTA, index);
  1784. vfta |= (1 << (vid & 0x1F));
  1785. ixgb_write_vfta(&adapter->hw, index, vfta);
  1786. }
  1787. static void
  1788. ixgb_vlan_rx_kill_vid(struct net_device *netdev, uint16_t vid)
  1789. {
  1790. struct ixgb_adapter *adapter = netdev_priv(netdev);
  1791. uint32_t vfta, index;
  1792. ixgb_irq_disable(adapter);
  1793. if(adapter->vlgrp)
  1794. adapter->vlgrp->vlan_devices[vid] = NULL;
  1795. ixgb_irq_enable(adapter);
  1796. /* remove VID from filter table*/
  1797. index = (vid >> 5) & 0x7F;
  1798. vfta = IXGB_READ_REG_ARRAY(&adapter->hw, VFTA, index);
  1799. vfta &= ~(1 << (vid & 0x1F));
  1800. ixgb_write_vfta(&adapter->hw, index, vfta);
  1801. }
  1802. static void
  1803. ixgb_restore_vlan(struct ixgb_adapter *adapter)
  1804. {
  1805. ixgb_vlan_rx_register(adapter->netdev, adapter->vlgrp);
  1806. if(adapter->vlgrp) {
  1807. uint16_t vid;
  1808. for(vid = 0; vid < VLAN_GROUP_ARRAY_LEN; vid++) {
  1809. if(!adapter->vlgrp->vlan_devices[vid])
  1810. continue;
  1811. ixgb_vlan_rx_add_vid(adapter->netdev, vid);
  1812. }
  1813. }
  1814. }
  1815. #ifdef CONFIG_NET_POLL_CONTROLLER
  1816. /*
  1817. * Polling 'interrupt' - used by things like netconsole to send skbs
  1818. * without having to re-enable interrupts. It's not called while
  1819. * the interrupt routine is executing.
  1820. */
  1821. static void ixgb_netpoll(struct net_device *dev)
  1822. {
  1823. struct ixgb_adapter *adapter = dev->priv;
  1824. disable_irq(adapter->pdev->irq);
  1825. ixgb_intr(adapter->pdev->irq, dev, NULL);
  1826. enable_irq(adapter->pdev->irq);
  1827. }
  1828. #endif
  1829. /* ixgb_main.c */