From: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>
To: Andrew Lunn <andrew@lunn.ch>, Heiner Kallweit <hkallweit1@gmail.com>
Cc: Alexandre Torgue <alexandre.torgue@foss.st.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Florian Fainelli <f.fainelli@gmail.com>,
Jakub Kicinski <kuba@kernel.org>,
Jiawen Wu <jiawenwu@trustnetic.com>,
Jose Abreu <joabreu@synopsys.com>,
Jose Abreu <Jose.Abreu@synopsys.com>,
linux-arm-kernel@lists.infradead.org,
linux-stm32@st-md-mailman.stormreply.com,
Maxime Coquelin <mcoquelin.stm32@gmail.com>,
Mengyuan Lou <mengyuanlou@net-swift.com>,
netdev@vger.kernel.org, Paolo Abeni <pabeni@redhat.com>,
Vladimir Oltean <olteanv@gmail.com>
Subject: [PATCH net-next 02/13] net: pcs: xpcs: don't use array for interface
Date: Fri, 04 Oct 2024 11:20:46 +0100 [thread overview]
Message-ID: <E1swfQU-006Df2-EF@rmk-PC.armlinux.org.uk> (raw)
In-Reply-To: <Zv_BTd8UF7XbJF_e@shell.armlinux.org.uk>
Currently, xpcs uses an array of interfaces that each "compat" entry
supports. When looking up the compat entry for an interface, we
iterate over the compat entries and then over each interface.
Since each compat entry only has a single interface in its interfaces
array, replace the array with a single member in the compat structure.
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
drivers/net/pcs/pcs-xpcs.c | 71 ++++++++------------------------------
1 file changed, 14 insertions(+), 57 deletions(-)
diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c
index e1f264039c91..4fbf7c816ed5 100644
--- a/drivers/net/pcs/pcs-xpcs.c
+++ b/drivers/net/pcs/pcs-xpcs.c
@@ -107,38 +107,9 @@ static const int xpcs_2500basex_features[] = {
__ETHTOOL_LINK_MODE_MASK_NBITS,
};
-static const phy_interface_t xpcs_usxgmii_interfaces[] = {
- PHY_INTERFACE_MODE_USXGMII,
-};
-
-static const phy_interface_t xpcs_10gkr_interfaces[] = {
- PHY_INTERFACE_MODE_10GKR,
-};
-
-static const phy_interface_t xpcs_xlgmii_interfaces[] = {
- PHY_INTERFACE_MODE_XLGMII,
-};
-
-static const phy_interface_t xpcs_10gbaser_interfaces[] = {
- PHY_INTERFACE_MODE_10GBASER,
-};
-
-static const phy_interface_t xpcs_sgmii_interfaces[] = {
- PHY_INTERFACE_MODE_SGMII,
-};
-
-static const phy_interface_t xpcs_1000basex_interfaces[] = {
- PHY_INTERFACE_MODE_1000BASEX,
-};
-
-static const phy_interface_t xpcs_2500basex_interfaces[] = {
- PHY_INTERFACE_MODE_2500BASEX,
-};
-
struct dw_xpcs_compat {
+ phy_interface_t interface;
const int *supported;
- const phy_interface_t *interface;
- int num_interfaces;
int an_mode;
int (*pma_config)(struct dw_xpcs *xpcs);
};
@@ -153,12 +124,10 @@ static const struct dw_xpcs_compat *
xpcs_find_compat(const struct dw_xpcs_desc *desc, phy_interface_t interface)
{
const struct dw_xpcs_compat *compat;
- int j;
for (compat = desc->compat; compat->supported; compat++)
- for (j = 0; j < compat->num_interfaces; j++)
- if (compat->interface[j] == interface)
- return compat;
+ if (compat->interface == interface)
+ return compat;
return NULL;
}
@@ -598,11 +567,9 @@ static int xpcs_validate(struct phylink_pcs *pcs, unsigned long *supported,
void xpcs_get_interfaces(struct dw_xpcs *xpcs, unsigned long *interfaces)
{
const struct dw_xpcs_compat *compat;
- int j;
for (compat = xpcs->desc->compat; compat->supported; compat++)
- for (j = 0; j < compat->num_interfaces; j++)
- __set_bit(compat->interface[j], interfaces);
+ __set_bit(compat->interface, interfaces);
}
EXPORT_SYMBOL_GPL(xpcs_get_interfaces);
@@ -1285,39 +1252,32 @@ static int xpcs_get_id(struct dw_xpcs *xpcs)
static const struct dw_xpcs_compat synopsys_xpcs_compat[] = {
{
+ .interface = PHY_INTERFACE_MODE_USXGMII,
.supported = xpcs_usxgmii_features,
- .interface = xpcs_usxgmii_interfaces,
- .num_interfaces = ARRAY_SIZE(xpcs_usxgmii_interfaces),
.an_mode = DW_AN_C73,
}, {
+ .interface = PHY_INTERFACE_MODE_10GKR,
.supported = xpcs_10gkr_features,
- .interface = xpcs_10gkr_interfaces,
- .num_interfaces = ARRAY_SIZE(xpcs_10gkr_interfaces),
.an_mode = DW_AN_C73,
}, {
+ .interface = PHY_INTERFACE_MODE_XLGMII,
.supported = xpcs_xlgmii_features,
- .interface = xpcs_xlgmii_interfaces,
- .num_interfaces = ARRAY_SIZE(xpcs_xlgmii_interfaces),
.an_mode = DW_AN_C73,
}, {
+ .interface = PHY_INTERFACE_MODE_10GBASER,
.supported = xpcs_10gbaser_features,
- .interface = xpcs_10gbaser_interfaces,
- .num_interfaces = ARRAY_SIZE(xpcs_10gbaser_interfaces),
.an_mode = DW_10GBASER,
}, {
+ .interface = PHY_INTERFACE_MODE_SGMII,
.supported = xpcs_sgmii_features,
- .interface = xpcs_sgmii_interfaces,
- .num_interfaces = ARRAY_SIZE(xpcs_sgmii_interfaces),
.an_mode = DW_AN_C37_SGMII,
}, {
+ .interface = PHY_INTERFACE_MODE_1000BASEX,
.supported = xpcs_1000basex_features,
- .interface = xpcs_1000basex_interfaces,
- .num_interfaces = ARRAY_SIZE(xpcs_1000basex_interfaces),
.an_mode = DW_AN_C37_1000BASEX,
}, {
+ .interface = PHY_INTERFACE_MODE_2500BASEX,
.supported = xpcs_2500basex_features,
- .interface = xpcs_2500basex_interfaces,
- .num_interfaces = ARRAY_SIZE(xpcs_2500basex_interfaces),
.an_mode = DW_2500BASEX,
}, {
}
@@ -1325,9 +1285,8 @@ static const struct dw_xpcs_compat synopsys_xpcs_compat[] = {
static const struct dw_xpcs_compat nxp_sja1105_xpcs_compat[] = {
{
+ .interface = PHY_INTERFACE_MODE_SGMII,
.supported = xpcs_sgmii_features,
- .interface = xpcs_sgmii_interfaces,
- .num_interfaces = ARRAY_SIZE(xpcs_sgmii_interfaces),
.an_mode = DW_AN_C37_SGMII,
.pma_config = nxp_sja1105_sgmii_pma_config,
}, {
@@ -1336,15 +1295,13 @@ static const struct dw_xpcs_compat nxp_sja1105_xpcs_compat[] = {
static const struct dw_xpcs_compat nxp_sja1110_xpcs_compat[] = {
{
+ .interface = PHY_INTERFACE_MODE_SGMII,
.supported = xpcs_sgmii_features,
- .interface = xpcs_sgmii_interfaces,
- .num_interfaces = ARRAY_SIZE(xpcs_sgmii_interfaces),
.an_mode = DW_AN_C37_SGMII,
.pma_config = nxp_sja1110_sgmii_pma_config,
}, {
+ .interface = PHY_INTERFACE_MODE_2500BASEX,
.supported = xpcs_2500basex_features,
- .interface = xpcs_2500basex_interfaces,
- .num_interfaces = ARRAY_SIZE(xpcs_2500basex_interfaces),
.an_mode = DW_2500BASEX,
.pma_config = nxp_sja1110_2500basex_pma_config,
}, {
--
2.30.2
next prev parent reply other threads:[~2024-10-04 10:24 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-04 10:19 [PATCH net-next 00/13] net: pcs: xpcs: cleanups batch 2 Russell King (Oracle)
2024-10-04 10:20 ` [PATCH net-next 01/13] net: pcs: xpcs: remove dw_xpcs_compat enum Russell King (Oracle)
2024-10-04 10:20 ` Russell King (Oracle) [this message]
2024-10-04 10:20 ` [PATCH net-next 03/13] net: pcs: xpcs: pass xpcs instead of xpcs->id to xpcs_find_compat() Russell King (Oracle)
2024-10-04 10:20 ` [PATCH net-next 04/13] net: pcs: xpcs: provide a helper to get the phylink pcs given xpcs Russell King (Oracle)
2024-10-04 10:21 ` [PATCH net-next 05/13] net: pcs: xpcs: move definition of struct dw_xpcs to private header Russell King (Oracle)
2024-10-04 10:21 ` [PATCH net-next 06/13] net: pcs: xpcs: rename xpcs_get_id() Russell King (Oracle)
2024-10-04 10:21 ` [PATCH net-next 07/13] net: pcs: xpcs: move searching ID list out of line Russell King (Oracle)
2024-10-04 10:21 ` [PATCH net-next 08/13] net: pcs: xpcs: use FIELD_PREP() and FIELD_GET() Russell King (Oracle)
2024-10-08 9:01 ` Paolo Abeni
2024-10-04 10:21 ` [PATCH net-next 09/13] net: pcs: xpcs: add _modify() accessors Russell King (Oracle)
2024-10-04 10:21 ` [PATCH net-next 10/13] net: pcs: xpcs: convert to use read_poll_timeout() Russell King (Oracle)
2024-10-04 10:21 ` [PATCH net-next 11/13] net: pcs: xpcs: use dev_*() to print messages Russell King (Oracle)
2024-10-04 10:21 ` [PATCH net-next 12/13] net: pcs: xpcs: correctly place DW_VR_MII_DIG_CTRL1_2G5_EN Russell King (Oracle)
2024-10-04 10:21 ` [PATCH net-next 13/13] net: pcs: xpcs: move Wangxun VR_XS_PCS_DIG_CTRL1 configuration Russell King (Oracle)
2024-10-04 10:25 ` [PATCH net-next 00/13] net: pcs: xpcs: cleanups batch 2 Russell King (Oracle)
2024-10-04 11:19 ` Vladimir Oltean
2024-10-04 17:07 ` Russell King (Oracle)
2024-10-04 23:40 ` Serge Semin
[not found] ` <rxv7tlvbl57yq62obsqtgr7r4llnb2ejjlaeausfxpdkxgxpyo@kqrgq2hdodts>
2024-10-09 9:27 ` Russell King (Oracle)
2024-10-10 20:31 ` Serge Semin
2024-10-09 11:20 ` patchwork-bot+netdevbpf
2024-10-09 11:47 ` Vladimir Oltean
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=E1swfQU-006Df2-EF@rmk-PC.armlinux.org.uk \
--to=rmk+kernel@armlinux.org.uk \
--cc=Jose.Abreu@synopsys.com \
--cc=alexandre.torgue@foss.st.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=f.fainelli@gmail.com \
--cc=hkallweit1@gmail.com \
--cc=jiawenwu@trustnetic.com \
--cc=joabreu@synopsys.com \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=mengyuanlou@net-swift.com \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=pabeni@redhat.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;
as well as URLs for NNTP newsgroup(s).