Skip to content

Commit

Permalink
Drivers: hv: vmbus: Add utility function for querying ring size
Browse files Browse the repository at this point in the history
Add a function to query for the preferred ring buffer size of VMBus
device. This will allow the drivers (eg. UIO) to allocate the most
optimized ring buffer size for devices.

Signed-off-by: Saurabh Sengar <[email protected]>
Reviewed-by: Long Li <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
Saurabh Sengar authored and gregkh committed Apr 11, 2024
1 parent a36b697 commit e8c4bd6
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
15 changes: 12 additions & 3 deletions drivers/hv/channel_mgmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,9 @@ const struct vmbus_device vmbus_devs[] = {
},

/* File copy */
{ .dev_type = HV_FCOPY,
/* fcopy always uses 16KB ring buffer size and is working well for last many years */
{ .pref_ring_size = 0x4000,
.dev_type = HV_FCOPY,
HV_FCOPY_GUID,
.perf_device = false,
.allowed_in_isolated = false,
Expand All @@ -140,12 +142,19 @@ const struct vmbus_device vmbus_devs[] = {
.allowed_in_isolated = false,
},

/* Unknown GUID */
{ .dev_type = HV_UNKNOWN,
/*
* Unknown GUID
* 64 KB ring buffer + 4 KB header should be sufficient size for any Hyper-V device apart
* from HV_NIC and HV_SCSI. This case avoid the fallback for unknown devices to allocate
* much bigger (2 MB) of ring size.
*/
{ .pref_ring_size = 0x11000,
.dev_type = HV_UNKNOWN,
.perf_device = false,
.allowed_in_isolated = false,
},
};
EXPORT_SYMBOL_GPL(vmbus_devs);

static const struct {
guid_t guid;
Expand Down
5 changes: 5 additions & 0 deletions drivers/hv/hyperv_vmbus.h
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,11 @@ static inline bool hv_is_perf_channel(struct vmbus_channel *channel)
return vmbus_devs[channel->device_id].perf_device;
}

static inline size_t hv_dev_ring_size(struct vmbus_channel *channel)
{
return vmbus_devs[channel->device_id].pref_ring_size;
}

static inline bool hv_is_allocated_cpu(unsigned int cpu)
{
struct vmbus_channel *channel, *sc;
Expand Down
2 changes: 2 additions & 0 deletions include/linux/hyperv.h
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,8 @@ struct vmbus_requestor {
#define VMBUS_RQST_RESET (U64_MAX - 3)

struct vmbus_device {
/* preferred ring buffer size in KB, 0 means no preferred size for this device */
size_t pref_ring_size;
u16 dev_type;
guid_t guid;
bool perf_device;
Expand Down

0 comments on commit e8c4bd6

Please sign in to comment.