hyperv/vmbus: Add function to calculate max # of elements in a bufring.
MFC after: 1 week Sponsored by: Microsoft
This commit is contained in:
parent
b7c48d9ccc
commit
b864f0ef69
@ -161,5 +161,7 @@ uint32_t vmbus_chan_subidx(const struct vmbus_channel *chan);
|
|||||||
bool vmbus_chan_is_primary(const struct vmbus_channel *chan);
|
bool vmbus_chan_is_primary(const struct vmbus_channel *chan);
|
||||||
const struct hyperv_guid *
|
const struct hyperv_guid *
|
||||||
vmbus_chan_guid_inst(const struct vmbus_channel *chan);
|
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_ */
|
#endif /* !_VMBUS_H_ */
|
||||||
|
@ -74,6 +74,7 @@ struct sysctl_oid;
|
|||||||
static __inline int
|
static __inline int
|
||||||
vmbus_txbr_maxpktsz(const struct vmbus_txbr *tbr)
|
vmbus_txbr_maxpktsz(const struct vmbus_txbr *tbr)
|
||||||
{
|
{
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* - 64 bits for the trailing start index (- sizeof(uint64_t)).
|
* - 64 bits for the trailing start index (- sizeof(uint64_t)).
|
||||||
* - The rindex and windex can't be same (- 1). See
|
* - The rindex and windex can't be same (- 1). See
|
||||||
@ -82,6 +83,17 @@ vmbus_txbr_maxpktsz(const struct vmbus_txbr *tbr)
|
|||||||
return (tbr->txbr_dsize - sizeof(uint64_t) - 1);
|
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,
|
void vmbus_br_sysctl_create(struct sysctl_ctx_list *ctx,
|
||||||
struct sysctl_oid *br_tree, struct vmbus_br *br,
|
struct sysctl_oid *br_tree, struct vmbus_br *br,
|
||||||
const char *name);
|
const char *name);
|
||||||
|
@ -1411,3 +1411,16 @@ vmbus_chan_guid_inst(const struct vmbus_channel *chan)
|
|||||||
{
|
{
|
||||||
return &chan->ch_guid_inst;
|
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));
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user