From patchwork Tue Sep 1 12:36:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hemant Agrawal X-Patchwork-Id: 248854 Delivered-To: patch@linaro.org Received: by 2002:a92:5b9c:0:0:0:0:0 with SMTP id c28csp4195618ilg; Tue, 1 Sep 2020 05:43:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw14c/nMc332bcCVcD9DqI5kMc9Kn7m6W/x77HQ9V2mBRIoWNuvzyvM86r7qth7NU5lSnD4 X-Received: by 2002:a05:6402:486:: with SMTP id k6mr1589562edv.83.1598964226834; Tue, 01 Sep 2020 05:43:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598964226; cv=none; d=google.com; s=arc-20160816; b=fRGYXosYEeQlu3rH75T50Sws8xuB107Mlx266ln5bg4/h1m1MzR7kMOo+wpFd9Cb9a SzfPFaTJePcDaGL57xobPV2hFogUvVIWQgY3Xo5gwMZheGgw+A+FDph6/DBImD52cHd6 OhbHBLYVWW4VWmGK75mXJ4xY6mXQYAF2cVtVHSW8RiPZGxHCAl6k1XMM03ygWBl4QMoP DIIkLiJ7tqqitGLWvF2NQdvJyRe+A9YYi7qkPVNuw1on6Hl2OFDQFV7v+6swo6Ueclx9 wRoPoiRgo17q8iPMRbMe5eeGLxGuxVmpzgPTK7HRUVOZECPjwHD6j/85EUOEo1++aBBa S9MA== 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=KoP9TM7hXGYEQ7gMY+wyPQTW0geHyHog6XJ4YMN/e+4=; b=CneB60XtTvLSJaQEZSr5rFscfYZSMtcG4ZCT9WuhDstskGIt3bGgLQaeE4+ZIZ80CV aDsyyLkY+IxR3Ds3V/LAimoLInnAojIaWUh6VBsx0KRpOJbfbAd2jaySuk4OWCQszNkc 8hn/7dEGvDVr7eKPbL39Vv2p97/ckzHWRcnqa4mxR9kQzv/nAiEtJVIA7peVHDJVymPw geVnb0SyxKhb0wYEuf2rMHCOS7bJ8dS11pU7GECL/lwPlP1to2Nt5N670bAV3CPVzThV pY+m75/ggK07V07ir4cAg0nqVygZ4saVqxb6P0y+/L1GC3wabJjc/bUQOjxK+adrkUBb Ex8w== 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 a20si583331ejf.632.2020.09.01.05.43.46; Tue, 01 Sep 2020 05:43:46 -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 0B1351C1E9; Tue, 1 Sep 2020 14:43:07 +0200 (CEST) Received: from inva021.nxp.com (inva021.nxp.com [92.121.34.21]) by dpdk.org (Postfix) with ESMTP id 5F5AF1C123 for ; Tue, 1 Sep 2020 14:43:01 +0200 (CEST) Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id E1DB9200A5F; Tue, 1 Sep 2020 14:43:00 +0200 (CEST) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 0AE0B200046; Tue, 1 Sep 2020 14:42:57 +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 827DA4024E; Tue, 1 Sep 2020 14:42:54 +0200 (CEST) From: Hemant Agrawal To: dev@dpdk.org Cc: ferruh.yigit@intel.com Date: Tue, 1 Sep 2020 18:06:43 +0530 Message-Id: <20200901123650.29908-1-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200813180121.19480-1-hemant.agrawal@nxp.com> References: <20200813180121.19480-1-hemant.agrawal@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Subject: [dpdk-dev] [PATCH v6 1/8] net/dpaa: add support for fmlib in dpdk 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" DPAA platorm MAC interface is known as FMAN i.e. Frame Manager. There are two ways to control it. 1. Statically configure the queues and classification rules before the start of the application using FMC tool. 2. Dynamically configure it within application by making API calls of fmlib. The fmlib or Frame Manager library provides an API on top of the Frame Manager driver ioctl calls, that provides a user space application with a simple way to configure driver parameters and PCD (parse - classify - distribute) rules. This patch integrates the base fmlib so that various queue config, RSS and classification related features can be supported on DPAA platform. Signed-off-by: Sachin Saxena Signed-off-by: Hemant Agrawal --- doc/guides/nics/dpaa.rst | 52 +- doc/guides/platform/dpaa.rst | 21 +- drivers/net/dpaa/fmlib/dpaa_integration.h | 50 + drivers/net/dpaa/fmlib/fm_ext.h | 463 ++ drivers/net/dpaa/fmlib/fm_lib.c | 561 ++ drivers/net/dpaa/fmlib/fm_pcd_ext.h | 5787 +++++++++++++++++++++ drivers/net/dpaa/fmlib/fm_port_ext.h | 3350 ++++++++++++ drivers/net/dpaa/fmlib/ncsw_ext.h | 158 + drivers/net/dpaa/fmlib/net_ext.h | 411 ++ drivers/net/dpaa/meson.build | 3 +- 10 files changed, 10849 insertions(+), 7 deletions(-) create mode 100644 drivers/net/dpaa/fmlib/dpaa_integration.h create mode 100644 drivers/net/dpaa/fmlib/fm_ext.h create mode 100644 drivers/net/dpaa/fmlib/fm_lib.c create mode 100644 drivers/net/dpaa/fmlib/fm_pcd_ext.h create mode 100644 drivers/net/dpaa/fmlib/fm_port_ext.h create mode 100644 drivers/net/dpaa/fmlib/ncsw_ext.h create mode 100644 drivers/net/dpaa/fmlib/net_ext.h -- 2.17.1 diff --git a/doc/guides/nics/dpaa.rst b/doc/guides/nics/dpaa.rst index 17839a920..7e6010471 100644 --- a/doc/guides/nics/dpaa.rst +++ b/doc/guides/nics/dpaa.rst @@ -1,5 +1,5 @@ .. SPDX-License-Identifier: BSD-3-Clause - Copyright 2017 NXP + Copyright 2017,2020 NXP DPAA Poll Mode Driver @@ -21,6 +21,7 @@ Contents summary - DPAA overview - DPAA driver architecture overview +- FMAN configuration tools and library .. _dpaa_overview: @@ -285,6 +286,55 @@ for details. Done testpmd> +FMAN Config +----------- + +Frame Manager is also responsible for parser, classify and distribute +functionality in the DPAA. + + FMAN supports: + Packet parsing at wire speed. It supports standard protocols parsing and + identification by HW (VLAN/IP/UDP/TCP/SCTP/PPPoE/PPP/MPLS/GRE/IPSec). + It supports non-standard UDF header parsing for custom protocols. + Classification / Distribution: Coarse classification based on Key generation + Hash and exact match lookup + +FMC - FMAN Configuration Tool +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + This tool is available in User Space. The tool is used to configure FMAN + Physical (MAC) or Ephemeral (OH)ports for Parse/Classify/distribute. + The PCDs can be hash based where a set of fields are key input for hash + generation within FMAN keygen. The hash value is used to generate a FQID for + frame. There is a provision to setup exact match lookup too where field + values within a packet drives corresponding FQID. + Currently it works on XML file inputs. + + Limitations: + 1.For Dynamic Configuration change, currently no support is available. + E.g. enable/disable a port, a operator (set of VLANs and associate rules). + + 2.During FMC configuration, port for which policy is being configured is + brought down and the policy is flushed on port before new policy is updated + for the port. Support is required to add/append/delete etc. + + 3.FMC, being a separate user-space application, needs to be invoked from + Shell. + + + The details can be found in FMC Doc at: + `Frame Mnager Configuration Tool `_. + +FMLIB +~~~~~ + The Frame Manager library provides an API on top of the Frame Manager driver + ioctl calls, that provides a user space application with a simple way to + configure driver parameters and PCD (parse - classify - distribute) rules. + + This is an alternate to the FMC based configuration. This libray provides + direct ioctl based interfaces for FMAN configuration as used by the FMC tool + as well. This helps in overcoming the main limitaiton of FMC - i.e. lack + of dynamic configuration. + Limitations ----------- diff --git a/doc/guides/platform/dpaa.rst b/doc/guides/platform/dpaa.rst index 6005f2221..20a0e3932 100644 --- a/doc/guides/platform/dpaa.rst +++ b/doc/guides/platform/dpaa.rst @@ -58,17 +58,28 @@ compatible board: 4. **FMC Tool** - Before any DPDK application can be executed, the Frame Manager Configuration - Tool (FMC) need to be executed to set the configurations of the queues. This + If one is planning to use more than 1 Recv queue and hardware capability to + parse, classify and distribute the packets, the Frame Manager Configuration + Tool (FMC) need to be executed to set the configurations of the queues before + running the DPAA based DPDK application. This setting is persistent, the + configuration will remain in the hardware till it is re-configured. This includes the queue state, RSS and other policies. This tool can be obtained from `NXP (Freescale) Public Git Repository `_. This tool needs configuration files which are available in the :ref:`DPDK Extra Scripts `, described below for DPDK usages. -As an alternative method, DPAA PMD can also be executed using images provided -as part of SDK from NXP. The SDK includes all the above prerequisites necessary -to bring up a DPAA board. + Note that DPAA PMD can also be executed using images provided + as part of SDK from NXP. The SDK includes all the above prerequisites + necessary (i.e. fmc tool) to bring up a DPAA board. + + As an alternate method, DPAA PMDs starting from DPDK 20.11 also support the + fmlib library integration. The driver will detect about any existing FMC + based config (if /tmp/fmc.bin is present). DPAA FMD will be used only if no + previous fmc config is existing. + + Note that fmlib based integratin rely on underlying fmd driver in kernel, + which is available as part of NXP kernel or NXP SDK. The following dependencies are not part of DPDK and must be installed separately: diff --git a/drivers/net/dpaa/fmlib/dpaa_integration.h b/drivers/net/dpaa/fmlib/dpaa_integration.h new file mode 100644 index 000000000..33b9619f9 --- /dev/null +++ b/drivers/net/dpaa/fmlib/dpaa_integration.h @@ -0,0 +1,50 @@ +/* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0) + * Copyright 2009-2012 Freescale Semiconductor Inc. + * Copyright 2017-2020 NXP + */ + +#ifndef __DPAA_INTEGRATION_H +#define __DPAA_INTEGRATION_H + +#include "ncsw_ext.h" + +#define DPAA_VERSION 11 + +#define BM_MAX_NUM_OF_POOLS 64 /**< Number of buffers pools */ + +#define INTG_MAX_NUM_OF_FM 2 + +/* Ports defines */ +#define FM_MAX_NUM_OF_1G_MACS 6 +#define FM_MAX_NUM_OF_10G_MACS 2 +#define FM_MAX_NUM_OF_MACS (FM_MAX_NUM_OF_1G_MACS + FM_MAX_NUM_OF_10G_MACS) +#define FM_MAX_NUM_OF_OH_PORTS 6 + +#define FM_MAX_NUM_OF_1G_RX_PORTS FM_MAX_NUM_OF_1G_MACS +#define FM_MAX_NUM_OF_10G_RX_PORTS FM_MAX_NUM_OF_10G_MACS +#define FM_MAX_NUM_OF_RX_PORTS \ + (FM_MAX_NUM_OF_10G_RX_PORTS + FM_MAX_NUM_OF_1G_RX_PORTS) + +#define FM_MAX_NUM_OF_1G_TX_PORTS FM_MAX_NUM_OF_1G_MACS +#define FM_MAX_NUM_OF_10G_TX_PORTS FM_MAX_NUM_OF_10G_MACS +#define FM_MAX_NUM_OF_TX_PORTS \ + (FM_MAX_NUM_OF_10G_TX_PORTS + FM_MAX_NUM_OF_1G_TX_PORTS) + +#define FM_PORT_MAX_NUM_OF_EXT_POOLS 4 + /**< Number of external BM pools per Rx port */ +#define FM_NUM_CONG_GRPS 256 + /**< Total number of congestion groups in QM */ +#define FM_MAX_NUM_OF_SUB_PORTALS 16 +#define FM_PORT_MAX_NUM_OF_OBSERVED_EXT_POOLS 0 + +/* PCD defines */ +#define FM_PCD_PLCR_NUM_ENTRIES 256 + /**< Total number of policer profiles */ +#define FM_PCD_KG_NUM_OF_SCHEMES 32 + /**< Total number of KG schemes */ +#define FM_PCD_MAX_NUM_OF_CLS_PLANS 256 + /**< Number of classification plan entries. */ + +#define FM_MAX_PFC_PRIO 8 + +#endif /* __DPAA_INTEGRATION_H */ diff --git a/drivers/net/dpaa/fmlib/fm_ext.h b/drivers/net/dpaa/fmlib/fm_ext.h new file mode 100644 index 000000000..27c9fb471 --- /dev/null +++ b/drivers/net/dpaa/fmlib/fm_ext.h @@ -0,0 +1,463 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright 2008-2012 Freescale Semiconductor Inc. + * Copyright 2017-2020 NXP + */ + +#ifndef __FM_EXT_H +#define __FM_EXT_H + +#include "ncsw_ext.h" +#include "dpaa_integration.h" + +#define FM_IOC_TYPE_BASE (NCSW_IOC_TYPE_BASE + 1) +#define FMT_IOC_TYPE_BASE (NCSW_IOC_TYPE_BASE + 3) + +#define MODULE_FM 0x00010000 +#define __ERR_MODULE__ MODULE_FM + +/* #define FM_LIB_DBG */ + +#if defined(FM_LIB_DBG) + #define _fml_dbg(fmt, args...) \ + rte_log(RTE_LOG_ ## level, dpaa_logtype_pmd, "fmlib:%s(): " fmt "\n", \ + __func__, ##args) +#else + #define _fml_dbg(arg...) +#endif + +/*#define FM_IOCTL_DBG*/ + +#if defined(FM_IOCTL_DBG) + #define _fm_ioctl_dbg(fmt, args...) \ + rte_log(RTE_LOG_ ## level, dpaa_logtype_pmd, "fmioc:%s(): " fmt "\n", \ + __func__, ##args) +#else + #define _fm_ioctl_dbg(arg...) +#endif + +/* + * @Group lnx_ioctl_ncsw_grp NetCommSw Linux User-Space (IOCTL) API + * @{ + */ + +#define NCSW_IOC_TYPE_BASE 0xe0 + /**< defines the IOCTL type for all the NCSW Linux module commands */ + +/* + * @Group lnx_usr_FM_grp Frame Manager API + * + * @Description FM API functions, definitions and enums. + * + * The FM module is the main driver module and is a mandatory + * module for FM driver users. This module must be initialized + * first prior to any other drivers modules. + * The FM is a "singleton" module. It is responsible of the + * common HW modules: FPM, DMA, common QMI and common BMI + * initializations and run-time control routines. This module + * must be initialized always when working with any of the FM modules. + * NOTE - We assume that the FM library will be initialized only + * by core No. 0! + * + * @{ + */ + +/* + * @Description Enum for defining port types + */ +typedef enum e_fm_port_type { + e_FM_PORT_TYPE_OH_OFFLINE_PARSING = 0, /**< Offline parsing port */ + e_FM_PORT_TYPE_RX, /**< 1G Rx port */ + e_FM_PORT_TYPE_RX_10G, /**< 10G Rx port */ + e_FM_PORT_TYPE_TX, /**< 1G Tx port */ + e_FM_PORT_TYPE_TX_10G, /**< 10G Tx port */ + e_FM_PORT_TYPE_RX_2_5G, /**< 2.5G Rx port */ + e_FM_PORT_TYPE_TX_2_5G, /**< 2.5G Tx port */ + e_FM_PORT_TYPE_DUMMY +} e_fm_port_type; + +/* + * @Description Parse results memory layout + */ +typedef struct t_fm_prs_result { + volatile uint8_t lpid; /**< Logical port id */ + volatile uint8_t shimr; /**< Shim header result */ + volatile uint16_t l2r; /**< Layer 2 result */ + volatile uint16_t l3r; /**< Layer 3 result */ + volatile uint8_t l4r; /**< Layer 4 result */ + volatile uint8_t cplan; /**< Classification plan id */ + volatile uint16_t nxthdr; /**< Next Header */ + volatile uint16_t cksum; /**< Running-sum */ + volatile uint16_t flags_frag_off; + /** 6)*/ + e_FM_EX_FPM_STALL_ON_TASKS, /**< Stall of tasks on FPM */ + e_FM_EX_FPM_SINGLE_ECC, /**< Single ECC on FPM. */ + e_FM_EX_FPM_DOUBLE_ECC, + /**< Double ECC error on FPM ram access */ + e_FM_EX_QMI_SINGLE_ECC, /**< Single ECC on QMI. */ + e_FM_EX_QMI_DOUBLE_ECC, /**< Double bit ECC occurred on QMI */ + e_FM_EX_QMI_DEQ_FROM_UNKNOWN_PORTID,/**< Dequeue from unknown port id */ + e_FM_EX_BMI_LIST_RAM_ECC, /**< Linked List RAM ECC error */ + e_FM_EX_BMI_STORAGE_PROFILE_ECC,/**< Storage Profile ECC Error */ + e_FM_EX_BMI_STATISTICS_RAM_ECC, + /**< Statistics Count RAM ECC Error Enable */ + e_FM_EX_BMI_DISPATCH_RAM_ECC, /**< Dispatch RAM ECC Error Enable */ + e_FM_EX_IRAM_ECC, /**< Double bit ECC occurred on IRAM*/ + e_FM_EX_MURAM_ECC /**< Double bit ECC occurred on MURAM*/ +} e_fm_exceptions; + +/* + * @Description Enum for defining port DMA cache attributes + */ +typedef enum e_fm_dma_cache_option { + e_FM_DMA_NO_STASH = 0, /**< Cacheable, no Allocate (No Stashing) */ + e_FM_DMA_STASH = 1 /**< Cacheable and Allocate (Stashing on) */ +} e_fm_dma_cache_option; +/* + * @Group lnx_usr_FM_init_grp FM Initialization Unit + * + * @Description FM Initialization Unit + * + * Initialization Flow + * Initialization of the FM Module will be carried out by the + * application according to the following sequence: + * - Calling the configuration routine with basic parameters. + * - Calling the advance initialization routines to change + * driver's defaults. + * - Calling the initialization routine. + * + * @{ + */ + +t_handle fm_open(uint8_t id); +void fm_close(t_handle h_fm); + +/* + * @Description A structure for defining buffer prefix area content. + */ +typedef struct t_fm_buffer_prefix_content { + 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_pcdinfo; + /**< 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_ext_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); + */ +} t_fm_buffer_prefix_content; + +/* + * @Description A structure of information about each of the external + * buffer pools used by a port or storage-profile. + */ +typedef struct t_fm_ext_pool_params { + uint8_t id; /**< External buffer pool id */ + uint16_t size; /**< External buffer pool buffer size */ +} t_fm_ext_pool_params; + +/* + * @Description A structure for informing the driver about the external + * buffer pools allocated in the BM and used by a port or a + * storage-profile. + */ +typedef struct t_fm_ext_pools { + uint8_t num_of_pools_used; + /**< Number of pools use by this port*/ + t_fm_ext_pool_params ext_buf_pool[FM_PORT_MAX_NUM_OF_EXT_POOLS]; + /**< Parameters for each port */ +} t_fm_ext_pools; + +/* + * @Description A structure for defining backup BM Pools. + */ +typedef struct t_fm_backup_bm_pools { + uint8_t num_bkup_pools; + /**< Number of BM backup pools - must be smaller than + * the total number of pools defined for the specified + * port. + */ + uint8_t pool_ids[FM_PORT_MAX_NUM_OF_EXT_POOLS]; + /**< num_bkup_pools pool id's, specifying which pools + * should be used only as backup. Pool id's specified + * here must be a subset of the pools used by the + * specified port. + */ +} t_fm_backup_bm_pools; + +/** @} */ /* end of lnx_usr_FM_init_grp group */ + +/* + * @Group lnx_usr_FM_runtime_control_grp FM Runtime Control Unit + * + * @Description FM Runtime control unit API functions, definitions and enums. + * + * The FM driver provides a set of control routines. + * These routines may only be called after the module was fully + * initialized (both configuration and initialization routines + * were called). They are typically used to get information from + * hardware (status, counters/statistics, revision etc.), to + * modify a current state or to force/enable a required action. + * Run-time control may be called whenever necessary and as many + * times as needed. + * @{ + */ + +/* + * @Collection General FM defines. + */ +#define FM_MAX_NUM_OF_VALID_PORTS (FM_MAX_NUM_OF_OH_PORTS + \ + FM_MAX_NUM_OF_1G_RX_PORTS + \ + FM_MAX_NUM_OF_10G_RX_PORTS + \ + FM_MAX_NUM_OF_1G_TX_PORTS + \ + FM_MAX_NUM_OF_10G_TX_PORTS) + /**< Number of available FM ports */ +/* @} */ + +/** @} */ /* end of lnx_usr_FM_runtime_control_grp group */ +/** @} */ /* end of lnx_usr_FM_lib_grp group */ +/** @} */ /* end of lnx_usr_FM_grp group */ + +/* + * @Description FM Char device ioctls + */ + +/* + * @Group lnx_ioctl_FM_grp Frame Manager Linux IOCTL API + * + * @Description FM Linux ioctls definitions and enums + * + * @{ + */ + +/* + * @Collection FM IOCTL device ('/dev') definitions + */ +#define DEV_FM_NAME "fm" /**< Name of the FM chardev */ + +#define DEV_FM_MINOR_BASE 0 +#define DEV_FM_PCD_MINOR_BASE (DEV_FM_MINOR_BASE + 1) + /*/dev/fmx-pcd */ +#define DEV_FM_OH_PORTS_MINOR_BASE (DEV_FM_PCD_MINOR_BASE + 1) + /*/dev/fmx-port-ohy */ +#define DEV_FM_RX_PORTS_MINOR_BASE \ + (DEV_FM_OH_PORTS_MINOR_BASE + FM_MAX_NUM_OF_OH_PORTS) + /*/dev/fmx-port-rxy */ +#define DEV_FM_TX_PORTS_MINOR_BASE \ + (DEV_FM_RX_PORTS_MINOR_BASE + FM_MAX_NUM_OF_RX_PORTS) + /*/dev/fmx-port-txy */ +#define DEV_FM_MAX_MINORS \ + (DEV_FM_TX_PORTS_MINOR_BASE + FM_MAX_NUM_OF_TX_PORTS) + +#define FM_IOC_NUM(n) (n) +#define FM_PCD_IOC_NUM(n) ((n) + 20) +#define FM_PORT_IOC_NUM(n) ((n) + 70) +/* @} */ + +#define IOC_FM_MAX_NUM_OF_PORTS 64 + +/* + * @Description Enum for defining port types + * (must match enum e_fm_port_type defined in fm_ext.h) + */ +typedef enum ioc_fm_port_type { + e_IOC_FM_PORT_TYPE_OH_OFFLINE_PARSING = 0, /**< Offline parsing port */ + e_IOC_FM_PORT_TYPE_RX, /**< 1G Rx port */ + e_IOC_FM_PORT_TYPE_RX_10G, /**< 10G Rx port */ + e_IOC_FM_PORT_TYPE_TX, /**< 1G Tx port */ + e_IOC_FM_PORT_TYPE_TX_10G, /**< 10G Tx port */ + e_IOC_FM_PORT_TYPE_DUMMY +} ioc_fm_port_type; + +typedef struct ioc_fm_obj_t { + void *obj; +} ioc_fm_obj_t; + +typedef union ioc_fm_api_version_t { + struct { + uint8_t major; + uint8_t minor; + uint8_t respin; + uint8_t reserved; + } version; + uint32_t ver; +} ioc_fm_api_version_t; + +/* + * @Function FM_IOC_GET_API_VERSION + * + * @Description Reads the FMD IOCTL API version. + * + * @Param[in,out] ioc_fm_api_version_t The requested counter parameters + * + * @Return Version's value. + */ +#define FM_IOC_GET_API_VERSION \ + _IOR(FM_IOC_TYPE_BASE, FM_IOC_NUM(7), ioc_fm_api_version_t) +#define FMD_API_VERSION_MAJOR 21 +#define FMD_API_VERSION_MINOR 1 +#define FMD_API_VERSION_RESPIN 0 + +uint32_t fm_get_api_version(t_handle h_fm, ioc_fm_api_version_t *p_version); + + +#endif /* __FM_EXT_H */ diff --git a/drivers/net/dpaa/fmlib/fm_lib.c b/drivers/net/dpaa/fmlib/fm_lib.c new file mode 100644 index 000000000..0d1ca1237 --- /dev/null +++ b/drivers/net/dpaa/fmlib/fm_lib.c @@ -0,0 +1,561 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright 2008-2016 Freescale Semiconductor Inc. + * Copyright 2017-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 + +#define DEV_TO_ID(p) \ + do { \ + t_device *p_dev = (t_device *)p; \ + p = UINT_TO_PTR(p_dev->id); \ + } while (0) + +/* Major and minor are in sync with FMD, respin is for fmlib identification */ +#define FM_LIB_VERSION_MAJOR 21 +#define FM_LIB_VERSION_MINOR 1 +#define FM_LIB_VERSION_RESPIN 0 + +#if (FMD_API_VERSION_MAJOR != FM_LIB_VERSION_MAJOR) || \ + (FMD_API_VERSION_MINOR != FM_LIB_VERSION_MINOR) +#warning FMD and FMLIB version mismatch +#endif + +t_handle +fm_open(uint8_t id) +{ + t_device *p_dev; + int fd; + char dev_name[20]; + static bool called; + ioc_fm_api_version_t ver; + + _fml_dbg("Calling...\n"); + + p_dev = (t_device *)malloc(sizeof(t_device)); + if (p_dev == NULL) + return NULL; + + memset(dev_name, 0, 20); + sprintf(dev_name, "%s%s%d", "/dev/", DEV_FM_NAME, id); + fd = open(dev_name, O_RDWR); + if (fd < 0) { + free(p_dev); + return NULL; + } + + p_dev->id = id; + p_dev->fd = fd; + if (!called) { + called = true; + fm_get_api_version((t_handle)p_dev, &ver); + + if (ver.version.major != FMD_API_VERSION_MAJOR || + ver.version.minor != FMD_API_VERSION_MINOR || + ver.version.respin != FMD_API_VERSION_RESPIN) { + DPAA_PMD_WARN("Compiled against FMD API ver %u.%u.%u", + FMD_API_VERSION_MAJOR, + FMD_API_VERSION_MINOR, FMD_API_VERSION_RESPIN); + DPAA_PMD_WARN("Running with FMD API ver %u.%u.%u", + ver.version.major, ver.version.minor, + ver.version.respin); + } + } + _fml_dbg("Finishing.\n"); + + return (t_handle)p_dev; +} + +void fm_close(t_handle h_fm) +{ + t_device *p_dev = (t_device *)h_fm; + + _fml_dbg("Calling...\n"); + + close(p_dev->fd); + free(p_dev); + + _fml_dbg("Finishing.\n"); +} + +uint32_t +fm_get_api_version(t_handle h_fm, ioc_fm_api_version_t *p_version) +{ + t_device *p_dev = (t_device *)h_fm; + int ret; + + _fml_dbg("Calling...\n"); + + ret = ioctl(p_dev->fd, FM_IOC_GET_API_VERSION, p_version); + if (ret) { + DPAA_PMD_ERR("cannot get API version, error %i (%s)\n", + errno, strerror(errno)); + RETURN_ERROR(MINOR, E_INVALID_OPERATION, NO_MSG); + } + _fml_dbg("Finishing.\n"); + + return E_OK; +} + +t_handle +fm_pcd_open(t_fm_pcd_params *p_fm_pcd_params) +{ + t_device *p_dev; + int fd; + char dev_name[20]; + + _fml_dbg("Calling...\n"); + + p_dev = (t_device *)malloc(sizeof(t_device)); + if (p_dev == NULL) + return NULL; + + memset(dev_name, 0, 20); + sprintf(dev_name, "%s%s%u-pcd", "/dev/", DEV_FM_NAME, + (uint32_t)((t_device *)p_fm_pcd_params->h_fm)->id); + fd = open(dev_name, O_RDWR); + if (fd < 0) { + free(p_dev); + return NULL; + } + + p_dev->id = ((t_device *)p_fm_pcd_params->h_fm)->id; + p_dev->fd = fd; + p_dev->owners = 0; + + _fml_dbg("Finishing.\n"); + + return (t_handle)p_dev; +} + +void +fm_pcd_close(t_handle h_fm_pcd) +{ + t_device *p_dev = (t_device *)h_fm_pcd; + + _fml_dbg("Calling...\n"); + + close(p_dev->fd); + + if (p_dev->owners) { + printf("\nTry delete a prev created pcd handler(owners:%u)!\n", + p_dev->owners); + return; + } + + free(p_dev); + + _fml_dbg("Finishing.\n"); +} + +uint32_t +fm_pcd_enable(t_handle h_fm_pcd) +{ + t_device *p_dev = (t_device *)h_fm_pcd; + + _fml_dbg("Calling...\n"); + + if (ioctl(p_dev->fd, FM_PCD_IOC_ENABLE)) + RETURN_ERROR(MINOR, E_INVALID_OPERATION, NO_MSG); + + _fml_dbg("Finishing.\n"); + + return E_OK; +} + +uint32_t +fm_pcd_disable(t_handle h_fm_pcd) +{ + t_device *p_dev = (t_device *)h_fm_pcd; + + _fml_dbg("Calling...\n"); + + if (ioctl(p_dev->fd, FM_PCD_IOC_DISABLE)) + RETURN_ERROR(MINOR, E_INVALID_OPERATION, NO_MSG); + + _fml_dbg("Finishing.\n"); + + return E_OK; +} + +t_handle +fm_pcd_net_env_characteristics_set(t_handle h_fm_pcd, + ioc_fm_pcd_net_env_params_t *params) +{ + t_device *p_pcd_dev = (t_device *)h_fm_pcd; + t_device *p_dev = NULL; + + _fml_dbg("Calling...\n"); + + params->id = NULL; + + if (ioctl(p_pcd_dev->fd, FM_PCD_IOC_NET_ENV_CHARACTERISTICS_SET, + params)) + return NULL; + + p_dev = (t_device *)malloc(sizeof(t_device)); + if (p_dev == NULL) + return NULL; + + memset(p_dev, 0, sizeof(t_device)); + p_dev->h_user_priv = (t_handle)p_pcd_dev; + p_pcd_dev->owners++; + p_dev->id = PTR_TO_UINT(params->id); + + _fml_dbg("Finishing.\n"); + + return (t_handle)p_dev; +} + +uint32_t +fm_pcd_net_env_characteristics_delete(t_handle h_net_env) +{ + t_device *p_dev = (t_device *)h_net_env; + t_device *p_pcd_dev = NULL; + ioc_fm_obj_t id; + + _fml_dbg("Calling...\n"); + + p_pcd_dev = (t_device *)p_dev->h_user_priv; + id.obj = UINT_TO_PTR(p_dev->id); + + if (ioctl(p_pcd_dev->fd, FM_PCD_IOC_NET_ENV_CHARACTERISTICS_DELETE, + &id)) + RETURN_ERROR(MINOR, E_INVALID_OPERATION, NO_MSG); + + p_pcd_dev->owners--; + free(p_dev); + + _fml_dbg("Finishing.\n"); + + return E_OK; +} + +t_handle +fm_pcd_kg_scheme_set(t_handle h_fm_pcd, + ioc_fm_pcd_kg_scheme_params_t *params) +{ + t_device *p_pcd_dev = (t_device *)h_fm_pcd; + t_device *p_dev = NULL; + int ret; + + _fml_dbg("Calling...\n"); + + params->id = NULL; + + if (params->param.modify) { + if (params->param.scm_id.scheme_id) + DEV_TO_ID(params->param.scm_id.scheme_id); + else + return NULL; + } + + /* correct h_net_env param from scheme */ + if (params->param.net_env_params.net_env_id) + DEV_TO_ID(params->param.net_env_params.net_env_id); + + /* correct next engine params handlers: cc*/ + if (params->param.next_engine == e_IOC_FM_PCD_CC && + params->param.kg_next_engine_params.cc.tree_id) + DEV_TO_ID(params->param.kg_next_engine_params.cc.tree_id); + + ret = ioctl(p_pcd_dev->fd, FM_PCD_IOC_KG_SCHEME_SET, params); + if (ret) { + DPAA_PMD_ERR(" cannot set kg scheme, error %i (%s)\n", + errno, strerror(errno)); + return NULL; + } + + p_dev = (t_device *)malloc(sizeof(t_device)); + if (p_dev == NULL) + return NULL; + + memset(p_dev, 0, sizeof(t_device)); + p_dev->h_user_priv = (t_handle)p_pcd_dev; + /* increase owners only if a new scheme is created */ + if (!params->param.modify) + p_pcd_dev->owners++; + p_dev->id = PTR_TO_UINT(params->id); + + _fml_dbg("Finishing.\n"); + + return (t_handle)p_dev; +} + +uint32_t +fm_pcd_kg_scheme_delete(t_handle h_scheme) +{ + t_device *p_dev = (t_device *)h_scheme; + t_device *p_pcd_dev = NULL; + ioc_fm_obj_t id; + + _fml_dbg("Calling...\n"); + + p_pcd_dev = (t_device *)p_dev->h_user_priv; + id.obj = UINT_TO_PTR(p_dev->id); + + if (ioctl(p_pcd_dev->fd, FM_PCD_IOC_KG_SCHEME_DELETE, &id)) { + DPAA_PMD_WARN("cannot delete kg scheme, error %i (%s)\n", + errno, strerror(errno)); + RETURN_ERROR(MINOR, E_INVALID_OPERATION, NO_MSG); + } + + p_pcd_dev->owners--; + free(p_dev); + + _fml_dbg("Finishing.\n"); + + return E_OK; +} + +typedef struct { + e_fm_port_type port_type; /**< Port type */ + uint8_t port_id; /**< Port Id - relative to type */ +} t_fm_port; + +t_handle +fm_port_open(t_fm_port_params *p_fm_port_params) +{ + t_device *p_dev; + int fd; + char dev_name[30]; + t_fm_port *p_fm_port; + + _fml_dbg("Calling...\n"); + + p_dev = (t_device *)malloc(sizeof(t_device)); + if (p_dev == NULL) + return NULL; + + memset(p_dev, 0, sizeof(t_device)); + + p_fm_port = (t_fm_port *)malloc(sizeof(t_fm_port)); + if (!p_fm_port) { + free(p_dev); + return NULL; + } + memset(p_fm_port, 0, sizeof(t_fm_port)); + memset(dev_name, 0, sizeof(dev_name)); + switch (p_fm_port_params->port_type) { + case e_FM_PORT_TYPE_OH_OFFLINE_PARSING: + sprintf(dev_name, "%s%s%u-port-oh%d", "/dev/", DEV_FM_NAME, + (uint32_t)((t_device *)p_fm_port_params->h_fm)->id, + p_fm_port_params->port_id); + break; + case e_FM_PORT_TYPE_RX: + sprintf(dev_name, "%s%s%u-port-rx%d", "/dev/", DEV_FM_NAME, + (uint32_t)((t_device *)p_fm_port_params->h_fm)->id, + p_fm_port_params->port_id); + break; + case e_FM_PORT_TYPE_RX_10G: + sprintf(dev_name, "%s%s%u-port-rx%d", "/dev/", DEV_FM_NAME, + (uint32_t)((t_device *)p_fm_port_params->h_fm)->id, + FM_MAX_NUM_OF_1G_RX_PORTS + p_fm_port_params->port_id); + break; + case e_FM_PORT_TYPE_TX: + sprintf(dev_name, "%s%s%u-port-tx%d", "/dev/", DEV_FM_NAME, + (uint32_t)((t_device *)p_fm_port_params->h_fm)->id, + p_fm_port_params->port_id); + break; + case e_FM_PORT_TYPE_TX_10G: + sprintf(dev_name, "%s%s%u-port-tx%d", "/dev/", DEV_FM_NAME, + (uint32_t)((t_device *)p_fm_port_params->h_fm)->id, + FM_MAX_NUM_OF_1G_TX_PORTS + p_fm_port_params->port_id); + break; + default: + free(p_fm_port); + free(p_dev); + return NULL; + } + + fd = open(dev_name, O_RDWR); + if (fd < 0) { + free(p_fm_port); + free(p_dev); + return NULL; + } + + p_fm_port->port_type = p_fm_port_params->port_type; + p_fm_port->port_id = p_fm_port_params->port_id; + p_dev->id = p_fm_port_params->port_id; + p_dev->fd = fd; + p_dev->h_user_priv = (t_handle)p_fm_port; + + _fml_dbg("Finishing.\n"); + + return (t_handle)p_dev; +} + +void +fm_port_close(t_handle h_fm_port) +{ + t_device *p_dev = (t_device *)h_fm_port; + + _fml_dbg("Calling...\n"); + + close(p_dev->fd); + if (p_dev->h_user_priv) + free(p_dev->h_user_priv); + free(p_dev); + + _fml_dbg("Finishing.\n"); +} + +uint32_t +fm_port_disable(t_handle h_fm_port) +{ + t_device *p_dev = (t_device *)h_fm_port; + + _fml_dbg("Calling...\n"); + + if (ioctl(p_dev->fd, FM_PORT_IOC_DISABLE)) + RETURN_ERROR(MINOR, E_INVALID_OPERATION, NO_MSG); + + _fml_dbg("Finishing.\n"); + + return E_OK; +} + +uint32_t +fm_port_enable(t_handle h_fm_port) +{ + t_device *p_dev = (t_device *)h_fm_port; + + _fml_dbg("Calling...\n"); + + if (ioctl(p_dev->fd, FM_PORT_IOC_ENABLE)) + RETURN_ERROR(MINOR, E_INVALID_OPERATION, NO_MSG); + + _fml_dbg("Finishing.\n"); + + return E_OK; +} + +uint32_t +fm_port_set_pcd(t_handle h_fm_port, + ioc_fm_port_pcd_params_t *p) +{ + t_device *p_dev = (t_device *)h_fm_port; + + _fml_dbg("Calling...\n"); + + /* correct h_net_env param from t_fm_portPcdParams */ + DEV_TO_ID(p->net_env_id); + + /* correct pcd structures according to what support was set */ + if (p->pcd_support == e_IOC_FM_PCD_PRS_KG_AND_CC || + p->pcd_support == e_IOC_FM_PCD_PRS_KG_AND_CC_AND_PLCR || + p->pcd_support == e_IOC_FM_PCD_PRS_CC) { + if (p->p_cc_params && p->p_cc_params->cc_tree_id) + DEV_TO_ID(p->p_cc_params->cc_tree_id); + else + DPAA_PMD_WARN("Coarse Classification not set !"); + } + + if (p->pcd_support == e_IOC_FM_PCD_PRS_KG || + p->pcd_support == e_IOC_FM_PCD_PRS_KG_AND_CC || + p->pcd_support == e_IOC_FM_PCD_PRS_KG_AND_CC_AND_PLCR || + p->pcd_support == e_IOC_FM_PCD_PRS_KG_AND_PLCR){ + if (p->p_kg_params) { + uint32_t i; + ioc_fm_port_pcd_kg_params_t *kg_params; + + kg_params = p->p_kg_params; + + for (i = 0; i < kg_params->num_schemes; i++) + if (kg_params->scheme_ids[i]) + DEV_TO_ID(kg_params->scheme_ids[i]); + else + DPAA_PMD_WARN("Scheme:%u not set!!", i); + + if (kg_params->direct_scheme) + DEV_TO_ID(kg_params->direct_scheme_id); + } else { + DPAA_PMD_WARN("KeyGen not set !"); + } + } + + if (p->pcd_support == e_IOC_FM_PCD_PLCR_ONLY || + p->pcd_support == e_IOC_FM_PCD_PRS_PLCR || + p->pcd_support == e_IOC_FM_PCD_PRS_KG_AND_CC_AND_PLCR || + p->pcd_support == e_IOC_FM_PCD_PRS_KG_AND_PLCR) { + if (p->p_plcr_params) { + if (p->p_plcr_params->plcr_profile_id) + DEV_TO_ID(p->p_plcr_params->plcr_profile_id); + else + DPAA_PMD_WARN("Policer not set !"); + } + } + + if (p->p_ip_reassembly_manip) + DEV_TO_ID(p->p_ip_reassembly_manip); + + if (p->p_capwap_reassembly_manip) + DEV_TO_ID(p->p_capwap_reassembly_manip); + + if (ioctl(p_dev->fd, FM_PORT_IOC_SET_PCD, p)) + RETURN_ERROR(MINOR, E_INVALID_OPERATION, NO_MSG); + + _fml_dbg("Finishing.\n"); + + return E_OK; +} + +uint32_t +fm_port_delete_pcd(t_handle h_fm_port) +{ + t_device *p_dev = (t_device *)h_fm_port; + + _fml_dbg("Calling...\n"); + + if (ioctl(p_dev->fd, FM_PORT_IOC_DELETE_PCD)) + RETURN_ERROR(MINOR, E_INVALID_OPERATION, NO_MSG); + + _fml_dbg("Finishing.\n"); + + return E_OK; +} + +t_handle +create_device(t_handle h_user_priv, t_handle h_dev_id) +{ + t_device *p_user_priv_dev = (t_device *)h_user_priv; + t_device *p_dev = NULL; + + _fml_dbg("Calling...\n"); + + p_dev = (t_device *)malloc(sizeof(t_device)); + if (p_dev == NULL) + return NULL; + + memset(p_dev, 0, sizeof(t_device)); + p_dev->h_user_priv = h_user_priv; + p_user_priv_dev->owners++; + p_dev->id = PTR_TO_UINT(h_dev_id); + + _fml_dbg("Finishing.\n"); + + return (t_handle)p_dev; +} + +t_handle +get_device_id(t_handle h_dev) +{ + t_device *p_dev = (t_device *)h_dev; + + return (t_handle)p_dev->id; +} diff --git a/drivers/net/dpaa/fmlib/fm_pcd_ext.h b/drivers/net/dpaa/fmlib/fm_pcd_ext.h new file mode 100644 index 000000000..e767fbb70 --- /dev/null +++ b/drivers/net/dpaa/fmlib/fm_pcd_ext.h @@ -0,0 +1,5787 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright 2008-2012 Freescale Semiconductor Inc. + * Copyright 2017-2020 NXP + */ + +#ifndef __FM_PCD_EXT_H +#define __FM_PCD_EXT_H + +#include "ncsw_ext.h" +#include "net_ext.h" +#include "fm_ext.h" + +/* + * @Description FM PCD ... + * @Group lnx_ioctl_FM_grp Frame Manager Linux IOCTL API + * @Description Frame Manager Linux ioctls definitions and enums + * @{ + */ + +/* + * @Group lnx_ioctl_FM_PCD_grp FM PCD + * @Description Frame Manager PCD API functions, definitions and enums + * + * The FM PCD module is responsible for the initialization of all + * global classifying FM modules. This includes the parser + * general and common registers, the key generator global and + * common registers, and the policer global and common registers. + * In addition, the FM PCD SW module will initialize all required + * key generator schemes, coarse classification flows, and + * policer profiles. When an FM module is configured to work with + * one of these entities, it will register to it using the FM + * PORT API. The PCD module will manage the PCD resources - i.e. + * resource management of KeyGen schemes, etc. + * + * @{ + */ + +/* + * @Collection General PCD defines + */ +#define IOC_FM_PCD_MAX_NUM_OF_PRIVATE_HDRS 2 +/**< Number of units/headers saved for user */ + +#define IOC_FM_PCD_PRS_NUM_OF_HDRS 16 +/**< Number of headers supported by HW parser */ +#define IOC_FM_PCD_MAX_NUM_OF_DISTINCTION_UNITS \ + (32 - IOC_FM_PCD_MAX_NUM_OF_PRIVATE_HDRS) +/**< Number of distinction units is limited by register size (32 bits) minus + * reserved bits for private headers. + */ +#define IOC_FM_PCD_MAX_NUM_OF_INTERCHANGEABLE_HDRS 4 +/**< Maximum number of interchangeable headers in a distinction unit */ +#define IOC_FM_PCD_KG_NUM_OF_GENERIC_REGS 8 +/**< Total number of generic KeyGen registers */ +#define IOC_FM_PCD_KG_MAX_EXTRACTS_PER_KEY 35 +/**< Max number allowed on any configuration; For HW implementation reasons, + * in most cases less than this will be allowed; The driver will return an + * initialization error if resource is unavailable. + */ +#define IOC_FM_PCD_KG_NUM_OF_EXTRACT_MASKS 4 +/**< Total number of masks allowed on KeyGen extractions. */ +#define IOC_FM_PCD_KG_NUM_OF_DEFAULT_GROUPS 16 +/**< Number of default value logical groups */ +#define IOC_FM_PCD_PRS_NUM_OF_LABELS 32 +/**< Maximum number of SW parser labels */ +#define IOC_FM_PCD_SW_PRS_SIZE 0x00000800 +/**< Total size of SW parser area */ + +#define IOC_FM_PCD_MAX_MANIP_INSRT_TEMPLATE_SIZE 128 +/**< Maximum size of insertion template for insert manipulation */ + +#define IOC_FM_PCD_FRM_REPLIC_MAX_NUM_OF_ENTRIES 64 +/**< Maximum possible entries for frame replicator group */ +/* @} */ + +/* + * @Group lnx_ioctl_FM_PCD_init_grp FM PCD Initialization Unit + * + * @Description Frame Manager PCD Initialization Unit API + * + * @{ + */ + +/* + * @Description PCD counters + * (must match enum ioc_fm_pcd_counters defined in fm_pcd_ext.h) + */ +typedef enum ioc_fm_pcd_counters { + e_IOC_FM_PCD_KG_COUNTERS_TOTAL, /**< KeyGen counter */ + e_IOC_FM_PCD_PLCR_COUNTERS_RED, + /**< Policer counter - counts the total number of RED packets that exit + * the Policer. + */ + e_IOC_FM_PCD_PLCR_COUNTERS_YELLOW, + /**< Policer counter - counts the total number of YELLOW packets that + * exit the Policer. + */ + e_IOC_FM_PCD_PLCR_COUNTERS_RECOLORED_TO_RED, + /**< Policer counter - counts the number of packets that changed color + * to RED by the Policer; This is a subset of + * e_IOC_FM_PCD_PLCR_COUNTERS_RED packet count, indicating active color + * changes. + */ + e_IOC_FM_PCD_PLCR_COUNTERS_RECOLORED_TO_YELLOW, + /**< Policer counter - counts the number of packets that changed color + * to YELLOW by the Policer; This is a subset of + * e_IOC_FM_PCD_PLCR_COUNTERS_YELLOW packet count, indicating active + * color changes. + */ + e_IOC_FM_PCD_PLCR_COUNTERS_TOTAL, + /**< Policer counter - counts the total number of packets passed in the + * Policer. + */ + e_IOC_FM_PCD_PLCR_COUNTERS_LENGTH_MISMATCH, + /**< Policer counter - counts the number of packets with length + * mismatch. + */ + e_IOC_FM_PCD_PRS_COUNTERS_PARSE_DISPATCH, + /**< Parser counter - counts the number of times the parser block is + * dispatched. + */ + e_IOC_FM_PCD_PRS_COUNTERS_L2_PARSE_RESULT_RETURNED, + /**< Parser counter - counts the number of times L2 parse result is + * returned (including errors). + */ + e_IOC_FM_PCD_PRS_COUNTERS_L3_PARSE_RESULT_RETURNED, + /**< Parser counter - counts the number of times L3 parse result is + * returned (including errors). + */ + e_IOC_FM_PCD_PRS_COUNTERS_L4_PARSE_RESULT_RETURNED, + /**< Parser counter - counts the number of times L4 parse result is + * returned (including errors). + */ + e_IOC_FM_PCD_PRS_COUNTERS_SHIM_PARSE_RESULT_RETURNED, + /**< Parser counter - counts the number of times SHIM parse result is + * returned (including errors). + */ + e_IOC_FM_PCD_PRS_COUNTERS_L2_PARSE_RESULT_RETURNED_WITH_ERR, + /**< Parser counter - counts the number of times L2 parse result is + * returned with errors. + */ + e_IOC_FM_PCD_PRS_COUNTERS_L3_PARSE_RESULT_RETURNED_WITH_ERR, + /**< Parser counter - counts the number of times L3 parse result is + * returned with errors. + */ + e_IOC_FM_PCD_PRS_COUNTERS_L4_PARSE_RESULT_RETURNED_WITH_ERR, + /**< Parser counter - counts the number of times L4 parse result is + * returned with errors. + */ + e_IOC_FM_PCD_PRS_COUNTERS_SHIM_PARSE_RESULT_RETURNED_WITH_ERR, + /**< Parser counter - counts the number of times SHIM parse result is + * returned with errors. + */ + e_IOC_FM_PCD_PRS_COUNTERS_SOFT_PRS_CYCLES, + /**< Parser counter - counts the number of cycles spent executing soft + * parser instruction (including stall cycles). + */ + e_IOC_FM_PCD_PRS_COUNTERS_SOFT_PRS_STALL_CYCLES, + /**< Parser counter - counts the number of cycles stalled waiting for + * parser internal memory reads while executing soft parser instruction. + */ + e_IOC_FM_PCD_PRS_COUNTERS_HARD_PRS_CYCLE_INCL_STALL_CYCLES, + /**< Parser counter - counts the number of cycles spent executing hard + * parser (including stall cycles). + */ + e_IOC_FM_PCD_PRS_COUNTERS_MURAM_READ_CYCLES, + /**< MURAM counter - counts the number of cycles while performing FMan + * Memory read. + */ + e_IOC_FM_PCD_PRS_COUNTERS_MURAM_READ_STALL_CYCLES, + /**< MURAM counter - counts the number of cycles stalled while + * performing FMan Memory read. + */ + e_IOC_FM_PCD_PRS_COUNTERS_MURAM_WRITE_CYCLES, + /**< MURAM counter - counts the number of cycles while performing FMan + * Memory write. + */ + e_IOC_FM_PCD_PRS_COUNTERS_MURAM_WRITE_STALL_CYCLES, + /**< MURAM counter - counts the number of cycles stalled while + * performing FMan Memory write. + */ + e_IOC_FM_PCD_PRS_COUNTERS_FPM_COMMAND_STALL_CYCLES + /**< FPM counter - counts the number of cycles stalled while performing + * a FPM Command. + */ +} ioc_fm_pcd_counters; + +/* + * @Description PCD interrupts + * (must match enum ioc_fm_pcd_exceptions defined in + * fm_pcd_ext.h) + */ +typedef enum ioc_fm_pcd_exceptions { + e_IOC_FM_PCD_KG_EXCEPTION_DOUBLE_ECC, + /**< KeyGen double-bit ECC error is detected on internal memory read + * access. + */ + e_IOC_FM_PCD_KG_EXCEPTION_KEYSIZE_OVERFLOW, + /**< KeyGen scheme configuration error indicating a key size larger than + * 56 bytes. + */ + e_IOC_FM_PCD_PLCR_EXCEPTION_DOUBLE_ECC, + /**< Policer double-bit ECC error has been detected on PRAM read access. + */ + e_IOC_FM_PCD_PLCR_EXCEPTION_INIT_ENTRY_ERROR, + /**< Policer access to a non-initialized profile has been detected. */ + e_IOC_FM_PCD_PLCR_EXCEPTION_PRAM_SELF_INIT_COMPLETE, + /**< Policer RAM self-initialization complete */ + e_IOC_FM_PCD_PLCR_EXCEPTION_ATOMIC_ACTION_COMPLETE, + /**< Policer atomic action complete */ + e_IOC_FM_PCD_PRS_EXCEPTION_DOUBLE_ECC, + /**< Parser double-bit ECC error */ + e_IOC_FM_PCD_PRS_EXCEPTION_SINGLE_ECC + /**< Parser single-bit ECC error */ +} ioc_fm_pcd_exceptions; + +/** @} */ /* end of lnx_ioctl_FM_PCD_init_grp group */ + +/* + * @Group lnx_ioctl_FM_PCD_Runtime_grp FM PCD Runtime Unit + * + * @Description Frame Manager PCD Runtime Unit + * + * The runtime control allows creation of PCD infrastructure + * modules such as Network Environment Characteristics, + * Classification Plan Groups and Coarse Classification Trees. + * It also allows on-the-fly initialization, modification and + * removal of PCD modules such as KeyGen schemes, coarse + * classification nodes and Policer profiles. + * + * In order to explain the programming model of the PCD driver + * interface a few terms should be explained, and will be used + * below. + * - Distinction Header - One of the 16 protocols supported by + * the FM parser, or one of the SHIM headers (1 or 2). May be a + * header with a special option (see below). + * - Interchangeable Headers Group - This is a group of Headers + * recognized by either one of them. For example, if in a + * specific context the user chooses to treat IPv4 and IPV6 in + * the same way, they may create an interchangeable Headers + * Unit consisting of these 2 headers. + * - A Distinction Unit - a Distinction Header or an + * Interchangeable Headers Group. + * - Header with special option - applies to Ethernet, MPLS, + * VLAN, IPv4 and IPv6, includes multicast, broadcast and other + * protocol specific options. In terms of hardware it relates + * to the options available in the classification plan. + * - Network Environment Characteristics - a set of Distinction + * Units that define the total recognizable header selection + * for a certain environment. This is NOT the list of all + * headers that will ever appear in a flow, but rather + * everything that needs distinction in a flow, where + * distinction is made by KeyGen schemes and coarse + * classification action descriptors. + * + * The PCD runtime modules initialization is done in stages. The + * first stage after initializing the PCD module itself is to + * establish a Network Flows Environment Definition. The + * application may choose to establish one or more such + * environments. Later, when needed, the application will have to + * state, for some of its modules, to which single environment it + * belongs. + * + * @{ + */ + +/* + * @Description structure for FM counters + */ +typedef struct ioc_fm_pcd_counters_params_t { + ioc_fm_pcd_counters cnt; /**< The requested counter */ + uint32_t val; + /**< The requested value to get/set from/into the + * counter + */ +} ioc_fm_pcd_counters_params_t; + +/* + * @Description structure for FM exception definitios + */ +typedef struct ioc_fm_pcd_exception_params_t { + ioc_fm_pcd_exceptions exception; /**< The requested exception */ + bool enable; + /**< TRUE to enable interrupt, FALSE to mask it. */ +} ioc_fm_pcd_exception_params_t; + +/* + * @Description A structure for SW parser labels (must be identical to struct + * t_fm_pcd_prs_label_params defined in fm_pcd_ext.h) + */ +typedef struct ioc_fm_pcd_prs_label_params_t { + uint32_t instruction_offset; + /**< SW parser label instruction offset (2 bytes resolution), + * relative to Parser RAM + */ + ioc_net_header_type hdr; + /**< The existence of this header will invoke the SW parser + * code. + */ + uint8_t index_per_hdr; + /**< Normally 0, if more than one SW parser attachments for the + * same header, use this index to distinguish between them. + */ +} ioc_fm_pcd_prs_label_params_t; + +/* + * @Description A structure for SW parser (Must match struct + * ioc_fm_pcd_prs_sw_params_t defined in fm_pcd_ext.h) + */ +typedef struct ioc_fm_pcd_prs_sw_params_t { + bool override; + /**< FALSE to invoke a check that nothing else was + * loaded to this address, including internal patches. + * TRUE to override any existing code. + */ + uint32_t size; /**< SW parser code size */ + uint16_t base; + /**< SW parser base (in instruction counts! must be + * larger than 0x20) + */ + uint8_t *p_code; /**< SW parser code */ + uint32_t sw_prs_data_params[IOC_FM_PCD_PRS_NUM_OF_HDRS]; + /**< SW parser data (parameters) */ + uint8_t num_of_labels; /**< Number of labels for SW parser. */ + ioc_fm_pcd_prs_label_params_t + labels_table[IOC_FM_PCD_PRS_NUM_OF_LABELS]; + /**< SW parser labels table, containing num_of_labels + * entries + */ +} ioc_fm_pcd_prs_sw_params_t; + +/* + * @Description A structure to set the a KeyGen default value + */ +typedef struct ioc_fm_pcd_kg_dflt_value_params_t { + uint8_t value_id;/**< 0,1 - one of 2 global default values */ + uint32_t value; /**< The requested default value */ +} ioc_fm_pcd_kg_dflt_value_params_t; + +/* + * @Function fm_pcd_enable + * + * @Description This routine should be called after PCD is initialized for + * enabling all PCD engines according to their existing + * configuration. + * + * @Return 0 on success; Error code otherwise. + * + * @Cautions Allowed only when PCD is disabled. + */ +#define FM_PCD_IOC_ENABLE _IO(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(1)) + +/* + * @Function fm_pcd_disable + * + * @Description This routine may be called when PCD is enabled in order to + * disable all PCD engines. It may be called only when none of + * the ports in the system are using the PCD. + * + * @Return 0 on success; Error code otherwise. + * + * @Cautions Allowed only when PCD is enabled. + */ +#define FM_PCD_IOC_DISABLE _IO(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(2)) + +/* + * @Function fm_pcd_prs_load_sw + * + * @Description This routine may be called only when all ports in the + * system are actively using the classification plan scheme. + * In such cases it is recommended in order to save resources. + * The driver automatically saves 8 classification plans for + * ports that do NOT use the classification plan mechanism, to + * avoid this (in order to save those entries) this routine may + * be called. + * + * @Param[in] ioc_fm_pcd_prs_sw_params_t + * A pointer to the image of the software parser code. + * + * @Return 0 on success; Error code otherwise. + * + * @Cautions Allowed only when PCD is disabled. + */ +#define FM_PCD_IOC_PRS_LOAD_SW \ + _IOW(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(3), ioc_fm_pcd_prs_sw_params_t) + +/* + * @Function fm_pcd_kg_set_dflt_value + * + * @Description Calling this routine sets a global default value to be used + * by the KeyGen when parser does not recognize a required + * field/header. + * By default default values are 0. + * + * @Param[in] ioc_fm_pcd_kg_dflt_value_params_t A pointer to a structure + * with the relevant + * parameters + * + * @Return 0 on success; Error code otherwise. + * + * @Cautions Allowed only when PCD is disabled. + */ +#define FM_PCD_IOC_KG_SET_DFLT_VALUE \ + _IOW(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(6), \ + ioc_fm_pcd_kg_dflt_value_params_t) + +/* + * @Function fm_pcd_kg_set_additional_data_after_parsing + * + * @Description Calling this routine allows the keygen to access data past + * the parser finishing point. + * + * @Param[in] uint8_t payload-offset; the number of bytes beyond the + * parser location. + * + * @Return 0 on success; Error code otherwise. + * + * @Cautions Allowed only when PCD is disabled. + */ +#define FM_PCD_IOC_KG_SET_ADDITIONAL_DATA_AFTER_PARSING \ + _IOW(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(7), uint8_t) + +/* + * @Function fm_pcd_set_exception + * + * @Description Calling this routine enables/disables PCD interrupts. + * + * @Param[in] ioc_fm_pcd_exception_params_t + * Arguments struct with exception to be enabled/disabled. + * + * @Return 0 on success; Error code otherwise. + */ +#define FM_PCD_IOC_SET_EXCEPTION \ + _IOW(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(8), ioc_fm_pcd_exception_params_t) + +/* + * @Function fm_pcd_get_counter + * + * @Description Reads one of the FM PCD counters. + * + * @Param[in,out] ioc_fm_pcd_counters_params_t The requested counter parameters. + * + * @Return 0 on success; Error code otherwise. + * + * @Cautions It is user's responsibility to call this routine only + * for enabled counters, and there will be no indication if a + * disabled counter is accessed. + */ +#define FM_PCD_IOC_GET_COUNTER \ + _IOWR(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(9), ioc_fm_pcd_counters_params_t) + +/* + * @Function fm_pcd_kg_scheme_get_counter + * + * @Description Reads scheme packet counter. + * + * @Param[in] h_scheme scheme handle as returned by + * fm_pcd_kg_scheme_set(). + * + * @Return Counter's current value. + * + * @Cautions Allowed only following fm_pcd_init() & fm_pcd_kg_scheme_set(). + */ +#define FM_PCD_IOC_KG_SCHEME_GET_CNTR \ + _IOR(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(4), ioc_fm_pcd_kg_scheme_spc_t) + +/* + * @Function FM_PCD_ForceIntr + * + * @Description Causes an interrupt event on the requested source. + * + * @Param[in] ioc_fm_pcd_exceptions - An exception to be forced. + * + * @Return 0 on success; error code if the exception is not enabled, + * or is not able to create interrupt. + */ +#define FM_PCD_IOC_FORCE_INTR \ + _IOW(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(11), ioc_fm_pcd_exceptions) + +/* + * @Collection Definitions of coarse classification parameters as required by + * KeyGen (when coarse classification is the next engine after this + * scheme). + */ +#define IOC_FM_PCD_MAX_NUM_OF_CC_TREES 8 +#define IOC_FM_PCD_MAX_NUM_OF_CC_GROUPS 16 +#define IOC_FM_PCD_MAX_NUM_OF_CC_UNITS 4 +#define IOC_FM_PCD_MAX_NUM_OF_KEYS 256 +#define IOC_FM_PCD_MAX_NUM_OF_FLOWS (4 * KILOBYTE) +#define IOC_FM_PCD_MAX_SIZE_OF_KEY 56 +#define IOC_FM_PCD_MAX_CC_ENTRY_IN_GRP 16 +#define IOC_FM_PCD_LAST_KEY_INDEX 0xffff +#define IOC_FM_PCD_MANIP_DSCP_VALUES 64 +/* @} */ + +/* + * @Collection A set of definitions to allow protocol + * special option description. + */ +typedef uint32_t ioc_protocol_opt_t; + /**< A general type to define a protocol option. */ + +typedef ioc_protocol_opt_t ioc_eth_protocol_opt_t; + /**< Ethernet protocol options. */ +#define IOC_ETH_BROADCAST 0x80000000 /**< Ethernet Broadcast. */ +#define IOC_ETH_MULTICAST 0x40000000 /**< Ethernet Multicast. */ + +typedef ioc_protocol_opt_t ioc_vlan_protocol_opt_t; + /**< Vlan protocol options. */ +#define IOC_VLAN_STACKED 0x20000000 /**< Stacked VLAN. */ + +typedef ioc_protocol_opt_t ioc_mpls_protocol_opt_t; + /**< MPLS protocol options. */ +#define IOC_MPLS_STACKED 0x10000000 /**< Stacked MPLS. */ + +typedef ioc_protocol_opt_t ioc_ipv4_protocol_opt_t; + /**< IPv4 protocol options. */ +#define IOC_IPV4_BROADCAST_1 0x08000000 /**< IPv4 Broadcast. */ +#define IOC_IPV4_MULTICAST_1 0x04000000 /**< IPv4 Multicast. */ +#define IOC_IPV4_UNICAST_2 0x02000000 + /**< Tunneled IPv4 - Unicast. + */ +#define IOC_IPV4_MULTICAST_BROADCAST_2 0x01000000 + /**< Tunneled IPv4 - + * Broadcast/Multicast. + */ + +#define IOC_IPV4_FRAG_1 0x00000008 + /**< IPV4 reassembly option. IPV4 + * Reassembly manipulation requires network + * environment with IPV4 header and IPV4_FRAG_1 + * option + */ + +typedef ioc_protocol_opt_t ioc_ipv6_protocol_opt_t; + /**< IPv6 protocol options. */ +#define IOC_IPV6_MULTICAST_1 0x00800000 /**< IPv6 Multicast. */ +#define IOC_IPV6_UNICAST_2 0x00400000 + /**< Tunneled IPv6 - Unicast. */ +#define IOC_IPV6_MULTICAST_2 0x00200000 + /**< Tunneled IPv6 - Multicast. */ + +#define IOC_IPV6_FRAG_1 0x00000004 + /**< IPV6 reassembly option. IPV6 Reassembly + * manipulation requires network environment + * with IPV6 header and IPV6_FRAG_1 option + */ +typedef ioc_protocol_opt_t ioc_capwap_protocol_opt_t; + /**< CAPWAP protocol options. */ +#define CAPWAP_FRAG_1 0x00000008 + /**< CAPWAP reassembly option. CAPWAP Reassembly + * manipulation requires network environment + * with CAPWAP header and CAPWAP_FRAG_1 option; + * in case where fragment found, the + * fragment-extension offset may be found at + * 'shim2' (in parser-result). + */ + +/* @} */ + +#define IOC_FM_PCD_MANIP_MAX_HDR_SIZE 256 +#define IOC_FM_PCD_MANIP_DSCP_TO_VLAN_TRANS 64 +/** + * @Collection A set of definitions to support Header Manipulation selection. + */ +typedef uint32_t ioc_hdr_manip_flags_t; + /**< A general type to define a HMan update command flags. */ + +typedef ioc_hdr_manip_flags_t ioc_ipv4_hdr_manip_update_flags_t; + /**< IPv4 protocol HMan update command flags. */ + +#define IOC_HDR_MANIP_IPV4_TOS 0x80000000 + /**< update TOS with the given value ('tos' field of + * ioc_fm_pcd_manip_hdr_field_update_ipv4_t) + */ +#define IOC_HDR_MANIP_IPV4_ID 0x40000000 + /**< update IP ID with the given value ('id' field of + * ioc_fm_pcd_manip_hdr_field_update_ipv4_t) + */ +#define IOC_HDR_MANIP_IPV4_TTL 0x20000000 /**< Decrement TTL by 1 */ +#define IOC_HDR_MANIP_IPV4_SRC 0x10000000 + /**< update IP source address with the given value ('src' field + * of ioc_fm_pcd_manip_hdr_field_update_ipv4_t) + */ +#define IOC_HDR_MANIP_IPV4_DST 0x08000000 + /**< update IP destination address with the given value + * ('dst' field of ioc_fm_pcd_manip_hdr_field_update_ipv4_t) + */ + +typedef ioc_hdr_manip_flags_t ioc_ipv6_hdr_manip_update_flags_t; + /**< IPv6 protocol HMan update command flags. */ + +#define IOC_HDR_MANIP_IPV6_TC 0x80000000 + /**< update Traffic Class address with the given value ('traffic_class' + * field of ioc_fm_pcd_manip_hdr_field_update_ipv6_t) + */ +#define IOC_HDR_MANIP_IPV6_HL 0x40000000 /**< Decrement Hop Limit by 1 */ +#define IOC_HDR_MANIP_IPV6_SRC 0x20000000 + /**< update IP source address with the given value ('src' field + * of ioc_fm_pcd_manip_hdr_field_update_ipv6_t) + */ +#define IOC_HDR_MANIP_IPV6_DST 0x10000000 + /**< update IP destination address with the given value ('dst' + * field of ioc_fm_pcd_manip_hdr_field_update_ipv6_t) + */ + +typedef ioc_hdr_manip_flags_t ioc_tcp_udp_hdr_manip_update_flags_t; + /**< TCP/UDP protocol HMan update command flags. */ + +#define IOC_HDR_MANIP_TCP_UDP_SRC 0x80000000 + /**< update TCP/UDP source address with the given value + * ('src' field of ioc_fm_pcd_manip_hdr_field_update_tcp_udp_t) + */ +#define IOC_HDR_MANIP_TCP_UDP_DST 0x40000000 + /**< update TCP/UDP destination address with the given value + * ('dst' field of ioc_fm_pcd_manip_hdr_field_update_tcp_udp_t) + */ +#define IOC_HDR_MANIP_TCP_UDP_CHECKSUM 0x20000000 + /**< update TCP/UDP checksum */ + +/* @} */ + +/* + * @Description A type used for returning the order of the key extraction. + * each value in this array represents the index of the + * extraction command as defined by the user in the + * initialization extraction array. The valid size of this array + * is the user define number of extractions required (also + * marked by the second '0' in this array). + */ +typedef uint8_t + ioc_fm_pcd_kg_key_order_t [IOC_FM_PCD_KG_MAX_EXTRACTS_PER_KEY]; + +/* + *@Description All PCD engines + * (must match enum e_FmPcdEngine defined in fm_pcd_ext.h) + */ + +typedef enum ioc_fm_pcd_engine { + e_IOC_FM_PCD_INVALID = 0, /**< Invalid PCD engine */ + e_IOC_FM_PCD_DONE, /**< No PCD Engine indicated */ + e_IOC_FM_PCD_KG, /**< KeyGen */ + e_IOC_FM_PCD_CC, /**< Coarse Classifier */ + e_IOC_FM_PCD_PLCR, /**< Policer */ + e_IOC_FM_PCD_PRS, /**< Parser */ + e_IOC_FM_PCD_FR, /**< Frame Replicator */ + e_IOC_FM_PCD_HASH /**< Hash Table */ +} ioc_fm_pcd_engine; + +/* + * @Description An enum for selecting extraction by header types + * (Must match enum e_FmPcdExtractByHdrType defined in + * fm_pcd_ext.h) + */ +typedef enum ioc_fm_pcd_extract_by_hdr_type { + e_IOC_FM_PCD_EXTRACT_FROM_HDR, /**< Extract bytes from header */ + e_IOC_FM_PCD_EXTRACT_FROM_FIELD,/**< Extract bytes from header field */ + e_IOC_FM_PCD_EXTRACT_FULL_FIELD /**< Extract a full field */ +} ioc_fm_pcd_extract_by_hdr_type; + +/* + * @Description An enum for selecting extraction source (when it is not the + * header) (Must match enum e_FmPcdExtractFrom defined in + * fm_pcd_ext.h) + */ +typedef enum ioc_fm_pcd_extract_from { + e_IOC_FM_PCD_EXTRACT_FROM_FRAME_START, + /**< KG & CC: Extract from beginning of frame */ + e_IOC_FM_PCD_EXTRACT_FROM_DFLT_VALUE, + /**< KG only: Extract from a default value */ + e_IOC_FM_PCD_EXTRACT_FROM_CURR_END_OF_PARSE, + /**< KG only: Extract from the point where parsing had + * finished + */ + e_IOC_FM_PCD_EXTRACT_FROM_KEY, /**< CC only: Field where saved KEY */ + e_IOC_FM_PCD_EXTRACT_FROM_HASH, /**< CC only: Field where saved HASH */ + e_IOC_FM_PCD_EXTRACT_FROM_PARSE_RESULT, + /**< KG & CC: Extract from the parser result */ + e_IOC_FM_PCD_EXTRACT_FROM_ENQ_FQID, + /**< KG & CC: Extract from enqueue FQID */ + e_IOC_FM_PCD_EXTRACT_FROM_FLOW_ID + /**< CC only: Field where saved Dequeue FQID */ +} ioc_fm_pcd_extract_from; + +/* + * @Description An enum for selecting extraction type + */ +typedef enum ioc_fm_pcd_extract_type { + e_IOC_FM_PCD_EXTRACT_BY_HDR, /**< Extract according to header */ + e_IOC_FM_PCD_EXTRACT_NON_HDR, + /**< Extract from data that is not the header */ + e_IOC_FM_PCD_KG_EXTRACT_PORT_PRIVATE_INFO + /**< Extract private info as specified by user */ +} ioc_fm_pcd_extract_type; + +/* + * @Description An enum for selecting a default + */ +typedef enum ioc_fm_pcd_kg_extract_dflt_select { + e_IOC_FM_PCD_KG_DFLT_GBL_0, + /**< Default selection is KG register 0 */ + e_IOC_FM_PCD_KG_DFLT_GBL_1, + /**< Default selection is KG register 1 */ + e_IOC_FM_PCD_KG_DFLT_PRIVATE_0, + /**< Default selection is a per scheme register 0 */ + e_IOC_FM_PCD_KG_DFLT_PRIVATE_1, + /**< Default selection is a per scheme register 1 */ + e_IOC_FM_PCD_KG_DFLT_ILLEGAL /**< Illegal selection */ +} ioc_fm_pcd_kg_extract_dflt_select; + +/* + * @Description Enumeration type defining all default groups - each group + * shares a default value, one of four user-initialized values. + */ +typedef enum ioc_fm_pcd_kg_known_fields_dflt_types { + e_IOC_FM_PCD_KG_MAC_ADDR, /**< MAC Address */ + e_IOC_FM_PCD_KG_TCI, /**< TCI field */ + e_IOC_FM_PCD_KG_ENET_TYPE, /**< ENET Type */ + e_IOC_FM_PCD_KG_PPP_SESSION_ID, /**< PPP Session id */ + e_IOC_FM_PCD_KG_PPP_PROTOCOL_ID, /**< PPP Protocol id */ + e_IOC_FM_PCD_KG_MPLS_LABEL, /**< MPLS label */ + e_IOC_FM_PCD_KG_IP_ADDR, /**< IP addr */ + e_IOC_FM_PCD_KG_PROTOCOL_TYPE, /**< Protocol type */ + e_IOC_FM_PCD_KG_IP_TOS_TC, /**< TOS or TC */ + e_IOC_FM_PCD_KG_IPV6_FLOW_LABEL, /**< IPV6 flow label */ + e_IOC_FM_PCD_KG_IPSEC_SPI, /**< IPSEC SPI */ + e_IOC_FM_PCD_KG_L4_PORT, /**< L4 Port */ + e_IOC_FM_PCD_KG_TCP_FLAG, /**< TCP Flag */ + e_IOC_FM_PCD_KG_GENERIC_FROM_DATA, + /**< grouping implemented by SW, any data extraction that is not + * the full field described above + */ + e_IOC_FM_PCD_KG_GENERIC_FROM_DATA_NO_V, + /**< grouping implemented by SW, any data extraction without + * validation + */ + e_IOC_FM_PCD_KG_GENERIC_NOT_FROM_DATA + /**< grouping implemented by SW, extraction from parser result + * or direct use of default value + */ +} ioc_fm_pcd_kg_known_fields_dflt_types; + +/* + * @Description Enumeration type for defining header index for scenarios with + * multiple (tunneled) headers + */ +typedef enum ioc_fm_pcd_hdr_index { + e_IOC_FM_PCD_HDR_INDEX_NONE = 0, + /**< used when multiple headers not used, also + * to specify regular IP (not tunneled). + */ + e_IOC_FM_PCD_HDR_INDEX_1,/**< may be used for VLAN, MPLS, tunneled IP */ + e_IOC_FM_PCD_HDR_INDEX_2,/**< may be used for MPLS, tunneled IP */ + e_IOC_FM_PCD_HDR_INDEX_3,/**< may be used for MPLS */ + e_IOC_FM_PCD_HDR_INDEX_LAST = 0xFF /**< may be used for VLAN, MPLS */ +} ioc_fm_pcd_hdr_index; + +/* + * @Description Enumeration type for selecting the policer profile functional + * type + */ +typedef enum ioc_fm_pcd_profile_type_selection { + e_IOC_FM_PCD_PLCR_PORT_PRIVATE, /**< Port dedicated profile */ + e_IOC_FM_PCD_PLCR_SHARED + /**< Shared profile (shared within partition) */ +} ioc_fm_pcd_profile_type_selection; + +/* + * @Description Enumeration type for selecting the policer profile algorithm + */ +typedef enum ioc_fm_pcd_plcr_algorithm_selection { + e_IOC_FM_PCD_PLCR_PASS_THROUGH, /**< Policer pass through */ + e_IOC_FM_PCD_PLCR_RFC_2698, /**< Policer algorithm RFC 2698 */ + e_IOC_FM_PCD_PLCR_RFC_4115 /**< Policer algorithm RFC 4115 */ +} ioc_fm_pcd_plcr_algorithm_selection; + +/* + * @Description Enumeration type for selecting a policer profile color mode + */ +typedef enum ioc_fm_pcd_plcr_color_mode { + e_IOC_FM_PCD_PLCR_COLOR_BLIND, /**< Color blind */ + e_IOC_FM_PCD_PLCR_COLOR_AWARE /**< Color aware */ +} ioc_fm_pcd_plcr_color_mode; + +/* + * @Description Enumeration type for selecting a policer profile color + */ +typedef enum ioc_fm_pcd_plcr_color { + e_IOC_FM_PCD_PLCR_GREEN, /**< Green */ + e_IOC_FM_PCD_PLCR_YELLOW, /**< Yellow */ + e_IOC_FM_PCD_PLCR_RED, /**< Red */ + e_IOC_FM_PCD_PLCR_OVERRIDE /**< Color override */ +} ioc_fm_pcd_plcr_color; + +/* + * @Description Enumeration type for selecting the policer profile packet + * frame length selector + */ +typedef enum ioc_fm_pcd_plcr_frame_length_select { + e_IOC_FM_PCD_PLCR_L2_FRM_LEN, /**< L2 frame length */ + e_IOC_FM_PCD_PLCR_L3_FRM_LEN, /**< L3 frame length */ + e_IOC_FM_PCD_PLCR_L4_FRM_LEN, /**< L4 frame length */ + e_IOC_FM_PCD_PLCR_FULL_FRM_LEN /**< Full frame length */ +} ioc_fm_pcd_plcr_frame_length_select; + +/* + * @Description Enumeration type for selecting roll-back frame + */ +typedef enum ioc_fm_pcd_plcr_roll_back_frame_select { + e_IOC_FM_PCD_PLCR_ROLLBACK_L2_FRM_LEN, /**< Rollback L2 frame length */ + e_IOC_FM_PCD_PLCR_ROLLBACK_FULL_FRM_LEN + /**< Rollback Full frame length */ +} ioc_fm_pcd_plcr_roll_back_frame_select; + +/* + * @Description Enumeration type for selecting the policer profile packet or + * byte mode + */ +typedef enum ioc_fm_pcd_plcr_rate_mode { + e_IOC_FM_PCD_PLCR_BYTE_MODE, /**< Byte mode */ + e_IOC_FM_PCD_PLCR_PACKET_MODE /**< Packet mode */ +} ioc_fm_pcd_plcr_rate_mode; + +/* + * @Description Enumeration type for defining action of frame + */ +typedef enum ioc_fm_pcd_done_action { + e_IOC_FM_PCD_ENQ_FRAME = 0, /**< Enqueue frame */ + e_IOC_FM_PCD_DROP_FRAME /**< Drop frame */ +} ioc_fm_pcd_done_action; + +/* + * @Description Enumeration type for selecting the policer counter + */ +typedef enum ioc_fm_pcd_plcr_profile_counters { + e_IOC_FM_PCD_PLCR_PROFILE_GREEN_PACKET_TOTAL_COUNTER, + /**< Green packets counter */ + e_IOC_FM_PCD_PLCR_PROFILE_YELLOW_PACKET_TOTAL_COUNTER, + /**< Yellow packets counter */ + e_IOC_FM_PCD_PLCR_PROFILE_RED_PACKET_TOTAL_COUNTER, + /**< Red packets counter */ + e_IOC_FM_PCD_PLCR_PROFILE_RECOLOURED_YELLOW_PACKET_TOTAL_COUNTER, + /**< Recolored yellow packets counter */ + e_IOC_FM_PCD_PLCR_PROFILE_RECOLOURED_RED_PACKET_TOTAL_COUNTER + /**< Recolored red packets counter */ +} ioc_fm_pcd_plcr_profile_counters; + +/* + * @Description Enumeration type for selecting the PCD action after extraction + */ +typedef enum ioc_fm_pcd_action { + e_IOC_FM_PCD_ACTION_NONE, /**< NONE */ + e_IOC_FM_PCD_ACTION_EXACT_MATCH, + /**< Exact match on the selected extraction */ + e_IOC_FM_PCD_ACTION_INDEXED_LOOKUP + /**< Indexed lookup on the selected extraction */ +} ioc_fm_pcd_action; + +/* + * @Description Enumeration type for selecting type of insert manipulation + */ +typedef enum ioc_fm_pcd_manip_hdr_insrt_type { + e_IOC_FM_PCD_MANIP_INSRT_GENERIC, + /**< Insert according to offset & size */ + e_IOC_FM_PCD_MANIP_INSRT_BY_HDR, + /**< Insert according to protocol */ +} ioc_fm_pcd_manip_hdr_insrt_type; + +/* + * @Description Enumeration type for selecting type of remove manipulation + */ +typedef enum ioc_fm_pcd_manip_hdr_rmv_type { + e_IOC_FM_PCD_MANIP_RMV_GENERIC, + /**< Remove according to offset & size */ + e_IOC_FM_PCD_MANIP_RMV_BY_HDR + /**< Remove according to offset & size */ +} ioc_fm_pcd_manip_hdr_rmv_type; + +/* + * @Description An enum for selecting specific L2 fields removal + */ +typedef enum ioc_fm_pcd_manip_hdr_rmv_specific_l2 { + e_IOC_FM_PCD_MANIP_HDR_RMV_ETHERNET, /**< Ethernet/802.3 MAC */ + e_IOC_FM_PCD_MANIP_HDR_RMV_STACKED_QTAGS, /**< stacked QTags */ + e_IOC_FM_PCD_MANIP_HDR_RMV_ETHERNET_AND_MPLS, + /**< MPLS and Ethernet/802.3 MAC header unitl the header + * which follows the MPLS header + */ + e_IOC_FM_PCD_MANIP_HDR_RMV_MPLS + /**< Remove MPLS header (Unlimited MPLS labels) */ +} ioc_fm_pcd_manip_hdr_rmv_specific_l2; + +/* + * @Description Enumeration type for selecting specific fields updates + */ +typedef enum ioc_fm_pcd_manip_hdr_field_update_type { + e_IOC_FM_PCD_MANIP_HDR_FIELD_UPDATE_VLAN, /**< VLAN updates */ + e_IOC_FM_PCD_MANIP_HDR_FIELD_UPDATE_IPV4, /**< IPV4 updates */ + e_IOC_FM_PCD_MANIP_HDR_FIELD_UPDATE_IPV6, /**< IPV6 updates */ + e_IOC_FM_PCD_MANIP_HDR_FIELD_UPDATE_TCP_UDP, /**< TCP_UDP updates */ +} ioc_fm_pcd_manip_hdr_field_update_type; + +/* + * @Description Enumeration type for selecting VLAN updates + */ +typedef enum ioc_fm_pcd_manip_hdr_field_update_vlan { + e_IOC_FM_PCD_MANIP_HDR_FIELD_UPDATE_VLAN_VPRI, + /**< Replace VPri of outer most VLAN tag. */ + e_IOC_FM_PCD_MANIP_HDR_FIELD_UPDATE_DSCP_TO_VLAN + /**< DSCP to VLAN priority bits translation */ +} ioc_fm_pcd_manip_hdr_field_update_vlan; + +/* + * @Description Enumeration type for selecting specific L2 fields removal + */ +typedef enum ioc_fm_pcd_manip_hdr_insrt_specific_l2 { + e_IOC_FM_PCD_MANIP_HDR_INSRT_MPLS + /**< Insert MPLS header (Unlimited MPLS labels) */ +} ioc_fm_pcd_manip_hdr_insrt_specific_l2; + +/* + * @Description Enumeration type for selecting QoS mapping mode + * + * Note: In all cases except + * 'e_FM_PCD_MANIP_HDR_QOS_MAPPING_NONE' User should instruct the + * port to read the parser-result + */ +typedef enum ioc_fm_pcd_manip_hdr_qos_mapping_mode { + e_IOC_FM_PCD_MANIP_HDR_QOS_MAPPING_NONE = 0, + /**< No mapping, QoS field will not be changed */ + e_IOC_FM_PCD_MANIP_HDR_QOS_MAPPING_AS_IS, + /**< QoS field will be overwritten by the last byte in + * the parser-result. + */ +} ioc_fm_pcd_manip_hdr_qos_mapping_mode; + +/* + * @Description Enumeration type for selecting QoS source + * + * Note: In all cases except 'e_FM_PCD_MANIP_HDR_QOS_SRC_NONE' + * User should left room for the parser-result on input/output + * buffer and instruct the port to read/write the parser-result + * to the buffer (RPD should be set) + */ +typedef enum ioc_fm_pcd_manip_hdr_qos_src { + e_IOC_FM_PCD_MANIP_HDR_QOS_SRC_NONE = 0, + /**< TODO */ + e_IOC_FM_PCD_MANIP_HDR_QOS_SRC_USER_DEFINED, + /**< QoS will be taken from the last byte in the + * parser-result. + */ +} ioc_fm_pcd_manip_hdr_qos_src; + +/* + * @Description Enumeration type for selecting type of header insertion + */ +typedef enum ioc_fm_pcd_manip_hdr_insrt_by_hdr_type { + e_IOC_FM_PCD_MANIP_INSRT_BY_HDR_SPECIFIC_L2, + /**< Specific L2 fields insertion */ + e_IOC_FM_PCD_MANIP_INSRT_BY_HDR_IP, /**< IP insertion */ + e_IOC_FM_PCD_MANIP_INSRT_BY_HDR_UDP, /**< UDP insertion */ + e_IOC_FM_PCD_MANIP_INSRT_BY_HDR_UDP_LITE, + /**< UDP lite insertion */ + e_IOC_FM_PCD_MANIP_INSRT_BY_HDR_CAPWAP /**< CAPWAP insertion */ +} ioc_fm_pcd_manip_hdr_insrt_by_hdr_type; + +/* + * @Description Enumeration type for selecting specific custom command + */ +typedef enum ioc_fm_pcd_manip_hdr_custom_type { + e_IOC_FM_PCD_MANIP_HDR_CUSTOM_IP_REPLACE, + /**< Replace IPv4/IPv6 */ + e_IOC_FM_PCD_MANIP_HDR_CUSTOM_GEN_FIELD_REPLACE, +} ioc_fm_pcd_manip_hdr_custom_type; + +/* + * @Description Enumeration type for selecting specific custom command + */ +typedef enum ioc_fm_pcd_manip_hdr_custom_ip_replace { + e_IOC_FM_PCD_MANIP_HDR_CUSTOM_REPLACE_IPV4_BY_IPV6, + /**< Replace IPv4 by IPv6 */ + e_IOC_FM_PCD_MANIP_HDR_CUSTOM_REPLACE_IPV6_BY_IPV4 + /**< Replace IPv6 by IPv4 */ +} ioc_fm_pcd_manip_hdr_custom_ip_replace; + +/* + * @Description Enumeration type for selecting type of header removal + */ +typedef enum ioc_fm_pcd_manip_hdr_rmv_by_hdr_type { + e_IOC_FM_PCD_MANIP_RMV_BY_HDR_SPECIFIC_L2 = 0, + /**< Specific L2 fields removal */ + e_IOC_FM_PCD_MANIP_RMV_BY_HDR_CAPWAP, /**< CAPWAP removal */ + e_IOC_FM_PCD_MANIP_RMV_BY_HDR_FROM_START, + /**< Locate from data that is not the header */ +} ioc_fm_pcd_manip_hdr_rmv_by_hdr_type; + +/* + * @Description Enumeration type for selecting type of timeout mode + */ +typedef enum ioc_fm_pcd_manip_reassem_time_out_mode { + e_IOC_FM_PCD_MANIP_TIME_OUT_BETWEEN_FRAMES, + /**< Limits the time of the reassembly + * process from the first fragment to + * the last + */ + e_IOC_FM_PCD_MANIP_TIME_OUT_BETWEEN_FRAG + /**< Limits the time of receiving the + * fragment + */ +} ioc_fm_pcd_manip_reassem_time_out_mode; + +/* + * @Description Enumeration type for selecting type of WaysNumber mode + */ +typedef enum ioc_fm_pcd_manip_reassem_ways_number { + e_IOC_FM_PCD_MANIP_ONE_WAY_HASH = 1, /**< One way hash */ + e_IOC_FM_PCD_MANIP_TWO_WAYS_HASH, /**< Two ways hash */ + e_IOC_FM_PCD_MANIP_THREE_WAYS_HASH, /**< Three ways hash */ + e_IOC_FM_PCD_MANIP_FOUR_WAYS_HASH, /**< Four ways hash */ + e_IOC_FM_PCD_MANIP_FIVE_WAYS_HASH, /**< Five ways hash */ + e_IOC_FM_PCD_MANIP_SIX_WAYS_HASH, /**< Six ways hash */ + e_IOC_FM_PCD_MANIP_SEVEN_WAYS_HASH, /**< Seven ways hash */ + e_IOC_FM_PCD_MANIP_EIGHT_WAYS_HASH /**< Eight ways hash */ +} ioc_fm_pcd_manip_reassem_ways_number; + +/* + * @Description Enumeration type for selecting manipulation type + */ +typedef enum ioc_fm_pcd_manip_type { + e_IOC_FM_PCD_MANIP_HDR = 0, /**< Header manipulation */ + e_IOC_FM_PCD_MANIP_REASSEM, /**< Reassembly */ + e_IOC_FM_PCD_MANIP_FRAG, /**< Fragmentation */ + e_IOC_FM_PCD_MANIP_SPECIAL_OFFLOAD /**< Special Offloading */ +} ioc_fm_pcd_manip_type; + +/* + * @Description Enumeration type for selecting type of statistics mode + */ +typedef enum ioc_fm_pcd_cc_stats_mode { + e_IOC_FM_PCD_CC_STATS_MODE_NONE = 0, /**< No statistics support */ + e_IOC_FM_PCD_CC_STATS_MODE_FRAME, /**< Frame count statistics */ + e_IOC_FM_PCD_CC_STATS_MODE_BYTE_AND_FRAME, + /**< Byte and frame count statistics */ + e_IOC_FM_PCD_CC_STATS_MODE_RMON, + /**< Byte and frame length range count statistics */ +} ioc_fm_pcd_cc_stats_mode; + +/* + * @Description Enumeration type for determining the action in case an IP + * packet is larger than MTU but its DF (Don't Fragment) bit is + * set. + */ +typedef enum ioc_fm_pcd_manip_donot_frag_action { + e_IOC_FM_PCD_MANIP_DISCARD_PACKET = 0, /**< Discard packet */ + e_IOC_FM_PCD_MANIP_ENQ_TO_ERR_Q_OR_DISCARD_PACKET = + e_IOC_FM_PCD_MANIP_DISCARD_PACKET, + /**< Obsolete, cannot enqueue to error queue; In + * practice, selects to discard packets; Will be + * removed in the future + */ + e_IOC_FM_PCD_MANIP_FRAGMENT_PACKECT, + /**< Fragment packet and continue normal + * processing + */ + e_IOC_FM_PCD_MANIP_CONTINUE_WITHOUT_FRAG + /**< Continue normal processing without + * fragmenting the packet + */ +} ioc_fm_pcd_manip_donot_frag_action; + +/* + * @Description Enumeration type for selecting type of special offload + * manipulation + */ +typedef enum ioc_fm_pcd_manip_special_offload_type { + e_IOC_FM_PCD_MANIP_SPECIAL_OFFLOAD_IPSEC, + /**< IPSec offload manipulation */ + e_IOC_FM_PCD_MANIP_SPECIAL_OFFLOAD_CAPWAP + /**< CAPWAP offload manipulation */ +} ioc_fm_pcd_manip_special_offload_type; + +/* + * @Description A union of protocol dependent special options + * (Must match union u_FmPcdHdrProtocolOpt defined in + * fm_pcd_ext.h) + */ +typedef union ioc_fm_pcd_hdr_protocol_opt_u { + ioc_eth_protocol_opt_t eth_opt; /**< Ethernet options */ + ioc_vlan_protocol_opt_t vlan_opt; /**< Vlan options */ + ioc_mpls_protocol_opt_t mpls_opt; /**< MPLS options */ + ioc_ipv4_protocol_opt_t ipv4_opt; /**< IPv4 options */ + ioc_ipv6_protocol_opt_t ipv6_opt; /**< IPv6 options */ + ioc_capwap_protocol_opt_t capwap_opt; /**< CAPWAP options */ +} ioc_fm_pcd_hdr_protocol_opt_u; + +/* + * @Description A union holding all known protocol fields + */ +typedef union ioc_fm_pcd_fields_u { + ioc_header_field_eth_t eth; /**< Ethernet*/ + ioc_header_field_vlan_t vlan; /**< VLAN*/ + ioc_header_field_llc_snap_t llc_snap; /**< LLC SNAP*/ + ioc_header_field_pppoe_t pppoe; /**< PPPoE*/ + ioc_header_field_mpls_t mpls; /**< MPLS*/ + ioc_header_field_ip_t ip; /**< IP */ + ioc_header_field_ipv4_t ipv4; /**< IPv4*/ + ioc_header_field_ipv6_t ipv6; /**< IPv6*/ + ioc_header_field_udp_t udp; /**< UDP */ + ioc_header_field_udp_lite_t udp_lite; /**< UDP_Lite*/ + ioc_header_field_tcp_t tcp; /**< TCP */ + ioc_header_field_sctp_t sctp; /**< SCTP*/ + ioc_header_field_dccp_t dccp; /**< DCCP*/ + ioc_header_field_gre_t gre; /**< GRE */ + ioc_header_field_minencap_t minencap;/**< Minimal Encapsulation */ + ioc_header_field_ipsec_ah_t ipsec_ah; /**< IPSec AH*/ + ioc_header_field_ipsec_esp_t ipsec_esp; /**< IPSec ESP*/ + ioc_header_field_udp_encap_esp_t udp_encap_esp; + /**< UDP Encapsulation ESP */ +} ioc_fm_pcd_fields_u; + +/* + * @Description Parameters for defining header extraction for key generation + */ +typedef struct ioc_fm_pcd_from_hdr_t { + uint8_t size; /**< Size in byte */ + uint8_t offset; /**< Byte offset */ +} ioc_fm_pcd_from_hdr_t; + +/* + * @Description Parameters for defining field extraction for key generation + */ +typedef struct ioc_fm_pcd_from_field_t { + ioc_fm_pcd_fields_u field; /**< Field selection */ + uint8_t size; /**< Size in byte */ + uint8_t offset; /**< Byte offset */ +} ioc_fm_pcd_from_field_t; + +/* + * @Description Parameters for defining a single network environment unit + * A distinction unit should be defined if it will later be used + * by one or more PCD engines to distinguish between flows. + * (Must match struct t_FmPcdDistinctionUnit defined in + * fm_pcd_ext.h) + */ +typedef struct ioc_fm_pcd_distinction_unit_t { + struct { + ioc_net_header_type hdr; + /**< One of the headers supported by the FM */ + ioc_fm_pcd_hdr_protocol_opt_u opt; /**< Select only one option! */ + } hdrs[IOC_FM_PCD_MAX_NUM_OF_INTERCHANGEABLE_HDRS]; +} ioc_fm_pcd_distinction_unit_t; + +/* + * @Description Parameters for defining all different distinction units + * supported by a specific PCD Network Environment + * Characteristics module. + * + * Each unit represent a protocol or a group of protocols that + * may be used later by the different PCD engines to distinguish + * between flows. + * (Must match struct t_FmPcdNetEnvParams defined in + * fm_pcd_ext.h) + */ +struct fm_pcd_net_env_params_t { + uint8_t num_of_distinction_units; + /**< Number of different units to be identified */ + ioc_fm_pcd_distinction_unit_t + units[IOC_FM_PCD_MAX_NUM_OF_DISTINCTION_UNITS]; + /**< An array of num_of_distinction_units of the different units to be + * identified + */ +}; + +typedef struct ioc_fm_pcd_net_env_params_t { + struct fm_pcd_net_env_params_t param; + void *id; + /**< Output parameter; Returns the net-env Id to be used */ +} ioc_fm_pcd_net_env_params_t; + +/* + * @Description Parameters for defining a single extraction action when + * creating a key + */ +typedef struct ioc_fm_pcd_extract_entry_t { + ioc_fm_pcd_extract_type type; /**< Extraction type select */ + union { + struct { + ioc_net_header_type hdr; /**< Header selection */ + bool ignore_protocol_validation; + /**< Ignore protocol validation */ + ioc_fm_pcd_hdr_index hdr_index; + /**< Relevant only for MPLS, VLAN and + * tunneled IP. Otherwise should be + * cleared. + */ + ioc_fm_pcd_extract_by_hdr_type type; + /**< Header extraction type select */ + union { + ioc_fm_pcd_from_hdr_t from_hdr; + /**< Extract bytes from header + * parameters + */ + ioc_fm_pcd_from_field_t from_field; + /**< Extract bytes from field parameters + */ + ioc_fm_pcd_fields_u full_field; + /**< Extract full field parameters */ + } extract_by_hdr_type; + } extract_by_hdr;/**< Used when type = e_IOC_FM_PCD_KG_EXTRACT_BY_HDR */ + struct { + ioc_fm_pcd_extract_from src; + /**< Non-header extraction source */ + ioc_fm_pcd_action action; /**< Relevant for CC Only */ + uint16_t ic_indx_mask; + /**< Relevant only for CC whenaction = + * e_IOC_FM_PCD_ACTION_INDEXED_LOOKUP; Note that + * the number of bits that are set within this + * mask must be log2 of the CC-node + * 'num_of_keys'. Note that the mask cannot be + * set on the lower bits. + */ + uint8_t offset; /**< Byte offset */ + uint8_t size; /**< Size in bytes */ + } extract_non_hdr; + /**< Used when type = e_IOC_FM_PCD_KG_EXTRACT_NON_HDR */ + } extract_params; +} ioc_fm_pcd_extract_entry_t; + +/* + * @Description A structure for defining masks for each extracted + * field in the key. + */ +typedef struct ioc_fm_pcd_kg_extract_mask_t { + uint8_t extract_array_index; + /**< Index in the extraction array, as + * initialized by user + */ + uint8_t offset; /**< Byte offset */ + uint8_t mask; + /**< A byte mask (selected bits will be ignored) */ +} ioc_fm_pcd_kg_extract_mask_t; + +/* + * @Description A structure for defining default selection per groups of + * fields + */ +typedef struct ioc_fm_pcd_kg_extract_dflt_t { + ioc_fm_pcd_kg_known_fields_dflt_types type; + /**< Default type select */ + ioc_fm_pcd_kg_extract_dflt_select dflt_select; + /**< Default register select */ +} ioc_fm_pcd_kg_extract_dflt_t; + + +/* + * @Description A structure for defining all parameters needed for + * generation a key and using a hash function + */ +typedef struct ioc_fm_pcd_kg_key_extract_and_hash_params_t { + uint32_t private_dflt0; + /**< Scheme default register 0 */ + uint32_t private_dflt1; + /**< Scheme default register 1 */ + uint8_t num_of_used_extracts; + /**< defines the valid size of the + * following array + */ + ioc_fm_pcd_extract_entry_t + extract_array[IOC_FM_PCD_KG_MAX_EXTRACTS_PER_KEY]; + /**< An array of extraction definitions. + */ + uint8_t num_of_used_dflts; + /**< defines the valid size of the + * following array + */ + ioc_fm_pcd_kg_extract_dflt_t + dflts[IOC_FM_PCD_KG_NUM_OF_DEFAULT_GROUPS]; + /**< For each extraction used in this + * scheme, specify the required default + * register to be used when header is + * not found. types not specified in + * this array will get undefined value. + */ + uint8_t num_of_used_masks; + /**< Defines the valid size of the + * following array + */ + ioc_fm_pcd_kg_extract_mask_t + masks[IOC_FM_PCD_KG_NUM_OF_EXTRACT_MASKS]; + uint8_t hash_shift; + /**< Hash result right shift. Selects + * the 24 bits out of the 64 hash + * result. 0 means using the 24 LSB's, + * otherwise use the 24 LSB's after + * shifting right. + */ + uint32_t hash_dist_num_of_fqids; + /**< must be > 1 and a power of 2. + * Represents the range of queues for + * the key and hash functionality + */ + uint8_t hash_distribution_fqids_shift; + /**< selects the FQID bits that will be + * effected by the hash + */ + bool symmetric_hash; + /**< TRUE to generate the same hash for + * frames with swapped source and + * destination fields on all layers; If + * TRUE, driver will check that for all + * layers, if SRC extraction is + * selected, DST extraction must also be + * selected, and vice versa. + */ +} ioc_fm_pcd_kg_key_extract_and_hash_params_t; + +/* + * @Description A structure of parameters for defining a single Qid mask + * (extracted OR). + */ +typedef struct ioc_fm_pcd_kg_extracted_or_params_t { + ioc_fm_pcd_extract_type type; + /**< Extraction type select */ + union { + struct { + /**< used when type = e_IOC_FM_PCD_KG_EXTRACT_BY_HDR */ + ioc_net_header_type hdr; + ioc_fm_pcd_hdr_index hdr_index; + /**< Relevant only for MPLS, + * VLAN and tunneled IP. + * Otherwise should be cleared. + */ + bool ignore_protocol_validation; + + } extract_by_hdr; + ioc_fm_pcd_extract_from src; + /**< used when type = + * e_IOC_FM_PCD_KG_EXTRACT_NON_HDR + */ + } extract_params; + uint8_t extraction_offset; + /**< Offset for extraction */ + ioc_fm_pcd_kg_extract_dflt_select dflt_value; + /**< Select register from which + * extraction is taken if field not + * found + */ + uint8_t mask; + /**< Mask LSB byte of extraction + * (specified bits are ignored) + */ + + uint8_t bit_offset_in_fqid; + /**< 0-31, Selects which bits of the 24 FQID bits to effect + * using the extracted byte; Assume byte is placed as the 8 + * MSB's in a 32 bit word where the lower bits are the FQID; i.e + * if bitOffsetInFqid=1 than its LSB will effect the FQID MSB, + * if bitOffsetInFqid=24 than the extracted byte will effect the + * 8 LSB's of the FQID, if bitOffsetInFqid=31 than the byte's + * MSB will effect the FQID's LSB; 0 means - no effect on FQID; + * Note that one, and only one of bitOffsetInFqid or + * bitOffsetInPlcrProfile must be set (i.e, extracted byte must + * effect either FQID or Policer profile). + */ + uint8_t bit_offset_in_plcr_profile; + /**< 0-15, Selects which bits of the 8 policer profile id bits + * to effect using the extracted byte; Assume byte is placed as + * the 8 MSB's in a 16 bit word where the lower bits are the + * policer profile id; i.e if bitOffsetInPlcrProfile=1 than its + * LSB will effect the profile MSB, if bitOffsetInFqid=8 than + * the extracted byte will effect the whole policer profile id, + * if bitOffsetInFqid=15 than the byte's MSB will effect the + * Policer Profile id's LSB; 0 means - no effect on policer + * profile; Note that one, and only one of bitOffsetInFqid or + * bitOffsetInPlcrProfile must be set (i.e, extracted byte must + * effect either FQID or Policer profile). + */ +} ioc_fm_pcd_kg_extracted_or_params_t; + +/* + * @Description A structure for configuring scheme counter + */ +typedef struct ioc_fm_pcd_kg_scheme_counter_t { + bool update; + /**< FALSE to keep the current counter state and + * continue from that point, TRUE to update/reset the + * counter when the scheme is written. + */ + uint32_t value; + /**< If update=TRUE, this value will be written into the + * counter; clear this field to reset the counter. + */ +} ioc_fm_pcd_kg_scheme_counter_t; + + +/* + * @Description A structure for retrieving FMKG_SE_SPC + */ +typedef struct ioc_fm_pcd_kg_scheme_spc_t { + uint32_t val; /**< return value */ + void *id; /**< scheme handle */ +} ioc_fm_pcd_kg_scheme_spc_t; + +/* + * @Description A structure for defining policer profile parameters as + * required by keygen (when policer is the next engine after this + * scheme). + * (Must match struct t_FmPcdKgPlcrProfile defined in + * fm_pcd_ext.h) + */ +typedef struct ioc_fm_pcd_kg_plcr_profile_t { + bool shared_profile; + /**< TRUE if this profile is shared between ports (i.e. + * managed by primary partition) May not be TRUE if + * profile is after Coarse Classification + */ + bool direct; + /**< If TRUE, direct_relative_profile_id only selects + * the profile id, if FALSE + * fqid_offset_relative_profile_id_base is used together + * with fqid_offset_shift and num_of_profiles + * parameters, to define a range of profiles from which + * the KeyGen result will determine the destination + * policer profile. + */ + union { + uint16_t direct_relative_profile_id; + /**< Used if 'direct' is TRUE, to select policer + * profile. This parameter should indicate the policer + * profile offset within the port's policer profiles or + * SHARED window. + */ + struct { + uint8_t fqid_offset_shift; + /**< Shift of KG results without the qid base */ + uint8_t fqid_offset_relative_profile_id_base; + /**< OR of KG results without the qid base This + * parameter should indicate the policer profile offset + * within the port's policer profiles window or SHARED + * window depends on shared_profile + */ + uint8_t num_of_profiles; + /**< Range of profiles starting at base */ + } indirect_profile; /**< Indirect profile parameters */ + } profile_select; + /**< Direct/indirect profile selection and parameters */ +} ioc_fm_pcd_kg_plcr_profile_t; + +/* + * @Description Parameters for configuring a storage profile for a KeyGen + * scheme. + */ +typedef struct ioc_fm_pcd_kg_storage_profile_t { + bool direct; + /**< If TRUE, directRelativeProfileId only selects the profile + * id; If FALSE, fqidOffsetRelativeProfileIdBase is used + * together with fqidOffsetShift and num_of_profiles parameters + * to define a range of profiles from which the KeyGen result + * will determine the destination storage profile. + */ + union { + uint16_t direct_relative_profile_id; + /**< Used when 'direct' is TRUE, to select a storage profile; + * should indicate the storage profile offset within the port's + * storage profiles window. + */ + struct { + uint8_t fqid_offset_shift; + /**< Shift of KeyGen results without the FQID base */ + uint8_t fqid_offset_relative_profile_id_base; + /**< OR of KeyGen results without the FQID base; should + * indicate the policer profile offset within the port's + * storage profiles window. + */ + uint8_t num_of_profiles; + /**< Range of profiles starting at base. */ + } indirect_profile; + /**< Indirect profile parameters. */ + } profile_select; + /**< Direct/indirect profile selection and parameters. */ +} ioc_fm_pcd_kg_storage_profile_t; + +/* + * @Description Parameters for defining CC as the next engine after KeyGen + * (Must match struct t_FmPcdKgCc defined in fm_pcd_ext.h) + */ +typedef struct ioc_fm_pcd_kg_cc_t { + void *tree_id; + /**< CC Tree id */ + uint8_t grp_id; + /**< CC group id within the CC tree */ + bool plcr_next; + /**< TRUE if after CC, in case of data + * frame, policing is required. + */ + bool bypass_plcr_profile_generation; + /**< TRUE to bypass KeyGen policer + * profile generation; selected profile + * is the one set at port initialization + */ + ioc_fm_pcd_kg_plcr_profile_t plcr_profile; + /**< Valid only if plcr_next = TRUE and + * bypass_plcr_profile_generation = + * FALSE + */ +} ioc_fm_pcd_kg_cc_t; + +/* + * @Description Parameters for defining initializing a KeyGen scheme (Must + * match struct t_FmPcdKgSchemeParams defined in fm_pcd_ext.h) + */ +struct fm_pcd_kg_scheme_params_t { + bool modify; /**< TRUE to change an existing scheme */ + union { + uint8_t relative_scheme_id; + /**< if modify=FALSE: partition-relative scheme id */ + void *scheme_id; + /**< if modify=TRUE: the id of an existing scheme */ + } scm_id; + bool always_direct; + /**< This scheme is reached only directly, i.e. no need for + * match vector; KeyGen will ignore it when matching + */ + struct { + /**< HL relevant only if always_direct=FALSE */ + void *net_env_id; + /**< The id of the Network Environment as returned + * by fm_pcd_net_env_characteristics_set() + */ + uint8_t num_of_distinction_units; + /**< Number of NetEnv units listed in unit_ids array */ + uint8_t unit_ids[IOC_FM_PCD_MAX_NUM_OF_DISTINCTION_UNITS]; + /**< Indexes as passed to SetNetEnvCharacteristics (?) array */ + } net_env_params; + bool use_hash; + /**< use the KG Hash functionality */ + ioc_fm_pcd_kg_key_extract_and_hash_params_t key_ext_and_hash; + /**< used only if useHash = TRUE */ + bool bypass_fqid_generation; + /**< Normally - FALSE, TRUE to avoid FQID update in the IC; In + * such a case FQID after KG will be the default FQID defined + * for the relevant port, or the FQID defined by CC in cases + * where CC was the previous engine. + */ + uint32_t base_fqid; + /**< Base FQID; Relevant only if bypass_fqid_generation = FALSE; + * If hash is used and an even distribution is expected + * according to hash_dist_num_of_fqids, base_fqid must + * be aligned to hash_dist_num_of_fqids. + */ + uint8_t num_of_used_extracted_ors; + /**< Number of FQID masks listed in extracted_ors array*/ + ioc_fm_pcd_kg_extracted_or_params_t + extracted_ors[IOC_FM_PCD_KG_NUM_OF_GENERIC_REGS]; + /**< IOC_FM_PCD_KG_NUM_OF_GENERIC_REGS registers are shared + * between qid_masks functionality and some of the extraction + * actions; Normally only some will be used for qid_mask. Driver + * will return error if resource is full at initialization time. + */ + bool override_storage_profile; + /**< TRUE if KeyGen override previously decided storage profile + */ + ioc_fm_pcd_kg_storage_profile_t storage_profile; + /**< Used when override_storage_profile=TRUE */ + ioc_fm_pcd_engine next_engine; + /**< may be BMI, PLCR or CC */ + union { + /**< depends on nextEngine */ + ioc_fm_pcd_done_action done_action; + /**< Used when next engine is BMI (done) */ + ioc_fm_pcd_kg_plcr_profile_t plcr_profile; + /**< Used when next engine is PLCR */ + ioc_fm_pcd_kg_cc_t cc; + /**< Used when next engine is CC */ + } kg_next_engine_params; + ioc_fm_pcd_kg_scheme_counter_t scheme_counter; + /**< A structure of parameters for updating the scheme counter*/ +}; + +typedef struct ioc_fm_pcd_kg_scheme_params_t { + struct fm_pcd_kg_scheme_params_t param; + void *id; /**< Returns the scheme Id to be used */ +} ioc_fm_pcd_kg_scheme_params_t; + +/* + * @Collection + */ +#define IOC_FM_PCD_CC_STATS_MAX_FLR 10 + /* Maximal supported number of frame length ranges */ +#define IOC_FM_PCD_CC_STATS_FLR_SIZE 2 + /* Size in bytes of a frame length range limit */ +#define IOC_FM_PCD_CC_STATS_FLR_COUNT_SIZE 4 + /* Size in bytes of a frame length range counter */ +/* @} */ + +/* + * @Description Parameters for defining CC as the next engine after a CC node. + * (Must match struct t_FmPcdCcNextCcParams defined in + * fm_pcd_ext.h) + */ +typedef struct ioc_fm_pcd_cc_next_cc_params_t { + void *cc_node_id; /**< Id of the next CC node */ +} ioc_fm_pcd_cc_next_cc_params_t; + +/* + * @Description A structure for defining Frame Replicator as the next engine + * after a CC node. (Must match struct t_FmPcdCcNextFrParams + * defined in fm_pcd_ext.h) + */ +typedef struct ioc_fm_pcd_cc_next_fr_params_t { + void *frm_replic_id; + /**< The id of the next frame replicator group */ +} ioc_fm_pcd_cc_next_fr_params_t; + +/* + * @Description A structure for defining PLCR params when PLCR is the + * next engine after a CC node + * (Must match struct t_FmPcdCcNextPlcrParams defined in + * fm_pcd_ext.h) + */ +typedef struct ioc_fm_pcd_cc_next_plcr_params_t { + bool override_params; + /**< TRUE if CC override previously decided parameters*/ + bool shared_profile; + /**< Relevant only if overrideParams=TRUE: TRUE if this profile + * is shared between ports + */ + uint16_t new_relative_profile_id; + /**< Relevant only if overrideParams=TRUE: (otherwise profile id + * is taken from keygen); This parameter should indicate the + * policer profile offset within the port's policer profiles or + * from SHARED window. + */ + uint32_t new_fqid; + /**< Relevant only if overrideParams=TRUE: FQID for enquing the + * frame; In earlier chips if policer next engine is KEYGEN, + * this parameter can be 0, because the KEYGEN always decides + * the enqueue FQID. + */ + uint8_t new_relative_storage_profile_id; + /**< Indicates the relative storage profile offset within the + * port's storage profiles window; Relevant only if the port was + * configured with VSP. + */ +} ioc_fm_pcd_cc_next_plcr_params_t; + +/* + * @Description A structure for defining enqueue params when BMI is the next + * engine after a CC node (Must match struct + * t_FmPcdCcNextEnqueueParams defined in fm_pcd_ext.h) + */ +typedef struct ioc_fm_pcd_cc_next_enqueue_params_t { + ioc_fm_pcd_done_action action; + /**< Action - when next engine is BMI (done) */ + bool override_fqid; + /**< TRUE if CC override previously decided fqid + * and vspid, relevant if action = + * e_IOC_FM_PCD_ENQ_FRAME + */ + uint32_t new_fqid; + /**< Valid if overrideFqid=TRUE, FQID for + * enqueuing the frame (otherwise FQID is taken + * from KeyGen), relevant if action = + * e_IOC_FM_PCD_ENQ_FRAME + */ + uint8_t new_relative_storage_profile_id; + /**< Valid if override_fqid=TRUE, Indicates the relative + * virtual storage profile offset within the port's + * storage profiles window; Relevant only if the port + * was configured with VSP. + */ + +} ioc_fm_pcd_cc_next_enqueue_params_t; + +/* + * @Description A structure for defining KG params when KG is the next engine + * after a CC node (Must match struct t_FmPcdCcNextKgParams + * defined in fm_pcd_ext.h) + */ +typedef struct ioc_fm_pcd_cc_next_kg_params_t { + bool override_fqid; + /**< TRUE if CC override previously decided fqid and vspid, + * Note - this parameters are irrelevant for earlier chips + */ + uint32_t new_fqid; + /**< Valid if overrideFqid=TRUE, FQID for enqueuing the frame + * (otherwise FQID is taken from KeyGen), + * Note - this parameters are irrelevant for earlier chips + */ + uint8_t new_relative_storage_profile_id; + /**< Valid if override_fqid=TRUE, Indicates the relative virtual + * storage profile offset within the port's storage profiles + * window; Relevant only if the port was configured with VSP. + */ + void *p_direct_scheme; /**< Direct scheme id to go to. */ +} ioc_fm_pcd_cc_next_kg_params_t; + +/* + * @Description Parameters for defining the next engine after a CC node. + * (Must match struct ioc_fm_pcd_cc_next_engine_params_t defined + * in fm_pcd_ext.h) + */ +typedef struct ioc_fm_pcd_cc_next_engine_params_t { + ioc_fm_pcd_engine next_engine; + /**< User has to initialize parameters according + * to nextEngine definition + */ + union { + ioc_fm_pcd_cc_next_cc_params_t cc_params; + /**< Parameters in case next engine is CC */ + ioc_fm_pcd_cc_next_plcr_params_t plcr_params; + /**< Parameters in case next engine is PLCR */ + ioc_fm_pcd_cc_next_enqueue_params_t enqueue_params; + /**< Parameters in case next engine is BMI */ + ioc_fm_pcd_cc_next_kg_params_t kg_params; + /**< Parameters in case next engine is KG */ + ioc_fm_pcd_cc_next_fr_params_t fr_params; + /**< Parameters in case next engine is FR */ + } params; + /**< Union used for all the next-engine parameters options */ + void *manip_id; + /**< Handle to Manipulation object. Relevant if + * next engine is of type result + * (e_IOC_FM_PCD_PLCR, e_IOC_FM_PCD_KG, + * e_IOC_FM_PCD_DONE) + */ + bool statistics_en; + /**< If TRUE, statistics counters are + * incremented for each frame passing through + * this Coarse Classification entry. + */ +} ioc_fm_pcd_cc_next_engine_params_t; + +/* + * @Description Parameters for defining a single CC key + */ +typedef struct ioc_fm_pcd_cc_key_params_t { + uint8_t *p_key; + /**< pointer to the key of the size defined in key_size + */ + uint8_t *p_mask; + /**< pointer to the Mask per key of the size defined in + * key_size. p_key and p_mask (if defined) has to be of + * the same size defined in the key_size + */ + ioc_fm_pcd_cc_next_engine_params_t cc_next_engine_params; + /**< parameters for the next for the defined Key in + * p_key + */ + +} ioc_fm_pcd_cc_key_params_t; + +/* + * @Description Parameters for defining CC keys parameters + * The driver supports two methods for CC node allocation: + * dynamic and static. Static mode was created in order to + * prevent runtime alloc/free of FMan memory (MURAM), which may + * cause fragmentation; in this mode, the driver automatically + * allocates the memory according to 'max_num_of_keys' parameter. + * The driver calculates the maximal memory size that may be used + * for this CC-Node taking into consideration 'mask_support' and + * 'statistics_mode' parameters. When 'action' = + * e_IOC_FM_PCD_ACTION_INDEXED_LOOKUP in the extraction + * parameters of this node, 'max_num_of_keys' must be equal to + * 'num_of_keys'. In dynamic mode, 'max_num_of_keys' must be + * zero. At initialization, all required structures are allocated + * according to 'num_of_keys' parameter. During runtime + * modification, these structures are re-allocated according to + * the updated number of keys. + * Please note that 'action' and 'ic_indx_mask' mentioned in the + * specific parameter explanations are passed in the extraction + * parameters of the node (fields of + * extractccparams.extractnonhdr). + */ +typedef struct ioc_keys_params_t { + uint16_t max_num_of_keys; + /**< Maximum number of keys that will (ever) be used in + * this CC-Node; A value of zero may be used for dynamic + * memory allocation. + */ + bool mask_support; + /**< This parameter is relevant only if a node is + * initialized with action = + * e_IOC_FM_PCD_ACTION_EXACT_MATCH and max_num_of_keys > + * 0; Should be TRUE to reserve table memory for key + * masks, even if initial keys do not contain masks, or + * if the node was initialized as 'empty' (without + * keys); this will allow user to add keys with masks at + * runtime. + */ + ioc_fm_pcd_cc_stats_mode statistics_mode; + /**< Determines the supported statistics mode for all + * node's keys. To enable statistics gathering, + * statistics should be enabled per every key, using + * 'statistics_en' in next engine parameters structure + * of that key; If 'max_num_of_keys' is set, all + * required structures will be preallocated for all keys + */ + uint16_t frame_length_ranges[IOC_FM_PCD_CC_STATS_MAX_FLR]; + /**< Relevant only for 'RMON' statistics mode (this feature is + * supported only on B4860 device); Holds a list of programmable + * thresholds. For each received frame, its length in bytes is + * examined against these range thresholds and the appropriate + * counter is incremented by 1. For example, to belong to range + * i, the following should hold: range i-1 threshold < frame + * length <= range i threshold Each range threshold must be + * larger then its preceding range threshold. Last range + * threshold must be 0xFFFF. + */ + uint16_t num_of_keys; + /**< Number of initial keys; Note that in case of 'action' = + * e_IOC_FM_PCD_ACTION_INDEXED_LOOKUP, this field should be + * power-of-2 of the number of bits that are set in + * 'ic_indx_mask'. + */ + uint8_t key_size; + /**< Size of key - for extraction of type FULL_FIELD, 'key_size' + * has to be the standard size of the selected key; For other + * extraction types, 'key_size' has to be as size of extraction; + * When 'action' = e_IOC_FM_PCD_ACTION_INDEXED_LOOKUP, + * 'key_size' must be 2. + */ + ioc_fm_pcd_cc_key_params_t key_params[IOC_FM_PCD_MAX_NUM_OF_KEYS]; + /**< An array with 'num_of_keys' entries, each entry specifies + * the corresponding key parameters; When 'action' = + * e_IOC_FM_PCD_ACTION_EXACT_MATCH, this value must not exceed + * 255 (IOC_FM_PCD_MAX_NUM_OF_KEYS-1) as the last entry is saved + * for the 'miss' entry. + */ + ioc_fm_pcd_cc_next_engine_params_t cc_next_engine_params_for_miss; + /**< Parameters for defining the next engine when a key is not + * matched; Not relevant if action = + * e_IOC_FM_PCD_ACTION_INDEXED_LOOKUP. + */ +} ioc_keys_params_t; + +/* + * @Description Parameters for defining a CC node + */ +struct fm_pcd_cc_node_params_t { + ioc_fm_pcd_extract_entry_t extract_cc_params; + /**< Extraction parameters */ + ioc_keys_params_t keys_params; + /**< Keys definition matching the selected extraction */ +}; + +typedef struct ioc_fm_pcd_cc_node_params_t { + struct fm_pcd_cc_node_params_t param; + void *id; + /**< Output parameter; returns the CC node Id to be used */ +} ioc_fm_pcd_cc_node_params_t; + +/* + * @Description Parameters for defining a hash table + * (Must match struct ioc_fm_pcd_hash_table_params_t defined in + * fm_pcd_ext.h) + */ +struct fm_pcd_hash_table_params_t { + uint16_t max_num_of_keys; + /**< Maximum Number Of Keys that will (ever) be used in this + * Hash-table + */ + ioc_fm_pcd_cc_stats_mode statistics_mode; + /**< If not e_IOC_FM_PCD_CC_STATS_MODE_NONE, the required + * structures for the requested statistics mode will be + * allocated according to max_num_of_keys. + */ + uint8_t kg_hash_shift; + /**< KG-Hash-shift as it was configured in the KG-scheme that + * leads to this hash-table. + */ + uint16_t hash_res_mask; + /**< Mask that will be used on the hash-result; The + * number-of-sets for this hash will be calculated as (2^(number + * of bits set in 'hash_res_mask')); The 4 lower bits must be + * cleared. + */ + uint8_t hash_shift; + /**< Byte offset from the beginning of the KeyGen hash result to + * the 2-bytes to be used as hash index. + */ + uint8_t match_key_size; + /**< Size of the exact match keys held by the hash buckets */ + + ioc_fm_pcd_cc_next_engine_params_t cc_next_engine_params_for_miss; + /**< Parameters for defining the next engine when a key is not + * matched + */ +}; + +typedef struct ioc_fm_pcd_hash_table_params_t { + struct fm_pcd_hash_table_params_t param; + void *id; +} ioc_fm_pcd_hash_table_params_t; + +/* + * @Description A structure with the arguments for the + * fm_pcd_hash_table_add_key ioctl() call + */ +typedef struct ioc_fm_pcd_hash_table_add_key_params_t { + void *p_hash_tbl; + uint8_t key_size; + ioc_fm_pcd_cc_key_params_t key_params; +} ioc_fm_pcd_hash_table_add_key_params_t; + +/* + * @Description Parameters for defining a CC tree group. + * + * This structure defines a CC group in terms of NetEnv units and + * the action to be taken in each case. The unit_ids list must be + * given in order from low to high indices. + * ioc_fm_pcd_cc_next_engine_params_t is a list of + * 2^num_of_distinction_units structures where each defines the + * next action to be taken for each units combination. for + * example: num_of_distinction_units = 2 unit_ids = {1,3} + * next_engine_per_entries_in_grp[0] = + * ioc_fm_pcd_cc_next_engine_params_t for the case that unit 1 - + * not found; unit 3 - not found; + * next_engine_per_entries_in_grp[1] = + * ioc_fm_pcd_cc_next_engine_params_t for the case that unit 1 - + * not found; unit 3 - found; + * next_engine_per_entries_in_grp[2] = + * ioc_fm_pcd_cc_next_engine_params_t for the case that unit 1 - + * found; unit 3 - not found; + * next_engine_per_entries_in_grp[3] = + * ioc_fm_pcd_cc_next_engine_params_t for the case that unit 1 - + * found; unit 3 - found; + */ +typedef struct ioc_fm_pcd_cc_grp_params_t { + uint8_t num_of_distinction_units; /**< Up to 4 */ + uint8_t unit_ids[IOC_FM_PCD_MAX_NUM_OF_CC_UNITS]; + /**< Indexes of the units as defined in + * fm_pcd_net_env_characteristics_set() + */ + ioc_fm_pcd_cc_next_engine_params_t + next_engine_per_entries_in_grp[IOC_FM_PCD_MAX_CC_ENTRY_IN_GRP]; + /**< Maximum entries per group is 16 */ +} ioc_fm_pcd_cc_grp_params_t; + +/* + * @Description Parameters for defining the CC tree groups + * (Must match struct ioc_fm_pcd_cc_tree_params_t defined in + * fm_pcd_ext.h) + */ +typedef struct ioc_fm_pcd_cc_tree_params_t { + void *net_env_id; + /**< Id of the Network Environment as returned + * by fm_pcd_net_env_characteristics_set() + */ + uint8_t num_of_groups; + /**< Number of CC groups within the CC tree */ + ioc_fm_pcd_cc_grp_params_t + fm_pcd_cc_group_params[IOC_FM_PCD_MAX_NUM_OF_CC_GROUPS]; + /**< Parameters for each group. */ + void *id; + /**< Output parameter; Returns the tree Id to be used */ +} ioc_fm_pcd_cc_tree_params_t; + +/* + * @Description Parameters for defining policer byte rate + */ +typedef struct ioc_fm_pcd_plcr_byte_rate_mode_param_t { + ioc_fm_pcd_plcr_frame_length_select frame_length_selection; + /**< Frame length selection */ + ioc_fm_pcd_plcr_roll_back_frame_select roll_back_frame_selection; + /**< relevant option only e_IOC_FM_PCD_PLCR_L2_FRM_LEN, + * e_IOC_FM_PCD_PLCR_FULL_FRM_LEN + */ +} ioc_fm_pcd_plcr_byte_rate_mode_param_t; + +/* + * @Description Parameters for defining the policer profile (based on + * RFC-2698 or RFC-4115 attributes). + */ +typedef struct ioc_fm_pcd_plcr_non_passthrough_alg_param_t { + ioc_fm_pcd_plcr_rate_mode rate_mode; + /**< Byte / Packet */ + ioc_fm_pcd_plcr_byte_rate_mode_param_t byte_mode_param; + /**< Valid for Byte NULL for Packet */ + uint32_t committed_info_rate; + /**< KBits/Sec or Packets/Sec */ + uint32_t committed_burst_size; + /**< KBits or Packets */ + uint32_t peak_or_excess_info_rate; + /**< KBits/Sec or Packets/Sec */ + uint32_t peak_or_excess_burst_size; + /**< KBits or Packets */ +} ioc_fm_pcd_plcr_non_passthrough_alg_param_t; + +/* + * @Description Parameters for defining the next engine after policer + */ +typedef union ioc_fm_pcd_plcr_next_engine_params_u { + ioc_fm_pcd_done_action action; + /**< Action - when next engine is BMI (done) */ + void *p_profile; + /**< Policer profile handle - used when next + * engine is PLCR, must be a SHARED profile + */ + void *p_direct_scheme; + /**< Direct scheme select - when next engine is + * Keygen + */ +} ioc_fm_pcd_plcr_next_engine_params_u; + +typedef struct ioc_fm_pcd_port_params_t { + ioc_fm_port_type port_type; + /**< Type of port for this profile */ + uint8_t port_id; + /**< FM-Port id of port for this profile */ +} ioc_fm_pcd_port_params_t; + +/* + * @Description Parameters for defining the policer profile entry + * (Must match struct ioc_fm_pcd_plcr_profile_params_t defined in + * fm_pcd_ext.h) + */ +struct fm_pcd_plcr_profile_params_t { + bool modify; + /**< TRUE to change an existing profile */ + union { + struct { + ioc_fm_pcd_profile_type_selection profile_type; + /**< Type of policer profile */ + ioc_fm_pcd_port_params_t *p_fm_port; + /**< Relevant for per-port profiles only */ + uint16_t relative_profile_id; + /**< Profile id - relative to shared group or to + * port + */ + } new_params; + /**< Use it when modify = FALSE */ + void *p_profile; + /**< A handle to a profile - use it when modify=TRUE */ + } profile_select; + ioc_fm_pcd_plcr_algorithm_selection alg_selection; + /**< Profile Algorithm PASS_THROUGH, RFC_2698, RFC_4115 */ + ioc_fm_pcd_plcr_color_mode color_mode; + /**< COLOR_BLIND, COLOR_AWARE */ + + union { + ioc_fm_pcd_plcr_color dflt_color; + /**< For Color-Blind Pass-Through mode; the policer will + * re-color any incoming packet with the default value. + */ + ioc_fm_pcd_plcr_color override; + /**< For Color-Aware modes; the profile response to a pre-color + * value of 2'b11. + */ + } color; + + ioc_fm_pcd_plcr_non_passthrough_alg_param_t + non_passthrough_alg_param; + /**< RFC2698 or RFC4115 parameters */ + + ioc_fm_pcd_engine next_engine_on_green; + /**< Next engine for green-colored frames */ + ioc_fm_pcd_plcr_next_engine_params_u params_on_green; + /**< Next engine parameters for green-colored frames */ + + ioc_fm_pcd_engine next_engine_on_yellow; + /**< Next engine for yellow-colored frames */ + ioc_fm_pcd_plcr_next_engine_params_u params_on_yellow; + /**< Next engine parameters for yellow-colored frames */ + + ioc_fm_pcd_engine next_engine_on_red; + /**< Next engine for red-colored frames */ + ioc_fm_pcd_plcr_next_engine_params_u params_on_red; + /**< Next engine parameters for red-colored frames */ + + bool trap_profile_on_flow_A; + /**< Obsolete - do not use */ + bool trap_profile_on_flow_B; + /**< Obsolete - do not use */ + bool trap_profile_on_flow_C; + /**< Obsolete - do not use */ +}; + +typedef struct ioc_fm_pcd_plcr_profile_params_t { + struct fm_pcd_plcr_profile_params_t param; + void *id; + /**< output parameter; Returns the profile Id to be used */ +} ioc_fm_pcd_plcr_profile_params_t; + +/* + * @Description A structure for modifying CC tree next engine + */ +typedef struct ioc_fm_pcd_cc_tree_modify_next_engine_params_t { + void *id; + /**< CC tree Id to be used */ + uint8_t grp_indx; + /**< A Group index in the tree */ + uint8_t indx; + /**< Entry index in the group defined by grp_index */ + ioc_fm_pcd_cc_next_engine_params_t cc_next_engine_params; + /**< Parameters for the next for the defined Key in the + * p_key + */ +} ioc_fm_pcd_cc_tree_modify_next_engine_params_t; + +/* + * @Description A structure for modifying CC node next engine + */ +typedef struct ioc_fm_pcd_cc_node_modify_next_engine_params_t { + void *id; + /**< CC node Id to be used */ + uint16_t key_indx; + /**< Key index for Next Engine Params modifications; + * NOTE: This parameter is IGNORED for miss-key! + */ + uint8_t key_size; + /**< Key size of added key */ + ioc_fm_pcd_cc_next_engine_params_t cc_next_engine_params; + /**< parameters for the next for the defined Key in the + * p_key + */ +} ioc_fm_pcd_cc_node_modify_next_engine_params_t; + +/* + * @Description A structure for remove CC node key + */ +typedef struct ioc_fm_pcd_cc_node_remove_key_params_t { + void *id; + /**< CC node Id to be used */ + uint16_t key_indx; + /**< Key index for Next Engine Params modifications; + * NOTE: This parameter is IGNORED for miss-key! + */ +} ioc_fm_pcd_cc_node_remove_key_params_t; + +/* + * @Description A structure for modifying CC node key and next engine + */ +typedef struct ioc_fm_pcd_cc_node_modify_key_and_next_engine_params_t { + void *id; + /**< CC node Id to be used */ + uint16_t key_indx; + /**< Key index for Next Engine Params modifications; + * NOTE: This parameter is IGNORED for miss-key! + */ + uint8_t key_size; + /**< Key size of added key */ + ioc_fm_pcd_cc_key_params_t key_params; + /**< it's array with num_of_keys entries each entry in + * the array of the type ioc_fm_pcd_cc_key_params_t + */ +} ioc_fm_pcd_cc_node_modify_key_and_next_engine_params_t; + +/* + * @Description A structure for modifying CC node key + */ +typedef struct ioc_fm_pcd_cc_node_modify_key_params_t { + void *id; + /**< CC node Id to be used */ + uint16_t key_indx; + /**< Key index for Next Engine Params modifications; + * NOTE: This parameter is IGNORED for miss-key! + */ + uint8_t key_size; + /**< Key size of added key */ + uint8_t *p_key; + /**< Pointer to the key of the size defined in key_size + */ + uint8_t *p_mask; + /**< Pointer to the Mask per key of the size defined in + * key_size. p_key and p_mask (if defined) have to be of + * the same size as defined in the key_size + */ +} ioc_fm_pcd_cc_node_modify_key_params_t; + +/* + * @Description A structure with the arguments for the + * fm_pcd_hash_table_remove_key ioctl() call + */ +typedef struct ioc_fm_pcd_hash_table_remove_key_params_t { + void *p_hash_tbl; /**< The id of the hash table */ + uint8_t key_size; /**< The size of the key to remove */ + uint8_t *p_key; /**< Pointer to the key to remove */ +} ioc_fm_pcd_hash_table_remove_key_params_t; + +/* + * @Description Parameters for selecting a location for requested manipulation + */ +typedef struct ioc_fm_manip_hdr_info_t { + ioc_net_header_type hdr; /**< Header selection */ + ioc_fm_pcd_hdr_index hdr_index; + /**< Relevant only for MPLS, VLAN and tunneled IP. + * Otherwise should be cleared. + */ + bool by_field; + /**< TRUE if the location of manipulation is according + * to some field in the specific header + */ + ioc_fm_pcd_fields_u full_field; + /**< Relevant only when by_field = TRUE: Extract field + */ +} ioc_fm_manip_hdr_info_t; + +/* + * @Description Parameters for defining header removal by header type + */ +typedef struct ioc_fm_pcd_manip_hdr_rmv_by_hdr_params_t { + ioc_fm_pcd_manip_hdr_rmv_by_hdr_type type; + /**< Selection of header removal location */ + union { + ioc_fm_manip_hdr_info_t hdr_info; + /**< Relevant when type = e_FM_PCD_MANIP_RMV_BY_HDR_FROM_START + */ + ioc_fm_pcd_manip_hdr_rmv_specific_l2 specific_l2; + /**< Relevant when type = e_IOC_FM_PCD_MANIP_BY_HDR_SPECIFIC_L2; + * Defines which L2 headers to remove. + */ + } u; +} ioc_fm_pcd_manip_hdr_rmv_by_hdr_params_t; + +/* + * @Description Parameters for configuring IP fragmentation manipulation + */ +typedef struct ioc_fm_pcd_manip_frag_ip_params_t { + uint16_t size_for_fragmentation; + /**< If length of the frame is greater than this value, IP + * fragmentation will be executed. + */ + bool sg_bpid_en; + /**< Enable a dedicated buffer pool id for the Scatter/Gather + * buffer allocation; If disabled, the Scatter/Gather buffer + * will be allocated from the same pool as the received frame's + * buffer. + */ + uint8_t sg_bpid; + /**< Scatter/Gather buffer pool id; This parameter is relevant + * when 'sg_bpid_en=TRUE'; Same LIODN number is used for these + * buffers as for the received frames buffers, so buffers of + * this pool need to be allocated in the same memory area as the + * received buffers. If the received buffers arrive from + * different sources, the Scatter/Gather BP id should be mutual + * to all these sources. + */ + ioc_fm_pcd_manip_donot_frag_action donot_frag_action; + /**< Don't Fragment Action - If an IP packet is larger than MTU + * and its DF bit is set, then this field will determine the + * action to be taken. + */ +} ioc_fm_pcd_manip_frag_ip_params_t; + +/* + * @Description Parameters for configuring IP reassembly manipulation. + * + * This is a common structure for both IPv4 and IPv6 reassembly + * manipulation. For reassembly of both IPv4 and IPv6, make sure + * to set the 'hdr' field in ioc_fm_pcd_manip_reassem_params_t to + * IOC_header_type_ipv_6. + */ +typedef struct ioc_fm_pcd_manip_reassem_ip_params_t { + uint8_t relative_scheme_id[2]; + /**< Partition relative scheme id: relativeSchemeId[0] - + * Relative scheme ID for IPV4 Reassembly manipulation; + * relativeSchemeId[1] - Relative scheme ID for IPV6 + * Reassembly manipulation; NOTE: The following comment + * is relevant only for FMAN v2 devices: Relative scheme + * ID for IPv4/IPv6 Reassembly manipulation must be + * smaller than the user schemes id to ensure that the + * reassembly's schemes will be first match. The + * remaining schemes, if defined, should have higher + * relative scheme ID. + */ + uint32_t non_consistent_sp_fqid; + /**< In case that other fragments of the frame + * corresponds to different storage profile than the + * opening fragment (Non-Consistent-SP state) then one + * of two possible scenarios occurs: if + * 'nonConsistentSpFqid != 0', the reassembled frame + * will be enqueued to this fqid, otherwise a 'Non + * Consistent SP' bit will be set in the FD[status]. + */ + uint8_t data_mem_id; + /**< Memory partition ID for the IPR's external tables + * structure + */ + uint16_t data_liodn_offset; + /**< LIODN offset for access the IPR's external tables + * structure. + */ + uint16_t min_frag_size[2]; + /**< Minimum fragment size: minFragSize[0] - for ipv4, + * minFragSize[1] - for ipv6 + */ + ioc_fm_pcd_manip_reassem_ways_number num_of_frames_per_hash_entry[2]; + /**< Number of frames per hash entry needed for + * reassembly process: num_of_frames_per_hash_entry[0] - + * for ipv4 (max value is + * e_IOC_FM_PCD_MANIP_EIGHT_WAYS_HASH); + * num_of_frames_per_hash_entry[1] - for ipv6 (max value + * is e_IOC_FM_PCD_MANIP_SIX_WAYS_HASH). + */ + uint16_t max_num_frames_in_process; + /**< Number of frames which can be processed by + * Reassembly in the same time; Must be power of 2; In + * the case num_of_frames_per_hash_entry == + * e_IOC_FM_PCD_MANIP_FOUR_WAYS_HASH, + * max_num_frames_in_process has to be in the range of + * 4 - 512; In the case num_of_frames_per_hash_entry == + * e_IOC_FM_PCD_MANIP_EIGHT_WAYS_HASH, + * max_num_frames_in_process has to be in the range of + * 8 - 2048. + */ + ioc_fm_pcd_manip_reassem_time_out_mode time_out_mode; + /**< Expiration delay initialized by Reassembly process + */ + uint32_t fqid_for_time_out_frames; + /**< FQID in which time out frames will enqueue during + * Time Out Process + */ + uint32_t timeout_threshold_for_reassm_process; + /**< Represents the time interval in microseconds which + * defines if opened frame (at least one fragment was + * processed but not all the fragments)is found as too + * old + */ +} ioc_fm_pcd_manip_reassem_ip_params_t; + +/* + * @Description Parameters for defining IPSEC manipulation + */ +typedef struct ioc_fm_pcd_manip_special_offload_ipsec_params_t { + bool decryption; + /**< TRUE if being used in decryption direction; + * FALSE if being used in encryption direction. + */ + bool ecn_copy; + /**< TRUE to copy the ECN bits from inner/outer to + * outer/inner (direction depends on the 'decryption' + * field). + */ + bool dscp_copy; + /**< TRUE to copy the DSCP bits from inner/outer to + * outer/inner (direction depends on the 'decryption' + * field). + */ + bool variable_ip_hdr_len; + /**< TRUE for supporting variable IP header length in + * decryption. + */ + bool variable_ip_version; + /**< TRUE for supporting both IP version on the same SA + * in encryption + */ + uint8_t outer_ip_hdr_len; + /**< If 'variable_ip_version == TRUE' than this field + * must be set to non-zero value; It is specifies the + * length of the outer IP header that was configured in + * the corresponding SA. + */ + uint16_t arw_size; + /**< if <> '0' then will perform ARW check for this SA; + * The value must be a multiplication of 16 + */ + void *arw_addr; + /**< if arwSize <> '0' then this field must be set to + * non-zero value; MUST be allocated from FMAN's MURAM + * that the post-sec op-port belong Must be 4B aligned. + * Required MURAM size is + * '(NEXT_POWER_OF_2(arwSize+32))/8+4' Bytes + */ +} ioc_fm_pcd_manip_special_offload_ipsec_params_t; + +/* + * @Description Parameters for configuring CAPWAP fragmentation manipulation + * + * Restrictions: + * - Maximum number of fragments per frame is 16. + * - Transmit confirmation is not supported. + * - Fragmentation nodes must be set as the last PCD action (i.e. + * the corresponding CC node key must have next engine set to + * e_FM_PCD_DONE). + * - Only BMan buffers shall be used for frames to be fragmented. + * - NOTE: The following comment is relevant only for FMAN v3 + * devices: IPF does not support VSP. Therefore, on the same + * port where we have IPF we cannot support VSP. + */ +typedef struct ioc_fm_pcd_manip_frag_capwap_params_t { + uint16_t size_for_fragmentation; + /**< If length of the frame is greater than this value, + * CAPWAP fragmentation will be executed. + */ + bool sg_bpid_en; + /**< Enable a dedicated buffer pool id for the + * Scatter/Gather buffer allocation; If disabled, the + * Scatter/Gather buffer will be allocated from the same + * pool as the received frame's buffer. + */ + uint8_t sg_bpid; + /**< Scatter/Gather buffer pool id; This parameters is + * relevant when 'sg_bpidEn=TRUE'; Same LIODN number is + * used for these buffers as for the received frames + * buffers, so buffers of this pool need to be allocated + * in the same memory area as the received buffers. If + * the received buffers arrive from different sources, + * the Scatter/Gather BP id should be mutual to all + * these sources. + */ + bool compress_mode_en; + /**< CAPWAP Header Options Compress Enable mode; When + * this mode is enabled then only the first fragment + * include the CAPWAP header options field (if user + * provides it in the input frame) and all other + * fragments exclude the CAPWAP options field (CAPWAP + * header is updated accordingly). + */ +} ioc_fm_pcd_manip_frag_capwap_params_t; + +/* + * @Description Parameters for configuring CAPWAP reassembly manipulation. + * + * Restrictions: + * - Application must define one scheme to catch the reassembled + * frames. + * - Maximum number of fragments per frame is 16. + */ +typedef struct ioc_fm_pcd_manip_reassem_capwap_params_t { + uint8_t relative_scheme_id; + /**< Partition relative scheme id; NOTE: this id must be + * smaller than the user schemes id to ensure that the + * reassembly scheme will be first match; Rest schemes, + * if defined, should have higher relative scheme ID. + */ + uint8_t data_mem_id; + /**< Memory partition ID for the IPR's external tables + * structure + */ + uint16_t data_liodn_offset; + /**< LIODN offset for access the IPR's external tables + * structure. + */ + uint16_t max_reassembled_frame_length; + /**< The maximum CAPWAP reassembled frame length in + * bytes; If maxReassembledFrameLength == 0, any + * successful reassembled frame length is considered as + * a valid length; if maxReassembledFrameLength > 0, a + * successful reassembled frame which its length exceeds + * this value is considered as an error frame (FD + * status[CRE] bit is set). + */ + ioc_fm_pcd_manip_reassem_ways_number num_of_frames_per_hash_entry; + /**< Number of frames per hash entry needed for + * reassembly process + */ + uint16_t max_num_frames_in_process; + /**< Number of frames which can be processed by + * reassembly in the same time; Must be power of 2; In + * the case num_of_frames_per_hash_entry == + * e_FM_PCD_MANIP_FOUR_WAYS_HASH, + * max_num_frames_in_process has to be in the range of + * 4 - 512; In the case num_of_frames_per_hash_entry == + * e_FM_PCD_MANIP_EIGHT_WAYS_HASH, + * max_num_frames_in_process has to be in the range of + * 8 - 2048. + */ + ioc_fm_pcd_manip_reassem_time_out_mode time_out_mode; + /**< Expiration delay initialized by Reassembly process + */ + uint32_t fqid_for_time_out_frames; + /**< FQID in which time out frames will enqueue during + * Time Out Process; Recommended value for this field is + * 0; in this way timed-out frames will be discarded + */ + uint32_t timeout_threshold_for_reassm_process; + /**< Represents the time interval in microseconds which + * defines if opened frame (at least one fragment was + * processed but not all the fragments)is found as too + * old + */ +} ioc_fm_pcd_manip_reassem_capwap_params_t; + +/* + * @Description structure for defining CAPWAP manipulation + */ +typedef struct ioc_fm_pcd_manip_special_offload_capwap_params_t { + bool dtls; + /**< TRUE if continue to SEC DTLS encryption */ + ioc_fm_pcd_manip_hdr_qos_src qos_src; + /**< TODO */ +} ioc_fm_pcd_manip_special_offload_capwap_params_t; + +/* + * @Description Parameters for defining special offload manipulation + */ +typedef struct ioc_fm_pcd_manip_special_offload_params_t { + ioc_fm_pcd_manip_special_offload_type type; + /**< Type of special offload manipulation */ + union { + ioc_fm_pcd_manip_special_offload_ipsec_params_t ipsec; + /**< Parameters for IPSec; Relevant when type = + * e_IOC_FM_PCD_MANIP_SPECIAL_OFFLOAD_IPSEC + */ + + ioc_fm_pcd_manip_special_offload_capwap_params_t capwap; + /**< Parameters for CAPWAP; Relevant when type = + * e_FM_PCD_MANIP_SPECIAL_OFFLOAD_CAPWAP + */ + } u; +} ioc_fm_pcd_manip_special_offload_params_t; + +/* + * @Description Parameters for defining generic removal manipulation + */ +typedef struct ioc_fm_pcd_manip_hdr_rmv_generic_params_t { + uint8_t offset; + /**< Offset from beginning of header to the start location of + * the removal + */ + uint8_t size; /**< Size of removed section */ +} ioc_fm_pcd_manip_hdr_rmv_generic_params_t; + +/* + * @Description Parameters for defining insertion manipulation + */ +typedef struct ioc_fm_pcd_manip_hdr_insrt_t { + uint8_t size; /**< size of inserted section */ + uint8_t *p_data; /**< data to be inserted */ +} ioc_fm_pcd_manip_hdr_insrt_t; + +/* + * @Description Parameters for defining generic insertion manipulation + */ +typedef struct ioc_fm_pcd_manip_hdr_insrt_generic_params_t { + uint8_t offset; + /**< Offset from beginning of header to the start + * location of the insertion + */ + uint8_t size; /**< Size of inserted section */ + bool replace; + /**< TRUE to override (replace) existing data at + * 'offset', FALSE to insert + */ + uint8_t *p_data; + /**< Pointer to data to be inserted */ +} ioc_fm_pcd_manip_hdr_insrt_generic_params_t; + +/* + * @Description Parameters for defining header manipulation VLAN DSCP To Vpri + * translation + */ +typedef struct ioc_fm_pcd_manip_hdr_field_update_vlan_dscp_to_vpri_t { + uint8_t dscp_to_vpri_table[IOC_FM_PCD_MANIP_DSCP_TO_VLAN_TRANS]; + /**< A table of VPri values for each DSCP value; The index is + * the D_SCP value (0-0x3F) and the value is the corresponding + * VPRI (0-15). + */ + uint8_t vpri_def_val; + /**< 0-7, Relevant only if if update_type = + * e_IOC_FM_PCD_MANIP_HDR_FIELD_UPDATE_DSCP_TO_VLAN, this field + * is the Q Tag default value if the IP header is not found. + */ +} ioc_fm_pcd_manip_hdr_field_update_vlan_dscp_to_vpri_t; + +/* + * @Description Parameters for defining header manipulation VLAN fields + * updates + */ +typedef struct ioc_fm_pcd_manip_hdr_field_update_vlan_t { + ioc_fm_pcd_manip_hdr_field_update_vlan update_type; + /**< Selects VLAN update type */ + union { + uint8_t vpri; + /**< 0-7, Relevant only if If update_type = + * e_IOC_FM_PCD_MANIP_HDR_FIELD_UPDATE_VLAN_PRI, this is the new + * VLAN pri. + */ + ioc_fm_pcd_manip_hdr_field_update_vlan_dscp_to_vpri_t dscp_to_vpri; + /**< Parameters structure, Relevant only if update_type = + * e_IOC_FM_PCD_MANIP_HDR_FIELD_UPDATE_DSCP_TO_VLAN. + */ + } u; +} ioc_fm_pcd_manip_hdr_field_update_vlan_t; + +/* + * @Description Parameters for defining header manipulation IPV4 fields + * updates + */ +typedef struct ioc_fm_pcd_manip_hdr_field_update_ipv4_t { + ioc_ipv4_hdr_manip_update_flags_t valid_updates; + /**< ORed flag, selecting the required updates */ + uint8_t tos; + /**< 8 bit New TOS; Relevant if valid_updates contains + * IOC_HDR_MANIP_IPV4_TOS + */ + uint16_t id; + /**< 16 bit New IP ID; Relevant only if + * valid_updates contains IOC_HDR_MANIP_IPV4_ID + */ + uint32_t src; + /**< 32 bit New IP SRC; Relevant only if + * valid_updates contains IOC_HDR_MANIP_IPV4_SRC + */ + uint32_t dst; + /**< 32 bit New IP DST; Relevant only if + * valid_updates contains IOC_HDR_MANIP_IPV4_DST + */ +} ioc_fm_pcd_manip_hdr_field_update_ipv4_t; + +/* + * @Description Parameters for defining header manipulation IPV6 fields + * updates + */ +typedef struct ioc_fm_pcd_manip_hdr_field_update_ipv6_t { + ioc_ipv6_hdr_manip_update_flags_t valid_updates; + /**< ORed flag, selecting the required updates */ + uint8_t traffic_class; + /**< 8 bit New Traffic Class; Relevant if valid_updates + * contains IOC_HDR_MANIP_IPV6_TC + */ + uint8_t src[ioc_net_hf_ipv6_addr_size]; + /**< 16 byte new IP SRC; Relevant only if valid_updates + * contains IOC_HDR_MANIP_IPV6_SRC + */ + uint8_t dst[ioc_net_hf_ipv6_addr_size]; + /**< 16 byte new IP DST; Relevant only if valid_updates + * contains IOC_HDR_MANIP_IPV6_DST + */ +} ioc_fm_pcd_manip_hdr_field_update_ipv6_t; + +/* + * @Description Parameters for defining header manipulation TCP/UDP fields + * updates + */ +typedef struct ioc_fm_pcd_manip_hdr_field_update_tcp_udp_t { + ioc_tcp_udp_hdr_manip_update_flags_t valid_updates; + /**< ORed flag, selecting the required updates */ + uint16_t src; + /**< 16 bit New TCP/UDP SRC; Relevant only if + * valid_updates contains IOC_HDR_MANIP_TCP_UDP_SRC + */ + uint16_t dst; + /**< 16 bit New TCP/UDP DST; Relevant only if + * valid_updates contains IOC_HDR_MANIP_TCP_UDP_DST + */ +} ioc_fm_pcd_manip_hdr_field_update_tcp_udp_t; + +/* + * @Description Parameters for defining header manipulation fields updates + */ +typedef struct ioc_fm_pcd_manip_hdr_field_update_params_t { + ioc_fm_pcd_manip_hdr_field_update_type type; + /**< Type of header field update manipulation */ + union { + ioc_fm_pcd_manip_hdr_field_update_vlan_t vlan; + /**< Parameters for VLAN update. Relevant when type = + * e_IOC_FM_PCD_MANIP_HDR_FIELD_UPDATE_VLAN + */ + ioc_fm_pcd_manip_hdr_field_update_ipv4_t ipv4; + /**< Parameters for IPv4 update. Relevant when type = + * e_IOC_FM_PCD_MANIP_HDR_FIELD_UPDATE_IPV4 + */ + ioc_fm_pcd_manip_hdr_field_update_ipv6_t ipv6; + /**< Parameters for IPv6 update. Relevant when type = + * e_IOC_FM_PCD_MANIP_HDR_FIELD_UPDATE_IPV6 + */ + ioc_fm_pcd_manip_hdr_field_update_tcp_udp_t tcp_udp; + /**< Parameters for TCP/UDP update. Relevant when type = + * e_IOC_FM_PCD_MANIP_HDR_FIELD_UPDATE_TCP_UDP + */ + } u; +} ioc_fm_pcd_manip_hdr_field_update_params_t; + +/* + * @Description Parameters for defining custom header manipulation for IP + * replacement + */ +typedef struct ioc_fm_pcd_manip_hdr_custom_ip_hdr_replace_t { + ioc_fm_pcd_manip_hdr_custom_ip_replace replace_type; + /**< Selects replace update type */ + bool dec_ttl_hl; + /**< Decrement TTL (IPV4) or Hop limit (IPV6) by 1 */ + bool update_ipv4_id; + /**< Relevant when replace_type = + * e_IOC_FM_PCD_MANIP_HDR_CUSTOM_REPLACE_IPV6_BY_IPV4 + */ + uint16_t id; + /**< 16 bit New IP ID; Relevant only if update_ipv4_id = TRUE */ + uint8_t hdr_size; + /**< The size of the new IP header */ + uint8_t hdr[IOC_FM_PCD_MANIP_MAX_HDR_SIZE]; + /**< The new IP header */ +} ioc_fm_pcd_manip_hdr_custom_ip_hdr_replace_t; + +/* + * @Description Parameters for defining custom header manipulation + */ +typedef struct ioc_fm_pcd_manip_hdr_custom_params_t { + ioc_fm_pcd_manip_hdr_custom_type type; + /**< Type of header field update manipulation */ + union { + ioc_fm_pcd_manip_hdr_custom_ip_hdr_replace_t ip_hdr_replace; + /**< Parameters IP header replacement */ + } u; +} ioc_fm_pcd_manip_hdr_custom_params_t; + +/* + * @Description Parameters for defining specific L2 insertion manipulation + */ +typedef struct ioc_fm_pcd_manip_hdr_insrt_specific_l2_params_t { + ioc_fm_pcd_manip_hdr_insrt_specific_l2 specific_l2; + /**< Selects which L2 headers to insert */ + bool update; + /**< TRUE to update MPLS header */ + uint8_t size; + /**< size of inserted section */ + uint8_t *p_data; + /**< data to be inserted */ +} ioc_fm_pcd_manip_hdr_insrt_specific_l2_params_t; + +/* + * @Description Parameters for defining IP insertion manipulation + */ +typedef struct ioc_fm_pcd_manip_hdr_insrt_ip_params_t { + bool calc_l4_checksum; + /**< Calculate L4 checksum. */ + ioc_fm_pcd_manip_hdr_qos_mapping_mode mapping_mode; + /**< TODO */ + uint8_t last_pid_offset; + /**< the offset of the last Protocol within the inserted + * header + */ + uint16_t id; /**< 16 bit New IP ID */ + bool donot_frag_overwrite; + /**< IPv4 only. DF is overwritten with the hash-result + * next-to-last byte. This byte is configured to be + * overwritten when RPD is set. + */ + uint8_t last_dst_offset; + /**< IPv6 only. if routing extension exist, user should + * set the offset of the destination address in order + * to calculate UDP checksum pseudo header; Otherwise + * set it to '0'. + */ + ioc_fm_pcd_manip_hdr_insrt_t insrt; + /**< size and data to be inserted. */ +} ioc_fm_pcd_manip_hdr_insrt_ip_params_t; + +/* + * @Description Parameters for defining header insertion manipulation by + * header type + */ +typedef struct ioc_fm_pcd_manip_hdr_insrt_by_hdr_params_t { + ioc_fm_pcd_manip_hdr_insrt_by_hdr_type type; + /**< Selects manipulation type */ + union { + ioc_fm_pcd_manip_hdr_insrt_specific_l2_params_t specific_l2_params; + /**< Used when type = + * e_IOC_FM_PCD_MANIP_INSRT_BY_HDR_SPECIFIC_L2: Selects + * which L2 headers to remove + */ + ioc_fm_pcd_manip_hdr_insrt_ip_params_t ip_params; + /**< Used when type = e_FM_PCD_MANIP_INSRT_BY_HDR_IP */ + ioc_fm_pcd_manip_hdr_insrt_t insrt; + /**< Used when type is one of + * e_FM_PCD_MANIP_INSRT_BY_HDR_UDP, + * e_FM_PCD_MANIP_INSRT_BY_HDR_UDP_LITE, or + * e_FM_PCD_MANIP_INSRT_BY_HDR_CAPWAP + */ + } u; +} ioc_fm_pcd_manip_hdr_insrt_by_hdr_params_t; + +/* + * @Description Parameters for defining header insertion manipulation + */ +typedef struct ioc_fm_pcd_manip_hdr_insrt_params_t { + ioc_fm_pcd_manip_hdr_insrt_type type; + /**< Type of insertion manipulation */ + union { + ioc_fm_pcd_manip_hdr_insrt_by_hdr_params_t by_hdr; + /**< Parameters for defining header insertion + * manipulation by header type, relevant if 'type' = + * e_IOC_FM_PCD_MANIP_INSRT_BY_HDR + */ + ioc_fm_pcd_manip_hdr_insrt_generic_params_t generic; + /**< Parameters for defining generic header insertion + * manipulation, relevant if type = + * e_IOC_FM_PCD_MANIP_INSRT_GENERIC + */ + } u; +} ioc_fm_pcd_manip_hdr_insrt_params_t; + +/* + * @Description Parameters for defining header removal manipulation + */ +typedef struct ioc_fm_pcd_manip_hdr_rmv_params_t { + ioc_fm_pcd_manip_hdr_rmv_type type; + /**< Type of header removal manipulation */ + union { + ioc_fm_pcd_manip_hdr_rmv_by_hdr_params_t by_hdr; + /**< Parameters for defining header removal manipulation + * by header type, relevant if type = + * e_IOC_FM_PCD_MANIP_RMV_BY_HDR + */ + ioc_fm_pcd_manip_hdr_rmv_generic_params_t generic; + /**< Parameters for defining generic header removal + * manipulation, relevant if type = + * e_IOC_FM_PCD_MANIP_RMV_GENERIC + */ + } u; +} ioc_fm_pcd_manip_hdr_rmv_params_t; + +/* + * @Description Parameters for defining header manipulation node + */ +typedef struct ioc_fm_pcd_manip_hdr_params_t { + bool rmv; + /**< TRUE, to define removal manipulation */ + ioc_fm_pcd_manip_hdr_rmv_params_t rmv_params; + /**< Parameters for removal manipulation, relevant if + * 'rmv' = TRUE + */ + + bool insrt; + /**< TRUE, to define insertion manipulation */ + ioc_fm_pcd_manip_hdr_insrt_params_t insrt_params; + /**< Parameters for insertion manipulation, relevant if + * 'insrt' = TRUE + */ + + bool field_update; + /**< TRUE, to define field update manipulation */ + ioc_fm_pcd_manip_hdr_field_update_params_t field_update_params; + /**< Parameters for field update manipulation, relevant + * if 'fieldUpdate' = TRUE + */ + + bool custom; + /**< TRUE, to define custom manipulation */ + ioc_fm_pcd_manip_hdr_custom_params_t custom_params; + /**< Parameters for custom manipulation, relevant if + * 'custom' = TRUE + */ + + bool donot_parse_after_manip; + /**< FALSE to activate the parser a second time after + * completing the manipulation on the frame + */ +} ioc_fm_pcd_manip_hdr_params_t; + +/* + * @Description structure for defining fragmentation manipulation + */ +typedef struct ioc_fm_pcd_manip_frag_params_t { + ioc_net_header_type hdr; + /**< Header selection */ + union { + ioc_fm_pcd_manip_frag_capwap_params_t capwap_frag; + /**< Parameters for defining CAPWAP fragmentation, + * relevant if 'hdr' = HEADER_TYPE_CAPWAP + */ + ioc_fm_pcd_manip_frag_ip_params_t ip_frag; + /**< Parameters for defining IP fragmentation, relevant + * if 'hdr' = HEADER_TYPE_Ipv4 or HEADER_TYPE_Ipv6 + */ + } u; +} ioc_fm_pcd_manip_frag_params_t; + +/* + * @Description structure for defining reassemble manipulation + */ +typedef struct ioc_fm_pcd_manip_reassem_params_t { + ioc_net_header_type hdr; + /**< Header selection */ + union { + ioc_fm_pcd_manip_reassem_capwap_params_t capwap_reassem; + /**< Parameters for defining CAPWAP reassembly, relevant + * if 'hdr' = HEADER_TYPE_CAPWAP + */ + ioc_fm_pcd_manip_reassem_ip_params_t ip_reassem; + /**< Parameters for defining IP reassembly, relevant if + * 'hdr' = HEADER_TYPE_Ipv4 or HEADER_TYPE_Ipv6 + */ + } u; +} ioc_fm_pcd_manip_reassem_params_t; + +/* + * @Description Parameters for defining a manipulation node + */ +struct fm_pcd_manip_params_t { + ioc_fm_pcd_manip_type type; + /**< Selects type of manipulation node */ + union { + ioc_fm_pcd_manip_hdr_params_t hdr; + /**< Parameters for defining header manipulation node */ + ioc_fm_pcd_manip_reassem_params_t reassem; + /**< Parameters for defining reassembly manipulation + * node + */ + ioc_fm_pcd_manip_frag_params_t frag; + /**< Parameters for defining fragmentation manipulation + * node + */ + ioc_fm_pcd_manip_special_offload_params_t special_offload; + /**< Parameters for defining special offload + * manipulation node + */ + } u; + void *p_next_manip; + /**< Handle to another (previously defined) manipulation node; + * Allows concatenation of manipulation actions. This parameter + * is optional and may be NULL. + */ +}; + +typedef struct ioc_fm_pcd_manip_params_t { + struct fm_pcd_manip_params_t param; + void *id; +} ioc_fm_pcd_manip_params_t; + +/* + * @Description Structure for retrieving IP reassembly statistics + */ +typedef struct ioc_fm_pcd_manip_reassem_ip_stats_t { + /* common counters for both IPv4 and IPv6 */ + uint32_t timeout; + /**< Counts the number of TimeOut occurrences */ + uint32_t rfd_pool_busy; + /**< Counts the number of failed attempts to allocate a + * Reassembly Frame Descriptor + */ + uint32_t internal_buffer_busy; + /**< Counts the number of times an internal buffer busy occurred + */ + uint32_t external_buffer_busy; + /**< Counts the number of times external buffer busy occurred */ + uint32_t sg_fragments; + /**< Counts the number of Scatter/Gather fragments */ + uint32_t dma_semaphore_depletion; + /**< Counts the number of failed attempts to allocate a DMA + * semaphore + */ + uint32_t non_consistent_sp; + /**< Counts the number of Non Consistent Storage Profile events + * for successfully reassembled frames + */ +struct { + uint32_t successfully_reassembled; + /**< Counts the number of successfully reassembled frames */ + uint32_t valid_fragments; + /**< Counts the total number of valid fragments that have been + * processed for all frames + */ + uint32_t processed_fragments; + /**< Counts the number of processed fragments (valid and error + * fragments) for all frames + */ + uint32_t malformed_fragments; + /**< Counts the number of malformed fragments processed for all + * frames + */ + uint32_t discarded_fragments; + /**< Counts the number of fragments discarded by the reassembly + * process + */ + uint32_t auto_learn_busy; + /**< Counts the number of times a busy condition occurs when + * attempting to access an IP-Reassembly Automatic Learning Hash + * set + */ + uint32_t more_than16fragments; + /**< Counts the fragment occurrences in which the number of + * fragments-per-frame exceeds 16 + */ + } specific_hdr_statistics[2]; + /**< slot '0' is for IPv4, slot '1' is for IPv6 */ +} ioc_fm_pcd_manip_reassem_ip_stats_t; + +/* + * @Description Structure for retrieving IP fragmentation statistics + */ +typedef struct ioc_fm_pcd_manip_frag_ip_stats_t { + uint32_t total_frames; + /**< Number of frames that passed through the + * manipulation node + */ + uint32_t fragmented_frames; + /**< Number of frames that were fragmented */ + uint32_t generated_fragments; + /**< Number of fragments that were generated */ +} ioc_fm_pcd_manip_frag_ip_stats_t; + +/* + * @Description Structure for retrieving CAPWAP reassembly statistics + */ +typedef struct ioc_fm_pcd_manip_reassem_capwap_stats_t { + uint32_t timeout; + /**< Counts the number of timeout occurrences */ + uint32_t rfd_pool_busy; + /**< Counts the number of failed attempts to allocate a + * Reassembly Frame Descriptor + */ + uint32_t internal_buffer_busy; + /**< Counts the number of times an internal buffer busy + * occurred + */ + uint32_t external_buffer_busy; + /**< Counts the number of times external buffer busy + * occurred + */ + uint32_t sg_fragments; + /**< Counts the number of Scatter/Gather fragments */ + uint32_t dma_semaphore_depletion; + /**< Counts the number of failed attempts to allocate a + * DMA semaphore + */ + uint32_t successfully_reassembled; + /**< Counts the number of successfully reassembled + * frames + */ + uint32_t valid_fragments; + /**< Counts the total number of valid fragments that + * have been processed for all frames + */ + uint32_t processed_fragments; + /**< Counts the number of processed fragments (valid and + * error fragments) for all frames + */ + uint32_t malformed_fragments; + /**< Counts the number of malformed fragments processed + * for all frames + */ + uint32_t auto_learn_busy; + /**< Counts the number of times a busy condition occurs + * when attempting to access an Reassembly Automatic + * Learning Hash set + */ + uint32_t discarded_fragments; + /**< Counts the number of fragments discarded by the + * reassembly process + */ + uint32_t more_than16fragments; + /**< Counts the fragment occurrences in which the number + * of fragments-per-frame exceeds 16 + */ + uint32_t exceed_max_reassembly_frame_len; + /**< ounts the number of times that a successful + * reassembled frame length exceeds + * MaxReassembledFrameLength value + */ +} ioc_fm_pcd_manip_reassem_capwap_stats_t; + +/* + * @Description Structure for retrieving CAPWAP fragmentation statistics + */ +typedef struct ioc_fm_pcd_manip_frag_capwap_stats_t { + uint32_t total_frames; + /**< Number of frames that passed through the + * manipulation node + */ + uint32_t fragmented_frames; + /**< Number of frames that were fragmented */ + uint32_t generated_fragments; + /**< Number of fragments that were generated */ +#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0)) + uint8_t sg_allocation_failure; + /**< Number of allocation failure of s/g buffers */ +#endif /* (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0)) */ +} ioc_fm_pcd_manip_frag_capwap_stats_t; + +/* + * @Description Structure for retrieving reassembly statistics + */ +typedef struct ioc_fm_pcd_manip_reassem_stats_t { + union { + ioc_fm_pcd_manip_reassem_ip_stats_t ip_reassem; + /**< Structure for IP reassembly statistics */ + ioc_fm_pcd_manip_reassem_capwap_stats_t capwap_reassem; + /**< Structure for CAPWAP reassembly statistics */ + } u; +} ioc_fm_pcd_manip_reassem_stats_t; + +/* + * @Description structure for retrieving fragmentation statistics + */ +typedef struct ioc_fm_pcd_manip_frag_stats_t { + union { + ioc_fm_pcd_manip_frag_ip_stats_t ip_frag; + /**< Structure for IP fragmentation statistics */ + ioc_fm_pcd_manip_frag_capwap_stats_t capwap_frag; + /**< Structure for CAPWAP fragmentation statistics */ + } u; +} ioc_fm_pcd_manip_frag_stats_t; + +/* + * @Description structure for defining manipulation statistics + */ +typedef struct ioc_fm_pcd_manip_stats_t { + union { + ioc_fm_pcd_manip_reassem_stats_t reassem; + /**< Structure for reassembly statistics */ + ioc_fm_pcd_manip_frag_stats_t frag; + /**< Structure for fragmentation statistics */ + } u; +} ioc_fm_pcd_manip_stats_t; + +/* + * @Description Parameters for acquiring manipulation statistics + */ +typedef struct ioc_fm_pcd_manip_get_stats_t { + void *id; + ioc_fm_pcd_manip_stats_t stats; +} ioc_fm_pcd_manip_get_stats_t; + +/* + * @Description Parameters for defining frame replicator group and its members + */ +struct fm_pcd_frm_replic_group_params_t { + uint8_t max_num_of_entries; + /**< Maximal number of members in the group - + * must be at least two + */ + uint8_t num_of_entries; + /**< Number of members in the group - must be at + * least 1 + */ + ioc_fm_pcd_cc_next_engine_params_t + next_engine_params[IOC_FM_PCD_FRM_REPLIC_MAX_NUM_OF_ENTRIES]; + /**< Array of members' parameters */ +}; + +typedef struct ioc_fm_pcd_frm_replic_group_params_t { + struct fm_pcd_frm_replic_group_params_t param; + void *id; +} ioc_fm_pcd_frm_replic_group_params_t; + +typedef struct ioc_fm_pcd_frm_replic_member_t { + void *h_replic_group; + uint16_t member_index; +} ioc_fm_pcd_frm_replic_member_t; + +typedef struct ioc_fm_pcd_frm_replic_member_params_t { + ioc_fm_pcd_frm_replic_member_t member; + ioc_fm_pcd_cc_next_engine_params_t next_engine_params; +} ioc_fm_pcd_frm_replic_member_params_t; + + +typedef struct ioc_fm_pcd_cc_key_statistics_t { + uint32_t byte_count; + /**< This counter reflects byte count of frames that + * were matched by this key. + */ + uint32_t frame_count; + /**< This counter reflects count of frames that were + * matched by this key. + */ + uint32_t frame_length_range_count[IOC_FM_PCD_CC_STATS_MAX_FLR]; + /**< These counters reflect how many frames matched this + * key in 'RMON' statistics mode: Each counter holds the + * number of frames of a specific frames length range, + * according to the ranges provided at initialization. + */ +} ioc_fm_pcd_cc_key_statistics_t; + + +typedef struct ioc_fm_pcd_cc_tbl_get_stats_t { + void *id; + uint16_t key_index; + ioc_fm_pcd_cc_key_statistics_t statistics; +} ioc_fm_pcd_cc_tbl_get_stats_t; + +/* + * @Function fm_pcd_match_table_get_key_statistics + * + * @Description This routine may be used to get statistics counters of + * specific key in a CC Node. + * + * If 'e_FM_PCD_CC_STATS_MODE_FRAME' and + * 'e_FM_PCD_CC_STATS_MODE_BYTE_AND_FRAME' were set for this + * node, these counters reflect how many frames passed that were + * matched this key; The total frames count will be returned in + * the counter of the first range (as only one frame length range + * was defined). If 'e_FM_PCD_CC_STATS_MODE_RMON' was set for + * this node, the total frame count will be separated to frame + * length counters, based on provided frame length ranges. + * + * @Param[in] h_cc_node A handle to the node + * @Param[in] key_index Key index for adding + * @Param[out] p_key_statistics Key statistics counters + * + * @Return The specific key statistics. + * + * @Cautions Allowed only following fm_pcd_match_table_set(). + */ +#define FM_PCD_IOC_MATCH_TABLE_GET_KEY_STAT \ + _IOWR(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(12), \ + ioc_fm_pcd_cc_tbl_get_stats_t) + +/* + * @Function fm_pcd_match_table_get_miss_statistics + * + * @Description This routine may be used to get statistics counters of miss + * entry in a CC Node. + * + * If 'e_FM_PCD_CC_STATS_MODE_FRAME' and + * 'e_FM_PCD_CC_STATS_MODE_BYTE_AND_FRAME' were set for this + * node, these counters reflect how many frames were not matched + * to any existing key and therefore passed through the miss + * entry; The total frames count will be returned in the counter + * of the first range (as only one frame length range was + * defined). + * + * @Param[in] h_cc_node A handle to the node + * @Param[out] p_miss_statistics Statistics counters for 'miss' + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_pcd_match_table_set(). + */ + +#define FM_PCD_IOC_MATCH_TABLE_GET_MISS_STAT \ + _IOWR(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(13), \ + ioc_fm_pcd_cc_tbl_get_stats_t) + +/* + * @Function fm_pcd_hash_table_get_miss_statistics + * + * @Description This routine may be used to get statistics counters of 'miss' + * entry of the a hash table. + * + * If 'e_FM_PCD_CC_STATS_MODE_FRAME' and + * 'e_FM_PCD_CC_STATS_MODE_BYTE_AND_FRAME' were set for this + * node, these counters reflect how many frames were not matched + * to any existing key and therefore passed through the miss + * entry; + * + * @Param[in] h_hash_tbl A handle to a hash table + * @Param[out] p_miss_statistics Statistics counters for 'miss' + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_pcd_hash_table_set(). + */ +#define FM_PCD_IOC_HASH_TABLE_GET_MISS_STAT \ + _IOWR(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(14), \ + ioc_fm_pcd_cc_tbl_get_stats_t) + +/* + * @Function fm_pcd_net_env_characteristics_set + * + * @Description Define a set of Network Environment Characteristics. + * + * When setting an environment it is important to understand its + * application. It is not meant to describe the flows that will + * run on the ports using this environment, but what the user + * means TO DO with the PCD mechanisms in order to + * parse-classify-distribute those frames. + * By specifying a distinction unit, the user means it would use + * that option for distinction between frames at either a KeyGen + * scheme or a coarse classification action descriptor. Using + * interchangeable headers to define a unit means that the user + * is indifferent to which of the interchangeable headers is + * present in the frame, and wants the distinction to be based on + * the presence of either one of them. + * + * Depending on context, there are limitations to the use of + * environments. A port using the PCD functionality is bound to + * an environment. Some or even all ports may share an + * environment but also an environment per port is possible. When + * initializing a scheme, a classification plan group (see + * below), or a coarse classification tree, one of the + * initialized environments must be stated and related to. When a + * port is bound to a scheme, a classification plan group, or a + * coarse classification tree, it MUST be bound to the same + * environment. + * + * The different PCD modules, may relate (for flows definition) + * ONLY on distinction units as defined by their environment. + * When initializing a scheme for example, it may not choose to + * select IPV4 as a match for recognizing flows unless it was + * defined in the relating environment. In fact, to guide the + * user through the configuration of the PCD, each module's + * characterization in terms of flows is not done using protocol + * names, but using environment indexes. + * + * In terms of HW implementation, the list of distinction units + * sets the LCV vectors and later used for match vector, + * classification plan vectors and coarse classification + * indexing. + * + * @Param[in,out] ioc_fm_pcd_net_env_params_t A structure defining the + * distinction units for this + * configuration. + * + * @Return 0 on success; Error code otherwise. + */ +#define FM_PCD_IOC_NET_ENV_CHARACTERISTICS_SET \ + _IOWR(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(20), \ + ioc_fm_pcd_net_env_params_t) + +/* + * @Function fm_pcd_net_env_characteristics_delete + * + * @Description Deletes a set of Network Environment Charecteristics. + * + * @Param[in] ioc_fm_obj_t The id of a Network Environment object. + * + * @Return 0 on success; Error code otherwise. + */ +#define FM_PCD_IOC_NET_ENV_CHARACTERISTICS_DELETE \ + _IOW(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(21), ioc_fm_obj_t) + +/* + * @Function fm_pcd_kg_scheme_set + * + * @Description Initializing or modifying and enabling a scheme for the + * KeyGen. This routine should be called for adding or modifying + * a scheme. When a scheme needs modifying, the API requires that + * it will be rewritten. In such a case 'modify' should be TRUE. + * If the routine is called for a valid scheme and 'modify' is + * FALSE, it will return error. + * + * @Param[in,out] ioc_fm_pcd_kg_scheme_params_t A structure of + * parameters for defining + * the scheme + * + * @Return 0 on success; Error code otherwise. + */ +#define FM_PCD_IOC_KG_SCHEME_SET \ + _IOWR(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(24), \ + ioc_fm_pcd_kg_scheme_params_t) + +/* + * @Function fm_pcd_kg_scheme_delete + * + * @Description Deleting an initialized scheme. + * + * @Param[in] ioc_fm_obj_t scheme id as initialized by application at + * FM_PCD_IOC_KG_SET_SCHEME + * + * @Return 0 on success; Error code otherwise. + */ +#define FM_PCD_IOC_KG_SCHEME_DELETE \ + _IOW(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(25), ioc_fm_obj_t) + +/* + * @Function fm_pcd_cc_root_build + * + * @Description This routine must be called to define a complete coarse + * classification tree. This is the way to define coarse + * classification to a certain flow - the KeyGen schemes may + * point only to trees defined in this way. + * + * @Param[in,out] ioc_fm_pcd_cc_tree_params_t A structure of parameters to + * define the tree. + * + * @Return 0 on success; Error code otherwise. + */ +#define FM_PCD_IOC_CC_ROOT_BUILD \ + _IOWR(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(26), void *) + /* workaround ...*/ + +/* + * @Function fm_pcd_cc_root_delete + * + * @Description Deleting a built tree. + * + * @Param[in] ioc_fm_obj_t - The id of a CC tree. + */ +#define FM_PCD_IOC_CC_ROOT_DELETE \ + _IOW(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(27), ioc_fm_obj_t) + +/* + * @Function fm_pcd_match_table_set + * + * @Description This routine should be called for each CC (coarse + * classification) node. The whole CC tree should be built bottom + * up so that each node points to already defined nodes. p_NodeId + * returns the node Id to be used by other nodes. + * + * @Param[in,out] ioc_fm_pcd_cc_node_params_t A structure for defining the CC + * node params + * + * @Return 0 on success; Error code otherwise. + */ +#define FM_PCD_IOC_MATCH_TABLE_SET \ + _IOWR(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(28), void *) + /* workaround ...*/ + +/* + * @Function fm_pcd_match_table_delete + * + * @Description Deleting a built node. + * + * @Param[in] ioc_fm_obj_t - The id of a CC node. + * + * @Return 0 on success; Error code otherwise. + */ +#define FM_PCD_IOC_MATCH_TABLE_DELETE \ + _IOW(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(29), ioc_fm_obj_t) + +/* + * @Function fm_pcd_cc_root_modify_next_engine + * + * @Description Modify the Next Engine Parameters in the entry of the tree. + * + * @Param[in] ioc_fm_pcd_cc_tree_modify_next_engine_params_t + * Pointer to a structure with the relevant parameters + * + * @Return 0 on success; Error code otherwise. + * + * @Cautions Allowed only following fm_pcd_cc_root_build(). + */ +#define FM_PCD_IOC_CC_ROOT_MODIFY_NEXT_ENGINE \ + _IOW(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(30), \ + ioc_fm_pcd_cc_tree_modify_next_engine_params_t) + +/* + * @Function fm_pcd_match_table_modify_next_engine + * + * @Description Modify the Next Engine Parameters in the relevant key entry of + * the node. + * + * @Param[in] ioc_fm_pcd_cc_node_modify_next_engine_params_t + * A pointer to a structure with the relevant parameters + * + * @Return 0 on success; Error code otherwise. + * + * @Cautions Allowed only following fm_pcd_match_table_set(). + */ +#define FM_PCD_IOC_MATCH_TABLE_MODIFY_NEXT_ENGINE \ + _IOW(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(31), \ + ioc_fm_pcd_cc_node_modify_next_engine_params_t) + +/* + * @Function fm_pcd_match_table_modify_miss_next_engine + * + * @Description Modify the Next Engine Parameters of the Miss key case of the + * node. + * + * @Param[in] ioc_fm_pcd_cc_node_modify_next_engine_params_t + * Pointer to a structure with the relevant parameters + * + * @Return 0 on success; Error code otherwise. + * + * @Cautions Allowed only following fm_pcd_match_table_set(). + */ +#define FM_PCD_IOC_MATCH_TABLE_MODIFY_MISS_NEXT_ENGINE \ + _IOW(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(32), \ + ioc_fm_pcd_cc_node_modify_next_engine_params_t) + +/* + * @Function fm_pcd_match_table_remove_key + * + * @Description Remove the key (including next engine parameters of this key) + * defined by the index of the relevant node. + * + * @Param[in] ioc_fm_pcd_cc_node_remove_key_params_t + * A pointer to a structure with the relevant parameters + * + * @Return 0 on success; Error code otherwise. + * + * @Cautions Allowed only after fm_pcd_match_table_set() has been called + * for this node and for all of the nodes that lead to it. + */ +#define FM_PCD_IOC_MATCH_TABLE_REMOVE_KEY \ + _IOW(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(33), \ + ioc_fm_pcd_cc_node_remove_key_params_t) + +/* + * @Function fm_pcd_match_table_add_key + * + * @Description Add the key (including next engine parameters of this key in + * the index defined by the key_index. Note that + * 'FM_PCD_LAST_KEY_INDEX' may be used when the user don't care + * about the position of the key in the table - in that case, the + * key will be automatically added by the driver in the last + * available entry. + * + * @Param[in] ioc_fm_pcd_cc_node_modify_key_and_next_engine_params_t + * A pointer to a structure with the relevant parameters + * + * @Return 0 on success; Error code otherwise. + * + * @Cautions Allowed only after fm_pcd_match_table_set() has been called + * for this node and for all of the nodes that lead to it. + */ +#define FM_PCD_IOC_MATCH_TABLE_ADD_KEY \ + _IOW(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(34), \ + ioc_fm_pcd_cc_node_modify_key_and_next_engine_params_t) + +/* + * @Function fm_pcd_match_table_modify_key_and_next_engine + * + * @Description Modify the key and Next Engine Parameters of this key in the + * index defined by key_index. + * + * @Param[in] ioc_fm_pcd_cc_node_modify_key_and_next_engine_params_t + * A pointer to a structure with the relevant parameters + * + * @Return 0 on success; Error code otherwise. + * + * @Cautions Allowed only following fm_pcd_match_table_set() not only of + * the relevnt node but also the node that points to this node. + */ +#define FM_PCD_IOC_MATCH_TABLE_MODIFY_KEY_AND_NEXT_ENGINE \ + _IOW(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(35), \ + ioc_fm_pcd_cc_node_modify_key_and_next_engine_params_t) + +/* + * @Function fm_pcd_match_table_modify_key + * + * @Description Modify the key at the index defined by key_index. + * + * @Param[in] ioc_fm_pcd_cc_node_modify_key_params_t - Pointer to a + * structure with the relevant parameters + * + * @Return 0 on success; Error code otherwise. + * + * @Cautions Allowed only after fm_pcd_match_table_set() has been called + * for this node and for all of the nodes that lead to it. + */ +#define FM_PCD_IOC_MATCH_TABLE_MODIFY_KEY \ + _IOW(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(36), \ + ioc_fm_pcd_cc_node_modify_key_params_t) + +/* + * @Function fm_pcd_hash_table_set + * + * @Description This routine initializes a hash table structure. + * KeyGen hash result determines the hash bucket. + * Next, KeyGen key is compared against all keys of this bucket + * (exact match). + * Number of sets (number of buckets) of the hash equals to the + * number of 1-s in 'hash_res_mask' in the provided parameters. + * Number of hash table ways is then calculated by dividing + * 'max_num_of_keys' equally between the hash sets. This is the + * maximal number of keys that a hash bucket may hold. + * The hash table is initialized empty and keys may be added to + * it following the initialization. Keys masks are not supported + * in current hash table implementation. The initialized hash + * table can be integrated as a node in a CC tree. + * + * @Param[in,out] ioc_fm_pcd_hash_table_params_t Pointer to a structure + * with the relevant + * parameters. + * + * @Return 0 on success; Error code otherwise. + */ +#define FM_PCD_IOC_HASH_TABLE_SET \ + _IOWR(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(37), \ + ioc_fm_pcd_hash_table_params_t) + +/* + * @Function fm_pcd_hash_table_delete + * + * @Description This routine deletes the provided hash table and released all + * its allocated resources. + * + * @Param[in] ioc_fm_obj_t The ID of a hash table. + * + * @Return 0 on success; Error code otherwise. + * + * @Cautions Allowed only following fm_pcd_hash_table_set(). + */ +#define FM_PCD_IOC_HASH_TABLE_DELETE \ + _IOW(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(37), ioc_fm_obj_t) + +/* + * @Function fm_pcd_hash_table_add_key + * + * @Description This routine adds the provided key (including next engine + * parameters of this key) to the hash table. + * The key is added as the last key of the bucket that it is + * mapped to. + * + * @Param[in] ioc_fm_pcd_hash_table_add_key_params_t + * Pointer to a structure with the relevant parameters + * + * @Return 0 on success; error code otherwise. + * + * @Cautions Allowed only following fm_pcd_hash_table_set(). + */ +#define FM_PCD_IOC_HASH_TABLE_ADD_KEY \ + _IOW(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(39), \ + ioc_fm_pcd_hash_table_add_key_params_t) + +/* + * @Function fm_pcd_hash_table_remove_key + * + * @Description This routine removes the requested key (including next engine + * parameters of this key) from the hash table. + * + * @Param[in] ioc_fm_pcd_hash_table_remove_key_params_t - Pointer to a + * structure with the relevant parameters + * + * @Return 0 on success; Error code otherwise. + * + * @Cautions Allowed only following fm_pcd_hash_table_set(). + */ +#define FM_PCD_IOC_HASH_TABLE_REMOVE_KEY \ + _IOW(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(40), \ + ioc_fm_pcd_hash_table_remove_key_params_t) + +/* + * @Function fm_pcd_plcr_profile_set + * + * @Description Sets a profile entry in the policer profile table. + * The routine overrides any existing value. + * + * @Param[in,out] ioc_fm_pcd_plcr_profile_params_t A structure of + * parameters for defining + * a policer profile entry. + * + * @Return 0 on success; Error code otherwise. + */ +#define FM_PCD_IOC_PLCR_PROFILE_SET \ + _IOWR(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(41), \ + ioc_fm_pcd_plcr_profile_params_t) + +/* + * @Function fm_pcd_plcr_profile_delete + * + * @Description Delete a profile entry in the policer profile table. + * The routine set entry to invalid. + * + * @Param[in] ioc_fm_obj_t The id of a policer profile. + * + * @Return 0 on success; Error code otherwise. + */ +#define FM_PCD_IOC_PLCR_PROFILE_DELETE \ + _IOW(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(41), ioc_fm_obj_t) + +/* + * @Function fm_pcd_manip_node_set + * + * @Description This routine should be called for defining a manipulation + * node. A manipulation node must be defined before the CC node + * that precedes it. + * + * @Param[in] ioc_fm_pcd_manip_params_t A structure of parameters + * defining the manipulation. + * + * @Return A handle to the initialized object on success; NULL code + * otherwise. + */ +#define FM_PCD_IOC_MANIP_NODE_SET \ + _IOWR(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(43), \ + ioc_fm_pcd_manip_params_t) + +/* + * @Function fm_pcd_manip_node_replace + * + * @Description Change existing manipulation node to be according to new + * requirement. (Here, it's implemented as a variant of the same + * IOCTL as for fm_pcd_manip_node_set(), and one that when + * called, the 'id' member in its 'ioc_fm_pcd_manip_params_t' + * argument is set to contain the manip node's handle) + * + * @Param[in] ioc_fm_pcd_manip_params_t A structure of parameters + * defining the manipulation. + * + * @Return 0 on success; error code otherwise. + * + * @Cautions Allowed only following fm_pcd_manip_node_set(). + */ +#define FM_PCD_IOC_MANIP_NODE_REPLACE FM_PCD_IOC_MANIP_NODE_SET + +/* + * @Function fm_pcd_manip_node_delete + * + * @Description Delete an existing manipulation node. + * + * @Param[in] ioc_fm_obj_t The id of the manipulation node to delete. + * + * @Return 0 on success; error code otherwise. + * + * @Cautions Allowed only following fm_pcd_manip_node_set(). + */ +#define FM_PCD_IOC_MANIP_NODE_DELETE \ + _IOW(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(44), ioc_fm_obj_t) + +/* + * @Function fm_pcd_manip_get_statistics + * + * @Description Retrieve the manipulation statistics. + * + * @Param[in] h_manip_node A handle to a manipulation node. + * @Param[out] p_fm_pcd_manip_stats A structure for retrieving the + * manipulation statistics. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_pcd_manip_node_set(). + */ +#define FM_PCD_IOC_MANIP_GET_STATS \ + _IOWR(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(50), \ + ioc_fm_pcd_manip_get_stats_t) + +/* + * @Function fm_pcd_set_advanced_offload_support + * + * @Description This routine must be called in order to support the following + * features: IP-fragmentation, IP-reassembly, IPsec, + * Header-manipulation, frame-replicator. + * + * @Param[in] h_fm_pcd FM PCD module descriptor. + * + * @Return 0 on success; error code otherwise. + * + * @Cautions Allowed only when PCD is disabled. + */ +#define FM_PCD_IOC_SET_ADVANCED_OFFLOAD_SUPPORT \ + _IO(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(45)) + +/* + * @Function fm_pcd_frm_replic_set_group + * + * @Description Initialize a Frame Replicator group. + * + * @Param[in] h_fm_pcd FM PCD module descriptor. + * @Param[in] p_frm_replic_group_param A structure of parameters for + * the initialization of the frame + * replicator group. + * + * @Return A handle to the initialized object on success; NULL code + * otherwise. + * + * @Cautions Allowed only following fm_pcd_init(). + */ +#define FM_PCD_IOC_FRM_REPLIC_GROUP_SET \ + _IOWR(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(46), \ + ioc_fm_pcd_frm_replic_group_params_t) + +/* + * @Function fm_pcd_frm_replic_delete_group + * + * @Description Delete a Frame Replicator group. + * + * @Param[in] h_frm_replic_group A handle to the frame replicator group. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_pcd_frm_replic_set_group(). + */ +#define FM_PCD_IOC_FRM_REPLIC_GROUP_DELETE \ + _IOWR(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(47), ioc_fm_obj_t) + +/* + * @Function fm_pcd_frm_replic_add_member + * + * @Description Add the member in the index defined by the member_index. + * + * @Param[in] h_frm_replic_group A handle to the frame replicator group. + * @Param[in] member_index Member index for adding. + * @Param[in] p_member_params A pointer to the new member parameters. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_pcd_frm_replic_set_group() of this + * group. + */ +#define FM_PCD_IOC_FRM_REPLIC_MEMBER_ADD \ + _IOWR(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(48), \ + ioc_fm_pcd_frm_replic_member_params_t) + +/* + * @Function fm_pcd_frm_replic_remove_member + * + * @Description Remove the member defined by the index from the relevant group + * + * @Param[in] h_frm_replic_group A handle to the frame replicator group. + * @Param[in] member_index Member index for removing. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_pcd_frm_replic_set_group() of this + * group. + */ +#define FM_PCD_IOC_FRM_REPLIC_MEMBER_REMOVE \ + _IOWR(FM_IOC_TYPE_BASE, FM_PCD_IOC_NUM(49), \ + ioc_fm_pcd_frm_replic_member_t) + +/* + * @Group FM_grp Frame Manager API + * + * @Description Frame Manager Application Programming Interface + * + * @{ + */ + +/* + * @Group FM_PCD_grp FM PCD + * + * @Description Frame Manager PCD (Parse-Classify-Distribute) API. + * + * The FM PCD module is responsible for the initialization of all + * global classifying FM modules. This includes the parser + * general and common registers, the key generator global and + * common registers, and the policer global and common registers. + * In addition, the FM PCD SW module will initialize all required + * key generator schemes, coarse classification flows, and + * policer profiles. When FM module is configured to work with + * one of these entities, it will register to it using the FM + * PORT API. The PCD module will manage the PCD resources - i.e. + * resource management of KeyGen schemes, etc. + * + * @{ + */ + +/* + * @Collection General PCD defines + */ +#define FM_PCD_MAX_NUM_OF_PRIVATE_HDRS 2 +/**< Number of units/headers saved for user */ + +#define FM_PCD_PRS_NUM_OF_HDRS 16 +/**< Number of headers supported by HW parser */ +#define FM_PCD_MAX_NUM_OF_DISTINCTION_UNITS \ + (32 - FM_PCD_MAX_NUM_OF_PRIVATE_HDRS) +/**< Number of distinction units is limited by register size (32 bits) minus + *reserved bits for private headers. + */ +#define FM_PCD_MAX_NUM_OF_INTERCHANGEABLE_HDRS 4 +/**< Maximum number of interchangeable headers in a distinction unit */ +#define FM_PCD_KG_NUM_OF_GENERIC_REGS FM_KG_NUM_OF_GENERIC_REGS +/**< Total number of generic KeyGen registers */ +#define FM_PCD_KG_MAX_NUM_OF_EXTRACTS_PER_KEY 35 +/**< Max number allowed on any configuration; For HW implementation reasons, in + * most cases less than this will be allowed; The driver will return an + * initialization error if resource is unavailable. + */ +#define FM_PCD_KG_NUM_OF_EXTRACT_MASKS 4 +/**< Total number of masks allowed on KeyGen extractions. */ +#define FM_PCD_KG_NUM_OF_DEFAULT_GROUPS 16 +/**< Number of default value logical groups */ + +#define FM_PCD_PRS_NUM_OF_LABELS 32 +/**< Maximum number of SW parser labels */ +#define FM_SW_PRS_MAX_IMAGE_SIZE \ + (FM_PCD_SW_PRS_SIZE \ + /*- FM_PCD_PRS_SW_OFFSET -FM_PCD_PRS_SW_TAIL_SIZE*/ \ + - FM_PCD_PRS_SW_PATCHES_SIZE) +/**< Maximum size of SW parser code */ + +#define FM_PCD_MAX_MANIP_INSRT_TEMPLATE_SIZE 128 +/**< Maximum size of insertion template for insert manipulation */ + +#define FM_PCD_FRM_REPLIC_MAX_NUM_OF_ENTRIES 64 +/**< Maximum possible entries for frame replicator group */ +/* @} */ + +/* + * @Group FM_PCD_init_grp FM PCD Initialization Unit + * + * @Description Frame Manager PCD Initialization Unit API + * + * @{ + */ + +/* + * @Description Exceptions user callback routine, will be called upon an + * exception passing the exception identification. + * + * @Param[in] h_app User's application descriptor. + * @Param[in] exception The exception. + */ +typedef void (t_fm_pcd_exception_callback) (t_handle h_app, + ioc_fm_pcd_exceptions exception); + +/* + * @Description Exceptions user callback routine, will be called upon an + * exception passing the exception identification. + * + * @Param[in] h_app User's application descriptor. + * @Param[in] exception The exception. + * @Param[in] index id of the relevant source (may be scheme or + * profile id). + */ +typedef void (t_fm_pcd_id_exception_callback) (t_handle h_app, + ioc_fm_pcd_exceptions exception, + uint16_t index); + +/* + * @Description A callback for enqueuing frame onto a QM queue. + * + * @Param[in] h_qm_arg Application's handle passed to QM module on + * enqueue. + * @Param[in] p_fd Frame descriptor for the frame. + * + * @Return E_OK on success; Error code otherwise. + */ +typedef uint32_t (t_fm_pcd_qm_enqueue_callback) (t_handle h_qm_arg, void *p_fd); + +/* + * @Description Host-Command parameters structure. + * + * When using Host command for PCD functionalities, a dedicated + * port must be used. If this routine is called for a PCD in a + * single partition environment, or it is the Master partition in + * a Multi-partition environment, The port will be initialized by + * the PCD driver initialization routine. + */ +typedef struct t_fm_pcd_hc_params { + uintptr_t port_base_addr; + /**< Virtual Address of Host-Command Port memory mapped registers.*/ + uint8_t port_id; + /**< Port Id (0-6 relative to Host-Command/Offline-Parsing ports); + * NOTE: When configuring Host Command port for FMANv3 devices + * (DPAA_VERSION 11 and higher), port_id=0 MUST be used. + */ + uint16_t liodn_base; + /**< LIODN base for this port, to be used together with LIODN offset + * (irrelevant for P4080 revision 1.0) + */ + uint32_t err_fqid; + /**< Host-Command Port error queue Id. */ + uint32_t conf_fqid; + /**< Host-Command Port confirmation queue Id. */ + uint32_t qm_channel; + /**< QM channel dedicated to this Host-Command port; will be used by the + * FM for dequeue. + */ + t_fm_pcd_qm_enqueue_callback *f_qm_enqueue; + /**< Callback routine for enqueuing a frame to the QM */ + t_handle h_qm_arg; + /**< Application's handle passed to QM module on enqueue */ +} t_fm_pcd_hc_params; + +/* + * @Description The main structure for PCD initialization + */ +typedef struct t_fm_pcd_params { + bool prs_support; + /**< TRUE if Parser will be used for any of the FM ports. */ + bool cc_support; + /**< TRUE if Coarse Classification will be used for any of the FM ports. + */ + bool kg_support; + /**< TRUE if KeyGen will be used for any of the FM ports. */ + bool plcr_support; + /**< TRUE if Policer will be used for any of the FM ports. */ + t_handle h_fm; + /**< A handle to the FM module. */ + uint8_t num_schemes; + /**< Number of schemes dedicated to this partition. + * this parameter is relevant if 'kg_support'=TRUE. + */ + bool use_host_command; + /**< Optional for single partition, Mandatory for Multi partition */ + t_fm_pcd_hc_params hc; + /**< Host Command parameters, relevant only if 'use_host_command'=TRUE; + * Relevant when FM not runs in "guest-mode". + */ + t_fm_pcd_exception_callback *f_exception; + /**< Callback routine for general PCD exceptions; Relevant when FM not + * runs in "guest-mode". + */ + t_fm_pcd_id_exception_callback *f_exception_id; + /**< Callback routine for specific KeyGen scheme or Policer profile + * exceptions; Relevant when FM not runs in "guest-mode". + */ + t_handle h_app; + /**< A handle to an application layer object; This handle will be passed + * by the driver upon calling the above callbacks; Relevant when FM not + * runs in "guest-mode". + */ + uint8_t part_plcr_profiles_base; + /**< The first policer-profile-id dedicated to this partition. this + * parameter is relevant if 'plcr_support'=TRUE. NOTE: this parameter + * relevant only when working with multiple partitions. + */ + uint16_t part_num_of_plcr_profiles; + /**< Number of policer-profiles dedicated to this partition. This + * parameter is relevant if 'plcr_support'=TRUE. NOTE: this parameter + * relevant only when working with multiple partitions. + */ +} t_fm_pcd_params; + +typedef struct t_fm_pcd_prs_label_params { + uint32_t instruction_offset; + ioc_net_header_type hdr; + uint8_t index_per_hdr; +} t_fm_pcd_prs_label_params; + +typedef struct t_fm_pcd_prs_sw_params { + bool override; + uint32_t size; + uint16_t base; + uint8_t *p_code; + uint32_t sw_prs_data_params[FM_PCD_PRS_NUM_OF_HDRS]; + uint8_t num_of_labels; + t_fm_pcd_prs_label_params labels_table[FM_PCD_PRS_NUM_OF_LABELS]; +} t_fm_pcd_prs_sw_params; + +/* + * @Function fm_pcd_config + * + * @Description Basic configuration of the PCD module. + * Creates descriptor for the FM PCD module. + * + * @Param[in] p_fm_pcd_params A structure of parameters for the + initialization of PCD. + * + * @Return A handle to the initialized module. + */ +t_handle fm_pcd_config(t_fm_pcd_params *p_fm_pcd_params); + +/* + * @Function fm_pcd_init + * + * @Description Initialization of the PCD module. + * + * @Param[in] h_fm_pcd FM PCD module descriptor. + * + * @Return E_OK on success; Error code otherwise. + */ +uint32_t fm_pcd_init(t_handle h_fm_pcd); + +/* + * @Function fm_pcd_free + * + * @Description Frees all resources that were assigned to FM module. + * Calling this routine invalidates the descriptor. + * + * @Param[in] h_fm_pcd FM PCD module descriptor. + * + * @Return E_OK on success; Error code otherwise. + */ +uint32_t fm_pcd_free(t_handle h_fm_pcd); + +/* + * @Group FM_PCD_advanced_cfg_grp FM PCD Advanced Configuration + * Unit + * + * @Description Frame Manager PCD Advanced Configuration API. + * + * @{ + */ + +/* + * @Function fm_pcd_config_exception + * + * @Description Calling this routine changes the internal driver data base + * from its default selection of exceptions enabling. + * [DEFAULT_num_of_shared_plcr_profiles]. + * + * @Param[in] h_fm_pcd FM PCD module descriptor. + * @Param[in] exception The exception to be selected. + * @Param[in] enable TRUE to enable interrupt, FALSE to mask it. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions This routine should NOT be called from guest-partition (i.e. + * guestId != NCSW_PRIMARY_ID) + */ +uint32_t fm_pcd_config_exception(t_handle h_fm_pcd, + ioc_fm_pcd_exceptions exception, bool enable); + +/* + * @Function fm_pcd_config_hc_frames_data_memory + * + * @Description Configures memory-partition-id for FMan-Controller + * Host-Command frames. Calling this routine changes the internal + * driver data base from its default configuration [0]. + * + * @Param[in] h_fm_pcd FM PCD module descriptor. + * @Param[in] mem_id Memory partition ID. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions This routine may be called only if 'use_host_command' was TRUE + * when fm_pcd_config() routine was called. + */ +uint32_t fm_pcd_config_hc_frames_data_memory(t_handle h_fm_pcd, uint8_t mem_id); + +/* + * @Function fm_pcd_config_plcr_num_of_shared_profiles + * + * @Description Calling this routine changes the internal driver data base + * from its default selection of exceptions enablement. + * [DEFAULT_num_of_shared_plcr_profiles]. + * + * @Param[in] h_fm_pcd FM PCD module descriptor. + * @Param[in] num_of_shared_plcr_profiles Number of profiles to be shared + * between ports on this partition + * + * @Return E_OK on success; Error code otherwise. + */ +uint32_t fm_pcd_config_plcr_num_of_shared_profiles(t_handle h_fm_pcd, + uint16_t num_of_shared_plcr_profiles); + +/* + * @Function fm_pcd_config_plcr_auto_refresh_mode + * + * @Description Calling this routine changes the internal driver data base + * from its default selection of exceptions enablement. By + * default auto-refresh is [DEFAULT_plcrAutoRefresh]. + * + * @Param[in] h_fm_pcd FM PCD module descriptor. + * @Param[in] enable TRUE to enable, FALSE to disable + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions This routine should NOT be called from guest-partition + * (i.e. guestId != NCSW_PRIMARY_ID) + */ +uint32_t fm_pcd_config_plcr_auto_refresh_mode(t_handle h_fm_pcd, bool enable); + +/* + * @Function fm_pcd_config_prs_max_cycle_limit + * + * @Description Calling this routine changes the internal data structure for + * the maximum parsing time from its default value + * [DEFAULT_MAX_PRS_CYC_LIM]. + * + * @Param[in] h_fm_pcd FM PCD module descriptor. + * @Param[in] value 0 to disable the mechanism, or new maximum + * parsing time. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions This routine should NOT be called from guest-partition + * (i.e. guestId != NCSW_PRIMARY_ID) + */ +uint32_t fm_pcd_config_prs_max_cycle_limit(t_handle h_fm_pcd, uint16_t value); + +/** @} */ /* end of FM_PCD_advanced_cfg_grp group */ +/** @} */ /* end of FM_PCD_init_grp group */ + +/* + * @Group FM_PCD_Runtime_grp FM PCD Runtime Unit + * + * @Description Frame Manager PCD Runtime Unit API + * + * The runtime control allows creation of PCD infrastructure + * modules such as Network Environment Characteristics, + * Classification Plan Groups and Coarse Classification Trees. + * It also allows on-the-fly initialization, modification and + * removal of PCD modules such as KeyGen schemes, coarse + * classification nodes and Policer profiles. + * + * In order to explain the programming model of the PCD driver + * interface a few terms should be explained, and will be used + * below. + * - Distinction Header - One of the 16 protocols supported by + * the FM parser, or one of the SHIM headers (1 or 2). May be a + * header with a special option (see below). + * - Interchangeable Headers Group - This is a group of Headers + * recognized by either one of them. For example, if in a + * specific context the user chooses to treat IPv4 and IPV6 in + * the same way, they may create an interchangeable Headers + * Unit consisting of these 2 headers. + * - A Distinction Unit - a Distinction Header or an + * Interchangeable Headers Group. + * - Header with special option - applies to Ethernet, MPLS, + * VLAN, IPv4 and IPv6, includes multicast, broadcast and other + * protocol specific options. In terms of hardware it relates + * to the options available in the classification plan. + * - Network Environment Characteristics - a set of Distinction + * Units that define the total recognizable header selection + * for a certain environment. This is NOT the list of all + * headers that will ever appear in a flow, but rather + * everything that needs distinction in a flow, where + * distinction is made by KeyGen schemes and coarse + * classification action descriptors. + * + * The PCD runtime modules initialization is done in stages. The + * first stage after initializing the PCD module itself is to + * establish a Network Flows Environment Definition. The + * application may choose to establish one or more such + * environments. Later, when needed, the application will have to + * state, for some of its modules, to which single environment it + * belongs. + * + * @{ + */ + +t_handle fm_pcd_open(t_fm_pcd_params *p_fm_pcd_params); +void fm_pcd_close(t_handle h_fm_pcd); + +/* + * @Function fm_pcd_enable + * + * @Description This routine should be called after PCD is initialized for + * enabling all PCD engines according to their existing + * configuration. + * + * @Param[in] h_fm_pcd FM PCD module descriptor. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_pcd_init() and when PCD is disabled. + */ +uint32_t fm_pcd_enable(t_handle h_fm_pcd); + +/* + * @Function fm_pcd_disable + * + * @Description This routine may be called when PCD is enabled in order to + * disable all PCD engines. It may be called only when none of + * the ports in the system are using the PCD. + * + * @Param[in] h_fm_pcd FM PCD module descriptor. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_pcd_init() and when PCD is enabled. + */ +uint32_t fm_pcd_disable(t_handle h_fm_pcd); + +/* + * @Function fm_pcd_get_counter + * + * @Description Reads one of the FM PCD counters. + * + * @Param[in] h_fm_pcd FM PCD module descriptor. + * @Param[in] counter The requested counter. + * + * @Return Counter's current value. + * + * @Cautions Allowed only following fm_pcd_init(). + * Note that it is user's responsibility to call this routine + * only for enabled counters, and there will be no indication if + * a disabled counter is accessed. + */ +uint32_t fm_pcd_get_counter(t_handle h_fm_pcd, ioc_fm_pcd_counters counter); + +/* + * @Function fm_pcd_prs_load_sw + * + * @Description This routine may be called in order to load software parsing + * code. + * + * @Param[in] h_fm_pcd FM PCD module descriptor. + * @Param[in] p_sw_prs A pointer to a structure of software + * parser parameters, including the software + * parser image. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_pcd_init() and when PCD is disabled. + * This routine should NOT be called from guest-partition + * (i.e. guestId != NCSW_PRIMARY_ID) + */ +uint32_t fm_pcd_prs_load_sw(t_handle h_fm_pcd, + ioc_fm_pcd_prs_sw_params_t *p_sw_prs); + +/* + * @Function fm_pcd_set_advanced_offload_support + * + * @Description This routine must be called in order to support the following + * features: IP-fragmentation, IP-reassembly, IPsec, + * Header-manipulation, frame-replicator. + * + * @Param[in] h_fm_pcd FM PCD module descriptor. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_pcd_init() and when PCD is disabled. + * This routine should NOT be called from guest-partition + * (i.e. guestId != NCSW_PRIMARY_ID) + */ +uint32_t fm_pcd_set_advanced_offload_support(t_handle h_fm_pcd); + +/* + * @Function fm_pcd_kg_set_dflt_value + * + * @Description Calling this routine sets a global default value to be used + * by the KeyGen when parser does not recognize a required + * field/header. + * By default default values are 0. + * + * @Param[in] h_fm_pcd FM PCD module descriptor. + * @Param[in] value_id 0,1 - one of 2 global default values. + * @Param[in] value The requested default value. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_pcd_init() and when PCD is disabled. + * This routine should NOT be called from guest-partition + * (i.e. guestId != NCSW_PRIMARY_ID) + */ +uint32_t fm_pcd_kg_set_dflt_value(t_handle h_fm_pcd, + uint8_t value_id, uint32_t value); + +/* + * @Function fm_pcd_kg_set_additional_data_after_parsing + * + * @Description Calling this routine allows the KeyGen to access data past + * the parser finishing point. + * + * @Param[in] h_fm_pcd FM PCD module descriptor. + * @Param[in] payload_offset the number of bytes beyond the parser + * location. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_pcd_init() and when PCD is disabled. + * This routine should NOT be called from guest-partition (i.e. + * guestId != NCSW_PRIMARY_ID) + */ +uint32_t fm_pcd_kg_set_additional_data_after_parsing(t_handle h_fm_pcd, + uint8_t payload_offset); + +/* + * @Function fm_pcd_set_exception + * + * @Description Calling this routine enables/disables PCD interrupts. + * + * @Param[in] h_fm_pcd FM PCD module descriptor. + * @Param[in] exception The exception to be selected. + * @Param[in] enable TRUE to enable interrupt, FALSE to mask it. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_pcd_init(). + * This routine should NOT be called from guest-partition + * (i.e. guestId != NCSW_PRIMARY_ID) + */ +uint32_t fm_pcd_set_exception(t_handle h_fm_pcd, + ioc_fm_pcd_exceptions exception, bool enable); + +/* + * @Function fm_pcd_modify_counter + * + * @Description Sets a value to an enabled counter. Use "0" to reset the + * counter. + * + * @Param[in] h_fm_pcd FM PCD module descriptor. + * @Param[in] counter The requested counter. + * @Param[in] value The requested value to be written into the + * counter. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_pcd_init(). + * This routine should NOT be called from guest-partition + * (i.e. guestId != NCSW_PRIMARY_ID) + */ +uint32_t fm_pcd_modify_counter(t_handle h_fm_pcd, + ioc_fm_pcd_counters counter, uint32_t value); + +/* + * @Function fm_pcd_set_plcr_statistics + * + * @Description This routine may be used to enable/disable policer statistics + * counter. By default the statistics is enabled. + * + * @Param[in] h_fm_pcd FM PCD module descriptor + * @Param[in] enable TRUE to enable, FALSE to disable. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_pcd_init(). + * This routine should NOT be called from guest-partition + * (i.e. guestId != NCSW_PRIMARY_ID) + */ +uint32_t fm_pcd_set_plcr_statistics(t_handle h_fm_pcd, bool enable); + +/* + * @Function fm_pcd_set_prs_statistics + * + * @Description Defines whether to gather parser statistics including all + * ports. + * + * @Param[in] h_fm_pcd FM PCD module descriptor. + * @Param[in] enable TRUE to enable, FALSE to disable. + * + * @Return None + * + * @Cautions Allowed only following fm_pcd_init(). + * This routine should NOT be called from guest-partition + * (i.e. guestId != NCSW_PRIMARY_ID) + */ +void fm_pcd_set_prs_statistics(t_handle h_fm_pcd, bool enable); + +#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0)) +/* + * @Function fm_pcd_dump_regs + * + * @Description Dumps all PCD registers + * + * @Param[in] h_fm_pcd A handle to an FM PCD Module. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_pcd_init(). + * NOTE: this routine may be called only for FM in master mode + * (i.e. 'guestId'=NCSW_PRIMARY_ID) or in a case that the + * registers are mapped. + */ +uint32_t fm_pcd_dump_regs(t_handle h_fm_pcd); + +/* + * @Function fm_pcd_kg_dump_regs + * + * @Description Dumps all PCD KG registers + * + * @Param[in] h_fm_pcd A handle to an FM PCD Module. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_pcd_init(). + * NOTE: this routine may be called only for FM in master mode + * (i.e. 'guestId'=NCSW_PRIMARY_ID) or in a case that the + * registers are mapped. + */ +uint32_t fm_pcd_kg_dump_regs(t_handle h_fm_pcd); + +/* + * @Function fm_pcd_plcr_dump_regs + * + * @Description Dumps all PCD Policer registers + * + * @Param[in] h_fm_pcd A handle to an FM PCD Module. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_pcd_init(). + * NOTE: this routine may be called only for FM in master mode + * (i.e. 'guestId'=NCSW_PRIMARY_ID) or in a case that the + * registers are mapped. + */ +uint32_t fm_pcd_plcr_dump_regs(t_handle h_fm_pcd); + +/* + * @Function fm_pcd_plcr_profile_dump_regs + * + * @Description Dumps all PCD Policer profile registers + * + * @Param[in] h_profile A handle to a Policer profile. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_pcd_init(). + * NOTE: this routine may be called only for FM in master mode + * (i.e. 'guestId'=NCSW_PRIMARY_ID) or in a case that the + * registers are mapped. + */ +uint32_t fm_pcd_plcr_profile_dump_regs(t_handle h_profile); + +/* + * @Function fm_pcd_prs_dump_regs + * + * @Description Dumps all PCD Parser registers + * + * @Param[in] h_fm_pcd A handle to an FM PCD Module. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_pcd_init(). + * NOTE: this routine may be called only for FM in master mode + * (i.e. 'guestId'=NCSW_PRIMARY_ID) or in a case that the + * registers are mapped. + */ +uint32_t fm_pcd_prs_dump_regs(t_handle h_fm_pcd); + +/* + * @Function fm_pcd_hc_dump_regs + * + * @Description Dumps HC Port registers + * + * @Param[in] h_fm_pcd A handle to an FM PCD Module. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_pcd_init(). + * NOTE: this routine may be called only for FM in master mode + * (i.e. 'guestId'=NCSW_PRIMARY_ID). + */ +uint32_t fm_pcd_hc_dump_regs(t_handle h_fm_pcd); +#endif /* (defined(DEBUG_ERRORS) && ... */ + + +/* + * KeyGen FM_PCD_Runtime_build_grp FM PCD Runtime Building Unit + * + * @Description Frame Manager PCD Runtime Building API + * + * This group contains routines for setting, deleting and + * modifying PCD resources, for defining the total PCD tree. + * @{ + */ + +/* + * @Collection Definitions of coarse classification + * parameters as required by KeyGen (when coarse classification + * is the next engine after this scheme). + */ +#define FM_PCD_MAX_NUM_OF_CC_TREES 8 +#define FM_PCD_MAX_NUM_OF_CC_GROUPS 16 +#define FM_PCD_MAX_NUM_OF_CC_UNITS 4 +#define FM_PCD_MAX_NUM_OF_KEYS 256 +#define FM_PCD_MAX_NUM_OF_FLOWS (4 * KILOBYTE) +#define FM_PCD_MAX_SIZE_OF_KEY 56 +#define FM_PCD_MAX_NUM_OF_CC_ENTRIES_IN_GRP 16 +#define FM_PCD_LAST_KEY_INDEX 0xffff + +#define FM_PCD_MAX_NUM_OF_CC_NODES 255 + /* Obsolete, not used - will be removed in the future */ +/* @} */ + +/* + * @Collection A set of definitions to allow protocol + * special option description. + */ +typedef uint32_t protocol_opt_t; + /**< A general type to define a protocol option. */ + +typedef protocol_opt_t eth_protocol_opt_t; + /**< Ethernet protocol options. */ +#define ETH_BROADCAST 0x80000000 /**< Ethernet Broadcast. */ +#define ETH_MULTICAST 0x40000000 /**< Ethernet Multicast. */ + +typedef protocol_opt_t vlan_protocol_opt_t; /**< VLAN protocol options. */ +#define VLAN_STACKED 0x20000000 /**< Stacked VLAN. */ + +typedef protocol_opt_t mpls_protocol_opt_t; /**< MPLS protocol options. */ +#define MPLS_STACKED 0x10000000 /**< Stacked MPLS. */ + +typedef protocol_opt_t ipv_4protocol_opt_t; /**< IPv4 protocol options. */ +#define IPV4_BROADCAST_1 0x08000000 /**< IPv4 Broadcast. */ +#define IPV4_MULTICAST_1 0x04000000 /**< IPv4 Multicast. */ +#define IPV4_UNICAST_2 0x02000000 /**< Tunneled IPv4 - Unicast. */ +#define IPV4_MULTICAST_BROADCAST_2 0x01000000 + /**< Tunneled IPv4 - Broadcast/Multicast. */ + +#define IPV4_FRAG_1 0x00000008 + /**< IPV4 reassembly option. IPV4 Reassembly + * manipulation requires network environment + * with IPV4 header and IPV4_FRAG_1 option + */ + +typedef protocol_opt_t ipv_6protocol_opt_t; /**< IPv6 protocol options. */ +#define IPV6_MULTICAST_1 0x00800000 /**< IPv6 Multicast. */ +#define IPV6_UNICAST_2 0x00400000 /**< Tunneled IPv6 - Unicast. */ +#define IPV6_MULTICAST_2 0x00200000 /**< Tunneled IPv6 - Multicast. */ + +#define IPV6_FRAG_1 0x00000004 + /**< IPV6 reassembly option. IPV6 Reassembly + * manipulation requires network environment + * with IPV6 header and IPV6_FRAG_1 option; in + * case where fragment found, the + * fragment-extension offset may be found at + * 'shim2' (in parser-result). + */ +typedef protocol_opt_t capwap_protocol_opt_t; /**< CAPWAP protocol options. */ +#define CAPWAP_FRAG_1 0x00000008 + /**< CAPWAP reassembly option. CAPWAP Reassembly + * manipulation requires network environment + * with CAPWAP header and CAPWAP_FRAG_1 option; + * in case where fragment found, the + * fragment-extension offset may be found at + * 'shim2' (in parser-result). + */ + +/* @} */ + +#define FM_PCD_MANIP_MAX_HDR_SIZE 256 +#define FM_PCD_MANIP_DSCP_TO_VLAN_TRANS 64 + +/* + * @Collection A set of definitions to support Header Manipulation selection. + */ +typedef uint32_t hdr_manip_flags_t; + /**< A general type to define a HMan update command flags. */ + +typedef hdr_manip_flags_t ipv_4hdr_manip_update_flags_t; + /**< IPv4 protocol HMan update command flags. */ + +#define HDR_MANIP_IPV4_TOS 0x80000000 + /**< update TOS with the given value ('tos' field + * of t_FmPcdManipHdrFieldUpdateIpv4) + */ +#define HDR_MANIP_IPV4_ID 0x40000000 + /**< update IP ID with the given value ('id' field + * of t_FmPcdManipHdrFieldUpdateIpv4) + */ +#define HDR_MANIP_IPV4_TTL 0x20000000 + /**< Decrement TTL by 1 */ +#define HDR_MANIP_IPV4_SRC 0x10000000 + /**< update IP source address with the given value + * ('src' field of t_FmPcdManipHdrFieldUpdateIpv4) + */ +#define HDR_MANIP_IPV4_DST 0x08000000 + /**< update IP destination address with the given value + * ('dst' field of t_FmPcdManipHdrFieldUpdateIpv4) + */ + +typedef hdr_manip_flags_t ipv_6hdr_manip_update_flags_t; + /**< IPv6 protocol HMan update command flags. */ + +#define HDR_MANIP_IPV6_TC 0x80000000 + /**< update Traffic Class address with the given value + * ('trafficClass' field of + * t_FmPcdManipHdrFieldUpdateIpv6) + */ +#define HDR_MANIP_IPV6_HL 0x40000000 + /**< Decrement Hop Limit by 1 */ +#define HDR_MANIP_IPV6_SRC 0x20000000 + /**< update IP source address with the given value + * ('src' field of t_FmPcdManipHdrFieldUpdateIpv6) + */ +#define HDR_MANIP_IPV6_DST 0x10000000 + /**< update IP destination address with the given value + * ('dst' field of t_FmPcdManipHdrFieldUpdateIpv6) + */ + +typedef hdr_manip_flags_t tcp_udp_hdr_manip_update_flags_t; + /**< TCP/UDP protocol HMan update command flags. */ + +#define HDR_MANIP_TCP_UDP_SRC 0x80000000 + /**< update TCP/UDP source address with the given value + * ('src' field of t_FmPcdManipHdrFieldUpdateTcpUdp) + */ +#define HDR_MANIP_TCP_UDP_DST 0x40000000 + /**< update TCP/UDP destination address with the given value + * ('dst' field of t_FmPcdManipHdrFieldUpdateTcpUdp) + */ +#define HDR_MANIP_TCP_UDP_CHECKSUM 0x20000000 + /**< update TCP/UDP checksum */ + +/* @} */ + +/* + * @Description A type used for returning the order of the key extraction. + * each value in this array represents the index of the + * extraction command as defined by the user in the + * initialization extraction array. The valid size of this array + * is the user define number of extractions required (also marked + * by the second '0' in this array). + */ +typedef uint8_t t_fm_pcd_kg_key_order[FM_PCD_KG_MAX_NUM_OF_EXTRACTS_PER_KEY]; + +/* + * @Collection Definitions for CC statistics + */ +#define FM_PCD_CC_STATS_MAX_NUM_OF_FLR 10 + /* Maximal supported number of frame length ranges */ +#define FM_PCD_CC_STATS_FLR_SIZE 2 + /* Size in bytes of a frame length range limit */ +#define FM_PCD_CC_STATS_COUNTER_SIZE 4 + /* Size in bytes of a frame length range counter */ +/* @} */ + +/* + * @Description Parameters for defining CC keys parameters + * The driver supports two methods for CC node allocation: + * dynamic and static. Static mode was created in order to + * prevent runtime alloc/free of FMan memory (MURAM), which may + * cause fragmentation; in this mode, the driver automatically + * allocates the memory according to 'max_num_of_keys' parameter. + * The driver calculates the maximal memory size that may be used + * for this CC-Node taking into consideration 'mask_support' and + * 'statistics_mode' parameters. When 'action' = + * e_FM_PCD_ACTION_INDEXED_LOOKUP in the extraction parameters of + * this node, 'max_num_of_keys' must be equal to 'num_of_keys'. + * In dynamic mode, 'max_num_of_keys' must be zero. At + * initialization, all required structures are allocated + * according to 'num_of_keys' parameter. During runtime + * modification, these structures are re-allocated according to + * the updated number of keys. + * + * Please note that 'action' and 'icIndxMask' mentioned in the + * specific parameter explanations are passed in the extraction + * parameters of the node (fields of + * extractCcParams.extractNonHdr). + */ +typedef struct t_keys_params { + uint16_t max_num_of_keys; + /**< Maximum number of keys that will (ever) be used in this + * CC-Node; A value of zero may be used for dynamic memory + * allocation. + */ + bool mask_support; + /**< This parameter is relevant only if a node is initialized + * with 'action' = e_FM_PCD_ACTION_EXACT_MATCH and + * max_num_of_keys > 0; Should be TRUE to reserve table memory + * for key masks, even if initial keys do not contain masks, or + * if the node was initialized as 'empty' (without keys); this + * will allow user to add keys with masks at runtime. + * NOTE that if user want to use only global-masks (i.e. one + * common mask for all the entries within this table, this + * parameter should set to 'FALSE'. + */ + ioc_fm_pcd_cc_stats_mode statistics_mode; + /**< Determines the supported statistics mode for all node's + * keys. To enable statistics gathering, statistics should be + * enabled per every key, using 'statisticsEn' in next engine + * parameters structure of that key; If 'max_num_of_keys' is + * set, all required structures will be preallocated for all + * keys. + */ + uint16_t frame_length_ranges[FM_PCD_CC_STATS_MAX_NUM_OF_FLR]; + /**< Relevant only for 'RMON' statistics mode (this feature is + * supported only on B4860 device); Holds a list of programmable + * thresholds - for each received frame, its length in bytes is + * examined against these range thresholds and the appropriate + * counter is incremented by 1 - for example, to belong to range + * i, the following should hold: range i-1 threshold < frame + * length <= range i threshold. Each range threshold must be + * larger then its preceding range threshold, and last range + * threshold must be 0xFFFF. + */ + uint16_t num_of_keys; + /**< Number of initial keys; Note that in case of 'action' = + * e_FM_PCD_ACTION_INDEXED_LOOKUP, this field should be + * power-of-2 of the number of bits that are set in 'icIndxMask' + */ + uint8_t key_size; + /**< Size of key - for extraction of type FULL_FIELD, 'key_size' + * has to be the standard size of the selected key; For other + * extraction types, 'key_size' has to be as size of extraction; + * When 'action' = e_FM_PCD_ACTION_INDEXED_LOOKUP, 'key_size' + * must be 2. + */ + ioc_fm_pcd_cc_key_params_t key_params[FM_PCD_MAX_NUM_OF_KEYS]; + /**< An array with 'num_of_keys' entries, each entry specifies + * the corresponding key parameters; When 'action' = + * e_FM_PCD_ACTION_EXACT_MATCH, this value must not exceed 255 + * (FM_PCD_MAX_NUM_OF_KEYS-1) as the last entry is saved for the + * 'miss' entry. + */ + ioc_fm_pcd_cc_next_engine_params_t cc_next_engine_params_for_miss; + /**< Parameters for defining the next engine when a key is not + * matched; Not relevant if action = + * e_FM_PCD_ACTION_INDEXED_LOOKUP. + */ +} t_keys_params; + +/* + * @Description Parameters for defining custom header manipulation for generic + * field replacement + */ +typedef struct ioc_fm_pcd_manip_hdr_custom_gen_field_replace { + uint8_t src_offset; + /**< Location of new data - Offset from Parse Result + * (>= 16, src_offset+size <= 32, ) + */ + uint8_t dst_offset; + /**< Location of data to be overwritten - Offset from + * start of frame (dst_offset + size <= 256). + */ + uint8_t size; + /**< The number of bytes (<=16) to be replaced */ + uint8_t mask; + /**< Optional 1 byte mask. Set to select bits for + * replacement (1 - bit will be replaced); Clear to use + * field as is. + */ + uint8_t mask_offset; + /**< Relevant if mask != 0; Mask offset within the + * replaces "size" + */ +} ioc_fm_pcd_manip_hdr_custom_gen_field_replace; + +/* + * @Function fm_pcd_net_env_characteristics_set + * + * @Description Define a set of Network Environment Characteristics. + * + * When setting an environment it is important to understand its + * application. It is not meant to describe the flows that will + * run on the ports using this environment, but what the user + * means TO DO with the PCD mechanisms in order to + * parse-classify-distribute those frames. + * By specifying a distinction unit, the user means it would use + * that option for distinction between frames at either a KeyGen + * scheme or a coarse classification action descriptor. Using + * interchangeable headers to define a unit means that the user + * is indifferent to which of the interchangeable headers is + * present in the frame, and wants the distinction to be based on + * the presence of either one of them. + * + * Depending on context, there are limitations to the use of + * environments. A port using the PCD functionality is bound to + * an environment. Some or even all ports may share an + * environment but also an environment per port is possible. When + * initializing a scheme, a classification plan group (see + * below), or a coarse classification tree, one of the + * initialized environments must be stated and related to. When a + * port is bound to a scheme, a classification plan group, or a + * coarse classification tree, it MUST be bound to the same + * environment. + * + * The different PCD modules, may relate (for flows definition) + * ONLY on distinction units as defined by their environment. + * When initializing a scheme for example, it may not choose to + * select IPV4 as a match for recognizing flows unless it was + * defined in the relating environment. In fact, to guide the + * user through the configuration of the PCD, each module's + * characterization in terms of flows is not done using protocol + * names, but using environment indexes. + * + * In terms of HW implementation, the list of distinction units + * sets the LCV vectors and later used for match vector, + * classification plan vectors and coarse classification + * indexing. + * + * @Param[in] h_fm_pcd FM PCD module descriptor. + * @Param[in] p_netenv_params A structure of parameters for the + * initialization of the network + * environment. + * + * @Return A handle to the initialized object on success; NULL code + * otherwise. + * + * @Cautions Allowed only following fm_pcd_init(). + */ +t_handle fm_pcd_net_env_characteristics_set(t_handle h_fm_pcd, + ioc_fm_pcd_net_env_params_t *p_netenv_params); + +/* + * @Function fm_pcd_net_env_characteristics_delete + * + * @Description Deletes a set of Network Environment Characteristics. + * + * @Param[in] h_net_env A handle to the Network environment. + * + * @Return E_OK on success; Error code otherwise. + */ +uint32_t fm_pcd_net_env_characteristics_delete(t_handle h_net_env); + +/* + * @Function fm_pcd_kg_scheme_set + * + * @Description Initializing or modifying and enabling a scheme for the + * KeyGen. This routine should be called for adding or modifying + * a scheme. When a scheme needs modifying, the API requires that + * it will be rewritten. In such a case 'modify' should be TRUE. + * If the routine is called for a valid scheme and 'modify' is + * FALSE, it will return error. + * + * @Param[in] h_fm_pcd If this is a new scheme - A handle to an + * FM PCD Module. Otherwise NULL (ignored + * by driver). + * @Param[in,out] p_scheme_params A structure of parameters for defining + * the scheme + * + * @Return A handle to the initialized scheme on success; NULL code + * otherwise. When used as "modify" (rather than for setting a + * new scheme), p_scheme_params->id.h_scheme will return NULL if + * action fails due to scheme BUSY state. + * + * @Cautions Allowed only following fm_pcd_init(). + */ +t_handle fm_pcd_kg_scheme_set(t_handle h_fm_pcd, + ioc_fm_pcd_kg_scheme_params_t *p_scheme_params); + +/* + * @Function fm_pcd_kg_scheme_delete + * + * @Description Deleting an initialized scheme. + * + * @Param[in] h_scheme scheme handle as returned by + * fm_pcd_kg_scheme_set() + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_pcd_init() & fm_pcd_kg_scheme_set(). + */ +uint32_t fm_pcd_kg_scheme_delete(t_handle h_scheme); + +/* + * @Function fm_pcd_kg_scheme_get_counter + * + * @Description Reads scheme packet counter. + * + * @Param[in] h_scheme scheme handle as returned by + * fm_pcd_kg_scheme_set(). + * + * @Return Counter's current value. + * + * @Cautions Allowed only following fm_pcd_init() & fm_pcd_kg_scheme_set(). + */ +uint32_t fm_pcd_kg_scheme_get_counter(t_handle h_scheme); + +/* + * @Function fm_pcd_kg_scheme_set_counter + * + * @Description Writes scheme packet counter. + * + * @Param[in] h_scheme scheme handle as returned by + * fm_pcd_kg_scheme_set(). + * @Param[in] value New scheme counter value - typically '0' for + * resetting the counter. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_pcd_init() & fm_pcd_kg_scheme_set(). + */ +uint32_t fm_pcd_kg_scheme_set_counter(t_handle h_scheme, + uint32_t value); + +/* + * @Function fm_pcd_plcr_profile_set + * + * @Description Sets a profile entry in the policer profile table. + * The routine overrides any existing value. + * + * @Param[in] h_fm_pcd A handle to an FM PCD Module. + * @Param[in] p_profile A structure of parameters for defining a + * policer profile entry. + * + * @Return A handle to the initialized object on success; NULL code + * otherwise. When used as "modify" (rather than for setting a + * new profile), p_profile->id.h_profile will return NULL if + * action fails due to profile BUSY state. + * + * @Cautions Allowed only following fm_pcd_init(). + */ +t_handle fm_pcd_plcr_profile_set(t_handle h_fm_pcd, + ioc_fm_pcd_plcr_profile_params_t *p_profile); + +/* + * @Function fm_pcd_plcr_profile_delete + * + * @Description Delete a profile entry in the policer profile table. + * The routine set entry to invalid. + * + * @Param[in] h_profile A handle to the profile. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_pcd_init(). + */ +uint32_t fm_pcd_plcr_profile_delete(t_handle h_profile); + +/* + * @Function fm_pcd_plcr_profile_get_counter + * + * @Description Sets an entry in the classification plan. + * The routine overrides any existing value. + * + * @Param[in] h_profile A handle to the profile. + * @Param[in] counter Counter selector. + * + * @Return specific counter value. + * + * @Cautions Allowed only following fm_pcd_init(). + */ +uint32_t fm_pcd_plcr_profile_get_counter(t_handle h_profile, + ioc_fm_pcd_plcr_profile_counters counter); + +/* + * @Function fm_pcd_plcr_profile_set_counter + * + * @Description Sets an entry in the classification plan. + * The routine overrides any existing value. + * + * @Param[in] h_profile A handle to the profile. + * @Param[in] counter Counter selector. + * @Param[in] value value to set counter with. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_pcd_init(). + */ +uint32_t fm_pcd_plcr_profile_set_counter(t_handle h_profile, + ioc_fm_pcd_plcr_profile_counters counter, + uint32_t value); + +/* + * @Function fm_pcd_cc_root_build + * + * @Description This routine must be called to define a complete coarse + * classification tree. This is the way to define coarse + * classification to a certain flow - the KeyGen schemes may + * point only to trees defined in this way. + * + * @Param[in] h_fm_pcd FM PCD module descriptor. + * @Param[in] p_params A structure of parameters to define the tree. + * + * @Return A handle to the initialized object on success; NULL code + * otherwise. + * + * @Cautions Allowed only following fm_pcd_init(). + */ +t_handle fm_pcd_cc_root_build(t_handle h_fm_pcd, + ioc_fm_pcd_cc_tree_params_t *p_params); + +/* + * @Function fm_pcd_cc_root_delete + * + * @Description Deleting an built tree. + * + * @Param[in] h_cc_tree A handle to a CC tree. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_pcd_init(). + */ +uint32_t fm_pcd_cc_root_delete(t_handle h_cc_tree); + +/* + * @Function fm_pcd_cc_root_modify_next_engine + * + * @Description Modify the Next Engine Parameters in the entry of the tree. + * + * @Param[in] h_cc_tree A handle to the tree + * @Param[in] grp_id A Group index in the tree + * @Param[in] index Entry index in the group + * defined by grp_id + * @Param[in] p_fm_pcd_cc_next_engine Pointer to new next + * engine parameters + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following FM_PCD_CcBuildTree(). + */ +uint32_t fm_pcd_cc_root_modify_next_engine(t_handle h_cc_tree, + uint8_t grp_id, + uint8_t index, + ioc_fm_pcd_cc_next_engine_params_t *p_fm_pcd_cc_next_engine); + +/* + * @Function fm_pcd_match_table_set + * + * @Description This routine should be called for each CC (coarse + * classification) node. The whole CC tree should be built bottom + * up so that each node points to already defined nodes. + * + * @Param[in] h_fm_pcd FM PCD module descriptor. + * @Param[in] p_param A structure of parameters defining the CC node + * + * @Return A handle to the initialized object on success; NULL code + * otherwise. + * + * @Cautions Allowed only following fm_pcd_init(). + */ +t_handle fm_pcd_match_table_set(t_handle h_fm_pcd, + ioc_fm_pcd_cc_node_params_t *p_param); + +/* + * @Function fm_pcd_match_table_delete + * + * @Description Deleting an built node. + * + * @Param[in] h_cc_node A handle to a CC node. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_pcd_init(). + */ +uint32_t fm_pcd_match_table_delete(t_handle h_cc_node); + +/* + * @Function fm_pcd_match_table_modify_miss_next_engine + * + * @Description Modify the Next Engine Parameters of the Miss key case of the + * node. + * + * @Param[in] h_cc_node A handle to the node + * @Param[in] p_fm_pcd_cc_next_engine_params Parameters for defining + * next engine + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_pcd_match_table_set(); Not + * relevant in the case the node is of type 'INDEXED_LOOKUP'. + * When configuring nextEngine = e_FM_PCD_CC, note that + * p_fm_pcd_cc_next_engine_params->ccParams.h_cc_node must be + * different from the currently changed table. + * + */ +uint32_t fm_pcd_match_table_modify_miss_next_engine(t_handle h_cc_node, + ioc_fm_pcd_cc_next_engine_params_t *p_fm_pcd_cc_next_engine_params); + +/* + * @Function fm_pcd_match_table_remove_key + * + * @Description Remove the key (including next engine parameters of this key) + * defined by the index of the relevant node. + * + * @Param[in] h_cc_node A handle to the node + * @Param[in] key_index Key index for removing + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_pcd_match_table_set() was called for + * this node and the nodes that lead to it. + */ +uint32_t fm_pcd_match_table_remove_key(t_handle h_cc_node, + uint16_t key_index); + +/* + * @Function fm_pcd_match_table_add_key + * + * @Description Add the key (including next engine parameters of this key in + * the index defined by the key_index. Note that + * 'FM_PCD_LAST_KEY_INDEX' may be used by user that don't care + * about the position of the key in the table - in that case, the + * key will be automatically added by the driver in the last + * available entry. + * + * @Param[in] h_cc_node A handle to the node + * @Param[in] key_index Key index for adding. + * @Param[in] key_size Key size of added key + * @Param[in] p_key_params A pointer to the parameters includes new key + * with Next Engine Parameters + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_pcd_match_table_set() was called for + * this node and the nodes that lead to it. + */ +uint32_t fm_pcd_match_table_add_key(t_handle h_cc_node, + uint16_t key_index, + uint8_t key_size, + ioc_fm_pcd_cc_key_params_t *p_key_params); + +/* + * @Function fm_pcd_match_table_modify_next_engine + * + * @Description Modify the Next Engine Parameters in the relevant key entry of + * the node. + * + * @Param[in] h_cc_node A handle to the node + * @Param[in] key_index Key index for Next + * Engine modifications + * @Param[in] p_fm_pcd_cc_next_engine Parameters for defining + * next engine + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_pcd_match_table_set(). When + * configuring nextEngine = e_FM_PCD_CC, note that + * p_fm_pcd_cc_next_engine_params->ccParams.h_cc_node must be + * different from the currently changed table. + * + */ +uint32_t fm_pcd_match_table_modify_next_engine(t_handle h_cc_node, + uint16_t key_index, + ioc_fm_pcd_cc_next_engine_params_t *p_fm_pcd_cc_next_engine); + +/* + * @Function fm_pcd_match_table_modify_key_and_next_engine + * + * @Description Modify the key and Next Engine Parameters of this key in the + * index defined by the key_index. + * + * @Param[in] h_cc_node A handle to the node + * @Param[in] key_index Key index for adding + * @Param[in] key_size Key size of added key + * @Param[in] p_key_params A pointer to the parameters includes + * modified key and modified Next Engine + * Params + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_pcd_match_table_set() was called for + * this node and the nodes that lead to it. When configuring + * nextEngine = e_FM_PCD_CC, note that + * p_fm_pcd_cc_next_engine_params->ccParams.h_cc_node must be + * different from the currently changed table. + */ +uint32_t fm_pcd_match_table_modify_key_and_next_engine(t_handle h_cc_node, + uint16_t key_index, + uint8_t key_size, + ioc_fm_pcd_cc_key_params_t *p_key_params); + +/* + * @Function fm_pcd_match_table_modify_key + * + * @Description Modify the key in the index defined by the key_index. + * + * @Param[in] h_cc_node A handle to the node + * @Param[in] key_index Key index for adding + * @Param[in] key_size Key size of added key + * @Param[in] p_key A pointer to the new key + * @Param[in] p_mask A pointer to the new mask if relevant, + * otherwise pointer to NULL + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_pcd_match_table_set() was called for + * this node and the nodes that lead to it. + */ +uint32_t fm_pcd_match_table_modify_key(t_handle h_cc_node, + uint16_t key_index, + uint8_t key_size, + uint8_t *p_key, + uint8_t *p_mask); + +/* + * @Function fm_pcd_match_table_find_nremove_key + * + * @Description Remove the key (including next engine parameters of this key) + * defined by the key and mask. Note that this routine will + * search the node to locate the index of the required key + * (& mask) to remove. + * + * @Param[in] h_cc_node A handle to the node + * @Param[in] key_size Key size of the one to remove. + * @Param[in] p_key A pointer to the requested key to remove. + * @Param[in] p_mask A pointer to the mask if relevant, + * otherwise pointer to NULL + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_pcd_match_table_set() was called for + * this node and the nodes that lead to it. + */ +uint32_t fm_pcd_match_table_find_nremove_key(t_handle h_cc_node, + uint8_t key_size, + uint8_t *p_key, + uint8_t *p_mask); + +/* + * @Function fm_pcd_match_table_find_nmodify_next_engine + * + * @Description Modify the Next Engine Parameters in the relevant key entry of + * the node. Note that this routine will search the node to + * locate the index of the required key (& mask) to modify. + * + * @Param[in] h_cc_node A handle to the node + * @Param[in] key_size Key size of the one to modify. + * @Param[in] p_key A pointer to the requested key to modify + * @Param[in] p_mask A pointer to the mask if relevant, + * otherwise pointer to NULL + * @Param[in] p_fm_pcd_cc_next_engine Parameters for defining + * next engine + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_pcd_match_table_set(). When + * configuring nextEngine = e_FM_PCD_CC, note that + * p_fm_pcd_cc_next_engine_params->ccParams.h_cc_node must be + * different from the currently changed table. + */ +uint32_t fm_pcd_match_table_find_nmodify_next_engine(t_handle h_cc_node, + uint8_t key_size, + uint8_t *p_key, + uint8_t *p_mask, + ioc_fm_pcd_cc_next_engine_params_t *p_fm_pcd_cc_next_engine); + +/* + * @Function fm_pcd_match_table_find_nmodify_key_and_next_engine + * + * @Description Modify the key and Next Engine Parameters of this key in the + * index defined by the key_index. Note that this routine will + * search the node to locate the index of the required key + * (& mask) to modify. + * + * @Param[in] h_cc_node A handle to the node + * @Param[in] key_size Key size of the one to modify. + * @Param[in] p_key A pointer to the requested key to modify + * @Param[in] p_mask A pointer to the mask if relevant, + * otherwise pointer to NULL + * @Param[in] p_key_params A pointer to the parameters includes + * modified key and modified Next Engine + * Params + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_pcd_match_table_set() was called for + * this node and the nodes that lead to it. + * When configuring nextEngine = e_FM_PCD_CC, note that + * p_fm_pcd_cc_next_engine_params->ccParams.h_cc_node must be + * different from the currently changed table. + */ +uint32_t fm_pcd_match_table_find_nmodify_key_and_next_engine(t_handle h_cc_node, + uint8_t key_size, + uint8_t *p_key, + uint8_t *p_mask, + ioc_fm_pcd_cc_key_params_t *p_key_params); + +/* + * @Function fm_pcd_match_table_find_nmodify_key + * + * @Description Modify the key in the index defined by the key_index. Note + * that this routine will search the node to locate the index of + * the required key (& mask) to modify. + * + * @Param[in] h_cc_node A handle to the node + * @Param[in] key_size Key size of the one to modify. + * @Param[in] p_key A pointer to the requested key to modify. + * @Param[in] p_mask A pointer to the mask if relevant, + * otherwise pointer to NULL + * @Param[in] p_new_key A pointer to the new key + * @Param[in] p_new_mask A pointer to the new mask if relevant, + * otherwise pointer to NULL + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_pcd_match_table_set() was called for + * this node and the nodes that lead to it. + */ +uint32_t fm_pcd_match_table_find_nmodify_key(t_handle h_cc_node, + uint8_t key_size, + uint8_t *p_key, + uint8_t *p_mask, + uint8_t *p_new_key, + uint8_t *p_new_mask); + +/* + * @Function fm_pcd_match_table_get_key_counter + * + * @Description This routine may be used to get a counter of specific key in a + * CC Node; This counter reflects how many frames passed that + * were matched this key. + * + * @Param[in] h_cc_node A handle to the node + * @Param[in] key_index Key index for adding + * + * @Return The specific key counter. + * + * @Cautions Allowed only following fm_pcd_match_table_set(). + */ +uint32_t fm_pcd_match_table_get_key_counter(t_handle h_cc_node, + uint16_t key_index); + +/* + * @Function fm_pcd_match_table_get_key_statistics + * + * @Description This routine may be used to get statistics counters of + * specific key in a CC Node. + * + * If 'e_FM_PCD_CC_STATS_MODE_FRAME' and + * 'e_FM_PCD_CC_STATS_MODE_BYTE_AND_FRAME' were set for this + * node, these counters reflect how many frames passed that were + * matched this key; The total frames count will be returned in + * the counter of the first range (as only one frame length range + * was defined). If 'e_FM_PCD_CC_STATS_MODE_RMON' was set for + * this node, the total frame count will be separated to frame + * length counters, based on provided frame length ranges. + * + * @Param[in] h_cc_node A handle to the node + * @Param[in] key_index Key index for adding + * @Param[out] p_key_statistics Key statistics counters + * + * @Return The specific key statistics. + * + * @Cautions Allowed only following fm_pcd_match_table_set(). + */ +uint32_t fm_pcd_match_table_get_key_statistics(t_handle h_cc_node, + uint16_t key_index, + ioc_fm_pcd_cc_key_statistics_t *p_key_statistics); + +/* + * @Function fm_pcd_match_table_get_miss_statistics + * + * @Description This routine may be used to get statistics counters of miss + * entry in a CC Node. + * + * If 'e_FM_PCD_CC_STATS_MODE_FRAME' and + * 'e_FM_PCD_CC_STATS_MODE_BYTE_AND_FRAME' were set for this + * node, these counters reflect how many frames were not matched + * to any existing key and therefore passed through the miss + * entry; The total frames count will be returned in the counter + * of the first range (as only one frame length range was + * defined). + * + * @Param[in] h_cc_node A handle to the node + * @Param[out] p_miss_statistics Statistics counters for 'miss' + * + * @Return The statistics for 'miss'. + * + * @Cautions Allowed only following fm_pcd_match_table_set(). + */ +uint32_t fm_pcd_match_table_get_miss_statistics(t_handle h_cc_node, + ioc_fm_pcd_cc_key_statistics_t *p_miss_statistics); + +/* + * @Function fm_pcd_match_table_find_nget_key_statistics + * + * @Description This routine may be used to get statistics counters of + * specific key in a CC Node. + * + * If 'e_FM_PCD_CC_STATS_MODE_FRAME' and + * 'e_FM_PCD_CC_STATS_MODE_BYTE_AND_FRAME' were set for this + * node, these counters reflect how many frames passed that were + * matched this key; The total frames count will be returned in + * the counter of the first range (as only one frame length range + * was defined). If 'e_FM_PCD_CC_STATS_MODE_RMON' was set for + * this node, the total frame count will be separated to frame + * length counters, based on provided frame length ranges. + * Note that this routine will search the node to locate the + * index of the required key based on received key parameters. + * + * @Param[in] h_cc_node A handle to the node + * @Param[in] key_size Size of the requested key + * @Param[in] p_key A pointer to the requested key + * @Param[in] p_mask A pointer to the mask if relevant, + * otherwise pointer to NULL + * @Param[out] p_key_statistics Key statistics counters + * + * @Return The specific key statistics. + * + * @Cautions Allowed only following fm_pcd_match_table_set(). + */ +uint32_t fm_pcd_match_table_find_nget_key_statistics(t_handle h_cc_node, + uint8_t key_size, + uint8_t *p_key, + uint8_t *p_mask, + ioc_fm_pcd_cc_key_statistics_t *p_key_statistics); + +/* + * @Function fm_pcd_match_table_get_next_engine + * + * @Description Gets NextEngine of the relevant key_index. + * + * @Param[in] h_cc_node A handle to the node. + * @Param[in] key_index key_index in the + * relevant node. + * @Param[out] p_fm_pcd_cc_next_engine_params here updated + * nextEngine parameters + * for the relevant + * key_index of the CC Node + * received as parameter to + * this function + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_pcd_init(). + */ +uint32_t fm_pcd_match_table_get_next_engine(t_handle h_cc_node, + uint16_t key_index, + ioc_fm_pcd_cc_next_engine_params_t *p_fm_pcd_cc_next_engine_params); + +/* + * @Function fm_pcd_match_table_get_indexed_hash_bucket + * + * @Description This routine simulates KeyGen operation on the provided key + * and calculates to which hash bucket it will be mapped. + * + * @Param[in] h_cc_node A handle to the node. + * @Param[in] kg_key_size Key size as it was configured in + * the KG scheme that leads to this + * hash. + * @Param[in] p_kg_key Pointer to the key; must be like + * the key that the KG is + * generated, i.e. the same + * extraction and with mask if + * exist. + * @Param[in] kg_hash_shift Hash-shift as it was configured + * in the KG scheme that leads to + * this hash. + * @Param[out] p_cc_node_bucket_handle Pointer to the bucket of the + * provided key. + * @Param[out] p_bucket_index Index to the bucket of the + * provided key + * @Param[out] p_last_index Pointer to last index in the + * bucket of the provided key. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_pcd_hash_table_set() + */ +uint32_t fm_pcd_match_table_get_indexed_hash_bucket(t_handle h_cc_node, + uint8_t kg_key_size, + uint8_t *p_kg_key, + uint8_t kg_hash_shift, + t_handle *p_cc_node_bucket_handle, + uint8_t *p_bucket_index, + uint16_t *p_last_index); + +/* + * @Function fm_pcd_hash_table_set + * + * @Description This routine initializes a hash table structure. + * KeyGen hash result determines the hash bucket. + * Next, KeyGen key is compared against all keys of this bucket + * (exact match). + * Number of sets (number of buckets) of the hash equals to the + * number of 1-s in 'hashResMask' in the provided parameters. + * Number of hash table ways is then calculated by dividing + * 'max_num_of_keys' equally between the hash sets. This is the + * maximal number of keys that a hash bucket may hold. + * The hash table is initialized empty and keys may be added to + * it following the initialization. Keys masks are not supported + * in current hash table implementation. + * The initialized hash table can be integrated as a node in a CC + * tree. + * + * @Param[in] h_fm_pcd FM PCD module descriptor. + * @Param[in] p_param A structure of parameters defining the hash + * table + * + * @Return A handle to the initialized object on success; NULL code + * otherwise. + * + * @Cautions Allowed only following fm_pcd_init(). + */ +t_handle fm_pcd_hash_table_set(t_handle h_fm_pcd, + ioc_fm_pcd_hash_table_params_t *p_param); + +/* + * @Function fm_pcd_hash_table_delete + * + * @Description This routine deletes the provided hash table and released all + * its allocated resources. + * + * @Param[in] h_hash_tbl A handle to a hash table + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_pcd_hash_table_set(). + */ +uint32_t fm_pcd_hash_table_delete(t_handle h_hash_tbl); + +/* + * @Function fm_pcd_hash_table_add_key + * + * @Description This routine adds the provided key (including next engine + * parameters of this key) to the hash table. + * The key is added as the last key of the bucket that it is + * mapped to. + * + * @Param[in] h_hash_tbl A handle to a hash table + * @Param[in] key_size Key size of added key + * @Param[in] p_key_params A pointer to the parameters includes + * new key with next engine parameters; The pointer + * to the key mask must be NULL, as masks are not + * supported in hash table implementation. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_pcd_hash_table_set(). + */ +uint32_t fm_pcd_hash_table_add_key(t_handle h_hash_tbl, + uint8_t key_size, + ioc_fm_pcd_cc_key_params_t *p_key_params); + +/* + * @Function fm_pcd_hash_table_remove_key + * + * @Description This routine removes the requested key (including next engine + * parameters of this key) from the hash table. + * + * @Param[in] h_hash_tbl A handle to a hash table + * @Param[in] key_size Key size of the one to remove. + * @Param[in] p_key A pointer to the requested key to remove. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_pcd_hash_table_set(). + */ +uint32_t fm_pcd_hash_table_remove_key(t_handle h_hash_tbl, + uint8_t key_size, + uint8_t *p_key); + +/* + * @Function fm_pcd_hash_table_modify_next_engine + * + * @Description This routine modifies the next engine for the provided key. + * The key should be previously added to the hash table. + * + * @Param[in] h_hash_tbl A handle to a hash table + * @Param[in] key_size Key size of the key to modify. + * @Param[in] p_key A pointer to the requested key + * to modify. + * @Param[in] p_fm_pcd_cc_next_engine A structure for defining + * new next engine parameters. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_pcd_hash_table_set(). + * When configuring nextEngine = e_FM_PCD_CC, note that + * p_fm_pcd_cc_next_engine_params->ccParams.h_cc_node must be + * different from the currently changed table. + */ +uint32_t fm_pcd_hash_table_modify_next_engine(t_handle h_hash_tbl, + uint8_t key_size, + uint8_t *p_key, + ioc_fm_pcd_cc_next_engine_params_t *p_fm_pcd_cc_next_engine); + +/* + * @Function fm_pcd_hash_table_modify_miss_next_engine + * + * @Description This routine modifies the next engine on key match miss. + * + * @Param[in] h_hash_tbl A handle to a hash table + * @Param[in] p_fm_pcd_cc_next_engine A structure for defining + * new next engine parameters. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_pcd_hash_table_set(). + * When configuring nextEngine = e_FM_PCD_CC, note that + * p_fm_pcd_cc_next_engine_params->ccParams.h_cc_node must be + * different from the currently changed table. + */ +uint32_t fm_pcd_hash_table_modify_miss_next_engine(t_handle h_hash_tbl, + ioc_fm_pcd_cc_next_engine_params_t *p_fm_pcd_cc_next_engine); + +/* + * @Function fm_pcd_hash_table_get_miss_next_engine + * + * @Description Gets NextEngine in case of key match miss. + * + * @Param[in] h_hash_tbl A handle to a hash table + * @Param[out] p_fm_pcd_cc_next_engine_params Next engine parameters + * for the specified hash + * table. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_pcd_hash_table_set(). + */ +uint32_t fm_pcd_hash_table_get_miss_next_engine(t_handle h_hash_tbl, + ioc_fm_pcd_cc_next_engine_params_t *p_fm_pcd_cc_next_engine_params); + +/* + * @Function fm_pcd_hash_table_find_nget_key_statistics + * + * @Description This routine may be used to get statistics counters of + * specific key in a hash table. + * + * If 'e_FM_PCD_CC_STATS_MODE_FRAME' and + * 'e_FM_PCD_CC_STATS_MODE_BYTE_AND_FRAME' were set for this + * node, these counters reflect how many frames passed that were + * matched this key; The total frames count will be returned in + * the counter of the first range (as only one frame length range + * was defined). If 'e_FM_PCD_CC_STATS_MODE_RMON' was set for + * this node, the total frame count will be separated to frame + * length counters, based on provided frame length ranges. Note + * that this routine will identify the bucket of this key in the + * hash table and will search the bucket to locate the index of + * the required key based on received key parameters. + * + * @Param[in] h_hash_tbl A handle to a hash table + * @Param[in] key_size Size of the requested key + * @Param[in] p_key A pointer to the requested key + * @Param[out] p_key_statistics Key statistics counters + * + * @Return The specific key statistics. + * + * @Cautions Allowed only following fm_pcd_hash_table_set(). + */ +uint32_t fm_pcd_hash_table_find_nget_key_statistics(t_handle h_hash_tbl, + uint8_t key_size, + uint8_t *p_key, + ioc_fm_pcd_cc_key_statistics_t *p_key_statistics); + +/* + * @Function fm_pcd_hash_table_get_miss_statistics + * + * @Description This routine may be used to get statistics counters of 'miss' + * entry of the a hash table. + * + * If 'e_FM_PCD_CC_STATS_MODE_FRAME' and + * 'e_FM_PCD_CC_STATS_MODE_BYTE_AND_FRAME' were set for this + * node, these counters reflect how many frames were not matched + * to any existing key and therefore passed through the miss + * entry; + * + * @Param[in] h_hash_tbl A handle to a hash table + * @Param[out] p_miss_statistics Statistics counters for 'miss' + * + * @Return The statistics for 'miss'. + * + * @Cautions Allowed only following fm_pcd_hash_table_set(). + */ +uint32_t fm_pcd_hash_table_get_miss_statistics(t_handle h_hash_tbl, + ioc_fm_pcd_cc_key_statistics_t *p_miss_statistics); + +/* + * @Function fm_pcd_manip_node_set + * + * @Description This routine should be called for defining a manipulation + * node. A manipulation node must be defined before the CC node + * that precedes it. + * + * @Param[in] h_fm_pcd FM PCD module descriptor. + * @Param[in] p_fm_pcd_manip_params A structure of parameters + * defining the manipulation + * + * @Return A handle to the initialized object on success; NULL code + * otherwise. + * + * @Cautions Allowed only following fm_pcd_init(). + */ +t_handle fm_pcd_manip_node_set(t_handle h_fm_pcd, + ioc_fm_pcd_manip_params_t *p_fm_pcd_manip_params); + +/* + * @Function fm_pcd_manip_node_delete + * + * @Description Delete an existing manipulation node. + * + * @Param[in] h_manip_node A handle to a manipulation node. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_pcd_manip_node_set(). + */ +uint32_t fm_pcd_manip_node_delete(t_handle h_manip_node); + +/* + * @Function fm_pcd_manip_get_statistics + * + * @Description Retrieve the manipulation statistics. + * + * @Param[in] h_manip_node A handle to a manipulation node. + * @Param[out] p_fm_pcd_manip_stats A structure for retrieving the + * manipulation statistics + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_pcd_manip_node_set(). + */ +uint32_t fm_pcd_manip_get_statistics(t_handle h_manip_node, + ioc_fm_pcd_manip_stats_t *p_fm_pcd_manip_stats); + +/* + * @Function fm_pcd_manip_node_replace + * + * @Description Change existing manipulation node to be according to new + * requirement. + * + * @Param[in] h_manip_node A handle to a manipulation node. + * @Param[out] p_manip_params A structure of parameters defining the + * change requirement + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_pcd_manip_node_set(). + */ +uint32_t fm_pcd_manip_node_replace(t_handle h_manip_node, +ioc_fm_pcd_manip_params_t *p_manip_params); + +/* + * @Function fm_pcd_frm_replic_set_group + * + * @Description Initialize a Frame Replicator group. + * + * @Param[in] h_fm_pcd FM PCD module descriptor. + * @Param[in] p_frm_replic_group_param A structure of parameters for + * the initialization of the frame + * replicator group. + * + * @Return A handle to the initialized object on success; NULL code + * otherwise. + * + * @Cautions Allowed only following fm_pcd_init(). + */ +t_handle fm_pcd_frm_replic_set_group(t_handle h_fm_pcd, + ioc_fm_pcd_frm_replic_group_params_t *p_frm_replic_group_param); + +/* + * @Function fm_pcd_frm_replic_delete_group + * + * @Description Delete a Frame Replicator group. + * + * @Param[in] h_frm_replic_group A handle to the frame replicator group. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_pcd_frm_replic_set_group(). + */ +uint32_t fm_pcd_frm_replic_delete_group(t_handle h_frm_replic_group); + +/* + * @Function fm_pcd_frm_replic_add_member + * + * @Description Add the member in the index defined by the member_index. + * + * @Param[in] h_frm_replic_group A handle to the frame replicator group. + * @Param[in] member_index member index for adding. + * @Param[in] p_member_params A pointer to the new member parameters. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_pcd_frm_replic_set_group() of this + * group. + */ +uint32_t fm_pcd_frm_replic_add_member(t_handle h_frm_replic_group, + uint16_t member_index, + ioc_fm_pcd_cc_next_engine_params_t *p_member_params); + +/* + * @Function fm_pcd_frm_replic_remove_member + * + * @Description Remove the member defined by the index from the relevant + * group. + * + * @Param[in] h_frm_replic_group A handle to the frame replicator group. + * @Param[in] member_index member index for removing. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_pcd_frm_replic_set_group() of this + * group. + */ +uint32_t fm_pcd_frm_replic_remove_member(t_handle h_frm_replic_group, + uint16_t member_index); + +/** @} */ /* end of FM_PCD_Runtime_build_grp group */ +/** @} */ /* end of FM_PCD_Runtime_grp group */ +/** @} */ /* end of FM_PCD_grp group */ +/** @} */ /* end of FM_grp group */ + +#endif /* __FM_PCD_EXT_H */ diff --git a/drivers/net/dpaa/fmlib/fm_port_ext.h b/drivers/net/dpaa/fmlib/fm_port_ext.h new file mode 100644 index 000000000..df7773562 --- /dev/null +++ b/drivers/net/dpaa/fmlib/fm_port_ext.h @@ -0,0 +1,3350 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright 2008-2012 Freescale Semiconductor Inc. + * Copyright 2017-2020 NXP + */ + +#ifndef __FM_PORT_EXT_H +#define __FM_PORT_EXT_H + +#include +#include "ncsw_ext.h" +#include "fm_pcd_ext.h" +#include "fm_ext.h" +#include "net_ext.h" +#include "dpaa_integration.h" + +/* + * @Description FM Port routines + */ + +/* + * + * @Group lnx_ioctl_FM_grp Frame Manager Linux IOCTL API + * + * @Description FM Linux ioctls definitions and enums + * + * @{ + */ + +/* + * @Group lnx_ioctl_FM_PORT_grp FM Port + * + * @Description FM Port API + * + * The FM uses a general module called "port" to represent a Tx + * port (MAC), an Rx port (MAC), offline parsing flow or host + * command flow. There may be up to 17 (may change) ports in an + * FM - 5 Tx ports (4 for the 1G MACs, 1 for the 10G MAC), 5 Rx + * Ports, and 7 Host command/Offline parsing ports. The SW driver + * manages these ports as sub-modules of the FM, i.e. after an FM + * is initialized, its ports may be initialized and operated + * upon. + * + * The port is initialized aware of its type, but other functions + * on a port may be indifferent to its type. When necessary, the + * driver verifies coherency and returns error if applicable. + * + * On initialization, user specifies the port type and it's index + * (relative to the port's type). Host command and Offline + * parsing ports share the same id range, I.e user may not + * initialized host command port 0 and offline parsing port 0. + * + * @{ + */ + +/* + * @Description An enum for defining port PCD modes. + * (Must match enum e_fm_port_pcd_support defined in + * fm_port_ext.h) + * + * This enum defines the superset of PCD engines support - i.e. + * not all engines have to be used, but all have to be enabled. + * The real flow of a specific frame depends on the PCD + * configuration and the frame headers and payload. Note: the + * first engine and the first engine after the parser (if exists) + * should be in order, the order is important as it will define + * the flow of the port. However, as for the rest engines (the + * ones that follows), the order is not important anymore as it + * is defined by the PCD graph itself. + */ +typedef enum ioc_fm_port_pcd_support { + e_IOC_FM_PCD_NONE = 0 + /**< BMI to BMI, PCD is not used */ + , e_IOC_FM_PCD_PRS_ONLY /**< Use only Parser */ + , e_IOC_FM_PCD_PLCR_ONLY /**< Use only Policer */ + , e_IOC_FM_PCD_PRS_PLCR/**< Use Parser and Policer */ + , e_IOC_FM_PCD_PRS_KG /**< Use Parser and Keygen */ + , e_IOC_FM_PCD_PRS_KG_AND_CC + /**< Use Parser, Keygen and Coarse Classification */ + , e_IOC_FM_PCD_PRS_KG_AND_CC_AND_PLCR + /**< Use all PCD engines */ + , e_IOC_FM_PCD_PRS_KG_AND_PLCR + /**< Use Parser, Keygen and Policer */ + , e_IOC_FM_PCD_PRS_CC + /**< Use Parser and Coarse Classification */ + , e_IOC_FM_PCD_PRS_CC_AND_PLCR + /**< Use Parser and Coarse Classification and Policer */ + , e_IOC_FM_PCD_CC_ONLY + /**< Use only Coarse Classification */ +} ioc_fm_port_pcd_support; + +/* + * @Collection FM Frame error + */ +typedef uint32_t ioc_fm_port_frame_err_select_t; + /**< typedef for defining Frame Descriptor errors */ + +/* @} */ + +/* + * @Description An enum for defining Dual Tx rate limiting scale. + * (Must match e_fm_port_dual_rate_limiter_scale_down defined in + * fm_port_ext.h) + */ +typedef enum ioc_fm_port_dual_rate_limiter_scale_down { + e_IOC_FM_PORT_DUAL_RATE_LIMITER_NONE = 0, + /**< Use only single rate limiter*/ + e_IOC_FM_PORT_DUAL_RATE_LIMITER_SCALE_DOWN_BY_2, + /**< Divide high rate limiter by 2 */ + e_IOC_FM_PORT_DUAL_RATE_LIMITER_SCALE_DOWN_BY_4, + /**< Divide high rate limiter by 4 */ + e_IOC_FM_PORT_DUAL_RATE_LIMITER_SCALE_DOWN_BY_8 + /**< Divide high rate limiter by 8 */ +} ioc_fm_port_dual_rate_limiter_scale_down; + +/* + * @Description A structure for defining Tx rate limiting + * (Must match struct t_fm_port_rate_limit defined in + * fm_port_ext.h) + */ +typedef struct ioc_fm_port_rate_limit_t { + uint16_t max_burst_size; + /**< in KBytes for Tx ports, in frames for offline + * parsing ports. (note that for early chips burst size + * is rounded up to a multiply of 1000 frames). + */ + uint32_t rate_limit; + /**< in Kb/sec for Tx ports, in frame/sec for offline + * parsing ports. Rate limit refers to data rate (rather + * than line rate). + */ + ioc_fm_port_dual_rate_limiter_scale_down rate_limit_divider; + /**< For offline parsing ports only. Not-valid for some + * earlier chip revisions + */ +} ioc_fm_port_rate_limit_t; + + +/* + * @Group lnx_ioctl_FM_PORT_runtime_control_grp FM Port Runtime Control + * Unit + * + * @Description FM Port Runtime control unit API functions, definitions and + * enums. + * + * @{ + */ + +/* + * @Description An enum for defining FM Port counters. + * (Must match enum e_fm_port_counters defined in fm_port_ext.h) + */ +typedef enum ioc_fm_port_counters { + e_IOC_FM_PORT_COUNTERS_CYCLE, /**< BMI performance counter */ + e_IOC_FM_PORT_COUNTERS_TASK_UTIL, /**< BMI performance counter */ + e_IOC_FM_PORT_COUNTERS_QUEUE_UTIL, /**< BMI performance counter */ + e_IOC_FM_PORT_COUNTERS_DMA_UTIL, /**< BMI performance counter */ + e_IOC_FM_PORT_COUNTERS_FIFO_UTIL, /**< BMI performance counter */ + e_IOC_FM_PORT_COUNTERS_RX_PAUSE_ACTIVATION, + /**< BMI Rx only performance counter */ + e_IOC_FM_PORT_COUNTERS_FRAME, /**< BMI statistics counter */ + e_IOC_FM_PORT_COUNTERS_DISCARD_FRAME, /**< BMI statistics counter */ + e_IOC_FM_PORT_COUNTERS_DEALLOC_BUF, + /**< BMI deallocate buffer statistics counter */ + e_IOC_FM_PORT_COUNTERS_RX_BAD_FRAME, + /**< BMI Rx only statistics counter */ + e_IOC_FM_PORT_COUNTERS_RX_LARGE_FRAME, + /**< BMI Rx only statistics counter */ + e_IOC_FM_PORT_COUNTERS_RX_FILTER_FRAME, + /**< BMI Rx & OP only statistics counter */ + e_IOC_FM_PORT_COUNTERS_RX_LIST_DMA_ERR, + /**< BMI Rx, OP & HC only statistics counter */ + e_IOC_FM_PORT_COUNTERS_RX_OUT_OF_BUFFERS_DISCARD, + /**< BMI Rx, OP & HC statistics counter */ + e_IOC_FM_PORT_COUNTERS_PREPARE_TO_ENQUEUE_COUNTER, + /**< BMI Rx, OP & HC only statistics counter */ + e_IOC_FM_PORT_COUNTERS_WRED_DISCARD, + /**< BMI OP & HC only statistics counter */ + e_IOC_FM_PORT_COUNTERS_LENGTH_ERR, + /**< BMI non-Rx statistics counter */ + e_IOC_FM_PORT_COUNTERS_UNSUPPRTED_FORMAT, + /**< BMI non-Rx statistics counter */ + e_IOC_FM_PORT_COUNTERS_DEQ_TOTAL,/**< QMI total QM dequeues counter */ + e_IOC_FM_PORT_COUNTERS_ENQ_TOTAL,/**< QMI total QM enqueues counter */ + e_IOC_FM_PORT_COUNTERS_DEQ_FROM_DEFAULT,/**< QMI counter */ + e_IOC_FM_PORT_COUNTERS_DEQ_CONFIRM /**< QMI counter */ +} ioc_fm_port_counters; + +typedef struct ioc_fm_port_bmi_stats_t { + uint32_t cnt_cycle; + uint32_t cnt_task_util; + uint32_t cnt_queue_util; + uint32_t cnt_dma_util; + uint32_t cnt_fifo_util; + uint32_t cnt_rx_pause_activation; + uint32_t cnt_frame; + uint32_t cnt_discard_frame; + uint32_t cnt_dealloc_buf; + uint32_t cnt_rx_bad_frame; + uint32_t cnt_rx_large_frame; + uint32_t cnt_rx_filter_frame; + uint32_t cnt_rx_list_dma_err; + uint32_t cnt_rx_out_of_buffers_discard; + uint32_t cnt_wred_discard; + uint32_t cnt_length_err; + uint32_t cnt_unsupported_format; +} ioc_fm_port_bmi_stats_t; + +/* + * @Description Structure for Port id parameters. + * (Description may be inaccurate; + * must match struct t_fm_port_congestion_grps defined in + * fm_port_ext.h) + * + * Fields commented 'IN' are passed by the port module to be used + * by the FM module. Fields commented 'OUT' will be filled by FM + * before returning to port. + */ +typedef struct ioc_fm_port_congestion_groups_t { + uint16_t num_of_congestion_grps_to_consider; + /**< The number of required congestion groups to define + * the size of the following array + */ + uint8_t congestion_grps_to_consider[FM_NUM_CONG_GRPS]; + /**< An array of CG indexes; Note that the size of the + * array should be 'num_of_congestion_grps_to_consider'. + */ + bool pfc_priorities_enable[FM_NUM_CONG_GRPS][FM_MAX_PFC_PRIO]; + /**< A matrix that represents the map between the CG ids + * defined in 'congestion_grps_to_consider' to the + * priorities mapping array. + */ +} ioc_fm_port_congestion_groups_t; + + +/* + * @Function fm_port_disable + * + * @Description Gracefully disable an FM port. The port will not start new + * tasks after all tasks associated with the port are terminated. + * + * @Return 0 on success; error code otherwise. + * + * @Cautions This is a blocking routine, it returns after port is + * gracefully stopped, i.e. the port will not except new frames, + * but it will finish all frames or tasks which were already + * began + */ +#define FM_PORT_IOC_DISABLE _IO(FM_IOC_TYPE_BASE, FM_PORT_IOC_NUM(1)) + +/* + * @Function fm_port_enable + * + * @Description A runtime routine provided to allow disable/enable of port. + * + * @Return 0 on success; error code otherwise. + */ +#define FM_PORT_IOC_ENABLE _IO(FM_IOC_TYPE_BASE, FM_PORT_IOC_NUM(2)) + +/* + * @Function fm_port_set_rate_limit + * + * @Description Calling this routine enables rate limit algorithm. + * By default, this functionality is disabled. + * + * Note that rate - limit mechanism uses the FM time stamp. + * The selected rate limit specified here would be + * rounded DOWN to the nearest 16M. + * + * May be used for Tx and offline parsing ports only + * + * @Param[in] ioc_fm_port_rate_limit A structure of rate limit + * parameters + * + * @Return 0 on success; error code otherwise. + */ +#define FM_PORT_IOC_SET_RATE_LIMIT \ + IOW(FM_IOC_TYPE_BASE, FM_PORT_IOC_NUM(3), ioc_fm_port_rate_limit_t) + +/* + * @Function fm_port_delete_rate_limit + * + * @Description Calling this routine disables the previously enabled rate + * limit. + * + * May be used for Tx and offline parsing ports only + * + * @Return 0 on success; error code otherwise. + */ +#define FM_PORT_IOC_DELETE_RATE_LIMIT _IO(FM_IOC_TYPE_BASE, FM_PORT_IOC_NUM(5)) +#define FM_PORT_IOC_REMOVE_RATE_LIMIT FM_PORT_IOC_DELETE_RATE_LIMIT + +/* + * @Function fm_port_add_congestion_grps + * + * @Description This routine effects the corresponding Tx port. + * It should be called in order to enable pause frame + * transmission in case of congestion in one or more of the + * congestion groups relevant to this port. + * Each call to this routine may add one or more congestion + * groups to be considered relevant to this port. + * + * May be used for Rx, or RX+OP ports only (depending on chip) + * + * @Param[in] ioc_fm_port_congestion_groups_t A pointer to an array of + * congestion group ids to + * consider. + * + * @Return 0 on success; error code otherwise. + */ +#define FM_PORT_IOC_ADD_CONGESTION_GRPS \ + _IOW(FM_IOC_TYPE_BASE, FM_PORT_IOC_NUM(34), \ + ioc_fm_port_congestion_groups_t) + +/* + * @Function fm_port_remove_congestion_grps + * + * @Description This routine effects the corresponding Tx port. It should be + * called when congestion groups were defined for this port and + * are no longer relevant, or pause frames transmitting is not + * required on their behalf. Each call to this routine may remove + * one or more congestion groups to be considered relevant to + * this port. + * + * May be used for Rx, or RX+OP ports only (depending on chip) + * + * @Param[in] ioc_fm_port_congestion_groups_t A pointer to an array of + * congestion group ids to + * consider. + * + * @Return 0 on success; error code otherwise. + */ +#define FM_PORT_IOC_REMOVE_CONGESTION_GRPS \ + _IOW(FM_IOC_TYPE_BASE, FM_PORT_IOC_NUM(35), \ + ioc_fm_port_congestion_groups_t) + +/* + * @Function fm_port_set_errors_route + * + * @Description Errors selected for this routine will cause a frame with that + * error to be enqueued to error queue. + * Errors not selected for this routine will cause a frame with + * that error to be enqueued to the one of the other port queues. + * By default all errors are defined to be enqueued to error + * queue. Errors that were configured to be discarded (at + * initialization) may not be selected here. + * + * May be used for Rx and offline parsing ports only + * + * @Param[in] ioc_fm_port_frame_err_select_t A list of errors to + * enqueue to error queue + * + * @Return 0 on success; error code otherwise. + * + * @Cautions Allowed only following fm_port_config() and before + * fm_port_init(). + * (szbs001: How is it possible to have one function that needs + * to be called BEFORE fm_port_init() implemented as an ioctl, + * which will ALWAYS be called AFTER the fm_port_init() for that + I port!?!?!?!???!?!??!?!?) + */ +#define FM_PORT_IOC_SET_ERRORS_ROUTE \ + _IOW(FM_IOC_TYPE_BASE, FM_PORT_IOC_NUM(4), \ + ioc_fm_port_frame_err_select_t) + +/* + * @Group lnx_ioctl_FM_PORT_pcd_runtime_control_grp FM Port PCD Runtime + * Control Unit + * + * @Description FM Port PCD Runtime control unit API functions, definitions + * and enums. + * + * @{ + */ + +/* + * @Description A structure defining the KG scheme after the parser. + * (Must match struct ioc_fm_pcd_kg_scheme_select_t defined in + * fm_port_ext.h) + * + * This is relevant only to change scheme selection mode - from + * direct to indirect and vice versa, or when the scheme is + * selected directly, to select the scheme id. + * + */ +typedef struct ioc_fm_pcd_kg_scheme_select_t { + bool direct; + /**< TRUE to use 'scheme_id' directly, FALSE to use LCV.*/ + void *scheme_id; + /**< Relevant for 'direct'=TRUE only. 'scheme_id' selects the + * scheme after parser. + */ +} ioc_fm_pcd_kg_scheme_select_t; + +/* + * @Description Scheme IDs structure + * (Must match struct ioc_fm_pcd_port_schemes_params_t defined + * in fm_port_ext.h) + */ +typedef struct ioc_fm_pcd_port_schemes_params_t { + uint8_t num_schemes; + /**< Number of schemes for port to be bound to. */ + void *scheme_ids[FM_PCD_KG_NUM_OF_SCHEMES]; + /**< Array of 'num_schemes' schemes for the port to be bound + * to + */ +} ioc_fm_pcd_port_schemes_params_t; + +/* + * @Description A union for defining port protocol parameters for parser + * (Must match union u_FmPcdHdrPrsOpts defined in fm_port_ext.h) + */ +typedef union ioc_fm_pcd_hdr_prs_opts_u { + /* MPLS */ + struct { + bool label_interpretation_enable; + /**< When this bit is set, the last MPLS label will be + * interpreted as described in HW spec table. When the bit is + * cleared, the parser will advance to MPLS next parse + */ + ioc_net_header_type next_parse; + /**< must be equal or higher than IPv4 */ + } mpls_prs_options; + + /* VLAN */ + struct { + uint16_t tag_protocol_id1; + /**< User defined Tag Protocol Identifier, to be recognized on + * VLAN TAG on top of 0x8100 and 0x88A8 + */ + uint16_t tag_protocol_id2; + /**< User defined Tag Protocol Identifier, to be recognized on + * VLAN TAG on top of 0x8100 and 0x88A8 + */ + } vlan_prs_options; + + /* PPP */ + struct{ + bool enable_mtu_check; + /**< Check validity of MTU according to RFC2516 */ + } pppoe_prs_options; + + /* IPV6 */ + struct { + bool routing_hdr_disable; + /**< Disable routing header */ + } ipv6_prs_options; + + /* UDP */ + struct { + bool pad_ignore_checksum; + /**< TRUE to ignore pad in checksum */ + } udp_prs_options; + + /* TCP */ + struct { + bool pad_ignore_checksum; + /**< TRUE to ignore pad in checksum */ + } tcp_prs_options; +} ioc_fm_pcd_hdr_prs_opts_u; + +/* + * @Description A structure for defining each header for the parser + * (must match struct t_FmPcdPrsAdditionalHdrParams defined in + * fm_port_ext.h) + */ +typedef struct ioc_fm_pcd_prs_additional_hdr_params_t { + ioc_net_header_type hdr; /**< Selected header */ + bool err_disable; /**< TRUE to disable error indication */ + bool soft_prs_enable; + /**< Enable jump to SW parser when this header is recognized by + * the HW parser. + */ + uint8_t index_per_hdr; + /**< Normally 0, if more than one sw parser attachments exists + * for the same header, (in the main sw parser code) use this + * index to distinguish between them. + */ + bool use_prs_opts; /**< TRUE to use parser options. */ + ioc_fm_pcd_hdr_prs_opts_u prs_opts; + /**< A unuion according to header type, defining the parser + * options selected. + */ +} ioc_fm_pcd_prs_additional_hdr_params_t; + +/* + * @Description A structure for defining port PCD parameters + * (Must match t_fm_portPcdPrsParams defined in fm_port_ext.h) + */ +typedef struct ioc_fm_port_pcd_prs_params_t { + uint8_t prs_res_priv_info; + /**< The private info provides a method of inserting port + * information into the parser result. This information may be + * extracted by KeyGen and be used for frames distribution when + * a per-port distinction is required, it may also be used as a + * port logical id for analyzing incoming frames. + */ + uint8_t parsing_offset; + /**< Number of bytes from beginning of packet to start parsing + */ + ioc_net_header_type first_prs_hdr; + /**< The type of the first header axpected at 'parsing_offset' + */ + bool include_in_prs_statistics; + /**< TRUE to include this port in the parser statistics */ + uint8_t num_of_hdrs_with_additional_params; + /**< Normally 0, some headers may get special parameters */ + ioc_fm_pcd_prs_additional_hdr_params_t + additional_params[IOC_FM_PCD_PRS_NUM_OF_HDRS]; + /**< 'num_of_hdrs_with_additional_params' structures additional + * parameters for each header that requires them + */ + bool set_vlan_tpid1; + /**< TRUE to configure user selection of Ethertype to indicate a + * VLAN tag (in addition to the TPID values 0x8100 and 0x88A8). + */ + uint16_t vlan_tpid1; + /**< extra tag to use if set_vlan_tpid1=TRUE. */ + bool set_vlan_tpid2; + /**< TRUE to configure user selection of Ethertype to indicate a + * VLAN tag (in addition to the TPID values 0x8100 and 0x88A8). + */ + uint16_t vlan_tpid2; + /**< extra tag to use if set_vlan_tpid1=TRUE. */ +} ioc_fm_port_pcd_prs_params_t; + +/* + * @Description A structure for defining coarse alassification parameters + * (Must match t_fm_portPcdCcParams defined in fm_port_ext.h) + */ +typedef struct ioc_fm_port_pcd_cc_params_t { + void *cc_tree_id; /**< CC tree id */ +} ioc_fm_port_pcd_cc_params_t; + +/* + * @Description A structure for defining keygen parameters + * (Must match t_fm_portPcdKgParams defined in fm_port_ext.h) + */ +typedef struct ioc_fm_port_pcd_kg_params_t { + uint8_t num_schemes; + /**< Number of schemes for port to be bound to. */ + void *scheme_ids[FM_PCD_KG_NUM_OF_SCHEMES]; + /**< Array of 'num_schemes' schemes for the port to + * be bound to + */ + bool direct_scheme; + /**< TRUE for going from parser to a specific scheme, + * regardless of parser result + */ + void *direct_scheme_id; + /**< Scheme id, as returned by FM_PCD_KgSetScheme; + * relevant only if direct=TRUE. + */ +} ioc_fm_port_pcd_kg_params_t; + +/* + * @Description A structure for defining policer parameters + * (Must match t_fm_portPcdPlcrParams defined in fm_port_ext.h) + */ +typedef struct ioc_fm_port_pcd_plcr_params_t { + void *plcr_profile_id; + /**< Selected profile handle; + * relevant in one of the following cases: + * e_IOC_FM_PCD_PLCR_ONLY or + * e_IOC_FM_PCD_PRS_PLCR were selected, or if + * any flow uses a KG scheme where policer profile is not + * generated (bypass_plcr_profile_generation selected) + */ +} ioc_fm_port_pcd_plcr_params_t; + +/* + * @Description A structure for defining port PCD parameters + * (Must match struct t_fm_portPcdParams defined in + * fm_port_ext.h) + */ +typedef struct ioc_fm_port_pcd_params_t { + ioc_fm_port_pcd_support pcd_support; + /**< Relevant for Rx and offline ports only. + * Describes the active PCD engines for this port. + */ + void *net_env_id; /**< HL Unused in PLCR only mode */ + ioc_fm_port_pcd_prs_params_t *p_prs_params; + /**< Parser parameters for this port */ + ioc_fm_port_pcd_cc_params_t *p_cc_params; + /**< Coarse classification parameters for this port */ + ioc_fm_port_pcd_kg_params_t *p_kg_params; + /**< Keygen parameters for this port */ + ioc_fm_port_pcd_plcr_params_t *p_plcr_params; + /**< Policer parameters for this port */ + void *p_ip_reassembly_manip; + /**< IP Reassembly manipulation */ + void *p_capwap_reassembly_manip; + /**< CAPWAP Reassembly manipulation */ +} ioc_fm_port_pcd_params_t; + +/* + * @Description A structure for defining the Parser starting point + * (Must match struct ioc_fm_pcd_prs_start_t defined in + * fm_port_ext.h) + */ +typedef struct ioc_fm_pcd_prs_start_t { + uint8_t parsing_offset; + /**< Number of bytes from beginning of packet to start parsing + */ + ioc_net_header_type first_prs_hdr; + /**< The type of the first header axpected at 'parsing_offset' + */ +} ioc_fm_pcd_prs_start_t; + +/* + * @Description FQID parameters structure + */ +typedef struct ioc_fm_port_pcd_fqids_params_t { + uint32_t num_fqids; + /**< Number of fqids to be allocated for the port */ + uint8_t alignment; + /**< Alignment required for this port */ + uint32_t base_fqid; + /**< output parameter - the base fqid */ +} ioc_fm_port_pcd_fqids_params_t; + +/* + * @Function FM_PORT_IOC_ALLOC_PCD_FQIDS + * + * @Description Allocates FQID's + * May be used for Rx and offline parsing ports only + * + * @Param[in,out] ioc_fm_port_pcd_fqids_params_t Parameters for + * allocating FQID's + * + * @Return 0 on success; error code otherwise. + */ +#define FM_PORT_IOC_ALLOC_PCD_FQIDS \ + _IOWR(FM_IOC_TYPE_BASE, FM_PORT_IOC_NUM(19), \ + ioc_fm_port_pcd_fqids_params_t) + +/* + * @Function FM_PORT_IOC_FREE_PCD_FQIDS + * + * @Description Frees previously-allocated FQIDs + * May be used for Rx and offline parsing ports only + * + * @Param[in] uint32_t Base FQID of previously allocated range. + * + * @Return 0 on success; error code otherwise. + */ +#define FM_PORT_IOC_FREE_PCD_FQIDS \ + _IOW(FM_IOC_TYPE_BASE, FM_PORT_IOC_NUM(19), uint32_t) + +/* + * @Function fm_port_set_pcd + * + * @Description Calling this routine defines the port's PCD configuration. + * It changes it from its default configuration which is PCD + * disabled (BMI to BMI) and configures it according to the + * passed parameters. + * May be used for Rx and offline parsing ports only + * + * @Param[in] ioc_fm_port_pcd_params_t A Structure of parameters + * defining the port's PCD + * configuration. + * + * @Return 0 on success; error code otherwise. + */ +#define FM_PORT_IOC_SET_PCD \ + _IOW(FM_IOC_TYPE_BASE, FM_PORT_IOC_NUM(20), ioc_fm_port_pcd_params_t) + +/* + * @Function fm_port_delete_pcd + * + * @Description Calling this routine releases the port's PCD configuration. + * The port returns to its default configuration which is PCD + * disabled (BMI to BMI) and all PCD configuration is removed. + * May be used for Rx and offline parsing ports which are in PCD + * mode only + * + * @Return 0 on success; error code otherwise. + */ +#define FM_PORT_IOC_DELETE_PCD _IO(FM_IOC_TYPE_BASE, FM_PORT_IOC_NUM(21)) + +/* + * @Function fm_port_attach_pcd + * + * @Description This routine may be called after fm_port_detach_pcd was + * called, to return to the originally configured PCD support + * flow. The couple of routines are used to allow PCD + * configuration changes that demand that PCD will not be used + * while changes take place. + * + * May be used for Rx and offline parsing ports which are in PCD + * mode only + * + * @Return 0 on success; error code otherwise. + */ +#define FM_PORT_IOC_ATTACH_PCD _IO(FM_IOC_TYPE_BASE, FM_PORT_IOC_NUM(23)) + +/* + * @Function fm_port_detach_pcd + * + * @Description Calling this routine detaches the port from its PCD + * functionality. The port returns to its default flow which is + * BMI to BMI. + * + * May be used for Rx and offline parsing ports which are in PCD + * mode only + * + * @Return 0 on success; error code otherwise. + */ +#define FM_PORT_IOC_DETACH_PCD _IO(FM_IOC_TYPE_BASE, FM_PORT_IOC_NUM(22)) + +/* + * @Function fm_port_pcd_plcr_alloc_profiles + * + * @Description This routine may be called only for ports that use the Policer + * in order to allocate private policer profiles. + * + * @Param[in] uint16_t The number of required policer profiles + * + * @Return 0 on success; error code otherwise. + * + * @Cautions Allowed before fm_port_set_pcd() only. + */ +#define FM_PORT_IOC_PCD_PLCR_ALLOC_PROFILES \ + _IOW(FM_IOC_TYPE_BASE, FM_PORT_IOC_NUM(24), uint16_t) + +/* + * @Function fm_port_pcd_plcr_free_profiles + * + * @Description This routine should be called for freeing private policer + * profiles. + * + * @Return 0 on success; error code otherwise. + * + * @Cautions Allowed before fm_port_set_pcd() only. + */ +#define FM_PORT_IOC_PCD_PLCR_FREE_PROFILES \ + _IO(FM_IOC_TYPE_BASE, FM_PORT_IOC_NUM(25)) + +/* + * @Function fm_port_pcd_kg_modify_initial_scheme + * + * @Description This routine may be called only for ports that use the keygen + * in order to change the initial scheme frame should be routed + * to.The change may be of a scheme id (in case of direct mode), + * from direct to indirect, or from indirect to direct - + * specifying the scheme id. + * + * @Param[in] ioc_fm_pcd_kg_scheme_select_t + * A structure of parameters for defining whether a scheme is + * direct/indirect, and if direct - scheme id. + * + * @Return 0 on success; error code otherwise. + */ +#define FM_PORT_IOC_PCD_KG_MODIFY_INITIAL_SCHEME \ + _IOW(FM_IOC_TYPE_BASE, FM_PORT_IOC_NUM(26), \ + ioc_fm_pcd_kg_scheme_select_t) + +/* + * @Function fm_port_pcd_plcr_modify_initial_profile + * + * @Description This routine may be called for ports with flows + * e_IOC_FM_PCD_SUPPORT_PLCR_ONLY or + * e_IOC_FM_PCD_SUPPORT_PRS_AND_PLCR only, to change the initial + * Policer profile frame should be routed to. + * The change may be of a profile and / or absolute / direct mode + * selection. + * + * @Param[in] ioc_fm_obj_t Policer profile Id as returned from + * FM_PCD_PlcrSetProfile. + * + * @Return 0 on success; error code otherwise. + */ +#define FM_PORT_IOC_PCD_PLCR_MODIFY_INITIAL_PROFILE \ + _IOW(FM_IOC_TYPE_BASE, FM_PORT_IOC_NUM(27), ioc_fm_obj_t) + +/* + * @Function fm_port_pcd_cc_modify_tree + * + * @Description This routine may be called to change this port connection to + * a pre - initializes coarse classification Tree. + * + * @Param[in] ioc_fm_obj_t Id of new coarse classification tree selected + * for this port. + * + * @Return 0 on success; error code otherwise. + * + * @Cautions Allowed only following fm_port_set_pcd() and + * fm_port_detach_pcd() + */ +#define FM_PORT_IOC_PCD_CC_MODIFY_TREE \ + _IOW(FM_IOC_TYPE_BASE, FM_PORT_IOC_NUM(28), ioc_fm_obj_t) + +/* + * @Function fm_port_pcd_kg_bind_schemes + * + * @Description These routines may be called for modifying the binding of + * ports to schemes. The scheme itself is not added, just this + * specific port starts using it. + * + * @Param[in] ioc_fm_pcd_port_schemes_params_t Schemes parameters + * structure + * + * @Return 0 on success; error code otherwise. + * + * @Cautions Allowed only following fm_port_set_pcd(). + */ +#define FM_PORT_IOC_PCD_KG_BIND_SCHEMES \ + _IOW(FM_IOC_TYPE_BASE, FM_PORT_IOC_NUM(30), \ + ioc_fm_pcd_port_schemes_params_t) + +/* + * @Function fm_port_pcd_kg_unbind_schemes + * + * @Description These routines may be called for modifying the binding of + * ports to schemes. The scheme itself is not removed or + * invalidated, just this specific port stops using it. + * + * @Param[in] ioc_fm_pcd_port_schemes_params_t Schemes parameters + * structure + * + * @Return 0 on success; error code otherwise. + * + * @Cautions Allowed only following fm_port_set_pcd(). + */ +#define FM_PORT_IOC_PCD_KG_UNBIND_SCHEMES \ + _IOW(FM_IOC_TYPE_BASE, FM_PORT_IOC_NUM(31), \ + ioc_fm_pcd_port_schemes_params_t) + +#define ENET_NUM_OCTETS_PER_ADDRESS 6 + /**< Number of octets (8-bit bytes) in an ethernet address */ +typedef struct ioc_fm_port_mac_addr_params_t { + uint8_t addr[ENET_NUM_OCTETS_PER_ADDRESS]; +} ioc_fm_port_mac_addr_params_t; + +/* + * @Function FM_MAC_AddHashMacAddr + * + * @Description Add an Address to the hash table. This is for filter purpose + * only. + * + * @Param[in] ioc_fm_port_mac_addr_params_t Ethernet Mac address + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following FM_MAC_Init(). It is a filter only + * address. + * @Cautions Some address need to be filtered out in upper FM blocks. + */ +#define FM_PORT_IOC_ADD_RX_HASH_MAC_ADDR \ + _IOW(FM_IOC_TYPE_BASE, FM_PORT_IOC_NUM(36), \ + ioc_fm_port_mac_addr_params_t) + +/* + * @Function FM_MAC_RemoveHashMacAddr + * + * @Description Delete an Address to the hash table. This is for filter + * purpose only. + * + * @Param[in] ioc_fm_port_mac_addr_params_t Ethernet Mac address + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following FM_MAC_Init(). + */ +#define FM_PORT_IOC_REMOVE_RX_HASH_MAC_ADDR \ + _IOW(FM_IOC_TYPE_BASE, FM_PORT_IOC_NUM(37), \ + ioc_fm_port_mac_addr_params_t) + +typedef struct ioc_fm_port_tx_pause_frames_t { + uint8_t priority; + uint16_t pause_time; + uint16_t thresh_time; +} ioc_fm_port_tx_pause_frames_t; + +/* + * @Function FM_MAC_SetTxPauseFrames + * + * @Description Enable/Disable transmission of Pause-Frames. The routine + * changes the default configuration: pause-time - [0xf000] + * threshold-time - [0] + * + * @Param[in] ioc_fm_port_tx_pause_frames_params_t + * A structure holding the required parameters. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following FM_MAC_Init(). PFC is supported only on + * new mEMAC; i.e. in MACs that don't have PFC support (10G-MAC + * and dTSEC), user should use 'FM_MAC_NO_PFC' in the 'priority' + * field. + */ +#define FM_PORT_IOC_SET_TX_PAUSE_FRAMES \ + _IOW(FM_IOC_TYPE_BASE, FM_PORT_IOC_NUM(40), \ + ioc_fm_port_tx_pause_frames_t) + +typedef struct ioc_fm_port_mac_statistics_t { + /* RMON */ + uint64_t e_stat_pkts_64; + /**< r-10G tr-DT 64 byte frame counter */ + uint64_t e_stat_pkts_65_to_127; + /**< r-10G 65 to 127 byte frame counter */ + uint64_t e_stat_pkts_128_to_255; + /**< r-10G 128 to 255 byte frame counter */ + uint64_t e_stat_pkts_256_to_511; + /**< r-10G 256 to 511 byte frame counter */ + uint64_t e_stat_pkts_512_to_1023; + /**< r-10G 512 to 1023 byte frame counter*/ + uint64_t e_stat_pkts_1024_to_1518; + /**< r-10G 1024 to 1518 byte frame counter */ + uint64_t e_stat_pkts_1519_to_1522; + /**< r-10G 1519 to 1522 byte good frame count */ + /* */ + uint64_t e_stat_fragments; + /**< Total number of packets that were less than 64 octets long + * with a wrong CRC. + */ + uint64_t e_stat_jabbers; + /**< Total number of packets longer than valid maximum length + * octets + */ + uint64_t e_stat_drop_events; + /**< number of dropped packets due to internal errors of the MAC + * Client (during receive). + */ + uint64_t e_stat_CRC_align_errors; + /**< Incremented when frames of correct length but with CRC + * error are received. + */ + uint64_t e_stat_undersize_pkts; + /**< Incremented for frames under 64 bytes with a valid FCS and + * otherwise well formed; This count does not include range + * length errors + */ + uint64_t e_stat_oversize_pkts; + /**< Incremented for frames which exceed 1518 (non VLAN) or 1522 + * (VLAN) and contains a valid FCS and otherwise well formed + */ + /* Pause */ + uint64_t rx_stat_pause; /**< Pause MAC Control received */ + uint64_t tx_stat_pause; /**< Pause MAC Control sent */ + /* MIB II */ + uint64_t if_in_octets; /**< Total number of byte received. */ + uint64_t if_in_pkts; /**< Total number of packets received.*/ + uint64_t if_in_ucast_pkts; + /**< Total number of unicast frame received; + * NOTE: this counter is not supported on dTSEC MAC + */ + uint64_t if_in_mcast_pkts; + /**< Total number of multicast frame received*/ + uint64_t if_in_bcast_pkts; + /**< Total number of broadcast frame received */ + uint64_t if_in_discards; + /**< Frames received, but discarded due to problems within the + * MAC RX. + */ + uint64_t if_in_errors; + /**< Number of frames received with error: + * - FIFO Overflow Error + * - CRC Error + * - Frame Too Long Error + * - Alignment Error + * - The dedicated Error Code (0xfe, not a code error) was + * received + */ + uint64_t if_out_octets; /**< Total number of byte sent. */ + uint64_t if_out_pkts; /**< Total number of packets sent .*/ + uint64_t if_out_ucast_pkts; + /**< Total number of unicast frame sent; + * NOTE: this counter is not supported on dTSEC MAC + */ + uint64_t if_out_mcast_pkts; + /**< Total number of multicast frame sent */ + uint64_t if_out_bcast_pkts; + /**< Total number of multicast frame sent */ + uint64_t if_out_discards; + /**< Frames received, but discarded due to problems within the + * MAC TX N/A!. + */ + uint64_t if_out_errors; + /**< Number of frames transmitted with error: + * - FIFO Overflow Error + * - FIFO Underflow Error + * - Other + */ +} ioc_fm_port_mac_statistics_t; + +/* + * @Function FM_MAC_GetStatistics + * + * @Description get all MAC statistics counters + * + * @Param[out] ioc_fm_port_mac_statistics_t A structure holding the + * statistics + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following FM_Init(). + */ +#define FM_PORT_IOC_GET_MAC_STATISTICS \ + _IOR(FM_IOC_TYPE_BASE, FM_PORT_IOC_NUM(41), \ + ioc_fm_port_mac_statistics_t) + +/* + * @Function fm_port_get_bmi_counters + * + * @Description Read port's BMI stat counters and place them into + * a designated structure of counters. + * + * @Param[in] h_fm_port A handle to a FM Port module. + * @Param[out] p_bmi_stats counters structure + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_port_init(). + */ + +#define FM_PORT_IOC_GET_BMI_COUNTERS \ + _IOR(FM_IOC_TYPE_BASE, FM_PORT_IOC_NUM(42), ioc_fm_port_bmi_stats_t) + +/** @} */ /* end of lnx_ioctl_FM_PORT_pcd_runtime_control_grp group */ +/** @} */ /* end of lnx_ioctl_FM_PORT_runtime_control_grp group */ + +/** @} */ /* end of lnx_ioctl_FM_PORT_grp group */ +/** @} */ /* end of lnx_ioctl_FM_grp group */ + + +/* + * @Group gen_id General Drivers Utilities + * + * @Description External routines. + * + * @{ + */ + +/* + * @Group gen_error_id Errors, Events and Debug + * + * @Description External routines. + * + * @{ + */ + +/* + * The scheme below provides the bits description for error codes: + * + * 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 + * | Reserved (should be zero) | Module ID | + * + * 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 + * | Error Type | + */ + +#define ERROR_CODE(_err) ((((uint32_t)_err) & 0x0000FFFF) | __ERR_MODULE__) + +#define GET_ERROR_TYPE(_errcode) ((_errcode) & 0x0000FFFF) + /**< Extract module code from error code (#uint32_t) */ + +#define GET_ERROR_MODULE(_errcode) ((_errcode) & 0x00FF0000) + /**< Extract error type (#e_error_type) from + * error code (#uint32_t) + */ + +#define RETURN_ERROR(_level, _err, _vmsg) { return ERROR_CODE(_err); } + +/* + * @Description Error Type Enumeration + */ +typedef enum e_error_type { + E_OK = 0 + /* Never use "RETURN_ERROR" with E_OK; Use "return E_OK;"*/ + , E_WRITE_FAILED = EIO + /**< Write access failed on memory/device.*/ + /* String: none, or device name.*/ + , E_NO_DEVICE = ENXIO + /**< The associated device is not initialized.*/ + /* String: none.*/ + , E_NOT_AVAILABLE = EAGAIN + /**< Resource is unavailable.*/ + /* String: none, unless the operation is not the main goal of + * the function (in this case add resource description). + */ + , E_NO_MEMORY = ENOMEM + /**< External memory allocation failed.*/ + /* String: description of item for which allocation failed. */ + , E_INVALID_ADDRESS = EFAULT + /**< Invalid address.*/ + /* String: description of the specific violation.*/ + , E_BUSY = EBUSY + /**< Resource or module is busy.*/ + /* String: none, unless the operation is not the main goal + * of the function (in this case add resource + * description). + */ + , E_ALREADY_EXISTS = EEXIST + /**< Requested resource or item already exists.*/ + /* Use when resource duplication or sharing are not allowed. + * String: none, unless the operation is not the main goal + * of the function (in this case add item description). + */ + , E_INVALID_OPERATION = ENODEV + /**< The operation/command is invalid (unrecognized).*/ + /* String: none.*/ + , E_INVALID_VALUE = EDOM + /**< Invalid value.*/ + /* Use for non-enumeration parameters, and only when other error + * types are not suitable. + * String: parameter description + "(should be )", + * e.g: "Maximum Rx buffer length (should be divisible + * by 8)", "Channel number (should be even)". + */ + , E_NOT_IN_RANGE = ERANGE + /**< Parameter value is out of range.*/ + /* Don't use this error for enumeration parameters. + * String: parameter description + "(should be %d-%d)", + * e.g: "Number of pad characters (should be 0-15)". + */ + , E_NOT_SUPPORTED = ENOSYS + /**< The function is not supported or not implemented.*/ + /* String: none.*/ + , E_INVALID_STATE + /**< The operation is not allowed in current module state.*/ + /* String: none.*/ + , E_INVALID_HANDLE + /**< Invalid handle of module or object.*/ + /* String: none, unless the function takes in more than one + * handle (in this case add the handle description) + */ + , E_INVALID_ID + /**< Invalid module ID (usually enumeration or index).*/ + /* String: none, unless the function takes in more than one ID + * (in this case add the ID description) + */ + , E_NULL_POINTER + /**< Unexpected NULL pointer.*/ + /* String: pointer description.*/ + , E_INVALID_SELECTION + /**< Invalid selection or mode.*/ + /* Use for enumeration values, only when other error types are + * not suitable. + * String: parameter description. + */ + , E_INVALID_COMM_MODE + /**< Invalid communication mode.*/ + /* String: none, unless the function takes in more than one + * communication mode indications (in this case add + * parameter description). + */ + , E_INVALID_MEMORY_TYPE + /**< Invalid memory type.*/ + /* String: none, unless the function takes in more than one + * memory types (in this case add memory description, + * e.g: "Data memory", "Buffer descriptors memory"). + */ + , E_INVALID_CLOCK + /**< Invalid clock.*/ + /* String: none, unless the function takes in more than one + * clocks (in this case add clock description, e.g: "Rx + * clock", "Tx clock"). + */ + , E_CONFLICT + /**< Some setting conflicts with another setting.*/ + /* String: description of the conflicting settings.*/ + , E_NOT_ALIGNED + /**< Non-aligned address.*/ + /* String: parameter description + "(should be %d-bytes + * aligned)", e.g: "Rx data buffer (should be 32-bytes + * aligned)". + */ + , E_NOT_FOUND + /**< Requested resource or item was not found.*/ + /* Use only when the resource/item is uniquely identified. + * String: none, unless the operation is not the main goal + * of the function (in this case add item description). + */ + , E_FULL + /**< Resource is full.*/ + /* String: none, unless the operation is not the main goal of + * the function (in this case add resource description). + */ + , E_EMPTY + /**< Resource is empty.*/ + /* String: none, unless the operation is not the main goal of + * the function (in this case add resource description). + */ + , E_ALREADY_FREE + /**< Specified resource or item is already free or deleted.*/ + /* String: none, unless the operation is not the main goal + * of the function (in this case add item description). + */ + , E_READ_FAILED + /**< Read access failed on memory/device.*/ + /* String: none, or device name.*/ + , E_INVALID_FRAME + /**< Invalid frame object (NULL handle or missing buffers).*/ + /* String: none.*/ + , E_SEND_FAILED + /**< Send operation failed on device.*/ + /* String: none, or device name.*/ + , E_RECEIVE_FAILED + /**< Receive operation failed on device.*/ + /* String: none, or device name.*/ + , E_TIMEOUT/* = ETIMEDOUT*/ + /**< The operation timed out.*/ + /* String: none.*/ + + , E_DUMMY_LAST /* NEVER USED */ + +} e_error_type; + +/* + * + * @Group FM_grp Frame Manager API + * + * @Description FM API functions, definitions and enums + * + * @{ + */ + +/* + * @Group FM_PORT_grp FM Port + * + * @Description FM Port API + * + * The FM uses a general module called "port" to represent a Tx + * port (MAC), an Rx port (MAC) or Offline Parsing port. The + * number of ports in an FM varies between SOCs. The SW driver + * manages these ports as sub-modules of the FM, i.e. after an FM + * is initialized, its ports may be initialized and operated + * upon. + * + * The port is initialized aware of its type, but other functions + * on a port may be indifferent to its type. When necessary, the + * driver verifies coherence and returns error if applicable. + * + * On initialization, user specifies the port type and it's index + * (relative to the port's type) - always starting at 0. + * + * @{ + */ + +/* + * @Description An enum for defining port PCD modes. + * This enum defines the superset of PCD engines support - i.e. + * not all engines have to be used, but all have to be enabled. + * The real flow of a specific frame depends on the PCD + * configuration and the frame headers and payload. Note: the + * first engine and the first engine after the parser (if exists) + * should be in order, the order is important as it will define + * the flow of the port. However, as for the rest engines (the + * ones that follows), the order is not important anymore as it + * is defined by the PCD graph itself. + */ +typedef enum e_fm_port_pcd_support { + e_FM_PORT_PCD_SUPPORT_NONE = 0 + /**< BMI to BMI, PCD is not used */ + , e_FM_PORT_PCD_SUPPORT_PRS_ONLY + /**< Use only Parser */ + , e_FM_PORT_PCD_SUPPORT_PLCR_ONLY + /**< Use only Policer */ + , e_FM_PORT_PCD_SUPPORT_PRS_AND_PLCR + /**< Use Parser and Policer */ + , e_FM_PORT_PCD_SUPPORT_PRS_AND_KG + /**< Use Parser and Keygen */ + , e_FM_PORT_PCD_SUPPORT_PRS_AND_KG_AND_CC + /**< Use Parser, Keygen and Coarse Classification */ + , e_FM_PORT_PCD_SUPPORT_PRS_AND_KG_AND_CC_AND_PLCR + /**< Use all PCD engines */ + , e_FM_PORT_PCD_SUPPORT_PRS_AND_KG_AND_PLCR + /**< Use Parser, Keygen and Policer */ + , e_FM_PORT_PCD_SUPPORT_PRS_AND_CC + /**< Use Parser and Coarse Classification */ + , e_FM_PORT_PCD_SUPPORT_PRS_AND_CC_AND_PLCR + /**< Use Parser and Coarse Classification and Policer */ + , e_FM_PORT_PCD_SUPPORT_CC_ONLY + /**< Use only Coarse Classification */ +#ifdef FM_CAPWAP_SUPPORT + , e_FM_PORT_PCD_SUPPORT_CC_AND_KG + /**< Use Coarse Classification,and Keygen */ + , e_FM_PORT_PCD_SUPPORT_CC_AND_KG_AND_PLCR + /**< Use Coarse Classification, Keygen and Policer */ +#endif /* FM_CAPWAP_SUPPORT */ +} e_fm_port_pcd_support; + +/* + * @Description Port interrupts + */ +typedef enum e_fm_port_exceptions { + e_FM_PORT_EXCEPTION_IM_BUSY /**< Independent-Mode Rx-BUSY */ +} e_fm_port_exceptions; + +/* + * @Collection General FM Port defines + */ +#define FM_PORT_PRS_RESULT_NUM_OF_WORDS 8 + /**< Number of 4 bytes words in parser result */ +/* @} */ + +/* + * @Collection FM Frame error + */ +typedef uint32_t fm_port_frame_err_select_t; + /**< typedef for defining Frame Descriptor errors */ + +#define FM_PORT_FRM_ERR_UNSUPPORTED_FORMAT FM_FD_ERR_UNSUPPORTED_FORMAT + /**< Not for Rx-Port! Unsupported Format */ +#define FM_PORT_FRM_ERR_LENGTH FM_FD_ERR_LENGTH + /**< Not for Rx-Port! Length Error */ +#define FM_PORT_FRM_ERR_DMA FM_FD_ERR_DMA /**< DMA Data error */ +#define FM_PORT_FRM_ERR_NON_FM FM_FD_RX_STATUS_ERR_NON_FM + /**< non Frame-Manager error; probably come from SEC + * that was chained to FM + */ + +#define FM_PORT_FRM_ERR_IPRE (FM_FD_ERR_IPR & ~FM_FD_IPR) + /**< IPR error */ +#define FM_PORT_FRM_ERR_IPR_NCSP (FM_FD_ERR_IPR_NCSP & ~FM_FD_IPR) + /**< IPR non-consistent-sp */ + +#define FM_PORT_FRM_ERR_IPFE 0 + /**< Obsolete; will be removed in the future */ + +#ifdef FM_CAPWAP_SUPPORT +#define FM_PORT_FRM_ERR_CRE FM_FD_ERR_CRE +#define FM_PORT_FRM_ERR_CHE FM_FD_ERR_CHE +#endif /* FM_CAPWAP_SUPPORT */ + +#define FM_PORT_FRM_ERR_PHYSICAL FM_FD_ERR_PHYSICAL + /**< Rx FIFO overflow, FCS error, code error, running + * disparity error (SGMII and TBI modes), FIFO parity + * error. PHY Sequence error, PHY error control + * character detected. + */ +#define FM_PORT_FRM_ERR_SIZE FM_FD_ERR_SIZE + /**< Frame too long OR Frame size exceeds + * max_length_frame + */ +#define FM_PORT_FRM_ERR_CLS_DISCARD FM_FD_ERR_CLS_DISCARD + /**< indicates a classifier "drop" operation */ +#define FM_PORT_FRM_ERR_EXTRACTION FM_FD_ERR_EXTRACTION + /**< Extract Out of Frame */ +#define FM_PORT_FRM_ERR_NO_SCHEME FM_FD_ERR_NO_SCHEME + /**< No Scheme Selected */ +#define FM_PORT_FRM_ERR_KEYSIZE_OVERFLOW FM_FD_ERR_KEYSIZE_OVERFLOW + /**< Keysize Overflow */ +#define FM_PORT_FRM_ERR_COLOR_RED FM_FD_ERR_COLOR_RED + /**< Frame color is red */ +#define FM_PORT_FRM_ERR_COLOR_YELLOW FM_FD_ERR_COLOR_YELLOW + /**< Frame color is yellow */ +#define FM_PORT_FRM_ERR_ILL_PLCR FM_FD_ERR_ILL_PLCR + /**< Illegal Policer Profile selected */ +#define FM_PORT_FRM_ERR_PLCR_FRAME_LEN FM_FD_ERR_PLCR_FRAME_LEN + /**< Policer frame length error */ +#define FM_PORT_FRM_ERR_PRS_TIMEOUT FM_FD_ERR_PRS_TIMEOUT + /**< Parser Time out Exceed */ +#define FM_PORT_FRM_ERR_PRS_ILL_INSTRUCT FM_FD_ERR_PRS_ILL_INSTRUCT + /**< Invalid Soft Parser instruction */ +#define FM_PORT_FRM_ERR_PRS_HDR_ERR FM_FD_ERR_PRS_HDR_ERR + /**< Header error was identified during parsing */ +#define FM_PORT_FRM_ERR_BLOCK_LIMIT_EXCEEDED FM_FD_ERR_BLOCK_LIMIT_EXCEEDED + /**< Frame parsed beyind 256 first bytes */ +#define FM_PORT_FRM_ERR_PROCESS_TIMEOUT 0x00000001 + /**< FPM Frame Processing Timeout Exceeded */ +/* @} */ + + +/* + * @Group FM_PORT_init_grp FM Port Initialization Unit + * + * @Description FM Port Initialization Unit + * + * @{ + */ + +/* + * @Description Exceptions user callback routine, will be called upon an + * exception passing the exception identification. + * + * @Param[in] h_app User's application descriptor. + * @Param[in] exception The exception. + */ +typedef void (t_fm_port_exception_callback) (t_handle h_app, + e_fm_port_exceptions exception); + +/* + * @Description User callback function called by driver with received data. + * User provides this function. Driver invokes it. + * + * @Param[in] h_app Application's handle originally specified to + * the API Config function + * @Param[in] p_data A pointer to data received + * @Param[in] length length of received data + * @Param[in] status receive status and errors + * @Param[in] position position of buffer in frame + * @Param[in] h_buf_context A handle of the user acossiated with this buffer + * + * @Retval e_RX_STORE_RESPONSE_CONTINUE + * order the driver to continue Rx operation for all ready data. + * @Retval e_RX_STORE_RESPONSE_PAUSE + * order the driver to stop Rx operation. + */ +typedef e_rx_store_response(t_fm_port_im_rx_store_callback) (t_handle h_app, + uint8_t *p_data, + uint16_t length, + uint16_t status, + uint8_t position, + t_handle h_buf_context); + +/* + * @Description User callback function called by driver when transmit + * completed. + * User provides this function. Driver invokes it. + * + * @Param[in] h_app Application's handle originally specified to + * the API Config function + * @Param[in] p_data A pointer to data received + * @Param[in] status transmit status and errors + * @Param[in] last_buffer is last buffer in frame + * @Param[in] h_buf_context A handle of the user acossiated with this buffer + */ +typedef void (t_fm_port_im_tx_conf_callback) (t_handle h_app, + uint8_t *p_data, + uint16_t status, + t_handle h_buf_context); + +/* + * @Description A structure for additional Rx port parameters + */ +typedef struct t_fm_port_rx_params { + uint32_t err_fqid; /**< Error Queue Id. */ + uint32_t dflt_fqid; /**< Default Queue Id.*/ + uint16_t liodn_offset; /**< Port's LIODN offset. */ + 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 + */ +} t_fm_port_rx_params; + +/* + * @Description A structure for additional non-Rx port parameters + */ +typedef struct t_fm_port_non_rx_params { + uint32_t err_fqid; /**< Error Queue Id. */ + uint32_t dflt_fqid; + /**< For Tx - Default Confirmation queue, + * 0 means no Tx confirmation for processed frames. + * For OP port - default Rx queue. + */ + uint32_t qm_channel; + /**< QM-channel dedicated to this port; will be used by + * the FM for dequeue. + */ +} t_fm_port_non_rx_params; + +/* + * @Description A structure for additional Rx port parameters + */ +typedef struct t_fm_port_im_rx_tx_params { + t_handle h_fm_muram; + /**< A handle of the FM-MURAM partition */ + uint16_t liodn_offset; + /**< For Rx ports only. Port's LIODN Offset. */ + uint8_t data_mem_id; + /**< Memory partition ID for data buffers */ + uint32_t data_mem_attributes; + /**< Memory attributes for data buffers */ + t_buffer_pool_info rx_pool_params; + /**< For Rx ports only. */ + t_fm_port_im_rx_store_callback *f_rx_store; + /**< For Rx ports only. */ + t_fm_port_im_tx_conf_callback *f_tx_conf; + /**< For Tx ports only. */ +} t_fm_port_im_rx_tx_params; + +/* + * @Description A union for additional parameters depending on port type + */ +typedef union u_fm_port_specific_params { + t_fm_port_im_rx_tx_params im_rx_tx_params; + /**< Rx/Tx Independent-Mode port parameter structure */ + t_fm_port_rx_params rx_params; + /**< Rx port parameters structure */ + t_fm_port_non_rx_params non_rx_params; + /**< Non-Rx port parameters structure */ +} u_fm_port_specific_params; + +/* + * @Description A structure representing FM initialization parameters + */ +typedef struct t_fm_port_params { + uintptr_t base_addr; + /**< Virtual Address of memory mapped FM Port registers. + */ + t_handle h_fm; + /**< A handle to the FM object this port related to */ + e_fm_port_type port_type; /**< Port type */ + uint8_t port_id; + /**< Port Id - relative to type; + * NOTE: When configuring Offline Parsing port for + * FMANv3 devices (DPAA_VERSION 11 and higher), + * it is highly recommended NOT to use port_id=0 due to + * lack of HW resources on port_id=0. + */ + bool independent_mode_enable; + /**< This port is Independent-Mode - Used for Rx/Tx + * ports only! + */ + uint16_t liodn_base; + /**< Irrelevant for P4080 rev 1. LIODN base for this + * port, to be used together with LIODN offset. + */ + u_fm_port_specific_params specific_params; + /**< Additional parameters depending on port type. */ + + t_fm_port_exception_callback *f_exception; + /**< Relevant for IM only Callback routine to be called + * on BUSY exception + */ + t_handle h_app; + /**< A handle to an application layer object; This + * handle will be passed by the driver upon calling the + * above callbacks + */ +} t_fm_port_params; + +/* + * @Function fm_port_config + * + * @Description Creates a descriptor for the FM PORT module. + * + * The routine returns a handle(descriptor) to the FM PORT + * object. This descriptor must be passed as first parameter to + * all other FM PORT function calls. + * + * No actual initialization or configuration of FM hardware is + * done by this routine. + * + * @Param[in] p_fm_port_params Pointer to data structure of parameters + * + * @Retval Handle to FM object, or NULL for Failure. + */ +t_handle fm_port_config(t_fm_port_params *p_fm_port_params); + +/* + * @Function fm_port_init + * + * @Description Initializes the FM PORT module by defining the software + * structure and configuring the hardware registers. + * + * @Param[in] h_fm_port - FM PORT module descriptor + * + * @Return E_OK on success; Error code otherwise. + */ +uint32_t fm_port_init(t_handle h_fm_port); + +/* + * @Function fm_port_free + * + * @Description Frees all resources that were assigned to FM PORT module. + * + * Calling this routine invalidates the descriptor. + * + * @Param[in] h_fm_port - FM PORT module descriptor + * + * @Return E_OK on success; Error code otherwise. + */ +uint32_t fm_port_free(t_handle h_fm_port); + +t_handle fm_port_open(t_fm_port_params *p_fm_port_params); +void fm_port_close(t_handle h_fm_port); + + +/* + * @Group FM_PORT_advanced_init_grp FM Port Advanced Configuration + * Unit + * + * @Description Configuration functions used to change default values. + * + * @{ + */ + +/* + * @Description enum for defining QM frame dequeue + */ +typedef enum e_fm_port_deq_type { + e_FM_PORT_DEQ_TYPE1, + /**< Dequeue from the SP channel - with priority precedence, + * and Intra-Class Scheduling respected. + */ + e_FM_PORT_DEQ_TYPE2, + /**< Dequeue from the SP channel - with active FQ precedence, + * and Intra-Class Scheduling respected. + */ + e_FM_PORT_DEQ_TYPE3 + /**< Dequeue from the SP channel - with active FQ precedence, + * and override Intra-Class Scheduling + */ +} e_fm_port_deq_type; + +/* + * @Description enum for defining QM frame dequeue + */ +typedef enum e_fm_port_deq_prefetch_option { + e_FM_PORT_DEQ_NO_PREFETCH, + /**< QMI performs a dequeue action for a single frame + * only when a dedicated portID Tnum is waiting. + */ + e_FM_PORT_DEQ_PARTIAL_PREFETCH, + /**< QMI performs a dequeue action for 3 frames + * when one dedicated port_id tnum is waiting. + */ + e_FM_PORT_DEQ_FULL_PREFETCH + /**< QMI performs a dequeue action for 3 frames when + * no dedicated port_id tnums are waiting. + */ + +} e_fm_port_deq_prefetch_option; + +/* + * @Description enum for defining port default color + */ +typedef enum e_fm_port_color { + e_FM_PORT_COLOR_GREEN, /**< Default port color is green */ + e_FM_PORT_COLOR_YELLOW, /**< Default port color is yellow */ + e_FM_PORT_COLOR_RED, /**< Default port color is red */ + e_FM_PORT_COLOR_OVERRIDE/**< Ignore color */ +} e_fm_port_color; + +/* + * @Description A structure for defining Dual Tx rate limiting scale + */ +typedef enum e_fm_port_dual_rate_limiter_scale_down { + e_FM_PORT_DUAL_RATE_LIMITER_NONE = 0, + /**< Use only single rate limiter*/ + e_FM_PORT_DUAL_RATE_LIMITER_SCALE_DOWN_BY_2, + /**< Divide high rate limiter by 2 */ + e_FM_PORT_DUAL_RATE_LIMITER_SCALE_DOWN_BY_4, + /**< Divide high rate limiter by 4 */ + e_FM_PORT_DUAL_RATE_LIMITER_SCALE_DOWN_BY_8 + /**< Divide high rate limiter by 8 */ +} e_fm_port_dual_rate_limiter_scale_down; + +/* + * @Description A structure for defining FM port resources + */ +typedef struct t_fm_port_rsrc { + uint32_t num; + /**< Committed required resource */ + uint32_t extra; + /**< Extra (not committed) required resource */ +} t_fm_port_rsrc; + +/* + * @Description A structure for defining Tx rate limiting + */ +typedef struct t_fm_port_rate_limit { + uint16_t max_burst_size; + /**< in KBytes for Tx ports, in frames for OP + * ports. (note that for early chips burst size + * is rounded up to a multiply of 1000 frames). + */ + uint32_t rate_limit; + /**< in Kb/sec for Tx ports, in frame/sec for OP + * ports. Rate limit refers to data rate + * (rather than line rate). + */ + e_fm_port_dual_rate_limiter_scale_down rate_limit_divider; + /**< For OP ports only. Not-valid for some + * earlier chip revisions + */ +} t_fm_port_rate_limit; + +/* + * @Description A structure for defining the parameters of + * the Rx port performance counters + */ +typedef struct t_fm_port_performance_cnt { + uint8_t task_comp_val; + /**< Task compare value */ + uint8_t queue_comp_val; + /**< Rx queue/Tx confirm queue compare value (unused for H/O) */ + uint8_t dma_comp_val; + /**< Dma compare value */ + uint32_t fifo_comp_val; + /**< Fifo compare value (in bytes) */ +} t_fm_port_performance_cnt; + +/* + * @Function fm_port_config_num_of_open_dmas + * + * @Description Calling this routine changes the max number of open DMA's + * available for this port. It changes this parameter in the + * internal driver data base from its default configuration + * [OP: 1] + * [1G-RX, 1G-TX: 1 (+1)] + * [10G-RX, 10G-TX: 8 (+8)] + * + * @Param[in] h_fm_port A handle to a FM Port module. + * @Param[in] p_open_dmas A pointer to a structure of parameters defining + * the open DMA allocation. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_port_config() and before + * fm_port_init(). + */ +uint32_t fm_port_config_num_of_open_dmas(t_handle h_fm_port, + t_fm_port_rsrc *p_open_dmas); + +/* + * @Function fm_port_config_num_of_tasks + * + * @Description Calling this routine changes the max number of tasks available + * for this port. It changes this parameter in the internal + * driver data base from its default configuration + * [OP : 1] + * [1G - RX, 1G - TX : 3 ( + 2)] + * [10G - RX, 10G - TX : 16 ( + 8)] + * + * @Param[in] h_fm_port A handle to a FM Port module. + * @Param[in] p_num_of_tasks A pointer to a structure of parameters + * defining the tasks allocation. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_port_config() and before + * fm_port_init(). + */ +uint32_t fm_port_config_num_of_tasks(t_handle h_fm_port, + t_fm_port_rsrc *p_num_of_tasks); + +/* + * @Function fm_port_config_size_of_fifo + * + * @Description Calling this routine changes the max FIFO size configured for + * this port. + * + * This function changes the internal driver data base from its + * default configuration. Please refer to the driver's User Guide + * for information on default FIFO sizes in the various devices. + * [OP: 2KB] + * [1G-RX, 1G-TX: 11KB] + * [10G-RX, 10G-TX: 12KB] + * + * @Param[in] h_fm_port A handle to a FM Port module. + * @Param[in] p_size_of_fifo A pointer to a structure of parameters + * defining the FIFO allocation. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_port_config() and before + * fm_port_init(). + */ +uint32_t fm_port_config_size_of_fifo(t_handle h_fm_port, + t_fm_port_rsrc *p_size_of_fifo); + +/* + * @Function fm_port_config_deq_high_priority + * + * @Description Calling this routine changes the dequeue priority in the + * internal driver data base from its default configuration + * 1G: [DEFAULT_PORT_deqHighPriority_1G] + * 10G: [DEFAULT_PORT_deqHighPriority_10G] + * + * May be used for Non - Rx ports only + * + * @Param[in] h_fm_port A handle to a FM Port module. + * @Param[in] high_pri TRUE to select high priority, FALSE for normal + * operation. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_port_config() and before + * fm_port_init(). + */ +uint32_t fm_port_config_deq_high_priority(t_handle h_fm_port, bool high_pri); + +/* + * @Function fm_port_config_deq_type + * + * @Description Calling this routine changes the dequeue type parameter in the + * internal driver data base from its default configuration + * [DEFAULT_PORT_deq_type]. + * + * May be used for Non - Rx ports only + * + * @Param[in] h_fm_port A handle to a FM Port module. + * @Param[in] deq_type According to QM definition. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_port_config() and before + * fm_port_init(). + */ +uint32_t fm_port_config_deq_type(t_handle h_fm_port, + e_fm_port_deq_type deq_type); + +/* + * @Function fm_port_config_deq_prefetch_option + * + * @Description Calling this routine changes the dequeue prefetch option + * parameter in the internal driver data base from its default + * configuration [DEFAULT_PORT_deq_prefetch_option] + * Note: Available for some chips only + * + * May be used for Non - Rx ports only + * + * @Param[in] h_fm_port A handle to a FM Port module. + * @Param[in] deq_prefetch_option New option + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_port_config() and before + * fm_port_init(). + */ +uint32_t fm_port_config_deq_prefetch_option(t_handle h_fm_port, + e_fm_port_deq_prefetch_option deq_prefetch_option); + +/* + * @Function fm_port_config_deq_byte_cnt + * + * @Description Calling this routine changes the dequeue byte count parameter + * in the internal driver data base from its default + * configuration. + * 1G:[DEFAULT_PORT_deq_byte_cnt_1G]. + * 10G:[DEFAULT_PORT_deq_byte_cnt_10G]. + * + * May be used for Non - Rx ports only + * + * @Param[in] h_fm_port A handle to a FM Port module. + * @Param[in] deq_byte_cnt New byte count + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_port_config() and before + * fm_port_init(). + */ +uint32_t fm_port_config_deq_byte_cnt(t_handle h_fm_port, + uint16_t deq_byte_cnt); + +/* + * @Function fm_port_config_buffer_prefix_content + * + * @Description Defines the structure, size and content of the application + * buffer. The prefix will In Tx ports, if 'pass_prs_result', the + * application should set a value to their offsets in the prefix + * of the FM will save the first 'priv_data_size', than, + * depending on 'pass_prs_result' and 'pass_time_stamp', copy + * parse result and timeStamp, and the packet itself (in this + * order), to the application buffer, and to offset. + * Calling this routine changes the buffer margins definitions in + * the internal driver data base from its default configuration: + * Data size: [DEFAULT_PORT_bufferPrefixContent_priv_data_size] + * Pass Parser result: + * [DEFAULT_PORT_bufferPrefixContent_pass_prs_result]. + * Pass timestamp: + * [DEFAULT_PORT_bufferPrefixContent_pass_time_stamp]. + * + * May be used for all ports + * + * + * @Param[in] h_fm_port A handle to a FM Port + * module. + * @Param[in,out] p_fm_buffer_prefix_content A structure of + * parameters describing + * the structure of the + * buffer. + * Out parameter: Start + * margin - offset of data + * from start of external + * buffer. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_port_config() and before + * fm_port_init(). + */ +uint32_t fm_port_config_buffer_prefix_content(t_handle h_fm_port, + t_fm_buffer_prefix_content *p_fm_buffer_prefix_content); + +/* + * @Function fm_port_config_checksum_last_bytes_ignore + * + * @Description Calling this routine changes the number of checksum bytes to + * ignore parameter in the internal driver data base from its + * default configuration. + * + * May be used by Tx & Rx ports only + * + * @Param[in] h_fm_port A handle to a FM Port module. + * @Param[in] checksum_last_bytes_ignore New value + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_port_config() and before + * fm_port_init(). + */ +uint32_t fm_port_config_checksum_last_bytes_ignore(t_handle h_fm_port, + uint8_t checksum_last_bytes_ignore); + +/* + * @Function fm_port_config_cut_bytes_from_end + * + * @Description Calling this routine changes the number of bytes to cut from a + * frame's end parameter in the internal driver data base + * from its default configuration + * [DEFAULT_PORT_cut_bytes_from_end] + * Note that if the result of (frame length before chop - + * cut_bytes_from_end) is less than 14 bytes, the chop operation + * is not executed. + * + * May be used for Rx ports only + * + * @Param[in] h_fm_port A handle to a FM Port module. + * @Param[in] cut_bytes_from_end New value + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_port_config() and before + * fm_port_init(). + */ +uint32_t fm_port_config_cut_bytes_from_end(t_handle h_fm_port, + uint8_t cut_bytes_from_end); + +/* + * @Function fm_port_config_ext_buf_pools + * + * @Description This routine should be called for OP ports that internally use + * BM buffer pools. In such cases, e.g. for fragmentation and + * re-assembly, the FM needs new BM buffers. By calling this + * routine the user specifies the BM buffer pools that should be + * used. + * + * Note: Available for some chips only + * + * May be used for OP ports only + * + * @Param[in] h_fm_port A handle to a FM Port module. + * @Param[in] p_fm_ext_pools A structure of parameters for the + * external pools. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_port_config() and before + * fm_port_init(). + */ +uint32_t fm_port_config_ext_buf_pools(t_handle h_fm_port, + t_fm_ext_pools *p_fm_ext_pools); + +/* + * @Function fm_port_config_backup_pools + * + * @Description Calling this routine allows the configuration of some of the + * BM pools defined for this port as backup pools. + * A pool configured to be a backup pool will be used only if all + * other enabled non - backup pools are depleted. + * + * May be used for Rx ports only + * + * @Param[in] h_fm_port A handle to a FM Port module. + * @Param[in] p_fm_port_backup_bm_pools An array of pool id's. All pools + * specified here will be defined + * as backup pools. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_port_config() and before + * fm_port_init(). + */ +uint32_t fm_port_config_backup_pools(t_handle h_fm_port, + t_fm_backup_bm_pools *p_fm_port_backup_bm_pools); + +/* + * @Function fm_port_config_frm_discard_override + * + * @Description Calling this routine changes the error frames destination + * parameter in the internal driver data base from its default + * configuration: override =[DEFAULT_PORT_frmDiscardOverride] + * + * May be used for Rx and OP ports only + * + * @Param[in] h_fm_port A handle to a FM Port module. + * @Param[in] override TRUE to override discarding of error frames and + * enqueueing them to error queue. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_port_config() and before + * fm_port_init(). + */ +uint32_t fm_port_config_frm_discard_override(t_handle h_fm_port, + bool override); + +/* + * @Function fm_port_config_errors_to_discard + * + * @Description Calling this routine changes the behaviour on error parameter + * in the internal driver data base from its default + * configuration: [DEFAULT_PORT_errorsToDiscard]. + * If a requested error was previously defined as + * "ErrorsToEnqueue" it's definition will change and the frame + * will be discarded. Errors that were not defined either as + * "ErrorsToEnqueue" nor as "ErrorsToDiscard", will be forwarded + * to CPU. + * + * May be used for Rx and OP ports only + * + * @Param[in] h_fm_port A handle to a FM Port module. + * @Param[in] errs A list of errors to discard + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_port_config() and before + * fm_port_init(). + */ +uint32_t fm_port_config_errors_to_discard(t_handle h_fm_port, + fm_port_frame_err_select_t errs); + +/* + * @Function fm_port_config_dma_ic_cache_attr + * + * @Description Calling this routine changes the internal context cache + * attribute parameter in the internal driver data base + * from its default configuration: + * [DEFAULT_PORT_dmaIntContextCacheAttr] + * + * May be used for all port types + * + * @Param[in] h_fm_port A handle to a FM Port module. + * @Param[in] int_context_cache_attr New selection + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_port_config() and before + * fm_port_init(). + */ +uint32_t fm_port_config_dma_ic_cache_attr(t_handle h_fm_port, + e_fm_dma_cache_option int_context_cache_attr); + +/* + * @Function fm_port_config_dma_hdr_attr + * + * @Description Calling this routine changes the header cache attribute + * parameter in the internal driver data base from its default + * configuration[DEFAULT_PORT_dmaHeaderCacheAttr] + * + * May be used for all port types + * + * @Param[in] h_fm_port A handle to a FM Port module. + * @Param[in] header_cache_attr New selection + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_port_config() and before + * fm_port_init(). + */ +uint32_t fm_port_config_dma_hdr_attr(t_handle h_fm_port, + e_fm_dma_cache_option header_cache_attr); + +/* + * @Function fm_port_config_dma_scatter_gather_attr + * + * @Description Calling this routine changes the scatter gather cache + * attribute parameter in the internal driver data base from its + * default configuration[DEFAULT_PORT_dmaScatterGatherCacheAttr] + * + * May be used for all port types + * + * @Param[in] h_fm_port A handle to a FM Port module. + * @Param[in] scatter_gather_cache_attr New selection + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_port_config() and before + * fm_port_init(). + */ +uint32_t fm_port_config_dma_scatter_gather_attr(t_handle h_fm_port, + e_fm_dma_cache_option scatter_gather_cache_attr); + +/* + * @Function fm_port_config_dma_write_optimize + * + * @Description Calling this routine changes the write optimization parameter + * in the internal driver data base from its default + * configuration : By default optimize = + * [DEFAULT_PORT_dmaWriteOptimize]. + * Note: + * 1. For head optimization, data alignment must be >= 16 + * (supported by default). + * + * 2. For tail optimization, note that the optimization is + * performed by extending the write transaction of the frame + * payload at the tail as needed to achieve optimal bus + * transfers, so that the last write is extended to be on + * 16 / 64 bytes aligned block (chip dependent). + * + * Relevant for non - Tx port types + * + * @Param[in] h_fm_port A handle to a FM Port module. + * @Param[in] optimize TRUE to enable optimization, FALSE for normal + * operation + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_port_config() and before + * fm_port_init(). + */ +uint32_t fm_port_config_dma_write_optimize(t_handle h_fm_port, + bool optimize); + +/* + * @Function fm_port_config_no_scather_gather + * + * @Description Calling this routine changes the no_scather_gather parameter + * in internal driver data base from its default configuration. + * + * @Param[in] h_fm_port A handle to a FM Port module. + * @Param[in] no_scather_gather TRUE - frame is discarded if can not be + * stored in single buffer, + * FALSE - frame can be stored in scatter + * gather (S / G) format. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_port_config() and before + * fm_port_init(). + */ +uint32_t fm_port_config_no_scather_gather(t_handle h_fm_port, + bool no_scather_gather); + +/* + * @Function fm_port_config_dflt_color + * + * @Description Calling this routine changes the internal default color + * parameter in the internal driver data base + * from its default configuration[DEFAULT_PORT_color] + * + * May be used for all port types + * + * @Param[in] h_fm_port A handle to a FM Port module. + * @Param[in] color New selection + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_port_config() and before + * fm_port_init(). + */ +uint32_t fm_port_config_dflt_color(t_handle h_fm_port, e_fm_port_color color); + +/* + * @Function fm_port_config_sync_req + * + * @Description Calling this routine changes the synchronization attribute + * parameter in the internal driver data base from its default + * configuration: sync_req =[DEFAULT_PORT_sync_req] + * + * May be used for all port types + * + * @Param[in] h_fm_port A handle to a FM Port module. + * @Param[in] sync_req TRUE to request synchronization, FALSE + * otherwise. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_port_config() and before + * fm_port_init(). + */ +uint32_t fm_port_config_sync_req(t_handle h_fm_port, bool sync_req); + +/* + * @Function fm_port_config_forward_reuse_int_context + * + * @Description This routine is relevant for Rx ports that are routed to OP + * port. It changes the internal context reuse option in the + * internal driver data base from its default configuration: + * reuse =[DEFAULT_PORT_forwardIntContextReuse] + * + * May be used for Rx ports only + * + * @Param[in] h_fm_port A handle to a FM Port module. + * @Param[in] reuse TRUE to reuse internal context on frames + * forwarded to OP port. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_port_config() and before + * fm_port_init(). + */ +uint32_t fm_port_config_forward_reuse_int_context(t_handle h_fm_port, + bool reuse); + +/* + * @Function fm_port_config_donot_release_tx_buf_to_bm + * + * @Description This routine should be called if no Tx confirmation + * is done, and yet buffers should not be released to the BM. + * + * Normally, buffers are returned using the Tx confirmation + * process. When Tx confirmation is not used (defFqid = 0), + * buffers are typically released to the BM. This routine + * may be called to avoid this behavior and not release the + * buffers. + * + * May be used for Tx ports only + * + * @Param[in] h_fm_port A handle to a FM Port module. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_port_config() and before + * fm_port_init(). + */ +uint32_t fm_port_config_donot_release_tx_buf_to_bm(t_handle h_fm_port); + +/* + * @Function fm_port_config_immax_rx_buf_length + * + * @Description Changes the maximum receive buffer length from its default + * configuration: Closest rounded down power of 2 value of the + * data buffer size. + * + * The maximum receive buffer length directly affects the + * structure of received frames (single- or multi-buffered) and + * the performance of both the FM and the driver. + * + * The selection between single- or multi-buffered frames should + * be done according to the characteristics of the specific + * application. The recommended mode is to use a single data + * buffer per packet, as this mode provides the best performance. + * However, the user can select to use multiple data buffers per + * packet. + * + * @Param[in] h_fm_port A handle to a FM Port module. + * @Param[in] new_val Maximum receive buffer length (in bytes). + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_port_config() and before + * fm_port_init(). This routine is to be used only if + * Independent-Mode is enabled. + */ +uint32_t fm_port_config_immax_rx_buf_length(t_handle h_fm_port, + uint16_t new_val); + +/* + * @Function fm_port_config_imrx_bd_ring_length + * + * @Description Changes the receive BD ring length from its default + * configuration:[DEFAULT_PORT_rxBdRingLength] + * + * @Param[in] h_fm_port A handle to a FM Port module. + * @Param[in] new_val The desired BD ring length. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_port_config() and before + * fm_port_init(). This routine is to be used only if + * Independent-Mode is enabled. + */ +uint32_t fm_port_config_imrx_bd_ring_length(t_handle h_fm_port, + uint16_t new_val); + +/* + * @Function fm_port_config_imtx_bd_ring_length + * + * @Description Changes the transmit BD ring length from its default + * configuration:[DEFAULT_PORT_txBdRingLength] + * + * @Param[in] h_fm_port A handle to a FM Port module. + * @Param[in] new_val The desired BD ring length. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_port_config() and before + * fm_port_init(). This routine is to be used only if + * Independent-Mode is enabled. + */ +uint32_t fm_port_config_imtx_bd_ring_length(t_handle h_fm_port, + uint16_t new_val); + +/* + * @Function fm_port_config_imfman_ctrl_external_structs_memory + * + * @Description Configures memory partition and attributes for FMan-Controller + * data structures (e.g. BD rings). + * Calling this routine changes the internal driver data base + * from its default configuration + * [DEFAULT_PORT_ImfwExtStructsMemId, + * DEFAULT_PORT_ImfwExtStructsMemAttr]. + * + * @Param[in] h_fm_port A handle to a FM Port module. + * @Param[in] mem_id Memory partition ID. + * @Param[in] mem_attributes Memory attributes mask (a combination of + * MEMORY_ATTR_x flags). + * + * @Return E_OK on success; Error code otherwise. + */ +uint32_t fm_port_config_imfman_ctrl_external_structs_memory(t_handle h_fm_port, + uint8_t mem_id, + uint32_t mem_attributes); + +/* + * @Function fm_port_config_impolling + * + * @Description Changes the Rx flow from interrupt driven (default) to + * polling. + * + * @Param[in] h_fm_port A handle to a FM Port module. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_port_config() and before + * fm_port_init(). + * This routine is to be used only if Independent-Mode is + * enabled. + */ +uint32_t fm_port_config_impolling(t_handle h_fm_port); + +/* + * @Function fm_port_config_max_frame_length + * + * @Description Changes the definition of the max size of frame that should be + * transmitted/received on this port from its default value + * [DEFAULT_PORT_maxFrameLength]. + * This parameter is used for confirmation of the minimum Fifo + * size calculations and only for Tx ports or ports working in + * independent mode. This should be larger than the maximum + * possible MTU that will be used for this port (i.e. its MAC). + * + * @Param[in] h_fm_port A handle to a FM Port module. + * @Param[in] length Max size of frame + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_port_config() and before + * fm_port_init(). This routine is to be used only if + * Independent-Mode is enabled. + */ +uint32_t fm_port_config_max_frame_length(t_handle h_fm_port, + uint16_t length); + +/* + * @Function fm_port_config_tx_fifo_min_fill_level + * + * @Description Calling this routine changes the fifo minimum fill level + * parameter in the internal driver data base from its default + * configuration[DEFAULT_PORT_txFifoMinFillLevel] + * + * May be used for Tx ports only + * + * @Param[in] h_fm_port A handle to a FM Port module. + * @Param[in] min_fill_level New value + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_port_config() and before + * fm_port_init(). + */ +uint32_t fm_port_config_tx_fifo_min_fill_level(t_handle h_fm_port, + uint32_t min_fill_level); + +/* + * @Function fm_port_config_fifo_deq_pipeline_depth + * + * @Description Calling this routine changes the fifo dequeue pipeline depth + * parameter in the internal driver data base + * + * from its default configuration : + * 1G ports : [DEFAULT_PORT_fifoDeqPipelineDepth_1G], + * 10G port : [DEFAULT_PORT_fifoDeqPipelineDepth_10G], + * OP port : [DEFAULT_PORT_fifoDeqPipelineDepth_OH] + * + * May be used for Tx / OP ports only + * + * @Param[in] h_fm_port A handle to a FM Port module. + * @Param[in] deq_pipeline_depth New value + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_port_config() and before + * fm_port_init(). + */ +uint32_t fm_port_config_fifo_deq_pipeline_depth(t_handle h_fm_port, + uint8_t deq_pipeline_depth); + +/* + * @Function fm_port_config_tx_fifo_low_comf_level + * + * @Description Calling this routine changes the fifo low comfort level + * parameter in internal driver data base from its default + * configuration[DEFAULT_PORT_txFifoLowComfLevel] + * + * May be used for Tx ports only + * + * @Param[in] h_fm_port A handle to a FM Port module. + * @Param[in] fifo_low_comf_level New value + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_port_config() and before + * fm_port_init(). + */ +uint32_t fm_port_config_tx_fifo_low_comf_level(t_handle h_fm_port, + uint32_t fifo_low_comf_level); + +/* + * @Function fm_port_config_rx_fifo_threshold + * + * @Description Calling this routine changes the threshold of the FIFO fill + * level parameter in the internal driver data base from its + * default configuration[DEFAULT_PORT_rxFifoThreshold] + * + * If the total number of buffers which are currently in use and + * associated with the specific RX port exceed this threshold, + * the BMI will signal the MAC to send a pause frame over the + * link. + * + * May be used for Rx ports only + * + * @Param[in] h_fm_port A handle to a FM Port module. + * @Param[in] fifo_threshold New value + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_port_config() and before + * fm_port_init(). + */ +uint32_t fm_port_config_rx_fifo_threshold(t_handle h_fm_port, + uint32_t fifo_threshold); + +/* + * @Function fm_port_config_rx_fifo_pri_elevation_level + * + * @Description Calling this routine changes the priority elevation level + * parameter in the internal driver data base from its default + * configuration[DEFAULT_PORT_rxFifoPriElevationLevel] + * + * If the total number of buffers which are currently in use and + * associated with the specific RX port exceed the amount + * specified in pri_elevation_level, BMI will signal the main + * FM's DMA to elevate the FM priority on the system bus. + * + * May be used for Rx ports only + * + * @Param[in] h_fm_port A handle to a FM Port module. + * @Param[in] pri_elevation_level New value + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_port_config() and before + * fm_port_init(). + */ +uint32_t fm_port_config_rx_fifo_pri_elevation_level(t_handle h_fm_port, + uint32_t pri_elevation_level); + +#ifdef FM_HEAVY_TRAFFIC_HANG_ERRATA_FMAN_A005669 +/* + * @Function fm_port_config_bcbworkaround + * + * @Description Configures BCB errata workaround. + * + * When BCB errata is applicable, the workaround is always + * performed by FM Controller. Thus, this functions doesn't + * actually enable errata workaround but rather allows driver to + * perform adjustments required due to errata workaround + * execution in FM controller. + * + * Applying BCB workaround also configures + * FM_PORT_FRM_ERR_PHYSICAL errors to be discarded. Thus + * FM_PORT_FRM_ERR_PHYSICAL can't be set by + * fm_port_set_errors_route() function. + * + * @Param[in] h_fm_port A handle to a FM Port module. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_port_config() and before + * fm_port_init(). + */ +uint32_t fm_port_config_bcbworkaround(t_handle h_fm_port); +#endif /* FM_HEAVY_TRAFFIC_HANG_ERRATA_FMAN_A005669 */ + +/* + * @Function fm_port_config_internal_buff_offset + * + * @Description Configures internal buffer offset. + * + * May be used for Rx and OP ports only + * + * @Param[in] h_fm_port A handle to a FM Port module. + * @Param[in] val New value + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_port_config() and before + * fm_port_init(). + */ +uint32_t fm_port_config_internal_buff_offset(t_handle h_fm_port, uint8_t val); + +/** @} */ /* end of FM_PORT_advanced_init_grp group */ +/** @} */ /* end of FM_PORT_init_grp group */ + +/* + * @Group FM_PORT_runtime_control_grp FM Port Runtime Control Unit + * + * @Description FM Port Runtime control unit API functions, definitions and + * enums. + * + * @{ + */ + +/* + * @Description enum for defining FM Port counters + */ +typedef enum e_fm_port_counters { + e_FM_PORT_COUNTERS_CYCLE, /**< BMI performance counter */ + e_FM_PORT_COUNTERS_TASK_UTIL, /**< BMI performance counter */ + e_FM_PORT_COUNTERS_QUEUE_UTIL, /**< BMI performance counter */ + e_FM_PORT_COUNTERS_DMA_UTIL, /**< BMI performance counter */ + e_FM_PORT_COUNTERS_FIFO_UTIL, /**< BMI performance counter */ + e_FM_PORT_COUNTERS_RX_PAUSE_ACTIVATION, + /**< BMI Rx only performance counter */ + e_FM_PORT_COUNTERS_FRAME, /**< BMI statistics counter */ + e_FM_PORT_COUNTERS_DISCARD_FRAME, /**< BMI statistics counter */ + e_FM_PORT_COUNTERS_DEALLOC_BUF, + /**< BMI deallocate buffer statistics counter */ + e_FM_PORT_COUNTERS_RX_BAD_FRAME, + /**< BMI Rx only statistics counter */ + e_FM_PORT_COUNTERS_RX_LARGE_FRAME, + /**< BMI Rx only statistics counter */ + e_FM_PORT_COUNTERS_RX_FILTER_FRAME, + /**< BMI Rx & OP only statistics counter */ + e_FM_PORT_COUNTERS_RX_LIST_DMA_ERR, + /**< BMI Rx, OP & HC only statistics counter */ + e_FM_PORT_COUNTERS_RX_OUT_OF_BUFFERS_DISCARD, + /**< BMI Rx, OP & HC statistics counter */ + e_FM_PORT_COUNTERS_PREPARE_TO_ENQUEUE_COUNTER, + /**< BMI Rx, OP & HC only statistics counter */ + e_FM_PORT_COUNTERS_WRED_DISCARD, + /**< BMI OP & HC only statistics counter */ + e_FM_PORT_COUNTERS_LENGTH_ERR, + /**< BMI non-Rx statistics counter */ + e_FM_PORT_COUNTERS_UNSUPPRTED_FORMAT, + /**< BMI non-Rx statistics counter */ + e_FM_PORT_COUNTERS_DEQ_TOTAL, /**< QMI total QM dequeues counter */ + e_FM_PORT_COUNTERS_ENQ_TOTAL, /**< QMI total QM enqueues counter */ + e_FM_PORT_COUNTERS_DEQ_FROM_DEFAULT, /**< QMI counter */ + e_FM_PORT_COUNTERS_DEQ_CONFIRM /**< QMI counter */ +} e_fm_port_counters; + +typedef struct t_fm_port_bmi_stats { + uint32_t cnt_cycle; + uint32_t cnt_task_util; + uint32_t cnt_queue_util; + uint32_t cnt_dma_util; + uint32_t cnt_fifo_util; + uint32_t cnt_rx_pause_activation; + uint32_t cnt_frame; + uint32_t cnt_discard_frame; + uint32_t cnt_dealloc_buf; + uint32_t cnt_rx_bad_frame; + uint32_t cnt_rx_large_frame; + uint32_t cnt_rx_filter_frame; + uint32_t cnt_rx_list_dma_err; + uint32_t cnt_rx_out_of_buffers_discard; + uint32_t cnt_wred_discard; + uint32_t cnt_length_err; + uint32_t cnt_unsupported_format; +} t_fm_port_bmi_stats; + +/* + * @Description Structure for Port id parameters. + * Fields commented 'IN' are passed by the port module to be used + * by the FM module. + * Fields commented 'OUT' will be filled by FM before returning + * to port. + */ +typedef struct t_fm_port_congestion_grps { + uint16_t num_of_congestion_grps_to_consider; + /**< The number of required CGs to define the size of + * the following array + */ + uint8_t congestion_grps_to_consider[FM_NUM_CONG_GRPS]; + /**< An array of CG indexes; Note that the size of the + * array should be 'num_of_congestion_grps_to_consider'. + */ + bool pfc_prio_enable[FM_NUM_CONG_GRPS][FM_MAX_PFC_PRIO]; + /**< a matrix that represents the map between the CG ids + * defined in 'congestion_grps_to_consider' to the + * priorties mapping array. + */ +} t_fm_port_congestion_grps; + + +#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0)) +/* + * @Function fm_port_dump_regs + * + * @Description Dump all regs. + * + * Calling this routine invalidates the descriptor. + * + * @Param[in] h_fm_port FM PORT module descriptor + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_port_init(). + */ +uint32_t fm_port_dump_regs(t_handle h_fm_port); +#endif /* (defined(DEBUG_ERRORS) && ... */ + +/* + * @Function fm_port_get_buffer_data_offset + * + * @Description Relevant for Rx ports. Returns the data offset from the + * beginning of the data buffer + * + * @Param[in] h_fm_port FM PORT module descriptor + * + * @Return data offset. + * + * @Cautions Allowed only following fm_port_init(). + */ +uint32_t fm_port_get_buffer_data_offset(t_handle h_fm_port); + +/* + * @Function fm_port_get_buffer_icinfo + * + * @Description Returns the Internal Context offset from the beginning of the + * data buffer + * + * @Param[in] h_fm_port FM PORT module descriptor + * @Param[in] p_data A pointer to the data buffer. + * + * @Return Internal context info pointer on success, NULL if + * 'allOtherInfo' was not configured for this port. + * + * @Cautions Allowed only following fm_port_init(). + */ +uint8_t *fm_port_get_buffer_icinfo(t_handle h_fm_port, char *p_data); + +/* + * @Function fm_port_get_buffer_prs_result + * + * @Description Returns the pointer to the parse result in the data buffer. + * In Rx ports this is relevant after reception, if parse result + * is configured to be part of the data passed to the + * application. For non Rx ports it may be used to get the + * pointer of the area in the buffer where parse result should be + * initialized - if so configured. + * See fm_port_config_buffer_prefix_content for data buffer + * prefix configuration. + * + * @Param[in] h_fm_port FM PORT module descriptor + * @Param[in] p_data A pointer to the data buffer. + * + * @Return Parse result pointer on success, NULL if parse result was not + * configured for this port. + * + * @Cautions Allowed only following fm_port_init(). + */ +t_fm_prs_result *fm_port_get_buffer_prs_result(t_handle h_fm_port, + char *p_data); + +/* + * @Function fm_port_get_buffer_time_stamp + * + * @Description Returns the time stamp in the data buffer. + * Relevant for Rx ports for getting the buffer time stamp. + * See fm_port_config_buffer_prefix_content for data buffer + * prefix configuration. + * + * @Param[in] h_fm_port FM PORT module descriptor + * @Param[in] p_data A pointer to the data buffer. + * + * @Return A pointer to the hash result on success, NULL otherwise. + * + * @Cautions Allowed only following fm_port_init(). + */ +uint64_t *fm_port_get_buffer_time_stamp(t_handle h_fm_port, char *p_data); + +/* + * @Function fm_port_get_buffer_hash_result + * + * @Description Given a data buffer, on the condition that hash result was + * defined as a part of the buffer content(see + * fm_port_config_buffer_prefix_content) this routine will return + * the pointer to the hash result location in the buffer prefix. + * + * @Param[in] h_fm_port FM PORT module descriptor + * @Param[in] p_data A pointer to the data buffer. + * + * @Return A pointer to the hash result on success, NULL otherwise. + * + * @Cautions Allowed only following fm_port_init(). + */ +uint8_t *fm_port_get_buffer_hash_result(t_handle h_fm_port, char *p_data); + +/* + * @Function fm_port_disable + * + * @Description Gracefully disable an FM port. The port will not start new + * tasks after all tasks associated with the port are terminated. + * + * @Param[in] h_fm_port A handle to a FM Port module. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_port_init(). + * This is a blocking routine, it returns after port is + * gracefully stopped, i.e. the port will not except new frames, + * but it will finish all frames or tasks which were already + * began + */ +uint32_t fm_port_disable(t_handle h_fm_port); + +/* + * @Function fm_port_enable + * + * @Description A runtime routine provided to allow disable/enable of port. + * + * @Param[in] h_fm_port A handle to a FM Port module. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_port_init(). + */ +uint32_t fm_port_enable(t_handle h_fm_port); + +/* + * @Function fm_port_set_rate_limit + * + * @Description Calling this routine enables rate limit algorithm. + * By default, this functionality is disabled. + * + * Note that rate - limit mechanism uses the FM time stamp. + * The selected rate limit specified here would be + * rounded DOWN to the nearest 16M. + * + * May be used for Tx and OP ports only + * + * @Param[in] h_fm_port A handle to a FM Port module. + * @Param[in] p_rate_limit A structure of rate limit parameters + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_port_init(). If rate limit is set + * on a port that need to send PFC frames, it might violate the + * stop transmit timing. + */ +uint32_t fm_port_set_rate_limit(t_handle h_fm_port, + t_fm_port_rate_limit *p_rate_limit); + +/* + * @Function fm_port_delete_rate_limit + * + * @Description Calling this routine disables and clears rate limit + * initialization. + * + * May be used for Tx and OP ports only + * + * @Param[in] h_fm_port A handle to a FM Port module. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_port_init(). + */ +uint32_t fm_port_delete_rate_limit(t_handle h_fm_port); + +/* + * @Function fm_port_set_pfc_priorities_mapping_to_qman_wq + + * @Description Calling this routine maps each PFC received priority to the + * transmit WQ. This WQ will be blocked upon receiving a PFC + * frame with this priority. + * + * May be used for Tx ports only. + * + * @Param[in] h_fm_port A handle to a FM Port module. + * @Param[in] prio PFC priority (0 - 7). + * @Param[in] wq Work Queue (0 - 7). + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_port_init(). + */ +uint32_t fm_port_set_pfc_priorities_mapping_to_qman_wq(t_handle h_fm_port, + uint8_t prio, uint8_t wq); + +/* + * @Function fm_port_set_statistics_counters + * + * @Description Calling this routine enables/disables port's statistics + * counters. By default, counters are enabled. + * + * May be used for all port types + * + * @Param[in] h_fm_port A handle to a FM Port module. + * @Param[in] enable TRUE to enable, FALSE to disable. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_port_init(). + */ +uint32_t fm_port_set_statistics_counters(t_handle h_fm_port, bool enable); + +/* + * @Function fm_port_set_frame_queue_counters + * + * @Description Calling this routine enables/disables port's enqueue/dequeue + * counters. By default, counters are enabled. + * + * May be used for all ports + * + * @Param[in] h_fm_port A handle to a FM Port module. + * @Param[in] enable TRUE to enable, FALSE to disable. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_port_init(). + */ +uint32_t fm_port_set_frame_queue_counters(t_handle h_fm_port, + bool enable); + +/* + * @Function fm_port_analyze_performance_params + * + * @Description User may call this routine to so the driver will analyze if + * the basic performance parameters are correct and also the + * driver may suggest of improvements; The basic parameters are + * FIFO sizes, number of DMAs and number of TNUMs for the port. + * + * May be used for all port types + * + * @Param[in] h_fm_port A handle to a FM Port module. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_port_init(). + */ +uint32_t fm_port_analyze_performance_params(t_handle h_fm_port); + +/* + * @Function fm_port_set_alloc_buf_counter + * + * @Description Calling this routine enables/disables BM pool allocate + * buffer counters. + * By default, counters are enabled. + * + * May be used for Rx ports only + * + * @Param[in] h_fm_port A handle to a FM Port module. + * @Param[in] pool_id BM pool id. + * @Param[in] enable TRUE to enable, FALSE to disable. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_port_init(). + */ +uint32_t fm_port_set_alloc_buf_counter(t_handle h_fm_port, + uint8_t pool_id, bool enable); + +/* + * @Function fm_port_get_bmi_counters + * + * @Description Read port's BMI stat counters and place them into + * a designated structure of counters. + * + * @Param[in] h_fm_port A handle to a FM Port module. + * @Param[out] p_bmi_stats counters structure + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_port_init(). + */ +uint32_t fm_port_get_bmi_counters(t_handle h_fm_port, + t_fm_port_bmi_stats *p_bmi_stats); + +/* + * @Function fm_port_get_counter + * + * @Description Reads one of the FM PORT counters. + * + * @Param[in] h_fm_port A handle to a FM Port module. + * @Param[in] fm_port_counter The requested counter. + * + * @Return Counter's current value. + * + * @Cautions Allowed only following fm_port_init(). + * Note that it is user's responsibility to call this routine + * only for enabled counters, and there will be no indication if + * a disabled counter is accessed. + */ +uint32_t fm_port_get_counter(t_handle h_fm_port, + e_fm_port_counters fm_port_counter); + +/* + * @Function fm_port_modify_counter + * + * @Description Sets a value to an enabled counter. Use "0" to reset the + * counter. + * + * @Param[in] h_fm_port A handle to a FM Port module. + * @Param[in] fm_port_counter The requested counter. + * @Param[in] value The requested value to be written into + * the counter. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_port_init(). + */ +uint32_t fm_port_modify_counter(t_handle h_fm_port, + e_fm_port_counters fm_port_counter, uint32_t value); + +/* + * @Function fm_port_get_alloc_buf_counter + * + * @Description Reads one of the FM PORT buffer counters. + * + * @Param[in] h_fm_port A handle to a FM Port module. + * @Param[in] pool_id The requested pool. + * + * @Return Counter's current value. + * + * @Cautions Allowed only following fm_port_init(). + * Note that it is user's responsibility to call this routine + * only for enabled counters, and there will be no indication if + * a disabled counter is accessed. + */ +uint32_t fm_port_get_alloc_buf_counter(t_handle h_fm_port, + uint8_t pool_id); + +/* + * @Function fm_port_modify_alloc_buf_counter + * + * @Description Sets a value to an enabled counter. Use "0" to reset the + * counter. + * + * @Param[in] h_fm_port A handle to a FM Port module. + * @Param[in] pool_id The requested pool. + * @Param[in] value The requested value to be written into the + * counter. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_port_init(). + */ +uint32_t fm_port_modify_alloc_buf_counter(t_handle h_fm_port, + uint8_t pool_id, uint32_t value); + +/* + * @Function fm_port_add_congestion_grps + * + * @Description This routine effects the corresponding Tx port. + * It should be called in order to enable pause + * frame transmission in case of congestion in one or more + * of the congestion groups relevant to this port. + * Each call to this routine may add one or more congestion + * groups to be considered relevant to this port. + * + * May be used for Rx, or RX + OP ports only (depending on chip) + * + * @Param[in] h_fm_port A handle to a FM Port module. + * @Param[in] p_congestion_grps A pointer to an array of congestion + * groups id's to consider. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_port_init(). + */ +uint32_t fm_port_add_congestion_grps(t_handle h_fm_port, + t_fm_port_congestion_grps *p_congestion_grps); + +/* + * @Function fm_port_remove_congestion_grps + * + * @Description This routine effects the corresponding Tx port. It should be + * called when congestion groups were defined for this port and + * are no longer relevant, or pause frames transmitting is not + * required on their behalf. + * Each call to this routine may remove one or more congestion + * groups to be considered relevant to this port. + * + * May be used for Rx, or RX + OP ports only (depending on chip) + * + * @Param[in] h_fm_port A handle to a FM Port module. + * @Param[in] p_congestion_grps A pointer to an array of congestion + * groups id's to consider. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_port_init(). + */ +uint32_t fm_port_remove_congestion_grps(t_handle h_fm_port, + t_fm_port_congestion_grps *p_congestion_grps); + +/* + * @Function fm_port_is_stalled + * + * @Description A routine for checking whether the specified port is stalled. + * + * @Param[in] h_fm_port A handle to a FM Port module. + * + * @Return TRUE if port is stalled, FALSE otherwise + * + * @Cautions Allowed only following fm_port_init(). + */ +bool fm_port_is_stalled(t_handle h_fm_port); + +/* + * @Function fm_port_release_stalled + * + * @Description This routine may be called in case the port was stalled and + * may now be released. + * Note that this routine is available only on older FMan + * revisions (FMan v2, DPAA v1.0 only). + * + * @Param[in] h_fm_port A handle to a FM Port module. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_port_init(). + */ +uint32_t fm_port_release_stalled(t_handle h_fm_port); + +/* + * @Function fm_port_set_rx_l4checksum_verify + * + * @Description This routine is relevant for Rx ports (1G and 10G). The + * routine set / clear the L3 / L4 checksum verification (on RX + * side). Note that this takes affect only if hw - parser is + * enabled ! + * + * @Param[in] h_fm_port A handle to a FM Port module. + * @Param[in] l_4checksum boolean indicates whether to do L3/L4 checksum + * on frames or not. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_port_init(). + */ +uint32_t fm_port_set_rx_l4checksum_verify(t_handle h_fm_port, + bool l_4checksum); + +/* + * @Function fm_port_set_errors_route + * + * @Description Errors selected for this routine will cause a frame with that + * error to be enqueued to error queue. + * Errors not selected for this routine will cause a frame with + * that error to be enqueued to the one of the other port queues. + * By default all errors are defined to be enqueued to error + * queue. Errors that were configured to be discarded(at + * initialization) may not be selected here. + * + * May be used for Rx and OP ports only + * + * @Param[in] h_fm_port A handle to a FM Port module. + * @Param[in] errs A list of errors to enqueue to error queue + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_port_config() and before + * fm_port_init(). + */ +uint32_t fm_port_set_errors_route(t_handle h_fm_port, + fm_port_frame_err_select_t errs); + +/* + * @Function fm_port_set_imexceptions + * + * @Description Calling this routine enables/disables FM PORT interrupts. + * + * @Param[in] h_fm_port FM PORT module descriptor. + * @Param[in] exception The exception to be selected. + * @Param[in] enable TRUE to enable interrupt, FALSE to mask it. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_port_init(). + * This routine should NOT be called from guest-partition + * (i.e. guestId != NCSW_PRIMARY_ID) + */ +uint32_t fm_port_set_imexceptions(t_handle h_fm_port, + e_fm_port_exceptions exception, bool enable); + +/* + * @Function fm_port_set_performance_counters + * + * @Description Calling this routine enables/disables port's performance + * counters. By default, counters are enabled. + * + * May be used for all port types + * + * @Param[in] h_fm_port A handle to a FM Port module. + * @Param[in] enable TRUE to enable, FALSE to disable. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_port_init(). + */ +uint32_t fm_port_set_performance_counters(t_handle h_fm_port, + bool enable); + +/* + * @Function fm_port_set_performance_counters_params + * + * @Description Calling this routine defines port's performance counters + * parameters. + * + * May be used for all port types + * + * @Param[in] h_fm_port A handle to a FM Port module. + * @Param[in] p_fm_port_performance_cnt A pointer to a structure of + * performance counters parameters. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_port_init(). + */ +uint32_t fm_port_set_performance_counters_params(t_handle h_fm_port, + t_fm_port_performance_cnt *p_fm_port_performance_cnt); + +/* + * @Group FM_PORT_pcd_runtime_control_grp + * FM Port PCD Runtime Control Unit + * + * @Description FM Port PCD Runtime control unit API functions, definitions + * and enums. + * + * @Function fm_port_set_pcd + * + * @Description Calling this routine defines the port's PCD configuration. It + * changes it from its default configuration which is PCD + * disabled (BMI to BMI) and configures it according to the + * passed parameters. + * + * May be used for Rx and OP ports only + * + * @Param[in] h_fm_port A handle to a FM Port module. + * @Param[in] p_fm_port_pcd A Structure of parameters defining the port's + * PCD configuration. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_port_init(). + */ +uint32_t fm_port_set_pcd(t_handle h_fm_port, + ioc_fm_port_pcd_params_t *p_fm_port_pcd); + +/* + * @Function fm_port_delete_pcd + * + * @Description Calling this routine releases the port's PCD configuration. + * The port returns to its default configuration which is PCD + * disabled (BMI to BMI) and all PCD configuration is removed. + * + * May be used for Rx and OP ports which are in PCD mode only + * + * @Param[in] h_fm_port A handle to a FM Port module. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_port_init(). + */ +uint32_t fm_port_delete_pcd(t_handle h_fm_port); + +/* + * @Function fm_port_attach_pcd + * + * @Description This routine may be called after fm_port_detach_pcd was + * called, to return to the originally configured PCD support + * flow. The couple of routines are used to allow PCD + * configuration changes that demand that PCD will not be used + * while changes take place. + * + * May be used for Rx and OP ports which are in PCD mode only + * + * @Param[in] h_fm_port A handle to a FM Port module. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_port_init(). + */ +uint32_t fm_port_attach_pcd(t_handle h_fm_port); + +/* + * @Function fm_port_detach_pcd + * + * @Description Calling this routine detaches the port from its PCD + * functionality. The port returns to its default flow which is + * BMI to BMI. + * + * May be used for Rx and OP ports which are in PCD mode only + * + * @Param[in] h_fm_port A handle to a FM Port module. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_port_attach_pcd(). + */ +uint32_t fm_port_detach_pcd(t_handle h_fm_port); + +/* + * @Function fm_port_pcd_plcr_alloc_profiles + * + * @Description This routine may be called only for ports that use the Policer + * in order to allocate private policer profiles. + * + * @Param[in] h_fm_port A handle to a FM Port module. + * @Param[in] num_of_profiles The number of required policer profiles + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_port_init() and fm_pcd_init(), and + * before fm_port_set_pcd(). + */ +uint32_t fm_port_pcd_plcr_alloc_profiles(t_handle h_fm_port, + uint16_t num_of_profiles); + +/* + * @Function fm_port_pcd_plcr_free_profiles + * + * @Description This routine should be called for freeing private policer + * profiles. + * + * @Param[in] h_fm_port A handle to a FM Port module. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_port_init() and fm_pcd_init(), and + * before fm_port_set_pcd(). + */ +uint32_t fm_port_pcd_plcr_free_profiles(t_handle h_fm_port); + +/* + * @Function fm_port_pcd_kg_modify_initial_scheme + * + * @Description This routine may be called only for ports that use the keygen + * in order to change the initial scheme frame should be routed + * to. The change may be of a scheme id(in case of direct mode), + * from direct to indirect, or from indirect to direct - + * specifying the scheme id. + * + * @Param[in] h_fm_port A handle to a FM Port module. + * @Param[in] p_fm_pcd_kg_scheme A structure of parameters for defining + * whether a scheme is direct / indirect, + * and if direct - scheme id. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_port_init() and fm_port_set_pcd(). + */ +uint32_t fm_port_pcd_kg_modify_initial_scheme(t_handle h_fm_port, + ioc_fm_pcd_kg_scheme_select_t *p_fm_pcd_kg_scheme); + +/* + * @Function fm_port_pcd_plcr_modify_initial_profile + * + * @Description This routine may be called for ports with flows + * e_FM_PORT_PCD_SUPPORT_PLCR_ONLY or + * e_FM_PORT_PCD_SUPPORT_PRS_AND_PLCR only, to change the initial + * Policer profile frame should be routed to. The change may be + * of a profile and / or absolute / direct mode selection. + * + * @Param[in] h_fm_port A handle to a FM Port module. + * @Param[in] h_profile Policer profile handle + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_port_init() and fm_port_set_pcd(). + */ +uint32_t fm_port_pcd_plcr_modify_initial_profile(t_handle h_fm_port, + t_handle h_profile); + +/* + * @Function fm_port_pcd_cc_modify_tree + * + * @Description This routine may be called for ports that use coarse + * classification tree if the user wishes to replace the tree. + * The routine may not be called while port receives packets + * using the PCD functionalities, therefore port must be first + * detached from the PCD, only than the routine may be called, + * and than port be attached to PCD again. + * + * @Param[in] h_fm_port A handle to a FM Port module. + * @Param[in] h_cc_tree A CC tree that was already built. The tree id as + * returned from the BuildTree routine. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_port_init(), fm_port_set_pcd() and + * fm_port_detach_pcd() + */ +uint32_t fm_port_pcd_cc_modify_tree(t_handle h_fm_port, t_handle h_cc_tree); + +/* + * @Function fm_port_pcd_kg_bind_schemes + * + * @Description These routines may be called for adding more schemes for the + * port to be bound to. The selected schemes are not added, just + * this specific port starts using them. + * + * @Param[in] h_fm_port A handle to a FM Port module. + * @Param[in] p_port_scheme A structure defining the list of schemes + * to be added. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_port_init() and fm_port_set_pcd(). + */ +uint32_t fm_port_pcd_kg_bind_schemes(t_handle h_fm_port, + ioc_fm_pcd_port_schemes_params_t *p_port_scheme); + +/* + * @Function fm_port_pcd_kg_unbind_schemes + * + * @Description These routines may be called for adding more schemes for the + * port to be bound to. The selected schemes are not removed or + * invalidated, just this specific port stops using them. + * + * @Param[in] h_fm_port A handle to a FM Port module. + * @Param[in] p_port_scheme A structure defining the list of schemes + * to be added. + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_port_init() and fm_port_set_pcd(). + */ +uint32_t fm_port_pcd_kg_unbind_schemes(t_handle h_fm_port, + ioc_fm_pcd_port_schemes_params_t *p_port_scheme); + +/* + * @Function fm_port_get_ipv_4options_count + * + * @Description TODO + * + * @Param[in] h_fm_port A handle to a FM Port module. + * @Param[out] p_ipv_4options_count will hold the counter value + * + * @Return E_OK on success; Error code otherwise. + * + * @Cautions Allowed only following fm_port_init() + */ +uint32_t fm_port_get_ipv_4options_count(t_handle h_fm_port, + uint32_t *p_ipv_4options_count); + +/** @} */ /* end of FM_PORT_pcd_runtime_control_grp group */ +/** @} */ /* end of FM_PORT_runtime_control_grp group */ +/** @} */ /* end of FM_PORT_grp group */ +/** @} */ /* end of FM_grp group */ +#endif /* __FM_PORT_EXT_H */ diff --git a/drivers/net/dpaa/fmlib/ncsw_ext.h b/drivers/net/dpaa/fmlib/ncsw_ext.h new file mode 100644 index 000000000..ae5f0c884 --- /dev/null +++ b/drivers/net/dpaa/fmlib/ncsw_ext.h @@ -0,0 +1,158 @@ +/* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0) + * Copyright 2008-2012 Freescale Semiconductor Inc. + * Copyright 2017-2020 NXP + */ + +#ifndef __NCSW_EXT_H +#define __NCSW_EXT_H + +#include + +#define PTR_TO_UINT(_ptr) ((uintptr_t)(_ptr)) +#define UINT_TO_PTR(_val) ((void *)(uintptr_t)(_val)) + +/* phys_address_t should be uintptr_t */ +typedef uint64_t phys_address_t; + +/* + * @Description Possible RxStore callback responses. + */ +typedef enum e_rx_store_response { + e_RX_STORE_RESPONSE_PAUSE + /**< Pause invoking callback with received data; in polling + * mode, start again invoking callback only next time user + * invokes the receive routine; in interrupt mode, start again + * invoking callback only next time a receive event triggers an + * interrupt; in all cases, received data that are pending are + * not lost, rather, their processing is temporarily deferred; + * in all cases, received data are processed in the order in + * which they were received. + */ + , e_RX_STORE_RESPONSE_CONTINUE + /**< Continue invoking callback with received data. */ +} e_rx_store_response; + + +/* + * @Description General Handle + */ +typedef void *t_handle; /**< handle, used as object's descriptor */ + +/* @} */ + +/* + * @Function t_get_buf_function + * + * @Description User callback function called by driver to get data buffer. + * + * User provides this function. Driver invokes it. + * + * @Param[in] h_buffer_pool A handle to buffer pool manager + * @Param[out] p_buf_context_handle Returns the user's private context that + * should be associated with the buffer + * + * @Return Pointer to data buffer, NULL if error + */ +typedef uint8_t * (t_get_buf_function)(t_handle h_buffer_pool, + t_handle *p_buf_context_handle); + +/* + * @Function t_put_buf_function + * + * @Description User callback function called by driver to return data buffer. + * User provides this function. Driver invokes it. + * + * @Param[in] h_buffer_pool A handle to buffer pool manager + * @Param[in] p_buffer A pointer to buffer to return + * @Param[in] h_buf_context The user's private context associated + * with the returned buffer + * + * @Return E_OK on success; Error code otherwise + */ +typedef uint32_t (t_put_buf_function)(t_handle h_buffer_pool, + uint8_t *p_buffer, + t_handle h_buf_context); + +/* + * @Function t_phys_to_virt + * + * @Description Translates a physical address to the matching virtual address. + * + * @Param[in] addr The physical address to translate. + * + * @Return Virtual address. + */ +typedef void *t_phys_to_virt(phys_address_t addr); + +/* + * @Function t_virt_to_phys + * + * @Description Translates a virtual address to the matching physical address. + * + * @Param[in] addr The virtual address to translate. + * + * @Return Physical address. + */ +typedef phys_address_t t_virt_to_phys(void *addr); + +/* + * @Description Buffer Pool Information Structure. + */ +typedef struct t_buffer_pool_info { + t_handle h_buffer_pool; + /**< A handle to the buffer pool mgr */ + t_get_buf_function *f_get_buf; + /**< User callback to get a free buffer */ + t_put_buf_function *f_put_buf; + /**< User callback to return a buffer */ + uint16_t buffer_size; + /**< Buffer size (in bytes) */ + t_phys_to_virt *f_phys_to_virt; + /**< User callback to translate pool buffers physical addresses + * to virtual addresses + */ + t_virt_to_phys *f_virt_to_phys; + /**< User callback to translate pool buffers virtual addresses + * to physical addresses + */ +} t_buffer_pool_info; + +/* + * @Description User callback function called by driver with receive data. + * User provides this function. Driver invokes it. + * + * @Param[in] h_app Application's handle, as was provided to the + * driver by the user + * @Param[in] queue_id Receive queue ID + * @Param[in] p_data Pointer to the buffer with received data + * @Param[in] h_buf_context The user's private context associated with the + * given data buffer + * @Param[in] length Length of received data + * @Param[in] status Receive status and errors + * @Param[in] position Position of buffer in frame + * @Param[in] flags Driver-dependent information + * + * @Retval e_RX_STORE_RESPONSE_CONTINUE order the driver to continue Rx + * operation for all ready data. + * @Retval e_RX_STORE_RESPONSE_PAUSE order the driver to stop Rx ops. + */ +typedef e_rx_store_response(t_rx_store_function)(t_handle h_app, + uint32_t queue_id, + uint8_t *p_data, + t_handle h_buf_context, + uint32_t length, + uint16_t status, + uint8_t position, + uint32_t flags); + +typedef struct t_device { + uintptr_t id; /**< the device id */ + int fd; /**< the device file descriptor */ + t_handle h_user_priv; + uint32_t owners; +} t_device; + +t_handle create_device(t_handle h_user_priv, t_handle h_dev_id); +t_handle get_device_id(t_handle h_dev); + +#endif /* __NCSW_EXT_H */ diff --git a/drivers/net/dpaa/fmlib/net_ext.h b/drivers/net/dpaa/fmlib/net_ext.h new file mode 100644 index 000000000..4cd520931 --- /dev/null +++ b/drivers/net/dpaa/fmlib/net_ext.h @@ -0,0 +1,411 @@ +/* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0) + * Copyright 2008-2012 Freescale Semiconductor Inc. + * Copyright 2017-2019 NXP + */ + +#ifndef __NET_EXT_H +#define __NET_EXT_H + +#include "ncsw_ext.h" + +/* + * @Description This file contains common and general netcomm headers + * definitions. + */ + +typedef uint8_t ioc_header_field_ppp_t; + +#define IOC_NET_HF_PPP_PID (1) +#define IOC_NET_HF_PPP_COMPRESSED (IOC_NET_HF_PPP_PID << 1) +#define IOC_NET_HF_PPP_ALL_FIELDS ((IOC_NET_HF_PPP_PID << 2) - 1) + +typedef uint8_t ioc_header_field_pppoe_t; + +#define ioc_net_hf_pppo_e_ver (1) +#define ioc_net_hf_pppo_e_type (ioc_net_hf_pppo_e_ver << 1) +#define ioc_net_hf_pppo_e_code (ioc_net_hf_pppo_e_ver << 2) +#define ioc_net_hf_pppo_e_sid (ioc_net_hf_pppo_e_ver << 3) +#define ioc_net_hf_pppo_e_len (ioc_net_hf_pppo_e_ver << 4) +#define ioc_net_hf_pppo_e_session (ioc_net_hf_pppo_e_ver << 5) +#define ioc_net_hf_pppo_e_pid (ioc_net_hf_pppo_e_ver << 6) +#define ioc_net_hf_pppo_e_all_fields ((ioc_net_hf_pppo_e_ver << 7) - 1) + +#define IOC_NET_HF_PPPMUX_PID (1) +#define IOC_NET_HF_PPPMUX_CKSUM (IOC_NET_HF_PPPMUX_PID << 1) +#define IOC_NET_HF_PPPMUX_COMPRESSED (IOC_NET_HF_PPPMUX_PID << 2) +#define IOC_NET_HF_PPPMUX_ALL_FIELDS ((IOC_NET_HF_PPPMUX_PID << 3) - 1) + +#define IOC_NET_HF_PPPMUX_SUBFRAME_PFF (1) +#define IOC_NET_HF_PPPMUX_SUBFRAME_LXT (IOC_NET_HF_PPPMUX_SUBFRAME_PFF << 1) +#define IOC_NET_HF_PPPMUX_SUBFRAME_LEN (IOC_NET_HF_PPPMUX_SUBFRAME_PFF << 2) +#define IOC_NET_HF_PPPMUX_SUBFRAME_PID (IOC_NET_HF_PPPMUX_SUBFRAME_PFF << 3) +#define IOC_NET_HF_PPPMUX_SUBFRAME_USE_PID \ + (IOC_NET_HF_PPPMUX_SUBFRAME_PFF << 4) +#define IOC_NET_HF_PPPMUX_SUBFRAME_ALL_FIELDS \ + ((IOC_NET_HF_PPPMUX_SUBFRAME_PFF << 5) - 1) + +typedef uint8_t ioc_header_field_eth_t; + +#define IOC_NET_HF_ETH_DA (1) +#define IOC_NET_HF_ETH_SA (IOC_NET_HF_ETH_DA << 1) +#define IOC_NET_HF_ETH_LENGTH (IOC_NET_HF_ETH_DA << 2) +#define IOC_NET_HF_ETH_TYPE (IOC_NET_HF_ETH_DA << 3) +#define IOC_NET_HF_ETH_FINAL_CKSUM (IOC_NET_HF_ETH_DA << 4) +#define IOC_NET_HF_ETH_PADDING (IOC_NET_HF_ETH_DA << 5) +#define IOC_NET_HF_ETH_ALL_FIELDS ((IOC_NET_HF_ETH_DA << 6) - 1) + +#define IOC_NET_HF_ETH_ADDR_SIZE 6 + +typedef uint16_t ioc_header_field_ip_t; + +#define IOC_NET_HF_IP_VER (1) +#define IOC_NET_HF_IP_DSCP (IOC_NET_HF_IP_VER << 2) +#define IOC_NET_HF_IP_ECN (IOC_NET_HF_IP_VER << 3) +#define IOC_NET_HF_IP_PROTO (IOC_NET_HF_IP_VER << 4) + +#define IOC_NET_HF_IP_PROTO_SIZE 1 + +typedef uint16_t ioc_header_field_ipv4_t; + +#define ioc_net_hf_ipv_4_ver (1) +#define ioc_net_hf_ipv_4_hdr_len (ioc_net_hf_ipv_4_ver << 1) +#define ioc_net_hf_ipv_4_tos (ioc_net_hf_ipv_4_ver << 2) +#define ioc_net_hf_ipv_4_total_len (ioc_net_hf_ipv_4_ver << 3) +#define ioc_net_hf_ipv_4_id (ioc_net_hf_ipv_4_ver << 4) +#define ioc_net_hf_ipv_4_flag_d (ioc_net_hf_ipv_4_ver << 5) +#define ioc_net_hf_ipv_4_flag_m (ioc_net_hf_ipv_4_ver << 6) +#define ioc_net_hf_ipv_4_offset (ioc_net_hf_ipv_4_ver << 7) +#define ioc_net_hf_ipv_4_ttl (ioc_net_hf_ipv_4_ver << 8) +#define ioc_net_hf_ipv_4_proto (ioc_net_hf_ipv_4_ver << 9) +#define ioc_net_hf_ipv_4_cksum (ioc_net_hf_ipv_4_ver << 10) +#define ioc_net_hf_ipv_4_src_ip (ioc_net_hf_ipv_4_ver << 11) +#define ioc_net_hf_ipv_4_dst_ip (ioc_net_hf_ipv_4_ver << 12) +#define ioc_net_hf_ipv_4_opts (ioc_net_hf_ipv_4_ver << 13) +#define ioc_net_hf_ipv_4_opts_COUNT (ioc_net_hf_ipv_4_ver << 14) +#define ioc_net_hf_ipv_4_all_fields ((ioc_net_hf_ipv_4_ver << 15) - 1) + +#define ioc_net_hf_ipv_4_addr_size 4 +#define ioc_net_hf_ipv_4_proto_SIZE 1 + +typedef uint8_t ioc_header_field_ipv6_t; + +#define ioc_net_hf_ipv_6_ver (1) +#define ioc_net_hf_ipv_6_tc (ioc_net_hf_ipv_6_ver << 1) +#define ioc_net_hf_ipv_6_src_ip (ioc_net_hf_ipv_6_ver << 2) +#define ioc_net_hf_ipv_6_dst_ip (ioc_net_hf_ipv_6_ver << 3) +#define ioc_net_hf_ipv_6_next_hdr (ioc_net_hf_ipv_6_ver << 4) +#define ioc_net_hf_ipv_6_fl (ioc_net_hf_ipv_6_ver << 5) +#define ioc_net_hf_ipv_6_hop_limit (ioc_net_hf_ipv_6_ver << 6) +#define ioc_net_hf_ipv_6_all_fields ((ioc_net_hf_ipv_6_ver << 7) - 1) + +#define ioc_net_hf_ipv6_addr_size 16 +#define ioc_net_hf_ipv_6_next_hdr_SIZE 1 + +#define IOC_NET_HF_ICMP_TYPE (1) +#define IOC_NET_HF_ICMP_CODE (IOC_NET_HF_ICMP_TYPE << 1) +#define IOC_NET_HF_ICMP_CKSUM (IOC_NET_HF_ICMP_TYPE << 2) +#define IOC_NET_HF_ICMP_ID (IOC_NET_HF_ICMP_TYPE << 3) +#define IOC_NET_HF_ICMP_SQ_NUM (IOC_NET_HF_ICMP_TYPE << 4) +#define IOC_NET_HF_ICMP_ALL_FIELDS ((IOC_NET_HF_ICMP_TYPE << 5) - 1) + +#define IOC_NET_HF_ICMP_CODE_SIZE 1 +#define IOC_NET_HF_ICMP_TYPE_SIZE 1 + +#define IOC_NET_HF_IGMP_VERSION (1) +#define IOC_NET_HF_IGMP_TYPE (IOC_NET_HF_IGMP_VERSION << 1) +#define IOC_NET_HF_IGMP_CKSUM (IOC_NET_HF_IGMP_VERSION << 2) +#define IOC_NET_HF_IGMP_DATA (IOC_NET_HF_IGMP_VERSION << 3) +#define IOC_NET_HF_IGMP_ALL_FIELDS ((IOC_NET_HF_IGMP_VERSION << 4) - 1) + +typedef uint16_t ioc_header_field_tcp_t; + +#define IOC_NET_HF_TCP_PORT_SRC (1) +#define IOC_NET_HF_TCP_PORT_DST (IOC_NET_HF_TCP_PORT_SRC << 1) +#define IOC_NET_HF_TCP_SEQ (IOC_NET_HF_TCP_PORT_SRC << 2) +#define IOC_NET_HF_TCP_ACK (IOC_NET_HF_TCP_PORT_SRC << 3) +#define IOC_NET_HF_TCP_OFFSET (IOC_NET_HF_TCP_PORT_SRC << 4) +#define IOC_NET_HF_TCP_FLAGS (IOC_NET_HF_TCP_PORT_SRC << 5) +#define IOC_NET_HF_TCP_WINDOW (IOC_NET_HF_TCP_PORT_SRC << 6) +#define IOC_NET_HF_TCP_CKSUM (IOC_NET_HF_TCP_PORT_SRC << 7) +#define IOC_NET_HF_TCP_URGPTR (IOC_NET_HF_TCP_PORT_SRC << 8) +#define IOC_NET_HF_TCP_OPTS (IOC_NET_HF_TCP_PORT_SRC << 9) +#define IOC_NET_HF_TCP_OPTS_COUNT (IOC_NET_HF_TCP_PORT_SRC << 10) +#define IOC_NET_HF_TCP_ALL_FIELDS ((IOC_NET_HF_TCP_PORT_SRC << 11) - 1) + +#define IOC_NET_HF_TCP_PORT_SIZE 2 + +typedef uint8_t ioc_header_field_sctp_t; + +#define IOC_NET_HF_SCTP_PORT_SRC (1) +#define IOC_NET_HF_SCTP_PORT_DST (IOC_NET_HF_SCTP_PORT_SRC << 1) +#define IOC_NET_HF_SCTP_VER_TAG (IOC_NET_HF_SCTP_PORT_SRC << 2) +#define IOC_NET_HF_SCTP_CKSUM (IOC_NET_HF_SCTP_PORT_SRC << 3) +#define IOC_NET_HF_SCTP_ALL_FIELDS ((IOC_NET_HF_SCTP_PORT_SRC << 4) - 1) + +#define IOC_NET_HF_SCTP_PORT_SIZE 2 + +typedef uint8_t ioc_header_field_dccp_t; + +#define IOC_NET_HF_DCCP_PORT_SRC (1) +#define IOC_NET_HF_DCCP_PORT_DST (IOC_NET_HF_DCCP_PORT_SRC << 1) +#define IOC_NET_HF_DCCP_ALL_FIELDS ((IOC_NET_HF_DCCP_PORT_SRC << 2) - 1) + +#define IOC_NET_HF_DCCP_PORT_SIZE 2 + +typedef uint8_t ioc_header_field_udp_t; + +#define IOC_NET_HF_UDP_PORT_SRC (1) +#define IOC_NET_HF_UDP_PORT_DST (IOC_NET_HF_UDP_PORT_SRC << 1) +#define IOC_NET_HF_UDP_LEN (IOC_NET_HF_UDP_PORT_SRC << 2) +#define IOC_NET_HF_UDP_CKSUM (IOC_NET_HF_UDP_PORT_SRC << 3) +#define IOC_NET_HF_UDP_ALL_FIELDS ((IOC_NET_HF_UDP_PORT_SRC << 4) - 1) + +#define IOC_NET_HF_UDP_PORT_SIZE 2 + +typedef uint8_t ioc_header_field_udp_lite_t; + +#define IOC_NET_HF_UDP_LITE_PORT_SRC (1) +#define IOC_NET_HF_UDP_LITE_PORT_DST (IOC_NET_HF_UDP_LITE_PORT_SRC << 1) +#define IOC_NET_HF_UDP_LITE_ALL_FIELDS \ + ((IOC_NET_HF_UDP_LITE_PORT_SRC << 2) - 1) + +#define IOC_NET_HF_UDP_LITE_PORT_SIZE 2 + +typedef uint8_t ioc_header_field_udp_encap_esp_t; + +#define IOC_NET_HF_UDP_ENCAP_ESP_PORT_SRC (1) +#define IOC_NET_HF_UDP_ENCAP_ESP_PORT_DST \ + (IOC_NET_HF_UDP_ENCAP_ESP_PORT_SRC << 1) +#define IOC_NET_HF_UDP_ENCAP_ESP_LEN \ + (IOC_NET_HF_UDP_ENCAP_ESP_PORT_SRC << 2) +#define IOC_NET_HF_UDP_ENCAP_ESP_CKSUM \ + (IOC_NET_HF_UDP_ENCAP_ESP_PORT_SRC << 3) +#define IOC_NET_HF_UDP_ENCAP_ESP_SPI \ + (IOC_NET_HF_UDP_ENCAP_ESP_PORT_SRC << 4) +#define IOC_NET_HF_UDP_ENCAP_ESP_SEQUENCE_NUM \ + (IOC_NET_HF_UDP_ENCAP_ESP_PORT_SRC << 5) +#define IOC_NET_HF_UDP_ENCAP_ESP_ALL_FIELDS \ + ((IOC_NET_HF_UDP_ENCAP_ESP_PORT_SRC << 6) - 1) + +#define IOC_NET_HF_UDP_ENCAP_ESP_PORT_SIZE 2 +#define IOC_NET_HF_UDP_ENCAP_ESP_SPI_SIZE 4 + +#define IOC_NET_HF_IPHC_CID (1) +#define IOC_NET_HF_IPHC_CID_TYPE (IOC_NET_HF_IPHC_CID << 1) +#define IOC_NET_HF_IPHC_HCINDEX (IOC_NET_HF_IPHC_CID << 2) +#define IOC_NET_HF_IPHC_GEN (IOC_NET_HF_IPHC_CID << 3) +#define IOC_NET_HF_IPHC_D_BIT (IOC_NET_HF_IPHC_CID << 4) +#define IOC_NET_HF_IPHC_ALL_FIELDS ((IOC_NET_HF_IPHC_CID << 5) - 1) + +#define IOC_NET_HF_SCTP_CHUNK_DATA_TYPE (1) +#define IOC_NET_HF_SCTP_CHUNK_DATA_FLAGS \ + (IOC_NET_HF_SCTP_CHUNK_DATA_TYPE << 1) +#define IOC_NET_HF_SCTP_CHUNK_DATA_LENGTH \ + (IOC_NET_HF_SCTP_CHUNK_DATA_TYPE << 2) +#define IOC_NET_HF_SCTP_CHUNK_DATA_TSN \ + (IOC_NET_HF_SCTP_CHUNK_DATA_TYPE << 3) +#define IOC_NET_HF_SCTP_CHUNK_DATA_STREAM_ID \ + (IOC_NET_HF_SCTP_CHUNK_DATA_TYPE << 4) +#define IOC_NET_HF_SCTP_CHUNK_DATA_STREAM_SQN \ + (IOC_NET_HF_SCTP_CHUNK_DATA_TYPE << 5) +#define IOC_NET_HF_SCTP_CHUNK_DATA_PAYLOAD_PID \ + (IOC_NET_HF_SCTP_CHUNK_DATA_TYPE << 6) +#define IOC_NET_HF_SCTP_CHUNK_DATA_UNORDERED \ + (IOC_NET_HF_SCTP_CHUNK_DATA_TYPE << 7) +#define IOC_NET_HF_SCTP_CHUNK_DATA_BEGINNING \ + (IOC_NET_HF_SCTP_CHUNK_DATA_TYPE << 8) +#define IOC_NET_HF_SCTP_CHUNK_DATA_END \ + (IOC_NET_HF_SCTP_CHUNK_DATA_TYPE << 9) +#define IOC_NET_HF_SCTP_CHUNK_DATA_ALL_FIELDS \ + ((IOC_NET_HF_SCTP_CHUNK_DATA_TYPE << 10) - 1) + +#define ioc_net_hf_l2tpv_2_type_bit (1) +#define ioc_net_hf_l2tpv_2_length_bit (ioc_net_hf_l2tpv_2_type_bit << 1) +#define ioc_net_hf_l2tpv_2_sequence_bit (ioc_net_hf_l2tpv_2_type_bit << 2) +#define ioc_net_hf_l2tpv_2_offset_bit (ioc_net_hf_l2tpv_2_type_bit << 3) +#define ioc_net_hf_l2tpv_2_priority_bit (ioc_net_hf_l2tpv_2_type_bit << 4) +#define ioc_net_hf_l2tpv_2_version (ioc_net_hf_l2tpv_2_type_bit << 5) +#define ioc_net_hf_l2tpv_2_len (ioc_net_hf_l2tpv_2_type_bit << 6) +#define ioc_net_hf_l2tpv_2_tunnel_id (ioc_net_hf_l2tpv_2_type_bit << 7) +#define ioc_net_hf_l2tpv_2_session_id (ioc_net_hf_l2tpv_2_type_bit << 8) +#define ioc_net_hf_l2tpv_2_ns (ioc_net_hf_l2tpv_2_type_bit << 9) +#define ioc_net_hf_l2tpv_2_nr (ioc_net_hf_l2tpv_2_type_bit << 10) +#define ioc_net_hf_l2tpv_2_offset_size (ioc_net_hf_l2tpv_2_type_bit << 11) +#define ioc_net_hf_l2tpv_2_first_byte (ioc_net_hf_l2tpv_2_type_bit << 12) +#define ioc_net_hf_l2tpv_2_all_fields \ + ((ioc_net_hf_l2tpv_2_type_bit << 13) - 1) + +#define ioc_net_hf_l2tpv_3_ctrl_type_bit (1) +#define ioc_net_hf_l2tpv_3_ctrl_length_bit \ + (ioc_net_hf_l2tpv_3_ctrl_type_bit << 1) +#define ioc_net_hf_l2tpv_3_ctrl_sequence_bit \ + (ioc_net_hf_l2tpv_3_ctrl_type_bit << 2) +#define ioc_net_hf_l2tpv_3_ctrl_version (ioc_net_hf_l2tpv_3_ctrl_type_bit << 3) +#define ioc_net_hf_l2tpv_3_ctrl_length (ioc_net_hf_l2tpv_3_ctrl_type_bit << 4) +#define ioc_net_hf_l2tpv_3_ctrl_control (ioc_net_hf_l2tpv_3_ctrl_type_bit << 5) +#define ioc_net_hf_l2tpv_3_ctrl_sent (ioc_net_hf_l2tpv_3_ctrl_type_bit << 6) +#define ioc_net_hf_l2tpv_3_ctrl_recv (ioc_net_hf_l2tpv_3_ctrl_type_bit << 7) +#define ioc_net_hf_l2tpv_3_ctrl_first_byte \ + (ioc_net_hf_l2tpv_3_ctrl_type_bit << 8) +#define ioc_net_hf_l2tpv_3_ctrl_all_fields \ + ((ioc_net_hf_l2tpv_3_ctrl_type_bit << 9) - 1) + +#define ioc_net_hf_l2tpv_3_sess_type_bit (1) +#define ioc_net_hf_l2tpv_3_sess_version (ioc_net_hf_l2tpv_3_sess_type_bit << 1) +#define ioc_net_hf_l2tpv_3_sess_id (ioc_net_hf_l2tpv_3_sess_type_bit << 2) +#define ioc_net_hf_l2tpv_3_sess_cookie (ioc_net_hf_l2tpv_3_sess_type_bit << 3) +#define ioc_net_hf_l2tpv_3_sess_all_fields \ + ((ioc_net_hf_l2tpv_3_sess_type_bit << 4) - 1) + +typedef uint8_t ioc_header_field_vlan_t; + +#define IOC_NET_HF_VLAN_VPRI (1) +#define IOC_NET_HF_VLAN_CFI (IOC_NET_HF_VLAN_VPRI << 1) +#define IOC_NET_HF_VLAN_VID (IOC_NET_HF_VLAN_VPRI << 2) +#define IOC_NET_HF_VLAN_LENGTH (IOC_NET_HF_VLAN_VPRI << 3) +#define IOC_NET_HF_VLAN_TYPE (IOC_NET_HF_VLAN_VPRI << 4) +#define IOC_NET_HF_VLAN_ALL_FIELDS ((IOC_NET_HF_VLAN_VPRI << 5) - 1) + +#define IOC_NET_HF_VLAN_TCI (IOC_NET_HF_VLAN_VPRI | \ + IOC_NET_HF_VLAN_CFI | \ + IOC_NET_HF_VLAN_VID) + +typedef uint8_t ioc_header_field_llc_t; + +#define IOC_NET_HF_LLC_DSAP (1) +#define IOC_NET_HF_LLC_SSAP (IOC_NET_HF_LLC_DSAP << 1) +#define IOC_NET_HF_LLC_CTRL (IOC_NET_HF_LLC_DSAP << 2) +#define IOC_NET_HF_LLC_ALL_FIELDS ((IOC_NET_HF_LLC_DSAP << 3) - 1) + +#define IOC_NET_HF_NLPID_NLPID (1) +#define IOC_NET_HF_NLPID_ALL_FIELDS ((IOC_NET_HF_NLPID_NLPID << 1) - 1) + +typedef uint8_t ioc_header_field_snap_t; + +#define IOC_NET_HF_SNAP_OUI (1) +#define IOC_NET_HF_SNAP_PID (IOC_NET_HF_SNAP_OUI << 1) +#define IOC_NET_HF_SNAP_ALL_FIELDS ((IOC_NET_HF_SNAP_OUI << 2) - 1) + +typedef uint8_t ioc_header_field_llc_snap_t; + +#define IOC_NET_HF_LLC_SNAP_TYPE (1) +#define IOC_NET_HF_LLC_SNAP_ALL_FIELDS ((IOC_NET_HF_LLC_SNAP_TYPE << 1) - 1) + +#define IOC_NET_HF_ARP_HTYPE (1) +#define IOC_NET_HF_ARP_PTYPE (IOC_NET_HF_ARP_HTYPE << 1) +#define IOC_NET_HF_ARP_HLEN (IOC_NET_HF_ARP_HTYPE << 2) +#define IOC_NET_HF_ARP_PLEN (IOC_NET_HF_ARP_HTYPE << 3) +#define IOC_NET_HF_ARP_OPER (IOC_NET_HF_ARP_HTYPE << 4) +#define IOC_NET_HF_ARP_SHA (IOC_NET_HF_ARP_HTYPE << 5) +#define IOC_NET_HF_ARP_SPA (IOC_NET_HF_ARP_HTYPE << 6) +#define IOC_NET_HF_ARP_TH (IOC_NET_HF_ARP_HTYPE << 7) +#define IOC_NET_HF_ARP_TPA (IOC_NET_HF_ARP_HTYPE << 8) +#define IOC_NET_HF_ARP_ALL_FIELDS ((IOC_NET_HF_ARP_HTYPE << 9) - 1) + +#define IOC_NET_HF_RFC2684_LLC (1) +#define IOC_NET_HF_RFC2684_NLPID (IOC_NET_HF_RFC2684_LLC << 1) +#define IOC_NET_HF_RFC2684_OUI (IOC_NET_HF_RFC2684_LLC << 2) +#define IOC_NET_HF_RFC2684_PID (IOC_NET_HF_RFC2684_LLC << 3) +#define IOC_NET_HF_RFC2684_VPN_OUI (IOC_NET_HF_RFC2684_LLC << 4) +#define IOC_NET_HF_RFC2684_VPN_IDX (IOC_NET_HF_RFC2684_LLC << 5) +#define IOC_NET_HF_RFC2684_ALL_FIELDS ((IOC_NET_HF_RFC2684_LLC << 6) - 1) + +#define IOC_NET_HF_USER_DEFINED_SRCPORT (1) +#define IOC_NET_HF_USER_DEFINED_PCDID (IOC_NET_HF_USER_DEFINED_SRCPORT << 1) +#define IOC_NET_HF_USER_DEFINED_ALL_FIELDS \ + ((IOC_NET_HF_USER_DEFINED_SRCPORT << 2) - 1) + +#define IOC_NET_HF_PAYLOAD_BUFFER (1) +#define IOC_NET_HF_PAYLOAD_SIZE (IOC_NET_HF_PAYLOAD_BUFFER << 1) +#define IOC_NET_HF_MAX_FRM_SIZE (IOC_NET_HF_PAYLOAD_BUFFER << 2) +#define IOC_NET_HF_MIN_FRM_SIZE (IOC_NET_HF_PAYLOAD_BUFFER << 3) +#define IOC_NET_HF_PAYLOAD_TYPE (IOC_NET_HF_PAYLOAD_BUFFER << 4) +#define IOC_NET_HF_FRAME_SIZE (IOC_NET_HF_PAYLOAD_BUFFER << 5) +#define IOC_NET_HF_PAYLOAD_ALL_FIELDS ((IOC_NET_HF_PAYLOAD_BUFFER << 6) - 1) + +typedef uint8_t ioc_header_field_gre_t; + +#define IOC_NET_HF_GRE_TYPE (1) +#define IOC_NET_HF_GRE_ALL_FIELDS ((IOC_NET_HF_GRE_TYPE << 1) - 1) + +typedef uint8_t ioc_header_field_minencap_t; + +#define IOC_NET_HF_MINENCAP_SRC_IP (1) +#define IOC_NET_HF_MINENCAP_DST_IP (IOC_NET_HF_MINENCAP_SRC_IP << 1) +#define IOC_NET_HF_MINENCAP_TYPE (IOC_NET_HF_MINENCAP_SRC_IP << 2) +#define IOC_NET_HF_MINENCAP_ALL_FIELDS ((IOC_NET_HF_MINENCAP_SRC_IP << 3) - 1) + +typedef uint8_t ioc_header_field_ipsec_ah_t; + +#define IOC_NET_HF_IPSEC_AH_SPI (1) +#define IOC_NET_HF_IPSEC_AH_NH (IOC_NET_HF_IPSEC_AH_SPI << 1) +#define IOC_NET_HF_IPSEC_AH_ALL_FIELDS ((IOC_NET_HF_IPSEC_AH_SPI << 2) - 1) + +typedef uint8_t ioc_header_field_ipsec_esp_t; + +#define IOC_NET_HF_IPSEC_ESP_SPI (1) +#define IOC_NET_HF_IPSEC_ESP_SEQUENCE_NUM (IOC_NET_HF_IPSEC_ESP_SPI << 1) +#define IOC_NET_HF_IPSEC_ESP_ALL_FIELDS ((IOC_NET_HF_IPSEC_ESP_SPI << 2) - 1) + +#define IOC_NET_HF_IPSEC_ESP_SPI_SIZE 4 + + +typedef uint8_t ioc_header_field_mpls_t; + +#define IOC_NET_HF_MPLS_LABEL_STACK (1) +#define IOC_NET_HF_MPLS_LABEL_STACK_ALL_FIELDS \ + ((IOC_NET_HF_MPLS_LABEL_STACK << 1) - 1) + +typedef uint8_t ioc_header_field_macsec_t; + +#define IOC_NET_HF_MACSEC_SECTAG (1) +#define IOC_NET_HF_MACSEC_ALL_FIELDS ((IOC_NET_HF_MACSEC_SECTAG << 1) - 1) + +typedef enum { + HEADER_TYPE_NONE = 0, + HEADER_TYPE_PAYLOAD, + HEADER_TYPE_ETH, + HEADER_TYPE_VLAN, + HEADER_TYPE_IPV4, + HEADER_TYPE_IPV6, + HEADER_TYPE_IP, + HEADER_TYPE_TCP, + HEADER_TYPE_UDP, + HEADER_TYPE_UDP_LITE, + HEADER_TYPE_IPHC, + HEADER_TYPE_SCTP, + HEADER_TYPE_SCTP_CHUNK_DATA, + HEADER_TYPE_PPPOE, + HEADER_TYPE_PPP, + HEADER_TYPE_PPPMUX, + HEADER_TYPE_PPPMUX_SUBFRAME, + HEADER_TYPE_L2TPV2, + HEADER_TYPE_L2TPV3_CTRL, + HEADER_TYPE_L2TPV3_SESS, + HEADER_TYPE_LLC, + HEADER_TYPE_LLC_SNAP, + HEADER_TYPE_NLPID, + HEADER_TYPE_SNAP, + HEADER_TYPE_MPLS, + HEADER_TYPE_IPSEC_AH, + HEADER_TYPE_IPSEC_ESP, + HEADER_TYPE_UDP_ENCAP_ESP, /* RFC 3948 */ + HEADER_TYPE_MACSEC, + HEADER_TYPE_GRE, + HEADER_TYPE_MINENCAP, + HEADER_TYPE_DCCP, + HEADER_TYPE_ICMP, + HEADER_TYPE_IGMP, + HEADER_TYPE_ARP, + HEADER_TYPE_CAPWAP, + HEADER_TYPE_CAPWAP_DTLS, + HEADER_TYPE_RFC2684, + HEADER_TYPE_USER_DEFINED_L2, + HEADER_TYPE_USER_DEFINED_L3, + HEADER_TYPE_USER_DEFINED_L4, + HEADER_TYPE_USER_DEFINED_SHIM1, + HEADER_TYPE_USER_DEFINED_SHIM2, + MAX_HEADER_TYPE_COUNT +} ioc_net_header_type; + +#endif /* __NET_EXT_H */ diff --git a/drivers/net/dpaa/meson.build b/drivers/net/dpaa/meson.build index 271416f08..b2cd555fd 100644 --- a/drivers/net/dpaa/meson.build +++ b/drivers/net/dpaa/meson.build @@ -1,5 +1,5 @@ # SPDX-License-Identifier: BSD-3-Clause -# Copyright 2018 NXP +# Copyright 2018-2020 NXP if not is_linux build = false @@ -8,6 +8,7 @@ endif deps += ['mempool_dpaa'] sources = files('dpaa_ethdev.c', + 'fmlib/fm_lib.c', 'dpaa_rxtx.c') if cc.has_argument('-Wno-pointer-arith') From patchwork Tue Sep 1 12:36:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hemant Agrawal X-Patchwork-Id: 248850 Delivered-To: patch@linaro.org Received: by 2002:a92:5b9c:0:0:0:0:0 with SMTP id c28csp4195031ilg; Tue, 1 Sep 2020 05:43:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxbyCDWFgQZcjJCMOzy45irtpjS9t8gu462H/YdSrUdJ9t//8xpf2gvCEJeR+EKASPxTugH X-Received: by 2002:a17:906:8688:: with SMTP id g8mr1250629ejx.25.1598964182724; Tue, 01 Sep 2020 05:43:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598964182; cv=none; d=google.com; s=arc-20160816; b=dCF6FmsndlE1dnbfSw2hVxPH9wJTfWtex/y1uOQL2+1Bqp092VSz/LB92BFSxr7wb3 B9Y9CxtQn+hFHC9+PN9yyvHzCMhk6gGN31gwEtQ5eNunL1pNppcFx9RgiDkihFZBqbet c9X+ok/qStIPBL9PcYeIDv6kr35gC3HYV3zNnbkI+h/XH5bTsrjDjuE2LFi59+IZpgLf Ub/6CXwDJy5py/wnZ8gyaFoL17duFVILiz6xOmzN/jwXHVSQWZkwCXAHBq1w8qi10kj7 hCjWuYVG7dlfMjyCj9iz7ho2rUZ7xo/n1NL4hQ2yJxLwKjeAYGgrrm1kL6eCU8SlA2AF rR1w== 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=y5tX2Rv8X2jGSuxIoysC5cvyNIqBEAn8oNxEc5oFYmc=; b=QeBtApe06HDpSRTsC+ucfnuRw0mPf3ukPZKYEs476TlvQ2gnOuRKTiklvJxnxQG8lm T8d0vlvvOvpNp8iP555jEvgZe2Io+nPxlByxwFGhn8BubCOHY/+Z2ftVEBHdmFHj+fHN bH9Hpvzwqdpb1Su99GRvSfeiX/zgVQidKqBM4kwAscm/3ZRZbXDUI0/bv8I+yWIzFdoD 57rFPPUfew1/Rczs50eQSrNnFuvmiIs+IlcrDeZkob8K3LPtS2B9iKZQ0vzfS5iWeVxN 9VLuFayRa2PNEuOAO44Va7YLCQdr5O1xUCC3dVtnVGuymS9rhfivJxE4a5TcCsZTm/5v 1RSg== 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 a9si608784ejx.166.2020.09.01.05.43.02; Tue, 01 Sep 2020 05:43:02 -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 07D891C0BF; Tue, 1 Sep 2020 14:43:01 +0200 (CEST) Received: from inva020.nxp.com (inva020.nxp.com [92.121.34.13]) by dpdk.org (Postfix) with ESMTP id 449B21C0B7 for ; Tue, 1 Sep 2020 14:42:59 +0200 (CEST) Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 0D4481A00AB; Tue, 1 Sep 2020 14:42:59 +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 906B01A0097; Tue, 1 Sep 2020 14:42:57 +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 83809402A2; Tue, 1 Sep 2020 14:42:55 +0200 (CEST) From: Hemant Agrawal To: dev@dpdk.org Cc: ferruh.yigit@intel.com Date: Tue, 1 Sep 2020 18:06:44 +0530 Message-Id: <20200901123650.29908-2-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200901123650.29908-1-hemant.agrawal@nxp.com> References: <20200813180121.19480-1-hemant.agrawal@nxp.com> <20200901123650.29908-1-hemant.agrawal@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Subject: [dpdk-dev] [PATCH v6 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 --- doc/guides/nics/dpaa.rst | 8 ++ drivers/net/dpaa/fmlib/fm_vsp.c | 148 ++++++++++++++++++++++++++++ drivers/net/dpaa/fmlib/fm_vsp_ext.h | 131 ++++++++++++++++++++++++ drivers/net/dpaa/meson.build | 1 + 4 files changed, 288 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/doc/guides/nics/dpaa.rst b/doc/guides/nics/dpaa.rst index 7e6010471..c4bfcd09a 100644 --- a/doc/guides/nics/dpaa.rst +++ b/doc/guides/nics/dpaa.rst @@ -335,6 +335,14 @@ FMLIB as well. This helps in overcoming the main limitaiton of FMC - i.e. lack of dynamic configuration. +VSP (Virtual Storage Profile) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + The storage profiled are means to provide virtualized interface. A ranges of + storage profiles cab be associated to Ethernet ports. + They are selected during classification. Specify how the frame should be + written to memory and which buffer pool to select for packet storange in + queues. Start and End margin of buffer can also be configured. + Limitations ----------- diff --git a/drivers/net/dpaa/fmlib/fm_vsp.c b/drivers/net/dpaa/fmlib/fm_vsp.c new file mode 100644 index 000000000..78efd93f2 --- /dev/null +++ b/drivers/net/dpaa/fmlib/fm_vsp.c @@ -0,0 +1,148 @@ +/* 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_vsp_alloc(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 000000000..b51c46162 --- /dev/null +++ b/drivers/net/dpaa/fmlib/fm_vsp_ext.h @@ -0,0 +1,131 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * 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_vsp_alloc(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); + +#define FM_PORT_IOC_VSP_ALLOC \ + _IOW(FM_IOC_TYPE_BASE, FM_PORT_IOC_NUM(38), \ + ioc_fm_port_vsp_alloc_params_t) + +#define FM_IOC_VSP_CONFIG \ + _IOWR(FM_IOC_TYPE_BASE, FM_IOC_NUM(8), ioc_fm_vsp_params_t) + +#define FM_IOC_VSP_INIT \ + _IOW(FM_IOC_TYPE_BASE, FM_IOC_NUM(9), ioc_fm_obj_t) + +#define FM_IOC_VSP_FREE \ + _IOW(FM_IOC_TYPE_BASE, FM_IOC_NUM(10), ioc_fm_obj_t) + +#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 b2cd555fd..aca1dccc3 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') From patchwork Tue Sep 1 12:36:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hemant Agrawal X-Patchwork-Id: 248851 Delivered-To: patch@linaro.org Received: by 2002:a92:5b9c:0:0:0:0:0 with SMTP id c28csp4195134ilg; Tue, 1 Sep 2020 05:43:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwQm8JHaERxUu0IugEC4LSXf0oBlEWRFUzzZ7Zha3kQJwyPrN+qsrbQcjstH+g1mUvfb3eg X-Received: by 2002:a17:906:b881:: with SMTP id hb1mr1262522ejb.207.1598964190012; Tue, 01 Sep 2020 05:43:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598964190; cv=none; d=google.com; s=arc-20160816; b=et+aKklaEh4yxsubtrqvDQ1OBjzMQVr7dJu6lR+2N1khGJX2H0JKHyHeyIt0z0IO9c 0sUHvV6Akc/R0KWD4tWlFtQLS65n4xxNrkAtL+W1vbpi0nE/t2hIsksP8Bkruzk2nr3+ DzRPRY3pkaMarEyTO+d5TQ9R+vhvx1zIBdB8AdQC35YRNggVqpOi7nTDxxuIofNnQN2G bj8VMryj+2x8YUr1XzpJHVRB2mNO/8P+l/SDx+82vphXZgKm97/5obMbjaVuj+05R9gK pu2Wal2uSYVle/W3z810pWqbYVn86dvhQ7Dw9EqQ2wYbXxFOXNH4BVokFQM+O2PuE6zy oSiw== 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=Ir3A8c5/RGtK/Kxh1Im4o30qm7/7FRWUiP+6LpVFX9M=; b=hvF38kofLNgmoBoOIlgmq5lW7FkTmPiBYRPSWOCineR/8SLwXQlZbuGIfPWCI4Bmcy GVQDUxVP4ZZKkMeiACo8kXChLC1tFpw7eUofvOfGL+JSymViPydKp7ThmW0Gzbn7VjmH aEpByyrc0kuTnGN1Ni8KfCBtXlvWGWBOa2zJAst49qX8dO8vFYTwLKGGVjYVul9B35n8 5dbhaDn/yYqExbJEz17czIr7tPr3bpT00/RJEsQ9zQP+y/hwzZPz0ix3OM8/lVNv6M5g TrqT0V/MM1Adu6BGESNDgWcHmWrlSicwGk2ZwcXwYdCn9NMQo2wi7zACZeihIdnxgZ8z 4mtA== 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 p4si544362edd.192.2020.09.01.05.43.09; Tue, 01 Sep 2020 05:43:10 -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 68C341C19C; Tue, 1 Sep 2020 14:43:02 +0200 (CEST) Received: from inva020.nxp.com (inva020.nxp.com [92.121.34.13]) by dpdk.org (Postfix) with ESMTP id 0247F1C0B7 for ; Tue, 1 Sep 2020 14:43:00 +0200 (CEST) Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id CCABE1A068E; Tue, 1 Sep 2020 14:42:59 +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 28C941A00A3; Tue, 1 Sep 2020 14:42:58 +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 19F82402A8; Tue, 1 Sep 2020 14:42:56 +0200 (CEST) From: Hemant Agrawal To: dev@dpdk.org Cc: ferruh.yigit@intel.com Date: Tue, 1 Sep 2020 18:06:45 +0530 Message-Id: <20200901123650.29908-3-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200901123650.29908-1-hemant.agrawal@nxp.com> References: <20200813180121.19480-1-hemant.agrawal@nxp.com> <20200901123650.29908-1-hemant.agrawal@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Subject: [dpdk-dev] [PATCH v6 3/8] net/dpaa: add support for fmcless mode 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: Sachin Saxena This patch uses fmlib to configure the FMAN HW for flow and distribution configuration, thus avoiding the need for static FMC tool execution optionally. Signed-off-by: Sachin Saxena Signed-off-by: Hemant Agrawal --- drivers/bus/dpaa/include/fsl_qman.h | 1 + drivers/bus/dpaa/rte_bus_dpaa_version.map | 1 + drivers/net/dpaa/dpaa_ethdev.c | 111 ++- drivers/net/dpaa/dpaa_ethdev.h | 4 + drivers/net/dpaa/dpaa_flow.c | 901 ++++++++++++++++++++++ drivers/net/dpaa/dpaa_flow.h | 14 + drivers/net/dpaa/meson.build | 1 + 7 files changed, 1011 insertions(+), 22 deletions(-) create mode 100644 drivers/net/dpaa/dpaa_flow.c create mode 100644 drivers/net/dpaa/dpaa_flow.h -- 2.17.1 diff --git a/drivers/bus/dpaa/include/fsl_qman.h b/drivers/bus/dpaa/include/fsl_qman.h index 8ba37411a..dd7ca783a 100644 --- a/drivers/bus/dpaa/include/fsl_qman.h +++ b/drivers/bus/dpaa/include/fsl_qman.h @@ -1896,6 +1896,7 @@ int qman_enqueue_orp(struct qman_fq *fq, const struct qm_fd *fd, u32 flags, * FQs than requested (though alignment will be as requested). If @partial is * zero, the return value will either be 'count' or negative. */ +__rte_internal int qman_alloc_fqid_range(u32 *result, u32 count, u32 align, int partial); static inline int qman_alloc_fqid(u32 *result) { diff --git a/drivers/bus/dpaa/rte_bus_dpaa_version.map b/drivers/bus/dpaa/rte_bus_dpaa_version.map index 77840a564..f47922c6a 100644 --- a/drivers/bus/dpaa/rte_bus_dpaa_version.map +++ b/drivers/bus/dpaa/rte_bus_dpaa_version.map @@ -49,6 +49,7 @@ INTERNAL { netcfg_release; per_lcore_dpaa_io; qman_alloc_cgrid_range; + qman_alloc_fqid_range; qman_alloc_pool_range; qman_clear_irq; qman_create_cgr; diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c index c15e2b546..c5b9ac1a5 100644 --- a/drivers/net/dpaa/dpaa_ethdev.c +++ b/drivers/net/dpaa/dpaa_ethdev.c @@ -39,6 +39,7 @@ #include #include +#include #include #include @@ -76,6 +77,7 @@ static uint64_t dev_tx_offloads_nodis = /* Keep track of whether QMAN and BMAN have been globally initialized */ static int is_global_init; +static int fmc_q = 1; /* Indicates the use of static fmc for distribution */ static int default_q; /* use default queue - FMC is not executed*/ /* At present we only allow up to 4 push mode queues as default - as each of * this queue need dedicated portal and we are short of portals. @@ -1418,16 +1420,15 @@ static int dpaa_rx_queue_init(struct qman_fq *fq, struct qman_cgr *cgr_rx, } }; - if (fqid) { + if (fmc_q || default_q) { ret = qman_reserve_fqid(fqid); if (ret) { - DPAA_PMD_ERR("reserve rx fqid 0x%x failed with ret: %d", + DPAA_PMD_ERR("reserve rx fqid 0x%x failed, ret: %d", fqid, ret); return -EINVAL; } - } else { - flags |= QMAN_FQ_FLAG_DYNAMIC_FQID; } + DPAA_PMD_DEBUG("creating rx fq %p, fqid 0x%x", fq, fqid); ret = qman_create_fq(fqid, flags, fq); if (ret) { @@ -1602,7 +1603,7 @@ dpaa_dev_init(struct rte_eth_dev *eth_dev) struct fman_if_bpool *bp, *tmp_bp; uint32_t cgrid[DPAA_MAX_NUM_PCD_QUEUES]; uint32_t cgrid_tx[MAX_DPAA_CORES]; - char eth_buf[RTE_ETHER_ADDR_FMT_SIZE]; + uint32_t dev_rx_fqids[DPAA_MAX_NUM_PCD_QUEUES]; PMD_INIT_FUNC_TRACE(); @@ -1619,30 +1620,36 @@ dpaa_dev_init(struct rte_eth_dev *eth_dev) dpaa_intf->ifid = dev_id; dpaa_intf->cfg = cfg; + memset((char *)dev_rx_fqids, 0, + sizeof(uint32_t) * DPAA_MAX_NUM_PCD_QUEUES); + /* Initialize Rx FQ's */ if (default_q) { num_rx_fqs = DPAA_DEFAULT_NUM_PCD_QUEUES; + } else if (fmc_q) { + num_rx_fqs = 1; } else { - if (getenv("DPAA_NUM_RX_QUEUES")) - num_rx_fqs = atoi(getenv("DPAA_NUM_RX_QUEUES")); - else - num_rx_fqs = DPAA_DEFAULT_NUM_PCD_QUEUES; + /* FMCLESS mode, load balance to multiple cores.*/ + num_rx_fqs = rte_lcore_count(); } - /* Each device can not have more than DPAA_MAX_NUM_PCD_QUEUES RX * queues. */ - if (num_rx_fqs <= 0 || num_rx_fqs > DPAA_MAX_NUM_PCD_QUEUES) { + if (num_rx_fqs < 0 || num_rx_fqs > DPAA_MAX_NUM_PCD_QUEUES) { DPAA_PMD_ERR("Invalid number of RX queues\n"); return -EINVAL; } - dpaa_intf->rx_queues = rte_zmalloc(NULL, - sizeof(struct qman_fq) * num_rx_fqs, MAX_CACHELINE); - if (!dpaa_intf->rx_queues) { - DPAA_PMD_ERR("Failed to alloc mem for RX queues\n"); - return -ENOMEM; + if (num_rx_fqs > 0) { + dpaa_intf->rx_queues = rte_zmalloc(NULL, + sizeof(struct qman_fq) * num_rx_fqs, MAX_CACHELINE); + if (!dpaa_intf->rx_queues) { + DPAA_PMD_ERR("Failed to alloc mem for RX queues\n"); + return -ENOMEM; + } + } else { + dpaa_intf->rx_queues = NULL; } memset(cgrid, 0, sizeof(cgrid)); @@ -1661,7 +1668,7 @@ dpaa_dev_init(struct rte_eth_dev *eth_dev) } /* If congestion control is enabled globally*/ - if (td_threshold) { + if (num_rx_fqs > 0 && td_threshold) { dpaa_intf->cgr_rx = rte_zmalloc(NULL, sizeof(struct qman_cgr) * num_rx_fqs, MAX_CACHELINE); if (!dpaa_intf->cgr_rx) { @@ -1680,12 +1687,20 @@ dpaa_dev_init(struct rte_eth_dev *eth_dev) dpaa_intf->cgr_rx = NULL; } + if (!fmc_q && !default_q) { + ret = qman_alloc_fqid_range(dev_rx_fqids, num_rx_fqs, + num_rx_fqs, 0); + if (ret < 0) { + DPAA_PMD_ERR("Failed to alloc rx fqid's\n"); + goto free_rx; + } + } + for (loop = 0; loop < num_rx_fqs; loop++) { if (default_q) fqid = cfg->rx_def; else - fqid = DPAA_PCD_FQID_START + fman_intf->mac_idx * - DPAA_PCD_FQID_MULTIPLIER + loop; + fqid = dev_rx_fqids[loop]; if (dpaa_intf->cgr_rx) dpaa_intf->cgr_rx[loop].cgrid = cgrid[loop]; @@ -1782,9 +1797,16 @@ dpaa_dev_init(struct rte_eth_dev *eth_dev) /* copy the primary mac address */ rte_ether_addr_copy(&fman_intf->mac_addr, ð_dev->data->mac_addrs[0]); - rte_ether_format_addr(eth_buf, sizeof(eth_buf), &fman_intf->mac_addr); - DPAA_PMD_INFO("net: dpaa: %s: %s", dpaa_device->name, eth_buf); + RTE_LOG(INFO, PMD, "net: dpaa: %s: %02x:%02x:%02x:%02x:%02x:%02x\n", + dpaa_device->name, + fman_intf->mac_addr.addr_bytes[0], + fman_intf->mac_addr.addr_bytes[1], + fman_intf->mac_addr.addr_bytes[2], + fman_intf->mac_addr.addr_bytes[3], + fman_intf->mac_addr.addr_bytes[4], + fman_intf->mac_addr.addr_bytes[5]); + /* Disable RX mode */ fman_if_discard_rx_errors(fman_intf); @@ -1831,6 +1853,12 @@ dpaa_dev_uninit(struct rte_eth_dev *dev) return -1; } + /* DPAA FM deconfig */ + if (!(default_q || fmc_q)) { + if (dpaa_fm_deconfig(dpaa_intf, dev->process_private)) + DPAA_PMD_WARN("DPAA FM deconfig failed\n"); + } + dpaa_eth_dev_close(dev); /* release configuration memory */ @@ -1874,7 +1902,7 @@ dpaa_dev_uninit(struct rte_eth_dev *dev) } static int -rte_dpaa_probe(struct rte_dpaa_driver *dpaa_drv __rte_unused, +rte_dpaa_probe(struct rte_dpaa_driver *dpaa_drv, struct rte_dpaa_device *dpaa_dev) { int diag; @@ -1920,6 +1948,13 @@ rte_dpaa_probe(struct rte_dpaa_driver *dpaa_drv __rte_unused, default_q = 1; } + if (!(default_q || fmc_q)) { + if (dpaa_fm_init()) { + DPAA_PMD_ERR("FM init failed\n"); + return -1; + } + } + /* disabling the default push mode for LS1043 */ if (dpaa_svr_family == SVR_LS1043A_FAMILY) dpaa_push_mode_max_queue = 0; @@ -1993,6 +2028,38 @@ rte_dpaa_remove(struct rte_dpaa_device *dpaa_dev) return 0; } +static void __attribute__((destructor(102))) dpaa_finish(void) +{ + /* For secondary, primary will do all the cleanup */ + if (rte_eal_process_type() != RTE_PROC_PRIMARY) + return; + + if (!(default_q || fmc_q)) { + unsigned int i; + + for (i = 0; i < RTE_MAX_ETHPORTS; i++) { + if (rte_eth_devices[i].dev_ops == &dpaa_devops) { + struct rte_eth_dev *dev = &rte_eth_devices[i]; + struct dpaa_if *dpaa_intf = + dev->data->dev_private; + struct fman_if *fif = + dev->process_private; + if (dpaa_intf->port_handle) + if (dpaa_fm_deconfig(dpaa_intf, fif)) + DPAA_PMD_WARN("DPAA FM " + "deconfig failed\n"); + } + } + if (is_global_init) + if (dpaa_fm_term()) + DPAA_PMD_WARN("DPAA FM term failed\n"); + + is_global_init = 0; + + DPAA_PMD_INFO("DPAA fman cleaned up"); + } +} + static struct rte_dpaa_driver rte_dpaa_pmd = { .drv_flags = RTE_DPAA_DRV_INTR_LSC, .drv_type = FSL_DPAA_ETH, diff --git a/drivers/net/dpaa/dpaa_ethdev.h b/drivers/net/dpaa/dpaa_ethdev.h index 4c40ff86a..b10c4a20b 100644 --- a/drivers/net/dpaa/dpaa_ethdev.h +++ b/drivers/net/dpaa/dpaa_ethdev.h @@ -118,6 +118,10 @@ struct dpaa_if { uint32_t ifid; struct dpaa_bp_info *bp_info; struct rte_eth_fc_conf *fc_conf; + void *port_handle; + void *netenv_handle; + void *scheme_handle[2]; + uint32_t scheme_count; }; struct dpaa_if_stats { diff --git a/drivers/net/dpaa/dpaa_flow.c b/drivers/net/dpaa/dpaa_flow.c new file mode 100644 index 000000000..a12141efe --- /dev/null +++ b/drivers/net/dpaa/dpaa_flow.c @@ -0,0 +1,901 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright 2017-2019 NXP + */ + +/* System headers */ +#include +#include +#include +#include + +#include +#include +#include +#include + +#define DPAA_MAX_NUM_ETH_DEV 8 + +static inline +ioc_fm_pcd_extract_entry_t * +SCH_EXT_ARR(ioc_fm_pcd_kg_scheme_params_t *scheme_params, int hdr_idx) +{ +return &scheme_params->param.key_ext_and_hash.extract_array[hdr_idx]; +} + +#define SCH_EXT_HDR(scheme_params, hdr_idx) \ + SCH_EXT_ARR(scheme_params, hdr_idx)->extract_params.extract_by_hdr + +#define SCH_EXT_FULL_FLD(scheme_params, hdr_idx) \ + SCH_EXT_HDR(scheme_params, hdr_idx).extract_by_hdr_type.full_field + +/* FM global info */ +struct dpaa_fm_info { + t_handle fman_handle; + t_handle pcd_handle; +}; + +/*FM model to read and write from file */ +struct dpaa_fm_model { + uint32_t dev_count; + uint8_t device_order[DPAA_MAX_NUM_ETH_DEV]; + t_fm_port_params fm_port_params[DPAA_MAX_NUM_ETH_DEV]; + t_handle netenv_devid[DPAA_MAX_NUM_ETH_DEV]; + t_handle scheme_devid[DPAA_MAX_NUM_ETH_DEV][2]; +}; + +static struct dpaa_fm_info fm_info; +static struct dpaa_fm_model fm_model; +static const char *fm_log = "/tmp/fmdpdk.bin"; + +static void fm_prev_cleanup(void) +{ + uint32_t fman_id = 0, i = 0, devid; + struct dpaa_if dpaa_intf = {0}; + t_fm_pcd_params fm_pcd_params = {0}; + PMD_INIT_FUNC_TRACE(); + + fm_info.fman_handle = fm_open(fman_id); + if (!fm_info.fman_handle) { + printf("\n%s- unable to open FMAN", __func__); + return; + } + + fm_pcd_params.h_fm = fm_info.fman_handle; + fm_pcd_params.prs_support = true; + fm_pcd_params.kg_support = true; + /* FM PCD Open */ + fm_info.pcd_handle = fm_pcd_open(&fm_pcd_params); + if (!fm_info.pcd_handle) { + printf("\n%s- unable to open PCD", __func__); + return; + } + + while (i < fm_model.dev_count) { + devid = fm_model.device_order[i]; + /* FM Port Open */ + fm_model.fm_port_params[devid].h_fm = fm_info.fman_handle; + dpaa_intf.port_handle = + fm_port_open(&fm_model.fm_port_params[devid]); + dpaa_intf.scheme_handle[0] = create_device(fm_info.pcd_handle, + fm_model.scheme_devid[devid][0]); + dpaa_intf.scheme_count = 1; + if (fm_model.scheme_devid[devid][1]) { + dpaa_intf.scheme_handle[1] = + create_device(fm_info.pcd_handle, + fm_model.scheme_devid[devid][1]); + if (dpaa_intf.scheme_handle[1]) + dpaa_intf.scheme_count++; + } + + dpaa_intf.netenv_handle = create_device(fm_info.pcd_handle, + fm_model.netenv_devid[devid]); + i++; + if (!dpaa_intf.netenv_handle || + !dpaa_intf.scheme_handle[0] || + !dpaa_intf.port_handle) + continue; + + if (dpaa_fm_deconfig(&dpaa_intf, NULL)) + printf("\nDPAA FM deconfig failed\n"); + } + + if (dpaa_fm_term()) + printf("\nDPAA FM term failed\n"); + + memset(&fm_model, 0, sizeof(struct dpaa_fm_model)); +} + +void dpaa_write_fm_config_to_file(void) +{ + size_t bytes_write; + FILE *fp = fopen(fm_log, "wb"); + PMD_INIT_FUNC_TRACE(); + + if (!fp) { + DPAA_PMD_ERR("File open failed"); + return; + } + bytes_write = fwrite(&fm_model, sizeof(struct dpaa_fm_model), 1, fp); + if (!bytes_write) { + DPAA_PMD_WARN("No bytes write"); + fclose(fp); + return; + } + fclose(fp); +} + +static void dpaa_read_fm_config_from_file(void) +{ + size_t bytes_read; + FILE *fp = fopen(fm_log, "rb"); + PMD_INIT_FUNC_TRACE(); + + if (!fp) + return; + DPAA_PMD_INFO("Previous DPDK-FM config instance present, cleaning up."); + + bytes_read = fread(&fm_model, sizeof(struct dpaa_fm_model), 1, fp); + if (!bytes_read) { + DPAA_PMD_WARN("No bytes read"); + fclose(fp); + return; + } + fclose(fp); + + /*FM cleanup from previous configured app */ + fm_prev_cleanup(); +} + +static inline int +set_hash_params_eth(ioc_fm_pcd_kg_scheme_params_t *scheme_params, int hdr_idx) +{ + int k; + + for (k = 0; k < 2; k++) { + SCH_EXT_ARR(scheme_params, hdr_idx)->type = + e_IOC_FM_PCD_EXTRACT_BY_HDR; + SCH_EXT_HDR(scheme_params, hdr_idx).hdr = + HEADER_TYPE_ETH; + SCH_EXT_HDR(scheme_params, hdr_idx).hdr_index = + e_IOC_FM_PCD_HDR_INDEX_NONE; + SCH_EXT_HDR(scheme_params, hdr_idx).type = + e_IOC_FM_PCD_EXTRACT_FULL_FIELD; + if (k == 0) + SCH_EXT_FULL_FLD(scheme_params, hdr_idx).eth = + IOC_NET_HF_ETH_SA; + else + SCH_EXT_FULL_FLD(scheme_params, hdr_idx).eth = + IOC_NET_HF_ETH_DA; + hdr_idx++; + } + return hdr_idx; +} + +static inline int +set_hash_params_ipv4(ioc_fm_pcd_kg_scheme_params_t *scheme_params, int hdr_idx) +{ + int k; + + for (k = 0; k < 2; k++) { + SCH_EXT_ARR(scheme_params, hdr_idx)->type = + e_IOC_FM_PCD_EXTRACT_BY_HDR; + SCH_EXT_HDR(scheme_params, hdr_idx).hdr = + HEADER_TYPE_IPV4; + SCH_EXT_HDR(scheme_params, hdr_idx).hdr_index = + e_IOC_FM_PCD_HDR_INDEX_NONE; + SCH_EXT_HDR(scheme_params, hdr_idx).type = + e_IOC_FM_PCD_EXTRACT_FULL_FIELD; + if (k == 0) + SCH_EXT_FULL_FLD(scheme_params, hdr_idx).ipv4 = + ioc_net_hf_ipv_4_src_ip; + else + SCH_EXT_FULL_FLD(scheme_params, hdr_idx).ipv4 = + ioc_net_hf_ipv_4_dst_ip; + hdr_idx++; + } + return hdr_idx; +} + +static inline int +set_hash_params_ipv6(ioc_fm_pcd_kg_scheme_params_t *scheme_params, int hdr_idx) +{ + int k; + + for (k = 0; k < 2; k++) { + SCH_EXT_ARR(scheme_params, hdr_idx)->type = + e_IOC_FM_PCD_EXTRACT_BY_HDR; + SCH_EXT_HDR(scheme_params, hdr_idx).hdr = + HEADER_TYPE_IPV6; + SCH_EXT_HDR(scheme_params, hdr_idx).hdr_index = + e_IOC_FM_PCD_HDR_INDEX_NONE; + SCH_EXT_HDR(scheme_params, hdr_idx).type = + e_IOC_FM_PCD_EXTRACT_FULL_FIELD; + if (k == 0) + SCH_EXT_FULL_FLD(scheme_params, hdr_idx).ipv6 = + ioc_net_hf_ipv_6_src_ip; + else + SCH_EXT_FULL_FLD(scheme_params, hdr_idx).ipv6 = + ioc_net_hf_ipv_6_dst_ip; + hdr_idx++; + } + return hdr_idx; +} + +static inline int +set_hash_params_udp(ioc_fm_pcd_kg_scheme_params_t *scheme_params, int hdr_idx) +{ + int k; + + for (k = 0; k < 2; k++) { + SCH_EXT_ARR(scheme_params, hdr_idx)->type = + e_IOC_FM_PCD_EXTRACT_BY_HDR; + SCH_EXT_HDR(scheme_params, hdr_idx).hdr = + HEADER_TYPE_UDP; + SCH_EXT_HDR(scheme_params, hdr_idx).hdr_index = + e_IOC_FM_PCD_HDR_INDEX_NONE; + SCH_EXT_HDR(scheme_params, hdr_idx).type = + e_IOC_FM_PCD_EXTRACT_FULL_FIELD; + if (k == 0) + SCH_EXT_FULL_FLD(scheme_params, hdr_idx).udp = + IOC_NET_HF_UDP_PORT_SRC; + else + SCH_EXT_FULL_FLD(scheme_params, hdr_idx).udp = + IOC_NET_HF_UDP_PORT_DST; + hdr_idx++; + } + return hdr_idx; +} + +static inline int +set_hash_params_tcp(ioc_fm_pcd_kg_scheme_params_t *scheme_params, int hdr_idx) +{ + int k; + + for (k = 0; k < 2; k++) { + SCH_EXT_ARR(scheme_params, hdr_idx)->type = + e_IOC_FM_PCD_EXTRACT_BY_HDR; + SCH_EXT_HDR(scheme_params, hdr_idx).hdr = + HEADER_TYPE_TCP; + SCH_EXT_HDR(scheme_params, hdr_idx).hdr_index = + e_IOC_FM_PCD_HDR_INDEX_NONE; + SCH_EXT_HDR(scheme_params, hdr_idx).type = + e_IOC_FM_PCD_EXTRACT_FULL_FIELD; + if (k == 0) + SCH_EXT_FULL_FLD(scheme_params, hdr_idx).tcp = + IOC_NET_HF_TCP_PORT_SRC; + else + SCH_EXT_FULL_FLD(scheme_params, hdr_idx).tcp = + IOC_NET_HF_TCP_PORT_DST; + hdr_idx++; + } + return hdr_idx; +} + +static inline int +set_hash_params_sctp(ioc_fm_pcd_kg_scheme_params_t *scheme_params, int hdr_idx) +{ + int k; + + for (k = 0; k < 2; k++) { + SCH_EXT_ARR(scheme_params, hdr_idx)->type = + e_IOC_FM_PCD_EXTRACT_BY_HDR; + SCH_EXT_HDR(scheme_params, hdr_idx).hdr = + HEADER_TYPE_SCTP; + SCH_EXT_HDR(scheme_params, hdr_idx).hdr_index = + e_IOC_FM_PCD_HDR_INDEX_NONE; + SCH_EXT_HDR(scheme_params, hdr_idx).type = + e_IOC_FM_PCD_EXTRACT_FULL_FIELD; + if (k == 0) + SCH_EXT_FULL_FLD(scheme_params, hdr_idx).sctp = + IOC_NET_HF_SCTP_PORT_SRC; + else + SCH_EXT_FULL_FLD(scheme_params, hdr_idx).sctp = + IOC_NET_HF_SCTP_PORT_DST; + hdr_idx++; + } + return hdr_idx; +} + +/* Set scheme params for hash distribution */ +static int set_scheme_params(ioc_fm_pcd_kg_scheme_params_t *scheme_params, + ioc_fm_pcd_net_env_params_t *dist_units, + struct dpaa_if *dpaa_intf, + struct fman_if *fif __rte_unused) +{ + int dist_idx, hdr_idx = 0; + PMD_INIT_FUNC_TRACE(); + + scheme_params->param.use_hash = 1; + scheme_params->param.modify = false; + scheme_params->param.always_direct = false; + scheme_params->param.scheme_counter.update = 1; + scheme_params->param.scheme_counter.value = 0; + scheme_params->param.next_engine = e_IOC_FM_PCD_DONE; + scheme_params->param.base_fqid = dpaa_intf->rx_queues[0].fqid; + scheme_params->param.net_env_params.net_env_id = + dpaa_intf->netenv_handle; + scheme_params->param.net_env_params.num_of_distinction_units = + dist_units->param.num_of_distinction_units; + + scheme_params->param.key_ext_and_hash.hash_dist_num_of_fqids = + dpaa_intf->nb_rx_queues; + scheme_params->param.key_ext_and_hash.num_of_used_extracts = + 2 * dist_units->param.num_of_distinction_units; + + for (dist_idx = 0; dist_idx < + dist_units->param.num_of_distinction_units; + dist_idx++) { + switch (dist_units->param.units[dist_idx].hdrs[0].hdr) { + case HEADER_TYPE_ETH: + hdr_idx = set_hash_params_eth(scheme_params, hdr_idx); + break; + + case HEADER_TYPE_IPV4: + hdr_idx = set_hash_params_ipv4(scheme_params, hdr_idx); + break; + + case HEADER_TYPE_IPV6: + hdr_idx = set_hash_params_ipv6(scheme_params, hdr_idx); + break; + + case HEADER_TYPE_UDP: + hdr_idx = set_hash_params_udp(scheme_params, hdr_idx); + break; + + case HEADER_TYPE_TCP: + hdr_idx = set_hash_params_tcp(scheme_params, hdr_idx); + break; + + case HEADER_TYPE_SCTP: + hdr_idx = set_hash_params_sctp(scheme_params, hdr_idx); + break; + + default: + DPAA_PMD_ERR("Invalid Distinction Unit"); + return -1; + } + } + + return 0; +} + +static void set_dist_units(ioc_fm_pcd_net_env_params_t *dist_units, + uint64_t req_dist_set) +{ + uint32_t loop = 0, dist_idx = 0, dist_field = 0; + int l2_configured = 0, ipv4_configured = 0, ipv6_configured = 0; + int udp_configured = 0, tcp_configured = 0, sctp_configured = 0; + PMD_INIT_FUNC_TRACE(); + + if (!req_dist_set) + dist_units->param.units[dist_idx++].hdrs[0].hdr = + HEADER_TYPE_ETH; + + while (req_dist_set) { + if (req_dist_set % 2 != 0) { + dist_field = 1U << loop; + switch (dist_field) { + case ETH_RSS_L2_PAYLOAD: + + if (l2_configured) + break; + l2_configured = 1; + + dist_units->param.units[dist_idx++].hdrs[0].hdr + = HEADER_TYPE_ETH; + break; + + case ETH_RSS_IPV4: + case ETH_RSS_FRAG_IPV4: + case ETH_RSS_NONFRAG_IPV4_OTHER: + + if (ipv4_configured) + break; + ipv4_configured = 1; + dist_units->param.units[dist_idx++].hdrs[0].hdr + = HEADER_TYPE_IPV4; + break; + + case ETH_RSS_IPV6: + case ETH_RSS_FRAG_IPV6: + case ETH_RSS_NONFRAG_IPV6_OTHER: + case ETH_RSS_IPV6_EX: + + if (ipv6_configured) + break; + ipv6_configured = 1; + dist_units->param.units[dist_idx++].hdrs[0].hdr + = HEADER_TYPE_IPV6; + break; + + case ETH_RSS_NONFRAG_IPV4_TCP: + case ETH_RSS_NONFRAG_IPV6_TCP: + case ETH_RSS_IPV6_TCP_EX: + + if (tcp_configured) + break; + tcp_configured = 1; + dist_units->param.units[dist_idx++].hdrs[0].hdr + = HEADER_TYPE_TCP; + break; + + case ETH_RSS_NONFRAG_IPV4_UDP: + case ETH_RSS_NONFRAG_IPV6_UDP: + case ETH_RSS_IPV6_UDP_EX: + + if (udp_configured) + break; + udp_configured = 1; + dist_units->param.units[dist_idx++].hdrs[0].hdr + = HEADER_TYPE_UDP; + break; + + case ETH_RSS_NONFRAG_IPV4_SCTP: + case ETH_RSS_NONFRAG_IPV6_SCTP: + + if (sctp_configured) + break; + sctp_configured = 1; + + dist_units->param.units[dist_idx++].hdrs[0].hdr + = HEADER_TYPE_SCTP; + break; + + default: + DPAA_PMD_ERR("Bad flow distribution option"); + } + } + req_dist_set = req_dist_set >> 1; + loop++; + } + + /* Dist units is set to dist_idx */ + dist_units->param.num_of_distinction_units = dist_idx; +} + +/* Apply PCD configuration on interface */ +static inline int set_port_pcd(struct dpaa_if *dpaa_intf) +{ + int ret = 0; + unsigned int idx; + ioc_fm_port_pcd_params_t pcd_param; + ioc_fm_port_pcd_prs_params_t prs_param; + ioc_fm_port_pcd_kg_params_t kg_param; + + PMD_INIT_FUNC_TRACE(); + + /* PCD support for hash distribution */ + uint8_t pcd_support = e_FM_PORT_PCD_SUPPORT_PRS_AND_KG; + + memset(&pcd_param, 0, sizeof(pcd_param)); + memset(&prs_param, 0, sizeof(prs_param)); + memset(&kg_param, 0, sizeof(kg_param)); + + /* Set parse params */ + prs_param.first_prs_hdr = HEADER_TYPE_ETH; + + /* Set kg params */ + for (idx = 0; idx < dpaa_intf->scheme_count; idx++) + kg_param.scheme_ids[idx] = dpaa_intf->scheme_handle[idx]; + kg_param.num_schemes = dpaa_intf->scheme_count; + + /* Set pcd params */ + pcd_param.net_env_id = dpaa_intf->netenv_handle; + pcd_param.pcd_support = pcd_support; + pcd_param.p_kg_params = &kg_param; + pcd_param.p_prs_params = &prs_param; + + /* FM PORT Disable */ + ret = fm_port_disable(dpaa_intf->port_handle); + if (ret != E_OK) { + DPAA_PMD_ERR("fm_port_disable: Failed"); + return ret; + } + + /* FM PORT SetPCD */ + ret = fm_port_set_pcd(dpaa_intf->port_handle, &pcd_param); + if (ret != E_OK) { + DPAA_PMD_ERR("fm_port_set_pcd: Failed"); + return ret; + } + + /* FM PORT Enable */ + ret = fm_port_enable(dpaa_intf->port_handle); + if (ret != E_OK) { + DPAA_PMD_ERR("fm_port_enable: Failed"); + goto fm_port_delete_pcd; + } + + return 0; + +fm_port_delete_pcd: + /* FM PORT DeletePCD */ + ret = fm_port_delete_pcd(dpaa_intf->port_handle); + if (ret != E_OK) { + DPAA_PMD_ERR("fm_port_delete_pcd: Failed\n"); + return ret; + } + return -1; +} + +/* Unset PCD NerEnv and scheme */ +static inline void unset_pcd_netenv_scheme(struct dpaa_if *dpaa_intf) +{ + int ret; + PMD_INIT_FUNC_TRACE(); + + /* reduce scheme count */ + if (dpaa_intf->scheme_count) + dpaa_intf->scheme_count--; + + DPAA_PMD_DEBUG("KG SCHEME DEL %d handle =%p", + dpaa_intf->scheme_count, + dpaa_intf->scheme_handle[dpaa_intf->scheme_count]); + + ret = fm_pcd_kg_scheme_delete(dpaa_intf->scheme_handle + [dpaa_intf->scheme_count]); + if (ret != E_OK) + DPAA_PMD_ERR("fm_pcd_kg_scheme_delete: Failed"); + + dpaa_intf->scheme_handle[dpaa_intf->scheme_count] = NULL; +} + +/* Set PCD NetEnv and Scheme and default scheme */ +static inline int set_default_scheme(struct dpaa_if *dpaa_intf) +{ + ioc_fm_pcd_kg_scheme_params_t scheme_params; + int idx = dpaa_intf->scheme_count; + PMD_INIT_FUNC_TRACE(); + + /* Set PCD NetEnvCharacteristics */ + memset(&scheme_params, 0, sizeof(scheme_params)); + + /* Adding 10 to default schemes as the number of interface would be + * lesser than 10 and the relative scheme ids should be unique for + * every scheme. + */ + scheme_params.param.scm_id.relative_scheme_id = + 10 + dpaa_intf->ifid; + scheme_params.param.use_hash = 0; + scheme_params.param.next_engine = e_IOC_FM_PCD_DONE; + scheme_params.param.net_env_params.num_of_distinction_units = 0; + scheme_params.param.net_env_params.net_env_id = + dpaa_intf->netenv_handle; + scheme_params.param.base_fqid = dpaa_intf->rx_queues[0].fqid; + scheme_params.param.key_ext_and_hash.hash_dist_num_of_fqids = 1; + scheme_params.param.key_ext_and_hash.num_of_used_extracts = 0; + scheme_params.param.modify = false; + scheme_params.param.always_direct = false; + scheme_params.param.scheme_counter.update = 1; + scheme_params.param.scheme_counter.value = 0; + + /* FM PCD KgSchemeSet */ + dpaa_intf->scheme_handle[idx] = + fm_pcd_kg_scheme_set(fm_info.pcd_handle, &scheme_params); + DPAA_PMD_DEBUG("KG SCHEME SET %d handle =%p", + idx, dpaa_intf->scheme_handle[idx]); + if (!dpaa_intf->scheme_handle[idx]) { + DPAA_PMD_ERR("fm_pcd_kg_scheme_set: Failed"); + return -1; + } + + fm_model.scheme_devid[dpaa_intf->ifid][idx] = + get_device_id(dpaa_intf->scheme_handle[idx]); + dpaa_intf->scheme_count++; + return 0; +} + + +/* Set PCD NetEnv and Scheme and default scheme */ +static inline int set_pcd_netenv_scheme(struct dpaa_if *dpaa_intf, + uint64_t req_dist_set, + struct fman_if *fif) +{ + int ret = -1; + ioc_fm_pcd_net_env_params_t dist_units; + ioc_fm_pcd_kg_scheme_params_t scheme_params; + int idx = dpaa_intf->scheme_count; + PMD_INIT_FUNC_TRACE(); + + /* Set PCD NetEnvCharacteristics */ + memset(&dist_units, 0, sizeof(dist_units)); + memset(&scheme_params, 0, sizeof(scheme_params)); + + /* Set dist unit header type */ + set_dist_units(&dist_units, req_dist_set); + + scheme_params.param.scm_id.relative_scheme_id = dpaa_intf->ifid; + + /* Set PCD Scheme params */ + ret = set_scheme_params(&scheme_params, &dist_units, dpaa_intf, fif); + if (ret) { + DPAA_PMD_ERR("Set scheme params: Failed"); + return -1; + } + + /* FM PCD KgSchemeSet */ + dpaa_intf->scheme_handle[idx] = + fm_pcd_kg_scheme_set(fm_info.pcd_handle, &scheme_params); + DPAA_PMD_DEBUG("KG SCHEME SET %d handle =%p", + idx, dpaa_intf->scheme_handle[idx]); + if (!dpaa_intf->scheme_handle[idx]) { + DPAA_PMD_ERR("fm_pcd_kg_scheme_set: Failed"); + return -1; + } + + fm_model.scheme_devid[dpaa_intf->ifid][idx] = + get_device_id(dpaa_intf->scheme_handle[idx]); + dpaa_intf->scheme_count++; + return 0; +} + + +static inline int get_port_type(struct fman_if *fif) +{ + if (fif->mac_type == fman_mac_1g) + return e_FM_PORT_TYPE_RX; + else if (fif->mac_type == fman_mac_2_5g) + return e_FM_PORT_TYPE_RX_2_5G; + else if (fif->mac_type == fman_mac_10g) + return e_FM_PORT_TYPE_RX_10G; + + DPAA_PMD_ERR("MAC type unsupported"); + return -1; +} + +static inline int set_fm_port_handle(struct dpaa_if *dpaa_intf, + uint64_t req_dist_set, + struct fman_if *fif) +{ + t_fm_port_params fm_port_params; + ioc_fm_pcd_net_env_params_t dist_units; + PMD_INIT_FUNC_TRACE(); + + /* FMAN mac indexes mappings (0 is unused, + * first 8 are for 1G, next for 10G ports + */ + uint8_t mac_idx[] = {-1, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1}; + + /* Memset FM port params */ + memset(&fm_port_params, 0, sizeof(fm_port_params)); + + /* Set FM port params */ + fm_port_params.h_fm = fm_info.fman_handle; + fm_port_params.port_type = get_port_type(fif); + fm_port_params.port_id = mac_idx[fif->mac_idx]; + + /* FM PORT Open */ + dpaa_intf->port_handle = fm_port_open(&fm_port_params); + if (!dpaa_intf->port_handle) { + DPAA_PMD_ERR("fm_port_open: Failed\n"); + return -1; + } + + fm_model.fm_port_params[dpaa_intf->ifid] = fm_port_params; + + /* Set PCD NetEnvCharacteristics */ + memset(&dist_units, 0, sizeof(dist_units)); + + /* Set dist unit header type */ + set_dist_units(&dist_units, req_dist_set); + + /* FM PCD NetEnvCharacteristicsSet */ + dpaa_intf->netenv_handle = + fm_pcd_net_env_characteristics_set(fm_info.pcd_handle, + &dist_units); + if (!dpaa_intf->netenv_handle) { + DPAA_PMD_ERR("fm_pcd_net_env_characteristics_set: Failed"); + return -1; + } + + fm_model.netenv_devid[dpaa_intf->ifid] = + get_device_id(dpaa_intf->netenv_handle); + + return 0; +} + +/* De-Configure DPAA FM */ +int dpaa_fm_deconfig(struct dpaa_if *dpaa_intf, + struct fman_if *fif __rte_unused) +{ + int ret; + unsigned int idx; + + PMD_INIT_FUNC_TRACE(); + + /* FM PORT Disable */ + ret = fm_port_disable(dpaa_intf->port_handle); + if (ret != E_OK) { + DPAA_PMD_ERR("fm_port_disable: Failed"); + return ret; + } + + /* FM PORT DeletePCD */ + ret = fm_port_delete_pcd(dpaa_intf->port_handle); + if (ret != E_OK) { + DPAA_PMD_ERR("fm_port_delete_pcd: Failed"); + return ret; + } + + for (idx = 0; idx < dpaa_intf->scheme_count; idx++) { + DPAA_PMD_DEBUG("KG SCHEME DEL %d, handle =%p", + idx, dpaa_intf->scheme_handle[idx]); + /* FM PCD KgSchemeDelete */ + ret = fm_pcd_kg_scheme_delete(dpaa_intf->scheme_handle[idx]); + if (ret != E_OK) { + DPAA_PMD_ERR("fm_pcd_kg_scheme_delete: Failed"); + return ret; + } + dpaa_intf->scheme_handle[idx] = NULL; + } + /* FM PCD NetEnvCharacteristicsDelete */ + ret = fm_pcd_net_env_characteristics_delete(dpaa_intf->netenv_handle); + if (ret != E_OK) { + DPAA_PMD_ERR("fm_pcd_net_env_characteristics_delete: Failed"); + return ret; + } + dpaa_intf->netenv_handle = NULL; + + /* FM PORT Close */ + fm_port_close(dpaa_intf->port_handle); + dpaa_intf->port_handle = NULL; + + /* Set scheme count to 0 */ + dpaa_intf->scheme_count = 0; + + return 0; +} + +int dpaa_fm_config(struct rte_eth_dev *dev, uint64_t req_dist_set) +{ + struct dpaa_if *dpaa_intf = dev->data->dev_private; + struct fman_if *fif = dev->process_private; + int ret; + unsigned int i = 0; + PMD_INIT_FUNC_TRACE(); + + if (dpaa_intf->port_handle) { + if (dpaa_fm_deconfig(dpaa_intf, fif)) + DPAA_PMD_ERR("DPAA FM deconfig failed"); + } + + if (!dev->data->nb_rx_queues) + return 0; + + if (dev->data->nb_rx_queues & (dev->data->nb_rx_queues - 1)) { + DPAA_PMD_ERR("No of queues should be power of 2"); + return -1; + } + + dpaa_intf->nb_rx_queues = dev->data->nb_rx_queues; + + /* Open FM Port and set it in port info */ + ret = set_fm_port_handle(dpaa_intf, req_dist_set, fif); + if (ret) { + DPAA_PMD_ERR("Set FM Port handle: Failed"); + return -1; + } + + /* Set PCD netenv and scheme */ + if (req_dist_set) { + ret = set_pcd_netenv_scheme(dpaa_intf, req_dist_set, fif); + if (ret) { + DPAA_PMD_ERR("Set PCD NetEnv and Scheme dist: Failed"); + goto unset_fm_port_handle; + } + } + /* Set default netenv and scheme */ + ret = set_default_scheme(dpaa_intf); + if (ret) { + DPAA_PMD_ERR("Set PCD NetEnv and Scheme: Failed"); + goto unset_pcd_netenv_scheme1; + } + + /* Set Port PCD */ + ret = set_port_pcd(dpaa_intf); + if (ret) { + DPAA_PMD_ERR("Set Port PCD: Failed"); + goto unset_pcd_netenv_scheme; + } + + for (; i < fm_model.dev_count; i++) + if (fm_model.device_order[i] == dpaa_intf->ifid) + return 0; + + fm_model.device_order[fm_model.dev_count] = dpaa_intf->ifid; + fm_model.dev_count++; + + return 0; + +unset_pcd_netenv_scheme: + unset_pcd_netenv_scheme(dpaa_intf); + +unset_pcd_netenv_scheme1: + unset_pcd_netenv_scheme(dpaa_intf); + +unset_fm_port_handle: + /* FM PORT Close */ + fm_port_close(dpaa_intf->port_handle); + dpaa_intf->port_handle = NULL; + return -1; +} + +int dpaa_fm_init(void) +{ + t_handle fman_handle; + t_handle pcd_handle; + t_fm_pcd_params fm_pcd_params = {0}; + /* Hard-coded : fman id 0 since one fman is present in LS104x */ + int fman_id = 0, ret; + PMD_INIT_FUNC_TRACE(); + + dpaa_read_fm_config_from_file(); + + /* FM Open */ + fman_handle = fm_open(fman_id); + if (!fman_handle) { + DPAA_PMD_ERR("fm_open: Failed"); + return -1; + } + + /* FM PCD Open */ + fm_pcd_params.h_fm = fman_handle; + fm_pcd_params.prs_support = true; + fm_pcd_params.kg_support = true; + pcd_handle = fm_pcd_open(&fm_pcd_params); + if (!pcd_handle) { + fm_close(fman_handle); + DPAA_PMD_ERR("fm_pcd_open: Failed"); + return -1; + } + + /* FM PCD Enable */ + ret = fm_pcd_enable(pcd_handle); + if (ret) { + fm_close(fman_handle); + fm_pcd_close(pcd_handle); + DPAA_PMD_ERR("fm_pcd_enable: Failed"); + return -1; + } + + /* Set fman and pcd handle in fm info */ + fm_info.fman_handle = fman_handle; + fm_info.pcd_handle = pcd_handle; + + return 0; +} + + +/* De-initialization of FM */ +int dpaa_fm_term(void) +{ + int ret; + + PMD_INIT_FUNC_TRACE(); + + if (fm_info.pcd_handle && fm_info.fman_handle) { + /* FM PCD Disable */ + ret = fm_pcd_disable(fm_info.pcd_handle); + if (ret) { + DPAA_PMD_ERR("fm_pcd_disable: Failed"); + return -1; + } + + /* FM PCD Close */ + fm_pcd_close(fm_info.pcd_handle); + fm_info.pcd_handle = NULL; + } + + if (fm_info.fman_handle) { + /* FM Close */ + fm_close(fm_info.fman_handle); + fm_info.fman_handle = NULL; + } + + if (access(fm_log, F_OK) != -1) { + ret = remove(fm_log); + if (ret) + DPAA_PMD_ERR("File remove: Failed"); + } + return 0; +} diff --git a/drivers/net/dpaa/dpaa_flow.h b/drivers/net/dpaa/dpaa_flow.h new file mode 100644 index 000000000..d16bfec21 --- /dev/null +++ b/drivers/net/dpaa/dpaa_flow.h @@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright 2017,2019 NXP + */ + +#ifndef __DPAA_FLOW_H__ +#define __DPAA_FLOW_H__ + +int dpaa_fm_init(void); +int dpaa_fm_term(void); +int dpaa_fm_config(struct rte_eth_dev *dev, uint64_t req_dist_set); +int dpaa_fm_deconfig(struct dpaa_if *dpaa_intf, struct fman_if *fif); +void dpaa_write_fm_config_to_file(void); + +#endif diff --git a/drivers/net/dpaa/meson.build b/drivers/net/dpaa/meson.build index aca1dccc3..51f1f32a1 100644 --- a/drivers/net/dpaa/meson.build +++ b/drivers/net/dpaa/meson.build @@ -10,6 +10,7 @@ deps += ['mempool_dpaa'] sources = files('dpaa_ethdev.c', 'fmlib/fm_lib.c', 'fmlib/fm_vsp.c', + 'dpaa_flow.c', 'dpaa_rxtx.c') if cc.has_argument('-Wno-pointer-arith') From patchwork Tue Sep 1 12:36:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hemant Agrawal X-Patchwork-Id: 248852 Delivered-To: patch@linaro.org Received: by 2002:a92:5b9c:0:0:0:0:0 with SMTP id c28csp4195254ilg; Tue, 1 Sep 2020 05:43:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwGA4g45tpxlDbLvcbZx5pNOywdbM3/P98dgjvvMPUoyoJdLg3tfMuWl4JolARMyj+hKw7Y X-Received: by 2002:a17:906:529a:: with SMTP id c26mr1355859ejm.252.1598964200807; Tue, 01 Sep 2020 05:43:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598964200; cv=none; d=google.com; s=arc-20160816; b=rhOlGNQ17dq0RDv/10Hq3dqPC19m2VdHSam42Ihwdp+lDJ0h9uHcckFCXawJUgx06v Fp4f8eXQ6OPU1W43DKrp0ypvqS2QLv9VnnvlTdanoa2oahdlEjajdEZ7TMdovFax3yNv hAu3oSmKlobAe9OwQTUeD61UXAkbbVYUo8wuJKQhfWJMIXeKJXCvqdADa1wYYhw6fX47 C5NEDJllgdDTFKDJiqW3IJnYiEpmV4lII/ZzC/n4SalJlkhTQ4mtzked+0R4zMyXZYQx aNfqwrWNgsbmpLqftI4tJdwdUhRKwwpo1HnP0DxhTDT1/MAXCcrFM+pStiWLdvm24Gsv 0diQ== 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=BGhS5e+CvPwDkOSGV2fzpXa0wWY/6GFltdS1KYoEcHM=; b=ygco/Z5TIYXqirp7d9Jpe+aFN84AH5eL3DrbpBNzL5vncxyHkEwXtc8kIDo2TU0REI /zlfI4Y6rT8+p3TN5CLp/4keeVZPoChut6WZNkXOdQZ7C0b7Q+LG/pbcuzEc6ezvNaNc ep/SbqcZI1ZMKJuh0NCcncivtlVMmpZsTrnfrF0ommXKXWNP+EDXWud2iofZkcam7OXL QAQLXqK4ibhyaODKVedpfVieNh5hFWDyhS2s8Rfwqx5ZyGjbcA9z53zmjAr9whdg8Ooj Thy/TUXCr1mShIWU1jCDbCU0sKqYWgy0FoilS0b42PaUjQWj+RoaiGhjEuy5B9qCyl/Y m/cQ== 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 cy23si488805edb.311.2020.09.01.05.43.20; Tue, 01 Sep 2020 05:43:20 -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 02E6D1C1BD; Tue, 1 Sep 2020 14:43:04 +0200 (CEST) Received: from inva020.nxp.com (inva020.nxp.com [92.121.34.13]) by dpdk.org (Postfix) with ESMTP id 4CD041C0B7 for ; Tue, 1 Sep 2020 14:43:00 +0200 (CEST) Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 2D6791A0097; Tue, 1 Sep 2020 14:43:00 +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 B1A301A00A7; Tue, 1 Sep 2020 14:42:58 +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 A46C2402BF; Tue, 1 Sep 2020 14:42:56 +0200 (CEST) From: Hemant Agrawal To: dev@dpdk.org Cc: ferruh.yigit@intel.com Date: Tue, 1 Sep 2020 18:06:46 +0530 Message-Id: <20200901123650.29908-4-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200901123650.29908-1-hemant.agrawal@nxp.com> References: <20200813180121.19480-1-hemant.agrawal@nxp.com> <20200901123650.29908-1-hemant.agrawal@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Subject: [dpdk-dev] [PATCH v6 4/8] bus/dpaa: add shared MAC support 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: Radu Bulie A shared MAC interface is an interface which can be used by both kernel and userspace based on classification configuration It is defined in dts with the compatible string "fsl,dpa-ethernet-shared" which bpool will be seeded by the dpdk partition and configured as a netdev by the dpaa Linux eth driver. User space buffers from the bpool will be kmapped by the kernel. Signed-off-by: Radu Bulie Signed-off-by: Jun Yang Signed-off-by: Nipun Gupta Acked-by: Hemant Agrawal --- drivers/bus/dpaa/base/fman/fman.c | 27 ++++++++++++++++++++++----- drivers/bus/dpaa/include/fman.h | 2 ++ drivers/net/dpaa/dpaa_ethdev.c | 31 +++++++++++++++++-------------- drivers/net/dpaa/dpaa_flow.c | 18 ++++++++++++++---- 4 files changed, 55 insertions(+), 23 deletions(-) -- 2.17.1 diff --git a/drivers/bus/dpaa/base/fman/fman.c b/drivers/bus/dpaa/base/fman/fman.c index 33be9e5d7..3ae29bf06 100644 --- a/drivers/bus/dpaa/base/fman/fman.c +++ b/drivers/bus/dpaa/base/fman/fman.c @@ -167,13 +167,21 @@ fman_if_init(const struct device_node *dpa_node) const char *mname, *fname; const char *dname = dpa_node->full_name; size_t lenp; - int _errno; + int _errno, is_shared = 0; const char *char_prop; uint32_t na; if (of_device_is_available(dpa_node) == false) return 0; + if (!of_device_is_compatible(dpa_node, "fsl,dpa-ethernet-init") && + !of_device_is_compatible(dpa_node, "fsl,dpa-ethernet-shared")) { + return 0; + } + + if (of_device_is_compatible(dpa_node, "fsl,dpa-ethernet-shared")) + is_shared = 1; + rprop = "fsl,qman-frame-queues-rx"; mprop = "fsl,fman-mac"; @@ -387,7 +395,7 @@ fman_if_init(const struct device_node *dpa_node) goto err; } - assert(lenp == (4 * sizeof(phandle))); + assert(lenp >= (4 * sizeof(phandle))); na = of_n_addr_cells(mac_node); /* Get rid of endianness (issues). Convert to host byte order */ @@ -408,7 +416,7 @@ fman_if_init(const struct device_node *dpa_node) goto err; } - assert(lenp == (4 * sizeof(phandle))); + assert(lenp >= (4 * sizeof(phandle))); /*TODO: Fix for other cases also */ na = of_n_addr_cells(mac_node); /* Get rid of endianness (issues). Convert to host byte order */ @@ -508,6 +516,9 @@ fman_if_init(const struct device_node *dpa_node) pools_phandle++; } + if (is_shared) + __if->__if.is_shared_mac = 1; + /* Parsing of the network interface is complete, add it to the list */ DPAA_BUS_LOG(DEBUG, "Found %s, Tx Channel = %x, FMAN = %x," "Port ID = %x", @@ -524,7 +535,7 @@ fman_if_init(const struct device_node *dpa_node) int fman_init(void) { - const struct device_node *dpa_node; + const struct device_node *dpa_node, *parent_node; int _errno; /* If multiple dependencies try to initialise the Fman driver, don't @@ -539,7 +550,13 @@ fman_init(void) return fman_ccsr_map_fd; } - for_each_compatible_node(dpa_node, NULL, "fsl,dpa-ethernet-init") { + parent_node = of_find_compatible_node(NULL, NULL, "fsl,dpaa"); + if (!parent_node) { + DPAA_BUS_LOG(ERR, "Unable to find fsl,dpaa node"); + return -ENODEV; + } + + for_each_child_node(parent_node, dpa_node) { _errno = fman_if_init(dpa_node); if (_errno) { FMAN_ERR(_errno, "if_init(%s)\n", dpa_node->full_name); diff --git a/drivers/bus/dpaa/include/fman.h b/drivers/bus/dpaa/include/fman.h index 7a0a7d405..cb7f18ca2 100644 --- a/drivers/bus/dpaa/include/fman.h +++ b/drivers/bus/dpaa/include/fman.h @@ -320,6 +320,8 @@ struct fman_if { struct rte_ether_addr mac_addr; /* The Qman channel to schedule Tx FQs to */ u16 tx_channel_id; + + uint8_t is_shared_mac; /* The hard-coded FQIDs for this interface. Note: this doesn't cover * the PCD nor the "Rx default" FQIDs, which are configured via FMC * and its XML-based configuration. diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c index c5b9ac1a5..c2d480397 100644 --- a/drivers/net/dpaa/dpaa_ethdev.c +++ b/drivers/net/dpaa/dpaa_ethdev.c @@ -351,7 +351,8 @@ static void dpaa_eth_dev_stop(struct rte_eth_dev *dev) PMD_INIT_FUNC_TRACE(); - fman_if_disable_rx(fif); + if (!fif->is_shared_mac) + fman_if_disable_rx(fif); dev->tx_pkt_burst = dpaa_eth_tx_drop_all; } @@ -1807,19 +1808,21 @@ dpaa_dev_init(struct rte_eth_dev *eth_dev) fman_intf->mac_addr.addr_bytes[4], fman_intf->mac_addr.addr_bytes[5]); - - /* Disable RX mode */ - fman_if_discard_rx_errors(fman_intf); - fman_if_disable_rx(fman_intf); - /* Disable promiscuous mode */ - fman_if_promiscuous_disable(fman_intf); - /* Disable multicast */ - fman_if_reset_mcast_filter_table(fman_intf); - /* Reset interface statistics */ - fman_if_stats_reset(fman_intf); - /* Disable SG by default */ - fman_if_set_sg(fman_intf, 0); - fman_if_set_maxfrm(fman_intf, RTE_ETHER_MAX_LEN + VLAN_TAG_SIZE); + if (!fman_intf->is_shared_mac) { + /* Disable RX mode */ + fman_if_discard_rx_errors(fman_intf); + fman_if_disable_rx(fman_intf); + /* Disable promiscuous mode */ + fman_if_promiscuous_disable(fman_intf); + /* Disable multicast */ + fman_if_reset_mcast_filter_table(fman_intf); + /* Reset interface statistics */ + fman_if_stats_reset(fman_intf); + /* Disable SG by default */ + fman_if_set_sg(fman_intf, 0); + fman_if_set_maxfrm(fman_intf, + RTE_ETHER_MAX_LEN + VLAN_TAG_SIZE); + } return 0; diff --git a/drivers/net/dpaa/dpaa_flow.c b/drivers/net/dpaa/dpaa_flow.c index a12141efe..d24cd856c 100644 --- a/drivers/net/dpaa/dpaa_flow.c +++ b/drivers/net/dpaa/dpaa_flow.c @@ -736,6 +736,14 @@ int dpaa_fm_deconfig(struct dpaa_if *dpaa_intf, } dpaa_intf->netenv_handle = NULL; + if (fif && fif->is_shared_mac) { + ret = fm_port_enable(dpaa_intf->port_handle); + if (ret != E_OK) { + DPAA_PMD_ERR("shared mac re-enable failed"); + return ret; + } + } + /* FM PORT Close */ fm_port_close(dpaa_intf->port_handle); dpaa_intf->port_handle = NULL; @@ -785,10 +793,12 @@ int dpaa_fm_config(struct rte_eth_dev *dev, uint64_t req_dist_set) } } /* Set default netenv and scheme */ - ret = set_default_scheme(dpaa_intf); - if (ret) { - DPAA_PMD_ERR("Set PCD NetEnv and Scheme: Failed"); - goto unset_pcd_netenv_scheme1; + if (!fif->is_shared_mac) { + ret = set_default_scheme(dpaa_intf); + if (ret) { + DPAA_PMD_ERR("Set PCD NetEnv and Scheme: Failed"); + goto unset_pcd_netenv_scheme1; + } } /* Set Port PCD */ From patchwork Tue Sep 1 12:36:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hemant Agrawal X-Patchwork-Id: 248853 Delivered-To: patch@linaro.org Received: by 2002:a92:5b9c:0:0:0:0:0 with SMTP id c28csp4195472ilg; Tue, 1 Sep 2020 05:43:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxqY5oh8AWaWCLTuosPWm2MmsllfjA2UBRXHabLCV5xfHo9kUK/GnEDF9hAMq/fVird/W4k X-Received: by 2002:a17:906:3e81:: with SMTP id a1mr1253018ejj.227.1598964216322; Tue, 01 Sep 2020 05:43:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598964216; cv=none; d=google.com; s=arc-20160816; b=IYcXh6+CbIoH/RP58GqfFWenNBL519z5BA00/2gi7gwZLnsNurebksWU0olYvHIf5D tbzMMzgghi9EyUyk/DTkJ6RaGMjD4FUMsE+v18gINGBoCeONYUtc7SfjIxTSOWrIuR1M 0vghuh0ICLYCNHHKT2aYHfEFrJryM63tt7hGgOfxXaRHBlrVSjpnFuH0yzMDpmCLx+Sq q2+dsEmxWZIAjM8OcUSMQ6E5uked/mgfMY7nPiO+GsSYl0swRU9jOETd+EOvVxVWn9HL kfsCpj7NwbwpJ4XS2kQRNZ0xcO5B1Bqqdu8/Ca9OhtGDVfWkKHGHvOn3jNZo34gEo+le y4JA== 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=LbQqvUt9iMcKwiGrZbRtwTtEtHzJCc+JTT6jI32vVUE=; b=etSp9FQVr6t7fiQIaEL6o/d56OAHoBNZxNNbcY8kZyZqZwsP5wdFUzcqYnOKvZFE9T hk+Ir7UBxrOuD7KJTFQ6GMrDNQ2eM2VSoWIYpknZDRN19Kju4Fx2MxR8N/9NivPgzmqZ 1/eoZzpp0vvhZ29/eD0gUBJEVDnqgRl3icWA5bpY9C5Z5jKcGlrjp33ZZBf95bP+arRr nW+C/45Zbmt7McJToKGp2mdatpB5GWPjWcUUejxUCbJcrxSBx1u1i+jTTJYJrAHgJ/2b gVl3E72R6J+qp0pwyicodDew283ejp03NNVx0t0rElYKvdjyPqYojQR57gxx3u3DiNYN aT3w== 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 f24si591088ejd.473.2020.09.01.05.43.36; Tue, 01 Sep 2020 05:43:36 -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 E97D21C1DB; Tue, 1 Sep 2020 14:43:05 +0200 (CEST) Received: from inva021.nxp.com (inva021.nxp.com [92.121.34.21]) by dpdk.org (Postfix) with ESMTP id B2DB11C0B7 for ; Tue, 1 Sep 2020 14:43:00 +0200 (CEST) Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 8D4C7200078; Tue, 1 Sep 2020 14:43:00 +0200 (CEST) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 4927620004D; Tue, 1 Sep 2020 14:42:59 +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 3B821402C3; Tue, 1 Sep 2020 14:42:57 +0200 (CEST) From: Hemant Agrawal To: dev@dpdk.org Cc: ferruh.yigit@intel.com Date: Tue, 1 Sep 2020 18:06:47 +0530 Message-Id: <20200901123650.29908-5-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200901123650.29908-1-hemant.agrawal@nxp.com> References: <20200813180121.19480-1-hemant.agrawal@nxp.com> <20200901123650.29908-1-hemant.agrawal@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Subject: [dpdk-dev] [PATCH v6 5/8] bus/dpaa: add Virtual Storage Profile port init 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" This patch add support to initialize the VSP ports in the FMAN library. Signed-off-by: Hemant Agrawal --- drivers/bus/dpaa/base/fman/fman.c | 57 +++++++++++++++++++++++++++++++ drivers/bus/dpaa/include/fman.h | 3 ++ 2 files changed, 60 insertions(+) -- 2.17.1 diff --git a/drivers/bus/dpaa/base/fman/fman.c b/drivers/bus/dpaa/base/fman/fman.c index 3ae29bf06..39102bc1f 100644 --- a/drivers/bus/dpaa/base/fman/fman.c +++ b/drivers/bus/dpaa/base/fman/fman.c @@ -145,6 +145,61 @@ fman_get_mac_index(uint64_t regs_addr_host, uint8_t *mac_idx) return ret; } +static void fman_if_vsp_init(struct __fman_if *__if) +{ + const phandle *prop; + int cell_index; + const struct device_node *dev; + size_t lenp; + const uint8_t mac_idx[] = {-1, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1}; + + if (__if->__if.mac_type == fman_mac_1g) { + for_each_compatible_node(dev, NULL, + "fsl,fman-port-1g-rx-extended-args") { + prop = of_get_property(dev, "cell-index", &lenp); + if (prop) { + cell_index = of_read_number( + &prop[0], + lenp / sizeof(phandle)); + if (cell_index == mac_idx[__if->__if.mac_idx]) { + prop = of_get_property( + dev, + "vsp-window", &lenp); + if (prop) { + __if->__if.num_profiles = + of_read_number( + &prop[0], 1); + __if->__if.base_profile_id = + of_read_number( + &prop[1], 1); + } + } + } + } + } else if (__if->__if.mac_type == fman_mac_10g) { + for_each_compatible_node(dev, NULL, + "fsl,fman-port-10g-rx-extended-args") { + prop = of_get_property(dev, "cell-index", &lenp); + if (prop) { + cell_index = of_read_number( + &prop[0], lenp / sizeof(phandle)); + if (cell_index == mac_idx[__if->__if.mac_idx]) { + prop = of_get_property( + dev, "vsp-window", &lenp); + if (prop) { + __if->__if.num_profiles = + of_read_number( + &prop[0], 1); + __if->__if.base_profile_id = + of_read_number( + &prop[1], 1); + } + } + } + } + } +} + static int fman_if_init(const struct device_node *dpa_node) { @@ -519,6 +574,8 @@ fman_if_init(const struct device_node *dpa_node) if (is_shared) __if->__if.is_shared_mac = 1; + fman_if_vsp_init(__if); + /* Parsing of the network interface is complete, add it to the list */ DPAA_BUS_LOG(DEBUG, "Found %s, Tx Channel = %x, FMAN = %x," "Port ID = %x", diff --git a/drivers/bus/dpaa/include/fman.h b/drivers/bus/dpaa/include/fman.h index cb7f18ca2..dcf408372 100644 --- a/drivers/bus/dpaa/include/fman.h +++ b/drivers/bus/dpaa/include/fman.h @@ -321,6 +321,9 @@ struct fman_if { /* The Qman channel to schedule Tx FQs to */ u16 tx_channel_id; + uint8_t base_profile_id; + uint8_t num_profiles; + uint8_t is_shared_mac; /* The hard-coded FQIDs for this interface. Note: this doesn't cover * the PCD nor the "Rx default" FQIDs, which are configured via FMC From patchwork Tue Sep 1 12:36:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hemant Agrawal X-Patchwork-Id: 248857 Delivered-To: patch@linaro.org Received: by 2002:a92:5b9c:0:0:0:0:0 with SMTP id c28csp4196148ilg; Tue, 1 Sep 2020 05:44:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwwM90Zi5w9r7dijmmDlPDwsOTZ4qfbOXe7U9Z48r4R6sn3QO5DRCRD0q57E5e17rw+kLc3 X-Received: by 2002:aa7:cd90:: with SMTP id x16mr551054edv.302.1598964266945; Tue, 01 Sep 2020 05:44:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598964266; cv=none; d=google.com; s=arc-20160816; b=rG0Altft9InifnOXGRKkCXlpsEA/z4B7fP8TYUJmI7SEgYkFYcJiXIF3OqntbThDoa erkDbsYgFFrJ1w2rOssTQYEZVt6J8tuM4lU2ZNfKE8ndP45i+HiCxJuwF8ZX6YBSslMM 1MA6ZiQQiWYc273mY1Lez90h9mrp4ExycsAHHQgIrQ7r1NFCFgHkNncWobQysdRSCfya poCHLbbtuQVAErxV0BjpNwqj8q9tLFkfiZLUsX90EC/TsDch/39emxNqn18QAH46z4fN JaKRiIb+DLIzsR4LiQ16Z4degBVcal/RY6ubnN3ZsPlDVIeV8B8dgmZ5B/5djCMpP3DG R4yA== 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=zkCaU6GfsKdcUldd4oKyXjQWPTfDn98Hjow1aIsmI8g=; b=sRn/2COvNExQE0oQWgLTup6GqVsmbaY+IIqTl0vtio1Xk4gx1BwgC30NgfnFX/g89B 5XxLz0RzHOMrZZtJ6kE8cNg83eS6BCNt25JuURFPI3w2sQyo+7cYXdHZRljWOqW6UAtx d2mg5ZGd8tWx+vogSZDwUWAEwzXiHtdqd2hscX/FwCwMA4aF6QCtIhNNZqsidTlkdyKY cRkcx1aZHGpey99ydCRdILp62IOOsLRJzcAcaQjVnAHmbbp8nrZCflw9R4TOM0Ug0hKn 22cY+DRP8B5749JCjv5/kFqopCKmzuFV4iHXu4012yubrwlDTBrDK3R2EZbnc1o4eOGP tqRA== 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 n14si471088eds.248.2020.09.01.05.44.26; Tue, 01 Sep 2020 05:44:26 -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 DB2C51C20A; Tue, 1 Sep 2020 14:43:09 +0200 (CEST) Received: from inva020.nxp.com (inva020.nxp.com [92.121.34.13]) by dpdk.org (Postfix) with ESMTP id 80E781C1AE for ; Tue, 1 Sep 2020 14:43:02 +0200 (CEST) Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 6469E1A0097; Tue, 1 Sep 2020 14:43:02 +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 BBCDA1A0062; Tue, 1 Sep 2020 14:43:00 +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 C4BFD402D7; Tue, 1 Sep 2020 14:42:57 +0200 (CEST) From: Hemant Agrawal To: dev@dpdk.org Cc: ferruh.yigit@intel.com Date: Tue, 1 Sep 2020 18:06:48 +0530 Message-Id: <20200901123650.29908-6-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200901123650.29908-1-hemant.agrawal@nxp.com> References: <20200813180121.19480-1-hemant.agrawal@nxp.com> <20200901123650.29908-1-hemant.agrawal@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Subject: [dpdk-dev] [PATCH v6 6/8] net/dpaa: add support for Virtual Storage Profile 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 Virtual Storage profile (VSP) feature. With VSP support when memory pool is created, the hw buffer pool id i.e. bpid is not allocated; thhe bpid is identified by dpaa flow create API. The memory pool of RX queue is attached to specific BMan pool according to the VSP ID when RX queue is setup. for fmlib based hash queue, vsp base ID is assigned to each queue. Signed-off-by: Jun Yang Acked-by: Hemant Agrawal --- drivers/bus/dpaa/include/fsl_qman.h | 1 + drivers/net/dpaa/dpaa_ethdev.c | 133 +++++++++++++++++----- drivers/net/dpaa/dpaa_ethdev.h | 7 ++ drivers/net/dpaa/dpaa_flow.c | 164 +++++++++++++++++++++++++++- drivers/net/dpaa/dpaa_flow.h | 5 + 5 files changed, 282 insertions(+), 28 deletions(-) -- 2.17.1 diff --git a/drivers/bus/dpaa/include/fsl_qman.h b/drivers/bus/dpaa/include/fsl_qman.h index dd7ca783a..10212f0fd 100644 --- a/drivers/bus/dpaa/include/fsl_qman.h +++ b/drivers/bus/dpaa/include/fsl_qman.h @@ -1229,6 +1229,7 @@ struct qman_fq { int q_fd; u16 ch_id; + int8_t vsp_id; u8 cgr_groupid; u8 is_static:4; u8 qp_initialized:4; diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c index c2d480397..8e7eb9824 100644 --- a/drivers/net/dpaa/dpaa_ethdev.c +++ b/drivers/net/dpaa/dpaa_ethdev.c @@ -722,6 +722,55 @@ static int dpaa_eth_multicast_disable(struct rte_eth_dev *dev) return 0; } +static void dpaa_fman_if_pool_setup(struct rte_eth_dev *dev) +{ + struct dpaa_if *dpaa_intf = dev->data->dev_private; + struct fman_if_ic_params icp; + uint32_t fd_offset; + uint32_t bp_size; + + memset(&icp, 0, sizeof(icp)); + /* set ICEOF for to the default value , which is 0*/ + icp.iciof = DEFAULT_ICIOF; + icp.iceof = DEFAULT_RX_ICEOF; + icp.icsz = DEFAULT_ICSZ; + fman_if_set_ic_params(dev->process_private, &icp); + + fd_offset = RTE_PKTMBUF_HEADROOM + DPAA_HW_BUF_RESERVE; + fman_if_set_fdoff(dev->process_private, fd_offset); + + /* Buffer pool size should be equal to Dataroom Size*/ + bp_size = rte_pktmbuf_data_room_size(dpaa_intf->bp_info->mp); + + fman_if_set_bp(dev->process_private, + dpaa_intf->bp_info->mp->size, + dpaa_intf->bp_info->bpid, bp_size); +} + +static inline int dpaa_eth_rx_queue_bp_check(struct rte_eth_dev *dev, + int8_t vsp_id, uint32_t bpid) +{ + struct dpaa_if *dpaa_intf = dev->data->dev_private; + struct fman_if *fif = dev->process_private; + + if (fif->num_profiles) { + if (vsp_id < 0) + vsp_id = fif->base_profile_id; + } else { + if (vsp_id < 0) + vsp_id = 0; + } + + if (dpaa_intf->vsp_bpid[vsp_id] && + bpid != dpaa_intf->vsp_bpid[vsp_id]) { + DPAA_PMD_ERR("Various MPs are assigned to RXQs with same VSP"); + + return -1; + } + + return 0; +} + static int dpaa_eth_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx, uint16_t nb_desc, @@ -757,6 +806,20 @@ int dpaa_eth_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx, DPAA_PMD_INFO("Rx queue setup for queue index: %d fq_id (0x%x)", queue_idx, rxq->fqid); + if (!fif->num_profiles) { + if (dpaa_intf->bp_info && dpaa_intf->bp_info->bp && + dpaa_intf->bp_info->mp != mp) { + DPAA_PMD_WARN("Multiple pools on same interface not" + " supported"); + return -EINVAL; + } + } else { + if (dpaa_eth_rx_queue_bp_check(dev, rxq->vsp_id, + DPAA_MEMPOOL_TO_POOL_INFO(mp)->bpid)) { + return -EINVAL; + } + } + /* Max packet can fit in single buffer */ if (dev->data->dev_conf.rxmode.max_rx_pkt_len <= buffsz) { ; @@ -779,36 +842,40 @@ int dpaa_eth_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx, buffsz - RTE_PKTMBUF_HEADROOM); } - if (!dpaa_intf->bp_info || dpaa_intf->bp_info->mp != mp) { - struct fman_if_ic_params icp; - uint32_t fd_offset; - uint32_t bp_size; + dpaa_intf->bp_info = DPAA_MEMPOOL_TO_POOL_INFO(mp); - if (!mp->pool_data) { - DPAA_PMD_ERR("Not an offloaded buffer pool!"); - return -1; + /* For shared interface, it's done in kernel, skip.*/ + if (!fif->is_shared_mac) + dpaa_fman_if_pool_setup(dev); + + if (fif->num_profiles) { + int8_t vsp_id = rxq->vsp_id; + + if (vsp_id >= 0) { + ret = dpaa_port_vsp_update(dpaa_intf, fmc_q, vsp_id, + DPAA_MEMPOOL_TO_POOL_INFO(mp)->bpid, + fif); + if (ret) { + DPAA_PMD_ERR("dpaa_port_vsp_update failed"); + return ret; + } + } else { + DPAA_PMD_INFO("Base profile is associated to" + " RXQ fqid:%d\r\n", rxq->fqid); + if (fif->is_shared_mac) { + DPAA_PMD_ERR("Fatal: Base profile is associated" + " to shared interface on DPDK."); + return -EINVAL; + } + dpaa_intf->vsp_bpid[fif->base_profile_id] = + DPAA_MEMPOOL_TO_POOL_INFO(mp)->bpid; } - dpaa_intf->bp_info = DPAA_MEMPOOL_TO_POOL_INFO(mp); - - memset(&icp, 0, sizeof(icp)); - /* set ICEOF for to the default value , which is 0*/ - icp.iciof = DEFAULT_ICIOF; - icp.iceof = DEFAULT_RX_ICEOF; - icp.icsz = DEFAULT_ICSZ; - fman_if_set_ic_params(fif, &icp); - - fd_offset = RTE_PKTMBUF_HEADROOM + DPAA_HW_BUF_RESERVE; - fman_if_set_fdoff(fif, fd_offset); - - /* Buffer pool size should be equal to Dataroom Size*/ - bp_size = rte_pktmbuf_data_room_size(mp); - fman_if_set_bp(fif, mp->size, - dpaa_intf->bp_info->bpid, bp_size); - dpaa_intf->valid = 1; - DPAA_PMD_DEBUG("if:%s fd_offset = %d offset = %d", - dpaa_intf->name, fd_offset, - fman_if_get_fdoff(fif)); + } else { + dpaa_intf->vsp_bpid[0] = + DPAA_MEMPOOL_TO_POOL_INFO(mp)->bpid; } + + dpaa_intf->valid = 1; DPAA_PMD_DEBUG("if:%s sg_on = %d, max_frm =%d", dpaa_intf->name, fman_if_get_sg_enable(fif), dev->data->dev_conf.rxmode.max_rx_pkt_len); @@ -1605,6 +1672,8 @@ dpaa_dev_init(struct rte_eth_dev *eth_dev) uint32_t cgrid[DPAA_MAX_NUM_PCD_QUEUES]; uint32_t cgrid_tx[MAX_DPAA_CORES]; uint32_t dev_rx_fqids[DPAA_MAX_NUM_PCD_QUEUES]; + int8_t dev_vspids[DPAA_MAX_NUM_PCD_QUEUES]; + int8_t vsp_id = -1; PMD_INIT_FUNC_TRACE(); @@ -1624,6 +1693,8 @@ dpaa_dev_init(struct rte_eth_dev *eth_dev) memset((char *)dev_rx_fqids, 0, sizeof(uint32_t) * DPAA_MAX_NUM_PCD_QUEUES); + memset(dev_vspids, -1, DPAA_MAX_NUM_PCD_QUEUES); + /* Initialize Rx FQ's */ if (default_q) { num_rx_fqs = DPAA_DEFAULT_NUM_PCD_QUEUES; @@ -1703,6 +1774,8 @@ dpaa_dev_init(struct rte_eth_dev *eth_dev) else fqid = dev_rx_fqids[loop]; + vsp_id = dev_vspids[loop]; + if (dpaa_intf->cgr_rx) dpaa_intf->cgr_rx[loop].cgrid = cgrid[loop]; @@ -1711,6 +1784,7 @@ dpaa_dev_init(struct rte_eth_dev *eth_dev) fqid); if (ret) goto free_rx; + dpaa_intf->rx_queues[loop].vsp_id = vsp_id; dpaa_intf->rx_queues[loop].dpaa_intf = dpaa_intf; } dpaa_intf->nb_rx_queues = num_rx_fqs; @@ -2051,6 +2125,11 @@ static void __attribute__((destructor(102))) dpaa_finish(void) if (dpaa_fm_deconfig(dpaa_intf, fif)) DPAA_PMD_WARN("DPAA FM " "deconfig failed\n"); + if (fif->num_profiles) { + if (dpaa_port_vsp_cleanup(dpaa_intf, + fif)) + DPAA_PMD_WARN("DPAA FM vsp cleanup failed\n"); + } } } if (is_global_init) diff --git a/drivers/net/dpaa/dpaa_ethdev.h b/drivers/net/dpaa/dpaa_ethdev.h index b10c4a20b..dd182c4d5 100644 --- a/drivers/net/dpaa/dpaa_ethdev.h +++ b/drivers/net/dpaa/dpaa_ethdev.h @@ -103,6 +103,10 @@ #define DPAA_FD_CMD_CFQ 0x00ffffff /**< Confirmation Frame Queue */ +#define DPAA_VSP_PROFILE_MAX_NUM 8 + +#define DPAA_DEFAULT_RXQ_VSP_ID 1 + /* Each network interface is represented by one of these */ struct dpaa_if { int valid; @@ -122,6 +126,9 @@ struct dpaa_if { void *netenv_handle; void *scheme_handle[2]; uint32_t scheme_count; + + void *vsp_handle[DPAA_VSP_PROFILE_MAX_NUM]; + uint32_t vsp_bpid[DPAA_VSP_PROFILE_MAX_NUM]; }; struct dpaa_if_stats { diff --git a/drivers/net/dpaa/dpaa_flow.c b/drivers/net/dpaa/dpaa_flow.c index d24cd856c..a0087df67 100644 --- a/drivers/net/dpaa/dpaa_flow.c +++ b/drivers/net/dpaa/dpaa_flow.c @@ -12,6 +12,7 @@ #include #include #include +#include #define DPAA_MAX_NUM_ETH_DEV 8 @@ -47,6 +48,17 @@ static struct dpaa_fm_info fm_info; static struct dpaa_fm_model fm_model; static const char *fm_log = "/tmp/fmdpdk.bin"; +static inline uint8_t fm_default_vsp_id(struct fman_if *fif) +{ + /* Avoid being same as base profile which could be used + * for kernel interface of shared mac. + */ + if (fif->base_profile_id) + return 0; + else + return DPAA_DEFAULT_RXQ_VSP_ID; +} + static void fm_prev_cleanup(void) { uint32_t fman_id = 0, i = 0, devid; @@ -300,11 +312,18 @@ set_hash_params_sctp(ioc_fm_pcd_kg_scheme_params_t *scheme_params, int hdr_idx) static int set_scheme_params(ioc_fm_pcd_kg_scheme_params_t *scheme_params, ioc_fm_pcd_net_env_params_t *dist_units, struct dpaa_if *dpaa_intf, - struct fman_if *fif __rte_unused) + struct fman_if *fif) { int dist_idx, hdr_idx = 0; PMD_INIT_FUNC_TRACE(); + if (fif->num_profiles) { + scheme_params->param.override_storage_profile = true; + scheme_params->param.storage_profile.direct = true; + scheme_params->param.storage_profile.profile_select + .direct_relative_profile_id = fm_default_vsp_id(fif); + } + scheme_params->param.use_hash = 1; scheme_params->param.modify = false; scheme_params->param.always_direct = false; @@ -784,6 +803,14 @@ int dpaa_fm_config(struct rte_eth_dev *dev, uint64_t req_dist_set) return -1; } + if (fif->num_profiles) { + for (i = 0; i < dpaa_intf->nb_rx_queues; i++) + dpaa_intf->rx_queues[i].vsp_id = + fm_default_vsp_id(fif); + + i = 0; + } + /* Set PCD netenv and scheme */ if (req_dist_set) { ret = set_pcd_netenv_scheme(dpaa_intf, req_dist_set, fif); @@ -909,3 +936,138 @@ int dpaa_fm_term(void) } return 0; } + +static int dpaa_port_vsp_configure(struct dpaa_if *dpaa_intf, + uint8_t vsp_id, t_handle fman_handle, + struct fman_if *fif) +{ + t_fm_vsp_params vsp_params; + t_fm_buffer_prefix_content buf_prefix_cont; + uint8_t mac_idx[] = {-1, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1}; + uint8_t idx = mac_idx[fif->mac_idx]; + int ret; + + if (vsp_id == fif->base_profile_id && fif->is_shared_mac) { + /* For shared interface, VSP of base + * profile is default pool located in kernel. + */ + dpaa_intf->vsp_bpid[vsp_id] = 0; + return 0; + } + + if (vsp_id >= DPAA_VSP_PROFILE_MAX_NUM) { + DPAA_PMD_ERR("VSP ID %d exceeds MAX number %d", + vsp_id, DPAA_VSP_PROFILE_MAX_NUM); + return -1; + } + + memset(&vsp_params, 0, sizeof(vsp_params)); + vsp_params.h_fm = fman_handle; + vsp_params.relative_profile_id = vsp_id; + vsp_params.port_params.port_id = idx; + if (fif->mac_type == fman_mac_1g) { + vsp_params.port_params.port_type = e_FM_PORT_TYPE_RX; + } else if (fif->mac_type == fman_mac_2_5g) { + vsp_params.port_params.port_type = e_FM_PORT_TYPE_RX_2_5G; + } else if (fif->mac_type == fman_mac_10g) { + vsp_params.port_params.port_type = e_FM_PORT_TYPE_RX_10G; + } else { + DPAA_PMD_ERR("Mac type %d error", fif->mac_type); + return -1; + } + vsp_params.ext_buf_pools.num_of_pools_used = 1; + vsp_params.ext_buf_pools.ext_buf_pool[0].id = + dpaa_intf->vsp_bpid[vsp_id]; + vsp_params.ext_buf_pools.ext_buf_pool[0].size = + RTE_MBUF_DEFAULT_BUF_SIZE; + + dpaa_intf->vsp_handle[vsp_id] = fm_vsp_config(&vsp_params); + if (!dpaa_intf->vsp_handle[vsp_id]) { + DPAA_PMD_ERR("fm_vsp_config error for profile %d", vsp_id); + return -EINVAL; + } + + /* configure the application buffer (structure, size and + * content) + */ + + memset(&buf_prefix_cont, 0, sizeof(buf_prefix_cont)); + + buf_prefix_cont.priv_data_size = 16; + buf_prefix_cont.data_align = 64; + buf_prefix_cont.pass_prs_result = true; + buf_prefix_cont.pass_time_stamp = true; + buf_prefix_cont.pass_hash_result = false; + buf_prefix_cont.pass_all_other_pcdinfo = false; + ret = fm_vsp_config_buffer_prefix_content(dpaa_intf->vsp_handle[vsp_id], + &buf_prefix_cont); + if (ret != E_OK) { + DPAA_PMD_ERR("fm_vsp_config_buffer_prefix_content error for profile %d err: %d", + vsp_id, ret); + return ret; + } + + /* initialize the FM VSP module */ + ret = fm_vsp_init(dpaa_intf->vsp_handle[vsp_id]); + if (ret != E_OK) { + DPAA_PMD_ERR("fm_vsp_init error for profile %d err:%d", + vsp_id, ret); + return ret; + } + + return 0; +} + +int dpaa_port_vsp_update(struct dpaa_if *dpaa_intf, + bool fmc_mode, uint8_t vsp_id, uint32_t bpid, + struct fman_if *fif) +{ + int ret = 0; + t_handle fman_handle; + + if (!fif->num_profiles) + return 0; + + if (vsp_id >= fif->num_profiles) + return 0; + + if (dpaa_intf->vsp_bpid[vsp_id] == bpid) + return 0; + + if (dpaa_intf->vsp_handle[vsp_id]) { + ret = fm_vsp_free(dpaa_intf->vsp_handle[vsp_id]); + if (ret != E_OK) { + DPAA_PMD_ERR("Error fm_vsp_free: err %d vsp_handle[%d]", + ret, vsp_id); + return ret; + } + dpaa_intf->vsp_handle[vsp_id] = 0; + } + + if (fmc_mode) + fman_handle = fm_open(0); + else + fman_handle = fm_info.fman_handle; + + dpaa_intf->vsp_bpid[vsp_id] = bpid; + + return dpaa_port_vsp_configure(dpaa_intf, vsp_id, fman_handle, fif); +} + +int dpaa_port_vsp_cleanup(struct dpaa_if *dpaa_intf, struct fman_if *fif) +{ + int idx, ret; + + for (idx = 0; idx < (uint8_t)fif->num_profiles; idx++) { + if (dpaa_intf->vsp_handle[idx]) { + ret = fm_vsp_free(dpaa_intf->vsp_handle[idx]); + if (ret != E_OK) { + DPAA_PMD_ERR("Error fm_vsp_free: err %d" + " vsp_handle[%d]", ret, idx); + return ret; + } + } + } + + return E_OK; +} diff --git a/drivers/net/dpaa/dpaa_flow.h b/drivers/net/dpaa/dpaa_flow.h index d16bfec21..f5e131acf 100644 --- a/drivers/net/dpaa/dpaa_flow.h +++ b/drivers/net/dpaa/dpaa_flow.h @@ -10,5 +10,10 @@ int dpaa_fm_term(void); int dpaa_fm_config(struct rte_eth_dev *dev, uint64_t req_dist_set); int dpaa_fm_deconfig(struct dpaa_if *dpaa_intf, struct fman_if *fif); void dpaa_write_fm_config_to_file(void); +int dpaa_port_vsp_update(struct dpaa_if *dpaa_intf, + bool fmc_mode, uint8_t vsp_id, uint32_t bpid, struct fman_if *fif); +int dpaa_port_vsp_cleanup(struct dpaa_if *dpaa_intf, struct fman_if *fif); +int dpaa_port_fmc_init(struct fman_if *fif, + uint32_t *fqids, int8_t *vspids, int max_nb_rxq); #endif From patchwork Tue Sep 1 12:36:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hemant Agrawal X-Patchwork-Id: 248856 Delivered-To: patch@linaro.org Received: by 2002:a92:5b9c:0:0:0:0:0 with SMTP id c28csp4195912ilg; Tue, 1 Sep 2020 05:44:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy9JW1Y+lBqFjyEXlQZ1KKBIxevCTiXDZiNG/6O4e1BjDP+uIBQFwYW6jD/Hm2TGVBS391f X-Received: by 2002:a50:fa94:: with SMTP id w20mr1320725edr.206.1598964248015; Tue, 01 Sep 2020 05:44:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598964248; cv=none; d=google.com; s=arc-20160816; b=gdp9xIsRnzxwGlTLpmZTWCzZqy6790MNVWLefw2OCmwknivA7dpY0u5pE4MjTxGYVu xLUyzyc2Dte8IajV31lIBGWXTuP4szRiLbAv5YmBW0PppCeodZ0ssbmHCYvggLRFUMKQ YLebB1hQ/K5rQ+yxpLpLlaXwmVQgjLBHB4nWQfD3fHSmWlDG6AXGKeQg9Ue5aVq9KVPH tC9By/H/+8riBtDoh9TzVyKpJssS8qTVfS7+qrXkg+kKkYf5wblKueL1jyQwcZLg9ISO K5ayEkO1n/sOthb5fUOQH7OFYPicHjovqiT2qw+f/zienB4jbyDbZrW3FXMWZ9PlFIaT 6BNg== 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=EomL7M8MT2ukmRm1sfrxDj45cK9JFN2d3GKSEdY2dv0=; b=mYzPF5gcfxERqRLD6Wz6FJpnbSjrJBiTXqfafm+JbvtlOFaeWjzCGNzXL4hJAiaPb0 MBOvpUn7r9Dr2tjT9lrHhuESJT44Wc3YRp3dfva+x6KXMLzGuGbuQVL1QE3lNt7ZEHFA lnXgxqtvVnZJEix4SdImZro3OtT6+o67Q48qE8vRKDok331LHpqbSHGrTNDyrIUQx0/3 agIUJ9huHtmVb3aH9rtLPg+cQ7ZeYgC4/Y7uNilndQ2ELCNtkQx9U45+nyDZh3uhFoQo AtvGlpaQCsvDgQ5XnbRpDctvb1ULsTZKNjRmfoaMMBnVQoVJ5Hnxs5GKJKcKR4u7tgtG seAQ== 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 a5si485498edu.87.2020.09.01.05.44.07; Tue, 01 Sep 2020 05:44:08 -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 397151C1F5; Tue, 1 Sep 2020 14:43:08 +0200 (CEST) Received: from inva021.nxp.com (inva021.nxp.com [92.121.34.21]) by dpdk.org (Postfix) with ESMTP id 5A0CC1C135 for ; Tue, 1 Sep 2020 14:43:02 +0200 (CEST) Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 39746200893; Tue, 1 Sep 2020 14:43:02 +0200 (CEST) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id BBC6720004D; Tue, 1 Sep 2020 14:43:00 +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 59B38402D9; Tue, 1 Sep 2020 14:42:58 +0200 (CEST) From: Hemant Agrawal To: dev@dpdk.org Cc: ferruh.yigit@intel.com Date: Tue, 1 Sep 2020 18:06:49 +0530 Message-Id: <20200901123650.29908-7-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200901123650.29908-1-hemant.agrawal@nxp.com> References: <20200813180121.19480-1-hemant.agrawal@nxp.com> <20200901123650.29908-1-hemant.agrawal@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Subject: [dpdk-dev] [PATCH v6 7/8] net/dpaa: add fmc parser support for VSP 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 FMC tool genertes and saves the setup in a file. This patch help Parse the /tmp/fmc.bin generated by fmc to setup RXQs for each port on fmc mode. The parser gets the fqids and vspids from fmc.bin Signed-off-by: Jun Yang Acked-by: Hemant Agrawal --- drivers/net/dpaa/dpaa_ethdev.c | 26 +- drivers/net/dpaa/dpaa_ethdev.h | 10 +- drivers/net/dpaa/dpaa_fmc.c | 475 +++++++++++++++++++++++++++++++++ drivers/net/dpaa/meson.build | 3 +- 4 files changed, 507 insertions(+), 7 deletions(-) create mode 100644 drivers/net/dpaa/dpaa_fmc.c -- 2.17.1 diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c index 8e7eb9824..0ce2f5ae3 100644 --- a/drivers/net/dpaa/dpaa_ethdev.c +++ b/drivers/net/dpaa/dpaa_ethdev.c @@ -259,6 +259,16 @@ dpaa_eth_dev_configure(struct rte_eth_dev *dev) dev->data->scattered_rx = 1; } + if (!(default_q || fmc_q)) { + if (dpaa_fm_config(dev, + eth_conf->rx_adv_conf.rss_conf.rss_hf)) { + dpaa_write_fm_config_to_file(); + DPAA_PMD_ERR("FM port configuration: Failed\n"); + return -1; + } + dpaa_write_fm_config_to_file(); + } + /* if the interrupts were configured on this devices*/ if (intr_handle && intr_handle->fd) { if (dev->data->dev_conf.intr_conf.lsc != 0) @@ -334,6 +344,9 @@ static int dpaa_eth_dev_start(struct rte_eth_dev *dev) PMD_INIT_FUNC_TRACE(); + if (!(default_q || fmc_q)) + dpaa_write_fm_config_to_file(); + /* Change tx callback to the real one */ if (dpaa_intf->cgr_tx) dev->tx_pkt_burst = dpaa_eth_queue_tx_slow; @@ -1699,7 +1712,18 @@ dpaa_dev_init(struct rte_eth_dev *eth_dev) if (default_q) { num_rx_fqs = DPAA_DEFAULT_NUM_PCD_QUEUES; } else if (fmc_q) { - num_rx_fqs = 1; + num_rx_fqs = dpaa_port_fmc_init(fman_intf, dev_rx_fqids, + dev_vspids, + DPAA_MAX_NUM_PCD_QUEUES); + if (num_rx_fqs < 0) { + DPAA_PMD_ERR("%s FMC initializes failed!", + dpaa_intf->name); + goto free_rx; + } + if (!num_rx_fqs) { + DPAA_PMD_WARN("%s is not configured by FMC.", + dpaa_intf->name); + } } else { /* FMCLESS mode, load balance to multiple cores.*/ num_rx_fqs = rte_lcore_count(); diff --git a/drivers/net/dpaa/dpaa_ethdev.h b/drivers/net/dpaa/dpaa_ethdev.h index dd182c4d5..1b8e120e8 100644 --- a/drivers/net/dpaa/dpaa_ethdev.h +++ b/drivers/net/dpaa/dpaa_ethdev.h @@ -59,10 +59,10 @@ #endif /* PCD frame queues */ -#define DPAA_PCD_FQID_START 0x400 -#define DPAA_PCD_FQID_MULTIPLIER 0x100 #define DPAA_DEFAULT_NUM_PCD_QUEUES 1 -#define DPAA_MAX_NUM_PCD_QUEUES 4 +#define DPAA_VSP_PROFILE_MAX_NUM 8 +#define DPAA_MAX_NUM_PCD_QUEUES DPAA_VSP_PROFILE_MAX_NUM +/*Same as VSP profile number*/ #define DPAA_IF_TX_PRIORITY 3 #define DPAA_IF_RX_PRIORITY 0 @@ -103,10 +103,10 @@ #define DPAA_FD_CMD_CFQ 0x00ffffff /**< Confirmation Frame Queue */ -#define DPAA_VSP_PROFILE_MAX_NUM 8 - #define DPAA_DEFAULT_RXQ_VSP_ID 1 +#define FMC_FILE "/tmp/fmc.bin" + /* Each network interface is represented by one of these */ struct dpaa_if { int valid; diff --git a/drivers/net/dpaa/dpaa_fmc.c b/drivers/net/dpaa/dpaa_fmc.c new file mode 100644 index 000000000..0ef362274 --- /dev/null +++ b/drivers/net/dpaa/dpaa_fmc.c @@ -0,0 +1,475 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright 2017-2020 NXP + */ + +/* System headers */ +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#define FMC_OUTPUT_FORMAT_VER 0x106 + +#define FMC_NAME_LEN 64 +#define FMC_FMAN_NUM 2 +#define FMC_PORTS_PER_FMAN 16 +#define FMC_SCHEMES_NUM 32 +#define FMC_SCHEME_PROTOCOLS_NUM 16 +#define FMC_CC_NODES_NUM 512 +#define FMC_REPLICATORS_NUM 16 +#define FMC_PLC_NUM 64 +#define MAX_SP_CODE_SIZE 0x7C0 +#define FMC_MANIP_MAX 64 +#define FMC_HMANIP_MAX 512 +#define FMC_INSERT_MAX 56 +#define FM_PCD_MAX_REPS 64 + +typedef struct fmc_port_t { + e_fm_port_type type; + unsigned int number; + struct fm_pcd_net_env_params_t distinction_units; + struct ioc_fm_port_pcd_params_t pcd_param; + struct ioc_fm_port_pcd_prs_params_t prs_param; + struct ioc_fm_port_pcd_kg_params_t kg_param; + struct ioc_fm_port_pcd_cc_params_t cc_param; + char name[FMC_NAME_LEN]; + char cctree_name[FMC_NAME_LEN]; + t_handle handle; + t_handle env_id_handle; + t_handle env_id_dev_id; + t_handle cctree_handle; + t_handle cctree_dev_id; + + unsigned int schemes_count; + unsigned int schemes[FMC_SCHEMES_NUM]; + unsigned int ccnodes_count; + unsigned int ccnodes[FMC_CC_NODES_NUM]; + unsigned int htnodes_count; + unsigned int htnodes[FMC_CC_NODES_NUM]; + + unsigned int replicators_count; + unsigned int replicators[FMC_REPLICATORS_NUM]; + ioc_fm_port_vsp_alloc_params_t vsp_param; + + unsigned int ccroot_count; + unsigned int ccroot[FMC_CC_NODES_NUM]; + enum ioc_fm_pcd_engine ccroot_type[FMC_CC_NODES_NUM]; + unsigned int ccroot_manip[FMC_CC_NODES_NUM]; + + unsigned int reasm_index; +} fmc_port; + +typedef struct fmc_fman_t { + unsigned int number; + unsigned int port_count; + unsigned int ports[FMC_PORTS_PER_FMAN]; + char name[FMC_NAME_LEN]; + t_handle handle; + char pcd_name[FMC_NAME_LEN]; + t_handle pcd_handle; + unsigned int kg_payload_offset; + + unsigned int offload_support; + + unsigned int reasm_count; + struct fm_pcd_manip_params_t reasm[FMC_MANIP_MAX]; + char reasm_name[FMC_MANIP_MAX][FMC_NAME_LEN]; + t_handle reasm_handle[FMC_MANIP_MAX]; + t_handle reasm_dev_id[FMC_MANIP_MAX]; + + unsigned int frag_count; + struct fm_pcd_manip_params_t frag[FMC_MANIP_MAX]; + char frag_name[FMC_MANIP_MAX][FMC_NAME_LEN]; + t_handle frag_handle[FMC_MANIP_MAX]; + t_handle frag_dev_id[FMC_MANIP_MAX]; + + unsigned int hdr_count; + struct fm_pcd_manip_params_t hdr[FMC_HMANIP_MAX]; + uint8_t insert_data[FMC_HMANIP_MAX][FMC_INSERT_MAX]; + char hdr_name[FMC_HMANIP_MAX][FMC_NAME_LEN]; + t_handle hdr_handle[FMC_HMANIP_MAX]; + t_handle hdr_dev_id[FMC_HMANIP_MAX]; + unsigned int hdr_has_next[FMC_HMANIP_MAX]; + unsigned int hdr_next[FMC_HMANIP_MAX]; +} fmc_fman; + +typedef enum fmc_apply_order_e { + fmcengine_start, + fmcengine_end, + fmcport_start, + fmcport_end, + fmcscheme, + fmcccnode, + fmchtnode, + fmccctree, + fmcpolicer, + fmcreplicator, + fmcmanipulation +} fmc_apply_order_e; + +typedef struct fmc_apply_order_t { + fmc_apply_order_e type; + unsigned int index; +} fmc_apply_order; + +struct fmc_model_t { + unsigned int format_version; + unsigned int sp_enable; + t_fm_pcd_prs_sw_params sp; + uint8_t spcode[MAX_SP_CODE_SIZE]; + + unsigned int fman_count; + fmc_fman fman[FMC_FMAN_NUM]; + + unsigned int port_count; + fmc_port port[FMC_FMAN_NUM * FMC_PORTS_PER_FMAN]; + + unsigned int scheme_count; + char scheme_name[FMC_SCHEMES_NUM][FMC_NAME_LEN]; + t_handle scheme_handle[FMC_SCHEMES_NUM]; + t_handle scheme_dev_id[FMC_SCHEMES_NUM]; + struct fm_pcd_kg_scheme_params_t scheme[FMC_SCHEMES_NUM]; + + unsigned int ccnode_count; + char ccnode_name[FMC_CC_NODES_NUM][FMC_NAME_LEN]; + t_handle ccnode_handle[FMC_CC_NODES_NUM]; + t_handle ccnode_dev_id[FMC_CC_NODES_NUM]; + struct fm_pcd_cc_node_params_t ccnode[FMC_CC_NODES_NUM]; + uint8_t cckeydata[FMC_CC_NODES_NUM][FM_PCD_MAX_NUM_OF_KEYS] + [FM_PCD_MAX_SIZE_OF_KEY]; + unsigned char ccmask[FMC_CC_NODES_NUM][FM_PCD_MAX_NUM_OF_KEYS] + [FM_PCD_MAX_SIZE_OF_KEY]; + unsigned int + ccentry_action_index[FMC_CC_NODES_NUM][FM_PCD_MAX_NUM_OF_KEYS]; + enum ioc_fm_pcd_engine + ccentry_action_type[FMC_CC_NODES_NUM][FM_PCD_MAX_NUM_OF_KEYS]; + unsigned char ccentry_frag[FMC_CC_NODES_NUM][FM_PCD_MAX_NUM_OF_KEYS]; + unsigned int ccentry_manip[FMC_CC_NODES_NUM][FM_PCD_MAX_NUM_OF_KEYS]; + unsigned int ccmiss_action_index[FMC_CC_NODES_NUM]; + enum ioc_fm_pcd_engine ccmiss_action_type[FMC_CC_NODES_NUM]; + unsigned char ccmiss_frag[FMC_CC_NODES_NUM]; + unsigned int ccmiss_manip[FMC_CC_NODES_NUM]; + + unsigned int htnode_count; + char htnode_name[FMC_CC_NODES_NUM][FMC_NAME_LEN]; + t_handle htnode_handle[FMC_CC_NODES_NUM]; + t_handle htnode_dev_id[FMC_CC_NODES_NUM]; + struct fm_pcd_hash_table_params_t htnode[FMC_CC_NODES_NUM]; + + unsigned int htentry_count[FMC_CC_NODES_NUM]; + struct ioc_fm_pcd_cc_key_params_t + htentry[FMC_CC_NODES_NUM][FM_PCD_MAX_NUM_OF_KEYS]; + uint8_t htkeydata[FMC_CC_NODES_NUM][FM_PCD_MAX_NUM_OF_KEYS] + [FM_PCD_MAX_SIZE_OF_KEY]; + unsigned int + htentry_action_index[FMC_CC_NODES_NUM][FM_PCD_MAX_NUM_OF_KEYS]; + enum ioc_fm_pcd_engine + htentry_action_type[FMC_CC_NODES_NUM][FM_PCD_MAX_NUM_OF_KEYS]; + unsigned char htentry_frag[FMC_CC_NODES_NUM][FM_PCD_MAX_NUM_OF_KEYS]; + unsigned int htentry_manip[FMC_CC_NODES_NUM][FM_PCD_MAX_NUM_OF_KEYS]; + + unsigned int htmiss_action_index[FMC_CC_NODES_NUM]; + enum ioc_fm_pcd_engine htmiss_action_type[FMC_CC_NODES_NUM]; + unsigned char htmiss_frag[FMC_CC_NODES_NUM]; + unsigned int htmiss_manip[FMC_CC_NODES_NUM]; + + unsigned int replicator_count; + char replicator_name[FMC_REPLICATORS_NUM][FMC_NAME_LEN]; + t_handle replicator_handle[FMC_REPLICATORS_NUM]; + t_handle replicator_dev_id[FMC_REPLICATORS_NUM]; + struct fm_pcd_frm_replic_group_params_t replicator[FMC_REPLICATORS_NUM]; + unsigned int + repentry_action_index[FMC_REPLICATORS_NUM][FM_PCD_MAX_REPS]; + unsigned char repentry_frag[FMC_REPLICATORS_NUM][FM_PCD_MAX_REPS]; + unsigned int repentry_manip[FMC_REPLICATORS_NUM][FM_PCD_MAX_REPS]; + + unsigned int policer_count; + char policer_name[FMC_PLC_NUM][FMC_NAME_LEN]; + struct fm_pcd_plcr_profile_params_t policer[FMC_PLC_NUM]; + t_handle policer_handle[FMC_PLC_NUM]; + t_handle policer_dev_id[FMC_PLC_NUM]; + unsigned int policer_action_index[FMC_PLC_NUM][3]; + + unsigned int apply_order_count; + fmc_apply_order apply_order[FMC_FMAN_NUM * + FMC_PORTS_PER_FMAN * + (FMC_SCHEMES_NUM + FMC_CC_NODES_NUM)]; +}; + +struct fmc_model_t *g_fmc_model; + +static int dpaa_port_fmc_port_parse(struct fman_if *fif, + const struct fmc_model_t *fmc_model, + int apply_idx) +{ + int current_port = fmc_model->apply_order[apply_idx].index; + const fmc_port *pport = &fmc_model->port[current_port]; + const uint8_t mac_idx[] = {-1, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1}; + const uint8_t mac_type[] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2}; + + if (mac_idx[fif->mac_idx] != pport->number || + mac_type[fif->mac_idx] != pport->type) + return -1; + + return current_port; +} + +static int dpaa_port_fmc_scheme_parse(struct fman_if *fif, + const struct fmc_model_t *fmc, + int apply_idx, + uint16_t *rxq_idx, int max_nb_rxq, + uint32_t *fqids, int8_t *vspids) +{ + int idx = fmc->apply_order[apply_idx].index; + uint32_t i; + + if (!fmc->scheme[idx].override_storage_profile && + fif->is_shared_mac) { + DPAA_PMD_WARN("No VSP assigned to scheme %d for sharemac %d!", + idx, fif->mac_idx); + DPAA_PMD_WARN("Risk to receive pkts from skb pool to CRASH!"); + } + + if (e_IOC_FM_PCD_DONE == + fmc->scheme[idx].next_engine) { + for (i = 0; i < fmc->scheme[idx] + .key_ext_and_hash.hash_dist_num_of_fqids; i++) { + uint32_t fqid = fmc->scheme[idx].base_fqid + i; + int k, found = 0; + + if (fqid == fif->fqid_rx_def) { + if (fif->is_shared_mac && + fmc->scheme[idx].override_storage_profile && + fmc->scheme[idx].storage_profile.direct && + fmc->scheme[idx].storage_profile + .profile_select.direct_relative_profile_id != + fif->base_profile_id) { + DPAA_PMD_ERR("Def RXQ must be associated with def VSP on sharemac!"); + + return -1; + } + continue; + } + + if (fif->is_shared_mac && + !fmc->scheme[idx].override_storage_profile) { + DPAA_PMD_ERR("RXQ to DPDK must be associated with VSP on sharemac!"); + return -1; + } + + if (fif->is_shared_mac && + fmc->scheme[idx].override_storage_profile && + fmc->scheme[idx].storage_profile.direct && + fmc->scheme[idx].storage_profile + .profile_select.direct_relative_profile_id == + fif->base_profile_id) { + DPAA_PMD_ERR("RXQ can't be associated with default VSP on sharemac!"); + + return -1; + } + + if ((*rxq_idx) >= max_nb_rxq) { + DPAA_PMD_DEBUG("Too many queues in FMC policy" + "%d overflow %d", + (*rxq_idx), max_nb_rxq); + + continue; + } + + for (k = 0; k < (*rxq_idx); k++) { + if (fqids[k] == fqid) { + found = 1; + break; + } + } + + if (found) + continue; + fqids[(*rxq_idx)] = fqid; + if (fmc->scheme[idx].override_storage_profile) { + if (fmc->scheme[idx].storage_profile.direct) { + vspids[(*rxq_idx)] = + fmc->scheme[idx].storage_profile + .profile_select + .direct_relative_profile_id; + } else { + vspids[(*rxq_idx)] = -1; + } + } else { + vspids[(*rxq_idx)] = -1; + } + (*rxq_idx)++; + } + } + + return 0; +} + +static int dpaa_port_fmc_ccnode_parse(struct fman_if *fif, + const struct fmc_model_t *fmc_model, + int apply_idx, + uint16_t *rxq_idx, int max_nb_rxq, + uint32_t *fqids, int8_t *vspids) +{ + uint16_t j, k, found = 0; + const struct ioc_keys_params_t *keys_params; + uint32_t fqid, cc_idx = fmc_model->apply_order[apply_idx].index; + + keys_params = &fmc_model->ccnode[cc_idx].keys_params; + + if ((*rxq_idx) >= max_nb_rxq) { + DPAA_PMD_WARN("Too many queues in FMC policy %d overflow %d", + (*rxq_idx), max_nb_rxq); + + return 0; + } + + for (j = 0; j < keys_params->num_of_keys; ++j) { + found = 0; + fqid = keys_params->key_params[j].cc_next_engine_params + .params.enqueue_params.new_fqid; + + if (keys_params->key_params[j].cc_next_engine_params + .next_engine != e_IOC_FM_PCD_DONE) { + DPAA_PMD_WARN("FMC CC next engine not support"); + continue; + } + if (keys_params->key_params[j].cc_next_engine_params + .params.enqueue_params.action != + e_IOC_FM_PCD_ENQ_FRAME) + continue; + for (k = 0; k < (*rxq_idx); k++) { + if (fqids[k] == fqid) { + found = 1; + break; + } + } + if (found) + continue; + + if ((*rxq_idx) >= max_nb_rxq) { + DPAA_PMD_WARN("Too many queues in FMC policy %d overflow %d", + (*rxq_idx), max_nb_rxq); + + return 0; + } + + fqids[(*rxq_idx)] = fqid; + vspids[(*rxq_idx)] = + keys_params->key_params[j].cc_next_engine_params + .params.enqueue_params + .new_relative_storage_profile_id; + + if (vspids[(*rxq_idx)] == fif->base_profile_id && + fif->is_shared_mac) { + DPAA_PMD_ERR("VSP %d can NOT be used on DPDK.", + vspids[(*rxq_idx)]); + DPAA_PMD_ERR("It is associated to skb pool of shared interface."); + return -1; + } + (*rxq_idx)++; + } + + return 0; +} + +int dpaa_port_fmc_init(struct fman_if *fif, + uint32_t *fqids, int8_t *vspids, int max_nb_rxq) +{ + int current_port = -1, ret; + uint16_t rxq_idx = 0; + const struct fmc_model_t *fmc_model; + uint32_t i; + + if (!g_fmc_model) { + size_t bytes_read; + FILE *fp = fopen(FMC_FILE, "rb"); + + if (!fp) { + DPAA_PMD_ERR("%s not exists", FMC_FILE); + return -1; + } + + g_fmc_model = rte_malloc(NULL, sizeof(struct fmc_model_t), 64); + if (!g_fmc_model) { + DPAA_PMD_ERR("FMC memory alloc failed"); + fclose(fp); + return -1; + } + + bytes_read = fread(g_fmc_model, + sizeof(struct fmc_model_t), 1, fp); + if (!bytes_read) { + DPAA_PMD_ERR("No bytes read"); + fclose(fp); + rte_free(g_fmc_model); + g_fmc_model = NULL; + return -1; + } + fclose(fp); + } + + fmc_model = g_fmc_model; + + if (fmc_model->format_version != FMC_OUTPUT_FORMAT_VER) + return -1; + + for (i = 0; i < fmc_model->apply_order_count; i++) { + switch (fmc_model->apply_order[i].type) { + case fmcengine_start: + break; + case fmcengine_end: + break; + case fmcport_start: + current_port = dpaa_port_fmc_port_parse(fif, + fmc_model, i); + break; + case fmcport_end: + break; + case fmcscheme: + if (current_port < 0) + break; + + ret = dpaa_port_fmc_scheme_parse(fif, fmc_model, + i, &rxq_idx, + max_nb_rxq, + fqids, vspids); + if (ret) + return ret; + + break; + case fmcccnode: + if (current_port < 0) + break; + + ret = dpaa_port_fmc_ccnode_parse(fif, fmc_model, + i, &rxq_idx, + max_nb_rxq, fqids, + vspids); + if (ret) + return ret; + + break; + case fmchtnode: + break; + case fmcreplicator: + break; + case fmccctree: + break; + case fmcpolicer: + break; + case fmcmanipulation: + break; + default: + break; + } + } + + return rxq_idx; +} diff --git a/drivers/net/dpaa/meson.build b/drivers/net/dpaa/meson.build index 51f1f32a1..c00dba6f6 100644 --- a/drivers/net/dpaa/meson.build +++ b/drivers/net/dpaa/meson.build @@ -11,7 +11,8 @@ sources = files('dpaa_ethdev.c', 'fmlib/fm_lib.c', 'fmlib/fm_vsp.c', 'dpaa_flow.c', - 'dpaa_rxtx.c') + 'dpaa_rxtx.c', + 'dpaa_fmc.c') if cc.has_argument('-Wno-pointer-arith') cflags += '-Wno-pointer-arith' From patchwork Tue Sep 1 12:36:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hemant Agrawal X-Patchwork-Id: 248858 Delivered-To: patch@linaro.org Received: by 2002:a92:5b9c:0:0:0:0:0 with SMTP id c28csp4196305ilg; Tue, 1 Sep 2020 05:44:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxPZWf1hFag0EPrazGBwKA6hWxCvy97myNiRPfaZxLwCPupjxUP3eP+4g0smgmONar1WDM+ X-Received: by 2002:a17:906:15c2:: with SMTP id l2mr1277776ejd.112.1598964278034; Tue, 01 Sep 2020 05:44:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598964278; cv=none; d=google.com; s=arc-20160816; b=kMm44dJ33Yzx8VHixIOA/Rnlwfvr9bpp8EpVeevn7/FzHvvjGsriPx2EGZg4ZU19p8 Zy+VSPJOCqErj+4PvWKtZ85M4A5zHqsHwBx4ARVQYfsAlhgmm40oMtg0d3Xh6n6biMad hqNtnGSU1JrBAH+UdrNsEwUfKu+WTAQm+BUexitZNrPDYzmO7/yjzeqT39V5gOB+VZiI C2ZnakEmwyx1cyQkTAYTX+dwVaJGtfnaBpINw8tisF1nqDp6QP1ErhCJLYVgbZbN7kKk d5m7nNRNmXiieSq27vzNp+ZqlWRckMVPI15dQOAQUe9zQRuvbzd/ouROwBl0OsZfufxD bR2w== 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=3KuIgF7p9xrINzK4UNObIp5KmRTubIg1xh0J83GVla4=; b=iQwdDgiUP1AoQhXadvSB4df2Hu3JWynAEL8C+fal4jlpzrVSlWL0m59TKDxnTluwnd 858rJpeXOAYy8K59AQADXSbRjRNNvS70Hj57EApzsP14SMFrwg5doMIE3Va0MDPj+WfQ g0E9xT6oxhZZkrgpghLji5d7qhKch1HrZdJ/Zb90IJD5nkrxRdLO/UCy4v5tZLLU8Ft1 GCq1QKxsV+GNgFC6jdU3fMGOWLSpjjxezqZWyzDOo39DIO2zwUVt0z76zN097UDUcr8O gI68TBBj5AochBaYb511pu0+x9aozILDbs+Nx0E+GaDoYAeEhLPESSFMxy7j8uRrb5ib Z8Bw== 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 u22si518675eja.418.2020.09.01.05.44.37; Tue, 01 Sep 2020 05:44:38 -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 EC8EB1C1D2; Tue, 1 Sep 2020 14:43:10 +0200 (CEST) Received: from inva020.nxp.com (inva020.nxp.com [92.121.34.13]) by dpdk.org (Postfix) with ESMTP id EAFD21C1AE for ; Tue, 1 Sep 2020 14:43:02 +0200 (CEST) Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id CBD801A0062; Tue, 1 Sep 2020 14:43:02 +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 86EB61A0575; Tue, 1 Sep 2020 14:43:01 +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 E2EBA402EB; Tue, 1 Sep 2020 14:42:58 +0200 (CEST) From: Hemant Agrawal To: dev@dpdk.org Cc: ferruh.yigit@intel.com Date: Tue, 1 Sep 2020 18:06:50 +0530 Message-Id: <20200901123650.29908-8-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200901123650.29908-1-hemant.agrawal@nxp.com> References: <20200813180121.19480-1-hemant.agrawal@nxp.com> <20200901123650.29908-1-hemant.agrawal@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Subject: [dpdk-dev] [PATCH v6 8/8] net/dpaa: add RSS update func with FMCless 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: Sachin Saxena With fmlib (FMCLESS) mode now RSS can be modified on runtime. This patch add support for RSS update functions Signed-off-by: Hemant Agrawal Signed-off-by: Sachin Saxena --- drivers/net/dpaa/dpaa_ethdev.c | 37 ++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) -- 2.17.1 diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c index 0ce2f5ae3..b0f2023e6 100644 --- a/drivers/net/dpaa/dpaa_ethdev.c +++ b/drivers/net/dpaa/dpaa_ethdev.c @@ -1303,6 +1303,41 @@ dpaa_dev_set_mac_addr(struct rte_eth_dev *dev, return ret; } +static int +dpaa_dev_rss_hash_update(struct rte_eth_dev *dev, + struct rte_eth_rss_conf *rss_conf) +{ + struct rte_eth_dev_data *data = dev->data; + struct rte_eth_conf *eth_conf = &data->dev_conf; + + PMD_INIT_FUNC_TRACE(); + + if (!(default_q || fmc_q)) { + if (dpaa_fm_config(dev, rss_conf->rss_hf)) { + DPAA_PMD_ERR("FM port configuration: Failed\n"); + return -1; + } + eth_conf->rx_adv_conf.rss_conf.rss_hf = rss_conf->rss_hf; + } else { + DPAA_PMD_ERR("Function not supported\n"); + return -ENOTSUP; + } + return 0; +} + +static int +dpaa_dev_rss_hash_conf_get(struct rte_eth_dev *dev, + struct rte_eth_rss_conf *rss_conf) +{ + struct rte_eth_dev_data *data = dev->data; + struct rte_eth_conf *eth_conf = &data->dev_conf; + + /* dpaa does not support rss_key, so length should be 0*/ + rss_conf->rss_key_len = 0; + rss_conf->rss_hf = eth_conf->rx_adv_conf.rss_conf.rss_hf; + return 0; +} + static int dpaa_dev_queue_intr_enable(struct rte_eth_dev *dev, uint16_t queue_id) { @@ -1418,6 +1453,8 @@ static struct eth_dev_ops dpaa_devops = { .rx_queue_intr_enable = dpaa_dev_queue_intr_enable, .rx_queue_intr_disable = dpaa_dev_queue_intr_disable, + .rss_hash_update = dpaa_dev_rss_hash_update, + .rss_hash_conf_get = dpaa_dev_rss_hash_conf_get, }; static bool