From nobody Sat Dec 31 12:29:16 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4NkhJX2Z69z2nMTF; Sat, 31 Dec 2022 12:29:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4NkhJX263Hz4KT5; Sat, 31 Dec 2022 12:29:16 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1672489756; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=GlL4cNjkALSHEj9bNeQL8HxP8OIkkRaTXup9C603pdo=; b=nrk9gd4J8zje1fCeTK7+9c3uya3xXTUtrtmeJ+i6ry1m3ZpM8FHFrRESgE/Spf/5QftjtY TfzH1qPENOzKV9CLB4SrnGiaC85bi8N4eseukQobk1OaqEhFLsBFbndAPHduozrGOV0KhB LcJg5e4N/i1zejsAbhDwLBbhH6g6c+uhCENSpBS0bkNWHDQzBQPmh+d3GBU41gLi37bOtm rRt/RkkLgApjRQO1+Mh0txcKTq+iUhHAJUszcdyUCMhJJNF3YiqKL3aeSXh5XGzxg2llWO 5YC/gF/OBbuA/ctYZh9knHzGIufGPSFlB1OlxWg4dQ2LMNE12TrSp4Wq1GcU3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1672489756; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=GlL4cNjkALSHEj9bNeQL8HxP8OIkkRaTXup9C603pdo=; b=lrx6j4mhaCtNfKuM7mo/wGy8Waz6yTv84SzA8fKv2sVJmLpwWWzaXAjH7l5KO2s5FKBkQg lA1vQICFciJ/spBVaSVLAW/23Siq41zXFkq748booeqdKvI4+QRohKU8/YK8Wy6Sol60on TsY0Ux25zZdE76ZK4Tis6y0xVbd1qY1bUQswykgunwqi+NLgwYmMqFm0onBFdY4tltycDG kt5TtvRDZ99EIr7vd0vsKK0+GxmP2ej6plITgr4+o+QGvJuH9TCZbcvO6pvr6n3mZdO1R7 mGVh/jxd47C+W8iHsHcy43cR3uOsKfjQ3OPFu3lXNHUFbZBiMpkudRmq2kWITQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1672489756; a=rsa-sha256; cv=none; b=ChVA9mfnbDO/ObFbe4Wm3s+Vxx3wD5K9qiXGuVRMVXn5JTDK6qj6lroJM/xTUdFxPWJW/d pXzxz68h9x0f+P10SdB3WWCuMUeZiYGiLQXlYj2UHqstQNvzAYgZiDsyMe2xL3y/LiQ9jv YQE6ZmyksNdSm5chw1f+l2zvH/Zk79tRk6rHOxipj9SCBIQ7AAmzApoOag3IftpeDJ/zCr Uo6kvyJLgO3ZR1eDHCYUJG30h7PQB678tdxaUEtZMKAQQXlOnx38cbiOHgnhkf1plMlW8H 9JVZ1rWXnzwUxe2VFIM3MVEXZP9lkyZnlMF/tK4nRqVZhJwLdUjlMg29t1Vwxg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4NkhJX1Bbxzndv; Sat, 31 Dec 2022 12:29:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 2BVCTGOY069995; Sat, 31 Dec 2022 12:29:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2BVCTG08069994; Sat, 31 Dec 2022 12:29:16 GMT (envelope-from git) Date: Sat, 31 Dec 2022 12:29:16 GMT Message-Id: <202212311229.2BVCTG08069994@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Vincenzo Maffione Subject: git: 82e3b96039bd - stable/12 - netmap: drop compatibility FreeBSD code List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: vmaffione X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 82e3b96039bd870824abb808251b058d55b3d4c9 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by vmaffione: URL: https://cgit.FreeBSD.org/src/commit/?id=82e3b96039bd870824abb808251b058d55b3d4c9 commit 82e3b96039bd870824abb808251b058d55b3d4c9 Author: Vincenzo Maffione AuthorDate: 2022-12-24 14:31:14 +0000 Commit: Vincenzo Maffione CommitDate: 2022-12-31 12:13:55 +0000 netmap: drop compatibility FreeBSD code Netmap users on FreeBSD are not supposed to import code from the github netmap repository anymore. They should use the code that is available in the src repo. We can therefore drop the compatibility code. MFC after: 7 days (cherry picked from commit 3da494d3246e30a19d2107c8bb8a293ffd5a9da6) --- sys/dev/netmap/if_ptnet.c | 9 ----- sys/dev/netmap/netmap_freebsd.c | 24 +----------- sys/dev/netmap/netmap_generic.c | 4 -- sys/dev/netmap/netmap_kern.h | 81 ----------------------------------------- 4 files changed, 1 insertion(+), 117 deletions(-) diff --git a/sys/dev/netmap/if_ptnet.c b/sys/dev/netmap/if_ptnet.c index 2c16e01225a0..d799c3de08eb 100644 --- a/sys/dev/netmap/if_ptnet.c +++ b/sys/dev/netmap/if_ptnet.c @@ -93,12 +93,7 @@ #error "INET not defined, cannot support offloadings" #endif -#if __FreeBSD_version >= 1100000 static uint64_t ptnet_get_counter(if_t, ift_counter); -#else -typedef struct ifnet *if_t; -#define if_getsoftc(_ifp) (_ifp)->if_softc -#endif //#define PTNETMAP_STATS //#define DEBUG @@ -419,9 +414,7 @@ ptnet_attach(device_t dev) ifp->if_flags = IFF_BROADCAST | IFF_MULTICAST | IFF_SIMPLEX; ifp->if_init = ptnet_init; ifp->if_ioctl = ptnet_ioctl; -#if __FreeBSD_version >= 1100000 ifp->if_get_counter = ptnet_get_counter; -#endif ifp->if_transmit = ptnet_transmit; ifp->if_qflush = ptnet_qflush; @@ -1014,7 +1007,6 @@ ptnet_media_change(if_t ifp) return 0; } -#if __FreeBSD_version >= 1100000 static uint64_t ptnet_get_counter(if_t ifp, ift_counter cnt) { @@ -1052,7 +1044,6 @@ ptnet_get_counter(if_t ifp, ift_counter cnt) return (if_get_counter_default(ifp, cnt)); } } -#endif #ifdef PTNETMAP_STATS diff --git a/sys/dev/netmap/netmap_freebsd.c b/sys/dev/netmap/netmap_freebsd.c index 28f753b06f8c..a8c18a1134c2 100644 --- a/sys/dev/netmap/netmap_freebsd.c +++ b/sys/dev/netmap/netmap_freebsd.c @@ -210,11 +210,7 @@ nm_os_ifnet_fini(void) unsigned nm_os_ifnet_mtu(struct ifnet *ifp) { -#if __FreeBSD_version < 1100030 - return ifp->if_data.ifi_mtu; -#else /* __FreeBSD_version >= 1100030 */ return ifp->if_mtu; -#endif } rawsum_t @@ -422,26 +418,10 @@ nm_os_generic_xmit_frame(struct nm_os_gen_arg *a) struct ifnet *ifp = a->ifp; struct mbuf *m = a->m; -#if __FreeBSD_version < 1100000 - /* - * Old FreeBSD versions. The mbuf has a cluster attached, - * we need to copy from the cluster to the netmap buffer. - */ - if (MBUF_REFCNT(m) != 1) { - nm_prerr("invalid refcnt %d for %p", MBUF_REFCNT(m), m); - panic("in generic_xmit_frame"); - } - if (m->m_ext.ext_size < len) { - nm_prlim(2, "size %d < len %d", m->m_ext.ext_size, len); - len = m->m_ext.ext_size; - } - bcopy(a->addr, m->m_data, len); -#else /* __FreeBSD_version >= 1100000 */ - /* New FreeBSD versions. Link the external storage to + /* Link the external storage to * the netmap buffer, so that no copy is necessary. */ m->m_ext.ext_buf = m->m_data = a->addr; m->m_ext.ext_size = len; -#endif /* __FreeBSD_version >= 1100000 */ m->m_flags |= M_PKTHDR; m->m_len = m->m_pkthdr.len = len; @@ -459,13 +439,11 @@ nm_os_generic_xmit_frame(struct nm_os_gen_arg *a) } -#if __FreeBSD_version >= 1100005 struct netmap_adapter * netmap_getna(if_t ifp) { return (NA((struct ifnet *)ifp)); } -#endif /* __FreeBSD_version >= 1100005 */ /* * The following two functions are empty until we have a generic diff --git a/sys/dev/netmap/netmap_generic.c b/sys/dev/netmap/netmap_generic.c index 45b5d3bde35f..cb90e911b7e4 100644 --- a/sys/dev/netmap/netmap_generic.c +++ b/sys/dev/netmap/netmap_generic.c @@ -482,11 +482,7 @@ generic_mbuf_destructor(struct mbuf *m) * txsync. */ netmap_generic_irq(na, r, NULL); #ifdef __FreeBSD__ -#if __FreeBSD_version <= 1200050 - void_mbuf_dtor(m, NULL, NULL); -#else /* __FreeBSD_version >= 1200051 */ void_mbuf_dtor(m); -#endif /* __FreeBSD_version >= 1200051 */ #endif } diff --git a/sys/dev/netmap/netmap_kern.h b/sys/dev/netmap/netmap_kern.h index a45a405d5163..b6f0f70c8ac8 100644 --- a/sys/dev/netmap/netmap_kern.h +++ b/sys/dev/netmap/netmap_kern.h @@ -110,23 +110,12 @@ #define NM_ATOMIC_TEST_AND_SET(p) (!atomic_cmpset_acq_int((p), 0, 1)) #define NM_ATOMIC_CLEAR(p) atomic_store_rel_int((p), 0) -#if __FreeBSD_version >= 1100030 #define WNA(_ifp) (_ifp)->if_netmap -#else /* older FreeBSD */ -#define WNA(_ifp) (_ifp)->if_pspare[0] -#endif /* older FreeBSD */ -#if __FreeBSD_version >= 1100005 struct netmap_adapter *netmap_getna(if_t ifp); -#endif -#if __FreeBSD_version >= 1100027 #define MBUF_REFCNT(m) ((m)->m_ext.ext_count) #define SET_MBUF_REFCNT(m, x) (m)->m_ext.ext_count = x -#else -#define MBUF_REFCNT(m) ((m)->m_ext.ref_cnt ? *((m)->m_ext.ref_cnt) : -1) -#define SET_MBUF_REFCNT(m, x) *((m)->m_ext.ref_cnt) = x -#endif #define MBUF_QUEUED(m) 1 @@ -2298,69 +2287,6 @@ ptnet_sync_tail(struct nm_csb_ktoa *ktoa, struct netmap_kring *kring) #ifdef __FreeBSD__ /* * FreeBSD mbuf allocator/deallocator in emulation mode: - */ -#if __FreeBSD_version < 1100000 - -/* - * For older versions of FreeBSD: - * - * We allocate EXT_PACKET mbuf+clusters, but need to set M_NOFREE - * so that the destructor, if invoked, will not free the packet. - * In principle we should set the destructor only on demand, - * but since there might be a race we better do it on allocation. - * As a consequence, we also need to set the destructor or we - * would leak buffers. - */ - -/* mbuf destructor, also need to change the type to EXT_EXTREF, - * add an M_NOFREE flag, and then clear the flag and - * chain into uma_zfree(zone_pack, mf) - * (or reinstall the buffer ?) - */ -#define SET_MBUF_DESTRUCTOR(m, fn) do { \ - (m)->m_ext.ext_free = (void *)fn; \ - (m)->m_ext.ext_type = EXT_EXTREF; \ -} while (0) - -static int -void_mbuf_dtor(struct mbuf *m, void *arg1, void *arg2) -{ - /* restore original mbuf */ - m->m_ext.ext_buf = m->m_data = m->m_ext.ext_arg1; - m->m_ext.ext_arg1 = NULL; - m->m_ext.ext_type = EXT_PACKET; - m->m_ext.ext_free = NULL; - if (MBUF_REFCNT(m) == 0) - SET_MBUF_REFCNT(m, 1); - uma_zfree(zone_pack, m); - - return 0; -} - -static inline struct mbuf * -nm_os_get_mbuf(struct ifnet *ifp, int len) -{ - struct mbuf *m; - - (void)ifp; - m = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR); - if (m) { - /* m_getcl() (mb_ctor_mbuf) has an assert that checks that - * M_NOFREE flag is not specified as third argument, - * so we have to set M_NOFREE after m_getcl(). */ - m->m_flags |= M_NOFREE; - m->m_ext.ext_arg1 = m->m_ext.ext_buf; // XXX save - m->m_ext.ext_free = (void *)void_mbuf_dtor; - m->m_ext.ext_type = EXT_EXTREF; - nm_prdis(5, "create m %p refcnt %d", m, MBUF_REFCNT(m)); - } - return m; -} - -#else /* __FreeBSD_version >= 1100000 */ - -/* - * Newer versions of FreeBSD, using a straightforward scheme. * * We allocate mbufs with m_gethdr(), since the mbuf header is needed * by the driver. We also attach a customly-provided external storage, @@ -2373,13 +2299,7 @@ nm_os_get_mbuf(struct ifnet *ifp, int len) * has a KASSERT(), checking that the mbuf dtor function is not NULL. */ -#if __FreeBSD_version <= 1200050 -static void void_mbuf_dtor(struct mbuf *m, void *arg1, void *arg2) { } -#else /* __FreeBSD_version >= 1200051 */ -/* The arg1 and arg2 pointers argument were removed by r324446, which - * in included since version 1200051. */ static void void_mbuf_dtor(struct mbuf *m) { } -#endif /* __FreeBSD_version >= 1200051 */ #define SET_MBUF_DESTRUCTOR(m, fn) do { \ (m)->m_ext.ext_free = (fn != NULL) ? \ @@ -2405,7 +2325,6 @@ nm_os_get_mbuf(struct ifnet *ifp, int len) return m; } -#endif /* __FreeBSD_version >= 1100000 */ #endif /* __FreeBSD__ */ struct nmreq_option * nmreq_getoption(struct nmreq_header *, uint16_t);