From owner-svn-src-all@freebsd.org Wed Sep 20 22:14:52 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9525BE26535; Wed, 20 Sep 2017 22:14:52 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 70CFC826BB; Wed, 20 Sep 2017 22:14:52 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v8KMEp22078503; Wed, 20 Sep 2017 22:14:51 GMT (envelope-from marius@FreeBSD.org) Received: (from marius@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v8KMEpno078499; Wed, 20 Sep 2017 22:14:51 GMT (envelope-from marius@FreeBSD.org) Message-Id: <201709202214.v8KMEpno078499@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: marius set sender to marius@FreeBSD.org using -f From: Marius Strobl Date: Wed, 20 Sep 2017 22:14:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-releng@freebsd.org Subject: svn commit: r323838 - releng/10.4/sys/dev/ixgbe X-SVN-Group: releng X-SVN-Commit-Author: marius X-SVN-Commit-Paths: releng/10.4/sys/dev/ixgbe X-SVN-Commit-Revision: 323838 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Sep 2017 22:14:52 -0000 Author: marius Date: Wed Sep 20 22:14:50 2017 New Revision: 323838 URL: https://svnweb.freebsd.org/changeset/base/323838 Log: MF10: r323830 Unbreak netmap(4) support in ixgbe(4) after r315333: - Both ixgbe_netmap.c and ixv_netmap.c assumed a netmap(4) driver newer than what's actually in stable/10. - Additionally, at the bottom line ixv_netmap.c did exactly the same as ixgbe_netmap.c, i. e. used IXGBE_TDH() as appropriate for PFs only instead of IXGBE_VFTDH() and tried to configure CRC stripping although the corresponding registers aren't available to VFs in the first place. With these changes, the netmap(4) support in ixgbe(4) is in line again with the code in sys/dev/netmap/ixgbe_netmap.h as of r295008. Breakage reported by: Slawa Olhovchenkov Just like r315333 that never existed in head, this is a direct commit to stable/10. However, ixgbe(4) in head has a related bug in that it assumes a netmap(4) driver API older than what's in head and also does the wrong things for VFs as it uses the PF-only ixgbe_netmap.c for both PFs and VFs in the first place. MF10: r323835, MFC: r320916 Reset unsupported SFP tuneable back to original entry name. Approved by: re (gjb) Modified: releng/10.4/sys/dev/ixgbe/if_ix.c releng/10.4/sys/dev/ixgbe/ixgbe_netmap.c releng/10.4/sys/dev/ixgbe/ixv_netmap.c releng/10.4/sys/dev/ixgbe/ixv_netmap.h Directory Properties: releng/10.4/ (props changed) Modified: releng/10.4/sys/dev/ixgbe/if_ix.c ============================================================================== --- releng/10.4/sys/dev/ixgbe/if_ix.c Wed Sep 20 22:11:01 2017 (r323837) +++ releng/10.4/sys/dev/ixgbe/if_ix.c Wed Sep 20 22:14:50 2017 (r323838) @@ -338,7 +338,7 @@ SYSCTL_INT(_hw_ix, OID_AUTO, rxd, CTLFLAG_RDTUN, &ixgb */ static int allow_unsupported_sfp = FALSE; TUNABLE_INT("hw.ix.unsupported_sfp", &allow_unsupported_sfp); -SYSCTL_INT(_hw_ix, OID_AUTO, allow_unsupported_sfp, CTLFLAG_RDTUN, +SYSCTL_INT(_hw_ix, OID_AUTO, unsupported_sfp, CTLFLAG_RDTUN, &allow_unsupported_sfp, 0, "Allow unsupported SFP modules...use at your own risk"); Modified: releng/10.4/sys/dev/ixgbe/ixgbe_netmap.c ============================================================================== --- releng/10.4/sys/dev/ixgbe/ixgbe_netmap.c Wed Sep 20 22:11:01 2017 (r323837) +++ releng/10.4/sys/dev/ixgbe/ixgbe_netmap.c Wed Sep 20 22:14:50 2017 (r323838) @@ -316,6 +316,8 @@ ixgbe_netmap_txsync(struct netmap_kring *kring, int fl } } + nm_txsync_finalize(kring); + return 0; } @@ -343,7 +345,7 @@ ixgbe_netmap_rxsync(struct netmap_kring *kring, int fl u_int nic_i; /* index into the NIC ring */ u_int n; u_int const lim = kring->nkr_num_slots - 1; - u_int const head = kring->rhead; + u_int const head = nm_rxsync_prologue(kring); int force_update = (flags & NAF_FORCE_READ) || kring->nr_kflags & NKR_PENDINTR; /* device-specific */ @@ -449,6 +451,9 @@ ixgbe_netmap_rxsync(struct netmap_kring *kring, int fl nic_i = nm_prev(nic_i, lim); IXGBE_WRITE_REG(&adapter->hw, rxr->tail, nic_i); } + + /* tell userspace that there might be new packets */ + nm_rxsync_finalize(kring); return 0; Modified: releng/10.4/sys/dev/ixgbe/ixv_netmap.c ============================================================================== --- releng/10.4/sys/dev/ixgbe/ixv_netmap.c Wed Sep 20 22:11:01 2017 (r323837) +++ releng/10.4/sys/dev/ixgbe/ixv_netmap.c Wed Sep 20 22:14:50 2017 (r323838) @@ -60,7 +60,7 @@ /* * $FreeBSD$ * - * netmap support for: ixgbe + * netmap support for: ixv * * This file is meant to be a reference on how to implement * netmap support for a network driver. @@ -83,63 +83,17 @@ /* * device-specific sysctl variables: * - * ixv_crcstrip: 0: keep CRC in rx frames (default), 1: strip it. - * During regular operations the CRC is stripped, but on some - * hardware reception of frames not multiple of 64 is slower, - * so using crcstrip=0 helps in benchmarks. - * * ixv_rx_miss, ixv_rx_miss_bufs: * count packets that might be missed due to lost interrupts. */ SYSCTL_DECL(_dev_netmap); static int ixv_rx_miss, ixv_rx_miss_bufs; -int ixv_crcstrip; -SYSCTL_INT(_dev_netmap, OID_AUTO, ixv_crcstrip, - CTLFLAG_RW, &ixv_crcstrip, 0, "strip CRC on rx frames"); SYSCTL_INT(_dev_netmap, OID_AUTO, ixv_rx_miss, CTLFLAG_RW, &ixv_rx_miss, 0, "potentially missed rx intr"); SYSCTL_INT(_dev_netmap, OID_AUTO, ixv_rx_miss_bufs, CTLFLAG_RW, &ixv_rx_miss_bufs, 0, "potentially missed rx intr bufs"); -static void -set_crcstrip(struct ixgbe_hw *hw, int onoff) -{ - /* crc stripping is set in two places: - * IXGBE_HLREG0 (modified on init_locked and hw reset) - * IXGBE_RDRXCTL (set by the original driver in - * ixgbe_setup_hw_rsc() called in init_locked. - * We disable the setting when netmap is compiled in). - * We update the values here, but also in ixgbe.c because - * init_locked sometimes is called outside our control. - */ - uint32_t hl, rxc; - - hl = IXGBE_READ_REG(hw, IXGBE_HLREG0); - rxc = IXGBE_READ_REG(hw, IXGBE_RDRXCTL); - if (netmap_verbose) - D("%s read HLREG 0x%x rxc 0x%x", - onoff ? "enter" : "exit", hl, rxc); - /* hw requirements ... */ - rxc &= ~IXGBE_RDRXCTL_RSCFRSTSIZE; - rxc |= IXGBE_RDRXCTL_RSCACKC; - if (onoff && !ixv_crcstrip) { - /* keep the crc. Fast rx */ - hl &= ~IXGBE_HLREG0_RXCRCSTRP; - rxc &= ~IXGBE_RDRXCTL_CRCSTRIP; - } else { - /* reset default mode */ - hl |= IXGBE_HLREG0_RXCRCSTRP; - rxc |= IXGBE_RDRXCTL_CRCSTRIP; - } - if (netmap_verbose) - D("%s write HLREG 0x%x rxc 0x%x", - onoff ? "enter" : "exit", hl, rxc); - IXGBE_WRITE_REG(hw, IXGBE_HLREG0, hl); - IXGBE_WRITE_REG(hw, IXGBE_RDRXCTL, rxc); -} - - /* * Register/unregister. We are already under netmap lock. * Only called on the first register or the last unregister. @@ -153,7 +107,6 @@ ixv_netmap_reg(struct netmap_adapter *na, int onoff) IXGBE_CORE_LOCK(adapter); adapter->stop_locked(adapter); - set_crcstrip(&adapter->hw, onoff); /* enable or disable flags and callbacks in na and ifp */ if (onoff) { nm_set_native_flags(na); @@ -161,7 +114,6 @@ ixv_netmap_reg(struct netmap_adapter *na, int onoff) nm_clear_native_flags(na); } adapter->init_locked(adapter); /* also enables intr */ - set_crcstrip(&adapter->hw, onoff); // XXX why twice ? IXGBE_CORE_UNLOCK(adapter); return (ifp->if_drv_flags & IFF_DRV_RUNNING ? 0 : 1); } @@ -338,7 +290,7 @@ ixv_netmap_txsync(struct netmap_kring *kring, int flag * REPORT_STATUS in a few slots so TDH is the only * good way. */ - nic_i = IXGBE_READ_REG(&adapter->hw, IXGBE_TDH(kring->ring_id)); + nic_i = IXGBE_READ_REG(&adapter->hw, IXGBE_VFTDH(kring->ring_id)); if (nic_i >= kring->nkr_num_slots) { /* XXX can it happen ? */ D("TDH wrap %d", nic_i); nic_i -= kring->nkr_num_slots; @@ -350,6 +302,8 @@ ixv_netmap_txsync(struct netmap_kring *kring, int flag } } + nm_txsync_finalize(kring); + return 0; } @@ -377,7 +331,7 @@ ixv_netmap_rxsync(struct netmap_kring *kring, int flag u_int nic_i; /* index into the NIC ring */ u_int n; u_int const lim = kring->nkr_num_slots - 1; - u_int const head = kring->rhead; + u_int const head = nm_rxsync_prologue(kring); int force_update = (flags & NAF_FORCE_READ) || kring->nr_kflags & NKR_PENDINTR; /* device-specific */ @@ -407,7 +361,7 @@ ixv_netmap_rxsync(struct netmap_kring *kring, int flag * rxr->next_to_check is set to 0 on a ring reinit */ if (netmap_no_pendintr || force_update) { - int crclen = (ixv_crcstrip) ? 0 : 4; + int crclen = 0; uint16_t slot_flags = kring->nkr_slot_flags; nic_i = rxr->next_to_check; // or also k2n(kring->nr_hwtail) @@ -483,6 +437,9 @@ ixv_netmap_rxsync(struct netmap_kring *kring, int flag nic_i = nm_prev(nic_i, lim); IXGBE_WRITE_REG(&adapter->hw, rxr->tail, nic_i); } + + /* tell userspace that there might be new packets */ + nm_rxsync_finalize(kring); return 0; Modified: releng/10.4/sys/dev/ixgbe/ixv_netmap.h ============================================================================== --- releng/10.4/sys/dev/ixgbe/ixv_netmap.h Wed Sep 20 22:11:01 2017 (r323837) +++ releng/10.4/sys/dev/ixgbe/ixv_netmap.h Wed Sep 20 22:14:50 2017 (r323838) @@ -42,12 +42,10 @@ #include #include -extern int ixv_crcstrip; - /* - * ixgbe_netmap.c contains functions for netmap + * ixv_netmap.c contains functions for netmap * support that extend the standard driver. See additional - * comments in ixgbe_netmap.c. + * comments in ixv_netmap.c. */ void ixv_netmap_attach(struct adapter *adapter);