From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-BL2-obe.outbound.protection.outlook.com (mail-bl2nam02on0047.outbound.protection.outlook.com [104.47.38.47]) by dpdk.org (Postfix) with ESMTP id CA1FC2BBE for ; Fri, 15 Sep 2017 07:32:44 +0200 (CEST) Received: from BN6PR03CA0050.namprd03.prod.outlook.com (10.173.137.12) by DM5PR03MB2700.namprd03.prod.outlook.com (10.168.197.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.56.11; Fri, 15 Sep 2017 05:32:43 +0000 Received: from BL2FFO11FD024.protection.gbl (2a01:111:f400:7c09::176) by BN6PR03CA0050.outlook.office365.com (2603:10b6:404:4c::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.56.8 via Frontend Transport; Fri, 15 Sep 2017 05:32:42 +0000 Authentication-Results: spf=fail (sender IP is 192.88.158.2) smtp.mailfrom=nxp.com; nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=fail action=none header.from=nxp.com; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.158.2 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.158.2; helo=az84smr01.freescale.net; Received: from az84smr01.freescale.net (192.88.158.2) by BL2FFO11FD024.mail.protection.outlook.com (10.173.161.103) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.13.11 via Frontend Transport; Fri, 15 Sep 2017 05:32:42 +0000 Received: from [10.232.133.65] (B10814-12.ap.freescale.net [10.232.133.65]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id v8F5WbMA000911; Thu, 14 Sep 2017 22:32:38 -0700 To: Akhil Goyal , References: <20170914082651.26232-1-akhil.goyal@nxp.com> <20170914082651.26232-2-akhil.goyal@nxp.com> CC: , , , , , , , From: Hemant Agrawal Message-ID: Date: Fri, 15 Sep 2017 11:02:36 +0530 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <20170914082651.26232-2-akhil.goyal@nxp.com> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit X-EOPAttributedMessage: 0 X-Matching-Connectors: 131499271626531932; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.158.2; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(336005)(7966004)(39860400002)(346002)(39380400002)(376002)(2980300002)(1109001)(1110001)(339900001)(24454002)(377454003)(199003)(189002)(8656003)(316002)(106466001)(58126008)(53546010)(498600001)(105606002)(47776003)(83506001)(50986999)(76176999)(54356999)(8676002)(305945005)(65956001)(65806001)(104016004)(81156014)(81166006)(8936002)(85426001)(356003)(15650500001)(65826007)(68736007)(189998001)(31696002)(229853002)(2950100002)(7416002)(77096006)(53936002)(50466002)(5660300001)(69596002)(31686004)(97736004)(33646002)(36756003)(23746002)(86362001)(6246003)(64126003)(2906002)(54906002)(4326008)(230700001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR03MB2700; H:az84smr01.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD024; 1:3q3AoX6xtPzGB4Md6lhe6anpEtAhm+O1Wk9/bDGFpdDK/+Ttd1gomjUnWVyXXMEYvS+IPmeSsvHx3fyYmnuu+6Cu9KP46T32E+d6/HrNJVdO1u8nDMvZ99yuRRBz+QLc X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4e620f4e-4275-49f4-42fc-08d4fbfb2ffa X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(300000503095)(300135400095)(2017052603199)(201703131430075)(201703131517081)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:DM5PR03MB2700; X-Microsoft-Exchange-Diagnostics: 1; DM5PR03MB2700; 3:CvamuIGgLNdIDif7FIiND9Fy77mZgs54uUjgK8xt7Nxp1Yz/RTMmTz2xsFeFTOixk/CDPJ+tpjgGFfrPI9ZHhCz7TYe29zJTJacK8ISLkFcsUDwM1RC4qmWa9S8E6c802pcKChKxGp2F8RWOpOfBtR4eqzsjnbwTQTZFCq6Vv+YKGz/hpPHGVPGkAgDPNuBLcx81V4vCXg4aWtwn8WWKBXmSx+/VvHpp2kmQdZh//SeXJwf8gPdsn1myyGX91VgFQwXxbJ1gaKfPxFxHNALw4OZ22vfeY2CSFYFwRm9m3evPmoA7w05DNs7vTCG6o0VBcvezMESoENVuuWGaiObc/g==; 25:/c2mlNGzmQNfAiUyyCypCwzYTL5M3bPIRWjLdZwM06skDgLlT0lI1evIonSk668HUNLS4YWegofuOS6l1tEcRTNvG9GENPoHNTjj2UbPDLKIEuUVAhu6XWUzf2VRKTNXMMSOtxYPfMml6EP9guvi06iyStlRaMt4wXrgAORyceHjwljC2y7X+PoXxOxFP2taaTNQApsLS2rc/kdk2FEFSg0GczuNQoaxzuQIF2sDArsKXL+qsFeNIEofcoh2JagZQ/pfLL+71ZrbfYn1nPAQA/4nBU5uIcTc71MHmJAEmfxDv5N4rBwSg41P8bSDbovAbZU4wt6IFgu4oIw2Dvv+Uw==; 31:jszyr0kCppG3WZZu3X15HXeC8IB3OdAOEgngt54KZitJW4ajGbql0DVxUgalYDb/+LpVQT4xMEY1GhPT9Q7RtwUyZvELIAcQMiCYUBE/5Ur9mfO9zWLRvhnxepAhx5+5XBa3czlcxHcyX5tezpjSmXyoJq9XF/t9aXnxVslWPEdhA/Mt9vrck9hd6zfE/u0/FE3dLSOOwol4ZGEeGnJYJS5/Tso82g9F0Izrl2ojJI8= X-MS-TrafficTypeDiagnostic: DM5PR03MB2700: X-Exchange-Antispam-Report-Test: UriScan:(192374486261705); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6095135)(2401047)(5005006)(8121501046)(100000703101)(100105400095)(93006095)(93001095)(10201501046)(3002001)(6055026)(6096035)(201703131430075)(201703131441075)(201703131448075)(201703131433075)(201703161259150)(20161123556025)(20161123565025)(20161123563025)(20161123561025)(20161123559100)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:DM5PR03MB2700; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(400006)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:DM5PR03MB2700; X-Microsoft-Exchange-Diagnostics: 1; DM5PR03MB2700; 4:cny9G87iSqn6kk6JsJtcl2UBrv4BsRqjrwevf90bjvp/upFUStIjhl49Wgzd7scnQPOMwuAOhQ8F4l0f4q/ncMlx6RwzkEV1fKUM2c1IPWvQBDVcE5jnRCc/RkKxRA/r1wHnG17pip8ync5gu4q3vq6XiF/VWwvkAQp1N3FjkI0EV51CBfJpX7UKTn0pC7KfwrKQ/htDBeDwTrQ1GLF3GjRZP/g2w9GmShDuF6chwQVPLv2KGK+bJ45icASrSoKjHgkgzdJLdwNeEsvnEC8yDfwaPKfzW2bpCm/A+TCVXgo= X-Forefront-PRVS: 0431F981D8 X-Microsoft-Exchange-Diagnostics: =?Windows-1252?Q?1; DM5PR03MB2700; 23:eXt5yphWRxR3LD24ta1p67JVHiPxS+18LHQqb?= =?Windows-1252?Q?p1+jNVGtUT3austPBKvJjhau3TVOVdUK24BoW2+H3O/tqnZsvm87cD6z?= =?Windows-1252?Q?y6mdOJ8vO8QbdoK+Bjeq7FPfQhMsrlOdi0Lze5TuDS+zwIRLzOoMObFQ?= =?Windows-1252?Q?X6wtmEtn9abJ11nUJnIIrm9mC7c1oAoP4Bfis6uzaladTCxu4swk1kR/?= =?Windows-1252?Q?a3P2B/zkgyKVskfCulJc9DELDOKT8THHJNBADhtiKdLprvw/onRhl2B2?= =?Windows-1252?Q?cs/qJ+sE40veeZX1ZD1+UAbD41k6q8yQc3F7eAFXiAMtEmcOsUJkD6vO?= =?Windows-1252?Q?LN2nXIQVGTOOlZqjCrQNKd/l/pC8ZETRtAZZgfIdvkh2gsYY3fc766KA?= =?Windows-1252?Q?dADIMLUSAi9oveHLeVCOaK5JWqelly5ijePDU6iQ+bUau7o6zMp6kpoJ?= =?Windows-1252?Q?1SPjg+z1Fmei7VKeGtiGGYY9OIb2PPNgITzmAg2NjzAxC2v82wkrcsz5?= =?Windows-1252?Q?7gJRaGrxe36I6o96ekzkRNS2vhJfm5QwY/L5+FbbdlsA3mrrPSQEQHYW?= =?Windows-1252?Q?Y3yv+pTAGOz00Xv6HKmrag+31XoHNBU97oytXfDbWUm5V3V9J4jBX/Nm?= =?Windows-1252?Q?rp2RpzK8WPvIAOaq2J/ovefUeg6FowyOjDDson/OkCACBNQ2B32TIAW2?= =?Windows-1252?Q?eZrkRCaLEp4sD3A0DJ3PQBzW4H2ajrlBwX/AZl/dlkZPr+N9ZapkspIB?= =?Windows-1252?Q?azUGLXqdldL7kZVWtQBGl82/noJ09Hq93panfUqCteXu5PrKlxWXpc1B?= =?Windows-1252?Q?hMcwAZxQnAXlTU5AUWarbrBjxJPNoSuFEU9Ccp1c48tfGEzEB+owjmE4?= =?Windows-1252?Q?kU5tShSyPvtyTfEOOxAPz3P+eYxVxFuDmZd8CqltZUFvye/5P0AAM9c2?= =?Windows-1252?Q?TSdemt8pO1XSmB7aZdeMwFmEo3fE2cu/ZexneoDFF9aqINzmn3e8s/nz?= =?Windows-1252?Q?yl9pWAonH/4u0cH0meAuE9JpryOD5y8MAoHhC3Vvc1jzFg7/ZUoeDiRy?= =?Windows-1252?Q?Ou49SIt5ktVzt+rqFEAcMa9E3BB1qs0c3ykvWXnykmJRZbcjm6SzC85O?= =?Windows-1252?Q?ZToduZaAEZxbTYB+ulDqpXCiZ/dt4h7aMziLJqbL9FLALXL6pnT0VsVQ?= =?Windows-1252?Q?xTPSlWob1QUIWrkzSDgbrbKW72wN4eS+p7Pp39xE3lcvSSLOV7aVOUvL?= =?Windows-1252?Q?sy08RiNArN+aVXApACSX8/w5E1xGz1KBnPs/Wpxg+2XPtldPsvCCgly4?= =?Windows-1252?Q?tTsxc5Qt7zujg7aM44Us48NxJVZXl0V5u8d6VfbimN1GsMBkgbe71WDi?= =?Windows-1252?Q?ZcXuU1RkztS3uEI+RRvukjsIvYvqC4tjh1UVcTVzCDwlgkxvKZrPsY1g?= =?Windows-1252?Q?u0M7wRNXU6iZOSfmFCS3blidfgoAJPahD1RZU/pY9hm3ysodt2Ah3T7A?= =?Windows-1252?Q?UAEBNnNIAWghXrOt87rWBHFFc0WWp8KzQMmMgj/aIvps8MJpJz+MBqkw?= =?Windows-1252?Q?hIWQnTdsNgO5FU=3D?= X-Microsoft-Exchange-Diagnostics: 1; DM5PR03MB2700; 6:K9lCjuevWN2uj/rPeAQqQ0bDvGBEGD226j9EHBK3RWnaqvACjH7+3ZQTO0DH1W+FkWKFoGLYIX0rUi1EjX4rawdS1tIvIhuELHQszn4FTWmDZzI3AFTyMoV+WsS9uD8eNbS40g9Gqby9tFMt6g/WsgA+OZb5lXwW6CbtctMZKoehHVZ0nxK9OJRgfxTFwU/Q5UGXYjoRPC5WN2esnKg+VaENrNnBWTnQ0YRRZg5N909ivH50LAkC13/VvOyg6A5zHCXwqASHsHHB1CR4+jIAXpfclVWd7gdCUuxySqZoOo/X06YqKb4zx4oAtUVwfJhkWEIaZ3DtxWcxsKd8nd03FA==; 5:pBtnyHYd7iqaATapz5GF5TLRjURP+V9O4/ChRj8GqArNwxGBwf4/eXmQES3pRTPGNxMwT+uGX6c7UR1JYFvFVeDgSP5nJucL0p4ywsddAOhxlQ+ROW3eQwSCF9Thme9iVFk1zLxhUixiTReqPBcbVw==; 24:MJSLhMGmOcVZ2XFqPD2YfVgC/xl9t4V58jjs8tvLKCj2oGstaRHQeYPsk9jiadARj1cFEYTWXi7XXxxuSVvNKba3CZ2mqj8ZpCPI6ssCC5Y=; 7:IvWoTBEmoJ3XgOoQK4qewX7Gz6ZrqKgipTza7g4z5kv5VmETjHhXG5gURDRqaz8hwV6qPChx1NGhGIaReNyiojluKU93K87Vi7lNpmPpAvgfUPhTnFeEiOB64+YDg1DB73v5qOFSg3vaV6rwnmUSer1soeDoNfiZQ2s0c3L0JW2SnEuu7RP/MX0KDn+fhCN/N/mu/TPczuOVO57ZISg1/X666X4ycxRI4wSXlXSbKOI= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Sep 2017 05:32:42.4035 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.158.2]; Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR03MB2700 Subject: Re: [dpdk-dev] [PATCH 01/11] lib/rte_security: add security library 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, 15 Sep 2017 05:32:45 -0000 Hi, On 9/14/2017 1:56 PM, Akhil Goyal wrote: .. > diff --git a/lib/librte_security/rte_security.c b/lib/librte_security/rte_security.c > new file mode 100644 > index 0000000..5776246 > --- /dev/null > +++ b/lib/librte_security/rte_security.c > @@ -0,0 +1,252 @@ > +/*- > + * BSD LICENSE > + * > + * Copyright 2017 NXP. > + * Copyright(c) 2017 Intel Corporation. All rights reserved. > + * > + * Redistribution and use in source and binary forms, with or without > + * modification, are permitted provided that the following conditions > + * are met: > + * > + * * Redistributions of source code must retain the above copyright > + * notice, this list of conditions and the following disclaimer. > + * * Redistributions in binary form must reproduce the above copyright > + * notice, this list of conditions and the following disclaimer in > + * the documentation and/or other materials provided with the > + * distribution. > + * * Neither the name of NXP nor the names of its > + * contributors may be used to endorse or promote products derived > + * from this software without specific prior written permission. > + * > + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS > + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT > + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR > + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT > + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, > + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT > + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, > + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY > + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT > + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE > + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. > + */ > + > +#include > +#include > + > +#include "rte_security.h" > +#include "rte_security_driver.h" > + > +#define RTE_SECURITY_INSTANCES_BLOCK_ALLOC_SZ (8) > + > +struct rte_security_ctx { > + uint16_t id; > + enum { > + RTE_SECURITY_INSTANCE_INVALID = 0, > + RTE_SECURITY_INSTANCE_VALID > + } state; > + void *device; > + struct rte_security_ops *ops; > +}; > + > +static struct rte_security_ctx *security_instances; > +static uint16_t max_nb_security_instances; > +static uint16_t nb_security_instances; > + > +static int > +rte_security_is_valid_id(uint16_t id) > +{ > + if (id >= nb_security_instances || > + (security_instances[id].state != RTE_SECURITY_INSTANCE_VALID)) > + return 0; > + else > + return 1; > +} > + > +/* Macros to check for valid id */ > +#define RTE_SEC_VALID_ID_OR_ERR_RET(id, retval) do { \ > + if (!rte_security_is_valid_id(id)) { \ > + RTE_PMD_DEBUG_TRACE("Invalid sec_id=%d\n", id); \ > + return retval; \ > + } \ > +} while (0) > + > +#define RTE_SEC_VALID_ID_OR_RET(id) do { \ > + if (!rte_security_is_valid_id(id)) { \ > + RTE_PMD_DEBUG_TRACE("Invalid sec_id=%d\n", id); \ > + return; \ > + } \ > +} while (0) > + > +int > +rte_security_register(uint16_t *id, void *device, > + struct rte_security_ops *ops) > +{ > + if (max_nb_security_instances == 0) { > + security_instances = rte_malloc( > + "rte_security_instances_ops", > + sizeof(*security_instances) * > + RTE_SECURITY_INSTANCES_BLOCK_ALLOC_SZ, 0); > + > + if (security_instances == NULL) > + return -ENOMEM; > + max_nb_security_instances = > + RTE_SECURITY_INSTANCES_BLOCK_ALLOC_SZ; > + } else if (nb_security_instances >= max_nb_security_instances) { > + uint16_t *instances = rte_realloc(security_instances, > + sizeof(struct rte_security_ops *) * > + (max_nb_security_instances + > + RTE_SECURITY_INSTANCES_BLOCK_ALLOC_SZ), 0); I think "RTE_SECURITY_INSTANCES_BLOCK_ALLOC_SZ" value as 8 is relatively small. you may want to keep it "64" or more. you may change it into two parts - Initial block size and incremental block size for realloc. Also, do you want to make it a configurable variable. as some implementation may need really large number of SAs. > + > + if (instances == NULL) > + return -ENOMEM; > + > + max_nb_security_instances += > + RTE_SECURITY_INSTANCES_BLOCK_ALLOC_SZ; > + } > + > + *id = nb_security_instances++; > + > + security_instances[*id].id = *id; > + security_instances[*id].state = RTE_SECURITY_INSTANCE_VALID; > + security_instances[*id].device = device; > + security_instances[*id].ops = ops; > + > + return 0; > +} > + > +int > +rte_security_unregister(__rte_unused uint16_t *id) > +{ > + /* To be implemented */ > + return 0; > +} > + > +struct rte_security_session * > +rte_security_session_create(uint16_t id, > + struct rte_security_session_conf *conf, > + struct rte_mempool *mp) > +{ > + struct rte_security_ctx *instance; > + struct rte_security_session *sess = NULL; > + > + RTE_SEC_VALID_ID_OR_ERR_RET(id, NULL); > + instance = &security_instances[id]; > + > + if (conf == NULL) > + return NULL; > + > + if (rte_mempool_get(mp, (void *)&sess)) > + return NULL; > + > + RTE_FUNC_PTR_OR_ERR_RET(*instance->ops->session_create, NULL); it will leak the sess memory, if returned on error. > + if (instance->ops->session_create(instance->device, conf, sess, mp)) { > + rte_mempool_put(mp, (void *)sess); > + return NULL; > + } can the mempool operations be part of session_create api? it will be similar to destroy, which is expected to free the 'sess' object to mempool? > + return sess; > +} > + .. > diff --git a/lib/librte_security/rte_security.h b/lib/librte_security/rte_security.h > new file mode 100644 > index 0000000..2faac96 > --- /dev/null > +++ b/lib/librte_security/rte_security.h > @@ -0,0 +1,494 @@ > +/*- > + * BSD LICENSE > + * > + * Copyright 2017 NXP. > + * Copyright(c) 2017 Intel Corporation. All rights reserved. > + * > + * Redistribution and use in source and binary forms, with or without > + * modification, are permitted provided that the following conditions > + * are met: > + * > + * * Redistributions of source code must retain the above copyright > + * notice, this list of conditions and the following disclaimer. > + * * Redistributions in binary form must reproduce the above copyright > + * notice, this list of conditions and the following disclaimer in > + * the documentation and/or other materials provided with the > + * distribution. > + * * Neither the name of NXP nor the names of its > + * contributors may be used to endorse or promote products derived > + * from this software without specific prior written permission. > + * > + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS > + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT > + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR > + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT > + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, > + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT > + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, > + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY > + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT > + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE > + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. > + */ > + > +#ifndef _RTE_SECURITY_H_ > +#define _RTE_SECURITY_H_ > + > +/** > + * @file rte_security.h > + * > + * RTE Security Common Definitions > + * > + */ > + > +#ifdef __cplusplus > +extern "C" { > +#endif > + > +#include > +#include > +#include > + > +#include > +#include > +#include > +#include > +#include > + > +/** IPSec protocol mode */ > +enum rte_security_ipsec_sa_mode { > + RTE_SECURITY_IPSEC_SA_MODE_TRANSPORT, > + /**< IPSec Transport mode */ > + RTE_SECURITY_IPSEC_SA_MODE_TUNNEL, > + /**< IPSec Tunnel mode */ > +}; > + > +/** IPSec Protocol */ > +enum rte_security_ipsec_sa_protocol { > + RTE_SECURITY_IPSEC_SA_PROTO_AH, > + /**< AH protocol */ > + RTE_SECURITY_IPSEC_SA_PROTO_ESP, > + /**< ESP protocol */ > +}; > + > +/** IPSEC tunnel type */ > +enum rte_security_ipsec_tunnel_type { > + RTE_SECURITY_IPSEC_TUNNEL_IPV4 = 0, > + /**< Outer header is IPv4 */ > + RTE_SECURITY_IPSEC_TUNNEL_IPV6, > + /**< Outer header is IPv6 */ > +}; > + > +/** > + * IPSEC tunnel parameters > + * > + * These parameters are used to build outbound tunnel headers. > + */ > +struct rte_security_ipsec_tunnel_param { > + enum rte_security_ipsec_tunnel_type type; > + /**< Tunnel type: IPv4 or IPv6 */ > + union { > + struct { > + struct in_addr src_ip; > + /**< IPv4 source address */ > + struct in_addr dst_ip; > + /**< IPv4 destination address */ > + uint8_t dscp; > + /**< IPv4 Differentiated Services Code Point */ > + uint8_t df; > + /**< IPv4 Don't Fragment bit */ > + uint8_t ttl; > + /**< IPv4 Time To Live */ > + } ipv4; > + /**< IPv4 header parameters */ > + struct { > + struct in6_addr src_addr; > + /**< IPv6 source address */ > + struct in6_addr dst_addr; > + /**< IPv6 destination address */ > + uint8_t dscp; > + /**< IPv6 Differentiated Services Code Point */ > + uint32_t flabel; > + /**< IPv6 flow label */ > + uint8_t hlimit; > + /**< IPv6 hop limit */ > + } ipv6; > + /**< IPv6 header parameters */ > + }; > +}; > + > +/** > + * IPsec Security Association option flags > + */ > +struct rte_security_ipsec_sa_options { > + /** Extended Sequence Numbers (ESN) > + * > + * * 1: Use extended (64 bit) sequence numbers > + * * 0: Use normal sequence numbers > + */ > + uint32_t esn : 1; > + > + /** UDP encapsulation > + * > + * * 1: Do UDP encapsulation/decapsulation so that IPSEC packets can > + * traverse through NAT boxes. > + * * 0: No UDP encapsulation > + */ > + uint32_t udp_encap : 1; > + > + /** Copy DSCP bits > + * > + * * 1: Copy IPv4 or IPv6 DSCP bits from inner IP header to > + * the outer IP header in encapsulation, and vice versa in > + * decapsulation. > + * * 0: Use values from odp_ipsec_tunnel_param_t in encapsulation and > + * do not change DSCP field in decapsulation. > + */ > + uint32_t copy_dscp : 1; > + > + /** Copy IPv6 Flow Label > + * > + * * 1: Copy IPv6 flow label from inner IPv6 header to the > + * outer IPv6 header. > + * * 0: Use value from odp_ipsec_tunnel_param_t > + */ > + uint32_t copy_flabel : 1; > + > + /** Copy IPv4 Don't Fragment bit > + * > + * * 1: Copy the DF bit from the inner IPv4 header to the outer > + * IPv4 header. > + * * 0: Use value from odp_ipsec_tunnel_param_t > + */ > + uint32_t copy_df : 1; > + > + /** Decrement inner packet Time To Live (TTL) field > + * > + * * 1: In tunnel mode, decrement inner packet IPv4 TTL or > + * IPv6 Hop Limit after tunnel decapsulation, or before tunnel > + * encapsulation. > + * * 0: Inner packet is not modified. > + */ > + uint32_t dec_ttl : 1; > + > + /** HW constructs/removes trailer of packets > + * > + * * 1: Transmitted packets will have the trailer added to them by > + * hardawre. The next protocol field will be based on the > + * mbuf->inner_esp_next_proto field. > + * Received packets have no trailer, the next protocol field is > + * supplied in the mbuf->inner_esp_next_proto field. > + * * 0: Inner packet is not modified. > + */ > + uint32_t no_trailer : 1; > +}; > + > +/** IPSec security association direction */ > +enum rte_security_ipsec_sa_direction { > + RTE_SECURITY_IPSEC_SA_DIR_EGRESS, > + /**< Encrypt and generate digest */ > + RTE_SECURITY_IPSEC_SA_DIR_INGRESS, > + /**< Verify digest and decrypt */ > +}; > + > +/** > + * IPsec security association configuration data. > + * > + * This structure contains data required to create an IPsec SA security session. > + */ > +struct rte_security_ipsec_xform { > + uint32_t spi; > + /**< SA security parameter index */ > + uint32_t salt; > + /**< SA salt */ > + struct rte_security_ipsec_sa_options options; > + /**< various SA options */ > + enum rte_security_ipsec_sa_direction direction; > + /**< IPSec SA Direction - Egress/Ingress */ > + enum rte_security_ipsec_sa_protocol proto; > + /**< IPsec SA Protocol - AH/ESP */ > + enum rte_security_ipsec_sa_mode mode; > + /**< IPsec SA Mode - transport/tunnel */ > + struct rte_security_ipsec_tunnel_param tunnel; > + /**< Tunnel parameters, NULL for transport mode */ > +}; > + > +/** > + * MACsec security session configuration > + */ > +struct rte_security_macsec_xform { > + /** To be Filled */ > +}; > + > +/** > + * Security session action type. > + */ > +enum rte_security_session_action_type { > + RTE_SECURITY_ACTION_TYPE_NONE, > + /**< No security actions */ This is not being used, it seems that you are only using it as marker to indicate end of capability set? > + RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO, > + /**< Crypto processing for security protocol is processed inline > + * during transmission */ > + RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL, > + /**< All security protocol processing is performed inline during > + * transmission */ > + RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL > + /**< All security protocol processing including crypto is performed > + * on a lookaside accelerator */ > +}; > + > +/** Security session protocol definition */ > +enum rte_security_session_protocol { > + RTE_SECURITY_PROTOCOL_IPSEC, > + /**< IPsec Protocol */ > + RTE_SECURITY_PROTOCOL_MACSEC, > + /**< MACSec Protocol */ > +}; > + > +/** > + * Security session configuration > + */ > +struct rte_security_session_conf { > + enum rte_security_session_action_type action_type; > + /**< Type of action to be performed on the session */ > + enum rte_security_session_protocol protocol; > + /**< Security protocol to be configured */ > + union { > + struct rte_security_ipsec_xform ipsec; > + struct rte_security_macsec_xform macsec; > + }; > + /**< Configuration parameters for security session */ > + struct rte_crypto_sym_xform *crypto_xform; > + /**< Security Session Crypto Transformations */ > +}; > + > +struct rte_security_session { > + __extension__ void *sess_private_data; > + /**< Private session material */ > +}; > + Do you need specific error handling for security sessions as well? In case of full protocol offloads, you will need indications for 1. SEQ number overflow (egress side, if the SA is not refreshed on time) 2. Anti replay window config and err handlings? > +/** > + * Create security session as specified by the session configuration > + * > + * @param id security instance identifier id > + * @param conf session configuration parameters fix the indentation here and other places in this file. > + * @param mp mempool to allocate session objects from > + * @return > + * - On success, pointer to session > + * - On failure, NULL > + */ > +struct rte_security_session * > +rte_security_session_create(uint16_t id, > + struct rte_security_session_conf *conf, > + struct rte_mempool *mp); > + > +/**