This allows using deferred skb freeing and with NAPI. And get buffer recycling.
Unified · Split
| @@ -601,7 +601,8 @@ static inline void netvsc_free_send_slot(struct netvsc_device *net_device, · 600 unmodified lines | |||
| 601 | static void netvsc_send_tx_complete(struct netvsc_device *net_device, | 601 | static void netvsc_send_tx_complete(struct netvsc_device *net_device, |
| 602 | struct vmbus_channel *incoming_channel, | 602 | struct vmbus_channel *incoming_channel, |
| 603 | struct hv_device *device, | 603 | struct hv_device *device, |
| 604 | const struct vmpacket_descriptor *desc) | 604 | const struct vmpacket_descriptor *desc, |
| 605 | int budget) | ||
| 605 | { | 606 | { |
| 606 | struct sk_buff *skb = (struct sk_buff *)(unsigned long)desc->trans_id; | 607 | struct sk_buff *skb = (struct sk_buff *)(unsigned long)desc->trans_id; |
| 607 | struct net_device *ndev = hv_get_drvdata(device); | 608 | struct net_device *ndev = hv_get_drvdata(device); |
| @@ -628,7 +629,7 @@ static void netvsc_send_tx_complete(struct netvsc_device *net_device, · 20 unmodified lines | |||
| 628 | tx_stats->bytes += packet->total_bytes; | 629 | tx_stats->bytes += packet->total_bytes; |
| 629 | u64_stats_update_end(&tx_stats->syncp); | 630 | u64_stats_update_end(&tx_stats->syncp); |
| 630 | 631 | ||
| 631 | dev_consume_skb_any(skb); | 632 | napi_consume_skb(skb, budget); |
| 632 | } | 633 | } |
| 633 | 634 | ||
| 634 | queue_sends = | 635 | queue_sends = |
| @@ -646,7 +647,8 @@ static void netvsc_send_tx_complete(struct netvsc_device *net_device, · 11 unmodified lines | |||
| 646 | static void netvsc_send_completion(struct netvsc_device *net_device, | 647 | static void netvsc_send_completion(struct netvsc_device *net_device, |
| 647 | struct vmbus_channel *incoming_channel, | 648 | struct vmbus_channel *incoming_channel, |
| 648 | struct hv_device *device, | 649 | struct hv_device *device, |
| 649 | const struct vmpacket_descriptor *desc) | 650 | const struct vmpacket_descriptor *desc, |
| 651 | int budget) | ||
| 650 | { | 652 | { |
| 651 | struct nvsp_message *nvsp_packet = hv_pkt_data(desc); | 653 | struct nvsp_message *nvsp_packet = hv_pkt_data(desc); |
| 652 | struct net_device *ndev = hv_get_drvdata(device); | 654 | struct net_device *ndev = hv_get_drvdata(device); |
| @@ -664,7 +666,7 @@ static void netvsc_send_completion(struct netvsc_device *net_device, · 11 unmodified lines | |||
| 664 | 666 | ||
| 665 | case NVSP_MSG1_TYPE_SEND_RNDIS_PKT_COMPLETE: | 667 | case NVSP_MSG1_TYPE_SEND_RNDIS_PKT_COMPLETE: |
| 666 | netvsc_send_tx_complete(net_device, incoming_channel, | 668 | netvsc_send_tx_complete(net_device, incoming_channel, |
| 667 | device, desc); | 669 | device, desc, budget); |
| 668 | break; | 670 | break; |
| 669 | 671 | ||
| 670 | default: | 672 | default: |
| @@ -1174,14 +1176,16 @@ static int netvsc_process_raw_pkt(struct hv_device *device, · 503 unmodified lines | |||
| 1174 | struct vmbus_channel *channel, | 1176 | struct vmbus_channel *channel, |
| 1175 | struct netvsc_device *net_device, | 1177 | struct netvsc_device *net_device, |
| 1176 | struct net_device *ndev, | 1178 | struct net_device *ndev, |
| 1177 | const struct vmpacket_descriptor *desc) | 1179 | const struct vmpacket_descriptor *desc, |
| 1180 | int budget) | ||
| 1178 | { | 1181 | { |
| 1179 | struct net_device_context *net_device_ctx = netdev_priv(ndev); | 1182 | struct net_device_context *net_device_ctx = netdev_priv(ndev); |
| 1180 | struct nvsp_message *nvmsg = hv_pkt_data(desc); | 1183 | struct nvsp_message *nvmsg = hv_pkt_data(desc); |
| 1181 | 1184 | ||
| 1182 | switch (desc->type) { | 1185 | switch (desc->type) { |
| 1183 | case VM_PKT_COMP: | 1186 | case VM_PKT_COMP: |
| 1184 | netvsc_send_completion(net_device, channel, device, desc); | 1187 | netvsc_send_completion(net_device, channel, device, |
| 1188 | desc, budget); | ||
| 1185 | break; | 1189 | break; |
| 1186 | 1190 | ||
| 1187 | case VM_PKT_DATA_USING_XFER_PAGES: | 1191 | case VM_PKT_DATA_USING_XFER_PAGES: |
| @@ -1230,7 +1234,7 @@ int netvsc_poll(struct napi_struct *napi, int budget) · 42 unmodified lines | |||
| 1230 | 1234 | ||
| 1231 | while (nvchan->desc && work_done < budget) { | 1235 | while (nvchan->desc && work_done < budget) { |
| 1232 | work_done += netvsc_process_raw_pkt(device, channel, net_device, | 1236 | work_done += netvsc_process_raw_pkt(device, channel, net_device, |
| 1233 | ndev, nvchan->desc); | 1237 | ndev, nvchan->desc, budget); |
| 1234 | nvchan->desc = hv_pkt_iter_next(channel, nvchan->desc); | 1238 | nvchan->desc = hv_pkt_iter_next(channel, nvchan->desc); |
| 1235 | } | 1239 | } |
| 1236 | 1240 | ||