efx.c 33 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /****************************************************************************
  3. * Driver for Solarflare network controllers and boards
  4. * Copyright 2005-2006 Fen Systems Ltd.
  5. * Copyright 2005-2013 Solarflare Communications Inc.
  6. */
  7. #include <linux/filter.h>
  8. #include <linux/module.h>
  9. #include <linux/pci.h>
  10. #include <linux/netdevice.h>
  11. #include <linux/etherdevice.h>
  12. #include <linux/delay.h>
  13. #include <linux/notifier.h>
  14. #include <linux/ip.h>
  15. #include <linux/tcp.h>
  16. #include <linux/in.h>
  17. #include <linux/ethtool.h>
  18. #include <linux/topology.h>
  19. #include <linux/gfp.h>
  20. #include <linux/aer.h>
  21. #include <linux/interrupt.h>
  22. #include "net_driver.h"
  23. #include <net/gre.h>
  24. #include <net/udp_tunnel.h>
  25. #include "efx.h"
  26. #include "efx_common.h"
  27. #include "efx_channels.h"
  28. #include "rx_common.h"
  29. #include "tx_common.h"
  30. #include "nic.h"
  31. #include "io.h"
  32. #include "selftest.h"
  33. #include "sriov.h"
  34. #ifdef CONFIG_SFC_SIENA_SRIOV
  35. #include "siena_sriov.h"
  36. #endif
  37. #include "mcdi_port_common.h"
  38. #include "mcdi_pcol.h"
  39. #include "workarounds.h"
  40. /**************************************************************************
  41. *
  42. * Configurable values
  43. *
  44. *************************************************************************/
  45. module_param_named(interrupt_mode, efx_siena_interrupt_mode, uint, 0444);
  46. MODULE_PARM_DESC(interrupt_mode,
  47. "Interrupt mode (0=>MSIX 1=>MSI 2=>legacy)");
  48. module_param_named(rss_cpus, efx_siena_rss_cpus, uint, 0444);
  49. MODULE_PARM_DESC(rss_cpus, "Number of CPUs to use for Receive-Side Scaling");
  50. /*
  51. * Use separate channels for TX and RX events
  52. *
  53. * Set this to 1 to use separate channels for TX and RX. It allows us
  54. * to control interrupt affinity separately for TX and RX.
  55. *
  56. * This is only used in MSI-X interrupt mode
  57. */
  58. bool efx_siena_separate_tx_channels;
  59. module_param_named(efx_separate_tx_channels, efx_siena_separate_tx_channels,
  60. bool, 0444);
  61. MODULE_PARM_DESC(efx_separate_tx_channels,
  62. "Use separate channels for TX and RX");
  63. /* Initial interrupt moderation settings. They can be modified after
  64. * module load with ethtool.
  65. *
  66. * The default for RX should strike a balance between increasing the
  67. * round-trip latency and reducing overhead.
  68. */
  69. static unsigned int rx_irq_mod_usec = 60;
  70. /* Initial interrupt moderation settings. They can be modified after
  71. * module load with ethtool.
  72. *
  73. * This default is chosen to ensure that a 10G link does not go idle
  74. * while a TX queue is stopped after it has become full. A queue is
  75. * restarted when it drops below half full. The time this takes (assuming
  76. * worst case 3 descriptors per packet and 1024 descriptors) is
  77. * 512 / 3 * 1.2 = 205 usec.
  78. */
  79. static unsigned int tx_irq_mod_usec = 150;
  80. static bool phy_flash_cfg;
  81. module_param(phy_flash_cfg, bool, 0644);
  82. MODULE_PARM_DESC(phy_flash_cfg, "Set PHYs into reflash mode initially");
  83. static unsigned debug = (NETIF_MSG_DRV | NETIF_MSG_PROBE |
  84. NETIF_MSG_LINK | NETIF_MSG_IFDOWN |
  85. NETIF_MSG_IFUP | NETIF_MSG_RX_ERR |
  86. NETIF_MSG_TX_ERR | NETIF_MSG_HW);
  87. module_param(debug, uint, 0);
  88. MODULE_PARM_DESC(debug, "Bitmapped debugging message enable value");
  89. /**************************************************************************
  90. *
  91. * Utility functions and prototypes
  92. *
  93. *************************************************************************/
  94. static void efx_remove_port(struct efx_nic *efx);
  95. static int efx_xdp_setup_prog(struct efx_nic *efx, struct bpf_prog *prog);
  96. static int efx_xdp(struct net_device *dev, struct netdev_bpf *xdp);
  97. static int efx_xdp_xmit(struct net_device *dev, int n, struct xdp_frame **xdpfs,
  98. u32 flags);
  99. #define EFX_ASSERT_RESET_SERIALISED(efx) \
  100. do { \
  101. if ((efx->state == STATE_READY) || \
  102. (efx->state == STATE_RECOVERY) || \
  103. (efx->state == STATE_DISABLED)) \
  104. ASSERT_RTNL(); \
  105. } while (0)
  106. /**************************************************************************
  107. *
  108. * Port handling
  109. *
  110. **************************************************************************/
  111. static void efx_fini_port(struct efx_nic *efx);
  112. static int efx_probe_port(struct efx_nic *efx)
  113. {
  114. int rc;
  115. netif_dbg(efx, probe, efx->net_dev, "create port\n");
  116. if (phy_flash_cfg)
  117. efx->phy_mode = PHY_MODE_SPECIAL;
  118. /* Connect up MAC/PHY operations table */
  119. rc = efx->type->probe_port(efx);
  120. if (rc)
  121. return rc;
  122. /* Initialise MAC address to permanent address */
  123. eth_hw_addr_set(efx->net_dev, efx->net_dev->perm_addr);
  124. return 0;
  125. }
  126. static int efx_init_port(struct efx_nic *efx)
  127. {
  128. int rc;
  129. netif_dbg(efx, drv, efx->net_dev, "init port\n");
  130. mutex_lock(&efx->mac_lock);
  131. efx->port_initialized = true;
  132. /* Ensure the PHY advertises the correct flow control settings */
  133. rc = efx_siena_mcdi_port_reconfigure(efx);
  134. if (rc && rc != -EPERM)
  135. goto fail;
  136. mutex_unlock(&efx->mac_lock);
  137. return 0;
  138. fail:
  139. mutex_unlock(&efx->mac_lock);
  140. return rc;
  141. }
  142. static void efx_fini_port(struct efx_nic *efx)
  143. {
  144. netif_dbg(efx, drv, efx->net_dev, "shut down port\n");
  145. if (!efx->port_initialized)
  146. return;
  147. efx->port_initialized = false;
  148. efx->link_state.up = false;
  149. efx_siena_link_status_changed(efx);
  150. }
  151. static void efx_remove_port(struct efx_nic *efx)
  152. {
  153. netif_dbg(efx, drv, efx->net_dev, "destroying port\n");
  154. efx->type->remove_port(efx);
  155. }
  156. /**************************************************************************
  157. *
  158. * NIC handling
  159. *
  160. **************************************************************************/
  161. static LIST_HEAD(efx_primary_list);
  162. static LIST_HEAD(efx_unassociated_list);
  163. static bool efx_same_controller(struct efx_nic *left, struct efx_nic *right)
  164. {
  165. return left->type == right->type &&
  166. left->vpd_sn && right->vpd_sn &&
  167. !strcmp(left->vpd_sn, right->vpd_sn);
  168. }
  169. static void efx_associate(struct efx_nic *efx)
  170. {
  171. struct efx_nic *other, *next;
  172. if (efx->primary == efx) {
  173. /* Adding primary function; look for secondaries */
  174. netif_dbg(efx, probe, efx->net_dev, "adding to primary list\n");
  175. list_add_tail(&efx->node, &efx_primary_list);
  176. list_for_each_entry_safe(other, next, &efx_unassociated_list,
  177. node) {
  178. if (efx_same_controller(efx, other)) {
  179. list_del(&other->node);
  180. netif_dbg(other, probe, other->net_dev,
  181. "moving to secondary list of %s %s\n",
  182. pci_name(efx->pci_dev),
  183. efx->net_dev->name);
  184. list_add_tail(&other->node,
  185. &efx->secondary_list);
  186. other->primary = efx;
  187. }
  188. }
  189. } else {
  190. /* Adding secondary function; look for primary */
  191. list_for_each_entry(other, &efx_primary_list, node) {
  192. if (efx_same_controller(efx, other)) {
  193. netif_dbg(efx, probe, efx->net_dev,
  194. "adding to secondary list of %s %s\n",
  195. pci_name(other->pci_dev),
  196. other->net_dev->name);
  197. list_add_tail(&efx->node,
  198. &other->secondary_list);
  199. efx->primary = other;
  200. return;
  201. }
  202. }
  203. netif_dbg(efx, probe, efx->net_dev,
  204. "adding to unassociated list\n");
  205. list_add_tail(&efx->node, &efx_unassociated_list);
  206. }
  207. }
  208. static void efx_dissociate(struct efx_nic *efx)
  209. {
  210. struct efx_nic *other, *next;
  211. list_del(&efx->node);
  212. efx->primary = NULL;
  213. list_for_each_entry_safe(other, next, &efx->secondary_list, node) {
  214. list_del(&other->node);
  215. netif_dbg(other, probe, other->net_dev,
  216. "moving to unassociated list\n");
  217. list_add_tail(&other->node, &efx_unassociated_list);
  218. other->primary = NULL;
  219. }
  220. }
  221. static int efx_probe_nic(struct efx_nic *efx)
  222. {
  223. int rc;
  224. netif_dbg(efx, probe, efx->net_dev, "creating NIC\n");
  225. /* Carry out hardware-type specific initialisation */
  226. rc = efx->type->probe(efx);
  227. if (rc)
  228. return rc;
  229. do {
  230. if (!efx->max_channels || !efx->max_tx_channels) {
  231. netif_err(efx, drv, efx->net_dev,
  232. "Insufficient resources to allocate"
  233. " any channels\n");
  234. rc = -ENOSPC;
  235. goto fail1;
  236. }
  237. /* Determine the number of channels and queues by trying
  238. * to hook in MSI-X interrupts.
  239. */
  240. rc = efx_siena_probe_interrupts(efx);
  241. if (rc)
  242. goto fail1;
  243. rc = efx_siena_set_channels(efx);
  244. if (rc)
  245. goto fail1;
  246. /* dimension_resources can fail with EAGAIN */
  247. rc = efx->type->dimension_resources(efx);
  248. if (rc != 0 && rc != -EAGAIN)
  249. goto fail2;
  250. if (rc == -EAGAIN)
  251. /* try again with new max_channels */
  252. efx_siena_remove_interrupts(efx);
  253. } while (rc == -EAGAIN);
  254. if (efx->n_channels > 1)
  255. netdev_rss_key_fill(efx->rss_context.rx_hash_key,
  256. sizeof(efx->rss_context.rx_hash_key));
  257. efx_siena_set_default_rx_indir_table(efx, &efx->rss_context);
  258. /* Initialise the interrupt moderation settings */
  259. efx->irq_mod_step_us = DIV_ROUND_UP(efx->timer_quantum_ns, 1000);
  260. efx_siena_init_irq_moderation(efx, tx_irq_mod_usec, rx_irq_mod_usec,
  261. true, true);
  262. return 0;
  263. fail2:
  264. efx_siena_remove_interrupts(efx);
  265. fail1:
  266. efx->type->remove(efx);
  267. return rc;
  268. }
  269. static void efx_remove_nic(struct efx_nic *efx)
  270. {
  271. netif_dbg(efx, drv, efx->net_dev, "destroying NIC\n");
  272. efx_siena_remove_interrupts(efx);
  273. efx->type->remove(efx);
  274. }
  275. /**************************************************************************
  276. *
  277. * NIC startup/shutdown
  278. *
  279. *************************************************************************/
  280. static int efx_probe_all(struct efx_nic *efx)
  281. {
  282. int rc;
  283. rc = efx_probe_nic(efx);
  284. if (rc) {
  285. netif_err(efx, probe, efx->net_dev, "failed to create NIC\n");
  286. goto fail1;
  287. }
  288. rc = efx_probe_port(efx);
  289. if (rc) {
  290. netif_err(efx, probe, efx->net_dev, "failed to create port\n");
  291. goto fail2;
  292. }
  293. BUILD_BUG_ON(EFX_DEFAULT_DMAQ_SIZE < EFX_RXQ_MIN_ENT);
  294. if (WARN_ON(EFX_DEFAULT_DMAQ_SIZE < EFX_TXQ_MIN_ENT(efx))) {
  295. rc = -EINVAL;
  296. goto fail3;
  297. }
  298. #ifdef CONFIG_SFC_SIENA_SRIOV
  299. rc = efx->type->vswitching_probe(efx);
  300. if (rc) /* not fatal; the PF will still work fine */
  301. netif_warn(efx, probe, efx->net_dev,
  302. "failed to setup vswitching rc=%d;"
  303. " VFs may not function\n", rc);
  304. #endif
  305. rc = efx_siena_probe_filters(efx);
  306. if (rc) {
  307. netif_err(efx, probe, efx->net_dev,
  308. "failed to create filter tables\n");
  309. goto fail4;
  310. }
  311. rc = efx_siena_probe_channels(efx);
  312. if (rc)
  313. goto fail5;
  314. return 0;
  315. fail5:
  316. efx_siena_remove_filters(efx);
  317. fail4:
  318. #ifdef CONFIG_SFC_SIENA_SRIOV
  319. efx->type->vswitching_remove(efx);
  320. #endif
  321. fail3:
  322. efx_remove_port(efx);
  323. fail2:
  324. efx_remove_nic(efx);
  325. fail1:
  326. return rc;
  327. }
  328. static void efx_remove_all(struct efx_nic *efx)
  329. {
  330. rtnl_lock();
  331. efx_xdp_setup_prog(efx, NULL);
  332. rtnl_unlock();
  333. efx_siena_remove_channels(efx);
  334. efx_siena_remove_filters(efx);
  335. #ifdef CONFIG_SFC_SIENA_SRIOV
  336. efx->type->vswitching_remove(efx);
  337. #endif
  338. efx_remove_port(efx);
  339. efx_remove_nic(efx);
  340. }
  341. /**************************************************************************
  342. *
  343. * Interrupt moderation
  344. *
  345. **************************************************************************/
  346. unsigned int efx_siena_usecs_to_ticks(struct efx_nic *efx, unsigned int usecs)
  347. {
  348. if (usecs == 0)
  349. return 0;
  350. if (usecs * 1000 < efx->timer_quantum_ns)
  351. return 1; /* never round down to 0 */
  352. return usecs * 1000 / efx->timer_quantum_ns;
  353. }
  354. /* Set interrupt moderation parameters */
  355. int efx_siena_init_irq_moderation(struct efx_nic *efx, unsigned int tx_usecs,
  356. unsigned int rx_usecs, bool rx_adaptive,
  357. bool rx_may_override_tx)
  358. {
  359. struct efx_channel *channel;
  360. unsigned int timer_max_us;
  361. EFX_ASSERT_RESET_SERIALISED(efx);
  362. timer_max_us = efx->timer_max_ns / 1000;
  363. if (tx_usecs > timer_max_us || rx_usecs > timer_max_us)
  364. return -EINVAL;
  365. if (tx_usecs != rx_usecs && efx->tx_channel_offset == 0 &&
  366. !rx_may_override_tx) {
  367. netif_err(efx, drv, efx->net_dev, "Channels are shared. "
  368. "RX and TX IRQ moderation must be equal\n");
  369. return -EINVAL;
  370. }
  371. efx->irq_rx_adaptive = rx_adaptive;
  372. efx->irq_rx_moderation_us = rx_usecs;
  373. efx_for_each_channel(channel, efx) {
  374. if (efx_channel_has_rx_queue(channel))
  375. channel->irq_moderation_us = rx_usecs;
  376. else if (efx_channel_has_tx_queues(channel))
  377. channel->irq_moderation_us = tx_usecs;
  378. else if (efx_channel_is_xdp_tx(channel))
  379. channel->irq_moderation_us = tx_usecs;
  380. }
  381. return 0;
  382. }
  383. void efx_siena_get_irq_moderation(struct efx_nic *efx, unsigned int *tx_usecs,
  384. unsigned int *rx_usecs, bool *rx_adaptive)
  385. {
  386. *rx_adaptive = efx->irq_rx_adaptive;
  387. *rx_usecs = efx->irq_rx_moderation_us;
  388. /* If channels are shared between RX and TX, so is IRQ
  389. * moderation. Otherwise, IRQ moderation is the same for all
  390. * TX channels and is not adaptive.
  391. */
  392. if (efx->tx_channel_offset == 0) {
  393. *tx_usecs = *rx_usecs;
  394. } else {
  395. struct efx_channel *tx_channel;
  396. tx_channel = efx->channel[efx->tx_channel_offset];
  397. *tx_usecs = tx_channel->irq_moderation_us;
  398. }
  399. }
  400. /**************************************************************************
  401. *
  402. * ioctls
  403. *
  404. *************************************************************************/
  405. /* Net device ioctl
  406. * Context: process, rtnl_lock() held.
  407. */
  408. static int efx_ioctl(struct net_device *net_dev, struct ifreq *ifr, int cmd)
  409. {
  410. struct efx_nic *efx = netdev_priv(net_dev);
  411. struct mii_ioctl_data *data = if_mii(ifr);
  412. if (cmd == SIOCSHWTSTAMP)
  413. return efx_siena_ptp_set_ts_config(efx, ifr);
  414. if (cmd == SIOCGHWTSTAMP)
  415. return efx_siena_ptp_get_ts_config(efx, ifr);
  416. /* Convert phy_id from older PRTAD/DEVAD format */
  417. if ((cmd == SIOCGMIIREG || cmd == SIOCSMIIREG) &&
  418. (data->phy_id & 0xfc00) == 0x0400)
  419. data->phy_id ^= MDIO_PHY_ID_C45 | 0x0400;
  420. return mdio_mii_ioctl(&efx->mdio, data, cmd);
  421. }
  422. /**************************************************************************
  423. *
  424. * Kernel net device interface
  425. *
  426. *************************************************************************/
  427. /* Context: process, rtnl_lock() held. */
  428. static int efx_net_open(struct net_device *net_dev)
  429. {
  430. struct efx_nic *efx = netdev_priv(net_dev);
  431. int rc;
  432. netif_dbg(efx, ifup, efx->net_dev, "opening device on CPU %d\n",
  433. raw_smp_processor_id());
  434. rc = efx_check_disabled(efx);
  435. if (rc)
  436. return rc;
  437. if (efx->phy_mode & PHY_MODE_SPECIAL)
  438. return -EBUSY;
  439. if (efx_siena_mcdi_poll_reboot(efx) && efx_siena_reset(efx, RESET_TYPE_ALL))
  440. return -EIO;
  441. /* Notify the kernel of the link state polled during driver load,
  442. * before the monitor starts running */
  443. efx_siena_link_status_changed(efx);
  444. efx_siena_start_all(efx);
  445. if (efx->state == STATE_DISABLED || efx->reset_pending)
  446. netif_device_detach(efx->net_dev);
  447. efx_siena_selftest_async_start(efx);
  448. return 0;
  449. }
  450. /* Context: process, rtnl_lock() held.
  451. * Note that the kernel will ignore our return code; this method
  452. * should really be a void.
  453. */
  454. static int efx_net_stop(struct net_device *net_dev)
  455. {
  456. struct efx_nic *efx = netdev_priv(net_dev);
  457. netif_dbg(efx, ifdown, efx->net_dev, "closing on CPU %d\n",
  458. raw_smp_processor_id());
  459. /* Stop the device and flush all the channels */
  460. efx_siena_stop_all(efx);
  461. return 0;
  462. }
  463. static int efx_vlan_rx_add_vid(struct net_device *net_dev, __be16 proto, u16 vid)
  464. {
  465. struct efx_nic *efx = netdev_priv(net_dev);
  466. if (efx->type->vlan_rx_add_vid)
  467. return efx->type->vlan_rx_add_vid(efx, proto, vid);
  468. else
  469. return -EOPNOTSUPP;
  470. }
  471. static int efx_vlan_rx_kill_vid(struct net_device *net_dev, __be16 proto, u16 vid)
  472. {
  473. struct efx_nic *efx = netdev_priv(net_dev);
  474. if (efx->type->vlan_rx_kill_vid)
  475. return efx->type->vlan_rx_kill_vid(efx, proto, vid);
  476. else
  477. return -EOPNOTSUPP;
  478. }
  479. static const struct net_device_ops efx_netdev_ops = {
  480. .ndo_open = efx_net_open,
  481. .ndo_stop = efx_net_stop,
  482. .ndo_get_stats64 = efx_siena_net_stats,
  483. .ndo_tx_timeout = efx_siena_watchdog,
  484. .ndo_start_xmit = efx_siena_hard_start_xmit,
  485. .ndo_validate_addr = eth_validate_addr,
  486. .ndo_eth_ioctl = efx_ioctl,
  487. .ndo_change_mtu = efx_siena_change_mtu,
  488. .ndo_set_mac_address = efx_siena_set_mac_address,
  489. .ndo_set_rx_mode = efx_siena_set_rx_mode,
  490. .ndo_set_features = efx_siena_set_features,
  491. .ndo_features_check = efx_siena_features_check,
  492. .ndo_vlan_rx_add_vid = efx_vlan_rx_add_vid,
  493. .ndo_vlan_rx_kill_vid = efx_vlan_rx_kill_vid,
  494. #ifdef CONFIG_SFC_SIENA_SRIOV
  495. .ndo_set_vf_mac = efx_sriov_set_vf_mac,
  496. .ndo_set_vf_vlan = efx_sriov_set_vf_vlan,
  497. .ndo_set_vf_spoofchk = efx_sriov_set_vf_spoofchk,
  498. .ndo_get_vf_config = efx_sriov_get_vf_config,
  499. .ndo_set_vf_link_state = efx_sriov_set_vf_link_state,
  500. #endif
  501. .ndo_get_phys_port_id = efx_siena_get_phys_port_id,
  502. .ndo_get_phys_port_name = efx_siena_get_phys_port_name,
  503. .ndo_setup_tc = efx_siena_setup_tc,
  504. #ifdef CONFIG_RFS_ACCEL
  505. .ndo_rx_flow_steer = efx_siena_filter_rfs,
  506. #endif
  507. .ndo_xdp_xmit = efx_xdp_xmit,
  508. .ndo_bpf = efx_xdp
  509. };
  510. static int efx_xdp_setup_prog(struct efx_nic *efx, struct bpf_prog *prog)
  511. {
  512. struct bpf_prog *old_prog;
  513. if (efx->xdp_rxq_info_failed) {
  514. netif_err(efx, drv, efx->net_dev,
  515. "Unable to bind XDP program due to previous failure of rxq_info\n");
  516. return -EINVAL;
  517. }
  518. if (prog && efx->net_dev->mtu > efx_siena_xdp_max_mtu(efx)) {
  519. netif_err(efx, drv, efx->net_dev,
  520. "Unable to configure XDP with MTU of %d (max: %d)\n",
  521. efx->net_dev->mtu, efx_siena_xdp_max_mtu(efx));
  522. return -EINVAL;
  523. }
  524. old_prog = rtnl_dereference(efx->xdp_prog);
  525. rcu_assign_pointer(efx->xdp_prog, prog);
  526. /* Release the reference that was originally passed by the caller. */
  527. if (old_prog)
  528. bpf_prog_put(old_prog);
  529. return 0;
  530. }
  531. /* Context: process, rtnl_lock() held. */
  532. static int efx_xdp(struct net_device *dev, struct netdev_bpf *xdp)
  533. {
  534. struct efx_nic *efx = netdev_priv(dev);
  535. switch (xdp->command) {
  536. case XDP_SETUP_PROG:
  537. return efx_xdp_setup_prog(efx, xdp->prog);
  538. default:
  539. return -EINVAL;
  540. }
  541. }
  542. static int efx_xdp_xmit(struct net_device *dev, int n, struct xdp_frame **xdpfs,
  543. u32 flags)
  544. {
  545. struct efx_nic *efx = netdev_priv(dev);
  546. if (!netif_running(dev))
  547. return -EINVAL;
  548. return efx_siena_xdp_tx_buffers(efx, n, xdpfs, flags & XDP_XMIT_FLUSH);
  549. }
  550. static void efx_update_name(struct efx_nic *efx)
  551. {
  552. strcpy(efx->name, efx->net_dev->name);
  553. efx_siena_mtd_rename(efx);
  554. efx_siena_set_channel_names(efx);
  555. }
  556. static int efx_netdev_event(struct notifier_block *this,
  557. unsigned long event, void *ptr)
  558. {
  559. struct net_device *net_dev = netdev_notifier_info_to_dev(ptr);
  560. if ((net_dev->netdev_ops == &efx_netdev_ops) &&
  561. event == NETDEV_CHANGENAME)
  562. efx_update_name(netdev_priv(net_dev));
  563. return NOTIFY_DONE;
  564. }
  565. static struct notifier_block efx_netdev_notifier = {
  566. .notifier_call = efx_netdev_event,
  567. };
  568. static ssize_t phy_type_show(struct device *dev,
  569. struct device_attribute *attr, char *buf)
  570. {
  571. struct efx_nic *efx = dev_get_drvdata(dev);
  572. return sprintf(buf, "%d\n", efx->phy_type);
  573. }
  574. static DEVICE_ATTR_RO(phy_type);
  575. static int efx_register_netdev(struct efx_nic *efx)
  576. {
  577. struct net_device *net_dev = efx->net_dev;
  578. struct efx_channel *channel;
  579. int rc;
  580. net_dev->watchdog_timeo = 5 * HZ;
  581. net_dev->irq = efx->pci_dev->irq;
  582. net_dev->netdev_ops = &efx_netdev_ops;
  583. if (efx_nic_rev(efx) >= EFX_REV_HUNT_A0)
  584. net_dev->priv_flags |= IFF_UNICAST_FLT;
  585. net_dev->ethtool_ops = &efx_siena_ethtool_ops;
  586. netif_set_tso_max_segs(net_dev, EFX_TSO_MAX_SEGS);
  587. net_dev->min_mtu = EFX_MIN_MTU;
  588. net_dev->max_mtu = EFX_MAX_MTU;
  589. rtnl_lock();
  590. /* Enable resets to be scheduled and check whether any were
  591. * already requested. If so, the NIC is probably hosed so we
  592. * abort.
  593. */
  594. efx->state = STATE_READY;
  595. smp_mb(); /* ensure we change state before checking reset_pending */
  596. if (efx->reset_pending) {
  597. pci_err(efx->pci_dev, "aborting probe due to scheduled reset\n");
  598. rc = -EIO;
  599. goto fail_locked;
  600. }
  601. rc = dev_alloc_name(net_dev, net_dev->name);
  602. if (rc < 0)
  603. goto fail_locked;
  604. efx_update_name(efx);
  605. /* Always start with carrier off; PHY events will detect the link */
  606. netif_carrier_off(net_dev);
  607. rc = register_netdevice(net_dev);
  608. if (rc)
  609. goto fail_locked;
  610. efx_for_each_channel(channel, efx) {
  611. struct efx_tx_queue *tx_queue;
  612. efx_for_each_channel_tx_queue(tx_queue, channel)
  613. efx_siena_init_tx_queue_core_txq(tx_queue);
  614. }
  615. efx_associate(efx);
  616. rtnl_unlock();
  617. rc = device_create_file(&efx->pci_dev->dev, &dev_attr_phy_type);
  618. if (rc) {
  619. netif_err(efx, drv, efx->net_dev,
  620. "failed to init net dev attributes\n");
  621. goto fail_registered;
  622. }
  623. efx_siena_init_mcdi_logging(efx);
  624. return 0;
  625. fail_registered:
  626. rtnl_lock();
  627. efx_dissociate(efx);
  628. unregister_netdevice(net_dev);
  629. fail_locked:
  630. efx->state = STATE_UNINIT;
  631. rtnl_unlock();
  632. netif_err(efx, drv, efx->net_dev, "could not register net dev\n");
  633. return rc;
  634. }
  635. static void efx_unregister_netdev(struct efx_nic *efx)
  636. {
  637. if (!efx->net_dev)
  638. return;
  639. BUG_ON(netdev_priv(efx->net_dev) != efx);
  640. if (efx_dev_registered(efx)) {
  641. strscpy(efx->name, pci_name(efx->pci_dev), sizeof(efx->name));
  642. efx_siena_fini_mcdi_logging(efx);
  643. device_remove_file(&efx->pci_dev->dev, &dev_attr_phy_type);
  644. unregister_netdev(efx->net_dev);
  645. }
  646. }
  647. /**************************************************************************
  648. *
  649. * List of NICs we support
  650. *
  651. **************************************************************************/
  652. /* PCI device ID table */
  653. static const struct pci_device_id efx_pci_table[] = {
  654. {PCI_DEVICE(PCI_VENDOR_ID_SOLARFLARE, 0x0803), /* SFC9020 */
  655. .driver_data = (unsigned long)&siena_a0_nic_type},
  656. {PCI_DEVICE(PCI_VENDOR_ID_SOLARFLARE, 0x0813), /* SFL9021 */
  657. .driver_data = (unsigned long)&siena_a0_nic_type},
  658. {0} /* end of list */
  659. };
  660. /**************************************************************************
  661. *
  662. * Data housekeeping
  663. *
  664. **************************************************************************/
  665. void efx_siena_update_sw_stats(struct efx_nic *efx, u64 *stats)
  666. {
  667. u64 n_rx_nodesc_trunc = 0;
  668. struct efx_channel *channel;
  669. efx_for_each_channel(channel, efx)
  670. n_rx_nodesc_trunc += channel->n_rx_nodesc_trunc;
  671. stats[GENERIC_STAT_rx_nodesc_trunc] = n_rx_nodesc_trunc;
  672. stats[GENERIC_STAT_rx_noskb_drops] = atomic_read(&efx->n_rx_noskb_drops);
  673. }
  674. /**************************************************************************
  675. *
  676. * PCI interface
  677. *
  678. **************************************************************************/
  679. /* Main body of final NIC shutdown code
  680. * This is called only at module unload (or hotplug removal).
  681. */
  682. static void efx_pci_remove_main(struct efx_nic *efx)
  683. {
  684. /* Flush reset_work. It can no longer be scheduled since we
  685. * are not READY.
  686. */
  687. BUG_ON(efx->state == STATE_READY);
  688. efx_siena_flush_reset_workqueue(efx);
  689. efx_siena_disable_interrupts(efx);
  690. efx_siena_clear_interrupt_affinity(efx);
  691. efx_siena_fini_interrupt(efx);
  692. efx_fini_port(efx);
  693. efx->type->fini(efx);
  694. efx_siena_fini_napi(efx);
  695. efx_remove_all(efx);
  696. }
  697. /* Final NIC shutdown
  698. * This is called only at module unload (or hotplug removal). A PF can call
  699. * this on its VFs to ensure they are unbound first.
  700. */
  701. static void efx_pci_remove(struct pci_dev *pci_dev)
  702. {
  703. struct efx_nic *efx;
  704. efx = pci_get_drvdata(pci_dev);
  705. if (!efx)
  706. return;
  707. /* Mark the NIC as fini, then stop the interface */
  708. rtnl_lock();
  709. efx_dissociate(efx);
  710. dev_close(efx->net_dev);
  711. efx_siena_disable_interrupts(efx);
  712. efx->state = STATE_UNINIT;
  713. rtnl_unlock();
  714. if (efx->type->sriov_fini)
  715. efx->type->sriov_fini(efx);
  716. efx_unregister_netdev(efx);
  717. efx_siena_mtd_remove(efx);
  718. efx_pci_remove_main(efx);
  719. efx_siena_fini_io(efx);
  720. netif_dbg(efx, drv, efx->net_dev, "shutdown successful\n");
  721. efx_siena_fini_struct(efx);
  722. free_netdev(efx->net_dev);
  723. pci_disable_pcie_error_reporting(pci_dev);
  724. };
  725. /* NIC VPD information
  726. * Called during probe to display the part number of the
  727. * installed NIC.
  728. */
  729. static void efx_probe_vpd_strings(struct efx_nic *efx)
  730. {
  731. struct pci_dev *dev = efx->pci_dev;
  732. unsigned int vpd_size, kw_len;
  733. u8 *vpd_data;
  734. int start;
  735. vpd_data = pci_vpd_alloc(dev, &vpd_size);
  736. if (IS_ERR(vpd_data)) {
  737. pci_warn(dev, "Unable to read VPD\n");
  738. return;
  739. }
  740. start = pci_vpd_find_ro_info_keyword(vpd_data, vpd_size,
  741. PCI_VPD_RO_KEYWORD_PARTNO, &kw_len);
  742. if (start < 0)
  743. pci_err(dev, "Part number not found or incomplete\n");
  744. else
  745. pci_info(dev, "Part Number : %.*s\n", kw_len, vpd_data + start);
  746. start = pci_vpd_find_ro_info_keyword(vpd_data, vpd_size,
  747. PCI_VPD_RO_KEYWORD_SERIALNO, &kw_len);
  748. if (start < 0)
  749. pci_err(dev, "Serial number not found or incomplete\n");
  750. else
  751. efx->vpd_sn = kmemdup_nul(vpd_data + start, kw_len, GFP_KERNEL);
  752. kfree(vpd_data);
  753. }
  754. /* Main body of NIC initialisation
  755. * This is called at module load (or hotplug insertion, theoretically).
  756. */
  757. static int efx_pci_probe_main(struct efx_nic *efx)
  758. {
  759. int rc;
  760. /* Do start-of-day initialisation */
  761. rc = efx_probe_all(efx);
  762. if (rc)
  763. goto fail1;
  764. efx_siena_init_napi(efx);
  765. down_write(&efx->filter_sem);
  766. rc = efx->type->init(efx);
  767. up_write(&efx->filter_sem);
  768. if (rc) {
  769. pci_err(efx->pci_dev, "failed to initialise NIC\n");
  770. goto fail3;
  771. }
  772. rc = efx_init_port(efx);
  773. if (rc) {
  774. netif_err(efx, probe, efx->net_dev,
  775. "failed to initialise port\n");
  776. goto fail4;
  777. }
  778. rc = efx_siena_init_interrupt(efx);
  779. if (rc)
  780. goto fail5;
  781. efx_siena_set_interrupt_affinity(efx);
  782. rc = efx_siena_enable_interrupts(efx);
  783. if (rc)
  784. goto fail6;
  785. return 0;
  786. fail6:
  787. efx_siena_clear_interrupt_affinity(efx);
  788. efx_siena_fini_interrupt(efx);
  789. fail5:
  790. efx_fini_port(efx);
  791. fail4:
  792. efx->type->fini(efx);
  793. fail3:
  794. efx_siena_fini_napi(efx);
  795. efx_remove_all(efx);
  796. fail1:
  797. return rc;
  798. }
  799. static int efx_pci_probe_post_io(struct efx_nic *efx)
  800. {
  801. struct net_device *net_dev = efx->net_dev;
  802. int rc = efx_pci_probe_main(efx);
  803. if (rc)
  804. return rc;
  805. if (efx->type->sriov_init) {
  806. rc = efx->type->sriov_init(efx);
  807. if (rc)
  808. pci_err(efx->pci_dev, "SR-IOV can't be enabled rc %d\n",
  809. rc);
  810. }
  811. /* Determine netdevice features */
  812. net_dev->features |= (efx->type->offload_features | NETIF_F_SG |
  813. NETIF_F_TSO | NETIF_F_RXCSUM | NETIF_F_RXALL);
  814. if (efx->type->offload_features & (NETIF_F_IPV6_CSUM | NETIF_F_HW_CSUM))
  815. net_dev->features |= NETIF_F_TSO6;
  816. /* Check whether device supports TSO */
  817. if (!efx->type->tso_versions || !efx->type->tso_versions(efx))
  818. net_dev->features &= ~NETIF_F_ALL_TSO;
  819. /* Mask for features that also apply to VLAN devices */
  820. net_dev->vlan_features |= (NETIF_F_HW_CSUM | NETIF_F_SG |
  821. NETIF_F_HIGHDMA | NETIF_F_ALL_TSO |
  822. NETIF_F_RXCSUM);
  823. net_dev->hw_features |= net_dev->features & ~efx->fixed_features;
  824. /* Disable receiving frames with bad FCS, by default. */
  825. net_dev->features &= ~NETIF_F_RXALL;
  826. /* Disable VLAN filtering by default. It may be enforced if
  827. * the feature is fixed (i.e. VLAN filters are required to
  828. * receive VLAN tagged packets due to vPort restrictions).
  829. */
  830. net_dev->features &= ~NETIF_F_HW_VLAN_CTAG_FILTER;
  831. net_dev->features |= efx->fixed_features;
  832. rc = efx_register_netdev(efx);
  833. if (!rc)
  834. return 0;
  835. efx_pci_remove_main(efx);
  836. return rc;
  837. }
  838. /* NIC initialisation
  839. *
  840. * This is called at module load (or hotplug insertion,
  841. * theoretically). It sets up PCI mappings, resets the NIC,
  842. * sets up and registers the network devices with the kernel and hooks
  843. * the interrupt service routine. It does not prepare the device for
  844. * transmission; this is left to the first time one of the network
  845. * interfaces is brought up (i.e. efx_net_open).
  846. */
  847. static int efx_pci_probe(struct pci_dev *pci_dev,
  848. const struct pci_device_id *entry)
  849. {
  850. struct net_device *net_dev;
  851. struct efx_nic *efx;
  852. int rc;
  853. /* Allocate and initialise a struct net_device and struct efx_nic */
  854. net_dev = alloc_etherdev_mqs(sizeof(*efx), EFX_MAX_CORE_TX_QUEUES,
  855. EFX_MAX_RX_QUEUES);
  856. if (!net_dev)
  857. return -ENOMEM;
  858. efx = netdev_priv(net_dev);
  859. efx->type = (const struct efx_nic_type *) entry->driver_data;
  860. efx->fixed_features |= NETIF_F_HIGHDMA;
  861. pci_set_drvdata(pci_dev, efx);
  862. SET_NETDEV_DEV(net_dev, &pci_dev->dev);
  863. rc = efx_siena_init_struct(efx, pci_dev, net_dev);
  864. if (rc)
  865. goto fail1;
  866. pci_info(pci_dev, "Solarflare NIC detected\n");
  867. if (!efx->type->is_vf)
  868. efx_probe_vpd_strings(efx);
  869. /* Set up basic I/O (BAR mappings etc) */
  870. rc = efx_siena_init_io(efx, efx->type->mem_bar(efx),
  871. efx->type->max_dma_mask,
  872. efx->type->mem_map_size(efx));
  873. if (rc)
  874. goto fail2;
  875. rc = efx_pci_probe_post_io(efx);
  876. if (rc) {
  877. /* On failure, retry once immediately.
  878. * If we aborted probe due to a scheduled reset, dismiss it.
  879. */
  880. efx->reset_pending = 0;
  881. rc = efx_pci_probe_post_io(efx);
  882. if (rc) {
  883. /* On another failure, retry once more
  884. * after a 50-305ms delay.
  885. */
  886. unsigned char r;
  887. get_random_bytes(&r, 1);
  888. msleep((unsigned int)r + 50);
  889. efx->reset_pending = 0;
  890. rc = efx_pci_probe_post_io(efx);
  891. }
  892. }
  893. if (rc)
  894. goto fail3;
  895. netif_dbg(efx, probe, efx->net_dev, "initialisation successful\n");
  896. /* Try to create MTDs, but allow this to fail */
  897. rtnl_lock();
  898. rc = efx_mtd_probe(efx);
  899. rtnl_unlock();
  900. if (rc && rc != -EPERM)
  901. netif_warn(efx, probe, efx->net_dev,
  902. "failed to create MTDs (%d)\n", rc);
  903. (void)pci_enable_pcie_error_reporting(pci_dev);
  904. if (efx->type->udp_tnl_push_ports)
  905. efx->type->udp_tnl_push_ports(efx);
  906. return 0;
  907. fail3:
  908. efx_siena_fini_io(efx);
  909. fail2:
  910. efx_siena_fini_struct(efx);
  911. fail1:
  912. WARN_ON(rc > 0);
  913. netif_dbg(efx, drv, efx->net_dev, "initialisation failed. rc=%d\n", rc);
  914. free_netdev(net_dev);
  915. return rc;
  916. }
  917. /* efx_pci_sriov_configure returns the actual number of Virtual Functions
  918. * enabled on success
  919. */
  920. #ifdef CONFIG_SFC_SIENA_SRIOV
  921. static int efx_pci_sriov_configure(struct pci_dev *dev, int num_vfs)
  922. {
  923. int rc;
  924. struct efx_nic *efx = pci_get_drvdata(dev);
  925. if (efx->type->sriov_configure) {
  926. rc = efx->type->sriov_configure(efx, num_vfs);
  927. if (rc)
  928. return rc;
  929. else
  930. return num_vfs;
  931. } else
  932. return -EOPNOTSUPP;
  933. }
  934. #endif
  935. static int efx_pm_freeze(struct device *dev)
  936. {
  937. struct efx_nic *efx = dev_get_drvdata(dev);
  938. rtnl_lock();
  939. if (efx->state != STATE_DISABLED) {
  940. efx->state = STATE_UNINIT;
  941. efx_device_detach_sync(efx);
  942. efx_siena_stop_all(efx);
  943. efx_siena_disable_interrupts(efx);
  944. }
  945. rtnl_unlock();
  946. return 0;
  947. }
  948. static void efx_pci_shutdown(struct pci_dev *pci_dev)
  949. {
  950. struct efx_nic *efx = pci_get_drvdata(pci_dev);
  951. if (!efx)
  952. return;
  953. efx_pm_freeze(&pci_dev->dev);
  954. pci_disable_device(pci_dev);
  955. }
  956. static int efx_pm_thaw(struct device *dev)
  957. {
  958. int rc;
  959. struct efx_nic *efx = dev_get_drvdata(dev);
  960. rtnl_lock();
  961. if (efx->state != STATE_DISABLED) {
  962. rc = efx_siena_enable_interrupts(efx);
  963. if (rc)
  964. goto fail;
  965. mutex_lock(&efx->mac_lock);
  966. efx_siena_mcdi_port_reconfigure(efx);
  967. mutex_unlock(&efx->mac_lock);
  968. efx_siena_start_all(efx);
  969. efx_device_attach_if_not_resetting(efx);
  970. efx->state = STATE_READY;
  971. efx->type->resume_wol(efx);
  972. }
  973. rtnl_unlock();
  974. /* Reschedule any quenched resets scheduled during efx_pm_freeze() */
  975. efx_siena_queue_reset_work(efx);
  976. return 0;
  977. fail:
  978. rtnl_unlock();
  979. return rc;
  980. }
  981. static int efx_pm_poweroff(struct device *dev)
  982. {
  983. struct pci_dev *pci_dev = to_pci_dev(dev);
  984. struct efx_nic *efx = pci_get_drvdata(pci_dev);
  985. efx->type->fini(efx);
  986. efx->reset_pending = 0;
  987. pci_save_state(pci_dev);
  988. return pci_set_power_state(pci_dev, PCI_D3hot);
  989. }
  990. /* Used for both resume and restore */
  991. static int efx_pm_resume(struct device *dev)
  992. {
  993. struct pci_dev *pci_dev = to_pci_dev(dev);
  994. struct efx_nic *efx = pci_get_drvdata(pci_dev);
  995. int rc;
  996. rc = pci_set_power_state(pci_dev, PCI_D0);
  997. if (rc)
  998. return rc;
  999. pci_restore_state(pci_dev);
  1000. rc = pci_enable_device(pci_dev);
  1001. if (rc)
  1002. return rc;
  1003. pci_set_master(efx->pci_dev);
  1004. rc = efx->type->reset(efx, RESET_TYPE_ALL);
  1005. if (rc)
  1006. return rc;
  1007. down_write(&efx->filter_sem);
  1008. rc = efx->type->init(efx);
  1009. up_write(&efx->filter_sem);
  1010. if (rc)
  1011. return rc;
  1012. rc = efx_pm_thaw(dev);
  1013. return rc;
  1014. }
  1015. static int efx_pm_suspend(struct device *dev)
  1016. {
  1017. int rc;
  1018. efx_pm_freeze(dev);
  1019. rc = efx_pm_poweroff(dev);
  1020. if (rc)
  1021. efx_pm_resume(dev);
  1022. return rc;
  1023. }
  1024. static const struct dev_pm_ops efx_pm_ops = {
  1025. .suspend = efx_pm_suspend,
  1026. .resume = efx_pm_resume,
  1027. .freeze = efx_pm_freeze,
  1028. .thaw = efx_pm_thaw,
  1029. .poweroff = efx_pm_poweroff,
  1030. .restore = efx_pm_resume,
  1031. };
  1032. static struct pci_driver efx_pci_driver = {
  1033. .name = KBUILD_MODNAME,
  1034. .id_table = efx_pci_table,
  1035. .probe = efx_pci_probe,
  1036. .remove = efx_pci_remove,
  1037. .driver.pm = &efx_pm_ops,
  1038. .shutdown = efx_pci_shutdown,
  1039. .err_handler = &efx_siena_err_handlers,
  1040. #ifdef CONFIG_SFC_SIENA_SRIOV
  1041. .sriov_configure = efx_pci_sriov_configure,
  1042. #endif
  1043. };
  1044. /**************************************************************************
  1045. *
  1046. * Kernel module interface
  1047. *
  1048. *************************************************************************/
  1049. static int __init efx_init_module(void)
  1050. {
  1051. int rc;
  1052. pr_info("Solarflare Siena driver\n");
  1053. rc = register_netdevice_notifier(&efx_netdev_notifier);
  1054. if (rc)
  1055. goto err_notifier;
  1056. #ifdef CONFIG_SFC_SIENA_SRIOV
  1057. rc = efx_init_sriov();
  1058. if (rc)
  1059. goto err_sriov;
  1060. #endif
  1061. rc = efx_siena_create_reset_workqueue();
  1062. if (rc)
  1063. goto err_reset;
  1064. rc = pci_register_driver(&efx_pci_driver);
  1065. if (rc < 0)
  1066. goto err_pci;
  1067. return 0;
  1068. err_pci:
  1069. efx_siena_destroy_reset_workqueue();
  1070. err_reset:
  1071. #ifdef CONFIG_SFC_SIENA_SRIOV
  1072. efx_fini_sriov();
  1073. err_sriov:
  1074. #endif
  1075. unregister_netdevice_notifier(&efx_netdev_notifier);
  1076. err_notifier:
  1077. return rc;
  1078. }
  1079. static void __exit efx_exit_module(void)
  1080. {
  1081. pr_info("Solarflare Siena driver unloading\n");
  1082. pci_unregister_driver(&efx_pci_driver);
  1083. efx_siena_destroy_reset_workqueue();
  1084. #ifdef CONFIG_SFC_SIENA_SRIOV
  1085. efx_fini_sriov();
  1086. #endif
  1087. unregister_netdevice_notifier(&efx_netdev_notifier);
  1088. }
  1089. module_init(efx_init_module);
  1090. module_exit(efx_exit_module);
  1091. MODULE_AUTHOR("Solarflare Communications and "
  1092. "Michael Brown <[email protected]>");
  1093. MODULE_DESCRIPTION("Solarflare Siena network driver");
  1094. MODULE_LICENSE("GPL");
  1095. MODULE_DEVICE_TABLE(pci, efx_pci_table);