From: Stephen Hemminger <stephen-OTpzqLSitTUnbdJkjeBofR2eb7JE58TQ@public.gmane.org>
To: Ouyang Changchun
<changchun.ouyang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Cc: dev-VfR2kkLFssw@public.gmane.org,
Stephen Hemminger
<shemming-43mecJUBy8ZBDgjK7y7TUQ@public.gmane.org>
Subject: [RFC 10/10] virtio: add support for promiscious and multicast
Date: Mon, 25 Aug 2014 19:07:56 -0700 [thread overview]
Message-ID: <20140826020858.448904783@networkplumber.org> (raw)
In-Reply-To: 20140826020746.062748014@networkplumber.org
[-- Attachment #1: virtio-ctrl-rx.patch --]
[-- Type: text/plain, Size: 4798 bytes --]
Implement standard virtio controls for enabling and disabling
promiscious and multicast.
Signed-off-by: Stephen Hemminger <shemming-43mecJUBy8ZBDgjK7y7TUQ@public.gmane.org>
--- a/lib/librte_pmd_virtio/virtio_ethdev.c 2014-08-25 19:00:16.754586819 -0700
+++ b/lib/librte_pmd_virtio/virtio_ethdev.c 2014-08-25 19:02:48.019397658 -0700
@@ -77,6 +77,11 @@ static void virtio_get_hwaddr(struct vir
static void virtio_dev_rx_queue_release(__rte_unused void *rxq);
static void virtio_dev_tx_queue_release(__rte_unused void *txq);
+static void virtio_promiscuous_enable(struct rte_eth_dev *dev);
+static void virtio_promiscuous_disable(struct rte_eth_dev *dev);
+static void virtio_allmulticast_enable(struct rte_eth_dev *dev);
+static void virtio_allmulticast_disable(struct rte_eth_dev *dev);
+
static void virtio_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats);
static void virtio_dev_stats_reset(struct rte_eth_dev *dev);
static void virtio_dev_free_mbufs(struct rte_eth_dev *dev);
@@ -405,23 +410,27 @@ virtio_dev_close(struct rte_eth_dev *dev
* dev_ops for virtio, bare necessities for basic operation
*/
static struct eth_dev_ops virtio_eth_dev_ops = {
- .dev_configure = virtio_dev_configure,
- .dev_start = virtio_dev_start,
- .dev_stop = virtio_dev_stop,
- .dev_close = virtio_dev_close,
-
- .dev_infos_get = virtio_dev_info_get,
- .stats_get = virtio_dev_stats_get,
- .stats_reset = virtio_dev_stats_reset,
- .link_update = virtio_dev_link_update,
- .mac_addr_add = NULL,
- .mac_addr_remove = NULL,
- .rx_queue_setup = virtio_dev_rx_queue_setup,
+ .dev_configure = virtio_dev_configure,
+ .dev_start = virtio_dev_start,
+ .dev_stop = virtio_dev_stop,
+ .dev_close = virtio_dev_close,
+
+ .dev_infos_get = virtio_dev_info_get,
+ .stats_get = virtio_dev_stats_get,
+ .stats_reset = virtio_dev_stats_reset,
+ .link_update = virtio_dev_link_update,
+ .promiscuous_enable = virtio_promiscuous_enable,
+ .promiscuous_disable = virtio_promiscuous_disable,
+ .allmulticast_enable = virtio_allmulticast_enable,
+ .allmulticast_disable = virtio_allmulticast_disable,
+ .mac_addr_add = NULL,
+ .mac_addr_remove = NULL,
+ .rx_queue_setup = virtio_dev_rx_queue_setup,
/* meaningfull only to multiple queue */
- .rx_queue_release = virtio_dev_rx_queue_release,
- .tx_queue_setup = virtio_dev_tx_queue_setup,
+ .rx_queue_release = virtio_dev_rx_queue_release,
+ .tx_queue_setup = virtio_dev_tx_queue_setup,
/* meaningfull only to multiple queue */
- .tx_queue_release = virtio_dev_tx_queue_release,
+ .tx_queue_release = virtio_dev_tx_queue_release,
/* collect stats per queue */
.queue_stats_mapping_set = virtio_dev_queue_stats_mapping_set,
};
@@ -466,6 +475,63 @@ virtio_dev_atomic_write_link_status(stru
return 0;
}
+/* Control receive processing (ie multicast, promiscious, mac address). */
+static int virtio_ctrl_rx(struct virtio_hw *hw, uint8_t cmd, uint8_t onoff)
+{
+ struct virtio_pmd_ctrl ctrl;
+ int len, ret;
+
+ if (!vtpci_with_feature(hw, VIRTIO_NET_F_CTRL_RX))
+ return -ENOTSUP;
+
+ ctrl.hdr.class = VIRTIO_NET_CTRL_RX;
+ ctrl.hdr.cmd = cmd;
+ memcpy(ctrl.data, &onoff, sizeof(uint8_t));
+
+ len = sizeof(uint8_t);
+ ret = virtio_send_command(hw->cvq, &ctrl, &len, 1);
+ if (ret != 0)
+ PMD_DRV_LOG(NOTICE, "ctrl_rx %u failed: %d\n", cmd, ret);
+
+ return ret;
+}
+
+static void
+virtio_promiscuous_enable(struct rte_eth_dev *dev)
+{
+ struct virtio_hw *hw = dev->data->dev_private;
+
+ PMD_INIT_LOG(DEBUG, "promiscious enable");
+ virtio_ctrl_rx(hw, VIRTIO_NET_CTRL_RX_PROMISC, 1);
+}
+
+static void
+virtio_promiscuous_disable(struct rte_eth_dev *dev)
+{
+ struct virtio_hw *hw = dev->data->dev_private;
+
+ PMD_INIT_LOG(DEBUG, "promiscious disable");
+ virtio_ctrl_rx(hw, VIRTIO_NET_CTRL_RX_PROMISC, 0);
+}
+
+static void
+virtio_allmulticast_enable(struct rte_eth_dev *dev)
+{
+ struct virtio_hw *hw = dev->data->dev_private;
+
+ PMD_INIT_LOG(DEBUG, "allmulticast enable");
+ virtio_ctrl_rx(hw, VIRTIO_NET_CTRL_RX_ALLMULTI, 1);
+}
+
+static void
+virtio_allmulticast_disable(struct rte_eth_dev *dev)
+{
+ struct virtio_hw *hw = dev->data->dev_private;
+
+ PMD_INIT_LOG(DEBUG, "allmulticast disable");
+ virtio_ctrl_rx(hw, VIRTIO_NET_CTRL_RX_ALLMULTI, 0);
+}
+
static void
virtio_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
{
@@ -559,7 +625,7 @@ virtio_negotiate_features(struct virtio_
{
uint32_t host_features, mask;
- mask = VIRTIO_NET_F_CTRL_RX | VIRTIO_NET_F_CTRL_VLAN;
+ mask = VIRTIO_NET_F_CTRL_VLAN;
mask |= VIRTIO_NET_F_CSUM | VIRTIO_NET_F_GUEST_CSUM;
/* TSO and LRO are only available when their corresponding
next prev parent reply other threads:[~2014-08-26 2:07 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-26 2:07 [RFC 00/10] virtio patches Stephen Hemminger
2014-08-26 2:07 ` [RFC 01/10] virtio: rearrange resource initialization Stephen Hemminger
[not found] ` <20140826020837.898427212-OTpzqLSitTUnbdJkjeBofR2eb7JE58TQ@public.gmane.org>
2014-08-26 7:14 ` Ouyang, Changchun
2014-08-26 2:07 ` [RFC 02/10] virtio: use weak barriers Stephen Hemminger
2014-08-26 2:07 ` [RFC 03/10] virtio: allow starting with link down Stephen Hemminger
2014-08-26 2:07 ` [RFC 04/10] virtio: add support for Link State interrupt Stephen Hemminger
2014-08-26 2:07 ` [RFC 05/10] ether: add soft vlan encap/decap functions Stephen Hemminger
2014-08-26 2:07 ` [RFC 06/10] virtio: use software vlan stripping Stephen Hemminger
[not found] ` <20140826020848.386074683-OTpzqLSitTUnbdJkjeBofR2eb7JE58TQ@public.gmane.org>
2014-08-26 8:37 ` Ouyang, Changchun
[not found] ` <F52918179C57134FAEC9EA62FA2F96251183B285-E2R4CRU6q/6iAffOGbnezLfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2014-08-26 16:24 ` Stephen Hemminger
2014-08-27 5:42 ` Ouyang, Changchun
[not found] ` <F52918179C57134FAEC9EA62FA2F96251183B79C-E2R4CRU6q/6iAffOGbnezLfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2014-08-27 18:04 ` Stephen Hemminger
2014-08-26 2:07 ` [RFC 07/10] virtio: remove unnecessary adapter structure Stephen Hemminger
[not found] ` <20140826020851.474452281-OTpzqLSitTUnbdJkjeBofR2eb7JE58TQ@public.gmane.org>
2014-08-26 6:43 ` Ouyang, Changchun
2014-08-26 2:07 ` [RFC 08/10] virtio: remove redundant vq_alignment Stephen Hemminger
[not found] ` <20140826020853.851222673-OTpzqLSitTUnbdJkjeBofR2eb7JE58TQ@public.gmane.org>
2014-08-26 8:41 ` Ouyang, Changchun
2014-08-26 2:07 ` [RFC 09/10] virtio: fix how states are handled during initialization Stephen Hemminger
2014-08-26 2:07 ` Stephen Hemminger [this message]
[not found] ` <20140826020858.448904783-OTpzqLSitTUnbdJkjeBofR2eb7JE58TQ@public.gmane.org>
2014-08-26 6:55 ` [RFC 10/10] virtio: add support for promiscious and multicast Ouyang, Changchun
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=20140826020858.448904783@networkplumber.org \
--to=stephen-otpzqlsittunbdjkjebofr2eb7je58tq@public.gmane.org \
--cc=changchun.ouyang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
--cc=dev-VfR2kkLFssw@public.gmane.org \
--cc=shemming-43mecJUBy8ZBDgjK7y7TUQ@public.gmane.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.