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 5C4BBA054F; Tue, 16 Mar 2021 16:09:25 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3348526006A; Tue, 16 Mar 2021 16:09:25 +0100 (CET) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mails.dpdk.org (Postfix) with ESMTP id D00A626005B; Tue, 16 Mar 2021 16:09:23 +0100 (CET) IronPort-SDR: QQhpHZ8YcJkzuwB7sNQ2RKQVf4Kx1QuM2NTeYjXIQuVQs53YnWBr2Hg77N5aJ2C3S/oLSWqfgE tUHJL5jtw86Q== X-IronPort-AV: E=McAfee;i="6000,8403,9924"; a="253290967" X-IronPort-AV: E=Sophos;i="5.81,251,1610438400"; d="scan'208";a="253290967" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Mar 2021 08:09:11 -0700 IronPort-SDR: vsedb7aw4lHIXawpFdYdflEZz+ioc4V3cmFx8YfHUqbxV7PCvZcUshiwxQEbLzElGuElHtKVXU tgVgE0ie6j+Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,251,1610438400"; d="scan'208";a="378896423" Received: from silpixa00400573.ir.intel.com (HELO silpixa00400573.ger.corp.intel.com) ([10.237.223.107]) by fmsmga007.fm.intel.com with ESMTP; 16 Mar 2021 08:09:10 -0700 From: Cristian Dumitrescu To: dev@dpdk.org Cc: stable@dpdk.org, Churchill Khangar Date: Tue, 16 Mar 2021 15:09:09 +0000 Message-Id: <20210316150909.55045-1-cristian.dumitrescu@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [dpdk-dev] [PATCH v2] table: fix actions with different data size X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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" 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 Signed-off-by: Cristian Dumitrescu 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