+
+/*
+ * 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, uint8_t count_reset)
+{
+ 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;
+ if (count_reset) {
+ p_pdb->parent_flow_tbl[idx].pkt_count = 0;
+ p_pdb->parent_flow_tbl[idx].byte_count = 0;
+ }
+ }
+ 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;
+ }
+ }
+}
+
+/*
+ * Set the shared bit for the flow db entry
+ *
+ * res [in] Ptr to fdb entry
+ * shared [in] shared flag
+ *
+ * returns none
+ */
+void ulp_flow_db_shared_session_set(struct ulp_flow_db_res_params *res,
+ enum bnxt_ulp_shared_session shared)
+{
+ if (res && (shared & BNXT_ULP_SHARED_SESSION_YES))
+ res->fdb_flags |= ULP_FDB_FLAG_SHARED_SESSION;
+}