net/bonding: fix mbuf fast free usage

Message ID 20220521070814.35704-1-humin29@huawei.com (mailing list archive)
State Changes Requested, archived
Delegated to: Ferruh Yigit
Headers
Series net/bonding: fix mbuf fast free usage |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/github-robot: build success github build: passed
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS

Commit Message

humin (Q) May 21, 2022, 7:08 a.m. UTC
  Usage of 'RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE' offload has two
constraints: per-queue all mbufs comes from the same mempool and
has refcnt = 1.

Bonding mode Broadcast, Tx mbuf has more than one refcnt.
Bonding mode 8023AD, It contains two mempools separately for LACP
packets and other packets. In Tx or Rx, Fast mbuf free will operate
mbuf from different mempool.

This patch will prevent 'RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE' offload
when in bonding mode Broadcast and mode 8023AD.

Fixes: 78aecefed955 ("bond: move param parsing in configure step")
Cc: stable@dpdk.org

Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
 drivers/net/bonding/rte_eth_bond_pmd.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
  

Comments

Ferruh Yigit May 24, 2022, 1:43 p.m. UTC | #1
On 5/21/2022 8:08 AM, Min Hu (Connor) wrote:
> [CAUTION: External Email]
> 
> Usage of 'RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE' offload has two
> constraints: per-queue all mbufs comes from the same mempool and
> has refcnt = 1.
> 
> Bonding mode Broadcast, Tx mbuf has more than one refcnt.
> Bonding mode 8023AD, It contains two mempools separately for LACP
> packets and other packets. In Tx or Rx, Fast mbuf free will operate
> mbuf from different mempool.
> 
> This patch will prevent 'RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE' offload
> when in bonding mode Broadcast and mode 8023AD.
> 

Hi Connor,

Please find a few syntax comment below, rest lgtm.

> Fixes: 78aecefed955 ("bond: move param parsing in configure step")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
> ---
>   drivers/net/bonding/rte_eth_bond_pmd.c | 10 ++++++++++
>   1 file changed, 10 insertions(+)
> 
> diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c
> index c929b55768..5ca90c7590 100644
> --- a/drivers/net/bonding/rte_eth_bond_pmd.c
> +++ b/drivers/net/bonding/rte_eth_bond_pmd.c
> @@ -3563,6 +3563,7 @@ bond_ethdev_configure(struct rte_eth_dev *dev)
>          const char *name = dev->device->name;
>          struct bond_dev_private *internals = dev->data->dev_private;
>          struct rte_kvargs *kvlist = internals->kvlist;
> +       uint64_t offloads;
>          int arg_count;
>          uint16_t port_id = dev - rte_eth_devices;
>          uint8_t agg_mode;
> @@ -3613,6 +3614,15 @@ bond_ethdev_configure(struct rte_eth_dev *dev)
>                  }
>          }
> 
> +       offloads = dev->data->dev_conf.txmode.offloads;
> +       if ((offloads & RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE) &&
> +               (internals->mode == BONDING_MODE_8023AD ||
> +               internals->mode == BONDING_MODE_BROADCAST)) {

Can you indent above two lines one more tab, to differentiate them from 
content of the if block.

> +               RTE_BOND_LOG(WARNING, "BOND MODE Broadcast & 8023AD don't support MBUF_FAST_FREE offload, force disable it.");

- Why "BOND MODE" is uppercase, if there is no special reason for it, I 
suggest using lower case.

- Can you break the message to next line, this enables shorter line 
without breaking the message:
RTE_BOND_LOG(WARNING,
	"BOND MODE Broadcast & 8023AD don't support ....

> +               offloads &= ~RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE;
> +               dev->data->dev_conf.txmode.offloads = offloads;
> +       }
> +
>          /* set the max_rx_pktlen */
>          internals->max_rx_pktlen = internals->candidate_max_rx_pktlen;
> 
> --
> 2.33.0
>
  
humin (Q) May 25, 2022, 1:11 a.m. UTC | #2
Thanks Ferruh,
	v2 has been sent.

在 2022/5/24 21:43, Ferruh Yigit 写道:
> On 5/21/2022 8:08 AM, Min Hu (Connor) wrote:
>> [CAUTION: External Email]
>>
>> Usage of 'RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE' offload has two
>> constraints: per-queue all mbufs comes from the same mempool and
>> has refcnt = 1.
>>
>> Bonding mode Broadcast, Tx mbuf has more than one refcnt.
>> Bonding mode 8023AD, It contains two mempools separately for LACP
>> packets and other packets. In Tx or Rx, Fast mbuf free will operate
>> mbuf from different mempool.
>>
>> This patch will prevent 'RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE' offload
>> when in bonding mode Broadcast and mode 8023AD.
>>
> 
> Hi Connor,
> 
> Please find a few syntax comment below, rest lgtm.
> 
>> Fixes: 78aecefed955 ("bond: move param parsing in configure step")
>> Cc: stable@dpdk.org
>>
>> Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
>> ---
>>   drivers/net/bonding/rte_eth_bond_pmd.c | 10 ++++++++++
>>   1 file changed, 10 insertions(+)
>>
>> diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c 
>> b/drivers/net/bonding/rte_eth_bond_pmd.c
>> index c929b55768..5ca90c7590 100644
>> --- a/drivers/net/bonding/rte_eth_bond_pmd.c
>> +++ b/drivers/net/bonding/rte_eth_bond_pmd.c
>> @@ -3563,6 +3563,7 @@ bond_ethdev_configure(struct rte_eth_dev *dev)
>>          const char *name = dev->device->name;
>>          struct bond_dev_private *internals = dev->data->dev_private;
>>          struct rte_kvargs *kvlist = internals->kvlist;
>> +       uint64_t offloads;
>>          int arg_count;
>>          uint16_t port_id = dev - rte_eth_devices;
>>          uint8_t agg_mode;
>> @@ -3613,6 +3614,15 @@ bond_ethdev_configure(struct rte_eth_dev *dev)
>>                  }
>>          }
>>
>> +       offloads = dev->data->dev_conf.txmode.offloads;
>> +       if ((offloads & RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE) &&
>> +               (internals->mode == BONDING_MODE_8023AD ||
>> +               internals->mode == BONDING_MODE_BROADCAST)) {
> 
> Can you indent above two lines one more tab, to differentiate them from 
> content of the if block.
> 
>> +               RTE_BOND_LOG(WARNING, "BOND MODE Broadcast & 8023AD 
>> don't support MBUF_FAST_FREE offload, force disable it.");
> 
> - Why "BOND MODE" is uppercase, if there is no special reason for it, I 
> suggest using lower case.
> 
> - Can you break the message to next line, this enables shorter line 
> without breaking the message:
> RTE_BOND_LOG(WARNING,
>      "BOND MODE Broadcast & 8023AD don't support ....
> 
>> +               offloads &= ~RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE;
>> +               dev->data->dev_conf.txmode.offloads = offloads;
>> +       }
>> +
>>          /* set the max_rx_pktlen */
>>          internals->max_rx_pktlen = internals->candidate_max_rx_pktlen;
>>
>> -- 
>> 2.33.0
>>
> 
> .
  

Patch

diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c
index c929b55768..5ca90c7590 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -3563,6 +3563,7 @@  bond_ethdev_configure(struct rte_eth_dev *dev)
 	const char *name = dev->device->name;
 	struct bond_dev_private *internals = dev->data->dev_private;
 	struct rte_kvargs *kvlist = internals->kvlist;
+	uint64_t offloads;
 	int arg_count;
 	uint16_t port_id = dev - rte_eth_devices;
 	uint8_t agg_mode;
@@ -3613,6 +3614,15 @@  bond_ethdev_configure(struct rte_eth_dev *dev)
 		}
 	}
 
+	offloads = dev->data->dev_conf.txmode.offloads;
+	if ((offloads & RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE) &&
+		(internals->mode == BONDING_MODE_8023AD ||
+		internals->mode == BONDING_MODE_BROADCAST)) {
+		RTE_BOND_LOG(WARNING, "BOND MODE Broadcast & 8023AD don't support MBUF_FAST_FREE offload, force disable it.");
+		offloads &= ~RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE;
+		dev->data->dev_conf.txmode.offloads = offloads;
+	}
+
 	/* set the max_rx_pktlen */
 	internals->max_rx_pktlen = internals->candidate_max_rx_pktlen;