diff mbox series

[net] bnxt_en: replace reset with config timestamps

Message ID 20220919183907.6689-1-vfedorenko@novek.ru (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series [net] bnxt_en: replace reset with config timestamps | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net
netdev/fixes_present success Fixes tag present in non-next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers warning 2 maintainers not CCed: edumazet@google.com pabeni@redhat.com
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 12 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Vadim Fedorenko Sept. 19, 2022, 6:39 p.m. UTC
Any change to the hardware timestamps configuration triggers nic restart,
which breaks transmition and reception of network packets for a while.
But there is no need to fully restart the device because while configuring
hardware timestamps. The code for changing configuration runs after all
of the initialisation, when the NIC is actually up and running. This patch
changes the code that ioctl will only update configuration registers and
will not trigger carrier status change. Tested on BCM57504.

Fixes: 11862689e8f1 ("bnxt_en: Configure ptp filters during bnxt open")
Cc: Richard Cochran <richardcochran@gmail.com>
Signed-off-by: Vadim Fedorenko <vfedorenko@novek.ru>
---
 drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

Comments

Michael Chan Sept. 20, 2022, 2:36 p.m. UTC | #1
On Mon, Sep 19, 2022 at 11:39 AM Vadim Fedorenko <vfedorenko@novek.ru> wrote:
>
> Any change to the hardware timestamps configuration triggers nic restart,
> which breaks transmition and reception of network packets for a while.
> But there is no need to fully restart the device because while configuring
> hardware timestamps. The code for changing configuration runs after all
> of the initialisation, when the NIC is actually up and running. This patch
> changes the code that ioctl will only update configuration registers and
> will not trigger carrier status change. Tested on BCM57504.
>
> Fixes: 11862689e8f1 ("bnxt_en: Configure ptp filters during bnxt open")
> Cc: Richard Cochran <richardcochran@gmail.com>
> Signed-off-by: Vadim Fedorenko <vfedorenko@novek.ru>
> ---
>  drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c
> index 8e316367f6ce..36e9148468b5 100644
> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c
> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c
> @@ -505,10 +505,8 @@ static int bnxt_hwrm_ptp_cfg(struct bnxt *bp)
>         ptp->tstamp_filters = flags;
>
>         if (netif_running(bp->dev)) {
> -               rc = bnxt_close_nic(bp, false, false);
> -               if (!rc)
> -                       rc = bnxt_open_nic(bp, false, false);
> -               if (!rc && !ptp->tstamp_filters)
> +               bnxt_ptp_cfg_tstamp_filters(bp);
> +               if (!ptp->tstamp_filters)

Closing and opening is the correct sequence, but this might work too.
Please give us a day to review this.  Thanks.
Michael Chan Sept. 21, 2022, 9:33 p.m. UTC | #2
On Tue, Sep 20, 2022 at 7:36 AM Michael Chan <michael.chan@broadcom.com> wrote:
>
> On Mon, Sep 19, 2022 at 11:39 AM Vadim Fedorenko <vfedorenko@novek.ru> wrote:
> >
> > Any change to the hardware timestamps configuration triggers nic restart,
> > which breaks transmition and reception of network packets for a while.
> > But there is no need to fully restart the device because while configuring
> > hardware timestamps. The code for changing configuration runs after all
> > of the initialisation, when the NIC is actually up and running. This patch
> > changes the code that ioctl will only update configuration registers and
> > will not trigger carrier status change. Tested on BCM57504.
> >
> > Fixes: 11862689e8f1 ("bnxt_en: Configure ptp filters during bnxt open")
> > Cc: Richard Cochran <richardcochran@gmail.com>
> > Signed-off-by: Vadim Fedorenko <vfedorenko@novek.ru>
> > ---
> >  drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c | 6 ++----
> >  1 file changed, 2 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c
> > index 8e316367f6ce..36e9148468b5 100644
> > --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c
> > +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c
> > @@ -505,10 +505,8 @@ static int bnxt_hwrm_ptp_cfg(struct bnxt *bp)
> >         ptp->tstamp_filters = flags;
> >
> >         if (netif_running(bp->dev)) {
> > -               rc = bnxt_close_nic(bp, false, false);
> > -               if (!rc)
> > -                       rc = bnxt_open_nic(bp, false, false);
> > -               if (!rc && !ptp->tstamp_filters)
> > +               bnxt_ptp_cfg_tstamp_filters(bp);
> > +               if (!ptp->tstamp_filters)
>
> Closing and opening is the correct sequence, but this might work too.
> Please give us a day to review this.  Thanks.

We have internally discussed this issue in great detail.  If the user
is changing the ALL_RX setting (enabling it or disabling it), just
calling bnxt_ptp_cfg_tstamp_filters() is not sufficient.  The reason
is that there is no synchronization after we send the new setting to
the FW.  We don't know when valid timestamps will start showing up in
the RX completion ring after turning on ALL_RX.  That's why we need to
close and open.  After open, all RX packets are guaranteed to have
valid timestamps.

So what we can do is to detect any changes to ALL_RX setting.  If
ALL_RX is not changing, we can just do what this patch is doing.  If
ALL_RX is changing, we can do something less intrusive than
close/open.  We can just shutdown RX and restart RX.  This way we
don't have to toggle carrier and cause a bigger disruption.

My colleague Pavan will take a few days to work on this.  Thanks.
Vadim Fedorenko Sept. 21, 2022, 10:34 p.m. UTC | #3
On 21.09.2022 22:33, Michael Chan wrote:
> On Tue, Sep 20, 2022 at 7:36 AM Michael Chan <michael.chan@broadcom.com> wrote:
>>
>> On Mon, Sep 19, 2022 at 11:39 AM Vadim Fedorenko <vfedorenko@novek.ru> wrote:
>>>
>>> Any change to the hardware timestamps configuration triggers nic restart,
>>> which breaks transmition and reception of network packets for a while.
>>> But there is no need to fully restart the device because while configuring
>>> hardware timestamps. The code for changing configuration runs after all
>>> of the initialisation, when the NIC is actually up and running. This patch
>>> changes the code that ioctl will only update configuration registers and
>>> will not trigger carrier status change. Tested on BCM57504.
>>>
>>> Fixes: 11862689e8f1 ("bnxt_en: Configure ptp filters during bnxt open")
>>> Cc: Richard Cochran <richardcochran@gmail.com>
>>> Signed-off-by: Vadim Fedorenko <vfedorenko@novek.ru>
>>> ---
>>>   drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c | 6 ++----
>>>   1 file changed, 2 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c
>>> index 8e316367f6ce..36e9148468b5 100644
>>> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c
>>> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c
>>> @@ -505,10 +505,8 @@ static int bnxt_hwrm_ptp_cfg(struct bnxt *bp)
>>>          ptp->tstamp_filters = flags;
>>>
>>>          if (netif_running(bp->dev)) {
>>> -               rc = bnxt_close_nic(bp, false, false);
>>> -               if (!rc)
>>> -                       rc = bnxt_open_nic(bp, false, false);
>>> -               if (!rc && !ptp->tstamp_filters)
>>> +               bnxt_ptp_cfg_tstamp_filters(bp);
>>> +               if (!ptp->tstamp_filters)
>>
>> Closing and opening is the correct sequence, but this might work too.
>> Please give us a day to review this.  Thanks.
> 
> We have internally discussed this issue in great detail.  If the user
> is changing the ALL_RX setting (enabling it or disabling it), just
> calling bnxt_ptp_cfg_tstamp_filters() is not sufficient.  The reason
> is that there is no synchronization after we send the new setting to
> the FW.  We don't know when valid timestamps will start showing up in
> the RX completion ring after turning on ALL_RX.  That's why we need to
> close and open.  After open, all RX packets are guaranteed to have
> valid timestamps.
> 
> So what we can do is to detect any changes to ALL_RX setting.  If
> ALL_RX is not changing, we can just do what this patch is doing.  If
> ALL_RX is changing, we can do something less intrusive than
> close/open.  We can just shutdown RX and restart RX.  This way we
> don't have to toggle carrier and cause a bigger disruption.
> 
Thanks for the review. I got your point regarding timestamps for all RX packets,
but for now I care about the case when ALL_RX is not supported. I can send a v2
with the check for this condition while you are working on the improvements for
all cases. Will it be to review and commit such patch?

Thanks.
diff mbox series

Patch

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c
index 8e316367f6ce..36e9148468b5 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c
@@ -505,10 +505,8 @@  static int bnxt_hwrm_ptp_cfg(struct bnxt *bp)
 	ptp->tstamp_filters = flags;
 
 	if (netif_running(bp->dev)) {
-		rc = bnxt_close_nic(bp, false, false);
-		if (!rc)
-			rc = bnxt_open_nic(bp, false, false);
-		if (!rc && !ptp->tstamp_filters)
+		bnxt_ptp_cfg_tstamp_filters(bp);
+		if (!ptp->tstamp_filters)
 			rc = -EIO;
 	}