Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2006790imm; Thu, 24 May 2018 04:24:41 -0700 (PDT) X-Google-Smtp-Source: AB8JxZo32a1CGDUizGgwe4FUPYlcCEnBgRkAOwHxgUDAI0KYHnnIAiw3OOIgIE0ykHrhpD0jOS5y X-Received: by 2002:a65:6085:: with SMTP id t5-v6mr5645176pgu.362.1527161081576; Thu, 24 May 2018 04:24:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527161081; cv=none; d=google.com; s=arc-20160816; b=hcPFQDrVmW9AX4pAOkWS5f8FW5vHLKCvAWwtZQiTOtyyg8H8g+YT/Z0gfCX2RTwNbF M3XsQWeSx1Fyp7GJGWAPv6gOqd0OYEl024FK0C41ImZVGx+FnMpKBBSuU+LaVMXcCDum 7AgETj1zZ1OML1bGoojqwLl3GzeZivpx8sGp+mcw0ZxIQJxWrU2Byb/jM7jA9dVs52ah L/x87k3dbOXVPpwhU5SBtzDdozbqWlkoUKad0DI1r/W2PNHGEcCiKSsscevrrsvpDj4G MP7+nH1X9/YK+uqSvdoEHO7bIQqLOajoKez23ymPRy9Mx4PsBDtjh7MfqHYorUJZbNC5 MIKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=OKcWu7AsyAjuoFv58Pngt/iUG/wuGVJ9ZtCt677/I6U=; b=KgoOJiXbSR6QU6AQOv5/0AszRliqYc/BO9z424du6UC0VYNBzJ5zpEzha23S8q3j3F qnCd5uJHEpH3X6iGOg2Y2uSfWtkBKdrmXkQTeUPCx+rEQY20fHVZ2j62HyJd6Fnb7q7y xVJ5eVSLtorMzhBvYzp7jjEaH3s+ic2Evlk3SqgRRgeSzF+GfDys7Hz2Utq5IhBk1c0W UREqLuz9L46pQdzSo8z17uDZp8cJD9BPG5hvJ/TciyKWalWmanoCo0/moo2cTDZo2CBU 5aShTCsRSpom6waOiC02LcIAV8JR45y0GIkkkM+YTpjZE6+/SJ4G3FmYchBP1S5BW7O2 oY6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ry5jRRTf; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i73-v6si21984923pfe.27.2018.05.24.04.24.26; Thu, 24 May 2018 04:24:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ry5jRRTf; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S967812AbeEXJwH (ORCPT + 99 others); Thu, 24 May 2018 05:52:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:48640 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S967806AbeEXJwA (ORCPT ); Thu, 24 May 2018 05:52:00 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6B0CE20847; Thu, 24 May 2018 09:51:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527155519; bh=dIDQu0tXlNY/6fcGziCx+c6x6+fnlxK5wA8Hv3LiQ7c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ry5jRRTfH6Fvl8cqmvw+UFko0xAXNrdlP5JMSZ/AA0wSSfFrwdl7NpJXa4WR3aquc pPu23MK9UU7CccWJ1wcHoTfQSzg/0QtaU1AmxEj8SGRMOIrfpl2OgweffZ5r5//5Vf zmV+ghLMmps2hWjLPDeFKluGXlx9qGsQM78BAp0g= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Stephen Hemminger , "David S. Miller" Subject: [PATCH 4.14 019/165] hv_netvsc: empty current transmit aggregation if flow blocked Date: Thu, 24 May 2018 11:37:05 +0200 Message-Id: <20180524093622.762630373@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524093621.979359379@linuxfoundation.org> References: <20180524093621.979359379@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Stephen Hemminger [ Commit cfd8afd986cdb59ea9adac873c5082498a1eb7c0 upstream. ] 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 Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/hyperv/hyperv_net.h | 2 +- drivers/net/hyperv/netvsc.c | 36 +++++++++++++++++++++--------------- drivers/net/hyperv/netvsc_drv.c | 2 +- drivers/net/hyperv/rndis_filter.c | 3 +-- 4 files changed, 24 insertions(+), 19 deletions(-) --- a/drivers/net/hyperv/hyperv_net.h +++ b/drivers/net/hyperv/hyperv_net.h @@ -192,7 +192,7 @@ struct netvsc_device *netvsc_device_add( 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, --- a/drivers/net/hyperv/netvsc.c +++ b/drivers/net/hyperv/netvsc.c @@ -700,13 +700,13 @@ static u32 netvsc_get_next_send_section( 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, + bool xmit_more) { char *start = net_device->send_buf; char *dest = start + (section_index * net_device->send_section_size) @@ -719,7 +719,8 @@ static u32 netvsc_copy_to_send_buf(struc packet->page_buf_cnt; /* Add padding */ - if (skb->xmit_more && remain && !packet->cp_partial) { + remain = packet->total_data_buflen & (net_device->pkt_align - 1); + if (xmit_more && remain) { padding = net_device->pkt_align - remain; rndis_msg->msg_len += padding; packet->total_data_buflen += padding; @@ -739,8 +740,6 @@ static u32 netvsc_copy_to_send_buf(struc memset(dest, 0, padding); msg_size += padding; } - - return msg_size; } static inline int netvsc_send_pkt( @@ -828,12 +827,13 @@ static inline void move_pkt_msd(struct h } /* 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; @@ -844,8 +844,7 @@ int netvsc_send(struct net_device_contex 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 xmit_more = (skb != NULL) ? skb->xmit_more : false; + bool try_batch, xmit_more; /* If device is rescinded, return error and packet will get dropped. */ if (unlikely(!net_device || net_device->destroy)) @@ -896,10 +895,17 @@ int netvsc_send(struct net_device_contex } } + /* 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; @@ -919,7 +925,7 @@ int netvsc_send(struct net_device_contex if (msdp->skb) dev_consume_skb_any(msdp->skb); - if (xmit_more && !packet->cp_partial) { + if (xmit_more) { msdp->skb = skb; msdp->pkt = packet; msdp->count++; --- a/drivers/net/hyperv/netvsc_drv.c +++ b/drivers/net/hyperv/netvsc_drv.c @@ -614,7 +614,7 @@ static int netvsc_start_xmit(struct sk_b /* 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; --- a/drivers/net/hyperv/rndis_filter.c +++ b/drivers/net/hyperv/rndis_filter.c @@ -217,7 +217,6 @@ static int rndis_filter_send_request(str 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 */ @@ -245,7 +244,7 @@ static int rndis_filter_send_request(str } 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;