net/ncsi: Don't mark configured channels inactive

The concepts of a channel being 'active' and it having link are slightly
muddled in the NCSI driver. Tweak this slightly so that
NCSI_CHANNEL_ACTIVE represents a channel that has been configured and
enabled, and NCSI_CHANNEL_INACTIVE represents a de-configured channel.
This distinction is important because a channel can be 'active' but have
its link down; in this case the channel may still need to be configured
so that it may receive AEN link-state-change packets.

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Samuel Mendoza-Jonas 2018-11-16 15:51:57 +11:00 committed by David S. Miller
parent cd09ab095c
commit 0b970e1b04
2 changed files with 12 additions and 8 deletions

View File

@ -57,6 +57,7 @@ static int ncsi_aen_handler_lsc(struct ncsi_dev_priv *ndp,
int state; int state;
unsigned long old_data, data; unsigned long old_data, data;
unsigned long flags; unsigned long flags;
bool had_link, has_link;
/* Find the NCSI channel */ /* Find the NCSI channel */
ncsi_find_package_and_channel(ndp, h->common.channel, NULL, &nc); ncsi_find_package_and_channel(ndp, h->common.channel, NULL, &nc);
@ -73,6 +74,9 @@ static int ncsi_aen_handler_lsc(struct ncsi_dev_priv *ndp,
ncm->data[2] = data; ncm->data[2] = data;
ncm->data[4] = ntohl(lsc->oem_status); ncm->data[4] = ntohl(lsc->oem_status);
had_link = !!(old_data & 0x1);
has_link = !!(data & 0x1);
netdev_dbg(ndp->ndev.dev, "NCSI: LSC AEN - channel %u state %s\n", netdev_dbg(ndp->ndev.dev, "NCSI: LSC AEN - channel %u state %s\n",
nc->id, data & 0x1 ? "up" : "down"); nc->id, data & 0x1 ? "up" : "down");
@ -80,15 +84,16 @@ static int ncsi_aen_handler_lsc(struct ncsi_dev_priv *ndp,
state = nc->state; state = nc->state;
spin_unlock_irqrestore(&nc->lock, flags); spin_unlock_irqrestore(&nc->lock, flags);
if (!((old_data ^ data) & 0x1) || chained) if (state == NCSI_CHANNEL_INACTIVE)
return 0; netdev_warn(ndp->ndev.dev,
if (!(state == NCSI_CHANNEL_INACTIVE && (data & 0x1)) && "NCSI: Inactive channel %u received AEN!\n",
!(state == NCSI_CHANNEL_ACTIVE && !(data & 0x1))) nc->id);
if ((had_link == has_link) || chained)
return 0; return 0;
if (state == NCSI_CHANNEL_ACTIVE) if (had_link)
ndp->flags |= NCSI_DEV_RESHUFFLE; ndp->flags |= NCSI_DEV_RESHUFFLE;
ncsi_stop_channel_monitor(nc); ncsi_stop_channel_monitor(nc);
spin_lock_irqsave(&ndp->lock, flags); spin_lock_irqsave(&ndp->lock, flags);
list_add_tail_rcu(&nc->link, &ndp->channel_queue); list_add_tail_rcu(&nc->link, &ndp->channel_queue);

View File

@ -916,12 +916,11 @@ static void ncsi_configure_channel(struct ncsi_dev_priv *ndp)
break; break;
} }
nc->state = NCSI_CHANNEL_ACTIVE;
if (nc->modes[NCSI_MODE_LINK].data[2] & 0x1) { if (nc->modes[NCSI_MODE_LINK].data[2] & 0x1) {
hot_nc = nc; hot_nc = nc;
nc->state = NCSI_CHANNEL_ACTIVE;
} else { } else {
hot_nc = NULL; hot_nc = NULL;
nc->state = NCSI_CHANNEL_INACTIVE;
netdev_dbg(ndp->ndev.dev, netdev_dbg(ndp->ndev.dev,
"NCSI: channel %u link down after config\n", "NCSI: channel %u link down after config\n",
nc->id); nc->id);