Module Name: src Committed By: msaitoh Date: Fri Dec 2 12:14:37 UTC 2016
Modified Files: src/sys/dev/pci/ixgbe: ix_txrx.c ixgbe.c ixv.c Log Message: Update ixg(4) and ixv(4) up to FreeBSD r294578: - Fixup SFP module insertion on the 82599 when insertion happens after the system is booted and running. Add PHY detection logic to ixgbe_handle_mod() and add locking to ixgbe_handle_msf() as well. FreeBSD r293334. - Fix ix advertise value after media change. When ifconfig sets media then the values displayed by the advertise_speed value are invalidated. Fix this by setting the bits correctly including setting advertise to 0 for media = auto. FreeBSD r294578. - Some others (e.g. LRO(not used by NetBSD)). To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/dev/pci/ixgbe/ix_txrx.c cvs rdiff -u -r1.50 -r1.51 src/sys/dev/pci/ixgbe/ixgbe.c cvs rdiff -u -r1.27 -r1.28 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.8 src/sys/dev/pci/ixgbe/ix_txrx.c:1.9 --- src/sys/dev/pci/ixgbe/ix_txrx.c:1.8 Fri Dec 2 10:42:04 2016 +++ src/sys/dev/pci/ixgbe/ix_txrx.c Fri Dec 2 12:14:37 2016 @@ -58,8 +58,8 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ -/*$FreeBSD: head/sys/dev/ixgbe/ix_txrx.c 292674 2015-12-23 22:45:17Z sbruno $*/ -/*$NetBSD: ix_txrx.c,v 1.8 2016/12/02 10:42:04 msaitoh Exp $*/ +/*$FreeBSD: head/sys/dev/ixgbe/ix_txrx.c 292751 2015-12-26 17:27:48Z bz $*/ +/*$NetBSD: ix_txrx.c,v 1.9 2016/12/02 12:14:37 msaitoh Exp $*/ #include "opt_inet.h" #include "opt_inet6.h" @@ -821,6 +821,7 @@ ixgbe_tx_ctx_setup(struct tx_ring *txr, l3d = mtod(mp, char *) + ehdrlen; switch (etype) { +#ifdef INET case ETHERTYPE_IP: ip = (struct ip *)(l3d); ip_hlen = ip->ip_hl << 2; @@ -829,12 +830,15 @@ ixgbe_tx_ctx_setup(struct tx_ring *txr, KASSERT((mp->m_pkthdr.csum_flags & M_CSUM_IPv4) == 0 || ip->ip_sum == 0); break; +#endif +#ifdef INET6 case ETHERTYPE_IPV6: ip6 = (struct ip6_hdr *)(l3d); ip_hlen = sizeof(struct ip6_hdr); ipproto = ip6->ip6_nxt; type_tucmd_mlhl |= IXGBE_ADVTXD_TUCMD_IPV6; break; +#endif default: break; } Index: src/sys/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.50 src/sys/dev/pci/ixgbe/ixgbe.c:1.51 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.50 Fri Dec 2 11:56:55 2016 +++ src/sys/dev/pci/ixgbe/ixgbe.c Fri Dec 2 12:14:37 2016 @@ -58,8 +58,8 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ -/*$FreeBSD: head/sys/dev/ixgbe/if_ix.c 292674 2015-12-23 22:45:17Z sbruno $*/ -/*$NetBSD: ixgbe.c,v 1.50 2016/12/02 11:56:55 msaitoh Exp $*/ +/*$FreeBSD: head/sys/dev/ixgbe/if_ix.c 294578 2016-01-22 17:03:32Z smh $*/ +/*$NetBSD: ixgbe.c,v 1.51 2016/12/02 12:14:37 msaitoh Exp $*/ #include "opt_inet.h" #include "opt_inet6.h" @@ -2033,10 +2033,16 @@ ixgbe_media_change(struct ifnet * ifp) hw->mac.autotry_restart = TRUE; hw->mac.ops.setup_link(hw, speed, TRUE); - adapter->advertise = - ((speed & IXGBE_LINK_SPEED_10GB_FULL) << 2) | - ((speed & IXGBE_LINK_SPEED_1GB_FULL) << 1) | - ((speed & IXGBE_LINK_SPEED_100_FULL) << 0); + if (IFM_SUBTYPE(ifm->ifm_media) == IFM_AUTO) { + adapter->advertise = 0; + } else { + if ((speed & IXGBE_LINK_SPEED_10GB_FULL) != 0) + adapter->advertise |= 1 << 2; + if ((speed & IXGBE_LINK_SPEED_1GB_FULL) != 0) + adapter->advertise |= 1 << 1; + if ((speed & IXGBE_LINK_SPEED_100_FULL) != 0) + adapter->advertise |= 1 << 0; + } return (0); @@ -3066,18 +3072,8 @@ ixgbe_config_link(struct adapter *adapte sfp = ixgbe_is_sfp(hw); if (sfp) { - void *ip; - - if (hw->phy.multispeed_fiber) { - hw->mac.ops.setup_sfp(hw); - ixgbe_enable_tx_laser(hw); - ip = adapter->msf_si; - } else { - ip = adapter->mod_si; - } - kpreempt_disable(); - softint_schedule(ip); + softint_schedule(adapter->mod_si); kpreempt_enable(); } else { if (hw->mac.ops.check_link) @@ -3885,23 +3881,66 @@ ixgbe_handle_mod(void *context) { struct adapter *adapter = context; struct ixgbe_hw *hw = &adapter->hw; + enum ixgbe_phy_type orig_type = hw->phy.type; device_t dev = adapter->dev; u32 err; + IXGBE_CORE_LOCK(adapter); + + /* Check to see if the PHY type changed */ + if (hw->phy.ops.identify) { + hw->phy.type = ixgbe_phy_unknown; + hw->phy.ops.identify(hw); + } + + if (hw->phy.type != orig_type) { + device_printf(dev, "Detected phy_type %d\n", hw->phy.type); + + if (hw->phy.type == ixgbe_phy_none) { + hw->phy.sfp_type = ixgbe_sfp_type_unknown; + goto out; + } + + /* Try to do the initialization that was skipped before */ + if (hw->phy.ops.init) + hw->phy.ops.init(hw); + if (hw->phy.ops.reset) + hw->phy.ops.reset(hw); + } + 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; } err = hw->mac.ops.setup_sfp(hw); if (err == IXGBE_ERR_SFP_NOT_SUPPORTED) { device_printf(dev, "Setup failure - unsupported SFP+ module type.\n"); - return; + goto out; + } + if (hw->phy.multispeed_fiber) + softint_schedule(adapter->msf_si); +out: + /* Update media type */ + switch (hw->mac.ops.get_media_type(hw)) { + case ixgbe_media_type_fiber: + adapter->optics = IFM_10G_SR; + break; + case ixgbe_media_type_copper: + adapter->optics = IFM_10G_TWINAX; + break; + case ixgbe_media_type_cx4: + adapter->optics = IFM_10G_CX4; + break; + default: + adapter->optics = 0; + break; } - softint_schedule(adapter->msf_si); + + IXGBE_CORE_UNLOCK(adapter); return; } @@ -3917,6 +3956,7 @@ ixgbe_handle_msf(void *context) u32 autoneg; bool negotiate; + IXGBE_CORE_LOCK(adapter); /* get_supported_phy_layer will call hw->phy.ops.identify_sfp() */ adapter->phy_layer = ixgbe_get_supported_physical_layer(hw); @@ -3931,6 +3971,7 @@ ixgbe_handle_msf(void *context) /* Adjust media types shown in ifconfig */ ifmedia_removeall(&adapter->media); ixgbe_add_media_types(adapter); + IXGBE_CORE_UNLOCK(adapter); return; } Index: src/sys/dev/pci/ixgbe/ixv.c diff -u src/sys/dev/pci/ixgbe/ixv.c:1.27 src/sys/dev/pci/ixgbe/ixv.c:1.28 --- src/sys/dev/pci/ixgbe/ixv.c:1.27 Fri Dec 2 11:56:55 2016 +++ src/sys/dev/pci/ixgbe/ixv.c Fri Dec 2 12:14:37 2016 @@ -31,7 +31,7 @@ ******************************************************************************/ /*$FreeBSD: head/sys/dev/ixgbe/if_ixv.c 292674 2015-12-23 22:45:17Z sbruno $*/ -/*$NetBSD: ixv.c,v 1.27 2016/12/02 11:56:55 msaitoh Exp $*/ +/*$NetBSD: ixv.c,v 1.28 2016/12/02 12:14:37 msaitoh Exp $*/ #include "opt_inet.h" #include "opt_inet6.h" @@ -1744,7 +1744,7 @@ ixv_initialize_receive_units(struct adap /* Disable the queue */ rxdctl = IXGBE_READ_REG(hw, IXGBE_VFRXDCTL(i)); - rxdctl &= ~(IXGBE_RXDCTL_ENABLE | IXGBE_RXDCTL_VME); + rxdctl &= ~IXGBE_RXDCTL_ENABLE; IXGBE_WRITE_REG(hw, IXGBE_VFRXDCTL(i), rxdctl); for (int j = 0; j < 10; j++) { if (IXGBE_READ_REG(hw, IXGBE_VFRXDCTL(i)) & @@ -1778,8 +1778,7 @@ ixv_initialize_receive_units(struct adap rxr->tail = IXGBE_VFRDT(rxr->me); /* Do the queue enabling last */ - rxdctl = IXGBE_READ_REG(hw, IXGBE_VFRXDCTL(i)); - rxdctl |= IXGBE_RXDCTL_ENABLE; + rxdctl |= IXGBE_RXDCTL_ENABLE | IXGBE_RXDCTL_VME; IXGBE_WRITE_REG(hw, IXGBE_VFRXDCTL(i), rxdctl); for (int k = 0; k < 10; k++) { if (IXGBE_READ_REG(hw, IXGBE_VFRXDCTL(i)) & @@ -2236,10 +2235,10 @@ ixv_print_debug_info(struct adapter *ada device_printf(dev,"RX(%d) Bytes Received: %lu\n", rxr->me, (long)rxr->rx_bytes.ev_count); #ifdef LRO - device_printf(dev,"RX(%d) LRO Queued= %d\n", - rxr->me, lro->lro_queued); - device_printf(dev,"RX(%d) LRO Flushed= %d\n", - rxr->me, lro->lro_flushed); + device_printf(dev,"RX(%d) LRO Queued= %lld\n", + rxr->me, (long long)lro->lro_queued); + device_printf(dev,"RX(%d) LRO Flushed= %lld\n", + rxr->me, (long long)lro->lro_flushed); #endif /* LRO */ device_printf(dev,"TX(%d) Packets Sent: %lu\n", txr->me, (long)txr->total_packets.ev_count);