Skip to contentSkip to conversation

Propagate NCSI channel carrier loss/gain events to the kernel

PATCH In review Johnathan Mantey 3 participants 6 messages Jan 10, 2020 – Jan 15, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Propagate NCSI channel carrier loss/gain events to the kernel

From 76d99782ec897b010ba507895d60d27dca8dca44 Mon Sep 17 00:00:00 2001
From: Johnathan Mantey <[email protected]>
Date: Fri, 10 Jan 2020 12:46:17 -0800
Subject: [PATCH] Propagate NCSI channel carrier loss/gain events to the kernel

Problem statement:
Insertion or removal of a network cable attached to a NCSI controlled network channel does not notify the kernel of the loss/gain of the network link.

The expectation is that /sys/class/net/eth(x)/carrier will change state after a pull/insertion event. In addition the carrier_up_count and carrier_down_count files should increment.

Change statement:
Use the NCSI Asynchronous Event Notification handler to detect a change in a NCSI link.
Add code to propagate carrier on/off state to the network interface. The on/off state is only modified after the existing code identifies if the network device HAD or HAS a link state change.

Test procedure:
Connected a L2 switch with only two ports connected.
One port was a DHCP corporate net, the other port attached to the NCSI controlled NIC.

Starting with the L2 switch with DC on, check to make sure the NCSI link is operating.
cat /sys/class/net/eth1/carrier
1
cat /sys/class/net/eth1/carrier_up_count
0
cat /sys/class/net/eth1/carrier_down_count
0

Remove DC from the L2 switch, and check link state cat /sys/class/net/eth1/carrier
0
cat /sys/class/net/eth1/carrier_up_count
0
cat /sys/class/net/eth1/carrier_down_count 1

Restore DC to the L2 switch, and check link state
cat /sys/class/net/eth1/carrier
1
cat /sys/class/net/eth1/carrier_up_count
1
cat /sys/class/net/eth1/carrier_down_count
1

---
 net/ncsi/ncsi-aen.c | 6 ++++++

 1 file changed, 6 insertions(+)
net/ncsi/ncsi-aen.c +0 -0
index b635c194f0a8..274c415dcead 100644
@@ -89,6 +89,12 @@ static int ncsi_aen_handler_lsc(struct ncsi_dev_priv

*ndp,
     if ((had_link == has_link) || chained)
         return 0;

+    if (had_link) {
+        netif_carrier_off(ndp->ndev.dev);
+    } else {
+        netif_carrier_on(ndp->ndev.dev);
+    }
+
     if (!ndp->multi_package && !nc->package->multi_channel) { if (had_link) {
             ndp->flags |= NCSI_DEV_RESHUFFLE;

Signature · 1 line
2.24.1
maintainer
#1 lore raw

From: Johnathan Mantey <[email protected]>
Date: Fri, 10 Jan 2020 14:02:23 -0800

Please format your Subject line as:

Subject: $SUBSYSTEM_PREFIX: Summary.

Here, $SUBSYSTEM_PREFIX would be "ncsi: "

Quoted 9 lines

Problem statement:
Insertion or removal of a network cable attached to a NCSI controlled network channel does not notify the kernel of the loss/gain of the network link.

The expectation is that /sys/class/net/eth(x)/carrier will change state after a pull/insertion event. In addition the carrier_up_count and carrier_down_count files should increment.

Quoted 6 lines

Change statement:
Use the NCSI Asynchronous Event Notification handler to detect a change in a NCSI link.
Add code to propagate carrier on/off state to the network interface. The on/off state is only modified after the existing code identifies if the network device HAD or HAS a link state change.

Please remove this "Problem statement:" and "Change statement:", we know what you are talking about.

Quoted 10 lines
(quoted diff) +0 -0
@@ -89,6 +89,12 @@ static int ncsi_aen_handler_lsc(struct ncsi_dev_priv
 *ndp,
      if ((had_link == has_link) || chained)
          return 0;


+    if (had_link) {
+        netif_carrier_off(ndp->ndev.dev);
+    } else {
+        netif_carrier_on(ndp->ndev.dev);
+    }

As per coding style, single line basic blocks should not get curly braces around them in this situation.

Thank you.

maintainer
#2 lore raw
In reply to Johnathan Mantey
Quoted 17 lines · Johnathan Mantey

From 76d99782ec897b010ba507895d60d27dca8dca44 Mon Sep 17 00:00:00 2001
From: Johnathan Mantey <[email protected]>
Date: Fri, 10 Jan 2020 12:46:17 -0800
Subject: [PATCH] Propagate NCSI channel carrier loss/gain events to the
kernel

Problem statement:
Insertion or removal of a network cable attached to a NCSI controlled network channel does not notify the kernel of the loss/gain of the network link.

The expectation is that /sys/class/net/eth(x)/carrier will change state after a pull/insertion event. In addition the carrier_up_count and carrier_down_count files should increment.

Quoted 6 lines

Change statement:
Use the NCSI Asynchronous Event Notification handler to detect a change in a NCSI link.
Add code to propagate carrier on/off state to the network interface. The on/off state is only modified after the existing code identifies if the network device HAD or HAS a link state change.

If we set the carrier state off until we successfully configured a channel could we avoid this limitation?

Cheers,
Sam

Quoted 56 lines

Test procedure:
Connected a L2 switch with only two ports connected. One port was a DHCP corporate net, the other port attached to the NCSI
controlled NIC.

Starting with the L2 switch with DC on, check to make sure the NCSI link is operating.
cat /sys/class/net/eth1/carrier
1
cat /sys/class/net/eth1/carrier_up_count
0
cat /sys/class/net/eth1/carrier_down_count
0

Remove DC from the L2 switch, and check link state cat /sys/class/net/eth1/carrier
0
cat /sys/class/net/eth1/carrier_up_count
0
cat /sys/class/net/eth1/carrier_down_count 1

Restore DC to the L2 switch, and check link state
cat /sys/class/net/eth1/carrier
1
cat /sys/class/net/eth1/carrier_up_count
1
cat /sys/class/net/eth1/carrier_down_count
1

---
 net/ncsi/ncsi-aen.c | 6 ++++++
 1 file changed, 6 insertions(+)
net/ncsi/ncsi-aen.c +0 -0
index b635c194f0a8..274c415dcead 100644
@@ -89,6 +89,12 @@ static int ncsi_aen_handler_lsc(struct

ncsi_dev_priv
*ndp,

     if ((had_link == has_link) || chained)
         return 0;
net/ncsi/ncsi-aen.c +6 -0
+    if (had_link) {
+        netif_carrier_off(ndp->ndev.dev);
+    } else {
+        netif_carrier_on(ndp->ndev.dev);
+    }
+
     if (!ndp->multi_package && !nc->package->multi_channel) {
         if (had_link) {
             ndp->flags |= NCSI_DEV_RESHUFFLE;
#3 lore raw

Sam,

This code is working on a channel that is completely configured. This code is covering a situation where the RJ45 cable is intentionally or mistakenly removed from a system. In the event that the network cable is removed/damaged/slips, the kernel needs to change state to show that network interface no longer has a link. For my employers use case the loss of carrier is then added to a log of system state changes. Thus for each internal channel there needs to be a way to report that the channel has/does not have a link carrier.

Quoted 88 lines · samjonas
Quoted 17 lines · Johnathan Mantey

From 76d99782ec897b010ba507895d60d27dca8dca44 Mon Sep 17 00:00:00 2001
From: Johnathan Mantey <[email protected]>
Date: Fri, 10 Jan 2020 12:46:17 -0800
Subject: [PATCH] Propagate NCSI channel carrier loss/gain events to the
kernel

Problem statement:
Insertion or removal of a network cable attached to a NCSI controlled network channel does not notify the kernel of the loss/gain of the network link.

The expectation is that /sys/class/net/eth(x)/carrier will change state after a pull/insertion event. In addition the carrier_up_count and carrier_down_count files should increment.

Quoted 6 lines

Change statement:
Use the NCSI Asynchronous Event Notification handler to detect a change in a NCSI link.
Add code to propagate carrier on/off state to the network interface. The on/off state is only modified after the existing code identifies if the network device HAD or HAS a link state change.

If we set the carrier state off until we successfully configured a channel could we avoid this limitation?

Cheers,
Sam

Quoted 56 lines

Test procedure:
Connected a L2 switch with only two ports connected. One port was a DHCP corporate net, the other port attached to the NCSI
controlled NIC.

Starting with the L2 switch with DC on, check to make sure the NCSI link is operating.
cat /sys/class/net/eth1/carrier
1
cat /sys/class/net/eth1/carrier_up_count
0
cat /sys/class/net/eth1/carrier_down_count
0

Remove DC from the L2 switch, and check link state cat /sys/class/net/eth1/carrier
0
cat /sys/class/net/eth1/carrier_up_count
0
cat /sys/class/net/eth1/carrier_down_count 1

Restore DC to the L2 switch, and check link state
cat /sys/class/net/eth1/carrier
1
cat /sys/class/net/eth1/carrier_up_count
1
cat /sys/class/net/eth1/carrier_down_count
1

---
 net/ncsi/ncsi-aen.c | 6 ++++++
 1 file changed, 6 insertions(+)
net/ncsi/ncsi-aen.c +0 -0
index b635c194f0a8..274c415dcead 100644
@@ -89,6 +89,12 @@ static int ncsi_aen_handler_lsc(struct

ncsi_dev_priv
*ndp,

     if ((had_link == has_link) || chained)
         return 0;
net/ncsi/ncsi-aen.c +6 -0
+    if (had_link) {
+        netif_carrier_off(ndp->ndev.dev);
+    } else {
+        netif_carrier_on(ndp->ndev.dev);
+    }
+
     if (!ndp->multi_package && !nc->package->multi_channel) {
         if (had_link) {
             ndp->flags |= NCSI_DEV_RESHUFFLE;
Signature · 6 lines
Johnathan Mantey
Senior Software Engineer
*azad technology partners*
Contributing to Technology Innovation since 1992
Phone: (503) 712-6764
Email: [email protected] <mailto:[email protected]>
maintainer
#4 lore raw
Quoted 15 lines · Johnathan Mantey

Sam,

This code is working on a channel that is completely configured. This
code is covering a situation where the RJ45 cable is intentionally or mistakenly removed from a system. In the event that the network cable is
removed/damaged/slips, the kernel needs to change state to show that network interface no longer has a link. For my employers use case the
loss of carrier is then added to a log of system state changes. Thus for
each internal channel there needs to be a way to report that the channel
has/does not have a link carrier.

Hi Johnathan,

Right, updating the carrier status for NC-SI enabled interfaces is helpful for a number of use cases (DHCP, etc). At the moment this will only update the status after a LSC AEN appears, so on init the carrier status will always be "up" regardless of what's plugged into the channels. Does NC-SI still behave as expected if the carrier status is initially set to "down"?
(However if we did do that we would also need a change to set the carrier status on on configuration, or for packages that don't support AENs).

Cheers,
Sam

Quoted 98 lines · samjonas
Quoted 94 lines · Johnathan Mantey
Quoted 21 lines

From 76d99782ec897b010ba507895d60d27dca8dca44 Mon Sep 17 00:00:00 2001
From: Johnathan Mantey <[email protected]>
Date: Fri, 10 Jan 2020 12:46:17 -0800
Subject: [PATCH] Propagate NCSI channel carrier loss/gain events to
the
kernel

Problem statement:
Insertion or removal of a network cable attached to a NCSI controlled
network channel does not notify the kernel of the loss/gain of the
network link.

The expectation is that /sys/class/net/eth(x)/carrier will change state after a pull/insertion event. In addition the carrier_up_count
and carrier_down_count files should increment.

Quoted 8 lines

Change statement:
Use the NCSI Asynchronous Event Notification handler to detect a change in a NCSI link.
Add code to propagate carrier on/off state to the network interface.
The on/off state is only modified after the existing code identifies
if the network device HAD or HAS a link state change.

If we set the carrier state off until we successfully configured a channel could we avoid this limitation?

Cheers,
Sam

Quoted 57 lines

Test procedure:
Connected a L2 switch with only two ports connected. One port was a DHCP corporate net, the other port attached to the NCSI
controlled NIC.

Starting with the L2 switch with DC on, check to make sure the NCSI
link is operating.
cat /sys/class/net/eth1/carrier
1
cat /sys/class/net/eth1/carrier_up_count
0
cat /sys/class/net/eth1/carrier_down_count
0

Remove DC from the L2 switch, and check link state cat /sys/class/net/eth1/carrier
0
cat /sys/class/net/eth1/carrier_up_count
0
cat /sys/class/net/eth1/carrier_down_count 1

Restore DC to the L2 switch, and check link state
cat /sys/class/net/eth1/carrier
1
cat /sys/class/net/eth1/carrier_up_count
1
cat /sys/class/net/eth1/carrier_down_count
1

---
 net/ncsi/ncsi-aen.c | 6 ++++++
 1 file changed, 6 insertions(+)
net/ncsi/ncsi-aen.c +0 -0
index b635c194f0a8..274c415dcead 100644
@@ -89,6 +89,12 @@ static int ncsi_aen_handler_lsc(struct

ncsi_dev_priv
*ndp,

     if ((had_link == has_link) || chained)
         return 0;
net/ncsi/ncsi-aen.c +6 -0
+    if (had_link) {
+        netif_carrier_off(ndp->ndev.dev);
+    } else {
+        netif_carrier_on(ndp->ndev.dev);
+    }
+
     if (!ndp->multi_package && !nc->package->multi_channel) {
         if (had_link) {
             ndp->flags |= NCSI_DEV_RESHUFFLE;
maintainer
#5 lore raw
Quoted 23 lines · samjonas
Quoted 11 lines · Johnathan Mantey

Sam,

This code is working on a channel that is completely configured. This
code is covering a situation where the RJ45 cable is intentionally or
mistakenly removed from a system. In the event that the network cable
is
removed/damaged/slips, the kernel needs to change state to show that

Quoted 8 lines

network interface no longer has a link. For my employers use case the
loss of carrier is then added to a log of system state changes. Thus
for
each internal channel there needs to be a way to report that the channel
has/does not have a link carrier.

Hi Johnathan,

Quoted 9 lines

Right, updating the carrier status for NC-SI enabled interfaces is helpful for a number of use cases (DHCP, etc). At the moment this will
only update the status after a LSC AEN appears, so on init the carrier
status will always be "up" regardless of what's plugged into the channels. Does NC-SI still behave as expected if the carrier status is
initially set to "down"?

Ah I think I remember the issue with this; AFAIK netif_carrier_off() will stop scheduling packets for the interface. The change here should work for this specific case because the remote NIC will fire the LSC asynchronously, but it probably has the nasty side effect of stopping xmit for the entire local interface - ie, all packages and channels on this interface.

With this change can you confirm that normal failover still works for example, or otherwise try to configure the interface after a LSC/down event?

Thanks,
Sam

Quoted 112 lines

(However if we did do that we would also need a change to set the carrier status on on configuration, or for packages that don't support
AENs).

Cheers,
Sam

Quoted 104 lines · samjonas
Quoted 100 lines · Johnathan Mantey
Quoted 24 lines

From 76d99782ec897b010ba507895d60d27dca8dca44 Mon Sep 17 00:00:00
2001
From: Johnathan Mantey <[email protected]>
Date: Fri, 10 Jan 2020 12:46:17 -0800
Subject: [PATCH] Propagate NCSI channel carrier loss/gain events
to
the
kernel

Problem statement:
Insertion or removal of a network cable attached to a NCSI controlled
network channel does not notify the kernel of the loss/gain of the
network link.

The expectation is that /sys/class/net/eth(x)/carrier will change
state after a pull/insertion event. In addition the carrier_up_count
and carrier_down_count files should increment.

Quoted 9 lines

Change statement:
Use the NCSI Asynchronous Event Notification handler to detect a
change in a NCSI link.
Add code to propagate carrier on/off state to the network interface.
The on/off state is only modified after the existing code identifies
if the network device HAD or HAS a link state change.

If we set the carrier state off until we successfully configured a
channel could we avoid this limitation?

Cheers,
Sam

Quoted 58 lines

Test procedure:
Connected a L2 switch with only two ports connected. One port was a DHCP corporate net, the other port attached to the
NCSI
controlled NIC.

Starting with the L2 switch with DC on, check to make sure the NCSI
link is operating.
cat /sys/class/net/eth1/carrier
1
cat /sys/class/net/eth1/carrier_up_count
0
cat /sys/class/net/eth1/carrier_down_count
0

Remove DC from the L2 switch, and check link state cat /sys/class/net/eth1/carrier
0
cat /sys/class/net/eth1/carrier_up_count
0
cat /sys/class/net/eth1/carrier_down_count 1

Restore DC to the L2 switch, and check link state
cat /sys/class/net/eth1/carrier
1
cat /sys/class/net/eth1/carrier_up_count
1
cat /sys/class/net/eth1/carrier_down_count
1

---
 net/ncsi/ncsi-aen.c | 6 ++++++
 1 file changed, 6 insertions(+)
net/ncsi/ncsi-aen.c +0 -0
index b635c194f0a8..274c415dcead 100644
@@ -89,6 +89,12 @@ static int ncsi_aen_handler_lsc(struct

ncsi_dev_priv
*ndp,

     if ((had_link == has_link) || chained)
         return 0;
net/ncsi/ncsi-aen.c +6 -0
+    if (had_link) {
+        netif_carrier_off(ndp->ndev.dev);
+    } else {
+        netif_carrier_on(ndp->ndev.dev);
+    }
+
     if (!ndp->multi_package && !nc->package->multi_channel) {
         if (had_link) {
             ndp->flags |= NCSI_DEV_RESHUFFLE;