From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754531AbbBZVdn (ORCPT ); Thu, 26 Feb 2015 16:33:43 -0500 Received: from mail-bl2on0137.outbound.protection.outlook.com ([65.55.169.137]:52016 "EHLO na01-bl2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754474AbbBZVdl (ORCPT ); Thu, 26 Feb 2015 16:33:41 -0500 X-Greylist: delayed 4676 seconds by postgrey-1.27 at vger.kernel.org; Thu, 26 Feb 2015 16:33:41 EST From: Andrew Schwartzmeyer To: CC: , , , , , , , Subject: [PATCH] Implement Hyper-V netvsc_get_channels() ethool op Date: Thu, 26 Feb 2015 12:00:40 -0800 Message-ID: <1424980840-33714-1-git-send-email-andrew@schwartzmeyer.com> X-Mailer: git-send-email 2.3.0 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [166.170.42.35] X-ClientProxiedBy: CO2PR06CA011.namprd06.prod.outlook.com (10.141.242.11) To BLUPR0801MB642.namprd08.prod.outlook.com (10.141.253.150) Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=andrew@schwartzmeyer.com; X-Microsoft-Antispam: UriScan:; X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:;SRVR:BLUPR0801MB642; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(5005006);SRVR:BLUPR0801MB642; X-Forefront-PRVS: 0499DAF22A X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(6009001)(189002)(199003)(62966003)(47776003)(36756003)(77096005)(50466002)(77156002)(229853001)(66066001)(64706001)(46102003)(101416001)(110136001)(48376002)(53416004)(42186005)(2561002)(2351001)(97736003)(19580405001)(40100003)(122386002)(69596002)(19580395003)(81156004)(575784001)(105586002)(33646002)(1511001)(2421001)(50226001)(86362001)(68736005)(50986999)(87976001)(106356001)(92566002);DIR:OUT;SFP:1102;SCL:1;SRVR:BLUPR0801MB642;H:marvin.local.net;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:;SRVR:BLUPR0801MB642; X-OriginatorOrg: schwartzmeyer.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Feb 2015 20:00:47.3102 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR0801MB642 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This adds support for reporting the combined channels count of the hv_netvsc driver via 'ethtool --show-channels'. This required adding 'max_chn' to 'struct netvsc_device', and assigning it 'rsscap.num_recv_que' in 'rndis_filter_device_add'. Now we can access the combined maximum channel count via 'struct netvsc_device' in the ethtool callback. Signed-off-by: Andrew Schwartzmeyer --- drivers/net/hyperv/hyperv_net.h | 1 + drivers/net/hyperv/netvsc_drv.c | 14 ++++++++++++++ drivers/net/hyperv/rndis_filter.c | 5 ++++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h index 384ca4f4de4a..371f2a6c0715 100644 --- a/drivers/net/hyperv/hyperv_net.h +++ b/drivers/net/hyperv/hyperv_net.h @@ -635,6 +635,7 @@ struct netvsc_device { struct vmbus_channel *chn_table[NR_CPUS]; u32 send_table[VRSS_SEND_TAB_SIZE]; u32 num_chn; + u32 max_chn; atomic_t queue_sends[NR_CPUS]; /* Holds rndis device info */ diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c index 15d82eda0baf..a06bd6614007 100644 --- a/drivers/net/hyperv/netvsc_drv.c +++ b/drivers/net/hyperv/netvsc_drv.c @@ -687,6 +687,19 @@ static void netvsc_get_drvinfo(struct net_device *net, strlcpy(info->fw_version, "N/A", sizeof(info->fw_version)); } +static void netvsc_get_channels(struct net_device *net, + struct ethtool_channels *channel) +{ + struct net_device_context *net_device_ctx = netdev_priv(net); + struct hv_device *dev = net_device_ctx->device_ctx; + struct netvsc_device *nvdev = hv_get_drvdata(dev); + + if (nvdev) { + channel->max_combined = nvdev->max_chn; + channel->combined_count = nvdev->num_chn; + } +} + static int netvsc_change_mtu(struct net_device *ndev, int mtu) { struct net_device_context *ndevctx = netdev_priv(ndev); @@ -760,6 +773,7 @@ static void netvsc_poll_controller(struct net_device *net) static const struct ethtool_ops ethtool_ops = { .get_drvinfo = netvsc_get_drvinfo, .get_link = ethtool_op_get_link, + .get_channels = netvsc_get_channels, }; static const struct net_device_ops device_ops = { diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c index 7816d98bdddc..015f9b9b5093 100644 --- a/drivers/net/hyperv/rndis_filter.c +++ b/drivers/net/hyperv/rndis_filter.c @@ -1094,6 +1094,7 @@ int rndis_filter_device_add(struct hv_device *dev, if (ret || rsscap.num_recv_que < 2) goto out; + net_device->max_chn = rsscap.num_recv_que; net_device->num_chn = (num_online_cpus() < rsscap.num_recv_que) ? num_online_cpus() : rsscap.num_recv_que; if (net_device->num_chn == 1) @@ -1140,8 +1141,10 @@ int rndis_filter_device_add(struct hv_device *dev, ret = rndis_filter_set_rss_param(rndis_device, net_device->num_chn); out: - if (ret) + if (ret) { + net_device->max_chn = 1; net_device->num_chn = 1; + } return 0; /* return 0 because primary channel can be used alone */ err_dev_remv: -- 2.3.0