diff options
| author | Stephen Hemminger <sthemmin@microsoft.com> | 2016-08-23 15:17:48 -0400 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2016-08-23 15:05:36 -0400 |
| commit | 30d1de08c87ddde6f73936c3350e7e153988fe02 (patch) | |
| tree | 5a4a6a71197554762f5deec5909cfbc1e0c308f6 /drivers/net/hyperv | |
| parent | 796cc88c32c1bd1f833d596448ac785a8736e57c (diff) | |
hv_netvsc: make inline functions static
Several new functions were introduced into hyperv.h but only used in one file.
Move them and let compiler decide on inline.
Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/hyperv')
| -rw-r--r-- | drivers/net/hyperv/netvsc.c | 85 |
1 files changed, 84 insertions, 1 deletions
diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c index fe83de33895d..4ef2af63419f 100644 --- a/drivers/net/hyperv/netvsc.c +++ b/drivers/net/hyperv/netvsc.c | |||
| @@ -34,6 +34,89 @@ | |||
| 34 | #include "hyperv_net.h" | 34 | #include "hyperv_net.h" |
| 35 | 35 | ||
| 36 | /* | 36 | /* |
| 37 | * An API to support in-place processing of incoming VMBUS packets. | ||
| 38 | */ | ||
| 39 | #define VMBUS_PKT_TRAILER 8 | ||
| 40 | |||
| 41 | static struct vmpacket_descriptor * | ||
| 42 | get_next_pkt_raw(struct vmbus_channel *channel) | ||
| 43 | { | ||
| 44 | struct hv_ring_buffer_info *ring_info = &channel->inbound; | ||
| 45 | u32 read_loc = ring_info->priv_read_index; | ||
| 46 | void *ring_buffer = hv_get_ring_buffer(ring_info); | ||
| 47 | struct vmpacket_descriptor *cur_desc; | ||
| 48 | u32 packetlen; | ||
| 49 | u32 dsize = ring_info->ring_datasize; | ||
| 50 | u32 delta = read_loc - ring_info->ring_buffer->read_index; | ||
| 51 | u32 bytes_avail_toread = (hv_get_bytes_to_read(ring_info) - delta); | ||
| 52 | |||
| 53 | if (bytes_avail_toread < sizeof(struct vmpacket_descriptor)) | ||
| 54 | return NULL; | ||
| 55 | |||
| 56 | if ((read_loc + sizeof(*cur_desc)) > dsize) | ||
| 57 | return NULL; | ||
| 58 | |||
| 59 | cur_desc = ring_buffer + read_loc; | ||
| 60 | packetlen = cur_desc->len8 << 3; | ||
| 61 | |||
| 62 | /* | ||
| 63 | * If the packet under consideration is wrapping around, | ||
| 64 | * return failure. | ||
| 65 | */ | ||
| 66 | if ((read_loc + packetlen + VMBUS_PKT_TRAILER) > (dsize - 1)) | ||
| 67 | return NULL; | ||
| 68 | |||
| 69 | return cur_desc; | ||
| 70 | } | ||
| 71 | |||
| 72 | /* | ||
| 73 | * A helper function to step through packets "in-place" | ||
| 74 | * This API is to be called after each successful call | ||
| 75 | * get_next_pkt_raw(). | ||
| 76 | */ | ||
| 77 | static void put_pkt_raw(struct vmbus_channel *channel, | ||
| 78 | struct vmpacket_descriptor *desc) | ||
| 79 | { | ||
| 80 | struct hv_ring_buffer_info *ring_info = &channel->inbound; | ||
| 81 | u32 read_loc = ring_info->priv_read_index; | ||
| 82 | u32 packetlen = desc->len8 << 3; | ||
| 83 | u32 dsize = ring_info->ring_datasize; | ||
| 84 | |||
| 85 | BUG_ON((read_loc + packetlen + VMBUS_PKT_TRAILER) > dsize); | ||
| 86 | |||
| 87 | /* | ||
| 88 | * Include the packet trailer. | ||
| 89 | */ | ||
| 90 | ring_info->priv_read_index += packetlen + VMBUS_PKT_TRAILER; | ||
| 91 | } | ||
| 92 | |||
| 93 | /* | ||
| 94 | * This call commits the read index and potentially signals the host. | ||
| 95 | * Here is the pattern for using the "in-place" consumption APIs: | ||
| 96 | * | ||
| 97 | * while (get_next_pkt_raw() { | ||
| 98 | * process the packet "in-place"; | ||
| 99 | * put_pkt_raw(); | ||
| 100 | * } | ||
| 101 | * if (packets processed in place) | ||
| 102 | * commit_rd_index(); | ||
| 103 | */ | ||
| 104 | static void commit_rd_index(struct vmbus_channel *channel) | ||
| 105 | { | ||
| 106 | struct hv_ring_buffer_info *ring_info = &channel->inbound; | ||
| 107 | /* | ||
| 108 | * Make sure all reads are done before we update the read index since | ||
| 109 | * the writer may start writing to the read area once the read index | ||
| 110 | * is updated. | ||
| 111 | */ | ||
| 112 | virt_rmb(); | ||
| 113 | ring_info->ring_buffer->read_index = ring_info->priv_read_index; | ||
| 114 | |||
| 115 | if (hv_need_to_signal_on_read(ring_info)) | ||
| 116 | vmbus_set_event(channel); | ||
| 117 | } | ||
| 118 | |||
| 119 | /* | ||
| 37 | * Switch the data path from the synthetic interface to the VF | 120 | * Switch the data path from the synthetic interface to the VF |
| 38 | * interface. | 121 | * interface. |
| 39 | */ | 122 | */ |
| @@ -749,7 +832,7 @@ static u32 netvsc_copy_to_send_buf(struct netvsc_device *net_device, | |||
| 749 | return msg_size; | 832 | return msg_size; |
| 750 | } | 833 | } |
| 751 | 834 | ||
| 752 | static inline int netvsc_send_pkt( | 835 | static int netvsc_send_pkt( |
| 753 | struct hv_device *device, | 836 | struct hv_device *device, |
| 754 | struct hv_netvsc_packet *packet, | 837 | struct hv_netvsc_packet *packet, |
| 755 | struct netvsc_device *net_device, | 838 | struct netvsc_device *net_device, |
