From patchwork Wed Jan 6 10:05:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Malov X-Patchwork-Id: 86047 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (xvm-189-124.dc0.ghst.net [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8A49BA09FF; Wed, 6 Jan 2021 11:06:13 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D2DB7160935; Wed, 6 Jan 2021 11:06:12 +0100 (CET) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id 5D00016091F; Wed, 6 Jan 2021 11:06:11 +0100 (CET) Received: from localhost.localdomain (unknown [188.242.7.54]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by shelob.oktetlabs.ru (Postfix) with ESMTPSA id C958D7F523; Wed, 6 Jan 2021 13:06:10 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru C958D7F523 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=oktetlabs.ru; s=default; t=1609927570; bh=/Vpb4H1X0QkQ3JrJPTS45PXp+ILeICphEWIlByVceQQ=; h=From:To:Cc:Subject:Date; b=aeYErSMANNix9nbGkO0OEuHjQMmIlxXBnl+aU/OsnizUdPVrtChUalhFv0SxJaDxl VS0+jI/wT8BczhdJ/Od/L+v+VHIcwoVe7anwjzebgODapVtsQyqeCzmr2wDgT98eHH YE6bBnWmI45jrEsFlHEic2nzIqpF10AR2rA9nZ68= From: Ivan Malov To: dev@dpdk.org Cc: stable@dpdk.org, Andy Moreton , Andrew Rybchenko Date: Wed, 6 Jan 2021 13:05:59 +0300 Message-Id: <20210106100601.29299-1-ivan.malov@oktetlabs.ru> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 1/3] common/sfc_efx/base: fix MAE match spec validation helper 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" A particular FW version is aware of some set of match fields. Depending on FW configuration and match specification type, a known field may not necessarily be allowed to have a non-zero mask. FW communicates such restrictions via field capabilities MCDI. Newer FW may be aware of more fields. For such fields, older FW simply does not report any capabilities. A situation may occur when libefx is aware of a match field which the FW is unaware of (eg., older FW), that is, FW does not report capability status for this field. In this case, libefx must consider such field as unsupported and demand all-zeros mask for it when validating match specifications. Currently, the helper in question simply exits and reports that the specification is valid when it encounters a field with no capability status available. This is clearly wrong. Introduce the missing check to fix the problem. Fixes: 34285fd0891d ("common/sfc_efx/base: add match spec validate API") Cc: stable@dpdk.org Reviewed-by: Andy Moreton Reviewed-by: Andrew Rybchenko Signed-off-by: Ivan Malov --- drivers/common/sfc_efx/base/efx_mae.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/common/sfc_efx/base/efx_mae.c b/drivers/common/sfc_efx/base/efx_mae.c index a54d5f6e6..ef15deb10 100644 --- a/drivers/common/sfc_efx/base/efx_mae.c +++ b/drivers/common/sfc_efx/base/efx_mae.c @@ -885,8 +885,17 @@ efx_mae_match_spec_is_valid( if (m_size == 0) continue; /* Skip array gap */ - if ((unsigned int)field_cap_id >= field_ncaps) - break; + if ((unsigned int)field_cap_id >= field_ncaps) { + /* + * The FW has not reported capability status for + * this field. Make sure that its mask is zeroed. + */ + is_valid = efx_mask_is_all_zeros(m_size, m_buf); + if (is_valid != B_FALSE) + continue; + else + break; + } switch (field_caps[field_cap_id].emfc_support) { case MAE_FIELD_SUPPORTED_MATCH_MASK: From patchwork Wed Jan 6 10:06:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Malov X-Patchwork-Id: 86048 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (xvm-189-124.dc0.ghst.net [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id DC2DFA09FF; Wed, 6 Jan 2021 11:06:20 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 12E56160940; Wed, 6 Jan 2021 11:06:14 +0100 (CET) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id 8FA8716091F; Wed, 6 Jan 2021 11:06:11 +0100 (CET) Received: from localhost.localdomain (unknown [188.242.7.54]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by shelob.oktetlabs.ru (Postfix) with ESMTPSA id 2EA807F56C; Wed, 6 Jan 2021 13:06:11 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru 2EA807F56C DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=oktetlabs.ru; s=default; t=1609927571; bh=wfvqKZW9UTvV1b4ILUYVYyGRZJYU4IgWfUwPSOcJX/U=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=fo4shyOLgfIv9idgnr6LhNdh8Hb4P0ypc6QjGkPpZF5/GUO1pwiikiF3XgM6hVNiC vH6GWMBsHsfqzf81b2hARHaENQYfaDPePH0d/5zp6OcHIMFDTokpyMoefeue7hrxp7 gvBnBzvWwkbCsaX4ECx7CbDyGhjIzH8pYgxnrT0g= From: Ivan Malov To: dev@dpdk.org Cc: stable@dpdk.org, Andy Moreton , Andrew Rybchenko Date: Wed, 6 Jan 2021 13:06:00 +0300 Message-Id: <20210106100601.29299-2-ivan.malov@oktetlabs.ru> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210106100601.29299-1-ivan.malov@oktetlabs.ru> References: <20210106100601.29299-1-ivan.malov@oktetlabs.ru> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 2/3] common/sfc_efx/base: fix MAE match spec class comparison API 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 helper exits once it encounters a field which hasn't its capability status reported by the FW. Handle the corner case when the two mask-value pairs match for the field, which, in the absence of capability information, is sufficient to deem the class unaffected by the field. Explain this in a comment. Fixes: bb71f7e0a35a ("common/sfc_efx/base: add match specs class comparison API") Cc: stable@dpdk.org Reviewed-by: Andy Moreton Reviewed-by: Andrew Rybchenko Signed-off-by: Ivan Malov --- drivers/common/sfc_efx/base/efx.h | 5 ++++ drivers/common/sfc_efx/base/efx_mae.c | 34 +++++++++++++++++---------- 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/drivers/common/sfc_efx/base/efx.h b/drivers/common/sfc_efx/base/efx.h index 3b40e28b4..ccf9c7ab8 100644 --- a/drivers/common/sfc_efx/base/efx.h +++ b/drivers/common/sfc_efx/base/efx.h @@ -4283,6 +4283,11 @@ efx_mae_action_set_specs_equal( * Conduct a comparison to check whether two match specifications * of equal rule type (action / outer) and priority would map to * the very same rule class from the firmware's standpoint. + * + * For match specification fields that are not supported by firmware, + * the rule class only matches if the mask/value pairs for that field + * are equal. Clients should use efx_mae_match_spec_is_valid() before + * calling this API to detect usage of unsupported fields. */ LIBEFX_API extern __checkReturn efx_rc_t diff --git a/drivers/common/sfc_efx/base/efx_mae.c b/drivers/common/sfc_efx/base/efx_mae.c index ef15deb10..c1717d7b0 100644 --- a/drivers/common/sfc_efx/base/efx_mae.c +++ b/drivers/common/sfc_efx/base/efx_mae.c @@ -1408,18 +1408,32 @@ efx_mae_match_specs_class_cmp( ++field_id) { const efx_mae_mv_desc_t *descp = &desc_setp[field_id]; efx_mae_field_cap_id_t field_cap_id = descp->emmd_field_cap_id; - - if (descp->emmd_mask_size == 0) + const uint8_t *lmaskp = mvpl + descp->emmd_mask_offset; + const uint8_t *rmaskp = mvpr + descp->emmd_mask_offset; + size_t mask_size = descp->emmd_mask_size; + const uint8_t *lvalp = mvpl + descp->emmd_value_offset; + const uint8_t *rvalp = mvpr + descp->emmd_value_offset; + size_t value_size = descp->emmd_value_size; + + if (mask_size == 0) continue; /* Skip array gap */ - if ((unsigned int)field_cap_id >= field_ncaps) - break; + if ((unsigned int)field_cap_id >= field_ncaps) { + /* + * The FW has not reported capability status for this + * field. It's unknown whether any difference between + * the two masks / values affects the class. The only + * case when the class must be the same is when these + * mask-value pairs match. Otherwise, report mismatch. + */ + if ((memcmp(lmaskp, rmaskp, mask_size) == 0) && + (memcmp(lvalp, rvalp, value_size) == 0)) + continue; + else + break; + } if (field_caps[field_cap_id].emfc_mask_affects_class) { - const uint8_t *lmaskp = mvpl + descp->emmd_mask_offset; - const uint8_t *rmaskp = mvpr + descp->emmd_mask_offset; - size_t mask_size = descp->emmd_mask_size; - if (memcmp(lmaskp, rmaskp, mask_size) != 0) { have_same_class = B_FALSE; break; @@ -1427,10 +1441,6 @@ efx_mae_match_specs_class_cmp( } if (field_caps[field_cap_id].emfc_match_affects_class) { - const uint8_t *lvalp = mvpl + descp->emmd_value_offset; - const uint8_t *rvalp = mvpr + descp->emmd_value_offset; - size_t value_size = descp->emmd_value_size; - if (memcmp(lvalp, rvalp, value_size) != 0) { have_same_class = B_FALSE; break; From patchwork Wed Jan 6 10:06:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Malov X-Patchwork-Id: 86049 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (xvm-189-124.dc0.ghst.net [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id EC8C4A09FF; Wed, 6 Jan 2021 11:06:27 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 52F79160946; Wed, 6 Jan 2021 11:06:15 +0100 (CET) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id C681216091F; Wed, 6 Jan 2021 11:06:11 +0100 (CET) Received: from localhost.localdomain (unknown [188.242.7.54]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by shelob.oktetlabs.ru (Postfix) with ESMTPSA id 6D4147F591; Wed, 6 Jan 2021 13:06:11 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru 6D4147F591 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=oktetlabs.ru; s=default; t=1609927571; bh=dFbSSMU0Rsb3zwDWkp11Z8BWfgiu1dOhhezOUIU6IGI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=A1idcOzpm9VNmV/6fKJvpPker7WEcMRuTw97n72dCoHv5DVRHPjEgTDlqdjRbikaX Hrxjs/+LY5teUcBPOmy7PkFaU6j22r9CaDcRcNm9Zs8J7hbWZedDirNRtTumoe7W94 LMcMhwb83E8CbYfKy4KMc1gyMfwOojUbdGm8XMI0= From: Ivan Malov To: dev@dpdk.org Cc: stable@dpdk.org, Andy Moreton , Andrew Rybchenko Date: Wed, 6 Jan 2021 13:06:01 +0300 Message-Id: <20210106100601.29299-3-ivan.malov@oktetlabs.ru> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210106100601.29299-1-ivan.malov@oktetlabs.ru> References: <20210106100601.29299-1-ivan.malov@oktetlabs.ru> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 3/3] common/sfc_efx/base: enhance field ID check in field set API 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" A field ID passed to the API may point to a gap in the array of field descriptors. Turn down such invocations as improper. Fixes: 370ed675a952 ("common/sfc_efx/base: support setting PPORT in match spec") Cc: stable@dpdk.org Reviewed-by: Andy Moreton Reviewed-by: Andrew Rybchenko Signed-off-by: Ivan Malov --- drivers/common/sfc_efx/base/efx_mae.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/common/sfc_efx/base/efx_mae.c b/drivers/common/sfc_efx/base/efx_mae.c index c1717d7b0..f4a529f5a 100644 --- a/drivers/common/sfc_efx/base/efx_mae.c +++ b/drivers/common/sfc_efx/base/efx_mae.c @@ -678,16 +678,22 @@ efx_mae_match_spec_field_set( goto fail2; } - if (value_size != descp->emmd_value_size) { + if (descp->emmd_mask_size == 0) { + /* The ID points to a gap in the array of field descriptors. */ rc = EINVAL; goto fail3; } - if (mask_size != descp->emmd_mask_size) { + if (value_size != descp->emmd_value_size) { rc = EINVAL; goto fail4; } + if (mask_size != descp->emmd_mask_size) { + rc = EINVAL; + goto fail5; + } + if (descp->emmd_endianness == EFX_MAE_FIELD_BE) { /* * The mask/value are in network (big endian) order. @@ -729,6 +735,8 @@ efx_mae_match_spec_field_set( return (0); +fail5: + EFSYS_PROBE(fail5); fail4: EFSYS_PROBE(fail4); fail3: