* [PATCH net-next 01/10] bnxt_en: Set NAPR 1.2 support when registering with firmware
2025-01-13 6:39 [PATCH net-next 00/10] bnxt_en: Add NPAR 1.2 and TPH support Michael Chan
@ 2025-01-13 6:39 ` Michael Chan
2025-01-13 7:56 ` Michal Swiatkowski
2025-01-13 6:39 ` [PATCH net-next 02/10] bnxt_en Refactor completion ring allocation logic for P5_PLUS chips Michael Chan
` (8 subsequent siblings)
9 siblings, 1 reply; 28+ messages in thread
From: Michael Chan @ 2025-01-13 6:39 UTC (permalink / raw)
To: davem
Cc: netdev, edumazet, kuba, pabeni, andrew+netdev, pavan.chebbi,
andrew.gospodarek, somnath.kotur
NPAR 1.2 adds a transparent VLAN tag for all packets between the NIC
and the switch. Because of that, RX VLAN acceleration cannot be
supported for any additional host configured VLANs. The driver has
to acknowledge that it can support no RX VLAN acceleration and
set the NPAR 1.2 supported flag when registering with the FW.
Otherwise, the FW call will fail and the driver will abort on these
NPAR 1.2 NICs with this error:
bnxt_en 0000:26:00.0 (unnamed net_device) (uninitialized): hwrm req_type 0x1d seq id 0xb error 0x2
Reviewed-by: Somnath Kotur <somnath.kotur@broadcom.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
---
drivers/net/ethernet/broadcom/bnxt/bnxt.c | 5 +++++
drivers/net/ethernet/broadcom/bnxt/bnxt.h | 1 +
2 files changed, 6 insertions(+)
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index 884d42db5554..8527788bed91 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -5537,6 +5537,8 @@ int bnxt_hwrm_func_drv_rgtr(struct bnxt *bp, unsigned long *bmap, int bmap_size,
if (bp->fw_cap & BNXT_FW_CAP_ERROR_RECOVERY)
flags |= FUNC_DRV_RGTR_REQ_FLAGS_ERROR_RECOVERY_SUPPORT |
FUNC_DRV_RGTR_REQ_FLAGS_MASTER_SUPPORT;
+ if (bp->fw_cap & BNXT_FW_CAP_NPAR_1_2)
+ flags |= FUNC_DRV_RGTR_REQ_FLAGS_NPAR_1_2_SUPPORT;
req->flags = cpu_to_le32(flags);
req->ver_maj_8b = DRV_VER_MAJ;
req->ver_min_8b = DRV_VER_MIN;
@@ -8338,6 +8340,7 @@ static int bnxt_hwrm_func_qcfg(struct bnxt *bp)
switch (resp->port_partition_type) {
case FUNC_QCFG_RESP_PORT_PARTITION_TYPE_NPAR1_0:
+ case FUNC_QCFG_RESP_PORT_PARTITION_TYPE_NPAR1_2:
case FUNC_QCFG_RESP_PORT_PARTITION_TYPE_NPAR1_5:
case FUNC_QCFG_RESP_PORT_PARTITION_TYPE_NPAR2_0:
bp->port_partition_type = resp->port_partition_type;
@@ -9502,6 +9505,8 @@ static int __bnxt_hwrm_func_qcaps(struct bnxt *bp)
bp->fw_cap |= BNXT_FW_CAP_HOT_RESET_IF;
if (BNXT_PF(bp) && (flags_ext & FUNC_QCAPS_RESP_FLAGS_EXT_FW_LIVEPATCH_SUPPORTED))
bp->fw_cap |= BNXT_FW_CAP_LIVEPATCH;
+ if (flags_ext & FUNC_QCAPS_RESP_FLAGS_EXT_NPAR_1_2_SUPPORTED)
+ bp->fw_cap |= BNXT_FW_CAP_NPAR_1_2;
if (BNXT_PF(bp) && (flags_ext & FUNC_QCAPS_RESP_FLAGS_EXT_DFLT_VLAN_TPID_PCP_SUPPORTED))
bp->fw_cap |= BNXT_FW_CAP_DFLT_VLAN_TPID_PCP;
if (flags_ext & FUNC_QCAPS_RESP_FLAGS_EXT_BS_V2_SUPPORTED)
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
index 094c9e95b463..a634ad76177d 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
@@ -2488,6 +2488,7 @@ struct bnxt {
#define BNXT_FW_CAP_CFA_RFS_RING_TBL_IDX_V3 BIT_ULL(39)
#define BNXT_FW_CAP_VNIC_RE_FLUSH BIT_ULL(40)
#define BNXT_FW_CAP_SW_MAX_RESOURCE_LIMITS BIT_ULL(41)
+ #define BNXT_FW_CAP_NPAR_1_2 BIT_ULL(42)
u32 fw_dbg_cap;
--
2.30.1
^ permalink raw reply related [flat|nested] 28+ messages in thread* Re: [PATCH net-next 01/10] bnxt_en: Set NAPR 1.2 support when registering with firmware
2025-01-13 6:39 ` [PATCH net-next 01/10] bnxt_en: Set NAPR 1.2 support when registering with firmware Michael Chan
@ 2025-01-13 7:56 ` Michal Swiatkowski
0 siblings, 0 replies; 28+ messages in thread
From: Michal Swiatkowski @ 2025-01-13 7:56 UTC (permalink / raw)
To: Michael Chan
Cc: davem, netdev, edumazet, kuba, pabeni, andrew+netdev,
pavan.chebbi, andrew.gospodarek, somnath.kotur
On Sun, Jan 12, 2025 at 10:39:18PM -0800, Michael Chan wrote:
> NPAR 1.2 adds a transparent VLAN tag for all packets between the NIC
> and the switch. Because of that, RX VLAN acceleration cannot be
> supported for any additional host configured VLANs. The driver has
> to acknowledge that it can support no RX VLAN acceleration and
> set the NPAR 1.2 supported flag when registering with the FW.
> Otherwise, the FW call will fail and the driver will abort on these
> NPAR 1.2 NICs with this error:
>
> bnxt_en 0000:26:00.0 (unnamed net_device) (uninitialized): hwrm req_type 0x1d seq id 0xb error 0x2
>
> Reviewed-by: Somnath Kotur <somnath.kotur@broadcom.com>
> Signed-off-by: Michael Chan <michael.chan@broadcom.com>
> ---
> drivers/net/ethernet/broadcom/bnxt/bnxt.c | 5 +++++
> drivers/net/ethernet/broadcom/bnxt/bnxt.h | 1 +
> 2 files changed, 6 insertions(+)
>
> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> index 884d42db5554..8527788bed91 100644
> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> @@ -5537,6 +5537,8 @@ int bnxt_hwrm_func_drv_rgtr(struct bnxt *bp, unsigned long *bmap, int bmap_size,
> if (bp->fw_cap & BNXT_FW_CAP_ERROR_RECOVERY)
> flags |= FUNC_DRV_RGTR_REQ_FLAGS_ERROR_RECOVERY_SUPPORT |
> FUNC_DRV_RGTR_REQ_FLAGS_MASTER_SUPPORT;
> + if (bp->fw_cap & BNXT_FW_CAP_NPAR_1_2)
> + flags |= FUNC_DRV_RGTR_REQ_FLAGS_NPAR_1_2_SUPPORT;
> req->flags = cpu_to_le32(flags);
> req->ver_maj_8b = DRV_VER_MAJ;
> req->ver_min_8b = DRV_VER_MIN;
> @@ -8338,6 +8340,7 @@ static int bnxt_hwrm_func_qcfg(struct bnxt *bp)
>
> switch (resp->port_partition_type) {
> case FUNC_QCFG_RESP_PORT_PARTITION_TYPE_NPAR1_0:
> + case FUNC_QCFG_RESP_PORT_PARTITION_TYPE_NPAR1_2:
> case FUNC_QCFG_RESP_PORT_PARTITION_TYPE_NPAR1_5:
> case FUNC_QCFG_RESP_PORT_PARTITION_TYPE_NPAR2_0:
> bp->port_partition_type = resp->port_partition_type;
> @@ -9502,6 +9505,8 @@ static int __bnxt_hwrm_func_qcaps(struct bnxt *bp)
> bp->fw_cap |= BNXT_FW_CAP_HOT_RESET_IF;
> if (BNXT_PF(bp) && (flags_ext & FUNC_QCAPS_RESP_FLAGS_EXT_FW_LIVEPATCH_SUPPORTED))
> bp->fw_cap |= BNXT_FW_CAP_LIVEPATCH;
> + if (flags_ext & FUNC_QCAPS_RESP_FLAGS_EXT_NPAR_1_2_SUPPORTED)
> + bp->fw_cap |= BNXT_FW_CAP_NPAR_1_2;
> if (BNXT_PF(bp) && (flags_ext & FUNC_QCAPS_RESP_FLAGS_EXT_DFLT_VLAN_TPID_PCP_SUPPORTED))
> bp->fw_cap |= BNXT_FW_CAP_DFLT_VLAN_TPID_PCP;
> if (flags_ext & FUNC_QCAPS_RESP_FLAGS_EXT_BS_V2_SUPPORTED)
> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
> index 094c9e95b463..a634ad76177d 100644
> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h
> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
> @@ -2488,6 +2488,7 @@ struct bnxt {
> #define BNXT_FW_CAP_CFA_RFS_RING_TBL_IDX_V3 BIT_ULL(39)
> #define BNXT_FW_CAP_VNIC_RE_FLUSH BIT_ULL(40)
> #define BNXT_FW_CAP_SW_MAX_RESOURCE_LIMITS BIT_ULL(41)
> + #define BNXT_FW_CAP_NPAR_1_2 BIT_ULL(42)
>
> u32 fw_dbg_cap;
>
> --
> 2.30.1
Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
^ permalink raw reply [flat|nested] 28+ messages in thread
* [PATCH net-next 02/10] bnxt_en Refactor completion ring allocation logic for P5_PLUS chips
2025-01-13 6:39 [PATCH net-next 00/10] bnxt_en: Add NPAR 1.2 and TPH support Michael Chan
2025-01-13 6:39 ` [PATCH net-next 01/10] bnxt_en: Set NAPR 1.2 support when registering with firmware Michael Chan
@ 2025-01-13 6:39 ` Michael Chan
2025-01-13 7:59 ` Michal Swiatkowski
2025-01-13 6:39 ` [PATCH net-next 03/10] bnxt_en: Refactor TX ring allocation logic Michael Chan
` (7 subsequent siblings)
9 siblings, 1 reply; 28+ messages in thread
From: Michael Chan @ 2025-01-13 6:39 UTC (permalink / raw)
To: davem
Cc: netdev, edumazet, kuba, pabeni, andrew+netdev, pavan.chebbi,
andrew.gospodarek, somnath.kotur, Ajit Khaparde
Add a new bnxt_hwrm_cp_ring_alloc_p5() function to handle allocating
one completion ring on P5_PLUS chips. This simplifies the existing code
and will be useful later in the series.
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
---
drivers/net/ethernet/broadcom/bnxt/bnxt.c | 44 +++++++++++------------
1 file changed, 21 insertions(+), 23 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index 8527788bed91..d364a707664b 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -7172,6 +7172,25 @@ static int bnxt_hwrm_rx_agg_ring_alloc(struct bnxt *bp,
return 0;
}
+static int bnxt_hwrm_cp_ring_alloc_p5(struct bnxt *bp,
+ struct bnxt_cp_ring_info *cpr)
+{
+ struct bnxt_napi *bnapi = cpr->bnapi;
+ u32 type = HWRM_RING_ALLOC_CMPL;
+ struct bnxt_ring_struct *ring;
+ u32 map_idx = bnapi->index;
+ int rc;
+
+ ring = &cpr->cp_ring_struct;
+ ring->handle = BNXT_SET_NQ_HDL(cpr);
+ rc = hwrm_ring_alloc_send_msg(bp, ring, type, map_idx);
+ if (rc)
+ return rc;
+ bnxt_set_db(bp, &cpr->cp_db, type, map_idx, ring->fw_ring_id);
+ bnxt_db_cq(bp, &cpr->cp_db, cpr->cp_raw_cons);
+ return 0;
+}
+
static int bnxt_hwrm_ring_alloc(struct bnxt *bp)
{
bool agg_rings = !!(bp->flags & BNXT_FLAG_AGG_RINGS);
@@ -7215,19 +7234,9 @@ static int bnxt_hwrm_ring_alloc(struct bnxt *bp)
u32 map_idx;
if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) {
- struct bnxt_cp_ring_info *cpr2 = txr->tx_cpr;
- struct bnxt_napi *bnapi = txr->bnapi;
- u32 type2 = HWRM_RING_ALLOC_CMPL;
-
- ring = &cpr2->cp_ring_struct;
- ring->handle = BNXT_SET_NQ_HDL(cpr2);
- map_idx = bnapi->index;
- rc = hwrm_ring_alloc_send_msg(bp, ring, type2, map_idx);
+ rc = bnxt_hwrm_cp_ring_alloc_p5(bp, txr->tx_cpr);
if (rc)
goto err_out;
- bnxt_set_db(bp, &cpr2->cp_db, type2, map_idx,
- ring->fw_ring_id);
- bnxt_db_cq(bp, &cpr2->cp_db, cpr2->cp_raw_cons);
}
ring = &txr->tx_ring_struct;
map_idx = i;
@@ -7247,20 +7256,9 @@ static int bnxt_hwrm_ring_alloc(struct bnxt *bp)
if (!agg_rings)
bnxt_db_write(bp, &rxr->rx_db, rxr->rx_prod);
if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) {
- struct bnxt_cp_ring_info *cpr2 = rxr->rx_cpr;
- struct bnxt_napi *bnapi = rxr->bnapi;
- u32 type2 = HWRM_RING_ALLOC_CMPL;
- struct bnxt_ring_struct *ring;
- u32 map_idx = bnapi->index;
-
- ring = &cpr2->cp_ring_struct;
- ring->handle = BNXT_SET_NQ_HDL(cpr2);
- rc = hwrm_ring_alloc_send_msg(bp, ring, type2, map_idx);
+ rc = bnxt_hwrm_cp_ring_alloc_p5(bp, rxr->rx_cpr);
if (rc)
goto err_out;
- bnxt_set_db(bp, &cpr2->cp_db, type2, map_idx,
- ring->fw_ring_id);
- bnxt_db_cq(bp, &cpr2->cp_db, cpr2->cp_raw_cons);
}
}
--
2.30.1
^ permalink raw reply related [flat|nested] 28+ messages in thread* Re: [PATCH net-next 02/10] bnxt_en Refactor completion ring allocation logic for P5_PLUS chips
2025-01-13 6:39 ` [PATCH net-next 02/10] bnxt_en Refactor completion ring allocation logic for P5_PLUS chips Michael Chan
@ 2025-01-13 7:59 ` Michal Swiatkowski
0 siblings, 0 replies; 28+ messages in thread
From: Michal Swiatkowski @ 2025-01-13 7:59 UTC (permalink / raw)
To: Michael Chan
Cc: davem, netdev, edumazet, kuba, pabeni, andrew+netdev,
pavan.chebbi, andrew.gospodarek, somnath.kotur, Ajit Khaparde
On Sun, Jan 12, 2025 at 10:39:19PM -0800, Michael Chan wrote:
> Add a new bnxt_hwrm_cp_ring_alloc_p5() function to handle allocating
> one completion ring on P5_PLUS chips. This simplifies the existing code
> and will be useful later in the series.
>
> Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
> Signed-off-by: Michael Chan <michael.chan@broadcom.com>
> ---
> drivers/net/ethernet/broadcom/bnxt/bnxt.c | 44 +++++++++++------------
> 1 file changed, 21 insertions(+), 23 deletions(-)
>
> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> index 8527788bed91..d364a707664b 100644
> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> @@ -7172,6 +7172,25 @@ static int bnxt_hwrm_rx_agg_ring_alloc(struct bnxt *bp,
> return 0;
> }
>
> +static int bnxt_hwrm_cp_ring_alloc_p5(struct bnxt *bp,
> + struct bnxt_cp_ring_info *cpr)
> +{
> + struct bnxt_napi *bnapi = cpr->bnapi;
> + u32 type = HWRM_RING_ALLOC_CMPL;
Nit, can be const
> + struct bnxt_ring_struct *ring;
> + u32 map_idx = bnapi->index;
> + int rc;
> +
> + ring = &cpr->cp_ring_struct;
> + ring->handle = BNXT_SET_NQ_HDL(cpr);
> + rc = hwrm_ring_alloc_send_msg(bp, ring, type, map_idx);
> + if (rc)
> + return rc;
> + bnxt_set_db(bp, &cpr->cp_db, type, map_idx, ring->fw_ring_id);
> + bnxt_db_cq(bp, &cpr->cp_db, cpr->cp_raw_cons);
> + return 0;
> +}
> +
> static int bnxt_hwrm_ring_alloc(struct bnxt *bp)
> {
> bool agg_rings = !!(bp->flags & BNXT_FLAG_AGG_RINGS);
> @@ -7215,19 +7234,9 @@ static int bnxt_hwrm_ring_alloc(struct bnxt *bp)
> u32 map_idx;
>
> if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) {
> - struct bnxt_cp_ring_info *cpr2 = txr->tx_cpr;
> - struct bnxt_napi *bnapi = txr->bnapi;
> - u32 type2 = HWRM_RING_ALLOC_CMPL;
> -
> - ring = &cpr2->cp_ring_struct;
> - ring->handle = BNXT_SET_NQ_HDL(cpr2);
> - map_idx = bnapi->index;
> - rc = hwrm_ring_alloc_send_msg(bp, ring, type2, map_idx);
> + rc = bnxt_hwrm_cp_ring_alloc_p5(bp, txr->tx_cpr);
> if (rc)
> goto err_out;
> - bnxt_set_db(bp, &cpr2->cp_db, type2, map_idx,
> - ring->fw_ring_id);
> - bnxt_db_cq(bp, &cpr2->cp_db, cpr2->cp_raw_cons);
> }
> ring = &txr->tx_ring_struct;
> map_idx = i;
> @@ -7247,20 +7256,9 @@ static int bnxt_hwrm_ring_alloc(struct bnxt *bp)
> if (!agg_rings)
> bnxt_db_write(bp, &rxr->rx_db, rxr->rx_prod);
> if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) {
> - struct bnxt_cp_ring_info *cpr2 = rxr->rx_cpr;
> - struct bnxt_napi *bnapi = rxr->bnapi;
> - u32 type2 = HWRM_RING_ALLOC_CMPL;
> - struct bnxt_ring_struct *ring;
> - u32 map_idx = bnapi->index;
> -
> - ring = &cpr2->cp_ring_struct;
> - ring->handle = BNXT_SET_NQ_HDL(cpr2);
> - rc = hwrm_ring_alloc_send_msg(bp, ring, type2, map_idx);
> + rc = bnxt_hwrm_cp_ring_alloc_p5(bp, rxr->rx_cpr);
> if (rc)
> goto err_out;
> - bnxt_set_db(bp, &cpr2->cp_db, type2, map_idx,
> - ring->fw_ring_id);
> - bnxt_db_cq(bp, &cpr2->cp_db, cpr2->cp_raw_cons);
> }
> }
>
> --
> 2.30.1
Nice simplification
Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
^ permalink raw reply [flat|nested] 28+ messages in thread
* [PATCH net-next 03/10] bnxt_en: Refactor TX ring allocation logic
2025-01-13 6:39 [PATCH net-next 00/10] bnxt_en: Add NPAR 1.2 and TPH support Michael Chan
2025-01-13 6:39 ` [PATCH net-next 01/10] bnxt_en: Set NAPR 1.2 support when registering with firmware Michael Chan
2025-01-13 6:39 ` [PATCH net-next 02/10] bnxt_en Refactor completion ring allocation logic for P5_PLUS chips Michael Chan
@ 2025-01-13 6:39 ` Michael Chan
2025-01-13 8:02 ` Michal Swiatkowski
2025-01-13 6:39 ` [PATCH net-next 04/10] bnxt_en: Refactor completion ring free routine Michael Chan
` (6 subsequent siblings)
9 siblings, 1 reply; 28+ messages in thread
From: Michael Chan @ 2025-01-13 6:39 UTC (permalink / raw)
To: davem
Cc: netdev, edumazet, kuba, pabeni, andrew+netdev, pavan.chebbi,
andrew.gospodarek, somnath.kotur, Ajit Khaparde
Add a new bnxt_hwrm_tx_ring_alloc() function to handle allocating
a transmit ring. This will be useful later in the series.
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
---
drivers/net/ethernet/broadcom/bnxt/bnxt.c | 22 +++++++++++++++-------
1 file changed, 15 insertions(+), 7 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index d364a707664b..e9a2e30c1537 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -7191,6 +7191,20 @@ static int bnxt_hwrm_cp_ring_alloc_p5(struct bnxt *bp,
return 0;
}
+static int bnxt_hwrm_tx_ring_alloc(struct bnxt *bp,
+ struct bnxt_tx_ring_info *txr, u32 tx_idx)
+{
+ struct bnxt_ring_struct *ring = &txr->tx_ring_struct;
+ u32 type = HWRM_RING_ALLOC_TX;
+ int rc;
+
+ rc = hwrm_ring_alloc_send_msg(bp, ring, type, tx_idx);
+ if (rc)
+ return rc;
+ bnxt_set_db(bp, &txr->tx_db, type, tx_idx, ring->fw_ring_id);
+ return 0;
+}
+
static int bnxt_hwrm_ring_alloc(struct bnxt *bp)
{
bool agg_rings = !!(bp->flags & BNXT_FLAG_AGG_RINGS);
@@ -7227,23 +7241,17 @@ static int bnxt_hwrm_ring_alloc(struct bnxt *bp)
}
}
- type = HWRM_RING_ALLOC_TX;
for (i = 0; i < bp->tx_nr_rings; i++) {
struct bnxt_tx_ring_info *txr = &bp->tx_ring[i];
- struct bnxt_ring_struct *ring;
- u32 map_idx;
if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) {
rc = bnxt_hwrm_cp_ring_alloc_p5(bp, txr->tx_cpr);
if (rc)
goto err_out;
}
- ring = &txr->tx_ring_struct;
- map_idx = i;
- rc = hwrm_ring_alloc_send_msg(bp, ring, type, map_idx);
+ rc = bnxt_hwrm_tx_ring_alloc(bp, txr, i);
if (rc)
goto err_out;
- bnxt_set_db(bp, &txr->tx_db, type, map_idx, ring->fw_ring_id);
}
for (i = 0; i < bp->rx_nr_rings; i++) {
--
2.30.1
^ permalink raw reply related [flat|nested] 28+ messages in thread* Re: [PATCH net-next 03/10] bnxt_en: Refactor TX ring allocation logic
2025-01-13 6:39 ` [PATCH net-next 03/10] bnxt_en: Refactor TX ring allocation logic Michael Chan
@ 2025-01-13 8:02 ` Michal Swiatkowski
0 siblings, 0 replies; 28+ messages in thread
From: Michal Swiatkowski @ 2025-01-13 8:02 UTC (permalink / raw)
To: Michael Chan
Cc: davem, netdev, edumazet, kuba, pabeni, andrew+netdev,
pavan.chebbi, andrew.gospodarek, somnath.kotur, Ajit Khaparde
On Sun, Jan 12, 2025 at 10:39:20PM -0800, Michael Chan wrote:
> Add a new bnxt_hwrm_tx_ring_alloc() function to handle allocating
> a transmit ring. This will be useful later in the series.
>
> Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
> Signed-off-by: Michael Chan <michael.chan@broadcom.com>
> ---
> drivers/net/ethernet/broadcom/bnxt/bnxt.c | 22 +++++++++++++++-------
> 1 file changed, 15 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> index d364a707664b..e9a2e30c1537 100644
> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> @@ -7191,6 +7191,20 @@ static int bnxt_hwrm_cp_ring_alloc_p5(struct bnxt *bp,
> return 0;
> }
>
> +static int bnxt_hwrm_tx_ring_alloc(struct bnxt *bp,
> + struct bnxt_tx_ring_info *txr, u32 tx_idx)
> +{
> + struct bnxt_ring_struct *ring = &txr->tx_ring_struct;
> + u32 type = HWRM_RING_ALLOC_TX;
Nit as previous, can be const
> + int rc;
> +
> + rc = hwrm_ring_alloc_send_msg(bp, ring, type, tx_idx);
> + if (rc)
> + return rc;
> + bnxt_set_db(bp, &txr->tx_db, type, tx_idx, ring->fw_ring_id);
> + return 0;
> +}
> +
> static int bnxt_hwrm_ring_alloc(struct bnxt *bp)
> {
> bool agg_rings = !!(bp->flags & BNXT_FLAG_AGG_RINGS);
> @@ -7227,23 +7241,17 @@ static int bnxt_hwrm_ring_alloc(struct bnxt *bp)
> }
> }
>
> - type = HWRM_RING_ALLOC_TX;
> for (i = 0; i < bp->tx_nr_rings; i++) {
> struct bnxt_tx_ring_info *txr = &bp->tx_ring[i];
> - struct bnxt_ring_struct *ring;
> - u32 map_idx;
>
> if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) {
> rc = bnxt_hwrm_cp_ring_alloc_p5(bp, txr->tx_cpr);
> if (rc)
> goto err_out;
> }
> - ring = &txr->tx_ring_struct;
> - map_idx = i;
> - rc = hwrm_ring_alloc_send_msg(bp, ring, type, map_idx);
> + rc = bnxt_hwrm_tx_ring_alloc(bp, txr, i);
> if (rc)
> goto err_out;
> - bnxt_set_db(bp, &txr->tx_db, type, map_idx, ring->fw_ring_id);
> }
>
> for (i = 0; i < bp->rx_nr_rings; i++) {
> --
> 2.30.1
Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
^ permalink raw reply [flat|nested] 28+ messages in thread
* [PATCH net-next 04/10] bnxt_en: Refactor completion ring free routine
2025-01-13 6:39 [PATCH net-next 00/10] bnxt_en: Add NPAR 1.2 and TPH support Michael Chan
` (2 preceding siblings ...)
2025-01-13 6:39 ` [PATCH net-next 03/10] bnxt_en: Refactor TX ring allocation logic Michael Chan
@ 2025-01-13 6:39 ` Michael Chan
2025-01-13 8:06 ` Michal Swiatkowski
2025-01-13 6:39 ` [PATCH net-next 05/10] bnxt_en: Refactor bnxt_free_tx_rings() to free per Tx ring Michael Chan
` (5 subsequent siblings)
9 siblings, 1 reply; 28+ messages in thread
From: Michael Chan @ 2025-01-13 6:39 UTC (permalink / raw)
To: davem
Cc: netdev, edumazet, kuba, pabeni, andrew+netdev, pavan.chebbi,
andrew.gospodarek, somnath.kotur, Kalesh AP
From: Somnath Kotur <somnath.kotur@broadcom.com>
Add a wrapper routine to free L2 completion rings. This will be
useful later in the series.
Reviewed-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Signed-off-by: Somnath Kotur <somnath.kotur@broadcom.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
---
drivers/net/ethernet/broadcom/bnxt/bnxt.c | 26 ++++++++++++++---------
1 file changed, 16 insertions(+), 10 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index e9a2e30c1537..4c5cb4dd7420 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -7378,6 +7378,20 @@ static void bnxt_hwrm_rx_agg_ring_free(struct bnxt *bp,
bp->grp_info[grp_idx].agg_fw_ring_id = INVALID_HW_RING_ID;
}
+static void bnxt_hwrm_cp_ring_free(struct bnxt *bp,
+ struct bnxt_cp_ring_info *cpr)
+{
+ struct bnxt_ring_struct *ring;
+
+ ring = &cpr->cp_ring_struct;
+ if (ring->fw_ring_id == INVALID_HW_RING_ID)
+ return;
+
+ hwrm_ring_free_send_msg(bp, ring, RING_FREE_REQ_RING_TYPE_L2_CMPL,
+ INVALID_HW_RING_ID);
+ ring->fw_ring_id = INVALID_HW_RING_ID;
+}
+
static void bnxt_hwrm_ring_free(struct bnxt *bp, bool close_path)
{
u32 type;
@@ -7423,17 +7437,9 @@ static void bnxt_hwrm_ring_free(struct bnxt *bp, bool close_path)
struct bnxt_ring_struct *ring;
int j;
- for (j = 0; j < cpr->cp_ring_count && cpr->cp_ring_arr; j++) {
- struct bnxt_cp_ring_info *cpr2 = &cpr->cp_ring_arr[j];
+ for (j = 0; j < cpr->cp_ring_count && cpr->cp_ring_arr; j++)
+ bnxt_hwrm_cp_ring_free(bp, &cpr->cp_ring_arr[j]);
- ring = &cpr2->cp_ring_struct;
- if (ring->fw_ring_id == INVALID_HW_RING_ID)
- continue;
- hwrm_ring_free_send_msg(bp, ring,
- RING_FREE_REQ_RING_TYPE_L2_CMPL,
- INVALID_HW_RING_ID);
- ring->fw_ring_id = INVALID_HW_RING_ID;
- }
ring = &cpr->cp_ring_struct;
if (ring->fw_ring_id != INVALID_HW_RING_ID) {
hwrm_ring_free_send_msg(bp, ring, type,
--
2.30.1
^ permalink raw reply related [flat|nested] 28+ messages in thread* Re: [PATCH net-next 04/10] bnxt_en: Refactor completion ring free routine
2025-01-13 6:39 ` [PATCH net-next 04/10] bnxt_en: Refactor completion ring free routine Michael Chan
@ 2025-01-13 8:06 ` Michal Swiatkowski
0 siblings, 0 replies; 28+ messages in thread
From: Michal Swiatkowski @ 2025-01-13 8:06 UTC (permalink / raw)
To: Michael Chan
Cc: davem, netdev, edumazet, kuba, pabeni, andrew+netdev,
pavan.chebbi, andrew.gospodarek, somnath.kotur, Kalesh AP
On Sun, Jan 12, 2025 at 10:39:21PM -0800, Michael Chan wrote:
> From: Somnath Kotur <somnath.kotur@broadcom.com>
>
> Add a wrapper routine to free L2 completion rings. This will be
> useful later in the series.
>
> Reviewed-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
> Signed-off-by: Somnath Kotur <somnath.kotur@broadcom.com>
> Signed-off-by: Michael Chan <michael.chan@broadcom.com>
> ---
> drivers/net/ethernet/broadcom/bnxt/bnxt.c | 26 ++++++++++++++---------
> 1 file changed, 16 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> index e9a2e30c1537..4c5cb4dd7420 100644
> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> @@ -7378,6 +7378,20 @@ static void bnxt_hwrm_rx_agg_ring_free(struct bnxt *bp,
> bp->grp_info[grp_idx].agg_fw_ring_id = INVALID_HW_RING_ID;
> }
>
> +static void bnxt_hwrm_cp_ring_free(struct bnxt *bp,
> + struct bnxt_cp_ring_info *cpr)
> +{
> + struct bnxt_ring_struct *ring;
> +
> + ring = &cpr->cp_ring_struct;
> + if (ring->fw_ring_id == INVALID_HW_RING_ID)
> + return;
> +
> + hwrm_ring_free_send_msg(bp, ring, RING_FREE_REQ_RING_TYPE_L2_CMPL,
> + INVALID_HW_RING_ID);
> + ring->fw_ring_id = INVALID_HW_RING_ID;
> +}
> +
> static void bnxt_hwrm_ring_free(struct bnxt *bp, bool close_path)
> {
> u32 type;
> @@ -7423,17 +7437,9 @@ static void bnxt_hwrm_ring_free(struct bnxt *bp, bool close_path)
> struct bnxt_ring_struct *ring;
> int j;
>
> - for (j = 0; j < cpr->cp_ring_count && cpr->cp_ring_arr; j++) {
> - struct bnxt_cp_ring_info *cpr2 = &cpr->cp_ring_arr[j];
> + for (j = 0; j < cpr->cp_ring_count && cpr->cp_ring_arr; j++)
> + bnxt_hwrm_cp_ring_free(bp, &cpr->cp_ring_arr[j]);
>
> - ring = &cpr2->cp_ring_struct;
> - if (ring->fw_ring_id == INVALID_HW_RING_ID)
> - continue;
> - hwrm_ring_free_send_msg(bp, ring,
> - RING_FREE_REQ_RING_TYPE_L2_CMPL,
> - INVALID_HW_RING_ID);
> - ring->fw_ring_id = INVALID_HW_RING_ID;
> - }
> ring = &cpr->cp_ring_struct;
> if (ring->fw_ring_id != INVALID_HW_RING_ID) {
> hwrm_ring_free_send_msg(bp, ring, type,
> --
> 2.30.1
Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
^ permalink raw reply [flat|nested] 28+ messages in thread
* [PATCH net-next 05/10] bnxt_en: Refactor bnxt_free_tx_rings() to free per Tx ring
2025-01-13 6:39 [PATCH net-next 00/10] bnxt_en: Add NPAR 1.2 and TPH support Michael Chan
` (3 preceding siblings ...)
2025-01-13 6:39 ` [PATCH net-next 04/10] bnxt_en: Refactor completion ring free routine Michael Chan
@ 2025-01-13 6:39 ` Michael Chan
2025-01-13 8:17 ` Michal Swiatkowski
2025-01-13 6:39 ` [PATCH net-next 06/10] bnxt_en: Refactor RX/RX AGG ring parameters setup for P5_PLUS Michael Chan
` (4 subsequent siblings)
9 siblings, 1 reply; 28+ messages in thread
From: Michael Chan @ 2025-01-13 6:39 UTC (permalink / raw)
To: davem
Cc: netdev, edumazet, kuba, pabeni, andrew+netdev, pavan.chebbi,
andrew.gospodarek, somnath.kotur
From: Somnath Kotur <somnath.kotur@broadcom.com>
Modify bnxt_free_tx_rings() to free the skbs per Tx ring.
This will be useful later in the series.
Signed-off-by: Somnath Kotur <somnath.kotur@broadcom.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
---
drivers/net/ethernet/broadcom/bnxt/bnxt.c | 115 ++++++++++++----------
1 file changed, 61 insertions(+), 54 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index 4c5cb4dd7420..4336a5b54289 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -3314,74 +3314,81 @@ static int bnxt_poll_p5(struct napi_struct *napi, int budget)
return work_done;
}
-static void bnxt_free_tx_skbs(struct bnxt *bp)
+static void bnxt_free_one_tx_ring_skbs(struct bnxt *bp,
+ struct bnxt_tx_ring_info *txr, int idx)
{
int i, max_idx;
struct pci_dev *pdev = bp->pdev;
- if (!bp->tx_ring)
- return;
-
max_idx = bp->tx_nr_pages * TX_DESC_CNT;
- for (i = 0; i < bp->tx_nr_rings; i++) {
- struct bnxt_tx_ring_info *txr = &bp->tx_ring[i];
- int j;
- if (!txr->tx_buf_ring)
+ for (i = 0; i < max_idx;) {
+ struct bnxt_sw_tx_bd *tx_buf = &txr->tx_buf_ring[i];
+ struct sk_buff *skb;
+ int j, last;
+
+ if (idx < bp->tx_nr_rings_xdp &&
+ tx_buf->action == XDP_REDIRECT) {
+ dma_unmap_single(&pdev->dev,
+ dma_unmap_addr(tx_buf, mapping),
+ dma_unmap_len(tx_buf, len),
+ DMA_TO_DEVICE);
+ xdp_return_frame(tx_buf->xdpf);
+ tx_buf->action = 0;
+ tx_buf->xdpf = NULL;
+ i++;
continue;
+ }
- for (j = 0; j < max_idx;) {
- struct bnxt_sw_tx_bd *tx_buf = &txr->tx_buf_ring[j];
- struct sk_buff *skb;
- int k, last;
-
- if (i < bp->tx_nr_rings_xdp &&
- tx_buf->action == XDP_REDIRECT) {
- dma_unmap_single(&pdev->dev,
- dma_unmap_addr(tx_buf, mapping),
- dma_unmap_len(tx_buf, len),
- DMA_TO_DEVICE);
- xdp_return_frame(tx_buf->xdpf);
- tx_buf->action = 0;
- tx_buf->xdpf = NULL;
- j++;
- continue;
- }
+ skb = tx_buf->skb;
+ if (!skb) {
+ i++;
+ continue;
+ }
- skb = tx_buf->skb;
- if (!skb) {
- j++;
- continue;
- }
+ tx_buf->skb = NULL;
- tx_buf->skb = NULL;
+ if (tx_buf->is_push) {
+ dev_kfree_skb(skb);
+ i += 2;
+ continue;
+ }
- if (tx_buf->is_push) {
- dev_kfree_skb(skb);
- j += 2;
- continue;
- }
+ dma_unmap_single(&pdev->dev,
+ dma_unmap_addr(tx_buf, mapping),
+ skb_headlen(skb),
+ DMA_TO_DEVICE);
- dma_unmap_single(&pdev->dev,
- dma_unmap_addr(tx_buf, mapping),
- skb_headlen(skb),
- DMA_TO_DEVICE);
+ last = tx_buf->nr_frags;
+ i += 2;
+ for (j = 0; j < last; j++, i++) {
+ int ring_idx = i & bp->tx_ring_mask;
+ skb_frag_t *frag = &skb_shinfo(skb)->frags[j];
- last = tx_buf->nr_frags;
- j += 2;
- for (k = 0; k < last; k++, j++) {
- int ring_idx = j & bp->tx_ring_mask;
- skb_frag_t *frag = &skb_shinfo(skb)->frags[k];
-
- tx_buf = &txr->tx_buf_ring[ring_idx];
- dma_unmap_page(
- &pdev->dev,
- dma_unmap_addr(tx_buf, mapping),
- skb_frag_size(frag), DMA_TO_DEVICE);
- }
- dev_kfree_skb(skb);
+ tx_buf = &txr->tx_buf_ring[ring_idx];
+ dma_unmap_page(&pdev->dev,
+ dma_unmap_addr(tx_buf, mapping),
+ skb_frag_size(frag), DMA_TO_DEVICE);
}
- netdev_tx_reset_queue(netdev_get_tx_queue(bp->dev, i));
+ dev_kfree_skb(skb);
+ }
+ netdev_tx_reset_queue(netdev_get_tx_queue(bp->dev, idx));
+}
+
+static void bnxt_free_tx_skbs(struct bnxt *bp)
+{
+ int i;
+
+ if (!bp->tx_ring)
+ return;
+
+ for (i = 0; i < bp->tx_nr_rings; i++) {
+ struct bnxt_tx_ring_info *txr = &bp->tx_ring[i];
+
+ if (!txr->tx_buf_ring)
+ continue;
+
+ bnxt_free_one_tx_ring_skbs(bp, txr, i);
}
}
--
2.30.1
^ permalink raw reply related [flat|nested] 28+ messages in thread* Re: [PATCH net-next 05/10] bnxt_en: Refactor bnxt_free_tx_rings() to free per Tx ring
2025-01-13 6:39 ` [PATCH net-next 05/10] bnxt_en: Refactor bnxt_free_tx_rings() to free per Tx ring Michael Chan
@ 2025-01-13 8:17 ` Michal Swiatkowski
0 siblings, 0 replies; 28+ messages in thread
From: Michal Swiatkowski @ 2025-01-13 8:17 UTC (permalink / raw)
To: Michael Chan
Cc: davem, netdev, edumazet, kuba, pabeni, andrew+netdev,
pavan.chebbi, andrew.gospodarek, somnath.kotur
On Sun, Jan 12, 2025 at 10:39:22PM -0800, Michael Chan wrote:
> From: Somnath Kotur <somnath.kotur@broadcom.com>
>
> Modify bnxt_free_tx_rings() to free the skbs per Tx ring.
> This will be useful later in the series.
>
> Signed-off-by: Somnath Kotur <somnath.kotur@broadcom.com>
> Signed-off-by: Michael Chan <michael.chan@broadcom.com>
> ---
> drivers/net/ethernet/broadcom/bnxt/bnxt.c | 115 ++++++++++++----------
> 1 file changed, 61 insertions(+), 54 deletions(-)
>
> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> index 4c5cb4dd7420..4336a5b54289 100644
> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> @@ -3314,74 +3314,81 @@ static int bnxt_poll_p5(struct napi_struct *napi, int budget)
> return work_done;
> }
>
> -static void bnxt_free_tx_skbs(struct bnxt *bp)
> +static void bnxt_free_one_tx_ring_skbs(struct bnxt *bp,
> + struct bnxt_tx_ring_info *txr, int idx)
> {
> int i, max_idx;
> struct pci_dev *pdev = bp->pdev;
>
> - if (!bp->tx_ring)
> - return;
> -
> max_idx = bp->tx_nr_pages * TX_DESC_CNT;
> - for (i = 0; i < bp->tx_nr_rings; i++) {
> - struct bnxt_tx_ring_info *txr = &bp->tx_ring[i];
> - int j;
>
> - if (!txr->tx_buf_ring)
> + for (i = 0; i < max_idx;) {
> + struct bnxt_sw_tx_bd *tx_buf = &txr->tx_buf_ring[i];
> + struct sk_buff *skb;
> + int j, last;
> +
> + if (idx < bp->tx_nr_rings_xdp &&
> + tx_buf->action == XDP_REDIRECT) {
> + dma_unmap_single(&pdev->dev,
> + dma_unmap_addr(tx_buf, mapping),
> + dma_unmap_len(tx_buf, len),
> + DMA_TO_DEVICE);
> + xdp_return_frame(tx_buf->xdpf);
> + tx_buf->action = 0;
> + tx_buf->xdpf = NULL;
> + i++;
> continue;
> + }
>
> - for (j = 0; j < max_idx;) {
> - struct bnxt_sw_tx_bd *tx_buf = &txr->tx_buf_ring[j];
> - struct sk_buff *skb;
> - int k, last;
> -
> - if (i < bp->tx_nr_rings_xdp &&
> - tx_buf->action == XDP_REDIRECT) {
> - dma_unmap_single(&pdev->dev,
> - dma_unmap_addr(tx_buf, mapping),
> - dma_unmap_len(tx_buf, len),
> - DMA_TO_DEVICE);
> - xdp_return_frame(tx_buf->xdpf);
> - tx_buf->action = 0;
> - tx_buf->xdpf = NULL;
> - j++;
> - continue;
> - }
> + skb = tx_buf->skb;
> + if (!skb) {
> + i++;
> + continue;
> + }
>
> - skb = tx_buf->skb;
> - if (!skb) {
> - j++;
> - continue;
> - }
> + tx_buf->skb = NULL;
>
> - tx_buf->skb = NULL;
> + if (tx_buf->is_push) {
> + dev_kfree_skb(skb);
> + i += 2;
> + continue;
> + }
>
> - if (tx_buf->is_push) {
> - dev_kfree_skb(skb);
> - j += 2;
> - continue;
> - }
> + dma_unmap_single(&pdev->dev,
> + dma_unmap_addr(tx_buf, mapping),
> + skb_headlen(skb),
> + DMA_TO_DEVICE);
>
> - dma_unmap_single(&pdev->dev,
> - dma_unmap_addr(tx_buf, mapping),
> - skb_headlen(skb),
> - DMA_TO_DEVICE);
> + last = tx_buf->nr_frags;
> + i += 2;
> + for (j = 0; j < last; j++, i++) {
> + int ring_idx = i & bp->tx_ring_mask;
> + skb_frag_t *frag = &skb_shinfo(skb)->frags[j];
>
> - last = tx_buf->nr_frags;
> - j += 2;
> - for (k = 0; k < last; k++, j++) {
> - int ring_idx = j & bp->tx_ring_mask;
> - skb_frag_t *frag = &skb_shinfo(skb)->frags[k];
> -
> - tx_buf = &txr->tx_buf_ring[ring_idx];
> - dma_unmap_page(
> - &pdev->dev,
> - dma_unmap_addr(tx_buf, mapping),
> - skb_frag_size(frag), DMA_TO_DEVICE);
> - }
> - dev_kfree_skb(skb);
> + tx_buf = &txr->tx_buf_ring[ring_idx];
> + dma_unmap_page(&pdev->dev,
> + dma_unmap_addr(tx_buf, mapping),
> + skb_frag_size(frag), DMA_TO_DEVICE);
> }
> - netdev_tx_reset_queue(netdev_get_tx_queue(bp->dev, i));
> + dev_kfree_skb(skb);
> + }
> + netdev_tx_reset_queue(netdev_get_tx_queue(bp->dev, idx));
> +}
> +
> +static void bnxt_free_tx_skbs(struct bnxt *bp)
> +{
> + int i;
> +
> + if (!bp->tx_ring)
> + return;
> +
> + for (i = 0; i < bp->tx_nr_rings; i++) {
> + struct bnxt_tx_ring_info *txr = &bp->tx_ring[i];
> +
> + if (!txr->tx_buf_ring)
> + continue;
> +
> + bnxt_free_one_tx_ring_skbs(bp, txr, i);
> }
> }
Looks fine, I didn't find any functional changes from previous version.
Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
>
> --
> 2.30.1
^ permalink raw reply [flat|nested] 28+ messages in thread
* [PATCH net-next 06/10] bnxt_en: Refactor RX/RX AGG ring parameters setup for P5_PLUS
2025-01-13 6:39 [PATCH net-next 00/10] bnxt_en: Add NPAR 1.2 and TPH support Michael Chan
` (4 preceding siblings ...)
2025-01-13 6:39 ` [PATCH net-next 05/10] bnxt_en: Refactor bnxt_free_tx_rings() to free per Tx ring Michael Chan
@ 2025-01-13 6:39 ` Michael Chan
2025-01-13 8:27 ` Michal Swiatkowski
2025-01-13 6:39 ` [PATCH net-next 07/10] bnxt_en: Pass NQ ID to the FW when allocating RX/RX AGG rings Michael Chan
` (3 subsequent siblings)
9 siblings, 1 reply; 28+ messages in thread
From: Michael Chan @ 2025-01-13 6:39 UTC (permalink / raw)
To: davem
Cc: netdev, edumazet, kuba, pabeni, andrew+netdev, pavan.chebbi,
andrew.gospodarek, somnath.kotur, Hongguang Gao, Ajit Khaparde
There is some common code for setting up RX and RX AGG ring allocation
parameters for P5_PLUS chips. Refactor the logic into a new function.
Reviewed-by: Hongguang Gao <hongguang.gao@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
---
drivers/net/ethernet/broadcom/bnxt/bnxt.c | 58 +++++++++++------------
1 file changed, 28 insertions(+), 30 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index 4336a5b54289..c862250d3b77 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -6917,6 +6917,28 @@ static void bnxt_hwrm_ring_grp_free(struct bnxt *bp)
hwrm_req_drop(bp, req);
}
+static void bnxt_set_rx_ring_params_p5(struct bnxt *bp, u32 ring_type,
+ struct hwrm_ring_alloc_input *req,
+ struct bnxt_ring_struct *ring)
+{
+ struct bnxt_ring_grp_info *grp_info = &bp->grp_info[ring->grp_idx];
+ u32 enables = RING_ALLOC_REQ_ENABLES_RX_BUF_SIZE_VALID;
+
+ if (ring_type == HWRM_RING_ALLOC_AGG) {
+ req->ring_type = RING_ALLOC_REQ_RING_TYPE_RX_AGG;
+ req->rx_ring_id = cpu_to_le16(grp_info->rx_fw_ring_id);
+ req->rx_buf_size = cpu_to_le16(BNXT_RX_PAGE_SIZE);
+ enables |= RING_ALLOC_REQ_ENABLES_RX_RING_ID_VALID;
+ } else {
+ req->rx_buf_size = cpu_to_le16(bp->rx_buf_use_size);
+ if (NET_IP_ALIGN == 2)
+ req->flags =
+ cpu_to_le16(RING_ALLOC_REQ_FLAGS_RX_SOP_PAD);
+ }
+ req->stat_ctx_id = cpu_to_le32(grp_info->fw_stats_ctx);
+ req->enables |= cpu_to_le32(enables);
+}
+
static int hwrm_ring_alloc_send_msg(struct bnxt *bp,
struct bnxt_ring_struct *ring,
u32 ring_type, u32 map_index)
@@ -6968,37 +6990,13 @@ static int hwrm_ring_alloc_send_msg(struct bnxt *bp,
break;
}
case HWRM_RING_ALLOC_RX:
- req->ring_type = RING_ALLOC_REQ_RING_TYPE_RX;
- req->length = cpu_to_le32(bp->rx_ring_mask + 1);
- if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) {
- u16 flags = 0;
-
- /* Association of rx ring with stats context */
- grp_info = &bp->grp_info[ring->grp_idx];
- req->rx_buf_size = cpu_to_le16(bp->rx_buf_use_size);
- req->stat_ctx_id = cpu_to_le32(grp_info->fw_stats_ctx);
- req->enables |= cpu_to_le32(
- RING_ALLOC_REQ_ENABLES_RX_BUF_SIZE_VALID);
- if (NET_IP_ALIGN == 2)
- flags = RING_ALLOC_REQ_FLAGS_RX_SOP_PAD;
- req->flags = cpu_to_le16(flags);
- }
- break;
case HWRM_RING_ALLOC_AGG:
- if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) {
- req->ring_type = RING_ALLOC_REQ_RING_TYPE_RX_AGG;
- /* Association of agg ring with rx ring */
- grp_info = &bp->grp_info[ring->grp_idx];
- req->rx_ring_id = cpu_to_le16(grp_info->rx_fw_ring_id);
- req->rx_buf_size = cpu_to_le16(BNXT_RX_PAGE_SIZE);
- req->stat_ctx_id = cpu_to_le32(grp_info->fw_stats_ctx);
- req->enables |= cpu_to_le32(
- RING_ALLOC_REQ_ENABLES_RX_RING_ID_VALID |
- RING_ALLOC_REQ_ENABLES_RX_BUF_SIZE_VALID);
- } else {
- req->ring_type = RING_ALLOC_REQ_RING_TYPE_RX;
- }
- req->length = cpu_to_le32(bp->rx_agg_ring_mask + 1);
+ req->ring_type = RING_ALLOC_REQ_RING_TYPE_RX;
+ req->length = (ring_type == HWRM_RING_ALLOC_RX) ?
+ cpu_to_le32(bp->rx_ring_mask + 1) :
+ cpu_to_le32(bp->rx_agg_ring_mask + 1);
+ if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS)
+ bnxt_set_rx_ring_params_p5(bp, ring_type, req, ring);
break;
case HWRM_RING_ALLOC_CMPL:
req->ring_type = RING_ALLOC_REQ_RING_TYPE_L2_CMPL;
--
2.30.1
^ permalink raw reply related [flat|nested] 28+ messages in thread* Re: [PATCH net-next 06/10] bnxt_en: Refactor RX/RX AGG ring parameters setup for P5_PLUS
2025-01-13 6:39 ` [PATCH net-next 06/10] bnxt_en: Refactor RX/RX AGG ring parameters setup for P5_PLUS Michael Chan
@ 2025-01-13 8:27 ` Michal Swiatkowski
0 siblings, 0 replies; 28+ messages in thread
From: Michal Swiatkowski @ 2025-01-13 8:27 UTC (permalink / raw)
To: Michael Chan
Cc: davem, netdev, edumazet, kuba, pabeni, andrew+netdev,
pavan.chebbi, andrew.gospodarek, somnath.kotur, Hongguang Gao,
Ajit Khaparde
On Sun, Jan 12, 2025 at 10:39:23PM -0800, Michael Chan wrote:
> There is some common code for setting up RX and RX AGG ring allocation
> parameters for P5_PLUS chips. Refactor the logic into a new function.
>
> Reviewed-by: Hongguang Gao <hongguang.gao@broadcom.com>
> Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
> Signed-off-by: Michael Chan <michael.chan@broadcom.com>
> ---
> drivers/net/ethernet/broadcom/bnxt/bnxt.c | 58 +++++++++++------------
> 1 file changed, 28 insertions(+), 30 deletions(-)
>
> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> index 4336a5b54289..c862250d3b77 100644
> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> @@ -6917,6 +6917,28 @@ static void bnxt_hwrm_ring_grp_free(struct bnxt *bp)
> hwrm_req_drop(bp, req);
> }
>
> +static void bnxt_set_rx_ring_params_p5(struct bnxt *bp, u32 ring_type,
> + struct hwrm_ring_alloc_input *req,
> + struct bnxt_ring_struct *ring)
> +{
> + struct bnxt_ring_grp_info *grp_info = &bp->grp_info[ring->grp_idx];
> + u32 enables = RING_ALLOC_REQ_ENABLES_RX_BUF_SIZE_VALID;
> +
> + if (ring_type == HWRM_RING_ALLOC_AGG) {
> + req->ring_type = RING_ALLOC_REQ_RING_TYPE_RX_AGG;
> + req->rx_ring_id = cpu_to_le16(grp_info->rx_fw_ring_id);
> + req->rx_buf_size = cpu_to_le16(BNXT_RX_PAGE_SIZE);
> + enables |= RING_ALLOC_REQ_ENABLES_RX_RING_ID_VALID;
> + } else {
> + req->rx_buf_size = cpu_to_le16(bp->rx_buf_use_size);
> + if (NET_IP_ALIGN == 2)
> + req->flags =
> + cpu_to_le16(RING_ALLOC_REQ_FLAGS_RX_SOP_PAD);
> + }
> + req->stat_ctx_id = cpu_to_le32(grp_info->fw_stats_ctx);
> + req->enables |= cpu_to_le32(enables);
> +}
> +
> static int hwrm_ring_alloc_send_msg(struct bnxt *bp,
> struct bnxt_ring_struct *ring,
> u32 ring_type, u32 map_index)
> @@ -6968,37 +6990,13 @@ static int hwrm_ring_alloc_send_msg(struct bnxt *bp,
> break;
> }
> case HWRM_RING_ALLOC_RX:
> - req->ring_type = RING_ALLOC_REQ_RING_TYPE_RX;
> - req->length = cpu_to_le32(bp->rx_ring_mask + 1);
> - if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) {
> - u16 flags = 0;
> -
> - /* Association of rx ring with stats context */
> - grp_info = &bp->grp_info[ring->grp_idx];
> - req->rx_buf_size = cpu_to_le16(bp->rx_buf_use_size);
> - req->stat_ctx_id = cpu_to_le32(grp_info->fw_stats_ctx);
> - req->enables |= cpu_to_le32(
> - RING_ALLOC_REQ_ENABLES_RX_BUF_SIZE_VALID);
> - if (NET_IP_ALIGN == 2)
> - flags = RING_ALLOC_REQ_FLAGS_RX_SOP_PAD;
> - req->flags = cpu_to_le16(flags);
> - }
> - break;
> case HWRM_RING_ALLOC_AGG:
> - if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) {
> - req->ring_type = RING_ALLOC_REQ_RING_TYPE_RX_AGG;
> - /* Association of agg ring with rx ring */
> - grp_info = &bp->grp_info[ring->grp_idx];
> - req->rx_ring_id = cpu_to_le16(grp_info->rx_fw_ring_id);
> - req->rx_buf_size = cpu_to_le16(BNXT_RX_PAGE_SIZE);
> - req->stat_ctx_id = cpu_to_le32(grp_info->fw_stats_ctx);
> - req->enables |= cpu_to_le32(
> - RING_ALLOC_REQ_ENABLES_RX_RING_ID_VALID |
> - RING_ALLOC_REQ_ENABLES_RX_BUF_SIZE_VALID);
> - } else {
> - req->ring_type = RING_ALLOC_REQ_RING_TYPE_RX;
> - }
> - req->length = cpu_to_le32(bp->rx_agg_ring_mask + 1);
> + req->ring_type = RING_ALLOC_REQ_RING_TYPE_RX;
> + req->length = (ring_type == HWRM_RING_ALLOC_RX) ?
> + cpu_to_le32(bp->rx_ring_mask + 1) :
> + cpu_to_le32(bp->rx_agg_ring_mask + 1);
> + if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS)
> + bnxt_set_rx_ring_params_p5(bp, ring_type, req, ring);
> break;
> case HWRM_RING_ALLOC_CMPL:
> req->ring_type = RING_ALLOC_REQ_RING_TYPE_L2_CMPL;
> --
> 2.30.1
Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
^ permalink raw reply [flat|nested] 28+ messages in thread
* [PATCH net-next 07/10] bnxt_en: Pass NQ ID to the FW when allocating RX/RX AGG rings
2025-01-13 6:39 [PATCH net-next 00/10] bnxt_en: Add NPAR 1.2 and TPH support Michael Chan
` (5 preceding siblings ...)
2025-01-13 6:39 ` [PATCH net-next 06/10] bnxt_en: Refactor RX/RX AGG ring parameters setup for P5_PLUS Michael Chan
@ 2025-01-13 6:39 ` Michael Chan
2025-01-13 8:29 ` Michal Swiatkowski
2025-01-13 6:39 ` [PATCH net-next 08/10] bnxt_en: Reallocate Rx completion ring for TPH support Michael Chan
` (2 subsequent siblings)
9 siblings, 1 reply; 28+ messages in thread
From: Michael Chan @ 2025-01-13 6:39 UTC (permalink / raw)
To: davem
Cc: netdev, edumazet, kuba, pabeni, andrew+netdev, pavan.chebbi,
andrew.gospodarek, somnath.kotur, Hongguang Gao, Ajit Khaparde
Newer firmware can use the NQ ring ID associated with each RX/RX AGG
ring to enable PCIe Steering Tags on P5_PLUS chips. When allocating
RX/RX AGG rings, pass along NQ ring ID for the firmware to use. This
information helps optimize DMA writes by directing them to the cache
closer to the CPU consuming the data, potentially improving the
processing speed. This change is backward-compatible with older
firmware, which will simply disregard the information.
Reviewed-by: Hongguang Gao <hongguang.gao@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
Signed-off-by: Andy Gospodarek <andrew.gospodarek@broadcom.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
---
drivers/net/ethernet/broadcom/bnxt/bnxt.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index c862250d3b77..30a57bbc407c 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -6922,7 +6922,8 @@ static void bnxt_set_rx_ring_params_p5(struct bnxt *bp, u32 ring_type,
struct bnxt_ring_struct *ring)
{
struct bnxt_ring_grp_info *grp_info = &bp->grp_info[ring->grp_idx];
- u32 enables = RING_ALLOC_REQ_ENABLES_RX_BUF_SIZE_VALID;
+ u32 enables = RING_ALLOC_REQ_ENABLES_RX_BUF_SIZE_VALID |
+ RING_ALLOC_REQ_ENABLES_NQ_RING_ID_VALID;
if (ring_type == HWRM_RING_ALLOC_AGG) {
req->ring_type = RING_ALLOC_REQ_RING_TYPE_RX_AGG;
@@ -6936,6 +6937,7 @@ static void bnxt_set_rx_ring_params_p5(struct bnxt *bp, u32 ring_type,
cpu_to_le16(RING_ALLOC_REQ_FLAGS_RX_SOP_PAD);
}
req->stat_ctx_id = cpu_to_le32(grp_info->fw_stats_ctx);
+ req->nq_ring_id = cpu_to_le16(grp_info->cp_fw_ring_id);
req->enables |= cpu_to_le32(enables);
}
--
2.30.1
^ permalink raw reply related [flat|nested] 28+ messages in thread* Re: [PATCH net-next 07/10] bnxt_en: Pass NQ ID to the FW when allocating RX/RX AGG rings
2025-01-13 6:39 ` [PATCH net-next 07/10] bnxt_en: Pass NQ ID to the FW when allocating RX/RX AGG rings Michael Chan
@ 2025-01-13 8:29 ` Michal Swiatkowski
0 siblings, 0 replies; 28+ messages in thread
From: Michal Swiatkowski @ 2025-01-13 8:29 UTC (permalink / raw)
To: Michael Chan
Cc: davem, netdev, edumazet, kuba, pabeni, andrew+netdev,
pavan.chebbi, andrew.gospodarek, somnath.kotur, Hongguang Gao,
Ajit Khaparde
On Sun, Jan 12, 2025 at 10:39:24PM -0800, Michael Chan wrote:
> Newer firmware can use the NQ ring ID associated with each RX/RX AGG
> ring to enable PCIe Steering Tags on P5_PLUS chips. When allocating
> RX/RX AGG rings, pass along NQ ring ID for the firmware to use. This
> information helps optimize DMA writes by directing them to the cache
> closer to the CPU consuming the data, potentially improving the
> processing speed. This change is backward-compatible with older
> firmware, which will simply disregard the information.
>
> Reviewed-by: Hongguang Gao <hongguang.gao@broadcom.com>
> Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
> Signed-off-by: Andy Gospodarek <andrew.gospodarek@broadcom.com>
> Signed-off-by: Michael Chan <michael.chan@broadcom.com>
> ---
> drivers/net/ethernet/broadcom/bnxt/bnxt.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> index c862250d3b77..30a57bbc407c 100644
> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> @@ -6922,7 +6922,8 @@ static void bnxt_set_rx_ring_params_p5(struct bnxt *bp, u32 ring_type,
> struct bnxt_ring_struct *ring)
> {
> struct bnxt_ring_grp_info *grp_info = &bp->grp_info[ring->grp_idx];
> - u32 enables = RING_ALLOC_REQ_ENABLES_RX_BUF_SIZE_VALID;
> + u32 enables = RING_ALLOC_REQ_ENABLES_RX_BUF_SIZE_VALID |
> + RING_ALLOC_REQ_ENABLES_NQ_RING_ID_VALID;
>
> if (ring_type == HWRM_RING_ALLOC_AGG) {
> req->ring_type = RING_ALLOC_REQ_RING_TYPE_RX_AGG;
> @@ -6936,6 +6937,7 @@ static void bnxt_set_rx_ring_params_p5(struct bnxt *bp, u32 ring_type,
> cpu_to_le16(RING_ALLOC_REQ_FLAGS_RX_SOP_PAD);
> }
> req->stat_ctx_id = cpu_to_le32(grp_info->fw_stats_ctx);
> + req->nq_ring_id = cpu_to_le16(grp_info->cp_fw_ring_id);
> req->enables |= cpu_to_le32(enables);
> }
>
> --
> 2.30.1
Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
^ permalink raw reply [flat|nested] 28+ messages in thread
* [PATCH net-next 08/10] bnxt_en: Reallocate Rx completion ring for TPH support
2025-01-13 6:39 [PATCH net-next 00/10] bnxt_en: Add NPAR 1.2 and TPH support Michael Chan
` (6 preceding siblings ...)
2025-01-13 6:39 ` [PATCH net-next 07/10] bnxt_en: Pass NQ ID to the FW when allocating RX/RX AGG rings Michael Chan
@ 2025-01-13 6:39 ` Michael Chan
2025-01-13 8:35 ` Michal Swiatkowski
2025-01-13 6:39 ` [PATCH net-next 09/10] bnxt_en: Extend queue stop/start for Tx rings Michael Chan
2025-01-13 6:39 ` [PATCH net-next 10/10] bnxt_en: Add TPH support in BNXT driver Michael Chan
9 siblings, 1 reply; 28+ messages in thread
From: Michael Chan @ 2025-01-13 6:39 UTC (permalink / raw)
To: davem
Cc: netdev, edumazet, kuba, pabeni, andrew+netdev, pavan.chebbi,
andrew.gospodarek, somnath.kotur, David Wei
From: Somnath Kotur <somnath.kotur@broadcom.com>
In order to program the correct Steering Tag during an IRQ affinity
change, we need to free/re-allocate the Rx completion ring during
queue_restart. Call FW to free the Rx completion ring and clear the
ring entries in queue_stop(). Re-allocate it in queue_start().
Signed-off-by: Somnath Kotur <somnath.kotur@broadcom.com>
Reviewed-by: Michael Chan <michael.chan@broadcom.com>
---
Cc: David Wei <dw@davidwei.uk>
---
drivers/net/ethernet/broadcom/bnxt/bnxt.c | 26 +++++++++++++++++++++--
1 file changed, 24 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index 30a57bbc407c..fe350d0ba99c 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -7399,6 +7399,19 @@ static void bnxt_hwrm_cp_ring_free(struct bnxt *bp,
ring->fw_ring_id = INVALID_HW_RING_ID;
}
+static void bnxt_clear_one_cp_ring(struct bnxt *bp, struct bnxt_cp_ring_info *cpr)
+{
+ struct bnxt_ring_struct *ring = &cpr->cp_ring_struct;
+ int i, size = ring->ring_mem.page_size;
+
+ cpr->cp_raw_cons = 0;
+ cpr->toggle = 0;
+
+ for (i = 0; i < bp->cp_nr_pages; i++)
+ if (cpr->cp_desc_ring[i])
+ memset(cpr->cp_desc_ring[i], 0, size);
+}
+
static void bnxt_hwrm_ring_free(struct bnxt *bp, bool close_path)
{
u32 type;
@@ -15618,10 +15631,15 @@ static int bnxt_queue_start(struct net_device *dev, void *qmem, int idx)
rc = bnxt_hwrm_rx_ring_alloc(bp, rxr);
if (rc)
return rc;
- rc = bnxt_hwrm_rx_agg_ring_alloc(bp, rxr);
+
+ rc = bnxt_hwrm_cp_ring_alloc_p5(bp, rxr->rx_cpr);
if (rc)
goto err_free_hwrm_rx_ring;
+ rc = bnxt_hwrm_rx_agg_ring_alloc(bp, rxr);
+ if (rc)
+ goto err_free_hwrm_cp_ring;
+
bnxt_db_write(bp, &rxr->rx_db, rxr->rx_prod);
if (bp->flags & BNXT_FLAG_AGG_RINGS)
bnxt_db_write(bp, &rxr->rx_agg_db, rxr->rx_agg_prod);
@@ -15645,6 +15663,8 @@ static int bnxt_queue_start(struct net_device *dev, void *qmem, int idx)
return 0;
+err_free_hwrm_cp_ring:
+ bnxt_hwrm_cp_ring_free(bp, rxr->rx_cpr);
err_free_hwrm_rx_ring:
bnxt_hwrm_rx_ring_free(bp, rxr, false);
return rc;
@@ -15669,11 +15689,13 @@ static int bnxt_queue_stop(struct net_device *dev, void *qmem, int idx)
cancel_work_sync(&rxr->bnapi->cp_ring.dim.work);
bnxt_hwrm_rx_ring_free(bp, rxr, false);
bnxt_hwrm_rx_agg_ring_free(bp, rxr, false);
- rxr->rx_next_cons = 0;
page_pool_disable_direct_recycling(rxr->page_pool);
if (bnxt_separate_head_pool())
page_pool_disable_direct_recycling(rxr->head_pool);
+ bnxt_hwrm_cp_ring_free(bp, rxr->rx_cpr);
+ bnxt_clear_one_cp_ring(bp, rxr->rx_cpr);
+
memcpy(qmem, rxr, sizeof(*rxr));
bnxt_init_rx_ring_struct(bp, qmem);
--
2.30.1
^ permalink raw reply related [flat|nested] 28+ messages in thread* Re: [PATCH net-next 08/10] bnxt_en: Reallocate Rx completion ring for TPH support
2025-01-13 6:39 ` [PATCH net-next 08/10] bnxt_en: Reallocate Rx completion ring for TPH support Michael Chan
@ 2025-01-13 8:35 ` Michal Swiatkowski
2025-01-14 21:42 ` Michael Chan
0 siblings, 1 reply; 28+ messages in thread
From: Michal Swiatkowski @ 2025-01-13 8:35 UTC (permalink / raw)
To: Michael Chan
Cc: davem, netdev, edumazet, kuba, pabeni, andrew+netdev,
pavan.chebbi, andrew.gospodarek, somnath.kotur, David Wei
On Sun, Jan 12, 2025 at 10:39:25PM -0800, Michael Chan wrote:
> From: Somnath Kotur <somnath.kotur@broadcom.com>
>
> In order to program the correct Steering Tag during an IRQ affinity
> change, we need to free/re-allocate the Rx completion ring during
> queue_restart. Call FW to free the Rx completion ring and clear the
> ring entries in queue_stop(). Re-allocate it in queue_start().
>
> Signed-off-by: Somnath Kotur <somnath.kotur@broadcom.com>
> Reviewed-by: Michael Chan <michael.chan@broadcom.com>
> ---
> Cc: David Wei <dw@davidwei.uk>
> ---
> drivers/net/ethernet/broadcom/bnxt/bnxt.c | 26 +++++++++++++++++++++--
> 1 file changed, 24 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> index 30a57bbc407c..fe350d0ba99c 100644
> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> @@ -7399,6 +7399,19 @@ static void bnxt_hwrm_cp_ring_free(struct bnxt *bp,
> ring->fw_ring_id = INVALID_HW_RING_ID;
> }
>
> +static void bnxt_clear_one_cp_ring(struct bnxt *bp, struct bnxt_cp_ring_info *cpr)
> +{
> + struct bnxt_ring_struct *ring = &cpr->cp_ring_struct;
> + int i, size = ring->ring_mem.page_size;
> +
> + cpr->cp_raw_cons = 0;
> + cpr->toggle = 0;
> +
> + for (i = 0; i < bp->cp_nr_pages; i++)
> + if (cpr->cp_desc_ring[i])
> + memset(cpr->cp_desc_ring[i], 0, size);
> +}
> +
> static void bnxt_hwrm_ring_free(struct bnxt *bp, bool close_path)
> {
> u32 type;
> @@ -15618,10 +15631,15 @@ static int bnxt_queue_start(struct net_device *dev, void *qmem, int idx)
> rc = bnxt_hwrm_rx_ring_alloc(bp, rxr);
> if (rc)
> return rc;
> - rc = bnxt_hwrm_rx_agg_ring_alloc(bp, rxr);
> +
> + rc = bnxt_hwrm_cp_ring_alloc_p5(bp, rxr->rx_cpr);
> if (rc)
> goto err_free_hwrm_rx_ring;
>
> + rc = bnxt_hwrm_rx_agg_ring_alloc(bp, rxr);
> + if (rc)
> + goto err_free_hwrm_cp_ring;
> +
> bnxt_db_write(bp, &rxr->rx_db, rxr->rx_prod);
> if (bp->flags & BNXT_FLAG_AGG_RINGS)
> bnxt_db_write(bp, &rxr->rx_agg_db, rxr->rx_agg_prod);
> @@ -15645,6 +15663,8 @@ static int bnxt_queue_start(struct net_device *dev, void *qmem, int idx)
>
> return 0;
>
> +err_free_hwrm_cp_ring:
> + bnxt_hwrm_cp_ring_free(bp, rxr->rx_cpr);
> err_free_hwrm_rx_ring:
> bnxt_hwrm_rx_ring_free(bp, rxr, false);
> return rc;
> @@ -15669,11 +15689,13 @@ static int bnxt_queue_stop(struct net_device *dev, void *qmem, int idx)
> cancel_work_sync(&rxr->bnapi->cp_ring.dim.work);
> bnxt_hwrm_rx_ring_free(bp, rxr, false);
> bnxt_hwrm_rx_agg_ring_free(bp, rxr, false);
> - rxr->rx_next_cons = 0;
Unrelated?
> page_pool_disable_direct_recycling(rxr->page_pool);
> if (bnxt_separate_head_pool())
> page_pool_disable_direct_recycling(rxr->head_pool);
>
> + bnxt_hwrm_cp_ring_free(bp, rxr->rx_cpr);
> + bnxt_clear_one_cp_ring(bp, rxr->rx_cpr);
> +
> memcpy(qmem, rxr, sizeof(*rxr));
> bnxt_init_rx_ring_struct(bp, qmem);
>
Rest looks fine:
Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
> --
> 2.30.1
^ permalink raw reply [flat|nested] 28+ messages in thread* Re: [PATCH net-next 08/10] bnxt_en: Reallocate Rx completion ring for TPH support
2025-01-13 8:35 ` Michal Swiatkowski
@ 2025-01-14 21:42 ` Michael Chan
2025-01-15 5:58 ` Michal Swiatkowski
0 siblings, 1 reply; 28+ messages in thread
From: Michael Chan @ 2025-01-14 21:42 UTC (permalink / raw)
To: Michal Swiatkowski
Cc: davem, netdev, edumazet, kuba, pabeni, andrew+netdev,
pavan.chebbi, andrew.gospodarek, somnath.kotur, David Wei
[-- Attachment #1: Type: text/plain, Size: 1237 bytes --]
On Mon, Jan 13, 2025 at 12:38 AM Michal Swiatkowski
<michal.swiatkowski@linux.intel.com> wrote:
>
> On Sun, Jan 12, 2025 at 10:39:25PM -0800, Michael Chan wrote:
> > From: Somnath Kotur <somnath.kotur@broadcom.com>
> > @@ -15669,11 +15689,13 @@ static int bnxt_queue_stop(struct net_device *dev, void *qmem, int idx)
> > cancel_work_sync(&rxr->bnapi->cp_ring.dim.work);
> > bnxt_hwrm_rx_ring_free(bp, rxr, false);
> > bnxt_hwrm_rx_agg_ring_free(bp, rxr, false);
> > - rxr->rx_next_cons = 0;
> Unrelated?
This line is unneeded. It gets overwritten by the clone during
queue_start(). We remove it since we are making related changes in
this function. I'll add a comment about this in the Changelog.
Thanks.
>
> > page_pool_disable_direct_recycling(rxr->page_pool);
> > if (bnxt_separate_head_pool())
> > page_pool_disable_direct_recycling(rxr->head_pool);
> >
> > + bnxt_hwrm_cp_ring_free(bp, rxr->rx_cpr);
> > + bnxt_clear_one_cp_ring(bp, rxr->rx_cpr);
> > +
> > memcpy(qmem, rxr, sizeof(*rxr));
> > bnxt_init_rx_ring_struct(bp, qmem);
> >
>
> Rest looks fine:
> Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4209 bytes --]
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH net-next 08/10] bnxt_en: Reallocate Rx completion ring for TPH support
2025-01-14 21:42 ` Michael Chan
@ 2025-01-15 5:58 ` Michal Swiatkowski
0 siblings, 0 replies; 28+ messages in thread
From: Michal Swiatkowski @ 2025-01-15 5:58 UTC (permalink / raw)
To: Michael Chan
Cc: davem, netdev, edumazet, kuba, pabeni, andrew+netdev,
pavan.chebbi, andrew.gospodarek, somnath.kotur, David Wei
On Tue, Jan 14, 2025 at 01:42:42PM -0800, Michael Chan wrote:
> On Mon, Jan 13, 2025 at 12:38 AM Michal Swiatkowski
> <michal.swiatkowski@linux.intel.com> wrote:
> >
> > On Sun, Jan 12, 2025 at 10:39:25PM -0800, Michael Chan wrote:
> > > From: Somnath Kotur <somnath.kotur@broadcom.com>
> > > @@ -15669,11 +15689,13 @@ static int bnxt_queue_stop(struct net_device *dev, void *qmem, int idx)
> > > cancel_work_sync(&rxr->bnapi->cp_ring.dim.work);
> > > bnxt_hwrm_rx_ring_free(bp, rxr, false);
> > > bnxt_hwrm_rx_agg_ring_free(bp, rxr, false);
> > > - rxr->rx_next_cons = 0;
> > Unrelated?
>
> This line is unneeded. It gets overwritten by the clone during
> queue_start(). We remove it since we are making related changes in
> this function. I'll add a comment about this in the Changelog.
> Thanks.
Sure, thanks.
>
> >
> > > page_pool_disable_direct_recycling(rxr->page_pool);
> > > if (bnxt_separate_head_pool())
> > > page_pool_disable_direct_recycling(rxr->head_pool);
> > >
> > > + bnxt_hwrm_cp_ring_free(bp, rxr->rx_cpr);
> > > + bnxt_clear_one_cp_ring(bp, rxr->rx_cpr);
> > > +
> > > memcpy(qmem, rxr, sizeof(*rxr));
> > > bnxt_init_rx_ring_struct(bp, qmem);
> > >
> >
> > Rest looks fine:
> > Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
^ permalink raw reply [flat|nested] 28+ messages in thread
* [PATCH net-next 09/10] bnxt_en: Extend queue stop/start for Tx rings
2025-01-13 6:39 [PATCH net-next 00/10] bnxt_en: Add NPAR 1.2 and TPH support Michael Chan
` (7 preceding siblings ...)
2025-01-13 6:39 ` [PATCH net-next 08/10] bnxt_en: Reallocate Rx completion ring for TPH support Michael Chan
@ 2025-01-13 6:39 ` Michael Chan
2025-01-13 8:40 ` Michal Swiatkowski
` (3 more replies)
2025-01-13 6:39 ` [PATCH net-next 10/10] bnxt_en: Add TPH support in BNXT driver Michael Chan
9 siblings, 4 replies; 28+ messages in thread
From: Michael Chan @ 2025-01-13 6:39 UTC (permalink / raw)
To: davem
Cc: netdev, edumazet, kuba, pabeni, andrew+netdev, pavan.chebbi,
andrew.gospodarek, somnath.kotur, Ajit Khaparde, David Wei
From: Somnath Kotur <somnath.kotur@broadcom.com>
In order to use queue_stop/queue_start to support the new Steering
Tags, we need to free the TX ring and TX completion ring if it is a
combined channel with TX/RX sharing the same NAPI. Otherwise
TX completions will not have the updated Steering Tag. With that
we can now add napi_disable() and napi_enable() during queue_stop()/
queue_start(). This will guarantee that NAPI will stop processing
the completion entries in case there are additional pending entries
in the completion rings after queue_stop().
There could be some NQEs sitting unprocessed while NAPI is disabled
thereby leaving the NQ unarmed. Explictily Re-arm the NQ after
napi_enable() in queue start so that NAPI will resume properly.
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
Signed-off-by: Somnath Kotur <somnath.kotur@broadcom.com>
Reviewed-by: Michael Chan <michael.chan@broadcom.com>
---
Cc: David Wei <dw@davidwei.uk>
Discussion about adding napi_disable()/napi_enable():
https://lore.kernel.org/netdev/5336d624-8d8b-40a6-b732-b020e4a119a2@davidwei.uk/#t
---
drivers/net/ethernet/broadcom/bnxt/bnxt.c | 99 ++++++++++++++++++++++-
1 file changed, 98 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index fe350d0ba99c..eddb4de959c6 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -7341,6 +7341,22 @@ static int hwrm_ring_free_send_msg(struct bnxt *bp,
return 0;
}
+static void bnxt_hwrm_tx_ring_free(struct bnxt *bp, struct bnxt_tx_ring_info *txr,
+ bool close_path)
+{
+ struct bnxt_ring_struct *ring = &txr->tx_ring_struct;
+ u32 cmpl_ring_id;
+
+ if (ring->fw_ring_id == INVALID_HW_RING_ID)
+ return;
+
+ cmpl_ring_id = close_path ? bnxt_cp_ring_for_tx(bp, txr) :
+ INVALID_HW_RING_ID;
+ hwrm_ring_free_send_msg(bp, ring, RING_FREE_REQ_RING_TYPE_TX,
+ cmpl_ring_id);
+ ring->fw_ring_id = INVALID_HW_RING_ID;
+}
+
static void bnxt_hwrm_rx_ring_free(struct bnxt *bp,
struct bnxt_rx_ring_info *rxr,
bool close_path)
@@ -11247,6 +11263,69 @@ int bnxt_reserve_rings(struct bnxt *bp, bool irq_re_init)
return 0;
}
+static void bnxt_tx_queue_stop(struct bnxt *bp, int idx)
+{
+ struct bnxt_tx_ring_info *txr;
+ struct netdev_queue *txq;
+ struct bnxt_napi *bnapi;
+ int i;
+
+ bnapi = bp->bnapi[idx];
+ bnxt_for_each_napi_tx(i, bnapi, txr) {
+ WRITE_ONCE(txr->dev_state, BNXT_DEV_STATE_CLOSING);
+ synchronize_net();
+
+ if (!(bnapi->flags & BNXT_NAPI_FLAG_XDP)) {
+ txq = netdev_get_tx_queue(bp->dev, txr->txq_index);
+ if (txq) {
+ __netif_tx_lock_bh(txq);
+ netif_tx_stop_queue(txq);
+ __netif_tx_unlock_bh(txq);
+ }
+ }
+ bnxt_hwrm_tx_ring_free(bp, txr, true);
+ bnxt_hwrm_cp_ring_free(bp, txr->tx_cpr);
+ bnxt_free_one_tx_ring_skbs(bp, txr, txr->txq_index);
+ bnxt_clear_one_cp_ring(bp, txr->tx_cpr);
+ }
+}
+
+static int bnxt_tx_queue_start(struct bnxt *bp, int idx)
+{
+ struct bnxt_tx_ring_info *txr;
+ struct netdev_queue *txq;
+ struct bnxt_napi *bnapi;
+ int rc, i;
+
+ bnapi = bp->bnapi[idx];
+ bnxt_for_each_napi_tx(i, bnapi, txr) {
+ rc = bnxt_hwrm_cp_ring_alloc_p5(bp, txr->tx_cpr);
+ if (rc)
+ return rc;
+
+ rc = bnxt_hwrm_tx_ring_alloc(bp, txr, false);
+ if (rc) {
+ bnxt_hwrm_cp_ring_free(bp, txr->tx_cpr);
+ return rc;
+ }
+ txr->tx_prod = 0;
+ txr->tx_cons = 0;
+ txr->tx_hw_cons = 0;
+
+ WRITE_ONCE(txr->dev_state, 0);
+ synchronize_net();
+
+ if (bnapi->flags & BNXT_NAPI_FLAG_XDP)
+ continue;
+
+ txq = netdev_get_tx_queue(bp->dev, txr->txq_index);
+ if (txq)
+ netif_tx_start_queue(txq);
+ }
+
+ return 0;
+}
+
static void bnxt_free_irq(struct bnxt *bp)
{
struct bnxt_irq *irq;
@@ -15647,6 +15726,16 @@ static int bnxt_queue_start(struct net_device *dev, void *qmem, int idx)
cpr = &rxr->bnapi->cp_ring;
cpr->sw_stats->rx.rx_resets++;
+ if (bp->flags & BNXT_FLAG_SHARED_RINGS) {
+ rc = bnxt_tx_queue_start(bp, idx);
+ if (rc)
+ netdev_warn(bp->dev,
+ "tx queue restart failed: rc=%d\n", rc);
+ }
+
+ napi_enable(&rxr->bnapi->napi);
+ bnxt_db_nq_arm(bp, &cpr->cp_db, cpr->cp_raw_cons);
+
for (i = 0; i <= BNXT_VNIC_NTUPLE; i++) {
vnic = &bp->vnic_info[i];
@@ -15675,6 +15764,7 @@ 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;
+ struct bnxt_napi *bnapi;
int i;
for (i = 0; i <= BNXT_VNIC_NTUPLE; i++) {
@@ -15686,15 +15776,22 @@ static int bnxt_queue_stop(struct net_device *dev, void *qmem, int idx)
/* Make sure NAPI sees that the VNIC is disabled */
synchronize_net();
rxr = &bp->rx_ring[idx];
- cancel_work_sync(&rxr->bnapi->cp_ring.dim.work);
+ bnapi = rxr->bnapi;
+ cancel_work_sync(&bnapi->cp_ring.dim.work);
bnxt_hwrm_rx_ring_free(bp, rxr, false);
bnxt_hwrm_rx_agg_ring_free(bp, rxr, false);
page_pool_disable_direct_recycling(rxr->page_pool);
if (bnxt_separate_head_pool())
page_pool_disable_direct_recycling(rxr->head_pool);
+ if (bp->flags & BNXT_FLAG_SHARED_RINGS)
+ bnxt_tx_queue_stop(bp, idx);
+
+ napi_disable(&bnapi->napi);
+
bnxt_hwrm_cp_ring_free(bp, rxr->rx_cpr);
bnxt_clear_one_cp_ring(bp, rxr->rx_cpr);
+ bnxt_db_nq(bp, &cpr->cp_db, cpr->cp_raw_cons);
memcpy(qmem, rxr, sizeof(*rxr));
bnxt_init_rx_ring_struct(bp, qmem);
--
2.30.1
^ permalink raw reply related [flat|nested] 28+ messages in thread* Re: [PATCH net-next 09/10] bnxt_en: Extend queue stop/start for Tx rings
2025-01-13 6:39 ` [PATCH net-next 09/10] bnxt_en: Extend queue stop/start for Tx rings Michael Chan
@ 2025-01-13 8:40 ` Michal Swiatkowski
2025-01-14 2:05 ` Somnath Kotur
2025-01-15 1:29 ` Michael Chan
2025-01-13 16:01 ` Bjorn Helgaas
` (2 subsequent siblings)
3 siblings, 2 replies; 28+ messages in thread
From: Michal Swiatkowski @ 2025-01-13 8:40 UTC (permalink / raw)
To: Michael Chan
Cc: davem, netdev, edumazet, kuba, pabeni, andrew+netdev,
pavan.chebbi, andrew.gospodarek, somnath.kotur, Ajit Khaparde,
David Wei
On Sun, Jan 12, 2025 at 10:39:26PM -0800, Michael Chan wrote:
> From: Somnath Kotur <somnath.kotur@broadcom.com>
>
> In order to use queue_stop/queue_start to support the new Steering
> Tags, we need to free the TX ring and TX completion ring if it is a
> combined channel with TX/RX sharing the same NAPI. Otherwise
> TX completions will not have the updated Steering Tag. With that
> we can now add napi_disable() and napi_enable() during queue_stop()/
> queue_start(). This will guarantee that NAPI will stop processing
> the completion entries in case there are additional pending entries
> in the completion rings after queue_stop().
>
> There could be some NQEs sitting unprocessed while NAPI is disabled
> thereby leaving the NQ unarmed. Explictily Re-arm the NQ after
> napi_enable() in queue start so that NAPI will resume properly.
>
> Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
> Signed-off-by: Somnath Kotur <somnath.kotur@broadcom.com>
> Reviewed-by: Michael Chan <michael.chan@broadcom.com>
> ---
> Cc: David Wei <dw@davidwei.uk>
>
> Discussion about adding napi_disable()/napi_enable():
>
> https://lore.kernel.org/netdev/5336d624-8d8b-40a6-b732-b020e4a119a2@davidwei.uk/#t
> ---
> drivers/net/ethernet/broadcom/bnxt/bnxt.c | 99 ++++++++++++++++++++++-
> 1 file changed, 98 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> index fe350d0ba99c..eddb4de959c6 100644
> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> @@ -7341,6 +7341,22 @@ static int hwrm_ring_free_send_msg(struct bnxt *bp,
> return 0;
> }
>
> +static void bnxt_hwrm_tx_ring_free(struct bnxt *bp, struct bnxt_tx_ring_info *txr,
> + bool close_path)
> +{
> + struct bnxt_ring_struct *ring = &txr->tx_ring_struct;
> + u32 cmpl_ring_id;
> +
> + if (ring->fw_ring_id == INVALID_HW_RING_ID)
> + return;
> +
> + cmpl_ring_id = close_path ? bnxt_cp_ring_for_tx(bp, txr) :
> + INVALID_HW_RING_ID;
> + hwrm_ring_free_send_msg(bp, ring, RING_FREE_REQ_RING_TYPE_TX,
> + cmpl_ring_id);
> + ring->fw_ring_id = INVALID_HW_RING_ID;
> +}
> +
> static void bnxt_hwrm_rx_ring_free(struct bnxt *bp,
> struct bnxt_rx_ring_info *rxr,
> bool close_path)
> @@ -11247,6 +11263,69 @@ int bnxt_reserve_rings(struct bnxt *bp, bool irq_re_init)
> return 0;
> }
>
> +static void bnxt_tx_queue_stop(struct bnxt *bp, int idx)
> +{
> + struct bnxt_tx_ring_info *txr;
> + struct netdev_queue *txq;
> + struct bnxt_napi *bnapi;
> + int i;
> +
> + bnapi = bp->bnapi[idx];
> + bnxt_for_each_napi_tx(i, bnapi, txr) {
> + WRITE_ONCE(txr->dev_state, BNXT_DEV_STATE_CLOSING);
> + synchronize_net();
> +
> + if (!(bnapi->flags & BNXT_NAPI_FLAG_XDP)) {
> + txq = netdev_get_tx_queue(bp->dev, txr->txq_index);
> + if (txq) {
> + __netif_tx_lock_bh(txq);
> + netif_tx_stop_queue(txq);
> + __netif_tx_unlock_bh(txq);
> + }
> + }
> + bnxt_hwrm_tx_ring_free(bp, txr, true);
> + bnxt_hwrm_cp_ring_free(bp, txr->tx_cpr);
> + bnxt_free_one_tx_ring_skbs(bp, txr, txr->txq_index);
> + bnxt_clear_one_cp_ring(bp, txr->tx_cpr);
> + }
> +}
> +
> +static int bnxt_tx_queue_start(struct bnxt *bp, int idx)
> +{
> + struct bnxt_tx_ring_info *txr;
> + struct netdev_queue *txq;
> + struct bnxt_napi *bnapi;
> + int rc, i;
> +
> + bnapi = bp->bnapi[idx];
> + bnxt_for_each_napi_tx(i, bnapi, txr) {
> + rc = bnxt_hwrm_cp_ring_alloc_p5(bp, txr->tx_cpr);
> + if (rc)
> + return rc;
> +
> + rc = bnxt_hwrm_tx_ring_alloc(bp, txr, false);
> + if (rc) {
> + bnxt_hwrm_cp_ring_free(bp, txr->tx_cpr);
What about ring allocated in previous steps? Don't you need to free them
too?
> + return rc;
> + }
> + txr->tx_prod = 0;
> + txr->tx_cons = 0;
> + txr->tx_hw_cons = 0;
> +
> + WRITE_ONCE(txr->dev_state, 0);
> + synchronize_net();
> +
> + if (bnapi->flags & BNXT_NAPI_FLAG_XDP)
> + continue;
> +
> + txq = netdev_get_tx_queue(bp->dev, txr->txq_index);
> + if (txq)
> + netif_tx_start_queue(txq);
> + }
> +
> + return 0;
> +}
> +
> static void bnxt_free_irq(struct bnxt *bp)
> {
> struct bnxt_irq *irq;
> @@ -15647,6 +15726,16 @@ static int bnxt_queue_start(struct net_device *dev, void *qmem, int idx)
> cpr = &rxr->bnapi->cp_ring;
> cpr->sw_stats->rx.rx_resets++;
>
> + if (bp->flags & BNXT_FLAG_SHARED_RINGS) {
> + rc = bnxt_tx_queue_start(bp, idx);
> + if (rc)
> + netdev_warn(bp->dev,
> + "tx queue restart failed: rc=%d\n", rc);
> + }
> +
> + napi_enable(&rxr->bnapi->napi);
> + bnxt_db_nq_arm(bp, &cpr->cp_db, cpr->cp_raw_cons);
> +
> for (i = 0; i <= BNXT_VNIC_NTUPLE; i++) {
> vnic = &bp->vnic_info[i];
>
> @@ -15675,6 +15764,7 @@ 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;
> + struct bnxt_napi *bnapi;
> int i;
>
> for (i = 0; i <= BNXT_VNIC_NTUPLE; i++) {
> @@ -15686,15 +15776,22 @@ static int bnxt_queue_stop(struct net_device *dev, void *qmem, int idx)
> /* Make sure NAPI sees that the VNIC is disabled */
> synchronize_net();
> rxr = &bp->rx_ring[idx];
> - cancel_work_sync(&rxr->bnapi->cp_ring.dim.work);
> + bnapi = rxr->bnapi;
> + cancel_work_sync(&bnapi->cp_ring.dim.work);
> bnxt_hwrm_rx_ring_free(bp, rxr, false);
> bnxt_hwrm_rx_agg_ring_free(bp, rxr, false);
> page_pool_disable_direct_recycling(rxr->page_pool);
> if (bnxt_separate_head_pool())
> page_pool_disable_direct_recycling(rxr->head_pool);
>
> + if (bp->flags & BNXT_FLAG_SHARED_RINGS)
> + bnxt_tx_queue_stop(bp, idx);
> +
> + napi_disable(&bnapi->napi);
> +
> bnxt_hwrm_cp_ring_free(bp, rxr->rx_cpr);
> bnxt_clear_one_cp_ring(bp, rxr->rx_cpr);
> + bnxt_db_nq(bp, &cpr->cp_db, cpr->cp_raw_cons);
>
> memcpy(qmem, rxr, sizeof(*rxr));
> bnxt_init_rx_ring_struct(bp, qmem);
> --
> 2.30.1
^ permalink raw reply [flat|nested] 28+ messages in thread* Re: [PATCH net-next 09/10] bnxt_en: Extend queue stop/start for Tx rings
2025-01-13 8:40 ` Michal Swiatkowski
@ 2025-01-14 2:05 ` Somnath Kotur
2025-01-15 1:29 ` Michael Chan
1 sibling, 0 replies; 28+ messages in thread
From: Somnath Kotur @ 2025-01-14 2:05 UTC (permalink / raw)
To: Michal Swiatkowski
Cc: Michael Chan, David S. Miller, netdev, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Andrew Lunn, Pavan Chebbi,
Andrew Gospodarek, Ajit Khaparde, David Wei
[-- Attachment #1.1: Type: text/plain, Size: 7302 bytes --]
On Mon, 13 Jan, 2025, 14:13 Michal Swiatkowski, <
michal.swiatkowski@linux.intel.com> wrote:
> On Sun, Jan 12, 2025 at 10:39:26PM -0800, Michael Chan wrote:
> > From: Somnath Kotur <somnath.kotur@broadcom.com>
> >
> > In order to use queue_stop/queue_start to support the new Steering
> > Tags, we need to free the TX ring and TX completion ring if it is a
> > combined channel with TX/RX sharing the same NAPI. Otherwise
> > TX completions will not have the updated Steering Tag. With that
> > we can now add napi_disable() and napi_enable() during queue_stop()/
> > queue_start(). This will guarantee that NAPI will stop processing
> > the completion entries in case there are additional pending entries
> > in the completion rings after queue_stop().
> >
> > There could be some NQEs sitting unprocessed while NAPI is disabled
> > thereby leaving the NQ unarmed. Explictily Re-arm the NQ after
> > napi_enable() in queue start so that NAPI will resume properly.
> >
> > Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
> > Signed-off-by: Somnath Kotur <somnath.kotur@broadcom.com>
> > Reviewed-by: Michael Chan <michael.chan@broadcom.com>
> > ---
> > Cc: David Wei <dw@davidwei.uk>
> >
> > Discussion about adding napi_disable()/napi_enable():
> >
> >
> https://lore.kernel.org/netdev/5336d624-8d8b-40a6-b732-b020e4a119a2@davidwei.uk/#t
> > ---
> > drivers/net/ethernet/broadcom/bnxt/bnxt.c | 99 ++++++++++++++++++++++-
> > 1 file changed, 98 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> > index fe350d0ba99c..eddb4de959c6 100644
> > --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> > +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> > @@ -7341,6 +7341,22 @@ static int hwrm_ring_free_send_msg(struct bnxt
> *bp,
> > return 0;
> > }
> >
> > +static void bnxt_hwrm_tx_ring_free(struct bnxt *bp, struct
> bnxt_tx_ring_info *txr,
> > + bool close_path)
> > +{
> > + struct bnxt_ring_struct *ring = &txr->tx_ring_struct;
> > + u32 cmpl_ring_id;
> > +
> > + if (ring->fw_ring_id == INVALID_HW_RING_ID)
> > + return;
> > +
> > + cmpl_ring_id = close_path ? bnxt_cp_ring_for_tx(bp, txr) :
> > + INVALID_HW_RING_ID;
> > + hwrm_ring_free_send_msg(bp, ring, RING_FREE_REQ_RING_TYPE_TX,
> > + cmpl_ring_id);
> > + ring->fw_ring_id = INVALID_HW_RING_ID;
> > +}
> > +
> > static void bnxt_hwrm_rx_ring_free(struct bnxt *bp,
> > struct bnxt_rx_ring_info *rxr,
> > bool close_path)
> > @@ -11247,6 +11263,69 @@ int bnxt_reserve_rings(struct bnxt *bp, bool
> irq_re_init)
> > return 0;
> > }
> >
> > +static void bnxt_tx_queue_stop(struct bnxt *bp, int idx)
> > +{
> > + struct bnxt_tx_ring_info *txr;
> > + struct netdev_queue *txq;
> > + struct bnxt_napi *bnapi;
> > + int i;
> > +
> > + bnapi = bp->bnapi[idx];
> > + bnxt_for_each_napi_tx(i, bnapi, txr) {
> > + WRITE_ONCE(txr->dev_state, BNXT_DEV_STATE_CLOSING);
> > + synchronize_net();
> > +
> > + if (!(bnapi->flags & BNXT_NAPI_FLAG_XDP)) {
> > + txq = netdev_get_tx_queue(bp->dev, txr->txq_index);
> > + if (txq) {
> > + __netif_tx_lock_bh(txq);
> > + netif_tx_stop_queue(txq);
> > + __netif_tx_unlock_bh(txq);
> > + }
> > + }
> > + bnxt_hwrm_tx_ring_free(bp, txr, true);
> > + bnxt_hwrm_cp_ring_free(bp, txr->tx_cpr);
> > + bnxt_free_one_tx_ring_skbs(bp, txr, txr->txq_index);
> > + bnxt_clear_one_cp_ring(bp, txr->tx_cpr);
> > + }
> > +}
> > +
> > +static int bnxt_tx_queue_start(struct bnxt *bp, int idx)
> > +{
> > + struct bnxt_tx_ring_info *txr;
> > + struct netdev_queue *txq;
> > + struct bnxt_napi *bnapi;
> > + int rc, i;
> > +
> > + bnapi = bp->bnapi[idx];
> > + bnxt_for_each_napi_tx(i, bnapi, txr) {
> > + rc = bnxt_hwrm_cp_ring_alloc_p5(bp, txr->tx_cpr);
> > + if (rc)
> > + return rc;
> > +
> > + rc = bnxt_hwrm_tx_ring_alloc(bp, txr, false);
> > + if (rc) {
> > + bnxt_hwrm_cp_ring_free(bp, txr->tx_cpr);
> What about ring allocated in previous steps? Don't you need to free them
> too?
>
Sure thanks, will take care
>
> > + return rc;
> > + }
> > + txr->tx_prod = 0;
> > + txr->tx_cons = 0;
> > + txr->tx_hw_cons = 0;
> > +
> > + WRITE_ONCE(txr->dev_state, 0);
> > + synchronize_net();
> > +
> > + if (bnapi->flags & BNXT_NAPI_FLAG_XDP)
> > + continue;
> > +
> > + txq = netdev_get_tx_queue(bp->dev, txr->txq_index);
> > + if (txq)
> > + netif_tx_start_queue(txq);
> > + }
> > +
> > + return 0;
> > +}
> > +
> > static void bnxt_free_irq(struct bnxt *bp)
> > {
> > struct bnxt_irq *irq;
> > @@ -15647,6 +15726,16 @@ static int bnxt_queue_start(struct net_device
> *dev, void *qmem, int idx)
> > cpr = &rxr->bnapi->cp_ring;
> > cpr->sw_stats->rx.rx_resets++;
> >
> > + if (bp->flags & BNXT_FLAG_SHARED_RINGS) {
> > + rc = bnxt_tx_queue_start(bp, idx);
> > + if (rc)
> > + netdev_warn(bp->dev,
> > + "tx queue restart failed: rc=%d\n",
> rc);
> > + }
> > +
> > + napi_enable(&rxr->bnapi->napi);
> > + bnxt_db_nq_arm(bp, &cpr->cp_db, cpr->cp_raw_cons);
> > +
> > for (i = 0; i <= BNXT_VNIC_NTUPLE; i++) {
> > vnic = &bp->vnic_info[i];
> >
> > @@ -15675,6 +15764,7 @@ 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;
> > + struct bnxt_napi *bnapi;
> > int i;
> >
> > for (i = 0; i <= BNXT_VNIC_NTUPLE; i++) {
> > @@ -15686,15 +15776,22 @@ static int bnxt_queue_stop(struct net_device
> *dev, void *qmem, int idx)
> > /* Make sure NAPI sees that the VNIC is disabled */
> > synchronize_net();
> > rxr = &bp->rx_ring[idx];
> > - cancel_work_sync(&rxr->bnapi->cp_ring.dim.work);
> > + bnapi = rxr->bnapi;
> > + cancel_work_sync(&bnapi->cp_ring.dim.work);
> > bnxt_hwrm_rx_ring_free(bp, rxr, false);
> > bnxt_hwrm_rx_agg_ring_free(bp, rxr, false);
> > page_pool_disable_direct_recycling(rxr->page_pool);
> > if (bnxt_separate_head_pool())
> > page_pool_disable_direct_recycling(rxr->head_pool);
> >
> > + if (bp->flags & BNXT_FLAG_SHARED_RINGS)
> > + bnxt_tx_queue_stop(bp, idx);
> > +
> > + napi_disable(&bnapi->napi);
> > +
> > bnxt_hwrm_cp_ring_free(bp, rxr->rx_cpr);
> > bnxt_clear_one_cp_ring(bp, rxr->rx_cpr);
> > + bnxt_db_nq(bp, &cpr->cp_db, cpr->cp_raw_cons);
> >
> > memcpy(qmem, rxr, sizeof(*rxr));
> > bnxt_init_rx_ring_struct(bp, qmem);
> > --
> > 2.30.1
>
[-- Attachment #1.2: Type: text/html, Size: 10461 bytes --]
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4212 bytes --]
^ permalink raw reply [flat|nested] 28+ messages in thread* Re: [PATCH net-next 09/10] bnxt_en: Extend queue stop/start for Tx rings
2025-01-13 8:40 ` Michal Swiatkowski
2025-01-14 2:05 ` Somnath Kotur
@ 2025-01-15 1:29 ` Michael Chan
1 sibling, 0 replies; 28+ messages in thread
From: Michael Chan @ 2025-01-15 1:29 UTC (permalink / raw)
To: Michal Swiatkowski
Cc: davem, netdev, edumazet, kuba, pabeni, andrew+netdev,
pavan.chebbi, andrew.gospodarek, somnath.kotur, Ajit Khaparde,
David Wei
[-- Attachment #1: Type: text/plain, Size: 1100 bytes --]
On Mon, Jan 13, 2025 at 12:43 AM Michal Swiatkowski
<michal.swiatkowski@linux.intel.com> wrote:
>
> On Sun, Jan 12, 2025 at 10:39:26PM -0800, Michael Chan wrote:
> > From: Somnath Kotur <somnath.kotur@broadcom.com>
> > +static int bnxt_tx_queue_start(struct bnxt *bp, int idx)
> > +{
> > + struct bnxt_tx_ring_info *txr;
> > + struct netdev_queue *txq;
> > + struct bnxt_napi *bnapi;
> > + int rc, i;
> > +
> > + bnapi = bp->bnapi[idx];
> > + bnxt_for_each_napi_tx(i, bnapi, txr) {
> > + rc = bnxt_hwrm_cp_ring_alloc_p5(bp, txr->tx_cpr);
> > + if (rc)
> > + return rc;
> > +
> > + rc = bnxt_hwrm_tx_ring_alloc(bp, txr, false);
> > + if (rc) {
> > + bnxt_hwrm_cp_ring_free(bp, txr->tx_cpr);
> What about ring allocated in previous steps? Don't you need to free them
> too?
Any failure here will likely cause TX timeout even with the proper
unwind. I think the correct thing to do is to initiate a reset. I
will work with Somnath to implement that. Thanks.
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4209 bytes --]
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH net-next 09/10] bnxt_en: Extend queue stop/start for Tx rings
2025-01-13 6:39 ` [PATCH net-next 09/10] bnxt_en: Extend queue stop/start for Tx rings Michael Chan
2025-01-13 8:40 ` Michal Swiatkowski
@ 2025-01-13 16:01 ` Bjorn Helgaas
2025-01-14 4:57 ` Somnath Kotur
2025-01-14 8:48 ` kernel test robot
2025-01-14 11:23 ` kernel test robot
3 siblings, 1 reply; 28+ messages in thread
From: Bjorn Helgaas @ 2025-01-13 16:01 UTC (permalink / raw)
To: Michael Chan
Cc: davem, netdev, edumazet, kuba, pabeni, andrew+netdev,
pavan.chebbi, andrew.gospodarek, somnath.kotur, Ajit Khaparde,
David Wei
On Sun, Jan 12, 2025 at 10:39:26PM -0800, Michael Chan wrote:
> From: Somnath Kotur <somnath.kotur@broadcom.com>
>
> In order to use queue_stop/queue_start to support the new Steering
> Tags, we need to free the TX ring and TX completion ring if it is a
> combined channel with TX/RX sharing the same NAPI. Otherwise
> TX completions will not have the updated Steering Tag. With that
> we can now add napi_disable() and napi_enable() during queue_stop()/
> queue_start(). This will guarantee that NAPI will stop processing
> the completion entries in case there are additional pending entries
> in the completion rings after queue_stop().
>
> There could be some NQEs sitting unprocessed while NAPI is disabled
> thereby leaving the NQ unarmed. Explictily Re-arm the NQ after
> napi_enable() in queue start so that NAPI will resume properly.
s/Explictily Re-arm/Explicitly re-arm/ (typo + capitalization)
There's a mix of "TX/RX" vs "Tx/Rx" styles in the subjects and commit
logs of this series.
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH net-next 09/10] bnxt_en: Extend queue stop/start for Tx rings
2025-01-13 16:01 ` Bjorn Helgaas
@ 2025-01-14 4:57 ` Somnath Kotur
0 siblings, 0 replies; 28+ messages in thread
From: Somnath Kotur @ 2025-01-14 4:57 UTC (permalink / raw)
To: Bjorn Helgaas
Cc: Michael Chan, David S. Miller, netdev, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Andrew Lunn, Pavan Chebbi,
Andrew Gospodarek, Ajit Khaparde, David Wei
[-- Attachment #1: Type: text/plain, Size: 1180 bytes --]
On Mon, Jan 13, 2025 at 9:31 PM Bjorn Helgaas <helgaas@kernel.org> wrote:
>
> On Sun, Jan 12, 2025 at 10:39:26PM -0800, Michael Chan wrote:
> > From: Somnath Kotur <somnath.kotur@broadcom.com>
> >
> > In order to use queue_stop/queue_start to support the new Steering
> > Tags, we need to free the TX ring and TX completion ring if it is a
> > combined channel with TX/RX sharing the same NAPI. Otherwise
> > TX completions will not have the updated Steering Tag. With that
> > we can now add napi_disable() and napi_enable() during queue_stop()/
> > queue_start(). This will guarantee that NAPI will stop processing
> > the completion entries in case there are additional pending entries
> > in the completion rings after queue_stop().
> >
> > There could be some NQEs sitting unprocessed while NAPI is disabled
> > thereby leaving the NQ unarmed. Explictily Re-arm the NQ after
> > napi_enable() in queue start so that NAPI will resume properly.
>
> s/Explictily Re-arm/Explicitly re-arm/ (typo + capitalization)
>
> There's a mix of "TX/RX" vs "Tx/Rx" styles in the subjects and commit
> logs of this series.
Sure, thank you will take care of this
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4212 bytes --]
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH net-next 09/10] bnxt_en: Extend queue stop/start for Tx rings
2025-01-13 6:39 ` [PATCH net-next 09/10] bnxt_en: Extend queue stop/start for Tx rings Michael Chan
2025-01-13 8:40 ` Michal Swiatkowski
2025-01-13 16:01 ` Bjorn Helgaas
@ 2025-01-14 8:48 ` kernel test robot
2025-01-14 11:23 ` kernel test robot
3 siblings, 0 replies; 28+ messages in thread
From: kernel test robot @ 2025-01-14 8:48 UTC (permalink / raw)
To: Michael Chan, davem
Cc: oe-kbuild-all, netdev, edumazet, kuba, pabeni, andrew+netdev,
pavan.chebbi, andrew.gospodarek, somnath.kotur, Ajit Khaparde,
David Wei
Hi Michael,
kernel test robot noticed the following build errors:
[auto build test ERROR on net-next/main]
url: https://github.com/intel-lab-lkp/linux/commits/Michael-Chan/bnxt_en-Set-NAPR-1-2-support-when-registering-with-firmware/20250113-144205
base: net-next/main
patch link: https://lore.kernel.org/r/20250113063927.4017173-10-michael.chan%40broadcom.com
patch subject: [PATCH net-next 09/10] bnxt_en: Extend queue stop/start for Tx rings
config: csky-randconfig-001-20250114 (https://download.01.org/0day-ci/archive/20250114/202501141605.iErAEuFQ-lkp@intel.com/config)
compiler: csky-linux-gcc (GCC) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250114/202501141605.iErAEuFQ-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202501141605.iErAEuFQ-lkp@intel.com/
All errors (new ones prefixed by >>):
drivers/net/ethernet/broadcom/bnxt/bnxt.c: In function 'bnxt_request_irq':
drivers/net/ethernet/broadcom/bnxt/bnxt.c:11360:16: warning: variable 'j' set but not used [-Wunused-but-set-variable]
11360 | int i, j, rc = 0;
| ^
drivers/net/ethernet/broadcom/bnxt/bnxt.c: In function 'bnxt_queue_stop':
>> drivers/net/ethernet/broadcom/bnxt/bnxt.c:15794:25: error: 'cpr' undeclared (first use in this function); did you mean 'cpu'?
15794 | bnxt_db_nq(bp, &cpr->cp_db, cpr->cp_raw_cons);
| ^~~
| cpu
drivers/net/ethernet/broadcom/bnxt/bnxt.c:15794:25: note: each undeclared identifier is reported only once for each function it appears in
vim +15794 drivers/net/ethernet/broadcom/bnxt/bnxt.c
15761
15762 static int bnxt_queue_stop(struct net_device *dev, void *qmem, int idx)
15763 {
15764 struct bnxt *bp = netdev_priv(dev);
15765 struct bnxt_rx_ring_info *rxr;
15766 struct bnxt_vnic_info *vnic;
15767 struct bnxt_napi *bnapi;
15768 int i;
15769
15770 for (i = 0; i <= BNXT_VNIC_NTUPLE; i++) {
15771 vnic = &bp->vnic_info[i];
15772 vnic->mru = 0;
15773 bnxt_hwrm_vnic_update(bp, vnic,
15774 VNIC_UPDATE_REQ_ENABLES_MRU_VALID);
15775 }
15776 /* Make sure NAPI sees that the VNIC is disabled */
15777 synchronize_net();
15778 rxr = &bp->rx_ring[idx];
15779 bnapi = rxr->bnapi;
15780 cancel_work_sync(&bnapi->cp_ring.dim.work);
15781 bnxt_hwrm_rx_ring_free(bp, rxr, false);
15782 bnxt_hwrm_rx_agg_ring_free(bp, rxr, false);
15783 page_pool_disable_direct_recycling(rxr->page_pool);
15784 if (bnxt_separate_head_pool())
15785 page_pool_disable_direct_recycling(rxr->head_pool);
15786
15787 if (bp->flags & BNXT_FLAG_SHARED_RINGS)
15788 bnxt_tx_queue_stop(bp, idx);
15789
15790 napi_disable(&bnapi->napi);
15791
15792 bnxt_hwrm_cp_ring_free(bp, rxr->rx_cpr);
15793 bnxt_clear_one_cp_ring(bp, rxr->rx_cpr);
15794 bnxt_db_nq(bp, &cpr->cp_db, cpr->cp_raw_cons);
15795
15796 memcpy(qmem, rxr, sizeof(*rxr));
15797 bnxt_init_rx_ring_struct(bp, qmem);
15798
15799 return 0;
15800 }
15801
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 28+ messages in thread* Re: [PATCH net-next 09/10] bnxt_en: Extend queue stop/start for Tx rings
2025-01-13 6:39 ` [PATCH net-next 09/10] bnxt_en: Extend queue stop/start for Tx rings Michael Chan
` (2 preceding siblings ...)
2025-01-14 8:48 ` kernel test robot
@ 2025-01-14 11:23 ` kernel test robot
3 siblings, 0 replies; 28+ messages in thread
From: kernel test robot @ 2025-01-14 11:23 UTC (permalink / raw)
To: Michael Chan, davem
Cc: llvm, oe-kbuild-all, netdev, edumazet, kuba, pabeni,
andrew+netdev, pavan.chebbi, andrew.gospodarek, somnath.kotur,
Ajit Khaparde, David Wei
Hi Michael,
kernel test robot noticed the following build errors:
[auto build test ERROR on net-next/main]
url: https://github.com/intel-lab-lkp/linux/commits/Michael-Chan/bnxt_en-Set-NAPR-1-2-support-when-registering-with-firmware/20250113-144205
base: net-next/main
patch link: https://lore.kernel.org/r/20250113063927.4017173-10-michael.chan%40broadcom.com
patch subject: [PATCH net-next 09/10] bnxt_en: Extend queue stop/start for Tx rings
config: s390-allmodconfig (https://download.01.org/0day-ci/archive/20250114/202501141828.3alxlzbA-lkp@intel.com/config)
compiler: clang version 19.1.3 (https://github.com/llvm/llvm-project ab51eccf88f5321e7c60591c5546b254b6afab99)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250114/202501141828.3alxlzbA-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202501141828.3alxlzbA-lkp@intel.com/
All errors (new ones prefixed by >>):
In file included from drivers/net/ethernet/broadcom/bnxt/bnxt.c:11:
In file included from include/linux/module.h:19:
In file included from include/linux/elf.h:6:
In file included from arch/s390/include/asm/elf.h:181:
In file included from arch/s390/include/asm/mmu_context.h:11:
In file included from arch/s390/include/asm/pgalloc.h:18:
In file included from include/linux/mm.h:2224:
include/linux/vmstat.h:504:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
504 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
505 | item];
| ~~~~
include/linux/vmstat.h:511:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
511 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
512 | NR_VM_NUMA_EVENT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~~
include/linux/vmstat.h:524:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
524 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
525 | NR_VM_NUMA_EVENT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~~
>> drivers/net/ethernet/broadcom/bnxt/bnxt.c:15794:18: error: use of undeclared identifier 'cpr'
15794 | bnxt_db_nq(bp, &cpr->cp_db, cpr->cp_raw_cons);
| ^
drivers/net/ethernet/broadcom/bnxt/bnxt.c:15794:30: error: use of undeclared identifier 'cpr'
15794 | bnxt_db_nq(bp, &cpr->cp_db, cpr->cp_raw_cons);
| ^
3 warnings and 2 errors generated.
vim +/cpr +15794 drivers/net/ethernet/broadcom/bnxt/bnxt.c
15761
15762 static int bnxt_queue_stop(struct net_device *dev, void *qmem, int idx)
15763 {
15764 struct bnxt *bp = netdev_priv(dev);
15765 struct bnxt_rx_ring_info *rxr;
15766 struct bnxt_vnic_info *vnic;
15767 struct bnxt_napi *bnapi;
15768 int i;
15769
15770 for (i = 0; i <= BNXT_VNIC_NTUPLE; i++) {
15771 vnic = &bp->vnic_info[i];
15772 vnic->mru = 0;
15773 bnxt_hwrm_vnic_update(bp, vnic,
15774 VNIC_UPDATE_REQ_ENABLES_MRU_VALID);
15775 }
15776 /* Make sure NAPI sees that the VNIC is disabled */
15777 synchronize_net();
15778 rxr = &bp->rx_ring[idx];
15779 bnapi = rxr->bnapi;
15780 cancel_work_sync(&bnapi->cp_ring.dim.work);
15781 bnxt_hwrm_rx_ring_free(bp, rxr, false);
15782 bnxt_hwrm_rx_agg_ring_free(bp, rxr, false);
15783 page_pool_disable_direct_recycling(rxr->page_pool);
15784 if (bnxt_separate_head_pool())
15785 page_pool_disable_direct_recycling(rxr->head_pool);
15786
15787 if (bp->flags & BNXT_FLAG_SHARED_RINGS)
15788 bnxt_tx_queue_stop(bp, idx);
15789
15790 napi_disable(&bnapi->napi);
15791
15792 bnxt_hwrm_cp_ring_free(bp, rxr->rx_cpr);
15793 bnxt_clear_one_cp_ring(bp, rxr->rx_cpr);
15794 bnxt_db_nq(bp, &cpr->cp_db, cpr->cp_raw_cons);
15795
15796 memcpy(qmem, rxr, sizeof(*rxr));
15797 bnxt_init_rx_ring_struct(bp, qmem);
15798
15799 return 0;
15800 }
15801
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 28+ messages in thread
* [PATCH net-next 10/10] bnxt_en: Add TPH support in BNXT driver
2025-01-13 6:39 [PATCH net-next 00/10] bnxt_en: Add NPAR 1.2 and TPH support Michael Chan
` (8 preceding siblings ...)
2025-01-13 6:39 ` [PATCH net-next 09/10] bnxt_en: Extend queue stop/start for Tx rings Michael Chan
@ 2025-01-13 6:39 ` Michael Chan
9 siblings, 0 replies; 28+ messages in thread
From: Michael Chan @ 2025-01-13 6:39 UTC (permalink / raw)
To: davem
Cc: netdev, edumazet, kuba, pabeni, andrew+netdev, pavan.chebbi,
andrew.gospodarek, somnath.kotur, Manoj Panicker, Wei Huang,
Ajit Khaparde, Bjorn Helgaas
From: Manoj Panicker <manoj.panicker2@amd.com>
Add TPH support to the Broadcom BNXT device driver. This allows the
driver to utilize TPH functions for retrieving and configuring Steering
Tags when changing interrupt affinity. With compatible NIC firmware,
network traffic will be tagged correctly with Steering Tags, resulting
in significant memory bandwidth savings and other advantages as
demonstrated by real network benchmarks on TPH-capable platforms.
Co-developed-by: Somnath Kotur <somnath.kotur@broadcom.com>
Signed-off-by: Somnath Kotur <somnath.kotur@broadcom.com>
Co-developed-by: Wei Huang <wei.huang2@amd.com>
Signed-off-by: Wei Huang <wei.huang2@amd.com>
Signed-off-by: Manoj Panicker <manoj.panicker2@amd.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
Reviewed-by: Andy Gospodarek <andrew.gospodarek@broadcom.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
---
Cc: Bjorn Helgaas <helgaas@kernel.org>
Previous driver series fixing rtnl_lock and empty release function:
https://lore.kernel.org/netdev/20241115200412.1340286-1-wei.huang2@amd.com/
v5 of the PCI series using netdev_rx_queue_restart():
https://lore.kernel.org/netdev/20240916205103.3882081-5-wei.huang2@amd.com/
v1 of the PCI series using open/close:
https://lore.kernel.org/netdev/20240509162741.1937586-9-wei.huang2@amd.com/
---
drivers/net/ethernet/broadcom/bnxt/bnxt.c | 105 ++++++++++++++++++++++
drivers/net/ethernet/broadcom/bnxt/bnxt.h | 7 ++
2 files changed, 112 insertions(+)
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index eddb4de959c6..8ca73da801a3 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -55,6 +55,8 @@
#include <net/page_pool/helpers.h>
#include <linux/align.h>
#include <net/netdev_queues.h>
+#include <net/netdev_rx_queue.h>
+#include <linux/pci-tph.h>
#include "bnxt_hsi.h"
#include "bnxt.h"
@@ -11326,6 +11328,83 @@ static int bnxt_tx_queue_start(struct bnxt *bp, int idx)
return 0;
}
+static void bnxt_irq_affinity_notify(struct irq_affinity_notify *notify,
+ const cpumask_t *mask)
+{
+ struct bnxt_irq *irq;
+ u16 tag;
+ int err;
+
+ irq = container_of(notify, struct bnxt_irq, affinity_notify);
+
+ if (!irq->bp->tph_mode)
+ return;
+
+ cpumask_copy(irq->cpu_mask, mask);
+
+ if (irq->ring_nr >= irq->bp->rx_nr_rings)
+ return;
+
+ if (pcie_tph_get_cpu_st(irq->bp->pdev, TPH_MEM_TYPE_VM,
+ cpumask_first(irq->cpu_mask), &tag))
+ return;
+
+ if (pcie_tph_set_st_entry(irq->bp->pdev, irq->msix_nr, tag))
+ return;
+
+ rtnl_lock();
+ if (netif_running(irq->bp->dev)) {
+ err = netdev_rx_queue_restart(irq->bp->dev, irq->ring_nr);
+ if (err)
+ netdev_err(irq->bp->dev,
+ "RX queue restart failed: err=%d\n", err);
+ }
+ rtnl_unlock();
+}
+
+static void bnxt_irq_affinity_release(struct kref *ref)
+{
+ struct irq_affinity_notify *notify =
+ container_of(ref, struct irq_affinity_notify, kref);
+ struct bnxt_irq *irq;
+
+ irq = container_of(notify, struct bnxt_irq, affinity_notify);
+
+ if (!irq->bp->tph_mode)
+ return;
+
+ if (pcie_tph_set_st_entry(irq->bp->pdev, irq->msix_nr, 0)) {
+ netdev_err(irq->bp->dev,
+ "Setting ST=0 for MSIX entry %d failed\n",
+ irq->msix_nr);
+ return;
+ }
+}
+
+static void bnxt_release_irq_notifier(struct bnxt_irq *irq)
+{
+ irq_set_affinity_notifier(irq->vector, NULL);
+}
+
+static void bnxt_register_irq_notifier(struct bnxt *bp, struct bnxt_irq *irq)
+{
+ struct irq_affinity_notify *notify;
+
+ irq->bp = bp;
+
+ /* Nothing to do if TPH is not enabled */
+ if (!bp->tph_mode)
+ return;
+
+ /* Register IRQ affinity notifier */
+ notify = &irq->affinity_notify;
+ notify->irq = irq->vector;
+ notify->notify = bnxt_irq_affinity_notify;
+ notify->release = bnxt_irq_affinity_release;
+
+ irq_set_affinity_notifier(irq->vector, notify);
+}
+
static void bnxt_free_irq(struct bnxt *bp)
{
struct bnxt_irq *irq;
@@ -11348,11 +11427,18 @@ static void bnxt_free_irq(struct bnxt *bp)
free_cpumask_var(irq->cpu_mask);
irq->have_cpumask = 0;
}
+
+ bnxt_release_irq_notifier(irq);
+
free_irq(irq->vector, bp->bnapi[i]);
}
irq->requested = 0;
}
+
+ /* Disable TPH support */
+ pcie_disable_tph(bp->pdev);
+ bp->tph_mode = 0;
}
static int bnxt_request_irq(struct bnxt *bp)
@@ -11372,6 +11458,12 @@ static int bnxt_request_irq(struct bnxt *bp)
#ifdef CONFIG_RFS_ACCEL
rmap = bp->dev->rx_cpu_rmap;
#endif
+
+ /* Enable TPH support as part of IRQ request */
+ rc = pcie_enable_tph(bp->pdev, PCI_TPH_ST_IV_MODE);
+ if (!rc)
+ bp->tph_mode = PCI_TPH_ST_IV_MODE;
+
for (i = 0, j = 0; i < bp->cp_nr_rings; i++) {
int map_idx = bnxt_cp_num_to_irq_num(bp, i);
struct bnxt_irq *irq = &bp->irq_tbl[map_idx];
@@ -11395,8 +11487,11 @@ static int bnxt_request_irq(struct bnxt *bp)
if (zalloc_cpumask_var(&irq->cpu_mask, GFP_KERNEL)) {
int numa_node = dev_to_node(&bp->pdev->dev);
+ u16 tag;
irq->have_cpumask = 1;
+ irq->msix_nr = map_idx;
+ irq->ring_nr = i;
cpumask_set_cpu(cpumask_local_spread(i, numa_node),
irq->cpu_mask);
rc = irq_update_affinity_hint(irq->vector, irq->cpu_mask);
@@ -11406,6 +11501,16 @@ static int bnxt_request_irq(struct bnxt *bp)
irq->vector);
break;
}
+
+ bnxt_register_irq_notifier(bp, irq);
+
+ /* Init ST table entry */
+ if (pcie_tph_get_cpu_st(irq->bp->pdev, TPH_MEM_TYPE_VM,
+ cpumask_first(irq->cpu_mask),
+ &tag))
+ continue;
+
+ pcie_tph_set_st_entry(irq->bp->pdev, irq->msix_nr, tag);
}
}
return rc;
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
index a634ad76177d..7069d7f6f90b 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
@@ -1231,6 +1231,11 @@ struct bnxt_irq {
u8 have_cpumask:1;
char name[IFNAMSIZ + BNXT_IRQ_NAME_EXTRA];
cpumask_var_t cpu_mask;
+
+ struct bnxt *bp;
+ int msix_nr;
+ int ring_nr;
+ struct irq_affinity_notify affinity_notify;
};
#define HWRM_RING_ALLOC_TX 0x1
@@ -2226,6 +2231,8 @@ struct bnxt {
struct net_device *dev;
struct pci_dev *pdev;
+ u8 tph_mode;
+
atomic_t intr_sem;
u32 flags;
--
2.30.1
^ permalink raw reply related [flat|nested] 28+ messages in thread