diff options
author | sephe <sephe@FreeBSD.org> | 2016-10-17 02:30:45 +0000 |
---|---|---|
committer | sephe <sephe@FreeBSD.org> | 2016-10-17 02:30:45 +0000 |
commit | c9e683c4be0e397b212dc77ae4ab277a64d07ab1 (patch) | |
tree | 9219a0a08354ef9ee4671f475d4c1aed493a6f70 /sys/dev/hyperv/include | |
parent | e51be1e422dd7678c3d84a237a733a854abfd9ee (diff) | |
download | FreeBSD-src-c9e683c4be0e397b212dc77ae4ab277a64d07ab1.zip FreeBSD-src-c9e683c4be0e397b212dc77ae4ab277a64d07ab1.tar.gz |
MFC 302875,302876,302878-302881
302875
hyperv/vmbus: Redefine channel packet.
The channel packet header will be shared w/ PRP (physical region page)
list channel packet and SG (scatter gather) list channel packet.
Sponsored by: Microsoft OSTC
Differential Revision: https://reviews.freebsd.org/D7155
302876
hyperv/vmbus: Rework sglist sending.
Sponsored by: Microsoft OSTC
Differential Revision: https://reviews.freebsd.org/D7156
302878
hyeprv/vmbus: Rework prplist sending.
Sponsored by: Microsoft OSTC
Differential Revision: https://reviews.freebsd.org/D7175
302879
hyperv/vmbus: Move channel packet flags definition to vmbus.h
Sponsored by: Microsoft OSTC
Differential Revision: https://reviews.freebsd.org/D7176
302880
hyperv/vmbus: Move channel packet types definition to vmbus.h
Sponsored by: Microsoft OSTC
Differential Revision: https://reviews.freebsd.org/D7177
302881
hyperv/vmbus: Cleanup channel sending
Sponsored by: Microsoft OSTC
Differential Revision: https://reviews.freebsd.org/D7178
Diffstat (limited to 'sys/dev/hyperv/include')
-rw-r--r-- | sys/dev/hyperv/include/hyperv.h | 63 | ||||
-rw-r--r-- | sys/dev/hyperv/include/vmbus.h | 69 |
2 files changed, 71 insertions, 61 deletions
diff --git a/sys/dev/hyperv/include/hyperv.h b/sys/dev/hyperv/include/hyperv.h index 9b59e20..7032794 100644 --- a/sys/dev/hyperv/include/hyperv.h +++ b/sys/dev/hyperv/include/hyperv.h @@ -82,19 +82,6 @@ typedef uint8_t hv_bool_uint8_t; #define VMBUS_VERSION_MAJOR(ver) (((uint32_t)(ver)) >> 16) #define VMBUS_VERSION_MINOR(ver) (((uint32_t)(ver)) & 0xffff) -#define HV_MAX_PAGE_BUFFER_COUNT 32 -#define HV_MAX_MULTIPAGE_BUFFER_COUNT 32 - -#define HV_ALIGN_UP(value, align) \ - (((value) & (align-1)) ? \ - (((value) + (align-1)) & ~(align-1) ) : (value)) - -#define HV_ALIGN_DOWN(value, align) ( (value) & ~(align-1) ) - -#define HV_NUM_PAGES_SPANNED(addr, len) \ - ((HV_ALIGN_UP(addr+len, PAGE_SIZE) - \ - HV_ALIGN_DOWN(addr, PAGE_SIZE)) >> PAGE_SHIFT ) - struct hyperv_guid { uint8_t hv_guid[16]; } __packed; @@ -125,25 +112,6 @@ typedef struct { hv_vm_transfer_page ranges[1]; } __packed hv_vm_transfer_page_packet_header; -typedef enum { - HV_VMBUS_PACKET_TYPE_INVALID = 0x0, - HV_VMBUS_PACKET_TYPES_SYNCH = 0x1, - HV_VMBUS_PACKET_TYPE_ADD_TRANSFER_PAGE_SET = 0x2, - HV_VMBUS_PACKET_TYPE_REMOVE_TRANSFER_PAGE_SET = 0x3, - HV_VMBUS_PACKET_TYPE_ESTABLISH_GPADL = 0x4, - HV_VMBUS_PACKET_TYPE_TEAR_DOWN_GPADL = 0x5, - HV_VMBUS_PACKET_TYPE_DATA_IN_BAND = 0x6, - HV_VMBUS_PACKET_TYPE_DATA_USING_TRANSFER_PAGES = 0x7, - HV_VMBUS_PACKET_TYPE_DATA_USING_GPADL = 0x8, - HV_VMBUS_PACKET_TYPE_DATA_USING_GPA_DIRECT = 0x9, - HV_VMBUS_PACKET_TYPE_CANCEL_REQUEST = 0xa, - HV_VMBUS_PACKET_TYPE_COMPLETION = 0xb, - HV_VMBUS_PACKET_TYPE_DATA_USING_ADDITIONAL_PACKETS = 0xc, - HV_VMBUS_PACKET_TYPE_ADDITIONAL_DATA = 0xd -} hv_vmbus_packet_type; - -#define HV_VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED 1 - #define HW_MACADDR_LEN 6 /* @@ -225,18 +193,6 @@ typedef struct { } __packed hv_vmbus_ring_buffer; typedef struct { - int length; - int offset; - uint64_t pfn; -} __packed hv_vmbus_page_buffer; - -typedef struct { - int length; - int offset; - uint64_t pfn_array[HV_MAX_MULTIPAGE_BUFFER_COUNT]; -} __packed hv_vmbus_multipage_buffer; - -typedef struct { hv_vmbus_ring_buffer* ring_buffer; struct mtx ring_lock; uint32_t ring_data_size; /* ring_size */ @@ -372,23 +328,8 @@ int hv_vmbus_channel_send_packet( void* buffer, uint32_t buffer_len, uint64_t request_id, - hv_vmbus_packet_type type, - uint32_t flags); - -int hv_vmbus_channel_send_packet_pagebuffer( - hv_vmbus_channel* channel, - hv_vmbus_page_buffer page_buffers[], - uint32_t page_count, - void* buffer, - uint32_t buffer_len, - uint64_t request_id); - -int hv_vmbus_channel_send_packet_multipagebuffer( - hv_vmbus_channel* channel, - hv_vmbus_multipage_buffer* multi_page_buffer, - void* buffer, - uint32_t buffer_len, - uint64_t request_id); + uint16_t type, + uint16_t flags); int hv_vmbus_channel_establish_gpadl( hv_vmbus_channel* channel, diff --git a/sys/dev/hyperv/include/vmbus.h b/sys/dev/hyperv/include/vmbus.h new file mode 100644 index 0000000..1960e84 --- /dev/null +++ b/sys/dev/hyperv/include/vmbus.h @@ -0,0 +1,69 @@ +/*- + * Copyright (c) 2016 Microsoft Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, this list of conditions, and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _VMBUS_H_ +#define _VMBUS_H_ + +#include <sys/param.h> + +/* + * GPA stuffs. + */ +struct vmbus_gpa_range { + uint32_t gpa_len; + uint32_t gpa_ofs; + uint64_t gpa_page[0]; +} __packed; + +/* This is actually vmbus_gpa_range.gpa_page[1] */ +struct vmbus_gpa { + uint32_t gpa_len; + uint32_t gpa_ofs; + uint64_t gpa_page; +} __packed; + +#define VMBUS_CHANPKT_TYPE_INBAND 0x0006 +#define VMBUS_CHANPKT_TYPE_RXBUF 0x0007 +#define VMBUS_CHANPKT_TYPE_GPA 0x0009 +#define VMBUS_CHANPKT_TYPE_COMP 0x000b + +#define VMBUS_CHANPKT_FLAG_RC 0x0001 /* report completion */ + +#define VMBUS_CHAN_SGLIST_MAX 32 +#define VMBUS_CHAN_PRPLIST_MAX 32 + +struct hv_vmbus_channel; + +int vmbus_chan_send_sglist(struct hv_vmbus_channel *chan, + struct vmbus_gpa sg[], int sglen, void *data, int dlen, + uint64_t xactid); +int vmbus_chan_send_prplist(struct hv_vmbus_channel *chan, + struct vmbus_gpa_range *prp, int prp_cnt, void *data, int dlen, + uint64_t xactid); + +#endif /* !_VMBUS_H_ */ |