mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00

Add base to collect dump entities. Collect register dump and update template header accordingly. 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>
79 lines
2.3 KiB
C
79 lines
2.3 KiB
C
/*
|
|
* Copyright (C) 2017 Chelsio Communications. All rights reserved.
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
* under the terms and conditions of the GNU General Public License,
|
|
* version 2, as published by the Free Software Foundation.
|
|
*
|
|
* This program is distributed in the hope it will be useful, but WITHOUT
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
* more details.
|
|
*
|
|
* The full GNU General Public License is included in this distribution in
|
|
* the file called "COPYING".
|
|
*
|
|
*/
|
|
|
|
#include "cxgb4.h"
|
|
#include "cudbg_if.h"
|
|
#include "cudbg_lib_common.h"
|
|
#include "cudbg_lib.h"
|
|
|
|
static void cudbg_write_and_release_buff(struct cudbg_buffer *pin_buff,
|
|
struct cudbg_buffer *dbg_buff)
|
|
{
|
|
cudbg_update_buff(pin_buff, dbg_buff);
|
|
cudbg_put_buff(pin_buff, dbg_buff);
|
|
}
|
|
|
|
/* This function will add additional padding bytes into debug_buffer to make it
|
|
* 4 byte aligned.
|
|
*/
|
|
void cudbg_align_debug_buffer(struct cudbg_buffer *dbg_buff,
|
|
struct cudbg_entity_hdr *entity_hdr)
|
|
{
|
|
u8 zero_buf[4] = {0};
|
|
u8 padding, remain;
|
|
|
|
remain = (dbg_buff->offset - entity_hdr->start_offset) % 4;
|
|
padding = 4 - remain;
|
|
if (remain) {
|
|
memcpy(((u8 *)dbg_buff->data) + dbg_buff->offset, &zero_buf,
|
|
padding);
|
|
dbg_buff->offset += padding;
|
|
entity_hdr->num_pad = padding;
|
|
}
|
|
entity_hdr->size = dbg_buff->offset - entity_hdr->start_offset;
|
|
}
|
|
|
|
struct cudbg_entity_hdr *cudbg_get_entity_hdr(void *outbuf, int i)
|
|
{
|
|
struct cudbg_hdr *cudbg_hdr = (struct cudbg_hdr *)outbuf;
|
|
|
|
return (struct cudbg_entity_hdr *)
|
|
((char *)outbuf + cudbg_hdr->hdr_len +
|
|
(sizeof(struct cudbg_entity_hdr) * (i - 1)));
|
|
}
|
|
|
|
int cudbg_collect_reg_dump(struct cudbg_init *pdbg_init,
|
|
struct cudbg_buffer *dbg_buff,
|
|
struct cudbg_error *cudbg_err)
|
|
{
|
|
struct adapter *padap = pdbg_init->adap;
|
|
struct cudbg_buffer temp_buff = { 0 };
|
|
u32 buf_size = 0;
|
|
int rc = 0;
|
|
|
|
if (is_t4(padap->params.chip))
|
|
buf_size = T4_REGMAP_SIZE;
|
|
else if (is_t5(padap->params.chip) || is_t6(padap->params.chip))
|
|
buf_size = T5_REGMAP_SIZE;
|
|
|
|
rc = cudbg_get_buff(dbg_buff, buf_size, &temp_buff);
|
|
if (rc)
|
|
return rc;
|
|
t4_get_regs(padap, (void *)temp_buff.data, temp_buff.size);
|
|
cudbg_write_and_release_buff(&temp_buff, dbg_buff);
|
|
return rc;
|
|
}
|