From: Wei Fang <wei.fang@nxp.com>
To: claudiu.manoil@nxp.com, vladimir.oltean@nxp.com,
xiaoning.wang@nxp.com, andrew+netdev@lunn.ch,
davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com
Cc: imx@lists.linux.dev, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH net-next 08/15] net: enetc: add VF-PF messaging support for IP minor revision query
Date: Mon, 11 May 2026 16:07:58 +0800 [thread overview]
Message-ID: <20260511080805.2052495-9-wei.fang@nxp.com> (raw)
In-Reply-To: <20260511080805.2052495-1-wei.fang@nxp.com>
For ENETC v4, different SoCs use different minor revisions, such as
i.MX95 v4.1, i.MX94 v4.3, and i.MX952 v4.6. Unlike the PF, the VF does
not have access to a global register that exposes the IP minor revision.
In the current driver model, the VF must select the appropriate driver
data based on this revision information.
To support this requirement, the VF now sends a minor revision query
message to the PF through the VSI-to-PSI mailbox mechanism. The PF
responds with the IP minor revision so that the VF can match the correct
driver data.
This patch adds PF-side support for replying to the minor revision
message and VF-side support for sending the query.
Signed-off-by: Wei Fang <wei.fang@nxp.com>
---
.../ethernet/freescale/enetc/enetc_mailbox.h | 28 ++++++++++-
.../net/ethernet/freescale/enetc/enetc_msg.c | 29 ++++++++++++
.../net/ethernet/freescale/enetc/enetc_vf.c | 47 ++++++++++++++++++-
3 files changed, 101 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/freescale/enetc/enetc_mailbox.h b/drivers/net/ethernet/freescale/enetc/enetc_mailbox.h
index 260c7333d93a..294185b54147 100644
--- a/drivers/net/ethernet/freescale/enetc/enetc_mailbox.h
+++ b/drivers/net/ethernet/freescale/enetc/enetc_mailbox.h
@@ -65,6 +65,9 @@
* (blocking requests), and
* 2) PSI_TX_control: PSIMSGSR[MC] - for PSI to VSI notification messages
* (async mode)
+ *
+ * Note that for some GET messages, there is no COOKIE field, and the CLASS
+ * CODE field is expanded to 8 bits.
*/
#ifndef __ENETC_MAILBOX_H
@@ -93,12 +96,17 @@ enum enetc_msg_class_id {
/* Common Class ID for PSI-to-VSI and VSI-to-PSI messages */
ENETC_MSG_CLASS_ID_MAC_FILTER = 0x20,
+ ENETC_MSG_CLASS_ID_IP_REVISION = 0xf0,
};
enum enetc_msg_mac_filter_cmd_id {
ENETC_MSG_SET_PRIMARY_MAC,
};
+enum enetc_msg_ip_revision_cmd_id {
+ ENETC_MSG_GET_IP_MN = 1,
+};
+
/* Class-specific error return codes of MAC filter */
enum enetc_mac_filter_class_code {
ENETC_MF_CLASS_CODE_INVALID_MAC,
@@ -108,13 +116,20 @@ struct enetc_msg_swbd {
void *vaddr;
dma_addr_t dma;
int size;
+ u8 class_code; /* save return code from PSI for 'get' messages */
};
/* The PSI-tO-VSI message format, only a 16-bits code */
union enetc_pf_msg {
struct {
- u8 cookie:4;
- u8 class_code:4;
+ union {
+ struct {
+ u8 cookie:4;
+ u8 class_code:4;
+ };
+ /* some messages class_code is 8-bit without cookie */
+ u8 class_code_u8;
+ };
u8 class_id;
};
u16 code;
@@ -150,4 +165,13 @@ struct enetc_msg_mac_exact_filter {
struct enetc_mac_addr mac[];
};
+/* The generic message format applies to the following messages:
+ * Get IP revision message, class_id 0xf0.
+ * cmd_id 1: get IP minor revision
+ */
+struct enetc_msg_generic {
+ struct enetc_msg_header hdr;
+ u8 resv[16];
+};
+
#endif
diff --git a/drivers/net/ethernet/freescale/enetc/enetc_msg.c b/drivers/net/ethernet/freescale/enetc/enetc_msg.c
index 1384752efa7b..f3e78865617e 100644
--- a/drivers/net/ethernet/freescale/enetc/enetc_msg.c
+++ b/drivers/net/ethernet/freescale/enetc/enetc_msg.c
@@ -87,6 +87,20 @@ static void enetc_msg_handle_mac_filter(struct enetc_msg_header *msg_hdr,
}
}
+static void enetc_msg_handle_ip_revision(struct enetc_msg_header *msg_hdr,
+ struct enetc_pf *pf,
+ union enetc_pf_msg *pf_msg)
+{
+ switch (msg_hdr->cmd_id) {
+ case ENETC_MSG_GET_IP_MN:
+ pf_msg->class_id = ENETC_MSG_CLASS_ID_IP_REVISION;
+ pf_msg->class_code_u8 = pf->si->revision & 0xff;
+ break;
+ default:
+ pf_msg->class_id = ENETC_MSG_CLASS_ID_CMD_NOT_SUPPORT;
+ }
+}
+
static void enetc_msg_handle_rxmsg(struct enetc_pf *pf, int vf_id,
union enetc_pf_msg *pf_msg)
{
@@ -121,10 +135,25 @@ static void enetc_msg_handle_rxmsg(struct enetc_pf *pf, int vf_id,
return;
}
+ /* The new messages are currently only supported on ENETC v4. If v1
+ * requires them, the current restriction can be lifted.
+ */
+ if (is_enetc_rev1(pf->si) &&
+ !(msg_hdr->class_id == ENETC_MSG_CLASS_ID_MAC_FILTER &&
+ msg_hdr->cmd_id == ENETC_MSG_SET_PRIMARY_MAC)) {
+ dev_err(dev, "Unsupported messages for ENETC v1\n");
+ pf_msg->class_id = ENETC_MSG_CLASS_ID_CMD_NOT_SUPPORT;
+
+ return;
+ }
+
switch (msg_hdr->class_id) {
case ENETC_MSG_CLASS_ID_MAC_FILTER:
enetc_msg_handle_mac_filter(msg_hdr, pf, vf_id, pf_msg);
break;
+ case ENETC_MSG_CLASS_ID_IP_REVISION:
+ enetc_msg_handle_ip_revision(msg_hdr, pf, pf_msg);
+ break;
default:
pf_msg->class_id = ENETC_MSG_CLASS_ID_CMD_NOT_SUPPORT;
}
diff --git a/drivers/net/ethernet/freescale/enetc/enetc_vf.c b/drivers/net/ethernet/freescale/enetc/enetc_vf.c
index 31ca08e679b8..d17ab5b2306d 100644
--- a/drivers/net/ethernet/freescale/enetc/enetc_vf.c
+++ b/drivers/net/ethernet/freescale/enetc/enetc_vf.c
@@ -106,6 +106,9 @@ static int enetc_msg_vsi_send(struct enetc_si *si, struct enetc_msg_swbd *msg)
case ENETC_MSG_CLASS_ID_MAC_FILTER:
err = -EINVAL;
break;
+ case ENETC_MSG_CLASS_ID_IP_REVISION:
+ msg->class_code = pf_msg.class_code_u8;
+ break;
default:
err = -EIO;
}
@@ -141,6 +144,27 @@ static int enetc_msg_vsi_set_primary_mac_addr(struct enetc_ndev_priv *priv,
return enetc_msg_vsi_send(priv->si, &msg_swbd);
}
+static int enetc_vf_get_ip_minor_revision(struct enetc_si *si)
+{
+ struct device *dev = &si->pdev->dev;
+ struct enetc_msg_swbd msg_swbd;
+ int err;
+
+ msg_swbd.size = ALIGN(sizeof(struct enetc_msg_generic),
+ ENETC_MSG_ALIGN);
+ msg_swbd.vaddr = dma_alloc_coherent(dev, msg_swbd.size,
+ &msg_swbd.dma, GFP_KERNEL);
+ if (!msg_swbd.vaddr)
+ return -ENOMEM;
+
+ enetc_msg_fill_common_hdr(&msg_swbd, ENETC_MSG_CLASS_ID_IP_REVISION,
+ ENETC_MSG_GET_IP_MN, 0, 0);
+
+ err = enetc_msg_vsi_send(si, &msg_swbd);
+
+ return err ? err : msg_swbd.class_code;
+}
+
static int enetc_vf_set_mac_addr(struct net_device *ndev, void *addr)
{
struct enetc_ndev_priv *priv = netdev_priv(ndev);
@@ -192,6 +216,27 @@ static const struct net_device_ops enetc_ndev_ops = {
.ndo_hwtstamp_set = enetc_hwtstamp_set,
};
+static void enetc_vf_get_revision(struct enetc_si *si)
+{
+ int ip_mn;
+
+ if (is_enetc_rev1(si)) {
+ si->revision = ENETC_REV_1_0;
+ return;
+ }
+
+ ip_mn = enetc_vf_get_ip_minor_revision(si);
+ if (ip_mn >= 0) {
+ si->revision = (si->pdev->revision << 8) | ip_mn;
+ return;
+ }
+
+ si->revision = ENETC_REV_4_1;
+ dev_info(&si->pdev->dev,
+ "Failed to get revision, use compatible revision: 0x%04x\n",
+ si->revision);
+}
+
static void enetc_vf_netdev_setup(struct enetc_si *si, struct net_device *ndev,
const struct net_device_ops *ndev_ops)
{
@@ -251,7 +296,7 @@ static int enetc_vf_probe(struct pci_dev *pdev,
return dev_err_probe(&pdev->dev, err, "PCI probing failed\n");
si = pci_get_drvdata(pdev);
- si->revision = ENETC_REV_1_0;
+ enetc_vf_get_revision(si);
si->ops = &enetc_vsi_ops;
err = enetc_get_driver_data(si);
if (err) {
--
2.34.1
next prev parent reply other threads:[~2026-05-11 8:35 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-11 8:07 [PATCH net-next 00/15] net: enetc: Prepare for ENETC v4 VF support Wei Fang
2026-05-11 8:07 ` [PATCH net-next 01/15] net: enetc: switch VF primary MAC setter to PF ops for commonization Wei Fang
2026-05-11 15:41 ` Vladimir Oltean
2026-05-11 8:07 ` [PATCH net-next 02/15] net: enetc: move VF message handlers to enetc_msg.c Wei Fang
2026-05-11 8:07 ` [PATCH net-next 03/15] net: enetc: avoid VF->PF mailbox timeout during SR-IOV teardown Wei Fang
2026-05-11 8:07 ` [PATCH net-next 04/15] net: enetc: relocate SR-IOV configuration helper for common PF support Wei Fang
2026-05-11 8:07 ` [PATCH net-next 05/15] net: enetc: integrate enetc_msg.c into enetc-pf-common driver Wei Fang
2026-05-11 8:07 ` [PATCH net-next 06/15] net: enetc: use read_poll_timeout() for VF mailbox polling Wei Fang
2026-05-11 8:07 ` [PATCH net-next 07/15] net: enetc: convert mailbox messages to new formats Wei Fang
2026-05-11 8:07 ` Wei Fang [this message]
2026-05-11 8:07 ` [PATCH net-next 09/15] net: enetc: align v1 CBDR API with v4 for VF driver sharing Wei Fang
2026-05-11 8:08 ` [PATCH net-next 10/15] net: enetc: add CBDR setup/teardown hooks to enetc_si_ops for VF support Wei Fang
2026-05-11 8:08 ` [PATCH net-next 11/15] net: enetc: add generic helper to initialize SR-IOV resources Wei Fang
2026-05-11 8:08 ` [PATCH net-next 12/15] net: enetc: use MADDR_TYPE for MAC filter array size Wei Fang
2026-05-11 8:08 ` [PATCH net-next 13/15] net: enetc: dynamically allocate rxmsg based on VF count Wei Fang
2026-05-11 8:08 ` [PATCH net-next 14/15] net: enetc: refactor MR interrupt enable/disable helpers Wei Fang
2026-05-11 8:08 ` [PATCH net-next 15/15] net: enetc: generate MR interrupt mask based on the number of enabled VFs Wei Fang
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=20260511080805.2052495-9-wei.fang@nxp.com \
--to=wei.fang@nxp.com \
--cc=andrew+netdev@lunn.ch \
--cc=claudiu.manoil@nxp.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=imx@lists.linux.dev \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=vladimir.oltean@nxp.com \
--cc=xiaoning.wang@nxp.com \
/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