]> www.infradead.org Git - users/willy/xarray.git/commitdiff
hsr: enhance netlink socket interface to support PRP
authorMurali Karicheri <m-karicheri2@ti.com>
Wed, 22 Jul 2020 14:40:16 +0000 (10:40 -0400)
committerDavid S. Miller <davem@davemloft.net>
Mon, 27 Jul 2020 19:20:40 +0000 (12:20 -0700)
Parallel Redundancy Protocol (PRP) is another redundancy protocol
introduced by IEC 63439 standard. It is similar to HSR in many
aspects:-

 - Use a pair of Ethernet interfaces to created the PRP device
 - Use a 6 byte redundancy protocol part (RCT, Redundancy Check
   Trailer) similar to HSR Tag.
 - Has Link Redundancy Entity (LRE) that works with RCT to implement
   redundancy.

Key difference is that the protocol unit is a trailer instead of a
prefix as in HSR. That makes it inter-operable with tradition network
components such as bridges/switches which treat it as pad bytes,
whereas HSR nodes requires some kind of translators (Called redbox) to
talk to regular network devices. This features allows regular linux box
to be converted to a DAN-P box. DAN-P stands for Dual Attached Node - PRP
similar to DAN-H (Dual Attached Node - HSR).

Add a comment at the header/source code to explicitly state that the
driver files also handles PRP protocol as well.

Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
16 files changed:
include/uapi/linux/hsr_netlink.h
include/uapi/linux/if_link.h
net/hsr/Kconfig
net/hsr/hsr_debugfs.c
net/hsr/hsr_device.c
net/hsr/hsr_device.h
net/hsr/hsr_forward.c
net/hsr/hsr_forward.h
net/hsr/hsr_framereg.c
net/hsr/hsr_framereg.h
net/hsr/hsr_main.c
net/hsr/hsr_main.h
net/hsr/hsr_netlink.c
net/hsr/hsr_netlink.h
net/hsr/hsr_slave.c
net/hsr/hsr_slave.h

index c218ef9c35dd547d3be567f129059cbf206e8c7a..d540ea9bbef4b0563310832b1e772ea87f0fc2f7 100644 (file)
@@ -17,7 +17,7 @@
 /* Generic Netlink HSR family definition
  */
 
-/* attributes */
+/* attributes for HSR or PRP node */
 enum {
        HSR_A_UNSPEC,
        HSR_A_NODE_ADDR,
index af8f3198752622baae5b3ef4f0225411e1c76d96..63af646463582df49f47b72df63436738de2b77c 100644 (file)
@@ -907,7 +907,14 @@ enum {
 #define IFLA_IPOIB_MAX (__IFLA_IPOIB_MAX - 1)
 
 
-/* HSR section */
+/* HSR/PRP section, both uses same interface */
+
+/* Different redundancy protocols for hsr device */
+enum {
+       HSR_PROTOCOL_HSR,
+       HSR_PROTOCOL_PRP,
+       HSR_PROTOCOL_MAX,
+};
 
 enum {
        IFLA_HSR_UNSPEC,
@@ -917,6 +924,9 @@ enum {
        IFLA_HSR_SUPERVISION_ADDR,      /* Supervision frame multicast addr */
        IFLA_HSR_SEQ_NR,
        IFLA_HSR_VERSION,               /* HSR version */
+       IFLA_HSR_PROTOCOL,              /* Indicate different protocol than
+                                        * HSR. For example PRP.
+                                        */
        __IFLA_HSR_MAX,
 };
 
index 8095b034e76e475d76095b950b66deff49efb584..1b048c17b6c835373cfe4a4f68925fe69be78e86 100644 (file)
@@ -4,24 +4,35 @@
 #
 
 config HSR
-       tristate "High-availability Seamless Redundancy (HSR)"
+       tristate "High-availability Seamless Redundancy (HSR & PRP)"
        help
+         This enables IEC 62439 defined High-availability Seamless
+         Redundancy (HSR) and Parallel Redundancy Protocol (PRP).
+
          If you say Y here, then your Linux box will be able to act as a
-         DANH ("Doubly attached node implementing HSR"). For this to work,
-         your Linux box needs (at least) two physical Ethernet interfaces,
-         and it must be connected as a node in a ring network together with
-         other HSR capable nodes.
+         DANH ("Doubly attached node implementing HSR") or DANP ("Doubly
+         attached node implementing PRP"). For this to work, your Linux box
+         needs (at least) two physical Ethernet interfaces.
+
+         For DANH, it must be connected as a node in a ring network together
+         with other HSR capable nodes. All Ethernet frames sent over the HSR
+         device will be sent in both directions on the ring (over both slave
+         ports), giving a redundant, instant fail-over network. Each HSR node
+         in the ring acts like a bridge for HSR frames, but filters frames
+         that have been forwarded earlier.
 
-         All Ethernet frames sent over the hsr device will be sent in both
-         directions on the ring (over both slave ports), giving a redundant,
-         instant fail-over network. Each HSR node in the ring acts like a
-         bridge for HSR frames, but filters frames that have been forwarded
-         earlier.
+         For DANP, it must be connected as a node connecting to two
+         separate networks over the two slave interfaces. Like HSR, Ethernet
+         frames sent over the PRP device will be sent to both networks giving
+         a redundant, instant fail-over network. Unlike HSR, PRP networks
+         can have Singly Attached Nodes (SAN) such as PC, printer, bridges
+         etc and will be able to communicate with DANP nodes.
 
          This code is a "best effort" to comply with the HSR standard as
          described in IEC 62439-3:2010 (HSRv0) and IEC 62439-3:2012 (HSRv1),
-         but no compliancy tests have been made. Use iproute2 to select
-         the version you desire.
+         and PRP standard described in IEC 62439-4:2012 (PRP), but no
+         compliancy tests have been made. Use iproute2 to select the protocol
+         you would like to use.
 
          You need to perform any and all necessary tests yourself before
          relying on this code in a safety critical system!
index 9787ef11ca71cd7e9171d6edec63e44f5b172f37..c1932c0a15be9c603e163a6d292a73dbb22804ed 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * hsr_debugfs code
+ * debugfs code for HSR & PRP
  * Copyright (C) 2019 Texas Instruments Incorporated
  *
  * Author(s):
index 8a927b647829d1bc37bd3586746559d86b91b2db..40ac45123a62118eff294e68eb9b7e9c7f9a63ef 100644 (file)
@@ -3,9 +3,8 @@
  *
  * Author(s):
  *     2011-2014 Arvid Brodin, arvid.brodin@alten.se
- *
  * This file contains device methods for creating, using and destroying
- * virtual HSR devices.
+ * virtual HSR or PRP devices.
  */
 
 #include <linux/netdevice.h>
@@ -427,6 +426,10 @@ int hsr_dev_finalize(struct net_device *hsr_dev, struct net_device *slave[2],
 
        ether_addr_copy(hsr_dev->dev_addr, slave[0]->dev_addr);
 
+       /* currently PRP is not supported */
+       if (protocol_version == PRP_V1)
+               return -EPROTONOSUPPORT;
+
        /* Make sure we recognize frames from ourselves in hsr_rcv() */
        res = hsr_create_self_node(hsr, hsr_dev->dev_addr,
                                   slave[1]->dev_addr);
index b8f9262ed101aceb1bcc65ef4558c62f6d79f6fb..868373822ee4cc883f35e796f213d8a40cd06407 100644 (file)
@@ -3,6 +3,8 @@
  *
  * Author(s):
  *     2011-2014 Arvid Brodin, arvid.brodin@alten.se
+ *
+ * include file for HSR and PRP.
  */
 
 #ifndef __HSR_DEVICE_H
index ab8dca0c0b65317ed77f6d2c0266f10ab6414c7b..55adb4dbd235fdccbe1b756cc1dc1ae5cd6a1535 100644 (file)
@@ -3,6 +3,8 @@
  *
  * Author(s):
  *     2011-2014 Arvid Brodin, arvid.brodin@alten.se
+ *
+ * Frame router for HSR and PRP.
  */
 
 #include "hsr_forward.h"
index 51a69295566cf683d2879493ab3f9857297941a2..b2a6fa319d944d30c6321f6c9ce46411d83c68b7 100644 (file)
@@ -3,6 +3,8 @@
  *
  * Author(s):
  *     2011-2014 Arvid Brodin, arvid.brodin@alten.se
+ *
+ * include file for HSR and PRP.
  */
 
 #ifndef __HSR_FORWARD_H
index 530de24b1fb5739021088f786eda0a2c5c37e45f..13b2190e6556e859570e52fc67f286f0f35aa7a8 100644 (file)
@@ -8,6 +8,7 @@
  * interface. A frame is identified by its source MAC address and its HSR
  * sequence number. This code keeps track of senders and their sequence numbers
  * to allow filtering of duplicate frames, and to detect HSR ring errors.
+ * Same code handles filtering of duplicates for PRP as well.
  */
 
 #include <linux/if_ether.h>
index 0f0fa12b432937fdae50dc2f57953fffe238c20b..c06447780d057540f3338afe43fe7717dbebc322 100644 (file)
@@ -3,6 +3,8 @@
  *
  * Author(s):
  *     2011-2014 Arvid Brodin, arvid.brodin@alten.se
+ *
+ * include file for HSR and PRP.
  */
 
 #ifndef __HSR_FRAMEREG_H
index 144da15f0a817028d4248e026fd1b18ad5e2045b..2fd1976e5b1c3865773f41e765e45bd5f2b5f296 100644 (file)
@@ -3,6 +3,8 @@
  *
  * Author(s):
  *     2011-2014 Arvid Brodin, arvid.brodin@alten.se
+ *
+ * Event handling for HSR and PRP devices.
  */
 
 #include <linux/netdevice.h>
index f74193465bf5bee638742c67fa1a415a480eee24..8cf10d67d5f96017e207660a6c5eb3d027e74bfd 100644 (file)
@@ -3,6 +3,8 @@
  *
  * Author(s):
  *     2011-2014 Arvid Brodin, arvid.brodin@alten.se
+ *
+ * include file for HSR and PRP.
  */
 
 #ifndef __HSR_PRIVATE_H
@@ -131,6 +133,13 @@ struct hsr_port {
        enum hsr_port_type      type;
 };
 
+/* used by driver internally to differentiate various protocols */
+enum hsr_version {
+       HSR_V0 = 0,
+       HSR_V1,
+       PRP_V1,
+};
+
 struct hsr_priv {
        struct rcu_head         rcu_head;
        struct list_head        ports;
@@ -141,7 +150,7 @@ struct hsr_priv {
        int announce_count;
        u16 sequence_nr;
        u16 sup_sequence_nr;    /* For HSRv1 separate seq_nr for supervision */
-       u8 prot_version;        /* Indicate if HSRv0 or HSRv1. */
+       enum hsr_version prot_version;  /* Indicate if HSRv0, HSRv1 or PRPv1 */
        spinlock_t seqnr_lock;  /* locking for sequence_nr */
        spinlock_t list_lock;   /* locking for node list */
        unsigned char           sup_multicast_addr[ETH_ALEN];
index 6e14b7d2263992742a69203956da7dd5da448fdf..06c3cd98876076f2223fcdfc434af6074282c6b8 100644 (file)
@@ -4,7 +4,7 @@
  * Author(s):
  *     2011-2014 Arvid Brodin, arvid.brodin@alten.se
  *
- * Routines for handling Netlink messages for HSR.
+ * Routines for handling Netlink messages for HSR and PRP.
  */
 
 #include "hsr_netlink.h"
@@ -22,6 +22,7 @@ static const struct nla_policy hsr_policy[IFLA_HSR_MAX + 1] = {
        [IFLA_HSR_VERSION]      = { .type = NLA_U8 },
        [IFLA_HSR_SUPERVISION_ADDR]     = { .len = ETH_ALEN },
        [IFLA_HSR_SEQ_NR]               = { .type = NLA_U16 },
+       [IFLA_HSR_PROTOCOL]             = { .type = NLA_U8 },
 };
 
 /* Here, it seems a netdevice has already been allocated for us, and the
@@ -31,8 +32,10 @@ static int hsr_newlink(struct net *src_net, struct net_device *dev,
                       struct nlattr *tb[], struct nlattr *data[],
                       struct netlink_ext_ack *extack)
 {
+       enum hsr_version proto_version;
+       unsigned char multicast_spec;
+       u8 proto = HSR_PROTOCOL_HSR;
        struct net_device *link[2];
-       unsigned char multicast_spec, hsr_version;
 
        if (!data) {
                NL_SET_ERR_MSG_MOD(extack, "No slave devices specified");
@@ -69,18 +72,34 @@ static int hsr_newlink(struct net *src_net, struct net_device *dev,
        else
                multicast_spec = nla_get_u8(data[IFLA_HSR_MULTICAST_SPEC]);
 
+       if (data[IFLA_HSR_PROTOCOL])
+               proto = nla_get_u8(data[IFLA_HSR_PROTOCOL]);
+
+       if (proto >= HSR_PROTOCOL_MAX) {
+               NL_SET_ERR_MSG_MOD(extack, "Unsupported protocol\n");
+               return -EINVAL;
+       }
+
        if (!data[IFLA_HSR_VERSION]) {
-               hsr_version = 0;
+               proto_version = HSR_V0;
        } else {
-               hsr_version = nla_get_u8(data[IFLA_HSR_VERSION]);
-               if (hsr_version > 1) {
+               if (proto == HSR_PROTOCOL_PRP) {
+                       NL_SET_ERR_MSG_MOD(extack, "PRP version unsupported\n");
+                       return -EINVAL;
+               }
+
+               proto_version = nla_get_u8(data[IFLA_HSR_VERSION]);
+               if (proto_version > HSR_V1) {
                        NL_SET_ERR_MSG_MOD(extack,
-                                          "Only versions 0..1 are supported");
+                                          "Only HSR version 0/1 supported\n");
                        return -EINVAL;
                }
        }
 
-       return hsr_dev_finalize(dev, link, multicast_spec, hsr_version, extack);
+       if (proto == HSR_PROTOCOL_PRP)
+               proto_version = PRP_V1;
+
+       return hsr_dev_finalize(dev, link, multicast_spec, proto_version, extack);
 }
 
 static void hsr_dellink(struct net_device *dev, struct list_head *head)
@@ -102,6 +121,7 @@ static void hsr_dellink(struct net_device *dev, struct list_head *head)
 static int hsr_fill_info(struct sk_buff *skb, const struct net_device *dev)
 {
        struct hsr_priv *hsr = netdev_priv(dev);
+       u8 proto = HSR_PROTOCOL_HSR;
        struct hsr_port *port;
 
        port = hsr_port_get_hsr(hsr, HSR_PT_SLAVE_A);
@@ -120,6 +140,10 @@ static int hsr_fill_info(struct sk_buff *skb, const struct net_device *dev)
                    hsr->sup_multicast_addr) ||
            nla_put_u16(skb, IFLA_HSR_SEQ_NR, hsr->sequence_nr))
                goto nla_put_failure;
+       if (hsr->prot_version == PRP_V1)
+               proto = HSR_PROTOCOL_PRP;
+       if (nla_put_u8(skb, IFLA_HSR_PROTOCOL, proto))
+               goto nla_put_failure;
 
        return 0;
 
index 1121bb192a18e8be5a15320907327b427f3b4c29..501552d9753b9ad1895220d22718b6483428a31e 100644 (file)
@@ -3,6 +3,8 @@
  *
  * Author(s):
  *     2011-2014 Arvid Brodin, arvid.brodin@alten.se
+ *
+ * include file for HSR and PRP.
  */
 
 #ifndef __HSR_NETLINK_H
index 25b6ffba26cde9eb80f79d4853a735c0d250ef6b..b5c0834de338f401dd61b689b834a252699aaf90 100644 (file)
@@ -3,6 +3,8 @@
  *
  * Author(s):
  *     2011-2014 Arvid Brodin, arvid.brodin@alten.se
+ *
+ * Frame handler other utility functions for HSR and PRP.
  */
 
 #include "hsr_slave.h"
index 8953ea279ce9c6ebdf08099ecd14f5c817ec83c4..9708a4f0ec09daa85200ea511018e76971b6a221 100644 (file)
@@ -2,6 +2,8 @@
 /* Copyright 2011-2014 Autronica Fire and Security AS
  *
  *     2011-2014 Arvid Brodin, arvid.brodin@alten.se
+ *
+ * include file for HSR and PRP.
  */
 
 #ifndef __HSR_SLAVE_H