This RFC series add support for Parallel Redundancy Protocol (PRP)
as defined in IEC-62439-3 in the kernel networking subsystem. PRP
Uses a Redundancy Control Trailer (RCT) the format of which is
similar to HSR Tag. This is used for implementing redundancy.
RCT consists of 6 bytes similar to HSR tag and contain following
fields:-
- 16-bit sequence number (SeqNr);
- 4-bit LAN identifier (LanId);
- 12 bit frame size (LSDUsize);
- 16-bit suffix (PRPsuffix).
The PRPsuffix identifies PRP frames and distinguishes PRP frames
from other protocols that also append a trailer to their useful
data. The LSDUsize field allows the receiver to distinguish PRP
frames from random, nonredundant frames as an additional check.
LSDUsize is the size of the Ethernet payload inclusive of the
RCT. Sequence number along with LanId is used for duplicate
detection and discard.
PRP node is also known as Dual Attached Node (DAN-P) since it
is typically attached to two different LAN for redundancy.
DAN-P duplicates each of L2 frames and send it over the two
Ethernet links. Each outgoing frame is appended with RCT.
Unlike HSR, these are added to the end of L2 frame and may be
treated as padding by bridges and therefore would be work with
traditional bridges or switches, where as HSR wouldn't as Tag
is prefixed to the Ethenet frame. At the remote end, these are
received and the duplicate frame is discarded before the stripped
frame is send up the networking stack. Like HSR, PRP also sends
periodic Supervision frames to the network. These frames are
received and MAC address from the SV frames are populated in a
database called Node Table. The above functions are grouped into
a block called Link Redundancy Entity (LRE) in the IEC spec.
As there are many similarities between HSR and PRP protocols,
this patch re-use the code from HSR driver to implement PRP
driver. As many part of the code can be re-used, this patch
introduces a new common API definitions for both protocols and
propose to obsolete the existing HSR defines in
include/uapi/linux/if_link.h. New definitions are prefixed
with a HSR_PRP prefix. Similarly include/uapi/linux/hsr_netlink.h
is proposed to be replaced with include/uapi/linux/hsr_prp_netlink.h
which also uses the HSR_PRP prefix. The netlink socket interface
code is migrated (as well as the iproute2 being sent as a follow up
patch) to use the new API definitions. To re-use the code,
following are done as a preparatory patch before adding the PRP
functionality:-
- prefix all common code with hsr_prp
- net/hsr -> renamed to net/hsr-prp
- All common struct types, constants, functions renamed with
hsr{HSR}_prp{PRP} prefix.
Please review this and provide me feedback so that I can work to
incorporate them and send a formal patch series for this. As this
series impacts user space, I am not sure if this is the right
approach to introduce a new definitions and obsolete the old
API definitions for HSR. The current approach is choosen
to avoid redundant code in iproute2 and in the netlink driver
code (hsr_netlink.c). Other approach we discussed internally was
to Keep the HSR prefix in the user space and kernel code, but
live with the redundant code in the iproute2 and hsr netlink
code. Would like to hear from you what is the best way to add
this feature to networking core. If there is any other
alternative approach possible, I would like to hear about the
same.
The patch was tested using two TI AM57x IDK boards which are
connected back to back over two CPSW ports.
Script used for creating the hsr/prp interface is given below
and uses the ip link command. Also provided logs from the tests
I have executed for your reference.
iproute2 related patches will follow soon....
Murali Karicheri
Texas Instruments
============ setup.sh =================================================
#!/bin/sh
if [ $# -lt 4 ]
then
echo "setup-cpsw.sh <hsr/prp> <MAC-Address of slave-A>"
echo " <ip address for hsr/prp interface>"
echo " <if_name of hsr/prp interface>"
exit
fi
if [ "$1" != "hsr" ] && [ "$1" != "prp" ]
then
echo "use hsr or prp as first argument"
exit
fi
if_a=eth2
if_b=eth3
if_name=$4
ifconfig $if_a down
ifconfig $if_b down
ifconfig $if_a hw ether $2
ifconfig $if_b hw ether $2
ifconfig $if_a up
ifconfig $if_b up
echo "Setting up $if_name with MAC address $2 for slaves and IP address $3"
echo " using $if_a and $if_b"
if [ "$1" = "hsr" ]; then
options="version 1"
else
options=""
fi
ip link add name $if_name type $1 slave1 $if_a slave2 $if_b supervision 0 $options
ifconfig $if_name $3 up
==================================================================================
PRP Logs:
DUT-1 : https://pastebin.ubuntu.com/p/hhsRjTQpcr/
DUT-2 : https://pastebin.ubuntu.com/p/snPFKhnpk4/
HSR Logs:
DUT-1 : https://pastebin.ubuntu.com/p/FZPNc6Nwdm/
DUT-2 : https://pastebin.ubuntu.com/p/CtV4ZVS3Yd/
Murali Karicheri (13):
net: hsr: Re-use Kconfig option to support PRP
net: hsr: rename hsr directory to hsr-prp to introduce PRP
net: hsr: rename files to introduce PRP support
net: hsr: rename hsr variable inside struct hsr_port to priv
net: hsr: rename hsr_port_get_hsr() to hsr_prp_get_port()
net: hsr: some renaming to introduce PRP driver support
net: hsr: introduce common uapi include/definitions for HSR and PRP
net: hsr: migrate HSR netlink socket code to use new common API
net: hsr: move re-usable code for PRP to hsr_prp_netlink.c
net: hsr: add netlink socket interface for PRP
net: prp: add supervision frame generation and handling support
net: prp: add packet handling support
net: prp: enhance debugfs to display PRP specific info in node table
MAINTAINERS | 2 +-
include/uapi/linux/hsr_netlink.h | 3 +
include/uapi/linux/hsr_prp_netlink.h | 50 ++
include/uapi/linux/if_link.h | 19 +
net/Kconfig | 2 +-
net/Makefile | 2 +-
net/hsr-prp/Kconfig | 37 ++
net/hsr-prp/Makefile | 11 +
net/hsr-prp/hsr_netlink.c | 202 +++++++
net/{hsr => hsr-prp}/hsr_netlink.h | 15 +-
.../hsr_prp_debugfs.c} | 82 +--
net/hsr-prp/hsr_prp_device.c | 562 ++++++++++++++++++
net/hsr-prp/hsr_prp_device.h | 23 +
net/hsr-prp/hsr_prp_forward.c | 558 +++++++++++++++++
.../hsr_prp_forward.h} | 10 +-
.../hsr_prp_framereg.c} | 323 +++++-----
net/hsr-prp/hsr_prp_framereg.h | 68 +++
net/hsr-prp/hsr_prp_main.c | 194 ++++++
net/hsr-prp/hsr_prp_main.h | 289 +++++++++
net/hsr-prp/hsr_prp_netlink.c | 365 ++++++++++++
net/hsr-prp/hsr_prp_netlink.h | 28 +
net/hsr-prp/hsr_prp_slave.c | 222 +++++++
net/hsr-prp/hsr_prp_slave.h | 37 ++
net/hsr-prp/prp_netlink.c | 141 +++++
net/hsr-prp/prp_netlink.h | 27 +
net/hsr/Kconfig | 29 -
net/hsr/Makefile | 10 -
net/hsr/hsr_device.c | 509 ----------------
net/hsr/hsr_device.h | 22 -
net/hsr/hsr_forward.c | 379 ------------
net/hsr/hsr_framereg.h | 62 --
net/hsr/hsr_main.c | 154 -----
net/hsr/hsr_main.h | 188 ------
net/hsr/hsr_netlink.c | 514 ----------------
net/hsr/hsr_slave.c | 198 ------
net/hsr/hsr_slave.h | 33 -
36 files changed, 3084 insertions(+), 2286 deletions(-)
create mode 100644 include/uapi/linux/hsr_prp_netlink.h
create mode 100644 net/hsr-prp/Kconfig
create mode 100644 net/hsr-prp/Makefile
create mode 100644 net/hsr-prp/hsr_netlink.c
rename net/{hsr => hsr-prp}/hsr_netlink.h (58%)
rename net/{hsr/hsr_debugfs.c => hsr-prp/hsr_prp_debugfs.c} (52%)
create mode 100644 net/hsr-prp/hsr_prp_device.c
create mode 100644 net/hsr-prp/hsr_prp_device.h
create mode 100644 net/hsr-prp/hsr_prp_forward.c
rename net/{hsr/hsr_forward.h => hsr-prp/hsr_prp_forward.h} (50%)
rename net/{hsr/hsr_framereg.c => hsr-prp/hsr_prp_framereg.c} (56%)
create mode 100644 net/hsr-prp/hsr_prp_framereg.h
create mode 100644 net/hsr-prp/hsr_prp_main.c
create mode 100644 net/hsr-prp/hsr_prp_main.h
create mode 100644 net/hsr-prp/hsr_prp_netlink.c
create mode 100644 net/hsr-prp/hsr_prp_netlink.h
create mode 100644 net/hsr-prp/hsr_prp_slave.c
create mode 100644 net/hsr-prp/hsr_prp_slave.h
create mode 100644 net/hsr-prp/prp_netlink.c
create mode 100644 net/hsr-prp/prp_netlink.h
delete mode 100644 net/hsr/Kconfig
delete mode 100644 net/hsr/Makefile
delete mode 100644 net/hsr/hsr_device.c
delete mode 100644 net/hsr/hsr_device.h
delete mode 100644 net/hsr/hsr_forward.c
delete mode 100644 net/hsr/hsr_framereg.h
delete mode 100644 net/hsr/hsr_main.c
delete mode 100644 net/hsr/hsr_main.h
delete mode 100644 net/hsr/hsr_netlink.c
delete mode 100644 net/hsr/hsr_slave.c
delete mode 100644 net/hsr/hsr_slave.h
--
2.17.1
Similar to HSR, add a netlink socket interface code re-using the
common functions from hsr_prp_netlink.c. Use wrapper functions
for hsr_dev_setup() and prp_dev_setup() to setup HSR/PRP interface
by calling common hsr_prp_dev_setup().
Signed-off-by: Murali Karicheri <[email protected]>
---
net/hsr-prp/Makefile | 2 +-
net/hsr-prp/hsr_netlink.c | 11 ++-
net/hsr-prp/hsr_netlink.h | 1 +
net/hsr-prp/hsr_prp_device.c | 34 +++++---
net/hsr-prp/hsr_prp_device.h | 3 +-
net/hsr-prp/hsr_prp_framereg.c | 6 +-
net/hsr-prp/hsr_prp_main.c | 51 ++++++++++--
net/hsr-prp/hsr_prp_main.h | 5 ++
net/hsr-prp/hsr_prp_netlink.c | 80 +++++++++----------
net/hsr-prp/hsr_prp_netlink.h | 5 +-
net/hsr-prp/prp_netlink.c | 141 +++++++++++++++++++++++++++++++++
net/hsr-prp/prp_netlink.h | 27 +++++++
12 files changed, 302 insertions(+), 64 deletions(-)
create mode 100644 net/hsr-prp/prp_netlink.c
create mode 100644 net/hsr-prp/prp_netlink.h
diff --git a/net/hsr-prp/Makefile b/net/hsr-prp/Makefile
index 76f266cd1976..9b84b0d813c2 100644
--- a/net/hsr-prp/Makefile
+++ b/net/hsr-prp/Makefile
@@ -7,5 +7,5 @@ obj-$(CONFIG_HSR_PRP) += hsr-prp.o
hsr-prp-y := hsr_prp_main.o hsr_prp_framereg.o \
hsr_prp_device.o hsr_netlink.o hsr_prp_slave.o \
- hsr_prp_forward.o hsr_prp_netlink.o
+ hsr_prp_forward.o hsr_prp_netlink.o prp_netlink.o
hsr-prp-$(CONFIG_DEBUG_FS) += hsr_prp_debugfs.o
diff --git a/net/hsr-prp/hsr_netlink.c b/net/hsr-prp/hsr_netlink.c
index 6bdb369ced36..f14ed521dcb2 100644
--- a/net/hsr-prp/hsr_netlink.c
+++ b/net/hsr-prp/hsr_netlink.c
@@ -32,7 +32,7 @@ static int hsr_newlink(struct net *src_net, struct net_device *dev,
struct nlattr *tb[], struct nlattr *data[],
struct netlink_ext_ack *extack)
{
- return hsr_prp_newlink(src_net, dev, tb, data, extack);
+ return hsr_prp_newlink(HSR, src_net, dev, tb, data, extack);
}
static struct rtnl_link_ops hsr_link_ops __read_mostly = {
@@ -40,7 +40,7 @@ static struct rtnl_link_ops hsr_link_ops __read_mostly = {
.maxtype = IFLA_HSR_PRP_MAX,
.policy = hsr_policy,
.priv_size = sizeof(struct hsr_prp_priv),
- .setup = hsr_prp_dev_setup,
+ .setup = hsr_dev_setup,
.newlink = hsr_newlink,
.fill_info = hsr_prp_fill_info,
};
@@ -188,10 +188,15 @@ int __init hsr_netlink_init(void)
return rc;
}
-void __exit hsr_netlink_exit(void)
+void hsr_nl_cleanup(void)
{
genl_unregister_family(&hsr_genl_family);
rtnl_link_unregister(&hsr_link_ops);
}
+void __exit hsr_netlink_exit(void)
+{
+ hsr_nl_cleanup();
+}
+
MODULE_ALIAS_RTNL_LINK("hsr");
diff --git a/net/hsr-prp/hsr_netlink.h b/net/hsr-prp/hsr_netlink.h
index df3d1acb08e0..b0e96193b09f 100644
--- a/net/hsr-prp/hsr_netlink.h
+++ b/net/hsr-prp/hsr_netlink.h
@@ -18,6 +18,7 @@ struct hsr_prp_port;
int __init hsr_netlink_init(void);
void __exit hsr_netlink_exit(void);
+void hsr_nl_cleanup(void);
void hsr_nl_ringerror(struct hsr_prp_priv *priv,
unsigned char addr[ETH_ALEN],
struct hsr_prp_port *port);
diff --git a/net/hsr-prp/hsr_prp_device.c b/net/hsr-prp/hsr_prp_device.c
index 43269c204445..501de23a97f5 100644
--- a/net/hsr-prp/hsr_prp_device.c
+++ b/net/hsr-prp/hsr_prp_device.c
@@ -321,7 +321,7 @@ static void hsr_prp_announce(struct timer_list *t)
rcu_read_lock();
master = hsr_prp_get_port(priv, HSR_PRP_PT_MASTER);
- if (priv->announce_count < 3 && priv->prot_version == 0) {
+ if (priv->announce_count < 3 && priv->prot_version == HSR_V0) {
send_hsr_prp_supervision_frame(master, HSR_TLV_ANNOUNCE,
priv->prot_version);
priv->announce_count++;
@@ -384,11 +384,7 @@ static const struct net_device_ops hsr_prp_device_ops = {
.ndo_uninit = hsr_prp_dev_destroy,
};
-static struct device_type hsr_type = {
- .name = "hsr",
-};
-
-void hsr_prp_dev_setup(struct net_device *dev)
+static void hsr_prp_dev_setup(struct net_device *dev, struct device_type *type)
{
eth_hw_addr_random(dev);
@@ -396,7 +392,7 @@ void hsr_prp_dev_setup(struct net_device *dev)
dev->min_mtu = 0;
dev->header_ops = &hsr_prp_header_ops;
dev->netdev_ops = &hsr_prp_device_ops;
- SET_NETDEV_DEVTYPE(dev, &hsr_type);
+ SET_NETDEV_DEVTYPE(dev, type);
dev->priv_flags |= IFF_NO_QUEUE;
dev->needs_free_netdev = true;
@@ -419,6 +415,24 @@ void hsr_prp_dev_setup(struct net_device *dev)
dev->features |= NETIF_F_NETNS_LOCAL;
}
+static struct device_type hsr_type = {
+ .name = "hsr",
+};
+
+void hsr_dev_setup(struct net_device *dev)
+{
+ hsr_prp_dev_setup(dev, &hsr_type);
+}
+
+static struct device_type prp_type = {
+ .name = "prp",
+};
+
+void prp_dev_setup(struct net_device *dev)
+{
+ hsr_prp_dev_setup(dev, &prp_type);
+}
+
/* Return true if dev is a HSR master; return false otherwise.
*/
inline bool is_hsr_prp_master(struct net_device *dev)
@@ -439,6 +453,10 @@ int hsr_prp_dev_finalize(struct net_device *hsr_prp_dev,
struct hsr_prp_priv *priv;
int res;
+ /* PRP not supported yet */
+ if (protocol_version == PRP_V1)
+ return -EPROTONOSUPPORT;
+
priv = netdev_priv(hsr_prp_dev);
INIT_LIST_HEAD(&priv->ports);
INIT_LIST_HEAD(&priv->node_db);
@@ -464,8 +482,6 @@ int hsr_prp_dev_finalize(struct net_device *hsr_prp_dev,
ether_addr_copy(priv->sup_multicast_addr, def_multicast_addr);
priv->sup_multicast_addr[ETH_ALEN - 1] = multicast_spec;
- priv->prot_version = protocol_version;
-
/* FIXME: should I modify the value of these?
*
* - hsr_ptp_dev->flags - i.e.
diff --git a/net/hsr-prp/hsr_prp_device.h b/net/hsr-prp/hsr_prp_device.h
index 4f734a36b2d6..107f1c498442 100644
--- a/net/hsr-prp/hsr_prp_device.h
+++ b/net/hsr-prp/hsr_prp_device.h
@@ -11,7 +11,8 @@
#include <linux/netdevice.h>
#include "hsr_prp_main.h"
-void hsr_prp_dev_setup(struct net_device *dev);
+void hsr_dev_setup(struct net_device *dev);
+void prp_dev_setup(struct net_device *dev);
int hsr_prp_dev_finalize(struct net_device *dev, struct net_device *slave[2],
unsigned char multicast_spec, u8 protocol_version,
struct netlink_ext_ack *extack);
diff --git a/net/hsr-prp/hsr_prp_framereg.c b/net/hsr-prp/hsr_prp_framereg.c
index d78d32d513ca..42c673befe2c 100644
--- a/net/hsr-prp/hsr_prp_framereg.c
+++ b/net/hsr-prp/hsr_prp_framereg.c
@@ -17,6 +17,7 @@
#include "hsr_prp_main.h"
#include "hsr_prp_framereg.h"
#include "hsr_netlink.h"
+#include "prp_netlink.h"
/* TODO: use hash lists for mac addresses (linux/jhash.h)? */
@@ -443,7 +444,10 @@ void hsr_prp_prune_nodes(struct timer_list *t)
/* Prune old entries */
if (time_is_before_jiffies(timestamp +
msecs_to_jiffies(HSR_PRP_NODE_FORGET_TIME))) {
- hsr_nl_nodedown(priv, node->macaddress_A);
+ if (priv->prot_version <= HSR_V1)
+ hsr_nl_nodedown(priv, node->macaddress_A);
+ else
+ prp_nl_nodedown(priv, node->macaddress_A);
list_del_rcu(&node->mac_list);
/* Note that we need to free this entry later: */
kfree_rcu(node, rcu_head);
diff --git a/net/hsr-prp/hsr_prp_main.c b/net/hsr-prp/hsr_prp_main.c
index 4565744ce1a1..e7e5ca537456 100644
--- a/net/hsr-prp/hsr_prp_main.c
+++ b/net/hsr-prp/hsr_prp_main.c
@@ -12,6 +12,7 @@
#include "hsr_prp_main.h"
#include "hsr_prp_device.h"
#include "hsr_netlink.h"
+#include "prp_netlink.h"
#include "hsr_prp_framereg.h"
#include "hsr_prp_slave.h"
@@ -25,6 +26,17 @@ static bool hsr_prp_slave_empty(struct hsr_prp_priv *priv)
return true;
}
+static int hsr_prp_netdev_notify(struct notifier_block *nb, unsigned long event,
+ void *ptr);
+
+static struct notifier_block hsr_nb = {
+ .notifier_call = hsr_prp_netdev_notify, /* Slave event notifications */
+};
+
+static struct notifier_block prp_nb = {
+ .notifier_call = hsr_prp_netdev_notify, /* Slave event notifications */
+};
+
static int hsr_prp_netdev_notify(struct notifier_block *nb, unsigned long event,
void *ptr)
{
@@ -50,6 +62,11 @@ static int hsr_prp_netdev_notify(struct notifier_block *nb, unsigned long event,
priv = port->priv;
}
+ if (priv->prot_version <= HSR_V1 && nb != &hsr_nb)
+ return NOTIFY_DONE;
+ else if (priv->prot_version == PRP_V1 && nb != &prp_nb)
+ return NOTIFY_DONE;
+
switch (event) {
case NETDEV_UP: /* Administrative state DOWN */
case NETDEV_DOWN: /* Administrative state UP */
@@ -127,18 +144,38 @@ struct hsr_prp_port *hsr_prp_get_port(struct hsr_prp_priv *priv,
return NULL;
}
-static struct notifier_block hsr_nb = {
- .notifier_call = hsr_prp_netdev_notify, /* Slave event notifications */
-};
-
static int __init hsr_prp_init(void)
{
int res;
BUILD_BUG_ON(sizeof(struct hsr_tag) != HSR_PRP_HLEN);
- register_netdevice_notifier(&hsr_nb);
- res = hsr_netlink_init();
+ res = register_netdevice_notifier(&hsr_nb);
+ if (!res)
+ res = hsr_netlink_init();
+ else
+ return res;
+
+ if (res)
+ goto cleanup_hsr_notify;
+
+ res = register_netdevice_notifier(&prp_nb);
+ if (!res)
+ res = prp_netlink_init();
+ else
+ goto cleanup_hsr_link;
+
+ if (res)
+ goto cleanup_prp_notify;
+
+ return res;
+
+cleanup_prp_notify:
+ unregister_netdevice_notifier(&prp_nb);
+cleanup_hsr_link:
+ hsr_nl_cleanup();
+cleanup_hsr_notify:
+ unregister_netdevice_notifier(&hsr_nb);
return res;
}
@@ -146,7 +183,9 @@ static int __init hsr_prp_init(void)
static void __exit hsr_prp_exit(void)
{
unregister_netdevice_notifier(&hsr_nb);
+ unregister_netdevice_notifier(&prp_nb);
hsr_netlink_exit();
+ prp_netlink_exit();
hsr_prp_debugfs_remove_root();
}
diff --git a/net/hsr-prp/hsr_prp_main.h b/net/hsr-prp/hsr_prp_main.h
index 7d9a3e009a2d..00c312e5189f 100644
--- a/net/hsr-prp/hsr_prp_main.h
+++ b/net/hsr-prp/hsr_prp_main.h
@@ -132,6 +132,8 @@ struct hsr_prp_port {
enum hsr_prp_port_type type;
};
+#define HSR 0
+#define PRP 1
struct hsr_prp_priv {
struct rcu_head rcu_head;
struct list_head ports;
@@ -145,6 +147,9 @@ struct hsr_prp_priv {
u8 prot_version; /* Indicate if HSRv0 or HSRv1. */
spinlock_t seqnr_lock; /* locking for sequence_nr */
spinlock_t list_lock; /* locking for node list */
+#define HSR_V0 0
+#define HSR_V1 1
+#define PRP_V1 2
unsigned char sup_multicast_addr[ETH_ALEN];
#ifdef CONFIG_DEBUG_FS
struct dentry *node_tbl_root;
diff --git a/net/hsr-prp/hsr_prp_netlink.c b/net/hsr-prp/hsr_prp_netlink.c
index 04d51cd97496..865df1dbe621 100644
--- a/net/hsr-prp/hsr_prp_netlink.c
+++ b/net/hsr-prp/hsr_prp_netlink.c
@@ -12,12 +12,13 @@
#include "hsr_prp_device.h"
#include "hsr_prp_framereg.h"
-int hsr_prp_newlink(struct net *src_net, struct net_device *dev,
- struct nlattr *tb[], struct nlattr *data[],
+int hsr_prp_newlink(int proto, struct net *src_net,
+ struct net_device *dev, struct nlattr *tb[],
+ struct nlattr *data[],
struct netlink_ext_ack *extack)
{
struct net_device *link[2];
- unsigned char multicast_spec, hsr_version;
+ unsigned char mc_lsb, version = 0;
if (!data) {
NL_SET_ERR_MSG_MOD(extack, "No slave devices specified");
@@ -50,23 +51,22 @@ int hsr_prp_newlink(struct net *src_net, struct net_device *dev,
}
if (!data[IFLA_HSR_PRP_SF_MC_ADDR_LSB])
- multicast_spec = 0;
+ mc_lsb = 0;
else
- multicast_spec = nla_get_u8(data[IFLA_HSR_PRP_SF_MC_ADDR_LSB]);
+ mc_lsb = nla_get_u8(data[IFLA_HSR_PRP_SF_MC_ADDR_LSB]);
- if (!data[IFLA_HSR_PRP_VERSION]) {
- hsr_version = 0;
+ if (proto == PRP) {
+ version = PRP_V1;
} else {
- hsr_version = nla_get_u8(data[IFLA_HSR_PRP_VERSION]);
- if (hsr_version > 1) {
+ version = nla_get_u8(data[IFLA_HSR_PRP_VERSION]);
+ if (version > 1) {
NL_SET_ERR_MSG_MOD(extack,
"Only versions 0..1 are supported");
return -EINVAL;
}
}
- return hsr_prp_dev_finalize(dev, link, multicast_spec, hsr_version,
- extack);
+ return hsr_prp_dev_finalize(dev, link, mc_lsb, version, extack);
}
int hsr_prp_fill_info(struct sk_buff *skb, const struct net_device *dev)
@@ -133,7 +133,7 @@ void hsr_prp_nl_nodedown(struct hsr_prp_priv *priv,
fail:
rcu_read_lock();
master = hsr_prp_get_port(priv, HSR_PRP_PT_MASTER);
- netdev_warn(master->dev, "Could not send HSR node down\n");
+ netdev_warn(master->dev, "Could not send HSR/PRP node down\n");
rcu_read_unlock();
}
@@ -142,7 +142,7 @@ int hsr_prp_get_node_status(struct genl_family *genl_family,
{
/* For receiving */
struct nlattr *na;
- struct net_device *hsr_dev;
+ struct net_device *ndev;
/* For sending */
struct sk_buff *skb_out;
@@ -150,10 +150,10 @@ int hsr_prp_get_node_status(struct genl_family *genl_family,
struct hsr_prp_priv *priv;
struct hsr_prp_port *port;
unsigned char node_addr_b[ETH_ALEN];
- int hsr_node_if1_age;
- u16 hsr_node_if1_seq;
- int hsr_node_if2_age;
- u16 hsr_node_if2_seq;
+ int node_if1_age;
+ u16 node_if1_seq;
+ int node_if2_age;
+ u16 node_if2_seq;
int addr_b_ifindex;
int res;
@@ -168,12 +168,11 @@ int hsr_prp_get_node_status(struct genl_family *genl_family,
goto invalid;
rcu_read_lock();
- hsr_dev =
- dev_get_by_index_rcu(genl_info_net(info),
- nla_get_u32(info->attrs[HSR_PRP_A_IFINDEX]));
- if (!hsr_dev)
+ ndev = __dev_get_by_index(genl_info_net(info),
+ nla_get_u32(info->attrs[HSR_PRP_A_IFINDEX]));
+ if (!ndev)
goto rcu_unlock;
- if (!is_hsr_prp_master(hsr_dev))
+ if (!is_hsr_prp_master(ndev))
goto rcu_unlock;
/* Send reply */
@@ -191,20 +190,20 @@ int hsr_prp_get_node_status(struct genl_family *genl_family,
goto nla_put_failure;
}
- res = nla_put_u32(skb_out, HSR_PRP_A_IFINDEX, hsr_dev->ifindex);
+ res = nla_put_u32(skb_out, HSR_PRP_A_IFINDEX, ndev->ifindex);
if (res < 0)
goto nla_put_failure;
- priv = netdev_priv(hsr_dev);
+ priv = netdev_priv(ndev);
res = hsr_prp_get_node_data(priv,
(unsigned char *)
nla_data(info->attrs[HSR_PRP_A_NODE_ADDR]),
node_addr_b,
&addr_b_ifindex,
- &hsr_node_if1_age,
- &hsr_node_if1_seq,
- &hsr_node_if2_age,
- &hsr_node_if2_seq);
+ &node_if1_age,
+ &node_if1_seq,
+ &node_if2_age,
+ &node_if2_seq);
if (res < 0)
goto nla_put_failure;
@@ -225,10 +224,10 @@ int hsr_prp_get_node_status(struct genl_family *genl_family,
goto nla_put_failure;
}
- res = nla_put_u32(skb_out, HSR_PRP_A_IF1_AGE, hsr_node_if1_age);
+ res = nla_put_u32(skb_out, HSR_PRP_A_IF1_AGE, node_if1_age);
if (res < 0)
goto nla_put_failure;
- res = nla_put_u16(skb_out, HSR_PRP_A_IF1_SEQ, hsr_node_if1_seq);
+ res = nla_put_u16(skb_out, HSR_PRP_A_IF1_SEQ, node_if1_seq);
if (res < 0)
goto nla_put_failure;
port = hsr_prp_get_port(priv, HSR_PRP_PT_SLAVE_A);
@@ -238,10 +237,10 @@ int hsr_prp_get_node_status(struct genl_family *genl_family,
if (res < 0)
goto nla_put_failure;
- res = nla_put_u32(skb_out, HSR_PRP_A_IF2_AGE, hsr_node_if2_age);
+ res = nla_put_u32(skb_out, HSR_PRP_A_IF2_AGE, node_if2_age);
if (res < 0)
goto nla_put_failure;
- res = nla_put_u16(skb_out, HSR_PRP_A_IF2_SEQ, hsr_node_if2_seq);
+ res = nla_put_u16(skb_out, HSR_PRP_A_IF2_SEQ, node_if2_seq);
if (res < 0)
goto nla_put_failure;
port = hsr_prp_get_port(priv, HSR_PRP_PT_SLAVE_B);
@@ -273,14 +272,14 @@ int hsr_prp_get_node_status(struct genl_family *genl_family,
return res;
}
-/* Get a list of MacAddressA of all nodes known to this node (including self).
+/* Get a list of mac_address_a of all nodes known to this node (including self).
*/
int hsr_prp_get_node_list(struct genl_family *genl_family,
struct sk_buff *skb_in, struct genl_info *info)
{
unsigned char addr[ETH_ALEN];
- struct net_device *hsr_dev;
struct hsr_prp_priv *priv;
+ struct net_device *ndev;
struct sk_buff *skb_out;
bool restart = false;
struct nlattr *na;
@@ -296,12 +295,11 @@ int hsr_prp_get_node_list(struct genl_family *genl_family,
goto invalid;
rcu_read_lock();
- hsr_dev =
- dev_get_by_index_rcu(genl_info_net(info),
- nla_get_u32(info->attrs[HSR_PRP_A_IFINDEX]));
- if (!hsr_dev)
+ ndev = __dev_get_by_index(genl_info_net(info),
+ nla_get_u32(info->attrs[HSR_PRP_A_IFINDEX]));
+ if (!ndev)
goto rcu_unlock;
- if (!is_hsr_prp_master(hsr_dev))
+ if (!is_hsr_prp_master(ndev))
goto rcu_unlock;
restart:
@@ -321,12 +319,12 @@ int hsr_prp_get_node_list(struct genl_family *genl_family,
}
if (!restart) {
- res = nla_put_u32(skb_out, HSR_PRP_A_IFINDEX, hsr_dev->ifindex);
+ res = nla_put_u32(skb_out, HSR_PRP_A_IFINDEX, ndev->ifindex);
if (res < 0)
goto nla_put_failure;
}
- priv = netdev_priv(hsr_dev);
+ priv = netdev_priv(ndev);
if (!pos)
pos = hsr_prp_get_next_node(priv, NULL, addr);
diff --git a/net/hsr-prp/hsr_prp_netlink.h b/net/hsr-prp/hsr_prp_netlink.h
index a3a4e6252e45..5bd0f8cf2644 100644
--- a/net/hsr-prp/hsr_prp_netlink.h
+++ b/net/hsr-prp/hsr_prp_netlink.h
@@ -13,8 +13,9 @@
#include "hsr_prp_main.h"
-int hsr_prp_newlink(struct net *src_net, struct net_device *dev,
- struct nlattr *tb[], struct nlattr *data[],
+int hsr_prp_newlink(int proto, struct net *src_net,
+ struct net_device *dev, struct nlattr *tb[],
+ struct nlattr *data[],
struct netlink_ext_ack *extack);
int hsr_prp_fill_info(struct sk_buff *skb, const struct net_device *dev);
void hsr_prp_nl_nodedown(struct hsr_prp_priv *priv,
diff --git a/net/hsr-prp/prp_netlink.c b/net/hsr-prp/prp_netlink.c
new file mode 100644
index 000000000000..d6c0a64e0a84
--- /dev/null
+++ b/net/hsr-prp/prp_netlink.c
@@ -0,0 +1,141 @@
+// SPDX-License-Identifier: GPL-2.0
+/* This is based on hsr_netlink.c from Arvid Brodin, [email protected]
+ *
+ * Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com
+ *
+ * Author(s):
+ * Murali Karicheri <[email protected]>
+ * Routines for handling Netlink messages for PRP
+ */
+
+#include <linux/kernel.h>
+#include <net/genetlink.h>
+#include <net/rtnetlink.h>
+
+#include "prp_netlink.h"
+#include "hsr_prp_netlink.h"
+#include "hsr_prp_main.h"
+#include "hsr_prp_device.h"
+#include "hsr_prp_framereg.h"
+
+static const struct nla_policy prp_policy[IFLA_HSR_PRP_MAX + 1] = {
+ [IFLA_HSR_PRP_SLAVE1] = { .type = NLA_U32 },
+ [IFLA_HSR_PRP_SLAVE2] = { .type = NLA_U32 },
+ [IFLA_HSR_PRP_SF_MC_ADDR_LSB] = { .type = NLA_U8 },
+ [IFLA_HSR_PRP_SF_MC_ADDR] = { .len = ETH_ALEN },
+ [IFLA_HSR_PRP_SEQ_NR] = { .type = NLA_U16 },
+};
+
+/* Here, it seems a netdevice has already been allocated for us, and the
+ * hsr_prp_dev_setup routine has been executed. Nice!
+ */
+static int prp_newlink(struct net *src_net, struct net_device *dev,
+ struct nlattr *tb[], struct nlattr *data[],
+ struct netlink_ext_ack *extack)
+{
+ return hsr_prp_newlink(PRP, src_net, dev, tb, data, extack);
+}
+
+static struct rtnl_link_ops prp_link_ops __read_mostly = {
+ .kind = "prp",
+ .maxtype = IFLA_HSR_PRP_MAX,
+ .policy = prp_policy,
+ .priv_size = sizeof(struct hsr_prp_priv),
+ .setup = prp_dev_setup,
+ .newlink = prp_newlink,
+ .fill_info = hsr_prp_fill_info,
+};
+
+/* NLA_BINARY missing in libnl; use NLA_UNSPEC in userspace instead. */
+static const struct nla_policy prp_genl_policy[HSR_PRP_A_MAX + 1] = {
+ [HSR_PRP_A_NODE_ADDR] = { .type = NLA_BINARY, .len = ETH_ALEN },
+ [HSR_PRP_A_NODE_ADDR_B] = { .type = NLA_BINARY, .len = ETH_ALEN },
+ [HSR_PRP_A_IFINDEX] = { .type = NLA_U32 },
+ [HSR_PRP_A_IF1_AGE] = { .type = NLA_U32 },
+ [HSR_PRP_A_IF2_AGE] = { .type = NLA_U32 },
+ [HSR_PRP_A_IF1_SEQ] = { .type = NLA_U16 },
+ [HSR_PRP_A_IF2_SEQ] = { .type = NLA_U16 },
+};
+
+static struct genl_family prp_genl_family;
+
+static const struct genl_multicast_group prp_mcgrps[] = {
+ { .name = "prp-network", },
+};
+
+/* 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).
+ */
+void prp_nl_nodedown(struct hsr_prp_priv *priv, unsigned char addr[ETH_ALEN])
+{
+ hsr_prp_nl_nodedown(priv, &prp_genl_family, addr);
+}
+
+static int prp_get_node_status(struct sk_buff *skb_in, struct genl_info *info)
+{
+ return hsr_prp_get_node_status(&prp_genl_family, skb_in, info);
+}
+
+static int prp_get_node_list(struct sk_buff *skb_in, struct genl_info *info)
+{
+ return hsr_prp_get_node_list(&prp_genl_family, skb_in, info);
+}
+
+static const struct genl_ops prp_ops[] = {
+ {
+ .cmd = HSR_PRP_C_GET_NODE_STATUS,
+ .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
+ .flags = 0,
+ .doit = prp_get_node_status,
+ .dumpit = NULL,
+ },
+ {
+ .cmd = HSR_PRP_C_GET_NODE_LIST,
+ .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
+ .flags = 0,
+ .doit = prp_get_node_list,
+ .dumpit = NULL,
+ },
+};
+
+static struct genl_family prp_genl_family __ro_after_init = {
+ .hdrsize = 0,
+ .name = "PRP",
+ .version = 1,
+ .maxattr = HSR_PRP_A_MAX,
+ .policy = prp_genl_policy,
+ .module = THIS_MODULE,
+ .ops = prp_ops,
+ .n_ops = ARRAY_SIZE(prp_ops),
+ .mcgrps = prp_mcgrps,
+ .n_mcgrps = ARRAY_SIZE(prp_mcgrps),
+};
+
+int __init prp_netlink_init(void)
+{
+ int rc;
+
+ rc = rtnl_link_register(&prp_link_ops);
+ if (rc)
+ goto fail_rtnl_link_register;
+
+ rc = genl_register_family(&prp_genl_family);
+ if (rc)
+ goto fail_genl_register_family;
+
+ return 0;
+
+fail_genl_register_family:
+ rtnl_link_unregister(&prp_link_ops);
+fail_rtnl_link_register:
+
+ return rc;
+}
+
+void __exit prp_netlink_exit(void)
+{
+ genl_unregister_family(&prp_genl_family);
+ rtnl_link_unregister(&prp_link_ops);
+}
+
+MODULE_ALIAS_RTNL_LINK("prp");
diff --git a/net/hsr-prp/prp_netlink.h b/net/hsr-prp/prp_netlink.h
new file mode 100644
index 000000000000..ad43b33b5bfb
--- /dev/null
+++ b/net/hsr-prp/prp_netlink.h
@@ -0,0 +1,27 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* prp_netlink.h:
+ * This is based on hsr_netlink.h from Arvid Brodin, [email protected]
+ *
+ * Copyright (C) 2017-2020 Texas Instruments Incorporated - http://www.ti.com
+ *
+ * Author(s):
+ * Murali Karicheri <[email protected]>
+ */
+
+#ifndef __PRP_NETLINK_H
+#define __PRP_NETLINK_H
+
+#include <linux/if_ether.h>
+#include <linux/module.h>
+
+#include <uapi/linux/hsr_prp_netlink.h>
+
+struct hsr_prp_priv;
+struct hsr_prp_port;
+
+int __init prp_netlink_init(void);
+void __exit prp_netlink_exit(void);
+
+void prp_nl_nodedown(struct hsr_prp_priv *priv, unsigned char addr[ETH_ALEN]);
+
+#endif /* __PRP_NETLINK_H */
--
2.17.1
There are many commonalities between HSR and PRP protocols except for
the fact that HSR uses Tag as a prefix vs RCT (Redundancy Control Trail)
as a trailer for PRP. Few of the commonalities to name are:- both uses
a pair of Ethernet interfaces, can be set up the same way from user
space using ip link command, Same Multicast MAC address for Supervision
frames, similar mechanism for redundancy, duplicate and discard using
tag/rct etc. So this patch introduces a common user space API in
if_link.h with a HSR_PRP prefix and common hsr_prp_netlink.h for
protocol specific interface configuration. It is assumed that the old
definitions and include file for HSR may be obsoleted at some time
future (TBD) once all applications migrate to the new API.
IFLA_HSR_PRP_SUPERVISION_ADDR is the MC address for Supervision Frames
(SF), so use the name IFLA_HSR_PRP_SF_MC_ADDR instead to make it shorter
and also change IFLA_HSR_PRP_MULTICAST_SPEC to
IFLA_HSR_PRP_SF_MC_ADDR_LSB as it is the last byte of the MC address
used by Supervision frames.
Signed-off-by: Murali Karicheri <[email protected]>
---
include/uapi/linux/hsr_netlink.h | 3 ++
include/uapi/linux/hsr_prp_netlink.h | 50 ++++++++++++++++++++++++++++
include/uapi/linux/if_link.h | 19 +++++++++++
3 files changed, 72 insertions(+)
create mode 100644 include/uapi/linux/hsr_prp_netlink.h
diff --git a/include/uapi/linux/hsr_netlink.h b/include/uapi/linux/hsr_netlink.h
index c218ef9c35dd..54650ffca2be 100644
--- a/include/uapi/linux/hsr_netlink.h
+++ b/include/uapi/linux/hsr_netlink.h
@@ -14,6 +14,9 @@
#ifndef __UAPI_HSR_NETLINK_H
#define __UAPI_HSR_NETLINK_H
+/* This file will become obsolete soon!!! Start using hsr_prp_netlink.h
+ * instead
+ */
/* Generic Netlink HSR family definition
*/
diff --git a/include/uapi/linux/hsr_prp_netlink.h b/include/uapi/linux/hsr_prp_netlink.h
new file mode 100644
index 000000000000..17865cf14432
--- /dev/null
+++ b/include/uapi/linux/hsr_prp_netlink.h
@@ -0,0 +1,50 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* prp_prp_netlink.h: This is based on hsr_netlink.h from Arvid Brodin,
+ * [email protected]
+ *
+ * Copyright 2011-2014 Autronica Fire and Security AS
+ * Copyright (C) 2020 Texas Instruments Incorporated
+ *
+ * Author(s):
+ * 2011-2014 Arvid Brodin, [email protected]
+ * 2020 Murali Karicheri <[email protected]>
+ */
+
+#ifndef __UAPI_HSR_PRP_NETLINK_H
+#define __UAPI_HSR_PRP_NETLINK_H
+
+/* Generic Netlink HSR/PRP family definition
+ */
+
+/* attributes */
+enum {
+ HSR_PRP_A_UNSPEC,
+ HSR_PRP_A_NODE_ADDR,
+ HSR_PRP_A_IFINDEX,
+ HSR_PRP_A_IF1_AGE,
+ HSR_PRP_A_IF2_AGE,
+ HSR_PRP_A_NODE_ADDR_B,
+ HSR_PRP_A_IF1_SEQ,
+ HSR_PRP_A_IF2_SEQ,
+ HSR_PRP_A_IF1_IFINDEX,
+ HSR_PRP_A_IF2_IFINDEX,
+ HSR_PRP_A_ADDR_B_IFINDEX,
+ __HSR_PRP_A_MAX,
+};
+#define HSR_PRP_A_MAX (__HSR_PRP_A_MAX - 1)
+
+
+/* commands */
+enum {
+ HSR_PRP_C_UNSPEC,
+ HSR_PRP_C_RING_ERROR, /* only for HSR for now */
+ HSR_PRP_C_NODE_DOWN,
+ HSR_PRP_C_GET_NODE_STATUS,
+ HSR_PRP_C_SET_NODE_STATUS,
+ HSR_PRP_C_GET_NODE_LIST,
+ HSR_PRP_C_SET_NODE_LIST,
+ __HSR_PRP_C_MAX,
+};
+#define HSR_PRP_C_MAX (__HSR_PRP_C_MAX - 1)
+
+#endif /* __UAPI_HSR_PRP_NETLINK_H */
diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h
index a009365ad67b..520537f35dcb 100644
--- a/include/uapi/linux/if_link.h
+++ b/include/uapi/linux/if_link.h
@@ -906,6 +906,8 @@ enum {
#define IFLA_IPOIB_MAX (__IFLA_IPOIB_MAX - 1)
+/* Will become obsolete soon!!! Replaced with IFLA_HSR_PRP* prefix below */
+
/* HSR section */
enum {
@@ -1055,4 +1057,21 @@ struct ifla_rmnet_flags {
__u32 mask;
};
+/* New definitions below to replace the HSR_ prefixed ones for HSR and PRP.
+ * It is expected to migrate all applications to this and obsolete the
+ * HSR specific definitions used currently.
+ */
+enum {
+ IFLA_HSR_PRP_UNSPEC,
+ IFLA_HSR_PRP_SLAVE1,
+ IFLA_HSR_PRP_SLAVE2,
+ IFLA_HSR_PRP_SF_MC_ADDR_LSB, /* Last byte of supervision addr */
+ IFLA_HSR_PRP_SF_MC_ADDR, /* Supervision frame multicast addr */
+ IFLA_HSR_PRP_SEQ_NR,
+ IFLA_HSR_PRP_VERSION, /* HSR version */
+ __IFLA_HSR_PRP_MAX,
+};
+
+#define IFLA_HSR_PRP_MAX (__IFLA_HSR_PRP_MAX - 1)
+
#endif /* _UAPI_LINUX_IF_LINK_H */
--
2.17.1
The struct hsr_port has a variable pointing to the private struct
of the driver. This should have been named priv instead of hsr
to be clean. This would be needed as it is planned to re-use the
code for prp and then priv variable is more appropriate than hsr.
So fix it by search and replace of all instances within the driver.
Signed-off-by: Murali Karicheri <[email protected]>
---
net/hsr-prp/hsr_netlink.c | 36 ++++-----
net/hsr-prp/hsr_prp_device.c | 144 ++++++++++++++++-----------------
net/hsr-prp/hsr_prp_device.h | 4 +-
net/hsr-prp/hsr_prp_forward.c | 24 +++---
net/hsr-prp/hsr_prp_framereg.c | 91 ++++++++++-----------
net/hsr-prp/hsr_prp_framereg.h | 10 +--
net/hsr-prp/hsr_prp_main.c | 32 ++++----
net/hsr-prp/hsr_prp_main.h | 8 +-
net/hsr-prp/hsr_prp_slave.c | 28 +++----
net/hsr-prp/hsr_prp_slave.h | 2 +-
10 files changed, 190 insertions(+), 189 deletions(-)
diff --git a/net/hsr-prp/hsr_netlink.c b/net/hsr-prp/hsr_netlink.c
index 9791d4d89aef..9e3f6eda69f5 100644
--- a/net/hsr-prp/hsr_netlink.c
+++ b/net/hsr-prp/hsr_netlink.c
@@ -85,24 +85,24 @@ 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)
{
- struct hsr_priv *hsr = netdev_priv(dev);
+ struct hsr_priv *priv = netdev_priv(dev);
struct hsr_port *port;
- port = hsr_port_get_hsr(hsr, HSR_PT_SLAVE_A);
+ port = hsr_port_get_hsr(priv, HSR_PT_SLAVE_A);
if (port) {
if (nla_put_u32(skb, IFLA_HSR_SLAVE1, port->dev->ifindex))
goto nla_put_failure;
}
- port = hsr_port_get_hsr(hsr, HSR_PT_SLAVE_B);
+ port = hsr_port_get_hsr(priv, HSR_PT_SLAVE_B);
if (port) {
if (nla_put_u32(skb, IFLA_HSR_SLAVE2, port->dev->ifindex))
goto nla_put_failure;
}
if (nla_put(skb, IFLA_HSR_SUPERVISION_ADDR, ETH_ALEN,
- hsr->sup_multicast_addr) ||
- nla_put_u16(skb, IFLA_HSR_SEQ_NR, hsr->sequence_nr))
+ priv->sup_multicast_addr) ||
+ nla_put_u16(skb, IFLA_HSR_SEQ_NR, priv->sequence_nr))
goto nla_put_failure;
return 0;
@@ -142,7 +142,7 @@ static const struct genl_multicast_group hsr_mcgrps[] = {
* over one of the slave interfaces. This would indicate an open network ring
* (i.e. a link has failed somewhere).
*/
-void hsr_nl_ringerror(struct hsr_priv *hsr, unsigned char addr[ETH_ALEN],
+void hsr_nl_ringerror(struct hsr_priv *priv, unsigned char addr[ETH_ALEN],
struct hsr_port *port)
{
struct sk_buff *skb;
@@ -177,7 +177,7 @@ void hsr_nl_ringerror(struct hsr_priv *hsr, unsigned char addr[ETH_ALEN],
fail:
rcu_read_lock();
- master = hsr_port_get_hsr(hsr, HSR_PT_MASTER);
+ master = hsr_port_get_hsr(priv, HSR_PT_MASTER);
netdev_warn(master->dev, "Could not send HSR ring error message\n");
rcu_read_unlock();
}
@@ -185,7 +185,7 @@ void hsr_nl_ringerror(struct hsr_priv *hsr, unsigned char addr[ETH_ALEN],
/* 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).
*/
-void hsr_nl_nodedown(struct hsr_priv *hsr, unsigned char addr[ETH_ALEN])
+void hsr_nl_nodedown(struct hsr_priv *priv, unsigned char addr[ETH_ALEN])
{
struct sk_buff *skb;
void *msg_head;
@@ -214,7 +214,7 @@ void hsr_nl_nodedown(struct hsr_priv *hsr, unsigned char addr[ETH_ALEN])
fail:
rcu_read_lock();
- master = hsr_port_get_hsr(hsr, HSR_PT_MASTER);
+ master = hsr_port_get_hsr(priv, HSR_PT_MASTER);
netdev_warn(master->dev, "Could not send HSR node down\n");
rcu_read_unlock();
}
@@ -236,7 +236,7 @@ static int hsr_get_node_status(struct sk_buff *skb_in, struct genl_info *info)
/* For sending */
struct sk_buff *skb_out;
void *msg_head;
- struct hsr_priv *hsr;
+ struct hsr_priv *priv;
struct hsr_port *port;
unsigned char hsr_node_addr_b[ETH_ALEN];
int hsr_node_if1_age;
@@ -283,8 +283,8 @@ static int hsr_get_node_status(struct sk_buff *skb_in, struct genl_info *info)
if (res < 0)
goto nla_put_failure;
- hsr = netdev_priv(hsr_dev);
- res = hsr_get_node_data(hsr,
+ priv = netdev_priv(hsr_dev);
+ res = hsr_get_node_data(priv,
(unsigned char *)
nla_data(info->attrs[HSR_A_NODE_ADDR]),
hsr_node_addr_b,
@@ -319,7 +319,7 @@ 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);
if (res < 0)
goto nla_put_failure;
- port = hsr_port_get_hsr(hsr, HSR_PT_SLAVE_A);
+ port = hsr_port_get_hsr(priv, HSR_PT_SLAVE_A);
if (port)
res = nla_put_u32(skb_out, HSR_A_IF1_IFINDEX,
port->dev->ifindex);
@@ -332,7 +332,7 @@ 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);
if (res < 0)
goto nla_put_failure;
- port = hsr_port_get_hsr(hsr, HSR_PT_SLAVE_B);
+ port = hsr_port_get_hsr(priv, HSR_PT_SLAVE_B);
if (port)
res = nla_put_u32(skb_out, HSR_A_IF2_IFINDEX,
port->dev->ifindex);
@@ -368,7 +368,7 @@ static int hsr_get_node_list(struct sk_buff *skb_in, struct genl_info *info)
unsigned char addr[ETH_ALEN];
struct net_device *hsr_dev;
struct sk_buff *skb_out;
- struct hsr_priv *hsr;
+ struct hsr_priv *priv;
bool restart = false;
struct nlattr *na;
void *pos = NULL;
@@ -412,10 +412,10 @@ static int hsr_get_node_list(struct sk_buff *skb_in, struct genl_info *info)
goto nla_put_failure;
}
- hsr = netdev_priv(hsr_dev);
+ priv = netdev_priv(hsr_dev);
if (!pos)
- pos = hsr_get_next_node(hsr, NULL, addr);
+ pos = hsr_get_next_node(priv, NULL, addr);
while (pos) {
res = nla_put(skb_out, HSR_A_NODE_ADDR, ETH_ALEN, addr);
if (res < 0) {
@@ -428,7 +428,7 @@ static int hsr_get_node_list(struct sk_buff *skb_in, struct genl_info *info)
}
goto nla_put_failure;
}
- pos = hsr_get_next_node(hsr, pos, addr);
+ pos = hsr_get_next_node(priv, pos, addr);
}
rcu_read_unlock();
diff --git a/net/hsr-prp/hsr_prp_device.c b/net/hsr-prp/hsr_prp_device.c
index ed50022849cb..df85b8f7f007 100644
--- a/net/hsr-prp/hsr_prp_device.c
+++ b/net/hsr-prp/hsr_prp_device.c
@@ -60,7 +60,7 @@ static bool hsr_check_carrier(struct hsr_port *master)
ASSERT_RTNL();
- hsr_for_each_port(master->hsr, port) {
+ hsr_for_each_port(master->priv, port) {
if (port->type != HSR_PT_MASTER && is_slave_up(port->dev)) {
netif_carrier_on(master->dev);
return true;
@@ -75,29 +75,29 @@ static bool hsr_check_carrier(struct hsr_port *master)
static void hsr_check_announce(struct net_device *hsr_dev,
unsigned char old_operstate)
{
- struct hsr_priv *hsr;
+ struct hsr_priv *priv;
- hsr = netdev_priv(hsr_dev);
+ priv = netdev_priv(hsr_dev);
if (hsr_dev->operstate == IF_OPER_UP && old_operstate != IF_OPER_UP) {
/* Went up */
- hsr->announce_count = 0;
- mod_timer(&hsr->announce_timer,
+ priv->announce_count = 0;
+ mod_timer(&priv->announce_timer,
jiffies + msecs_to_jiffies(HSR_ANNOUNCE_INTERVAL));
}
if (hsr_dev->operstate != IF_OPER_UP && old_operstate == IF_OPER_UP)
/* Went down */
- del_timer(&hsr->announce_timer);
+ del_timer(&priv->announce_timer);
}
-void hsr_check_carrier_and_operstate(struct hsr_priv *hsr)
+void hsr_check_carrier_and_operstate(struct hsr_priv *priv)
{
struct hsr_port *master;
unsigned char old_operstate;
bool has_carrier;
- master = hsr_port_get_hsr(hsr, HSR_PT_MASTER);
+ master = hsr_port_get_hsr(priv, HSR_PT_MASTER);
/* netif_stacked_transfer_operstate() cannot be used here since
* it doesn't set IF_OPER_LOWERLAYERDOWN (?)
*/
@@ -107,13 +107,13 @@ void hsr_check_carrier_and_operstate(struct hsr_priv *hsr)
hsr_check_announce(master->dev, old_operstate);
}
-int hsr_get_max_mtu(struct hsr_priv *hsr)
+int hsr_get_max_mtu(struct hsr_priv *priv)
{
unsigned int mtu_max;
struct hsr_port *port;
mtu_max = ETH_DATA_LEN;
- hsr_for_each_port(hsr, port)
+ hsr_for_each_port(priv, port)
if (port->type != HSR_PT_MASTER)
mtu_max = min(port->dev->mtu, mtu_max);
@@ -124,11 +124,11 @@ int hsr_get_max_mtu(struct hsr_priv *hsr)
static int hsr_dev_change_mtu(struct net_device *dev, int new_mtu)
{
- struct hsr_priv *hsr;
+ struct hsr_priv *priv;
- hsr = netdev_priv(dev);
+ priv = netdev_priv(dev);
- if (new_mtu > hsr_get_max_mtu(hsr)) {
+ if (new_mtu > hsr_get_max_mtu(priv)) {
netdev_info(dev, "A HSR master's MTU cannot be greater than the smallest MTU of its slaves minus the HSR Tag length (%d octets).\n",
HSR_HLEN);
return -EINVAL;
@@ -141,14 +141,14 @@ static int hsr_dev_change_mtu(struct net_device *dev, int new_mtu)
static int hsr_dev_open(struct net_device *dev)
{
- struct hsr_priv *hsr;
+ struct hsr_priv *priv;
struct hsr_port *port;
char designation;
- hsr = netdev_priv(dev);
+ priv = netdev_priv(dev);
designation = '\0';
- hsr_for_each_port(hsr, port) {
+ hsr_for_each_port(priv, port) {
if (port->type == HSR_PT_MASTER)
continue;
switch (port->type) {
@@ -178,7 +178,7 @@ static int hsr_dev_close(struct net_device *dev)
return 0;
}
-static netdev_features_t hsr_features_recompute(struct hsr_priv *hsr,
+static netdev_features_t hsr_features_recompute(struct hsr_priv *priv,
netdev_features_t features)
{
netdev_features_t mask;
@@ -194,7 +194,7 @@ static netdev_features_t hsr_features_recompute(struct hsr_priv *hsr,
* may become enabled.
*/
features &= ~NETIF_F_ONE_FOR_ALL;
- hsr_for_each_port(hsr, port)
+ hsr_for_each_port(priv, port)
features = netdev_increment_features(features,
port->dev->features,
mask);
@@ -205,17 +205,17 @@ static netdev_features_t hsr_features_recompute(struct hsr_priv *hsr,
static netdev_features_t hsr_fix_features(struct net_device *dev,
netdev_features_t features)
{
- struct hsr_priv *hsr = netdev_priv(dev);
+ struct hsr_priv *priv = netdev_priv(dev);
- return hsr_features_recompute(hsr, features);
+ return hsr_features_recompute(priv, features);
}
static int hsr_dev_xmit(struct sk_buff *skb, struct net_device *dev)
{
- struct hsr_priv *hsr = netdev_priv(dev);
+ struct hsr_priv *priv = netdev_priv(dev);
struct hsr_port *master;
- master = hsr_port_get_hsr(hsr, HSR_PT_MASTER);
+ master = hsr_port_get_hsr(priv, HSR_PT_MASTER);
if (master) {
skb->dev = master->dev;
hsr_forward_skb(skb, master);
@@ -257,7 +257,7 @@ static void send_hsr_supervision_frame(struct hsr_port *master,
skb->priority = TC_PRIO_CONTROL;
if (dev_hard_header(skb, skb->dev, (hsr_ver ? ETH_P_HSR : ETH_P_PRP),
- master->hsr->sup_multicast_addr,
+ master->priv->sup_multicast_addr,
skb->dev->dev_addr, skb->len) <= 0)
goto out;
skb_reset_mac_header(skb);
@@ -275,17 +275,17 @@ static void send_hsr_supervision_frame(struct hsr_port *master,
set_hsr_stag_HSR_ver(hsr_stag, hsr_ver);
/* From HSRv1 on we have separate supervision sequence numbers. */
- spin_lock_irqsave(&master->hsr->seqnr_lock, irqflags);
+ spin_lock_irqsave(&master->priv->seqnr_lock, irqflags);
if (hsr_ver > 0) {
- hsr_stag->sequence_nr = htons(master->hsr->sup_sequence_nr);
- hsr_tag->sequence_nr = htons(master->hsr->sequence_nr);
- master->hsr->sup_sequence_nr++;
- master->hsr->sequence_nr++;
+ hsr_stag->sequence_nr = htons(master->priv->sup_sequence_nr);
+ hsr_tag->sequence_nr = htons(master->priv->sequence_nr);
+ master->priv->sup_sequence_nr++;
+ master->priv->sequence_nr++;
} else {
- hsr_stag->sequence_nr = htons(master->hsr->sequence_nr);
- master->hsr->sequence_nr++;
+ hsr_stag->sequence_nr = htons(master->priv->sequence_nr);
+ master->priv->sequence_nr++;
}
- spin_unlock_irqrestore(&master->hsr->seqnr_lock, irqflags);
+ spin_unlock_irqrestore(&master->priv->seqnr_lock, irqflags);
hsr_stag->HSR_TLV_type = type;
/* TODO: Why 12 in HSRv0? */
@@ -311,47 +311,47 @@ static void send_hsr_supervision_frame(struct hsr_port *master,
*/
static void hsr_announce(struct timer_list *t)
{
- struct hsr_priv *hsr;
+ struct hsr_priv *priv;
struct hsr_port *master;
unsigned long interval;
- hsr = from_timer(hsr, t, announce_timer);
+ priv = from_timer(priv, t, announce_timer);
rcu_read_lock();
- master = hsr_port_get_hsr(hsr, HSR_PT_MASTER);
+ master = hsr_port_get_hsr(priv, HSR_PT_MASTER);
- if (hsr->announce_count < 3 && hsr->prot_version == 0) {
+ if (priv->announce_count < 3 && priv->prot_version == 0) {
send_hsr_supervision_frame(master, HSR_TLV_ANNOUNCE,
- hsr->prot_version);
- hsr->announce_count++;
+ priv->prot_version);
+ priv->announce_count++;
interval = msecs_to_jiffies(HSR_ANNOUNCE_INTERVAL);
} else {
send_hsr_supervision_frame(master, HSR_TLV_LIFE_CHECK,
- hsr->prot_version);
+ priv->prot_version);
interval = msecs_to_jiffies(HSR_LIFE_CHECK_INTERVAL);
}
if (is_admin_up(master->dev))
- mod_timer(&hsr->announce_timer, jiffies + interval);
+ mod_timer(&priv->announce_timer, jiffies + interval);
rcu_read_unlock();
}
-static void hsr_del_ports(struct hsr_priv *hsr)
+static void hsr_del_ports(struct hsr_priv *priv)
{
struct hsr_port *port;
- port = hsr_port_get_hsr(hsr, HSR_PT_SLAVE_A);
+ port = hsr_port_get_hsr(priv, HSR_PT_SLAVE_A);
if (port)
hsr_del_port(port);
- port = hsr_port_get_hsr(hsr, HSR_PT_SLAVE_B);
+ port = hsr_port_get_hsr(priv, HSR_PT_SLAVE_B);
if (port)
hsr_del_port(port);
- port = hsr_port_get_hsr(hsr, HSR_PT_MASTER);
+ port = hsr_port_get_hsr(priv, HSR_PT_MASTER);
if (port)
hsr_del_port(port);
}
@@ -362,16 +362,16 @@ static void hsr_del_ports(struct hsr_priv *hsr)
*/
static void hsr_dev_destroy(struct net_device *hsr_dev)
{
- struct hsr_priv *hsr = netdev_priv(hsr_dev);
+ struct hsr_priv *priv = netdev_priv(hsr_dev);
- hsr_debugfs_term(hsr);
- hsr_del_ports(hsr);
+ hsr_debugfs_term(priv);
+ hsr_del_ports(priv);
- del_timer_sync(&hsr->prune_timer);
- del_timer_sync(&hsr->announce_timer);
+ del_timer_sync(&priv->prune_timer);
+ del_timer_sync(&priv->announce_timer);
- hsr_del_self_node(hsr);
- hsr_del_nodes(&hsr->node_db);
+ hsr_del_self_node(priv);
+ hsr_del_nodes(&priv->node_db);
}
static const struct net_device_ops hsr_device_ops = {
@@ -434,35 +434,35 @@ int hsr_dev_finalize(struct net_device *hsr_dev, struct net_device *slave[2],
unsigned char multicast_spec, u8 protocol_version,
struct netlink_ext_ack *extack)
{
- struct hsr_priv *hsr;
+ struct hsr_priv *priv;
int res;
- hsr = netdev_priv(hsr_dev);
- INIT_LIST_HEAD(&hsr->ports);
- INIT_LIST_HEAD(&hsr->node_db);
- INIT_LIST_HEAD(&hsr->self_node_db);
- spin_lock_init(&hsr->list_lock);
+ priv = netdev_priv(hsr_dev);
+ INIT_LIST_HEAD(&priv->ports);
+ INIT_LIST_HEAD(&priv->node_db);
+ INIT_LIST_HEAD(&priv->self_node_db);
+ spin_lock_init(&priv->list_lock);
ether_addr_copy(hsr_dev->dev_addr, slave[0]->dev_addr);
/* Make sure we recognize frames from ourselves in hsr_rcv() */
- res = hsr_create_self_node(hsr, hsr_dev->dev_addr,
+ res = hsr_create_self_node(priv, hsr_dev->dev_addr,
slave[1]->dev_addr);
if (res < 0)
return res;
- spin_lock_init(&hsr->seqnr_lock);
+ spin_lock_init(&priv->seqnr_lock);
/* Overflow soon to find bugs easier: */
- hsr->sequence_nr = HSR_SEQNR_START;
- hsr->sup_sequence_nr = HSR_SUP_SEQNR_START;
+ priv->sequence_nr = HSR_SEQNR_START;
+ priv->sup_sequence_nr = HSR_SUP_SEQNR_START;
- timer_setup(&hsr->announce_timer, hsr_announce, 0);
- timer_setup(&hsr->prune_timer, hsr_prune_nodes, 0);
+ timer_setup(&priv->announce_timer, hsr_announce, 0);
+ timer_setup(&priv->prune_timer, hsr_prune_nodes, 0);
- ether_addr_copy(hsr->sup_multicast_addr, def_multicast_addr);
- hsr->sup_multicast_addr[ETH_ALEN - 1] = multicast_spec;
+ ether_addr_copy(priv->sup_multicast_addr, def_multicast_addr);
+ priv->sup_multicast_addr[ETH_ALEN - 1] = multicast_spec;
- hsr->prot_version = protocol_version;
+ priv->prot_version = protocol_version;
/* FIXME: should I modify the value of these?
*
@@ -477,7 +477,7 @@ int hsr_dev_finalize(struct net_device *hsr_dev, struct net_device *slave[2],
/* Make sure the 1st call to netif_carrier_on() gets through */
netif_carrier_off(hsr_dev);
- res = hsr_add_port(hsr, hsr_dev, HSR_PT_MASTER, extack);
+ res = hsr_add_port(priv, hsr_dev, HSR_PT_MASTER, extack);
if (res)
goto err_add_master;
@@ -485,25 +485,25 @@ int hsr_dev_finalize(struct net_device *hsr_dev, struct net_device *slave[2],
if (res)
goto err_unregister;
- res = hsr_add_port(hsr, slave[0], HSR_PT_SLAVE_A, extack);
+ res = hsr_add_port(priv, slave[0], HSR_PT_SLAVE_A, extack);
if (res)
goto err_add_slaves;
- res = hsr_add_port(hsr, slave[1], HSR_PT_SLAVE_B, extack);
+ res = hsr_add_port(priv, slave[1], HSR_PT_SLAVE_B, extack);
if (res)
goto err_add_slaves;
- hsr_debugfs_init(hsr, hsr_dev);
- mod_timer(&hsr->prune_timer, jiffies + msecs_to_jiffies(PRUNE_PERIOD));
+ hsr_debugfs_init(priv, hsr_dev);
+ mod_timer(&priv->prune_timer, jiffies + msecs_to_jiffies(PRUNE_PERIOD));
return 0;
err_add_slaves:
unregister_netdevice(hsr_dev);
err_unregister:
- hsr_del_ports(hsr);
+ hsr_del_ports(priv);
err_add_master:
- hsr_del_self_node(hsr);
+ hsr_del_self_node(priv);
return res;
}
diff --git a/net/hsr-prp/hsr_prp_device.h b/net/hsr-prp/hsr_prp_device.h
index 4cf3db603174..91642845cdd2 100644
--- a/net/hsr-prp/hsr_prp_device.h
+++ b/net/hsr-prp/hsr_prp_device.h
@@ -15,8 +15,8 @@ void hsr_dev_setup(struct net_device *dev);
int hsr_dev_finalize(struct net_device *hsr_dev, struct net_device *slave[2],
unsigned char multicast_spec, u8 protocol_version,
struct netlink_ext_ack *extack);
-void hsr_check_carrier_and_operstate(struct hsr_priv *hsr);
+void hsr_check_carrier_and_operstate(struct hsr_priv *priv);
bool is_hsr_master(struct net_device *dev);
-int hsr_get_max_mtu(struct hsr_priv *hsr);
+int hsr_get_max_mtu(struct hsr_priv *priv);
#endif /* __HSR_DEVICE_H */
diff --git a/net/hsr-prp/hsr_prp_forward.c b/net/hsr-prp/hsr_prp_forward.c
index 5ff0efba5db5..2b6abb09fe4b 100644
--- a/net/hsr-prp/hsr_prp_forward.c
+++ b/net/hsr-prp/hsr_prp_forward.c
@@ -42,7 +42,7 @@ struct hsr_frame_info {
* 3) Allow different MAC addresses for the two slave interfaces, using the
* MacAddressA field.
*/
-static bool is_supervision_frame(struct hsr_priv *hsr, struct sk_buff *skb)
+static bool is_supervision_frame(struct hsr_priv *priv, struct sk_buff *skb)
{
struct ethhdr *eth_hdr;
struct hsr_sup_tag *hsr_sup_tag;
@@ -53,7 +53,7 @@ static bool is_supervision_frame(struct hsr_priv *hsr, struct sk_buff *skb)
/* Correct addr? */
if (!ether_addr_equal(eth_hdr->h_dest,
- hsr->sup_multicast_addr))
+ priv->sup_multicast_addr))
return false;
/* Correct ether type?. */
@@ -172,7 +172,7 @@ static struct sk_buff *create_tagged_skb(struct sk_buff *skb_o,
memmove(dst, src, movelen);
skb_reset_mac_header(skb);
- hsr_fill_tag(skb, frame, port, port->hsr->prot_version);
+ hsr_fill_tag(skb, frame, port, port->priv->prot_version);
return skb;
}
@@ -244,7 +244,7 @@ static void hsr_forward_do(struct hsr_frame_info *frame)
struct hsr_port *port;
struct sk_buff *skb;
- hsr_for_each_port(frame->port_rcv->hsr, port) {
+ hsr_for_each_port(frame->port_rcv->priv, port) {
/* Don't send frame back the way it came */
if (port == frame->port_rcv)
continue;
@@ -286,10 +286,10 @@ static void hsr_forward_do(struct hsr_frame_info *frame)
}
}
-static void check_local_dest(struct hsr_priv *hsr, struct sk_buff *skb,
+static void check_local_dest(struct hsr_priv *priv, struct sk_buff *skb,
struct hsr_frame_info *frame)
{
- if (hsr_addr_is_self(hsr, eth_hdr(skb)->h_dest)) {
+ if (hsr_addr_is_self(priv, eth_hdr(skb)->h_dest)) {
frame->is_local_exclusive = true;
skb->pkt_type = PACKET_HOST;
} else {
@@ -311,7 +311,7 @@ static int hsr_fill_frame_info(struct hsr_frame_info *frame,
struct ethhdr *ethhdr;
unsigned long irqflags;
- frame->is_supervision = is_supervision_frame(port->hsr, skb);
+ frame->is_supervision = is_supervision_frame(port->priv, skb);
frame->node_src = hsr_get_node(port, skb, frame->is_supervision);
if (!frame->node_src)
return -1; /* Unknown node and !is_supervision, or no mem */
@@ -332,14 +332,14 @@ static int hsr_fill_frame_info(struct hsr_frame_info *frame,
frame->skb_std = skb;
frame->skb_hsr = NULL;
/* Sequence nr for the master node */
- spin_lock_irqsave(&port->hsr->seqnr_lock, irqflags);
- frame->sequence_nr = port->hsr->sequence_nr;
- port->hsr->sequence_nr++;
- spin_unlock_irqrestore(&port->hsr->seqnr_lock, irqflags);
+ spin_lock_irqsave(&port->priv->seqnr_lock, irqflags);
+ frame->sequence_nr = port->priv->sequence_nr;
+ port->priv->sequence_nr++;
+ spin_unlock_irqrestore(&port->priv->seqnr_lock, irqflags);
}
frame->port_rcv = port;
- check_local_dest(port->hsr, skb, frame);
+ check_local_dest(port->priv, skb, frame);
return 0;
}
diff --git a/net/hsr-prp/hsr_prp_framereg.c b/net/hsr-prp/hsr_prp_framereg.c
index b02a2a0ca0ff..854338352e93 100644
--- a/net/hsr-prp/hsr_prp_framereg.c
+++ b/net/hsr-prp/hsr_prp_framereg.c
@@ -37,11 +37,11 @@ static bool seq_nr_after(u16 a, u16 b)
#define seq_nr_before(a, b) seq_nr_after((b), (a))
#define seq_nr_before_or_eq(a, b) (!seq_nr_after((a), (b)))
-bool hsr_addr_is_self(struct hsr_priv *hsr, unsigned char *addr)
+bool hsr_addr_is_self(struct hsr_priv *priv, unsigned char *addr)
{
struct hsr_node *node;
- node = list_first_or_null_rcu(&hsr->self_node_db, struct hsr_node,
+ node = list_first_or_null_rcu(&priv->self_node_db, struct hsr_node,
mac_list);
if (!node) {
WARN_ONCE(1, "HSR: No self node\n");
@@ -74,11 +74,11 @@ static struct hsr_node *find_node_by_addr_A(struct list_head *node_db,
/* Helper for device init; the self_node_db is used in hsr_rcv() to recognize
* frames from self that's been looped over the HSR ring.
*/
-int hsr_create_self_node(struct hsr_priv *hsr,
+int hsr_create_self_node(struct hsr_priv *priv,
unsigned char addr_a[ETH_ALEN],
unsigned char addr_b[ETH_ALEN])
{
- struct list_head *self_node_db = &hsr->self_node_db;
+ struct list_head *self_node_db = &priv->self_node_db;
struct hsr_node *node, *oldnode;
node = kmalloc(sizeof(*node), GFP_KERNEL);
@@ -88,33 +88,33 @@ int hsr_create_self_node(struct hsr_priv *hsr,
ether_addr_copy(node->macaddress_A, addr_a);
ether_addr_copy(node->macaddress_B, addr_b);
- spin_lock_bh(&hsr->list_lock);
+ spin_lock_bh(&priv->list_lock);
oldnode = list_first_or_null_rcu(self_node_db,
struct hsr_node, mac_list);
if (oldnode) {
list_replace_rcu(&oldnode->mac_list, &node->mac_list);
- spin_unlock_bh(&hsr->list_lock);
+ spin_unlock_bh(&priv->list_lock);
kfree_rcu(oldnode, rcu_head);
} else {
list_add_tail_rcu(&node->mac_list, self_node_db);
- spin_unlock_bh(&hsr->list_lock);
+ spin_unlock_bh(&priv->list_lock);
}
return 0;
}
-void hsr_del_self_node(struct hsr_priv *hsr)
+void hsr_del_self_node(struct hsr_priv *priv)
{
- struct list_head *self_node_db = &hsr->self_node_db;
+ struct list_head *self_node_db = &priv->self_node_db;
struct hsr_node *node;
- spin_lock_bh(&hsr->list_lock);
+ spin_lock_bh(&priv->list_lock);
node = list_first_or_null_rcu(self_node_db, struct hsr_node, mac_list);
if (node) {
list_del_rcu(&node->mac_list);
kfree_rcu(node, rcu_head);
}
- spin_unlock_bh(&hsr->list_lock);
+ spin_unlock_bh(&priv->list_lock);
}
void hsr_del_nodes(struct list_head *node_db)
@@ -130,7 +130,7 @@ void hsr_del_nodes(struct list_head *node_db)
* seq_out is used to initialize filtering of outgoing duplicate frames
* originating from the newly added node.
*/
-static struct hsr_node *hsr_add_node(struct hsr_priv *hsr,
+static struct hsr_node *hsr_add_node(struct hsr_priv *priv,
struct list_head *node_db,
unsigned char addr[],
u16 seq_out)
@@ -154,19 +154,19 @@ static struct hsr_node *hsr_add_node(struct hsr_priv *hsr,
for (i = 0; i < HSR_PT_PORTS; i++)
new_node->seq_out[i] = seq_out;
- spin_lock_bh(&hsr->list_lock);
+ spin_lock_bh(&priv->list_lock);
list_for_each_entry_rcu(node, node_db, mac_list,
- lockdep_is_held(&hsr->list_lock)) {
+ lockdep_is_held(&priv->list_lock)) {
if (ether_addr_equal(node->macaddress_A, addr))
goto out;
if (ether_addr_equal(node->macaddress_B, addr))
goto out;
}
list_add_tail_rcu(&new_node->mac_list, node_db);
- spin_unlock_bh(&hsr->list_lock);
+ spin_unlock_bh(&priv->list_lock);
return new_node;
out:
- spin_unlock_bh(&hsr->list_lock);
+ spin_unlock_bh(&priv->list_lock);
kfree(new_node);
return node;
}
@@ -176,8 +176,8 @@ static struct hsr_node *hsr_add_node(struct hsr_priv *hsr,
struct hsr_node *hsr_get_node(struct hsr_port *port, struct sk_buff *skb,
bool is_sup)
{
- struct list_head *node_db = &port->hsr->node_db;
- struct hsr_priv *hsr = port->hsr;
+ struct list_head *node_db = &port->priv->node_db;
+ struct hsr_priv *priv = port->priv;
struct hsr_node *node;
struct ethhdr *ethhdr;
u16 seq_out;
@@ -211,7 +211,7 @@ struct hsr_node *hsr_get_node(struct hsr_port *port, struct sk_buff *skb,
seq_out = HSR_SEQNR_START;
}
- return hsr_add_node(hsr, node_db, ethhdr->h_source, seq_out);
+ return hsr_add_node(priv, node_db, ethhdr->h_source, seq_out);
}
/* Use the Supervision frame's info about an eventual macaddress_B for merging
@@ -221,7 +221,7 @@ struct hsr_node *hsr_get_node(struct hsr_port *port, struct sk_buff *skb,
void hsr_handle_sup_frame(struct sk_buff *skb, struct hsr_node *node_curr,
struct hsr_port *port_rcv)
{
- struct hsr_priv *hsr = port_rcv->hsr;
+ struct hsr_priv *priv = port_rcv->priv;
struct hsr_sup_payload *hsr_sp;
struct hsr_node *node_real;
struct list_head *node_db;
@@ -243,11 +243,11 @@ void hsr_handle_sup_frame(struct sk_buff *skb, struct hsr_node *node_curr,
hsr_sp = (struct hsr_sup_payload *)skb->data;
/* Merge node_curr (registered on macaddress_B) into node_real */
- node_db = &port_rcv->hsr->node_db;
+ node_db = &port_rcv->priv->node_db;
node_real = find_node_by_addr_A(node_db, hsr_sp->macaddress_A);
if (!node_real)
/* No frame received from AddrA of this node yet */
- node_real = hsr_add_node(hsr, node_db, hsr_sp->macaddress_A,
+ node_real = hsr_add_node(priv, node_db, hsr_sp->macaddress_A,
HSR_SEQNR_START - 1);
if (!node_real)
goto done; /* No mem */
@@ -268,9 +268,9 @@ void hsr_handle_sup_frame(struct sk_buff *skb, struct hsr_node *node_curr,
}
node_real->addr_B_port = port_rcv->type;
- spin_lock_bh(&hsr->list_lock);
+ spin_lock_bh(&priv->list_lock);
list_del_rcu(&node_curr->mac_list);
- spin_unlock_bh(&hsr->list_lock);
+ spin_unlock_bh(&priv->list_lock);
kfree_rcu(node_curr, rcu_head);
done:
@@ -315,7 +315,7 @@ void hsr_addr_subst_dest(struct hsr_node *node_src, struct sk_buff *skb,
if (!is_unicast_ether_addr(eth_hdr(skb)->h_dest))
return;
- node_dst = find_node_by_addr_A(&port->hsr->node_db,
+ node_dst = find_node_by_addr_A(&port->priv->node_db,
eth_hdr(skb)->h_dest);
if (!node_dst) {
if (net_ratelimit())
@@ -360,22 +360,22 @@ int hsr_register_frame_out(struct hsr_port *port, struct hsr_node *node,
return 0;
}
-static struct hsr_port *get_late_port(struct hsr_priv *hsr,
+static struct hsr_port *get_late_port(struct hsr_priv *priv,
struct hsr_node *node)
{
if (node->time_in_stale[HSR_PT_SLAVE_A])
- return hsr_port_get_hsr(hsr, HSR_PT_SLAVE_A);
+ return hsr_port_get_hsr(priv, HSR_PT_SLAVE_A);
if (node->time_in_stale[HSR_PT_SLAVE_B])
- return hsr_port_get_hsr(hsr, HSR_PT_SLAVE_B);
+ return hsr_port_get_hsr(priv, HSR_PT_SLAVE_B);
if (time_after(node->time_in[HSR_PT_SLAVE_B],
node->time_in[HSR_PT_SLAVE_A] +
msecs_to_jiffies(MAX_SLAVE_DIFF)))
- return hsr_port_get_hsr(hsr, HSR_PT_SLAVE_A);
+ return hsr_port_get_hsr(priv, HSR_PT_SLAVE_A);
if (time_after(node->time_in[HSR_PT_SLAVE_A],
node->time_in[HSR_PT_SLAVE_B] +
msecs_to_jiffies(MAX_SLAVE_DIFF)))
- return hsr_port_get_hsr(hsr, HSR_PT_SLAVE_B);
+ return hsr_port_get_hsr(priv, HSR_PT_SLAVE_B);
return NULL;
}
@@ -385,21 +385,21 @@ static struct hsr_port *get_late_port(struct hsr_priv *hsr,
*/
void hsr_prune_nodes(struct timer_list *t)
{
- struct hsr_priv *hsr = from_timer(hsr, t, prune_timer);
+ struct hsr_priv *priv = from_timer(priv, t, prune_timer);
struct hsr_node *node;
struct hsr_node *tmp;
struct hsr_port *port;
unsigned long timestamp;
unsigned long time_a, time_b;
- spin_lock_bh(&hsr->list_lock);
- list_for_each_entry_safe(node, tmp, &hsr->node_db, mac_list) {
+ spin_lock_bh(&priv->list_lock);
+ list_for_each_entry_safe(node, tmp, &priv->node_db, mac_list) {
/* Don't prune own node. Neither time_in[HSR_PT_SLAVE_A]
* nor time_in[HSR_PT_SLAVE_B], will ever be updated for
* the master port. Thus the master node will be repeatedly
* pruned leading to packet loss.
*/
- if (hsr_addr_is_self(hsr, node->macaddress_A))
+ if (hsr_addr_is_self(priv, node->macaddress_A))
continue;
/* Shorthand */
@@ -426,35 +426,36 @@ void hsr_prune_nodes(struct timer_list *t)
if (time_is_after_jiffies(timestamp +
msecs_to_jiffies(1.5 * MAX_SLAVE_DIFF))) {
rcu_read_lock();
- port = get_late_port(hsr, node);
+ port = get_late_port(priv, node);
if (port)
- hsr_nl_ringerror(hsr, node->macaddress_A, port);
+ hsr_nl_ringerror(priv,
+ node->macaddress_A, port);
rcu_read_unlock();
}
/* Prune old entries */
if (time_is_before_jiffies(timestamp +
msecs_to_jiffies(HSR_NODE_FORGET_TIME))) {
- hsr_nl_nodedown(hsr, node->macaddress_A);
+ hsr_nl_nodedown(priv, node->macaddress_A);
list_del_rcu(&node->mac_list);
/* Note that we need to free this entry later: */
kfree_rcu(node, rcu_head);
}
}
- spin_unlock_bh(&hsr->list_lock);
+ spin_unlock_bh(&priv->list_lock);
/* Restart timer */
- mod_timer(&hsr->prune_timer,
+ mod_timer(&priv->prune_timer,
jiffies + msecs_to_jiffies(PRUNE_PERIOD));
}
-void *hsr_get_next_node(struct hsr_priv *hsr, void *_pos,
+void *hsr_get_next_node(struct hsr_priv *priv, void *_pos,
unsigned char addr[ETH_ALEN])
{
struct hsr_node *node;
if (!_pos) {
- node = list_first_or_null_rcu(&hsr->node_db,
+ node = list_first_or_null_rcu(&priv->node_db,
struct hsr_node, mac_list);
if (node)
ether_addr_copy(addr, node->macaddress_A);
@@ -462,7 +463,7 @@ void *hsr_get_next_node(struct hsr_priv *hsr, void *_pos,
}
node = _pos;
- list_for_each_entry_continue_rcu(node, &hsr->node_db, mac_list) {
+ list_for_each_entry_continue_rcu(node, &priv->node_db, mac_list) {
ether_addr_copy(addr, node->macaddress_A);
return node;
}
@@ -470,7 +471,7 @@ void *hsr_get_next_node(struct hsr_priv *hsr, void *_pos,
return NULL;
}
-int hsr_get_node_data(struct hsr_priv *hsr,
+int hsr_get_node_data(struct hsr_priv *priv,
const unsigned char *addr,
unsigned char addr_b[ETH_ALEN],
unsigned int *addr_b_ifindex,
@@ -483,7 +484,7 @@ int hsr_get_node_data(struct hsr_priv *hsr,
struct hsr_port *port;
unsigned long tdiff;
- node = find_node_by_addr_A(&hsr->node_db, addr);
+ node = find_node_by_addr_A(&priv->node_db, addr);
if (!node)
return -ENOENT;
@@ -514,7 +515,7 @@ int hsr_get_node_data(struct hsr_priv *hsr,
*if2_seq = node->seq_out[HSR_PT_SLAVE_A];
if (node->addr_B_port != HSR_PT_NONE) {
- port = hsr_port_get_hsr(hsr, node->addr_B_port);
+ port = hsr_port_get_hsr(priv, node->addr_B_port);
*addr_b_ifindex = port->dev->ifindex;
} else {
*addr_b_ifindex = -1;
diff --git a/net/hsr-prp/hsr_prp_framereg.h b/net/hsr-prp/hsr_prp_framereg.h
index c7a2a975aca0..b29b685e444a 100644
--- a/net/hsr-prp/hsr_prp_framereg.h
+++ b/net/hsr-prp/hsr_prp_framereg.h
@@ -12,13 +12,13 @@
struct hsr_node;
-void hsr_del_self_node(struct hsr_priv *hsr);
+void hsr_del_self_node(struct hsr_priv *priv);
void hsr_del_nodes(struct list_head *node_db);
struct hsr_node *hsr_get_node(struct hsr_port *port, struct sk_buff *skb,
bool is_sup);
void hsr_handle_sup_frame(struct sk_buff *skb, struct hsr_node *node_curr,
struct hsr_port *port);
-bool hsr_addr_is_self(struct hsr_priv *hsr, unsigned char *addr);
+bool hsr_addr_is_self(struct hsr_priv *priv, unsigned char *addr);
void hsr_addr_subst_source(struct hsr_node *node, struct sk_buff *skb);
void hsr_addr_subst_dest(struct hsr_node *node_src, struct sk_buff *skb,
@@ -31,14 +31,14 @@ int hsr_register_frame_out(struct hsr_port *port, struct hsr_node *node,
void hsr_prune_nodes(struct timer_list *t);
-int hsr_create_self_node(struct hsr_priv *hsr,
+int hsr_create_self_node(struct hsr_priv *priv,
unsigned char addr_a[ETH_ALEN],
unsigned char addr_b[ETH_ALEN]);
-void *hsr_get_next_node(struct hsr_priv *hsr, void *_pos,
+void *hsr_get_next_node(struct hsr_priv *priv, void *_pos,
unsigned char addr[ETH_ALEN]);
-int hsr_get_node_data(struct hsr_priv *hsr,
+int hsr_get_node_data(struct hsr_priv *priv,
const unsigned char *addr,
unsigned char addr_b[ETH_ALEN],
unsigned int *addr_b_ifindex,
diff --git a/net/hsr-prp/hsr_prp_main.c b/net/hsr-prp/hsr_prp_main.c
index d0b7117bf5f9..caa544d0af42 100644
--- a/net/hsr-prp/hsr_prp_main.c
+++ b/net/hsr-prp/hsr_prp_main.c
@@ -15,11 +15,11 @@
#include "hsr_prp_framereg.h"
#include "hsr_prp_slave.h"
-static bool hsr_slave_empty(struct hsr_priv *hsr)
+static bool hsr_slave_empty(struct hsr_priv *priv)
{
struct hsr_port *port;
- hsr_for_each_port(hsr, port)
+ hsr_for_each_port(priv, port)
if (port->type != HSR_PT_MASTER)
return false;
return true;
@@ -30,7 +30,7 @@ static int hsr_netdev_notify(struct notifier_block *nb, unsigned long event,
{
struct hsr_port *port, *master;
struct net_device *dev;
- struct hsr_priv *hsr;
+ struct hsr_priv *priv;
LIST_HEAD(list_kill);
int mtu_max;
int res;
@@ -40,21 +40,21 @@ static int hsr_netdev_notify(struct notifier_block *nb, unsigned long event,
if (!port) {
if (!is_hsr_master(dev))
return NOTIFY_DONE; /* Not an HSR device */
- hsr = netdev_priv(dev);
- port = hsr_port_get_hsr(hsr, HSR_PT_MASTER);
+ priv = netdev_priv(dev);
+ port = hsr_port_get_hsr(priv, HSR_PT_MASTER);
if (!port) {
/* Resend of notification concerning removed device? */
return NOTIFY_DONE;
}
} else {
- hsr = port->hsr;
+ priv = port->priv;
}
switch (event) {
case NETDEV_UP: /* Administrative state DOWN */
case NETDEV_DOWN: /* Administrative state UP */
case NETDEV_CHANGE: /* Link (carrier) state changes */
- hsr_check_carrier_and_operstate(hsr);
+ hsr_check_carrier_and_operstate(priv);
break;
case NETDEV_CHANGENAME:
if (is_hsr_master(dev))
@@ -69,7 +69,7 @@ static int hsr_netdev_notify(struct notifier_block *nb, unsigned long event,
break;
}
- master = hsr_port_get_hsr(hsr, HSR_PT_MASTER);
+ master = hsr_port_get_hsr(priv, HSR_PT_MASTER);
if (port->type == HSR_PT_SLAVE_A) {
ether_addr_copy(master->dev->dev_addr, dev->dev_addr);
@@ -78,8 +78,8 @@ static int hsr_netdev_notify(struct notifier_block *nb, unsigned long event,
}
/* Make sure we recognize frames from ourselves in hsr_rcv() */
- port = hsr_port_get_hsr(hsr, HSR_PT_SLAVE_B);
- res = hsr_create_self_node(hsr,
+ port = hsr_port_get_hsr(priv, HSR_PT_SLAVE_B);
+ res = hsr_create_self_node(priv,
master->dev->dev_addr,
port ?
port->dev->dev_addr :
@@ -91,15 +91,15 @@ static int hsr_netdev_notify(struct notifier_block *nb, unsigned long event,
case NETDEV_CHANGEMTU:
if (port->type == HSR_PT_MASTER)
break; /* Handled in ndo_change_mtu() */
- mtu_max = hsr_get_max_mtu(port->hsr);
- master = hsr_port_get_hsr(port->hsr, HSR_PT_MASTER);
+ mtu_max = hsr_get_max_mtu(port->priv);
+ master = hsr_port_get_hsr(port->priv, HSR_PT_MASTER);
master->dev->mtu = mtu_max;
break;
case NETDEV_UNREGISTER:
if (!is_hsr_master(dev)) {
- master = hsr_port_get_hsr(port->hsr, HSR_PT_MASTER);
+ master = hsr_port_get_hsr(port->priv, HSR_PT_MASTER);
hsr_del_port(port);
- if (hsr_slave_empty(master->hsr)) {
+ if (hsr_slave_empty(master->priv)) {
unregister_netdevice_queue(master->dev,
&list_kill);
unregister_netdevice_many(&list_kill);
@@ -116,11 +116,11 @@ static int hsr_netdev_notify(struct notifier_block *nb, unsigned long event,
return NOTIFY_DONE;
}
-struct hsr_port *hsr_port_get_hsr(struct hsr_priv *hsr, enum hsr_port_type pt)
+struct hsr_port *hsr_port_get_hsr(struct hsr_priv *priv, enum hsr_port_type pt)
{
struct hsr_port *port;
- hsr_for_each_port(hsr, port)
+ hsr_for_each_port(priv, port)
if (port->type == pt)
return port;
return NULL;
diff --git a/net/hsr-prp/hsr_prp_main.h b/net/hsr-prp/hsr_prp_main.h
index f74193465bf5..d11a9f0b696f 100644
--- a/net/hsr-prp/hsr_prp_main.h
+++ b/net/hsr-prp/hsr_prp_main.h
@@ -127,7 +127,7 @@ enum hsr_port_type {
struct hsr_port {
struct list_head port_list;
struct net_device *dev;
- struct hsr_priv *hsr;
+ struct hsr_priv *priv;
enum hsr_port_type type;
};
@@ -150,10 +150,10 @@ struct hsr_priv {
#endif
};
-#define hsr_for_each_port(hsr, port) \
- list_for_each_entry_rcu((port), &(hsr)->ports, port_list)
+#define hsr_for_each_port(priv, port) \
+ list_for_each_entry_rcu((port), &(priv)->ports, port_list)
-struct hsr_port *hsr_port_get_hsr(struct hsr_priv *hsr, enum hsr_port_type pt);
+struct hsr_port *hsr_port_get_hsr(struct hsr_priv *priv, enum hsr_port_type pt);
/* Caller must ensure skb is a valid HSR frame */
static inline u16 hsr_get_skb_sequence_nr(struct sk_buff *skb)
diff --git a/net/hsr-prp/hsr_prp_slave.c b/net/hsr-prp/hsr_prp_slave.c
index fad8fef783cc..96de8d15db00 100644
--- a/net/hsr-prp/hsr_prp_slave.c
+++ b/net/hsr-prp/hsr_prp_slave.c
@@ -29,7 +29,7 @@ static rx_handler_result_t hsr_handle_frame(struct sk_buff **pskb)
if (!port)
goto finish_pass;
- if (hsr_addr_is_self(port->hsr, eth_hdr(skb)->h_source)) {
+ if (hsr_addr_is_self(port->priv, eth_hdr(skb)->h_source)) {
/* Directly kill frames sent by ourselves */
kfree_skb(skb);
goto finish_consume;
@@ -97,7 +97,7 @@ static int hsr_check_dev_ok(struct net_device *dev,
}
/* Setup device to be added to the HSR bridge. */
-static int hsr_portdev_setup(struct hsr_priv *hsr, struct net_device *dev,
+static int hsr_portdev_setup(struct hsr_priv *priv, struct net_device *dev,
struct hsr_port *port,
struct netlink_ext_ack *extack)
@@ -110,7 +110,7 @@ static int hsr_portdev_setup(struct hsr_priv *hsr, struct net_device *dev,
if (res)
return res;
- master = hsr_port_get_hsr(hsr, HSR_PT_MASTER);
+ master = hsr_port_get_hsr(priv, HSR_PT_MASTER);
hsr_dev = master->dev;
res = netdev_upper_dev_link(dev, hsr_dev, extack);
@@ -131,7 +131,7 @@ static int hsr_portdev_setup(struct hsr_priv *hsr, struct net_device *dev,
return res;
}
-int hsr_add_port(struct hsr_priv *hsr, struct net_device *dev,
+int hsr_add_port(struct hsr_priv *priv, struct net_device *dev,
enum hsr_port_type type, struct netlink_ext_ack *extack)
{
struct hsr_port *port, *master;
@@ -143,7 +143,7 @@ int hsr_add_port(struct hsr_priv *hsr, struct net_device *dev,
return res;
}
- port = hsr_port_get_hsr(hsr, type);
+ port = hsr_port_get_hsr(priv, type);
if (port)
return -EBUSY; /* This port already exists */
@@ -151,22 +151,22 @@ int hsr_add_port(struct hsr_priv *hsr, struct net_device *dev,
if (!port)
return -ENOMEM;
- port->hsr = hsr;
+ port->priv = priv;
port->dev = dev;
port->type = type;
if (type != HSR_PT_MASTER) {
- res = hsr_portdev_setup(hsr, dev, port, extack);
+ res = hsr_portdev_setup(priv, dev, port, extack);
if (res)
goto fail_dev_setup;
}
- list_add_tail_rcu(&port->port_list, &hsr->ports);
+ list_add_tail_rcu(&port->port_list, &priv->ports);
synchronize_rcu();
- master = hsr_port_get_hsr(hsr, HSR_PT_MASTER);
+ master = hsr_port_get_hsr(priv, HSR_PT_MASTER);
netdev_update_features(master->dev);
- dev_set_mtu(master->dev, hsr_get_max_mtu(hsr));
+ dev_set_mtu(master->dev, hsr_get_max_mtu(priv));
return 0;
@@ -177,16 +177,16 @@ int hsr_add_port(struct hsr_priv *hsr, struct net_device *dev,
void hsr_del_port(struct hsr_port *port)
{
- struct hsr_priv *hsr;
+ struct hsr_priv *priv;
struct hsr_port *master;
- hsr = port->hsr;
- master = hsr_port_get_hsr(hsr, HSR_PT_MASTER);
+ priv = port->priv;
+ master = hsr_port_get_hsr(priv, HSR_PT_MASTER);
list_del_rcu(&port->port_list);
if (port != master) {
netdev_update_features(master->dev);
- dev_set_mtu(master->dev, hsr_get_max_mtu(hsr));
+ dev_set_mtu(master->dev, hsr_get_max_mtu(priv));
netdev_rx_handler_unregister(port->dev);
dev_set_promiscuity(port->dev, -1);
netdev_upper_dev_unlink(port->dev, master->dev);
diff --git a/net/hsr-prp/hsr_prp_slave.h b/net/hsr-prp/hsr_prp_slave.h
index c0360b111151..85f292d88845 100644
--- a/net/hsr-prp/hsr_prp_slave.h
+++ b/net/hsr-prp/hsr_prp_slave.h
@@ -12,7 +12,7 @@
#include <linux/rtnetlink.h>
#include "hsr_prp_main.h"
-int hsr_add_port(struct hsr_priv *hsr, struct net_device *dev,
+int hsr_add_port(struct hsr_priv *priv, struct net_device *dev,
enum hsr_port_type pt, struct netlink_ext_ack *extack);
void hsr_del_port(struct hsr_port *port);
bool hsr_port_exists(const struct net_device *dev);
--
2.17.1
Migrate the existing netlink socket code to the use the new common API.
Signed-off-by: Murali Karicheri <[email protected]>
---
net/hsr-prp/hsr_netlink.c | 123 +++++++++++++++++++-------------------
net/hsr-prp/hsr_netlink.h | 2 +-
2 files changed, 64 insertions(+), 61 deletions(-)
diff --git a/net/hsr-prp/hsr_netlink.c b/net/hsr-prp/hsr_netlink.c
index fbfa98aee13c..1f7c3be8d96e 100644
--- a/net/hsr-prp/hsr_netlink.c
+++ b/net/hsr-prp/hsr_netlink.c
@@ -15,13 +15,13 @@
#include "hsr_prp_device.h"
#include "hsr_prp_framereg.h"
-static const struct nla_policy hsr_policy[IFLA_HSR_MAX + 1] = {
- [IFLA_HSR_SLAVE1] = { .type = NLA_U32 },
- [IFLA_HSR_SLAVE2] = { .type = NLA_U32 },
- [IFLA_HSR_MULTICAST_SPEC] = { .type = NLA_U8 },
- [IFLA_HSR_VERSION] = { .type = NLA_U8 },
- [IFLA_HSR_SUPERVISION_ADDR] = { .len = ETH_ALEN },
- [IFLA_HSR_SEQ_NR] = { .type = NLA_U16 },
+static const struct nla_policy hsr_policy[IFLA_HSR_PRP_MAX + 1] = {
+ [IFLA_HSR_PRP_SLAVE1] = { .type = NLA_U32 },
+ [IFLA_HSR_PRP_SLAVE2] = { .type = NLA_U32 },
+ [IFLA_HSR_PRP_SF_MC_ADDR_LSB] = { .type = NLA_U8 },
+ [IFLA_HSR_PRP_VERSION] = { .type = NLA_U8 },
+ [IFLA_HSR_PRP_SF_MC_ADDR] = { .len = ETH_ALEN },
+ [IFLA_HSR_PRP_SEQ_NR] = { .type = NLA_U16 },
};
/* Here, it seems a netdevice has already been allocated for us, and the
@@ -38,22 +38,22 @@ static int hsr_newlink(struct net *src_net, struct net_device *dev,
NL_SET_ERR_MSG_MOD(extack, "No slave devices specified");
return -EINVAL;
}
- if (!data[IFLA_HSR_SLAVE1]) {
+ if (!data[IFLA_HSR_PRP_SLAVE1]) {
NL_SET_ERR_MSG_MOD(extack, "Slave1 device not specified");
return -EINVAL;
}
link[0] = __dev_get_by_index(src_net,
- nla_get_u32(data[IFLA_HSR_SLAVE1]));
+ nla_get_u32(data[IFLA_HSR_PRP_SLAVE1]));
if (!link[0]) {
NL_SET_ERR_MSG_MOD(extack, "Slave1 does not exist");
return -EINVAL;
}
- if (!data[IFLA_HSR_SLAVE2]) {
+ if (!data[IFLA_HSR_PRP_SLAVE2]) {
NL_SET_ERR_MSG_MOD(extack, "Slave2 device not specified");
return -EINVAL;
}
link[1] = __dev_get_by_index(src_net,
- nla_get_u32(data[IFLA_HSR_SLAVE2]));
+ nla_get_u32(data[IFLA_HSR_PRP_SLAVE2]));
if (!link[1]) {
NL_SET_ERR_MSG_MOD(extack, "Slave2 does not exist");
return -EINVAL;
@@ -64,15 +64,15 @@ static int hsr_newlink(struct net *src_net, struct net_device *dev,
return -EINVAL;
}
- if (!data[IFLA_HSR_MULTICAST_SPEC])
+ if (!data[IFLA_HSR_PRP_SF_MC_ADDR_LSB])
multicast_spec = 0;
else
- multicast_spec = nla_get_u8(data[IFLA_HSR_MULTICAST_SPEC]);
+ multicast_spec = nla_get_u8(data[IFLA_HSR_PRP_SF_MC_ADDR_LSB]);
- if (!data[IFLA_HSR_VERSION]) {
+ if (!data[IFLA_HSR_PRP_VERSION]) {
hsr_version = 0;
} else {
- hsr_version = nla_get_u8(data[IFLA_HSR_VERSION]);
+ hsr_version = nla_get_u8(data[IFLA_HSR_PRP_VERSION]);
if (hsr_version > 1) {
NL_SET_ERR_MSG_MOD(extack,
"Only versions 0..1 are supported");
@@ -91,19 +91,19 @@ static int hsr_fill_info(struct sk_buff *skb, const struct net_device *dev)
port = hsr_prp_get_port(priv, HSR_PRP_PT_SLAVE_A);
if (port) {
- if (nla_put_u32(skb, IFLA_HSR_SLAVE1, port->dev->ifindex))
+ if (nla_put_u32(skb, IFLA_HSR_PRP_SLAVE1, port->dev->ifindex))
goto nla_put_failure;
}
port = hsr_prp_get_port(priv, HSR_PRP_PT_SLAVE_B);
if (port) {
- if (nla_put_u32(skb, IFLA_HSR_SLAVE2, port->dev->ifindex))
+ if (nla_put_u32(skb, IFLA_HSR_PRP_SLAVE2, port->dev->ifindex))
goto nla_put_failure;
}
- if (nla_put(skb, IFLA_HSR_SUPERVISION_ADDR, ETH_ALEN,
+ if (nla_put(skb, IFLA_HSR_PRP_SF_MC_ADDR, ETH_ALEN,
priv->sup_multicast_addr) ||
- nla_put_u16(skb, IFLA_HSR_SEQ_NR, priv->sequence_nr))
+ nla_put_u16(skb, IFLA_HSR_PRP_SEQ_NR, priv->sequence_nr))
goto nla_put_failure;
return 0;
@@ -114,7 +114,7 @@ static int hsr_fill_info(struct sk_buff *skb, const struct net_device *dev)
static struct rtnl_link_ops hsr_link_ops __read_mostly = {
.kind = "hsr",
- .maxtype = IFLA_HSR_MAX,
+ .maxtype = IFLA_HSR_PRP_MAX,
.policy = hsr_policy,
.priv_size = sizeof(struct hsr_prp_priv),
.setup = hsr_prp_dev_setup,
@@ -123,14 +123,14 @@ static struct rtnl_link_ops hsr_link_ops __read_mostly = {
};
/* attribute policy */
-static const struct nla_policy hsr_genl_policy[HSR_A_MAX + 1] = {
- [HSR_A_NODE_ADDR] = { .len = ETH_ALEN },
- [HSR_A_NODE_ADDR_B] = { .len = ETH_ALEN },
- [HSR_A_IFINDEX] = { .type = NLA_U32 },
- [HSR_A_IF1_AGE] = { .type = NLA_U32 },
- [HSR_A_IF2_AGE] = { .type = NLA_U32 },
- [HSR_A_IF1_SEQ] = { .type = NLA_U16 },
- [HSR_A_IF2_SEQ] = { .type = NLA_U16 },
+static const struct nla_policy hsr_genl_policy[HSR_PRP_A_MAX + 1] = {
+ [HSR_PRP_A_NODE_ADDR] = { .len = ETH_ALEN },
+ [HSR_PRP_A_NODE_ADDR_B] = { .len = ETH_ALEN },
+ [HSR_PRP_A_IFINDEX] = { .type = NLA_U32 },
+ [HSR_PRP_A_IF1_AGE] = { .type = NLA_U32 },
+ [HSR_PRP_A_IF2_AGE] = { .type = NLA_U32 },
+ [HSR_PRP_A_IF1_SEQ] = { .type = NLA_U16 },
+ [HSR_PRP_A_IF2_SEQ] = { .type = NLA_U16 },
};
static struct genl_family hsr_genl_family;
@@ -157,15 +157,15 @@ void hsr_nl_ringerror(struct hsr_prp_priv *priv,
goto fail;
msg_head = genlmsg_put(skb, 0, 0, &hsr_genl_family, 0,
- HSR_C_RING_ERROR);
+ HSR_PRP_C_RING_ERROR);
if (!msg_head)
goto nla_put_failure;
- res = nla_put(skb, HSR_A_NODE_ADDR, ETH_ALEN, addr);
+ res = nla_put(skb, HSR_PRP_A_NODE_ADDR, ETH_ALEN, addr);
if (res < 0)
goto nla_put_failure;
- res = nla_put_u32(skb, HSR_A_IFINDEX, port->dev->ifindex);
+ res = nla_put_u32(skb, HSR_PRP_A_IFINDEX, port->dev->ifindex);
if (res < 0)
goto nla_put_failure;
@@ -199,11 +199,12 @@ void hsr_nl_nodedown(struct hsr_prp_priv *priv,
if (!skb)
goto fail;
- msg_head = genlmsg_put(skb, 0, 0, &hsr_genl_family, 0, HSR_C_NODE_DOWN);
+ msg_head = genlmsg_put(skb, 0, 0, &hsr_genl_family, 0,
+ HSR_PRP_C_NODE_DOWN);
if (!msg_head)
goto nla_put_failure;
- res = nla_put(skb, HSR_A_NODE_ADDR, ETH_ALEN, addr);
+ res = nla_put(skb, HSR_PRP_A_NODE_ADDR, ETH_ALEN, addr);
if (res < 0)
goto nla_put_failure;
@@ -222,7 +223,7 @@ void hsr_nl_nodedown(struct hsr_prp_priv *priv,
rcu_read_unlock();
}
-/* HSR_C_GET_NODE_STATUS lets userspace query the internal HSR node table
+/* HSR_PRP_C_GET_NODE_STATUS lets userspace query the internal HSR node table
* about the status of a specific node in the network, defined by its MAC
* address.
*
@@ -252,16 +253,17 @@ static int hsr_get_node_status(struct sk_buff *skb_in, struct genl_info *info)
if (!info)
goto invalid;
- na = info->attrs[HSR_A_IFINDEX];
+ na = info->attrs[HSR_PRP_A_IFINDEX];
if (!na)
goto invalid;
- na = info->attrs[HSR_A_NODE_ADDR];
+ na = info->attrs[HSR_PRP_A_NODE_ADDR];
if (!na)
goto invalid;
rcu_read_lock();
- hsr_dev = dev_get_by_index_rcu(genl_info_net(info),
- nla_get_u32(info->attrs[HSR_A_IFINDEX]));
+ hsr_dev =
+ dev_get_by_index_rcu(genl_info_net(info),
+ nla_get_u32(info->attrs[HSR_PRP_A_IFINDEX]));
if (!hsr_dev)
goto rcu_unlock;
if (!is_hsr_prp_master(hsr_dev))
@@ -276,20 +278,20 @@ static int hsr_get_node_status(struct sk_buff *skb_in, struct genl_info *info)
msg_head = genlmsg_put(skb_out, NETLINK_CB(skb_in).portid,
info->snd_seq, &hsr_genl_family, 0,
- HSR_C_SET_NODE_STATUS);
+ HSR_PRP_C_SET_NODE_STATUS);
if (!msg_head) {
res = -ENOMEM;
goto nla_put_failure;
}
- res = nla_put_u32(skb_out, HSR_A_IFINDEX, hsr_dev->ifindex);
+ res = nla_put_u32(skb_out, HSR_PRP_A_IFINDEX, hsr_dev->ifindex);
if (res < 0)
goto nla_put_failure;
priv = netdev_priv(hsr_dev);
res = hsr_prp_get_node_data(priv,
(unsigned char *)
- nla_data(info->attrs[HSR_A_NODE_ADDR]),
+ nla_data(info->attrs[HSR_PRP_A_NODE_ADDR]),
node_addr_b,
&addr_b_ifindex,
&hsr_node_if1_age,
@@ -299,45 +301,45 @@ static int hsr_get_node_status(struct sk_buff *skb_in, struct genl_info *info)
if (res < 0)
goto nla_put_failure;
- res = nla_put(skb_out, HSR_A_NODE_ADDR, ETH_ALEN,
- nla_data(info->attrs[HSR_A_NODE_ADDR]));
+ res = nla_put(skb_out, HSR_PRP_A_NODE_ADDR, ETH_ALEN,
+ nla_data(info->attrs[HSR_PRP_A_NODE_ADDR]));
if (res < 0)
goto nla_put_failure;
if (addr_b_ifindex > -1) {
- res = nla_put(skb_out, HSR_A_NODE_ADDR_B, ETH_ALEN,
+ res = nla_put(skb_out, HSR_PRP_A_NODE_ADDR_B, ETH_ALEN,
node_addr_b);
if (res < 0)
goto nla_put_failure;
- res = nla_put_u32(skb_out, HSR_A_ADDR_B_IFINDEX,
+ res = nla_put_u32(skb_out, HSR_PRP_A_ADDR_B_IFINDEX,
addr_b_ifindex);
if (res < 0)
goto nla_put_failure;
}
- res = nla_put_u32(skb_out, HSR_A_IF1_AGE, hsr_node_if1_age);
+ res = nla_put_u32(skb_out, HSR_PRP_A_IF1_AGE, hsr_node_if1_age);
if (res < 0)
goto nla_put_failure;
- res = nla_put_u16(skb_out, HSR_A_IF1_SEQ, hsr_node_if1_seq);
+ res = nla_put_u16(skb_out, HSR_PRP_A_IF1_SEQ, hsr_node_if1_seq);
if (res < 0)
goto nla_put_failure;
port = hsr_prp_get_port(priv, HSR_PRP_PT_SLAVE_A);
if (port)
- res = nla_put_u32(skb_out, HSR_A_IF1_IFINDEX,
+ res = nla_put_u32(skb_out, HSR_PRP_A_IF1_IFINDEX,
port->dev->ifindex);
if (res < 0)
goto nla_put_failure;
- res = nla_put_u32(skb_out, HSR_A_IF2_AGE, hsr_node_if2_age);
+ res = nla_put_u32(skb_out, HSR_PRP_A_IF2_AGE, hsr_node_if2_age);
if (res < 0)
goto nla_put_failure;
- res = nla_put_u16(skb_out, HSR_A_IF2_SEQ, hsr_node_if2_seq);
+ res = nla_put_u16(skb_out, HSR_PRP_A_IF2_SEQ, hsr_node_if2_seq);
if (res < 0)
goto nla_put_failure;
port = hsr_prp_get_port(priv, HSR_PRP_PT_SLAVE_B);
if (port)
- res = nla_put_u32(skb_out, HSR_A_IF2_IFINDEX,
+ res = nla_put_u32(skb_out, HSR_PRP_A_IF2_IFINDEX,
port->dev->ifindex);
if (res < 0)
goto nla_put_failure;
@@ -381,13 +383,14 @@ static int hsr_get_node_list(struct sk_buff *skb_in, struct genl_info *info)
if (!info)
goto invalid;
- na = info->attrs[HSR_A_IFINDEX];
+ na = info->attrs[HSR_PRP_A_IFINDEX];
if (!na)
goto invalid;
rcu_read_lock();
- hsr_dev = dev_get_by_index_rcu(genl_info_net(info),
- nla_get_u32(info->attrs[HSR_A_IFINDEX]));
+ hsr_dev =
+ dev_get_by_index_rcu(genl_info_net(info),
+ nla_get_u32(info->attrs[HSR_PRP_A_IFINDEX]));
if (!hsr_dev)
goto rcu_unlock;
if (!is_hsr_prp_master(hsr_dev))
@@ -403,14 +406,14 @@ static int hsr_get_node_list(struct sk_buff *skb_in, struct genl_info *info)
msg_head = genlmsg_put(skb_out, NETLINK_CB(skb_in).portid,
info->snd_seq, &hsr_genl_family, 0,
- HSR_C_SET_NODE_LIST);
+ HSR_PRP_C_SET_NODE_LIST);
if (!msg_head) {
res = -ENOMEM;
goto nla_put_failure;
}
if (!restart) {
- res = nla_put_u32(skb_out, HSR_A_IFINDEX, hsr_dev->ifindex);
+ res = nla_put_u32(skb_out, HSR_PRP_A_IFINDEX, hsr_dev->ifindex);
if (res < 0)
goto nla_put_failure;
}
@@ -420,7 +423,7 @@ static int hsr_get_node_list(struct sk_buff *skb_in, struct genl_info *info)
if (!pos)
pos = hsr_prp_get_next_node(priv, NULL, addr);
while (pos) {
- res = nla_put(skb_out, HSR_A_NODE_ADDR, ETH_ALEN, addr);
+ res = nla_put(skb_out, HSR_PRP_A_NODE_ADDR, ETH_ALEN, addr);
if (res < 0) {
if (res == -EMSGSIZE) {
genlmsg_end(skb_out, msg_head);
@@ -457,14 +460,14 @@ static int hsr_get_node_list(struct sk_buff *skb_in, struct genl_info *info)
static const struct genl_ops hsr_ops[] = {
{
- .cmd = HSR_C_GET_NODE_STATUS,
+ .cmd = HSR_PRP_C_GET_NODE_STATUS,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
.flags = 0,
.doit = hsr_get_node_status,
.dumpit = NULL,
},
{
- .cmd = HSR_C_GET_NODE_LIST,
+ .cmd = HSR_PRP_C_GET_NODE_LIST,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
.flags = 0,
.doit = hsr_get_node_list,
@@ -476,7 +479,7 @@ static struct genl_family hsr_genl_family __ro_after_init = {
.hdrsize = 0,
.name = "HSR",
.version = 1,
- .maxattr = HSR_A_MAX,
+ .maxattr = HSR_PRP_A_MAX,
.policy = hsr_genl_policy,
.netnsok = true,
.module = THIS_MODULE,
diff --git a/net/hsr-prp/hsr_netlink.h b/net/hsr-prp/hsr_netlink.h
index ae7a1c0de80d..df3d1acb08e0 100644
--- a/net/hsr-prp/hsr_netlink.h
+++ b/net/hsr-prp/hsr_netlink.h
@@ -10,7 +10,7 @@
#include <linux/if_ether.h>
#include <linux/module.h>
-#include <uapi/linux/hsr_netlink.h>
+#include <uapi/linux/hsr_prp_netlink.h>
struct hsr_prp_priv;
struct hsr_prp_port;
--
2.17.1
As PRP implementation expect to re-use code from HSR driver, rename
the existing files that can be re-used with a hsr_prp prefix.
Signed-off-by: Murali Karicheri <[email protected]>
---
net/hsr-prp/Makefile | 11 ++++++-----
net/hsr-prp/hsr_netlink.c | 6 +++---
net/hsr-prp/{hsr_debugfs.c => hsr_prp_debugfs.c} | 6 +++---
net/hsr-prp/{hsr_device.c => hsr_prp_device.c} | 10 +++++-----
net/hsr-prp/{hsr_device.h => hsr_prp_device.h} | 2 +-
net/hsr-prp/{hsr_forward.c => hsr_prp_forward.c} | 6 +++---
net/hsr-prp/{hsr_forward.h => hsr_prp_forward.h} | 2 +-
net/hsr-prp/{hsr_framereg.c => hsr_prp_framereg.c} | 4 ++--
net/hsr-prp/{hsr_framereg.h => hsr_prp_framereg.h} | 2 +-
net/hsr-prp/{hsr_main.c => hsr_prp_main.c} | 8 ++++----
net/hsr-prp/{hsr_main.h => hsr_prp_main.h} | 0
net/hsr-prp/{hsr_slave.c => hsr_prp_slave.c} | 10 +++++-----
net/hsr-prp/{hsr_slave.h => hsr_prp_slave.h} | 2 +-
13 files changed, 35 insertions(+), 34 deletions(-)
rename net/hsr-prp/{hsr_debugfs.c => hsr_prp_debugfs.c} (97%)
rename net/hsr-prp/{hsr_device.c => hsr_prp_device.c} (98%)
rename net/hsr-prp/{hsr_device.h => hsr_prp_device.h} (96%)
rename net/hsr-prp/{hsr_forward.c => hsr_prp_forward.c} (99%)
rename net/hsr-prp/{hsr_forward.h => hsr_prp_forward.h} (92%)
rename net/hsr-prp/{hsr_framereg.c => hsr_prp_framereg.c} (99%)
rename net/hsr-prp/{hsr_framereg.h => hsr_prp_framereg.h} (98%)
rename net/hsr-prp/{hsr_main.c => hsr_prp_main.c} (96%)
rename net/hsr-prp/{hsr_main.h => hsr_prp_main.h} (100%)
rename net/hsr-prp/{hsr_slave.c => hsr_prp_slave.c} (96%)
rename net/hsr-prp/{hsr_slave.h => hsr_prp_slave.h} (97%)
diff --git a/net/hsr-prp/Makefile b/net/hsr-prp/Makefile
index fd207c1a0854..608045f088a4 100644
--- a/net/hsr-prp/Makefile
+++ b/net/hsr-prp/Makefile
@@ -1,10 +1,11 @@
# SPDX-License-Identifier: GPL-2.0-only
#
-# Makefile for HSR
+# Makefile for HSR & PRP
#
-obj-$(CONFIG_HSR_PRP) += hsr.o
+obj-$(CONFIG_HSR_PRP) += hsr-prp.o
-hsr-y := hsr_main.o hsr_framereg.o hsr_device.o \
- hsr_netlink.o hsr_slave.o hsr_forward.o
-hsr-$(CONFIG_DEBUG_FS) += hsr_debugfs.o
+hsr-prp-y := hsr_prp_main.o hsr_prp_framereg.o \
+ hsr_prp_device.o hsr_netlink.o hsr_prp_slave.o \
+ hsr_prp_forward.o
+hsr-prp-$(CONFIG_DEBUG_FS) += hsr_prp_debugfs.o
diff --git a/net/hsr-prp/hsr_netlink.c b/net/hsr-prp/hsr_netlink.c
index 1decb25f6764..9791d4d89aef 100644
--- a/net/hsr-prp/hsr_netlink.c
+++ b/net/hsr-prp/hsr_netlink.c
@@ -11,9 +11,9 @@
#include <linux/kernel.h>
#include <net/rtnetlink.h>
#include <net/genetlink.h>
-#include "hsr_main.h"
-#include "hsr_device.h"
-#include "hsr_framereg.h"
+#include "hsr_prp_main.h"
+#include "hsr_prp_device.h"
+#include "hsr_prp_framereg.h"
static const struct nla_policy hsr_policy[IFLA_HSR_MAX + 1] = {
[IFLA_HSR_SLAVE1] = { .type = NLA_U32 },
diff --git a/net/hsr-prp/hsr_debugfs.c b/net/hsr-prp/hsr_prp_debugfs.c
similarity index 97%
rename from net/hsr-prp/hsr_debugfs.c
rename to net/hsr-prp/hsr_prp_debugfs.c
index 9787ef11ca71..d37b44082e92 100644
--- a/net/hsr-prp/hsr_debugfs.c
+++ b/net/hsr-prp/hsr_prp_debugfs.c
@@ -1,5 +1,5 @@
/*
- * hsr_debugfs code
+ * hsr_prp_debugfs code
* Copyright (C) 2019 Texas Instruments Incorporated
*
* Author(s):
@@ -17,8 +17,8 @@
#include <linux/module.h>
#include <linux/errno.h>
#include <linux/debugfs.h>
-#include "hsr_main.h"
-#include "hsr_framereg.h"
+#include "hsr_prp_main.h"
+#include "hsr_prp_framereg.h"
static struct dentry *hsr_debugfs_root_dir;
diff --git a/net/hsr-prp/hsr_device.c b/net/hsr-prp/hsr_prp_device.c
similarity index 98%
rename from net/hsr-prp/hsr_device.c
rename to net/hsr-prp/hsr_prp_device.c
index cd99f548e440..ed50022849cb 100644
--- a/net/hsr-prp/hsr_device.c
+++ b/net/hsr-prp/hsr_prp_device.c
@@ -13,11 +13,11 @@
#include <linux/etherdevice.h>
#include <linux/rtnetlink.h>
#include <linux/pkt_sched.h>
-#include "hsr_device.h"
-#include "hsr_slave.h"
-#include "hsr_framereg.h"
-#include "hsr_main.h"
-#include "hsr_forward.h"
+#include "hsr_prp_device.h"
+#include "hsr_prp_slave.h"
+#include "hsr_prp_framereg.h"
+#include "hsr_prp_main.h"
+#include "hsr_prp_forward.h"
static bool is_admin_up(struct net_device *dev)
{
diff --git a/net/hsr-prp/hsr_device.h b/net/hsr-prp/hsr_prp_device.h
similarity index 96%
rename from net/hsr-prp/hsr_device.h
rename to net/hsr-prp/hsr_prp_device.h
index a099d7de7e79..4cf3db603174 100644
--- a/net/hsr-prp/hsr_device.h
+++ b/net/hsr-prp/hsr_prp_device.h
@@ -9,7 +9,7 @@
#define __HSR_DEVICE_H
#include <linux/netdevice.h>
-#include "hsr_main.h"
+#include "hsr_prp_main.h"
void hsr_dev_setup(struct net_device *dev);
int hsr_dev_finalize(struct net_device *hsr_dev, struct net_device *slave[2],
diff --git a/net/hsr-prp/hsr_forward.c b/net/hsr-prp/hsr_prp_forward.c
similarity index 99%
rename from net/hsr-prp/hsr_forward.c
rename to net/hsr-prp/hsr_prp_forward.c
index ddd9605bad04..5ff0efba5db5 100644
--- a/net/hsr-prp/hsr_forward.c
+++ b/net/hsr-prp/hsr_prp_forward.c
@@ -5,13 +5,13 @@
* 2011-2014 Arvid Brodin, [email protected]
*/
-#include "hsr_forward.h"
+#include "hsr_prp_forward.h"
#include <linux/types.h>
#include <linux/skbuff.h>
#include <linux/etherdevice.h>
#include <linux/if_vlan.h>
-#include "hsr_main.h"
-#include "hsr_framereg.h"
+#include "hsr_prp_main.h"
+#include "hsr_prp_framereg.h"
struct hsr_node;
diff --git a/net/hsr-prp/hsr_forward.h b/net/hsr-prp/hsr_prp_forward.h
similarity index 92%
rename from net/hsr-prp/hsr_forward.h
rename to net/hsr-prp/hsr_prp_forward.h
index 51a69295566c..cbc0704cc14a 100644
--- a/net/hsr-prp/hsr_forward.h
+++ b/net/hsr-prp/hsr_prp_forward.h
@@ -9,7 +9,7 @@
#define __HSR_FORWARD_H
#include <linux/netdevice.h>
-#include "hsr_main.h"
+#include "hsr_prp_main.h"
void hsr_forward_skb(struct sk_buff *skb, struct hsr_port *port);
diff --git a/net/hsr-prp/hsr_framereg.c b/net/hsr-prp/hsr_prp_framereg.c
similarity index 99%
rename from net/hsr-prp/hsr_framereg.c
rename to net/hsr-prp/hsr_prp_framereg.c
index 03b891904314..b02a2a0ca0ff 100644
--- a/net/hsr-prp/hsr_framereg.c
+++ b/net/hsr-prp/hsr_prp_framereg.c
@@ -14,8 +14,8 @@
#include <linux/etherdevice.h>
#include <linux/slab.h>
#include <linux/rculist.h>
-#include "hsr_main.h"
-#include "hsr_framereg.h"
+#include "hsr_prp_main.h"
+#include "hsr_prp_framereg.h"
#include "hsr_netlink.h"
/* TODO: use hash lists for mac addresses (linux/jhash.h)? */
diff --git a/net/hsr-prp/hsr_framereg.h b/net/hsr-prp/hsr_prp_framereg.h
similarity index 98%
rename from net/hsr-prp/hsr_framereg.h
rename to net/hsr-prp/hsr_prp_framereg.h
index 0f0fa12b4329..c7a2a975aca0 100644
--- a/net/hsr-prp/hsr_framereg.h
+++ b/net/hsr-prp/hsr_prp_framereg.h
@@ -8,7 +8,7 @@
#ifndef __HSR_FRAMEREG_H
#define __HSR_FRAMEREG_H
-#include "hsr_main.h"
+#include "hsr_prp_main.h"
struct hsr_node;
diff --git a/net/hsr-prp/hsr_main.c b/net/hsr-prp/hsr_prp_main.c
similarity index 96%
rename from net/hsr-prp/hsr_main.c
rename to net/hsr-prp/hsr_prp_main.c
index e2564de67603..d0b7117bf5f9 100644
--- a/net/hsr-prp/hsr_main.c
+++ b/net/hsr-prp/hsr_prp_main.c
@@ -9,11 +9,11 @@
#include <linux/rculist.h>
#include <linux/timer.h>
#include <linux/etherdevice.h>
-#include "hsr_main.h"
-#include "hsr_device.h"
+#include "hsr_prp_main.h"
+#include "hsr_prp_device.h"
#include "hsr_netlink.h"
-#include "hsr_framereg.h"
-#include "hsr_slave.h"
+#include "hsr_prp_framereg.h"
+#include "hsr_prp_slave.h"
static bool hsr_slave_empty(struct hsr_priv *hsr)
{
diff --git a/net/hsr-prp/hsr_main.h b/net/hsr-prp/hsr_prp_main.h
similarity index 100%
rename from net/hsr-prp/hsr_main.h
rename to net/hsr-prp/hsr_prp_main.h
diff --git a/net/hsr-prp/hsr_slave.c b/net/hsr-prp/hsr_prp_slave.c
similarity index 96%
rename from net/hsr-prp/hsr_slave.c
rename to net/hsr-prp/hsr_prp_slave.c
index 25b6ffba26cd..fad8fef783cc 100644
--- a/net/hsr-prp/hsr_slave.c
+++ b/net/hsr-prp/hsr_prp_slave.c
@@ -5,14 +5,14 @@
* 2011-2014 Arvid Brodin, [email protected]
*/
-#include "hsr_slave.h"
+#include "hsr_prp_slave.h"
#include <linux/etherdevice.h>
#include <linux/if_arp.h>
#include <linux/if_vlan.h>
-#include "hsr_main.h"
-#include "hsr_device.h"
-#include "hsr_forward.h"
-#include "hsr_framereg.h"
+#include "hsr_prp_main.h"
+#include "hsr_prp_device.h"
+#include "hsr_prp_forward.h"
+#include "hsr_prp_framereg.h"
static rx_handler_result_t hsr_handle_frame(struct sk_buff **pskb)
{
diff --git a/net/hsr-prp/hsr_slave.h b/net/hsr-prp/hsr_prp_slave.h
similarity index 97%
rename from net/hsr-prp/hsr_slave.h
rename to net/hsr-prp/hsr_prp_slave.h
index 8953ea279ce9..c0360b111151 100644
--- a/net/hsr-prp/hsr_slave.h
+++ b/net/hsr-prp/hsr_prp_slave.h
@@ -10,7 +10,7 @@
#include <linux/skbuff.h>
#include <linux/netdevice.h>
#include <linux/rtnetlink.h>
-#include "hsr_main.h"
+#include "hsr_prp_main.h"
int hsr_add_port(struct hsr_priv *hsr, struct net_device *dev,
enum hsr_port_type pt, struct netlink_ext_ack *extack);
--
2.17.1
As prp driver is expected to re-use code from HSR driver,
rename the directory to net/hsr-prp as a preparatory step.
Signed-off-by: Murali Karicheri <[email protected]>
---
MAINTAINERS | 2 +-
net/Kconfig | 2 +-
net/Makefile | 2 +-
net/{hsr => hsr-prp}/Kconfig | 0
net/{hsr => hsr-prp}/Makefile | 0
net/{hsr => hsr-prp}/hsr_debugfs.c | 0
net/{hsr => hsr-prp}/hsr_device.c | 0
net/{hsr => hsr-prp}/hsr_device.h | 0
net/{hsr => hsr-prp}/hsr_forward.c | 0
net/{hsr => hsr-prp}/hsr_forward.h | 0
net/{hsr => hsr-prp}/hsr_framereg.c | 0
net/{hsr => hsr-prp}/hsr_framereg.h | 0
net/{hsr => hsr-prp}/hsr_main.c | 0
net/{hsr => hsr-prp}/hsr_main.h | 0
net/{hsr => hsr-prp}/hsr_netlink.c | 0
net/{hsr => hsr-prp}/hsr_netlink.h | 0
net/{hsr => hsr-prp}/hsr_slave.c | 0
net/{hsr => hsr-prp}/hsr_slave.h | 0
18 files changed, 3 insertions(+), 3 deletions(-)
rename net/{hsr => hsr-prp}/Kconfig (100%)
rename net/{hsr => hsr-prp}/Makefile (100%)
rename net/{hsr => hsr-prp}/hsr_debugfs.c (100%)
rename net/{hsr => hsr-prp}/hsr_device.c (100%)
rename net/{hsr => hsr-prp}/hsr_device.h (100%)
rename net/{hsr => hsr-prp}/hsr_forward.c (100%)
rename net/{hsr => hsr-prp}/hsr_forward.h (100%)
rename net/{hsr => hsr-prp}/hsr_framereg.c (100%)
rename net/{hsr => hsr-prp}/hsr_framereg.h (100%)
rename net/{hsr => hsr-prp}/hsr_main.c (100%)
rename net/{hsr => hsr-prp}/hsr_main.h (100%)
rename net/{hsr => hsr-prp}/hsr_netlink.c (100%)
rename net/{hsr => hsr-prp}/hsr_netlink.h (100%)
rename net/{hsr => hsr-prp}/hsr_slave.c (100%)
rename net/{hsr => hsr-prp}/hsr_slave.h (100%)
diff --git a/MAINTAINERS b/MAINTAINERS
index db7a6d462dff..94d357145f81 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -7789,7 +7789,7 @@ F: drivers/net/usb/hso.c
HSR NETWORK PROTOCOL
L: [email protected]
S: Orphan
-F: net/hsr/
+F: net/hsr-prp/
HT16K33 LED CONTROLLER DRIVER
M: Robin van der Gracht <[email protected]>
diff --git a/net/Kconfig b/net/Kconfig
index c5ba2d180c43..20216973d25f 100644
--- a/net/Kconfig
+++ b/net/Kconfig
@@ -239,7 +239,7 @@ source "net/vmw_vsock/Kconfig"
source "net/netlink/Kconfig"
source "net/mpls/Kconfig"
source "net/nsh/Kconfig"
-source "net/hsr/Kconfig"
+source "net/hsr-prp/Kconfig"
source "net/switchdev/Kconfig"
source "net/l3mdev/Kconfig"
source "net/qrtr/Kconfig"
diff --git a/net/Makefile b/net/Makefile
index 4f1c6a44f2c3..cab7e4071f42 100644
--- a/net/Makefile
+++ b/net/Makefile
@@ -77,7 +77,7 @@ obj-$(CONFIG_OPENVSWITCH) += openvswitch/
obj-$(CONFIG_VSOCKETS) += vmw_vsock/
obj-$(CONFIG_MPLS) += mpls/
obj-$(CONFIG_NET_NSH) += nsh/
-obj-$(CONFIG_HSR_PRP) += hsr/
+obj-$(CONFIG_HSR_PRP) += hsr-prp/
ifneq ($(CONFIG_NET_SWITCHDEV),)
obj-y += switchdev/
endif
diff --git a/net/hsr/Kconfig b/net/hsr-prp/Kconfig
similarity index 100%
rename from net/hsr/Kconfig
rename to net/hsr-prp/Kconfig
diff --git a/net/hsr/Makefile b/net/hsr-prp/Makefile
similarity index 100%
rename from net/hsr/Makefile
rename to net/hsr-prp/Makefile
diff --git a/net/hsr/hsr_debugfs.c b/net/hsr-prp/hsr_debugfs.c
similarity index 100%
rename from net/hsr/hsr_debugfs.c
rename to net/hsr-prp/hsr_debugfs.c
diff --git a/net/hsr/hsr_device.c b/net/hsr-prp/hsr_device.c
similarity index 100%
rename from net/hsr/hsr_device.c
rename to net/hsr-prp/hsr_device.c
diff --git a/net/hsr/hsr_device.h b/net/hsr-prp/hsr_device.h
similarity index 100%
rename from net/hsr/hsr_device.h
rename to net/hsr-prp/hsr_device.h
diff --git a/net/hsr/hsr_forward.c b/net/hsr-prp/hsr_forward.c
similarity index 100%
rename from net/hsr/hsr_forward.c
rename to net/hsr-prp/hsr_forward.c
diff --git a/net/hsr/hsr_forward.h b/net/hsr-prp/hsr_forward.h
similarity index 100%
rename from net/hsr/hsr_forward.h
rename to net/hsr-prp/hsr_forward.h
diff --git a/net/hsr/hsr_framereg.c b/net/hsr-prp/hsr_framereg.c
similarity index 100%
rename from net/hsr/hsr_framereg.c
rename to net/hsr-prp/hsr_framereg.c
diff --git a/net/hsr/hsr_framereg.h b/net/hsr-prp/hsr_framereg.h
similarity index 100%
rename from net/hsr/hsr_framereg.h
rename to net/hsr-prp/hsr_framereg.h
diff --git a/net/hsr/hsr_main.c b/net/hsr-prp/hsr_main.c
similarity index 100%
rename from net/hsr/hsr_main.c
rename to net/hsr-prp/hsr_main.c
diff --git a/net/hsr/hsr_main.h b/net/hsr-prp/hsr_main.h
similarity index 100%
rename from net/hsr/hsr_main.h
rename to net/hsr-prp/hsr_main.h
diff --git a/net/hsr/hsr_netlink.c b/net/hsr-prp/hsr_netlink.c
similarity index 100%
rename from net/hsr/hsr_netlink.c
rename to net/hsr-prp/hsr_netlink.c
diff --git a/net/hsr/hsr_netlink.h b/net/hsr-prp/hsr_netlink.h
similarity index 100%
rename from net/hsr/hsr_netlink.h
rename to net/hsr-prp/hsr_netlink.h
diff --git a/net/hsr/hsr_slave.c b/net/hsr-prp/hsr_slave.c
similarity index 100%
rename from net/hsr/hsr_slave.c
rename to net/hsr-prp/hsr_slave.c
diff --git a/net/hsr/hsr_slave.h b/net/hsr-prp/hsr_slave.h
similarity index 100%
rename from net/hsr/hsr_slave.h
rename to net/hsr-prp/hsr_slave.h
--
2.17.1
hsr_port_get_hsr() actually gets port struct ptr from the priv. So
rename it to reflect the same. hsr_prp prefix is chosen as this
can be re-used for PRP driver as well.
Signed-off-by: Murali Karicheri <[email protected]>
---
net/hsr-prp/hsr_netlink.c | 12 ++++++------
net/hsr-prp/hsr_prp_device.c | 14 +++++++-------
net/hsr-prp/hsr_prp_framereg.c | 10 +++++-----
net/hsr-prp/hsr_prp_main.c | 12 ++++++------
net/hsr-prp/hsr_prp_main.h | 2 +-
net/hsr-prp/hsr_prp_slave.c | 8 ++++----
6 files changed, 29 insertions(+), 29 deletions(-)
diff --git a/net/hsr-prp/hsr_netlink.c b/net/hsr-prp/hsr_netlink.c
index 9e3f6eda69f5..727b5dc9f31b 100644
--- a/net/hsr-prp/hsr_netlink.c
+++ b/net/hsr-prp/hsr_netlink.c
@@ -88,13 +88,13 @@ static int hsr_fill_info(struct sk_buff *skb, const struct net_device *dev)
struct hsr_priv *priv = netdev_priv(dev);
struct hsr_port *port;
- port = hsr_port_get_hsr(priv, HSR_PT_SLAVE_A);
+ port = hsr_prp_get_port(priv, HSR_PT_SLAVE_A);
if (port) {
if (nla_put_u32(skb, IFLA_HSR_SLAVE1, port->dev->ifindex))
goto nla_put_failure;
}
- port = hsr_port_get_hsr(priv, HSR_PT_SLAVE_B);
+ port = hsr_prp_get_port(priv, HSR_PT_SLAVE_B);
if (port) {
if (nla_put_u32(skb, IFLA_HSR_SLAVE2, port->dev->ifindex))
goto nla_put_failure;
@@ -177,7 +177,7 @@ void hsr_nl_ringerror(struct hsr_priv *priv, unsigned char addr[ETH_ALEN],
fail:
rcu_read_lock();
- master = hsr_port_get_hsr(priv, HSR_PT_MASTER);
+ master = hsr_prp_get_port(priv, HSR_PT_MASTER);
netdev_warn(master->dev, "Could not send HSR ring error message\n");
rcu_read_unlock();
}
@@ -214,7 +214,7 @@ void hsr_nl_nodedown(struct hsr_priv *priv, unsigned char addr[ETH_ALEN])
fail:
rcu_read_lock();
- master = hsr_port_get_hsr(priv, HSR_PT_MASTER);
+ master = hsr_prp_get_port(priv, HSR_PT_MASTER);
netdev_warn(master->dev, "Could not send HSR node down\n");
rcu_read_unlock();
}
@@ -319,7 +319,7 @@ 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);
if (res < 0)
goto nla_put_failure;
- port = hsr_port_get_hsr(priv, HSR_PT_SLAVE_A);
+ port = hsr_prp_get_port(priv, HSR_PT_SLAVE_A);
if (port)
res = nla_put_u32(skb_out, HSR_A_IF1_IFINDEX,
port->dev->ifindex);
@@ -332,7 +332,7 @@ 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);
if (res < 0)
goto nla_put_failure;
- port = hsr_port_get_hsr(priv, HSR_PT_SLAVE_B);
+ port = hsr_prp_get_port(priv, HSR_PT_SLAVE_B);
if (port)
res = nla_put_u32(skb_out, HSR_A_IF2_IFINDEX,
port->dev->ifindex);
diff --git a/net/hsr-prp/hsr_prp_device.c b/net/hsr-prp/hsr_prp_device.c
index df85b8f7f007..d8bc9a48b6f2 100644
--- a/net/hsr-prp/hsr_prp_device.c
+++ b/net/hsr-prp/hsr_prp_device.c
@@ -97,7 +97,7 @@ void hsr_check_carrier_and_operstate(struct hsr_priv *priv)
unsigned char old_operstate;
bool has_carrier;
- master = hsr_port_get_hsr(priv, HSR_PT_MASTER);
+ master = hsr_prp_get_port(priv, HSR_PT_MASTER);
/* netif_stacked_transfer_operstate() cannot be used here since
* it doesn't set IF_OPER_LOWERLAYERDOWN (?)
*/
@@ -215,7 +215,7 @@ static int hsr_dev_xmit(struct sk_buff *skb, struct net_device *dev)
struct hsr_priv *priv = netdev_priv(dev);
struct hsr_port *master;
- master = hsr_port_get_hsr(priv, HSR_PT_MASTER);
+ master = hsr_prp_get_port(priv, HSR_PT_MASTER);
if (master) {
skb->dev = master->dev;
hsr_forward_skb(skb, master);
@@ -318,7 +318,7 @@ static void hsr_announce(struct timer_list *t)
priv = from_timer(priv, t, announce_timer);
rcu_read_lock();
- master = hsr_port_get_hsr(priv, HSR_PT_MASTER);
+ master = hsr_prp_get_port(priv, HSR_PT_MASTER);
if (priv->announce_count < 3 && priv->prot_version == 0) {
send_hsr_supervision_frame(master, HSR_TLV_ANNOUNCE,
@@ -343,22 +343,22 @@ static void hsr_del_ports(struct hsr_priv *priv)
{
struct hsr_port *port;
- port = hsr_port_get_hsr(priv, HSR_PT_SLAVE_A);
+ port = hsr_prp_get_port(priv, HSR_PT_SLAVE_A);
if (port)
hsr_del_port(port);
- port = hsr_port_get_hsr(priv, HSR_PT_SLAVE_B);
+ port = hsr_prp_get_port(priv, HSR_PT_SLAVE_B);
if (port)
hsr_del_port(port);
- port = hsr_port_get_hsr(priv, HSR_PT_MASTER);
+ port = hsr_prp_get_port(priv, HSR_PT_MASTER);
if (port)
hsr_del_port(port);
}
/* This has to be called after all the readers are gone.
* Otherwise we would have to check the return value of
- * hsr_port_get_hsr().
+ * hsr_prp_get_port().
*/
static void hsr_dev_destroy(struct net_device *hsr_dev)
{
diff --git a/net/hsr-prp/hsr_prp_framereg.c b/net/hsr-prp/hsr_prp_framereg.c
index 854338352e93..102b0a85f440 100644
--- a/net/hsr-prp/hsr_prp_framereg.c
+++ b/net/hsr-prp/hsr_prp_framereg.c
@@ -364,18 +364,18 @@ static struct hsr_port *get_late_port(struct hsr_priv *priv,
struct hsr_node *node)
{
if (node->time_in_stale[HSR_PT_SLAVE_A])
- return hsr_port_get_hsr(priv, HSR_PT_SLAVE_A);
+ return hsr_prp_get_port(priv, HSR_PT_SLAVE_A);
if (node->time_in_stale[HSR_PT_SLAVE_B])
- return hsr_port_get_hsr(priv, HSR_PT_SLAVE_B);
+ return hsr_prp_get_port(priv, HSR_PT_SLAVE_B);
if (time_after(node->time_in[HSR_PT_SLAVE_B],
node->time_in[HSR_PT_SLAVE_A] +
msecs_to_jiffies(MAX_SLAVE_DIFF)))
- return hsr_port_get_hsr(priv, HSR_PT_SLAVE_A);
+ return hsr_prp_get_port(priv, HSR_PT_SLAVE_A);
if (time_after(node->time_in[HSR_PT_SLAVE_A],
node->time_in[HSR_PT_SLAVE_B] +
msecs_to_jiffies(MAX_SLAVE_DIFF)))
- return hsr_port_get_hsr(priv, HSR_PT_SLAVE_B);
+ return hsr_prp_get_port(priv, HSR_PT_SLAVE_B);
return NULL;
}
@@ -515,7 +515,7 @@ int hsr_get_node_data(struct hsr_priv *priv,
*if2_seq = node->seq_out[HSR_PT_SLAVE_A];
if (node->addr_B_port != HSR_PT_NONE) {
- port = hsr_port_get_hsr(priv, node->addr_B_port);
+ port = hsr_prp_get_port(priv, node->addr_B_port);
*addr_b_ifindex = port->dev->ifindex;
} else {
*addr_b_ifindex = -1;
diff --git a/net/hsr-prp/hsr_prp_main.c b/net/hsr-prp/hsr_prp_main.c
index caa544d0af42..de85f42be6ee 100644
--- a/net/hsr-prp/hsr_prp_main.c
+++ b/net/hsr-prp/hsr_prp_main.c
@@ -41,7 +41,7 @@ static int hsr_netdev_notify(struct notifier_block *nb, unsigned long event,
if (!is_hsr_master(dev))
return NOTIFY_DONE; /* Not an HSR device */
priv = netdev_priv(dev);
- port = hsr_port_get_hsr(priv, HSR_PT_MASTER);
+ port = hsr_prp_get_port(priv, HSR_PT_MASTER);
if (!port) {
/* Resend of notification concerning removed device? */
return NOTIFY_DONE;
@@ -69,7 +69,7 @@ static int hsr_netdev_notify(struct notifier_block *nb, unsigned long event,
break;
}
- master = hsr_port_get_hsr(priv, HSR_PT_MASTER);
+ master = hsr_prp_get_port(priv, HSR_PT_MASTER);
if (port->type == HSR_PT_SLAVE_A) {
ether_addr_copy(master->dev->dev_addr, dev->dev_addr);
@@ -78,7 +78,7 @@ static int hsr_netdev_notify(struct notifier_block *nb, unsigned long event,
}
/* Make sure we recognize frames from ourselves in hsr_rcv() */
- port = hsr_port_get_hsr(priv, HSR_PT_SLAVE_B);
+ port = hsr_prp_get_port(priv, HSR_PT_SLAVE_B);
res = hsr_create_self_node(priv,
master->dev->dev_addr,
port ?
@@ -92,12 +92,12 @@ static int hsr_netdev_notify(struct notifier_block *nb, unsigned long event,
if (port->type == HSR_PT_MASTER)
break; /* Handled in ndo_change_mtu() */
mtu_max = hsr_get_max_mtu(port->priv);
- master = hsr_port_get_hsr(port->priv, HSR_PT_MASTER);
+ master = hsr_prp_get_port(port->priv, HSR_PT_MASTER);
master->dev->mtu = mtu_max;
break;
case NETDEV_UNREGISTER:
if (!is_hsr_master(dev)) {
- master = hsr_port_get_hsr(port->priv, HSR_PT_MASTER);
+ master = hsr_prp_get_port(port->priv, HSR_PT_MASTER);
hsr_del_port(port);
if (hsr_slave_empty(master->priv)) {
unregister_netdevice_queue(master->dev,
@@ -116,7 +116,7 @@ static int hsr_netdev_notify(struct notifier_block *nb, unsigned long event,
return NOTIFY_DONE;
}
-struct hsr_port *hsr_port_get_hsr(struct hsr_priv *priv, enum hsr_port_type pt)
+struct hsr_port *hsr_prp_get_port(struct hsr_priv *priv, enum hsr_port_type pt)
{
struct hsr_port *port;
diff --git a/net/hsr-prp/hsr_prp_main.h b/net/hsr-prp/hsr_prp_main.h
index d11a9f0b696f..5a99d0b12c66 100644
--- a/net/hsr-prp/hsr_prp_main.h
+++ b/net/hsr-prp/hsr_prp_main.h
@@ -153,7 +153,7 @@ struct hsr_priv {
#define hsr_for_each_port(priv, port) \
list_for_each_entry_rcu((port), &(priv)->ports, port_list)
-struct hsr_port *hsr_port_get_hsr(struct hsr_priv *priv, enum hsr_port_type pt);
+struct hsr_port *hsr_prp_get_port(struct hsr_priv *priv, enum hsr_port_type pt);
/* Caller must ensure skb is a valid HSR frame */
static inline u16 hsr_get_skb_sequence_nr(struct sk_buff *skb)
diff --git a/net/hsr-prp/hsr_prp_slave.c b/net/hsr-prp/hsr_prp_slave.c
index 96de8d15db00..2c8832bf7a5f 100644
--- a/net/hsr-prp/hsr_prp_slave.c
+++ b/net/hsr-prp/hsr_prp_slave.c
@@ -110,7 +110,7 @@ static int hsr_portdev_setup(struct hsr_priv *priv, struct net_device *dev,
if (res)
return res;
- master = hsr_port_get_hsr(priv, HSR_PT_MASTER);
+ master = hsr_prp_get_port(priv, HSR_PT_MASTER);
hsr_dev = master->dev;
res = netdev_upper_dev_link(dev, hsr_dev, extack);
@@ -143,7 +143,7 @@ int hsr_add_port(struct hsr_priv *priv, struct net_device *dev,
return res;
}
- port = hsr_port_get_hsr(priv, type);
+ port = hsr_prp_get_port(priv, type);
if (port)
return -EBUSY; /* This port already exists */
@@ -164,7 +164,7 @@ int hsr_add_port(struct hsr_priv *priv, struct net_device *dev,
list_add_tail_rcu(&port->port_list, &priv->ports);
synchronize_rcu();
- master = hsr_port_get_hsr(priv, HSR_PT_MASTER);
+ master = hsr_prp_get_port(priv, HSR_PT_MASTER);
netdev_update_features(master->dev);
dev_set_mtu(master->dev, hsr_get_max_mtu(priv));
@@ -181,7 +181,7 @@ void hsr_del_port(struct hsr_port *port)
struct hsr_port *master;
priv = port->priv;
- master = hsr_port_get_hsr(priv, HSR_PT_MASTER);
+ master = hsr_prp_get_port(priv, HSR_PT_MASTER);
list_del_rcu(&port->port_list);
if (port != master) {
--
2.17.1
Hello netdev experts,
On 5/6/20 12:30 PM, Murali Karicheri wrote:
> This RFC series add support for Parallel Redundancy Protocol (PRP)
> as defined in IEC-62439-3 in the kernel networking subsystem. PRP
> Uses a Redundancy Control Trailer (RCT) the format of which is
> similar to HSR Tag. This is used for implementing redundancy.
> RCT consists of 6 bytes similar to HSR tag and contain following
> fields:-
>
> - 16-bit sequence number (SeqNr);
> - 4-bit LAN identifier (LanId);
> - 12 bit frame size (LSDUsize);
> - 16-bit suffix (PRPsuffix).
>
> The PRPsuffix identifies PRP frames and distinguishes PRP frames
> from other protocols that also append a trailer to their useful
> data. The LSDUsize field allows the receiver to distinguish PRP
> frames from random, nonredundant frames as an additional check.
> LSDUsize is the size of the Ethernet payload inclusive of the
> RCT. Sequence number along with LanId is used for duplicate
> detection and discard.
>
> PRP node is also known as Dual Attached Node (DAN-P) since it
> is typically attached to two different LAN for redundancy.
> DAN-P duplicates each of L2 frames and send it over the two
> Ethernet links. Each outgoing frame is appended with RCT.
> Unlike HSR, these are added to the end of L2 frame and may be
> treated as padding by bridges and therefore would be work with
> traditional bridges or switches, where as HSR wouldn't as Tag
> is prefixed to the Ethenet frame. At the remote end, these are
> received and the duplicate frame is discarded before the stripped
> frame is send up the networking stack. Like HSR, PRP also sends
> periodic Supervision frames to the network. These frames are
> received and MAC address from the SV frames are populated in a
> database called Node Table. The above functions are grouped into
> a block called Link Redundancy Entity (LRE) in the IEC spec.
>
> As there are many similarities between HSR and PRP protocols,
> this patch re-use the code from HSR driver to implement PRP
> driver. As many part of the code can be re-used, this patch
> introduces a new common API definitions for both protocols and
> propose to obsolete the existing HSR defines in
> include/uapi/linux/if_link.h. New definitions are prefixed
> with a HSR_PRP prefix. Similarly include/uapi/linux/hsr_netlink.h
> is proposed to be replaced with include/uapi/linux/hsr_prp_netlink.h
> which also uses the HSR_PRP prefix. The netlink socket interface
> code is migrated (as well as the iproute2 being sent as a follow up
> patch) to use the new API definitions. To re-use the code,
> following are done as a preparatory patch before adding the PRP
> functionality:-
>
> - prefix all common code with hsr_prp
> - net/hsr -> renamed to net/hsr-prp
> - All common struct types, constants, functions renamed with
> hsr{HSR}_prp{PRP} prefix.
>
> Please review this and provide me feedback so that I can work to
> incorporate them and send a formal patch series for this. As this
> series impacts user space, I am not sure if this is the right
> approach to introduce a new definitions and obsolete the old
> API definitions for HSR. The current approach is choosen
> to avoid redundant code in iproute2 and in the netlink driver
> code (hsr_netlink.c). Other approach we discussed internally was
> to Keep the HSR prefix in the user space and kernel code, but
> live with the redundant code in the iproute2 and hsr netlink
> code. Would like to hear from you what is the best way to add
> this feature to networking core. If there is any other
> alternative approach possible, I would like to hear about the
> same.
>
> The patch was tested using two TI AM57x IDK boards which are
> connected back to back over two CPSW ports.
>
> Script used for creating the hsr/prp interface is given below
> and uses the ip link command. Also provided logs from the tests
> I have executed for your reference.
>
> iproute2 related patches will follow soon....
Could someone please review this and provide some feedback to take
this forward?
Thanks and regards,
>
> Murali Karicheri
> Texas Instruments
-Cut-------------------------
Hi David, et all,
On 5/13/20 8:27 AM, Murali Karicheri wrote:
> Hello netdev experts,
>
> On 5/6/20 12:30 PM, Murali Karicheri wrote:
>> This RFC series add support for Parallel Redundancy Protocol (PRP)
>> as defined in IEC-62439-3 in the kernel networking subsystem. PRP
>> Uses a Redundancy Control Trailer (RCT) the format of which is
>> similar to HSR Tag. This is used for implementing redundancy.
>> RCT consists of 6 bytes similar to HSR tag and contain following
>> fields:-
>>
>> - 16-bit sequence number (SeqNr);
>> - 4-bit LAN identifier (LanId);
>> - 12 bit frame size (LSDUsize);
>> - 16-bit suffix (PRPsuffix).
>>
>> The PRPsuffix identifies PRP frames and distinguishes PRP frames
>> from other protocols that also append a trailer to their useful
>> data. The LSDUsize field allows the receiver to distinguish PRP
>> frames from random, nonredundant frames as an additional check.
>> LSDUsize is the size of the Ethernet payload inclusive of the
>> RCT. Sequence number along with LanId is used for duplicate
>> detection and discard.
>>
>> PRP node is also known as Dual Attached Node (DAN-P) since it
>> is typically attached to two different LAN for redundancy.
>> DAN-P duplicates each of L2 frames and send it over the two
>> Ethernet links. Each outgoing frame is appended with RCT.
>> Unlike HSR, these are added to the end of L2 frame and may be
>> treated as padding by bridges and therefore would be work with
>> traditional bridges or switches, where as HSR wouldn't as Tag
>> is prefixed to the Ethenet frame. At the remote end, these are
>> received and the duplicate frame is discarded before the stripped
>> frame is send up the networking stack. Like HSR, PRP also sends
>> periodic Supervision frames to the network. These frames are
>> received and MAC address from the SV frames are populated in a
>> database called Node Table. The above functions are grouped into
>> a block called Link Redundancy Entity (LRE) in the IEC spec.
>>
>> As there are many similarities between HSR and PRP protocols,
>> this patch re-use the code from HSR driver to implement PRP
>> driver. As many part of the code can be re-used, this patch
>> introduces a new common API definitions for both protocols and
>> propose to obsolete the existing HSR defines in
>> include/uapi/linux/if_link.h. New definitions are prefixed
>> with a HSR_PRP prefix. Similarly include/uapi/linux/hsr_netlink.h
>> is proposed to be replaced with include/uapi/linux/hsr_prp_netlink.h
>> which also uses the HSR_PRP prefix. The netlink socket interface
>> code is migrated (as well as the iproute2 being sent as a follow up
>> patch) to use the new API definitions. To re-use the code,
>> following are done as a preparatory patch before adding the PRP
>> functionality:-
>>
>> Â Â - prefix all common code with hsr_prp
>> Â Â - net/hsr -> renamed to net/hsr-prp
>> Â Â - All common struct types, constants, functions renamed with
>> Â Â Â Â hsr{HSR}_prp{PRP} prefix.
>>
>> Please review this and provide me feedback so that I can work to
>> incorporate them and send a formal patch series for this. As this
>> series impacts user space, I am not sure if this is the right
>> approach to introduce a new definitions and obsolete the old
>> API definitions for HSR. The current approach is choosen
>> to avoid redundant code in iproute2 and in the netlink driver
>> code (hsr_netlink.c). Other approach we discussed internally was
>> to Keep the HSR prefix in the user space and kernel code, but
>> live with the redundant code in the iproute2 and hsr netlink
>> code. Would like to hear from you what is the best way to add
>> this feature to networking core. If there is any other
>> alternative approach possible, I would like to hear about the
>> same.
>>
>> The patch was tested using two TI AM57x IDK boards which are
>> connected back to back over two CPSW ports.
>>
>> Script used for creating the hsr/prp interface is given below
>> and uses the ip link command. Also provided logs from the tests
>> I have executed for your reference.
>>
>> iproute2 related patches will follow soon....
> Could someone please review this and provide some feedback to take
> this forward?
>
> Thanks and regards,
>>
>> Murali Karicheri
>> Texas Instruments
>
>
> -Cut-------------------------
I plan to send a formal patch early next week as we would like to move
forward with this series. So please take some high level look at this
and guide me if I am on the right track or this requires rework for
a formal patch.
--
Murali Karicheri
Texas Instruments
Murali Karicheri <[email protected]> writes:
> This RFC series add support for Parallel Redundancy Protocol (PRP)
> as defined in IEC-62439-3 in the kernel networking subsystem. PRP
> Uses a Redundancy Control Trailer (RCT) the format of which is
> similar to HSR Tag. This is used for implementing redundancy.
> RCT consists of 6 bytes similar to HSR tag and contain following
> fields:-
>
> - 16-bit sequence number (SeqNr);
> - 4-bit LAN identifier (LanId);
> - 12 bit frame size (LSDUsize);
> - 16-bit suffix (PRPsuffix).
>
> The PRPsuffix identifies PRP frames and distinguishes PRP frames
> from other protocols that also append a trailer to their useful
> data. The LSDUsize field allows the receiver to distinguish PRP
> frames from random, nonredundant frames as an additional check.
> LSDUsize is the size of the Ethernet payload inclusive of the
> RCT. Sequence number along with LanId is used for duplicate
> detection and discard.
>
> PRP node is also known as Dual Attached Node (DAN-P) since it
> is typically attached to two different LAN for redundancy.
> DAN-P duplicates each of L2 frames and send it over the two
> Ethernet links. Each outgoing frame is appended with RCT.
> Unlike HSR, these are added to the end of L2 frame and may be
> treated as padding by bridges and therefore would be work with
> traditional bridges or switches, where as HSR wouldn't as Tag
> is prefixed to the Ethenet frame. At the remote end, these are
> received and the duplicate frame is discarded before the stripped
> frame is send up the networking stack. Like HSR, PRP also sends
> periodic Supervision frames to the network. These frames are
> received and MAC address from the SV frames are populated in a
> database called Node Table. The above functions are grouped into
> a block called Link Redundancy Entity (LRE) in the IEC spec.
>
> As there are many similarities between HSR and PRP protocols,
> this patch re-use the code from HSR driver to implement PRP
> driver. As many part of the code can be re-used, this patch
> introduces a new common API definitions for both protocols and
> propose to obsolete the existing HSR defines in
> include/uapi/linux/if_link.h. New definitions are prefixed
> with a HSR_PRP prefix. Similarly include/uapi/linux/hsr_netlink.h
> is proposed to be replaced with include/uapi/linux/hsr_prp_netlink.h
> which also uses the HSR_PRP prefix. The netlink socket interface
> code is migrated (as well as the iproute2 being sent as a follow up
> patch) to use the new API definitions. To re-use the code,
> following are done as a preparatory patch before adding the PRP
> functionality:-
>
> - prefix all common code with hsr_prp
> - net/hsr -> renamed to net/hsr-prp
> - All common struct types, constants, functions renamed with
> hsr{HSR}_prp{PRP} prefix.
I don't really like these prefixes, I am thinking of when support for
IEEE 802.1CB is added, do we rename this to "hsr_prp_frer"?
And it gets even more complicated, and using 802.1CB you can configure
the tagging method and the stream identification function so a system
can interoperate in a HSR or PRP network.
So, I see this as different methods of achieving the same result, which
makes me think that the different "methods/types" (HSR and PRP in your
case) should be basically different implementations of a "struct
hsr_ops" interface. With this hsr_ops something like this:
struct hsr_ops {
int (*handle_frame)()
int (*add_port)()
int (*remove_port)()
int (*setup)()
void (*teardown)()
};
>
> Please review this and provide me feedback so that I can work to
> incorporate them and send a formal patch series for this. As this
> series impacts user space, I am not sure if this is the right
> approach to introduce a new definitions and obsolete the old
> API definitions for HSR. The current approach is choosen
> to avoid redundant code in iproute2 and in the netlink driver
> code (hsr_netlink.c). Other approach we discussed internally was
> to Keep the HSR prefix in the user space and kernel code, but
> live with the redundant code in the iproute2 and hsr netlink
> code. Would like to hear from you what is the best way to add
> this feature to networking core. If there is any other
> alternative approach possible, I would like to hear about the
> same.
Why redudant code is needed in the netlink parts and in iproute2 when
keeping the hsr prefix?
>
> The patch was tested using two TI AM57x IDK boards which are
> connected back to back over two CPSW ports.
>
> Script used for creating the hsr/prp interface is given below
> and uses the ip link command. Also provided logs from the tests
> I have executed for your reference.
>
> iproute2 related patches will follow soon....
>
> Murali Karicheri
> Texas Instruments
>
> ============ setup.sh =================================================
> #!/bin/sh
> if [ $# -lt 4 ]
> then
> echo "setup-cpsw.sh <hsr/prp> <MAC-Address of slave-A>"
> echo " <ip address for hsr/prp interface>"
> echo " <if_name of hsr/prp interface>"
> exit
> fi
>
> if [ "$1" != "hsr" ] && [ "$1" != "prp" ]
> then
> echo "use hsr or prp as first argument"
> exit
> fi
>
> if_a=eth2
> if_b=eth3
> if_name=$4
>
> ifconfig $if_a down
> ifconfig $if_b down
> ifconfig $if_a hw ether $2
> ifconfig $if_b hw ether $2
> ifconfig $if_a up
> ifconfig $if_b up
>
> echo "Setting up $if_name with MAC address $2 for slaves and IP address $3"
> echo " using $if_a and $if_b"
>
> if [ "$1" = "hsr" ]; then
> options="version 1"
> else
> options=""
> fi
>
> ip link add name $if_name type $1 slave1 $if_a slave2 $if_b supervision 0 $options
> ifconfig $if_name $3 up
> ==================================================================================
> PRP Logs:
>
> DUT-1 : https://pastebin.ubuntu.com/p/hhsRjTQpcr/
> DUT-2 : https://pastebin.ubuntu.com/p/snPFKhnpk4/
>
> HSR Logs:
>
> DUT-1 : https://pastebin.ubuntu.com/p/FZPNc6Nwdm/
> DUT-2 : https://pastebin.ubuntu.com/p/CtV4ZVS3Yd/
>
> Murali Karicheri (13):
> net: hsr: Re-use Kconfig option to support PRP
> net: hsr: rename hsr directory to hsr-prp to introduce PRP
> net: hsr: rename files to introduce PRP support
> net: hsr: rename hsr variable inside struct hsr_port to priv
> net: hsr: rename hsr_port_get_hsr() to hsr_prp_get_port()
> net: hsr: some renaming to introduce PRP driver support
> net: hsr: introduce common uapi include/definitions for HSR and PRP
> net: hsr: migrate HSR netlink socket code to use new common API
> net: hsr: move re-usable code for PRP to hsr_prp_netlink.c
> net: hsr: add netlink socket interface for PRP
> net: prp: add supervision frame generation and handling support
> net: prp: add packet handling support
> net: prp: enhance debugfs to display PRP specific info in node table
>
> MAINTAINERS | 2 +-
> include/uapi/linux/hsr_netlink.h | 3 +
> include/uapi/linux/hsr_prp_netlink.h | 50 ++
> include/uapi/linux/if_link.h | 19 +
> net/Kconfig | 2 +-
> net/Makefile | 2 +-
> net/hsr-prp/Kconfig | 37 ++
> net/hsr-prp/Makefile | 11 +
> net/hsr-prp/hsr_netlink.c | 202 +++++++
> net/{hsr => hsr-prp}/hsr_netlink.h | 15 +-
> .../hsr_prp_debugfs.c} | 82 +--
> net/hsr-prp/hsr_prp_device.c | 562 ++++++++++++++++++
> net/hsr-prp/hsr_prp_device.h | 23 +
> net/hsr-prp/hsr_prp_forward.c | 558 +++++++++++++++++
> .../hsr_prp_forward.h} | 10 +-
> .../hsr_prp_framereg.c} | 323 +++++-----
> net/hsr-prp/hsr_prp_framereg.h | 68 +++
> net/hsr-prp/hsr_prp_main.c | 194 ++++++
> net/hsr-prp/hsr_prp_main.h | 289 +++++++++
> net/hsr-prp/hsr_prp_netlink.c | 365 ++++++++++++
> net/hsr-prp/hsr_prp_netlink.h | 28 +
> net/hsr-prp/hsr_prp_slave.c | 222 +++++++
> net/hsr-prp/hsr_prp_slave.h | 37 ++
> net/hsr-prp/prp_netlink.c | 141 +++++
> net/hsr-prp/prp_netlink.h | 27 +
> net/hsr/Kconfig | 29 -
> net/hsr/Makefile | 10 -
> net/hsr/hsr_device.c | 509 ----------------
> net/hsr/hsr_device.h | 22 -
> net/hsr/hsr_forward.c | 379 ------------
> net/hsr/hsr_framereg.h | 62 --
> net/hsr/hsr_main.c | 154 -----
> net/hsr/hsr_main.h | 188 ------
> net/hsr/hsr_netlink.c | 514 ----------------
> net/hsr/hsr_slave.c | 198 ------
> net/hsr/hsr_slave.h | 33 -
> 36 files changed, 3084 insertions(+), 2286 deletions(-)
> create mode 100644 include/uapi/linux/hsr_prp_netlink.h
> create mode 100644 net/hsr-prp/Kconfig
> create mode 100644 net/hsr-prp/Makefile
> create mode 100644 net/hsr-prp/hsr_netlink.c
> rename net/{hsr => hsr-prp}/hsr_netlink.h (58%)
> rename net/{hsr/hsr_debugfs.c => hsr-prp/hsr_prp_debugfs.c} (52%)
> create mode 100644 net/hsr-prp/hsr_prp_device.c
> create mode 100644 net/hsr-prp/hsr_prp_device.h
> create mode 100644 net/hsr-prp/hsr_prp_forward.c
> rename net/{hsr/hsr_forward.h => hsr-prp/hsr_prp_forward.h} (50%)
> rename net/{hsr/hsr_framereg.c => hsr-prp/hsr_prp_framereg.c} (56%)
> create mode 100644 net/hsr-prp/hsr_prp_framereg.h
> create mode 100644 net/hsr-prp/hsr_prp_main.c
> create mode 100644 net/hsr-prp/hsr_prp_main.h
> create mode 100644 net/hsr-prp/hsr_prp_netlink.c
> create mode 100644 net/hsr-prp/hsr_prp_netlink.h
> create mode 100644 net/hsr-prp/hsr_prp_slave.c
> create mode 100644 net/hsr-prp/hsr_prp_slave.h
> create mode 100644 net/hsr-prp/prp_netlink.c
> create mode 100644 net/hsr-prp/prp_netlink.h
> delete mode 100644 net/hsr/Kconfig
> delete mode 100644 net/hsr/Makefile
> delete mode 100644 net/hsr/hsr_device.c
> delete mode 100644 net/hsr/hsr_device.h
> delete mode 100644 net/hsr/hsr_forward.c
> delete mode 100644 net/hsr/hsr_framereg.h
> delete mode 100644 net/hsr/hsr_main.c
> delete mode 100644 net/hsr/hsr_main.h
> delete mode 100644 net/hsr/hsr_netlink.c
> delete mode 100644 net/hsr/hsr_slave.c
> delete mode 100644 net/hsr/hsr_slave.h
>
> --
> 2.17.1
>
--
Vinicius
Hi Vinicius,
On 5/21/20 1:31 PM, Vinicius Costa Gomes wrote:
> Murali Karicheri <[email protected]> writes:
>
------------ Snip-------------
>> - prefix all common code with hsr_prp
>> - net/hsr -> renamed to net/hsr-prp
>> - All common struct types, constants, functions renamed with
>> hsr{HSR}_prp{PRP} prefix.
>
> I don't really like these prefixes, I am thinking of when support for
> IEEE 802.1CB is added, do we rename this to "hsr_prp_frer"?
>
> And it gets even more complicated, and using 802.1CB you can configure
> the tagging method and the stream identification function so a system
> can interoperate in a HSR or PRP network.
>
> So, I see this as different methods of achieving the same result, which
> makes me think that the different "methods/types" (HSR and PRP in your
> case) should be basically different implementations of a "struct
> hsr_ops" interface. With this hsr_ops something like this:
>
> struct hsr_ops {
> int (*handle_frame)()
> int (*add_port)()
> int (*remove_port)()
> int (*setup)()
> void (*teardown)()
> };
>
Thanks for your response!
I agree with you that the prefix renaming is ugly. However I wasn't
sure if it is okay to use a hsr prefixed code to handle PRP as
well as it may not be intuitive to anyone investigating the code. For
the same reason, handling 802.1CB specifc functions using the hsr_
prefixed code. If that is okay, then patch 1-6 are unnecessary. We could
also add some documentation at the top of the file to indicate that
both hsr and prp are implemented in the code or something like that.
BTW, I need to investigate more into 802.1CB and this was not known
when I developed this code few years ago.
Main difference between HSR and PRP is how they handle the protocol tag
or rct and create or handle the protocol specific part in the frame.
For that part, we should be able to define ops() like you have
suggested, instead of doing if check throughout the code. Hope that
is what you meant by hsr_ops() for this. Again shouldn't we use some
generic name like proto_ops or red_ops instead of hsr_ops() and assign
protocol specific implementaion to them? i.e hsr_ or prp_
or 802.1CB specific functions assigned to the function pointers. For
now I see handle_frame(), handle_sv_frame, create_frame(),
create_sv_frame() etc implemented differently (This is currently part of
patch 11 & 12). So something like
struct proto_ops {
int (*handle_frame)();
int (*create_frame)();
int (*handle_sv_frame)();
int (*create_sv_frame)();
};
and call dev->proto_ops->handle_frame() to process a frame from the
main hook. proto_ops gets initialized to of the set if implementation
at device or interface creation in hsr_dev_finalize().
>>
>> Please review this and provide me feedback so that I can work to
>> incorporate them and send a formal patch series for this. As this
>> series impacts user space, I am not sure if this is the right
>> approach to introduce a new definitions and obsolete the old
>> API definitions for HSR. The current approach is choosen
>> to avoid redundant code in iproute2 and in the netlink driver
>> code (hsr_netlink.c). Other approach we discussed internally was
>> to Keep the HSR prefix in the user space and kernel code, but
>> live with the redundant code in the iproute2 and hsr netlink
>> code. Would like to hear from you what is the best way to add
>> this feature to networking core. If there is any other
>> alternative approach possible, I would like to hear about the
>> same.
>
> Why redudant code is needed in the netlink parts and in iproute2 when
> keeping the hsr prefix?
May be this is due to the specific implementation that I chose.
Currently I have separate netlink socket for HSR and PRP which may
be an overkill since bith are similar protocol.
Currently hsr inteface is created as
ip link add name hsr0 type hsr slave1 eth0 slave2 eth1 supervision 0
So I have implemented similar command for prp
ip link add name prp0 type prp slave1 eth0 slave2 eth1 supervision 0
In patch 7/13 I renamed existing HSR netlink socket attributes that
defines the hsr interface with the assumption that we can obsolete
the old definitions in favor of new common definitions with the
HSR_PRP prefix. Then I have separate code for creating prp
interface and related functions, even though they are similar.
So using common definitions, I re-use the code in netlink and
iproute2 (see patch 8 and 9 to re-use the code). PRP netlink
socket code in patch 10 which register prp_genl_family similar
to HSR.
+static struct genl_family prp_genl_family __ro_after_init = {
+ .hdrsize = 0,
+ .name = "PRP",
+ .version = 1,
+ .maxattr = HSR_PRP_A_MAX,
+ .policy = prp_genl_policy,
+ .module = THIS_MODULE,
+ .ops = prp_ops,
+ .n_ops = ARRAY_SIZE(prp_ops),
+ .mcgrps = prp_mcgrps,
+ .n_mcgrps = ARRAY_SIZE(prp_mcgrps),
+};
+
+int __init prp_netlink_init(void)
+{
+ int rc;
+
+ rc = rtnl_link_register(&prp_link_ops);
+ if (rc)
+ goto fail_rtnl_link_register;
+
+ rc = genl_register_family(&prp_genl_family);
+ if (rc)
+ goto fail_genl_register_family;
If we choose to re-use the existing HSR_ uapi defines, then should we
re-use the hsr netlink socket interface for PRP as well and
add additional attribute for differentiating the protocol specific
part?
i.e introduce protocol attribute to existing HSR uapi defines for
netlink socket to handle creation of prp interface.
enum {
HSR_A_UNSPEC,
HSR_A_NODE_ADDR,
HSR_A_IFINDEX,
HSR_A_IF1_AGE,
HSR_A_IF2_AGE,
HSR_A_NODE_ADDR_B,
HSR_A_IF1_SEQ,
HSR_A_IF2_SEQ,
HSR_A_IF1_IFINDEX,
HSR_A_IF2_IFINDEX,
HSR_A_ADDR_B_IFINDEX,
+ HSR_A_PROTOCOL <====if missing it is HSR (backward
compatibility)
defines HSR or PRP or 802.1CB in future.
__HSR_A_MAX,
};
So if ip link command is
ip link add name <if name> type <proto> slave1 eth0 slave2 eth1
supervision 0
Add HSR_A_PROTOCOL attribute with HSR/PRP specific value.
This way, the iprout2 code mostly remain the same as hsr, but will
change a bit to introduced this new attribute if user choose proto as
'prp' vs 'hsr'
BTW, I have posted the existing iproute2 code also to the mailing list
with title 'iproute2: Add PRP support'.
If re-using hsr code with existing prefix is fine for PRP or any future
protocol such as 801.1B, then I will drop patch 1-6 that are essentially
doing some renaming and re-use existing hsr netlink code for PRP with
added attribute to differentiate the protocol at the driver as described
above along with proto_ops and re-spin the series.
Let me know.
Regards,
Murali
>
>>
>> The patch was tested using two TI AM57x IDK boards which are
>> connected back to back over two CPSW ports.
>>
>> Script used for creating the hsr/prp interface is given below
>> and uses the ip link command. Also provided logs from the tests
>> I have executed for your reference.
>>
>> iproute2 related patches will follow soon....
>>
>> Murali Karicheri
>> Texas Instruments
>>
>> ============ setup.sh =================================================
>> #!/bin/sh
>> if [ $# -lt 4 ]
>> then
>> echo "setup-cpsw.sh <hsr/prp> <MAC-Address of slave-A>"
>> echo " <ip address for hsr/prp interface>"
>> echo " <if_name of hsr/prp interface>"
>> exit
>> fi
>>
>> if [ "$1" != "hsr" ] && [ "$1" != "prp" ]
>> then
>> echo "use hsr or prp as first argument"
>> exit
>> fi
>>
>> if_a=eth2
>> if_b=eth3
>> if_name=$4
>>
>> ifconfig $if_a down
>> ifconfig $if_b down
>> ifconfig $if_a hw ether $2
>> ifconfig $if_b hw ether $2
>> ifconfig $if_a up
>> ifconfig $if_b up
>>
>> echo "Setting up $if_name with MAC address $2 for slaves and IP address $3"
>> echo " using $if_a and $if_b"
>>
>> if [ "$1" = "hsr" ]; then
>> options="version 1"
>> else
>> options=""
>> fi
>>
>> ip link add name $if_name type $1 slave1 $if_a slave2 $if_b supervision 0 $options
>> ifconfig $if_name $3 up
>> ==================================================================================
>> PRP Logs:
>>
>> DUT-1 : https://pastebin.ubuntu.com/p/hhsRjTQpcr/
>> DUT-2 : https://pastebin.ubuntu.com/p/snPFKhnpk4/
>>
>> HSR Logs:
>>
>> DUT-1 : https://pastebin.ubuntu.com/p/FZPNc6Nwdm/
>> DUT-2 : https://pastebin.ubuntu.com/p/CtV4ZVS3Yd/
>>
>> Murali Karicheri (13):
>> net: hsr: Re-use Kconfig option to support PRP
>> net: hsr: rename hsr directory to hsr-prp to introduce PRP
>> net: hsr: rename files to introduce PRP support
>> net: hsr: rename hsr variable inside struct hsr_port to priv
>> net: hsr: rename hsr_port_get_hsr() to hsr_prp_get_port()
>> net: hsr: some renaming to introduce PRP driver support
>> net: hsr: introduce common uapi include/definitions for HSR and PRP
>> net: hsr: migrate HSR netlink socket code to use new common API
>> net: hsr: move re-usable code for PRP to hsr_prp_netlink.c
>> net: hsr: add netlink socket interface for PRP
>> net: prp: add supervision frame generation and handling support
>> net: prp: add packet handling support
>> net: prp: enhance debugfs to display PRP specific info in node table
>>
>> MAINTAINERS | 2 +-
>> include/uapi/linux/hsr_netlink.h | 3 +
>> include/uapi/linux/hsr_prp_netlink.h | 50 ++
>> include/uapi/linux/if_link.h | 19 +
>> net/Kconfig | 2 +-
>> net/Makefile | 2 +-
>> net/hsr-prp/Kconfig | 37 ++
>> net/hsr-prp/Makefile | 11 +
>> net/hsr-prp/hsr_netlink.c | 202 +++++++
>> net/{hsr => hsr-prp}/hsr_netlink.h | 15 +-
>> .../hsr_prp_debugfs.c} | 82 +--
>> net/hsr-prp/hsr_prp_device.c | 562 ++++++++++++++++++
>> net/hsr-prp/hsr_prp_device.h | 23 +
>> net/hsr-prp/hsr_prp_forward.c | 558 +++++++++++++++++
>> .../hsr_prp_forward.h} | 10 +-
>> .../hsr_prp_framereg.c} | 323 +++++-----
>> net/hsr-prp/hsr_prp_framereg.h | 68 +++
>> net/hsr-prp/hsr_prp_main.c | 194 ++++++
>> net/hsr-prp/hsr_prp_main.h | 289 +++++++++
>> net/hsr-prp/hsr_prp_netlink.c | 365 ++++++++++++
>> net/hsr-prp/hsr_prp_netlink.h | 28 +
>> net/hsr-prp/hsr_prp_slave.c | 222 +++++++
>> net/hsr-prp/hsr_prp_slave.h | 37 ++
>> net/hsr-prp/prp_netlink.c | 141 +++++
>> net/hsr-prp/prp_netlink.h | 27 +
>> net/hsr/Kconfig | 29 -
>> net/hsr/Makefile | 10 -
>> net/hsr/hsr_device.c | 509 ----------------
>> net/hsr/hsr_device.h | 22 -
>> net/hsr/hsr_forward.c | 379 ------------
>> net/hsr/hsr_framereg.h | 62 --
>> net/hsr/hsr_main.c | 154 -----
>> net/hsr/hsr_main.h | 188 ------
>> net/hsr/hsr_netlink.c | 514 ----------------
>> net/hsr/hsr_slave.c | 198 ------
>> net/hsr/hsr_slave.h | 33 -
>> 36 files changed, 3084 insertions(+), 2286 deletions(-)
>> create mode 100644 include/uapi/linux/hsr_prp_netlink.h
>> create mode 100644 net/hsr-prp/Kconfig
>> create mode 100644 net/hsr-prp/Makefile
>> create mode 100644 net/hsr-prp/hsr_netlink.c
>> rename net/{hsr => hsr-prp}/hsr_netlink.h (58%)
>> rename net/{hsr/hsr_debugfs.c => hsr-prp/hsr_prp_debugfs.c} (52%)
>> create mode 100644 net/hsr-prp/hsr_prp_device.c
>> create mode 100644 net/hsr-prp/hsr_prp_device.h
>> create mode 100644 net/hsr-prp/hsr_prp_forward.c
>> rename net/{hsr/hsr_forward.h => hsr-prp/hsr_prp_forward.h} (50%)
>> rename net/{hsr/hsr_framereg.c => hsr-prp/hsr_prp_framereg.c} (56%)
>> create mode 100644 net/hsr-prp/hsr_prp_framereg.h
>> create mode 100644 net/hsr-prp/hsr_prp_main.c
>> create mode 100644 net/hsr-prp/hsr_prp_main.h
>> create mode 100644 net/hsr-prp/hsr_prp_netlink.c
>> create mode 100644 net/hsr-prp/hsr_prp_netlink.h
>> create mode 100644 net/hsr-prp/hsr_prp_slave.c
>> create mode 100644 net/hsr-prp/hsr_prp_slave.h
>> create mode 100644 net/hsr-prp/prp_netlink.c
>> create mode 100644 net/hsr-prp/prp_netlink.h
>> delete mode 100644 net/hsr/Kconfig
>> delete mode 100644 net/hsr/Makefile
>> delete mode 100644 net/hsr/hsr_device.c
>> delete mode 100644 net/hsr/hsr_device.h
>> delete mode 100644 net/hsr/hsr_forward.c
>> delete mode 100644 net/hsr/hsr_framereg.h
>> delete mode 100644 net/hsr/hsr_main.c
>> delete mode 100644 net/hsr/hsr_main.h
>> delete mode 100644 net/hsr/hsr_netlink.c
>> delete mode 100644 net/hsr/hsr_slave.c
>> delete mode 100644 net/hsr/hsr_slave.h
>>
>> --
>> 2.17.1
>>
>
--
Murali Karicheri
Texas Instruments
Hi Vinicius,
On Thu, 21 May 2020 at 20:33, Vinicius Costa Gomes
<[email protected]> wrote:
>
> Murali Karicheri <[email protected]> writes:
>
> > This RFC series add support for Parallel Redundancy Protocol (PRP)
> > as defined in IEC-62439-3 in the kernel networking subsystem. PRP
> > Uses a Redundancy Control Trailer (RCT) the format of which is
> > similar to HSR Tag. This is used for implementing redundancy.
> > RCT consists of 6 bytes similar to HSR tag and contain following
> > fields:-
> >
> > - 16-bit sequence number (SeqNr);
> > - 4-bit LAN identifier (LanId);
> > - 12 bit frame size (LSDUsize);
> > - 16-bit suffix (PRPsuffix).
> >
> > The PRPsuffix identifies PRP frames and distinguishes PRP frames
> > from other protocols that also append a trailer to their useful
> > data. The LSDUsize field allows the receiver to distinguish PRP
> > frames from random, nonredundant frames as an additional check.
> > LSDUsize is the size of the Ethernet payload inclusive of the
> > RCT. Sequence number along with LanId is used for duplicate
> > detection and discard.
> >
> > PRP node is also known as Dual Attached Node (DAN-P) since it
> > is typically attached to two different LAN for redundancy.
> > DAN-P duplicates each of L2 frames and send it over the two
> > Ethernet links. Each outgoing frame is appended with RCT.
> > Unlike HSR, these are added to the end of L2 frame and may be
> > treated as padding by bridges and therefore would be work with
> > traditional bridges or switches, where as HSR wouldn't as Tag
> > is prefixed to the Ethenet frame. At the remote end, these are
> > received and the duplicate frame is discarded before the stripped
> > frame is send up the networking stack. Like HSR, PRP also sends
> > periodic Supervision frames to the network. These frames are
> > received and MAC address from the SV frames are populated in a
> > database called Node Table. The above functions are grouped into
> > a block called Link Redundancy Entity (LRE) in the IEC spec.
> >
> > As there are many similarities between HSR and PRP protocols,
> > this patch re-use the code from HSR driver to implement PRP
> > driver. As many part of the code can be re-used, this patch
> > introduces a new common API definitions for both protocols and
> > propose to obsolete the existing HSR defines in
> > include/uapi/linux/if_link.h. New definitions are prefixed
> > with a HSR_PRP prefix. Similarly include/uapi/linux/hsr_netlink.h
> > is proposed to be replaced with include/uapi/linux/hsr_prp_netlink.h
> > which also uses the HSR_PRP prefix. The netlink socket interface
> > code is migrated (as well as the iproute2 being sent as a follow up
> > patch) to use the new API definitions. To re-use the code,
> > following are done as a preparatory patch before adding the PRP
> > functionality:-
> >
> > - prefix all common code with hsr_prp
> > - net/hsr -> renamed to net/hsr-prp
> > - All common struct types, constants, functions renamed with
> > hsr{HSR}_prp{PRP} prefix.
>
> I don't really like these prefixes, I am thinking of when support for
> IEEE 802.1CB is added, do we rename this to "hsr_prp_frer"?
>
> And it gets even more complicated, and using 802.1CB you can configure
> the tagging method and the stream identification function so a system
> can interoperate in a HSR or PRP network.
>
Is it a given that 802.1CB in Linux should be implemented using an hsr
upper device?
802.1CB is _much_ more flexible than both HSR and PRP. You can have
more than 2 ports, you can have per-stream rules (each stream has its
own sequence number), and those rules can identify the source, the
destination, or both the source and the destination.
> So, I see this as different methods of achieving the same result, which
> makes me think that the different "methods/types" (HSR and PRP in your
> case) should be basically different implementations of a "struct
> hsr_ops" interface. With this hsr_ops something like this:
>
> struct hsr_ops {
> int (*handle_frame)()
> int (*add_port)()
> int (*remove_port)()
> int (*setup)()
> void (*teardown)()
> };
>
> >
> > Please review this and provide me feedback so that I can work to
> > incorporate them and send a formal patch series for this. As this
> > series impacts user space, I am not sure if this is the right
> > approach to introduce a new definitions and obsolete the old
> > API definitions for HSR. The current approach is choosen
> > to avoid redundant code in iproute2 and in the netlink driver
> > code (hsr_netlink.c). Other approach we discussed internally was
> > to Keep the HSR prefix in the user space and kernel code, but
> > live with the redundant code in the iproute2 and hsr netlink
> > code. Would like to hear from you what is the best way to add
> > this feature to networking core. If there is any other
> > alternative approach possible, I would like to hear about the
> > same.
>
> Why redudant code is needed in the netlink parts and in iproute2 when
> keeping the hsr prefix?
>
> >
> > The patch was tested using two TI AM57x IDK boards which are
> > connected back to back over two CPSW ports.
> >
> > Script used for creating the hsr/prp interface is given below
> > and uses the ip link command. Also provided logs from the tests
> > I have executed for your reference.
> >
> > iproute2 related patches will follow soon....
> >
> > Murali Karicheri
> > Texas Instruments
> >
> > ============ setup.sh =================================================
> > #!/bin/sh
> > if [ $# -lt 4 ]
> > then
> > echo "setup-cpsw.sh <hsr/prp> <MAC-Address of slave-A>"
> > echo " <ip address for hsr/prp interface>"
> > echo " <if_name of hsr/prp interface>"
> > exit
> > fi
> >
> > if [ "$1" != "hsr" ] && [ "$1" != "prp" ]
> > then
> > echo "use hsr or prp as first argument"
> > exit
> > fi
> >
> > if_a=eth2
> > if_b=eth3
> > if_name=$4
> >
> > ifconfig $if_a down
> > ifconfig $if_b down
> > ifconfig $if_a hw ether $2
> > ifconfig $if_b hw ether $2
> > ifconfig $if_a up
> > ifconfig $if_b up
> >
> > echo "Setting up $if_name with MAC address $2 for slaves and IP address $3"
> > echo " using $if_a and $if_b"
> >
> > if [ "$1" = "hsr" ]; then
> > options="version 1"
> > else
> > options=""
> > fi
> >
> > ip link add name $if_name type $1 slave1 $if_a slave2 $if_b supervision 0 $options
> > ifconfig $if_name $3 up
> > ==================================================================================
> > PRP Logs:
> >
> > DUT-1 : https://pastebin.ubuntu.com/p/hhsRjTQpcr/
> > DUT-2 : https://pastebin.ubuntu.com/p/snPFKhnpk4/
> >
> > HSR Logs:
> >
> > DUT-1 : https://pastebin.ubuntu.com/p/FZPNc6Nwdm/
> > DUT-2 : https://pastebin.ubuntu.com/p/CtV4ZVS3Yd/
> >
> > Murali Karicheri (13):
> > net: hsr: Re-use Kconfig option to support PRP
> > net: hsr: rename hsr directory to hsr-prp to introduce PRP
> > net: hsr: rename files to introduce PRP support
> > net: hsr: rename hsr variable inside struct hsr_port to priv
> > net: hsr: rename hsr_port_get_hsr() to hsr_prp_get_port()
> > net: hsr: some renaming to introduce PRP driver support
> > net: hsr: introduce common uapi include/definitions for HSR and PRP
> > net: hsr: migrate HSR netlink socket code to use new common API
> > net: hsr: move re-usable code for PRP to hsr_prp_netlink.c
> > net: hsr: add netlink socket interface for PRP
> > net: prp: add supervision frame generation and handling support
> > net: prp: add packet handling support
> > net: prp: enhance debugfs to display PRP specific info in node table
> >
> > MAINTAINERS | 2 +-
> > include/uapi/linux/hsr_netlink.h | 3 +
> > include/uapi/linux/hsr_prp_netlink.h | 50 ++
> > include/uapi/linux/if_link.h | 19 +
> > net/Kconfig | 2 +-
> > net/Makefile | 2 +-
> > net/hsr-prp/Kconfig | 37 ++
> > net/hsr-prp/Makefile | 11 +
> > net/hsr-prp/hsr_netlink.c | 202 +++++++
> > net/{hsr => hsr-prp}/hsr_netlink.h | 15 +-
> > .../hsr_prp_debugfs.c} | 82 +--
> > net/hsr-prp/hsr_prp_device.c | 562 ++++++++++++++++++
> > net/hsr-prp/hsr_prp_device.h | 23 +
> > net/hsr-prp/hsr_prp_forward.c | 558 +++++++++++++++++
> > .../hsr_prp_forward.h} | 10 +-
> > .../hsr_prp_framereg.c} | 323 +++++-----
> > net/hsr-prp/hsr_prp_framereg.h | 68 +++
> > net/hsr-prp/hsr_prp_main.c | 194 ++++++
> > net/hsr-prp/hsr_prp_main.h | 289 +++++++++
> > net/hsr-prp/hsr_prp_netlink.c | 365 ++++++++++++
> > net/hsr-prp/hsr_prp_netlink.h | 28 +
> > net/hsr-prp/hsr_prp_slave.c | 222 +++++++
> > net/hsr-prp/hsr_prp_slave.h | 37 ++
> > net/hsr-prp/prp_netlink.c | 141 +++++
> > net/hsr-prp/prp_netlink.h | 27 +
> > net/hsr/Kconfig | 29 -
> > net/hsr/Makefile | 10 -
> > net/hsr/hsr_device.c | 509 ----------------
> > net/hsr/hsr_device.h | 22 -
> > net/hsr/hsr_forward.c | 379 ------------
> > net/hsr/hsr_framereg.h | 62 --
> > net/hsr/hsr_main.c | 154 -----
> > net/hsr/hsr_main.h | 188 ------
> > net/hsr/hsr_netlink.c | 514 ----------------
> > net/hsr/hsr_slave.c | 198 ------
> > net/hsr/hsr_slave.h | 33 -
> > 36 files changed, 3084 insertions(+), 2286 deletions(-)
> > create mode 100644 include/uapi/linux/hsr_prp_netlink.h
> > create mode 100644 net/hsr-prp/Kconfig
> > create mode 100644 net/hsr-prp/Makefile
> > create mode 100644 net/hsr-prp/hsr_netlink.c
> > rename net/{hsr => hsr-prp}/hsr_netlink.h (58%)
> > rename net/{hsr/hsr_debugfs.c => hsr-prp/hsr_prp_debugfs.c} (52%)
> > create mode 100644 net/hsr-prp/hsr_prp_device.c
> > create mode 100644 net/hsr-prp/hsr_prp_device.h
> > create mode 100644 net/hsr-prp/hsr_prp_forward.c
> > rename net/{hsr/hsr_forward.h => hsr-prp/hsr_prp_forward.h} (50%)
> > rename net/{hsr/hsr_framereg.c => hsr-prp/hsr_prp_framereg.c} (56%)
> > create mode 100644 net/hsr-prp/hsr_prp_framereg.h
> > create mode 100644 net/hsr-prp/hsr_prp_main.c
> > create mode 100644 net/hsr-prp/hsr_prp_main.h
> > create mode 100644 net/hsr-prp/hsr_prp_netlink.c
> > create mode 100644 net/hsr-prp/hsr_prp_netlink.h
> > create mode 100644 net/hsr-prp/hsr_prp_slave.c
> > create mode 100644 net/hsr-prp/hsr_prp_slave.h
> > create mode 100644 net/hsr-prp/prp_netlink.c
> > create mode 100644 net/hsr-prp/prp_netlink.h
> > delete mode 100644 net/hsr/Kconfig
> > delete mode 100644 net/hsr/Makefile
> > delete mode 100644 net/hsr/hsr_device.c
> > delete mode 100644 net/hsr/hsr_device.h
> > delete mode 100644 net/hsr/hsr_forward.c
> > delete mode 100644 net/hsr/hsr_framereg.h
> > delete mode 100644 net/hsr/hsr_main.c
> > delete mode 100644 net/hsr/hsr_main.h
> > delete mode 100644 net/hsr/hsr_netlink.c
> > delete mode 100644 net/hsr/hsr_slave.c
> > delete mode 100644 net/hsr/hsr_slave.h
> >
> > --
> > 2.17.1
> >
>
> --
> Vinicius
Thanks,
-Vladimir
Hi Vladimir,
On 5/25/20 5:37 PM, Vladimir Oltean wrote:
> Hi Vinicius,
>
> On Thu, 21 May 2020 at 20:33, Vinicius Costa Gomes
> <[email protected]> wrote:
>>
>> Murali Karicheri <[email protected]> writes:
>>
>>> This RFC series add support for Parallel Redundancy Protocol (PRP)
>>> as defined in IEC-62439-3 in the kernel networking subsystem. PRP
>>> Uses a Redundancy Control Trailer (RCT) the format of which is
>>> similar to HSR Tag. This is used for implementing redundancy.
>>> RCT consists of 6 bytes similar to HSR tag and contain following
>>> fields:-
>>>
>>> - 16-bit sequence number (SeqNr);
>>> - 4-bit LAN identifier (LanId);
>>> - 12 bit frame size (LSDUsize);
>>> - 16-bit suffix (PRPsuffix).
>>>
>>> The PRPsuffix identifies PRP frames and distinguishes PRP frames
>>> from other protocols that also append a trailer to their useful
>>> data. The LSDUsize field allows the receiver to distinguish PRP
>>> frames from random, nonredundant frames as an additional check.
>>> LSDUsize is the size of the Ethernet payload inclusive of the
>>> RCT. Sequence number along with LanId is used for duplicate
>>> detection and discard.
>>>
>>> PRP node is also known as Dual Attached Node (DAN-P) since it
>>> is typically attached to two different LAN for redundancy.
>>> DAN-P duplicates each of L2 frames and send it over the two
>>> Ethernet links. Each outgoing frame is appended with RCT.
>>> Unlike HSR, these are added to the end of L2 frame and may be
>>> treated as padding by bridges and therefore would be work with
>>> traditional bridges or switches, where as HSR wouldn't as Tag
>>> is prefixed to the Ethenet frame. At the remote end, these are
>>> received and the duplicate frame is discarded before the stripped
>>> frame is send up the networking stack. Like HSR, PRP also sends
>>> periodic Supervision frames to the network. These frames are
>>> received and MAC address from the SV frames are populated in a
>>> database called Node Table. The above functions are grouped into
>>> a block called Link Redundancy Entity (LRE) in the IEC spec.
>>>
>>> As there are many similarities between HSR and PRP protocols,
>>> this patch re-use the code from HSR driver to implement PRP
>>> driver. As many part of the code can be re-used, this patch
>>> introduces a new common API definitions for both protocols and
>>> propose to obsolete the existing HSR defines in
>>> include/uapi/linux/if_link.h. New definitions are prefixed
>>> with a HSR_PRP prefix. Similarly include/uapi/linux/hsr_netlink.h
>>> is proposed to be replaced with include/uapi/linux/hsr_prp_netlink.h
>>> which also uses the HSR_PRP prefix. The netlink socket interface
>>> code is migrated (as well as the iproute2 being sent as a follow up
>>> patch) to use the new API definitions. To re-use the code,
>>> following are done as a preparatory patch before adding the PRP
>>> functionality:-
>>>
>>> - prefix all common code with hsr_prp
>>> - net/hsr -> renamed to net/hsr-prp
>>> - All common struct types, constants, functions renamed with
>>> hsr{HSR}_prp{PRP} prefix.
>>
>> I don't really like these prefixes, I am thinking of when support for
>> IEEE 802.1CB is added, do we rename this to "hsr_prp_frer"?
>>
>> And it gets even more complicated, and using 802.1CB you can configure
>> the tagging method and the stream identification function so a system
>> can interoperate in a HSR or PRP network.
>>
>
> Is it a given that 802.1CB in Linux should be implemented using an hsr
> upper device?
> 802.1CB is _much_ more flexible than both HSR and PRP. You can have
> more than 2 ports, you can have per-stream rules (each stream has its
> own sequence number), and those rules can identify the source, the
> destination, or both the source and the destination.
>
I haven't looked the spec for 802.1CB. If they re-use HSR/PRP Tag in the
L2 protocol it make sense to enhance the driver. Else I don't see any
re-use possibility. Do you know the above?
Thanks
Murali
>> So, I see this as different methods of achieving the same result, which
>> makes me think that the different "methods/types" (HSR and PRP in your
>> case) should be basically different implementations of a "struct
>> hsr_ops" interface. With this hsr_ops something like this:
>>
>> struct hsr_ops {
>> int (*handle_frame)()
>> int (*add_port)()
>> int (*remove_port)()
>> int (*setup)()
>> void (*teardown)()
>> };
>>
>>>
>>> Please review this and provide me feedback so that I can work to
>>> incorporate them and send a formal patch series for this. As this
>>> series impacts user space, I am not sure if this is the right
>>> approach to introduce a new definitions and obsolete the old
>>> API definitions for HSR. The current approach is choosen
>>> to avoid redundant code in iproute2 and in the netlink driver
>>> code (hsr_netlink.c). Other approach we discussed internally was
>>> to Keep the HSR prefix in the user space and kernel code, but
>>> live with the redundant code in the iproute2 and hsr netlink
>>> code. Would like to hear from you what is the best way to add
>>> this feature to networking core. If there is any other
>>> alternative approach possible, I would like to hear about the
>>> same.
>>
>> Why redudant code is needed in the netlink parts and in iproute2 when
>> keeping the hsr prefix?
>>
>>>
>>> The patch was tested using two TI AM57x IDK boards which are
>>> connected back to back over two CPSW ports.
>>>
>>> Script used for creating the hsr/prp interface is given below
>>> and uses the ip link command. Also provided logs from the tests
>>> I have executed for your reference.
>>>
>>> iproute2 related patches will follow soon....
>>>
>>> Murali Karicheri
>>> Texas Instruments
>>>
>>> ============ setup.sh =================================================
>>> #!/bin/sh
>>> if [ $# -lt 4 ]
>>> then
>>> echo "setup-cpsw.sh <hsr/prp> <MAC-Address of slave-A>"
>>> echo " <ip address for hsr/prp interface>"
>>> echo " <if_name of hsr/prp interface>"
>>> exit
>>> fi
>>>
>>> if [ "$1" != "hsr" ] && [ "$1" != "prp" ]
>>> then
>>> echo "use hsr or prp as first argument"
>>> exit
>>> fi
>>>
>>> if_a=eth2
>>> if_b=eth3
>>> if_name=$4
>>>
>>> ifconfig $if_a down
>>> ifconfig $if_b down
>>> ifconfig $if_a hw ether $2
>>> ifconfig $if_b hw ether $2
>>> ifconfig $if_a up
>>> ifconfig $if_b up
>>>
>>> echo "Setting up $if_name with MAC address $2 for slaves and IP address $3"
>>> echo " using $if_a and $if_b"
>>>
>>> if [ "$1" = "hsr" ]; then
>>> options="version 1"
>>> else
>>> options=""
>>> fi
>>>
>>> ip link add name $if_name type $1 slave1 $if_a slave2 $if_b supervision 0 $options
>>> ifconfig $if_name $3 up
>>> ==================================================================================
>>> PRP Logs:
>>>
>>> DUT-1 : https://pastebin.ubuntu.com/p/hhsRjTQpcr/
>>> DUT-2 : https://pastebin.ubuntu.com/p/snPFKhnpk4/
>>>
>>> HSR Logs:
>>>
>>> DUT-1 : https://pastebin.ubuntu.com/p/FZPNc6Nwdm/
>>> DUT-2 : https://pastebin.ubuntu.com/p/CtV4ZVS3Yd/
>>>
>>> Murali Karicheri (13):
>>> net: hsr: Re-use Kconfig option to support PRP
>>> net: hsr: rename hsr directory to hsr-prp to introduce PRP
>>> net: hsr: rename files to introduce PRP support
>>> net: hsr: rename hsr variable inside struct hsr_port to priv
>>> net: hsr: rename hsr_port_get_hsr() to hsr_prp_get_port()
>>> net: hsr: some renaming to introduce PRP driver support
>>> net: hsr: introduce common uapi include/definitions for HSR and PRP
>>> net: hsr: migrate HSR netlink socket code to use new common API
>>> net: hsr: move re-usable code for PRP to hsr_prp_netlink.c
>>> net: hsr: add netlink socket interface for PRP
>>> net: prp: add supervision frame generation and handling support
>>> net: prp: add packet handling support
>>> net: prp: enhance debugfs to display PRP specific info in node table
>>>
>>> MAINTAINERS | 2 +-
>>> include/uapi/linux/hsr_netlink.h | 3 +
>>> include/uapi/linux/hsr_prp_netlink.h | 50 ++
>>> include/uapi/linux/if_link.h | 19 +
>>> net/Kconfig | 2 +-
>>> net/Makefile | 2 +-
>>> net/hsr-prp/Kconfig | 37 ++
>>> net/hsr-prp/Makefile | 11 +
>>> net/hsr-prp/hsr_netlink.c | 202 +++++++
>>> net/{hsr => hsr-prp}/hsr_netlink.h | 15 +-
>>> .../hsr_prp_debugfs.c} | 82 +--
>>> net/hsr-prp/hsr_prp_device.c | 562 ++++++++++++++++++
>>> net/hsr-prp/hsr_prp_device.h | 23 +
>>> net/hsr-prp/hsr_prp_forward.c | 558 +++++++++++++++++
>>> .../hsr_prp_forward.h} | 10 +-
>>> .../hsr_prp_framereg.c} | 323 +++++-----
>>> net/hsr-prp/hsr_prp_framereg.h | 68 +++
>>> net/hsr-prp/hsr_prp_main.c | 194 ++++++
>>> net/hsr-prp/hsr_prp_main.h | 289 +++++++++
>>> net/hsr-prp/hsr_prp_netlink.c | 365 ++++++++++++
>>> net/hsr-prp/hsr_prp_netlink.h | 28 +
>>> net/hsr-prp/hsr_prp_slave.c | 222 +++++++
>>> net/hsr-prp/hsr_prp_slave.h | 37 ++
>>> net/hsr-prp/prp_netlink.c | 141 +++++
>>> net/hsr-prp/prp_netlink.h | 27 +
>>> net/hsr/Kconfig | 29 -
>>> net/hsr/Makefile | 10 -
>>> net/hsr/hsr_device.c | 509 ----------------
>>> net/hsr/hsr_device.h | 22 -
>>> net/hsr/hsr_forward.c | 379 ------------
>>> net/hsr/hsr_framereg.h | 62 --
>>> net/hsr/hsr_main.c | 154 -----
>>> net/hsr/hsr_main.h | 188 ------
>>> net/hsr/hsr_netlink.c | 514 ----------------
>>> net/hsr/hsr_slave.c | 198 ------
>>> net/hsr/hsr_slave.h | 33 -
>>> 36 files changed, 3084 insertions(+), 2286 deletions(-)
>>> create mode 100644 include/uapi/linux/hsr_prp_netlink.h
>>> create mode 100644 net/hsr-prp/Kconfig
>>> create mode 100644 net/hsr-prp/Makefile
>>> create mode 100644 net/hsr-prp/hsr_netlink.c
>>> rename net/{hsr => hsr-prp}/hsr_netlink.h (58%)
>>> rename net/{hsr/hsr_debugfs.c => hsr-prp/hsr_prp_debugfs.c} (52%)
>>> create mode 100644 net/hsr-prp/hsr_prp_device.c
>>> create mode 100644 net/hsr-prp/hsr_prp_device.h
>>> create mode 100644 net/hsr-prp/hsr_prp_forward.c
>>> rename net/{hsr/hsr_forward.h => hsr-prp/hsr_prp_forward.h} (50%)
>>> rename net/{hsr/hsr_framereg.c => hsr-prp/hsr_prp_framereg.c} (56%)
>>> create mode 100644 net/hsr-prp/hsr_prp_framereg.h
>>> create mode 100644 net/hsr-prp/hsr_prp_main.c
>>> create mode 100644 net/hsr-prp/hsr_prp_main.h
>>> create mode 100644 net/hsr-prp/hsr_prp_netlink.c
>>> create mode 100644 net/hsr-prp/hsr_prp_netlink.h
>>> create mode 100644 net/hsr-prp/hsr_prp_slave.c
>>> create mode 100644 net/hsr-prp/hsr_prp_slave.h
>>> create mode 100644 net/hsr-prp/prp_netlink.c
>>> create mode 100644 net/hsr-prp/prp_netlink.h
>>> delete mode 100644 net/hsr/Kconfig
>>> delete mode 100644 net/hsr/Makefile
>>> delete mode 100644 net/hsr/hsr_device.c
>>> delete mode 100644 net/hsr/hsr_device.h
>>> delete mode 100644 net/hsr/hsr_forward.c
>>> delete mode 100644 net/hsr/hsr_framereg.h
>>> delete mode 100644 net/hsr/hsr_main.c
>>> delete mode 100644 net/hsr/hsr_main.h
>>> delete mode 100644 net/hsr/hsr_netlink.c
>>> delete mode 100644 net/hsr/hsr_slave.c
>>> delete mode 100644 net/hsr/hsr_slave.h
>>>
>>> --
>>> 2.17.1
>>>
>>
>> --
>> Vinicius
>
> Thanks,
> -Vladimir
>
--
Murali Karicheri
Texas Instruments
Hi Vladimir,
Vladimir Oltean <[email protected]> writes:
>>
>> I don't really like these prefixes, I am thinking of when support for
>> IEEE 802.1CB is added, do we rename this to "hsr_prp_frer"?
>>
>> And it gets even more complicated, and using 802.1CB you can configure
>> the tagging method and the stream identification function so a system
>> can interoperate in a HSR or PRP network.
>>
>
> Is it a given that 802.1CB in Linux should be implemented using an hsr
> upper device?
What I was trying to express is the idea of using "hsr" as the directory
name/prefix for all the features that deal with frame replication for
reliability, including 802.1CB. At least until we find a better name.
> 802.1CB is _much_ more flexible than both HSR and PRP. You can have
> more than 2 ports, you can have per-stream rules (each stream has its
> own sequence number), and those rules can identify the source, the
> destination, or both the source and the destination.
Same understanding here.
Cheers,
--
Vinicius
Hi Murali,
On Tue, 26 May 2020 at 17:12, Murali Karicheri <[email protected]> wrote:
>
> Hi Vladimir,
>
> I haven't looked the spec for 802.1CB. If they re-use HSR/PRP Tag in the
> L2 protocol it make sense to enhance the driver. Else I don't see any
> re-use possibility. Do you know the above?
>
> Thanks
>
> Murali
IEEE 802.1CB redundancy tag sits between Source MAC address and
Ethertype or any VLAN tag, is 6 bytes in length, of which:
- first 2 bytes are the 0xf1c1 EtherType
- next 2 bytes are reserved
- last 2 bytes are the sequence number
There is also a pre-standard version of the IEEE 802.1CB redundancy
tag, which is only 4 bytes in length. I assume vendors of pre-standard
equipment will want to have support for this 4-byte tag as well, as
well as a mechanism of converting between HSR/PRP/pre-standard 802.1CB
tag on one set of ports, and 802.1CB on another set of ports.
>
> --
> Murali Karicheri
> Texas Instruments
Thanks,
-Vladimir
Murali Karicheri <[email protected]> writes:
> Hi Vinicius,
>
> On 5/21/20 1:31 PM, Vinicius Costa Gomes wrote:
>> Murali Karicheri <[email protected]> writes:
>>
> ------------ Snip-------------
>
>>> - prefix all common code with hsr_prp
>>> - net/hsr -> renamed to net/hsr-prp
>>> - All common struct types, constants, functions renamed with
>>> hsr{HSR}_prp{PRP} prefix.
>>
>> I don't really like these prefixes, I am thinking of when support for
>> IEEE 802.1CB is added, do we rename this to "hsr_prp_frer"?
>>
>> And it gets even more complicated, and using 802.1CB you can configure
>> the tagging method and the stream identification function so a system
>> can interoperate in a HSR or PRP network.
>>
>> So, I see this as different methods of achieving the same result, which
>> makes me think that the different "methods/types" (HSR and PRP in your
>> case) should be basically different implementations of a "struct
>> hsr_ops" interface. With this hsr_ops something like this:
>>
>> struct hsr_ops {
>> int (*handle_frame)()
>> int (*add_port)()
>> int (*remove_port)()
>> int (*setup)()
>> void (*teardown)()
>> };
>>
>
> Thanks for your response!
>
> I agree with you that the prefix renaming is ugly. However I wasn't
> sure if it is okay to use a hsr prefixed code to handle PRP as
> well as it may not be intuitive to anyone investigating the code. For
> the same reason, handling 802.1CB specifc functions using the hsr_
> prefixed code. If that is okay, then patch 1-6 are unnecessary. We could
> also add some documentation at the top of the file to indicate that
> both hsr and prp are implemented in the code or something like that.
> BTW, I need to investigate more into 802.1CB and this was not known
> when I developed this code few years ago.
I think for now it's better to make it clear how similar PRP and HSR
are.
As for the renaming, I am afraid that this boat has sailed, as the
netlink API already uses HSR_ and it's better to reuse that than create
a new family for, at least conceptually, the same thing (PRP and
802.1CB). And this is important bit, the userspace API.
And even for 802.1CB using name "High-availability Seamless Redudancy"
is as good as any, if very pompous.
>
> Main difference between HSR and PRP is how they handle the protocol tag
> or rct and create or handle the protocol specific part in the frame.
> For that part, we should be able to define ops() like you have
> suggested, instead of doing if check throughout the code. Hope that
> is what you meant by hsr_ops() for this. Again shouldn't we use some
> generic name like proto_ops or red_ops instead of hsr_ops() and assign
> protocol specific implementaion to them? i.e hsr_ or prp_
> or 802.1CB specific functions assigned to the function pointers. For
> now I see handle_frame(), handle_sv_frame, create_frame(),
> create_sv_frame() etc implemented differently (This is currently part of
> patch 11 & 12). So something like
>
> struct proto_ops {
> int (*handle_frame)();
> int (*create_frame)();
> int (*handle_sv_frame)();
> int (*create_sv_frame)();
> };
That's it. That was the idea I was trying to communicate :-)
>
> and call dev->proto_ops->handle_frame() to process a frame from the
> main hook. proto_ops gets initialized to of the set if implementation
> at device or interface creation in hsr_dev_finalize().
>
>>>
>>> Please review this and provide me feedback so that I can work to
>>> incorporate them and send a formal patch series for this. As this
>>> series impacts user space, I am not sure if this is the right
>>> approach to introduce a new definitions and obsolete the old
>>> API definitions for HSR. The current approach is choosen
>>> to avoid redundant code in iproute2 and in the netlink driver
>>> code (hsr_netlink.c). Other approach we discussed internally was
>>> to Keep the HSR prefix in the user space and kernel code, but
>>> live with the redundant code in the iproute2 and hsr netlink
>>> code. Would like to hear from you what is the best way to add
>>> this feature to networking core. If there is any other
>>> alternative approach possible, I would like to hear about the
>>> same.
>>
>> Why redudant code is needed in the netlink parts and in iproute2 when
>> keeping the hsr prefix?
>
> May be this is due to the specific implementation that I chose.
> Currently I have separate netlink socket for HSR and PRP which may
> be an overkill since bith are similar protocol.
>
> Currently hsr inteface is created as
>
> ip link add name hsr0 type hsr slave1 eth0 slave2 eth1 supervision 0
>
> So I have implemented similar command for prp
>
> ip link add name prp0 type prp slave1 eth0 slave2 eth1 supervision 0
>
> In patch 7/13 I renamed existing HSR netlink socket attributes that
> defines the hsr interface with the assumption that we can obsolete
> the old definitions in favor of new common definitions with the
> HSR_PRP prefix. Then I have separate code for creating prp
> interface and related functions, even though they are similar.
> So using common definitions, I re-use the code in netlink and
> iproute2 (see patch 8 and 9 to re-use the code). PRP netlink
> socket code in patch 10 which register prp_genl_family similar
> to HSR.
Deprecating an userspace API is hard and takes a long time. So let's
avoid that if it makes sense.
>
> +static struct genl_family prp_genl_family __ro_after_init = {
> + .hdrsize = 0,
> + .name = "PRP",
> + .version = 1,
> + .maxattr = HSR_PRP_A_MAX,
> + .policy = prp_genl_policy,
> + .module = THIS_MODULE,
> + .ops = prp_ops,
> + .n_ops = ARRAY_SIZE(prp_ops),
> + .mcgrps = prp_mcgrps,
> + .n_mcgrps = ARRAY_SIZE(prp_mcgrps),
> +};
> +
> +int __init prp_netlink_init(void)
> +{
> + int rc;
> +
> + rc = rtnl_link_register(&prp_link_ops);
> + if (rc)
> + goto fail_rtnl_link_register;
> +
> + rc = genl_register_family(&prp_genl_family);
> + if (rc)
> + goto fail_genl_register_family;
>
>
> If we choose to re-use the existing HSR_ uapi defines, then should we
> re-use the hsr netlink socket interface for PRP as well and
> add additional attribute for differentiating the protocol specific
> part?
Yes, that seems the way to go.
>
> i.e introduce protocol attribute to existing HSR uapi defines for
> netlink socket to handle creation of prp interface.
>
> enum {
> HSR_A_UNSPEC,
> HSR_A_NODE_ADDR,
> HSR_A_IFINDEX,
> HSR_A_IF1_AGE,
> HSR_A_IF2_AGE,
> HSR_A_NODE_ADDR_B,
> HSR_A_IF1_SEQ,
> HSR_A_IF2_SEQ,
> HSR_A_IF1_IFINDEX,
> HSR_A_IF2_IFINDEX,
> HSR_A_ADDR_B_IFINDEX,
> + HSR_A_PROTOCOL <====if missing it is HSR (backward
> compatibility)
> defines HSR or PRP or 802.1CB in future.
> __HSR_A_MAX,
> };
>
> So if ip link command is
>
> ip link add name <if name> type <proto> slave1 eth0 slave2 eth1
> supervision 0
>
> Add HSR_A_PROTOCOL attribute with HSR/PRP specific value.
>
> This way, the iprout2 code mostly remain the same as hsr, but will
> change a bit to introduced this new attribute if user choose proto as
> 'prp' vs 'hsr'
Sounds good, I think.
>
> BTW, I have posted the existing iproute2 code also to the mailing list
> with title 'iproute2: Add PRP support'.
>
> If re-using hsr code with existing prefix is fine for PRP or any future
> protocol such as 801.1B, then I will drop patch 1-6 that are essentially
> doing some renaming and re-use existing hsr netlink code for PRP with
> added attribute to differentiate the protocol at the driver as described
> above along with proto_ops and re-spin the series.
If I forget that HSR is also the name of a protocol, what the acronym
means makes sense for 802.1CB, so it's not too bad, I think.
>
> Let me know.
>
> Regards,
>
> Murali
Cheers,
--
Vinicius
Hi Vladimir
On 5/26/20 2:25 PM, Vladimir Oltean wrote:
> Hi Murali,
>
> On Tue, 26 May 2020 at 17:12, Murali Karicheri <[email protected]> wrote:
>>
>> Hi Vladimir,
>>
>
>> I haven't looked the spec for 802.1CB. If they re-use HSR/PRP Tag in the
>> L2 protocol it make sense to enhance the driver. Else I don't see any
>> re-use possibility. Do you know the above?
>>
>> Thanks
>>
>> Murali
>
> IEEE 802.1CB redundancy tag sits between Source MAC address and
> Ethertype or any VLAN tag, is 6 bytes in length, of which:
> - first 2 bytes are the 0xf1c1 EtherType
> - next 2 bytes are reserved
> - last 2 bytes are the sequence number
> There is also a pre-standard version of the IEEE 802.1CB redundancy
> tag, which is only 4 bytes in length. I assume vendors of pre-standard
> equipment will want to have support for this 4-byte tag as well, as
> well as a mechanism of converting between HSR/PRP/pre-standard 802.1CB
> tag on one set of ports, and 802.1CB on another set of ports.
>
Thanks for sharing the details. I also took a quick glance at the
802.1CB spec today. It answered also my above question
1) In addition to FRER tag, it also includes HSR tag and PRP trailer
that can be provisioned through management objects.
2) Now I think I get what Vinicius refers to the interoperability. there
can be HSR tag received on ingress port and PRP on the egress port of
a relay function.
Essentially tag usage is configurable on a stream basis. Since both
HSR and PRP functions for frame formatting and decoding would be
re-usable. In addition driver could be enhanced for FRER functions.
Regards,
Murali
>>
>> --
>> Murali Karicheri
>> Texas Instruments
>
> Thanks,
> -Vladimir
>
--
Murali Karicheri
Texas Instruments
Hi Vinicius,
On 5/26/20 2:56 PM, Vinicius Costa Gomes wrote:
> Murali Karicheri <[email protected]> writes:
>
>> Hi Vinicius,
>>
>> On 5/21/20 1:31 PM, Vinicius Costa Gomes wrote:
>>> Murali Karicheri <[email protected]> writes:
>>>
>> ------------ Snip-------------
>>> So, I see this as different methods of achieving the same result, which
>>> makes me think that the different "methods/types" (HSR and PRP in your
>>> case) should be basically different implementations of a "struct
>>> hsr_ops" interface. With this hsr_ops something like this:
>>>
>>> struct hsr_ops {
>>> int (*handle_frame)()
>>> int (*add_port)()
>>> int (*remove_port)()
>>> int (*setup)()
>>> void (*teardown)()
>>> };
>>>
>>
>> Thanks for your response!
>>
>> I agree with you that the prefix renaming is ugly. However I wasn't
>> sure if it is okay to use a hsr prefixed code to handle PRP as
>> well as it may not be intuitive to anyone investigating the code. For
>> the same reason, handling 802.1CB specifc functions using the hsr_
>> prefixed code. If that is okay, then patch 1-6 are unnecessary. We could
>> also add some documentation at the top of the file to indicate that
>> both hsr and prp are implemented in the code or something like that.
>> BTW, I need to investigate more into 802.1CB and this was not known
>> when I developed this code few years ago.
>
> I think for now it's better to make it clear how similar PRP and HSR
> are.
>
> As for the renaming, I am afraid that this boat has sailed, as the
> netlink API already uses HSR_ and it's better to reuse that than create
> a new family for, at least conceptually, the same thing (PRP and
> 802.1CB). And this is important bit, the userspace API.
>
> And even for 802.1CB using name "High-availability Seamless Redudancy"
> is as good as any, if very pompous.
> I have reviewed the 802.1CB at a high level. The idea of 802.1CB is
also high availability and redundancy similar to HSR and PRP but at
stream level. So now I feel more comfortable to re-use the hsr prefix
until we find a better name. I can document this in all file headers to
make this explicit when I spin the formal patch for this. I will wait
for a couple of weeks before start the work on a formal patch
series so that others have a chance to respond as well.
>>
>> Main difference between HSR and PRP is how they handle the protocol tag
>> or rct and create or handle the protocol specific part in the frame.
>> For that part, we should be able to define ops() like you have
>> suggested, instead of doing if check throughout the code. Hope that
>> is what you meant by hsr_ops() for this. Again shouldn't we use some
>> generic name like proto_ops or red_ops instead of hsr_ops() and assign
>> protocol specific implementaion to them? i.e hsr_ or prp_
>> or 802.1CB specific functions assigned to the function pointers. For
>> now I see handle_frame(), handle_sv_frame, create_frame(),
>> create_sv_frame() etc implemented differently (This is currently part of
>> patch 11 & 12). So something like
>>
>> struct proto_ops {
>> int (*handle_frame)();
>> int (*create_frame)();
>> int (*handle_sv_frame)();
>> int (*create_sv_frame)();
>> };
>
> That's it. That was the idea I was trying to communicate :-)
>
Ok
>>
>> and call dev->proto_ops->handle_frame() to process a frame from the
>> main hook. proto_ops gets initialized to of the set if implementation
>> at device or interface creation in hsr_dev_finalize().
>>
>>>>
>>>> Please review this and provide me feedback so that I can work to
>>>> incorporate them and send a formal patch series for this. As this
>>>> series impacts user space, I am not sure if this is the right
>>>> approach to introduce a new definitions and obsolete the old
>>>> API definitions for HSR. The current approach is choosen
>>>> to avoid redundant code in iproute2 and in the netlink driver
>>>> code (hsr_netlink.c). Other approach we discussed internally was
>>>> to Keep the HSR prefix in the user space and kernel code, but
>>>> live with the redundant code in the iproute2 and hsr netlink
>>>> code. Would like to hear from you what is the best way to add
>>>> this feature to networking core. If there is any other
>>>> alternative approach possible, I would like to hear about the
>>>> same.
>>>
>>> Why redudant code is needed in the netlink parts and in iproute2 when
>>> keeping the hsr prefix?
>>
>> May be this is due to the specific implementation that I chose.
>> Currently I have separate netlink socket for HSR and PRP which may
>> be an overkill since bith are similar protocol.
>>
>> Currently hsr inteface is created as
>>
>> ip link add name hsr0 type hsr slave1 eth0 slave2 eth1 supervision 0
>>
>> So I have implemented similar command for prp
>>
>> ip link add name prp0 type prp slave1 eth0 slave2 eth1 supervision 0
>>
>> In patch 7/13 I renamed existing HSR netlink socket attributes that
>> defines the hsr interface with the assumption that we can obsolete
>> the old definitions in favor of new common definitions with the
>> HSR_PRP prefix. Then I have separate code for creating prp
>> interface and related functions, even though they are similar.
>> So using common definitions, I re-use the code in netlink and
>> iproute2 (see patch 8 and 9 to re-use the code). PRP netlink
>> socket code in patch 10 which register prp_genl_family similar
>> to HSR.
>
> Deprecating an userspace API is hard and takes a long time. So let's
> avoid that if it makes sense.
>
Ok, make sense.
>>
>> +static struct genl_family prp_genl_family __ro_after_init = {
>> + .hdrsize = 0,
>> + .name = "PRP",
>> + .version = 1,
>> + .maxattr = HSR_PRP_A_MAX,
>> + .policy = prp_genl_policy,
>> + .module = THIS_MODULE,
>> + .ops = prp_ops,
>> + .n_ops = ARRAY_SIZE(prp_ops),
>> + .mcgrps = prp_mcgrps,
>> + .n_mcgrps = ARRAY_SIZE(prp_mcgrps),
>> +};
>> +
>> +int __init prp_netlink_init(void)
>> +{
>> + int rc;
>> +
>> + rc = rtnl_link_register(&prp_link_ops);
>> + if (rc)
>> + goto fail_rtnl_link_register;
>> +
>> + rc = genl_register_family(&prp_genl_family);
>> + if (rc)
>> + goto fail_genl_register_family;
>>
>>
>> If we choose to re-use the existing HSR_ uapi defines, then should we
>> re-use the hsr netlink socket interface for PRP as well and
>> add additional attribute for differentiating the protocol specific
>> part?
>
> Yes, that seems the way to go.
>
Ok.
>>
>> i.e introduce protocol attribute to existing HSR uapi defines for
>> netlink socket to handle creation of prp interface.
>>
>> enum {
>> HSR_A_UNSPEC,
>> HSR_A_NODE_ADDR,
>> HSR_A_IFINDEX,
>> HSR_A_IF1_AGE,
>> HSR_A_IF2_AGE,
>> HSR_A_NODE_ADDR_B,
>> HSR_A_IF1_SEQ,
>> HSR_A_IF2_SEQ,
>> HSR_A_IF1_IFINDEX,
>> HSR_A_IF2_IFINDEX,
>> HSR_A_ADDR_B_IFINDEX,
>> + HSR_A_PROTOCOL <====if missing it is HSR (backward
>> compatibility)
>> defines HSR or PRP or 802.1CB in future.
>> __HSR_A_MAX,
>> };
>>
>> So if ip link command is
>>
>> ip link add name <if name> type <proto> slave1 eth0 slave2 eth1
>> supervision 0
>>
>> Add HSR_A_PROTOCOL attribute with HSR/PRP specific value.
>>
>> This way, the iprout2 code mostly remain the same as hsr, but will
>> change a bit to introduced this new attribute if user choose proto as
>> 'prp' vs 'hsr'
>
> Sounds good, I think.
Ok. If we want to add 802.1CB later, specific value used can be
extended to use 802.1CB.
>
>>
>> BTW, I have posted the existing iproute2 code also to the mailing list
>> with title 'iproute2: Add PRP support'.
>>
>> If re-using hsr code with existing prefix is fine for PRP or any future
>> protocol such as 801.1B, then I will drop patch 1-6 that are essentially
>> doing some renaming and re-use existing hsr netlink code for PRP with
>> added attribute to differentiate the protocol at the driver as described
>> above along with proto_ops and re-spin the series.
>
> If I forget that HSR is also the name of a protocol, what the acronym
> means makes sense for 802.1CB, so it's not too bad, I think.
>
Agree.
>>
>> Let me know.
>>
>> Regards,
>>
>> Murali
>
>
> Cheers,
>
--
Murali Karicheri
Texas Instruments