ib_sysfs.h 1.2 KB

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