|
|
ee47b4 |
From faf19bd8bdb1a6ca0dd98843cd09fd96b1f2f901 Mon Sep 17 00:00:00 2001
|
|
|
ee47b4 |
From: padkrish <padkrish@cisco.com>
|
|
|
ee47b4 |
Date: Wed, 21 Jan 2015 03:37:57 +0000
|
|
|
ee47b4 |
Subject: [PATCH] VDP: Support in VDP22 for correct error code/status to
|
|
|
ee47b4 |
vdptool
|
|
|
ee47b4 |
|
|
|
ee47b4 |
This commit has the following changes:
|
|
|
ee47b4 |
a. Returning the status or error code to vdptool for the error cases. Errors
|
|
|
ee47b4 |
can be Tx error, invalid parameters, incorrect configuration etc. The vdptool
|
|
|
ee47b4 |
is modified to print the error messages from lldpad.
|
|
|
ee47b4 |
b. Modify the vdptool option from set-tlv/get-tlv to set-vsi/get-vsi. The
|
|
|
ee47b4 |
vdptool man page document is also modified accordingly.
|
|
|
ee47b4 |
c. Re-arrange the definitions in header files.
|
|
|
ee47b4 |
d. Fix some formatting issues.
|
|
|
ee47b4 |
|
|
|
ee47b4 |
Signed-off-by: padkrish <padkrish@cisco.com>
|
|
|
ee47b4 |
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
|
|
|
ee47b4 |
---
|
|
|
ee47b4 |
docs/vdptool.8 | 12 ++--
|
|
|
ee47b4 |
include/lldpad_status.h | 25 +++++----
|
|
|
ee47b4 |
include/qbg_vdp22.h | 50 +++++++++--------
|
|
|
ee47b4 |
include/qbg_vdp22_clif.h | 8 +++
|
|
|
ee47b4 |
include/qbg_vdp22def.h | 39 +++++++++++++
|
|
|
ee47b4 |
qbg/vdp22.c | 20 ++++++-
|
|
|
ee47b4 |
qbg/vdp22_cmds.c | 63 +++++++++++++++------
|
|
|
ee47b4 |
qbg/vdp22sm.c | 15 -----
|
|
|
ee47b4 |
qbg/vdp_ascii.c | 56 +++++++++++++++----
|
|
|
ee47b4 |
vdptool.c | 141 ++++++++++++++++++++++++++++++++++++++---------
|
|
|
ee47b4 |
10 files changed, 316 insertions(+), 113 deletions(-)
|
|
|
ee47b4 |
|
|
|
ee47b4 |
diff --git a/docs/vdptool.8 b/docs/vdptool.8
|
|
|
ee47b4 |
index 02b4e8e..0b50a13 100644
|
|
|
ee47b4 |
--- a/docs/vdptool.8
|
|
|
ee47b4 |
+++ b/docs/vdptool.8
|
|
|
ee47b4 |
@@ -98,7 +98,7 @@ Wait for the bridge response message
|
|
|
ee47b4 |
.SS VSI Parameter
|
|
|
ee47b4 |
Each VDP22 TLVs contains a command mode, manager identifier,
|
|
|
ee47b4 |
type identifier, type identifier version, VSI instance identifier,
|
|
|
ee47b4 |
-migiration hints and filter information.
|
|
|
ee47b4 |
+migration hints and filter information.
|
|
|
ee47b4 |
The fields are explained next:
|
|
|
ee47b4 |
.TP
|
|
|
ee47b4 |
.B "mode (Command Mode):"
|
|
|
ee47b4 |
@@ -140,7 +140,7 @@ an UUID according to RFC 4122
|
|
|
ee47b4 |
with optional dashes in between.
|
|
|
ee47b4 |
.TP
|
|
|
ee47b4 |
.B "hints (Migration Hints):"
|
|
|
ee47b4 |
-The migiration hints is a string aiding in
|
|
|
ee47b4 |
+The migration hints is a string aiding in
|
|
|
ee47b4 |
migration of virtual machines:
|
|
|
ee47b4 |
.RS
|
|
|
ee47b4 |
.IP none:
|
|
|
ee47b4 |
@@ -193,11 +193,11 @@ show usage information
|
|
|
ee47b4 |
.B \-v, version
|
|
|
ee47b4 |
show version information
|
|
|
ee47b4 |
.TP
|
|
|
ee47b4 |
-.B \-t, get-tlv
|
|
|
ee47b4 |
-get TLV information for the specified interface
|
|
|
ee47b4 |
+.B \-t, get-vsi
|
|
|
ee47b4 |
+get VSI information for the specified interface
|
|
|
ee47b4 |
.TP
|
|
|
ee47b4 |
-.B \-T, set-tlv
|
|
|
ee47b4 |
-set TLV information for the specified interface
|
|
|
ee47b4 |
+.B \-T, set-vsi
|
|
|
ee47b4 |
+set VSI information for the specified interface
|
|
|
ee47b4 |
.TP
|
|
|
ee47b4 |
.B \-p, ping
|
|
|
ee47b4 |
display the process identifier of the running lldpad process
|
|
|
ee47b4 |
diff --git a/include/lldpad_status.h b/include/lldpad_status.h
|
|
|
ee47b4 |
index df6e0f7..568063b 100644
|
|
|
ee47b4 |
--- a/include/lldpad_status.h
|
|
|
ee47b4 |
+++ b/include/lldpad_status.h
|
|
|
ee47b4 |
@@ -33,18 +33,19 @@
|
|
|
ee47b4 |
#define LLDPAD_STATUS_H
|
|
|
ee47b4 |
|
|
|
ee47b4 |
typedef enum {
|
|
|
ee47b4 |
- cmd_success = 0,
|
|
|
ee47b4 |
- cmd_failed,
|
|
|
ee47b4 |
- cmd_device_not_found,
|
|
|
ee47b4 |
- cmd_agent_not_found,
|
|
|
ee47b4 |
- cmd_invalid,
|
|
|
ee47b4 |
- cmd_bad_params,
|
|
|
ee47b4 |
- cmd_peer_not_present,
|
|
|
ee47b4 |
- cmd_ctrl_vers_not_compatible,
|
|
|
ee47b4 |
- cmd_not_capable,
|
|
|
ee47b4 |
- cmd_not_applicable,
|
|
|
ee47b4 |
- cmd_no_access,
|
|
|
ee47b4 |
- cmd_agent_not_supported,
|
|
|
ee47b4 |
+ cmd_success = 0,
|
|
|
ee47b4 |
+ cmd_failed,
|
|
|
ee47b4 |
+ cmd_device_not_found,
|
|
|
ee47b4 |
+ cmd_agent_not_found,
|
|
|
ee47b4 |
+ cmd_invalid,
|
|
|
ee47b4 |
+ cmd_bad_params,
|
|
|
ee47b4 |
+ cmd_peer_not_present,
|
|
|
ee47b4 |
+ cmd_ctrl_vers_not_compatible,
|
|
|
ee47b4 |
+ cmd_not_capable,
|
|
|
ee47b4 |
+ cmd_not_applicable,
|
|
|
ee47b4 |
+ cmd_no_access,
|
|
|
ee47b4 |
+ cmd_agent_not_supported,
|
|
|
ee47b4 |
+ cmd_max_status,
|
|
|
ee47b4 |
} cmd_status;
|
|
|
ee47b4 |
|
|
|
ee47b4 |
#endif /* LLDPAD_STATUS_H */
|
|
|
ee47b4 |
diff --git a/include/qbg_vdp22.h b/include/qbg_vdp22.h
|
|
|
ee47b4 |
index af0aa15..6c3c9ee 100644
|
|
|
ee47b4 |
--- a/include/qbg_vdp22.h
|
|
|
ee47b4 |
+++ b/include/qbg_vdp22.h
|
|
|
ee47b4 |
@@ -65,22 +65,36 @@ enum vdp22_role { /* State for VDP22 bridge processing */
|
|
|
ee47b4 |
VDP22_STATION /* State role */
|
|
|
ee47b4 |
};
|
|
|
ee47b4 |
|
|
|
ee47b4 |
-enum vdp22_cmdresp { /* VDP22 Protocol command responses */
|
|
|
ee47b4 |
- VDP22_RESP_SUCCESS = 0, /* Success */
|
|
|
ee47b4 |
- VDP22_RESP_INVALID_FORMAT = 1,
|
|
|
ee47b4 |
- VDP22_RESP_NO_RESOURCES = 2,
|
|
|
ee47b4 |
- VDP22_RESP_NO_VSIMGR = 3, /* No contact to VSI manager */
|
|
|
ee47b4 |
- VDP22_RESP_OTHER = 4, /* Other reasons */
|
|
|
ee47b4 |
- VDP22_RESP_NOADDR = 5, /* Invalid VID, MAC, GROUP etc */
|
|
|
ee47b4 |
- VDP22_RESP_DEASSOC = 252, /* Deassoc response */
|
|
|
ee47b4 |
- VDP22_RESP_TIMEOUT = 253, /* Timeout response */
|
|
|
ee47b4 |
- VDP22_RESP_KEEP = 254, /* Keep response */
|
|
|
ee47b4 |
- VDP22_RESP_NONE = 255 /* No response returned so far */
|
|
|
ee47b4 |
+/*
|
|
|
ee47b4 |
+ * VSI information. One node per matching entry (same mgrid, type_id, type_ver,
|
|
|
ee47b4 |
+ * id_fmt, id and fif). Filter data can be added and removed.
|
|
|
ee47b4 |
+ */
|
|
|
ee47b4 |
+enum vsi22_flags { /* Flags (or'ed in) */
|
|
|
ee47b4 |
+ VDP22_BUSY = 1, /* This node is under work */
|
|
|
ee47b4 |
+ VDP22_DELETE_ME = 2, /* Deallocate this node */
|
|
|
ee47b4 |
+ VDP22_RETURN_VID = 4, /* Return wildcard vlan id */
|
|
|
ee47b4 |
+ VDP22_NOTIFY = 8, /* Send netlink message to requestor */
|
|
|
ee47b4 |
+ VDP22_NLCMD = 16 /* Netlink command pending */
|
|
|
ee47b4 |
+};
|
|
|
ee47b4 |
+
|
|
|
ee47b4 |
+enum { /* VDP22 Protocol command responses */
|
|
|
ee47b4 |
+ USEC_PER_SEC = 1000000, /* Microseconds per second */
|
|
|
ee47b4 |
+ VDP22_RESBIT = 0x80, /* VSI reserved bit */
|
|
|
ee47b4 |
+ VDP22_ACKBIT = 0x40, /* VSI Acknowledgement bit */
|
|
|
ee47b4 |
+ VDP22_KEEPBIT = 0x20, /* VSI keep error bit */
|
|
|
ee47b4 |
+ VDP22_HARDBIT = 0x10, /* VSI hard error bit */
|
|
|
ee47b4 |
+ VDP22_STATUS_MASK = 0x0f, /* Status mask */
|
|
|
ee47b4 |
+ VDP22_STATUS_SHIFT = 0, /* Status offset */
|
|
|
ee47b4 |
};
|
|
|
ee47b4 |
|
|
|
ee47b4 |
enum {
|
|
|
ee47b4 |
VDP22_MGRIDSZ = 16, /* Size of manager identifier */
|
|
|
ee47b4 |
- VDP22_IDSZ = 16 /* Size of vsi identifier */
|
|
|
ee47b4 |
+ VDP22_IDSZ = 16, /* Size of vsi identifier */
|
|
|
ee47b4 |
+};
|
|
|
ee47b4 |
+
|
|
|
ee47b4 |
+struct vdp22_ptlv { /* Packed TLV for VDP data exchange */
|
|
|
ee47b4 |
+ unsigned short head; /* TLV 16 bit header */
|
|
|
ee47b4 |
+ unsigned char data[]; /* TLV Data buffer */
|
|
|
ee47b4 |
};
|
|
|
ee47b4 |
|
|
|
ee47b4 |
struct vsi_origin { /* Originator of VSI request */
|
|
|
ee47b4 |
@@ -99,18 +113,6 @@ struct fid22 { /* Filter data: GROUP,MAC,VLAN entry */
|
|
|
ee47b4 |
struct vsi_origin requestor;
|
|
|
ee47b4 |
};
|
|
|
ee47b4 |
|
|
|
ee47b4 |
-/*
|
|
|
ee47b4 |
- * VSI information. One node per matching entry (same mgrid, type_id, type_ver,
|
|
|
ee47b4 |
- * id_fmt, id and fif). Filter data can be added and removed.
|
|
|
ee47b4 |
- */
|
|
|
ee47b4 |
-enum vsi22_flags { /* Flags (or'ed in) */
|
|
|
ee47b4 |
- VDP22_BUSY = 1, /* This node is under work */
|
|
|
ee47b4 |
- VDP22_DELETE_ME = 2, /* Deallocate this node */
|
|
|
ee47b4 |
- VDP22_RETURN_VID = 4, /* Return wildcard vlan id */
|
|
|
ee47b4 |
- VDP22_NOTIFY = 8, /* Send netlink message to requestor */
|
|
|
ee47b4 |
- VDP22_NLCMD = 16 /* Netlink command pending */
|
|
|
ee47b4 |
-};
|
|
|
ee47b4 |
-
|
|
|
ee47b4 |
struct vdp22smi { /* Data structure for VDP22 state machine */
|
|
|
ee47b4 |
int state; /* State of VDP state machine for VSI */
|
|
|
ee47b4 |
bool kato; /* VSI KA ACK timeout hit for this VSI */
|
|
|
ee47b4 |
diff --git a/include/qbg_vdp22_clif.h b/include/qbg_vdp22_clif.h
|
|
|
ee47b4 |
index 8346b98..0cc603e 100644
|
|
|
ee47b4 |
--- a/include/qbg_vdp22_clif.h
|
|
|
ee47b4 |
+++ b/include/qbg_vdp22_clif.h
|
|
|
ee47b4 |
@@ -33,6 +33,8 @@
|
|
|
ee47b4 |
#define OP_FID_POS 8 /* Second Byte */
|
|
|
ee47b4 |
#define OP_OUI_POS 16 /* Third Byte */
|
|
|
ee47b4 |
|
|
|
ee47b4 |
+#include "lldpad_status.h"
|
|
|
ee47b4 |
+
|
|
|
ee47b4 |
typedef enum {
|
|
|
ee47b4 |
cmd_getstats,
|
|
|
ee47b4 |
cmd_gettlv,
|
|
|
ee47b4 |
@@ -60,5 +62,11 @@ typedef enum {
|
|
|
ee47b4 |
*/
|
|
|
ee47b4 |
} vdp22_op;
|
|
|
ee47b4 |
|
|
|
ee47b4 |
+enum vdp22_cmd_status {
|
|
|
ee47b4 |
+ cmd_vdp_prot_no_support = cmd_max_status + 1,
|
|
|
ee47b4 |
+ cmd_vdp_nomem,
|
|
|
ee47b4 |
+ cmd_vdp_busy,
|
|
|
ee47b4 |
+};
|
|
|
ee47b4 |
+
|
|
|
ee47b4 |
struct lldp_module *vdp22_cli_register(void);
|
|
|
ee47b4 |
#endif
|
|
|
ee47b4 |
diff --git a/include/qbg_vdp22def.h b/include/qbg_vdp22def.h
|
|
|
ee47b4 |
index ff4270c..c305a2b 100644
|
|
|
ee47b4 |
--- a/include/qbg_vdp22def.h
|
|
|
ee47b4 |
+++ b/include/qbg_vdp22def.h
|
|
|
ee47b4 |
@@ -94,6 +94,31 @@ enum vsi_key_arg {
|
|
|
ee47b4 |
VSI_INVALID_ARG
|
|
|
ee47b4 |
};
|
|
|
ee47b4 |
|
|
|
ee47b4 |
+enum vdp22_cmdresp { /* VDP22 Protocol command responses */
|
|
|
ee47b4 |
+ VDP22_RESP_SUCCESS = 0, /* Success */
|
|
|
ee47b4 |
+ VDP22_RESP_INVALID_FORMAT = 1,
|
|
|
ee47b4 |
+ VDP22_RESP_NO_RESOURCES = 2,
|
|
|
ee47b4 |
+ VDP22_RESP_NO_VSIMGR = 3, /* No contact to VSI manager */
|
|
|
ee47b4 |
+ VDP22_RESP_OTHER = 4, /* Other reasons */
|
|
|
ee47b4 |
+ VDP22_RESP_NOADDR = 5, /* Invalid VID, MAC, GROUP etc */
|
|
|
ee47b4 |
+ VDP22_RESP_DEASSOC = 252, /* Deassoc response */
|
|
|
ee47b4 |
+ VDP22_RESP_TIMEOUT = 253, /* Timeout response */
|
|
|
ee47b4 |
+ VDP22_RESP_KEEP = 254, /* Keep response */
|
|
|
ee47b4 |
+ VDP22_RESP_NONE = 255 /* No response returned so far */
|
|
|
ee47b4 |
+};
|
|
|
ee47b4 |
+
|
|
|
ee47b4 |
+/*
|
|
|
ee47b4 |
+ * Errors applicable mostly for VDP22_RESP_NONE
|
|
|
ee47b4 |
+ */
|
|
|
ee47b4 |
+
|
|
|
ee47b4 |
+enum vdp22_cmderr {
|
|
|
ee47b4 |
+ VDP22_KATO = 0,
|
|
|
ee47b4 |
+ VDP22_ACKTO,
|
|
|
ee47b4 |
+ VDP22_TXERR
|
|
|
ee47b4 |
+};
|
|
|
ee47b4 |
+
|
|
|
ee47b4 |
+#define VDP22_STATUS_BITS 8 /* Number of bits in Status field */
|
|
|
ee47b4 |
+
|
|
|
ee47b4 |
#define VSI22_ARG_MODE_STR "mode"
|
|
|
ee47b4 |
#define VSI22_ARG_MGRID_STR "mgrid2"
|
|
|
ee47b4 |
#define VSI22_ARG_TYPEID_STR "typeid"
|
|
|
ee47b4 |
@@ -105,4 +130,18 @@ enum vsi_key_arg {
|
|
|
ee47b4 |
#define VSI22_ARG_FILTER_STR "filter"
|
|
|
ee47b4 |
#define VSI22_ARG_OUI_STR "oui"
|
|
|
ee47b4 |
|
|
|
ee47b4 |
+#define VSI22_KATO_ERR_STR "Keepalive Timeout"
|
|
|
ee47b4 |
+#define VSI22_ACKTO_ERR_STR "Ack not received from bridge"
|
|
|
ee47b4 |
+#define VSI22_TX_ERR_STR "Transmission Error"
|
|
|
ee47b4 |
+
|
|
|
ee47b4 |
+#define VSI22_INVALID_FRMT_ERR_STR "VDP TLV Format is Invalid"
|
|
|
ee47b4 |
+#define VSI22_NO_RES_ERR_STR "Insufficient resources at bridge"
|
|
|
ee47b4 |
+#define VSI22_NO_VSIMGR_ERR_STR "Unable to contact VSI Mgr"
|
|
|
ee47b4 |
+#define VSI22_OTHER_ERR_STR "Other Failures"
|
|
|
ee47b4 |
+#define VSI22_NOADDR_ERR_STR "Invalid VID, GroupID or MAC address field"
|
|
|
ee47b4 |
+#define VSI22_DEASS_ERR_STR "Deassoc received from switch"
|
|
|
ee47b4 |
+#define VSI22_TIMEOUT_ERR_STR "Timeout Error"
|
|
|
ee47b4 |
+#define VSI22_KEEP_ERR_STR "Command rejected by bridge and state prior to" \
|
|
|
ee47b4 |
+ " requested command is kept"
|
|
|
ee47b4 |
+
|
|
|
ee47b4 |
#endif
|
|
|
ee47b4 |
diff --git a/qbg/vdp22.c b/qbg/vdp22.c
|
|
|
ee47b4 |
index af11af8..d7aa648 100644
|
|
|
ee47b4 |
--- a/qbg/vdp22.c
|
|
|
ee47b4 |
+++ b/qbg/vdp22.c
|
|
|
ee47b4 |
@@ -42,6 +42,7 @@
|
|
|
ee47b4 |
#include "qbg_vdp22.h"
|
|
|
ee47b4 |
#include "qbg_utils.h"
|
|
|
ee47b4 |
#include "qbg_vdp22_cmds.h"
|
|
|
ee47b4 |
+#include "qbg_vdp22def.h"
|
|
|
ee47b4 |
|
|
|
ee47b4 |
/*
|
|
|
ee47b4 |
* VDP22 helper functions
|
|
|
ee47b4 |
@@ -469,7 +470,8 @@ static bool filter_ok(unsigned char ffmt, struct fid22 *fp,
|
|
|
ee47b4 |
else
|
|
|
ee47b4 |
rc = false;
|
|
|
ee47b4 |
}
|
|
|
ee47b4 |
- LLDPAD_DBG("%s:rc:%d\n", __func__, rc);
|
|
|
ee47b4 |
+ LLDPAD_DBG("%s: ffmt:%d gpid_on:%d rc:%d\n", __func__, ffmt,
|
|
|
ee47b4 |
+ gpid_on, rc);
|
|
|
ee47b4 |
return rc;
|
|
|
ee47b4 |
}
|
|
|
ee47b4 |
|
|
|
ee47b4 |
@@ -1007,12 +1009,26 @@ static pid_t havepid(struct vsi22 *vsi)
|
|
|
ee47b4 |
return mypid;
|
|
|
ee47b4 |
}
|
|
|
ee47b4 |
|
|
|
ee47b4 |
+unsigned char vdp22_getsm_errcode(struct vsi22 *vsi)
|
|
|
ee47b4 |
+{
|
|
|
ee47b4 |
+ unsigned char err_code = 0;
|
|
|
ee47b4 |
+
|
|
|
ee47b4 |
+ if (vsi->smi.kato)
|
|
|
ee47b4 |
+ err_code |= (1 << VDP22_KATO);
|
|
|
ee47b4 |
+ if (vsi->smi.acktimeout)
|
|
|
ee47b4 |
+ err_code |= (1 << VDP22_ACKTO);
|
|
|
ee47b4 |
+ if (vsi->smi.txmit_error)
|
|
|
ee47b4 |
+ err_code |= (1 << VDP22_TXERR);
|
|
|
ee47b4 |
+ return err_code;
|
|
|
ee47b4 |
+}
|
|
|
ee47b4 |
+
|
|
|
ee47b4 |
/*
|
|
|
ee47b4 |
* Convert and VSI22 to VDP netlink format and send it back to the originator.
|
|
|
ee47b4 |
*/
|
|
|
ee47b4 |
static int vdp22_back(struct vsi22 *vsi, pid_t to,
|
|
|
ee47b4 |
int (*fct)(struct vdpnl_vsi *))
|
|
|
ee47b4 |
{
|
|
|
ee47b4 |
+ unsigned char err_code;
|
|
|
ee47b4 |
int i;
|
|
|
ee47b4 |
struct vdpnl_vsi nl;
|
|
|
ee47b4 |
struct vdpnl_mac nlmac[vsi->no_fdata];
|
|
|
ee47b4 |
@@ -1025,6 +1041,8 @@ static int vdp22_back(struct vsi22 *vsi, pid_t to,
|
|
|
ee47b4 |
memcpy(nl.ifname, vsi->vdp->ifname, sizeof(nl.ifname));
|
|
|
ee47b4 |
nl.request = vsi->vsi_mode;
|
|
|
ee47b4 |
nl.response = vsi->status;
|
|
|
ee47b4 |
+ err_code = vdp22_getsm_errcode(vsi);
|
|
|
ee47b4 |
+ nl.response |= (err_code << VDP22_STATUS_BITS);
|
|
|
ee47b4 |
nl.vsi_mgrid = vsi->mgrid[0];
|
|
|
ee47b4 |
memcpy(nl.vsi_mgrid2, vsi->mgrid, sizeof(nl.vsi_mgrid2));
|
|
|
ee47b4 |
nl.vsi_typeversion = vsi->type_ver;
|
|
|
ee47b4 |
diff --git a/qbg/vdp22_cmds.c b/qbg/vdp22_cmds.c
|
|
|
ee47b4 |
index 409858d..5d5ef6b 100644
|
|
|
ee47b4 |
--- a/qbg/vdp22_cmds.c
|
|
|
ee47b4 |
+++ b/qbg/vdp22_cmds.c
|
|
|
ee47b4 |
@@ -165,7 +165,8 @@ static int handle_set_arg(struct cmd *cmd, char *arg, char *argvalue,
|
|
|
ee47b4 |
* bb: C for command and 2 or 3 for message version number
|
|
|
ee47b4 |
* cc: 1 for get command and 2 for set command
|
|
|
ee47b4 |
* dddddddd: 8 hex digits options, supported are op_arg, op_argval, op_conifg
|
|
|
ee47b4 |
- * and op_local
|
|
|
ee47b4 |
+ * and op_local. The number of filter (fid) parameters are encoded
|
|
|
ee47b4 |
+ * here (second byte from right).
|
|
|
ee47b4 |
* ee: 2 hex digit length of interface name
|
|
|
ee47b4 |
* ffff: string for interface name
|
|
|
ee47b4 |
* gg: 2 hex digit for bridge type (nearest customer bridge only)
|
|
|
ee47b4 |
@@ -179,7 +180,7 @@ static int handle_set_arg(struct cmd *cmd, char *arg, char *argvalue,
|
|
|
ee47b4 |
* The total input length can be used to determine the number of arguaments.
|
|
|
ee47b4 |
*
|
|
|
ee47b4 |
* The member ops of struct cmd settings depends on the invoked with
|
|
|
ee47b4 |
- * -T (cmd_gettlv) -a assoc:
|
|
|
ee47b4 |
+ * -T (cmd_getvsi) -a assoc:
|
|
|
ee47b4 |
* -c key --> ops=(0x15) op_config,op_arg,op_local), numargs > 0
|
|
|
ee47b4 |
* -c key=abc --> ops=(0x1d) op_config,op_arg,op_argval,op_local), numargs > 0
|
|
|
ee47b4 |
* -c --> ops=0x11 (op_config,op_local), numargs = 0
|
|
|
ee47b4 |
@@ -279,8 +280,16 @@ int vdp22_clif_cmd(UNUSED void *data, UNUSED struct sockaddr_un *from,
|
|
|
ee47b4 |
int vdp22_sendevent(struct vdpnl_vsi *p)
|
|
|
ee47b4 |
{
|
|
|
ee47b4 |
char msg[MAX_CLIF_MSGBUF];
|
|
|
ee47b4 |
+ char tmp_buf[MAX_CLIF_MSGBUF];
|
|
|
ee47b4 |
+ int c, len;
|
|
|
ee47b4 |
|
|
|
ee47b4 |
- vdp_vdpnl2str(p, msg, sizeof(msg));
|
|
|
ee47b4 |
+ vdp_vdpnl2str(p, tmp_buf, sizeof(msg));
|
|
|
ee47b4 |
+ len = strlen(tmp_buf);
|
|
|
ee47b4 |
+ if ((unsigned)len > sizeof(msg))
|
|
|
ee47b4 |
+ return 0;
|
|
|
ee47b4 |
+ c = snprintf(msg, sizeof(msg), "%04x%s", len, tmp_buf);
|
|
|
ee47b4 |
+ if ((c < 0) || ((unsigned)c >= sizeof(msg)))
|
|
|
ee47b4 |
+ return 0;
|
|
|
ee47b4 |
LLDPAD_DBG("%s:%s vsi:%p(%#2x), len:%zd msg:%s\n", __func__,
|
|
|
ee47b4 |
p->ifname, p, p->vsi_uuid[0], strlen(msg), msg);
|
|
|
ee47b4 |
send_event(16, LLDP_MOD_VDP22, msg);
|
|
|
ee47b4 |
@@ -324,6 +333,29 @@ static int ifok(struct cmd *cmd)
|
|
|
ee47b4 |
return good_cmd;
|
|
|
ee47b4 |
}
|
|
|
ee47b4 |
|
|
|
ee47b4 |
+static int get_vdp22_retval(int rc)
|
|
|
ee47b4 |
+{
|
|
|
ee47b4 |
+ if (!rc)
|
|
|
ee47b4 |
+ return cmd_success;
|
|
|
ee47b4 |
+
|
|
|
ee47b4 |
+ switch (rc) {
|
|
|
ee47b4 |
+ case -EPROTONOSUPPORT:
|
|
|
ee47b4 |
+ return cmd_vdp_prot_no_support;
|
|
|
ee47b4 |
+ case -EOPNOTSUPP:
|
|
|
ee47b4 |
+ return cmd_not_capable;
|
|
|
ee47b4 |
+ case -EINVAL:
|
|
|
ee47b4 |
+ return cmd_bad_params;
|
|
|
ee47b4 |
+ case -ENOMEM:
|
|
|
ee47b4 |
+ return cmd_vdp_nomem;
|
|
|
ee47b4 |
+ case -EBUSY:
|
|
|
ee47b4 |
+ return cmd_vdp_busy;
|
|
|
ee47b4 |
+ case -ENODEV:
|
|
|
ee47b4 |
+ return cmd_device_not_found;
|
|
|
ee47b4 |
+ default:
|
|
|
ee47b4 |
+ return cmd_failed;
|
|
|
ee47b4 |
+ }
|
|
|
ee47b4 |
+}
|
|
|
ee47b4 |
+
|
|
|
ee47b4 |
static int set_arg_vsi3(struct cmd *cmd, char *argvalue, bool test, int size)
|
|
|
ee47b4 |
{
|
|
|
ee47b4 |
cmd_status good_cmd = vdp22_cmdok(cmd, cmd_settlv);
|
|
|
ee47b4 |
@@ -340,7 +372,7 @@ static int set_arg_vsi3(struct cmd *cmd, char *argvalue, bool test, int size)
|
|
|
ee47b4 |
vsi.macsz = size;
|
|
|
ee47b4 |
rc = vdp_str2vdpnl(argvalue, &vsi, cmd->ifname);
|
|
|
ee47b4 |
if (rc) {
|
|
|
ee47b4 |
- good_cmd = cmd_bad_params;
|
|
|
ee47b4 |
+ good_cmd = get_vdp22_retval(rc);
|
|
|
ee47b4 |
goto out;
|
|
|
ee47b4 |
}
|
|
|
ee47b4 |
if (!port_find_by_ifindex(get_ifidx(cmd->ifname))) {
|
|
|
ee47b4 |
@@ -351,12 +383,8 @@ static int set_arg_vsi3(struct cmd *cmd, char *argvalue, bool test, int size)
|
|
|
ee47b4 |
if (good_cmd != cmd_success || test)
|
|
|
ee47b4 |
goto out;
|
|
|
ee47b4 |
rc = vdp22_request(&vsi, 1);
|
|
|
ee47b4 |
- if (!rc)
|
|
|
ee47b4 |
- good_cmd = cmd_success;
|
|
|
ee47b4 |
- else if (rc == -ENODEV)
|
|
|
ee47b4 |
- good_cmd = cmd_device_not_found;
|
|
|
ee47b4 |
- else
|
|
|
ee47b4 |
- good_cmd = cmd_failed;
|
|
|
ee47b4 |
+ good_cmd = get_vdp22_retval(rc);
|
|
|
ee47b4 |
+
|
|
|
ee47b4 |
out:
|
|
|
ee47b4 |
return good_cmd;
|
|
|
ee47b4 |
}
|
|
|
ee47b4 |
@@ -480,7 +508,8 @@ static int get_vsi_partial_arg(UNUSED char *arg, char *orig_argvalue,
|
|
|
ee47b4 |
int rc = -ENOMEM, len, c;
|
|
|
ee47b4 |
u16 vsi_arg_key_flags = 0;
|
|
|
ee47b4 |
|
|
|
ee47b4 |
- if (vdp22_parse_str_vdpnl(vsinl, &vsi_arg_key_flags, orig_argvalue))
|
|
|
ee47b4 |
+ rc = vdp22_parse_str_vdpnl(vsinl, &vsi_arg_key_flags, orig_argvalue);
|
|
|
ee47b4 |
+ if (rc)
|
|
|
ee47b4 |
goto out;
|
|
|
ee47b4 |
vdp = vdp22_getvdp(vsinl->ifname);
|
|
|
ee47b4 |
if (!vdp)
|
|
|
ee47b4 |
@@ -498,7 +527,6 @@ static int get_vsi_partial_arg(UNUSED char *arg, char *orig_argvalue,
|
|
|
ee47b4 |
len = strlen(tmp_buf);
|
|
|
ee47b4 |
c = snprintf(out + used, out_len - used, "%04x%s",
|
|
|
ee47b4 |
len, tmp_buf);
|
|
|
ee47b4 |
- vdp22_freemaclist(vsinl);
|
|
|
ee47b4 |
if ((c < 0) || ((unsigned)c >= (out_len - used)))
|
|
|
ee47b4 |
goto out_delvsi;
|
|
|
ee47b4 |
if (rc)
|
|
|
ee47b4 |
@@ -544,11 +572,14 @@ static int get_arg_vsi(struct cmd *cmd, char *arg, char *argvalue,
|
|
|
ee47b4 |
memset(&mac, 0, sizeof(mac));
|
|
|
ee47b4 |
vsi.macsz = fsize;
|
|
|
ee47b4 |
vsi.maclist = mac;
|
|
|
ee47b4 |
- if (!get_vsi_partial_arg(arg, argvalue, &vsi, vsi_str,
|
|
|
ee47b4 |
- sizeof(vsi_str)))
|
|
|
ee47b4 |
- goto out;
|
|
|
ee47b4 |
- } else if (!catvsis(&vsi, vsi_str, sizeof(vsi_str)))
|
|
|
ee47b4 |
+ rc = get_vsi_partial_arg(arg, argvalue, &vsi, vsi_str,
|
|
|
ee47b4 |
+ sizeof(vsi_str));
|
|
|
ee47b4 |
+ } else
|
|
|
ee47b4 |
+ rc = catvsis(&vsi, vsi_str, sizeof(vsi_str));
|
|
|
ee47b4 |
+ if (!rc) {
|
|
|
ee47b4 |
+ good_cmd = get_vdp22_retval(rc);
|
|
|
ee47b4 |
goto out;
|
|
|
ee47b4 |
+ }
|
|
|
ee47b4 |
rc = snprintf(obuf, obuf_len, "%s", vsi_str);
|
|
|
ee47b4 |
if (rc > 0 || rc < obuf_len)
|
|
|
ee47b4 |
good_cmd = cmd_success;
|
|
|
ee47b4 |
diff --git a/qbg/vdp22sm.c b/qbg/vdp22sm.c
|
|
|
ee47b4 |
index 6264f74..83a97fb 100644
|
|
|
ee47b4 |
--- a/qbg/vdp22sm.c
|
|
|
ee47b4 |
+++ b/qbg/vdp22sm.c
|
|
|
ee47b4 |
@@ -46,21 +46,6 @@
|
|
|
ee47b4 |
#include "qbg_vdp22.h"
|
|
|
ee47b4 |
#include "qbg_utils.h"
|
|
|
ee47b4 |
|
|
|
ee47b4 |
-struct vdp22_ptlv { /* Packed TLV for VDP data exchange */
|
|
|
ee47b4 |
- unsigned short head; /* TLV 16 bit header */
|
|
|
ee47b4 |
- unsigned char data[]; /* TLV Data buffer */
|
|
|
ee47b4 |
-};
|
|
|
ee47b4 |
-
|
|
|
ee47b4 |
-enum { /* VDP22 Protocol command responses */
|
|
|
ee47b4 |
- USEC_PER_SEC = 1000000, /* Microseconds per second */
|
|
|
ee47b4 |
- VDP22_RESBIT = 0x80, /* VSI reserved bit */
|
|
|
ee47b4 |
- VDP22_ACKBIT = 0x40, /* VSI Acknowledgement bit */
|
|
|
ee47b4 |
- VDP22_KEEPBIT = 0x20, /* VSI keep error bit */
|
|
|
ee47b4 |
- VDP22_HARDBIT = 0x10, /* VSI hard error bit */
|
|
|
ee47b4 |
- VDP22_STATUS_MASK = 0x0f, /* Status mask */
|
|
|
ee47b4 |
- VDP22_STATUS_SHIFT = 0, /* Status offset */
|
|
|
ee47b4 |
-};
|
|
|
ee47b4 |
-
|
|
|
ee47b4 |
/*
|
|
|
ee47b4 |
* Set status code
|
|
|
ee47b4 |
*/
|
|
|
ee47b4 |
diff --git a/qbg/vdp_ascii.c b/qbg/vdp_ascii.c
|
|
|
ee47b4 |
index 76dde4a..70ec79b 100644
|
|
|
ee47b4 |
--- a/qbg/vdp_ascii.c
|
|
|
ee47b4 |
+++ b/qbg/vdp_ascii.c
|
|
|
ee47b4 |
@@ -44,6 +44,7 @@
|
|
|
ee47b4 |
#include "qbg_vdpnl.h"
|
|
|
ee47b4 |
#include "qbg_utils.h"
|
|
|
ee47b4 |
#include "lldp_util.h"
|
|
|
ee47b4 |
+#include "messages.h"
|
|
|
ee47b4 |
|
|
|
ee47b4 |
struct vsi_keyword_handler vsi_key_handle[] = {
|
|
|
ee47b4 |
{VSI22_ARG_MODE_STR, VSI_MODE_ARG},
|
|
|
ee47b4 |
@@ -285,6 +286,24 @@ enum vsi_key_arg get_keywork_val(char *keyword)
|
|
|
ee47b4 |
return VSI_INVALID_ARG;
|
|
|
ee47b4 |
}
|
|
|
ee47b4 |
|
|
|
ee47b4 |
+/*
|
|
|
ee47b4 |
+ * If the ordering is maintained in vsi_key_handle, then this function is not
|
|
|
ee47b4 |
+ * necessary as the keyword can be retrieved using
|
|
|
ee47b4 |
+ * 'vsi_key_handle[keyval].keyword'.
|
|
|
ee47b4 |
+ */
|
|
|
ee47b4 |
+
|
|
|
ee47b4 |
+char *get_keyword_str(enum vsi_key_arg keyval)
|
|
|
ee47b4 |
+{
|
|
|
ee47b4 |
+ int count, key_str_size;
|
|
|
ee47b4 |
+
|
|
|
ee47b4 |
+ key_str_size = sizeof(vsi_key_handle) / sizeof(vsi_key_handle[0]);
|
|
|
ee47b4 |
+ for (count = 0; count < key_str_size; count++) {
|
|
|
ee47b4 |
+ if (vsi_key_handle[count].val == keyval)
|
|
|
ee47b4 |
+ return vsi_key_handle[count].keyword;
|
|
|
ee47b4 |
+ }
|
|
|
ee47b4 |
+ return NULL;
|
|
|
ee47b4 |
+}
|
|
|
ee47b4 |
+
|
|
|
ee47b4 |
int vdp22_parse_str_vdpnl(struct vdpnl_vsi *vsi, u16 *key_flags,
|
|
|
ee47b4 |
char *orig_argvalue)
|
|
|
ee47b4 |
{
|
|
|
ee47b4 |
@@ -315,52 +334,57 @@ int vdp22_parse_str_vdpnl(struct vdpnl_vsi *vsi, u16 *key_flags,
|
|
|
ee47b4 |
numargs = get_arg_val_list(argvalue, ilen, &ioff, args, argvals);
|
|
|
ee47b4 |
if (numargs == 0)
|
|
|
ee47b4 |
goto out_free;
|
|
|
ee47b4 |
+ rc = -EINVAL;
|
|
|
ee47b4 |
for (i = 0; i < numargs; i++) {
|
|
|
ee47b4 |
vsi_key = get_keywork_val(args[i]);
|
|
|
ee47b4 |
switch (vsi_key) {
|
|
|
ee47b4 |
case VSI_MODE_ARG:
|
|
|
ee47b4 |
if (!argvals[i] || !getmode(vsi, argvals[i]))
|
|
|
ee47b4 |
- goto out_free;
|
|
|
ee47b4 |
+ goto out_err;
|
|
|
ee47b4 |
break;
|
|
|
ee47b4 |
case VSI_MGRID2_ARG:
|
|
|
ee47b4 |
if (!argvals[i] || !getmgr2id(vsi, argvals[i]))
|
|
|
ee47b4 |
- goto out_free;
|
|
|
ee47b4 |
+ goto out_err;
|
|
|
ee47b4 |
break;
|
|
|
ee47b4 |
case VSI_TYPEID_ARG:
|
|
|
ee47b4 |
if (!argvals[i] ||
|
|
|
ee47b4 |
!getnumber(argvals[i], 0, 0xffffff, &no))
|
|
|
ee47b4 |
- goto out_free;
|
|
|
ee47b4 |
+ goto out_err;
|
|
|
ee47b4 |
vsi->vsi_typeid = no;
|
|
|
ee47b4 |
break;
|
|
|
ee47b4 |
case VSI_TYPEIDVER_ARG:
|
|
|
ee47b4 |
if (!argvals[i] || !getnumber(argvals[i], 0, 0xff, &no))
|
|
|
ee47b4 |
- goto out_free;
|
|
|
ee47b4 |
+ goto out_err;
|
|
|
ee47b4 |
vsi->vsi_typeversion = no;
|
|
|
ee47b4 |
break;
|
|
|
ee47b4 |
case VSI_VSIID_ARG:
|
|
|
ee47b4 |
if (!argvals[i] ||
|
|
|
ee47b4 |
vdp_str2uuid(vsi->vsi_uuid, argvals[i],
|
|
|
ee47b4 |
sizeof(vsi->vsi_uuid)))
|
|
|
ee47b4 |
- goto out_free;
|
|
|
ee47b4 |
+ goto out_err;
|
|
|
ee47b4 |
vsi->vsi_idfmt = VDP22_ID_UUID;
|
|
|
ee47b4 |
break;
|
|
|
ee47b4 |
case VSI_FILTER_ARG:
|
|
|
ee47b4 |
if (idx < vsi->macsz && !getfid(vsi, argvals[i], idx))
|
|
|
ee47b4 |
- goto out_free;
|
|
|
ee47b4 |
+ goto out_err;
|
|
|
ee47b4 |
idx++;
|
|
|
ee47b4 |
break;
|
|
|
ee47b4 |
case VSI_HINTS_ARG:
|
|
|
ee47b4 |
if (!argvals[i] || !gethints(vsi, argvals[i]))
|
|
|
ee47b4 |
- goto out_free;
|
|
|
ee47b4 |
+ goto out_err;
|
|
|
ee47b4 |
break;
|
|
|
ee47b4 |
default:
|
|
|
ee47b4 |
- goto out_free;
|
|
|
ee47b4 |
+ goto out_err;
|
|
|
ee47b4 |
}
|
|
|
ee47b4 |
num_arg_keys |= (1 << vsi_key);
|
|
|
ee47b4 |
}
|
|
|
ee47b4 |
*key_flags = num_arg_keys;
|
|
|
ee47b4 |
rc = 0;
|
|
|
ee47b4 |
|
|
|
ee47b4 |
+out_err:
|
|
|
ee47b4 |
+ if (rc)
|
|
|
ee47b4 |
+ LLDPAD_ERR("Incorrect arguments specified for key %s\n",
|
|
|
ee47b4 |
+ get_keyword_str(vsi_key));
|
|
|
ee47b4 |
out_free:
|
|
|
ee47b4 |
free(argvals);
|
|
|
ee47b4 |
out_args:
|
|
|
ee47b4 |
@@ -400,11 +424,16 @@ static int str2vdpnl(char *orig_argvalue, struct vdpnl_vsi *vsi)
|
|
|
ee47b4 |
u16 vsi_mand_mask = (1 << VSI_MAND_NUM_ARG) - 1;
|
|
|
ee47b4 |
u16 num_arg_keys = 0;
|
|
|
ee47b4 |
|
|
|
ee47b4 |
- if (vdp22_parse_str_vdpnl(vsi, &num_arg_keys, orig_argvalue))
|
|
|
ee47b4 |
+ rc = vdp22_parse_str_vdpnl(vsi, &num_arg_keys, orig_argvalue);
|
|
|
ee47b4 |
+ if (rc) {
|
|
|
ee47b4 |
+ LLDPAD_ERR("%s: Incorrect arguments\n", __func__);
|
|
|
ee47b4 |
goto out;
|
|
|
ee47b4 |
+ }
|
|
|
ee47b4 |
/* Return error if no filter information provided */
|
|
|
ee47b4 |
if ((num_arg_keys & vsi_mand_mask) == vsi_mand_mask)
|
|
|
ee47b4 |
rc = 0;
|
|
|
ee47b4 |
+ else
|
|
|
ee47b4 |
+ LLDPAD_ERR("%s: Incomplete arguments\n", __func__);
|
|
|
ee47b4 |
out:
|
|
|
ee47b4 |
return rc;
|
|
|
ee47b4 |
}
|
|
|
ee47b4 |
@@ -444,7 +473,6 @@ static char *check_and_update(size_t *total, size_t *length, char *s, int c)
|
|
|
ee47b4 |
/*
|
|
|
ee47b4 |
* Convert VSI association to string.
|
|
|
ee47b4 |
*/
|
|
|
ee47b4 |
-#ifdef LATER_USE
|
|
|
ee47b4 |
static const char *mode2str(unsigned char x)
|
|
|
ee47b4 |
{
|
|
|
ee47b4 |
if (x == VDP22_ASSOC)
|
|
|
ee47b4 |
@@ -457,7 +485,6 @@ static const char *mode2str(unsigned char x)
|
|
|
ee47b4 |
return "deassoc";
|
|
|
ee47b4 |
return "unknown";
|
|
|
ee47b4 |
}
|
|
|
ee47b4 |
-#endif
|
|
|
ee47b4 |
|
|
|
ee47b4 |
/*
|
|
|
ee47b4 |
* Convert filter information format into vlan[-mac][-group] string.
|
|
|
ee47b4 |
@@ -544,7 +571,12 @@ int vdp_vdpnl2str(struct vdpnl_vsi *p, char *s, size_t length)
|
|
|
ee47b4 |
char instance[VDP_UUID_STRLEN + 2];
|
|
|
ee47b4 |
|
|
|
ee47b4 |
mgrid2str(instance, p, sizeof(instance));
|
|
|
ee47b4 |
- c = snprintf(s, length, "%02x%s%04x%s%02x%s%04x%lu%02x%s%04x%d",
|
|
|
ee47b4 |
+ c = snprintf(s, length, "%02x%s%04x%s%02x%s%04x%s%02x%s%04x%lu%02x%s"
|
|
|
ee47b4 |
+ "%04x%d",
|
|
|
ee47b4 |
+ (unsigned int)strlen(VSI22_ARG_MODE_STR),
|
|
|
ee47b4 |
+ VSI22_ARG_MODE_STR,
|
|
|
ee47b4 |
+ (unsigned int)strlen(mode2str(p->request)),
|
|
|
ee47b4 |
+ mode2str(p->request),
|
|
|
ee47b4 |
(unsigned int)strlen(VSI22_ARG_MGRID_STR),
|
|
|
ee47b4 |
VSI22_ARG_MGRID_STR,
|
|
|
ee47b4 |
(unsigned int)strlen(instance), instance,
|
|
|
ee47b4 |
diff --git a/vdptool.c b/vdptool.c
|
|
|
ee47b4 |
index 551e829..f7fd288 100644
|
|
|
ee47b4 |
--- a/vdptool.c
|
|
|
ee47b4 |
+++ b/vdptool.c
|
|
|
ee47b4 |
@@ -54,6 +54,28 @@
|
|
|
ee47b4 |
#include "qbg22.h"
|
|
|
ee47b4 |
#include "qbg_vdp22_clif.h"
|
|
|
ee47b4 |
#include "lldp_util.h"
|
|
|
ee47b4 |
+#include "qbg_vdp22def.h"
|
|
|
ee47b4 |
+
|
|
|
ee47b4 |
+static char *print_vdp_status(enum vdp22_cmd_status status)
|
|
|
ee47b4 |
+{
|
|
|
ee47b4 |
+ char *str;
|
|
|
ee47b4 |
+
|
|
|
ee47b4 |
+ switch (status) {
|
|
|
ee47b4 |
+ case cmd_vdp_prot_no_support:
|
|
|
ee47b4 |
+ str = "VDP protocol not supported on interface";
|
|
|
ee47b4 |
+ break;
|
|
|
ee47b4 |
+ case cmd_vdp_nomem:
|
|
|
ee47b4 |
+ str = "Not enough memory";
|
|
|
ee47b4 |
+ break;
|
|
|
ee47b4 |
+ case cmd_vdp_busy:
|
|
|
ee47b4 |
+ str = "VSI association in progress";
|
|
|
ee47b4 |
+ break;
|
|
|
ee47b4 |
+ default:
|
|
|
ee47b4 |
+ str = "Unknown status";
|
|
|
ee47b4 |
+ break;
|
|
|
ee47b4 |
+ }
|
|
|
ee47b4 |
+ return str;
|
|
|
ee47b4 |
+}
|
|
|
ee47b4 |
|
|
|
ee47b4 |
static char *print_status(cmd_status status)
|
|
|
ee47b4 |
{
|
|
|
ee47b4 |
@@ -97,7 +119,7 @@ static char *print_status(cmd_status status)
|
|
|
ee47b4 |
str = "TLV does not support agent type";
|
|
|
ee47b4 |
break;
|
|
|
ee47b4 |
default:
|
|
|
ee47b4 |
- str = "Unknown status";
|
|
|
ee47b4 |
+ str = print_vdp_status(status);
|
|
|
ee47b4 |
break;
|
|
|
ee47b4 |
}
|
|
|
ee47b4 |
return str;
|
|
|
ee47b4 |
@@ -165,7 +187,7 @@ static int render_cmd(struct cmd *cmd, int argc, char **args, char **argvals)
|
|
|
ee47b4 |
|
|
|
ee47b4 |
int vdp_clif_command(struct clif *, char *, int);
|
|
|
ee47b4 |
|
|
|
ee47b4 |
-static int vdp_cmd_gettlv(struct clif *clif, int argc, char *argv[],
|
|
|
ee47b4 |
+static int vdp_cmd_getvsi(struct clif *clif, int argc, char *argv[],
|
|
|
ee47b4 |
struct cmd *cmd, int raw)
|
|
|
ee47b4 |
{
|
|
|
ee47b4 |
int numargs = 0;
|
|
|
ee47b4 |
@@ -219,7 +241,7 @@ out:
|
|
|
ee47b4 |
return cmd_invalid;
|
|
|
ee47b4 |
}
|
|
|
ee47b4 |
|
|
|
ee47b4 |
-static int vdp_cmd_settlv(struct clif *clif, int argc, char *argv[],
|
|
|
ee47b4 |
+static int vdp_cmd_setvsi(struct clif *clif, int argc, char *argv[],
|
|
|
ee47b4 |
struct cmd *cmd, int raw)
|
|
|
ee47b4 |
{
|
|
|
ee47b4 |
int numargs = 0;
|
|
|
ee47b4 |
@@ -299,12 +321,77 @@ static int vdp_parse_response(char *buf)
|
|
|
ee47b4 |
return hex2u8(buf + CLIF_STAT_OFF);
|
|
|
ee47b4 |
}
|
|
|
ee47b4 |
|
|
|
ee47b4 |
-int get_vsi_args(char *ibuf)
|
|
|
ee47b4 |
+void print_vsi_err_msg(char *key_val)
|
|
|
ee47b4 |
+{
|
|
|
ee47b4 |
+ unsigned long errcode;
|
|
|
ee47b4 |
+ int resp_err, smi_err;
|
|
|
ee47b4 |
+
|
|
|
ee47b4 |
+ errcode = strtol(key_val, NULL, 10);
|
|
|
ee47b4 |
+ resp_err = errcode & 0xff;
|
|
|
ee47b4 |
+ smi_err = (errcode >> VDP22_STATUS_BITS) & 0xff;
|
|
|
ee47b4 |
+
|
|
|
ee47b4 |
+ switch (resp_err) {
|
|
|
ee47b4 |
+ case VDP22_RESP_INVALID_FORMAT:
|
|
|
ee47b4 |
+ printf("\tError returned by Bridge: %s\n",
|
|
|
ee47b4 |
+ VSI22_INVALID_FRMT_ERR_STR);
|
|
|
ee47b4 |
+ break;
|
|
|
ee47b4 |
+ case VDP22_RESP_NO_RESOURCES:
|
|
|
ee47b4 |
+ printf("\tError returned by Bridge: %s\n",
|
|
|
ee47b4 |
+ VSI22_NO_RES_ERR_STR);
|
|
|
ee47b4 |
+ break;
|
|
|
ee47b4 |
+ case VDP22_RESP_NO_VSIMGR:
|
|
|
ee47b4 |
+ printf("\tError returned by Bridge: %s\n",
|
|
|
ee47b4 |
+ VSI22_NO_VSIMGR_ERR_STR);
|
|
|
ee47b4 |
+ break;
|
|
|
ee47b4 |
+ case VDP22_RESP_OTHER:
|
|
|
ee47b4 |
+ printf("\tError returned by Bridge: %s\n", VSI22_OTHER_ERR_STR);
|
|
|
ee47b4 |
+ break;
|
|
|
ee47b4 |
+ case VDP22_RESP_NOADDR:
|
|
|
ee47b4 |
+ printf("\tError returned by Bridge: %s\n",
|
|
|
ee47b4 |
+ VSI22_NOADDR_ERR_STR);
|
|
|
ee47b4 |
+ break;
|
|
|
ee47b4 |
+ case VDP22_RESP_DEASSOC:
|
|
|
ee47b4 |
+ printf("\tError returned by Bridge: %s\n", VSI22_DEASS_ERR_STR);
|
|
|
ee47b4 |
+ break;
|
|
|
ee47b4 |
+ case VDP22_RESP_TIMEOUT:
|
|
|
ee47b4 |
+ printf("\tError returned by Bridge: %s\n",
|
|
|
ee47b4 |
+ VSI22_TIMEOUT_ERR_STR);
|
|
|
ee47b4 |
+ break;
|
|
|
ee47b4 |
+ case VDP22_RESP_KEEP:
|
|
|
ee47b4 |
+ printf("\tError returned by Bridge: %s\n", VSI22_KEEP_ERR_STR);
|
|
|
ee47b4 |
+ break;
|
|
|
ee47b4 |
+ default:
|
|
|
ee47b4 |
+ break;
|
|
|
ee47b4 |
+ }
|
|
|
ee47b4 |
+ if (smi_err & (1 << VDP22_KATO))
|
|
|
ee47b4 |
+ printf("\tInternal Error : %s\n", VSI22_KATO_ERR_STR);
|
|
|
ee47b4 |
+ if (smi_err & (1 << VDP22_ACKTO))
|
|
|
ee47b4 |
+ printf("\tInternal Error : %s\n", VSI22_ACKTO_ERR_STR);
|
|
|
ee47b4 |
+ if (smi_err & (1 << VDP22_TXERR))
|
|
|
ee47b4 |
+ printf("\tInternal Error : %s\n", VSI22_TX_ERR_STR);
|
|
|
ee47b4 |
+}
|
|
|
ee47b4 |
+
|
|
|
ee47b4 |
+static void print_vsi(char **args, char **argvals, int numargs,
|
|
|
ee47b4 |
+ bool err_flag)
|
|
|
ee47b4 |
+{
|
|
|
ee47b4 |
+ int i;
|
|
|
ee47b4 |
+
|
|
|
ee47b4 |
+ for (i = 0; i < numargs; i++) {
|
|
|
ee47b4 |
+ if (err_flag && (!strcmp(args[i], VSI22_ARG_HINTS_STR)))
|
|
|
ee47b4 |
+ print_vsi_err_msg(argvals[i]);
|
|
|
ee47b4 |
+ else {
|
|
|
ee47b4 |
+ printf("\t%s", args[i]);
|
|
|
ee47b4 |
+ printf(" = %s\n", argvals[i]);
|
|
|
ee47b4 |
+ }
|
|
|
ee47b4 |
+ }
|
|
|
ee47b4 |
+}
|
|
|
ee47b4 |
+
|
|
|
ee47b4 |
+int get_vsi_args(char *ibuf, bool print_err_code)
|
|
|
ee47b4 |
{
|
|
|
ee47b4 |
int ioff = 0;
|
|
|
ee47b4 |
char **args;
|
|
|
ee47b4 |
char **argvals;
|
|
|
ee47b4 |
- int numargs, i;
|
|
|
ee47b4 |
+ int numargs;
|
|
|
ee47b4 |
int ilen = strlen(ibuf);
|
|
|
ee47b4 |
|
|
|
ee47b4 |
/* count args and argvalus */
|
|
|
ee47b4 |
@@ -321,17 +408,14 @@ int get_vsi_args(char *ibuf)
|
|
|
ee47b4 |
}
|
|
|
ee47b4 |
|
|
|
ee47b4 |
numargs = get_arg_val_list(ibuf, ilen, &ioff, args, argvals);
|
|
|
ee47b4 |
- for (i = 0; i < numargs; i++) {
|
|
|
ee47b4 |
- printf("\t%s", args[i]);
|
|
|
ee47b4 |
- printf(" = %s\n", argvals[i]);
|
|
|
ee47b4 |
- }
|
|
|
ee47b4 |
+ print_vsi(args, argvals, numargs, print_err_code);
|
|
|
ee47b4 |
|
|
|
ee47b4 |
free(args);
|
|
|
ee47b4 |
free(argvals);
|
|
|
ee47b4 |
return ioff;
|
|
|
ee47b4 |
}
|
|
|
ee47b4 |
|
|
|
ee47b4 |
-static void print_all_vsis(char *ibuf)
|
|
|
ee47b4 |
+static void print_all_vsis(char *ibuf, bool err_code, char *msg)
|
|
|
ee47b4 |
{
|
|
|
ee47b4 |
size_t ilen = strlen(ibuf);
|
|
|
ee47b4 |
u16 vsi_len;
|
|
|
ee47b4 |
@@ -346,8 +430,11 @@ static void print_all_vsis(char *ibuf)
|
|
|
ee47b4 |
ilen -= 2 * sizeof(u16);
|
|
|
ee47b4 |
strncpy(tmp_ibuf, ibuf + offset, vsi_len);
|
|
|
ee47b4 |
tmp_ibuf[vsi_len] = '\0';
|
|
|
ee47b4 |
- printf("%s %d:\n", "VSI ", vsi_cnt);
|
|
|
ee47b4 |
- get_vsi_args(tmp_ibuf);
|
|
|
ee47b4 |
+ if (msg)
|
|
|
ee47b4 |
+ printf("%s\n", msg);
|
|
|
ee47b4 |
+ else
|
|
|
ee47b4 |
+ printf("%s %d:\n", "VSI ", vsi_cnt);
|
|
|
ee47b4 |
+ get_vsi_args(tmp_ibuf, err_code);
|
|
|
ee47b4 |
offset += vsi_len;
|
|
|
ee47b4 |
ilen -= vsi_len;
|
|
|
ee47b4 |
vsi_cnt++;
|
|
|
ee47b4 |
@@ -361,7 +448,7 @@ static void print_cmd_response(char *ibuf, int status)
|
|
|
ee47b4 |
int ioff;
|
|
|
ee47b4 |
|
|
|
ee47b4 |
if (status != cmd_success) {
|
|
|
ee47b4 |
- printf("%s\n", print_status(status));
|
|
|
ee47b4 |
+ printf("FAILED: %s\n", print_status(status));
|
|
|
ee47b4 |
return;
|
|
|
ee47b4 |
}
|
|
|
ee47b4 |
|
|
|
ee47b4 |
@@ -385,7 +472,7 @@ static void print_cmd_response(char *ibuf, int status)
|
|
|
ee47b4 |
|
|
|
ee47b4 |
switch (cmd.cmd) {
|
|
|
ee47b4 |
case cmd_gettlv:
|
|
|
ee47b4 |
- print_all_vsis(ibuf + ioff);
|
|
|
ee47b4 |
+ print_all_vsis(ibuf + ioff, false, NULL);
|
|
|
ee47b4 |
break;
|
|
|
ee47b4 |
case cmd_settlv:
|
|
|
ee47b4 |
printf("%s", ibuf + ioff);
|
|
|
ee47b4 |
@@ -423,6 +510,7 @@ static void vdp_print_response(char *buf, int status)
|
|
|
ee47b4 |
static void vdp_print_event_msg(char *buf)
|
|
|
ee47b4 |
{
|
|
|
ee47b4 |
printf("%s buf:%s\n", __func__, buf);
|
|
|
ee47b4 |
+ print_all_vsis(buf + CLIF_RSP_OFF, true, "Response from VDP");
|
|
|
ee47b4 |
}
|
|
|
ee47b4 |
|
|
|
ee47b4 |
/*
|
|
|
ee47b4 |
@@ -519,8 +607,8 @@ static const char *commands_help =
|
|
|
ee47b4 |
" -v|version show version\n"
|
|
|
ee47b4 |
" -p|ping ping lldpad and query pid of lldpad\n"
|
|
|
ee47b4 |
" -q|quit exit lldptool (interactive mode)\n"
|
|
|
ee47b4 |
-" -t|get-tlv get tlvid value\n"
|
|
|
ee47b4 |
-" -T|set-tlv set arg for tlvid to value\n";
|
|
|
ee47b4 |
+" -t|get-vsi get VSI association(s)\n"
|
|
|
ee47b4 |
+" -T|set-vsi set VSI association\n";
|
|
|
ee47b4 |
|
|
|
ee47b4 |
static struct clif *clif_conn;
|
|
|
ee47b4 |
static int cli_quit;
|
|
|
ee47b4 |
@@ -638,7 +726,7 @@ static int _clif_command(struct clif *clif, char *cmd, int print)
|
|
|
ee47b4 |
size_t len;
|
|
|
ee47b4 |
int ret;
|
|
|
ee47b4 |
int rc;
|
|
|
ee47b4 |
- char reply[200];
|
|
|
ee47b4 |
+ char reply[MAX_CLIF_MSGBUF];
|
|
|
ee47b4 |
size_t reply_len2 = sizeof(reply);
|
|
|
ee47b4 |
|
|
|
ee47b4 |
print_raw_message(cmd, print);
|
|
|
ee47b4 |
@@ -653,7 +741,8 @@ static int _clif_command(struct clif *clif, char *cmd, int print)
|
|
|
ee47b4 |
printf("'%s' command timed out.\n", cmd);
|
|
|
ee47b4 |
return -2;
|
|
|
ee47b4 |
} else if (ret < 0) {
|
|
|
ee47b4 |
- printf("'%s' command failed.\n", cmd);
|
|
|
ee47b4 |
+ printf("'%s' command failed with error %s.\n", cmd,
|
|
|
ee47b4 |
+ strerror(errno));
|
|
|
ee47b4 |
return -1;
|
|
|
ee47b4 |
}
|
|
|
ee47b4 |
if (print) {
|
|
|
ee47b4 |
@@ -662,10 +751,8 @@ static int _clif_command(struct clif *clif, char *cmd, int print)
|
|
|
ee47b4 |
}
|
|
|
ee47b4 |
if (cli_attached) {
|
|
|
ee47b4 |
rc = clif_vsievt(clif, reply, &reply_len2, 5);
|
|
|
ee47b4 |
- printf("\nReturn from vsievt %d ret %d Reply %s\n", rc, ret,
|
|
|
ee47b4 |
- reply);
|
|
|
ee47b4 |
if (!rc)
|
|
|
ee47b4 |
- printf("\nMsg is %s\n", reply);
|
|
|
ee47b4 |
+ print_all_vsis(reply, true, "Response from VDP");
|
|
|
ee47b4 |
}
|
|
|
ee47b4 |
|
|
|
ee47b4 |
return ret;
|
|
|
ee47b4 |
@@ -739,10 +826,10 @@ static struct cli_cmd {
|
|
|
ee47b4 |
{ cmd_license, "license", cli_cmd_license },
|
|
|
ee47b4 |
{ cmd_version, "version", cli_cmd_version },
|
|
|
ee47b4 |
{ cmd_quit, "quit", cli_cmd_quit },
|
|
|
ee47b4 |
- { cmd_gettlv, "gettlv", vdp_cmd_gettlv },
|
|
|
ee47b4 |
- { cmd_gettlv, "get-tlv", vdp_cmd_gettlv },
|
|
|
ee47b4 |
- { cmd_settlv, "settlv", vdp_cmd_settlv },
|
|
|
ee47b4 |
- { cmd_settlv, "set-tlv", vdp_cmd_settlv },
|
|
|
ee47b4 |
+ { cmd_gettlv, "getvsi", vdp_cmd_getvsi },
|
|
|
ee47b4 |
+ { cmd_gettlv, "get-vsi", vdp_cmd_getvsi },
|
|
|
ee47b4 |
+ { cmd_settlv, "setvsi", vdp_cmd_setvsi },
|
|
|
ee47b4 |
+ { cmd_settlv, "set-vsi", vdp_cmd_setvsi },
|
|
|
ee47b4 |
{ cmd_nop, NULL, cli_cmd_nop }
|
|
|
ee47b4 |
};
|
|
|
ee47b4 |
|
|
|
ee47b4 |
@@ -774,8 +861,8 @@ static struct option lldptool_opts[] = {
|
|
|
ee47b4 |
{"help", 0, NULL, 'h'},
|
|
|
ee47b4 |
{"version", 0, NULL, 'v'},
|
|
|
ee47b4 |
{"stats", 0, NULL, 'S'},
|
|
|
ee47b4 |
- {"get-tlv", 0, NULL, 't'},
|
|
|
ee47b4 |
- {"set-tlv", 0, NULL, 'T'},
|
|
|
ee47b4 |
+ {"get-vsi", 0, NULL, 't'},
|
|
|
ee47b4 |
+ {"set-vsi", 0, NULL, 'T'},
|
|
|
ee47b4 |
{"get-lldp", 0, NULL, 'l'},
|
|
|
ee47b4 |
{"set-lldp", 0, NULL, 'L'},
|
|
|
ee47b4 |
{0, 0, 0, 0}
|
|
|
ee47b4 |
--
|
|
|
ee47b4 |
2.1.0
|
|
|
ee47b4 |
|