Commit 70ebe4a4 authored by Arvid Brodin's avatar Arvid Brodin Committed by David S. Miller

net/hsr: Better variable names and update of contact info.

Signed-off-by: default avatarArvid Brodin <arvid.brodin@alten.se>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent b8125404
This diff is collapsed.
/* Copyright 2011-2013 Autronica Fire and Security AS /* Copyright 2011-2014 Autronica Fire and Security AS
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free * under the terms of the GNU General Public License as published by the Free
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* any later version. * any later version.
* *
* Author(s): * Author(s):
* 2011-2013 Arvid Brodin, arvid.brodin@xdin.com * 2011-2014 Arvid Brodin, arvid.brodin@alten.se
*/ */
#ifndef __HSR_DEVICE_H #ifndef __HSR_DEVICE_H
...@@ -24,6 +24,6 @@ void hsr_set_carrier(struct net_device *hsr_dev, struct net_device *slave1, ...@@ -24,6 +24,6 @@ void hsr_set_carrier(struct net_device *hsr_dev, struct net_device *slave1,
struct net_device *slave2); struct net_device *slave2);
void hsr_check_announce(struct net_device *hsr_dev, int old_operstate); void hsr_check_announce(struct net_device *hsr_dev, int old_operstate);
bool is_hsr_master(struct net_device *dev); bool is_hsr_master(struct net_device *dev);
int hsr_get_max_mtu(struct hsr_priv *hsr_priv); int hsr_get_max_mtu(struct hsr_priv *hsr);
#endif /* __HSR_DEVICE_H */ #endif /* __HSR_DEVICE_H */
/* Copyright 2011-2013 Autronica Fire and Security AS /* Copyright 2011-2014 Autronica Fire and Security AS
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free * under the terms of the GNU General Public License as published by the Free
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* any later version. * any later version.
* *
* Author(s): * Author(s):
* 2011-2013 Arvid Brodin, arvid.brodin@xdin.com * 2011-2014 Arvid Brodin, arvid.brodin@alten.se
* *
* The HSR spec says never to forward the same frame twice on the same * The HSR spec says never to forward the same frame twice on the same
* interface. A frame is identified by its source MAC address and its HSR * interface. A frame is identified by its source MAC address and its HSR
...@@ -23,11 +23,11 @@ ...@@ -23,11 +23,11 @@
#include "hsr_netlink.h" #include "hsr_netlink.h"
struct node_entry { struct hsr_node {
struct list_head mac_list; struct list_head mac_list;
unsigned char MacAddressA[ETH_ALEN]; unsigned char MacAddressA[ETH_ALEN];
unsigned char MacAddressB[ETH_ALEN]; unsigned char MacAddressB[ETH_ALEN];
enum hsr_dev_idx AddrB_if; /* The local slave through which AddrB enum hsr_dev_idx AddrB_if;/* The local slave through which AddrB
* frames are received from this node * frames are received from this node
*/ */
unsigned long time_in[HSR_MAX_SLAVE]; unsigned long time_in[HSR_MAX_SLAVE];
...@@ -42,10 +42,10 @@ struct node_entry { ...@@ -42,10 +42,10 @@ struct node_entry {
/* Search for mac entry. Caller must hold rcu read lock. /* Search for mac entry. Caller must hold rcu read lock.
*/ */
static struct node_entry *find_node_by_AddrA(struct list_head *node_db, static struct hsr_node *find_node_by_AddrA(struct list_head *node_db,
const unsigned char addr[ETH_ALEN]) const unsigned char addr[ETH_ALEN])
{ {
struct node_entry *node; struct hsr_node *node;
list_for_each_entry_rcu(node, node_db, mac_list) { list_for_each_entry_rcu(node, node_db, mac_list) {
if (ether_addr_equal(node->MacAddressA, addr)) if (ether_addr_equal(node->MacAddressA, addr))
...@@ -58,10 +58,10 @@ static struct node_entry *find_node_by_AddrA(struct list_head *node_db, ...@@ -58,10 +58,10 @@ static struct node_entry *find_node_by_AddrA(struct list_head *node_db,
/* Search for mac entry. Caller must hold rcu read lock. /* Search for mac entry. Caller must hold rcu read lock.
*/ */
static struct node_entry *find_node_by_AddrB(struct list_head *node_db, static struct hsr_node *find_node_by_AddrB(struct list_head *node_db,
const unsigned char addr[ETH_ALEN]) const unsigned char addr[ETH_ALEN])
{ {
struct node_entry *node; struct hsr_node *node;
list_for_each_entry_rcu(node, node_db, mac_list) { list_for_each_entry_rcu(node, node_db, mac_list) {
if (ether_addr_equal(node->MacAddressB, addr)) if (ether_addr_equal(node->MacAddressB, addr))
...@@ -74,9 +74,9 @@ static struct node_entry *find_node_by_AddrB(struct list_head *node_db, ...@@ -74,9 +74,9 @@ static struct node_entry *find_node_by_AddrB(struct list_head *node_db,
/* Search for mac entry. Caller must hold rcu read lock. /* Search for mac entry. Caller must hold rcu read lock.
*/ */
struct node_entry *hsr_find_node(struct list_head *node_db, struct sk_buff *skb) struct hsr_node *hsr_find_node(struct list_head *node_db, struct sk_buff *skb)
{ {
struct node_entry *node; struct hsr_node *node;
struct ethhdr *ethhdr; struct ethhdr *ethhdr;
if (!skb_mac_header_was_set(skb)) if (!skb_mac_header_was_set(skb))
...@@ -102,7 +102,7 @@ int hsr_create_self_node(struct list_head *self_node_db, ...@@ -102,7 +102,7 @@ int hsr_create_self_node(struct list_head *self_node_db,
unsigned char addr_a[ETH_ALEN], unsigned char addr_a[ETH_ALEN],
unsigned char addr_b[ETH_ALEN]) unsigned char addr_b[ETH_ALEN])
{ {
struct node_entry *node, *oldnode; struct hsr_node *node, *oldnode;
node = kmalloc(sizeof(*node), GFP_KERNEL); node = kmalloc(sizeof(*node), GFP_KERNEL);
if (!node) if (!node)
...@@ -113,7 +113,7 @@ int hsr_create_self_node(struct list_head *self_node_db, ...@@ -113,7 +113,7 @@ int hsr_create_self_node(struct list_head *self_node_db,
rcu_read_lock(); rcu_read_lock();
oldnode = list_first_or_null_rcu(self_node_db, oldnode = list_first_or_null_rcu(self_node_db,
struct node_entry, mac_list); struct hsr_node, mac_list);
if (oldnode) { if (oldnode) {
list_replace_rcu(&oldnode->mac_list, &node->mac_list); list_replace_rcu(&oldnode->mac_list, &node->mac_list);
rcu_read_unlock(); rcu_read_unlock();
...@@ -154,8 +154,8 @@ int hsr_create_self_node(struct list_head *self_node_db, ...@@ -154,8 +154,8 @@ int hsr_create_self_node(struct list_head *self_node_db,
* We also need to detect if the sender's SlaveA and SlaveB cables have been * We also need to detect if the sender's SlaveA and SlaveB cables have been
* swapped. * swapped.
*/ */
struct node_entry *hsr_merge_node(struct hsr_priv *hsr_priv, struct hsr_node *hsr_merge_node(struct hsr_priv *hsr,
struct node_entry *node, struct hsr_node *node,
struct sk_buff *skb, struct sk_buff *skb,
enum hsr_dev_idx dev_idx) enum hsr_dev_idx dev_idx)
{ {
...@@ -194,7 +194,7 @@ struct node_entry *hsr_merge_node(struct hsr_priv *hsr_priv, ...@@ -194,7 +194,7 @@ struct node_entry *hsr_merge_node(struct hsr_priv *hsr_priv,
if (node) if (node)
return node; return node;
node = find_node_by_AddrA(&hsr_priv->node_db, hsr_sp->MacAddressA); node = find_node_by_AddrA(&hsr->node_db, hsr_sp->MacAddressA);
if (node) { if (node) {
/* Node is known, but frame was received from an unknown /* Node is known, but frame was received from an unknown
* address. Node is PICS_SUBS capable; merge its AddrB. * address. Node is PICS_SUBS capable; merge its AddrB.
...@@ -224,7 +224,7 @@ struct node_entry *hsr_merge_node(struct hsr_priv *hsr_priv, ...@@ -224,7 +224,7 @@ struct node_entry *hsr_merge_node(struct hsr_priv *hsr_priv,
for (i = 0; i < HSR_MAX_DEV; i++) for (i = 0; i < HSR_MAX_DEV; i++)
node->seq_out[i] = ntohs(hsr_ethsup->hsr_sup.sequence_nr) - 1; node->seq_out[i] = ntohs(hsr_ethsup->hsr_sup.sequence_nr) - 1;
list_add_tail_rcu(&node->mac_list, &hsr_priv->node_db); list_add_tail_rcu(&node->mac_list, &hsr->node_db);
return node; return node;
} }
...@@ -236,10 +236,10 @@ struct node_entry *hsr_merge_node(struct hsr_priv *hsr_priv, ...@@ -236,10 +236,10 @@ struct node_entry *hsr_merge_node(struct hsr_priv *hsr_priv,
* address with that node's "official" address (MacAddressA) so that upper * address with that node's "official" address (MacAddressA) so that upper
* layers recognize where it came from. * layers recognize where it came from.
*/ */
void hsr_addr_subst_source(struct hsr_priv *hsr_priv, struct sk_buff *skb) void hsr_addr_subst_source(struct hsr_priv *hsr, struct sk_buff *skb)
{ {
struct ethhdr *ethhdr; struct ethhdr *ethhdr;
struct node_entry *node; struct hsr_node *node;
if (!skb_mac_header_was_set(skb)) { if (!skb_mac_header_was_set(skb)) {
WARN_ONCE(1, "%s: Mac header not set\n", __func__); WARN_ONCE(1, "%s: Mac header not set\n", __func__);
...@@ -248,7 +248,7 @@ void hsr_addr_subst_source(struct hsr_priv *hsr_priv, struct sk_buff *skb) ...@@ -248,7 +248,7 @@ void hsr_addr_subst_source(struct hsr_priv *hsr_priv, struct sk_buff *skb)
ethhdr = (struct ethhdr *) skb_mac_header(skb); ethhdr = (struct ethhdr *) skb_mac_header(skb);
rcu_read_lock(); rcu_read_lock();
node = find_node_by_AddrB(&hsr_priv->node_db, ethhdr->h_source); node = find_node_by_AddrB(&hsr->node_db, ethhdr->h_source);
if (node) if (node)
ether_addr_copy(ethhdr->h_source, node->MacAddressA); ether_addr_copy(ethhdr->h_source, node->MacAddressA);
rcu_read_unlock(); rcu_read_unlock();
...@@ -264,13 +264,13 @@ void hsr_addr_subst_source(struct hsr_priv *hsr_priv, struct sk_buff *skb) ...@@ -264,13 +264,13 @@ void hsr_addr_subst_source(struct hsr_priv *hsr_priv, struct sk_buff *skb)
* This is needed to keep the packets flowing through switches that learn on * This is needed to keep the packets flowing through switches that learn on
* which "side" the different interfaces are. * which "side" the different interfaces are.
*/ */
void hsr_addr_subst_dest(struct hsr_priv *hsr_priv, struct ethhdr *ethhdr, void hsr_addr_subst_dest(struct hsr_priv *hsr, struct ethhdr *ethhdr,
enum hsr_dev_idx dev_idx) enum hsr_dev_idx dev_idx)
{ {
struct node_entry *node; struct hsr_node *node;
rcu_read_lock(); rcu_read_lock();
node = find_node_by_AddrA(&hsr_priv->node_db, ethhdr->h_dest); node = find_node_by_AddrA(&hsr->node_db, ethhdr->h_dest);
if (node && (node->AddrB_if == dev_idx)) if (node && (node->AddrB_if == dev_idx))
ether_addr_copy(ethhdr->h_dest, node->MacAddressB); ether_addr_copy(ethhdr->h_dest, node->MacAddressB);
rcu_read_unlock(); rcu_read_unlock();
...@@ -295,7 +295,7 @@ static bool seq_nr_after(u16 a, u16 b) ...@@ -295,7 +295,7 @@ static bool seq_nr_after(u16 a, u16 b)
#define seq_nr_before_or_eq(a, b) (!seq_nr_after((a), (b))) #define seq_nr_before_or_eq(a, b) (!seq_nr_after((a), (b)))
void hsr_register_frame_in(struct node_entry *node, enum hsr_dev_idx dev_idx) void hsr_register_frame_in(struct hsr_node *node, enum hsr_dev_idx dev_idx)
{ {
if ((dev_idx < 0) || (dev_idx >= HSR_MAX_SLAVE)) { if ((dev_idx < 0) || (dev_idx >= HSR_MAX_SLAVE)) {
WARN_ONCE(1, "%s: Invalid dev_idx (%d)\n", __func__, dev_idx); WARN_ONCE(1, "%s: Invalid dev_idx (%d)\n", __func__, dev_idx);
...@@ -314,7 +314,7 @@ void hsr_register_frame_in(struct node_entry *node, enum hsr_dev_idx dev_idx) ...@@ -314,7 +314,7 @@ void hsr_register_frame_in(struct node_entry *node, enum hsr_dev_idx dev_idx)
* 0 otherwise, or * 0 otherwise, or
* negative error code on error * negative error code on error
*/ */
int hsr_register_frame_out(struct node_entry *node, enum hsr_dev_idx dev_idx, int hsr_register_frame_out(struct hsr_node *node, enum hsr_dev_idx dev_idx,
struct sk_buff *skb) struct sk_buff *skb)
{ {
struct hsr_ethhdr *hsr_ethhdr; struct hsr_ethhdr *hsr_ethhdr;
...@@ -340,7 +340,7 @@ int hsr_register_frame_out(struct node_entry *node, enum hsr_dev_idx dev_idx, ...@@ -340,7 +340,7 @@ int hsr_register_frame_out(struct node_entry *node, enum hsr_dev_idx dev_idx,
static bool is_late(struct node_entry *node, enum hsr_dev_idx dev_idx) static bool is_late(struct hsr_node *node, enum hsr_dev_idx dev_idx)
{ {
enum hsr_dev_idx other; enum hsr_dev_idx other;
...@@ -366,14 +366,14 @@ static bool is_late(struct node_entry *node, enum hsr_dev_idx dev_idx) ...@@ -366,14 +366,14 @@ static bool is_late(struct node_entry *node, enum hsr_dev_idx dev_idx)
/* Remove stale sequence_nr records. Called by timer every /* Remove stale sequence_nr records. Called by timer every
* HSR_LIFE_CHECK_INTERVAL (two seconds or so). * HSR_LIFE_CHECK_INTERVAL (two seconds or so).
*/ */
void hsr_prune_nodes(struct hsr_priv *hsr_priv) void hsr_prune_nodes(struct hsr_priv *hsr)
{ {
struct node_entry *node; struct hsr_node *node;
unsigned long timestamp; unsigned long timestamp;
unsigned long time_a, time_b; unsigned long time_a, time_b;
rcu_read_lock(); rcu_read_lock();
list_for_each_entry_rcu(node, &hsr_priv->node_db, mac_list) { list_for_each_entry_rcu(node, &hsr->node_db, mac_list) {
/* Shorthand */ /* Shorthand */
time_a = node->time_in[HSR_DEV_SLAVE_A]; time_a = node->time_in[HSR_DEV_SLAVE_A];
time_b = node->time_in[HSR_DEV_SLAVE_B]; time_b = node->time_in[HSR_DEV_SLAVE_B];
...@@ -399,17 +399,17 @@ void hsr_prune_nodes(struct hsr_priv *hsr_priv) ...@@ -399,17 +399,17 @@ void hsr_prune_nodes(struct hsr_priv *hsr_priv)
msecs_to_jiffies(1.5*MAX_SLAVE_DIFF))) { msecs_to_jiffies(1.5*MAX_SLAVE_DIFF))) {
if (is_late(node, HSR_DEV_SLAVE_A)) if (is_late(node, HSR_DEV_SLAVE_A))
hsr_nl_ringerror(hsr_priv, node->MacAddressA, hsr_nl_ringerror(hsr, node->MacAddressA,
HSR_DEV_SLAVE_A); HSR_DEV_SLAVE_A);
else if (is_late(node, HSR_DEV_SLAVE_B)) else if (is_late(node, HSR_DEV_SLAVE_B))
hsr_nl_ringerror(hsr_priv, node->MacAddressA, hsr_nl_ringerror(hsr, node->MacAddressA,
HSR_DEV_SLAVE_B); HSR_DEV_SLAVE_B);
} }
/* Prune old entries */ /* Prune old entries */
if (time_is_before_jiffies(timestamp + if (time_is_before_jiffies(timestamp +
msecs_to_jiffies(HSR_NODE_FORGET_TIME))) { msecs_to_jiffies(HSR_NODE_FORGET_TIME))) {
hsr_nl_nodedown(hsr_priv, node->MacAddressA); hsr_nl_nodedown(hsr, node->MacAddressA);
list_del_rcu(&node->mac_list); list_del_rcu(&node->mac_list);
/* Note that we need to free this entry later: */ /* Note that we need to free this entry later: */
kfree_rcu(node, rcu_head); kfree_rcu(node, rcu_head);
...@@ -419,21 +419,21 @@ void hsr_prune_nodes(struct hsr_priv *hsr_priv) ...@@ -419,21 +419,21 @@ void hsr_prune_nodes(struct hsr_priv *hsr_priv)
} }
void *hsr_get_next_node(struct hsr_priv *hsr_priv, void *_pos, void *hsr_get_next_node(struct hsr_priv *hsr, void *_pos,
unsigned char addr[ETH_ALEN]) unsigned char addr[ETH_ALEN])
{ {
struct node_entry *node; struct hsr_node *node;
if (!_pos) { if (!_pos) {
node = list_first_or_null_rcu(&hsr_priv->node_db, node = list_first_or_null_rcu(&hsr->node_db,
struct node_entry, mac_list); struct hsr_node, mac_list);
if (node) if (node)
ether_addr_copy(addr, node->MacAddressA); ether_addr_copy(addr, node->MacAddressA);
return node; return node;
} }
node = _pos; node = _pos;
list_for_each_entry_continue_rcu(node, &hsr_priv->node_db, mac_list) { list_for_each_entry_continue_rcu(node, &hsr->node_db, mac_list) {
ether_addr_copy(addr, node->MacAddressA); ether_addr_copy(addr, node->MacAddressA);
return node; return node;
} }
...@@ -442,7 +442,7 @@ void *hsr_get_next_node(struct hsr_priv *hsr_priv, void *_pos, ...@@ -442,7 +442,7 @@ void *hsr_get_next_node(struct hsr_priv *hsr_priv, void *_pos,
} }
int hsr_get_node_data(struct hsr_priv *hsr_priv, int hsr_get_node_data(struct hsr_priv *hsr,
const unsigned char *addr, const unsigned char *addr,
unsigned char addr_b[ETH_ALEN], unsigned char addr_b[ETH_ALEN],
unsigned int *addr_b_ifindex, unsigned int *addr_b_ifindex,
...@@ -451,12 +451,12 @@ int hsr_get_node_data(struct hsr_priv *hsr_priv, ...@@ -451,12 +451,12 @@ int hsr_get_node_data(struct hsr_priv *hsr_priv,
int *if2_age, int *if2_age,
u16 *if2_seq) u16 *if2_seq)
{ {
struct node_entry *node; struct hsr_node *node;
unsigned long tdiff; unsigned long tdiff;
rcu_read_lock(); rcu_read_lock();
node = find_node_by_AddrA(&hsr_priv->node_db, addr); node = find_node_by_AddrA(&hsr->node_db, addr);
if (!node) { if (!node) {
rcu_read_unlock(); rcu_read_unlock();
return -ENOENT; /* No such entry */ return -ENOENT; /* No such entry */
...@@ -488,8 +488,8 @@ int hsr_get_node_data(struct hsr_priv *hsr_priv, ...@@ -488,8 +488,8 @@ int hsr_get_node_data(struct hsr_priv *hsr_priv,
*if1_seq = node->seq_out[HSR_DEV_SLAVE_B]; *if1_seq = node->seq_out[HSR_DEV_SLAVE_B];
*if2_seq = node->seq_out[HSR_DEV_SLAVE_A]; *if2_seq = node->seq_out[HSR_DEV_SLAVE_A];
if ((node->AddrB_if != HSR_DEV_NONE) && hsr_priv->slave[node->AddrB_if]) if ((node->AddrB_if != HSR_DEV_NONE) && hsr->slave[node->AddrB_if])
*addr_b_ifindex = hsr_priv->slave[node->AddrB_if]->ifindex; *addr_b_ifindex = hsr->slave[node->AddrB_if]->ifindex;
else else
*addr_b_ifindex = -1; *addr_b_ifindex = -1;
......
/* Copyright 2011-2013 Autronica Fire and Security AS /* Copyright 2011-2014 Autronica Fire and Security AS
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free * under the terms of the GNU General Public License as published by the Free
...@@ -6,42 +6,42 @@ ...@@ -6,42 +6,42 @@
* any later version. * any later version.
* *
* Author(s): * Author(s):
* 2011-2013 Arvid Brodin, arvid.brodin@xdin.com * 2011-2014 Arvid Brodin, arvid.brodin@alten.se
*/ */
#ifndef _HSR_FRAMEREG_H #ifndef __HSR_FRAMEREG_H
#define _HSR_FRAMEREG_H #define __HSR_FRAMEREG_H
#include "hsr_main.h" #include "hsr_main.h"
struct node_entry; struct hsr_node;
struct node_entry *hsr_find_node(struct list_head *node_db, struct sk_buff *skb); struct hsr_node *hsr_find_node(struct list_head *node_db, struct sk_buff *skb);
struct node_entry *hsr_merge_node(struct hsr_priv *hsr_priv, struct hsr_node *hsr_merge_node(struct hsr_priv *hsr,
struct node_entry *node, struct hsr_node *node,
struct sk_buff *skb, struct sk_buff *skb,
enum hsr_dev_idx dev_idx); enum hsr_dev_idx dev_idx);
void hsr_addr_subst_source(struct hsr_priv *hsr_priv, struct sk_buff *skb); void hsr_addr_subst_source(struct hsr_priv *hsr, struct sk_buff *skb);
void hsr_addr_subst_dest(struct hsr_priv *hsr_priv, struct ethhdr *ethhdr, void hsr_addr_subst_dest(struct hsr_priv *hsr, struct ethhdr *ethhdr,
enum hsr_dev_idx dev_idx); enum hsr_dev_idx dev_idx);
void hsr_register_frame_in(struct node_entry *node, enum hsr_dev_idx dev_idx); void hsr_register_frame_in(struct hsr_node *node, enum hsr_dev_idx dev_idx);
int hsr_register_frame_out(struct node_entry *node, enum hsr_dev_idx dev_idx, int hsr_register_frame_out(struct hsr_node *node, enum hsr_dev_idx dev_idx,
struct sk_buff *skb); struct sk_buff *skb);
void hsr_prune_nodes(struct hsr_priv *hsr_priv); void hsr_prune_nodes(struct hsr_priv *hsr);
int hsr_create_self_node(struct list_head *self_node_db, int hsr_create_self_node(struct list_head *self_node_db,
unsigned char addr_a[ETH_ALEN], unsigned char addr_a[ETH_ALEN],
unsigned char addr_b[ETH_ALEN]); unsigned char addr_b[ETH_ALEN]);
void *hsr_get_next_node(struct hsr_priv *hsr_priv, void *_pos, void *hsr_get_next_node(struct hsr_priv *hsr, void *_pos,
unsigned char addr[ETH_ALEN]); unsigned char addr[ETH_ALEN]);
int hsr_get_node_data(struct hsr_priv *hsr_priv, int hsr_get_node_data(struct hsr_priv *hsr,
const unsigned char *addr, const unsigned char *addr,
unsigned char addr_b[ETH_ALEN], unsigned char addr_b[ETH_ALEN],
unsigned int *addr_b_ifindex, unsigned int *addr_b_ifindex,
...@@ -50,4 +50,4 @@ int hsr_get_node_data(struct hsr_priv *hsr_priv, ...@@ -50,4 +50,4 @@ int hsr_get_node_data(struct hsr_priv *hsr_priv,
int *if2_age, int *if2_age,
u16 *if2_seq); u16 *if2_seq);
#endif /* _HSR_FRAMEREG_H */ #endif /* __HSR_FRAMEREG_H */
This diff is collapsed.
/* Copyright 2011-2013 Autronica Fire and Security AS /* Copyright 2011-2014 Autronica Fire and Security AS
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free * under the terms of the GNU General Public License as published by the Free
...@@ -6,11 +6,11 @@ ...@@ -6,11 +6,11 @@
* any later version. * any later version.
* *
* Author(s): * Author(s):
* 2011-2013 Arvid Brodin, arvid.brodin@xdin.com * 2011-2014 Arvid Brodin, arvid.brodin@alten.se
*/ */
#ifndef _HSR_PRIVATE_H #ifndef __HSR_PRIVATE_H
#define _HSR_PRIVATE_H #define __HSR_PRIVATE_H
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include <linux/list.h> #include <linux/list.h>
...@@ -46,16 +46,16 @@ ...@@ -46,16 +46,16 @@
* path, LSDU_size, sequence Nr }. But we let eth_header() create { h_dest, * path, LSDU_size, sequence Nr }. But we let eth_header() create { h_dest,
* h_source, h_proto = 0x88FB }, and add { path, LSDU_size, sequence Nr, * h_source, h_proto = 0x88FB }, and add { path, LSDU_size, sequence Nr,
* encapsulated protocol } instead. * encapsulated protocol } instead.
*
* Field names as defined in the IEC:2010 standard for HSR.
*/ */
#define HSR_TAGLEN 6
/* Field names below as defined in the IEC:2010 standard for HSR. */
struct hsr_tag { struct hsr_tag {
__be16 path_and_LSDU_size; __be16 path_and_LSDU_size;
__be16 sequence_nr; __be16 sequence_nr;
__be16 encap_proto; __be16 encap_proto;
} __packed; } __packed;
#define HSR_HLEN 6
/* The helper functions below assumes that 'path' occupies the 4 most /* The helper functions below assumes that 'path' occupies the 4 most
* significant bits of the 16-bit field shared by 'path' and 'LSDU_size' (or * significant bits of the 16-bit field shared by 'path' and 'LSDU_size' (or
...@@ -159,8 +159,8 @@ struct hsr_priv { ...@@ -159,8 +159,8 @@ struct hsr_priv {
unsigned char sup_multicast_addr[ETH_ALEN]; unsigned char sup_multicast_addr[ETH_ALEN];
}; };
void register_hsr_master(struct hsr_priv *hsr_priv); void register_hsr_master(struct hsr_priv *hsr);
void unregister_hsr_master(struct hsr_priv *hsr_priv); void unregister_hsr_master(struct hsr_priv *hsr);
bool is_hsr_slave(struct net_device *dev); bool is_hsr_slave(struct net_device *dev);
#endif /* _HSR_PRIVATE_H */ #endif /* __HSR_PRIVATE_H */
/* Copyright 2011-2013 Autronica Fire and Security AS /* Copyright 2011-2014 Autronica Fire and Security AS
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free * under the terms of the GNU General Public License as published by the Free
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* any later version. * any later version.
* *
* Author(s): * Author(s):
* 2011-2013 Arvid Brodin, arvid.brodin@xdin.com * 2011-2014 Arvid Brodin, arvid.brodin@alten.se
* *
* Routines for handling Netlink messages for HSR. * Routines for handling Netlink messages for HSR.
*/ */
...@@ -63,21 +63,21 @@ static int hsr_newlink(struct net *src_net, struct net_device *dev, ...@@ -63,21 +63,21 @@ static int hsr_newlink(struct net *src_net, struct net_device *dev,
static int hsr_fill_info(struct sk_buff *skb, const struct net_device *dev) static int hsr_fill_info(struct sk_buff *skb, const struct net_device *dev)
{ {
struct hsr_priv *hsr_priv; struct hsr_priv *hsr;
hsr_priv = netdev_priv(dev); hsr = netdev_priv(dev);
if (hsr_priv->slave[0]) if (hsr->slave[0])
if (nla_put_u32(skb, IFLA_HSR_SLAVE1, hsr_priv->slave[0]->ifindex)) if (nla_put_u32(skb, IFLA_HSR_SLAVE1, hsr->slave[0]->ifindex))
goto nla_put_failure; goto nla_put_failure;
if (hsr_priv->slave[1]) if (hsr->slave[1])
if (nla_put_u32(skb, IFLA_HSR_SLAVE2, hsr_priv->slave[1]->ifindex)) if (nla_put_u32(skb, IFLA_HSR_SLAVE2, hsr->slave[1]->ifindex))
goto nla_put_failure; goto nla_put_failure;
if (nla_put(skb, IFLA_HSR_SUPERVISION_ADDR, ETH_ALEN, if (nla_put(skb, IFLA_HSR_SUPERVISION_ADDR, ETH_ALEN,
hsr_priv->sup_multicast_addr) || hsr->sup_multicast_addr) ||
nla_put_u16(skb, IFLA_HSR_SEQ_NR, hsr_priv->sequence_nr)) nla_put_u16(skb, IFLA_HSR_SEQ_NR, hsr->sequence_nr))
goto nla_put_failure; goto nla_put_failure;
return 0; return 0;
...@@ -128,7 +128,7 @@ static const struct genl_multicast_group hsr_mcgrps[] = { ...@@ -128,7 +128,7 @@ static const struct genl_multicast_group hsr_mcgrps[] = {
* over one of the slave interfaces. This would indicate an open network ring * over one of the slave interfaces. This would indicate an open network ring
* (i.e. a link has failed somewhere). * (i.e. a link has failed somewhere).
*/ */
void hsr_nl_ringerror(struct hsr_priv *hsr_priv, unsigned char addr[ETH_ALEN], void hsr_nl_ringerror(struct hsr_priv *hsr, unsigned char addr[ETH_ALEN],
enum hsr_dev_idx dev_idx) enum hsr_dev_idx dev_idx)
{ {
struct sk_buff *skb; struct sk_buff *skb;
...@@ -148,8 +148,8 @@ void hsr_nl_ringerror(struct hsr_priv *hsr_priv, unsigned char addr[ETH_ALEN], ...@@ -148,8 +148,8 @@ void hsr_nl_ringerror(struct hsr_priv *hsr_priv, unsigned char addr[ETH_ALEN],
if (res < 0) if (res < 0)
goto nla_put_failure; goto nla_put_failure;
if (hsr_priv->slave[dev_idx]) if (hsr->slave[dev_idx])
ifindex = hsr_priv->slave[dev_idx]->ifindex; ifindex = hsr->slave[dev_idx]->ifindex;
else else
ifindex = -1; ifindex = -1;
res = nla_put_u32(skb, HSR_A_IFINDEX, ifindex); res = nla_put_u32(skb, HSR_A_IFINDEX, ifindex);
...@@ -165,13 +165,13 @@ void hsr_nl_ringerror(struct hsr_priv *hsr_priv, unsigned char addr[ETH_ALEN], ...@@ -165,13 +165,13 @@ void hsr_nl_ringerror(struct hsr_priv *hsr_priv, unsigned char addr[ETH_ALEN],
kfree_skb(skb); kfree_skb(skb);
fail: fail:
netdev_warn(hsr_priv->dev, "Could not send HSR ring error message\n"); netdev_warn(hsr->dev, "Could not send HSR ring error message\n");
} }
/* This is called when we haven't heard from the node with MAC address addr for /* This is called when we haven't heard from the node with MAC address addr for
* some time (just before the node is removed from the node table/list). * some time (just before the node is removed from the node table/list).
*/ */
void hsr_nl_nodedown(struct hsr_priv *hsr_priv, unsigned char addr[ETH_ALEN]) void hsr_nl_nodedown(struct hsr_priv *hsr, unsigned char addr[ETH_ALEN])
{ {
struct sk_buff *skb; struct sk_buff *skb;
void *msg_head; void *msg_head;
...@@ -199,7 +199,7 @@ void hsr_nl_nodedown(struct hsr_priv *hsr_priv, unsigned char addr[ETH_ALEN]) ...@@ -199,7 +199,7 @@ void hsr_nl_nodedown(struct hsr_priv *hsr_priv, unsigned char addr[ETH_ALEN])
kfree_skb(skb); kfree_skb(skb);
fail: fail:
netdev_warn(hsr_priv->dev, "Could not send HSR node down\n"); netdev_warn(hsr->dev, "Could not send HSR node down\n");
} }
...@@ -220,7 +220,7 @@ static int hsr_get_node_status(struct sk_buff *skb_in, struct genl_info *info) ...@@ -220,7 +220,7 @@ static int hsr_get_node_status(struct sk_buff *skb_in, struct genl_info *info)
/* For sending */ /* For sending */
struct sk_buff *skb_out; struct sk_buff *skb_out;
void *msg_head; void *msg_head;
struct hsr_priv *hsr_priv; struct hsr_priv *hsr;
unsigned char hsr_node_addr_b[ETH_ALEN]; unsigned char hsr_node_addr_b[ETH_ALEN];
int hsr_node_if1_age; int hsr_node_if1_age;
u16 hsr_node_if1_seq; u16 hsr_node_if1_seq;
...@@ -267,8 +267,8 @@ static int hsr_get_node_status(struct sk_buff *skb_in, struct genl_info *info) ...@@ -267,8 +267,8 @@ static int hsr_get_node_status(struct sk_buff *skb_in, struct genl_info *info)
if (res < 0) if (res < 0)
goto nla_put_failure; goto nla_put_failure;
hsr_priv = netdev_priv(hsr_dev); hsr = netdev_priv(hsr_dev);
res = hsr_get_node_data(hsr_priv, res = hsr_get_node_data(hsr,
(unsigned char *) nla_data(info->attrs[HSR_A_NODE_ADDR]), (unsigned char *) nla_data(info->attrs[HSR_A_NODE_ADDR]),
hsr_node_addr_b, hsr_node_addr_b,
&addr_b_ifindex, &addr_b_ifindex,
...@@ -301,9 +301,9 @@ static int hsr_get_node_status(struct sk_buff *skb_in, struct genl_info *info) ...@@ -301,9 +301,9 @@ static int hsr_get_node_status(struct sk_buff *skb_in, struct genl_info *info)
res = nla_put_u16(skb_out, HSR_A_IF1_SEQ, hsr_node_if1_seq); res = nla_put_u16(skb_out, HSR_A_IF1_SEQ, hsr_node_if1_seq);
if (res < 0) if (res < 0)
goto nla_put_failure; goto nla_put_failure;
if (hsr_priv->slave[0]) if (hsr->slave[0])
res = nla_put_u32(skb_out, HSR_A_IF1_IFINDEX, res = nla_put_u32(skb_out, HSR_A_IF1_IFINDEX,
hsr_priv->slave[0]->ifindex); hsr->slave[0]->ifindex);
if (res < 0) if (res < 0)
goto nla_put_failure; goto nla_put_failure;
...@@ -313,9 +313,9 @@ static int hsr_get_node_status(struct sk_buff *skb_in, struct genl_info *info) ...@@ -313,9 +313,9 @@ static int hsr_get_node_status(struct sk_buff *skb_in, struct genl_info *info)
res = nla_put_u16(skb_out, HSR_A_IF2_SEQ, hsr_node_if2_seq); res = nla_put_u16(skb_out, HSR_A_IF2_SEQ, hsr_node_if2_seq);
if (res < 0) if (res < 0)
goto nla_put_failure; goto nla_put_failure;
if (hsr_priv->slave[1]) if (hsr->slave[1])
res = nla_put_u32(skb_out, HSR_A_IF2_IFINDEX, res = nla_put_u32(skb_out, HSR_A_IF2_IFINDEX,
hsr_priv->slave[1]->ifindex); hsr->slave[1]->ifindex);
genlmsg_end(skb_out, msg_head); genlmsg_end(skb_out, msg_head);
genlmsg_unicast(genl_info_net(info), skb_out, info->snd_portid); genlmsg_unicast(genl_info_net(info), skb_out, info->snd_portid);
...@@ -345,7 +345,7 @@ static int hsr_get_node_list(struct sk_buff *skb_in, struct genl_info *info) ...@@ -345,7 +345,7 @@ static int hsr_get_node_list(struct sk_buff *skb_in, struct genl_info *info)
/* For sending */ /* For sending */
struct sk_buff *skb_out; struct sk_buff *skb_out;
void *msg_head; void *msg_head;
struct hsr_priv *hsr_priv; struct hsr_priv *hsr;
void *pos; void *pos;
unsigned char addr[ETH_ALEN]; unsigned char addr[ETH_ALEN];
int res; int res;
...@@ -385,17 +385,17 @@ static int hsr_get_node_list(struct sk_buff *skb_in, struct genl_info *info) ...@@ -385,17 +385,17 @@ static int hsr_get_node_list(struct sk_buff *skb_in, struct genl_info *info)
if (res < 0) if (res < 0)
goto nla_put_failure; goto nla_put_failure;
hsr_priv = netdev_priv(hsr_dev); hsr = netdev_priv(hsr_dev);
rcu_read_lock(); rcu_read_lock();
pos = hsr_get_next_node(hsr_priv, NULL, addr); pos = hsr_get_next_node(hsr, NULL, addr);
while (pos) { while (pos) {
res = nla_put(skb_out, HSR_A_NODE_ADDR, ETH_ALEN, addr); res = nla_put(skb_out, HSR_A_NODE_ADDR, ETH_ALEN, addr);
if (res < 0) { if (res < 0) {
rcu_read_unlock(); rcu_read_unlock();
goto nla_put_failure; goto nla_put_failure;
} }
pos = hsr_get_next_node(hsr_priv, pos, addr); pos = hsr_get_next_node(hsr, pos, addr);
} }
rcu_read_unlock(); rcu_read_unlock();
......
/* Copyright 2011-2013 Autronica Fire and Security AS /* Copyright 2011-2014 Autronica Fire and Security AS
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free * under the terms of the GNU General Public License as published by the Free
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* any later version. * any later version.
* *
* Author(s): * Author(s):
* 2011-2013 Arvid Brodin, arvid.brodin@xdin.com * 2011-2014 Arvid Brodin, arvid.brodin@alten.se
*/ */
#ifndef __HSR_NETLINK_H #ifndef __HSR_NETLINK_H
...@@ -21,9 +21,9 @@ struct hsr_priv; ...@@ -21,9 +21,9 @@ struct hsr_priv;
int __init hsr_netlink_init(void); int __init hsr_netlink_init(void);
void __exit hsr_netlink_exit(void); void __exit hsr_netlink_exit(void);
void hsr_nl_ringerror(struct hsr_priv *hsr_priv, unsigned char addr[ETH_ALEN], void hsr_nl_ringerror(struct hsr_priv *hsr, unsigned char addr[ETH_ALEN],
int dev_idx); int dev_idx);
void hsr_nl_nodedown(struct hsr_priv *hsr_priv, unsigned char addr[ETH_ALEN]); void hsr_nl_nodedown(struct hsr_priv *hsr, unsigned char addr[ETH_ALEN]);
void hsr_nl_framedrop(int dropcount, int dev_idx); void hsr_nl_framedrop(int dropcount, int dev_idx);
void hsr_nl_linkdown(int dev_idx); void hsr_nl_linkdown(int dev_idx);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment