All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ahmed Amamou <ahmed@gandi.net>
To: netdev@vger.kernel.org
Cc: william@gandi.net, f.cachereul@alphalink.fr,
	Ahmed Amamou <ahmed@gandi.net>, Emmanuel Hocdet <manu@gandi.net>,
	Kamel Haddadou <kamel@gandi.net>
Subject: [RFC PATCH 01/24] net: rbridge: add trill frame description
Date: Wed, 24 Sep 2014 17:51:57 +0200	[thread overview]
Message-ID: <1411573940-14079-2-git-send-email-ahmed@gandi.net> (raw)
In-Reply-To: <1411573940-14079-1-git-send-email-ahmed@gandi.net>

add basic trill header description and basic header getter and setter fuctions

Signed-off-by: Ahmed Amamou <ahmed@gandi.net>
Signed-off-by: Emmanuel Hocdet <manu@gandi.net>
Signed-off-by: Kamel Haddadou <kamel@gandi.net>
---
 include/linux/if_trill.h      | 89 +++++++++++++++++++++++++++++++++++++++++++
 include/uapi/linux/if_ether.h |  1 +
 2 files changed, 90 insertions(+)
 create mode 100644 include/linux/if_trill.h

diff --git a/include/linux/if_trill.h b/include/linux/if_trill.h
new file mode 100644
index 0000000..ad9c631
--- /dev/null
+++ b/include/linux/if_trill.h
@@ -0,0 +1,89 @@
+#ifndef _LINUX_IF_TRILL_H_
+#define _LINUX_IF_TRILL_H_
+
+#include <linux/types.h>
+
+/*
+ * trill_hdr structure
+ *                                +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *                                | V | R |M|op-Length| Hop Count |
+ *+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *|  Egress RBridge Nickname      |    Ingress RBridge Nickname   |
+ *+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *
+ */
+
+struct trill_hdr {
+	__be16 th_flags;
+	__be16 th_egressnick;
+	__be16 th_ingressnick;
+} __attribute__ ((packed));
+
+static inline u16 trill_get_version(u16 trill_flags)
+{
+	return ((trill_flags >> 14) & 0x0003);
+}
+
+static inline u16 trill_set_version(u16 trill_flags, u16 v)
+{
+	trill_flags |= ((v & 0x0003) << 14);
+	return trill_flags;
+}
+
+static inline u16 trill_get_reserved(u16 trill_flags)
+{
+	return ((trill_flags >> 12) & 0x0003);
+}
+
+static inline u16 trill_set_reserved(u16 trill_flags, u16 v)
+{
+	trill_flags |= ((v & 0x0003) << 12);
+	return trill_flags;
+}
+
+static inline u16 trill_get_multidest(u16 trill_flags)
+{
+	return ((trill_flags >> 11) & 0x0001);
+}
+
+static inline u16 trill_set_multidest(u16 trill_flags, u16 flag)
+{
+	trill_flags |= ((flag & 0x0001) << 11);
+	return trill_flags;
+}
+
+/* len is in 4 bytes units << 2*/
+static inline size_t trill_get_optslen(u16 trill_flags)
+{
+	return (((trill_flags >> 6) & 0x001F) << 2);
+}
+
+static inline u16 trill_set_optslen(u16 trill_flags, u16 len)
+{
+	trill_flags |= (((len >> 2) & 0x001F) << 6);
+	return trill_flags;
+}
+
+static inline u16 trill_get_hopcount(u16 trill_flags)
+{
+	return (trill_flags & 0x003F);
+}
+
+static inline u16 trill_set_hopcount(u16 trill_flags, u16 count)
+{
+	trill_flags |= (count & 0x003F);
+	return trill_flags;
+}
+
+static inline void trillhdr_dec_hopcount(struct trill_hdr *trh)
+{
+	u8 *flags = (u8 *) & (trh->th_flags);
+	if (flags[1] & 0x3F)
+		flags[1] -= 1;
+}
+
+static inline size_t trill_header_len(struct trill_hdr *trh)
+{
+	return (sizeof(*trh) + trill_get_optslen(ntohs(trh->th_flags)));
+}
+#endif				/* !(_LINUX_IF_TRILL_H_) */
diff --git a/include/uapi/linux/if_ether.h b/include/uapi/linux/if_ether.h
index 0f8210b..a9eb2f2 100644
--- a/include/uapi/linux/if_ether.h
+++ b/include/uapi/linux/if_ether.h
@@ -48,6 +48,7 @@
 #define	ETH_P_BPQ	0x08FF		/* G8BPQ AX.25 Ethernet Packet	[ NOT AN OFFICIALLY REGISTERED ID ] */
 #define ETH_P_IEEEPUP	0x0a00		/* Xerox IEEE802.3 PUP packet */
 #define ETH_P_IEEEPUPAT	0x0a01		/* Xerox IEEE802.3 PUP Addr Trans packet */
+#define ETH_P_TRILL	0x22F3		/* TRILL frames RFC 6325 */
 #define ETH_P_BATMAN	0x4305		/* B.A.T.M.A.N.-Advanced packet [ NOT AN OFFICIALLY REGISTERED ID ] */
 #define ETH_P_DEC       0x6000          /* DEC Assigned proto           */
 #define ETH_P_DNA_DL    0x6001          /* DEC DNA Dump/Load            */
-- 
1.9.1

  reply	other threads:[~2014-09-24 15:58 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-24 15:51 [RFC PATCH 00/24] TRILL implementation Ahmed Amamou
2014-09-24 15:51 ` Ahmed Amamou [this message]
2014-09-24 16:38   ` [RFC PATCH 01/24] net: rbridge: add trill frame description Stephen Hemminger
2014-09-24 16:48     ` William Dauchy
2014-09-24 17:26       ` Cong Wang
2014-09-24 17:34         ` William Dauchy
2014-09-24 17:01   ` Cong Wang
2014-09-24 15:51 ` [RFC PATCH 02/24] net: rbridge: Add layer 2 IS-IS Ethertype Ahmed Amamou
2014-09-24 15:51 ` [RFC PATCH 03/24] net: rbridge: Add RBridge structure Ahmed Amamou
2014-09-24 16:40   ` Stephen Hemminger
2014-09-24 16:55     ` William Dauchy
2014-09-24 17:18   ` Cong Wang
2014-09-24 15:52 ` [RFC PATCH 04/24] net: rbridge: Add CONFIG_TRILL Ahmed Amamou
2014-09-24 15:52 ` [RFC PATCH 05/24] net: rbridge: Adapt Bridge structure Ahmed Amamou
2014-09-24 20:56   ` Francois Romieu
2014-09-24 15:52 ` [RFC PATCH 06/24] net: rbridge: Enable/disable TRILL capability Ahmed Amamou
2014-09-24 17:46   ` Vlad Yasevich
2014-09-24 15:52 ` [RFC PATCH 07/24] net: rbridge: Add sysfs for trill_state Ahmed Amamou
2014-09-24 15:52 ` [RFC PATCH 08/24] net: rbridge: Add Rbridge netlink message skeleton Ahmed Amamou
2014-09-24 17:52   ` Vlad Yasevich
2014-09-24 15:52 ` [RFC PATCH 09/24] net: rbridge: Get Rbridge nickname from daemon Ahmed Amamou
2014-09-24 15:52 ` [RFC PATCH 10/24] net: rbridge: Add elected dtroot Ahmed Amamou
2014-09-25 11:30   ` Sergei Shtylyov
2014-09-24 15:52 ` [RFC PATCH 11/24] net: rbridge: Add rbr_node management function Ahmed Amamou
2014-09-25 11:24   ` Sergei Shtylyov
2014-09-24 15:52 ` [RFC PATCH 12/24] net: rbridge: Clean up rbr_node on rbridge stop Ahmed Amamou
2014-09-24 15:52 ` [RFC PATCH 13/24] net: rbridge: Add set_node function Ahmed Amamou
2014-09-25 11:34   ` Sergei Shtylyov
2014-09-24 15:52 ` [RFC PATCH 14/24] net: rbridge: Add get_node function Ahmed Amamou
2014-09-24 15:52 ` [RFC PATCH 15/24] net: rbridge: Add basic trill frame handling function Ahmed Amamou
2014-09-24 19:23   ` Francois Romieu
2014-09-24 15:52 ` [RFC PATCH 16/24] net: rbridge: Update forwarding database Ahmed Amamou
2014-09-24 15:52 ` [RFC PATCH 17/24] net: rbridge: Add test on trill flag before flood Ahmed Amamou
2014-09-24 15:52 ` [RFC PATCH 18/24] net: rbridge: Add encapsulation process Ahmed Amamou
2014-09-24 15:52 ` [RFC PATCH 19/24] net: rbridge: Add receive function Ahmed Amamou
2014-09-24 15:52 ` [RFC PATCH 20/24] net: rbridge: Add multicast recv handling Ahmed Amamou
2014-09-24 15:52 ` [RFC PATCH 21/24] net: rbridge: Add decapsulation function Ahmed Amamou
2014-09-24 15:52 ` [RFC PATCH 22/24] net: rbridge: Add rbr_fwd Ahmed Amamou
2014-09-25 11:43   ` Sergei Shtylyov
2014-09-24 15:52 ` [RFC PATCH 23/24] net: rbridge: Add rbr_multidest_fwd Ahmed Amamou
2014-09-24 15:52 ` [RFC PATCH 24/24] net: rbridge: replace net_port rx_handler Ahmed Amamou
2014-09-24 16:44 ` [RFC PATCH 00/24] TRILL implementation Stephen Hemminger
2014-09-24 16:54   ` William Dauchy
2014-09-24 17:24     ` Cong Wang
2014-09-24 17:33       ` William Dauchy
2014-09-24 20:57     ` Francois Romieu

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=1411573940-14079-2-git-send-email-ahmed@gandi.net \
    --to=ahmed@gandi.net \
    --cc=f.cachereul@alphalink.fr \
    --cc=kamel@gandi.net \
    --cc=manu@gandi.net \
    --cc=netdev@vger.kernel.org \
    --cc=william@gandi.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.