Skip to contentSkip to conversation

cxgb3: Drain Mac Tx fifo when the port goes down.

PATCH New Divy Le Ray 1 participant 8 messages Jul 8, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/8 cxgb3: Drain Mac Tx fifo when the port goes down.

From: Divy Le Ray <[email protected]>

Drain the MAC TX fifos when a port goes down. Back pressure might otherwise occur, leading to both ports of the same adapter to hang.

---

 drivers/net/cxgb3/cxgb3_main.c |   29 ++++++++++++++++++++++++++++-
 1 files changed, 28 insertions(+), 1 deletions(-)
drivers/net/cxgb3/cxgb3_main.c +28 -1
index 538dda4..ef59921 100644
@@ -172,6 +172,23 @@ static void link_report(struct net_device *dev)
 	}
 }
 
+static void enable_tx_fifo_drain(struct adapter *adapter,
+				 struct port_info *pi)
+{
+	t3_set_reg_field(adapter, A_XGM_TXFIFO_CFG + pi->mac.offset, 0,
+			 F_ENDROPPKT);
+	t3_write_reg(adapter, A_XGM_RX_CTRL + pi->mac.offset, 0);
+	t3_write_reg(adapter, A_XGM_TX_CTRL + pi->mac.offset, F_TXEN);
+	t3_write_reg(adapter, A_XGM_RX_CTRL + pi->mac.offset, F_RXEN);
+}
+
+static void disable_tx_fifo_drain(struct adapter *adapter,
+				  struct port_info *pi)
+{
+	t3_set_reg_field(adapter, A_XGM_TXFIFO_CFG + pi->mac.offset,
+			 F_ENDROPPKT, 0);
+}
+
 void t3_os_link_fault(struct adapter *adap, int port_id, int state)
 {
 	struct net_device *dev = adap->port[port_id];
@@ -185,6 +202,8 @@ void t3_os_link_fault(struct adapter *adap, int port_id, int state)
 
 		netif_carrier_on(dev);
 
+		disable_tx_fifo_drain(adap, pi);
+
 		/* Clear local faults */
 		t3_xgm_intr_disable(adap, pi->port_id);
 		t3_read_reg(adap, A_XGM_INT_STATUS +
@@ -200,9 +219,12 @@ void t3_os_link_fault(struct adapter *adap, int port_id, int state)
 		t3_xgm_intr_enable(adap, pi->port_id);
 
 		t3_mac_enable(mac, MAC_DIRECTION_TX);
-	} else
+	} else {
 		netif_carrier_off(dev);
 
+		/* Flush TX FIFO */
+		enable_tx_fifo_drain(adap, pi);
+	}
 	link_report(dev);
 }
 
@@ -232,6 +254,8 @@ void t3_os_link_changed(struct adapter *adapter, int port_id, int link_stat,
 
 	if (link_stat != netif_carrier_ok(dev)) {
 		if (link_stat) {
+			disable_tx_fifo_drain(adapter, pi);
+
 			t3_mac_enable(mac, MAC_DIRECTION_RX);
 
 			/* Clear local faults */
@@ -263,6 +287,9 @@ void t3_os_link_changed(struct adapter *adapter, int port_id, int link_stat,
 			t3_read_reg(adapter, A_XGM_INT_STATUS + pi->mac.offset);
 			t3_mac_disable(mac, MAC_DIRECTION_RX);
 			t3_link_start(&pi->phy, mac, &pi->link_config);
+
+			/* Flush TX FIFO */
+			enable_tx_fifo_drain(adapter, pi);
 		}
 
 		link_report(dev);
#1 lore raw

PATCH 2/8 cxgb3: Fix T3C MAC max packet size access

From: Divy Le Ray <[email protected]>

Max packet size is not the only field in T3C's High Water Mark register. Mask the register to access this field.

---

 drivers/net/cxgb3/xgmac.c |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)
drivers/net/cxgb3/xgmac.c +6 -5
index f87f943..0109ee4 100644
@@ -447,11 +447,12 @@ int t3_mac_set_speed_duplex_fc(struct cmac *mac, int speed, int duplex, int fc)
 
 	val = t3_read_reg(adap, A_XGM_RXFIFO_CFG + oft);
 	val &= ~V_RXFIFOPAUSEHWM(M_RXFIFOPAUSEHWM);
-	if (fc & PAUSE_TX)
-		val |= V_RXFIFOPAUSEHWM(rx_fifo_hwm(
-						t3_read_reg(adap,
-						A_XGM_RX_MAX_PKT_SIZE
-						+ oft)) / 8);
+	if (fc & PAUSE_TX) {
+		u32 rx_max_pkt_size =
+		    G_RXMAXPKTSIZE(t3_read_reg(adap,
+					       A_XGM_RX_MAX_PKT_SIZE + oft));
+		val |= V_RXFIFOPAUSEHWM(rx_fifo_hwm(rx_max_pkt_size) / 8);
+	}
 	t3_write_reg(adap, A_XGM_RXFIFO_CFG + oft, val);
 
 	t3_set_reg_field(adap, A_XGM_TX_CFG + oft, F_TXPAUSEEN,
#2 lore raw

PATCH 3/8 cxgb3: AEL2020 phy support update

In reply to Divy Le Ray

From: Divy Le Ray <[email protected]>

We don't always see the link status update interrupt when we come out of reset and the peer is up.
Check and report the link status right before enabling interrupts. Also fix LED settings, to get a consistent link status.

---

 drivers/net/cxgb3/adapter.h |    8 +++
 drivers/net/cxgb3/ael1002.c |  102 ++++++++++++++++++++++++++++++++-----------
 2 files changed, 83 insertions(+), 27 deletions(-)
drivers/net/cxgb3/adapter.h +8 -0
index 1694fad..bfa312d 100644
@@ -276,6 +276,14 @@ static inline struct port_info *adap2pinfo(struct adapter *adap, int idx)
 	return netdev_priv(adap->port[idx]);
 }
 
+static inline int phy2portid(struct cphy *phy)
+{
+	struct adapter *adap = phy->adapter;
+	struct port_info *port0 = adap2pinfo(adap, 0);
+
+	return &port0->phy == phy ? 0 : 1;
+}
+
 #define OFFLOAD_DEVMAP_BIT 15
 
 #define tdev2adap(d) container_of(d, struct adapter, tdev)
drivers/net/cxgb3/ael1002.c +75 -27

141 lines not on this page · raw message

#3 lore raw

PATCH 4/8 cxgb3: AQ100X phy support update

In reply to Divy Le Ray

From: Divy Le Ray <[email protected]>

Add missing SUPPORTED_TP flag.
Update FW version checking.
Do the full initialization even if the FW version is unknown, it might help catching further issues.

---

 drivers/net/cxgb3/aq100x.c |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)
drivers/net/cxgb3/aq100x.c +3 -4
index b1fd5bf..341b7ef 100644
@@ -271,7 +271,8 @@ int t3_aq100x_phy_prep(struct cphy *phy, struct adapter *adapter, int phy_addr,
 
 	cphy_init(phy, adapter, phy_addr, &aq100x_ops, mdio_ops,
 		  SUPPORTED_1000baseT_Full | SUPPORTED_10000baseT_Full |
-		  SUPPORTED_Autoneg | SUPPORTED_AUI, "1000/10GBASE-T");
+		  SUPPORTED_TP | SUPPORTED_Autoneg | SUPPORTED_AUI,
+		  "1000/10GBASE-T");
 
 	/*
 	 * The PHY has been out of reset ever since the system powered up.  So
@@ -316,11 +317,9 @@ int t3_aq100x_phy_prep(struct cphy *phy, struct adapter *adapter, int phy_addr,
 
 	/* Firmware version check. */
 	t3_mdio_read(phy, MDIO_MMD_VEND1, AQ_FW_VERSION, &v);
-	if (v != 30) {
+	if (v != 101)
 		CH_WARN(adapter, "PHY%d: unsupported firmware %d\n",
 			phy_addr, v);
-		return 0; /* allow t3_prep_adapter to succeed */
-	}
 
 	/*
 	 * The PHY should start in really-low-power mode.  Prepare it for normal
#4 lore raw

PATCH 5/8 cxgb3: fix phy power down

In reply to Divy Le Ray

From: Divy Le Ray <[email protected]>

2 phys are were not getting the Global Tx disable bit set when powered down, leading to an inconsistent link state on peer.

---

 drivers/net/cxgb3/ael1002.c |   10 ++--------
 1 files changed, 2 insertions(+), 8 deletions(-)
drivers/net/cxgb3/ael1002.c +2 -8
index 99e3e0f..66e47f7 100644
@@ -224,12 +224,6 @@ static int ael1006_reset(struct cphy *phy, int wait)
 	return t3_phy_reset(phy, MDIO_MMD_PMAPMD, wait);
 }
 
-static int ael1006_power_down(struct cphy *phy, int enable)
-{
-	return mdio_set_flag(&phy->mdio, phy->mdio.prtad, MDIO_MMD_PMAPMD,
-			     MDIO_CTRL1, MDIO_CTRL1_LPOWER, enable);
-}
-
 static struct cphy_ops ael1006_ops = {
 	.reset = ael1006_reset,
 	.intr_enable = t3_phy_lasi_intr_enable,
@@ -237,7 +231,7 @@ static struct cphy_ops ael1006_ops = {
 	.intr_clear = t3_phy_lasi_intr_clear,
 	.intr_handler = t3_phy_lasi_intr_handler,
 	.get_link_status = get_link_status_r,
-	.power_down = ael1006_power_down,
+	.power_down = ael1002_power_down,
 	.mmds = MDIO_DEVS_PMAPMD | MDIO_DEVS_PCS | MDIO_DEVS_PHYXS,
 };
 
@@ -1888,7 +1882,7 @@ static struct cphy_ops qt2045_ops = {
 	.intr_clear = t3_phy_lasi_intr_clear,
 	.intr_handler = t3_phy_lasi_intr_handler,
 	.get_link_status = get_link_status_x,
-	.power_down = ael1006_power_down,
+	.power_down = ael1002_power_down,
 	.mmds = MDIO_DEVS_PMAPMD | MDIO_DEVS_PCS | MDIO_DEVS_PHYXS,
 };
 
#5 lore raw

PATCH 6/8 cxgb3: Fix mss table initialization

In reply to Divy Le Ray

From: Divy Le Ray <[email protected]>

Fix the HW SMT table initialization to avoid random mss miscomputations for offload connections.

---

 drivers/net/cxgb3/cxgb3_main.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/net/cxgb3/cxgb3_main.c +1 -0
index ef59921..49fe46d 100644
@@ -470,6 +470,7 @@ static int init_tp_parity(struct adapter *adap)
 		memset(req, 0, sizeof(*req));
 		req->wr.wr_hi = htonl(V_WR_OP(FW_WROPCODE_FORWARD));
 		OPCODE_TID(req) = htonl(MK_OPCODE_TID(CPL_SMT_WRITE_REQ, i));
+		req->mtu_idx = NMTUS - 1;
 		req->iff = i;
 		t3_mgmt_tx(adap, skb);
 		if (skb == adap->nofail_skb) {
#6 lore raw

PATCH 7/8 cxgb3: fix mac index mapping

In reply to Divy Le Ray

From: Divy Le Ray <[email protected]>

Override the mac index computation for the gen2 adapter, as each port is expected to use index 0.

---

 drivers/net/cxgb3/t3_hw.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/net/cxgb3/t3_hw.c +2 -0
index 870d449..e78d341 100644
@@ -3682,6 +3682,8 @@ static void mc7_prep(struct adapter *adapter, struct mc7 *mc7,
 void mac_prep(struct cmac *mac, struct adapter *adapter, int index)
 {
 	mac->adapter = adapter;
+	if (!adapter->params.vpd.xauicfg[1])
+		index = 0;
 	mac->offset = (XGMAC0_1_BASE_ADDR - XGMAC0_0_BASE_ADDR) * index;
 	mac->nucast = 1;
 
#7 lore raw

PATCH 8/8 cxgb3: use request_firmware() for the EDC registers setup

In reply to Divy Le Ray

From: Divy Le Ray <[email protected]>

use request_firmware() to load the phy's EDC programmation

---

 drivers/net/cxgb3/adapter.h             |    2 
 drivers/net/cxgb3/ael1002.c             | 1081 +------------------------------
 drivers/net/cxgb3/common.h              |   10 
 drivers/net/cxgb3/cxgb3_main.c          |   69 ++
 firmware/Makefile                       |    5 
 firmware/WHENCE                         |   17 
 firmware/cxgb3/ael2005_opt_edc.bin.ihex |   69 ++
 firmware/cxgb3/ael2005_twx_edc.bin.ihex |   93 +++
 firmware/cxgb3/ael2020_twx_edc.bin.ihex |  100 +++
 9 files changed, 395 insertions(+), 1051 deletions(-)
 create mode 100644 firmware/cxgb3/ael2005_opt_edc.bin.ihex
 create mode 100644 firmware/cxgb3/ael2005_twx_edc.bin.ihex
 create mode 100644 firmware/cxgb3/ael2020_twx_edc.bin.ihex
drivers/net/cxgb3/adapter.h +2 -0
index bfa312d..74723f2 100644
@@ -320,4 +320,6 @@ int t3_get_desc(const struct sge_qset *qs, unsigned int qnum, unsigned int idx,
 		unsigned char *data);
 irqreturn_t t3_sge_intr_msix(int irq, void *cookie);
 
+int t3_get_edc_fw(struct cphy *phy, int edc_idx, int size);
+
 #endif				/* __T3_ADAPTER_H__ */
drivers/net/cxgb3/ael1002.c +31 -1050

1,117 lines not on this page · raw message

drivers/net/cxgb3/common.h +10 -0
index d21b705..1b2c305 100644
@@ -566,6 +566,15 @@ struct cphy_ops {
 
 	u32 mmds;
 };
+enum {
+	EDC_OPT_AEL2005 = 0,
+	EDC_OPT_AEL2005_SIZE = 1084,
+	EDC_TWX_AEL2005 = 1,
+	EDC_TWX_AEL2005_SIZE = 1464,
+	EDC_TWX_AEL2020 = 2,
+	EDC_TWX_AEL2020_SIZE = 1628,
+	EDC_MAX_SIZE = EDC_TWX_AEL2020_SIZE, /* Max cache size */
+};
 
 /* A PHY instance */
 struct cphy {
@@ -577,6 +586,7 @@ struct cphy {
 	unsigned long fifo_errors;	/* FIFO over/under-flows */
 	const struct cphy_ops *ops;	/* PHY operations */
 	struct mdio_if_info mdio;
+	u16 phy_cache[EDC_MAX_SIZE];	/* EDC cache */
 };
 
 /* Convenience MDIO read/write wrappers */
drivers/net/cxgb3/cxgb3_main.c +69 -0

75 lines not on this page · raw message

firmware/Makefile +4 -1
index 621de8e..44313b2 100644
@@ -41,7 +41,10 @@ fw-shipped-$(CONFIG_CASSINI) += sun/cassini.bin
 fw-shipped-$(CONFIG_COMPUTONE) += intelliport2.bin
 fw-shipped-$(CONFIG_CHELSIO_T3) += cxgb3/t3b_psram-1.1.0.bin \
 				   cxgb3/t3c_psram-1.1.0.bin \
-				   cxgb3/t3fw-7.4.0.bin
+				   cxgb3/t3fw-7.4.0.bin \
+				   cxgb3/ael2005_opt_edc.bin \
+				   cxgb3/ael2005_twx_edc.bin \
+				   cxgb3/ael2020_twx_edc.bin
 fw-shipped-$(CONFIG_DVB_AV7110) += av7110/bootcode.bin
 fw-shipped-$(CONFIG_DVB_TTUSB_BUDGET) += ttusb-budget/dspbootcode.bin
 fw-shipped-$(CONFIG_E100) += e100/d101m_ucode.bin e100/d101s_ucode.bin \
firmware/WHENCE +17 -0
index 0f5649a..d9e3a94 100644
@@ -418,6 +418,23 @@ License: GPLv2 or OpenIB.org BSD license, no source visible
 
 --------------------------------------------------------------------------
 
+Driver: cxgb3 - Chelsio Terminator 3 1G/10G Ethernet adapter
+
+File: cxgb3/ael2005_opt_edc.bin.ihex
+File: cxgb3/ael2005_twx_edc.bin.ihex
+File: cxgb3/ael2020_twx_edc.bin.ihex
+
+Licence:
+ *	Copyright (c) 2007-2009 NetLogic Microsystems, Inc.
+ *
+ *	Permission is hereby granted for the distribution of this firmware
+ *	data in hexadecimal or equivalent format, provided this copyright
+ *	notice is accompanying it.
+
+Found in hex form in kernel source.
+
+--------------------------------------------------------------------------
+
 Driver: e100 -- Intel PRO/100 Ethernet NIC
 
 File: e100/d101m_ucode.bin
firmware/cxgb3/ael2005_opt_edc.bin.ihex new file +69 -0

69 lines not on this page · raw message

firmware/cxgb3/ael2005_twx_edc.bin.ihex new file +93 -0

93 lines not on this page · raw message

firmware/cxgb3/ael2020_twx_edc.bin.ihex new file +100 -0

100 lines not on this page · raw message