[PATCH 8/8] net/ncsi: LSC AEN handler improvement

Gavin Shan gwshan at linux.vnet.ibm.com
Mon May 9 11:47:19 AEST 2016


This improves the LSC (Link Status Change) AEN handler:

   * The first channel with up link is choosen as active channel.
   * The first channel is choosen as active channel if none of channels
     is link up.
   * The active channel is always configured when its link becomes up
     or it's just picked as new active channel.

Signed-off-by: Gavin Shan <gwshan at linux.vnet.ibm.com>
---
 net/ncsi/ncsi-aen.c    |  6 +++---
 net/ncsi/ncsi-manage.c | 22 ++++++++++++----------
 2 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/net/ncsi/ncsi-aen.c b/net/ncsi/ncsi-aen.c
index 87caaa8..5bc0873 100644
--- a/net/ncsi/ncsi-aen.c
+++ b/net/ncsi/ncsi-aen.c
@@ -81,14 +81,14 @@ static int ncsi_aen_handler_lsc(struct ncsi_dev_priv *ndp,
 	ncm->ncm_data[2] = ntohl(lsc->status);
 	ncm->ncm_data[4] = ntohl(lsc->oem_status);
 	if (!ndp->ndp_active_channel ||
-	    ndp->ndp_active_channel != nc ||
-	    ncm->ncm_data[2] & 0x1)
+	    ndp->ndp_active_channel != nc)
 		return 0;
 
 	/* If this channel is the active one and the link is down,
 	 * we have to choose another channel to be active one.
 	 */
-	ndp->ndp_flags |= NCSI_DEV_PRIV_FLAG_CHANGE_ACTIVE;
+	if (!(ncm->ncm_data[2] & 0x1))
+		ndp->ndp_flags |= NCSI_DEV_PRIV_FLAG_CHANGE_ACTIVE;
 	ncsi_suspend_dev(nd);
 
 	return 0;
diff --git a/net/ncsi/ncsi-manage.c b/net/ncsi/ncsi-manage.c
index 48575d2..5080f72 100644
--- a/net/ncsi/ncsi-manage.c
+++ b/net/ncsi/ncsi-manage.c
@@ -470,8 +470,7 @@ static void ncsi_dev_config(struct ncsi_dev_priv *ndp)
 		if (nc->nc_modes[NCSI_MODE_LINK].ncm_data[2] & 0x1)
 			nd->nd_link_up = 1;
 
-		if (!(ndp->ndp_flags & NCSI_DEV_PRIV_FLAG_CHANGE_ACTIVE))
-			nd->nd_handler(nd);
+		nd->nd_handler(nd);
 		ndp->ndp_flags &= ~NCSI_DEV_PRIV_FLAG_CHANGE_ACTIVE;
 
 		break;
@@ -500,13 +499,17 @@ static void ncsi_choose_active_channel(struct ncsi_dev_priv *ndp)
 	ndp->ndp_active_channel = NULL;
 	NCSI_FOR_EACH_PACKAGE(ndp, np) {
 		NCSI_FOR_EACH_CHANNEL(np, nc) {
-			ncm = &nc->nc_modes[NCSI_MODE_LINK];
-			if (ndp->ndp_active_channel ||
-			    !(ncm->ncm_data[2] & 0x1))
-				continue;
+			if (!ndp->ndp_active_channel) {
+				ndp->ndp_active_package = np;
+				ndp->ndp_active_channel = nc;
+			}
 
-			ndp->ndp_active_package = np;
-			ndp->ndp_active_channel = nc;
+			ncm = &nc->nc_modes[NCSI_MODE_LINK];
+			if (ncm->ncm_data[2] & 0x1) {
+				ndp->ndp_active_package = np;
+				ndp->ndp_active_channel = nc;
+				return;
+			}
 		}
 	}
 }
@@ -743,8 +746,7 @@ done:
 		if (ndp->ndp_flags & NCSI_DEV_PRIV_FLAG_CHANGE_ACTIVE)
 			ncsi_choose_active_channel(ndp);
 
-		if (!(ndp->ndp_flags & NCSI_DEV_PRIV_FLAG_CHANGE_ACTIVE) ||
-		    !ndp->ndp_active_channel) {
+		if (!ndp->ndp_active_channel) {
 			nd->nd_state = ncsi_dev_state_functional;
 			nd->nd_link_up = 0;
 			nd->nd_handler(nd);
-- 
2.1.0



More information about the openbmc mailing list