From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 00680A0524; Fri, 31 Jan 2020 11:05:05 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2704E1C0DC; Fri, 31 Jan 2020 11:04:45 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by dpdk.org (Postfix) with ESMTP id 9DB451C0DC for ; Fri, 31 Jan 2020 11:04:43 +0100 (CET) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 00VA0XFx014373; Fri, 31 Jan 2020 02:04:42 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0818; bh=k9bB1+dNx6kvKlDbrns+1k8jC0E/+ri/KcYL/OEvRfg=; b=JWRCBTnqeTLuK++iS+t4RnfARY8W40/YKZid5gFI9lTw+b9tgjdXjZpsyFQO2EB3+XKs FO6E+gyJvGApA7J8klalKHoF8m92o27DsAOWwXWJuDMsDir1RjzpXWBhAwFvuw6uXf4L c+811HxweLNRndC1mNnx59rCWktKNJYCzGH8cihpiHHuBLYyQ3uxPETicdsAyQg10snJ Ik4xQR+SLiXKxNKNTPKNR4herOsJDRvT4CMhQ8XF1c3QCQsX4JFq7N3UoAYI+0QARiJD xpJgYRIWgCX2GaAFobVqch2ElJPYmAXPknR1s/aSwuRxP4CE1Rf5ii/V+i5Qa6rykMAR 6g== Received: from sc-exch04.marvell.com ([199.233.58.184]) by mx0a-0016f401.pphosted.com with ESMTP id 2xupkhxx21-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Fri, 31 Jan 2020 02:04:42 -0800 Received: from SC-EXCH01.marvell.com (10.93.176.81) by SC-EXCH04.marvell.com (10.93.176.84) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 31 Jan 2020 02:04:41 -0800 Received: from maili.marvell.com (10.93.176.43) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Fri, 31 Jan 2020 02:04:41 -0800 Received: from ajoseph83.caveonetworks.com (unknown [10.29.45.60]) by maili.marvell.com (Postfix) with ESMTP id 30BDF3F703F; Fri, 31 Jan 2020 02:04:36 -0800 (PST) From: Anoob Joseph To: Akhil Goyal , Declan Doherty , Thomas Monjalon CC: Anoob Joseph , Jerin Jacob , Narayana Prasad , Kiran Kumar K , Nithin Dabilpuram , "Pavan Nikhilesh" , Ankur Dwivedi , Archana Muniganti , Tejasree Kondoj , Vamsi Attunuru , "Lukasz Bartosik" , Date: Fri, 31 Jan 2020 15:33:44 +0530 Message-ID: <1580465035-30455-5-git-send-email-anoobj@marvell.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1580465035-30455-1-git-send-email-anoobj@marvell.com> References: <1579344553-11428-1-git-send-email-anoobj@marvell.com> <1580465035-30455-1-git-send-email-anoobj@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.572 definitions=2020-01-31_02:2020-01-30, 2020-01-31 signatures=0 Subject: [dpdk-dev] [PATCH v3 04/15] net/octeontx2: create eth security ctx 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Adding security ctx to the eth device. Signed-off-by: Ankur Dwivedi Signed-off-by: Anoob Joseph Signed-off-by: Archana Muniganti Signed-off-by: Tejasree Kondoj Signed-off-by: Vamsi Attunuru --- MAINTAINERS | 1 + drivers/net/octeontx2/Makefile | 1 + drivers/net/octeontx2/meson.build | 4 +++- drivers/net/octeontx2/otx2_ethdev.c | 15 +++++++++++++- drivers/net/octeontx2/otx2_ethdev_sec.c | 35 +++++++++++++++++++++++++++++++++ drivers/net/octeontx2/otx2_ethdev_sec.h | 14 +++++++++++++ 6 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 drivers/net/octeontx2/otx2_ethdev_sec.c create mode 100644 drivers/net/octeontx2/otx2_ethdev_sec.h diff --git a/MAINTAINERS b/MAINTAINERS index 7b1ea56..5d05b29 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -728,6 +728,7 @@ Marvell OCTEON TX2 - security M: Anoob Joseph T: git://dpdk.org/next/dpdk-next-crypto F: drivers/common/octeontx2/otx2_sec* +F: drivers/net/octeontx2/otx2_ethdev_sec* Mellanox mlx4 M: Matan Azrad diff --git a/drivers/net/octeontx2/Makefile b/drivers/net/octeontx2/Makefile index 68f5765..8649f89 100644 --- a/drivers/net/octeontx2/Makefile +++ b/drivers/net/octeontx2/Makefile @@ -50,6 +50,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_OCTEONTX2_PMD) += \ otx2_flow_utils.c \ otx2_ethdev_irq.c \ otx2_ethdev_ops.c \ + otx2_ethdev_sec.c \ otx2_ethdev_debug.c \ otx2_ethdev_devargs.c diff --git a/drivers/net/octeontx2/meson.build b/drivers/net/octeontx2/meson.build index fad3076..dfbf99a 100644 --- a/drivers/net/octeontx2/meson.build +++ b/drivers/net/octeontx2/meson.build @@ -20,11 +20,13 @@ sources = files('otx2_rx.c', 'otx2_flow_utils.c', 'otx2_ethdev_irq.c', 'otx2_ethdev_ops.c', + 'otx2_ethdev_sec.c', 'otx2_ethdev_debug.c', 'otx2_ethdev_devargs.c' ) -deps += ['bus_pci', 'common_octeontx2', 'mempool_octeontx2'] +deps += ['bus_pci', 'cryptodev', 'security'] +deps += ['common_octeontx2', 'mempool_octeontx2'] cflags += ['-flax-vector-conversions'] diff --git a/drivers/net/octeontx2/otx2_ethdev.c b/drivers/net/octeontx2/otx2_ethdev.c index 268b383..7fd5254 100644 --- a/drivers/net/octeontx2/otx2_ethdev.c +++ b/drivers/net/octeontx2/otx2_ethdev.c @@ -12,6 +12,7 @@ #include #include "otx2_ethdev.h" +#include "otx2_ethdev_sec.h" static inline uint64_t nix_get_rx_offload_capa(struct otx2_eth_dev *dev) @@ -2243,10 +2244,17 @@ otx2_eth_dev_init(struct rte_eth_dev *eth_dev) dev->hwcap |= OTX2_FIXUP_F_LIMIT_CQ_FULL; } + /* Create security ctx */ + rc = otx2_eth_sec_ctx_create(eth_dev); + if (rc) + goto free_mac_addrs; + dev->tx_offload_capa |= DEV_TX_OFFLOAD_SECURITY; + dev->rx_offload_capa |= DEV_RX_OFFLOAD_SECURITY; + /* Initialize rte-flow */ rc = otx2_flow_init(dev); if (rc) - goto free_mac_addrs; + goto sec_ctx_destroy; otx2_nix_mc_filter_init(dev); @@ -2257,6 +2265,8 @@ otx2_eth_dev_init(struct rte_eth_dev *eth_dev) dev->rx_offload_capa, dev->tx_offload_capa); return 0; +sec_ctx_destroy: + otx2_eth_sec_ctx_destroy(eth_dev); free_mac_addrs: rte_free(eth_dev->data->mac_addrs); unregister_irq: @@ -2340,6 +2350,9 @@ otx2_eth_dev_uninit(struct rte_eth_dev *eth_dev, bool mbox_close) if (rc) otx2_err("Failed to cleanup npa lf, rc=%d", rc); + /* Destroy security ctx */ + otx2_eth_sec_ctx_destroy(eth_dev); + rte_free(eth_dev->data->mac_addrs); eth_dev->data->mac_addrs = NULL; dev->drv_inited = false; diff --git a/drivers/net/octeontx2/otx2_ethdev_sec.c b/drivers/net/octeontx2/otx2_ethdev_sec.c new file mode 100644 index 0000000..80c5689 --- /dev/null +++ b/drivers/net/octeontx2/otx2_ethdev_sec.c @@ -0,0 +1,35 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright (C) 2020 Marvell International Ltd. + */ + +#include +#include +#include + +#include "otx2_ethdev_sec.h" + +int +otx2_eth_sec_ctx_create(struct rte_eth_dev *eth_dev) +{ + struct rte_security_ctx *ctx; + + ctx = rte_malloc("otx2_eth_sec_ctx", + sizeof(struct rte_security_ctx), 0); + if (ctx == NULL) + return -ENOMEM; + + /* Populate ctx */ + + ctx->device = eth_dev; + ctx->sess_cnt = 0; + + eth_dev->security_ctx = ctx; + + return 0; +} + +void +otx2_eth_sec_ctx_destroy(struct rte_eth_dev *eth_dev) +{ + rte_free(eth_dev->security_ctx); +} diff --git a/drivers/net/octeontx2/otx2_ethdev_sec.h b/drivers/net/octeontx2/otx2_ethdev_sec.h new file mode 100644 index 0000000..4a925e9 --- /dev/null +++ b/drivers/net/octeontx2/otx2_ethdev_sec.h @@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright (C) 2020 Marvell International Ltd. + */ + +#ifndef __OTX2_ETHDEV_SEC_H__ +#define __OTX2_ETHDEV_SEC_H__ + +#include + +int otx2_eth_sec_ctx_create(struct rte_eth_dev *eth_dev); + +void otx2_eth_sec_ctx_destroy(struct rte_eth_dev *eth_dev); + +#endif /* __OTX2_ETHDEV_SEC_H__ */ -- 2.7.4