get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 68402,
    "url": "http://patches.dpdk.org/api/patches/68402/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/1586852011-37536-17-git-send-email-venkatkumar.duvvuru@broadcom.com/",
    "project": {
        "id": 1,
        "url": "http://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": "<1586852011-37536-17-git-send-email-venkatkumar.duvvuru@broadcom.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1586852011-37536-17-git-send-email-venkatkumar.duvvuru@broadcom.com",
    "date": "2020-04-14T08:13:13",
    "name": "[v3,16/34] net/bnxt: add support for ULP session manager init",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "a29b4ce8c11acfabc8845b4094acec3bda0af2be",
    "submitter": {
        "id": 1635,
        "url": "http://patches.dpdk.org/api/people/1635/?format=api",
        "name": "Venkat Duvvuru",
        "email": "venkatkumar.duvvuru@broadcom.com"
    },
    "delegate": {
        "id": 1766,
        "url": "http://patches.dpdk.org/api/users/1766/?format=api",
        "username": "ajitkhaparde",
        "first_name": "Ajit",
        "last_name": "Khaparde",
        "email": "ajit.khaparde@broadcom.com"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/1586852011-37536-17-git-send-email-venkatkumar.duvvuru@broadcom.com/mbox/",
    "series": [
        {
            "id": 9362,
            "url": "http://patches.dpdk.org/api/series/9362/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=9362",
            "date": "2020-04-14T08:12:57",
            "name": "add support for host based flow table management",
            "version": 3,
            "mbox": "http://patches.dpdk.org/series/9362/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/68402/comments/",
    "check": "fail",
    "checks": "http://patches.dpdk.org/api/patches/68402/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 A8C52A0577;\n\tTue, 14 Apr 2020 10:17:32 +0200 (CEST)",
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 5CFC21C28F;\n\tTue, 14 Apr 2020 10:14:30 +0200 (CEST)",
            "from mail-pg1-f176.google.com (mail-pg1-f176.google.com\n [209.85.215.176]) by dpdk.org (Postfix) with ESMTP id 86ED71C2A3\n for <dev@dpdk.org>; Tue, 14 Apr 2020 10:14:28 +0200 (CEST)",
            "by mail-pg1-f176.google.com with SMTP id c23so5683816pgj.3\n for <dev@dpdk.org>; Tue, 14 Apr 2020 01:14:28 -0700 (PDT)",
            "from S60.dhcp.broadcom.net ([192.19.234.250])\n by smtp.gmail.com with ESMTPSA id e196sm671176pfh.43.2020.04.14.01.14.23\n (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128);\n Tue, 14 Apr 2020 01:14:25 -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=9Bt3CWIILGuTJsyeBJFPehkrm0RmTE9wwdiU+SAKeBQ=;\n b=av6+jTK3AHmxKH27bz6S/DPh2mNUf9rV9b/7b0oITrpmKvP6g36rpRueLH5HS8fKf9\n tlLctK7JwYl+SJQTaVtikGQvHwcMxPaWsSh9lcNEXAEcw56OtpzjYDSn1NrUEC9qv4o4\n 0BJlgRLz1+fUC6pgh00GNeyIqeW0FXxJxD7BM=",
        "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=9Bt3CWIILGuTJsyeBJFPehkrm0RmTE9wwdiU+SAKeBQ=;\n b=nW6rg86CjhyH6t4ghvEvP0IuhAxliTQY9+R6xMNzGnRZAG1bYXldBjldzWTnn6Z3TE\n IoAY+InQolccDeG/GhjpCWK+j7vKwhoLFLIaYm/PLwrqndyp6W78fBiyVCiW3IJ8ScGz\n X++tDalEJVTgB0+MR0ayLZE5CBzpzXG7RNIBGc0PuDmd58Et0BD3tQ1Zwx42UyM/MzuJ\n y0ikRrgbuacgOCDp4OtNW8sIoq0ubUk4JkjRv/T+pEYm1cFyQd96+Sy/Dl9spH8CD8XG\n Gmqz9806kQ6u3cQPft5yVh3K+KkxraCTs6CldYlY4JcJlDWnJ0S7GY8O/GEZbaDPaD8a\n 9row==",
        "X-Gm-Message-State": "AGi0PubemIE6k52D8DXwQTdFQCvW5ujdjK3LyJFzuQk2ASVARG/pTPPf\n 6QFjmfR93/U+F7D6W+lKInfE8Huz0rA6lQRXqbr9yaAuD6yvW9i25TNfOjMcVG/2gCWDimAPNt9\n A7cq2t+9OsdnCJTkhN5mPmNxd5K+bZ7iN4cIBIV3jr3IFRZhHe9ZYWW966T96d69DzCP2",
        "X-Google-Smtp-Source": "\n APiQypKP628tOZ5xpWFPjMmQEQrRzNEkZFczJXSIiugYpqhr9nZTYd0Fm2Tf3Q2bYo+1JUCxMpH7iw==",
        "X-Received": "by 2002:a63:68c1:: with SMTP id\n d184mr2016380pgc.231.1586852066179;\n Tue, 14 Apr 2020 01:14:26 -0700 (PDT)",
        "From": "Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>",
        "To": "dev@dpdk.org",
        "Cc": "Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>,\n Mike Baucom <michael.baucom@broadcom.com>",
        "Date": "Tue, 14 Apr 2020 13:43:13 +0530",
        "Message-Id": "\n <1586852011-37536-17-git-send-email-venkatkumar.duvvuru@broadcom.com>",
        "X-Mailer": "git-send-email 2.7.4",
        "In-Reply-To": "\n <1586852011-37536-1-git-send-email-venkatkumar.duvvuru@broadcom.com>",
        "References": "\n <1586806811-21736-1-git-send-email-venkatkumar.duvvuru@broadcom.com>\n <1586852011-37536-1-git-send-email-venkatkumar.duvvuru@broadcom.com>",
        "Subject": "[dpdk-dev] [PATCH v3 16/34] net/bnxt: add support for ULP session\n\tmanager init",
        "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": "A ULP session will contain all the resources needed to support\nrte flow offloads. A session is initialized as part of rte_eth_device\nstart. A DPDK application can have multiple interfaces which\nmeans rte_eth_device start will be called for each of these devices.\nULP session manager will make sure that a single ULP session is only\ninitialized once. Apart from this, it also initializes MARK database,\nEEM table & flow database. ULP session manager also manages a list of\nall opened ULP sessions.\n\nSigned-off-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>\nSigned-off-by: Mike Baucom <michael.baucom@broadcom.com>\nReviewed-by: Lance Richardson <lance.richardson@broadcom.com>\nReviewed-by: Ajit Kumar Khaparde <ajit.khaparde@broadcom.com>\n---\n drivers/net/bnxt/Makefile                     |   6 +-\n drivers/net/bnxt/bnxt.h                       |   5 +\n drivers/net/bnxt/bnxt_ethdev.c                |   4 +\n drivers/net/bnxt/tf_ulp/bnxt_tf_common.h      |  35 ++\n drivers/net/bnxt/tf_ulp/bnxt_ulp.c            | 527 ++++++++++++++++++++++++++\n drivers/net/bnxt/tf_ulp/bnxt_ulp.h            | 100 +++++\n drivers/net/bnxt/tf_ulp/ulp_flow_db.c         | 187 +++++++++\n drivers/net/bnxt/tf_ulp/ulp_flow_db.h         |  77 ++++\n drivers/net/bnxt/tf_ulp/ulp_mark_mgr.c        |  94 +++++\n drivers/net/bnxt/tf_ulp/ulp_mark_mgr.h        |  49 +++\n drivers/net/bnxt/tf_ulp/ulp_template_db.c     |  27 ++\n drivers/net/bnxt/tf_ulp/ulp_template_db.h     |  35 ++\n drivers/net/bnxt/tf_ulp/ulp_template_struct.h |  40 ++\n 13 files changed, 1185 insertions(+), 1 deletion(-)\n create mode 100644 drivers/net/bnxt/tf_ulp/bnxt_tf_common.h\n create mode 100644 drivers/net/bnxt/tf_ulp/bnxt_ulp.c\n create mode 100644 drivers/net/bnxt/tf_ulp/bnxt_ulp.h\n create mode 100644 drivers/net/bnxt/tf_ulp/ulp_flow_db.c\n create mode 100644 drivers/net/bnxt/tf_ulp/ulp_flow_db.h\n create mode 100644 drivers/net/bnxt/tf_ulp/ulp_mark_mgr.c\n create mode 100644 drivers/net/bnxt/tf_ulp/ulp_mark_mgr.h\n create mode 100644 drivers/net/bnxt/tf_ulp/ulp_template_db.c\n create mode 100644 drivers/net/bnxt/tf_ulp/ulp_template_db.h\n create mode 100644 drivers/net/bnxt/tf_ulp/ulp_template_struct.h",
    "diff": "diff --git a/drivers/net/bnxt/Makefile b/drivers/net/bnxt/Makefile\nindex 4c95847..bb9b888 100644\n--- a/drivers/net/bnxt/Makefile\n+++ b/drivers/net/bnxt/Makefile\n@@ -44,7 +44,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_rxtx_vec_sse.c\n endif\n \n ifeq ($(CONFIG_RTE_LIBRTE_BNXT_PMD), y)\n-CFLAGS += -I$(SRCDIR) -I$(SRCDIR)/tf_core\n+CFLAGS += -I$(SRCDIR) -I$(SRCDIR)/tf_core -I$(SRCDIR)/tf_ulp\n endif\n \n SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/tf_core.c\n@@ -57,6 +57,10 @@ SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/tf_rm.c\n SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/tf_tbl.c\n SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/tfp.c\n \n+SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_ulp/bnxt_ulp.c\n+SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_ulp/ulp_mark_mgr.c\n+SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_ulp/ulp_flow_db.c\n+SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_ulp/ulp_template_db.c\n #\n # Export include files\n #\ndiff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h\nindex cd84ebd..cd20740 100644\n--- a/drivers/net/bnxt/bnxt.h\n+++ b/drivers/net/bnxt/bnxt.h\n@@ -22,6 +22,7 @@\n #include \"bnxt_util.h\"\n \n #include \"tf_core.h\"\n+#include \"bnxt_ulp.h\"\n \n /* Vendor ID */\n #define PCI_VENDOR_ID_BROADCOM\t\t0x14E4\n@@ -687,6 +688,7 @@ struct bnxt {\n \tuint16_t\t\tport_svif;\n \n \tstruct tf\t\ttfp;\n+\tstruct bnxt_ulp_context\tulp_ctx;\n \tuint8_t\t\t\ttruflow;\n };\n \n@@ -729,6 +731,9 @@ extern int bnxt_logtype_driver;\n #define PMD_DRV_LOG(level, fmt, args...) \\\n \t  PMD_DRV_LOG_RAW(level, fmt, ## args)\n \n+int32_t bnxt_ulp_init(struct bnxt *bp);\n+void bnxt_ulp_deinit(struct bnxt *bp);\n+\n uint16_t bnxt_get_vnic_id(uint16_t port);\n uint16_t bnxt_get_svif(uint16_t port_id, bool func_svif);\n \ndiff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c\nindex c4bbf1d..1703ce3 100644\n--- a/drivers/net/bnxt/bnxt_ethdev.c\n+++ b/drivers/net/bnxt/bnxt_ethdev.c\n@@ -904,6 +904,10 @@ static int bnxt_dev_start_op(struct rte_eth_dev *eth_dev)\n \tpthread_mutex_lock(&bp->def_cp_lock);\n \tbnxt_schedule_fw_health_check(bp);\n \tpthread_mutex_unlock(&bp->def_cp_lock);\n+\n+\tif (bp->truflow)\n+\t\tbnxt_ulp_init(bp);\n+\n \treturn 0;\n \n error:\ndiff --git a/drivers/net/bnxt/tf_ulp/bnxt_tf_common.h b/drivers/net/bnxt/tf_ulp/bnxt_tf_common.h\nnew file mode 100644\nindex 0000000..3516df4\n--- /dev/null\n+++ b/drivers/net/bnxt/tf_ulp/bnxt_tf_common.h\n@@ -0,0 +1,35 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2014-2019 Broadcom\n+ * All rights reserved.\n+ */\n+\n+#ifndef _BNXT_TF_COMMON_H_\n+#define _BNXT_TF_COMMON_H_\n+\n+#define BNXT_TF_DBG(lvl, fmt, args...)\tPMD_DRV_LOG(lvl, fmt, ## args)\n+\n+#define BNXT_ULP_EM_FLOWS\t\t\t8192\n+#define BNXT_ULP_1M_FLOWS\t\t\t1000000\n+#define BNXT_EEM_RX_GLOBAL_ID_MASK\t\t(BNXT_ULP_1M_FLOWS - 1)\n+#define BNXT_EEM_TX_GLOBAL_ID_MASK\t\t(BNXT_ULP_1M_FLOWS - 1)\n+#define BNXT_EEM_HASH_KEY2_USED\t\t\t0x8000000\n+#define BNXT_EEM_RX_HW_HASH_KEY2_BIT\t\tBNXT_ULP_1M_FLOWS\n+#define\tBNXT_ULP_DFLT_RX_MAX_KEY\t\t512\n+#define\tBNXT_ULP_DFLT_RX_MAX_ACTN_ENTRY\t\t256\n+#define\tBNXT_ULP_DFLT_RX_MEM\t\t\t0\n+#define\tBNXT_ULP_RX_NUM_FLOWS\t\t\t32\n+#define\tBNXT_ULP_RX_TBL_IF_ID\t\t\t0\n+#define\tBNXT_ULP_DFLT_TX_MAX_KEY\t\t512\n+#define\tBNXT_ULP_DFLT_TX_MAX_ACTN_ENTRY\t\t256\n+#define\tBNXT_ULP_DFLT_TX_MEM\t\t\t0\n+#define\tBNXT_ULP_TX_NUM_FLOWS\t\t\t32\n+#define\tBNXT_ULP_TX_TBL_IF_ID\t\t\t0\n+\n+struct bnxt_ulp_mark_tbl *\n+bnxt_ulp_cntxt_ptr2_mark_db_get(struct bnxt_ulp_context *ulp_ctx);\n+\n+int32_t\n+bnxt_ulp_cntxt_ptr2_mark_db_set(struct bnxt_ulp_context *ulp_ctx,\n+\t\t\t\tstruct bnxt_ulp_mark_tbl *mark_tbl);\n+\n+#endif /* _BNXT_TF_COMMON_H_ */\ndiff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp.c b/drivers/net/bnxt/tf_ulp/bnxt_ulp.c\nnew file mode 100644\nindex 0000000..7afc6bf\n--- /dev/null\n+++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp.c\n@@ -0,0 +1,527 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2019-2020 Broadcom\n+ * All rights reserved.\n+ */\n+\n+#include <rte_log.h>\n+#include <rte_malloc.h>\n+#include <rte_flow.h>\n+#include <rte_flow_driver.h>\n+#include <rte_tailq.h>\n+\n+#include \"bnxt_ulp.h\"\n+#include \"bnxt_tf_common.h\"\n+#include \"bnxt.h\"\n+#include \"tf_core.h\"\n+#include \"tf_ext_flow_handle.h\"\n+\n+#include \"ulp_template_db.h\"\n+#include \"ulp_template_struct.h\"\n+#include \"ulp_mark_mgr.h\"\n+#include \"ulp_flow_db.h\"\n+\n+/* Linked list of all TF sessions. */\n+STAILQ_HEAD(, bnxt_ulp_session_state) bnxt_ulp_session_list =\n+\t\t\tSTAILQ_HEAD_INITIALIZER(bnxt_ulp_session_list);\n+\n+/* Mutex to synchronize bnxt_ulp_session_list operations. */\n+static pthread_mutex_t bnxt_ulp_global_mutex = PTHREAD_MUTEX_INITIALIZER;\n+\n+/*\n+ * Initialize an ULP session.\n+ * An ULP session will contain all the resources needed to support rte flow\n+ * offloads. A session is initialized as part of rte_eth_device start.\n+ * A single vswitch instance can have multiple uplinks which means\n+ * rte_eth_device start will be called for each of these devices.\n+ * ULP session manager will make sure that a single ULP session is only\n+ * initialized once. Apart from this, it also initializes MARK database,\n+ * EEM table & flow database. ULP session manager also manages a list of\n+ * all opened ULP sessions.\n+ */\n+static int32_t\n+ulp_ctx_session_open(struct bnxt *bp,\n+\t\t     struct bnxt_ulp_session_state *session)\n+{\n+\tstruct rte_eth_dev\t\t*ethdev = bp->eth_dev;\n+\tint32_t\t\t\t\trc = 0;\n+\tstruct tf_open_session_parms\tparams;\n+\n+\tmemset(&params, 0, sizeof(params));\n+\n+\trc = rte_eth_dev_get_name_by_port(ethdev->data->port_id,\n+\t\t\t\t\t  params.ctrl_chan_name);\n+\tif (rc) {\n+\t\tBNXT_TF_DBG(ERR, \"Invalid port %d, rc = %d\\n\",\n+\t\t\t    ethdev->data->port_id, rc);\n+\t\treturn rc;\n+\t}\n+\n+\trc = tf_open_session(&bp->tfp, &params);\n+\tif (rc) {\n+\t\tBNXT_TF_DBG(ERR, \"Failed to open TF session - %s, rc = %d\\n\",\n+\t\t\t    params.ctrl_chan_name, rc);\n+\t\treturn -EINVAL;\n+\t}\n+\tsession->session_opened = 1;\n+\tsession->g_tfp = &bp->tfp;\n+\treturn rc;\n+}\n+\n+static void\n+bnxt_init_tbl_scope_parms(struct bnxt *bp,\n+\t\t\t  struct tf_alloc_tbl_scope_parms *params)\n+{\n+\tstruct bnxt_ulp_device_params\t*dparms;\n+\tuint32_t dev_id;\n+\tint rc;\n+\n+\trc = bnxt_ulp_cntxt_dev_id_get(&bp->ulp_ctx, &dev_id);\n+\tif (rc)\n+\t\t/* TBD: For now, just use default. */\n+\t\tdparms = 0;\n+\telse\n+\t\tdparms = bnxt_ulp_device_params_get(dev_id);\n+\n+\tif (!dparms) {\n+\t\tparams->rx_max_key_sz_in_bits = BNXT_ULP_DFLT_RX_MAX_KEY;\n+\t\tparams->rx_max_action_entry_sz_in_bits =\n+\t\t\tBNXT_ULP_DFLT_RX_MAX_ACTN_ENTRY;\n+\t\tparams->rx_mem_size_in_mb = BNXT_ULP_DFLT_RX_MEM;\n+\t\tparams->rx_num_flows_in_k = BNXT_ULP_RX_NUM_FLOWS;\n+\t\tparams->rx_tbl_if_id = BNXT_ULP_RX_TBL_IF_ID;\n+\n+\t\tparams->tx_max_key_sz_in_bits = BNXT_ULP_DFLT_TX_MAX_KEY;\n+\t\tparams->tx_max_action_entry_sz_in_bits =\n+\t\t\tBNXT_ULP_DFLT_TX_MAX_ACTN_ENTRY;\n+\t\tparams->tx_mem_size_in_mb = BNXT_ULP_DFLT_TX_MEM;\n+\t\tparams->tx_num_flows_in_k = BNXT_ULP_TX_NUM_FLOWS;\n+\t\tparams->tx_tbl_if_id = BNXT_ULP_TX_TBL_IF_ID;\n+\t} else {\n+\t\tparams->rx_max_key_sz_in_bits = BNXT_ULP_DFLT_RX_MAX_KEY;\n+\t\tparams->rx_max_action_entry_sz_in_bits =\n+\t\t\tBNXT_ULP_DFLT_RX_MAX_ACTN_ENTRY;\n+\t\tparams->rx_mem_size_in_mb = BNXT_ULP_DFLT_RX_MEM;\n+\t\tparams->rx_num_flows_in_k = dparms->num_flows / (1024);\n+\t\tparams->rx_tbl_if_id = BNXT_ULP_RX_TBL_IF_ID;\n+\n+\t\tparams->tx_max_key_sz_in_bits = BNXT_ULP_DFLT_TX_MAX_KEY;\n+\t\tparams->tx_max_action_entry_sz_in_bits =\n+\t\t\tBNXT_ULP_DFLT_TX_MAX_ACTN_ENTRY;\n+\t\tparams->tx_mem_size_in_mb = BNXT_ULP_DFLT_TX_MEM;\n+\t\tparams->tx_num_flows_in_k = dparms->num_flows / (1024);\n+\t\tparams->tx_tbl_if_id = BNXT_ULP_TX_TBL_IF_ID;\n+\t}\n+}\n+\n+/* Initialize Extended Exact Match host memory. */\n+static int32_t\n+ulp_eem_tbl_scope_init(struct bnxt *bp)\n+{\n+\tstruct tf_alloc_tbl_scope_parms params = {0};\n+\tint rc;\n+\n+\tbnxt_init_tbl_scope_parms(bp, &params);\n+\n+\trc = tf_alloc_tbl_scope(&bp->tfp, &params);\n+\tif (rc) {\n+\t\tBNXT_TF_DBG(ERR, \"Unable to allocate eem table scope rc = %d\\n\",\n+\t\t\t    rc);\n+\t\treturn rc;\n+\t}\n+\n+\trc = bnxt_ulp_cntxt_tbl_scope_id_set(&bp->ulp_ctx, params.tbl_scope_id);\n+\tif (rc) {\n+\t\tBNXT_TF_DBG(ERR, \"Unable to set table scope id\\n\");\n+\t\treturn rc;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+/* The function to free and deinit the ulp context data. */\n+static int32_t\n+ulp_ctx_deinit(struct bnxt *bp,\n+\t       struct bnxt_ulp_session_state *session)\n+{\n+\tif (!session || !bp) {\n+\t\tBNXT_TF_DBG(ERR, \"Invalid Arguments\\n\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\t/* Free the contents */\n+\tif (session->cfg_data) {\n+\t\trte_free(session->cfg_data);\n+\t\tbp->ulp_ctx.cfg_data = NULL;\n+\t\tsession->cfg_data = NULL;\n+\t}\n+\treturn 0;\n+}\n+\n+/* The function to allocate and initialize the ulp context data. */\n+static int32_t\n+ulp_ctx_init(struct bnxt *bp,\n+\t     struct bnxt_ulp_session_state *session)\n+{\n+\tstruct bnxt_ulp_data\t*ulp_data;\n+\tint32_t\t\t\trc = 0;\n+\n+\tif (!session || !bp) {\n+\t\tBNXT_TF_DBG(ERR, \"Invalid Arguments\\n\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\t/* Allocate memory to hold ulp context data. */\n+\tulp_data = rte_zmalloc(\"bnxt_ulp_data\",\n+\t\t\t       sizeof(struct bnxt_ulp_data), 0);\n+\tif (!ulp_data) {\n+\t\tBNXT_TF_DBG(ERR, \"Failed to allocate memory for ulp data\\n\");\n+\t\treturn -ENOMEM;\n+\t}\n+\n+\t/* Increment the ulp context data reference count usage. */\n+\tbp->ulp_ctx.cfg_data = ulp_data;\n+\tsession->cfg_data = ulp_data;\n+\tulp_data->ref_cnt++;\n+\n+\t/* Open the ulp session. */\n+\trc = ulp_ctx_session_open(bp, session);\n+\tif (rc) {\n+\t\t(void)ulp_ctx_deinit(bp, session);\n+\t\treturn rc;\n+\t}\n+\tbnxt_ulp_cntxt_tfp_set(&bp->ulp_ctx, session->g_tfp);\n+\treturn rc;\n+}\n+\n+static int32_t\n+ulp_ctx_attach(struct bnxt_ulp_context *ulp_ctx,\n+\t       struct bnxt_ulp_session_state *session)\n+{\n+\tif (!ulp_ctx || !session) {\n+\t\tBNXT_TF_DBG(ERR, \"Invalid Arguments\\n\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\t/* Increment the ulp context data reference count usage. */\n+\tulp_ctx->cfg_data = session->cfg_data;\n+\tulp_ctx->cfg_data->ref_cnt++;\n+\n+\t/* TBD call TF_session_attach. */\n+\tulp_ctx->g_tfp = session->g_tfp;\n+\treturn 0;\n+}\n+\n+/*\n+ * Initialize the state of an ULP session.\n+ * If the state of an ULP session is not initialized, set it's state to\n+ * initialized. If the state is already initialized, do nothing.\n+ */\n+static void\n+ulp_context_initialized(struct bnxt_ulp_session_state *session, bool *init)\n+{\n+\tpthread_mutex_lock(&session->bnxt_ulp_mutex);\n+\n+\tif (!session->bnxt_ulp_init) {\n+\t\tsession->bnxt_ulp_init = true;\n+\t\t*init = false;\n+\t} else {\n+\t\t*init = true;\n+\t}\n+\n+\tpthread_mutex_unlock(&session->bnxt_ulp_mutex);\n+}\n+\n+/*\n+ * Check if an ULP session is already allocated for a specific PCI\n+ * domain & bus. If it is already allocated simply return the session\n+ * pointer, otherwise allocate a new session.\n+ */\n+static struct bnxt_ulp_session_state *\n+ulp_get_session(struct rte_pci_addr *pci_addr)\n+{\n+\tstruct bnxt_ulp_session_state *session;\n+\n+\tSTAILQ_FOREACH(session, &bnxt_ulp_session_list, next) {\n+\t\tif (session->pci_info.domain == pci_addr->domain &&\n+\t\t    session->pci_info.bus == pci_addr->bus) {\n+\t\t\treturn session;\n+\t\t}\n+\t}\n+\treturn NULL;\n+}\n+\n+/*\n+ * Allocate and Initialize an ULP session and set it's state to INITIALIZED.\n+ * If it's already initialized simply return the already existing session.\n+ */\n+static struct bnxt_ulp_session_state *\n+ulp_session_init(struct bnxt *bp,\n+\t\t bool *init)\n+{\n+\tstruct rte_pci_device\t\t*pci_dev;\n+\tstruct rte_pci_addr\t\t*pci_addr;\n+\tstruct bnxt_ulp_session_state\t*session;\n+\n+\tif (!bp)\n+\t\treturn NULL;\n+\n+\tpci_dev = RTE_DEV_TO_PCI(bp->eth_dev->device);\n+\tpci_addr = &pci_dev->addr;\n+\n+\tpthread_mutex_lock(&bnxt_ulp_global_mutex);\n+\n+\tsession = ulp_get_session(pci_addr);\n+\tif (!session) {\n+\t\t/* Not Found the session  Allocate a new one */\n+\t\tsession = rte_zmalloc(\"bnxt_ulp_session\",\n+\t\t\t\t      sizeof(struct bnxt_ulp_session_state),\n+\t\t\t\t      0);\n+\t\tif (!session) {\n+\t\t\tBNXT_TF_DBG(ERR,\n+\t\t\t\t    \"Allocation failed for bnxt_ulp_session\\n\");\n+\t\t\tpthread_mutex_unlock(&bnxt_ulp_global_mutex);\n+\t\t\treturn NULL;\n+\n+\t\t} else {\n+\t\t\t/* Add it to the queue */\n+\t\t\tsession->pci_info.domain = pci_addr->domain;\n+\t\t\tsession->pci_info.bus = pci_addr->bus;\n+\t\t\tpthread_mutex_init(&session->bnxt_ulp_mutex, NULL);\n+\t\t\tSTAILQ_INSERT_TAIL(&bnxt_ulp_session_list,\n+\t\t\t\t\t   session, next);\n+\t\t}\n+\t}\n+\tulp_context_initialized(session, init);\n+\tpthread_mutex_unlock(&bnxt_ulp_global_mutex);\n+\treturn session;\n+}\n+\n+/*\n+ * When a port is initialized by dpdk. This functions is called\n+ * and this function initializes the ULP context and rest of the\n+ * infrastructure associated with it.\n+ */\n+int32_t\n+bnxt_ulp_init(struct bnxt *bp)\n+{\n+\tstruct bnxt_ulp_session_state *session;\n+\tbool init;\n+\tint rc;\n+\n+\t/*\n+\t * Multiple uplink ports can be associated with a single vswitch.\n+\t * Make sure only the port that is started first will initialize\n+\t * the TF session.\n+\t */\n+\tsession = ulp_session_init(bp, &init);\n+\tif (!session) {\n+\t\tBNXT_TF_DBG(ERR, \"Failed to initialize the tf session\\n\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\t/*\n+\t * If ULP is already initialized for a specific domain then simply\n+\t * assign the ulp context to this rte_eth_dev.\n+\t */\n+\tif (init) {\n+\t\trc = ulp_ctx_attach(&bp->ulp_ctx, session);\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}\n+\t\treturn rc;\n+\t}\n+\n+\t/* Allocate and Initialize the ulp context. */\n+\trc = ulp_ctx_init(bp, session);\n+\tif (rc) {\n+\t\tBNXT_TF_DBG(ERR, \"Failed to create the ulp context\\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+\t\tBNXT_TF_DBG(ERR, \"Failed to create the mark database\\n\");\n+\t\tgoto jump_to_error;\n+\t}\n+\n+\t/* Create the flow database. */\n+\trc = ulp_flow_db_init(&bp->ulp_ctx);\n+\tif (rc) {\n+\t\tBNXT_TF_DBG(ERR, \"Failed to create the flow database\\n\");\n+\t\tgoto jump_to_error;\n+\t}\n+\n+\t/* Create the eem table scope. */\n+\trc = ulp_eem_tbl_scope_init(bp);\n+\tif (rc) {\n+\t\tBNXT_TF_DBG(ERR, \"Failed to create the eem scope table\\n\");\n+\t\tgoto jump_to_error;\n+\t}\n+\n+\treturn rc;\n+\n+jump_to_error:\n+\treturn -ENOMEM;\n+}\n+\n+/* Below are the access functions to access internal data of ulp context. */\n+\n+/* Function to set the Mark DB into the context. */\n+int32_t\n+bnxt_ulp_cntxt_ptr2_mark_db_set(struct bnxt_ulp_context *ulp_ctx,\n+\t\t\t\tstruct bnxt_ulp_mark_tbl *mark_tbl)\n+{\n+\tif (!ulp_ctx || !ulp_ctx->cfg_data) {\n+\t\tBNXT_TF_DBG(ERR, \"Invalid ulp context data\\n\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tulp_ctx->cfg_data->mark_tbl = mark_tbl;\n+\n+\treturn 0;\n+}\n+\n+/* Function to retrieve the Mark DB from the context. */\n+struct bnxt_ulp_mark_tbl *\n+bnxt_ulp_cntxt_ptr2_mark_db_get(struct bnxt_ulp_context *ulp_ctx)\n+{\n+\tif (!ulp_ctx || !ulp_ctx->cfg_data)\n+\t\treturn NULL;\n+\n+\treturn ulp_ctx->cfg_data->mark_tbl;\n+}\n+\n+/* Function to set the device id of the hardware. */\n+int32_t\n+bnxt_ulp_cntxt_dev_id_set(struct bnxt_ulp_context *ulp_ctx,\n+\t\t\t  uint32_t dev_id)\n+{\n+\tif (ulp_ctx && ulp_ctx->cfg_data) {\n+\t\tulp_ctx->cfg_data->dev_id = dev_id;\n+\t\treturn 0;\n+\t}\n+\n+\treturn -EINVAL;\n+}\n+\n+/* Function to get the device id of the hardware. */\n+int32_t\n+bnxt_ulp_cntxt_dev_id_get(struct bnxt_ulp_context *ulp_ctx,\n+\t\t\t  uint32_t *dev_id)\n+{\n+\tif (ulp_ctx && ulp_ctx->cfg_data) {\n+\t\t*dev_id = ulp_ctx->cfg_data->dev_id;\n+\t\treturn 0;\n+\t}\n+\n+\treturn -EINVAL;\n+}\n+\n+/* Function to get the table scope id of the EEM table. */\n+int32_t\n+bnxt_ulp_cntxt_tbl_scope_id_get(struct bnxt_ulp_context *ulp_ctx,\n+\t\t\t\tuint32_t *tbl_scope_id)\n+{\n+\tif (ulp_ctx && ulp_ctx->cfg_data) {\n+\t\t*tbl_scope_id = ulp_ctx->cfg_data->tbl_scope_id;\n+\t\treturn 0;\n+\t}\n+\n+\treturn -EINVAL;\n+}\n+\n+/* Function to set the table scope id of the EEM table. */\n+int32_t\n+bnxt_ulp_cntxt_tbl_scope_id_set(struct bnxt_ulp_context *ulp_ctx,\n+\t\t\t\tuint32_t tbl_scope_id)\n+{\n+\tif (ulp_ctx && ulp_ctx->cfg_data) {\n+\t\tulp_ctx->cfg_data->tbl_scope_id = tbl_scope_id;\n+\t\treturn 0;\n+\t}\n+\n+\treturn -EINVAL;\n+}\n+\n+/* Function to set the tfp session details from the ulp context. */\n+int32_t\n+bnxt_ulp_cntxt_tfp_set(struct bnxt_ulp_context *ulp, struct tf *tfp)\n+{\n+\tif (!ulp) {\n+\t\tBNXT_TF_DBG(ERR, \"Invalid arguments\\n\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\t/* TBD The tfp should be removed once tf_attach is implemented. */\n+\tulp->g_tfp = tfp;\n+\treturn 0;\n+}\n+\n+/* Function to get the tfp session details from the ulp context. */\n+struct tf *\n+bnxt_ulp_cntxt_tfp_get(struct bnxt_ulp_context *ulp)\n+{\n+\tif (!ulp) {\n+\t\tBNXT_TF_DBG(ERR, \"Invalid arguments\\n\");\n+\t\treturn NULL;\n+\t}\n+\t/* TBD The tfp should be removed once tf_attach is implemented. */\n+\treturn ulp->g_tfp;\n+}\n+\n+/*\n+ * Get the device table entry based on the device id.\n+ *\n+ * dev_id [in] The device id of the hardware\n+ *\n+ * Returns the pointer to the device parameters.\n+ */\n+struct bnxt_ulp_device_params *\n+bnxt_ulp_device_params_get(uint32_t dev_id)\n+{\n+\tif (dev_id < BNXT_ULP_MAX_NUM_DEVICES)\n+\t\treturn &ulp_device_params[dev_id];\n+\treturn NULL;\n+}\n+\n+/* Function to set the flow database to the ulp context. */\n+int32_t\n+bnxt_ulp_cntxt_ptr2_flow_db_set(struct bnxt_ulp_context\t*ulp_ctx,\n+\t\t\t\tstruct bnxt_ulp_flow_db\t*flow_db)\n+{\n+\tif (!ulp_ctx || !ulp_ctx->cfg_data) {\n+\t\tBNXT_TF_DBG(ERR, \"Invalid ulp context data\\n\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tulp_ctx->cfg_data->flow_db = flow_db;\n+\treturn 0;\n+}\n+\n+/* Function to get the flow database from the ulp context. */\n+struct bnxt_ulp_flow_db\t*\n+bnxt_ulp_cntxt_ptr2_flow_db_get(struct bnxt_ulp_context\t*ulp_ctx)\n+{\n+\tif (!ulp_ctx || !ulp_ctx->cfg_data) {\n+\t\tBNXT_TF_DBG(ERR, \"Invalid ulp context data\\n\");\n+\t\treturn NULL;\n+\t}\n+\n+\treturn ulp_ctx->cfg_data->flow_db;\n+}\n+\n+/* Function to get the ulp context from eth device. */\n+struct bnxt_ulp_context\t*\n+bnxt_ulp_eth_dev_ptr2_cntxt_get(struct rte_eth_dev\t*dev)\n+{\n+\tstruct bnxt\t*bp;\n+\n+\tbp = (struct bnxt *)dev->data->dev_private;\n+\tif (!bp) {\n+\t\tBNXT_TF_DBG(ERR, \"Bnxt private data is not initialized\\n\");\n+\t\treturn NULL;\n+\t}\n+\treturn &bp->ulp_ctx;\n+}\ndiff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp.h b/drivers/net/bnxt/tf_ulp/bnxt_ulp.h\nnew file mode 100644\nindex 0000000..d88225f\n--- /dev/null\n+++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp.h\n@@ -0,0 +1,100 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2019-2020 Broadcom\n+ * All rights reserved.\n+ */\n+\n+#ifndef _BNXT_ULP_H_\n+#define _BNXT_ULP_H_\n+\n+#include <inttypes.h>\n+#include <stdbool.h>\n+#include <sys/queue.h>\n+\n+#include \"rte_ethdev.h\"\n+\n+struct bnxt_ulp_data {\n+\tuint32_t\t\t\ttbl_scope_id;\n+\tstruct bnxt_ulp_mark_tbl\t*mark_tbl;\n+\tuint32_t\t\t\tdev_id; /* Hardware device id */\n+\tuint32_t\t\t\tref_cnt;\n+\tstruct bnxt_ulp_flow_db\t\t*flow_db;\n+};\n+\n+struct bnxt_ulp_context {\n+\tstruct bnxt_ulp_data\t*cfg_data;\n+\t/* TBD The tfp should be removed once tf_attach is implemented. */\n+\tstruct tf\t\t*g_tfp;\n+};\n+\n+struct bnxt_ulp_pci_info {\n+\tuint32_t\tdomain;\n+\tuint8_t\t\tbus;\n+};\n+\n+struct bnxt_ulp_session_state {\n+\tSTAILQ_ENTRY(bnxt_ulp_session_state)\tnext;\n+\tbool\t\t\t\t\tbnxt_ulp_init;\n+\tpthread_mutex_t\t\t\t\tbnxt_ulp_mutex;\n+\tstruct bnxt_ulp_pci_info\t\tpci_info;\n+\tstruct bnxt_ulp_data\t\t\t*cfg_data;\n+\t/* TBD The tfp should be removed once tf_attach is implemented. */\n+\tstruct tf\t\t\t\t*g_tfp;\n+\tuint32_t\t\t\t\tsession_opened;\n+};\n+\n+/* ULP flow id structure */\n+struct rte_tf_flow {\n+\tuint32_t\tflow_id;\n+};\n+\n+/* Function to set the device id of the hardware. */\n+int32_t\n+bnxt_ulp_cntxt_dev_id_set(struct bnxt_ulp_context *ulp_ctx, uint32_t dev_id);\n+\n+/* Function to get the device id of the hardware. */\n+int32_t\n+bnxt_ulp_cntxt_dev_id_get(struct bnxt_ulp_context *ulp_ctx, uint32_t *dev_id);\n+\n+/* Function to set the table scope id of the EEM table. */\n+int32_t\n+bnxt_ulp_cntxt_tbl_scope_id_set(struct bnxt_ulp_context *ulp_ctx,\n+\t\t\t\tuint32_t tbl_scope_id);\n+\n+/* Function to get the table scope id of the EEM table. */\n+int32_t\n+bnxt_ulp_cntxt_tbl_scope_id_get(struct bnxt_ulp_context *ulp_ctx,\n+\t\t\t\tuint32_t *tbl_scope_id);\n+\n+/* Function to set the tfp session details in the ulp context. */\n+int32_t\n+bnxt_ulp_cntxt_tfp_set(struct bnxt_ulp_context *ulp, struct tf *tfp);\n+\n+/* Function to get the tfp session details from ulp context. */\n+struct tf *\n+bnxt_ulp_cntxt_tfp_get(struct bnxt_ulp_context *ulp);\n+\n+/* Get the device table entry based on the device id. */\n+struct bnxt_ulp_device_params *\n+bnxt_ulp_device_params_get(uint32_t dev_id);\n+\n+int32_t\n+bnxt_ulp_ctxt_ptr2_mark_db_set(struct bnxt_ulp_context *ulp_ctx,\n+\t\t\t       struct bnxt_ulp_mark_tbl *mark_tbl);\n+\n+struct bnxt_ulp_mark_tbl *\n+bnxt_ulp_ctxt_ptr2_mark_db_get(struct bnxt_ulp_context *ulp_ctx);\n+\n+/* Function to set the flow database to the ulp context. */\n+int32_t\n+bnxt_ulp_cntxt_ptr2_flow_db_set(struct bnxt_ulp_context\t*ulp_ctx,\n+\t\t\t\tstruct bnxt_ulp_flow_db\t*flow_db);\n+\n+/* Function to get the flow database from the ulp context. */\n+struct bnxt_ulp_flow_db\t*\n+bnxt_ulp_cntxt_ptr2_flow_db_get(struct bnxt_ulp_context\t*ulp_ctx);\n+\n+/* Function to get the ulp context from eth device. */\n+struct bnxt_ulp_context\t*\n+bnxt_ulp_eth_dev_ptr2_cntxt_get(struct rte_eth_dev *dev);\n+\n+#endif /* _BNXT_ULP_H_ */\ndiff --git a/drivers/net/bnxt/tf_ulp/ulp_flow_db.c b/drivers/net/bnxt/tf_ulp/ulp_flow_db.c\nnew file mode 100644\nindex 0000000..3dd39c1\n--- /dev/null\n+++ b/drivers/net/bnxt/tf_ulp/ulp_flow_db.c\n@@ -0,0 +1,187 @@\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_tf_common.h\"\n+#include \"ulp_flow_db.h\"\n+#include \"ulp_template_struct.h\"\n+\n+/*\n+ * Helper function to allocate the flow table and initialize\n+ * the stack for allocation operations.\n+ *\n+ * flow_db [in] Ptr to flow database structure\n+ * tbl_idx [in] The index to table creation.\n+ *\n+ * Returns 0 on success or negative number on failure.\n+ */\n+static int32_t\n+ulp_flow_db_alloc_resource(struct bnxt_ulp_flow_db *flow_db,\n+\t\t\t   enum bnxt_ulp_flow_db_tables tbl_idx)\n+{\n+\tuint32_t\t\t\tidx = 0;\n+\tstruct bnxt_ulp_flow_tbl\t*flow_tbl;\n+\tuint32_t\t\t\tsize;\n+\n+\tflow_tbl = &flow_db->flow_tbl[tbl_idx];\n+\n+\tsize = sizeof(struct ulp_fdb_resource_info) * flow_tbl->num_resources;\n+\tflow_tbl->flow_resources =\n+\t\t\trte_zmalloc(\"ulp_fdb_resource_info\", size, 0);\n+\n+\tif (!flow_tbl->flow_resources) {\n+\t\tBNXT_TF_DBG(ERR, \"Failed to alloc memory for flow table\\n\");\n+\t\treturn -ENOMEM;\n+\t}\n+\tsize = sizeof(uint32_t) * flow_tbl->num_resources;\n+\tflow_tbl->flow_tbl_stack = rte_zmalloc(\"flow_tbl_stack\", size, 0);\n+\tif (!flow_tbl->flow_tbl_stack) {\n+\t\tBNXT_TF_DBG(ERR, \"Failed to alloc memory flow tbl stack\\n\");\n+\t\treturn -ENOMEM;\n+\t}\n+\tsize = (flow_tbl->num_flows / sizeof(uint64_t)) + 1;\n+\tflow_tbl->active_flow_tbl = rte_zmalloc(\"active flow tbl\", size, 0);\n+\tif (!flow_tbl->active_flow_tbl) {\n+\t\tBNXT_TF_DBG(ERR, \"Failed to alloc memory active tbl\\n\");\n+\t\treturn -ENOMEM;\n+\t}\n+\n+\t/* Initialize the stack table. */\n+\tfor (idx = 0; idx < flow_tbl->num_resources; idx++)\n+\t\tflow_tbl->flow_tbl_stack[idx] = idx;\n+\n+\t/* Ignore the first element in the list. */\n+\tflow_tbl->head_index = 1;\n+\t/* Tail points to the last entry in the list. */\n+\tflow_tbl->tail_index = flow_tbl->num_resources - 1;\n+\treturn 0;\n+}\n+\n+/*\n+ * Helper function to de allocate the flow table.\n+ *\n+ * flow_db [in] Ptr to flow database structure\n+ * tbl_idx [in] The index to table creation.\n+ *\n+ * Returns none.\n+ */\n+static void\n+ulp_flow_db_dealloc_resource(struct bnxt_ulp_flow_db *flow_db,\n+\t\t\t     enum bnxt_ulp_flow_db_tables tbl_idx)\n+{\n+\tstruct bnxt_ulp_flow_tbl\t*flow_tbl;\n+\n+\tflow_tbl = &flow_db->flow_tbl[tbl_idx];\n+\n+\t/* Free all the allocated tables in the flow table. */\n+\tif (flow_tbl->active_flow_tbl) {\n+\t\trte_free(flow_tbl->active_flow_tbl);\n+\t\tflow_tbl->active_flow_tbl = NULL;\n+\t}\n+\n+\tif (flow_tbl->flow_tbl_stack) {\n+\t\trte_free(flow_tbl->flow_tbl_stack);\n+\t\tflow_tbl->flow_tbl_stack = NULL;\n+\t}\n+\n+\tif (flow_tbl->flow_resources) {\n+\t\trte_free(flow_tbl->flow_resources);\n+\t\tflow_tbl->flow_resources = NULL;\n+\t}\n+}\n+\n+/*\n+ * Initialize the flow database. Memory is allocated in this\n+ * call and assigned to the flow 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_flow_db_init(struct bnxt_ulp_context *ulp_ctxt)\n+{\n+\tstruct bnxt_ulp_device_params\t\t*dparms;\n+\tstruct bnxt_ulp_flow_tbl\t\t*flow_tbl;\n+\tstruct bnxt_ulp_flow_db\t\t\t*flow_db;\n+\tuint32_t\t\t\t\tdev_id;\n+\n+\t/* Get the dev specific number of flows that needed to be supported. */\n+\tif (bnxt_ulp_cntxt_dev_id_get(ulp_ctxt, &dev_id)) {\n+\t\tBNXT_TF_DBG(ERR, \"Invalid device id\\n\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tdparms = bnxt_ulp_device_params_get(dev_id);\n+\tif (!dparms) {\n+\t\tBNXT_TF_DBG(ERR, \"could not fetch the device params\\n\");\n+\t\treturn -ENODEV;\n+\t}\n+\n+\tflow_db = rte_zmalloc(\"bnxt_ulp_flow_db\",\n+\t\t\t      sizeof(struct bnxt_ulp_flow_db), 0);\n+\tif (!flow_db) {\n+\t\tBNXT_TF_DBG(ERR,\n+\t\t\t    \"Failed to allocate memory for flow table ptr\\n\");\n+\t\tgoto error_free;\n+\t}\n+\n+\t/* Attach the flow database to the ulp context. */\n+\tbnxt_ulp_cntxt_ptr2_flow_db_set(ulp_ctxt, flow_db);\n+\n+\t/* Populate the regular flow table limits. */\n+\tflow_tbl = &flow_db->flow_tbl[BNXT_ULP_REGULAR_FLOW_TABLE];\n+\tflow_tbl->num_flows = dparms->num_flows + 1;\n+\tflow_tbl->num_resources = (flow_tbl->num_flows *\n+\t\t\t\t   dparms->num_resources_per_flow);\n+\n+\t/* Populate the default flow table limits. */\n+\tflow_tbl = &flow_db->flow_tbl[BNXT_ULP_DEFAULT_FLOW_TABLE];\n+\tflow_tbl->num_flows = BNXT_FLOW_DB_DEFAULT_NUM_FLOWS + 1;\n+\tflow_tbl->num_resources = (flow_tbl->num_flows *\n+\t\t\t\t   BNXT_FLOW_DB_DEFAULT_NUM_RESOURCES);\n+\n+\t/* Allocate the resource for the regular flow table. */\n+\tif (ulp_flow_db_alloc_resource(flow_db, BNXT_ULP_REGULAR_FLOW_TABLE))\n+\t\tgoto error_free;\n+\tif (ulp_flow_db_alloc_resource(flow_db, BNXT_ULP_DEFAULT_FLOW_TABLE))\n+\t\tgoto error_free;\n+\n+\t/* All good so return. */\n+\treturn 0;\n+error_free:\n+\tulp_flow_db_deinit(ulp_ctxt);\n+\treturn -ENOMEM;\n+}\n+\n+/*\n+ * Deinitialize the flow database. Memory is deallocated in\n+ * this call and all flows should have been purged before this\n+ * call.\n+ *\n+ * ulp_ctxt [in] Ptr to ulp context\n+ *\n+ * Returns 0 on success.\n+ */\n+int32_t\tulp_flow_db_deinit(struct bnxt_ulp_context *ulp_ctxt)\n+{\n+\tstruct bnxt_ulp_flow_db\t\t\t*flow_db;\n+\n+\tflow_db = bnxt_ulp_cntxt_ptr2_flow_db_get(ulp_ctxt);\n+\tif (!flow_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_flow_db_set(ulp_ctxt, NULL);\n+\n+\t/* Free up all the memory. */\n+\tulp_flow_db_dealloc_resource(flow_db, BNXT_ULP_REGULAR_FLOW_TABLE);\n+\tulp_flow_db_dealloc_resource(flow_db, BNXT_ULP_DEFAULT_FLOW_TABLE);\n+\trte_free(flow_db);\n+\n+\treturn 0;\n+}\ndiff --git a/drivers/net/bnxt/tf_ulp/ulp_flow_db.h b/drivers/net/bnxt/tf_ulp/ulp_flow_db.h\nnew file mode 100644\nindex 0000000..a2ee8fa\n--- /dev/null\n+++ b/drivers/net/bnxt/tf_ulp/ulp_flow_db.h\n@@ -0,0 +1,77 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2014-2019 Broadcom\n+ * All rights reserved.\n+ */\n+\n+#ifndef _ULP_FLOW_DB_H_\n+#define _ULP_FLOW_DB_H_\n+\n+#include \"bnxt_ulp.h\"\n+#include \"ulp_template_db.h\"\n+\n+#define BNXT_FLOW_DB_DEFAULT_NUM_FLOWS\t\t128\n+#define BNXT_FLOW_DB_DEFAULT_NUM_RESOURCES\t5\n+\n+/* Structure for the flow database resource information. */\n+struct ulp_fdb_resource_info {\n+\t/* Points to next resource in the chained list. */\n+\tuint32_t\tnxt_resource_idx;\n+\tunion {\n+\t\tuint64_t\tresource_em_handle;\n+\t\tstruct {\n+\t\t\tuint32_t\tresource_type;\n+\t\t\tuint32_t\tresource_hndl;\n+\t\t};\n+\t};\n+};\n+\n+/* Structure for the flow database resource information. */\n+struct bnxt_ulp_flow_tbl {\n+\t/* Flow tbl is the resource object list for each flow id. */\n+\tstruct ulp_fdb_resource_info\t*flow_resources;\n+\n+\t/* Flow table stack to track free list of resources. */\n+\tuint32_t\t*flow_tbl_stack;\n+\tuint32_t\thead_index;\n+\tuint32_t\ttail_index;\n+\n+\t/* Table to track the active flows. */\n+\tuint64_t\t*active_flow_tbl;\n+\tuint32_t\tnum_flows;\n+\tuint32_t\tnum_resources;\n+};\n+\n+/* Flow database supports two tables. */\n+enum bnxt_ulp_flow_db_tables {\n+\tBNXT_ULP_REGULAR_FLOW_TABLE,\n+\tBNXT_ULP_DEFAULT_FLOW_TABLE,\n+\tBNXT_ULP_FLOW_TABLE_MAX\n+};\n+\n+/* Structure for the flow database resource information. */\n+struct bnxt_ulp_flow_db {\n+\tstruct bnxt_ulp_flow_tbl\tflow_tbl[BNXT_ULP_FLOW_TABLE_MAX];\n+};\n+\n+/*\n+ * Initialize the flow database. Memory is allocated in this\n+ * call and assigned to the flow 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_flow_db_init(struct bnxt_ulp_context *ulp_ctxt);\n+\n+/*\n+ * Deinitialize the flow database. Memory is deallocated in\n+ * this call and all flows should have been purged before this\n+ * call.\n+ *\n+ * ulp_ctxt [in] Ptr to ulp context\n+ *\n+ * Returns 0 on success.\n+ */\n+int32_t\tulp_flow_db_deinit(struct bnxt_ulp_context *ulp_ctxt);\n+\n+#endif /* _ULP_FLOW_DB_H_ */\ndiff --git a/drivers/net/bnxt/tf_ulp/ulp_mark_mgr.c b/drivers/net/bnxt/tf_ulp/ulp_mark_mgr.c\nnew file mode 100644\nindex 0000000..3f28a73\n--- /dev/null\n+++ b/drivers/net/bnxt/tf_ulp/ulp_mark_mgr.c\n@@ -0,0 +1,94 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2014-2020 Broadcom\n+ * All rights reserved.\n+ */\n+\n+#include <rte_common.h>\n+#include <rte_malloc.h>\n+#include <rte_log.h>\n+#include \"bnxt_ulp.h\"\n+#include \"tf_ext_flow_handle.h\"\n+#include \"ulp_mark_mgr.h\"\n+#include \"bnxt_tf_common.h\"\n+#include \"../bnxt.h\"\n+#include \"ulp_template_db.h\"\n+#include \"ulp_template_struct.h\"\n+\n+/*\n+ * Allocate and Initialize all Mark Manager resources for this ulp context.\n+ *\n+ * ctxt [in] The ulp context for the mark manager.\n+ *\n+ */\n+int32_t\n+ulp_mark_db_init(struct bnxt_ulp_context *ctxt)\n+{\n+\tstruct bnxt_ulp_device_params *dparms;\n+\tstruct bnxt_ulp_mark_tbl *mark_tbl = NULL;\n+\tuint32_t dev_id;\n+\n+\tif (!ctxt) {\n+\t\tBNXT_TF_DBG(DEBUG, \"Invalid ULP CTXT\\n\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tif (bnxt_ulp_cntxt_dev_id_get(ctxt, &dev_id)) {\n+\t\tBNXT_TF_DBG(DEBUG, \"Failed to get device id\\n\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tdparms = bnxt_ulp_device_params_get(dev_id);\n+\tif (!dparms) {\n+\t\tBNXT_TF_DBG(DEBUG, \"Failed to device parms\\n\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tmark_tbl = rte_zmalloc(\"ulp_rx_mark_tbl_ptr\",\n+\t\t\t       sizeof(struct bnxt_ulp_mark_tbl), 0);\n+\tif (!mark_tbl)\n+\t\tgoto mem_error;\n+\n+\t/* Need to allocate 2 * Num flows to account for hash type bit. */\n+\tmark_tbl->lfid_tbl = rte_zmalloc(\"ulp_rx_em_flow_mark_table\",\n+\t\t\t\t\t dparms->lfid_entries *\n+\t\t\t\t\t    sizeof(struct bnxt_lfid_mark_info),\n+\t\t\t\t\t 0);\n+\n+\tif (!mark_tbl->lfid_tbl)\n+\t\tgoto mem_error;\n+\n+\t/* Need to allocate 2 * Num flows to account for hash type bit. */\n+\tmark_tbl->gfid_tbl = rte_zmalloc(\"ulp_rx_eem_flow_mark_table\",\n+\t\t\t\t\t 2 * dparms->num_flows *\n+\t\t\t\t\t    sizeof(struct bnxt_gfid_mark_info),\n+\t\t\t\t\t 0);\n+\tif (!mark_tbl->gfid_tbl)\n+\t\tgoto mem_error;\n+\n+\t/*\n+\t * TBD: This needs to be generalized for better mark handling\n+\t * These values are used to compress the FID to the allowable index\n+\t * space.  The FID from hw may be the full hash.\n+\t */\n+\tmark_tbl->gfid_max\t= dparms->gfid_entries - 1;\n+\tmark_tbl->gfid_mask\t= (dparms->gfid_entries / 2) - 1;\n+\tmark_tbl->gfid_type_bit = (dparms->gfid_entries / 2);\n+\n+\tBNXT_TF_DBG(DEBUG, \"GFID Max = 0x%08x\\nGFID MASK = 0x%08x\\n\",\n+\t\t    mark_tbl->gfid_max,\n+\t\t    mark_tbl->gfid_mask);\n+\n+\t/* Add the mart tbl to the ulp context. */\n+\tbnxt_ulp_cntxt_ptr2_mark_db_set(ctxt, mark_tbl);\n+\n+\treturn 0;\n+\n+mem_error:\n+\trte_free(mark_tbl->gfid_tbl);\n+\trte_free(mark_tbl->lfid_tbl);\n+\trte_free(mark_tbl);\n+\tBNXT_TF_DBG(DEBUG,\n+\t\t    \"Failed to allocate memory for mark mgr\\n\");\n+\n+\treturn -ENOMEM;\n+}\ndiff --git a/drivers/net/bnxt/tf_ulp/ulp_mark_mgr.h b/drivers/net/bnxt/tf_ulp/ulp_mark_mgr.h\nnew file mode 100644\nindex 0000000..b175abd\n--- /dev/null\n+++ b/drivers/net/bnxt/tf_ulp/ulp_mark_mgr.h\n@@ -0,0 +1,49 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2014-2019 Broadcom\n+ * All rights reserved.\n+ */\n+\n+#ifndef _ULP_MARK_MGR_H_\n+#define _ULP_MARK_MGR_H_\n+\n+#include \"bnxt_ulp.h\"\n+\n+#define ULP_MARK_INVALID (0)\n+struct bnxt_lfid_mark_info {\n+\tuint16_t\tmark_id;\n+\tbool\t\tvalid;\n+};\n+\n+struct bnxt_gfid_mark_info {\n+\tuint32_t\tmark_id;\n+\tbool\t\tvalid;\n+};\n+\n+struct bnxt_ulp_mark_tbl {\n+\tstruct bnxt_lfid_mark_info\t*lfid_tbl;\n+\tstruct bnxt_gfid_mark_info\t*gfid_tbl;\n+\tuint32_t\t\t\tgfid_mask;\n+\tuint32_t\t\t\tgfid_type_bit;\n+\tuint32_t\t\t\tgfid_max;\n+};\n+\n+/*\n+ * Allocate and Initialize all Mark Manager resources for this ulp context.\n+ *\n+ * Initialize MARK database for GFID & LFID tables\n+ * GFID: Global flow id which is based on EEM hash id.\n+ * LFID: Local flow id which is the CFA action pointer.\n+ * GFID is used for EEM flows, LFID is used for EM flows.\n+ *\n+ * Flow mapper modules adds mark_id in the MARK database.\n+ *\n+ * BNXT PMD receive handler extracts the hardware flow id from the\n+ * received completion record. Fetches mark_id from the MARK\n+ * database using the flow id. Injects mark_id into the packet's mbuf.\n+ *\n+ * ctxt [in] The ulp context for the mark manager.\n+ */\n+int32_t\n+ulp_mark_db_init(struct bnxt_ulp_context *ctxt);\n+\n+#endif /* _ULP_MARK_MGR_H_ */\ndiff --git a/drivers/net/bnxt/tf_ulp/ulp_template_db.c b/drivers/net/bnxt/tf_ulp/ulp_template_db.c\nnew file mode 100644\nindex 0000000..9670635\n--- /dev/null\n+++ b/drivers/net/bnxt/tf_ulp/ulp_template_db.c\n@@ -0,0 +1,27 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2014-2019 Broadcom\n+ * All rights reserved.\n+ */\n+\n+/*\n+ * date: Mon Mar  9 02:37:53 2020\n+ * version: 0.0\n+ */\n+\n+#include \"ulp_template_db.h\"\n+#include \"ulp_template_struct.h\"\n+\n+struct bnxt_ulp_device_params ulp_device_params[] = {\n+\t[BNXT_ULP_DEVICE_ID_WH_PLUS] = {\n+\t\t.global_fid_enable       = BNXT_ULP_SYM_YES,\n+\t\t.byte_order              = (enum bnxt_ulp_byte_order)\n+\t\t\t\t\t\tBNXT_ULP_SYM_LITTLE_ENDIAN,\n+\t\t.encap_byte_swap         = 1,\n+\t\t.lfid_entries            = 16384,\n+\t\t.lfid_entry_size         = 4,\n+\t\t.gfid_entries            = 65536,\n+\t\t.gfid_entry_size         = 4,\n+\t\t.num_flows               = 32768,\n+\t\t.num_resources_per_flow  = 8\n+\t}\n+};\ndiff --git a/drivers/net/bnxt/tf_ulp/ulp_template_db.h b/drivers/net/bnxt/tf_ulp/ulp_template_db.h\nnew file mode 100644\nindex 0000000..ba2a101\n--- /dev/null\n+++ b/drivers/net/bnxt/tf_ulp/ulp_template_db.h\n@@ -0,0 +1,35 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2014-2019 Broadcom\n+ * All rights reserved.\n+ */\n+\n+/*\n+ * date: Mon Mar  9 02:37:53 2020\n+ * version: 0.0\n+ */\n+\n+#ifndef ULP_TEMPLATE_DB_H_\n+#define ULP_TEMPLATE_DB_H_\n+\n+#define BNXT_ULP_MAX_NUM_DEVICES 4\n+\n+enum bnxt_ulp_byte_order {\n+\tBNXT_ULP_BYTE_ORDER_BE,\n+\tBNXT_ULP_BYTE_ORDER_LE,\n+\tBNXT_ULP_BYTE_ORDER_LAST\n+};\n+\n+enum bnxt_ulp_device_id {\n+\tBNXT_ULP_DEVICE_ID_WH_PLUS,\n+\tBNXT_ULP_DEVICE_ID_THOR,\n+\tBNXT_ULP_DEVICE_ID_STINGRAY,\n+\tBNXT_ULP_DEVICE_ID_STINGRAY2,\n+\tBNXT_ULP_DEVICE_ID_LAST\n+};\n+\n+enum bnxt_ulp_sym {\n+\tBNXT_ULP_SYM_LITTLE_ENDIAN = 1,\n+\tBNXT_ULP_SYM_YES = 1\n+};\n+\n+#endif /* _ULP_TEMPLATE_DB_H_ */\ndiff --git a/drivers/net/bnxt/tf_ulp/ulp_template_struct.h b/drivers/net/bnxt/tf_ulp/ulp_template_struct.h\nnew file mode 100644\nindex 0000000..4b9d0b2\n--- /dev/null\n+++ b/drivers/net/bnxt/tf_ulp/ulp_template_struct.h\n@@ -0,0 +1,40 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2014-2019 Broadcom\n+ * All rights reserved.\n+ */\n+\n+#ifndef _ULP_TEMPLATE_STRUCT_H_\n+#define _ULP_TEMPLATE_STRUCT_H_\n+\n+#include <stdint.h>\n+#include \"rte_ether.h\"\n+#include \"rte_icmp.h\"\n+#include \"rte_ip.h\"\n+#include \"rte_tcp.h\"\n+#include \"rte_udp.h\"\n+#include \"rte_esp.h\"\n+#include \"rte_sctp.h\"\n+#include \"rte_flow.h\"\n+#include \"tf_core.h\"\n+\n+/* Device specific parameters. */\n+struct bnxt_ulp_device_params {\n+\tuint8_t\t\t\t\tdescription[16];\n+\tuint32_t\t\t\tglobal_fid_enable;\n+\tenum bnxt_ulp_byte_order\tbyte_order;\n+\tuint8_t\t\t\t\tencap_byte_swap;\n+\tuint32_t\t\t\tlfid_entries;\n+\tuint32_t\t\t\tlfid_entry_size;\n+\tuint64_t\t\t\tgfid_entries;\n+\tuint32_t\t\t\tgfid_entry_size;\n+\tuint64_t\t\t\tnum_flows;\n+\tuint32_t\t\t\tnum_resources_per_flow;\n+};\n+\n+/*\n+ * The ulp_device_params is indexed by the dev_id.\n+ * This table maintains the device specific parameters.\n+ */\n+extern struct bnxt_ulp_device_params ulp_device_params[];\n+\n+#endif /* _ULP_TEMPLATE_STRUCT_H_ */\n",
    "prefixes": [
        "v3",
        "16/34"
    ]
}