Skip to content

Commit 7cc373d

Browse files
committed
Merge branch 'cxgb4-add-support-to-read-write-flash'
Vishal Kulkarni says: ==================== cxgb4: add support to read/write flash This series of patches adds support to read/write different binary images of serial flash present in Chelsio terminator. V2 changes: Patch 1: No change Patch 2: No change Patch 3: Fix 4 compilation warnings reported by C=1, W=1 flags Patch 4: No change Patch 5: No change ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents 0fb9fba + 17b332f commit 7cc373d

9 files changed

Lines changed: 637 additions & 16 deletions

File tree

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ enum cudbg_dbg_entity_type {
7070
CUDBG_HMA_INDIRECT = 67,
7171
CUDBG_HMA = 68,
7272
CUDBG_QDESC = 70,
73-
CUDBG_MAX_ENTITY = 71,
73+
CUDBG_FLASH = 71,
74+
CUDBG_MAX_ENTITY = 72,
7475
};
7576

7677
struct cudbg_init {

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

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3156,3 +3156,40 @@ int cudbg_collect_qdesc(struct cudbg_init *pdbg_init,
31563156

31573157
return rc;
31583158
}
3159+
3160+
int cudbg_collect_flash(struct cudbg_init *pdbg_init,
3161+
struct cudbg_buffer *dbg_buff,
3162+
struct cudbg_error *cudbg_err)
3163+
{
3164+
struct adapter *padap = pdbg_init->adap;
3165+
u32 count = padap->params.sf_size, n;
3166+
struct cudbg_buffer temp_buff = {0};
3167+
u32 addr, i;
3168+
int rc;
3169+
3170+
addr = FLASH_EXP_ROM_START;
3171+
3172+
for (i = 0; i < count; i += SF_PAGE_SIZE) {
3173+
n = min_t(u32, count - i, SF_PAGE_SIZE);
3174+
3175+
rc = cudbg_get_buff(pdbg_init, dbg_buff, n, &temp_buff);
3176+
if (rc) {
3177+
cudbg_err->sys_warn = CUDBG_STATUS_PARTIAL_DATA;
3178+
goto out;
3179+
}
3180+
rc = t4_read_flash(padap, addr, n, (u32 *)temp_buff.data, 0);
3181+
if (rc)
3182+
goto out;
3183+
3184+
addr += (n * 4);
3185+
rc = cudbg_write_and_release_buff(pdbg_init, &temp_buff,
3186+
dbg_buff);
3187+
if (rc) {
3188+
cudbg_err->sys_warn = CUDBG_STATUS_PARTIAL_DATA;
3189+
goto out;
3190+
}
3191+
}
3192+
3193+
out:
3194+
return rc;
3195+
}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,9 @@ int cudbg_collect_hma_meminfo(struct cudbg_init *pdbg_init,
162162
int cudbg_collect_qdesc(struct cudbg_init *pdbg_init,
163163
struct cudbg_buffer *dbg_buff,
164164
struct cudbg_error *cudbg_err);
165-
165+
int cudbg_collect_flash(struct cudbg_init *pdbg_init,
166+
struct cudbg_buffer *dbg_buff,
167+
struct cudbg_error *cudbg_err);
166168
struct cudbg_entity_hdr *cudbg_get_entity_hdr(void *outbuf, int i);
167169
void cudbg_align_debug_buffer(struct cudbg_buffer *dbg_buff,
168170
struct cudbg_entity_hdr *entity_hdr);

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

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,64 @@ enum cc_fec {
139139
FEC_BASER_RS = 1 << 2 /* BaseR/Reed-Solomon */
140140
};
141141

142+
enum {
143+
CXGB4_ETHTOOL_FLASH_FW = 1,
144+
CXGB4_ETHTOOL_FLASH_PHY = 2,
145+
CXGB4_ETHTOOL_FLASH_BOOT = 3,
146+
CXGB4_ETHTOOL_FLASH_BOOTCFG = 4
147+
};
148+
149+
struct cxgb4_bootcfg_data {
150+
__le16 signature;
151+
__u8 reserved[2];
152+
};
153+
154+
struct cxgb4_pcir_data {
155+
__le32 signature; /* Signature. The string "PCIR" */
156+
__le16 vendor_id; /* Vendor Identification */
157+
__le16 device_id; /* Device Identification */
158+
__u8 vital_product[2]; /* Pointer to Vital Product Data */
159+
__u8 length[2]; /* PCIR Data Structure Length */
160+
__u8 revision; /* PCIR Data Structure Revision */
161+
__u8 class_code[3]; /* Class Code */
162+
__u8 image_length[2]; /* Image Length. Multiple of 512B */
163+
__u8 code_revision[2]; /* Revision Level of Code/Data */
164+
__u8 code_type;
165+
__u8 indicator;
166+
__u8 reserved[2];
167+
};
168+
169+
/* BIOS boot headers */
170+
struct cxgb4_pci_exp_rom_header {
171+
__le16 signature; /* ROM Signature. Should be 0xaa55 */
172+
__u8 reserved[22]; /* Reserved per processor Architecture data */
173+
__le16 pcir_offset; /* Offset to PCI Data Structure */
174+
};
175+
176+
/* Legacy PCI Expansion ROM Header */
177+
struct legacy_pci_rom_hdr {
178+
__u8 signature[2]; /* ROM Signature. Should be 0xaa55 */
179+
__u8 size512; /* Current Image Size in units of 512 bytes */
180+
__u8 initentry_point[4];
181+
__u8 cksum; /* Checksum computed on the entire Image */
182+
__u8 reserved[16]; /* Reserved */
183+
__le16 pcir_offset; /* Offset to PCI Data Struture */
184+
};
185+
186+
#define CXGB4_HDR_CODE1 0x00
187+
#define CXGB4_HDR_CODE2 0x03
188+
#define CXGB4_HDR_INDI 0x80
189+
190+
/* BOOT constants */
191+
enum {
192+
BOOT_CFG_SIG = 0x4243,
193+
BOOT_SIZE_INC = 512,
194+
BOOT_SIGNATURE = 0xaa55,
195+
BOOT_MIN_SIZE = sizeof(struct cxgb4_pci_exp_rom_header),
196+
BOOT_MAX_SIZE = 1024 * BOOT_SIZE_INC,
197+
PCIR_SIGNATURE = 0x52494350
198+
};
199+
142200
struct port_stats {
143201
u64 tx_octets; /* total # of octets in good frames */
144202
u64 tx_frames; /* all good frames */
@@ -492,6 +550,11 @@ struct trace_params {
492550
unsigned char port;
493551
};
494552

553+
struct cxgb4_fw_data {
554+
__be32 signature;
555+
__u8 reserved[4];
556+
};
557+
495558
/* Firmware Port Capabilities types. */
496559

497560
typedef u16 fw_port_cap16_t; /* 16-bit Port Capabilities integral value */
@@ -1988,6 +2051,10 @@ void t4_register_netevent_notifier(void);
19882051
int t4_i2c_rd(struct adapter *adap, unsigned int mbox, int port,
19892052
unsigned int devid, unsigned int offset,
19902053
unsigned int len, u8 *buf);
2054+
int t4_load_boot(struct adapter *adap, u8 *boot_data,
2055+
unsigned int boot_addr, unsigned int size);
2056+
int t4_load_bootcfg(struct adapter *adap,
2057+
const u8 *cfg_data, unsigned int size);
19912058
void free_rspq_fl(struct adapter *adap, struct sge_rspq *rq, struct sge_fl *fl);
19922059
void free_tx_desc(struct adapter *adap, struct sge_txq *q,
19932060
unsigned int n, bool unmap);

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ static const struct cxgb4_collect_entity cxgb4_collect_hw_dump[] = {
6666
{ CUDBG_HMA_INDIRECT, cudbg_collect_hma_indirect },
6767
};
6868

69+
static const struct cxgb4_collect_entity cxgb4_collect_flash_dump[] = {
70+
{ CUDBG_FLASH, cudbg_collect_flash },
71+
};
72+
6973
static u32 cxgb4_get_entity_length(struct adapter *adap, u32 entity)
7074
{
7175
struct cudbg_tcam tcam_region = { 0 };
@@ -330,6 +334,9 @@ u32 cxgb4_get_dump_length(struct adapter *adap, u32 flag)
330334
}
331335
}
332336

337+
if (flag & CXGB4_ETH_DUMP_FLASH)
338+
len += adap->params.sf_size;
339+
333340
/* If compression is enabled, a smaller destination buffer is enough */
334341
wsize = cudbg_get_workspace_size();
335342
if (wsize && len > CUDBG_DUMP_BUFF_SIZE)
@@ -468,6 +475,13 @@ int cxgb4_cudbg_collect(struct adapter *adap, void *buf, u32 *buf_size,
468475
buf,
469476
&total_size);
470477

478+
if (flag & CXGB4_ETH_DUMP_FLASH)
479+
cxgb4_cudbg_collect_entity(&cudbg_init, &dbg_buff,
480+
cxgb4_collect_flash_dump,
481+
ARRAY_SIZE(cxgb4_collect_flash_dump),
482+
buf,
483+
&total_size);
484+
471485
cudbg_free_compress_buff(&cudbg_init);
472486
cudbg_hdr->data_len = total_size;
473487
if (cudbg_init.compress_type != CUDBG_COMPRESSION_NONE)

‎drivers/net/ethernet/chelsio/cxgb4/cxgb4_cudbg.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ enum CXGB4_ETHTOOL_DUMP_FLAGS {
2727
CXGB4_ETH_DUMP_NONE = ETH_FW_DUMP_DISABLE,
2828
CXGB4_ETH_DUMP_MEM = (1 << 0), /* On-Chip Memory Dumps */
2929
CXGB4_ETH_DUMP_HW = (1 << 1), /* various FW and HW dumps */
30+
CXGB4_ETH_DUMP_FLASH = (1 << 2), /* Dump flash memory */
3031
};
3132

3233
#define CXGB4_ETH_DUMP_ALL (CXGB4_ETH_DUMP_MEM | CXGB4_ETH_DUMP_HW)

0 commit comments

Comments
 (0)