Skip to contentSkip to conversation

Improve NCSI driver logging

PATCH Superseded Samuel Mendoza-Jonas 2 participants 5 messages Nov 6, 2017 – Nov 7, 2017

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Samuel Mendoza-Jonas

author maintainer
#0 lore raw

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.

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    | 34 ++++++++++++++++++---
 net/ncsi/ncsi-manage.c | 83 +++++++++++++++++++++++++++++++++++++++++++-------
 net/ncsi/ncsi-rsp.c    | 31 ++++++++++++++++++-
 4 files changed, 133 insertions(+), 16 deletions(-)
Signature · 1 line
2.14.3
author maintainer
#1 lore raw

PATCH 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    | 34 +++++++++++++++++++---
 net/ncsi/ncsi-manage.c | 79 +++++++++++++++++++++++++++++++++++++++++++-------
 net/ncsi/ncsi-rsp.c    | 10 ++++++-
 3 files changed, 107 insertions(+), 16 deletions(-)
net/ncsi/ncsi-aen.c +30 -4
index f135938bf781..7600db88fa95 100644
@@ -60,8 +60,10 @@ static int ncsi_aen_handler_lsc(struct ncsi_dev_priv *ndp,
 
 	/* Find the NCSI channel */
 	ncsi_find_package_and_channel(ndp, h->common.channel, NULL, &nc);
-	if (!nc)
+	if (!nc) {
+		netdev_err(ndp->ndev.dev, "NCSI: LSC - no channel!\n");
 		return -ENODEV;
+	}
 
 	/* Update the link status */
 	lsc = (struct ncsi_aen_lsc_pkt *)h;
@@ -73,6 +75,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 - 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);
@@ -103,12 +108,17 @@ static int ncsi_aen_handler_cr(struct ncsi_dev_priv *ndp,
 
 	/* Find the NCSI channel */
 	ncsi_find_package_and_channel(ndp, h->common.channel, NULL, &nc);
-	if (!nc)
+	if (!nc) {
+		netdev_err(ndp->ndev.dev, "NCSI: CR - no channel!\n");
 		return -ENODEV;
+	}
 
 	spin_lock_irqsave(&nc->lock, flags);
 	if (!list_empty(&nc->link) ||
 	    nc->state != NCSI_CHANNEL_ACTIVE) {
+		netdev_info(ndp->ndev.dev,
+			    "NCSI: CR - channel %u queued or not ACTIVE\n",
+			    nc->id);
 		spin_unlock_irqrestore(&nc->lock, flags);
 		return 0;
 	}
@@ -137,16 +147,23 @@ static int ncsi_aen_handler_hncdsc(struct ncsi_dev_priv *ndp,
 
 	/* Find the NCSI channel */
 	ncsi_find_package_and_channel(ndp, h->common.channel, NULL, &nc);
-	if (!nc)
+	if (!nc) {
+		netdev_err(ndp->ndev.dev, "NCSI: HNCDSC - no channel!\n");
 		return -ENODEV;
+	}
 
 	/* If the channel is active one, we need reconfigure it */
 	spin_lock_irqsave(&nc->lock, flags);
 	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 - channel %u state %s\n",
+		    nc->id, ncm->data[3] & 0x3 ? "up" : "down");
 	if (!list_empty(&nc->link) ||
 	    nc->state != NCSI_CHANNEL_ACTIVE) {
+		netdev_info(ndp->ndev.dev,
+			    "NCSI: HNCDSC - channel %u queued or not ACTIVE\n",
+			    nc->id);
 		spin_unlock_irqrestore(&nc->lock, flags);
 		return 0;
 	}
@@ -198,6 +215,7 @@ int ncsi_aen_handler(struct ncsi_dev_priv *ndp, struct sk_buff *skb)
 
 	/* Find the handler */
 	h = (struct ncsi_aen_pkt_hdr *)skb_network_header(skb);
+	netdev_info(ndp->ndev.dev, "NCSI: %s - type %u\n", __func__, h->type);
 	for (i = 0; i < ARRAY_SIZE(ncsi_aen_handlers); i++) {
 		if (ncsi_aen_handlers[i].type == h->type) {
 			nah = &ncsi_aen_handlers[i];
@@ -212,10 +230,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 +68 -11

207 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 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    | 21 +++++++++++++++++++++
 3 files changed, 26 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 6fd90415b2a2..2b8e3a102c45 100644
@@ -809,6 +809,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;
@@ -886,6 +887,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 +21 -0
index 58186c4102f0..b5446441b195 100644
@@ -724,6 +724,16 @@ static int ncsi_rsp_handler_gp(struct ncsi_request *nr)
 	if (!nc)
 		return -ENODEV;
 
+	netdev_info(ndp->ndev.dev, "NCSI: Channel %u Parameters:\n", nc->id);
+	netdev_info(ndp->ndev.dev, "NCSI: Channel %s\n",
+		    ntohl(rsp->valid_modes) & 0x2 ? "enabled" : "disabled");
+	netdev_info(ndp->ndev.dev, "NCSI: BPF %s\n",
+		    ntohl(rsp->valid_modes) & 0x1 ? "enabled" : "disabled");
+	netdev_info(ndp->ndev.dev, "NCSI: TX %s\n",
+		    ntohl(rsp->valid_modes) & 0x4 ? "enabled" : "disabled");
+	netdev_info(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 +756,17 @@ 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_info(ndp->ndev.dev, "NCSI: link settings %08x\n",
+		    ntohl(rsp->link_mode));
+	netdev_info(ndp->ndev.dev, "NCSI: MAC address count %08x\n",
+		    rsp->mac_cnt);
+	netdev_info(ndp->ndev.dev, "NCSI: MAC address 1 %s\n",
+		    rsp->mac_enable & 0x1 ? "enabled" : "disabled");
+	netdev_info(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
#3 lore raw
In reply to Samuel Mendoza-Jonas
Quoted 11 lines · Samuel Mendoza-Jonas

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.

Do you want this applied to the tree?

I don't see a reason not to post it upstream (independently of me applying it) as is.

Cheers,

Joel

author maintainer
#4 lore raw
Quoted 10 lines · Joel Stanley
Quoted 8 lines · Samuel Mendoza-Jonas

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.

Quoted 8 lines
Quoted 3 lines

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.

Do you want this applied to the tree?

I don't see a reason not to post it upstream (independently of me applying it) as is.

If you're happy to take it, yeah it will help debugging (or at least laying blame) immensely.

Agreed about upstream, but I'll revise a few of the log levels down to DEBUG/etc for that, and probably include it alongside some other fixes- to-be.

Cheers,
Sam

Quoted 4 lines

Cheers,

Joel