Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F154357011
D7268.id18621.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
5 KB
Referenced Files
None
Subscribers
None
D7268.id18621.diff
View Options
Index: sys/dev/hyperv/vmbus/hv_ring_buffer.c
===================================================================
--- sys/dev/hyperv/vmbus/hv_ring_buffer.c
+++ sys/dev/hyperv/vmbus/hv_ring_buffer.c
@@ -44,36 +44,74 @@
char *dest, uint32_t dest_len, uint32_t start_read_offset);
static int
-hv_rbi_sysctl_stats(SYSCTL_HANDLER_ARGS)
+vmbus_br_sysctl_state(SYSCTL_HANDLER_ARGS)
{
- hv_vmbus_ring_buffer_info* rbi;
- uint32_t read_index, write_index, interrupt_mask, sz;
- uint32_t read_avail, write_avail;
- char rbi_stats[256];
-
- rbi = (hv_vmbus_ring_buffer_info*)arg1;
- read_index = rbi->ring_buffer->read_index;
- write_index = rbi->ring_buffer->write_index;
- interrupt_mask = rbi->ring_buffer->interrupt_mask;
- sz = rbi->ring_data_size;
- write_avail = HV_BYTES_AVAIL_TO_WRITE(read_index,
- write_index, sz);
- read_avail = sz - write_avail;
-
- snprintf(rbi_stats, sizeof(rbi_stats),
- "r_idx:%d w_idx:%d int_mask:%d r_avail:%d w_avail:%d",
- read_index, write_index, interrupt_mask, read_avail, write_avail);
- return sysctl_handle_string(oidp, rbi_stats, sizeof(rbi_stats), req);
+ const hv_vmbus_ring_buffer_info *br = arg1;
+ uint32_t rindex, windex, intr_mask, ravail, wavail;
+ char state[256];
+
+ rindex = br->ring_buffer->read_index;
+ windex = br->ring_buffer->write_index;
+ intr_mask = br->ring_buffer->interrupt_mask;
+ wavail = HV_BYTES_AVAIL_TO_WRITE(rindex, windex, br->ring_data_size);
+ ravail = br->ring_data_size - wavail;
+
+ snprintf(state, sizeof(state),
+ "rindex:%u windex:%u intr_mask:%u ravail:%u wavail:%u",
+ rindex, windex, intr_mask, ravail, wavail);
+ return sysctl_handle_string(oidp, state, sizeof(state), req);
+}
+
+/*
+ * Binary bufring states.
+ */
+static int
+vmbus_br_sysctl_state_bin(SYSCTL_HANDLER_ARGS)
+{
+#define BR_STATE_RIDX 0
+#define BR_STATE_WIDX 1
+#define BR_STATE_IMSK 2
+#define BR_STATE_RSPC 3
+#define BR_STATE_WSPC 4
+#define BR_STATE_MAX 5
+
+ const hv_vmbus_ring_buffer_info *br = arg1;
+ uint32_t rindex, windex, wavail, state[BR_STATE_MAX];
+
+ rindex = br->ring_buffer->read_index;
+ windex = br->ring_buffer->write_index;
+ wavail = HV_BYTES_AVAIL_TO_WRITE(rindex, windex, br->ring_data_size);
+
+ state[BR_STATE_RIDX] = rindex;
+ state[BR_STATE_WIDX] = windex;
+ state[BR_STATE_IMSK] = br->ring_buffer->interrupt_mask;
+ state[BR_STATE_WSPC] = wavail;
+ state[BR_STATE_RSPC] = br->ring_data_size - wavail;
+
+ return sysctl_handle_opaque(oidp, state, sizeof(state), req);
}
void
-hv_ring_buffer_stat(struct sysctl_ctx_list *ctx,
- struct sysctl_oid_list *tree_node, hv_vmbus_ring_buffer_info *rbi,
- const char *desc)
+vmbus_br_sysctl_create(struct sysctl_ctx_list *ctx, struct sysctl_oid *br_tree,
+ hv_vmbus_ring_buffer_info *br, const char *name)
{
- SYSCTL_ADD_PROC(ctx, tree_node, OID_AUTO,
- "ring_buffer_stats", CTLTYPE_STRING|CTLFLAG_RD|CTLFLAG_MPSAFE,
- rbi, 0, hv_rbi_sysctl_stats, "A", desc);
+ struct sysctl_oid *tree;
+ char desc[64];
+
+ tree = SYSCTL_ADD_NODE(ctx, SYSCTL_CHILDREN(br_tree), OID_AUTO,
+ name, CTLFLAG_RD | CTLFLAG_MPSAFE, 0, "");
+ if (tree == NULL)
+ return;
+
+ snprintf(desc, sizeof(desc), "%s state", name);
+ SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, "state",
+ CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE,
+ br, 0, vmbus_br_sysctl_state, "A", desc);
+
+ snprintf(desc, sizeof(desc), "%s binary state", name);
+ SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, "state_bin",
+ CTLTYPE_OPAQUE | CTLFLAG_RD | CTLFLAG_MPSAFE,
+ br, 0, vmbus_br_sysctl_state_bin, "IU", desc);
}
/**
Index: sys/dev/hyperv/vmbus/hv_vmbus_priv.h
===================================================================
--- sys/dev/hyperv/vmbus/hv_vmbus_priv.h
+++ sys/dev/hyperv/vmbus/hv_vmbus_priv.h
@@ -45,13 +45,11 @@
* Private, VM Bus functions
*/
struct sysctl_ctx_list;
-struct sysctl_oid_list;
+struct sysctl_oid;
-void hv_ring_buffer_stat(
- struct sysctl_ctx_list *ctx,
- struct sysctl_oid_list *tree_node,
- hv_vmbus_ring_buffer_info *rbi,
- const char *desc);
+void vmbus_br_sysctl_create(struct sysctl_ctx_list *ctx,
+ struct sysctl_oid *br_tree, hv_vmbus_ring_buffer_info *br,
+ const char *name);
int hv_vmbus_ring_buffer_init(
hv_vmbus_ring_buffer_info *ring_info,
Index: sys/dev/hyperv/vmbus/vmbus_chan.c
===================================================================
--- sys/dev/hyperv/vmbus/vmbus_chan.c
+++ sys/dev/hyperv/vmbus/vmbus_chan.c
@@ -171,24 +171,17 @@
chan, 0, vmbus_chan_sysctl_mnf, "I",
"has monitor notification facilities");
- /*
- * Create sysctl tree for RX bufring.
- */
- br_tree = SYSCTL_ADD_NODE(ctx, SYSCTL_CHILDREN(chid_tree), OID_AUTO,
- "in", CTLFLAG_RD | CTLFLAG_MPSAFE, 0, "");
- if (br_tree != NULL) {
- hv_ring_buffer_stat(ctx, SYSCTL_CHILDREN(br_tree),
- &chan->ch_rxbr, "inbound ring buffer stats");
- }
-
- /*
- * Create sysctl tree for TX bufring.
- */
br_tree = SYSCTL_ADD_NODE(ctx, SYSCTL_CHILDREN(chid_tree), OID_AUTO,
- "out", CTLFLAG_RD | CTLFLAG_MPSAFE, 0, "");
+ "br", CTLFLAG_RD | CTLFLAG_MPSAFE, 0, "");
if (br_tree != NULL) {
- hv_ring_buffer_stat(ctx, SYSCTL_CHILDREN(br_tree),
- &chan->ch_txbr, "outbound ring buffer stats");
+ /*
+ * Create sysctl tree for RX bufring.
+ */
+ vmbus_br_sysctl_create(ctx, br_tree, &chan->ch_rxbr, "rx");
+ /*
+ * Create sysctl tree for TX bufring.
+ */
+ vmbus_br_sysctl_create(ctx, br_tree, &chan->ch_txbr, "tx");
}
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Apr 29, 1:54 AM (2 h, 26 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
32277496
Default Alt Text
D7268.id18621.diff (5 KB)
Attached To
Mode
D7268: hyperv/vmbus: Cleanup and augment bufring sysctl tree creation
Attached
Detach File
Event Timeline
Log In to Comment