DPDK patches and discussions
 help / color / mirror / Atom feed
From: Vamsi Attunuru <vattunuru@marvell.com>
To: <dev@dpdk.org>, <jerinj@marvell.com>
Cc: <sedara@marvell.com>, <vattunuru@marvell.com>
Subject: [PATCH] net/octeon_ep: support backward compatibility
Date: Thu, 22 Jun 2023 04:18:07 -0700	[thread overview]
Message-ID: <20230622111807.2679750-1-vattunuru@marvell.com> (raw)

From: Sathesh Edara <sedara@marvell.com>

Add backward compatibility support between VF
and PF mailbox messages.

Signed-off-by: Sathesh Edara <sedara@marvell.com>
Signed-off-by: Vamsi Attunuru <vattunuru@marvell.com>
---
 drivers/net/octeon_ep/otx_ep_common.h |  3 +++
 drivers/net/octeon_ep/otx_ep_ethdev.c |  6 +++++
 drivers/net/octeon_ep/otx_ep_mbox.c   | 38 ++++++++++++++++++++++-----
 drivers/net/octeon_ep/otx_ep_mbox.h   | 11 ++++++--
 4 files changed, 50 insertions(+), 8 deletions(-)

diff --git a/drivers/net/octeon_ep/otx_ep_common.h b/drivers/net/octeon_ep/otx_ep_common.h
index 42aa065a3a..c150cbe619 100644
--- a/drivers/net/octeon_ep/otx_ep_common.h
+++ b/drivers/net/octeon_ep/otx_ep_common.h
@@ -538,6 +538,9 @@ struct otx_ep_device {
 
 	/* Mailbox receive message length */
 	int32_t mbox_rcv_message_len;
+
+	/* Negotiated Mbox version */
+	uint32_t mbox_neg_ver;
 };
 
 int otx_ep_setup_iqs(struct otx_ep_device *otx_ep, uint32_t iq_no,
diff --git a/drivers/net/octeon_ep/otx_ep_ethdev.c b/drivers/net/octeon_ep/otx_ep_ethdev.c
index a9868909f8..57b965ad06 100644
--- a/drivers/net/octeon_ep/otx_ep_ethdev.c
+++ b/drivers/net/octeon_ep/otx_ep_ethdev.c
@@ -666,6 +666,12 @@ otx_ep_eth_dev_init(struct rte_eth_dev *eth_dev)
 	otx_epvf->port_id = eth_dev->data->port_id;
 	eth_dev->dev_ops = &otx_ep_eth_dev_ops;
 	rte_spinlock_init(&otx_epvf->mbox_lock);
+
+	/*
+	 * Initialize negotiated Mbox version to base version of VF Mbox
+	 * This will address working legacy PF with latest VF.
+	 */
+	otx_epvf->mbox_neg_ver = OTX_EP_MBOX_VERSION_V1;
 	eth_dev->data->mac_addrs = rte_zmalloc("otx_ep", RTE_ETHER_ADDR_LEN, 0);
 	if (eth_dev->data->mac_addrs == NULL) {
 		otx_ep_err("MAC addresses memory allocation failed\n");
diff --git a/drivers/net/octeon_ep/otx_ep_mbox.c b/drivers/net/octeon_ep/otx_ep_mbox.c
index 1ad36e14c8..4118645dc7 100644
--- a/drivers/net/octeon_ep/otx_ep_mbox.c
+++ b/drivers/net/octeon_ep/otx_ep_mbox.c
@@ -12,6 +12,14 @@
 #include "cnxk_ep_vf.h"
 #include "otx_ep_mbox.h"
 
+/*
+ * When a new command is implemented, the below table should be updated
+ * with new command and it's version info.
+ */
+static uint32_t otx_ep_cmd_versions[OTX_EP_MBOX_CMD_MAX] = {
+	[0 ... OTX_EP_MBOX_CMD_DEV_REMOVE] = OTX_EP_MBOX_VERSION_V1
+};
+
 static int
 __otx_ep_send_mbox_cmd(struct otx_ep_device *otx_ep,
 		       union otx_ep_mbox_word cmd,
@@ -56,6 +64,12 @@ otx_ep_send_mbox_cmd(struct otx_ep_device *otx_ep,
 	int ret;
 
 	rte_spinlock_lock(&otx_ep->mbox_lock);
+	if (otx_ep_cmd_versions[cmd.s.opcode] > otx_ep->mbox_neg_ver) {
+		otx_ep_dbg("CMD:%d not supported in Version:%d\n", cmd.s.opcode,
+			    otx_ep->mbox_neg_ver);
+		rte_spinlock_unlock(&otx_ep->mbox_lock);
+		return -EOPNOTSUPP;
+	}
 	ret = __otx_ep_send_mbox_cmd(otx_ep, cmd, rsp);
 	rte_spinlock_unlock(&otx_ep->mbox_lock);
 	return ret;
@@ -284,15 +298,27 @@ int otx_ep_mbox_version_check(struct rte_eth_dev *eth_dev)
 
 	cmd.u64 = 0;
 	cmd.s_version.opcode = OTX_EP_MBOX_CMD_VERSION;
-	cmd.s_version.version = OTX_EP_MBOX_VERSION;
+	cmd.s_version.version = OTX_EP_MBOX_VERSION_CURRENT;
 	ret = otx_ep_send_mbox_cmd(otx_ep, cmd, &rsp);
-	if (!ret)
-		return 0;
-	if (ret == OTX_EP_MBOX_CMD_STATUS_NACK) {
-		otx_ep_err("VF Mbox version:%u is not compatible with PF\n",
+
+	/*
+	 * VF receives NACK or version info as zero
+	 * only if PF driver running old version of Mailbox
+	 * In this case VF mailbox version fallbacks to base
+	 * mailbox vesrion OTX_EP_MBOX_VERSION_V1.
+	 * Default VF mbox_neg_ver is set to OTX_EP_MBOX_VERSION_V1
+	 * during initialization of PMD driver.
+	 */
+	if (ret == OTX_EP_MBOX_CMD_STATUS_NACK || rsp.s_version.version == 0) {
+		otx_ep_dbg("VF Mbox version fallback to base version from:%u\n",
 			(uint32_t)cmd.s_version.version);
+		return 0;
 	}
-	return ret;
+	otx_ep->mbox_neg_ver = (uint32_t)rsp.s_version.version;
+	otx_ep_dbg("VF Mbox version:%u Negotiated VF version with PF:%u\n",
+		    (uint32_t)cmd.s_version.version,
+		    (uint32_t)rsp.s_version.version);
+	return 0;
 }
 
 int otx_ep_mbox_send_dev_exit(struct rte_eth_dev *eth_dev)
diff --git a/drivers/net/octeon_ep/otx_ep_mbox.h b/drivers/net/octeon_ep/otx_ep_mbox.h
index 9df3c53edd..a3fc15cca7 100644
--- a/drivers/net/octeon_ep/otx_ep_mbox.h
+++ b/drivers/net/octeon_ep/otx_ep_mbox.h
@@ -5,8 +5,15 @@
 #ifndef _OTX_EP_MBOX_H_
 #define _OTX_EP_MBOX_H_
 
+/*
+ * When a new command is implemented, VF Mbox version should be bumped.
+ */
+enum octep_pfvf_mbox_version {
+	OTX_EP_MBOX_VERSION_V0,
+	OTX_EP_MBOX_VERSION_V1,
+};
 
-#define OTX_EP_MBOX_VERSION        1
+#define OTX_EP_MBOX_VERSION_CURRENT OTX_EP_MBOX_VERSION_V1
 
 enum otx_ep_mbox_opcode {
 	OTX_EP_MBOX_CMD_VERSION,
@@ -20,7 +27,7 @@ enum otx_ep_mbox_opcode {
 	OTX_EP_MBOX_CMD_GET_LINK_STATUS,
 	OTX_EP_MBOX_CMD_GET_MTU,
 	OTX_EP_MBOX_CMD_DEV_REMOVE,
-	OTX_EP_MBOX_CMD_LAST,
+	OTX_EP_MBOX_CMD_MAX,
 };
 
 enum otx_ep_mbox_word_type {
-- 
2.25.1


             reply	other threads:[~2023-06-22 11:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-22 11:18 Vamsi Attunuru [this message]
2023-06-23  2:55 ` Jerin Jacob

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=20230622111807.2679750-1-vattunuru@marvell.com \
    --to=vattunuru@marvell.com \
    --cc=dev@dpdk.org \
    --cc=jerinj@marvell.com \
    --cc=sedara@marvell.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;
as well as URLs for NNTP newsgroup(s).