From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: "Ng, Boon Khai" <boon.khai.ng@intel.com>
Cc: Andrew Lunn <andrew@lunn.ch>,
Alexandre Torgue <alexandre.torgue@foss.st.com>,
Jose Abreu <joabreu@synopsys.com>,
"David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>,
Paolo Abeni <pabeni@redhat.com>,
Maxime Coquelin <mcoquelin.stm32@gmail.com>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"linux-stm32@st-md-mailman.stormreply.com"
<linux-stm32@st-md-mailman.stormreply.com>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"Ang, Tien Sung" <tien.sung.ang@intel.com>,
"G Thomas, Rohan" <rohan.g.thomas@intel.com>,
"Looi, Hong Aun" <hong.aun.looi@intel.com>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Subject: RE: [Enable Designware XGMAC VLAN Stripping Feature v2 1/1] net: stmmac: dwxgmac2: Add support for HW-accelerated VLAN Stripping
Date: Thu, 30 May 2024 11:25:16 +0300 (EEST) [thread overview]
Message-ID: <322d8745-7eae-4a68-4606-d9fdb19b4662@linux.intel.com> (raw)
In-Reply-To: <DM8PR11MB5751194374C75EC5D5889D6AC1F32@DM8PR11MB5751.namprd11.prod.outlook.com>
On Thu, 30 May 2024, Ng, Boon Khai wrote:
> > It is well know this driver is a mess. I just wanted to check you are not adding
> > to be mess by simply cut/pasting rather than refactoring code.
>
> Okay sure Andrew, will take note on this.
>
> > static void dwmac4_rx_hw_vlan(struct mac_device_info *hw,
> > struct dma_desc *rx_desc, struct sk_buff *skb) {
> > if (hw->desc->get_rx_vlan_valid(rx_desc)) {
> > u16 vid = hw->desc->get_rx_vlan_tci(rx_desc);
> >
> > __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), vid);
> > }
> > }
> >
> > Looks identical to me.
>
> Yes, some of the functions are identical, the driver has been divided
> into dwmac4_core.c and dwxgmac2_core.c initially, so to enable the
> rx_hw_vlan, it is porting from dwmac4_core to dwxgmac2_core.
>
> > The basic flow is the same. Lets look at the #defines:
> >
> Right, the basic flow is direct copy and paste, and only the function
> name is updated from dwmac4 to dwxgmac2.
> > +static inline bool dwxgmac2_wrback_get_rx_vlan_valid(struct dma_desc
> > +*p) {
> > + u32 et_lt;
> > +
> > + et_lt = FIELD_GET(XGMAC_RDES3_ET_LT, le32_to_cpu(p->des3));
> > +
> > + return et_lt >= XGMAC_ET_LT_VLAN_STAG &&
> > + et_lt <= XGMAC_ET_LT_DVLAN_STAG_CTAG; }
> >
> > static bool dwmac4_wrback_get_rx_vlan_valid(struct dma_desc *p) {
> > return ((le32_to_cpu(p->des3) & RDES3_LAST_DESCRIPTOR) &&
> > (le32_to_cpu(p->des3) & RDES3_RDES0_VALID)); }
> >
> > #define RDES3_RDES0_VALID BIT(25)
> > #define RDES3_LAST_DESCRIPTOR BIT(28)
> >
> > #define XGMAC_RDES3_ET_LT GENMASK(19, 16)
> > +#define XGMAC_ET_LT_VLAN_STAG 8
> > +#define XGMAC_ET_LT_VLAN_CTAG 9
> > +#define XGMAC_ET_LT_DVLAN_CTAG_CTAG 10
> >
> > This does actually look different.
> >
>
> Yes, this is the part in the descriptor where dwxgmac2 get the vlan Valid.
> it is described in Designware cores xgmac 10G Ethernet MAC version 3.10a
> page 1573.
>
> > Please take a step back and see if you can help clean up some of the mess in
> > this driver by refactoring bits of identical code, rather than copy/pasting it.
> >
>
> Appreciate if you could help to point out which part that I have to cleanup?
> Do you mean I should combine the identical part between dwmac4_core.c
> and dwxgmac2_core.c? or I should update the part that looks different and
> make them the same?
You should generalize the existing functions into some other file within
stmmac/ folder and call those functions from both dwmac4_core and dwxgmac2_core.
Do the rework of existing function & callers first and add the new bits
in another patch in the patch series.
Unfortunately, it's hard to catch copy-paste like this from other files
when not very familiar with the driver.
--
i.
next prev parent reply other threads:[~2024-05-30 8:25 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-27 9:33 [Enable Designware XGMAC VLAN Stripping Feature v2 0/1] Boon Khai Ng
2024-05-27 9:33 ` [Enable Designware XGMAC VLAN Stripping Feature v2 1/1] net: stmmac: dwxgmac2: Add support for HW-accelerated VLAN Stripping Boon Khai Ng
2024-05-27 10:40 ` [EXTERNAL] " Sunil Kovvuri Goutham
2024-05-27 13:28 ` Ng, Boon Khai
2024-05-27 15:36 ` Sunil Kovvuri Goutham
2024-05-28 2:06 ` Ng, Boon Khai
2024-05-28 7:18 ` Sunil Kovvuri Goutham
2024-05-28 7:21 ` Ng, Boon Khai
2024-05-28 12:21 ` Andrew Lunn
2024-05-30 2:16 ` Ng, Boon Khai
2024-05-27 19:00 ` Andrew Lunn
2024-05-28 2:29 ` Ng, Boon Khai
2024-05-28 13:02 ` Andrew Lunn
2024-05-30 5:48 ` Ng, Boon Khai
2024-05-30 8:25 ` Ilpo Järvinen [this message]
2024-06-04 6:05 ` Ng, Boon Khai
2024-06-04 19:26 ` Andrew Lunn
2024-06-07 4:09 ` Ng, Boon Khai
2024-06-10 12:30 ` Andrew Lunn
2024-06-11 7:01 ` Ng, Boon Khai
2024-06-11 7:06 ` Ilpo Järvinen
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=322d8745-7eae-4a68-4606-d9fdb19b4662@linux.intel.com \
--to=ilpo.jarvinen@linux.intel.com \
--cc=alexandre.torgue@foss.st.com \
--cc=andrew@lunn.ch \
--cc=andriy.shevchenko@linux.intel.com \
--cc=boon.khai.ng@intel.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hong.aun.looi@intel.com \
--cc=joabreu@synopsys.com \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=rohan.g.thomas@intel.com \
--cc=tien.sung.ang@intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®