From: Ioana Ciornei <ioana.ciornei@nxp.com>
To: davem@davemloft.net, kuba@kernel.org, netdev@vger.kernel.org
Cc: kishon@ti.com, vkoul@kernel.org, robh+dt@kernel.org,
leoyang.li@nxp.com, linux-phy@lists.infradead.org,
devicetree@vger.kernel.org, linux@armlinux.org.uk,
shawnguo@kernel.org, hongxing.zhu@nxp.com,
Ioana Ciornei <ioana.ciornei@nxp.com>
Subject: [PATCH net-next v3 5/8] dpaa2-mac: retrieve API version and detect features
Date: Thu, 10 Mar 2022 16:51:57 +0200 [thread overview]
Message-ID: <20220310145200.3645763-6-ioana.ciornei@nxp.com> (raw)
In-Reply-To: <20220310145200.3645763-1-ioana.ciornei@nxp.com>
Retrieve the API version running on the firmware and based on it detect
which features are available for usage.
The first one to be listed is the capability to change the MAC protocol
at runtime.
Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
---
Changes in v2:
- none
Changes in v3:
- none
.../net/ethernet/freescale/dpaa2/dpaa2-mac.c | 30 +++++++++++++++++++
.../net/ethernet/freescale/dpaa2/dpaa2-mac.h | 2 ++
2 files changed, 32 insertions(+)
diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
index 521f036d1c00..c4a49bf10156 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
@@ -11,6 +11,28 @@
#define phylink_to_dpaa2_mac(config) \
container_of((config), struct dpaa2_mac, phylink_config)
+#define DPMAC_PROTOCOL_CHANGE_VER_MAJOR 4
+#define DPMAC_PROTOCOL_CHANGE_VER_MINOR 8
+
+#define DPAA2_MAC_FEATURE_PROTOCOL_CHANGE BIT(0)
+
+static int dpaa2_mac_cmp_ver(struct dpaa2_mac *mac,
+ u16 ver_major, u16 ver_minor)
+{
+ if (mac->ver_major == ver_major)
+ return mac->ver_minor - ver_minor;
+ return mac->ver_major - ver_major;
+}
+
+static void dpaa2_mac_detect_features(struct dpaa2_mac *mac)
+{
+ mac->features = 0;
+
+ if (dpaa2_mac_cmp_ver(mac, DPMAC_PROTOCOL_CHANGE_VER_MAJOR,
+ DPMAC_PROTOCOL_CHANGE_VER_MINOR) >= 0)
+ mac->features |= DPAA2_MAC_FEATURE_PROTOCOL_CHANGE;
+}
+
static int phy_mode(enum dpmac_eth_if eth_if, phy_interface_t *if_mode)
{
*if_mode = PHY_INTERFACE_MODE_NA;
@@ -359,6 +381,14 @@ int dpaa2_mac_open(struct dpaa2_mac *mac)
goto err_close_dpmac;
}
+ err = dpmac_get_api_version(mac->mc_io, 0, &mac->ver_major, &mac->ver_minor);
+ if (err) {
+ netdev_err(net_dev, "dpmac_get_api_version() = %d\n", err);
+ goto err_close_dpmac;
+ }
+
+ dpaa2_mac_detect_features(mac);
+
/* Find the device node representing the MAC device and link the device
* behind the associated netdev to it.
*/
diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.h b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.h
index 1331a8477fe4..d2e51d21c80c 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.h
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.h
@@ -17,6 +17,8 @@ struct dpaa2_mac {
struct net_device *net_dev;
struct fsl_mc_io *mc_io;
struct dpmac_attr attr;
+ u16 ver_major, ver_minor;
+ unsigned long features;
struct phylink_config phylink_config;
struct phylink *phylink;
--
2.33.1
next prev parent reply other threads:[~2022-03-10 15:00 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-10 14:51 [PATCH net-next v3 0/8] dpaa2-mac: add support for changing the protocol at runtime Ioana Ciornei
2022-03-10 14:51 ` [PATCH net-next v3 1/8] phy: add support for the Layerscape SerDes 28G Ioana Ciornei
2022-03-10 14:51 ` [PATCH net-next v3 2/8] dt-bindings: phy: add the "fsl,lynx-28g" compatible Ioana Ciornei
2022-03-10 16:47 ` Krzysztof Kozlowski
2022-03-10 17:32 ` Ioana Ciornei
2022-03-10 21:19 ` Krzysztof Kozlowski
2022-03-10 17:58 ` Russell King (Oracle)
2022-03-10 19:06 ` Ioana Ciornei
2022-03-10 14:51 ` [PATCH net-next v3 3/8] dpaa2-mac: add the MC API for retrieving the version Ioana Ciornei
2022-03-10 14:51 ` [PATCH net-next v3 4/8] dpaa2-mac: add the MC API for reconfiguring the protocol Ioana Ciornei
2022-03-10 14:51 ` Ioana Ciornei [this message]
2022-03-10 14:51 ` [PATCH net-next v3 6/8] dpaa2-mac: move setting up supported_interfaces into a function Ioana Ciornei
2022-03-10 14:51 ` [PATCH net-next v3 7/8] dpaa2-mac: configure the SerDes phy on a protocol change Ioana Ciornei
2022-03-10 15:05 ` Russell King (Oracle)
2022-03-10 15:57 ` Ioana Ciornei
2022-03-10 14:52 ` [PATCH net-next v3 8/8] arch: arm64: dts: lx2160a: describe the SerDes block #1 Ioana Ciornei
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=20220310145200.3645763-6-ioana.ciornei@nxp.com \
--to=ioana.ciornei@nxp.com \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=hongxing.zhu@nxp.com \
--cc=kishon@ti.com \
--cc=kuba@kernel.org \
--cc=leoyang.li@nxp.com \
--cc=linux-phy@lists.infradead.org \
--cc=linux@armlinux.org.uk \
--cc=netdev@vger.kernel.org \
--cc=robh+dt@kernel.org \
--cc=shawnguo@kernel.org \
--cc=vkoul@kernel.org \
/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).