nic.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535
  1. /****************************************************************************
  2. * Driver for Solarflare network controllers and boards
  3. * Copyright 2005-2006 Fen Systems Ltd.
  4. * Copyright 2006-2013 Solarflare Communications Inc.
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License version 2 as published
  8. * by the Free Software Foundation, incorporated herein by reference.
  9. */
  10. #include <linux/bitops.h>
  11. #include <linux/delay.h>
  12. #include <linux/interrupt.h>
  13. #include <linux/pci.h>
  14. #include <linux/module.h>
  15. #include <linux/seq_file.h>
  16. #include <linux/cpu_rmap.h>
  17. #include "net_driver.h"
  18. #include "bitfield.h"
  19. #include "efx.h"
  20. #include "nic.h"
  21. #include "ef10_regs.h"
  22. #include "farch_regs.h"
  23. #include "io.h"
  24. #include "workarounds.h"
  25. /**************************************************************************
  26. *
  27. * Generic buffer handling
  28. * These buffers are used for interrupt status, MAC stats, etc.
  29. *
  30. **************************************************************************/
  31. int efx_nic_alloc_buffer(struct efx_nic *efx, struct efx_buffer *buffer,
  32. unsigned int len, gfp_t gfp_flags)
  33. {
  34. buffer->addr = dma_zalloc_coherent(&efx->pci_dev->dev, len,
  35. &buffer->dma_addr, gfp_flags);
  36. if (!buffer->addr)
  37. return -ENOMEM;
  38. buffer->len = len;
  39. return 0;
  40. }
  41. void efx_nic_free_buffer(struct efx_nic *efx, struct efx_buffer *buffer)
  42. {
  43. if (buffer->addr) {
  44. dma_free_coherent(&efx->pci_dev->dev, buffer->len,
  45. buffer->addr, buffer->dma_addr);
  46. buffer->addr = NULL;
  47. }
  48. }
  49. /* Check whether an event is present in the eventq at the current
  50. * read pointer. Only useful for self-test.
  51. */
  52. bool efx_nic_event_present(struct efx_channel *channel)
  53. {
  54. return efx_event_present(efx_event(channel, channel->eventq_read_ptr));
  55. }
  56. void efx_nic_event_test_start(struct efx_channel *channel)
  57. {
  58. channel->event_test_cpu = -1;
  59. smp_wmb();
  60. channel->efx->type->ev_test_generate(channel);
  61. }
  62. int efx_nic_irq_test_start(struct efx_nic *efx)
  63. {
  64. efx->last_irq_cpu = -1;
  65. smp_wmb();
  66. return efx->type->irq_test_generate(efx);
  67. }
  68. /* Hook interrupt handler(s)
  69. * Try MSI and then legacy interrupts.
  70. */
  71. int efx_nic_init_interrupt(struct efx_nic *efx)
  72. {
  73. struct efx_channel *channel;
  74. unsigned int n_irqs;
  75. int rc;
  76. if (!EFX_INT_MODE_USE_MSI(efx)) {
  77. rc = request_irq(efx->legacy_irq,
  78. efx->type->irq_handle_legacy, IRQF_SHARED,
  79. efx->name, efx);
  80. if (rc) {
  81. netif_err(efx, drv, efx->net_dev,
  82. "failed to hook legacy IRQ %d\n",
  83. efx->pci_dev->irq);
  84. goto fail1;
  85. }
  86. return 0;
  87. }
  88. #ifdef CONFIG_RFS_ACCEL
  89. if (efx->interrupt_mode == EFX_INT_MODE_MSIX) {
  90. efx->net_dev->rx_cpu_rmap =
  91. alloc_irq_cpu_rmap(efx->n_rx_channels);
  92. if (!efx->net_dev->rx_cpu_rmap) {
  93. rc = -ENOMEM;
  94. goto fail1;
  95. }
  96. }
  97. #endif
  98. /* Hook MSI or MSI-X interrupt */
  99. n_irqs = 0;
  100. efx_for_each_channel(channel, efx) {
  101. rc = request_irq(channel->irq, efx->type->irq_handle_msi,
  102. IRQF_PROBE_SHARED, /* Not shared */
  103. efx->msi_context[channel->channel].name,
  104. &efx->msi_context[channel->channel]);
  105. if (rc) {
  106. netif_err(efx, drv, efx->net_dev,
  107. "failed to hook IRQ %d\n", channel->irq);
  108. goto fail2;
  109. }
  110. ++n_irqs;
  111. #ifdef CONFIG_RFS_ACCEL
  112. if (efx->interrupt_mode == EFX_INT_MODE_MSIX &&
  113. channel->channel < efx->n_rx_channels) {
  114. rc = irq_cpu_rmap_add(efx->net_dev->rx_cpu_rmap,
  115. channel->irq);
  116. if (rc)
  117. goto fail2;
  118. }
  119. #endif
  120. }
  121. return 0;
  122. fail2:
  123. #ifdef CONFIG_RFS_ACCEL
  124. free_irq_cpu_rmap(efx->net_dev->rx_cpu_rmap);
  125. efx->net_dev->rx_cpu_rmap = NULL;
  126. #endif
  127. efx_for_each_channel(channel, efx) {
  128. if (n_irqs-- == 0)
  129. break;
  130. free_irq(channel->irq, &efx->msi_context[channel->channel]);
  131. }
  132. fail1:
  133. return rc;
  134. }
  135. void efx_nic_fini_interrupt(struct efx_nic *efx)
  136. {
  137. struct efx_channel *channel;
  138. #ifdef CONFIG_RFS_ACCEL
  139. free_irq_cpu_rmap(efx->net_dev->rx_cpu_rmap);
  140. efx->net_dev->rx_cpu_rmap = NULL;
  141. #endif
  142. if (EFX_INT_MODE_USE_MSI(efx)) {
  143. /* Disable MSI/MSI-X interrupts */
  144. efx_for_each_channel(channel, efx)
  145. free_irq(channel->irq,
  146. &efx->msi_context[channel->channel]);
  147. } else {
  148. /* Disable legacy interrupt */
  149. free_irq(efx->legacy_irq, efx);
  150. }
  151. }
  152. /* Register dump */
  153. #define REGISTER_REVISION_FA 1
  154. #define REGISTER_REVISION_FB 2
  155. #define REGISTER_REVISION_FC 3
  156. #define REGISTER_REVISION_FZ 3 /* last Falcon arch revision */
  157. #define REGISTER_REVISION_ED 4
  158. #define REGISTER_REVISION_EZ 4 /* latest EF10 revision */
  159. struct efx_nic_reg {
  160. u32 offset:24;
  161. u32 min_revision:3, max_revision:3;
  162. };
  163. #define REGISTER(name, arch, min_rev, max_rev) { \
  164. arch ## R_ ## min_rev ## max_rev ## _ ## name, \
  165. REGISTER_REVISION_ ## arch ## min_rev, \
  166. REGISTER_REVISION_ ## arch ## max_rev \
  167. }
  168. #define REGISTER_AA(name) REGISTER(name, F, A, A)
  169. #define REGISTER_AB(name) REGISTER(name, F, A, B)
  170. #define REGISTER_AZ(name) REGISTER(name, F, A, Z)
  171. #define REGISTER_BB(name) REGISTER(name, F, B, B)
  172. #define REGISTER_BZ(name) REGISTER(name, F, B, Z)
  173. #define REGISTER_CZ(name) REGISTER(name, F, C, Z)
  174. #define REGISTER_DZ(name) REGISTER(name, E, D, Z)
  175. static const struct efx_nic_reg efx_nic_regs[] = {
  176. REGISTER_AZ(ADR_REGION),
  177. REGISTER_AZ(INT_EN_KER),
  178. REGISTER_BZ(INT_EN_CHAR),
  179. REGISTER_AZ(INT_ADR_KER),
  180. REGISTER_BZ(INT_ADR_CHAR),
  181. /* INT_ACK_KER is WO */
  182. /* INT_ISR0 is RC */
  183. REGISTER_AZ(HW_INIT),
  184. REGISTER_CZ(USR_EV_CFG),
  185. REGISTER_AB(EE_SPI_HCMD),
  186. REGISTER_AB(EE_SPI_HADR),
  187. REGISTER_AB(EE_SPI_HDATA),
  188. REGISTER_AB(EE_BASE_PAGE),
  189. REGISTER_AB(EE_VPD_CFG0),
  190. /* EE_VPD_SW_CNTL and EE_VPD_SW_DATA are not used */
  191. /* PMBX_DBG_IADDR and PBMX_DBG_IDATA are indirect */
  192. /* PCIE_CORE_INDIRECT is indirect */
  193. REGISTER_AB(NIC_STAT),
  194. REGISTER_AB(GPIO_CTL),
  195. REGISTER_AB(GLB_CTL),
  196. /* FATAL_INTR_KER and FATAL_INTR_CHAR are partly RC */
  197. REGISTER_BZ(DP_CTRL),
  198. REGISTER_AZ(MEM_STAT),
  199. REGISTER_AZ(CS_DEBUG),
  200. REGISTER_AZ(ALTERA_BUILD),
  201. REGISTER_AZ(CSR_SPARE),
  202. REGISTER_AB(PCIE_SD_CTL0123),
  203. REGISTER_AB(PCIE_SD_CTL45),
  204. REGISTER_AB(PCIE_PCS_CTL_STAT),
  205. /* DEBUG_DATA_OUT is not used */
  206. /* DRV_EV is WO */
  207. REGISTER_AZ(EVQ_CTL),
  208. REGISTER_AZ(EVQ_CNT1),
  209. REGISTER_AZ(EVQ_CNT2),
  210. REGISTER_AZ(BUF_TBL_CFG),
  211. REGISTER_AZ(SRM_RX_DC_CFG),
  212. REGISTER_AZ(SRM_TX_DC_CFG),
  213. REGISTER_AZ(SRM_CFG),
  214. /* BUF_TBL_UPD is WO */
  215. REGISTER_AZ(SRM_UPD_EVQ),
  216. REGISTER_AZ(SRAM_PARITY),
  217. REGISTER_AZ(RX_CFG),
  218. REGISTER_BZ(RX_FILTER_CTL),
  219. /* RX_FLUSH_DESCQ is WO */
  220. REGISTER_AZ(RX_DC_CFG),
  221. REGISTER_AZ(RX_DC_PF_WM),
  222. REGISTER_BZ(RX_RSS_TKEY),
  223. /* RX_NODESC_DROP is RC */
  224. REGISTER_AA(RX_SELF_RST),
  225. /* RX_DEBUG, RX_PUSH_DROP are not used */
  226. REGISTER_CZ(RX_RSS_IPV6_REG1),
  227. REGISTER_CZ(RX_RSS_IPV6_REG2),
  228. REGISTER_CZ(RX_RSS_IPV6_REG3),
  229. /* TX_FLUSH_DESCQ is WO */
  230. REGISTER_AZ(TX_DC_CFG),
  231. REGISTER_AA(TX_CHKSM_CFG),
  232. REGISTER_AZ(TX_CFG),
  233. /* TX_PUSH_DROP is not used */
  234. REGISTER_AZ(TX_RESERVED),
  235. REGISTER_BZ(TX_PACE),
  236. /* TX_PACE_DROP_QID is RC */
  237. REGISTER_BB(TX_VLAN),
  238. REGISTER_BZ(TX_IPFIL_PORTEN),
  239. REGISTER_AB(MD_TXD),
  240. REGISTER_AB(MD_RXD),
  241. REGISTER_AB(MD_CS),
  242. REGISTER_AB(MD_PHY_ADR),
  243. REGISTER_AB(MD_ID),
  244. /* MD_STAT is RC */
  245. REGISTER_AB(MAC_STAT_DMA),
  246. REGISTER_AB(MAC_CTRL),
  247. REGISTER_BB(GEN_MODE),
  248. REGISTER_AB(MAC_MC_HASH_REG0),
  249. REGISTER_AB(MAC_MC_HASH_REG1),
  250. REGISTER_AB(GM_CFG1),
  251. REGISTER_AB(GM_CFG2),
  252. /* GM_IPG and GM_HD are not used */
  253. REGISTER_AB(GM_MAX_FLEN),
  254. /* GM_TEST is not used */
  255. REGISTER_AB(GM_ADR1),
  256. REGISTER_AB(GM_ADR2),
  257. REGISTER_AB(GMF_CFG0),
  258. REGISTER_AB(GMF_CFG1),
  259. REGISTER_AB(GMF_CFG2),
  260. REGISTER_AB(GMF_CFG3),
  261. REGISTER_AB(GMF_CFG4),
  262. REGISTER_AB(GMF_CFG5),
  263. REGISTER_BB(TX_SRC_MAC_CTL),
  264. REGISTER_AB(XM_ADR_LO),
  265. REGISTER_AB(XM_ADR_HI),
  266. REGISTER_AB(XM_GLB_CFG),
  267. REGISTER_AB(XM_TX_CFG),
  268. REGISTER_AB(XM_RX_CFG),
  269. REGISTER_AB(XM_MGT_INT_MASK),
  270. REGISTER_AB(XM_FC),
  271. REGISTER_AB(XM_PAUSE_TIME),
  272. REGISTER_AB(XM_TX_PARAM),
  273. REGISTER_AB(XM_RX_PARAM),
  274. /* XM_MGT_INT_MSK (note no 'A') is RC */
  275. REGISTER_AB(XX_PWR_RST),
  276. REGISTER_AB(XX_SD_CTL),
  277. REGISTER_AB(XX_TXDRV_CTL),
  278. /* XX_PRBS_CTL, XX_PRBS_CHK and XX_PRBS_ERR are not used */
  279. /* XX_CORE_STAT is partly RC */
  280. REGISTER_DZ(BIU_HW_REV_ID),
  281. REGISTER_DZ(MC_DB_LWRD),
  282. REGISTER_DZ(MC_DB_HWRD),
  283. };
  284. struct efx_nic_reg_table {
  285. u32 offset:24;
  286. u32 min_revision:3, max_revision:3;
  287. u32 step:6, rows:21;
  288. };
  289. #define REGISTER_TABLE_DIMENSIONS(_, offset, arch, min_rev, max_rev, step, rows) { \
  290. offset, \
  291. REGISTER_REVISION_ ## arch ## min_rev, \
  292. REGISTER_REVISION_ ## arch ## max_rev, \
  293. step, rows \
  294. }
  295. #define REGISTER_TABLE(name, arch, min_rev, max_rev) \
  296. REGISTER_TABLE_DIMENSIONS( \
  297. name, arch ## R_ ## min_rev ## max_rev ## _ ## name, \
  298. arch, min_rev, max_rev, \
  299. arch ## R_ ## min_rev ## max_rev ## _ ## name ## _STEP, \
  300. arch ## R_ ## min_rev ## max_rev ## _ ## name ## _ROWS)
  301. #define REGISTER_TABLE_AA(name) REGISTER_TABLE(name, F, A, A)
  302. #define REGISTER_TABLE_AZ(name) REGISTER_TABLE(name, F, A, Z)
  303. #define REGISTER_TABLE_BB(name) REGISTER_TABLE(name, F, B, B)
  304. #define REGISTER_TABLE_BZ(name) REGISTER_TABLE(name, F, B, Z)
  305. #define REGISTER_TABLE_BB_CZ(name) \
  306. REGISTER_TABLE_DIMENSIONS(name, FR_BZ_ ## name, F, B, B, \
  307. FR_BZ_ ## name ## _STEP, \
  308. FR_BB_ ## name ## _ROWS), \
  309. REGISTER_TABLE_DIMENSIONS(name, FR_BZ_ ## name, F, C, Z, \
  310. FR_BZ_ ## name ## _STEP, \
  311. FR_CZ_ ## name ## _ROWS)
  312. #define REGISTER_TABLE_CZ(name) REGISTER_TABLE(name, F, C, Z)
  313. #define REGISTER_TABLE_DZ(name) REGISTER_TABLE(name, E, D, Z)
  314. static const struct efx_nic_reg_table efx_nic_reg_tables[] = {
  315. /* DRIVER is not used */
  316. /* EVQ_RPTR, TIMER_COMMAND, USR_EV and {RX,TX}_DESC_UPD are WO */
  317. REGISTER_TABLE_BB(TX_IPFIL_TBL),
  318. REGISTER_TABLE_BB(TX_SRC_MAC_TBL),
  319. REGISTER_TABLE_AA(RX_DESC_PTR_TBL_KER),
  320. REGISTER_TABLE_BB_CZ(RX_DESC_PTR_TBL),
  321. REGISTER_TABLE_AA(TX_DESC_PTR_TBL_KER),
  322. REGISTER_TABLE_BB_CZ(TX_DESC_PTR_TBL),
  323. REGISTER_TABLE_AA(EVQ_PTR_TBL_KER),
  324. REGISTER_TABLE_BB_CZ(EVQ_PTR_TBL),
  325. /* We can't reasonably read all of the buffer table (up to 8MB!).
  326. * However this driver will only use a few entries. Reading
  327. * 1K entries allows for some expansion of queue count and
  328. * size before we need to change the version. */
  329. REGISTER_TABLE_DIMENSIONS(BUF_FULL_TBL_KER, FR_AA_BUF_FULL_TBL_KER,
  330. F, A, A, 8, 1024),
  331. REGISTER_TABLE_DIMENSIONS(BUF_FULL_TBL, FR_BZ_BUF_FULL_TBL,
  332. F, B, Z, 8, 1024),
  333. REGISTER_TABLE_CZ(RX_MAC_FILTER_TBL0),
  334. REGISTER_TABLE_BB_CZ(TIMER_TBL),
  335. REGISTER_TABLE_BB_CZ(TX_PACE_TBL),
  336. REGISTER_TABLE_BZ(RX_INDIRECTION_TBL),
  337. /* TX_FILTER_TBL0 is huge and not used by this driver */
  338. REGISTER_TABLE_CZ(TX_MAC_FILTER_TBL0),
  339. REGISTER_TABLE_CZ(MC_TREG_SMEM),
  340. /* MSIX_PBA_TABLE is not mapped */
  341. /* SRM_DBG is not mapped (and is redundant with BUF_FLL_TBL) */
  342. REGISTER_TABLE_BZ(RX_FILTER_TBL0),
  343. REGISTER_TABLE_DZ(BIU_MC_SFT_STATUS),
  344. };
  345. size_t efx_nic_get_regs_len(struct efx_nic *efx)
  346. {
  347. const struct efx_nic_reg *reg;
  348. const struct efx_nic_reg_table *table;
  349. size_t len = 0;
  350. for (reg = efx_nic_regs;
  351. reg < efx_nic_regs + ARRAY_SIZE(efx_nic_regs);
  352. reg++)
  353. if (efx->type->revision >= reg->min_revision &&
  354. efx->type->revision <= reg->max_revision)
  355. len += sizeof(efx_oword_t);
  356. for (table = efx_nic_reg_tables;
  357. table < efx_nic_reg_tables + ARRAY_SIZE(efx_nic_reg_tables);
  358. table++)
  359. if (efx->type->revision >= table->min_revision &&
  360. efx->type->revision <= table->max_revision)
  361. len += table->rows * min_t(size_t, table->step, 16);
  362. return len;
  363. }
  364. void efx_nic_get_regs(struct efx_nic *efx, void *buf)
  365. {
  366. const struct efx_nic_reg *reg;
  367. const struct efx_nic_reg_table *table;
  368. for (reg = efx_nic_regs;
  369. reg < efx_nic_regs + ARRAY_SIZE(efx_nic_regs);
  370. reg++) {
  371. if (efx->type->revision >= reg->min_revision &&
  372. efx->type->revision <= reg->max_revision) {
  373. efx_reado(efx, (efx_oword_t *)buf, reg->offset);
  374. buf += sizeof(efx_oword_t);
  375. }
  376. }
  377. for (table = efx_nic_reg_tables;
  378. table < efx_nic_reg_tables + ARRAY_SIZE(efx_nic_reg_tables);
  379. table++) {
  380. size_t size, i;
  381. if (!(efx->type->revision >= table->min_revision &&
  382. efx->type->revision <= table->max_revision))
  383. continue;
  384. size = min_t(size_t, table->step, 16);
  385. for (i = 0; i < table->rows; i++) {
  386. switch (table->step) {
  387. case 4: /* 32-bit SRAM */
  388. efx_readd(efx, buf, table->offset + 4 * i);
  389. break;
  390. case 8: /* 64-bit SRAM */
  391. efx_sram_readq(efx,
  392. efx->membase + table->offset,
  393. buf, i);
  394. break;
  395. case 16: /* 128-bit-readable register */
  396. efx_reado_table(efx, buf, table->offset, i);
  397. break;
  398. case 32: /* 128-bit register, interleaved */
  399. efx_reado_table(efx, buf, table->offset, 2 * i);
  400. break;
  401. default:
  402. WARN_ON(1);
  403. return;
  404. }
  405. buf += size;
  406. }
  407. }
  408. }
  409. /**
  410. * efx_nic_describe_stats - Describe supported statistics for ethtool
  411. * @desc: Array of &struct efx_hw_stat_desc describing the statistics
  412. * @count: Length of the @desc array
  413. * @mask: Bitmask of which elements of @desc are enabled
  414. * @names: Buffer to copy names to, or %NULL. The names are copied
  415. * starting at intervals of %ETH_GSTRING_LEN bytes.
  416. *
  417. * Returns the number of visible statistics, i.e. the number of set
  418. * bits in the first @count bits of @mask for which a name is defined.
  419. */
  420. size_t efx_nic_describe_stats(const struct efx_hw_stat_desc *desc, size_t count,
  421. const unsigned long *mask, u8 *names)
  422. {
  423. size_t visible = 0;
  424. size_t index;
  425. for_each_set_bit(index, mask, count) {
  426. if (desc[index].name) {
  427. if (names) {
  428. strlcpy(names, desc[index].name,
  429. ETH_GSTRING_LEN);
  430. names += ETH_GSTRING_LEN;
  431. }
  432. ++visible;
  433. }
  434. }
  435. return visible;
  436. }
  437. /**
  438. * efx_nic_update_stats - Convert statistics DMA buffer to array of u64
  439. * @desc: Array of &struct efx_hw_stat_desc describing the DMA buffer
  440. * layout. DMA widths of 0, 16, 32 and 64 are supported; where
  441. * the width is specified as 0 the corresponding element of
  442. * @stats is not updated.
  443. * @count: Length of the @desc array
  444. * @mask: Bitmask of which elements of @desc are enabled
  445. * @stats: Buffer to update with the converted statistics. The length
  446. * of this array must be at least @count.
  447. * @dma_buf: DMA buffer containing hardware statistics
  448. * @accumulate: If set, the converted values will be added rather than
  449. * directly stored to the corresponding elements of @stats
  450. */
  451. void efx_nic_update_stats(const struct efx_hw_stat_desc *desc, size_t count,
  452. const unsigned long *mask,
  453. u64 *stats, const void *dma_buf, bool accumulate)
  454. {
  455. size_t index;
  456. for_each_set_bit(index, mask, count) {
  457. if (desc[index].dma_width) {
  458. const void *addr = dma_buf + desc[index].offset;
  459. u64 val;
  460. switch (desc[index].dma_width) {
  461. case 16:
  462. val = le16_to_cpup((__le16 *)addr);
  463. break;
  464. case 32:
  465. val = le32_to_cpup((__le32 *)addr);
  466. break;
  467. case 64:
  468. val = le64_to_cpup((__le64 *)addr);
  469. break;
  470. default:
  471. WARN_ON(1);
  472. val = 0;
  473. break;
  474. }
  475. if (accumulate)
  476. stats[index] += val;
  477. else
  478. stats[index] = val;
  479. }
  480. }
  481. }
  482. void efx_nic_fix_nodesc_drop_stat(struct efx_nic *efx, u64 *rx_nodesc_drops)
  483. {
  484. /* if down, or this is the first update after coming up */
  485. if (!(efx->net_dev->flags & IFF_UP) || !efx->rx_nodesc_drops_prev_state)
  486. efx->rx_nodesc_drops_while_down +=
  487. *rx_nodesc_drops - efx->rx_nodesc_drops_total;
  488. efx->rx_nodesc_drops_total = *rx_nodesc_drops;
  489. efx->rx_nodesc_drops_prev_state = !!(efx->net_dev->flags & IFF_UP);
  490. *rx_nodesc_drops -= efx->rx_nodesc_drops_while_down;
  491. }