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 B359AA04E6; Fri, 30 Oct 2020 18:49:11 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D20556A1A; Fri, 30 Oct 2020 18:45:29 +0100 (CET) Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by dpdk.org (Postfix) with ESMTP id CE5FB593A for ; Fri, 30 Oct 2020 18:45:14 +0100 (CET) Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id 849575C0222; Fri, 30 Oct 2020 13:45:14 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Fri, 30 Oct 2020 13:45:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm2; bh=J3RBE1bgeb3gm u4FInGoS6XAPQG+HMuKP2wilUMhvWI=; b=OKz/lXnFI2kUgJEhjrZzAFEuCy0Fr 4j+IHYJH/tU3koXf04tp3+Q4qIWEeF8gbh4+uTXL7SbIfVJRCGLh2vDckmf4Z6dj 9xLmqWg1Q+HszjjXd7Yr8a65dkPW9LYNOO1x7N0S8z6cjarQA8QxikXFli49Kx+J 7EXWLdXDqb7ZepGlaxYzl/NTZw6nZIn8jpcNa7coKRRFqWJ4BjBZl4oKHP3TaSen OlJ4d4TYuqpaOlx5il5MeSA2ViKJRr/tTKz01EvYhK/+qfbOG+P7LVdBtE1fM0SJ 1UoUYNnil5WuHnOrPoz2POFYAl1GbcgA3zvFFuOEQfAFnUMvqYDKGFB3Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=J3RBE1bgeb3gmu4FInGoS6XAPQG+HMuKP2wilUMhvWI=; b=r7tkPfqb UrV4erYO/XMz0Ly8ClIkYhmUYZ6b9vF1aCCi5WNwCLGLOsEUBi5qGod8KbAeliDf 1+jMrcjC31xIj4YQQb+a0Uxx4zoqQr1xAqhZ2N4cLIOi1FO0zr08aYN5H+K5RHxo mS1kwl55VOjsm6Z95yS0t/+j8h5jcS80M3n3yszkalUbOofdViGs8shArlA/v8Qj Do4o5/viinjRXaAigrAdM7fqLbW7FykJSI6JhUg81FYJTh33a8a3N9LWuRYqIdEJ +7UV993ubumf2MuJejLuAfmNER0pOxI5ZHLAfjZ8bfNa7WnLjwX0bK/CQvvL+bIq pf1DTiLupiUDzw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrleehgdellecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepvfhhohhmrghs ucfoohhnjhgrlhhonhcuoehthhhomhgrshesmhhonhhjrghlohhnrdhnvghtqeenucggtf frrghtthgvrhhnpedvhefgiedvjeegtdevheefhfetleefgfeivefgffevfeejgedtgfeu tdehtdegveenucfkphepjeejrddufeegrddvtdefrddukeegnecuvehluhhsthgvrhfuih iivgepleenucfrrghrrghmpehmrghilhhfrhhomhepthhhohhmrghssehmohhnjhgrlhho nhdrnhgvth X-ME-Proxy: Received: from xps.monjalon.net (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id 24F5B3064674; Fri, 30 Oct 2020 13:45:13 -0400 (EDT) From: Thomas Monjalon To: dev@dpdk.org Cc: ferruh.yigit@intel.com, david.marchand@redhat.com, bruce.richardson@intel.com, olivier.matz@6wind.com, andrew.rybchenko@oktetlabs.ru, akhil.goyal@nxp.com, jerinj@marvell.com, Nicolas Chautru Date: Fri, 30 Oct 2020 18:44:39 +0100 Message-Id: <20201030174441.1076264-14-thomas@monjalon.net> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201030174441.1076264-1-thomas@monjalon.net> References: <20201026052105.1561859-1-thomas@monjalon.net> <20201030174441.1076264-1-thomas@monjalon.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v6 13/15] examples/bbdev: switch to dynamic mbuf field 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" The example used the deprecated mbuf field udata64 as input mbuf pointer. It is moved to a dynamic field in order to allow removal of udata64. Signed-off-by: Thomas Monjalon Reviewed-by: Andrew Rybchenko --- examples/bbdev_app/main.c | 42 +++++++++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 10 deletions(-) diff --git a/examples/bbdev_app/main.c b/examples/bbdev_app/main.c index e512c807cd..2e170caf84 100644 --- a/examples/bbdev_app/main.c +++ b/examples/bbdev_app/main.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -59,6 +60,15 @@ } \ } while (0) +static int input_dynfield_offset = -1; + +static inline struct rte_mbuf ** +mbuf_input(struct rte_mbuf *mbuf) +{ + return RTE_MBUF_DYNFIELD(mbuf, + input_dynfield_offset, struct rte_mbuf **); +} + static const struct rte_eth_conf port_conf = { .rxmode = { .mq_mode = ETH_MQ_RX_NONE, @@ -294,11 +304,11 @@ pktmbuf_free_bulk(struct rte_mbuf **mbufs, unsigned int nb_to_free) } static inline void -pktmbuf_userdata_free_bulk(struct rte_mbuf **mbufs, unsigned int nb_to_free) +pktmbuf_input_free_bulk(struct rte_mbuf **mbufs, unsigned int nb_to_free) { unsigned int i; for (i = 0; i < nb_to_free; ++i) { - struct rte_mbuf *rx_pkt = mbufs[i]->userdata; + struct rte_mbuf *rx_pkt = *mbuf_input(mbufs[i]); rte_pktmbuf_free(rx_pkt); rte_pktmbuf_free(mbufs[i]); } @@ -429,7 +439,7 @@ verify_data(struct rte_mbuf **mbufs, uint16_t num_pkts) uint16_t i; for (i = 0; i < num_pkts; ++i) { struct rte_mbuf *out = mbufs[i]; - struct rte_mbuf *in = out->userdata; + struct rte_mbuf *in = *mbuf_input(out); if (memcmp(rte_pktmbuf_mtod_offset(in, uint8_t *, sizeof(struct rte_ether_hdr)), @@ -731,7 +741,7 @@ run_encoding(struct lcore_conf *lcore_conf) rte_pktmbuf_data_len(rx_pkts_burst[i]) - sizeof(struct rte_ether_hdr); /* save input mbuf pointer for later comparison */ - enc_out_pkts[i]->userdata = rx_pkts_burst[i]; + *mbuf_input(enc_out_pkts[i]) = rx_pkts_burst[i]; /* copy ethernet header */ rte_pktmbuf_reset(enc_out_pkts[i]); @@ -775,7 +785,7 @@ run_encoding(struct lcore_conf *lcore_conf) nb_enq = rte_bbdev_enqueue_enc_ops(bbdev_id, enc_queue_id, bbdev_ops_burst, nb_rx); if (unlikely(nb_enq < nb_rx)) { - pktmbuf_userdata_free_bulk(&enc_out_pkts[nb_enq], + pktmbuf_input_free_bulk(&enc_out_pkts[nb_enq], nb_rx - nb_enq); rte_bbdev_enc_op_free_bulk(&bbdev_ops_burst[nb_enq], nb_rx - nb_enq); @@ -805,7 +815,7 @@ run_encoding(struct lcore_conf *lcore_conf) nb_sent = rte_ring_enqueue_burst(enc_to_dec_ring, (void **)enc_out_pkts, nb_deq, NULL); if (unlikely(nb_sent < nb_deq)) { - pktmbuf_userdata_free_bulk(&enc_out_pkts[nb_sent], + pktmbuf_input_free_bulk(&enc_out_pkts[nb_sent], nb_deq - nb_sent); lcore_stats->enc_to_dec_lost_packets += nb_deq - nb_sent; } @@ -842,7 +852,7 @@ run_decoding(struct lcore_conf *lcore_conf) if (unlikely(rte_bbdev_dec_op_alloc_bulk(bbdev_op_pool, bbdev_ops_burst, nb_recv) != 0)) { - pktmbuf_userdata_free_bulk(recv_pkts_burst, nb_recv); + pktmbuf_input_free_bulk(recv_pkts_burst, nb_recv); lcore_stats->rx_lost_packets += nb_recv; return; } @@ -871,7 +881,7 @@ run_decoding(struct lcore_conf *lcore_conf) nb_enq = rte_bbdev_enqueue_dec_ops(bbdev_id, bbdev_queue_id, bbdev_ops_burst, nb_recv); if (unlikely(nb_enq < nb_recv)) { - pktmbuf_userdata_free_bulk(&recv_pkts_burst[nb_enq], + pktmbuf_input_free_bulk(&recv_pkts_burst[nb_enq], nb_recv - nb_enq); rte_bbdev_dec_op_free_bulk(&bbdev_ops_burst[nb_enq], nb_recv - nb_enq); @@ -898,12 +908,12 @@ run_decoding(struct lcore_conf *lcore_conf) /* Free the RX mbufs after verification */ for (i = 0; i < nb_deq; ++i) - rte_pktmbuf_free(recv_pkts_burst[i]->userdata); + rte_pktmbuf_free(*mbuf_input(recv_pkts_burst[i])); /* Transmit the packets */ nb_tx = rte_eth_tx_burst(port_id, tx_queue_id, recv_pkts_burst, nb_deq); if (unlikely(nb_tx < nb_deq)) { - pktmbuf_userdata_free_bulk(&recv_pkts_burst[nb_tx], + pktmbuf_input_free_bulk(&recv_pkts_burst[nb_tx], nb_deq - nb_tx); lcore_stats->tx_lost_packets += nb_deq - nb_tx; } @@ -1046,6 +1056,12 @@ main(int argc, char **argv) bool stats_thread_started = false; unsigned int main_lcore_id = rte_get_main_lcore(); + static const struct rte_mbuf_dynfield input_dynfield_desc = { + .name = "example_bbdev_dynfield_input", + .size = sizeof(struct rte_mbuf *), + .align = __alignof__(struct rte_mbuf *), + }; + rte_atomic16_init(&global_exit_flag); sigret = signal(SIGTERM, signal_handler); @@ -1115,6 +1131,12 @@ main(int argc, char **argv) if (bbdev_mbuf_mempool == NULL) rte_exit(EXIT_FAILURE, "Cannot create ethdev mbuf mempool\n"); + /* register mbuf field to store input pointer */ + input_dynfield_offset = + rte_mbuf_dynfield_register(&input_dynfield_desc); + if (input_dynfield_offset < 0) + rte_exit(EXIT_FAILURE, "Cannot register mbuf field\n"); + /* initialize ports */ ret = initialize_ports(&app_params, ethdev_mbuf_mempool); -- 2.28.0