Skip to content

Commit

Permalink
net/ncsi: LSC AEN handler improvement
Browse files Browse the repository at this point in the history
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@linux.vnet.ibm.com>
Signed-off-by: Joel Stanley <joel@jms.id.au>
  • Loading branch information
Gavin Shan authored and Joel Stanley committed May 11, 2016
1 parent 2f6ee36 commit 4657b13
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
6 changes: 3 additions & 3 deletions net/ncsi/ncsi-aen.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
22 changes: 12 additions & 10 deletions net/ncsi/ncsi-manage.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
}
}
}
Expand Down Expand Up @@ -743,8 +746,7 @@ static void ncsi_dev_suspend(struct ncsi_dev_priv *ndp)
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);
Expand Down

0 comments on commit 4657b13

Please sign in to comment.