svn commit: r304790 - in head/sys/dev/hyperv: include vmbus
Sepherosa Ziehau
sephe at FreeBSD.org
Thu Aug 25 05:35:52 UTC 2016
Author: sephe
Date: Thu Aug 25 05:35:51 2016
New Revision: 304790
URL: https://svnweb.freebsd.org/changeset/base/304790
Log:
hyperv/vmbus: Add function to calculate max # of elements in a bufring.
MFC after: 1 week
Sponsored by: Microsoft
Modified:
head/sys/dev/hyperv/include/vmbus.h
head/sys/dev/hyperv/vmbus/vmbus_brvar.h
head/sys/dev/hyperv/vmbus/vmbus_chan.c
Modified: head/sys/dev/hyperv/include/vmbus.h
==============================================================================
--- head/sys/dev/hyperv/include/vmbus.h Thu Aug 25 05:28:02 2016 (r304789)
+++ head/sys/dev/hyperv/include/vmbus.h Thu Aug 25 05:35:51 2016 (r304790)
@@ -161,5 +161,7 @@ uint32_t vmbus_chan_subidx(const struct
bool vmbus_chan_is_primary(const struct vmbus_channel *chan);
const struct hyperv_guid *
vmbus_chan_guid_inst(const struct vmbus_channel *chan);
+int vmbus_chan_prplist_nelem(int br_size, int prpcnt_max,
+ int dlen_max);
#endif /* !_VMBUS_H_ */
Modified: head/sys/dev/hyperv/vmbus/vmbus_brvar.h
==============================================================================
--- head/sys/dev/hyperv/vmbus/vmbus_brvar.h Thu Aug 25 05:28:02 2016 (r304789)
+++ head/sys/dev/hyperv/vmbus/vmbus_brvar.h Thu Aug 25 05:35:51 2016 (r304790)
@@ -74,6 +74,7 @@ struct sysctl_oid;
static __inline int
vmbus_txbr_maxpktsz(const struct vmbus_txbr *tbr)
{
+
/*
* - 64 bits for the trailing start index (- sizeof(uint64_t)).
* - The rindex and windex can't be same (- 1). See
@@ -82,6 +83,17 @@ vmbus_txbr_maxpktsz(const struct vmbus_t
return (tbr->txbr_dsize - sizeof(uint64_t) - 1);
}
+static __inline int
+vmbus_br_nelem(int br_size, int elem_size)
+{
+
+ /* Strip bufring header */
+ br_size -= sizeof(struct vmbus_bufring);
+ /* Add per-element trailing index */
+ elem_size += sizeof(uint64_t);
+ return (br_size / elem_size);
+}
+
void vmbus_br_sysctl_create(struct sysctl_ctx_list *ctx,
struct sysctl_oid *br_tree, struct vmbus_br *br,
const char *name);
Modified: head/sys/dev/hyperv/vmbus/vmbus_chan.c
==============================================================================
--- head/sys/dev/hyperv/vmbus/vmbus_chan.c Thu Aug 25 05:28:02 2016 (r304789)
+++ head/sys/dev/hyperv/vmbus/vmbus_chan.c Thu Aug 25 05:35:51 2016 (r304790)
@@ -1411,3 +1411,16 @@ vmbus_chan_guid_inst(const struct vmbus_
{
return &chan->ch_guid_inst;
}
+
+int
+vmbus_chan_prplist_nelem(int br_size, int prpcnt_max, int dlen_max)
+{
+ int elem_size;
+
+ elem_size = __offsetof(struct vmbus_chanpkt_prplist,
+ cp_range[0].gpa_page[prpcnt_max]);
+ elem_size += dlen_max;
+ elem_size = VMBUS_CHANPKT_TOTLEN(elem_size);
+
+ return (vmbus_br_nelem(br_size, elem_size));
+}
More information about the svn-src-head
mailing list