#include <linux/times.h>
#include <linux/version.h>
-#include "brc_sysfs.h"
+#include "dp_sysfs.h"
#include "datapath.h"
#include "dp_dev.h"
/* Hack to attempt to build on more platforms. */
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)
-#define BRC_DEVICE_ATTR CLASS_DEVICE_ATTR
+#define DP_DEVICE_ATTR CLASS_DEVICE_ATTR
#define DEVICE_PARAMS struct class_device *d
#define DEVICE_ARGS d
#define DEV_ATTR(NAME) class_device_attr_##NAME
#else
-#define BRC_DEVICE_ATTR DEVICE_ATTR
+#define DP_DEVICE_ATTR DEVICE_ATTR
#define DEVICE_PARAMS struct device *d, struct device_attribute *attr
#define DEVICE_ARGS d, attr
#define DEV_ATTR(NAME) dev_attr_##NAME
{
return store_bridge_parm(DEVICE_ARGS, buf, len, set_forward_delay);
}
-static BRC_DEVICE_ATTR(forward_delay, S_IRUGO | S_IWUSR,
+static DP_DEVICE_ATTR(forward_delay, S_IRUGO | S_IWUSR,
show_forward_delay, store_forward_delay);
static ssize_t show_hello_time(DEVICE_PARAMS, char *buf)
{
return store_bridge_parm(DEVICE_ARGS, buf, len, set_hello_time);
}
-static BRC_DEVICE_ATTR(hello_time, S_IRUGO | S_IWUSR, show_hello_time,
+static DP_DEVICE_ATTR(hello_time, S_IRUGO | S_IWUSR, show_hello_time,
store_hello_time);
static ssize_t show_max_age(DEVICE_PARAMS, char *buf)
{
return store_bridge_parm(DEVICE_ARGS, buf, len, set_max_age);
}
-static BRC_DEVICE_ATTR(max_age, S_IRUGO | S_IWUSR, show_max_age, store_max_age);
+static DP_DEVICE_ATTR(max_age, S_IRUGO | S_IWUSR, show_max_age, store_max_age);
static ssize_t show_ageing_time(DEVICE_PARAMS, char *buf)
{
{
return store_bridge_parm(DEVICE_ARGS, buf, len, set_ageing_time);
}
-static BRC_DEVICE_ATTR(ageing_time, S_IRUGO | S_IWUSR, show_ageing_time,
+static DP_DEVICE_ATTR(ageing_time, S_IRUGO | S_IWUSR, show_ageing_time,
store_ageing_time);
static ssize_t show_stp_state(DEVICE_PARAMS, char *buf)
return len;
}
-static BRC_DEVICE_ATTR(stp_state, S_IRUGO | S_IWUSR, show_stp_state,
+static DP_DEVICE_ATTR(stp_state, S_IRUGO | S_IWUSR, show_stp_state,
store_stp_state);
static ssize_t show_priority(DEVICE_PARAMS, char *buf)
{
return store_bridge_parm(DEVICE_ARGS, buf, len, set_priority);
}
-static BRC_DEVICE_ATTR(priority, S_IRUGO | S_IWUSR, show_priority, store_priority);
+static DP_DEVICE_ATTR(priority, S_IRUGO | S_IWUSR, show_priority, store_priority);
static ssize_t show_root_id(DEVICE_PARAMS, char *buf)
{
return sprintf(buf, "0000.010203040506\n");
#endif
}
-static BRC_DEVICE_ATTR(root_id, S_IRUGO, show_root_id, NULL);
+static DP_DEVICE_ATTR(root_id, S_IRUGO, show_root_id, NULL);
static ssize_t show_bridge_id(DEVICE_PARAMS, char *buf)
{
return sprintf(buf, "%.2x%.2x.%.2x%.2x%.2x%.2x%.2x%.2x\n",
0, 0, addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]);
}
-static BRC_DEVICE_ATTR(bridge_id, S_IRUGO, show_bridge_id, NULL);
+static DP_DEVICE_ATTR(bridge_id, S_IRUGO, show_bridge_id, NULL);
static ssize_t show_root_port(DEVICE_PARAMS, char *buf)
{
return sprintf(buf, "%d\n", 0);
#endif
}
-static BRC_DEVICE_ATTR(root_port, S_IRUGO, show_root_port, NULL);
+static DP_DEVICE_ATTR(root_port, S_IRUGO, show_root_port, NULL);
static ssize_t show_root_path_cost(DEVICE_PARAMS, char *buf)
{
return sprintf(buf, "%d\n", 0);
#endif
}
-static BRC_DEVICE_ATTR(root_path_cost, S_IRUGO, show_root_path_cost, NULL);
+static DP_DEVICE_ATTR(root_path_cost, S_IRUGO, show_root_path_cost, NULL);
static ssize_t show_topology_change(DEVICE_PARAMS, char *buf)
{
return sprintf(buf, "%d\n", 0);
#endif
}
-static BRC_DEVICE_ATTR(topology_change, S_IRUGO, show_topology_change, NULL);
+static DP_DEVICE_ATTR(topology_change, S_IRUGO, show_topology_change, NULL);
static ssize_t show_topology_change_detected(DEVICE_PARAMS, char *buf)
{
return sprintf(buf, "%d\n", 0);
#endif
}
-static BRC_DEVICE_ATTR(topology_change_detected, S_IRUGO,
+static DP_DEVICE_ATTR(topology_change_detected, S_IRUGO,
show_topology_change_detected, NULL);
static ssize_t show_hello_timer(DEVICE_PARAMS, char *buf)
return sprintf(buf, "%d\n", 0);
#endif
}
-static BRC_DEVICE_ATTR(hello_timer, S_IRUGO, show_hello_timer, NULL);
+static DP_DEVICE_ATTR(hello_timer, S_IRUGO, show_hello_timer, NULL);
static ssize_t show_tcn_timer(DEVICE_PARAMS, char *buf)
{
return sprintf(buf, "%d\n", 0);
#endif
}
-static BRC_DEVICE_ATTR(tcn_timer, S_IRUGO, show_tcn_timer, NULL);
+static DP_DEVICE_ATTR(tcn_timer, S_IRUGO, show_tcn_timer, NULL);
static ssize_t show_topology_change_timer(DEVICE_PARAMS, char *buf)
{
return sprintf(buf, "%d\n", 0);
#endif
}
-static BRC_DEVICE_ATTR(topology_change_timer, S_IRUGO, show_topology_change_timer,
+static DP_DEVICE_ATTR(topology_change_timer, S_IRUGO, show_topology_change_timer,
NULL);
static ssize_t show_gc_timer(DEVICE_PARAMS, char *buf)
return sprintf(buf, "%d\n", 0);
#endif
}
-static BRC_DEVICE_ATTR(gc_timer, S_IRUGO, show_gc_timer, NULL);
+static DP_DEVICE_ATTR(gc_timer, S_IRUGO, show_gc_timer, NULL);
static ssize_t show_group_addr(DEVICE_PARAMS, char *buf)
{
return len;
}
-static BRC_DEVICE_ATTR(group_addr, S_IRUGO | S_IWUSR,
+static DP_DEVICE_ATTR(group_addr, S_IRUGO | S_IWUSR,
show_group_addr, store_group_addr);
static struct attribute *bridge_attrs[] = {
* to hold links. The ifobj exists in the same data structure
* as its parent the bridge so reference counting works.
*/
-int brc_sysfs_add_dp(struct datapath *dp)
+int dp_sysfs_add_dp(struct datapath *dp)
{
struct kobject *kobj = &dp->ports[ODPP_LOCAL]->dev->NETDEV_DEV_MEMBER.kobj;
int err;
goto out1;
}
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)
- kobject_set_name(&dp->ifobj, SYSFS_BRIDGE_PORT_SUBDIR);
- dp->ifobj.ktype = NULL;
- dp->ifobj.kset = NULL;
- dp->ifobj.parent = kobj;
-
- err = kobject_register(&dp->ifobj);
+ /* Create /sys/class/net/<devname>/brif directory. */
+ err = kobject_add(&dp->ifobj, kobj, SYSFS_BRIDGE_PORT_SUBDIR);
if (err) {
pr_info("%s: can't add kobject (directory) %s/%s\n",
__FUNCTION__, dp_name(dp), kobject_name(&dp->ifobj));
goto out2;
}
-#else
- dp->ifobj = kobject_create_and_add(SYSFS_BRIDGE_PORT_SUBDIR, kobj);
- if (!dp->ifobj) {
- pr_info("%s: can't add kobject (directory) %s/%s\n",
- __func__, dp_name(dp), SYSFS_BRIDGE_PORT_SUBDIR);
- goto out2;
- }
-#endif
+ kobject_uevent(&dp->ifobj, KOBJ_ADD);
return 0;
out2:
return err;
}
-int brc_sysfs_del_dp(struct datapath *dp)
+int dp_sysfs_del_dp(struct datapath *dp)
{
struct kobject *kobj = &dp->ports[ODPP_LOCAL]->dev->NETDEV_DEV_MEMBER.kobj;
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)
- kobject_unregister(&dp->ifobj);
-#else
- kobject_put(dp->ifobj);
-#endif
+ kobject_del(&dp->ifobj);
sysfs_remove_group(kobj, &bridge_group);
return 0;
}
#else /* !CONFIG_SYSFS */
-int brc_sysfs_add_dp(struct datapath *dp) { return 0; }
-int brc_sysfs_del_dp(struct datapath *dp) { return 0; }
-int brc_sysfs_add_if(struct net_bridge_port *p) { return 0; }
-int brc_sysfs_del_if(struct net_bridge_port *p)
-{
- dev_put(p->dev);
- kfree(p);
- return 0;
-}
+int dp_sysfs_add_dp(struct datapath *dp) { return 0; }
+int dp_sysfs_del_dp(struct datapath *dp) { return 0; }
+int dp_sysfs_add_if(struct net_bridge_port *p) { return 0; }
+int dp_sysfs_del_if(struct net_bridge_port *p) { return 0; }
#endif /* !CONFIG_SYSFS */