get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/68568/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 68568,
    "url": "https://patches.dpdk.org/api/patches/68568/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/1586962156-11179-12-git-send-email-venkatkumar.duvvuru@broadcom.com/",
    "project": {
        "id": 1,
        "url": "https://patches.dpdk.org/api/projects/1/?format=api",
        "name": "DPDK",
        "link_name": "dpdk",
        "list_id": "dev.dpdk.org",
        "list_email": "dev@dpdk.org",
        "web_url": "http://core.dpdk.org",
        "scm_url": "git://dpdk.org/dpdk",
        "webscm_url": "http://git.dpdk.org/dpdk",
        "list_archive_url": "https://inbox.dpdk.org/dev",
        "list_archive_url_format": "https://inbox.dpdk.org/dev/{}",
        "commit_url_format": ""
    },
    "msgid": "<1586962156-11179-12-git-send-email-venkatkumar.duvvuru@broadcom.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1586962156-11179-12-git-send-email-venkatkumar.duvvuru@broadcom.com",
    "date": "2020-04-15T14:49:16",
    "name": "[11/11] net/bnxt: addition of the port database",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "f671f7c805420588bd9cdce271592c306590becc",
    "submitter": {
        "id": 1635,
        "url": "https://patches.dpdk.org/api/people/1635/?format=api",
        "name": "Venkat Duvvuru",
        "email": "venkatkumar.duvvuru@broadcom.com"
    },
    "delegate": {
        "id": 1766,
        "url": "https://patches.dpdk.org/api/users/1766/?format=api",
        "username": "ajitkhaparde",
        "first_name": "Ajit",
        "last_name": "Khaparde",
        "email": "ajit.khaparde@broadcom.com"
    },
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/1586962156-11179-12-git-send-email-venkatkumar.duvvuru@broadcom.com/mbox/",
    "series": [
        {
            "id": 9397,
            "url": "https://patches.dpdk.org/api/series/9397/?format=api",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=9397",
            "date": "2020-04-15T14:49:05",
            "name": "enhancements to host based flow table management",
            "version": 1,
            "mbox": "https://patches.dpdk.org/series/9397/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/68568/comments/",
    "check": "fail",
    "checks": "https://patches.dpdk.org/api/patches/68568/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@inbox.dpdk.org",
        "Delivered-To": "patchwork@inbox.dpdk.org",
        "Received": [
            "from dpdk.org (dpdk.org [92.243.14.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id BDD6EA0563;\n\tWed, 15 Apr 2020 16:52:42 +0200 (CEST)",
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 223E41D94D;\n\tWed, 15 Apr 2020 16:50:57 +0200 (CEST)",
            "from mail-pf1-f193.google.com (mail-pf1-f193.google.com\n [209.85.210.193]) by dpdk.org (Postfix) with ESMTP id 748F91D94A\n for <dev@dpdk.org>; Wed, 15 Apr 2020 16:50:55 +0200 (CEST)",
            "by mail-pf1-f193.google.com with SMTP id 201so67969pfv.2\n for <dev@dpdk.org>; Wed, 15 Apr 2020 07:50:55 -0700 (PDT)",
            "from S60.dhcp.broadcom.net ([192.19.234.250])\n by smtp.gmail.com with ESMTPSA id 11sm13767969pfz.91.2020.04.15.07.50.50\n (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128);\n Wed, 15 Apr 2020 07:50:51 -0700 (PDT)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com;\n s=google;\n h=from:to:cc:subject:date:message-id:in-reply-to:references;\n bh=1TlqkJlBZs3mVEGBnHq6Tco3LzIIaAvz+h2ZV3TrQZ0=;\n b=di7AYVK7gVLKl/oz7XepiLUsMU783Hd6yEn9NgJt3aGiM9gV5cKyoZ1eMjcbq63B08\n HF5qszQrwiD0lAPPml8LwMlkMu5CddjGwhF0E64glvKwNwYch0Tg9XCn8hKUIW1N8r7t\n QiDMe28mfNzu5f7ZWCQWfRIX5sOy9rZqCNcfM=",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20161025;\n h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n :references;\n bh=1TlqkJlBZs3mVEGBnHq6Tco3LzIIaAvz+h2ZV3TrQZ0=;\n b=eExVJpmyDEKOkM6GJ9OzqgSRsOEqnpz+Hyb8glX5uZsKWDr7P5QPQoNZXgyhRj9I0q\n CgfBDRpZqidpxWJ16AblIZOyV676r9dSNfHtI1jhqRsZsd9rmDb0rl34Tv9AfKibGZr+\n He3uky6bJ2Na++VeA4rFqQ0o/Ffoxt/5pI76wcJbjrClQcJMV5iVyjMEe6sh1c82W2b/\n yXeJYhr9hVbKjN+0/6uqqL1UpIKR6T7uFcTQ7oBofrCxsxANutKNyIfvukt8ShynBYey\n tyhUMbKutwamFNisBA7znaLSFXzLJW/Bv4Od3vD9lxIcMuqlSUSmWKsWV0aQcB1v+6u9\n GILw==",
        "X-Gm-Message-State": "AGi0PuY/bT3/nmPuo7BqH02RfG1VSY5n+Rka9qGyhV6QtIll0F0wsH+1\n K0c2tmRH3OPZvj1oNFtPJJW3SEcjWpvghIoSHx5j//ErQs8eo3BR8SB5dV0MT0aAk9gtG/Zd2/b\n A6NvKzicPGDhi+sujVvzhI2qzHQjDRr5YJ51LRSdaV8S+PIT2Ekba5bXE17n2ngcr6TH4",
        "X-Google-Smtp-Source": "\n APiQypK/DTMFgI4onlkwt3FP/iTLeaBM06i9Get9w6RGa/oqxwvFmd2FMm5lAgoHmWaSAOXggmyIoA==",
        "X-Received": "by 2002:a62:3843:: with SMTP id f64mr28588040pfa.81.1586962252325;\n Wed, 15 Apr 2020 07:50:52 -0700 (PDT)",
        "From": "Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>",
        "To": "dev@dpdk.org",
        "Cc": "Kishore Padmanabha <kishore.padmanabha@broadcom.com>,\n Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>",
        "Date": "Wed, 15 Apr 2020 20:19:16 +0530",
        "Message-Id": "\n <1586962156-11179-12-git-send-email-venkatkumar.duvvuru@broadcom.com>",
        "X-Mailer": "git-send-email 2.7.4",
        "In-Reply-To": "\n <1586962156-11179-1-git-send-email-venkatkumar.duvvuru@broadcom.com>",
        "References": "\n <1586962156-11179-1-git-send-email-venkatkumar.duvvuru@broadcom.com>",
        "Subject": "[dpdk-dev] [PATCH 11/11] net/bnxt: addition of the port database",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "From: Kishore Padmanabha <kishore.padmanabha@broadcom.com>\n\nThe port database is a repository of the port details\nit is used by the ulp code to query any port related details.\n\nReviewed-by: Mike Baucom <michael.baucom@broadcom.com>\nSigned-off-by: Kishore Padmanabha <kishore.padmanabha@broadcom.com>\nSigned-off-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>\n---\n drivers/net/bnxt/Makefile                     |   1 +\n drivers/net/bnxt/meson.build                  |   1 +\n drivers/net/bnxt/tf_ulp/bnxt_ulp.c            |  48 +++++\n drivers/net/bnxt/tf_ulp/bnxt_ulp.h            |  10 +\n drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c       |  13 +-\n drivers/net/bnxt/tf_ulp/ulp_port_db.c         | 264 ++++++++++++++++++++++++++\n drivers/net/bnxt/tf_ulp/ulp_port_db.h         | 134 +++++++++++++\n drivers/net/bnxt/tf_ulp/ulp_rte_parser.c      |  16 +-\n drivers/net/bnxt/tf_ulp/ulp_template_struct.h |   1 +\n 9 files changed, 482 insertions(+), 6 deletions(-)\n create mode 100644 drivers/net/bnxt/tf_ulp/ulp_port_db.c\n create mode 100644 drivers/net/bnxt/tf_ulp/ulp_port_db.h",
    "diff": "diff --git a/drivers/net/bnxt/Makefile b/drivers/net/bnxt/Makefile\nindex 5ed33cc..2a39ed1 100644\n--- a/drivers/net/bnxt/Makefile\n+++ b/drivers/net/bnxt/Makefile\n@@ -66,6 +66,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_ulp/ulp_mapper.c\n SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_ulp/ulp_matcher.c\n SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_ulp/ulp_rte_parser.c\n SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_ulp/bnxt_ulp_flow.c\n+SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_ulp/ulp_port_db.c\n \n #\n # Export include files\ndiff --git a/drivers/net/bnxt/meson.build b/drivers/net/bnxt/meson.build\nindex d75f887..59dda69 100644\n--- a/drivers/net/bnxt/meson.build\n+++ b/drivers/net/bnxt/meson.build\n@@ -41,6 +41,7 @@ sources = files('bnxt_cpr.c',\n \t'tf_ulp/ulp_matcher.c',\n \t'tf_ulp/ulp_rte_parser.c',\n \t'tf_ulp/bnxt_ulp_flow.c',\n+\t'tf_ulp/ulp_port_db.c',\n \n \t'rte_pmd_bnxt.c')\n \ndiff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp.c b/drivers/net/bnxt/tf_ulp/bnxt_ulp.c\nindex 202b4a5..1823b73 100644\n--- a/drivers/net/bnxt/tf_ulp/bnxt_ulp.c\n+++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp.c\n@@ -20,6 +20,7 @@\n #include \"ulp_mark_mgr.h\"\n #include \"ulp_flow_db.h\"\n #include \"ulp_mapper.h\"\n+#include \"ulp_port_db.h\"\n \n /* Linked list of all TF sessions. */\n STAILQ_HEAD(, bnxt_ulp_session_state) bnxt_ulp_session_list =\n@@ -454,6 +455,13 @@ bnxt_ulp_init(struct bnxt *bp)\n \t\tif (rc) {\n \t\t\tBNXT_TF_DBG(ERR,\n \t\t\t\t    \"Failed to attach the ulp context\\n\");\n+\t\t\treturn rc;\n+\t\t}\n+\t\t/* update the port database */\n+\t\trc = ulp_port_db_dev_port_intf_update(&bp->ulp_ctx, bp);\n+\t\tif (rc) {\n+\t\t\tBNXT_TF_DBG(ERR,\n+\t\t\t\t    \"Failed to update port database\\n\");\n \t\t}\n \t\treturn rc;\n \t}\n@@ -465,6 +473,20 @@ bnxt_ulp_init(struct bnxt *bp)\n \t\tgoto jump_to_error;\n \t}\n \n+\t/* create the port database */\n+\trc = ulp_port_db_init(&bp->ulp_ctx);\n+\tif (rc) {\n+\t\tBNXT_TF_DBG(ERR, \"Failed to create the port database\\n\");\n+\t\tgoto jump_to_error;\n+\t}\n+\n+\t/* update the port database */\n+\trc = ulp_port_db_dev_port_intf_update(&bp->ulp_ctx, bp);\n+\tif (rc) {\n+\t\tBNXT_TF_DBG(ERR, \"Failed to update port database\\n\");\n+\t\tgoto jump_to_error;\n+\t}\n+\n \t/* Create the Mark database. */\n \trc = ulp_mark_db_init(&bp->ulp_ctx);\n \tif (rc) {\n@@ -539,6 +561,9 @@ bnxt_ulp_deinit(struct bnxt *bp)\n \t/* cleanup the ulp mapper */\n \tulp_mapper_deinit(&bp->ulp_ctx);\n \n+\t/* Delete the Port database */\n+\tulp_port_db_deinit(&bp->ulp_ctx);\n+\n \t/* Delete the ulp context and tf session */\n \tulp_ctx_detach(bp, session);\n \n@@ -723,3 +748,26 @@ bnxt_ulp_cntxt_ptr2_mapper_data_get(struct bnxt_ulp_context *ulp_ctx)\n \n \treturn ulp_ctx->cfg_data->mapper_data;\n }\n+\n+/* Function to set the port database to the ulp context. */\n+int32_t\n+bnxt_ulp_cntxt_ptr2_port_db_set(struct bnxt_ulp_context\t*ulp_ctx,\n+\t\t\t\tstruct bnxt_ulp_port_db\t*port_db)\n+{\n+\tif (!ulp_ctx || !ulp_ctx->cfg_data)\n+\t\treturn -EINVAL;\n+\n+\tulp_ctx->cfg_data->port_db = port_db;\n+\treturn 0;\n+}\n+\n+/* Function to get the port database from the ulp context. */\n+struct bnxt_ulp_port_db *\n+bnxt_ulp_cntxt_ptr2_port_db_get(struct bnxt_ulp_context\t*ulp_ctx)\n+{\n+\tif (!ulp_ctx || !ulp_ctx->cfg_data)\n+\t\treturn NULL;\n+\n+\treturn ulp_ctx->cfg_data->port_db;\n+}\n+\ndiff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp.h b/drivers/net/bnxt/tf_ulp/bnxt_ulp.h\nindex d2ca178..eecc09c 100644\n--- a/drivers/net/bnxt/tf_ulp/bnxt_ulp.h\n+++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp.h\n@@ -19,6 +19,7 @@ struct bnxt_ulp_data {\n \tuint32_t\t\t\tref_cnt;\n \tstruct bnxt_ulp_flow_db\t\t*flow_db;\n \tvoid\t\t\t\t*mapper_data;\n+\tstruct bnxt_ulp_port_db\t\t*port_db;\n };\n \n struct bnxt_ulp_context {\n@@ -117,4 +118,13 @@ bnxt_ulp_cntxt_ptr2_mapper_data_set(struct bnxt_ulp_context *ulp_ctx,\n void *\n bnxt_ulp_cntxt_ptr2_mapper_data_get(struct bnxt_ulp_context *ulp_ctx);\n \n+/* Function to set the port database to the ulp context. */\n+int32_t\n+bnxt_ulp_cntxt_ptr2_port_db_set(struct bnxt_ulp_context\t*ulp_ctx,\n+\t\t\t\tstruct bnxt_ulp_port_db\t*port_db);\n+\n+/* Function to get the port database from the ulp context. */\n+struct bnxt_ulp_port_db *\n+bnxt_ulp_cntxt_ptr2_port_db_get(struct bnxt_ulp_context\t*ulp_ctx);\n+\n #endif /* _BNXT_ULP_H_ */\ndiff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c b/drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c\nindex 7783f85..dbec8ce 100644\n--- a/drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c\n+++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c\n@@ -69,7 +69,7 @@ bnxt_ulp_flow_create(struct rte_eth_dev *dev,\n {\n \tstruct bnxt_ulp_mapper_create_parms mapper_cparms = { 0 };\n \tstruct ulp_rte_parser_params params;\n-\tstruct bnxt_ulp_context *ulp_ctx = NULL;\n+\tstruct bnxt_ulp_context *ulp_ctx;\n \tuint32_t class_id, act_tmpl;\n \tstruct rte_flow *flow_id;\n \tuint32_t fid;\n@@ -90,6 +90,7 @@ bnxt_ulp_flow_create(struct rte_eth_dev *dev,\n \n \t/* Initialize the parser params */\n \tmemset(&params, 0, sizeof(struct ulp_rte_parser_params));\n+\tparams.ulp_ctx = ulp_ctx;\n \n \tif (attr->egress)\n \t\tparams.dir = ULP_DIR_EGRESS;\n@@ -142,7 +143,7 @@ bnxt_ulp_flow_create(struct rte_eth_dev *dev,\n \n /* Function to validate the rte flow. */\n static int\n-bnxt_ulp_flow_validate(struct rte_eth_dev *dev __rte_unused,\n+bnxt_ulp_flow_validate(struct rte_eth_dev *dev,\n \t\t       const struct rte_flow_attr *attr,\n \t\t       const struct rte_flow_item pattern[],\n \t\t       const struct rte_flow_action actions[],\n@@ -151,6 +152,7 @@ bnxt_ulp_flow_validate(struct rte_eth_dev *dev __rte_unused,\n \tstruct ulp_rte_parser_params\t\tparams;\n \tuint32_t class_id, act_tmpl;\n \tint ret;\n+\tstruct bnxt_ulp_context *ulp_ctx;\n \n \tif (bnxt_ulp_flow_validate_args(attr,\n \t\t\t\t\tpattern, actions,\n@@ -159,8 +161,15 @@ bnxt_ulp_flow_validate(struct rte_eth_dev *dev __rte_unused,\n \t\treturn -EINVAL;\n \t}\n \n+\tulp_ctx = bnxt_ulp_eth_dev_ptr2_cntxt_get(dev);\n+\tif (!ulp_ctx) {\n+\t\tBNXT_TF_DBG(ERR, \"ULP context is not initialized\\n\");\n+\t\treturn -EINVAL;\n+\t}\n+\n \t/* Initialize the parser params */\n \tmemset(&params, 0, sizeof(struct ulp_rte_parser_params));\n+\tparams.ulp_ctx = ulp_ctx;\n \n \tif (attr->egress)\n \t\tparams.dir = ULP_DIR_EGRESS;\ndiff --git a/drivers/net/bnxt/tf_ulp/ulp_port_db.c b/drivers/net/bnxt/tf_ulp/ulp_port_db.c\nnew file mode 100644\nindex 0000000..762f90e\n--- /dev/null\n+++ b/drivers/net/bnxt/tf_ulp/ulp_port_db.c\n@@ -0,0 +1,264 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2014-2020 Broadcom\n+ * All rights reserved.\n+ */\n+\n+#include <rte_malloc.h>\n+#include \"bnxt.h\"\n+#include \"bnxt_vnic.h\"\n+#include \"bnxt_tf_common.h\"\n+#include \"ulp_port_db.h\"\n+\n+static uint32_t\n+ulp_port_db_allocate_ifindex(struct bnxt_ulp_port_db *port_db)\n+{\n+\tuint32_t idx = 1;\n+\n+\twhile (idx < port_db->ulp_intf_list_size &&\n+\t       port_db->ulp_intf_list[idx].type != BNXT_ULP_INTF_TYPE_INVALID)\n+\t\tidx++;\n+\n+\tif (idx >= port_db->ulp_intf_list_size) {\n+\t\tBNXT_TF_DBG(ERR, \"Port DB interface list is full\\n\");\n+\t\treturn 0;\n+\t}\n+\treturn idx;\n+}\n+\n+/*\n+ * Initialize the port database. Memory is allocated in this\n+ * call and assigned to the port database.\n+ *\n+ * ulp_ctxt [in] Ptr to ulp context\n+ *\n+ * Returns 0 on success or negative number on failure.\n+ */\n+int32_t\tulp_port_db_init(struct bnxt_ulp_context *ulp_ctxt)\n+{\n+\tstruct bnxt_ulp_port_db *port_db;\n+\n+\tport_db = rte_zmalloc(\"bnxt_ulp_port_db\",\n+\t\t\t      sizeof(struct bnxt_ulp_port_db), 0);\n+\tif (!port_db) {\n+\t\tBNXT_TF_DBG(ERR,\n+\t\t\t    \"Failed to allocate memory for port db\\n\");\n+\t\treturn -ENOMEM;\n+\t}\n+\n+\t/* Attach the port database to the ulp context. */\n+\tbnxt_ulp_cntxt_ptr2_port_db_set(ulp_ctxt, port_db);\n+\n+\t/* index 0 is not being used hence add 1 to size */\n+\tport_db->ulp_intf_list_size = BNXT_PORT_DB_MAX_INTF_LIST + 1;\n+\t/* Allocate the port tables */\n+\tport_db->ulp_intf_list = rte_zmalloc(\"bnxt_ulp_port_db_intf_list\",\n+\t\t\t\t\t     port_db->ulp_intf_list_size *\n+\t\t\t\t\t     sizeof(struct ulp_interface_info),\n+\t\t\t\t\t     0);\n+\tif (!port_db->ulp_intf_list) {\n+\t\tBNXT_TF_DBG(ERR,\n+\t\t\t    \"Failed to allocate mem for port interface list\\n\");\n+\t\tgoto error_free;\n+\t}\n+\treturn 0;\n+\n+error_free:\n+\tulp_port_db_deinit(ulp_ctxt);\n+\treturn -ENOMEM;\n+}\n+\n+/*\n+ * Deinitialize the port database. Memory is deallocated in\n+ * this call.\n+ *\n+ * ulp_ctxt [in] Ptr to ulp context\n+ *\n+ * Returns 0 on success.\n+ */\n+int32_t\tulp_port_db_deinit(struct bnxt_ulp_context *ulp_ctxt)\n+{\n+\tstruct bnxt_ulp_port_db *port_db;\n+\n+\tport_db = bnxt_ulp_cntxt_ptr2_port_db_get(ulp_ctxt);\n+\tif (!port_db) {\n+\t\tBNXT_TF_DBG(ERR, \"Invalid Arguments\\n\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\t/* Detach the flow database from the ulp context. */\n+\tbnxt_ulp_cntxt_ptr2_port_db_set(ulp_ctxt, NULL);\n+\n+\t/* Free up all the memory. */\n+\trte_free(port_db->ulp_intf_list);\n+\trte_free(port_db);\n+\treturn 0;\n+}\n+\n+/*\n+ * Update the port database.This api is called when the port\n+ * details are available during the startup.\n+ *\n+ * ulp_ctxt [in] Ptr to ulp context\n+ * bp [in]. ptr to the device function.\n+ *\n+ * Returns 0 on success or negative number on failure.\n+ */\n+int32_t\tulp_port_db_dev_port_intf_update(struct bnxt_ulp_context *ulp_ctxt,\n+\t\t\t\t\t struct bnxt *bp)\n+{\n+\tstruct bnxt_ulp_port_db *port_db;\n+\tuint32_t port_id = bp->eth_dev->data->port_id;\n+\tuint32_t ifindex;\n+\tstruct ulp_interface_info *intf;\n+\tint32_t rc;\n+\tstruct bnxt_vnic_info *vnic;\n+\n+\tport_db = bnxt_ulp_cntxt_ptr2_port_db_get(ulp_ctxt);\n+\tif (!port_db) {\n+\t\tBNXT_TF_DBG(ERR, \"Invalid Arguments\\n\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\trc = ulp_port_db_dev_port_to_ulp_index(ulp_ctxt, port_id, &ifindex);\n+\tif (rc == -ENOENT) {\n+\t\t/* port not found, allocate one */\n+\t\tifindex = ulp_port_db_allocate_ifindex(port_db);\n+\t\tif (!ifindex)\n+\t\t\treturn -ENOMEM;\n+\t\tport_db->dev_port_list[port_id] = ifindex;\n+\t} else if (rc == -EINVAL) {\n+\t\treturn -EINVAL;\n+\t}\n+\n+\t/* update the interface details */\n+\tintf = &port_db->ulp_intf_list[ifindex];\n+\tif (BNXT_PF(bp) || BNXT_VF(bp)) {\n+\t\tif (BNXT_PF(bp)) {\n+\t\t\tintf->type = BNXT_ULP_INTF_TYPE_PF;\n+\t\t\tintf->port_svif = bp->port_svif;\n+\t\t} else {\n+\t\t\tintf->type = BNXT_ULP_INTF_TYPE_VF;\n+\t\t}\n+\t\tintf->func_id = bp->fw_fid;\n+\t\tintf->func_svif = bp->func_svif;\n+\t\tvnic = BNXT_GET_DEFAULT_VNIC(bp);\n+\t\tif (vnic)\n+\t\t\tintf->default_vnic = vnic->fw_vnic_id;\n+\t\tintf->bp = bp;\n+\t\tmemcpy(intf->mac_addr, bp->mac_addr, sizeof(intf->mac_addr));\n+\t} else {\n+\t\tBNXT_TF_DBG(ERR, \"Invalid interface type\\n\");\n+\t}\n+\n+\treturn 0;\n+}\n+\n+/*\n+ * Api to get the ulp ifindex for a given device port.\n+ *\n+ * ulp_ctxt [in] Ptr to ulp context\n+ * port_id [in].device port id\n+ * ifindex [out] ulp ifindex\n+ *\n+ * Returns 0 on success or negative number on failure.\n+ */\n+int32_t\n+ulp_port_db_dev_port_to_ulp_index(struct bnxt_ulp_context *ulp_ctxt,\n+\t\t\t\t  uint32_t port_id,\n+\t\t\t\t  uint32_t *ifindex)\n+{\n+\tstruct bnxt_ulp_port_db *port_db;\n+\n+\t*ifindex = 0;\n+\tport_db = bnxt_ulp_cntxt_ptr2_port_db_get(ulp_ctxt);\n+\tif (!port_db || port_id >= RTE_MAX_ETHPORTS) {\n+\t\tBNXT_TF_DBG(ERR, \"Invalid Arguments\\n\");\n+\t\treturn -EINVAL;\n+\t}\n+\tif (!port_db->dev_port_list[port_id])\n+\t\treturn -ENOENT;\n+\n+\t*ifindex = port_db->dev_port_list[port_id];\n+\treturn 0;\n+}\n+\n+/*\n+ * Api to get the function id for a given ulp ifindex.\n+ *\n+ * ulp_ctxt [in] Ptr to ulp context\n+ * ifindex [in] ulp ifindex\n+ * func_id [out] the function id of the given ifindex.\n+ *\n+ * Returns 0 on success or negative number on failure.\n+ */\n+int32_t\n+ulp_port_db_function_id_get(struct bnxt_ulp_context *ulp_ctxt,\n+\t\t\t    uint32_t ifindex,\n+\t\t\t    uint16_t *func_id)\n+{\n+\tstruct bnxt_ulp_port_db *port_db;\n+\n+\tport_db = bnxt_ulp_cntxt_ptr2_port_db_get(ulp_ctxt);\n+\tif (!port_db || ifindex >= port_db->ulp_intf_list_size || !ifindex) {\n+\t\tBNXT_TF_DBG(ERR, \"Invalid Arguments\\n\");\n+\t\treturn -EINVAL;\n+\t}\n+\t*func_id =  port_db->ulp_intf_list[ifindex].func_id;\n+\treturn 0;\n+}\n+\n+/*\n+ * Api to get the svid for a given ulp ifindex.\n+ *\n+ * ulp_ctxt [in] Ptr to ulp context\n+ * ifindex [in] ulp ifindex\n+ * dir [in] the direction for the flow.\n+ * svif [out] the svif of the given ifindex.\n+ *\n+ * Returns 0 on success or negative number on failure.\n+ */\n+int32_t\n+ulp_port_db_svif_get(struct bnxt_ulp_context *ulp_ctxt,\n+\t\t     uint32_t ifindex,\n+\t\t     uint32_t dir,\n+\t\t     uint16_t *svif)\n+{\n+\tstruct bnxt_ulp_port_db *port_db;\n+\n+\tport_db = bnxt_ulp_cntxt_ptr2_port_db_get(ulp_ctxt);\n+\tif (!port_db || ifindex >= port_db->ulp_intf_list_size || !ifindex) {\n+\t\tBNXT_TF_DBG(ERR, \"Invalid Arguments\\n\");\n+\t\treturn -EINVAL;\n+\t}\n+\tif (dir == ULP_DIR_EGRESS)\n+\t\t*svif = port_db->ulp_intf_list[ifindex].func_svif;\n+\telse\n+\t\t*svif = port_db->ulp_intf_list[ifindex].port_svif;\n+\treturn 0;\n+}\n+\n+/*\n+ * Api to get the vnic id for a given ulp ifindex.\n+ *\n+ * ulp_ctxt [in] Ptr to ulp context\n+ * ifindex [in] ulp ifindex\n+ * vnic [out] the vnic of the given ifindex.\n+ *\n+ * Returns 0 on success or negative number on failure.\n+ */\n+int32_t\n+ulp_port_db_default_vnic_get(struct bnxt_ulp_context *ulp_ctxt,\n+\t\t\t     uint32_t ifindex,\n+\t\t\t     uint16_t *vnic)\n+{\n+\tstruct bnxt_ulp_port_db *port_db;\n+\n+\tport_db = bnxt_ulp_cntxt_ptr2_port_db_get(ulp_ctxt);\n+\tif (!port_db || ifindex >= port_db->ulp_intf_list_size || !ifindex) {\n+\t\tBNXT_TF_DBG(ERR, \"Invalid Arguments\\n\");\n+\t\treturn -EINVAL;\n+\t}\n+\t*vnic = port_db->ulp_intf_list[ifindex].default_vnic;\n+\treturn 0;\n+}\n+\ndiff --git a/drivers/net/bnxt/tf_ulp/ulp_port_db.h b/drivers/net/bnxt/tf_ulp/ulp_port_db.h\nnew file mode 100644\nindex 0000000..271c29a\n--- /dev/null\n+++ b/drivers/net/bnxt/tf_ulp/ulp_port_db.h\n@@ -0,0 +1,134 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2014-2019 Broadcom\n+ * All rights reserved.\n+ */\n+\n+#ifndef _ULP_PORT_DB_H_\n+#define _ULP_PORT_DB_H_\n+\n+#include \"bnxt_ulp.h\"\n+\n+#define BNXT_PORT_DB_MAX_INTF_LIST\t\t256\n+\n+/* enumeration of the interface types */\n+enum bnxt_ulp_intf_type {\n+\tBNXT_ULP_INTF_TYPE_INVALID = 0,\n+\tBNXT_ULP_INTF_TYPE_PF = 1,\n+\tBNXT_ULP_INTF_TYPE_VF,\n+\tBNXT_ULP_INTF_TYPE_PF_REP,\n+\tBNXT_ULP_INTF_TYPE_VF_REP,\n+\tBNXT_ULP_INTF_TYPE_LAST\n+};\n+\n+/* Structure for the Port database resource information. */\n+struct ulp_interface_info {\n+\tenum bnxt_ulp_intf_type\ttype;\n+\tuint16_t\t\tfunc_id;\n+\tuint16_t\t\tfunc_svif;\n+\tuint16_t\t\tport_svif;\n+\tuint16_t\t\tdefault_vnic;\n+\tuint8_t\t\t\tmac_addr[RTE_ETHER_ADDR_LEN];\n+\t/* back pointer to the bnxt driver, it is null for rep ports */\n+\tstruct bnxt\t\t*bp;\n+};\n+\n+/* Structure for the Port database */\n+struct bnxt_ulp_port_db {\n+\tstruct ulp_interface_info\t*ulp_intf_list;\n+\tuint32_t\t\t\tulp_intf_list_size;\n+\n+\t/* dpdk device external port list */\n+\tuint16_t\t\t\tdev_port_list[RTE_MAX_ETHPORTS];\n+};\n+\n+/*\n+ * Initialize the port database. Memory is allocated in this\n+ * call and assigned to the port database.\n+ *\n+ * ulp_ctxt [in] Ptr to ulp context\n+ *\n+ * Returns 0 on success or negative number on failure.\n+ */\n+int32_t\tulp_port_db_init(struct bnxt_ulp_context *ulp_ctxt);\n+\n+/*\n+ * Deinitialize the port database. Memory is deallocated in\n+ * this call.\n+ *\n+ * ulp_ctxt [in] Ptr to ulp context\n+ *\n+ * Returns 0 on success.\n+ */\n+int32_t\tulp_port_db_deinit(struct bnxt_ulp_context *ulp_ctxt);\n+\n+/*\n+ * Update the port database.This api is called when the port\n+ * details are available during the startup.\n+ *\n+ * ulp_ctxt [in] Ptr to ulp context\n+ * bp [in]. ptr to the device function.\n+ *\n+ * Returns 0 on success or negative number on failure.\n+ */\n+int32_t\tulp_port_db_dev_port_intf_update(struct bnxt_ulp_context *ulp_ctxt,\n+\t\t\t\t\t struct bnxt *bp);\n+\n+/*\n+ * Api to get the ulp ifindex for a given device port.\n+ *\n+ * ulp_ctxt [in] Ptr to ulp context\n+ * port_id [in].device port id\n+ * ifindex [out] ulp ifindex\n+ *\n+ * Returns 0 on success or negative number on failure.\n+ */\n+int32_t\n+ulp_port_db_dev_port_to_ulp_index(struct bnxt_ulp_context *ulp_ctxt,\n+\t\t\t\t  uint32_t port_id,\n+\t\t\t\t  uint32_t *ifindex);\n+\n+/*\n+ * Api to get the function id for a given ulp ifindex.\n+ *\n+ * ulp_ctxt [in] Ptr to ulp context\n+ * ifindex [in] ulp ifindex\n+ * func_id [out] the function id of the given ifindex.\n+ *\n+ * Returns 0 on success or negative number on failure.\n+ */\n+int32_t\n+ulp_port_db_function_id_get(struct bnxt_ulp_context *ulp_ctxt,\n+\t\t\t    uint32_t ifindex,\n+\t\t\t    uint16_t *func_id);\n+\n+/*\n+ * Api to get the svid for a given ulp ifindex.\n+ *\n+ * ulp_ctxt [in] Ptr to ulp context\n+ * ifindex [in] ulp ifindex\n+ * dir [in] the direction for the flow.\n+ * svif [out] the svif of the given ifindex.\n+ *\n+ * Returns 0 on success or negative number on failure.\n+ */\n+int32_t\n+ulp_port_db_svif_get(struct bnxt_ulp_context *ulp_ctxt,\n+\t\t     uint32_t ifindex,\n+\t\t     uint32_t dir,\n+\t\t     uint16_t *svif);\n+\n+/*\n+ * Api to get the vnic id for a given ulp ifindex.\n+ *\n+ * ulp_ctxt [in] Ptr to ulp context\n+ * ifindex [in] ulp ifindex\n+ * vnic [out] the vnic of the given ifindex.\n+ *\n+ * Returns 0 on success or negative number on failure.\n+ */\n+int32_t\n+ulp_port_db_default_vnic_get(struct bnxt_ulp_context *ulp_ctxt,\n+\t\t\t     uint32_t ifindex,\n+\t\t\t     uint16_t *vnic);\n+\n+#endif /* _ULP_PORT_DB_H_ */\ndiff --git a/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c b/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c\nindex 873f864..ace5fad 100644\n--- a/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c\n+++ b/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c\n@@ -10,6 +10,7 @@\n #include \"ulp_rte_parser.h\"\n #include \"ulp_utils.h\"\n #include \"tfp.h\"\n+#include \"ulp_port_db.h\"\n \n /* Utility function to skip the void items. */\n static inline int32_t\n@@ -161,6 +162,8 @@ ulp_rte_parser_svif_set(struct ulp_rte_parser_params *params,\n \tuint16_t port_id = svif;\n \tuint32_t dir = 0;\n \tstruct ulp_rte_hdr_field *hdr_field;\n+\tuint32_t ifindex;\n+\tint32_t rc;\n \n \tif (ULP_BITMAP_ISSET(params->hdr_bitmap.bits, BNXT_ULP_HDR_BIT_SVIF)) {\n \t\tBNXT_TF_DBG(ERR,\n@@ -175,10 +178,15 @@ ulp_rte_parser_svif_set(struct ulp_rte_parser_params *params,\n \t\tdir = ULP_UTIL_CHF_IDX_RD(params,\n \t\t\t\t\t  BNXT_ULP_CHF_IDX_DIRECTION);\n \t\t/* perform the conversion from dpdk port to bnxt svif */\n-\t\tif (dir == ULP_DIR_EGRESS)\n-\t\t\tsvif = bnxt_get_svif(port_id, true);\n-\t\telse\n-\t\t\tsvif = bnxt_get_svif(port_id, false);\n+\t\trc = ulp_port_db_dev_port_to_ulp_index(params->ulp_ctx, port_id,\n+\t\t\t\t\t\t       &ifindex);\n+\t\tif (rc) {\n+\t\t\tBNXT_TF_DBG(ERR,\n+\t\t\t\t    \"Invalid port id\\n\");\n+\t\t\treturn BNXT_TF_RC_ERROR;\n+\t\t}\n+\t\tulp_port_db_svif_get(params->ulp_ctx, ifindex, dir, &svif);\n+\t\tsvif = rte_cpu_to_be_16(svif);\n \t}\n \thdr_field = &params->hdr_field[BNXT_ULP_PROTO_HDR_FIELD_SVIF_IDX];\n \tmemcpy(hdr_field->spec, &svif, sizeof(svif));\ndiff --git a/drivers/net/bnxt/tf_ulp/ulp_template_struct.h b/drivers/net/bnxt/tf_ulp/ulp_template_struct.h\nindex 1bef5ab..0e0d02f 100644\n--- a/drivers/net/bnxt/tf_ulp/ulp_template_struct.h\n+++ b/drivers/net/bnxt/tf_ulp/ulp_template_struct.h\n@@ -66,6 +66,7 @@ struct ulp_rte_parser_params {\n \tstruct ulp_rte_act_bitmap\tact_bitmap;\n \tstruct ulp_rte_act_prop\t\tact_prop;\n \tuint32_t\t\t\tdir;\n+\tstruct bnxt_ulp_context\t\t*ulp_ctx;\n };\n \n /* Flow Parser Header Information Structure */\n",
    "prefixes": [
        "11/11"
    ]
}