Skip to contentSkip to conversation

cxgb4: Common platform specific changes for DB Drop Recovery

PATCH Superseded Vipul Pandya 4 participants 8 messages Oct 20, 2011 – Feb 6, 2012 5 messages not in the archive

Subsystems (4)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 2/10 cxgb4: Common platform specific changes for DB Drop Recovery

- Add platform-specific callback functions for interrupts. This is needed to do a single read-clear of the CAUSE register and then call out to platform specific functions for DB threshold interrupts and DB drop interrupts.

- Add t4_mem_win_read_len() - mem-window reads for arbitrary lengths. This is used to read the CIDX/PIDX values from EC contexts during DB drop recovery.

- Add t4_fwaddrspace_write() - sends addrspace write cmds to the fw. Needed to flush the sge eq context cache.

---
Changes:
V2: Corrected the subject for patch.

 drivers/net/ethernet/chelsio/cxgb4/t4_hw.c    |   69 +++++++++++++++++++++----
 drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h |    5 ++
 2 files changed, 63 insertions(+), 11 deletions(-)
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c +58 -11
index 13609bf..32e1dd5 100644
@@ -868,11 +868,14 @@ int t4_restart_aneg(struct adapter *adap, unsigned int mbox, unsigned int port)
 	return t4_wr_mbox(adap, mbox, &c, sizeof(c), NULL);
 }
 
+typedef void (*int_handler_t)(struct adapter *adap);
+
 struct intr_info {
 	unsigned int mask;       /* bits to check in interrupt status */
 	const char *msg;         /* message to print or NULL */
 	short stat_idx;          /* stat counter to increment or -1 */
 	unsigned short fatal;    /* whether the condition reported is fatal */
+	int_handler_t int_handler; /* platform-specific int handler */
 };
 
 /**
@@ -905,6 +908,8 @@ static int t4_handle_intr_status(struct adapter *adapter, unsigned int reg,
 		} else if (acts->msg && printk_ratelimit())
 			dev_warn(adapter->pdev_dev, "%s (0x%x)\n", acts->msg,
 				 status & acts->mask);
+		if (acts->int_handler)
+			acts->int_handler(adapter);
 		mask |= acts->mask;
 	}
 	status &= mask;
@@ -1013,9 +1018,9 @@ static void sge_intr_handler(struct adapter *adapter)
 		{ ERR_INVALID_CIDX_INC,
 		  "SGE GTS CIDX increment too large", -1, 0 },
 		{ ERR_CPL_OPCODE_0, "SGE received 0-length CPL", -1, 0 },
-		{ F_DBFIFO_LP_INT, NULL, -1, 0 },
-		{ F_DBFIFO_HP_INT, NULL, -1, 0 },
-		{ ERR_DROPPED_DB, "SGE doorbell dropped", -1, 0 },
+		{ F_DBFIFO_LP_INT, NULL, -1, 0, t4_db_full },
+		{ F_DBFIFO_HP_INT, NULL, -1, 0, t4_db_full },
+		{ F_ERR_DROPPED_DB, NULL, -1, 0, t4_db_dropped },
 		{ ERR_DATA_CPL_ON_HIGH_QID1 | ERR_DATA_CPL_ON_HIGH_QID0,
 		  "SGE IQID > 1023 received CPL for FL", -1, 0 },
 		{ ERR_BAD_DB_PIDX3, "SGE DBP 3 pidx increment too large", -1,
@@ -1036,20 +1041,14 @@ static void sge_intr_handler(struct adapter *adapter)
 	};
 
 	v = (u64)t4_read_reg(adapter, SGE_INT_CAUSE1) |
-	    ((u64)t4_read_reg(adapter, SGE_INT_CAUSE2) << 32);
+		((u64)t4_read_reg(adapter, SGE_INT_CAUSE2) << 32);
 	if (v) {
 		dev_alert(adapter->pdev_dev, "SGE parity error (%#llx)\n",
-			 (unsigned long long)v);
+				(unsigned long long)v);
 		t4_write_reg(adapter, SGE_INT_CAUSE1, v);
 		t4_write_reg(adapter, SGE_INT_CAUSE2, v >> 32);
 	}
 
-	err = t4_read_reg(adapter, A_SGE_INT_CAUSE3);
-	if (err & (F_DBFIFO_HP_INT|F_DBFIFO_LP_INT))
-		t4_db_full(adapter);
-	if (err & F_ERR_DROPPED_DB)
-		t4_db_dropped(adapter);
-
 	if (t4_handle_intr_status(adapter, SGE_INT_CAUSE3, sge_intr_info) ||
 	    v != 0)
 		t4_fatal_err(adapter);
@@ -1995,6 +1994,54 @@ int t4_wol_pat_enable(struct adapter *adap, unsigned int port, unsigned int map,
 	(var).retval_len16 = htonl(FW_LEN16(var)); \
 } while (0)
 
+int t4_fwaddrspace_write(struct adapter *adap, unsigned int mbox,
+			  u32 addr, u32 val)
+{
+	struct fw_ldst_cmd c;
+
+	memset(&c, 0, sizeof(c));
+	c.op_to_addrspace = htonl(V_FW_CMD_OP(FW_LDST_CMD) | F_FW_CMD_REQUEST |
+			    F_FW_CMD_WRITE |
+			    V_FW_LDST_CMD_ADDRSPACE(FW_LDST_ADDRSPC_FIRMWARE));
+	c.cycles_to_len16 = htonl(FW_LEN16(c));
+	c.u.addrval.addr = htonl(addr);
+	c.u.addrval.val = htonl(val);
+
+	return t4_wr_mbox(adap, mbox, &c, sizeof(c), NULL);
+}
+
+/*
+ *     t4_mem_win_read_len - read memory through PCIE memory window
+ *     @adap: the adapter
+ *     @addr: address of first byte requested aligned on 32b.
+ *     @data: len bytes to hold the data read
+ *     @len: amount of data to read from window.  Must be <=
+ *            MEMWIN0_APERATURE after adjusting for 16B alignment
+ *            requirements of the the memory window.
+ *
+ *     Read len bytes of data from MC starting at @addr.
+ */
+int t4_mem_win_read_len(struct adapter *adap, u32 addr, __be32 *data, int len)
+{
+	int i;
+	int off;
+
+	/*
+	 * Align on a 16B boundary.
+	 */
+	off = addr & 15;
+	if ((addr & 3) || (len + off) > MEMWIN0_APERTURE)
+		return -EINVAL;
+
+	t4_write_reg(adap, A_PCIE_MEM_ACCESS_OFFSET, addr & ~15);
+	t4_read_reg(adap, A_PCIE_MEM_ACCESS_OFFSET);
+
+	for (i = 0; i < len; i += 4)
+		*data++ = t4_read_reg(adap, (MEMWIN0_BASE + off + i));
+
+	return 0;
+}
+
 /**
  *	t4_mdio_rd - read a PHY register through MDIO
  *	@adap: the adapter
drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h +5 -0
index edcfd7e..83ca454 100644
@@ -1620,4 +1620,9 @@ struct fw_hdr {
 #define FW_HDR_FW_VER_MINOR_GET(x) (((x) >> 16) & 0xff)
 #define FW_HDR_FW_VER_MICRO_GET(x) (((x) >> 8) & 0xff)
 #define FW_HDR_FW_VER_BUILD_GET(x) (((x) >> 0) & 0xff)
+
+int t4_mem_win_read_len(struct adapter *adap, u32 addr, __be32 *data, int len);
+int t4_fwaddrspace_write(struct adapter *adap, unsigned int mbox,
+			  u32 addr, u32 val);
+
 #endif /* _T4FW_INTERFACE_H_ */
Signature · 6 lines
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#1 lore raw

Don't add stuff to the t4fw_interface.h, that is owned by firmware.

Quoted 6 lines

-----Original Message-----
From: [email protected] [mailto:linux-rdma- [email protected]] On Behalf Of Vipul Pandya
Sent: Thursday, October 20, 2011 10:10 AM
To: [email protected]; [email protected]
Cc: [email protected]; [email protected]; Divy Le Ray;

Dimitrios

Quoted 2 lines

Michailidis; Kumar A S; Steve Wise; Vipul Pandya
Subject: [PATCH V2 02/10] cxgb4: Common platform specific changes for

DB

Quoted 3 lines

Drop Recovery

- Add platform-specific callback functions for interrupts. This

is

Quoted 1 line

needed to do a single read-clear of the CAUSE register and then

call

Quoted 1 line

out to platform specific functions for DB threshold interrupts and

DB

Quoted 3 lines

drop interrupts.

- Add t4_mem_win_read_len() - mem-window reads for arbitrary

lengths.

Quoted 1 line

This is used to read the CIDX/PIDX values from EC contexts during

DB

Quoted 3 lines

drop recovery.

- Add t4_fwaddrspace_write() - sends addrspace write cmds to the

fw.

drivers/net/ethernet/chelsio/cxgb4/t4_hw.c int t4_restart_aneg(struct adapter *adap,

Quoted 19 lines

Needed to flush the sge eq context cache.

---
Changes:
V2: Corrected the subject for patch.

 drivers/net/ethernet/chelsio/cxgb4/t4_hw.c    |   69
+++++++++++++++++++++----
 drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h |    5 ++
 2 files changed, 63 insertions(+), 11 deletions(-)
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c +0 -0
index 13609bf..32e1dd5 100644
@@ -868,11 +868,14 @@ int t4_restart_aneg(struct adapter *adap,

unsigned

drivers/net/ethernet/chelsio/cxgb4/t4_hw.c int t4_restart_aneg(struct adapter *adap, unsigned int mbox, unsigned int port)

Quoted 10 lines
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c +2 -0
 int mbox, unsigned int port)
 	return t4_wr_mbox(adap, mbox, &c, sizeof(c), NULL);  }
 
+typedef void (*int_handler_t)(struct adapter *adap);
+
 struct intr_info {
 	unsigned int mask;       /* bits to check in interrupt status */
 	const char *msg;         /* message to print or NULL */
 	short stat_idx;          /* stat counter to increment or -1 */
 	unsigned short fatal;    /* whether the condition reported is

fatal */

Quoted 16 lines
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c +3 -0
+	int_handler_t int_handler; /* platform-specific int handler */
 };
 
 /**
@@ -905,6 +908,8 @@ static int t4_handle_intr_status(struct adapter
 *adapter, unsigned int reg,
 		} else if (acts->msg && printk_ratelimit())
 			dev_warn(adapter->pdev_dev, "%s (0x%x)\n", acts-
 >msg,
 				 status & acts->mask);
+		if (acts->int_handler)
+			acts->int_handler(adapter);
 		mask |= acts->mask;
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c +0 -0
 	}
 	status &= mask;

drivers/net/ethernet/chelsio/cxgb4/t4_hw.c static void sge_intr_handler(struct adapter · line 1021

Quoted 4 lines
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c +0 -0
@@ -1013,9 +1018,9 @@ static void sge_intr_handler(struct adapter
 *adapter)
 		{ ERR_INVALID_CIDX_INC,
 		  "SGE GTS CIDX increment too large", -1, 0 },
 		{ ERR_CPL_OPCODE_0, "SGE received 0-length CPL", -1, 0

},

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

Quoted 10 lines
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c +3 -3
-		{ F_DBFIFO_LP_INT, NULL, -1, 0 },
-		{ F_DBFIFO_HP_INT, NULL, -1, 0 },
-		{ ERR_DROPPED_DB, "SGE doorbell dropped", -1, 0 },
+		{ F_DBFIFO_LP_INT, NULL, -1, 0, t4_db_full },
+		{ F_DBFIFO_HP_INT, NULL, -1, 0, t4_db_full },
+		{ F_ERR_DROPPED_DB, NULL, -1, 0, t4_db_dropped },
 		{ ERR_DATA_CPL_ON_HIGH_QID1 |
 ERR_DATA_CPL_ON_HIGH_QID0,
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c +0 -0
 		  "SGE IQID > 1023 received CPL for FL", -1, 0 },
 		{ ERR_BAD_DB_PIDX3, "SGE DBP 3 pidx increment too

large",

Quoted 1 line

-1, @@ -1036,20 +1041,14 @@ static void sge_intr_handler(struct

adapter

drivers/net/ethernet/chelsio/cxgb4/t4_hw.c static void sge_intr_handler(struct adapter *adapter)

Quoted 8 lines

*adapter)

drivers/net/ethernet/chelsio/cxgb4/t4_hw.c +1 -1
 	};
 
 	v = (u64)t4_read_reg(adapter, SGE_INT_CAUSE1) |
-	    ((u64)t4_read_reg(adapter, SGE_INT_CAUSE2) << 32);
+		((u64)t4_read_reg(adapter, SGE_INT_CAUSE2) << 32);
 	if (v) {
 		dev_alert(adapter->pdev_dev, "SGE parity error

(%#llx)\n",

drivers/net/ethernet/chelsio/cxgb4/t4_hw.c static void sge_intr_handler(struct adapter *adapter)

Quoted 13 lines
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c +1 -7
-			 (unsigned long long)v);
+				(unsigned long long)v);
 		t4_write_reg(adapter, SGE_INT_CAUSE1, v);
 		t4_write_reg(adapter, SGE_INT_CAUSE2, v >> 32);
 	}
 
-	err = t4_read_reg(adapter, A_SGE_INT_CAUSE3);
-	if (err & (F_DBFIFO_HP_INT|F_DBFIFO_LP_INT))
-		t4_db_full(adapter);
-	if (err & F_ERR_DROPPED_DB)
-		t4_db_dropped(adapter);
-
 	if (t4_handle_intr_status(adapter, SGE_INT_CAUSE3,

sge_intr_info)

Quoted 78 lines

||

drivers/net/ethernet/chelsio/cxgb4/t4_hw.c +7 -0
 	    v != 0)
 		t4_fatal_err(adapter);
@@ -1995,6 +1994,54 @@ int t4_wol_pat_enable(struct adapter *adap,
 unsigned int port, unsigned int map,
 	(var).retval_len16 = htonl(FW_LEN16(var)); \  } while (0)
 
+int t4_fwaddrspace_write(struct adapter *adap, unsigned int mbox,
+			  u32 addr, u32 val)
+{
+	struct fw_ldst_cmd c;
+
+	memset(&c, 0, sizeof(c));
+	c.op_to_addrspace = htonl(V_FW_CMD_OP(FW_LDST_CMD) |

F_FW_CMD_REQUEST |

drivers/net/ethernet/chelsio/cxgb4/t4_hw.c +2 -0
+			    F_FW_CMD_WRITE |
+

V_FW_LDST_CMD_ADDRSPACE(FW_LDST_ADDRSPC_FIRMWARE));

drivers/net/ethernet/chelsio/cxgb4/t4_hw.c +38 -0
+	c.cycles_to_len16 = htonl(FW_LEN16(c));
+	c.u.addrval.addr = htonl(addr);
+	c.u.addrval.val = htonl(val);
+
+	return t4_wr_mbox(adap, mbox, &c, sizeof(c), NULL); }
+
+/*
+ *     t4_mem_win_read_len - read memory through PCIE memory window
+ *     @adap: the adapter
+ *     @addr: address of first byte requested aligned on 32b.
+ *     @data: len bytes to hold the data read
+ *     @len: amount of data to read from window.  Must be <=
+ *            MEMWIN0_APERATURE after adjusting for 16B alignment
+ *            requirements of the the memory window.
+ *
+ *     Read len bytes of data from MC starting at @addr.
+ */
+int t4_mem_win_read_len(struct adapter *adap, u32 addr, __be32 *data,
+int len) {
+	int i;
+	int off;
+
+	/*
+	 * Align on a 16B boundary.
+	 */
+	off = addr & 15;
+	if ((addr & 3) || (len + off) > MEMWIN0_APERTURE)
+		return -EINVAL;
+
+	t4_write_reg(adap, A_PCIE_MEM_ACCESS_OFFSET, addr & ~15);
+	t4_read_reg(adap, A_PCIE_MEM_ACCESS_OFFSET);
+
+	for (i = 0; i < len; i += 4)
+		*data++ = t4_read_reg(adap, (MEMWIN0_BASE + off + i));
+
+	return 0;
+}
+
 /**
  *	t4_mdio_rd - read a PHY register through MDIO
  *	@adap: the adapter
drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h +0 -0
index edcfd7e..83ca454 100644
@@ -1620,4 +1620,9 @@ struct fw_hdr {
 #define FW_HDR_FW_VER_MINOR_GET(x) (((x) >> 16) & 0xff)  #define

FW_HDR_FW_VER_MICRO_GET(x) (((x) >> 8) & 0xff) #define FW_HDR_FW_VER_BUILD_GET(x) (((x) >> 0) & 0xff)

drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h +3 -0
+
+int t4_mem_win_read_len(struct adapter *adap, u32 addr, __be32 *data,
+int len); int t4_fwaddrspace_write(struct adapter *adap, unsigned int

mbox,

drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h +2 -1
+			  u32 addr, u32 val);
+
 #endif /* _T4FW_INTERFACE_H_ */
--

1.7.1

Quoted 2 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma"

in the

Quoted 2 lines

body of a message to [email protected] More majordomo info at
http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 8A71B368A89016469F72CD08050AD3340A3D3120-utt48SW1nMZEErodcbzraFjMPmZJtkid@public.gmane.org

A message that is not in the archive (sent off-list or not yet received): CAL1RGDXoeJNYz3R58bU-ixRyY1uKNgGPdUrWZ4nbcuyRDjL6Cg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#5 lore raw

Hi Roland,

Quoted 6 lines · Roland Dreier
Quoted 1 line · Felix Marti

Don't add stuff to the t4fw_interface.h, that is owned by firmware.

Vipul, do you plan to respin to handle Felix's comment?

- R.

Vipul is on leave, so replying on his behalf.

Vipul did a respin of this patch, and posted the V3 version. Its available here:
http://www.mail-archive.com/[email protected]/msg09659.html

Thanks,
Kumar.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 20111028182234.GA11554-ZuiPNEE88OINxtijsoNbcrBI9BrxbZE7QQ4Iyu8u01E@public.gmane.org

A message that is not in the archive (sent off-list or not yet received): CAL1RGDVQJUb2sM+Yo1sYVO5o-GhyBCOGo3_Q0U7YkR0GAoFgfg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#9 lore raw

Hi Roland,

This is just a gentle reminder to confirm if this patch series is going to get merge for 3.2?

Let us know if something is missing from our side since i don't see the patches yet in your infiniband tree's for-next branch.

Thanks,
Vipul

Quoted 7 lines · Roland Dreier
Quoted 3 lines

Vipul did a respin of this patch, and posted the V3 version. Its available here:
http://www.mail-archive.com/[email protected]/msg09659.html

Got it, thanks.

- R.

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#10 lore raw
In reply to a message not in the archive

Hi Roland,

Quoted 7 lines · Roland Dreier
Quoted 3 lines

Vipul did a respin of this patch, and posted the V3 version. Its available here:
http://www.mail-archive.com/[email protected]/msg09659.html

Got it, thanks.

- R.

Will this series be coming out with 3.3?
let me know if anything is required from my side.

Thanks,
Vipul Pandya
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): [email protected]

#12 lore raw
Quoted 2 lines · Vipul Pandya

Will this series be coming out with 3.3?
let me know if anything is required from my side.

No, this series is not in 3.3.

Sorry, but this kind of got lost in the shuffle.

Can you resend the series against the latest kernel, and explain again which parts are for net-next and which parts are for my RDMA tree?

- R.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html