netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/6] dpaa2-mac: various updates
@ 2021-01-07 15:36 Ioana Ciornei
  2021-01-07 15:36 ` [PATCH 1/6] dpaa2-mac: split up initializing the MAC object from connecting to it Ioana Ciornei
                   ` (5 more replies)
  0 siblings, 6 replies; 12+ messages in thread
From: Ioana Ciornei @ 2021-01-07 15:36 UTC (permalink / raw)
  To: davem, kuba, netdev; +Cc: laurentiu.tudor, Ioana Ciornei

From: Ioana Ciornei <ioana.ciornei@nxp.com>

The first two patches of this series extends the MAC statistics support
to also work for network interfaces which have their link status handled
by firmware (TYPE_FIXED).

The next two patches are fixing a sporadic problem which happens when
the connected DPMAC object is not yet discovered by the fsl-mc bus, thus
the dpaa2-eth is not able to get a reference to it. A referred probe
will be requested in this case.

Finally, the last two patches make some cosmetic changes, mostly
removing comments and unnecessary checks.


Ioana Ciornei (6):
  dpaa2-mac: split up initializing the MAC object from connecting to it
  dpaa2-mac: export MAC counters even when in TYPE_FIXED
  bus: fsl-mc: return -EPROBE_DEFER when a device is not yet discovered
  dpaa2-eth: retry the probe when the MAC is not yet discovered on the
    bus
  dpaa2-mac: remove an unnecessary check
  dpaa2-mac: remove a comment regarding pause settings

 drivers/bus/fsl-mc/fsl-mc-bus.c               |   9 ++
 .../net/ethernet/freescale/dpaa2/dpaa2-eth.c  |  53 ++++---
 .../net/ethernet/freescale/dpaa2/dpaa2-eth.h  |  13 ++
 .../ethernet/freescale/dpaa2/dpaa2-ethtool.c  |  16 +--
 .../net/ethernet/freescale/dpaa2/dpaa2-mac.c  | 134 ++++++++----------
 .../net/ethernet/freescale/dpaa2/dpaa2-mac.h  |   5 +
 6 files changed, 125 insertions(+), 105 deletions(-)

-- 
2.29.2


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 1/6] dpaa2-mac: split up initializing the MAC object from connecting to it
  2021-01-07 15:36 [PATCH 0/6] dpaa2-mac: various updates Ioana Ciornei
@ 2021-01-07 15:36 ` Ioana Ciornei
  2021-01-07 15:36 ` [PATCH 2/6] dpaa2-mac: export MAC counters even when in TYPE_FIXED Ioana Ciornei
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 12+ messages in thread
From: Ioana Ciornei @ 2021-01-07 15:36 UTC (permalink / raw)
  To: davem, kuba, netdev; +Cc: laurentiu.tudor, Ioana Ciornei

From: Ioana Ciornei <ioana.ciornei@nxp.com>

Split up the initialization phase of the dpmac object from actually
configuring the phylink instance, connecting to it and configuring the
MAC. This is done so that even though the dpni object is connected to a
dpmac which has link management handled by the firmware we are still
able to export the MAC counters.

Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
---
 .../net/ethernet/freescale/dpaa2/dpaa2-eth.c  | 14 +++-
 .../net/ethernet/freescale/dpaa2/dpaa2-mac.c  | 68 +++++++++++--------
 .../net/ethernet/freescale/dpaa2/dpaa2-mac.h  |  5 ++
 3 files changed, 58 insertions(+), 29 deletions(-)

diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
index fb0bcd18ec0c..61385894e8c7 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
@@ -4056,15 +4056,24 @@ static int dpaa2_eth_connect_mac(struct dpaa2_eth_priv *priv)
 	mac->mc_io = priv->mc_io;
 	mac->net_dev = priv->net_dev;
 
+	err = dpaa2_mac_open(mac);
+	if (err)
+		goto err_free_mac;
+
 	err = dpaa2_mac_connect(mac);
 	if (err) {
 		netdev_err(priv->net_dev, "Error connecting to the MAC endpoint\n");
-		kfree(mac);
-		return err;
+		goto err_close_mac;
 	}
 	priv->mac = mac;
 
 	return 0;
+
+err_close_mac:
+	dpaa2_mac_close(mac);
+err_free_mac:
+	kfree(mac);
+	return err;
 }
 
 static void dpaa2_eth_disconnect_mac(struct dpaa2_eth_priv *priv)
@@ -4073,6 +4082,7 @@ static void dpaa2_eth_disconnect_mac(struct dpaa2_eth_priv *priv)
 		return;
 
 	dpaa2_mac_disconnect(priv->mac);
+	dpaa2_mac_close(priv->mac);
 	kfree(priv->mac);
 	priv->mac = NULL;
 }
diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
index 828c177df03d..b97a219878c0 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
@@ -302,36 +302,20 @@ static void dpaa2_pcs_destroy(struct dpaa2_mac *mac)
 
 int dpaa2_mac_connect(struct dpaa2_mac *mac)
 {
-	struct fsl_mc_device *dpmac_dev = mac->mc_dev;
 	struct net_device *net_dev = mac->net_dev;
 	struct device_node *dpmac_node;
 	struct phylink *phylink;
-	struct dpmac_attr attr;
 	int err;
 
-	err = dpmac_open(mac->mc_io, 0, dpmac_dev->obj_desc.id,
-			 &dpmac_dev->mc_handle);
-	if (err || !dpmac_dev->mc_handle) {
-		netdev_err(net_dev, "dpmac_open() = %d\n", err);
-		return -ENODEV;
-	}
-
-	err = dpmac_get_attributes(mac->mc_io, 0, dpmac_dev->mc_handle, &attr);
-	if (err) {
-		netdev_err(net_dev, "dpmac_get_attributes() = %d\n", err);
-		goto err_close_dpmac;
-	}
-
-	mac->if_link_type = attr.link_type;
+	mac->if_link_type = mac->attr.link_type;
 
-	dpmac_node = dpaa2_mac_get_node(attr.id);
+	dpmac_node = dpaa2_mac_get_node(mac->attr.id);
 	if (!dpmac_node) {
-		netdev_err(net_dev, "No dpmac@%d node found.\n", attr.id);
-		err = -ENODEV;
-		goto err_close_dpmac;
+		netdev_err(net_dev, "No dpmac@%d node found.\n", mac->attr.id);
+		return -ENODEV;
 	}
 
-	err = dpaa2_mac_get_if_mode(dpmac_node, attr);
+	err = dpaa2_mac_get_if_mode(dpmac_node, mac->attr);
 	if (err < 0) {
 		err = -EINVAL;
 		goto err_put_node;
@@ -351,9 +335,9 @@ int dpaa2_mac_connect(struct dpaa2_mac *mac)
 		goto err_put_node;
 	}
 
-	if (attr.link_type == DPMAC_LINK_TYPE_PHY &&
-	    attr.eth_if != DPMAC_ETH_IF_RGMII) {
-		err = dpaa2_pcs_create(mac, dpmac_node, attr.id);
+	if (mac->attr.link_type == DPMAC_LINK_TYPE_PHY &&
+	    mac->attr.eth_if != DPMAC_ETH_IF_RGMII) {
+		err = dpaa2_pcs_create(mac, dpmac_node, mac->attr.id);
 		if (err)
 			goto err_put_node;
 	}
@@ -389,8 +373,7 @@ int dpaa2_mac_connect(struct dpaa2_mac *mac)
 	dpaa2_pcs_destroy(mac);
 err_put_node:
 	of_node_put(dpmac_node);
-err_close_dpmac:
-	dpmac_close(mac->mc_io, 0, dpmac_dev->mc_handle);
+
 	return err;
 }
 
@@ -402,8 +385,39 @@ void dpaa2_mac_disconnect(struct dpaa2_mac *mac)
 	phylink_disconnect_phy(mac->phylink);
 	phylink_destroy(mac->phylink);
 	dpaa2_pcs_destroy(mac);
+}
+
+int dpaa2_mac_open(struct dpaa2_mac *mac)
+{
+	struct fsl_mc_device *dpmac_dev = mac->mc_dev;
+	struct net_device *net_dev = mac->net_dev;
+	int err;
+
+	err = dpmac_open(mac->mc_io, 0, dpmac_dev->obj_desc.id,
+			 &dpmac_dev->mc_handle);
+	if (err || !dpmac_dev->mc_handle) {
+		netdev_err(net_dev, "dpmac_open() = %d\n", err);
+		return -ENODEV;
+	}
+
+	err = dpmac_get_attributes(mac->mc_io, 0, dpmac_dev->mc_handle, &mac->attr);
+	if (err) {
+		netdev_err(net_dev, "dpmac_get_attributes() = %d\n", err);
+		goto err_close_dpmac;
+	}
+
+	return 0;
+
+err_close_dpmac:
+	dpmac_close(mac->mc_io, 0, dpmac_dev->mc_handle);
+	return err;
+}
+
+void dpaa2_mac_close(struct dpaa2_mac *mac)
+{
+	struct fsl_mc_device *dpmac_dev = mac->mc_dev;
 
-	dpmac_close(mac->mc_io, 0, mac->mc_dev->mc_handle);
+	dpmac_close(mac->mc_io, 0, dpmac_dev->mc_handle);
 }
 
 static char dpaa2_mac_ethtool_stats[][ETH_GSTRING_LEN] = {
diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.h b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.h
index 955a52856210..13d42dd58ec9 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.h
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.h
@@ -17,6 +17,7 @@ struct dpaa2_mac {
 	struct dpmac_link_state state;
 	struct net_device *net_dev;
 	struct fsl_mc_io *mc_io;
+	struct dpmac_attr attr;
 
 	struct phylink_config phylink_config;
 	struct phylink *phylink;
@@ -28,6 +29,10 @@ struct dpaa2_mac {
 bool dpaa2_mac_is_type_fixed(struct fsl_mc_device *dpmac_dev,
 			     struct fsl_mc_io *mc_io);
 
+int dpaa2_mac_open(struct dpaa2_mac *mac);
+
+void dpaa2_mac_close(struct dpaa2_mac *mac);
+
 int dpaa2_mac_connect(struct dpaa2_mac *mac);
 
 void dpaa2_mac_disconnect(struct dpaa2_mac *mac);
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 2/6] dpaa2-mac: export MAC counters even when in TYPE_FIXED
  2021-01-07 15:36 [PATCH 0/6] dpaa2-mac: various updates Ioana Ciornei
  2021-01-07 15:36 ` [PATCH 1/6] dpaa2-mac: split up initializing the MAC object from connecting to it Ioana Ciornei
@ 2021-01-07 15:36 ` Ioana Ciornei
  2021-01-07 15:36 ` [PATCH 3/6] bus: fsl-mc: return -EPROBE_DEFER when a device is not yet discovered Ioana Ciornei
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 12+ messages in thread
From: Ioana Ciornei @ 2021-01-07 15:36 UTC (permalink / raw)
  To: davem, kuba, netdev; +Cc: laurentiu.tudor, Ioana Ciornei

From: Ioana Ciornei <ioana.ciornei@nxp.com>

If the network interface object is connected to a MAC of TYPE_FIXED, the
link status management is handled exclusively by the firmware. This does
not mean that the driver cannot access the MAC counters and export them
in ethtool.

For this to happen, we open the attached dpmac device and keep a pointer
to it in priv->mac. Because of this, all the checks in the driver of the
following form 'if (priv->mac)' have to be updated to actually check
the dpmac attribute and not rely on the presence of a non-NULL value.

Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
---
 .../net/ethernet/freescale/dpaa2/dpaa2-eth.c  | 37 +++++++++----------
 .../net/ethernet/freescale/dpaa2/dpaa2-eth.h  | 13 +++++++
 .../ethernet/freescale/dpaa2/dpaa2-ethtool.c  | 16 ++++----
 .../net/ethernet/freescale/dpaa2/dpaa2-mac.c  | 26 -------------
 4 files changed, 39 insertions(+), 53 deletions(-)

diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
index 61385894e8c7..f3f53e36aa00 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
@@ -1691,7 +1691,7 @@ static int dpaa2_eth_link_state_update(struct dpaa2_eth_priv *priv)
 	/* When we manage the MAC/PHY using phylink there is no need
 	 * to manually update the netif_carrier.
 	 */
-	if (priv->mac)
+	if (dpaa2_eth_is_type_phy(priv))
 		goto out;
 
 	/* Chech link state; speed / duplex changes are not treated yet */
@@ -1730,7 +1730,7 @@ static int dpaa2_eth_open(struct net_device *net_dev)
 			   priv->dpbp_dev->obj_desc.id, priv->bpid);
 	}
 
-	if (!priv->mac) {
+	if (!dpaa2_eth_is_type_phy(priv)) {
 		/* We'll only start the txqs when the link is actually ready;
 		 * make sure we don't race against the link up notification,
 		 * which may come immediately after dpni_enable();
@@ -1752,7 +1752,7 @@ static int dpaa2_eth_open(struct net_device *net_dev)
 		goto enable_err;
 	}
 
-	if (priv->mac)
+	if (dpaa2_eth_is_type_phy(priv))
 		phylink_start(priv->mac->phylink);
 
 	return 0;
@@ -1826,11 +1826,11 @@ static int dpaa2_eth_stop(struct net_device *net_dev)
 	int dpni_enabled = 0;
 	int retries = 10;
 
-	if (!priv->mac) {
+	if (dpaa2_eth_is_type_phy(priv)) {
+		phylink_stop(priv->mac->phylink);
+	} else {
 		netif_tx_stop_all_queues(net_dev);
 		netif_carrier_off(net_dev);
-	} else {
-		phylink_stop(priv->mac->phylink);
 	}
 
 	/* On dpni_disable(), the MC firmware will:
@@ -2115,7 +2115,7 @@ static int dpaa2_eth_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
 	if (cmd == SIOCSHWTSTAMP)
 		return dpaa2_eth_ts_ioctl(dev, rq, cmd);
 
-	if (priv->mac)
+	if (dpaa2_eth_is_type_phy(priv))
 		return phylink_mii_ioctl(priv->mac->phylink, rq, cmd);
 
 	return -EOPNOTSUPP;
@@ -4045,9 +4045,6 @@ static int dpaa2_eth_connect_mac(struct dpaa2_eth_priv *priv)
 	if (IS_ERR_OR_NULL(dpmac_dev) || dpmac_dev->dev.type != &fsl_mc_bus_dpmac_type)
 		return 0;
 
-	if (dpaa2_mac_is_type_fixed(dpmac_dev, priv->mc_io))
-		return 0;
-
 	mac = kzalloc(sizeof(struct dpaa2_mac), GFP_KERNEL);
 	if (!mac)
 		return -ENOMEM;
@@ -4059,18 +4056,21 @@ static int dpaa2_eth_connect_mac(struct dpaa2_eth_priv *priv)
 	err = dpaa2_mac_open(mac);
 	if (err)
 		goto err_free_mac;
+	priv->mac = mac;
 
-	err = dpaa2_mac_connect(mac);
-	if (err) {
-		netdev_err(priv->net_dev, "Error connecting to the MAC endpoint\n");
-		goto err_close_mac;
+	if (dpaa2_eth_is_type_phy(priv)) {
+		err = dpaa2_mac_connect(mac);
+		if (err) {
+			netdev_err(priv->net_dev, "Error connecting to the MAC endpoint\n");
+			goto err_close_mac;
+		}
 	}
-	priv->mac = mac;
 
 	return 0;
 
 err_close_mac:
 	dpaa2_mac_close(mac);
+	priv->mac = NULL;
 err_free_mac:
 	kfree(mac);
 	return err;
@@ -4078,10 +4078,9 @@ static int dpaa2_eth_connect_mac(struct dpaa2_eth_priv *priv)
 
 static void dpaa2_eth_disconnect_mac(struct dpaa2_eth_priv *priv)
 {
-	if (!priv->mac)
-		return;
+	if (dpaa2_eth_is_type_phy(priv))
+		dpaa2_mac_disconnect(priv->mac);
 
-	dpaa2_mac_disconnect(priv->mac);
 	dpaa2_mac_close(priv->mac);
 	kfree(priv->mac);
 	priv->mac = NULL;
@@ -4111,7 +4110,7 @@ static irqreturn_t dpni_irq0_handler_thread(int irq_num, void *arg)
 		dpaa2_eth_update_tx_fqids(priv);
 
 		rtnl_lock();
-		if (priv->mac)
+		if (dpaa2_eth_has_mac(priv))
 			dpaa2_eth_disconnect_mac(priv);
 		else
 			dpaa2_eth_connect_mac(priv);
diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h
index d236b8695c39..c3d456c45102 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h
@@ -693,6 +693,19 @@ static inline unsigned int dpaa2_eth_rx_head_room(struct dpaa2_eth_priv *priv)
 	return priv->tx_data_offset - DPAA2_ETH_RX_HWA_SIZE;
 }
 
+static inline bool dpaa2_eth_is_type_phy(struct dpaa2_eth_priv *priv)
+{
+	if (priv->mac && priv->mac->attr.link_type == DPMAC_LINK_TYPE_PHY)
+		return true;
+
+	return false;
+}
+
+static inline bool dpaa2_eth_has_mac(struct dpaa2_eth_priv *priv)
+{
+	return priv->mac ? true : false;
+}
+
 int dpaa2_eth_set_hash(struct net_device *net_dev, u64 flags);
 int dpaa2_eth_set_cls(struct net_device *net_dev, u64 key);
 int dpaa2_eth_cls_key_size(u64 key);
diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-ethtool.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-ethtool.c
index f981a523e13a..bf59708b869e 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-ethtool.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-ethtool.c
@@ -85,7 +85,7 @@ static int dpaa2_eth_nway_reset(struct net_device *net_dev)
 {
 	struct dpaa2_eth_priv *priv = netdev_priv(net_dev);
 
-	if (priv->mac)
+	if (dpaa2_eth_is_type_phy(priv))
 		return phylink_ethtool_nway_reset(priv->mac->phylink);
 
 	return -EOPNOTSUPP;
@@ -97,7 +97,7 @@ dpaa2_eth_get_link_ksettings(struct net_device *net_dev,
 {
 	struct dpaa2_eth_priv *priv = netdev_priv(net_dev);
 
-	if (priv->mac)
+	if (dpaa2_eth_is_type_phy(priv))
 		return phylink_ethtool_ksettings_get(priv->mac->phylink,
 						     link_settings);
 
@@ -115,7 +115,7 @@ dpaa2_eth_set_link_ksettings(struct net_device *net_dev,
 {
 	struct dpaa2_eth_priv *priv = netdev_priv(net_dev);
 
-	if (!priv->mac)
+	if (!dpaa2_eth_is_type_phy(priv))
 		return -ENOTSUPP;
 
 	return phylink_ethtool_ksettings_set(priv->mac->phylink, link_settings);
@@ -127,7 +127,7 @@ static void dpaa2_eth_get_pauseparam(struct net_device *net_dev,
 	struct dpaa2_eth_priv *priv = netdev_priv(net_dev);
 	u64 link_options = priv->link_state.options;
 
-	if (priv->mac) {
+	if (dpaa2_eth_is_type_phy(priv)) {
 		phylink_ethtool_get_pauseparam(priv->mac->phylink, pause);
 		return;
 	}
@@ -150,7 +150,7 @@ static int dpaa2_eth_set_pauseparam(struct net_device *net_dev,
 		return -EOPNOTSUPP;
 	}
 
-	if (priv->mac)
+	if (dpaa2_eth_is_type_phy(priv))
 		return phylink_ethtool_set_pauseparam(priv->mac->phylink,
 						      pause);
 	if (pause->autoneg)
@@ -198,7 +198,7 @@ static void dpaa2_eth_get_strings(struct net_device *netdev, u32 stringset,
 			strlcpy(p, dpaa2_ethtool_extras[i], ETH_GSTRING_LEN);
 			p += ETH_GSTRING_LEN;
 		}
-		if (priv->mac)
+		if (dpaa2_eth_has_mac(priv))
 			dpaa2_mac_get_strings(p);
 		break;
 	}
@@ -211,7 +211,7 @@ static int dpaa2_eth_get_sset_count(struct net_device *net_dev, int sset)
 
 	switch (sset) {
 	case ETH_SS_STATS: /* ethtool_get_stats(), ethtool_get_drvinfo() */
-		if (priv->mac)
+		if (dpaa2_eth_has_mac(priv))
 			num_ss_stats += dpaa2_mac_get_sset_count();
 		return num_ss_stats;
 	default:
@@ -313,7 +313,7 @@ static void dpaa2_eth_get_ethtool_stats(struct net_device *net_dev,
 	}
 	*(data + i++) = buf_cnt;
 
-	if (priv->mac)
+	if (dpaa2_eth_has_mac(priv))
 		dpaa2_mac_get_ethtool_stats(priv->mac, data + i);
 }
 
diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
index b97a219878c0..666bc88c178f 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
@@ -228,32 +228,6 @@ static const struct phylink_mac_ops dpaa2_mac_phylink_ops = {
 	.mac_link_down = dpaa2_mac_link_down,
 };
 
-bool dpaa2_mac_is_type_fixed(struct fsl_mc_device *dpmac_dev,
-			     struct fsl_mc_io *mc_io)
-{
-	struct dpmac_attr attr;
-	bool fixed = false;
-	u16 mc_handle = 0;
-	int err;
-
-	err = dpmac_open(mc_io, 0, dpmac_dev->obj_desc.id,
-			 &mc_handle);
-	if (err || !mc_handle)
-		return false;
-
-	err = dpmac_get_attributes(mc_io, 0, mc_handle, &attr);
-	if (err)
-		goto out;
-
-	if (attr.link_type == DPMAC_LINK_TYPE_FIXED)
-		fixed = true;
-
-out:
-	dpmac_close(mc_io, 0, mc_handle);
-
-	return fixed;
-}
-
 static int dpaa2_pcs_create(struct dpaa2_mac *mac,
 			    struct device_node *dpmac_node, int id)
 {
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 3/6] bus: fsl-mc: return -EPROBE_DEFER when a device is not yet discovered
  2021-01-07 15:36 [PATCH 0/6] dpaa2-mac: various updates Ioana Ciornei
  2021-01-07 15:36 ` [PATCH 1/6] dpaa2-mac: split up initializing the MAC object from connecting to it Ioana Ciornei
  2021-01-07 15:36 ` [PATCH 2/6] dpaa2-mac: export MAC counters even when in TYPE_FIXED Ioana Ciornei
@ 2021-01-07 15:36 ` Ioana Ciornei
  2021-01-07 17:15   ` Laurentiu Tudor
  2021-01-07 15:36 ` [PATCH 4/6] dpaa2-eth: retry the probe when the MAC is not yet discovered on the bus Ioana Ciornei
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 12+ messages in thread
From: Ioana Ciornei @ 2021-01-07 15:36 UTC (permalink / raw)
  To: davem, kuba, netdev; +Cc: laurentiu.tudor, Ioana Ciornei

From: Ioana Ciornei <ioana.ciornei@nxp.com>

The fsl_mc_get_endpoint() should return a pointer to the connected
fsl_mc device, if there is one. By interrogating the MC firmware, we
know if there is an endpoint or not so when the endpoint device is
actually searched on the fsl-mc bus and not found we are hitting the
case in which the device has not been yet discovered by the bus.

Return -EPROBE_DEFER so that callers can differentiate this case.

Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
---
 drivers/bus/fsl-mc/fsl-mc-bus.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/bus/fsl-mc/fsl-mc-bus.c b/drivers/bus/fsl-mc/fsl-mc-bus.c
index 34811db074b7..28d5da1c011c 100644
--- a/drivers/bus/fsl-mc/fsl-mc-bus.c
+++ b/drivers/bus/fsl-mc/fsl-mc-bus.c
@@ -936,6 +936,15 @@ struct fsl_mc_device *fsl_mc_get_endpoint(struct fsl_mc_device *mc_dev)
 	endpoint_desc.id = endpoint2.id;
 	endpoint = fsl_mc_device_lookup(&endpoint_desc, mc_bus_dev);
 
+	/*
+	 * We know that the device has an endpoint because we verified by
+	 * interrogating the firmware. This is the case when the device was not
+	 * yet discovered by the fsl-mc bus, thus the lookup returned NULL.
+	 * Differentiate this case by returning EPROBE_DEFER.
+	 */
+	if (!endpoint)
+		return ERR_PTR(-EPROBE_DEFER);
+
 	return endpoint;
 }
 EXPORT_SYMBOL_GPL(fsl_mc_get_endpoint);
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 4/6] dpaa2-eth: retry the probe when the MAC is not yet discovered on the bus
  2021-01-07 15:36 [PATCH 0/6] dpaa2-mac: various updates Ioana Ciornei
                   ` (2 preceding siblings ...)
  2021-01-07 15:36 ` [PATCH 3/6] bus: fsl-mc: return -EPROBE_DEFER when a device is not yet discovered Ioana Ciornei
@ 2021-01-07 15:36 ` Ioana Ciornei
  2021-01-07 21:24   ` Andrew Lunn
  2021-01-07 15:36 ` [PATCH 5/6] dpaa2-mac: remove an unnecessary check Ioana Ciornei
  2021-01-07 15:36 ` [PATCH 6/6] dpaa2-mac: remove a comment regarding pause settings Ioana Ciornei
  5 siblings, 1 reply; 12+ messages in thread
From: Ioana Ciornei @ 2021-01-07 15:36 UTC (permalink / raw)
  To: davem, kuba, netdev; +Cc: laurentiu.tudor, Ioana Ciornei

From: Ioana Ciornei <ioana.ciornei@nxp.com>

The fsl_mc_get_endpoint() function now returns -EPROBE_DEFER when the
dpmac device was not yet discovered by the fsl-mc bus. When this
happens, pass the error code up so that we can retry the probe at a
later time.

Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
---
 drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
index f3f53e36aa00..3297e390476b 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
@@ -4042,6 +4042,10 @@ static int dpaa2_eth_connect_mac(struct dpaa2_eth_priv *priv)
 
 	dpni_dev = to_fsl_mc_device(priv->net_dev->dev.parent);
 	dpmac_dev = fsl_mc_get_endpoint(dpni_dev);
+
+	if (PTR_ERR(dpmac_dev) == -EPROBE_DEFER)
+		return PTR_ERR(dpmac_dev);
+
 	if (IS_ERR_OR_NULL(dpmac_dev) || dpmac_dev->dev.type != &fsl_mc_bus_dpmac_type)
 		return 0;
 
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 5/6] dpaa2-mac: remove an unnecessary check
  2021-01-07 15:36 [PATCH 0/6] dpaa2-mac: various updates Ioana Ciornei
                   ` (3 preceding siblings ...)
  2021-01-07 15:36 ` [PATCH 4/6] dpaa2-eth: retry the probe when the MAC is not yet discovered on the bus Ioana Ciornei
@ 2021-01-07 15:36 ` Ioana Ciornei
  2021-01-07 15:36 ` [PATCH 6/6] dpaa2-mac: remove a comment regarding pause settings Ioana Ciornei
  5 siblings, 0 replies; 12+ messages in thread
From: Ioana Ciornei @ 2021-01-07 15:36 UTC (permalink / raw)
  To: davem, kuba, netdev; +Cc: laurentiu.tudor, Ioana Ciornei

From: Ioana Ciornei <ioana.ciornei@nxp.com>

The dpaa2-eth driver has phylink integration only if the connected dpmac
object is in TYPE_PHY (aka the PCS/PHY etc link status is managed by
Linux instead of the firmware). The check is thus unnecessary because
the code path that reaches the .mac_link_up() callback is only with
TYPE_PHY dpmac objects.

Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
---
 .../net/ethernet/freescale/dpaa2/dpaa2-mac.c  | 43 ++++++++-----------
 1 file changed, 19 insertions(+), 24 deletions(-)

diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
index 666bc88c178f..40aa81eb3c4b 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
@@ -174,30 +174,25 @@ static void dpaa2_mac_link_up(struct phylink_config *config,
 
 	dpmac_state->up = 1;
 
-	if (mac->if_link_type == DPMAC_LINK_TYPE_PHY) {
-		/* If the DPMAC is configured for PHY mode, we need
-		 * to pass the link parameters to the MC firmware.
-		 */
-		dpmac_state->rate = speed;
-
-		if (duplex == DUPLEX_HALF)
-			dpmac_state->options |= DPMAC_LINK_OPT_HALF_DUPLEX;
-		else if (duplex == DUPLEX_FULL)
-			dpmac_state->options &= ~DPMAC_LINK_OPT_HALF_DUPLEX;
-
-		/* This is lossy; the firmware really should take the pause
-		 * enablement status rather than pause/asym pause status.
-		 */
-		if (rx_pause)
-			dpmac_state->options |= DPMAC_LINK_OPT_PAUSE;
-		else
-			dpmac_state->options &= ~DPMAC_LINK_OPT_PAUSE;
-
-		if (rx_pause ^ tx_pause)
-			dpmac_state->options |= DPMAC_LINK_OPT_ASYM_PAUSE;
-		else
-			dpmac_state->options &= ~DPMAC_LINK_OPT_ASYM_PAUSE;
-	}
+	dpmac_state->rate = speed;
+
+	if (duplex == DUPLEX_HALF)
+		dpmac_state->options |= DPMAC_LINK_OPT_HALF_DUPLEX;
+	else if (duplex == DUPLEX_FULL)
+		dpmac_state->options &= ~DPMAC_LINK_OPT_HALF_DUPLEX;
+
+	/* This is lossy; the firmware really should take the pause
+	 * enablement status rather than pause/asym pause status.
+	 */
+	if (rx_pause)
+		dpmac_state->options |= DPMAC_LINK_OPT_PAUSE;
+	else
+		dpmac_state->options &= ~DPMAC_LINK_OPT_PAUSE;
+
+	if (rx_pause ^ tx_pause)
+		dpmac_state->options |= DPMAC_LINK_OPT_ASYM_PAUSE;
+	else
+		dpmac_state->options &= ~DPMAC_LINK_OPT_ASYM_PAUSE;
 
 	err = dpmac_set_link_state(mac->mc_io, 0,
 				   mac->mc_dev->mc_handle, dpmac_state);
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 6/6] dpaa2-mac: remove a comment regarding pause settings
  2021-01-07 15:36 [PATCH 0/6] dpaa2-mac: various updates Ioana Ciornei
                   ` (4 preceding siblings ...)
  2021-01-07 15:36 ` [PATCH 5/6] dpaa2-mac: remove an unnecessary check Ioana Ciornei
@ 2021-01-07 15:36 ` Ioana Ciornei
  2021-01-07 21:26   ` Andrew Lunn
  5 siblings, 1 reply; 12+ messages in thread
From: Ioana Ciornei @ 2021-01-07 15:36 UTC (permalink / raw)
  To: davem, kuba, netdev; +Cc: laurentiu.tudor, Ioana Ciornei

From: Ioana Ciornei <ioana.ciornei@nxp.com>

The pause settings are not actually lossy since the MC firmware was does
is to transform back these pause/asym-pause flags into rx/tx pause
enablement status. We are not losing information by this transformation,
thus remove the comment.

Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
---
 drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
index 40aa81eb3c4b..f76adbe8c32b 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
@@ -181,9 +181,6 @@ static void dpaa2_mac_link_up(struct phylink_config *config,
 	else if (duplex == DUPLEX_FULL)
 		dpmac_state->options &= ~DPMAC_LINK_OPT_HALF_DUPLEX;
 
-	/* This is lossy; the firmware really should take the pause
-	 * enablement status rather than pause/asym pause status.
-	 */
 	if (rx_pause)
 		dpmac_state->options |= DPMAC_LINK_OPT_PAUSE;
 	else
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH 3/6] bus: fsl-mc: return -EPROBE_DEFER when a device is not yet discovered
  2021-01-07 15:36 ` [PATCH 3/6] bus: fsl-mc: return -EPROBE_DEFER when a device is not yet discovered Ioana Ciornei
@ 2021-01-07 17:15   ` Laurentiu Tudor
  0 siblings, 0 replies; 12+ messages in thread
From: Laurentiu Tudor @ 2021-01-07 17:15 UTC (permalink / raw)
  To: Ioana Ciornei, davem, kuba, netdev; +Cc: Ioana Ciornei


On 1/7/2021 5:36 PM, Ioana Ciornei wrote:
> From: Ioana Ciornei <ioana.ciornei@nxp.com>
> 
> The fsl_mc_get_endpoint() should return a pointer to the connected
> fsl_mc device, if there is one. By interrogating the MC firmware, we
> know if there is an endpoint or not so when the endpoint device is
> actually searched on the fsl-mc bus and not found we are hitting the
> case in which the device has not been yet discovered by the bus.
> 
> Return -EPROBE_DEFER so that callers can differentiate this case.
> 
> Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>

Acked-by: Laurentiu Tudor <laurentiu.tudor@nxp.com>

---
Best Regards, Laurentiu

> ---
>  drivers/bus/fsl-mc/fsl-mc-bus.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/drivers/bus/fsl-mc/fsl-mc-bus.c b/drivers/bus/fsl-mc/fsl-mc-bus.c
> index 34811db074b7..28d5da1c011c 100644
> --- a/drivers/bus/fsl-mc/fsl-mc-bus.c
> +++ b/drivers/bus/fsl-mc/fsl-mc-bus.c
> @@ -936,6 +936,15 @@ struct fsl_mc_device *fsl_mc_get_endpoint(struct fsl_mc_device *mc_dev)
>  	endpoint_desc.id = endpoint2.id;
>  	endpoint = fsl_mc_device_lookup(&endpoint_desc, mc_bus_dev);
>  
> +	/*
> +	 * We know that the device has an endpoint because we verified by
> +	 * interrogating the firmware. This is the case when the device was not
> +	 * yet discovered by the fsl-mc bus, thus the lookup returned NULL.
> +	 * Differentiate this case by returning EPROBE_DEFER.
> +	 */
> +	if (!endpoint)
> +		return ERR_PTR(-EPROBE_DEFER);
> +
>  	return endpoint;
>  }
>  EXPORT_SYMBOL_GPL(fsl_mc_get_endpoint);
> 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 4/6] dpaa2-eth: retry the probe when the MAC is not yet discovered on the bus
  2021-01-07 15:36 ` [PATCH 4/6] dpaa2-eth: retry the probe when the MAC is not yet discovered on the bus Ioana Ciornei
@ 2021-01-07 21:24   ` Andrew Lunn
  2021-01-07 21:33     ` Ioana Ciornei
  0 siblings, 1 reply; 12+ messages in thread
From: Andrew Lunn @ 2021-01-07 21:24 UTC (permalink / raw)
  To: Ioana Ciornei; +Cc: davem, kuba, netdev, laurentiu.tudor, Ioana Ciornei

On Thu, Jan 07, 2021 at 05:36:36PM +0200, Ioana Ciornei wrote:
> From: Ioana Ciornei <ioana.ciornei@nxp.com>
> 
> The fsl_mc_get_endpoint() function now returns -EPROBE_DEFER when the
> dpmac device was not yet discovered by the fsl-mc bus. When this
> happens, pass the error code up so that we can retry the probe at a
> later time.
> 
> Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
> ---
>  drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
> index f3f53e36aa00..3297e390476b 100644
> --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
> +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
> @@ -4042,6 +4042,10 @@ static int dpaa2_eth_connect_mac(struct dpaa2_eth_priv *priv)
>  
>  	dpni_dev = to_fsl_mc_device(priv->net_dev->dev.parent);
>  	dpmac_dev = fsl_mc_get_endpoint(dpni_dev);
> +
> +	if (PTR_ERR(dpmac_dev) == -EPROBE_DEFER)
> +		return PTR_ERR(dpmac_dev);
> +
>  	if (IS_ERR_OR_NULL(dpmac_dev) || dpmac_dev->dev.type != &fsl_mc_bus_dpmac_type)

Hi Ioana

Given the previous change, i don't think dpmac_dev can be NULL, so you
can change this to IS_ERR(). IS_ERR_OR_NULL() often triggers extra
review work because it is easy to get it wrong, so removing it is nice.

       Andrew

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 6/6] dpaa2-mac: remove a comment regarding pause settings
  2021-01-07 15:36 ` [PATCH 6/6] dpaa2-mac: remove a comment regarding pause settings Ioana Ciornei
@ 2021-01-07 21:26   ` Andrew Lunn
  2021-01-07 21:37     ` Ioana Ciornei
  0 siblings, 1 reply; 12+ messages in thread
From: Andrew Lunn @ 2021-01-07 21:26 UTC (permalink / raw)
  To: Ioana Ciornei; +Cc: davem, kuba, netdev, laurentiu.tudor, Ioana Ciornei

On Thu, Jan 07, 2021 at 05:36:38PM +0200, Ioana Ciornei wrote:
> From: Ioana Ciornei <ioana.ciornei@nxp.com>
> 
> The pause settings are not actually lossy since the MC firmware was does
> is

was does is?

    Andrew

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 4/6] dpaa2-eth: retry the probe when the MAC is not yet discovered on the bus
  2021-01-07 21:24   ` Andrew Lunn
@ 2021-01-07 21:33     ` Ioana Ciornei
  0 siblings, 0 replies; 12+ messages in thread
From: Ioana Ciornei @ 2021-01-07 21:33 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: Ioana Ciornei, davem, kuba, netdev, laurentiu.tudor, Ioana Ciornei

On Thu, Jan 07, 2021 at 10:24:38PM +0100, Andrew Lunn wrote:
> On Thu, Jan 07, 2021 at 05:36:36PM +0200, Ioana Ciornei wrote:
> > From: Ioana Ciornei <ioana.ciornei@nxp.com>
> > 
> > The fsl_mc_get_endpoint() function now returns -EPROBE_DEFER when the
> > dpmac device was not yet discovered by the fsl-mc bus. When this
> > happens, pass the error code up so that we can retry the probe at a
> > later time.
> > 
> > Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
> > ---
> >  drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c | 4 ++++
> >  1 file changed, 4 insertions(+)
> > 
> > diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
> > index f3f53e36aa00..3297e390476b 100644
> > --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
> > +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
> > @@ -4042,6 +4042,10 @@ static int dpaa2_eth_connect_mac(struct dpaa2_eth_priv *priv)
> >  
> >  	dpni_dev = to_fsl_mc_device(priv->net_dev->dev.parent);
> >  	dpmac_dev = fsl_mc_get_endpoint(dpni_dev);
> > +
> > +	if (PTR_ERR(dpmac_dev) == -EPROBE_DEFER)
> > +		return PTR_ERR(dpmac_dev);
> > +
> >  	if (IS_ERR_OR_NULL(dpmac_dev) || dpmac_dev->dev.type != &fsl_mc_bus_dpmac_type)
> 
> Hi Ioana
> 
> Given the previous change, i don't think dpmac_dev can be NULL, so you
> can change this to IS_ERR(). IS_ERR_OR_NULL() often triggers extra
> review work because it is easy to get it wrong, so removing it is nice.
> 

Indeed, fsl_mc_get_endpoint() does no longer return NULL.
I'll change it to IS_ERR() in v2.

Thanks!

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 6/6] dpaa2-mac: remove a comment regarding pause settings
  2021-01-07 21:26   ` Andrew Lunn
@ 2021-01-07 21:37     ` Ioana Ciornei
  0 siblings, 0 replies; 12+ messages in thread
From: Ioana Ciornei @ 2021-01-07 21:37 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: Ioana Ciornei, davem, kuba, netdev, laurentiu.tudor, Ioana Ciornei

On Thu, Jan 07, 2021 at 10:26:28PM +0100, Andrew Lunn wrote:
> On Thu, Jan 07, 2021 at 05:36:38PM +0200, Ioana Ciornei wrote:
> > From: Ioana Ciornei <ioana.ciornei@nxp.com>
> > 
> > The pause settings are not actually lossy since the MC firmware was does
> > is
> 
> was does is?
> 

It was supposed to be 'what does is'...

Even so, I'll reword it.

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2021-01-07 21:38 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-07 15:36 [PATCH 0/6] dpaa2-mac: various updates Ioana Ciornei
2021-01-07 15:36 ` [PATCH 1/6] dpaa2-mac: split up initializing the MAC object from connecting to it Ioana Ciornei
2021-01-07 15:36 ` [PATCH 2/6] dpaa2-mac: export MAC counters even when in TYPE_FIXED Ioana Ciornei
2021-01-07 15:36 ` [PATCH 3/6] bus: fsl-mc: return -EPROBE_DEFER when a device is not yet discovered Ioana Ciornei
2021-01-07 17:15   ` Laurentiu Tudor
2021-01-07 15:36 ` [PATCH 4/6] dpaa2-eth: retry the probe when the MAC is not yet discovered on the bus Ioana Ciornei
2021-01-07 21:24   ` Andrew Lunn
2021-01-07 21:33     ` Ioana Ciornei
2021-01-07 15:36 ` [PATCH 5/6] dpaa2-mac: remove an unnecessary check Ioana Ciornei
2021-01-07 15:36 ` [PATCH 6/6] dpaa2-mac: remove a comment regarding pause settings Ioana Ciornei
2021-01-07 21:26   ` Andrew Lunn
2021-01-07 21:37     ` Ioana Ciornei

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).