18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci/* Copyright (C) 2010-2020  B.A.T.M.A.N. contributors:
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * Marek Lindner
58c2ecf20Sopenharmony_ci */
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci#ifndef _NET_BATMAN_ADV_SYSFS_H_
88c2ecf20Sopenharmony_ci#define _NET_BATMAN_ADV_SYSFS_H_
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci#include "main.h"
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci#include <linux/kobject.h>
138c2ecf20Sopenharmony_ci#include <linux/netdevice.h>
148c2ecf20Sopenharmony_ci#include <linux/sysfs.h>
158c2ecf20Sopenharmony_ci#include <linux/types.h>
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci#define BATADV_SYSFS_IF_MESH_SUBDIR "mesh"
188c2ecf20Sopenharmony_ci#define BATADV_SYSFS_IF_BAT_SUBDIR "batman_adv"
198c2ecf20Sopenharmony_ci/**
208c2ecf20Sopenharmony_ci * BATADV_SYSFS_VLAN_SUBDIR_PREFIX - prefix of the subfolder that will be
218c2ecf20Sopenharmony_ci *  created in the sysfs hierarchy for each VLAN interface. The subfolder will
228c2ecf20Sopenharmony_ci *  be named "BATADV_SYSFS_VLAN_SUBDIR_PREFIX%vid".
238c2ecf20Sopenharmony_ci */
248c2ecf20Sopenharmony_ci#define BATADV_SYSFS_VLAN_SUBDIR_PREFIX "vlan"
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ci/**
278c2ecf20Sopenharmony_ci * struct batadv_attribute - sysfs export helper for batman-adv attributes
288c2ecf20Sopenharmony_ci */
298c2ecf20Sopenharmony_cistruct batadv_attribute {
308c2ecf20Sopenharmony_ci	/** @attr: sysfs attribute file */
318c2ecf20Sopenharmony_ci	struct attribute attr;
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ci	/**
348c2ecf20Sopenharmony_ci	 * @show: function to export the current attribute's content to sysfs
358c2ecf20Sopenharmony_ci	 */
368c2ecf20Sopenharmony_ci	ssize_t (*show)(struct kobject *kobj, struct attribute *attr,
378c2ecf20Sopenharmony_ci			char *buf);
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ci	/**
408c2ecf20Sopenharmony_ci	 * @store: function to load new value from character buffer and save it
418c2ecf20Sopenharmony_ci	 * in batman-adv attribute
428c2ecf20Sopenharmony_ci	 */
438c2ecf20Sopenharmony_ci	ssize_t (*store)(struct kobject *kobj, struct attribute *attr,
448c2ecf20Sopenharmony_ci			 char *buf, size_t count);
458c2ecf20Sopenharmony_ci};
468c2ecf20Sopenharmony_ci
478c2ecf20Sopenharmony_ci#ifdef CONFIG_BATMAN_ADV_SYSFS
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_ciint batadv_sysfs_add_meshif(struct net_device *dev);
508c2ecf20Sopenharmony_civoid batadv_sysfs_del_meshif(struct net_device *dev);
518c2ecf20Sopenharmony_ciint batadv_sysfs_add_hardif(struct kobject **hardif_obj,
528c2ecf20Sopenharmony_ci			    struct net_device *dev);
538c2ecf20Sopenharmony_civoid batadv_sysfs_del_hardif(struct kobject **hardif_obj);
548c2ecf20Sopenharmony_ciint batadv_sysfs_add_vlan(struct net_device *dev,
558c2ecf20Sopenharmony_ci			  struct batadv_softif_vlan *vlan);
568c2ecf20Sopenharmony_civoid batadv_sysfs_del_vlan(struct batadv_priv *bat_priv,
578c2ecf20Sopenharmony_ci			   struct batadv_softif_vlan *vlan);
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_ci#else
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_cistatic inline int batadv_sysfs_add_meshif(struct net_device *dev)
628c2ecf20Sopenharmony_ci{
638c2ecf20Sopenharmony_ci	return 0;
648c2ecf20Sopenharmony_ci}
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_cistatic inline void batadv_sysfs_del_meshif(struct net_device *dev)
678c2ecf20Sopenharmony_ci{
688c2ecf20Sopenharmony_ci}
698c2ecf20Sopenharmony_ci
708c2ecf20Sopenharmony_cistatic inline int batadv_sysfs_add_hardif(struct kobject **hardif_obj,
718c2ecf20Sopenharmony_ci					  struct net_device *dev)
728c2ecf20Sopenharmony_ci{
738c2ecf20Sopenharmony_ci	return 0;
748c2ecf20Sopenharmony_ci}
758c2ecf20Sopenharmony_ci
768c2ecf20Sopenharmony_cistatic inline void batadv_sysfs_del_hardif(struct kobject **hardif_obj)
778c2ecf20Sopenharmony_ci{
788c2ecf20Sopenharmony_ci}
798c2ecf20Sopenharmony_ci
808c2ecf20Sopenharmony_cistatic inline int batadv_sysfs_add_vlan(struct net_device *dev,
818c2ecf20Sopenharmony_ci					struct batadv_softif_vlan *vlan)
828c2ecf20Sopenharmony_ci{
838c2ecf20Sopenharmony_ci	return 0;
848c2ecf20Sopenharmony_ci}
858c2ecf20Sopenharmony_ci
868c2ecf20Sopenharmony_cistatic inline void batadv_sysfs_del_vlan(struct batadv_priv *bat_priv,
878c2ecf20Sopenharmony_ci					 struct batadv_softif_vlan *vlan)
888c2ecf20Sopenharmony_ci{
898c2ecf20Sopenharmony_ci}
908c2ecf20Sopenharmony_ci
918c2ecf20Sopenharmony_ci#endif
928c2ecf20Sopenharmony_ci
938c2ecf20Sopenharmony_ci#endif /* _NET_BATMAN_ADV_SYSFS_H_ */
94