lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <d19abc0a-4685-514d-387b-ac75503ee07a@gmail.com>
Date:   Mon, 14 Feb 2022 09:16:10 -0800
From:   Florian Fainelli <f.fainelli@...il.com>
To:     Måns Rullgård <mans@...sr.com>,
        netdev@...r.kernel.org,
        Egil Hjelmeland <privat@...l-hjelmeland.no>,
        Vladimir Oltean <olteanv@...il.com>,
        Andrew Lunn <andrew@...n.ch>,
        Juergen Borleis <jbe@...gutronix.de>,
        Grygorii Strashko <grygorii.strashko@...com>,
        lorenzo@...nel.org
Subject: Re: DSA using cpsw and lan9303

+others,

netdev is a high volume list, you should probably copy directly the
people involved with the code you are working with.

On 2/14/22 8:44 AM, Måns Rullgård wrote:
> The hardware I'm working on has a LAN9303 switch connected to the
> Ethernet port of an AM335x (ZCE package).  In trying to make DSA work
> with this combination, I have encountered two problems.
> 
> Firstly, the cpsw driver configures the hardware to filter out frames
> with unknown VLAN tags.  To make it accept the tagged frames coming from
> the LAN9303, I had to modify the latter driver like this:
> 
> diff --git a/drivers/net/dsa/lan9303-core.c b/drivers/net/dsa/lan9303-core.c
> index 2de67708bbd2..460c998c0c33 100644
> --- a/drivers/net/dsa/lan9303-core.c
> +++ b/drivers/net/dsa/lan9303-core.c
> @@ -1078,20 +1079,28 @@ static int lan9303_port_enable(struct dsa_switch *ds, int port,
>                                struct phy_device *phy)
>  {
>         struct lan9303 *chip = ds->priv;
> +       struct net_device *master;
>  
>         if (!dsa_is_user_port(ds, port))
>                 return 0;
>  
> +       master = dsa_to_port(chip->ds, 0)->master;
> +       vlan_vid_add(master, htons(ETH_P_8021Q), port);

That looks about right given that net/dsa/tag_lan9303.c appears to be a
quasi DSA_TAG_PROTO_8021Q implementation AFAICT.

> +
>         return lan9303_enable_processing_port(chip, port);
>  }
>  
> 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.
> Please don't make me send an actual patch.
-- 
Florian

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ