From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 1BAE7A00C5;
	Mon, 12 Sep 2022 03:10:21 +0200 (CEST)
Received: from [217.70.189.124] (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id 3268642B86;
	Mon, 12 Sep 2022 03:09:26 +0200 (CEST)
Received: from mga04.intel.com (mga04.intel.com [192.55.52.120])
 by mails.dpdk.org (Postfix) with ESMTP id BF88142829
 for <dev@dpdk.org>; Mon, 12 Sep 2022 03:09:18 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple;
 d=intel.com; i=@intel.com; q=dns/txt; s=Intel;
 t=1662944958; x=1694480958;
 h=from:to:cc:subject:date:message-id:in-reply-to: references;
 bh=cMy0fxAEX3XxsZfi0lojCxhm7um1vFEHwnWg9PDDOus=;
 b=NodUDb8f+l15xXa4tg1QZyIY/f4IhgcSKWu2opfrtXO4wbO8Mw6rCm9u
 51Z+oUrB7E+hYRMIqnKnAWKEuX2gb7KK2TbA/Xh7VTjWO9xWpVtPepjdo
 UZ+Br2YMpVIT+cofyPty96dU4Mfr97hWo8WHQmRfLMPy0Ux5VxhHqpUOF
 XDwjq+7c2izGSlLwNqoefToVbFzlKLoG5eAJaufxSY6yAJpMgUuvmXofS
 GxxwYG9PRlcHPkyNEH2Eq9tmoRLTD6KHSfARH6ZqBKa23nOl5/+TsISIU
 bj2ZMtt/nEE406WpRGCn3lPzhHSBingUNLRhP6j2jE8JRF5rRRw2+iige A==;
X-IronPort-AV: E=McAfee;i="6500,9779,10467"; a="296501700"
X-IronPort-AV: E=Sophos;i="5.93,308,1654585200"; d="scan'208";a="296501700"
Received: from orsmga004.jf.intel.com ([10.7.209.38])
 by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;
 11 Sep 2022 18:09:18 -0700
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.93,308,1654585200"; d="scan'208";a="741617975"
Received: from unknown (HELO icx-npg-scs1-cp1.localdomain) ([10.233.180.245])
 by orsmga004.jf.intel.com with ESMTP; 11 Sep 2022 18:09:17 -0700
From: Nic Chautru <nicolas.chautru@intel.com>
To: dev@dpdk.org, thomas@monjalon.net, gakhil@marvell.com,
 hemant.agrawal@nxp.com
Cc: maxime.coquelin@redhat.com, trix@redhat.com, mdr@ashroe.eu,
 bruce.richardson@intel.com, david.marchand@redhat.com,
 stephen@networkplumber.org, hernan.vargas@intel.com,
 Nicolas Chautru <nicolas.chautru@intel.com>
Subject: [PATCH v2 10/11] baseband/acc200: add device status and vf2pf comms
Date: Sun, 11 Sep 2022 18:08:57 -0700
Message-Id: <1662944938-32649-11-git-send-email-nicolas.chautru@intel.com>
X-Mailer: git-send-email 1.8.3.1
In-Reply-To: <1662944938-32649-1-git-send-email-nicolas.chautru@intel.com>
References: <1657238503-143836-2-git-send-email-nicolas.chautru@intel.com>
 <1662944938-32649-1-git-send-email-nicolas.chautru@intel.com>
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org

From: Nicolas Chautru <nicolas.chautru@intel.com>

Add support to expose the device status seen from the
host through v2pf mailbox communication.

Signed-off-by: Nicolas Chautru <nicolas.chautru@intel.com>
---
 drivers/baseband/acc200/rte_acc200_pmd.c | 61 +++++++++++++++++++++++---------
 1 file changed, 44 insertions(+), 17 deletions(-)

diff --git a/drivers/baseband/acc200/rte_acc200_pmd.c b/drivers/baseband/acc200/rte_acc200_pmd.c
index 8fe5704..a969679 100644
--- a/drivers/baseband/acc200/rte_acc200_pmd.c
+++ b/drivers/baseband/acc200/rte_acc200_pmd.c
@@ -201,23 +201,47 @@
 	rte_bbdev_log_debug(
 			"%s Config LLR SIGN IN/OUT %s %s QG %u %u %u %u %u AQ %u %u %u %u %u Len %u %u %u %u %u\n",
 			(d->pf_device) ? "PF" : "VF",
-			(acc_conf->input_pos_llr_1_bit) ? "POS" : "NEG",
-			(acc_conf->output_pos_llr_1_bit) ? "POS" : "NEG",
-			acc_conf->q_ul_4g.num_qgroups,
-			acc_conf->q_dl_4g.num_qgroups,
-			acc_conf->q_ul_5g.num_qgroups,
-			acc_conf->q_dl_5g.num_qgroups,
-			acc_conf->q_fft.num_qgroups,
-			acc_conf->q_ul_4g.num_aqs_per_groups,
-			acc_conf->q_dl_4g.num_aqs_per_groups,
-			acc_conf->q_ul_5g.num_aqs_per_groups,
-			acc_conf->q_dl_5g.num_aqs_per_groups,
-			acc_conf->q_fft.num_aqs_per_groups,
-			acc_conf->q_ul_4g.aq_depth_log2,
-			acc_conf->q_dl_4g.aq_depth_log2,
-			acc_conf->q_ul_5g.aq_depth_log2,
-			acc_conf->q_dl_5g.aq_depth_log2,
-			acc_conf->q_fft.aq_depth_log2);
+			(acc200_conf->input_pos_llr_1_bit) ? "POS" : "NEG",
+			(acc200_conf->output_pos_llr_1_bit) ? "POS" : "NEG",
+			acc200_conf->q_ul_4g.num_qgroups,
+			acc200_conf->q_dl_4g.num_qgroups,
+			acc200_conf->q_ul_5g.num_qgroups,
+			acc200_conf->q_dl_5g.num_qgroups,
+			acc200_conf->q_fft.num_qgroups,
+			acc200_conf->q_ul_4g.num_aqs_per_groups,
+			acc200_conf->q_dl_4g.num_aqs_per_groups,
+			acc200_conf->q_ul_5g.num_aqs_per_groups,
+			acc200_conf->q_dl_5g.num_aqs_per_groups,
+			acc200_conf->q_fft.num_aqs_per_groups,
+			acc200_conf->q_ul_4g.aq_depth_log2,
+			acc200_conf->q_dl_4g.aq_depth_log2,
+			acc200_conf->q_ul_5g.aq_depth_log2,
+			acc200_conf->q_dl_5g.aq_depth_log2,
+			acc200_conf->q_fft.aq_depth_log2);
+}
+
+static inline void
+acc200_vf2pf(struct acc_device *d, unsigned int payload)
+{
+	acc_reg_write(d, HWVfHiVfToPfDbellVf, payload);
+}
+
+/* Request device status information */
+static inline uint32_t
+acc200_device_status(struct rte_bbdev *dev)
+{
+	struct acc_device *d = dev->data->dev_private;
+	uint32_t reg, time_out = 0;
+	if (d->pf_device)
+		return RTE_BBDEV_DEV_NOT_SUPPORTED;
+	acc200_vf2pf(d, ACC_VF2PF_STATUS_REQUEST);
+	reg = acc_reg_read(d, HWVfHiPfToVfDbellVf);
+	while ((time_out < ACC200_STATUS_TO) && (reg == RTE_BBDEV_DEV_NOSTATUS)) {
+		usleep(ACC200_STATUS_WAIT); /*< Wait or VF->PF->VF Comms */
+		reg = acc_reg_read(d, HWVfHiPfToVfDbellVf);
+		time_out++;
+	}
+	return reg;
 }
 
 /* Checks PF Info Ring to find the interrupt cause and handles it accordingly */
@@ -537,6 +561,7 @@
 
 	/* Mark as configured properly */
 	d->configured = true;
+	acc200_vf2pf(d, ACC_VF2PF_USING_VF);
 
 	rte_bbdev_log_debug(
 			"ACC200 (%s) configured  sw_rings = %p, sw_rings_iova = %#"
@@ -1047,6 +1072,8 @@
 
 	/* Read and save the populated config from ACC200 registers */
 	fetch_acc200_config(dev);
+	/* Check the status of device */
+	dev_info->device_status = acc200_device_status(dev);
 
 	/* Exposed number of queues */
 	dev_info->num_queues[RTE_BBDEV_OP_NONE] = 0;
-- 
1.8.3.1