blob: d987f8b30a98b49ebbe2f7c3813adf8dda2b6236 [file] [log] [blame]
Sven Eckelmann7db7d9f2017-11-19 15:05:11 +01001/* SPDX-License-Identifier: GPL-2.0 */
Sven Eckelmann68e039f2020-01-01 00:00:01 +01002/* Copyright (C) 2010-2020 B.A.T.M.A.N. contributors:
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +00003 *
4 * Marek Lindner
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +00005 */
6
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +00007#ifndef _NET_BATMAN_ADV_SYSFS_H_
8#define _NET_BATMAN_ADV_SYSFS_H_
9
Sven Eckelmann1e2c2a42015-04-17 19:40:28 +020010#include "main.h"
11
Sven Eckelmann68a600d2019-05-24 20:11:17 +020012#include <linux/kobject.h>
13#include <linux/netdevice.h>
Sven Eckelmann1e2c2a42015-04-17 19:40:28 +020014#include <linux/sysfs.h>
15#include <linux/types.h>
16
Sven Eckelmann036cbfe2012-06-03 22:19:09 +020017#define BATADV_SYSFS_IF_MESH_SUBDIR "mesh"
18#define BATADV_SYSFS_IF_BAT_SUBDIR "batman_adv"
Antonio Quartulli90f44352013-07-02 11:04:35 +020019/**
20 * BATADV_SYSFS_VLAN_SUBDIR_PREFIX - prefix of the subfolder that will be
21 * created in the sysfs hierarchy for each VLAN interface. The subfolder will
22 * be named "BATADV_SYSFS_VLAN_SUBDIR_PREFIX%vid".
23 */
24#define BATADV_SYSFS_VLAN_SUBDIR_PREFIX "vlan"
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +000025
Sven Eckelmannc93effc2017-12-02 19:51:50 +010026/**
27 * struct batadv_attribute - sysfs export helper for batman-adv attributes
28 */
Sven Eckelmannb4d66b82012-06-05 22:31:29 +020029struct batadv_attribute {
Sven Eckelmannc93effc2017-12-02 19:51:50 +010030 /** @attr: sysfs attribute file */
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +000031 struct attribute attr;
Sven Eckelmannc93effc2017-12-02 19:51:50 +010032
33 /**
34 * @show: function to export the current attribute's content to sysfs
35 */
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +000036 ssize_t (*show)(struct kobject *kobj, struct attribute *attr,
37 char *buf);
Sven Eckelmannc93effc2017-12-02 19:51:50 +010038
39 /**
40 * @store: function to load new value from character buffer and save it
41 * in batman-adv attribute
42 */
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +000043 ssize_t (*store)(struct kobject *kobj, struct attribute *attr,
44 char *buf, size_t count);
45};
46
Sven Eckelmann0fa4c302019-03-03 18:02:57 +010047#ifdef CONFIG_BATMAN_ADV_SYSFS
48
Sven Eckelmann5853e222012-05-12 02:09:24 +020049int batadv_sysfs_add_meshif(struct net_device *dev);
50void batadv_sysfs_del_meshif(struct net_device *dev);
51int batadv_sysfs_add_hardif(struct kobject **hardif_obj,
52 struct net_device *dev);
53void batadv_sysfs_del_hardif(struct kobject **hardif_obj);
Antonio Quartulli90f44352013-07-02 11:04:35 +020054int batadv_sysfs_add_vlan(struct net_device *dev,
55 struct batadv_softif_vlan *vlan);
56void batadv_sysfs_del_vlan(struct batadv_priv *bat_priv,
57 struct batadv_softif_vlan *vlan);
Sven Eckelmann0fa4c302019-03-03 18:02:57 +010058
59#else
60
61static inline int batadv_sysfs_add_meshif(struct net_device *dev)
62{
63 return 0;
64}
65
66static inline void batadv_sysfs_del_meshif(struct net_device *dev)
67{
68}
69
70static inline int batadv_sysfs_add_hardif(struct kobject **hardif_obj,
71 struct net_device *dev)
72{
73 return 0;
74}
75
76static inline void batadv_sysfs_del_hardif(struct kobject **hardif_obj)
77{
78}
79
80static inline int batadv_sysfs_add_vlan(struct net_device *dev,
81 struct batadv_softif_vlan *vlan)
82{
83 return 0;
84}
85
86static inline void batadv_sysfs_del_vlan(struct batadv_priv *bat_priv,
87 struct batadv_softif_vlan *vlan)
88{
89}
90
91#endif
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +000092
93#endif /* _NET_BATMAN_ADV_SYSFS_H_ */