bnxt_en: Support configurable PTP TX timeout
Subsystems (5)
Michael Chan
maintainercover bnxt_en: Support configurable PTP TX timeout
The driver needs to call firmware to retrieve the PTP hardware TX timestamp for PTP packets. The PTP packet is timestamped by hardware right before packet transmission on the wire. So there is variable delay on when the timestamp is available. The current fixed timeout value of 1 msec passed to the firmware may not be long enough on busy networks.
Add a devlink driver runtime parameter to allow the user to configure this timeout value. Increase the default to 1 second and allow a maximum of 5 seconds.
Pavan Chebbi (2):
bnxt_en: Introduce devlink runtime driver param to set ptp tx timeout
bnxt_en: Retry for TX timestamp from FW until timeout specified
Documentation/networking/devlink/bnxt.rst | 7 ++++ .../net/ethernet/broadcom/bnxt/bnxt_devlink.c | 42 +++++++++++++++++++ drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c | 20 +++++++-- drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h | 7 +++- 4 files changed, 72 insertions(+), 4 deletions(-)
Signature · 1 line
2.30.1
Michael Chan
maintainerPATCH 1/2 bnxt_en: Introduce devlink runtime driver param to set ptp tx timeout
From: Pavan Chebbi <[email protected]>
Sometimes, the current 1ms value that driver waits for firmware to obtain a tx timestamp for a PTP packet may not be sufficient. User may want the driver to wait for a longer custom period before timing out.
Introduce a new runtime driver param for devlink "ptp_tx_timeout". Using this parameter the driver can wait for up to the specified time, when it is querying for a TX timestamp from firmware. By default the value is set to 1s.
--- .../net/ethernet/broadcom/bnxt/bnxt_devlink.c | 42 +++++++++++++++++++ drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c | 1 + drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h | 3 ++ 3 files changed, 46 insertions(+)
drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c +42 -0
@@ -652,6 +652,7 @@ static const struct devlink_ops bnxt_vf_dl_ops;enum bnxt_dl_param_id {BNXT_DEVLINK_PARAM_ID_BASE =DEVLINK_PARAM_GENERIC_ID_MAX ,BNXT_DEVLINK_PARAM_ID_GRE_VER_CHECK , +BNXT_DEVLINK_PARAM_ID_PTP_TXTS_TMO , };static const struct bnxt_dl_nvm_param nvm_params[] = {
@@ -1077,6 +1078,42 @@ static int bnxt_hwrm_nvm_req(struct bnxt *bp, u32 param_id, void *msg,return rc; } +static int bnxt_dl_ptp_param_get (struct devlink *dl,u32 id, +struct devlink_param_gset_ctx *ctx) +{ +struct bnxt *bp =bnxt_get_bp_from_dl (dl); + +if (!bp->ptp_cfg) +return -EOPNOTSUPP ; + + ctx->val.vu32 = bp->ptp_cfg->txts_tmo; +return 0 ; +} + +static int bnxt_dl_ptp_param_set (struct devlink *dl,u32 id, +struct devlink_param_gset_ctx *ctx) +{ +struct bnxt *bp =bnxt_get_bp_from_dl (dl); + +if (!bp->ptp_cfg) +return -EOPNOTSUPP ; + + bp->ptp_cfg->txts_tmo = ctx->val.vu32; +return 0 ; +} + +static int bnxt_dl_ptp_param_validate (struct devlink *dl,u32 id, +union devlink_param_value val, +struct netlink_ext_ack *extack) +{ +if (val.vu32 >BNXT_PTP_MAX_TX_TMO ) { +NL_SET_ERR_MSG_FMT_MOD (extack,"TX timeout value exceeds the maximum (%d ms)" , +BNXT_PTP_MAX_TX_TMO ); +return -EINVAL ; + } +return 0 ; +} +static int bnxt_dl_nvm_param_get (struct devlink *dl,u32 id,struct devlink_param_gset_ctx *ctx) {
@@ -1180,6 +1217,11 @@ static const struct devlink_param bnxt_dl_params[] = { BIT(DEVLINK_PARAM_CMODE_PERMANENT), bnxt_dl_nvm_param_get, bnxt_dl_nvm_param_set, NULL), +DEVLINK_PARAM_DRIVER (BNXT_DEVLINK_PARAM_ID_PTP_TXTS_TMO , +"ptp_tx_timeout" ,DEVLINK_PARAM_TYPE_U32 , +BIT (DEVLINK_PARAM_CMODE_RUNTIME ), + bnxt_dl_ptp_param_get, bnxt_dl_ptp_param_set, + bnxt_dl_ptp_param_validate),/* keep REMOTE_DEV_RESET last, it is excluded based on caps */ DEVLINK_PARAM_GENERIC(ENABLE_REMOTE_DEV_RESET, BIT(DEVLINK_PARAM_CMODE_RUNTIME),
drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c +1 -0
@@ -965,6 +965,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:
drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h +3 -0
@@ -22,6 +22,8 @@#define BNXT_LO_TIMER_MASK 0x0000ffffffffUL#define BNXT_HI_TIMER_MASK 0xffff00000000UL +#define BNXT_PTP_DFLT_TX_TMO 1000/* ms */ +#define BNXT_PTP_MAX_TX_TMO 5000/* ms */ #define BNXT_PTP_QTS_TIMEOUT 1000#define BNXT_PTP_QTS_TX_ENABLES (PORT_TS_QUERY_REQ_ENABLES_PTP_SEQ_ID | \ PORT_TS_QUERY_REQ_ENABLES_TS_REQ_TIMEOUT | \
@@ -120,6 +122,7 @@ struct bnxt_ptp_cfg {u32 refclk_regs[2 ];u32 refclk_mapped_regs[2 ]; +u32 txts_tmo; };#if BITS_PER_LONG ==32
Signature · 1 line
2.30.1
Re: [PATCH net-next 1/2] bnxt_en: Introduce devlink runtime driver param to set ptp tx timeout
Quoted 105 lines · Michael Chan
From: Pavan Chebbi <[email protected]>
Sometimes, the current 1ms value that driver waits for firmware to obtain a tx timestamp for a PTP packet may not be sufficient. User may want the driver to wait for a longer custom period before timing out.
Introduce a new runtime driver param for devlink "
ptp_tx_timeout". Using this parameter the driver can wait for up to the specified time, when it is querying for a TX timestamp from firmware. By default the value is set to 1s.Reviewed-by Andy Gospodarek <[email protected]>Signed-off-by Pavan Chebbi <[email protected]>Signed-off-by Michael Chan <[email protected]>--- .../net/ethernet/broadcom/bnxt/bnxt_devlink.c | 42 +++++++++++++++++++ drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c | 1 + drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h | 3 ++ 3 files changed, 46 insertions(+)drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c +42
-0@@ -652,6 +652,7 @@ static const struct devlink_ops bnxt_vf_dl_ops;enum bnxt_dl_param_id {BNXT_DEVLINK_PARAM_ID_BASE =DEVLINK_PARAM_GENERIC_ID_MAX ,BNXT_DEVLINK_PARAM_ID_GRE_VER_CHECK , +BNXT_DEVLINK_PARAM_ID_PTP_TXTS_TMO , };static const struct bnxt_dl_nvm_param nvm_params[] = {@@ -1077,6 +1078,42 @@ static int bnxt_hwrm_nvm_req(struct bnxt *bp, u32 param_id, void *msg,return rc; } +static int bnxt_dl_ptp_param_get (struct devlink *dl,u32 id, +struct devlink_param_gset_ctx *ctx) +{ +struct bnxt *bp =bnxt_get_bp_from_dl (dl); + +if (!bp->ptp_cfg) +return -EOPNOTSUPP ; + + ctx->val.vu32 = bp->ptp_cfg->txts_tmo; +return 0 ; +} + +static int bnxt_dl_ptp_param_set (struct devlink *dl,u32 id, +struct devlink_param_gset_ctx *ctx) +{ +struct bnxt *bp =bnxt_get_bp_from_dl (dl); + +if (!bp->ptp_cfg) +return -EOPNOTSUPP ; + + bp->ptp_cfg->txts_tmo = ctx->val.vu32; +return 0 ; +} + +static int bnxt_dl_ptp_param_validate (struct devlink *dl,u32 id, +union devlink_param_value val, +struct netlink_ext_ack *extack) +{ +if (val.vu32 >BNXT_PTP_MAX_TX_TMO ) { +NL_SET_ERR_MSG_FMT_MOD (extack,"TX timeout value exceeds the maximum (%d ms)" , +BNXT_PTP_MAX_TX_TMO ); +return -EINVAL ; + } +return 0 ; +} +static int bnxt_dl_nvm_param_get (struct devlink *dl,u32 id,struct devlink_param_gset_ctx *ctx) {@@ -1180,6 +1217,11 @@ static const struct devlink_param bnxt_dl_params[] = { BIT(DEVLINK_PARAM_CMODE_PERMANENT), bnxt_dl_nvm_param_get, bnxt_dl_nvm_param_set, NULL), +DEVLINK_PARAM_DRIVER (BNXT_DEVLINK_PARAM_ID_PTP_TXTS_TMO , +"ptp_tx_timeout" ,DEVLINK_PARAM_TYPE_U32 , +BIT (DEVLINK_PARAM_CMODE_RUNTIME ), + bnxt_dl_ptp_param_get, bnxt_dl_ptp_param_set, + bnxt_dl_ptp_param_validate),/* keep REMOTE_DEV_RESET last, it is excluded based on caps */ DEVLINK_PARAM_GENERIC(ENABLE_REMOTE_DEV_RESET, BIT(DEVLINK_PARAM_CMODE_RUNTIME),drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c +1
-0@@ -965,6 +965,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:drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h +0
-0
drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h line 25
Quoted 4 lines
drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h +1
-0@@ -22,6 +22,8 @@#define BNXT_LO_TIMER_MASK 0x0000ffffffffUL#define BNXT_HI_TIMER_MASK 0xffff00000000UL +#define BNXT_PTP_DFLT_TX_TMO 1000/* ms */
I'm not happy with such huge timeout, but looks like other vendors do expect the same timeouts, I'm ok.
Quoted 12 lines
drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h +2
-0+#define BNXT_PTP_MAX_TX_TMO 5000/* ms */ #define BNXT_PTP_QTS_TIMEOUT 1000#define BNXT_PTP_QTS_TX_ENABLES (PORT_TS_QUERY_REQ_ENABLES_PTP_SEQ_ID | \ PORT_TS_QUERY_REQ_ENABLES_TS_REQ_TIMEOUT | \@@ -120,6 +122,7 @@ struct bnxt_ptp_cfg {u32 refclk_regs[2 ];u32 refclk_mapped_regs[2 ]; +u32 txts_tmo; };#if BITS_PER_LONG ==32
Jiri Pirko
maintainerRe: [PATCH net-next 1/2] bnxt_en: Introduce devlink runtime driver param to set ptp tx timeout
In reply to Michael ChanQuoted 77 lines · Thu, Feb 29, 2024 at 08:02:01AM CET, [email protected] wrote:
From: Pavan Chebbi <[email protected]>
Sometimes, the current 1ms value that driver waits for firmware to obtain a tx timestamp for a PTP packet may not be sufficient. User may want the driver to wait for a longer custom period before timing out.
Introduce a new runtime driver param for devlink "
ptp_tx_timeout". Using this parameter the driver can wait for up to the specified time, when it is querying for a TX timestamp from firmware. By default the value is set to 1s.Reviewed-by Andy Gospodarek <[email protected]>Signed-off-by Pavan Chebbi <[email protected]>Signed-off-by Michael Chan <[email protected]>---
.../net/ethernet/broadcom/bnxt/bnxt_devlink.c | 42 +++++++++++++++++++ drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c | 1 + drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h | 3 ++ 3 files changed, 46 insertions(+)drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c +37
-0@@ -652,6 +652,7 @@ static const struct devlink_ops bnxt_vf_dl_ops;enum bnxt_dl_param_id {BNXT_DEVLINK_PARAM_ID_BASE =DEVLINK_PARAM_GENERIC_ID_MAX ,BNXT_DEVLINK_PARAM_ID_GRE_VER_CHECK , +BNXT_DEVLINK_PARAM_ID_PTP_TXTS_TMO , };static const struct bnxt_dl_nvm_param nvm_params[] = {@@ -1077,6 +1078,42 @@ static int bnxt_hwrm_nvm_req(struct bnxt *bp, u32 param_id, void *msg,return rc; } +static int bnxt_dl_ptp_param_get (struct devlink *dl,u32 id, +struct devlink_param_gset_ctx *ctx) +{ +struct bnxt *bp =bnxt_get_bp_from_dl (dl); + +if (!bp->ptp_cfg) +return -EOPNOTSUPP ; + + ctx->val.vu32 = bp->ptp_cfg->txts_tmo; +return 0 ; +} + +static int bnxt_dl_ptp_param_set (struct devlink *dl,u32 id, +struct devlink_param_gset_ctx *ctx) +{ +struct bnxt *bp =bnxt_get_bp_from_dl (dl); + +if (!bp->ptp_cfg) +return -EOPNOTSUPP ; + + bp->ptp_cfg->txts_tmo = ctx->val.vu32; +return 0 ; +} + +static int bnxt_dl_ptp_param_validate (struct devlink *dl,u32 id, +union devlink_param_value val, +struct netlink_ext_ack *extack) +{ +if (val.vu32 >BNXT_PTP_MAX_TX_TMO ) { +NL_SET_ERR_MSG_FMT_MOD (extack,"TX timeout value exceeds the maximum (%d ms)" , +BNXT_PTP_MAX_TX_TMO ); +return -EINVAL ; + } +return 0 ; +} +static int bnxt_dl_nvm_param_get (struct devlink *dl,u32 id,struct devlink_param_gset_ctx *ctx) {
drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c static const struct devlink_param bnxt_dl_params[] = { · line 1224
Quoted 8 lines
drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c +5
-0@@ -1180,6 +1217,11 @@ static const struct devlink_param bnxt_dl_params[] = {BIT (DEVLINK_PARAM_CMODE_PERMANENT ), bnxt_dl_nvm_param_get, bnxt_dl_nvm_param_set, NULL), +DEVLINK_PARAM_DRIVER (BNXT_DEVLINK_PARAM_ID_PTP_TXTS_TMO , + "ptp_tx_timeout", DEVLINK_PARAM_TYPE_U32, +BIT (DEVLINK_PARAM_CMODE_RUNTIME ), +bnxt_dl_ptp_param_get ,bnxt_dl_ptp_param_set , + bnxt_dl_ptp_param_validate),
Idk. This does not look sane to me at all. Will we have custom knobs to change timeout for arbitrary FW commands as this as a common thing? Driver is the one to take care of timeouts of FW gracefully, he should know the FW, not the user. Therefore exposing user knobs like this sounds pure wrong to me.
nack for adding this to devlink.
If this is some maybe-to-be-common ptp thing, can that be done as part of ptp api perhaps?
pw-bot: cr
Quoted 39 lines
drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c +0
-0/* keep REMOTE_DEV_RESET last, it is excluded based on caps */ DEVLINK_PARAM_GENERIC(ENABLE_REMOTE_DEV_RESET, BIT(DEVLINK_PARAM_CMODE_RUNTIME),drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c +1
-0@@ -965,6 +965,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:
drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h +3
-0@@ -22,6 +22,8 @@#define BNXT_LO_TIMER_MASK 0x0000ffffffffUL#define BNXT_HI_TIMER_MASK 0xffff00000000UL +#define BNXT_PTP_DFLT_TX_TMO 1000/* ms */ +#define BNXT_PTP_MAX_TX_TMO 5000/* ms */ #define BNXT_PTP_QTS_TIMEOUT 1000#define BNXT_PTP_QTS_TX_ENABLES (PORT_TS_QUERY_REQ_ENABLES_PTP_SEQ_ID | \ PORT_TS_QUERY_REQ_ENABLES_TS_REQ_TIMEOUT | \@@ -120,6 +122,7 @@ struct bnxt_ptp_cfg {u32 refclk_regs[2 ];u32 refclk_mapped_regs[2 ]; +u32 txts_tmo; };#if BITS_PER_LONG ==32 Signature · 1 line
2.30.1
Jakub Kicinski
maintainerRe: [PATCH net-next 1/2] bnxt_en: Introduce devlink runtime driver param to set ptp tx timeout
Quoted 7 lines · On Thu, 29 Feb 2024 18:11:49 +0100 Jiri Pirko wrote:
Idk. This does not look sane to me at all. Will we have custom knobs to change timeout for arbitrary FW commands as this as a common thing? Driver is the one to take care of timeouts of FW gracefully, he should know the FW, not the user. Therefore exposing user knobs like this sounds pure wrong to me.
nack for adding this to devlink.
+1
BTW why is the documentation in a different patch that the param :(
Quoted 2 lines
If this is some maybe-to-be-common ptp thing, can that be done as part of ptp api perhaps?
Perhaps, but also I think it's fairly impractical. Specialized users may be able to tune this, but in DC environment PTP is handled at the host level, and the applications come and go. So all the poor admin can do is set this to the max value. While in the driver you can actually try to be a bit more intelligent. Expecting the user to tune this strikes me as trying to take the easy way out..
Re: [PATCH net-next 1/2] bnxt_en: Introduce devlink runtime driver param to set ptp tx timeout
Quoted 7 lines · Jakub Kicinski
Quoted 6 lines · On Thu, 29 Feb 2024 18:11:49 +0100 Jiri Pirko wrote:
Idk. This does not look sane to me at all. Will we have custom knobs to change timeout for arbitrary FW commands as this as a common thing? Driver is the one to take care of timeouts of FW gracefully, he should know the FW, not the user. Therefore exposing user knobs like this sounds pure wrong to me.
Quoted 8 lines
Quoted 1 line
nack for adding this to devlink.
+1
BTW why is the documentation in a different patch that the param :(
Quoted 2 lines
If this is some maybe-to-be-common ptp thing, can that be done as part of ptp api perhaps?
Jiri, do you mean extend current ioctl used to enable/disable HW timestamps?
Quoted 3 lines
Perhaps, but also I think it's fairly impractical. Specialized users may be able to tune this, but in DC environment PTP is handled at the host
That's correct, only 1 app is actually doing syncronization
Quoted 1 line
level, and the applications come and go. So all the poor admin can do
Container/VM level applications don't care about PTP packets timestamps. They only care about the time being synchronized.
Quoted 1 line
is set this to the max value. While in the driver you can actually try
Pure admin will tune it according to the host level app configuration which may differ because of environment.
Quoted 2 lines
to be a bit more intelligent. Expecting the user to tune this strikes me as trying to take the easy way out..
There is no actual way for application to signal down to driver that it gave up waiting for TX timestamp, what other kind of smartness can we expect here?
Jakub Kicinski
maintainerRe: [PATCH net-next 1/2] bnxt_en: Introduce devlink runtime driver param to set ptp tx timeout
Quoted 9 lines · On Thu, 29 Feb 2024 21:22:19 +0000 Vadim Fedorenko wrote:
Quoted 2 lines
Perhaps, but also I think it's fairly impractical. Specialized users may be able to tune this, but in DC environment PTP is handled at the host
That's correct, only 1 app is actually doing syncronization
Quoted 1 line
level, and the applications come and go. So all the poor admin can do
Container/VM level applications don't care about PTP packets timestamps. They only care about the time being synchronized.
What I was saying is that in the PTP daemon you don't know whether the app running is likely to cause delays or not, and how long.
Quoted 4 lines
Quoted 1 line
is set this to the max value. While in the driver you can actually try
Pure admin will tune it according to the host level app configuration which may differ because of environment.
Concrete example?
Quoted 6 lines
Quoted 2 lines
to be a bit more intelligent. Expecting the user to tune this strikes me as trying to take the easy way out..
There is no actual way for application to signal down to driver that it gave up waiting for TX timestamp, what other kind of smartness can we expect here?
Let's figure out why the timeouts happen, before we create uAPIs. If it's because there's buffer bloat or a pause storm, the next TS request that gets queued will get stuck in the same exact way.
Pavan Chebbi
maintainerRe: [PATCH net-next 1/2] bnxt_en: Introduce devlink runtime driver param to set ptp tx timeout
Quoted 7 lines · Jakub Kicinski
Quoted 5 lines · On Thu, 29 Feb 2024 21:22:19 +0000 Vadim Fedorenko wrote:
Quoted 2 lines
Perhaps, but also I think it's fairly impractical. Specialized users may be able to tune this, but in DC environment PTP is handled at the host
That's correct, only 1 app is actually doing syncronization
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
level, and the applications come and go. So all the poor admin can do
Container/VM level applications don't care about PTP packets timestamps. They only care about the time being synchronized.
What I was saying is that in the PTP daemon you don't know whether the app running is likely to cause delays or not, and how long.
As such timeouts are rare but still normal. But if you've an environment where you want to have some kind of sync between the application and the NIC, as to when should both conclude that the timestamp is absolutely lost, we need some knob like this. Like you pointed out it's for an informed user who has knowledge of the workloads/flow control and how (badly) could they affect the TX. Of course the user cannot make an accurate estimation of the exact time out, but he can always experiment with the knob.
We are not sure if others need this as well, hence the private devlink parameter. For most common users, the default 1s timeout should serve well.
Quoted 17 lines
Quoted 4 lines
Quoted 1 line
is set this to the max value. While in the driver you can actually try
Pure admin will tune it according to the host level app configuration which may differ because of environment.
Concrete example?
Quoted 6 lines
Quoted 2 lines
to be a bit more intelligent. Expecting the user to tune this strikes me as trying to take the easy way out..
There is no actual way for application to signal down to driver that it gave up waiting for TX timestamp, what other kind of smartness can we expect here?
Let's figure out why the timeouts happen, before we create uAPIs. If it's because there's buffer bloat or a pause storm, the next TS request that gets queued will get stuck in the same exact way.
Jakub Kicinski
maintainerRe: [PATCH net-next 1/2] bnxt_en: Introduce devlink runtime driver param to set ptp tx timeout
Quoted 4 lines · On Fri, 1 Mar 2024 13:09:30 +0530 Pavan Chebbi wrote:
Quoted 2 lines
What I was saying is that in the PTP daemon you don't know whether the app running is likely to cause delays or not, and how long.
As such timeouts are rare but still normal.
Normal, because...? Why do they happen?
Quoted 5 lines
But if you've an environment where you want to have some kind of sync between the application and the NIC, as to when should both conclude that the timestamp is absolutely lost, we need some knob like this. Like you pointed out it's for an informed user who has knowledge of the
Let's start from informing the user why timeout happens.
Quoted 6 lines
workloads/flow control and how (badly) could they affect the TX. Of course the user cannot make an accurate estimation of the exact time out, but he can always experiment with the knob.
We are not sure if others need this as well, hence the private devlink parameter. For most common users, the default 1s timeout should serve well.
Pavan Chebbi
maintainerRe: [PATCH net-next 1/2] bnxt_en: Introduce devlink runtime driver param to set ptp tx timeout
Quoted 8 lines · Jakub Kicinski
Quoted 4 lines · On Fri, 1 Mar 2024 13:09:30 +0530 Pavan Chebbi wrote:
Quoted 2 lines
What I was saying is that in the PTP daemon you don't know whether the app running is likely to cause delays or not, and how long.
As such timeouts are rare but still normal.
Normal, because...? Why do they happen?
Excuse me for the late reply.
In my experience so far, it's primarily because of flow control and how stressed the underlying HW queue is. (I am sure it's not unique to our hardware alone)
Hence we wanted to accommodate cases where the expected wait time is higher than what is default in the driver, for the packets to go out. But it's disappointing to know that even private devlink params are discouraged for such purposes.
I'd think that non-generic driver params in devlink serve exactly such requirements and having such a knob would be useful for an advanced user.
Not to mention, in my view, such additions to devlink would make it more popular and would help in its wider adoption.
For now, we will drop this series and try to get back with a different solution.
Quoted 15 lines
Quoted 6 lines
But if you've an environment where you want to have some kind of sync between the application and the NIC, as to when should both conclude that the timestamp is absolutely lost, we need some knob like this. Like you pointed out it's for an informed user who has knowledge of the
Let's start from informing the user why timeout happens.
Quoted 6 lines
workloads/flow control and how (badly) could they affect the TX. Of course the user cannot make an accurate estimation of the exact time out, but he can always experiment with the knob.
We are not sure if others need this as well, hence the private devlink parameter. For most common users, the default 1s timeout should serve well.
Jakub Kicinski
maintainerRe: [PATCH net-next 1/2] bnxt_en: Introduce devlink runtime driver param to set ptp tx timeout
Quoted 4 lines · On Thu, 7 Mar 2024 09:20:44 +0530 Pavan Chebbi wrote:
Quoted 3 lines
Quoted 1 line
As such timeouts are rare but still normal.
Normal, because...? Why do they happen?
Quoted 13 lines
Excuse me for the late reply.
In my experience so far, it's primarily because of flow control and how stressed the underlying HW queue is. (I am sure it's not unique to our hardware alone)
Hence we wanted to accommodate cases where the expected wait time is higher than what is default in the driver, for the packets to go out. But it's disappointing to know that even private devlink params are discouraged for such purposes.
I'd think that non-generic driver params in devlink serve exactly such requirements and having such a knob would be useful for an advanced user.
Not to mention, in my view, such additions to devlink would make it more popular and would help in its wider adoption.
The problem can be solved more intelligently.
Jiri Pirko
maintainerRe: [PATCH net-next 1/2] bnxt_en: Introduce devlink runtime driver param to set ptp tx timeout
In reply to Vadim FedorenkoQuoted 12 lines · Thu, Feb 29, 2024 at 10:22:19PM CET, [email protected] wrote:
Quoted 11 lines · Jakub Kicinski
Quoted 7 lines · On Thu, 29 Feb 2024 18:11:49 +0100 Jiri Pirko wrote:
Idk. This does not look sane to me at all. Will we have custom knobs to change timeout for arbitrary FW commands as this as a common thing? Driver is the one to take care of timeouts of FW gracefully, he should know the FW, not the user. Therefore exposing user knobs like this sounds pure wrong to me.
nack for adding this to devlink.
+1
Quoted 7 lines
Quoted 4 lines
BTW why is the documentation in a different patch that the param :(
Quoted 2 lines
If this is some maybe-to-be-common ptp thing, can that be done as part of ptp api perhaps?
Jiri, do you mean extend current ioctl used to enable/disable HW timestamps?
Maybe.
Michael Chan
maintainerPATCH 2/2 bnxt_en: Retry for TX timestamp from FW until timeout specified
In reply to Michael ChanFrom: Pavan Chebbi <[email protected]>
Use the ptp_tx_timeout devlink parameter introduced in the previous patch to retry querying TX timestamp, up to the timeout specified. Firmware supports timeout values up to 65535 microseconds. The driver will set this firmware timeout value according to the ptp_tx_timeout parameter. If the ptp_tx_timeout value exceeds the maximum firmware value, the driver will retry in the context of bnxt_ptp_ts_aux_work().
--- Documentation/networking/devlink/bnxt.rst | 7 +++++++ drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c | 19 ++++++++++++++++--- drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h | 4 +++- 3 files changed, 26 insertions(+), 4 deletions(-)
Documentation/networking/devlink/bnxt.rst +7 -0
@@ -41,6 +41,13 @@ parameters. - Generic Routing Encapsulation (GRE) version check will be enabled in the device. If disabled, the device will skip the version check for incoming packets. + * - ``ptp_tx_timeout`` + - u32 + - Runtime + - PTP Transmit timestamp timeout value in milliseconds. The default + value is 1000 and the maximum value is 5000. Use a higher value + on a busy network to prevent timeout retrieving the PTP Transmit + timestamp. Info versions =============
drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c +16 -3
@@ -122,10 +122,14 @@ static int bnxt_hwrm_port_ts_query(struct bnxt *bp, u32 flags, u64 *ts) req->flags =cpu_to_le32 (flags);if ((flags &PORT_TS_QUERY_REQ_FLAGS_PATH ) ==PORT_TS_QUERY_REQ_FLAGS_PATH_TX ) { +struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; +u32 tmo_us = ptp->txts_tmo *1000 ; + req->enables =cpu_to_le16 (BNXT_PTP_QTS_TX_ENABLES ); - 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->ts_req_timeout =cpu_to_le16 (BNXT_PTP_QTS_TIMEOUT ); + req->ptp_seq_id =cpu_to_le32 (ptp->tx_seqid); + req->ptp_hdr_offset =cpu_to_le16 (ptp->tx_hdr_off); + tmo_us =min (tmo_us,BNXT_PTP_QTS_MAX_TMO_US ); + req->ts_req_timeout =cpu_to_le16 (tmo_us); } resp =hwrm_req_hold (bp, req);
@@ -675,6 +679,8 @@ static void bnxt_stamp_tx_skb(struct bnxt *bp, struct sk_buff *skb)u64 ts =0 , ns =0 ;int rc; +if (!ptp->txts_pending) + ptp->abs_txts_tmo = jiffies +msecs_to_jiffies (ptp->txts_tmo); rc =bnxt_hwrm_port_ts_query (bp,PORT_TS_QUERY_REQ_FLAGS_PATH_TX , &ts);if (!rc) {memset (×tamp,0 ,sizeof (timestamp));
@@ -684,6 +690,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, ×tamp); }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); }
@@ -691,6 +701,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)
@@ -714,6 +725,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 ; }
drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h +3 -1
@@ -24,7 +24,7 @@#define BNXT_PTP_DFLT_TX_TMO 1000/* ms */ #define BNXT_PTP_MAX_TX_TMO 5000/* 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 | \ PORT_TS_QUERY_REQ_ENABLES_TS_REQ_TIMEOUT | \ PORT_TS_QUERY_REQ_ENABLES_PTP_HDR_OFFSET)
@@ -117,12 +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
Signature · 1 line
2.30.1
Re: [PATCH net-next 2/2] bnxt_en: Retry for TX timestamp from FW until timeout specified
Quoted 45 lines · Michael Chan
From: Pavan Chebbi <[email protected]>
Use the
ptp_tx_timeoutdevlink parameter introduced in the previous patch to retry querying TX timestamp, up to the timeout specified. Firmware supports timeout values up to 65535 microseconds. The driver will set this firmware timeout value according to theptp_tx_timeoutparameter. If theptp_tx_timeoutvalue exceeds the maximum firmware value, the driver will retry in the context ofbnxt_ptp_ts_aux_work().Reviewed-by Andy Gospodarek <[email protected]>Signed-off-by Pavan Chebbi <[email protected]>Signed-off-by Michael Chan <[email protected]>--- Documentation/networking/devlink/bnxt.rst | 7 +++++++ drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c | 19 ++++++++++++++++--- drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h | 4 +++- 3 files changed, 26 insertions(+), 4 deletions(-)Documentation/networking/devlink/bnxt.rst +7
-0@@ -41,6 +41,13 @@ parameters. - Generic Routing Encapsulation (GRE) version check will be enabled in the device. If disabled, the device will skip the version check for incoming packets. + * - ``ptp_tx_timeout`` + - u32 + - Runtime + - PTP Transmit timestamp timeout value in milliseconds. The default + value is 1000 and the maximum value is 5000. Use a higher value + on a busy network to prevent timeout retrieving the PTP Transmit + timestamp. Info versions =============drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c +0
-0@@ -122,10 +122,14 @@ static int bnxt_hwrm_port_ts_query(struct bnxt *bp, u32 flags, u64 *ts) req->flags =cpu_to_le32 (flags);if ((flags &PORT_TS_QUERY_REQ_FLAGS_PATH ) ==PORT_TS_QUERY_REQ_FLAGS_PATH_TX ) {
drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c static int bnxt_hwrm_port_ts_query(struct bnxt *bp, u32 flags, u64 *ts) · line 131
Quoted 10 lines
drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c +6
-3+struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; +u32 tmo_us = ptp->txts_tmo *1000 ; + req->enables =cpu_to_le16 (BNXT_PTP_QTS_TX_ENABLES ); - 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->ts_req_timeout =cpu_to_le16 (BNXT_PTP_QTS_TIMEOUT ); + req->ptp_seq_id =cpu_to_le32 (ptp->tx_seqid); + req->ptp_hdr_offset =cpu_to_le16 (ptp->tx_hdr_off); + tmo_us =min (tmo_us,BNXT_PTP_QTS_MAX_TMO_US );
With this logic the request will stay longer than expected. With BNXT_PTP_QTS_MAX_TMO_US hardcoded to 65ms (it's later in the patch), and TXT timestamp timeout set for 270ms, the request will wait for 325ms in total. It doesn't look like a blocker, but it's definitely area to improve given that only one TX timestamp request can be in-flight.
Quoted 46 lines
drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c +10
-0+ req->ts_req_timeout =cpu_to_le16 (tmo_us); } resp =hwrm_req_hold (bp, req);@@ -675,6 +679,8 @@ static void bnxt_stamp_tx_skb(struct bnxt *bp, struct sk_buff *skb)u64 ts =0 , ns =0 ;int rc; +if (!ptp->txts_pending) + ptp->abs_txts_tmo = jiffies +msecs_to_jiffies (ptp->txts_tmo); rc =bnxt_hwrm_port_ts_query (bp,PORT_TS_QUERY_REQ_FLAGS_PATH_TX , &ts);if (!rc) {memset (×tamp,0 ,sizeof (timestamp));@@ -684,6 +690,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, ×tamp); }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); }@@ -691,6 +701,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)@@ -714,6 +725,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 ; }drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h +0
-0
drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h line 27
Quoted 5 lines
drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h +1
-1@@ -24,7 +24,7 @@#define BNXT_PTP_DFLT_TX_TMO 1000/* ms */ #define BNXT_PTP_MAX_TX_TMO 5000/* ms */ -#define BNXT_PTP_QTS_TIMEOUT 1000 +#define BNXT_PTP_QTS_MAX_TMO_US 65535
^^^^
This is the request timeout definition
Quoted 8 lines
drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h +1
-0#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_PTP_HDR_OFFSET)@@ -117,12 +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;
drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h struct bnxt_ptp_cfg { · line 130
Quoted 10 lines
drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h +1
-0int 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
Michael Chan
maintainerRe: [PATCH net-next 2/2] bnxt_en: Retry for TX timestamp from FW until timeout specified
Quoted 55 lines · Vadim Fedorenko
Quoted 53 lines · Michael Chan
From: Pavan Chebbi <[email protected]>
Use the
ptp_tx_timeoutdevlink parameter introduced in the previous patch to retry querying TX timestamp, up to the timeout specified. Firmware supports timeout values up to 65535 microseconds. The driver will set this firmware timeout value according to theptp_tx_timeoutparameter. If theptp_tx_timeoutvalue exceeds the maximum firmware value, the driver will retry in the context ofbnxt_ptp_ts_aux_work().Reviewed-by Andy Gospodarek <[email protected]>Signed-off-by Pavan Chebbi <[email protected]>Signed-off-by Michael Chan <[email protected]>--- Documentation/networking/devlink/bnxt.rst | 7 +++++++ drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c | 19 ++++++++++++++++--- drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h | 4 +++- 3 files changed, 26 insertions(+), 4 deletions(-)Documentation/networking/devlink/bnxt.rst +7
-0@@ -41,6 +41,13 @@ parameters. - Generic Routing Encapsulation (GRE) version check will be enabled in the device. If disabled, the device will skip the version check for incoming packets. + * - ``ptp_tx_timeout`` + - u32 + - Runtime + - PTP Transmit timestamp timeout value in milliseconds. The default + value is 1000 and the maximum value is 5000. Use a higher value + on a busy network to prevent timeout retrieving the PTP Transmit + timestamp. Info versions =============drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c +4
-3@@ -122,10 +122,14 @@ static int bnxt_hwrm_port_ts_query(struct bnxt *bp, u32 flags, u64 *ts) req->flags =cpu_to_le32 (flags);if ((flags &PORT_TS_QUERY_REQ_FLAGS_PATH ) ==PORT_TS_QUERY_REQ_FLAGS_PATH_TX ) { +struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; +u32 tmo_us = ptp->txts_tmo *1000 ; + req->enables =cpu_to_le16 (BNXT_PTP_QTS_TX_ENABLES ); - 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->ts_req_timeout =cpu_to_le16 (BNXT_PTP_QTS_TIMEOUT ); + req->ptp_seq_id =cpu_to_le32 (ptp->tx_seqid);
Quoted 8 lines
drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c static int bnxt_hwrm_port_ts_query(struct bnxt *bp, u32 flags, u64 *ts) · line 131
Quoted 2 lines
drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c +2
-0+ req->ptp_hdr_offset =cpu_to_le16 (ptp->tx_hdr_off); + tmo_us =min (tmo_us,BNXT_PTP_QTS_MAX_TMO_US );With this logic the request will stay longer than expected. With
BNXT_PTP_QTS_MAX_TMO_UShardcoded to 65ms (it's later in the patch), and TXT timestamp timeout set for 270ms, the request will wait for 325ms in total. It doesn't look like a blocker, but it's definitely area to improve given that only one TX timestamp request can be in-flight.
Note that the firmware will return the timestamp as soon as it is available or wait up to the timeout value. Yes, this firmware timeout value will be set to 65ms if the devlink parameter is > 65 ms. And yes, the worst case wait time can potentially be +65 msec in this case.
We can set this FW timeout value to something smaller than 65 ms (maybe something like 25 ms) when the devlink parameter is > 65 ms. Thanks.