+
+/*
+ * Write the generic table list hash entry
+ *
+ * tbl_list [in] - pointer to the generic table list
+ * hash_entry [in] - Hash table entry
+ * gen_tbl_ent [out] - generic table entry
+ *
+ * returns 0 on success.
+ */
+int32_t
+ulp_mapper_gen_tbl_hash_entry_add(struct ulp_mapper_gen_tbl_list *tbl_list,
+ struct ulp_gen_hash_entry_params *hash_entry,
+ struct ulp_mapper_gen_tbl_entry *gen_tbl_ent)
+{
+ uint32_t key;
+ int32_t rc = 0;
+
+ switch (hash_entry->search_flag) {
+ case ULP_GEN_HASH_SEARCH_FOUND:
+ BNXT_TF_DBG(ERR, "%s: gen hash entry already present\n",
+ tbl_list->gen_tbl_name);
+ return -EINVAL;
+ case ULP_GEN_HASH_SEARCH_FULL:
+ BNXT_TF_DBG(ERR, "%s: gen hash table is full\n",
+ tbl_list->gen_tbl_name);
+ return -EINVAL;
+ case ULP_GEN_HASH_SEARCH_MISSED:
+ rc = ulp_gen_hash_tbl_list_add(tbl_list->hash_tbl, hash_entry);
+ if (rc) {
+ BNXT_TF_DBG(ERR, "%s: gen hash table add failed\n",
+ tbl_list->gen_tbl_name);
+ return -EINVAL;
+ }
+ key = hash_entry->key_idx;
+ gen_tbl_ent->ref_count = &tbl_list->container.ref_count[key];
+ gen_tbl_ent->byte_data_size =
+ tbl_list->container.byte_data_size;
+ gen_tbl_ent->byte_data = &tbl_list->container.byte_data[key *
+ gen_tbl_ent->byte_data_size];
+ gen_tbl_ent->byte_order = tbl_list->container.byte_order;
+ break;
+ default:
+ BNXT_TF_DBG(ERR, "%s: invalid search flag\n",
+ tbl_list->gen_tbl_name);
+ return -EINVAL;
+ }
+
+ return rc;
+}