Blob Blame History Raw
From 5b74605009a7d14bd93e5b068a55e28ff91dd02a Mon Sep 17 00:00:00 2001
From: Jens Osterkamp <jens@linux.vnet.ibm.com>
Date: Tue, 8 Feb 2011 00:51:58 -0800
Subject: [PATCH 07/51] new: call VDP station state machine on demand

With this patch the VDP station state machine is now only called if work is
pending. This reduces code paths and avoids problems e.g. with link up/down
events and VM operations in parallel.

Signed-off-by: Jens Osterkamp <jens@linux.vnet.ibm.com>
Signed-off-by: Petr Sabata <psabata@redhat.com>
---
 event_iface.c   |    3 +--
 lldp_vdp.c      |   24 ++++++++++++------------
 lldp_vdp_cmds.c |    1 -
 3 files changed, 13 insertions(+), 15 deletions(-)

diff --git a/event_iface.c b/event_iface.c
index 5d447c6..51ea951 100644
--- a/event_iface.c
+++ b/event_iface.c
@@ -454,8 +454,7 @@ static int event_if_parse_setmsg(struct nlmsghdr *nlh)
 		return -EINVAL;
 	}
 
-	vdp_somethingChangedLocal(profile, true);
-	vdp_vsi_sm_station(p);
+	vdp_somethingChangedLocal(p, true);
 
 	return 0;
 }
diff --git a/lldp_vdp.c b/lldp_vdp.c
index 0cbf71e..6ebf171 100644
--- a/lldp_vdp.c
+++ b/lldp_vdp.c
@@ -131,16 +131,16 @@ void vdp_print_profile(struct vsi_profile *profile)
 
 /* vdp_somethingChangedLocal - set flag if profile has changed
  * @profile: profile to set the flag for
- * @mode: mode to set the flag to
+ * @flag: set the flag to true or false
  *
  * no return value
  *
  * set the localChange flag with a mode to indicate a profile has changed.
  * used next time when a ecpdu with profiles is sent out.
  */
-void vdp_somethingChangedLocal(struct vsi_profile *profile, bool mode)
+void vdp_somethingChangedLocal(struct vsi_profile *profile, bool flag)
 {
-	profile->localChange = mode;
+	profile->localChange = flag;
 }
 
 /* vdp_keepaliveTimer_expired - checks for expired ack timer
@@ -192,10 +192,10 @@ void vdp_timeout_handler(void *eloop_data, void *user_ctx)
 		if (p->keepaliveTimer > 0)
 			p->keepaliveTimer--;
 
-		if (vdp_ackTimer_expired(p))
-			vdp_vsi_sm_station(p);
-
-		if (vdp_keepaliveTimer_expired(p))
+		if (vdp_ackTimer_expired(p) ||
+		    vdp_keepaliveTimer_expired(p) ||
+		    p->ackReceived ||
+		    p->localChange)
 			vdp_vsi_sm_station(p);
 	}
 
@@ -481,9 +481,11 @@ void vdp_vsi_sm_station(struct vsi_profile *profile)
 		case VSI_DEASSOC_PROCESSING:
 			profile->response = VDP_RESPONSE_NO_RESPONSE;
 			vdp_stop_keepaliveTimer(profile);
-			vdp_somethingChangedLocal(profile, true);
-			ecp_somethingChangedLocal(vd);
-			ecp_tx_run_sm(vd);
+			if (profile->localChange) {
+				ecp_somethingChangedLocal(vd);
+				ecp_tx_run_sm(vd);
+			}
+			vdp_somethingChangedLocal(profile, false);
 			vdp_start_ackTimer(profile);
 			break;
 		case VSI_EXIT:
@@ -825,8 +827,6 @@ int vdp_indicate(struct vdp_data *vd, struct unpacked_tlv *tlv, int ecp_mode)
 
 				LLDPAD_DBG("%s(%i): profile response: %s (%i).\n", __func__, __LINE__,
 					   vsi_responses[p->response], p->response);
-
-				vdp_vsi_sm_station(p);
 			} else {
 				LLDPAD_DBG("%s(%i): station: profile not found !\n", __func__, __LINE__);
 				/* ignore profile */
diff --git a/lldp_vdp_cmds.c b/lldp_vdp_cmds.c
index 9f67d7d..387aecd 100644
--- a/lldp_vdp_cmds.c
+++ b/lldp_vdp_cmds.c
@@ -323,7 +323,6 @@ static int set_arg_mode(struct cmd *cmd, char *arg, char *argvalue,
        }
 
        vdp_somethingChangedLocal(profile, true);
-       vdp_vsi_sm_station(p);
 
        return cmd_success;
 }
-- 
1.7.4.4