From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id A82DDA04DD; Tue, 20 Oct 2020 10:56:21 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2EFA3BCE0; Tue, 20 Oct 2020 10:49:35 +0200 (CEST) Received: from dispatch1-us1.ppe-hosted.com (dispatch1-us1.ppe-hosted.com [148.163.129.52]) by dpdk.org (Postfix) with ESMTP id 4B012BBA2 for ; Tue, 20 Oct 2020 10:49:01 +0200 (CEST) Received: from mx1-us1.ppe-hosted.com (unknown [10.7.65.64]) by dispatch1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id BBFAA60081 for ; Tue, 20 Oct 2020 08:48:59 +0000 (UTC) Received: from us4-mdac16-10.ut7.mdlocal (unknown [10.7.65.180]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id BB8CC2009B for ; Tue, 20 Oct 2020 08:48:59 +0000 (UTC) X-Virus-Scanned: Proofpoint Essentials engine Received: from mx1-us1.ppe-hosted.com (unknown [10.7.66.33]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTPS id 47AEE220052 for ; Tue, 20 Oct 2020 08:48:59 +0000 (UTC) Received: from webmail.solarflare.com (uk.solarflare.com [193.34.186.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTPS id F2F19A80061 for ; Tue, 20 Oct 2020 08:48:58 +0000 (UTC) Received: from ukex01.SolarFlarecom.com (10.17.10.4) by ukex01.SolarFlarecom.com (10.17.10.4) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 20 Oct 2020 09:48:50 +0100 Received: from opal.uk.solarflarecom.com (10.17.10.1) by ukex01.SolarFlarecom.com (10.17.10.4) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 20 Oct 2020 09:48:50 +0100 Received: from ukv-loginhost.uk.solarflarecom.com (ukv-loginhost.uk.solarflarecom.com [10.17.10.39]) by opal.uk.solarflarecom.com (8.13.8/8.13.8) with ESMTP id 09K8mnWF030802; Tue, 20 Oct 2020 09:48:49 +0100 Received: from ukv-loginhost.uk.solarflarecom.com (localhost [127.0.0.1]) by ukv-loginhost.uk.solarflarecom.com (Postfix) with ESMTP id 52823161789; Tue, 20 Oct 2020 09:48:48 +0100 (BST) From: Andrew Rybchenko To: CC: , Ivan Malov Date: Tue, 20 Oct 2020 09:47:39 +0100 Message-ID: <1603183709-23420-13-git-send-email-arybchenko@solarflare.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1603183709-23420-1-git-send-email-arybchenko@solarflare.com> References: <1603183709-23420-1-git-send-email-arybchenko@solarflare.com> MIME-Version: 1.0 Content-Type: text/plain X-TM-AS-Product-Ver: SMEX-12.5.0.1300-8.6.1012-25736.003 X-TM-AS-Result: No-2.975200-8.000000-10 X-TMASE-MatchedRID: fPU3ZRMebCv5s5ZGHFKFGDQ60lWQoG0rKVrLOZD1BXQOkJQR4QWbsLBZ szSz1qeiqucwHXTsrX/cJxdWvjKQ3yiq3P159fwpqg0gbtLVIa96i696PjRPiNWO4MK8ycTFH8M UR/9vnkerO5PmBFOASkDTw9uN2GLZHVikQ9YmLLOInASnzB5VfFJAsn89ih94Bph69XjMbdlSkV 47LHGpi2b7tdoOCN42itqmw2mRWTOiwCaYPn5sJltTO+xodboGAp+UH372RZVHZg0gWH5yUdNVR hry6jgeuW0lBjgUk+dW1Uyf/vuKAOcYCqaThQZTt0cS/uxH87CWGk93C/VnSuy9vsxhLmzehnOL yflyxrMf9OAqZEL+UoAy6p60ZV62fJ5/bZ6npdiujVRFkkVsm5pFQJ/p5Nu32//BiXwu3rJ2HkB h36F2JFsU/6sZL7aV6S6RqbiHkfMf1hYTrHRVsdQGB+u1ogfeLXpd6HTgbX6DlWNaESsm5/DsnH BTQS9kyoRE4tv/7I7j/Qm+fSvAAma0vgPD7M1vmFd/HOChTo8= X-TM-AS-User-Approved-Sender: Yes X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--2.975200-8.000000 X-TMASE-Version: SMEX-12.5.0.1300-8.6.1012-25736.003 X-MDID: 1603183739-ELDCZJ3UCZLe X-PPE-DISP: 1603183739;ELDCZJ3UCZLe Subject: [dpdk-dev] [PATCH 12/62] common/sfc_efx/base: add a match specs class comparison API 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: Ivan Malov >From MAE standpoint, a flow rule belongs to some class. Field capabilities advertised by the FW provide a hint on whether changing a particular match field value or its mask will affect the class of the rule. A client driver can make use of the concept of a class by comparing a rule being validated with already inserted ones so that if an existing rule with the same class is encountered, it will become possible to skip making an explicit request to the FW because the class of an already inserted rule is wittingly valid. Implement an API for client drivers to carry out the said class comparison. Signed-off-by: Ivan Malov Signed-off-by: Andrew Rybchenko Reviewed-by: Andy Moreton --- drivers/common/sfc_efx/base/efx.h | 13 +++ drivers/common/sfc_efx/base/efx_mae.c | 96 +++++++++++++++++++ .../sfc_efx/rte_common_sfc_efx_version.map | 1 + 3 files changed, 110 insertions(+) diff --git a/drivers/common/sfc_efx/base/efx.h b/drivers/common/sfc_efx/base/efx.h index 094fad6367..c91f7948a0 100644 --- a/drivers/common/sfc_efx/base/efx.h +++ b/drivers/common/sfc_efx/base/efx.h @@ -4098,6 +4098,19 @@ efx_mae_match_spec_is_valid( __in efx_nic_t *enp, __in const efx_mae_match_spec_t *spec); +/* + * 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. + */ +LIBEFX_API +extern __checkReturn efx_rc_t +efx_mae_match_specs_class_cmp( + __in efx_nic_t *enp, + __in const efx_mae_match_spec_t *left, + __in const efx_mae_match_spec_t *right, + __out boolean_t *have_same_classp); + #endif /* EFSYS_OPT_MAE */ #ifdef __cplusplus diff --git a/drivers/common/sfc_efx/base/efx_mae.c b/drivers/common/sfc_efx/base/efx_mae.c index 9e22c3d507..a126cba37f 100644 --- a/drivers/common/sfc_efx/base/efx_mae.c +++ b/drivers/common/sfc_efx/base/efx_mae.c @@ -434,4 +434,100 @@ efx_mae_match_spec_is_valid( return (is_valid); } + __checkReturn efx_rc_t +efx_mae_match_specs_class_cmp( + __in efx_nic_t *enp, + __in const efx_mae_match_spec_t *left, + __in const efx_mae_match_spec_t *right, + __out boolean_t *have_same_classp) +{ + efx_mae_t *maep = enp->en_maep; + unsigned int field_ncaps = maep->em_max_nfields; + const efx_mae_field_cap_t *field_caps; + const efx_mae_mv_desc_t *desc_setp; + unsigned int desc_set_nentries; + boolean_t have_same_class = B_TRUE; + efx_mae_field_id_t field_id; + const uint8_t *mvpl; + const uint8_t *mvpr; + efx_rc_t rc; + + switch (left->emms_type) { + case EFX_MAE_RULE_ACTION: + field_caps = maep->em_action_rule_field_caps; + desc_setp = __efx_mae_action_rule_mv_desc_set; + desc_set_nentries = + EFX_ARRAY_SIZE(__efx_mae_action_rule_mv_desc_set); + mvpl = left->emms_mask_value_pairs.action; + mvpr = right->emms_mask_value_pairs.action; + break; + default: + rc = ENOTSUP; + goto fail1; + } + + if (field_caps == NULL) { + rc = EAGAIN; + goto fail2; + } + + if (left->emms_type != right->emms_type || + left->emms_prio != right->emms_prio) { + /* + * Rules of different types can never map to the same class. + * + * The FW can support some set of match criteria for one + * priority and not support the very same set for + * another priority. Thus, two rules which have + * different priorities can never map to + * the same class. + */ + *have_same_classp = B_FALSE; + return (0); + } + + for (field_id = 0; field_id < desc_set_nentries; ++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) + continue; /* Skip array gap */ + + if (field_cap_id >= field_ncaps) + 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; + } + } + + 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; + } + } + } + + *have_same_classp = have_same_class; + + return (0); + +fail2: + EFSYS_PROBE(fail2); +fail1: + EFSYS_PROBE1(fail1, efx_rc_t, rc); + return (rc); +} + #endif /* EFSYS_OPT_MAE */ diff --git a/drivers/common/sfc_efx/rte_common_sfc_efx_version.map b/drivers/common/sfc_efx/rte_common_sfc_efx_version.map index 0e6d44b6dc..aeb6f4d134 100644 --- a/drivers/common/sfc_efx/rte_common_sfc_efx_version.map +++ b/drivers/common/sfc_efx/rte_common_sfc_efx_version.map @@ -91,6 +91,7 @@ INTERNAL { efx_mae_match_spec_fini; efx_mae_match_spec_init; efx_mae_match_spec_is_valid; + efx_mae_match_specs_class_cmp; efx_mcdi_fini; efx_mcdi_get_proxy_handle; -- 2.17.1