From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR02-HE1-obe.outbound.protection.outlook.com (mail-eopbgr10054.outbound.protection.outlook.com [40.107.1.54]) by dpdk.org (Postfix) with ESMTP id 311C74F91 for ; Mon, 22 Oct 2018 15:31:06 +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=ZZ4wOPIDlEDox9xsJiNwq+bfObTDcM+ZLMX/wrdJjQs=; b=P6Q6lUzY2F1oQIgNj0d8mGpMxWlKMw/DAheGwJHzSt27hSJj1NDzrtdGyWIf01cAG0LNp6NWRlpoUXEAl4/3zViUVg/RoNPHSuiMaHpL+XuDPNsQG7KUeWSgzHg1HbjkzMq4MMoXXtYw1PyAdZQ7G21TDujO8lla5T6BQS3jkDY= Received: from HE1PR04MB1530.eurprd04.prod.outlook.com (10.164.48.20) by HE1PR04MB1433.eurprd04.prod.outlook.com (10.163.175.155) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1250.22; Mon, 22 Oct 2018 13:31:04 +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 13:31:04 +0000 From: Gagandeep Singh To: "dev@dpdk.org" , Akhil Goyal CC: Gagandeep Singh , Hemant Agrawal Thread-Topic: [PATCH v3 02/15] crypto/caam_jr: add HW tuning options Thread-Index: AQHUagt7MtqQ8Oit/UCWMLxIwAdxeQ== Date: Mon, 22 Oct 2018 13:31:04 +0000 Message-ID: <20181022133021.11264-3-g.singh@nxp.com> References: <20181012144055.9461-1-g.singh@nxp.com> <20181022133021.11264-1-g.singh@nxp.com> In-Reply-To: <20181022133021.11264-1-g.singh@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: BM1PR0101CA0016.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:18::26) To HE1PR04MB1530.eurprd04.prod.outlook.com (2a01:111:e400:59a8::20) x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [14.142.187.166] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; HE1PR04MB1433; 6:3LRAdNohz+AYPk/g7ZMiRhCOaQBiGIxlIa4pqrjjYQnDn6Rq3+a2zIiqqWqNLP5ORmaAU0h/M/numsAmLXuJ+9o1BshIO1rbfNUmNzoll6zKXLLpJ06BzfTIj6tGMpZIEgfPwwny4a1PvdBSvqqYmPk6mmRywvkfY7S+65/0V6lXzPn3BIPxAPVJC+gCHWN8EK4SVEHquGUIWckon2O0Z3Qa2KtY90qG7ui3arhKnE/+qVQ4XUiZdTNjS+RSqGSlYdcdiaqDWDykbE7s1PO5FDyC7QH1NrN55h8F8DqL0XjbsTezESsgnZ4imaA2FjVfGuUz6BJiIAE/uhu4e0UOC4urg+ukJJNkgQuY+SHEqOG0mcykn3WEgPfaSuwXryUtzb6vkjRNLcd/jeDPWWrHQAWaalxGkklTuQ9x+/7SRWwp5q4DxczMwGaeVCKUICmFzdT/PSf6XGc4gSTV2j8T3A==; 5:ISOE9WYvg2lvXh5wVPjdrIwFMU7YeXLK7AQFkPn3onn9Cd017cx9QAOfsdzjyQSOTRRlRxb0xDsG9hWomDoZysbQ7H9fYOvxtOjhTJcXbvtIj2CP0eNI58HPs0Ao33YiS/UMrYHQbdTlqIud0RiDz/oK3qq9tTGYRp9KLd/l+VM=; 7:ctOQ8S/DjpdBGRXmzaXdtLyvOGQ9vm6yMZ+b8pwO/9sOJgB9DuXNEYkrhLXZuFg6JlMaWQxIFHhc5bwDgnDURGffOth4hjwtoZo5Dp+tbs/npcclHd5/4n8JY2w09wPGynpvhmYhtXYzvqIKG7SPbpvSFNgRWZ/jZzkmy7MYBPVvdwtFRDvUih4roftsx5NcRi35I63r7tyIE9YvXUvDjrWPzvDcKb77OGnh6iVZxhKH5CSjWrHc+YGN/spItnvB x-ms-office365-filtering-correlation-id: 077a6ac9-c687-496f-5d0d-08d638229d5a 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:HE1PR04MB1433; x-ms-traffictypediagnostic: HE1PR04MB1433: authentication-results: spf=none (sender IP is ) smtp.mailfrom=G.Singh@nxp.com; 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)(3002001)(10201501046)(3231355)(944501410)(52105095)(93006095)(93001095)(6055026)(148016)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(201708071742011)(7699051)(76991095); SRVR:HE1PR04MB1433; BCL:0; PCL:0; RULEID:; SRVR:HE1PR04MB1433; x-forefront-prvs: 08331F819E x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(136003)(366004)(396003)(376002)(346002)(39860400002)(199004)(189003)(6636002)(386003)(6506007)(25786009)(4326008)(5660300001)(2900100001)(316002)(3846002)(6116002)(1076002)(53936002)(78486010)(71200400001)(71190400001)(6512007)(36756003)(86362001)(66066001)(186003)(97736004)(5250100002)(2501003)(68736007)(52116002)(102836004)(486006)(446003)(8676002)(81156014)(81166006)(26005)(6486002)(7736002)(305945005)(2906002)(6436002)(76176011)(99286004)(256004)(14444005)(478600001)(72206003)(55236004)(14454004)(8936002)(105586002)(106356001)(110136005)(11346002)(2616005)(476003)(54906003); DIR:OUT; SFP:1101; SCL:1; SRVR:HE1PR04MB1433; 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: Ojr5/6zKmK2XPliv7lSdOXAVnRo+o7dVoPP62bOpPjcNspHy8k/dffNaWwJXlM62kqRWiuC/pMGbP8s3qjIJOnac9M2NrdrZYg0KSo4ELrpyoCzsi/Qb39SCDSwTFsXD+LGx4W0HHA8L+IOlPlW74I3FbgErtLN06lzoy79I9icZM9ijJXD4vkvY+f3fB5tJVAbBDSHv478dF0ZCFMqBF1VNtVhajQIPBQjaKfs/bpYk3IGR1eG4JYnX+mvwQuDzHSCnmGt03dyo7e+q9NW3Ec1TxmT6f1gh7TEyG2ngoTsIT5jabGmZ6nILKcBOVdWGTDVianyB2QeVeu0zRKdWBavtpIjC0h8jKKBT87hFXxU= 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: 077a6ac9-c687-496f-5d0d-08d638229d5a X-MS-Exchange-CrossTenant-originalarrivaltime: 22 Oct 2018 13:31:04.7959 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR04MB1433 Subject: [dpdk-dev] [PATCH v3 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 13:31:06 -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..e7855cee6 --- /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 + +#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 + +typedef uint64_t dma_addr_t; + +#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