@@ -705,7 +705,9 @@ enum tfc_tbl_scope_bucket_factor {
TFC_TBL_SCOPE_BUCKET_FACTOR_4 = 4,
TFC_TBL_SCOPE_BUCKET_FACTOR_8 = 8,
TFC_TBL_SCOPE_BUCKET_FACTOR_16 = 16,
- TFC_TBL_SCOPE_BUCKET_FACTOR_MAX = TFC_TBL_SCOPE_BUCKET_FACTOR_16
+ TFC_TBL_SCOPE_BUCKET_FACTOR_32 = 32,
+ TFC_TBL_SCOPE_BUCKET_FACTOR_64 = 64,
+ TFC_TBL_SCOPE_BUCKET_FACTOR_MAX = TFC_TBL_SCOPE_BUCKET_FACTOR_64
};
/**
@@ -1420,8 +1422,9 @@ int tfc_act_set(struct tfc *tfcp,
* @param[in] cmm_clr
* Pointer to cmm clr
*
- * @param[in,out] data
- * Data read. Must be word aligned, i.e. [1:0] must be 0.
+ * @param[in,out] host_address
+ * Data read. Must be word aligned, i.e. [1:0] must be 0. The address
+ * must be the ret_mem_virt2iova() version of the virt address.
*
* @param[in,out] data_sz_words
* Data buffer size in words. Size could be 8/16/24/32/64B
@@ -1437,7 +1440,8 @@ int tfc_act_get(struct tfc *tfcp,
struct tfc_mpc_batch_info_t *batch_info,
const struct tfc_cmm_info *cmm_info,
struct tfc_cmm_clr *clr,
- uint8_t *data, uint16_t *data_sz_words);
+ uint64_t *host_address,
+ uint16_t *data_sz_words);
/**
* Free a CMM Resource
@@ -367,7 +367,7 @@ int tfc_act_get_only_response(struct cfa_bld_mpcinfo *mpc_info,
static int tfc_act_get_only(struct tfc *tfcp,
struct tfc_mpc_batch_info_t *batch_info,
const struct tfc_cmm_info *cmm_info,
- uint8_t *data,
+ uint64_t *host_address,
uint16_t *data_sz_words)
{
int rc = 0;
@@ -378,7 +378,6 @@ static int tfc_act_get_only(struct tfc *tfcp,
uint32_t buff_len;
struct cfa_mpc_data_obj fields_cmd[CFA_BLD_MPC_READ_CMD_MAX_FLD] = { {0} };
uint32_t entry_offset;
- uint64_t host_address;
struct bnxt_mpc_mbuf mpc_msg_in;
struct bnxt_mpc_mbuf mpc_msg_out;
uint32_t record_size;
@@ -405,13 +404,11 @@ static int tfc_act_get_only(struct tfc *tfcp,
}
/* Check that data pointer is word aligned */
- if (unlikely(((uint64_t)data) & 0x3ULL)) {
+ if (unlikely(*host_address & 0x3ULL)) {
PMD_DRV_LOG_LINE(ERR, "data pointer not word aligned");
return -EINVAL;
}
- host_address = (uint64_t)rte_mem_virt2iova(data);
-
/* Check that MPC APIs are bound */
if (unlikely(mpc_info->mpcops == NULL)) {
PMD_DRV_LOG_LINE(ERR, "MPC not initialized");
@@ -450,7 +447,7 @@ static int tfc_act_get_only(struct tfc *tfcp,
fields_cmd[CFA_BLD_MPC_READ_CMD_HOST_ADDRESS_FLD].field_id =
CFA_BLD_MPC_READ_CMD_HOST_ADDRESS_FLD;
- fields_cmd[CFA_BLD_MPC_READ_CMD_HOST_ADDRESS_FLD].val = host_address;
+ fields_cmd[CFA_BLD_MPC_READ_CMD_HOST_ADDRESS_FLD].val = *host_address;
buff_len = TFC_MPC_MAX_TX_BYTES;
@@ -547,7 +544,7 @@ int tfc_act_get_clear_response(struct cfa_bld_mpcinfo *mpc_info,
static int tfc_act_get_clear(struct tfc *tfcp,
struct tfc_mpc_batch_info_t *batch_info,
const struct tfc_cmm_info *cmm_info,
- uint8_t *data,
+ uint64_t *host_address,
uint16_t *data_sz_words,
uint8_t clr_offset,
uint8_t clr_size)
@@ -560,7 +557,6 @@ static int tfc_act_get_clear(struct tfc *tfcp,
uint32_t buff_len;
struct cfa_mpc_data_obj fields_cmd[CFA_BLD_MPC_READ_CLR_CMD_MAX_FLD] = { {0} };
uint32_t entry_offset;
- uint64_t host_address;
struct bnxt_mpc_mbuf mpc_msg_in;
struct bnxt_mpc_mbuf mpc_msg_out;
uint32_t record_size;
@@ -589,13 +585,11 @@ static int tfc_act_get_clear(struct tfc *tfcp,
}
/* Check that data pointer is word aligned */
- if (unlikely(((uint64_t)data) & 0x3ULL)) {
+ if (unlikely(*host_address & 0x3ULL)) {
PMD_DRV_LOG_LINE(ERR, "data pointer not word aligned");
return -EINVAL;
}
- host_address = (uint64_t)rte_mem_virt2iova(data);
-
/* Check that MPC APIs are bound */
if (unlikely(mpc_info->mpcops == NULL)) {
PMD_DRV_LOG_LINE(ERR, "MPC not initialized");
@@ -634,7 +628,7 @@ static int tfc_act_get_clear(struct tfc *tfcp,
fields_cmd[CFA_BLD_MPC_READ_CLR_CMD_HOST_ADDRESS_FLD].field_id =
CFA_BLD_MPC_READ_CLR_CMD_HOST_ADDRESS_FLD;
- fields_cmd[CFA_BLD_MPC_READ_CLR_CMD_HOST_ADDRESS_FLD].val = host_address;
+ fields_cmd[CFA_BLD_MPC_READ_CLR_CMD_HOST_ADDRESS_FLD].val = *host_address;
for (i = clr_offset; i < clr_size; i++)
mask |= (1 << i);
@@ -700,7 +694,8 @@ int tfc_act_get(struct tfc *tfcp,
struct tfc_mpc_batch_info_t *batch_info,
const struct tfc_cmm_info *cmm_info,
struct tfc_cmm_clr *clr,
- uint8_t *data, uint16_t *data_sz_words)
+ uint64_t *host_address,
+ uint16_t *data_sz_words)
{
/* It's not an error to pass clr as a Null pointer, just means that read
* and clear is not being requested. Also allow the user to manage
@@ -718,14 +713,15 @@ int tfc_act_get(struct tfc *tfcp,
return tfc_act_get_clear(tfcp,
batch_info,
cmm_info,
- data, data_sz_words,
+ host_address,
+ data_sz_words,
clr->offset_in_byte / 2,
clr->sz_in_byte / 2);
} else {
return tfc_act_get_only(tfcp,
batch_info,
cmm_info,
- data,
+ host_address,
data_sz_words);
}
}
@@ -53,6 +53,7 @@ ulp_fc_tfc_update_accum_stats(__rte_unused struct bnxt_ulp_context *ctxt,
}
static uint8_t *data;
+static uint64_t virt2iova_data;
static int32_t
ulp_fc_tfc_flow_stat_get(struct bnxt_ulp_context *ctxt,
@@ -84,6 +85,8 @@ ulp_fc_tfc_flow_stat_get(struct bnxt_ulp_context *ctxt,
BNXT_DRV_DBG(ERR, "Failed to allocate dma buffer\n");
return -EINVAL;
}
+
+ virt2iova_data = (uint64_t)rte_mem_virt2iova(data);
}
/* Ensure that data is large enough to read words */
@@ -105,7 +108,7 @@ ulp_fc_tfc_flow_stat_get(struct bnxt_ulp_context *ctxt,
cmm_clr.sz_in_byte = sizeof(data64[ULP_FC_TFC_PKT_CNT_OFFS]) +
sizeof(data64[ULP_FC_TFC_BYTE_CNT_OFFS]);
}
- rc = tfc_act_get(tfcp, NULL, &cmm_info, &cmm_clr, data, &word_size);
+ rc = tfc_act_get(tfcp, NULL, &cmm_info, &cmm_clr, &virt2iova_data, &word_size);
if (rc) {
BNXT_DRV_DBG(ERR,
"Failed to read stat memory hndl=0x%" PRIx64 "\n",
@@ -3,6 +3,8 @@
* All rights reserved.
*/
+#include <sched.h>
+#include <unistd.h>
#include <rte_common.h>
#include <rte_cycles.h>
#include <rte_malloc.h>
@@ -56,7 +58,9 @@ int32_t ulp_sc_mgr_init(struct bnxt_ulp_context *ctxt)
struct bnxt_ulp_sc_info *ulp_sc_info;
uint32_t stats_cache_tbl_sz;
uint32_t dev_id;
+ uint8_t *data;
int rc;
+ int i;
if (!ctxt) {
BNXT_DRV_DBG(DEBUG, "Invalid ULP CTXT\n");
@@ -124,6 +128,12 @@ int32_t ulp_sc_mgr_init(struct bnxt_ulp_context *ctxt)
goto error;
}
+ data = ulp_sc_info->read_data;
+ for (i = 0; i < ULP_SC_BATCH_SIZE; i++) {
+ ulp_sc_info->read_data_iova[i] = (uint64_t)rte_mem_virt2iova(data);
+ data += ULP_SC_PAGE_SIZE;
+ }
+
rc = ulp_sc_mgr_thread_start(ctxt);
if (rc)
BNXT_DRV_DBG(DEBUG, "Stats counter thread start failed\n");
@@ -241,12 +251,12 @@ static uint32_t ulp_stats_cache_main_loop(void *arg)
(uint64_t)sce;
rc = sc_ops->ulp_stats_cache_update(tfcp,
- sce->dir,
- data,
- sce->handle,
- &words,
- &batch_info,
- sce->reset);
+ sce->dir,
+ &ulp_sc_info->read_data_iova[batch],
+ sce->handle,
+ &words,
+ &batch_info,
+ sce->reset);
if (unlikely(rc)) {
/* Abort this batch */
PMD_DRV_LOG_LINE(ERR,
@@ -330,18 +340,39 @@ int32_t
ulp_sc_mgr_thread_start(struct bnxt_ulp_context *ctxt)
{
struct bnxt_ulp_sc_info *ulp_sc_info;
+ rte_thread_attr_t attr;
+ rte_cpuset_t mask;
+ size_t i;
int rc;
ulp_sc_info = bnxt_ulp_cntxt_ptr2_sc_info_get(ctxt);
if (ulp_sc_info && !(ulp_sc_info->flags & ULP_FLAG_SC_THREAD)) {
+ rte_thread_attr_init(&attr);
+
+ rte_thread_get_affinity(&mask);
+
+ for (i = 1; i < CPU_SETSIZE; i++) {
+ if (CPU_ISSET(i, &mask)) {
+ CPU_ZERO(&mask);
+ CPU_SET(i + 2, &mask);
+ break;
+ }
+ }
+
+ rc = rte_thread_attr_set_affinity(&attr, &mask);
+ if (rc)
+ return rc;
+
rc = rte_thread_create(&ulp_sc_info->tid,
- NULL,
+ &attr,
&ulp_stats_cache_main_loop,
(void *)ctxt->cfg_data);
if (rc)
return rc;
+ rte_thread_set_prefixed_name(ulp_sc_info->tid, "ulp_sc_mgr");
+
ulp_sc_info->flags |= ULP_FLAG_SC_THREAD;
}
@@ -36,6 +36,7 @@ struct ulp_sc_tfc_stats_cache_entry {
struct bnxt_ulp_sc_info {
struct ulp_sc_tfc_stats_cache_entry *stats_cache_tbl;
uint8_t *read_data;
+ uint64_t read_data_iova[ULP_SC_BATCH_SIZE];
uint32_t flags;
uint32_t num_entries;
uint32_t num_counters;
@@ -48,7 +49,7 @@ struct bnxt_ulp_sc_core_ops {
int32_t
(*ulp_stats_cache_update)(struct tfc *tfcp,
int dir,
- uint8_t *data,
+ uint64_t *host_address,
uint64_t handle,
uint16_t *words,
struct tfc_mpc_batch_info_t *batch_info,
@@ -24,7 +24,7 @@
static int32_t
ulp_sc_tfc_stats_cache_update(struct tfc *tfcp,
int dir,
- uint8_t *data,
+ uint64_t *host_address,
uint64_t handle,
uint16_t *words,
struct tfc_mpc_batch_info_t *batch_info,
@@ -48,7 +48,7 @@ ulp_sc_tfc_stats_cache_update(struct tfc *tfcp,
batch_info,
&cmm_info,
&cmm_clr,
- data,
+ host_address,
words);
return rc;