From patchwork Tue Aug 11 12:29:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hemant Agrawal X-Patchwork-Id: 247612 Delivered-To: patch@linaro.org Received: by 2002:a92:cc90:0:0:0:0:0 with SMTP id x16csp545857ilo; Tue, 11 Aug 2020 05:35:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJySELmN/FQLq1MCksgGA4RWDndFla2nijmry5vWDbqFTrOFcB2KRTab3ZcDiMNUTayWc3aX X-Received: by 2002:a25:5557:: with SMTP id j84mr49164916ybb.461.1597149330553; Tue, 11 Aug 2020 05:35:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597149330; cv=none; d=google.com; s=arc-20160816; b=z/DoaShRzR1wKa8nSpknKiTwIrUbeGn95r5uXtj1VZz8f07Ei4zsCSkGLF4QZ8fxxX 8e7RysdvG47mLtDomEzb7TKauMH4Iv+H+eF3Rh9NQuZTEW8oLtDdsDhiVtAa9SG8DSKM Ut6RAs599tzKw8P93llaQIZDJdm6KgJN/fxl+0CY0O8OE69KSeHxj/Bk+rOd9NtC98lO SZakebMG38a73YJekwdQ02k8EL6j+oBCsqV3Ist9sV0Uuz7u72C3BF9ojFzdpwdP/AsD Pjq2Dat07NbLScfNrwqTaPdjsHOZlGQwHeJtlznIxg1i2NprWGgByKjcNKiUP5qqVYGm xnig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:cc:to:from; bh=XwZDar0GCMA424Gd+Rve3oXhYSGy4fwo/JzWAr7zY+A=; b=yO+xQgZFg/mbsNgR+SBgIDdtPBERSL7t6HdkrafIlRnZ3YJNxtMikNGDz56QBTDh02 GZbHjH5K5klES8G/4DRhSJ/V7bHlht3eAbht77fuNFj/1YN7f7Kb+/NejkwQ/wefLOQD sOxoF+RVR/JWuhlcld4t0PGrsExhTCWk0HYMQkhqMO7YIthyv0IYiI7Np9qvaShWNYJY oUwq36a5iANrmpSodWHMYnRdLmlNUr51SwR96PQKz5fHbDRDRoqjCu+J/w/tPa42WDNa M1VkKoxp7qwfvS3PiJL8+wgpYfmKA9K170MELh+4tVpeCqV+VsUw9zuBZ+C+ardd73uI ToJA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from dpdk.org (dpdk.org. [92.243.14.124]) by mx.google.com with ESMTP id b10si8115307ybq.340.2020.08.11.05.35.29; Tue, 11 Aug 2020 05:35:30 -0700 (PDT) Received-SPF: pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) client-ip=92.243.14.124; Authentication-Results: mx.google.com; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 003771C00D; Tue, 11 Aug 2020 14:35:28 +0200 (CEST) Received: from inva020.nxp.com (inva020.nxp.com [92.121.34.13]) by dpdk.org (Postfix) with ESMTP id 0447C4C99 for ; Tue, 11 Aug 2020 14:35:26 +0200 (CEST) Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id C04A11A1F5B; Tue, 11 Aug 2020 14:35:26 +0200 (CEST) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 2E9441A170D; Tue, 11 Aug 2020 14:35:25 +0200 (CEST) Received: from bf-netperf1.ap.freescale.net (bf-netperf1.ap.freescale.net [10.232.133.63]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id 0A71C402DD; Tue, 11 Aug 2020 14:35:22 +0200 (CEST) From: Hemant Agrawal To: dev@dpdk.org Cc: Jun Yang Date: Tue, 11 Aug 2020 17:59:55 +0530 Message-Id: <20200811123001.30045-2-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200811123001.30045-1-hemant.agrawal@nxp.com> References: <20200711081716.25173-1-hemant.agrawal@nxp.com> <20200811123001.30045-1-hemant.agrawal@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Subject: [dpdk-dev] [PATCH v4 2/8] net/dpaa: add VSP support in FMLIB 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" From: Jun Yang This patch adds support for VSP (Virtual Storage Profile) in fmlib routines. VSP allow a network interface to be divided into physical and virtual instance(s). The concept is very similar to SRIOV. Signed-off-by: Jun Yang Acked-by: Hemant Agrawal --- drivers/net/dpaa/Makefile | 1 + drivers/net/dpaa/fmlib/fm_vsp.c | 143 +++++++++++++++++++++++++ drivers/net/dpaa/fmlib/fm_vsp_ext.h | 155 ++++++++++++++++++++++++++++ drivers/net/dpaa/meson.build | 1 + 4 files changed, 300 insertions(+) create mode 100644 drivers/net/dpaa/fmlib/fm_vsp.c create mode 100644 drivers/net/dpaa/fmlib/fm_vsp_ext.h -- 2.17.1 diff --git a/drivers/net/dpaa/Makefile b/drivers/net/dpaa/Makefile index deb9d5ed61..5eaa4abcb5 100644 --- a/drivers/net/dpaa/Makefile +++ b/drivers/net/dpaa/Makefile @@ -28,6 +28,7 @@ EXPORT_MAP := rte_pmd_dpaa_version.map # Interfaces with DPDK SRCS-$(CONFIG_RTE_LIBRTE_DPAA_PMD) += fmlib/fm_lib.c +SRCS-$(CONFIG_RTE_LIBRTE_DPAA_PMD) += fmlib/fm_vsp.c SRCS-$(CONFIG_RTE_LIBRTE_DPAA_PMD) += dpaa_ethdev.c SRCS-$(CONFIG_RTE_LIBRTE_DPAA_PMD) += dpaa_rxtx.c diff --git a/drivers/net/dpaa/fmlib/fm_vsp.c b/drivers/net/dpaa/fmlib/fm_vsp.c new file mode 100644 index 0000000000..6396bb6855 --- /dev/null +++ b/drivers/net/dpaa/fmlib/fm_vsp.c @@ -0,0 +1,143 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright 2019-2020 NXP + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include "fm_ext.h" +#include "fm_pcd_ext.h" +#include "fm_port_ext.h" +#include "fm_vsp_ext.h" +#include + +uint32_t FM_PORT_VSPAlloc(t_handle h_fm_port, + t_fm_port_vspalloc_params *p_params) +{ + t_device *p_dev = (t_device *)h_fm_port; + ioc_fm_port_vsp_alloc_params_t params; + + _fml_dbg("Calling...\n"); + memset(¶ms, 0, sizeof(ioc_fm_port_vsp_alloc_params_t)); + memcpy(¶ms.params, p_params, sizeof(t_fm_port_vspalloc_params)); + + if (ioctl(p_dev->fd, FM_PORT_IOC_VSP_ALLOC, ¶ms)) + RETURN_ERROR(MINOR, E_INVALID_OPERATION, NO_MSG); + + _fml_dbg("Called.\n"); + + return E_OK; +} + +t_handle fm_vsp_config(t_fm_vsp_params *p_fm_vsp_params) +{ + t_device *p_dev = NULL; + t_device *p_vsp_dev = NULL; + ioc_fm_vsp_params_t param; + + p_dev = p_fm_vsp_params->h_fm; + + _fml_dbg("Performing VSP Configuration...\n"); + + memset(¶m, 0, sizeof(ioc_fm_vsp_params_t)); + memcpy(¶m, p_fm_vsp_params, sizeof(t_fm_vsp_params)); + param.vsp_params.h_fm = UINT_TO_PTR(p_dev->id); + param.id = NULL; + + if (ioctl(p_dev->fd, FM_IOC_VSP_CONFIG, ¶m)) { + DPAA_PMD_ERR("%s ioctl error\n", __func__); + return NULL; + } + + p_vsp_dev = (t_device *)malloc(sizeof(t_device)); + if (!p_vsp_dev) { + DPAA_PMD_ERR("FM VSP Params!\n"); + return NULL; + } + memset(p_vsp_dev, 0, sizeof(t_device)); + p_vsp_dev->h_user_priv = (t_handle)p_dev; + p_dev->owners++; + p_vsp_dev->id = PTR_TO_UINT(param.id); + + _fml_dbg("VSP Configuration completed\n"); + + return (t_handle)p_vsp_dev; +} + +uint32_t fm_vsp_init(t_handle h_fm_vsp) +{ + t_device *p_dev = NULL; + t_device *p_vsp_dev = (t_device *)h_fm_vsp; + ioc_fm_obj_t id; + + _fml_dbg("Calling...\n"); + + p_dev = (t_device *)p_vsp_dev->h_user_priv; + id.obj = UINT_TO_PTR(p_vsp_dev->id); + + if (ioctl(p_dev->fd, FM_IOC_VSP_INIT, &id)) { + DPAA_PMD_ERR("%s ioctl error\n", __func__); + RETURN_ERROR(MINOR, E_INVALID_OPERATION, NO_MSG); + } + + _fml_dbg("Called.\n"); + + return E_OK; +} + +uint32_t fm_vsp_free(t_handle h_fm_vsp) +{ + t_device *p_dev = NULL; + t_device *p_vsp_dev = (t_device *)h_fm_vsp; + ioc_fm_obj_t id; + + _fml_dbg("Calling...\n"); + + p_dev = (t_device *)p_vsp_dev->h_user_priv; + id.obj = UINT_TO_PTR(p_vsp_dev->id); + + if (ioctl(p_dev->fd, FM_IOC_VSP_FREE, &id)) { + DPAA_PMD_ERR("%s ioctl error\n", __func__); + RETURN_ERROR(MINOR, E_INVALID_OPERATION, NO_MSG); + } + + p_dev->owners--; + free(p_vsp_dev); + + _fml_dbg("Called.\n"); + + return E_OK; +} + +uint32_t fm_vsp_config_buffer_prefix_content(t_handle h_fm_vsp, + t_fm_buffer_prefix_content *p_fm_buffer_prefix_content) +{ + t_device *p_dev = NULL; + t_device *p_vsp_dev = (t_device *)h_fm_vsp; + ioc_fm_buffer_prefix_content_params_t params; + + _fml_dbg("Calling...\n"); + + p_dev = (t_device *)p_vsp_dev->h_user_priv; + params.p_fm_vsp = UINT_TO_PTR(p_vsp_dev->id); + memcpy(¶ms.fm_buffer_prefix_content, + p_fm_buffer_prefix_content, sizeof(*p_fm_buffer_prefix_content)); + + if (ioctl(p_dev->fd, FM_IOC_VSP_CONFIG_BUFFER_PREFIX_CONTENT, + ¶ms)) { + DPAA_PMD_ERR("%s ioctl error\n", __func__); + RETURN_ERROR(MINOR, E_INVALID_OPERATION, NO_MSG); + } + + _fml_dbg("Called.\n"); + + return E_OK; +} diff --git a/drivers/net/dpaa/fmlib/fm_vsp_ext.h b/drivers/net/dpaa/fmlib/fm_vsp_ext.h new file mode 100644 index 0000000000..32918f40a7 --- /dev/null +++ b/drivers/net/dpaa/fmlib/fm_vsp_ext.h @@ -0,0 +1,155 @@ +/* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0) + * + * Copyright 2008-2012 Freescale Semiconductor, Inc + * Copyright 2019-2020 NXP + * + */ + +/* + * @File fm_vsp_ext.h + * + * @Description FM Virtual Storage-Profile + */ +#ifndef __FM_VSP_EXT_H +#define __FM_VSP_EXT_H +#include "ncsw_ext.h" +#include "fm_ext.h" +#include "net_ext.h" + +typedef struct t_fm_vsp_params { + t_handle h_fm; + /**< A handle to the FM object this VSP related to */ + t_fm_ext_pools ext_buf_pools; + /**< Which external buffer pools are used (up to + * FM_PORT_MAX_NUM_OF_EXT_POOLS), and their sizes. + * Parameter associated with Rx / OP port + */ + uint16_t liodn_offset; /**< VSP's LIODN offset */ + struct { + e_fm_port_type port_type; /**< Port type */ + uint8_t port_id; /**< Port Id - relative to type */ + } port_params; + uint8_t relative_profile_id; + /**< VSP Id - relative to VSP's range defined in + * relevant FM object + */ +} t_fm_vsp_params; + +typedef struct ioc_fm_vsp_params_t { + struct t_fm_vsp_params vsp_params; + void *id; /**< return value */ +} ioc_fm_vsp_params_t; + +typedef struct t_fm_port_vspalloc_params { + uint8_t num_of_profiles; + /**< Number of Virtual Storage Profiles; must be a power of 2 */ + uint8_t dflt_relative_id; + /**< The default Virtual-Storage-Profile-id dedicated to Rx/OP port. The + * same default Virtual-Storage-Profile-id will be for coupled Tx port + * if relevant function called for Rx port + */ +} t_fm_port_vspalloc_params; + +typedef struct ioc_fm_port_vsp_alloc_params_t { + struct t_fm_port_vspalloc_params params; + void *p_fm_tx_port; + /**< Handle to coupled Tx Port; not relevant for OP port. */ +} ioc_fm_port_vsp_alloc_params_t; + +typedef struct ioc_fm_buffer_prefix_content_t { + uint16_t priv_data_size; + /**< Number of bytes to be left at the beginning of the external + * buffer; Note that the private-area will start from the base + * of the buffer address. + */ + bool pass_prs_result; + /**< TRUE to pass the parse result to/from the FM; User + * may use fm_port_get_buffer_prs_result() in order to + * get the parser-result from a buffer. + */ + bool pass_time_stamp; + /**< TRUE to pass the timeStamp to/from the FM User may + * use fm_port_get_buffer_time_stamp() in order to get + * the parser-result from a buffer. + */ + bool pass_hash_result; + /**< TRUE to pass the KG hash result to/from the FM User + * may use fm_port_get_buffer_hash_result() in order to + * get the parser-result from a buffer. + */ + bool pass_all_other_pcd_info; + /**< Add all other Internal-Context information: AD, + * hash-result, key, etc. + */ + uint16_t data_align; + /**< 0 to use driver's default alignment [64], + * other value for selecting a data alignment (must be a + * power of 2); if write optimization is used, must be + * >= 16. + */ + uint8_t manip_extra_space; + /**< Maximum extra size needed + * (insertion-size minus removal-size); + * Note that this field impacts the size of the + * buffer-prefix (i.e. it pushes the data offset); + * This field is irrelevant if DPAA_VERSION==10 + */ +} ioc_fm_buffer_prefix_content_t; + +typedef struct ioc_fm_buffer_prefix_content_params_t { + void *p_fm_vsp; + ioc_fm_buffer_prefix_content_t fm_buffer_prefix_content; +} ioc_fm_buffer_prefix_content_params_t; + +uint32_t FM_PORT_VSPAlloc(t_handle h_fm_port, + t_fm_port_vspalloc_params *p_params); + +t_handle fm_vsp_config(t_fm_vsp_params *p_fm_vsp_params); + +uint32_t fm_vsp_init(t_handle h_fm_vsp); + +uint32_t fm_vsp_free(t_handle h_fm_vsp); + +uint32_t fm_vsp_config_buffer_prefix_content(t_handle h_fm_vsp, + t_fm_buffer_prefix_content *p_fm_buffer_prefix_content); + +#if defined(CONFIG_COMPAT) +#define FM_PORT_IOC_VSP_ALLOC_COMPAT \ + _IOW(FM_IOC_TYPE_BASE, FM_PORT_IOC_NUM(38), \ + ioc_compat_fm_port_vsp_alloc_params_t) +#endif +#define FM_PORT_IOC_VSP_ALLOC \ + _IOW(FM_IOC_TYPE_BASE, FM_PORT_IOC_NUM(38), \ + ioc_fm_port_vsp_alloc_params_t) + +#if defined(CONFIG_COMPAT) +#define FM_IOC_VSP_CONFIG_COMPAT \ + _IOWR(FM_IOC_TYPE_BASE, FM_IOC_NUM(8), ioc_compat_fm_vsp_params_t) +#endif +#define FM_IOC_VSP_CONFIG \ + _IOWR(FM_IOC_TYPE_BASE, FM_IOC_NUM(8), ioc_fm_vsp_params_t) + +#if defined(CONFIG_COMPAT) +#define FM_IOC_VSP_INIT_COMPAT \ + _IOW(FM_IOC_TYPE_BASE, FM_IOC_NUM(9), ioc_compat_fm_obj_t) +#endif +#define FM_IOC_VSP_INIT \ + _IOW(FM_IOC_TYPE_BASE, FM_IOC_NUM(9), ioc_fm_obj_t) + +#if defined(CONFIG_COMPAT) +#define FM_IOC_VSP_FREE_COMPAT \ + _IOW(FM_IOC_TYPE_BASE, FM_IOC_NUM(10), ioc_compat_fm_obj_t) +#endif +#define FM_IOC_VSP_FREE \ + _IOW(FM_IOC_TYPE_BASE, FM_IOC_NUM(10), ioc_fm_obj_t) + +#if defined(CONFIG_COMPAT) +#define FM_IOC_VSP_CONFIG_BUFFER_PREFIX_CONTENT_COMPAT \ + _IOW(FM_IOC_TYPE_BASE, FM_IOC_NUM(12), \ + ioc_compat_fm_buffer_prefix_content_params_t) +#endif +#define FM_IOC_VSP_CONFIG_BUFFER_PREFIX_CONTENT \ + _IOW(FM_IOC_TYPE_BASE, FM_IOC_NUM(12), \ + ioc_fm_buffer_prefix_content_params_t) + +#endif /* __FM_VSP_EXT_H */ diff --git a/drivers/net/dpaa/meson.build b/drivers/net/dpaa/meson.build index 67803cd34a..94d5095281 100644 --- a/drivers/net/dpaa/meson.build +++ b/drivers/net/dpaa/meson.build @@ -9,6 +9,7 @@ deps += ['mempool_dpaa'] sources = files('dpaa_ethdev.c', 'fmlib/fm_lib.c', + 'fmlib/fm_vsp.c', 'dpaa_rxtx.c') if cc.has_argument('-Wno-pointer-arith')