All of lore.kernel.org
 help / color / mirror / Atom feed
From: George McCollister <george.mccollister@gmail.com>
To: Vladimir Oltean <olteanv@gmail.com>
Cc: Jakub Kicinski <kuba@kernel.org>, Andrew Lunn <andrew@lunn.ch>,
	Vivien Didelot <vivien.didelot@gmail.com>,
	Florian Fainelli <f.fainelli@gmail.com>,
	Jonathan Corbet <corbet@lwn.net>,
	netdev@vger.kernel.org
Subject: Re: [RESEND PATCH net-next 1/4] net: hsr: generate supervision frame without HSR tag
Date: Tue, 2 Feb 2021 08:49:25 -0600	[thread overview]
Message-ID: <CAFSKS=MhuJtuXGDQHU_5w+AVf9DqdNh=zioJoZOuOYF5Jat-eQ@mail.gmail.com> (raw)
In-Reply-To: <20210202003729.oh224wtpqm6bcse3@skbuf>

On Mon, Feb 1, 2021 at 6:37 PM Vladimir Oltean <olteanv@gmail.com> wrote:
>
> On Mon, Feb 01, 2021 at 01:43:43PM -0600, George McCollister wrote:
> > > > diff --git a/net/hsr/hsr_device.c b/net/hsr/hsr_device.c
> > > > index ab953a1a0d6c..161b8da6a21d 100644
> > > > --- a/net/hsr/hsr_device.c
> > > > +++ b/net/hsr/hsr_device.c
> > > > @@ -242,8 +242,7 @@ static struct sk_buff *hsr_init_skb(struct hsr_port *master, u16 proto)
> > > >        * being, for PRP it is a trailer and for HSR it is a
> > > >        * header
> > > >        */
> > > > -     skb = dev_alloc_skb(sizeof(struct hsr_tag) +
> > > > -                         sizeof(struct hsr_sup_tag) +
> > > > +     skb = dev_alloc_skb(sizeof(struct hsr_sup_tag) +
> > > >                           sizeof(struct hsr_sup_payload) + hlen + tlen);
> > >
> > > Question 1: why are you no longer allocating struct hsr_tag (or struct prp_rct,
> > > which has the same size)?
> >
> > Because the tag is no longer being included in the supervisory frame
> > here. If I understand correctly hsr_create_tagged_frame and
> > prp_create_tagged_frame will create a new skb with HSR_HLEN added
> > later.
>
> I'm mostly doing static analysis of the code, which makes everything
> more difficult and also my review more inaccurate. I'll try to give your
> patches more testing when reviewing further, but I just got stuck into
> trying to understand them first.

I don't blame you at all. I've spent hours (maybe an understatement)
looking at the hsr code. Reviewing this patch without already being
familiar with the code or the standard would be very daunting.

>
> So your change makes fill_frame_info classify supervision frames as
> skb_std instead of skb_hsr or skb_prp. The tag is added only in
> hsr_create_tagged_frame right before dispatch to the egress port.
>
> But that means that there are places like for example
> hsr_handle_sup_frame which clearly don't like that: it checks whether
> there's a tagged skb in either frame->skb_hsr or frame->skb_prp, but not
> in frame->skb_std, so it now does basically nothing.
>
> Don't we need hsr_handle_sup_frame?

This part of the hsr code is very confusing and gave me problems at
first. Everywhere in the hsr_forward_do loop port is the destination
port. When it checks port->type == HSR_PT_MASTER before calling
hsr_handle_sup_frame it is checking for supervisory frames going to
the master port not from it. That is to say hsr_handle_sup_frame is
only called on incoming supervisory frames. This patch only addresses
generation of supervisory frames, that is to say outgoing supervisory
frames.

I may need to address this in the next patch for the case when removal
of the hsr/prp tag is offloaded on incoming frames.

>
> > > In hsr->proto_ops->fill_frame_info in the call path above, the skb is
> > > still put either into frame->skb_hsr or into frame->skb_prp, but not
> > > into frame->skb_std, even if it does not contain a struct hsr_tag.
> >
> > Are you sure? My patch changes hsr_fill_frame_info and
> > prp_fill_frame_info not to do that if port->type is HSR_PT_MASTER
> > which I'm pretty certain it always is when sending supervisory frames
> > like this. If I've overlooked something let me know.
>
> You're right, I had figured it out myself in the comment below where I
> called it a kludge.
>
> > >
> > > Also, which code exactly will insert the hsr_tag later? I assume
> > > hsr_fill_tag via hsr->proto_ops->create_tagged_frame?
> >
> > Correct.
>
> I think it's too late, see above.

I'm not saying it's impossible I missed something but I did test this
code pretty well with HSR v1 with and without offload on a ring with a
Moxa PT-G503. I even inspected everything on the wire to make sure it
was correct. I tested PRP as well though now I can't remember if I
inspected it on the wire so I'll make sure to check it again before
sending the next patch version.

>
> > > > -     if (!hsr->prot_version)
> > > > -             proto = ETH_P_PRP;
> > > > -     else
> > > > -             proto = ETH_P_HSR;
> > > > -
> > > > -     skb = hsr_init_skb(master, proto);
> > > > +     skb = hsr_init_skb(master, ETH_P_PRP);
> > >
> > > Question 2: why is this correct, setting skb->protocol to ETH_P_PRP
> > > (HSR v0) regardless of prot_version? Also, why is the change necessary?
> >
> > This part is not intuitive and I don't have a copy of the documents
> > where v0 was defined. It's unfortunate this code even supports v0
> > because AFAIK no one else uses it; but it's in here so we have to keep
> > supporting it I guess.
> > In v1 the tag has an eth type of 0x892f and the encapsulated
> > supervisory frame has a type of 0x88fb. In v0 0x88fb is used for the
> > eth type and there is no encapsulation type. So... this is correct
> > however I compared supervisory frame generation before and after this
> > patch for v0 and I found a problem. My changes make it add 0x88fb
> > again later for v0 which it's not supposed to do. I'll have to fix
> > that part somehow.
>
> Step 1: Sign up for HSR maintainership, it's currently orphan
> Step 2: Delete HSRv0 support
> Step 3: See if anyone shouts, probably not
> Step 4: Profit.

not a bad idea however user space defaults to using v0 when doing:
ip link add name hsr0 type hsr slave1 eth0 slave2 eth1

To use v1 you need to append "version 1".

It seems like it might be a hard sell to break the userspace default
even if no one in their right mind is using it. Still think it's
possible?

>
> > >
> > > Why is it such a big deal if supervision frames have HSR/PRP tag or not?
> >
> > Because if the switch does automatic HSR/PRP tag insertion it will end
> > up in there twice. You simply can't send anything with an HSR/PRP tag
> > if this is offloaded.
>
> When exactly will your hardware push a second HSR tag when the incoming
> packet already contains one? Obviously for tagged packets coming from
> the ring it should not do that. It must be treating the CPU port special
> somehow, but I don't understand how.

From the datasheet I linked before:
"At input the HSR tag is always removed if the port is in HSR mode. At
output a HSR tag is added if the output port is in HSR mode."
I don't see a great description of what happens internally when it's
forwarding from one redundant port to the other when in HSR (not PRP)
but perhaps it strips off the tag information, saves it and reapplies
it as it's going out? The redundant ports are in HSR mode, the CPU
facing port is not. Anyway I can tell you from using it, it does add a
second HSR tag if the CPU port sends a frame with one and the frames
going between the ring redundancy ports are forwarded with their
single tag.

  reply	other threads:[~2021-02-02 14:51 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-01 14:04 [RESEND PATCH net-next 0/4] add HSR offloading support for DSA switches George McCollister
2021-02-01 14:05 ` [RESEND PATCH net-next 1/4] net: hsr: generate supervision frame without HSR tag George McCollister
2021-02-01 14:59   ` Vladimir Oltean
2021-02-01 19:43     ` George McCollister
2021-02-02  0:37       ` Vladimir Oltean
2021-02-02 14:49         ` George McCollister [this message]
2021-02-03 21:16           ` Vladimir Oltean
2021-02-06 23:43           ` Vladimir Oltean
2021-02-08 15:26             ` George McCollister
2021-02-01 14:05 ` [RESEND PATCH net-next 2/4] net: hsr: add offloading support George McCollister
2021-02-01 15:23   ` Vladimir Oltean
2021-02-01 20:15     ` George McCollister
2021-02-03 20:43     ` George McCollister
2021-02-01 14:05 ` [RESEND PATCH net-next 3/4] net: dsa: add support for offloading HSR George McCollister
2021-02-01 14:05 ` [RESEND PATCH net-next 4/4] net: dsa: xrs700x: add HSR offloading support George McCollister
2021-02-01 15:29   ` Vladimir Oltean
2021-02-01 21:25     ` George McCollister

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='CAFSKS=MhuJtuXGDQHU_5w+AVf9DqdNh=zioJoZOuOYF5Jat-eQ@mail.gmail.com' \
    --to=george.mccollister@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=corbet@lwn.net \
    --cc=f.fainelli@gmail.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.com \
    --cc=vivien.didelot@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 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.