From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 44DE4A00C3; Wed, 15 Dec 2021 13:41:04 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C857340688; Wed, 15 Dec 2021 13:41:03 +0100 (CET) Received: from mail-io1-f48.google.com (mail-io1-f48.google.com [209.85.166.48]) by mails.dpdk.org (Postfix) with ESMTP id 0FD2740041 for ; Wed, 15 Dec 2021 13:41:03 +0100 (CET) Received: by mail-io1-f48.google.com with SMTP id e128so29847804iof.1 for ; Wed, 15 Dec 2021 04:41:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=6MvThBi+m58GVXMKDEoJsvR0IiSTIGdJr33Rm6EGz48=; b=VKustuFW7vS0oJltIReIJOYvsPvyOkoFLefcd1NtvCrfLx7r+OhZBQFJluEI3dyJIg kj6R7wZ9wSB5SVX6UPLClCwHSDbJIzi3IW5Zi+IW9Tm13l/t6D1uKugIVI6lptiMQg0M IcPQLvKBt9tfn1T21Mi4t6tTJDarByFSNQla3aZvDHlcWzynqqNdl0rshv4Jfyf0sa2z VslxOPUmYX0yjHAA/tTs5HoOuPG73A6cFQ4W61itGCAPLAiGL+1Zp57V/UHP669nb9tG meaGdp0spHg6IYq7NB6QRsTgok63yLMwIvUD2YlAdzs2rwl2A9OTY8DAcYgOlrf3qAb6 nj9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=6MvThBi+m58GVXMKDEoJsvR0IiSTIGdJr33Rm6EGz48=; b=0idfgIS7Snpw2JSiIJe3l2+0p8cPnDojD6k1yWkzhVh+jmaWvJXeSAOYu+4OuEOPjp ABm8JY1ALmTbYacLSCt+3up0uEHtfpptl8graLAAuM+YuecmI9Fu32U2spU63asUV+N/ VSFuKtzRqdWdukaHiHbbYes7ftnI66lNXjM/ICmLM3C4VDGJG26KzQdJSeZzKCaiuhFu 5wPB9Iw2L57lyq7R+WUCitAJAZCFt/QjExCQteKLbu9kH9+p57RpFCiXIIZ7WVsYBa7W 9mLHSQgruSfQaTsArZYu1LTfB8d20YGyhoLARFpw0RmHgNgB7VfFoW89Um7xAz3EGNaV F9LA== X-Gm-Message-State: AOAM530qQ+o7eXdrojOvRAdHSBhpE3ThJDRtafIOIHNZRUFwQOF22/1l yfOaHhEXVuE3c8t8+w+gANr9NvNYojOe3VQamRE= X-Google-Smtp-Source: ABdhPJye7E6J57Wyo05B5PjtVafcHil5KoFg8aLwrrT8TESQ8Omt7Kj6eoifA/5jHgRJbJUJ8pRJX9vm+7Car/TZex4= X-Received: by 2002:a02:1901:: with SMTP id b1mr5692129jab.592.1639572062344; Wed, 15 Dec 2021 04:41:02 -0800 (PST) MIME-Version: 1.0 References: <20211214141242.3383831-1-ronan.randles@intel.com> <20211214141242.3383831-6-ronan.randles@intel.com> In-Reply-To: <20211214141242.3383831-6-ronan.randles@intel.com> From: Jerin Jacob Date: Wed, 15 Dec 2021 18:10:36 +0530 Message-ID: Subject: Re: [PATCH 05/12] gen: add raw packet data API and tests To: Ronan Randles Cc: dpdk-dev , "Van Haaren, Harry" Content-Type: text/plain; charset="UTF-8" X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On Tue, Dec 14, 2021 at 7:43 PM Ronan Randles wrote: > > From: Harry van Haaren > > This commit adds a new API to gen, allowing the caller to set > raw packet data with a size. Tests are added to test the new > API with randomized packet data. > > Signed-off-by: Harry van Haaren > --- > } > > @@ -32,9 +53,37 @@ rte_gen_create(struct rte_mempool *mempool) > void > rte_gen_destroy(struct rte_gen *gen) > { > + rte_pktmbuf_free(gen->base_pkt); > rte_free(gen); > } > > + > uint16_t > rte_gen_rx_burst(struct rte_gen *gen, > struct rte_mbuf **rx_pkts, > @@ -45,17 +94,20 @@ rte_gen_rx_burst(struct rte_gen *gen, > if (err) > return 0; > > - const uint32_t pkt_len = 64; > + if (!gen->base_pkt) > + return 0; > + > + const uint32_t base_size = gen->base_pkt->pkt_len; > + const uint8_t *base_data = rte_pktmbuf_mtod(gen->base_pkt, uint8_t *); I think, the very next feature will be generating packets for incrementing IP addresses or so. In this case, one packet-based template will not work. May we worth consider that use case into API framework first and add support later for implementation as it may change the complete land space of API to have better performance. Options like struct rte_gen logical object can have N templates instead of one is an option on the table. :-) > > uint32_t i; > for (i = 0; i < nb_pkts; i++) { > struct rte_mbuf *m = rx_pkts[i]; > uint8_t *pkt_data = rte_pktmbuf_mtod(m, uint8_t *); > > - memset(pkt_data, 0, pkt_len); > - > - m->pkt_len = pkt_len; > - m->data_len = pkt_len; > + rte_memcpy(pkt_data, base_data, base_size); > + m->pkt_len = base_size; > + m->data_len = base_size; > } >