From patchwork Fri Jul 10 17:19:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hemant Agrawal X-Patchwork-Id: 235257 Delivered-To: patch@linaro.org Received: by 2002:a92:d244:0:0:0:0:0 with SMTP id v4csp647703ilg; Fri, 10 Jul 2020 10:24:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy7IP9zy8EsGSGyWI+14TjEMjEVul3tY5jSMrFZzfeRO0ErKze1KaefRNq5uK0O5hdAXmig X-Received: by 2002:a17:906:1453:: with SMTP id q19mr8788574ejc.111.1594401856007; Fri, 10 Jul 2020 10:24:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594401856; cv=none; d=google.com; s=arc-20160816; b=YGKsTNNB017jrMviv6wTWZ2Q31TGP3YfMjCZ1H0WFG2t2nUUtwK/zTO5Q8LHFRfdBt efaGtYuT0Ui8J5DGLW8fMuGX3jmDcy4p1VxfFdgVi1RcHoVtGGn4YxBEGvjV4MwEYRvL JImGBCStJxgEk/PNz76jegI8ZAqv5T6J9xi/6GGhrKZd6MYErtOBEAwXJ998bxa9G71R EYswo9wKqJqT/kdC4mF4q6SldpSpaxu7FKsfChDLDk6HK9JrIbYp6WYt/8x8AWr2m2er msdG1PwchmsV8YbGX8uX4l4KHhefRetrIIMmTDqA3HcVDdY6tmJURGMDU4HxClho+t3n vI5g== 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=tERtCnlpGd3xiOPXEUdHIfn7gsc5RVrKnyS2hAhQAn4=; b=gFHOvQh30xS9riHeUdblYUogUh870e2Cz4MUr0fgsVqHMN6IMdt1xfu5Xps5qwU2lp nc/bP2ERP59CWWYx2wUtwpWAt6OAYjjEuO2o0K9web6CzRzlSnZLNcfMwgrfKqwmbfmj 27P0mG4TEDrp2OrEovfqhyJsbO2H1gkx+QTUFJ8utCg26kUqcY2aIRMGEyYawU9pFDD8 E8MaNMNS9gSsMODcYaaBLtAZd6+/atVSvf+v+JHoitpK9TN0jTSaWhsTZG/TJjpYOHlt oom7RXp+f4tSroRKFAECCeEPMguuwCpFQnZRNvefV4M0y0gFwT4Z1ACNT/8N3HrytTYK eqmg== 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 yh22si4791917ejb.62.2020.07.10.10.24.15; Fri, 10 Jul 2020 10:24:15 -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 16FB01DD9C; Fri, 10 Jul 2020 19:24:13 +0200 (CEST) Received: from inva020.nxp.com (inva020.nxp.com [92.121.34.13]) by dpdk.org (Postfix) with ESMTP id 1AD791DD94 for ; Fri, 10 Jul 2020 19:24:11 +0200 (CEST) Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id ECEA11A04A6; Fri, 10 Jul 2020 19:24:10 +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 1D0401A04A5; Fri, 10 Jul 2020 19:24:09 +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 D8142402E3; Sat, 11 Jul 2020 01:24:06 +0800 (SGT) From: Hemant Agrawal To: dev@dpdk.org Cc: ferruh.yigit@intel.com, Jun Yang Date: Fri, 10 Jul 2020 22:49:40 +0530 Message-Id: <20200710171946.23246-3-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200710171946.23246-1-hemant.agrawal@nxp.com> References: <20200710171946.23246-1-hemant.agrawal@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Subject: [dpdk-dev] [PATCH v2 3/9] 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 --- drivers/net/dpaa/Makefile | 1 + drivers/net/dpaa/fmlib/fm_vsp.c | 143 ++++++++++++++++++++++++++++ drivers/net/dpaa/fmlib/fm_vsp_ext.h | 141 +++++++++++++++++++++++++++ drivers/net/dpaa/meson.build | 1 + 4 files changed, 286 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 0d2f32ba1..8db4e457f 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 000000000..b511b5159 --- /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_FmPort, + t_FmPortVSPAllocParams *p_Params) +{ + t_Device *p_Dev = (t_Device *)h_FmPort; + 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_FmPortVSPAllocParams)); + + 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_FmVspParams *p_FmVspParams) +{ + t_Device *p_Dev = NULL; + t_Device *p_VspDev = NULL; + ioc_fm_vsp_params_t param; + + p_Dev = p_FmVspParams->h_Fm; + + _fml_dbg("Performing VSP Configuration...\n"); + + memset(¶m, 0, sizeof(ioc_fm_vsp_params_t)); + memcpy(¶m, p_FmVspParams, sizeof(t_FmVspParams)); + 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_VspDev = (t_Device *)malloc(sizeof(t_Device)); + if (!p_VspDev) { + DPAA_PMD_ERR("FM VSP Params!\n"); + return NULL; + } + memset(p_VspDev, 0, sizeof(t_Device)); + p_VspDev->h_UserPriv = (t_Handle)p_Dev; + p_Dev->owners++; + p_VspDev->id = PTR_TO_UINT(param.id); + + _fml_dbg("VSP Configuration completed\n"); + + return (t_Handle)p_VspDev; +} + +uint32_t FM_VSP_Init(t_Handle h_FmVsp) +{ + t_Device *p_Dev = NULL; + t_Device *p_VspDev = (t_Device *)h_FmVsp; + ioc_fm_obj_t id; + + _fml_dbg("Calling...\n"); + + p_Dev = (t_Device *)p_VspDev->h_UserPriv; + id.obj = UINT_TO_PTR(p_VspDev->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_FmVsp) +{ + t_Device *p_Dev = NULL; + t_Device *p_VspDev = (t_Device *)h_FmVsp; + ioc_fm_obj_t id; + + _fml_dbg("Calling...\n"); + + p_Dev = (t_Device *)p_VspDev->h_UserPriv; + id.obj = UINT_TO_PTR(p_VspDev->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_VspDev); + + _fml_dbg("Called.\n"); + + return E_OK; +} + +uint32_t FM_VSP_ConfigBufferPrefixContent(t_Handle h_FmVsp, + t_FmBufferPrefixContent *p_FmBufferPrefixContent) +{ + t_Device *p_Dev = NULL; + t_Device *p_VspDev = (t_Device *)h_FmVsp; + ioc_fm_buffer_prefix_content_params_t params; + + _fml_dbg("Calling...\n"); + + p_Dev = (t_Device *)p_VspDev->h_UserPriv; + params.p_fm_vsp = UINT_TO_PTR(p_VspDev->id); + memcpy(¶ms.fm_buffer_prefix_content, + p_FmBufferPrefixContent, sizeof(*p_FmBufferPrefixContent)); + + 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 000000000..904f5312d --- /dev/null +++ b/drivers/net/dpaa/fmlib/fm_vsp_ext.h @@ -0,0 +1,141 @@ +/* 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_FmVspParams { + t_Handle h_Fm; + /**< A handle to the FM object this VSP related to */ + t_FmExtPools extBufPools;/**< 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 liodnOffset; /**< VSP's LIODN offset */ + struct { + e_FmPortType portType; /**< Port type */ + uint8_t portId; /**< Port Id - relative to type */ + } portParams; + uint8_t relativeProfileId; /**< VSP Id - relative to VSP's range + defined in relevant FM object */ +} t_FmVspParams; + +typedef struct ioc_fm_vsp_params_t { + struct t_FmVspParams vsp_params; + void *id; /**< return value */ +} ioc_fm_vsp_params_t; + +typedef struct t_FmPortVSPAllocParams { + uint8_t numOfProfiles; + /**< Number of Virtual Storage Profiles; must be a power of 2 */ + uint8_t dfltRelativeId; + /**< 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_FmPortVSPAllocParams; + +typedef struct ioc_fm_port_vsp_alloc_params_t { + struct t_FmPortVSPAllocParams 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_GetBufferPrsResult() 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_GetBufferTimeStamp() 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_GetBufferHashResult() 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_FmPort, t_FmPortVSPAllocParams *p_Params); + +t_Handle FM_VSP_Config(t_FmVspParams *p_FmVspParams); + +uint32_t FM_VSP_Init(t_Handle h_FmVsp); + +uint32_t FM_VSP_Free(t_Handle h_FmVsp); + +uint32_t FM_VSP_ConfigBufferPrefixContent(t_Handle h_FmVsp, + t_FmBufferPrefixContent *p_FmBufferPrefixContent); + +#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 67803cd34..94d509528 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')