From patchwork Wed Jun 19 14:47:51 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vlad Yasevich X-Patchwork-Id: 252586 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.180.67]) by ozlabs.org (Postfix) with ESMTP id 8EDD72C02A8 for ; Thu, 20 Jun 2013 00:48:18 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756877Ab3FSOsO (ORCPT ); Wed, 19 Jun 2013 10:48:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:63580 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756788Ab3FSOsM (ORCPT ); Wed, 19 Jun 2013 10:48:12 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r5JEmBpt010784 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 19 Jun 2013 10:48:12 -0400 Received: from vyasevic.redhat.com (ovpn-113-128.phx2.redhat.com [10.3.113.128]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r5JEm9bv002071; Wed, 19 Jun 2013 10:48:10 -0400 From: Vlad Yasevich To: netdev@vger.kernel.org Cc: davem@davemloft.net, mst@redhat.com, jasowang@redhat.com, Vlad Yasevich Subject: [PATCH net-next 1/2] macvtap: Let TUNSETOFFLOAD actually controll offload features. Date: Wed, 19 Jun 2013 10:47:51 -0400 Message-Id: <1371653272-11703-2-git-send-email-vyasevic@redhat.com> In-Reply-To: <1371653272-11703-1-git-send-email-vyasevic@redhat.com> References: <1371653272-11703-1-git-send-email-vyasevic@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org When the user issues TUNSETOFFLOAD ioctl, macvtap does not do anything other then to verify arguments. This patch adds functionality to allow users to actually control offload features. NETIF_F_GSO and NETIF_F_GRO are always on, but the rest of the features can be controlled. Signed-off-by: Vlad Yasevich --- drivers/net/macvlan.c | 9 +++++++++ drivers/net/macvtap.c | 41 ++++++++++++++++++++++++++++++++++++++++- include/linux/if_macvlan.h | 1 + 3 files changed, 50 insertions(+), 1 deletion(-) diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c index edfddc5..fa47415 100644 --- a/drivers/net/macvlan.c +++ b/drivers/net/macvlan.c @@ -638,6 +638,14 @@ static int macvlan_ethtool_get_settings(struct net_device *dev, return __ethtool_get_settings(vlan->lowerdev, cmd); } +static netdev_features_t macvlan_fix_features(struct net_device *dev, + netdev_features_t features) +{ + struct macvlan_dev *vlan = netdev_priv(dev); + + return (features & vlan->set_features) | (features & ~MACVLAN_FEATURES); +} + static const struct ethtool_ops macvlan_ethtool_ops = { .get_link = ethtool_op_get_link, .get_settings = macvlan_ethtool_get_settings, @@ -651,6 +659,7 @@ static const struct net_device_ops macvlan_netdev_ops = { .ndo_stop = macvlan_stop, .ndo_start_xmit = macvlan_start_xmit, .ndo_change_mtu = macvlan_change_mtu, + .ndo_fix_features = macvlan_fix_features, .ndo_change_rx_flags = macvlan_change_rx_flags, .ndo_set_mac_address = macvlan_set_mac_address, .ndo_set_rx_mode = macvlan_set_mac_lists, diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c index 5a76f20..09f0b1f 100644 --- a/drivers/net/macvtap.c +++ b/drivers/net/macvtap.c @@ -976,6 +976,45 @@ static int macvtap_ioctl_set_queue(struct file *file, unsigned int flags) return ret; } +static int set_offload(struct macvtap_queue *q, unsigned long arg) +{ + struct macvlan_dev *vlan; + netdev_features_t features = NETIF_F_GSO|NETIF_F_GRO; + int err = 0; + + if (arg & TUN_F_CSUM) { + features = NETIF_F_HW_CSUM; + + if (arg & (TUN_F_TSO4 | TUN_F_TSO6)) { + if (arg & TUN_F_TSO_ECN) + features |= NETIF_F_TSO_ECN; + if (arg & TUN_F_TSO4) + features |= NETIF_F_TSO; + if (arg & TUN_F_TSO6) + features |= NETIF_F_TSO6; + } + + if (arg & TUN_F_UFO) + features |= NETIF_F_UFO; + } + + rtnl_lock(); + rcu_read_lock_bh(); + vlan = rcu_dereference_bh(q->vlan); + if (!vlan) { + err = -ENOLINK; + goto unlock; + } + + vlan->set_features = features; + netdev_update_features(vlan->dev); + +unlock: + rcu_read_unlock_bh(); + rtnl_unlock(); + return err; +} + /* * provide compatibility with generic tun/tap interface */ @@ -1062,7 +1101,7 @@ static long macvtap_ioctl(struct file *file, unsigned int cmd, got enabled for forwarded frames */ if (!(q->flags & IFF_VNET_HDR)) return -EINVAL; - return 0; + return set_offload(q, arg); default: return -EINVAL; diff --git a/include/linux/if_macvlan.h b/include/linux/if_macvlan.h index f49a9f6..e446e82 100644 --- a/include/linux/if_macvlan.h +++ b/include/linux/if_macvlan.h @@ -65,6 +65,7 @@ struct macvlan_dev { DECLARE_BITMAP(mc_filter, MACVLAN_MC_FILTER_SZ); + netdev_features_t set_features; enum macvlan_mode mode; u16 flags; int (*receive)(struct sk_buff *skb);