Skip to contentSkip to conversation

implementation of IEEE 802.1Qbg in lldpad, part1

PATCH New Jens Osterkamp 1 participant 4 messages May 4, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi all,

this series of patches contains an implementation of the first part of IEEE 802.1Qbg, the exchange of EVB TLVs to negotiate VSI capabalities.

It supports setting the parameters of the TLV exchange from the command line using lldptool.

The patches are based on lldpad 0.9.34. lldpad is a project hosted on sourceforge.net. For more information about lldpad take a look at

http://sourceforge.net/projects/e1000/files/

section "DCB Tools / lldpad".

best regards,

Jens

#1 lore raw

PATCH 1/3 consolidation of MIN and MAX macros in common.h

This patch consolidates a modified version of the already existing MIN macro in lldpad to include/common.h and add a MAX macro.

---
 include/common.h       |   14 ++++++++++++++
 include/dcb_protocol.h |    4 ----
 2 files changed, 14 insertions(+), 4 deletions(-)
include/common.h +14 -0
index 01746ea..ab07dc2 100644
@@ -387,4 +387,18 @@ typedef int socklen_t;
 
 const char * wpa_ssid_txt(u8 *ssid, size_t ssid_len);
 
+#define MIN(x,y) \
+	({	\
+		typeof (x) __x = (x);	\
+		typeof (y) __y = (y);	\
+		__x < __y ? __x : __y;	\
+	 })
+
+#define MAX(x,y) \
+	({	\
+		typeof (x) __x = (x);	\
+		typeof (y) __y = (y);	\
+		__x > __y ? __x : __y;	\
+	 })
+
 #endif /* COMMON_H */
include/dcb_protocol.h +0 -4
index 67f653c..c7b856f 100644
@@ -58,10 +58,6 @@ typedef enum {
 #define DUP_DCBX_TLV_LLINK         0x0020
 #define TOO_MANY_NGHBRS            0x0040
 
-//#ifndef min /*todo: change to min()
-	#define MIN(x, y) ((x) < (y) ? x : y)
-//#endif
-
 #define INIT_DCB_OUI                    {0x00,0x1b,0x21}
 
 bool add_adapter(char *device_name);
Signature · 1 line
1.7.0.1
#2 lore raw

PATCH 2/3 implementation of IEEE 802.1Qbg in lldpad, part 1

In reply to Jens Osterkamp

This patch contains the first part of an initial implementation of the IEEE 802.1Qbg standard: It contains code for the exchange of EVB TLV capabilities between a host with virtual machines and an adjacent switch.

Exchange of EVB TLV may be enabled or disabled on a per port basis. Information about the information negotiated by the protocol can be queried on the commandline with lldptool.

The patch applies to lldpad 0.9.34 and still contains code to log protocol activity more verbosely than it would be necessary in the final version.

---
 Makefile.am             |   10 +-
 include/lldp.h          |   20 ++
 include/lldp_evb.h      |   58 +++++
 include/lldp_evb_clif.h |   33 +++
 include/lldp_evb_cmds.h |   31 +++
 include/lldp_tlv.h      |    1 +
 lldp_evb.c              |  567 +++++++++++++++++++++++++++++++++++++++++++++++
 lldp_evb_clif.c         |  232 +++++++++++++++++++
 lldp_evb_cmds.c         |  127 +++++++++++
 lldpad.c                |    2 +
 lldptool.c              |    2 +
 11 files changed, 1079 insertions(+), 4 deletions(-)
 create mode 100644 include/lldp_evb.h
 create mode 100644 include/lldp_evb_clif.h
 create mode 100644 include/lldp_evb_cmds.h
 create mode 100644 lldp_evb.c
 create mode 100644 lldp_evb_clif.c
 create mode 100644 lldp_evb_cmds.c
Makefile.am +6 -4
index 68e4144..554baec 100644
@@ -39,7 +39,7 @@ lldpad_include_HEADERS = include/dcb_types.h include/dcbtool.h \
 include/dcb_osdep.h include/clif.h include/lldp_dcbx_cmds.h include/common.h \
 include/lldpad.h include/os.h include/includes.h include/lldp_mand_cmds.h \
 include/clif_msgs.h include/lldp_basman_cmds.h include/lldp_8023_cmds.h \
-include/lldp_med_cmds.h include/lldp_dcbx_cfg.h
+include/lldp_med_cmds.h include/lldp_dcbx_cfg.h include/lldp_evb_cmds.h
 
 noinst_HEADERS = include/config.h include/ctrl_iface.h \
 include/dcb_driver_if_types.h include/dcb_driver_interface.h \
@@ -49,7 +49,7 @@ include/event_iface.h include/messages.h include/parse_cli.h include/version.h \
 include/lldptool_cli.h include/list.h \
 include/lldp_mand_clif.h include/lldp_basman_clif.h include/lldp_med_clif.h \
 include/lldp_8023_clif.h include/lldp_dcbx_clif.h include/lldptool.h \
-include/lldp_rtnl.h
+include/lldp_rtnl.h include/lldp_evb_clif.h
 
 lldpad_SOURCES = lldpad.c config.c  drv_cfg.c ctrl_iface.c event_iface.c eloop.c \
 common.c os_unix.c lldp_dcbx_cmds.c log.c lldpad_shm.c \
@@ -64,10 +64,12 @@ lldp_dcbx_cfg.c include/lldp_dcbx_cfg.h \
 lldp_util.c include/lldp_util.h \
 lldp_mand.c include/lldp_mand.h \
 lldp_mand_cmds.c lldp_basman_cmds.c lldp_8023_cmds.c lldp_med_cmds.c \
+lldp_evb_cmds.c \
 lldp_tlv.c include/lldp_tlv.h \
 lldp_basman.c include/lldp_basman.h	\
 lldp_med.c include/lldp_med.h \
-lldp_8023.c include/lldp_8023.h
+lldp_8023.c include/lldp_8023.h \
+lldp_evb.c include/lldp_evb.h
 
 
 
@@ -76,7 +78,7 @@ $(lldpad_include_HEADERS) $(noinst_HEADERS)
 
 lldptool_SOURCES = lldptool.c clif.c lldptool_cmds.c common.c os_unix.c \
 lldp_mand_clif.c lldp_basman_clif.c lldp_med_clif.c lldp_8023_clif.c \
-lldp_dcbx_clif.c $(lldpad_include_HEADERS) $(noinst_HEADERS)
+lldp_dcbx_clif.c lldp_evb_clif.c $(lldpad_include_HEADERS) $(noinst_HEADERS)
 
 nltest_SOURCES = nltest.c nltest.h
 
include/lldp.h +20 -0
index 66532bd..21347b0 100644
@@ -45,6 +45,8 @@
 /* Telecommunications Industry Association TR-41 Committee */
 #define OUI_TIA_TR41	0x0012bb
 
+#define OUI_IEEE_8021Qbg	0x001b3f
+
 /* IEEE 802.3AB Clause 9: TLV Types */
 #define CHASSIS_ID_TLV    1
 #define PORT_ID_TLV       2
@@ -186,5 +188,23 @@ enum {
 #define LLDP_8023_LINKAGG_CAPABLE	(1 << 0)
 #define LLDP_8023_LINKAGG_ENABLED	(1 << 1)
 
+/* IEEE 802.1Qbg subtype */
+#define LLDP_EVB_SUBTYPE		0
+
+/* forwarding mode */
+#define LLDP_EVB_CAPABILITY_FORWARD_STANDARD		(1 << 7)
+#define LLDP_EVB_CAPABILITY_FORWARD_RELAXEDRELAY	(1 << 6)
+
+/* EVB supported protocols */
+#define LLDP_EVB_CAPABILITY_PROTOCOL_RTE		(1 << 3)
+#define LLDP_EVB_CAPABILITY_PROTOCOL_ECP		(1 << 2)
+#define LLDP_EVB_CAPABILITY_PROTOCOL_VDPL		(1 << 1)
+#define LLDP_EVB_CAPABILITY_PROTOCOL_VDP		(1 << 0)
+
+/* EVB specific values */
+#define LLDP_EVB_DEFAULT_MAX_VSI			4096
+#define LLDP_EVB_DEFAULT_SVSI				3295
+#define LLDP_EVB_DEFAULT_RTE				15
+
 void somethingChangedLocal(char *ifname);
 #endif /* _LLDP_H */
include/lldp_evb.h new file +58 -0

58 lines not on this page · raw message

include/lldp_evb_clif.h new file +33 -0
new file mode 100644
index 0000000..56011d1
@@ -0,0 +1,33 @@
+/*******************************************************************************
+
+  implementation of EVB TLVs for LLDP
+  (c) Copyright IBM Corp. 2010
+
+  Author(s): Jens Osterkamp <[email protected]>
+
+  This program is free software; you can redistribute it and/or modify it
+  under the terms and conditions of the GNU General Public License,
+  version 2, as published by the Free Software Foundation.
+
+  This program is distributed in the hope it will be useful, but WITHOUT
+  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+  more details.
+
+  You should have received a copy of the GNU General Public License along with
+  this program; if not, write to the Free Software Foundation, Inc.,
+  51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+
+  The full GNU General Public License is included in this distribution in
+  the file called "COPYING".
+
+*******************************************************************************/
+
+#ifndef _LLDP_EVB_CLIF_H
+#define _LLDP_EVB_CLIF_H
+
+struct lldp_module *evb_cli_register(void);
+void evb_cli_unregister(struct lldp_module *);
+int evb_print_tlv(u32, u16, u8 *);
+
+#endif
include/lldp_evb_cmds.h new file +31 -0
new file mode 100644
index 0000000..1367e5d
@@ -0,0 +1,31 @@
+/*******************************************************************************
+
+  implementation of EVB TLVs for LLDP
+  (c) Copyright IBM Corp. 2010
+
+  Author(s): Jens Osterkamp <[email protected]>
+
+  This program is free software; you can redistribute it and/or modify it
+  under the terms and conditions of the GNU General Public License,
+  version 2, as published by the Free Software Foundation.
+
+  This program is distributed in the hope it will be useful, but WITHOUT
+  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+  more details.
+
+  You should have received a copy of the GNU General Public License along with
+  this program; if not, write to the Free Software Foundation, Inc.,
+  51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+
+  The full GNU General Public License is included in this distribution in
+  the file called "COPYING".
+
+*******************************************************************************/
+
+#ifndef _LLDP_EVB_CMDS_H
+#define _LLDP_EVB_CMDS_H
+
+struct arg_handlers *evb_get_arg_handlers();
+
+#endif
include/lldp_tlv.h +1 -0
index a32cc71..fe3a75a 100644
@@ -144,6 +144,7 @@ int tlv_ok(struct unpacked_tlv *tlv);
 #define TLVID_8021(sub)		TLVID(OUI_IEEE_8021, (sub))
 #define TLVID_8023(sub)		TLVID(OUI_IEEE_8023, (sub))
 #define TLVID_MED(sub)		TLVID(OUI_TIA_TR41, (sub))
+#define TLVID_8021Qbg(sub)	TLVID(OUI_IEEE_8021Qbg, (sub))
 
 /* the size in bytes needed for a packed tlv from unpacked tlv */
 #define TLVSIZE(t) ((t) ? (2 + (t)->length) : 0)
lldp_evb.c new file +567 -0

567 lines not on this page · raw message

lldp_evb_clif.c new file +232 -0

232 lines not on this page · raw message

lldp_evb_cmds.c new file +127 -0

127 lines not on this page · raw message

lldpad.c +2 -0
index e89abcd..711a995 100644
@@ -49,6 +49,7 @@
 #include "lldp_dcbx.h"
 #include "lldp_med.h"
 #include "lldp_8023.h"
+#include "lldp_evb.h"
 #include "config.h"
 #include "lldpad_shm.h"
 #include "clif.h"
@@ -63,6 +64,7 @@ struct lldp_module *(*register_tlv_table[])(void) = {
 	dcbx_register,
 	med_register,
 	ieee8023_register,
+	evb_register,
 	NULL,
 };
 
lldptool.c +2 -0
index a48df28..a06a279 100644
@@ -39,6 +39,7 @@
 #include "lldp_med_clif.h"
 #include "lldp_8023_clif.h"
 #include "lldp_dcbx_clif.h"
+#include "lldp_evb_clif.h"
 #include "lldptool.h"
 #include "lldptool_cli.h"
 #include "lldp_mod.h"
@@ -156,6 +157,7 @@ struct lldp_module *(*register_tlv_table[])(void) = {
 	ieee8023_cli_register,
 	med_cli_register,
 	dcbx_cli_register,
+	evb_cli_register,
 	NULL,
 };
 
Signature · 1 line
1.7.0.1
#3 lore raw

PATCH 3/3 support for getting and setting EVB TLV parameters

In reply to Jens Osterkamp

This patch adds for querying and setting parameters used in the exchange of EVB TLV messages.
The parameters that can be set are:

- forwarding mode
- host protocol capabilities (RTE, ECP, VDP and VDPL)
- no. of supported VSIs
- retransmission timer exponent (RTE)

To implement this, struct tlv_info_evb had to move to include/lldp_evb.h. Besides that, the patch contains some minor bugfixes.

---
 include/lldp_evb.h      |   20 +++
 include/lldp_evb_clif.h |   18 +++
 lldp_evb.c              |   21 +---
 lldp_evb_cmds.c         |  335 ++++++++++++++++++++++++++++++++++++++++++++++-
 4 files changed, 372 insertions(+), 22 deletions(-)
include/lldp_evb.h +20 -0
index 3559dde..de39fd3 100644
@@ -37,6 +37,25 @@ typedef enum {
 	EVB_CONFIRMATION
 } evb_state;
 
+struct tlv_info_evb {
+	u8 oui[3];
+	u8 sub;
+	/* supported forwarding mode */
+	u8 smode;
+	/* supported capabilities */
+	u8 scap;
+	/* currently configured forwarding mode */
+	u8 cmode;
+	/* currently configured capabilities */
+	u8 ccap;
+	/* supported no. of vsi */
+	u16 svsi;
+	/* currently configured no. of vsi */
+	u16 cvsi;
+	/* retransmission exponent */
+	u8 rte;
+} __attribute__ ((__packed__));
+
 struct evb_data {
 	char ifname[IFNAMSIZ];
 	struct unpacked_tlv *evb;
@@ -54,5 +73,6 @@ void evb_unregister(struct lldp_module *mod);
 struct packed_tlv *evb_gettlv(struct port *port);
 void evb_ifdown(char *);
 void evb_ifup(char *);
+struct evb_data *evb_data(char *ifname);
 
 #endif /* _LLDP_EVB_H */
include/lldp_evb_clif.h +18 -0
index 56011d1..5306eca 100644
@@ -30,4 +30,22 @@ struct lldp_module *evb_cli_register(void);
 void evb_cli_unregister(struct lldp_module *);
 int evb_print_tlv(u32, u16, u8 *);
 
+#define EVB_BUF_SIZE		256
+
+#define ARG_EVB_FORWARDING_MODE	"fmode"
+
+#define VAL_EVB_FMODE_BRIDGE        "bridge"
+#define VAL_EVB_FMODE_RELAXEDRELAY	"relaxedrelay"
+
+#define ARG_EVB_CAPABILITIES	"capabilities"
+
+#define VAL_EVB_CAPA_RTE		"rte"
+#define VAL_EVB_CAPA_ECP		"ecp"
+#define VAL_EVB_CAPA_VDPL		"vdpl"
+#define VAL_EVB_CAPA_VDP		"vdp"
+
+#define ARG_EVB_VSIS		"vsis"
+
+#define ARG_EVB_RTE			"rte"
+
 #endif
lldp_evb.c +1 -20
index 304a9f4..db5a11c 100644
@@ -39,26 +39,7 @@
 
 extern struct lldp_head lldp_head;
 
-struct tlv_info_evb {
-	u8 oui[3];
-	u8 sub;
-	/* supported forwarding mode */
-	u8 smode;
-	/* supported capabilities */
-	u8 scap;
-	/* currently configured forwarding mode */
-	u8 cmode;
-	/* currently configured capabilities */
-	u8 ccap;
-	/* supported no. of vsi */
-	u16 svsi;
-	/* currently configured no. of vsi */
-	u16 cvsi;
-	/* retransmission exponent */
-	u8 rte;
-} __attribute__ ((__packed__));
-
-static struct evb_data *evb_data(const char *ifname)
+struct evb_data *evb_data(char *ifname)
 {
 	struct evb_user_data *ud;
 	struct evb_data *bd = NULL;
lldp_evb_cmds.c +333 -2

360 lines not on this page · raw message

Signature · 1 line
1.7.0.1