From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-BN3-obe.outbound.protection.outlook.com (mail-bn3nam01on0078.outbound.protection.outlook.com [104.47.33.78]) by dpdk.org (Postfix) with ESMTP id 546D55B32 for ; Fri, 5 Oct 2018 15:00:36 +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=6K1X8W0FpNeD7XKaRvRTS9etZfO1fxX+MWP4cr7/7rQ=; b=oAHFBLnkAY+ga/nzN4/MC5/Ns1YX9SQFesGgygjs5zFW4Zce8SIrbLg82sKlUN0s0vTTSXZG+2oO9vaqWIBGCPCbtbrYEW8v0N4066GfVSmployqKxqomIqfLXdjlQOPN8el+U0y3Ifb5SeU9OX0Hn2951qEl5QIzv1c29PPI90= 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:29 +0000 From: Anoob Joseph To: Akhil Goyal , Pablo de Lara , Thomas Monjalon Cc: Anoob Joseph , Jerin Jacob , Narayana Prasad , dev@dpdk.org, Ankur Dwivedi , Murthy NSSR , Nithin Dabilpuram , Ragothaman Jayaraman , Srisivasubramanian S , Tejasree Kondoj Date: Fri, 5 Oct 2018 18:28:56 +0530 Message-Id: <1538744363-30340-6-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: 53d1799d-affb-416b-6f4a-08d62ac289a0 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:i5lwNltX2bSlTfEzXZLnKgYFTEFTirX61I8CPjf90inek+y7ADhbIGvais0WtF5HVvYMrVok6IVKXV3kdxOVUpz0nJuJQ2bh3oGl7Ma4jPZxpFS+2014BoeRJyE6GCEnYoJHPfPW+0lw7aPrvmd5LllkOJSThUSEU3nnAFD7tz3i6L4ob1WnLk5C2LoJ4u2cyxIdicOyjFbDOqtJnDc+OArp6c/fGBQwjLtQQrFQKKFIHlgsNl3s7yRnliEcQxuS; 25:rQ2anaEkY50YGYkw2Mns+YuWt+eq4IgBorM2Pi4/rpNTLvLxMySGR/z7ALUuWaQFuYnLtX0B77WRbDtdzbiUaB3O6oF74zWc0zKqnwXz2Al5Rw2V/6qgnKrdCoAboO7OdkqhVfWaT7EUvp/7EOh6G2VxkMOcDstQsWPdzGx/ZrCPZ68CIb3aPoORfCM7P9vFCPwumEC33PyeKhOb6PLsS6Dni0/J19+6Yk05yR1oZgZEcxmL3z9n5vwzcnvdO0R7ca+vkTZXy2mPLPZdma/tP5CyBRiG35ey8WA+H557Ox9k05f3JOaJzdFRegz5ONVIXvYhihQWmkRMh9oPcX+UUg==; 31:iwevEuDaa20CSuLO37zYAkSTMqblmq9+H8qlYWd/3wkPKMjHkU2SrXusczWH9lTzGLH8p7IuX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C7Y7q21Z/AMiR6P+3Jb1U0gWsh2NbLvbaspn5bE8RbKbaWTHzx0ektbg0BAA== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; 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)(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); 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:BP54Ksltb7+yL6QR5gwPdaeAR+YlbqV/qL8yDA1wd?= =?us-ascii?Q?na+PYxxwOBkzSXMISMMnIbOCHQ0Czjg0UFZY4qoLL/yNJukK1IStIqrC0ET2?= =?us-ascii?Q?C5XUO50MtKEWlPcwFku3b2quYsggIeXp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owYxJu7h6L7L1ZhV14GFjyKk2HPZM4gptohBQs4S0/WkVwa5xiTSfIS?= =?us-ascii?Q?L7m/h4cNYLuNVFDvTiVyTWxhB5uAC2pEfLZTjIm/BCDfys25rA0OooJW24qf?= =?us-ascii?Q?IAzUQ7QnNlH1yabq3O60WYycqGF4puuugUHeoWnVVDceexmwX79iYUja9Rvx?= =?us-ascii?Q?bifgAa1vD5bjUht17QhPU3uWJUO8jiFbWzAtDVbpGE1TUrvW12cqx83xzgFL?= =?us-ascii?Q?laruRDvf1ulDygbr3dJDO68I1+WV7gNuFDi6dvD2+1twYIup+UYwv9GojCke?= =?us-ascii?B?dz09?= X-Microsoft-Antispam-Message-Info: EtwTUK14wQLIG3Y0FeaRHBaTmWWx37akI5sRVEulDx/j6HbPVUPIEK2GrzainScPR6+Wqo8aB9l7TOz6jhCeSyRfLxWMOWXnmD9vIW+xmj8JiR35T583D08+X+dLyfKr34gykkEOqvzoZYkMW5HnDfxEFqrhlUNyaB9kf+M0t4Zy5M8gYo+oxX/gHcjNIqRRp7FCdvKDEFFdltKIFS/8B0OuEIwmAoRIiqzT93elLFh+kMMO9Dec154sXua1nMZ/s+Q0Kmve18TP0H0Se64Vtg1AE7MTxmOrTGyzj+ArI56rLjGLqam9by7d3BKsCPf/V1szqBVzJgYvSK/ebLQ7fPSXuY9BtJEReVmn/uZYEpo= X-Microsoft-Exchange-Diagnostics: 1; SN6PR07MB4910; 6:3OO4y3IdVTlVtAEs9KZD0ljd6qaTm/jcrJA3KsZf0ZqDMDTf3MXIqDr8u/27uKoFRZxsXjjjCldAGa1KcZUO67L+Rb1m4vdyBxWIPYYl2CYFA6SDIf84ro2ArqVBU8gMZNUks7IETKbML0sx4C52lHQjCo7NYC+C+3mHdhFk3t3XymYX9LWvh22tdmUY4YrBdo80ZnJS/cAyegHGNGIq3dsWnsVr2sBDzvw/GCPwOAqPUU6/tVOTx6SrjmXfS6SbOz58yiLIRxl/eYm/xYpkvxwJWSFMQt+YTzjg+pNHgjFIM0CiNZYRbj6cL3qaNMATPqd42nDynE8F0ykzhBspjwblr9+MaHQjuPkoKu69lcUAQQhuf2zShgDp4jeV6Dm4Ud8uLVH1cCQlnayIq6pWL+AqM3G3IyNkdStskRLCk3uKPgvEPSqIMvjFWlvzYgHk6q79pY48YTZsB4dcg2OVPg==; 5:rDUBXAD1rnG83jILFHZSkexgMkd0c7loMbU7dlOIXEb11cz4oYP6GAKGfs/cxoN5tUna3SncgKeFv5t2kY9LQSMAdJSWEQ8B4ixHShTkiBJGvngsOdQE3v6hDB/DiZmvXPOyuDjiUPjCwrwV2GUMyIofRNMUJck9ephMfUdUYQQ=; 7:MgzQJQG7x/BBgcN7zGmR9Y+zsbYSYnlclZfbMLo+Wd+MI1YHMbNOOYzqSPZfB6hEjYHP10RB1pYFoYmmyttu+nfDlNYlDTLkOgKqFlx12XQujCjeb6tvtK18stb8yTPNcTtqxoam42B1BWWNvfM5R+uL+VEc5kPSub2mQDVi6uBy0ATdkFwQ5P3fXHytGnji+ziOliWqMLrWzDA//qRfGGuRj0zAnWVfe7i0jUu+WN1751IbwjtAaLQ+k+4kXJhb SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Oct 2018 13:00:29.8888 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 53d1799d-affb-416b-6f4a-08d62ac289a0 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 05/32] crypto/octeontx: add hardware init routine 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:00:36 -0000 Adding hardware init routine for OCTEON TX crypto device. A place holder is added for misc polling routine. That will be added in the further patches. 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 | 48 ++++++++++++ drivers/crypto/octeontx/otx_cryptodev_hw_access.h | 87 +++++++++++++++++++++ drivers/crypto/octeontx/otx_cryptodev_ops.c | 92 ++++++++++++++++++++++- 5 files changed, 228 insertions(+), 1 deletion(-) create mode 100644 drivers/crypto/octeontx/otx_cryptodev_hw_access.c diff --git a/drivers/crypto/octeontx/Makefile b/drivers/crypto/octeontx/Makefile index 12fec75..4582540 100644 --- a/drivers/crypto/octeontx/Makefile +++ b/drivers/crypto/octeontx/Makefile @@ -24,6 +24,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_ops.c # export include files diff --git a/drivers/crypto/octeontx/meson.build b/drivers/crypto/octeontx/meson.build index 6564090..eca1cf1 100644 --- a/drivers/crypto/octeontx/meson.build +++ b/drivers/crypto/octeontx/meson.build @@ -8,6 +8,7 @@ deps += ['bus_pci'] name = 'octeontx_crypto' sources = files('otx_cryptodev.c', + 'otx_cryptodev_hw_access.c', 'otx_cryptodev_ops.c') cflags += '-DCPT_MODEL=CRYPTO_OCTEONTX' diff --git a/drivers/crypto/octeontx/otx_cryptodev_hw_access.c b/drivers/crypto/octeontx/otx_cryptodev_hw_access.c new file mode 100644 index 0000000..99fe3cf --- /dev/null +++ b/drivers/crypto/octeontx/otx_cryptodev_hw_access.c @@ -0,0 +1,48 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2018 Cavium, Inc + */ +#include + +#include + +#include "otx_cryptodev_hw_access.h" + +#include "cpt_pmd_logs.h" + +static int +otx_cpt_vf_init(struct cpt_vf *cptvf) +{ + int ret = 0; + + CPT_LOG_DP_DEBUG("%s: %s done", cptvf->dev_name, __func__); + + return ret; +} + +void +otx_cpt_poll_misc(struct cpt_vf *cptvf) +{ + RTE_SET_USED(cptvf); +} + +int +otx_cpt_hw_init(struct cpt_vf *cptvf, void *pdev, void *reg_base, char *name) +{ + memset(cptvf, 0, sizeof(struct cpt_vf)); + + /* Bar0 base address */ + cptvf->reg_base = reg_base; + strncpy(cptvf->dev_name, name, 32); + + cptvf->pdev = pdev; + + /* To clear if there are any pending mbox msgs */ + otx_cpt_poll_misc(cptvf); + + if (otx_cpt_vf_init(cptvf)) { + CPT_LOG_ERR("Failed to initialize CPT VF device"); + return -1; + } + + return 0; +} diff --git a/drivers/crypto/octeontx/otx_cryptodev_hw_access.h b/drivers/crypto/octeontx/otx_cryptodev_hw_access.h index 288ee41..1e1877c 100644 --- a/drivers/crypto/octeontx/otx_cryptodev_hw_access.h +++ b/drivers/crypto/octeontx/otx_cryptodev_hw_access.h @@ -5,6 +5,85 @@ #ifndef _OTX_CRYPTODEV_HW_ACCESS_H_ #define _OTX_CRYPTODEV_HW_ACCESS_H_ +#include + +#include + +#include "cpt_common.h" + +#define CPT_INTR_POLL_INTERVAL_MS (50) + +/* Default command queue length */ +#define DEFAULT_CMD_QCHUNKS 2 + +/* cpt instance */ +struct cpt_instance { + uint32_t queue_id; + uintptr_t rsvd; +}; + +struct command_chunk { + /** 128-byte aligned real_vaddr */ + uint8_t *head; + /** 128-byte aligned real_dma_addr */ + phys_addr_t dma_addr; +}; + +/** + * Command queue structure + */ +struct command_queue { + /** Command queue host write idx */ + uint32_t idx; + /** Command queue chunk */ + uint32_t cchunk; + /** Command queue head; instructions are inserted here */ + uint8_t *qhead; + /** Command chunk list head */ + struct command_chunk chead[DEFAULT_CMD_QCHUNKS]; +}; + +/** + * CPT VF device structure + */ +struct cpt_vf { + /** CPT instance */ + struct cpt_instance instance; + /** Register start address */ + uint8_t *reg_base; + /** Command queue information */ + struct command_queue cqueue; + /** Pending queue information */ + struct pending_queue pqueue; + /** Meta information per vf */ + struct cptvf_meta_info meta_info; + + /** Below fields are accessed only in control path */ + + /** Env specific pdev representing the pci dev */ + void *pdev; + /** Calculated queue size */ + uint32_t qsize; + /** Device index (0...CPT_MAX_VQ_NUM)*/ + uint8_t vfid; + /** VF type of cpt_vf_type_t (SE_TYPE(2) or AE_TYPE(1) */ + uint8_t vftype; + /** VF group (0 - 8) */ + uint8_t vfgrp; + /** Operating node: Bits (46:44) in BAR0 address */ + uint8_t node; + + /** VF-PF mailbox communication */ + + /** Flag if acked */ + bool pf_acked; + /** Flag if not acked */ + bool pf_nacked; + + /** Device name */ + char dev_name[32]; +} __rte_cache_aligned; + /* * CPT Registers map for 81xx */ @@ -44,4 +123,12 @@ ((a) & 0x1) + 0x100000ll * (b) + \ 8ll * ((c) & 0x1)) +/* VF HAL functions */ + +void +otx_cpt_poll_misc(struct cpt_vf *cptvf); + +int +otx_cpt_hw_init(struct cpt_vf *cptvf, void *pdev, void *reg_base, char *name); + #endif /* _OTX_CRYPTODEV_HW_ACCESS_H_ */ diff --git a/drivers/crypto/octeontx/otx_cryptodev_ops.c b/drivers/crypto/octeontx/otx_cryptodev_ops.c index 1b5f108..3bf6cd2 100644 --- a/drivers/crypto/octeontx/otx_cryptodev_ops.c +++ b/drivers/crypto/octeontx/otx_cryptodev_ops.c @@ -2,14 +2,104 @@ * Copyright(c) 2018 Cavium, Inc */ +#include +#include #include +#include + +#include "cpt_pmd_logs.h" #include "otx_cryptodev.h" +#include "otx_cryptodev_hw_access.h" #include "otx_cryptodev_ops.h" +/* Alarm routines */ + +static void +otx_cpt_alarm_cb(void *arg) +{ + struct cpt_vf *cptvf = arg; + otx_cpt_poll_misc(cptvf); + rte_eal_alarm_set(CPT_INTR_POLL_INTERVAL_MS * 1000, + otx_cpt_alarm_cb, cptvf); +} + +static int +otx_cpt_periodic_alarm_start(void *arg) +{ + return rte_eal_alarm_set(CPT_INTR_POLL_INTERVAL_MS * 1000, + otx_cpt_alarm_cb, arg); +} + int otx_cpt_dev_create(struct rte_cryptodev *c_dev) { - RTE_SET_USED(c_dev); + struct rte_pci_device *pdev = RTE_DEV_TO_PCI(c_dev->device); + struct cpt_vf *cptvf = NULL; + void *reg_base; + char dev_name[32]; + int ret; + + if (pdev->mem_resource[0].phys_addr == 0ULL) + return -EIO; + + /* for secondary processes, we don't initialise any further as primary + * has already done this work. + */ + if (rte_eal_process_type() != RTE_PROC_PRIMARY) + return 0; + + cptvf = rte_zmalloc_socket("otx_cryptodev_private_mem", + sizeof(struct cpt_vf), RTE_CACHE_LINE_SIZE, + rte_socket_id()); + + if (cptvf == NULL) { + CPT_LOG_ERR("Cannot allocate memory for device private data"); + return -ENOMEM; + } + + snprintf(dev_name, 32, "%02x:%02x.%x", + pdev->addr.bus, pdev->addr.devid, pdev->addr.function); + + reg_base = pdev->mem_resource[0].addr; + if (!reg_base) { + CPT_LOG_ERR("Failed to map BAR0 of %s", dev_name); + ret = -ENODEV; + goto fail; + } + + ret = otx_cpt_hw_init(cptvf, pdev, reg_base, dev_name); + if (ret) { + CPT_LOG_ERR("Failed to init cptvf %s", dev_name); + ret = -EIO; + goto fail; + } + + /* Start off timer for mailbox interrupts */ + otx_cpt_periodic_alarm_start(cptvf); + + c_dev->dev_ops = NULL; + + c_dev->enqueue_burst = NULL; + c_dev->dequeue_burst = NULL; + + c_dev->feature_flags = RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO | + RTE_CRYPTODEV_FF_HW_ACCELERATED | + RTE_CRYPTODEV_FF_SYM_OPERATION_CHAINING | + RTE_CRYPTODEV_FF_IN_PLACE_SGL | + RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT | + RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT; + + /* Save dev private data */ + c_dev->data->dev_private = cptvf; + return 0; + +fail: + if (cptvf) { + /* Free private data allocated */ + rte_free(cptvf); + } + + return ret; } -- 2.7.4