DPDK patches and discussions
 help / color / mirror / Atom feed
From: Chas Williams <3chas3@gmail.com>
To: dev@dpdk.org
Cc: mtetsuyah@gmail.com, yliu@fridaylinux.org,
	maxime.coquelin@redhat.com, Jan Blunck <jblunck@infradead.org>
Subject: [dpdk-dev] [PATCH 2/2] net/vhost: insert/strip VLAN header in software
Date: Thu, 29 Mar 2018 12:05:07 -0400	[thread overview]
Message-ID: <20180329160507.25081-2-3chas3@gmail.com> (raw)
In-Reply-To: <20180329160507.25081-1-3chas3@gmail.com>

From: Jan Blunck <jblunck@infradead.org>

This lets the vhost driver handle the VLAN header like the virtio driver
in software.

Signed-off-by: Jan Blunck <jblunck@infradead.org>
---
 drivers/net/vhost/rte_eth_vhost.c | 35 ++++++++++++++++++++++++++++++++++-
 1 file changed, 34 insertions(+), 1 deletion(-)

diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c
index 453d9bee1..0beb28e94 100644
--- a/drivers/net/vhost/rte_eth_vhost.c
+++ b/drivers/net/vhost/rte_eth_vhost.c
@@ -119,6 +119,7 @@ struct pmd_internal {
 	uint16_t max_queues;
 	rte_atomic32_t started;
 	int vid;
+	uint8_t vlan_strip;
 };
 
 struct internal_list {
@@ -422,6 +423,12 @@ eth_vhost_rx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs)
 
 	for (i = 0; likely(i < nb_rx); i++) {
 		bufs[i]->port = r->port;
+		bufs[i]->ol_flags = 0;
+		bufs[i]->vlan_tci = 0;
+
+		if (r->internal->vlan_strip)
+			rte_vlan_strip(bufs[i]);
+
 		r->stats.bytes += bufs[i]->pkt_len;
 	}
 
@@ -438,7 +445,7 @@ eth_vhost_tx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs)
 {
 	struct vhost_queue *r = q;
 	uint16_t i, nb_tx = 0;
-	uint16_t nb_send = nb_bufs;
+	uint16_t nb_send = 0;
 
 	if (unlikely(rte_atomic32_read(&r->allow_queuing) == 0))
 		return 0;
@@ -448,6 +455,22 @@ eth_vhost_tx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs)
 	if (unlikely(rte_atomic32_read(&r->allow_queuing) == 0))
 		goto out;
 
+	for (i = 0; i < nb_bufs; i++) {
+		struct rte_mbuf *m = bufs[i];
+
+		/* Do VLAN tag insertion */
+		if (m->ol_flags & PKT_TX_VLAN_PKT) {
+			int error = rte_vlan_insert(&m);
+			if (unlikely(error)) {
+				rte_pktmbuf_free(m);
+				continue;
+			}
+		}
+
+		bufs[nb_send] = m;
+		++nb_send;
+	}
+
 	/* Enqueue packets to guest RX queue */
 	while (nb_send) {
 		uint16_t nb_pkts;
@@ -489,6 +512,16 @@ eth_vhost_tx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs)
 static int
 eth_dev_configure(struct rte_eth_dev *dev __rte_unused)
 {
+	struct pmd_internal *internal = dev->data->dev_private;
+	const struct rte_eth_rxmode *rxmode = &dev->data->dev_conf.rxmode;
+
+	internal->vlan_strip = rxmode->hw_vlan_strip;
+
+	if (rxmode->hw_vlan_filter)
+		RTE_LOG(WARNING, PMD,
+			"vhost(%s): vlan filtering not available\n",
+			internal->dev_name);
+
 	return 0;
 }
 
-- 
2.13.6

  reply	other threads:[~2018-03-29 16:05 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-29 16:05 [dpdk-dev] [PATCH 1/2] net/vhost: set the vq consistently Chas Williams
2018-03-29 16:05 ` Chas Williams [this message]
2018-04-11 14:52   ` [dpdk-dev] [PATCH 2/2] net/vhost: insert/strip VLAN header in software Maxime Coquelin
2018-04-12  7:14   ` Maxime Coquelin
2018-05-08  1:31   ` Yao, Lei A
2018-04-11 14:46 ` [dpdk-dev] [PATCH 1/2] net/vhost: set the vq consistently Maxime Coquelin
2018-04-11 15:02   ` Maxime Coquelin

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=20180329160507.25081-2-3chas3@gmail.com \
    --to=3chas3@gmail.com \
    --cc=dev@dpdk.org \
    --cc=jblunck@infradead.org \
    --cc=maxime.coquelin@redhat.com \
    --cc=mtetsuyah@gmail.com \
    --cc=yliu@fridaylinux.org \
    /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).