+
+/*
+ * Api to get the function id for a given port id.
+ *
+ * ulp_ctxt [in] Ptr to ulp context
+ * port_id [in] dpdk port id
+ * func_id [out] the function id of the given ifindex.
+ *
+ * Returns 0 on success or negative number on failure.
+ */
+int32_t
+ulp_port_db_port_func_id_get(struct bnxt_ulp_context *ulp_ctxt,
+ uint16_t port_id, uint16_t *func_id)
+{
+ struct bnxt_ulp_port_db *port_db;
+ uint32_t ifindex;
+
+ port_db = bnxt_ulp_cntxt_ptr2_port_db_get(ulp_ctxt);
+ if (!port_db || port_id >= RTE_MAX_ETHPORTS) {
+ BNXT_TF_DBG(ERR, "Invalid Arguments\n");
+ return -EINVAL;
+ }
+ ifindex = port_db->dev_port_list[port_id];
+ if (!ifindex)
+ return -ENOENT;
+
+ switch (port_db->ulp_intf_list[ifindex].type) {
+ case BNXT_ULP_INTF_TYPE_TRUSTED_VF:
+ case BNXT_ULP_INTF_TYPE_PF:
+ *func_id = port_db->ulp_intf_list[ifindex].drv_func_id;
+ break;
+ case BNXT_ULP_INTF_TYPE_VF:
+ case BNXT_ULP_INTF_TYPE_VF_REP:
+ *func_id = port_db->ulp_intf_list[ifindex].vf_func_id;
+ break;
+ default:
+ *func_id = 0;
+ break;
+ }
+ return 0;
+}