From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6ADE7A00C2; Sat, 25 Apr 2020 05:49:10 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id E4CD41C1B7; Sat, 25 Apr 2020 05:48:57 +0200 (CEST) Received: from mail-ed1-f66.google.com (mail-ed1-f66.google.com [209.85.208.66]) by dpdk.org (Postfix) with ESMTP id B64541C1AC for ; Sat, 25 Apr 2020 05:48:54 +0200 (CEST) Received: by mail-ed1-f66.google.com with SMTP id t12so8975790edw.3 for ; Fri, 24 Apr 2020 20:48:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=hUockT7IRqoYpwYXxpnCUI4y3uXMDGHHlpzqSchX6sU=; b=a2k++XOQe/mha7Jas426QD4gu8YQAAn+NfvjXO35gDF1wYiHddgPok8Y2PCjDJCZx9 nto39wiKL79ZStLQJnnLKbhqI0b1UjG73GLc9h4iC/e/yi+YANUghbkWKkVz1hEXbhH0 1imMRjc1Nxih1TGjIVvNDcOYy4DHhvTyHMDQM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=hUockT7IRqoYpwYXxpnCUI4y3uXMDGHHlpzqSchX6sU=; b=MscJaykNzGqkjUI1EYJAP1V8sAuGu70Xxkst0qsQoYD5MDjWBTy9N85Rh5qZKEU1p7 7QByOPQIBMfwwLbLFb7XiZBy146VSA4tr0au9NfdVcsH99YOWcIX46oU+fnEaKIOFIQY P1N4MW8Ps2EKQ7rOeqpw6UVpYn+w1HzdH1HDQjPtiR29JRAJStveucUq1Her6O/zy9sM zWVbvb2hczqyNck4eLLWhdZ9UNaJOVqdvm8+3I+pfteNl5hzjPBSZTA9ahO9xLnFzT2t YixtsAPIj6Lp1Bxj+ofj6NPEKL0AUiE8+BKTpSEsh4MJRYhvqC8ibeldUKqXl7lwcMxO LarA== X-Gm-Message-State: AGi0PuZ+zg3gC0V0EzWaNFcWhJNcH/1AVGLeKtHWpBq6OvHHXcs1k5Fi 9ec3CfP6frXsKOQ+VkuAaYRBEvqnQngo1sJBV8LAWYXeHqStqTFw05R5VEgxOiyFXz3mFkToHMD O3WarHjU4LlgD9RpIWSIFd1InIq7DAC4YSWihBb1ygBDk6arAPOIBfjrbwDQDjZ0GvMZm X-Google-Smtp-Source: APiQypKtiibUj7vWAhC+0gSRvdhvvic5fFvplTNIDSxxLwmToViAShFunFdmcn1L69m35s8PJC75ow== X-Received: by 2002:a50:f74c:: with SMTP id j12mr9871104edn.197.1587786534010; Fri, 24 Apr 2020 20:48:54 -0700 (PDT) Received: from S60.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id ci6sm972012ejc.73.2020.04.24.20.48.51 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 24 Apr 2020 20:48:53 -0700 (PDT) From: Venkat Duvvuru To: dev@dpdk.org Cc: Farah Smith , Mike Baucom Date: Sat, 25 Apr 2020 09:17:23 +0530 Message-Id: <1587786446-35230-3-git-send-email-venkatkumar.duvvuru@broadcom.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1587786446-35230-1-git-send-email-venkatkumar.duvvuru@broadcom.com> References: <1587786446-35230-1-git-send-email-venkatkumar.duvvuru@broadcom.com> Subject: [dpdk-dev] [PATCH 2/5] net/bnxt: action record external pool updates X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Farah Smith - Added support variable sized action records - Additional error checking on table scope params - Single external pool supported per direction - Changed to return action record pointer - Allows action pool to fully utilize the number of flows Signed-off-by: Farah Smith Signed-off-by: Mike Baucom Reviewed-by: Peter Spreadborough Reviewed-by: Kishore Padmanabha --- drivers/net/bnxt/tf_core/tf_core.c | 3 - drivers/net/bnxt/tf_core/tf_core.h | 15 ++-- drivers/net/bnxt/tf_core/tf_rm.c | 3 - drivers/net/bnxt/tf_core/tf_session.h | 6 -- drivers/net/bnxt/tf_core/tf_tbl.c | 136 +++++++++++++--------------------- drivers/net/bnxt/tf_core/tf_tbl.h | 4 +- 6 files changed, 62 insertions(+), 105 deletions(-) diff --git a/drivers/net/bnxt/tf_core/tf_core.c b/drivers/net/bnxt/tf_core/tf_core.c index fc7d638..cf9f36a 100644 --- a/drivers/net/bnxt/tf_core/tf_core.c +++ b/drivers/net/bnxt/tf_core/tf_core.c @@ -175,9 +175,6 @@ tf_open_session(struct tf *tfp, /* Setup hash seeds */ tf_seeds_init(session); - /* Initialize external pool data structures */ - tf_init_tbl_pool(session); - session->ref_count++; /* Return session ID */ diff --git a/drivers/net/bnxt/tf_core/tf_core.h b/drivers/net/bnxt/tf_core/tf_core.h index 6a1f3a1..4b60973 100644 --- a/drivers/net/bnxt/tf_core/tf_core.h +++ b/drivers/net/bnxt/tf_core/tf_core.h @@ -83,7 +83,7 @@ enum tf_mem { /** EEM record AR helper * - * Helpers to handle the Action Record Pointer in the EEM Record Entry. + * Helper to handle the Action Record Pointer in the EEM Record Entry. * * Convert absolute offset to action record pointer in EEM record entry * Convert action record pointer in EEM record entry to absolute offset @@ -91,8 +91,6 @@ enum tf_mem { #define TF_ACT_REC_OFFSET_2_PTR(offset) ((offset) >> 4) #define TF_ACT_REC_PTR_2_OFFSET(offset) ((offset) << 4) -#define TF_ACT_REC_INDEX_2_OFFSET(idx) ((idx) << 9) - /* * Helper Macros */ @@ -943,8 +941,6 @@ enum tf_tbl_type { * scope. Internal types are not. */ TF_TBL_TYPE_EXT, - /** Future - external pool of size0 entries */ - TF_TBL_TYPE_EXT_0, TF_TBL_TYPE_MAX }; @@ -960,6 +956,10 @@ struct tf_alloc_tbl_entry_parms { */ enum tf_tbl_type type; /** + * [in] Table scope identifier (ignored unless TF_TBL_TYPE_EXT) + */ + uint32_t tbl_scope_id; + /** * [in] Enable search for matching entry. If the table type is * internal the shadow copy will be searched before * alloc. Session must be configured with shadow copy enabled. @@ -1029,6 +1029,10 @@ struct tf_free_tbl_entry_parms { */ enum tf_tbl_type type; /** + * [in] Table scope identifier (ignored unless TF_TBL_TYPE_EXT) + */ + uint32_t tbl_scope_id; + /** * [in] Index to free */ uint32_t idx; @@ -1070,7 +1074,6 @@ int tf_free_tbl_entry(struct tf *tfp, struct tf_set_tbl_entry_parms { /** * [in] Table scope identifier - * */ uint32_t tbl_scope_id; /** diff --git a/drivers/net/bnxt/tf_core/tf_rm.c b/drivers/net/bnxt/tf_core/tf_rm.c index a5e96f29..38b1e71 100644 --- a/drivers/net/bnxt/tf_core/tf_rm.c +++ b/drivers/net/bnxt/tf_core/tf_rm.c @@ -3104,7 +3104,6 @@ tf_rm_lookup_tbl_type_pool(struct tf_session *tfs, break; /* No bitalloc pools for these types */ case TF_TBL_TYPE_EXT: - case TF_TBL_TYPE_EXT_0: default: break; } @@ -3211,7 +3210,6 @@ tf_rm_convert_tbl_type(enum tf_tbl_type type, case TF_TBL_TYPE_ACT_MODIFY_IPV6_SRC: case TF_TBL_TYPE_VNIC_SVIF: case TF_TBL_TYPE_EXT: /* No pools for this type */ - case TF_TBL_TYPE_EXT_0: /* No pools for this type */ default: *hcapi_type = -1; rc = -EOPNOTSUPP; @@ -3277,7 +3275,6 @@ tf_rm_convert_index(struct tf_session *tfs, /* Not yet supported */ case TF_TBL_TYPE_VNIC_SVIF: case TF_TBL_TYPE_EXT: /* No pools for this type */ - case TF_TBL_TYPE_EXT_0: /* No pools for this type */ default: return -EOPNOTSUPP; } diff --git a/drivers/net/bnxt/tf_core/tf_session.h b/drivers/net/bnxt/tf_core/tf_session.h index fed34f1..50ef2d5 100644 --- a/drivers/net/bnxt/tf_core/tf_session.h +++ b/drivers/net/bnxt/tf_core/tf_session.h @@ -289,12 +289,6 @@ struct tf_session { /** Table scope array */ struct tf_tbl_scope_cb tbl_scopes[TF_NUM_TBL_SCOPE]; - - /** Each external pool is associated with a single table scope - * For each external pool store the associated table scope in - * this data structure - */ - uint32_t ext_pool_2_scope[TF_DIR_MAX][TF_EXT_POOL_CNT_MAX]; }; #endif /* _TF_SESSION_H_ */ diff --git a/drivers/net/bnxt/tf_core/tf_tbl.c b/drivers/net/bnxt/tf_core/tf_tbl.c index 17df274..236affe 100644 --- a/drivers/net/bnxt/tf_core/tf_tbl.c +++ b/drivers/net/bnxt/tf_core/tf_tbl.c @@ -701,6 +701,21 @@ tf_em_validate_num_entries(struct tf_tbl_scope_cb *tbl_scope_cb, } } + if (parms->rx_num_flows_in_k != 0 && + (parms->rx_max_key_sz_in_bits / 8 == 0)) { + PMD_DRV_LOG(ERR, + "EEM: Rx key size required: %u\n", + (parms->rx_max_key_sz_in_bits)); + return -EINVAL; + } + + if (parms->tx_num_flows_in_k != 0 && + (parms->tx_max_key_sz_in_bits / 8 == 0)) { + PMD_DRV_LOG(ERR, + "EEM: Tx key size required: %u\n", + (parms->tx_max_key_sz_in_bits)); + return -EINVAL; + } /* Rx */ tbl_scope_cb->em_ctx_info[TF_DIR_RX].em_tables[KEY0_TABLE].num_entries = parms->rx_num_flows_in_k * TF_KILOBYTE; @@ -715,7 +730,7 @@ tf_em_validate_num_entries(struct tf_tbl_scope_cb *tbl_scope_cb, tbl_scope_cb->em_ctx_info[TF_DIR_RX].em_tables[RECORD_TABLE].num_entries = parms->rx_num_flows_in_k * TF_KILOBYTE; tbl_scope_cb->em_ctx_info[TF_DIR_RX].em_tables[RECORD_TABLE].entry_size = - parms->tx_max_action_entry_sz_in_bits / 8; + parms->rx_max_action_entry_sz_in_bits / 8; tbl_scope_cb->em_ctx_info[TF_DIR_RX].em_tables[EFC_TABLE].num_entries = 0; @@ -954,14 +969,10 @@ tf_free_tbl_entry_shadow(struct tf_session *tfs, /** * Create External Tbl pool of memory indexes. * - * [in] session - * Pointer to session * [in] dir * direction * [in] tbl_scope_cb * pointer to the table scope - * [in] tbl_scope_id - * id of the table scope * [in] num_entries * number of entries to write * [in] entry_sz_bytes @@ -973,18 +984,16 @@ tf_free_tbl_entry_shadow(struct tf_session *tfs, * - Failure, entry not allocated, out of resources */ static int -tf_create_tbl_pool_external(struct tf_session *session, - enum tf_dir dir, +tf_create_tbl_pool_external(enum tf_dir dir, struct tf_tbl_scope_cb *tbl_scope_cb, - uint32_t table_scope_id, uint32_t num_entries, uint32_t entry_sz_bytes) - { struct tfp_calloc_parms parms; - uint32_t i, j; + uint32_t i; + int32_t j; int rc = 0; - struct stack *pool = &tbl_scope_cb->ext_pool[dir][TF_EXT_POOL_0]; + struct stack *pool = &tbl_scope_cb->ext_act_pool[dir]; parms.nitems = num_entries; parms.size = sizeof(uint32_t); @@ -1009,18 +1018,23 @@ tf_create_tbl_pool_external(struct tf_session *session, /* Save the malloced memory address so that it can * be freed when the table scope is freed. */ - tbl_scope_cb->ext_pool_mem[dir][TF_EXT_POOL_0] = - (uint32_t *)parms.mem_va; + tbl_scope_cb->ext_act_pool_mem[dir] = (uint32_t *)parms.mem_va; - /* Fill pool with indexes + /* Fill pool with indexes in reverse */ - j = num_entries * entry_sz_bytes - 1; + j = (num_entries - 1) * entry_sz_bytes; for (i = 0; i < num_entries; i++) { rc = stack_push(pool, j); if (rc != 0) { - PMD_DRV_LOG(ERR, "%d TBL: stack failure %s\n", - dir, strerror(-rc)); + PMD_DRV_LOG(ERR, "%s TBL: stack failure %s\n", + tf_dir_2_str(dir), strerror(-rc)); + goto cleanup; + } + + if (j < 0) { + PMD_DRV_LOG(ERR, "%d TBL: invalid offset (%d)\n", + dir, j); goto cleanup; } j -= entry_sz_bytes; @@ -1032,10 +1046,6 @@ tf_create_tbl_pool_external(struct tf_session *session, dir, strerror(-rc)); goto cleanup; } - /* Set the table scope associated with the pool - */ - session->ext_pool_2_scope[dir][TF_EXT_POOL_0] = table_scope_id; - return 0; cleanup: tfp_free((void *)parms.mem_va); @@ -1045,8 +1055,6 @@ tf_create_tbl_pool_external(struct tf_session *session, /** * Destroy External Tbl pool of memory indexes. * - * [in] session - * Pointer to session * [in] dir * direction * [in] tbl_scope_cb @@ -1054,18 +1062,13 @@ tf_create_tbl_pool_external(struct tf_session *session, * */ static void -tf_destroy_tbl_pool_external(struct tf_session *session, - enum tf_dir dir, - struct tf_tbl_scope_cb *tbl_scope_cb) +tf_destroy_tbl_pool_external(enum tf_dir dir, + struct tf_tbl_scope_cb *tbl_scope_cb) { - uint32_t *ext_pool_mem = - tbl_scope_cb->ext_pool_mem[dir][TF_EXT_POOL_0]; + uint32_t *ext_act_pool_mem = + tbl_scope_cb->ext_act_pool_mem[dir]; - tfp_free(ext_pool_mem); - - /* Set the table scope associated with the pool - */ - session->ext_pool_2_scope[dir][TF_EXT_POOL_0] = TF_TBL_SCOPE_INVALID; + tfp_free(ext_act_pool_mem); } /** @@ -1088,7 +1091,6 @@ tf_alloc_tbl_entry_pool_external(struct tf *tfp, int rc; uint32_t index; struct tf_session *tfs; - uint32_t tbl_scope_id; struct tf_tbl_scope_cb *tbl_scope_cb; struct stack *pool; @@ -1107,26 +1109,17 @@ tf_alloc_tbl_entry_pool_external(struct tf *tfp, tfs = (struct tf_session *)(tfp->session->core_data); - if (parms->type != TF_TBL_TYPE_EXT) { - PMD_DRV_LOG(ERR, - "dir:%d, Type not supported, type:%d\n", - parms->dir, - parms->type); - return -EOPNOTSUPP; - } - /* Get the pool info from the table scope */ - tbl_scope_id = tfs->ext_pool_2_scope[parms->dir][TF_EXT_POOL_0]; - tbl_scope_cb = tbl_scope_cb_find(tfs, tbl_scope_id); + tbl_scope_cb = tbl_scope_cb_find(tfs, parms->tbl_scope_id); if (tbl_scope_cb == NULL) { PMD_DRV_LOG(ERR, - "dir:%d, table scope not allocated\n", - parms->dir); + "%s, table scope not allocated\n", + tf_dir_2_str(parms->dir)); return -EINVAL; } - pool = &tbl_scope_cb->ext_pool[parms->dir][TF_EXT_POOL_0]; + pool = &tbl_scope_cb->ext_act_pool[parms->dir]; /* Allocate an element */ @@ -1246,12 +1239,11 @@ tf_alloc_tbl_entry_pool_internal(struct tf *tfp, */ static int tf_free_tbl_entry_pool_external(struct tf *tfp, - struct tf_free_tbl_entry_parms *parms) + struct tf_free_tbl_entry_parms *parms) { int rc = 0; struct tf_session *tfs; uint32_t index; - uint32_t tbl_scope_id; struct tf_tbl_scope_cb *tbl_scope_cb; struct stack *pool; @@ -1270,26 +1262,17 @@ tf_free_tbl_entry_pool_external(struct tf *tfp, tfs = (struct tf_session *)(tfp->session->core_data); - if (parms->type != TF_TBL_TYPE_EXT) { - PMD_DRV_LOG(ERR, - "dir:%d, Type not supported, type:%d\n", - parms->dir, - parms->type); - return -EOPNOTSUPP; - } - /* Get the pool info from the table scope */ - tbl_scope_id = tfs->ext_pool_2_scope[parms->dir][TF_EXT_POOL_0]; - tbl_scope_cb = tbl_scope_cb_find(tfs, tbl_scope_id); + tbl_scope_cb = tbl_scope_cb_find(tfs, parms->tbl_scope_id); if (tbl_scope_cb == NULL) { PMD_DRV_LOG(ERR, - "dir:%d, table scope error\n", + "dir:%d, Session info invalid\n", parms->dir); return -EINVAL; } - pool = &tbl_scope_cb->ext_pool[parms->dir][TF_EXT_POOL_0]; + pool = &tbl_scope_cb->ext_act_pool[parms->dir]; index = parms->idx; @@ -1390,18 +1373,6 @@ tf_free_tbl_entry_pool_internal(struct tf *tfp, return rc; } -/* API defined in tf_tbl.h */ -void -tf_init_tbl_pool(struct tf_session *session) -{ - enum tf_dir dir; - - for (dir = 0; dir < TF_DIR_MAX; dir++) { - session->ext_pool_2_scope[dir][TF_EXT_POOL_0] = - TF_TBL_SCOPE_INVALID; - } -} - /* API defined in tf_em.h */ struct tf_tbl_scope_cb * tbl_scope_cb_find(struct tf_session *session, @@ -1447,8 +1418,7 @@ tf_free_eem_tbl_scope_cb(struct tf *tfp, for (dir = 0; dir < TF_DIR_MAX; dir++) { /* Free associated external pools */ - tf_destroy_tbl_pool_external(session, - dir, + tf_destroy_tbl_pool_external(dir, tbl_scope_cb); tf_msg_em_op(tfp, dir, @@ -1551,12 +1521,10 @@ tf_alloc_eem_tbl_scope(struct tf *tfp, * Initially, this is a single fixed size pool for all external * actions related to a single table scope. */ - rc = tf_create_tbl_pool_external(session, - dir, - tbl_scope_cb, - index, - TF_EXT_POOL_ENTRY_CNT, - TF_EXT_POOL_ENTRY_SZ_BYTES); + rc = tf_create_tbl_pool_external(dir, + tbl_scope_cb, + em_tables[RECORD_TABLE].num_entries, + em_tables[RECORD_TABLE].entry_size); if (rc) { PMD_DRV_LOG(ERR, "%d TBL: Unable to allocate idx pools %s\n", @@ -1600,13 +1568,12 @@ tf_set_tbl_entry(struct tf *tfp, if (parms->type == TF_TBL_TYPE_EXT) { void *base_addr; - uint32_t offset = TF_ACT_REC_INDEX_2_OFFSET(parms->idx); + uint32_t offset = parms->idx; uint32_t tbl_scope_id; session = (struct tf_session *)(tfp->session->core_data); - tbl_scope_id = - session->ext_pool_2_scope[parms->dir][TF_EXT_POOL_0]; + tbl_scope_id = parms->tbl_scope_id; if (tbl_scope_id == TF_TBL_SCOPE_INVALID) { PMD_DRV_LOG(ERR, @@ -1618,7 +1585,6 @@ tf_set_tbl_entry(struct tf *tfp, /* Get the table scope control block associated with the * external pool */ - tbl_scope_cb = tbl_scope_cb_find(session, tbl_scope_id); if (tbl_scope_cb == NULL) diff --git a/drivers/net/bnxt/tf_core/tf_tbl.h b/drivers/net/bnxt/tf_core/tf_tbl.h index 5d3ea71..bdc6288 100644 --- a/drivers/net/bnxt/tf_core/tf_tbl.h +++ b/drivers/net/bnxt/tf_core/tf_tbl.h @@ -72,8 +72,8 @@ struct tf_tbl_scope_cb { int index; struct tf_em_ctx_mem_info em_ctx_info[TF_DIR_MAX]; struct tf_em_caps em_caps[TF_DIR_MAX]; - struct stack ext_pool[TF_DIR_MAX][TF_EXT_POOL_CNT_MAX]; - uint32_t *ext_pool_mem[TF_DIR_MAX][TF_EXT_POOL_CNT_MAX]; + struct stack ext_act_pool[TF_DIR_MAX]; + uint32_t *ext_act_pool_mem[TF_DIR_MAX]; }; /** Hardware Page sizes supported for EEM: 4K, 8K, 64K, 256K, 1M, 2M, 4M, 1G. -- 2.7.4