From: Yuanhan Liu <yuanhan.liu@linux.intel.com>
To: Pankaj Chauhan <pankaj.chauhan@nxp.com>
Cc: dev@dpdk.org, hemant.agrawal@nxp.com, jianfeng.tan@intel.com,
maxime.coquelin@redhat.com
Subject: Re: [dpdk-dev] [RFC][PATCH V2 1/3] examples/vhost: Add vswitch (generic switch) framework
Date: Mon, 26 Sep 2016 12:12:09 +0800 [thread overview]
Message-ID: <20160926041209.GK23158@yliu-dev.sh.intel.com> (raw)
In-Reply-To: <1473072871-16108-2-git-send-email-pankaj.chauhan@nxp.com>
Besides the VMDq proposal, I got few more comments for you.
On Mon, Sep 05, 2016 at 04:24:29PM +0530, Pankaj Chauhan wrote:
> Introduce support for a generic framework for handling of switching between
> physical and vhost devices. The vswitch framework introduces the following
> concept:
>
> 1. vswitch_dev: Vswitch device
It looks a bit confusing to me, to claim it as a "device": it's neither a
physical nic device nor a virtio net device. Something like "vswitch_unit",
or even "vswitch" is better and enough.
> Signed-off-by: Pankaj Chauhan <pankaj.chauhan@nxp.com>
> ---
> examples/vhost/Makefile | 2 +-
> examples/vhost/main.c | 128 +++++++++--
> examples/vhost/vswitch_common.c | 499 ++++++++++++++++++++++++++++++++++++++++
> examples/vhost/vswitch_common.h | 186 +++++++++++++++
> examples/vhost/vswitch_txrx.c | 97 ++++++++
> examples/vhost/vswitch_txrx.h | 71 ++++++
Seems that you forgot to include the file to implment all those ops for
"switch" vswitch mode? I mean, I just see a vs_lookup_n_fwd implmentation
of VMDq.
> @@ -1241,7 +1296,7 @@ static int
> new_device(int vid)
> {
> int lcore, core_add = 0;
> - uint32_t device_num_min = num_devices;
> + uint32_t device_num_min;
> struct vhost_dev *vdev;
>
> vdev = rte_zmalloc("vhost device", sizeof(*vdev), RTE_CACHE_LINE_SIZE);
> @@ -1252,6 +1307,16 @@ new_device(int vid)
> return -1;
> }
> vdev->vid = vid;
> + device_num_min = vs_get_max_vdevs(vswitch_dev_g);
> + RTE_LOG(INFO, VHOST_PORT, "max virtio devices %d\n", device_num_min);
> +
> + vs_port = vs_add_port(vswitch_dev_g, vid, VSWITCH_PTYPE_VIRTIO, vdev);
Note that "vid" does not equal "port". They are two different counters
and both start from 0. That means, you will get unexpected results from
following piece of code ---->
> +struct vswitch_port *vs_add_port(struct vswitch_dev *vs_dev, int port_id,
> + enum vswitch_port_type type, void *priv)
> +{
> + int rc = 0;
> + struct vswitch_port *vs_port = NULL;
> + struct vswitch_ops *vs_ops = vs_dev->ops;
> +
> + vs_port = vs_get_free_port(vs_dev);
> + if (!vs_port) {
> + RTE_LOG(DEBUG, VHOST_CONFIG, "Failed get free port in \
> + vswitch %s\n", vs_dev->name);
> + rc = -EBUSY;
> + goto out;
> + }
> +
> + vs_port->port_id = port_id;
> + vs_port->type = type;
> + vs_port->priv = priv;
> +
> + /* Initialize default port operations. It should be noted that
> + * The switch ops->add_port can replace them with switch specefic
> + * operations if required. This gives us more flexibility in switch
> + * implementations.
> + */
> +
> + switch (type) {
> + case VSWITCH_PTYPE_PHYS:
> + vs_port->do_tx = vs_do_tx_phys_port;
> + vs_port->do_rx = vs_do_rx_phys_port;
> + vs_port->get_txq = vs_get_txq_phys_port;
> + vs_port->get_rxq = vs_get_rxq_phys_port;
> + break;
> + case VSWITCH_PTYPE_VIRTIO:
> + vs_port->do_tx = vs_do_tx_virtio_port;
> + vs_port->do_rx = vs_do_rx_virtio_port;
> + vs_port->get_txq = vs_get_txq_virtio_port;
> + vs_port->get_rxq = vs_get_rxq_virtio_port;
> + break;
> + default:
> + RTE_LOG(DEBUG, VHOST_CONFIG, "Invalid port [id %d, type %d]",
> + port_id, type);
> + rc = -EINVAL;
> + goto out;
> + }
> +
> + if (vs_ops->add_port)
> + rc = vs_ops->add_port(vs_port);
> +
> + if (rc)
> + goto out;
> +
> + vs_port->state = VSWITCH_PSTATE_ADDED;
> +
> + rte_eth_macaddr_get(vs_port->port_id, &vs_port->mac_addr);
<--- here.
--yliu
> + RTE_LOG(INFO, VHOST_PORT, "Port %u MAC: %02"PRIx8" %02"PRIx8" %02"PRIx8
> + " %02"PRIx8" %02"PRIx8" %02"PRIx8"\n",
> + (unsigned)port_id,
> + vs_port->mac_addr.addr_bytes[0],
> + vs_port->mac_addr.addr_bytes[1],
> + vs_port->mac_addr.addr_bytes[2],
> + vs_port->mac_addr.addr_bytes[3],
> + vs_port->mac_addr.addr_bytes[4],
> + vs_port->mac_addr.addr_bytes[5]);
> +
> + RTE_LOG(DEBUG, VHOST_CONFIG, "Added port [%d, type %d] to \
> + vswitch %s\n", vs_port->port_id, type, vs_dev->name);
> +out:
> + if (rc){
> + RTE_LOG(INFO, VHOST_CONFIG, "Failed to Add port [%d, type %d] to \
> + vswitch %s\n", port_id, type, vs_dev->name);
> + if (vs_port)
> + vs_free_port(vs_port);
> + vs_port = NULL;
> + }
> +
> + return vs_port;
> +}
next prev parent reply other threads:[~2016-09-26 4:11 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-05 10:54 [dpdk-dev] [RFC][PATCH V2 0/3] example/vhost: Introduce Vswitch Framework Pankaj Chauhan
2016-09-05 10:54 ` [dpdk-dev] [RFC][PATCH V2 1/3] examples/vhost: Add vswitch (generic switch) framework Pankaj Chauhan
2016-09-09 8:56 ` Tan, Jianfeng
2016-09-12 10:55 ` Pankaj Chauhan
2016-09-13 6:51 ` Tan, Jianfeng
2016-09-15 9:00 ` Pankaj Chauhan
2016-09-19 12:42 ` Tan, Jianfeng
2016-09-27 11:26 ` Pankaj Chauhan
2016-09-19 14:43 ` Yuanhan Liu
2016-09-20 8:58 ` Pankaj Chauhan
2016-09-26 3:56 ` Yuanhan Liu
2016-09-27 11:35 ` Pankaj Chauhan
2016-09-27 12:10 ` Yuanhan Liu
2016-09-11 12:21 ` Yuanhan Liu
2016-09-12 10:59 ` Pankaj Chauhan
2016-09-26 4:12 ` Yuanhan Liu [this message]
2016-09-27 11:44 ` Pankaj Chauhan
2016-09-27 12:03 ` Yuanhan Liu
2016-09-05 10:54 ` [dpdk-dev] [RFC][PATCH V2 2/3] examples/vhost: Add vswitch command line options Pankaj Chauhan
2016-09-13 12:14 ` Yuanhan Liu
2016-09-15 9:11 ` Pankaj Chauhan
2016-09-05 10:54 ` [dpdk-dev] [RFC][PATCH V2 3/3] examples/vhost: Add VMDQ vswitch device Pankaj Chauhan
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=20160926041209.GK23158@yliu-dev.sh.intel.com \
--to=yuanhan.liu@linux.intel.com \
--cc=dev@dpdk.org \
--cc=hemant.agrawal@nxp.com \
--cc=jianfeng.tan@intel.com \
--cc=maxime.coquelin@redhat.com \
--cc=pankaj.chauhan@nxp.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).