CVS commit: [netbsd-9] src/sys/dev/pci/ixgbe
Module Name:src Committed By: martin Date: Wed Sep 2 12:34:55 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe [netbsd-9]: if_bypass.c ixgbe.c ixgbe_common.c Log Message: Pull up following revision(s) (requested by msaitoh in ticket #1070): sys/dev/pci/ixgbe/if_bypass.c: revision 1.6 sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.28 sys/dev/pci/ixgbe/ixgbe.c: revision 1.246 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. - 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.4.8.1 -r1.4.8.2 src/sys/dev/pci/ixgbe/if_bypass.c cvs rdiff -u -r1.199.2.11 -r1.199.2.12 src/sys/dev/pci/ixgbe/ixgbe.c cvs rdiff -u -r1.25.2.2 -r1.25.2.3 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/if_bypass.c diff -u src/sys/dev/pci/ixgbe/if_bypass.c:1.4.8.1 src/sys/dev/pci/ixgbe/if_bypass.c:1.4.8.2 --- src/sys/dev/pci/ixgbe/if_bypass.c:1.4.8.1 Sun Jan 26 11:03:17 2020 +++ src/sys/dev/pci/ixgbe/if_bypass.c Wed Sep 2 12:34:55 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 */ Index: src/sys/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.199.2.11 src/sys/dev/pci/ixgbe/ixgbe.c:1.199.2.12 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.199.2.11 Fri Jul 10 11:35:51 2020 +++ src/sys/dev/pci/ixgbe/ixgbe.c Wed Sep 2 12:34:55 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.199.2.11 2020/07/10 11:35:51 martin Exp $ */ +/* $NetBSD: ixgbe.c,v 1.199.2.12 2020/09/02 12:34:55 martin Exp $ */ /** @@ -861,7 +861,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.25.2.2 src/sys/dev/pci/ixgbe/ixgbe_common.c:1.25.2.3 --- src/sys/dev/pci/ixgbe/ixgbe_common.c:1.25.2.2 Fri Jul 10 11:35:51 2020 +++ src/sys/dev/pci/ixgbe/ixgbe_common.c Wed Sep 2 12:34:55 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe_common.c,v 1.25.2.2 2020/07/10 11:35:51 martin Exp $ */ +/* $NetBSD: ixgbe_common.c,v 1.25.2.3 2020/09/02 12:34:55 martin Exp $ */ /** SPDX-License-Identifier: BSD-3-Clause @@ -5234,7
CVS commit: [netbsd-9] src/sys/dev/pci/ixgbe
Module Name:src Committed By: martin Date: Fri Jul 10 11:35:51 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe [netbsd-9]: ix_txrx.c ixgbe.c ixgbe.h ixgbe_82598.c ixgbe_common.c ixgbe_netbsd.c ixgbe_osdep.h ixgbe_phy.c ixgbe_vf.c ixgbe_x550.c ixv.c Log Message: Pull up the following revisions, requested by msaitoh in ticket #997: sys/dev/pci/ixgbe/ix_txrx.c 1.62-1.63 via patch sys/dev/pci/ixgbe/ixgbe.c 1.225, 1.228-1.229, 1.232 via patch sys/dev/pci/ixgbe/ixgbe.h 1.64, 1.66 sys/dev/pci/ixgbe/ixv.c 1.146, 1.148-1.150 sys/dev/pci/ixgbe/ixgbe_common.c1.27 sys/dev/pci/ixgbe/ixgbe_vf.c1.23 sys/dev/pci/ixgbe/ixgbe_82598.c 1.15 sys/dev/pci/ixgbe/ixgbe_x550.c 1.18 sys/dev/pci/ixgbe/ixgbe_netbsd.c1.14 sys/dev/pci/ixgbe/ixgbe_phy.c 1.21 sys/dev/pci/ixgbe/ixgbe_osdep.h 1.26 - Fix IXGBE_LE32_TO_CPUS() macro for big endian machine. This problem was only on X550*. - Add debug printf()s. - Use unsigned to avoid undefined behavior in ixgbe_fc_enable_generic(). - Modify a little to reduce diff between ixgbe.c and ixv.c. No functional change. - Modify comment. - Remove unused macros. - Whitespace fix. - Fix typos. To generate a diff of this commit: cvs rdiff -u -r1.54.2.3 -r1.54.2.4 src/sys/dev/pci/ixgbe/ix_txrx.c cvs rdiff -u -r1.199.2.10 -r1.199.2.11 src/sys/dev/pci/ixgbe/ixgbe.c cvs rdiff -u -r1.56.2.2 -r1.56.2.3 src/sys/dev/pci/ixgbe/ixgbe.h cvs rdiff -u -r1.12.8.2 -r1.12.8.3 src/sys/dev/pci/ixgbe/ixgbe_82598.c cvs rdiff -u -r1.25.2.1 -r1.25.2.2 src/sys/dev/pci/ixgbe/ixgbe_common.c cvs rdiff -u -r1.9.4.2 -r1.9.4.3 src/sys/dev/pci/ixgbe/ixgbe_netbsd.c cvs rdiff -u -r1.23.6.2 -r1.23.6.3 src/sys/dev/pci/ixgbe/ixgbe_osdep.h cvs rdiff -u -r1.18.4.2 -r1.18.4.3 src/sys/dev/pci/ixgbe/ixgbe_phy.c cvs rdiff -u -r1.18.2.1 -r1.18.2.2 src/sys/dev/pci/ixgbe/ixgbe_vf.c cvs rdiff -u -r1.15.2.2 -r1.15.2.3 src/sys/dev/pci/ixgbe/ixgbe_x550.c cvs rdiff -u -r1.125.2.9 -r1.125.2.10 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.54.2.3 src/sys/dev/pci/ixgbe/ix_txrx.c:1.54.2.4 --- src/sys/dev/pci/ixgbe/ix_txrx.c:1.54.2.3 Sun Jan 26 11:03:17 2020 +++ src/sys/dev/pci/ixgbe/ix_txrx.c Fri Jul 10 11:35:51 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ix_txrx.c,v 1.54.2.3 2020/01/26 11:03:17 martin Exp $ */ +/* $NetBSD: ix_txrx.c,v 1.54.2.4 2020/07/10 11:35:51 martin Exp $ */ /** @@ -926,7 +926,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)) @@ -1569,7 +1569,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; @@ -1625,6 +1624,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; @@ -2233,7 +2233,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_NOWAIT | M_ZERO); + adapter->num_queues, M_DEVBUF, M_NOWAIT | M_ZERO); if (adapter->queues == NULL) { aprint_error_dev(dev, "Unable to allocate queue memory\n"); error = ENOMEM; @@ -2300,7 +2300,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.199.2.10 src/sys/dev/pci/ixgbe/ixgbe.c:1.199.2.11 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.199.2.10 Tue Jan 28 11:09:27 2020 +++ src/sys/dev/pci/ixgbe/ixgbe.c Fri Jul 10 11:35:51 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.199.2.10 2020/01/28 11:09:27 martin Exp $ */ +/* $NetBSD: ixgbe.c,v 1.199.2.11 2020/07/10 11:35:51 martin Exp $ */
CVS commit: [netbsd-9] src/sys/dev/pci/ixgbe
Module Name:src Committed By: martin Date: Tue Jan 28 11:09:27 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe [netbsd-9]: ixgbe.c ixgbe_82598.c ixgbe_82599.c ixgbe_phy.c ixgbe_type.h ixgbe_x550.c Log Message: Pull up following revision(s) (requested by msaitoh in ticket #664): sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.13 sys/dev/pci/ixgbe/ixgbe.c: revision 1.219 sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.20 sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.17 sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.22 sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.44 Add recovery code for unsupported SFP+. Before this commit: If an unsupported SFP module is inserted before booting, the driver attach failed and there was no way to recover form it without rebooting or detaching/reattaching driver (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.199.2.9 -r1.199.2.10 src/sys/dev/pci/ixgbe/ixgbe.c cvs rdiff -u -r1.12.8.1 -r1.12.8.2 src/sys/dev/pci/ixgbe/ixgbe_82598.c cvs rdiff -u -r1.21 -r1.21.4.1 src/sys/dev/pci/ixgbe/ixgbe_82599.c cvs rdiff -u -r1.18.4.1 -r1.18.4.2 src/sys/dev/pci/ixgbe/ixgbe_phy.c cvs rdiff -u -r1.41.2.1 -r1.41.2.2 src/sys/dev/pci/ixgbe/ixgbe_type.h cvs rdiff -u -r1.15.2.1 -r1.15.2.2 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.199.2.9 src/sys/dev/pci/ixgbe/ixgbe.c:1.199.2.10 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.199.2.9 Sun Jan 26 11:03:17 2020 +++ src/sys/dev/pci/ixgbe/ixgbe.c Tue Jan 28 11:09:27 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.199.2.9 2020/01/26 11:03:17 martin Exp $ */ +/* $NetBSD: ixgbe.c,v 1.199.2.10 2020/01/28 11:09:27 martin 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]; @@ -959,8 +960,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; @@ -1129,13 +1130,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; } @@ -1168,16 +1162,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); @@ -3896,6 +3896,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! */ @@ -3903,6 +3904,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); @@ -4076,12 +4078,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
CVS commit: [netbsd-9] src/sys/dev/pci/ixgbe
Module Name:src Committed By: martin Date: Sun Jan 26 11:03:17 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe [netbsd-9]: if_bypass.c ix_txrx.c ixgbe.c ixgbe.h ixgbe_82598.c ixgbe_api.c ixgbe_common.c ixgbe_netbsd.c ixgbe_osdep.c ixgbe_osdep.h ixgbe_phy.c ixv.c Log Message: Pull up the following (via patch), requested by msaitoh in ticket #648 sys/dev/pci/ixgbe/if_bypass.c 1.5 sys/dev/pci/ixgbe/ixgbe_osdep.c 1.5 sys/dev/pci/ixgbe/ix_txrx.c 1.58-1.60 sys/dev/pci/ixgbe/ixgbe.c 1.220-1.221 sys/dev/pci/ixgbe/ixgbe.h 1.60-1.2 sys/dev/pci/ixgbe/ixgbe_api.c 1.24 sys/dev/pci/ixgbe/ixgbe_common.c1.26 sys/dev/pci/ixgbe/ixgbe_netbsd.c1.11-1.12 sys/dev/pci/ixgbe/ixgbe_osdep.h 1.24 sys/dev/pci/ixgbe/ixgbe_phy.c 1.19 sys/dev/pci/ixgbe/ixgbe_82598.c 1.14 sys/dev/pci/ixgbe/ixv.c 1.142,1.144 - Free RX structure correctly when detaching. - Remove unused code. - Fix some typos in comment. - Remove extra spaces. - KNF. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.4.8.1 src/sys/dev/pci/ixgbe/if_bypass.c cvs rdiff -u -r1.54.2.2 -r1.54.2.3 src/sys/dev/pci/ixgbe/ix_txrx.c cvs rdiff -u -r1.199.2.8 -r1.199.2.9 src/sys/dev/pci/ixgbe/ixgbe.c cvs rdiff -u -r1.56.2.1 -r1.56.2.2 src/sys/dev/pci/ixgbe/ixgbe.h cvs rdiff -u -r1.12 -r1.12.8.1 src/sys/dev/pci/ixgbe/ixgbe_82598.c cvs rdiff -u -r1.23 -r1.23.2.1 src/sys/dev/pci/ixgbe/ixgbe_api.c cvs rdiff -u -r1.25 -r1.25.2.1 src/sys/dev/pci/ixgbe/ixgbe_common.c cvs rdiff -u -r1.9.4.1 -r1.9.4.2 src/sys/dev/pci/ixgbe/ixgbe_netbsd.c cvs rdiff -u -r1.4.8.1 -r1.4.8.2 src/sys/dev/pci/ixgbe/ixgbe_osdep.c cvs rdiff -u -r1.23.6.1 -r1.23.6.2 src/sys/dev/pci/ixgbe/ixgbe_osdep.h cvs rdiff -u -r1.18 -r1.18.4.1 src/sys/dev/pci/ixgbe/ixgbe_phy.c cvs rdiff -u -r1.125.2.8 -r1.125.2.9 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.4.8.1 --- 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 Sun Jan 26 11:03:17 2020 @@ -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/ix_txrx.c diff -u src/sys/dev/pci/ixgbe/ix_txrx.c:1.54.2.2 src/sys/dev/pci/ixgbe/ix_txrx.c:1.54.2.3 --- src/sys/dev/pci/ixgbe/ix_txrx.c:1.54.2.2 Fri Nov 1 09:34:27 2019 +++ src/sys/dev/pci/ixgbe/ix_txrx.c Sun Jan 26 11:03:17 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ix_txrx.c,v 1.54.2.2 2019/11/01 09:34:27 martin Exp $ */ +/* $NetBSD: ix_txrx.c,v 1.54.2.3 2020/01/26 11:03:17 martin 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; @@ -1693,6 +1693,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; @@ -2379,3 +2383,24 @@ tx_fail: fail: 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.199.2.8 src/sys/dev/pci/ixgbe/ixgbe.c:1.199.2.9 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.199.2.8 Tue Dec 24 17:44:22 2019 +++ src/sys/dev/pci/ixgbe/ixgbe.c Sun Jan 26 11:03:17 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.199.2.8 2019/12/24 17:44:22 martin Exp $ */ +/* $NetBSD: ixgbe.c,v 1.199.2.9 2020/01/26 11:03:17 martin 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
CVS commit: [netbsd-9] src/sys/dev/pci/ixgbe
Module Name:src Committed By: martin Date: Tue Dec 24 17:44:22 UTC 2019 Modified Files: src/sys/dev/pci/ixgbe [netbsd-9]: ixgbe.c ixgbe_osdep.c ixgbe_osdep.h ixv.c Log Message: Pull up following revision(s) (requested by msaitoh in ticket #580): sys/dev/pci/ixgbe/ixgbe.c: revision 1.217 sys/dev/pci/ixgbe/ixgbe.c: revision 1.218 sys/dev/pci/ixgbe/ixgbe_osdep.c: revision 1.6 sys/dev/pci/ixgbe/ixv.c: revision 1.143 sys/dev/pci/ixgbe/ixgbe_osdep.h: revision 1.25 Use bus_space_barrier() instead of x86 specific *fence instruction. Written by riastradh@. Add missing core lock in ixgbe_handle_mod(). To generate a diff of this commit: cvs rdiff -u -r1.199.2.7 -r1.199.2.8 src/sys/dev/pci/ixgbe/ixgbe.c cvs rdiff -u -r1.4 -r1.4.8.1 src/sys/dev/pci/ixgbe/ixgbe_osdep.c cvs rdiff -u -r1.23 -r1.23.6.1 src/sys/dev/pci/ixgbe/ixgbe_osdep.h cvs rdiff -u -r1.125.2.7 -r1.125.2.8 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.199.2.7 src/sys/dev/pci/ixgbe/ixgbe.c:1.199.2.8 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.199.2.7 Tue Nov 19 13:17:44 2019 +++ src/sys/dev/pci/ixgbe/ixgbe.c Tue Dec 24 17:44:22 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.199.2.7 2019/11/19 13:17:44 martin Exp $ */ +/* $NetBSD: ixgbe.c,v 1.199.2.8 2019/12/24 17:44:22 martin Exp $ */ /** @@ -4021,7 +4021,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 @@ -4613,6 +4613,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) { @@ -4630,14 +4631,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) @@ -4648,9 +4649,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 */ 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.4.8.1 --- 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 Tue Dec 24 17:44:22 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.4.8.1 2019/12/24 17:44:22 martin 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.23 src/sys/dev/pci/ixgbe/ixgbe_osdep.h:1.23.6.1 --- src/sys/dev/pci/ixgbe/ixgbe_osdep.h:1.23 Tue Jul 31 09:19:34 2018 +++ src/sys/dev/pci/ixgbe/ixgbe_osdep.h Tue Dec 24 17:44:22 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe_osdep.h,v 1.23 2018/07/31 09:19:34 msaitoh Exp $ */ +/* $NetBSD: ixgbe_osdep.h,v 1.23.6.1 2019/12/24 17:44:22 martin 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) \ +