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 71F5145B50; Wed, 16 Oct 2024 11:05:45 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3A7D540144; Wed, 16 Oct 2024 11:05:45 +0200 (CEST) Received: from dkmailrelay1.smartsharesystems.com (smartserver.smartsharesystems.com [77.243.40.215]) by mails.dpdk.org (Postfix) with ESMTP id 6AA8E400D6 for ; Wed, 16 Oct 2024 11:05:44 +0200 (CEST) Received: from smartserver.smartsharesystems.com (smartserver.smartsharesys.local [192.168.4.10]) by dkmailrelay1.smartsharesystems.com (Postfix) with ESMTP id 633C92099F; Wed, 16 Oct 2024 11:05:43 +0200 (CEST) Content-class: urn:content-classes:message Subject: RE: [PATCH] examples/l3fwd: support setting the data size of mbuf Date: Wed, 16 Oct 2024 11:05:42 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Message-ID: <98CBD80474FA8B44BF855DF32C47DC35E9F7ED@smartserver.smartshare.dk> In-Reply-To: <20241016082232.4005800-1-chaoyong.he@corigine.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PATCH] examples/l3fwd: support setting the data size of mbuf X-MimeOLE: Produced By Microsoft Exchange V6.5 Thread-Index: AdsfpKFGCItJLEWCRoeqlrxWKd9JuQAAuqhg References: <20241016082232.4005800-1-chaoyong.he@corigine.com> From: =?iso-8859-1?Q?Morten_Br=F8rup?= To: "Chaoyong He" , Cc: , "Long Wu" 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 > From: Chaoyong He [mailto:chaoyong.he@corigine.com] > Sent: Wednesday, 16 October 2024 10.23 >=20 > From: Long Wu >=20 > The previous code used a macro as the data size for mbuf > to create the mempool and users cannot modify the size. >=20 > Now modify the code to support setting the data size of > mbuf by '--mbuf-size' parameter. If user does not add the > parameter in start command line, the default size is still > 'RTE_MBUF_DEFAULT_BUF_SIZE'. >=20 > Examples: > dpdk-l3fwd -l 0-3 -- -p 0x03 --mbuf-size=3D4096 >=20 > Signed-off-by: Long Wu > Reviewed-by: Chaoyong He > --- > examples/l3fwd/main.c | 17 ++++++++++++++--- > 1 file changed, 14 insertions(+), 3 deletions(-) >=20 > diff --git a/examples/l3fwd/main.c b/examples/l3fwd/main.c > index 01b763e5ba..ccce16c6bb 100644 > --- a/examples/l3fwd/main.c > +++ b/examples/l3fwd/main.c > @@ -140,6 +140,7 @@ uint32_t max_pkt_len; > #ifdef RTE_LIB_EVENTDEV > static struct rte_mempool *vector_pool[RTE_MAX_ETHPORTS]; > #endif > +static uint16_t mbuf_seg_size =3D RTE_MBUF_DEFAULT_BUF_SIZE; Prefer variable using same offset as command line parameter: static uint16_t mbuf_data_size =3D RTE_MBUF_DEFAULT_DATAROOM; > static struct rte_mempool = *pktmbuf_pool[RTE_MAX_ETHPORTS][NB_SOCKETS]; > static uint8_t lkp_per_socket[NB_SOCKETS]; >=20 > @@ -448,7 +449,8 @@ print_usage(const char *prgname) > " One is ACL entry at while line leads > with character '%c',\n" > " another is route entry at while line > leads with character '%c'.\n" > " --rule_ipv6=3DFILE: Specify the ipv6 rules entries > file.\n" > - " --alg: ACL classify method to use, one of: %s.\n\n", > + " --alg: ACL classify method to use, one of: %s.\n" > + " --mbuf-size=3DN: Set the data size of mbuf to N > bytes.\n\n", > prgname, RX_DESC_DEFAULT, TX_DESC_DEFAULT, > ACL_LEAD_CHAR, ROUTE_LEAD_CHAR, alg); > } > @@ -698,6 +700,7 @@ static const char short_options[] =3D > #define CMD_LINE_OPT_RULE_IPV4 "rule_ipv4" > #define CMD_LINE_OPT_RULE_IPV6 "rule_ipv6" > #define CMD_LINE_OPT_ALG "alg" > +#define CMD_LINE_OPT_MBUF_SIZE "mbuf-size" >=20 > enum { > /* long options mapped to a short option */ > @@ -726,7 +729,8 @@ enum { > CMD_LINE_OPT_LOOKUP_NUM, > CMD_LINE_OPT_ENABLE_VECTOR_NUM, > CMD_LINE_OPT_VECTOR_SIZE_NUM, > - CMD_LINE_OPT_VECTOR_TMO_NS_NUM > + CMD_LINE_OPT_VECTOR_TMO_NS_NUM, > + CMD_LINE_OPT_MBUF_SIZE_NUM, > }; >=20 > static const struct option lgopts[] =3D { > @@ -753,6 +757,7 @@ static const struct option lgopts[] =3D { > {CMD_LINE_OPT_RULE_IPV4, 1, 0, CMD_LINE_OPT_RULE_IPV4_NUM}, > {CMD_LINE_OPT_RULE_IPV6, 1, 0, CMD_LINE_OPT_RULE_IPV6_NUM}, > {CMD_LINE_OPT_ALG, 1, 0, CMD_LINE_OPT_ALG_NUM}, > + {CMD_LINE_OPT_MBUF_SIZE, 1, 0, CMD_LINE_OPT_MBUF_SIZE_NUM}, > {NULL, 0, 0, 0} > }; >=20 > @@ -934,6 +939,12 @@ parse_args(int argc, char **argv) > case CMD_LINE_OPT_ALG_NUM: > l3fwd_set_alg(optarg); > break; > + case CMD_LINE_OPT_MBUF_SIZE_NUM: > + mbuf_seg_size =3D strtoul(optarg, NULL, 10) + > RTE_PKTMBUF_HEADROOM; > + if (mbuf_seg_size <=3D 0 || mbuf_seg_size > 0xFFFF) > + rte_exit(EXIT_FAILURE, > + "mbuf-size should be > 0 and < > 65536\n"); mbuf_data_size =3D strtoul(optarg, NULL, 10); if (mbuf_data_size =3D=3D ULONG_MAX) rte_exit(EXIT_FAILURE, "mbuf-size should be a number\n"); if (mbuf_data_size < RTE_ETHER_MIN_LEN || mbuf_data_size > 0xFFFF - RTE_PKTMBUF_HEADROOM) rte_exit(EXIT_FAILURE, "mbuf-size should be >=3D %u and <=3D %u\n", RTE_ETHER_MIN_LEN, 0xFFFF - RTE_PKTMBUF_HEADROOM); > + break; > default: > print_usage(prgname); > return -1; > @@ -1034,7 +1045,7 @@ init_mem(uint16_t portid, unsigned int nb_mbuf) > pktmbuf_pool[portid][socketid] =3D > rte_pktmbuf_pool_create(s, nb_mbuf, > MEMPOOL_CACHE_SIZE, 0, > - RTE_MBUF_DEFAULT_BUF_SIZE, socketid); > + mbuf_seg_size, socketid); mbuf_data_size + RTE_PKTMBUF_HEADROOM, socketid); > if (pktmbuf_pool[portid][socketid] =3D=3D NULL) > rte_exit(EXIT_FAILURE, > "Cannot init mbuf pool on socket %d\n", > -- > 2.39.1 With above changes, Acked-by: Morten Br=F8rup