xref: /openbmc/linux/include/rdma/ib_sysfs.h (revision 762f99f4f3cb41a775b5157dd761217beba65873)
1*054239f4SJason Gunthorpe /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
2*054239f4SJason Gunthorpe /*
3*054239f4SJason Gunthorpe  * Copyright (c) 2021 Mellanox Technologies Ltd.  All rights reserved.
4*054239f4SJason Gunthorpe  */
5*054239f4SJason Gunthorpe #ifndef DEF_RDMA_IB_SYSFS_H
6*054239f4SJason Gunthorpe #define DEF_RDMA_IB_SYSFS_H
7*054239f4SJason Gunthorpe 
8*054239f4SJason Gunthorpe #include <linux/sysfs.h>
9*054239f4SJason Gunthorpe 
10*054239f4SJason Gunthorpe struct ib_device;
11*054239f4SJason Gunthorpe 
12*054239f4SJason Gunthorpe struct ib_port_attribute {
13*054239f4SJason Gunthorpe 	struct attribute attr;
14*054239f4SJason Gunthorpe 	ssize_t (*show)(struct ib_device *ibdev, u32 port_num,
15*054239f4SJason Gunthorpe 			struct ib_port_attribute *attr, char *buf);
16*054239f4SJason Gunthorpe 	ssize_t (*store)(struct ib_device *ibdev, u32 port_num,
17*054239f4SJason Gunthorpe 			 struct ib_port_attribute *attr, const char *buf,
18*054239f4SJason Gunthorpe 			 size_t count);
19*054239f4SJason Gunthorpe };
20*054239f4SJason Gunthorpe 
21*054239f4SJason Gunthorpe #define IB_PORT_ATTR_RW(_name)                                                 \
22*054239f4SJason Gunthorpe 	struct ib_port_attribute ib_port_attr_##_name = __ATTR_RW(_name)
23*054239f4SJason Gunthorpe 
24*054239f4SJason Gunthorpe #define IB_PORT_ATTR_ADMIN_RW(_name)                                           \
25*054239f4SJason Gunthorpe 	struct ib_port_attribute ib_port_attr_##_name =                        \
26*054239f4SJason Gunthorpe 		__ATTR_RW_MODE(_name, 0600)
27*054239f4SJason Gunthorpe 
28*054239f4SJason Gunthorpe #define IB_PORT_ATTR_RO(_name)                                                 \
29*054239f4SJason Gunthorpe 	struct ib_port_attribute ib_port_attr_##_name = __ATTR_RO(_name)
30*054239f4SJason Gunthorpe 
31*054239f4SJason Gunthorpe #define IB_PORT_ATTR_WO(_name)                                                 \
32*054239f4SJason Gunthorpe 	struct ib_port_attribute ib_port_attr_##_name = __ATTR_WO(_name)
33*054239f4SJason Gunthorpe 
34*054239f4SJason Gunthorpe struct ib_device *ib_port_sysfs_get_ibdev_kobj(struct kobject *kobj,
35*054239f4SJason Gunthorpe 					       u32 *port_num);
36*054239f4SJason Gunthorpe 
37*054239f4SJason Gunthorpe #endif
38