From patchwork Thu Jun 22 11:18:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vamsi Krishna Attunuru X-Patchwork-Id: 128905 X-Patchwork-Delegate: jerinj@marvell.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 63E4942D23; Thu, 22 Jun 2023 13:18:25 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E6830406B8; Thu, 22 Jun 2023 13:18:24 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 26EC7406A2 for ; Thu, 22 Jun 2023 13:18:23 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 35M5m9cF020385 for ; Thu, 22 Jun 2023 04:18:22 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=ofZ/Nj4dhSj7l7RvkUet8fzpHzsOWp8+I+i4bhLHn14=; b=IPWS1VftIeh7hwPjQEWxYSJhfgVTlUrbhvdczefQ/HCWSyz0Rf5G5TFsAllxDi6M9unz yurpEq9q6zpR/oTOIfgn4yywUcNI7SuBCRspd2qpsFZHJlOYNiZ2cBpuB3zD1QhVHKhF xv1Me+eEBXlFDhBwclo2+adoyVIq0pdZbpIEMoLOsQbR5JhKhUTNc/eWHONZDb0LlM64 Qn/6/k+LKqq6Ijd9m0oNOCnVRej7X8cWFxgzGVQv17HcVmCr/mmxvMuERZagzUc0TH9H ZKDeSQj3J+lMkEQ97YP/M49MINjLTsRVjko+onbsiXzO1kbT8tXEubSecaBDJwTnYGSR dQ== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3rc97dhs4n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Thu, 22 Jun 2023 04:18:22 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Thu, 22 Jun 2023 04:18:20 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.48 via Frontend Transport; Thu, 22 Jun 2023 04:18:20 -0700 Received: from localhost.localdomain (unknown [10.28.36.156]) by maili.marvell.com (Postfix) with ESMTP id 7D7883F70B6; Thu, 22 Jun 2023 04:18:16 -0700 (PDT) From: Vamsi Attunuru To: , CC: , Subject: [PATCH] net/octeon_ep: support backward compatibility Date: Thu, 22 Jun 2023 04:18:07 -0700 Message-ID: <20230622111807.2679750-1-vattunuru@marvell.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Proofpoint-GUID: 7cVbpQaSbRQCH43P1QVC2muPXb5ZbAvC X-Proofpoint-ORIG-GUID: 7cVbpQaSbRQCH43P1QVC2muPXb5ZbAvC X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-06-22_07,2023-06-22_01,2023-05-22_02 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Sathesh Edara Add backward compatibility support between VF and PF mailbox messages. Signed-off-by: Sathesh Edara Signed-off-by: Vamsi Attunuru --- 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 {