[lldp-devel] [PATCH 4/6] ecp22 change module notification type

Thomas Richter tmricht at linux.vnet.ibm.com
Tue Feb 5 16:24:59 UTC 2013


Change the module notification type from ecp22 to the
upper layer protocols to a better name.
Add support to send ecp22 payload upstream.

Signed-off-by: Thomas Richter <tmricht at linux.vnet.ibm.com>
---
 include/lldp_qbg22.h |    8 ++++----
 qbg/lldp_ecp22.c     |   35 ++++++++++++++++++++++++++++++++---
 2 files changed, 36 insertions(+), 7 deletions(-)

diff --git a/include/lldp_qbg22.h b/include/lldp_qbg22.h
index 633e67b..1007bd9 100644
--- a/include/lldp_qbg22.h
+++ b/include/lldp_qbg22.h
@@ -53,11 +53,11 @@
 enum {				/* Identify data type in union below */
 	EVB22_TO_ECP22 = 1,	/* Data from EVB to ECP */
 	EVB22_TO_VDP22 = 2,	/* Data from EVB to VDP */
-	ECP22_TO_VDP22 = 3,	/* Data from ECP to VDP */
+	ECP22_TO_ULP = 3,	/* Data from ECP to VDP, etc */
 	VDP22_TO_ECP22 = 4,	/* Data from VDP to ECP */
 	/* ECP22 subtypes */
 	ECP22_VDP = 1,		/* VDP protocol */
-	ECP22_PE_CSP = 2	/* Port extender control and status protocol */
+	ECP22_PECSP = 2		/* Port extender control and status protocol */
 };
 
 struct evb22_to_ecp22 {		/* Notification from EVB to ECP */
@@ -71,7 +71,7 @@ struct evb22_to_vdp22 {		/* Notification from EVB to VDP */
 	unsigned char gpid;	/* Support group ids in VDP */
 };
 
-struct vdp22_to_ecp22 {		/* Notification from VDP to ECP */
+struct ecp22_to_ulp {		/* Notification from ECP to VDP, etc */
 	unsigned short len;	/* Size of bytestream */
 	void *data;		/* Pointer to data */
 };
@@ -81,7 +81,7 @@ struct qbg22_imm {		/* Intermodule message data structure */
 	union {			/* Overlay possible data */
 		struct evb22_to_ecp22 a;
 		struct evb22_to_vdp22 b;
-		struct vdp22_to_ecp22 c;
+		struct ecp22_to_ulp c;
 	} u;
 };
 #endif
diff --git a/qbg/lldp_ecp22.c b/qbg/lldp_ecp22.c
index 1dd2330..7279121 100644
--- a/qbg/lldp_ecp22.c
+++ b/qbg/lldp_ecp22.c
@@ -477,14 +477,43 @@ static void ecp22_es_send_ack(struct ecp22 *ecp)
 		      sizeof ack_frame);
 }
 
+
+/*
+ * Notify upper layer protocol function of ECP payload data just received.
+ */
+static void ecp22_to_ulp(unsigned short ulp, struct ecp22 *ecp)
+{
+	size_t offset = ETH_HLEN + sizeof(struct ecp22_hdr);
+	struct qbg22_imm to_ulp;
+
+	to_ulp.data_type = ECP22_TO_ULP;
+	to_ulp.u.c.len = ecp->rx.frame_len - offset;
+	to_ulp.u.c.data =  &ecp->rx.frame[offset];
+	if (ulp == ECP22_VDP)
+		modules_notify(LLDP_MOD_VDP22, LLDP_MOD_ECP22, ecp->ifname,
+			       &to_ulp);
+	else
+		LLDPAD_INFO("%s:%s ECP subtype %d not yet implemented\n",
+			    __func__, ecp->ifname, ulp);
+}
+
 /*
  * Execute action in state newECPDU.
+ * Notify upper layer protocol of new data.
  */
 static void ecp22_es_new_ecpdu(struct ecp22 *ecp)
 {
-	LLDPAD_DBG("%s:%s state %s notify ULP seqno %#hx\n", __func__,
-		   ecp->ifname, ecp22_rx_states[ecp->rx.state], ecp->rx.seqno);
+	struct ecp22_hdr *hdr = (struct ecp22_hdr *)&ecp->rx.frame[ETH_HLEN];
+	struct ecp22_hdr ecphdr;
+	unsigned short ulp;
+
+	ecphdr.ver_op_sub = ntohs(hdr->ver_op_sub);
+	ulp = ecp22_hdr_read_subtype(&ecphdr);
+	LLDPAD_DBG("%s:%s state %s notify ULP %d seqno %#hx\n", __func__,
+		   ecp->ifname, ecp22_rx_states[ecp->rx.state],
+		   ulp, ecp->rx.seqno);
 	ecp->rx.last_seqno = ecp->rx.seqno;
+	ecp22_to_ulp(ulp, ecp);
 }
 
 /*
@@ -915,7 +944,7 @@ out:
  * Payload data from VDP module.
  * Returns true when data update succeeded.
  */
-static int data_from_vdp(char *ifname, struct vdp22_to_ecp22 *ptr)
+static int data_from_vdp(char *ifname, struct ecp22_to_ulp *ptr)
 {
 	struct packed_tlv d;
 
-- 
1.7.1



More information about the lldp-devel mailing list