From: Lorenzo Bianconi <lorenzo@kernel.org>
To: Simon Horman <horms@kernel.org>
Cc: Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Philipp Zabel <p.zabel@pengutronix.de>,
linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org, netdev@vger.kernel.org,
devicetree@vger.kernel.org
Subject: Re: [PATCH net-next 11/12] net: airoha: Refactor src port configuration in airhoha_set_gdm2_loopback
Date: Thu, 16 Oct 2025 10:36:49 +0200 [thread overview]
Message-ID: <aPCuoR8ukM23d71i@lore-desk> (raw)
In-Reply-To: <aO_GOE0jPMlcP-VR@horms.kernel.org>
[-- Attachment #1: Type: text/plain, Size: 4531 bytes --]
> On Wed, Oct 15, 2025 at 09:15:11AM +0200, Lorenzo Bianconi wrote:
> > AN7583 chipset relies on different definitions for source-port
> > identifier used for hw offloading. In order to support hw offloading
> > in AN7583 controller, refactor src port configuration in
> > airhoha_set_gdm2_loopback routine and introduce get_src_port_id
> > callback.
> >
> > Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> > ---
> > drivers/net/ethernet/airoha/airoha_eth.c | 75 +++++++++++++++++++++----------
> > drivers/net/ethernet/airoha/airoha_eth.h | 11 +++--
> > drivers/net/ethernet/airoha/airoha_regs.h | 5 +--
> > 3 files changed, 60 insertions(+), 31 deletions(-)
> >
> > diff --git a/drivers/net/ethernet/airoha/airoha_eth.c b/drivers/net/ethernet/airoha/airoha_eth.c
> > index 5f6b5ab52e0265f7bb56b008ca653d64e04ff2d2..76c82750b3ae89a9fa81c64d3b7c3578b369480c 100644
> > --- a/drivers/net/ethernet/airoha/airoha_eth.c
> > +++ b/drivers/net/ethernet/airoha/airoha_eth.c
> > @@ -1682,11 +1682,14 @@ static int airoha_dev_set_macaddr(struct net_device *dev, void *p)
> > return 0;
> > }
> >
> > -static void airhoha_set_gdm2_loopback(struct airoha_gdm_port *port)
> > +static int airhoha_set_gdm2_loopback(struct airoha_gdm_port *port)
> > {
> > u32 pse_port = port->id == 3 ? FE_PSE_PORT_GDM3 : FE_PSE_PORT_GDM4;
> > struct airoha_eth *eth = port->qdma->eth;
> > u32 chan = port->id == 3 ? 4 : 0;
> > + /* XXX: handle XSI_USB_PORT and XSI_PCE1_PORT */
> > + u32 nbq = port->id == 3 ? 4 : 0;
> > + int src_port;
>
> I think this code could benefit for names (defines) for port ids.
> It's a bit clearer in airoha_en7581_get_src_port_id(). But the
> numbers seem kind of magic in this function.
ack, I will fix it in v2.
Regards,
Lorenzo
>
> >
> > /* Forward the traffic to the proper GDM port */
> > airoha_set_gdm_port_fwd_cfg(eth, REG_GDM_FWD_CFG(2), pse_port);
> > @@ -1709,29 +1712,23 @@ static void airhoha_set_gdm2_loopback(struct airoha_gdm_port *port)
> > airoha_fe_clear(eth, REG_FE_VIP_PORT_EN, BIT(2));
> > airoha_fe_clear(eth, REG_FE_IFC_PORT_EN, BIT(2));
> >
> > - if (port->id == 3) {
> > - /* FIXME: handle XSI_PCE1_PORT */
> > - airoha_fe_rmw(eth, REG_FE_WAN_PORT,
> > - WAN1_EN_MASK | WAN1_MASK | WAN0_MASK,
> > - FIELD_PREP(WAN0_MASK, HSGMII_LAN_PCIE0_SRCPORT));
> > - airoha_fe_rmw(eth,
> > - REG_SP_DFT_CPORT(HSGMII_LAN_PCIE0_SRCPORT >> 3),
> > - SP_CPORT_PCIE0_MASK,
> > - FIELD_PREP(SP_CPORT_PCIE0_MASK,
> > - FE_PSE_PORT_CDM2));
> > - } else {
> > - /* FIXME: handle XSI_USB_PORT */
> > + src_port = eth->soc->ops.get_src_port_id(port, nbq);
> > + if (src_port < 0)
> > + return src_port;
> > +
> > + airoha_fe_rmw(eth, REG_FE_WAN_PORT,
> > + WAN1_EN_MASK | WAN1_MASK | WAN0_MASK,
> > + FIELD_PREP(WAN0_MASK, src_port));
> > + airoha_fe_rmw(eth, REG_SP_DFT_CPORT(src_port >> 3),
> > + SP_CPORT_MASK(src_port & 0x7),
> > + FE_PSE_PORT_CDM2 << __ffs(SP_CPORT_MASK(src_port & 0x7)));
>
> Likewise, 3 and 0x7 a bit magical here.
>
> > +
> > + if (port->id != 3)
> > airoha_fe_rmw(eth, REG_SRC_PORT_FC_MAP6,
> > FC_ID_OF_SRC_PORT24_MASK,
> > FIELD_PREP(FC_ID_OF_SRC_PORT24_MASK, 2));
>
> ... and 2 here.
>
> > - airoha_fe_rmw(eth, REG_FE_WAN_PORT,
> > - WAN1_EN_MASK | WAN1_MASK | WAN0_MASK,
> > - FIELD_PREP(WAN0_MASK, HSGMII_LAN_ETH_SRCPORT));
> > - airoha_fe_rmw(eth,
> > - REG_SP_DFT_CPORT(HSGMII_LAN_ETH_SRCPORT >> 3),
> > - SP_CPORT_ETH_MASK,
> > - FIELD_PREP(SP_CPORT_ETH_MASK, FE_PSE_PORT_CDM2));
> > - }
> > +
> > + return 0;
> > }
>
> ...
>
> > @@ -3055,11 +3057,38 @@ static const char * const en7581_xsi_rsts_names[] = {
> > "xfp-mac",
> > };
> >
> > +static int airoha_en7581_get_src_port_id(struct airoha_gdm_port *port, int nbq)
> > +{
> > + switch (port->id) {
> > + case 3:
> > + /* 7581 SoC supports PCIe serdes on GDM3 port */
> > + if (nbq == 4)
> > + return HSGMII_LAN_7581_PCIE0_SRCPORT;
> > + if (nbq == 5)
> > + return HSGMII_LAN_7581_PCIE1_SRCPORT;
> > + break;
> > + case 4:
> > + /* 7581 SoC supports eth and usb serdes on GDM4 port */
> > + if (!nbq)
> > + return HSGMII_LAN_7581_ETH_SRCPORT;
> > + if (nbq == 1)
> > + return HSGMII_LAN_7581_USB_SRCPORT;
> > + break;
> > + default:
> > + break;
> > + }
> > +
> > + return -EINVAL;
> > +}
>
> ...
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
next prev parent reply other threads:[~2025-10-16 8:36 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-15 7:15 [PATCH net-next 00/12] net: airoha: Add AN7583 ethernet controller support Lorenzo Bianconi
2025-10-15 7:15 ` [PATCH net-next 01/12] dt-bindings: net: airoha: Add AN7583 support Lorenzo Bianconi
2025-10-15 7:15 ` [PATCH net-next 02/12] net: airoha: ppe: Dynamically allocate foe_check_time array in airoha_ppe struct Lorenzo Bianconi
2025-10-15 16:06 ` Simon Horman
2025-10-15 7:15 ` [PATCH net-next 03/12] net: airoha: Add airoha_ppe_get_num_stats_entries() and airoha_ppe_get_num_total_stats_entries() Lorenzo Bianconi
2025-10-15 12:52 ` Simon Horman
2025-10-16 8:10 ` Lorenzo Bianconi
2025-10-15 7:15 ` [PATCH net-next 04/12] net: airoha: Add airoha_eth_soc_data struct Lorenzo Bianconi
2025-10-15 16:06 ` Simon Horman
2025-10-15 7:15 ` [PATCH net-next 05/12] net: airoha: Generalize airoha_ppe2_is_enabled routine Lorenzo Bianconi
2025-10-15 16:07 ` Simon Horman
2025-10-15 7:15 ` [PATCH net-next 06/12] net: airoha: ppe: Move PPE memory info in airoha_eth_soc_data struct Lorenzo Bianconi
2025-10-15 16:07 ` Simon Horman
2025-10-15 7:15 ` [PATCH net-next 07/12] net: airoha: ppe: Remove airoha_ppe_is_enabled() where not necessary Lorenzo Bianconi
2025-10-15 16:07 ` Simon Horman
2025-10-15 7:15 ` [PATCH net-next 08/12] net: airoha: ppe: Configure SRAM PPE entries via the cpu Lorenzo Bianconi
2025-10-15 15:47 ` Simon Horman
2025-10-16 8:13 ` Lorenzo Bianconi
2025-10-15 7:15 ` [PATCH net-next 09/12] net: airoha: ppe: Flush PPE SRAM table during PPE setup Lorenzo Bianconi
2025-10-15 16:08 ` Simon Horman
2025-10-15 7:15 ` [PATCH net-next 10/12] net: airoha: Select default ppe cpu port in airoha_dev_init() Lorenzo Bianconi
2025-10-15 15:54 ` Simon Horman
2025-10-16 8:51 ` Lorenzo Bianconi
2025-10-15 7:15 ` [PATCH net-next 11/12] net: airoha: Refactor src port configuration in airhoha_set_gdm2_loopback Lorenzo Bianconi
2025-10-15 16:05 ` Simon Horman
2025-10-16 8:36 ` Lorenzo Bianconi [this message]
2025-10-15 7:15 ` [PATCH net-next 12/12] net: airoha: Add AN7583 SoC support Lorenzo Bianconi
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=aPCuoR8ukM23d71i@lore-desk \
--to=lorenzo@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=conor+dt@kernel.org \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=netdev@vger.kernel.org \
--cc=p.zabel@pengutronix.de \
--cc=pabeni@redhat.com \
--cc=robh@kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).