ulp_fc_mgr_shadow_mem_alloc(struct hw_fc_mem_info *parms, int size)
{
/* Allocate memory*/
- if (parms == NULL)
+ if (!parms)
return -EINVAL;
parms->mem_va = rte_zmalloc("ulp_fc_info",
RTE_CACHE_LINE_ROUNDUP(size),
4096);
- if (parms->mem_va == NULL) {
+ if (!parms->mem_va) {
BNXT_TF_DBG(ERR, "Allocate failed mem_va\n");
return -ENOMEM;
}
for (i = 0; i < TF_DIR_MAX; i++)
ulp_fc_mgr_shadow_mem_free(&ulp_fc_info->shadow_hw_tbl[i]);
-
rte_free(ulp_fc_info);
/* Safe to ignore on deinit */
stats = (uint64_t *)fc_info->shadow_hw_tbl[dir].mem_va;
parms.physical_mem_addr = (uintptr_t)fc_info->shadow_hw_tbl[dir].mem_pa;
- if (stats == NULL) {
+ if (!stats) {
PMD_DRV_LOG(ERR,
"BULK: Memory not initialized id:0x%x dir:%d\n",
parms.starting_idx, dir);
sw_acc_tbl_entry = &fc_info->sw_acc_tbl[dir][i];
if (!sw_acc_tbl_entry->valid)
continue;
- sw_acc_tbl_entry->pkt_count += FLOW_CNTR_PKTS(stats[i], dparms);
+ sw_acc_tbl_entry->pkt_count += FLOW_CNTR_PKTS(stats[i],
+ dparms);
sw_acc_tbl_entry->byte_count += FLOW_CNTR_BYTES(stats[i],
dparms);
}
return rc;
}
-static int ulp_get_single_flow_stat(struct tf *tfp,
+static int ulp_get_single_flow_stat(struct bnxt_ulp_context *ctxt,
+ struct tf *tfp,
struct bnxt_ulp_fc_info *fc_info,
enum tf_dir dir,
uint32_t hw_cntr_id,
int rc = 0;
struct tf_get_tbl_entry_parms parms = { 0 };
enum tf_tbl_type stype = TF_TBL_TYPE_ACT_STATS_64; /* TBD:Template? */
- struct sw_acc_counter *sw_acc_tbl_entry = NULL;
+ struct sw_acc_counter *sw_acc_tbl_entry = NULL, *t_sw;
uint64_t stats = 0;
uint32_t sw_cntr_indx = 0;
sw_acc_tbl_entry->pkt_count = FLOW_CNTR_PKTS(stats, dparms);
sw_acc_tbl_entry->byte_count = FLOW_CNTR_BYTES(stats, dparms);
+ /* Update the parent counters if it is child flow */
+ if (sw_acc_tbl_entry->parent_flow_id) {
+ /* Update the parent counters */
+ t_sw = sw_acc_tbl_entry;
+ if (ulp_flow_db_parent_flow_count_update(ctxt,
+ t_sw->parent_flow_id,
+ t_sw->pkt_count,
+ t_sw->byte_count)) {
+ PMD_DRV_LOG(ERR, "Error updating parent counters\n");
+ }
+ }
+
return rc;
}
break;
}
*/
+
+ /* reset the parent accumulation counters before accumulation if any */
+ ulp_flow_db_parent_flow_count_reset(ctxt);
+
num_entries = dparms->flow_count_db_entries / 2;
for (i = 0; i < TF_DIR_MAX; i++) {
for (j = 0; j < num_entries; j++) {
if (!ulp_fc_info->sw_acc_tbl[i][j].valid)
continue;
hw_cntr_id = ulp_fc_info->sw_acc_tbl[i][j].hw_cntr_id;
- rc = ulp_get_single_flow_stat(tfp, ulp_fc_info, i,
+ rc = ulp_get_single_flow_stat(ctxt, tfp, ulp_fc_info, i,
hw_cntr_id, dparms);
if (rc)
break;
(params.resource_sub_type ==
BNXT_ULP_RESOURCE_SUB_TYPE_INDEX_TYPE_INT_COUNT ||
params.resource_sub_type ==
- BNXT_ULP_RESOURCE_SUB_TYPE_INDEX_TYPE_EXT_COUNT)) {
+ BNXT_ULP_RESOURCE_SUB_TYPE_INDEX_TYPE_EXT_COUNT ||
+ params.resource_sub_type ==
+ BNXT_ULP_RESOURCE_SUB_TYPE_INDEX_TYPE_INT_COUNT_ACC)) {
found_cntr_resource = true;
break;
}
-
} while (!rc && nxt_resource_index);
bnxt_ulp_cntxt_release_fdb_lock(ctxt);
dir = params.direction;
hw_cntr_id = params.resource_hndl;
- sw_cntr_idx = hw_cntr_id -
- ulp_fc_info->shadow_hw_tbl[dir].start_idx;
- sw_acc_tbl_entry = &ulp_fc_info->sw_acc_tbl[dir][sw_cntr_idx];
if (params.resource_sub_type ==
BNXT_ULP_RESOURCE_SUB_TYPE_INDEX_TYPE_INT_COUNT) {
pthread_mutex_lock(&ulp_fc_info->fc_lock);
+ sw_cntr_idx = hw_cntr_id -
+ ulp_fc_info->shadow_hw_tbl[dir].start_idx;
+ sw_acc_tbl_entry = &ulp_fc_info->sw_acc_tbl[dir][sw_cntr_idx];
if (sw_acc_tbl_entry->pkt_count) {
count->hits_set = 1;
count->bytes_set = 1;
sw_acc_tbl_entry->byte_count = 0;
}
pthread_mutex_unlock(&ulp_fc_info->fc_lock);
+ } else if (params.resource_sub_type ==
+ BNXT_ULP_RESOURCE_SUB_TYPE_INDEX_TYPE_INT_COUNT_ACC) {
+ /* Get the stats from the parent child table */
+ ulp_flow_db_parent_flow_count_get(ctxt,
+ flow_id,
+ &count->hits,
+ &count->bytes);
+ count->hits_set = 1;
+ count->bytes_set = 1;
} else {
/* TBD: Handle External counters */
rc = -EINVAL;
return rc;
}
+
+/*
+ * Set the parent flow if it is SW accumulation counter entry.
+ *
+ * ctxt [in] The ulp context for the flow counter manager
+ *
+ * dir [in] The direction of the flow
+ *
+ * hw_cntr_id [in] The HW flow counter ID
+ *
+ * fid [in] parent flow id
+ *
+ */
+int32_t ulp_fc_mgr_cntr_parent_flow_set(struct bnxt_ulp_context *ctxt,
+ enum tf_dir dir,
+ uint32_t hw_cntr_id,
+ uint32_t fid)
+{
+ struct bnxt_ulp_fc_info *ulp_fc_info;
+ uint32_t sw_cntr_idx;
+ int32_t rc = 0;
+
+ ulp_fc_info = bnxt_ulp_cntxt_ptr2_fc_info_get(ctxt);
+ if (!ulp_fc_info)
+ return -EIO;
+
+ pthread_mutex_lock(&ulp_fc_info->fc_lock);
+ sw_cntr_idx = hw_cntr_id - ulp_fc_info->shadow_hw_tbl[dir].start_idx;
+ if (ulp_fc_info->sw_acc_tbl[dir][sw_cntr_idx].valid) {
+ ulp_fc_info->sw_acc_tbl[dir][sw_cntr_idx].parent_flow_id = fid;
+ } else {
+ BNXT_TF_DBG(ERR, "Failed to set parent flow id %x:%x\n",
+ hw_cntr_id, fid);
+ rc = -ENOENT;
+ }
+ pthread_mutex_unlock(&ulp_fc_info->fc_lock);
+
+ return rc;
+}
* the first match.
*/
static int32_t
-ulp_flow_db_resource_hndl_get(struct bnxt_ulp_context *ulp_ctx,
- enum bnxt_ulp_fdb_type flow_type,
- uint32_t flow_id,
- uint32_t resource_func,
- uint32_t res_subtype,
- uint64_t *res_hndl)
+ulp_flow_db_resource_params_get(struct bnxt_ulp_context *ulp_ctx,
+ enum bnxt_ulp_fdb_type flow_type,
+ uint32_t flow_id,
+ uint32_t resource_func,
+ uint32_t res_subtype,
+ struct ulp_flow_db_res_params *params)
{
struct bnxt_ulp_flow_db *flow_db;
struct bnxt_ulp_flow_tbl *flow_tbl;
return -EINVAL;
}
+ if (!params) {
+ BNXT_TF_DBG(ERR, "invalid argument\n");
+ return -EINVAL;
+ }
+
if (flow_type > BNXT_ULP_FDB_TYPE_DEFAULT) {
BNXT_TF_DBG(ERR, "Invalid flow type\n");
return -EINVAL;
}
/* Iterate the resource to get the resource handle */
res_id = flow_id;
+ memset(params, 0, sizeof(struct ulp_flow_db_res_params));
while (res_id) {
fid_res = &flow_tbl->flow_resources[res_id];
if (ulp_flow_db_resource_func_get(fid_res) == resource_func) {
if (resource_func & ULP_FLOW_DB_RES_FUNC_NEED_LOWER) {
if (res_subtype == fid_res->resource_sub_type) {
- *res_hndl = fid_res->resource_hndl;
+ ulp_flow_db_res_info_to_params(fid_res,
+ params);
return 0;
}
BNXT_ULP_RESOURCE_FUNC_EXT_EM_TABLE ||
resource_func ==
BNXT_ULP_RESOURCE_FUNC_INT_EM_TABLE) {
- *res_hndl = fid_res->resource_em_handle;
+ ulp_flow_db_res_info_to_params(fid_res,
+ params);
return 0;
}
}
uint16_t *cfa_action)
{
uint8_t sub_type = BNXT_ULP_RESOURCE_SUB_TYPE_INDEX_TYPE_VFR_CFA_ACTION;
- uint64_t hndl;
+ struct ulp_flow_db_res_params params;
int32_t rc;
- rc = ulp_flow_db_resource_hndl_get(ulp_ctx,
- BNXT_ULP_FDB_TYPE_DEFAULT,
- flow_id,
- BNXT_ULP_RESOURCE_FUNC_INDEX_TABLE,
- sub_type, &hndl);
+ rc = ulp_flow_db_resource_params_get(ulp_ctx,
+ BNXT_ULP_FDB_TYPE_DEFAULT,
+ flow_id,
+ BNXT_ULP_RESOURCE_FUNC_INDEX_TABLE,
+ sub_type, ¶ms);
if (rc) {
BNXT_TF_DBG(ERR, "CFA Action ptr not found for flow id %u\n",
flow_id);
return -ENOENT;
}
- *cfa_action = hndl;
+ *cfa_action = params.resource_hndl;
return 0;
}
+/* internal validation function for parent flow tbl */
+static struct bnxt_ulp_flow_db *
+ulp_flow_db_parent_arg_validation(struct bnxt_ulp_context *ulp_ctxt,
+ uint32_t fid)
+{
+ struct bnxt_ulp_flow_db *flow_db;
+
+ flow_db = bnxt_ulp_cntxt_ptr2_flow_db_get(ulp_ctxt);
+ if (!flow_db) {
+ BNXT_TF_DBG(ERR, "Invalid Arguments\n");
+ return NULL;
+ }
+
+ /* check for max flows */
+ if (fid >= flow_db->flow_tbl.num_flows || !fid) {
+ BNXT_TF_DBG(ERR, "Invalid flow index\n");
+ return NULL;
+ }
+
+ /* No support for parent child db then just exit */
+ if (!flow_db->parent_child_db.entries_count) {
+ BNXT_TF_DBG(ERR, "parent child db not supported\n");
+ return NULL;
+ }
+
+ return flow_db;
+}
+
/*
* Allocate the entry in the parent-child database
*
struct ulp_fdb_parent_child_db *p_pdb;
uint32_t idx, free_idx = 0;
- flow_db = bnxt_ulp_cntxt_ptr2_flow_db_get(ulp_ctxt);
+ /* validate the arguments */
+ flow_db = ulp_flow_db_parent_arg_validation(ulp_ctxt, fid);
if (!flow_db) {
- BNXT_TF_DBG(ERR, "Invalid Arguments\n");
- return -EINVAL;
- }
-
- /* check for max flows */
- if (fid >= flow_db->flow_tbl.num_flows || !fid) {
- BNXT_TF_DBG(ERR, "Invalid flow index\n");
- return -EINVAL;
- }
-
- /* No support for parent child db then just exit */
- if (!flow_db->parent_child_db.entries_count) {
- BNXT_TF_DBG(ERR, "parent child db not supported\n");
+ BNXT_TF_DBG(ERR, "parent child db validation failed\n");
return -EINVAL;
}
p_pdb = &flow_db->parent_child_db;
- for (idx = 0; idx <= p_pdb->entries_count; idx++) {
+ for (idx = 0; idx < p_pdb->entries_count; idx++) {
if (p_pdb->parent_flow_tbl[idx].parent_fid == fid) {
BNXT_TF_DBG(ERR, "fid is already allocated\n");
return -EINVAL;
struct ulp_fdb_parent_child_db *p_pdb;
uint32_t idx;
- flow_db = bnxt_ulp_cntxt_ptr2_flow_db_get(ulp_ctxt);
+ /* validate the arguments */
+ flow_db = ulp_flow_db_parent_arg_validation(ulp_ctxt, fid);
if (!flow_db) {
- BNXT_TF_DBG(ERR, "Invalid Arguments\n");
- return -EINVAL;
- }
-
- /* check for max flows */
- if (fid >= flow_db->flow_tbl.num_flows || !fid) {
- BNXT_TF_DBG(ERR, "Invalid flow index\n");
- return -EINVAL;
- }
-
- /* No support for parent child db then just exit */
- if (!flow_db->parent_child_db.entries_count) {
- BNXT_TF_DBG(ERR, "parent child db not supported\n");
+ BNXT_TF_DBG(ERR, "parent child db validation failed\n");
return -EINVAL;
}
p_pdb = &flow_db->parent_child_db;
- for (idx = 0; idx <= p_pdb->entries_count; idx++) {
+ for (idx = 0; idx < p_pdb->entries_count; idx++) {
if (p_pdb->parent_flow_tbl[idx].parent_fid == fid) {
/* free the contents */
p_pdb->parent_flow_tbl[idx].parent_fid = 0;
uint32_t idx, a_idx;
uint64_t *t;
- flow_db = bnxt_ulp_cntxt_ptr2_flow_db_get(ulp_ctxt);
+ /* validate the arguments */
+ flow_db = ulp_flow_db_parent_arg_validation(ulp_ctxt, parent_fid);
if (!flow_db) {
- BNXT_TF_DBG(ERR, "Invalid Arguments\n");
- return -EINVAL;
- }
-
- /* check for fid validity */
- if (parent_fid >= flow_db->flow_tbl.num_flows || !parent_fid) {
- BNXT_TF_DBG(ERR, "Invalid parent flow index %x\n", parent_fid);
+ BNXT_TF_DBG(ERR, "parent child db validation failed\n");
return -EINVAL;
}
return -EINVAL;
}
- /* No support for parent child db then just exit */
- if (!flow_db->parent_child_db.entries_count) {
- BNXT_TF_DBG(ERR, "parent child db not supported\n");
- return -EINVAL;
- }
-
p_pdb = &flow_db->parent_child_db;
a_idx = child_fid / ULP_INDEX_BITMAP_SIZE;
- for (idx = 0; idx <= p_pdb->entries_count; idx++) {
+ for (idx = 0; idx < p_pdb->entries_count; idx++) {
if (p_pdb->parent_flow_tbl[idx].parent_fid == parent_fid) {
t = p_pdb->parent_flow_tbl[idx].child_fid_bitset;
if (set_flag)
struct ulp_fdb_parent_child_db *p_pdb;
uint32_t idx;
- flow_db = bnxt_ulp_cntxt_ptr2_flow_db_get(ulp_ctxt);
+ /* validate the arguments */
+ flow_db = ulp_flow_db_parent_arg_validation(ulp_ctxt, parent_fid);
if (!flow_db) {
- BNXT_TF_DBG(ERR, "Invalid Arguments\n");
- return -EINVAL;
- }
-
- /* check for fid validity */
- if (parent_fid >= flow_db->flow_tbl.num_flows || !parent_fid) {
- BNXT_TF_DBG(ERR, "Invalid parent flow index %x\n", parent_fid);
- return -EINVAL;
- }
-
- /* No support for parent child db then just exit */
- if (!flow_db->parent_child_db.entries_count) {
- BNXT_TF_DBG(ERR, "parent child db not supported\n");
+ BNXT_TF_DBG(ERR, "parent child db validation failed\n");
return -EINVAL;
}
p_pdb = &flow_db->parent_child_db;
- for (idx = 0; idx <= p_pdb->entries_count; idx++) {
+ for (idx = 0; idx < p_pdb->entries_count; idx++) {
if (p_pdb->parent_flow_tbl[idx].parent_fid == parent_fid) {
*parent_idx = idx;
return 0;
return 0;
}
+/*
+ * Set the counter accumulation in the parent flow
+ *
+ * ulp_ctxt [in] Ptr to ulp_context
+ * parent_idx [in] The parent index of the parent flow entry
+ *
+ * returns index on success and negative on failure.
+ */
+static int32_t
+ulp_flow_db_parent_flow_count_accum_set(struct bnxt_ulp_context *ulp_ctxt,
+ uint32_t parent_idx)
+{
+ struct bnxt_ulp_flow_db *flow_db;
+ struct ulp_fdb_parent_child_db *p_pdb;
+
+ flow_db = bnxt_ulp_cntxt_ptr2_flow_db_get(ulp_ctxt);
+ if (!flow_db) {
+ BNXT_TF_DBG(ERR, "Invalid Arguments\n");
+ return -EINVAL;
+ }
+
+ /* check for parent idx validity */
+ p_pdb = &flow_db->parent_child_db;
+ if (parent_idx >= p_pdb->entries_count ||
+ !p_pdb->parent_flow_tbl[parent_idx].parent_fid) {
+ BNXT_TF_DBG(ERR, "Invalid parent flow index %x\n", parent_idx);
+ return -EINVAL;
+ }
+
+ p_pdb->parent_flow_tbl[parent_idx].counter_acc = 1;
+ return 0;
+}
+
+/*
+ * Get the counter accumulation in the parent flow
+ *
+ * ulp_ctxt [in] Ptr to ulp_context
+ * parent_fid [in] The flow id of the parent flow entry
+ *
+ * returns 0 if counter accum is set else -1.
+ */
+static int32_t
+ulp_flow_db_parent_flow_count_accum_get(struct bnxt_ulp_context *ulp_ctxt,
+ uint32_t parent_fid)
+{
+ struct bnxt_ulp_flow_db *flow_db;
+ struct ulp_fdb_parent_child_db *p_pdb;
+ uint32_t idx;
+
+ /* validate the arguments */
+ flow_db = ulp_flow_db_parent_arg_validation(ulp_ctxt, parent_fid);
+ if (!flow_db) {
+ BNXT_TF_DBG(ERR, "parent child db validation failed\n");
+ return -EINVAL;
+ }
+
+ p_pdb = &flow_db->parent_child_db;
+ for (idx = 0; idx < p_pdb->entries_count; idx++) {
+ if (p_pdb->parent_flow_tbl[idx].parent_fid == parent_fid) {
+ if (p_pdb->parent_flow_tbl[idx].counter_acc)
+ return 0;
+ break;
+ }
+ }
+ return -1;
+}
+
/*
* Orphan the child flow entry
* This is called only for child flows that have
ulp_flow_db_parent_flow_create(struct bnxt_ulp_mapper_parms *parms)
{
struct ulp_flow_db_res_params fid_parms;
+ uint32_t sub_type = BNXT_ULP_RESOURCE_SUB_TYPE_INDEX_TYPE_INT_COUNT_ACC;
+ struct ulp_flow_db_res_params res_params;
int32_t fid_idx;
/* create the child flow entry in parent flow table */
parms->fid);
return -1;
}
+
+ /* check of the flow has internal counter accumulation enabled */
+ if (!ulp_flow_db_resource_params_get(parms->ulp_ctx,
+ BNXT_ULP_FDB_TYPE_REGULAR,
+ parms->fid,
+ BNXT_ULP_RESOURCE_FUNC_INDEX_TABLE,
+ sub_type,
+ &res_params)) {
+ /* Enable the counter accumulation in parent entry */
+ if (ulp_flow_db_parent_flow_count_accum_set(parms->ulp_ctx,
+ fid_idx)) {
+ BNXT_TF_DBG(ERR, "Error in setting counter acc %x\n",
+ parms->fid);
+ return -1;
+ }
+ }
return 0;
}
ulp_flow_db_child_flow_create(struct bnxt_ulp_mapper_parms *parms)
{
struct ulp_flow_db_res_params fid_parms;
+ uint32_t sub_type = BNXT_ULP_RESOURCE_SUB_TYPE_INDEX_TYPE_INT_COUNT;
+ enum bnxt_ulp_resource_func res_fun;
+ struct ulp_flow_db_res_params res_p;
+ uint32_t parent_fid = parms->parent_fid;
int32_t rc;
/* create the parent flow entry in parent flow table */
parms->fid, 1);
if (rc) {
BNXT_TF_DBG(ERR, "Error in setting child fid %x\n", parms->fid);
- return -1;
+ return rc;
}
/* Add the parent details in the resource list of the flow */
fid_parms.resource_func = BNXT_ULP_RESOURCE_FUNC_CHILD_FLOW;
fid_parms.resource_hndl = parms->parent_fid;
fid_parms.critical_resource = BNXT_ULP_CRITICAL_RESOURCE_NO;
- if (ulp_flow_db_resource_add(parms->ulp_ctx, BNXT_ULP_FDB_TYPE_REGULAR,
- parms->fid, &fid_parms)) {
+ rc = ulp_flow_db_resource_add(parms->ulp_ctx,
+ BNXT_ULP_FDB_TYPE_REGULAR,
+ parms->fid, &fid_parms);
+ if (rc) {
BNXT_TF_DBG(ERR, "Error in adding flow res for fid %x\n",
parms->fid);
- return -1;
+ return rc;
+ }
+
+ /* check if accumulation count is set for parent flow */
+ rc = ulp_flow_db_parent_flow_count_accum_get(parms->ulp_ctx,
+ parms->parent_fid);
+ if (!rc) {
+ /* check if internal count action included for this flow.*/
+ res_fun = BNXT_ULP_RESOURCE_FUNC_INDEX_TABLE;
+ rc = ulp_flow_db_resource_params_get(parms->ulp_ctx,
+ BNXT_ULP_FDB_TYPE_REGULAR,
+ parms->fid,
+ res_fun,
+ sub_type,
+ &res_p);
+ if (!rc) {
+ /* update the counter manager to include parent fid */
+ if (ulp_fc_mgr_cntr_parent_flow_set(parms->ulp_ctx,
+ res_p.direction,
+ res_p.resource_hndl,
+ parent_fid)) {
+ BNXT_TF_DBG(ERR, "Error in setting child %x\n",
+ parms->fid);
+ return -1;
+ }
+ }
}
+ /* return success */
return 0;
}
+
+/*
+ * Update the parent counters
+ *
+ * ulp_ctxt [in] Ptr to ulp_context
+ * parent_fid [in] The flow id of the parent flow entry
+ * packet_count [in] - packet count
+ * byte_count [in] - byte count
+ *
+ * returns 0 on success
+ */
+int32_t
+ulp_flow_db_parent_flow_count_update(struct bnxt_ulp_context *ulp_ctxt,
+ uint32_t parent_fid,
+ uint64_t packet_count,
+ uint64_t byte_count)
+{
+ struct bnxt_ulp_flow_db *flow_db;
+ struct ulp_fdb_parent_child_db *p_pdb;
+ uint32_t idx;
+
+ /* validate the arguments */
+ flow_db = ulp_flow_db_parent_arg_validation(ulp_ctxt, parent_fid);
+ if (!flow_db) {
+ BNXT_TF_DBG(ERR, "parent child db validation failed\n");
+ return -EINVAL;
+ }
+
+ p_pdb = &flow_db->parent_child_db;
+ for (idx = 0; idx < p_pdb->entries_count; idx++) {
+ if (p_pdb->parent_flow_tbl[idx].parent_fid == parent_fid) {
+ if (p_pdb->parent_flow_tbl[idx].counter_acc) {
+ p_pdb->parent_flow_tbl[idx].pkt_count +=
+ packet_count;
+ p_pdb->parent_flow_tbl[idx].byte_count +=
+ byte_count;
+ }
+ return 0;
+ }
+ }
+ return -ENOENT;
+}
+
+/*
+ * Get the parent accumulation counters
+ *
+ * ulp_ctxt [in] Ptr to ulp_context
+ * parent_fid [in] The flow id of the parent flow entry
+ * packet_count [out] - packet count
+ * byte_count [out] - byte count
+ *
+ * returns 0 on success
+ */
+int32_t
+ulp_flow_db_parent_flow_count_get(struct bnxt_ulp_context *ulp_ctxt,
+ uint32_t parent_fid,
+ uint64_t *packet_count,
+ uint64_t *byte_count)
+{
+ struct bnxt_ulp_flow_db *flow_db;
+ struct ulp_fdb_parent_child_db *p_pdb;
+ uint32_t idx;
+
+ /* validate the arguments */
+ flow_db = ulp_flow_db_parent_arg_validation(ulp_ctxt, parent_fid);
+ if (!flow_db) {
+ BNXT_TF_DBG(ERR, "parent child db validation failed\n");
+ return -EINVAL;
+ }
+
+ p_pdb = &flow_db->parent_child_db;
+ for (idx = 0; idx < p_pdb->entries_count; idx++) {
+ if (p_pdb->parent_flow_tbl[idx].parent_fid == parent_fid) {
+ if (p_pdb->parent_flow_tbl[idx].counter_acc) {
+ *packet_count =
+ p_pdb->parent_flow_tbl[idx].pkt_count;
+ *byte_count =
+ p_pdb->parent_flow_tbl[idx].byte_count;
+ }
+ return 0;
+ }
+ }
+ return -ENOENT;
+}
+
+/*
+ * reset the parent accumulation counters
+ *
+ * ulp_ctxt [in] Ptr to ulp_context
+ *
+ * returns none
+ */
+void
+ulp_flow_db_parent_flow_count_reset(struct bnxt_ulp_context *ulp_ctxt)
+{
+ struct bnxt_ulp_flow_db *flow_db;
+ struct ulp_fdb_parent_child_db *p_pdb;
+ uint32_t idx;
+
+ /* validate the arguments */
+ flow_db = ulp_flow_db_parent_arg_validation(ulp_ctxt, 1);
+ if (!flow_db) {
+ BNXT_TF_DBG(ERR, "parent child db validation failed\n");
+ return;
+ }
+
+ p_pdb = &flow_db->parent_child_db;
+ for (idx = 0; idx < p_pdb->entries_count; idx++) {
+ if (p_pdb->parent_flow_tbl[idx].parent_fid &&
+ p_pdb->parent_flow_tbl[idx].counter_acc) {
+ p_pdb->parent_flow_tbl[idx].pkt_count = 0;
+ p_pdb->parent_flow_tbl[idx].byte_count = 0;
+ }
+ }
+}