1 /*
2  * Copyright (C) 2016 Parav Pandit <pandit.parav@gmail.com>
3  *
4  * This file is subject to the terms and conditions of version 2 of the GNU
5  * General Public License. See the file COPYING in the main directory of the
6  * Linux distribution for more details.
7  */
8 
9 #ifndef _CGROUP_RDMA_H
10 #define _CGROUP_RDMA_H
11 
12 #include <linux/cgroup.h>
13 
14 enum rdmacg_resource_type {
15 	RDMACG_RESOURCE_HCA_HANDLE,
16 	RDMACG_RESOURCE_HCA_OBJECT,
17 	RDMACG_RESOURCE_MAX,
18 };
19 
20 #ifdef CONFIG_CGROUP_RDMA
21 
22 struct rdma_cgroup {
23 	struct cgroup_subsys_state	css;
24 
25 	/*
26 	 * head to keep track of all resource pools
27 	 * that belongs to this cgroup.
28 	 */
29 	struct list_head		rpools;
30 };
31 
32 struct rdmacg_device {
33 	struct list_head	dev_node;
34 	struct list_head	rpools;
35 	char			*name;
36 };
37 
38 /*
39  * APIs for RDMA/IB stack to publish when a device wants to
40  * participate in resource accounting
41  */
42 int rdmacg_register_device(struct rdmacg_device *device);
43 void rdmacg_unregister_device(struct rdmacg_device *device);
44 
45 /* APIs for RDMA/IB stack to charge/uncharge pool specific resources */
46 int rdmacg_try_charge(struct rdma_cgroup **rdmacg,
47 		      struct rdmacg_device *device,
48 		      enum rdmacg_resource_type index);
49 void rdmacg_uncharge(struct rdma_cgroup *cg,
50 		     struct rdmacg_device *device,
51 		     enum rdmacg_resource_type index);
52 #endif	/* CONFIG_CGROUP_RDMA */
53 #endif	/* _CGROUP_RDMA_H */
54