From: Murali Karicheri <m-karicheri2@ti.com>
To: <davem@davemloft.net>, <kuba@kernel.org>,
<netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<linux-api@vger.kernel.org>, <nsekhar@ti.com>,
<grygorii.strashko@ti.com>, <vinicius.gomes@intel.com>
Subject: [net-next iproute2 PATCH v2 1/2] iplink: hsr: add support for creating PRP device similar to HSR
Date: Wed, 15 Jul 2020 12:40:11 -0400 [thread overview]
Message-ID: <20200715164012.1222-11-m-karicheri2@ti.com> (raw)
In-Reply-To: <20200715164012.1222-1-m-karicheri2@ti.com>
This patch enhances the iplink command to add a proto parameters to
create PRP device/interface similar to HSR. Both protocols are
quite similar and requires a pair of Ethernet interfaces. So re-use
the existing HSR iplink command to create PRP device/interface as
well. Use proto parameter to differentiate the two protocols.
Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
---
include/uapi/linux/if_link.h | 12 +++++++++++-
ip/iplink_hsr.c | 19 +++++++++++++++++--
2 files changed, 28 insertions(+), 3 deletions(-)
diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h
index a8901a39a345..fa2e3f642deb 100644
--- a/include/uapi/linux/if_link.h
+++ b/include/uapi/linux/if_link.h
@@ -904,7 +904,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,
@@ -914,6 +921,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,
};
diff --git a/ip/iplink_hsr.c b/ip/iplink_hsr.c
index 7d9167d4e6a3..6ea138a23cbc 100644
--- a/ip/iplink_hsr.c
+++ b/ip/iplink_hsr.c
@@ -25,7 +25,7 @@ static void print_usage(FILE *f)
{
fprintf(f,
"Usage:\tip link add name NAME type hsr slave1 SLAVE1-IF slave2 SLAVE2-IF\n"
- "\t[ supervision ADDR-BYTE ] [version VERSION]\n"
+ "\t[ supervision ADDR-BYTE ] [version VERSION] [proto PROTOCOL]\n"
"\n"
"NAME\n"
" name of new hsr device (e.g. hsr0)\n"
@@ -35,7 +35,9 @@ static void print_usage(FILE *f)
" 0-255; the last byte of the multicast address used for HSR supervision\n"
" frames (default = 0)\n"
"VERSION\n"
- " 0,1; the protocol version to be used. (default = 0)\n");
+ " 0,1; the protocol version to be used. (default = 0)\n"
+ "PROTOCOL\n"
+ " 0 - HSR, 1 - PRP. (default = 0 - HSR)\n");
}
static void usage(void)
@@ -49,6 +51,7 @@ static int hsr_parse_opt(struct link_util *lu, int argc, char **argv,
int ifindex;
unsigned char multicast_spec;
unsigned char protocol_version;
+ unsigned char protocol = HSR_PROTOCOL_HSR;
while (argc > 0) {
if (matches(*argv, "supervision") == 0) {
@@ -64,6 +67,13 @@ static int hsr_parse_opt(struct link_util *lu, int argc, char **argv,
invarg("version is invalid", *argv);
addattr_l(n, 1024, IFLA_HSR_VERSION,
&protocol_version, 1);
+ } else if (matches(*argv, "proto") == 0) {
+ NEXT_ARG();
+ if (!(get_u8(&protocol, *argv, 0) == HSR_PROTOCOL_HSR ||
+ get_u8(&protocol, *argv, 0) == HSR_PROTOCOL_PRP))
+ invarg("protocol is invalid", *argv);
+ addattr_l(n, 1024, IFLA_HSR_PROTOCOL,
+ &protocol, 1);
} else if (matches(*argv, "slave1") == 0) {
NEXT_ARG();
ifindex = ll_name_to_index(*argv);
@@ -140,6 +150,11 @@ static void hsr_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
RTA_PAYLOAD(tb[IFLA_HSR_SUPERVISION_ADDR]),
ARPHRD_VOID,
b1, sizeof(b1)));
+ if (tb[IFLA_HSR_PROTOCOL])
+ print_int(PRINT_ANY,
+ "proto",
+ "proto %d ",
+ rta_getattr_u8(tb[IFLA_HSR_PROTOCOL]));
}
static void hsr_print_help(struct link_util *lu, int argc, char **argv,
--
2.17.1
next prev parent reply other threads:[~2020-07-15 16:40 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-15 16:40 [net-next PATCH v2 0/9] Add PRP driver and bug fixes Murali Karicheri
2020-07-15 16:40 ` [net-next PATCH v2 1/9] net: hsr: fix incorrect lsdu size in the tag of HSR frames for small frames Murali Karicheri
2020-07-15 16:40 ` [net-next PATCH v2 2/9] net: hsr/prp: validate address B before copying to skb Murali Karicheri
2020-07-15 16:40 ` [net-next PATCH v2 3/9] hsr: enhance netlink socket interface to support PRP Murali Karicheri
2020-07-15 16:40 ` [net-next PATCH v2 4/9] net: hsr: introduce common code for skb initialization Murali Karicheri
2020-07-15 16:40 ` [net-next PATCH v2 5/9] net: hsr: introduce protocol specific function pointers Murali Karicheri
2020-07-15 16:40 ` [net-next PATCH v2 6/9] net: prp: add supervision frame generation utility function Murali Karicheri
2020-07-15 16:40 ` [net-next PATCH v2 7/9] net: hsr: define and use proto_ops ptrs to handle hsr specific frames Murali Karicheri
2020-07-15 16:40 ` [net-next PATCH v2 8/9] net: prp: add packet handling support Murali Karicheri
2020-07-15 16:40 ` [net-next PATCH v2 9/9] net: prp: enhance debugfs to display PRP info Murali Karicheri
2020-07-15 16:40 ` Murali Karicheri [this message]
2020-07-15 16:40 ` [net-next iproute2 PATCH v2 2/2] ip: iplink: prp: update man page for new parameter Murali Karicheri
2020-07-16 23:56 ` [net-next PATCH v2 0/9] Add PRP driver and bug fixes Jakub Kicinski
2020-07-17 14:19 ` Murali Karicheri
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200715164012.1222-11-m-karicheri2@ti.com \
--to=m-karicheri2@ti.com \
--cc=davem@davemloft.net \
--cc=grygorii.strashko@ti.com \
--cc=kuba@kernel.org \
--cc=linux-api@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=nsekhar@ti.com \
--cc=vinicius.gomes@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).