Commit 7de3c221 authored by Michael Chan's avatar Michael Chan Committed by Jakub Kicinski

bnxt_en: Add a timeout parameter to bnxt_hwrm_port_ts_query()

The caller can pass this new timeout parameter to the function to
specify the firmware timeout value when requesting the TX timestamp
from the firmware.  This will allow the caller to precisely control
the timeout and will be used in the next patch.  In this patch, the
parameter is 0 which means to use the current default value.

Cc: Richard Cochran <richardcochran@gmail.com>
Reviewed-by: default avatarPavan Chebbi <pavan.chebbi@broadcom.com>
Signed-off-by: default avatarMichael Chan <michael.chan@broadcom.com>
Reviewed-by: default avatarVadim Fedorenko <vadim.fedorenko@linux.dev>
Link: https://lore.kernel.org/r/20240325222902.220712-2-michael.chan@broadcom.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 7f9d82a0
...@@ -109,7 +109,8 @@ static void bnxt_ptp_get_current_time(struct bnxt *bp) ...@@ -109,7 +109,8 @@ static void bnxt_ptp_get_current_time(struct bnxt *bp)
spin_unlock_bh(&ptp->ptp_lock); spin_unlock_bh(&ptp->ptp_lock);
} }
static int bnxt_hwrm_port_ts_query(struct bnxt *bp, u32 flags, u64 *ts) static int bnxt_hwrm_port_ts_query(struct bnxt *bp, u32 flags, u64 *ts,
u32 txts_tmo)
{ {
struct hwrm_port_ts_query_output *resp; struct hwrm_port_ts_query_output *resp;
struct hwrm_port_ts_query_input *req; struct hwrm_port_ts_query_input *req;
...@@ -122,10 +123,15 @@ static int bnxt_hwrm_port_ts_query(struct bnxt *bp, u32 flags, u64 *ts) ...@@ -122,10 +123,15 @@ static int bnxt_hwrm_port_ts_query(struct bnxt *bp, u32 flags, u64 *ts)
req->flags = cpu_to_le32(flags); req->flags = cpu_to_le32(flags);
if ((flags & PORT_TS_QUERY_REQ_FLAGS_PATH) == if ((flags & PORT_TS_QUERY_REQ_FLAGS_PATH) ==
PORT_TS_QUERY_REQ_FLAGS_PATH_TX) { PORT_TS_QUERY_REQ_FLAGS_PATH_TX) {
u32 tmo_us = txts_tmo * 1000;
req->enables = cpu_to_le16(BNXT_PTP_QTS_TX_ENABLES); req->enables = cpu_to_le16(BNXT_PTP_QTS_TX_ENABLES);
req->ptp_seq_id = cpu_to_le32(bp->ptp_cfg->tx_seqid); req->ptp_seq_id = cpu_to_le32(bp->ptp_cfg->tx_seqid);
req->ptp_hdr_offset = cpu_to_le16(bp->ptp_cfg->tx_hdr_off); req->ptp_hdr_offset = cpu_to_le16(bp->ptp_cfg->tx_hdr_off);
req->ts_req_timeout = cpu_to_le16(BNXT_PTP_QTS_TIMEOUT); if (!tmo_us)
tmo_us = BNXT_PTP_QTS_TIMEOUT;
tmo_us = min(tmo_us, BNXT_PTP_QTS_MAX_TMO_US);
req->ts_req_timeout = cpu_to_le16(txts_tmo);
} }
resp = hwrm_req_hold(bp, req); resp = hwrm_req_hold(bp, req);
...@@ -675,7 +681,8 @@ static void bnxt_stamp_tx_skb(struct bnxt *bp, struct sk_buff *skb) ...@@ -675,7 +681,8 @@ static void bnxt_stamp_tx_skb(struct bnxt *bp, struct sk_buff *skb)
u64 ts = 0, ns = 0; u64 ts = 0, ns = 0;
int rc; int rc;
rc = bnxt_hwrm_port_ts_query(bp, PORT_TS_QUERY_REQ_FLAGS_PATH_TX, &ts); rc = bnxt_hwrm_port_ts_query(bp, PORT_TS_QUERY_REQ_FLAGS_PATH_TX, &ts,
0);
if (!rc) { if (!rc) {
memset(&timestamp, 0, sizeof(timestamp)); memset(&timestamp, 0, sizeof(timestamp));
spin_lock_bh(&ptp->ptp_lock); spin_lock_bh(&ptp->ptp_lock);
...@@ -891,7 +898,8 @@ int bnxt_ptp_init_rtc(struct bnxt *bp, bool phc_cfg) ...@@ -891,7 +898,8 @@ int bnxt_ptp_init_rtc(struct bnxt *bp, bool phc_cfg)
if (rc) if (rc)
return rc; return rc;
} else { } else {
rc = bnxt_hwrm_port_ts_query(bp, PORT_TS_QUERY_REQ_FLAGS_CURRENT_TIME, &ns); rc = bnxt_hwrm_port_ts_query(bp, PORT_TS_QUERY_REQ_FLAGS_CURRENT_TIME,
&ns, 0);
if (rc) if (rc)
return rc; return rc;
} }
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#define BNXT_HI_TIMER_MASK 0xffff00000000UL #define BNXT_HI_TIMER_MASK 0xffff00000000UL
#define BNXT_PTP_QTS_TIMEOUT 1000 #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 | \ #define BNXT_PTP_QTS_TX_ENABLES (PORT_TS_QUERY_REQ_ENABLES_PTP_SEQ_ID | \
PORT_TS_QUERY_REQ_ENABLES_TS_REQ_TIMEOUT | \ PORT_TS_QUERY_REQ_ENABLES_TS_REQ_TIMEOUT | \
PORT_TS_QUERY_REQ_ENABLES_PTP_HDR_OFFSET) PORT_TS_QUERY_REQ_ENABLES_PTP_HDR_OFFSET)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment