1 /* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
3 * Copyright (c) 2019 Mellanox Technologies. All rights reserved.
6 #ifndef _RDMA_COUNTER_H_
7 #define _RDMA_COUNTER_H_
9 #include <linux/mutex.h>
10 #include <linux/pid_namespace.h>
12 #include <rdma/restrack.h>
13 #include <rdma/rdma_netlink.h>
18 struct auto_mode_param {
22 struct rdma_counter_mode {
23 enum rdma_nl_counter_mode mode;
24 enum rdma_nl_counter_mask mask;
25 struct auto_mode_param param;
28 struct rdma_port_counter {
29 struct rdma_counter_mode mode;
30 struct rdma_hw_stats *hstats;
31 unsigned int num_counters;
36 struct rdma_restrack_entry res;
37 struct ib_device *device;
40 struct rdma_counter_mode mode;
42 struct rdma_hw_stats *stats;
46 void rdma_counter_init(struct ib_device *dev);
47 void rdma_counter_release(struct ib_device *dev);
48 int rdma_counter_set_auto_mode(struct ib_device *dev, u32 port,
49 enum rdma_nl_counter_mask mask,
50 struct netlink_ext_ack *extack);
51 int rdma_counter_bind_qp_auto(struct ib_qp *qp, u32 port);
52 int rdma_counter_unbind_qp(struct ib_qp *qp, bool force);
54 int rdma_counter_query_stats(struct rdma_counter *counter);
55 u64 rdma_counter_get_hwstat_value(struct ib_device *dev, u32 port, u32 index);
56 int rdma_counter_bind_qpn(struct ib_device *dev, u32 port,
57 u32 qp_num, u32 counter_id);
58 int rdma_counter_bind_qpn_alloc(struct ib_device *dev, u32 port,
59 u32 qp_num, u32 *counter_id);
60 int rdma_counter_unbind_qpn(struct ib_device *dev, u32 port,
61 u32 qp_num, u32 counter_id);
62 int rdma_counter_get_mode(struct ib_device *dev, u32 port,
63 enum rdma_nl_counter_mode *mode,
64 enum rdma_nl_counter_mask *mask);
66 int rdma_counter_modify(struct ib_device *dev, u32 port,
67 unsigned int index, bool enable);
68 #endif /* _RDMA_COUNTER_H_ */