From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on0066.outbound.protection.outlook.com [104.47.1.66]) by dpdk.org (Postfix) with ESMTP id 0B1E41B274 for ; Mon, 22 Oct 2018 16:57:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lCYfONbPC1shvDIRf3dXT5D4mherp8sWa/olNX8MUfs=; b=wIZy3Q4DeS0Rg9id7t9IYOTIpZi69VLBw2I3UldbRWJmx0W+zir2PvmQ1P7oF8K0hMZjgTaHDLQjIzho18arpCARzvErm65v7ExN8CVWp5TqZJr+XoiortW+m4FCZYrq5e7cPPef3b6mjQCp+pBgNr47P9ak9/GCch+9xzPmd/I= Received: from HE1PR04MB1530.eurprd04.prod.outlook.com (10.164.48.20) by HE1PR04MB2105.eurprd04.prod.outlook.com (10.166.67.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1228.25; Mon, 22 Oct 2018 14:57:25 +0000 Received: from HE1PR04MB1530.eurprd04.prod.outlook.com ([fe80::95cd:198:d5c5:59a4]) by HE1PR04MB1530.eurprd04.prod.outlook.com ([fe80::95cd:198:d5c5:59a4%5]) with mapi id 15.20.1250.028; Mon, 22 Oct 2018 14:57:25 +0000 From: Gagandeep Singh To: "dev@dpdk.org" , Akhil Goyal CC: Gagandeep Singh , Hemant Agrawal Thread-Topic: [PATCH v5 02/15] crypto/caam_jr: add HW tuning options Thread-Index: AQHUaheLbiyWO1Oeik6t/+9zivE9Og== Date: Mon, 22 Oct 2018 14:57:25 +0000 Message-ID: <20181022145644.29277-3-g.singh@nxp.com> References: <20181022141657.4727-1-g.singh@nxp.com> <20181022145644.29277-1-g.singh@nxp.com> In-Reply-To: <20181022145644.29277-1-g.singh@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: BM1PR0101CA0067.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:19::29) To HE1PR04MB1530.eurprd04.prod.outlook.com (2a01:111:e400:59a8::20) authentication-results: spf=none (sender IP is ) smtp.mailfrom=G.Singh@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [14.142.187.166] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; HE1PR04MB2105; 6:+KCK0VQMaoOTbjhrNOlQmZZeUhrPu+pzSvT5LD/tfO8dWTnUhKHEhUFhQnkki/6H19KKpomLqgTDnCJ+lG4kuLOwK5gmd+36MP3ad0z6Ni4SYq5nM/Am/LZMl623C4rcli6UM3BhJhgJAS8a+7Z0oRW/NPrxQyTTlH+cnuwgRAdksl9Nwvmw1aCB35cNNFdAiQdG0pJrKyRrm/h4rWlaAVJ7Jsz7leATOQV+WYriEJ18/seSmgfnK2O6+dBql7mjS31ATeRWAHmKUUsFzKtWNP2Hcuqv2O0hgJMPzvcdJ43Cdm9wQ0csOnKv2Z1kYdo6Aq9fxMVtMhLiWibLFFkAhVLHDq0uFHuSUEE+mbu6Ng7vxkFelrm087mSyIHA/NE84XgpwEa1zS8OX+J3ClP/8Qm/xM4vZ9eKhhXqvOrTPnd61T7UjuIGNqO7yI3c7r5c3DLtHuvRDlJlspbqx40NzQ==; 5:xRnrZrFxkxfobA4NdCpQZijCtjMpvnbqThm3GHjvwbeK6Sak3LsxCN1Qb86drFmOpuIaUvU56BdcILhoRpmY9cM47Khm/i0zw3o5GAtXYWtr72uexRVwMBcTYtIJD43QsTVvfdkXvkNCWVqOndUg6QVMWIbf1fw4b61inSRUVf4=; 7:shy+UPs1YVn+WxKp5uFO3hnjhpWAXGxErbizbBz0F+yujtvEHftcd+uR4AolrhhyM6Im976M8cHDTEDYf/RQty+PunnP4oHuOtke9K39vR2w5gCX0cOFteECDWJi2pedcPyMfbx4f+mGpB4hemzEymzk1XeWtS+ra9qKw9Vm6keQwgnSnfZLsNmq8GhQpyCiLBrYhxw8uCHtPTBT684mUaE4GI+6LBh6FFk8xaIvgHaGUtWllIos71LyJ91l/0Ba x-ms-office365-filtering-correlation-id: 597a7e90-967d-48b0-1843-08d6382ead8a x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(5600074)(711020)(4618075)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:HE1PR04MB2105; x-ms-traffictypediagnostic: HE1PR04MB2105: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(185117386973197); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(93006095)(93001095)(10201501046)(3002001)(3231355)(944501410)(52105095)(6055026)(148016)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(201708071742011)(7699051)(76991095); SRVR:HE1PR04MB2105; BCL:0; PCL:0; RULEID:; SRVR:HE1PR04MB2105; x-forefront-prvs: 08331F819E x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(136003)(366004)(376002)(346002)(396003)(39860400002)(199004)(189003)(14454004)(52116002)(186003)(8676002)(386003)(7736002)(11346002)(478600001)(6506007)(36756003)(78486010)(66066001)(2900100001)(14444005)(2501003)(25786009)(5250100002)(97736004)(6636002)(316002)(5660300001)(68736007)(99286004)(71190400001)(53936002)(71200400001)(4326008)(476003)(54906003)(2616005)(110136005)(2906002)(106356001)(26005)(102836004)(256004)(6512007)(55236004)(76176011)(72206003)(446003)(6116002)(6486002)(486006)(3846002)(8936002)(305945005)(81156014)(81166006)(86362001)(1076002)(105586002)(6436002); DIR:OUT; SFP:1101; SCL:1; SRVR:HE1PR04MB2105; H:HE1PR04MB1530.eurprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: +1mFUzg/LUwkvxI4cxvx1+Y+JZB0rpZh82K3ZNEoLpXdB09XvYxuZ/3jbnYbTx8y3zBcJJrwWVJ0QX/bF8kUu5VUgWrlKFd5yKt7XnQwp+Hccl3J6K6UhrMM52j1F9uEM/8JysuiVpsv+G89YKZn3Wk0+zcefuwtLkTvzRMaV9O31I6zfG6f6+VaqocUtmhY649Hd/JUArAMFeQPuKBNWxGNqh7scLjhpRcsVExaJJ6U4dU4/pYtGgh6B7WCXoSZsCwCHVFHJZuErIL/Aqs0VSq7X6IUuc6JTQ+hcM2Bd/raxgrnllTMRgoYUjvItuCdRKfORqSO3hYFZNq4PgNigsi1RPNDXisL+VUAny5Avzg= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 597a7e90-967d-48b0-1843-08d6382ead8a X-MS-Exchange-CrossTenant-originalarrivaltime: 22 Oct 2018 14:57:25.6067 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR04MB2105 Subject: [dpdk-dev] [PATCH v5 02/15] crypto/caam_jr: add HW tuning options 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: Mon, 22 Oct 2018 14:57:28 -0000 caam_jr hardware can be tuned for multiple settings like ring depth, coalescing, notification types, cache size etc. These parameter can be used for performance tuning for various platforms. Signed-off-by: Gagandeep Singh Signed-off-by: Hemant Agrawal Acked-by: Akhil Goyal --- drivers/crypto/caam_jr/caam_jr_config.h | 207 ++++++++++++++++++++++++ 1 file changed, 207 insertions(+) create mode 100644 drivers/crypto/caam_jr/caam_jr_config.h diff --git a/drivers/crypto/caam_jr/caam_jr_config.h b/drivers/crypto/caam_= jr/caam_jr_config.h new file mode 100644 index 000000000..041187a84 --- /dev/null +++ b/drivers/crypto/caam_jr/caam_jr_config.h @@ -0,0 +1,207 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright 2017-2018 NXP + */ + +#ifndef CAAM_JR_CONFIG_H +#define CAAM_JR_CONFIG_H + +#include + +#include + +#ifdef RTE_LIBRTE_PMD_CAAM_JR_BE +#define CAAM_BYTE_ORDER __BIG_ENDIAN +#else +#define CAAM_BYTE_ORDER __LITTLE_ENDIAN +#endif + +#if RTE_BYTE_ORDER =3D=3D RTE_BIG_ENDIAN +#define CORE_BYTE_ORDER __BIG_ENDIAN +#else +#define CORE_BYTE_ORDER __LITTLE_ENDIAN +#endif + +#if CORE_BYTE_ORDER !=3D CAAM_BYTE_ORDER + +#define cpu_to_caam64 rte_cpu_to_be_64 +#define cpu_to_caam32 rte_cpu_to_be_32 +#else +#define cpu_to_caam64 +#define cpu_to_caam32 + +#endif + +/* + * SEC is configured to start work in polling mode, + * when configured for NAPI notification style. + */ +#define SEC_STARTUP_POLLING_MODE 0 +/* + * SEC is configured to start work in interrupt mode, + * when configured for NAPI notification style. + */ +#define SEC_STARTUP_INTERRUPT_MODE 1 + +/* + * SEC driver will use NAPI model to receive notifications + * for processed packets from SEC engine hardware: + * - IRQ for low traffic + * - polling for high traffic. + */ +#define SEC_NOTIFICATION_TYPE_NAPI 0 +/* + * SEC driver will use ONLY interrupts to receive notifications + * for processed packets from SEC engine hardware. + */ +#define SEC_NOTIFICATION_TYPE_IRQ 1 +/* + * SEC driver will use ONLY polling to receive notifications + * for processed packets from SEC engine hardware. + */ +#define SEC_NOTIFICATION_TYPE_POLL 2 + +/* + * SEC USER SPACE DRIVER related configuration. + */ + +/* + * Determines how SEC user space driver will receive notifications + * for processed packets from SEC engine. + * Valid values are: #SEC_NOTIFICATION_TYPE_POLL, #SEC_NOTIFICATION_TYPE_I= RQ + * and #SEC_NOTIFICATION_TYPE_NAPI. + */ +#define SEC_NOTIFICATION_TYPE SEC_NOTIFICATION_TYPE_POLL + +/* Maximum number of job rings supported by SEC hardware */ +#define MAX_SEC_JOB_RINGS 4 + +/* Maximum number of QP per job ring */ +#define RTE_CAAM_MAX_NB_SEC_QPS 1 + +/* + * Size of cryptographic context that is used directly in communicating + * with SEC device. SEC device works only with physical addresses. This + * is the maximum size for a SEC descriptor ( =3D 64 words). + */ +#define SEC_CRYPTO_DESCRIPTOR_SIZE 256 + +/* + * Size of job descriptor submitted to SEC device for each packet to + * be processed. + * Job descriptor contains 3 DMA address pointers: + * - to shared descriptor, to input buffer and to output buffer. + * The job descriptor contains other SEC specific commands as well: + * - HEADER command, SEQ IN PTR command SEQ OUT PTR command and opaque dat= a + * each measuring 4 bytes. + * Job descriptor size, depending on physical address representation: + * - 32 bit - size is 28 bytes - cacheline-aligned size is 64 bytes + * - 36 bit - size is 40 bytes - cacheline-aligned size is 64 bytes + * @note: Job descriptor must be cacheline-aligned to ensure efficient + * memory access. + * @note: If other format is used for job descriptor, then the size must b= e + * revised. + */ +#define SEC_JOB_DESCRIPTOR_SIZE 64 + +/* + * Size of one entry in the input ring of a job ring. + * Input ring contains pointers to job descriptors. + * The memory used for an input ring and output ring must be physically + * contiguous. + */ +#define SEC_JOB_INPUT_RING_ENTRY_SIZE sizeof(dma_addr_t) + +/* + * Size of one entry in the output ring of a job ring. + * Output ring entry is a pointer to a job descriptor followed by a 4 byte + * status word. + * The memory used for an input ring and output ring must be physically + * contiguous. + * @note If desired to use also the optional SEQ OUT indication in output = ring + * entries, + * then 4 more bytes must be added to the size. + */ +#define SEC_JOB_OUTPUT_RING_ENTRY_SIZE (SEC_JOB_INPUT_RING_ENTRY_SIZE + 4= ) + +/* + * DMA memory required for an input ring of a job ring. + */ +#define SEC_DMA_MEM_INPUT_RING_SIZE ((SEC_JOB_INPUT_RING_ENTRY_SIZE) *= \ + (SEC_JOB_RING_SIZE)) + +/* + * DMA memory required for an output ring of a job ring. + * Required extra 4 byte for status word per each entry. + */ +#define SEC_DMA_MEM_OUTPUT_RING_SIZE ((SEC_JOB_OUTPUT_RING_ENTRY_SIZE) = * \ + (SEC_JOB_RING_SIZE)) + +/* DMA memory required for a job ring, including both input and output rin= gs. */ +#define SEC_DMA_MEM_JOB_RING_SIZE ((SEC_DMA_MEM_INPUT_RING_SIZE) + \ + (SEC_DMA_MEM_OUTPUT_RING_SIZE)) + +/* + * When calling sec_init() UA will provide an area of virtual memory + * of size #SEC_DMA_MEMORY_SIZE to be used internally by the driver + * to allocate data (like SEC descriptors) that needs to be passed to + * SEC device in physical addressing and later on retrieved from SEC devi= ce. + * At initialization the UA provides specialized ptov/vtop functions/macr= os to + * translate addresses allocated from this memory area. + */ +#define SEC_DMA_MEMORY_SIZE ((SEC_DMA_MEM_JOB_RING_SIZE) * \ + (MAX_SEC_JOB_RINGS)) + +#define L1_CACHE_BYTES 64 + +/* SEC JOB RING related configuration. */ + +/* + * Configure the size of the JOB RING. + * The maximum size of the ring in hardware limited to 1024. + * However the number of packets in flight in a time interval of 1ms can + * be calculated from the traffic rate (Mbps) and packet size. + * Here it was considered a packet size of 64 bytes. + * + * @note Round up to nearest power of 2 for optimized update + * of producer/consumer indexes of each job ring + */ +#define SEC_JOB_RING_SIZE 512 + +/* + * Interrupt coalescing related configuration. + * NOTE: SEC hardware enabled interrupt + * coalescing is not supported on SEC version 3.1! + * SEC version 4.4 has support for interrupt + * coalescing. + */ + +#if SEC_NOTIFICATION_TYPE !=3D SEC_NOTIFICATION_TYPE_POLL + +#define SEC_INT_COALESCING_ENABLE 1 +/* + * Interrupt Coalescing Descriptor Count Threshold. + * While interrupt coalescing is enabled (ICEN=3D1), this value determines + * how many Descriptors are completed before raising an interrupt. + * + * Valid values for this field are from 0 to 255. + * Note that a value of 1 functionally defeats the advantages of interrupt + * coalescing since the threshold value is reached each time that a + * Job Descriptor is completed. A value of 0 is treated in the same + * manner as a value of 1. + */ +#define SEC_INTERRUPT_COALESCING_DESCRIPTOR_COUNT_THRESH 10 + +/* + * Interrupt Coalescing Timer Threshold. + * While interrupt coalescing is enabled (ICEN=3D1), this value determines= the + * maximum amount of time after processing a Descriptor before raising an + * interrupt. + * The threshold value is represented in units equal to 64 CAAM interface + * clocks. Valid values for this field are from 1 to 65535. + * A value of 0 results in behavior identical to that when interrupt + * coalescing is disabled. + */ +#define SEC_INTERRUPT_COALESCING_TIMER_THRESH 100 +#endif /* SEC_NOTIFICATION_TYPE_POLL */ + +#endif /* CAAM_JR_CONFIG_H */ --=20 2.17.1