Backport upstream NCSI fixes
Subsystems (2)
Samuel Mendoza-Jonas
maintainercover Backport upstream NCSI fixes
This backports a few useful NCSI fixes which are upstream, as well as replacing "net/ncsi: Don't assume last available channel exists" with the actual upstream version.
Gavin Shan (3):
net/ncsi: Disable HWA mode when no channels are found net/ncsi: Enforce failover on link monitor timeout net/ncsi: Fix length of GVI response packet
Samuel Mendoza-Jonas (4):
Revert "net/ncsi: Don't assume last available channel exists" net/ncsi: Don't limit vids based on hot_channel net/ncsi: Fix AEN HNCDSC packet length
net/ncsi: Stop monitor if channel times out or is inactive
net/ncsi/internal.h | 1 + net/ncsi/ncsi-aen.c | 2 +- net/ncsi/ncsi-manage.c | 59 +++++++++++++++++++++++++++----------------------- net/ncsi/ncsi-rsp.c | 2 +- 4 files changed, 35 insertions(+), 29 deletions(-)
Signature · 1 line
2.14.2
Samuel Mendoza-Jonas
maintainerPATCH 1/7 Revert "net/ncsi: Don't assume last available channel exists"
This reverts commit 7fd4e7d3b4fc52cdb965e2bbd9bbb3d57cb803fc.
--- net/ncsi/ncsi-manage.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-)
net/ncsi/ncsi-manage.c +6 -15
@@ -1407,10 +1407,7 @@ int ncsi_vlan_rx_add_vid(struct net_device *dev, __be16 proto, u16 vid) } ndp =TO_NCSI_DEV_PRIV (nd); -if (!ndp) { -netdev_warn (dev,"ncsi: No ncsi_dev_priv?\n" ); -return 0 ; - } + ncf = ndp->hot_channel->filters[NCSI_FILTER_VLAN ];/* Add the VLAN id to our internal list */ list_for_each_entry_rcu (vlan, &ndp->vlan_vids, list) {
@@ -1422,17 +1419,11 @@ int ncsi_vlan_rx_add_vid(struct net_device *dev, __be16 proto, u16 vid) } } -if (!ndp->hot_channel) { -netdev_warn (dev, -"ncsi: no available filter to check maximum\n" ); - }else { - ncf = ndp->hot_channel->filters[NCSI_FILTER_VLAN ]; -if (n_vids >= ncf->total) { -netdev_info (dev, -"NCSI Channel supports up to %u VLAN tags but %u are already set\n" , - ncf->total, n_vids); -return -EINVAL ; - } +if (n_vids >= ncf->total) { +netdev_info (dev, +"NCSI Channel supports up to %u VLAN tags but %u are already set\n" , + ncf->total, n_vids); +return -EINVAL ; } vlan =kzalloc (sizeof (*vlan),GFP_KERNEL );
Signature · 1 line
2.14.2
Samuel Mendoza-Jonas
maintainerPATCH 2/7 net/ncsi: Don't limit vids based on hot_channel
In reply to Samuel Mendoza-JonasCurrently we drop any new VLAN ids if there are more than the current (or last used) channel can support. Most importantly this is a problem if no channel has been selected yet, resulting in a segfault.
Secondly this does not necessarily reflect the capabilities of any other channels. Instead only drop a new VLAN id if we are already tracking the maximum allowed by the NCSI specification. Per-channel limits are already handled by ncsi_add_filter(), but add a message to set_one_vid() to make it obvious that the channel can not support any more VLAN ids.
--- net/ncsi/internal.h | 1 + net/ncsi/ncsi-manage.c | 17 +++++++++-------- 2 files changed, 10 insertions(+), 8 deletions(-)
net/ncsi/internal.h +1 -0
@@ -286,6 +286,7 @@ struct ncsi_dev_priv {struct work_struct work;/* For channel management */ struct packet_type ptype;/* NCSI packet Rx handler */ struct list_head node;/* Form NCSI device list */ +#define NCSI_MAX_VLAN_VIDS 15struct list_head vlan_vids;/* List of active VLAN IDs */ };
net/ncsi/ncsi-manage.c +9 -8
@@ -717,6 +717,10 @@ static int set_one_vid(struct ncsi_dev_priv *ndp, struct ncsi_channel *nc,if (index <0 ) {netdev_err (ndp->ndev.dev,"Failed to add new VLAN tag, error %d\n" , index); +if (index == -ENOSPC ) +netdev_err (ndp->ndev.dev, +"Channel %u already has all VLAN filters set\n" , + nc->id);return -1 ; }
@@ -1390,7 +1394,6 @@ static int ncsi_kick_channels(struct ncsi_dev_priv *ndp)int ncsi_vlan_rx_add_vid (struct net_device *dev,__be16 proto,u16 vid) { -struct ncsi_channel_filter *ncf;struct ncsi_dev_priv *ndp;unsigned int n_vids =0 ;struct vlan_vid *vlan;
@@ -1407,7 +1410,6 @@ int ncsi_vlan_rx_add_vid(struct net_device *dev, __be16 proto, u16 vid) } ndp =TO_NCSI_DEV_PRIV (nd); - ncf = ndp->hot_channel->filters[NCSI_FILTER_VLAN ];/* Add the VLAN id to our internal list */ list_for_each_entry_rcu (vlan, &ndp->vlan_vids, list) {
@@ -1418,12 +1420,11 @@ int ncsi_vlan_rx_add_vid(struct net_device *dev, __be16 proto, u16 vid)return 0 ; } } - -if (n_vids >= ncf->total) { -netdev_info (dev, -"NCSI Channel supports up to %u VLAN tags but %u are already set\n" , - ncf->total, n_vids); -return -EINVAL ; +if (n_vids >=NCSI_MAX_VLAN_VIDS ) { +netdev_warn (dev, +"tried to add vlan id %u but NCSI max already registered (%u)\n" , + vid,NCSI_MAX_VLAN_VIDS ); +return -ENOSPC ; } vlan =kzalloc (sizeof (*vlan),GFP_KERNEL );
Signature · 1 line
2.14.2
Samuel Mendoza-Jonas
maintainerPATCH 3/7 net/ncsi: Fix AEN HNCDSC packet length
In reply to Samuel Mendoza-JonasCorrect the value of the HNCDSC AEN packet.
--- net/ncsi/ncsi-aen.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ncsi/ncsi-aen.c +1 -1
@@ -187,7 +187,7 @@ static struct ncsi_aen_handler { } ncsi_aen_handlers[] = { { NCSI_PKT_AEN_LSC, 12, ncsi_aen_handler_lsc }, { NCSI_PKT_AEN_CR, 4, ncsi_aen_handler_cr }, - { NCSI_PKT_AEN_HNCDSC, 4, ncsi_aen_handler_hncdsc } + { NCSI_PKT_AEN_HNCDSC, 8, ncsi_aen_handler_hncdsc } }; int ncsi_aen_handler(struct ncsi_dev_priv *ndp, struct sk_buff *skb)
Signature · 1 line
2.14.2
Samuel Mendoza-Jonas
maintainerPATCH 4/7 net/ncsi: Stop monitor if channel times out or is inactive
In reply to Samuel Mendoza-Jonasncsi_channel_monitor() misses stopping the channel monitor in several places that it should, causing a WARN_ON_ONCE() to trigger when the monitor is re-started later, eg:
[ 459.040000] WARNING: CPU: 0 PID: 1093 at net/ncsi/ncsi-manage.c:269 ncsi_start_channel_monitor+0x7c/0x90 [ 459.040000] CPU: 0 PID: 1093 Comm: kworker/0:3 Not tainted 4.10.17-gaca2fdd #140 [ 459.040000] Hardware name: ASpeed SoC [ 459.040000] Workqueue: events ncsi_dev_work [ 459.040000] [<80010094>] (unwind_backtrace) from [<8000d950>] (show_stack+0x20/0x24) [ 459.040000] [<8000d950>] (show_stack) from [<801dbf70>] (dump_stack+0x20/0x28) [ 459.040000] [<801dbf70>] (dump_stack) from [<80018d7c>] (__warn+0xe0/0x108) [ 459.040000] [<80018d7c>] (__warn) from [<80018e70>] (warn_slowpath_null+0x30/0x38) [ 459.040000] [<80018e70>] (warn_slowpath_null) from [<803f6a08>] (ncsi_start_channel_monitor+0x7c/0x90) [ 459.040000] [<803f6a08>] (ncsi_start_channel_monitor) from [<803f7664>] (ncsi_configure_channel+0xdc/0x5fc) [ 459.040000] [<803f7664>] (ncsi_configure_channel) from [<803f8160>] (ncsi_dev_work+0xac/0x474) [ 459.040000] [<803f8160>] (ncsi_dev_work) from [<8002d244>] (process_one_work+0x1e0/0x450) [ 459.040000] [<8002d244>] (process_one_work) from [<8002d510>] (worker_thread+0x5c/0x570) [ 459.040000] [<8002d510>] (worker_thread) from [<80033614>] (kthread+0x124/0x164) [ 459.040000] [<80033614>] (kthread) from [<8000a5e8>] (ret_from_fork+0x14/0x2c)
This also updates the monitor instead of just returning if ncsi_xmit_cmd() fails to send the get-link-status command so that the monitor properly times out.
--- net/ncsi/ncsi-manage.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
net/ncsi/ncsi-manage.c +9 -6
@@ -199,11 +199,15 @@ static void ncsi_channel_monitor(unsigned long data) monitor_state = nc->monitor.state;spin_unlock_irqrestore (&nc->lock, flags); -if (!enabled || chained) +if (!enabled || chained) { +ncsi_stop_channel_monitor (nc);return ; + }if (state !=NCSI_CHANNEL_INACTIVE && - state !=NCSI_CHANNEL_ACTIVE ) + state !=NCSI_CHANNEL_ACTIVE ) { +ncsi_stop_channel_monitor (nc);return ; + }switch (monitor_state) {case NCSI_CHANNEL_MONITOR_START :
@@ -214,12 +218,9 @@ static void ncsi_channel_monitor(unsigned long data) nca.type =NCSI_PKT_CMD_GLS ; nca.req_flags =0 ; ret =ncsi_xmit_cmd (&nca); -if (ret) { +if (ret)netdev_err (ndp->ndev.dev,"Error %d sending GLS\n" , ret); -return ; - } -break ; case NCSI_CHANNEL_MONITOR_WAIT ... NCSI_CHANNEL_MONITOR_WAIT_MAX:break ;
@@ -230,6 +231,8 @@ static void ncsi_channel_monitor(unsigned long data) ndp->flags |=NCSI_DEV_RESHUFFLE ; } +ncsi_stop_channel_monitor (nc); +spin_lock_irqsave (&nc->lock, flags); nc->state =NCSI_CHANNEL_INVISIBLE ;spin_unlock_irqrestore (&nc->lock, flags);
Signature · 1 line
2.14.2
Samuel Mendoza-Jonas
maintainerPATCH 5/7 net/ncsi: Disable HWA mode when no channels are found
In reply to Samuel Mendoza-JonasFrom: Gavin Shan <[email protected]>
When there are no NCSI channels probed, HWA (Hardware Arbitration) mode is enabled. It's not correct because HWA depends on the fact:
NCSI channels exist and all of them support HWA mode. This disables HWA when no channels are probed.
--- net/ncsi/ncsi-manage.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
net/ncsi/ncsi-manage.c +10 -2
@@ -991,12 +991,15 @@ static bool ncsi_check_hwa(struct ncsi_dev_priv *ndp)struct ncsi_package *np;struct ncsi_channel *nc;unsigned int cap; +bool has_channel = false;/* The hardware arbitration is disabled if any one channel * doesn't support explicitly. */ NCSI_FOR_EACH_PACKAGE(ndp, np) { NCSI_FOR_EACH_CHANNEL(np, nc) { + has_channel = true; + cap = nc->caps[NCSI_CAP_GENERIC].cap; if (!(cap & NCSI_CAP_GENERIC_HWA) || (cap & NCSI_CAP_GENERIC_HWA_MASK) !=
@@ -1007,8 +1010,13 @@ static bool ncsi_check_hwa(struct ncsi_dev_priv *ndp) } } - ndp->flags |=NCSI_DEV_HWA ; -return true; +if (has_channel) { + ndp->flags |=NCSI_DEV_HWA ; +return true; + } + + ndp->flags &= ~NCSI_DEV_HWA ; +return false; }static int ncsi_enable_hwa (struct ncsi_dev_priv *ndp)
Signature · 1 line
2.14.2
Samuel Mendoza-Jonas
maintainerPATCH 6/7 net/ncsi: Enforce failover on link monitor timeout
In reply to Samuel Mendoza-JonasFrom: Gavin Shan <[email protected]>
The NCSI channel has been configured to provide service if its link monitor timer is enabled, regardless of its state (inactive or active). So the timeout event on the link monitor indicates the out-of-service on that channel, for which a failover is needed.
This sets NCSI_DEV_RESHUFFLE flag to enforce failover on link monitor timeout, regardless the channel's original state (inactive or active). Also, the link is put into "down" state to give the failing channel lowest priority when selecting for the active channel. The state of failing channel should be set to active in order for deinitialization and failover to be done.
--- net/ncsi/ncsi-manage.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
net/ncsi/ncsi-manage.c +5 -3
@@ -186,6 +186,7 @@ static void ncsi_channel_monitor(unsigned long data)struct ncsi_channel *nc = (struct ncsi_channel *)data;struct ncsi_package *np = nc->package;struct ncsi_dev_priv *ndp = np->ndp; +struct ncsi_channel_mode *ncm;struct ncsi_cmd_arg nca;bool enabled, chained;unsigned int monitor_state;
@@ -225,20 +226,21 @@ static void ncsi_channel_monitor(unsigned long data) case NCSI_CHANNEL_MONITOR_WAIT ... NCSI_CHANNEL_MONITOR_WAIT_MAX:break ;default : -if (!(ndp->flags &NCSI_DEV_HWA ) && - state ==NCSI_CHANNEL_ACTIVE ) { +if (!(ndp->flags &NCSI_DEV_HWA )) {ncsi_report_link (ndp, true); ndp->flags |=NCSI_DEV_RESHUFFLE ; }ncsi_stop_channel_monitor (nc); + ncm = &nc->modes[NCSI_MODE_LINK ];spin_lock_irqsave (&nc->lock, flags); nc->state =NCSI_CHANNEL_INVISIBLE ; + ncm->data[2 ] &= ~0x1 ;spin_unlock_irqrestore (&nc->lock, flags);spin_lock_irqsave (&ndp->lock, flags); - nc->state =NCSI_CHANNEL_INACTIVE ; + nc->state =NCSI_CHANNEL_ACTIVE ;list_add_tail_rcu (&nc->link, &ndp->channel_queue);spin_unlock_irqrestore (&ndp->lock, flags);ncsi_process_next_channel (ndp);
Signature · 1 line
2.14.2
Samuel Mendoza-Jonas
maintainerPATCH 7/7 net/ncsi: Fix length of GVI response packet
In reply to Samuel Mendoza-JonasFrom: Gavin Shan <[email protected]>
The length of GVI (GetVersionInfo) response packet should be 40 instead of 36. This issue was found from /sys/kernel/debug/ncsi/eth0/stats.
# ethtool --ncsi eth0 swstats
:
RESPONSE OK TIMEOUT ERROR
=======================================
GVI 0 0 2With this applied, no error reported on GVI response packets:
# ethtool --ncsi eth0 swstats
:
RESPONSE OK TIMEOUT ERROR
=======================================
GVI 2 0 0--- net/ncsi/ncsi-rsp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ncsi/ncsi-rsp.c +1 -1
@@ -959,7 +959,7 @@ static struct ncsi_rsp_handler { { NCSI_PKT_RSP_EGMF, 4, ncsi_rsp_handler_egmf }, { NCSI_PKT_RSP_DGMF, 4, ncsi_rsp_handler_dgmf }, { NCSI_PKT_RSP_SNFC, 4, ncsi_rsp_handler_snfc }, - { NCSI_PKT_RSP_GVI, 36, ncsi_rsp_handler_gvi }, + { NCSI_PKT_RSP_GVI, 40, ncsi_rsp_handler_gvi }, { NCSI_PKT_RSP_GC, 32, ncsi_rsp_handler_gc }, { NCSI_PKT_RSP_GP, -1, ncsi_rsp_handler_gp }, { NCSI_PKT_RSP_GCPS, 172, ncsi_rsp_handler_gcps },
Signature · 1 line
2.14.2
Quoted 11 lines · Samuel Mendoza-Jonas
This backports a few useful NCSI fixes which are upstream, as well as replacing
"net/ncsi: Don't assume last available channel exists" with the actual upstream
version.Gavin Shan (3):
net/ncsi: Disable HWA mode when no channels are found net/ncsi: Enforce failover on link monitor timeout net/ncsi: Fix length of GVI response packet
Quoted 5 lines
Samuel Mendoza-Jonas (4):
Revert "net/ncsi: Don't assume last available channel exists" net/ncsi: Don't limit vids based onhot_channelnet/ncsi: Fix AEN HNCDSC packet length
net/ncsi: Stop monitor if channel times out or is inactive
Series applied to dev-4.10.
Cheers,
Andrew
Quoted 8 lines
net/ncsi/internal.h | 1 +
net/ncsi/ncsi-aen.c | 2 +-
net/ncsi/ncsi-manage.c | 59 +++++++++++++++++++++++++++-------------
----------
net/ncsi/ncsi-rsp.c | 2 +-4 files changed, 35 insertions(+), 29 deletions(-)