netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vadim Fedorenko <vadim.fedorenko@linux.dev>
To: Michael Chan <michael.chan@broadcom.com>,
	davem@davemloft.net, kuba@kernel.org
Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com,
	pavan.chebbi@broadcom.com, andrew.gospodarek@broadcom.com,
	Richard Cochran <richardcochran@gmail.com>
Subject: Re: [PATCH net-next 02/12] bnxt_en: Retry PTP TX timestamp from FW for 1 second
Date: Wed, 27 Mar 2024 23:02:24 -0700	[thread overview]
Message-ID: <00936e03-e4a0-4d93-a576-58a7cd61fd78@linux.dev> (raw)
In-Reply-To: <20240325222902.220712-3-michael.chan@broadcom.com>

On 25/03/2024 22:28, Michael Chan wrote:
> From: Pavan Chebbi <pavan.chebbi@broadcom.com>
> 
> Use a new default 1 second timeout value instead of the existing
> 1 msec value.  The driver will keep track of the remaining time
> before timeout and will pass this value to bnxt_hwrm_port_ts_query().
> The firmware supports timeout values up to 65535 usecs.  If the
> timeout value passed to bnxt_hwrm_port_ts_query() is less than the
> FW max value, we will use that value to precisely control the
> specified timeout.  If it is larger than the FW max value, we will
> use the FW max value and any additional retry to reach the desired
> timeout will be done in the context of bnxt_ptp_ts_aux_eork().
> 
> Link: https://lore.kernel.org/netdev/20240229070202.107488-2-michael.chan@broadcom.com/
> Cc: Vadim Fedorenko <vadim.fedorenko@linux.dev>
> Cc: Richard Cochran <richardcochran@gmail.com>
> Reviewed-by: Andy Gospodarek <andrew.gospodarek@broadcom.com>
> Signed-off-by: Pavan Chebbi <pavan.chebbi@broadcom.com>
> Signed-off-by: Michael Chan <michael.chan@broadcom.com>
> ---
> v2: Don't use the devlink parameter.
>      Pass the timeout parameter to bnxt_hwrm_port_ts_query() to precisely
>      control the timeout.
> ---
>   drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c | 16 +++++++++++++++-
>   drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h |  4 ++++
>   2 files changed, 19 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c
> index dbfd1b36774c..345aac4484ee 100644
> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c
> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c
> @@ -678,11 +678,17 @@ static void bnxt_stamp_tx_skb(struct bnxt *bp, struct sk_buff *skb)
>   {
>   	struct bnxt_ptp_cfg *ptp = bp->ptp_cfg;
>   	struct skb_shared_hwtstamps timestamp;
> +	unsigned long now = jiffies;
>   	u64 ts = 0, ns = 0;
> +	u32 tmo = 0;
>   	int rc;
>   
> +	if (!ptp->txts_pending)
> +		ptp->abs_txts_tmo = now + msecs_to_jiffies(ptp->txts_tmo);
> +	if (!time_after_eq(now, ptp->abs_txts_tmo))
> +		tmo = jiffies_to_msecs(ptp->abs_txts_tmo - now);
>   	rc = bnxt_hwrm_port_ts_query(bp, PORT_TS_QUERY_REQ_FLAGS_PATH_TX, &ts,
> -				     0);
> +				     tmo);
>   	if (!rc) {
>   		memset(&timestamp, 0, sizeof(timestamp));
>   		spin_lock_bh(&ptp->ptp_lock);
> @@ -691,6 +697,10 @@ static void bnxt_stamp_tx_skb(struct bnxt *bp, struct sk_buff *skb)
>   		timestamp.hwtstamp = ns_to_ktime(ns);
>   		skb_tstamp_tx(ptp->tx_skb, &timestamp);
>   	} else {
> +		if (!time_after_eq(jiffies, ptp->abs_txts_tmo)) {
> +			ptp->txts_pending = true;
> +			return;
> +		}
>   		netdev_warn_once(bp->dev,
>   				 "TS query for TX timer failed rc = %x\n", rc);
>   	}
> @@ -698,6 +708,7 @@ static void bnxt_stamp_tx_skb(struct bnxt *bp, struct sk_buff *skb)
>   	dev_kfree_skb_any(ptp->tx_skb);
>   	ptp->tx_skb = NULL;
>   	atomic_inc(&ptp->tx_avail);
> +	ptp->txts_pending = false;
>   }
>   
>   static long bnxt_ptp_ts_aux_work(struct ptp_clock_info *ptp_info)
> @@ -721,6 +732,8 @@ static long bnxt_ptp_ts_aux_work(struct ptp_clock_info *ptp_info)
>   		spin_unlock_bh(&ptp->ptp_lock);
>   		ptp->next_overflow_check = now + BNXT_PHC_OVERFLOW_PERIOD;
>   	}
> +	if (ptp->txts_pending)
> +		return 0;
>   	return HZ;
>   }
>   
> @@ -973,6 +986,7 @@ int bnxt_ptp_init(struct bnxt *bp, bool phc_cfg)
>   		spin_unlock_bh(&ptp->ptp_lock);
>   		ptp_schedule_worker(ptp->ptp_clock, 0);
>   	}
> +	ptp->txts_tmo = BNXT_PTP_DFLT_TX_TMO;
>   	return 0;
>   
>   out:
> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h b/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h
> index 04886d5f22ad..6a2bba3f9e2d 100644
> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h
> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h
> @@ -22,6 +22,7 @@
>   #define BNXT_LO_TIMER_MASK	0x0000ffffffffUL
>   #define BNXT_HI_TIMER_MASK	0xffff00000000UL
>   
> +#define BNXT_PTP_DFLT_TX_TMO	1000 /* ms */
>   #define BNXT_PTP_QTS_TIMEOUT	1000
>   #define BNXT_PTP_QTS_MAX_TMO_US	65535
>   #define BNXT_PTP_QTS_TX_ENABLES	(PORT_TS_QUERY_REQ_ENABLES_PTP_SEQ_ID |	\
> @@ -116,11 +117,14 @@ struct bnxt_ptp_cfg {
>   					 BNXT_PTP_MSG_PDELAY_REQ |	\
>   					 BNXT_PTP_MSG_PDELAY_RESP)
>   	u8			tx_tstamp_en:1;
> +	u8			txts_pending:1;
>   	int			rx_filter;
>   	u32			tstamp_filters;
>   
>   	u32			refclk_regs[2];
>   	u32			refclk_mapped_regs[2];
> +	u32			txts_tmo;
> +	unsigned long		abs_txts_tmo;
>   };
>   
>   #if BITS_PER_LONG == 32

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

  reply	other threads:[~2024-03-28  6:02 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-25 22:28 [PATCH net-next 00/12] bnxt_en: PTP and RSS updates Michael Chan
2024-03-25 22:28 ` [PATCH net-next 01/12] bnxt_en: Add a timeout parameter to bnxt_hwrm_port_ts_query() Michael Chan
2024-03-28  5:51   ` Vadim Fedorenko
2024-03-25 22:28 ` [PATCH net-next 02/12] bnxt_en: Retry PTP TX timestamp from FW for 1 second Michael Chan
2024-03-28  6:02   ` Vadim Fedorenko [this message]
2024-03-25 22:28 ` [PATCH net-next 03/12] bnxt_en: Add helper function bnxt_hwrm_vnic_rss_cfg_p5() Michael Chan
2024-03-25 22:28 ` [PATCH net-next 04/12] bnxt_en: Refactor VNIC alloc and cfg functions Michael Chan
2024-03-25 22:28 ` [PATCH net-next 05/12] bnxt_en: Introduce rss ctx structure, alloc/free functions Michael Chan
2024-03-25 22:28 ` [PATCH net-next 06/12] bnxt_en: Refactor RSS indir alloc/set functions Michael Chan
2024-03-25 22:28 ` [PATCH net-next 07/12] bnxt_en: Simplify bnxt_rfs_capable() Michael Chan
2024-03-25 22:28 ` [PATCH net-next 08/12] bnxt_en: Add a new_rss_ctx parameter to bnxt_rfs_capable() Michael Chan
2024-03-25 22:28 ` [PATCH net-next 09/12] bnxt_en: Refactor bnxt_set_rxfh() Michael Chan
2024-03-25 22:29 ` [PATCH net-next 10/12] bnxt_en: Support RSS contexts in ethtool .{get|set}_rxfh() Michael Chan
2024-03-26 10:50   ` Edward Cree
2024-03-26 11:43     ` Pavan Chebbi
2024-03-25 22:29 ` [PATCH net-next 11/12] bnxt_en: Refactor bnxt_cfg_rfs_ring_tbl_idx() Michael Chan
2024-03-25 22:29 ` [PATCH net-next 12/12] bnxt_en: Support adding ntuple rules on RSS contexts Michael Chan
2024-03-29  5:50 ` [PATCH net-next 00/12] bnxt_en: PTP and RSS updates patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=00936e03-e4a0-4d93-a576-58a7cd61fd78@linux.dev \
    --to=vadim.fedorenko@linux.dev \
    --cc=andrew.gospodarek@broadcom.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=michael.chan@broadcom.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=pavan.chebbi@broadcom.com \
    --cc=richardcochran@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).