diff mbox

[libibverbs,5/5] Add ibv_query_values_ex

Message ID 1445964700-13235-6-git-send-email-matanb@mellanox.com (mailing list archive)
State Superseded
Headers show

Commit Message

Matan Barak Oct. 27, 2015, 4:51 p.m. UTC
Add an extension verb to query certain values of device.
Currently, only IBV_VALUES_HW_CLOCK is supported, but this
verb could support other flags like IBV_VALUES_TEMP_SENSOR,
IBV_VALUES_CORE_FREQ, etc.
This extension verb only calls the provider.
The provider has to query this value somehow and mark the queried
values in comp_mask.

Signed-off-by: Matan Barak <matanb@mellanox.com>
---
 include/infiniband/verbs.h | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)
diff mbox

Patch

diff --git a/include/infiniband/verbs.h b/include/infiniband/verbs.h
index 3d66726..4829dac 100644
--- a/include/infiniband/verbs.h
+++ b/include/infiniband/verbs.h
@@ -1234,6 +1234,16 @@  struct ibv_create_cq_attr_ex {
 	uint32_t		flags;
 };
 
+enum ibv_values_mask {
+	IBV_VALUES_MASK_RAW_CLOCK	= 1 << 0,
+	IBV_VALUES_MASK_RESERVED	= 1 << 1
+};
+
+struct ibv_values_ex {
+	uint32_t	comp_mask;
+	struct timespec raw_clock;
+};
+
 enum verbs_context_mask {
 	VERBS_CONTEXT_XRCD	= 1 << 0,
 	VERBS_CONTEXT_SRQ	= 1 << 1,
@@ -1250,6 +1260,8 @@  struct ibv_poll_cq_ex_attr {
 
 struct verbs_context {
 	/*  "grows up" - new fields go here */
+	int (*query_values)(struct ibv_context *context,
+			    struct ibv_values_ex *values);
 	struct ibv_cq *(*create_cq_ex)(struct ibv_context *context,
 				       struct ibv_create_cq_attr_ex *);
 	void *priv;
@@ -1730,6 +1742,27 @@  ibv_create_qp_ex(struct ibv_context *context, struct ibv_qp_init_attr_ex *qp_ini
 }
 
 /**
+ * ibv_query_values_ex - Get current @q_values of device,
+ * @q_values is mask (Or's bits of enum ibv_values_mask) of the attributes
+ *	we need to query.
+ */
+static inline int
+ibv_query_values_ex(struct ibv_context *context,
+		    struct ibv_values_ex *values)
+{
+	struct verbs_context *vctx;
+
+	vctx = verbs_get_ctx_op(context, query_values);
+	if (!vctx)
+		return ENOSYS;
+
+	if (values->comp_mask & ~(IBV_VALUES_MASK_RESERVED - 1))
+		return EINVAL;
+
+	return vctx->query_values(context, values);
+}
+
+/**
  * ibv_query_device_ex - Get extended device properties
  */
 static inline int