net/ncsi: Allow enabling multiple packages & channels
Subsystems (3)
Samuel Mendoza-Jonas
maintainerv2 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.
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 | 63 ++++-- net/ncsi/ncsi-manage.c | 453 +++++++++++++++++++++++++------------- net/ncsi/ncsi-netlink.c | 229 ++++++++++++++++--- net/ncsi/ncsi-rsp.c | 2 +- 6 files changed, 578 insertions(+), 203 deletions(-)
Signature · 1 line
2.19.1
Samuel Mendoza-Jonas
maintainerPATCH v2 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 | 45 +++--------------------------------------- 2 files changed, 4 insertions(+), 44 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 +3 -42
69 lines not on this page · raw message
Signature · 1 line
2.19.1
kbuild test robot
build botRe: [PATCH net-next v2 1/6] net/ncsi: Don't enable all channels when HWA available
I love your patch! Yet something to improve:
Hi Samuel,
I love your patch! Yet something to improve:
[auto build test ERROR on net-next/master]
url: https://github.com/0day-ci/linux/commits/Samuel-Mendoza-Jonas/net-ncsi-Allow-enabling-multiple-packages-channels/20181024-103206
config: i386-randconfig-x014-201842 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0 reproduce:
# save the attached .config to linux build tree
make ARCH=i386 Note: the linux-review/Samuel-Mendoza-Jonas/net-ncsi-Allow-enabling-multiple-packages-channels/20181024-103206 HEAD 54369e39116e3a32a005dd577eba25bd50d15c31 builds fine.
It only hurts bisectibility.
All errors (new ones prefixed by >>):
net/ncsi/ncsi-manage.c: In function 'ncsi_probe_channel':
net/ncsi/ncsi-manage.c:1129:5: error: implicit declaration of function 'ncsi_enable_hwa'; did you mean 'ncsi_check_hwa'? [-Werror=implicit-function-declaration]
ncsi_enable_hwa(ndp);
^~~~~~~~~~~~~~~
ncsi_check_hwa
net/ncsi/ncsi-manage.c: In function 'ncsi_start_dev':
>> net/ncsi/ncsi-manage.c:1575:36: error: passing argument 1 of 'ncsi_choose_active_channel' from incompatible pointer type [-Werror=incompatible-pointer-types]
return ncsi_choose_active_channel(nd);
^~ net/ncsi/ncsi-manage.c:939:12: note: expected 'struct ncsi_dev_priv *' but argument is of type 'struct ncsi_dev *'
static int ncsi_choose_active_channel(struct ncsi_dev_priv *ndp)
^~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
vim +/ncsi_choose_active_channel +1575 net/ncsi/ncsi-manage.c
1560
1561 int ncsi_start_dev(struct ncsi_dev *nd)
1562 {
1563 struct ncsi_dev_priv *ndp = TO_NCSI_DEV_PRIV(nd);
1564
1565 if (nd->state != ncsi_dev_state_registered &&
1566 nd->state != ncsi_dev_state_functional)
1567 return -ENOTTY;
1568
1569 if (!(ndp->flags & NCSI_DEV_PROBED)) {
1570 nd->state = ncsi_dev_state_probe;
1571 schedule_work(&ndp->work);
1572 return 0;
1573 }
1574
> 1575 return ncsi_choose_active_channel(nd);
1576 }
1577 EXPORT_SYMBOL_GPL(ncsi_start_dev);
1578
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
Samuel Mendoza-Jonas
maintainerPATCH v2 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 | 88 ++++++++++++++---------------------------- 2 files changed, 31 insertions(+), 58 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 -58
128 lines not on this page · raw message
Signature · 1 line
2.19.1
Samuel Mendoza-Jonas
maintainerPATCH v2 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 v2 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 v2 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.
---
v2: Fixed ncsi_channel_is_tx() to consider the state of channels in other packages.
net/ncsi/internal.h | 2 ++ net/ncsi/ncsi-manage.c | 57 +++++++++++++++++++++++++++++++++++++---- net/ncsi/ncsi-netlink.c | 10 +++----- 3 files changed, 58 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 +52 -5
87 lines not on this page · raw message
net/ncsi/ncsi-netlink.c +4 -6
@@ -330,9 +330,8 @@ 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 */ +ncsi_reset_dev (&ndp->ndev);return 0 ; }
@@ -360,9 +359,8 @@ 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 */ +ncsi_reset_dev (&ndp->ndev);return 0 ; }
Signature · 1 line
2.19.1
RE: [PATCH net-next v2 5/6] net/ncsi: Reset channel state in ncsi_start_dev()
Hi Samuel,
I noticed a few issues and commented below.
Thanks,
Justin
Quoted 23 lines
/* Resources */
net/ncsi/internal.h +1
-0+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 +4
-2@@ -550,8 +550,10 @@ static void ncsi_suspend_channel(struct ncsi_dev_priv *ndp)spin_lock_irqsave (&nc->lock, flags); nc->state =NCSI_CHANNEL_INACTIVE ;spin_unlock_irqrestore (&nc->lock, flags); -ncsi_process_next_channel (ndp); - +if (ndp->flags &NCSI_DEV_RESET ) +ncsi_reset_dev (nd); +else +ncsi_process_next_channel (ndp);break ;default : netdev_warn(nd->dev, "Wrong NCSI state 0x%x in suspend\n",
net/ncsi/ncsi-manage.c int ncsi_start_dev(struct ncsi_dev *nd) · line 1559
Quoted 5 lines
net/ncsi/ncsi-manage.c +1
-1@@ -1554,7 +1556,7 @@ int ncsi_start_dev(struct ncsi_dev *nd)return 0 ; } -return ncsi_choose_active_channel (nd); +return ncsi_reset_dev (nd);
If there is no available channel due to the whitelist, ncsi_start_dev() function will return failed Status and the network interface may fail to bring up too. It is possible for user to disable all channels and leave the interface up for checking the LOM status.
net/ncsi/ncsi-manage.c int ncsi_start_dev(struct ncsi_dev *nd) · line 1561
Quoted 2 lines
net/ncsi/ncsi-manage.c +0
-0}EXPORT_SYMBOL_GPL (ncsi_start_dev);
Also, if I send set_package_mask and set_channel_mask commands back to back in a program, the state machine doesn't work well. If I use command line and wait for it to complete for each step, then it is fine.
npcm7xx-emc f0825000.eth eth2: NCSI: Multi-package enabled on ifindex 2, mask 0x00000001 npcm7xx-emc f0825000.eth eth2: NCSI: ncsi_stop_channel_monitor() - pkg 0 ch 0 npcm7xx-emc f0825000.eth eth2: NCSI: ncsi_dev_work()
npcm7xx-emc f0825000.eth eth2: NCSI: ncsi_suspend_channel() - pkg 0 ch 0 state 0400 npcm7xx-emc f0825000.eth eth2: NCSI: pkg 0 ch 0 set as preferred channel npcm7xx-emc f0825000.eth eth2: NCSI: Multi-channel enabled on ifindex 2, mask 0x00000003 npcm7xx-emc f0825000.eth eth2: NCSI: ncsi_stop_channel_monitor() - pkg 0 ch 1 npcm7xx-emc f0825000.eth eth2: NCSI: ncsi_dev_work()
npcm7xx-emc f0825000.eth eth2: NCSI: ncsi_suspend_channel() - pkg 0 ch 1 state 0400 npcm7xx-emc f0825000.eth eth2: NCSI: Package 1 set to all channels disabled npcm7xx-emc f0825000.eth eth2: NCSI: Multi-channel enabled on ifindex 2, mask 0x00000000 npcm7xx-emc f0825000.eth eth2: NCSI: ncsi_choose_active_channel() npcm7xx-emc f0825000.eth eth2: NCSI: ncsi_choose_active_channel() - pkg 0 npcm7xx-emc f0825000.eth eth2: NCSI: ncsi_choose_active_channel() - pass pkg whitelist npcm7xx-emc f0825000.eth eth2: NCSI: ncsi_choose_active_channel() - ch 0 npcm7xx-emc f0825000.eth eth2: NCSI: ncsi_choose_active_channel() - pass ch whitelist npcm7xx-emc f0825000.eth eth2: NCSI: ncsi_choose_active_channel() - skip npcm7xx-emc f0825000.eth eth2: NCSI: ncsi_choose_active_channel() - ch 1 npcm7xx-emc f0825000.eth eth2: NCSI: ncsi_choose_active_channel() - pass ch whitelist npcm7xx-emc f0825000.eth eth2: NCSI: ncsi_choose_active_channel() - skip npcm7xx-emc f0825000.eth eth2: NCSI: ncsi_choose_active_channel() - next pkg npcm7xx-emc f0825000.eth eth2: NCSI: ncsi_choose_active_channel() - pkg 1 npcm7xx-emc f0825000.eth eth2: NCSI: No channel found to configure! npcm7xx-emc f0825000.eth eth2: NCSI interface down
npcm7xx-emc f0825000.eth eth2: NCSI: ncsi_dev_work()
npcm7xx-emc f0825000.eth eth2: Wrong NCSI state 0x100 in workqueue
All masks are set correctly, but you can see the PS column is not right and channel doesn't configure correctly.
/sys/kernel/debug/ncsi_protocol# cat ncsi_device_status
IFIDX IFNAME NAME PID CID RX TX MP MC WP WC PC PS LS RU CR NQ HA
===================================================================
2 eth2 ncsi0 000 000 1 1 1 1 1 1 1 0 1 1 1 0 1 2 eth2 ncsi1 000 001 1 0 1 1 1 1 0 0 1 1 1 0 1 2 eth2 ncsi2 001 000 0 0 1 1 0 0 0 0 1 1 1 0 1 2 eth2 ncsi3 001 001 0 0 1 1 0 0 0 0 1 1 1 0 1
===================================================================
MP: Multi-mode Package WP: Whitelist Package
MC: Multi-mode Channel WC: Whitelist Channel
PC: Primary Channel
PS: Poll Status
LS: Link Status
RU: Running
CR: Carrier OK
NQ: Queue Stopped
HA: Hardware Arbitration
PS column is getting from (int)nc->monitor.enabled.
Samuel Mendoza-Jonas
maintainerRe: [PATCH net-next v2 5/6] net/ncsi: Reset channel state in ncsi_start_dev()
Quoted 34 lines · On Fri, 2018-10-26 at 17:25 +0000, [email protected] wrote:
Hi Samuel,
I noticed a few issues and commented below.
Thanks,
JustinQuoted 26 lines
/* Resources */
net/ncsi/internal.h +1
-0+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 +4
-2@@ -550,8 +550,10 @@ static void ncsi_suspend_channel(struct ncsi_dev_priv *ndp)spin_lock_irqsave (&nc->lock, flags); nc->state =NCSI_CHANNEL_INACTIVE ;spin_unlock_irqrestore (&nc->lock, flags); -ncsi_process_next_channel (ndp); - +if (ndp->flags &NCSI_DEV_RESET ) +ncsi_reset_dev (nd); +else +ncsi_process_next_channel (ndp);break ;default : netdev_warn(nd->dev, "Wrong NCSI state 0x%x in suspend\n",@@ -1554,7 +1556,7 @@ int ncsi_start_dev(struct ncsi_dev *nd)return 0 ; }
Quoted 7 lines
net/ncsi/ncsi-manage.c int ncsi_start_dev(struct ncsi_dev *nd) · line 1559
Quoted 2 lines
net/ncsi/ncsi-manage.c +1
-1-return ncsi_choose_active_channel (nd); +return ncsi_reset_dev (nd);If there is no available channel due to the whitelist,
ncsi_start_dev()function will return failed Status and the network interface may fail to bring up too. It is possible for user to disable all channels and leave the interface up for checking the LOM status.
I'm not sure that that is a bug, or at least not in the scope of this series. If the whitelist is set such that no channels are valid then there's nothing for NCSI to do. If we want to do something like always monitor all channels then that would be best to do in another patch.
Quoted 6 lines
net/ncsi/ncsi-manage.c int ncsi_start_dev(struct ncsi_dev *nd) · line 1561
Quoted 2 lines
net/ncsi/ncsi-manage.c +0
-0}EXPORT_SYMBOL_GPL (ncsi_start_dev);Also, if I send
set_package_maskandset_channel_maskcommands back to back in a program, the state machine doesn't work well. If I use command line and wait for it to complete for each step, then it is fine.
Yeah that's not great; probably hitting some corner cases in the NCSI locking. I'll look into the multi-channel related stuff but I have a feeling that if you tried this with the existing set/clear commands you would probably hit something similar, especially on your dual core platform. If so this is probably something to fix separately.
Quoted 50 lines
npcm7xx-emc f0825000.eth eth2: NCSI: Multi-package enabled on ifindex 2, mask
0x00000001npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_stop_channel_monitor()- pkg 0 ch 0 npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_dev_work()
npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_suspend_channel()- pkg 0 ch 0 state 0400 npcm7xx-emc f0825000.eth eth2: NCSI: pkg 0 ch 0 set as preferred channel npcm7xx-emc f0825000.eth eth2: NCSI: Multi-channel enabled on ifindex 2, mask0x00000003npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_stop_channel_monitor()- pkg 0 ch 1 npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_dev_work()
npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_suspend_channel()- pkg 0 ch 1 state 0400 npcm7xx-emc f0825000.eth eth2: NCSI: Package 1 set to all channels disabled npcm7xx-emc f0825000.eth eth2: NCSI: Multi-channel enabled on ifindex 2, mask0x00000000npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_choose_active_channel()npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_choose_active_channel()- pkg 0 npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_choose_active_channel()- pass pkg whitelist npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_choose_active_channel()- ch 0 npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_choose_active_channel()- pass ch whitelist npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_choose_active_channel()- skip npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_choose_active_channel()- ch 1 npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_choose_active_channel()- pass ch whitelist npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_choose_active_channel()- skip npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_choose_active_channel()- next pkg npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_choose_active_channel()- pkg 1 npcm7xx-emc f0825000.eth eth2: NCSI: No channel found to configure! npcm7xx-emc f0825000.eth eth2: NCSI interface down
npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_dev_work()
npcm7xx-emc f0825000.eth eth2: Wrong NCSI state0x100in workqueueAll masks are set correctly, but you can see the PS column is not right and channel doesn't configure correctly.
/sys/kernel/debug/ncsi_protocol# cat
ncsi_device_status
IFIDX IFNAME NAME PID CID RX TX MP MC WP WC PC PS LS RU CR NQ HA
===================================================================2 eth2 ncsi0 000 000 1 1 1 1 1 1 1 0 1 1 1 0 1 2 eth2 ncsi1 000 001 1 0 1 1 1 1 0 0 1 1 1 0 1 2 eth2 ncsi2 001 000 0 0 1 1 0 0 0 0 1 1 1 0 1 2 eth2 ncsi3 001 001 0 0 1 1 0 0 0 0 1 1 1 0 1===================================================================
MP: Multi-mode Package WP: Whitelist Package
MC: Multi-mode Channel WC: Whitelist Channel
PC: Primary Channel
PS: Poll Status
LS: Link Status
RU: Running
CR: Carrier OK
NQ: Queue Stopped
HA: Hardware ArbitrationPS column is getting from (int)nc->monitor.enabled.
RE: [PATCH net-next v2 5/6] net/ncsi: Reset channel state in ncsi_start_dev()
Quoted 57 lines · On Fri, 2018-10-26 at 17:25 +0000, [email protected] wrote:
Quoted 34 lines
Hi Samuel,
I noticed a few issues and commented below.
Thanks,
JustinQuoted 26 lines
/* Resources */
net/ncsi/internal.h +1
-0+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 +4
-2@@ -550,8 +550,10 @@ static void ncsi_suspend_channel(struct ncsi_dev_priv *ndp)spin_lock_irqsave (&nc->lock, flags); nc->state =NCSI_CHANNEL_INACTIVE ;spin_unlock_irqrestore (&nc->lock, flags); -ncsi_process_next_channel (ndp); - +if (ndp->flags &NCSI_DEV_RESET ) +ncsi_reset_dev (nd); +else +ncsi_process_next_channel (ndp);break ;default : netdev_warn(nd->dev, "Wrong NCSI state 0x%x in suspend\n",@@ -1554,7 +1556,7 @@ int ncsi_start_dev(struct ncsi_dev *nd)return 0 ; }Quoted 7 lines
net/ncsi/ncsi-manage.c int ncsi_start_dev(struct ncsi_dev *nd) · line 1559
Quoted 2 lines
net/ncsi/ncsi-manage.c +1
-1-return ncsi_choose_active_channel (nd); +return ncsi_reset_dev (nd);If there is no available channel due to the whitelist,
ncsi_start_dev()function will return failed Status and the network interface may fail to bring up too. It is possible for user to disable all channels and leave the interface up for checking the LOM status.I'm not sure that that is a bug, or at least not in the scope of this series. If the whitelist is set such that no channels are valid then there's nothing for NCSI to do. If we want to do something like always monitor all channels then that would be best to do in another patch.
Quoted 6 lines
net/ncsi/ncsi-manage.c int ncsi_start_dev(struct ncsi_dev *nd) · line 1561
Quoted 2 lines
net/ncsi/ncsi-manage.c +0
-0}EXPORT_SYMBOL_GPL (ncsi_start_dev);Also, if I send
set_package_maskandset_channel_maskcommands back to back in a program, the state machine doesn't work well. If I use command line and wait for it to complete for each step, then it is fine.
Quoted 6 lines
Yeah that's not great; probably hitting some corner cases in the NCSI locking. I'll look into the multi-channel related stuff but I have a feeling that if you tried this with the existing set/clear commands you would probably hit something similar, especially on your dual core platform. If so this is probably something to fix separately.
It is possible that it is causing by the following code in ncsi_reset_dev() function. The state might be overwritten and the previous operation is interrupted.
spin_lock_irqsave(&ndp->lock, flags); ndp->flags |= NCSI_DEV_RESET; ndp->active_channel = active; ndp->active_package = active->package; spin_unlock_irqrestore(&ndp->lock, flags); nd->state = ncsi_dev_state_suspend;
Quoted 50 lines
Quoted 50 lines
npcm7xx-emc f0825000.eth eth2: NCSI: Multi-package enabled on ifindex 2, mask
0x00000001npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_stop_channel_monitor()- pkg 0 ch 0 npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_dev_work()
npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_suspend_channel()- pkg 0 ch 0 state 0400 npcm7xx-emc f0825000.eth eth2: NCSI: pkg 0 ch 0 set as preferred channel npcm7xx-emc f0825000.eth eth2: NCSI: Multi-channel enabled on ifindex 2, mask0x00000003npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_stop_channel_monitor()- pkg 0 ch 1 npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_dev_work()
npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_suspend_channel()- pkg 0 ch 1 state 0400 npcm7xx-emc f0825000.eth eth2: NCSI: Package 1 set to all channels disabled npcm7xx-emc f0825000.eth eth2: NCSI: Multi-channel enabled on ifindex 2, mask0x00000000npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_choose_active_channel()npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_choose_active_channel()- pkg 0 npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_choose_active_channel()- pass pkg whitelist npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_choose_active_channel()- ch 0 npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_choose_active_channel()- pass ch whitelist npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_choose_active_channel()- skip npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_choose_active_channel()- ch 1 npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_choose_active_channel()- pass ch whitelist npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_choose_active_channel()- skip npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_choose_active_channel()- next pkg npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_choose_active_channel()- pkg 1 npcm7xx-emc f0825000.eth eth2: NCSI: No channel found to configure! npcm7xx-emc f0825000.eth eth2: NCSI interface down
npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_dev_work()
npcm7xx-emc f0825000.eth eth2: Wrong NCSI state0x100in workqueueAll masks are set correctly, but you can see the PS column is not right and channel doesn't configure correctly.
/sys/kernel/debug/ncsi_protocol# cat
ncsi_device_status
IFIDX IFNAME NAME PID CID RX TX MP MC WP WC PC PS LS RU CR NQ HA
===================================================================2 eth2 ncsi0 000 000 1 1 1 1 1 1 1 0 1 1 1 0 1 2 eth2 ncsi1 000 001 1 0 1 1 1 1 0 0 1 1 1 0 1 2 eth2 ncsi2 001 000 0 0 1 1 0 0 0 0 1 1 1 0 1 2 eth2 ncsi3 001 001 0 0 1 1 0 0 0 0 1 1 1 0 1===================================================================
MP: Multi-mode Package WP: Whitelist Package
MC: Multi-mode Channel WC: Whitelist Channel
PC: Primary Channel
PS: Poll Status
LS: Link Status
RU: Running
CR: Carrier OK
NQ: Queue Stopped
HA: Hardware ArbitrationPS column is getting from (int)nc->monitor.enabled.
Samuel Mendoza-Jonas
maintainerRe: [PATCH net-next v2 5/6] net/ncsi: Reset channel state in ncsi_start_dev()
Quoted 65 lines · On Tue, 2018-10-30 at 18:23 +0000, [email protected] wrote:
Quoted 55 lines · On Fri, 2018-10-26 at 17:25 +0000, [email protected] wrote:
Quoted 34 lines
Hi Samuel,
I noticed a few issues and commented below.
Thanks,
JustinQuoted 26 lines
/* Resources */
net/ncsi/internal.h +1
-0+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 +4
-2@@ -550,8 +550,10 @@ static void ncsi_suspend_channel(struct ncsi_dev_priv *ndp)spin_lock_irqsave (&nc->lock, flags); nc->state =NCSI_CHANNEL_INACTIVE ;spin_unlock_irqrestore (&nc->lock, flags); -ncsi_process_next_channel (ndp); - +if (ndp->flags &NCSI_DEV_RESET ) +ncsi_reset_dev (nd); +else +ncsi_process_next_channel (ndp);break ;default : netdev_warn(nd->dev, "Wrong NCSI state 0x%x in suspend\n",@@ -1554,7 +1556,7 @@ int ncsi_start_dev(struct ncsi_dev *nd)return 0 ; }Quoted 7 lines
net/ncsi/ncsi-manage.c int ncsi_start_dev(struct ncsi_dev *nd) · line 1559
Quoted 2 lines
net/ncsi/ncsi-manage.c +1
-1-return ncsi_choose_active_channel (nd); +return ncsi_reset_dev (nd);If there is no available channel due to the whitelist,
ncsi_start_dev()function will return failed Status and the network interface may fail to bring up too. It is possible for user to disable all channels and leave the interface up for checking the LOM status.I'm not sure that that is a bug, or at least not in the scope of this series. If the whitelist is set such that no channels are valid then there's nothing for NCSI to do. If we want to do something like always monitor all channels then that would be best to do in another patch.
Quoted 6 lines
net/ncsi/ncsi-manage.c int ncsi_start_dev(struct ncsi_dev *nd) · line 1561
Quoted 2 lines
net/ncsi/ncsi-manage.c +0
-0}EXPORT_SYMBOL_GPL (ncsi_start_dev);Also, if I send
set_package_maskandset_channel_maskcommands back to back in a program, the state machine doesn't work well. If I use command line and wait for it to complete for each step, then it is fine.Quoted 6 lines
Yeah that's not great; probably hitting some corner cases in the NCSI locking. I'll look into the multi-channel related stuff but I have a feeling that if you tried this with the existing set/clear commands you would probably hit something similar, especially on your dual core platform. If so this is probably something to fix separately.
It is possible that it is causing by the following code in
ncsi_reset_dev()function. The state might be overwritten and the previous operation is interrupted.
Quoted 7 lines
spin_lock_irqsave(&ndp->lock, flags); ndp->flags |= NCSI_DEV_RESET; ndp->active_channel = active; ndp->active_package = active->package; spin_unlock_irqrestore(&ndp->lock, flags); nd->state = ncsi_dev_state_suspend;
Yep, we should probably add a check before calling ncsi_reset_dev() in the netlink code if we're already in reset, and check in ncsi_reset_dev() if we mid-configuration.
For your trace below can you share exactly which commands you were sending? Those messages aren't upstream so it's not 100% clear what's being sent.
Thanks!
Sam
Quoted 52 lines
Quoted 50 lines
Quoted 50 lines
npcm7xx-emc f0825000.eth eth2: NCSI: Multi-package enabled on ifindex 2, mask
0x00000001npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_stop_channel_monitor()- pkg 0 ch 0 npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_dev_work()
npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_suspend_channel()- pkg 0 ch 0 state 0400 npcm7xx-emc f0825000.eth eth2: NCSI: pkg 0 ch 0 set as preferred channel npcm7xx-emc f0825000.eth eth2: NCSI: Multi-channel enabled on ifindex 2, mask0x00000003npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_stop_channel_monitor()- pkg 0 ch 1 npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_dev_work()
npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_suspend_channel()- pkg 0 ch 1 state 0400 npcm7xx-emc f0825000.eth eth2: NCSI: Package 1 set to all channels disabled npcm7xx-emc f0825000.eth eth2: NCSI: Multi-channel enabled on ifindex 2, mask0x00000000npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_choose_active_channel()npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_choose_active_channel()- pkg 0 npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_choose_active_channel()- pass pkg whitelist npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_choose_active_channel()- ch 0 npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_choose_active_channel()- pass ch whitelist npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_choose_active_channel()- skip npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_choose_active_channel()- ch 1 npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_choose_active_channel()- pass ch whitelist npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_choose_active_channel()- skip npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_choose_active_channel()- next pkg npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_choose_active_channel()- pkg 1 npcm7xx-emc f0825000.eth eth2: NCSI: No channel found to configure! npcm7xx-emc f0825000.eth eth2: NCSI interface down
npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_dev_work()
npcm7xx-emc f0825000.eth eth2: Wrong NCSI state0x100in workqueueAll masks are set correctly, but you can see the PS column is not right and channel doesn't configure correctly.
/sys/kernel/debug/ncsi_protocol# cat
ncsi_device_status
IFIDX IFNAME NAME PID CID RX TX MP MC WP WC PC PS LS RU CR NQ HA
===================================================================2 eth2 ncsi0 000 000 1 1 1 1 1 1 1 0 1 1 1 0 1 2 eth2 ncsi1 000 001 1 0 1 1 1 1 0 0 1 1 1 0 1 2 eth2 ncsi2 001 000 0 0 1 1 0 0 0 0 1 1 1 0 1 2 eth2 ncsi3 001 001 0 0 1 1 0 0 0 0 1 1 1 0 1===================================================================
MP: Multi-mode Package WP: Whitelist Package
MC: Multi-mode Channel WC: Whitelist Channel
PC: Primary Channel
PS: Poll Status
LS: Link Status
RU: Running
CR: Carrier OK
NQ: Queue Stopped
HA: Hardware ArbitrationPS column is getting from (int)nc->monitor.enabled.
RE: [PATCH net-next v2 5/6] net/ncsi: Reset channel state in ncsi_start_dev()
Quoted 8 lines
For your trace below can you share exactly which commands you were sending? Those messages aren't upstream so it's not 100% clear what's being sent.
Thanks!
Sam
It is sending via netlink directly. I have two packages (0 and 1) and each package has two channels (0 and 1) on my system. If I convert it to command line, it would be as below.
/home/root# ncsi_netlink -l 2 -m -a 0x01
Set cmd - ifindex 2, multi 1, mask 0x00000001
/home/root# ncsi_netlink -l 2 -m -b 0x03 -p 0
Set cmd - ifindex 2, package 0, channel -1, multi 1, mask 0x00000003
/home/root# ncsi_netlink -l 2 -m -b 0x00 -p 1
Set cmd - ifindex 2, package 1, channel -1, multi 1, mask 0x00000000
/home/root# ncsi_netlink
Usage: ncsi_netlink COMMAND [OPTION]... Send messages to the NCSI driver via Netlink (0.4)
Mandatory arguments to long options are mandatory for short options too. COMMAND:
-i, --info Display info for packages and channels -s, --set Force the usage of a certain package/channel combination -x, --clear Clear the above setting -a, --package-mask MASK Set package selection mask -b, --channel-mask MASK Set channel selection mask -o, --cmd DATA0 [DATA1]... Send NC-SI command -d, --discovery Request to discover packages and channels -k, --lookup Look up channel id or name -u, --status Display status -h, --help Print this help text
OPTION:
-l, --ifindex INDEX Specify the interface index -p, --package PACKAGE Package number -c, --channel CHANNEL Channel number (aka. port number) -n, --channel NAME Channel name (aka. ncsiX) -m, --multi-mode Set multi-mode
Example: ncsi_netlink -l 2 --info
Quoted 52 lines
Quoted 50 lines
Quoted 50 lines
Quoted 50 lines
npcm7xx-emc f0825000.eth eth2: NCSI: Multi-package enabled on ifindex 2, mask
0x00000001npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_stop_channel_monitor()- pkg 0 ch 0 npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_dev_work()
npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_suspend_channel()- pkg 0 ch 0 state 0400 npcm7xx-emc f0825000.eth eth2: NCSI: pkg 0 ch 0 set as preferred channel npcm7xx-emc f0825000.eth eth2: NCSI: Multi-channel enabled on ifindex 2, mask0x00000003npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_stop_channel_monitor()- pkg 0 ch 1 npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_dev_work()
npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_suspend_channel()- pkg 0 ch 1 state 0400 npcm7xx-emc f0825000.eth eth2: NCSI: Package 1 set to all channels disabled npcm7xx-emc f0825000.eth eth2: NCSI: Multi-channel enabled on ifindex 2, mask0x00000000npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_choose_active_channel()npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_choose_active_channel()- pkg 0 npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_choose_active_channel()- pass pkg whitelist npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_choose_active_channel()- ch 0 npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_choose_active_channel()- pass ch whitelist npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_choose_active_channel()- skip npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_choose_active_channel()- ch 1 npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_choose_active_channel()- pass ch whitelist npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_choose_active_channel()- skip npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_choose_active_channel()- next pkg npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_choose_active_channel()- pkg 1 npcm7xx-emc f0825000.eth eth2: NCSI: No channel found to configure! npcm7xx-emc f0825000.eth eth2: NCSI interface down
npcm7xx-emc f0825000.eth eth2: NCSI:ncsi_dev_work()
npcm7xx-emc f0825000.eth eth2: Wrong NCSI state0x100in workqueueAll masks are set correctly, but you can see the PS column is not right and channel doesn't configure correctly.
/sys/kernel/debug/ncsi_protocol# cat
ncsi_device_status
IFIDX IFNAME NAME PID CID RX TX MP MC WP WC PC PS LS RU CR NQ HA
===================================================================2 eth2 ncsi0 000 000 1 1 1 1 1 1 1 0 1 1 1 0 1 2 eth2 ncsi1 000 001 1 0 1 1 1 1 0 0 1 1 1 0 1 2 eth2 ncsi2 001 000 0 0 1 1 0 0 0 0 1 1 1 0 1 2 eth2 ncsi3 001 001 0 0 1 1 0 0 0 0 1 1 1 0 1===================================================================
MP: Multi-mode Package WP: Whitelist Package
MC: Multi-mode Channel WC: Whitelist Channel
PC: Primary Channel
PS: Poll Status
LS: Link Status
RU: Running
CR: Carrier OK
NQ: Queue Stopped
HA: Hardware ArbitrationPS column is getting from (int)nc->monitor.enabled.
Samuel Mendoza-Jonas
maintainerPATCH v2 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.
---
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().
include/uapi/linux/ncsi.h | 15 +++ net/ncsi/internal.h | 16 ++- net/ncsi/ncsi-aen.c | 49 ++++++-- net/ncsi/ncsi-manage.c | 247 +++++++++++++++++++++++++++++++------- net/ncsi/ncsi-netlink.c | 219 ++++++++++++++++++++++++++++----- net/ncsi/ncsi-rsp.c | 2 +- 6 files changed, 464 insertions(+), 84 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 +41 -8
62 lines not on this page · raw message
net/ncsi/ncsi-manage.c +202 -45
335 lines not on this page · raw message
net/ncsi/ncsi-netlink.c +191 -28
285 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 v2 6/6] net/ncsi: Configure multi-package, multi-channel modes with failover
Hi Samuel,
There is one place that we assume the next available TX channel is under the same package. Please see the comment below.
Thanks,
Justin
+/* Change the active Tx channel in a multi-channel setup */ +int ncsi_update_tx_channel(struct ncsi_dev_priv *ndp,
net/ncsi/ncsi-manage.c static int ncsi_gma_handler(struct ncsi_cmd_arg *nca, unsigned int mf_id) · line 811
Quoted 13 lines
net/ncsi/ncsi-manage.c +13
-0+struct ncsi_package *np, + struct ncsi_channel *disable, + struct ncsi_channel *enable) +{ + struct ncsi_cmd_arg nca; +struct ncsi_channel *nc; +int ret =0 ; + +if (!np->multi_channel) +netdev_warn (ndp->ndev.dev, +"NCSI: Trying to update Tx channel in single-channel mode\n" ); + nca.ndp = ndp; + nca.package = np->id;
If the channel may be on different package, the package ID here may not be correct in some cases.
Quoted 15 lines
net/ncsi/ncsi-manage.c +15
-0+ nca.req_flags =0 ; + +/* Find current channel with Tx enabled */ +if (!disable) { + NCSI_FOR_EACH_CHANNEL(np, nc) +if (nc->modes[NCSI_MODE_TX_ENABLE ].enable) + disable = nc; + } + +/* Find a suitable channel for Tx */ +if (!enable) { +if (np->preferred_channel && +ncsi_channel_has_link (np->preferred_channel)) { + enable = np->preferred_channel; + }else {
net/ncsi/ncsi-manage.c static int ncsi_gma_handler(struct ncsi_cmd_arg *nca, unsigned int mf_id) · line 836
Quoted 10 lines
net/ncsi/ncsi-manage.c +10
-0+ NCSI_FOR_EACH_CHANNEL(np, nc) { +if (!(np->channel_whitelist &0x1 << nc->id)) +continue ; +if (nc->state !=NCSI_CHANNEL_ACTIVE ) +continue ; +if (ncsi_channel_has_link (nc)) { + enable = nc; +break ; + } + }
When we search, we need to consider the other available channel might be on the package.
Quoted 8 lines
net/ncsi/ncsi-manage.c +8
-0+ } + } + +if (disable == enable) +return -1 ; + +if (!enable) +return -1 ;
net/ncsi/ncsi-manage.c static int ncsi_gma_handler(struct ncsi_cmd_arg *nca, unsigned int mf_id) · line 854
Quoted 10 lines
net/ncsi/ncsi-manage.c +10
-0+ +if (disable) { + nca.channel = disable->id; + nca.type =NCSI_PKT_CMD_DCNT ; + ret =ncsi_xmit_cmd (&nca); +if (ret) +netdev_err (ndp->ndev.dev, +"Error %d sending DCNT\n" , + ret); + }
I remove the cable from ncsi0 and it doesn't failover to ncsi3 as ncsi0 and ncsi3 are not under the same package.
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 3 0 0 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 0 0 1 1 1 0 0 1 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
PS: Poll Status LS: Link Status
RU: Running CR: Carrier OK
NQ: Queue Stopped HA: Hardware Arbitration
Samuel Mendoza-Jonas
maintainerRe: [PATCH net-next v2 6/6] net/ncsi: Configure multi-package, multi-channel modes with failover
Quoted 48 lines · On Fri, 2018-10-26 at 21:48 +0000, [email protected] wrote:
Hi Samuel,
There is one place that we assume the next available TX channel is under the same package. Please see the comment below.
Thanks,
Justinnet/ncsi/ncsi-manage.c +2
-0+/* Change the active Tx channel in a multi-channel setup */ +int ncsi_update_tx_channel(struct ncsi_dev_priv *ndp,net/ncsi/ncsi-manage.c static int ncsi_gma_handler(struct ncsi_cmd_arg *nca, unsigned int mf_id) · line 811
Quoted 13 lines
net/ncsi/ncsi-manage.c +13
-0+struct ncsi_package *np, + struct ncsi_channel *disable, + struct ncsi_channel *enable) +{ + struct ncsi_cmd_arg nca; +struct ncsi_channel *nc; +int ret =0 ; + +if (!np->multi_channel) +netdev_warn (ndp->ndev.dev, +"NCSI: Trying to update Tx channel in single-channel mode\n" ); + nca.ndp = ndp; + nca.package = np->id;If the channel may be on different package, the package ID here may not be correct in some cases.
Quoted 20 lines
net/ncsi/ncsi-manage.c +20
-0+ nca.req_flags =0 ; + +/* Find current channel with Tx enabled */ +if (!disable) { + NCSI_FOR_EACH_CHANNEL(np, nc) +if (nc->modes[NCSI_MODE_TX_ENABLE ].enable) + disable = nc; + } + +/* Find a suitable channel for Tx */ +if (!enable) { +if (np->preferred_channel && +ncsi_channel_has_link (np->preferred_channel)) { + enable = np->preferred_channel; + }else { + NCSI_FOR_EACH_CHANNEL(np, nc) { +if (!(np->channel_whitelist &0x1 << nc->id)) +continue ; +if (nc->state !=NCSI_CHANNEL_ACTIVE ) +continue ;
Quoted 8 lines
net/ncsi/ncsi-manage.c static int ncsi_gma_handler(struct ncsi_cmd_arg *nca, unsigned int mf_id) · line 836
Quoted 5 lines
net/ncsi/ncsi-manage.c +5
-0+if (ncsi_channel_has_link (nc)) { + enable = nc; +break ; + } + }When we search, we need to consider the other available channel might be on the package.
Good point, I've updated this to allow for enabling Tx on a different package.
Thanks,
Sam
Quoted 37 lines
Quoted 9 lines
net/ncsi/ncsi-manage.c +8
-0+ } + } + +if (disable == enable) +return -1 ; + +if (!enable) +return -1 ;net/ncsi/ncsi-manage.c static int ncsi_gma_handler(struct ncsi_cmd_arg *nca, unsigned int mf_id) · line 854
Quoted 10 lines
net/ncsi/ncsi-manage.c +10
-0+ +if (disable) { + nca.channel = disable->id; + nca.type =NCSI_PKT_CMD_DCNT ; + ret =ncsi_xmit_cmd (&nca); +if (ret) +netdev_err (ndp->ndev.dev, +"Error %d sending DCNT\n" , + ret); + }I remove the cable from ncsi0 and it doesn't failover to ncsi3 as ncsi0 and ncsi3 are not under the same package.
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 3 0 0 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 0 0 1 1 1 0 0 1 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
PS: Poll Status LS: Link Status
RU: Running CR: Carrier OK
NQ: Queue Stopped HA: Hardware Arbitration
David Miller
maintainerFrom: Samuel Mendoza-Jonas <[email protected]>
Date: Wed, 24 Oct 2018 10:51:55 +1300
Quoted 18 lines
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.
Quoted 6 lines
Changes in v2:
- Updated use of the channel lock inncsi_reset_dev(), making the channel invisible and leaving the monitor check toncsi_stop_channel_monitor().
- Fixedncsi_channel_is_tx()to consider the state of channels in other packages.
net-next is closed, please resubmit this when net-next opens back up.
Thank you.