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);
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);
+ rc = dev->ops->tf_dev_get_global_cfg(tfp, parms);
if (rc) {
TFP_DRV_LOG(ERR,
"%s: Global Cfg get failed, rc:%s\n",
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);
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);
+ rc = dev->ops->tf_dev_set_global_cfg(tfp, parms);
if (rc) {
TFP_DRV_LOG(ERR,
"%s: Global Cfg set failed, rc:%s\n",
return rc;
}
+int
+tf_map_tbl_scope(struct tf *tfp,
+ struct tf_map_tbl_scope_parms *parms)
+{
+ struct tf_session *tfs;
+ struct tf_dev_info *dev;
+ int rc;
+
+ TF_CHECK_PARMS2(tfp, parms);
+
+ /* Retrieve the session information */
+ rc = tf_session_get_session(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;
+ }
+
+ if (dev->ops->tf_dev_map_tbl_scope != NULL) {
+ rc = dev->ops->tf_dev_map_tbl_scope(tfp, parms);
+ } else {
+ TFP_DRV_LOG(ERR,
+ "Map table scope not supported by device\n");
+ return -EINVAL;
+ }
+
+ return rc;
+}
int
tf_free_tbl_scope(struct tf *tfp,
*/
uint32_t tbl_scope_id;
};
-
+/**
+ * tf_free_tbl_scope_parms definition
+ */
struct tf_free_tbl_scope_parms {
/**
* [in] table scope identifier
uint32_t tbl_scope_id;
};
+/**
+ * tf_map_tbl_scope_parms definition
+ */
+struct tf_map_tbl_scope_parms {
+ /**
+ * [in] table scope identifier
+ */
+ uint32_t tbl_scope_id;
+ /**
+ * [in] Which parifs are associated with this table scope. Bit 0
+ * indicates parif 0.
+ */
+ uint16_t parif_bitmask;
+};
+
/**
* allocate a table scope
*
* device constraints based upon calculations using either the number of flows
* requested or the size of memory indicated. Other parameters passed in
* determine the configuration (maximum key size, maximum external action record
- * size.
+ * size).
*
- * This API will allocate the table region in
- * DRAM, program the PTU page table entries, and program the number of static
- * buckets (if SR2) in the RX and TX CFAs. Buckets are assumed to start at
- * 0 in the EM memory for the scope. Upon successful completion of this API,
- * hash tables are fully initialized and ready for entries to be inserted.
+ * This API will allocate the table region in DRAM, program the PTU page table
+ * entries, and program the number of static buckets (if SR2) in the RX and TX
+ * CFAs. Buckets are assumed to start at 0 in the EM memory for the scope.
+ * Upon successful completion of this API, hash tables are fully initialized and
+ * ready for entries to be inserted.
*
* A single API is used to allocate a common table scope identifier in both
* receive and transmit CFA. The scope identifier is common due to nature of
int tf_alloc_tbl_scope(struct tf *tfp,
struct tf_alloc_tbl_scope_parms *parms);
+/**
+ * map a table scope (legacy device only Wh+/SR)
+ *
+ * Map a table scope to one or more partition interfaces (parifs).
+ * The parif can be remapped in the L2 context lookup for legacy devices. This
+ * API allows a number of parifs to be mapped to the same table scope. On
+ * legacy devices a table scope identifies one of 16 sets of EEM table base
+ * addresses and is associated with a PF communication channel. The associated
+ * PF must be configured for the table scope to operate.
+ *
+ * An L2 context TCAM lookup returns a remapped parif value used to
+ * index into the set of 16 parif_to_pf registers which are used to map to one
+ * of the 16 table scopes. This API allows the user to map the parifs in the
+ * mask to the previously allocated table scope (EEM table).
+ * Returns success or failure code.
+ */
+int tf_map_tbl_scope(struct tf *tfp,
+ struct tf_map_tbl_scope_parms *parms);
/**
* free a table scope
*
* get - Read the full configuration
*/
uint8_t *config;
+ /**
+ * [in] Configuration mask
+ * set - Read, Modify with mask and Write
+ * get - unused
+ */
+ uint8_t *config_mask;
/**
* [in] struct containing size
*/
*/
int (*tf_dev_alloc_tbl_scope)(struct tf *tfp,
struct tf_alloc_tbl_scope_parms *parms);
+ /**
+ * Map EEM parif
+ *
+ * [in] tfp
+ * Pointer to TF handle
+ *
+ * [in] parms
+ * Pointer to table scope map parameters
+ *
+ * [in/out] pointer to the parif_2_pf data to be updated
+ *
+ * [in/out] pointer to the parif_2_pf mask to be updated
+ *
+ * [in] sz_in_bytes - number of bytes to be written
+ *
+ * returns:
+ * 0 - Success
+ * -EINVAL - Error
+ */
+ int (*tf_dev_map_parif)(struct tf *tfp,
+ struct tf_map_tbl_scope_parms *parms,
+ uint8_t *data,
+ uint8_t *mask,
+ uint16_t sz_in_bytes);
+ /**
+ * Map EEM table scope
+ *
+ * [in] tfp
+ * Pointer to TF handle
+ *
+ * [in] parms
+ * Pointer to table scope map parameters
+ *
+ * returns:
+ * 0 - Success
+ * -EINVAL - Error
+ */
+ int (*tf_dev_map_tbl_scope)(struct tf *tfp,
+ struct tf_map_tbl_scope_parms *parms);
/**
* Free EEM table scope
* -EINVAL - Error
*/
int (*tf_dev_set_global_cfg)(struct tf *tfp,
- struct tf_dev_global_cfg_parms *parms);
+ struct tf_global_cfg_parms *parms);
/**
* Get global cfg
* -EINVAL - Error
*/
int (*tf_dev_get_global_cfg)(struct tf *tfp,
- struct tf_dev_global_cfg_parms *parms);
+ struct tf_global_cfg_parms *parms);
};
/**
#include "tf_tcam.h"
#include "tf_em.h"
#include "tf_if_tbl.h"
+#include "tfp.h"
+
+#define TF_DEV_P4_PARIF_MAX 16
+#define TF_DEV_P4_PF_MASK 0xfUL
/**
* Device specific function that retrieves the MAX number of HCAPI
return 0;
}
+static int
+tf_dev_p4_map_parif(struct tf *tfp __rte_unused,
+ struct tf_map_tbl_scope_parms *parms,
+ uint8_t *data,
+ uint8_t *mask,
+ uint16_t sz_in_bytes)
+{
+ uint32_t parif_pf[2] = { 0 };
+ uint32_t parif_pf_mask[2] = { 0 };
+ uint32_t parif;
+ uint32_t shift;
+ uint32_t scope_id = (uint32_t)(parms->tbl_scope_id);
+
+ if (sz_in_bytes != sizeof(uint64_t))
+ return -ENOTSUP;
+
+ for (parif = 0; parif < TF_DEV_P4_PARIF_MAX; parif++) {
+ if (parms->parif_bitmask & (1UL << parif)) {
+ if (parif < 8) {
+ shift = 4 * parif;
+ parif_pf_mask[0] |= TF_DEV_P4_PF_MASK << shift;
+ parif_pf[0] |= scope_id << shift;
+ } else {
+ shift = 4 * (parif - 8);
+ parif_pf_mask[1] |= TF_DEV_P4_PF_MASK << shift;
+ parif_pf[1] |= scope_id << shift;
+ }
+ }
+ }
+ tfp_memcpy(data, parif_pf, sz_in_bytes);
+ tfp_memcpy(mask, parif_pf_mask, sz_in_bytes);
+
+ return 0;
+}
+
+
/**
* Truflow P4 device specific functions
*/
.tf_dev_insert_ext_em_entry = NULL,
.tf_dev_delete_ext_em_entry = NULL,
.tf_dev_alloc_tbl_scope = NULL,
+ .tf_dev_map_tbl_scope = NULL,
+ .tf_dev_map_parif = NULL,
.tf_dev_free_tbl_scope = NULL,
.tf_dev_set_if_tbl = NULL,
.tf_dev_get_if_tbl = NULL,
.tf_dev_insert_ext_em_entry = tf_em_insert_ext_entry,
.tf_dev_delete_ext_em_entry = tf_em_delete_ext_entry,
.tf_dev_alloc_tbl_scope = tf_em_ext_common_alloc,
+ .tf_dev_map_tbl_scope = tf_em_ext_map_tbl_scope,
+ .tf_dev_map_parif = tf_dev_p4_map_parif,
.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,
struct tf_free_tbl_scope_parms *parms);
/**
- * Common free for external EEM using host or system memory
+ * Common free table scope for external EEM using host or system memory
*
* [in] tfp
* Pointer to TruFlow handle
struct tf_free_tbl_scope_parms *parms);
/**
- * Common alloc for external EEM using host or system memory
+ * Common alloc table scope for external EEM using host or system memory
*
* [in] tfp
* Pointer to TruFlow handle
*/
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.
/** Table scope array */
struct tf_tbl_scope_cb tbl_scopes[TF_NUM_TBL_SCOPE];
-/** Table scope reversal table
- *
- * Table scope are allocated from 15 to 0 within HCAPI RM. Because of the
- * association between PFs and legacy table scopes, reverse table scope ids.
- * 15 indicates 0, 14 indicates 1, etc... The application will only see the 0
- * based number. The firmware will only use the 0 based number. Only HCAPI RM
- * and Truflow RM believe the number is 15. When HCAPI RM support allocation
- * from low to high is supported, this adjust function can be removed.
- */
-const uint32_t tbl_scope_reverse[TF_NUM_TBL_SCOPE] = {
- 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
-
-static uint32_t
-tf_tbl_scope_adjust(uint32_t tbl_scope_id)
-{
- if (tbl_scope_id < TF_NUM_TBL_SCOPE)
- return tbl_scope_reverse[tbl_scope_id];
- else
- return TF_TBL_SCOPE_INVALID;
-};
-
-
/* API defined in tf_em.h */
struct tf_tbl_scope_cb *
tbl_scope_cb_find(uint32_t tbl_scope_id)
int i;
struct tf_rm_is_allocated_parms parms = { 0 };
int allocated;
- uint32_t rm_tbl_scope_id;
-
- rm_tbl_scope_id = tf_tbl_scope_adjust(tbl_scope_id);
-
- if (rm_tbl_scope_id == TF_TBL_SCOPE_INVALID)
- return NULL;
/* Check that id is valid */
parms.rm_db = eem_db[TF_DIR_RX];
parms.db_index = TF_EM_TBL_TYPE_TBL_SCOPE;
- parms.index = rm_tbl_scope_id;
+ parms.index = tbl_scope_id;
parms.allocated = &allocated;
i = tf_rm_is_allocated(&parms);
return NULL;
}
-int tf_tbl_scope_alloc(uint32_t *tbl_scope_id)
-{
- int rc;
- struct tf_rm_allocate_parms parms = { 0 };
- uint32_t rm_tbl_scope_id;
- uint32_t usr_tbl_scope_id = TF_TBL_SCOPE_INVALID;
-
- /* Get Table Scope control block from the session pool */
- parms.rm_db = eem_db[TF_DIR_RX];
- parms.db_index = TF_EM_TBL_TYPE_TBL_SCOPE;
- parms.index = &rm_tbl_scope_id;
-
- rc = tf_rm_allocate(&parms);
- if (rc) {
- TFP_DRV_LOG(ERR,
- "Failed to allocate table scope rc:%s\n",
- strerror(-rc));
- return rc;
- }
-
- usr_tbl_scope_id = tf_tbl_scope_adjust(rm_tbl_scope_id);
-
- if (usr_tbl_scope_id == TF_TBL_SCOPE_INVALID) {
- TFP_DRV_LOG(ERR,
- "Invalid table scope allocated id:%d\n",
- (int)rm_tbl_scope_id);
- return -EINVAL;
- }
- *tbl_scope_id = usr_tbl_scope_id;
- return 0;
-};
-
-int tf_tbl_scope_free(uint32_t tbl_scope_id)
-{
- struct tf_rm_free_parms parms = { 0 };
- uint32_t rm_tbl_scope_id;
- uint32_t rc;
-
- rm_tbl_scope_id = tf_tbl_scope_adjust(tbl_scope_id);
-
- if (rm_tbl_scope_id == TF_TBL_SCOPE_INVALID) {
- TFP_DRV_LOG(ERR,
- "Invalid table scope allocated id:%d\n",
- (int)tbl_scope_id);
- return -EINVAL;
- }
-
- parms.rm_db = eem_db[TF_DIR_RX];
- parms.db_index = TF_EM_TBL_TYPE_TBL_SCOPE;
- parms.index = rm_tbl_scope_id;
-
- rc = tf_rm_free(&parms);
- return rc;
-};
-
int
tf_create_tbl_pool_external(enum tf_dir dir,
struct tf_tbl_scope_cb *tbl_scope_cb,
{
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;
+
+ tbl_scope_cb = tbl_scope_cb_find(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;
+ }
+
+ /* 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;
+
+ 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, (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;
+ }
+
+ gcfg_parms.type =
+ (enum tf_global_config_type)TF_GLOBAL_CFG_INTERNAL_PARIF_2_PF;
+ 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;
+}
#include "tf_core.h"
#include "tf_session.h"
+
/**
* Function to search for table scope control block structure
* with specified table scope ID.
*/
struct tf_tbl_scope_cb *tbl_scope_cb_find(uint32_t tbl_scope_id);
-/**
- * Table Scope Allocate
- *
- * Allocate a table scope
- *
- * [in/out] pointer to tbl_scope_id
- *
- * Returns:
- * 0 - success
- * -EINVAL - error
- */
-int tf_tbl_scope_alloc(uint32_t *tbl_scope_id);
-
-/**
- * Table Scope Free
- *
- * Free a table scope
- *
- * [in] tbl_scope_id to free
- *
- * Returns:
- * 0 - success
- * -EINVAL - error
- */
-int tf_tbl_scope_free(uint32_t tbl_scope_id);
-
/**
* Create and initialize a stack to use for action entries
*
struct tf_tbl_scope_cb *tbl_scope_cb;
struct hcapi_cfa_em_table *em_tables;
struct tf_free_tbl_scope_parms free_parms;
-
- rc = tf_tbl_scope_alloc(&parms->tbl_scope_id);
+ struct tf_rm_allocate_parms aparms = { 0 };
+ struct tf_rm_free_parms fparms = { 0 };
+
+ /* Get Table Scope control block from the session pool */
+ aparms.rm_db = eem_db[TF_DIR_RX];
+ aparms.db_index = 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");
return -EINVAL;
cleanup:
- tf_tbl_scope_free(parms->tbl_scope_id);
+ /* Free Table control block */
+ fparms.rm_db = eem_db[TF_DIR_RX];
+ fparms.db_index = TF_EM_TBL_TYPE_TBL_SCOPE;
+ fparms.index = parms->tbl_scope_id;
+ tf_rm_free(&fparms);
return -EINVAL;
}
int rc = 0;
enum tf_dir dir;
struct tf_tbl_scope_cb *tbl_scope_cb;
+ struct tf_rm_free_parms aparms = { 0 };
tbl_scope_cb = tbl_scope_cb_find(parms->tbl_scope_id);
return -EINVAL;
}
- rc = tf_tbl_scope_free(parms->tbl_scope_id);
+ /* Free Table control block */
+ aparms.rm_db = eem_db[TF_DIR_RX];
+ aparms.db_index = 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");
int
tf_global_cfg_set(struct tf *tfp,
- struct tf_dev_global_cfg_parms *parms)
+ struct tf_global_cfg_parms *parms)
{
int rc;
struct tf_global_cfg_get_hcapi_parms hparms;
int
tf_global_cfg_get(struct tf *tfp,
- struct tf_dev_global_cfg_parms *parms)
+ struct tf_global_cfg_parms *parms)
{
int rc;
* The global cfg module provides processing of global cfg types.
*/
-struct tf;
+/* struct tf; */
+
+/* Internal type not available to user
+ * but available internally within Truflow
+ */
+enum tf_global_config_internal_type {
+ TF_GLOBAL_CFG_INTERNAL_PARIF_2_PF = TF_GLOBAL_CFG_TYPE_MAX,
+ TF_GLOBAL_CFG_INTERNAL_TYPE_MAX
+};
/**
* Global cfg configuration enumeration.
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
*
* - (-EINVAL) on failure.
*/
int tf_global_cfg_set(struct tf *tfp,
- struct tf_dev_global_cfg_parms *parms);
+ struct tf_global_cfg_parms *parms);
/**
* Get global configuration
* - (-EINVAL) on failure.
*/
int tf_global_cfg_get(struct tf *tfp,
- struct tf_dev_global_cfg_parms *parms);
+ struct tf_global_cfg_parms *parms);
#endif /* TF_GLOBAL_CFG_H */
int
tf_msg_get_global_cfg(struct tf *tfp,
- struct tf_dev_global_cfg_parms *params)
+ struct tf_global_cfg_parms *params)
{
int rc = 0;
struct tfp_send_msg_parms parms = { 0 };
int
tf_msg_set_global_cfg(struct tf *tfp,
- struct tf_dev_global_cfg_parms *params)
+ struct tf_global_cfg_parms *params)
{
int rc = 0;
struct tfp_send_msg_parms parms = { 0 };
tfp_memcpy(req.data, params->config,
params->config_sz_in_bytes);
+
+ /* Only set mask if pointer is provided
+ */
+ if (params->config_mask) {
+ tfp_memcpy(req.data + params->config_sz_in_bytes,
+ params->config_mask,
+ params->config_sz_in_bytes);
+ }
+
req.size = tfp_cpu_to_le_32(params->config_sz_in_bytes);
parms.tf_type = HWRM_TF_GLOBAL_CFG_SET;
* 0 on Success else internal Truflow error
*/
int tf_msg_get_global_cfg(struct tf *tfp,
- struct tf_dev_global_cfg_parms *params);
+ struct tf_global_cfg_parms *params);
/**
* Sends global cfg update request to Firmware
* 0 on Success else internal Truflow error
*/
int tf_msg_set_global_cfg(struct tf *tfp,
- struct tf_dev_global_cfg_parms *params);
+ struct tf_global_cfg_parms *params);
/**
* Sends bulk get message of a Table Type element to the firmware.