Skip to content

Commit a1c6952

Browse files
chelsiocudbgdavem330
authored andcommitted
cxgb4: collect MC memory dump
Use meminfo to get base address and size of MC memory. Also use same meminfo for EDC memory dumps. Signed-off-by: Rahul Lakkireddy <rahul.lakkireddy@chelsio.com> Signed-off-by: Ganesh Goudar <ganeshgr@chelsio.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 123e25c commit a1c6952

File tree

5 files changed

+108
-56
lines changed

5 files changed

+108
-56
lines changed

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

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,14 @@
1818
#ifndef __CUDBG_ENTITY_H__
1919
#define __CUDBG_ENTITY_H__
2020

21-
#define EDC0_FLAG 3
22-
#define EDC1_FLAG 4
21+
#define EDC0_FLAG 0
22+
#define EDC1_FLAG 1
23+
#define MC_FLAG 2
24+
#define MC0_FLAG 3
25+
#define MC1_FLAG 4
2326

2427
#define CUDBG_ENTITY_SIGNATURE 0xCCEDB001
2528

26-
struct card_mem {
27-
u16 size_edc0;
28-
u16 size_edc1;
29-
u16 mem_flag;
30-
};
31-
3229
struct cudbg_mbox_log {
3330
struct mbox_cmd entry;
3431
u32 hi[MBOX_LEN / 8];

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ enum cudbg_dbg_entity_type {
4747
CUDBG_CIM_OBQ_NCSI = 17,
4848
CUDBG_EDC0 = 18,
4949
CUDBG_EDC1 = 19,
50+
CUDBG_MC0 = 20,
51+
CUDBG_MC1 = 21,
5052
CUDBG_RSS = 22,
5153
CUDBG_RSS_VF_CONF = 25,
5254
CUDBG_PATH_MTU = 27,

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

Lines changed: 77 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -682,6 +682,42 @@ int cudbg_collect_obq_sge_rx_q1(struct cudbg_init *pdbg_init,
682682
return cudbg_read_cim_obq(pdbg_init, dbg_buff, cudbg_err, 7);
683683
}
684684

685+
static int cudbg_meminfo_get_mem_index(struct adapter *padap,
686+
struct cudbg_meminfo *mem_info,
687+
u8 mem_type, u8 *idx)
688+
{
689+
u8 i, flag;
690+
691+
switch (mem_type) {
692+
case MEM_EDC0:
693+
flag = EDC0_FLAG;
694+
break;
695+
case MEM_EDC1:
696+
flag = EDC1_FLAG;
697+
break;
698+
case MEM_MC0:
699+
/* Some T5 cards have both MC0 and MC1. */
700+
flag = is_t5(padap->params.chip) ? MC0_FLAG : MC_FLAG;
701+
break;
702+
case MEM_MC1:
703+
flag = MC1_FLAG;
704+
break;
705+
default:
706+
return CUDBG_STATUS_ENTITY_NOT_FOUND;
707+
}
708+
709+
for (i = 0; i < mem_info->avail_c; i++) {
710+
if (mem_info->avail[i].idx == flag) {
711+
*idx = i;
712+
return 0;
713+
}
714+
}
715+
716+
return CUDBG_STATUS_ENTITY_NOT_FOUND;
717+
}
718+
719+
#define CUDBG_YIELD_ITERATION 256
720+
685721
static int cudbg_read_fw_mem(struct cudbg_init *pdbg_init,
686722
struct cudbg_buffer *dbg_buff, u8 mem_type,
687723
unsigned long tot_len,
@@ -690,10 +726,20 @@ static int cudbg_read_fw_mem(struct cudbg_init *pdbg_init,
690726
unsigned long bytes, bytes_left, bytes_read = 0;
691727
struct adapter *padap = pdbg_init->adap;
692728
struct cudbg_buffer temp_buff = { 0 };
729+
u32 yield_count = 0;
693730
int rc = 0;
694731

695732
bytes_left = tot_len;
696733
while (bytes_left > 0) {
734+
/* As MC size is huge and read through PIO access, this
735+
* loop will hold cpu for a longer time. OS may think that
736+
* the process is hanged and will generate CPU stall traces.
737+
* So yield the cpu regularly.
738+
*/
739+
yield_count++;
740+
if (!(yield_count % CUDBG_YIELD_ITERATION))
741+
schedule();
742+
697743
bytes = min_t(unsigned long, bytes_left,
698744
(unsigned long)CUDBG_CHUNK_SIZE);
699745
rc = cudbg_get_buff(dbg_buff, bytes, &temp_buff);
@@ -717,27 +763,6 @@ static int cudbg_read_fw_mem(struct cudbg_init *pdbg_init,
717763
return rc;
718764
}
719765

720-
static void cudbg_collect_mem_info(struct cudbg_init *pdbg_init,
721-
struct card_mem *mem_info)
722-
{
723-
struct adapter *padap = pdbg_init->adap;
724-
u32 value;
725-
726-
value = t4_read_reg(padap, MA_EDRAM0_BAR_A);
727-
value = EDRAM0_SIZE_G(value);
728-
mem_info->size_edc0 = (u16)value;
729-
730-
value = t4_read_reg(padap, MA_EDRAM1_BAR_A);
731-
value = EDRAM1_SIZE_G(value);
732-
mem_info->size_edc1 = (u16)value;
733-
734-
value = t4_read_reg(padap, MA_TARGET_MEM_ENABLE_A);
735-
if (value & EDRAM0_ENABLE_F)
736-
mem_info->mem_flag |= (1 << EDC0_FLAG);
737-
if (value & EDRAM1_ENABLE_F)
738-
mem_info->mem_flag |= (1 << EDC1_FLAG);
739-
}
740-
741766
static void cudbg_t4_fwcache(struct cudbg_init *pdbg_init,
742767
struct cudbg_error *cudbg_err)
743768
{
@@ -757,37 +782,25 @@ static int cudbg_collect_mem_region(struct cudbg_init *pdbg_init,
757782
struct cudbg_error *cudbg_err,
758783
u8 mem_type)
759784
{
760-
struct card_mem mem_info = {0};
761-
unsigned long flag, size;
785+
struct adapter *padap = pdbg_init->adap;
786+
struct cudbg_meminfo mem_info;
787+
unsigned long size;
788+
u8 mc_idx;
762789
int rc;
763790

791+
memset(&mem_info, 0, sizeof(struct cudbg_meminfo));
792+
rc = cudbg_fill_meminfo(padap, &mem_info);
793+
if (rc)
794+
return rc;
795+
764796
cudbg_t4_fwcache(pdbg_init, cudbg_err);
765-
cudbg_collect_mem_info(pdbg_init, &mem_info);
766-
switch (mem_type) {
767-
case MEM_EDC0:
768-
flag = (1 << EDC0_FLAG);
769-
size = cudbg_mbytes_to_bytes(mem_info.size_edc0);
770-
break;
771-
case MEM_EDC1:
772-
flag = (1 << EDC1_FLAG);
773-
size = cudbg_mbytes_to_bytes(mem_info.size_edc1);
774-
break;
775-
default:
776-
rc = CUDBG_STATUS_ENTITY_NOT_FOUND;
777-
goto err;
778-
}
797+
rc = cudbg_meminfo_get_mem_index(padap, &mem_info, mem_type, &mc_idx);
798+
if (rc)
799+
return rc;
779800

780-
if (mem_info.mem_flag & flag) {
781-
rc = cudbg_read_fw_mem(pdbg_init, dbg_buff, mem_type,
782-
size, cudbg_err);
783-
if (rc)
784-
goto err;
785-
} else {
786-
rc = CUDBG_STATUS_ENTITY_NOT_FOUND;
787-
goto err;
788-
}
789-
err:
790-
return rc;
801+
size = mem_info.avail[mc_idx].limit - mem_info.avail[mc_idx].base;
802+
return cudbg_read_fw_mem(pdbg_init, dbg_buff, mem_type, size,
803+
cudbg_err);
791804
}
792805

793806
int cudbg_collect_edc0_meminfo(struct cudbg_init *pdbg_init,
@@ -806,6 +819,22 @@ int cudbg_collect_edc1_meminfo(struct cudbg_init *pdbg_init,
806819
MEM_EDC1);
807820
}
808821

822+
int cudbg_collect_mc0_meminfo(struct cudbg_init *pdbg_init,
823+
struct cudbg_buffer *dbg_buff,
824+
struct cudbg_error *cudbg_err)
825+
{
826+
return cudbg_collect_mem_region(pdbg_init, dbg_buff, cudbg_err,
827+
MEM_MC0);
828+
}
829+
830+
int cudbg_collect_mc1_meminfo(struct cudbg_init *pdbg_init,
831+
struct cudbg_buffer *dbg_buff,
832+
struct cudbg_error *cudbg_err)
833+
{
834+
return cudbg_collect_mem_region(pdbg_init, dbg_buff, cudbg_err,
835+
MEM_MC1);
836+
}
837+
809838
int cudbg_collect_rss(struct cudbg_init *pdbg_init,
810839
struct cudbg_buffer *dbg_buff,
811840
struct cudbg_error *cudbg_err)

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@ int cudbg_collect_edc0_meminfo(struct cudbg_init *pdbg_init,
7575
int cudbg_collect_edc1_meminfo(struct cudbg_init *pdbg_init,
7676
struct cudbg_buffer *dbg_buff,
7777
struct cudbg_error *cudbg_err);
78+
int cudbg_collect_mc0_meminfo(struct cudbg_init *pdbg_init,
79+
struct cudbg_buffer *dbg_buff,
80+
struct cudbg_error *cudbg_err);
81+
int cudbg_collect_mc1_meminfo(struct cudbg_init *pdbg_init,
82+
struct cudbg_buffer *dbg_buff,
83+
struct cudbg_error *cudbg_err);
7884
int cudbg_collect_rss(struct cudbg_init *pdbg_init,
7985
struct cudbg_buffer *dbg_buff,
8086
struct cudbg_error *cudbg_err);

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
static const struct cxgb4_collect_entity cxgb4_collect_mem_dump[] = {
2323
{ CUDBG_EDC0, cudbg_collect_edc0_meminfo },
2424
{ CUDBG_EDC1, cudbg_collect_edc1_meminfo },
25+
{ CUDBG_MC0, cudbg_collect_mc0_meminfo },
26+
{ CUDBG_MC1, cudbg_collect_mc1_meminfo },
2527
};
2628

2729
static const struct cxgb4_collect_entity cxgb4_collect_hw_dump[] = {
@@ -158,6 +160,22 @@ static u32 cxgb4_get_entity_length(struct adapter *adap, u32 entity)
158160
}
159161
len = cudbg_mbytes_to_bytes(len);
160162
break;
163+
case CUDBG_MC0:
164+
value = t4_read_reg(adap, MA_TARGET_MEM_ENABLE_A);
165+
if (value & EXT_MEM0_ENABLE_F) {
166+
value = t4_read_reg(adap, MA_EXT_MEMORY0_BAR_A);
167+
len = EXT_MEM0_SIZE_G(value);
168+
}
169+
len = cudbg_mbytes_to_bytes(len);
170+
break;
171+
case CUDBG_MC1:
172+
value = t4_read_reg(adap, MA_TARGET_MEM_ENABLE_A);
173+
if (value & EXT_MEM1_ENABLE_F) {
174+
value = t4_read_reg(adap, MA_EXT_MEMORY1_BAR_A);
175+
len = EXT_MEM1_SIZE_G(value);
176+
}
177+
len = cudbg_mbytes_to_bytes(len);
178+
break;
161179
case CUDBG_RSS:
162180
len = RSS_NENTRIES * sizeof(u16);
163181
break;

0 commit comments

Comments
 (0)