On 2021/2/8 16:40, Olivier Matz wrote:
Hi,
On Mon, Feb 08, 2021 at 09:07:39AM +0100, Thomas Monjalon wrote:
08/02/2021 07:29, Chengchang Tang:
Hi, Thomas Monjalon and Ferruh Yigit and others.
Here are two questions:
- What functions should be included in the 'tx_prepare' for PMDs?
- Whether an app must invoke 'rte_eth_tx_prepare' or under which
conditions an app must invoke the 'rte_eth_tx_prepare'?
I would say by default the app should prepare the checksums, except if there is an explicit offload request (DEV_TX_OFFLOAD_*). I think the tx_prepare should only prepare the HW Tx offload if the offload is not entirely done in HW.
On our side, we call tx_prepare() on a tx bulk if:
1/ a Tx offload is enabled on the port (DEV_TX_OFFLOAD_*) 2/ at least one mbuf in the bulk has an offload flag among PKT_TX_OFFLOAD_MASK
The purpose of tx_prepare() is to check that offload can be done in hw, and to prepare the packet data for the hw. For instance, niantics NICs require that the L4 checksum in the packet is set to the pseudo-header checksum.
This could have be done in the tx() function, but it is a separated function for 2 reasons:
- the application does not need to call it if it does not do hw tx offload
- the tx_prepare() function may modify packet data, which should not be the case for tx(). In a pipeline model, these 2 functions may be called on different cores.
In my opinion, the tx_prepare() function should deal with outer checksums preparation as well.
Olivier
.
Thank you, Thomas and Olivier. It's really helpful.
Chengchang