net/ncsi: Allow enabling multiple packages & channels
Subsystems (3)
Samuel Mendoza-Jonas
maintainerv3 cover net/ncsi: Allow enabling multiple packages & channels
This series extends the NCSI driver to configure multiple packages and/or channels simultaneously. Since the RFC series this includes a few extra changes to fix areas in the driver that either made this harder or were roadblocks due to deviations from the NCSI specification.
Patches 1 & 2 fix two issues where the driver made assumptions about the capabilities of the NCSI topology.
Patches 3 & 4 change some internal semantics slightly to make multi-mode easier.
Patch 5 introduces a cleaner way of reconfiguring the NCSI configuration and keeping track of channel states.
Patch 6 implements the main multi-package/multi-channel configuration, configured via the Netlink interface.
Readers who have an interesting NCSI setup - especially multi-package with HWA - please test! I think I've covered all permutations but I don't have infinite hardware to test on.
Changes in v2:
- Updated use of the channel lock in ncsi_reset_dev(), making the channel invisible and leaving the monitor check to ncsi_stop_channel_monitor().
- Fixed ncsi_channel_is_tx() to consider the state of channels in other packages.
Changes in v3:
- Fixed bisectability bug in patch 1
- Consider channels on all packages in a few places when multi-package is enabled.
- Avoid doubling up reset operations, and check the current driver state before reset to let any running operations complete.
- Reorganise the LSC handler slightly to avoid enabling Tx twice.
Samuel Mendoza-Jonas (6):
net/ncsi: Don't enable all channels when HWA available net/ncsi: Probe single packages to avoid conflict net/ncsi: Don't deselect package in suspend if active net/ncsi: Don't mark configured channels inactive net/ncsi: Reset channel state in ncsi_start_dev() net/ncsi: Configure multi-package, multi-channel modes with failover
include/uapi/linux/ncsi.h | 15 ++ net/ncsi/internal.h | 19 +- net/ncsi/ncsi-aen.c | 72 ++++-- net/ncsi/ncsi-manage.c | 511 ++++++++++++++++++++++++++------------ net/ncsi/ncsi-netlink.c | 233 ++++++++++++++--- net/ncsi/ncsi-rsp.c | 2 +- 6 files changed, 646 insertions(+), 206 deletions(-)
Signature · 1 line
2.19.1
Samuel Mendoza-Jonas
maintainerPATCH v3 1/6 net/ncsi: Don't enable all channels when HWA available
NCSI hardware arbitration allows multiple packages to be enabled at once and share the same wiring. If the NCSI driver recognises that HWA is available it unconditionally enables all packages and channels; but that is a configuration decision rather than something required by HWA. Additionally the current implementation will not failover on link events which can cause connectivity to be lost unless the interface is manually bounced.
Retain basic HWA support but remove the separate configuration path to enable all channels, leaving this to be handled by a later implementation.
--- net/ncsi/ncsi-aen.c | 3 +-- net/ncsi/ncsi-manage.c | 50 ++++-------------------------------------- 2 files changed, 5 insertions(+), 48 deletions(-)
net/ncsi/ncsi-aen.c +1 -2
@@ -86,8 +86,7 @@ static int ncsi_aen_handler_lsc(struct ncsi_dev_priv *ndp, !(state == NCSI_CHANNEL_ACTIVE && !(data & 0x1)))return 0 ; -if (!(ndp->flags &NCSI_DEV_HWA ) && - state ==NCSI_CHANNEL_ACTIVE ) +if (state ==NCSI_CHANNEL_ACTIVE ) ndp->flags |=NCSI_DEV_RESHUFFLE ;ncsi_stop_channel_monitor (nc);
net/ncsi/ncsi-manage.c +4 -46
80 lines not on this page · raw message
Signature · 1 line
2.19.1
Samuel Mendoza-Jonas
maintainerPATCH v3 2/6 net/ncsi: Probe single packages to avoid conflict
In reply to Samuel Mendoza-JonasCurrently the NCSI driver sends a select-package command to all possible packages simultaneously to discover what packages are available. However at this stage in the probe process the driver does not know if hardware arbitration is available: if it isn't then this process could cause collisions on the RMII bus when packages try to respond.
Update the probe loop to probe each package one by one, and once complete check if HWA is universally supported.
--- net/ncsi/internal.h | 1 + net/ncsi/ncsi-manage.c | 85 +++++++++++++++--------------------------- 2 files changed, 31 insertions(+), 55 deletions(-)
net/ncsi/internal.h +1 -0
@@ -292,6 +292,7 @@ struct ncsi_dev_priv {#if IS_ENABLED (CONFIG_IPV6 )unsigned int inet6_addr_num;/* Number of IPv6 addresses */ #endif +unsigned int package_probe_id;/* Current ID during probe */ unsigned int package_num;/* Number of packages */ struct list_head packages;/* List of packages */ struct ncsi_channel *hot_channel;/* Channel was ever active */
net/ncsi/ncsi-manage.c +30 -55
125 lines not on this page · raw message
Signature · 1 line
2.19.1
Samuel Mendoza-Jonas
maintainerPATCH v3 3/6 net/ncsi: Don't deselect package in suspend if active
In reply to Samuel Mendoza-JonasWhen a package is deselected all channels of that package cease communication. If there are other channels active on the package of the suspended channel this will disable them as well, so only send a deselect-package command if no other channels are active.
--- net/ncsi/ncsi-manage.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
net/ncsi/ncsi-manage.c +13 -2
@@ -440,12 +440,14 @@ static void ncsi_request_timeout(struct timer_list *t)static void ncsi_suspend_channel (struct ncsi_dev_priv *ndp) {struct ncsi_dev *nd = &ndp->ndev; -struct ncsi_package *np = ndp->active_package; -struct ncsi_channel *nc = ndp->active_channel; +struct ncsi_package *np; +struct ncsi_channel *nc, *tmp;struct ncsi_cmd_arg nca;unsigned long flags;int ret; + np = ndp->active_package; + nc = ndp->active_channel; nca.ndp = ndp; nca.req_flags =NCSI_REQ_FLAG_EVENT_DRIVEN ;switch (nd->state) {
@@ -521,6 +523,15 @@ static void ncsi_suspend_channel(struct ncsi_dev_priv *ndp)if (ret) goto error; + NCSI_FOR_EACH_CHANNEL(np, tmp) { +/* If there is another channel active on this package +* do not deselect the package. +*/ +if (tmp != nc && tmp->state ==NCSI_CHANNEL_ACTIVE ) { + nd->state = ncsi_dev_state_suspend_done; +break ; + } + }break ;case ncsi_dev_state_suspend_deselect: ndp->pending_req_num =1 ;
Signature · 1 line
2.19.1
Samuel Mendoza-Jonas
maintainerPATCH v3 4/6 net/ncsi: Don't mark configured channels inactive
In reply to Samuel Mendoza-JonasThe 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.
--- net/ncsi/ncsi-aen.c | 17 +++++++++++------ net/ncsi/ncsi-manage.c | 3 +-- 2 files changed, 12 insertions(+), 8 deletions(-)
net/ncsi/ncsi-aen.c +11 -6
@@ -57,6 +57,7 @@ static int ncsi_aen_handler_lsc(struct ncsi_dev_priv *ndp,int state;unsigned long old_data, data;unsigned long flags; +bool had_link, has_link;/* Find the NCSI channel */ 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[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" , nc->id, data &0x1 ?"up" :"down" );
@@ -80,15 +84,16 @@ static int ncsi_aen_handler_lsc(struct ncsi_dev_priv *ndp, state = nc->state;spin_unlock_irqrestore (&nc->lock, flags); -if (!((old_data ^ data) &0x1 ) || chained) -return 0 ; -if (!(state ==NCSI_CHANNEL_INACTIVE && (data &0x1 )) && - !(state ==NCSI_CHANNEL_ACTIVE && !(data &0x1 ))) +if (state ==NCSI_CHANNEL_INACTIVE ) +netdev_warn (ndp->ndev.dev, +"NCSI: Inactive channel %u received AEN!\n" , + nc->id); + +if ((had_link == has_link) || chained)return 0 ; -if (state ==NCSI_CHANNEL_ACTIVE ) +if (had_link) ndp->flags |=NCSI_DEV_RESHUFFLE ; -ncsi_stop_channel_monitor (nc);spin_lock_irqsave (&ndp->lock, flags);list_add_tail_rcu (&nc->link, &ndp->channel_queue);
net/ncsi/ncsi-manage.c +1 -2
@@ -916,12 +916,11 @@ static void ncsi_configure_channel(struct ncsi_dev_priv *ndp)break ; } + nc->state =NCSI_CHANNEL_ACTIVE ;if (nc->modes[NCSI_MODE_LINK ].data[2 ] &0x1 ) { hot_nc = nc; - nc->state =NCSI_CHANNEL_ACTIVE ; }else { hot_nc =NULL ; - nc->state =NCSI_CHANNEL_INACTIVE ;netdev_dbg (ndp->ndev.dev,"NCSI: channel %u link down after config\n" , nc->id);
Signature · 1 line
2.19.1
Samuel Mendoza-Jonas
maintainerPATCH v3 5/6 net/ncsi: Reset channel state in ncsi_start_dev()
In reply to Samuel Mendoza-JonasWhen the NCSI driver is stopped with ncsi_stop_dev() the channel monitors are stopped and the state set to "inactive". However the channels are still configured and active from the perspective of the network controller. We should suspend each active channel but in the context of ncsi_stop_dev() the transmit queue has been or is about to be stopped so we won't have time to do so.
Instead when ncsi_start_dev() is called if the NCSI topology has already been probed then call ncsi_reset_dev() to suspend any channels that were previously active. This resets the network controller to a known state, provides an up to date view of channel link state, and makes sure that mode flags such as NCSI_MODE_TX_ENABLE are properly reset.
In addition to ncsi_start_dev() use ncsi_reset_dev() in ncsi-netlink.c to update the channel configuration more cleanly.
--- net/ncsi/internal.h | 2 + net/ncsi/ncsi-manage.c | 98 ++++++++++++++++++++++++++++++++++++++--- net/ncsi/ncsi-netlink.c | 12 ++--- 3 files changed, 101 insertions(+), 11 deletions(-)
net/ncsi/internal.h +2 -0
@@ -287,6 +287,7 @@ struct ncsi_dev_priv {#define NCSI_DEV_PROBED 1/* Finalized NCSI topology */ #define NCSI_DEV_HWA 2/* Enabled HW arbitration */ #define NCSI_DEV_RESHUFFLE 4 +#define NCSI_DEV_RESET 8/* Reset state of NC */ unsigned int gma_flag;/* OEM GMA flag */ spinlock_t lock;/* Protect the NCSI device */ #if IS_ENABLED (CONFIG_IPV6 )
@@ -342,6 +343,7 @@ extern spinlock_t ncsi_dev_lock;list_for_each_entry_rcu (nc, &np->channels, node)/* Resources */ +int ncsi_reset_dev(struct ncsi_dev *nd);void ncsi_start_channel_monitor (struct ncsi_channel *nc);void ncsi_stop_channel_monitor (struct ncsi_channel *nc); struct ncsi_channel *ncsi_find_channel(struct ncsi_package *np,
net/ncsi/ncsi-manage.c +93 -5
134 lines not on this page · raw message
net/ncsi/ncsi-netlink.c +6 -6
@@ -330,9 +330,9 @@ static int ncsi_set_interface_nl(struct sk_buff *msg, struct genl_info *info) package_id, channel_id, channel_id == NCSI_RESERVED_CHANNEL ? " (any)" : ""); -/* Bounce the NCSI channel to set changes */ -ncsi_stop_dev (&ndp->ndev); -ncsi_start_dev (&ndp->ndev); +/* Update channel configuration */ +if (!(ndp->flags &NCSI_DEV_RESET )) +ncsi_reset_dev (&ndp->ndev);return 0 ; }
@@ -360,9 +360,9 @@ static int ncsi_clear_interface_nl(struct sk_buff *msg, struct genl_info *info)spin_unlock_irqrestore (&ndp->lock, flags);netdev_info (ndp->ndev.dev,"NCSI: Cleared preferred package/channel\n" ); -/* Bounce the NCSI channel to set changes */ -ncsi_stop_dev (&ndp->ndev); -ncsi_start_dev (&ndp->ndev); +/* Update channel configuration */ +if (!(ndp->flags &NCSI_DEV_RESET )) +ncsi_reset_dev (&ndp->ndev);return 0 ; }
Signature · 1 line
2.19.1
Samuel Mendoza-Jonas
maintainerPATCH v3 6/6 net/ncsi: Configure multi-package, multi-channel modes with failover
In reply to Samuel Mendoza-JonasThis patch extends the ncsi-netlink interface with two new commands and three new attributes to configure multiple packages and/or channels at once, and configure specific failover modes.
NCSI_CMD_SET_PACKAGE mask and NCSI_CMD_SET_CHANNEL_MASK set a whitelist of packages or channels allowed to be configured with the NCSI_ATTR_PACKAGE_MASK and NCSI_ATTR_CHANNEL_MASK attributes respectively. If one of these whitelists is set only packages or channels matching the whitelist are considered for the channel queue in ncsi_choose_active_channel().
These commands may also use the NCSI_ATTR_MULTI_FLAG to signal that multiple packages or channels may be configured simultaneously. NCSI hardware arbitration (HWA) must be available in order to enable multi-package mode. Multi-channel mode is always available.
If the NCSI_ATTR_CHANNEL_ID attribute is present in the NCSI_CMD_SET_CHANNEL_MASK command the it sets the preferred channel as with the NCSI_CMD_SET_INTERFACE command. The combination of preferred channel and channel whitelist defines a primary channel and the allowed failover channels.
If the NCSI_ATTR_MULTI_FLAG attribute is also present then the preferred channel is configured for Tx/Rx and the other channels are enabled only for Rx.
--- include/uapi/linux/ncsi.h | 15 +++ net/ncsi/internal.h | 16 ++- net/ncsi/ncsi-aen.c | 60 +++++++-- net/ncsi/ncsi-manage.c | 264 +++++++++++++++++++++++++++++++------- net/ncsi/ncsi-netlink.c | 221 +++++++++++++++++++++++++++---- net/ncsi/ncsi-rsp.c | 2 +- 6 files changed, 490 insertions(+), 88 deletions(-)
include/uapi/linux/ncsi.h +15 -0
@@ -26,6 +26,12 @@* @NCSI_CMD_SEND_CMD: send NC-SI command to network card. * Requires NCSI_ATTR_IFINDEX, NCSI_ATTR_PACKAGE_ID * and NCSI_ATTR_CHANNEL_ID. +* @NCSI_CMD_SET_PACKAGE_MASK: set a whitelist of allowed packages. +* Requires NCSI_ATTR_IFINDEX and NCSI_ATTR_PACKAGE_MASK. +* @NCSI_CMD_SET_CHANNEL_MASK: set a whitelist of allowed channels. +* Requires NCSI_ATTR_IFINDEX, NCSI_ATTR_PACKAGE_ID, and +* NCSI_ATTR_CHANNEL_MASK. If NCSI_ATTR_CHANNEL_ID is present it sets +* the primary channel. * @NCSI_CMD_MAX: highest command number */ enum ncsi_nl_commands {
@@ -34,6 +40,8 @@ enum ncsi_nl_commands {NCSI_CMD_SET_INTERFACE ,NCSI_CMD_CLEAR_INTERFACE ,NCSI_CMD_SEND_CMD , +NCSI_CMD_SET_PACKAGE_MASK , +NCSI_CMD_SET_CHANNEL_MASK , __NCSI_CMD_AFTER_LAST,NCSI_CMD_MAX = __NCSI_CMD_AFTER_LAST -1
@@ -48,6 +56,10 @@ enum ncsi_nl_commands {* @NCSI_ATTR_PACKAGE_ID: package ID * @NCSI_ATTR_CHANNEL_ID: channel ID * @NCSI_ATTR_DATA: command payload +* @NCSI_ATTR_MULTI_FLAG: flag to signal that multi-mode should be enabled with +* NCSI_CMD_SET_PACKAGE_MASK or NCSI_CMD_SET_CHANNEL_MASK. +* @NCSI_ATTR_PACKAGE_MASK: 32-bit mask of allowed packages. +* @NCSI_ATTR_CHANNEL_MASK: 32-bit mask of allowed channels. * @NCSI_ATTR_MAX: highest attribute number */ enum ncsi_nl_attrs {
@@ -57,6 +69,9 @@ enum ncsi_nl_attrs {NCSI_ATTR_PACKAGE_ID ,NCSI_ATTR_CHANNEL_ID ,NCSI_ATTR_DATA , +NCSI_ATTR_MULTI_FLAG , +NCSI_ATTR_PACKAGE_MASK , +NCSI_ATTR_CHANNEL_MASK , __NCSI_ATTR_AFTER_LAST,NCSI_ATTR_MAX = __NCSI_ATTR_AFTER_LAST -1
net/ncsi/internal.h +14 -2
@@ -222,6 +222,10 @@ struct ncsi_package {unsigned int channel_num;/* Number of channels */ struct list_head channels;/* List of chanels */ struct list_head node;/* Form list of packages */ + +bool multi_channel;/* Enable multiple channels */ +u32 channel_whitelist;/* Channels to configure */ +struct ncsi_channel *preferred_channel;/* Primary channel */ };struct ncsi_request {
@@ -297,8 +301,6 @@ struct ncsi_dev_priv {unsigned int package_num;/* Number of packages */ struct list_head packages;/* List of packages */ struct ncsi_channel *hot_channel;/* Channel was ever active */ -struct ncsi_package *force_package;/* Force a specific package */ -struct ncsi_channel *force_channel;/* Force a specific channel */ struct ncsi_request requests[256 ];/* Request table */ unsigned int request_id;/* Last used request ID */ #define NCSI_REQ_START_IDX 1
@@ -311,6 +313,9 @@ struct ncsi_dev_priv {struct list_head node;/* Form NCSI device list */ #define NCSI_MAX_VLAN_VIDS 15struct list_head vlan_vids;/* List of active VLAN IDs */ + +bool multi_package;/* Enable multiple packages */ +u32 package_whitelist;/* Packages to configure */ };struct ncsi_cmd_arg {
@@ -364,6 +369,13 @@ struct ncsi_request *ncsi_alloc_request(struct ncsi_dev_priv *ndp,void ncsi_free_request (struct ncsi_request *nr);struct ncsi_dev *ncsi_find_dev (struct net_device *dev);int ncsi_process_next_channel (struct ncsi_dev_priv *ndp); +bool ncsi_channel_has_link (struct ncsi_channel *channel); +bool ncsi_channel_is_last (struct ncsi_dev_priv *ndp, +struct ncsi_channel *channel); +int ncsi_update_tx_channel (struct ncsi_dev_priv *ndp, +struct ncsi_package *np, +struct ncsi_channel *disable, +struct ncsi_channel *enable);/* Packet handlers */ u32 ncsi_calculate_checksum (unsigned char *data,int len);
net/ncsi/ncsi-aen.c +48 -12
76 lines not on this page · raw message
net/ncsi/ncsi-manage.c +219 -45
352 lines not on this page · raw message
net/ncsi/ncsi-netlink.c +193 -28
287 lines not on this page · raw message
net/ncsi/ncsi-rsp.c +1 -1
@@ -256,7 +256,7 @@ static int ncsi_rsp_handler_dcnt(struct ncsi_request *nr)if (!ncm->enable)return 0 ; - ncm->enable =1 ; + ncm->enable =0 ;return 0 ; }
Signature · 1 line
2.19.1
RE: [PATCH net-next v3 6/6] net/ncsi: Configure multi-package, multi-channel modes with failover
Hi Samuel,
For multi-package and multi-channel case, channel seems to be select correctly. Expect that, I still see the timing issue for back-to-back netlink command. Due to that, channel might be set to invisible state. Please refer to ncsi0 and ncsi2 below. The channel state is set to 3.
cat /sys/kernel/debug/ncsi_protocol/ncsi_device_status
IFIDX IFNAME NAME PID CID RX TX MP MC WP WC PC CS PS LS RU CR NQ HA
=====================================================================
2 eth2 ncsi0 000 000 1 1 1 1 1 0 0 3 0 1 1 1 0 1 2 eth2 ncsi1 000 001 0 0 1 1 1 0 0 1 0 1 1 1 0 1 2 eth2 ncsi2 001 000 1 0 1 1 1 1 0 3 0 1 1 1 0 1 2 eth2 ncsi3 001 001 1 0 1 1 1 1 0 2 1 1 1 1 0 1
=====================================================================
MP: Multi-mode Package WP: Whitelist Package
MC: Multi-mode Channel WC: Whitelist Channel
PC: Primary Channel CS: Channel State IA/A/IV 1/2/3
PS: Poll Status LS: Link Status
RU: Running CR: Carrier OK
NQ: Queue Stopped HA: Hardware Arbitration
The timing issue is not only happening in application. If I use using the following way to send the request, I can see the issue as well.
ncsi_netlink -l 2 -a 0x01 -m; ncsi_netlink -l 2 -p 0 -b 0x03 -m; ncsi_netlink -l 2 -p 1 -b 0x00 -m; ncsi_netlink -l 2 -a 0x03 -m; ncsi_netlink -l 2 -p 0 -b 0x00 -m; ncsi_netlink -l 2 -p 1 -b 0x03 -m;
Also, there is one issue below for non-multi-package/non-multi-channel case.
Thanks,
Justin
Quoted 21 lines
net/ncsi/ncsi-manage.c +11
-3@@ -1008,32 +1164,49 @@ static int ncsi_choose_active_channel(struct ncsi_dev_priv *ndp) ncm = &nc->modes[NCSI_MODE_LINK ];if (ncm->data[2 ] &0x1 ) { -spin_unlock_irqrestore (&nc->lock, flags); found = nc; - goto out; + with_link = true; } -spin_unlock_irqrestore (&nc->lock, flags); +/* If multi_channel is enabled configure all valid +* channels whether or not they currently have link +* so they will have AENs enabled. +*/ +if (with_link || np->multi_channel) { +spin_lock_irqsave (&ndp->lock, flags); +list_add_tail_rcu (&nc->link, + &ndp->channel_queue); +spin_unlock_irqrestore (&ndp->lock, flags); +
net/ncsi/ncsi-manage.c static int ncsi_choose_active_channel(struct ncsi_dev_priv *ndp) · line 1190
Quoted 10 lines
net/ncsi/ncsi-manage.c +10
-0+netdev_dbg (ndp->ndev.dev, +"NCSI: Channel %u added to queue (link %s)\n" , + nc->id, + ncm->data[2 ] &0x1 ?"up" :"down" ); + } + +spin_unlock_irqrestore (&nc->lock, cflags); + +if (with_link && !np->multi_channel) +break ;
The line needs to change to "goto found". If not, all channels with link will be added even if the multi-channel is not enabled for that package. The ncsi1 below is enabled. There is no netlink command sent to enable multi-package or multi-channel.
IFIDX IFNAME NAME PID CID RX TX MP MC WP WC PC CS PS LS RU CR NQ HA
=====================================================================
2 eth2 ncsi0 000 000 1 1 0 0 1 1 0 2 1 1 1 1 0 1 2 eth2 ncsi1 000 001 1 0 0 0 1 1 0 2 1 1 1 1 0 1 2 eth2 ncsi2 001 000 0 0 0 0 1 1 0 1 0 1 1 1 0 1 2 eth2 ncsi3 001 001 0 0 0 0 1 1 0 1 0 1 1 1 0 1
=====================================================================
MP: Multi-mode Package WP: Whitelist Package
MC: Multi-mode Channel WC: Whitelist Channel
PC: Primary Channel CS: Channel State IA/A/IV 1/2/3
PS: Poll Status LS: Link Status
RU: Running CR: Carrier OK
NQ: Queue Stopped HA: Hardware Arbitration
net/ncsi/ncsi-manage.c static int ncsi_choose_active_channel(struct ncsi_dev_priv *ndp) · line 1194
Quoted 4 lines
net/ncsi/ncsi-manage.c +2
-0} +if (with_link && !ndp->multi_package) +break ; }
found:
After applying this change, I notice that if there is no link available to BMC when BMC starts, NC-SI can't properly configure channel once I plug in the Ethernet cable.
npcm7xx-emc f0825000.eth eth2: NCSI: ncsi_aen_handler_lsc() - pkg 0 ch 0 state up npcm7xx-emc f0825000.eth eth2: NCSI: ncsi_aen_handler_lsc() - had_link 0, has_link 1, chained 0 npcm7xx-emc f0825000.eth eth2: NCSI: ncsi_stop_channel_monitor() - pkg 0 ch 0 npcm7xx-emc f0825000.eth eth2: NCSI: ncsi_process_next_channel()
npcm7xx-emc f0825000.eth eth2: NCSI: ncsi_process_next_channel() - pkg 0 ch 0 INVISIBLE npcm7xx-emc f0825000.eth eth2: NCSI: ncsi_process_next_channel() - suspending pkg 0 ch 0 npcm7xx-emc f0825000.eth eth2: NCSI: ncsi_suspend_channel() - pkg 0 ch 0 state 0400 select npcm7xx-emc f0825000.eth eth2: NCSI: ncsi_dev_work()
npcm7xx-emc f0825000.eth eth2: NCSI: ncsi_suspend_channel() - pkg 0 ch 0 state 0403 dc npcm7xx-emc f0825000.eth eth2: NCSI: ncsi_dev_work()
npcm7xx-emc f0825000.eth eth2: NCSI: ncsi_suspend_channel() - pkg 0 ch 0 state 0404 deselect npcm7xx-emc f0825000.eth eth2: NCSI: ncsi_dev_work()
npcm7xx-emc f0825000.eth eth2: NCSI: ncsi_suspend_channel() - pkg 0 ch 0 state 0405 done npcm7xx-emc f0825000.eth eth2: NCSI: ncsi_rsp_handler_dp() - pkg 0 ch 0 INACTIVE npcm7xx-emc f0825000.eth eth2: NCSI: ncsi_rsp_handler_dp() - pkg 0 ch 1 INACTIVE npcm7xx-emc f0825000.eth eth2: NCSI: ncsi_dev_work()
npcm7xx-emc f0825000.eth eth2: NCSI: ncsi_suspend_channel() - pkg 0 ch 0 state 0406 deselect npcm7xx-emc f0825000.eth eth2: NCSI: ncsi_suspend_channel() - pkg 0 ch 0 INACTIVE npcm7xx-emc f0825000.eth eth2: NCSI: ncsi_process_next_channel()
npcm7xx-emc f0825000.eth eth2: NCSI: ncsi_process_next_channel() - No more channels to process npcm7xx-emc f0825000.eth eth2: NCSI interface down
Quoted 29 lines
net/ncsi/ncsi-manage.c +9
-12-if (!found) { +if (list_empty (&ndp->channel_queue) && found) { +netdev_info (ndp->ndev.dev, +"NCSI: No channel with link found, configuring channel %u\n" , + found->id); +spin_lock_irqsave (&ndp->lock, flags); +list_add_tail_rcu (&found->link, &ndp->channel_queue); +spin_unlock_irqrestore (&ndp->lock, flags); + }else if (!found) {netdev_warn (ndp->ndev.dev, -"NCSI: No channel found with link\n" ); +"NCSI: No channel found to configure!\n" );ncsi_report_link (ndp, true);return -ENODEV ; } - ncm = &found->modes[NCSI_MODE_LINK ]; -netdev_dbg (ndp->ndev.dev, -"NCSI: Channel %u added to queue (link %s)\n" , - found->id, ncm->data[2 ] &0x1 ?"up" :"down" ); - -out: -spin_lock_irqsave (&ndp->lock, flags); -list_add_tail_rcu (&found->link, &ndp->channel_queue); -spin_unlock_irqrestore (&ndp->lock, flags); -return ncsi_process_next_channel (ndp); }
Samuel Mendoza-Jonas
maintainerRe: [PATCH net-next v3 6/6] net/ncsi: Configure multi-package, multi-channel modes with failover
Quoted 21 lines · On Thu, 2018-11-08 at 22:48 +0000, [email protected] wrote:
Hi Samuel,
For multi-package and multi-channel case, channel seems to be select correctly. Expect that, I still see the timing issue for back-to-back netlink command. Due to that, channel might be set to invisible state. Please refer to ncsi0 and ncsi2 below. The channel state is set to 3.
cat
/sys/kernel/debug/ncsi_protocol/ncsi_device_status
IFIDX IFNAME NAME PID CID RX TX MP MC WP WC PC CS PS LS RU CR NQ HA
=====================================================================2 eth2 ncsi0 000 000 1 1 1 1 1 0 0 3 0 1 1 1 0 1 2 eth2 ncsi1 000 001 0 0 1 1 1 0 0 1 0 1 1 1 0 1 2 eth2 ncsi2 001 000 1 0 1 1 1 1 0 3 0 1 1 1 0 1 2 eth2 ncsi3 001 001 1 0 1 1 1 1 0 2 1 1 1 1 0 1=====================================================================
MP: Multi-mode Package WP: Whitelist Package
MC: Multi-mode Channel WC: Whitelist Channel
PC: Primary Channel CS: Channel State IA/A/IV 1/2/3
PS: Poll Status LS: Link Status
RU: Running CR: Carrier OK
NQ: Queue Stopped HA: Hardware Arbitration
Quoted 5 lines
The timing issue is not only happening in application. If I use using the following way to send the request, I can see the issue as well.
ncsi_netlink-l 2 -a0x01-m;ncsi_netlink-l 2 -p 0 -b0x03-m;ncsi_netlink-l 2 -p 1 -b0x00-m;ncsi_netlink-l 2 -a0x03-m;ncsi_netlink-l 2 -p 0 -b0x00-m;ncsi_netlink-l 2 -p 1 -b0x03-m;
This actually recreates for me as well; I see now what you mean about channels getting stuck in the invisible state. I believe I've narrowed down the issue. I've pasted an additional patch below if you are able to test on your machine.
Quoted 58 lines
Also, there is one issue below for non-multi-package/non-multi-channel case.
Thanks,
JustinQuoted 21 lines
(quoted diff) +11
-3@@ -1008,32 +1164,49 @@ static int ncsi_choose_active_channel(struct ncsi_dev_priv *ndp) ncm = &nc->modes[NCSI_MODE_LINK]; if (ncm->data[2] & 0x1) { - spin_unlock_irqrestore(&nc->lock, flags); found = nc; - goto out; + with_link = true; } - spin_unlock_irqrestore(&nc->lock, flags); + /* If multi_channel is enabled configure all valid + * channels whether or not they currently have link + * so they will have AENs enabled. + */ + if (with_link || np->multi_channel) { + spin_lock_irqsave(&ndp->lock, flags); + list_add_tail_rcu(&nc->link, + &ndp->channel_queue); + spin_unlock_irqrestore(&ndp->lock, flags); +Review static int ncsi_choose_active_channel(struct ncsi_dev_priv *ndp) · line 1190
Quoted 10 lines
(quoted diff) +10
-0+ netdev_dbg(ndp->ndev.dev, + "NCSI: Channel %u added to queue (link %s)\n", + nc->id, + ncm->data[2] & 0x1 ? "up" : "down"); + } + + spin_unlock_irqrestore(&nc->lock, cflags); + + if (with_link && !np->multi_channel) + break;The line needs to change to "goto found". If not, all channels with link will be added even if the multi-channel is not enabled for that package. The ncsi1 below is enabled. There is no netlink command sent to enable multi-package or multi-channel.
IFIDX IFNAME NAME PID CID RX TX MP MC WP WC PC CS PS LS RU CR NQ HA
=====================================================================2 eth2 ncsi0 000 000 1 1 0 0 1 1 0 2 1 1 1 1 0 1 2 eth2 ncsi1 000 001 1 0 0 0 1 1 0 2 1 1 1 1 0 1 2 eth2 ncsi2 001 000 0 0 0 0 1 1 0 1 0 1 1 1 0 1 2 eth2 ncsi3 001 001 0 0 0 0 1 1 0 1 0 1 1 1 0 1=====================================================================
MP: Multi-mode Package WP: Whitelist Package
MC: Multi-mode Channel WC: Whitelist Channel
PC: Primary Channel CS: Channel State IA/A/IV 1/2/3
PS: Poll Status LS: Link Status
RU: Running CR: Carrier OK
NQ: Queue Stopped HA: Hardware Arbitration
Quoted 6 lines
Review static int ncsi_choose_active_channel(struct ncsi_dev_priv *ndp) · line 1194
Quoted 4 lines
(quoted diff) +2
-0} + if (with_link && !ndp->multi_package) + break; }found:
This *may* be part of the above issue, I don't see this in normal operation. The combination of (with_link && !np->multi_channel) and (with_link && !ndp->multi_package) should prevent additional channels being added without the need for 'goto found'. Please let me know if you still see it with the extra patch.
Quoted 17 lines
After applying this change, I notice that if there is no link available to BMC when BMC starts, NC-SI can't properly configure channel once I plug in the Ethernet cable.
npcm7xx-emc f0825000.eth eth2: NCSI:
ncsi_aen_handler_lsc()- pkg 0 ch 0 state up npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_aen_handler_lsc()-had_link0,has_link1, chained 0 npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_stop_channel_monitor()- pkg 0 ch 0 npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_process_next_channel()
npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_process_next_channel()- pkg 0 ch 0 INVISIBLE npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_process_next_channel()- suspending pkg 0 ch 0 npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_suspend_channel()- pkg 0 ch 0 state 0400 select npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_dev_work()
npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_suspend_channel()- pkg 0 ch 0 state 0403 dc npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_dev_work()
npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_suspend_channel()- pkg 0 ch 0 state 0404 deselect npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_dev_work()
npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_suspend_channel()- pkg 0 ch 0 state 0405 done
Quoted 8 lines
npcm7xx-emc f0825000.eth eth2: NCSI:
ncsi_rsp_handler_dp()- pkg 0 ch 0 INACTIVE npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_rsp_handler_dp()- pkg 0 ch 1 INACTIVE npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_dev_work()
npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_suspend_channel()- pkg 0 ch 0 state 0406 deselect npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_suspend_channel()- pkg 0 ch 0 INACTIVE npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_process_next_channel()
npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_process_next_channel()- No more channels to process npcm7xx-emc f0825000.eth eth2: NCSI interface down
Good find, there was a corner case in the LSC AEN handler changes that led to this, I've fixed this in the patch as well. Thanks for testing!
Quoted 1 line
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samuel Mendoza-Jonas <[email protected]>
Date: Fri, 9 Nov 2018 13:11:03 +1100
Subject: [PATCH] net/ncsi: Reset state fixes, single-channel LSC
--- net/ncsi/ncsi-aen.c | 8 +++++--- net/ncsi/ncsi-manage.c | 19 +++++++++++++++---- 2 files changed, 20 insertions(+), 7 deletions(-)
net/ncsi/ncsi-aen.c +5 -3
@@ -93,14 +93,16 @@ static int ncsi_aen_handler_lsc(struct ncsi_dev_priv *ndp,if ((had_link == has_link) || chained)return 0 ; -if (!ndp->multi_package && !nc->package->multi_channel) { -if (had_link) - ndp->flags |=NCSI_DEV_RESHUFFLE ; +if (!ndp->multi_package && !nc->package->multi_channel && had_link) { + ndp->flags |=NCSI_DEV_RESHUFFLE ;ncsi_stop_channel_monitor (nc);spin_lock_irqsave (&ndp->lock, flags);list_add_tail_rcu (&nc->link, &ndp->channel_queue);spin_unlock_irqrestore (&ndp->lock, flags);return ncsi_process_next_channel (ndp); + }else { +/* Configured channel came up */ +return 0 ; }if (had_link) {
net/ncsi/ncsi-manage.c +15 -4
@@ -1063,17 +1063,17 @@ static void ncsi_configure_channel(struct ncsi_dev_priv *ndp)case ncsi_dev_state_config_done:netdev_dbg (ndp->ndev.dev,"NCSI: channel %u config done\n" , nc->id); +spin_lock_irqsave (&nc->lock, flags); + nc->state =NCSI_CHANNEL_ACTIVE ; +if (ndp->flags &NCSI_DEV_RESET ) {/* A reset event happened during config, start it now */ -spin_lock_irqsave (&nc->lock, flags); nc->reconfigure_needed = false;spin_unlock_irqrestore (&nc->lock, flags); - nd->state = ncsi_dev_state_functional;ncsi_reset_dev (nd);break ; } -spin_lock_irqsave (&nc->lock, flags);if (nc->reconfigure_needed) {/* This channel's configuration has been updated * part-way during the config state - start the
@@ -1092,7 +1092,6 @@ static void ncsi_configure_channel(struct ncsi_dev_priv *ndp)break ; } - nc->state =NCSI_CHANNEL_ACTIVE ;if (nc->modes[NCSI_MODE_LINK ].data[2 ] &0x1 ) { hot_nc = nc; }else {
@@ -1803,6 +1802,18 @@ int ncsi_reset_dev(struct ncsi_dev *nd)spin_unlock_irqrestore (&ndp->lock, flags);return 0 ; } + }else { +switch (nd->state) { +case ncsi_dev_state_suspend_done: +case ncsi_dev_state_config_done: +case ncsi_dev_state_functional: +/* Ok */ +break ; +default : +/* Current reset operation happening */ +spin_unlock_irqrestore (&ndp->lock, flags); +return 0 ; + } }if (!list_empty (&ndp->channel_queue)) {
Signature · 1 line
2.19.1
RE: [PATCH net-next v3 6/6] net/ncsi: Configure multi-package, multi-channel modes with failover
Hi Samuel,
The extra patch fixed most issues but I see another corner case.
Thanks,
Justin
Quoted 98 lines · On Thu, 2018-11-08 at 22:48 +0000, [email protected] wrote:
Quoted 21 lines
Hi Samuel,
For multi-package and multi-channel case, channel seems to be select correctly. Expect that, I still see the timing issue for back-to-back netlink command. Due to that, channel might be set to invisible state. Please refer to ncsi0 and ncsi2 below. The channel state is set to 3.
cat
/sys/kernel/debug/ncsi_protocol/ncsi_device_status
IFIDX IFNAME NAME PID CID RX TX MP MC WP WC PC CS PS LS RU CR NQ HA
=====================================================================2 eth2 ncsi0 000 000 1 1 1 1 1 0 0 3 0 1 1 1 0 1 2 eth2 ncsi1 000 001 0 0 1 1 1 0 0 1 0 1 1 1 0 1 2 eth2 ncsi2 001 000 1 0 1 1 1 1 0 3 0 1 1 1 0 1 2 eth2 ncsi3 001 001 1 0 1 1 1 1 0 2 1 1 1 1 0 1=====================================================================
MP: Multi-mode Package WP: Whitelist Package
MC: Multi-mode Channel WC: Whitelist Channel
PC: Primary Channel CS: Channel State IA/A/IV 1/2/3
PS: Poll Status LS: Link Status
RU: Running CR: Carrier OK
NQ: Queue Stopped HA: Hardware ArbitrationQuoted 5 lines
The timing issue is not only happening in application. If I use using the following way to send the request, I can see the issue as well.
ncsi_netlink-l 2 -a0x01-m;ncsi_netlink-l 2 -p 0 -b0x03-m;ncsi_netlink-l 2 -p 1 -b0x00-m;ncsi_netlink-l 2 -a0x03-m;ncsi_netlink-l 2 -p 0 -b0x00-m;ncsi_netlink-l 2 -p 1 -b0x03-m;This actually recreates for me as well; I see now what you mean about channels getting stuck in the invisible state. I believe I've narrowed down the issue. I've pasted an additional patch below if you are able to test on your machine.
Quoted 58 lines
Also, there is one issue below for non-multi-package/non-multi-channel case.
Thanks,
JustinQuoted 21 lines
(quoted diff) +11
-3@@ -1008,32 +1164,49 @@ static int ncsi_choose_active_channel(struct ncsi_dev_priv *ndp) ncm = &nc->modes[NCSI_MODE_LINK]; if (ncm->data[2] & 0x1) { - spin_unlock_irqrestore(&nc->lock, flags); found = nc; - goto out; + with_link = true; } - spin_unlock_irqrestore(&nc->lock, flags); + /* If multi_channel is enabled configure all valid + * channels whether or not they currently have link + * so they will have AENs enabled. + */ + if (with_link || np->multi_channel) { + spin_lock_irqsave(&ndp->lock, flags); + list_add_tail_rcu(&nc->link, + &ndp->channel_queue); + spin_unlock_irqrestore(&ndp->lock, flags); +Review static int ncsi_choose_active_channel(struct ncsi_dev_priv *ndp) · line 1190
Quoted 10 lines
(quoted diff) +10
-0+ netdev_dbg(ndp->ndev.dev, + "NCSI: Channel %u added to queue (link %s)\n", + nc->id, + ncm->data[2] & 0x1 ? "up" : "down"); + } + + spin_unlock_irqrestore(&nc->lock, cflags); + + if (with_link && !np->multi_channel) + break;The line needs to change to "goto found". If not, all channels with link will be added even if the multi-channel is not enabled for that package. The ncsi1 below is enabled. There is no netlink command sent to enable multi-package or multi-channel.
IFIDX IFNAME NAME PID CID RX TX MP MC WP WC PC CS PS LS RU CR NQ HA
=====================================================================2 eth2 ncsi0 000 000 1 1 0 0 1 1 0 2 1 1 1 1 0 1 2 eth2 ncsi1 000 001 1 0 0 0 1 1 0 2 1 1 1 1 0 1 2 eth2 ncsi2 001 000 0 0 0 0 1 1 0 1 0 1 1 1 0 1 2 eth2 ncsi3 001 001 0 0 0 0 1 1 0 1 0 1 1 1 0 1=====================================================================
MP: Multi-mode Package WP: Whitelist Package
MC: Multi-mode Channel WC: Whitelist Channel
PC: Primary Channel CS: Channel State IA/A/IV 1/2/3
PS: Poll Status LS: Link Status
RU: Running CR: Carrier OK
NQ: Queue Stopped HA: Hardware ArbitrationQuoted 6 lines
net/ncsi/ncsi-manage.c int ncsi_reset_dev(struct ncsi_dev *nd) · line 1817
Quoted 4 lines
net/ncsi/ncsi-manage.c +2
-0} +if (with_link && !ndp->multi_package) +break ; }found:
Quoted 6 lines
This *may* be part of the above issue, I don't see this in normal operation. The combination of (
with_link&& !np->multi_channel) and (with_link&& !ndp->multi_package) should prevent additional channels being added without the need for 'goto found'. Please let me know if you still see it with the extra patch.
This one is fixed by your extra patch but I see another corner case. Basically, the issue is due to the link status is not updating during the process of choosing the active channel. During the process, maybe we should find a chance to send Get Link Status command to all whitelist channels.
Here is my step.
1. All four channels plug Ethernet cable.
2. BMC starts without any multi-package/multi-channel configuration.
3. The ncsi0 channel is selected by NC-SI driver.
4. Remove cable from ncsi0.
5. The ncsi1 channel is selected by NC-SI driver.
6. Remove cable from ncsi1.
7. The ncsi2 channel is selected by NC-SI driver.
8. Insert cable for ncsi0. Link status will not be updated.
9. Remove cable from ncsi2.
10. The ncsi3 channel is selected by NC-SI driver.
11. Remove cable from ncsi3.
12. The selected channel is ncsi3 without link.
cat /sys/kernel/debug/ncsi_protocol/ncsi_device_
IFIDX IFNAME NAME PID CID RX TX MP MC WP WC PC CS PS LS RU CR NQ HA
=====================================================================
2 eth2 ncsi0 000 000 0 0 0 0 1 1 0 1 0 0 1 1 0 1 2 eth2 ncsi1 000 001 0 0 0 0 1 1 0 1 0 0 1 1 0 1 2 eth2 ncsi2 001 000 0 0 0 0 1 1 0 1 0 0 1 1 0 1 2 eth2 ncsi3 001 001 1 1 0 0 1 1 0 2 1 0 1 1 0 1
=====================================================================
MP: Multi-mode Package WP: Whitelist Package
MC: Multi-mode Channel WC: Whitelist Channel
PC: Primary Channel CS: Channel State IA/A/IV 1/2/3
PS: Poll Status LS: Link Status
RU: Running CR: Carrier OK
NQ: Queue Stopped HA: Hardware Arbitration
Quoted 26 lines
Quoted 17 lines
After applying this change, I notice that if there is no link available to BMC when BMC starts, NC-SI can't properly configure channel once I plug in the Ethernet cable.
npcm7xx-emc f0825000.eth eth2: NCSI:
ncsi_aen_handler_lsc()- pkg 0 ch 0 state up npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_aen_handler_lsc()-had_link0,has_link1, chained 0 npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_stop_channel_monitor()- pkg 0 ch 0 npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_process_next_channel()
npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_process_next_channel()- pkg 0 ch 0 INVISIBLE npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_process_next_channel()- suspending pkg 0 ch 0 npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_suspend_channel()- pkg 0 ch 0 state 0400 select npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_dev_work()
npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_suspend_channel()- pkg 0 ch 0 state 0403 dc npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_dev_work()
npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_suspend_channel()- pkg 0 ch 0 state 0404 deselect npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_dev_work()
npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_suspend_channel()- pkg 0 ch 0 state 0405 doneQuoted 8 lines
npcm7xx-emc f0825000.eth eth2: NCSI:
ncsi_rsp_handler_dp()- pkg 0 ch 0 INACTIVE npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_rsp_handler_dp()- pkg 0 ch 1 INACTIVE npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_dev_work()
npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_suspend_channel()- pkg 0 ch 0 state 0406 deselect npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_suspend_channel()- pkg 0 ch 0 INACTIVE npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_process_next_channel()
npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_process_next_channel()- No more channels to process npcm7xx-emc f0825000.eth eth2: NCSI interface down
Quoted 2 lines
Good find, there was a corner case in the LSC AEN handler changes that led to this, I've fixed this in the patch as well. Thanks for testing!
This one is fixed.
Quoted 90 lines
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samuel Mendoza-Jonas <[email protected]>
Date: Fri, 9 Nov 2018 13:11:03 +1100
Subject: [PATCH] net/ncsi: Reset state fixes, single-channel LSC--- net/ncsi/ncsi-aen.c | 8 +++++--- net/ncsi/ncsi-manage.c | 19 +++++++++++++++---- 2 files changed, 20 insertions(+), 7 deletions(-)net/ncsi/ncsi-aen.c +5
-3@@ -93,14 +93,16 @@ static int ncsi_aen_handler_lsc(struct ncsi_dev_priv *ndp,if ((had_link == has_link) || chained)return 0 ; -if (!ndp->multi_package && !nc->package->multi_channel) { -if (had_link) - ndp->flags |=NCSI_DEV_RESHUFFLE ; +if (!ndp->multi_package && !nc->package->multi_channel && had_link) { + ndp->flags |=NCSI_DEV_RESHUFFLE ;ncsi_stop_channel_monitor (nc);spin_lock_irqsave (&ndp->lock, flags);list_add_tail_rcu (&nc->link, &ndp->channel_queue);spin_unlock_irqrestore (&ndp->lock, flags);return ncsi_process_next_channel (ndp); + }else { +/* Configured channel came up */ +return 0 ; }if (had_link) {net/ncsi/ncsi-manage.c +15
-4@@ -1063,17 +1063,17 @@ static void ncsi_configure_channel(struct ncsi_dev_priv *ndp)case ncsi_dev_state_config_done:netdev_dbg (ndp->ndev.dev,"NCSI: channel %u config done\n" , nc->id); +spin_lock_irqsave (&nc->lock, flags); + nc->state =NCSI_CHANNEL_ACTIVE ; +if (ndp->flags &NCSI_DEV_RESET ) {/* A reset event happened during config, start it now */ -spin_lock_irqsave (&nc->lock, flags); nc->reconfigure_needed = false;spin_unlock_irqrestore (&nc->lock, flags); - nd->state = ncsi_dev_state_functional;ncsi_reset_dev (nd);break ; } -spin_lock_irqsave (&nc->lock, flags);if (nc->reconfigure_needed) {/* This channel's configuration has been updated * part-way during the config state - start the @@ -1092,7 +1092,6 @@ static void ncsi_configure_channel(struct ncsi_dev_priv *ndp)break ; } - nc->state =NCSI_CHANNEL_ACTIVE ;if (nc->modes[NCSI_MODE_LINK ].data[2 ] &0x1 ) { hot_nc = nc; }else {@@ -1803,6 +1802,18 @@ int ncsi_reset_dev(struct ncsi_dev *nd)spin_unlock_irqrestore (&ndp->lock, flags);return 0 ; } + }else { +switch (nd->state) { +case ncsi_dev_state_suspend_done: +case ncsi_dev_state_config_done: +case ncsi_dev_state_functional: +/* Ok */ +break ; +default : +/* Current reset operation happening */ +spin_unlock_irqrestore (&ndp->lock, flags); +return 0 ; + } }if (!list_empty (&ndp->channel_queue)) {Signature · 1 line
2.19.1
RE: [PATCH net-next v3 6/6] net/ncsi: Configure multi-package, multi-channel modes with failover
In reply to Samuel Mendoza-JonasHi Samuel,
After running more testing, I notice that the extra patch causing failover function to fail. Also, occasionally, I will see two channels having TX enabled if I send netlink command back-to-back.
cat /sys/kernel/debug/ncsi_protocol/ncsi_device_
IFIDX IFNAME NAME PID CID RX TX MP MC WP WC PC CS PS LS RU CR NQ HA
=====================================================================
2 eth2 ncsi0 000 000 1 1 1 1 1 1 1 2 1 1 1 1 0 1 2 eth2 ncsi1 000 001 1 1 1 1 1 1 0 2 1 1 1 1 0 1 2 eth2 ncsi2 001 000 0 0 1 1 0 0 0 1 0 1 1 1 0 1 2 eth2 ncsi3 001 001 0 0 1 1 0 0 0 1 0 1 1 1 0 1
=====================================================================
MP: Multi-mode Package WP: Whitelist Package
MC: Multi-mode Channel WC: Whitelist Channel
PC: Primary Channel CS: Channel State IA/A/IV 1/2/3
PS: Poll Status LS: Link Status
RU: Running CR: Carrier OK
NQ: Queue Stopped HA: Hardware Arbitration
Thanks,
Justin
Quoted 21 lines
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samuel Mendoza-Jonas <[email protected]>
Date: Fri, 9 Nov 2018 13:11:03 +1100
Subject: [PATCH] net/ncsi: Reset state fixes, single-channel LSC--- net/ncsi/ncsi-aen.c | 8 +++++--- net/ncsi/ncsi-manage.c | 19 +++++++++++++++---- 2 files changed, 20 insertions(+), 7 deletions(-)net/ncsi/ncsi-aen.c +0
-3@@ -93,14 +93,16 @@ static int ncsi_aen_handler_lsc(struct ncsi_dev_priv *ndp,if ((had_link == has_link) || chained)return 0 ; -if (!ndp->multi_package && !nc->package->multi_channel) { -if (had_link) - ndp->flags |=NCSI_DEV_RESHUFFLE ;
net/ncsi/ncsi-aen.c static int ncsi_aen_handler_lsc(struct ncsi_dev_priv *ndp, · line 105
Quoted 10 lines
net/ncsi/ncsi-aen.c +5
-0+if (!ndp->multi_package && !nc->package->multi_channel && had_link) { + ndp->flags |=NCSI_DEV_RESHUFFLE ;ncsi_stop_channel_monitor (nc);spin_lock_irqsave (&ndp->lock, flags);list_add_tail_rcu (&nc->link, &ndp->channel_queue);spin_unlock_irqrestore (&ndp->lock, flags);return ncsi_process_next_channel (ndp); + }else { +/* Configured channel came up */ +return 0 ;
It is always going to else statement if multi_package and/or mutlit_channel is enabled.
npcm7xx-emc f0825000.eth eth2: NCSI: ncsi_aen_handler_lsc() - pkg 0 ch 0 state down npcm7xx-emc f0825000.eth eth2: NCSI: ncsi_aen_handler_lsc() - had_link 1, has_link 0, chained 0
These codes have no chance to run.
if (had_link) {
ncm = &nc->modes[NCSI_MODE_TX_ENABLE];
if (ncsi_channel_is_last(ndp, nc)) {
/* No channels left, reconfigure */
return ncsi_reset_dev(&ndp->ndev);
} else if (ncm->enable) {
/* Need to failover Tx channel */
ncsi_update_tx_channel(ndp, nc->package, nc, NULL);
}Quoted 2 lines
net/ncsi/ncsi-aen.c +0
-0}
Samuel Mendoza-Jonas
maintainerRe: [PATCH net-next v3 6/6] net/ncsi: Configure multi-package, multi-channel modes with failover
Quoted 63 lines · On Fri, 2018-11-09 at 21:58 +0000, [email protected] wrote:
Hi Samuel,
After running more testing, I notice that the extra patch causing failover function to fail. Also, occasionally, I will see two channels having TX enabled if I send netlink command back-to-back.
cat
/sys/kernel/debug/ncsi_protocol/ncsi_device_
IFIDX IFNAME NAME PID CID RX TX MP MC WP WC PC CS PS LS RU CR NQ HA
=====================================================================2 eth2 ncsi0 000 000 1 1 1 1 1 1 1 2 1 1 1 1 0 1 2 eth2 ncsi1 000 001 1 1 1 1 1 1 0 2 1 1 1 1 0 1 2 eth2 ncsi2 001 000 0 0 1 1 0 0 0 1 0 1 1 1 0 1 2 eth2 ncsi3 001 001 0 0 1 1 0 0 0 1 0 1 1 1 0 1=====================================================================
MP: Multi-mode Package WP: Whitelist Package
MC: Multi-mode Channel WC: Whitelist Channel
PC: Primary Channel CS: Channel State IA/A/IV 1/2/3
PS: Poll Status LS: Link Status
RU: Running CR: Carrier OK
NQ: Queue Stopped HA: Hardware ArbitrationThanks,
JustinQuoted 21 lines
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samuel Mendoza-Jonas <[email protected]>
Date: Fri, 9 Nov 2018 13:11:03 +1100
Subject: [PATCH] net/ncsi: Reset state fixes, single-channel LSC--- net/ncsi/ncsi-aen.c | 8 +++++--- net/ncsi/ncsi-manage.c | 19 +++++++++++++++---- 2 files changed, 20 insertions(+), 7 deletions(-)net/ncsi/ncsi-aen.c +0
-3@@ -93,14 +93,16 @@ static int ncsi_aen_handler_lsc(struct ncsi_dev_priv *ndp,if ((had_link == has_link) || chained)return 0 ; -if (!ndp->multi_package && !nc->package->multi_channel) { -if (had_link) - ndp->flags |=NCSI_DEV_RESHUFFLE ;net/ncsi/ncsi-aen.c static int ncsi_aen_handler_lsc(struct ncsi_dev_priv *ndp, · line 105
Quoted 10 lines
net/ncsi/ncsi-aen.c +5
-0+if (!ndp->multi_package && !nc->package->multi_channel && had_link) { + ndp->flags |=NCSI_DEV_RESHUFFLE ;ncsi_stop_channel_monitor (nc);spin_lock_irqsave (&ndp->lock, flags);list_add_tail_rcu (&nc->link, &ndp->channel_queue);spin_unlock_irqrestore (&ndp->lock, flags);return ncsi_process_next_channel (ndp); + }else { +/* Configured channel came up */ +return 0 ;It is always going to else statement if
multi_packageand/ormutlit_channelis enabled.npcm7xx-emc f0825000.eth eth2: NCSI:
ncsi_aen_handler_lsc()- pkg 0 ch 0 state down npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_aen_handler_lsc()-had_link1,has_link0, chained 0These codes have no chance to run.
Quoted 12 lines
if (had_link) { ncm = &nc->modes[NCSI_MODE_TX_ENABLE]; if (ncsi_channel_is_last(ndp, nc)) { /* No channels left, reconfigure */ return ncsi_reset_dev(&ndp->ndev); } else if (ncm->enable) { /* Need to failover Tx channel */ ncsi_update_tx_channel(ndp, nc->package, nc, NULL); }Quoted 2 lines
net/ncsi/ncsi-aen.c +0
-0}
Oops, wrote that patch a little fast it seems. This may also affect the double-Tx above since ncsi_update_tx_channel() won't be reached. I've attached a fixed up version below.
For the failover issue you're seeing in your previous email the issue is likely in the ncsi_dev_state_suspend_gls state. This should send a GLS command to all available channels, but it only does it for the current package. Since not all packages are necessarily enabled in single-channel mode I'll need to have a think about the neatest way to handle that, but it's a separate issue from this patch.
Cheers,
Sam
Quoted 1 line
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samuel Mendoza-Jonas <[email protected]>
Date: Fri, 9 Nov 2018 13:11:03 +1100
Subject: [PATCH] net/ncsi: Reset state fixes, single-channel LSC
--- net/ncsi/ncsi-aen.c | 16 ++++++++++------ net/ncsi/ncsi-manage.c | 19 +++++++++++++++---- 2 files changed, 25 insertions(+), 10 deletions(-)
net/ncsi/ncsi-aen.c +10 -6
@@ -94,13 +94,17 @@ static int ncsi_aen_handler_lsc(struct ncsi_dev_priv *ndp,return 0 ;if (!ndp->multi_package && !nc->package->multi_channel) { -if (had_link) +if (had_link) { ndp->flags |=NCSI_DEV_RESHUFFLE ; -ncsi_stop_channel_monitor (nc); -spin_lock_irqsave (&ndp->lock, flags); -list_add_tail_rcu (&nc->link, &ndp->channel_queue); -spin_unlock_irqrestore (&ndp->lock, flags); -return ncsi_process_next_channel (ndp); +ncsi_stop_channel_monitor (nc); +spin_lock_irqsave (&ndp->lock, flags); +list_add_tail_rcu (&nc->link, &ndp->channel_queue); +spin_unlock_irqrestore (&ndp->lock, flags); +return ncsi_process_next_channel (ndp); + }else { +/* Configured channel came up */ +return 0 ; + } }if (had_link) {
net/ncsi/ncsi-manage.c +15 -4
@@ -1063,17 +1063,17 @@ static void ncsi_configure_channel(struct ncsi_dev_priv *ndp)case ncsi_dev_state_config_done:netdev_dbg (ndp->ndev.dev,"NCSI: channel %u config done\n" , nc->id); +spin_lock_irqsave (&nc->lock, flags); + nc->state =NCSI_CHANNEL_ACTIVE ; +if (ndp->flags &NCSI_DEV_RESET ) {/* A reset event happened during config, start it now */ -spin_lock_irqsave (&nc->lock, flags); nc->reconfigure_needed = false;spin_unlock_irqrestore (&nc->lock, flags); - nd->state = ncsi_dev_state_functional;ncsi_reset_dev (nd);break ; } -spin_lock_irqsave (&nc->lock, flags);if (nc->reconfigure_needed) {/* This channel's configuration has been updated * part-way during the config state - start the
@@ -1092,7 +1092,6 @@ static void ncsi_configure_channel(struct ncsi_dev_priv *ndp)break ; } - nc->state =NCSI_CHANNEL_ACTIVE ;if (nc->modes[NCSI_MODE_LINK ].data[2 ] &0x1 ) { hot_nc = nc; }else {
@@ -1803,6 +1802,18 @@ int ncsi_reset_dev(struct ncsi_dev *nd)spin_unlock_irqrestore (&ndp->lock, flags);return 0 ; } + }else { +switch (nd->state) { +case ncsi_dev_state_suspend_done: +case ncsi_dev_state_config_done: +case ncsi_dev_state_functional: +/* Ok */ +break ; +default : +/* Current reset operation happening */ +spin_unlock_irqrestore (&ndp->lock, flags); +return 0 ; + } }if (!list_empty (&ndp->channel_queue)) {
Signature · 1 line
2.19.1
RE: [PATCH net-next v3 6/6] net/ncsi: Configure multi-package, multi-channel modes with failover
Hi Samuel,
I have tested your new patch. The failover function works as expected.
Thanks,
Justin
Quoted 184 lines · On Fri, 2018-11-09 at 21:58 +0000, [email protected] wrote:
Quoted 63 lines
Hi Samuel,
After running more testing, I notice that the extra patch causing failover function to fail. Also, occasionally, I will see two channels having TX enabled if I send netlink command back-to-back.
cat
/sys/kernel/debug/ncsi_protocol/ncsi_device_
IFIDX IFNAME NAME PID CID RX TX MP MC WP WC PC CS PS LS RU CR NQ HA
=====================================================================2 eth2 ncsi0 000 000 1 1 1 1 1 1 1 2 1 1 1 1 0 1 2 eth2 ncsi1 000 001 1 1 1 1 1 1 0 2 1 1 1 1 0 1 2 eth2 ncsi2 001 000 0 0 1 1 0 0 0 1 0 1 1 1 0 1 2 eth2 ncsi3 001 001 0 0 1 1 0 0 0 1 0 1 1 1 0 1=====================================================================
MP: Multi-mode Package WP: Whitelist Package
MC: Multi-mode Channel WC: Whitelist Channel
PC: Primary Channel CS: Channel State IA/A/IV 1/2/3
PS: Poll Status LS: Link Status
RU: Running CR: Carrier OK
NQ: Queue Stopped HA: Hardware ArbitrationThanks,
JustinQuoted 21 lines
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samuel Mendoza-Jonas <[email protected]>
Date: Fri, 9 Nov 2018 13:11:03 +1100
Subject: [PATCH] net/ncsi: Reset state fixes, single-channel LSC--- net/ncsi/ncsi-aen.c | 8 +++++--- net/ncsi/ncsi-manage.c | 19 +++++++++++++++---- 2 files changed, 20 insertions(+), 7 deletions(-)net/ncsi/ncsi-aen.c +0
-3@@ -93,14 +93,16 @@ static int ncsi_aen_handler_lsc(struct ncsi_dev_priv *ndp,if ((had_link == has_link) || chained)return 0 ; -if (!ndp->multi_package && !nc->package->multi_channel) { -if (had_link) - ndp->flags |=NCSI_DEV_RESHUFFLE ;net/ncsi/ncsi-aen.c static int ncsi_aen_handler_lsc(struct ncsi_dev_priv *ndp, · line 105
Quoted 10 lines
net/ncsi/ncsi-aen.c +5
-0+if (!ndp->multi_package && !nc->package->multi_channel && had_link) { + ndp->flags |=NCSI_DEV_RESHUFFLE ;ncsi_stop_channel_monitor (nc);spin_lock_irqsave (&ndp->lock, flags);list_add_tail_rcu (&nc->link, &ndp->channel_queue);spin_unlock_irqrestore (&ndp->lock, flags);return ncsi_process_next_channel (ndp); + }else { +/* Configured channel came up */ +return 0 ;It is always going to else statement if
multi_packageand/ormutlit_channelis enabled.npcm7xx-emc f0825000.eth eth2: NCSI:
ncsi_aen_handler_lsc()- pkg 0 ch 0 state down npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_aen_handler_lsc()-had_link1,has_link0, chained 0These codes have no chance to run.
Quoted 12 lines
if (had_link) { ncm = &nc->modes[NCSI_MODE_TX_ENABLE]; if (ncsi_channel_is_last(ndp, nc)) { /* No channels left, reconfigure */ return ncsi_reset_dev(&ndp->ndev); } else if (ncm->enable) { /* Need to failover Tx channel */ ncsi_update_tx_channel(ndp, nc->package, nc, NULL); }Quoted 2 lines
net/ncsi/ncsi-aen.c +0
-0}Oops, wrote that patch a little fast it seems. This may also affect the double-Tx above since
ncsi_update_tx_channel()won't be reached. I've attached a fixed up version below.For the failover issue you're seeing in your previous email the issue is likely in the
ncsi_dev_state_suspend_glsstate. This should send a GLS command to all available channels, but it only does it for the current package. Since not all packages are necessarily enabled in single-channel mode I'll need to have a think about the neatest way to handle that, but it's a separate issue from this patch.Cheers,
SamFrom 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samuel Mendoza-Jonas <[email protected]>
Date: Fri, 9 Nov 2018 13:11:03 +1100
Subject: [PATCH] net/ncsi: Reset state fixes, single-channel LSC--- net/ncsi/ncsi-aen.c | 16 ++++++++++------ net/ncsi/ncsi-manage.c | 19 +++++++++++++++---- 2 files changed, 25 insertions(+), 10 deletions(-)net/ncsi/ncsi-aen.c +10
-6@@ -94,13 +94,17 @@ static int ncsi_aen_handler_lsc(struct ncsi_dev_priv *ndp,return 0 ;if (!ndp->multi_package && !nc->package->multi_channel) { -if (had_link) +if (had_link) { ndp->flags |=NCSI_DEV_RESHUFFLE ; -ncsi_stop_channel_monitor (nc); -spin_lock_irqsave (&ndp->lock, flags); -list_add_tail_rcu (&nc->link, &ndp->channel_queue); -spin_unlock_irqrestore (&ndp->lock, flags); -return ncsi_process_next_channel (ndp); +ncsi_stop_channel_monitor (nc); +spin_lock_irqsave (&ndp->lock, flags); +list_add_tail_rcu (&nc->link, &ndp->channel_queue); +spin_unlock_irqrestore (&ndp->lock, flags); +return ncsi_process_next_channel (ndp); + }else { +/* Configured channel came up */ +return 0 ; + } }if (had_link) {net/ncsi/ncsi-manage.c +15
-4@@ -1063,17 +1063,17 @@ static void ncsi_configure_channel(struct ncsi_dev_priv *ndp)case ncsi_dev_state_config_done:netdev_dbg (ndp->ndev.dev,"NCSI: channel %u config done\n" , nc->id); +spin_lock_irqsave (&nc->lock, flags); + nc->state =NCSI_CHANNEL_ACTIVE ; +if (ndp->flags &NCSI_DEV_RESET ) {/* A reset event happened during config, start it now */ -spin_lock_irqsave (&nc->lock, flags); nc->reconfigure_needed = false;spin_unlock_irqrestore (&nc->lock, flags); - nd->state = ncsi_dev_state_functional;ncsi_reset_dev (nd);break ; } -spin_lock_irqsave (&nc->lock, flags);if (nc->reconfigure_needed) {/* This channel's configuration has been updated * part-way during the config state - start the @@ -1092,7 +1092,6 @@ static void ncsi_configure_channel(struct ncsi_dev_priv *ndp)break ; } - nc->state =NCSI_CHANNEL_ACTIVE ;if (nc->modes[NCSI_MODE_LINK ].data[2 ] &0x1 ) { hot_nc = nc; }else {@@ -1803,6 +1802,18 @@ int ncsi_reset_dev(struct ncsi_dev *nd)spin_unlock_irqrestore (&ndp->lock, flags);return 0 ; } + }else { +switch (nd->state) { +case ncsi_dev_state_suspend_done: +case ncsi_dev_state_config_done: +case ncsi_dev_state_functional: +/* Ok */ +break ; +default : +/* Current reset operation happening */ +spin_unlock_irqrestore (&ndp->lock, flags); +return 0 ; + } }if (!list_empty (&ndp->channel_queue)) {Signature · 1 line
2.19.1