aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/chelsio
diff options
context:
space:
mode:
authorSantosh Rastapur <santosh@chelsio.com>2013-03-14 01:08:53 -0400
committerDavid S. Miller <davem@davemloft.net>2013-03-14 11:35:55 -0400
commit19dd37ba45f1f0593a6d90eac3a861dad958f6bd (patch)
tree35908e0a5db27e793655d1954e4a044cc908d048 /drivers/net/ethernet/chelsio
parent2cc301d20f80ecf532754aad39e150f488acdcb7 (diff)
cxgb4: Add T5 debugfs support
Signed-off-by: Santosh Rastapur <santosh@chelsio.com> Signed-off-by: Vipul Pandya <vipul@chelsio.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/chelsio')
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/cxgb4.h3
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c55
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/t4_hw.c104
3 files changed, 119 insertions, 43 deletions
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
index f8ff30e749b0..45b18bdbeab9 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
@@ -908,7 +908,8 @@ int t4_config_rss_range(struct adapter *adapter, int mbox, unsigned int viid,
908 int start, int n, const u16 *rspq, unsigned int nrspq); 908 int start, int n, const u16 *rspq, unsigned int nrspq);
909int t4_config_glbl_rss(struct adapter *adapter, int mbox, unsigned int mode, 909int t4_config_glbl_rss(struct adapter *adapter, int mbox, unsigned int mode,
910 unsigned int flags); 910 unsigned int flags);
911int t4_mc_read(struct adapter *adap, u32 addr, __be32 *data, u64 *parity); 911int t4_mc_read(struct adapter *adap, int idx, u32 addr, __be32 *data,
912 u64 *parity);
912int t4_edc_read(struct adapter *adap, int idx, u32 addr, __be32 *data, 913int t4_edc_read(struct adapter *adap, int idx, u32 addr, __be32 *data,
913 u64 *parity); 914 u64 *parity);
914 915
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 177d0c199e01..ca8807080404 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -2843,8 +2843,8 @@ static ssize_t mem_read(struct file *file, char __user *buf, size_t count,
2843 int ret, ofst; 2843 int ret, ofst;
2844 __be32 data[16]; 2844 __be32 data[16];
2845 2845
2846 if (mem == MEM_MC) 2846 if ((mem == MEM_MC) || (mem == MEM_MC1))
2847 ret = t4_mc_read(adap, pos, data, NULL); 2847 ret = t4_mc_read(adap, mem % MEM_MC, pos, data, NULL);
2848 else 2848 else
2849 ret = t4_edc_read(adap, mem, pos, data, NULL); 2849 ret = t4_edc_read(adap, mem, pos, data, NULL);
2850 if (ret) 2850 if (ret)
@@ -2885,18 +2885,37 @@ static void add_debugfs_mem(struct adapter *adap, const char *name,
2885static int setup_debugfs(struct adapter *adap) 2885static int setup_debugfs(struct adapter *adap)
2886{ 2886{
2887 int i; 2887 int i;
2888 u32 size;
2888 2889
2889 if (IS_ERR_OR_NULL(adap->debugfs_root)) 2890 if (IS_ERR_OR_NULL(adap->debugfs_root))
2890 return -1; 2891 return -1;
2891 2892
2892 i = t4_read_reg(adap, MA_TARGET_MEM_ENABLE); 2893 i = t4_read_reg(adap, MA_TARGET_MEM_ENABLE);
2893 if (i & EDRAM0_ENABLE) 2894 if (i & EDRAM0_ENABLE) {
2894 add_debugfs_mem(adap, "edc0", MEM_EDC0, 5); 2895 size = t4_read_reg(adap, MA_EDRAM0_BAR);
2895 if (i & EDRAM1_ENABLE) 2896 add_debugfs_mem(adap, "edc0", MEM_EDC0, EDRAM_SIZE_GET(size));
2896 add_debugfs_mem(adap, "edc1", MEM_EDC1, 5); 2897 }
2897 if (i & EXT_MEM_ENABLE) 2898 if (i & EDRAM1_ENABLE) {
2898 add_debugfs_mem(adap, "mc", MEM_MC, 2899 size = t4_read_reg(adap, MA_EDRAM1_BAR);
2899 EXT_MEM_SIZE_GET(t4_read_reg(adap, MA_EXT_MEMORY_BAR))); 2900 add_debugfs_mem(adap, "edc1", MEM_EDC1, EDRAM_SIZE_GET(size));
2901 }
2902 if (is_t4(adap->chip)) {
2903 size = t4_read_reg(adap, MA_EXT_MEMORY_BAR);
2904 if (i & EXT_MEM_ENABLE)
2905 add_debugfs_mem(adap, "mc", MEM_MC,
2906 EXT_MEM_SIZE_GET(size));
2907 } else {
2908 if (i & EXT_MEM_ENABLE) {
2909 size = t4_read_reg(adap, MA_EXT_MEMORY_BAR);
2910 add_debugfs_mem(adap, "mc0", MEM_MC0,
2911 EXT_MEM_SIZE_GET(size));
2912 }
2913 if (i & EXT_MEM1_ENABLE) {
2914 size = t4_read_reg(adap, MA_EXT_MEMORY1_BAR);
2915 add_debugfs_mem(adap, "mc1", MEM_MC1,
2916 EXT_MEM_SIZE_GET(size));
2917 }
2918 }
2900 if (adap->l2t) 2919 if (adap->l2t)
2901 debugfs_create_file("l2t", S_IRUSR, adap->debugfs_root, adap, 2920 debugfs_create_file("l2t", S_IRUSR, adap->debugfs_root, adap,
2902 &t4_l2t_fops); 2921 &t4_l2t_fops);
@@ -4101,17 +4120,27 @@ void t4_fatal_err(struct adapter *adap)
4101 4120
4102static void setup_memwin(struct adapter *adap) 4121static void setup_memwin(struct adapter *adap)
4103{ 4122{
4104 u32 bar0; 4123 u32 bar0, mem_win0_base, mem_win1_base, mem_win2_base;
4105 4124
4106 bar0 = pci_resource_start(adap->pdev, 0); /* truncation intentional */ 4125 bar0 = pci_resource_start(adap->pdev, 0); /* truncation intentional */
4126 if (is_t4(adap->chip)) {
4127 mem_win0_base = bar0 + MEMWIN0_BASE;
4128 mem_win1_base = bar0 + MEMWIN1_BASE;
4129 mem_win2_base = bar0 + MEMWIN2_BASE;
4130 } else {
4131 /* For T5, only relative offset inside the PCIe BAR is passed */
4132 mem_win0_base = MEMWIN0_BASE;
4133 mem_win1_base = MEMWIN1_BASE_T5;
4134 mem_win2_base = MEMWIN2_BASE_T5;
4135 }
4107 t4_write_reg(adap, PCIE_MEM_ACCESS_REG(PCIE_MEM_ACCESS_BASE_WIN, 0), 4136 t4_write_reg(adap, PCIE_MEM_ACCESS_REG(PCIE_MEM_ACCESS_BASE_WIN, 0),
4108 (bar0 + MEMWIN0_BASE) | BIR(0) | 4137 mem_win0_base | BIR(0) |
4109 WINDOW(ilog2(MEMWIN0_APERTURE) - 10)); 4138 WINDOW(ilog2(MEMWIN0_APERTURE) - 10));
4110 t4_write_reg(adap, PCIE_MEM_ACCESS_REG(PCIE_MEM_ACCESS_BASE_WIN, 1), 4139 t4_write_reg(adap, PCIE_MEM_ACCESS_REG(PCIE_MEM_ACCESS_BASE_WIN, 1),
4111 (bar0 + MEMWIN1_BASE) | BIR(0) | 4140 mem_win1_base | BIR(0) |
4112 WINDOW(ilog2(MEMWIN1_APERTURE) - 10)); 4141 WINDOW(ilog2(MEMWIN1_APERTURE) - 10));
4113 t4_write_reg(adap, PCIE_MEM_ACCESS_REG(PCIE_MEM_ACCESS_BASE_WIN, 2), 4142 t4_write_reg(adap, PCIE_MEM_ACCESS_REG(PCIE_MEM_ACCESS_BASE_WIN, 2),
4114 (bar0 + MEMWIN2_BASE) | BIR(0) | 4143 mem_win2_base | BIR(0) |
4115 WINDOW(ilog2(MEMWIN2_APERTURE) - 10)); 4144 WINDOW(ilog2(MEMWIN2_APERTURE) - 10));
4116} 4145}
4117 4146
diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
index 229a3bfa5ba0..d02d4e8c4417 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
@@ -282,6 +282,7 @@ int t4_wr_mbox_meat(struct adapter *adap, int mbox, const void *cmd, int size,
282 * t4_mc_read - read from MC through backdoor accesses 282 * t4_mc_read - read from MC through backdoor accesses
283 * @adap: the adapter 283 * @adap: the adapter
284 * @addr: address of first byte requested 284 * @addr: address of first byte requested
285 * @idx: which MC to access
285 * @data: 64 bytes of data containing the requested address 286 * @data: 64 bytes of data containing the requested address
286 * @ecc: where to store the corresponding 64-bit ECC word 287 * @ecc: where to store the corresponding 64-bit ECC word
287 * 288 *
@@ -289,22 +290,38 @@ int t4_wr_mbox_meat(struct adapter *adap, int mbox, const void *cmd, int size,
289 * that covers the requested address @addr. If @parity is not %NULL it 290 * that covers the requested address @addr. If @parity is not %NULL it
290 * is assigned the 64-bit ECC word for the read data. 291 * is assigned the 64-bit ECC word for the read data.
291 */ 292 */
292int t4_mc_read(struct adapter *adap, u32 addr, __be32 *data, u64 *ecc) 293int t4_mc_read(struct adapter *adap, int idx, u32 addr, __be32 *data, u64 *ecc)
293{ 294{
294 int i; 295 int i;
296 u32 mc_bist_cmd, mc_bist_cmd_addr, mc_bist_cmd_len;
297 u32 mc_bist_status_rdata, mc_bist_data_pattern;
295 298
296 if (t4_read_reg(adap, MC_BIST_CMD) & START_BIST) 299 if (is_t4(adap->chip)) {
300 mc_bist_cmd = MC_BIST_CMD;
301 mc_bist_cmd_addr = MC_BIST_CMD_ADDR;
302 mc_bist_cmd_len = MC_BIST_CMD_LEN;
303 mc_bist_status_rdata = MC_BIST_STATUS_RDATA;
304 mc_bist_data_pattern = MC_BIST_DATA_PATTERN;
305 } else {
306 mc_bist_cmd = MC_REG(MC_P_BIST_CMD, idx);
307 mc_bist_cmd_addr = MC_REG(MC_P_BIST_CMD_ADDR, idx);
308 mc_bist_cmd_len = MC_REG(MC_P_BIST_CMD_LEN, idx);
309 mc_bist_status_rdata = MC_REG(MC_P_BIST_STATUS_RDATA, idx);
310 mc_bist_data_pattern = MC_REG(MC_P_BIST_DATA_PATTERN, idx);
311 }
312
313 if (t4_read_reg(adap, mc_bist_cmd) & START_BIST)
297 return -EBUSY; 314 return -EBUSY;
298 t4_write_reg(adap, MC_BIST_CMD_ADDR, addr & ~0x3fU); 315 t4_write_reg(adap, mc_bist_cmd_addr, addr & ~0x3fU);
299 t4_write_reg(adap, MC_BIST_CMD_LEN, 64); 316 t4_write_reg(adap, mc_bist_cmd_len, 64);
300 t4_write_reg(adap, MC_BIST_DATA_PATTERN, 0xc); 317 t4_write_reg(adap, mc_bist_data_pattern, 0xc);
301 t4_write_reg(adap, MC_BIST_CMD, BIST_OPCODE(1) | START_BIST | 318 t4_write_reg(adap, mc_bist_cmd, BIST_OPCODE(1) | START_BIST |
302 BIST_CMD_GAP(1)); 319 BIST_CMD_GAP(1));
303 i = t4_wait_op_done(adap, MC_BIST_CMD, START_BIST, 0, 10, 1); 320 i = t4_wait_op_done(adap, mc_bist_cmd, START_BIST, 0, 10, 1);
304 if (i) 321 if (i)
305 return i; 322 return i;
306 323
307#define MC_DATA(i) MC_BIST_STATUS_REG(MC_BIST_STATUS_RDATA, i) 324#define MC_DATA(i) MC_BIST_STATUS_REG(mc_bist_status_rdata, i)
308 325
309 for (i = 15; i >= 0; i--) 326 for (i = 15; i >= 0; i--)
310 *data++ = htonl(t4_read_reg(adap, MC_DATA(i))); 327 *data++ = htonl(t4_read_reg(adap, MC_DATA(i)));
@@ -329,20 +346,39 @@ int t4_mc_read(struct adapter *adap, u32 addr, __be32 *data, u64 *ecc)
329int t4_edc_read(struct adapter *adap, int idx, u32 addr, __be32 *data, u64 *ecc) 346int t4_edc_read(struct adapter *adap, int idx, u32 addr, __be32 *data, u64 *ecc)
330{ 347{
331 int i; 348 int i;
349 u32 edc_bist_cmd, edc_bist_cmd_addr, edc_bist_cmd_len;
350 u32 edc_bist_cmd_data_pattern, edc_bist_status_rdata;
332 351
333 idx *= EDC_STRIDE; 352 if (is_t4(adap->chip)) {
334 if (t4_read_reg(adap, EDC_BIST_CMD + idx) & START_BIST) 353 edc_bist_cmd = EDC_REG(EDC_BIST_CMD, idx);
354 edc_bist_cmd_addr = EDC_REG(EDC_BIST_CMD_ADDR, idx);
355 edc_bist_cmd_len = EDC_REG(EDC_BIST_CMD_LEN, idx);
356 edc_bist_cmd_data_pattern = EDC_REG(EDC_BIST_DATA_PATTERN,
357 idx);
358 edc_bist_status_rdata = EDC_REG(EDC_BIST_STATUS_RDATA,
359 idx);
360 } else {
361 edc_bist_cmd = EDC_REG_T5(EDC_H_BIST_CMD, idx);
362 edc_bist_cmd_addr = EDC_REG_T5(EDC_H_BIST_CMD_ADDR, idx);
363 edc_bist_cmd_len = EDC_REG_T5(EDC_H_BIST_CMD_LEN, idx);
364 edc_bist_cmd_data_pattern =
365 EDC_REG_T5(EDC_H_BIST_DATA_PATTERN, idx);
366 edc_bist_status_rdata =
367 EDC_REG_T5(EDC_H_BIST_STATUS_RDATA, idx);
368 }
369
370 if (t4_read_reg(adap, edc_bist_cmd) & START_BIST)
335 return -EBUSY; 371 return -EBUSY;
336 t4_write_reg(adap, EDC_BIST_CMD_ADDR + idx, addr & ~0x3fU); 372 t4_write_reg(adap, edc_bist_cmd_addr, addr & ~0x3fU);
337 t4_write_reg(adap, EDC_BIST_CMD_LEN + idx, 64); 373 t4_write_reg(adap, edc_bist_cmd_len, 64);
338 t4_write_reg(adap, EDC_BIST_DATA_PATTERN + idx, 0xc); 374 t4_write_reg(adap, edc_bist_cmd_data_pattern, 0xc);
339 t4_write_reg(adap, EDC_BIST_CMD + idx, 375 t4_write_reg(adap, edc_bist_cmd,
340 BIST_OPCODE(1) | BIST_CMD_GAP(1) | START_BIST); 376 BIST_OPCODE(1) | BIST_CMD_GAP(1) | START_BIST);
341 i = t4_wait_op_done(adap, EDC_BIST_CMD + idx, START_BIST, 0, 10, 1); 377 i = t4_wait_op_done(adap, edc_bist_cmd, START_BIST, 0, 10, 1);
342 if (i) 378 if (i)
343 return i; 379 return i;
344 380
345#define EDC_DATA(i) (EDC_BIST_STATUS_REG(EDC_BIST_STATUS_RDATA, i) + idx) 381#define EDC_DATA(i) (EDC_BIST_STATUS_REG(edc_bist_status_rdata, i))
346 382
347 for (i = 15; i >= 0; i--) 383 for (i = 15; i >= 0; i--)
348 *data++ = htonl(t4_read_reg(adap, EDC_DATA(i))); 384 *data++ = htonl(t4_read_reg(adap, EDC_DATA(i)));
@@ -366,6 +402,7 @@ int t4_edc_read(struct adapter *adap, int idx, u32 addr, __be32 *data, u64 *ecc)
366static int t4_mem_win_rw(struct adapter *adap, u32 addr, __be32 *data, int dir) 402static int t4_mem_win_rw(struct adapter *adap, u32 addr, __be32 *data, int dir)
367{ 403{
368 int i; 404 int i;
405 u32 win_pf = is_t4(adap->chip) ? 0 : V_PFNUM(adap->fn);
369 406
370 /* 407 /*
371 * Setup offset into PCIE memory window. Address must be a 408 * Setup offset into PCIE memory window. Address must be a
@@ -374,7 +411,7 @@ static int t4_mem_win_rw(struct adapter *adap, u32 addr, __be32 *data, int dir)
374 * values.) 411 * values.)
375 */ 412 */
376 t4_write_reg(adap, PCIE_MEM_ACCESS_OFFSET, 413 t4_write_reg(adap, PCIE_MEM_ACCESS_OFFSET,
377 addr & ~(MEMWIN0_APERTURE - 1)); 414 (addr & ~(MEMWIN0_APERTURE - 1)) | win_pf);
378 t4_read_reg(adap, PCIE_MEM_ACCESS_OFFSET); 415 t4_read_reg(adap, PCIE_MEM_ACCESS_OFFSET);
379 416
380 /* Collecting data 4 bytes at a time upto MEMWIN0_APERTURE */ 417 /* Collecting data 4 bytes at a time upto MEMWIN0_APERTURE */
@@ -410,6 +447,7 @@ static int t4_memory_rw(struct adapter *adap, int mtype, u32 addr, u32 len,
410 __be32 *buf, int dir) 447 __be32 *buf, int dir)
411{ 448{
412 u32 pos, start, end, offset, memoffset; 449 u32 pos, start, end, offset, memoffset;
450 u32 edc_size, mc_size;
413 int ret = 0; 451 int ret = 0;
414 __be32 *data; 452 __be32 *data;
415 453
@@ -423,13 +461,21 @@ static int t4_memory_rw(struct adapter *adap, int mtype, u32 addr, u32 len,
423 if (!data) 461 if (!data)
424 return -ENOMEM; 462 return -ENOMEM;
425 463
426 /* 464 /* Offset into the region of memory which is being accessed
427 * Offset into the region of memory which is being accessed
428 * MEM_EDC0 = 0 465 * MEM_EDC0 = 0
429 * MEM_EDC1 = 1 466 * MEM_EDC1 = 1
430 * MEM_MC = 2 467 * MEM_MC = 2 -- T4
468 * MEM_MC0 = 2 -- For T5
469 * MEM_MC1 = 3 -- For T5
431 */ 470 */
432 memoffset = (mtype * (5 * 1024 * 1024)); 471 edc_size = EDRAM_SIZE_GET(t4_read_reg(adap, MA_EDRAM0_BAR));
472 if (mtype != MEM_MC1)
473 memoffset = (mtype * (edc_size * 1024 * 1024));
474 else {
475 mc_size = EXT_MEM_SIZE_GET(t4_read_reg(adap,
476 MA_EXT_MEMORY_BAR));
477 memoffset = (MEM_MC0 * edc_size + mc_size) * 1024 * 1024;
478 }
433 479
434 /* Determine the PCIE_MEM_ACCESS_OFFSET */ 480 /* Determine the PCIE_MEM_ACCESS_OFFSET */
435 addr = addr + memoffset; 481 addr = addr + memoffset;
@@ -2411,24 +2457,24 @@ int t4_fwaddrspace_write(struct adapter *adap, unsigned int mbox,
2411 * @addr: address of first byte requested aligned on 32b. 2457 * @addr: address of first byte requested aligned on 32b.
2412 * @data: len bytes to hold the data read 2458 * @data: len bytes to hold the data read
2413 * @len: amount of data to read from window. Must be <= 2459 * @len: amount of data to read from window. Must be <=
2414 * MEMWIN0_APERATURE after adjusting for 16B alignment 2460 * MEMWIN0_APERATURE after adjusting for 16B for T4 and
2415 * requirements of the the memory window. 2461 * 128B for T5 alignment requirements of the the memory window.
2416 * 2462 *
2417 * Read len bytes of data from MC starting at @addr. 2463 * Read len bytes of data from MC starting at @addr.
2418 */ 2464 */
2419int t4_mem_win_read_len(struct adapter *adap, u32 addr, __be32 *data, int len) 2465int t4_mem_win_read_len(struct adapter *adap, u32 addr, __be32 *data, int len)
2420{ 2466{
2421 int i; 2467 int i, off;
2422 int off; 2468 u32 win_pf = is_t4(adap->chip) ? 0 : V_PFNUM(adap->fn);
2423 2469
2424 /* 2470 /* Align on a 2KB boundary.
2425 * Align on a 16B boundary.
2426 */ 2471 */
2427 off = addr & 15; 2472 off = addr & MEMWIN0_APERTURE;
2428 if ((addr & 3) || (len + off) > MEMWIN0_APERTURE) 2473 if ((addr & 3) || (len + off) > MEMWIN0_APERTURE)
2429 return -EINVAL; 2474 return -EINVAL;
2430 2475
2431 t4_write_reg(adap, PCIE_MEM_ACCESS_OFFSET, addr & ~15); 2476 t4_write_reg(adap, PCIE_MEM_ACCESS_OFFSET,
2477 (addr & ~MEMWIN0_APERTURE) | win_pf);
2432 t4_read_reg(adap, PCIE_MEM_ACCESS_OFFSET); 2478 t4_read_reg(adap, PCIE_MEM_ACCESS_OFFSET);
2433 2479
2434 for (i = 0; i < len; i += 4) 2480 for (i = 0; i < len; i += 4)