From owner-svn-src-all@freebsd.org Sun Nov 22 09:10:13 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 37E3C2EA08D; Sun, 22 Nov 2020 09:10:13 +0000 (UTC) (envelope-from vmaffione@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 "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cf4Hn0gddz4ld9; Sun, 22 Nov 2020 09:10:13 +0000 (UTC) (envelope-from vmaffione@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0507B17D81; Sun, 22 Nov 2020 09:10:13 +0000 (UTC) (envelope-from vmaffione@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AM9ACLO001536; Sun, 22 Nov 2020 09:10:12 GMT (envelope-from vmaffione@FreeBSD.org) Received: (from vmaffione@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AM9ACxU001534; Sun, 22 Nov 2020 09:10:12 GMT (envelope-from vmaffione@FreeBSD.org) Message-Id: <202011220910.0AM9ACxU001534@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: vmaffione set sender to vmaffione@FreeBSD.org using -f From: Vincenzo Maffione Date: Sun, 22 Nov 2020 09:10:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367931 - head/tools/tools/netmap X-SVN-Group: head X-SVN-Commit-Author: vmaffione X-SVN-Commit-Paths: head/tools/tools/netmap X-SVN-Commit-Revision: 367931 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.34 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: Sun, 22 Nov 2020 09:10:13 -0000 Author: vmaffione Date: Sun Nov 22 09:10:12 2020 New Revision: 367931 URL: https://svnweb.freebsd.org/changeset/base/367931 Log: netmap: bridge: switch to libnetmap Use the newer libnetmap (included in base) rather than the older nm_open()/nm_close() defined in netmap_user.h Modified: head/tools/tools/netmap/Makefile head/tools/tools/netmap/bridge.c Modified: head/tools/tools/netmap/Makefile ============================================================================== --- head/tools/tools/netmap/Makefile Sun Nov 22 05:47:45 2020 (r367930) +++ head/tools/tools/netmap/Makefile Sun Nov 22 09:10:12 2020 (r367931) @@ -11,7 +11,7 @@ MAN= .include .include -LDFLAGS += -lpthread +LDFLAGS += -lpthread -lnetmap .ifdef WITHOUT_PCAP CFLAGS += -DNO_PCAP .else @@ -27,7 +27,7 @@ pkt-gen: pkt-gen.o $(CC) $(CFLAGS) -o pkt-gen pkt-gen.o $(LDFLAGS) bridge: bridge.o - $(CC) $(CFLAGS) -o bridge bridge.o + $(CC) $(CFLAGS) -o bridge bridge.o $(LDFLAGS) nmreplay: nmreplay.o $(CC) $(CFLAGS) -o nmreplay nmreplay.o $(LDFLAGS) Modified: head/tools/tools/netmap/bridge.c ============================================================================== --- head/tools/tools/netmap/bridge.c Sun Nov 22 05:47:45 2020 (r367930) +++ head/tools/tools/netmap/bridge.c Sun Nov 22 09:10:12 2020 (r367931) @@ -10,9 +10,12 @@ */ #include -#define NETMAP_WITH_LIBS -#include #include +#include +#include +#include +#include +#include static int verbose = 0; @@ -32,7 +35,7 @@ sigint_h(int sig) * how many packets on this set of queues ? */ static int -pkt_queued(struct nm_desc *d, int tx) +pkt_queued(struct nmport_d *d, int tx) { u_int i, tot = 0; @@ -61,8 +64,8 @@ process_rings(struct netmap_ring *rxring, struct netma if (rxring->flags || txring->flags) D("%s rxflags %x txflags %x", msg, rxring->flags, txring->flags); - j = rxring->cur; /* RX */ - k = txring->cur; /* TX */ + j = rxring->head; /* RX */ + k = txring->head; /* TX */ m = nm_ring_space(rxring); if (m < limit) limit = m; @@ -115,11 +118,11 @@ process_rings(struct netmap_ring *rxring, struct netma /* move packts from src to destination */ static int -move(struct nm_desc *src, struct nm_desc *dst, u_int limit) +move(struct nmport_d *src, struct nmport_d *dst, u_int limit) { struct netmap_ring *txring, *rxring; u_int m = 0, si = src->first_rx_ring, di = dst->first_tx_ring; - const char *msg = (src->req.nr_flags == NR_REG_SW) ? + const char *msg = (src->reg.nr_flags == NR_REG_SW) ? "host->net" : "net->host"; while (si <= src->last_rx_ring && di <= dst->last_tx_ring) { @@ -175,7 +178,7 @@ main(int argc, char **argv) struct pollfd pollfd[2]; int ch; u_int burst = 1024, wait_link = 4; - struct nm_desc *pa = NULL, *pb = NULL; + struct nmport_d *pa = NULL, *pb = NULL; char *ifa = NULL, *ifb = NULL; char ifabuf[64] = { 0 }; int loopback = 0; @@ -252,16 +255,16 @@ main(int argc, char **argv) } else { /* two different interfaces. Take all rings on if1 */ } - pa = nm_open(ifa, NULL, 0, NULL); + pa = nmport_open(ifa); if (pa == NULL) { D("cannot open %s", ifa); return (1); } /* try to reuse the mmap() of the first interface, if possible */ - pb = nm_open(ifb, NULL, NM_OPEN_NO_MMAP, pa); + pb = nmport_open(ifb); if (pb == NULL) { D("cannot open %s", ifb); - nm_close(pa); + nmport_close(pa); return (1); } zerocopy = zerocopy && (pa->mem == pb->mem); @@ -275,8 +278,8 @@ main(int argc, char **argv) D("Wait %d secs for link to come up...", wait_link); sleep(wait_link); D("Ready to go, %s 0x%x/%d <-> %s 0x%x/%d.", - pa->req.nr_name, pa->first_rx_ring, pa->req.nr_rx_rings, - pb->req.nr_name, pb->first_rx_ring, pb->req.nr_rx_rings); + pa->hdr.nr_name, pa->first_rx_ring, pa->reg.nr_rx_rings, + pb->hdr.nr_name, pb->first_rx_ring, pb->reg.nr_rx_rings); /* main loop */ signal(SIGINT, sigint_h); @@ -320,12 +323,12 @@ main(int argc, char **argv) pollfd[0].events, pollfd[0].revents, pkt_queued(pa, 0), - NETMAP_RXRING(pa->nifp, pa->cur_rx_ring)->cur, + NETMAP_RXRING(pa->nifp, pa->cur_rx_ring)->head, pkt_queued(pa, 1), pollfd[1].events, pollfd[1].revents, pkt_queued(pb, 0), - NETMAP_RXRING(pb->nifp, pb->cur_rx_ring)->cur, + NETMAP_RXRING(pb->nifp, pb->cur_rx_ring)->head, pkt_queued(pb, 1) ); if (ret < 0) @@ -349,8 +352,8 @@ main(int argc, char **argv) /* We don't need ioctl(NIOCTXSYNC) on the two file descriptors here, * kernel will txsync on next poll(). */ } - nm_close(pb); - nm_close(pa); + nmport_close(pb); + nmport_close(pa); return (0); }