From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 41117A054F for ; Tue, 16 Mar 2021 16:00:02 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 270E226006A; Tue, 16 Mar 2021 16:00:02 +0100 (CET) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by mails.dpdk.org (Postfix) with ESMTP id 3FF5326005B; Tue, 16 Mar 2021 16:00:00 +0100 (CET) IronPort-SDR: peku4PwNOmqJzdsPsonfQ4iSzkr56sg4PEi7gGXXNI/7D8wFBI47tAhDvVvu39pKZQ5QLoZXzo r2pVCq8myTtA== X-IronPort-AV: E=McAfee;i="6000,8403,9924"; a="250636593" X-IronPort-AV: E=Sophos;i="5.81,251,1610438400"; d="scan'208";a="250636593" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Mar 2021 07:59:57 -0700 IronPort-SDR: 4b70fjjDjimXLXNppEIpBmyuC/GxdcfzeH352b5kmyYHv1YbTI1BpclSdtGGZT3tOJkCO7PQR1 993XYBElhT6g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,251,1610438400"; d="scan'208";a="411079636" Received: from silpixa00400573.ir.intel.com (HELO silpixa00400573.ger.corp.intel.com) ([10.237.223.107]) by orsmga007.jf.intel.com with ESMTP; 16 Mar 2021 07:59:56 -0700 From: Cristian Dumitrescu To: dev@dpdk.org Cc: stable@dpdk.org, Churchill Khangar Date: Tue, 16 Mar 2021 14:59:55 +0000 Message-Id: <20210316145955.54965-1-cristian.dumitrescu@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [dpdk-stable] [PATCH] table: fix actions with different data size X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" The table layer provisions an action_id and action_data_size data bytes for each table key. This action_data_size is a maximal amount, as some actions (depending on action_id) can require zero or less data bytes than the maximal action_data_size. This fix allows for actions with different data sizes to co-exist within the same table. Fixes: d0a00966618b ("table: add exact match SWX table") Cc: stable@dpdk.org Signed-off-by: Churchill Khangar Acked-by: Cristian Dumitrescu --- lib/librte_table/rte_swx_table_em.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/librte_table/rte_swx_table_em.c b/lib/librte_table/rte_swx_table_em.c index 5f6722306..6886a82ba 100644 --- a/lib/librte_table/rte_swx_table_em.c +++ b/lib/librte_table/rte_swx_table_em.c @@ -337,7 +337,7 @@ bkt_key_install(struct table *t, /* Key data. */ bkt_data = table_key_data(t, bkt_key_id); bkt_data[0] = input->action_id; - if (t->params.action_data_size) + if (t->params.action_data_size && input->action_data) memcpy(&bkt_data[1], input->action_data, t->params.action_data_size); @@ -358,7 +358,7 @@ bkt_key_data_update(struct table *t, /* Key data. */ bkt_data = table_key_data(t, bkt_key_id); bkt_data[0] = input->action_id; - if (t->params.action_data_size) + if (t->params.action_data_size && input->action_data) memcpy(&bkt_data[1], input->action_data, t->params.action_data_size); @@ -485,8 +485,7 @@ table_add(void *table, struct rte_swx_table_entry *entry) CHECK(t, EINVAL); CHECK(entry, EINVAL); CHECK(entry->key, EINVAL); - CHECK((!t->params.action_data_size && !entry->action_data) || - (t->params.action_data_size && entry->action_data), EINVAL); + CHECK(!entry->action_data || t->params.action_data_size, EINVAL); input_sig = hash(entry->key, t->key_mask, t->key_size, 0); bkt_id = input_sig & (t->n_buckets - 1); -- 2.17.1