From: Tiwei Bie <tiwei.bie@intel.com>
To: Xiao Wang <xiao.w.wang@intel.com>
Cc: yliu@fridaylinux.org, dev@dpdk.org, stephen@networkplumber.org
Subject: Re: [dpdk-dev] [PATCH v2 2/2] net/virtio: support GUEST ANNOUNCE
Date: Mon, 4 Dec 2017 16:46:34 +0800 [thread overview]
Message-ID: <20171204084634.p6kdqpwlyau76v4a@debian-xvivbkq> (raw)
In-Reply-To: <1512396128-119985-3-git-send-email-xiao.w.wang@intel.com>
On Mon, Dec 04, 2017 at 06:02:08AM -0800, Xiao Wang wrote:
> When live migration is done, for the backup VM, either the virtio
> frontend or the vhost backend needs to send out gratuitous RARP packet
> to announce its new network location.
>
To support GUEST ANNOUNCE, do we just need to send a RARP packet?
Will it work in an IPv6-only network?
> This patch enables VIRTIO_NET_F_GUEST_ANNOUNCE feature to support live
[...]
> +
> +static int
> +virtio_dev_pause(struct rte_eth_dev *dev)
> +{
> + struct virtio_hw *hw = dev->data->dev_private;
> +
> + if (hw->started == 0)
> + return -1;
> + hw->started = 0;
> + /*
> + * Prevent the worker thread from touching queues to avoid condition,
Typo. Avoid "contention"?
> + * 1 ms should be enough for the ongoing Tx function to finish.
> + */
> + rte_delay_ms(1);
> + return 0;
> +}
> +
> +static void
> +virtio_dev_resume(struct rte_eth_dev *dev)
> +{
> + struct virtio_hw *hw = dev->data->dev_private;
> +
> + hw->started = 1;
> +}
> +
> +static void
> +generate_rarp(struct rte_eth_dev *dev)
You can give it a better name, e.g. virtio_notify_peers().
> +{
> + struct virtio_hw *hw = dev->data->dev_private;
> + struct rte_mbuf *rarp_mbuf = NULL;
> + struct virtnet_tx *txvq = dev->data->tx_queues[0];
> + struct virtnet_rx *rxvq = dev->data->rx_queues[0];
> +
> + rarp_mbuf = rte_mbuf_raw_alloc(rxvq->mpool);
> + if (rarp_mbuf == NULL) {
> + PMD_DRV_LOG(ERR, "mbuf allocate failed");
> + return;
> + }
> +
> + if (make_rarp_packet(rarp_mbuf, (struct ether_addr *)hw->mac_addr)) {
> + rte_pktmbuf_free(rarp_mbuf);
> + rarp_mbuf = NULL;
> + return;
> + }
> +
> + /* If virtio port just stopped, no need to send RARP */
> + if (virtio_dev_pause(dev) < 0)
> + return;
> +
> + virtio_inject_pkts(txvq, &rarp_mbuf, 1);
> + /* Recover the stored hw status to let worker thread continue */
> + virtio_dev_resume(dev);
> +}
> +
> +static void
> +virtnet_ack_link_announce(struct rte_eth_dev *dev)
Why use "virtnet_" prefix? I think "virtio_" would be better.
> +{
> + struct virtio_hw *hw = dev->data->dev_private;
> + struct virtio_pmd_ctrl ctrl;
> + int len;
> +
> + ctrl.hdr.class = VIRTIO_NET_CTRL_ANNOUNCE;
> + ctrl.hdr.cmd = VIRTIO_NET_CTRL_ANNOUNCE_ACK;
> + len = 0;
> +
> + virtio_send_command(hw->cvq, &ctrl, &len, 0);
> +}
> +
> /*
> - * Process Virtio Config changed interrupt and call the callback
> - * if link state changed.
> + * Process virtio config changed interrupt. Call the callback
> + * if link state changed; generate gratuitous RARP packet if
Better to replace ";" with ","
> + * the status indicates an ANNOUNCE.
> */
> void
> virtio_interrupt_handler(void *param)
> @@ -1274,6 +1391,12 @@ static int virtio_dev_xstats_get_names(struct rte_eth_dev *dev,
> NULL, NULL);
> }
>
> + if (isr & VIRTIO_NET_S_ANNOUNCE) {
> + rte_spinlock_lock(&hw->sl);
> + generate_rarp(dev);
Just curious. Do you need to make sure that the RARP packet
would be sent successfully?
> + virtnet_ack_link_announce(dev);
> + rte_spinlock_unlock(&hw->sl);
> + }
> }
[...]
> diff --git a/drivers/net/virtio/virtio_pci.h b/drivers/net/virtio/virtio_pci.h
> index 3c5ce66..3cd367e 100644
> --- a/drivers/net/virtio/virtio_pci.h
> +++ b/drivers/net/virtio/virtio_pci.h
> @@ -270,6 +270,7 @@ struct virtio_hw {
> struct virtio_pci_common_cfg *common_cfg;
> struct virtio_net_config *dev_cfg;
> void *virtio_user_dev;
> + rte_spinlock_t sl;
Some detailed comments need to be added in the code to
document the usage of this lock.
>
> struct virtqueue **vqs;
> };
[...]
> diff --git a/drivers/net/virtio/virtqueue.h b/drivers/net/virtio/virtqueue.h
> index 2305d91..ed420e9 100644
> --- a/drivers/net/virtio/virtqueue.h
> +++ b/drivers/net/virtio/virtqueue.h
> @@ -158,6 +158,17 @@ struct virtio_net_ctrl_mac {
> #define VIRTIO_NET_CTRL_VLAN_ADD 0
> #define VIRTIO_NET_CTRL_VLAN_DEL 1
>
> +/*
> + * Control link announce acknowledgement
> + *
> + * The command VIRTIO_NET_CTRL_ANNOUNCE_ACK is used to indicate that
> + * driver has recevied the notification; device would clear the
> + * VIRTIO_NET_S_ANNOUNCE bit in the status field after it receives
> + * this command.
> + */
> +#define VIRTIO_NET_CTRL_ANNOUNCE 3
> +#define VIRTIO_NET_CTRL_ANNOUNCE_ACK 0
You can just keep 3 and 0 in the same column.
Best regards,
Tiwei Bie
next prev parent reply other threads:[~2017-12-04 8:47 UTC|newest]
Thread overview: 112+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-24 11:03 [dpdk-dev] [PATCH 0/2] " Xiao Wang
2017-11-24 11:03 ` [dpdk-dev] [PATCH 1/2] net/virtio: make control queue thread-safe Xiao Wang
2017-11-24 5:38 ` Tiwei Bie
2017-11-30 2:10 ` Wang, Xiao W
2017-11-30 2:59 ` Stephen Hemminger
2017-12-01 1:38 ` Wang, Xiao W
2017-12-04 14:02 ` [dpdk-dev] [PATCH v2 0/2] net/virtio: support GUEST ANNOUNCE Xiao Wang
2017-12-04 14:02 ` [dpdk-dev] [PATCH v2 1/2] net/virtio: make control queue thread-safe Xiao Wang
2017-12-04 14:02 ` [dpdk-dev] [PATCH v2 2/2] net/virtio: support GUEST ANNOUNCE Xiao Wang
2017-12-04 8:46 ` Tiwei Bie [this message]
2018-01-03 1:37 ` Wang, Xiao W
2018-01-03 8:42 ` Wang, Xiao W
2017-12-06 11:23 ` Tiwei Bie
2017-12-06 14:22 ` Yuanhan Liu
2018-01-03 1:41 ` Wang, Xiao W
2018-01-04 7:41 ` [dpdk-dev] [PATCH v3 0/2] " Xiao Wang
2018-01-04 7:41 ` [dpdk-dev] [PATCH v3 1/2] net/virtio: make control queue thread-safe Xiao Wang
2018-01-04 7:41 ` [dpdk-dev] [PATCH v3 2/2] net/virtio: support GUEST ANNOUNCE Xiao Wang
2018-01-04 2:51 ` Tiwei Bie
2018-01-04 7:11 ` Wang, Xiao W
2018-01-04 15:59 ` [dpdk-dev] [PATCH v4 0/3] " Xiao Wang
2018-01-04 15:59 ` [dpdk-dev] [PATCH v4 1/3] net/virtio: make control queue thread-safe Xiao Wang
2018-01-04 15:59 ` [dpdk-dev] [PATCH v4 2/3] net/virtio: add packet injection method Xiao Wang
2018-01-04 7:56 ` Tiwei Bie
2018-01-05 16:46 ` [dpdk-dev] [PATCH v5 0/3] net/virtio: support GUEST ANNOUNCE Xiao Wang
2018-01-05 16:46 ` [dpdk-dev] [PATCH v5 1/3] net/virtio: make control queue thread-safe Xiao Wang
2018-01-05 16:46 ` [dpdk-dev] [PATCH v5 2/3] net/virtio: add packet injection method Xiao Wang
2018-01-05 18:00 ` Tiwei Bie
2018-01-07 2:37 ` Wang, Xiao W
2018-01-05 16:46 ` [dpdk-dev] [PATCH v5 3/3] net/virtio: support GUEST ANNOUNCE Xiao Wang
2018-01-05 17:56 ` Tiwei Bie
2018-01-07 2:29 ` Wang, Xiao W
2018-01-07 12:05 ` [dpdk-dev] [PATCH v6 0/3] " Xiao Wang
2018-01-07 12:05 ` [dpdk-dev] [PATCH v6 1/3] net/virtio: make control queue thread-safe Xiao Wang
2018-01-08 13:06 ` Yuanhan Liu
2018-01-08 15:25 ` Wang, Xiao W
2018-01-07 12:05 ` [dpdk-dev] [PATCH v6 2/3] net/virtio: add packet injection method Xiao Wang
2018-01-08 13:03 ` Yuanhan Liu
2018-01-08 15:11 ` Wang, Xiao W
2018-01-09 2:55 ` Wang, Xiao W
2018-01-09 14:26 ` [dpdk-dev] [PATCH v7 0/3] net/virtio: support GUEST ANNOUNCE Xiao Wang
2018-01-09 14:26 ` [dpdk-dev] [PATCH v7 1/3] net/virtio: make control queue thread-safe Xiao Wang
2018-01-09 14:26 ` [dpdk-dev] [PATCH v7 2/3] net/virtio: add packet injection method Xiao Wang
2018-01-09 14:26 ` [dpdk-dev] [PATCH v7 3/3] net/virtio: support GUEST ANNOUNCE Xiao Wang
2018-01-09 8:49 ` Maxime Coquelin
2018-01-09 10:58 ` Wang, Xiao W
2018-01-09 11:03 ` Wang, Xiao W
2018-01-09 11:41 ` Thomas Monjalon
2018-01-09 13:36 ` Yuanhan Liu
2018-01-09 13:26 ` [dpdk-dev] [PATCH v8 0/5] " Xiao Wang
2018-01-09 13:26 ` [dpdk-dev] [PATCH v8 1/5] net/virtio: make control queue thread-safe Xiao Wang
2018-01-09 13:26 ` [dpdk-dev] [PATCH v8 2/5] net/virtio: add packet injection method Xiao Wang
2018-01-09 13:26 ` [dpdk-dev] [PATCH v8 3/5] net: add a helper for making RARP packet Xiao Wang
2018-01-09 13:48 ` Thomas Monjalon
2018-01-09 15:52 ` Wang, Xiao W
2018-01-09 16:09 ` [dpdk-dev] [PATCH v9 0/5] net/virtio: support GUEST ANNOUNCE Xiao Wang
2018-01-09 16:09 ` [dpdk-dev] [PATCH v9 1/5] net/virtio: make control queue thread-safe Xiao Wang
2018-01-09 16:09 ` [dpdk-dev] [PATCH v9 2/5] net/virtio: add packet injection method Xiao Wang
2018-01-09 16:09 ` [dpdk-dev] [PATCH v9 3/5] net: add a helper for making RARP packet Xiao Wang
2018-01-09 17:22 ` Thomas Monjalon
2018-01-10 1:23 ` [dpdk-dev] [PATCH v10 0/5] net/virtio: support GUEST ANNOUNCE Xiao Wang
2018-01-10 1:23 ` [dpdk-dev] [PATCH v10 1/5] net/virtio: make control queue thread-safe Xiao Wang
2018-01-10 1:23 ` [dpdk-dev] [PATCH v10 2/5] net/virtio: add packet injection method Xiao Wang
2018-01-10 1:23 ` [dpdk-dev] [PATCH v10 3/5] net: add a helper for making RARP packet Xiao Wang
2018-01-10 13:06 ` Yuanhan Liu
2018-01-10 14:10 ` Thomas Monjalon
2018-01-16 9:01 ` Olivier Matz
2018-01-16 9:43 ` Wang, Xiao W
2018-01-16 10:42 ` Olivier Matz
2018-01-16 11:03 ` Wang, Xiao W
2018-01-16 11:42 ` Wang, Xiao W
2018-01-16 21:40 ` [dpdk-dev] [PATCH v11 0/5] net/virtio: support GUEST ANNOUNCE Xiao Wang
2018-01-16 21:40 ` [dpdk-dev] [PATCH v11 1/5] net/virtio: make control queue thread-safe Xiao Wang
2018-01-16 21:41 ` [dpdk-dev] [PATCH v11 2/5] net/virtio: add packet injection method Xiao Wang
2018-01-16 21:41 ` [dpdk-dev] [PATCH v11 3/5] net: add a helper for making RARP packet Xiao Wang
2018-01-16 14:29 ` Olivier Matz
2018-01-16 21:41 ` [dpdk-dev] [PATCH v11 4/5] vhost: use lib API to make " Xiao Wang
2018-01-16 21:41 ` [dpdk-dev] [PATCH v11 5/5] net/virtio: support GUEST ANNOUNCE Xiao Wang
2018-01-19 17:33 ` Ferruh Yigit
2018-01-20 14:31 ` Ferruh Yigit
2018-01-21 1:31 ` Wang, Xiao W
2018-01-18 3:09 ` [dpdk-dev] [PATCH v11 0/5] " Yuanhan Liu
2018-01-18 3:14 ` [dpdk-dev] [PATCH 1/2] net: fixup RARP generation Yuanhan Liu
2018-01-18 3:14 ` [dpdk-dev] [PATCH 2/2] net: fix build error Yuanhan Liu
2018-01-18 7:38 ` Thomas Monjalon
2018-01-18 7:45 ` Wang, Xiao W
2018-01-18 8:03 ` Yuanhan Liu
2018-01-18 8:36 ` Thomas Monjalon
2018-01-18 8:48 ` Yuanhan Liu
2018-01-18 8:38 ` [dpdk-dev] [PATCH 1/2] net: fixup RARP generation Thomas Monjalon
2018-01-18 8:51 ` Yuanhan Liu
2018-01-18 8:53 ` Wang, Xiao W
2018-01-19 16:04 ` Ferruh Yigit
2018-01-10 1:23 ` [dpdk-dev] [PATCH v10 4/5] vhost: use lib API to make RARP packet Xiao Wang
2018-01-10 1:23 ` [dpdk-dev] [PATCH v10 5/5] net/virtio: support GUEST ANNOUNCE Xiao Wang
2018-01-09 16:09 ` [dpdk-dev] [PATCH v9 4/5] vhost: use lib API to make RARP packet Xiao Wang
2018-01-09 16:09 ` [dpdk-dev] [PATCH v9 5/5] net/virtio: support GUEST ANNOUNCE Xiao Wang
2018-01-09 13:26 ` [dpdk-dev] [PATCH v8 4/5] vhost: use lib API to make RARP packet Xiao Wang
2018-01-09 13:26 ` [dpdk-dev] [PATCH v8 5/5] net/virtio: support GUEST ANNOUNCE Xiao Wang
2018-01-09 14:38 ` [dpdk-dev] [PATCH v8 0/5] " Maxime Coquelin
2018-01-07 12:05 ` [dpdk-dev] [PATCH v6 3/3] " Xiao Wang
2018-01-05 20:27 ` [dpdk-dev] [PATCH v4 2/3] net/virtio: add packet injection method Stephen Hemminger
2018-01-06 4:41 ` Tiwei Bie
2018-01-04 15:59 ` [dpdk-dev] [PATCH v4 3/3] net/virtio: support GUEST ANNOUNCE Xiao Wang
2018-01-04 11:13 ` Tiwei Bie
2017-11-24 11:04 ` [dpdk-dev] [PATCH 2/2] " Xiao Wang
2017-11-24 6:04 ` Tiwei Bie
2017-11-30 2:37 ` Wang, Xiao W
2017-11-27 12:48 ` Yuanhan Liu
2017-11-30 2:41 ` Wang, Xiao W
2017-12-05 14:26 ` Yuanhan Liu
2018-01-03 1:43 ` Wang, Xiao W
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=20171204084634.p6kdqpwlyau76v4a@debian-xvivbkq \
--to=tiwei.bie@intel.com \
--cc=dev@dpdk.org \
--cc=stephen@networkplumber.org \
--cc=xiao.w.wang@intel.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).