All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next 0/3] bnxt PTP optimizations
@ 2023-03-21 10:32 Pavan Chebbi
  2023-03-21 10:32 ` [PATCH net-next 1/3] bnxt: Change fw_cap to u64 to accommodate more capability bits Pavan Chebbi
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Pavan Chebbi @ 2023-03-21 10:32 UTC (permalink / raw)
  To: michael.chan, kuba
  Cc: davem, edumazet, gospo, netdev, pabeni, richardcochran, Pavan Chebbi

[-- Attachment #1: Type: text/plain, Size: 661 bytes --]

Patches to
1. Enforce software based freq adjustments only on shared PHC NIC

2. A prerequisite change to expand capability storage field to
accommodate more Firmware reported capabilities

Pavan Chebbi (3):
  bnxt: Change fw_cap to u64 to accommodate more capability bits
  bnxt: Defer PTP initialization to after querying function caps
  bnxt: Enforce PTP software freq adjustments only when in non-RTC mode

 drivers/net/ethernet/broadcom/bnxt/bnxt.c     |  4 +-
 drivers/net/ethernet/broadcom/bnxt/bnxt.h     | 57 ++++++++++---------
 drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c | 14 +++--
 3 files changed, 42 insertions(+), 33 deletions(-)

-- 
2.39.1


[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4209 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH net-next 1/3] bnxt: Change fw_cap to u64 to accommodate more capability bits
  2023-03-21 10:32 [PATCH net-next 0/3] bnxt PTP optimizations Pavan Chebbi
@ 2023-03-21 10:32 ` Pavan Chebbi
  2023-03-21 10:32 ` [PATCH net-next 2/3] bnxt: Defer PTP initialization to after querying function caps Pavan Chebbi
  2023-03-21 10:32 ` [PATCH net-next 3/3] bnxt: Enforce PTP software freq adjustments only when in non-RTC mode Pavan Chebbi
  2 siblings, 0 replies; 5+ messages in thread
From: Pavan Chebbi @ 2023-03-21 10:32 UTC (permalink / raw)
  To: michael.chan, kuba
  Cc: davem, edumazet, gospo, netdev, pabeni, richardcochran,
	Pavan Chebbi, Edwin Peer

[-- Attachment #1: Type: text/plain, Size: 3370 bytes --]

The current fw_cap field (u32) has run out of bits to save any
new capability.

Change the field to u64.

Signed-off-by: Pavan Chebbi <pavan.chebbi@broadcom.com>
Reviewed-by: Edwin Peer <edwin.peer@broadcom.com>
Reviewed-by: Michael Chan <michael.chan@broadcom.com>
---
 drivers/net/ethernet/broadcom/bnxt/bnxt.h | 56 +++++++++++------------
 1 file changed, 28 insertions(+), 28 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
index c0628ac1b798..d7eb0d244f42 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
@@ -1968,34 +1968,34 @@ struct bnxt {
 
 	u32			msg_enable;
 
-	u32			fw_cap;
-	#define BNXT_FW_CAP_SHORT_CMD			0x00000001
-	#define BNXT_FW_CAP_LLDP_AGENT			0x00000002
-	#define BNXT_FW_CAP_DCBX_AGENT			0x00000004
-	#define BNXT_FW_CAP_NEW_RM			0x00000008
-	#define BNXT_FW_CAP_IF_CHANGE			0x00000010
-	#define BNXT_FW_CAP_KONG_MB_CHNL		0x00000080
-	#define BNXT_FW_CAP_OVS_64BIT_HANDLE		0x00000400
-	#define BNXT_FW_CAP_TRUSTED_VF			0x00000800
-	#define BNXT_FW_CAP_ERROR_RECOVERY		0x00002000
-	#define BNXT_FW_CAP_PKG_VER			0x00004000
-	#define BNXT_FW_CAP_CFA_ADV_FLOW		0x00008000
-	#define BNXT_FW_CAP_CFA_RFS_RING_TBL_IDX_V2	0x00010000
-	#define BNXT_FW_CAP_PCIE_STATS_SUPPORTED	0x00020000
-	#define BNXT_FW_CAP_EXT_STATS_SUPPORTED		0x00040000
-	#define BNXT_FW_CAP_RSS_HASH_TYPE_DELTA		0x00080000
-	#define BNXT_FW_CAP_ERR_RECOVER_RELOAD		0x00100000
-	#define BNXT_FW_CAP_HOT_RESET			0x00200000
-	#define BNXT_FW_CAP_PTP_RTC			0x00400000
-	#define BNXT_FW_CAP_RX_ALL_PKT_TS		0x00800000
-	#define BNXT_FW_CAP_VLAN_RX_STRIP		0x01000000
-	#define BNXT_FW_CAP_VLAN_TX_INSERT		0x02000000
-	#define BNXT_FW_CAP_EXT_HW_STATS_SUPPORTED	0x04000000
-	#define BNXT_FW_CAP_LIVEPATCH			0x08000000
-	#define BNXT_FW_CAP_PTP_PPS			0x10000000
-	#define BNXT_FW_CAP_HOT_RESET_IF		0x20000000
-	#define BNXT_FW_CAP_RING_MONITOR		0x40000000
-	#define BNXT_FW_CAP_DBG_QCAPS			0x80000000
+	u64			fw_cap;
+	#define BNXT_FW_CAP_SHORT_CMD			BIT_ULL(0)
+	#define BNXT_FW_CAP_LLDP_AGENT			BIT_ULL(1)
+	#define BNXT_FW_CAP_DCBX_AGENT			BIT_ULL(2)
+	#define BNXT_FW_CAP_NEW_RM			BIT_ULL(3)
+	#define BNXT_FW_CAP_IF_CHANGE			BIT_ULL(4)
+	#define BNXT_FW_CAP_KONG_MB_CHNL		BIT_ULL(7)
+	#define BNXT_FW_CAP_OVS_64BIT_HANDLE		BIT_ULL(10)
+	#define BNXT_FW_CAP_TRUSTED_VF			BIT_ULL(11)
+	#define BNXT_FW_CAP_ERROR_RECOVERY		BIT_ULL(13)
+	#define BNXT_FW_CAP_PKG_VER			BIT_ULL(14)
+	#define BNXT_FW_CAP_CFA_ADV_FLOW		BIT_ULL(15)
+	#define BNXT_FW_CAP_CFA_RFS_RING_TBL_IDX_V2	BIT_ULL(16)
+	#define BNXT_FW_CAP_PCIE_STATS_SUPPORTED	BIT_ULL(17)
+	#define BNXT_FW_CAP_EXT_STATS_SUPPORTED		BIT_ULL(18)
+	#define BNXT_FW_CAP_RSS_HASH_TYPE_DELTA		BIT_ULL(19)
+	#define BNXT_FW_CAP_ERR_RECOVER_RELOAD		BIT_ULL(20)
+	#define BNXT_FW_CAP_HOT_RESET			BIT_ULL(21)
+	#define BNXT_FW_CAP_PTP_RTC			BIT_ULL(22)
+	#define BNXT_FW_CAP_RX_ALL_PKT_TS		BIT_ULL(23)
+	#define BNXT_FW_CAP_VLAN_RX_STRIP		BIT_ULL(24)
+	#define BNXT_FW_CAP_VLAN_TX_INSERT		BIT_ULL(25)
+	#define BNXT_FW_CAP_EXT_HW_STATS_SUPPORTED	BIT_ULL(26)
+	#define BNXT_FW_CAP_LIVEPATCH			BIT_ULL(27)
+	#define BNXT_FW_CAP_PTP_PPS			BIT_ULL(28)
+	#define BNXT_FW_CAP_HOT_RESET_IF		BIT_ULL(29)
+	#define BNXT_FW_CAP_RING_MONITOR		BIT_ULL(30)
+	#define BNXT_FW_CAP_DBG_QCAPS			BIT_ULL(31)
 
 	u32			fw_dbg_cap;
 
-- 
2.39.1


[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4209 bytes --]

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH net-next 2/3] bnxt: Defer PTP initialization to after querying function caps
  2023-03-21 10:32 [PATCH net-next 0/3] bnxt PTP optimizations Pavan Chebbi
  2023-03-21 10:32 ` [PATCH net-next 1/3] bnxt: Change fw_cap to u64 to accommodate more capability bits Pavan Chebbi
@ 2023-03-21 10:32 ` Pavan Chebbi
  2023-03-21 10:32 ` [PATCH net-next 3/3] bnxt: Enforce PTP software freq adjustments only when in non-RTC mode Pavan Chebbi
  2 siblings, 0 replies; 5+ messages in thread
From: Pavan Chebbi @ 2023-03-21 10:32 UTC (permalink / raw)
  To: michael.chan, kuba
  Cc: davem, edumazet, gospo, netdev, pabeni, richardcochran, Pavan Chebbi

[-- Attachment #1: Type: text/plain, Size: 2009 bytes --]

Driver uses the flag BNXT_FLAG_MULTI_HOST to determine whether
to use non-realtime mode PHC when running on a multi host NIC.
However when ptp initializes on a NIC with shared PHC, we still
don't have this flag set yet because HWRM_FUNC_QCFG is issued
much later.

Move the ptp initialization code after we have issued func_qcfg.
The next patch will use the BNXT_FLAG_MULTI_HOST flag during PTP
initialization.

Signed-off-by: Pavan Chebbi <pavan.chebbi@broadcom.com>
Reviewed-by: Michael Chan <michael.chan@broadcom.com>
---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c | 4 +++-
 drivers/net/ethernet/broadcom/bnxt/bnxt.h | 1 +
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index f533a8f46217..656a28ac2ff0 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -7769,7 +7769,7 @@ static int __bnxt_hwrm_func_qcaps(struct bnxt *bp)
 		if (flags & FUNC_QCAPS_RESP_FLAGS_WOL_MAGICPKT_SUPPORTED)
 			bp->flags |= BNXT_FLAG_WOL_CAP;
 		if (flags & FUNC_QCAPS_RESP_FLAGS_PTP_SUPPORTED) {
-			__bnxt_hwrm_ptp_qcfg(bp);
+			bp->fw_cap |= BNXT_FW_CAP_PTP;
 		} else {
 			bnxt_ptp_clear(bp);
 			kfree(bp->ptp_cfg);
@@ -12298,6 +12298,8 @@ static int bnxt_fw_init_one_p2(struct bnxt *bp)
 	bnxt_hwrm_vnic_qcaps(bp);
 	bnxt_hwrm_port_led_qcaps(bp);
 	bnxt_ethtool_init(bp);
+	if (bp->fw_cap & BNXT_FW_CAP_PTP)
+		__bnxt_hwrm_ptp_qcfg(bp);
 	bnxt_dcb_init(bp);
 	return 0;
 }
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
index d7eb0d244f42..0eeaed95a4ac 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
@@ -1996,6 +1996,7 @@ struct bnxt {
 	#define BNXT_FW_CAP_HOT_RESET_IF		BIT_ULL(29)
 	#define BNXT_FW_CAP_RING_MONITOR		BIT_ULL(30)
 	#define BNXT_FW_CAP_DBG_QCAPS			BIT_ULL(31)
+	#define BNXT_FW_CAP_PTP				BIT_ULL(32)
 
 	u32			fw_dbg_cap;
 
-- 
2.39.1


[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4209 bytes --]

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH net-next 3/3] bnxt: Enforce PTP software freq adjustments only when in non-RTC mode
  2023-03-21 10:32 [PATCH net-next 0/3] bnxt PTP optimizations Pavan Chebbi
  2023-03-21 10:32 ` [PATCH net-next 1/3] bnxt: Change fw_cap to u64 to accommodate more capability bits Pavan Chebbi
  2023-03-21 10:32 ` [PATCH net-next 2/3] bnxt: Defer PTP initialization to after querying function caps Pavan Chebbi
@ 2023-03-21 10:32 ` Pavan Chebbi
  2023-03-21 11:18   ` Vadim Fedorenko
  2 siblings, 1 reply; 5+ messages in thread
From: Pavan Chebbi @ 2023-03-21 10:32 UTC (permalink / raw)
  To: michael.chan, kuba
  Cc: davem, edumazet, gospo, netdev, pabeni, richardcochran, Pavan Chebbi

[-- Attachment #1: Type: text/plain, Size: 1963 bytes --]

Currently driver performs software based frequency adjustments
when RTC capability is not discovered or when in shared PHC mode.
But there may be some old firmware versions that still support
hardware freq adjustments without RTC capability being exposed.
In this situation driver will use non-realtime mode even on single
host NICs.

Hence enforce software frequency adjustments only when running in
shared PHC mode. Make suitable changes for cyclecounter for the
same.

Signed-off-by: Pavan Chebbi <pavan.chebbi@broadcom.com>
Reviewed-by: Michael Chan <michael.chan@broadcom.com>
---
 drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c
index a3a3978a4d1c..b79a186f864c 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c
@@ -230,7 +230,7 @@ static int bnxt_ptp_adjfine(struct ptp_clock_info *ptp_info, long scaled_ppm)
 						ptp_info);
 	struct bnxt *bp = ptp->bp;
 
-	if (BNXT_PTP_USE_RTC(bp))
+	if (!BNXT_MH(ptp->bp))
 		return bnxt_ptp_adjfine_rtc(bp, scaled_ppm);
 
 	spin_lock_bh(&ptp->ptp_lock);
@@ -861,9 +861,15 @@ static void bnxt_ptp_timecounter_init(struct bnxt *bp, bool init_tc)
 		memset(&ptp->cc, 0, sizeof(ptp->cc));
 		ptp->cc.read = bnxt_cc_read;
 		ptp->cc.mask = CYCLECOUNTER_MASK(48);
-		ptp->cc.shift = BNXT_CYCLES_SHIFT;
-		ptp->cc.mult = clocksource_khz2mult(BNXT_DEVCLK_FREQ, ptp->cc.shift);
-		ptp->cmult = ptp->cc.mult;
+		if (BNXT_MH(ptp->bp)) {
+			/* Use timecounter based non-real time mode */
+			ptp->cc.shift = BNXT_CYCLES_SHIFT;
+			ptp->cc.mult = clocksource_khz2mult(BNXT_DEVCLK_FREQ, ptp->cc.shift);
+			ptp->cmult = ptp->cc.mult;
+		} else {
+			ptp->cc.shift = 0;
+			ptp->cc.mult = 1;
+		}
 		ptp->next_overflow_check = jiffies + BNXT_PHC_OVERFLOW_PERIOD;
 	}
 	if (init_tc)
-- 
2.39.1


[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4209 bytes --]

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH net-next 3/3] bnxt: Enforce PTP software freq adjustments only when in non-RTC mode
  2023-03-21 10:32 ` [PATCH net-next 3/3] bnxt: Enforce PTP software freq adjustments only when in non-RTC mode Pavan Chebbi
@ 2023-03-21 11:18   ` Vadim Fedorenko
  0 siblings, 0 replies; 5+ messages in thread
From: Vadim Fedorenko @ 2023-03-21 11:18 UTC (permalink / raw)
  To: Pavan Chebbi, michael.chan, kuba
  Cc: davem, edumazet, gospo, netdev, pabeni, richardcochran

On 21/03/2023 10:32, Pavan Chebbi wrote:
> Currently driver performs software based frequency adjustments
> when RTC capability is not discovered or when in shared PHC mode.
> But there may be some old firmware versions that still support
> hardware freq adjustments without RTC capability being exposed.
> In this situation driver will use non-realtime mode even on single
> host NICs.
> 
> Hence enforce software frequency adjustments only when running in
> shared PHC mode. Make suitable changes for cyclecounter for the
> same.
> 
> Signed-off-by: Pavan Chebbi <pavan.chebbi@broadcom.com>
> Reviewed-by: Michael Chan <michael.chan@broadcom.com>
> ---
>   drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c | 14 ++++++++++----
>   1 file changed, 10 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c
> index a3a3978a4d1c..b79a186f864c 100644
> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c
> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c
> @@ -230,7 +230,7 @@ static int bnxt_ptp_adjfine(struct ptp_clock_info *ptp_info, long scaled_ppm)
>   						ptp_info);
>   	struct bnxt *bp = ptp->bp;
>   
> -	if (BNXT_PTP_USE_RTC(bp))
> +	if (!BNXT_MH(ptp->bp))

bp is already resolved and stored in variable, it's better to use it

>   		return bnxt_ptp_adjfine_rtc(bp, scaled_ppm);
>   
>   	spin_lock_bh(&ptp->ptp_lock);
> @@ -861,9 +861,15 @@ static void bnxt_ptp_timecounter_init(struct bnxt *bp, bool init_tc)
>   		memset(&ptp->cc, 0, sizeof(ptp->cc));
>   		ptp->cc.read = bnxt_cc_read;
>   		ptp->cc.mask = CYCLECOUNTER_MASK(48);
> -		ptp->cc.shift = BNXT_CYCLES_SHIFT;
> -		ptp->cc.mult = clocksource_khz2mult(BNXT_DEVCLK_FREQ, ptp->cc.shift);
> -		ptp->cmult = ptp->cc.mult;
> +		if (BNXT_MH(ptp->bp)) {

and here, bp is the first argument to the function, why you do resolve 
again?

> +			/* Use timecounter based non-real time mode */
> +			ptp->cc.shift = BNXT_CYCLES_SHIFT;
> +			ptp->cc.mult = clocksource_khz2mult(BNXT_DEVCLK_FREQ, ptp->cc.shift);
> +			ptp->cmult = ptp->cc.mult;
> +		} else {
> +			ptp->cc.shift = 0;
> +			ptp->cc.mult = 1;
> +		}
>   		ptp->next_overflow_check = jiffies + BNXT_PHC_OVERFLOW_PERIOD;
>   	}
>   	if (init_tc)

Otherwise looks good!

Acked-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-03-21 11:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-21 10:32 [PATCH net-next 0/3] bnxt PTP optimizations Pavan Chebbi
2023-03-21 10:32 ` [PATCH net-next 1/3] bnxt: Change fw_cap to u64 to accommodate more capability bits Pavan Chebbi
2023-03-21 10:32 ` [PATCH net-next 2/3] bnxt: Defer PTP initialization to after querying function caps Pavan Chebbi
2023-03-21 10:32 ` [PATCH net-next 3/3] bnxt: Enforce PTP software freq adjustments only when in non-RTC mode Pavan Chebbi
2023-03-21 11:18   ` Vadim Fedorenko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.