From patchwork Thu Jul 2 04:10:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajit Khaparde X-Patchwork-Id: 72728 X-Patchwork-Delegate: ajit.khaparde@broadcom.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9262DA0523; Thu, 2 Jul 2020 06:12:59 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 853AA1C1A6; Thu, 2 Jul 2020 06:11:56 +0200 (CEST) Received: from rnd-relay.smtp.broadcom.com (rnd-relay.smtp.broadcom.com [192.19.229.170]) by dpdk.org (Postfix) with ESMTP id 0DF0B1C0CD for ; Thu, 2 Jul 2020 06:11:40 +0200 (CEST) Received: from mail-irv-17.broadcom.com (mail-irv-17.lvn.broadcom.net [10.75.242.48]) by rnd-relay.smtp.broadcom.com (Postfix) with ESMTP id C97E330C0D2; Wed, 1 Jul 2020 21:11:38 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.10.3 rnd-relay.smtp.broadcom.com C97E330C0D2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1593663098; bh=8NtVhN3FWmlmAuafRZcQf2jR4TZBh7iz7djKqJs1+g8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FJ2bU9x9AjQSbXEqgclQ+5dbbOoR/Va5Sxb8OhAXZHUnLFQKSR4nFzDAt6+GVu3u9 NsBNd9SA4aoUzkn4ZD0RTd66qEHp0nwspEMan7Y7+b7/8wTgSwwlCvqiiI8EzXFBRK zNPeLVidx0fYFBupHpACO6JC9Afj35u7y4v6dXxQ= Received: from localhost.localdomain (unknown [10.230.185.215]) by mail-irv-17.broadcom.com (Postfix) with ESMTP id 474C014008B; Wed, 1 Jul 2020 21:11:38 -0700 (PDT) From: Ajit Khaparde To: dev@dpdk.org Cc: Venkat Duvvuru , Somnath Kotur , Kishore Padmanabha Date: Wed, 1 Jul 2020 21:10:51 -0700 Message-Id: <20200702041134.43198-9-ajit.khaparde@broadcom.com> X-Mailer: git-send-email 2.21.1 (Apple Git-122.3) In-Reply-To: <20200702041134.43198-1-ajit.khaparde@broadcom.com> References: <1f5421dc-0453-6dc8-09c2-ddfff6eb4888@intel.com> <20200702041134.43198-1-ajit.khaparde@broadcom.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v3 08/51] net/bnxt: modify port db to handle more info X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Venkat Duvvuru Apart from func_svif, func_id & vnic, port_db now stores and retrieves func_spif, func_parif, phy_port_id, port_svif, port_spif, port_parif, port_vport. New helper functions have been added to support the same. Signed-off-by: Venkat Duvvuru Reviewed-by: Somnath Kotur Reviewed-by: Kishore Padmanabha Reviewed-by: Ajit Khaparde --- drivers/net/bnxt/tf_ulp/ulp_port_db.c | 145 +++++++++++++++++++++----- drivers/net/bnxt/tf_ulp/ulp_port_db.h | 72 ++++++++++--- 2 files changed, 179 insertions(+), 38 deletions(-) diff --git a/drivers/net/bnxt/tf_ulp/ulp_port_db.c b/drivers/net/bnxt/tf_ulp/ulp_port_db.c index 66b584026..ea27ef41f 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_port_db.c +++ b/drivers/net/bnxt/tf_ulp/ulp_port_db.c @@ -106,13 +106,12 @@ int32_t ulp_port_db_deinit(struct bnxt_ulp_context *ulp_ctxt) int32_t ulp_port_db_dev_port_intf_update(struct bnxt_ulp_context *ulp_ctxt, struct rte_eth_dev *eth_dev) { - struct bnxt_ulp_port_db *port_db; - struct bnxt *bp = eth_dev->data->dev_private; uint32_t port_id = eth_dev->data->port_id; - uint32_t ifindex; + struct ulp_phy_port_info *port_data; + struct bnxt_ulp_port_db *port_db; struct ulp_interface_info *intf; + uint32_t ifindex; int32_t rc; - struct bnxt_vnic_info *vnic; port_db = bnxt_ulp_cntxt_ptr2_port_db_get(ulp_ctxt); if (!port_db) { @@ -133,22 +132,22 @@ int32_t ulp_port_db_dev_port_intf_update(struct bnxt_ulp_context *ulp_ctxt, /* update the interface details */ intf = &port_db->ulp_intf_list[ifindex]; - if (BNXT_PF(bp) || BNXT_VF(bp)) { - if (BNXT_PF(bp)) { - intf->type = BNXT_ULP_INTF_TYPE_PF; - intf->port_svif = bp->port_svif; - } else { - intf->type = BNXT_ULP_INTF_TYPE_VF; - } - intf->func_id = bp->fw_fid; - intf->func_svif = bp->func_svif; - vnic = BNXT_GET_DEFAULT_VNIC(bp); - if (vnic) - intf->default_vnic = vnic->fw_vnic_id; - intf->bp = bp; - memcpy(intf->mac_addr, bp->mac_addr, sizeof(intf->mac_addr)); - } else { - BNXT_TF_DBG(ERR, "Invalid interface type\n"); + + intf->type = bnxt_get_interface_type(port_id); + + intf->func_id = bnxt_get_fw_func_id(port_id); + intf->func_svif = bnxt_get_svif(port_id, 1); + intf->func_spif = bnxt_get_phy_port_id(port_id); + intf->func_parif = bnxt_get_parif(port_id); + intf->default_vnic = bnxt_get_vnic_id(port_id); + intf->phy_port_id = bnxt_get_phy_port_id(port_id); + + if (intf->type == BNXT_ULP_INTF_TYPE_PF) { + port_data = &port_db->phy_port_list[intf->phy_port_id]; + port_data->port_svif = bnxt_get_svif(port_id, 0); + port_data->port_spif = bnxt_get_phy_port_id(port_id); + port_data->port_parif = bnxt_get_parif(port_id); + port_data->port_vport = bnxt_get_vport(port_id); } return 0; @@ -209,7 +208,7 @@ ulp_port_db_function_id_get(struct bnxt_ulp_context *ulp_ctxt, } /* - * Api to get the svid for a given ulp ifindex. + * Api to get the svif for a given ulp ifindex. * * ulp_ctxt [in] Ptr to ulp context * ifindex [in] ulp ifindex @@ -225,16 +224,88 @@ ulp_port_db_svif_get(struct bnxt_ulp_context *ulp_ctxt, uint16_t *svif) { struct bnxt_ulp_port_db *port_db; + uint16_t phy_port_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 (dir == ULP_DIR_EGRESS) + if (dir == ULP_DIR_EGRESS) { *svif = port_db->ulp_intf_list[ifindex].func_svif; - else - *svif = port_db->ulp_intf_list[ifindex].port_svif; + } else { + phy_port_id = port_db->ulp_intf_list[ifindex].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 + * dir [in] the direction for the flow. + * 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 dir, + uint16_t *spif) +{ + struct bnxt_ulp_port_db *port_db; + uint16_t phy_port_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 (dir == ULP_DIR_EGRESS) { + *spif = port_db->ulp_intf_list[ifindex].func_spif; + } else { + phy_port_id = port_db->ulp_intf_list[ifindex].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 + * dir [in] the direction for the flow. + * 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 dir, + uint16_t *parif) +{ + struct bnxt_ulp_port_db *port_db; + uint16_t phy_port_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 (dir == ULP_DIR_EGRESS) { + *parif = port_db->ulp_intf_list[ifindex].func_parif; + } else { + phy_port_id = port_db->ulp_intf_list[ifindex].phy_port_id; + *parif = port_db->phy_port_list[phy_port_id].port_parif; + } + return 0; } @@ -262,3 +333,29 @@ ulp_port_db_default_vnic_get(struct bnxt_ulp_context *ulp_ctxt, *vnic = port_db->ulp_intf_list[ifindex].default_vnic; return 0; } + +/* + * Api to get the vport id for a given ulp ifindex. + * + * ulp_ctxt [in] Ptr to ulp context + * ifindex [in] ulp ifindex + * vport [out] the port of the given ifindex. + * + * Returns 0 on success or negative number on failure. + */ +int32_t +ulp_port_db_vport_get(struct bnxt_ulp_context *ulp_ctxt, + uint32_t ifindex, uint16_t *vport) +{ + struct bnxt_ulp_port_db *port_db; + uint16_t phy_port_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; + } + phy_port_id = port_db->ulp_intf_list[ifindex].phy_port_id; + *vport = port_db->phy_port_list[phy_port_id].port_vport; + return 0; +} diff --git a/drivers/net/bnxt/tf_ulp/ulp_port_db.h b/drivers/net/bnxt/tf_ulp/ulp_port_db.h index 604c4385a..87de3bcbc 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_port_db.h +++ b/drivers/net/bnxt/tf_ulp/ulp_port_db.h @@ -15,11 +15,17 @@ struct ulp_interface_info { enum bnxt_ulp_intf_type type; uint16_t func_id; uint16_t func_svif; - uint16_t port_svif; + uint16_t func_spif; + uint16_t func_parif; uint16_t default_vnic; - uint8_t mac_addr[RTE_ETHER_ADDR_LEN]; - /* back pointer to the bnxt driver, it is null for rep ports */ - struct bnxt *bp; + uint16_t phy_port_id; +}; + +struct ulp_phy_port_info { + uint16_t port_svif; + uint16_t port_spif; + uint16_t port_parif; + uint16_t port_vport; }; /* Structure for the Port database */ @@ -29,6 +35,7 @@ struct bnxt_ulp_port_db { /* dpdk device external port list */ uint16_t dev_port_list[RTE_MAX_ETHPORTS]; + struct ulp_phy_port_info phy_port_list[RTE_MAX_ETHPORTS]; }; /* @@ -74,8 +81,7 @@ int32_t ulp_port_db_dev_port_intf_update(struct bnxt_ulp_context *ulp_ctxt, */ int32_t ulp_port_db_dev_port_to_ulp_index(struct bnxt_ulp_context *ulp_ctxt, - uint32_t port_id, - uint32_t *ifindex); + uint32_t port_id, uint32_t *ifindex); /* * Api to get the function id for a given ulp ifindex. @@ -88,11 +94,10 @@ ulp_port_db_dev_port_to_ulp_index(struct bnxt_ulp_context *ulp_ctxt, */ int32_t ulp_port_db_function_id_get(struct bnxt_ulp_context *ulp_ctxt, - uint32_t ifindex, - uint16_t *func_id); + uint32_t ifindex, uint16_t *func_id); /* - * Api to get the svid for a given ulp ifindex. + * Api to get the svif for a given ulp ifindex. * * ulp_ctxt [in] Ptr to ulp context * ifindex [in] ulp ifindex @@ -103,9 +108,36 @@ ulp_port_db_function_id_get(struct bnxt_ulp_context *ulp_ctxt, */ int32_t ulp_port_db_svif_get(struct bnxt_ulp_context *ulp_ctxt, - uint32_t ifindex, - uint32_t dir, - uint16_t *svif); + uint32_t ifindex, uint32_t dir, uint16_t *svif); + +/* + * Api to get the spif for a given ulp ifindex. + * + * ulp_ctxt [in] Ptr to ulp context + * ifindex [in] ulp ifindex + * dir [in] the direction for the flow. + * 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 dir, uint16_t *spif); + + +/* + * Api to get the parif for a given ulp ifindex. + * + * ulp_ctxt [in] Ptr to ulp context + * ifindex [in] ulp ifindex + * dir [in] the direction for the flow. + * 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 dir, uint16_t *parif); /* * Api to get the vnic id for a given ulp ifindex. @@ -118,7 +150,19 @@ ulp_port_db_svif_get(struct bnxt_ulp_context *ulp_ctxt, */ int32_t ulp_port_db_default_vnic_get(struct bnxt_ulp_context *ulp_ctxt, - uint32_t ifindex, - uint16_t *vnic); + uint32_t ifindex, uint16_t *vnic); + +/* + * Api to get the vport id for a given ulp ifindex. + * + * ulp_ctxt [in] Ptr to ulp context + * ifindex [in] ulp ifindex + * vport [out] the port of the given ifindex. + * + * Returns 0 on success or negative number on failure. + */ +int32_t +ulp_port_db_vport_get(struct bnxt_ulp_context *ulp_ctxt, + uint32_t ifindex, uint16_t *vport); #endif /* _ULP_PORT_DB_H_ */