From: "Russell King (Oracle)" <linux@armlinux.org.uk>
To: Serge Semin <fancer.lancer@gmail.com>
Cc: Yanteng Si <siyanteng@loongson.cn>,
andrew@lunn.ch, hkallweit1@gmail.com, peppe.cavallaro@st.com,
alexandre.torgue@foss.st.com, joabreu@synopsys.com,
Jose.Abreu@synopsys.com, chenhuacai@loongson.cn,
guyinggang@loongson.cn, netdev@vger.kernel.org,
chris.chenfeiyang@gmail.com
Subject: Re: [PATCH net-next v8 09/11] net: stmmac: dwmac-loongson: Fix half duplex
Date: Wed, 20 Mar 2024 12:50:28 +0000 [thread overview]
Message-ID: <ZfrblN+OxODjZzfx@shell.armlinux.org.uk> (raw)
In-Reply-To: <Zfq8TNrt0KxW/IWh@shell.armlinux.org.uk>
On Wed, Mar 20, 2024 at 10:37:00AM +0000, Russell King (Oracle) wrote:
> I was thinking:
>
> stmmac_mac_phylink_get_caps(priv);
>
> if (priv->plat->mac_capabilities)
> priv->phylink_config.mac_capabilities &=
> priv->plat->mac_capabilities;
>
> In other words, if a platform sets plat->mac_capabilities, then it is
> providing the capabilities that it supports, and those need to reduce
> the capabilities provided by the MAC.
To further expand on this given the additional discussion, here's a
patch that amagamates the ideas so far - however, it doesn't
implement everything.
I think an additional step would be to provide a function that does all
the mac capability calculations, something like:
static void stmmac_calculate_mac_capabilities(struct stmmac_priv *priv)
{
struct phylink_config cfg;
/* do everything with cfg.mac_capabilities that is currently in
* stmmac_phy_setup()
*/
/* this must be done with rtnl held if the device is open */
priv->phylink_config.mac_capabilities = cfg.mac_capabilities;
}
and that needs to be called from both stmmac_reinit_queues() and
stmmac_phy_setup().
diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h b/drivers/net/ethernet/stmicro/stmmac/common.h
index a6fefe675ef1..a1e144b99213 100644
--- a/drivers/net/ethernet/stmicro/stmmac/common.h
+++ b/drivers/net/ethernet/stmicro/stmmac/common.h
@@ -605,6 +605,7 @@ struct mac_device_info {
unsigned int pmt;
unsigned int ps;
unsigned int xlgmac;
+ u32 phylink_mac_capabilities;
unsigned int num_vlan;
u32 vlan_filter[32];
bool vlan_fail_q_en;
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
index 6b6d0de09619..2e4da6ac5173 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
@@ -68,11 +68,6 @@ static void dwmac4_core_init(struct mac_device_info *hw,
init_waitqueue_head(&priv->tstamp_busy_wait);
}
-static void dwmac4_phylink_get_caps(struct stmmac_priv *priv)
-{
- priv->phylink_config.mac_capabilities |= MAC_2500FD;
-}
-
static void dwmac4_rx_queue_enable(struct mac_device_info *hw,
u8 mode, u32 queue)
{
@@ -1165,7 +1160,6 @@ static void dwmac4_set_hw_vlan_mode(struct mac_device_info *hw)
const struct stmmac_ops dwmac4_ops = {
.core_init = dwmac4_core_init,
- .phylink_get_caps = dwmac4_phylink_get_caps,
.set_mac = stmmac_set_mac,
.rx_ipc = dwmac4_rx_ipc_enable,
.rx_queue_enable = dwmac4_rx_queue_enable,
@@ -1210,7 +1204,6 @@ const struct stmmac_ops dwmac4_ops = {
const struct stmmac_ops dwmac410_ops = {
.core_init = dwmac4_core_init,
- .phylink_get_caps = dwmac4_phylink_get_caps,
.set_mac = stmmac_dwmac4_set_mac,
.rx_ipc = dwmac4_rx_ipc_enable,
.rx_queue_enable = dwmac4_rx_queue_enable,
@@ -1259,7 +1252,6 @@ const struct stmmac_ops dwmac410_ops = {
const struct stmmac_ops dwmac510_ops = {
.core_init = dwmac4_core_init,
- .phylink_get_caps = dwmac4_phylink_get_caps,
.set_mac = stmmac_dwmac4_set_mac,
.rx_ipc = dwmac4_rx_ipc_enable,
.rx_queue_enable = dwmac4_rx_queue_enable,
@@ -1372,5 +1364,7 @@ int dwmac4_setup(struct stmmac_priv *priv)
mac->mii.clk_csr_mask = GENMASK(11, 8);
mac->num_vlan = dwmac4_get_num_vlan(priv->ioaddr);
+ mac->phylink_mac_capabilities |= MAC_2500FD;
+
return 0;
}
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c
index 1af2f89a0504..f3daa284012b 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c
@@ -47,14 +47,6 @@ static void dwxgmac2_core_init(struct mac_device_info *hw,
writel(XGMAC_INT_DEFAULT_EN, ioaddr + XGMAC_INT_EN);
}
-static void xgmac_phylink_get_caps(struct stmmac_priv *priv)
-{
- priv->phylink_config.mac_capabilities |= MAC_2500FD | MAC_5000FD |
- MAC_10000FD | MAC_25000FD |
- MAC_40000FD | MAC_50000FD |
- MAC_100000FD;
-}
-
static void dwxgmac2_set_mac(void __iomem *ioaddr, bool enable)
{
u32 tx = readl(ioaddr + XGMAC_TX_CONFIG);
@@ -1516,7 +1508,6 @@ static void dwxgmac3_fpe_configure(void __iomem *ioaddr, struct stmmac_fpe_cfg *
const struct stmmac_ops dwxgmac210_ops = {
.core_init = dwxgmac2_core_init,
- .phylink_get_caps = xgmac_phylink_get_caps,
.set_mac = dwxgmac2_set_mac,
.rx_ipc = dwxgmac2_rx_ipc,
.rx_queue_enable = dwxgmac2_rx_queue_enable,
@@ -1577,7 +1568,6 @@ static void dwxlgmac2_rx_queue_enable(struct mac_device_info *hw, u8 mode,
const struct stmmac_ops dwxlgmac2_ops = {
.core_init = dwxgmac2_core_init,
- .phylink_get_caps = xgmac_phylink_get_caps,
.set_mac = dwxgmac2_set_mac,
.rx_ipc = dwxgmac2_rx_ipc,
.rx_queue_enable = dwxlgmac2_rx_queue_enable,
@@ -1656,6 +1646,11 @@ int dwxgmac2_setup(struct stmmac_priv *priv)
mac->mii.clk_csr_shift = 19;
mac->mii.clk_csr_mask = GENMASK(21, 19);
+ mac->phylink_mac_capabilities = MAC_2500FD | MAC_5000FD |
+ MAC_10000FD | MAC_25000FD |
+ MAC_40000FD | MAC_50000FD |
+ MAC_100000FD;
+
return 0;
}
@@ -1693,5 +1688,10 @@ int dwxlgmac2_setup(struct stmmac_priv *priv)
mac->mii.clk_csr_shift = 19;
mac->mii.clk_csr_mask = GENMASK(21, 19);
+ mac->phylink_mac_capabilities = MAC_2500FD | MAC_5000FD |
+ MAC_10000FD | MAC_25000FD |
+ MAC_40000FD | MAC_50000FD |
+ MAC_100000FD;
+
return 0;
}
diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ethernet/stmicro/stmmac/hwif.h
index 7be04b54738b..7370cd963569 100644
--- a/drivers/net/ethernet/stmicro/stmmac/hwif.h
+++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h
@@ -308,8 +308,6 @@ struct stmmac_est;
struct stmmac_ops {
/* MAC core initialization */
void (*core_init)(struct mac_device_info *hw, struct net_device *dev);
- /* Get phylink capabilities */
- void (*phylink_get_caps)(struct stmmac_priv *priv);
/* Enable the MAC RX/TX */
void (*set_mac)(void __iomem *ioaddr, bool enable);
/* Enable and verify that the IPC module is supported */
@@ -430,8 +428,6 @@ struct stmmac_ops {
#define stmmac_core_init(__priv, __args...) \
stmmac_do_void_callback(__priv, mac, core_init, __args)
-#define stmmac_mac_phylink_get_caps(__priv) \
- stmmac_do_void_callback(__priv, mac, phylink_get_caps, __priv)
#define stmmac_mac_set(__priv, __args...) \
stmmac_do_void_callback(__priv, mac, set_mac, __args)
#define stmmac_rx_ipc(__priv, __args...) \
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 24cd80490d19..5e8cffc49f1f 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -1240,15 +1240,25 @@ static int stmmac_phy_setup(struct stmmac_priv *priv)
MAC_10FD | MAC_100FD |
MAC_1000FD;
- stmmac_set_half_duplex(priv);
+ /* Merge in the MAC capabilities */
+ priv->phylink_config.mac_capabilities |=
+ priv->hw->phylink_mac_capabilities;
- /* Get the MAC specific capabilities */
- stmmac_mac_phylink_get_caps(priv);
+ stmmac_set_half_duplex(priv);
max_speed = priv->plat->max_speed;
if (max_speed)
phylink_limit_mac_speed(&priv->phylink_config, max_speed);
+ /* If the platform supplies MAC capabilities, calculate the union
+ * of the MAC and platform capabilities to give the whole-system
+ * capabilities. This intetionally can not add additional capabilities
+ * so if this is populated, it must list everything that is supported.
+ */
+ if (priv->plat->phylink_mac_capabilities)
+ priv->phylink_config.mac_capabilities &=
+ priv->plat->phylink_mac_capabilities;
+
fwnode = priv->plat->port_node;
if (!fwnode)
fwnode = dev_fwnode(priv->device);
diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h
index dfa1828cd756..fe3f64df17ac 100644
--- a/include/linux/stmmac.h
+++ b/include/linux/stmmac.h
@@ -272,6 +272,7 @@ struct plat_stmmacenet_data {
u8 tx_sched_algorithm;
struct stmmac_rxq_cfg rx_queues_cfg[MTL_MAX_RX_QUEUES];
struct stmmac_txq_cfg tx_queues_cfg[MTL_MAX_TX_QUEUES];
+ u32 phylink_mac_capabilities;
void (*fix_mac_speed)(void *priv, unsigned int speed, unsigned int mode);
int (*fix_soc_reset)(void *priv, void __iomem *ioaddr);
int (*serdes_powerup)(struct net_device *ndev, void *priv);
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
next prev parent reply other threads:[~2024-03-20 12:50 UTC|newest]
Thread overview: 97+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-30 8:43 [PATCH net-next v8 00/11] stmmac: Add Loongson platform support Yanteng Si
2024-01-30 8:43 ` [PATCH net-next v8 01/11] net: stmmac: Add multi-channel support Yanteng Si
2024-02-02 12:30 ` Simon Horman
2024-02-04 8:43 ` Yanteng Si
2024-02-04 23:28 ` Serge Semin
2024-02-06 9:02 ` Yanteng Si
2024-02-06 9:48 ` Serge Semin
2024-02-19 11:02 ` Yanteng Si
2024-02-21 13:48 ` Serge Semin
[not found] ` <ee2ffb6a-fe34-47a1-9734-b0e6697a5f09@loongson.cn>
2024-03-13 9:10 ` Yanteng Si
2024-03-19 14:18 ` Serge Semin
2024-03-20 9:47 ` Yanteng Si
2024-03-20 9:55 ` Russell King (Oracle)
2024-03-20 10:51 ` Yanteng Si
2024-02-05 1:11 ` Serge Semin
2024-01-30 8:43 ` [PATCH net-next v8 02/11] net: stmmac: dwmac-loongson: Refactor code for loongson_dwmac_probe() Yanteng Si
2024-02-02 12:33 ` Simon Horman
2024-02-04 8:47 ` Yanteng Si
2024-02-05 14:43 ` Serge Semin
2024-04-05 11:13 ` Yanteng Si
2024-01-30 8:43 ` [PATCH net-next v8 03/11] net: stmmac: dwmac-loongson: Add full PCI support Yanteng Si
2024-02-05 16:49 ` Serge Semin
2024-02-21 10:08 ` Yanteng Si
2024-01-30 8:43 ` [PATCH net-next v8 04/11] net: stmmac: dwmac-loongson: Move irq config to loongson_gmac_config Yanteng Si
2024-02-05 17:01 ` Serge Semin
2024-03-13 8:14 ` Yanteng Si
2024-03-19 13:43 ` Serge Semin
2024-03-20 10:12 ` Yanteng Si
2024-01-30 8:48 ` [PATCH net-next v8 05/11] net: stmmac: dwmac-loongson: Add Loongson-specific register definitions Yanteng Si
2024-02-05 18:17 ` Serge Semin
2024-02-22 13:39 ` Yanteng Si
2024-02-22 13:59 ` Serge Semin
2024-02-23 8:16 ` Yanteng Si
2024-02-23 18:50 ` Serge Semin
2024-03-07 13:15 ` Yanteng Si
2024-03-07 13:44 ` Serge Semin
2024-03-08 4:05 ` Yanteng Si
2024-01-30 8:48 ` [PATCH net-next v8 06/11] net: stmmac: dwmac-loongson: Add GNET support Yanteng Si
2024-02-05 20:58 ` Serge Semin
[not found] ` <d0e56c9b-9549-4061-8e44-2504b6b96897@loongson.cn>
2024-03-14 13:12 ` Yanteng Si
2024-03-19 15:03 ` Serge Semin
2024-03-20 10:23 ` Yanteng Si
2024-03-20 12:18 ` Serge Semin
2024-03-21 9:13 ` Yanteng Si
2024-03-21 14:55 ` Andrew Lunn
2024-03-28 11:41 ` Yanteng Si
2024-03-22 19:09 ` Serge Semin
2024-01-30 8:48 ` [PATCH net-next v8 07/11] net: stmmac: dwmac-loongson: Add multi-channel supports for loongson Yanteng Si
2024-02-05 21:28 ` Serge Semin
[not found] ` <e1c7b5fa-f3f8-4aa3-af4d-ca72b54d9c8c@loongson.cn>
2024-03-14 13:13 ` Yanteng Si
2024-03-19 15:53 ` Serge Semin
2024-03-22 10:36 ` Yanteng Si
2024-03-22 18:47 ` Serge Semin
2024-04-03 8:09 ` Yanteng Si
2024-04-03 12:03 ` Serge Semin
2024-04-05 10:17 ` Yanteng Si
2024-04-03 8:23 ` Yanteng Si
2024-01-30 8:48 ` [PATCH net-next v8 08/11] net: stmmac: dwmac-loongson: Fix MAC speed for GNET Yanteng Si
2024-02-05 21:55 ` Serge Semin
[not found] ` <4873ea5a-1b23-4512-b039-0a9198b53adf@loongson.cn>
2024-03-14 13:18 ` Yanteng Si
2024-03-19 17:02 ` Serge Semin
2024-03-20 10:42 ` Yanteng Si
2024-03-21 9:29 ` Yanteng Si
2024-03-21 15:02 ` Andrew Lunn
2024-03-21 15:19 ` Russell King (Oracle)
2024-03-21 15:38 ` Andrew Lunn
2024-03-26 12:32 ` Yanteng Si
2024-03-26 12:02 ` Yanteng Si
2024-03-26 12:21 ` Andrew Lunn
2024-03-27 2:41 ` Yanteng Si
2024-03-27 12:47 ` Andrew Lunn
2024-03-28 10:08 ` Yanteng Si
2024-01-30 8:49 ` [PATCH net-next v8 09/11] net: stmmac: dwmac-loongson: Fix half duplex Yanteng Si
2024-02-05 21:58 ` Serge Semin
2024-02-05 22:06 ` Serge Semin
2024-03-13 9:24 ` Yanteng Si
2024-03-13 10:21 ` Russell King (Oracle)
2024-03-14 13:08 ` Yanteng Si
2024-03-20 10:10 ` Serge Semin
2024-03-20 10:37 ` Russell King (Oracle)
2024-03-20 12:50 ` Russell King (Oracle) [this message]
2024-03-20 14:22 ` Russell King (Oracle)
2024-03-22 18:07 ` Serge Semin
2024-03-22 19:56 ` Russell King (Oracle)
2024-04-03 12:37 ` Serge Semin
2024-04-05 10:48 ` Yanteng Si
2024-01-30 8:49 ` [PATCH net-next v8 10/11] net: stmmac: dwmac-loongson: Disable flow control for GMAC Yanteng Si
2024-02-05 22:13 ` Serge Semin
2024-03-13 9:25 ` Yanteng Si
2024-01-30 8:49 ` [PATCH net-next v8 11/11] net: stmmac: dwmac-loongson: Disable coe for some Loongson GNET Yanteng Si
2024-02-05 22:18 ` Serge Semin
2024-03-13 9:52 ` Yanteng Si
2024-03-13 10:19 ` Yanteng Si
2024-03-20 11:24 ` Serge Semin
2024-01-30 9:57 ` [PATCH net-next v8 00/11] stmmac: Add Loongson platform support Serge Semin
2024-01-31 2:10 ` Jakub Kicinski
2024-01-31 9:20 ` Yanteng Si
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=ZfrblN+OxODjZzfx@shell.armlinux.org.uk \
--to=linux@armlinux.org.uk \
--cc=Jose.Abreu@synopsys.com \
--cc=alexandre.torgue@foss.st.com \
--cc=andrew@lunn.ch \
--cc=chenhuacai@loongson.cn \
--cc=chris.chenfeiyang@gmail.com \
--cc=fancer.lancer@gmail.com \
--cc=guyinggang@loongson.cn \
--cc=hkallweit1@gmail.com \
--cc=joabreu@synopsys.com \
--cc=netdev@vger.kernel.org \
--cc=peppe.cavallaro@st.com \
--cc=siyanteng@loongson.cn \
/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).