Skip to content

Commit

Permalink
cxgb4: add support to read serial flash
Browse files Browse the repository at this point in the history
This patch adds support to dump flash memory via
ethtool --get-dump

Signed-off-by: Vishal Kulkarni <vishal@chelsio.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Vishal Kulkarni authored and David S. Miller committed Jun 19, 2020
1 parent d5002c9 commit 17b332f
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 2 deletions.
3 changes: 2 additions & 1 deletion drivers/net/ethernet/chelsio/cxgb4/cudbg_if.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ enum cudbg_dbg_entity_type {
CUDBG_HMA_INDIRECT = 67,
CUDBG_HMA = 68,
CUDBG_QDESC = 70,
CUDBG_MAX_ENTITY = 71,
CUDBG_FLASH = 71,
CUDBG_MAX_ENTITY = 72,
};

struct cudbg_init {
Expand Down
37 changes: 37 additions & 0 deletions drivers/net/ethernet/chelsio/cxgb4/cudbg_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -3156,3 +3156,40 @@ int cudbg_collect_qdesc(struct cudbg_init *pdbg_init,

return rc;
}

int cudbg_collect_flash(struct cudbg_init *pdbg_init,
struct cudbg_buffer *dbg_buff,
struct cudbg_error *cudbg_err)
{
struct adapter *padap = pdbg_init->adap;
u32 count = padap->params.sf_size, n;
struct cudbg_buffer temp_buff = {0};
u32 addr, i;
int rc;

addr = FLASH_EXP_ROM_START;

for (i = 0; i < count; i += SF_PAGE_SIZE) {
n = min_t(u32, count - i, SF_PAGE_SIZE);

rc = cudbg_get_buff(pdbg_init, dbg_buff, n, &temp_buff);
if (rc) {
cudbg_err->sys_warn = CUDBG_STATUS_PARTIAL_DATA;
goto out;
}
rc = t4_read_flash(padap, addr, n, (u32 *)temp_buff.data, 0);
if (rc)
goto out;

addr += (n * 4);
rc = cudbg_write_and_release_buff(pdbg_init, &temp_buff,
dbg_buff);
if (rc) {
cudbg_err->sys_warn = CUDBG_STATUS_PARTIAL_DATA;
goto out;
}
}

out:
return rc;
}
4 changes: 3 additions & 1 deletion drivers/net/ethernet/chelsio/cxgb4/cudbg_lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,9 @@ int cudbg_collect_hma_meminfo(struct cudbg_init *pdbg_init,
int cudbg_collect_qdesc(struct cudbg_init *pdbg_init,
struct cudbg_buffer *dbg_buff,
struct cudbg_error *cudbg_err);

int cudbg_collect_flash(struct cudbg_init *pdbg_init,
struct cudbg_buffer *dbg_buff,
struct cudbg_error *cudbg_err);
struct cudbg_entity_hdr *cudbg_get_entity_hdr(void *outbuf, int i);
void cudbg_align_debug_buffer(struct cudbg_buffer *dbg_buff,
struct cudbg_entity_hdr *entity_hdr);
Expand Down
14 changes: 14 additions & 0 deletions drivers/net/ethernet/chelsio/cxgb4/cxgb4_cudbg.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ static const struct cxgb4_collect_entity cxgb4_collect_hw_dump[] = {
{ CUDBG_HMA_INDIRECT, cudbg_collect_hma_indirect },
};

static const struct cxgb4_collect_entity cxgb4_collect_flash_dump[] = {
{ CUDBG_FLASH, cudbg_collect_flash },
};

static u32 cxgb4_get_entity_length(struct adapter *adap, u32 entity)
{
struct cudbg_tcam tcam_region = { 0 };
Expand Down Expand Up @@ -330,6 +334,9 @@ u32 cxgb4_get_dump_length(struct adapter *adap, u32 flag)
}
}

if (flag & CXGB4_ETH_DUMP_FLASH)
len += adap->params.sf_size;

/* If compression is enabled, a smaller destination buffer is enough */
wsize = cudbg_get_workspace_size();
if (wsize && len > CUDBG_DUMP_BUFF_SIZE)
Expand Down Expand Up @@ -468,6 +475,13 @@ int cxgb4_cudbg_collect(struct adapter *adap, void *buf, u32 *buf_size,
buf,
&total_size);

if (flag & CXGB4_ETH_DUMP_FLASH)
cxgb4_cudbg_collect_entity(&cudbg_init, &dbg_buff,
cxgb4_collect_flash_dump,
ARRAY_SIZE(cxgb4_collect_flash_dump),
buf,
&total_size);

cudbg_free_compress_buff(&cudbg_init);
cudbg_hdr->data_len = total_size;
if (cudbg_init.compress_type != CUDBG_COMPRESSION_NONE)
Expand Down
1 change: 1 addition & 0 deletions drivers/net/ethernet/chelsio/cxgb4/cxgb4_cudbg.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ enum CXGB4_ETHTOOL_DUMP_FLAGS {
CXGB4_ETH_DUMP_NONE = ETH_FW_DUMP_DISABLE,
CXGB4_ETH_DUMP_MEM = (1 << 0), /* On-Chip Memory Dumps */
CXGB4_ETH_DUMP_HW = (1 << 1), /* various FW and HW dumps */
CXGB4_ETH_DUMP_FLASH = (1 << 2), /* Dump flash memory */
};

#define CXGB4_ETH_DUMP_ALL (CXGB4_ETH_DUMP_MEM | CXGB4_ETH_DUMP_HW)
Expand Down

0 comments on commit 17b332f

Please sign in to comment.