501eaf42ff33dd9d1377bab20206b44aa0a8e8d5
[openwrt/staging/blogic.git] /
1 From 022a11062261dc4703da846d3bf4d194ef6bebf5 Mon Sep 17 00:00:00 2001
2 From: Vladimir Oltean <vladimir.oltean@nxp.com>
3 Date: Tue, 29 Nov 2022 16:12:11 +0200
4 Subject: [PATCH 04/14] net: dpaa2: replace dpaa2_mac_is_type_fixed() with
5 dpaa2_mac_is_type_phy()
6
7 dpaa2_mac_is_type_fixed() is a header with no implementation and no
8 callers, which is referenced from the documentation though. It can be
9 deleted.
10
11 On the other hand, it would be useful to reuse the code between
12 dpaa2_eth_is_type_phy() and dpaa2_switch_port_is_type_phy(). That common
13 code should be called dpaa2_mac_is_type_phy(), so let's create that.
14
15 The removal and the addition are merged into the same patch because,
16 in fact, is_type_phy() is the logical opposite of is_type_fixed().
17
18 Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
19 Reviewed-by: Andrew Lunn <andrew@lunn.ch>
20 Reviewed-by: Ioana Ciornei <ioana.ciornei@nxp.com>
21 Tested-by: Ioana Ciornei <ioana.ciornei@nxp.com>
22 Signed-off-by: Paolo Abeni <pabeni@redhat.com>
23 ---
24 .../ethernet/freescale/dpaa2/mac-phy-support.rst | 9 ++++++---
25 drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h | 7 +------
26 drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.h | 10 ++++++++--
27 drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.h | 7 +------
28 4 files changed, 16 insertions(+), 17 deletions(-)
29
30 --- a/Documentation/networking/device_drivers/ethernet/freescale/dpaa2/mac-phy-support.rst
31 +++ b/Documentation/networking/device_drivers/ethernet/freescale/dpaa2/mac-phy-support.rst
32 @@ -181,10 +181,13 @@ when necessary using the below listed AP
33 - int dpaa2_mac_connect(struct dpaa2_mac *mac);
34 - void dpaa2_mac_disconnect(struct dpaa2_mac *mac);
35
36 -A phylink integration is necessary only when the partner DPMAC is not of TYPE_FIXED.
37 -One can check for this condition using the below API::
38 +A phylink integration is necessary only when the partner DPMAC is not of
39 +``TYPE_FIXED``. This means it is either of ``TYPE_PHY``, or of
40 +``TYPE_BACKPLANE`` (the difference being the two that in the ``TYPE_BACKPLANE``
41 +mode, the MC firmware does not access the PCS registers). One can check for
42 +this condition using the following helper::
43
44 - - bool dpaa2_mac_is_type_fixed(struct fsl_mc_device *dpmac_dev,struct fsl_mc_io *mc_io);
45 + - static inline bool dpaa2_mac_is_type_phy(struct dpaa2_mac *mac);
46
47 Before connection to a MAC, the caller must allocate and populate the
48 dpaa2_mac structure with the associated net_device, a pointer to the MC portal
49 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h
50 +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h
51 @@ -733,12 +733,7 @@ static inline unsigned int dpaa2_eth_rx_
52
53 static inline bool dpaa2_eth_is_type_phy(struct dpaa2_eth_priv *priv)
54 {
55 - if (priv->mac &&
56 - (priv->mac->attr.link_type == DPMAC_LINK_TYPE_PHY ||
57 - priv->mac->attr.link_type == DPMAC_LINK_TYPE_BACKPLANE))
58 - return true;
59 -
60 - return false;
61 + return dpaa2_mac_is_type_phy(priv->mac);
62 }
63
64 static inline bool dpaa2_eth_has_mac(struct dpaa2_eth_priv *priv)
65 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.h
66 +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.h
67 @@ -30,8 +30,14 @@ struct dpaa2_mac {
68 struct phy *serdes_phy;
69 };
70
71 -bool dpaa2_mac_is_type_fixed(struct fsl_mc_device *dpmac_dev,
72 - struct fsl_mc_io *mc_io);
73 +static inline bool dpaa2_mac_is_type_phy(struct dpaa2_mac *mac)
74 +{
75 + if (!mac)
76 + return false;
77 +
78 + return mac->attr.link_type == DPMAC_LINK_TYPE_PHY ||
79 + mac->attr.link_type == DPMAC_LINK_TYPE_BACKPLANE;
80 +}
81
82 int dpaa2_mac_open(struct dpaa2_mac *mac);
83
84 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.h
85 +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.h
86 @@ -230,12 +230,7 @@ static inline bool dpaa2_switch_supports
87 static inline bool
88 dpaa2_switch_port_is_type_phy(struct ethsw_port_priv *port_priv)
89 {
90 - if (port_priv->mac &&
91 - (port_priv->mac->attr.link_type == DPMAC_LINK_TYPE_PHY ||
92 - port_priv->mac->attr.link_type == DPMAC_LINK_TYPE_BACKPLANE))
93 - return true;
94 -
95 - return false;
96 + return dpaa2_mac_is_type_phy(port_priv->mac);
97 }
98
99 static inline bool dpaa2_switch_port_has_mac(struct ethsw_port_priv *port_priv)