[v2,21/25] net/bnxt: provide switch info if VFR are configured
diff mbox series

Message ID 20200916042851.32914-22-ajit.khaparde@broadcom.com
State Accepted
Delegated to: Ajit Khaparde
Headers show
Series
  • patchset for bnxt
Related show

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Ajit Khaparde Sept. 16, 2020, 4:28 a.m. UTC
From: Sriharsha Basavapatna <sriharsha.basavapatna@broadcom.com>

Some applications need switch_info of the device to be returned
as a part of eth_dev_info_get(). The offload logic in such
applications could use this info. Pass this info to the when VF
representors are configured.

Fixes: 322bd6e70272 ("net/bnxt: add port representor infrastructure")

Signed-off-by: Sriharsha Basavapatna <sriharsha.basavapatna@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
 drivers/net/bnxt/bnxt_ethdev.c | 8 ++++++++
 drivers/net/bnxt/bnxt_reps.c   | 5 +++++
 drivers/net/bnxt/bnxt_reps.h   | 7 +++++++
 3 files changed, 20 insertions(+)

Patch
diff mbox series

diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index 2a106fe7a..7c27e2435 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -908,6 +908,14 @@  static int bnxt_dev_info_get_op(struct rte_eth_dev *eth_dev,
 	dev_info->tx_desc_lim.nb_min = BNXT_MIN_RING_DESC;
 	dev_info->tx_desc_lim.nb_max = BNXT_MAX_TX_RING_DESC;
 
+	if (BNXT_PF(bp) || BNXT_VF_IS_TRUSTED(bp)) {
+		dev_info->switch_info.name = eth_dev->device->name;
+		dev_info->switch_info.domain_id = bp->switch_domain_id;
+		dev_info->switch_info.port_id =
+				BNXT_PF(bp) ? BNXT_SWITCH_PORT_ID_PF :
+				    BNXT_SWITCH_PORT_ID_TRUSTED_VF;
+	}
+
 	/* *INDENT-ON* */
 
 	/*
diff --git a/drivers/net/bnxt/bnxt_reps.c b/drivers/net/bnxt/bnxt_reps.c
index ef5bd0665..7350c0967 100644
--- a/drivers/net/bnxt/bnxt_reps.c
+++ b/drivers/net/bnxt/bnxt_reps.c
@@ -500,6 +500,11 @@  int bnxt_vf_rep_dev_info_get_op(struct rte_eth_dev *eth_dev,
 	dev_info->tx_offload_capa = BNXT_DEV_TX_OFFLOAD_SUPPORT;
 	dev_info->flow_type_rss_offloads = BNXT_ETH_RSS_SUPPORT;
 
+	dev_info->switch_info.name = eth_dev->device->name;
+	dev_info->switch_info.domain_id = rep_bp->switch_domain_id;
+	dev_info->switch_info.port_id =
+			rep_bp->vf_id & BNXT_SWITCH_PORT_ID_VF_MASK;
+
 	return 0;
 }
 
diff --git a/drivers/net/bnxt/bnxt_reps.h b/drivers/net/bnxt/bnxt_reps.h
index d877b0823..3239e03fc 100644
--- a/drivers/net/bnxt/bnxt_reps.h
+++ b/drivers/net/bnxt/bnxt_reps.h
@@ -12,6 +12,13 @@ 
 #define BNXT_MAX_CFA_CODE               65536
 #define BNXT_VF_IDX_INVALID             0xffff
 
+/* Switchdev Port ID Mapping (Per switch domain id).
+ * Lower 15 bits map the VFs (VF_ID). Upper bit maps the PF.
+ */
+#define	BNXT_SWITCH_PORT_ID_PF		0x8000
+#define	BNXT_SWITCH_PORT_ID_TRUSTED_VF	0x0
+#define BNXT_SWITCH_PORT_ID_VF_MASK	0x7FFF
+
 uint16_t
 bnxt_vfr_recv(uint16_t port_id, uint16_t queue_id, struct rte_mbuf *mbuf);
 int bnxt_vf_representor_init(struct rte_eth_dev *eth_dev, void *params);