From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on0072.outbound.protection.outlook.com [104.47.36.72]) by dpdk.org (Postfix) with ESMTP id 951E62C36 for ; Fri, 20 Jul 2018 20:42:47 +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=goafOMky+5yJ2q4rYsfpd2ld6xHT0U4nGlZvi67iA0M=; b=dApAQH/htfY6thF8trn3Oovtkf15awual49WtJnZ24Y4ahN8oQcRYVIAwNMBgoSzv5LAkK7DiLC4lHpLSiAtW8ddr1iGZDepwq86bfjJ1rGIMCtKBtH8i5RJl8GnY9NtyKDT/bcDILKNb8jN9NrYmFCC1eI1LazOw1L7F7t2sgc= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Ashish.Gupta@cavium.com; Received: from hyd1agupta-dt.caveonetworks.com (115.113.156.2) by BN6PR07MB3057.namprd07.prod.outlook.com (2603:10b6:404:a8::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.973.16; Fri, 20 Jul 2018 18:42:44 +0000 From: Ashish Gupta To: pablo.de.lara.guarch@intel.com Cc: dev@dpdk.org, narayanaprasad.athreya@cavium.com, mahipal.challa@cavium.com, Ashish Gupta , Shally Verma , Sunila Sahu Date: Sat, 21 Jul 2018 00:34:43 +0530 Message-Id: <20180720190447.7979-3-Ashish.Gupta@caviumnetworks.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180720190447.7979-1-Ashish.Gupta@caviumnetworks.com> References: <20180720190447.7979-1-Ashish.Gupta@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [115.113.156.2] X-ClientProxiedBy: BM1PR01CA0083.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:1::23) To BN6PR07MB3057.namprd07.prod.outlook.com (2603:10b6:404:a8::11) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: eaa6d94d-1047-4549-4085-08d5ee7095c9 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(4534165)(7168020)(4627221)(201703031133081)(201702281549075)(8990107)(5600053)(711020)(2017052603328)(7153060)(7193020); SRVR:BN6PR07MB3057; X-Microsoft-Exchange-Diagnostics: 1; BN6PR07MB3057; 3:Yrr1H6buJvA/ghJuz/36fIRiXaSuovD+FT8tUEPxxWChKOkY1C0BzMPWUzjP1vniS1u2w7HRVixY0yGXK4fKfn1+P4ywVeLKJY81ActEULBAUxrvNg5oGoRWhSyuoysXdNOOMt+zqltPFQWWJzNSO+8QfXQwREN8Oea0FcvxW56CJF4p+/xF6Bwlo3Ly1WbiVU/63/z+oWcQve8duErsFUHBHFENk66QtGQ3ItW1DuKo7hchToY3go0RhpSs3oVt; 25:vz0gXZ2Qyib+9/jFqTz4K4KuB/Yscayd1fjDuk2mKoqvjKVQsjx/gkTfnbCLZz1frzwKYKQDQ6gjkhhvjP0g4FvjdsqOQcerHa3xK53C4pSx0pclJXsSD0h2lTcwYiyerEh6uRzliRQa8EERl0vUnxupRxPnFitBmafGeFwRi3FWl5JvYepXIY1md6tQ1KlnDfLjYv/1DLhrUVf2rX6dfoLSlc54W9/cUFdmT366q7Jty6L8AkqwfwxmpFn4PxJSHME5fIJhj8oSrd466oB4O8mCiVPvkZHBeGr7R8K0GBhSX+CEfNh2vtjcvDUW4WPDo/Ve3inap2xh4G9MkJ4Omw==; 31:cBQZeqY6fgqoS7D+dqttnO21RDwAE/LUah6FiM4/2KcIsrZ7kHXm45YQnjFQpnCPBvg7ixMalt1aLhs/WEYk7Xfy95qmuJ4vOqCotOqITTf8C5cPrWO6Q59EO20S+8+JRlUz31AyLFUdGk70/MRh8jbx5rjuK1hrTJE52yx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-Test: UriScan:; X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3231311)(944501410)(52105095)(3002001)(93006095)(10201501046)(149027)(150027)(6041310)(20161123564045)(20161123558120)(20161123562045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011)(7699016); SRVR:BN6PR07MB3057; BCL:0; PCL:0; RULEID:; SRVR:BN6PR07MB3057; X-Forefront-PRVS: 073966E86B X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(136003)(366004)(346002)(396003)(39860400002)(376002)(199004)(189003)(186003)(486006)(107886003)(956004)(476003)(2616005)(26005)(6512007)(446003)(16526019)(8936002)(81156014)(97736004)(81166006)(55236004)(7736002)(11346002)(8676002)(72206003)(48376002)(4326008)(2351001)(2361001)(25786009)(6486002)(16586007)(54906003)(53416004)(50466002)(316002)(105586002)(36756003)(106356001)(42882007)(478600001)(68736007)(69596002)(14444005)(5660300001)(6916009)(66066001)(50226002)(47776003)(305945005)(76176011)(1076002)(6506007)(2906002)(6116002)(386003)(53936002)(52116002)(3846002)(51416003); DIR:OUT; SFP:1101; SCL:1; SRVR:BN6PR07MB3057; H:hyd1agupta-dt.caveonetworks.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; BN6PR07MB3057; 23:iclbWHRdRl6PYDNnVC/Cfg78bdyfdC8UktRAweaKX?= =?us-ascii?Q?sZM8tCpelK8ED6IC1N/ADu1CIIHCNcSEU522wCTelc9kr9aRDEXnwam1IWzS?= =?us-ascii?Q?bFH15Qa1B9SpYNAXUxg+kjjP9tEsxbWl/3n0x3Gd96915sl6XgChfUfCfG3C?= =?us-ascii?Q?AHLC5kY1w4pCTn13LYntb3O3JRZsEPXQFmCNY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Y31yQL4zSWEIlWc+xm44NHjZpLznqk3nwOZejz0IT9qD+D0ff5KsTTrvQJLfCmuWzQ2h3kzAtddISBquIfCPQhUcQ7wgnADNOaDk2Nf8wr2xl4s5EmhiEoth/AHFh4VTkxaYD4l/fovTKXIGB8cgcpENh65PY8drIuDWetYuUd486LGdIx5rqauXxoPswZGpw55UjVsN+4CZ43JvbDJ4EB5TGQ==; 5:iyVnkczGEDPb7wWGFXkbI1gLuqL4hVnacINLZAP1PeJ3yUg5q6rp9VsG2GWwxNfWDU9fXckBnfjQz4ug3GWaHTpnLj8zwg6xJkU/gnSfTaEgUmNCcH/NJmtqG1JCGw4InAb+F3psddWVPAu0U4Z8LwTRfDN3crXeP/SrFIJ1ETs=; 7:c9f4cwMDGrhDS4mLL2ZqYuozQfrh6+XYKvfzjORRDV7Lw88wD6iTeYUBxiaDTmR+v1LZ3BqECBn1cvOQQ6vYSyqs4NcJYZzw1GRihAdhShfxufRl7e7rQfB/cH5cvTpSucIwA2hZiGTNEZgH/BoFqlrR411ndowtO1jDJOPz5+LQNobDGkqEgHwHZnD3ieCNXD0HG9S3p9dM5u3eQa3t8ksH6EL2Eq7CG/k9kBIiiHDarkt6X9szfODoEw7QczNK SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jul 2018 18:42:44.0785 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: eaa6d94d-1047-4549-4085-08d5ee7095c9 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR07MB3057 Subject: [dpdk-dev] [PATCH v3 2/6] compress/octeontx: add device setup PMD ops 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, 20 Jul 2018 18:42:48 -0000 Add compression PMD device and queue pair setup ops. Signed-off-by: Ashish Gupta Signed-off-by: Shally Verma Signed-off-by: Sunila Sahu --- drivers/compress/octeontx/otx_zip.c | 71 +++++++++ drivers/compress/octeontx/otx_zip.h | 57 ++++++- drivers/compress/octeontx/otx_zip_pmd.c | 253 ++++++++++++++++++++++++++++++++ 3 files changed, 379 insertions(+), 2 deletions(-) diff --git a/drivers/compress/octeontx/otx_zip.c b/drivers/compress/octeontx/otx_zip.c index 4a5591c97..255b095de 100644 --- a/drivers/compress/octeontx/otx_zip.c +++ b/drivers/compress/octeontx/otx_zip.c @@ -18,6 +18,77 @@ zip_reg_write64(uint8_t *hw_addr, uint64_t offset, uint64_t val) *(uint64_t *)(base + offset) = val; } +static void +zip_q_enable(struct zipvf_qp *qp) +{ + zip_vqx_ena_t que_ena; + + /*ZIP VFx command queue init*/ + que_ena.u = 0ull; + que_ena.s.ena = 1; + + zip_reg_write64(qp->vf->vbar0, ZIP_VQ_ENA, que_ena.u); + rte_wmb(); +} + +/* initialize given qp on zip device */ +int +zipvf_q_init(struct zipvf_qp *qp) +{ + zip_vqx_sbuf_addr_t que_sbuf_addr; + + uint64_t size; + void *cmdq_addr; + uint64_t iova; + struct zipvf_cmdq *cmdq = &qp->cmdq; + struct zip_vf *vf = qp->vf; + + /* allocate and setup instruction queue */ + size = ZIP_MAX_CMDQ_SIZE; + size = ZIP_ALIGN_ROUNDUP(size, ZIP_CMDQ_ALIGN); + + cmdq_addr = rte_zmalloc(qp->name, size, ZIP_CMDQ_ALIGN); + if (cmdq_addr == NULL) + return -1; + + cmdq->sw_head = (uint64_t *)cmdq_addr; + cmdq->va = (uint8_t *)cmdq_addr; + iova = rte_mem_virt2iova(cmdq_addr); + + cmdq->iova = iova; + + que_sbuf_addr.u = 0ull; + que_sbuf_addr.s.ptr = (cmdq->iova >> 7); + zip_reg_write64(vf->vbar0, ZIP_VQ_SBUF_ADDR, que_sbuf_addr.u); + + zip_q_enable(qp); + + memset(cmdq->va, 0, ZIP_MAX_CMDQ_SIZE); + rte_spinlock_init(&cmdq->qlock); + + return 0; +} + +int +zipvf_q_term(struct zipvf_qp *qp) +{ + struct zipvf_cmdq *cmdq = &qp->cmdq; + zip_vqx_ena_t que_ena; + struct zip_vf *vf = qp->vf; + + if (cmdq->va != NULL) { + memset(cmdq->va, 0, ZIP_MAX_CMDQ_SIZE); + rte_free(cmdq->va); + } + + /*Disabling the ZIP queue*/ + que_ena.u = 0ull; + zip_reg_write64(vf->vbar0, ZIP_VQ_ENA, que_ena.u); + + return 0; +} + + int zipvf_create(struct rte_compressdev *compressdev) { diff --git a/drivers/compress/octeontx/otx_zip.h b/drivers/compress/octeontx/otx_zip.h index 8a58f31f8..1289919cb 100644 --- a/drivers/compress/octeontx/otx_zip.h +++ b/drivers/compress/octeontx/otx_zip.h @@ -77,8 +77,54 @@ int octtx_zip_logtype_driver; ZIP_PMD_LOG(INFO, fmt, ## args) #define ZIP_PMD_ERR(fmt, args...) \ ZIP_PMD_LOG(ERR, fmt, ## args) -#define ZIP_PMD_WARN(fmt, args...) \ - ZIP_PMD_LOG(WARNING, fmt, ## args) + +/* resources required to process stream */ +enum { + RES_BUF = 0, + CMD_BUF, + HASH_CTX_BUF, + DECOMP_CTX_BUF, + IN_DATA_BUF, + OUT_DATA_BUF, + HISTORY_DATA_BUF, + MAX_BUFS_PER_STREAM +} NUM_BUFS_PER_STREAM; + + +struct zipvf_qp; + + +/** + * ZIP instruction Queue + */ +struct zipvf_cmdq { + rte_spinlock_t qlock; + /* queue lock */ + uint64_t *sw_head; + /* pointer to start of 8-byte word length queue-head */ + uint8_t *va; + /* pointer to instruction queue virtual address */ + rte_iova_t iova; + /* iova addr of cmdq head*/ +}; + +/** + * ZIP device queue structure + */ +struct zipvf_qp { + struct zipvf_cmdq cmdq; + /* Hardware instruction queue structure */ + struct rte_ring *processed_pkts; + /* Ring for placing processed packets */ + struct rte_compressdev_stats qp_stats; + /* Queue pair statistics */ + uint16_t id; + /* Queue Pair Identifier */ + const char *name; + /* Unique Queue Pair Name */ + struct zip_vf *vf; + /* pointer to device, queue belongs to */ +} __rte_cache_aligned; /** * ZIP VF device structure. @@ -104,6 +150,13 @@ zipvf_create(struct rte_compressdev *compressdev); int zipvf_destroy(struct rte_compressdev *compressdev); +int +zipvf_q_init(struct zipvf_qp *qp); + +int +zipvf_q_term(struct zipvf_qp *qp); + + uint64_t zip_reg_read64(uint8_t *hw_addr, uint64_t offset); diff --git a/drivers/compress/octeontx/otx_zip_pmd.c b/drivers/compress/octeontx/otx_zip_pmd.c index b2cb115e0..f6285508a 100644 --- a/drivers/compress/octeontx/otx_zip_pmd.c +++ b/drivers/compress/octeontx/otx_zip_pmd.c @@ -11,8 +11,261 @@ #include "otx_zip.h" +static const struct rte_compressdev_capabilities + octtx_zip_pmd_capabilities[] = { + { .algo = RTE_COMP_ALGO_DEFLATE, + /* Deflate */ + .comp_feature_flags = RTE_COMP_FF_HUFFMAN_FIXED | + RTE_COMP_FF_HUFFMAN_DYNAMIC, + /* Non sharable Priv XFORM and Stateless */ + .window_size = { + .min = 1, + .max = 14, + .increment = 1 + /* size supported 2^1 to 2^14 */ + }, + }, + RTE_COMP_END_OF_CAPABILITIES_LIST() +}; + +/** Configure device */ +static int +zip_pmd_config(struct rte_compressdev *dev, + struct rte_compressdev_config *config) +{ + int nb_streams; + char res_pool[RTE_MEMZONE_NAMESIZE]; + struct zip_vf *vf; + struct rte_mempool *zip_buf_mp; + + if (!config || !dev) + return -EIO; + + vf = (struct zip_vf *)(dev->data->dev_private); + + /* create pool with maximum numbers of resources + * required by streams + */ + + /* use common pool for non-shareable priv_xform and stream */ + nb_streams = config->max_nb_priv_xforms + config->max_nb_streams; + + snprintf(res_pool, RTE_MEMZONE_NAMESIZE, "octtx_zip_res_pool%u", + dev->data->dev_id); + + /** TBD Should we use the per core object cache for stream resources */ + zip_buf_mp = rte_mempool_create( + res_pool, + nb_streams * MAX_BUFS_PER_STREAM, + ZIP_BUF_SIZE, + 0, + 0, + NULL, + NULL, + NULL, + NULL, + SOCKET_ID_ANY, + 0); + + if (zip_buf_mp == NULL) { + ZIP_PMD_ERR( + "Failed to create buf mempool octtx_zip_res_pool%u", + dev->data->dev_id); + return -1; + } + + vf->zip_mp = zip_buf_mp; + + return 0; +} + +/** Start device */ +static int +zip_pmd_start(__rte_unused struct rte_compressdev *dev) +{ + return 0; +} + +/** Stop device */ +static void +zip_pmd_stop(__rte_unused struct rte_compressdev *dev) +{ + +} + +/** Close device */ +static int +zip_pmd_close(struct rte_compressdev *dev) +{ + if (dev == NULL) + return -1; + + struct zip_vf *vf = (struct zip_vf *)dev->data->dev_private; + rte_mempool_free(vf->zip_mp); + + return 0; +} + +/** Get device statistics */ +static void +zip_pmd_stats_get(struct rte_compressdev *dev, + struct rte_compressdev_stats *stats) +{ + int qp_id; + + for (qp_id = 0; qp_id < dev->data->nb_queue_pairs; qp_id++) { + struct zipvf_qp *qp = dev->data->queue_pairs[qp_id]; + + stats->enqueued_count += qp->qp_stats.enqueued_count; + stats->dequeued_count += qp->qp_stats.dequeued_count; + + stats->enqueue_err_count += qp->qp_stats.enqueue_err_count; + stats->dequeue_err_count += qp->qp_stats.dequeue_err_count; + } +} + +/** Reset device statistics */ +static void +zip_pmd_stats_reset(struct rte_compressdev *dev) +{ + int qp_id; + + for (qp_id = 0; qp_id < dev->data->nb_queue_pairs; qp_id++) { + struct zipvf_qp *qp = dev->data->queue_pairs[qp_id]; + memset(&qp->qp_stats, 0, sizeof(qp->qp_stats)); + } +} + +/** Get device info */ +static void +zip_pmd_info_get(struct rte_compressdev *dev, + struct rte_compressdev_info *dev_info) +{ + struct zip_vf *vf = (struct zip_vf *)dev->data->dev_private; + + if (dev_info != NULL) { + dev_info->driver_name = dev->device->driver->name; + dev_info->feature_flags = dev->feature_flags; + dev_info->capabilities = octtx_zip_pmd_capabilities; + dev_info->max_nb_queue_pairs = vf->max_nb_queue_pairs; + } +} + +/** Release queue pair */ +static int +zip_pmd_qp_release(struct rte_compressdev *dev, uint16_t qp_id) +{ + struct zipvf_qp *qp = dev->data->queue_pairs[qp_id]; + + if (qp != NULL) { + zipvf_q_term(qp); + + if (qp->processed_pkts) + rte_ring_free(qp->processed_pkts); + + rte_free(qp); + dev->data->queue_pairs[qp_id] = NULL; + } + return 0; +} + +/** Create a ring to place process packets on */ +static struct rte_ring * +zip_pmd_qp_create_processed_pkts_ring(struct zipvf_qp *qp, + unsigned int ring_size, int socket_id) +{ + struct rte_ring *r; + + r = rte_ring_lookup(qp->name); + if (r) { + if (rte_ring_get_size(r) >= ring_size) { + ZIP_PMD_INFO("Reusing existing ring %s for processed" + " packets", qp->name); + return r; + } + + ZIP_PMD_ERR("Unable to reuse existing ring %s for processed" + " packets", qp->name); + return NULL; + } + + return rte_ring_create(qp->name, ring_size, socket_id, + RING_F_EXACT_SZ); +} + +/** Setup a queue pair */ +static int +zip_pmd_qp_setup(struct rte_compressdev *dev, uint16_t qp_id, + uint32_t max_inflight_ops, int socket_id) +{ + struct zipvf_qp *qp = NULL; + struct zip_vf *vf; + char *name; + int ret; + + if (!dev) + return -1; + + vf = (struct zip_vf *) (dev->data->dev_private); + + /* Free memory prior to re-allocation if needed. */ + if (dev->data->queue_pairs[qp_id] != NULL) { + ZIP_PMD_INFO("Using existing queue pair %d ", qp_id); + return 0; + } + + name = rte_malloc(NULL, RTE_COMPRESSDEV_NAME_MAX_LEN, 0); + snprintf(name, RTE_COMPRESSDEV_NAME_MAX_LEN, + "zip_pmd_%u_qp_%u", + dev->data->dev_id, qp_id); + + /* Allocate the queue pair data structure. */ + qp = rte_zmalloc_socket(name, sizeof(*qp), + RTE_CACHE_LINE_SIZE, socket_id); + if (qp == NULL) + return (-ENOMEM); + + qp->name = name; + + /* Create completion queue upto max_inflight_ops */ + qp->processed_pkts = zip_pmd_qp_create_processed_pkts_ring(qp, + max_inflight_ops, socket_id); + if (qp->processed_pkts == NULL) + goto qp_setup_cleanup; + + qp->id = qp_id; + qp->vf = vf; + + ret = zipvf_q_init(qp); + if (ret < 0) + goto qp_setup_cleanup; + + dev->data->queue_pairs[qp_id] = qp; + + memset(&qp->qp_stats, 0, sizeof(qp->qp_stats)); + return 0; + +qp_setup_cleanup: + if (qp->processed_pkts) + rte_ring_free(qp->processed_pkts); + if (qp) + rte_free(qp); + return -1; +} + struct rte_compressdev_ops octtx_zip_pmd_ops = { + .dev_configure = zip_pmd_config, + .dev_start = zip_pmd_start, + .dev_stop = zip_pmd_stop, + .dev_close = zip_pmd_close, + + .stats_get = zip_pmd_stats_get, + .stats_reset = zip_pmd_stats_reset, + + .dev_infos_get = zip_pmd_info_get, + .queue_pair_setup = zip_pmd_qp_setup, + .queue_pair_release = zip_pmd_qp_release, }; static int -- 2.14.3