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 A77E9A0518; Fri, 24 Jul 2020 07:33:31 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id DDA551C06D; Fri, 24 Jul 2020 07:33:11 +0200 (CEST) Received: from mail-vs1-f97.google.com (mail-vs1-f97.google.com [209.85.217.97]) by dpdk.org (Postfix) with ESMTP id 56EB91C067 for ; Fri, 24 Jul 2020 07:33:01 +0200 (CEST) Received: by mail-vs1-f97.google.com with SMTP id p25so4304968vsg.4 for ; Thu, 23 Jul 2020 22:33:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Ezz5kyK+ncR9csKqWKX/YsazdKUrm9sMjW5tGg+ACbg=; b=RErMwo77t48fB78G9e1/75aqctg6NrfG+/0gMCuWu8NZW2Vk3xps4X+2kJWWpa5GSD drzJt6gJtYBgkKXH9d4+ltIp9hhGivIm9kdPU36GBIVSs3gnOoHze1R9kef76zBDh2io 7QG9orCgrUSnAspOmTMQ2iZNAgPeSbg99VX0Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Ezz5kyK+ncR9csKqWKX/YsazdKUrm9sMjW5tGg+ACbg=; b=ky1GX6U7oxEwGhe9UAjf6qr0pMSXXKadSpW1t9Akyso42GxBe//g/37f9ZcsTVYCnw 3qA0Oa6d4dKH/LLs/JU8u4ivTQnCwa3NRKT16fAyQyk+bAjfA3mlO6xof2t0PjMzE1Q3 sOWTgc/mu4aVTjjAwLiW1KXv6phCOcFZvBfx79oCUiTysfWvTQP4PkscrAojY+9ZOBs/ Fd95bnXFYdl5PFW3pOOiTQYl1KlJYwPBREN1loyDfxfjz5gJkQ6MSMQkxAG1+vJPNF+u PIw9yLD+YqNGz0lJjkKZI6h2OQFWFc4khQBgCbUKzvJqD6dysxfrgDursZ66ntz5bK6g mH8A== X-Gm-Message-State: AOAM530UaOnxFn74vY0Z/3KpI+6aGo/0EKnZ1dUolRJIT9SH0EZB3+PL HJYmaAXN6Lvvlu2J/2D3rTLtxl2ZT08feHUjdW1vTG26OA2aThQ2xisJtnfWW9NQLYhUsQDDYGU SvpA8EH08mFzFLau3syr03MI6bkbebr/cWD6lRcbv/sINUzaFIUooARJ1sgQYY1ZQf+bmRvhLXO ehbA== X-Google-Smtp-Source: ABdhPJyOmZMujGevv/JQMkrNfUKb6L4gdgtHceZTLOeAqCi50CZNfQPzDysn5OWsx9w8YTZw7yvFIIzRm7Rv X-Received: by 2002:a67:d599:: with SMTP id m25mr6768979vsj.149.1595568780499; Thu, 23 Jul 2020 22:33:00 -0700 (PDT) Received: from localhost.localdomain ([192.19.223.252]) by smtp-relay.gmail.com with ESMTPS id h17sm592840vsk.0.2020.07.23.22.32.57 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Jul 2020 22:33:00 -0700 (PDT) X-Relaying-Domain: broadcom.com From: Ajit Khaparde To: dev@dpdk.org Cc: ferruh.yigit@intel.com, Mike Baucom , Kishore Padmanabha Date: Thu, 23 Jul 2020 22:32:17 -0700 Message-Id: <20200724053235.71069-5-ajit.khaparde@broadcom.com> X-Mailer: git-send-email 2.21.1 (Apple Git-122.3) In-Reply-To: <20200724053235.71069-1-ajit.khaparde@broadcom.com> References: <20200723115639.22357-1-somnath.kotur@broadcom.com> <20200724053235.71069-1-ajit.khaparde@broadcom.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v3 04/22] net/bnxt: modify ulp mapper to use tcam search 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: Mike Baucom modified ulp mappper to use the new tf_search_tcam_entry API. When search before allocation is requested, mapper calls tc_search_tcam_entry with the alloc flag. - On HIT, the result and tcam index is returned. - On MISS, the tcam index is returned but the result is created and the tcam entry is set. - On REJECT, the flow request is rejected. Signed-off-by: Mike Baucom Reviewed-by: Kishore Padmanabha Reviewed-by: Ajit Khaparde --- drivers/net/bnxt/tf_ulp/ulp_mapper.c | 106 ++++++++++++++++++--------- 1 file changed, 71 insertions(+), 35 deletions(-) diff --git a/drivers/net/bnxt/tf_ulp/ulp_mapper.c b/drivers/net/bnxt/tf_ulp/ulp_mapper.c index 6a727ed34..2d3373df2 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_mapper.c +++ b/drivers/net/bnxt/tf_ulp/ulp_mapper.c @@ -690,7 +690,7 @@ ulp_mapper_ident_extract(struct bnxt_ulp_mapper_parms *parms, { struct ulp_flow_db_res_params fid_parms; uint64_t id = 0; - uint32_t idx; + uint32_t idx = 0; struct tf_search_identifier_parms sparms = { 0 }; struct tf_free_identifier_parms free_parms = { 0 }; struct tf *tfp; @@ -1292,12 +1292,13 @@ ulp_mapper_tcam_tbl_process(struct bnxt_ulp_mapper_parms *parms, struct tf *tfp; int32_t rc, trc; struct tf_alloc_tcam_entry_parms aparms = { 0 }; + struct tf_search_tcam_entry_parms searchparms = { 0 }; struct tf_set_tcam_entry_parms sparms = { 0 }; struct ulp_flow_db_res_params fid_parms = { 0 }; struct tf_free_tcam_entry_parms free_parms = { 0 }; uint32_t hit = 0; uint16_t tmplen = 0; - struct ulp_blob res_blob; + uint16_t idx; /* Skip this if was handled by the cache. */ if (parms->tcam_tbl_opc == BNXT_ULP_MAPPER_TCAM_TBL_OPC_CACHE_SKIP) { @@ -1352,37 +1353,72 @@ ulp_mapper_tcam_tbl_process(struct bnxt_ulp_mapper_parms *parms, } } - aparms.dir = tbl->direction; - aparms.tcam_tbl_type = tbl->resource_type; - aparms.search_enable = tbl->srch_b4_alloc; - aparms.key_sz_in_bits = tbl->key_bit_size; - aparms.key = ulp_blob_data_get(&key, &tmplen); - if (tbl->key_bit_size != tmplen) { - BNXT_TF_DBG(ERR, "Key len (%d) != Expected (%d)\n", - tmplen, tbl->key_bit_size); - return -EINVAL; - } + if (!tbl->srch_b4_alloc) { + /* + * No search for re-use is requested, so simply allocate the + * tcam index. + */ + aparms.dir = tbl->direction; + aparms.tcam_tbl_type = tbl->resource_type; + aparms.search_enable = tbl->srch_b4_alloc; + aparms.key_sz_in_bits = tbl->key_bit_size; + aparms.key = ulp_blob_data_get(&key, &tmplen); + if (tbl->key_bit_size != tmplen) { + BNXT_TF_DBG(ERR, "Key len (%d) != Expected (%d)\n", + tmplen, tbl->key_bit_size); + return -EINVAL; + } - aparms.mask = ulp_blob_data_get(&mask, &tmplen); - if (tbl->key_bit_size != tmplen) { - BNXT_TF_DBG(ERR, "Mask len (%d) != Expected (%d)\n", - tmplen, tbl->key_bit_size); - return -EINVAL; - } + aparms.mask = ulp_blob_data_get(&mask, &tmplen); + if (tbl->key_bit_size != tmplen) { + BNXT_TF_DBG(ERR, "Mask len (%d) != Expected (%d)\n", + tmplen, tbl->key_bit_size); + return -EINVAL; + } - aparms.priority = tbl->priority; + aparms.priority = tbl->priority; - /* - * All failures after this succeeds require the entry to be freed. - * cannot return directly on failure, but needs to goto error - */ - rc = tf_alloc_tcam_entry(tfp, &aparms); - if (rc) { - BNXT_TF_DBG(ERR, "tcam alloc failed rc=%d.\n", rc); - return rc; - } + /* + * All failures after this succeeds require the entry to be + * freed. cannot return directly on failure, but needs to goto + * error. + */ + rc = tf_alloc_tcam_entry(tfp, &aparms); + if (rc) { + BNXT_TF_DBG(ERR, "tcam alloc failed rc=%d.\n", rc); + return rc; + } + idx = aparms.idx; + hit = aparms.hit; + } else { + /* + * Searching before allocation to see if we already have an + * entry. This allows re-use of a constrained resource. + */ + searchparms.dir = tbl->direction; + searchparms.tcam_tbl_type = tbl->resource_type; + searchparms.key = ulp_blob_data_get(&key, &tmplen); + searchparms.key_sz_in_bits = tbl->key_bit_size; + searchparms.mask = ulp_blob_data_get(&mask, &tmplen); + searchparms.priority = tbl->priority; + searchparms.alloc = 1; + searchparms.result = ulp_blob_data_get(&data, &tmplen); + searchparms.result_sz_in_bits = tbl->result_bit_size; + + rc = tf_search_tcam_entry(tfp, &searchparms); + if (rc) { + BNXT_TF_DBG(ERR, "tcam search failed rc=%d\n", rc); + return rc; + } - hit = aparms.hit; + /* Successful search, check the result */ + if (searchparms.search_status == REJECT) { + BNXT_TF_DBG(ERR, "tcam alloc rejected\n"); + return -ENOMEM; + } + idx = searchparms.idx; + hit = searchparms.hit; + } /* Build the result */ if (!tbl->srch_b4_alloc || !hit) { @@ -1430,9 +1466,9 @@ ulp_mapper_tcam_tbl_process(struct bnxt_ulp_mapper_parms *parms, } } - sparms.dir = aparms.dir; - sparms.tcam_tbl_type = aparms.tcam_tbl_type; - sparms.idx = aparms.idx; + sparms.dir = tbl->direction; + sparms.tcam_tbl_type = tbl->resource_type; + sparms.idx = idx; /* Already verified the key/mask lengths */ sparms.key = ulp_blob_data_get(&key, &tmplen); sparms.mask = ulp_blob_data_get(&mask, &tmplen); @@ -1464,7 +1500,7 @@ ulp_mapper_tcam_tbl_process(struct bnxt_ulp_mapper_parms *parms, rc = -EINVAL; goto error; } - parms->cache_ptr->tcam_idx = aparms.idx; + parms->cache_ptr->tcam_idx = idx; } /* Mark action */ @@ -1483,7 +1519,7 @@ ulp_mapper_tcam_tbl_process(struct bnxt_ulp_mapper_parms *parms, idents = ulp_mapper_ident_fields_get(tbl, &num_idents); for (i = 0; i < num_idents; i++) { rc = ulp_mapper_ident_extract(parms, tbl, - &idents[i], &res_blob); + &idents[i], &data); if (rc) { BNXT_TF_DBG(ERR, "Error in ident extraction\n"); @@ -1501,7 +1537,7 @@ ulp_mapper_tcam_tbl_process(struct bnxt_ulp_mapper_parms *parms, fid_parms.resource_func = tbl->resource_func; fid_parms.resource_type = tbl->resource_type; fid_parms.critical_resource = tbl->critical_resource; - fid_parms.resource_hndl = aparms.idx; + fid_parms.resource_hndl = idx; rc = ulp_flow_db_resource_add(parms->ulp_ctx, parms->tbl_idx, parms->fid, -- 2.21.1 (Apple Git-122.3)