struct hcapi_cfa_data *obj_data);
int hcapi_cfa_p4_mirror_hwop(struct hcapi_cfa_hwop *op,
struct hcapi_cfa_data *mirror);
+int hcapi_cfa_p4_global_cfg_hwop(struct hcapi_cfa_hwop *op,
+ uint32_t type,
+ struct hcapi_cfa_data *config);
#endif /* SUPPORT_CFA_HW_P4 */
/**
* HCAPI CFA device HW operation function callback definition
'tf_core/tf_util.c',
'tf_core/tf_if_tbl.c',
'tf_core/ll.c',
+ 'tf_core/tf_global_cfg.c',
'hcapi/hcapi_cfa_p4.c',
SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/tf_tcam.c
SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/tf_util.c
SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/tf_if_tbl.c
+SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/tf_global_cfg.c
} tf_type_t;
typedef enum tf_subtype {
- HWRM_TFT_REG_GET = 821,
- HWRM_TFT_REG_SET = 822,
+ HWRM_TFT_GET_GLOBAL_CFG = 821,
+ HWRM_TFT_SET_GLOBAL_CFG = 822,
HWRM_TFT_TBL_TYPE_BULK_GET = 825,
HWRM_TFT_IF_TBL_SET = 827,
HWRM_TFT_IF_TBL_GET = 828,
#define TF_BITS2BYTES(x) (((x) + 7) >> 3)
#define TF_BITS2BYTES_WORD_ALIGN(x) ((((x) + 31) >> 5) * 4)
+struct tf_set_global_cfg_input;
+struct tf_get_global_cfg_input;
+struct tf_get_global_cfg_output;
struct tf_tbl_type_bulk_get_input;
struct tf_tbl_type_bulk_get_output;
struct tf_if_tbl_set_input;
struct tf_if_tbl_get_input;
struct tf_if_tbl_get_output;
+/* Input params for global config set */
+typedef struct tf_set_global_cfg_input {
+ /* Session Id */
+ uint32_t fw_session_id;
+ /* flags */
+ uint32_t flags;
+ /* When set to 0, indicates the query apply to RX */
+#define TF_SET_GLOBAL_CFG_INPUT_FLAGS_DIR_RX (0x0)
+ /* When set to 1, indicates the query apply to TX */
+#define TF_SET_GLOBAL_CFG_INPUT_FLAGS_DIR_TX (0x1)
+ /* Config type */
+ uint32_t type;
+ /* Offset of the type */
+ uint32_t offset;
+ /* Size of the data to set in bytes */
+ uint16_t size;
+ /* Data to set */
+ uint8_t data[TF_BULK_SEND];
+} tf_set_global_cfg_input_t, *ptf_set_global_cfg_input_t;
+
+/* Input params for global config to get */
+typedef struct tf_get_global_cfg_input {
+ /* Session Id */
+ uint32_t fw_session_id;
+ /* flags */
+ uint32_t flags;
+ /* When set to 0, indicates the query apply to RX */
+#define TF_GET_GLOBAL_CFG_INPUT_FLAGS_DIR_RX (0x0)
+ /* When set to 1, indicates the query apply to TX */
+#define TF_GET_GLOBAL_CFG_INPUT_FLAGS_DIR_TX (0x1)
+ /* Config to retrieve */
+ uint32_t type;
+ /* Offset to retrieve */
+ uint32_t offset;
+ /* Size of the data to set in bytes */
+ uint16_t size;
+} tf_get_global_cfg_input_t, *ptf_get_global_cfg_input_t;
+
+/* Output params for global config */
+typedef struct tf_get_global_cfg_output {
+ /* Size of the total data read in bytes */
+ uint16_t size;
+ /* Data to get */
+ uint8_t data[TF_BULK_SEND];
+} tf_get_global_cfg_output_t, *ptf_get_global_cfg_output_t;
/* Input params for table type get */
typedef struct tf_tbl_type_bulk_get_input {
/* Session Id */
uint32_t fw_session_id;
/* flags */
- uint16_t flags;
+ uint32_t flags;
/* When set to 0, indicates the get apply to RX */
#define TF_TBL_TYPE_BULK_GET_INPUT_FLAGS_DIR_RX (0x0)
/* When set to 1, indicates the get apply to TX */
#include "tf_tbl.h"
#include "tf_em.h"
#include "tf_rm.h"
+#include "tf_global_cfg.h"
#include "tf_msg.h"
#include "tfp.h"
#include "bitalloc.h"
return rc;
}
+/** Get global configuration API
+ *
+ * returns:
+ * 0 - Success
+ * -EINVAL - Error
+ */
+int tf_get_global_cfg(struct tf *tfp,
+ struct tf_global_cfg_parms *parms)
+{
+ int rc = 0;
+ struct tf_session *tfs;
+ struct tf_dev_info *dev;
+ struct tf_dev_global_cfg_parms gparms = { 0 };
+
+ TF_CHECK_PARMS2(tfp, parms);
+
+ /* Retrieve the session information */
+ rc = tf_session_get_session(tfp, &tfs);
+ if (rc) {
+ TFP_DRV_LOG(ERR,
+ "%s: Failed to lookup session, rc:%s\n",
+ tf_dir_2_str(parms->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(parms->dir),
+ strerror(-rc));
+ return rc;
+ }
+
+ if (parms->config == NULL ||
+ parms->config_sz_in_bytes == 0) {
+ TFP_DRV_LOG(ERR, "Invalid Argument(s)\n");
+ return -EINVAL;
+ }
+
+ if (dev->ops->tf_dev_get_global_cfg == NULL) {
+ rc = -EOPNOTSUPP;
+ TFP_DRV_LOG(ERR,
+ "%s: Operation not supported, rc:%s\n",
+ tf_dir_2_str(parms->dir),
+ strerror(-rc));
+ return -EOPNOTSUPP;
+ }
+
+ gparms.dir = parms->dir;
+ gparms.type = parms->type;
+ gparms.offset = parms->offset;
+ gparms.config = parms->config;
+ gparms.config_sz_in_bytes = parms->config_sz_in_bytes;
+ rc = dev->ops->tf_dev_get_global_cfg(tfp, &gparms);
+ if (rc) {
+ TFP_DRV_LOG(ERR,
+ "%s: Global Cfg get failed, rc:%s\n",
+ tf_dir_2_str(parms->dir),
+ strerror(-rc));
+ return rc;
+ }
+
+ return rc;
+}
+
+/** Set global configuration API
+ *
+ * returns:
+ * 0 - Success
+ * -EINVAL - Error
+ */
+int tf_set_global_cfg(struct tf *tfp,
+ struct tf_global_cfg_parms *parms)
+{
+ int rc = 0;
+ struct tf_session *tfs;
+ struct tf_dev_info *dev;
+ struct tf_dev_global_cfg_parms gparms = { 0 };
+
+ TF_CHECK_PARMS2(tfp, parms);
+
+ /* Retrieve the session information */
+ rc = tf_session_get_session(tfp, &tfs);
+ if (rc) {
+ TFP_DRV_LOG(ERR,
+ "%s: Failed to lookup session, rc:%s\n",
+ tf_dir_2_str(parms->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(parms->dir),
+ strerror(-rc));
+ return rc;
+ }
+
+ if (parms->config == NULL ||
+ parms->config_sz_in_bytes == 0) {
+ TFP_DRV_LOG(ERR, "Invalid Argument(s)\n");
+ return -EINVAL;
+ }
+
+ if (dev->ops->tf_dev_set_global_cfg == NULL) {
+ rc = -EOPNOTSUPP;
+ TFP_DRV_LOG(ERR,
+ "%s: Operation not supported, rc:%s\n",
+ tf_dir_2_str(parms->dir),
+ strerror(-rc));
+ return -EOPNOTSUPP;
+ }
+
+ gparms.dir = parms->dir;
+ gparms.type = parms->type;
+ gparms.offset = parms->offset;
+ gparms.config = parms->config;
+ gparms.config_sz_in_bytes = parms->config_sz_in_bytes;
+ rc = dev->ops->tf_dev_set_global_cfg(tfp, &gparms);
+ if (rc) {
+ TFP_DRV_LOG(ERR,
+ "%s: Global Cfg set failed, rc:%s\n",
+ tf_dir_2_str(parms->dir),
+ strerror(-rc));
+ return rc;
+ }
+
+ return rc;
+}
+
int
tf_alloc_identifier(struct tf *tfp,
struct tf_alloc_identifier_parms *parms)
int tf_search_em_entry(struct tf *tfp,
struct tf_search_em_entry_parms *parms);
+/**
+ * @page global Global Configuration
+ *
+ * @ref tf_set_global_cfg
+ *
+ * @ref tf_get_global_cfg
+ */
+/**
+ * Tunnel Encapsulation Offsets
+ */
+enum tf_tunnel_encap_offsets {
+ TF_TUNNEL_ENCAP_L2,
+ TF_TUNNEL_ENCAP_NAT,
+ TF_TUNNEL_ENCAP_MPLS,
+ TF_TUNNEL_ENCAP_VXLAN,
+ TF_TUNNEL_ENCAP_GENEVE,
+ TF_TUNNEL_ENCAP_NVGRE,
+ TF_TUNNEL_ENCAP_GRE,
+ TF_TUNNEL_ENCAP_FULL_GENERIC
+};
+/**
+ * Global Configuration Table Types
+ */
+enum tf_global_config_type {
+ TF_TUNNEL_ENCAP, /**< Tunnel Encap Config(TECT) */
+ TF_ACTION_BLOCK, /**< Action Block Config(ABCR) */
+ TF_GLOBAL_CFG_TYPE_MAX
+};
+
+/**
+ * tf_global_cfg parameter definition
+ */
+struct tf_global_cfg_parms {
+ /**
+ * [in] receive or transmit direction
+ */
+ enum tf_dir dir;
+ /**
+ * [in] Global config type
+ */
+ enum tf_global_config_type type;
+ /**
+ * [in] Offset @ the type
+ */
+ uint32_t offset;
+ /**
+ * [in/out] Value of the configuration
+ * set - Read, Modify and Write
+ * get - Read the full configuration
+ */
+ uint8_t *config;
+ /**
+ * [in] struct containing size
+ */
+ uint16_t config_sz_in_bytes;
+};
+
+/**
+ * Get global configuration
+ *
+ * Retrieve the configuration
+ *
+ * Returns success or failure code.
+ */
+int tf_get_global_cfg(struct tf *tfp,
+ struct tf_global_cfg_parms *parms);
+
+/**
+ * Update the global configuration table
+ *
+ * Read, modify write the value.
+ *
+ * Returns success or failure code.
+ */
+int tf_set_global_cfg(struct tf *tfp,
+ struct tf_global_cfg_parms *parms);
+
/**
* @page if_tbl Interface Table Access
*
struct tf_tcam_cfg_parms tcam_cfg;
struct tf_em_cfg_parms em_cfg;
struct tf_if_tbl_cfg_parms if_tbl_cfg;
+ struct tf_global_cfg_cfg_parms global_cfg;
dev_handle->type = TF_DEVICE_TYPE_WH;
/* Initial function initialization */
goto fail;
}
+ /*
+ * GLOBAL_CFG
+ */
+ global_cfg.num_elements = TF_GLOBAL_CFG_TYPE_MAX;
+ global_cfg.cfg = tf_global_cfg_p4;
+ rc = tf_global_cfg_bind(tfp, &global_cfg);
+ if (rc) {
+ TFP_DRV_LOG(ERR,
+ "Global Cfg initialization failure\n");
+ goto fail;
+ }
+
/* Final function initialization */
dev_handle->ops = &tf_dev_ops_p4;
fail = true;
}
+ rc = tf_global_cfg_unbind(tfp);
+ if (rc) {
+ TFP_DRV_LOG(ERR,
+ "Device unbind failed, Global Cfg Type\n");
+ fail = true;
+ }
+
if (fail)
return -1;
#include "tf_tbl.h"
#include "tf_tcam.h"
#include "tf_if_tbl.h"
+#include "tf_global_cfg.h"
struct tf;
struct tf_session;
*/
int (*tf_dev_get_if_tbl)(struct tf *tfp,
struct tf_if_tbl_get_parms *parms);
+
+ /**
+ * Update global cfg
+ *
+ * [in] tfp
+ * Pointer to TF handle
+ *
+ * [in] parms
+ * Pointer to global cfg parameters
+ *
+ * returns:
+ * 0 - Success
+ * -EINVAL - Error
+ */
+ int (*tf_dev_set_global_cfg)(struct tf *tfp,
+ struct tf_dev_global_cfg_parms *parms);
+
+ /**
+ * Get global cfg
+ *
+ * [in] tfp
+ * Pointer to TF handle
+ *
+ * [in] parms
+ * Pointer to global cfg parameters
+ *
+ * returns:
+ * 0 - Success
+ * -EINVAL - Error
+ */
+ int (*tf_dev_get_global_cfg)(struct tf *tfp,
+ struct tf_dev_global_cfg_parms *parms);
};
/**
.tf_dev_free_tbl_scope = NULL,
.tf_dev_set_if_tbl = NULL,
.tf_dev_get_if_tbl = NULL,
+ .tf_dev_set_global_cfg = NULL,
+ .tf_dev_get_global_cfg = NULL,
};
/**
.tf_dev_free_tbl_scope = tf_em_ext_common_free,
.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,
+ .tf_dev_get_global_cfg = tf_global_cfg_get,
};
#include "tf_core.h"
#include "tf_rm.h"
#include "tf_if_tbl.h"
+#include "tf_global_cfg.h"
struct tf_rm_element_cfg tf_ident_p4[TF_IDENT_TYPE_MAX] = {
{ TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_L2_CTXT_REMAP },
{ TF_IF_TBL_CFG_NULL, CFA_IF_TBL_TYPE_INVALID }
};
+struct tf_global_cfg_cfg tf_global_cfg_p4[TF_GLOBAL_CFG_TYPE_MAX] = {
+ { TF_GLOBAL_CFG_CFG_HCAPI, TF_TUNNEL_ENCAP },
+ { TF_GLOBAL_CFG_CFG_HCAPI, TF_ACTION_BLOCK },
+};
#endif /* _TF_DEVICE_P4_H_ */
--- /dev/null
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2019-2020 Broadcom
+ * All rights reserved.
+ */
+
+#include <rte_common.h>
+
+#include "tf_global_cfg.h"
+#include "tf_common.h"
+#include "tf_util.h"
+#include "tf_msg.h"
+#include "tfp.h"
+
+struct tf;
+/**
+ * Global Cfg DBs.
+ */
+static void *global_cfg_db[TF_DIR_MAX];
+
+/**
+ * Init flag, set on bind and cleared on unbind
+ */
+static uint8_t init;
+
+/**
+ * Get HCAPI type parameters for a single element
+ */
+struct tf_global_cfg_get_hcapi_parms {
+ /**
+ * [in] Global Cfg DB Handle
+ */
+ void *global_cfg_db;
+ /**
+ * [in] DB Index, indicates which DB entry to perform the
+ * action on.
+ */
+ uint16_t db_index;
+ /**
+ * [out] Pointer to the hcapi type for the specified db_index
+ */
+ uint16_t *hcapi_type;
+};
+
+/**
+ * Check global_cfg_type and return hwrm type.
+ *
+ * [in] global_cfg_type
+ * Global Cfg type
+ *
+ * [out] hwrm_type
+ * HWRM device data type
+ *
+ * Returns:
+ * 0 - Success
+ * -EOPNOTSUPP - Type not supported
+ */
+static int
+tf_global_cfg_get_hcapi_type(struct tf_global_cfg_get_hcapi_parms *parms)
+{
+ struct tf_global_cfg_cfg *global_cfg;
+ enum tf_global_cfg_cfg_type cfg_type;
+
+ global_cfg = (struct tf_global_cfg_cfg *)parms->global_cfg_db;
+ cfg_type = global_cfg[parms->db_index].cfg_type;
+
+ if (cfg_type != TF_GLOBAL_CFG_CFG_HCAPI)
+ return -ENOTSUP;
+
+ *parms->hcapi_type = global_cfg[parms->db_index].hcapi_type;
+
+ return 0;
+}
+
+int
+tf_global_cfg_bind(struct tf *tfp __rte_unused,
+ struct tf_global_cfg_cfg_parms *parms)
+{
+ TF_CHECK_PARMS2(tfp, parms);
+
+ if (init) {
+ TFP_DRV_LOG(ERR,
+ "Global Cfg DB already initialized\n");
+ return -EINVAL;
+ }
+
+ global_cfg_db[TF_DIR_RX] = parms->cfg;
+ global_cfg_db[TF_DIR_TX] = parms->cfg;
+
+ init = 1;
+
+ TFP_DRV_LOG(INFO,
+ "Global Cfg - initialized\n");
+
+ return 0;
+}
+
+int
+tf_global_cfg_unbind(struct tf *tfp __rte_unused)
+{
+ /* Bail if nothing has been initialized */
+ if (!init) {
+ TFP_DRV_LOG(INFO,
+ "No Global Cfg DBs created\n");
+ return 0;
+ }
+
+ global_cfg_db[TF_DIR_RX] = NULL;
+ global_cfg_db[TF_DIR_TX] = NULL;
+ init = 0;
+
+ return 0;
+}
+
+int
+tf_global_cfg_set(struct tf *tfp,
+ struct tf_dev_global_cfg_parms *parms)
+{
+ int rc;
+ struct tf_global_cfg_get_hcapi_parms hparms;
+ uint16_t hcapi_type;
+
+ TF_CHECK_PARMS3(tfp, parms, parms->config);
+
+ if (!init) {
+ TFP_DRV_LOG(ERR,
+ "%s: No Global Cfg DBs created\n",
+ tf_dir_2_str(parms->dir));
+ return -EINVAL;
+ }
+
+ /* Convert TF type to HCAPI type */
+ hparms.global_cfg_db = global_cfg_db[parms->dir];
+ hparms.db_index = parms->type;
+ hparms.hcapi_type = &hcapi_type;
+ rc = tf_global_cfg_get_hcapi_type(&hparms);
+ if (rc) {
+ TFP_DRV_LOG(ERR,
+ "%s, Failed type lookup, type:%d, rc:%s\n",
+ tf_dir_2_str(parms->dir),
+ parms->type,
+ strerror(-rc));
+ return rc;
+ }
+
+ rc = tf_msg_set_global_cfg(tfp, parms);
+ if (rc) {
+ TFP_DRV_LOG(ERR,
+ "%s, Set failed, type:%d, rc:%s\n",
+ tf_dir_2_str(parms->dir),
+ parms->type,
+ strerror(-rc));
+ }
+
+ return 0;
+}
+
+int
+tf_global_cfg_get(struct tf *tfp,
+ struct tf_dev_global_cfg_parms *parms)
+
+{
+ int rc;
+ struct tf_global_cfg_get_hcapi_parms hparms;
+ uint16_t hcapi_type;
+
+ TF_CHECK_PARMS3(tfp, parms, parms->config);
+
+ if (!init) {
+ TFP_DRV_LOG(ERR,
+ "%s: No Global Cfg DBs created\n",
+ tf_dir_2_str(parms->dir));
+ return -EINVAL;
+ }
+
+ hparms.global_cfg_db = global_cfg_db[parms->dir];
+ hparms.db_index = parms->type;
+ hparms.hcapi_type = &hcapi_type;
+ rc = tf_global_cfg_get_hcapi_type(&hparms);
+ if (rc) {
+ TFP_DRV_LOG(ERR,
+ "%s, Failed type lookup, type:%d, rc:%s\n",
+ tf_dir_2_str(parms->dir),
+ parms->type,
+ strerror(-rc));
+ return rc;
+ }
+
+ /* Get the entry */
+ rc = tf_msg_get_global_cfg(tfp, parms);
+ if (rc) {
+ TFP_DRV_LOG(ERR,
+ "%s, Get failed, type:%d, rc:%s\n",
+ tf_dir_2_str(parms->dir),
+ parms->type,
+ strerror(-rc));
+ }
+
+ return 0;
+}
--- /dev/null
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2019-2020 Broadcom
+ * All rights reserved.
+ */
+
+#ifndef TF_GLOBAL_CFG_H_
+#define TF_GLOBAL_CFG_H_
+
+#include "tf_core.h"
+#include "stack.h"
+
+/**
+ * The global cfg module provides processing of global cfg types.
+ */
+
+struct tf;
+
+/**
+ * Global cfg configuration enumeration.
+ */
+enum tf_global_cfg_cfg_type {
+ /**
+ * No configuration
+ */
+ TF_GLOBAL_CFG_CFG_NULL,
+ /**
+ * HCAPI 'controlled'
+ */
+ TF_GLOBAL_CFG_CFG_HCAPI,
+};
+
+/**
+ * Global cfg configuration structure, used by the Device to configure
+ * how an individual global cfg type is configured in regard to the HCAPI type.
+ */
+struct tf_global_cfg_cfg {
+ /**
+ * Global cfg config controls how the DB for that element is
+ * processed.
+ */
+ enum tf_global_cfg_cfg_type cfg_type;
+
+ /**
+ * HCAPI Type for the element. Used for TF to HCAPI type
+ * conversion.
+ */
+ uint16_t hcapi_type;
+};
+
+/**
+ * Global Cfg configuration parameters
+ */
+struct tf_global_cfg_cfg_parms {
+ /**
+ * Number of table types in the configuration array
+ */
+ uint16_t num_elements;
+ /**
+ * Table Type element configuration array
+ */
+ struct tf_global_cfg_cfg *cfg;
+};
+
+/**
+ * global cfg parameters
+ */
+struct tf_dev_global_cfg_parms {
+ /**
+ * [in] Receive or transmit direction
+ */
+ enum tf_dir dir;
+ /**
+ * [in] Global config type
+ */
+ enum tf_global_config_type type;
+ /**
+ * [in] Offset @ the type
+ */
+ uint32_t offset;
+ /**
+ * [in/out] Value of the configuration
+ * set - Read, Modify and Write
+ * get - Read the full configuration
+ */
+ uint8_t *config;
+ /**
+ * [in] struct containing size
+ */
+ uint16_t config_sz_in_bytes;
+};
+
+/**
+ * @page global cfg
+ *
+ * @ref tf_global_cfg_bind
+ *
+ * @ref tf_global_cfg_unbind
+ *
+ * @ref tf_global_cfg_set
+ *
+ * @ref tf_global_cfg_get
+ *
+ */
+/**
+ * Initializes the Global Cfg module with the requested DBs. Must be
+ * invoked as the first thing before any of the access functions.
+ *
+ * [in] tfp
+ * Pointer to TF handle
+ *
+ * [in] parms
+ * Pointer to Global Cfg configuration parameters
+ *
+ * Returns
+ * - (0) if successful.
+ * - (-EINVAL) on failure.
+ */
+int
+tf_global_cfg_bind(struct tf *tfp,
+ struct tf_global_cfg_cfg_parms *parms);
+
+/**
+ * Cleans up the private DBs and releases all the data.
+ *
+ * [in] tfp
+ * Pointer to TF handle
+ *
+ * [in] parms
+ * Pointer to Global Cfg configuration parameters
+ *
+ * Returns
+ * - (0) if successful.
+ * - (-EINVAL) on failure.
+ */
+int
+tf_global_cfg_unbind(struct tf *tfp);
+
+/**
+ * Updates the global configuration table
+ *
+ * [in] tfp
+ * Pointer to TF handle, used for HCAPI communication
+ *
+ * [in] parms
+ * Pointer to global cfg parameters
+ *
+ * Returns
+ * - (0) if successful.
+ * - (-EINVAL) on failure.
+ */
+int tf_global_cfg_set(struct tf *tfp,
+ struct tf_dev_global_cfg_parms *parms);
+
+/**
+ * Get global configuration
+ *
+ * [in] tfp
+ * Pointer to TF handle, used for HCAPI communication
+ *
+ * [in] parms
+ * Pointer to global cfg parameters
+ *
+ * Returns
+ * - (0) if successful.
+ * - (-EINVAL) on failure.
+ */
+int tf_global_cfg_get(struct tf *tfp,
+ struct tf_dev_global_cfg_parms *parms);
+
+#endif /* TF_GLOBAL_CFG_H */
/* HWRM Tunneled messages */
+int
+tf_msg_get_global_cfg(struct tf *tfp,
+ struct tf_dev_global_cfg_parms *params)
+{
+ int rc = 0;
+ struct tfp_send_msg_parms parms = { 0 };
+ tf_get_global_cfg_input_t req = { 0 };
+ tf_get_global_cfg_output_t resp = { 0 };
+ uint32_t flags = 0;
+ uint8_t fw_session_id;
+ uint16_t resp_size = 0;
+
+ rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
+ if (rc) {
+ TFP_DRV_LOG(ERR,
+ "%s: Unable to lookup FW id, rc:%s\n",
+ tf_dir_2_str(params->dir),
+ strerror(-rc));
+ return rc;
+ }
+
+ flags = (params->dir == TF_DIR_TX ?
+ TF_GET_GLOBAL_CFG_INPUT_FLAGS_DIR_TX :
+ TF_GET_GLOBAL_CFG_INPUT_FLAGS_DIR_RX);
+
+ /* Populate the request */
+ req.fw_session_id = tfp_cpu_to_le_32(fw_session_id);
+ req.flags = tfp_cpu_to_le_32(flags);
+ req.type = tfp_cpu_to_le_32(params->type);
+ req.offset = tfp_cpu_to_le_32(params->offset);
+ req.size = tfp_cpu_to_le_32(params->config_sz_in_bytes);
+
+ MSG_PREP(parms,
+ TF_KONG_MB,
+ HWRM_TF,
+ HWRM_TFT_GET_GLOBAL_CFG,
+ req,
+ resp);
+
+ rc = tfp_send_msg_tunneled(tfp, &parms);
+
+ if (rc != 0)
+ return rc;
+
+ /* Verify that we got enough buffer to return the requested data */
+ resp_size = tfp_le_to_cpu_16(resp.size);
+ if (resp_size < params->config_sz_in_bytes)
+ return -EINVAL;
+
+ if (params->config)
+ tfp_memcpy(params->config,
+ resp.data,
+ resp_size);
+ else
+ return -EFAULT;
+
+ return tfp_le_to_cpu_32(parms.tf_resp_code);
+}
+
+int
+tf_msg_set_global_cfg(struct tf *tfp,
+ struct tf_dev_global_cfg_parms *params)
+{
+ int rc = 0;
+ struct tfp_send_msg_parms parms = { 0 };
+ tf_set_global_cfg_input_t req = { 0 };
+ uint32_t flags = 0;
+ uint8_t fw_session_id;
+
+ rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
+ if (rc) {
+ TFP_DRV_LOG(ERR,
+ "%s: Unable to lookup FW id, rc:%s\n",
+ tf_dir_2_str(params->dir),
+ strerror(-rc));
+ return rc;
+ }
+
+ flags = (params->dir == TF_DIR_TX ?
+ TF_SET_GLOBAL_CFG_INPUT_FLAGS_DIR_TX :
+ TF_SET_GLOBAL_CFG_INPUT_FLAGS_DIR_RX);
+
+ /* Populate the request */
+ req.fw_session_id = tfp_cpu_to_le_32(fw_session_id);
+ req.flags = tfp_cpu_to_le_32(flags);
+ req.type = tfp_cpu_to_le_32(params->type);
+ req.offset = tfp_cpu_to_le_32(params->offset);
+ tfp_memcpy(req.data, params->config,
+ params->config_sz_in_bytes);
+ req.size = tfp_cpu_to_le_32(params->config_sz_in_bytes);
+
+ MSG_PREP_NO_RESP(parms,
+ TF_KONG_MB,
+ HWRM_TF,
+ HWRM_TFT_SET_GLOBAL_CFG,
+ req);
+
+ rc = tfp_send_msg_tunneled(tfp, &parms);
+
+ if (rc != 0)
+ return rc;
+
+ return tfp_le_to_cpu_32(parms.tf_resp_code);
+}
+
int
tf_msg_bulk_get_tbl_entry(struct tf *tfp,
enum tf_dir dir,
return rc;
}
- flags = (params->dir == TF_DIR_TX ? TF_IF_TBL_SET_INPUT_FLAGS_DIR_TX :
- TF_IF_TBL_SET_INPUT_FLAGS_DIR_RX);
+ flags = (params->dir == TF_DIR_TX ? TF_IF_TBL_GET_INPUT_FLAGS_DIR_TX :
+ TF_IF_TBL_GET_INPUT_FLAGS_DIR_RX);
/* Populate the request */
req.fw_session_id =
#include "tf_tbl.h"
#include "tf_rm.h"
#include "tf_tcam.h"
+#include "tf_global_cfg.h"
struct tf;
/* HWRM Tunneled messages */
+/**
+ * Sends global cfg read request to Firmware
+ *
+ * [in] tfp
+ * Pointer to TF handle
+ *
+ * [in] params
+ * Pointer to read parameters
+ *
+ * Returns:
+ * 0 on Success else internal Truflow error
+ */
+int tf_msg_get_global_cfg(struct tf *tfp,
+ struct tf_dev_global_cfg_parms *params);
+
+/**
+ * Sends global cfg update request to Firmware
+ *
+ * [in] tfp
+ * Pointer to TF handle
+ *
+ * [in] params
+ * Pointer to write parameters
+ *
+ * Returns:
+ * 0 on Success else internal Truflow error
+ */
+int tf_msg_set_global_cfg(struct tf *tfp,
+ struct tf_dev_global_cfg_parms *params);
+
/**
* Sends bulk get message of a Table Type element to the firmware.
*