get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 93558,
    "url": "http://patches.dpdk.org/api/patches/93558/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20210530085929.29695-10-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": "<20210530085929.29695-10-venkatkumar.duvvuru@broadcom.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20210530085929.29695-10-venkatkumar.duvvuru@broadcom.com",
    "date": "2021-05-30T08:58:40",
    "name": "[09/58] net/bnxt: add Thor WC TCAM support",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "abf4a20a7ffa99dead9486abf54474179b0658ec",
    "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/20210530085929.29695-10-venkatkumar.duvvuru@broadcom.com/mbox/",
    "series": [
        {
            "id": 17161,
            "url": "http://patches.dpdk.org/api/series/17161/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=17161",
            "date": "2021-05-30T08:58:31",
            "name": "enhancements to host based flow table management",
            "version": 1,
            "mbox": "http://patches.dpdk.org/series/17161/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/93558/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/93558/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 1EB91A0524;\n\tSun, 30 May 2021 11:01:51 +0200 (CEST)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 0685940E5A;\n\tSun, 30 May 2021 11:00:45 +0200 (CEST)",
            "from relay.smtp-ext.broadcom.com (saphodev.broadcom.com\n [192.19.11.229]) by mails.dpdk.org (Postfix) with ESMTP id A690941137\n for <dev@dpdk.org>; Sun, 30 May 2021 11:00:41 +0200 (CEST)",
            "from S60.dhcp.broadcom.net (unknown [10.123.66.170])\n (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))\n (No client certificate requested)\n by relay.smtp-ext.broadcom.com (Postfix) with ESMTPS id 11B7C7DC2;\n Sun, 30 May 2021 02:00:39 -0700 (PDT)"
        ],
        "DKIM-Filter": "OpenDKIM Filter v2.11.0 relay.smtp-ext.broadcom.com 11B7C7DC2",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com;\n s=dkimrelay; t=1622365241;\n bh=Mxc/WgjYPnx6GLR01eXzxvJo/bd7YYyVPFl6+2x7De0=;\n h=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n b=mbm+swOdQBT3uIx33XzFSqpULkoi/yFAwTQVp2A1tfV+r7Cl7wiTvXfijDUueWfb0\n QjoqTIMduXnRXDt2zioElIeieX6ZPbc6wdO5xhMJx9VpmfkxpH3hgAZzPcWWEs1rr7\n gA6eOS4tKAby0yyYdsnUaV7tgBc03SM77LUxv31M=",
        "From": "Venkat Duvvuru <venkatkumar.duvvuru@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>",
        "Date": "Sun, 30 May 2021 14:28:40 +0530",
        "Message-Id": "<20210530085929.29695-10-venkatkumar.duvvuru@broadcom.com>",
        "X-Mailer": "git-send-email 2.17.1",
        "In-Reply-To": "<20210530085929.29695-1-venkatkumar.duvvuru@broadcom.com>",
        "References": "<20210530085929.29695-1-venkatkumar.duvvuru@broadcom.com>",
        "Subject": "[dpdk-dev] [PATCH 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>\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": [
        "09/58"
    ]
}