Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 197361
b: refs/heads/master
c: 1474124
h: refs/heads/master
i:
  197359: 8723ee0
v: v3
  • Loading branch information
Marek Lindner authored and Greg Kroah-Hartman committed May 11, 2010
1 parent 9bd2398 commit 38b9363
Show file tree
Hide file tree
Showing 17 changed files with 266 additions and 277 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 47fdf097c348673dced571da8a15939005219da0
refs/heads/master: 147412406a200a9a3230fad1e0e99c818e873680
6 changes: 3 additions & 3 deletions trunk/drivers/staging/batman-adv/aggregation.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,10 @@ static void aggregate(struct forw_packet *forw_packet_aggr,
(1 << forw_packet_aggr->num_packets);
}

void add_bat_packet_to_list(unsigned char *packet_buff, int packet_len,
void add_bat_packet_to_list(struct bat_priv *bat_priv,
unsigned char *packet_buff, int packet_len,
struct batman_if *if_incoming, char own_packet,
unsigned long send_time,
struct bat_priv *bat_priv)
unsigned long send_time)
{
/**
* _aggr -> pointer to the packet we want to aggregate with
Expand Down
8 changes: 4 additions & 4 deletions trunk/drivers/staging/batman-adv/aggregation.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ static inline int aggregated_packet(int buff_pos, int packet_len, int num_hna)
(next_buff_pos <= MAX_AGGREGATION_BYTES);
}

void add_bat_packet_to_list(unsigned char *packet_buff, int packet_len,
struct batman_if *if_outgoing, char own_packet,
unsigned long send_time,
struct bat_priv *bat_priv);
void add_bat_packet_to_list(struct bat_priv *bat_priv,
unsigned char *packet_buff, int packet_len,
struct batman_if *if_incoming, char own_packet,
unsigned long send_time);
void receive_aggr_bat_packet(struct ethhdr *ethhdr, unsigned char *packet_buff,
int packet_len, struct batman_if *if_incoming);
118 changes: 68 additions & 50 deletions trunk/drivers/staging/batman-adv/bat_sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "translation-table.h"
#include "originator.h"
#include "hard-interface.h"
#include "vis.h"

#define to_dev(obj) container_of(obj, struct device, kobj)

Expand Down Expand Up @@ -99,11 +100,66 @@ static ssize_t store_aggr_ogm(struct kobject *kobj, struct attribute *attr,
return count;
}

static ssize_t show_vis_mode(struct kobject *kobj, struct attribute *attr,
char *buff)
{
struct device *dev = to_dev(kobj->parent);
struct bat_priv *bat_priv = netdev_priv(to_net_dev(dev));
int vis_mode = atomic_read(&bat_priv->vis_mode);

return sprintf(buff, "status: %s\ncommands: client, server, %d, %d \n",
vis_mode == VIS_TYPE_CLIENT_UPDATE ?
"client" : "server",
VIS_TYPE_SERVER_SYNC, VIS_TYPE_CLIENT_UPDATE);
}

static ssize_t store_vis_mode(struct kobject *kobj, struct attribute *attr,
char *buff, size_t count)
{
struct device *dev = to_dev(kobj->parent);
struct net_device *net_dev = to_net_dev(dev);
struct bat_priv *bat_priv = netdev_priv(net_dev);
unsigned long val;
int ret, vis_mode_tmp = -1;

ret = strict_strtoul(buff, 10, &val);

if (((count == 2) && (!ret) && (val == VIS_TYPE_CLIENT_UPDATE)) ||
(strncmp(buff, "client", 6) == 0))
vis_mode_tmp = VIS_TYPE_CLIENT_UPDATE;

if (((count == 2) && (!ret) && (val == VIS_TYPE_SERVER_SYNC)) ||
(strncmp(buff, "server", 6) == 0))
vis_mode_tmp = VIS_TYPE_SERVER_SYNC;

if (vis_mode_tmp < 0) {
if (buff[count - 1] == '\n')
buff[count - 1] = '\0';

printk(KERN_INFO "batman-adv:Invalid parameter for 'vis mode' setting on mesh %s received: %s\n",
net_dev->name, buff);
return -EINVAL;
}

if (atomic_read(&bat_priv->vis_mode) == vis_mode_tmp)
return count;

printk(KERN_INFO "batman-adv:Changing vis mode from: %s to: %s on mesh: %s\n",
atomic_read(&bat_priv->vis_mode) == VIS_TYPE_CLIENT_UPDATE ?
"client" : "server", vis_mode_tmp == VIS_TYPE_CLIENT_UPDATE ?
"client" : "server", net_dev->name);

atomic_set(&bat_priv->vis_mode, (unsigned)vis_mode_tmp);
return count;
}

static BAT_ATTR(aggregate_ogm, S_IRUGO | S_IWUSR,
show_aggr_ogm, store_aggr_ogm);
static BAT_ATTR(vis_mode, S_IRUGO | S_IWUSR, show_vis_mode, store_vis_mode);

static struct bat_attribute *mesh_attrs[] = {
&bat_attr_aggregate_ogm,
&bat_attr_vis_mode,
NULL,
};

Expand All @@ -114,19 +170,6 @@ static ssize_t transtable_local_read(struct kobject *kobj,
struct device *dev = to_dev(kobj->parent);
struct net_device *net_dev = to_net_dev(dev);

rcu_read_lock();
if (list_empty(&if_list)) {
rcu_read_unlock();

if (off == 0)
return sprintf(buff,
"BATMAN mesh %s disabled - please specify interfaces to enable it\n",
net_dev->name);

return 0;
}
rcu_read_unlock();

return hna_local_fill_buffer_text(net_dev, buff, count, off);
}

Expand All @@ -137,65 +180,39 @@ static ssize_t transtable_global_read(struct kobject *kobj,
struct device *dev = to_dev(kobj->parent);
struct net_device *net_dev = to_net_dev(dev);

rcu_read_lock();
if (list_empty(&if_list)) {
rcu_read_unlock();

if (off == 0)
return sprintf(buff,
"BATMAN mesh %s disabled - please specify interfaces to enable it\n",
net_dev->name);

return 0;
}
rcu_read_unlock();

return hna_global_fill_buffer_text(net_dev, buff, count, off);
}

static ssize_t originators_read(struct kobject *kobj,
struct bin_attribute *bin_attr,
char *buff, loff_t off, size_t count)
{
/* FIXME: orig table should exist per batif */
struct device *dev = to_dev(kobj->parent);
struct net_device *net_dev = to_net_dev(dev);

rcu_read_lock();
if (list_empty(&if_list)) {
rcu_read_unlock();

if (off == 0)
return sprintf(buff,
"BATMAN mesh %s disabled - please specify interfaces to enable it\n",
net_dev->name);

return 0;
}

if (((struct batman_if *)if_list.next)->if_active != IF_ACTIVE) {
rcu_read_unlock();

if (off == 0)
return sprintf(buff,
"BATMAN mesh %s disabled - primary interface not active\n",
net_dev->name);
return orig_fill_buffer_text(net_dev, buff, count, off);
}

return 0;
}
rcu_read_unlock();
static ssize_t vis_data_read(struct kobject *kobj,
struct bin_attribute *bin_attr,
char *buff, loff_t off, size_t count)
{
struct device *dev = to_dev(kobj->parent);
struct net_device *net_dev = to_net_dev(dev);

return orig_fill_buffer_text(buff, count, off);
return vis_fill_buffer_text(net_dev, buff, count, off);
}

static BAT_BIN_ATTR(transtable_local, S_IRUGO, transtable_local_read, NULL);
static BAT_BIN_ATTR(transtable_global, S_IRUGO, transtable_global_read, NULL);
static BAT_BIN_ATTR(originators, S_IRUGO, originators_read, NULL);
static BAT_BIN_ATTR(vis_data, S_IRUGO, vis_data_read, NULL);

static struct bin_attribute *mesh_bin_attrs[] = {
&bat_attr_transtable_local,
&bat_attr_transtable_global,
&bat_attr_originators,
&bat_attr_vis_data,
NULL,
};

Expand All @@ -210,6 +227,7 @@ int sysfs_add_meshif(struct net_device *dev)
/* FIXME: should be done in the general mesh setup
routine as soon as we have it */
atomic_set(&bat_priv->aggregation_enabled, 1);
atomic_set(&bat_priv->vis_mode, VIS_TYPE_CLIENT_UPDATE);

bat_priv->mesh_obj = kobject_create_and_add(SYSFS_IF_MESH_SUBDIR,
batif_kobject);
Expand Down
2 changes: 0 additions & 2 deletions trunk/drivers/staging/batman-adv/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ DEFINE_SPINLOCK(forw_bcast_list_lock);

atomic_t originator_interval;
atomic_t vis_interval;
atomic_t vis_mode;
int16_t num_hna;
int16_t num_ifs;

Expand Down Expand Up @@ -84,7 +83,6 @@ int init_module(void)
atomic_set(&originator_interval, 1000);
atomic_set(&vis_interval, 1000);/* TODO: raise this later, this is only
* for debugging now. */
atomic_set(&vis_mode, VIS_TYPE_CLIENT_UPDATE);

/* the name should not be longer than 10 chars - see
* http://lwn.net/Articles/23634/ */
Expand Down
1 change: 0 additions & 1 deletion trunk/drivers/staging/batman-adv/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ extern spinlock_t forw_bcast_list_lock;

extern atomic_t originator_interval;
extern atomic_t vis_interval;
extern atomic_t vis_mode;
extern int16_t num_hna;
extern int16_t num_ifs;

Expand Down
33 changes: 29 additions & 4 deletions trunk/drivers/staging/batman-adv/originator.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "hash.h"
#include "translation-table.h"
#include "routing.h"
#include "hard-interface.h"

static DECLARE_DELAYED_WORK(purge_orig_wq, purge_orig);

Expand Down Expand Up @@ -205,7 +206,6 @@ static bool purge_orig_neighbors(struct orig_node *orig_node,
return neigh_purged;
}


static bool purge_orig_node(struct orig_node *orig_node)
{
struct neigh_node *best_neigh_node;
Expand All @@ -224,6 +224,7 @@ static bool purge_orig_node(struct orig_node *orig_node)
orig_node->hna_buff,
orig_node->hna_buff_len);
}

return false;
}

Expand All @@ -249,7 +250,8 @@ void purge_orig(struct work_struct *work)
start_purge_timer();
}

ssize_t orig_fill_buffer_text(char *buff, size_t count, loff_t off)
ssize_t orig_fill_buffer_text(struct net_device *net_dev, char *buff,
size_t count, loff_t off)
{
HASHIT(hashit);
struct orig_node *orig_node;
Expand All @@ -260,12 +262,35 @@ ssize_t orig_fill_buffer_text(char *buff, size_t count, loff_t off)
char orig_str[ETH_STR_LEN], router_str[ETH_STR_LEN];

rcu_read_lock();
if (list_empty(&if_list)) {
rcu_read_unlock();

if (off == 0)
return sprintf(buff,
"BATMAN mesh %s disabled - please specify interfaces to enable it\n",
net_dev->name);

return 0;
}

if (((struct batman_if *)if_list.next)->if_active != IF_ACTIVE) {
rcu_read_unlock();

if (off == 0)
return sprintf(buff,
"BATMAN mesh %s disabled - primary interface not active\n",
net_dev->name);

return 0;
}

hdr_len = sprintf(buff,
" %-14s (%s/%i) %17s [%10s]: %20s ... [B.A.T.M.A.N. adv %s%s, MainIF/MAC: %s/%s] \n",
" %-14s (%s/%i) %17s [%10s]: %20s ... [B.A.T.M.A.N. adv %s%s, MainIF/MAC: %s/%s (%s)] \n",
"Originator", "#", TQ_MAX_VALUE, "Nexthop", "outgoingIF",
"Potential nexthops", SOURCE_VERSION, REVISION_VERSION_STR,
((struct batman_if *)if_list.next)->dev,
((struct batman_if *)if_list.next)->addr_str);
((struct batman_if *)if_list.next)->addr_str,
net_dev->name);
rcu_read_unlock();

if (off < hdr_len)
Expand Down
3 changes: 2 additions & 1 deletion trunk/drivers/staging/batman-adv/originator.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ struct orig_node *get_orig_node(uint8_t *addr);
struct neigh_node *
create_neighbor(struct orig_node *orig_node, struct orig_node *orig_neigh_node,
uint8_t *neigh, struct batman_if *if_incoming);
ssize_t orig_fill_buffer_text(char *buff, size_t count, loff_t off);
ssize_t orig_fill_buffer_text(struct net_device *net_dev, char *buff,
size_t count, loff_t off);
Loading

0 comments on commit 38b9363

Please sign in to comment.