Skip to contentSkip to conversation

Improve NCSI driver logging

PATCH New Samuel Mendoza-Jonas 1 participant 3 messages Nov 8, 2017

Subsystems (2)
lore
Share & tools
lore

Samuel Mendoza-Jonas

author maintainer
#0 lore raw

v2 cover Improve NCSI driver logging

The NCSI driver has next to no logging at all, with some of the only useful logs actually coming from the ftgmac100 driver as link up/down messages.

Add a great deal more logging to the NCSI driver, tracking channel state and selection, link events, and so on. Patch 1 has no functional changes, and Patch 2 sends a Get-Parameters command during configuration to sanity check the current channel.

A form of this will go upstream (the log levels probably need some tweaking), but this iteration is being sent to OpenBMC to assist people currently debugging a few network issues in the ftgmac100/NCSI/Broadcom area.

v2:
Adjusted log levels (many down to KERN_DEBUG). Patch 2 is the source of most of the noise, and can probably be skipped - for upstream I'd intend to include it with a way to manually request that information rather than retrieve it on every configuration.

Samuel Mendoza-Jonas (2):
net/ncsi: General state debugging
net/ncsi: Query channel parameters during configuration

 net/ncsi/internal.h    |  1 +
 net/ncsi/ncsi-aen.c    | 15 +++++++++++++-
 net/ncsi/ncsi-manage.c | 56 +++++++++++++++++++++++++++++++++++++++++++-------
 net/ncsi/ncsi-rsp.c    | 33 ++++++++++++++++++++++++++++-
 4 files changed, 96 insertions(+), 9 deletions(-)
Signature · 1 line
2.14.3
author maintainer
#1 lore raw

PATCH v2 1/2 net/ncsi: General state debugging

While relatively noisy this helps to debug NCSI state transitions and the state of channels beyond the existing "down" or "up" messages that the driver currently has.

---
 net/ncsi/ncsi-aen.c    | 15 ++++++++++++++-
 net/ncsi/ncsi-manage.c | 52 +++++++++++++++++++++++++++++++++++++++++++-------
 net/ncsi/ncsi-rsp.c    | 10 +++++++++-
 3 files changed, 68 insertions(+), 9 deletions(-)
net/ncsi/ncsi-aen.c +14 -1
index f135938bf781..67e708e98ccf 100644
@@ -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(&nc->link);
 	state = nc->state;
 	spin_unlock_irqrestore(&nc->lock, flags);
@@ -145,6 +148,8 @@ static int ncsi_aen_handler_hncdsc(struct ncsi_dev_priv *ndp,
 	ncm = &nc->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(&nc->link) ||
 	    nc->state != NCSI_CHANNEL_ACTIVE) {
 		spin_unlock_irqrestore(&nc->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;
net/ncsi/ncsi-manage.c +45 -7

145 lines not on this page · raw message

net/ncsi/ncsi-rsp.c +9 -1
index 927dad4759d1..58186c4102f0 100644
@@ -1032,11 +1032,19 @@ int ncsi_rcv_rsp(struct sk_buff *skb, struct net_device *dev,
 	if (payload < 0)
 		payload = ntohs(hdr->length);
 	ret = ncsi_validate_rsp_pkt(nr, payload);
-	if (ret)
+	if (ret) {
+		netdev_warn(ndp->ndev.dev,
+			    "NCSI: 'bad' packet ignored for type 0x%x\n",
+			    hdr->type);
 		goto out;
+	}
 
 	/* Process the packet */
 	ret = nrh->handler(nr);
+	if (ret)
+		netdev_err(ndp->ndev.dev,
+			   "NCSI: Handler for packet type 0x%x returned %d\n",
+			   hdr->type, ret);
 out:
 	ncsi_free_request(nr);
 	return ret;
Signature · 1 line
2.14.3
author maintainer
#2 lore raw

PATCH v2 2/2 net/ncsi: Query channel parameters during configuration

In reply to Samuel Mendoza-Jonas

Send a Get-Parameters command during configuration to ensure the remote channel configuration reflects what we expect.

---
 net/ncsi/internal.h    |  1 +
 net/ncsi/ncsi-manage.c |  4 ++++
 net/ncsi/ncsi-rsp.c    | 23 +++++++++++++++++++++++
 3 files changed, 28 insertions(+)
net/ncsi/internal.h +1 -0
index d30f7bd741d0..d2ccc9a6ced1 100644
@@ -248,6 +248,7 @@ enum {
 	ncsi_dev_state_config_ec,
 	ncsi_dev_state_config_ae,
 	ncsi_dev_state_config_gls,
+	ncsi_dev_state_config_gp,
 	ncsi_dev_state_config_done,
 	ncsi_dev_state_suspend_select	= 0x0401,
 	ncsi_dev_state_suspend_gls,
net/ncsi/ncsi-manage.c +4 -0
index 97b76f26bde7..faab04625ccb 100644
@@ -807,6 +807,7 @@ static void ncsi_configure_channel(struct ncsi_dev_priv *ndp)
 	case ncsi_dev_state_config_ec:
 	case ncsi_dev_state_config_ae:
 	case ncsi_dev_state_config_gls:
+	case ncsi_dev_state_config_gp:
 		ndp->pending_req_num = 1;
 
 		nca.package = np->id;
@@ -884,6 +885,9 @@ static void ncsi_configure_channel(struct ncsi_dev_priv *ndp)
 			nd->state = ncsi_dev_state_config_gls;
 		} else if (nd->state == ncsi_dev_state_config_gls) {
 			nca.type = NCSI_PKT_CMD_GLS;
+			nd->state = ncsi_dev_state_config_gp;
+		} else if (nd->state == ncsi_dev_state_config_gp) {
+			nca.type = NCSI_PKT_CMD_GP;
 			nd->state = ncsi_dev_state_config_done;
 		}
 
net/ncsi/ncsi-rsp.c +23 -0
index 58186c4102f0..a7289c2d3870 100644
@@ -724,6 +724,17 @@ static int ncsi_rsp_handler_gp(struct ncsi_request *nr)
 	if (!nc)
 		return -ENODEV;
 
+	netdev_printk(KERN_DEBUG, ndp->ndev.dev,
+		      "NCSI: Channel %u Parameters:\n", nc->id);
+	netdev_printk(KERN_DEBUG, ndp->ndev.dev, "NCSI: Channel %s\n",
+		      ntohl(rsp->valid_modes) & 0x2 ? "enabled" : "disabled");
+	netdev_printk(KERN_DEBUG, ndp->ndev.dev, "NCSI: BPF %s\n",
+		      ntohl(rsp->valid_modes) & 0x1 ? "enabled" : "disabled");
+	netdev_printk(KERN_DEBUG, ndp->ndev.dev, "NCSI: TX %s\n",
+		      ntohl(rsp->valid_modes) & 0x4 ? "enabled" : "disabled");
+	netdev_printk(KERN_DEBUG, ndp->ndev.dev, "NCSI: MPF %s\n",
+		      ntohl(rsp->valid_modes) & 0x8 ? "enabled" : "disabled");
+
 	/* Modes with explicit enabled indications */
 	if (ntohl(rsp->valid_modes) & 0x1) {	/* BC filter mode */
 		nc->modes[NCSI_MODE_BC].enable = 1;
@@ -746,6 +757,18 @@ static int ncsi_rsp_handler_gp(struct ncsi_request *nr)
 	nc->modes[NCSI_MODE_AEN].enable = 1;
 	nc->modes[NCSI_MODE_AEN].data[0] = ntohl(rsp->aen_mode);
 
+	netdev_printk(KERN_DEBUG, ndp->ndev.dev, "NCSI: link settings %08x\n",
+		      ntohl(rsp->link_mode));
+	netdev_printk(KERN_DEBUG, ndp->ndev.dev,
+		      "NCSI: MAC address count %08x\n",
+		      rsp->mac_cnt);
+	netdev_printk(KERN_DEBUG, ndp->ndev.dev, "NCSI: MAC address 1 %s\n",
+		      rsp->mac_enable & 0x1 ? "enabled" : "disabled");
+	netdev_printk(KERN_DEBUG, ndp->ndev.dev,
+		      "NCSI: MAC address 1 %02x:%02x:%02x:%02x:%02x:%02x\n",
+		      rsp->mac[0], rsp->mac[1], rsp->mac[2],
+		      rsp->mac[3], rsp->mac[4], rsp->mac[5]);
+
 	/* MAC addresses filter table */
 	pdata = (unsigned char *)rsp + 48;
 	enable = rsp->mac_enable;
Signature · 1 line
2.14.3