Skip to content

Commit

Permalink
hv_netvsc: replace divide with mask when computing padding
Browse files Browse the repository at this point in the history
Packet alignment is always a power of 2 therefore modulus can
be replaced with a faster and operation

Signed-off-by: Stephen Hemminger <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
shemminger authored and davem330 committed Dec 3, 2017
1 parent 200a569 commit b85e06f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/net/hyperv/netvsc.c
Original file line number Diff line number Diff line change
Expand Up @@ -712,11 +712,12 @@ static u32 netvsc_copy_to_send_buf(struct netvsc_device *net_device,
int i;
u32 msg_size = 0;
u32 padding = 0;
u32 remain = packet->total_data_buflen % net_device->pkt_align;
u32 page_count = packet->cp_partial ? packet->rmsg_pgcnt :
packet->page_buf_cnt;
u32 remain;

/* Add padding */
remain = packet->total_data_buflen & (net_device->pkt_align - 1);
if (skb->xmit_more && remain && !packet->cp_partial) {
padding = net_device->pkt_align - remain;
rndis_msg->msg_len += padding;
Expand Down

0 comments on commit b85e06f

Please sign in to comment.