@@ -2310,3 +2310,45 @@ int ib_describe_counter_set(struct ib_device *device,
NULL);
}
EXPORT_SYMBOL(ib_describe_counter_set);
+
+/**
+ * ib_create_counter_set - Creates a Counter Set
+ * @device: The device on which to create the counter set.
+ * @cs_id: counter set id required to
+ * create the counter set.
+ */
+struct ib_counter_set *ib_create_counter_set(struct ib_device *device,
+ u16 cs_id)
+{
+ struct ib_counter_set *cs;
+
+ if (!device->create_counter_set)
+ return ERR_PTR(-ENOSYS);
+
+ cs = device->create_counter_set(device, cs_id, NULL);
+ if (!IS_ERR(cs)) {
+ cs->device = device;
+ cs->uobject = NULL;
+ cs->cs_id = cs_id;
+ atomic_set(&cs->usecnt, 0);
+ }
+
+ return cs;
+}
+EXPORT_SYMBOL(ib_create_counter_set);
+
+/**
+ * ib_destroy_counter_set - Destroys the specified counter set.
+ * @cs: The counter set to destroy.
+ **/
+int ib_destroy_counter_set(struct ib_counter_set *cs)
+{
+ if (!cs->device->destroy_counter_set)
+ return -ENOSYS;
+
+ if (atomic_read(&cs->usecnt))
+ return -EBUSY;
+
+ return cs->device->destroy_counter_set(cs);
+}
+EXPORT_SYMBOL(ib_destroy_counter_set);
@@ -2077,6 +2077,14 @@ struct ib_counter_set_describe_attr {
char *counters_names_buff;
};
+struct ib_counter_set {
+ struct ib_device *device;
+ struct ib_uobject *uobject;
+ u16 cs_id;
+ /* num of objects attached */
+ atomic_t usecnt;
+};
+
struct ib_device {
/* Do not access @dma_device directly from ULP nor from HW drivers. */
struct device *dma_device;
@@ -2336,6 +2344,10 @@ struct ib_device {
u16 cs_id,
struct ib_counter_set_describe_attr *cs_describe_attr,
struct ib_udata *udata);
+ struct ib_counter_set * (*create_counter_set)(struct ib_device *device,
+ u16 cs_id,
+ struct ib_udata *udata);
+ int (*destroy_counter_set)(struct ib_counter_set *cs);
/**
* rdma netdev operation
@@ -3647,6 +3659,9 @@ struct ib_rwq_ind_table *ib_create_rwq_ind_table(struct ib_device *device,
int ib_describe_counter_set(struct ib_device *device,
u16 cs_id,
struct ib_counter_set_describe_attr *cs_describe_attr);
+struct ib_counter_set *ib_create_counter_set(struct ib_device *device,
+ u16 cs_id);
+int ib_destroy_counter_set(struct ib_counter_set *cs);
int ib_map_mr_sg(struct ib_mr *mr, struct scatterlist *sg, int sg_nents,
unsigned int *sg_offset, unsigned int page_size);