Skip to content

Commit cfd8afd

Browse files
shemmingerdavem330
authored andcommitted
hv_netvsc: empty current transmit aggregation if flow blocked
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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 0da6edb commit cfd8afd

File tree

4 files changed

+17
-10
lines changed

4 files changed

+17
-10
lines changed

drivers/net/hyperv/hyperv_net.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ struct netvsc_device *netvsc_device_add(struct hv_device *device,
194194
const struct netvsc_device_info *info);
195195
int netvsc_alloc_recv_comp_ring(struct netvsc_device *net_device, u32 q_idx);
196196
void netvsc_device_remove(struct hv_device *device);
197-
int netvsc_send(struct net_device_context *ndc,
197+
int netvsc_send(struct net_device *net,
198198
struct hv_netvsc_packet *packet,
199199
struct rndis_message *rndis_msg,
200200
struct hv_page_buffer *page_buffer,

drivers/net/hyperv/netvsc.c

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@ static void netvsc_copy_to_send_buf(struct netvsc_device *net_device,
707707
struct hv_netvsc_packet *packet,
708708
struct rndis_message *rndis_msg,
709709
struct hv_page_buffer *pb,
710-
struct sk_buff *skb)
710+
bool xmit_more)
711711
{
712712
char *start = net_device->send_buf;
713713
char *dest = start + (section_index * net_device->send_section_size)
@@ -720,7 +720,7 @@ static void netvsc_copy_to_send_buf(struct netvsc_device *net_device,
720720

721721
/* Add padding */
722722
remain = packet->total_data_buflen & (net_device->pkt_align - 1);
723-
if (skb->xmit_more && remain && !packet->cp_partial) {
723+
if (xmit_more && remain) {
724724
padding = net_device->pkt_align - remain;
725725
rndis_msg->msg_len += padding;
726726
packet->total_data_buflen += padding;
@@ -829,12 +829,13 @@ static inline void move_pkt_msd(struct hv_netvsc_packet **msd_send,
829829
}
830830

831831
/* RCU already held by caller */
832-
int netvsc_send(struct net_device_context *ndev_ctx,
832+
int netvsc_send(struct net_device *ndev,
833833
struct hv_netvsc_packet *packet,
834834
struct rndis_message *rndis_msg,
835835
struct hv_page_buffer *pb,
836836
struct sk_buff *skb)
837837
{
838+
struct net_device_context *ndev_ctx = netdev_priv(ndev);
838839
struct netvsc_device *net_device
839840
= rcu_dereference_bh(ndev_ctx->nvdev);
840841
struct hv_device *device = ndev_ctx->device_ctx;
@@ -845,7 +846,7 @@ int netvsc_send(struct net_device_context *ndev_ctx,
845846
struct multi_send_data *msdp;
846847
struct hv_netvsc_packet *msd_send = NULL, *cur_send = NULL;
847848
struct sk_buff *msd_skb = NULL;
848-
bool try_batch;
849+
bool try_batch, xmit_more;
849850

850851
/* If device is rescinded, return error and packet will get dropped. */
851852
if (unlikely(!net_device || net_device->destroy))
@@ -896,10 +897,17 @@ int netvsc_send(struct net_device_context *ndev_ctx,
896897
}
897898
}
898899

900+
/* Keep aggregating only if stack says more data is coming
901+
* and not doing mixed modes send and not flow blocked
902+
*/
903+
xmit_more = skb->xmit_more &&
904+
!packet->cp_partial &&
905+
!netif_xmit_stopped(netdev_get_tx_queue(ndev, packet->q_idx));
906+
899907
if (section_index != NETVSC_INVALID_INDEX) {
900908
netvsc_copy_to_send_buf(net_device,
901909
section_index, msd_len,
902-
packet, rndis_msg, pb, skb);
910+
packet, rndis_msg, pb, xmit_more);
903911

904912
packet->send_buf_index = section_index;
905913

@@ -919,7 +927,7 @@ int netvsc_send(struct net_device_context *ndev_ctx,
919927
if (msdp->skb)
920928
dev_consume_skb_any(msdp->skb);
921929

922-
if (skb->xmit_more && !packet->cp_partial) {
930+
if (xmit_more) {
923931
msdp->skb = skb;
924932
msdp->pkt = packet;
925933
msdp->count++;

drivers/net/hyperv/netvsc_drv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net)
626626
/* timestamp packet in software */
627627
skb_tx_timestamp(skb);
628628

629-
ret = netvsc_send(net_device_ctx, packet, rndis_msg, pb, skb);
629+
ret = netvsc_send(net, packet, rndis_msg, pb, skb);
630630
if (likely(ret == 0))
631631
return NETDEV_TX_OK;
632632

drivers/net/hyperv/rndis_filter.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,6 @@ static int rndis_filter_send_request(struct rndis_device *dev,
215215
struct hv_netvsc_packet *packet;
216216
struct hv_page_buffer page_buf[2];
217217
struct hv_page_buffer *pb = page_buf;
218-
struct net_device_context *net_device_ctx = netdev_priv(dev->ndev);
219218
int ret;
220219

221220
/* Setup the packet to send it */
@@ -243,7 +242,7 @@ static int rndis_filter_send_request(struct rndis_device *dev,
243242
}
244243

245244
rcu_read_lock_bh();
246-
ret = netvsc_send(net_device_ctx, packet, NULL, pb, NULL);
245+
ret = netvsc_send(dev->ndev, packet, NULL, pb, NULL);
247246
rcu_read_unlock_bh();
248247

249248
return ret;

0 commit comments

Comments
 (0)