net/bnxt: mute some failure logs
[dpdk.git] / drivers / net / bnxt / tf_ulp / ulp_port_db.c
index 3c5a218..a11e678 100644 (file)
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2014-2020 Broadcom
+ * Copyright(c) 2014-2021 Broadcom
  * All rights reserved.
  */
 
@@ -162,6 +162,7 @@ int32_t     ulp_port_db_dev_port_intf_update(struct bnxt_ulp_context *ulp_ctxt,
                        bnxt_get_vnic_id(port_id, BNXT_ULP_INTF_TYPE_INVALID);
                func->phy_port_id = bnxt_get_phy_port_id(port_id);
                func->func_valid = true;
+               func->ifindex = ifindex;
        }
 
        if (intf->type == BNXT_ULP_INTF_TYPE_VF_REP) {
@@ -178,6 +179,7 @@ int32_t     ulp_port_db_dev_port_intf_update(struct bnxt_ulp_context *ulp_ctxt,
                func->func_vnic =
                        bnxt_get_vnic_id(port_id, BNXT_ULP_INTF_TYPE_VF_REP);
                func->phy_port_id = bnxt_get_phy_port_id(port_id);
+               func->ifindex = ifindex;
        }
 
        port_data = &port_db->phy_port_list[func->phy_port_id];
@@ -370,6 +372,8 @@ ulp_port_db_parif_get(struct bnxt_ulp_context *ulp_ctxt,
                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;
 
        return 0;
 }
@@ -461,3 +465,119 @@ ulp_port_db_phy_port_vport_get(struct bnxt_ulp_context *ulp_ctxt,
        *out_port = port_db->phy_port_list[phy_port].port_vport;
        return 0;
 }
+
+/*
+ * Api to get the svif for a given physical port.
+ *
+ * ulp_ctxt [in] Ptr to ulp context
+ * phy_port [in] physical port index
+ * svif [out] the svif of the given physical index
+ *
+ * Returns 0 on success or negative number on failure.
+ */
+int32_t
+ulp_port_db_phy_port_svif_get(struct bnxt_ulp_context *ulp_ctxt,
+                             uint32_t phy_port,
+                             uint16_t *svif)
+{
+       struct bnxt_ulp_port_db *port_db;
+
+       port_db = bnxt_ulp_cntxt_ptr2_port_db_get(ulp_ctxt);
+       if (!port_db || phy_port >= port_db->phy_port_cnt) {
+               BNXT_TF_DBG(ERR, "Invalid Arguments\n");
+               return -EINVAL;
+       }
+       *svif = port_db->phy_port_list[phy_port].port_svif;
+       return 0;
+}
+
+/*
+ * Api to get the port type for a given ulp ifindex.
+ *
+ * ulp_ctxt [in] Ptr to ulp context
+ * ifindex [in] ulp ifindex
+ *
+ * Returns port type.
+ */
+enum bnxt_ulp_intf_type
+ulp_port_db_port_type_get(struct bnxt_ulp_context *ulp_ctxt,
+                         uint32_t ifindex)
+{
+       struct bnxt_ulp_port_db *port_db;
+
+       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 BNXT_ULP_INTF_TYPE_INVALID;
+       }
+       return port_db->ulp_intf_list[ifindex].type;
+}
+
+/*
+ * Api to get the ulp ifindex for a given function id.
+ *
+ * ulp_ctxt [in] Ptr to ulp context
+ * func_id [in].device func id
+ * ifindex [out] ulp ifindex
+ *
+ * Returns 0 on success or negative number on failure.
+ */
+int32_t
+ulp_port_db_dev_func_id_to_ulp_index(struct bnxt_ulp_context *ulp_ctxt,
+                                    uint32_t func_id, uint32_t *ifindex)
+{
+       struct bnxt_ulp_port_db *port_db;
+
+       *ifindex = 0;
+       port_db = bnxt_ulp_cntxt_ptr2_port_db_get(ulp_ctxt);
+       if (!port_db || func_id >= BNXT_PORT_DB_MAX_FUNC) {
+               BNXT_TF_DBG(ERR, "Invalid Arguments\n");
+               return -EINVAL;
+       }
+       if (!port_db->ulp_func_id_tbl[func_id].func_valid)
+               return -ENOENT;
+
+       *ifindex = port_db->ulp_func_id_tbl[func_id].ifindex;
+       return 0;
+}
+
+/*
+ * 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;
+}