From mboxrd@z Thu Jan 1 00:00:00 1970 From: Florian Fainelli Subject: Re: [PATCH 1/2] net: emac: implement 802.1Q VLAN TX tagging support Date: Wed, 17 Oct 2018 13:08:21 -0700 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: "David S . Miller" To: Christian Lamparter , netdev@vger.kernel.org Return-path: Received: from mail-wm1-f68.google.com ([209.85.128.68]:54763 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725737AbeJREFv (ORCPT ); Thu, 18 Oct 2018 00:05:51 -0400 Received: by mail-wm1-f68.google.com with SMTP id r63-v6so3228190wma.4 for ; Wed, 17 Oct 2018 13:08:31 -0700 (PDT) In-Reply-To: Content-Language: en-US Sender: netdev-owner@vger.kernel.org List-ID: On 10/17/2018 12:53 PM, Christian Lamparter wrote: > As per' APM82181 Embedded Processor User Manual 26.1 EMAC Features: > VLAN: > - Support for VLAN tag ID in compliance with IEEE 802.3ac. > - VLAN tag insertion or replacement for transmit packets > > This patch completes the missing code for the VLAN tx tagging > support, as the the EMAC_MR1_VLE was already enabled. > > Signed-off-by: Christian Lamparter > --- > drivers/net/ethernet/ibm/emac/core.c | 32 ++++++++++++++++++++++++---- > drivers/net/ethernet/ibm/emac/core.h | 6 +++++- > 2 files changed, 33 insertions(+), 5 deletions(-) > > diff --git a/drivers/net/ethernet/ibm/emac/core.c b/drivers/net/ethernet/ibm/emac/core.c > index 760b2ad8e295..be560f9031f4 100644 > --- a/drivers/net/ethernet/ibm/emac/core.c > +++ b/drivers/net/ethernet/ibm/emac/core.c > @@ -37,6 +37,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -674,7 +675,7 @@ static int emac_configure(struct emac_instance *dev) > ndev->dev_addr[5]); > > /* VLAN Tag Protocol ID */ > - out_be32(&p->vtpid, 0x8100); > + out_be32(&p->vtpid, ETH_P_8021Q); > > /* Receive mode register */ > r = emac_iff2rmr(ndev); > @@ -1435,6 +1436,22 @@ static inline netdev_tx_t emac_xmit_finish(struct emac_instance *dev, int len) > return NETDEV_TX_OK; > } > > +static inline u16 emac_tx_vlan(struct emac_instance *dev, struct sk_buff *skb) > +{ > + /* Handle VLAN TPID and TCI insert if this is a VLAN skb */ > + if (emac_has_feature(dev, EMAC_FTR_HAS_VLAN_CTAG_TX) && > + skb_vlan_tag_present(skb)) { > + struct emac_regs __iomem *p = dev->emacp; > + > + /* update the VLAN TCI */ > + out_be32(&p->vtci, (u32)skb_vlan_tag_get(skb)); The only case where this is likely not going to be 0x8100/ETH_P_8021Q is if you do 802.1ad (QinQ) and you decided to somehow offload the S-Tag instead of the C-Tag. It would be a shame to slow down your TX path with an expensive register write, when maybe inserting the VLAN in software amounts to the same performance result ;) -- Florian