From: Stephen Hemminger <stephen@networkplumber.org>
To: Ouyang Changchun <changchun.ouyang@intel.com>
Cc: dev@dpdk.org, Stephen Hemminger <shemming@brocade.com>
Subject: [dpdk-dev] [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: 4770 bytes --]
Implement standard virtio controls for enabling and disabling
promiscious and multicast.
Signed-off-by: Stephen Hemminger <shemming@brocade.com>
--- 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:05 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-26 2:07 [dpdk-dev] [RFC 00/10] virtio patches Stephen Hemminger
2014-08-26 2:07 ` [dpdk-dev] [RFC 01/10] virtio: rearrange resource initialization Stephen Hemminger
2014-08-26 7:14 ` Ouyang, Changchun
2014-08-26 2:07 ` [dpdk-dev] [RFC 02/10] virtio: use weak barriers Stephen Hemminger
2014-08-26 2:07 ` [dpdk-dev] [RFC 03/10] virtio: allow starting with link down Stephen Hemminger
2014-08-26 2:07 ` [dpdk-dev] [RFC 04/10] virtio: add support for Link State interrupt Stephen Hemminger
2014-08-26 2:07 ` [dpdk-dev] [RFC 05/10] ether: add soft vlan encap/decap functions Stephen Hemminger
2014-08-26 2:07 ` [dpdk-dev] [RFC 06/10] virtio: use software vlan stripping Stephen Hemminger
2014-08-26 8:37 ` Ouyang, Changchun
2014-08-26 16:24 ` Stephen Hemminger
2014-08-27 5:42 ` Ouyang, Changchun
2014-08-27 18:04 ` Stephen Hemminger
2014-08-26 2:07 ` [dpdk-dev] [RFC 07/10] virtio: remove unnecessary adapter structure Stephen Hemminger
2014-08-26 6:43 ` Ouyang, Changchun
2014-08-26 2:07 ` [dpdk-dev] [RFC 08/10] virtio: remove redundant vq_alignment Stephen Hemminger
2014-08-26 8:41 ` Ouyang, Changchun
2014-08-26 2:07 ` [dpdk-dev] [RFC 09/10] virtio: fix how states are handled during initialization Stephen Hemminger
2014-08-26 2:07 ` Stephen Hemminger [this message]
2014-08-26 6:55 ` [dpdk-dev] [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@networkplumber.org \
--cc=changchun.ouyang@intel.com \
--cc=dev@dpdk.org \
--cc=shemming@brocade.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).