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 1044CA0597; Fri, 17 Apr 2020 18:19:39 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 5E37F1E9E6; Fri, 17 Apr 2020 18:19:30 +0200 (CEST) Received: from rnd-relay.smtp.broadcom.com (rnd-relay.smtp.broadcom.com [192.19.229.170]) by dpdk.org (Postfix) with ESMTP id 6AF5C1E9D1 for ; Fri, 17 Apr 2020 18:19:26 +0200 (CEST) Received: from mail-irv-17.broadcom.com (mail-irv-17.lvn.broadcom.net [10.75.242.48]) by rnd-relay.smtp.broadcom.com (Postfix) with ESMTP id 6241930C1DA; Fri, 17 Apr 2020 09:08:05 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.10.3 rnd-relay.smtp.broadcom.com 6241930C1DA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1587139685; bh=rf5r6a12evlfNwtlFrtP3DwPyhPUUZW8XXSVK1zKWf4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Jz1P6OWWqxA0SG3LLAM+dI+2NBeUMM83Onxy8B3zQfleerxdf1RX67ZuBHgv5unTg t5L2vY3eYn+cZKXa0WWNxsd02PQVQBfaCMiqueGxoIlW0bHLXiPkLOst47inoOaLKo 6e3SDQDKKFrEVZxJC5qVG/tXrJC+iYc4nBc+iEVo= Received: from localhost.localdomain (unknown [10.230.185.215]) by mail-irv-17.broadcom.com (Postfix) with ESMTP id 92F4B14008C; Fri, 17 Apr 2020 09:19:24 -0700 (PDT) From: Ajit Khaparde To: dev@dpdk.org Cc: Kishore Padmanabha , Michael Baucom , Venkat Duvvuru Date: Fri, 17 Apr 2020 09:19:11 -0700 Message-Id: <20200417161920.85858-4-ajit.khaparde@broadcom.com> X-Mailer: git-send-email 2.21.1 (Apple Git-122.3) In-Reply-To: <20200417161920.85858-1-ajit.khaparde@broadcom.com> References: <1586962156-11179-1-git-send-email-venkatkumar.duvvuru@broadcom.com> <20200417161920.85858-1-ajit.khaparde@broadcom.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v2 03/12] net/bnxt: add flow database resource iteration 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: Kishore Padmanabha This API can be used to iterate individual resource functions in the flow database. Reviewed-by: Michael Baucom Reviewed-by: Ajit Khaparde Signed-off-by: Kishore Padmanabha Signed-off-by: Venkat Duvvuru --- drivers/net/bnxt/tf_ulp/ulp_flow_db.c | 66 ++++++++++++++++++++++++++- drivers/net/bnxt/tf_ulp/ulp_flow_db.h | 17 +++++++ 2 files changed, 82 insertions(+), 1 deletion(-) diff --git a/drivers/net/bnxt/tf_ulp/ulp_flow_db.c b/drivers/net/bnxt/tf_ulp/ulp_flow_db.c index e99e94ab7..9e7f9f5e3 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_flow_db.c +++ b/drivers/net/bnxt/tf_ulp/ulp_flow_db.c @@ -560,7 +560,71 @@ int32_t ulp_flow_db_fid_free(struct bnxt_ulp_context *ulp_ctxt, return 0; } -/** Get the flow database entry iteratively +/* + * Get the flow database entry details + * + * ulp_ctxt [in] Ptr to ulp_context + * tbl_idx [in] Specify it is regular or default flow + * fid [in] The index to the flow entry + * nxt_idx [in/out] the index to the next entry + * params [out] The contents to be copied into params. + * + * returns 0 on success and negative on failure. + */ +int32_t ulp_flow_db_resource_get(struct bnxt_ulp_context *ulp_ctxt, + enum bnxt_ulp_flow_db_tables tbl_idx, + uint32_t fid, + uint32_t *nxt_idx, + struct ulp_flow_db_res_params *params) +{ + struct bnxt_ulp_flow_db *flow_db; + struct bnxt_ulp_flow_tbl *flow_tbl; + struct ulp_fdb_resource_info *nxt_resource, *fid_resource; + + flow_db = bnxt_ulp_cntxt_ptr2_flow_db_get(ulp_ctxt); + if (!flow_db) { + BNXT_TF_DBG(ERR, "Invalid Arguments\n"); + return -EINVAL; + } + + if (tbl_idx >= BNXT_ULP_FLOW_TABLE_MAX) { + BNXT_TF_DBG(ERR, "Invalid table index\n"); + return -EINVAL; + } + + flow_tbl = &flow_db->flow_tbl[tbl_idx]; + + /* check for limits of fid */ + if (fid >= flow_tbl->num_flows || !fid) { + BNXT_TF_DBG(ERR, "Invalid flow index\n"); + return -EINVAL; + } + + /* check if the flow is active or not */ + if (!ulp_flow_db_active_flow_is_set(flow_tbl, fid)) { + BNXT_TF_DBG(ERR, "flow does not exist\n"); + return -EINVAL; + } + + if (!*nxt_idx) { + fid_resource = &flow_tbl->flow_resources[fid]; + ulp_flow_db_res_info_to_params(fid_resource, params); + ULP_FLOW_DB_RES_NXT_SET(*nxt_idx, + fid_resource->nxt_resource_idx); + } else { + nxt_resource = &flow_tbl->flow_resources[*nxt_idx]; + ulp_flow_db_res_info_to_params(nxt_resource, params); + *nxt_idx = 0; + ULP_FLOW_DB_RES_NXT_SET(*nxt_idx, + nxt_resource->nxt_resource_idx); + } + + /* all good, return success */ + return 0; +} + +/* + * Get the flow database entry iteratively * * flow_tbl [in] Ptr to flow table * fid [in/out] The index to the flow entry diff --git a/drivers/net/bnxt/tf_ulp/ulp_flow_db.h b/drivers/net/bnxt/tf_ulp/ulp_flow_db.h index 543541565..5361dd025 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_flow_db.h +++ b/drivers/net/bnxt/tf_ulp/ulp_flow_db.h @@ -142,6 +142,23 @@ int32_t ulp_flow_db_fid_free(struct bnxt_ulp_context *ulp_ctxt, enum bnxt_ulp_flow_db_tables tbl_idx, uint32_t fid); +/* + *Get the flow database entry details + * + * ulp_ctxt [in] Ptr to ulp_context + * tbl_idx [in] Specify it is regular or default flow + * fid [in] The index to the flow entry + * nxt_idx [in/out] the index to the next entry + * params [out] The contents to be copied into params. + * + * returns 0 on success and negative on failure. + */ +int32_t ulp_flow_db_resource_get(struct bnxt_ulp_context *ulp_ctxt, + enum bnxt_ulp_flow_db_tables tbl_idx, + uint32_t fid, + uint32_t *nxt_idx, + struct ulp_flow_db_res_params *params); + /* * Flush all flows in the flow database. * -- 2.21.1 (Apple Git-122.3)