diff mbox series

[net-next,v1,2/3] bnxt_en: stop packet flow during bnxt_queue_stop/start

Message ID 20240729205459.2583533-3-dw@davidwei.uk (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series fix bnxt_en queue reset when queue is active | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 42 this patch: 42
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 5 of 5 maintainers
netdev/build_clang success Errors and warnings before: 43 this patch: 43
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 45 this patch: 45
netdev/checkpatch warning WARNING: 'Co-developed-by:' is the preferred signature form
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 2 this patch: 2
netdev/source_inline success Was 0 now: 0
netdev/contest warning net-next-2024-07-30--03-00 (tests: 675)

Commit Message

David Wei July 29, 2024, 8:54 p.m. UTC
Calling napi_stop/start during bnxt_queue_stop/start isn't enough. The
current implementation when resetting a queue while packets are flowing
puts the queue into an inconsistent state.

There needs to be some synchronisation with the FW. Add calls to
bnxt_hwrm_vnic_update() to set the MRU for both the default and ntuple
vnic during queue start/stop. When the MRU is set to 0, flow is stopped.
Each Rx queue belongs to either the default or the ntuple vnic.

Co-Developed-by: Somnath Kotur <somnath.kotur@broadcom.com>
Signed-off-by: Somnath Kotur <somnath.kotur@broadcom.com>
Signed-off-by: David Wei <dw@davidwei.uk>
---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

Comments

Wojciech Drewek July 30, 2024, 10:31 a.m. UTC | #1
On 29.07.2024 22:54, David Wei wrote:
> Calling napi_stop/start during bnxt_queue_stop/start isn't enough. The
> current implementation when resetting a queue while packets are flowing
> puts the queue into an inconsistent state.
> 
> There needs to be some synchronisation with the FW. Add calls to
> bnxt_hwrm_vnic_update() to set the MRU for both the default and ntuple
> vnic during queue start/stop. When the MRU is set to 0, flow is stopped.
> Each Rx queue belongs to either the default or the ntuple vnic.
> 
> Co-Developed-by: Somnath Kotur <somnath.kotur@broadcom.com>
> Signed-off-by: Somnath Kotur <somnath.kotur@broadcom.com>
> Signed-off-by: David Wei <dw@davidwei.uk>
> ---
>  drivers/net/ethernet/broadcom/bnxt/bnxt.c | 22 ++++++++++++++++++----
>  1 file changed, 18 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> index 8822d7a17fbf..ce60c9322fe6 100644
> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> @@ -15172,7 +15172,8 @@ static int bnxt_queue_start(struct net_device *dev, void *qmem, int idx)
>  	struct bnxt *bp = netdev_priv(dev);
>  	struct bnxt_rx_ring_info *rxr, *clone;
>  	struct bnxt_cp_ring_info *cpr;
> -	int rc;
> +	struct bnxt_vnic_info *vnic;
> +	int i, rc;
>  
>  	rxr = &bp->rx_ring[idx];
>  	clone = qmem;
> @@ -15197,11 +15198,16 @@ static int bnxt_queue_start(struct net_device *dev, void *qmem, int idx)
>  	if (bp->flags & BNXT_FLAG_AGG_RINGS)
>  		bnxt_db_write(bp, &rxr->rx_agg_db, rxr->rx_agg_prod);
>  
> -	napi_enable(&rxr->bnapi->napi);

I get it that napi_{enable|enable} isn't enough but why removing it?
Without it, RX will not work, the poll method won't be called or am I missing something?

> -
>  	cpr = &rxr->bnapi->cp_ring;
>  	cpr->sw_stats->rx.rx_resets++;
>  
> +	for (i = 0; i <= BNXT_VNIC_NTUPLE; i++) {
> +		vnic = &bp->vnic_info[i];
> +		vnic->mru = bp->dev->mtu + ETH_HLEN + VLAN_HLEN;
> +		bnxt_hwrm_vnic_update(bp, vnic,
> +				      VNIC_UPDATE_REQ_ENABLES_MRU_VALID);
> +	}
> +
>  	return 0;
>  
>  err_free_hwrm_rx_ring:
> @@ -15213,9 +15219,17 @@ static int bnxt_queue_stop(struct net_device *dev, void *qmem, int idx)
>  {
>  	struct bnxt *bp = netdev_priv(dev);
>  	struct bnxt_rx_ring_info *rxr;
> +	struct bnxt_vnic_info *vnic;
> +	int i;
> +
> +	for (i = 0; i <= BNXT_VNIC_NTUPLE; i++) {
> +		vnic = &bp->vnic_info[i];
> +		vnic->mru = 0;
> +		bnxt_hwrm_vnic_update(bp, vnic,
> +				      VNIC_UPDATE_REQ_ENABLES_MRU_VALID);
> +	}
>  
>  	rxr = &bp->rx_ring[idx];
> -	napi_disable(&rxr->bnapi->napi);
>  	bnxt_hwrm_rx_ring_free(bp, rxr, false);
>  	bnxt_hwrm_rx_agg_ring_free(bp, rxr, false);
>  	rxr->rx_next_cons = 0;
David Wei July 31, 2024, 11:35 a.m. UTC | #2
On 2024-07-30 11:31, Wojciech Drewek wrote:
> 
> 
> On 29.07.2024 22:54, David Wei wrote:
>> Calling napi_stop/start during bnxt_queue_stop/start isn't enough. The
>> current implementation when resetting a queue while packets are flowing
>> puts the queue into an inconsistent state.
>>
>> There needs to be some synchronisation with the FW. Add calls to
>> bnxt_hwrm_vnic_update() to set the MRU for both the default and ntuple
>> vnic during queue start/stop. When the MRU is set to 0, flow is stopped.
>> Each Rx queue belongs to either the default or the ntuple vnic.
>>
>> Co-Developed-by: Somnath Kotur <somnath.kotur@broadcom.com>
>> Signed-off-by: Somnath Kotur <somnath.kotur@broadcom.com>
>> Signed-off-by: David Wei <dw@davidwei.uk>
>> ---
>>  drivers/net/ethernet/broadcom/bnxt/bnxt.c | 22 ++++++++++++++++++----
>>  1 file changed, 18 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
>> index 8822d7a17fbf..ce60c9322fe6 100644
>> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
>> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
>> @@ -15172,7 +15172,8 @@ static int bnxt_queue_start(struct net_device *dev, void *qmem, int idx)
>>  	struct bnxt *bp = netdev_priv(dev);
>>  	struct bnxt_rx_ring_info *rxr, *clone;
>>  	struct bnxt_cp_ring_info *cpr;
>> -	int rc;
>> +	struct bnxt_vnic_info *vnic;
>> +	int i, rc;
>>  
>>  	rxr = &bp->rx_ring[idx];
>>  	clone = qmem;
>> @@ -15197,11 +15198,16 @@ static int bnxt_queue_start(struct net_device *dev, void *qmem, int idx)
>>  	if (bp->flags & BNXT_FLAG_AGG_RINGS)
>>  		bnxt_db_write(bp, &rxr->rx_agg_db, rxr->rx_agg_prod);
>>  
>> -	napi_enable(&rxr->bnapi->napi);
> 
> I get it that napi_{enable|enable} isn't enough but why removing it?
> Without it, RX will not work, the poll method won't be called or am I missing something?

From my testing removing napi_enable/disable() is needed for reset to
work on a queue that has traffic flowing.

Let me edit the commit message to make this bit clearer. Thanks.

> 
>> -
>>  	cpr = &rxr->bnapi->cp_ring;
>>  	cpr->sw_stats->rx.rx_resets++;
>>  
>> +	for (i = 0; i <= BNXT_VNIC_NTUPLE; i++) {
>> +		vnic = &bp->vnic_info[i];
>> +		vnic->mru = bp->dev->mtu + ETH_HLEN + VLAN_HLEN;
>> +		bnxt_hwrm_vnic_update(bp, vnic,
>> +				      VNIC_UPDATE_REQ_ENABLES_MRU_VALID);
>> +	}
>> +
>>  	return 0;
>>  
>>  err_free_hwrm_rx_ring:
>> @@ -15213,9 +15219,17 @@ static int bnxt_queue_stop(struct net_device *dev, void *qmem, int idx)
>>  {
>>  	struct bnxt *bp = netdev_priv(dev);
>>  	struct bnxt_rx_ring_info *rxr;
>> +	struct bnxt_vnic_info *vnic;
>> +	int i;
>> +
>> +	for (i = 0; i <= BNXT_VNIC_NTUPLE; i++) {
>> +		vnic = &bp->vnic_info[i];
>> +		vnic->mru = 0;
>> +		bnxt_hwrm_vnic_update(bp, vnic,
>> +				      VNIC_UPDATE_REQ_ENABLES_MRU_VALID);
>> +	}
>>  
>>  	rxr = &bp->rx_ring[idx];
>> -	napi_disable(&rxr->bnapi->napi);
>>  	bnxt_hwrm_rx_ring_free(bp, rxr, false);
>>  	bnxt_hwrm_rx_agg_ring_free(bp, rxr, false);
>>  	rxr->rx_next_cons = 0;
diff mbox series

Patch

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index 8822d7a17fbf..ce60c9322fe6 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -15172,7 +15172,8 @@  static int bnxt_queue_start(struct net_device *dev, void *qmem, int idx)
 	struct bnxt *bp = netdev_priv(dev);
 	struct bnxt_rx_ring_info *rxr, *clone;
 	struct bnxt_cp_ring_info *cpr;
-	int rc;
+	struct bnxt_vnic_info *vnic;
+	int i, rc;
 
 	rxr = &bp->rx_ring[idx];
 	clone = qmem;
@@ -15197,11 +15198,16 @@  static int bnxt_queue_start(struct net_device *dev, void *qmem, int idx)
 	if (bp->flags & BNXT_FLAG_AGG_RINGS)
 		bnxt_db_write(bp, &rxr->rx_agg_db, rxr->rx_agg_prod);
 
-	napi_enable(&rxr->bnapi->napi);
-
 	cpr = &rxr->bnapi->cp_ring;
 	cpr->sw_stats->rx.rx_resets++;
 
+	for (i = 0; i <= BNXT_VNIC_NTUPLE; i++) {
+		vnic = &bp->vnic_info[i];
+		vnic->mru = bp->dev->mtu + ETH_HLEN + VLAN_HLEN;
+		bnxt_hwrm_vnic_update(bp, vnic,
+				      VNIC_UPDATE_REQ_ENABLES_MRU_VALID);
+	}
+
 	return 0;
 
 err_free_hwrm_rx_ring:
@@ -15213,9 +15219,17 @@  static int bnxt_queue_stop(struct net_device *dev, void *qmem, int idx)
 {
 	struct bnxt *bp = netdev_priv(dev);
 	struct bnxt_rx_ring_info *rxr;
+	struct bnxt_vnic_info *vnic;
+	int i;
+
+	for (i = 0; i <= BNXT_VNIC_NTUPLE; i++) {
+		vnic = &bp->vnic_info[i];
+		vnic->mru = 0;
+		bnxt_hwrm_vnic_update(bp, vnic,
+				      VNIC_UPDATE_REQ_ENABLES_MRU_VALID);
+	}
 
 	rxr = &bp->rx_ring[idx];
-	napi_disable(&rxr->bnapi->napi);
 	bnxt_hwrm_rx_ring_free(bp, rxr, false);
 	bnxt_hwrm_rx_agg_ring_free(bp, rxr, false);
 	rxr->rx_next_cons = 0;