IB/mlx5: Add counter_alloc_stats() and counter_update_stats() support
[linux-2.6-block.git] / include / rdma / rdma_counter.h
CommitLineData
7ade1ff9
MZ
1/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
2/*
3 * Copyright (c) 2019 Mellanox Technologies. All rights reserved.
4 */
5
6#ifndef _RDMA_COUNTER_H_
7#define _RDMA_COUNTER_H_
8
413d3347 9#include <linux/mutex.h>
99fa331d 10#include <linux/pid_namespace.h>
413d3347 11
7ade1ff9
MZ
12#include <rdma/ib_verbs.h>
13#include <rdma/restrack.h>
413d3347
MZ
14#include <rdma/rdma_netlink.h>
15
99fa331d
MZ
16struct ib_qp;
17
413d3347
MZ
18struct auto_mode_param {
19 int qp_type;
20};
21
22struct rdma_counter_mode {
23 enum rdma_nl_counter_mode mode;
24 enum rdma_nl_counter_mask mask;
25 struct auto_mode_param param;
26};
27
28struct rdma_port_counter {
29 struct rdma_counter_mode mode;
30 struct mutex lock;
31};
7ade1ff9
MZ
32
33struct rdma_counter {
34 struct rdma_restrack_entry res;
35 struct ib_device *device;
36 uint32_t id;
99fa331d
MZ
37 struct kref kref;
38 struct rdma_counter_mode mode;
39 struct mutex lock;
c4ffee7c 40 struct rdma_hw_stats *stats;
7ade1ff9
MZ
41 u8 port;
42};
413d3347
MZ
43
44void rdma_counter_init(struct ib_device *dev);
45void rdma_counter_release(struct ib_device *dev);
46int rdma_counter_set_auto_mode(struct ib_device *dev, u8 port,
47 bool on, enum rdma_nl_counter_mask mask);
99fa331d
MZ
48int rdma_counter_bind_qp_auto(struct ib_qp *qp, u8 port);
49int rdma_counter_unbind_qp(struct ib_qp *qp, bool force);
413d3347 50
c4ffee7c
MZ
51int rdma_counter_query_stats(struct rdma_counter *counter);
52
7ade1ff9 53#endif /* _RDMA_COUNTER_H_ */