dev.dpdk.org archive mirror
 help / color / mirror / Atom feed
From: Chaoyong He <chaoyong.he@corigine.com>
To: dev@dpdk.org
Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com,
	Chaoyong He <chaoyong.he@corigine.com>
Subject: [PATCH v10 13/13] net/nfp: add the representor port rxtx logic
Date: Mon, 26 Sep 2022 14:59:57 +0800	[thread overview]
Message-ID: <1664175597-37248-14-git-send-email-chaoyong.he@corigine.com> (raw)
In-Reply-To: <1664175597-37248-1-git-send-email-chaoyong.he@corigine.com>

For the Rx logic, the representor port decap packet from the
corresponding ring.

For the Tx logic, the representor port prepend the metadata
into packet, and send to firmware through the queue 0 of pf
vNIC.

Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
---
 drivers/net/nfp/flower/nfp_flower_representor.c | 90 +++++++++++++++++++++++++
 1 file changed, 90 insertions(+)

diff --git a/drivers/net/nfp/flower/nfp_flower_representor.c b/drivers/net/nfp/flower/nfp_flower_representor.c
index b47b0a5..0e60f50 100644
--- a/drivers/net/nfp/flower/nfp_flower_representor.c
+++ b/drivers/net/nfp/flower/nfp_flower_representor.c
@@ -464,6 +464,92 @@
 	return 0;
 }
 
+static uint16_t
+nfp_flower_repr_rx_burst(void *rx_queue,
+		struct rte_mbuf **rx_pkts,
+		uint16_t nb_pkts)
+{
+	unsigned int available = 0;
+	unsigned int total_dequeue;
+	struct nfp_net_rxq *rxq;
+	struct rte_eth_dev *dev;
+	struct nfp_flower_representor *repr;
+
+	rxq = rx_queue;
+	if (unlikely(rxq == NULL)) {
+		PMD_RX_LOG(ERR, "RX Bad queue");
+		return 0;
+	}
+
+	dev = &rte_eth_devices[rxq->port_id];
+	repr = dev->data->dev_private;
+	if (unlikely(repr->ring == NULL)) {
+		PMD_RX_LOG(ERR, "representor %s has no ring configured!",
+				repr->name);
+		return 0;
+	}
+
+	total_dequeue = rte_ring_dequeue_burst(repr->ring, (void *)rx_pkts,
+			nb_pkts, &available);
+	if (total_dequeue != 0) {
+		PMD_RX_LOG(DEBUG, "Representor Rx burst for %s, port_id: 0x%x, "
+				"received: %u, available: %u", repr->name,
+				repr->port_id, total_dequeue, available);
+
+		repr->repr_stats.ipackets += total_dequeue;
+	}
+
+	return total_dequeue;
+}
+
+static uint16_t
+nfp_flower_repr_tx_burst(void *tx_queue,
+		struct rte_mbuf **tx_pkts,
+		uint16_t nb_pkts)
+{
+	uint16_t i;
+	uint16_t sent;
+	char *meta_offset;
+	void *pf_tx_queue;
+	struct nfp_net_txq *txq;
+	struct nfp_net_hw *pf_hw;
+	struct rte_eth_dev *dev;
+	struct rte_eth_dev *repr_dev;
+	struct nfp_flower_representor *repr;
+
+	txq = tx_queue;
+	if (unlikely(txq == NULL)) {
+		PMD_TX_LOG(ERR, "TX Bad queue");
+		return 0;
+	}
+
+	/* Grab a handle to the representor struct */
+	repr_dev = &rte_eth_devices[txq->port_id];
+	repr = repr_dev->data->dev_private;
+
+	for (i = 0; i < nb_pkts; i++) {
+		meta_offset = rte_pktmbuf_prepend(tx_pkts[i], FLOWER_PKT_DATA_OFFSET);
+		*(uint32_t *)meta_offset = rte_cpu_to_be_32(NFP_NET_META_PORTID);
+		meta_offset += 4;
+		*(uint32_t *)meta_offset = rte_cpu_to_be_32(repr->port_id);
+	}
+
+	/* This points to the PF vNIC that owns this representor */
+	pf_hw = txq->hw;
+	dev = pf_hw->eth_dev;
+
+	/* Only using Tx queue 0 for now. */
+	pf_tx_queue = dev->data->tx_queues[0];
+	sent = nfp_flower_pf_xmit_pkts(pf_tx_queue, tx_pkts, nb_pkts);
+	if (sent != 0) {
+		PMD_TX_LOG(DEBUG, "Representor Tx burst for %s, port_id: 0x%x transmitted: %u",
+				repr->name, repr->port_id, sent);
+		repr->repr_stats.opackets += sent;
+	}
+
+	return sent;
+}
+
 static const struct eth_dev_ops nfp_flower_pf_repr_dev_ops = {
 	.dev_infos_get        = nfp_flower_repr_dev_infos_get,
 
@@ -553,6 +639,8 @@
 	snprintf(repr->name, sizeof(repr->name), "%s", init_repr_data->name);
 
 	eth_dev->dev_ops = &nfp_flower_pf_repr_dev_ops;
+	eth_dev->rx_pkt_burst = nfp_flower_pf_recv_pkts;
+	eth_dev->tx_pkt_burst = nfp_flower_pf_xmit_pkts;
 	eth_dev->data->dev_flags |= RTE_ETH_DEV_REPRESENTOR;
 
 	eth_dev->data->representor_id = 0;
@@ -622,6 +710,8 @@
 	snprintf(repr->name, sizeof(repr->name), "%s", init_repr_data->name);
 
 	eth_dev->dev_ops = &nfp_flower_repr_dev_ops;
+	eth_dev->rx_pkt_burst = nfp_flower_repr_rx_burst;
+	eth_dev->tx_pkt_burst = nfp_flower_repr_tx_burst;
 	eth_dev->data->dev_flags |= RTE_ETH_DEV_REPRESENTOR;
 
 	if (repr->repr_type == NFP_REPR_TYPE_PHYS_PORT)
-- 
1.8.3.1


  parent reply	other threads:[~2022-09-26  7:02 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-26  6:59 [PATCH v10 00/13] preparation for the rte_flow offload of nfp PMD Chaoyong He
2022-09-26  6:59 ` [PATCH v10 01/13] net/nfp: move app specific attributes to own struct Chaoyong He
2022-09-26  6:59 ` [PATCH v10 02/13] net/nfp: simplify initialization and remove dead code Chaoyong He
2022-09-26  6:59 ` [PATCH v10 03/13] net/nfp: move app specific init logic to own function Chaoyong He
2022-09-26  6:59 ` [PATCH v10 04/13] net/nfp: add initial flower firmware support Chaoyong He
2022-09-26  6:59 ` [PATCH v10 05/13] net/nfp: add flower PF setup logic Chaoyong He
2022-09-26  6:59 ` [PATCH v10 06/13] net/nfp: add flower ctrl VNIC related logics Chaoyong He
2022-09-26  6:59 ` [PATCH v10 07/13] net/nfp: move common rxtx function for flower use Chaoyong He
2022-09-26  6:59 ` [PATCH v10 08/13] net/nfp: add flower ctrl VNIC rxtx logic Chaoyong He
2022-09-26  6:59 ` [PATCH v10 09/13] net/nfp: add flower representor framework Chaoyong He
2022-09-26  6:59 ` [PATCH v10 10/13] net/nfp: add flower PF related routines Chaoyong He
2022-09-26  6:59 ` [PATCH v10 11/13] net/nfp: move rxtx function to header file Chaoyong He
2022-09-26  6:59 ` [PATCH v10 12/13] net/nfp: add flower PF rxtx logic Chaoyong He
2022-09-26  6:59 ` Chaoyong He [this message]
2022-10-05 11:34 ` [PATCH v10 00/13] preparation for the rte_flow offload of nfp PMD Ferruh Yigit
2022-10-05 16:52   ` Ferruh Yigit
2022-10-10  8:51     ` Niklas Söderlund

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=1664175597-37248-14-git-send-email-chaoyong.he@corigine.com \
    --to=chaoyong.he@corigine.com \
    --cc=dev@dpdk.org \
    --cc=niklas.soderlund@corigine.com \
    --cc=oss-drivers@corigine.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).