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 4629A457C4 for ; Wed, 14 Aug 2024 16:59:07 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 23BDC402C4; Wed, 14 Aug 2024 16:59:07 +0200 (CEST) Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) by mails.dpdk.org (Postfix) with ESMTP id 1A16640274 for ; Wed, 14 Aug 2024 16:59:04 +0200 (CEST) Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-70d199fb3dfso5441159b3a.3 for ; Wed, 14 Aug 2024 07:59:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1723647544; x=1724252344; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=BOPcrCMlSvQ11QC2ZYPm8d+sNmTui22NpDIQDbkx9ow=; b=JEKifPG5TJgd36SCcFDQaHN6nbJ98H661ruAtJeL+Vzi6qnFQLq+py5Pf1nkb9Ml1N hPB0W7nKOfoQePGFUl3MvpiDYGOI3NVQKjU42tUgcGBgTpR+lrL+heX7dJ+KHiWdxaH7 WIHkpT6/EzMZjZ5qkvZYhpbupaAnb8xp/1H3z7ZvHUmPNeyA5huPXacRqdZwwNUFvb3C 3N3EGfhEWs9xp4k7x66A6qbJXftcbdAu0+7b8q3vOSXx/3fWeEXnsJLwfbFM7OB8edsj tYJPLLVGleC/Kyg5WLOD03Z0dQ/UuINJymTMDrWTGPyYvlS2JZ0ceUPNk1PkSjIWgs95 Gx2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723647544; x=1724252344; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BOPcrCMlSvQ11QC2ZYPm8d+sNmTui22NpDIQDbkx9ow=; b=P2r1a2GoR4b/dd+9BP8cQhq6j6wH+3LZKfKXLS3G07fQCm/Wo5W7ofBI8sAvEdAWuh /LWnFf9enX9XOkRQBlErsKNW70jfglLFHhB6oSMaSqQyGEb11964p9L2n0VEZ13/lpCJ 5ywt/0QBiJsYFm0hatLwoIWqq6EiPTEQ9AP046j2Vy9oHZlNnQ+p/x7no7xc2g0QuMf+ lT8mX05JdXcHIkS5iZ3B4BhP0x4/RmBO0xPXJUHri/5+H3kbi8bV0xcGVOK/+SIYvudz Sz+pov6QeZ7FH6m4ZKpTXMtZL25+xN2lTgBZkw39yvFiL3LbemaYgtWGth+JgkrtjMDF V5+A== X-Gm-Message-State: AOJu0YwTqGSyvO7/JW53obVUwFlik/wSvQRNAdAH3VJ1S4jQ1vZ5dARL P3wFiubQ9As/ICiaKUL3Yuu68OaQVywN6MDeWbF9hzhs8agpa0BAQj+AQSzhVbk= X-Google-Smtp-Source: AGHT+IHqrPlGvCUQPA4BsXMnM3dHyk4xDyZJqFf7Bnst+K/+fXgJ7mYmrLqH+hzPJqHZEB6SRaQjgg== X-Received: by 2002:a05:6a00:981:b0:70e:98e3:1c17 with SMTP id d2e1a72fcca58-712673e5e69mr3342113b3a.27.1723647543861; Wed, 14 Aug 2024 07:59:03 -0700 (PDT) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-712708367a1sm842748b3a.24.2024.08.14.07.59.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Aug 2024 07:59:03 -0700 (PDT) Date: Wed, 14 Aug 2024 07:59:02 -0700 From: Stephen Hemminger To: Lokesh Chakka Cc: users Subject: Re: reuse the packets after tx burst Message-ID: <20240814075902.187cda3f@hermes.local> In-Reply-To: References: <20240812075216.534be9db@hermes.local> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: users@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK usage discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: users-bounces@dpdk.org On Wed, 14 Aug 2024 17:57:40 +0530 Lokesh Chakka wrote: > hi stephen, >=20 > Thanks for your response. However it seems the solution is not working. T= he > following is the modified snippet.... >=20 > while( condition ) > { > for( pkt_count=3D0; pkt_count { > rte_mbuf_refcnt_set( mbuf[pkt_count], 2 );// setting to two - > first and second iteration > } > for( pkt_count=3D0; pkt_count<5; pkt_count++ ) > { > fprintf( stderr, "%s %d %u\n", __func__, __LINE__, > rte_mbuf_refcnt_read( mbuf[pkt_count] ) );//able to print two- first and > second iteration > } > if( rte_eth_tx_burst( port_id, 0, mbuf, num_of_pkts_per_queue ) !=3D > num_of_pkts_per_queue ) > { > fprintf( stderr, "%s %d %d %s\n", __func__, __LINE__, rte_errno, > rte_strerror(rte_errno) );//failing second time > rte_exit( EXIT_FAILURE, "%s %d rte_eth_tx_burst port id: %u\n", > __func__, __LINE__, port_id ); > } > fprintf( stderr, "%s %d port: %u sent %u packets\n", __func__, > __LINE__, port_id, num_of_pkts_per_queue );//able to send once - first > iteration only > for( pkt_count=3D0; pkt_count<5; pkt_count++ ) > { > fprintf( stderr, "%s %d %u\n", __func__, __LINE__, > rte_mbuf_refcnt_read( mbuf[pkt_count] ) );//refcnt is printing one > } > } >=20 > There seems to be some more gap in my understanding. Could you please help > understand the issue? >=20 > Thanks & Regards > -- > Lokesh Chakka. >=20 >=20 > On Mon, Aug 12, 2024 at 8:22=E2=80=AFPM Stephen Hemminger < > stephen@networkplumber.org> wrote: =20 >=20 > > On Mon, 12 Aug 2024 15:55:50 +0530 > > Lokesh Chakka wrote: > > =20 > > > hello, > > > > > > Here is a small piece of code : > > > > > > while( condition ) > > > { > > > > > > if( rte_eth_tx_burst( port_id, 0, mbuf, num_of_pkts_per_queue )= !=3D > > > num_of_pkts_per_queue ) > > > { > > > fprintf( stderr, "%d %s\n", rte_errno, =20 > > rte_strerror(rte_errno) ); =20 > > > rte_exit( EXIT_FAILURE, "%s %d rte_eth_tx_burst port id= : =20 > > %u\n", =20 > > > __func__, __LINE__, port_id );//second iteration failing. > > > } > > > fprintf( stderr, "%s %d port: %u packet: %c sent %u packets\n", > > > __func__, __LINE__, port_id, argv[3][0], num_of_pkts_per_queue > > > );//printing once > > > for( pkt_count=3D0; pkt_count > > {//want to send same data again...!!! > > > mbuf[pkt_count]->pkt_len =3D mbuf[pkt_count]->data_len = =3D =20 > > dev_info.max_mtu; =20 > > > > > > } > > > > > > } > > > > > > Can someone help me understand how to reuse the packets again to send= the > > > same data ? > > > =20 > > > > When packet is passed to tx_burst, the ownership of that mbuf is passed > > to the driver. The driver will free it after it is sent. > > > > One option would be to increase the reference count on the packet before > > sending. > > Using rte_mbuf_refcnt_update() function to add one to refcount. > > Then the driver will decrement refcount and the refcount will still be = one > > (not freed). > > > > Assume this is some kind of packet generator. > > =20 Don't use refcnt_set(), you want to add an additional refcount not force it= to two. The device driver may hold onto the mbuf for a while after it was passed to= tx_burst so can't assume a value of two. If the number actually queued is less that the number requested, that means= the device transmit queue is now full. Need to handle that case. Something like this might get you started: volatile running =3D true; void flood(uint16_t port_id, struct rte_mbufs *mbufs[], uint16_t num_pkts) { while (running) { /* Add additional reference to retain the packets */ for (uint16_t i =3D 0; i < num_pkts; i++) rte_mbuf_refcnt_update(mbufs[i], 1); uint16_t sent =3D rte_eth_tx_burst(port_id, queue_id, mbufs, num_pkts); if (sent < num_pkts) { /* device transmit queue was full, drop our reference */ for (uint16_t i =3D sent; i < num_pkts; i++) rte_pktmbuf_free(mbufs[i]); } } /* Don't leak original version */ rte_pktmbuf_free_bulk(mbufs, num_pkts); } =09