<div dir="ltr"><div>hi stephen,</div><div><br></div><div>Thanks for your response. However it seems the solution is not working. The following is the modified snippet....</div><div><br></div><div>while( condition )<br>{<br> for( pkt_count=0; pkt_count<num_of_pkts_per_queue; pkt_count++ )<br> {<br> rte_mbuf_refcnt_set( mbuf[pkt_count], 2 );// setting to two - first and second iteration<br> }<br> for( pkt_count=0; pkt_count<5; pkt_count++ )<br> {<br> fprintf( stderr, "%s %d %u\n", __func__, __LINE__, rte_mbuf_refcnt_read( mbuf[pkt_count] ) );//able to print two- first and second iteration<br> }<br> if( rte_eth_tx_burst( port_id, 0, mbuf, num_of_pkts_per_queue ) != num_of_pkts_per_queue )<br> {<br> fprintf( stderr, "%s %d %d %s\n", __func__, __LINE__, rte_errno, rte_strerror(rte_errno) );//failing second time<br> rte_exit( EXIT_FAILURE, "%s %d rte_eth_tx_burst port id: %u\n", __func__, __LINE__, port_id );<br> }<br> 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<br> for( pkt_count=0; pkt_count<5; pkt_count++ )<br> {<br> fprintf( stderr, "%s %d %u\n", __func__, __LINE__, rte_mbuf_refcnt_read( mbuf[pkt_count] ) );//refcnt is printing one<br> }<br>}<br></div><div><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><br></div><div>There seems to be some more gap in my understanding. Could you please help understand the issue?<br></div><div dir="ltr"><br>Thanks & Regards<br>--<br>Lokesh Chakka.</div></div></div></div></div></div></div></div></div></div></div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Aug 12, 2024 at 8:22 PM Stephen Hemminger <<a href="mailto:stephen@networkplumber.org">stephen@networkplumber.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Mon, 12 Aug 2024 15:55:50 +0530<br>
Lokesh Chakka <<a href="mailto:lvenkatakumarchakka@gmail.com" target="_blank">lvenkatakumarchakka@gmail.com</a>> wrote:<br>
<br>
> hello,<br>
> <br>
> Here is a small piece of code :<br>
> <br>
> while( condition )<br>
> {<br>
> <br>
> if( rte_eth_tx_burst( port_id, 0, mbuf, num_of_pkts_per_queue ) !=<br>
> num_of_pkts_per_queue )<br>
> {<br>
> fprintf( stderr, "%d %s\n", rte_errno, rte_strerror(rte_errno) );<br>
> rte_exit( EXIT_FAILURE, "%s %d rte_eth_tx_burst port id: %u\n",<br>
> __func__, __LINE__, port_id );//second iteration failing.<br>
> }<br>
> fprintf( stderr, "%s %d port: %u packet: %c sent %u packets\n",<br>
> __func__, __LINE__, port_id, argv[3][0], num_of_pkts_per_queue<br>
> );//printing once<br>
> for( pkt_count=0; pkt_count<num_of_pkts_per_queue; pkt_count++ )<br>
> {//want to send same data again...!!!<br>
> mbuf[pkt_count]->pkt_len = mbuf[pkt_count]->data_len = dev_info.max_mtu;<br>
> <br>
> }<br>
> <br>
> }<br>
> <br>
> Can someone help me understand how to reuse the packets again to send the<br>
> same data ?<br>
> <br>
<br>
When packet is passed to tx_burst, the ownership of that mbuf is passed<br>
to the driver. The driver will free it after it is sent.<br>
<br>
One option would be to increase the reference count on the packet before sending.<br>
Using rte_mbuf_refcnt_update() function to add one to refcount.<br>
Then the driver will decrement refcount and the refcount will still be one (not freed).<br>
<br>
Assume this is some kind of packet generator.<br>
</blockquote></div>