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.

MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D7155
This commit is contained in:
sephe 2016-07-15 06:16:39 +00:00
parent f7879d9f33
commit 2bab08ccf2
2 changed files with 32 additions and 12 deletions

View File

@ -634,27 +634,28 @@ hv_vmbus_channel_send_packet(
uint32_t flags) uint32_t flags)
{ {
int ret = 0; int ret = 0;
hv_vm_packet_descriptor desc; struct vmbus_chanpkt pkt;
uint32_t packet_len; uint32_t packet_len;
uint64_t aligned_data; uint64_t aligned_data;
uint32_t packet_len_aligned; uint32_t packet_len_aligned;
boolean_t need_sig; boolean_t need_sig;
struct iovec iov[3]; struct iovec iov[3];
packet_len = sizeof(hv_vm_packet_descriptor) + buffer_len; packet_len = sizeof(pkt) + buffer_len;
packet_len_aligned = HV_ALIGN_UP(packet_len, sizeof(uint64_t)); packet_len_aligned = roundup2(packet_len, VMBUS_CHANPKT_SIZE_ALIGN);
aligned_data = 0; aligned_data = 0;
/* Setup the descriptor */ /*
desc.type = type; /* HV_VMBUS_PACKET_TYPE_DATA_IN_BAND; */ * Setup channel packet.
desc.flags = flags; /* HV_VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED */ */
/* in 8-bytes granularity */ pkt.cp_hdr.cph_type = type;
desc.data_offset8 = sizeof(hv_vm_packet_descriptor) >> 3; pkt.cp_hdr.cph_flags = flags;
desc.length8 = (uint16_t) (packet_len_aligned >> 3); pkt.cp_hdr.cph_data_ofs = sizeof(pkt) >> VMBUS_CHANPKT_SIZE_SHIFT;
desc.transaction_id = request_id; pkt.cp_hdr.cph_len = packet_len_aligned >> VMBUS_CHANPKT_SIZE_SHIFT;
pkt.cp_hdr.cph_xactid = request_id;
iov[0].iov_base = &desc; iov[0].iov_base = &pkt;
iov[0].iov_len = sizeof(hv_vm_packet_descriptor); iov[0].iov_len = sizeof(pkt);
iov[1].iov_base = buffer; iov[1].iov_base = buffer;
iov[1].iov_len = buffer_len; iov[1].iov_len = buffer_len;

View File

@ -116,6 +116,25 @@ struct vmbus_gpa_range {
uint64_t gpa_page[]; uint64_t gpa_page[];
} __packed; } __packed;
/*
* Channel packets
*/
#define VMBUS_CHANPKT_SIZE_SHIFT 3
#define VMBUS_CHANPKT_SIZE_ALIGN (1 << VMBUS_CHANPKT_SIZE_SHIFT)
struct vmbus_chanpkt_hdr {
uint16_t cph_type;
uint16_t cph_data_ofs; /* in 8 bytes */
uint16_t cph_len; /* in 8 bytes */
uint16_t cph_flags;
uint64_t cph_xactid;
} __packed;
struct vmbus_chanpkt {
struct vmbus_chanpkt_hdr cp_hdr;
} __packed;
/* /*
* Channel messages * Channel messages
* - Embedded in vmbus_message.msg_data, e.g. response and notification. * - Embedded in vmbus_message.msg_data, e.g. response and notification.