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 D33A4A0565; Tue, 17 Mar 2020 16:41:31 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 999CB1C0D2; Tue, 17 Mar 2020 16:39:21 +0100 (CET) Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by dpdk.org (Postfix) with ESMTP id 7BE641C0C6 for ; Tue, 17 Mar 2020 16:39:18 +0100 (CET) Received: by mail-wr1-f65.google.com with SMTP id f11so9508030wrp.8 for ; Tue, 17 Mar 2020 08:39:18 -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=AhUvVi2NsRtKwzDrareTKOtJsw6bG6ctDcbk5EyMVF8=; b=Aw8pBTNYcfWXdI3yhKrmOKn3csziOcTqmYxd5vTMFe6x7J1XM7TosazK2aWk13awCC ro2rpGI5MJuDc4D49qOTsnfnYHoZytMDVEJHRddwd9+6w6uMg+SfUh6p1T+qh3xZWZGG /8eN47DEtH2kUCy3HwQ3P4EW6GkhQYlgyZinE= 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=AhUvVi2NsRtKwzDrareTKOtJsw6bG6ctDcbk5EyMVF8=; b=YOlxDqG23EyxFhU4NdJdFU55riH2KtNHozY9fCSqOyrOw7KJA+af1nlXElSUUS7XYg zWZwK/jcA2/GoXo2wM7cqOjBLcxfPgWowZQs57ie+UDnVEEQjLs3tG5QiR+VBR3sH397 GzMSm/AeA2VQGNl5xdgVFJhpXfarRNxLlmaXOttI1Ouc2Czkpjst4hGnncB0BKynqRjO HVm54IvPlxTHc4F7iDSFlzLkDyXd7nX65u1XyliP/t/oX0fDgmiP2Pk9sYFFdwQF4LFX d2kD1ia41+hsRxgWXeSIITHxGFRWdZqJ15VymXE/lYPm7steBRnMhjnRyDIZYs71quEm 8YVQ== X-Gm-Message-State: ANhLgQ19JJxVk+2t3fcQIrNrL+0u653LnMTJsly6/BSIvkDkqBNHHlPe qzTRAnNchQ7SD7sws5eVttFgK9qIpfovJyv+7Yd3gFqc2kxLyiLhlqyQwPOyuc6Vr13x21FnE3+ KL/6ROiWBxv243TR+DAlnhLp0iefwYSBE+HQzVHeSsycklCMda1+OvTZPlheWqub3Bju3 X-Google-Smtp-Source: ADFU+vvjbMkGbBwnA0EYUu96AA30VmuU3y8O4F0NKv/g/Zn7h9EwZabIWHKymSaBcbSzxOXP9jW8wQ== X-Received: by 2002:adf:fa4c:: with SMTP id y12mr7107663wrr.392.1584459557809; Tue, 17 Mar 2020 08:39:17 -0700 (PDT) Received: from S60.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id q4sm5052142wro.56.2020.03.17.08.39.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 17 Mar 2020 08:39:17 -0700 (PDT) From: Venkat Duvvuru To: dev@dpdk.org Cc: Farah Smith Date: Tue, 17 Mar 2020 21:08:07 +0530 Message-Id: <1584459511-5353-10-git-send-email-venkatkumar.duvvuru@broadcom.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1584459511-5353-1-git-send-email-venkatkumar.duvvuru@broadcom.com> References: <1584459511-5353-1-git-send-email-venkatkumar.duvvuru@broadcom.com> Subject: [dpdk-dev] [PATCH 09/33] 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 259ffa2..037f7d1 100644 --- a/drivers/net/bnxt/tf_core/tf_core.c +++ b/drivers/net/bnxt/tf_core/tf_core.c @@ -283,3 +283,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