Skip to content

Commit ddc7740

Browse files
Hariprasad Shenaidavem330
authored andcommitted
cxgb4: Decode link down reason code obtained from firmware
Signed-off-by: Hariprasad Shenai <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 23853a0 commit ddc7740

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

drivers/net/ethernet/chelsio/cxgb4/cxgb4.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,7 @@ struct link_config {
396396
unsigned char fc; /* actual link flow control */
397397
unsigned char autoneg; /* autonegotiating? */
398398
unsigned char link_ok; /* link up? */
399+
unsigned char link_down_rc; /* link down reason */
399400
};
400401

401402
#define FW_LEN16(fw_struct) FW_CMD_LEN16_V(sizeof(fw_struct) / 16)

drivers/net/ethernet/chelsio/cxgb4/t4_hw.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7102,6 +7102,32 @@ int t4_ofld_eq_free(struct adapter *adap, unsigned int mbox, unsigned int pf,
71027102
return t4_wr_mbox(adap, mbox, &c, sizeof(c), NULL);
71037103
}
71047104

7105+
/**
7106+
* t4_link_down_rc_str - return a string for a Link Down Reason Code
7107+
* @adap: the adapter
7108+
* @link_down_rc: Link Down Reason Code
7109+
*
7110+
* Returns a string representation of the Link Down Reason Code.
7111+
*/
7112+
static const char *t4_link_down_rc_str(unsigned char link_down_rc)
7113+
{
7114+
static const char * const reason[] = {
7115+
"Link Down",
7116+
"Remote Fault",
7117+
"Auto-negotiation Failure",
7118+
"Reserved",
7119+
"Insufficient Airflow",
7120+
"Unable To Determine Reason",
7121+
"No RX Signal Detected",
7122+
"Reserved",
7123+
};
7124+
7125+
if (link_down_rc >= ARRAY_SIZE(reason))
7126+
return "Bad Reason Code";
7127+
7128+
return reason[link_down_rc];
7129+
}
7130+
71057131
/**
71067132
* t4_handle_get_port_info - process a FW reply message
71077133
* @pi: the port info
@@ -7142,6 +7168,14 @@ void t4_handle_get_port_info(struct port_info *pi, const __be64 *rpl)
71427168
}
71437169
if (link_ok != lc->link_ok || speed != lc->speed ||
71447170
fc != lc->fc) { /* something changed */
7171+
if (!link_ok && lc->link_ok) {
7172+
unsigned char rc = FW_PORT_CMD_LINKDNRC_G(stat);
7173+
7174+
lc->link_down_rc = rc;
7175+
dev_warn(adap->pdev_dev,
7176+
"Port %d link down, reason: %s\n",
7177+
pi->port_id, t4_link_down_rc_str(rc));
7178+
}
71457179
lc->link_ok = link_ok;
71467180
lc->speed = speed;
71477181
lc->fc = fc;

drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2510,6 +2510,11 @@ struct fw_port_cmd {
25102510
#define FW_PORT_CMD_PTYPE_G(x) \
25112511
(((x) >> FW_PORT_CMD_PTYPE_S) & FW_PORT_CMD_PTYPE_M)
25122512

2513+
#define FW_PORT_CMD_LINKDNRC_S 5
2514+
#define FW_PORT_CMD_LINKDNRC_M 0x7
2515+
#define FW_PORT_CMD_LINKDNRC_G(x) \
2516+
(((x) >> FW_PORT_CMD_LINKDNRC_S) & FW_PORT_CMD_LINKDNRC_M)
2517+
25132518
#define FW_PORT_CMD_MODTYPE_S 0
25142519
#define FW_PORT_CMD_MODTYPE_M 0x1f
25152520
#define FW_PORT_CMD_MODTYPE_V(x) ((x) << FW_PORT_CMD_MODTYPE_S)

0 commit comments

Comments
 (0)