Re: [PATCH net-next 1/2] net/ncsi: Improve general state logging

2017-11-10 Thread David Miller
From: Samuel Mendoza-Jonas 
Date: Wed,  8 Nov 2017 16:30:44 +1100

> The NCSI driver is mostly silent which becomes a headache when trying to
> determine what has occurred on the NCSI connection. This adds additional
> logging in a few key areas such as state transitions and calling out
> certain errors more visibly.
> 
> Signed-off-by: Samuel Mendoza-Jonas 

Applied.


Re: [PATCH net-next 1/2] net/ncsi: Improve general state logging

2017-11-10 Thread David Miller
From: Samuel Mendoza-Jonas 
Date: Wed,  8 Nov 2017 16:30:44 +1100

> The NCSI driver is mostly silent which becomes a headache when trying to
> determine what has occurred on the NCSI connection. This adds additional
> logging in a few key areas such as state transitions and calling out
> certain errors more visibly.
> 
> Signed-off-by: Samuel Mendoza-Jonas 

Applied.


[PATCH net-next 1/2] net/ncsi: Improve general state logging

2017-11-07 Thread Samuel Mendoza-Jonas
The NCSI driver is mostly silent which becomes a headache when trying to
determine what has occurred on the NCSI connection. This adds additional
logging in a few key areas such as state transitions and calling out
certain errors more visibly.

Signed-off-by: Samuel Mendoza-Jonas 
---
 net/ncsi/ncsi-aen.c| 15 +-
 net/ncsi/ncsi-manage.c | 76 +-
 net/ncsi/ncsi-rsp.c| 10 ++-
 3 files changed, 80 insertions(+), 21 deletions(-)

diff --git a/net/ncsi/ncsi-aen.c b/net/ncsi/ncsi-aen.c
index f135938bf781..67e708e98ccf 100644
--- a/net/ncsi/ncsi-aen.c
+++ b/net/ncsi/ncsi-aen.c
@@ -73,6 +73,9 @@ static int ncsi_aen_handler_lsc(struct ncsi_dev_priv *ndp,
ncm->data[2] = data;
ncm->data[4] = ntohl(lsc->oem_status);
 
+   netdev_info(ndp->ndev.dev, "NCSI: LSC AEN - channel %u state %s\n",
+   nc->id, data & 0x1 ? "up" : "down");
+
chained = !list_empty(>link);
state = nc->state;
spin_unlock_irqrestore(>lock, flags);
@@ -145,6 +148,8 @@ static int ncsi_aen_handler_hncdsc(struct ncsi_dev_priv 
*ndp,
ncm = >modes[NCSI_MODE_LINK];
hncdsc = (struct ncsi_aen_hncdsc_pkt *)h;
ncm->data[3] = ntohl(hncdsc->status);
+   netdev_info(ndp->ndev.dev, "NCSI: HNCDSC AEN - channel %u state %s\n",
+   nc->id, ncm->data[3] & 0x3 ? "up" : "down");
if (!list_empty(>link) ||
nc->state != NCSI_CHANNEL_ACTIVE) {
spin_unlock_irqrestore(>lock, flags);
@@ -212,10 +217,18 @@ int ncsi_aen_handler(struct ncsi_dev_priv *ndp, struct 
sk_buff *skb)
}
 
ret = ncsi_validate_aen_pkt(h, nah->payload);
-   if (ret)
+   if (ret) {
+   netdev_warn(ndp->ndev.dev,
+   "NCSI: 'bad' packet ignored for AEN type 0x%x\n",
+   h->type);
goto out;
+   }
 
ret = nah->handler(ndp, h);
+   if (ret)
+   netdev_err(ndp->ndev.dev,
+  "NCSI: Handler for AEN type 0x%x returned %d\n",
+  h->type, ret);
 out:
consume_skb(skb);
return ret;
diff --git a/net/ncsi/ncsi-manage.c b/net/ncsi/ncsi-manage.c
index 47baf914eec2..a2b904a718c6 100644
--- a/net/ncsi/ncsi-manage.c
+++ b/net/ncsi/ncsi-manage.c
@@ -229,6 +229,8 @@ static void ncsi_channel_monitor(unsigned long data)
case NCSI_CHANNEL_MONITOR_WAIT ... NCSI_CHANNEL_MONITOR_WAIT_MAX:
break;
default:
+   netdev_err(ndp->ndev.dev, "NCSI Channel %d timed out!\n",
+  nc->id);
if (!(ndp->flags & NCSI_DEV_HWA)) {
ncsi_report_link(ndp, true);
ndp->flags |= NCSI_DEV_RESHUFFLE;
@@ -682,7 +684,7 @@ static int clear_one_vid(struct ncsi_dev_priv *ndp, struct 
ncsi_channel *nc,
data = ncsi_get_filter(nc, NCSI_FILTER_VLAN, index);
if (!data) {
netdev_err(ndp->ndev.dev,
-  "ncsi: failed to retrieve filter %d\n", index);
+  "NCSI: failed to retrieve filter %d\n", index);
/* Set the VLAN id to 0 - this will still disable the entry in
 * the filter table, but we won't know what it was.
 */
@@ -692,7 +694,7 @@ static int clear_one_vid(struct ncsi_dev_priv *ndp, struct 
ncsi_channel *nc,
}
 
netdev_printk(KERN_DEBUG, ndp->ndev.dev,
- "ncsi: removed vlan tag %u at index %d\n",
+ "NCSI: removed vlan tag %u at index %d\n",
  vid, index + 1);
ncsi_remove_filter(nc, NCSI_FILTER_VLAN, index);
 
@@ -718,7 +720,7 @@ static int set_one_vid(struct ncsi_dev_priv *ndp, struct 
ncsi_channel *nc,
if (index < 0) {
/* New tag to add */
netdev_printk(KERN_DEBUG, ndp->ndev.dev,
- "ncsi: new vlan id to set: %u\n",
+ "NCSI: new vlan id to set: %u\n",
  vlan->vid);
break;
}
@@ -745,7 +747,7 @@ static int set_one_vid(struct ncsi_dev_priv *ndp, struct 
ncsi_channel *nc,
}
 
netdev_printk(KERN_DEBUG, ndp->ndev.dev,
- "ncsi: set vid %u in packet, index %u\n",
+ "NCSI: set vid %u in packet, index %u\n",
  vlan->vid, index + 1);
nca->type = NCSI_PKT_CMD_SVF;
nca->words[1] = vlan->vid;
@@ -784,8 +786,11 @@ static void ncsi_configure_channel(struct ncsi_dev_priv 
*ndp)
nca.package = np->id;
nca.channel = NCSI_RESERVED_CHANNEL;
ret = ncsi_xmit_cmd();
-   if (ret)
+   if (ret) {
+   netdev_err(ndp->ndev.dev,
+

[PATCH net-next 1/2] net/ncsi: Improve general state logging

2017-11-07 Thread Samuel Mendoza-Jonas
The NCSI driver is mostly silent which becomes a headache when trying to
determine what has occurred on the NCSI connection. This adds additional
logging in a few key areas such as state transitions and calling out
certain errors more visibly.

Signed-off-by: Samuel Mendoza-Jonas 
---
 net/ncsi/ncsi-aen.c| 15 +-
 net/ncsi/ncsi-manage.c | 76 +-
 net/ncsi/ncsi-rsp.c| 10 ++-
 3 files changed, 80 insertions(+), 21 deletions(-)

diff --git a/net/ncsi/ncsi-aen.c b/net/ncsi/ncsi-aen.c
index f135938bf781..67e708e98ccf 100644
--- a/net/ncsi/ncsi-aen.c
+++ b/net/ncsi/ncsi-aen.c
@@ -73,6 +73,9 @@ static int ncsi_aen_handler_lsc(struct ncsi_dev_priv *ndp,
ncm->data[2] = data;
ncm->data[4] = ntohl(lsc->oem_status);
 
+   netdev_info(ndp->ndev.dev, "NCSI: LSC AEN - channel %u state %s\n",
+   nc->id, data & 0x1 ? "up" : "down");
+
chained = !list_empty(>link);
state = nc->state;
spin_unlock_irqrestore(>lock, flags);
@@ -145,6 +148,8 @@ static int ncsi_aen_handler_hncdsc(struct ncsi_dev_priv 
*ndp,
ncm = >modes[NCSI_MODE_LINK];
hncdsc = (struct ncsi_aen_hncdsc_pkt *)h;
ncm->data[3] = ntohl(hncdsc->status);
+   netdev_info(ndp->ndev.dev, "NCSI: HNCDSC AEN - channel %u state %s\n",
+   nc->id, ncm->data[3] & 0x3 ? "up" : "down");
if (!list_empty(>link) ||
nc->state != NCSI_CHANNEL_ACTIVE) {
spin_unlock_irqrestore(>lock, flags);
@@ -212,10 +217,18 @@ int ncsi_aen_handler(struct ncsi_dev_priv *ndp, struct 
sk_buff *skb)
}
 
ret = ncsi_validate_aen_pkt(h, nah->payload);
-   if (ret)
+   if (ret) {
+   netdev_warn(ndp->ndev.dev,
+   "NCSI: 'bad' packet ignored for AEN type 0x%x\n",
+   h->type);
goto out;
+   }
 
ret = nah->handler(ndp, h);
+   if (ret)
+   netdev_err(ndp->ndev.dev,
+  "NCSI: Handler for AEN type 0x%x returned %d\n",
+  h->type, ret);
 out:
consume_skb(skb);
return ret;
diff --git a/net/ncsi/ncsi-manage.c b/net/ncsi/ncsi-manage.c
index 47baf914eec2..a2b904a718c6 100644
--- a/net/ncsi/ncsi-manage.c
+++ b/net/ncsi/ncsi-manage.c
@@ -229,6 +229,8 @@ static void ncsi_channel_monitor(unsigned long data)
case NCSI_CHANNEL_MONITOR_WAIT ... NCSI_CHANNEL_MONITOR_WAIT_MAX:
break;
default:
+   netdev_err(ndp->ndev.dev, "NCSI Channel %d timed out!\n",
+  nc->id);
if (!(ndp->flags & NCSI_DEV_HWA)) {
ncsi_report_link(ndp, true);
ndp->flags |= NCSI_DEV_RESHUFFLE;
@@ -682,7 +684,7 @@ static int clear_one_vid(struct ncsi_dev_priv *ndp, struct 
ncsi_channel *nc,
data = ncsi_get_filter(nc, NCSI_FILTER_VLAN, index);
if (!data) {
netdev_err(ndp->ndev.dev,
-  "ncsi: failed to retrieve filter %d\n", index);
+  "NCSI: failed to retrieve filter %d\n", index);
/* Set the VLAN id to 0 - this will still disable the entry in
 * the filter table, but we won't know what it was.
 */
@@ -692,7 +694,7 @@ static int clear_one_vid(struct ncsi_dev_priv *ndp, struct 
ncsi_channel *nc,
}
 
netdev_printk(KERN_DEBUG, ndp->ndev.dev,
- "ncsi: removed vlan tag %u at index %d\n",
+ "NCSI: removed vlan tag %u at index %d\n",
  vid, index + 1);
ncsi_remove_filter(nc, NCSI_FILTER_VLAN, index);
 
@@ -718,7 +720,7 @@ static int set_one_vid(struct ncsi_dev_priv *ndp, struct 
ncsi_channel *nc,
if (index < 0) {
/* New tag to add */
netdev_printk(KERN_DEBUG, ndp->ndev.dev,
- "ncsi: new vlan id to set: %u\n",
+ "NCSI: new vlan id to set: %u\n",
  vlan->vid);
break;
}
@@ -745,7 +747,7 @@ static int set_one_vid(struct ncsi_dev_priv *ndp, struct 
ncsi_channel *nc,
}
 
netdev_printk(KERN_DEBUG, ndp->ndev.dev,
- "ncsi: set vid %u in packet, index %u\n",
+ "NCSI: set vid %u in packet, index %u\n",
  vlan->vid, index + 1);
nca->type = NCSI_PKT_CMD_SVF;
nca->words[1] = vlan->vid;
@@ -784,8 +786,11 @@ static void ncsi_configure_channel(struct ncsi_dev_priv 
*ndp)
nca.package = np->id;
nca.channel = NCSI_RESERVED_CHANNEL;
ret = ncsi_xmit_cmd();
-   if (ret)
+   if (ret) {
+   netdev_err(ndp->ndev.dev,
+  "NCSI: Failed to