Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 9 May 2017 08:08:29 +0000 (UTC)
From:      Navdeep Parhar <np@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r318014 - head/sys/dev/cxgbe
Message-ID:  <201705090808.v4988TG7023305@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: np
Date: Tue May  9 08:08:28 2017
New Revision: 318014
URL: https://svnweb.freebsd.org/changeset/base/318014

Log:
  cxgbe(4): Fixes related to the knob that controls link autonegotiation.
  
  - Do not leak the adapter lock in sysctl_autoneg.
  - Accept only 0 or 1 as valid settings for autonegotiation.
  - A fixed speed must be requested by the driver when autonegotiation is
    disabled otherwise the firmware will reject the l1cfg command.  Use
    the top speed supported by the port for now.
  
  MFC after:	3 days
  Sponsored by:	Chelsio Communications

Modified:
  head/sys/dev/cxgbe/adapter.h
  head/sys/dev/cxgbe/t4_main.c

Modified: head/sys/dev/cxgbe/adapter.h
==============================================================================
--- head/sys/dev/cxgbe/adapter.h	Tue May  9 05:32:35 2017	(r318013)
+++ head/sys/dev/cxgbe/adapter.h	Tue May  9 08:08:28 2017	(r318014)
@@ -1086,6 +1086,24 @@ port_top_speed(const struct port_info *p
 }
 
 static inline int
+port_top_speed_raw(const struct port_info *pi)
+{
+
+	if (pi->link_cfg.supported & FW_PORT_CAP_SPEED_100G)
+		return (FW_PORT_CAP_SPEED_100G);
+	if (pi->link_cfg.supported & FW_PORT_CAP_SPEED_40G)
+		return (FW_PORT_CAP_SPEED_40G);
+	if (pi->link_cfg.supported & FW_PORT_CAP_SPEED_25G)
+		return (FW_PORT_CAP_SPEED_25G);
+	if (pi->link_cfg.supported & FW_PORT_CAP_SPEED_10G)
+		return (FW_PORT_CAP_SPEED_10G);
+	if (pi->link_cfg.supported & FW_PORT_CAP_SPEED_1G)
+		return (FW_PORT_CAP_SPEED_1G);
+
+	return (0);
+}
+
+static inline int
 tx_resume_threshold(struct sge_eq *eq)
 {
 

Modified: head/sys/dev/cxgbe/t4_main.c
==============================================================================
--- head/sys/dev/cxgbe/t4_main.c	Tue May  9 05:32:35 2017	(r318013)
+++ head/sys/dev/cxgbe/t4_main.c	Tue May  9 08:08:28 2017	(r318014)
@@ -995,6 +995,7 @@ t4_attach(device_t dev)
 			lc->autoneg = t4_autoneg ? AUTONEG_ENABLE :
 			    AUTONEG_DISABLE;
 		}
+		lc->requested_speed = port_top_speed_raw(pi);
 
 		rc = -t4_link_l1cfg(sc, sc->mbox, pi->tx_chan, lc);
 		if (rc != 0) {
@@ -5883,7 +5884,12 @@ sysctl_autoneg(SYSCTL_HANDLER_ARGS)
 	if ((lc->supported & FW_PORT_CAP_ANEG) == 0)
 		return (ENOTSUP);
 
-	val = val ? AUTONEG_ENABLE : AUTONEG_DISABLE;
+	if (val == 0)
+		val = AUTONEG_DISABLE;
+	else if (val == 1)
+		val = AUTONEG_ENABLE;
+	else
+		return (EINVAL);
 	if (lc->autoneg == val)
 		return (0);	/* no change */
 
@@ -5896,6 +5902,7 @@ sysctl_autoneg(SYSCTL_HANDLER_ARGS)
 	rc = -t4_link_l1cfg(sc, sc->mbox, pi->tx_chan, lc);
 	if (rc != 0)
 		lc->autoneg = old;
+	end_synchronized_op(sc, 0);
 	return (rc);
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201705090808.v4988TG7023305>