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 D3D54A0577; Tue, 14 Apr 2020 10:16:08 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2AAF01C222; Tue, 14 Apr 2020 10:14:12 +0200 (CEST) Received: from mail-pl1-f196.google.com (mail-pl1-f196.google.com [209.85.214.196]) by dpdk.org (Postfix) with ESMTP id D58791C211 for ; Tue, 14 Apr 2020 10:14:09 +0200 (CEST) Received: by mail-pl1-f196.google.com with SMTP id a23so4394730plm.1 for ; Tue, 14 Apr 2020 01:14:09 -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=f/eGlMU9FSyhzepsld+jfomYZvxXW+OXiIcD/fIs6KY=; b=XQdmDDiI0LiNf2KzM65ASOna9WWGlu9t0CElZAmbyRkmjWmL0T5xUOcVtIcXW6yPyU VLXn7H3NQkSPVoY8V1SA0EAMOJEU9m9xAR4oYz9uQ1cJ11QsToSgf1RAyPdjZ29Rp4Og +pPMDMgJCKtXa3I+Vc6CB15IUE7GTLLlFvSlQ= 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=f/eGlMU9FSyhzepsld+jfomYZvxXW+OXiIcD/fIs6KY=; b=cvRNx61QOsFtieTMXb+6Tl6dbLbl83QO/uaDK05Yr0LLAOqo/yg+t/UlwANqwwSXSb melvZ4aJf/eQAivXMj8t87VCoEwMmwUfoS2z1gBzSWspE+UL61enoEpsXmQQ8IZUfL+W s9JXODTQRgpPL6GYcDwWRYG5yQ9sZkc7/6mqHB2pm/7K4B9Tv9+WbI6ZB02yYqT54JFk qfiikSHSxcExy8H02B0Enugoa2rKOHxsU0cwXPG3EDSaUAP3cZTK0oAzDyFtbsD63msO 0Zoxtigk8K6G/2mAi7TF2M3nZUH+bL+skwrhoQ97sPQPJDfwL6IMJ4m3ydHRsM1CC126 lkRg== X-Gm-Message-State: AGi0PubCj2QahMVxQe4hiFc4LicVzY0FigsRETC2rpKhgIO5oCQcGb/D omvW4TaU6kWEBDsu96LwloTBqLfKn0F+FAbT6t+9yf5uY3S75ALX3s93tobxoLQ8kdk64RTbYLA Q3v/C5jCiuhPcoYzyXYjT2SykqV9Ib1X4kxxGfVNtc4XKoS8s4RoOhfLgA//L7MScVqiH X-Google-Smtp-Source: APiQypLvHAa2xq3qvHOarXdC0DTlL/T0ivqH7CzAjGiRq55Dh4+kvyHKPpmOKgRFarhOgDmvvsYPNw== X-Received: by 2002:a17:90b:2397:: with SMTP id mr23mr2632152pjb.88.1586852048513; Tue, 14 Apr 2020 01:14:08 -0700 (PDT) Received: from S60.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id e196sm671176pfh.43.2020.04.14.01.14.06 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 Apr 2020 01:14:07 -0700 (PDT) From: Venkat Duvvuru To: dev@dpdk.org Cc: Farah Smith Date: Tue, 14 Apr 2020 13:43:06 +0530 Message-Id: <1586852011-37536-10-git-send-email-venkatkumar.duvvuru@broadcom.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1586852011-37536-1-git-send-email-venkatkumar.duvvuru@broadcom.com> References: <1586806811-21736-1-git-send-email-venkatkumar.duvvuru@broadcom.com> <1586852011-37536-1-git-send-email-venkatkumar.duvvuru@broadcom.com> Subject: [dpdk-dev] [PATCH v3 09/34] net/bnxt: add tf core identifier support 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 - Add TruFlow Identifier resource support - Add TruFlow public API for Identifier resources. - Add support code and stack for Identifier resource allocation control. Signed-off-by: Farah Smith Reviewed-by: Randy Schacher Reviewed-by: Ajit Kumar Khaparde --- drivers/net/bnxt/tf_core/tf_core.c | 156 +++++++++++++++++++++++++++++++++++++ drivers/net/bnxt/tf_core/tf_core.h | 55 +++++++++++++ drivers/net/bnxt/tf_core/tf_msg.c | 13 ++++ 3 files changed, 224 insertions(+) diff --git a/drivers/net/bnxt/tf_core/tf_core.c b/drivers/net/bnxt/tf_core/tf_core.c index bb6d38b..7b027f7 100644 --- a/drivers/net/bnxt/tf_core/tf_core.c +++ b/drivers/net/bnxt/tf_core/tf_core.c @@ -284,3 +284,159 @@ tf_close_session(struct tf *tfp) return rc_close; } + +/** allocate identifier resource + * + * Returns success or failure code. + */ +int tf_alloc_identifier(struct tf *tfp, + struct tf_alloc_identifier_parms *parms) +{ + struct bitalloc *session_pool; + struct tf_session *tfs; + int id; + int rc; + + if (parms == NULL || tfp == NULL) + return -EINVAL; + + if (tfp->session == NULL || tfp->session->core_data == NULL) { + PMD_DRV_LOG(ERR, "%s: session error\n", + tf_dir_2_str(parms->dir)); + return -EINVAL; + } + + tfs = (struct tf_session *)(tfp->session->core_data); + + switch (parms->ident_type) { + case TF_IDENT_TYPE_L2_CTXT: + TF_RM_GET_POOLS(tfs, parms->dir, &session_pool, + TF_L2_CTXT_REMAP_POOL_NAME, + rc); + break; + case TF_IDENT_TYPE_PROF_FUNC: + TF_RM_GET_POOLS(tfs, parms->dir, &session_pool, + TF_PROF_FUNC_POOL_NAME, + rc); + break; + case TF_IDENT_TYPE_EM_PROF: + TF_RM_GET_POOLS(tfs, parms->dir, &session_pool, + TF_EM_PROF_ID_POOL_NAME, + rc); + break; + case TF_IDENT_TYPE_WC_PROF: + TF_RM_GET_POOLS(tfs, parms->dir, &session_pool, + TF_WC_TCAM_PROF_ID_POOL_NAME, + rc); + break; + case TF_IDENT_TYPE_L2_FUNC: + PMD_DRV_LOG(ERR, "%s: unsupported %s\n", + tf_dir_2_str(parms->dir), + tf_ident_2_str(parms->ident_type)); + rc = -EOPNOTSUPP; + break; + default: + PMD_DRV_LOG(ERR, "%s: %s\n", + tf_dir_2_str(parms->dir), + tf_ident_2_str(parms->ident_type)); + rc = -EINVAL; + break; + } + + if (rc) { + PMD_DRV_LOG(ERR, "%s: identifier pool %s failure\n", + tf_dir_2_str(parms->dir), + tf_ident_2_str(parms->ident_type)); + return rc; + } + + id = ba_alloc(session_pool); + + if (id == BA_FAIL) { + PMD_DRV_LOG(ERR, "%s: %s: No resource available\n", + tf_dir_2_str(parms->dir), + tf_ident_2_str(parms->ident_type)); + return -ENOMEM; + } + parms->id = id; + return 0; +} + +/** free identifier resource + * + * Returns success or failure code. + */ +int tf_free_identifier(struct tf *tfp, + struct tf_free_identifier_parms *parms) +{ + struct bitalloc *session_pool; + int rc; + int ba_rc; + struct tf_session *tfs; + + if (parms == NULL || tfp == NULL) + return -EINVAL; + + if (tfp->session == NULL || tfp->session->core_data == NULL) { + PMD_DRV_LOG(ERR, "%s: Session error\n", + tf_dir_2_str(parms->dir)); + return -EINVAL; + } + + tfs = (struct tf_session *)(tfp->session->core_data); + + switch (parms->ident_type) { + case TF_IDENT_TYPE_L2_CTXT: + TF_RM_GET_POOLS(tfs, parms->dir, &session_pool, + TF_L2_CTXT_REMAP_POOL_NAME, + rc); + break; + case TF_IDENT_TYPE_PROF_FUNC: + TF_RM_GET_POOLS(tfs, parms->dir, &session_pool, + TF_PROF_FUNC_POOL_NAME, + rc); + break; + case TF_IDENT_TYPE_EM_PROF: + TF_RM_GET_POOLS(tfs, parms->dir, &session_pool, + TF_EM_PROF_ID_POOL_NAME, + rc); + break; + case TF_IDENT_TYPE_WC_PROF: + TF_RM_GET_POOLS(tfs, parms->dir, &session_pool, + TF_WC_TCAM_PROF_ID_POOL_NAME, + rc); + break; + case TF_IDENT_TYPE_L2_FUNC: + PMD_DRV_LOG(ERR, "%s: unsupported %s\n", + tf_dir_2_str(parms->dir), + tf_ident_2_str(parms->ident_type)); + rc = -EOPNOTSUPP; + break; + default: + PMD_DRV_LOG(ERR, "%s: invalid %s\n", + tf_dir_2_str(parms->dir), + tf_ident_2_str(parms->ident_type)); + rc = -EINVAL; + break; + } + if (rc) { + PMD_DRV_LOG(ERR, "%s: %s Identifier pool access failed\n", + tf_dir_2_str(parms->dir), + tf_ident_2_str(parms->ident_type)); + return rc; + } + + ba_rc = ba_inuse(session_pool, (int)parms->id); + + if (ba_rc == BA_FAIL || ba_rc == BA_ENTRY_FREE) { + PMD_DRV_LOG(ERR, "%s: %s: Entry %d already free", + tf_dir_2_str(parms->dir), + tf_ident_2_str(parms->ident_type), + parms->id); + return -EINVAL; + } + + ba_free(session_pool, (int)parms->id); + + return 0; +} diff --git a/drivers/net/bnxt/tf_core/tf_core.h b/drivers/net/bnxt/tf_core/tf_core.h index 16c8251..afad9ea 100644 --- a/drivers/net/bnxt/tf_core/tf_core.h +++ b/drivers/net/bnxt/tf_core/tf_core.h @@ -402,6 +402,61 @@ enum tf_identifier_type { TF_IDENT_TYPE_L2_FUNC }; +/** tf_alloc_identifier parameter definition + */ +struct tf_alloc_identifier_parms { + /** + * [in] receive or transmit direction + */ + enum tf_dir dir; + /** + * [in] Identifier type + */ + enum tf_identifier_type ident_type; + /** + * [out] Identifier allocated + */ + uint16_t id; +}; + +/** tf_free_identifier parameter definition + */ +struct tf_free_identifier_parms { + /** + * [in] receive or transmit direction + */ + enum tf_dir dir; + /** + * [in] Identifier type + */ + enum tf_identifier_type ident_type; + /** + * [in] ID to free + */ + uint16_t id; +}; + +/** allocate identifier resource + * + * TruFlow core will allocate a free id from the per identifier resource type + * pool reserved for the session during tf_open(). No firmware is involved. + * + * Returns success or failure code. + */ +int tf_alloc_identifier(struct tf *tfp, + struct tf_alloc_identifier_parms *parms); + +/** free identifier resource + * + * TruFlow core will return an id back to the per identifier resource type pool + * reserved for the session. No firmware is involved. During tf_close, the + * complete pool is returned to the firmware. + * + * Returns success or failure code. + */ +int tf_free_identifier(struct tf *tfp, + struct tf_free_identifier_parms *parms); + /** * TCAM table type */ diff --git a/drivers/net/bnxt/tf_core/tf_msg.c b/drivers/net/bnxt/tf_core/tf_msg.c index 4ce2bc5..c44f96f 100644 --- a/drivers/net/bnxt/tf_core/tf_msg.c +++ b/drivers/net/bnxt/tf_core/tf_msg.c @@ -94,6 +94,19 @@ } while (0) /** + * This is the MAX data we can transport across regular HWRM + */ +#define TF_PCI_BUF_SIZE_MAX 88 + +/** + * If data bigger than TF_PCI_BUF_SIZE_MAX then use DMA method + */ +struct tf_msg_dma_buf { + void *va_addr; + uint64_t pa_addr; +}; + +/** * Sends session open request to TF Firmware */ int -- 2.7.4