get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 94103,
    "url": "https://patches.dpdk.org/api/patches/94103/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/20210613000652.28191-10-ajit.khaparde@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": "<20210613000652.28191-10-ajit.khaparde@broadcom.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20210613000652.28191-10-ajit.khaparde@broadcom.com",
    "date": "2021-06-13T00:06:03",
    "name": "[v2,09/58] net/bnxt: add Thor WC TCAM support",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "abf4a20a7ffa99dead9486abf54474179b0658ec",
    "submitter": {
        "id": 501,
        "url": "https://patches.dpdk.org/api/people/501/?format=api",
        "name": "Ajit Khaparde",
        "email": "ajit.khaparde@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/20210613000652.28191-10-ajit.khaparde@broadcom.com/mbox/",
    "series": [
        {
            "id": 17305,
            "url": "https://patches.dpdk.org/api/series/17305/?format=api",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=17305",
            "date": "2021-06-13T00:05:54",
            "name": "enhancements to host based flow table management",
            "version": 2,
            "mbox": "https://patches.dpdk.org/series/17305/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/94103/comments/",
    "check": "success",
    "checks": "https://patches.dpdk.org/api/patches/94103/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 mails.dpdk.org (mails.dpdk.org [217.70.189.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id A5983A0C41;\n\tSun, 13 Jun 2021 02:08:12 +0200 (CEST)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 74D2F41150;\n\tSun, 13 Jun 2021 02:07:13 +0200 (CEST)",
            "from mail-pl1-f177.google.com (mail-pl1-f177.google.com\n [209.85.214.177])\n by mails.dpdk.org (Postfix) with ESMTP id 057AD4114C\n for <dev@dpdk.org>; Sun, 13 Jun 2021 02:07:10 +0200 (CEST)",
            "by mail-pl1-f177.google.com with SMTP id e7so4685453plj.7\n for <dev@dpdk.org>; Sat, 12 Jun 2021 17:07:10 -0700 (PDT)",
            "from localhost.localdomain ([192.19.223.252])\n by smtp.gmail.com with ESMTPSA id gg22sm12774609pjb.17.2021.06.12.17.07.08\n (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128);\n Sat, 12 Jun 2021 17:07:08 -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 :mime-version; bh=UjKf7dMLXKblWk4DPaw9h4yhS8Kv6b1SoB6E+HUG5KQ=;\n b=d2L+cqNaV3geeA9OvjIijSe5fm1UxTjhz0xwQ0RCwmK1G43MStIsQk4vgmJsETooZz\n B3/yyW7yLD4qzrebScsGdZtP3Zg7tw9V+yuzS5fKaedmAq/jGR+0bH2dd5AnE48jbI+z\n b2m2LWvJgcrGcaQ9MHKfZo/oKE4xhU7jsoH4w=",
        "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:mime-version;\n bh=UjKf7dMLXKblWk4DPaw9h4yhS8Kv6b1SoB6E+HUG5KQ=;\n b=WN9J3ZweUCx5JJdqgHpId4xCvYP0Iof/WyxHb9QxJTzab6PvomXf8dvAGNvh8ejH2W\n Nam2uHg2HHHYW0lRm9bC5L2WdIv1ZaKW6FVu4diSd5ZaXlXmbSoB3ytSbZjR5t7lxRr4\n /j4ey7W0ieUXkWjBSbdWZbbgRawnPsFA4d1Sy4v/m5neKpKhCZ+AM1Dw5Zo4PhTlzaNA\n tEyVBVeqIOLp5OuZhS7dZs1/pb36G7D+PYYrGDLCyrq80fcH8N5dcBZr1b5yOB32jlqm\n IJmElulQldJe6qGqrLNTUrvhQycnmTlbbL0CYI01lhr4X5LDUc316RGcUekXZshFwGuF\n FXDQ==",
        "X-Gm-Message-State": "AOAM531JYidWCcfEkfylE9TuQ9AaNOtbjHT9NJXoey08rCPl9xxSyaqD\n DIrRPk5Uyaw7F8uTf8mszjX1T6Eyjc4a2d8Fjqasm67gi1zd1Buyl1CVAs8zxpbr+PwOQtUjKUb\n AHZ6D42dZaJjQZifqMFgSJoPeS79+H0fBDnI9di40AYvxYL41dpD64zTGY3NZeEo=",
        "X-Google-Smtp-Source": "\n ABdhPJw+YKq/z9HmUwZf97826z4z+3vEn+xginkGG1NJIR7PEkYEDUC8bG7m8P5OkQKaBjxKx6Llbg==",
        "X-Received": "by 2002:a17:90a:ad85:: with SMTP id\n s5mr11698877pjq.230.1623542829443;\n Sat, 12 Jun 2021 17:07:09 -0700 (PDT)",
        "From": "Ajit Khaparde <ajit.khaparde@broadcom.com>",
        "To": "dev@dpdk.org",
        "Cc": "Jay Ding <jay.ding@broadcom.com>,\n Randy Schacher <stuart.schacher@broadcom.com>,\n Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>,\n Farah Smith <farah.smith@broadcom.com>",
        "Date": "Sat, 12 Jun 2021 17:06:03 -0700",
        "Message-Id": "<20210613000652.28191-10-ajit.khaparde@broadcom.com>",
        "X-Mailer": "git-send-email 2.21.1 (Apple Git-122.3)",
        "In-Reply-To": "<20210613000652.28191-1-ajit.khaparde@broadcom.com>",
        "References": "<20210530085929.29695-1-venkatkumar.duvvuru@broadcom.com>\n <20210613000652.28191-1-ajit.khaparde@broadcom.com>",
        "MIME-Version": "1.0",
        "Content-Type": "multipart/signed; protocol=\"application/pkcs7-signature\";\n micalg=sha-256; boundary=\"000000000000a9914105c49a8530\"",
        "X-Content-Filtered-By": "Mailman/MimeDel 2.1.29",
        "Subject": "[dpdk-dev] [PATCH v2 09/58] net/bnxt: add Thor WC TCAM support",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.29",
        "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: Jay Ding <jay.ding@broadcom.com>\n\n1. Add set/get/free/alloc for WC TCAM\n2. Rework the key size in slice management.\n3. Add 3 FKB WC keys for WC TCAM set cli cmd\n4. Add transform key function for WC TCAM FKB key\n5. Add checking for key buffer length for get_tcam\n\nSigned-off-by: Jay Ding <jay.ding@broadcom.com>\nSigned-off-by: Randy Schacher <stuart.schacher@broadcom.com>\nSigned-off-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>\nReviewed-by: Farah Smith <farah.smith@broadcom.com>\nReviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>\n---\n drivers/net/bnxt/tf_core/tf_core.c       |   2 +\n drivers/net/bnxt/tf_core/tf_core.h       |   5 +-\n drivers/net/bnxt/tf_core/tf_device_p4.c  |   2 -\n drivers/net/bnxt/tf_core/tf_device_p58.c |   7 +-\n drivers/net/bnxt/tf_core/tf_device_p58.h |   3 +\n drivers/net/bnxt/tf_core/tf_msg.c        |  31 ++--\n drivers/net/bnxt/tf_core/tf_tcam.c       | 192 ++++++++++++-----------\n 7 files changed, 132 insertions(+), 110 deletions(-)",
    "diff": "diff --git a/drivers/net/bnxt/tf_core/tf_core.c b/drivers/net/bnxt/tf_core/tf_core.c\nindex a3b6afbc88..573fa0b1ed 100644\n--- a/drivers/net/bnxt/tf_core/tf_core.c\n+++ b/drivers/net/bnxt/tf_core/tf_core.c\n@@ -842,8 +842,10 @@ tf_get_tcam_entry(struct tf *tfp __rte_unused,\n \tgparms.type = parms->tcam_tbl_type;\n \tgparms.idx = parms->idx;\n \tgparms.key = parms->key;\n+\tgparms.key_size = dev->ops->tf_dev_word_align(parms->key_sz_in_bits);\n \tgparms.mask = parms->mask;\n \tgparms.result = parms->result;\n+\tgparms.result_size = TF_BITS2BYTES_WORD_ALIGN(parms->result_sz_in_bits);\n \n \trc = dev->ops->tf_dev_get_tcam(tfp, &gparms);\n \tif (rc) {\ndiff --git a/drivers/net/bnxt/tf_core/tf_core.h b/drivers/net/bnxt/tf_core/tf_core.h\nindex 0cc3719a1b..fcba492dc5 100644\n--- a/drivers/net/bnxt/tf_core/tf_core.h\n+++ b/drivers/net/bnxt/tf_core/tf_core.h\n@@ -1286,7 +1286,7 @@ struct tf_get_tcam_entry_parms {\n \t */\n \tuint8_t *mask;\n \t/**\n-\t * [out] key size in bits\n+\t * [in/out] key size in bits\n \t */\n \tuint16_t key_sz_in_bits;\n \t/**\n@@ -1294,7 +1294,7 @@ struct tf_get_tcam_entry_parms {\n \t */\n \tuint8_t *result;\n \t/**\n-\t * [out] struct containing result size in bits\n+\t * [in/out] struct containing result size in bits\n \t */\n \tuint16_t result_sz_in_bits;\n };\n@@ -1961,6 +1961,7 @@ enum tf_tunnel_encap_offsets {\n enum tf_global_config_type {\n \tTF_TUNNEL_ENCAP,  /**< Tunnel Encap Config(TECT) */\n \tTF_ACTION_BLOCK,  /**< Action Block Config(ABCR) */\n+\tTF_COUNTER_CFG,   /**< Counter Configuration (CNTRS_CTRL) */\n \tTF_GLOBAL_CFG_TYPE_MAX\n };\n \ndiff --git a/drivers/net/bnxt/tf_core/tf_device_p4.c b/drivers/net/bnxt/tf_core/tf_device_p4.c\nindex d0bede89e3..e5aaaac9a0 100644\n--- a/drivers/net/bnxt/tf_core/tf_device_p4.c\n+++ b/drivers/net/bnxt/tf_core/tf_device_p4.c\n@@ -144,8 +144,6 @@ tf_dev_p4_get_tcam_slice_info(struct tf *tfp __rte_unused,\n \t\t*num_slices_per_row = CFA_P4_WC_TCAM_SLICES_PER_ROW;\n \t\tif (key_sz > *num_slices_per_row * CFA_P4_WC_TCAM_SLICE_SIZE)\n \t\t\treturn -ENOTSUP;\n-\n-\t\t*num_slices_per_row = 1;\n \t} else { /* for other type of tcam */\n \t\t*num_slices_per_row = 1;\n \t}\ndiff --git a/drivers/net/bnxt/tf_core/tf_device_p58.c b/drivers/net/bnxt/tf_core/tf_device_p58.c\nindex 50a8d82074..65e283ed11 100644\n--- a/drivers/net/bnxt/tf_core/tf_device_p58.c\n+++ b/drivers/net/bnxt/tf_core/tf_device_p58.c\n@@ -123,15 +123,14 @@ tf_dev_p58_get_tcam_slice_info(struct tf *tfp __rte_unused,\n \t\t\t      uint16_t key_sz,\n \t\t\t      uint16_t *num_slices_per_row)\n {\n-#define CFA_P58_WC_TCAM_SLICES_PER_ROW 2\n-#define CFA_P58_WC_TCAM_SLICE_SIZE     12\n+#define CFA_P58_WC_TCAM_SLICES_PER_ROW 1\n+#define CFA_P58_WC_TCAM_SLICE_SIZE     24\n \n \tif (type == TF_TCAM_TBL_TYPE_WC_TCAM) {\n+\t\t/* only support single slice key size now */\n \t\t*num_slices_per_row = CFA_P58_WC_TCAM_SLICES_PER_ROW;\n \t\tif (key_sz > *num_slices_per_row * CFA_P58_WC_TCAM_SLICE_SIZE)\n \t\t\treturn -ENOTSUP;\n-\n-\t\t*num_slices_per_row = 1;\n \t} else { /* for other type of tcam */\n \t\t*num_slices_per_row = 1;\n \t}\ndiff --git a/drivers/net/bnxt/tf_core/tf_device_p58.h b/drivers/net/bnxt/tf_core/tf_device_p58.h\nindex abd916985e..07f022769b 100644\n--- a/drivers/net/bnxt/tf_core/tf_device_p58.h\n+++ b/drivers/net/bnxt/tf_core/tf_device_p58.h\n@@ -189,5 +189,8 @@ struct tf_global_cfg_cfg tf_global_cfg_p58[TF_GLOBAL_CFG_TYPE_MAX] = {\n \t[TF_ACTION_BLOCK] = {\n \t\tTF_GLOBAL_CFG_CFG_HCAPI, TF_ACTION_BLOCK\n \t},\n+\t[TF_COUNTER_CFG] = {\n+\t\tTF_GLOBAL_CFG_CFG_HCAPI, TF_COUNTER_CFG\n+\t},\n };\n #endif /* _TF_DEVICE_P58_H_ */\ndiff --git a/drivers/net/bnxt/tf_core/tf_msg.c b/drivers/net/bnxt/tf_core/tf_msg.c\nindex 1af5c6d11c..ec4c7890c3 100644\n--- a/drivers/net/bnxt/tf_core/tf_msg.c\n+++ b/drivers/net/bnxt/tf_core/tf_msg.c\n@@ -39,19 +39,8 @@\n  * array size (define above) should be checked and compared.\n  */\n #define TF_MSG_SIZE_HWRM_TF_GLOBAL_CFG_SET 56\n-static_assert(sizeof(struct hwrm_tf_global_cfg_set_input) ==\n-\t      TF_MSG_SIZE_HWRM_TF_GLOBAL_CFG_SET,\n-\t      \"HWRM message size changed: hwrm_tf_global_cfg_set_input\");\n-\n #define TF_MSG_SIZE_HWRM_TF_EM_INSERT      104\n-static_assert(sizeof(struct hwrm_tf_em_insert_input) ==\n-\t      TF_MSG_SIZE_HWRM_TF_EM_INSERT,\n-\t      \"HWRM message size changed: hwrm_tf_em_insert_input\");\n-\n #define TF_MSG_SIZE_HWRM_TF_TBL_TYPE_SET   128\n-static_assert(sizeof(struct hwrm_tf_tbl_type_set_input) ==\n-\t      TF_MSG_SIZE_HWRM_TF_TBL_TYPE_SET,\n-\t      \"HWRM message size changed: hwrm_tf_tbl_type_set_input\");\n \n /**\n  * This is the MAX data we can transport across regular HWRM\n@@ -630,6 +619,9 @@ tf_msg_insert_em_internal_entry(struct tf *tfp,\n \tstruct tf_dev_info *dev;\n \tstruct tf_session *tfs;\n \n+\tRTE_BUILD_BUG_ON(sizeof(struct hwrm_tf_em_insert_input) !=\n+\t\t\t TF_MSG_SIZE_HWRM_TF_EM_INSERT);\n+\n \t/* Retrieve the session information */\n \trc = tf_session_get_session_internal(tfp, &tfs);\n \tif (rc) {\n@@ -1255,6 +1247,17 @@ tf_msg_tcam_entry_get(struct tf *tfp,\n \tif (mparms.tf_resp_code != 0)\n \t\treturn tfp_le_to_cpu_32(mparms.tf_resp_code);\n \n+\tif (parms->key_size < resp.key_size ||\n+\t    parms->result_size < resp.result_size) {\n+\t\trc = -EINVAL;\n+\t\tTFP_DRV_LOG(ERR,\n+\t\t\t    \"%s: Key buffer(%d) is smaller than the key(%d), rc:%s\\n\",\n+\t\t\t    tf_dir_2_str(parms->dir),\n+\t\t\t    parms->key_size,\n+\t\t\t    resp.key_size,\n+\t\t\t    strerror(-rc));\n+\t\treturn rc;\n+\t}\n \tparms->key_size = resp.key_size;\n \tparms->result_size = resp.result_size;\n \ttfp_memcpy(parms->key, resp.dev_data, resp.key_size);\n@@ -1320,6 +1323,9 @@ tf_msg_set_tbl_entry(struct tf *tfp,\n \tstruct tf_dev_info *dev;\n \tstruct tf_session *tfs;\n \n+\tRTE_BUILD_BUG_ON(sizeof(struct hwrm_tf_tbl_type_set_input) !=\n+\t\t\t TF_MSG_SIZE_HWRM_TF_TBL_TYPE_SET);\n+\n \t/* Retrieve the session information */\n \trc = tf_session_get_session_internal(tfp, &tfs);\n \tif (rc) {\n@@ -1554,6 +1560,9 @@ tf_msg_set_global_cfg(struct tf *tfp,\n \tstruct tf_dev_info *dev;\n \tstruct tf_session *tfs;\n \n+\tRTE_BUILD_BUG_ON(sizeof(struct hwrm_tf_global_cfg_set_input) !=\n+\t\t\t TF_MSG_SIZE_HWRM_TF_GLOBAL_CFG_SET);\n+\n \t/* Retrieve the session information */\n \trc = tf_session_get_session_internal(tfp, &tfs);\n \tif (rc) {\ndiff --git a/drivers/net/bnxt/tf_core/tf_tcam.c b/drivers/net/bnxt/tf_core/tf_tcam.c\nindex 42d503f500..1b5c29815d 100644\n--- a/drivers/net/bnxt/tf_core/tf_tcam.c\n+++ b/drivers/net/bnxt/tf_core/tf_tcam.c\n@@ -48,10 +48,13 @@ tf_tcam_bind(struct tf *tfp,\n \tstruct tf_rm_free_db_parms fparms;\n \tstruct tf_rm_create_db_parms db_cfg;\n \tstruct tf_tcam_resources *tcam_cnt;\n-\tstruct tf_shadow_tcam_free_db_parms fshadow;\n \tstruct tf_rm_get_alloc_info_parms ainfo;\n+\tstruct tf_shadow_tcam_free_db_parms fshadow;\n \tstruct tf_shadow_tcam_cfg_parms shadow_cfg;\n \tstruct tf_shadow_tcam_create_db_parms shadow_cdb;\n+\tuint16_t num_slices = 1;\n+\tstruct tf_session *tfs;\n+\tstruct tf_dev_info *dev;\n \n \tTF_CHECK_PARMS2(tfp, parms);\n \n@@ -61,11 +64,37 @@ tf_tcam_bind(struct tf *tfp,\n \t\treturn -EINVAL;\n \t}\n \n+\t/* Retrieve the session information */\n+\trc = tf_session_get_session_internal(tfp, &tfs);\n+\tif (rc)\n+\t\treturn rc;\n+\n+\t/* Retrieve the device information */\n+\trc = tf_session_get_device(tfs, &dev);\n+\tif (rc)\n+\t\treturn rc;\n+\n+\tif (dev->ops->tf_dev_get_tcam_slice_info == NULL) {\n+\t\trc = -EOPNOTSUPP;\n+\t\tTFP_DRV_LOG(ERR,\n+\t\t\t    \"Operation not supported, rc:%s\\n\",\n+\t\t\t    strerror(-rc));\n+\t\treturn rc;\n+\t}\n+\n+\trc = dev->ops->tf_dev_get_tcam_slice_info(tfp,\n+\t\t\t\t\t\t  TF_TCAM_TBL_TYPE_WC_TCAM,\n+\t\t\t\t\t\t  0,\n+\t\t\t\t\t\t  &num_slices);\n+\tif (rc)\n+\t\treturn rc;\n+\n \ttcam_cnt = parms->resources->tcam_cnt;\n-\tif ((tcam_cnt[TF_DIR_RX].cnt[TF_TCAM_TBL_TYPE_WC_TCAM] % 2) ||\n-\t    (tcam_cnt[TF_DIR_TX].cnt[TF_TCAM_TBL_TYPE_WC_TCAM] % 2)) {\n+\tif ((tcam_cnt[TF_DIR_RX].cnt[TF_TCAM_TBL_TYPE_WC_TCAM] % num_slices) ||\n+\t    (tcam_cnt[TF_DIR_TX].cnt[TF_TCAM_TBL_TYPE_WC_TCAM] % num_slices)) {\n \t\tTFP_DRV_LOG(ERR,\n-\t\t\t    \"Number of WC TCAM entries cannot be odd num\\n\");\n+\t\t\t    \"Requested num of WC TCAM entries has to be multiple %d\\n\",\n+\t\t\t    num_slices);\n \t\treturn -EINVAL;\n \t}\n \n@@ -88,6 +117,26 @@ tf_tcam_bind(struct tf *tfp,\n \t\t}\n \t}\n \n+\t/* check if reserved resource for WC is multiple of num_slices */\n+\tfor (d = 0; d < TF_DIR_MAX; d++) {\n+\t\tmemset(&info, 0, sizeof(info));\n+\t\tainfo.rm_db = tcam_db[d];\n+\t\tainfo.subtype = TF_TCAM_TBL_TYPE_WC_TCAM;\n+\t\tainfo.info = &info;\n+\t\trc = tf_rm_get_info(&ainfo);\n+\t\tif (rc)\n+\t\t\tgoto error;\n+\n+\t\tif (info.entry.start % num_slices != 0 ||\n+\t\t    info.entry.stride % num_slices != 0) {\n+\t\t\tTFP_DRV_LOG(ERR,\n+\t\t\t\t    \"%s: TCAM reserved resource is not multiple of %d\\n\",\n+\t\t\t\t    tf_dir_2_str(d),\n+\t\t\t\t    num_slices);\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\t}\n+\n \t/* Initialize the TCAM manager. */\n \tif (parms->shadow_copy) {\n \t\tfor (d = 0; d < TF_DIR_MAX; d++) {\n@@ -163,7 +212,6 @@ tf_tcam_unbind(struct tf *tfp)\n \tint i;\n \tstruct tf_rm_free_db_parms fparms;\n \tstruct tf_shadow_tcam_free_db_parms fshadow;\n-\n \tTF_CHECK_PARMS1(tfp);\n \n \t/* Bail if nothing has been initialized */\n@@ -202,11 +250,12 @@ int\n tf_tcam_alloc(struct tf *tfp,\n \t      struct tf_tcam_alloc_parms *parms)\n {\n-\tint rc;\n+\tint rc, i;\n \tstruct tf_session *tfs;\n \tstruct tf_dev_info *dev;\n \tstruct tf_rm_allocate_parms aparms;\n-\tuint16_t num_slice_per_row = 1;\n+\tuint16_t num_slices = 1;\n+\tuint32_t index;\n \n \tTF_CHECK_PARMS2(tfp, parms);\n \n@@ -236,32 +285,24 @@ tf_tcam_alloc(struct tf *tfp,\n \t\treturn rc;\n \t}\n \n-\t/* Need to retrieve row size etc */\n+\t/* Need to retrieve number of slices based on the key_size */\n \trc = dev->ops->tf_dev_get_tcam_slice_info(tfp,\n \t\t\t\t\t\t  parms->type,\n \t\t\t\t\t\t  parms->key_size,\n-\t\t\t\t\t\t  &num_slice_per_row);\n+\t\t\t\t\t\t  &num_slices);\n \tif (rc)\n \t\treturn rc;\n \n-\t/* Allocate requested element */\n-\tmemset(&aparms, 0, sizeof(aparms));\n-\n-\taparms.rm_db = tcam_db[parms->dir];\n-\taparms.subtype = parms->type;\n-\taparms.priority = parms->priority;\n-\taparms.index = (uint32_t *)&parms->idx;\n-\trc = tf_rm_allocate(&aparms);\n-\tif (rc) {\n-\t\tTFP_DRV_LOG(ERR,\n-\t\t\t    \"%s: Failed tcam, type:%d\\n\",\n-\t\t\t    tf_dir_2_str(parms->dir),\n-\t\t\t    parms->type);\n-\t\treturn rc;\n-\t}\n-\n-\tif (parms->type == TF_TCAM_TBL_TYPE_WC_TCAM &&\n-\t    (parms->idx % 2) != 0) {\n+\t/*\n+\t * For WC TCAM, number of slices could be 4, 2, 1 based on\n+\t * the key_size. For other TCAM, it is always 1\n+\t */\n+\tfor (i = 0; i < num_slices; i++) {\n+\t\tmemset(&aparms, 0, sizeof(aparms));\n+\t\taparms.rm_db = tcam_db[parms->dir];\n+\t\taparms.subtype = parms->type;\n+\t\taparms.priority = parms->priority;\n+\t\taparms.index = &index;\n \t\trc = tf_rm_allocate(&aparms);\n \t\tif (rc) {\n \t\t\tTFP_DRV_LOG(ERR,\n@@ -270,9 +311,11 @@ tf_tcam_alloc(struct tf *tfp,\n \t\t\t\t    parms->type);\n \t\t\treturn rc;\n \t\t}\n-\t}\n \n-\tparms->idx *= num_slice_per_row;\n+\t\t/* return the start index of each row */\n+\t\tif (i == 0)\n+\t\t\tparms->idx = index;\n+\t}\n \n \treturn 0;\n }\n@@ -287,9 +330,10 @@ tf_tcam_free(struct tf *tfp,\n \tstruct tf_rm_is_allocated_parms aparms;\n \tstruct tf_rm_free_parms fparms;\n \tstruct tf_rm_get_hcapi_parms hparms;\n-\tuint16_t num_slice_per_row = 1;\n+\tuint16_t num_slices = 1;\n \tint allocated = 0;\n \tstruct tf_shadow_tcam_remove_parms shparms;\n+\tint i;\n \n \tTF_CHECK_PARMS2(tfp, parms);\n \n@@ -323,16 +367,24 @@ tf_tcam_free(struct tf *tfp,\n \trc = dev->ops->tf_dev_get_tcam_slice_info(tfp,\n \t\t\t\t\t\t  parms->type,\n \t\t\t\t\t\t  0,\n-\t\t\t\t\t\t  &num_slice_per_row);\n+\t\t\t\t\t\t  &num_slices);\n \tif (rc)\n \t\treturn rc;\n \n+\tif (parms->idx % num_slices) {\n+\t\tTFP_DRV_LOG(ERR,\n+\t\t\t    \"%s: TCAM reserved resource is not multiple of %d\\n\",\n+\t\t\t    tf_dir_2_str(parms->dir),\n+\t\t\t    num_slices);\n+\t\treturn -EINVAL;\n+\t}\n+\n \t/* Check if element is in use */\n \tmemset(&aparms, 0, sizeof(aparms));\n \n \taparms.rm_db = tcam_db[parms->dir];\n \taparms.subtype = parms->type;\n-\taparms.index = parms->idx / num_slice_per_row;\n+\taparms.index = parms->idx;\n \taparms.allocated = &allocated;\n \trc = tf_rm_is_allocated(&aparms);\n \tif (rc)\n@@ -376,44 +428,20 @@ tf_tcam_free(struct tf *tfp,\n \t\t}\n \t}\n \n-\t/* Free requested element */\n-\tmemset(&fparms, 0, sizeof(fparms));\n-\tfparms.rm_db = tcam_db[parms->dir];\n-\tfparms.subtype = parms->type;\n-\tfparms.index = parms->idx / num_slice_per_row;\n-\trc = tf_rm_free(&fparms);\n-\tif (rc) {\n-\t\tTFP_DRV_LOG(ERR,\n-\t\t\t    \"%s: Free failed, type:%d, index:%d\\n\",\n-\t\t\t    tf_dir_2_str(parms->dir),\n-\t\t\t    parms->type,\n-\t\t\t    parms->idx);\n-\t\treturn rc;\n-\t}\n-\n-\tif (parms->type == TF_TCAM_TBL_TYPE_WC_TCAM) {\n-\t\tint i;\n-\n-\t\tfor (i = -1; i < 3; i += 3) {\n-\t\t\taparms.index += i;\n-\t\t\trc = tf_rm_is_allocated(&aparms);\n-\t\t\tif (rc)\n-\t\t\t\treturn rc;\n-\n-\t\t\tif (allocated == TF_RM_ALLOCATED_ENTRY_IN_USE) {\n-\t\t\t\t/* Free requested element */\n-\t\t\t\tfparms.index = aparms.index;\n-\t\t\t\trc = tf_rm_free(&fparms);\n-\t\t\t\tif (rc) {\n-\t\t\t\t\tTFP_DRV_LOG(ERR,\n-\t\t\t\t\t\t    \"%s: Free failed, type:%d, \"\n-\t\t\t\t\t\t    \"index:%d\\n\",\n-\t\t\t\t\t\t    tf_dir_2_str(parms->dir),\n-\t\t\t\t\t\t    parms->type,\n-\t\t\t\t\t\t    fparms.index);\n-\t\t\t\t\treturn rc;\n-\t\t\t\t}\n-\t\t\t}\n+\tfor (i = 0; i < num_slices; i++) {\n+\t\t/* Free requested element */\n+\t\tmemset(&fparms, 0, sizeof(fparms));\n+\t\tfparms.rm_db = tcam_db[parms->dir];\n+\t\tfparms.subtype = parms->type;\n+\t\tfparms.index = parms->idx + i;\n+\t\trc = tf_rm_free(&fparms);\n+\t\tif (rc) {\n+\t\t\tTFP_DRV_LOG(ERR,\n+\t\t\t\t    \"%s: Free failed, type:%d, index:%d\\n\",\n+\t\t\t\t    tf_dir_2_str(parms->dir),\n+\t\t\t\t    parms->type,\n+\t\t\t\t    parms->idx);\n+\t\t\treturn rc;\n \t\t}\n \t}\n \n@@ -449,8 +477,8 @@ tf_tcam_alloc_search(struct tf *tfp,\n {\n \tstruct tf_shadow_tcam_search_parms sparms;\n \tstruct tf_shadow_tcam_bind_index_parms bparms;\n-\tstruct tf_tcam_alloc_parms aparms;\n \tstruct tf_tcam_free_parms fparms;\n+\tstruct tf_tcam_alloc_parms aparms;\n \tuint16_t num_slice_per_row = 1;\n \tstruct tf_session *tfs;\n \tstruct tf_dev_info *dev;\n@@ -626,7 +654,7 @@ tf_tcam_set(struct tf *tfp __rte_unused,\n \n \taparms.rm_db = tcam_db[parms->dir];\n \taparms.subtype = parms->type;\n-\taparms.index = parms->idx / num_slice_per_row;\n+\taparms.index = parms->idx;\n \taparms.allocated = &allocated;\n \trc = tf_rm_is_allocated(&aparms);\n \tif (rc)\n@@ -693,7 +721,6 @@ tf_tcam_get(struct tf *tfp __rte_unused,\n \tstruct tf_dev_info *dev;\n \tstruct tf_rm_is_allocated_parms aparms;\n \tstruct tf_rm_get_hcapi_parms hparms;\n-\tuint16_t num_slice_per_row = 1;\n \tint allocated = 0;\n \n \tTF_CHECK_PARMS2(tfp, parms);\n@@ -715,29 +742,12 @@ tf_tcam_get(struct tf *tfp __rte_unused,\n \tif (rc)\n \t\treturn rc;\n \n-\tif (dev->ops->tf_dev_get_tcam_slice_info == NULL) {\n-\t\trc = -EOPNOTSUPP;\n-\t\tTFP_DRV_LOG(ERR,\n-\t\t\t    \"%s: Operation not supported, rc:%s\\n\",\n-\t\t\t    tf_dir_2_str(parms->dir),\n-\t\t\t    strerror(-rc));\n-\t\treturn rc;\n-\t}\n-\n-\t/* Need to retrieve row size etc */\n-\trc = dev->ops->tf_dev_get_tcam_slice_info(tfp,\n-\t\t\t\t\t\t  parms->type,\n-\t\t\t\t\t\t  parms->key_size,\n-\t\t\t\t\t\t  &num_slice_per_row);\n-\tif (rc)\n-\t\treturn rc;\n-\n \t/* Check if element is in use */\n \tmemset(&aparms, 0, sizeof(aparms));\n \n \taparms.rm_db = tcam_db[parms->dir];\n \taparms.subtype = parms->type;\n-\taparms.index = parms->idx / num_slice_per_row;\n+\taparms.index = parms->idx;\n \taparms.allocated = &allocated;\n \trc = tf_rm_is_allocated(&aparms);\n \tif (rc)\n",
    "prefixes": [
        "v2",
        "09/58"
    ]
}