2022-09-14 10:09:34

by Siddharth Vadapalli

[permalink] [raw]
Subject: [PATCH 4/8] net: ethernet: ti: am65-cpsw: Add mac enable link function

Add function am65_cpsw_nuss_mac_enable_link() to invoke
am65_cpsw_enable_phy(), cpsw_ale_control_set(), am65_cpsw_qos_link_up()
and netif_tx_wake_all_queues() to prevent duplicate code. The above
set of function calls are currently invoked by the
am65_cpsw_nuss_mac_link_up() function. In a later patch in this series
meant for adding fixed-link support, even the am65_cpsw_nuss_mac_config()
function will invoke the same set of functions.

Signed-off-by: Siddharth Vadapalli <[email protected]>
---
drivers/net/ethernet/ti/am65-cpsw-nuss.c | 25 ++++++++++++++----------
1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
index c7e6ad374e1a..72b1df12f320 100644
--- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c
+++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
@@ -1473,6 +1473,20 @@ static void am65_cpsw_nuss_mac_control(struct am65_cpsw_port *port, phy_interfac
cpsw_sl_ctl_set(port->slave.mac_sl, mac_control);
}

+static void am65_cpsw_nuss_mac_enable_link(struct am65_cpsw_port *port, int speed, int duplex)
+{
+ struct am65_cpsw_common *common = port->common;
+ struct net_device *ndev = port->ndev;
+ /* enable phy */
+ am65_cpsw_enable_phy(port->slave.ifphy);
+
+ /* enable forwarding */
+ cpsw_ale_control_set(common->ale, port->port_id, ALE_PORT_STATE, ALE_PORT_STATE_FORWARD);
+
+ am65_cpsw_qos_link_up(ndev, speed);
+ netif_tx_wake_all_queues(ndev);
+}
+
static void am65_cpsw_nuss_mac_config(struct phylink_config *config, unsigned int mode,
const struct phylink_link_state *state)
{
@@ -1521,19 +1535,10 @@ static void am65_cpsw_nuss_mac_link_up(struct phylink_config *config, struct phy
struct am65_cpsw_slave_data *slave = container_of(config, struct am65_cpsw_slave_data,
phylink_config);
struct am65_cpsw_port *port = container_of(slave, struct am65_cpsw_port, slave);
- struct am65_cpsw_common *common = port->common;
- struct net_device *ndev = port->ndev;

am65_cpsw_nuss_mac_control(port, interface, speed, duplex, tx_pause, rx_pause);

- /* enable phy */
- am65_cpsw_enable_phy(port->slave.ifphy);
-
- /* enable forwarding */
- cpsw_ale_control_set(common->ale, port->port_id, ALE_PORT_STATE, ALE_PORT_STATE_FORWARD);
-
- am65_cpsw_qos_link_up(ndev, speed);
- netif_tx_wake_all_queues(ndev);
+ am65_cpsw_nuss_mac_enable_link(port, speed, duplex);
}

static const struct phylink_mac_ops am65_cpsw_phylink_mac_ops = {
--
2.25.1


2022-09-14 16:46:07

by Russell King (Oracle)

[permalink] [raw]
Subject: Re: [PATCH 4/8] net: ethernet: ti: am65-cpsw: Add mac enable link function

On Wed, Sep 14, 2022 at 03:20:49PM +0530, Siddharth Vadapalli wrote:
> Add function am65_cpsw_nuss_mac_enable_link() to invoke
> am65_cpsw_enable_phy(), cpsw_ale_control_set(), am65_cpsw_qos_link_up()
> and netif_tx_wake_all_queues() to prevent duplicate code. The above
> set of function calls are currently invoked by the
> am65_cpsw_nuss_mac_link_up() function. In a later patch in this series
> meant for adding fixed-link support, even the am65_cpsw_nuss_mac_config()
> function will invoke the same set of functions.

I don't think you will need this patch once you've debugged why
mac_link_up() doesn't get called for a fixed link (it should be
called.)

--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!