sysfs.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /* Copyright (C) 2010-2020 B.A.T.M.A.N. contributors:
  3. *
  4. * Marek Lindner
  5. */
  6. #ifndef _NET_BATMAN_ADV_SYSFS_H_
  7. #define _NET_BATMAN_ADV_SYSFS_H_
  8. #include "main.h"
  9. #include <linux/kobject.h>
  10. #include <linux/netdevice.h>
  11. #include <linux/sysfs.h>
  12. #include <linux/types.h>
  13. #define BATADV_SYSFS_IF_MESH_SUBDIR "mesh"
  14. #define BATADV_SYSFS_IF_BAT_SUBDIR "batman_adv"
  15. /**
  16. * BATADV_SYSFS_VLAN_SUBDIR_PREFIX - prefix of the subfolder that will be
  17. * created in the sysfs hierarchy for each VLAN interface. The subfolder will
  18. * be named "BATADV_SYSFS_VLAN_SUBDIR_PREFIX%vid".
  19. */
  20. #define BATADV_SYSFS_VLAN_SUBDIR_PREFIX "vlan"
  21. /**
  22. * struct batadv_attribute - sysfs export helper for batman-adv attributes
  23. */
  24. struct batadv_attribute {
  25. /** @attr: sysfs attribute file */
  26. struct attribute attr;
  27. /**
  28. * @show: function to export the current attribute's content to sysfs
  29. */
  30. ssize_t (*show)(struct kobject *kobj, struct attribute *attr,
  31. char *buf);
  32. /**
  33. * @store: function to load new value from character buffer and save it
  34. * in batman-adv attribute
  35. */
  36. ssize_t (*store)(struct kobject *kobj, struct attribute *attr,
  37. char *buf, size_t count);
  38. };
  39. #ifdef CONFIG_BATMAN_ADV_SYSFS
  40. int batadv_sysfs_add_meshif(struct net_device *dev);
  41. void batadv_sysfs_del_meshif(struct net_device *dev);
  42. int batadv_sysfs_add_hardif(struct kobject **hardif_obj,
  43. struct net_device *dev);
  44. void batadv_sysfs_del_hardif(struct kobject **hardif_obj);
  45. int batadv_sysfs_add_vlan(struct net_device *dev,
  46. struct batadv_softif_vlan *vlan);
  47. void batadv_sysfs_del_vlan(struct batadv_priv *bat_priv,
  48. struct batadv_softif_vlan *vlan);
  49. #else
  50. static inline int batadv_sysfs_add_meshif(struct net_device *dev)
  51. {
  52. return 0;
  53. }
  54. static inline void batadv_sysfs_del_meshif(struct net_device *dev)
  55. {
  56. }
  57. static inline int batadv_sysfs_add_hardif(struct kobject **hardif_obj,
  58. struct net_device *dev)
  59. {
  60. return 0;
  61. }
  62. static inline void batadv_sysfs_del_hardif(struct kobject **hardif_obj)
  63. {
  64. }
  65. static inline int batadv_sysfs_add_vlan(struct net_device *dev,
  66. struct batadv_softif_vlan *vlan)
  67. {
  68. return 0;
  69. }
  70. static inline void batadv_sysfs_del_vlan(struct batadv_priv *bat_priv,
  71. struct batadv_softif_vlan *vlan)
  72. {
  73. }
  74. #endif
  75. #endif /* _NET_BATMAN_ADV_SYSFS_H_ */