From patchwork Tue Jun 14 17:13:26 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wyborny, Carolyn" X-Patchwork-Id: 100380 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 325A8B6F7F for ; Wed, 15 Jun 2011 03:11:50 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752015Ab1FNRLp (ORCPT ); Tue, 14 Jun 2011 13:11:45 -0400 Received: from mga09.intel.com ([134.134.136.24]:15073 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751214Ab1FNRLp (ORCPT ); Tue, 14 Jun 2011 13:11:45 -0400 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP; 14 Jun 2011 10:11:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.65,365,1304319600"; d="scan'208";a="14545741" Received: from cmw-fed14.jf.intel.com ([10.23.21.70]) by orsmga001.jf.intel.com with ESMTP; 14 Jun 2011 10:11:44 -0700 From: Carolyn Wyborny To: netdev@vger.kernel.org, bhutchings@solarflare.com Subject: [RFC 2/2] ethtool: Add support for DMA Coalescing feature config to ethtool. Date: Tue, 14 Jun 2011 10:13:26 -0700 Message-Id: <1308071606-6333-1-git-send-email-carolyn.wyborny@intel.com> X-Mailer: git-send-email 1.7.4.4 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This RFC patch adds functions to get and set DMA Coalescing feature configuration. Signed-off-by: Carolyn Wyborny --- include/linux/ethtool.h | 15 ++++++++++++++- net/core/ethtool.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletions(-) diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h index c6a850a..efed754 100644 --- a/include/linux/ethtool.h +++ b/include/linux/ethtool.h @@ -703,6 +703,14 @@ enum ethtool_sfeatures_retval_bits { ETHTOOL_F_COMPAT__BIT, }; +/* for configuring DMA coalescing parameters of chip */ +struct ethtool_dmac { + __u32 cmd; /* ETHTOOL_{G,S}DMAC */ + + /* tune setting, options and validation determined by device. */ + __u32 tune; +}; + #define ETHTOOL_F_UNSUPPORTED (1 << ETHTOOL_F_UNSUPPORTED__BIT) #define ETHTOOL_F_WISH (1 << ETHTOOL_F_WISH__BIT) #define ETHTOOL_F_COMPAT (1 << ETHTOOL_F_COMPAT__BIT) @@ -877,6 +885,8 @@ bool ethtool_invalid_flags(struct net_device *dev, u32 data, u32 supported); * and flag of the device. * @get_dump_data: Get dump data. * @set_dump: Set dump specific flags to the device. + * @get_dmac: Get DMA Coalescing setting from device. + * @set_dmac: Set DMA Coalescing setting. * * All operations are optional (i.e. the function pointer may be set * to %NULL) and callers must take this into account. Callers must @@ -955,7 +965,8 @@ struct ethtool_ops { int (*get_dump_data)(struct net_device *, struct ethtool_dump *, void *); int (*set_dump)(struct net_device *, struct ethtool_dump *); - + void (*get_dmac)(struct net_device *, struct ethtool_dmac *); + int (*set_dmac)(struct net_device *, struct ethtool_dmac *); }; #endif /* __KERNEL__ */ @@ -1029,6 +1040,8 @@ struct ethtool_ops { #define ETHTOOL_SET_DUMP 0x0000003e /* Set dump settings */ #define ETHTOOL_GET_DUMP_FLAG 0x0000003f /* Get dump settings */ #define ETHTOOL_GET_DUMP_DATA 0x00000040 /* Get dump data */ +#define ETHTOOL_GDMAC 0X00000041 /* Get DMA Coalsce settings */ +#define ETHTOOL_SDMAC 0X00000042 /* Set DMA Coalsce settings */ /* compatibility with older code */ #define SPARC_ETH_GSET ETHTOOL_GSET diff --git a/net/core/ethtool.c b/net/core/ethtool.c index fd14116..0f122d3 100644 --- a/net/core/ethtool.c +++ b/net/core/ethtool.c @@ -1926,6 +1926,32 @@ out: vfree(data); return ret; } +static int ethtool_set_dmac(struct net_device *dev, void __user *useraddr) +{ + struct ethtool_dmac dmac; + + if (!dev->ethtool_ops->set_dmac) + return -EOPNOTSUPP; + + if (copy_from_user(&dmac, useraddr, sizeof(dmac))) + return -EFAULT; + + return dev->ethtool_ops->set_dmac(dev, &dmac); +} + +static int ethtool_get_dmac(struct net_device *dev, void __user *useraddr) +{ + struct ethtool_dmac dmac = { .cmd = ETHTOOL_GDMAC }; + + if (!dev->ethtool_ops->get_dmac) + return -EOPNOTSUPP; + + dev->ethtool_ops->get_dmac(dev, &dmac); + + if (copy_to_user(useraddr, &dmac, sizeof(dmac))) + return -EFAULT; + return 0; +} /* The main entry point in this file. Called from net/core/dev.c */ @@ -2152,6 +2178,12 @@ int dev_ethtool(struct net *net, struct ifreq *ifr) case ETHTOOL_GET_DUMP_DATA: rc = ethtool_get_dump_data(dev, useraddr); break; + case ETHTOOL_GDMAC: + rc = ethtool_get_dmac(dev, useraddr); + break; + case ETHTOOL_SDMAC: + rc = ethtool_set_dmac(dev, useraddr); + break; default: rc = -EOPNOTSUPP; }