On 7/25/2022 5:08 AM, Chengwen Feng wrote:
Normally, to use the HW offloads capability (e.g. checksum and TSO) in the Tx direction, the application needs to call rte_eth_dev_prepare to do some adjustment with the packets before sending them (e.g. processing pseudo headers when Tx checksum offload enabled). But, the tx_prepare callback of the bonding driver is not implemented. Therefore, the sent packets may have errors (e.g. checksum errors). However, it is difficult to design the tx_prepare callback for bonding driver. Because when a bonded device sends packets, the bonded device allocates the packets to different slave devices based on the real-time link status and bonding mode. That is, it is very difficult for the bonded device to determine which slave device's prepare function should be invoked. So, in this patch, the tx_prepare callback of bonding driver is not implemented. Instead, the rte_eth_dev_tx_prepare() will be called for all the fast path packets in mode 0, 1, 2, 4, 5, 6 (mode 3 is not included, see[1]). In this way, all tx_offloads can be processed correctly for all NIC devices in these modes. As previously discussed (see V1), if the tx_prepare fails, the bonding driver will free the cossesponding packets internally, and only the packets of the tx_prepare OK are xmit.
Please provide link to discussion you refer to.
To minimize performance impact, this patch adds one new 'tx_prepare_enabled' field, and corresponding control and get API: rte_eth_bond_tx_prepare_set() and rte_eth_bond_tx_prepare_get(). [1]: In bond mode 3 (broadcast), a packet needs to be sent by all slave ports. Different slave PMDs process the packets differently in tx_prepare. If call tx_prepare before each slave port sending, the sent packet may be incorrect. Signed-off-by: Chengchang Tang <tangchengch...@huawei.com> Signed-off-by: Chengwen Feng <fengcheng...@huawei.com>
<...>
+static inline uint16_t +bond_ethdev_tx_wrap(struct bond_tx_queue *bd_tx_q, uint16_t slave_port_id, + struct rte_mbuf **tx_pkts, uint16_t nb_pkts) +{ + struct bond_dev_private *internals = bd_tx_q->dev_private; + uint16_t queue_id = bd_tx_q->queue_id; + struct rte_mbuf *fail_pkts[nb_pkts]; + uint8_t fail_mark[nb_pkts]; + uint16_t nb_pre, index; + uint16_t fail_cnt = 0; + int i; + + if (!internals->tx_prepare_enabled) + goto tx_burst; + + nb_pre = rte_eth_tx_prepare(slave_port_id, queue_id, tx_pkts, nb_pkts); + if (nb_pre == nb_pkts) + goto tx_burst; + + fail_pkts[fail_cnt++] = tx_pkts[nb_pre]; + memset(fail_mark, 0, sizeof(fail_mark)); + fail_mark[nb_pre] = 1; + for (i = nb_pre + 1; i < nb_pkts; /* update in inner loop */) { + nb_pre = rte_eth_tx_prepare(slave_port_id, queue_id, + tx_pkts + i, nb_pkts - i);
I assume intention is to make this as transparent as possible to the user, that is why you are using a wrapper that combines `rte_eth_tx_prepare()` & `rte_eth_tx_burst()` APIs. But for other PMDs `rte_eth_tx_burst()` is called explicitly by the application.
Path is also adding two new bonding specific APIs to enable/disable Tx prepare. Instead if you leave calling `rte_eth_tx_prepare()` decision to user, there will be no need for the enable/disable Tx prepare APIs and the wrapper.
The `tx_pkt_prepare()` implementation in bonding can do the mode check, call Tx prepare for all slaves and apply failure recovery, as done in this wrapper function, what do you think, will it work?