From patchwork Wed Dec 13 00:48:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 847700 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=networkplumber-org.20150623.gappssmtp.com header.i=@networkplumber-org.20150623.gappssmtp.com header.b="rrhI5y9n"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3yxJ3S0SNBz9t2W for ; Wed, 13 Dec 2017 11:48:52 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753011AbdLMAst (ORCPT ); Tue, 12 Dec 2017 19:48:49 -0500 Received: from mail-pg0-f67.google.com ([74.125.83.67]:35345 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752914AbdLMAsp (ORCPT ); Tue, 12 Dec 2017 19:48:45 -0500 Received: by mail-pg0-f67.google.com with SMTP id q20so545633pgv.2 for ; Tue, 12 Dec 2017 16:48:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=+6GXnXOuZSuykUl5IRjPQolOJzrTxiJcLtQMo6QyBH4=; b=rrhI5y9nRxBK0zYIRnUZ3Dqj2RtrF5shVEx/Se0tJ0IbnjpLnnf+KyCHyVY88jG21s bySw2J4jC+gD0chU9nqiyJ4THnh+g52CUW9WHi23Od8dXeVTGvjFbnnrA1o3JjVl45vl TlJTpZdUnACSdLjB/Bfc5KeHGjbEhAVMURUwG7KbdtMoksrgnoskOkC34evCbQLkc/aw 2lVAbhobrlkafr3ggdMjFF4mR44yBHgwERYid75fA8zsZTZ8bgcvaDI45PVHg75m4Pnx 8gn84+GdqZxFRh5IlkaOaiTUGmNA94pk6wx+U7ClIsNxGPqzwXn/PrGpimXxHHwPnQ2m UMfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=+6GXnXOuZSuykUl5IRjPQolOJzrTxiJcLtQMo6QyBH4=; b=DKhJTosSpe3DaT9uMc9u1VyCASCfmoN5Jawf9zMWxtec+WZNzpsrJKXuPfYBC9MInD mTWuKYJY39TvU+ChCWQ48RItQm+0l0KXHo+LMogdv2AYMaA/I/Cvpa5CtPhbsbMhEuNF jSiCwnhJmzoP4ZmFB1InglG7Q7nip9mGc65Qz3+p06d77xaGgWW7v+Uev0fCC2VR65JB K+WveexGhRiDl/r0rL9KKsS8Sr3uUxc3B3RD+kfbwE/Ba4+0dD7ENu+bIsqB3RnIrQIW X7cRa11fMbvDzdF9H+lThGekh8skua96/7nSRNcdHnB5rEZEKGmLEkt3qJ9sPtP2Iwee xi/A== X-Gm-Message-State: AKGB3mJre43bMhamdsWlLoBHBuXPMR2zyZTUyoWDQWLGnRmibpsgaYGD Y7Hmrr6+GRZIAoyhrrW8a7DBTA== X-Google-Smtp-Source: ACJfBov33JpQr1Kbz2UVnml4CxIUb0Q5NPHK+jSAMO17sQ+GtzZRsoIatGXpphjVlHuu2UPWQNnwxw== X-Received: by 10.84.229.5 with SMTP id b5mr4116047plk.405.1513126124478; Tue, 12 Dec 2017 16:48:44 -0800 (PST) Received: from xeon-e3.wavecable.com (76-14-207-240.or.wavecable.com. [76.14.207.240]) by smtp.gmail.com with ESMTPSA id y131sm433692pfg.125.2017.12.12.16.48.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Dec 2017 16:48:43 -0800 (PST) From: Stephen Hemminger X-Google-Original-From: Stephen Hemminger To: kys@microsoft.com, haiyangz@microsoft.com, sthemmin@microsoft.com Cc: devel@linuxdriverproject.org, netdev@vger.kernel.org Subject: [PATCH net-next 1/6] hv_netvsc: copy_to_send buf can be void Date: Tue, 12 Dec 2017 16:48:35 -0800 Message-Id: <20171213004840.17507-2-sthemmin@microsoft.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171213004840.17507-1-sthemmin@microsoft.com> References: <20171213004840.17507-1-sthemmin@microsoft.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Since only caller does not care about return value. Signed-off-by: Stephen Hemminger --- drivers/net/hyperv/netvsc.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c index e4bcd202a56a..9407907c4988 100644 --- a/drivers/net/hyperv/netvsc.c +++ b/drivers/net/hyperv/netvsc.c @@ -696,19 +696,18 @@ static u32 netvsc_get_next_send_section(struct netvsc_device *net_device) return NETVSC_INVALID_INDEX; } -static u32 netvsc_copy_to_send_buf(struct netvsc_device *net_device, - unsigned int section_index, - u32 pend_size, - struct hv_netvsc_packet *packet, - struct rndis_message *rndis_msg, - struct hv_page_buffer *pb, - struct sk_buff *skb) +static void netvsc_copy_to_send_buf(struct netvsc_device *net_device, + unsigned int section_index, + u32 pend_size, + struct hv_netvsc_packet *packet, + struct rndis_message *rndis_msg, + struct hv_page_buffer *pb, + struct sk_buff *skb) { char *start = net_device->send_buf; char *dest = start + (section_index * net_device->send_section_size) + pend_size; int i; - u32 msg_size = 0; u32 padding = 0; u32 page_count = packet->cp_partial ? packet->rmsg_pgcnt : packet->page_buf_cnt; @@ -728,16 +727,11 @@ static u32 netvsc_copy_to_send_buf(struct netvsc_device *net_device, u32 len = pb[i].len; memcpy(dest, (src + offset), len); - msg_size += len; dest += len; } - if (padding) { + if (padding) memset(dest, 0, padding); - msg_size += padding; - } - - return msg_size; } static inline int netvsc_send_pkt( From patchwork Wed Dec 13 00:48:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 847710 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=networkplumber-org.20150623.gappssmtp.com header.i=@networkplumber-org.20150623.gappssmtp.com header.b="T1GmiQUz"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3yxJ6D4l74z9t2W for ; Wed, 13 Dec 2017 11:51:16 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753213AbdLMAvO (ORCPT ); Tue, 12 Dec 2017 19:51:14 -0500 Received: from mail-pf0-f194.google.com ([209.85.192.194]:37615 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752972AbdLMAsq (ORCPT ); Tue, 12 Dec 2017 19:48:46 -0500 Received: by mail-pf0-f194.google.com with SMTP id n6so581971pfa.4 for ; Tue, 12 Dec 2017 16:48:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=L9mwmRourvrNXnqLl5//swOtjYbY8wcsbnsgRgFW81w=; b=T1GmiQUzPooJxrOOJanDSyI+yRAmb+2SAXweRjnLYEXXGd6Rd0wGilMek4LCsDqhwN aIcxez9eTIz1kzA/OjUoatW8vEh6qxGP8+N3Y0Veq1wspc4csFE1dZOXeSTLNoghTj2B h6QpusAjJWFGL0YoZj+8B2kJQqwLU7kkfkhpTBhyElab73LGp8VtLFjzT4XhqioaIUVb Or9ChLafI0bwIlo+7rqybLOm+VtIgHa8BMWkeX0bc1o5mlcsyzTkRv4xrYPjwbbpG5MP 1I1YrVR9+w8VqSL62VNUAywcTiXdozFxxgbPqaOLPD2DHhC7LIpThEQ2pqrLR0QGy1qL x39Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=L9mwmRourvrNXnqLl5//swOtjYbY8wcsbnsgRgFW81w=; b=aKvLDDSEYctnTPFdfnJu+6/6NVJ8LbZuBc9VJvD6UOISet9R7AjDemDTHDmEoAlRwI T4joTTXpSl+VtflNbDBsDVSJeH8/zL7mZuRcs9x9UQWbv8SQVRTylYxnzxlz5pAS5g0L rrK0nipq3CzLtlmcUi+IgP91eqVlPQL3YmFRJ+PoXio1PgMO7e8bi9D3v0WITDBy7f19 ghmDZIkHQPCHtC5hPF9nyztgA+9g4E9Q+izzXnCtwwDcZ1CCwfNMAsndT6sGo1G4SuCD xy3MvGwk1uUivBqxPwc3BRiKwqqevDGSiQOwdOR4v38we0g3xwokZSNnl+bRjdD0moZq NHpA== X-Gm-Message-State: AKGB3mI+Y9gZixNBvgGj6mxGlLOvTfNxOkATLBGgTCFz7DEWT1YBA9PX dANfg5+Pw9Ig8lObZHnSdyEXfw== X-Google-Smtp-Source: ACJfBoscS52IJlYHTYL3KvtiSwmctk0/BgtDv7/3j476Faq1KPBhQvYcIIq6+2LSg8A0xdQEWkGKww== X-Received: by 10.84.179.193 with SMTP id b59mr4116246plc.12.1513126125744; Tue, 12 Dec 2017 16:48:45 -0800 (PST) Received: from xeon-e3.wavecable.com (76-14-207-240.or.wavecable.com. [76.14.207.240]) by smtp.gmail.com with ESMTPSA id y131sm433692pfg.125.2017.12.12.16.48.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Dec 2017 16:48:44 -0800 (PST) From: Stephen Hemminger X-Google-Original-From: Stephen Hemminger To: kys@microsoft.com, haiyangz@microsoft.com, sthemmin@microsoft.com Cc: devel@linuxdriverproject.org, netdev@vger.kernel.org Subject: [PATCH net-next 2/6] hv_netvsc: track memory allocation failures in ethtool stats Date: Tue, 12 Dec 2017 16:48:36 -0800 Message-Id: <20171213004840.17507-3-sthemmin@microsoft.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171213004840.17507-1-sthemmin@microsoft.com> References: <20171213004840.17507-1-sthemmin@microsoft.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org When skb can not be allocated, update ethtool statisitics rather than rx_dropped which is intended for netif_receive. Signed-off-by: Stephen Hemminger --- drivers/net/hyperv/hyperv_net.h | 1 + drivers/net/hyperv/netvsc_drv.c | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h index 3d940c67ea94..42bbde1cbe45 100644 --- a/drivers/net/hyperv/hyperv_net.h +++ b/drivers/net/hyperv/hyperv_net.h @@ -692,6 +692,7 @@ struct netvsc_ethtool_stats { unsigned long tx_busy; unsigned long tx_send_full; unsigned long rx_comp_busy; + unsigned long rx_no_memory; unsigned long stop_queue; unsigned long wake_queue; }; diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c index dc70de674ca9..d16b68974d80 100644 --- a/drivers/net/hyperv/netvsc_drv.c +++ b/drivers/net/hyperv/netvsc_drv.c @@ -777,8 +777,8 @@ int netvsc_recv_callback(struct net_device *net, skb = netvsc_alloc_recv_skb(net, &nvchan->napi, csum_info, vlan, data, len); if (unlikely(!skb)) { + ++net_device_ctx->eth_stats.rx_no_memory; drop: - ++net->stats.rx_dropped; rcu_read_unlock(); return NVSP_STAT_FAIL; } @@ -1129,12 +1129,13 @@ static const struct { u16 offset; } netvsc_stats[] = { { "tx_scattered", offsetof(struct netvsc_ethtool_stats, tx_scattered) }, - { "tx_no_memory", offsetof(struct netvsc_ethtool_stats, tx_no_memory) }, + { "tx_no_memory", offsetof(struct netvsc_ethtool_stats, tx_no_memory) }, { "tx_no_space", offsetof(struct netvsc_ethtool_stats, tx_no_space) }, { "tx_too_big", offsetof(struct netvsc_ethtool_stats, tx_too_big) }, { "tx_busy", offsetof(struct netvsc_ethtool_stats, tx_busy) }, { "tx_send_full", offsetof(struct netvsc_ethtool_stats, tx_send_full) }, { "rx_comp_busy", offsetof(struct netvsc_ethtool_stats, rx_comp_busy) }, + { "rx_no_memory", offsetof(struct netvsc_ethtool_stats, rx_no_memory) }, { "stop_queue", offsetof(struct netvsc_ethtool_stats, stop_queue) }, { "wake_queue", offsetof(struct netvsc_ethtool_stats, wake_queue) }, }, vf_stats[] = { From patchwork Wed Dec 13 00:48:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 847701 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=networkplumber-org.20150623.gappssmtp.com header.i=@networkplumber-org.20150623.gappssmtp.com header.b="hFBL8V0i"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3yxJ3S6sPNz9t2Z for ; Wed, 13 Dec 2017 11:48:52 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753027AbdLMAsv (ORCPT ); Tue, 12 Dec 2017 19:48:51 -0500 Received: from mail-pg0-f68.google.com ([74.125.83.68]:40324 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752880AbdLMAss (ORCPT ); Tue, 12 Dec 2017 19:48:48 -0500 Received: by mail-pg0-f68.google.com with SMTP id k15so537087pgr.7 for ; Tue, 12 Dec 2017 16:48:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=L1bmZEHvtqpSqE56zG5C0OvvnkFaKS3fw7ct2Cl9rdE=; b=hFBL8V0iqbKDmFOmyO1/g3iu+wYfMs6CtmDYE6sBnbohuGxHeSz/XfcUB4GM9/hjm9 JPOBMZbyXI/RM+f+mubCQSNI2hUSIT64xr1+Sb4JCj1zM7rMH/7/pI//6l9GsmNNqcAa kbyAe/o/aS8rPpiMF59ut2DfIc0FkyLYkG2ydN8djvOUj66ANdk7xhNJT4wZCF2vRYoy 62iBt9ADCXxlBIitibp696Y/oogoyj095WugS1nl81/If1S5biWL6B1E6cb6GIuONLET NL+cJRIbKR09nU/0bHKiC0whvUBEK9sw3iu5OlxJ4zoXPSb36SeqmSrdIFpdP9lXKDHo syhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=L1bmZEHvtqpSqE56zG5C0OvvnkFaKS3fw7ct2Cl9rdE=; b=i+FhtOsedFTz3C3EgWw4ZcSQxkXm47dASqHFlyva6kwuLkwRCOOqTQA3Y4wf1FmKTJ SfLVpf3gSckcAz/RMelG9fJpJguEEPyLZf/HXzUhZVP+RR9T53kHx5c5Jz3aOiSC2z4f pZ89YGurpVN7mtKMj2tX8Lf1eg54cSnjtmnoYIqhbGuUL+l/0vLrNtVIjGYulE+7QR/Q YxRl+nmZ/C33J0c1/z7zuwy7jXZ4zkohCBJcBJO28/ul/c9we9uOwR2jWAvUk3cGW2dc UGIYpA1zqV2mBHYP+QDaLZ5hahTqvJFXU0B/9ZOgoMwYxeTav4Vp1G7fgApniFlRm7tv FOVw== X-Gm-Message-State: AKGB3mKeWkZM+/UKRcZZ1ESlRWq6B+0RhqxmdU6LvG2zJmFHxoA9lJem O7mqU+82VpDK3BPQaMJG3Wq0gw== X-Google-Smtp-Source: ACJfBosjD5kWhfdW5IoeM6MBTgbI+F3fTU496JQJAAleh3DgRijrvT4mZotBQEzi8RapfuqMFAVBCg== X-Received: by 10.84.216.29 with SMTP id m29mr4044077pli.243.1513126126970; Tue, 12 Dec 2017 16:48:46 -0800 (PST) Received: from xeon-e3.wavecable.com (76-14-207-240.or.wavecable.com. [76.14.207.240]) by smtp.gmail.com with ESMTPSA id y131sm433692pfg.125.2017.12.12.16.48.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Dec 2017 16:48:46 -0800 (PST) From: Stephen Hemminger X-Google-Original-From: Stephen Hemminger To: kys@microsoft.com, haiyangz@microsoft.com, sthemmin@microsoft.com Cc: devel@linuxdriverproject.org, netdev@vger.kernel.org Subject: [PATCH net-next 3/6] hv_netvsc: simplify function args in receive status path Date: Tue, 12 Dec 2017 16:48:37 -0800 Message-Id: <20171213004840.17507-4-sthemmin@microsoft.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171213004840.17507-1-sthemmin@microsoft.com> References: <20171213004840.17507-1-sthemmin@microsoft.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The caller (netvsc_receive) already has the net device pointer, and should just pass that to functions rather than the hyperv device. This eliminates several impossible error paths in the process. Signed-off-by: Stephen Hemminger --- drivers/net/hyperv/hyperv_net.h | 3 +-- drivers/net/hyperv/netvsc.c | 2 +- drivers/net/hyperv/netvsc_drv.c | 12 ++---------- drivers/net/hyperv/rndis_filter.c | 9 +++------ 4 files changed, 7 insertions(+), 19 deletions(-) diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h index 42bbde1cbe45..6463b7f5aa00 100644 --- a/drivers/net/hyperv/hyperv_net.h +++ b/drivers/net/hyperv/hyperv_net.h @@ -199,7 +199,7 @@ int netvsc_send(struct net_device_context *ndc, struct rndis_message *rndis_msg, struct hv_page_buffer *page_buffer, struct sk_buff *skb); -void netvsc_linkstatus_callback(struct hv_device *device_obj, +void netvsc_linkstatus_callback(struct net_device *net, struct rndis_message *resp); int netvsc_recv_callback(struct net_device *net, struct vmbus_channel *channel, @@ -222,7 +222,6 @@ int rndis_filter_set_rss_param(struct rndis_device *rdev, const u8 *key); int rndis_filter_receive(struct net_device *ndev, struct netvsc_device *net_dev, - struct hv_device *dev, struct vmbus_channel *channel, void *data, u32 buflen); diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c index 9407907c4988..d8165407bcda 100644 --- a/drivers/net/hyperv/netvsc.c +++ b/drivers/net/hyperv/netvsc.c @@ -1077,7 +1077,7 @@ static int netvsc_receive(struct net_device *ndev, u32 buflen = vmxferpage_packet->ranges[i].byte_count; /* Pass it to the upper layer */ - status = rndis_filter_receive(ndev, net_device, device, + status = rndis_filter_receive(ndev, net_device, channel, data, buflen); } diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c index d16b68974d80..6f12f81fd8aa 100644 --- a/drivers/net/hyperv/netvsc_drv.c +++ b/drivers/net/hyperv/netvsc_drv.c @@ -656,22 +656,14 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net) /* * netvsc_linkstatus_callback - Link up/down notification */ -void netvsc_linkstatus_callback(struct hv_device *device_obj, +void netvsc_linkstatus_callback(struct net_device *net, struct rndis_message *resp) { struct rndis_indicate_status *indicate = &resp->msg.indicate_status; - struct net_device *net; - struct net_device_context *ndev_ctx; + struct net_device_context *ndev_ctx = netdev_priv(net); struct netvsc_reconfig *event; unsigned long flags; - net = hv_get_drvdata(device_obj); - - if (!net) - return; - - ndev_ctx = netdev_priv(net); - /* Update the physical link speed when changing to another vSwitch */ if (indicate->status == RNDIS_STATUS_LINK_SPEED_CHANGE) { u32 speed; diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c index 673492063307..901838b2bcc9 100644 --- a/drivers/net/hyperv/rndis_filter.c +++ b/drivers/net/hyperv/rndis_filter.c @@ -134,11 +134,9 @@ static void put_rndis_request(struct rndis_device *dev, kfree(req); } -static void dump_rndis_message(struct hv_device *hv_dev, +static void dump_rndis_message(struct net_device *netdev, const struct rndis_message *rndis_msg) { - struct net_device *netdev = hv_get_drvdata(hv_dev); - switch (rndis_msg->ndis_msg_type) { case RNDIS_MSG_PACKET: netdev_dbg(netdev, "RNDIS_MSG_PACKET (len %u, " @@ -397,7 +395,6 @@ static int rndis_filter_receive_data(struct net_device *ndev, int rndis_filter_receive(struct net_device *ndev, struct netvsc_device *net_dev, - struct hv_device *dev, struct vmbus_channel *channel, void *data, u32 buflen) { @@ -419,7 +416,7 @@ int rndis_filter_receive(struct net_device *ndev, } if (netif_msg_rx_status(net_device_ctx)) - dump_rndis_message(dev, rndis_msg); + dump_rndis_message(ndev, rndis_msg); switch (rndis_msg->ndis_msg_type) { case RNDIS_MSG_PACKET: @@ -434,7 +431,7 @@ int rndis_filter_receive(struct net_device *ndev, case RNDIS_MSG_INDICATE: /* notification msgs */ - netvsc_linkstatus_callback(dev, rndis_msg); + netvsc_linkstatus_callback(ndev, rndis_msg); break; default: netdev_err(ndev, From patchwork Wed Dec 13 00:48:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 847702 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=networkplumber-org.20150623.gappssmtp.com header.i=@networkplumber-org.20150623.gappssmtp.com header.b="ecJaTBmZ"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3yxJ3Y36gjz9t2W for ; Wed, 13 Dec 2017 11:48:57 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753049AbdLMAsz (ORCPT ); Tue, 12 Dec 2017 19:48:55 -0500 Received: from mail-pg0-f68.google.com ([74.125.83.68]:46033 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752984AbdLMAst (ORCPT ); Tue, 12 Dec 2017 19:48:49 -0500 Received: by mail-pg0-f68.google.com with SMTP id m25so525060pgv.12 for ; Tue, 12 Dec 2017 16:48:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=DvIY/wyfpc0AnHJaCN2XUntBWcX1hPqCZXquVXlwhZM=; b=ecJaTBmZFEoSNcq8Zifhf7tzFTLmXi+LQpc3XmOL97ZQORjbsLG7IYupGO8tJ/YB2D UTHlUnaZ9oa0fXozedIo7a3tYYE4WhC5Su9/Y3g2zfObKvl6lOnCp+erj8SVlpr2G+eT Ljj1CypDn2NT8L5lOHAvb3dc5bqcNedPtf7s9IcdZBe47WzpGFYVS4ttyaXSRVTN34Yc Y+lbVeBB5Nuh1sEZDA8m/Gm7BMrmnZxnBBmbAivjLyE18ZbwabN8DcZ6Md0/VkAhu7YW SYNDTAX0Utz3frjulHTqal5m/cfS2qvHdq/t2gHClWLbl8jPc69j8CPpParxFpB7dOLX 5BGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=DvIY/wyfpc0AnHJaCN2XUntBWcX1hPqCZXquVXlwhZM=; b=rADdOSdX82+Zd+symfsDL6i3ILIvrfjwteLM3s9Ei7f9YgR2cTOMV4/08hav5JAB0o ww8T2+DEqbp8e9Jkf96sXxAfb0AwokxJ32aSIoUfAP+g2LBsayv8gs+3hnB7o3lP98+M bPyjZGi5tGk5oZbXi/rVFJGIPQ5qKrQEQ9L9Y0XoBgATF+ns+kTfnZfhRKOEhl8MAdV3 6PRY7eOYUMgYTNqirtpaDuxuk9ZoqlAfEMcn1evIAhwK1dA8E1L4nXSyJsxRKJYe6Fbn zFPIXCc/ZN8rj5IICWuyKPu1sRPJc2jTaFafQcaZz5VYhZCgHeJ9qzN8tyRSTbPlZDCa 50Jg== X-Gm-Message-State: AKGB3mKGScJ2lF82jlPzbjV1bGawm30qLdiaKu61h3J+MWefvT19d2PN 16fEE3cPFNwZJ5lCbm/8zgh1sQ== X-Google-Smtp-Source: ACJfBou7mjHozaSiS9j85zvZkASiyT79hv5wrZz4ttxK6L5SYXrR1KRJ0lipE/TGC45LuJ4AaWH+4A== X-Received: by 10.99.111.206 with SMTP id k197mr3595936pgc.182.1513126128486; Tue, 12 Dec 2017 16:48:48 -0800 (PST) Received: from xeon-e3.wavecable.com (76-14-207-240.or.wavecable.com. [76.14.207.240]) by smtp.gmail.com with ESMTPSA id y131sm433692pfg.125.2017.12.12.16.48.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Dec 2017 16:48:47 -0800 (PST) From: Stephen Hemminger X-Google-Original-From: Stephen Hemminger To: kys@microsoft.com, haiyangz@microsoft.com, sthemmin@microsoft.com Cc: devel@linuxdriverproject.org, netdev@vger.kernel.org Subject: [PATCH net-next 4/6] hv_netvsc: pass netvsc_device to receive callback Date: Tue, 12 Dec 2017 16:48:38 -0800 Message-Id: <20171213004840.17507-5-sthemmin@microsoft.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171213004840.17507-1-sthemmin@microsoft.com> References: <20171213004840.17507-1-sthemmin@microsoft.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The netvsc_receive_callback function was using RCU to find the appropriate underlying netvsc_device. Since calling function already had that pointer, this was unnecessary. Signed-off-by: Stephen Hemminger --- drivers/net/hyperv/hyperv_net.h | 1 + drivers/net/hyperv/netvsc_drv.c | 14 ++------------ drivers/net/hyperv/rndis_filter.c | 7 +++++-- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h index 6463b7f5aa00..eb01943b23c3 100644 --- a/drivers/net/hyperv/hyperv_net.h +++ b/drivers/net/hyperv/hyperv_net.h @@ -202,6 +202,7 @@ int netvsc_send(struct net_device_context *ndc, void netvsc_linkstatus_callback(struct net_device *net, struct rndis_message *resp); int netvsc_recv_callback(struct net_device *net, + struct netvsc_device *nvdev, struct vmbus_channel *channel, void *data, u32 len, const struct ndis_tcp_ip_checksum_info *csum_info, diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c index 6f12f81fd8aa..36091ed570e2 100644 --- a/drivers/net/hyperv/netvsc_drv.c +++ b/drivers/net/hyperv/netvsc_drv.c @@ -743,34 +743,26 @@ static struct sk_buff *netvsc_alloc_recv_skb(struct net_device *net, * "wire" on the specified device. */ int netvsc_recv_callback(struct net_device *net, + struct netvsc_device *net_device, struct vmbus_channel *channel, void *data, u32 len, const struct ndis_tcp_ip_checksum_info *csum_info, const struct ndis_pkt_8021q_info *vlan) { struct net_device_context *net_device_ctx = netdev_priv(net); - struct netvsc_device *net_device; u16 q_idx = channel->offermsg.offer.sub_channel_index; - struct netvsc_channel *nvchan; + struct netvsc_channel *nvchan = &net_device->chan_table[q_idx]; struct sk_buff *skb; struct netvsc_stats *rx_stats; if (net->reg_state != NETREG_REGISTERED) return NVSP_STAT_FAIL; - rcu_read_lock(); - net_device = rcu_dereference(net_device_ctx->nvdev); - if (unlikely(!net_device)) - goto drop; - - nvchan = &net_device->chan_table[q_idx]; - /* Allocate a skb - TODO direct I/O to pages? */ skb = netvsc_alloc_recv_skb(net, &nvchan->napi, csum_info, vlan, data, len); if (unlikely(!skb)) { ++net_device_ctx->eth_stats.rx_no_memory; -drop: rcu_read_unlock(); return NVSP_STAT_FAIL; } @@ -794,8 +786,6 @@ int netvsc_recv_callback(struct net_device *net, u64_stats_update_end(&rx_stats->syncp); napi_gro_receive(&nvchan->napi, skb); - rcu_read_unlock(); - return 0; } diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c index 901838b2bcc9..025110a19d4a 100644 --- a/drivers/net/hyperv/rndis_filter.c +++ b/drivers/net/hyperv/rndis_filter.c @@ -352,6 +352,7 @@ static inline void *rndis_get_ppi(struct rndis_packet *rpkt, u32 type) } static int rndis_filter_receive_data(struct net_device *ndev, + struct netvsc_device *nvdev, struct rndis_device *dev, struct rndis_message *msg, struct vmbus_channel *channel, @@ -388,7 +389,8 @@ static int rndis_filter_receive_data(struct net_device *ndev, */ data = (void *)((unsigned long)data + data_offset); csum_info = rndis_get_ppi(rndis_pkt, TCPIP_CHKSUM_PKTINFO); - return netvsc_recv_callback(ndev, channel, + + return netvsc_recv_callback(ndev, nvdev, channel, data, rndis_pkt->data_len, csum_info, vlan); } @@ -420,7 +422,8 @@ int rndis_filter_receive(struct net_device *ndev, switch (rndis_msg->ndis_msg_type) { case RNDIS_MSG_PACKET: - return rndis_filter_receive_data(ndev, rndis_dev, rndis_msg, + return rndis_filter_receive_data(ndev, net_dev, + rndis_dev, rndis_msg, channel, data, buflen); case RNDIS_MSG_INIT_C: case RNDIS_MSG_QUERY_C: From patchwork Wed Dec 13 00:48:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 847709 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=networkplumber-org.20150623.gappssmtp.com header.i=@networkplumber-org.20150623.gappssmtp.com header.b="TDHnVGVU"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3yxJ671mdYz9t2W for ; Wed, 13 Dec 2017 11:51:11 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753034AbdLMAvH (ORCPT ); Tue, 12 Dec 2017 19:51:07 -0500 Received: from mail-pf0-f196.google.com ([209.85.192.196]:35986 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752914AbdLMAsu (ORCPT ); Tue, 12 Dec 2017 19:48:50 -0500 Received: by mail-pf0-f196.google.com with SMTP id p84so584845pfd.3 for ; Tue, 12 Dec 2017 16:48:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=jJ8ICprXCf5HtldvGigYWoJRRGF/I36dyRGSe0KbAuc=; b=TDHnVGVU98oq7JvRENRAjQAbwbIbvB+Lb7xb4ApjO4aqa9rF4opb3PspzC6fHl1ZbZ GPP1sS0PoUp49AdR+qYWbxHcAgU06NTZQ06LBt0Sf4sPfVPZlH7KD6IJFnyNKowFnDQn BnvTnq1Y0wGjEiwbXHO7EgTRN70850nllqDi1fhPPNUtA9nKYql3s+SefJbC6JmcFCUZ b2xiU7zf+zexZXQGMuOmtpMr3aqXlxAKFk1ZcPKn1GtrVYVo0cA2+uyQ1CJmzY8a5Url qmDkpPT2FIf4T+BfPQKKTJjAWmq/I7TuXakEFIrK7IM5vFWbw9yM62fy06r+ugF4vF4r UakQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=jJ8ICprXCf5HtldvGigYWoJRRGF/I36dyRGSe0KbAuc=; b=cdBmVrMxLmP8qG66tRK1gju1ZzWQDzX/JQPCAyHSjEZ8HzmYWdJwwOtGTYik2ORP3R 5DTSFKQI79h5j085/1JFkwdCOuSJKBlragUGmwwEwdnVl4grHVOJI5EGq2RDAcz1otlA BpLteeiD6kndbtTXeeYlhRQNfZklXDjrNP00NTFvLgR3zjpCmTbqqgN4Bz6QmXbTjP86 bVtMOWiuX+cEqsLnB6f6Rim9K9oZF2K9sh1MLSSW3lH0IXcjPwcdNw8o/qdvtJW4PZW1 pEpF7jLMQSoZpi75abDZOFH4qs3r5AHiQ+Ylz3TPMXzKRZDB149OhJQRiBTjmMw0Snjv BsMw== X-Gm-Message-State: AKGB3mKOHLW9nqmdI/Ih4ycx+44HdRGBFhBrHAbfhpPfigFw/Wd4rP4u jyfiFNR5XWrA8Jt5Ykl3w+2JPA== X-Google-Smtp-Source: ACJfBosV+JqTChkosi6+lp0lBq31ogy3HUShUJRcS+93DGmWqdl+pyLrOStre8haEYEGIcyIUiA/6A== X-Received: by 10.159.235.132 with SMTP id f4mr4083774plr.122.1513126129660; Tue, 12 Dec 2017 16:48:49 -0800 (PST) Received: from xeon-e3.wavecable.com (76-14-207-240.or.wavecable.com. [76.14.207.240]) by smtp.gmail.com with ESMTPSA id y131sm433692pfg.125.2017.12.12.16.48.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Dec 2017 16:48:48 -0800 (PST) From: Stephen Hemminger X-Google-Original-From: Stephen Hemminger To: kys@microsoft.com, haiyangz@microsoft.com, sthemmin@microsoft.com Cc: devel@linuxdriverproject.org, netdev@vger.kernel.org Subject: [PATCH net-next 5/6] hv_netvsc: remove open_cnt reference count Date: Tue, 12 Dec 2017 16:48:39 -0800 Message-Id: <20171213004840.17507-6-sthemmin@microsoft.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171213004840.17507-1-sthemmin@microsoft.com> References: <20171213004840.17507-1-sthemmin@microsoft.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org There is only ever a single instance of network device object referencing the internal rndis object. Therefore the open_cnt atomic is not necessary. Signed-off-by: Stephen Hemminger --- drivers/net/hyperv/hyperv_net.h | 2 -- drivers/net/hyperv/netvsc.c | 2 +- drivers/net/hyperv/rndis_filter.c | 10 +++------- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h index eb01943b23c3..8ebe72bf89ff 100644 --- a/drivers/net/hyperv/hyperv_net.h +++ b/drivers/net/hyperv/hyperv_net.h @@ -810,8 +810,6 @@ struct netvsc_device { u32 max_pkt; /* max number of pkt in one send, e.g. 8 */ u32 pkt_align; /* alignment bytes, e.g. 8 */ - atomic_t open_cnt; - struct netvsc_channel chan_table[VRSS_CHANNEL_MAX]; struct rcu_head rcu; diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c index d8165407bcda..6dd97f232f87 100644 --- a/drivers/net/hyperv/netvsc.c +++ b/drivers/net/hyperv/netvsc.c @@ -73,7 +73,7 @@ static struct netvsc_device *alloc_net_device(void) init_waitqueue_head(&net_device->wait_drain); net_device->destroy = false; - atomic_set(&net_device->open_cnt, 0); + net_device->max_pkt = RNDIS_MAX_PKT_DEFAULT; net_device->pkt_align = RNDIS_PKT_ALIGN_DEFAULT; diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c index 025110a19d4a..035976949177 100644 --- a/drivers/net/hyperv/rndis_filter.c +++ b/drivers/net/hyperv/rndis_filter.c @@ -1362,9 +1362,6 @@ int rndis_filter_open(struct netvsc_device *nvdev) if (!nvdev) return -EINVAL; - if (atomic_inc_return(&nvdev->open_cnt) != 1) - return 0; - return rndis_filter_open_device(nvdev->extension); } @@ -1373,13 +1370,12 @@ int rndis_filter_close(struct netvsc_device *nvdev) if (!nvdev) return -EINVAL; - if (atomic_dec_return(&nvdev->open_cnt) != 0) - return 0; - return rndis_filter_close_device(nvdev->extension); } bool rndis_filter_opened(const struct netvsc_device *nvdev) { - return atomic_read(&nvdev->open_cnt) > 0; + const struct rndis_device *dev = nvdev->extension; + + return dev->state == RNDIS_DEV_DATAINITIALIZED; } From patchwork Wed Dec 13 00:48:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 847703 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=networkplumber-org.20150623.gappssmtp.com header.i=@networkplumber-org.20150623.gappssmtp.com header.b="MGb8HFiA"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3yxJ3d727nz9t2W for ; Wed, 13 Dec 2017 11:49:01 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752858AbdLMAs7 (ORCPT ); Tue, 12 Dec 2017 19:48:59 -0500 Received: from mail-pf0-f196.google.com ([209.85.192.196]:40156 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753028AbdLMAsv (ORCPT ); Tue, 12 Dec 2017 19:48:51 -0500 Received: by mail-pf0-f196.google.com with SMTP id v26so577026pfl.7 for ; Tue, 12 Dec 2017 16:48:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=X5yAB5+sAH9/PogwynnEgk6kIpC724A7c/y9mISpkhY=; b=MGb8HFiAuZhU7zFx5gdNQI8u71s3CkwLEW2RsqnW48LKcF2BE6cFjJ9e+7M4wRibwi Mkqa7pZemgIUwexQPvdrY23bztzkgfZw1/0WpddlA1vh9qv3uQcGCiazU3G3pbxw44iu 4L+fwiZN418vxyWsR+EcOD3vvjd+NVe11FhwK7877sjz241WrxfPKbnin2v8tEMD5iUw YB6dO+aVH3gu5PxXkty6m45by1mpVSnW2gXZEwZLv5rkAHKKXc5Qjvh5UQBUNbfQCveB pl2WRmgnPa21CHfSd6+OIrBtgwdkpLhOcDu0GEKllRJcUjjt9WPFhq8UV8E9Sx7oEJho 7yhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=X5yAB5+sAH9/PogwynnEgk6kIpC724A7c/y9mISpkhY=; b=TfVORmdItlQ0n4nO+SeXEA7ItCZMx5Pph35s67pWhQuMks24v3XkYKMENMK2Tw/9oO Z5CSZqcF5vxO7fh3upOSZQBEwBRZdX4PZdRn8thnECsPCfV/arrOvdXKCNWTFG2f4Gor nxHEfO2cBRw3pQTmxBQ7N6KmIkcJZKmwr+i2IqZmx9x8R1DVLHrzpBQQeTk+c4ZiugTY 0cwKCVvMIw1zmzlHnRPlflFW+3uxj6OO61Oo7ydz4GLJ0DUO6w8evdzUOxZAvLyNc9Ll 9VPa4LT2wcDFRDA1hEdDr9UheI5K87tPkY0aRahRjoJUjK0sVzxaQKLO0R7poKGD/jUF LYVQ== X-Gm-Message-State: AKGB3mLpuuW2Q5IEi+NEv31gUKNCvm/zsaXx8F6z0x4z1i0aByf6KYGA RfsX6yu+kIDg46CHujkptDZ8dgMrdjo= X-Google-Smtp-Source: ACJfBoujjKutHuVFahwAUALo6CQYm66xY8nAoOBSOObrtpjeH1QBhJnptVLQLibX1ZhN7miI7lqbcQ== X-Received: by 10.84.177.129 with SMTP id x1mr4098164plb.217.1513126131006; Tue, 12 Dec 2017 16:48:51 -0800 (PST) Received: from xeon-e3.wavecable.com (76-14-207-240.or.wavecable.com. [76.14.207.240]) by smtp.gmail.com with ESMTPSA id y131sm433692pfg.125.2017.12.12.16.48.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Dec 2017 16:48:50 -0800 (PST) From: Stephen Hemminger X-Google-Original-From: Stephen Hemminger To: kys@microsoft.com, haiyangz@microsoft.com, sthemmin@microsoft.com Cc: devel@linuxdriverproject.org, netdev@vger.kernel.org Subject: [PATCH net-next 6/6] hv_netvsc: empty current transmit aggregation if flow blocked Date: Tue, 12 Dec 2017 16:48:40 -0800 Message-Id: <20171213004840.17507-7-sthemmin@microsoft.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171213004840.17507-1-sthemmin@microsoft.com> References: <20171213004840.17507-1-sthemmin@microsoft.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org If the transmit queue is known full, then don't keep aggregating data. And the cp_partial flag which indicates that the current aggregation buffer is full can be folded in to avoid more conditionals. Signed-off-by: Stephen Hemminger --- drivers/net/hyperv/hyperv_net.h | 2 +- drivers/net/hyperv/netvsc.c | 20 ++++++++++++++------ drivers/net/hyperv/netvsc_drv.c | 2 +- drivers/net/hyperv/rndis_filter.c | 3 +-- 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h index 8ebe72bf89ff..c46ecd8cb7cd 100644 --- a/drivers/net/hyperv/hyperv_net.h +++ b/drivers/net/hyperv/hyperv_net.h @@ -194,7 +194,7 @@ struct netvsc_device *netvsc_device_add(struct hv_device *device, const struct netvsc_device_info *info); int netvsc_alloc_recv_comp_ring(struct netvsc_device *net_device, u32 q_idx); void netvsc_device_remove(struct hv_device *device); -int netvsc_send(struct net_device_context *ndc, +int netvsc_send(struct net_device *net, struct hv_netvsc_packet *packet, struct rndis_message *rndis_msg, struct hv_page_buffer *page_buffer, diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c index 6dd97f232f87..66cfd0eb3434 100644 --- a/drivers/net/hyperv/netvsc.c +++ b/drivers/net/hyperv/netvsc.c @@ -702,7 +702,7 @@ static void netvsc_copy_to_send_buf(struct netvsc_device *net_device, struct hv_netvsc_packet *packet, struct rndis_message *rndis_msg, struct hv_page_buffer *pb, - struct sk_buff *skb) + bool xmit_more) { char *start = net_device->send_buf; char *dest = start + (section_index * net_device->send_section_size) @@ -715,7 +715,7 @@ static void netvsc_copy_to_send_buf(struct netvsc_device *net_device, /* Add padding */ remain = packet->total_data_buflen & (net_device->pkt_align - 1); - if (skb->xmit_more && remain && !packet->cp_partial) { + if (xmit_more && remain) { padding = net_device->pkt_align - remain; rndis_msg->msg_len += padding; packet->total_data_buflen += padding; @@ -824,12 +824,13 @@ static inline void move_pkt_msd(struct hv_netvsc_packet **msd_send, } /* RCU already held by caller */ -int netvsc_send(struct net_device_context *ndev_ctx, +int netvsc_send(struct net_device *ndev, struct hv_netvsc_packet *packet, struct rndis_message *rndis_msg, struct hv_page_buffer *pb, struct sk_buff *skb) { + struct net_device_context *ndev_ctx = netdev_priv(ndev); struct netvsc_device *net_device = rcu_dereference_bh(ndev_ctx->nvdev); struct hv_device *device = ndev_ctx->device_ctx; @@ -840,7 +841,7 @@ int netvsc_send(struct net_device_context *ndev_ctx, struct multi_send_data *msdp; struct hv_netvsc_packet *msd_send = NULL, *cur_send = NULL; struct sk_buff *msd_skb = NULL; - bool try_batch; + bool try_batch, xmit_more; /* If device is rescinded, return error and packet will get dropped. */ if (unlikely(!net_device || net_device->destroy)) @@ -891,10 +892,17 @@ int netvsc_send(struct net_device_context *ndev_ctx, } } + /* Keep aggregating only if stack says more data is coming + * and not doing mixed modes send and not flow blocked + */ + xmit_more = skb->xmit_more && + !packet->cp_partial && + !netif_xmit_stopped(netdev_get_tx_queue(ndev, packet->q_idx)); + if (section_index != NETVSC_INVALID_INDEX) { netvsc_copy_to_send_buf(net_device, section_index, msd_len, - packet, rndis_msg, pb, skb); + packet, rndis_msg, pb, xmit_more); packet->send_buf_index = section_index; @@ -914,7 +922,7 @@ int netvsc_send(struct net_device_context *ndev_ctx, if (msdp->skb) dev_consume_skb_any(msdp->skb); - if (skb->xmit_more && !packet->cp_partial) { + if (xmit_more) { msdp->skb = skb; msdp->pkt = packet; msdp->count++; diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c index 36091ed570e2..3737c1fefb04 100644 --- a/drivers/net/hyperv/netvsc_drv.c +++ b/drivers/net/hyperv/netvsc_drv.c @@ -630,7 +630,7 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net) /* timestamp packet in software */ skb_tx_timestamp(skb); - ret = netvsc_send(net_device_ctx, packet, rndis_msg, pb, skb); + ret = netvsc_send(net, packet, rndis_msg, pb, skb); if (likely(ret == 0)) return NETDEV_TX_OK; diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c index 035976949177..91a67c5297f7 100644 --- a/drivers/net/hyperv/rndis_filter.c +++ b/drivers/net/hyperv/rndis_filter.c @@ -215,7 +215,6 @@ static int rndis_filter_send_request(struct rndis_device *dev, struct hv_netvsc_packet *packet; struct hv_page_buffer page_buf[2]; struct hv_page_buffer *pb = page_buf; - struct net_device_context *net_device_ctx = netdev_priv(dev->ndev); int ret; /* Setup the packet to send it */ @@ -243,7 +242,7 @@ static int rndis_filter_send_request(struct rndis_device *dev, } rcu_read_lock_bh(); - ret = netvsc_send(net_device_ctx, packet, NULL, pb, NULL); + ret = netvsc_send(dev->ndev, packet, NULL, pb, NULL); rcu_read_unlock_bh(); return ret;