+
+/*
+ * Get a Mark from the Mark Manager
+ *
+ * ctxt [in] The ulp context for the mark manager
+ *
+ * is_gfid [in] The type of fid (GFID or LFID)
+ *
+ * fid [in] The flow id that is returned by HW in BD
+ *
+ * vfr_flag [out].it indicatesif mark is vfr_id or mark id
+ *
+ * mark [out] The mark that is associated with the FID
+ *
+ */
+int32_t
+ulp_mark_db_mark_get(struct bnxt_ulp_context *ctxt,
+ bool is_gfid,
+ uint32_t fid,
+ uint32_t *vfr_flag,
+ uint32_t *mark)
+{
+ struct bnxt_ulp_mark_tbl *mtbl;
+ uint32_t idx = 0;
+
+ if (!ctxt || !mark)
+ return -EINVAL;
+
+ mtbl = bnxt_ulp_cntxt_ptr2_mark_db_get(ctxt);
+ if (!mtbl)
+ return -EINVAL;
+
+ idx = ulp_mark_db_idx_get(is_gfid, fid, mtbl);
+
+ if (is_gfid) {
+ if (idx >= mtbl->gfid_num_entries ||
+ ULP_MARK_DB_ENTRY_IS_INVALID(&mtbl->gfid_tbl[idx]))
+ return -EINVAL;
+
+ *vfr_flag = ULP_MARK_DB_ENTRY_IS_VFR_ID(&mtbl->gfid_tbl[idx]);
+ *mark = mtbl->gfid_tbl[idx].mark_id;
+ } else {
+ if (idx >= mtbl->lfid_num_entries ||
+ ULP_MARK_DB_ENTRY_IS_INVALID(&mtbl->lfid_tbl[idx]))
+ return -EINVAL;
+
+ *vfr_flag = ULP_MARK_DB_ENTRY_IS_VFR_ID(&mtbl->lfid_tbl[idx]);
+ *mark = mtbl->lfid_tbl[idx].mark_id;
+ }
+
+ return 0;
+}
+
+/*
+ * Adds a Mark to the Mark Manager
+ *
+ * ctxt [in] The ulp context for the mark manager
+ *
+ * mark_flag [in] mark flags.
+ *
+ * fid [in] The flow id that is returned by HW in BD
+ *
+ * mark [in] The mark to be associated with the FID
+ *
+ */
+int32_t
+ulp_mark_db_mark_add(struct bnxt_ulp_context *ctxt,
+ uint32_t mark_flag,
+ uint32_t fid,
+ uint32_t mark)
+{
+ struct bnxt_ulp_mark_tbl *mtbl;
+ uint32_t idx = 0;
+ bool is_gfid;
+
+ if (!ctxt) {
+ BNXT_TF_DBG(ERR, "Invalid ulp context\n");
+ return -EINVAL;
+ }
+
+ mtbl = bnxt_ulp_cntxt_ptr2_mark_db_get(ctxt);
+ if (!mtbl) {
+ BNXT_TF_DBG(ERR, "Unable to get Mark DB\n");
+ return -EINVAL;
+ }
+
+ is_gfid = (mark_flag & BNXT_ULP_MARK_GLOBAL_HW_FID);
+ if (is_gfid) {
+ idx = ulp_mark_db_idx_get(is_gfid, fid, mtbl);
+ if (idx >= mtbl->gfid_num_entries) {
+ BNXT_TF_DBG(ERR, "Mark index greater than allocated\n");
+ return -EINVAL;
+ }
+ BNXT_TF_DBG(DEBUG, "Set GFID[0x%0x] = 0x%0x\n", idx, mark);
+ mtbl->gfid_tbl[idx].mark_id = mark;
+ ULP_MARK_DB_ENTRY_SET_VALID(&mtbl->gfid_tbl[idx]);
+
+ } else {
+ /* For the LFID, the FID is used as the index */
+ if (fid >= mtbl->lfid_num_entries) {
+ BNXT_TF_DBG(ERR, "Mark index greater than allocated\n");
+ return -EINVAL;
+ }
+ BNXT_TF_DBG(DEBUG, "Set LFID[0x%0x] = 0x%0x\n", fid, mark);
+ mtbl->lfid_tbl[fid].mark_id = mark;
+ ULP_MARK_DB_ENTRY_SET_VALID(&mtbl->lfid_tbl[fid]);
+
+ if (mark_flag & BNXT_ULP_MARK_VFR_ID)
+ ULP_MARK_DB_ENTRY_SET_VFR_ID(&mtbl->lfid_tbl[fid]);
+ }
+
+ return 0;
+}
+
+/*
+ * Removes a Mark from the Mark Manager
+ *
+ * ctxt [in] The ulp context for the mark manager
+ *
+ * mark_flag [in] mark flags.
+ *
+ * fid [in] The flow id that is returned by HW in BD
+ *
+ */
+int32_t
+ulp_mark_db_mark_del(struct bnxt_ulp_context *ctxt,
+ uint32_t mark_flag,
+ uint32_t fid)
+{
+ struct bnxt_ulp_mark_tbl *mtbl;
+ uint32_t idx = 0;
+ bool is_gfid;
+
+ if (!ctxt) {
+ BNXT_TF_DBG(ERR, "Invalid ulp context\n");
+ return -EINVAL;
+ }
+
+ mtbl = bnxt_ulp_cntxt_ptr2_mark_db_get(ctxt);
+ if (!mtbl) {
+ BNXT_TF_DBG(ERR, "Unable to get Mark DB\n");
+ return -EINVAL;
+ }
+
+ is_gfid = (mark_flag & BNXT_ULP_MARK_GLOBAL_HW_FID);
+ if (is_gfid) {
+ idx = ulp_mark_db_idx_get(is_gfid, fid, mtbl);
+ if (idx >= mtbl->gfid_num_entries) {
+ BNXT_TF_DBG(ERR, "Mark index greater than allocated\n");
+ return -EINVAL;
+ }
+ BNXT_TF_DBG(DEBUG, "Reset GFID[0x%0x]\n", idx);
+ memset(&mtbl->gfid_tbl[idx], 0,
+ sizeof(struct bnxt_gfid_mark_info));
+
+ } else {
+ /* For the LFID, the FID is used as the index */
+ if (fid >= mtbl->lfid_num_entries) {
+ BNXT_TF_DBG(ERR, "Mark index greater than allocated\n");
+ return -EINVAL;
+ }
+ memset(&mtbl->lfid_tbl[fid], 0,
+ sizeof(struct bnxt_lfid_mark_info));
+ }
+
+ return 0;
+}