CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Wed Aug 18 09:17:17 UTC 2021 Modified Files: src/sys/dev/pci/ixgbe: ix_txrx.c Log Message: Refresh unrefreshed descriptors' buffers correctly. - Update next_to_refresh at least before ixgbe_rx_unrefresed() to detect the unrefreshed status correctly in ixgbe_rxeof(). - next_to_refresh points to the previous entry of the first unrefreshed descriptor, so fix a loop variable to point to the correct one in ixgbe_refresh_mbufs(). - Without the above two fixes, RX ring may have some unrefreshed entries which have inconsistent state. On such state, "ifconfig down up" causes panic in bus_dmamap_sync() on aarch64. - Tested on amd64 and aarch64. OK'd by knakahara. To generate a diff of this commit: cvs rdiff -u -r1.81 -r1.82 src/sys/dev/pci/ixgbe/ix_txrx.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ix_txrx.c diff -u src/sys/dev/pci/ixgbe/ix_txrx.c:1.81 src/sys/dev/pci/ixgbe/ix_txrx.c:1.82 --- src/sys/dev/pci/ixgbe/ix_txrx.c:1.81 Wed Jul 7 08:58:19 2021 +++ src/sys/dev/pci/ixgbe/ix_txrx.c Wed Aug 18 09:17:17 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: ix_txrx.c,v 1.81 2021/07/07 08:58:19 msaitoh Exp $ */ +/* $NetBSD: ix_txrx.c,v 1.82 2021/08/18 09:17:17 msaitoh Exp $ */ /** @@ -64,7 +64,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ix_txrx.c,v 1.81 2021/07/07 08:58:19 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ix_txrx.c,v 1.82 2021/08/18 09:17:17 msaitoh Exp $"); #include "opt_inet.h" #include "opt_inet6.h" @@ -1336,15 +1336,15 @@ ixgbe_refresh_mbufs(struct rx_ring *rxr, struct adapter *adapter = rxr->adapter; struct ixgbe_rx_buf *rxbuf; struct mbuf *mp; - int i, j, error; + int i, error; boolrefreshed = false; - i = j = rxr->next_to_refresh; - /* Control the loop with one beyond */ - if (++j == rxr->num_desc) - j = 0; + i = rxr->next_to_refresh; + /* next_to_refresh points to the previous one */ + if (++i == rxr->num_desc) + i = 0; - while (j != limit) { + while (i != limit) { rxbuf = >rx_buffers[i]; if (rxbuf->buf == NULL) { mp = ixgbe_getjcl(>jcl_head, M_NOWAIT, @@ -1387,11 +1387,10 @@ ixgbe_refresh_mbufs(struct rx_ring *rxr, } refreshed = true; - /* Next is precalculated */ - i = j; + /* next_to_refresh points to the previous one */ rxr->next_to_refresh = i; - if (++j == rxr->num_desc) - j = 0; + if (++i == rxr->num_desc) + i = 0; } update: @@ -2090,6 +2089,7 @@ next_desc: /* Advance our pointers to the next descriptor. */ if (++i == rxr->num_desc) i = 0; + rxr->next_to_check = i; /* Now send to the stack or do LRO */ if (sendmp != NULL) { @@ -2107,8 +2107,6 @@ next_desc: if (ixgbe_rx_unrefreshed(rxr)) ixgbe_refresh_mbufs(rxr, i); - rxr->next_to_check = i; - IXGBE_RX_UNLOCK(rxr); #ifdef LRO
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Thu Jul 15 08:09:31 UTC 2021 Modified Files: src/sys/dev/pci/ixgbe: ixgbe.c ixv.c Log Message: Add a new sysctl to read rxr->next_to_refresh. To generate a diff of this commit: cvs rdiff -u -r1.286 -r1.287 src/sys/dev/pci/ixgbe/ixgbe.c cvs rdiff -u -r1.163 -r1.164 src/sys/dev/pci/ixgbe/ixv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.286 src/sys/dev/pci/ixgbe/ixgbe.c:1.287 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.286 Wed Jul 7 08:58:19 2021 +++ src/sys/dev/pci/ixgbe/ixgbe.c Thu Jul 15 08:09:31 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.286 2021/07/07 08:58:19 msaitoh Exp $ */ +/* $NetBSD: ixgbe.c,v 1.287 2021/07/15 08:09:31 msaitoh Exp $ */ /** @@ -64,7 +64,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ixgbe.c,v 1.286 2021/07/07 08:58:19 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ixgbe.c,v 1.287 2021/07/15 08:09:31 msaitoh Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -253,6 +253,7 @@ static int ixgbe_sysctl_power_state(SYSC static int ixgbe_sysctl_print_rss_config(SYSCTLFN_PROTO); #endif static int ixgbe_sysctl_next_to_check_handler(SYSCTLFN_PROTO); +static int ixgbe_sysctl_next_to_refresh_handler(SYSCTLFN_PROTO); static int ixgbe_sysctl_rdh_handler(SYSCTLFN_PROTO); static int ixgbe_sysctl_rdt_handler(SYSCTLFN_PROTO); static int ixgbe_sysctl_tdt_handler(SYSCTLFN_PROTO); @@ -1930,6 +1931,13 @@ ixgbe_add_hw_stats(struct adapter *adapt break; if (sysctl_createv(log, 0, , , + CTLFLAG_READONLY, CTLTYPE_INT, "rxd_nxrf", + SYSCTL_DESCR("Receive Descriptor next to refresh"), + ixgbe_sysctl_next_to_refresh_handler, 0, (void *)rxr, 0, + CTL_CREATE, CTL_EOL) != 0) + break; + + if (sysctl_createv(log, 0, , , CTLFLAG_READONLY, CTLTYPE_INT, "rxd_head", SYSCTL_DESCR("Receive Descriptor Head"), ixgbe_sysctl_rdh_handler, 0, (void *)rxr, 0, @@ -2302,6 +2310,32 @@ ixgbe_sysctl_next_to_check_handler(SYSCT } /* ixgbe_sysctl_next_to_check_handler */ / + * ixgbe_sysctl_next_to_refresh_handler - Receive Descriptor next to check + * handler function + * + * Retrieves the next_to_refresh value + / +static int +ixgbe_sysctl_next_to_refresh_handler(SYSCTLFN_ARGS) +{ + struct sysctlnode node = *rnode; + struct rx_ring *rxr = (struct rx_ring *)node.sysctl_data; + struct adapter *adapter; + uint32_t val; + + if (!rxr) + return (0); + + adapter = rxr->adapter; + if (ixgbe_fw_recovery_mode_swflag(adapter)) + return (EPERM); + + val = rxr->next_to_refresh; + node.sysctl_data = + return sysctl_lookup(SYSCTLFN_CALL()); +} /* ixgbe_sysctl_next_to_refresh_handler */ + +/ * ixgbe_sysctl_rdh_handler - Receive Descriptor Head handler function * * Retrieves the RDH value from the hardware Index: src/sys/dev/pci/ixgbe/ixv.c diff -u src/sys/dev/pci/ixgbe/ixv.c:1.163 src/sys/dev/pci/ixgbe/ixv.c:1.164 --- src/sys/dev/pci/ixgbe/ixv.c:1.163 Wed Jul 7 08:58:19 2021 +++ src/sys/dev/pci/ixgbe/ixv.c Thu Jul 15 08:09:31 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: ixv.c,v 1.163 2021/07/07 08:58:19 msaitoh Exp $ */ +/* $NetBSD: ixv.c,v 1.164 2021/07/15 08:09:31 msaitoh Exp $ */ /** @@ -35,7 +35,7 @@ /*$FreeBSD: head/sys/dev/ixgbe/if_ixv.c 331224 2018-03-19 20:55:05Z erj $*/ #include -__KERNEL_RCSID(0, "$NetBSD: ixv.c,v 1.163 2021/07/07 08:58:19 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ixv.c,v 1.164 2021/07/15 08:09:31 msaitoh Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -144,6 +144,7 @@ static void ixv_set_sysctl_value(struct const char *, int *, int); static int ixv_sysctl_interrupt_rate_handler(SYSCTLFN_PROTO); static int ixv_sysctl_next_to_check_handler(SYSCTLFN_PROTO); +static int ixv_sysctl_next_to_refresh_handler(SYSCTLFN_PROTO); static int ixv_sysctl_rdh_handler(SYSCTLFN_PROTO); static int ixv_sysctl_rdt_handler(SYSCTLFN_PROTO); static int ixv_sysctl_tdt_handler(SYSCTLFN_PROTO); @@ -2033,6 +2034,32 @@ ixv_sysctl_next_to_check_handler(SYSCTLF } /* ixv_sysctl_next_to_check_handler */ / + * ixv_sysctl_next_to_refresh_handler - Receive Descriptor next to refresh + * handler function + * + * Retrieves the next_to_refresh value + / +static int +ixv_sysctl_next_to_refresh_handler(SYSCTLFN_ARGS) +{ + struct sysctlnode node = *rnode; + struct rx_ring *rxr = (struct rx_ring
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Wed Jul 7 08:58:20 UTC 2021 Modified Files: src/sys/dev/pci/ixgbe: ix_txrx.c ixgbe.c ixgbe.h ixv.c Log Message: Add new sysctl "rx_copy_len". ixgbe_rxeof() has an optimization "RX_COPY" to reduce costs of bus_dmamap_load_mbuf() and bus_dmamap_unload() by copying a mbuf cluster's memory to a newly allocated mbuf's MH_databuf[] and recycle the original map. The optimization is used when a length of a packet is smaller than a specific value. The value is calculated based on MHLEN. The size of MHLEN is architecture specific. It's 256 or 512. Make the threshold controllable by adding a new sysctl. To generate a diff of this commit: cvs rdiff -u -r1.80 -r1.81 src/sys/dev/pci/ixgbe/ix_txrx.c cvs rdiff -u -r1.285 -r1.286 src/sys/dev/pci/ixgbe/ixgbe.c cvs rdiff -u -r1.75 -r1.76 src/sys/dev/pci/ixgbe/ixgbe.h cvs rdiff -u -r1.162 -r1.163 src/sys/dev/pci/ixgbe/ixv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ix_txrx.c diff -u src/sys/dev/pci/ixgbe/ix_txrx.c:1.80 src/sys/dev/pci/ixgbe/ix_txrx.c:1.81 --- src/sys/dev/pci/ixgbe/ix_txrx.c:1.80 Wed Jul 7 08:32:51 2021 +++ src/sys/dev/pci/ixgbe/ix_txrx.c Wed Jul 7 08:58:19 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: ix_txrx.c,v 1.80 2021/07/07 08:32:51 msaitoh Exp $ */ +/* $NetBSD: ix_txrx.c,v 1.81 2021/07/07 08:58:19 msaitoh Exp $ */ /** @@ -64,7 +64,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ix_txrx.c,v 1.80 2021/07/07 08:32:51 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ix_txrx.c,v 1.81 2021/07/07 08:58:19 msaitoh Exp $"); #include "opt_inet.h" #include "opt_inet6.h" @@ -1976,7 +1976,7 @@ ixgbe_rxeof(struct ix_queue *que) * is cache aligned into a new mbuf, and * leave the old mbuf+cluster for re-use. */ - if (eop && len <= IXGBE_RX_COPY_LEN) { + if (eop && len <= adapter->rx_copy_len) { sendmp = m_gethdr(M_NOWAIT, MT_DATA); if (sendmp != NULL) { sendmp->m_data += IXGBE_RX_COPY_ALIGN; Index: src/sys/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.285 src/sys/dev/pci/ixgbe/ixgbe.c:1.286 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.285 Tue Jun 29 21:03:36 2021 +++ src/sys/dev/pci/ixgbe/ixgbe.c Wed Jul 7 08:58:19 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.285 2021/06/29 21:03:36 pgoyette Exp $ */ +/* $NetBSD: ixgbe.c,v 1.286 2021/07/07 08:58:19 msaitoh Exp $ */ /** @@ -64,7 +64,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ixgbe.c,v 1.285 2021/06/29 21:03:36 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ixgbe.c,v 1.286 2021/07/07 08:58:19 msaitoh Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -259,6 +259,7 @@ static int ixgbe_sysctl_tdt_handler(SYSC static int ixgbe_sysctl_tdh_handler(SYSCTLFN_PROTO); static int ixgbe_sysctl_eee_state(SYSCTLFN_PROTO); static int ixgbe_sysctl_debug(SYSCTLFN_PROTO); +static int ixgbe_sysctl_rx_copy_len(SYSCTLFN_PROTO); static int ixgbe_sysctl_wol_enable(SYSCTLFN_PROTO); static int ixgbe_sysctl_wufc(SYSCTLFN_PROTO); @@ -986,6 +987,9 @@ ixgbe_attach(device_t parent, device_t d } else adapter->num_rx_desc = ixgbe_rxd; + /* Set default high limit of copying mbuf in rxeof */ + adapter->rx_copy_len = IXGBE_RX_COPY_LEN_MAX; + adapter->num_jcl = adapter->num_rx_desc * IXGBE_JCLNUM_MULTI; /* Allocate our TX/RX Queues */ @@ -3368,6 +3372,13 @@ ixgbe_add_device_sysctls(struct adapter aprint_error_dev(dev, "could not create sysctl\n"); if (sysctl_createv(log, 0, , , + CTLFLAG_READWRITE, CTLTYPE_INT, + "rx_copy_len", SYSCTL_DESCR("RX Copy Length"), + ixgbe_sysctl_rx_copy_len, 0, + (void *)adapter, 0, CTL_CREATE, CTL_EOL) != 0) + aprint_error_dev(dev, "could not create sysctl\n"); + + if (sysctl_createv(log, 0, , , CTLFLAG_READONLY, CTLTYPE_INT, "num_rx_desc", SYSCTL_DESCR("Number of rx descriptors"), NULL, 0, >num_rx_desc, 0, CTL_CREATE, CTL_EOL) != 0) @@ -6174,6 +6185,31 @@ ixgbe_sysctl_debug(SYSCTLFN_ARGS) } /* ixgbe_sysctl_debug */ / + * ixgbe_sysctl_rx_copy_len + / +static int +ixgbe_sysctl_rx_copy_len(SYSCTLFN_ARGS) +{ + struct sysctlnode node = *rnode; + struct adapter *adapter = (struct adapter *)node.sysctl_data; + int error; + int result = adapter->rx_copy_len; + + node.sysctl_data = + error = sysctl_lookup(SYSCTLFN_CALL()); + + if (error || newp == NULL) + return error; + + if ((result < 0) || (result > IXGBE_RX_COPY_LEN_MAX)) + return EINVAL; + + adapter->rx_copy_len = result; + + return 0; +} /* ixgbe_sysctl_rx_copy_len */ + +/ *
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Wed Jul 7 08:32:51 UTC 2021 Modified Files: src/sys/dev/pci/ixgbe: ix_txrx.c Log Message: Set rxr->next_to_refresh correctly in ixgbe_setup_receive_ring(). ixgbe_setup_receive_ring() fully allocates rx buffers. When a descriptor ring is full, rxr->next_to_refresh should point to rxr_next_to_check -1. Before this change, rxr->next_to_refresh is set to 0 and ixgbe_refresh_mbufs() wastefully loops in ixgbe_refresh_mbufs() because it means the ring is empty. To generate a diff of this commit: cvs rdiff -u -r1.79 -r1.80 src/sys/dev/pci/ixgbe/ix_txrx.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ix_txrx.c diff -u src/sys/dev/pci/ixgbe/ix_txrx.c:1.79 src/sys/dev/pci/ixgbe/ix_txrx.c:1.80 --- src/sys/dev/pci/ixgbe/ix_txrx.c:1.79 Thu May 27 06:11:34 2021 +++ src/sys/dev/pci/ixgbe/ix_txrx.c Wed Jul 7 08:32:51 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: ix_txrx.c,v 1.79 2021/05/27 06:11:34 msaitoh Exp $ */ +/* $NetBSD: ix_txrx.c,v 1.80 2021/07/07 08:32:51 msaitoh Exp $ */ /** @@ -64,7 +64,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ix_txrx.c,v 1.79 2021/05/27 06:11:34 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ix_txrx.c,v 1.80 2021/07/07 08:32:51 msaitoh Exp $"); #include "opt_inet.h" #include "opt_inet6.h" @@ -1577,7 +1577,7 @@ ixgbe_setup_receive_ring(struct rx_ring /* Setup our descriptor indices */ rxr->next_to_check = 0; - rxr->next_to_refresh = 0; + rxr->next_to_refresh = adapter->num_rx_desc - 1; /* Fully allocated */ rxr->lro_enabled = FALSE; rxr->rx_copies.ev_count = 0; #if 0 /* NetBSD */
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Thu May 27 06:11:35 UTC 2021 Modified Files: src/sys/dev/pci/ixgbe: ix_txrx.c Log Message: Do no_jmbuf++ when ixgbe_getjcl() failed in ixgbe_setup_receive_ring(), too. To generate a diff of this commit: cvs rdiff -u -r1.78 -r1.79 src/sys/dev/pci/ixgbe/ix_txrx.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ix_txrx.c diff -u src/sys/dev/pci/ixgbe/ix_txrx.c:1.78 src/sys/dev/pci/ixgbe/ix_txrx.c:1.79 --- src/sys/dev/pci/ixgbe/ix_txrx.c:1.78 Thu May 20 22:36:08 2021 +++ src/sys/dev/pci/ixgbe/ix_txrx.c Thu May 27 06:11:34 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: ix_txrx.c,v 1.78 2021/05/20 22:36:08 ryo Exp $ */ +/* $NetBSD: ix_txrx.c,v 1.79 2021/05/27 06:11:34 msaitoh Exp $ */ /** @@ -64,7 +64,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ix_txrx.c,v 1.78 2021/05/20 22:36:08 ryo Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ix_txrx.c,v 1.79 2021/05/27 06:11:34 msaitoh Exp $"); #include "opt_inet.h" #include "opt_inet6.h" @@ -1548,6 +1548,7 @@ ixgbe_setup_receive_ring(struct rx_ring rxbuf->buf = ixgbe_getjcl(>jcl_head, M_NOWAIT, MT_DATA, M_PKTHDR, adapter->rx_mbuf_sz); if (rxbuf->buf == NULL) { + rxr->no_jmbuf.ev_count++; error = ENOBUFS; goto fail; }
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: ryo Date: Thu May 20 22:36:09 UTC 2021 Modified Files: src/sys/dev/pci/ixgbe: ix_txrx.c Log Message: fix little-endian dependence To generate a diff of this commit: cvs rdiff -u -r1.77 -r1.78 src/sys/dev/pci/ixgbe/ix_txrx.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ix_txrx.c diff -u src/sys/dev/pci/ixgbe/ix_txrx.c:1.77 src/sys/dev/pci/ixgbe/ix_txrx.c:1.78 --- src/sys/dev/pci/ixgbe/ix_txrx.c:1.77 Thu May 20 10:39:32 2021 +++ src/sys/dev/pci/ixgbe/ix_txrx.c Thu May 20 22:36:08 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: ix_txrx.c,v 1.77 2021/05/20 10:39:32 msaitoh Exp $ */ +/* $NetBSD: ix_txrx.c,v 1.78 2021/05/20 22:36:08 ryo Exp $ */ /** @@ -64,7 +64,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ix_txrx.c,v 1.77 2021/05/20 10:39:32 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ix_txrx.c,v 1.78 2021/05/20 22:36:08 ryo Exp $"); #include "opt_inet.h" #include "opt_inet6.h" @@ -1125,7 +1125,7 @@ ixgbe_txeof(struct tx_ring *txr) * or the slot has the DD bit set. */ if (kring->nr_kflags < kring->nkr_num_slots && - txd[kring->nr_kflags].wb.status & IXGBE_TXD_STAT_DD) { + le32toh(txd[kring->nr_kflags].wb.status) & IXGBE_TXD_STAT_DD) { netmap_tx_irq(ifp, txr->me); } return false; @@ -1150,7 +1150,7 @@ ixgbe_txeof(struct tx_ring *txr) if (eop == NULL) /* No work */ break; - if ((eop->wb.status & IXGBE_TXD_STAT_DD) == 0) + if ((le32toh(eop->wb.status) & IXGBE_TXD_STAT_DD) == 0) break; /* I/O not complete */ if (buf->m_head) {
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Thu May 20 10:39:32 UTC 2021 Modified Files: src/sys/dev/pci/ixgbe: ix_txrx.c Log Message: Use uint64_t instead of bus_addr_t for the TX descriptor's buffer address. At least, this change is required for macppc (sizeof(bus_addr_t) == 4) to make TX work. To generate a diff of this commit: cvs rdiff -u -r1.76 -r1.77 src/sys/dev/pci/ixgbe/ix_txrx.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ix_txrx.c diff -u src/sys/dev/pci/ixgbe/ix_txrx.c:1.76 src/sys/dev/pci/ixgbe/ix_txrx.c:1.77 --- src/sys/dev/pci/ixgbe/ix_txrx.c:1.76 Thu May 20 01:02:42 2021 +++ src/sys/dev/pci/ixgbe/ix_txrx.c Thu May 20 10:39:32 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: ix_txrx.c,v 1.76 2021/05/20 01:02:42 ryo Exp $ */ +/* $NetBSD: ix_txrx.c,v 1.77 2021/05/20 10:39:32 msaitoh Exp $ */ /** @@ -64,7 +64,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ix_txrx.c,v 1.76 2021/05/20 01:02:42 ryo Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ix_txrx.c,v 1.77 2021/05/20 10:39:32 msaitoh Exp $"); #include "opt_inet.h" #include "opt_inet6.h" @@ -501,7 +501,7 @@ retry: i = txr->next_avail_desc; for (j = 0; j < map->dm_nsegs; j++) { bus_size_t seglen; - bus_addr_t segaddr; + uint64_t segaddr; txbuf = >tx_buffers[i]; txd = >tx_base[i];
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: ryo Date: Thu May 20 01:02:42 UTC 2021 Modified Files: src/sys/dev/pci/ixgbe: ix_txrx.c Log Message: Added BUS_DMA_COHERENT flag to bus_dmamem_map() to improve stability on aarch64. In ixgbe, TX/RX descriptor rings are configured in 16-byte units. If BUS_DMA_COHERENT is not specified, cpu cache (writeback/invalidate) operations by bus_dmamap_sync() in aarch64 (arm/arm32/bus_dma.c) are done per cache line size (usually 64 bytes). As a result, adjacent descriptors conflict with the DMA operation, resulting in unstable operation. To avoid this, descriptors area should be mapped as non-cache with BUS_DMA_COHERENT. thanks to msaitoh@ for his help in debugging. To generate a diff of this commit: cvs rdiff -u -r1.75 -r1.76 src/sys/dev/pci/ixgbe/ix_txrx.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ix_txrx.c diff -u src/sys/dev/pci/ixgbe/ix_txrx.c:1.75 src/sys/dev/pci/ixgbe/ix_txrx.c:1.76 --- src/sys/dev/pci/ixgbe/ix_txrx.c:1.75 Tue May 18 05:29:15 2021 +++ src/sys/dev/pci/ixgbe/ix_txrx.c Thu May 20 01:02:42 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: ix_txrx.c,v 1.75 2021/05/18 05:29:15 msaitoh Exp $ */ +/* $NetBSD: ix_txrx.c,v 1.76 2021/05/20 01:02:42 ryo Exp $ */ /** @@ -64,7 +64,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ix_txrx.c,v 1.75 2021/05/18 05:29:15 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ix_txrx.c,v 1.76 2021/05/20 01:02:42 ryo Exp $"); #include "opt_inet.h" #include "opt_inet6.h" @@ -2208,7 +2208,7 @@ ixgbe_dma_malloc(struct adapter *adapter } r = bus_dmamem_map(dma->dma_tag->dt_dmat, >dma_seg, rsegs, - size, >dma_vaddr, BUS_DMA_NOWAIT); + size, >dma_vaddr, BUS_DMA_NOWAIT | BUS_DMA_COHERENT); if (r != 0) { aprint_error_dev(dev, "%s: bus_dmamem_map failed; error %d\n", __func__, r);
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Wed May 19 08:19:20 UTC 2021 Modified Files: src/sys/dev/pci/ixgbe: ixgbe_dcb_82598.h ixgbe_netbsd.h ixgbe_type.h ixgbe_x540.c ixgbe_x550.c ixv.c Log Message: No functional change: - Add NetBSD RCS IDs. - KNF. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/dev/pci/ixgbe/ixgbe_dcb_82598.h cvs rdiff -u -r1.12 -r1.13 src/sys/dev/pci/ixgbe/ixgbe_netbsd.h cvs rdiff -u -r1.48 -r1.49 src/sys/dev/pci/ixgbe/ixgbe_type.h cvs rdiff -u -r1.18 -r1.19 src/sys/dev/pci/ixgbe/ixgbe_x540.c cvs rdiff -u -r1.19 -r1.20 src/sys/dev/pci/ixgbe/ixgbe_x550.c cvs rdiff -u -r1.160 -r1.161 src/sys/dev/pci/ixgbe/ixv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ixgbe_dcb_82598.h diff -u src/sys/dev/pci/ixgbe/ixgbe_dcb_82598.h:1.6 src/sys/dev/pci/ixgbe/ixgbe_dcb_82598.h:1.7 --- src/sys/dev/pci/ixgbe/ixgbe_dcb_82598.h:1.6 Wed Apr 4 08:13:07 2018 +++ src/sys/dev/pci/ixgbe/ixgbe_dcb_82598.h Wed May 19 08:19:20 2021 @@ -1,3 +1,5 @@ +/* $NetBSD: ixgbe_dcb_82598.h,v 1.7 2021/05/19 08:19:20 msaitoh Exp $ */ + /** SPDX-License-Identifier: BSD-3-Clause Index: src/sys/dev/pci/ixgbe/ixgbe_netbsd.h diff -u src/sys/dev/pci/ixgbe/ixgbe_netbsd.h:1.12 src/sys/dev/pci/ixgbe/ixgbe_netbsd.h:1.13 --- src/sys/dev/pci/ixgbe/ixgbe_netbsd.h:1.12 Tue Mar 9 10:03:18 2021 +++ src/sys/dev/pci/ixgbe/ixgbe_netbsd.h Wed May 19 08:19:20 2021 @@ -1,4 +1,4 @@ -/*$NetBSD: ixgbe_netbsd.h,v 1.12 2021/03/09 10:03:18 msaitoh Exp $*/ +/* $NetBSD: ixgbe_netbsd.h,v 1.13 2021/05/19 08:19:20 msaitoh Exp $ */ /* * Copyright (c) 2011 The NetBSD Foundation, Inc. * All rights reserved. @@ -96,8 +96,8 @@ struct ixgbe_extmem_head { booleh_initialized; }; -int ixgbe_dma_tag_create(bus_dma_tag_t, bus_size_t, bus_size_t, bus_size_t, int, -bus_size_t, int, ixgbe_dma_tag_t **); +int ixgbe_dma_tag_create(bus_dma_tag_t, bus_size_t, bus_size_t, bus_size_t, +int, bus_size_t, int, ixgbe_dma_tag_t **); void ixgbe_dma_tag_destroy(ixgbe_dma_tag_t *); int ixgbe_dmamap_create(ixgbe_dma_tag_t *, int, bus_dmamap_t *); void ixgbe_dmamap_destroy(ixgbe_dma_tag_t *, bus_dmamap_t); Index: src/sys/dev/pci/ixgbe/ixgbe_type.h diff -u src/sys/dev/pci/ixgbe/ixgbe_type.h:1.48 src/sys/dev/pci/ixgbe/ixgbe_type.h:1.49 --- src/sys/dev/pci/ixgbe/ixgbe_type.h:1.48 Sat Dec 26 06:10:17 2020 +++ src/sys/dev/pci/ixgbe/ixgbe_type.h Wed May 19 08:19:20 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe_type.h,v 1.48 2020/12/26 06:10:17 msaitoh Exp $ */ +/* $NetBSD: ixgbe_type.h,v 1.49 2021/05/19 08:19:20 msaitoh Exp $ */ /** SPDX-License-Identifier: BSD-3-Clause @@ -2782,7 +2782,7 @@ enum { #define IXGBE_RXDADV_ERR_FDIR_LEN 0x0010 /* FDIR Length error */ #define IXGBE_RXDADV_ERR_FDIR_DROP 0x0020 /* FDIR Drop error */ #define IXGBE_RXDADV_ERR_FDIR_COLL 0x0040 /* FDIR Collision error */ -#define IXGBE_RXDADV_ERR_HBO 0x0080 /*Header Buffer Overflow */ +#define IXGBE_RXDADV_ERR_HBO 0x0080 /* Header Buffer Overflow */ #define IXGBE_RXDADV_ERR_CE 0x0100 /* CRC Error */ #define IXGBE_RXDADV_ERR_LE 0x0200 /* Length Error */ #define IXGBE_RXDADV_ERR_PE 0x0800 /* Packet Error */ Index: src/sys/dev/pci/ixgbe/ixgbe_x540.c diff -u src/sys/dev/pci/ixgbe/ixgbe_x540.c:1.18 src/sys/dev/pci/ixgbe/ixgbe_x540.c:1.19 --- src/sys/dev/pci/ixgbe/ixgbe_x540.c:1.18 Fri Apr 30 06:55:32 2021 +++ src/sys/dev/pci/ixgbe/ixgbe_x540.c Wed May 19 08:19:20 2021 @@ -1,3 +1,5 @@ +/* $NetBSD: ixgbe_x540.c,v 1.19 2021/05/19 08:19:20 msaitoh Exp $ */ + /** SPDX-License-Identifier: BSD-3-Clause @@ -34,7 +36,7 @@ /*$FreeBSD: head/sys/dev/ixgbe/ixgbe_x540.c 331224 2018-03-19 20:55:05Z erj $*/ #include -__KERNEL_RCSID(0, "$NetBSD: ixgbe_x540.c,v 1.18 2021/04/30 06:55:32 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ixgbe_x540.c,v 1.19 2021/05/19 08:19:20 msaitoh Exp $"); #include "ixgbe_x540.h" #include "ixgbe_type.h" Index: src/sys/dev/pci/ixgbe/ixgbe_x550.c diff -u src/sys/dev/pci/ixgbe/ixgbe_x550.c:1.19 src/sys/dev/pci/ixgbe/ixgbe_x550.c:1.20 --- src/sys/dev/pci/ixgbe/ixgbe_x550.c:1.19 Fri Apr 30 06:55:32 2021 +++ src/sys/dev/pci/ixgbe/ixgbe_x550.c Wed May 19 08:19:20 2021 @@ -1,3 +1,5 @@ +/* $NetBSD: ixgbe_x550.c,v 1.20 2021/05/19 08:19:20 msaitoh Exp $ */ + /** Copyright (c) 2001-2017, Intel Corporation @@ -33,7 +35,7 @@ /*$FreeBSD: head/sys/dev/ixgbe/ixgbe_x550.c 331224 2018-03-19 20:55:05Z erj $*/ #include -__KERNEL_RCSID(0, "$NetBSD: ixgbe_x550.c,v 1.19 2021/04/30 06:55:32 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ixgbe_x550.c,v 1.20 2021/05/19
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Tue May 18 05:29:16 UTC 2021 Modified Files: src/sys/dev/pci/ixgbe: ix_txrx.c ixgbe.c ixv.c Log Message: - Cleanup an rxbuf entry when bus_dmamap_load_mbuf() failed to prevent panic. - Print error number when error occurred. To generate a diff of this commit: cvs rdiff -u -r1.74 -r1.75 src/sys/dev/pci/ixgbe/ix_txrx.c cvs rdiff -u -r1.282 -r1.283 src/sys/dev/pci/ixgbe/ixgbe.c cvs rdiff -u -r1.159 -r1.160 src/sys/dev/pci/ixgbe/ixv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ix_txrx.c diff -u src/sys/dev/pci/ixgbe/ix_txrx.c:1.74 src/sys/dev/pci/ixgbe/ix_txrx.c:1.75 --- src/sys/dev/pci/ixgbe/ix_txrx.c:1.74 Fri May 14 05:15:17 2021 +++ src/sys/dev/pci/ixgbe/ix_txrx.c Tue May 18 05:29:15 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: ix_txrx.c,v 1.74 2021/05/14 05:15:17 msaitoh Exp $ */ +/* $NetBSD: ix_txrx.c,v 1.75 2021/05/18 05:29:15 msaitoh Exp $ */ /** @@ -64,7 +64,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ix_txrx.c,v 1.74 2021/05/14 05:15:17 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ix_txrx.c,v 1.75 2021/05/18 05:29:15 msaitoh Exp $"); #include "opt_inet.h" #include "opt_inet6.h" @@ -1556,8 +1556,16 @@ ixgbe_setup_receive_ring(struct rx_ring /* Get the memory mapping */ error = bus_dmamap_load_mbuf(rxr->ptag->dt_dmat, rxbuf->pmap, mp, BUS_DMA_NOWAIT); - if (error != 0) + if (error != 0) { + /* + * Clear this entry for later cleanup in + * ixgbe_discard() which is called via + * ixgbe_free_receive_ring(). + */ + m_freem(mp); + rxbuf->buf = NULL; goto fail; + } bus_dmamap_sync(rxr->ptag->dt_dmat, rxbuf->pmap, 0, adapter->rx_mbuf_sz, BUS_DMASYNC_PREREAD); /* Update the descriptor and the cached value */ Index: src/sys/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.282 src/sys/dev/pci/ixgbe/ixgbe.c:1.283 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.282 Fri May 7 09:15:52 2021 +++ src/sys/dev/pci/ixgbe/ixgbe.c Tue May 18 05:29:16 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.282 2021/05/07 09:15:52 msaitoh Exp $ */ +/* $NetBSD: ixgbe.c,v 1.283 2021/05/18 05:29:16 msaitoh Exp $ */ /** @@ -64,7 +64,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ixgbe.c,v 1.282 2021/05/07 09:15:52 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ixgbe.c,v 1.283 2021/05/18 05:29:16 msaitoh Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -3984,7 +3984,7 @@ ixgbe_init_locked(struct adapter *adapte u32 rxdctl, rxctrl; u32 ctrl_ext; bool unsupported_sfp = false; - int i, j, err; + int i, j, error; /* XXX check IFF_UP and IFF_RUNNING, power-saving state! */ @@ -4042,8 +4042,10 @@ ixgbe_init_locked(struct adapter *adapte adapter->rx_mbuf_sz = MJUMPAGESIZE; /* Prepare receive descriptors and buffers */ - if (ixgbe_setup_receive_structures(adapter)) { - device_printf(dev, "Could not setup receive structures\n"); + error = ixgbe_setup_receive_structures(adapter); + if (error) { + device_printf(dev, + "Could not setup receive structures (err = %d)\n", error); ixgbe_stop_locked(adapter); return; } @@ -4173,8 +4175,8 @@ ixgbe_init_locked(struct adapter *adapte * need to be kick-started */ if (hw->phy.type == ixgbe_phy_none) { - err = hw->phy.ops.identify(hw); - if (err == IXGBE_ERR_SFP_NOT_SUPPORTED) + error = hw->phy.ops.identify(hw); + if (error == IXGBE_ERR_SFP_NOT_SUPPORTED) unsupported_sfp = true; } else if (hw->phy.type == ixgbe_phy_sfp_unsupported) unsupported_sfp = true; Index: src/sys/dev/pci/ixgbe/ixv.c diff -u src/sys/dev/pci/ixgbe/ixv.c:1.159 src/sys/dev/pci/ixgbe/ixv.c:1.160 --- src/sys/dev/pci/ixgbe/ixv.c:1.159 Fri Apr 30 06:55:32 2021 +++ src/sys/dev/pci/ixgbe/ixv.c Tue May 18 05:29:16 2021 @@ -1,4 +1,4 @@ -/*$NetBSD: ixv.c,v 1.159 2021/04/30 06:55:32 msaitoh Exp $*/ +/*$NetBSD: ixv.c,v 1.160 2021/05/18 05:29:16 msaitoh Exp $*/ /** @@ -35,7 +35,7 @@ /*$FreeBSD: head/sys/dev/ixgbe/if_ixv.c 331224 2018-03-19 20:55:05Z erj $*/ #include -__KERNEL_RCSID(0, "$NetBSD: ixv.c,v 1.159 2021/04/30 06:55:32 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ixv.c,v 1.160 2021/05/18 05:29:16 msaitoh Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -756,8 +756,10 @@ ixv_init_locked(struct adapter *adapter) adapter->rx_mbuf_sz = MJUMPAGESIZE; /* Prepare receive descriptors and buffers */ - if (ixgbe_setup_receive_structures(adapter)) { - device_printf(dev, "Could not setup receive structures\n"); + error = ixgbe_setup_receive_structures(adapter); + if (error) { + device_printf(dev, + "Could not setup receive structures (err = %d)\n", error);
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Fri May 14 05:15:17 UTC 2021 Modified Files: src/sys/dev/pci/ixgbe: ix_txrx.c Log Message: Keep m_len and m_pkthdr.len consistent to prevent panic on arm. Arm's bus_dmamap_load_mbuf() keeps a pointer to the original mbuf and bus_dmamap_sync() refers it. ixgbe_rxeof() modified mbuf's m_len inconsistently with m_pkthdr and dm_mapsize. "ifconfig down up" made panic by referring the inconsistent mbuf length. To generate a diff of this commit: cvs rdiff -u -r1.73 -r1.74 src/sys/dev/pci/ixgbe/ix_txrx.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ix_txrx.c diff -u src/sys/dev/pci/ixgbe/ix_txrx.c:1.73 src/sys/dev/pci/ixgbe/ix_txrx.c:1.74 --- src/sys/dev/pci/ixgbe/ix_txrx.c:1.73 Fri May 14 01:30:06 2021 +++ src/sys/dev/pci/ixgbe/ix_txrx.c Fri May 14 05:15:17 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: ix_txrx.c,v 1.73 2021/05/14 01:30:06 knakahara Exp $ */ +/* $NetBSD: ix_txrx.c,v 1.74 2021/05/14 05:15:17 msaitoh Exp $ */ /** @@ -64,7 +64,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ix_txrx.c,v 1.73 2021/05/14 01:30:06 knakahara Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ix_txrx.c,v 1.74 2021/05/14 05:15:17 msaitoh Exp $"); #include "opt_inet.h" #include "opt_inet6.h" @@ -1949,7 +1949,6 @@ ixgbe_rxeof(struct ix_queue *que) * buffer struct and pass this along from one * descriptor to the next, until we get EOP. */ - mp->m_len = len; /* * See if there is a stored head * that determines what we are @@ -1958,6 +1957,7 @@ ixgbe_rxeof(struct ix_queue *que) if (sendmp != NULL) { /* secondary frag */ rbuf->buf = newmp; rbuf->fmp = NULL; + mp->m_len = len; mp->m_flags &= ~M_PKTHDR; sendmp->m_pkthdr.len += mp->m_len; } else { @@ -1983,12 +1983,13 @@ ixgbe_rxeof(struct ix_queue *que) if (sendmp == NULL) { rbuf->buf = newmp; rbuf->fmp = NULL; +mp->m_len = len; sendmp = mp; } /* first desc of a non-ps chain */ sendmp->m_flags |= M_PKTHDR; - sendmp->m_pkthdr.len = mp->m_len; + sendmp->m_pkthdr.len = len; } ++processed;
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: knakahara Date: Fri May 14 01:30:06 UTC 2021 Modified Files: src/sys/dev/pci/ixgbe: ix_txrx.c Log Message: Comment out flow director processing in fast path. ixgbe_xmit() is per-queue fast path. It should reduce access to per-device data (adapter->feat_en). To generate a diff of this commit: cvs rdiff -u -r1.72 -r1.73 src/sys/dev/pci/ixgbe/ix_txrx.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ix_txrx.c diff -u src/sys/dev/pci/ixgbe/ix_txrx.c:1.72 src/sys/dev/pci/ixgbe/ix_txrx.c:1.73 --- src/sys/dev/pci/ixgbe/ix_txrx.c:1.72 Tue May 11 01:30:30 2021 +++ src/sys/dev/pci/ixgbe/ix_txrx.c Fri May 14 01:30:06 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: ix_txrx.c,v 1.72 2021/05/11 01:30:30 rin Exp $ */ +/* $NetBSD: ix_txrx.c,v 1.73 2021/05/14 01:30:06 knakahara Exp $ */ /** @@ -64,7 +64,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ix_txrx.c,v 1.72 2021/05/11 01:30:30 rin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ix_txrx.c,v 1.73 2021/05/14 01:30:06 knakahara Exp $"); #include "opt_inet.h" #include "opt_inet6.h" @@ -485,6 +485,7 @@ retry: return (error); } +#ifdef IXGBE_FDIR /* Do the flow director magic */ if ((adapter->feat_en & IXGBE_FEATURE_FDIR) && (txr->atr_sample) && (!adapter->fdir_reinit)) { @@ -494,6 +495,7 @@ retry: txr->atr_count = 0; } } +#endif olinfo_status |= IXGBE_ADVTXD_CC; i = txr->next_avail_desc;
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: rin Date: Tue May 11 01:30:30 UTC 2021 Modified Files: src/sys/dev/pci/ixgbe: ix_txrx.c Log Message: Call bus_dmamap_unload(9) via ixgbe_dmamap_unload(), before freeing DMA buffer. Also, when the buffer is already freed, do not call bus_dmamap_unload(9) (no resource leaks with this change). Otherwise, MMU fault occurs for some bus_dma(9) implementations. With this fix, X550-T1 and X540-T1 work fine on alpha (at least DS10 with PCI-PCIe reverse bridge). Discussed with msaitoh. Thanks! To generate a diff of this commit: cvs rdiff -u -r1.71 -r1.72 src/sys/dev/pci/ixgbe/ix_txrx.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ix_txrx.c diff -u src/sys/dev/pci/ixgbe/ix_txrx.c:1.71 src/sys/dev/pci/ixgbe/ix_txrx.c:1.72 --- src/sys/dev/pci/ixgbe/ix_txrx.c:1.71 Fri Apr 30 06:55:32 2021 +++ src/sys/dev/pci/ixgbe/ix_txrx.c Tue May 11 01:30:30 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: ix_txrx.c,v 1.71 2021/04/30 06:55:32 msaitoh Exp $ */ +/* $NetBSD: ix_txrx.c,v 1.72 2021/05/11 01:30:30 rin Exp $ */ /** @@ -64,7 +64,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ix_txrx.c,v 1.71 2021/04/30 06:55:32 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ix_txrx.c,v 1.72 2021/05/11 01:30:30 rin Exp $"); #include "opt_inet.h" #include "opt_inet6.h" @@ -1766,16 +1766,17 @@ ixgbe_rx_discard(struct rx_ring *rxr, in if (rbuf->fmp != NULL) {/* Partial chain ? */ bus_dmamap_sync(rxr->ptag->dt_dmat, rbuf->pmap, 0, rbuf->buf->m_pkthdr.len, BUS_DMASYNC_POSTREAD); + ixgbe_dmamap_unload(rxr->ptag, rbuf->pmap); m_freem(rbuf->fmp); rbuf->fmp = NULL; rbuf->buf = NULL; /* rbuf->buf is part of fmp's chain */ } else if (rbuf->buf) { bus_dmamap_sync(rxr->ptag->dt_dmat, rbuf->pmap, 0, rbuf->buf->m_pkthdr.len, BUS_DMASYNC_POSTREAD); + ixgbe_dmamap_unload(rxr->ptag, rbuf->pmap); m_free(rbuf->buf); rbuf->buf = NULL; } - ixgbe_dmamap_unload(rxr->ptag, rbuf->pmap); rbuf->flags = 0;
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Fri May 7 09:15:52 UTC 2021 Modified Files: src/sys/dev/pci/ixgbe: ixgbe.c Log Message: Print the error value of ixgbe_reset_hw() for debugging. To generate a diff of this commit: cvs rdiff -u -r1.281 -r1.282 src/sys/dev/pci/ixgbe/ixgbe.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.281 src/sys/dev/pci/ixgbe/ixgbe.c:1.282 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.281 Fri Apr 30 06:55:32 2021 +++ src/sys/dev/pci/ixgbe/ixgbe.c Fri May 7 09:15:52 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.281 2021/04/30 06:55:32 msaitoh Exp $ */ +/* $NetBSD: ixgbe.c,v 1.282 2021/05/07 09:15:52 msaitoh Exp $ */ /** @@ -64,7 +64,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ixgbe.c,v 1.281 2021/04/30 06:55:32 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ixgbe.c,v 1.282 2021/05/07 09:15:52 msaitoh Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -1004,7 +1004,8 @@ ixgbe_attach(device_t parent, device_t d unsupported_sfp = true; error = IXGBE_SUCCESS; } else if (error) { - aprint_error_dev(dev, "Hardware initialization failed\n"); + aprint_error_dev(dev, + "Hardware initialization failed(error = %d)\n", error); error = EIO; goto err_late; }
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Fri Apr 30 06:55:32 UTC 2021 Modified Files: src/sys/dev/pci/ixgbe: if_bypass.c if_fdir.c if_sriov.c ix_txrx.c ixgbe.c ixgbe_82598.c ixgbe_82599.c ixgbe_api.c ixgbe_common.c ixgbe_dcb.c ixgbe_dcb_82598.c ixgbe_dcb_82599.c ixgbe_mbx.c ixgbe_netbsd.c ixgbe_netmap.c ixgbe_osdep.c ixgbe_phy.c ixgbe_vf.c ixgbe_x540.c ixgbe_x550.c ixv.c Log Message: Add missing __KERNEL_RCSID(). To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/dev/pci/ixgbe/if_bypass.c cvs rdiff -u -r1.4 -r1.5 src/sys/dev/pci/ixgbe/if_fdir.c cvs rdiff -u -r1.10 -r1.11 src/sys/dev/pci/ixgbe/if_sriov.c \ src/sys/dev/pci/ixgbe/ixgbe_dcb.c cvs rdiff -u -r1.70 -r1.71 src/sys/dev/pci/ixgbe/ix_txrx.c cvs rdiff -u -r1.280 -r1.281 src/sys/dev/pci/ixgbe/ixgbe.c cvs rdiff -u -r1.15 -r1.16 src/sys/dev/pci/ixgbe/ixgbe_82598.c \ src/sys/dev/pci/ixgbe/ixgbe_netbsd.c cvs rdiff -u -r1.22 -r1.23 src/sys/dev/pci/ixgbe/ixgbe_82599.c cvs rdiff -u -r1.24 -r1.25 src/sys/dev/pci/ixgbe/ixgbe_api.c cvs rdiff -u -r1.30 -r1.31 src/sys/dev/pci/ixgbe/ixgbe_common.c cvs rdiff -u -r1.8 -r1.9 src/sys/dev/pci/ixgbe/ixgbe_dcb_82598.c \ src/sys/dev/pci/ixgbe/ixgbe_dcb_82599.c cvs rdiff -u -r1.11 -r1.12 src/sys/dev/pci/ixgbe/ixgbe_mbx.c cvs rdiff -u -r1.3 -r1.4 src/sys/dev/pci/ixgbe/ixgbe_netmap.c cvs rdiff -u -r1.6 -r1.7 src/sys/dev/pci/ixgbe/ixgbe_osdep.c cvs rdiff -u -r1.23 -r1.24 src/sys/dev/pci/ixgbe/ixgbe_phy.c cvs rdiff -u -r1.26 -r1.27 src/sys/dev/pci/ixgbe/ixgbe_vf.c cvs rdiff -u -r1.17 -r1.18 src/sys/dev/pci/ixgbe/ixgbe_x540.c cvs rdiff -u -r1.18 -r1.19 src/sys/dev/pci/ixgbe/ixgbe_x550.c cvs rdiff -u -r1.158 -r1.159 src/sys/dev/pci/ixgbe/ixv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/if_bypass.c diff -u src/sys/dev/pci/ixgbe/if_bypass.c:1.7 src/sys/dev/pci/ixgbe/if_bypass.c:1.8 --- src/sys/dev/pci/ixgbe/if_bypass.c:1.7 Fri Apr 30 06:41:36 2021 +++ src/sys/dev/pci/ixgbe/if_bypass.c Fri Apr 30 06:55:32 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_bypass.c,v 1.7 2021/04/30 06:41:36 msaitoh Exp $ */ +/* $NetBSD: if_bypass.c,v 1.8 2021/04/30 06:55:32 msaitoh Exp $ */ /** Copyright (c) 2001-2017, Intel Corporation @@ -33,6 +33,8 @@ **/ /*$FreeBSD: head/sys/dev/ixgbe/if_bypass.c 327031 2017-12-20 18:15:06Z erj $*/ +#include +__KERNEL_RCSID(0, "$NetBSD: if_bypass.c,v 1.8 2021/04/30 06:55:32 msaitoh Exp $"); #include "ixgbe.h" Index: src/sys/dev/pci/ixgbe/if_fdir.c diff -u src/sys/dev/pci/ixgbe/if_fdir.c:1.4 src/sys/dev/pci/ixgbe/if_fdir.c:1.5 --- src/sys/dev/pci/ixgbe/if_fdir.c:1.4 Fri Apr 30 06:41:36 2021 +++ src/sys/dev/pci/ixgbe/if_fdir.c Fri Apr 30 06:55:32 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_fdir.c,v 1.4 2021/04/30 06:41:36 msaitoh Exp $ */ +/* $NetBSD: if_fdir.c,v 1.5 2021/04/30 06:55:32 msaitoh Exp $ */ /** Copyright (c) 2001-2017, Intel Corporation @@ -33,6 +33,9 @@ **/ /*$FreeBSD: head/sys/dev/ixgbe/if_fdir.c 327031 2017-12-20 18:15:06Z erj $*/ +#include +__KERNEL_RCSID(0, "$NetBSD: if_fdir.c,v 1.5 2021/04/30 06:55:32 msaitoh Exp $"); + #include "ixgbe.h" #ifdef IXGBE_FDIR Index: src/sys/dev/pci/ixgbe/if_sriov.c diff -u src/sys/dev/pci/ixgbe/if_sriov.c:1.10 src/sys/dev/pci/ixgbe/if_sriov.c:1.11 --- src/sys/dev/pci/ixgbe/if_sriov.c:1.10 Fri Apr 30 06:41:36 2021 +++ src/sys/dev/pci/ixgbe/if_sriov.c Fri Apr 30 06:55:32 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_sriov.c,v 1.10 2021/04/30 06:41:36 msaitoh Exp $ */ +/* $NetBSD: if_sriov.c,v 1.11 2021/04/30 06:55:32 msaitoh Exp $ */ /** Copyright (c) 2001-2017, Intel Corporation @@ -33,6 +33,9 @@ **/ /*$FreeBSD: head/sys/dev/ixgbe/if_sriov.c 327031 2017-12-20 18:15:06Z erj $*/ +#include +__KERNEL_RCSID(0, "$NetBSD: if_sriov.c,v 1.11 2021/04/30 06:55:32 msaitoh Exp $"); + #include "ixgbe.h" #include "ixgbe_sriov.h" Index: src/sys/dev/pci/ixgbe/ixgbe_dcb.c diff -u src/sys/dev/pci/ixgbe/ixgbe_dcb.c:1.10 src/sys/dev/pci/ixgbe/ixgbe_dcb.c:1.11 --- src/sys/dev/pci/ixgbe/ixgbe_dcb.c:1.10 Fri Apr 30 06:41:36 2021 +++ src/sys/dev/pci/ixgbe/ixgbe_dcb.c Fri Apr 30 06:55:32 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe_dcb.c,v 1.10 2021/04/30 06:41:36 msaitoh Exp $ */ +/* $NetBSD: ixgbe_dcb.c,v 1.11 2021/04/30 06:55:32 msaitoh Exp $ */ /** SPDX-License-Identifier: BSD-3-Clause @@ -34,6 +34,8 @@
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Fri Apr 30 06:41:36 UTC 2021 Modified Files: src/sys/dev/pci/ixgbe: if_bypass.c if_fdir.c if_sriov.c ixgbe_bypass.h ixgbe_dcb.c ixgbe_dcb.h ixgbe_dcb_82598.c ixgbe_dcb_82599.c ixgbe_dcb_82599.h ixgbe_fdir.h ixgbe_features.h ixgbe_netmap.c ixgbe_netmap.h ixgbe_rss.h ixgbe_sriov.h ixgbe_x540.h ixgbe_x550.h Log Message: Add NetBSD RCS IDs. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/dev/pci/ixgbe/if_bypass.c \ src/sys/dev/pci/ixgbe/ixgbe_dcb.h src/sys/dev/pci/ixgbe/ixgbe_dcb_82599.h cvs rdiff -u -r1.3 -r1.4 src/sys/dev/pci/ixgbe/if_fdir.c \ src/sys/dev/pci/ixgbe/ixgbe_sriov.h cvs rdiff -u -r1.9 -r1.10 src/sys/dev/pci/ixgbe/if_sriov.c \ src/sys/dev/pci/ixgbe/ixgbe_dcb.c cvs rdiff -u -r1.1 -r1.2 src/sys/dev/pci/ixgbe/ixgbe_bypass.h \ src/sys/dev/pci/ixgbe/ixgbe_netmap.h cvs rdiff -u -r1.7 -r1.8 src/sys/dev/pci/ixgbe/ixgbe_dcb_82598.c \ src/sys/dev/pci/ixgbe/ixgbe_dcb_82599.c cvs rdiff -u -r1.2 -r1.3 src/sys/dev/pci/ixgbe/ixgbe_fdir.h \ src/sys/dev/pci/ixgbe/ixgbe_features.h \ src/sys/dev/pci/ixgbe/ixgbe_netmap.c cvs rdiff -u -r1.4 -r1.5 src/sys/dev/pci/ixgbe/ixgbe_rss.h cvs rdiff -u -r1.8 -r1.9 src/sys/dev/pci/ixgbe/ixgbe_x540.h cvs rdiff -u -r1.5 -r1.6 src/sys/dev/pci/ixgbe/ixgbe_x550.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/if_bypass.c diff -u src/sys/dev/pci/ixgbe/if_bypass.c:1.6 src/sys/dev/pci/ixgbe/if_bypass.c:1.7 --- src/sys/dev/pci/ixgbe/if_bypass.c:1.6 Wed Aug 12 09:13:46 2020 +++ src/sys/dev/pci/ixgbe/if_bypass.c Fri Apr 30 06:41:36 2021 @@ -1,3 +1,4 @@ +/* $NetBSD: if_bypass.c,v 1.7 2021/04/30 06:41:36 msaitoh Exp $ */ /** Copyright (c) 2001-2017, Intel Corporation Index: src/sys/dev/pci/ixgbe/ixgbe_dcb.h diff -u src/sys/dev/pci/ixgbe/ixgbe_dcb.h:1.6 src/sys/dev/pci/ixgbe/ixgbe_dcb.h:1.7 --- src/sys/dev/pci/ixgbe/ixgbe_dcb.h:1.6 Wed Apr 4 08:13:07 2018 +++ src/sys/dev/pci/ixgbe/ixgbe_dcb.h Fri Apr 30 06:41:36 2021 @@ -1,3 +1,4 @@ +/* $NetBSD: ixgbe_dcb.h,v 1.7 2021/04/30 06:41:36 msaitoh Exp $ */ /** SPDX-License-Identifier: BSD-3-Clause Index: src/sys/dev/pci/ixgbe/ixgbe_dcb_82599.h diff -u src/sys/dev/pci/ixgbe/ixgbe_dcb_82599.h:1.6 src/sys/dev/pci/ixgbe/ixgbe_dcb_82599.h:1.7 --- src/sys/dev/pci/ixgbe/ixgbe_dcb_82599.h:1.6 Wed Apr 4 08:13:07 2018 +++ src/sys/dev/pci/ixgbe/ixgbe_dcb_82599.h Fri Apr 30 06:41:36 2021 @@ -1,3 +1,4 @@ +/* $NetBSD: ixgbe_dcb_82599.h,v 1.7 2021/04/30 06:41:36 msaitoh Exp $ */ /** SPDX-License-Identifier: BSD-3-Clause Index: src/sys/dev/pci/ixgbe/if_fdir.c diff -u src/sys/dev/pci/ixgbe/if_fdir.c:1.3 src/sys/dev/pci/ixgbe/if_fdir.c:1.4 --- src/sys/dev/pci/ixgbe/if_fdir.c:1.3 Mon Sep 7 05:50:58 2020 +++ src/sys/dev/pci/ixgbe/if_fdir.c Fri Apr 30 06:41:36 2021 @@ -1,3 +1,4 @@ +/* $NetBSD: if_fdir.c,v 1.4 2021/04/30 06:41:36 msaitoh Exp $ */ /** Copyright (c) 2001-2017, Intel Corporation Index: src/sys/dev/pci/ixgbe/ixgbe_sriov.h diff -u src/sys/dev/pci/ixgbe/ixgbe_sriov.h:1.3 src/sys/dev/pci/ixgbe/ixgbe_sriov.h:1.4 --- src/sys/dev/pci/ixgbe/ixgbe_sriov.h:1.3 Wed Apr 4 08:13:07 2018 +++ src/sys/dev/pci/ixgbe/ixgbe_sriov.h Fri Apr 30 06:41:36 2021 @@ -1,3 +1,4 @@ +/* $NetBSD: ixgbe_sriov.h,v 1.4 2021/04/30 06:41:36 msaitoh Exp $ */ /** Copyright (c) 2001-2017, Intel Corporation Index: src/sys/dev/pci/ixgbe/if_sriov.c diff -u src/sys/dev/pci/ixgbe/if_sriov.c:1.9 src/sys/dev/pci/ixgbe/if_sriov.c:1.10 --- src/sys/dev/pci/ixgbe/if_sriov.c:1.9 Mon Jan 25 19:59:49 2021 +++ src/sys/dev/pci/ixgbe/if_sriov.c Fri Apr 30 06:41:36 2021 @@ -1,3 +1,4 @@ +/* $NetBSD: if_sriov.c,v 1.10 2021/04/30 06:41:36 msaitoh Exp $ */ /** Copyright (c) 2001-2017, Intel Corporation Index: src/sys/dev/pci/ixgbe/ixgbe_dcb.c diff -u src/sys/dev/pci/ixgbe/ixgbe_dcb.c:1.9 src/sys/dev/pci/ixgbe/ixgbe_dcb.c:1.10 --- src/sys/dev/pci/ixgbe/ixgbe_dcb.c:1.9 Mon Sep 3 16:29:33 2018 +++ src/sys/dev/pci/ixgbe/ixgbe_dcb.c Fri Apr 30 06:41:36 2021 @@ -1,3 +1,4 @@ +/* $NetBSD: ixgbe_dcb.c,v 1.10 2021/04/30 06:41:36 msaitoh Exp $ */ /** SPDX-License-Identifier: BSD-3-Clause Index: src/sys/dev/pci/ixgbe/ixgbe_bypass.h diff -u src/sys/dev/pci/ixgbe/ixgbe_bypass.h:1.1 src/sys/dev/pci/ixgbe/ixgbe_bypass.h:1.2 --- src/sys/dev/pci/ixgbe/ixgbe_bypass.h:1.1 Wed
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Wed Mar 31 07:53:53 UTC 2021 Modified Files: src/sys/dev/pci/ixgbe: ix_txrx.c ixgbe.c ixv.c Log Message: KNF a bit. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.69 -r1.70 src/sys/dev/pci/ixgbe/ix_txrx.c cvs rdiff -u -r1.279 -r1.280 src/sys/dev/pci/ixgbe/ixgbe.c cvs rdiff -u -r1.157 -r1.158 src/sys/dev/pci/ixgbe/ixv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ix_txrx.c diff -u src/sys/dev/pci/ixgbe/ix_txrx.c:1.69 src/sys/dev/pci/ixgbe/ix_txrx.c:1.70 --- src/sys/dev/pci/ixgbe/ix_txrx.c:1.69 Fri Mar 12 01:54:29 2021 +++ src/sys/dev/pci/ixgbe/ix_txrx.c Wed Mar 31 07:53:53 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: ix_txrx.c,v 1.69 2021/03/12 01:54:29 knakahara Exp $ */ +/* $NetBSD: ix_txrx.c,v 1.70 2021/03/31 07:53:53 msaitoh Exp $ */ /** @@ -202,7 +202,7 @@ ixgbe_mq_start(struct ifnet *ifp, struct { struct adapter *adapter = ifp->if_softc; struct tx_ring *txr; - int i; + int i; #ifdef RSS uint32_t bucket_id; #endif @@ -1755,11 +1755,9 @@ ixgbe_rx_discard(struct rx_ring *rxr, in rbuf = >rx_buffers[i]; /* - * With advanced descriptors the writeback - * clobbers the buffer addrs, so its easier - * to just free the existing mbufs and take - * the normal refresh path to get new buffers - * and mapping. + * With advanced descriptors the writeback clobbers the buffer addrs, + * so its easier to just free the existing mbufs and take the normal + * refresh path to get new buffers and mapping. */ if (rbuf->fmp != NULL) {/* Partial chain ? */ Index: src/sys/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.279 src/sys/dev/pci/ixgbe/ixgbe.c:1.280 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.279 Tue Mar 9 10:03:18 2021 +++ src/sys/dev/pci/ixgbe/ixgbe.c Wed Mar 31 07:53:53 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.279 2021/03/09 10:03:18 msaitoh Exp $ */ +/* $NetBSD: ixgbe.c,v 1.280 2021/03/31 07:53:53 msaitoh Exp $ */ /** @@ -1694,17 +1694,20 @@ ixgbe_update_stats_counters(struct adapt stats->gorc.ev_count += IXGBE_READ_REG(hw, IXGBE_GORCL) + ((u64)IXGBE_READ_REG(hw, IXGBE_GORCH) << 32); stats->gotc.ev_count += IXGBE_READ_REG(hw, IXGBE_GOTCL) + - ((u64)IXGBE_READ_REG(hw, IXGBE_GOTCH) << 32) - total * ETHER_MIN_LEN; + ((u64)IXGBE_READ_REG(hw, IXGBE_GOTCH) << 32) + - total * ETHER_MIN_LEN; stats->tor.ev_count += IXGBE_READ_REG(hw, IXGBE_TORL) + ((u64)IXGBE_READ_REG(hw, IXGBE_TORH) << 32); stats->lxonrxc.ev_count += IXGBE_READ_REG(hw, IXGBE_LXONRXCNT); - stats->lxoffrxc.ev_count += IXGBE_READ_REG(hw, IXGBE_LXOFFRXCNT); + stats->lxoffrxc.ev_count + += IXGBE_READ_REG(hw, IXGBE_LXOFFRXCNT); } else { stats->lxonrxc.ev_count += IXGBE_READ_REG(hw, IXGBE_LXONRXC); stats->lxoffrxc.ev_count += IXGBE_READ_REG(hw, IXGBE_LXOFFRXC); /* 82598 only has a counter in the high register */ stats->gorc.ev_count += IXGBE_READ_REG(hw, IXGBE_GORCH); - stats->gotc.ev_count += IXGBE_READ_REG(hw, IXGBE_GOTCH) - total * ETHER_MIN_LEN; + stats->gotc.ev_count += IXGBE_READ_REG(hw, IXGBE_GOTCH) + - total * ETHER_MIN_LEN; stats->tor.ev_count += IXGBE_READ_REG(hw, IXGBE_TORH); } @@ -1916,42 +1919,35 @@ ixgbe_add_hw_stats(struct adapter *adapt #endif if (sysctl_createv(log, 0, , , - CTLFLAG_READONLY, - CTLTYPE_INT, - "rxd_nxck", SYSCTL_DESCR("Receive Descriptor next to check"), - ixgbe_sysctl_next_to_check_handler, 0, (void *)rxr, 0, + CTLFLAG_READONLY, CTLTYPE_INT, "rxd_nxck", + SYSCTL_DESCR("Receive Descriptor next to check"), + ixgbe_sysctl_next_to_check_handler, 0, (void *)rxr, 0, CTL_CREATE, CTL_EOL) != 0) break; if (sysctl_createv(log, 0, , , - CTLFLAG_READONLY, - CTLTYPE_INT, - "rxd_head", SYSCTL_DESCR("Receive Descriptor Head"), + CTLFLAG_READONLY, CTLTYPE_INT, "rxd_head", + SYSCTL_DESCR("Receive Descriptor Head"), ixgbe_sysctl_rdh_handler, 0, (void *)rxr, 0, CTL_CREATE, CTL_EOL) != 0) break; if (sysctl_createv(log, 0, , , - CTLFLAG_READONLY, - CTLTYPE_INT, - "rxd_tail", SYSCTL_DESCR("Receive Descriptor Tail"), + CTLFLAG_READONLY, CTLTYPE_INT, "rxd_tail", + SYSCTL_DESCR("Receive Descriptor Tail"), ixgbe_sysctl_rdt_handler, 0, (void *)rxr, 0, CTL_CREATE, CTL_EOL) != 0) break; if (i < __arraycount(stats->qprc)) { - evcnt_attach_dynamic(>qprc[i], - EVCNT_TYPE_MISC, NULL, adapter->queues[i].evnamebuf, - "qprc"); - evcnt_attach_dynamic(>qptc[i], - EVCNT_TYPE_MISC, NULL, adapter->queues[i].evnamebuf, - "qptc"); - evcnt_attach_dynamic(>qbrc[i], - EVCNT_TYPE_MISC, NULL,
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Wed Mar 31 07:52:15 UTC 2021 Modified Files: src/sys/dev/pci/ixgbe: ixv.c Log Message: Modify error message to sync with ixgbe.c To generate a diff of this commit: cvs rdiff -u -r1.156 -r1.157 src/sys/dev/pci/ixgbe/ixv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ixv.c diff -u src/sys/dev/pci/ixgbe/ixv.c:1.156 src/sys/dev/pci/ixgbe/ixv.c:1.157 --- src/sys/dev/pci/ixgbe/ixv.c:1.156 Thu Mar 11 02:30:47 2021 +++ src/sys/dev/pci/ixgbe/ixv.c Wed Mar 31 07:52:14 2021 @@ -1,4 +1,4 @@ -/*$NetBSD: ixv.c,v 1.156 2021/03/11 02:30:47 msaitoh Exp $*/ +/*$NetBSD: ixv.c,v 1.157 2021/03/31 07:52:14 msaitoh Exp $*/ /** @@ -3358,7 +3358,7 @@ ixv_allocate_msix(struct adapter *adapte IXGBE_WORKQUEUE_FLAGS); if (error) { aprint_error_dev(dev, - "couldn't create workqueue\n"); + "couldn't create workqueue for Tx/Rx\n"); } /* and Mailbox */
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: knakahara Date: Fri Mar 12 01:54:29 UTC 2021 Modified Files: src/sys/dev/pci/ixgbe: ix_txrx.c Log Message: Refactor rxr->next_to_check updating. To generate a diff of this commit: cvs rdiff -u -r1.68 -r1.69 src/sys/dev/pci/ixgbe/ix_txrx.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ix_txrx.c diff -u src/sys/dev/pci/ixgbe/ix_txrx.c:1.68 src/sys/dev/pci/ixgbe/ix_txrx.c:1.69 --- src/sys/dev/pci/ixgbe/ix_txrx.c:1.68 Fri Mar 12 01:53:36 2021 +++ src/sys/dev/pci/ixgbe/ix_txrx.c Fri Mar 12 01:54:29 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: ix_txrx.c,v 1.68 2021/03/12 01:53:36 knakahara Exp $ */ +/* $NetBSD: ix_txrx.c,v 1.69 2021/03/12 01:54:29 knakahara Exp $ */ /** @@ -2079,9 +2079,7 @@ next_desc: /* Now send to the stack or do LRO */ if (sendmp != NULL) { - rxr->next_to_check = i; ixgbe_rx_input(rxr, ifp, sendmp, ptype); - i = rxr->next_to_check; } /* Every 8 descriptors we go to refresh mbufs */
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: knakahara Date: Fri Mar 12 01:53:36 UTC 2021 Modified Files: src/sys/dev/pci/ixgbe: ix_txrx.c Log Message: Remove extra unlock/lock processing around if_percpuq_enqueue(). same as if_wm.c:r1.700 To generate a diff of this commit: cvs rdiff -u -r1.67 -r1.68 src/sys/dev/pci/ixgbe/ix_txrx.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ix_txrx.c diff -u src/sys/dev/pci/ixgbe/ix_txrx.c:1.67 src/sys/dev/pci/ixgbe/ix_txrx.c:1.68 --- src/sys/dev/pci/ixgbe/ix_txrx.c:1.67 Tue Mar 9 10:03:18 2021 +++ src/sys/dev/pci/ixgbe/ix_txrx.c Fri Mar 12 01:53:36 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: ix_txrx.c,v 1.67 2021/03/09 10:03:18 msaitoh Exp $ */ +/* $NetBSD: ix_txrx.c,v 1.68 2021/03/12 01:53:36 knakahara Exp $ */ /** @@ -2080,9 +2080,7 @@ next_desc: /* Now send to the stack or do LRO */ if (sendmp != NULL) { rxr->next_to_check = i; - IXGBE_RX_UNLOCK(rxr); ixgbe_rx_input(rxr, ifp, sendmp, ptype); - IXGBE_RX_LOCK(rxr); i = rxr->next_to_check; }
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Thu Mar 11 02:30:47 UTC 2021 Modified Files: src/sys/dev/pci/ixgbe: ixv.c Log Message: Add "TX " to "Queue No Descriptor Available" to make it more understandable. Same as ixgbe.c rev. 1.278. To generate a diff of this commit: cvs rdiff -u -r1.155 -r1.156 src/sys/dev/pci/ixgbe/ixv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ixv.c diff -u src/sys/dev/pci/ixgbe/ixv.c:1.155 src/sys/dev/pci/ixgbe/ixv.c:1.156 --- src/sys/dev/pci/ixgbe/ixv.c:1.155 Tue Mar 9 10:03:18 2021 +++ src/sys/dev/pci/ixgbe/ixv.c Thu Mar 11 02:30:47 2021 @@ -1,4 +1,4 @@ -/*$NetBSD: ixv.c,v 1.155 2021/03/09 10:03:18 msaitoh Exp $*/ +/*$NetBSD: ixv.c,v 1.156 2021/03/11 02:30:47 msaitoh Exp $*/ /** @@ -2669,7 +2669,7 @@ ixv_add_stats_sysctls(struct adapter *ad NULL, adapter->queues[i].evnamebuf, "TSO"); evcnt_attach_dynamic(>no_desc_avail, EVCNT_TYPE_MISC, NULL, adapter->queues[i].evnamebuf, - "Queue No Descriptor Available"); + "TX Queue No Descriptor Available"); evcnt_attach_dynamic(>total_packets, EVCNT_TYPE_MISC, NULL, adapter->queues[i].evnamebuf, "Queue Packets Transmitted");
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Mon Mar 8 07:10:45 UTC 2021 Modified Files: src/sys/dev/pci/ixgbe: ix_txrx.c Log Message: Use no_jmbuf evcnt for the failure case of ixgbe_getjcl(). To generate a diff of this commit: cvs rdiff -u -r1.65 -r1.66 src/sys/dev/pci/ixgbe/ix_txrx.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ix_txrx.c diff -u src/sys/dev/pci/ixgbe/ix_txrx.c:1.65 src/sys/dev/pci/ixgbe/ix_txrx.c:1.66 --- src/sys/dev/pci/ixgbe/ix_txrx.c:1.65 Tue Mar 2 11:10:53 2021 +++ src/sys/dev/pci/ixgbe/ix_txrx.c Mon Mar 8 07:10:45 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: ix_txrx.c,v 1.65 2021/03/02 11:10:53 msaitoh Exp $ */ +/* $NetBSD: ix_txrx.c,v 1.66 2021/03/08 07:10:45 msaitoh Exp $ */ /** @@ -1883,7 +1883,7 @@ ixgbe_rxeof(struct ix_queue *que) else newmp = NULL; if (newmp == NULL) { - rxr->rx_discarded.ev_count++; + rxr->no_jmbuf.ev_count++; /* * Descriptor initialization is already done by the * above code (cur->wb.upper.status_error = 0).
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Tue Mar 2 11:10:53 UTC 2021 Modified Files: src/sys/dev/pci/ixgbe: ix_txrx.c Log Message: Fix jcl's starvation case in ixgbe_rxeof() again. ix_txrx.c rev.1.64 preallocates jcl to prevent starvation but it's not perfect. Don't use ixgbe_rx_discard() and just update the old descriptor for reuse. It's also required for multiple descriptors case to refresh subsequent descriptor(s). Reviewed by knakahara@. To generate a diff of this commit: cvs rdiff -u -r1.64 -r1.65 src/sys/dev/pci/ixgbe/ix_txrx.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ix_txrx.c diff -u src/sys/dev/pci/ixgbe/ix_txrx.c:1.64 src/sys/dev/pci/ixgbe/ix_txrx.c:1.65 --- src/sys/dev/pci/ixgbe/ix_txrx.c:1.64 Mon Jan 18 09:09:04 2021 +++ src/sys/dev/pci/ixgbe/ix_txrx.c Tue Mar 2 11:10:53 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: ix_txrx.c,v 1.64 2021/01/18 09:09:04 knakahara Exp $ */ +/* $NetBSD: ix_txrx.c,v 1.65 2021/03/02 11:10:53 msaitoh Exp $ */ /** @@ -1319,6 +1319,11 @@ ixgbe_setup_hw_rsc(struct rx_ring *rxr) * exhaustion are unnecessary, if an mbuf cannot be obtained * it just returns, keeping its placeholder, thus it can simply * be recalled to try again. + * + * XXX NetBSD TODO: + *- The ixgbe_rxeof() function always preallocates mbuf cluster (jcl), + * so the ixgbe_refresh_mbufs() function can be simplified. + * / static void ixgbe_refresh_mbufs(struct rx_ring *rxr, int limit) @@ -1799,7 +1804,9 @@ ixgbe_rxeof(struct ix_queue *que) struct ixgbe_rx_buf *rbuf, *nbuf; int i, nextp, processed = 0; u32 staterr = 0; - u32 count = adapter->rx_process_limit; + u32 count = 0; + u32 limit = adapter->rx_process_limit; + bool discard_multidesc = false; #ifdef RSS u16 pkt_info; #endif @@ -1816,7 +1823,14 @@ ixgbe_rxeof(struct ix_queue *que) } #endif /* DEV_NETMAP */ - for (i = rxr->next_to_check; count != 0;) { + /* + * The max number of loop is rx_process_limit. If discard_multidesc is + * true, continue processing to not to send broken packet to the upper + * layer. + */ + for (i = rxr->next_to_check; + (count < limit) || (discard_multidesc == true);) { + struct mbuf *sendmp, *mp; struct mbuf *newmp; u32 rsc, ptype; @@ -1837,7 +1851,7 @@ ixgbe_rxeof(struct ix_queue *que) if ((staterr & IXGBE_RXD_STAT_DD) == 0) break; - count--; + count++; sendmp = NULL; nbuf = NULL; rsc = 0; @@ -1858,17 +1872,37 @@ ixgbe_rxeof(struct ix_queue *que) #endif rxr->rx_discarded.ev_count++; ixgbe_rx_discard(rxr, i); + discard_multidesc = false; goto next_desc; } /* pre-alloc new mbuf */ - newmp = ixgbe_getjcl(>jcl_head, M_NOWAIT, MT_DATA, M_PKTHDR, - rxr->mbuf_sz); + if (!discard_multidesc) + newmp = ixgbe_getjcl(>jcl_head, M_NOWAIT, MT_DATA, + M_PKTHDR, rxr->mbuf_sz); + else + newmp = NULL; if (newmp == NULL) { rxr->rx_discarded.ev_count++; - ixgbe_rx_discard(rxr, i); + /* + * Descriptor initialization is already done by the + * above code (cur->wb.upper.status_error = 0). + * So, we can reuse current rbuf->buf for new packet. + * + * Rewrite the buffer addr, see comment in + * ixgbe_rx_discard(). + */ + cur->read.pkt_addr = rbuf->addr; + m_freem(rbuf->fmp); + rbuf->fmp = NULL; + if (!eop) { +/* Discard the entire packet. */ +discard_multidesc = true; + } else +discard_multidesc = false; goto next_desc; } + discard_multidesc = false; bus_dmamap_sync(rxr->ptag->dt_dmat, rbuf->pmap, 0, rbuf->buf->m_pkthdr.len, BUS_DMASYNC_POSTREAD);
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Wed Jan 20 06:53:17 UTC 2021 Modified Files: src/sys/dev/pci/ixgbe: ixgbe_vf.c Log Message: The max number of queue(pair) is not 7 but 8. Inspired by DPDK. To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 src/sys/dev/pci/ixgbe/ixgbe_vf.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ixgbe_vf.c diff -u src/sys/dev/pci/ixgbe/ixgbe_vf.c:1.25 src/sys/dev/pci/ixgbe/ixgbe_vf.c:1.26 --- src/sys/dev/pci/ixgbe/ixgbe_vf.c:1.25 Mon Nov 30 05:30:56 2020 +++ src/sys/dev/pci/ixgbe/ixgbe_vf.c Wed Jan 20 06:53:17 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe_vf.c,v 1.25 2020/11/30 05:30:56 msaitoh Exp $ */ +/* $NetBSD: ixgbe_vf.c,v 1.26 2021/01/20 06:53:17 msaitoh Exp $ */ /** SPDX-License-Identifier: BSD-3-Clause @@ -121,7 +121,8 @@ static void ixgbe_virt_clr_reg(struct ix IXGBE_WRITE_REG(hw, IXGBE_VFPSRTYPE, 0); - for (i = 0; i < 7; i++) { + KASSERT(IXGBE_VF_MAX_TX_QUEUES == IXGBE_VF_MAX_RX_QUEUES); + for (i = 0; i < IXGBE_VF_MAX_TX_QUEUES; i++) { IXGBE_WRITE_REG(hw, IXGBE_VFRDH(i), 0); IXGBE_WRITE_REG(hw, IXGBE_VFRDT(i), 0); IXGBE_WRITE_REG(hw, IXGBE_VFRXDCTL(i), 0);
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: knakahara Date: Mon Jan 18 09:09:04 UTC 2021 Modified Files: src/sys/dev/pci/ixgbe: ix_txrx.c Log Message: Fix ixg(4) Rx interrupt stall when Rx buffers are exhausted. Current ixgbe_rxeof() implementation calls ixgbe_refresh_mbufs()(and ixgbe_getjcl()) after ixgbe_rx_input()(and if_percpuq_enqueue()). And ixg(4) uses its own m_ext structure. That causes Rx interrupt stall when Rx buffers are exhausted. e.g. TCP iperf3 with large windows size. Furthermore, Rx descriptor problem has occurred after stoppping the load. To fix that problem, ixgbe_rxeof() must call ixgbe_getjcl() before ixgbe_rx_input(), and must discard the new packet when ixgbe_getjcl() fails. By the way, ixg(4) should use MCLGET() instead of own m_ext structure. ok'ed by msaitoh@n.o, thanks. To generate a diff of this commit: cvs rdiff -u -r1.63 -r1.64 src/sys/dev/pci/ixgbe/ix_txrx.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ix_txrx.c diff -u src/sys/dev/pci/ixgbe/ix_txrx.c:1.63 src/sys/dev/pci/ixgbe/ix_txrx.c:1.64 --- src/sys/dev/pci/ixgbe/ix_txrx.c:1.63 Fri Apr 17 02:21:25 2020 +++ src/sys/dev/pci/ixgbe/ix_txrx.c Mon Jan 18 09:09:04 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: ix_txrx.c,v 1.63 2020/04/17 02:21:25 msaitoh Exp $ */ +/* $NetBSD: ix_txrx.c,v 1.64 2021/01/18 09:09:04 knakahara Exp $ */ /** @@ -1818,6 +1818,7 @@ ixgbe_rxeof(struct ix_queue *que) for (i = rxr->next_to_check; count != 0;) { struct mbuf *sendmp, *mp; + struct mbuf *newmp; u32 rsc, ptype; u16 len; u16 vtag = 0; @@ -1860,6 +1861,15 @@ ixgbe_rxeof(struct ix_queue *que) goto next_desc; } + /* pre-alloc new mbuf */ + newmp = ixgbe_getjcl(>jcl_head, M_NOWAIT, MT_DATA, M_PKTHDR, + rxr->mbuf_sz); + if (newmp == NULL) { + rxr->rx_discarded.ev_count++; + ixgbe_rx_discard(rxr, i); + goto next_desc; + } + bus_dmamap_sync(rxr->ptag->dt_dmat, rbuf->pmap, 0, rbuf->buf->m_pkthdr.len, BUS_DMASYNC_POSTREAD); @@ -1908,7 +1918,8 @@ ixgbe_rxeof(struct ix_queue *que) */ sendmp = rbuf->fmp; if (sendmp != NULL) { /* secondary frag */ - rbuf->buf = rbuf->fmp = NULL; + rbuf->buf = newmp; + rbuf->fmp = NULL; mp->m_flags &= ~M_PKTHDR; sendmp->m_pkthdr.len += mp->m_len; } else { @@ -1927,10 +1938,13 @@ ixgbe_rxeof(struct ix_queue *que) sendmp->m_len = len; rxr->rx_copies.ev_count++; rbuf->flags |= IXGBE_RX_COPY; + + m_freem(newmp); } } if (sendmp == NULL) { -rbuf->buf = rbuf->fmp = NULL; +rbuf->buf = newmp; +rbuf->fmp = NULL; sendmp = mp; }
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Thu Jan 14 05:47:35 UTC 2021 Modified Files: src/sys/dev/pci/ixgbe: ixgbe.c Log Message: Add "TX " to "Queue No Descriptor Available" to make it more understandable. To generate a diff of this commit: cvs rdiff -u -r1.277 -r1.278 src/sys/dev/pci/ixgbe/ixgbe.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.277 src/sys/dev/pci/ixgbe/ixgbe.c:1.278 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.277 Thu Dec 31 12:34:33 2020 +++ src/sys/dev/pci/ixgbe/ixgbe.c Thu Jan 14 05:47:35 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.277 2020/12/31 12:34:33 msaitoh Exp $ */ +/* $NetBSD: ixgbe.c,v 1.278 2021/01/14 05:47:35 msaitoh Exp $ */ /** @@ -1902,7 +1902,7 @@ ixgbe_add_hw_stats(struct adapter *adapt NULL, adapter->queues[i].evnamebuf, "TSO"); evcnt_attach_dynamic(>no_desc_avail, EVCNT_TYPE_MISC, NULL, adapter->queues[i].evnamebuf, - "Queue No Descriptor Available"); + "TX Queue No Descriptor Available"); evcnt_attach_dynamic(>total_packets, EVCNT_TYPE_MISC, NULL, adapter->queues[i].evnamebuf, "Queue Packets Transmitted");
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Thu Dec 31 12:34:33 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe: ixgbe.c Log Message: Reduce code duplication. No functional change. Add new ixgbe_intr_admin_common() and use it in both ixgbe_msix_admin() and ixgbe_legacy_irq(). To generate a diff of this commit: cvs rdiff -u -r1.276 -r1.277 src/sys/dev/pci/ixgbe/ixgbe.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.276 src/sys/dev/pci/ixgbe/ixgbe.c:1.277 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.276 Sat Dec 26 06:27:38 2020 +++ src/sys/dev/pci/ixgbe/ixgbe.c Thu Dec 31 12:34:33 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.276 2020/12/26 06:27:38 msaitoh Exp $ */ +/* $NetBSD: ixgbe.c,v 1.277 2020/12/31 12:34:33 msaitoh Exp $ */ /** @@ -258,12 +258,11 @@ static int ixgbe_sysctl_debug(SYSCTLFN_P static int ixgbe_sysctl_wol_enable(SYSCTLFN_PROTO); static int ixgbe_sysctl_wufc(SYSCTLFN_PROTO); -/* Legacy (single vector) interrupt handler */ -static int ixgbe_legacy_irq(void *); - -/* The MSI/MSI-X Interrupt handlers */ +/* Interrupt functions */ static int ixgbe_msix_que(void *); static int ixgbe_msix_admin(void *); +static void ixgbe_intr_admin_common(struct adapter *, u32, u32 *); +static int ixgbe_legacy_irq(void *); /* Event handlers running on workqueue */ static void ixgbe_handle_que(void *); @@ -3089,11 +3088,9 @@ ixgbe_msix_admin(void *arg) { struct adapter *adapter = arg; struct ixgbe_hw *hw = >hw; - u32 eicr, eicr_mask; + u32 eicr; u32 eims_orig; u32 eims_disable = 0; - u32 task_requests = 0; - s32 retval; ++adapter->admin_irqev.ev_count; @@ -3115,10 +3112,26 @@ ixgbe_msix_admin(void *arg) /* Clear all OTHER interrupts with write */ IXGBE_WRITE_REG(hw, IXGBE_EICR, eicr); + ixgbe_intr_admin_common(adapter, eicr, _disable); + + /* Re-enable some OTHER interrupts */ + IXGBE_WRITE_REG(hw, IXGBE_EIMS, eims_orig & ~eims_disable); + + return 1; +} /* ixgbe_msix_admin */ + +static void +ixgbe_intr_admin_common(struct adapter *adapter, u32 eicr, u32 *eims_disable) +{ + struct ixgbe_hw *hw = >hw; + u32 eicr_mask; + u32 task_requests = 0; + s32 retval; + /* Link status change */ if (eicr & IXGBE_EICR_LSC) { task_requests |= IXGBE_REQUEST_TASK_LSC; - eims_disable |= IXGBE_EIMS_LSC; + *eims_disable |= IXGBE_EIMS_LSC; } if (ixgbe_is_sfp(hw)) { @@ -3138,13 +3151,13 @@ ixgbe_msix_admin(void *arg) || ((hw->phy.sfp_type == ixgbe_sfp_type_not_present) && (eicr & IXGBE_EICR_LSC))) { task_requests |= IXGBE_REQUEST_TASK_MOD; - eims_disable |= IXGBE_EIMS_LSC; + *eims_disable |= IXGBE_EIMS_LSC; } if ((hw->mac.type == ixgbe_mac_82599EB) && (eicr & IXGBE_EICR_GPI_SDP1_BY_MAC(hw))) { task_requests |= IXGBE_REQUEST_TASK_MSF; - eims_disable |= IXGBE_EIMS_GPI_SDP1_BY_MAC(hw); + *eims_disable |= IXGBE_EIMS_GPI_SDP1_BY_MAC(hw); } } @@ -3154,7 +3167,7 @@ ixgbe_msix_admin(void *arg) if (!atomic_cas_uint(>fdir_reinit, 0, 1)) { task_requests |= IXGBE_REQUEST_TASK_FDIR; /* Disable the interrupt */ -eims_disable |= IXGBE_EIMS_FLOW_DIR; +*eims_disable |= IXGBE_EIMS_FLOW_DIR; } } @@ -3162,7 +3175,7 @@ ixgbe_msix_admin(void *arg) device_printf(adapter->dev, "CRITICAL: ECC ERROR!! Please Reboot!!\n"); /* Disable interrupt to prevent log spam */ - eims_disable |= IXGBE_EICR_ECC; + *eims_disable |= IXGBE_EICR_ECC; } /* Check for over temp condition */ @@ -3172,7 +3185,7 @@ ixgbe_msix_admin(void *arg) if (!(eicr & IXGBE_EICR_GPI_SDP0_X550EM_a)) break; /* Disable interrupt to prevent log spam */ -eims_disable |= IXGBE_EICR_GPI_SDP0_X550EM_a; +*eims_disable |= IXGBE_EICR_GPI_SDP0_X550EM_a; retval = hw->phy.ops.check_overtemp(hw); if (retval != IXGBE_ERR_OVERTEMP) @@ -3184,7 +3197,7 @@ ixgbe_msix_admin(void *arg) if (!(eicr & IXGBE_EICR_TS)) break; /* Disable interrupt to prevent log spam */ -eims_disable |= IXGBE_EIMS_TS; +*eims_disable |= IXGBE_EIMS_TS; retval = hw->phy.ops.check_overtemp(hw); if (retval != IXGBE_ERR_OVERTEMP) @@ -3199,7 +3212,7 @@ ixgbe_msix_admin(void *arg) if ((adapter->feat_en & IXGBE_FEATURE_SRIOV) && (eicr & IXGBE_EICR_MAILBOX)) { task_requests |= IXGBE_REQUEST_TASK_MBX; - eims_disable |= IXGBE_EIMS_MAILBOX; + *eims_disable |= IXGBE_EIMS_MAILBOX; } } @@ -3208,7 +3221,7 @@ ixgbe_msix_admin(void *arg) retval = ixgbe_check_fan_failure(adapter, eicr, true); if (retval == IXGBE_ERR_FAN_FAILURE) { /* Disable interrupt to prevent log spam */ - eims_disable |= IXGBE_EIMS_GPI_SDP1_BY_MAC(hw); + *eims_disable |= IXGBE_EIMS_GPI_SDP1_BY_MAC(hw); } } @@ -3216,7 +3229,7 @@ ixgbe_msix_admin(void
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Sat Dec 26 06:27:38 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe: ixgbe.c Log Message: Copy & paste some missing part (flow director, ECC and temp sensor) from ixgbe_msix_admin() to ixgbe_legacy_irq(). Now it's ready to make a new function to share the common part. It'll be done in near future. To generate a diff of this commit: cvs rdiff -u -r1.275 -r1.276 src/sys/dev/pci/ixgbe/ixgbe.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.275 src/sys/dev/pci/ixgbe/ixgbe.c:1.276 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.275 Sat Dec 26 06:17:55 2020 +++ src/sys/dev/pci/ixgbe/ixgbe.c Sat Dec 26 06:27:38 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.275 2020/12/26 06:17:55 msaitoh Exp $ */ +/* $NetBSD: ixgbe.c,v 1.276 2020/12/26 06:27:38 msaitoh Exp $ */ /** @@ -5272,6 +5272,61 @@ ixgbe_legacy_irq(void *arg) } } + if (adapter->hw.mac.type != ixgbe_mac_82598EB) { + if ((adapter->feat_en & IXGBE_FEATURE_FDIR) && + (eicr & IXGBE_EICR_FLOW_DIR)) { + if (!atomic_cas_uint(>fdir_reinit, 0, 1)) { +task_requests |= IXGBE_REQUEST_TASK_FDIR; +/* Disable the interrupt */ +eims_disable |= IXGBE_EIMS_FLOW_DIR; + } + } + + if (eicr & IXGBE_EICR_ECC) { + device_printf(adapter->dev, + "CRITICAL: ECC ERROR!! Please Reboot!!\n"); + /* Disable interrupt to prevent log spam */ + eims_disable |= IXGBE_EICR_ECC; + } + + /* Check for over temp condition */ + if (adapter->feat_en & IXGBE_FEATURE_TEMP_SENSOR) { + switch (adapter->hw.mac.type) { + case ixgbe_mac_X550EM_a: +if (!(eicr & IXGBE_EICR_GPI_SDP0_X550EM_a)) + break; +/* Disable interrupt to prevent log spam */ +eims_disable |= IXGBE_EICR_GPI_SDP0_X550EM_a; + +retval = hw->phy.ops.check_overtemp(hw); +if (retval != IXGBE_ERR_OVERTEMP) + break; +device_printf(adapter->dev, "CRITICAL: OVER TEMP!! PHY IS SHUT DOWN!!\n"); +device_printf(adapter->dev, "System shutdown required!\n"); +break; + default: +if (!(eicr & IXGBE_EICR_TS)) + break; +/* Disable interrupt to prevent log spam */ +eims_disable |= IXGBE_EIMS_TS; + +retval = hw->phy.ops.check_overtemp(hw); +if (retval != IXGBE_ERR_OVERTEMP) + break; +device_printf(adapter->dev, "CRITICAL: OVER TEMP!! PHY IS SHUT DOWN!!\n"); +device_printf(adapter->dev, "System shutdown required!\n"); +break; + } + } + + /* Check for VF message */ + if ((adapter->feat_en & IXGBE_FEATURE_SRIOV) && + (eicr & IXGBE_EICR_MAILBOX)) { + task_requests |= IXGBE_REQUEST_TASK_MBX; + eims_disable |= IXGBE_EIMS_MAILBOX; + } + } + /* Check for fan failure */ if (adapter->feat_en & IXGBE_FEATURE_FAN_FAIL) { retval = ixgbe_check_fan_failure(adapter, eicr, true);
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Sat Dec 26 06:17:55 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe: ixgbe.c Log Message: Don't return in the middle of ixgbe_msix_admin() when an flow director reinit failed. NetBSD currently doesn't support flow director, so this is not a real bug. To generate a diff of this commit: cvs rdiff -u -r1.274 -r1.275 src/sys/dev/pci/ixgbe/ixgbe.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.274 src/sys/dev/pci/ixgbe/ixgbe.c:1.275 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.274 Sat Dec 26 06:10:17 2020 +++ src/sys/dev/pci/ixgbe/ixgbe.c Sat Dec 26 06:17:55 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.274 2020/12/26 06:10:17 msaitoh Exp $ */ +/* $NetBSD: ixgbe.c,v 1.275 2020/12/26 06:17:55 msaitoh Exp $ */ /** @@ -3151,12 +3151,11 @@ ixgbe_msix_admin(void *arg) if (adapter->hw.mac.type != ixgbe_mac_82598EB) { if ((adapter->feat_en & IXGBE_FEATURE_FDIR) && (eicr & IXGBE_EICR_FLOW_DIR)) { - /* This is probably overkill :) */ - if (!atomic_cas_uint(>fdir_reinit, 0, 1)) -return 1; - task_requests |= IXGBE_REQUEST_TASK_FDIR; - /* Disable the interrupt */ - eims_disable |= IXGBE_EIMS_FLOW_DIR; + if (!atomic_cas_uint(>fdir_reinit, 0, 1)) { +task_requests |= IXGBE_REQUEST_TASK_FDIR; +/* Disable the interrupt */ +eims_disable |= IXGBE_EIMS_FLOW_DIR; + } } if (eicr & IXGBE_EICR_ECC) {
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Sat Dec 26 06:10:17 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe: ixgbe.c ixgbe_type.h Log Message: Disable some interrupt in ixgbe_{legacy_irq,msix_admin}() to prevent log spam. To generate a diff of this commit: cvs rdiff -u -r1.273 -r1.274 src/sys/dev/pci/ixgbe/ixgbe.c cvs rdiff -u -r1.47 -r1.48 src/sys/dev/pci/ixgbe/ixgbe_type.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.273 src/sys/dev/pci/ixgbe/ixgbe.c:1.274 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.273 Sat Dec 26 06:07:16 2020 +++ src/sys/dev/pci/ixgbe/ixgbe.c Sat Dec 26 06:10:17 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.273 2020/12/26 06:07:16 msaitoh Exp $ */ +/* $NetBSD: ixgbe.c,v 1.274 2020/12/26 06:10:17 msaitoh Exp $ */ /** @@ -175,7 +175,7 @@ static void ixgbe_init_locked(struct ada static void ixgbe_ifstop(struct ifnet *, int); static void ixgbe_stop_locked(void *); static void ixgbe_init_device_features(struct adapter *); -static void ixgbe_check_fan_failure(struct adapter *, u32, bool); +static int ixgbe_check_fan_failure(struct adapter *, u32, bool); static void ixgbe_add_media_types(struct adapter *); static void ixgbe_media_status(struct ifnet *, struct ifmediareq *); static int ixgbe_media_change(struct ifnet *); @@ -3162,6 +3162,8 @@ ixgbe_msix_admin(void *arg) if (eicr & IXGBE_EICR_ECC) { device_printf(adapter->dev, "CRITICAL: ECC ERROR!! Please Reboot!!\n"); + /* Disable interrupt to prevent log spam */ + eims_disable |= IXGBE_EICR_ECC; } /* Check for over temp condition */ @@ -3170,6 +3172,8 @@ ixgbe_msix_admin(void *arg) case ixgbe_mac_X550EM_a: if (!(eicr & IXGBE_EICR_GPI_SDP0_X550EM_a)) break; +/* Disable interrupt to prevent log spam */ +eims_disable |= IXGBE_EICR_GPI_SDP0_X550EM_a; retval = hw->phy.ops.check_overtemp(hw); if (retval != IXGBE_ERR_OVERTEMP) @@ -3180,6 +3184,8 @@ ixgbe_msix_admin(void *arg) default: if (!(eicr & IXGBE_EICR_TS)) break; +/* Disable interrupt to prevent log spam */ +eims_disable |= IXGBE_EIMS_TS; retval = hw->phy.ops.check_overtemp(hw); if (retval != IXGBE_ERR_OVERTEMP) @@ -3200,7 +3206,11 @@ ixgbe_msix_admin(void *arg) /* Check for fan failure */ if (adapter->feat_en & IXGBE_FEATURE_FAN_FAIL) { - ixgbe_check_fan_failure(adapter, eicr, true); + retval = ixgbe_check_fan_failure(adapter, eicr, true); + if (retval == IXGBE_ERR_FAN_FAILURE) { + /* Disable interrupt to prevent log spam */ + eims_disable |= IXGBE_EIMS_GPI_SDP1_BY_MAC(hw); + } } /* External PHY interrupt */ @@ -5185,6 +5195,7 @@ ixgbe_legacy_irq(void *arg) u32 eims_enable = 0; u32 eims_disable = 0; u32 task_requests = 0; + s32 retval; eims_orig = IXGBE_READ_REG(hw, IXGBE_EIMS); /* @@ -5264,7 +5275,11 @@ ixgbe_legacy_irq(void *arg) /* Check for fan failure */ if (adapter->feat_en & IXGBE_FEATURE_FAN_FAIL) { - ixgbe_check_fan_failure(adapter, eicr, true); + retval = ixgbe_check_fan_failure(adapter, eicr, true); + if (retval == IXGBE_ERR_FAN_FAILURE) { + /* Disable interrupt to prevent log spam */ + eims_disable |= IXGBE_EIMS_GPI_SDP1_BY_MAC(hw); + } } /* External PHY interrupt */ @@ -6539,7 +6554,7 @@ ixgbe_ioctl(struct ifnet *ifp, u_long co / * ixgbe_check_fan_failure / -static void +static int ixgbe_check_fan_failure(struct adapter *adapter, u32 reg, bool in_interrupt) { u32 mask; @@ -6547,8 +6562,12 @@ ixgbe_check_fan_failure(struct adapter * mask = (in_interrupt) ? IXGBE_EICR_GPI_SDP1_BY_MAC(>hw) : IXGBE_ESDP_SDP1; - if (reg & mask) + if (reg & mask) { device_printf(adapter->dev, "\nCRITICAL: FAN FAILURE!! REPLACE IMMEDIATELY!!\n"); + return IXGBE_ERR_FAN_FAILURE; + } + + return IXGBE_SUCCESS; } /* ixgbe_check_fan_failure */ / Index: src/sys/dev/pci/ixgbe/ixgbe_type.h diff -u src/sys/dev/pci/ixgbe/ixgbe_type.h:1.47 src/sys/dev/pci/ixgbe/ixgbe_type.h:1.48 --- src/sys/dev/pci/ixgbe/ixgbe_type.h:1.47 Sat Dec 26 06:07:16 2020 +++ src/sys/dev/pci/ixgbe/ixgbe_type.h Sat Dec 26 06:10:17 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe_type.h,v 1.47 2020/12/26 06:07:16 msaitoh Exp $ */ +/* $NetBSD: ixgbe_type.h,v 1.48 2020/12/26 06:10:17 msaitoh Exp $ */ /** SPDX-License-Identifier: BSD-3-Clause @@ -4324,7 +4324,7 @@ struct ixgbe_hw { #define IXGBE_ERR_NOT_TRUSTED -50 /* XXX NetBSD */ #define IXGBE_ERR_NOT_IN_PROMISC -51 /* XXX NetBSD */ - +#define
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Sat Dec 26 06:07:16 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe: ixgbe.c ixgbe.h ixgbe_type.h Log Message: Disable/enable the OTHER interrupts correctly. The OTHER interrupt was not blocked correctly when MSI-X is used. ixgbe.c rev. 1.260 added new mutex to avoid the race but it didn't disable the interrupt itself. Calling ixgbe_enable_intr() enables all interrupts, so it's not good to call it when some interrupt sources should not be enabled (e.g.: calling ixgbe_enable_intr() in ixgbe_handle_admin() enables queue interrupt). IXGBE_REQUEST_TASK_NEED_ACKINTR doesn't work as expected because ixgbe_handle_admin() can't know which task is enqueued from the interrupt context and can't re-enable a specific EIMS bit. Solve the above three problems by the following two changes: - MSI-X: Disable the OTHER interrupts in the biginning of ixgbe_msix_admin(). - Set mask bits correctly at the end of ixgbe_legacy_irq() and ixgbe_msix_admin() using with eim_orig, eims_enable and eims_disable. - Remove IXGBE_REQUEST_TASK_NEED_ACKINTR and add IXGBE_REQUEST_TASK_{MOD,MSF}_WOI. To generate a diff of this commit: cvs rdiff -u -r1.272 -r1.273 src/sys/dev/pci/ixgbe/ixgbe.c cvs rdiff -u -r1.73 -r1.74 src/sys/dev/pci/ixgbe/ixgbe.h cvs rdiff -u -r1.46 -r1.47 src/sys/dev/pci/ixgbe/ixgbe_type.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.272 src/sys/dev/pci/ixgbe/ixgbe.c:1.273 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.272 Sat Dec 26 06:02:42 2020 +++ src/sys/dev/pci/ixgbe/ixgbe.c Sat Dec 26 06:07:16 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.272 2020/12/26 06:02:42 msaitoh Exp $ */ +/* $NetBSD: ixgbe.c,v 1.273 2020/12/26 06:07:16 msaitoh Exp $ */ /** @@ -269,7 +269,7 @@ static int ixgbe_msix_admin(void *); static void ixgbe_handle_que(void *); static void ixgbe_handle_link(void *); static void ixgbe_handle_msf(void *); -static void ixgbe_handle_mod(void *); +static void ixgbe_handle_mod(void *, bool); static void ixgbe_handle_phy(void *); /* Deferred workqueue handlers */ @@ -1566,9 +1566,9 @@ ixgbe_config_link(struct adapter *adapte if (sfp) { if (hw->phy.multispeed_fiber) { ixgbe_enable_tx_laser(hw); - task_requests |= IXGBE_REQUEST_TASK_MSF; + task_requests |= IXGBE_REQUEST_TASK_MSF_WOI; } - task_requests |= IXGBE_REQUEST_TASK_MOD; + task_requests |= IXGBE_REQUEST_TASK_MOD_WOI; mutex_enter(>admin_mtx); adapter->task_requests |= task_requests; @@ -3090,17 +3090,24 @@ ixgbe_msix_admin(void *arg) struct adapter *adapter = arg; struct ixgbe_hw *hw = >hw; u32 eicr, eicr_mask; + u32 eims_orig; + u32 eims_disable = 0; u32 task_requests = 0; s32 retval; ++adapter->admin_irqev.ev_count; - /* First get the cause */ + eims_orig = IXGBE_READ_REG(hw, IXGBE_EIMS); + /* Pause other interrupts */ + IXGBE_WRITE_REG(hw, IXGBE_EIMC, IXGBE_MSIX_OTHER_CLEAR_MASK); + /* + * First get the cause. + * * The specifications of 82598, 82599, X540 and X550 say EICS register * is write only. However, Linux says it is a workaround for silicon - * errata to read EICS instead of EICR to get interrupt cause. It seems - * there is a problem about read clear mechanism for EICR register. + * errata to read EICS instead of EICR to get interrupt cause. + * At least, reading EICR clears lower 16bits of EIMS on 82598. */ eicr = IXGBE_READ_REG(hw, IXGBE_EICS); /* Be sure the queue bits are not cleared */ @@ -3110,8 +3117,8 @@ ixgbe_msix_admin(void *arg) /* Link status change */ if (eicr & IXGBE_EICR_LSC) { - IXGBE_WRITE_REG(hw, IXGBE_EIMC, IXGBE_EIMC_LSC); task_requests |= IXGBE_REQUEST_TASK_LSC; + eims_disable |= IXGBE_EIMS_LSC; } if (ixgbe_is_sfp(hw)) { @@ -3131,11 +3138,13 @@ ixgbe_msix_admin(void *arg) || ((hw->phy.sfp_type == ixgbe_sfp_type_not_present) && (eicr & IXGBE_EICR_LSC))) { task_requests |= IXGBE_REQUEST_TASK_MOD; + eims_disable |= IXGBE_EIMS_LSC; } if ((hw->mac.type == ixgbe_mac_82599EB) && (eicr & IXGBE_EICR_GPI_SDP1_BY_MAC(hw))) { task_requests |= IXGBE_REQUEST_TASK_MSF; + eims_disable |= IXGBE_EIMS_GPI_SDP1_BY_MAC(hw); } } @@ -3145,9 +3154,9 @@ ixgbe_msix_admin(void *arg) /* This is probably overkill :) */ if (!atomic_cas_uint(>fdir_reinit, 0, 1)) return 1; - /* Disable the interrupt */ - IXGBE_WRITE_REG(hw, IXGBE_EIMC, IXGBE_EIMC_FLOW_DIR); task_requests |= IXGBE_REQUEST_TASK_FDIR; + /* Disable the interrupt */ + eims_disable |= IXGBE_EIMS_FLOW_DIR; } if (eicr & IXGBE_EICR_ECC) { @@ -3161,8 +3170,7 @@ ixgbe_msix_admin(void *arg) case ixgbe_mac_X550EM_a: if (!(eicr &
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Sat Dec 26 06:02:42 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe: ixgbe.c Log Message: Check EICR's queue bit instead of IFF_RUNNING. This change fixes a bug that it might incorrectly enable interrupt when IFF_RUNNING is not set. It also changes that the TX/RX is not processed if a queue interrupt isn't occurred. To generate a diff of this commit: cvs rdiff -u -r1.271 -r1.272 src/sys/dev/pci/ixgbe/ixgbe.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.271 src/sys/dev/pci/ixgbe/ixgbe.c:1.272 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.271 Sat Dec 26 06:01:22 2020 +++ src/sys/dev/pci/ixgbe/ixgbe.c Sat Dec 26 06:02:42 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.271 2020/12/26 06:01:22 msaitoh Exp $ */ +/* $NetBSD: ixgbe.c,v 1.272 2020/12/26 06:02:42 msaitoh Exp $ */ /** @@ -5154,7 +5154,6 @@ ixgbe_legacy_irq(void *arg) struct ix_queue *que = arg; struct adapter *adapter = que->adapter; struct ixgbe_hw *hw = >hw; - struct ifnet *ifp = adapter->ifp; struct tx_ring *txr = adapter->tx_rings; bool reenable_intr = true; u32 eicr, eicr_mask; @@ -5172,14 +5171,16 @@ ixgbe_legacy_irq(void *arg) eicr = IXGBE_READ_REG(hw, IXGBE_EICR); adapter->stats.pf.legint.ev_count++; - ++que->irqs.ev_count; if (eicr == 0) { adapter->stats.pf.intzero.ev_count++; IXGBE_WRITE_REG(hw, IXGBE_EIMS, eims_orig); return 0; } - if ((ifp->if_flags & IFF_RUNNING) != 0) { + /* Queue (0) intr */ + if ((eicr & IXGBE_EIMC_RTX_QUEUE) != 0) { + ++que->irqs.ev_count; + /* * The same as ixgbe_msix_que() about * "que->txrx_use_workqueue".
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Sat Dec 26 06:01:22 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe: ixgbe.c Log Message: Don't use "more" flag for simplify in ixgbe_legacy_irq(). No functional change intended. To generate a diff of this commit: cvs rdiff -u -r1.270 -r1.271 src/sys/dev/pci/ixgbe/ixgbe.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.270 src/sys/dev/pci/ixgbe/ixgbe.c:1.271 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.270 Thu Dec 24 22:36:43 2020 +++ src/sys/dev/pci/ixgbe/ixgbe.c Sat Dec 26 06:01:22 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.270 2020/12/24 22:36:43 msaitoh Exp $ */ +/* $NetBSD: ixgbe.c,v 1.271 2020/12/26 06:01:22 msaitoh Exp $ */ /** @@ -5156,7 +5156,6 @@ ixgbe_legacy_irq(void *arg) struct ixgbe_hw *hw = >hw; struct ifnet *ifp = adapter->ifp; struct tx_ring *txr = adapter->tx_rings; - bool more = false; bool reenable_intr = true; u32 eicr, eicr_mask; u32 eims_orig; @@ -5187,13 +5186,6 @@ ixgbe_legacy_irq(void *arg) */ que->txrx_use_workqueue = adapter->txrx_use_workqueue; -#ifdef __NetBSD__ - /* Don't run ixgbe_rxeof in interrupt context */ - more = true; -#else - more = ixgbe_rxeof(que); -#endif - IXGBE_TX_LOCK(txr); ixgbe_txeof(txr); #ifdef notyet @@ -5201,6 +5193,10 @@ ixgbe_legacy_irq(void *arg) ixgbe_start_locked(ifp, txr); #endif IXGBE_TX_UNLOCK(txr); + + que->req.ev_count++; + ixgbe_sched_handle_que(adapter, que); + reenable_intr = false; } /* Link status change */ @@ -5242,11 +5238,6 @@ ixgbe_legacy_irq(void *arg) (eicr & IXGBE_EICR_GPI_SDP0_X540)) task_requests |= IXGBE_REQUEST_TASK_PHY; - if (more) { - que->req.ev_count++; - ixgbe_sched_handle_que(adapter, que); - reenable_intr = false; - } if (task_requests != 0) { /* Re-enabling other interrupts is done in the admin task */ task_requests |= IXGBE_REQUEST_TASK_NEED_ACKINTR;
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Thu Dec 24 22:36:43 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe: ixgbe.c Log Message: Simplify setting of EIAC register. No functional change intended. To generate a diff of this commit: cvs rdiff -u -r1.269 -r1.270 src/sys/dev/pci/ixgbe/ixgbe.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.269 src/sys/dev/pci/ixgbe/ixgbe.c:1.270 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.269 Thu Dec 24 18:32:53 2020 +++ src/sys/dev/pci/ixgbe/ixgbe.c Thu Dec 24 22:36:43 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.269 2020/12/24 18:32:53 msaitoh Exp $ */ +/* $NetBSD: ixgbe.c,v 1.270 2020/12/24 22:36:43 msaitoh Exp $ */ /** @@ -5085,13 +5085,11 @@ ixgbe_enable_intr(struct adapter *adapte /* With MSI-X we use auto clear */ if (adapter->msix_mem) { - mask = IXGBE_EIMS_ENABLE_MASK; - /* Don't autoclear Link */ - mask &= ~IXGBE_EIMS_OTHER; - mask &= ~IXGBE_EIMS_LSC; - if (adapter->feat_cap & IXGBE_FEATURE_SRIOV) - mask &= ~IXGBE_EIMS_MAILBOX; - IXGBE_WRITE_REG(hw, IXGBE_EIAC, mask); + /* + * It's not required to set TCP_TIMER because we don't use + * it. + */ + IXGBE_WRITE_REG(hw, IXGBE_EIAC, IXGBE_EIMS_RTX_QUEUE); } /*
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Thu Dec 24 18:32:53 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe: ixgbe.c Log Message: Fix a bug that INTx is disabled if the INTx line is shared with other device. ixgbe.c rev. 1.264 was not correct. Restore EIMS before return. To read ECIR, clearing EIMC is required for an errata, so 0) save the original EIMS value 1) clear EIMS 2) read EICR 3) restore with the saved value. To generate a diff of this commit: cvs rdiff -u -r1.268 -r1.269 src/sys/dev/pci/ixgbe/ixgbe.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.268 src/sys/dev/pci/ixgbe/ixgbe.c:1.269 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.268 Thu Dec 24 15:51:33 2020 +++ src/sys/dev/pci/ixgbe/ixgbe.c Thu Dec 24 18:32:53 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.268 2020/12/24 15:51:33 msaitoh Exp $ */ +/* $NetBSD: ixgbe.c,v 1.269 2020/12/24 18:32:53 msaitoh Exp $ */ /** @@ -5161,9 +5161,14 @@ ixgbe_legacy_irq(void *arg) bool more = false; bool reenable_intr = true; u32 eicr, eicr_mask; + u32 eims_orig; u32 task_requests = 0; - /* Silicon errata #26 on 82598. Disable all interrupts */ + eims_orig = IXGBE_READ_REG(hw, IXGBE_EIMS); + /* + * Silicon errata #26 on 82598. Disable all interrupts before reading + * EICR. + */ IXGBE_WRITE_REG(hw, IXGBE_EIMC, IXGBE_IRQ_CLEAR_MASK); /* Read and clear EICR */ @@ -5173,6 +5178,7 @@ ixgbe_legacy_irq(void *arg) ++que->irqs.ev_count; if (eicr == 0) { adapter->stats.pf.intzero.ev_count++; + IXGBE_WRITE_REG(hw, IXGBE_EIMS, eims_orig); return 0; }
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Thu Dec 24 15:51:33 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe: ixgbe.c Log Message: The EICR register are cleared in the beginning of the ixgbe_legacy_irq(), so it's not required to clear each bit later in the function. To generate a diff of this commit: cvs rdiff -u -r1.267 -r1.268 src/sys/dev/pci/ixgbe/ixgbe.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.267 src/sys/dev/pci/ixgbe/ixgbe.c:1.268 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.267 Thu Dec 24 15:51:04 2020 +++ src/sys/dev/pci/ixgbe/ixgbe.c Thu Dec 24 15:51:33 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.267 2020/12/24 15:51:04 msaitoh Exp $ */ +/* $NetBSD: ixgbe.c,v 1.268 2020/12/24 15:51:33 msaitoh Exp $ */ /** @@ -5166,6 +5166,7 @@ ixgbe_legacy_irq(void *arg) /* Silicon errata #26 on 82598. Disable all interrupts */ IXGBE_WRITE_REG(hw, IXGBE_EIMC, IXGBE_IRQ_CLEAR_MASK); + /* Read and clear EICR */ eicr = IXGBE_READ_REG(hw, IXGBE_EICR); adapter->stats.pf.legint.ev_count++; @@ -5218,14 +5219,11 @@ ixgbe_legacy_irq(void *arg) if ((eicr & eicr_mask) || ((hw->phy.sfp_type == ixgbe_sfp_type_not_present) && (eicr & IXGBE_EICR_LSC))) { - IXGBE_WRITE_REG(hw, IXGBE_EICR, eicr_mask); task_requests |= IXGBE_REQUEST_TASK_MOD; } if ((hw->mac.type == ixgbe_mac_82599EB) && (eicr & IXGBE_EICR_GPI_SDP1_BY_MAC(hw))) { - IXGBE_WRITE_REG(hw, IXGBE_EICR, - IXGBE_EICR_GPI_SDP1_BY_MAC(hw)); task_requests |= IXGBE_REQUEST_TASK_MSF; } } @@ -5233,7 +5231,6 @@ ixgbe_legacy_irq(void *arg) /* Check for fan failure */ if (adapter->feat_en & IXGBE_FEATURE_FAN_FAIL) { ixgbe_check_fan_failure(adapter, eicr, true); - IXGBE_WRITE_REG(hw, IXGBE_EICR, IXGBE_EICR_GPI_SDP1_BY_MAC(hw)); } /* External PHY interrupt */
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Thu Dec 24 15:51:04 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe: ixgbe.c Log Message: The EICR register's all OTHER interrupt bits are cleared in the beginning of the ixgbe_msix_admin(), so it's not required to clear each bit later in the function. To generate a diff of this commit: cvs rdiff -u -r1.266 -r1.267 src/sys/dev/pci/ixgbe/ixgbe.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.266 src/sys/dev/pci/ixgbe/ixgbe.c:1.267 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.266 Thu Dec 24 10:37:47 2020 +++ src/sys/dev/pci/ixgbe/ixgbe.c Thu Dec 24 15:51:04 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.266 2020/12/24 10:37:47 msaitoh Exp $ */ +/* $NetBSD: ixgbe.c,v 1.267 2020/12/24 15:51:04 msaitoh Exp $ */ /** @@ -3130,14 +3130,11 @@ ixgbe_msix_admin(void *arg) if ((eicr & eicr_mask) || ((hw->phy.sfp_type == ixgbe_sfp_type_not_present) && (eicr & IXGBE_EICR_LSC))) { - IXGBE_WRITE_REG(hw, IXGBE_EICR, eicr_mask); task_requests |= IXGBE_REQUEST_TASK_MOD; } if ((hw->mac.type == ixgbe_mac_82599EB) && (eicr & IXGBE_EICR_GPI_SDP1_BY_MAC(hw))) { - IXGBE_WRITE_REG(hw, IXGBE_EICR, - IXGBE_EICR_GPI_SDP1_BY_MAC(hw)); task_requests |= IXGBE_REQUEST_TASK_MSF; } } @@ -3156,7 +3153,6 @@ ixgbe_msix_admin(void *arg) if (eicr & IXGBE_EICR_ECC) { device_printf(adapter->dev, "CRITICAL: ECC ERROR!! Please Reboot!!\n"); - IXGBE_WRITE_REG(hw, IXGBE_EICR, IXGBE_EICR_ECC); } /* Check for over temp condition */ @@ -3167,8 +3163,6 @@ ixgbe_msix_admin(void *arg) break; IXGBE_WRITE_REG(hw, IXGBE_EIMC, IXGBE_EICR_GPI_SDP0_X550EM_a); -IXGBE_WRITE_REG(hw, IXGBE_EICR, -IXGBE_EICR_GPI_SDP0_X550EM_a); retval = hw->phy.ops.check_overtemp(hw); if (retval != IXGBE_ERR_OVERTEMP) break; @@ -3183,7 +3177,6 @@ ixgbe_msix_admin(void *arg) break; device_printf(adapter->dev, "CRITICAL: OVER TEMP!! PHY IS SHUT DOWN!!\n"); device_printf(adapter->dev, "System shutdown required!\n"); -IXGBE_WRITE_REG(hw, IXGBE_EICR, IXGBE_EICR_TS); break; } } @@ -3198,13 +3191,11 @@ ixgbe_msix_admin(void *arg) /* Check for fan failure */ if (adapter->feat_en & IXGBE_FEATURE_FAN_FAIL) { ixgbe_check_fan_failure(adapter, eicr, TRUE); - IXGBE_WRITE_REG(hw, IXGBE_EICR, IXGBE_EICR_GPI_SDP1_BY_MAC(hw)); } /* External PHY interrupt */ if ((hw->phy.type == ixgbe_phy_x550em_ext_t) && (eicr & IXGBE_EICR_GPI_SDP0_X540)) { - IXGBE_WRITE_REG(hw, IXGBE_EICR, IXGBE_EICR_GPI_SDP0_X540); task_requests |= IXGBE_REQUEST_TASK_PHY; }
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Thu Dec 24 10:37:47 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe: ixgbe.c Log Message: Reorder some code to reduce diff between ixgbe_legacy_irq() and ixgbe_msix_admin. No functional change intended. To generate a diff of this commit: cvs rdiff -u -r1.265 -r1.266 src/sys/dev/pci/ixgbe/ixgbe.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.265 src/sys/dev/pci/ixgbe/ixgbe.c:1.266 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.265 Thu Dec 24 10:00:36 2020 +++ src/sys/dev/pci/ixgbe/ixgbe.c Thu Dec 24 10:37:47 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.265 2020/12/24 10:00:36 msaitoh Exp $ */ +/* $NetBSD: ixgbe.c,v 1.266 2020/12/24 10:37:47 msaitoh Exp $ */ /** @@ -3108,6 +3108,12 @@ ixgbe_msix_admin(void *arg) /* Clear all OTHER interrupts with write */ IXGBE_WRITE_REG(hw, IXGBE_EICR, eicr); + /* Link status change */ + if (eicr & IXGBE_EICR_LSC) { + IXGBE_WRITE_REG(hw, IXGBE_EIMC, IXGBE_EIMC_LSC); + task_requests |= IXGBE_REQUEST_TASK_LSC; + } + if (ixgbe_is_sfp(hw)) { /* Pluggable optics-related interrupt */ if (hw->mac.type >= ixgbe_mac_X540) @@ -3136,12 +3142,6 @@ ixgbe_msix_admin(void *arg) } } - /* Link status change */ - if (eicr & IXGBE_EICR_LSC) { - IXGBE_WRITE_REG(hw, IXGBE_EIMC, IXGBE_EIMC_LSC); - task_requests |= IXGBE_REQUEST_TASK_LSC; - } - if (adapter->hw.mac.type != ixgbe_mac_82598EB) { if ((adapter->feat_en & IXGBE_FEATURE_FDIR) && (eicr & IXGBE_EICR_FLOW_DIR)) { @@ -5207,11 +5207,9 @@ ixgbe_legacy_irq(void *arg) IXGBE_TX_UNLOCK(txr); } - /* Check for fan failure */ - if (adapter->feat_en & IXGBE_FEATURE_FAN_FAIL) { - ixgbe_check_fan_failure(adapter, eicr, true); - IXGBE_WRITE_REG(hw, IXGBE_EICR, IXGBE_EICR_GPI_SDP1_BY_MAC(hw)); - } + /* Link status change */ + if (eicr & IXGBE_EICR_LSC) + task_requests |= IXGBE_REQUEST_TASK_LSC; if (ixgbe_is_sfp(hw)) { /* Pluggable optics-related interrupt */ @@ -5241,9 +5239,11 @@ ixgbe_legacy_irq(void *arg) } } - /* Link status change */ - if (eicr & IXGBE_EICR_LSC) - task_requests |= IXGBE_REQUEST_TASK_LSC; + /* Check for fan failure */ + if (adapter->feat_en & IXGBE_FEATURE_FAN_FAIL) { + ixgbe_check_fan_failure(adapter, eicr, true); + IXGBE_WRITE_REG(hw, IXGBE_EICR, IXGBE_EICR_GPI_SDP1_BY_MAC(hw)); + } /* External PHY interrupt */ if ((hw->phy.type == ixgbe_phy_x550em_ext_t) &&
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Thu Dec 24 10:00:36 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe: ixgbe.c Log Message: Add some debug printf()s and modify comments. To generate a diff of this commit: cvs rdiff -u -r1.264 -r1.265 src/sys/dev/pci/ixgbe/ixgbe.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.264 src/sys/dev/pci/ixgbe/ixgbe.c:1.265 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.264 Thu Dec 24 06:14:41 2020 +++ src/sys/dev/pci/ixgbe/ixgbe.c Thu Dec 24 10:00:36 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.264 2020/12/24 06:14:41 msaitoh Exp $ */ +/* $NetBSD: ixgbe.c,v 1.265 2020/12/24 10:00:36 msaitoh Exp $ */ /** @@ -3105,7 +3105,7 @@ ixgbe_msix_admin(void *arg) eicr = IXGBE_READ_REG(hw, IXGBE_EICS); /* Be sure the queue bits are not cleared */ eicr &= ~IXGBE_EICR_RTX_QUEUE; - /* Clear interrupt with write */ + /* Clear all OTHER interrupts with write */ IXGBE_WRITE_REG(hw, IXGBE_EICR, eicr); if (ixgbe_is_sfp(hw)) { @@ -5172,7 +5172,7 @@ ixgbe_legacy_irq(void *arg) u32 eicr, eicr_mask; u32 task_requests = 0; - /* Silicon errata #26 on 82598 */ + /* Silicon errata #26 on 82598. Disable all interrupts */ IXGBE_WRITE_REG(hw, IXGBE_EIMC, IXGBE_IRQ_CLEAR_MASK); eicr = IXGBE_READ_REG(hw, IXGBE_EICR); @@ -5186,7 +5186,8 @@ ixgbe_legacy_irq(void *arg) if ((ifp->if_flags & IFF_RUNNING) != 0) { /* - * The same as ixgbe_msix_que() about "que->txrx_use_workqueue". + * The same as ixgbe_msix_que() about + * "que->txrx_use_workqueue". */ que->txrx_use_workqueue = adapter->txrx_use_workqueue; @@ -6142,6 +6143,8 @@ ixgbe_print_debug_info(struct adapter *a device_printf(dev, "EIMS_EX(1):\t%08x\n", IXGBE_READ_REG(hw, IXGBE_EIMS_EX(1))); } + device_printf(dev, "EIAM:\t%08x\n", IXGBE_READ_REG(hw, IXGBE_EIAM)); + device_printf(dev, "EIAC:\t%08x\n", IXGBE_READ_REG(hw, IXGBE_EIAC)); } /* ixgbe_print_debug_info */ / @@ -6566,10 +6569,12 @@ ixgbe_handle_que(void *context) que->req.ev_count++; ixgbe_sched_handle_que(adapter, que); } else if (que->res != NULL) { - /* Re-enable this interrupt */ + /* MSIX: Re-enable this interrupt */ ixgbe_enable_queue(adapter, que->msix); - } else + } else { + /* INTx or MSI */ ixgbe_enable_intr(adapter); + } return; } /* ixgbe_handle_que */
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Thu Dec 24 06:14:42 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe: ixgbe.c Log Message: Remove strange ixgbe_enable_intr() in ixgbe_legacy_irq(). If the interface is UP and the INTx line is shared with other devices, it result in enabling all interrupt sources even if some of them are disabled for the workqueue. Delete ixgbe_enable_intr() in ixgbe_legacy_irq(). To generate a diff of this commit: cvs rdiff -u -r1.263 -r1.264 src/sys/dev/pci/ixgbe/ixgbe.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.263 src/sys/dev/pci/ixgbe/ixgbe.c:1.264 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.263 Tue Dec 22 07:16:23 2020 +++ src/sys/dev/pci/ixgbe/ixgbe.c Thu Dec 24 06:14:41 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.263 2020/12/22 07:16:23 msaitoh Exp $ */ +/* $NetBSD: ixgbe.c,v 1.264 2020/12/24 06:14:41 msaitoh Exp $ */ /** @@ -5181,8 +5181,6 @@ ixgbe_legacy_irq(void *arg) ++que->irqs.ev_count; if (eicr == 0) { adapter->stats.pf.intzero.ev_count++; - if ((ifp->if_flags & IFF_UP) != 0) - ixgbe_enable_intr(adapter); return 0; }
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Tue Dec 22 07:16:23 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe: ixgbe.c Log Message: Correctly ACK the fan failure interrupt in ixgbe_legacy_irq(). To generate a diff of this commit: cvs rdiff -u -r1.262 -r1.263 src/sys/dev/pci/ixgbe/ixgbe.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.262 src/sys/dev/pci/ixgbe/ixgbe.c:1.263 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.262 Fri Dec 11 05:01:19 2020 +++ src/sys/dev/pci/ixgbe/ixgbe.c Tue Dec 22 07:16:23 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.262 2020/12/11 05:01:19 msaitoh Exp $ */ +/* $NetBSD: ixgbe.c,v 1.263 2020/12/22 07:16:23 msaitoh Exp $ */ /** @@ -5211,7 +5211,7 @@ ixgbe_legacy_irq(void *arg) /* Check for fan failure */ if (adapter->feat_en & IXGBE_FEATURE_FAN_FAIL) { ixgbe_check_fan_failure(adapter, eicr, true); - IXGBE_WRITE_REG(hw, IXGBE_EIMS, IXGBE_EICR_GPI_SDP1_BY_MAC(hw)); + IXGBE_WRITE_REG(hw, IXGBE_EICR, IXGBE_EICR_GPI_SDP1_BY_MAC(hw)); } if (ixgbe_is_sfp(hw)) {
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Fri Dec 11 05:01:19 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe: ixgbe.c ixgbe_type.h Log Message: Don't use EIMC_OTHER bit because it's read only other than 82598. Documents say: 82598: All of bit 31(OTHER bit) of EIxx are reserved. In reality, at least EIMS_OTHER and EIMC_OTHER exist and the OTHER interrupt doesn't work without EIMS_OTHER. Other than 82598: EIMS_OTHER is read only and EIMC_OTHER doesn't exist. If one of bit 29..16 is set, EIMS_OTHER is set to 1 (Note that bit 30(TCP timer isn't included)). Even if write bit 31 of EIMC to 1, it's ignored (EIMS_OTHER doesn't set). We introduced new spin mutex in ixgbe.c rev. 1.260, so it's OK to remove EIMC_OTHER stuff. We already set EIMS_OTHER in if_init(), so keep it for 82598. No functional change other than 82598. Another solution is to control bit 30..16 directly to mask/unmask interrupt instead of the mutex. TODO: Some MSI-X interrupt(LSC, module insertion/removal etc.)'s mask/unmask code between ixgbe_msix_admin() and ixgbe_handle_admin() may be wrong. It'll be fixed later. To generate a diff of this commit: cvs rdiff -u -r1.261 -r1.262 src/sys/dev/pci/ixgbe/ixgbe.c cvs rdiff -u -r1.45 -r1.46 src/sys/dev/pci/ixgbe/ixgbe_type.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.261 src/sys/dev/pci/ixgbe/ixgbe.c:1.262 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.261 Mon Nov 30 07:53:42 2020 +++ src/sys/dev/pci/ixgbe/ixgbe.c Fri Dec 11 05:01:19 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.261 2020/11/30 07:53:42 msaitoh Exp $ */ +/* $NetBSD: ixgbe.c,v 1.262 2020/12/11 05:01:19 msaitoh Exp $ */ /** @@ -3095,9 +3095,6 @@ ixgbe_msix_admin(void *arg) ++adapter->admin_irqev.ev_count; - /* Pause other interrupts */ - IXGBE_WRITE_REG(hw, IXGBE_EIMC, IXGBE_EIMC_OTHER); - /* First get the cause */ /* * The specifications of 82598, 82599, X540 and X550 say EICS register @@ -3219,9 +3216,6 @@ ixgbe_msix_admin(void *arg) adapter->task_requests |= task_requests; ixgbe_schedule_admin_tasklet(adapter); mutex_exit(>admin_mtx); - } else { - /* Re-enable other interrupts */ - IXGBE_WRITE_REG(hw, IXGBE_EIMS, IXGBE_EIMS_OTHER); } return 1; @@ -4809,7 +4803,6 @@ ixgbe_handle_admin(struct work *wk, void { struct adapter *adapter = context; struct ifnet *ifp = adapter->ifp; - struct ixgbe_hw *hw = >hw; u32 task_requests; mutex_enter(>admin_mtx); @@ -4848,11 +4841,12 @@ ixgbe_handle_admin(struct work *wk, void } #endif if ((task_requests & IXGBE_REQUEST_TASK_NEED_ACKINTR) != 0) { - if ((adapter->feat_en & IXGBE_FEATURE_MSIX) != 0) { - /* Re-enable other interrupts */ - IXGBE_WRITE_REG(hw, IXGBE_EIMS, IXGBE_EIMS_OTHER); - } else - ixgbe_enable_intr(adapter); + /* + * XXX FIXME. + * ixgbe_enable_intr() enables all interrupts. It might enable + * an interrupt which should not be enabled. + */ + ixgbe_enable_intr(adapter); } IXGBE_CORE_UNLOCK(adapter); Index: src/sys/dev/pci/ixgbe/ixgbe_type.h diff -u src/sys/dev/pci/ixgbe/ixgbe_type.h:1.45 src/sys/dev/pci/ixgbe/ixgbe_type.h:1.46 --- src/sys/dev/pci/ixgbe/ixgbe_type.h:1.45 Mon Aug 31 11:19:54 2020 +++ src/sys/dev/pci/ixgbe/ixgbe_type.h Fri Dec 11 05:01:19 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe_type.h,v 1.45 2020/08/31 11:19:54 msaitoh Exp $ */ +/* $NetBSD: ixgbe_type.h,v 1.46 2020/12/11 05:01:19 msaitoh Exp $ */ /** SPDX-License-Identifier: BSD-3-Clause @@ -1998,6 +1998,13 @@ enum { #define IXGBE_EIMS_PBUR IXGBE_EICR_PBUR /* Pkt Buf Handler Err */ #define IXGBE_EIMS_DHER IXGBE_EICR_DHER /* Descr Handler Error */ #define IXGBE_EIMS_TCP_TIMER IXGBE_EICR_TCP_TIMER /* TCP Timer */ +/* + * EIMS_OTHER is R/W on 82598 though the document says it's reserved. + * It MUST be required to set this bit to get OTHER interrupt. + * + * On other chips, it's read only. It's set if any bits of 29..16 is not zero. + * Bit 30 (TCP_TIMER) doesn't affect to EIMS_OTHER. + */ #define IXGBE_EIMS_OTHER IXGBE_EICR_OTHER /* INT Cause Active */ /* Extended Interrupt Mask Clear */ @@ -2019,6 +2026,7 @@ enum { #define IXGBE_EIMC_PBUR IXGBE_EICR_PBUR /* Pkt Buf Handler Err */ #define IXGBE_EIMC_DHER IXGBE_EICR_DHER /* Desc Handler Err */ #define IXGBE_EIMC_TCP_TIMER IXGBE_EICR_TCP_TIMER /* TCP Timer */ +/* EIMC_OTHER works only on 82598. See EIMS_OTHER's comment */ #define IXGBE_EIMC_OTHER IXGBE_EICR_OTHER /* INT Cause Active */ #define IXGBE_EIMS_ENABLE_MASK ( \
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Mon Nov 30 07:53:42 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe: ixgbe.c Log Message: Apply ixgbe.c rev. 1.204 which was for ixgbe_msix_admin() to ixgbe_legacy_irq(), too. > An interrupt might not arrive when a module is inserted. When an link > status change interrupt occurred and the driver still regard SFP as > unplugged, issue the module softint before issuing LSC interrupt. TODO: Reduce duplicated code. To generate a diff of this commit: cvs rdiff -u -r1.260 -r1.261 src/sys/dev/pci/ixgbe/ixgbe.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.260 src/sys/dev/pci/ixgbe/ixgbe.c:1.261 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.260 Tue Nov 17 04:50:29 2020 +++ src/sys/dev/pci/ixgbe/ixgbe.c Mon Nov 30 07:53:42 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.260 2020/11/17 04:50:29 knakahara Exp $ */ +/* $NetBSD: ixgbe.c,v 1.261 2020/11/30 07:53:42 msaitoh Exp $ */ /** @@ -5220,10 +5220,6 @@ ixgbe_legacy_irq(void *arg) IXGBE_WRITE_REG(hw, IXGBE_EIMS, IXGBE_EICR_GPI_SDP1_BY_MAC(hw)); } - /* Link status change */ - if (eicr & IXGBE_EICR_LSC) - task_requests |= IXGBE_REQUEST_TASK_LSC; - if (ixgbe_is_sfp(hw)) { /* Pluggable optics-related interrupt */ if (hw->mac.type >= ixgbe_mac_X540) @@ -5231,7 +5227,15 @@ ixgbe_legacy_irq(void *arg) else eicr_mask = IXGBE_EICR_GPI_SDP2_BY_MAC(hw); - if (eicr & eicr_mask) { + /* + * An interrupt might not arrive when a module is inserted. + * When an link status change interrupt occurred and the driver + * still regard SFP as unplugged, issue the module softint + * and then issue LSC interrupt. + */ + if ((eicr & eicr_mask) + || ((hw->phy.sfp_type == ixgbe_sfp_type_not_present) + && (eicr & IXGBE_EICR_LSC))) { IXGBE_WRITE_REG(hw, IXGBE_EICR, eicr_mask); task_requests |= IXGBE_REQUEST_TASK_MOD; } @@ -5244,6 +5248,10 @@ ixgbe_legacy_irq(void *arg) } } + /* Link status change */ + if (eicr & IXGBE_EICR_LSC) + task_requests |= IXGBE_REQUEST_TASK_LSC; + /* External PHY interrupt */ if ((hw->phy.type == ixgbe_phy_x550em_ext_t) && (eicr & IXGBE_EICR_GPI_SDP0_X540))
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Mon Nov 30 05:30:56 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe: ixgbe_vf.c Log Message: s/ we we / we / To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/sys/dev/pci/ixgbe/ixgbe_vf.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ixgbe_vf.c diff -u src/sys/dev/pci/ixgbe/ixgbe_vf.c:1.24 src/sys/dev/pci/ixgbe/ixgbe_vf.c:1.25 --- src/sys/dev/pci/ixgbe/ixgbe_vf.c:1.24 Wed Jul 22 01:24:40 2020 +++ src/sys/dev/pci/ixgbe/ixgbe_vf.c Mon Nov 30 05:30:56 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe_vf.c,v 1.24 2020/07/22 01:24:40 msaitoh Exp $ */ +/* $NetBSD: ixgbe_vf.c,v 1.25 2020/11/30 05:30:56 msaitoh Exp $ */ /** SPDX-License-Identifier: BSD-3-Clause @@ -784,7 +784,7 @@ int ixgbevf_get_queues(struct ixgbe_hw * msg[0] &= ~IXGBE_VT_MSGTYPE_CTS; /* - * if we we didn't get an ACK there must have been + * if we didn't get an ACK there must have been * some sort of mailbox error so we should treat it * as such */
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Thu Nov 19 02:23:24 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe: ixgbe.h Log Message: Add comment. To generate a diff of this commit: cvs rdiff -u -r1.72 -r1.73 src/sys/dev/pci/ixgbe/ixgbe.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ixgbe.h diff -u src/sys/dev/pci/ixgbe/ixgbe.h:1.72 src/sys/dev/pci/ixgbe/ixgbe.h:1.73 --- src/sys/dev/pci/ixgbe/ixgbe.h:1.72 Tue Nov 17 04:50:29 2020 +++ src/sys/dev/pci/ixgbe/ixgbe.h Thu Nov 19 02:23:24 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.h,v 1.72 2020/11/17 04:50:29 knakahara Exp $ */ +/* $NetBSD: ixgbe.h,v 1.73 2020/11/19 02:23:24 msaitoh Exp $ */ /** SPDX-License-Identifier: BSD-3-Clause @@ -331,8 +331,8 @@ struct ix_queue { struct evcnt irqs; /* Hardware interrupt */ struct evcnt handleq; /* software_interrupt */ struct evcnt req; /* deferred */ - char namebuf[32]; - char evnamebuf[32]; + char namebuf[32]; /* Name for sysctl */ + char evnamebuf[32]; /* Name for evcnt */ /* Lock for disabled_count and this queue's EIMS/EIMC bit */ kmutex_t dc_mtx;
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: knakahara Date: Tue Nov 17 04:50:29 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe: ixgbe.c ixgbe.h Log Message: Add new spin mutex to avoid race between ixgbe_msix_admin() and ixgbe_handle_admin(). At first, it seems "IXGBE_WRITE_REG(hw, IXGBE_EIMC, IXGBE_EIMC_OTHER)" cannot stop interrupts, because 31th bit is reserved for 82598, 82599, X540 and X550. So, the current following design (1) ixgbe_msix_admin() disables interrupts (2) ixgbe_msix_admin() calls workqueue_enqueue() for ixgbe_handle_admin() (3) ixgbe_handle_admin() does interrupt processing (4) after ixgbe_handle_admin() has done all interrupt processings, ixgbe_handle_admin() enables interrupts does not work correctly, that is, interrupts can be lost while ixgbe_handle_admin() is running. To fix that, add new spin mutex(adapter->admmin_mtx) which protects atomically the following two members. - adapter->admin_pending - adapter->task_requests The unnecessary "IXGBE_WRITE_REG(hw, IXGBE_EIMC, IXGBE_EIMC_OTHER)" code will be removed later. Reviewed and tested by hikaru@n.o and msaitoh@n.o, thanks. To generate a diff of this commit: cvs rdiff -u -r1.259 -r1.260 src/sys/dev/pci/ixgbe/ixgbe.c cvs rdiff -u -r1.71 -r1.72 src/sys/dev/pci/ixgbe/ixgbe.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.259 src/sys/dev/pci/ixgbe/ixgbe.c:1.260 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.259 Fri Nov 13 05:53:36 2020 +++ src/sys/dev/pci/ixgbe/ixgbe.c Tue Nov 17 04:50:29 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.259 2020/11/13 05:53:36 msaitoh Exp $ */ +/* $NetBSD: ixgbe.c,v 1.260 2020/11/17 04:50:29 knakahara Exp $ */ /** @@ -1136,6 +1136,7 @@ ixgbe_attach(device_t parent, device_t d goto err_late; /* Tasklets for Link, SFP, Multispeed Fiber and Flow Director */ + mutex_init(&(adapter)->admin_mtx, MUTEX_DEFAULT, IPL_NET); snprintf(wqname, sizeof(wqname), "%s-admin", device_xname(dev)); error = workqueue_create(>admin_wq, wqname, ixgbe_handle_admin, adapter, IXGBE_WORKQUEUE_PRI, IPL_NET, @@ -1283,6 +1284,7 @@ err_out: ixgbe_free_pci_resources(adapter); if (adapter->mta != NULL) free(adapter->mta, M_DEVBUF); + mutex_destroy(&(adapter)->admin_mtx); /* XXX appropriate order? */ IXGBE_CORE_LOCK_DESTROY(adapter); return; @@ -1538,10 +1540,13 @@ static void ixgbe_schedule_admin_tasklet(struct adapter *adapter) { + KASSERT(mutex_owned(>admin_mtx)); + if (__predict_true(adapter->osdep.detaching == false)) { - if (atomic_cas_uint(>admin_pending, 0, 1) == 0) + if (adapter->admin_pending == 0) workqueue_enqueue(adapter->admin_wq, >admin_wc, NULL); + adapter->admin_pending = 1; } } @@ -1564,8 +1569,11 @@ ixgbe_config_link(struct adapter *adapte task_requests |= IXGBE_REQUEST_TASK_MSF; } task_requests |= IXGBE_REQUEST_TASK_MOD; - atomic_or_32(>task_requests, task_requests); + + mutex_enter(>admin_mtx); + adapter->task_requests |= task_requests; ixgbe_schedule_admin_tasklet(adapter); + mutex_exit(>admin_mtx); } else { struct ifmedia *ifm = >media; @@ -3206,8 +3214,11 @@ ixgbe_msix_admin(void *arg) if (task_requests != 0) { /* Re-enabling other interrupts is done in the admin task */ task_requests |= IXGBE_REQUEST_TASK_NEED_ACKINTR; - atomic_or_32(>task_requests, task_requests); + + mutex_enter(>admin_mtx); + adapter->task_requests |= task_requests; ixgbe_schedule_admin_tasklet(adapter); + mutex_exit(>admin_mtx); } else { /* Re-enable other interrupts */ IXGBE_WRITE_REG(hw, IXGBE_EIMS, IXGBE_EIMS_OTHER); @@ -3758,6 +3769,7 @@ ixgbe_detach(device_t dev, int flags) ixgbe_free_queues(adapter); free(adapter->mta, M_DEVBUF); + mutex_destroy(>admin_mtx); /* XXX appropriate order? */ IXGBE_CORE_LOCK_DESTROY(adapter); return (0); @@ -4522,9 +4534,10 @@ ixgbe_handle_timer(struct work *wk, void sched_mod_task = true; } if (sched_mod_task) { - atomic_or_32(>task_requests, - IXGBE_REQUEST_TASK_MOD); + mutex_enter(>admin_mtx); + adapter->task_requests |= IXGBE_REQUEST_TASK_MOD; ixgbe_schedule_admin_tasklet(adapter); + mutex_exit(>admin_mtx); } } @@ -4733,8 +4746,11 @@ out: * MSF. At least, calling ixgbe_handle_msf on 82598 DA makes the link * flap because the function calls setup_link(). */ - if (hw->mac.type != ixgbe_mac_82598EB) - atomic_or_32(>task_requests, IXGBE_REQUEST_TASK_MSF); + if (hw->mac.type != ixgbe_mac_82598EB) { + mutex_enter(>admin_mtx); + adapter->task_requests |= IXGBE_REQUEST_TASK_MSF; + mutex_exit(>admin_mtx); + } /* * Don't call ixgbe_schedule_admin_tasklet() because we are on @@ -4794,7 +4810,13 @@ ixgbe_handle_admin(struct work *wk, void struct adapter *adapter = context;
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Fri Nov 13 05:53:36 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe: ixgbe.c Log Message: Fix a bug that some advertise speeds can't be set with hw.ixgN.advertise_speed if both 2.5G and 5G are set. Fix the error message, too. To generate a diff of this commit: cvs rdiff -u -r1.258 -r1.259 src/sys/dev/pci/ixgbe/ixgbe.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.258 src/sys/dev/pci/ixgbe/ixgbe.c:1.259 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.258 Mon Sep 7 09:14:53 2020 +++ src/sys/dev/pci/ixgbe/ixgbe.c Fri Nov 13 05:53:36 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.258 2020/09/07 09:14:53 knakahara Exp $ */ +/* $NetBSD: ixgbe.c,v 1.259 2020/11/13 05:53:36 msaitoh Exp $ */ /** @@ -5542,9 +5542,9 @@ ixgbe_set_advertise(struct adapter *adap return (EINVAL); } - if (advertise < 0x0 || advertise > 0x2f) { + if (advertise < 0x0 || advertise > 0x3f) { device_printf(dev, - "Invalid advertised speed; valid modes are 0x0 through 0x7\n"); + "Invalid advertised speed; valid modes are 0x0 through 0x3f\n"); return (EINVAL); }
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Fri Nov 13 04:12:38 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe: ixgbe_x540.c Log Message: Fix typo in a debug message. To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/sys/dev/pci/ixgbe/ixgbe_x540.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ixgbe_x540.c diff -u src/sys/dev/pci/ixgbe/ixgbe_x540.c:1.16 src/sys/dev/pci/ixgbe/ixgbe_x540.c:1.17 --- src/sys/dev/pci/ixgbe/ixgbe_x540.c:1.16 Mon Jun 11 10:34:18 2018 +++ src/sys/dev/pci/ixgbe/ixgbe_x540.c Fri Nov 13 04:12:38 2020 @@ -824,7 +824,7 @@ s32 ixgbe_acquire_swfw_sync_X540(struct * bits in the SW_FW_SYNC register. */ if (ixgbe_get_swfw_sync_semaphore(hw)) { - DEBUGOUT("Failed to get NVM sempahore and register semaphore while forcefully ignoring FW sempahore bit(s) and setting SW semaphore bit(s), returning IXGBE_ERR_SWFW_SYNC\n"); + DEBUGOUT("Failed to get NVM semaphore and register semaphore while forcefully ignoring FW semaphore bit(s) and setting SW semaphore bit(s), returning IXGBE_ERR_SWFW_SYNC\n"); return IXGBE_ERR_SWFW_SYNC; } swfw_sync = IXGBE_READ_REG(hw, IXGBE_SWFW_SYNC_BY_MAC(hw));
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: knakahara Date: Mon Sep 7 09:14:54 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe: ixgbe.c Log Message: Fix race between ixgbe_msix_admin() and ixgbe_handle_admin(), pointed out by ozaki-r@n.o. The race is caused by the following. CPU#A processes workqueue, CPU#B processes admin interrupt. (0) one of CPUs already calls ixgbe_schedule_admin_tasklet() such as ixgbe_handle_timer() (1) CPU#A: read adapter->task_requests (2) CPU#B: set adapter->task_requests (3) CPU#B: read(and try to set) adapter->admin_pending but adapter->admin_pending is set, so does not call workqueue_enqueue() (4) CPU#A: clear adapter->admin_pending that is, the tasks set by (2) is not processed as missfire workqueue by (3). To generate a diff of this commit: cvs rdiff -u -r1.257 -r1.258 src/sys/dev/pci/ixgbe/ixgbe.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.257 src/sys/dev/pci/ixgbe/ixgbe.c:1.258 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.257 Mon Sep 7 05:50:58 2020 +++ src/sys/dev/pci/ixgbe/ixgbe.c Mon Sep 7 09:14:53 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.257 2020/09/07 05:50:58 msaitoh Exp $ */ +/* $NetBSD: ixgbe.c,v 1.258 2020/09/07 09:14:53 knakahara Exp $ */ /** @@ -4805,6 +4805,13 @@ ixgbe_handle_admin(struct work *wk, void */ IFNET_LOCK(ifp); IXGBE_CORE_LOCK(adapter); + /* + * Clear the admin_pending flag before reading task_requests to avoid + * missfiring workqueue though setting task_request. + * Hmm, ixgbe_schedule_admin_tasklet() can extra-fire though + * task_requests are done by prior workqueue, but it is harmless. + */ + atomic_store_relaxed(>admin_pending, 0); while ((req = (adapter->task_requests & ~IXGBE_REQUEST_TASK_NEED_ACKINTR)) != 0) { @@ -4841,7 +4848,6 @@ ixgbe_handle_admin(struct work *wk, void } #endif } - atomic_store_relaxed(>admin_pending, 0); if ((adapter->task_requests & IXGBE_REQUEST_TASK_NEED_ACKINTR) != 0) { atomic_and_32(>task_requests, ~IXGBE_REQUEST_TASK_NEED_ACKINTR);
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Mon Sep 7 05:50:58 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe: if_fdir.c if_sriov.c ixgbe.c ixv.c Log Message: - Remove extra callout_stop() in ixgbe_detach(). Found by knakahara@. - Rename ix{gbe,v}_free_workqueue() to ix{gbe,v}_free_deferred_handlers(). - Add KASSERT() to functions who are called from ixgbe_handle_admin(). To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/dev/pci/ixgbe/if_fdir.c cvs rdiff -u -r1.7 -r1.8 src/sys/dev/pci/ixgbe/if_sriov.c cvs rdiff -u -r1.256 -r1.257 src/sys/dev/pci/ixgbe/ixgbe.c cvs rdiff -u -r1.153 -r1.154 src/sys/dev/pci/ixgbe/ixv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/if_fdir.c diff -u src/sys/dev/pci/ixgbe/if_fdir.c:1.2 src/sys/dev/pci/ixgbe/if_fdir.c:1.3 --- src/sys/dev/pci/ixgbe/if_fdir.c:1.2 Wed Apr 4 08:13:07 2018 +++ src/sys/dev/pci/ixgbe/if_fdir.c Mon Sep 7 05:50:58 2020 @@ -55,6 +55,8 @@ ixgbe_reinit_fdir(void *context) struct adapter *adapter = context; struct ifnet *ifp = adapter->ifp; + KASSERT(mutex_owned(>core_mtx)); + if (!(adapter->feat_en & IXGBE_FEATURE_FDIR)) return; if (adapter->fdir_reinit != 1) /* Shouldn't happen */ Index: src/sys/dev/pci/ixgbe/if_sriov.c diff -u src/sys/dev/pci/ixgbe/if_sriov.c:1.7 src/sys/dev/pci/ixgbe/if_sriov.c:1.8 --- src/sys/dev/pci/ixgbe/if_sriov.c:1.7 Thu Jun 25 07:53:01 2020 +++ src/sys/dev/pci/ixgbe/if_sriov.c Mon Sep 7 05:50:58 2020 @@ -643,6 +643,8 @@ ixgbe_handle_mbx(void *context, int pend struct ixgbe_vf *vf; int i; + KASSERT(mutex_owned(>core_mtx)); + hw = >hw; for (i = 0; i < adapter->num_vfs; i++) { Index: src/sys/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.256 src/sys/dev/pci/ixgbe/ixgbe.c:1.257 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.256 Mon Sep 7 04:15:12 2020 +++ src/sys/dev/pci/ixgbe/ixgbe.c Mon Sep 7 05:50:58 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.256 2020/09/07 04:15:12 msaitoh Exp $ */ +/* $NetBSD: ixgbe.c,v 1.257 2020/09/07 05:50:58 msaitoh Exp $ */ /** @@ -181,7 +181,7 @@ static void ixgbe_media_status(struct if static int ixgbe_media_change(struct ifnet *); static int ixgbe_allocate_pci_resources(struct adapter *, const struct pci_attach_args *); -static void ixgbe_free_workqueue(struct adapter *); +static void ixgbe_free_deferred_handlers(struct adapter *); static void ixgbe_get_slot_info(struct adapter *); static int ixgbe_allocate_msix(struct adapter *, const struct pci_attach_args *); @@ -1279,7 +1279,7 @@ err_out: ctrl_ext = IXGBE_READ_REG(>hw, IXGBE_CTRL_EXT); ctrl_ext &= ~IXGBE_CTRL_EXT_DRV_LOAD; IXGBE_WRITE_REG(>hw, IXGBE_CTRL_EXT, ctrl_ext); - ixgbe_free_workqueue(adapter); + ixgbe_free_deferred_handlers(adapter); ixgbe_free_pci_resources(adapter); if (adapter->mta != NULL) free(adapter->mta, M_DEVBUF); @@ -3518,7 +3518,7 @@ map_err: } /* ixgbe_allocate_pci_resources */ static void -ixgbe_free_workqueue(struct adapter *adapter) +ixgbe_free_deferred_handlers(struct adapter *adapter) { struct ix_queue *que = adapter->queues; struct tx_ring *txr = adapter->tx_rings; @@ -3558,7 +3558,7 @@ ixgbe_free_workqueue(struct adapter *ada workqueue_destroy(adapter->recovery_mode_timer_wq); adapter->recovery_mode_timer_wq = NULL; } -} /* ixgbe_free_workqueue */ +} /* ixgbe_free_deferred_handlers */ / * ixgbe_detach - Device removal routine @@ -3610,10 +3610,8 @@ ixgbe_detach(device_t dev, int flags) ixgbe_setup_low_power_mode(adapter); callout_halt(>timer, NULL); - if (adapter->feat_en & IXGBE_FEATURE_RECOVERY_MODE) { - callout_stop(>recovery_mode_timer); + if (adapter->feat_en & IXGBE_FEATURE_RECOVERY_MODE) callout_halt(>recovery_mode_timer, NULL); - } workqueue_wait(adapter->admin_wq, >admin_wc); atomic_store_relaxed(>admin_pending, 0); @@ -3624,7 +3622,7 @@ ixgbe_detach(device_t dev, int flags) ether_ifdetach(adapter->ifp); - ixgbe_free_workqueue(adapter); + ixgbe_free_deferred_handlers(adapter); /* let hardware know driver is unloading */ ctrl_ext = IXGBE_READ_REG(>hw, IXGBE_CTRL_EXT); @@ -4673,6 +4671,8 @@ ixgbe_handle_mod(void *context) u32 err; bool last_unsupported_sfp_recovery; + KASSERT(mutex_owned(>core_mtx)); + last_sfp_type = hw->phy.sfp_type; last_unsupported_sfp_recovery = hw->need_unsupported_sfp_recovery; ++adapter->mod_workev.ev_count; @@ -4754,6 +4754,8 @@ ixgbe_handle_msf(void *context) u32 autoneg; bool negotiate; + KASSERT(mutex_owned(>core_mtx)); + ++adapter->msf_workev.ev_count; autoneg = hw->phy.autoneg_advertised; @@ -4773,6 +4775,8 @@ ixgbe_handle_phy(void *context) struct ixgbe_hw *hw = >hw; int error; + KASSERT(mutex_owned(>core_mtx)); +
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Mon Sep 7 04:15:12 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe: ixgbe.c Log Message: __predict_false() should be __predict_true() for adapter->osdep.detaching == false check. To generate a diff of this commit: cvs rdiff -u -r1.255 -r1.256 src/sys/dev/pci/ixgbe/ixgbe.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.255 src/sys/dev/pci/ixgbe/ixgbe.c:1.256 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.255 Mon Sep 7 03:57:27 2020 +++ src/sys/dev/pci/ixgbe/ixgbe.c Mon Sep 7 04:15:12 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.255 2020/09/07 03:57:27 msaitoh Exp $ */ +/* $NetBSD: ixgbe.c,v 1.256 2020/09/07 04:15:12 msaitoh Exp $ */ /** @@ -1538,7 +1538,7 @@ static void ixgbe_schedule_admin_tasklet(struct adapter *adapter) { - if (__predict_false(adapter->osdep.detaching == false)) { + if (__predict_true(adapter->osdep.detaching == false)) { if (atomic_cas_uint(>admin_pending, 0, 1) == 0) workqueue_enqueue(adapter->admin_wq, >admin_wc, NULL); @@ -4627,7 +4627,7 @@ ixgbe_recovery_mode_timer(void *arg) { struct adapter *adapter = arg; - if (__predict_false(adapter->osdep.detaching == false)) { + if (__predict_true(adapter->osdep.detaching == false)) { if (atomic_cas_uint(>recovery_mode_timer_pending, 0, 1) == 0) { workqueue_enqueue(adapter->recovery_mode_timer_wq,
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Mon Sep 7 03:57:28 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe: ixgbe.c Log Message: Don't schedule admin work while shutdown like the recovery mode timer. The admin workqueue also runs while !IFF_UP like the recovery mode timer. Apply the same change of ixgbe.c 1.254 to ixgbe_schedule_admin_tasklet() to prevent panic. Found by ozaki-r@. To generate a diff of this commit: cvs rdiff -u -r1.254 -r1.255 src/sys/dev/pci/ixgbe/ixgbe.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.254 src/sys/dev/pci/ixgbe/ixgbe.c:1.255 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.254 Tue Sep 1 04:19:16 2020 +++ src/sys/dev/pci/ixgbe/ixgbe.c Mon Sep 7 03:57:27 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.254 2020/09/01 04:19:16 msaitoh Exp $ */ +/* $NetBSD: ixgbe.c,v 1.255 2020/09/07 03:57:27 msaitoh Exp $ */ /** @@ -1538,9 +1538,11 @@ static void ixgbe_schedule_admin_tasklet(struct adapter *adapter) { - if (atomic_cas_uint(>admin_pending, 0, 1) == 0) - workqueue_enqueue(adapter->admin_wq, - >admin_wc, NULL); + if (__predict_false(adapter->osdep.detaching == false)) { + if (atomic_cas_uint(>admin_pending, 0, 1) == 0) + workqueue_enqueue(adapter->admin_wq, + >admin_wc, NULL); + } } /
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Tue Sep 1 04:19:16 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe: ixgbe.c ixgbe_osdep.h Log Message: Fix a panic on shutdown on a machine which use the recovery mode timer. The recovery mode timer is first issued by the callout and it schedule the workqueue. The workqueue then reschedule the callout. It's hard to stop both of them without race only with callout_stop() and workqueue_wait. To solve this problem. add new "detaching" flag and use it. The situation is almost the same as schedule_wqs_ok for the local_timer's callout and workqueue, but the difference is that the local_timer isn't required to run if the interface is not up. If it's not important to prevent running timer while !IFF_UP, the flag can be integrated into one. To generate a diff of this commit: cvs rdiff -u -r1.253 -r1.254 src/sys/dev/pci/ixgbe/ixgbe.c cvs rdiff -u -r1.27 -r1.28 src/sys/dev/pci/ixgbe/ixgbe_osdep.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.253 src/sys/dev/pci/ixgbe/ixgbe.c:1.254 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.253 Tue Sep 1 04:06:56 2020 +++ src/sys/dev/pci/ixgbe/ixgbe.c Tue Sep 1 04:19:16 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.253 2020/09/01 04:06:56 msaitoh Exp $ */ +/* $NetBSD: ixgbe.c,v 1.254 2020/09/01 04:19:16 msaitoh Exp $ */ /** @@ -828,6 +828,7 @@ ixgbe_attach(device_t parent, device_t d else adapter->osdep.dmat = pa->pa_dmat; adapter->osdep.attached = false; + adapter->osdep.detaching = false; ent = ixgbe_lookup(pa); @@ -3598,6 +3599,7 @@ ixgbe_detach(device_t dev, int flags) } #endif + adapter->osdep.detaching = true; /* * Stop the interface. ixgbe_setup_low_power_mode() calls * ixgbe_ifstop(), so it's not required to call ixgbe_ifstop() @@ -4623,10 +4625,12 @@ ixgbe_recovery_mode_timer(void *arg) { struct adapter *adapter = arg; - if (atomic_cas_uint(>recovery_mode_timer_pending, 0, 1) == 0) - { - workqueue_enqueue(adapter->recovery_mode_timer_wq, - >recovery_mode_timer_wc, NULL); + if (__predict_false(adapter->osdep.detaching == false)) { + if (atomic_cas_uint(>recovery_mode_timer_pending, + 0, 1) == 0) { + workqueue_enqueue(adapter->recovery_mode_timer_wq, + >recovery_mode_timer_wc, NULL); + } } } Index: src/sys/dev/pci/ixgbe/ixgbe_osdep.h diff -u src/sys/dev/pci/ixgbe/ixgbe_osdep.h:1.27 src/sys/dev/pci/ixgbe/ixgbe_osdep.h:1.28 --- src/sys/dev/pci/ixgbe/ixgbe_osdep.h:1.27 Thu Jun 25 07:53:02 2020 +++ src/sys/dev/pci/ixgbe/ixgbe_osdep.h Tue Sep 1 04:19:16 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe_osdep.h,v 1.27 2020/06/25 07:53:02 msaitoh Exp $ */ +/* $NetBSD: ixgbe_osdep.h,v 1.28 2020/09/01 04:19:16 msaitoh Exp $ */ /** SPDX-License-Identifier: BSD-3-Clause @@ -200,6 +200,7 @@ struct ixgbe_osdep int nintrs; void *ihs[IXG_MAX_NINTR]; bool attached; + bool detaching; }; /* These routines need struct ixgbe_hw declared */
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Tue Sep 1 04:06:56 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe: ixgbe.c Log Message: Call ixgbe_ifstop() instead of ixgbe_stop_locked() in ixgbe_setup_low_power_mode() to stop the timer workqueue. To generate a diff of this commit: cvs rdiff -u -r1.252 -r1.253 src/sys/dev/pci/ixgbe/ixgbe.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.252 src/sys/dev/pci/ixgbe/ixgbe.c:1.253 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.252 Mon Aug 31 14:12:50 2020 +++ src/sys/dev/pci/ixgbe/ixgbe.c Tue Sep 1 04:06:56 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.252 2020/08/31 14:12:50 msaitoh Exp $ */ +/* $NetBSD: ixgbe.c,v 1.253 2020/09/01 04:06:56 msaitoh Exp $ */ /** @@ -3600,12 +3600,10 @@ ixgbe_detach(device_t dev, int flags) /* * Stop the interface. ixgbe_setup_low_power_mode() calls - * ixgbe_stop_locked(), so it's not required to call ixgbe_stop_locked() + * ixgbe_ifstop(), so it's not required to call ixgbe_ifstop() * directly. */ - IXGBE_CORE_LOCK(adapter); ixgbe_setup_low_power_mode(adapter); - IXGBE_CORE_UNLOCK(adapter); callout_halt(>timer, NULL); if (adapter->feat_en & IXGBE_FEATURE_RECOVERY_MODE) { @@ -3773,16 +3771,15 @@ ixgbe_setup_low_power_mode(struct adapte { struct ixgbe_hw *hw = >hw; device_t dev = adapter->dev; + struct ifnet *ifp = adapter->ifp; s32 error = 0; - KASSERT(mutex_owned(>core_mtx)); - /* Limit power management flow to X550EM baseT */ if (hw->device_id == IXGBE_DEV_ID_X550EM_X_10G_T && hw->phy.ops.enter_lplu) { /* X550EM baseT adapters need a special LPLU flow */ hw->phy.reset_disable = true; - ixgbe_stop_locked(adapter); + ixgbe_ifstop(ifp, 1); error = hw->phy.ops.enter_lplu(hw); if (error) device_printf(dev, @@ -3790,9 +3787,11 @@ ixgbe_setup_low_power_mode(struct adapte hw->phy.reset_disable = false; } else { /* Just stop for other adapters */ - ixgbe_stop_locked(adapter); + ixgbe_ifstop(ifp, 1); } + IXGBE_CORE_LOCK(adapter); + if (!hw->wol_enabled) { ixgbe_set_phy_power(hw, FALSE); IXGBE_WRITE_REG(hw, IXGBE_WUFC, 0); @@ -3820,6 +3819,8 @@ ixgbe_setup_low_power_mode(struct adapte } + IXGBE_CORE_UNLOCK(adapter); + return error; } /* ixgbe_setup_low_power_mode */ @@ -3835,9 +3836,7 @@ ixgbe_shutdown(device_t dev) INIT_DEBUGOUT("ixgbe_shutdown: begin"); - IXGBE_CORE_LOCK(adapter); error = ixgbe_setup_low_power_mode(adapter); - IXGBE_CORE_UNLOCK(adapter); return (error); } /* ixgbe_shutdown */ @@ -3856,12 +3855,8 @@ ixgbe_suspend(device_t dev, const pmf_qu INIT_DEBUGOUT("ixgbe_suspend: begin"); - IXGBE_CORE_LOCK(adapter); - error = ixgbe_setup_low_power_mode(adapter); - IXGBE_CORE_UNLOCK(adapter); - return (error); } /* ixgbe_suspend */
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Mon Aug 31 14:12:50 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe: ixgbe.c ixgbe_common.c ixv.c Log Message: Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional change. To generate a diff of this commit: cvs rdiff -u -r1.251 -r1.252 src/sys/dev/pci/ixgbe/ixgbe.c cvs rdiff -u -r1.29 -r1.30 src/sys/dev/pci/ixgbe/ixgbe_common.c cvs rdiff -u -r1.152 -r1.153 src/sys/dev/pci/ixgbe/ixv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.251 src/sys/dev/pci/ixgbe/ixgbe.c:1.252 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.251 Mon Aug 31 11:19:54 2020 +++ src/sys/dev/pci/ixgbe/ixgbe.c Mon Aug 31 14:12:50 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.251 2020/08/31 11:19:54 msaitoh Exp $ */ +/* $NetBSD: ixgbe.c,v 1.252 2020/08/31 14:12:50 msaitoh Exp $ */ /** @@ -173,7 +173,7 @@ static int ixgbe_ioctl(struct ifnet *, u static int ixgbe_init(struct ifnet *); static void ixgbe_init_locked(struct adapter *); static void ixgbe_ifstop(struct ifnet *, int); -static void ixgbe_stop(void *); +static void ixgbe_stop_locked(void *); static void ixgbe_init_device_features(struct adapter *); static void ixgbe_check_fan_failure(struct adapter *, u32, bool); static void ixgbe_add_media_types(struct adapter *); @@ -1229,7 +1229,7 @@ ixgbe_attach(device_t parent, device_t d /* For Netmap */ adapter->init_locked = ixgbe_init_locked; - adapter->stop_locked = ixgbe_stop; + adapter->stop_locked = ixgbe_stop_locked; if (adapter->feat_en & IXGBE_FEATURE_NETMAP) ixgbe_netmap_attach(adapter); @@ -3599,8 +3599,9 @@ ixgbe_detach(device_t dev, int flags) #endif /* - * Stop the interface. ixgbe_setup_low_power_mode() calls ixgbe_stop(), - * so it's not required to call ixgbe_stop() directly. + * Stop the interface. ixgbe_setup_low_power_mode() calls + * ixgbe_stop_locked(), so it's not required to call ixgbe_stop_locked() + * directly. */ IXGBE_CORE_LOCK(adapter); ixgbe_setup_low_power_mode(adapter); @@ -3781,7 +3782,7 @@ ixgbe_setup_low_power_mode(struct adapte hw->phy.ops.enter_lplu) { /* X550EM baseT adapters need a special LPLU flow */ hw->phy.reset_disable = true; - ixgbe_stop(adapter); + ixgbe_stop_locked(adapter); error = hw->phy.ops.enter_lplu(hw); if (error) device_printf(dev, @@ -3789,7 +3790,7 @@ ixgbe_setup_low_power_mode(struct adapte hw->phy.reset_disable = false; } else { /* Just stop for other adapters */ - ixgbe_stop(adapter); + ixgbe_stop_locked(adapter); } if (!hw->wol_enabled) { @@ -3976,7 +3977,7 @@ ixgbe_init_locked(struct adapter *adapte /* Prepare transmit descriptors and buffers */ if (ixgbe_setup_transmit_structures(adapter)) { device_printf(dev, "Could not setup transmit structures\n"); - ixgbe_stop(adapter); + ixgbe_stop_locked(adapter); return; } @@ -3998,7 +3999,7 @@ ixgbe_init_locked(struct adapter *adapte /* Prepare receive descriptors and buffers */ if (ixgbe_setup_receive_structures(adapter)) { device_printf(dev, "Could not setup receive structures\n"); - ixgbe_stop(adapter); + ixgbe_stop_locked(adapter); return; } @@ -4647,7 +4648,7 @@ ixgbe_handle_recovery_mode_timer(struct device_printf(adapter->dev, "Firmware recovery mode detected. Limiting functionality. Refer to the Intel(R) Ethernet Adapters and Devices User Guide for details on firmware recovery mode.\n"); if (hw->adapter_stopped == FALSE) -ixgbe_stop(adapter); +ixgbe_stop_locked(adapter); } } else atomic_cas_uint(>recovery_mode, 1, 0); @@ -4856,7 +4857,7 @@ ixgbe_ifstop(struct ifnet *ifp, int disa struct adapter *adapter = ifp->if_softc; IXGBE_CORE_LOCK(adapter); - ixgbe_stop(adapter); + ixgbe_stop_locked(adapter); IXGBE_CORE_UNLOCK(adapter); workqueue_wait(adapter->timer_wq, >timer_wc); @@ -4864,13 +4865,13 @@ ixgbe_ifstop(struct ifnet *ifp, int disa } / - * ixgbe_stop - Stop the hardware + * ixgbe_stop_locked - Stop the hardware * * Disables all traffic on the adapter by issuing a * global reset on the MAC and deallocates TX/RX buffers. / static void -ixgbe_stop(void *arg) +ixgbe_stop_locked(void *arg) { struct ifnet *ifp; struct adapter *adapter = arg; @@ -4880,7 +4881,7 @@ ixgbe_stop(void *arg) KASSERT(mutex_owned(>core_mtx)); - INIT_DEBUGOUT("ixgbe_stop: begin\n"); + INIT_DEBUGOUT("ixgbe_stop_locked: begin\n"); ixgbe_disable_intr(adapter); callout_stop(>timer); @@ -4906,7 +4907,7 @@ ixgbe_stop(void *arg) ixgbe_set_rar(>hw, 0, adapter->hw.mac.addr, 0, IXGBE_RAH_AV); return; -} /* ixgbe_stop */ +} /*
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Mon Aug 31 11:19:54 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe: ixgbe.c ixgbe.h ixgbe_common.c ixgbe_phy.c ixgbe_phy.h ixgbe_type.h Log Message: If an SFP+ module is not inserted, don't try to access SFP+ EEPROM. This change eliminate long timeout. Reduce code duplication using with ixgbe_sfp_cage_full(hw). To generate a diff of this commit: cvs rdiff -u -r1.250 -r1.251 src/sys/dev/pci/ixgbe/ixgbe.c cvs rdiff -u -r1.70 -r1.71 src/sys/dev/pci/ixgbe/ixgbe.h cvs rdiff -u -r1.28 -r1.29 src/sys/dev/pci/ixgbe/ixgbe_common.c cvs rdiff -u -r1.22 -r1.23 src/sys/dev/pci/ixgbe/ixgbe_phy.c cvs rdiff -u -r1.11 -r1.12 src/sys/dev/pci/ixgbe/ixgbe_phy.h cvs rdiff -u -r1.44 -r1.45 src/sys/dev/pci/ixgbe/ixgbe_type.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.250 src/sys/dev/pci/ixgbe/ixgbe.c:1.251 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.250 Mon Aug 31 06:23:19 2020 +++ src/sys/dev/pci/ixgbe/ixgbe.c Mon Aug 31 11:19:54 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.250 2020/08/31 06:23:19 msaitoh Exp $ */ +/* $NetBSD: ixgbe.c,v 1.251 2020/08/31 11:19:54 msaitoh Exp $ */ /** @@ -70,6 +70,7 @@ #endif #include "ixgbe.h" +#include "ixgbe_phy.h" #include "ixgbe_sriov.h" #include "vlan.h" @@ -257,9 +258,6 @@ static int ixgbe_sysctl_debug(SYSCTLFN_P static int ixgbe_sysctl_wol_enable(SYSCTLFN_PROTO); static int ixgbe_sysctl_wufc(SYSCTLFN_PROTO); -/* Support for pluggable optic modules */ -static bool ixgbe_sfp_cage_full(struct adapter *); - /* Legacy (single vector) interrupt handler */ static int ixgbe_legacy_irq(void *); @@ -786,7 +784,7 @@ ixgbe_quirks(struct adapter *adapter) (strcmp(product, "MA10-ST0") == 0)) { aprint_verbose_dev(dev, "Enable SFP+ MOD_ABS inverse quirk\n"); - adapter->quirks |= IXGBE_QUIRK_MOD_ABS_INVERT; + adapter->hw.quirks |= IXGBE_QUIRK_MOD_ABS_INVERT; } } } @@ -4519,7 +4517,7 @@ ixgbe_handle_timer(struct work *wk, void was_full = hw->phy.sfp_type != ixgbe_sfp_type_not_present; - is_full = ixgbe_sfp_cage_full(adapter); + is_full = ixgbe_sfp_cage_full(hw); /* Do probe if cage state changed */ if (was_full ^ is_full) @@ -4661,35 +4659,6 @@ ixgbe_handle_recovery_mode_timer(struct } /* ixgbe_handle_recovery_mode_timer */ / - * ixgbe_sfp_cage_full - * - * Determine if a port had optics inserted. - / -static bool -ixgbe_sfp_cage_full(struct adapter *adapter) -{ - struct ixgbe_hw *hw = >hw; - uint32_t mask; - int rv; - - if (hw->mac.type >= ixgbe_mac_X540) - mask = IXGBE_ESDP_SDP0; - else - mask = IXGBE_ESDP_SDP2; - - rv = IXGBE_READ_REG(hw, IXGBE_ESDP) & mask; - if ((adapter->quirks & IXGBE_QUIRK_MOD_ABS_INVERT) != 0) - rv = !rv; - - if (hw->mac.type == ixgbe_mac_X550EM_a) { - /* X550EM_a's SDP0 is inverted than others. */ - return !rv; - } - - return rv; -} /* ixgbe_sfp_cage_full */ - -/ * ixgbe_handle_mod - Tasklet for SFP module interrupts / static void @@ -4699,32 +4668,15 @@ ixgbe_handle_mod(void *context) struct ixgbe_hw *hw = >hw; device_t dev = adapter->dev; enum ixgbe_sfp_type last_sfp_type; - u32 err, cage_full = 0; + u32 err; bool last_unsupported_sfp_recovery; last_sfp_type = hw->phy.sfp_type; last_unsupported_sfp_recovery = hw->need_unsupported_sfp_recovery; ++adapter->mod_workev.ev_count; if (adapter->hw.need_crosstalk_fix) { - switch (hw->mac.type) { - case ixgbe_mac_82599EB: - cage_full = IXGBE_READ_REG(hw, IXGBE_ESDP) & - IXGBE_ESDP_SDP2; - break; - case ixgbe_mac_X550EM_x: - case ixgbe_mac_X550EM_a: - /* - * XXX See ixgbe_sfp_cage_full(). It seems the bit is - * inverted on X550EM_a, so I think this is incorrect. - */ - cage_full = IXGBE_READ_REG(hw, IXGBE_ESDP) & - IXGBE_ESDP_SDP0; - break; - default: - break; - } - - if (!cage_full) + if ((hw->mac.type != ixgbe_mac_82598EB) && + !ixgbe_sfp_cage_full(hw)) goto out; } Index: src/sys/dev/pci/ixgbe/ixgbe.h diff -u src/sys/dev/pci/ixgbe/ixgbe.h:1.70 src/sys/dev/pci/ixgbe/ixgbe.h:1.71 --- src/sys/dev/pci/ixgbe/ixgbe.h:1.70 Thu Aug 27 00:07:56 2020 +++ src/sys/dev/pci/ixgbe/ixgbe.h Mon Aug 31 11:19:54 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.h,v 1.70 2020/08/27 00:07:56 msaitoh Exp $ */ +/* $NetBSD: ixgbe.h,v 1.71 2020/08/31 11:19:54 msaitoh Exp $ */ /** SPDX-License-Identifier: BSD-3-Clause @@
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Mon Aug 31 06:23:19 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe: ixgbe.c Log Message: Fix typo in comment. To generate a diff of this commit: cvs rdiff -u -r1.249 -r1.250 src/sys/dev/pci/ixgbe/ixgbe.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.249 src/sys/dev/pci/ixgbe/ixgbe.c:1.250 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.249 Mon Aug 31 06:20:06 2020 +++ src/sys/dev/pci/ixgbe/ixgbe.c Mon Aug 31 06:23:19 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.249 2020/08/31 06:20:06 msaitoh Exp $ */ +/* $NetBSD: ixgbe.c,v 1.250 2020/08/31 06:23:19 msaitoh Exp $ */ /** @@ -4511,7 +4511,7 @@ ixgbe_handle_timer(struct work *wk, void if (hw->mac.type == ixgbe_mac_82598EB) { /* * On 82598EB, SFP+'s MOD_ABS pin is not connected to - * any GPIP(SDP). So just schedule TASK_MOD. + * any GPIO(SDP). So just schedule TASK_MOD. */ sched_mod_task = true; } else { @@ -4777,7 +4777,7 @@ out: /* * Don't shedule MSF event if the chip is 82598. 82598 doesn't support * MSF. At least, calling ixgbe_handle_msf on 82598 DA makes the link - * flap because the function call setup_link(). + * flap because the function calls setup_link(). */ if (hw->mac.type != ixgbe_mac_82598EB) atomic_or_32(>task_requests, IXGBE_REQUEST_TASK_MSF);
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Mon Aug 31 06:20:06 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe: ixgbe.c ixgbe_phy.c Log Message: Fix 82598 SFP+ problems. On 82598, SFP+'s MOD_ABS isn't connected to the MAC's GPIO pin, so we can't call ixgbe_sfp_cage_full(). Always issue TASK_MOD from ixgbe_handle_timer() on 82598. Fix ixgbe_identify_sfp_module_generic() for ixgbe_phy_nl. In the driver, hw->phy.type sometimes be compared with ixgbe_phy_nl. In ixgbe_identify_sfp_module_generic(), hw->phy.type may be overridden with another value. For ixgbe_phy_nl, some code don't override phy.type but others were not. Make it consistently keep ixgbe_phy_nl. This change fixes a problem that ixgbe_is_sfp() change the return value true to false when any SFP+ devices are connected to the cage on 82598 and never recover from it. Don't schedule MSF(multi speed fiber) task from ixgbe_handle_mod() on 82598. This task is only for devices which support multi speed fiber and 82598 doesn't support it. Before ixgbe.c rev. 1.237, ixgbe_handle_mod() isn't called on 82598 because 82598 has no SFP+ module insertion/removal interrupt. ixgbe.c rev. 1.237 changed to call the function via timer on 82598. This change fixes a bug that 82598 DA interface's link flaps. To generate a diff of this commit: cvs rdiff -u -r1.248 -r1.249 src/sys/dev/pci/ixgbe/ixgbe.c cvs rdiff -u -r1.21 -r1.22 src/sys/dev/pci/ixgbe/ixgbe_phy.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.248 src/sys/dev/pci/ixgbe/ixgbe.c:1.249 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.248 Thu Aug 27 04:54:43 2020 +++ src/sys/dev/pci/ixgbe/ixgbe.c Mon Aug 31 06:20:06 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.248 2020/08/27 04:54:43 msaitoh Exp $ */ +/* $NetBSD: ixgbe.c,v 1.249 2020/08/31 06:20:06 msaitoh Exp $ */ /** @@ -4506,11 +4506,26 @@ ixgbe_handle_timer(struct work *wk, void /* Check for pluggable optics */ if (ixgbe_is_sfp(hw)) { - bool was_full = hw->phy.sfp_type != ixgbe_sfp_type_not_present; - bool is_full = ixgbe_sfp_cage_full(adapter); + bool sched_mod_task = false; - /* do probe if cage state changed */ - if (was_full ^ is_full) { + if (hw->mac.type == ixgbe_mac_82598EB) { + /* + * On 82598EB, SFP+'s MOD_ABS pin is not connected to + * any GPIP(SDP). So just schedule TASK_MOD. + */ + sched_mod_task = true; + } else { + bool was_full, is_full; + + was_full = + hw->phy.sfp_type != ixgbe_sfp_type_not_present; + is_full = ixgbe_sfp_cage_full(adapter); + + /* Do probe if cage state changed */ + if (was_full ^ is_full) +sched_mod_task = true; + } + if (sched_mod_task) { atomic_or_32(>task_requests, IXGBE_REQUEST_TASK_MOD); ixgbe_schedule_admin_tasklet(adapter); @@ -4683,8 +4698,12 @@ ixgbe_handle_mod(void *context) struct adapter *adapter = context; struct ixgbe_hw *hw = >hw; device_t dev = adapter->dev; + enum ixgbe_sfp_type last_sfp_type; u32 err, cage_full = 0; + bool last_unsupported_sfp_recovery; + last_sfp_type = hw->phy.sfp_type; + last_unsupported_sfp_recovery = hw->need_unsupported_sfp_recovery; ++adapter->mod_workev.ev_count; if (adapter->hw.need_crosstalk_fix) { switch (hw->mac.type) { @@ -4711,8 +4730,9 @@ ixgbe_handle_mod(void *context) err = hw->phy.ops.identify_sfp(hw); if (err == IXGBE_ERR_SFP_NOT_SUPPORTED) { - device_printf(dev, - "Unsupported SFP+ module type was detected.\n"); + if (last_unsupported_sfp_recovery == false) + device_printf(dev, + "Unsupported SFP+ module type was detected.\n"); goto out; } @@ -4726,7 +4746,10 @@ ixgbe_handle_mod(void *context) * approach. */ ixgbe_init_locked(adapter); - } else { + } else if ((hw->phy.sfp_type != ixgbe_sfp_type_not_present) && + (hw->phy.sfp_type != last_sfp_type)) { + /* A module is inserted and changed. */ + if (hw->mac.type == ixgbe_mac_82598EB) err = hw->phy.ops.reset(hw); else { @@ -4751,7 +4774,14 @@ out: ifmedia_set(>media, IFM_ETHER | IFM_AUTO); IXGBE_CORE_LOCK(adapter); - atomic_or_32(>task_requests, IXGBE_REQUEST_TASK_MSF); + /* + * Don't shedule MSF event if the chip is 82598. 82598 doesn't support + * MSF. At least, calling ixgbe_handle_msf on 82598 DA makes the link + * flap because the function call setup_link(). + */ + if (hw->mac.type != ixgbe_mac_82598EB) + atomic_or_32(>task_requests, IXGBE_REQUEST_TASK_MSF); + /* * Don't call ixgbe_schedule_admin_tasklet() because we are on * the workqueue now. Index: src/sys/dev/pci/ixgbe/ixgbe_phy.c diff -u src/sys/dev/pci/ixgbe/ixgbe_phy.c:1.21 src/sys/dev/pci/ixgbe/ixgbe_phy.c:1.22 --- src/sys/dev/pci/ixgbe/ixgbe_phy.c:1.21 Fri Apr 17 02:21:25 2020 +++ src/sys/dev/pci/ixgbe/ixgbe_phy.c Mon Aug 31 06:20:06 2020 @@
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Thu Aug 27 04:54:43 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe: ixgbe.c Log Message: Limit MA10-ST0's quirk only for on-chip devices. To generate a diff of this commit: cvs rdiff -u -r1.247 -r1.248 src/sys/dev/pci/ixgbe/ixgbe.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.247 src/sys/dev/pci/ixgbe/ixgbe.c:1.248 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.247 Thu Aug 27 04:49:52 2020 +++ src/sys/dev/pci/ixgbe/ixgbe.c Thu Aug 27 04:54:43 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.247 2020/08/27 04:49:52 msaitoh Exp $ */ +/* $NetBSD: ixgbe.c,v 1.248 2020/08/27 04:54:43 msaitoh Exp $ */ /** @@ -768,19 +768,26 @@ static void ixgbe_quirks(struct adapter *adapter) { device_t dev = adapter->dev; + struct ixgbe_hw *hw = >hw; const char *vendor, *product; - /* Quirk for inverted logic of SFP+'s MOD_ABS */ - vendor = pmf_get_platform("system-vendor"); - product = pmf_get_platform("system-product"); + if (hw->device_id == IXGBE_DEV_ID_X550EM_A_SFP_N) { + /* + * Quirk for inverted logic of SFP+'s MOD_ABS on GIGABYTE + * MA10-ST0. + */ + vendor = pmf_get_platform("system-vendor"); + product = pmf_get_platform("system-product"); - if ((vendor == NULL) || (product == NULL)) - return; + if ((vendor == NULL) || (product == NULL)) + return; - if ((strcmp(vendor, "GIGABYTE") == 0) && - (strcmp(product, "MA10-ST0") == 0)) { - aprint_verbose_dev(dev, "Enable SFP+ MOD_ABS inverse quirk\n"); - adapter->quirks |= IXGBE_QUIRK_MOD_ABS_INVERT; + if ((strcmp(vendor, "GIGABYTE") == 0) && + (strcmp(product, "MA10-ST0") == 0)) { + aprint_verbose_dev(dev, + "Enable SFP+ MOD_ABS inverse quirk\n"); + adapter->quirks |= IXGBE_QUIRK_MOD_ABS_INVERT; + } } } @@ -831,9 +838,6 @@ ixgbe_attach(device_t parent, device_t d aprint_normal(": %s, Version - %s\n", ixgbe_strings[ent->index], ixgbe_driver_version); - /* Set quirk flags */ - ixgbe_quirks(adapter); - /* Core Lock Init */ IXGBE_CORE_LOCK_INIT(adapter, device_xname(dev)); @@ -860,6 +864,9 @@ ixgbe_attach(device_t parent, device_t d hw->subsystem_vendor_id = PCI_SUBSYS_VENDOR(subid); hw->subsystem_device_id = PCI_SUBSYS_ID(subid); + /* Set quirk flags */ + ixgbe_quirks(adapter); + /* * Make sure BUSMASTER is set */
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Thu Aug 27 04:49:52 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe: ixgbe.c Log Message: Fix compile error. To generate a diff of this commit: cvs rdiff -u -r1.246 -r1.247 src/sys/dev/pci/ixgbe/ixgbe.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.246 src/sys/dev/pci/ixgbe/ixgbe.c:1.247 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.246 Thu Aug 27 03:57:52 2020 +++ src/sys/dev/pci/ixgbe/ixgbe.c Thu Aug 27 04:49:52 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.246 2020/08/27 03:57:52 msaitoh Exp $ */ +/* $NetBSD: ixgbe.c,v 1.247 2020/08/27 04:49:52 msaitoh Exp $ */ /** @@ -4500,7 +4500,7 @@ ixgbe_handle_timer(struct work *wk, void /* Check for pluggable optics */ if (ixgbe_is_sfp(hw)) { bool was_full = hw->phy.sfp_type != ixgbe_sfp_type_not_present; - bool is_full = ixgbe_sfp_cage_full(hw); + bool is_full = ixgbe_sfp_cage_full(adapter); /* do probe if cage state changed */ if (was_full ^ is_full) {
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Thu Aug 27 03:57:52 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe: ixgbe.c ixgbe_common.c Log Message: Minor change. - Print "X550EM X" instead of "X550EM" for Xeon D devices. - Fix typo in comment. Same as FreeBSD. To generate a diff of this commit: cvs rdiff -u -r1.245 -r1.246 src/sys/dev/pci/ixgbe/ixgbe.c cvs rdiff -u -r1.27 -r1.28 src/sys/dev/pci/ixgbe/ixgbe_common.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.245 src/sys/dev/pci/ixgbe/ixgbe.c:1.246 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.245 Thu Aug 27 00:07:56 2020 +++ src/sys/dev/pci/ixgbe/ixgbe.c Thu Aug 27 03:57:52 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.245 2020/08/27 00:07:56 msaitoh Exp $ */ +/* $NetBSD: ixgbe.c,v 1.246 2020/08/27 03:57:52 msaitoh Exp $ */ /** @@ -900,7 +900,7 @@ ixgbe_attach(device_t parent, device_t d str = "X550"; break; case ixgbe_mac_X550EM_x: - str = "X550EM"; + str = "X550EM X"; break; case ixgbe_mac_X550EM_a: str = "X550EM A"; Index: src/sys/dev/pci/ixgbe/ixgbe_common.c diff -u src/sys/dev/pci/ixgbe/ixgbe_common.c:1.27 src/sys/dev/pci/ixgbe/ixgbe_common.c:1.28 --- src/sys/dev/pci/ixgbe/ixgbe_common.c:1.27 Wed Feb 5 07:45:46 2020 +++ src/sys/dev/pci/ixgbe/ixgbe_common.c Thu Aug 27 03:57:52 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe_common.c,v 1.27 2020/02/05 07:45:46 msaitoh Exp $ */ +/* $NetBSD: ixgbe_common.c,v 1.28 2020/08/27 03:57:52 msaitoh Exp $ */ /** SPDX-License-Identifier: BSD-3-Clause @@ -5234,7 +5234,7 @@ void ixgbe_get_oem_prod_version(struct i nvm_ver->oem_valid = FALSE; hw->eeprom.ops.read(hw, NVM_OEM_PROD_VER_PTR, ); - /* Return is offset to OEM Product Version block is invalid */ + /* Return if offset to OEM Product Version block is invalid */ if (offset == 0x0 || offset == NVM_INVALID_PTR) return;
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Thu Aug 27 00:07:56 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe: ixgbe.c ixgbe.h Log Message: ADD SFP+ MOD_ABS inversion quirk. On X550 EM, GPIO(SDP) and SFP+'s MOD_ABS is directly connected. It has no inverter. GIGABYTE MA10-ST0 has a inverter, so add new quirk for it. To generate a diff of this commit: cvs rdiff -u -r1.244 -r1.245 src/sys/dev/pci/ixgbe/ixgbe.c cvs rdiff -u -r1.69 -r1.70 src/sys/dev/pci/ixgbe/ixgbe.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.244 src/sys/dev/pci/ixgbe/ixgbe.c:1.245 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.244 Mon Aug 24 19:03:27 2020 +++ src/sys/dev/pci/ixgbe/ixgbe.c Thu Aug 27 00:07:56 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.244 2020/08/24 19:03:27 msaitoh Exp $ */ +/* $NetBSD: ixgbe.c,v 1.245 2020/08/27 00:07:56 msaitoh Exp $ */ /** @@ -159,6 +159,7 @@ static const char*ixgbe_strings[] = * Function prototypes / static int ixgbe_probe(device_t, cfdata_t, void *); +static void ixgbe_quirks(struct adapter *); static void ixgbe_attach(device_t, device_t, void *); static int ixgbe_detach(device_t, int); #if 0 @@ -257,7 +258,7 @@ static int ixgbe_sysctl_wol_enable(SYSCT static int ixgbe_sysctl_wufc(SYSCTLFN_PROTO); /* Support for pluggable optic modules */ -static bool ixgbe_sfp_cage_full(struct ixgbe_hw *); +static bool ixgbe_sfp_cage_full(struct adapter *); /* Legacy (single vector) interrupt handler */ static int ixgbe_legacy_irq(void *); @@ -763,6 +764,26 @@ ixgbe_initialize_transmit_units(struct a return; } /* ixgbe_initialize_transmit_units */ +static void +ixgbe_quirks(struct adapter *adapter) +{ + device_t dev = adapter->dev; + const char *vendor, *product; + + /* Quirk for inverted logic of SFP+'s MOD_ABS */ + vendor = pmf_get_platform("system-vendor"); + product = pmf_get_platform("system-product"); + + if ((vendor == NULL) || (product == NULL)) + return; + + if ((strcmp(vendor, "GIGABYTE") == 0) && + (strcmp(product, "MA10-ST0") == 0)) { + aprint_verbose_dev(dev, "Enable SFP+ MOD_ABS inverse quirk\n"); + adapter->quirks |= IXGBE_QUIRK_MOD_ABS_INVERT; + } +} + / * ixgbe_attach - Device initialization routine * @@ -810,6 +831,9 @@ ixgbe_attach(device_t parent, device_t d aprint_normal(": %s, Version - %s\n", ixgbe_strings[ent->index], ixgbe_driver_version); + /* Set quirk flags */ + ixgbe_quirks(adapter); + /* Core Lock Init */ IXGBE_CORE_LOCK_INIT(adapter, device_xname(dev)); @@ -4620,8 +4644,9 @@ ixgbe_handle_recovery_mode_timer(struct * Determine if a port had optics inserted. / static bool -ixgbe_sfp_cage_full(struct ixgbe_hw *hw) +ixgbe_sfp_cage_full(struct adapter *adapter) { + struct ixgbe_hw *hw = >hw; uint32_t mask; int rv; @@ -4631,9 +4656,12 @@ ixgbe_sfp_cage_full(struct ixgbe_hw *hw) mask = IXGBE_ESDP_SDP2; rv = IXGBE_READ_REG(hw, IXGBE_ESDP) & mask; + if ((adapter->quirks & IXGBE_QUIRK_MOD_ABS_INVERT) != 0) + rv = !rv; + if (hw->mac.type == ixgbe_mac_X550EM_a) { - /* It seems X550EM_a's SDP0 is inverted than others... */ - return (rv == 0); + /* X550EM_a's SDP0 is inverted than others. */ + return !rv; } return rv; Index: src/sys/dev/pci/ixgbe/ixgbe.h diff -u src/sys/dev/pci/ixgbe/ixgbe.h:1.69 src/sys/dev/pci/ixgbe/ixgbe.h:1.70 --- src/sys/dev/pci/ixgbe/ixgbe.h:1.69 Mon Aug 17 07:59:06 2020 +++ src/sys/dev/pci/ixgbe/ixgbe.h Thu Aug 27 00:07:56 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.h,v 1.69 2020/08/17 07:59:06 msaitoh Exp $ */ +/* $NetBSD: ixgbe.h,v 1.70 2020/08/27 00:07:56 msaitoh Exp $ */ /** SPDX-License-Identifier: BSD-3-Clause @@ -623,6 +623,9 @@ struct adapter { u32 feat_cap; u32 feat_en; + /* Quirks */ + u32 quirks; + /* Traffic classes */ struct ixgbe_tc tcs[IXGBE_DCB_MAX_TRAFFIC_CLASS]; @@ -770,6 +773,8 @@ bool ixgbe_rxeof(struct ix_queue *); #define IXGBE_REQUEST_TASK_LSC 0x20 #define IXGBE_REQUEST_TASK_NEED_ACKINTR 0x80 +#define IXGBE_QUIRK_MOD_ABS_INVERT __BIT(0) + /* For NetBSD */ const struct sysctlnode *ixgbe_sysctl_instance(struct adapter *); void ixgbe_jcl_reinit(struct adapter *, bus_dma_tag_t, struct rx_ring *,
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Mon Aug 24 19:03:28 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe: ixgbe.c Log Message: Fix handling of IXGBE_REQUEST_TASK_NEED_ACKINTR again... To generate a diff of this commit: cvs rdiff -u -r1.243 -r1.244 src/sys/dev/pci/ixgbe/ixgbe.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.243 src/sys/dev/pci/ixgbe/ixgbe.c:1.244 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.243 Mon Aug 24 18:42:17 2020 +++ src/sys/dev/pci/ixgbe/ixgbe.c Mon Aug 24 19:03:27 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.243 2020/08/24 18:42:17 msaitoh Exp $ */ +/* $NetBSD: ixgbe.c,v 1.244 2020/08/24 19:03:27 msaitoh Exp $ */ /** @@ -4782,7 +4782,9 @@ ixgbe_handle_admin(struct work *wk, void */ IFNET_LOCK(ifp); IXGBE_CORE_LOCK(adapter); - while ((req = adapter->task_requests) != 0) { + while ((req = + (adapter->task_requests & ~IXGBE_REQUEST_TASK_NEED_ACKINTR)) + != 0) { if ((req & IXGBE_REQUEST_TASK_LSC) != 0) { ixgbe_handle_link(adapter); atomic_and_32(>task_requests,
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Mon Aug 24 18:42:17 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe: ixgbe.c Log Message: The admin workqueue can be used even if the interface is not up. OK'd by thorpej@. Will fixes PR#55534 reported by Shinichi Doyashiki To generate a diff of this commit: cvs rdiff -u -r1.242 -r1.243 src/sys/dev/pci/ixgbe/ixgbe.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.242 src/sys/dev/pci/ixgbe/ixgbe.c:1.243 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.242 Mon Aug 24 18:31:14 2020 +++ src/sys/dev/pci/ixgbe/ixgbe.c Mon Aug 24 18:42:17 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.242 2020/08/24 18:31:14 msaitoh Exp $ */ +/* $NetBSD: ixgbe.c,v 1.243 2020/08/24 18:42:17 msaitoh Exp $ */ /** @@ -1507,11 +1507,10 @@ ixgbe_is_sfp(struct ixgbe_hw *hw) static void ixgbe_schedule_admin_tasklet(struct adapter *adapter) { - if (adapter->schedule_wqs_ok) { - if (atomic_cas_uint(>admin_pending, 0, 1) == 0) - workqueue_enqueue(adapter->admin_wq, - >admin_wc, NULL); - } + + if (atomic_cas_uint(>admin_pending, 0, 1) == 0) + workqueue_enqueue(adapter->admin_wq, + >admin_wc, NULL); } / @@ -4841,8 +4840,6 @@ ixgbe_ifstop(struct ifnet *ifp, int disa ixgbe_stop(adapter); IXGBE_CORE_UNLOCK(adapter); - workqueue_wait(adapter->admin_wq, >admin_wc); - atomic_store_relaxed(>admin_pending, 0); workqueue_wait(adapter->timer_wq, >timer_wc); atomic_store_relaxed(>timer_pending, 0); }
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Mon Aug 24 18:31:15 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe: ixgbe.c Log Message: Fix ixgbe_sfp_cage_full() on X550EM_A. In ixgbe_handle_mod(): switch (hw->mac.type) { case ixgbe_mac_82599EB: cage_full = IXGBE_READ_REG(hw, IXGBE_ESDP) & IXGBE_ESDP_SDP2; break; case ixgbe_mac_X550EM_x: case ixgbe_mac_X550EM_a: cage_full = IXGBE_READ_REG(hw, IXGBE_ESDP) & IXGBE_ESDP_SDP0; break; default: break; } so I had thought that IXGBE_ESDP_SDP0 bit is 1 on cage is full. In reality, at least, X550EM_A's SFP+ cage is 0 on cage is full. So invert the logic of ixgbe_sfp_cage_full() on X550EM_A To generate a diff of this commit: cvs rdiff -u -r1.241 -r1.242 src/sys/dev/pci/ixgbe/ixgbe.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.241 src/sys/dev/pci/ixgbe/ixgbe.c:1.242 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.241 Mon Aug 24 18:21:59 2020 +++ src/sys/dev/pci/ixgbe/ixgbe.c Mon Aug 24 18:31:14 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.241 2020/08/24 18:21:59 msaitoh Exp $ */ +/* $NetBSD: ixgbe.c,v 1.242 2020/08/24 18:31:14 msaitoh Exp $ */ /** @@ -4624,13 +4624,20 @@ static bool ixgbe_sfp_cage_full(struct ixgbe_hw *hw) { uint32_t mask; + int rv; if (hw->mac.type >= ixgbe_mac_X540) mask = IXGBE_ESDP_SDP0; else mask = IXGBE_ESDP_SDP2; - return IXGBE_READ_REG(hw, IXGBE_ESDP) & mask; + rv = IXGBE_READ_REG(hw, IXGBE_ESDP) & mask; + if (hw->mac.type == ixgbe_mac_X550EM_a) { + /* It seems X550EM_a's SDP0 is inverted than others... */ + return (rv == 0); + } + + return rv; } /* ixgbe_sfp_cage_full */ / @@ -4653,6 +4660,10 @@ ixgbe_handle_mod(void *context) break; case ixgbe_mac_X550EM_x: case ixgbe_mac_X550EM_a: + /* + * XXX See ixgbe_sfp_cage_full(). It seems the bit is + * inverted on X550EM_a, so I think this is incorrect. + */ cage_full = IXGBE_READ_REG(hw, IXGBE_ESDP) & IXGBE_ESDP_SDP0; break;
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Mon Aug 24 18:21:59 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe: ixgbe.c Log Message: Fix race in ixgbe_detach() to prevent panic on shutdown. To generate a diff of this commit: cvs rdiff -u -r1.240 -r1.241 src/sys/dev/pci/ixgbe/ixgbe.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.240 src/sys/dev/pci/ixgbe/ixgbe.c:1.241 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.240 Mon Aug 24 18:16:04 2020 +++ src/sys/dev/pci/ixgbe/ixgbe.c Mon Aug 24 18:21:59 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.240 2020/08/24 18:16:04 msaitoh Exp $ */ +/* $NetBSD: ixgbe.c,v 1.241 2020/08/24 18:21:59 msaitoh Exp $ */ /** @@ -3558,13 +3558,6 @@ ixgbe_detach(device_t dev, int flags) return (EBUSY); } - /* - * Stop the interface. ixgbe_setup_low_power_mode() calls ixgbe_stop(), - * so it's not required to call ixgbe_stop() directly. - */ - IXGBE_CORE_LOCK(adapter); - ixgbe_setup_low_power_mode(adapter); - IXGBE_CORE_UNLOCK(adapter); #if NVLAN > 0 /* Make sure VLANs are not using driver */ if (!VLAN_ATTACHED(>osdep.ec)) @@ -3577,6 +3570,25 @@ ixgbe_detach(device_t dev, int flags) } #endif + /* + * Stop the interface. ixgbe_setup_low_power_mode() calls ixgbe_stop(), + * so it's not required to call ixgbe_stop() directly. + */ + IXGBE_CORE_LOCK(adapter); + ixgbe_setup_low_power_mode(adapter); + IXGBE_CORE_UNLOCK(adapter); + + callout_halt(>timer, NULL); + if (adapter->feat_en & IXGBE_FEATURE_RECOVERY_MODE) { + callout_stop(>recovery_mode_timer); + callout_halt(>recovery_mode_timer, NULL); + } + + workqueue_wait(adapter->admin_wq, >admin_wc); + atomic_store_relaxed(>admin_pending, 0); + workqueue_wait(adapter->timer_wq, >timer_wc); + atomic_store_relaxed(>timer_pending, 0); + pmf_device_deregister(dev); ether_ifdetach(adapter->ifp); @@ -3588,12 +3600,6 @@ ixgbe_detach(device_t dev, int flags) ctrl_ext &= ~IXGBE_CTRL_EXT_DRV_LOAD; IXGBE_WRITE_REG(>hw, IXGBE_CTRL_EXT, ctrl_ext); - callout_halt(>timer, NULL); - if (adapter->feat_en & IXGBE_FEATURE_RECOVERY_MODE) { - callout_stop(>recovery_mode_timer); - callout_halt(>recovery_mode_timer, NULL); - } - if (adapter->feat_en & IXGBE_FEATURE_NETMAP) netmap_detach(adapter->ifp);
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Mon Aug 24 18:16:04 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe: ixgbe.c Log Message: Fix handling of IXGBE_REQUEST_TASK_NEED_ACKINTR in ixgbe_handle_admin(). To generate a diff of this commit: cvs rdiff -u -r1.239 -r1.240 src/sys/dev/pci/ixgbe/ixgbe.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.239 src/sys/dev/pci/ixgbe/ixgbe.c:1.240 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.239 Mon Aug 17 08:23:30 2020 +++ src/sys/dev/pci/ixgbe/ixgbe.c Mon Aug 24 18:16:04 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.239 2020/08/17 08:23:30 msaitoh Exp $ */ +/* $NetBSD: ixgbe.c,v 1.240 2020/08/24 18:16:04 msaitoh Exp $ */ /** @@ -4801,7 +4801,9 @@ ixgbe_handle_admin(struct work *wk, void #endif } atomic_store_relaxed(>admin_pending, 0); - if ((req & IXGBE_REQUEST_TASK_NEED_ACKINTR) != 0) { + if ((adapter->task_requests & IXGBE_REQUEST_TASK_NEED_ACKINTR) != 0) { + atomic_and_32(>task_requests, + ~IXGBE_REQUEST_TASK_NEED_ACKINTR); if ((adapter->feat_en & IXGBE_FEATURE_MSIX) != 0) { /* Re-enable other interrupts */ IXGBE_WRITE_REG(hw, IXGBE_EIMS, IXGBE_EIMS_OTHER);
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Mon Aug 17 08:23:30 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe: ixgbe.c Log Message: Simplify SFP+ check. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.238 -r1.239 src/sys/dev/pci/ixgbe/ixgbe.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.238 src/sys/dev/pci/ixgbe/ixgbe.c:1.239 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.238 Mon Aug 17 07:59:06 2020 +++ src/sys/dev/pci/ixgbe/ixgbe.c Mon Aug 17 08:23:30 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.238 2020/08/17 07:59:06 msaitoh Exp $ */ +/* $NetBSD: ixgbe.c,v 1.239 2020/08/17 08:23:30 msaitoh Exp $ */ /** @@ -4465,7 +4465,6 @@ ixgbe_handle_timer(struct work *wk, void u64 v0, v1, v2, v3, v4, v5, v6, v7; int hung = 0; int i; - bool do_probe = false; IXGBE_CORE_LOCK(adapter); @@ -4475,12 +4474,11 @@ ixgbe_handle_timer(struct work *wk, void bool is_full = ixgbe_sfp_cage_full(hw); /* do probe if cage state changed */ - if (was_full ^ is_full) - do_probe = true; - } - if (do_probe) { - atomic_or_32(>task_requests, IXGBE_REQUEST_TASK_MOD); - ixgbe_schedule_admin_tasklet(adapter); + if (was_full ^ is_full) { + atomic_or_32(>task_requests, + IXGBE_REQUEST_TASK_MOD); + ixgbe_schedule_admin_tasklet(adapter); + } } ixgbe_update_link_status(adapter);
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Mon Aug 17 07:59:06 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe: ixgbe.c ixgbe.h Log Message: Re-enabling interrupt is required only when a work is scheduled form the interrput context. To generate a diff of this commit: cvs rdiff -u -r1.237 -r1.238 src/sys/dev/pci/ixgbe/ixgbe.c cvs rdiff -u -r1.68 -r1.69 src/sys/dev/pci/ixgbe/ixgbe.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.237 src/sys/dev/pci/ixgbe/ixgbe.c:1.238 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.237 Mon Aug 17 07:26:55 2020 +++ src/sys/dev/pci/ixgbe/ixgbe.c Mon Aug 17 07:59:06 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.237 2020/08/17 07:26:55 msaitoh Exp $ */ +/* $NetBSD: ixgbe.c,v 1.238 2020/08/17 07:59:06 msaitoh Exp $ */ /** @@ -3173,9 +3173,10 @@ ixgbe_msix_admin(void *arg) } if (task_requests != 0) { + /* Re-enabling other interrupts is done in the admin task */ + task_requests |= IXGBE_REQUEST_TASK_NEED_ACKINTR; atomic_or_32(>task_requests, task_requests); ixgbe_schedule_admin_tasklet(adapter); - /* Re-enabling other interrupts is done in the admin task */ } else { /* Re-enable other interrupts */ IXGBE_WRITE_REG(hw, IXGBE_EIMS, IXGBE_EIMS_OTHER); @@ -4802,11 +4803,13 @@ ixgbe_handle_admin(struct work *wk, void #endif } atomic_store_relaxed(>admin_pending, 0); - if ((adapter->feat_en & IXGBE_FEATURE_MSIX) != 0) { - /* Re-enable other interrupts */ - IXGBE_WRITE_REG(hw, IXGBE_EIMS, IXGBE_EIMS_OTHER); - } else - ixgbe_enable_intr(adapter); + if ((req & IXGBE_REQUEST_TASK_NEED_ACKINTR) != 0) { + if ((adapter->feat_en & IXGBE_FEATURE_MSIX) != 0) { + /* Re-enable other interrupts */ + IXGBE_WRITE_REG(hw, IXGBE_EIMS, IXGBE_EIMS_OTHER); + } else + ixgbe_enable_intr(adapter); + } IXGBE_CORE_UNLOCK(adapter); IFNET_UNLOCK(ifp); @@ -5210,6 +5213,8 @@ ixgbe_legacy_irq(void *arg) reenable_intr = false; } if (task_requests != 0) { + /* Re-enabling other interrupts is done in the admin task */ + task_requests |= IXGBE_REQUEST_TASK_NEED_ACKINTR; atomic_or_32(>task_requests, task_requests); ixgbe_schedule_admin_tasklet(adapter); reenable_intr = false; Index: src/sys/dev/pci/ixgbe/ixgbe.h diff -u src/sys/dev/pci/ixgbe/ixgbe.h:1.68 src/sys/dev/pci/ixgbe/ixgbe.h:1.69 --- src/sys/dev/pci/ixgbe/ixgbe.h:1.68 Mon Aug 17 07:26:55 2020 +++ src/sys/dev/pci/ixgbe/ixgbe.h Mon Aug 17 07:59:06 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.h,v 1.68 2020/08/17 07:26:55 msaitoh Exp $ */ +/* $NetBSD: ixgbe.h,v 1.69 2020/08/17 07:59:06 msaitoh Exp $ */ /** SPDX-License-Identifier: BSD-3-Clause @@ -768,6 +768,7 @@ bool ixgbe_rxeof(struct ix_queue *); #define IXGBE_REQUEST_TASK_FDIR 0x08 #define IXGBE_REQUEST_TASK_PHY 0x10 #define IXGBE_REQUEST_TASK_LSC 0x20 +#define IXGBE_REQUEST_TASK_NEED_ACKINTR 0x80 /* For NetBSD */ const struct sysctlnode *ixgbe_sysctl_instance(struct adapter *);
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Mon Aug 17 07:26:55 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe: ixgbe.c ixgbe.h Log Message: Fix a bug that the driver sometimes missed module insertion. The ixgbe_sfp_probe() function was only for 82598 and other chips had no way to poll SFP+ cage. The ixgbe_handle_mod() already has function to treat module insertion/removal for all chips, so enqueue the work if the cage status changed. All of ixgbe chips' SFP+ module interrupt is only on the inserstion. This change also detect the removal by the timer. To generate a diff of this commit: cvs rdiff -u -r1.236 -r1.237 src/sys/dev/pci/ixgbe/ixgbe.c cvs rdiff -u -r1.67 -r1.68 src/sys/dev/pci/ixgbe/ixgbe.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.236 src/sys/dev/pci/ixgbe/ixgbe.c:1.237 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.236 Mon Aug 17 06:30:25 2020 +++ src/sys/dev/pci/ixgbe/ixgbe.c Mon Aug 17 07:26:55 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.236 2020/08/17 06:30:25 msaitoh Exp $ */ +/* $NetBSD: ixgbe.c,v 1.237 2020/08/17 07:26:55 msaitoh Exp $ */ /** @@ -257,7 +257,7 @@ static int ixgbe_sysctl_wol_enable(SYSCT static int ixgbe_sysctl_wufc(SYSCTLFN_PROTO); /* Support for pluggable optic modules */ -static bool ixgbe_sfp_probe(struct adapter *); +static bool ixgbe_sfp_cage_full(struct ixgbe_hw *); /* Legacy (single vector) interrupt handler */ static int ixgbe_legacy_irq(void *); @@ -962,15 +962,9 @@ ixgbe_attach(device_t parent, device_t d hw->phy.reset_if_overtemp = TRUE; error = ixgbe_reset_hw(hw); hw->phy.reset_if_overtemp = FALSE; - if (error == IXGBE_ERR_SFP_NOT_PRESENT) { - /* - * No optics in this port, set up - * so the timer routine will probe - * for later insertion. - */ - adapter->sfp_probe = TRUE; + if (error == IXGBE_ERR_SFP_NOT_PRESENT) error = IXGBE_SUCCESS; - } else if (error == IXGBE_ERR_SFP_NOT_SUPPORTED) { + else if (error == IXGBE_ERR_SFP_NOT_SUPPORTED) { aprint_error_dev(dev, "Unsupported SFP+ module detected!\n"); unsupported_sfp = true; error = IXGBE_SUCCESS; @@ -4463,19 +4457,30 @@ static void ixgbe_handle_timer(struct work *wk, void *context) { struct adapter *adapter = context; + struct ixgbe_hw *hw = >hw; device_t dev = adapter->dev; struct ix_queue *que = adapter->queues; u64 queues = 0; u64 v0, v1, v2, v3, v4, v5, v6, v7; int hung = 0; int i; + bool do_probe = false; IXGBE_CORE_LOCK(adapter); /* Check for pluggable optics */ - if (adapter->sfp_probe) - if (!ixgbe_sfp_probe(adapter)) - goto out; /* Nothing to do */ + if (ixgbe_is_sfp(hw)) { + bool was_full = hw->phy.sfp_type != ixgbe_sfp_type_not_present; + bool is_full = ixgbe_sfp_cage_full(hw); + + /* do probe if cage state changed */ + if (was_full ^ is_full) + do_probe = true; + } + if (do_probe) { + atomic_or_32(>task_requests, IXGBE_REQUEST_TASK_MOD); + ixgbe_schedule_admin_tasklet(adapter); + } ixgbe_update_link_status(adapter); ixgbe_update_stats_counters(adapter); @@ -4553,7 +4558,6 @@ ixgbe_handle_timer(struct work *wk, void } #endif -out: atomic_store_relaxed(>timer_pending, 0); IXGBE_CORE_UNLOCK(adapter); callout_reset(>timer, hz, ixgbe_local_timer, adapter); @@ -4607,38 +4611,22 @@ ixgbe_handle_recovery_mode_timer(struct } /* ixgbe_handle_recovery_mode_timer */ / - * ixgbe_sfp_probe + * ixgbe_sfp_cage_full * * Determine if a port had optics inserted. / static bool -ixgbe_sfp_probe(struct adapter *adapter) +ixgbe_sfp_cage_full(struct ixgbe_hw *hw) { - struct ixgbe_hw *hw = >hw; - device_t dev = adapter->dev; - bool result = FALSE; + uint32_t mask; - if ((hw->phy.type == ixgbe_phy_nl) && - (hw->phy.sfp_type == ixgbe_sfp_type_not_present)) { - s32 ret = hw->phy.ops.identify_sfp(hw); - if (ret) - goto out; - ret = hw->phy.ops.reset(hw); - adapter->sfp_probe = FALSE; - if (ret == IXGBE_ERR_SFP_NOT_SUPPORTED) { - device_printf(dev,"Unsupported SFP+ module detected!"); - device_printf(dev, - "Reload driver with supported module.\n"); - goto out; - } else - device_printf(dev, "SFP+ module detected!\n"); - /* We now have supported optics */ - result = TRUE; - } -out: + if (hw->mac.type >= ixgbe_mac_X540) + mask = IXGBE_ESDP_SDP0; + else + mask = IXGBE_ESDP_SDP2; - return (result); -} /* ixgbe_sfp_probe */ + return IXGBE_READ_REG(hw, IXGBE_ESDP) & mask; +} /* ixgbe_sfp_cage_full */ / * ixgbe_handle_mod - Tasklet for SFP module interrupts Index: src/sys/dev/pci/ixgbe/ixgbe.h diff -u
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Mon Aug 17 06:30:25 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe: ixgbe.c Log Message: Add missing workqueue_wait() for the recovery_mode_timer workqueue. To generate a diff of this commit: cvs rdiff -u -r1.235 -r1.236 src/sys/dev/pci/ixgbe/ixgbe.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.235 src/sys/dev/pci/ixgbe/ixgbe.c:1.236 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.235 Thu Aug 13 08:42:18 2020 +++ src/sys/dev/pci/ixgbe/ixgbe.c Mon Aug 17 06:30:25 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.235 2020/08/13 08:42:18 msaitoh Exp $ */ +/* $NetBSD: ixgbe.c,v 1.236 2020/08/17 06:30:25 msaitoh Exp $ */ /** @@ -3522,6 +3522,13 @@ ixgbe_free_workqueue(struct adapter *ada adapter->timer_wq = NULL; } if (adapter->recovery_mode_timer_wq != NULL) { + /* + * ixgbe_ifstop() doesn't call the workqueue_wait() for + * the recovery_mode_timer workqueue, so call it here. + */ + workqueue_wait(adapter->recovery_mode_timer_wq, + >recovery_mode_timer_wc); + atomic_store_relaxed(>recovery_mode_timer_pending, 0); workqueue_destroy(adapter->recovery_mode_timer_wq); adapter->recovery_mode_timer_wq = NULL; }
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Thu Aug 13 08:42:18 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe: ixgbe.c Log Message: Set recovery_mode_timer workqueue's name correctly. To generate a diff of this commit: cvs rdiff -u -r1.234 -r1.235 src/sys/dev/pci/ixgbe/ixgbe.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.234 src/sys/dev/pci/ixgbe/ixgbe.c:1.235 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.234 Thu Aug 13 08:38:50 2020 +++ src/sys/dev/pci/ixgbe/ixgbe.c Thu Aug 13 08:42:18 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.234 2020/08/13 08:38:50 msaitoh Exp $ */ +/* $NetBSD: ixgbe.c,v 1.235 2020/08/13 08:42:18 msaitoh Exp $ */ /** @@ -1228,6 +1228,8 @@ ixgbe_attach(device_t parent, device_t d /* Set up the timer callout */ callout_init(>recovery_mode_timer, IXGBE_CALLOUT_FLAGS); + snprintf(wqname, sizeof(wqname), "%s-recovery", + device_xname(dev)); error = workqueue_create(>recovery_mode_timer_wq, wqname, ixgbe_handle_recovery_mode_timer, adapter, IXGBE_WORKQUEUE_PRI, IPL_NET, IXGBE_TASKLET_WQ_FLAGS);
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Thu Aug 13 08:38:50 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe: ixgbe.c ixv.c Log Message: Use atomic_cas_uint() and atomic_store_relaxed(). Advised by thorpej@. Tested by me. OK'd by knakahara. To generate a diff of this commit: cvs rdiff -u -r1.233 -r1.234 src/sys/dev/pci/ixgbe/ixgbe.c cvs rdiff -u -r1.151 -r1.152 src/sys/dev/pci/ixgbe/ixv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.233 src/sys/dev/pci/ixgbe/ixgbe.c:1.234 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.233 Thu Jun 25 07:53:01 2020 +++ src/sys/dev/pci/ixgbe/ixgbe.c Thu Aug 13 08:38:50 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.233 2020/06/25 07:53:01 msaitoh Exp $ */ +/* $NetBSD: ixgbe.c,v 1.234 2020/08/13 08:38:50 msaitoh Exp $ */ /** @@ -1512,11 +1512,9 @@ static void ixgbe_schedule_admin_tasklet(struct adapter *adapter) { if (adapter->schedule_wqs_ok) { - if (!adapter->admin_pending) { - atomic_or_uint(>admin_pending, 1); + if (atomic_cas_uint(>admin_pending, 0, 1) == 0) workqueue_enqueue(adapter->admin_wq, >admin_wc, NULL); - } } } @@ -4063,7 +4061,7 @@ ixgbe_init_locked(struct adapter *adapte ixgbe_enable_rx_dma(hw, rxctrl); callout_reset(>timer, hz, ixgbe_local_timer, adapter); - atomic_and_uint(>timer_pending, ~1); + atomic_store_relaxed(>timer_pending, 0); if (adapter->feat_en & IXGBE_FEATURE_RECOVERY_MODE) callout_reset(>recovery_mode_timer, hz, ixgbe_recovery_mode_timer, adapter); @@ -4446,11 +,9 @@ ixgbe_local_timer(void *arg) struct adapter *adapter = arg; if (adapter->schedule_wqs_ok) { - if (!adapter->timer_pending) { - atomic_or_uint(>timer_pending, 1); + if (atomic_cas_uint(>timer_pending, 0, 1) == 0) workqueue_enqueue(adapter->timer_wq, >timer_wc, NULL); - } } } @@ -4549,7 +4545,7 @@ ixgbe_handle_timer(struct work *wk, void #endif out: - atomic_and_uint(>timer_pending, ~1); + atomic_store_relaxed(>timer_pending, 0); IXGBE_CORE_UNLOCK(adapter); callout_reset(>timer, hz, ixgbe_local_timer, adapter); return; @@ -4570,8 +4566,8 @@ ixgbe_recovery_mode_timer(void *arg) { struct adapter *adapter = arg; - if (!adapter->recovery_mode_timer_pending) { - atomic_or_uint(>recovery_mode_timer_pending, 1); + if (atomic_cas_uint(>recovery_mode_timer_pending, 0, 1) == 0) + { workqueue_enqueue(adapter->recovery_mode_timer_wq, >recovery_mode_timer_wc, NULL); } @@ -4595,7 +4591,7 @@ ixgbe_handle_recovery_mode_timer(struct } else atomic_cas_uint(>recovery_mode, 1, 0); - atomic_and_uint(>recovery_mode_timer_pending, ~1); + atomic_store_relaxed(>recovery_mode_timer_pending, 0); callout_reset(>recovery_mode_timer, hz, ixgbe_recovery_mode_timer, adapter); IXGBE_CORE_UNLOCK(adapter); @@ -4808,7 +4804,7 @@ ixgbe_handle_admin(struct work *wk, void } #endif } - atomic_and_uint(>admin_pending, ~1); + atomic_store_relaxed(>admin_pending, 0); if ((adapter->feat_en & IXGBE_FEATURE_MSIX) != 0) { /* Re-enable other interrupts */ IXGBE_WRITE_REG(hw, IXGBE_EIMS, IXGBE_EIMS_OTHER); @@ -4829,9 +4825,9 @@ ixgbe_ifstop(struct ifnet *ifp, int disa IXGBE_CORE_UNLOCK(adapter); workqueue_wait(adapter->admin_wq, >admin_wc); - atomic_and_uint(>admin_pending, ~1); + atomic_store_relaxed(>admin_pending, 0); workqueue_wait(adapter->timer_wq, >timer_wc); - atomic_and_uint(>timer_pending, ~1); + atomic_store_relaxed(>timer_pending, 0); } / Index: src/sys/dev/pci/ixgbe/ixv.c diff -u src/sys/dev/pci/ixgbe/ixv.c:1.151 src/sys/dev/pci/ixgbe/ixv.c:1.152 --- src/sys/dev/pci/ixgbe/ixv.c:1.151 Thu Jun 25 07:53:02 2020 +++ src/sys/dev/pci/ixgbe/ixv.c Thu Aug 13 08:38:50 2020 @@ -1,4 +1,4 @@ -/*$NetBSD: ixv.c,v 1.151 2020/06/25 07:53:02 msaitoh Exp $*/ +/*$NetBSD: ixv.c,v 1.152 2020/08/13 08:38:50 msaitoh Exp $*/ /** @@ -787,7 +787,7 @@ ixv_init_locked(struct adapter *adapter) /* Start watchdog */ callout_reset(>timer, hz, ixv_local_timer, adapter); - atomic_and_uint(>timer_pending, ~1); + atomic_store_relaxed(>timer_pending, 0); /* OK to schedule workqueues. */ adapter->schedule_wqs_ok = true; @@ -1063,11 +1063,9 @@ static void ixv_schedule_admin_tasklet(struct adapter *adapter) { if (adapter->schedule_wqs_ok) { - if (!adapter->admin_pending) { - atomic_or_uint(>admin_pending, 1); + if (atomic_cas_uint(>admin_pending, 0, 1) == 0) workqueue_enqueue(adapter->admin_wq, >admin_wc, NULL); - } } } @@ -1252,11 +1250,9 @@ ixv_local_timer(void *arg) struct adapter *adapter = arg; if (adapter->schedule_wqs_ok) { - if (!adapter->timer_pending)
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Wed Aug 12 09:13:46 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe: if_bypass.c Log Message: Fix checking return value of atomic_cas_uint(). This change fixes a bug that extra delay() is called only once even if atomic_cas_uint() isn't failed or delay() isn't called when atomic_cas_uint() failed. The reason of this bug was that I simply converted FreeBSD' atomic_cmpset_int() to atomic_cas_uint(). The return value's semantics is different. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/dev/pci/ixgbe/if_bypass.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/if_bypass.c diff -u src/sys/dev/pci/ixgbe/if_bypass.c:1.5 src/sys/dev/pci/ixgbe/if_bypass.c:1.6 --- src/sys/dev/pci/ixgbe/if_bypass.c:1.5 Mon Dec 16 02:50:54 2019 +++ src/sys/dev/pci/ixgbe/if_bypass.c Wed Aug 12 09:13:46 2020 @@ -45,9 +45,9 @@ static void ixgbe_bypass_mutex_enter(struct adapter *adapter) { - while (atomic_cas_uint(>bypass.low, 0, 1) == 0) + while (atomic_cas_uint(>bypass.low, 0, 1) != 0) usec_delay(3000); - while (atomic_cas_uint(>bypass.high, 0, 1) == 0) + while (atomic_cas_uint(>bypass.high, 0, 1) != 0) usec_delay(3000); return; } /* ixgbe_bypass_mutex_enter */ @@ -58,9 +58,9 @@ ixgbe_bypass_mutex_enter(struct adapter static void ixgbe_bypass_mutex_clear(struct adapter *adapter) { - while (atomic_cas_uint(>bypass.high, 1, 0) == 0) + while (atomic_cas_uint(>bypass.high, 1, 0) != 1) usec_delay(6000); - while (atomic_cas_uint(>bypass.low, 1, 0) == 0) + while (atomic_cas_uint(>bypass.low, 1, 0) != 1) usec_delay(6000); return; } /* ixgbe_bypass_mutex_clear */ @@ -73,7 +73,7 @@ ixgbe_bypass_mutex_clear(struct adapter static void ixgbe_bypass_wd_mutex_enter(struct adapter *adapter) { - while (atomic_cas_uint(>bypass.high, 0, 1) == 0) + while (atomic_cas_uint(>bypass.high, 0, 1) != 0) usec_delay(3000); return; } /* ixgbe_bypass_wd_mutex_enter */ @@ -84,7 +84,7 @@ ixgbe_bypass_wd_mutex_enter(struct adapt static void ixgbe_bypass_wd_mutex_clear(struct adapter *adapter) { - while (atomic_cas_uint(>bypass.high, 1, 0) == 0) + while (atomic_cas_uint(>bypass.high, 1, 0) != 1) usec_delay(6000); return; } /* ixgbe_bypass_wd_mutex_clear */ @@ -585,7 +585,7 @@ ixgbe_bp_log(SYSCTLFN_ARGS) return (error); /* Keep the log display single-threaded */ - while (atomic_cas_uint(>bypass.log, 0, 1) == 0) + while (atomic_cas_uint(>bypass.log, 0, 1) != 0) usec_delay(3000); ixgbe_bypass_mutex_enter(adapter); @@ -713,14 +713,14 @@ ixgbe_bp_log(SYSCTLFN_ARGS) status = 0; /* reset */ /* Another log command can now run */ - while (atomic_cas_uint(>bypass.log, 1, 0) == 0) + while (atomic_cas_uint(>bypass.log, 1, 0) != 1) usec_delay(3000); return (error); unlock_err: ixgbe_bypass_mutex_clear(adapter); status = 0; /* reset */ - while (atomic_cas_uint(>bypass.log, 1, 0) == 0) + while (atomic_cas_uint(>bypass.log, 1, 0) != 1) usec_delay(3000); return (EINVAL); } /* ixgbe_bp_log */
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Thu Jun 25 07:53:02 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe: if_sriov.c ixgbe.c ixgbe.h ixgbe_netbsd.c ixgbe_osdep.h ixv.c Log Message: Reduce ixgbe's busy loop using with workqueue and kpause. - Use workqueue instead of softint to make some functions sleepable. - Use new workqueue and enqueue it in ixgbe_local_timer() and ixgbe_recovery_mode_timer() to make them sleepable. - Make new ixgbe_delay() and use it. This functions sleeps if the time is more than equals 1 tick. If it's not, do delay(). To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/dev/pci/ixgbe/if_sriov.c cvs rdiff -u -r1.232 -r1.233 src/sys/dev/pci/ixgbe/ixgbe.c cvs rdiff -u -r1.66 -r1.67 src/sys/dev/pci/ixgbe/ixgbe.h cvs rdiff -u -r1.14 -r1.15 src/sys/dev/pci/ixgbe/ixgbe_netbsd.c cvs rdiff -u -r1.26 -r1.27 src/sys/dev/pci/ixgbe/ixgbe_osdep.h cvs rdiff -u -r1.150 -r1.151 src/sys/dev/pci/ixgbe/ixv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/if_sriov.c diff -u src/sys/dev/pci/ixgbe/if_sriov.c:1.6 src/sys/dev/pci/ixgbe/if_sriov.c:1.7 --- src/sys/dev/pci/ixgbe/if_sriov.c:1.6 Thu Jun 27 05:55:40 2019 +++ src/sys/dev/pci/ixgbe/if_sriov.c Thu Jun 25 07:53:01 2020 @@ -645,7 +645,6 @@ ixgbe_handle_mbx(void *context, int pend hw = >hw; - IXGBE_CORE_LOCK(adapter); for (i = 0; i < adapter->num_vfs; i++) { vf = >vfs[i]; @@ -660,7 +659,6 @@ ixgbe_handle_mbx(void *context, int pend ixgbe_process_vf_ack(adapter, vf); } } - IXGBE_CORE_UNLOCK(adapter); } /* ixgbe_handle_mbx */ int Index: src/sys/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.232 src/sys/dev/pci/ixgbe/ixgbe.c:1.233 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.232 Thu Jun 18 09:00:11 2020 +++ src/sys/dev/pci/ixgbe/ixgbe.c Thu Jun 25 07:53:01 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.232 2020/06/18 09:00:11 msaitoh Exp $ */ +/* $NetBSD: ixgbe.c,v 1.233 2020/06/25 07:53:01 msaitoh Exp $ */ /** @@ -179,7 +179,7 @@ static void ixgbe_media_status(struct if static int ixgbe_media_change(struct ifnet *); static int ixgbe_allocate_pci_resources(struct adapter *, const struct pci_attach_args *); -static void ixgbe_free_softint(struct adapter *); +static void ixgbe_free_workqueue(struct adapter *); static void ixgbe_get_slot_info(struct adapter *); static int ixgbe_allocate_msix(struct adapter *, const struct pci_attach_args *); @@ -189,12 +189,14 @@ static int ixgbe_configure_interrupts(st static void ixgbe_free_pciintr_resources(struct adapter *); static void ixgbe_free_pci_resources(struct adapter *); static void ixgbe_local_timer(void *); -static void ixgbe_local_timer1(void *); +static void ixgbe_handle_timer(struct work *, void *); static void ixgbe_recovery_mode_timer(void *); +static void ixgbe_handle_recovery_mode_timer(struct work *, void *); static int ixgbe_setup_interface(device_t, struct adapter *); static void ixgbe_config_gpie(struct adapter *); static void ixgbe_config_dmac(struct adapter *); static void ixgbe_config_delay_values(struct adapter *); +static void ixgbe_schedule_admin_tasklet(struct adapter *); static void ixgbe_config_link(struct adapter *); static void ixgbe_check_wol_support(struct adapter *); static int ixgbe_setup_low_power_mode(struct adapter *); @@ -262,17 +264,17 @@ static int ixgbe_legacy_irq(void *); /* The MSI/MSI-X Interrupt handlers */ static int ixgbe_msix_que(void *); -static int ixgbe_msix_link(void *); +static int ixgbe_msix_admin(void *); -/* Software interrupts for deferred work */ +/* Event handlers running on workqueue */ static void ixgbe_handle_que(void *); static void ixgbe_handle_link(void *); +static void ixgbe_handle_msf(void *); static void ixgbe_handle_mod(void *); static void ixgbe_handle_phy(void *); -static void ixgbe_handle_msf(struct work *, void *); - -/* Workqueue handler for deferred work */ +/* Deferred workqueue handlers */ +static void ixgbe_handle_admin(struct work *, void *); static void ixgbe_handle_que_work(struct work *, void *); static const ixgbe_vendor_info_t *ixgbe_lookup(const struct pci_attach_args *); @@ -783,6 +785,7 @@ ixgbe_attach(device_t parent, device_t d struct pci_attach_args *pa = aux; bool unsupported_sfp = false; const char *str; + char wqname[MAXCOMLEN]; char buf[256]; INIT_DEBUGOUT("ixgbe_attach: begin"); @@ -807,11 +810,20 @@ ixgbe_attach(device_t parent, device_t d aprint_normal(": %s, Version - %s\n", ixgbe_strings[ent->index], ixgbe_driver_version); - /* Core Lock Init*/ + /* Core Lock Init */ IXGBE_CORE_LOCK_INIT(adapter, device_xname(dev)); - /* Set up the timer callout */ + /* Set up the timer callout and workqueue */ callout_init(>timer, IXGBE_CALLOUT_FLAGS); + snprintf(wqname,
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Thu Jun 25 06:45:10 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe: ixgbe_82598.c Log Message: Use unsigned to avoid undefined behavior in ixgbe_fc_enable_generic(). Same as ixgbe_common.c rev. 1.24. Found by KUBSan. To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/sys/dev/pci/ixgbe/ixgbe_82598.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ixgbe_82598.c diff -u src/sys/dev/pci/ixgbe/ixgbe_82598.c:1.14 src/sys/dev/pci/ixgbe/ixgbe_82598.c:1.15 --- src/sys/dev/pci/ixgbe/ixgbe_82598.c:1.14 Fri Jan 3 12:59:46 2020 +++ src/sys/dev/pci/ixgbe/ixgbe_82598.c Thu Jun 25 06:45:10 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe_82598.c,v 1.14 2020/01/03 12:59:46 pgoyette Exp $ */ +/* $NetBSD: ixgbe_82598.c,v 1.15 2020/06/25 06:45:10 msaitoh Exp $ */ /** SPDX-License-Identifier: BSD-3-Clause @@ -538,7 +538,7 @@ s32 ixgbe_fc_enable_82598(struct ixgbe_h } /* Configure pause time (2 TCs per register) */ - reg = hw->fc.pause_time * 0x00010001; + reg = (u32)hw->fc.pause_time * 0x00010001; for (i = 0; i < (IXGBE_DCB_MAX_TRAFFIC_CLASS / 2); i++) IXGBE_WRITE_REG(hw, IXGBE_FCTTV(i), reg);
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Tue Jun 23 05:50:01 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe: ixgbe.h Log Message: KNF. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.65 -r1.66 src/sys/dev/pci/ixgbe/ixgbe.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ixgbe.h diff -u src/sys/dev/pci/ixgbe/ixgbe.h:1.65 src/sys/dev/pci/ixgbe/ixgbe.h:1.66 --- src/sys/dev/pci/ixgbe/ixgbe.h:1.65 Thu Feb 6 06:28:49 2020 +++ src/sys/dev/pci/ixgbe/ixgbe.h Tue Jun 23 05:50:01 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.h,v 1.65 2020/02/06 06:28:49 thorpej Exp $ */ +/* $NetBSD: ixgbe.h,v 1.66 2020/06/23 05:50:01 msaitoh Exp $ */ /** SPDX-License-Identifier: BSD-3-Clause @@ -268,10 +268,10 @@ typedef struct _ixgbe_vendor_info_t { /* This is used to get SFP+ module data */ struct ixgbe_i2c_req { -u8 dev_addr; -u8 offset; -u8 len; -u8 data[8]; + u8 dev_addr; + u8 offset; + u8 len; + u8 data[8]; }; struct ixgbe_bp_data { @@ -334,13 +334,15 @@ struct ix_queue { char namebuf[32]; char evnamebuf[32]; - kmutex_t dc_mtx; /* lock for disabled_count and this queue's EIMS/EIMC bit */ - int disabled_count;/* - * means - * 0 : this queue is enabled - * > 0 : this queue is disabled - * the value is ixgbe_disable_queue() called count - */ + /* Lock for disabled_count and this queue's EIMS/EIMC bit */ + kmutex_t dc_mtx; + /* + * disabled_count means: + * 0 : this queue is enabled + * > 0 : this queue is disabled + * the value is ixgbe_disable_queue() called count + */ + int disabled_count; bool txrx_use_workqueue; }; @@ -373,10 +375,10 @@ struct tx_ring { u16 atr_sample; u16 atr_count; - u64 bytes; /* used for AIM */ + u64 bytes; /* Used for AIM */ u64 packets; /* Soft Stats */ - struct evcnt tso_tx; + struct evcnt tso_tx; struct evcnt no_desc_avail; struct evcnt total_packets; struct evcnt pcq_drops; @@ -409,7 +411,7 @@ struct rx_ring { bool hw_rsc; bool vtag_strip; u16 next_to_refresh; - u16 next_to_check; + u16 next_to_check; u16 num_desc; u16 mbuf_sz; #if 0 @@ -417,8 +419,8 @@ struct rx_ring { #endif struct ixgbe_rx_buf *rx_buffers; ixgbe_dma_tag_t *ptag; - u16 last_rx_mbuf_sz; - u32 last_num_rx_desc; + u16 last_rx_mbuf_sz; + u32 last_num_rx_desc; ixgbe_extmem_head_t jcl_head; u64 bytes; /* Used for AIM calc */ @@ -427,10 +429,10 @@ struct rx_ring { /* Soft stats */ struct evcnt rx_copies; struct evcnt rx_packets; - struct evcnt rx_bytes; - struct evcnt rx_discarded; - struct evcnt no_jmbuf; - u64 rsc_num; + struct evcnt rx_bytes; + struct evcnt rx_discarded; + struct evcnt no_jmbuf; + u64 rsc_num; /* Flow Director */ u64 flm; @@ -496,7 +498,7 @@ struct adapter { u16 num_segs; u32 link_speed; bool link_up; - u32 vector; + u32 vector; u16 dmac; u32 phy_layer; @@ -525,15 +527,17 @@ struct adapter { void *phy_si; /* PHY intr tasklet */ bool txrx_use_workqueue; - struct workqueue *que_wq;/* workqueue for ixgbe_handle_que_work() */ - /* - * que_wq's "enqueued flag" is not required, - * because twice workqueue_enqueue() for - * ixgbe_handle_que_work() is avoided by masking - * the queue's interrupt by EIMC. - * See also ixgbe_msix_que(). - */ - struct workqueue *txr_wq;/* workqueue for ixgbe_deferred_mq_start_work() */ + + /* + * Workqueue for ixgbe_handle_que_work(). + * + * que_wq's "enqueued flag" is not required, because twice + * workqueue_enqueue() for ixgbe_handle_que_work() is avoided by + * masking the queue's interrupt by EIMC. See also ixgbe_msix_que(). + */ + struct workqueue *que_wq; + /* Workqueue for ixgbe_deferred_mq_start_work() */ + struct workqueue *txr_wq; percpu_t *txr_wq_enqueued; /* @@ -574,23 +578,23 @@ struct adapter { struct ixgbe_bp_databypass; /* Netmap */ - void (*init_locked)(struct adapter *); - void (*stop_locked)(void *); + void (*init_locked)(struct adapter *); + void (*stop_locked)(void *); /* Firmware error check */ u_int recovery_mode; struct callout recovery_mode_timer; /* Misc stats maintained by the driver */ - struct evcnt efbig_tx_dma_setup; - struct evcnt mbuf_defrag_failed; - struct evcnt efbig2_tx_dma_setup; - struct evcnt einval_tx_dma_setup; - struct evcnt other_tx_dma_setup; - struct evcnt eagain_tx_dma_setup; - struct evcnt enomem_tx_dma_setup; - struct evcnt tso_err; - struct evcnt
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Thu Jun 18 09:00:11 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe: ixgbe.c ixv.c Log Message: Modify a liitle to reduce diff between ixgbe.c and ixv.c. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.231 -r1.232 src/sys/dev/pci/ixgbe/ixgbe.c cvs rdiff -u -r1.149 -r1.150 src/sys/dev/pci/ixgbe/ixv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.231 src/sys/dev/pci/ixgbe/ixgbe.c:1.232 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.231 Wed Jun 17 09:11:13 2020 +++ src/sys/dev/pci/ixgbe/ixgbe.c Thu Jun 18 09:00:11 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.231 2020/06/17 09:11:13 msaitoh Exp $ */ +/* $NetBSD: ixgbe.c,v 1.232 2020/06/18 09:00:11 msaitoh Exp $ */ /** @@ -168,9 +168,9 @@ static bool ixgbe_suspend(device_t, cons static bool ixgbe_resume(device_t, const pmf_qual_t *); static int ixgbe_ifflags_cb(struct ethercom *); static int ixgbe_ioctl(struct ifnet *, u_long, void *); -static void ixgbe_ifstop(struct ifnet *, int); static int ixgbe_init(struct ifnet *); static void ixgbe_init_locked(struct adapter *); +static void ixgbe_ifstop(struct ifnet *, int); static void ixgbe_stop(void *); static void ixgbe_init_device_features(struct adapter *); static void ixgbe_check_fan_failure(struct adapter *, u32, bool); @@ -4457,7 +4457,7 @@ ixgbe_local_timer1(void *arg) { struct adapter *adapter = arg; device_t dev = adapter->dev; - struct ix_queue *que = adapter->queues; + struct ix_queue *que = adapter->queues; u64 queues = 0; u64 v0, v1, v2, v3, v4, v5, v6, v7; int hung = 0; @@ -4530,7 +4530,7 @@ ixgbe_local_timer1(void *arg) } } - /* Only truely watchdog if all queues show hung */ + /* Only truly watchdog if all queues show hung */ if (hung == adapter->num_queues) goto watchdog; #if 0 /* XXX Avoid unexpectedly disabling interrupt forever (PR#53294) */ @@ -6258,7 +6258,7 @@ out: * return 0 on success, positive on failure / static int -ixgbe_ioctl(struct ifnet * ifp, u_long command, void *data) +ixgbe_ioctl(struct ifnet *ifp, u_long command, void *data) { struct adapter *adapter = ifp->if_softc; struct ixgbe_hw *hw = >hw; Index: src/sys/dev/pci/ixgbe/ixv.c diff -u src/sys/dev/pci/ixgbe/ixv.c:1.149 src/sys/dev/pci/ixgbe/ixv.c:1.150 --- src/sys/dev/pci/ixgbe/ixv.c:1.149 Thu Jun 11 09:16:05 2020 +++ src/sys/dev/pci/ixgbe/ixv.c Thu Jun 18 09:00:11 2020 @@ -1,4 +1,4 @@ -/*$NetBSD: ixv.c,v 1.149 2020/06/11 09:16:05 msaitoh Exp $*/ +/*$NetBSD: ixv.c,v 1.150 2020/06/18 09:00:11 msaitoh Exp $*/ /** @@ -158,7 +158,7 @@ const struct sysctlnode *ixv_sysctl_inst static const ixgbe_vendor_info_t *ixv_lookup(const struct pci_attach_args *); / - * FreeBSD Device Interface Entry Points + * NetBSD Device Interface Entry Points / CFATTACH_DECL3_NEW(ixv, sizeof(struct adapter), ixv_probe, ixv_attach, ixv_detach, NULL, NULL, NULL, @@ -319,8 +319,8 @@ ixv_attach(device_t parent, device_t dev /* Allocate, clear, and link in our adapter structure */ adapter = device_private(dev); - adapter->dev = dev; adapter->hw.back = adapter; + adapter->dev = dev; hw = >hw; adapter->init_locked = ixv_init_locked; @@ -341,7 +341,7 @@ ixv_attach(device_t parent, device_t dev aprint_normal(": %s, Version - %s\n", ixv_strings[ent->index], ixv_driver_version); - /* Core Lock Init*/ + /* Core Lock Init */ IXGBE_CORE_LOCK_INIT(adapter, device_xname(dev)); /* Do base PCI setup - map BAR0 */ @@ -1081,7 +1081,7 @@ ixv_negotiate_api(struct adapter *adapte / - * ixv_set_multi - Multicast Update + * ixv_set_rxfilter - Multicast Update * * Called whenever multicast address list is updated. / @@ -3306,8 +3306,8 @@ ixv_allocate_msix(struct adapter *adapte /* Round-robin affinity */ kcpuset_zero(affinity); kcpuset_set(affinity, cpu_id % ncpu); - error = interrupt_distribute(adapter->osdep.ihs[vector], - affinity, NULL); + error = interrupt_distribute(adapter->osdep.ihs[vector], affinity, + NULL); aprint_normal_dev(dev, "for link, interrupting at %s", intrstr);
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Wed Jun 17 09:11:13 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe: ixgbe.c Log Message: Add missing callout_stop() for recovery_mode_timer. NOTE: One of the difference between the local_timer and recovery_mode_timer is that local_timer runs only when IFF_UP and recovery_mode_timer always runs (it's enabled on attach). To generate a diff of this commit: cvs rdiff -u -r1.230 -r1.231 src/sys/dev/pci/ixgbe/ixgbe.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.230 src/sys/dev/pci/ixgbe/ixgbe.c:1.231 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.230 Fri Jun 12 09:28:48 2020 +++ src/sys/dev/pci/ixgbe/ixgbe.c Wed Jun 17 09:11:13 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.230 2020/06/12 09:28:48 msaitoh Exp $ */ +/* $NetBSD: ixgbe.c,v 1.231 2020/06/17 09:11:13 msaitoh Exp $ */ /** @@ -3593,8 +3593,10 @@ ixgbe_detach(device_t dev, int flags) IXGBE_WRITE_REG(>hw, IXGBE_CTRL_EXT, ctrl_ext); callout_halt(>timer, NULL); - if (adapter->feat_en & IXGBE_FEATURE_RECOVERY_MODE) + if (adapter->feat_en & IXGBE_FEATURE_RECOVERY_MODE) { + callout_stop(>recovery_mode_timer); callout_halt(>recovery_mode_timer, NULL); + } if (adapter->feat_en & IXGBE_FEATURE_NETMAP) netmap_detach(adapter->ifp); @@ -3917,6 +3919,8 @@ ixgbe_init_locked(struct adapter *adapte hw->adapter_stopped = FALSE; ixgbe_stop_adapter(hw); callout_stop(>timer); + if (adapter->feat_en & IXGBE_FEATURE_RECOVERY_MODE) + callout_stop(>recovery_mode_timer); for (i = 0, que = adapter->queues; i < adapter->num_queues; i++, que++) que->disabled_count = 0; @@ -4062,6 +4066,9 @@ ixgbe_init_locked(struct adapter *adapte ixgbe_enable_rx_dma(hw, rxctrl); callout_reset(>timer, hz, ixgbe_local_timer, adapter); + if (adapter->feat_en & IXGBE_FEATURE_RECOVERY_MODE) + callout_reset(>recovery_mode_timer, hz, + ixgbe_recovery_mode_timer, adapter); /* Set up MSI/MSI-X routing */ if (adapter->feat_en & IXGBE_FEATURE_MSIX) {
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Fri Jun 12 09:28:48 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe: ixgbe.c Log Message: - Remove extra kpreempt_disable() -> kpreempt_enable() because ixgbe_handle_msf() was changed from softint to workqueue. - Set schedule_wqs_ok before enabling interrupt to prevent the race. - Fix comment. To generate a diff of this commit: cvs rdiff -u -r1.229 -r1.230 src/sys/dev/pci/ixgbe/ixgbe.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.229 src/sys/dev/pci/ixgbe/ixgbe.c:1.230 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.229 Thu Jun 11 09:16:05 2020 +++ src/sys/dev/pci/ixgbe/ixgbe.c Fri Jun 12 09:28:48 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.229 2020/06/11 09:16:05 msaitoh Exp $ */ +/* $NetBSD: ixgbe.c,v 1.230 2020/06/12 09:28:48 msaitoh Exp $ */ /** @@ -1538,9 +1538,7 @@ ixgbe_config_link(struct adapter *adapte ixgbe_schedule_msf_tasklet(adapter); kpreempt_enable(); } - kpreempt_disable(); softint_schedule(adapter->mod_si); - kpreempt_enable(); } else { struct ifmedia *ifm = >media; @@ -4126,6 +4124,9 @@ ixgbe_init_locked(struct adapter *adapte /* Setup DMA Coalescing */ ixgbe_config_dmac(adapter); + /* OK to schedule workqueues. */ + adapter->schedule_wqs_ok = true; + /* And now turn on interrupts */ ixgbe_enable_intr(adapter); @@ -4143,9 +4144,6 @@ ixgbe_init_locked(struct adapter *adapte /* Now inform the stack we're ready */ ifp->if_flags |= IFF_RUNNING; - /* OK to schedule workqueues. */ - adapter->schedule_wqs_ok = true; - return; } /* ixgbe_init_locked */ @@ -4694,7 +4692,7 @@ ixgbe_handle_msf(struct work *wk, void * /* * Hold the IFNET_LOCK across this entire call. This will - * prevent additional changes to adapter->phy_layer and + * prevent additional changes to adapter->phy_layer * and serialize calls to this tasklet. We cannot hold the * CORE_LOCK while calling into the ifmedia functions as * they may block while allocating memory.
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Thu Jun 11 09:16:05 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe: ixgbe.c ixv.c Log Message: Fix typo. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.228 -r1.229 src/sys/dev/pci/ixgbe/ixgbe.c cvs rdiff -u -r1.148 -r1.149 src/sys/dev/pci/ixgbe/ixv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.228 src/sys/dev/pci/ixgbe/ixgbe.c:1.229 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.228 Fri Apr 17 02:21:25 2020 +++ src/sys/dev/pci/ixgbe/ixgbe.c Thu Jun 11 09:16:05 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.228 2020/04/17 02:21:25 msaitoh Exp $ */ +/* $NetBSD: ixgbe.c,v 1.229 2020/06/11 09:16:05 msaitoh Exp $ */ /** @@ -409,12 +409,12 @@ static int (*ixgbe_ring_empty)(struct if #ifdef NET_MPSAFE #define IXGBE_MPSAFE 1 #define IXGBE_CALLOUT_FLAGS CALLOUT_MPSAFE -#define IXGBE_SOFTINFT_FLAGS SOFTINT_MPSAFE +#define IXGBE_SOFTINT_FLAGS SOFTINT_MPSAFE #define IXGBE_WORKQUEUE_FLAGS WQ_PERCPU | WQ_MPSAFE #define IXGBE_TASKLET_WQ_FLAGS WQ_MPSAFE #else #define IXGBE_CALLOUT_FLAGS 0 -#define IXGBE_SOFTINFT_FLAGS 0 +#define IXGBE_SOFTINT_FLAGS 0 #define IXGBE_WORKQUEUE_FLAGS WQ_PERCPU #define IXGBE_TASKLET_WQ_FLAGS 0 #endif @@ -1100,15 +1100,15 @@ ixgbe_attach(device_t parent, device_t d goto err_late; /* Tasklets for Link, SFP, Multispeed Fiber and Flow Director */ - adapter->link_si = softint_establish(SOFTINT_NET |IXGBE_SOFTINFT_FLAGS, + adapter->link_si = softint_establish(SOFTINT_NET |IXGBE_SOFTINT_FLAGS, ixgbe_handle_link, adapter); - adapter->mod_si = softint_establish(SOFTINT_NET | IXGBE_SOFTINFT_FLAGS, + adapter->mod_si = softint_establish(SOFTINT_NET | IXGBE_SOFTINT_FLAGS, ixgbe_handle_mod, adapter); - adapter->phy_si = softint_establish(SOFTINT_NET | IXGBE_SOFTINFT_FLAGS, + adapter->phy_si = softint_establish(SOFTINT_NET | IXGBE_SOFTINT_FLAGS, ixgbe_handle_phy, adapter); if (adapter->feat_en & IXGBE_FEATURE_FDIR) adapter->fdir_si = - softint_establish(SOFTINT_NET | IXGBE_SOFTINFT_FLAGS, + softint_establish(SOFTINT_NET | IXGBE_SOFTINT_FLAGS, ixgbe_reinit_fdir, adapter); if ((adapter->link_si == NULL) || (adapter->mod_si == NULL) || (adapter->phy_si == NULL) @@ -6537,7 +6537,7 @@ alloc_retry: */ if (!(adapter->feat_en & IXGBE_FEATURE_LEGACY_TX)) { txr->txr_si = - softint_establish(SOFTINT_NET | IXGBE_SOFTINFT_FLAGS, + softint_establish(SOFTINT_NET | IXGBE_SOFTINT_FLAGS, ixgbe_deferred_mq_start, txr); snprintf(wqname, sizeof(wqname), "%sdeferTx", device_xname(dev)); @@ -6546,7 +6546,7 @@ alloc_retry: IPL_NET, IXGBE_WORKQUEUE_FLAGS); adapter->txr_wq_enqueued = percpu_alloc(sizeof(u_int)); } - que->que_si = softint_establish(SOFTINT_NET | IXGBE_SOFTINFT_FLAGS, + que->que_si = softint_establish(SOFTINT_NET | IXGBE_SOFTINT_FLAGS, ixgbe_handle_que, que); snprintf(wqname, sizeof(wqname), "%sTxRx", device_xname(dev)); error = workqueue_create(>que_wq, wqname, @@ -6686,7 +6686,7 @@ ixgbe_allocate_msix(struct adapter *adap if (!(adapter->feat_en & IXGBE_FEATURE_LEGACY_TX)) { txr->txr_si = softint_establish( -SOFTINT_NET | IXGBE_SOFTINFT_FLAGS, +SOFTINT_NET | IXGBE_SOFTINT_FLAGS, ixgbe_deferred_mq_start, txr); if (txr->txr_si == NULL) { aprint_error_dev(dev, @@ -6696,7 +6696,7 @@ ixgbe_allocate_msix(struct adapter *adap } } que->que_si - = softint_establish(SOFTINT_NET | IXGBE_SOFTINFT_FLAGS, + = softint_establish(SOFTINT_NET | IXGBE_SOFTINT_FLAGS, ixgbe_handle_que, que); if (que->que_si == NULL) { aprint_error_dev(dev, @@ -6758,7 +6758,7 @@ ixgbe_allocate_msix(struct adapter *adap if (adapter->feat_cap & IXGBE_FEATURE_SRIOV) { adapter->mbx_si = - softint_establish(SOFTINT_NET | IXGBE_SOFTINFT_FLAGS, + softint_establish(SOFTINT_NET | IXGBE_SOFTINT_FLAGS, ixgbe_handle_mbx, adapter); if (adapter->mbx_si == NULL) { aprint_error_dev(dev, Index: src/sys/dev/pci/ixgbe/ixv.c diff -u src/sys/dev/pci/ixgbe/ixv.c:1.148 src/sys/dev/pci/ixgbe/ixv.c:1.149 --- src/sys/dev/pci/ixgbe/ixv.c:1.148 Fri Apr 17 02:21:25 2020 +++ src/sys/dev/pci/ixgbe/ixv.c Thu Jun 11 09:16:05 2020 @@ -1,4 +1,4 @@ -/*$NetBSD: ixv.c,v 1.148 2020/04/17 02:21:25 msaitoh Exp $*/ +/*$NetBSD: ixv.c,v 1.149 2020/06/11 09:16:05 msaitoh Exp $*/ /** @@ -226,11 +226,11 @@ TUNABLE_INT("hw.ixv.enable_legacy_tx", & #ifdef NET_MPSAFE #define IXGBE_MPSAFE 1 #define IXGBE_CALLOUT_FLAGS CALLOUT_MPSAFE -#define IXGBE_SOFTINFT_FLAGS SOFTINT_MPSAFE +#define IXGBE_SOFTINT_FLAGS SOFTINT_MPSAFE #define IXGBE_WORKQUEUE_FLAGS WQ_PERCPU | WQ_MPSAFE #else #define
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Thu Jun 11 05:16:22 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe: ixgbe_osdep.h Log Message: Fix IXGBE_LE32_TO_CPUS() macro for big endian machine. This problem was only on X550*. Not tested on big endian machine. To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 src/sys/dev/pci/ixgbe/ixgbe_osdep.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ixgbe_osdep.h diff -u src/sys/dev/pci/ixgbe/ixgbe_osdep.h:1.25 src/sys/dev/pci/ixgbe/ixgbe_osdep.h:1.26 --- src/sys/dev/pci/ixgbe/ixgbe_osdep.h:1.25 Tue Dec 17 05:49:01 2019 +++ src/sys/dev/pci/ixgbe/ixgbe_osdep.h Thu Jun 11 05:16:22 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe_osdep.h,v 1.25 2019/12/17 05:49:01 msaitoh Exp $ */ +/* $NetBSD: ixgbe_osdep.h,v 1.26 2020/06/11 05:16:22 msaitoh Exp $ */ /** SPDX-License-Identifier: BSD-3-Clause @@ -139,7 +139,7 @@ enum { #define IXGBE_CPU_TO_LE16 htole16 #define IXGBE_CPU_TO_LE32 htole32 #define IXGBE_LE32_TO_CPU le32toh -#define IXGBE_LE32_TO_CPUS(x) +#define IXGBE_LE32_TO_CPUS(x) (*(x) = le32toh(*(x))) #define IXGBE_CPU_TO_BE16 htobe16 #define IXGBE_CPU_TO_BE32 htobe32 #define IXGBE_BE32_TO_CPU be32toh
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Fri Apr 17 02:21:25 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe: ix_txrx.c ixgbe.c ixgbe_netbsd.c ixgbe_phy.c ixv.c Log Message: No functional change: - modify comment - whitespace fix To generate a diff of this commit: cvs rdiff -u -r1.62 -r1.63 src/sys/dev/pci/ixgbe/ix_txrx.c cvs rdiff -u -r1.227 -r1.228 src/sys/dev/pci/ixgbe/ixgbe.c cvs rdiff -u -r1.13 -r1.14 src/sys/dev/pci/ixgbe/ixgbe_netbsd.c cvs rdiff -u -r1.20 -r1.21 src/sys/dev/pci/ixgbe/ixgbe_phy.c cvs rdiff -u -r1.147 -r1.148 src/sys/dev/pci/ixgbe/ixv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ix_txrx.c diff -u src/sys/dev/pci/ixgbe/ix_txrx.c:1.62 src/sys/dev/pci/ixgbe/ix_txrx.c:1.63 --- src/sys/dev/pci/ixgbe/ix_txrx.c:1.62 Wed Feb 5 07:45:46 2020 +++ src/sys/dev/pci/ixgbe/ix_txrx.c Fri Apr 17 02:21:25 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ix_txrx.c,v 1.62 2020/02/05 07:45:46 msaitoh Exp $ */ +/* $NetBSD: ix_txrx.c,v 1.63 2020/04/17 02:21:25 msaitoh Exp $ */ /** @@ -919,7 +919,7 @@ ixgbe_tx_ctx_setup(struct tx_ring *txr, vlan_macip_lens |= ip_hlen; /* No support for offloads for non-L4 next headers */ - switch (ipproto) { + switch (ipproto) { case IPPROTO_TCP: if (mp->m_pkthdr.csum_flags & (M_CSUM_TCPv4 | M_CSUM_TCPv6)) @@ -2220,7 +2220,7 @@ ixgbe_allocate_queues(struct adapter *ad /* First, allocate the top level queue structs */ adapter->queues = (struct ix_queue *)malloc(sizeof(struct ix_queue) * -adapter->num_queues, M_DEVBUF, M_WAITOK | M_ZERO); + adapter->num_queues, M_DEVBUF, M_WAITOK | M_ZERO); /* Second, allocate the TX ring struct memory */ adapter->tx_rings = malloc(sizeof(struct tx_ring) * @@ -2272,7 +2272,7 @@ ixgbe_allocate_queues(struct adapter *ad "Critical Failure setting up transmit buffers\n"); error = ENOMEM; goto err_tx_desc; - } + } if (!(adapter->feat_en & IXGBE_FEATURE_LEGACY_TX)) { /* Allocate a buf ring */ txr->txr_interq = pcq_create(IXGBE_BR_SIZE, KM_SLEEP); Index: src/sys/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.227 src/sys/dev/pci/ixgbe/ixgbe.c:1.228 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.227 Sun Mar 15 23:04:50 2020 +++ src/sys/dev/pci/ixgbe/ixgbe.c Fri Apr 17 02:21:25 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.227 2020/03/15 23:04:50 thorpej Exp $ */ +/* $NetBSD: ixgbe.c,v 1.228 2020/04/17 02:21:25 msaitoh Exp $ */ /** @@ -3227,7 +3227,7 @@ ixgbe_sysctl_interrupt_rate_handler(SYSC if (rate > 0 && rate < 50) { if (rate < 1000) rate = 1000; - reg |= ((400/rate) & 0xff8); + reg |= ((400 / rate) & 0xff8); /* * When RSC is used, ITR interval must be larger than * RSC_DELAY. Currently, we use 2us for RSC_DELAY. Index: src/sys/dev/pci/ixgbe/ixgbe_netbsd.c diff -u src/sys/dev/pci/ixgbe/ixgbe_netbsd.c:1.13 src/sys/dev/pci/ixgbe/ixgbe_netbsd.c:1.14 --- src/sys/dev/pci/ixgbe/ixgbe_netbsd.c:1.13 Sat Feb 1 02:33:08 2020 +++ src/sys/dev/pci/ixgbe/ixgbe_netbsd.c Fri Apr 17 02:21:25 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe_netbsd.c,v 1.13 2020/02/01 02:33:08 riastradh Exp $ */ +/* $NetBSD: ixgbe_netbsd.c,v 1.14 2020/04/17 02:21:25 msaitoh Exp $ */ /* * Copyright (c) 2011 The NetBSD Foundation, Inc. * All rights reserved. @@ -79,7 +79,7 @@ ixgbe_dmamap_destroy(ixgbe_dma_tag_t *dt void ixgbe_dmamap_sync(ixgbe_dma_tag_t *dt, bus_dmamap_t dmam, int ops) { -bus_dmamap_sync(dt->dt_dmat, dmam, 0, dt->dt_maxsize, ops); + bus_dmamap_sync(dt->dt_dmat, dmam, 0, dt->dt_maxsize, ops); } void Index: src/sys/dev/pci/ixgbe/ixgbe_phy.c diff -u src/sys/dev/pci/ixgbe/ixgbe_phy.c:1.20 src/sys/dev/pci/ixgbe/ixgbe_phy.c:1.21 --- src/sys/dev/pci/ixgbe/ixgbe_phy.c:1.20 Mon Dec 23 09:36:18 2019 +++ src/sys/dev/pci/ixgbe/ixgbe_phy.c Fri Apr 17 02:21:25 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe_phy.c,v 1.20 2019/12/23 09:36:18 msaitoh Exp $ */ +/* $NetBSD: ixgbe_phy.c,v 1.21 2020/04/17 02:21:25 msaitoh Exp $ */ /** SPDX-License-Identifier: BSD-3-Clause @@ -1786,7 +1786,7 @@ s32 ixgbe_identify_qsfp_module_generic(s /* Determine PHY vendor for optical modules */ if (comp_codes_10g & (IXGBE_SFF_10GBASESR_CAPABLE | - IXGBE_SFF_10GBASELR_CAPABLE)) { + IXGBE_SFF_10GBASELR_CAPABLE)) { status = hw->phy.ops.read_i2c_eeprom(hw, IXGBE_SFF_QSFP_VENDOR_OUI_BYTE0, _bytes[0]); Index: src/sys/dev/pci/ixgbe/ixv.c diff -u src/sys/dev/pci/ixgbe/ixv.c:1.147 src/sys/dev/pci/ixgbe/ixv.c:1.148 --- src/sys/dev/pci/ixgbe/ixv.c:1.147 Sun Mar 15 23:04:50 2020 +++ src/sys/dev/pci/ixgbe/ixv.c Fri Apr 17 02:21:25 2020 @@ -1,4 +1,4 @@
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: thorpej Date: Thu Feb 6 06:28:49 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe: ixgbe.c ixgbe.h Log Message: Ensure we don't call workqueue_enqueue() if the pluggable optics handler is already pending. To generate a diff of this commit: cvs rdiff -u -r1.225 -r1.226 src/sys/dev/pci/ixgbe/ixgbe.c cvs rdiff -u -r1.64 -r1.65 src/sys/dev/pci/ixgbe/ixgbe.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.225 src/sys/dev/pci/ixgbe/ixgbe.c:1.226 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.225 Wed Feb 5 07:45:46 2020 +++ src/sys/dev/pci/ixgbe/ixgbe.c Thu Feb 6 06:28:49 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.225 2020/02/05 07:45:46 msaitoh Exp $ */ +/* $NetBSD: ixgbe.c,v 1.226 2020/02/06 06:28:49 thorpej Exp $ */ /** @@ -1507,6 +1507,18 @@ ixgbe_is_sfp(struct ixgbe_hw *hw) } } /* ixgbe_is_sfp */ +static void +ixgbe_schedule_msf_tasklet(struct adapter *adapter) +{ + if (adapter->schedule_wqs_ok) { + if (!adapter->msf_pending) { + adapter->msf_pending = true; + workqueue_enqueue(adapter->msf_wq, + >msf_wc, NULL); + } + } +} + / * ixgbe_config_link / @@ -1523,9 +1535,7 @@ ixgbe_config_link(struct adapter *adapte if (hw->phy.multispeed_fiber) { ixgbe_enable_tx_laser(hw); kpreempt_disable(); - if (adapter->schedule_wqs_ok) -workqueue_enqueue(adapter->msf_wq, ->msf_wc, NULL); + ixgbe_schedule_msf_tasklet(adapter); kpreempt_enable(); } kpreempt_disable(); @@ -3099,9 +3109,7 @@ ixgbe_msix_link(void *arg) (eicr & IXGBE_EICR_GPI_SDP1_BY_MAC(hw))) { IXGBE_WRITE_REG(hw, IXGBE_EICR, IXGBE_EICR_GPI_SDP1_BY_MAC(hw)); - if (adapter->schedule_wqs_ok) -workqueue_enqueue(adapter->msf_wq, ->msf_wc, NULL); + ixgbe_schedule_msf_tasklet(adapter); } } @@ -4674,8 +4682,7 @@ ixgbe_handle_mod(void *context) goto out; } } - if (adapter->schedule_wqs_ok) - workqueue_enqueue(adapter->msf_wq, >msf_wc, NULL); + ixgbe_schedule_msf_tasklet(adapter); out: IXGBE_CORE_UNLOCK(adapter); } /* ixgbe_handle_mod */ @@ -4703,6 +4710,7 @@ ixgbe_handle_msf(struct work *wk, void * IFNET_LOCK(ifp); IXGBE_CORE_LOCK(adapter); + adapter->msf_pending = false; ++adapter->msf_sicount.ev_count; /* get_supported_phy_layer will call hw->phy.ops.identify_sfp() */ adapter->phy_layer = ixgbe_get_supported_physical_layer(hw); @@ -4754,6 +4762,7 @@ ixgbe_ifstop(struct ifnet *ifp, int disa IXGBE_CORE_UNLOCK(adapter); workqueue_wait(adapter->msf_wq, >msf_wc); + adapter->msf_pending = false; } / @@ -5122,9 +5131,7 @@ ixgbe_legacy_irq(void *arg) (eicr & IXGBE_EICR_GPI_SDP1_BY_MAC(hw))) { IXGBE_WRITE_REG(hw, IXGBE_EICR, IXGBE_EICR_GPI_SDP1_BY_MAC(hw)); - if (adapter->schedule_wqs_ok) -workqueue_enqueue(adapter->msf_wq, ->msf_wc, NULL); + ixgbe_schedule_msf_tasklet(adapter); } } Index: src/sys/dev/pci/ixgbe/ixgbe.h diff -u src/sys/dev/pci/ixgbe/ixgbe.h:1.64 src/sys/dev/pci/ixgbe/ixgbe.h:1.65 --- src/sys/dev/pci/ixgbe/ixgbe.h:1.64 Wed Feb 5 07:45:46 2020 +++ src/sys/dev/pci/ixgbe/ixgbe.h Thu Feb 6 06:28:49 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.h,v 1.64 2020/02/05 07:45:46 msaitoh Exp $ */ +/* $NetBSD: ixgbe.h,v 1.65 2020/02/06 06:28:49 thorpej Exp $ */ /** SPDX-License-Identifier: BSD-3-Clause @@ -515,6 +515,7 @@ struct adapter { void *mod_si; /* SFP tasklet */ struct workqueue *msf_wq; /* Multispeed Fiber */ struct work msf_wc; + bool msf_pending; void *mbx_si; /* VF -> PF mailbox interrupt */ /* Flow Director */
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Wed Feb 5 10:07:47 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe: ixv.c Log Message: Modify note in ixv_update_stats(). VF doesn't count errors by hardware. To generate a diff of this commit: cvs rdiff -u -r1.145 -r1.146 src/sys/dev/pci/ixgbe/ixv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ixv.c diff -u src/sys/dev/pci/ixgbe/ixv.c:1.145 src/sys/dev/pci/ixgbe/ixv.c:1.146 --- src/sys/dev/pci/ixgbe/ixv.c:1.145 Tue Feb 4 05:44:15 2020 +++ src/sys/dev/pci/ixgbe/ixv.c Wed Feb 5 10:07:47 2020 @@ -1,4 +1,4 @@ -/*$NetBSD: ixv.c,v 1.145 2020/02/04 05:44:15 thorpej Exp $*/ +/*$NetBSD: ixv.c,v 1.146 2020/02/05 10:07:47 msaitoh Exp $*/ /** @@ -2401,12 +2401,8 @@ ixv_update_stats(struct adapter *adapter stats->vfgotc); UPDATE_STAT_32(IXGBE_VFMPRC, stats->last_vfmprc, stats->vfmprc); - /* Fill out the OS statistics structure */ - /* - * NetBSD: Don't override if_{i|o}{packets|bytes|mcasts} with - * adapter->stats counters. It's required to make ifconfig -z - * (SOICZIFDATA) work. - */ + /* VF doesn't count errors by hardware */ + } /* ixv_update_stats */ /
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Wed Feb 5 09:47:16 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe: ixgbe_vf.c ixgbe_x550.c Log Message: No functional change: - Fix typos. - Remove extra newline. To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/sys/dev/pci/ixgbe/ixgbe_vf.c cvs rdiff -u -r1.17 -r1.18 src/sys/dev/pci/ixgbe/ixgbe_x550.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ixgbe_vf.c diff -u src/sys/dev/pci/ixgbe/ixgbe_vf.c:1.22 src/sys/dev/pci/ixgbe/ixgbe_vf.c:1.23 --- src/sys/dev/pci/ixgbe/ixgbe_vf.c:1.22 Fri Sep 20 09:28:37 2019 +++ src/sys/dev/pci/ixgbe/ixgbe_vf.c Wed Feb 5 09:47:16 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe_vf.c,v 1.22 2019/09/20 09:28:37 msaitoh Exp $ */ +/* $NetBSD: ixgbe_vf.c,v 1.23 2020/02/05 09:47:16 msaitoh Exp $ */ /** SPDX-License-Identifier: BSD-3-Clause @@ -475,7 +475,7 @@ s32 ixgbevf_update_xcast_mode(struct ixg * On linux's PF driver implementation, the PF replies VF's * XCAST_MODE_ALLMULTI message not with NACK but with ACK even if the * virtual function is NOT marked "trust" and act as - * XCAST_MODE_"MULTI". If ixv(4) simply check the return vaule of + * XCAST_MODE_"MULTI". If ixv(4) simply check the return value of * update_xcast_mode(XCAST_MODE_ALLMULTI), SIOCSADDMULTI success and * the user may have trouble with some addresses. Fortunately, the * Linux's PF driver's "ACK" message has not XCAST_MODE_"ALL"MULTI but Index: src/sys/dev/pci/ixgbe/ixgbe_x550.c diff -u src/sys/dev/pci/ixgbe/ixgbe_x550.c:1.17 src/sys/dev/pci/ixgbe/ixgbe_x550.c:1.18 --- src/sys/dev/pci/ixgbe/ixgbe_x550.c:1.17 Mon Dec 23 09:36:18 2019 +++ src/sys/dev/pci/ixgbe/ixgbe_x550.c Wed Feb 5 09:47:16 2020 @@ -2895,7 +2895,7 @@ static s32 ixgbe_setup_sfi_x550a(struct * @speed: new link speed * @autoneg_wait_to_complete: unused * - * Configure the the integrated PHY for SFP support. + * Configure the integrated PHY for SFP support. **/ static s32 ixgbe_setup_mac_link_sfp_x550a(struct ixgbe_hw *hw, ixgbe_link_speed speed, @@ -4843,4 +4843,3 @@ bool ixgbe_fw_recovery_mode_X550(struct return !!(fwsm & IXGBE_FWSM_FW_NVM_RECOVERY_MODE); } -
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Wed Feb 5 07:45:46 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe: ix_txrx.c ixgbe.c ixgbe.h ixgbe_common.c Log Message: No functional change: - Add debug printf()s. - Remove unused macros. - Remove extra newline. To generate a diff of this commit: cvs rdiff -u -r1.61 -r1.62 src/sys/dev/pci/ixgbe/ix_txrx.c cvs rdiff -u -r1.224 -r1.225 src/sys/dev/pci/ixgbe/ixgbe.c cvs rdiff -u -r1.63 -r1.64 src/sys/dev/pci/ixgbe/ixgbe.h cvs rdiff -u -r1.26 -r1.27 src/sys/dev/pci/ixgbe/ixgbe_common.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ix_txrx.c diff -u src/sys/dev/pci/ixgbe/ix_txrx.c:1.61 src/sys/dev/pci/ixgbe/ix_txrx.c:1.62 --- src/sys/dev/pci/ixgbe/ix_txrx.c:1.61 Thu Jan 30 14:02:14 2020 +++ src/sys/dev/pci/ixgbe/ix_txrx.c Wed Feb 5 07:45:46 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ix_txrx.c,v 1.61 2020/01/30 14:02:14 thorpej Exp $ */ +/* $NetBSD: ix_txrx.c,v 1.62 2020/02/05 07:45:46 msaitoh Exp $ */ /** @@ -1556,7 +1556,6 @@ ixgbe_setup_receive_ring(struct rx_ring rxbuf->addr = htole64(rxbuf->pmap->dm_segs[0].ds_addr); } - /* Setup our descriptor indices */ rxr->next_to_check = 0; rxr->next_to_refresh = 0; @@ -1612,6 +1611,7 @@ ixgbe_setup_receive_structures(struct ad struct rx_ring *rxr = adapter->rx_rings; intj; + INIT_DEBUGOUT("ixgbe_setup_receive_structures"); for (j = 0; j < adapter->num_queues; j++, rxr++) if (ixgbe_setup_receive_ring(rxr)) goto fail; Index: src/sys/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.224 src/sys/dev/pci/ixgbe/ixgbe.c:1.225 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.224 Wed Feb 5 01:44:53 2020 +++ src/sys/dev/pci/ixgbe/ixgbe.c Wed Feb 5 07:45:46 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.224 2020/02/05 01:44:53 msaitoh Exp $ */ +/* $NetBSD: ixgbe.c,v 1.225 2020/02/05 07:45:46 msaitoh Exp $ */ /** @@ -677,6 +677,8 @@ ixgbe_initialize_transmit_units(struct a struct ixgbe_hw *hw = >hw; int i; + INIT_DEBUGOUT("ixgbe_initialize_transmit_units"); + /* Setup the Base and Length of the Tx Descriptor Ring */ for (i = 0; i < adapter->num_queues; i++, txr++) { u64 tdba = txr->txdma.dma_paddr; Index: src/sys/dev/pci/ixgbe/ixgbe.h diff -u src/sys/dev/pci/ixgbe/ixgbe.h:1.63 src/sys/dev/pci/ixgbe/ixgbe.h:1.64 --- src/sys/dev/pci/ixgbe/ixgbe.h:1.63 Tue Feb 4 19:42:55 2020 +++ src/sys/dev/pci/ixgbe/ixgbe.h Wed Feb 5 07:45:46 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.h,v 1.63 2020/02/04 19:42:55 thorpej Exp $ */ +/* $NetBSD: ixgbe.h,v 1.64 2020/02/05 07:45:46 msaitoh Exp $ */ /** SPDX-License-Identifier: BSD-3-Clause @@ -646,29 +646,6 @@ struct adapter { #define IXGBE_CORE_LOCK_ASSERT(_sc) KASSERT(mutex_owned(&(_sc)->core_mtx)) #define IXGBE_TX_LOCK_ASSERT(_sc) KASSERT(mutex_owned(&(_sc)->tx_mtx)) -/* Stats macros */ -#if __FreeBSD_version >= 1100036 -#define IXGBE_SET_IERRORS(sc, count) (sc)->ierrors = (count) -#define IXGBE_SET_OPACKETS(sc, count)(sc)->opackets = (count) -#define IXGBE_SET_OERRORS(sc, count) (sc)->oerrors = (count) -#define IXGBE_SET_COLLISIONS(sc, count) -#define IXGBE_SET_IBYTES(sc, count) (sc)->ibytes = (count) -#define IXGBE_SET_OBYTES(sc, count) (sc)->obytes = (count) -#define IXGBE_SET_IMCASTS(sc, count) (sc)->imcasts = (count) -#define IXGBE_SET_OMCASTS(sc, count) (sc)->omcasts = (count) -#define IXGBE_SET_IQDROPS(sc, count) (sc)->iqdrops = (count) -#else -#define IXGBE_SET_IERRORS(sc, count) (sc)->ifp->if_ierrors = (count) -#define IXGBE_SET_OPACKETS(sc, count)(sc)->ifp->if_opackets = (count) -#define IXGBE_SET_OERRORS(sc, count) (sc)->ifp->if_oerrors = (count) -#define IXGBE_SET_COLLISIONS(sc, count) (sc)->ifp->if_collisions = (count) -#define IXGBE_SET_IBYTES(sc, count) (sc)->ifp->if_ibytes = (count) -#define IXGBE_SET_OBYTES(sc, count) (sc)->ifp->if_obytes = (count) -#define IXGBE_SET_IMCASTS(sc, count) (sc)->ifp->if_imcasts = (count) -#define IXGBE_SET_OMCASTS(sc, count) (sc)->ifp->if_omcasts = (count) -#define IXGBE_SET_IQDROPS(sc, count) (sc)->ifp->if_iqdrops = (count) -#endif - /* External PHY register addresses */ #define IXGBE_PHY_CURRENT_TEMP 0xC820 #define IXGBE_PHY_OVERTEMP_STATUS 0xC830 Index: src/sys/dev/pci/ixgbe/ixgbe_common.c diff -u src/sys/dev/pci/ixgbe/ixgbe_common.c:1.26 src/sys/dev/pci/ixgbe/ixgbe_common.c:1.27 --- src/sys/dev/pci/ixgbe/ixgbe_common.c:1.26 Mon Dec 16 02:50:54 2019 +++ src/sys/dev/pci/ixgbe/ixgbe_common.c Wed Feb 5 07:45:46 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe_common.c,v 1.26 2019/12/16 02:50:54 msaitoh Exp $ */ +/* $NetBSD: ixgbe_common.c,v 1.27
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Wed Feb 5 01:44:53 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe: ixgbe.c Log Message: Update comment in ixgbe_update_stats_counters() to clarify why we update if_iqdrops and if_ierrors only. No functional change. OK'd by knakahara and thorpej. To generate a diff of this commit: cvs rdiff -u -r1.223 -r1.224 src/sys/dev/pci/ixgbe/ixgbe.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.223 src/sys/dev/pci/ixgbe/ixgbe.c:1.224 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.223 Tue Feb 4 19:42:55 2020 +++ src/sys/dev/pci/ixgbe/ixgbe.c Wed Feb 5 01:44:53 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.223 2020/02/04 19:42:55 thorpej Exp $ */ +/* $NetBSD: ixgbe.c,v 1.224 2020/02/05 01:44:53 msaitoh Exp $ */ /** @@ -1708,15 +1708,11 @@ ixgbe_update_stats_counters(struct adapt stats->fcoedwtc.ev_count += IXGBE_READ_REG(hw, IXGBE_FCOEDWTC); } - /* Fill out the OS statistics structure */ /* - * NetBSD: Don't override if_{i|o}{packets|bytes|mcasts} with - * adapter->stats counters. It's required to make ifconfig -z - * (SOICZIFDATA) work. + * Fill out the OS statistics structure. Only RX errors are required + * here because all TX counters are incremented in the TX path and + * normal RX counters are prepared in ether_input(). */ - /* XXX Actually, just fill in the per-cpu stats, please !!! */ - - /* Rx Errors */ net_stat_ref_t nsr = IF_STAT_GETREF(ifp); if_statadd_ref(nsr, if_iqdrops, total_missed_rx); if_statadd_ref(nsr, if_ierrors, crcerrs + rlec);
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: thorpej Date: Tue Feb 4 19:42:56 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe: ixgbe.c ixgbe.h Log Message: - Fix locking problem with optics module interrupts: ifmedia_add() may block on memory allocation, and so it cannot be safely done from a softint nor can it be done while holding a spin lock. Fix this by using a workqueue rather than a softint, and hold the IFNET_LOCK across the entire handler, and the CORE_LOCK only across the code that needs to serialize access to the hardware state. - Use ifmedia_fini(). Tested in a variety of devices by msaitoh@. (Thanks!) To generate a diff of this commit: cvs rdiff -u -r1.222 -r1.223 src/sys/dev/pci/ixgbe/ixgbe.c cvs rdiff -u -r1.62 -r1.63 src/sys/dev/pci/ixgbe/ixgbe.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.222 src/sys/dev/pci/ixgbe/ixgbe.c:1.223 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.222 Sat Feb 1 12:55:22 2020 +++ src/sys/dev/pci/ixgbe/ixgbe.c Tue Feb 4 19:42:55 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.222 2020/02/01 12:55:22 thorpej Exp $ */ +/* $NetBSD: ixgbe.c,v 1.223 2020/02/04 19:42:55 thorpej Exp $ */ /** @@ -267,10 +267,11 @@ static int ixgbe_msix_link(void *); /* Software interrupts for deferred work */ static void ixgbe_handle_que(void *); static void ixgbe_handle_link(void *); -static void ixgbe_handle_msf(void *); static void ixgbe_handle_mod(void *); static void ixgbe_handle_phy(void *); +static void ixgbe_handle_msf(struct work *, void *); + /* Workqueue handler for deferred work */ static void ixgbe_handle_que_work(struct work *, void *); @@ -410,10 +411,12 @@ static int (*ixgbe_ring_empty)(struct if #define IXGBE_CALLOUT_FLAGS CALLOUT_MPSAFE #define IXGBE_SOFTINFT_FLAGS SOFTINT_MPSAFE #define IXGBE_WORKQUEUE_FLAGS WQ_PERCPU | WQ_MPSAFE +#define IXGBE_TASKLET_WQ_FLAGS WQ_MPSAFE #else #define IXGBE_CALLOUT_FLAGS 0 #define IXGBE_SOFTINFT_FLAGS 0 #define IXGBE_WORKQUEUE_FLAGS WQ_PERCPU +#define IXGBE_TASKLET_WQ_FLAGS 0 #endif #define IXGBE_WORKQUEUE_PRI PRI_SOFTNET @@ -1099,8 +1102,6 @@ ixgbe_attach(device_t parent, device_t d ixgbe_handle_link, adapter); adapter->mod_si = softint_establish(SOFTINT_NET | IXGBE_SOFTINFT_FLAGS, ixgbe_handle_mod, adapter); - adapter->msf_si = softint_establish(SOFTINT_NET | IXGBE_SOFTINFT_FLAGS, - ixgbe_handle_msf, adapter); adapter->phy_si = softint_establish(SOFTINT_NET | IXGBE_SOFTINFT_FLAGS, ixgbe_handle_phy, adapter); if (adapter->feat_en & IXGBE_FEATURE_FDIR) @@ -1108,13 +1109,23 @@ ixgbe_attach(device_t parent, device_t d softint_establish(SOFTINT_NET | IXGBE_SOFTINFT_FLAGS, ixgbe_reinit_fdir, adapter); if ((adapter->link_si == NULL) || (adapter->mod_si == NULL) - || (adapter->msf_si == NULL) || (adapter->phy_si == NULL) + || (adapter->phy_si == NULL) || ((adapter->feat_en & IXGBE_FEATURE_FDIR) && (adapter->fdir_si == NULL))) { aprint_error_dev(dev, "could not establish software interrupts ()\n"); goto err_out; } + char wqname[MAXCOMLEN]; + snprintf(wqname, sizeof(wqname), "%s-msf", device_xname(dev)); + error = workqueue_create(>msf_wq, wqname, + ixgbe_handle_msf, adapter, IXGBE_WORKQUEUE_PRI, IPL_NET, + IXGBE_TASKLET_WQ_FLAGS); + if (error) { + aprint_error_dev(dev, + "could not create MSF workqueue (%d)\n", error); + goto err_out; + } error = ixgbe_start_hw(hw); switch (error) { @@ -1510,7 +1521,9 @@ ixgbe_config_link(struct adapter *adapte if (hw->phy.multispeed_fiber) { ixgbe_enable_tx_laser(hw); kpreempt_disable(); - softint_schedule(adapter->msf_si); + if (adapter->schedule_wqs_ok) +workqueue_enqueue(adapter->msf_wq, +>msf_wc, NULL); kpreempt_enable(); } kpreempt_disable(); @@ -3088,7 +3101,9 @@ ixgbe_msix_link(void *arg) (eicr & IXGBE_EICR_GPI_SDP1_BY_MAC(hw))) { IXGBE_WRITE_REG(hw, IXGBE_EICR, IXGBE_EICR_GPI_SDP1_BY_MAC(hw)); - softint_schedule(adapter->msf_si); + if (adapter->schedule_wqs_ok) +workqueue_enqueue(adapter->msf_wq, +>msf_wc, NULL); } } @@ -3500,9 +3515,9 @@ ixgbe_free_softint(struct adapter *adapt softint_disestablish(adapter->mod_si); adapter->mod_si = NULL; } - if (adapter->msf_si != NULL) { - softint_disestablish(adapter->msf_si); - adapter->msf_si = NULL; + if (adapter->msf_wq != NULL) { + workqueue_destroy(adapter->msf_wq); + adapter->msf_wq = NULL; } if (adapter->phy_si != NULL) { softint_disestablish(adapter->phy_si); @@ -3593,6 +3608,7 @@ ixgbe_detach(device_t dev, int flags) bus_generic_detach(dev); #endif if_detach(adapter->ifp); + ifmedia_fini(>media); if_percpuq_destroy(adapter->ipq); sysctl_teardown(>sysctllog); @@ -4129,6 +4145,9 @@
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: thorpej Date: Sat Feb 1 12:55:23 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe: ixgbe.c Log Message: Adopt . XXX This driver needs some work in this regard (practually no stats are reported). To generate a diff of this commit: cvs rdiff -u -r1.221 -r1.222 src/sys/dev/pci/ixgbe/ixgbe.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.221 src/sys/dev/pci/ixgbe/ixgbe.c:1.222 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.221 Tue Jan 21 14:55:55 2020 +++ src/sys/dev/pci/ixgbe/ixgbe.c Sat Feb 1 12:55:22 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.221 2020/01/21 14:55:55 msaitoh Exp $ */ +/* $NetBSD: ixgbe.c,v 1.222 2020/02/01 12:55:22 thorpej Exp $ */ /** @@ -1701,11 +1701,13 @@ ixgbe_update_stats_counters(struct adapt * adapter->stats counters. It's required to make ifconfig -z * (SOICZIFDATA) work. */ - ifp->if_collisions = 0; + /* XXX Actually, just fill in the per-cpu stats, please !!! */ /* Rx Errors */ - ifp->if_iqdrops += total_missed_rx; - ifp->if_ierrors += crcerrs + rlec; + net_stat_ref_t nsr = IF_STAT_GETREF(ifp); + if_statadd_ref(nsr, if_iqdrops, total_missed_rx); + if_statadd_ref(nsr, if_ierrors, crcerrs + rlec); + IF_STAT_PUTREF(ifp); } /* ixgbe_update_stats_counters */ /
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: riastradh Date: Sat Feb 1 02:33:09 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe: ixgbe_netbsd.c Log Message: Use atomic_load_acquire for FreeBSDish atomic_load_acq_uint shim. To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/sys/dev/pci/ixgbe/ixgbe_netbsd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ixgbe_netbsd.c diff -u src/sys/dev/pci/ixgbe/ixgbe_netbsd.c:1.12 src/sys/dev/pci/ixgbe/ixgbe_netbsd.c:1.13 --- src/sys/dev/pci/ixgbe/ixgbe_netbsd.c:1.12 Tue Jan 21 14:55:55 2020 +++ src/sys/dev/pci/ixgbe/ixgbe_netbsd.c Sat Feb 1 02:33:08 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe_netbsd.c,v 1.12 2020/01/21 14:55:55 msaitoh Exp $ */ +/* $NetBSD: ixgbe_netbsd.c,v 1.13 2020/02/01 02:33:08 riastradh Exp $ */ /* * Copyright (c) 2011 The NetBSD Foundation, Inc. * All rights reserved. @@ -303,15 +303,5 @@ ixgbe_pci_enable_busmaster(pci_chipset_t u_int atomic_load_acq_uint(volatile u_int *p) { - u_int rv; - - rv = *p; - /* - * XXX - * membar_sync() is far more than we need on most CPUs; - * we just don't have an MI load-acqure operation. - */ - membar_sync(); - - return rv; + return atomic_load_acquire(p); }
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Tue Jan 21 14:55:55 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe: ix_txrx.c ixgbe.c ixgbe.h ixgbe_netbsd.c ixv.c Log Message: Fix the freeing code for some error paths. Found and tested by Patrick Welche. To generate a diff of this commit: cvs rdiff -u -r1.59 -r1.60 src/sys/dev/pci/ixgbe/ix_txrx.c cvs rdiff -u -r1.220 -r1.221 src/sys/dev/pci/ixgbe/ixgbe.c cvs rdiff -u -r1.61 -r1.62 src/sys/dev/pci/ixgbe/ixgbe.h cvs rdiff -u -r1.11 -r1.12 src/sys/dev/pci/ixgbe/ixgbe_netbsd.c cvs rdiff -u -r1.143 -r1.144 src/sys/dev/pci/ixgbe/ixv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ix_txrx.c diff -u src/sys/dev/pci/ixgbe/ix_txrx.c:1.59 src/sys/dev/pci/ixgbe/ix_txrx.c:1.60 --- src/sys/dev/pci/ixgbe/ix_txrx.c:1.59 Mon Jan 20 07:19:04 2020 +++ src/sys/dev/pci/ixgbe/ix_txrx.c Tue Jan 21 14:55:55 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ix_txrx.c,v 1.59 2020/01/20 07:19:04 msaitoh Exp $ */ +/* $NetBSD: ix_txrx.c,v 1.60 2020/01/21 14:55:55 msaitoh Exp $ */ /** @@ -2353,3 +2353,24 @@ err_tx_desc: free(adapter->queues, M_DEVBUF); return (error); } /* ixgbe_allocate_queues */ + +/ + * ixgbe_free_queues + * + * Free descriptors for the transmit and receive rings, and then + * the memory associated with each. + / +void +ixgbe_free_queues(struct adapter *adapter) +{ + struct ix_queue *que; + int i; + + ixgbe_free_transmit_structures(adapter); + ixgbe_free_receive_structures(adapter); + for (i = 0; i < adapter->num_queues; i++) { + que = >queues[i]; + mutex_destroy(>dc_mtx); + } + free(adapter->queues, M_DEVBUF); +} /* ixgbe_free_queues */ Index: src/sys/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.220 src/sys/dev/pci/ixgbe/ixgbe.c:1.221 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.220 Fri Jan 3 12:59:46 2020 +++ src/sys/dev/pci/ixgbe/ixgbe.c Tue Jan 21 14:55:55 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.220 2020/01/03 12:59:46 pgoyette Exp $ */ +/* $NetBSD: ixgbe.c,v 1.221 2020/01/21 14:55:55 msaitoh Exp $ */ /** @@ -1059,9 +1059,7 @@ ixgbe_attach(device_t parent, device_t d error = ixgbe_allocate_msix(adapter, pa); if (error) { /* Free allocated queue structures first */ - ixgbe_free_transmit_structures(adapter); - ixgbe_free_receive_structures(adapter); - free(adapter->queues, M_DEVBUF); + ixgbe_free_queues(adapter); /* Fallback to legacy interrupt */ adapter->feat_en &= ~IXGBE_FEATURE_MSIX; @@ -1236,9 +1234,7 @@ ixgbe_attach(device_t parent, device_t d return; err_late: - ixgbe_free_transmit_structures(adapter); - ixgbe_free_receive_structures(adapter); - free(adapter->queues, M_DEVBUF); + ixgbe_free_queues(adapter); err_out: ctrl_ext = IXGBE_READ_REG(>hw, IXGBE_CTRL_EXT); ctrl_ext &= ~IXGBE_CTRL_EXT_DRV_LOAD; @@ -3712,13 +3708,7 @@ ixgbe_detach(device_t dev, int flags) evcnt_detach(>ptc1023); evcnt_detach(>ptc1522); - ixgbe_free_transmit_structures(adapter); - ixgbe_free_receive_structures(adapter); - for (i = 0; i < adapter->num_queues; i++) { - struct ix_queue * que = >queues[i]; - mutex_destroy(>dc_mtx); - } - free(adapter->queues, M_DEVBUF); + ixgbe_free_queues(adapter); free(adapter->mta, M_DEVBUF); IXGBE_CORE_LOCK_DESTROY(adapter); Index: src/sys/dev/pci/ixgbe/ixgbe.h diff -u src/sys/dev/pci/ixgbe/ixgbe.h:1.61 src/sys/dev/pci/ixgbe/ixgbe.h:1.62 --- src/sys/dev/pci/ixgbe/ixgbe.h:1.61 Mon Jan 20 07:19:04 2020 +++ src/sys/dev/pci/ixgbe/ixgbe.h Tue Jan 21 14:55:55 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.h,v 1.61 2020/01/20 07:19:04 msaitoh Exp $ */ +/* $NetBSD: ixgbe.h,v 1.62 2020/01/21 14:55:55 msaitoh Exp $ */ /** SPDX-License-Identifier: BSD-3-Clause @@ -768,6 +768,7 @@ void ixgbe_deferred_mq_start_work(struct void ixgbe_drain_all(struct adapter *); int ixgbe_allocate_queues(struct adapter *); +void ixgbe_free_queues(struct adapter *); int ixgbe_setup_transmit_structures(struct adapter *); void ixgbe_free_transmit_structures(struct adapter *); int ixgbe_setup_receive_structures(struct adapter *); Index: src/sys/dev/pci/ixgbe/ixgbe_netbsd.c diff -u src/sys/dev/pci/ixgbe/ixgbe_netbsd.c:1.11 src/sys/dev/pci/ixgbe/ixgbe_netbsd.c:1.12 --- src/sys/dev/pci/ixgbe/ixgbe_netbsd.c:1.11 Mon Jan 20 07:19:04 2020 +++ src/sys/dev/pci/ixgbe/ixgbe_netbsd.c Tue Jan 21 14:55:55 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe_netbsd.c,v 1.11 2020/01/20 07:19:04 msaitoh Exp $ */ +/* $NetBSD: ixgbe_netbsd.c,v 1.12 2020/01/21 14:55:55 msaitoh Exp $ */ /* * Copyright (c) 2011 The NetBSD Foundation,
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Mon Jan 20 07:19:04 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe: ix_txrx.c ixgbe.h ixgbe_netbsd.c Log Message: Free jumbo mem structure correctly. Found by yamaguchi@ using with LOCKDEBUG. To generate a diff of this commit: cvs rdiff -u -r1.58 -r1.59 src/sys/dev/pci/ixgbe/ix_txrx.c cvs rdiff -u -r1.60 -r1.61 src/sys/dev/pci/ixgbe/ixgbe.h cvs rdiff -u -r1.10 -r1.11 src/sys/dev/pci/ixgbe/ixgbe_netbsd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ix_txrx.c diff -u src/sys/dev/pci/ixgbe/ix_txrx.c:1.58 src/sys/dev/pci/ixgbe/ix_txrx.c:1.59 --- src/sys/dev/pci/ixgbe/ix_txrx.c:1.58 Mon Dec 16 02:50:54 2019 +++ src/sys/dev/pci/ixgbe/ix_txrx.c Mon Jan 20 07:19:04 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ix_txrx.c,v 1.58 2019/12/16 02:50:54 msaitoh Exp $ */ +/* $NetBSD: ix_txrx.c,v 1.59 2020/01/20 07:19:04 msaitoh Exp $ */ /** @@ -1681,6 +1681,10 @@ ixgbe_free_receive_buffers(struct rx_rin rxbuf->pmap = NULL; } } + + /* NetBSD specific. See ixgbe_netbsd.c */ + ixgbe_jcl_destroy(adapter, rxr); + if (rxr->rx_buffers != NULL) { free(rxr->rx_buffers, M_DEVBUF); rxr->rx_buffers = NULL; Index: src/sys/dev/pci/ixgbe/ixgbe.h diff -u src/sys/dev/pci/ixgbe/ixgbe.h:1.60 src/sys/dev/pci/ixgbe/ixgbe.h:1.61 --- src/sys/dev/pci/ixgbe/ixgbe.h:1.60 Mon Dec 16 02:50:54 2019 +++ src/sys/dev/pci/ixgbe/ixgbe.h Mon Jan 20 07:19:04 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.h,v 1.60 2019/12/16 02:50:54 msaitoh Exp $ */ +/* $NetBSD: ixgbe.h,v 1.61 2020/01/20 07:19:04 msaitoh Exp $ */ /** SPDX-License-Identifier: BSD-3-Clause @@ -780,6 +780,7 @@ const struct sysctlnode *ixgbe_sysctl_in /* For NetBSD */ void ixgbe_jcl_reinit(struct adapter *, bus_dma_tag_t, struct rx_ring *, int, size_t); +void ixgbe_jcl_destroy(struct adapter *, struct rx_ring *); #include "ixgbe_bypass.h" #include "ixgbe_fdir.h" Index: src/sys/dev/pci/ixgbe/ixgbe_netbsd.c diff -u src/sys/dev/pci/ixgbe/ixgbe_netbsd.c:1.10 src/sys/dev/pci/ixgbe/ixgbe_netbsd.c:1.11 --- src/sys/dev/pci/ixgbe/ixgbe_netbsd.c:1.10 Wed Sep 4 07:29:34 2019 +++ src/sys/dev/pci/ixgbe/ixgbe_netbsd.c Mon Jan 20 07:19:04 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe_netbsd.c,v 1.10 2019/09/04 07:29:34 msaitoh Exp $ */ +/* $NetBSD: ixgbe_netbsd.c,v 1.11 2020/01/20 07:19:04 msaitoh Exp $ */ /* * Copyright (c) 2011 The NetBSD Foundation, Inc. * All rights reserved. @@ -161,6 +161,22 @@ post_zalloc_err: return NULL; } +static void +ixgbe_jcl_freeall(struct adapter *adapter, struct rx_ring *rxr) +{ + ixgbe_extmem_head_t *eh = >jcl_head; + ixgbe_extmem_t *em; + bus_dma_tag_t dmat = rxr->ptag->dt_dmat; + + while ((em = ixgbe_getext(eh, 0)) != NULL) { + KASSERT(em->em_vaddr != NULL); + bus_dmamem_unmap(dmat, em->em_vaddr, em->em_size); + bus_dmamem_free(dmat, >em_seg, 1); + memset(em, 0, sizeof(*em)); + kmem_free(em, sizeof(*em)); + } +} + void ixgbe_jcl_reinit(struct adapter *adapter, bus_dma_tag_t dmat, struct rx_ring *rxr, int nbuf, size_t size) @@ -187,13 +203,7 @@ ixgbe_jcl_reinit(struct adapter *adapter return; /* Free all dmamem */ - while ((em = ixgbe_getext(eh, 0)) != NULL) { - KASSERT(em->em_vaddr != NULL); - bus_dmamem_unmap(dmat, em->em_vaddr, em->em_size); - bus_dmamem_free(dmat, >em_seg, 1); - memset(em, 0, sizeof(*em)); - kmem_free(em, sizeof(*em)); - } + ixgbe_jcl_freeall(adapter, rxr); for (i = 0; i < nbuf; i++) { if ((em = ixgbe_newext(eh, dmat, size)) == NULL) { @@ -210,6 +220,21 @@ ixgbe_jcl_reinit(struct adapter *adapter rxr->last_num_rx_desc = adapter->num_rx_desc; } +void +ixgbe_jcl_destroy(struct adapter *adapter, struct rx_ring *rxr) +{ + ixgbe_extmem_head_t *eh = >jcl_head; + + /* Free all dmamem */ + ixgbe_jcl_freeall(adapter, rxr); + + if (eh->eh_initialized) { + mutex_destroy(>eh_mtx); + eh->eh_initialized = false; + } +} + + static void ixgbe_jcl_free(struct mbuf *m, void *buf, size_t size, void *arg) {
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: pgoyette Date: Fri Jan 3 12:59:46 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe: ixgbe.c ixgbe_82598.c ixgbe_api.c Log Message: Fix some typos in comments. >From vezhlys on freenode IRC. To generate a diff of this commit: cvs rdiff -u -r1.219 -r1.220 src/sys/dev/pci/ixgbe/ixgbe.c cvs rdiff -u -r1.13 -r1.14 src/sys/dev/pci/ixgbe/ixgbe_82598.c cvs rdiff -u -r1.23 -r1.24 src/sys/dev/pci/ixgbe/ixgbe_api.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.219 src/sys/dev/pci/ixgbe/ixgbe.c:1.220 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.219 Mon Dec 23 09:36:17 2019 +++ src/sys/dev/pci/ixgbe/ixgbe.c Fri Jan 3 12:59:46 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.219 2019/12/23 09:36:17 msaitoh Exp $ */ +/* $NetBSD: ixgbe.c,v 1.220 2020/01/03 12:59:46 pgoyette Exp $ */ /** @@ -353,7 +353,7 @@ SYSCTL_INT(_hw_ix, OID_AUTO, enable_msix * Number of Queues, can be set to 0, * it then autoconfigures based on the * number of cpus with a max of 8. This - * can be overriden manually here. + * can be overridden manually here. */ static int ixgbe_num_queues = 0; SYSCTL_INT(_hw_ix, OID_AUTO, num_queues, CTLFLAG_RDTUN, _num_queues, 0, Index: src/sys/dev/pci/ixgbe/ixgbe_82598.c diff -u src/sys/dev/pci/ixgbe/ixgbe_82598.c:1.13 src/sys/dev/pci/ixgbe/ixgbe_82598.c:1.14 --- src/sys/dev/pci/ixgbe/ixgbe_82598.c:1.13 Mon Dec 23 09:36:17 2019 +++ src/sys/dev/pci/ixgbe/ixgbe_82598.c Fri Jan 3 12:59:46 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe_82598.c,v 1.13 2019/12/23 09:36:17 msaitoh Exp $ */ +/* $NetBSD: ixgbe_82598.c,v 1.14 2020/01/03 12:59:46 pgoyette Exp $ */ /** SPDX-License-Identifier: BSD-3-Clause @@ -90,7 +90,7 @@ void ixgbe_set_pcie_completion_timeout(s goto out; /* - * if capababilities version is type 1 we can write the + * if capabilities version is type 1 we can write the * timeout of 10ms to 250ms through the GCR register */ if (!(gcr & IXGBE_GCR_CAP_VER2)) { @@ -913,7 +913,7 @@ mac_reset_top: /* * Store the original AUTOC value if it has not been * stored off yet. Otherwise restore the stored original - * AUTOC value since the reset operation sets back to deaults. + * AUTOC value since the reset operation sets back to defaults. */ autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC); if (hw->mac.orig_link_settings_stored == FALSE) { Index: src/sys/dev/pci/ixgbe/ixgbe_api.c diff -u src/sys/dev/pci/ixgbe/ixgbe_api.c:1.23 src/sys/dev/pci/ixgbe/ixgbe_api.c:1.24 --- src/sys/dev/pci/ixgbe/ixgbe_api.c:1.23 Thu Jun 27 05:55:40 2019 +++ src/sys/dev/pci/ixgbe/ixgbe_api.c Fri Jan 3 12:59:46 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe_api.c,v 1.23 2019/06/27 05:55:40 msaitoh Exp $ */ +/* $NetBSD: ixgbe_api.c,v 1.24 2020/01/03 12:59:46 pgoyette Exp $ */ /** SPDX-License-Identifier: BSD-3-Clause @@ -1381,8 +1381,8 @@ s32 ixgbe_bypass_rw(struct ixgbe_hw *hw, * ixgbe_bypass_valid_rd - Verify valid return from bit-bang. * * If we send a write we can't be sure it took until we can read back - * that same register. It can be a problem as some of the feilds may - * for valid reasons change inbetween the time wrote the register and + * that same register. It can be a problem as some of the fields may + * for valid reasons change in-between the time wrote the register and * we read it again to verify. So this function check everything we * can check and then assumes it worked. * @@ -1396,7 +1396,7 @@ bool ixgbe_bypass_valid_rd(struct ixgbe_ } /** - * ixgbe_bypass_set - Set a bypass field in the FW CTRL Regiter. + * ixgbe_bypass_set - Set a bypass field in the FW CTRL Register. * @hw: pointer to hardware structure * @cmd: The control word we are setting. * @event: The event we are setting in the FW. This also happens to
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Mon Dec 23 09:36:18 UTC 2019 Modified Files: src/sys/dev/pci/ixgbe: ixgbe.c ixgbe_82598.c ixgbe_82599.c ixgbe_phy.c ixgbe_type.h ixgbe_x550.c Log Message: Add recovery code for unsupported SFP+. Before this commit: If an unsuppored SFP module is inserted before booting, the driver attach failed and there was no way to recover form it without rebooting or detaching/reattaching drvier (drvctl -d && drvctl -r pciN). After this commit: We can automatically recover any time by replacing it with a supported module. To generate a diff of this commit: cvs rdiff -u -r1.218 -r1.219 src/sys/dev/pci/ixgbe/ixgbe.c cvs rdiff -u -r1.12 -r1.13 src/sys/dev/pci/ixgbe/ixgbe_82598.c cvs rdiff -u -r1.21 -r1.22 src/sys/dev/pci/ixgbe/ixgbe_82599.c cvs rdiff -u -r1.19 -r1.20 src/sys/dev/pci/ixgbe/ixgbe_phy.c cvs rdiff -u -r1.43 -r1.44 src/sys/dev/pci/ixgbe/ixgbe_type.h cvs rdiff -u -r1.16 -r1.17 src/sys/dev/pci/ixgbe/ixgbe_x550.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.218 src/sys/dev/pci/ixgbe/ixgbe.c:1.219 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.218 Mon Dec 23 09:19:40 2019 +++ src/sys/dev/pci/ixgbe/ixgbe.c Mon Dec 23 09:36:17 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.218 2019/12/23 09:19:40 msaitoh Exp $ */ +/* $NetBSD: ixgbe.c,v 1.219 2019/12/23 09:36:17 msaitoh Exp $ */ /** @@ -776,6 +776,7 @@ ixgbe_attach(device_t parent, device_t d pcireg_t id, subid; const ixgbe_vendor_info_t *ent; struct pci_attach_args *pa = aux; + bool unsupported_sfp = false; const char *str; char buf[256]; @@ -954,8 +955,8 @@ ixgbe_attach(device_t parent, device_t d error = IXGBE_SUCCESS; } else if (error == IXGBE_ERR_SFP_NOT_SUPPORTED) { aprint_error_dev(dev, "Unsupported SFP+ module detected!\n"); - error = EIO; - goto err_late; + unsupported_sfp = true; + error = IXGBE_SUCCESS; } else if (error) { aprint_error_dev(dev, "Hardware initialization failed\n"); error = EIO; @@ -1126,13 +1127,6 @@ ixgbe_attach(device_t parent, device_t d "please contact your Intel or hardware representative " "who provided you with this hardware.\n"); break; - case IXGBE_ERR_SFP_NOT_SUPPORTED: - aprint_error_dev(dev, "Unsupported SFP+ Module\n"); - error = EIO; - goto err_late; - case IXGBE_ERR_SFP_NOT_PRESENT: - aprint_error_dev(dev, "No SFP+ Module found\n"); - /* falls thru */ default: break; } @@ -1165,16 +1159,22 @@ ixgbe_attach(device_t parent, device_t d oui, model, rev); } - /* Enable the optics for 82599 SFP+ fiber */ - ixgbe_enable_tx_laser(hw); - /* Enable EEE power saving */ if (adapter->feat_cap & IXGBE_FEATURE_EEE) hw->mac.ops.setup_eee(hw, adapter->feat_en & IXGBE_FEATURE_EEE); /* Enable power to the phy. */ - ixgbe_set_phy_power(hw, TRUE); + if (!unsupported_sfp) { + /* Enable the optics for 82599 SFP+ fiber */ + ixgbe_enable_tx_laser(hw); + + /* + * XXX Currently, ixgbe_set_phy_power() supports only copper + * PHY, so it's not required to test with !unsupported_sfp. + */ + ixgbe_set_phy_power(hw, TRUE); + } /* Initialize statistics */ ixgbe_update_stats_counters(adapter); @@ -3901,6 +3901,7 @@ ixgbe_init_locked(struct adapter *adapte u32 txdctl, mhadd; u32 rxdctl, rxctrl; u32 ctrl_ext; + bool unsupported_sfp = false; int i, j, err; /* XXX check IFF_UP and IFF_RUNNING, power-saving state! */ @@ -3908,6 +3909,7 @@ ixgbe_init_locked(struct adapter *adapte KASSERT(mutex_owned(>core_mtx)); INIT_DEBUGOUT("ixgbe_init_locked: begin"); + hw->need_unsupported_sfp_recovery = false; hw->adapter_stopped = FALSE; ixgbe_stop_adapter(hw); callout_stop(>timer); @@ -4081,12 +4083,14 @@ ixgbe_init_locked(struct adapter *adapte */ if (hw->phy.type == ixgbe_phy_none) { err = hw->phy.ops.identify(hw); - if (err == IXGBE_ERR_SFP_NOT_SUPPORTED) { - device_printf(dev, - "Unsupported SFP+ module type was detected.\n"); - return; - } - } + if (err == IXGBE_ERR_SFP_NOT_SUPPORTED) + unsupported_sfp = true; + } else if (hw->phy.type == ixgbe_phy_sfp_unsupported) + unsupported_sfp = true; + + if (unsupported_sfp) + device_printf(dev, + "Unsupported SFP+ module type was detected.\n"); /* Set moderation on the Link interrupt */ ixgbe_eitr_write(adapter, adapter->vector, IXGBE_LINK_ITR); @@ -4097,10 +4101,12 @@ ixgbe_init_locked(struct adapter *adapte adapter->feat_en & IXGBE_FEATURE_EEE); /* Enable power to the phy. */ - ixgbe_set_phy_power(hw, TRUE); + if (!unsupported_sfp) { + ixgbe_set_phy_power(hw, TRUE); - /* Config/Enable Link */ - ixgbe_config_link(adapter); + /* Config/Enable Link */ + ixgbe_config_link(adapter); + } /* Hardware Packet Buffer &
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Mon Dec 23 09:19:40 UTC 2019 Modified Files: src/sys/dev/pci/ixgbe: ixgbe.c Log Message: Add missing core lock in ixgbe_handle_mod(). To generate a diff of this commit: cvs rdiff -u -r1.217 -r1.218 src/sys/dev/pci/ixgbe/ixgbe.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.217 src/sys/dev/pci/ixgbe/ixgbe.c:1.218 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.217 Tue Dec 17 05:49:01 2019 +++ src/sys/dev/pci/ixgbe/ixgbe.c Mon Dec 23 09:19:40 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.217 2019/12/17 05:49:01 msaitoh Exp $ */ +/* $NetBSD: ixgbe.c,v 1.218 2019/12/23 09:19:40 msaitoh Exp $ */ /** @@ -4608,6 +4608,7 @@ ixgbe_handle_mod(void *context) device_t dev = adapter->dev; u32 err, cage_full = 0; + IXGBE_CORE_LOCK(adapter); ++adapter->mod_sicount.ev_count; if (adapter->hw.need_crosstalk_fix) { switch (hw->mac.type) { @@ -4625,14 +4626,14 @@ ixgbe_handle_mod(void *context) } if (!cage_full) - return; + goto out; } err = hw->phy.ops.identify_sfp(hw); if (err == IXGBE_ERR_SFP_NOT_SUPPORTED) { device_printf(dev, "Unsupported SFP+ module type was detected.\n"); - return; + goto out; } if (hw->mac.type == ixgbe_mac_82598EB) @@ -4643,9 +4644,11 @@ ixgbe_handle_mod(void *context) if (err == IXGBE_ERR_SFP_NOT_SUPPORTED) { device_printf(dev, "Setup failure - unsupported SFP+ module type.\n"); - return; + goto out; } softint_schedule(adapter->msf_si); +out: + IXGBE_CORE_UNLOCK(adapter); } /* ixgbe_handle_mod */
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Tue Dec 17 05:49:01 UTC 2019 Modified Files: src/sys/dev/pci/ixgbe: ixgbe.c ixgbe_osdep.c ixgbe_osdep.h ixv.c Log Message: Use bus_space_barrier() instead of x86 specific *fence instruction. Written by riastradh@. To generate a diff of this commit: cvs rdiff -u -r1.216 -r1.217 src/sys/dev/pci/ixgbe/ixgbe.c cvs rdiff -u -r1.5 -r1.6 src/sys/dev/pci/ixgbe/ixgbe_osdep.c cvs rdiff -u -r1.24 -r1.25 src/sys/dev/pci/ixgbe/ixgbe_osdep.h cvs rdiff -u -r1.142 -r1.143 src/sys/dev/pci/ixgbe/ixv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.216 src/sys/dev/pci/ixgbe/ixgbe.c:1.217 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.216 Mon Nov 18 03:17:51 2019 +++ src/sys/dev/pci/ixgbe/ixgbe.c Tue Dec 17 05:49:01 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.216 2019/11/18 03:17:51 msaitoh Exp $ */ +/* $NetBSD: ixgbe.c,v 1.217 2019/12/17 05:49:01 msaitoh Exp $ */ /** @@ -4016,7 +4016,7 @@ ixgbe_init_locked(struct adapter *adapte else msec_delay(1); } - wmb(); + IXGBE_WRITE_BARRIER(hw); /* * In netmap mode, we must preserve the buffers made Index: src/sys/dev/pci/ixgbe/ixgbe_osdep.c diff -u src/sys/dev/pci/ixgbe/ixgbe_osdep.c:1.5 src/sys/dev/pci/ixgbe/ixgbe_osdep.c:1.6 --- src/sys/dev/pci/ixgbe/ixgbe_osdep.c:1.5 Mon Dec 16 02:50:54 2019 +++ src/sys/dev/pci/ixgbe/ixgbe_osdep.c Tue Dec 17 05:49:01 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe_osdep.c,v 1.5 2019/12/16 02:50:54 msaitoh Exp $ */ +/* $NetBSD: ixgbe_osdep.c,v 1.6 2019/12/17 05:49:01 msaitoh Exp $ */ /** @@ -116,3 +116,12 @@ ixgbe_write_reg_array(struct ixgbe_hw *h ((struct adapter *)hw->back)->osdep.mem_bus_space_handle, reg + (offset << 2), val); } + +inline void +ixgbe_write_barrier(struct ixgbe_hw *hw) +{ + bus_space_barrier(((struct adapter *)hw->back)->osdep.mem_bus_space_tag, + ((struct adapter *)hw->back)->osdep.mem_bus_space_handle, + 0, ((struct adapter *)hw->back)->osdep.mem_size, + BUS_SPACE_BARRIER_WRITE); +} Index: src/sys/dev/pci/ixgbe/ixgbe_osdep.h diff -u src/sys/dev/pci/ixgbe/ixgbe_osdep.h:1.24 src/sys/dev/pci/ixgbe/ixgbe_osdep.h:1.25 --- src/sys/dev/pci/ixgbe/ixgbe_osdep.h:1.24 Mon Dec 16 02:50:54 2019 +++ src/sys/dev/pci/ixgbe/ixgbe_osdep.h Tue Dec 17 05:49:01 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe_osdep.h,v 1.24 2019/12/16 02:50:54 msaitoh Exp $ */ +/* $NetBSD: ixgbe_osdep.h,v 1.25 2019/12/17 05:49:01 msaitoh Exp $ */ /** SPDX-License-Identifier: BSD-3-Clause @@ -157,18 +157,6 @@ typedef uint64_t u64; /* This device driver's max interrupt numbers. */ #define IXG_MAX_NINTR 64 -#if __FreeBSD_version < 80 -#if defined(__i386__) || defined(__amd64__) -#define mb() __asm volatile("mfence" ::: "memory") -#define wmb() __asm volatile("sfence" ::: "memory") -#define rmb() __asm volatile("lfence" ::: "memory") -#else -#define mb() -#define rmb() -#define wmb() -#endif -#endif - #if defined(__i386__) || defined(__amd64__) static __inline void prefetch(void *x) @@ -241,4 +229,8 @@ extern void ixgbe_write_reg_array(struct #define IXGBE_WRITE_REG_ARRAY(a, reg, offset, val) \ ixgbe_write_reg_array(a, reg, offset, val) +extern void ixgbe_write_barrier(struct ixgbe_hw *); +#define IXGBE_WRITE_BARRIER(a) \ +ixgbe_write_barrier(a) + #endif /* _IXGBE_OSDEP_H_ */ Index: src/sys/dev/pci/ixgbe/ixv.c diff -u src/sys/dev/pci/ixgbe/ixv.c:1.142 src/sys/dev/pci/ixgbe/ixv.c:1.143 --- src/sys/dev/pci/ixgbe/ixv.c:1.142 Mon Dec 16 02:50:54 2019 +++ src/sys/dev/pci/ixgbe/ixv.c Tue Dec 17 05:49:01 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: ixv.c,v 1.142 2019/12/16 02:50:54 msaitoh Exp $*/ +/*$NetBSD: ixv.c,v 1.143 2019/12/17 05:49:01 msaitoh Exp $*/ /** @@ -1844,7 +1844,7 @@ ixv_initialize_receive_units(struct adap else break; } - wmb(); + IXGBE_WRITE_BARRIER(hw); /* Setup the Base and Length of the Rx Descriptor Ring */ IXGBE_WRITE_REG(hw, IXGBE_VFRDBAL(j), (rdba & 0xULL)); @@ -1876,7 +1876,7 @@ ixv_initialize_receive_units(struct adap break; msec_delay(1); } - wmb(); + IXGBE_WRITE_BARRIER(hw); /* Set the Tail Pointer */ #ifdef DEV_NETMAP
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Mon Dec 16 02:50:54 UTC 2019 Modified Files: src/sys/dev/pci/ixgbe: if_bypass.c ix_txrx.c ixgbe.h ixgbe_common.c ixgbe_osdep.c ixgbe_osdep.h ixgbe_phy.c ixv.c Log Message: No functional change: - Remove unused code. - Remove extra spaces. - KNF. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/dev/pci/ixgbe/if_bypass.c \ src/sys/dev/pci/ixgbe/ixgbe_osdep.c cvs rdiff -u -r1.57 -r1.58 src/sys/dev/pci/ixgbe/ix_txrx.c cvs rdiff -u -r1.59 -r1.60 src/sys/dev/pci/ixgbe/ixgbe.h cvs rdiff -u -r1.25 -r1.26 src/sys/dev/pci/ixgbe/ixgbe_common.c cvs rdiff -u -r1.23 -r1.24 src/sys/dev/pci/ixgbe/ixgbe_osdep.h cvs rdiff -u -r1.18 -r1.19 src/sys/dev/pci/ixgbe/ixgbe_phy.c cvs rdiff -u -r1.141 -r1.142 src/sys/dev/pci/ixgbe/ixv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/if_bypass.c diff -u src/sys/dev/pci/ixgbe/if_bypass.c:1.4 src/sys/dev/pci/ixgbe/if_bypass.c:1.5 --- src/sys/dev/pci/ixgbe/if_bypass.c:1.4 Wed Apr 4 08:13:07 2018 +++ src/sys/dev/pci/ixgbe/if_bypass.c Mon Dec 16 02:50:54 2019 @@ -101,7 +101,7 @@ ixgbe_get_bypass_time(u32 *year, u32 *se nanotime(); *sec = current.tv_sec; - while(*sec > SEC_THIS_YEAR(*year)) { + while (*sec > SEC_THIS_YEAR(*year)) { *sec -= SEC_THIS_YEAR(*year); (*year)++; } Index: src/sys/dev/pci/ixgbe/ixgbe_osdep.c diff -u src/sys/dev/pci/ixgbe/ixgbe_osdep.c:1.4 src/sys/dev/pci/ixgbe/ixgbe_osdep.c:1.5 --- src/sys/dev/pci/ixgbe/ixgbe_osdep.c:1.4 Wed Apr 4 08:13:07 2018 +++ src/sys/dev/pci/ixgbe/ixgbe_osdep.c Mon Dec 16 02:50:54 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe_osdep.c,v 1.4 2018/04/04 08:13:07 msaitoh Exp $ */ +/* $NetBSD: ixgbe_osdep.c,v 1.5 2019/12/16 02:50:54 msaitoh Exp $ */ /** @@ -56,7 +56,7 @@ ixgbe_read_pci_cfg(struct ixgbe_hw *hw, return __SHIFTOUT(pci_conf_read(pc, tag, reg - 2), __BITS(31, 16)); default: - panic("%s: invalid register (%" PRIx32, __func__, reg); + panic("%s: invalid register (%" PRIx32, __func__, reg); break; } } @@ -79,7 +79,7 @@ ixgbe_write_pci_cfg(struct ixgbe_hw *hw, __SHIFTIN(value, __BITS(31, 16)) | old); break; default: - panic("%s: invalid register (%" PRIx32, __func__, reg); + panic("%s: invalid register (%" PRIx32, __func__, reg); break; } Index: src/sys/dev/pci/ixgbe/ix_txrx.c diff -u src/sys/dev/pci/ixgbe/ix_txrx.c:1.57 src/sys/dev/pci/ixgbe/ix_txrx.c:1.58 --- src/sys/dev/pci/ixgbe/ix_txrx.c:1.57 Sun Nov 10 21:16:36 2019 +++ src/sys/dev/pci/ixgbe/ix_txrx.c Mon Dec 16 02:50:54 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: ix_txrx.c,v 1.57 2019/11/10 21:16:36 chs Exp $ */ +/* $NetBSD: ix_txrx.c,v 1.58 2019/12/16 02:50:54 msaitoh Exp $ */ /** @@ -148,7 +148,7 @@ ixgbe_legacy_start_locked(struct ifnet * return (ENETDOWN); if (txr->txr_no_space) return (ENETDOWN); - + while (!IFQ_IS_EMPTY(>if_snd)) { if (txr->tx_avail <= IXGBE_QUEUE_MIN_FREE) break; Index: src/sys/dev/pci/ixgbe/ixgbe.h diff -u src/sys/dev/pci/ixgbe/ixgbe.h:1.59 src/sys/dev/pci/ixgbe/ixgbe.h:1.60 --- src/sys/dev/pci/ixgbe/ixgbe.h:1.59 Wed Oct 30 07:27:51 2019 +++ src/sys/dev/pci/ixgbe/ixgbe.h Mon Dec 16 02:50:54 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.h,v 1.59 2019/10/30 07:27:51 msaitoh Exp $ */ +/* $NetBSD: ixgbe.h,v 1.60 2019/12/16 02:50:54 msaitoh Exp $ */ /** SPDX-License-Identifier: BSD-3-Clause @@ -134,9 +134,9 @@ * RxDescriptors Valid Range: 64-4096 Default Value: 256 This value is the * number of receive descriptors allocated for each RX queue. Increasing this * value allows the driver to buffer more incoming packets. Each descriptor - * is 16 bytes. A receive buffer is also allocated for each descriptor. - * - * Note: with 8 rings and a dual port card, it is possible to bump up + * is 16 bytes. A receive buffer is also allocated for each descriptor. + * + * Note: with 8 rings and a dual port card, it is possible to bump up * against the system mbuf pool limit, you can tune nmbclusters * to adjust for this. */ Index: src/sys/dev/pci/ixgbe/ixgbe_common.c diff -u src/sys/dev/pci/ixgbe/ixgbe_common.c:1.25 src/sys/dev/pci/ixgbe/ixgbe_common.c:1.26 --- src/sys/dev/pci/ixgbe/ixgbe_common.c:1.25 Thu Jul 25 09:01:56 2019 +++ src/sys/dev/pci/ixgbe/ixgbe_common.c Mon Dec 16 02:50:54 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe_common.c,v 1.25 2019/07/25 09:01:56 msaitoh Exp $ */ +/* $NetBSD: ixgbe_common.c,v 1.26 2019/12/16 02:50:54 msaitoh Exp $ */ /** SPDX-License-Identifier: BSD-3-Clause @@ -5520,7 +5520,7 @@ s32 ixgbe_setup_mac_link_multispeed_fibe goto
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Fri May 10 02:56:08 UTC 2019 Modified Files: src/sys/dev/pci/ixgbe: ixgbe.c Log Message: Fix typo. This code is not used yet. To generate a diff of this commit: cvs rdiff -u -r1.179 -r1.180 src/sys/dev/pci/ixgbe/ixgbe.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.179 src/sys/dev/pci/ixgbe/ixgbe.c:1.180 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.179 Mon Mar 18 11:38:03 2019 +++ src/sys/dev/pci/ixgbe/ixgbe.c Fri May 10 02:56:08 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.179 2019/03/18 11:38:03 msaitoh Exp $ */ +/* $NetBSD: ixgbe.c,v 1.180 2019/05/10 02:56:08 msaitoh Exp $ */ /** @@ -1445,7 +1445,7 @@ ixgbe_add_media_types(struct adapter *ad ADD(IFM_10G_KR | IFM_FDX, 0); } if (layer & IXGBE_PHYSICAL_LAYER_10GBASE_KX4) { - ADD(AIFM_10G_KX4 | IFM_FDX, 0); + ADD(IFM_10G_KX4 | IFM_FDX, 0); } #else if (layer & IXGBE_PHYSICAL_LAYER_10GBASE_KR) {
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Fri Mar 15 02:38:20 UTC 2019 Modified Files: src/sys/dev/pci/ixgbe: ixgbe.c ixv.c Log Message: - Simplily. Suggested by knakahara. - Modify comment. Per queue VLAN enable flags is on 82599 and later. - Fix typo in comment. To generate a diff of this commit: cvs rdiff -u -r1.177 -r1.178 src/sys/dev/pci/ixgbe/ixgbe.c cvs rdiff -u -r1.110 -r1.111 src/sys/dev/pci/ixgbe/ixv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.177 src/sys/dev/pci/ixgbe/ixgbe.c:1.178 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.177 Wed Mar 13 10:02:13 2019 +++ src/sys/dev/pci/ixgbe/ixgbe.c Fri Mar 15 02:38:20 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.177 2019/03/13 10:02:13 msaitoh Exp $ */ +/* $NetBSD: ixgbe.c,v 1.178 2019/03/15 02:38:20 msaitoh Exp $ */ /** @@ -2376,14 +2376,16 @@ ixgbe_setup_vlan_hw_support(struct adapt * on NetBSD. */ - /* Enalble HW tagging only if any vlan is attached */ + /* Enable HW tagging only if any vlan is attached */ hwtagging = (ec->ec_capenable & ETHERCAP_VLAN_HWTAGGING) - && VLAN_ATTACHED(>osdep.ec); + && VLAN_ATTACHED(ec); /* Setup the queues for vlans */ for (i = 0; i < adapter->num_queues; i++) { rxr = >rx_rings[i]; - /* On 82599 the VLAN enable is per/queue in RXDCTL */ + /* + * On 82599 and later, the VLAN enable is per/queue in RXDCTL. + */ if (hw->mac.type != ixgbe_mac_82598EB) { ctrl = IXGBE_READ_REG(hw, IXGBE_RXDCTL(rxr->me)); if (hwtagging) Index: src/sys/dev/pci/ixgbe/ixv.c diff -u src/sys/dev/pci/ixgbe/ixv.c:1.110 src/sys/dev/pci/ixgbe/ixv.c:1.111 --- src/sys/dev/pci/ixgbe/ixv.c:1.110 Wed Mar 13 10:08:02 2019 +++ src/sys/dev/pci/ixgbe/ixv.c Fri Mar 15 02:38:20 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: ixv.c,v 1.110 2019/03/13 10:08:02 msaitoh Exp $*/ +/*$NetBSD: ixv.c,v 1.111 2019/03/15 02:38:20 msaitoh Exp $*/ /** @@ -1979,9 +1979,9 @@ ixv_setup_vlan_support(struct adapter *a * on NetBSD. */ - /* Enalble HW tagging only if any vlan is attached */ + /* Enable HW tagging only if any vlan is attached */ hwtagging = (ec->ec_capenable & ETHERCAP_VLAN_HWTAGGING) - && VLAN_ATTACHED(>osdep.ec); + && VLAN_ATTACHED(ec); /* Enable the queues */ for (int i = 0; i < adapter->num_queues; i++) {