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 ABAE9A0A04 for ; Sun, 17 Jan 2021 23:21:22 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9497E140D57; Sun, 17 Jan 2021 23:21:22 +0100 (CET) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id C0465140D34; Sun, 17 Jan 2021 23:21:20 +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 1A5667F5AD; Mon, 18 Jan 2021 01:21:20 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru 1A5667F5AD DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=oktetlabs.ru; s=default; t=1610922080; bh=gQSUP7ExV3L4VmxzCh0oW+l/NAVtyKQxW9Da1O7pPpc=; h=From:To:Cc:Subject:Date; b=YDBlgEuCXPxjMudMuob1zLbLmXLysAd48zyp/K6bWPvjqSlgZ3xRHogpsIDqlhr8e 09KPVldwIJISVgE4Cs4zFNY9BdxiGM9WgAT56J837mVjmD6Irs+2pBim9z+LdCC9IM f/GF2SQlkikSJEPYMNiRyPT4EhEBEXjNVELZO7OQ= From: Ivan Malov To: dev@dpdk.org Cc: stable@dpdk.org, Andrew Rybchenko , Andy Moreton Date: Mon, 18 Jan 2021 01:21:11 +0300 Message-Id: <20210117222112.26305-1-ivan.malov@oktetlabs.ru> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] [PATCH] common/sfc_efx/base: apply mask to value on match field set 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" An application may submit all-zeros masks for a given field to be used in two given specifications and, in the meantime, use different unmasked values. Later on, when compared, the two specifications will prove unequal, and, if the rules in question are outer, the client driver will have to allocate a separate rule for the second specification. Provided that all other match criteria are the same, the HW will deem the two outer rules being duplicates, which is in fact the case. Apply masks to values in efx_mae_match_spec_field_set() API to fix the issue and avoid duplicate outer rule allocations. Fixes: 370ed675a952 ("common/sfc_efx/base: support setting PPORT in match spec") Cc: stable@dpdk.org Reported-by: Andrew Rybchenko Signed-off-by: Ivan Malov Reviewed-by: Andrew Rybchenko Reviewed-by: Andy Moreton --- drivers/common/sfc_efx/base/efx_mae.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/drivers/common/sfc_efx/base/efx_mae.c b/drivers/common/sfc_efx/base/efx_mae.c index 22f29d454..adb06746b 100644 --- a/drivers/common/sfc_efx/base/efx_mae.c +++ b/drivers/common/sfc_efx/base/efx_mae.c @@ -701,12 +701,32 @@ efx_mae_match_spec_field_set( } if (descp->emmd_endianness == EFX_MAE_FIELD_BE) { + unsigned int i; + /* * The mask/value are in network (big endian) order. * The MCDI request field is also big endian. */ - memcpy(mvp + descp->emmd_value_offset, value, value_size); - memcpy(mvp + descp->emmd_mask_offset, mask, mask_size); + + EFSYS_ASSERT3U(value_size, ==, mask_size); + + for (i = 0; i < value_size; ++i) { + uint8_t *v_bytep = mvp + descp->emmd_value_offset + i; + uint8_t *m_bytep = mvp + descp->emmd_mask_offset + i; + + /* + * Apply the mask (which may be all-zeros) to the value. + * + * If this API is provided with some value to set for a + * given field in one specification and with some other + * value to set for this field in another specification, + * then, if the two masks are all-zeros, the field will + * avoid being counted as a mismatch when comparing the + * specifications using efx_mae_match_specs_equal() API. + */ + *v_bytep = value[i] & mask[i]; + *m_bytep = mask[i]; + } } else { efx_dword_t dword; -- 2.20.1