From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR03-DB5-obe.outbound.protection.outlook.com (mail-eopbgr40069.outbound.protection.outlook.com [40.107.4.69]) by dpdk.org (Postfix) with ESMTP id BE9325F33 for ; Mon, 22 Oct 2018 16:17:39 +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=pcnHup/+4UP6D2vfsmUT70groo0B3TZ1R61bWiEzuCWQj0+ZV1Gf1NG/mRyKwFzNEdy+jWdzTNpqVrsUW/HoV7t8JwoLUW/cexKhJG8zn5emhbdaJ7Ak1OruhG8RD8+HklJ9QdcNdYwBBwKISwYMHlvo2gDg6jQPm6dVUN9nJvg= Received: from HE1PR04MB1530.eurprd04.prod.outlook.com (10.164.48.20) by HE1PR04MB1051.eurprd04.prod.outlook.com (10.162.26.148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1250.30; Mon, 22 Oct 2018 14:17:37 +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:17:37 +0000 From: Gagandeep Singh To: "dev@dpdk.org" , Akhil Goyal CC: Gagandeep Singh , Hemant Agrawal Thread-Topic: [PATCH v4 02/15] crypto/caam_jr: add HW tuning options Thread-Index: AQHUahH7XWQ4Tvq9zk65AWSi6Ua0mw== Date: Mon, 22 Oct 2018 14:17:37 +0000 Message-ID: <20181022141657.4727-3-g.singh@nxp.com> References: <20181022133021.11264-1-g.singh@nxp.com> <20181022141657.4727-1-g.singh@nxp.com> In-Reply-To: <20181022141657.4727-1-g.singh@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: BM1PR0101CA0025.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:1a::11) 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; HE1PR04MB1051; 6:u2Fd8nv/JQmM2G+JIRbd6D6sPFtSLiPOZ8upmqdSwDx5QnbwVxlI3TAr6hoqs9wVtoaN1+TxGifT2W5AhtKiaQ3bBkFcdXN+68gtO8x3HMW6y1jrOnwSNNCqTHm8uG5KUBFofcy5j78kHsxGNJ5eGzKyNeCo5wifmUbgylYJToiU0KO5m65RneQoP7y80L+BvUQ8o8XlSMkW1ycbUtKrJVEtvijwgi0RzPBH9bGEy2YZPJudv/ALphV5e7SzSCGF3A8TaU5v9pk4KqfiV7ODZt+4ILmOklIlLAYY3JqtbiFxj0aLq7uo66nBwdbWL42MfXPDXnLzYAD+Lh/ElP/dTFnPqtbOczi6X7NoJ9TbtUDuNIGuiG5ZM7JvKWT1b7GZLnDepp2Kzfd782DIbI2gE21K8zxvDkkNzBElC8M6uY9/iYlBa23NgEWUXK4dn15vGaDuTWjdruOFRdtNyl9new==; 5:PUnjbMiyG+W7Ry1DLaILM1S2sA+cVaPh84Lt8MQttIk65DEpzQD23/yjpYAOBsUoh5X/OH9a5d20UPx9zz0R6IxGcl7EB2TxUWsXkW4fRMLQyXDd00Q/IhuN/XNp2QPWI/VVr4S4hE00uy5/W+bH8opZY0wF+4JmAr2aMT3q66U=; 7:zo3cv4jyCz99MyKyRCdyIVgylyR7PemR9ldT5QCAswz1NrMR5KWZI5vYzNPtzxv2CcS5b6r938cp/2MhgUYWsXPLQCHVOcScmQ3ePQUyclzt5OlXIcTjgdKvoM+GwEzbSDoYK7yF7BYN7BwMBFgJaTbfX/2eNuTSZuqpPhrFPgt/vfv5WPgZIU9o409GoH44FWtMuJmvqqJdkMxYhAvSm9CTkKZoSL8vYAuSb1nZPS2gCHrfwqPx6K123Pok2//m x-ms-office365-filtering-correlation-id: 4df14259-847a-480c-c7a7-08d638291df0 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:HE1PR04MB1051; x-ms-traffictypediagnostic: HE1PR04MB1051: 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)(8121501046)(5005006)(10201501046)(3231355)(944501410)(52105095)(3002001)(93006095)(93001095)(6055026)(148016)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(201708071742011)(7699051)(76991095); SRVR:HE1PR04MB1051; BCL:0; PCL:0; RULEID:; SRVR:HE1PR04MB1051; x-forefront-prvs: 08331F819E x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(396003)(39860400002)(136003)(346002)(376002)(199004)(189003)(14454004)(486006)(256004)(14444005)(3846002)(7736002)(4326008)(2616005)(2501003)(11346002)(6116002)(54906003)(2900100001)(110136005)(476003)(78486010)(72206003)(6512007)(8936002)(316002)(36756003)(6436002)(81166006)(71200400001)(71190400001)(478600001)(68736007)(86362001)(52116002)(53936002)(186003)(76176011)(446003)(81156014)(6486002)(8676002)(102836004)(26005)(55236004)(66066001)(6636002)(105586002)(5660300001)(305945005)(106356001)(25786009)(2906002)(97736004)(386003)(6506007)(99286004)(1076002)(5250100002); DIR:OUT; SFP:1101; SCL:1; SRVR:HE1PR04MB1051; 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: C84jqKjE3ptq0+MRydgipf+MBXL+XganseVrlgRcdyU8N9tAxyiAdfN3bZhyr28J7J63g1PA8wUIyp2ISPPeHZjYNnO3gPSX8WYrPrz/9Vp7ZQLUMgfuhZvhIsRFRsdL9dWFXSK+o+J9yGBWBhV6K/pSnYCDUm/FeOsRuoJ+1xXpmcMFMGthTRQkAhUVIyr6P4OCpbeqPfR2D8mFCK0y74xkpleCchNHEORBS6aWfrNCnK5dtJm6RL4AQSQ9VBiMYwhXyken1mQ8vzroGmrFlsg2C5rKhz/tqiBHIbuQlliVs/GoBYI+vwFcvhzXjNicKCUOCtO740HicUhRW7FzZSOqZxwM4/PSr+4NePrfITI= 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: 4df14259-847a-480c-c7a7-08d638291df0 X-MS-Exchange-CrossTenant-originalarrivaltime: 22 Oct 2018 14:17:37.2402 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR04MB1051 Subject: [dpdk-dev] [PATCH v4 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:17:40 -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