From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id E3EB1A0613 for ; Fri, 27 Sep 2019 16:01:31 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 475E91BE9B; Fri, 27 Sep 2019 16:01:31 +0200 (CEST) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id CEF121BDFD for ; Fri, 27 Sep 2019 16:01:29 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Sep 2019 07:01:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,555,1559545200"; d="scan'208";a="365157415" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by orsmga005.jf.intel.com with ESMTP; 27 Sep 2019 07:01:28 -0700 Received: from fmsmsx156.amr.corp.intel.com (10.18.116.74) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.439.0; Fri, 27 Sep 2019 07:01:28 -0700 Received: from lcsmsx155.ger.corp.intel.com (10.186.165.233) by fmsmsx156.amr.corp.intel.com (10.18.116.74) with Microsoft SMTP Server (TLS) id 14.3.439.0; Fri, 27 Sep 2019 07:01:27 -0700 Received: from hasmsx114.ger.corp.intel.com ([169.254.14.116]) by LCSMSX155.ger.corp.intel.com ([169.254.12.233]) with mapi id 14.03.0439.000; Fri, 27 Sep 2019 17:01:25 +0300 From: "Baran, MarcinX" To: "Richardson, Bruce" CC: "dev@dpdk.org" , "Modrak, PawelX" Thread-Topic: [dpdk-dev] [PATCH v5 2/6] examples/ioat: add software copy support Thread-Index: AQHVb4aGS+2IWyZu+0GXRWkH5y+Iwqc/I60AgAB1G4A= Date: Fri, 27 Sep 2019 14:01:25 +0000 Message-ID: <06CDC4676D44784DA2DF9423D4B672BE15ECCC9F@HASMSX114.ger.corp.intel.com> References: <20190919093850.460-1-marcinx.baran@intel.com> <20190920073714.1314-1-marcinx.baran@intel.com> <20190920073714.1314-3-marcinx.baran@intel.com> <20190927100120.GB1847@bricha3-MOBL.ger.corp.intel.com> In-Reply-To: <20190927100120.GB1847@bricha3-MOBL.ger.corp.intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.2.0.6 dlp-reaction: no-action x-originating-ip: [10.184.70.11] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v5 2/6] examples/ioat: add software copy support X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" -----Original Message----- From: Bruce Richardson =20 Sent: Friday, September 27, 2019 12:01 PM To: Baran, MarcinX Cc: dev@dpdk.org; Modrak, PawelX Subject: Re: [dpdk-dev] [PATCH v5 2/6] examples/ioat: add software copy sup= port On Fri, Sep 20, 2019 at 09:37:10AM +0200, Marcin Baran wrote: > Added support for copying packets > using software copy mode and MAC address changing. The copies are=20 > processed using one lcore. >=20 > Signed-off-by: Marcin Baran > Signed-off-by: Pawel Modrak > --- > examples/ioat/ioatfwd.c | 211=20 > +++++++++++++++++++++++++++++++++++----- > 1 file changed, 188 insertions(+), 23 deletions(-) >=20 > diff --git a/examples/ioat/ioatfwd.c b/examples/ioat/ioatfwd.c index=20 > 977ea6a61..3a092c6cf 100644 > --- a/examples/ioat/ioatfwd.c > +++ b/examples/ioat/ioatfwd.c > @@ -13,7 +13,7 @@ > #include > #include > =20 > -/* size of ring used for software copying between rx and tx. */ > + /* size of ring used for software copying between rx and tx. */ > #define RTE_LOGTYPE_IOAT RTE_LOGTYPE_USER1 #define MAX_PKT_BURST 32 =20 > #define MEMPOOL_CACHE_SIZE 512 @@ -89,6 +89,142 @@ static struct=20 > rte_ether_addr ioat_ports_eth_addr[RTE_MAX_ETHPORTS]; > static struct rte_eth_dev_tx_buffer *tx_buffer[RTE_MAX_ETHPORTS]; =20 > struct rte_mempool *ioat_pktmbuf_pool; > =20 > +static void > +update_mac_addrs(struct rte_mbuf *m, uint32_t dest_portid) { > + struct rte_ether_hdr *eth; > + void *tmp; > + > + eth =3D rte_pktmbuf_mtod(m, struct rte_ether_hdr *); > + > + /* 02:00:00:00:00:xx - overwriting 2 bytes of source address but > + * it's acceptable cause it gets overwritten by rte_ether_addr_copy > + */ > + tmp =3D ð->d_addr.addr_bytes[0]; > + *((uint64_t *)tmp) =3D 0x000000000002 + ((uint64_t)dest_portid << 40); > + > + /* src addr */ > + rte_ether_addr_copy(&ioat_ports_eth_addr[dest_portid],=20 > +ð->s_addr); } > + > +static inline void > +pktmbuf_sw_copy(struct rte_mbuf *src, struct rte_mbuf *dst) { > + /* Copy packet metadata */ > + rte_memcpy(&dst->rearm_data, > + &src->rearm_data, > + offsetof(struct rte_mbuf, cacheline1) > + - offsetof(struct rte_mbuf, rearm_data)); > + > + /* Copy packet data */ > + rte_memcpy(rte_pktmbuf_mtod(dst, char *), > + rte_pktmbuf_mtod(src, char *), src->data_len); } > + > +/* Receive packets on one port and enqueue to IOAT rawdev or=20 > +rte_ring. */ static void ioat_rx_port(struct rxtx_port_config=20 > +*rx_config) { > + uint32_t nb_rx, nb_enq, i, j; > + struct rte_mbuf *pkts_burst[MAX_PKT_BURST]; > + > + for (i =3D 0; i < rx_config->nb_queues; i++) { > + > + nb_rx =3D rte_eth_rx_burst(rx_config->rxtx_port, i, > + pkts_burst, MAX_PKT_BURST); > + > + if (nb_rx =3D=3D 0) > + continue; > + > + /* Perform packet software copy, free source packets */ > + int ret; > + struct rte_mbuf *pkts_burst_copy[MAX_PKT_BURST]; > + > + ret =3D rte_mempool_get_bulk(ioat_pktmbuf_pool, > + (void *)pkts_burst_copy, nb_rx); > + > + if (unlikely(ret < 0)) > + rte_exit(EXIT_FAILURE, > + "Unable to allocate memory.\n"); > + > + for (j =3D 0; j < nb_rx; j++) > + pktmbuf_sw_copy(pkts_burst[j], > + pkts_burst_copy[j]); > + > + rte_mempool_put_bulk(ioat_pktmbuf_pool, > + (void *)pkts_burst, nb_rx); > + > + nb_enq =3D rte_ring_enqueue_burst( > + rx_config->rx_to_tx_ring, > + (void *)pkts_burst_copy, nb_rx, NULL); > + > + /* Free any not enqueued packets. */ > + rte_mempool_put_bulk(ioat_pktmbuf_pool, > + (void *)&pkts_burst_copy[nb_enq], > + nb_rx - nb_enq); > + } > +} > + > +/* Transmit packets from IOAT rawdev/rte_ring for one port. */ static=20 > +void ioat_tx_port(struct rxtx_port_config *tx_config) { > + uint32_t i, nb_dq =3D 0; > + struct rte_mbuf *mbufs_dst[MAX_PKT_BURST]; > + > + /* Deque the mbufs from rx_to_tx_ring. */ > + nb_dq =3D rte_ring_dequeue_burst(tx_config->rx_to_tx_ring, > + (void *)mbufs_dst, MAX_PKT_BURST, NULL); > + > + if (nb_dq =3D=3D 0) > + return; > + > + /* Update macs if enabled */ > + if (mac_updating) { > + for (i =3D 0; i < nb_dq; i++) > + update_mac_addrs(mbufs_dst[i], > + tx_config->rxtx_port); > + } > + > + const uint16_t nb_tx =3D rte_eth_tx_burst(tx_config->rxtx_port, > + 0, (void *)mbufs_dst, nb_dq); > + > + /* Free any unsent packets. */ > + if (unlikely(nb_tx < nb_dq)) > + rte_mempool_put_bulk(ioat_pktmbuf_pool, > + (void *)&mbufs_dst[nb_tx], > + nb_dq - nb_tx); > +} > + > +/* Main rx and tx loop if only one slave lcore available */ static=20 > +void > +rxtx_main_loop(void) > +{ > + uint16_t i; > + uint16_t nb_ports =3D cfg.nb_ports; > + > + RTE_LOG(INFO, IOAT, "Entering main rx and tx loop for copy on" > + " lcore %u\n", rte_lcore_id()); > + > + while (!force_quit) > + for (i =3D 0; i < nb_ports; i++) { > + ioat_rx_port(&cfg.ports[i]); > + ioat_tx_port(&cfg.ports[i]); > + } > +} > + > +static void start_forwarding_cores(void) { > + uint32_t lcore_id =3D rte_lcore_id(); > + > + RTE_LOG(INFO, IOAT, "Entering %s on lcore %u\n", > + __func__, rte_lcore_id()); > + > + lcore_id =3D rte_get_next_lcore(lcore_id, true, true); > + rte_eal_remote_launch((lcore_function_t *)rxtx_main_loop, > + NULL, lcore_id); > +} > + > /* Display usage */ > static void > ioat_usage(const char *prgname) > @@ -102,7 +238,7 @@ ioat_usage(const char *prgname) > " - The destination MAC address is replaced by 02:00:00:00:00:TX= _PORT_ID\n" > " -c --copy-type CT: type of copy: sw|rawdev\n" > " -s --ring-size RS: size of IOAT rawdev ring for hardware copy mode = or rte_ring for software copy mode\n", > - prgname); > + prgname); > } > =20 > static int > @@ -161,16 +297,16 @@ ioat_parse_args(int argc, char **argv, unsigned int= nb_ports) > argvopt =3D argv; > =20 > while ((opt =3D getopt_long(argc, argvopt, short_options, > - lgopts, &option_index)) !=3D EOF) { > + lgopts, &option_index)) !=3D EOF) { These and the other whitespace changes in this patch should be fixed in pat= ch 1 rather than having them as modifications here. Without these whitespace changes merged into original patch: Acked-by: Bruce Richardson [Marcin]: Whitespace changes moved to previous commit for v6.