Skip to content

Commit

Permalink
cxgb4: move Tx/Rx free pages collection to common code
Browse files Browse the repository at this point in the history
This information needs to be collected in vmcore device dump as well.
So, move to common code.

Fixes: fa145d5 ("cxgb4: display number of rx and tx pages free")
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>
  • Loading branch information
Rahul Lakkireddy authored and David S. Miller committed Jul 24, 2018
1 parent 9d0f180 commit ae2a922
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
2 changes: 2 additions & 0 deletions drivers/net/ethernet/chelsio/cxgb4/cudbg_entity.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ struct cudbg_meminfo {
u32 loopback_used[NCHAN];
u32 loopback_alloc[NCHAN];
u32 p_structs_free_cnt;
u32 free_rx_cnt;
u32 free_tx_cnt;
};

struct cudbg_cim_pif_la {
Expand Down
10 changes: 10 additions & 0 deletions drivers/net/ethernet/chelsio/cxgb4/cudbg_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -349,13 +349,23 @@ int cudbg_fill_meminfo(struct adapter *padap,
meminfo_buff->up_extmem2_hi = hi;

lo = t4_read_reg(padap, TP_PMM_RX_MAX_PAGE_A);
for (i = 0, meminfo_buff->free_rx_cnt = 0; i < 2; i++)
meminfo_buff->free_rx_cnt +=
FREERXPAGECOUNT_G(t4_read_reg(padap,
TP_FLM_FREE_RX_CNT_A));

meminfo_buff->rx_pages_data[0] = PMRXMAXPAGE_G(lo);
meminfo_buff->rx_pages_data[1] =
t4_read_reg(padap, TP_PMM_RX_PAGE_SIZE_A) >> 10;
meminfo_buff->rx_pages_data[2] = (lo & PMRXNUMCHN_F) ? 2 : 1;

lo = t4_read_reg(padap, TP_PMM_TX_MAX_PAGE_A);
hi = t4_read_reg(padap, TP_PMM_TX_PAGE_SIZE_A);
for (i = 0, meminfo_buff->free_tx_cnt = 0; i < 4; i++)
meminfo_buff->free_tx_cnt +=
FREETXPAGECOUNT_G(t4_read_reg(padap,
TP_FLM_FREE_TX_CNT_A));

meminfo_buff->tx_pages_data[0] = PMTXMAXPAGE_G(lo);
meminfo_buff->tx_pages_data[1] =
hi >= (1 << 20) ? (hi >> 20) : (hi >> 10);
Expand Down
11 changes: 2 additions & 9 deletions drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -2858,7 +2858,6 @@ static int meminfo_show(struct seq_file *seq, void *v)
{
static const char * const memory[] = { "EDC0:", "EDC1:", "MC:",
"MC0:", "MC1:", "HMA:"};
unsigned int free_rx_cnt, free_tx_cnt;
struct adapter *adap = seq->private;
struct cudbg_meminfo meminfo;
int i, rc;
Expand Down Expand Up @@ -2890,18 +2889,12 @@ static int meminfo_show(struct seq_file *seq, void *v)
mem_region_show(seq, "uP Extmem2:", meminfo.up_extmem2_lo,
meminfo.up_extmem2_hi);

for (i = 0, free_rx_cnt = 0; i < 2; i++)
free_rx_cnt += FREERXPAGECOUNT_G
(t4_read_reg(adap, TP_FLM_FREE_RX_CNT_A));
seq_printf(seq, "\n%u Rx pages (%u free) of size %uKiB for %u channels\n",
meminfo.rx_pages_data[0], free_rx_cnt,
meminfo.rx_pages_data[0], meminfo.free_rx_cnt,
meminfo.rx_pages_data[1], meminfo.rx_pages_data[2]);

for (i = 0, free_tx_cnt = 0; i < 4; i++)
free_tx_cnt += FREETXPAGECOUNT_G
(t4_read_reg(adap, TP_FLM_FREE_TX_CNT_A));
seq_printf(seq, "%u Tx pages (%u free) of size %u%ciB for %u channels\n",
meminfo.tx_pages_data[0], free_tx_cnt,
meminfo.tx_pages_data[0], meminfo.free_tx_cnt,
meminfo.tx_pages_data[1], meminfo.tx_pages_data[2],
meminfo.tx_pages_data[3]);

Expand Down

0 comments on commit ae2a922

Please sign in to comment.