diff mbox series

[net-next,6/7] bnxt_en: Utilize ulp client resources if RoCE is not registered

Message ID 20240409215431.41424-7-michael.chan@broadcom.com (mailing list archive)
State Accepted
Commit d630624ebd708fb659b18a8d1423e8e26de075ab
Delegated to: Netdev Maintainers
Headers show
Series bnxt_en: Updates for net-next | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 942 this patch: 942
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 4 of 4 maintainers
netdev/build_clang success Errors and warnings before: 953 this patch: 953
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 956 this patch: 956
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 124 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 2 this patch: 2
netdev/source_inline success Was 0 now: 0

Commit Message

Michael Chan April 9, 2024, 9:54 p.m. UTC
From: Vikas Gupta <vikas.gupta@broadcom.com>

If the RoCE driver is not registered for a RoCE capable device, add
flexibility to use the RoCE resources (MSIX/NQs) for L2 purposes,
such as additional rings configured by the user or for XDP.

Reviewed-by: Andy Gospodarek <andrew.gospodarek@broadcom.com>
Signed-off-by: Vikas Gupta <vikas.gupta@broadcom.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c     | 41 +++++++++++++++----
 drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c | 14 +++++++
 drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.h |  2 +
 3 files changed, 48 insertions(+), 9 deletions(-)

Comments

Jacob Keller April 9, 2024, 11:41 p.m. UTC | #1
On 4/9/2024 2:54 PM, Michael Chan wrote:
> From: Vikas Gupta <vikas.gupta@broadcom.com>
> 
> If the RoCE driver is not registered for a RoCE capable device, add
> flexibility to use the RoCE resources (MSIX/NQs) for L2 purposes,
> such as additional rings configured by the user or for XDP.
> 
> Reviewed-by: Andy Gospodarek <andrew.gospodarek@broadcom.com>
> Signed-off-by: Vikas Gupta <vikas.gupta@broadcom.com>
> Signed-off-by: Michael Chan <michael.chan@broadcom.com>
> ---

Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>

>  drivers/net/ethernet/broadcom/bnxt/bnxt.c     | 41 +++++++++++++++----
>  drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c | 14 +++++++
>  drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.h |  2 +
>  3 files changed, 48 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> index 88cf8f47e071..a2e21fe64ab9 100644
> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> @@ -7470,14 +7470,27 @@ static bool bnxt_rings_ok(struct bnxt *bp, struct bnxt_hw_rings *hwr)
>  static int __bnxt_reserve_rings(struct bnxt *bp)
>  {
>  	struct bnxt_hw_rings hwr = {0};
> +	int cp = bp->cp_nr_rings;
>  	int rx_rings, rc;
> +	int ulp_msix = 0;
>  	bool sh = false;
>  	int tx_cp;
>  
>  	if (!bnxt_need_reserve_rings(bp))
>  		return 0;
>  
> -	hwr.cp = bnxt_nq_rings_in_use(bp);
> +	if (!bnxt_ulp_registered(bp->edev)) {
> +		ulp_msix = bnxt_get_avail_msix(bp, bp->ulp_num_msix_want);
> +		if (!ulp_msix)
> +			bnxt_set_ulp_stat_ctxs(bp, 0);
> +
> +		if (ulp_msix > bp->ulp_num_msix_want)
> +			ulp_msix = bp->ulp_num_msix_want;
> +		hwr.cp = cp + ulp_msix;
> +	} else {
> +		hwr.cp = bnxt_nq_rings_in_use(bp);
> +	}
> +
>  	hwr.tx = bp->tx_nr_rings;
>  	hwr.rx = bp->rx_nr_rings;
>  	if (bp->flags & BNXT_FLAG_SHARED_RINGS)
> @@ -7550,12 +7563,11 @@ static int __bnxt_reserve_rings(struct bnxt *bp)
>  		bnxt_set_dflt_rss_indir_tbl(bp, NULL);
>  
>  	if (!bnxt_ulp_registered(bp->edev) && BNXT_NEW_RM(bp)) {
> -		int resv_msix, resv_ctx, ulp_msix, ulp_ctxs;
> +		int resv_msix, resv_ctx, ulp_ctxs;
>  		struct bnxt_hw_resc *hw_resc;
>  
>  		hw_resc = &bp->hw_resc;
>  		resv_msix = hw_resc->resv_irqs - bp->cp_nr_rings;
> -		ulp_msix = bnxt_get_ulp_msix_num(bp);
>  		ulp_msix = min_t(int, resv_msix, ulp_msix);
>  		bnxt_set_ulp_msix_num(bp, ulp_msix);
>  		resv_ctx = hw_resc->resv_stat_ctxs  - bp->cp_nr_rings;
> @@ -10609,13 +10621,23 @@ int bnxt_reserve_rings(struct bnxt *bp, bool irq_re_init)
>  {
>  	bool irq_cleared = false;
>  	int tcs = bp->num_tc;
> +	int irqs_required;
>  	int rc;
>  
>  	if (!bnxt_need_reserve_rings(bp))
>  		return 0;
>  
> -	if (irq_re_init && BNXT_NEW_RM(bp) &&
> -	    bnxt_get_num_msix(bp) != bp->total_irqs) {
> +	if (!bnxt_ulp_registered(bp->edev)) {
> +		int ulp_msix = bnxt_get_avail_msix(bp, bp->ulp_num_msix_want);
> +
> +		if (ulp_msix > bp->ulp_num_msix_want)
> +			ulp_msix = bp->ulp_num_msix_want;
> +		irqs_required = ulp_msix + bp->cp_nr_rings;
> +	} else {
> +		irqs_required = bnxt_get_num_msix(bp);
> +	}
> +
> +	if (irq_re_init && BNXT_NEW_RM(bp) && irqs_required != bp->total_irqs) {
>  		bnxt_ulp_irq_stop(bp);
>  		bnxt_clear_int_mode(bp);
>  		irq_cleared = true;
> @@ -13625,8 +13647,8 @@ int bnxt_check_rings(struct bnxt *bp, int tx, int rx, bool sh, int tcs,
>  		return -ENOMEM;
>  	hwr.stat = hwr.cp;
>  	if (BNXT_NEW_RM(bp)) {
> -		hwr.cp += bnxt_get_ulp_msix_num(bp);
> -		hwr.stat += bnxt_get_ulp_stat_ctxs(bp);
> +		hwr.cp += bnxt_get_ulp_msix_num_in_use(bp);
> +		hwr.stat += bnxt_get_ulp_stat_ctxs_in_use(bp);
>  		hwr.grp = rx;
>  		hwr.rss_ctx = bnxt_get_total_rss_ctxs(bp, &hwr);
>  	}
> @@ -14899,8 +14921,9 @@ static void _bnxt_get_max_rings(struct bnxt *bp, int *max_rx, int *max_tx,
>  	*max_rx = hw_resc->max_rx_rings;
>  	*max_cp = bnxt_get_max_func_cp_rings_for_en(bp);
>  	max_irq = min_t(int, bnxt_get_max_func_irqs(bp) -
> -			bnxt_get_ulp_msix_num(bp),
> -			hw_resc->max_stat_ctxs - bnxt_get_ulp_stat_ctxs(bp));
> +			bnxt_get_ulp_msix_num_in_use(bp),
> +			hw_resc->max_stat_ctxs -
> +			bnxt_get_ulp_stat_ctxs_in_use(bp));
>  	if (!(bp->flags & BNXT_FLAG_CHIP_P5_PLUS))
>  		*max_cp = min_t(int, *max_cp, max_irq);
>  	max_ring_grps = hw_resc->max_hw_ring_grps;
> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c
> index de2cb1d4cd98..edb10aebd095 100644
> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c
> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c
> @@ -61,6 +61,13 @@ void bnxt_set_ulp_msix_num(struct bnxt *bp, int num)
>  		bp->edev->ulp_num_msix_vec = num;
>  }
>  
> +int bnxt_get_ulp_msix_num_in_use(struct bnxt *bp)
> +{
> +	if (bnxt_ulp_registered(bp->edev))
> +		return bp->edev->ulp_num_msix_vec;
> +	return 0;
> +}
> +
>  int bnxt_get_ulp_stat_ctxs(struct bnxt *bp)
>  {
>  	if (bp->edev)
> @@ -74,6 +81,13 @@ void bnxt_set_ulp_stat_ctxs(struct bnxt *bp, int num_ulp_ctx)
>  		bp->edev->ulp_num_ctxs = num_ulp_ctx;
>  }
>  
> +int bnxt_get_ulp_stat_ctxs_in_use(struct bnxt *bp)
> +{
> +	if (bnxt_ulp_registered(bp->edev))
> +		return bp->edev->ulp_num_ctxs;
> +	return 0;
> +}
> +
>  void bnxt_set_dflt_ulp_stat_ctxs(struct bnxt *bp)
>  {
>  	if (bp->edev) {
> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.h b/drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.h
> index 04ce3328e66f..b86baf901a5d 100644
> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.h
> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.h
> @@ -98,9 +98,11 @@ static inline bool bnxt_ulp_registered(struct bnxt_en_dev *edev)
>  }
>  
>  int bnxt_get_ulp_msix_num(struct bnxt *bp);
> +int bnxt_get_ulp_msix_num_in_use(struct bnxt *bp);
>  void bnxt_set_ulp_msix_num(struct bnxt *bp, int num);
>  int bnxt_get_ulp_stat_ctxs(struct bnxt *bp);
>  void bnxt_set_ulp_stat_ctxs(struct bnxt *bp, int num_ctxs);
> +int bnxt_get_ulp_stat_ctxs_in_use(struct bnxt *bp);
>  void bnxt_set_dflt_ulp_stat_ctxs(struct bnxt *bp);
>  void bnxt_ulp_stop(struct bnxt *bp);
>  void bnxt_ulp_start(struct bnxt *bp, int err);
diff mbox series

Patch

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index 88cf8f47e071..a2e21fe64ab9 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -7470,14 +7470,27 @@  static bool bnxt_rings_ok(struct bnxt *bp, struct bnxt_hw_rings *hwr)
 static int __bnxt_reserve_rings(struct bnxt *bp)
 {
 	struct bnxt_hw_rings hwr = {0};
+	int cp = bp->cp_nr_rings;
 	int rx_rings, rc;
+	int ulp_msix = 0;
 	bool sh = false;
 	int tx_cp;
 
 	if (!bnxt_need_reserve_rings(bp))
 		return 0;
 
-	hwr.cp = bnxt_nq_rings_in_use(bp);
+	if (!bnxt_ulp_registered(bp->edev)) {
+		ulp_msix = bnxt_get_avail_msix(bp, bp->ulp_num_msix_want);
+		if (!ulp_msix)
+			bnxt_set_ulp_stat_ctxs(bp, 0);
+
+		if (ulp_msix > bp->ulp_num_msix_want)
+			ulp_msix = bp->ulp_num_msix_want;
+		hwr.cp = cp + ulp_msix;
+	} else {
+		hwr.cp = bnxt_nq_rings_in_use(bp);
+	}
+
 	hwr.tx = bp->tx_nr_rings;
 	hwr.rx = bp->rx_nr_rings;
 	if (bp->flags & BNXT_FLAG_SHARED_RINGS)
@@ -7550,12 +7563,11 @@  static int __bnxt_reserve_rings(struct bnxt *bp)
 		bnxt_set_dflt_rss_indir_tbl(bp, NULL);
 
 	if (!bnxt_ulp_registered(bp->edev) && BNXT_NEW_RM(bp)) {
-		int resv_msix, resv_ctx, ulp_msix, ulp_ctxs;
+		int resv_msix, resv_ctx, ulp_ctxs;
 		struct bnxt_hw_resc *hw_resc;
 
 		hw_resc = &bp->hw_resc;
 		resv_msix = hw_resc->resv_irqs - bp->cp_nr_rings;
-		ulp_msix = bnxt_get_ulp_msix_num(bp);
 		ulp_msix = min_t(int, resv_msix, ulp_msix);
 		bnxt_set_ulp_msix_num(bp, ulp_msix);
 		resv_ctx = hw_resc->resv_stat_ctxs  - bp->cp_nr_rings;
@@ -10609,13 +10621,23 @@  int bnxt_reserve_rings(struct bnxt *bp, bool irq_re_init)
 {
 	bool irq_cleared = false;
 	int tcs = bp->num_tc;
+	int irqs_required;
 	int rc;
 
 	if (!bnxt_need_reserve_rings(bp))
 		return 0;
 
-	if (irq_re_init && BNXT_NEW_RM(bp) &&
-	    bnxt_get_num_msix(bp) != bp->total_irqs) {
+	if (!bnxt_ulp_registered(bp->edev)) {
+		int ulp_msix = bnxt_get_avail_msix(bp, bp->ulp_num_msix_want);
+
+		if (ulp_msix > bp->ulp_num_msix_want)
+			ulp_msix = bp->ulp_num_msix_want;
+		irqs_required = ulp_msix + bp->cp_nr_rings;
+	} else {
+		irqs_required = bnxt_get_num_msix(bp);
+	}
+
+	if (irq_re_init && BNXT_NEW_RM(bp) && irqs_required != bp->total_irqs) {
 		bnxt_ulp_irq_stop(bp);
 		bnxt_clear_int_mode(bp);
 		irq_cleared = true;
@@ -13625,8 +13647,8 @@  int bnxt_check_rings(struct bnxt *bp, int tx, int rx, bool sh, int tcs,
 		return -ENOMEM;
 	hwr.stat = hwr.cp;
 	if (BNXT_NEW_RM(bp)) {
-		hwr.cp += bnxt_get_ulp_msix_num(bp);
-		hwr.stat += bnxt_get_ulp_stat_ctxs(bp);
+		hwr.cp += bnxt_get_ulp_msix_num_in_use(bp);
+		hwr.stat += bnxt_get_ulp_stat_ctxs_in_use(bp);
 		hwr.grp = rx;
 		hwr.rss_ctx = bnxt_get_total_rss_ctxs(bp, &hwr);
 	}
@@ -14899,8 +14921,9 @@  static void _bnxt_get_max_rings(struct bnxt *bp, int *max_rx, int *max_tx,
 	*max_rx = hw_resc->max_rx_rings;
 	*max_cp = bnxt_get_max_func_cp_rings_for_en(bp);
 	max_irq = min_t(int, bnxt_get_max_func_irqs(bp) -
-			bnxt_get_ulp_msix_num(bp),
-			hw_resc->max_stat_ctxs - bnxt_get_ulp_stat_ctxs(bp));
+			bnxt_get_ulp_msix_num_in_use(bp),
+			hw_resc->max_stat_ctxs -
+			bnxt_get_ulp_stat_ctxs_in_use(bp));
 	if (!(bp->flags & BNXT_FLAG_CHIP_P5_PLUS))
 		*max_cp = min_t(int, *max_cp, max_irq);
 	max_ring_grps = hw_resc->max_hw_ring_grps;
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c
index de2cb1d4cd98..edb10aebd095 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c
@@ -61,6 +61,13 @@  void bnxt_set_ulp_msix_num(struct bnxt *bp, int num)
 		bp->edev->ulp_num_msix_vec = num;
 }
 
+int bnxt_get_ulp_msix_num_in_use(struct bnxt *bp)
+{
+	if (bnxt_ulp_registered(bp->edev))
+		return bp->edev->ulp_num_msix_vec;
+	return 0;
+}
+
 int bnxt_get_ulp_stat_ctxs(struct bnxt *bp)
 {
 	if (bp->edev)
@@ -74,6 +81,13 @@  void bnxt_set_ulp_stat_ctxs(struct bnxt *bp, int num_ulp_ctx)
 		bp->edev->ulp_num_ctxs = num_ulp_ctx;
 }
 
+int bnxt_get_ulp_stat_ctxs_in_use(struct bnxt *bp)
+{
+	if (bnxt_ulp_registered(bp->edev))
+		return bp->edev->ulp_num_ctxs;
+	return 0;
+}
+
 void bnxt_set_dflt_ulp_stat_ctxs(struct bnxt *bp)
 {
 	if (bp->edev) {
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.h b/drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.h
index 04ce3328e66f..b86baf901a5d 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.h
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.h
@@ -98,9 +98,11 @@  static inline bool bnxt_ulp_registered(struct bnxt_en_dev *edev)
 }
 
 int bnxt_get_ulp_msix_num(struct bnxt *bp);
+int bnxt_get_ulp_msix_num_in_use(struct bnxt *bp);
 void bnxt_set_ulp_msix_num(struct bnxt *bp, int num);
 int bnxt_get_ulp_stat_ctxs(struct bnxt *bp);
 void bnxt_set_ulp_stat_ctxs(struct bnxt *bp, int num_ctxs);
+int bnxt_get_ulp_stat_ctxs_in_use(struct bnxt *bp);
 void bnxt_set_dflt_ulp_stat_ctxs(struct bnxt *bp);
 void bnxt_ulp_stop(struct bnxt *bp);
 void bnxt_ulp_start(struct bnxt *bp, int err);