X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fnet%2Fdpaa2%2Fbase%2Fdpaa2_hw_dpni.c;h=b901b4342ffb562ef4374a85487866d9c95c3f30;hb=a1756feeecd740d2beddfc0da92b5df6a9d0b06b;hp=1269dd2a23a7b4b8c59a5f2ddfeae290129cacfc;hpb=16bbc98a3e6305766c79fb42e55ca05b323d6e4d;p=dpdk.git diff --git a/drivers/net/dpaa2/base/dpaa2_hw_dpni.c b/drivers/net/dpaa2/base/dpaa2_hw_dpni.c index 1269dd2a23..b901b4342f 100644 --- a/drivers/net/dpaa2/base/dpaa2_hw_dpni.c +++ b/drivers/net/dpaa2/base/dpaa2_hw_dpni.c @@ -1,41 +1,15 @@ -/*- - * BSD LICENSE +/* SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 2016 Freescale Semiconductor, Inc. All rights reserved. - * Copyright 2016 NXP. + * Copyright 2016-2021 NXP * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Freescale Semiconductor, Inc nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include #include -#include +#include #include #include #include @@ -43,21 +17,23 @@ #include #include -#include +#include #include #include #include "../dpaa2_ethdev.h" -static void +int dpaa2_distset_to_dpkg_profile_cfg( - uint32_t req_dist_set, + uint64_t req_dist_set, struct dpkg_profile_cfg *kg_cfg); int -dpaa2_setup_flow_dist(struct rte_eth_dev *eth_dev, - uint32_t req_dist_set) +rte_pmd_dpaa2_set_custom_hash(uint16_t port_id, + uint16_t offset, + uint8_t size) { + struct rte_eth_dev *eth_dev = &rte_eth_devices[port_id]; struct dpaa2_dev_priv *priv = eth_dev->data->dev_private; struct fsl_mc_io *dpni = priv->hw; struct dpni_rx_tc_dist_cfg tc_cfg; @@ -65,34 +41,105 @@ dpaa2_setup_flow_dist(struct rte_eth_dev *eth_dev, void *p_params; int ret, tc_index = 0; + p_params = 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 = DPKG_EXTRACT_FROM_DATA; + kg_cfg.extracts[0].extract.from_data.offset = offset; + kg_cfg.extracts[0].extract.from_data.size = size; + kg_cfg.extracts[0].num_of_byte_masks = 0; + kg_cfg.num_extracts = 1; + + ret = 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 = (size_t)(DPAA2_VADDR_TO_IOVA(p_params)); + tc_cfg.dist_size = eth_dev->data->nb_rx_queues; + tc_cfg.dist_mode = DPNI_DIST_MODE_HASH; + + ret = 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, int tc_index) +{ + struct dpaa2_dev_priv *priv = eth_dev->data->dev_private; + struct fsl_mc_io *dpni = priv->hw; + struct dpni_rx_dist_cfg tc_cfg; + struct dpkg_profile_cfg kg_cfg; + void *p_params; + int ret, tc_dist_queues; + + /*TC distribution size is set with dist_queues or + * nb_rx_queues % dist_queues in order of TC priority index. + * Calculating dist size for this tc_index:- + */ + tc_dist_queues = eth_dev->data->nb_rx_queues - + tc_index * priv->dist_queues; + if (tc_dist_queues <= 0) { + DPAA2_PMD_INFO("No distribution on TC%d", tc_index); + return 0; + } + + if (tc_dist_queues > priv->dist_queues) + tc_dist_queues = priv->dist_queues; + p_params = rte_malloc( NULL, DIST_PARAM_IOVA_SIZE, RTE_CACHE_LINE_SIZE); if (!p_params) { - RTE_LOG(ERR, PMD, "Memory unavaialble\n"); + DPAA2_PMD_ERR("Unable to allocate flow-dist parameters"); return -ENOMEM; } + memset(p_params, 0, DIST_PARAM_IOVA_SIZE); - memset(&tc_cfg, 0, sizeof(struct dpni_rx_tc_dist_cfg)); + memset(&tc_cfg, 0, sizeof(struct dpni_rx_dist_cfg)); + + ret = dpaa2_distset_to_dpkg_profile_cfg(req_dist_set, &kg_cfg); + if (ret) { + DPAA2_PMD_ERR("Given RSS Hash (%" PRIx64 ") not supported", + req_dist_set); + rte_free(p_params); + return ret; + } - dpaa2_distset_to_dpkg_profile_cfg(req_dist_set, &kg_cfg); tc_cfg.key_cfg_iova = (uint64_t)(DPAA2_VADDR_TO_IOVA(p_params)); - tc_cfg.dist_size = eth_dev->data->nb_rx_queues; - tc_cfg.dist_mode = DPNI_DIST_MODE_HASH; + tc_cfg.dist_size = tc_dist_queues; + tc_cfg.enable = true; + tc_cfg.tc = tc_index; ret = dpkg_prepare_key_cfg(&kg_cfg, p_params); if (ret) { - RTE_LOG(ERR, PMD, "Unable to prepare extract parameters\n"); + DPAA2_PMD_ERR("Unable to prepare extract parameters"); rte_free(p_params); return ret; } - ret = dpni_set_rx_tc_dist(dpni, CMD_PRI_LOW, priv->token, tc_index, - &tc_cfg); + ret = dpni_set_rx_hash_dist(dpni, CMD_PRI_LOW, priv->token, &tc_cfg); rte_free(p_params); if (ret) { - RTE_LOG(ERR, PMD, - "Setting distribution for Rx failed with err: %d\n", - ret); + DPAA2_PMD_ERR( + "Setting distribution for Rx failed with err: %d", + ret); return ret; } @@ -105,7 +152,7 @@ int dpaa2_remove_flow_dist( { struct dpaa2_dev_priv *priv = eth_dev->data->dev_private; struct fsl_mc_io *dpni = priv->hw; - struct dpni_rx_tc_dist_cfg tc_cfg; + struct dpni_rx_dist_cfg tc_cfg; struct dpkg_profile_cfg kg_cfg; void *p_params; int ret; @@ -113,46 +160,50 @@ int dpaa2_remove_flow_dist( p_params = rte_malloc( NULL, DIST_PARAM_IOVA_SIZE, RTE_CACHE_LINE_SIZE); if (!p_params) { - RTE_LOG(ERR, PMD, "Memory unavaialble\n"); + DPAA2_PMD_ERR("Unable to allocate flow-dist parameters"); return -ENOMEM; } - memset(p_params, 0, DIST_PARAM_IOVA_SIZE); - memset(&tc_cfg, 0, sizeof(struct dpni_rx_tc_dist_cfg)); - kg_cfg.num_extracts = 0; - tc_cfg.key_cfg_iova = (uint64_t)(DPAA2_VADDR_TO_IOVA(p_params)); + + memset(&tc_cfg, 0, sizeof(struct dpni_rx_dist_cfg)); tc_cfg.dist_size = 0; - tc_cfg.dist_mode = DPNI_DIST_MODE_NONE; + tc_cfg.key_cfg_iova = (uint64_t)(DPAA2_VADDR_TO_IOVA(p_params)); + tc_cfg.enable = true; + tc_cfg.tc = tc_index; + memset(p_params, 0, DIST_PARAM_IOVA_SIZE); + kg_cfg.num_extracts = 0; ret = dpkg_prepare_key_cfg(&kg_cfg, p_params); if (ret) { - RTE_LOG(ERR, PMD, "Unable to prepare extract parameters\n"); + DPAA2_PMD_ERR("Unable to prepare extract parameters"); rte_free(p_params); return ret; } - ret = dpni_set_rx_tc_dist(dpni, CMD_PRI_LOW, priv->token, tc_index, - &tc_cfg); + ret = dpni_set_rx_hash_dist(dpni, CMD_PRI_LOW, priv->token, + &tc_cfg); rte_free(p_params); if (ret) - RTE_LOG(ERR, PMD, - "Setting distribution for Rx failed with err: %d\n", - ret); + DPAA2_PMD_ERR( + "Setting distribution for Rx failed with err: %d", + ret); return ret; } -static void +int dpaa2_distset_to_dpkg_profile_cfg( - uint32_t req_dist_set, + uint64_t req_dist_set, struct dpkg_profile_cfg *kg_cfg) { - uint32_t loop = 0, i = 0, dist_field = 0; + uint32_t loop = 0, i = 0; + uint64_t dist_field = 0; int l2_configured = 0, l3_configured = 0; int l4_configured = 0, sctp_configured = 0; + int mpls_configured = 0; memset(kg_cfg, 0, sizeof(struct dpkg_profile_cfg)); while (req_dist_set) { if (req_dist_set % 2 != 0) { - dist_field = 1U << loop; + dist_field = 1ULL << loop; switch (dist_field) { case ETH_RSS_L2_PAYLOAD: @@ -171,6 +222,43 @@ dpaa2_distset_to_dpkg_profile_cfg( i++; break; + case ETH_RSS_MPLS: + + if (mpls_configured) + break; + mpls_configured = 1; + + kg_cfg->extracts[i].extract.from_hdr.prot = + NET_PROT_MPLS; + kg_cfg->extracts[i].extract.from_hdr.field = + NH_FLD_MPLS_MPLSL_1; + kg_cfg->extracts[i].type = + DPKG_EXTRACT_FROM_HDR; + kg_cfg->extracts[i].extract.from_hdr.type = + DPKG_FULL_FIELD; + i++; + + kg_cfg->extracts[i].extract.from_hdr.prot = + NET_PROT_MPLS; + kg_cfg->extracts[i].extract.from_hdr.field = + NH_FLD_MPLS_MPLSL_2; + kg_cfg->extracts[i].type = + DPKG_EXTRACT_FROM_HDR; + kg_cfg->extracts[i].extract.from_hdr.type = + DPKG_FULL_FIELD; + i++; + + kg_cfg->extracts[i].extract.from_hdr.prot = + NET_PROT_MPLS; + kg_cfg->extracts[i].extract.from_hdr.field = + NH_FLD_MPLS_MPLSL_N; + kg_cfg->extracts[i].type = + DPKG_EXTRACT_FROM_HDR; + kg_cfg->extracts[i].extract.from_hdr.type = + DPKG_FULL_FIELD; + i++; + break; + case ETH_RSS_IPV4: case ETH_RSS_FRAG_IPV4: case ETH_RSS_NONFRAG_IPV4_OTHER: @@ -276,14 +364,17 @@ dpaa2_distset_to_dpkg_profile_cfg( break; default: - PMD_DRV_LOG(WARNING, "Bad flow distribution" - " option %x\n", dist_field); + DPAA2_PMD_WARN( + "unsupported flow dist option 0x%" PRIx64, + dist_field); + return -EINVAL; } } req_dist_set = req_dist_set >> 1; loop++; } kg_cfg->num_extracts = i; + return 0; } int @@ -313,8 +404,10 @@ dpaa2_attach_bp_list(struct dpaa2_dev_priv *priv, DPNI_BUF_LAYOUT_OPT_FRAME_STATUS | DPNI_BUF_LAYOUT_OPT_PARSER_RESULT | DPNI_BUF_LAYOUT_OPT_DATA_ALIGN | + DPNI_BUF_LAYOUT_OPT_TIMESTAMP | DPNI_BUF_LAYOUT_OPT_PRIVATE_DATA_SIZE; + layout.pass_timestamp = true; layout.pass_frame_status = 1; layout.private_data_size = DPAA2_FD_PTA_SIZE; layout.pass_parser_result = 1; @@ -324,12 +417,13 @@ dpaa2_attach_bp_list(struct dpaa2_dev_priv *priv, retcode = dpni_set_buffer_layout(dpni, CMD_PRI_LOW, priv->token, DPNI_QUEUE_RX, &layout); if (retcode) { - PMD_INIT_LOG(ERR, "Err(%d) in setting rx buffer layout\n", + DPAA2_PMD_ERR("Error configuring buffer pool Rx layout (%d)", retcode); return retcode; } /*Attach buffer pool to the network interface as described by the user*/ + memset(&bpool_cfg, 0, sizeof(struct dpni_pools_cfg)); bpool_cfg.num_dpbp = 1; bpool_cfg.pools[0].dpbp_id = bp_list->buf_pool.dpbp_node->dpbp_id; bpool_cfg.pools[0].backup_pool = 0; @@ -339,9 +433,9 @@ dpaa2_attach_bp_list(struct dpaa2_dev_priv *priv, retcode = dpni_set_pools(dpni, CMD_PRI_LOW, priv->token, &bpool_cfg); if (retcode != 0) { - PMD_INIT_LOG(ERR, "Error in attaching the buffer pool list" - " bpid = %d Error code = %d\n", - bpool_cfg.pools[0].dpbp_id, retcode); + DPAA2_PMD_ERR("Error configuring buffer pool on interface." + " bpid = %d error code = %d", + bpool_cfg.pools[0].dpbp_id, retcode); return retcode; }