Netdev List
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org,
	Stephen Hemminger <stephen@networkplumber.org>,
	Stephen Hemminger <sthemmin@microsoft.com>
Subject: [PATCH net-stable 08/24] hv_netvsc: empty current transmit aggregation if flow blocked
Date: Mon, 14 May 2018 15:32:07 -0700	[thread overview]
Message-ID: <20180514223223.25433-9-sthemmin@microsoft.com> (raw)
In-Reply-To: <20180514223223.25433-1-sthemmin@microsoft.com>

From: Stephen Hemminger <stephen@networkplumber.org>

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 <sthemmin@microsoft.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
---
 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(-)

diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
index a3f628c3c9ed..fd51a329e36e 100644
--- a/drivers/net/hyperv/hyperv_net.h
+++ b/drivers/net/hyperv/hyperv_net.h
@@ -192,7 +192,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 4bc8a1d529d9..22da6399b37a 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -700,13 +700,13 @@ 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,
+				    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(struct netvsc_device *net_device,
 		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(struct netvsc_device *net_device,
 		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 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;
@@ -844,8 +844,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 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_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;
 
@@ -919,7 +925,7 @@ int netvsc_send(struct net_device_context *ndev_ctx,
 		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++;
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index cfaf433b0cda..b48a673d526d 100644
--- 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_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 be57639bee29..0c99d9926085 100644
--- a/drivers/net/hyperv/rndis_filter.c
+++ b/drivers/net/hyperv/rndis_filter.c
@@ -217,7 +217,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 */
@@ -245,7 +244,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;
-- 
2.17.0

  parent reply	other threads:[~2018-05-14 22:32 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-14 22:31 [PATCH net-stable 00/24] hv_netvsc patches for 4.14 stable Stephen Hemminger
2018-05-14 22:32 ` [PATCH net-stable 01/24] hv_netvsc: Fix the real number of queues of non-vRSS cases Stephen Hemminger
2018-05-14 22:32 ` [PATCH net-stable 02/24] hv_netvsc: Rename ind_table to rx_table Stephen Hemminger
2018-05-14 22:32 ` [PATCH net-stable 03/24] hv_netvsc: Rename tx_send_table to tx_table Stephen Hemminger
2018-05-14 22:32 ` [PATCH net-stable 04/24] hv_netvsc: Add initialization of tx_table in netvsc_device_add() Stephen Hemminger
2018-05-14 22:32 ` [PATCH net-stable 05/24] hv_netvsc: Set tx_table to equal weight after subchannels open Stephen Hemminger
2018-05-14 22:32 ` [PATCH net-stable 06/24] hv_netvsc: netvsc_teardown_gpadl() split Stephen Hemminger
2018-05-14 22:32 ` [PATCH net-stable 07/24] hv_netvsc: preserve hw_features on mtu/channels/ringparam changes Stephen Hemminger
2018-05-14 22:32 ` Stephen Hemminger [this message]
2018-05-14 22:32 ` [PATCH net-stable 09/24] hv_netvsc: Use the num_online_cpus() for channel limit Stephen Hemminger
2018-05-14 22:32 ` [PATCH net-stable 10/24] hv_netvsc: avoid retry on send during shutdown Stephen Hemminger
2018-05-14 22:32 ` [PATCH net-stable 11/24] hv_netvsc: only wake transmit queue if link is up Stephen Hemminger
2018-05-14 22:32 ` [PATCH net-stable 12/24] hv_netvsc: fix error unwind handling if vmbus_open fails Stephen Hemminger
2018-05-14 22:32 ` [PATCH net-stable 13/24] hv_netvsc: cancel subchannel setup before halting device Stephen Hemminger
2018-05-14 22:32 ` [PATCH net-stable 14/24] hv_netvsc: fix race in napi poll when rescheduling Stephen Hemminger
2018-05-14 22:32 ` [PATCH net-stable 15/24] hv_netvsc: defer queue selection to VF Stephen Hemminger
2018-05-14 22:32 ` [PATCH net-stable 16/24] hv_netvsc: disable NAPI before channel close Stephen Hemminger
2018-05-14 22:32 ` [PATCH net-stable 17/24] hv_netvsc: use RCU to fix concurrent rx and queue changes Stephen Hemminger
2018-05-14 22:32 ` [PATCH net-stable 18/24] hv_netvsc: change GPAD teardown order on older versions Stephen Hemminger
2018-05-14 22:32 ` [PATCH net-stable 19/24] hv_netvsc: common detach logic Stephen Hemminger
2018-05-14 22:32 ` [PATCH net-stable 20/24] hv_netvsc: Use Windows version instead of NVSP version on GPAD teardown Stephen Hemminger
2018-05-14 22:32 ` [PATCH net-stable 21/24] hv_netvsc: Split netvsc_revoke_buf() and netvsc_teardown_gpadl() Stephen Hemminger
2018-05-14 22:32 ` [PATCH net-stable 22/24] hv_netvsc: Ensure correct teardown message sequence order Stephen Hemminger
2018-05-14 22:32 ` [PATCH net-stable 23/24] hv_netvsc: Fix net device attach on older Windows hosts Stephen Hemminger
2018-05-14 22:32 ` [PATCH net-stable 24/24] hv_netvsc: set master device Stephen Hemminger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180514223223.25433-9-sthemmin@microsoft.com \
    --to=stephen@networkplumber.org \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=sthemmin@microsoft.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox