From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-BN3-obe.outbound.protection.outlook.com (mail-bn3nam01on0069.outbound.protection.outlook.com [104.47.33.69]) by dpdk.org (Postfix) with ESMTP id 581231B100 for ; Fri, 5 Oct 2018 15:01:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=nYTIGpWZFFk5lrYW4jyfMTOo755hM2UG7ypMVvjRTKg=; b=GIOjuLhErFsSq9fukecaanrnUR/ZfNBComwJwEHlSgThiskYEySssNEd4CRcPLDPpjexV7+Yur+UNhViWFA2N6kZSlwCrT0F4JqfZGuIGRIKAh1RMMotKwfmqgaN4xE76U3dbGVCdxYXBmNyEwO/IBHpk2qYcp6MH2UlRTTLbIY= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Anoob.Joseph@cavium.com; Received: from ajoseph83.caveonetworks.com.com (115.113.156.2) by SN6PR07MB4910.namprd07.prod.outlook.com (2603:10b6:805:39::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1207.21; Fri, 5 Oct 2018 13:00:59 +0000 From: Anoob Joseph To: Akhil Goyal , Pablo de Lara , Thomas Monjalon Cc: Murthy NSSR , Jerin Jacob , Narayana Prasad , dev@dpdk.org, Ankur Dwivedi , Anoob Joseph , Nithin Dabilpuram , Ragothaman Jayaraman , Srisivasubramanian S , Tejasree Kondoj Date: Fri, 5 Oct 2018 18:29:02 +0530 Message-Id: <1538744363-30340-12-git-send-email-anoob.joseph@caviumnetworks.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1538744363-30340-1-git-send-email-anoob.joseph@caviumnetworks.com> References: <1536033560-21541-1-git-send-email-ajoseph@caviumnetworks.com> <1538744363-30340-1-git-send-email-anoob.joseph@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [115.113.156.2] X-ClientProxiedBy: MA1PR0101CA0036.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:22::22) To SN6PR07MB4910.namprd07.prod.outlook.com (2603:10b6:805:39::16) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c4f22c20-be01-4e24-e46d-08d62ac29b8a X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:SN6PR07MB4910; X-Microsoft-Exchange-Diagnostics: 1; SN6PR07MB4910; 3:K0BIzYOE65A108m8+QOOh+vORacEndUtOVB2w+sW88P/0y8QHvvWUEDSvTyOE33iZzyfMVRor4L0+qdiigkjpC1g7ZQ2013lyZ3h5z1f15Jpy8aQYd5b++xwrbm4qXuPGM9ivlrc62rcjMHPVba6LUcvmpBxYm9ypCHWM1RzuURuMqfn+JefGJnn5RX2RhtoAqs00z84Fud+RLpyBhlkv16VXM6HUQs4x0hUgyl30T917InwdteaVLZryWSwrn8e; 25:PtD89qZG4IYe8sc/uL0yiUW+d7w0PN76PNkMnfjWz+jJkX94+C94yJXAJb7kOZFlqtWlh7VyinhO3gXRXD+9kZPTChe2fwsPw7NqFGSqaoSZ0/Bn55OWDBQapFK83ET2WT6R8OUs8rn1EuYmED6nPSCMa2EkYo7qtQJEACkA1hcqHHvsbIdBFhe8JBNm5YC7tcQ91xZhXVJ0NNLJKESDzZyJy8zv4FyhX9l9O+2Dc9U7JfKV/3hWnJf9cnyPNP+1BWmC3mmziLGeDXAtwxHFznkoA3APiDI3xRH5MjjVJTe1sPGyQTZli3ixuVRsPJ4QeMdxlsPRtfJl+c5smC0pUA==; 31:oagiVQnVI4iYLKkOiOhQRwrDI0S8m7d84wGgPAR297o5M/KGIIjrka7YshbKsXGBro9cxy4iK7fvJGh0hWbRwbi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2tDqCcEO8swLQnzaytXuuPaDFcqaReo3z8sw+ODoP2V21qxUYpIwonSo8yy2S+0bRP4dqyfM670 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(35073007944872); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3002001)(3231355)(944501410)(52105095)(10201501046)(93006095)(149066)(150057)(6041310)(20161123564045)(20161123558120)(20161123560045)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051); SRVR:SN6PR07MB4910; BCL:0; PCL:0; RULEID:; SRVR:SN6PR07MB4910; X-Forefront-PRVS: 0816F1D86E X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(376002)(39860400002)(346002)(136003)(396003)(366004)(199004)(189003)(51416003)(76176011)(11346002)(50226002)(25786009)(8936002)(48376002)(305945005)(186003)(16526019)(110136005)(6486002)(3846002)(446003)(52116002)(6116002)(81156014)(8676002)(575784001)(97736004)(5660300001)(50466002)(4326008)(956004)(42882007)(2616005)(68736007)(478600001)(54906003)(7736002)(81166006)(6666003)(16586007)(107886003)(26005)(55236004)(66066001)(386003)(47776003)(6512007)(72206003)(44832011)(476003)(316002)(14444005)(36756003)(105586002)(106356001)(486006)(6506007)(2906002)(53936002)(15650500001); DIR:OUT; SFP:1101; SCL:1; SRVR:SN6PR07MB4910; H:ajoseph83.caveonetworks.com.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SN6PR07MB4910; 23:rMSEBKt9J1k/vMcBiPi5WlC1rIWmwkJqSA0kzYb3D?= =?us-ascii?Q?qVxvPOfLTCIKQ7eeAKSvDBQ73dHSOxnoq7uE9/EioohHwViOChSrA0C5r8SQ?= =?us-ascii?Q?km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T?= =?us-ascii?Q?RPRQH64yDhIrGSIi8f5qUPBrAwzGozJpzGfP7xACbt7D3b5dq8nqOhkSycUg?= =?us-ascii?Q?0uDnrtrtomhEyTtd8tGV9VrPH55aCImRYgq5bVprgZ4Sp5cdbmSlF6VfD3Wi?= =?us-ascii?Q?mxUSDsLWBdr22PKzATJU6RHOYQJwAUkp17e1hoz3JJiEt8MceVGShR8SezN3?= =?us-ascii?Q?jwdtFYm1WXcK2fuORi/43EndSC3MM7c3pxYN64NBySWzGgympPJAgcPKfRtk?= =?us-ascii?Q?6wCsp6obxkn1o16FkuK9kvELAdKYWjAmi6RAgjGy4fwzFSLy0+eoLxHAvZFu?= =?us-ascii?Q?UsmkWgBgKdDRcxsRCRnOb9dxOYSLMjJgCrI+0LC6SKBH2ggeX+hkIQxiZ/IJ?= =?us-ascii?Q?N8UIA=3D=3D?= X-Microsoft-Antispam-Message-Info: dW9lQbjmAf+tENdPPmsqs2GyYjd3X0qSUokxGfrYb7musFcMHN4GG80EUf2mHKUjocpLb6U8RaUp8kyVtKDzadCH3/5nws/lby0Cw/unO019ipbQcMUe1ztkdDMKPZKCchidt52FgAfbCJkugpucP5W+XLm1xUSdJ04uCx2HcRPIVV2IDK2dpIHtquwquMoZQEYZj4j3driFYw0Kkz9N3WvHYk64DBABfBnyrKGt+9krF9bVZXAZnVG7yp8bXFrFQwYkVq00Tu0iUKDMMkmNaVqkK3mEF/sXhXqXomu2tlDlIIKKZqdqz4SIZthWf3D0kbRpCXIhWbkxiFjmisg3O+0GQi53L0kGFb0XWv5/MiA= X-Microsoft-Exchange-Diagnostics: 1; SN6PR07MB4910; 6:VvVvSaqlml7se/gWcjPB4xkvxUzR5jEzLHQ8CjYgLiCsHV/wJLk/JlWrWxAh7dxjsfcxOEOpfRwYP+myfV+0Vg+VCEnfmFuRasm4jRdjtk8TO4YGpD0zlNDP9cwxRHZSVMqhgaPR+X/uiGjSwXd6Lg+T+T/F6/PwRSdyaZFrCmFezKL2PLCm47hgtMz/gNnHI1I83gXrF3a9G29HZuFda6uTocoAFib+oSt92kESxV3DgNIC1rfLaYqeQum+Is8ABUxgkUk2scgARilb7nwXm9YbDEv+2bNtQgMV5H2FBvSRd0eKkdQntHFkS1u3jgIB4cW4uoPe+I0849OYsd6BiP9DWoLHOLnGFmZTqwE2Kv1EfIWGSBZT2eCGooNFtbv5SvvP94218VmpALWTi0M33qgSgzluK5Eh02ZgArhKw03BB55ZyqulEY6ghJ5vAOcorohAspta0Xjjd9Ud9mVucg==; 5:Gakzg5U36xqmIYN+nwMRRYRmGOTJMDTT7kLaxTaLwlJzQ1K3fqH/k9WhCQ8m5aOfZLmpE9O1qnz3664oF59MYxQCmB7qKS0vK6qZ2EH7Vu920WLXgHkV7SJwy45RJv7Ta2AAxCn2WmUWMvmH90dHIVaMXvk4ideqUniNG2BtOPs=; 7:T0sZbGqahr1DvZ31vKwSrYfgFXzmq4ra9bYjRt5Bawk9Ma6LCJ7a46Ea7RgW/l3uioHATvtfKVavBYOPx9S9jo6m5HpgHQwOMRHJRDxfqsRaD99Vv77eSOIJyyZNKlQ2i7J/hMUz0Z82NdiF9EKKFFv0lCGmbQgQ/GjMbK4yxqMzSG0hePJvL4gwNil+TWiaBKC76MqObS0qQLPLbsoHOsVW3IiV5907j43bge2CjQntrkM+aes56MvZkkNpzirD SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Oct 2018 13:00:59.8055 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c4f22c20-be01-4e24-e46d-08d62ac29b8a X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR07MB4910 Subject: [dpdk-dev] [PATCH v3 11/32] crypto/octeontx: add mailbox routines X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Oct 2018 13:01:05 -0000 From: Murthy NSSR Adding mailbox routines to interact with the pf driver Signed-off-by: Ankur Dwivedi Signed-off-by: Anoob Joseph Signed-off-by: Murthy NSSR Signed-off-by: Nithin Dabilpuram Signed-off-by: Ragothaman Jayaraman Signed-off-by: Srisivasubramanian S Signed-off-by: Tejasree Kondoj --- drivers/crypto/octeontx/Makefile | 1 + drivers/crypto/octeontx/meson.build | 1 + drivers/crypto/octeontx/otx_cryptodev_hw_access.c | 13 ++ drivers/crypto/octeontx/otx_cryptodev_mbox.c | 178 ++++++++++++++++++++++ drivers/crypto/octeontx/otx_cryptodev_mbox.h | 92 +++++++++++ 5 files changed, 285 insertions(+) create mode 100644 drivers/crypto/octeontx/otx_cryptodev_mbox.c create mode 100644 drivers/crypto/octeontx/otx_cryptodev_mbox.h diff --git a/drivers/crypto/octeontx/Makefile b/drivers/crypto/octeontx/Makefile index 1808244..2e78e69 100644 --- a/drivers/crypto/octeontx/Makefile +++ b/drivers/crypto/octeontx/Makefile @@ -27,6 +27,7 @@ CFLAGS += -I$(RTE_SDK)/drivers/common/cpt SRCS-$(CONFIG_RTE_LIBRTE_PMD_OCTEONTX_CRYPTO) += otx_cryptodev.c SRCS-$(CONFIG_RTE_LIBRTE_PMD_OCTEONTX_CRYPTO) += otx_cryptodev_capabilities.c SRCS-$(CONFIG_RTE_LIBRTE_PMD_OCTEONTX_CRYPTO) += otx_cryptodev_hw_access.c +SRCS-$(CONFIG_RTE_LIBRTE_PMD_OCTEONTX_CRYPTO) += otx_cryptodev_mbox.c SRCS-$(CONFIG_RTE_LIBRTE_PMD_OCTEONTX_CRYPTO) += otx_cryptodev_ops.c # export include files diff --git a/drivers/crypto/octeontx/meson.build b/drivers/crypto/octeontx/meson.build index 7f65476..6511b40 100644 --- a/drivers/crypto/octeontx/meson.build +++ b/drivers/crypto/octeontx/meson.build @@ -11,6 +11,7 @@ name = 'octeontx_crypto' sources = files('otx_cryptodev.c', 'otx_cryptodev_capabilities.c', 'otx_cryptodev_hw_access.c', + 'otx_cryptodev_mbox.c', 'otx_cryptodev_ops.c') includes += include_directories('../../common/cpt') diff --git a/drivers/crypto/octeontx/otx_cryptodev_hw_access.c b/drivers/crypto/octeontx/otx_cryptodev_hw_access.c index e8a2b0b..eb9fbcf 100644 --- a/drivers/crypto/octeontx/otx_cryptodev_hw_access.c +++ b/drivers/crypto/octeontx/otx_cryptodev_hw_access.c @@ -7,6 +7,7 @@ #include #include "otx_cryptodev_hw_access.h" +#include "otx_cryptodev_mbox.h" #include "cpt_pmd_logs.h" #include "cpt_hw_types.h" @@ -22,8 +23,19 @@ otx_cpt_vf_init(struct cpt_vf *cptvf) { int ret = 0; + /* Check ready with PF */ + /* Gets chip ID / device Id from PF if ready */ + ret = otx_cpt_check_pf_ready(cptvf); + if (ret) { + CPT_LOG_ERR("%s: PF not responding to READY msg", + cptvf->dev_name); + ret = -EBUSY; + goto exit; + } + CPT_LOG_DP_DEBUG("%s: %s done", cptvf->dev_name, __func__); +exit: return ret; } @@ -178,6 +190,7 @@ otx_cpt_poll_misc(struct cpt_vf *cptvf) if (likely(intr & CPT_VF_INTR_MBOX_MASK)) { CPT_LOG_DP_DEBUG("%s: Mailbox interrupt 0x%lx on CPT VF %d", cptvf->dev_name, (unsigned int long)intr, cptvf->vfid); + otx_cpt_handle_mbox_intr(cptvf); otx_cpt_clear_mbox_intr(cptvf); } else if (unlikely(intr & CPT_VF_INTR_IRDE_MASK)) { otx_cpt_clear_irde_intr(cptvf); diff --git a/drivers/crypto/octeontx/otx_cryptodev_mbox.c b/drivers/crypto/octeontx/otx_cryptodev_mbox.c new file mode 100644 index 0000000..a8e51a8 --- /dev/null +++ b/drivers/crypto/octeontx/otx_cryptodev_mbox.c @@ -0,0 +1,178 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2018 Cavium, Inc + */ + +#include + +#include "otx_cryptodev_hw_access.h" +#include "otx_cryptodev_mbox.h" + +void +otx_cpt_handle_mbox_intr(struct cpt_vf *cptvf) +{ + struct cpt_mbox mbx = {0, 0}; + + /* + * MBOX[0] contains msg + * MBOX[1] contains data + */ + mbx.msg = CPT_READ_CSR(CPT_CSR_REG_BASE(cptvf), + CPTX_VFX_PF_MBOXX(0, 0, 0)); + mbx.data = CPT_READ_CSR(CPT_CSR_REG_BASE(cptvf), + CPTX_VFX_PF_MBOXX(0, 0, 1)); + + CPT_LOG_DP_DEBUG("%s: Mailbox msg 0x%lx from PF", + cptvf->dev_name, (unsigned int long)mbx.msg); + switch (mbx.msg) { + case OTX_CPT_MSG_READY: + { + otx_cpt_chipid_vfid_t cid; + + cid.u64 = mbx.data; + cptvf->pf_acked = true; + cptvf->vfid = cid.s.vfid; + CPT_LOG_DP_DEBUG("%s: Received VFID %d chip_id %d", + cptvf->dev_name, + cptvf->vfid, cid.s.chip_id); + } + break; + case OTX_CPT_MSG_QBIND_GRP: + cptvf->pf_acked = true; + cptvf->vftype = mbx.data; + CPT_LOG_DP_DEBUG("%s: VF %d type %s group %d", + cptvf->dev_name, cptvf->vfid, + ((mbx.data == SE_TYPE) ? "SE" : "AE"), + cptvf->vfgrp); + break; + case OTX_CPT_MBOX_MSG_TYPE_ACK: + cptvf->pf_acked = true; + break; + case OTX_CPT_MBOX_MSG_TYPE_NACK: + cptvf->pf_nacked = true; + break; + default: + CPT_LOG_DP_DEBUG("%s: Invalid msg from PF, msg 0x%lx", + cptvf->dev_name, (unsigned int long)mbx.msg); + break; + } +} + +/* Send a mailbox message to PF + * @vf: vf from which this message to be sent + * @mbx: Message to be sent + */ +static void +otx_cpt_send_msg_to_pf(struct cpt_vf *cptvf, struct cpt_mbox *mbx) +{ + /* Writing mbox(1) causes interrupt */ + CPT_WRITE_CSR(CPT_CSR_REG_BASE(cptvf), + CPTX_VFX_PF_MBOXX(0, 0, 0), mbx->msg); + CPT_WRITE_CSR(CPT_CSR_REG_BASE(cptvf), + CPTX_VFX_PF_MBOXX(0, 0, 1), mbx->data); +} + +static int32_t +otx_cpt_send_msg_to_pf_timeout(struct cpt_vf *cptvf, struct cpt_mbox *mbx) +{ + int timeout = OTX_CPT_MBOX_MSG_TIMEOUT; + int sleep_ms = 10; + + cptvf->pf_acked = false; + cptvf->pf_nacked = false; + + otx_cpt_send_msg_to_pf(cptvf, mbx); + + /* Wait for previous message to be acked, timeout 2sec */ + while (!cptvf->pf_acked) { + if (cptvf->pf_nacked) + return -EINVAL; + usleep(sleep_ms * 1000); + otx_cpt_poll_misc(cptvf); + if (cptvf->pf_acked) + break; + timeout -= sleep_ms; + if (!timeout) { + CPT_LOG_ERR("%s: PF didn't ack mbox msg %lx(vfid %u)", + cptvf->dev_name, + (unsigned int long)(mbx->msg & 0xFF), + cptvf->vfid); + return -EBUSY; + } + } + return 0; +} + +int +otx_cpt_check_pf_ready(struct cpt_vf *cptvf) +{ + struct cpt_mbox mbx = {0, 0}; + + mbx.msg = OTX_CPT_MSG_READY; + if (otx_cpt_send_msg_to_pf_timeout(cptvf, &mbx)) { + CPT_LOG_ERR("%s: PF didn't respond to READY msg", + cptvf->dev_name); + return 1; + } + return 0; +} + +int +otx_cpt_send_vq_size_msg(struct cpt_vf *cptvf) +{ + struct cpt_mbox mbx = {0, 0}; + + mbx.msg = OTX_CPT_MSG_QLEN; + + mbx.data = cptvf->qsize; + if (otx_cpt_send_msg_to_pf_timeout(cptvf, &mbx)) { + CPT_LOG_ERR("%s: PF didn't respond to vq_size msg", + cptvf->dev_name); + return 1; + } + return 0; +} + +int +otx_cpt_send_vf_grp_msg(struct cpt_vf *cptvf, uint32_t group) +{ + struct cpt_mbox mbx = {0, 0}; + + mbx.msg = OTX_CPT_MSG_QBIND_GRP; + + /* Convey group of the VF */ + mbx.data = group; + if (otx_cpt_send_msg_to_pf_timeout(cptvf, &mbx)) { + CPT_LOG_ERR("%s: PF didn't respond to vf_type msg", + cptvf->dev_name); + return 1; + } + return 0; +} + +int +otx_cpt_send_vf_up(struct cpt_vf *cptvf) +{ + struct cpt_mbox mbx = {0, 0}; + + mbx.msg = OTX_CPT_MSG_VF_UP; + if (otx_cpt_send_msg_to_pf_timeout(cptvf, &mbx)) { + CPT_LOG_ERR("%s: PF didn't respond to UP msg", + cptvf->dev_name); + return 1; + } + return 0; +} + +int +otx_cpt_send_vf_down(struct cpt_vf *cptvf) +{ + struct cpt_mbox mbx = {0, 0}; + + mbx.msg = OTX_CPT_MSG_VF_DOWN; + if (otx_cpt_send_msg_to_pf_timeout(cptvf, &mbx)) { + CPT_LOG_ERR("%s: PF didn't respond to DOWN msg", + cptvf->dev_name); + return 1; + } + return 0; +} diff --git a/drivers/crypto/octeontx/otx_cryptodev_mbox.h b/drivers/crypto/octeontx/otx_cryptodev_mbox.h new file mode 100644 index 0000000..b05d1c5 --- /dev/null +++ b/drivers/crypto/octeontx/otx_cryptodev_mbox.h @@ -0,0 +1,92 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2018 Cavium, Inc + */ + +#ifndef _OTX_CRYPTODEV_MBOX_H_ +#define _OTX_CRYPTODEV_MBOX_H_ + +#include +#include + +#include "cpt_common.h" +#include "cpt_pmd_logs.h" + +#include "otx_cryptodev_hw_access.h" + +#define OTX_CPT_MBOX_MSG_TIMEOUT 2000 /* In Milli Seconds */ + +#define OTX_CPT_MBOX_MSG_TYPE_REQ 0 +#define OTX_CPT_MBOX_MSG_TYPE_ACK 1 +#define OTX_CPT_MBOX_MSG_TYPE_NACK 2 +#define OTX_CPT_MBOX_MSG_TYPE_NOP 3 + +/* CPT mailbox structure */ +struct cpt_mbox { + /** Message type MBOX[0] */ + uint64_t msg; + /** Data MBOX[1] */ + uint64_t data; +}; + +typedef enum { + OTX_CPT_MSG_VF_UP = 1, + OTX_CPT_MSG_VF_DOWN, + OTX_CPT_MSG_READY, + OTX_CPT_MSG_QLEN, + OTX_CPT_MSG_QBIND_GRP, + OTX_CPT_MSG_VQ_PRIORITY, + OTX_CPT_MSG_PF_TYPE, +} otx_cpt_mbox_opcode_t; + +typedef union { + uint64_t u64; + struct { +#if RTE_BYTE_ORDER == RTE_BIG_ENDIAN + uint32_t chip_id; + uint8_t vfid; + uint8_t reserved[3]; +#else + uint8_t reserved[3]; + uint8_t vfid; + uint32_t chip_id; +#endif + } s; +} otx_cpt_chipid_vfid_t; + +/* Poll handler to handle mailbox messages from VFs */ +void +otx_cpt_handle_mbox_intr(struct cpt_vf *cptvf); + +/* + * Checks if VF is able to comminicate with PF + * and also gets the CPT number this VF is associated to. + */ +int +otx_cpt_check_pf_ready(struct cpt_vf *cptvf); + +/* + * Communicate VQs size to PF to program CPT(0)_PF_Q(0-15)_CTL of the VF. + * Must be ACKed. + */ +int +otx_cpt_send_vq_size_msg(struct cpt_vf *cptvf); + +/* + * Communicate VF group required to PF and get the VQ binded to that group + */ +int +otx_cpt_send_vf_grp_msg(struct cpt_vf *cptvf, uint32_t group); + +/* + * Communicate to PF that VF is UP and running + */ +int +otx_cpt_send_vf_up(struct cpt_vf *cptvf); + +/* + * Communicate to PF that VF is DOWN and running + */ +int +otx_cpt_send_vf_down(struct cpt_vf *cptvf); + +#endif /* _OTX_CRYPTODEV_MBOX_H_ */ -- 2.7.4