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 56FF2A0545; Tue, 11 Oct 2022 15:28:05 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 45B5642DE1; Tue, 11 Oct 2022 15:28:05 +0200 (CEST) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by mails.dpdk.org (Postfix) with ESMTP id 3CE3F42B7D for ; Tue, 11 Oct 2022 15:28:04 +0200 (CEST) Received: from dggpeml500024.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4MmxN30YnszpVds; Tue, 11 Oct 2022 21:24:51 +0800 (CST) Received: from [10.67.100.224] (10.67.100.224) by dggpeml500024.china.huawei.com (7.185.36.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 11 Oct 2022 21:28:01 +0800 Subject: Re: [PATCH v4] net/bonding: call Tx prepare before Tx burst To: Chas Williams <3chas3@gmail.com>, , CC: , , , , References: <1619171202-28486-2-git-send-email-tangchengchang@huawei.com> <20221009033639.38232-1-fengchengwen@huawei.com> From: fengchengwen Message-ID: Date: Tue, 11 Oct 2022 21:28:00 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 8bit X-Originating-IP: [10.67.100.224] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpeml500024.china.huawei.com (7.185.36.10) X-CFilter-Loop: Reflected X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Hi Chas, On 2022/10/11 3:42, Chas Williams wrote: > > > On 10/8/22 23:36, Chengwen Feng wrote: >>       uint16_t slaves[RTE_MAX_ETHPORTS]; >>       uint8_t tx_failed_flag = 0; >>       uint16_t num_of_slaves; >> +    uint16_t num_tx_prep; >>         uint16_t max_nb_of_tx_pkts = 0; >>   @@ -1320,12 +1339,18 @@ bond_ethdev_tx_burst_broadcast(void *queue, struct rte_mbuf **bufs, >>       for (i = 0; i < nb_pkts; i++) >>           rte_pktmbuf_refcnt_update(bufs[i], num_of_slaves - 1); >>   +    /* It is rare that bond different PMDs together, so just call tx-prepare once */ >> +    num_tx_prep = rte_eth_tx_prepare(slaves[0], bd_tx_q->queue_id, >> +                    bufs, nb_pkts); > > You probably want to do this before you update the refcnt on the mbufs. > Otherwise, the common rte_eth_tx_prepare operation, rte_vlan_insert, will > fail since the refcnt will not be 1. nice catch v5 already sent to fix it, please review it. Thanks > >> +    if (unlikely(num_tx_prep < nb_pkts)) >> +        tx_failed_flag = 1; >> + >>       /* Transmit burst on each active slave */ >>       for (i = 0; i < num_of_slaves; i++) { >>           slave_tx_total[i] = rte_eth_tx_burst(slaves[i], bd_tx_q->queue_id, >> -                    bufs, nb_pkts); >> +                    bufs, num_tx_prep); >>   -        if (unlikely(slave_tx_total[i] < nb_pkts)) >> +        if (unlikely(slave_tx_total[i] < num_tx_prep)) >>               tx_failed_flag = 1; >>             /* record the value and slave index for the slave which transmits the >> diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h >> index e8d1e1c658..b0396bb86e 100644 >> --- a/lib/ethdev/rte_ethdev.h >> +++ b/lib/ethdev/rte_ethdev.h >> @@ -6031,6 +6031,10 @@ uint16_t rte_eth_call_tx_callbacks(uint16_t port_id, uint16_t queue_id, >>    * @see rte_eth_tx_prepare to perform some prior checks or adjustments >>    * for offloads. >>    * >> + * @note This function must not modify mbufs (including packets data) unless >> + * the refcnt is 1. The exception is the bonding PMD, which does not have >> + * tx-prepare function, in this case, mbufs maybe modified. > > Exactly. See my comment about calling prepare before you modify the refcnt. > >> + * >>    * @param port_id >>    *   The port identifier of the Ethernet device. >>    * @param queue_id > .