From patchwork Tue Jul 7 09:22:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hemant Agrawal X-Patchwork-Id: 234973 Delivered-To: patch@linaro.org Received: by 2002:a92:d244:0:0:0:0:0 with SMTP id v4csp738775ilg; Tue, 7 Jul 2020 02:31:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzTK1yKofbZJ9oQA+t9sbgYCNWwPfL9uD1gNYr6IhKziXZW0QChSOpTOxi8pm9a5aJL6Hxv X-Received: by 2002:a50:cbcd:: with SMTP id l13mr43301350edi.384.1594114277348; Tue, 07 Jul 2020 02:31:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594114277; cv=none; d=google.com; s=arc-20160816; b=vRD0qjARivmQNgkL7mQhk3NUZ51VsROrXYkX8BlJiHsKRzyUBlhfGLa2uvhPbH6HIx oG39neSyN+wCVzFDL61asvThl4y9eF6lD2xDAwnB1iNJcmdC62AGbmuZZQgGpCMiOrSl epOK77aDuR0NnNJRDii6eUGCWWFMFICcdqB4jLJ9HX7X91Fk78iT5TwSeeA7HE7pwDpl pjPgmatZR85oA5EvnqOtNYETcm5t7WE6tb1l/D7+G+Oy25ZgL+2XBEnpyif8iaWvhzur FitiOX2sTphxeVq73wfpZz+IuGaMXmVz1c0Abe4HAcyqkegoehxEafYe5rhjySWJ6jNY U7CQ== 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=W5c/TVUnXEvGvn8qQrfeokLRBXiDWWcrXhKVynGlvds=; b=nUL7O1yaZFdZ8P1rrB+yP4OYzYKHb20IZhCok3hDhW/I+Mc+mYG+8oM8ZQfklqU9Dh wUM8A7Ad35ZjQZBVdKKhiOjG4lLLawLdmizJd8rkXKk79DTL7USuF/aTCn0bhCp4N5J3 KiSv3af3wwW09T2L8a84IT3Btu8bt4sU17a6cg/QviXE/fHChX31TxG1IbHHJPkCA7Ts DFCL+7kyY2IPciIZq0oHldRIOCnjpDbJkY3fkK593hRcjmMPEwJ8qZ7DzafJS7YawgVB QuP/KPEU5He9D4lQ1koHQJozFlOymVYDjZZZyMFMxd2Il4wwDJOe2IiMQESEV6OhgFwO vzxw== 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 dp6si18531896ejc.472.2020.07.07.02.31.17; Tue, 07 Jul 2020 02:31:17 -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 B68D81DDF4; Tue, 7 Jul 2020 11:27:31 +0200 (CEST) Received: from inva021.nxp.com (inva021.nxp.com [92.121.34.21]) by dpdk.org (Postfix) with ESMTP id B2EC21DC93 for ; Tue, 7 Jul 2020 11:27:12 +0200 (CEST) Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 956F42008E9; Tue, 7 Jul 2020 11:27:12 +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 AE2EF20060D; Tue, 7 Jul 2020 11:27:10 +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 720B0402FC; Tue, 7 Jul 2020 17:27:08 +0800 (SGT) From: Hemant Agrawal To: dev@dpdk.org Cc: ferruh.yigit@intel.com, Jun Yang Date: Tue, 7 Jul 2020 14:52:35 +0530 Message-Id: <20200707092244.12791-21-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200707092244.12791-1-hemant.agrawal@nxp.com> References: <20200527132326.1382-1-hemant.agrawal@nxp.com> <20200707092244.12791-1-hemant.agrawal@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Subject: [dpdk-dev] [PATCH v2 20/29] net/dpaa2: define the size of table entry 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 If entry size is not bigger than 27, MC alloc one TCAM entry, otherwise, alloc 2 TCAM entries. Extracts size by HW must be not bigger than TCAM entry size(27 or 54). So define the flow entry size as 54. Signed-off-by: Jun Yang --- drivers/net/dpaa2/dpaa2_flow.c | 90 ++++++++++++++++++++++------------ 1 file changed, 60 insertions(+), 30 deletions(-) -- 2.17.1 diff --git a/drivers/net/dpaa2/dpaa2_flow.c b/drivers/net/dpaa2/dpaa2_flow.c index 760a8a793..bcbd5977a 100644 --- a/drivers/net/dpaa2/dpaa2_flow.c +++ b/drivers/net/dpaa2/dpaa2_flow.c @@ -29,6 +29,8 @@ */ int mc_l4_port_identification; +#define FIXED_ENTRY_SIZE 54 + enum flow_rule_ipaddr_type { FLOW_NONE_IPADDR, FLOW_IPV4_ADDR, @@ -47,7 +49,8 @@ struct rte_flow { LIST_ENTRY(rte_flow) next; /**< Pointer to the next flow structure. */ struct dpni_rule_cfg qos_rule; struct dpni_rule_cfg fs_rule; - uint8_t key_size; + uint8_t qos_real_key_size; + uint8_t fs_real_key_size; uint8_t tc_id; /** Traffic Class ID. */ uint8_t tc_index; /** index within this Traffic Class. */ enum rte_flow_action_type action; @@ -478,6 +481,7 @@ dpaa2_flow_rule_data_set( prot, field); return -1; } + memcpy((void *)(size_t)(rule->key_iova + offset), key, size); memcpy((void *)(size_t)(rule->mask_iova + offset), mask, size); @@ -523,9 +527,11 @@ _dpaa2_flow_rule_move_ipaddr_tail( len = NH_FLD_IPV6_ADDR_SIZE; memcpy(tmp, (char *)key_src, len); + memset((char *)key_src, 0, len); memcpy((char *)key_dst, tmp, len); memcpy(tmp, (char *)mask_src, len); + memset((char *)mask_src, 0, len); memcpy((char *)mask_dst, tmp, len); return 0; @@ -1251,8 +1257,7 @@ dpaa2_configure_flow_generic_ip( return -1; } - local_cfg |= (DPAA2_QOS_TABLE_RECONFIGURE | - DPAA2_QOS_TABLE_IPADDR_EXTRACT); + local_cfg |= DPAA2_QOS_TABLE_RECONFIGURE; } index = dpaa2_flow_extract_search( @@ -1269,8 +1274,7 @@ dpaa2_configure_flow_generic_ip( return -1; } - local_cfg |= (DPAA2_FS_TABLE_RECONFIGURE | - DPAA2_FS_TABLE_IPADDR_EXTRACT); + local_cfg |= DPAA2_FS_TABLE_RECONFIGURE; } if (spec_ipv4) @@ -1339,8 +1343,7 @@ dpaa2_configure_flow_generic_ip( return -1; } - local_cfg |= (DPAA2_QOS_TABLE_RECONFIGURE | - DPAA2_QOS_TABLE_IPADDR_EXTRACT); + local_cfg |= DPAA2_QOS_TABLE_RECONFIGURE; } index = dpaa2_flow_extract_search( @@ -1361,8 +1364,7 @@ dpaa2_configure_flow_generic_ip( return -1; } - local_cfg |= (DPAA2_FS_TABLE_RECONFIGURE | - DPAA2_FS_TABLE_IPADDR_EXTRACT); + local_cfg |= DPAA2_FS_TABLE_RECONFIGURE; } if (spec_ipv4) @@ -2641,7 +2643,7 @@ dpaa2_flow_entry_update( char ipdst_key[NH_FLD_IPV6_ADDR_SIZE]; char ipsrc_mask[NH_FLD_IPV6_ADDR_SIZE]; char ipdst_mask[NH_FLD_IPV6_ADDR_SIZE]; - int extend = -1, extend1, size; + int extend = -1, extend1, size = -1; uint16_t qos_index; while (curr) { @@ -2696,6 +2698,9 @@ dpaa2_flow_entry_update( else extend = extend1; + RTE_ASSERT((size == NH_FLD_IPV4_ADDR_SIZE) || + (size == NH_FLD_IPV6_ADDR_SIZE)); + memcpy(ipsrc_key, (char *)(size_t)curr->qos_rule.key_iova + curr->ipaddr_rule.qos_ipsrc_offset, @@ -2725,6 +2730,9 @@ dpaa2_flow_entry_update( else extend = extend1; + RTE_ASSERT((size == NH_FLD_IPV4_ADDR_SIZE) || + (size == NH_FLD_IPV6_ADDR_SIZE)); + memcpy(ipdst_key, (char *)(size_t)curr->qos_rule.key_iova + curr->ipaddr_rule.qos_ipdst_offset, @@ -2745,6 +2753,8 @@ dpaa2_flow_entry_update( } if (curr->ipaddr_rule.qos_ipsrc_offset >= 0) { + RTE_ASSERT((size == NH_FLD_IPV4_ADDR_SIZE) || + (size == NH_FLD_IPV6_ADDR_SIZE)); memcpy((char *)(size_t)curr->qos_rule.key_iova + curr->ipaddr_rule.qos_ipsrc_offset, ipsrc_key, @@ -2755,6 +2765,8 @@ dpaa2_flow_entry_update( size); } if (curr->ipaddr_rule.qos_ipdst_offset >= 0) { + RTE_ASSERT((size == NH_FLD_IPV4_ADDR_SIZE) || + (size == NH_FLD_IPV6_ADDR_SIZE)); memcpy((char *)(size_t)curr->qos_rule.key_iova + curr->ipaddr_rule.qos_ipdst_offset, ipdst_key, @@ -2766,7 +2778,9 @@ dpaa2_flow_entry_update( } if (extend >= 0) - curr->qos_rule.key_size += extend; + curr->qos_real_key_size += extend; + + curr->qos_rule.key_size = FIXED_ENTRY_SIZE; ret = dpni_add_qos_entry(dpni, CMD_PRI_LOW, priv->token, &curr->qos_rule, @@ -2873,7 +2887,8 @@ dpaa2_flow_entry_update( } if (extend >= 0) - curr->fs_rule.key_size += extend; + curr->fs_real_key_size += extend; + curr->fs_rule.key_size = FIXED_ENTRY_SIZE; ret = dpni_add_fs_entry(dpni, CMD_PRI_LOW, priv->token, curr->tc_id, curr->tc_index, @@ -3093,31 +3108,34 @@ dpaa2_generic_flow_set(struct rte_flow *flow, priv->qos_entries); return -1; } - flow->qos_rule.key_size = priv->extract - .qos_key_extract.key_info.key_total_size; + flow->qos_rule.key_size = FIXED_ENTRY_SIZE; if (flow->ipaddr_rule.ipaddr_type == FLOW_IPV4_ADDR) { if (flow->ipaddr_rule.qos_ipdst_offset >= flow->ipaddr_rule.qos_ipsrc_offset) { - flow->qos_rule.key_size = + flow->qos_real_key_size = flow->ipaddr_rule.qos_ipdst_offset + NH_FLD_IPV4_ADDR_SIZE; } else { - flow->qos_rule.key_size = + flow->qos_real_key_size = flow->ipaddr_rule.qos_ipsrc_offset + NH_FLD_IPV4_ADDR_SIZE; } - } else if (flow->ipaddr_rule.ipaddr_type == FLOW_IPV6_ADDR) { + } else if (flow->ipaddr_rule.ipaddr_type == + FLOW_IPV6_ADDR) { if (flow->ipaddr_rule.qos_ipdst_offset >= flow->ipaddr_rule.qos_ipsrc_offset) { - flow->qos_rule.key_size = + flow->qos_real_key_size = flow->ipaddr_rule.qos_ipdst_offset + NH_FLD_IPV6_ADDR_SIZE; } else { - flow->qos_rule.key_size = + flow->qos_real_key_size = flow->ipaddr_rule.qos_ipsrc_offset + NH_FLD_IPV6_ADDR_SIZE; } } + + flow->qos_rule.key_size = FIXED_ENTRY_SIZE; + ret = dpni_add_qos_entry(dpni, CMD_PRI_LOW, priv->token, &flow->qos_rule, flow->tc_id, qos_index, @@ -3134,17 +3152,20 @@ dpaa2_generic_flow_set(struct rte_flow *flow, priv->fs_entries); return -1; } - flow->fs_rule.key_size = priv->extract - .tc_key_extract[attr->group].key_info.key_total_size; + + flow->fs_real_key_size = + priv->extract.tc_key_extract[flow->tc_id] + .key_info.key_total_size; + if (flow->ipaddr_rule.ipaddr_type == FLOW_IPV4_ADDR) { if (flow->ipaddr_rule.fs_ipdst_offset >= flow->ipaddr_rule.fs_ipsrc_offset) { - flow->fs_rule.key_size = + flow->fs_real_key_size = flow->ipaddr_rule.fs_ipdst_offset + NH_FLD_IPV4_ADDR_SIZE; } else { - flow->fs_rule.key_size = + flow->fs_real_key_size = flow->ipaddr_rule.fs_ipsrc_offset + NH_FLD_IPV4_ADDR_SIZE; } @@ -3152,15 +3173,18 @@ dpaa2_generic_flow_set(struct rte_flow *flow, FLOW_IPV6_ADDR) { if (flow->ipaddr_rule.fs_ipdst_offset >= flow->ipaddr_rule.fs_ipsrc_offset) { - flow->fs_rule.key_size = + flow->fs_real_key_size = flow->ipaddr_rule.fs_ipdst_offset + NH_FLD_IPV6_ADDR_SIZE; } else { - flow->fs_rule.key_size = + flow->fs_real_key_size = flow->ipaddr_rule.fs_ipsrc_offset + NH_FLD_IPV6_ADDR_SIZE; } } + + flow->fs_rule.key_size = FIXED_ENTRY_SIZE; + ret = dpni_add_fs_entry(dpni, CMD_PRI_LOW, priv->token, flow->tc_id, flow->tc_index, &flow->fs_rule, &action); @@ -3259,8 +3283,10 @@ dpaa2_generic_flow_set(struct rte_flow *flow, priv->qos_entries); return -1; } - flow->qos_rule.key_size = + + flow->qos_real_key_size = priv->extract.qos_key_extract.key_info.key_total_size; + flow->qos_rule.key_size = FIXED_ENTRY_SIZE; ret = dpni_add_qos_entry(dpni, CMD_PRI_LOW, priv->token, &flow->qos_rule, flow->tc_id, qos_index, 0, 0); @@ -3283,11 +3309,15 @@ dpaa2_generic_flow_set(struct rte_flow *flow, } if (!ret) { - ret = dpaa2_flow_entry_update(priv, flow->tc_id); - if (ret) { - DPAA2_PMD_ERR("Flow entry update failed."); + if (is_keycfg_configured & + (DPAA2_QOS_TABLE_RECONFIGURE | + DPAA2_FS_TABLE_RECONFIGURE)) { + ret = dpaa2_flow_entry_update(priv, flow->tc_id); + if (ret) { + DPAA2_PMD_ERR("Flow entry update failed."); - return -1; + return -1; + } } /* New rules are inserted. */ if (!curr) {