From patchwork Tue Jan 13 21:23:19 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Williamson X-Patchwork-Id: 18297 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by ozlabs.org (Postfix) with ESMTP id A96CEDE1B0 for ; Wed, 14 Jan 2009 08:23:56 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752359AbZAMVXf (ORCPT ); Tue, 13 Jan 2009 16:23:35 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753806AbZAMVXe (ORCPT ); Tue, 13 Jan 2009 16:23:34 -0500 Received: from g5t0009.atlanta.hp.com ([15.192.0.46]:4105 "EHLO g5t0009.atlanta.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753377AbZAMVXa (ORCPT ); Tue, 13 Jan 2009 16:23:30 -0500 Received: from g4t0009.houston.hp.com (g4t0009.houston.hp.com [16.234.32.26]) by g5t0009.atlanta.hp.com (Postfix) with ESMTP id 4DFC530338; Tue, 13 Jan 2009 21:23:30 +0000 (UTC) Received: from ldl.fc.hp.com (ldl.fc.hp.com [15.11.146.30]) by g4t0009.houston.hp.com (Postfix) with ESMTP id ECC6CC0CD; Tue, 13 Jan 2009 21:23:29 +0000 (UTC) Received: from localhost (ldl.fc.hp.com [127.0.0.1]) by ldl.fc.hp.com (Postfix) with ESMTP id 9FDA139C001; Tue, 13 Jan 2009 14:23:29 -0700 (MST) X-Virus-Scanned: Debian amavisd-new at ldl.fc.hp.com Received: from ldl.fc.hp.com ([127.0.0.1]) by localhost (ldl.fc.hp.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id YcUyeRJmiqkX; Tue, 13 Jan 2009 14:23:28 -0700 (MST) Received: from [192.168.1.60] (squirrel.fc.hp.com [15.11.146.57]) by ldl.fc.hp.com (Postfix) with ESMTP id CCB4239C017; Tue, 13 Jan 2009 14:23:27 -0700 (MST) Subject: [PATCH 3/4] virtio_net: Add a set_rx_mode interface From: Alex Williamson To: Rusty Russell Cc: kvm , netdev , Mark McLoughlin Organization: HP OSLO R&D Date: Tue, 13 Jan 2009 14:23:19 -0700 Message-Id: <1231881799.9095.188.camel@bling> Mime-Version: 1.0 X-Mailer: Evolution 2.24.2 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Signed-off-by: Alex Williamson --- drivers/net/virtio_net.c | 18 ++++++++++++++++++ include/linux/virtio_net.h | 4 ++++ 2 files changed, 22 insertions(+), 0 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index de348de..b18dd4c 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -664,6 +664,23 @@ static int virtnet_set_tx_csum(struct net_device *dev, u32 data) return ethtool_op_set_tx_hw_csum(dev, data); } +static void virtnet_set_rx_mode(struct net_device *dev) +{ + struct virtnet_info *vi = netdev_priv(dev); + u8 promisc, allmulti; + + promisc = ((dev->flags & IFF_PROMISC) != 0 || dev->uc_count > 0); + allmulti = ((dev->flags & IFF_ALLMULTI) != 0 || dev->mc_count > 0); + + virtnet_send_command(vi, VIRTIO_NET_CTRL_RX_MODE, + VIRTIO_NET_CTRL_RX_MODE_PROMISC, + &promisc, sizeof(promisc)); + + virtnet_send_command(vi, VIRTIO_NET_CTRL_RX_MODE, + VIRTIO_NET_CTRL_RX_MODE_ALLMULTI, + &allmulti, sizeof(allmulti)); +} + static struct ethtool_ops virtnet_ethtool_ops = { .set_tx_csum = virtnet_set_tx_csum, .set_sg = ethtool_op_set_sg, @@ -687,6 +704,7 @@ static const struct net_device_ops virtnet_netdev = { .ndo_start_xmit = start_xmit, .ndo_validate_addr = eth_validate_addr, .ndo_set_mac_address = virtnet_set_mac_address, + .ndo_set_rx_mode = virtnet_set_rx_mode, .ndo_change_mtu = virtnet_change_mtu, #ifdef CONFIG_NET_POLL_CONTROLLER .ndo_poll_controller = virtnet_netpoll, diff --git a/include/linux/virtio_net.h b/include/linux/virtio_net.h index 1de7c86..80cd7d3 100644 --- a/include/linux/virtio_net.h +++ b/include/linux/virtio_net.h @@ -56,4 +56,8 @@ struct virtio_net_hdr_mrg_rxbuf { #define VIRTIO_NET_OK 0 #define VIRTIO_NET_ERR 1 +#define VIRTIO_NET_CTRL_RX_MODE 0 + #define VIRTIO_NET_CTRL_RX_MODE_PROMISC 0 + #define VIRTIO_NET_CTRL_RX_MODE_ALLMULTI 1 + #endif /* _LINUX_VIRTIO_NET_H */