Merge tag 'xfs-6.4-rc1-fixes' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux
[linux-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 12#include <rdma/restrack.h>
413d3347
MZ
13#include <rdma/rdma_netlink.h>
14
390d5772 15struct ib_device;
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;
f34a55e4 30 struct rdma_hw_stats *hstats;
1bd8e0a9 31 unsigned int num_counters;
413d3347
MZ
32 struct mutex lock;
33};
7ade1ff9
MZ
34
35struct rdma_counter {
36 struct rdma_restrack_entry res;
37 struct ib_device *device;
38 uint32_t id;
99fa331d
MZ
39 struct kref kref;
40 struct rdma_counter_mode mode;
41 struct mutex lock;
c4ffee7c 42 struct rdma_hw_stats *stats;
1fb7f897 43 u32 port;
7ade1ff9 44};
413d3347
MZ
45
46void rdma_counter_init(struct ib_device *dev);
47void rdma_counter_release(struct ib_device *dev);
1fb7f897 48int rdma_counter_set_auto_mode(struct ib_device *dev, u32 port,
33eb12f2
PH
49 enum rdma_nl_counter_mask mask,
50 struct netlink_ext_ack *extack);
1fb7f897 51int rdma_counter_bind_qp_auto(struct ib_qp *qp, u32 port);
99fa331d 52int rdma_counter_unbind_qp(struct ib_qp *qp, bool force);
413d3347 53
c4ffee7c 54int rdma_counter_query_stats(struct rdma_counter *counter);
1fb7f897
MB
55u64 rdma_counter_get_hwstat_value(struct ib_device *dev, u32 port, u32 index);
56int rdma_counter_bind_qpn(struct ib_device *dev, u32 port,
1bd8e0a9 57 u32 qp_num, u32 counter_id);
1fb7f897 58int rdma_counter_bind_qpn_alloc(struct ib_device *dev, u32 port,
1bd8e0a9 59 u32 qp_num, u32 *counter_id);
1fb7f897 60int rdma_counter_unbind_qpn(struct ib_device *dev, u32 port,
1bd8e0a9 61 u32 qp_num, u32 counter_id);
1fb7f897 62int rdma_counter_get_mode(struct ib_device *dev, u32 port,
b389327d
MZ
63 enum rdma_nl_counter_mode *mode,
64 enum rdma_nl_counter_mask *mask);
c4ffee7c 65
5e2ddd1e
AL
66int rdma_counter_modify(struct ib_device *dev, u32 port,
67 unsigned int index, bool enable);
7ade1ff9 68#endif /* _RDMA_COUNTER_H_ */