Commit 17b332f4 authored by Vishal Kulkarni's avatar Vishal Kulkarni Committed by David S. Miller
Browse files

cxgb4: add support to read serial flash



This patch adds support to dump flash memory via
ethtool --get-dump

Signed-off-by: default avatarVishal Kulkarni <vishal@chelsio.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent d5002c9a
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -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 {
+37 −0
Original line number Diff line number Diff line
@@ -3156,3 +3156,40 @@ out_free:

	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;
}
+3 −1
Original line number Diff line number Diff line
@@ -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);
+14 −0
Original line number Diff line number Diff line
@@ -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 };
@@ -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)
@@ -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)
+1 −0
Original line number Diff line number Diff line
@@ -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)