From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id DC72845B90; Mon, 21 Oct 2024 10:15:18 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3D8C540612; Mon, 21 Oct 2024 10:15:04 +0200 (CEST) Received: from mail-oa1-f43.google.com (mail-oa1-f43.google.com [209.85.160.43]) by mails.dpdk.org (Postfix) with ESMTP id 8C98540651 for ; Mon, 21 Oct 2024 10:15:02 +0200 (CEST) Received: by mail-oa1-f43.google.com with SMTP id 586e51a60fabf-2887326be3dso1775083fac.1 for ; Mon, 21 Oct 2024 01:15:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1729498501; x=1730103301; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FWIMQUCvwNbeX6x31LVNdEv/Hi6UqXBDHDzSdstgbCE=; b=NqsfujsDWOK85ukYjJ0LAU3uw9aeTgfxUf3krNo/SEQXAS7pJ/4DKI/PiTo5V/W6Ys mXA+1NgkarU0cRl+GyXYpmlKKokOym31m7+gxtIvK4UDIU0OeKdHRWFtOUPYnhDJhGXH XbZGpDdNZ/TKicmfp7g9TmJS87wsnEBlCUPYQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729498501; x=1730103301; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FWIMQUCvwNbeX6x31LVNdEv/Hi6UqXBDHDzSdstgbCE=; b=flvpJHGBuQUiQXanEXXlHLD7ZFixjsXBYrBjYnKreBp+jjBiMCN7Byui3OOvYN4XlP F6oawAo6dyDjj8lea2Kv51quPiCB33Frd3Zy3FFMdW66hoX/NVbp/RODPHH9wYm2+cg/ SijmhYuJalowNLhsZRlkgxqaqjFOrsXSieY54gTlszA2/I22X5UkCNUVY51gl+9UbPnf eTbTCPWmXZhWxE1MxufpzO9tMZ+tEdamxvay1dqMRUrtDKtZE2t/WTvGut2iaUVaTNxi pjX+7gHbC90jU2ly2aPBwkO9ss8vHZFcam6IS3kkuN/X0VUh+ggmGt3jKSgnmkqrIo5W ekpw== X-Gm-Message-State: AOJu0YypCI2ThLiIqQbEVRputQcnVxTp1gQUoq+DhDgQ9O3DyNJplsPn smR1CseNJwTlEBTadzr5CSgZSwK9QM0P6rKpQbkQCiHKTXHw+UtWX0ZLndM+LYaHUrLuTTv6+Wi MSdfY5jSGg3ZmJxd+6foYEVDFjAlAtTTAo02x2rH6oFidjSnzjOxYkXKoh9Gmb6JcAR2sKFwbFX T1Hs90z0Z/jPR4JX0zrWtfUZDIOw/Olvgb2a/SGX1C1g== X-Google-Smtp-Source: AGHT+IGdt7/L73ijzb3YscXUeloHqOMsn1QGF0f/h751ifjZkHIMuYqKafy7iqREer5AKaI//fQsAA== X-Received: by 2002:a05:6870:65a1:b0:288:8f84:5f14 with SMTP id 586e51a60fabf-2892c24f6efmr7952376fac.8.1729498500357; Mon, 21 Oct 2024 01:15:00 -0700 (PDT) Received: from dhcp-10-123-154-23.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71ec1313926sm2291631b3a.4.2024.10.21.01.14.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Oct 2024 01:14:59 -0700 (PDT) From: Sriharsha Basavapatna To: dev@dpdk.org Cc: Shuanglin Wang , Sriharsha Basavapatna , Shahaji Bhosle , Farah Smith , Ajit Khaparde Subject: [PATCH v6 03/47] net/bnxt: tf_core: External EM support cleanup Date: Mon, 21 Oct 2024 13:55:23 +0530 Message-Id: <20241021082607.232829-4-sriharsha.basavapatna@broadcom.com> X-Mailer: git-send-email 2.39.0.189.g4dbebc36b0 In-Reply-To: <20241021082607.232829-1-sriharsha.basavapatna@broadcom.com> References: <20241021082607.232829-1-sriharsha.basavapatna@broadcom.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Shuanglin Wang Isolate external EM support as it is now defunct on Wh+. Signed-off-by: Shuanglin Wang Signed-off-by: Sriharsha Basavapatna Reviewed-by: Shahaji Bhosle Reviewed-by: Farah Smith Reviewed-by: Ajit Khaparde --- drivers/net/bnxt/tf_core/meson.build | 2 - drivers/net/bnxt/tf_core/tf_core.h | 34 +- drivers/net/bnxt/tf_core/tf_device.c | 30 - drivers/net/bnxt/tf_core/tf_device_p4.c | 17 +- drivers/net/bnxt/tf_core/tf_device_p4.h | 1 + drivers/net/bnxt/tf_core/tf_device_p58.c | 6 +- drivers/net/bnxt/tf_core/tf_em.h | 361 +------ drivers/net/bnxt/tf_core/tf_em_common.c | 1191 ---------------------- drivers/net/bnxt/tf_core/tf_em_common.h | 1 + drivers/net/bnxt/tf_core/tf_em_host.c | 574 ----------- drivers/net/bnxt/tf_core/tf_msg.c | 465 --------- drivers/net/bnxt/tf_core/tf_tcam.c | 1 - 12 files changed, 71 insertions(+), 2612 deletions(-) diff --git a/drivers/net/bnxt/tf_core/meson.build b/drivers/net/bnxt/tf_core/meson.build index ae44aa34cf..13a71738a0 100644 --- a/drivers/net/bnxt/tf_core/meson.build +++ b/drivers/net/bnxt/tf_core/meson.build @@ -21,9 +21,7 @@ sources += files( 'tf_device.c', 'tf_device_p4.c', 'tf_device_p58.c', - 'tf_em_common.c', 'tf_em_hash_internal.c', - 'tf_em_host.c', 'tf_em_internal.c', 'tf_global_cfg.c', 'tf_hash.c', diff --git a/drivers/net/bnxt/tf_core/tf_core.h b/drivers/net/bnxt/tf_core/tf_core.h index 3da1d2a5ca..fd1ee2f454 100644 --- a/drivers/net/bnxt/tf_core/tf_core.h +++ b/drivers/net/bnxt/tf_core/tf_core.h @@ -21,9 +21,15 @@ /********** BEGIN Truflow Core DEFINITIONS **********/ +/** + * \cond DO_NOT_DOCUMENT + */ #define TF_KILOBYTE 1024 #define TF_MEGABYTE (1024 * 1024) +/** + * \endcond + */ /** * direction */ @@ -93,15 +99,19 @@ enum tf_sram_bank_id { * * Convert absolute offset to action record pointer in EEM record entry * Convert action record pointer in EEM record entry to absolute offset + * \cond DO_NOT_DOCUMENT */ #define TF_ACT_REC_OFFSET_2_PTR(offset) ((offset) >> 4) #define TF_ACT_REC_PTR_2_OFFSET(offset) ((offset) << 4) -/* +/** * Helper Macros */ #define TF_BITS_2_BYTES(num_bits) (((num_bits) + 7) / 8) +/** + * \endcond + */ /********** BEGIN API FUNCTION PROTOTYPES/PARAMETERS **********/ /** @@ -147,6 +157,8 @@ enum tf_sram_bank_id { * TruFlow session. Session ID is constructed from the passed in * ctrl_chan_name in tf_open_session() together with an allocated * fw_session_id. Done by TruFlow on tf_open_session(). + * + * \cond DO_NOT_DOCUMENT */ union tf_session_id { uint32_t id; @@ -172,6 +184,10 @@ union tf_session_client_id { uint8_t fw_session_client_id; } internal; }; +/** + * \endcond + */ + /** * Session Version @@ -181,12 +197,17 @@ union tf_session_client_id { * versions can be supported. * * Please see the TF_VER_MAJOR/MINOR and UPDATE defines. + * + * \cond DO_NOT_DOCUMENT */ struct tf_session_version { uint8_t major; uint8_t minor; uint8_t update; }; +/** + * \endcond + */ /** * Session supported device types @@ -485,6 +506,7 @@ struct tf_session_info { * * NOTE: This struct must be within the BNXT PMD struct bnxt * (bp). This allows use of container_of() to get access to the PMD. + * \cond DO_NOT_DOCUMENT */ struct tf { struct tf_session_info *session; @@ -493,6 +515,9 @@ struct tf { */ void *bp; }; +/** + * \endcond + */ /** * Identifier resource definition @@ -716,12 +741,15 @@ int tf_open_session(struct tf *tfp, /** * General internal resource info - * + * \cond DO_NOT_DOCUMENT */ struct tf_resource_info { uint16_t start; uint16_t stride; }; +/** + * \endcond + */ /** * Identifier resource definition @@ -2386,6 +2414,7 @@ struct tf_get_version_parms { /* [out] major * * Version Major number. + * \cond DO_NOT_DOCUMENT */ uint8_t major; @@ -2402,6 +2431,7 @@ struct tf_get_version_parms { uint8_t update; /** + * \endcond * [out] dev_ident_caps * * fw available identifier resource list diff --git a/drivers/net/bnxt/tf_core/tf_device.c b/drivers/net/bnxt/tf_core/tf_device.c index 02a9ebd7b2..d023194d0c 100644 --- a/drivers/net/bnxt/tf_core/tf_device.c +++ b/drivers/net/bnxt/tf_core/tf_device.c @@ -153,28 +153,6 @@ tf_dev_bind_p4(struct tf *tfp, } no_rsv_flag = false; } - - /* - * EEM - */ - - em_cfg.cfg = tf_em_ext_p4; - rsv_cnt = tf_dev_reservation_check(TF_EM_TBL_TYPE_MAX, - em_cfg.cfg, - (uint16_t *)resources->em_cnt); - if (rsv_cnt) { - em_cfg.num_elements = TF_EM_TBL_TYPE_MAX; - em_cfg.resources = resources; - em_cfg.mem_type = TF_EEM_MEM_TYPE_HOST; - rc = tf_em_ext_common_bind(tfp, &em_cfg); - if (rc) { - TFP_DRV_LOG(ERR, - "EEM initialization failure\n"); - goto fail; - } - no_rsv_flag = false; - } - /* * EM */ @@ -294,14 +272,6 @@ tf_dev_unbind_p4(struct tf *tfp) "Device unbind failed, Table Type\n"); fail = true; } - - rc = tf_em_ext_common_unbind(tfp); - if (rc) { - TFP_DRV_LOG(INFO, - "Device unbind failed, EEM\n"); - fail = true; - } - rc = tf_em_int_unbind(tfp); if (rc) { TFP_DRV_LOG(INFO, diff --git a/drivers/net/bnxt/tf_core/tf_device_p4.c b/drivers/net/bnxt/tf_core/tf_device_p4.c index 911ea92471..4df1918bc5 100644 --- a/drivers/net/bnxt/tf_core/tf_device_p4.c +++ b/drivers/net/bnxt/tf_core/tf_device_p4.c @@ -15,6 +15,7 @@ #include "tf_if_tbl.h" #include "tfp.h" #include "tf_msg_common.h" +#include "tf_util.h" #define TF_DEV_P4_PARIF_MAX 16 #define TF_DEV_P4_PF_MASK 0xfUL @@ -528,13 +529,13 @@ const struct tf_dev_ops tf_dev_ops_p4 = { .tf_dev_get_tbl_info = NULL, .tf_dev_is_sram_managed = tf_dev_p4_is_sram_managed, .tf_dev_alloc_tbl = tf_tbl_alloc, - .tf_dev_alloc_ext_tbl = tf_tbl_ext_alloc, + .tf_dev_alloc_ext_tbl = NULL, .tf_dev_alloc_sram_tbl = tf_tbl_alloc, .tf_dev_free_tbl = tf_tbl_free, - .tf_dev_free_ext_tbl = tf_tbl_ext_free, + .tf_dev_free_ext_tbl = NULL, .tf_dev_free_sram_tbl = tf_tbl_free, .tf_dev_set_tbl = tf_tbl_set, - .tf_dev_set_ext_tbl = tf_tbl_ext_common_set, + .tf_dev_set_ext_tbl = NULL, .tf_dev_set_sram_tbl = NULL, .tf_dev_get_tbl = tf_tbl_get, .tf_dev_get_sram_tbl = NULL, @@ -551,13 +552,13 @@ const struct tf_dev_ops tf_dev_ops_p4 = { .tf_dev_get_tcam_resc_info = tf_tcam_get_resc_info, .tf_dev_insert_int_em_entry = tf_em_insert_int_entry, .tf_dev_delete_int_em_entry = tf_em_delete_int_entry, - .tf_dev_insert_ext_em_entry = tf_em_insert_ext_entry, - .tf_dev_delete_ext_em_entry = tf_em_delete_ext_entry, + .tf_dev_insert_ext_em_entry = NULL, + .tf_dev_delete_ext_em_entry = NULL, .tf_dev_get_em_resc_info = tf_em_get_resc_info, - .tf_dev_alloc_tbl_scope = tf_em_ext_common_alloc, - .tf_dev_map_tbl_scope = tf_em_ext_map_tbl_scope, + .tf_dev_alloc_tbl_scope = NULL, + .tf_dev_map_tbl_scope = NULL, .tf_dev_map_parif = tf_dev_p4_map_parif, - .tf_dev_free_tbl_scope = tf_em_ext_common_free, + .tf_dev_free_tbl_scope = NULL, .tf_dev_set_if_tbl = tf_if_tbl_set, .tf_dev_get_if_tbl = tf_if_tbl_get, .tf_dev_set_global_cfg = tf_global_cfg_set, diff --git a/drivers/net/bnxt/tf_core/tf_device_p4.h b/drivers/net/bnxt/tf_core/tf_device_p4.h index 20da2f97db..750e50f787 100644 --- a/drivers/net/bnxt/tf_core/tf_device_p4.h +++ b/drivers/net/bnxt/tf_core/tf_device_p4.h @@ -11,6 +11,7 @@ #include "tf_rm.h" #include "tf_if_tbl.h" #include "tf_global_cfg.h" +#include "hcapi_cfa_defs.h" extern struct tf_rm_element_cfg tf_tbl_p4[TF_DIR_MAX][TF_TBL_TYPE_MAX]; diff --git a/drivers/net/bnxt/tf_core/tf_device_p58.c b/drivers/net/bnxt/tf_core/tf_device_p58.c index 6916c50fdc..51c260b5d7 100644 --- a/drivers/net/bnxt/tf_core/tf_device_p58.c +++ b/drivers/net/bnxt/tf_core/tf_device_p58.c @@ -853,12 +853,12 @@ const struct tf_dev_ops tf_dev_ops_p58 = { .tf_dev_get_tbl_info = tf_dev_p58_get_sram_tbl_info, .tf_dev_alloc_tbl = tf_tbl_alloc, .tf_dev_alloc_sram_tbl = tf_tbl_sram_alloc, - .tf_dev_alloc_ext_tbl = tf_tbl_ext_alloc, + .tf_dev_alloc_ext_tbl = NULL, .tf_dev_free_tbl = tf_tbl_free, - .tf_dev_free_ext_tbl = tf_tbl_ext_free, + .tf_dev_free_ext_tbl = NULL, .tf_dev_free_sram_tbl = tf_tbl_sram_free, .tf_dev_set_tbl = tf_tbl_set, - .tf_dev_set_ext_tbl = tf_tbl_ext_common_set, + .tf_dev_set_ext_tbl = NULL, .tf_dev_set_sram_tbl = tf_tbl_sram_set, .tf_dev_get_tbl = tf_tbl_get, .tf_dev_get_sram_tbl = tf_tbl_sram_get, diff --git a/drivers/net/bnxt/tf_core/tf_em.h b/drivers/net/bnxt/tf_core/tf_em.h index 97cdb48f14..15f810521c 100644 --- a/drivers/net/bnxt/tf_core/tf_em.h +++ b/drivers/net/bnxt/tf_core/tf_em.h @@ -12,70 +12,11 @@ #include "hcapi_cfa_defs.h" -#define TF_EM_MIN_ENTRIES (1 << 15) /* 32K */ -#define TF_EM_MAX_ENTRIES (1 << 27) /* 128M */ - #define TF_P4_HW_EM_KEY_MAX_SIZE 52 #define TF_P4_EM_KEY_RECORD_SIZE 64 #define TF_P58_HW_EM_KEY_MAX_SIZE 80 -#define TF_EM_MAX_MASK 0x7FFF -#define TF_EM_MAX_ENTRY (128 * 1024 * 1024) - -/** - * Hardware Page sizes supported for EEM: - * 4K, 8K, 64K, 256K, 1M, 2M, 4M, 1G. - * - * Round-down other page sizes to the lower hardware page - * size supported. - */ -#define TF_EM_PAGE_SIZE_4K 12 -#define TF_EM_PAGE_SIZE_8K 13 -#define TF_EM_PAGE_SIZE_64K 16 -#define TF_EM_PAGE_SIZE_256K 18 -#define TF_EM_PAGE_SIZE_1M 20 -#define TF_EM_PAGE_SIZE_2M 21 -#define TF_EM_PAGE_SIZE_4M 22 -#define TF_EM_PAGE_SIZE_1G 30 - -/* Set page size */ -#define BNXT_TF_PAGE_SIZE TF_EM_PAGE_SIZE_2M - -#if (BNXT_TF_PAGE_SIZE == TF_EM_PAGE_SIZE_4K) /** 4K */ -#define TF_EM_PAGE_SHIFT TF_EM_PAGE_SIZE_4K -#define TF_EM_PAGE_SIZE_ENUM HWRM_TF_CTXT_MEM_RGTR_INPUT_PAGE_SIZE_4K -#elif (BNXT_TF_PAGE_SIZE == TF_EM_PAGE_SIZE_8K) /** 8K */ -#define TF_EM_PAGE_SHIFT TF_EM_PAGE_SIZE_8K -#define TF_EM_PAGE_SIZE_ENUM HWRM_TF_CTXT_MEM_RGTR_INPUT_PAGE_SIZE_8K -#elif (BNXT_TF_PAGE_SIZE == TF_EM_PAGE_SIZE_64K) /** 64K */ -#define TF_EM_PAGE_SHIFT TF_EM_PAGE_SIZE_64K -#define TF_EM_PAGE_SIZE_ENUM HWRM_TF_CTXT_MEM_RGTR_INPUT_PAGE_SIZE_64K -#elif (BNXT_TF_PAGE_SIZE == TF_EM_PAGE_SIZE_256K) /** 256K */ -#define TF_EM_PAGE_SHIFT TF_EM_PAGE_SIZE_256K -#define TF_EM_PAGE_SIZE_ENUM HWRM_TF_CTXT_MEM_RGTR_INPUT_PAGE_SIZE_256K -#elif (BNXT_TF_PAGE_SIZE == TF_EM_PAGE_SIZE_1M) /** 1M */ -#define TF_EM_PAGE_SHIFT TF_EM_PAGE_SIZE_1M -#define TF_EM_PAGE_SIZE_ENUM HWRM_TF_CTXT_MEM_RGTR_INPUT_PAGE_SIZE_1M -#elif (BNXT_TF_PAGE_SIZE == TF_EM_PAGE_SIZE_2M) /** 2M */ -#define TF_EM_PAGE_SHIFT TF_EM_PAGE_SIZE_2M -#define TF_EM_PAGE_SIZE_ENUM HWRM_TF_CTXT_MEM_RGTR_INPUT_PAGE_SIZE_2M -#elif (BNXT_TF_PAGE_SIZE == TF_EM_PAGE_SIZE_4M) /** 4M */ -#define TF_EM_PAGE_SHIFT TF_EM_PAGE_SIZE_4M -#define TF_EM_PAGE_SIZE_ENUM HWRM_TF_CTXT_MEM_RGTR_INPUT_PAGE_SIZE_4M -#elif (BNXT_TF_PAGE_SIZE == TF_EM_PAGE_SIZE_1G) /** 1G */ -#define TF_EM_PAGE_SHIFT TF_EM_PAGE_SIZE_1G -#define TF_EM_PAGE_SIZE_ENUM HWRM_TF_CTXT_MEM_RGTR_INPUT_PAGE_SIZE_1G -#else -#error "Invalid Page Size specified. Please use a TF_EM_PAGE_SIZE_n define" -#endif - -/* - * System memory always uses 4K pages - */ -#define TF_EM_PAGE_SIZE (1 << TF_EM_PAGE_SHIFT) -#define TF_EM_PAGE_ALIGNMENT (1 << TF_EM_PAGE_SHIFT) - /* * Used to build GFID: * @@ -90,16 +31,6 @@ #define TF_EM_INTERNAL_INDEX_MASK 0xFFFC #define TF_EM_INTERNAL_ENTRY_MASK 0x3 -/** EM Entry - * Each EM entry is 512-bit (64-bytes) but ordered differently to - * EEM. - */ -struct tf_em_64b_entry { - /** Header is 8 bytes long */ - struct cfa_p4_eem_entry_hdr hdr; - /** Key is 448 bits - 56 bytes */ - uint8_t key[TF_P4_EM_KEY_RECORD_SIZE - sizeof(struct cfa_p4_eem_entry_hdr)]; -}; /** EEM Memory Type * @@ -132,6 +63,17 @@ struct tf_em_cfg_parms { enum tf_mem_type mem_type; }; +/** EM Entry + * Each EM entry is 512-bit (64-bytes) but ordered differently to + * EEM. + */ +struct tf_em_64b_entry { + /** Header is 8 bytes long */ + struct cfa_p4_eem_entry_hdr hdr; + /** Key is 448 bits - 56 bytes */ + uint8_t key[TF_P4_EM_KEY_RECORD_SIZE - sizeof(struct cfa_p4_eem_entry_hdr)]; +}; + /** * EM database * @@ -153,29 +95,33 @@ struct em_rm_db { * * @ref tf_em_delete_int_entry * - * @ref tf_em_insert_ext_entry + * @ref tf_em_insert_ext_entry DEFUNCT * - * @ref tf_em_delete_ext_entry + * @ref tf_em_delete_ext_entry DEFUNCT * - * @ref tf_em_insert_ext_sys_entry + * @ref tf_em_insert_ext_sys_entry DEFUNCT * - * @ref tf_em_delete_ext_sys_entry + * @ref tf_em_delete_ext_sys_entry DEFUNCT * * @ref tf_em_int_bind * * @ref tf_em_int_unbind * - * @ref tf_em_ext_common_bind + * @ref tf_em_ext_common_bind DEFUNCT * - * @ref tf_em_ext_common_unbind + * @ref tf_em_ext_common_unbind DEFUNCT * - * @ref tf_em_ext_alloc + * @ref tf_em_ext_host_alloc DEFUNCT * - * @ref tf_em_ext_free + * @ref tf_em_ext_host_free DEFUNCT * - * @ref tf_em_ext_common_free + * @ref tf_em_ext_system_alloc DEFUNCT * - * @ref tf_em_ext_common_alloc + * @ref tf_em_ext_system_free DEFUNCT + * + * @ref tf_em_ext_common_free DEFUNCT + * + * @ref tf_em_ext_common_alloc DEFUNCT */ /** @@ -258,70 +204,6 @@ int tf_em_hash_delete_int_entry(struct tf *tfp, int tf_em_move_int_entry(struct tf *tfp, struct tf_move_em_entry_parms *parms); -/** - * Insert record in to external EEM table - * - * [in] tfp - * Pointer to TruFlow handle - * - * [in] parms - * Pointer to input parameters - * - * Returns: - * 0 - Success - * -EINVAL - Parameter error - */ -int tf_em_insert_ext_entry(struct tf *tfp, - struct tf_insert_em_entry_parms *parms); - -/** - * Insert record from external EEM table - * - * [in] tfp - * Pointer to TruFlow handle - * - * [in] parms - * Pointer to input parameters - * - * Returns: - * 0 - Success - * -EINVAL - Parameter error - */ -int tf_em_delete_ext_entry(struct tf *tfp, - struct tf_delete_em_entry_parms *parms); - -/** - * Insert record in to external system EEM table - * - * [in] tfp - * Pointer to TruFlow handle - * - * [in] parms - * Pointer to input parameters - * - * Returns: - * 0 - Success - * -EINVAL - Parameter error - */ -int tf_em_insert_ext_sys_entry(struct tf *tfp, - struct tf_insert_em_entry_parms *parms); - -/** - * Delete record from external system EEM table - * - * [in] tfp - * Pointer to TruFlow handle - * - * [in] parms - * Pointer to input parameters - * - * Returns: - * 0 - Success - * -EINVAL - Parameter error - */ -int tf_em_delete_ext_sys_entry(struct tf *tfp, - struct tf_delete_em_entry_parms *parms); - /** * Bind internal EM device interface * @@ -353,199 +235,6 @@ int tf_em_int_bind(struct tf *tfp, */ int tf_em_int_unbind(struct tf *tfp); -/** - * Common bind for EEM device interface. Used for both host and - * system memory - * - * [in] tfp - * Pointer to TruFlow handle - * - * [in] parms - * Pointer to input parameters - * - * Returns: - * 0 - Success - * -EINVAL - Parameter error - */ -int tf_em_ext_common_bind(struct tf *tfp, - struct tf_em_cfg_parms *parms); - -/** - * Common unbind for EEM device interface. Used for both host and - * system memory - * - * [in] tfp - * Pointer to TruFlow handle - * - * [in] parms - * Pointer to input parameters - * - * Returns: - * 0 - Success - * -EINVAL - Parameter error - */ -int tf_em_ext_common_unbind(struct tf *tfp); - -/** - * Alloc for external EEM using host memory - * - * [in] tfp - * Pointer to TruFlow handle - * - * [in] parms - * Pointer to input parameters - * - * Returns: - * 0 - Success - * -EINVAL - Parameter error - */ -int tf_em_ext_alloc(struct tf *tfp, - struct tf_alloc_tbl_scope_parms *parms); - -/** - * Free for external EEM using host memory - * - * [in] tfp - * Pointer to TruFlow handle - * - * [in] parms - * Pointer to input parameters - * - * Returns: - * 0 - Success - * -EINVAL - Parameter error - */ -int tf_em_ext_free(struct tf *tfp, - struct tf_free_tbl_scope_parms *parms); - -/** - * Common free table scope for external EEM using host or system memory - * - * [in] tfp - * Pointer to TruFlow handle - * - * [in] parms - * Pointer to input parameters - * - * Returns: - * 0 - Success - * -EINVAL - Parameter error - */ -int tf_em_ext_common_free(struct tf *tfp, - struct tf_free_tbl_scope_parms *parms); - -/** - * Common alloc table scope for external EEM using host or system memory - * - * [in] tfp - * Pointer to TruFlow handle - * - * [in] parms - * Pointer to input parameters - * - * Returns: - * 0 - Success - * -EINVAL - Parameter error - */ -int tf_em_ext_common_alloc(struct tf *tfp, - struct tf_alloc_tbl_scope_parms *parms); -/** - * Map a set of parifs to a set of EEM base addresses (table scope) - * - * [in] tfp - * Pointer to TruFlow handle - * - * [in] parms - * Pointer to input parameters - * - * Returns: - * 0 - Success - * -EINVAL - Parameter error - */ -int tf_em_ext_map_tbl_scope(struct tf *tfp, - struct tf_map_tbl_scope_parms *parms); - -/** - * Allocate External Tbl entry from the scope pool. - * - * [in] tfp - * Pointer to Truflow Handle - * [in] parms - * Allocation parameters - * - * Return: - * 0 - Success, entry allocated - no search support - * -ENOMEM -EINVAL -EOPNOTSUPP - * - Failure, entry not allocated, out of resources - */ -int -tf_tbl_ext_alloc(struct tf *tfp, - struct tf_tbl_alloc_parms *parms); - -/** - * Free External Tbl entry to the scope pool. - * - * [in] tfp - * Pointer to Truflow Handle - * [in] parms - * Allocation parameters - * - * Return: - * 0 - Success, entry freed - * - * - Failure, entry not successfully freed for these reasons - * -ENOMEM - * -EOPNOTSUPP - * -EINVAL - */ -int -tf_tbl_ext_free(struct tf *tfp, - struct tf_tbl_free_parms *parms); - -/** - * Sets the specified external table type element. - * - * This API sets the specified element data by invoking the - * firmware. - * - * [in] tfp - * Pointer to TF handle - * - * [in] parms - * Pointer to table set parameters - * - * Returns - * - (0) if successful. - * - (-EINVAL) on failure. - */ -int tf_tbl_ext_common_set(struct tf *tfp, - struct tf_tbl_set_parms *parms); - -/** - * Sets the specified external table type element. - * - * This API sets the specified element data by invoking the - * firmware. - * - * [in] tfp - * Pointer to TF handle - * - * [in] parms - * Pointer to table set parameters - * - * Returns - * - (0) if successful. - * - (-EINVAL) on failure. - */ -int tf_tbl_ext_set(struct tf *tfp, - struct tf_tbl_set_parms *parms); - -int -tf_em_ext_system_bind(struct tf *tfp, - struct tf_em_cfg_parms *parms); - -int offload_system_mmap(struct tf_tbl_scope_cb *tbl_scope_cb); - /** * Retrieves the allocated resource info * diff --git a/drivers/net/bnxt/tf_core/tf_em_common.c b/drivers/net/bnxt/tf_core/tf_em_common.c index c518150d1f..2449759db0 100644 --- a/drivers/net/bnxt/tf_core/tf_em_common.c +++ b/drivers/net/bnxt/tf_core/tf_em_common.c @@ -21,1194 +21,3 @@ #include "hcapi_cfa.h" #include "bnxt.h" -/** Invalid table scope id */ -#define TF_TBL_SCOPE_INVALID 0xffffffff - -/* Number of pointers per page_size */ -#define MAX_PAGE_PTRS(page_size) ((page_size) / sizeof(void *)) - -/** - * Host or system - */ -static enum tf_mem_type mem_type; - -/* API defined in tf_em.h */ -int -tf_create_tbl_pool_external(enum tf_dir dir, - struct tf_tbl_scope_cb *tbl_scope_cb, - uint32_t num_entries, - uint32_t entry_sz_bytes) -{ - struct tfp_calloc_parms parms; - uint32_t i; - int32_t j; - int rc = 0; - struct stack *pool = &tbl_scope_cb->ext_act_pool[dir]; - - parms.nitems = num_entries; - parms.size = sizeof(uint32_t); - parms.alignment = 0; - - if (tfp_calloc(&parms) != 0) { - TFP_DRV_LOG(ERR, "%s: TBL: external pool failure %s\n", - tf_dir_2_str(dir), strerror(ENOMEM)); - return -ENOMEM; - } - - /* Create empty stack - */ - rc = stack_init(num_entries, parms.mem_va, pool); - - if (rc != 0) { - TFP_DRV_LOG(ERR, "%s: TBL: stack init failure %s\n", - tf_dir_2_str(dir), strerror(-rc)); - goto cleanup; - } - - /* Save the malloced memory address so that it can - * be freed when the table scope is freed. - */ - tbl_scope_cb->ext_act_pool_mem[dir] = (uint32_t *)parms.mem_va; - - /* Fill pool with indexes in reverse - */ - j = (num_entries - 1) * entry_sz_bytes; - - for (i = 0; i < num_entries; i++) { - rc = stack_push(pool, j); - if (rc != 0) { - TFP_DRV_LOG(ERR, "%s TBL: stack failure %s\n", - tf_dir_2_str(dir), strerror(-rc)); - goto cleanup; - } - - if (j < 0) { - TFP_DRV_LOG(ERR, "%d TBL: invalid offset (%d)\n", - dir, j); - goto cleanup; - } - j -= entry_sz_bytes; - } - - if (!stack_is_full(pool)) { - rc = -EINVAL; - TFP_DRV_LOG(ERR, "%s TBL: stack failure %s\n", - tf_dir_2_str(dir), strerror(-rc)); - goto cleanup; - } - return 0; -cleanup: - tfp_free((void *)parms.mem_va); - return rc; -} - -/** - * Destroy External Tbl pool of memory indexes. - * - * [in] dir - * direction - * [in] tbl_scope_cb - * pointer to the table scope - */ -void -tf_destroy_tbl_pool_external(enum tf_dir dir, - struct tf_tbl_scope_cb *tbl_scope_cb) -{ - uint32_t *ext_act_pool_mem = - tbl_scope_cb->ext_act_pool_mem[dir]; - - tfp_free(ext_act_pool_mem); -} - -/** - * Looks up table scope control block using tbl_scope_id from tf_session. - * - * [in] tfp - * Pointer to Truflow Handle - * [in] tbl_scope_id - * table scope id - * - * Return: - * - Pointer to the tf_tbl_scope_cb, if found. - * - (NULL) on failure, not found. - */ -struct tf_tbl_scope_cb * -tf_em_ext_common_tbl_scope_find(struct tf *tfp, - uint32_t tbl_scope_id) -{ - int rc; - struct em_ext_db *ext_db; - void *ext_ptr = NULL; - struct tf_tbl_scope_cb *tbl_scope_cb = NULL; - struct ll_entry *entry; - - rc = tf_session_get_em_ext_db(tfp, &ext_ptr); - if (rc) - return NULL; - - ext_db = (struct em_ext_db *)ext_ptr; - - for (entry = ext_db->tbl_scope_ll.head; entry != NULL; - entry = entry->next) { - tbl_scope_cb = (struct tf_tbl_scope_cb *)entry; - if (tbl_scope_cb->tbl_scope_id == tbl_scope_id) - return tbl_scope_cb; - } - - return NULL; -} - -/** - * Allocate External Tbl entry from the scope pool. - * - * [in] tfp - * Pointer to Truflow Handle - * [in] parms - * Allocation parameters - * - * Return: - * 0 - Success, entry allocated - no search support - * -ENOMEM -EINVAL -EOPNOTSUPP - * - Failure, entry not allocated, out of resources - */ -int -tf_tbl_ext_alloc(struct tf *tfp, - struct tf_tbl_alloc_parms *parms) -{ - int rc; - uint32_t index; - struct tf_tbl_scope_cb *tbl_scope_cb; - struct stack *pool; - - TF_CHECK_PARMS2(tfp, parms); - - tbl_scope_cb = tf_em_ext_common_tbl_scope_find(tfp, parms->tbl_scope_id); - if (tbl_scope_cb == NULL) { - TFP_DRV_LOG(ERR, - "%s, table scope not allocated\n", - tf_dir_2_str(parms->dir)); - return -EINVAL; - } - - pool = &tbl_scope_cb->ext_act_pool[parms->dir]; - - /* Allocate an element - */ - rc = stack_pop(pool, &index); - - if (rc != 0) { - TFP_DRV_LOG(ERR, - "%s, Allocation failed, type:%d\n", - tf_dir_2_str(parms->dir), - parms->type); - return rc; - } - - *parms->idx = index; - return rc; -} - -/** - * Free External Tbl entry to the scope pool. - * - * [in] tfp - * Pointer to Truflow Handle - * [in] parms - * Allocation parameters - * - * Return: - * 0 - Success, entry freed - * - * - Failure, entry not successfully freed for these reasons - * -ENOMEM - * -EOPNOTSUPP - * -EINVAL - */ -int -tf_tbl_ext_free(struct tf *tfp, - struct tf_tbl_free_parms *parms) -{ - int rc = 0; - uint32_t index; - struct tf_tbl_scope_cb *tbl_scope_cb; - struct stack *pool; - - TF_CHECK_PARMS2(tfp, parms); - - tbl_scope_cb = tf_em_ext_common_tbl_scope_find(tfp, parms->tbl_scope_id); - if (tbl_scope_cb == NULL) { - TFP_DRV_LOG(ERR, - "%s, table scope error\n", - tf_dir_2_str(parms->dir)); - return -EINVAL; - } - pool = &tbl_scope_cb->ext_act_pool[parms->dir]; - - index = parms->idx; - - rc = stack_push(pool, index); - - if (rc != 0) { - TFP_DRV_LOG(ERR, - "%s, consistency error, stack full, type:%d, idx:%d\n", - tf_dir_2_str(parms->dir), - parms->type, - index); - } - return rc; -} - -uint32_t -tf_em_get_key_mask(int num_entries) -{ - uint32_t mask = num_entries - 1; - - if (num_entries & TF_EM_MAX_MASK) - return 0; - - if (num_entries > TF_EM_MAX_ENTRY) - return 0; - - return mask; -} - -void -tf_em_create_key_entry(struct cfa_p4_eem_entry_hdr *result, - uint8_t *in_key, - struct cfa_p4_eem_64b_entry *key_entry) -{ - key_entry->hdr.word1 = result->word1; - key_entry->hdr.pointer = result->pointer; - memcpy(key_entry->key, in_key, TF_P4_HW_EM_KEY_MAX_SIZE + 4); -} - -/** - * Return the number of page table pages needed to - * reference the given number of next level pages. - * - * [in] num_pages - * Number of EM pages - * - * [in] page_size - * Size of each EM page - * - * Returns: - * Number of EM page table pages - */ -static uint32_t -tf_em_page_tbl_pgcnt(uint32_t num_pages, - uint32_t page_size) -{ - return roundup(num_pages, MAX_PAGE_PTRS(page_size)) / - MAX_PAGE_PTRS(page_size); - return 0; -} - -/** - * Given the number of data pages, page_size and the maximum - * number of page table levels (already determined), size - * the number of page table pages required at each level. - * - * [in] max_lvl - * Max number of levels - * - * [in] num_data_pages - * Number of EM data pages - * - * [in] page_size - * Size of an EM page - * - * [out] *page_cnt - * EM page count - */ -static void -tf_em_size_page_tbls(int max_lvl, - uint64_t num_data_pages, - uint32_t page_size, - uint32_t *page_cnt) -{ - if (max_lvl == TF_PT_LVL_0) { - page_cnt[TF_PT_LVL_0] = num_data_pages; - } else if (max_lvl == TF_PT_LVL_1) { - page_cnt[TF_PT_LVL_1] = num_data_pages; - page_cnt[TF_PT_LVL_0] = - tf_em_page_tbl_pgcnt(page_cnt[TF_PT_LVL_1], page_size); - } else if (max_lvl == TF_PT_LVL_2) { - page_cnt[TF_PT_LVL_2] = num_data_pages; - page_cnt[TF_PT_LVL_1] = - tf_em_page_tbl_pgcnt(page_cnt[TF_PT_LVL_2], page_size); - page_cnt[TF_PT_LVL_0] = - tf_em_page_tbl_pgcnt(page_cnt[TF_PT_LVL_1], page_size); - } else { - return; - } -} - -/** - * Given the page size, size of each data item (entry size), - * and the total number of entries needed, determine the number - * of page table levels and the number of data pages required. - * - * [in] page_size - * Page size - * - * [in] entry_size - * Entry size - * - * [in] num_entries - * Number of entries needed - * - * [out] num_data_pages - * Number of pages required - * - * Returns: - * Success - Number of EM page levels required - * -ENOMEM - Out of memory - */ -static int -tf_em_size_page_tbl_lvl(uint32_t page_size, - uint32_t entry_size, - uint32_t num_entries, - uint64_t *num_data_pages) -{ - uint64_t lvl_data_size = page_size; - int lvl = TF_PT_LVL_0; - uint64_t data_size; - - *num_data_pages = 0; - data_size = (uint64_t)num_entries * entry_size; - - while (lvl_data_size < data_size) { - lvl++; - - if (lvl == TF_PT_LVL_1) - lvl_data_size = (uint64_t)MAX_PAGE_PTRS(page_size) * - page_size; - else if (lvl == TF_PT_LVL_2) - lvl_data_size = (uint64_t)MAX_PAGE_PTRS(page_size) * - MAX_PAGE_PTRS(page_size) * page_size; - else - return -ENOMEM; - } - - *num_data_pages = roundup(data_size, page_size) / page_size; - - return lvl; -} - -/** - * Size the EM table based on capabilities - * - * [in] tbl - * EM table to size - * - * Returns: - * 0 - Success - * - EINVAL - Parameter error - * - ENOMEM - Out of memory - */ -int -tf_em_size_table(struct hcapi_cfa_em_table *tbl, - uint32_t page_size) -{ - uint64_t num_data_pages; - uint32_t *page_cnt; - int max_lvl; - uint32_t num_entries; - uint32_t cnt = TF_EM_MIN_ENTRIES; - - /* Ignore entry if both size and number are zero */ - if (!tbl->entry_size && !tbl->num_entries) - return 0; - - /* If only one is set then error */ - if (!tbl->entry_size || !tbl->num_entries) - return -EINVAL; - - /* Determine number of page table levels and the number - * of data pages needed to process the given eem table. - */ - if (tbl->type == TF_RECORD_TABLE) { - /* - * For action records just a memory size is provided. Work - * backwards to resolve to number of entries - */ - num_entries = tbl->num_entries / tbl->entry_size; - if (num_entries < TF_EM_MIN_ENTRIES) { - num_entries = TF_EM_MIN_ENTRIES; - } else { - while (num_entries > cnt && cnt <= TF_EM_MAX_ENTRIES) - cnt *= 2; - num_entries = cnt; - } - } else { - num_entries = tbl->num_entries; - } - - max_lvl = tf_em_size_page_tbl_lvl(page_size, - tbl->entry_size, - tbl->num_entries, - &num_data_pages); - if (max_lvl < 0) { - TFP_DRV_LOG(WARNING, "EEM: Failed to size page table levels\n"); - TFP_DRV_LOG(WARNING, - "table: %d data-sz: %016" PRIu64 " page-sz: %u\n", - tbl->type, (uint64_t)num_entries * tbl->entry_size, - page_size); - return -ENOMEM; - } - - tbl->num_lvl = max_lvl + 1; - tbl->num_data_pages = num_data_pages; - - /* Determine the number of pages needed at each level */ - page_cnt = tbl->page_cnt; - memset(page_cnt, 0, sizeof(tbl->page_cnt)); - tf_em_size_page_tbls(max_lvl, num_data_pages, page_size, - page_cnt); - - TFP_DRV_LOG(INFO, "EEM: Sized page table: %d\n", tbl->type); - TFP_DRV_LOG(INFO, - "EEM: lvls: %d sz: %016" PRIu64 " pgs: %016" PRIu64 \ - " l0: %u l1: %u l2: %u\n", - max_lvl + 1, - (uint64_t)num_data_pages * page_size, - num_data_pages, - page_cnt[TF_PT_LVL_0], - page_cnt[TF_PT_LVL_1], - page_cnt[TF_PT_LVL_2]); - - return 0; -} - -/** - * Validates EM number of entries requested - * - * [in] tbl_scope_cb - * Pointer to table scope control block to be populated - * - * [in] parms - * Pointer to input parameters - * - * Returns: - * 0 - Success - * -EINVAL - Parameter error - */ -int -tf_em_validate_num_entries(struct tf_tbl_scope_cb *tbl_scope_cb, - struct tf_alloc_tbl_scope_parms *parms) -{ - uint32_t cnt; - - if (parms->rx_mem_size_in_mb != 0) { - uint32_t key_b = 2 * ((parms->rx_max_key_sz_in_bits / 8) + 1); - uint32_t action_b = ((parms->rx_max_action_entry_sz_in_bits / 8) - + 1); - uint32_t num_entries = (parms->rx_mem_size_in_mb * - TF_MEGABYTE) / (key_b + action_b); - - if (num_entries < TF_EM_MIN_ENTRIES) { - TFP_DRV_LOG(ERR, "EEM: Insufficient memory requested:" - "%uMB\n", - parms->rx_mem_size_in_mb); - return -EINVAL; - } - - cnt = TF_EM_MIN_ENTRIES; - while (num_entries > cnt && - cnt <= TF_EM_MAX_ENTRIES) - cnt *= 2; - - if (cnt > TF_EM_MAX_ENTRIES) { - TFP_DRV_LOG(ERR, "EEM: Invalid number of Tx requested: " - "%u\n", - (parms->tx_num_flows_in_k * TF_KILOBYTE)); - return -EINVAL; - } - - parms->rx_num_flows_in_k = cnt / TF_KILOBYTE; - } else { - if ((parms->rx_num_flows_in_k * TF_KILOBYTE) < - TF_EM_MIN_ENTRIES || - (parms->rx_num_flows_in_k * TF_KILOBYTE) > - tbl_scope_cb->em_caps[TF_DIR_RX].max_entries_supported) { - TFP_DRV_LOG(ERR, - "EEM: Invalid number of Rx flows " - "requested:%u max:%u\n", - parms->rx_num_flows_in_k * TF_KILOBYTE, - tbl_scope_cb->em_caps[TF_DIR_RX].max_entries_supported); - return -EINVAL; - } - - /* must be a power-of-2 supported value - * in the range 32K - 128M - */ - cnt = TF_EM_MIN_ENTRIES; - while ((parms->rx_num_flows_in_k * TF_KILOBYTE) != cnt && - cnt <= TF_EM_MAX_ENTRIES) - cnt *= 2; - - if (cnt > TF_EM_MAX_ENTRIES) { - TFP_DRV_LOG(ERR, - "EEM: Invalid number of Rx requested: %u\n", - (parms->rx_num_flows_in_k * TF_KILOBYTE)); - return -EINVAL; - } - } - - if (parms->tx_mem_size_in_mb != 0) { - uint32_t key_b = 2 * (parms->tx_max_key_sz_in_bits / 8 + 1); - uint32_t action_b = ((parms->tx_max_action_entry_sz_in_bits / 8) - + 1); - uint32_t num_entries = (parms->tx_mem_size_in_mb * - (TF_KILOBYTE * TF_KILOBYTE)) / - (key_b + action_b); - - if (num_entries < TF_EM_MIN_ENTRIES) { - TFP_DRV_LOG(ERR, - "EEM: Insufficient memory requested:%uMB\n", - parms->rx_mem_size_in_mb); - return -EINVAL; - } - - cnt = TF_EM_MIN_ENTRIES; - while (num_entries > cnt && - cnt <= TF_EM_MAX_ENTRIES) - cnt *= 2; - - if (cnt > TF_EM_MAX_ENTRIES) { - TFP_DRV_LOG(ERR, - "EEM: Invalid number of Tx requested: %u\n", - (parms->tx_num_flows_in_k * TF_KILOBYTE)); - return -EINVAL; - } - - parms->tx_num_flows_in_k = cnt / TF_KILOBYTE; - } else { - if ((parms->tx_num_flows_in_k * TF_KILOBYTE) < - TF_EM_MIN_ENTRIES || - (parms->tx_num_flows_in_k * TF_KILOBYTE) > - tbl_scope_cb->em_caps[TF_DIR_TX].max_entries_supported) { - TFP_DRV_LOG(ERR, - "EEM: Invalid number of Tx flows " - "requested:%u max:%u\n", - (parms->tx_num_flows_in_k * TF_KILOBYTE), - tbl_scope_cb->em_caps[TF_DIR_TX].max_entries_supported); - return -EINVAL; - } - - cnt = TF_EM_MIN_ENTRIES; - while ((parms->tx_num_flows_in_k * TF_KILOBYTE) != cnt && - cnt <= TF_EM_MAX_ENTRIES) - cnt *= 2; - - if (cnt > TF_EM_MAX_ENTRIES) { - TFP_DRV_LOG(ERR, - "EEM: Invalid number of Tx requested: %u\n", - (parms->tx_num_flows_in_k * TF_KILOBYTE)); - return -EINVAL; - } - } - - if (parms->rx_num_flows_in_k != 0 && - parms->rx_max_key_sz_in_bits / 8 == 0) { - TFP_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) { - TFP_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[TF_KEY0_TABLE].num_entries = - parms->rx_num_flows_in_k * TF_KILOBYTE; - tbl_scope_cb->em_ctx_info[TF_DIR_RX].em_tables[TF_KEY0_TABLE].entry_size = - parms->rx_max_key_sz_in_bits / 8; - - tbl_scope_cb->em_ctx_info[TF_DIR_RX].em_tables[TF_KEY1_TABLE].num_entries = - parms->rx_num_flows_in_k * TF_KILOBYTE; - tbl_scope_cb->em_ctx_info[TF_DIR_RX].em_tables[TF_KEY1_TABLE].entry_size = - parms->rx_max_key_sz_in_bits / 8; - - tbl_scope_cb->em_ctx_info[TF_DIR_RX].em_tables[TF_RECORD_TABLE].num_entries = - parms->rx_num_flows_in_k * TF_KILOBYTE; - tbl_scope_cb->em_ctx_info[TF_DIR_RX].em_tables[TF_RECORD_TABLE].entry_size = - parms->rx_max_action_entry_sz_in_bits / 8; - - tbl_scope_cb->em_ctx_info[TF_DIR_RX].em_tables[TF_EFC_TABLE].num_entries = - 0; - - tbl_scope_cb->em_ctx_info[TF_DIR_RX].em_tables[TF_ACTION_TABLE].num_entries = - parms->rx_num_flows_in_k * TF_KILOBYTE; - tbl_scope_cb->em_ctx_info[TF_DIR_RX].em_tables[TF_ACTION_TABLE].entry_size = - parms->rx_max_action_entry_sz_in_bits / 8; - - tbl_scope_cb->em_ctx_info[TF_DIR_RX].em_tables[TF_EM_LKUP_TABLE].num_entries = - parms->rx_num_flows_in_k * TF_KILOBYTE; - tbl_scope_cb->em_ctx_info[TF_DIR_RX].em_tables[TF_EM_LKUP_TABLE].entry_size = - parms->rx_max_key_sz_in_bits / 8; - - /* Tx */ - tbl_scope_cb->em_ctx_info[TF_DIR_TX].em_tables[TF_KEY0_TABLE].num_entries = - parms->tx_num_flows_in_k * TF_KILOBYTE; - tbl_scope_cb->em_ctx_info[TF_DIR_TX].em_tables[TF_KEY0_TABLE].entry_size = - parms->tx_max_key_sz_in_bits / 8; - - tbl_scope_cb->em_ctx_info[TF_DIR_TX].em_tables[TF_KEY1_TABLE].num_entries = - parms->tx_num_flows_in_k * TF_KILOBYTE; - tbl_scope_cb->em_ctx_info[TF_DIR_TX].em_tables[TF_KEY1_TABLE].entry_size = - parms->tx_max_key_sz_in_bits / 8; - - tbl_scope_cb->em_ctx_info[TF_DIR_TX].em_tables[TF_RECORD_TABLE].num_entries = - parms->tx_num_flows_in_k * TF_KILOBYTE; - tbl_scope_cb->em_ctx_info[TF_DIR_TX].em_tables[TF_RECORD_TABLE].entry_size = - parms->tx_max_action_entry_sz_in_bits / 8; - - tbl_scope_cb->em_ctx_info[TF_DIR_TX].em_tables[TF_EFC_TABLE].num_entries = - 0; - - tbl_scope_cb->em_ctx_info[TF_DIR_TX].em_tables[TF_ACTION_TABLE].num_entries = - parms->rx_num_flows_in_k * TF_KILOBYTE; - tbl_scope_cb->em_ctx_info[TF_DIR_TX].em_tables[TF_ACTION_TABLE].entry_size = - parms->tx_max_action_entry_sz_in_bits / 8; - - tbl_scope_cb->em_ctx_info[TF_DIR_TX].em_tables[TF_EM_LKUP_TABLE].num_entries = - parms->rx_num_flows_in_k * TF_KILOBYTE; - tbl_scope_cb->em_ctx_info[TF_DIR_TX].em_tables[TF_EM_LKUP_TABLE].entry_size = - parms->tx_max_key_sz_in_bits / 8; - - return 0; -} - -/** insert EEM entry API - * - * returns: - * 0 - * TF_ERR - unable to get lock - * - * insert callback returns: - * 0 - * TF_ERR_EM_DUP - key is already in table - */ -static int -tf_insert_eem_entry(struct tf_dev_info *dev, - struct tf_tbl_scope_cb *tbl_scope_cb, - struct tf_insert_em_entry_parms *parms) -{ - uint32_t mask; - uint32_t key0_hash; - uint32_t key1_hash; - uint32_t key0_index; - uint32_t key1_index; - struct cfa_p4_eem_64b_entry key_entry; - uint32_t index; - enum hcapi_cfa_em_table_type table_type; - uint32_t gfid; - struct hcapi_cfa_hwop op; - struct hcapi_cfa_key_tbl key_tbl; - struct hcapi_cfa_key_data key_obj; - struct hcapi_cfa_key_loc key_loc; - uint64_t big_hash; - int rc; - - /* Get mask to use on hash */ - mask = tf_em_get_key_mask(tbl_scope_cb->em_ctx_info[parms->dir].em_tables[TF_KEY0_TABLE].num_entries); - - if (!mask) - return -EINVAL; - - if (dev->ops->tf_dev_cfa_key_hash == NULL) - return -EINVAL; - - big_hash = dev->ops->tf_dev_cfa_key_hash((uint64_t *)parms->key, - (TF_P4_HW_EM_KEY_MAX_SIZE + 4) * 8); - key0_hash = (uint32_t)(big_hash >> 32); - key1_hash = (uint32_t)(big_hash & 0xFFFFFFFF); - - key0_index = key0_hash & mask; - key1_index = key1_hash & mask; - - /* - * Use the "result" arg to populate all of the key entry then - * store the byte swapped "raw" entry in a local copy ready - * for insertion in to the table. - */ - tf_em_create_key_entry((struct cfa_p4_eem_entry_hdr *)parms->em_record, - ((uint8_t *)parms->key), - &key_entry); - - /* - * Try to add to Key0 table, if that does not work then - * try the key1 table. - */ - index = key0_index; - op.opcode = HCAPI_CFA_HWOPS_ADD; - key_tbl.base0 = - (uint8_t *)&tbl_scope_cb->em_ctx_info[parms->dir].em_tables[TF_KEY0_TABLE]; - key_tbl.page_size = TF_EM_PAGE_SIZE; - key_obj.offset = index * TF_P4_EM_KEY_RECORD_SIZE; - key_obj.data = (uint8_t *)&key_entry; - key_obj.size = TF_P4_EM_KEY_RECORD_SIZE; - - rc = cfa_p4_devops.hcapi_cfa_key_hw_op(&op, - &key_tbl, - &key_obj, - &key_loc); - - if (rc == 0) { - table_type = TF_KEY0_TABLE; - } else { - index = key1_index; - - key_tbl.base0 = - (uint8_t *)&tbl_scope_cb->em_ctx_info[parms->dir].em_tables[TF_KEY1_TABLE]; - key_obj.offset = index * TF_P4_EM_KEY_RECORD_SIZE; - - rc = cfa_p4_devops.hcapi_cfa_key_hw_op(&op, - &key_tbl, - &key_obj, - &key_loc); - if (rc != 0) - return rc; - - table_type = TF_KEY1_TABLE; - } - - TF_SET_GFID(gfid, - index, - table_type); - TF_SET_FLOW_ID(parms->flow_id, - gfid, - TF_GFID_TABLE_EXTERNAL, - parms->dir); - TF_SET_FIELDS_IN_FLOW_HANDLE(parms->flow_handle, - 0, - 0, - 0, - index, - 0, - table_type); - - return 0; -} - -/** delete EEM hash entry API - * - * returns: - * 0 - * -EINVAL - parameter error - * TF_NO_SESSION - bad session ID - * TF_ERR_TBL_SCOPE - invalid table scope - * TF_ERR_TBL_IF - invalid table interface - * - * insert callback returns - * 0 - * TF_NO_EM_MATCH - entry not found - */ -static int -tf_delete_eem_entry(struct tf_tbl_scope_cb *tbl_scope_cb, - struct tf_delete_em_entry_parms *parms) -{ - enum hcapi_cfa_em_table_type hash_type; - uint32_t index; - struct hcapi_cfa_hwop op; - struct hcapi_cfa_key_tbl key_tbl; - struct hcapi_cfa_key_data key_obj; - struct hcapi_cfa_key_loc key_loc; - int rc; - - TF_GET_HASH_TYPE_FROM_FLOW_HANDLE(parms->flow_handle, hash_type); - TF_GET_INDEX_FROM_FLOW_HANDLE(parms->flow_handle, index); - - op.opcode = HCAPI_CFA_HWOPS_DEL; - key_tbl.base0 = - (uint8_t *)&tbl_scope_cb->em_ctx_info[parms->dir].em_tables - [(hash_type == 0 ? TF_KEY0_TABLE : TF_KEY1_TABLE)]; - key_tbl.page_size = TF_EM_PAGE_SIZE; - key_obj.offset = index * TF_P4_EM_KEY_RECORD_SIZE; - key_obj.data = NULL; - key_obj.size = TF_P4_EM_KEY_RECORD_SIZE; - - rc = cfa_p4_devops.hcapi_cfa_key_hw_op(&op, - &key_tbl, - &key_obj, - &key_loc); - - if (!rc) - return rc; - - return 0; -} - -/** insert EM hash entry API - * - * returns: - * 0 - Success - * -EINVAL - Error - */ -int -tf_em_insert_ext_entry(struct tf *tfp, - struct tf_insert_em_entry_parms *parms) -{ - int rc; - struct tf_tbl_scope_cb *tbl_scope_cb; - struct tf_session *tfs; - struct tf_dev_info *dev; - - tbl_scope_cb = tf_em_ext_common_tbl_scope_find(tfp, parms->tbl_scope_id); - if (tbl_scope_cb == NULL) { - TFP_DRV_LOG(ERR, "Invalid tbl_scope_cb\n"); - return -EINVAL; - } - - /* Retrieve the session information */ - rc = tf_session_get_session_internal(tfp, &tfs); - if (rc) - return rc; - - /* Retrieve the device information */ - rc = tf_session_get_device(tfs, &dev); - if (rc) - return rc; - - return tf_insert_eem_entry - (dev, - tbl_scope_cb, - parms); -} - -/** Delete EM hash entry API - * - * returns: - * 0 - Success - * -EINVAL - Error - */ -int -tf_em_delete_ext_entry(struct tf *tfp, - struct tf_delete_em_entry_parms *parms) -{ - struct tf_tbl_scope_cb *tbl_scope_cb; - - tbl_scope_cb = tf_em_ext_common_tbl_scope_find(tfp, parms->tbl_scope_id); - if (tbl_scope_cb == NULL) { - TFP_DRV_LOG(ERR, "Invalid tbl_scope_cb\n"); - return -EINVAL; - } - - return tf_delete_eem_entry(tbl_scope_cb, parms); -} - -int -tf_em_ext_common_bind(struct tf *tfp, - struct tf_em_cfg_parms *parms) -{ - int rc; - int i; - struct tf_rm_create_db_parms db_cfg = { 0 }; - struct em_ext_db *ext_db; - struct tfp_calloc_parms cparms; - - TF_CHECK_PARMS2(tfp, parms); - - cparms.nitems = 1; - cparms.size = sizeof(struct em_ext_db); - cparms.alignment = 0; - if (tfp_calloc(&cparms) != 0) { - TFP_DRV_LOG(ERR, "em_ext_db alloc error %s\n", - strerror(ENOMEM)); - return -ENOMEM; - } - - ext_db = cparms.mem_va; - ll_init(&ext_db->tbl_scope_ll); - for (i = 0; i < TF_DIR_MAX; i++) - ext_db->eem_db[i] = NULL; - tf_session_set_em_ext_db(tfp, ext_db); - - db_cfg.module = TF_MODULE_TYPE_EM; - db_cfg.num_elements = parms->num_elements; - db_cfg.cfg = parms->cfg; - - for (i = 0; i < TF_DIR_MAX; i++) { - db_cfg.dir = i; - db_cfg.alloc_cnt = parms->resources->em_cnt[i].cnt; - - /* Check if we got any request to support EEM, if so - * we build an EM Ext DB holding Table Scopes. - */ - if (db_cfg.alloc_cnt[TF_EM_TBL_TYPE_TBL_SCOPE] == 0) - continue; - - db_cfg.rm_db = (void *)&ext_db->eem_db[i]; - rc = tf_rm_create_db(tfp, &db_cfg); - if (rc) { - TFP_DRV_LOG(ERR, - "%s: EM Ext DB creation failed\n", - tf_dir_2_str(i)); - - return rc; - } - } - - mem_type = parms->mem_type; - - return 0; -} - -int -tf_em_ext_common_unbind(struct tf *tfp) -{ - int rc; - int i; - struct tf_rm_free_db_parms fparms = { 0 }; - struct em_ext_db *ext_db = NULL; - struct tf_session *tfs = NULL; - struct tf_dev_info *dev; - struct ll_entry *entry; - struct tf_tbl_scope_cb *tbl_scope_cb = NULL; - void *ext_ptr = NULL; - struct tf_free_tbl_scope_parms tparms = { 0 }; - - TF_CHECK_PARMS1(tfp); - - rc = tf_session_get_session_internal(tfp, &tfs); - if (rc) { - TFP_DRV_LOG(ERR, "Failed to get tf_session, rc:%s\n", - strerror(-rc)); - return rc; - } - - /* Retrieve the device information */ - rc = tf_session_get_device(tfs, &dev); - if (rc) { - TFP_DRV_LOG(ERR, - "Failed to lookup device, rc:%s\n", - strerror(-rc)); - return rc; - } - - rc = tf_session_get_em_ext_db(tfp, &ext_ptr); - if (rc) { - TFP_DRV_LOG(ERR, - "Failed to get em_ext_db from session, rc:%s\n", - strerror(-rc)); - return rc; - } - - ext_db = (struct em_ext_db *)ext_ptr; - if (ext_db != NULL) { - entry = ext_db->tbl_scope_ll.head; - while (entry != NULL) { - tbl_scope_cb = (struct tf_tbl_scope_cb *)entry; - entry = entry->next; - tparms.tbl_scope_id = - tbl_scope_cb->tbl_scope_id; - - if (dev->ops->tf_dev_free_tbl_scope) { - dev->ops->tf_dev_free_tbl_scope(tfp, - &tparms); - } else { - /* should not reach here */ - ll_delete(&ext_db->tbl_scope_ll, - &tbl_scope_cb->ll_entry); - tfp_free(tbl_scope_cb); - } - } - - for (i = 0; i < TF_DIR_MAX; i++) { - if (ext_db->eem_db[i] == NULL) - continue; - - fparms.dir = i; - fparms.rm_db = ext_db->eem_db[i]; - rc = tf_rm_free_db(tfp, &fparms); - if (rc) - return rc; - - ext_db->eem_db[i] = NULL; - } - - tfp_free(ext_db); - } - - tf_session_set_em_ext_db(tfp, NULL); - - return 0; -} - -/** - * Sets the specified external table type element. - * - * This API sets the specified element data - * - * [in] tfp - * Pointer to TF handle - * - * [in] parms - * Pointer to table set parameters - * - * Returns - * - (0) if successful. - * - (-EINVAL) on failure. - */ -int tf_tbl_ext_common_set(struct tf *tfp, - struct tf_tbl_set_parms *parms) -{ - int rc = 0; - struct tf_tbl_scope_cb *tbl_scope_cb; - uint32_t tbl_scope_id; - struct hcapi_cfa_hwop op; - struct hcapi_cfa_key_tbl key_tbl; - struct hcapi_cfa_key_data key_obj; - struct hcapi_cfa_key_loc key_loc; - - TF_CHECK_PARMS2(tfp, parms); - - if (parms->data == NULL) { - TFP_DRV_LOG(ERR, - "%s, invalid parms->data\n", - tf_dir_2_str(parms->dir)); - return -EINVAL; - } - - tbl_scope_id = parms->tbl_scope_id; - - if (tbl_scope_id == TF_TBL_SCOPE_INVALID) { - TFP_DRV_LOG(ERR, - "%s, Table scope not allocated\n", - tf_dir_2_str(parms->dir)); - return -EINVAL; - } - - tbl_scope_cb = tf_em_ext_common_tbl_scope_find(tfp, tbl_scope_id); - if (tbl_scope_cb == NULL) { - TFP_DRV_LOG(ERR, - "%s, table scope error\n", - tf_dir_2_str(parms->dir)); - return -EINVAL; - } - - op.opcode = HCAPI_CFA_HWOPS_PUT; - key_tbl.base0 = - (uint8_t *)&tbl_scope_cb->em_ctx_info[parms->dir].em_tables[TF_RECORD_TABLE]; - key_tbl.page_size = TF_EM_PAGE_SIZE; - key_obj.offset = parms->idx; - key_obj.data = parms->data; - key_obj.size = parms->data_sz_in_bytes; - - rc = cfa_p4_devops.hcapi_cfa_key_hw_op(&op, - &key_tbl, - &key_obj, - &key_loc); - - return rc; -} - -int -tf_em_ext_common_alloc(struct tf *tfp, - struct tf_alloc_tbl_scope_parms *parms) -{ - return tf_em_ext_alloc(tfp, parms); -} - -int -tf_em_ext_common_free(struct tf *tfp, - struct tf_free_tbl_scope_parms *parms) -{ - return tf_em_ext_free(tfp, parms); -} - -int tf_em_ext_map_tbl_scope(struct tf *tfp, - struct tf_map_tbl_scope_parms *parms) -{ - int rc = 0; - struct tf_session *tfs; - struct tf_tbl_scope_cb *tbl_scope_cb; - struct tf_global_cfg_parms gcfg_parms = { 0 }; - struct tfp_calloc_parms aparms; - uint32_t *data, *mask; - uint32_t sz_in_bytes = 8; - struct tf_dev_info *dev; - - /* Retrieve the session information */ - rc = tf_session_get_session_internal(tfp, &tfs); - if (rc) - return rc; - - /* Retrieve the device information */ - rc = tf_session_get_device(tfs, &dev); - if (rc) - return rc; - - tbl_scope_cb = tf_em_ext_common_tbl_scope_find(tfp, parms->tbl_scope_id); - if (tbl_scope_cb == NULL) { - TFP_DRV_LOG(ERR, "Invalid tbl_scope_cb tbl_scope_id(%d)\n", - parms->tbl_scope_id); - return -EINVAL; - } - - if (dev->ops->tf_dev_map_tbl_scope == NULL) { - rc = -EOPNOTSUPP; - TFP_DRV_LOG(ERR, - "Map table scope operation not supported, rc:%s\n", - strerror(-rc)); - return rc; - } - - aparms.nitems = 2; - aparms.size = sizeof(uint32_t); - aparms.alignment = 0; - - if (tfp_calloc(&aparms) != 0) { - TFP_DRV_LOG(ERR, "Map tbl scope alloc data error %s\n", - strerror(ENOMEM)); - return -ENOMEM; - } - data = aparms.mem_va; - - if (tfp_calloc(&aparms) != 0) { - TFP_DRV_LOG(ERR, "Map tbl scope alloc mask error %s\n", - strerror(ENOMEM)); - rc = -ENOMEM; - goto clean; - } - mask = aparms.mem_va; - - rc = dev->ops->tf_dev_map_parif(tfp, parms->parif_bitmask, - tbl_scope_cb->pf, - (uint8_t *)data, (uint8_t *)mask, - sz_in_bytes); - - if (rc) { - TFP_DRV_LOG(ERR, - "Map table scope config failure, rc:%s\n", - strerror(-rc)); - goto cleaner; - } - - /* Note that TF_GLOBAL_CFG_INTERNAL_PARIF_2_PF is same as below enum */ - gcfg_parms.type = TF_GLOBAL_CFG_TYPE_MAX; - gcfg_parms.offset = 0; - gcfg_parms.config = (uint8_t *)data; - gcfg_parms.config_mask = (uint8_t *)mask; - gcfg_parms.config_sz_in_bytes = sizeof(uint64_t); - - rc = tf_msg_set_global_cfg(tfp, &gcfg_parms); - if (rc) { - TFP_DRV_LOG(ERR, - "Map tbl scope, set failed, rc:%s\n", - strerror(-rc)); - } -cleaner: - tfp_free(mask); -clean: - tfp_free(data); - - return rc; -} diff --git a/drivers/net/bnxt/tf_core/tf_em_common.h b/drivers/net/bnxt/tf_core/tf_em_common.h index 0ae95f260a..3625673952 100644 --- a/drivers/net/bnxt/tf_core/tf_em_common.h +++ b/drivers/net/bnxt/tf_core/tf_em_common.h @@ -6,6 +6,7 @@ #ifndef _TF_EM_COMMON_H_ #define _TF_EM_COMMON_H_ +#include "hcapi_cfa_defs.h" #include "tf_core.h" #include "tf_session.h" #include "ll.h" diff --git a/drivers/net/bnxt/tf_core/tf_em_host.c b/drivers/net/bnxt/tf_core/tf_em_host.c index 9efffe4ee5..6db0057b2c 100644 --- a/drivers/net/bnxt/tf_core/tf_em_host.c +++ b/drivers/net/bnxt/tf_core/tf_em_host.c @@ -21,577 +21,3 @@ #include "tf_ext_flow_handle.h" #include "bnxt.h" - -#define PTU_PTE_VALID 0x1UL -#define PTU_PTE_LAST 0x2UL -#define PTU_PTE_NEXT_TO_LAST 0x4UL - -/* Number of pointers per page_size */ -#define MAX_PAGE_PTRS(page_size) ((page_size) / sizeof(void *)) - -/** - * Function to free a page table - * - * [in] tp - * Pointer to the page table to free - */ -static void -tf_em_free_pg_tbl(struct hcapi_cfa_em_page_tbl *tp) -{ - uint32_t i; - - for (i = 0; i < tp->pg_count; i++) { - if (!tp->pg_va_tbl[i]) { - TFP_DRV_LOG(WARNING, - "No mapping for page: %d table: %016" PRIu64 "\n", - i, - (uint64_t)(uintptr_t)tp); - continue; - } - - tfp_free(tp->pg_va_tbl[i]); - tp->pg_va_tbl[i] = NULL; - } - - tp->pg_count = 0; - tfp_free(tp->pg_va_tbl); - tp->pg_va_tbl = NULL; - tfp_free(tp->pg_pa_tbl); - tp->pg_pa_tbl = NULL; -} - -/** - * Function to free an EM table - * - * [in] tbl - * Pointer to the EM table to free - */ -static void -tf_em_free_page_table(struct hcapi_cfa_em_table *tbl) -{ - struct hcapi_cfa_em_page_tbl *tp; - int i; - - for (i = 0; i < tbl->num_lvl; i++) { - tp = &tbl->pg_tbl[i]; - TFP_DRV_LOG(INFO, - "EEM: Freeing page table: size %u lvl %d cnt %u\n", - TF_EM_PAGE_SIZE, - i, - tp->pg_count); - - tf_em_free_pg_tbl(tp); - } - - tbl->l0_addr = NULL; - tbl->l0_dma_addr = 0; - tbl->num_lvl = 0; - tbl->num_data_pages = 0; -} - -/** - * Allocation of page tables - * - * [in] tfp - * Pointer to a TruFlow handle - * - * [in] pg_count - * Page count to allocate - * - * [in] pg_size - * Size of each page - * - * Returns: - * 0 - Success - * -ENOMEM - Out of memory - */ -static int -tf_em_alloc_pg_tbl(struct hcapi_cfa_em_page_tbl *tp, - uint32_t pg_count, - uint32_t pg_size) -{ - uint32_t i; - struct tfp_calloc_parms parms; - - parms.nitems = pg_count; - parms.size = sizeof(void *); - parms.alignment = 0; - - if (tfp_calloc(&parms) != 0) - return -ENOMEM; - - tp->pg_va_tbl = parms.mem_va; - - if (tfp_calloc(&parms) != 0) { - tfp_free(tp->pg_va_tbl); - return -ENOMEM; - } - - tp->pg_pa_tbl = parms.mem_va; - - tp->pg_count = 0; - tp->pg_size = pg_size; - - for (i = 0; i < pg_count; i++) { - parms.nitems = 1; - parms.size = pg_size; - parms.alignment = TF_EM_PAGE_ALIGNMENT; - - if (tfp_calloc(&parms) != 0) - goto cleanup; - - tp->pg_pa_tbl[i] = (uintptr_t)parms.mem_pa; - tp->pg_va_tbl[i] = parms.mem_va; - - memset(tp->pg_va_tbl[i], 0, pg_size); - tp->pg_count++; - } - - return 0; - -cleanup: - tf_em_free_pg_tbl(tp); - return -ENOMEM; -} - -/** - * Allocates EM page tables - * - * [in] tbl - * Table to allocate pages for - * - * Returns: - * 0 - Success - * -ENOMEM - Out of memory - */ -static int -tf_em_alloc_page_table(struct hcapi_cfa_em_table *tbl) -{ - struct hcapi_cfa_em_page_tbl *tp; - int rc = 0; - int i; - uint32_t j; - - for (i = 0; i < tbl->num_lvl; i++) { - tp = &tbl->pg_tbl[i]; - - rc = tf_em_alloc_pg_tbl(tp, - tbl->page_cnt[i], - TF_EM_PAGE_SIZE); - if (rc) { - TFP_DRV_LOG(WARNING, - "Failed to allocate page table: lvl: %d, rc:%s\n", - i, - strerror(-rc)); - goto cleanup; - } - - for (j = 0; j < tp->pg_count; j++) { - TFP_DRV_LOG(INFO, - "EEM: Allocated page table: size %u lvl %d cnt" - " %u VA:%p PA:%p\n", - TF_EM_PAGE_SIZE, - i, - tp->pg_count, - (void *)(uintptr_t)tp->pg_va_tbl[j], - (void *)(uintptr_t)tp->pg_pa_tbl[j]); - } - } - return rc; - -cleanup: - tf_em_free_page_table(tbl); - return rc; -} - -/** - * Links EM page tables - * - * [in] tp - * Pointer to page table - * - * [in] tp_next - * Pointer to the next page table - * - * [in] set_pte_last - * Flag controlling if the page table is last - */ -static void -tf_em_link_page_table(struct hcapi_cfa_em_page_tbl *tp, - struct hcapi_cfa_em_page_tbl *tp_next, - bool set_pte_last) -{ - uint64_t *pg_pa = tp_next->pg_pa_tbl; - uint64_t *pg_va; - uint64_t valid; - uint32_t k = 0; - uint32_t i; - uint32_t j; - - for (i = 0; i < tp->pg_count; i++) { - pg_va = tp->pg_va_tbl[i]; - - for (j = 0; j < MAX_PAGE_PTRS(tp->pg_size); j++) { - if (k == tp_next->pg_count - 2 && set_pte_last) - valid = PTU_PTE_NEXT_TO_LAST | PTU_PTE_VALID; - else if (k == tp_next->pg_count - 1 && set_pte_last) - valid = PTU_PTE_LAST | PTU_PTE_VALID; - else - valid = PTU_PTE_VALID; - - pg_va[j] = tfp_cpu_to_le_64(pg_pa[k] | valid); - if (++k >= tp_next->pg_count) - return; - } - } -} - -/** - * Setup a EM page table - * - * [in] tbl - * Pointer to EM page table - */ -static void -tf_em_setup_page_table(struct hcapi_cfa_em_table *tbl) -{ - struct hcapi_cfa_em_page_tbl *tp_next; - struct hcapi_cfa_em_page_tbl *tp; - bool set_pte_last = 0; - int i; - - for (i = 0; i < tbl->num_lvl - 1; i++) { - tp = &tbl->pg_tbl[i]; - tp_next = &tbl->pg_tbl[i + 1]; - if (i == tbl->num_lvl - 2) - set_pte_last = 1; - tf_em_link_page_table(tp, tp_next, set_pte_last); - } - - tbl->l0_addr = tbl->pg_tbl[TF_PT_LVL_0].pg_va_tbl[0]; - tbl->l0_dma_addr = tbl->pg_tbl[TF_PT_LVL_0].pg_pa_tbl[0]; -} - -/** - * Unregisters EM Ctx in Firmware - * - * [in] tfp - * Pointer to a TruFlow handle - * - * [in] tbl_scope_cb - * Pointer to a table scope control block - * - * [in] dir - * Receive or transmit direction - */ -static void -tf_em_ctx_unreg(struct tf *tfp, - struct tf_tbl_scope_cb *tbl_scope_cb, - int dir) -{ - struct hcapi_cfa_em_ctx_mem_info *ctxp = &tbl_scope_cb->em_ctx_info[dir]; - struct hcapi_cfa_em_table *tbl; - int i; - - for (i = TF_KEY0_TABLE; i < TF_MAX_TABLE; i++) { - tbl = &ctxp->em_tables[i]; - - if (tbl->num_entries != 0 && tbl->entry_size != 0) { - tf_msg_em_mem_unrgtr(tfp, &tbl->ctx_id); - tf_em_free_page_table(tbl); - } - } -} - -/** - * Registers EM Ctx in Firmware - * - * [in] tfp - * Pointer to a TruFlow handle - * - * [in] tbl_scope_cb - * Pointer to a table scope control block - * - * [in] dir - * Receive or transmit direction - * - * Returns: - * 0 - Success - * -ENOMEM - Out of Memory - */ -static int -tf_em_ctx_reg(struct tf *tfp, - struct tf_tbl_scope_cb *tbl_scope_cb, - int dir) -{ - struct hcapi_cfa_em_ctx_mem_info *ctxp = &tbl_scope_cb->em_ctx_info[dir]; - struct hcapi_cfa_em_table *tbl; - int rc = 0; - int i; - - for (i = TF_KEY0_TABLE; i < TF_MAX_TABLE; i++) { - tbl = &ctxp->em_tables[i]; - - if (tbl->num_entries && tbl->entry_size) { - rc = tf_em_size_table(tbl, TF_EM_PAGE_SIZE); - - if (rc) - goto cleanup; - - rc = tf_em_alloc_page_table(tbl); - if (rc) - goto cleanup; - - tf_em_setup_page_table(tbl); - rc = tf_msg_em_mem_rgtr(tfp, - tbl->num_lvl - 1, - TF_EM_PAGE_SIZE_ENUM, - tbl->l0_dma_addr, - &tbl->ctx_id); - if (rc) - goto cleanup; - } - } - return rc; - -cleanup: - tf_em_ctx_unreg(tfp, tbl_scope_cb, dir); - return rc; -} - -int -tf_em_ext_alloc(struct tf *tfp, - struct tf_alloc_tbl_scope_parms *parms) -{ - int rc; - enum tf_dir dir; - struct tf_tbl_scope_cb *tbl_scope_cb; - struct hcapi_cfa_em_table *em_tables; - struct tf_free_tbl_scope_parms free_parms; - struct tf_rm_allocate_parms aparms = { 0 }; - struct tf_rm_free_parms fparms = { 0 }; - struct tfp_calloc_parms cparms; - struct tf_session *tfs = NULL; - struct em_ext_db *ext_db = NULL; - void *ext_ptr = NULL; - uint16_t pf; - - rc = tf_session_get_session_internal(tfp, &tfs); - if (rc) { - TFP_DRV_LOG(ERR, "Failed to get tf_session, rc:%s\n", - strerror(-rc)); - return rc; - } - - rc = tf_session_get_em_ext_db(tfp, &ext_ptr); - if (rc) { - TFP_DRV_LOG(ERR, - "Failed to get em_ext_db from session, rc:%s\n", - strerror(-rc)); - return rc; - } - ext_db = (struct em_ext_db *)ext_ptr; - - rc = tfp_get_pf(tfp, &pf); - if (rc) { - TFP_DRV_LOG(ERR, - "EEM: PF query error rc:%s\n", - strerror(-rc)); - goto cleanup; - } - - /* Get Table Scope control block from the session pool */ - aparms.rm_db = ext_db->eem_db[TF_DIR_RX]; - aparms.subtype = TF_EM_TBL_TYPE_TBL_SCOPE; - aparms.index = (uint32_t *)&parms->tbl_scope_id; - rc = tf_rm_allocate(&aparms); - if (rc) { - TFP_DRV_LOG(ERR, - "Failed to allocate table scope\n"); - goto cleanup; - } - - /* Create tbl_scope, initialize and attach to the session */ - cparms.nitems = 1; - cparms.size = sizeof(struct tf_tbl_scope_cb); - cparms.alignment = 0; - rc = tfp_calloc(&cparms); - if (rc) { - /* Log error */ - TFP_DRV_LOG(ERR, - "Failed to allocate session table scope, rc:%s\n", - strerror(-rc)); - goto cleanup; - } - - tbl_scope_cb = cparms.mem_va; - tbl_scope_cb->tbl_scope_id = parms->tbl_scope_id; - tbl_scope_cb->pf = pf; - - for (dir = 0; dir < TF_DIR_MAX; dir++) { - rc = tf_msg_em_qcaps(tfp, - dir, - &tbl_scope_cb->em_caps[dir]); - if (rc) { - TFP_DRV_LOG(ERR, - "EEM: Unable to query for EEM capability," - " rc:%s\n", - strerror(-rc)); - goto cleanup_ts; - } - } - - /* - * Validate and setup table sizes - */ - if (tf_em_validate_num_entries(tbl_scope_cb, parms)) - goto cleanup_ts; - - for (dir = 0; dir < TF_DIR_MAX; dir++) { - /* - * Allocate tables and signal configuration to FW - */ - rc = tf_em_ctx_reg(tfp, tbl_scope_cb, dir); - if (rc) { - TFP_DRV_LOG(ERR, - "EEM: Unable to register for EEM ctx," - " rc:%s\n", - strerror(-rc)); - goto cleanup_ts; - } - - em_tables = tbl_scope_cb->em_ctx_info[dir].em_tables; - rc = tf_msg_em_cfg(tfp, - em_tables[TF_KEY0_TABLE].num_entries, - em_tables[TF_KEY0_TABLE].ctx_id, - em_tables[TF_KEY1_TABLE].ctx_id, - em_tables[TF_RECORD_TABLE].ctx_id, - em_tables[TF_EFC_TABLE].ctx_id, - parms->hw_flow_cache_flush_timer, - dir); - if (rc) { - TFP_DRV_LOG(ERR, - "TBL: Unable to configure EEM in firmware" - " rc:%s\n", - strerror(-rc)); - goto cleanup_full; - } - - rc = tf_msg_em_op(tfp, - dir, - HWRM_TF_EXT_EM_OP_INPUT_OP_EXT_EM_ENABLE); - - if (rc) { - TFP_DRV_LOG(ERR, - "EEM: Unable to enable EEM in firmware" - " rc:%s\n", - strerror(-rc)); - goto cleanup_full; - } - - /* Allocate the pool of offsets of the external memory. - * Initially, this is a single fixed size pool for all external - * actions related to a single table scope. - */ - rc = tf_create_tbl_pool_external(dir, - tbl_scope_cb, - em_tables[TF_RECORD_TABLE].num_entries, - em_tables[TF_RECORD_TABLE].entry_size); - if (rc) { - TFP_DRV_LOG(ERR, - "%s TBL: Unable to allocate idx pools %s\n", - tf_dir_2_str(dir), - strerror(-rc)); - goto cleanup_full; - } - } - - /* Insert into session tbl_scope list */ - ll_insert(&ext_db->tbl_scope_ll, &tbl_scope_cb->ll_entry); - return 0; - -cleanup_full: - free_parms.tbl_scope_id = parms->tbl_scope_id; - /* Insert into session list prior to ext_free */ - ll_insert(&ext_db->tbl_scope_ll, &tbl_scope_cb->ll_entry); - tf_em_ext_free(tfp, &free_parms); - return -EINVAL; - -cleanup_ts: - tfp_free(tbl_scope_cb); - -cleanup: - /* Free Table control block */ - fparms.rm_db = ext_db->eem_db[TF_DIR_RX]; - fparms.subtype = TF_EM_TBL_TYPE_TBL_SCOPE; - fparms.index = parms->tbl_scope_id; - rc = tf_rm_free(&fparms); - if (rc) - TFP_DRV_LOG(ERR, "Failed to free table scope\n"); - - return -EINVAL; -} - -int -tf_em_ext_free(struct tf *tfp, - struct tf_free_tbl_scope_parms *parms) -{ - int rc = 0; - enum tf_dir dir; - struct tf_tbl_scope_cb *tbl_scope_cb; - struct tf_session *tfs; - struct em_ext_db *ext_db = NULL; - void *ext_ptr = NULL; - struct tf_rm_free_parms aparms = { 0 }; - - rc = tf_session_get_session_internal(tfp, &tfs); - if (rc) { - TFP_DRV_LOG(ERR, "Failed to get tf_session, rc:%s\n", - strerror(-rc)); - return -EINVAL; - } - - rc = tf_session_get_em_ext_db(tfp, &ext_ptr); - if (rc) { - TFP_DRV_LOG(ERR, - "Failed to get em_ext_db from session, rc:%s\n", - strerror(-rc)); - return rc; - } - ext_db = (struct em_ext_db *)ext_ptr; - - tbl_scope_cb = tf_em_ext_common_tbl_scope_find(tfp, parms->tbl_scope_id); - if (tbl_scope_cb == NULL) { - TFP_DRV_LOG(ERR, "Table scope error\n"); - return -EINVAL; - } - - /* Free Table control block */ - aparms.rm_db = ext_db->eem_db[TF_DIR_RX]; - aparms.subtype = TF_EM_TBL_TYPE_TBL_SCOPE; - aparms.index = parms->tbl_scope_id; - rc = tf_rm_free(&aparms); - if (rc) { - TFP_DRV_LOG(ERR, - "Failed to free table scope\n"); - } - - /* free table scope locks */ - for (dir = 0; dir < TF_DIR_MAX; dir++) { - /* Free associated external pools - */ - tf_destroy_tbl_pool_external(dir, - tbl_scope_cb); - tf_msg_em_op(tfp, - dir, - HWRM_TF_EXT_EM_OP_INPUT_OP_EXT_EM_DISABLE); - - /* free table scope and all associated resources */ - tf_em_ctx_unreg(tfp, tbl_scope_cb, dir); - } - - /* remove from session list and free tbl_scope */ - ll_delete(&ext_db->tbl_scope_ll, &tbl_scope_cb->ll_entry); - tfp_free(tbl_scope_cb); - return rc; -} diff --git a/drivers/net/bnxt/tf_core/tf_msg.c b/drivers/net/bnxt/tf_core/tf_msg.c index 4aa90f6b07..08e9783d52 100644 --- a/drivers/net/bnxt/tf_core/tf_msg.c +++ b/drivers/net/bnxt/tf_core/tf_msg.c @@ -1100,471 +1100,6 @@ tf_msg_move_em_entry(struct tf *tfp, return 0; } -int tf_msg_ext_em_ctxt_mem_alloc(struct tf *tfp, - struct hcapi_cfa_em_table *tbl, - uint64_t *dma_addr, - uint32_t *page_lvl, - uint32_t *page_size) -{ - struct tfp_send_msg_parms parms = { 0 }; - struct hwrm_tf_ctxt_mem_alloc_input req = {0}; - struct hwrm_tf_ctxt_mem_alloc_output resp = {0}; - uint32_t mem_size_k; - int rc = 0; - struct tf_dev_info *dev; - struct tf_session *tfs; - uint32_t fw_se_id; - - /* Retrieve the session information */ - rc = tf_session_get_session_internal(tfp, &tfs); - if (rc) { - TFP_DRV_LOG(ERR, - "Failed to lookup session, rc:%s\n", - strerror(-rc)); - return rc; - } - - /* Retrieve the device information */ - rc = tf_session_get_device(tfs, &dev); - if (rc) { - TFP_DRV_LOG(ERR, - "Failed to lookup device, rc:%s\n", - strerror(-rc)); - return rc; - } - /* Retrieve the session information */ - fw_se_id = tfs->session_id.internal.fw_session_id; - - if (tbl->num_entries && tbl->entry_size) { - /* unit: kbytes */ - mem_size_k = (tbl->num_entries / TF_KILOBYTE) * tbl->entry_size; - req.mem_size = tfp_cpu_to_le_32(mem_size_k); - req.fw_session_id = tfp_cpu_to_le_32(fw_se_id); - parms.tf_type = HWRM_TF_CTXT_MEM_ALLOC; - parms.req_data = (uint32_t *)&req; - parms.req_size = sizeof(req); - parms.resp_data = (uint32_t *)&resp; - parms.resp_size = sizeof(resp); - parms.mailbox = dev->ops->tf_dev_get_mailbox(); - rc = tfp_send_msg_direct(tf_session_get_bp(tfp), &parms); - if (rc) { - TFP_DRV_LOG(ERR, "Failed ext_em_alloc error rc:%s\n", - strerror(-rc)); - return rc; - } - - *dma_addr = tfp_le_to_cpu_64(resp.page_dir); - *page_lvl = resp.page_level; - *page_size = resp.page_size; - } - - return rc; -} - -int tf_msg_ext_em_ctxt_mem_free(struct tf *tfp, - uint32_t mem_size_k, - uint64_t dma_addr, - uint8_t page_level, - uint8_t page_size) -{ - struct tfp_send_msg_parms parms = { 0 }; - struct hwrm_tf_ctxt_mem_free_input req = {0}; - struct hwrm_tf_ctxt_mem_free_output resp = {0}; - int rc = 0; - struct tf_dev_info *dev; - struct tf_session *tfs; - uint32_t fw_se_id; - - /* Retrieve the session information */ - rc = tf_session_get_session_internal(tfp, &tfs); - if (rc) { - TFP_DRV_LOG(ERR, - "Failed to lookup session, rc:%s\n", - strerror(-rc)); - return rc; - } - - /* Retrieve the device information */ - rc = tf_session_get_device(tfs, &dev); - if (rc) { - TFP_DRV_LOG(ERR, - "Failed to lookup device, rc:%s\n", - strerror(-rc)); - return rc; - } - /* Retrieve the session information */ - fw_se_id = tfs->session_id.internal.fw_session_id; - - req.fw_session_id = tfp_cpu_to_le_32(fw_se_id); - req.mem_size = tfp_cpu_to_le_32(mem_size_k); - req.page_dir = tfp_cpu_to_le_64(dma_addr); - req.page_level = page_level; - req.page_size = page_size; - parms.tf_type = HWRM_TF_CTXT_MEM_FREE; - parms.req_data = (uint32_t *)&req; - parms.req_size = sizeof(req); - parms.resp_data = (uint32_t *)&resp; - parms.resp_size = sizeof(resp); - parms.mailbox = dev->ops->tf_dev_get_mailbox(); - rc = tfp_send_msg_direct(tf_session_get_bp(tfp), &parms); - - return rc; -} - -int -tf_msg_em_mem_rgtr(struct tf *tfp, - int page_lvl, - int page_size, - uint64_t dma_addr, - uint16_t *ctx_id) -{ - int rc; - struct hwrm_tf_ctxt_mem_rgtr_input req = { 0 }; - struct hwrm_tf_ctxt_mem_rgtr_output resp = { 0 }; - struct tfp_send_msg_parms parms = { 0 }; - struct tf_dev_info *dev; - struct tf_session *tfs; - uint32_t fw_se_id; - - /* Retrieve the session information */ - rc = tf_session_get_session_internal(tfp, &tfs); - if (rc) { - TFP_DRV_LOG(ERR, - "Failed to lookup session, rc:%s\n", - strerror(-rc)); - return rc; - } - - /* Retrieve the device information */ - rc = tf_session_get_device(tfs, &dev); - if (rc) { - TFP_DRV_LOG(ERR, - "Failed to lookup device, rc:%s\n", - strerror(-rc)); - return rc; - } - fw_se_id = tfs->session_id.internal.fw_session_id; - - req.fw_session_id = tfp_cpu_to_le_32(fw_se_id); - req.page_level = page_lvl; - req.page_size = page_size; - req.page_dir = tfp_cpu_to_le_64(dma_addr); - - parms.tf_type = HWRM_TF_CTXT_MEM_RGTR; - parms.req_data = (uint32_t *)&req; - parms.req_size = sizeof(req); - parms.resp_data = (uint32_t *)&resp; - parms.resp_size = sizeof(resp); - parms.mailbox = dev->ops->tf_dev_get_mailbox(); - - rc = tfp_send_msg_direct(tf_session_get_bp(tfp), - &parms); - if (rc) - return rc; - - *ctx_id = tfp_le_to_cpu_16(resp.ctx_id); - - return rc; -} - -int -tf_msg_em_mem_unrgtr(struct tf *tfp, - uint16_t *ctx_id) -{ - int rc; - struct hwrm_tf_ctxt_mem_unrgtr_input req = {0}; - struct hwrm_tf_ctxt_mem_unrgtr_output resp = {0}; - struct tfp_send_msg_parms parms = { 0 }; - struct tf_dev_info *dev; - struct tf_session *tfs; - uint32_t fw_se_id; - - /* Retrieve the session information */ - rc = tf_session_get_session_internal(tfp, &tfs); - if (rc) { - TFP_DRV_LOG(ERR, - "Failed to lookup session, rc:%s\n", - strerror(-rc)); - return rc; - } - - /* Retrieve the device information */ - rc = tf_session_get_device(tfs, &dev); - if (rc) { - TFP_DRV_LOG(ERR, - "Failed to lookup device, rc:%s\n", - strerror(-rc)); - return rc; - } - - fw_se_id = tfs->session_id.internal.fw_session_id; - req.fw_session_id = tfp_cpu_to_le_32(fw_se_id); - - req.ctx_id = tfp_cpu_to_le_32(*ctx_id); - - parms.tf_type = HWRM_TF_CTXT_MEM_UNRGTR; - parms.req_data = (uint32_t *)&req; - parms.req_size = sizeof(req); - parms.resp_data = (uint32_t *)&resp; - parms.resp_size = sizeof(resp); - parms.mailbox = dev->ops->tf_dev_get_mailbox(); - - rc = tfp_send_msg_direct(tf_session_get_bp(tfp), - &parms); - return rc; -} - -int -tf_msg_em_qcaps(struct tf *tfp, - int dir, - struct tf_em_caps *em_caps) -{ - int rc; - struct hwrm_tf_ext_em_qcaps_input req = {0}; - struct hwrm_tf_ext_em_qcaps_output resp = { 0 }; - uint32_t flags; - struct tfp_send_msg_parms parms = { 0 }; - struct tf_dev_info *dev; - struct tf_session *tfs; - uint32_t fw_se_id; - - /* Retrieve the session information */ - rc = tf_session_get_session_internal(tfp, &tfs); - if (rc) { - TFP_DRV_LOG(ERR, - "%s: Failed to lookup session, rc:%s\n", - tf_dir_2_str(dir), - strerror(-rc)); - return rc; - } - fw_se_id = tfs->session_id.internal.fw_session_id; - - /* Retrieve the device information */ - rc = tf_session_get_device(tfs, &dev); - if (rc) { - TFP_DRV_LOG(ERR, - "%s: Failed to lookup device, rc:%s\n", - tf_dir_2_str(dir), - strerror(-rc)); - return rc; - } - - flags = (dir == TF_DIR_TX ? HWRM_TF_EXT_EM_QCAPS_INPUT_FLAGS_DIR_TX : - HWRM_TF_EXT_EM_QCAPS_INPUT_FLAGS_DIR_RX); - req.flags = tfp_cpu_to_le_32(flags); - - parms.tf_type = HWRM_TF_EXT_EM_QCAPS; - req.fw_session_id = tfp_cpu_to_le_32(fw_se_id); - parms.req_data = (uint32_t *)&req; - parms.req_size = sizeof(req); - parms.resp_data = (uint32_t *)&resp; - parms.resp_size = sizeof(resp); - parms.mailbox = dev->ops->tf_dev_get_mailbox(); - - rc = tfp_send_msg_direct(tf_session_get_bp(tfp), - &parms); - if (rc) - return rc; - - em_caps->supported = tfp_le_to_cpu_32(resp.supported); - em_caps->max_entries_supported = - tfp_le_to_cpu_32(resp.max_entries_supported); - em_caps->key_entry_size = tfp_le_to_cpu_16(resp.key_entry_size); - em_caps->record_entry_size = - tfp_le_to_cpu_16(resp.record_entry_size); - em_caps->efc_entry_size = tfp_le_to_cpu_16(resp.efc_entry_size); - - return rc; -} - -int -tf_msg_em_cfg(struct tf *tfp, - uint32_t num_entries, - uint16_t key0_ctx_id, - uint16_t key1_ctx_id, - uint16_t record_ctx_id, - uint16_t efc_ctx_id, - uint8_t flush_interval, - int dir) -{ - int rc; - struct hwrm_tf_ext_em_cfg_input req = {0}; - struct hwrm_tf_ext_em_cfg_output resp = {0}; - uint32_t flags; - struct tfp_send_msg_parms parms = { 0 }; - struct tf_dev_info *dev; - struct tf_session *tfs; - - /* Retrieve the session information */ - rc = tf_session_get_session_internal(tfp, &tfs); - if (rc) { - TFP_DRV_LOG(ERR, - "%s: Failed to lookup session, rc:%s\n", - tf_dir_2_str(dir), - strerror(-rc)); - return rc; - } - - /* Retrieve the device information */ - rc = tf_session_get_device(tfs, &dev); - if (rc) { - TFP_DRV_LOG(ERR, - "%s: Failed to lookup device, rc:%s\n", - tf_dir_2_str(dir), - strerror(-rc)); - return rc; - } - - flags = (dir == TF_DIR_TX ? HWRM_TF_EXT_EM_CFG_INPUT_FLAGS_DIR_TX : - HWRM_TF_EXT_EM_CFG_INPUT_FLAGS_DIR_RX); - flags |= HWRM_TF_EXT_EM_QCAPS_INPUT_FLAGS_PREFERRED_OFFLOAD; - - req.flags = tfp_cpu_to_le_32(flags); - req.num_entries = tfp_cpu_to_le_32(num_entries); - - req.flush_interval = flush_interval; - - req.key0_ctx_id = tfp_cpu_to_le_16(key0_ctx_id); - req.key1_ctx_id = tfp_cpu_to_le_16(key1_ctx_id); - req.record_ctx_id = tfp_cpu_to_le_16(record_ctx_id); - req.efc_ctx_id = tfp_cpu_to_le_16(efc_ctx_id); - - parms.tf_type = HWRM_TF_EXT_EM_CFG; - parms.req_data = (uint32_t *)&req; - parms.req_size = sizeof(req); - parms.resp_data = (uint32_t *)&resp; - parms.resp_size = sizeof(resp); - parms.mailbox = dev->ops->tf_dev_get_mailbox(); - - rc = tfp_send_msg_direct(tf_session_get_bp(tfp), - &parms); - return rc; -} - -int -tf_msg_ext_em_cfg(struct tf *tfp, - struct tf_tbl_scope_cb *tbl_scope_cb, - uint32_t st_buckets, - uint8_t flush_interval, - enum tf_dir dir) -{ - struct hcapi_cfa_em_ctx_mem_info *ctxp = &tbl_scope_cb->em_ctx_info[dir]; - struct hcapi_cfa_em_table *lkup_tbl, *act_tbl; - struct hwrm_tf_ext_em_cfg_input req = {0}; - struct hwrm_tf_ext_em_cfg_output resp = {0}; - struct tfp_send_msg_parms parms = { 0 }; - uint32_t flags; - struct tf_dev_info *dev; - struct tf_session *tfs; - uint32_t fw_se_id; - int rc; - - /* Retrieve the session information */ - rc = tf_session_get_session_internal(tfp, &tfs); - if (rc) { - TFP_DRV_LOG(ERR, - "%s: Failed to lookup session, rc:%s\n", - tf_dir_2_str(dir), - strerror(-rc)); - return rc; - } - - /* Retrieve the device information */ - rc = tf_session_get_device(tfs, &dev); - if (rc) { - TFP_DRV_LOG(ERR, - "%s: Failed to lookup device, rc:%s\n", - tf_dir_2_str(dir), - strerror(-rc)); - return rc; - } - fw_se_id = tfs->session_id.internal.fw_session_id; - - lkup_tbl = &ctxp->em_tables[TF_EM_LKUP_TABLE]; - act_tbl = &ctxp->em_tables[TF_ACTION_TABLE]; - flags = (dir == TF_DIR_TX ? HWRM_TF_EXT_EM_CFG_INPUT_FLAGS_DIR_TX : - HWRM_TF_EXT_EM_CFG_INPUT_FLAGS_DIR_RX); - flags |= HWRM_TF_EXT_EM_QCAPS_INPUT_FLAGS_PREFERRED_OFFLOAD; - - req.flags = tfp_cpu_to_le_32(flags); - req.num_entries = tfp_cpu_to_le_32(act_tbl->num_entries); - req.lkup_static_buckets = tfp_cpu_to_le_32(st_buckets); - req.fw_session_id = tfp_cpu_to_le_32(fw_se_id); - req.flush_interval = flush_interval; - req.action_ctx_id = tfp_cpu_to_le_16(act_tbl->ctx_id); - req.action_tbl_scope = tfp_cpu_to_le_16(tbl_scope_cb->tbl_scope_id); - req.lkup_ctx_id = tfp_cpu_to_le_16(lkup_tbl->ctx_id); - req.lkup_tbl_scope = tfp_cpu_to_le_16(tbl_scope_cb->tbl_scope_id); - - req.enables = (HWRM_TF_EXT_EM_CFG_INPUT_ENABLES_ACTION_CTX_ID | - HWRM_TF_EXT_EM_CFG_INPUT_ENABLES_ACTION_TBL_SCOPE | - HWRM_TF_EXT_EM_CFG_INPUT_ENABLES_LKUP_CTX_ID | - HWRM_TF_EXT_EM_CFG_INPUT_ENABLES_LKUP_TBL_SCOPE | - HWRM_TF_EXT_EM_CFG_INPUT_ENABLES_LKUP_STATIC_BUCKETS | - HWRM_TF_EXT_EM_CFG_INPUT_ENABLES_NUM_ENTRIES); - - parms.tf_type = HWRM_TF_EXT_EM_CFG; - parms.req_data = (uint32_t *)&req; - parms.req_size = sizeof(req); - parms.resp_data = (uint32_t *)&resp; - parms.resp_size = sizeof(resp); - parms.mailbox = dev->ops->tf_dev_get_mailbox(); - - rc = tfp_send_msg_direct(tf_session_get_bp(tfp), - &parms); - return rc; -} - -int -tf_msg_em_op(struct tf *tfp, - int dir, - uint16_t op) -{ - int rc; - struct hwrm_tf_ext_em_op_input req = {0}; - struct hwrm_tf_ext_em_op_output resp = {0}; - uint32_t flags; - struct tfp_send_msg_parms parms = { 0 }; - struct tf_dev_info *dev; - struct tf_session *tfs; - - /* Retrieve the session information */ - rc = tf_session_get_session_internal(tfp, &tfs); - if (rc) { - TFP_DRV_LOG(ERR, - "%s: Failed to lookup session, rc:%s\n", - tf_dir_2_str(dir), - strerror(-rc)); - return rc; - } - - /* Retrieve the device information */ - rc = tf_session_get_device(tfs, &dev); - if (rc) { - TFP_DRV_LOG(ERR, - "%s: Failed to lookup device, rc:%s\n", - tf_dir_2_str(dir), - strerror(-rc)); - return rc; - } - - flags = (dir == TF_DIR_TX ? HWRM_TF_EXT_EM_CFG_INPUT_FLAGS_DIR_TX : - HWRM_TF_EXT_EM_CFG_INPUT_FLAGS_DIR_RX); - req.flags = tfp_cpu_to_le_32(flags); - req.op = tfp_cpu_to_le_16(op); - - parms.tf_type = HWRM_TF_EXT_EM_OP; - parms.req_data = (uint32_t *)&req; - parms.req_size = sizeof(req); - parms.resp_data = (uint32_t *)&resp; - parms.resp_size = sizeof(resp); - parms.mailbox = dev->ops->tf_dev_get_mailbox(); - - rc = tfp_send_msg_direct(tf_session_get_bp(tfp), - &parms); - return rc; -} - int tf_msg_tcam_entry_set(struct tf *tfp, struct tf_dev_info *dev, diff --git a/drivers/net/bnxt/tf_core/tf_tcam.c b/drivers/net/bnxt/tf_core/tf_tcam.c index 9e0671d47b..df5cad75b5 100644 --- a/drivers/net/bnxt/tf_core/tf_tcam.c +++ b/drivers/net/bnxt/tf_core/tf_tcam.c @@ -261,7 +261,6 @@ tf_tcam_unbind(struct tf *tfp) tcam_db->tcam_db[i] = NULL; } - } rc = tf_tcam_mgr_unbind_msg(tfp, dev); -- 2.39.3