DPDK patches and discussions
 help / color / mirror / Atom feed
From: beilei.xing@intel.com
To: jingjing.wu@intel.com, mingxia.liu@intel.com
Cc: dev@dpdk.org, Beilei Xing <beilei.xing@intel.com>
Subject: [PATCH 11/19] net/cpfl: add exceptional vport
Date: Wed,  9 Aug 2023 15:51:26 +0000	[thread overview]
Message-ID: <20230809155134.539287-12-beilei.xing@intel.com> (raw)
In-Reply-To: <20230809155134.539287-1-beilei.xing@intel.com>

From: Beilei Xing <beilei.xing@intel.com>

This patch creates exceptional vport when there's port representor.

Signed-off-by: Beilei Xing <beilei.xing@intel.com>
---
 drivers/net/cpfl/cpfl_ethdev.c | 107 ++++++++++++++++++++++++++++++---
 drivers/net/cpfl/cpfl_ethdev.h |   8 +++
 drivers/net/cpfl/cpfl_rxtx.c   |  16 +++++
 drivers/net/cpfl/cpfl_rxtx.h   |   7 +++
 4 files changed, 131 insertions(+), 7 deletions(-)

diff --git a/drivers/net/cpfl/cpfl_ethdev.c b/drivers/net/cpfl/cpfl_ethdev.c
index 88c1479f3a..f674d93050 100644
--- a/drivers/net/cpfl/cpfl_ethdev.c
+++ b/drivers/net/cpfl/cpfl_ethdev.c
@@ -1023,8 +1023,13 @@ cpfl_dev_start(struct rte_eth_dev *dev)
 		goto err_startq;
 	}
 
-	cpfl_set_rx_function(dev);
-	cpfl_set_tx_function(dev);
+	if (cpfl_vport->exceptional) {
+		dev->rx_pkt_burst = cpfl_dummy_recv_pkts;
+		dev->tx_pkt_burst = cpfl_dummy_xmit_pkts;
+	} else {
+		cpfl_set_rx_function(dev);
+		cpfl_set_tx_function(dev);
+	}
 
 	ret = idpf_vc_vport_ena_dis(vport, true);
 	if (ret != 0) {
@@ -1098,13 +1103,15 @@ cpfl_dev_close(struct rte_eth_dev *dev)
 	if (!adapter->base.is_rx_singleq && !adapter->base.is_tx_singleq)
 		cpfl_p2p_queue_grps_del(vport);
 
+	if (!cpfl_vport->exceptional) {
+		adapter->cur_vports &= ~RTE_BIT32(vport->devarg_id);
+		adapter->cur_vport_nb--;
+		adapter->vports[vport->sw_idx] = NULL;
+	}
+
 	idpf_vport_deinit(vport);
 	rte_free(cpfl_vport->p2p_q_chunks_info);
-
-	adapter->cur_vports &= ~RTE_BIT32(vport->devarg_id);
-	adapter->cur_vport_nb--;
 	dev->data->dev_private = NULL;
-	adapter->vports[vport->sw_idx] = NULL;
 	rte_free(cpfl_vport);
 
 	return 0;
@@ -1621,6 +1628,11 @@ cpfl_handle_vchnl_event_msg(struct cpfl_adapter_ext *adapter, uint8_t *msg, uint
 		return;
 	}
 
+	/* ignore if it is exceptional vport */
+	if (adapter->exceptional_vport &&
+	    adapter->exceptional_vport->base.vport_id == vc_event->vport_id)
+		return;
+
 	vport = cpfl_find_vport(adapter, vc_event->vport_id);
 	if (!vport) {
 		PMD_DRV_LOG(ERR, "Can't find vport.");
@@ -2192,6 +2204,56 @@ cpfl_dev_vport_init(struct rte_eth_dev *dev, void *init_params)
 	return ret;
 }
 
+static int
+cpfl_exceptional_vport_init(struct rte_eth_dev *dev, void *init_params)
+{
+	struct cpfl_vport *cpfl_vport = CPFL_DEV_TO_VPORT(dev);
+	struct idpf_vport *vport = &cpfl_vport->base;
+	struct cpfl_adapter_ext *adapter = init_params;
+	/* for sending create vport virtchnl msg prepare */
+	struct virtchnl2_create_vport create_vport_info;
+	int ret = 0;
+
+	dev->dev_ops = &cpfl_eth_dev_ops;
+	vport->adapter = &adapter->base;
+
+	memset(&create_vport_info, 0, sizeof(create_vport_info));
+	ret = idpf_vport_info_init(vport, &create_vport_info);
+	if (ret != 0) {
+		PMD_INIT_LOG(ERR, "Failed to init exceptional vport req_info.");
+		goto err;
+	}
+
+	ret = idpf_vport_init(vport, &create_vport_info, dev->data);
+	if (ret != 0) {
+		PMD_INIT_LOG(ERR, "Failed to init exceptional vport.");
+		goto err;
+	}
+
+	cpfl_vport->itf.adapter = adapter;
+	cpfl_vport->itf.data = dev->data;
+	cpfl_vport->exceptional = TRUE;
+
+	dev->data->mac_addrs = rte_zmalloc(NULL, RTE_ETHER_ADDR_LEN, 0);
+	if (dev->data->mac_addrs == NULL) {
+		PMD_INIT_LOG(ERR, "Cannot allocate mac_addr for exceptional vport.");
+		ret = -ENOMEM;
+		goto err_mac_addrs;
+	}
+
+	rte_ether_addr_copy((struct rte_ether_addr *)vport->default_mac_addr,
+			    &dev->data->mac_addrs[0]);
+
+	adapter->exceptional_vport = cpfl_vport;
+
+	return 0;
+
+err_mac_addrs:
+	idpf_vport_deinit(vport);
+err:
+	return ret;
+}
+
 static const struct rte_pci_id pci_id_cpfl_map[] = {
 	{ RTE_PCI_DEVICE(IDPF_INTEL_VENDOR_ID, IDPF_DEV_ID_CPF) },
 	{ .vendor_id = 0, /* sentinel */ },
@@ -2299,6 +2361,23 @@ cpfl_vport_create(struct rte_pci_device *pci_dev, struct cpfl_adapter_ext *adapt
 	return 0;
 }
 
+static int
+cpfl_exceptional_vport_create(struct rte_pci_device *pci_dev, struct cpfl_adapter_ext *adapter)
+{
+	char name[RTE_ETH_NAME_MAX_LEN];
+	int ret;
+
+	snprintf(name, sizeof(name), "cpfl_%s_exceptional_vport", pci_dev->name);
+	ret = rte_eth_dev_create(&pci_dev->device, name,
+				 sizeof(struct cpfl_vport),
+				 NULL, NULL, cpfl_exceptional_vport_init,
+				 adapter);
+	if (ret != 0)
+		PMD_DRV_LOG(ERR, "Failed to create exceptional vport");
+
+	return ret;
+}
+
 static int
 cpfl_pci_probe_first(struct rte_pci_device *pci_dev)
 {
@@ -2347,13 +2426,19 @@ cpfl_pci_probe_first(struct rte_pci_device *pci_dev)
 		goto close_ethdev;
 	}
 
+	if (adapter->devargs.repr_args_num > 0) {
+		retval = cpfl_exceptional_vport_create(pci_dev, adapter);
+		if (retval != 0) {
+			PMD_INIT_LOG(ERR, "Failed to create exceptional vport. ");
+			goto close_ethdev;
+		}
+	}
 	retval = cpfl_repr_create(pci_dev, adapter);
 	if (retval != 0) {
 		PMD_INIT_LOG(ERR, "Failed to create representors ");
 		goto close_ethdev;
 	}
 
-
 	return 0;
 
 close_ethdev:
@@ -2387,6 +2472,14 @@ cpfl_pci_probe_again(struct rte_pci_device *pci_dev, struct cpfl_adapter_ext *ad
 		return ret;
 	}
 
+	if (adapter->exceptional_vport == NULL && adapter->devargs.repr_args_num > 0) {
+		ret = cpfl_exceptional_vport_create(pci_dev, adapter);
+		if (ret != 0) {
+			PMD_INIT_LOG(ERR, "Failed to create exceptional vport. ");
+			return ret;
+		}
+	}
+
 	ret = cpfl_repr_create(pci_dev, adapter);
 	if (ret != 0) {
 		PMD_INIT_LOG(ERR, "Failed to create representors ");
diff --git a/drivers/net/cpfl/cpfl_ethdev.h b/drivers/net/cpfl/cpfl_ethdev.h
index 9cc96839ed..b0fb05c7b9 100644
--- a/drivers/net/cpfl/cpfl_ethdev.h
+++ b/drivers/net/cpfl/cpfl_ethdev.h
@@ -156,6 +156,11 @@ struct cpfl_vport {
 	struct idpf_rx_queue *p2p_rx_bufq;
 	struct idpf_tx_queue *p2p_tx_complq;
 	bool p2p_manual_bind;
+
+	/* exceptional vport */
+	bool exceptional;  /* this vport is for exceptional one */
+	uint32_t dispatch_service_id;
+	uint32_t dispatch_core_id;
 };
 
 struct cpfl_repr {
@@ -180,6 +185,9 @@ struct cpfl_adapter_ext {
 	uint16_t used_vecs_num;
 	struct cpfl_devargs devargs;
 
+	/* exceptional vport and exceptional queues */
+	struct cpfl_vport *exceptional_vport;
+
 	rte_spinlock_t vport_map_lock;
 	struct rte_hash *vport_map_hash;
 
diff --git a/drivers/net/cpfl/cpfl_rxtx.c b/drivers/net/cpfl/cpfl_rxtx.c
index 2ef6871a85..df6a8c1940 100644
--- a/drivers/net/cpfl/cpfl_rxtx.c
+++ b/drivers/net/cpfl/cpfl_rxtx.c
@@ -1409,6 +1409,22 @@ cpfl_stop_queues(struct rte_eth_dev *dev)
 	}
 }
 
+uint16_t
+cpfl_dummy_recv_pkts(__rte_unused void *queue,
+		     __rte_unused struct rte_mbuf **tx_pkts,
+		     __rte_unused uint16_t nb_pkts)
+{
+	return 0;
+}
+
+uint16_t
+cpfl_dummy_xmit_pkts(__rte_unused void *queue,
+		     __rte_unused struct rte_mbuf **tx_pkts,
+		     __rte_unused uint16_t nb_pkts)
+{
+	return 0;
+}
+
 void
 cpfl_set_rx_function(struct rte_eth_dev *dev)
 {
diff --git a/drivers/net/cpfl/cpfl_rxtx.h b/drivers/net/cpfl/cpfl_rxtx.h
index aacd087b56..914a0485b5 100644
--- a/drivers/net/cpfl/cpfl_rxtx.h
+++ b/drivers/net/cpfl/cpfl_rxtx.h
@@ -117,4 +117,11 @@ int cpfl_switch_hairpin_complq(struct cpfl_vport *cpfl_vport, bool on);
 int cpfl_switch_hairpin_bufq(struct cpfl_vport *cpfl_vport, bool on);
 int cpfl_switch_hairpin_rxtx_queue(struct cpfl_vport *cpfl_vport, uint16_t qid,
 				   bool rx, bool on);
+uint16_t cpfl_dummy_recv_pkts(void *queue,
+			      struct rte_mbuf **tx_pkts,
+			      uint16_t nb_pkts);
+
+uint16_t cpfl_dummy_xmit_pkts(void *queue,
+			      struct rte_mbuf **tx_pkts,
+			      uint16_t nb_pkts);
 #endif /* _CPFL_RXTX_H_ */
-- 
2.34.1


  parent reply	other threads:[~2023-08-09  7:34 UTC|newest]

Thread overview: 89+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-09 15:51 [PATCH 00/19] net/cpfl: support port representor beilei.xing
2023-08-09 15:51 ` [PATCH 01/19] net/cpfl: refine devargs parse and process beilei.xing
2023-08-09 15:51 ` [PATCH 02/19] net/cpfl: introduce interface structure beilei.xing
2023-08-09 15:51 ` [PATCH 03/19] net/cpfl: add cp channel beilei.xing
2023-08-09 15:51 ` [PATCH 04/19] net/cpfl: enable vport mapping beilei.xing
2023-08-09 15:51 ` [PATCH 05/19] net/cpfl: parse representor devargs beilei.xing
2023-08-09 15:51 ` [PATCH 06/19] net/cpfl: support probe again beilei.xing
2023-08-09 15:51 ` [PATCH 07/19] net/cpfl: create port representor beilei.xing
2023-08-09 15:51 ` [PATCH 08/19] net/cpfl: support vport list/info get beilei.xing
2023-08-09 15:51 ` [PATCH 09/19] net/cpfl: update vport info before creating representor beilei.xing
2023-08-09 15:51 ` [PATCH 10/19] net/cpfl: refine handle virtual channel message beilei.xing
2023-08-09 15:51 ` beilei.xing [this message]
2023-08-09 15:51 ` [PATCH 12/19] net/cpfl: support representor Rx/Tx queue setup beilei.xing
2023-08-09 15:51 ` [PATCH 13/19] net/cpfl: support link update for representor beilei.xing
2023-08-09 15:51 ` [PATCH 14/19] net/cpfl: add stats ops " beilei.xing
2023-08-09 15:51 ` [PATCH 15/19] common/idpf: refine inline function beilei.xing
2023-08-09 15:51 ` [PATCH 16/19] net/cpfl: support representor data path beilei.xing
2023-08-09 15:51 ` [PATCH 17/19] net/cpfl: support dispatch process beilei.xing
2023-08-09 15:51 ` [PATCH 18/19] net/cpfl: add dispatch service beilei.xing
2023-08-09 15:51 ` [PATCH 19/19] doc: update release notes for representor beilei.xing
2023-08-16 15:05 ` [PATCH v2 00/12] net/cpfl: support port representor beilei.xing
2023-08-16 15:05   ` [PATCH v2 01/12] net/cpfl: refine devargs parse and process beilei.xing
2023-08-16 15:05   ` [PATCH v2 02/12] net/cpfl: introduce interface structure beilei.xing
2023-08-16 15:05   ` [PATCH v2 03/12] net/cpfl: add cp channel beilei.xing
2023-08-16 15:05   ` [PATCH v2 04/12] net/cpfl: enable vport mapping beilei.xing
2023-08-16 15:05   ` [PATCH v2 05/12] net/cpfl: parse representor devargs beilei.xing
2023-08-16 15:05   ` [PATCH v2 06/12] net/cpfl: support probe again beilei.xing
2023-08-16 15:05   ` [PATCH v2 07/12] net/cpfl: create port representor beilei.xing
2023-09-05  7:35     ` Liu, Mingxia
2023-09-05  8:30     ` Liu, Mingxia
2023-08-16 15:05   ` [PATCH v2 08/12] net/cpfl: support vport list/info get beilei.xing
2023-08-16 15:05   ` [PATCH v2 09/12] net/cpfl: update vport info before creating representor beilei.xing
2023-09-06  2:33     ` Liu, Mingxia
2023-08-16 15:05   ` [PATCH v2 10/12] net/cpfl: refine handle virtual channel message beilei.xing
2023-08-16 15:05   ` [PATCH v2 11/12] net/cpfl: support link update for representor beilei.xing
2023-08-16 15:05   ` [PATCH v2 12/12] net/cpfl: support Rx/Tx queue setup " beilei.xing
2023-09-06  3:02     ` Liu, Mingxia
2023-09-07 15:15   ` [PATCH v3 00/11] net/cpfl: support port representor beilei.xing
2023-09-07 15:15     ` [PATCH v3 01/11] net/cpfl: refine devargs parse and process beilei.xing
2023-09-07 15:15     ` [PATCH v3 02/11] net/cpfl: introduce interface structure beilei.xing
2023-09-07 15:15     ` [PATCH v3 03/11] net/cpfl: refine handle virtual channel message beilei.xing
2023-09-07 15:15     ` [PATCH v3 04/11] net/cpfl: introduce CP channel API beilei.xing
2023-09-07 15:16     ` [PATCH v3 05/11] net/cpfl: enable vport mapping beilei.xing
2023-09-07 15:16     ` [PATCH v3 06/11] net/cpfl: parse representor devargs beilei.xing
2023-09-07 15:16     ` [PATCH v3 07/11] net/cpfl: support probe again beilei.xing
2023-09-07 15:16     ` [PATCH v3 08/11] net/cpfl: create port representor beilei.xing
2023-09-07 15:16     ` [PATCH v3 09/11] net/cpfl: support vport list/info get beilei.xing
2023-09-07 15:16     ` [PATCH v3 10/11] net/cpfl: update vport info before creating representor beilei.xing
2023-09-07 15:16     ` [PATCH v3 11/11] net/cpfl: support link update for representor beilei.xing
2023-09-08 11:16     ` [PATCH v4 00/10] net/cpfl: support port representor beilei.xing
2023-09-08 11:16       ` [PATCH v4 01/10] net/cpfl: refine devargs parse and process beilei.xing
2023-09-08 11:16       ` [PATCH v4 02/10] net/cpfl: introduce interface structure beilei.xing
2023-09-09  2:08         ` Wu, Jingjing
2023-09-08 11:16       ` [PATCH v4 03/10] net/cpfl: refine handle virtual channel message beilei.xing
2023-09-09  2:13         ` Wu, Jingjing
2023-09-08 11:16       ` [PATCH v4 04/10] net/cpfl: introduce CP channel API beilei.xing
2023-09-08 11:16       ` [PATCH v4 05/10] net/cpfl: enable vport mapping beilei.xing
2023-09-08 11:16       ` [PATCH v4 06/10] net/cpfl: parse representor devargs beilei.xing
2023-09-08 11:16       ` [PATCH v4 07/10] net/cpfl: support probe again beilei.xing
2023-09-08 11:16       ` [PATCH v4 08/10] net/cpfl: support vport list/info get beilei.xing
2023-09-09  2:34         ` Wu, Jingjing
2023-09-08 11:17       ` [PATCH v4 09/10] net/cpfl: create port representor beilei.xing
2023-09-09  3:04         ` Wu, Jingjing
2023-09-08 11:17       ` [PATCH v4 10/10] net/cpfl: support link update for representor beilei.xing
2023-09-09  3:05         ` Wu, Jingjing
2023-09-12 16:26       ` [PATCH v5 00/10] net/cpfl: support port representor beilei.xing
2023-09-12 16:26         ` [PATCH v5 01/10] net/cpfl: refine devargs parse and process beilei.xing
2023-09-12 16:26         ` [PATCH v5 02/10] net/cpfl: introduce interface structure beilei.xing
2023-09-12 16:26         ` [PATCH v5 03/10] net/cpfl: refine handle virtual channel message beilei.xing
2023-09-12 16:26         ` [PATCH v5 04/10] net/cpfl: introduce CP channel API beilei.xing
2023-09-12 16:26         ` [PATCH v5 05/10] net/cpfl: enable vport mapping beilei.xing
2023-09-12 16:26         ` [PATCH v5 06/10] net/cpfl: support vport list/info get beilei.xing
2023-09-12 16:26         ` [PATCH v5 07/10] net/cpfl: parse representor devargs beilei.xing
2023-09-12 16:26         ` [PATCH v5 08/10] net/cpfl: support probe again beilei.xing
2023-09-12 16:26         ` [PATCH v5 09/10] net/cpfl: create port representor beilei.xing
2023-09-12 16:26         ` [PATCH v5 10/10] net/cpfl: support link update for representor beilei.xing
2023-09-12 17:30         ` [PATCH v6 00/10] net/cpfl: support port representor beilei.xing
2023-09-12 17:30           ` [PATCH v6 01/10] net/cpfl: refine devargs parse and process beilei.xing
2023-09-12 17:30           ` [PATCH v6 02/10] net/cpfl: introduce interface structure beilei.xing
2023-09-12 17:30           ` [PATCH v6 03/10] net/cpfl: refine handle virtual channel message beilei.xing
2023-09-12 17:30           ` [PATCH v6 04/10] net/cpfl: introduce CP channel API beilei.xing
2023-09-12 17:30           ` [PATCH v6 05/10] net/cpfl: enable vport mapping beilei.xing
2023-09-12 17:30           ` [PATCH v6 06/10] net/cpfl: support vport list/info get beilei.xing
2023-09-12 17:30           ` [PATCH v6 07/10] net/cpfl: parse representor devargs beilei.xing
2023-09-12 17:30           ` [PATCH v6 08/10] net/cpfl: support probe again beilei.xing
2023-09-12 17:30           ` [PATCH v6 09/10] net/cpfl: create port representor beilei.xing
2023-09-12 17:30           ` [PATCH v6 10/10] net/cpfl: support link update for representor beilei.xing
2023-09-13  1:01           ` [PATCH v6 00/10] net/cpfl: support port representor Wu, Jingjing
2023-09-13  5:41             ` Zhang, Qi Z

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230809155134.539287-12-beilei.xing@intel.com \
    --to=beilei.xing@intel.com \
    --cc=dev@dpdk.org \
    --cc=jingjing.wu@intel.com \
    --cc=mingxia.liu@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).