+
+ if (svif_type == BNXT_ULP_DRV_FUNC_SVIF) {
+ func_id = port_db->ulp_intf_list[ifindex].drv_func_id;
+ *svif = port_db->ulp_func_id_tbl[func_id].func_svif;
+ } else if (svif_type == BNXT_ULP_VF_FUNC_SVIF) {
+ func_id = port_db->ulp_intf_list[ifindex].vf_func_id;
+ *svif = port_db->ulp_func_id_tbl[func_id].func_svif;
+ } else {
+ func_id = port_db->ulp_intf_list[ifindex].drv_func_id;
+ phy_port_id = port_db->ulp_func_id_tbl[func_id].phy_port_id;
+ *svif = port_db->phy_port_list[phy_port_id].port_svif;
+ }
+
+ return 0;
+}
+
+/*
+ * Api to get the spif for a given ulp ifindex.
+ *
+ * ulp_ctxt [in] Ptr to ulp context
+ * ifindex [in] ulp ifindex
+ * spif_type [in] the spif type of the given ifindex.
+ * spif [out] the spif of the given ifindex.
+ *
+ * Returns 0 on success or negative number on failure.
+ */
+int32_t
+ulp_port_db_spif_get(struct bnxt_ulp_context *ulp_ctxt,
+ uint32_t ifindex,
+ uint32_t spif_type,
+ uint16_t *spif)
+{
+ struct bnxt_ulp_port_db *port_db;
+ uint16_t phy_port_id, func_id;
+
+ port_db = bnxt_ulp_cntxt_ptr2_port_db_get(ulp_ctxt);
+ if (!port_db || ifindex >= port_db->ulp_intf_list_size || !ifindex) {
+ BNXT_TF_DBG(ERR, "Invalid Arguments\n");
+ return -EINVAL;
+ }
+
+ if (spif_type == BNXT_ULP_DRV_FUNC_SPIF) {
+ func_id = port_db->ulp_intf_list[ifindex].drv_func_id;
+ *spif = port_db->ulp_func_id_tbl[func_id].func_spif;
+ } else if (spif_type == BNXT_ULP_VF_FUNC_SPIF) {
+ func_id = port_db->ulp_intf_list[ifindex].vf_func_id;
+ *spif = port_db->ulp_func_id_tbl[func_id].func_spif;
+ } else {
+ func_id = port_db->ulp_intf_list[ifindex].drv_func_id;
+ phy_port_id = port_db->ulp_func_id_tbl[func_id].phy_port_id;
+ *spif = port_db->phy_port_list[phy_port_id].port_spif;
+ }
+
+ return 0;
+}
+
+/*
+ * Api to get the parif for a given ulp ifindex.
+ *
+ * ulp_ctxt [in] Ptr to ulp context
+ * ifindex [in] ulp ifindex
+ * parif_type [in] the parif type of the given ifindex.
+ * parif [out] the parif of the given ifindex.
+ *
+ * Returns 0 on success or negative number on failure.
+ */
+int32_t
+ulp_port_db_parif_get(struct bnxt_ulp_context *ulp_ctxt,
+ uint32_t ifindex,
+ uint32_t parif_type,
+ uint16_t *parif)
+{
+ struct bnxt_ulp_port_db *port_db;
+ uint16_t phy_port_id, func_id;
+
+ port_db = bnxt_ulp_cntxt_ptr2_port_db_get(ulp_ctxt);
+ if (!port_db || ifindex >= port_db->ulp_intf_list_size || !ifindex) {
+ BNXT_TF_DBG(ERR, "Invalid Arguments\n");
+ return -EINVAL;
+ }
+ if (parif_type == BNXT_ULP_DRV_FUNC_PARIF) {
+ func_id = port_db->ulp_intf_list[ifindex].drv_func_id;
+ *parif = port_db->ulp_func_id_tbl[func_id].func_parif;
+ } else if (parif_type == BNXT_ULP_VF_FUNC_PARIF) {
+ func_id = port_db->ulp_intf_list[ifindex].vf_func_id;
+ *parif = port_db->ulp_func_id_tbl[func_id].func_parif;
+ } else {
+ func_id = port_db->ulp_intf_list[ifindex].drv_func_id;
+ phy_port_id = port_db->ulp_func_id_tbl[func_id].phy_port_id;
+ *parif = port_db->phy_port_list[phy_port_id].port_parif;
+ }
+ /* Parif needs to be reset to a free partition */
+ *parif += BNXT_ULP_FREE_PARIF_BASE;
+