Subject: Re: DSA using cpsw and lan9303

From: Måns Rullgård <[email-masked]>
Date: Mon, 14 Feb 2022 19:17:33 +0000

Vladimir Oltean <[email-masked]> writes:

> Hi Måns,
>
> On Mon, Feb 14, 2022 at 09:16:10AM -0800, Florian Fainelli wrote:
>> +others,
>>
>> netdev is a high volume list, you should probably copy directly the
>> people involved with the code you are working with.
>
> Thanks, Florian.
>
>> > Secondly, the cpsw driver strips VLAN tags from incoming frames, and
>> > this prevents the DSA parsing from working.  As a dirty workaround, I
>> > did this:
>> >
>> > diff --git a/drivers/net/ethernet/ti/cpsw_priv.c b/drivers/net/ethernet/ti/cpsw_priv.c
>> > index 424e644724e4..e15f42ece8bf 100644
>> > --- a/drivers/net/ethernet/ti/cpsw_priv.c
>> > +++ b/drivers/net/ethernet/ti/cpsw_priv.c
>> > @@ -235,6 +235,7 @@ void cpsw_rx_vlan_encap(struct sk_buff *skb)
>> >
>> >         /* Remove VLAN header encapsulation word */
>> >         skb_pull(skb, CPSW_RX_VLAN_ENCAP_HDR_SIZE);
>> > +       return;
>> >
>> >         pkt_type = (rx_vlan_encap_hdr >>
>> >                     CPSW_RX_VLAN_ENCAP_HDR_PKT_TYPE_SHIFT) &
>> >
>> > With these changes, everything seems to work as expected.
>> >
>> > Now I'd appreciate if someone could tell me how I should have done this.
>
> Assuming cpsw_rx_vlan_encap() doesn't just eat the VLAN, but puts it in
> the skb hwaccel area. The tag_lan9303.c tagger must deal with both
> variants of VLANs.
>
> For example, dsa_8021q_rcv() has:
>
> 	skb_push_rcsum(skb, ETH_HLEN);
> 	if (skb_vlan_tag_present(skb)) {
> 		tci = skb_vlan_tag_get(skb);
> 		__vlan_hwaccel_clear_tag(skb);
> 	} else {
> 		__skb_vlan_pop(skb, &tci);
> 	}
> 	skb_pull_rcsum(skb, ETH_HLEN);
>
> 	vid = tci & VLAN_VID_MASK;
>
> 	(process @vid here)
>
> which should give you a head start.

Thanks, that looks promising.

>> > Please don't make me send an actual patch.
>
> So what is your plan otherwise? :)

I meant I didn't want to send a patch I know to be broken only to
provoke a discussion.

-- 
Måns Rullgård