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 92FC5457C3 for ; Wed, 14 Aug 2024 14:27:54 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8350540BA0; Wed, 14 Aug 2024 14:27:54 +0200 (CEST) Received: from mail-yb1-f182.google.com (mail-yb1-f182.google.com [209.85.219.182]) by mails.dpdk.org (Postfix) with ESMTP id 1916640274 for ; Wed, 14 Aug 2024 14:27:53 +0200 (CEST) Received: by mail-yb1-f182.google.com with SMTP id 3f1490d57ef6-e0b7efa1c1bso5786357276.3 for ; Wed, 14 Aug 2024 05:27:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723638472; x=1724243272; darn=dpdk.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=GfbbXLMgkg+gTJ2ngZjASr+uumJfzuCxNGqKJnxffU0=; b=B8jjOI7EoUDgTz2wdu6bfucbnNbPFT5I+2uLWUi3CRO69Nh//zZzby5/fRq2W+L8id Ytjoars0KXUDJi0nuGPSiC9kFCxFkCSdDE2uMI9V2tRAgTlXwbCatCKuVc62VVsorjar B0f2NFpXED1+MeYU70faANHm4xG29aLIV6CeUfRqGuYnRx/GIXQsezEPyJnnkhjQDcJK olmMsrGM8GesF0N1uGOW+zQ64TMU9UzjAk0nr5dtYug4jSq0iy81rwgkMgQUAM4bXLLx toFaAGvo3SgF0+UEGZVukDvxp+5muvmJ6xl9OxXoTsRUk6jjUAEvQqiKAoUnDlB1itxP A3bA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723638472; x=1724243272; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=GfbbXLMgkg+gTJ2ngZjASr+uumJfzuCxNGqKJnxffU0=; b=SxhewUV/pkAjS7d5hB29yK3gDSK7UoGlW0ug2L0ZyJMffnBbmkQbP9piQYd7aNqTIw 3f4xTNb2NfXjAq5XQmZCp4k6j2YWilg6TUKC9cvfJLbJZHTXAFFGGmJ4TivW3tuDRrCe MW+oUHhFec53VFQMK/b2T8YdKV+WFKtV/bWAiZeT5+3EMgVnqQS/Jv4/50gfkYRpIVIF ouKu9dNb80ocQKNCPHLj6uW3sYXcECuHblGswcA9bn7b5hvmRsRquQbaQsg99lp3QVRe vm5WtIHB473ivaSOujL1V6JN90F+4Py5q2uD51dA0bcl/jsZEfuJV0A3Birab325rZKZ q2+g== X-Gm-Message-State: AOJu0YziTWpQMQ/USe8NZZrGWa1hJjmw6Hp2bxLUA7kZWo6d2tZdFOZp B/kYZ7Yz+cz89JxPGM1Xe7hyPS9nwCJ1wi3kJTvAXkWab2j4Vk+e1VPQAB09PUKbj6d+RHeGsT7 ufaqVQ3/9rvqLVfAVARrTqsvqO4OZsFCzqc0= X-Google-Smtp-Source: AGHT+IEXIqSrVjEFK/cV3Cg9a298XMnXFwFXDD511yrbe5rZPcSqZLXzWTHY6CYLcvhXqVLQI9/XvGoK5t1ZL33rO0s= X-Received: by 2002:a05:6902:18d2:b0:e0b:3863:bca7 with SMTP id 3f1490d57ef6-e1155bb3d7bmr3203754276.37.1723638472206; Wed, 14 Aug 2024 05:27:52 -0700 (PDT) MIME-Version: 1.0 References: <20240812075216.534be9db@hermes.local> In-Reply-To: <20240812075216.534be9db@hermes.local> From: Lokesh Chakka Date: Wed, 14 Aug 2024 17:57:40 +0530 Message-ID: Subject: Re: reuse the packets after tx burst To: Stephen Hemminger Cc: users Content-Type: multipart/alternative; boundary="000000000000db723d061fa3da8f" 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 --000000000000db723d061fa3da8f Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable hi stephen, Thanks for your response. However it seems the solution is not working. The following is the modified snippet.... while( condition ) { for( pkt_count=3D0; pkt_count wrote: > On Mon, 12 Aug 2024 15:55:50 +0530 > Lokesh Chakka wrote: > > > 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, > rte_strerror(rte_errno) ); > > rte_exit( EXIT_FAILURE, "%s %d rte_eth_tx_burst port id: > %u\n", > > __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 > dev_info.max_mtu; > > > > } > > > > } > > > > Can someone help me understand how to reuse the packets again to send t= he > > same data ? > > > > 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 on= e > (not freed). > > Assume this is some kind of packet generator. > --000000000000db723d061fa3da8f Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
hi stephen,

Thanks for your = response. However it seems the solution is not working. The following is th= e modified snippet....

while( condition )
{
= =C2=A0=C2=A0=C2=A0=C2=A0 for( pkt_count=3D0; pkt_count<num_of_pkts_per_q= ueue; pkt_count++ )
=C2=A0=C2=A0=C2=A0=C2=A0 {
=C2=A0=C2=A0=C2=A0=C2= =A0 =C2=A0=C2=A0=C2=A0=C2=A0 rte_mbuf_refcnt_set( mbuf[pkt_count], 2 );//= setting to two - first and second iteration
=C2=A0=C2=A0=C2=A0=C2=A0 }=
=C2=A0=C2=A0=C2=A0=C2=A0 for( pkt_count=3D0; pkt_count<5; pkt_count= ++ )
=C2=A0=C2=A0=C2=A0=C2=A0 {
=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2= =A0=C2=A0=C2=A0 fprintf( stderr, "%s %d %u\n", __func__, __LINE= __, rte_mbuf_refcnt_read( mbuf[pkt_count] ) );//able to print two- first an= d second iteration
=C2=A0=C2=A0=C2=A0=C2=A0 }
=C2=A0=C2=A0=C2=A0=C2= =A0 if( rte_eth_tx_burst( port_id, 0, mbuf, num_of_pkts_per_queue ) !=3D n= um_of_pkts_per_queue )
=C2=A0=C2=A0=C2=A0=C2=A0 {
=C2=A0=C2=A0=C2=A0= =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 fprintf( stderr, "%s %d %d %s\n"= ;, __func__, __LINE__, rte_errno, rte_strerror(rte_errno) );//failing secon= d time
=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 rte_exit( EXI= T_FAILURE, "%s %d rte_eth_tx_burst port id: %u\n", __func__, __LI= NE__, port_id );
=C2=A0=C2=A0=C2=A0=C2=A0 }
=C2=A0=C2=A0=C2=A0=C2=A0= fprintf( stderr, "%s %d port: %u sent %u packets\n", __func__, = __LINE__, port_id, num_of_pkts_per_queue );//able to send once - first iter= ation only
=C2=A0=C2=A0=C2=A0=C2=A0 for( pkt_count=3D0; pkt_count<5;= pkt_count++ )
=C2=A0=C2=A0=C2=A0=C2=A0 {
=C2=A0=C2=A0=C2=A0=C2=A0 = =C2=A0=C2=A0=C2=A0=C2=A0 fprintf( stderr, "%s %d %u\n", __func_= _, __LINE__, rte_mbuf_refcnt_read( mbuf[pkt_count] ) );//refcnt is printing= one
=C2=A0=C2=A0=C2=A0=C2=A0 }
}

There seems to be some more gap in my unde= rstanding. Could you please help understand the issue?

Thanks & Regards
--
Lokesh Chakka.


On Mon, Aug 12, 2024= at 8:22=E2=80=AFPM Stephen Hemminger <stephen@networkplumber.org> wrote:
On Mon, 12 Aug 2024 15:55:50 +0530 Lokesh Chakka <lvenkatakumarchakka@gmail.com> wrote:

> hello,
>
> Here is a small piece of code :
>
> while( condition )
> {
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0if( rte_eth_tx_burst( port_id, 0, mbuf, num_= of_pkts_per_queue ) !=3D
> num_of_pkts_per_queue )
>=C2=A0 =C2=A0 =C2=A0 =C2=A0{
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0fprintf( stderr,= "%d %s\n", rte_errno, rte_strerror(rte_errno) );
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0rte_exit( EXIT_F= AILURE, "%s %d rte_eth_tx_burst port id: %u\n",
> __func__, __LINE__, port_id );//second iteration failing.
>=C2=A0 =C2=A0 =C2=A0 =C2=A0}
>=C2=A0 =C2=A0 =C2=A0 =C2=A0fprintf( 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
>=C2=A0 =C2=A0 =C2=A0 =C2=A0for( pkt_count=3D0; pkt_count<num_of_pkts= _per_queue; pkt_count++ )
>=C2=A0 =C2=A0 =C2=A0 =C2=A0{//want to send same data again...!!!
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0mbuf[pkt_count]-= >pkt_len =3D mbuf[pkt_count]->data_len =3D dev_info.max_mtu;
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0}
>
> }
>
> Can someone help me understand how to reuse the packets again to send = the
> same data ?
>

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 se= nding.
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.
--000000000000db723d061fa3da8f--