From mboxrd@z Thu Jan 1 00:00:00 1970 From: Hemant Agrawal Subject: [PATCH 16/20] net/dpaa2: add API to support custom hash key Date: Thu, 27 Dec 2018 06:23:15 +0000 Message-ID: <20181227062233.30781-17-hemant.agrawal@nxp.com> References: <20181227062233.30781-1-hemant.agrawal@nxp.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Cc: "ferruh.yigit@intel.com" , Shreyansh Jain , Nipun Gupta To: "dev@dpdk.org" Return-path: Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-eopbgr140042.outbound.protection.outlook.com [40.107.14.42]) by dpdk.org (Postfix) with ESMTP id F2FB65A4A for ; Thu, 27 Dec 2018 07:23:16 +0100 (CET) In-Reply-To: <20181227062233.30781-1-hemant.agrawal@nxp.com> Content-Language: en-US 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: Nipun Gupta The DPAA2 hw can support a special offset based configuration to program distribution on hash. This is for all cases, which are not directly supported. e.g. HASH based distribution on inner ip header of a GRE tunnel. Signed-off-by: Nipun Gupta --- drivers/net/dpaa2/base/dpaa2_hw_dpni.c | 52 ++++++++++++++++++++- drivers/net/dpaa2/rte_pmd_dpaa2.h | 28 +++++++++++ drivers/net/dpaa2/rte_pmd_dpaa2_version.map | 1 + 3 files changed, 80 insertions(+), 1 deletion(-) diff --git a/drivers/net/dpaa2/base/dpaa2_hw_dpni.c b/drivers/net/dpaa2/bas= e/dpaa2_hw_dpni.c index a6f86df8c..11f14931e 100644 --- a/drivers/net/dpaa2/base/dpaa2_hw_dpni.c +++ b/drivers/net/dpaa2/base/dpaa2_hw_dpni.c @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 2016 Freescale Semiconductor, Inc. All rights reserved. - * Copyright 2016 NXP + * Copyright 2016-2018 NXP * */ =20 @@ -28,6 +28,56 @@ dpaa2_distset_to_dpkg_profile_cfg( uint64_t req_dist_set, struct dpkg_profile_cfg *kg_cfg); =20 +int +rte_pmd_dpaa2_set_custom_hash(uint16_t port_id, + uint16_t offset, + uint8_t size) +{ + struct rte_eth_dev *eth_dev =3D &rte_eth_devices[port_id]; + struct dpaa2_dev_priv *priv =3D eth_dev->data->dev_private; + struct fsl_mc_io *dpni =3D priv->hw; + struct dpni_rx_tc_dist_cfg tc_cfg; + struct dpkg_profile_cfg kg_cfg; + void *p_params; + int ret, tc_index =3D 0; + + p_params =3D rte_zmalloc( + NULL, DIST_PARAM_IOVA_SIZE, RTE_CACHE_LINE_SIZE); + if (!p_params) { + DPAA2_PMD_ERR("Unable to allocate flow-dist parameters"); + return -ENOMEM; + } + + kg_cfg.extracts[0].type =3D DPKG_EXTRACT_FROM_DATA; + kg_cfg.extracts[0].extract.from_data.offset =3D offset; + kg_cfg.extracts[0].extract.from_data.size =3D size; + kg_cfg.num_extracts =3D 1; + + ret =3D dpkg_prepare_key_cfg(&kg_cfg, p_params); + if (ret) { + DPAA2_PMD_ERR("Unable to prepare extract parameters"); + rte_free(p_params); + return ret; + } + + memset(&tc_cfg, 0, sizeof(struct dpni_rx_tc_dist_cfg)); + tc_cfg.key_cfg_iova =3D (size_t)(DPAA2_VADDR_TO_IOVA(p_params)); + tc_cfg.dist_size =3D eth_dev->data->nb_rx_queues; + tc_cfg.dist_mode =3D DPNI_DIST_MODE_HASH; + + ret =3D dpni_set_rx_tc_dist(dpni, CMD_PRI_LOW, priv->token, tc_index, + &tc_cfg); + rte_free(p_params); + if (ret) { + DPAA2_PMD_ERR( + "Setting distribution for Rx failed with err: %d", + ret); + return ret; + } + + return 0; +} + int dpaa2_setup_flow_dist(struct rte_eth_dev *eth_dev, uint64_t req_dist_set) diff --git a/drivers/net/dpaa2/rte_pmd_dpaa2.h b/drivers/net/dpaa2/rte_pmd_= dpaa2.h index 57de27f21..7052d9da9 100644 --- a/drivers/net/dpaa2/rte_pmd_dpaa2.h +++ b/drivers/net/dpaa2/rte_pmd_dpaa2.h @@ -59,4 +59,32 @@ rte_pmd_dpaa2_mux_flow_create(uint32_t dpdmux_id, struct rte_flow_item *pattern[], struct rte_flow_action *actions[]); =20 +/** + * @warning + * @b EXPERIMENTAL: this API may change, or be removed, without prior noti= ce + * + * Create a custom hash key on basis of offset of start of packet and size= . + * for e.g. if we need GRE packets (non-vlan and without any extra headers= ) + * to be hashed on basis of inner IP header, we will provide offset as: + * 14 (eth) + 20 (IP) + 4 (GRE) + 12 (Inner Src offset) =3D 50 and size + * as 8 bytes. + * + * @param port_id + * The port identifier of the Ethernet device. + * @param offset + * Offset from the start of packet which needs to be included to + * calculate hash + * @param size + * Size of the hash input key + * + * @return + * - 0 if successful. + * - Negative in case of failure. + */ +__rte_experimental +int +rte_pmd_dpaa2_set_custom_hash(uint16_t port_id, + uint16_t offset, + uint8_t size); + #endif /* _RTE_PMD_DPAA2_H */ diff --git a/drivers/net/dpaa2/rte_pmd_dpaa2_version.map b/drivers/net/dpaa= 2/rte_pmd_dpaa2_version.map index 1661c5fb5..d1b4cdb23 100644 --- a/drivers/net/dpaa2/rte_pmd_dpaa2_version.map +++ b/drivers/net/dpaa2/rte_pmd_dpaa2_version.map @@ -15,5 +15,6 @@ EXPERIMENTAL { global: =20 rte_pmd_dpaa2_mux_flow_create; + rte_pmd_dpaa2_set_custom_hash; rte_pmd_dpaa2_set_timestamp; } DPDK_17.11; --=20 2.17.1