Skip to content

Commit 430cc48

Browse files
committed
Merge branch 'dpaa2-mac-various-updates'
Ioana Ciornei says: ==================== dpaa2-mac: various updates 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. Changes in v2: - replaced IS_ERR_OR_NULL() by IS_ERR() in patch 4/6 - reworded the commit message of patch 6/6 ==================== Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents 38f7b44 + 1400208 commit 430cc48

File tree

6 files changed

+126
-105
lines changed

6 files changed

+126
-105
lines changed

drivers/bus/fsl-mc/fsl-mc-bus.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,15 @@ struct fsl_mc_device *fsl_mc_get_endpoint(struct fsl_mc_device *mc_dev)
840840
endpoint_desc.id = endpoint2.id;
841841
endpoint = fsl_mc_device_lookup(&endpoint_desc, mc_bus_dev);
842842

843+
/*
844+
* We know that the device has an endpoint because we verified by
845+
* interrogating the firmware. This is the case when the device was not
846+
* yet discovered by the fsl-mc bus, thus the lookup returned NULL.
847+
* Differentiate this case by returning EPROBE_DEFER.
848+
*/
849+
if (!endpoint)
850+
return ERR_PTR(-EPROBE_DEFER);
851+
843852
return endpoint;
844853
}
845854
EXPORT_SYMBOL_GPL(fsl_mc_get_endpoint);

drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1691,7 +1691,7 @@ static int dpaa2_eth_link_state_update(struct dpaa2_eth_priv *priv)
16911691
/* When we manage the MAC/PHY using phylink there is no need
16921692
* to manually update the netif_carrier.
16931693
*/
1694-
if (priv->mac)
1694+
if (dpaa2_eth_is_type_phy(priv))
16951695
goto out;
16961696

16971697
/* Chech link state; speed / duplex changes are not treated yet */
@@ -1730,7 +1730,7 @@ static int dpaa2_eth_open(struct net_device *net_dev)
17301730
priv->dpbp_dev->obj_desc.id, priv->bpid);
17311731
}
17321732

1733-
if (!priv->mac) {
1733+
if (!dpaa2_eth_is_type_phy(priv)) {
17341734
/* We'll only start the txqs when the link is actually ready;
17351735
* make sure we don't race against the link up notification,
17361736
* which may come immediately after dpni_enable();
@@ -1752,7 +1752,7 @@ static int dpaa2_eth_open(struct net_device *net_dev)
17521752
goto enable_err;
17531753
}
17541754

1755-
if (priv->mac)
1755+
if (dpaa2_eth_is_type_phy(priv))
17561756
phylink_start(priv->mac->phylink);
17571757

17581758
return 0;
@@ -1826,11 +1826,11 @@ static int dpaa2_eth_stop(struct net_device *net_dev)
18261826
int dpni_enabled = 0;
18271827
int retries = 10;
18281828

1829-
if (!priv->mac) {
1829+
if (dpaa2_eth_is_type_phy(priv)) {
1830+
phylink_stop(priv->mac->phylink);
1831+
} else {
18301832
netif_tx_stop_all_queues(net_dev);
18311833
netif_carrier_off(net_dev);
1832-
} else {
1833-
phylink_stop(priv->mac->phylink);
18341834
}
18351835

18361836
/* 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)
21152115
if (cmd == SIOCSHWTSTAMP)
21162116
return dpaa2_eth_ts_ioctl(dev, rq, cmd);
21172117

2118-
if (priv->mac)
2118+
if (dpaa2_eth_is_type_phy(priv))
21192119
return phylink_mii_ioctl(priv->mac->phylink, rq, cmd);
21202120

21212121
return -EOPNOTSUPP;
@@ -4042,10 +4042,11 @@ static int dpaa2_eth_connect_mac(struct dpaa2_eth_priv *priv)
40424042

40434043
dpni_dev = to_fsl_mc_device(priv->net_dev->dev.parent);
40444044
dpmac_dev = fsl_mc_get_endpoint(dpni_dev);
4045-
if (IS_ERR_OR_NULL(dpmac_dev) || dpmac_dev->dev.type != &fsl_mc_bus_dpmac_type)
4046-
return 0;
40474045

4048-
if (dpaa2_mac_is_type_fixed(dpmac_dev, priv->mc_io))
4046+
if (PTR_ERR(dpmac_dev) == -EPROBE_DEFER)
4047+
return PTR_ERR(dpmac_dev);
4048+
4049+
if (IS_ERR(dpmac_dev) || dpmac_dev->dev.type != &fsl_mc_bus_dpmac_type)
40494050
return 0;
40504051

40514052
mac = kzalloc(sizeof(struct dpaa2_mac), GFP_KERNEL);
@@ -4056,23 +4057,35 @@ static int dpaa2_eth_connect_mac(struct dpaa2_eth_priv *priv)
40564057
mac->mc_io = priv->mc_io;
40574058
mac->net_dev = priv->net_dev;
40584059

4059-
err = dpaa2_mac_connect(mac);
4060-
if (err) {
4061-
netdev_err(priv->net_dev, "Error connecting to the MAC endpoint\n");
4062-
kfree(mac);
4063-
return err;
4064-
}
4060+
err = dpaa2_mac_open(mac);
4061+
if (err)
4062+
goto err_free_mac;
40654063
priv->mac = mac;
40664064

4065+
if (dpaa2_eth_is_type_phy(priv)) {
4066+
err = dpaa2_mac_connect(mac);
4067+
if (err) {
4068+
netdev_err(priv->net_dev, "Error connecting to the MAC endpoint\n");
4069+
goto err_close_mac;
4070+
}
4071+
}
4072+
40674073
return 0;
4074+
4075+
err_close_mac:
4076+
dpaa2_mac_close(mac);
4077+
priv->mac = NULL;
4078+
err_free_mac:
4079+
kfree(mac);
4080+
return err;
40684081
}
40694082

40704083
static void dpaa2_eth_disconnect_mac(struct dpaa2_eth_priv *priv)
40714084
{
4072-
if (!priv->mac)
4073-
return;
4085+
if (dpaa2_eth_is_type_phy(priv))
4086+
dpaa2_mac_disconnect(priv->mac);
40744087

4075-
dpaa2_mac_disconnect(priv->mac);
4088+
dpaa2_mac_close(priv->mac);
40764089
kfree(priv->mac);
40774090
priv->mac = NULL;
40784091
}
@@ -4101,7 +4114,7 @@ static irqreturn_t dpni_irq0_handler_thread(int irq_num, void *arg)
41014114
dpaa2_eth_update_tx_fqids(priv);
41024115

41034116
rtnl_lock();
4104-
if (priv->mac)
4117+
if (dpaa2_eth_has_mac(priv))
41054118
dpaa2_eth_disconnect_mac(priv);
41064119
else
41074120
dpaa2_eth_connect_mac(priv);

drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,19 @@ static inline unsigned int dpaa2_eth_rx_head_room(struct dpaa2_eth_priv *priv)
693693
return priv->tx_data_offset - DPAA2_ETH_RX_HWA_SIZE;
694694
}
695695

696+
static inline bool dpaa2_eth_is_type_phy(struct dpaa2_eth_priv *priv)
697+
{
698+
if (priv->mac && priv->mac->attr.link_type == DPMAC_LINK_TYPE_PHY)
699+
return true;
700+
701+
return false;
702+
}
703+
704+
static inline bool dpaa2_eth_has_mac(struct dpaa2_eth_priv *priv)
705+
{
706+
return priv->mac ? true : false;
707+
}
708+
696709
int dpaa2_eth_set_hash(struct net_device *net_dev, u64 flags);
697710
int dpaa2_eth_set_cls(struct net_device *net_dev, u64 key);
698711
int dpaa2_eth_cls_key_size(u64 key);

drivers/net/ethernet/freescale/dpaa2/dpaa2-ethtool.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ static int dpaa2_eth_nway_reset(struct net_device *net_dev)
8585
{
8686
struct dpaa2_eth_priv *priv = netdev_priv(net_dev);
8787

88-
if (priv->mac)
88+
if (dpaa2_eth_is_type_phy(priv))
8989
return phylink_ethtool_nway_reset(priv->mac->phylink);
9090

9191
return -EOPNOTSUPP;
@@ -97,7 +97,7 @@ dpaa2_eth_get_link_ksettings(struct net_device *net_dev,
9797
{
9898
struct dpaa2_eth_priv *priv = netdev_priv(net_dev);
9999

100-
if (priv->mac)
100+
if (dpaa2_eth_is_type_phy(priv))
101101
return phylink_ethtool_ksettings_get(priv->mac->phylink,
102102
link_settings);
103103

@@ -115,7 +115,7 @@ dpaa2_eth_set_link_ksettings(struct net_device *net_dev,
115115
{
116116
struct dpaa2_eth_priv *priv = netdev_priv(net_dev);
117117

118-
if (!priv->mac)
118+
if (!dpaa2_eth_is_type_phy(priv))
119119
return -ENOTSUPP;
120120

121121
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,
127127
struct dpaa2_eth_priv *priv = netdev_priv(net_dev);
128128
u64 link_options = priv->link_state.options;
129129

130-
if (priv->mac) {
130+
if (dpaa2_eth_is_type_phy(priv)) {
131131
phylink_ethtool_get_pauseparam(priv->mac->phylink, pause);
132132
return;
133133
}
@@ -150,7 +150,7 @@ static int dpaa2_eth_set_pauseparam(struct net_device *net_dev,
150150
return -EOPNOTSUPP;
151151
}
152152

153-
if (priv->mac)
153+
if (dpaa2_eth_is_type_phy(priv))
154154
return phylink_ethtool_set_pauseparam(priv->mac->phylink,
155155
pause);
156156
if (pause->autoneg)
@@ -198,7 +198,7 @@ static void dpaa2_eth_get_strings(struct net_device *netdev, u32 stringset,
198198
strlcpy(p, dpaa2_ethtool_extras[i], ETH_GSTRING_LEN);
199199
p += ETH_GSTRING_LEN;
200200
}
201-
if (priv->mac)
201+
if (dpaa2_eth_has_mac(priv))
202202
dpaa2_mac_get_strings(p);
203203
break;
204204
}
@@ -211,7 +211,7 @@ static int dpaa2_eth_get_sset_count(struct net_device *net_dev, int sset)
211211

212212
switch (sset) {
213213
case ETH_SS_STATS: /* ethtool_get_stats(), ethtool_get_drvinfo() */
214-
if (priv->mac)
214+
if (dpaa2_eth_has_mac(priv))
215215
num_ss_stats += dpaa2_mac_get_sset_count();
216216
return num_ss_stats;
217217
default:
@@ -313,7 +313,7 @@ static void dpaa2_eth_get_ethtool_stats(struct net_device *net_dev,
313313
}
314314
*(data + i++) = buf_cnt;
315315

316-
if (priv->mac)
316+
if (dpaa2_eth_has_mac(priv))
317317
dpaa2_mac_get_ethtool_stats(priv->mac, data + i);
318318
}
319319

0 commit comments

Comments
 (0)