From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-CY1-obe.outbound.protection.outlook.com (mail-cys01nam02on0060.outbound.protection.outlook.com [104.47.37.60]) by dpdk.org (Postfix) with ESMTP id A062D2F4F for ; Tue, 4 Sep 2018 06:03:08 +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=F/fWmOtQ1tJiEIxLMobpeSv8egzBbWhRvMsFZoyO2iU=; b=PCaitebkOUsZGUA7qSHviJRel3KJJXLMil4U4EYpo50KE/kXUOpXuKxiQBPJEMVO85Gvzj8ukX3x5tkB8EJplr+IZaJhtTQ8NKBcIHmoaqSPtQFM0Zqt8RpAGve7fqrzHalwpNMGSR3cXhjDZgxke0vjs6m9w8Wu4vVehcjKwfk= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Anoob.Joseph@cavium.com; Received: from ajoseph83.caveonetworks.com.com (115.113.156.2) by BYAPR07MB4902.namprd07.prod.outlook.com (2603:10b6:a02:ef::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1101.15; Tue, 4 Sep 2018 04:02:35 +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: Tue, 4 Sep 2018 09:28:59 +0530 Message-Id: <1536033560-21541-13-git-send-email-ajoseph@caviumnetworks.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1536033560-21541-1-git-send-email-ajoseph@caviumnetworks.com> References: <1528476325-15585-1-git-send-email-anoob.joseph@caviumnetworks.com> <1536033560-21541-1-git-send-email-ajoseph@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [115.113.156.2] X-ClientProxiedBy: BMXPR01CA0023.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:d::33) To BYAPR07MB4902.namprd07.prod.outlook.com (2603:10b6:a02:ef::25) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5951d053-210e-48bd-a84c-08d6121b416e X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:BYAPR07MB4902; X-Microsoft-Exchange-Diagnostics: 1; BYAPR07MB4902; 3:9SjN9UpqN5r1opupG2mudZ9lXvdPTUiJmZzVq5/AnCgMICT9tSEPgPo+U7M6uubaOqqH/iPO98n6l6GfpotGZxBJ/onRhgFgSh3W98C3DUBcgoFPrW9L0kIZREBecJXrTalAxazSyjzUJymlGMDO7P5KXJTTNvLudVzSC3a5DsGaS3lc+269zUYWcY7nu1/IvaFgTkOT1sw8wV+kFC/Xi3Y6U6ftaRTMQgsjmSjnaDdMiIf2PQBq8SkA1SpjXMKR; 25:JlJPtKgSW7rdT5Og6LshUVgvxATMV7vANyiiJEHwuBmm4MPls7opCyk06/D+VPS4G5D7VhdkZSuybgtCkCil83b9+vOWhe4UvG4BONcrm3+v3Fv9bPOPzfNVypeqHKOymSUw0m56ME/Ddn6RpWS7nhz5oee2Th/Ip7UI8YNcTrgs/Xqggvdb4jmlF9ubsAtK3TNv2wdWT8KNbi5D18en6KlA2AOlJf1lvqrso+15S01KZ6ngVSJpQsInMIBgjxlfV9jXKfyPpvODpdz3+Xa9QbDJ1QYcwBUxJy388SkdDlNSN0vjdX/MKcJ7q4FY1orJ8H0Y+kTHSHVaX3DBAHjX4A==; 31:iv8T71872b/qVKy88gZhKYqslGTsQfbqUEptE4P7zT92bJvXK7p6BtzblrWw25xK/TAJmy50DIqawehFULVgvDVm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xhv1IZ5bUIwQJsJg/rGo96OKqms9eFgJpHI5kdPJu3cyreoqH96zkFECa/BRV88DcsJNPxih2ye9x/iEwzzcDXxYv+j34 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)(10201501046)(93006095)(3231311)(944501410)(52105095)(3002001)(149027)(150027)(6041310)(20161123562045)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(201708071742011)(7699016); SRVR:BYAPR07MB4902; BCL:0; PCL:0; RULEID:; SRVR:BYAPR07MB4902; X-Forefront-PRVS: 0785459C39 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(366004)(396003)(136003)(346002)(376002)(39860400002)(199004)(189003)(26005)(51416003)(52116002)(76176011)(81166006)(305945005)(81156014)(7736002)(105586002)(316002)(6506007)(106356001)(6512007)(8936002)(446003)(54906003)(25786009)(6666003)(68736007)(50226002)(110136005)(53936002)(16586007)(42882007)(386003)(5660300001)(2906002)(72206003)(50466002)(6486002)(36756003)(6116002)(107886003)(2616005)(14444005)(186003)(3846002)(478600001)(15650500001)(66066001)(476003)(8676002)(47776003)(486006)(575784001)(956004)(48376002)(11346002)(4326008)(97736004)(16526019); DIR:OUT; SFP:1101; SCL:1; SRVR:BYAPR07MB4902; 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; BYAPR07MB4902; 23:S8/MoPci2SygHi1d08xFVhg0/u48QUOOXeUiMz7Qc?= =?us-ascii?Q?rWEAqKsKZIqn6t7p5HkqGs/nrU5aqJrssKeebvm5KdDMvUUAphJEcXfj+4sY?= =?us-ascii?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+EfgQKfsIep0k/wergDnQlT5MUYFW?= =?us-ascii?Q?Km0tryYT19l+GFVf8gmETx4TwmabIiJTh/MoAbLbofVVwaGFfa8wbjDdfcBb?= =?us-ascii?Q?6Pc5SFBBmAkzsNIgsspvLMoIkyuOAzpkYuiJU8pIyvxZ09iU+XiiaFPBUPEg?= =?us-ascii?Q?V75Afwg8oAjNsASST+NwgXVGuHdI9VWyDSj3qrNiUHN12LjbbOZLaUqJexTO?= =?us-ascii?Q?y3b3VpB4oyiFEs45Av2zBKd4bFyZ6jai9SmwXhstE/PZiInQmuLPmE2jM5st?= =?us-ascii?Q?QLMP84vCmAudlwn5IvYrkNxB5AAhzk0UscllKoDpMpBrrwgid/SSCNULfjTq?= =?us-ascii?Q?dSbkl314hQDrrr2vqVb9A8=3D?= X-Microsoft-Antispam-Message-Info: B/CTQBrSWlhNobVv2QR/VYJJFdCmtDXPTdsmO27xelTZ4l05Mu/UjYp4x8Zgy7yGAEn2qHxR7uRHzlq1frM/lHtTO2sVVJyO0UGkp3TvBqVZDwA6U7Fz8+24FRsbv378AmUlbNWn3HbH8RQ8Njp0dV3xxK6H9UO24dprcgOrvvoPMMZSAiAcLmqEkrMt8keByeHOUCF6ByIGDxtwOFFSYQHGmfcSuxwNZjJpKG+eLNRpZHgCBzBzfk1fOwKBE6AT37udKDciNGzj3c/JSws+ma8EuFi1Mg2gXN7mEWTCvH1+7S/hMU7SZlZ08gORiQWe5jPoo1g/moV4mVHQfG4aErzGw9NTpcbav6CTcXkCVnE= X-Microsoft-Exchange-Diagnostics: 1; BYAPR07MB4902; 6:RKXb6XDwLp8pwCdUqZ//n29kac/cq+ezvlzczpAfx2klXZDK2Chr4kWSIP8VslNlpOtGuE6uaHy2owNda9thapGM8eC0ZA+vHHP33JjpH0pnmsJicNhArqDKZ/9nuD7PLqfIB3hGqwUQ3einuPXasF953Kcf5HxfYeQmu510bWT5QxwE9CgxIwSpDodQXFXUgRYQgeQ09yAUrElCAP295uSGZQQ/cvIz+mNaHvY7Vm0C6blJRP8x9rWLeVV1lUHeZZJuWrpbfpgY+NIhOTwRH+XtWS6Y+M6UaTdyKpgAUJify5B1mWnDagcZaVPdCqJU19EG91iY53u/Y+J8T41yTIW76MabTp5KtSft/d8ji08155gcAYQh1nkZbfplW2xlo90IEg5o1GpCc8F+vU7inZl5yj6DXRwIG7fWOWaXDjzv1trX6/QiQJ2uE5aMqeTw6R5eRcubvwIovqlF47pmkw==; 5:ZbtGJVDCeZAvL41X9BUglAUNyNjA+NaPReyw8xNndxE8wiCgPZYtIGFFR9zOG6j0Kckj6vmw62JEEAEYFz6C4XDHRMhtFFJiV1rvMbPfYqL8ioddDsEsUEQbafaIzgm15HEIB/OtcKLrYPdVK7Rgr94JNLEjFGQyBfBWCj0g9MU=; 7:i9iF9tuZ2CfRNyg5O8YToIu3LWQLrF+lnravP7xHRWHb8XiPtatqKO1mZ1kaTCZkyKQCP7bF0FolMpZXkwft5c+Ly/6boAXipSBXIJLrCqUteX7fh9npp+yLVyuRNozyJv2eM+N/3RNHcRAVtXgCmkkXL9/s2pBs2g7u7r/bDlY6PZqoNovCiPybmmcLJG84XARgZxvtnFuAU3kYHbM5G9cBPEyqv696rq5yG8C5nmTqHB1RxJo6zGZvoAK0MmXp SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Sep 2018 04:02:35.2410 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5951d053-210e-48bd-a84c-08d6121b416e X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR07MB4902 Subject: [dpdk-dev] [PATCH v2 12/33] 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: Tue, 04 Sep 2018 04:03:09 -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 | 180 ++++++++++++++++++++++ drivers/crypto/octeontx/otx_cryptodev_mbox.h | 92 +++++++++++ 5 files changed, 287 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 064c9b0..949e983 100644 --- a/drivers/crypto/octeontx/Makefile +++ b/drivers/crypto/octeontx/Makefile @@ -26,6 +26,7 @@ CFLAGS += -I$(RTE_SDK)/drivers/common/cpt # PMD code SRCS-$(CONFIG_RTE_LIBRTE_PMD_OCTEONTX_CRYPTO) += otx_cryptodev.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 60ffc97..54e775c 100644 --- a/drivers/crypto/octeontx/meson.build +++ b/drivers/crypto/octeontx/meson.build @@ -10,6 +10,7 @@ name = 'octeontx_crypto' sources = files('otx_cryptodev.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 f8b6005..a6b5bc6 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" @@ -25,8 +26,19 @@ otx_cpt_vf_init(struct cpt_vf *cptvf) /* Mark as VF driver */ cptvf->flags |= CPT_FLAG_VF_DRIVER; + /* 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; } @@ -181,6 +193,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..d85f0d1 --- /dev/null +++ b/drivers/crypto/octeontx/otx_cryptodev_mbox.c @@ -0,0 +1,180 @@ +/* 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; + cptvf->chip_id = cid.s.chip_id; + 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_PMD_DRV_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..2c51c4f --- /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 { + uint64_t msg; + /**< Message type MBOX[0] */ + uint64_t data; + /**< Data MBOX[1] */ +}; + +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