Skip to content

Commit

Permalink
anolis: net/smc: Introduce link-related proc file
Browse files Browse the repository at this point in the history
ANBZ: #1742

ANBZ: torvalds#346

This patch introduces link-related proc files to report statistics
information of SMC-R links.

Signed-off-by: Guangguan Wang <[email protected]>
Acked-by: Tony Lu <[email protected]>
Acked-by: Tony Lu <[email protected]>
Link: https://gitee.com/anolis/cloud-kernel/pulls/577
Link: https://gitee.com/anolis/cloud-kernel/pulls/906
  • Loading branch information
Guangguan Wang authored and zychao66 committed Nov 25, 2022
1 parent d218a42 commit 3bc40ee
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 7 deletions.
58 changes: 55 additions & 3 deletions net/smc/smc_proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,11 @@ static void _conn_show(struct seq_file *seq, struct smc_sock *smc, int protocol)

seq_printf(seq, CONN_LGR_FM, lgr->role == SMC_CLNT ? 'C' : 'S',
lnk->ibname, lnk->ibport, lnk->roce_qp->qp_num,
lnk->peer_qpn, lnk->wr_tx_cnt, lnk->wr_rx_cnt);
lnk->peer_qpn, smc->conn.tx_cnt, smc->conn.tx_bytes,
smc->conn.tx_corked_cnt, smc->conn.tx_corked_bytes);
} else {
seq_puts(seq, "- - - - - - - -\n");
seq_puts(seq, "- - - - - - -"
" - - -\n");
}
}

Expand All @@ -170,7 +172,7 @@ static int smc_conn_show(struct seq_file *seq, void *v)
seq_printf(seq, sp->protocol == SMCPROTO_SMC ? CONN4_HDR : CONN6_HDR,
"sl", "local_addr", "remote_addr", "is_fb", "fb_rsn", "sock",
"clc_sock", "st", "inode", "lgr_id", "lgr_role", "dev", "port",
"l_qp", "r_qp", "tx_cnt", "rx_cnt");
"l_qp", "r_qp", "tx_P", "tx_B", "cork_P", "cork_B");
goto out;
}

Expand Down Expand Up @@ -234,6 +236,51 @@ static struct smc_proc_entry smc_proc[] = {
#endif
};

extern struct smc_lgr_list smc_lgr_list;
static int proc_show_links(struct seq_file *seq, void *v)
{
struct smc_link_group *lgr, *lg;
struct smc_link *lnk;
int i = 0, j = 0;

seq_printf(seq, "%-9s%-6s%-6s%-5s%-7s%-6s%-7s%-7s%-7s%-4s%-4s%-6s%-6s%-6s%-6s%-6s%-7s\n",
"grp", "type", "role", "idx", "gconn", "conn", "state", "qpn_l", "qpn_r",
"tx", "rx", "cr-e", "cr-l", "cr-r", "cr_h", "cr_l", "flags");

spin_lock_bh(&smc_lgr_list.lock);
list_for_each_entry_safe(lgr, lg, &smc_lgr_list.list, list) {
for (i = 0; i < SMC_LINKS_PER_LGR_MAX; i++) {
lnk = &lgr->lnk[i];
if (!smc_link_usable(lnk))
continue;
for (j = 0; j < SMC_LGR_ID_SIZE; j++)
seq_printf(seq, "%02X", lgr->id[j]);
seq_printf(seq, " %-6s%-6s%-5d%-7d%-6d%-7d%-7d%-7d%-4d%-4d%-6u%-6d%-6d%-6u%-6u%-7lu\n",
lgr->is_smcd ? "D" : "R", lgr->role == SMC_CLNT ? "C" : "S", i,
lgr->conns_num, atomic_read(&lnk->conn_cnt), lnk->state,
lnk->roce_qp ? lnk->roce_qp->qp_num : 0, lnk->peer_qpn,
lnk->wr_tx_cnt, lnk->wr_rx_cnt, lnk->credits_enable,
atomic_read(&lnk->local_rq_credits),
atomic_read(&lnk->peer_rq_credits), lnk->local_cr_watermark_high,
lnk->peer_cr_watermark_low, lnk->flags);
}
}
spin_unlock_bh(&smc_lgr_list.lock);
return 0;
}

static int proc_open_links(struct inode *inode, struct file *file)
{
single_open(file, proc_show_links, NULL);
return 0;
}

static struct proc_ops link_file_ops = {
.proc_open = proc_open_links,
.proc_read = seq_read,
.proc_release = single_release,
};

static int __net_init smc_proc_dir_init(struct net *net)
{
int i, rc = -ENOMEM;
Expand All @@ -250,6 +297,9 @@ static int __net_init smc_proc_dir_init(struct net *net)
goto err_entry;
}

if (!proc_create("links", 0444, net->proc_net_smc, &link_file_ops))
goto err_entry;

return 0;

err_entry:
Expand All @@ -265,6 +315,8 @@ static void __net_exit smc_proc_dir_exit(struct net *net)
{
int i;

remove_proc_entry("links", net->proc_net_smc);

for (i = 0; i < ARRAY_SIZE(smc_proc); i++)
remove_proc_entry(smc_proc[i].name, net->proc_net_smc);

Expand Down
10 changes: 6 additions & 4 deletions net/smc/smc_proc.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@
#include <net/net_namespace.h>
#include "smc.h"

#define CONN4_HDR ("%4s:%-15s%-15s%-7s%-10s%-19s%-19s%-6s%-19s%-11s%-11s%-9s%-6s%-6s%-7s%-9s%-6s\n")
#define CONN6_HDR ("%4s:%-39s%-39s%-7s%-10s%-19s%-19s%-6s%-19s%-11s%-11s%-9s%-6s%-6s%-7s%-9s%-6s\n")
#define CONN4_HDR ("%4s:%-15s%-15s%-7s%-10s%-19s%-19s%-6s%-17s%-11s" \
"%-11s%-13s%-6s%-6s%-7s%-9s%-9s%-9s%-9s\n")
#define CONN6_HDR ("%4s:%-39s%-39s%-7s%-10s%-19s%-19s%-6s%-17s%-11s" \
"%-11s%-13s%-6s%-6s%-7s%-9s%-9s%-9s%-9s\n")
#define CONN4_ADDR_FM ("%4d:%08X:%04X %08X:%04X")
#define CONN6_ADDR_FM ("%4d:%08X%08X%08X%08X:%04X %08X%08X%08X%08X:%04X")
#define CONN_SK_FM (" %c %-8X %pK %pK %2d %-16lu ")
#define CONN_LGR_FM (" %c %-8s %d %-4X %-4X %-8X %-8X\n")
#define CONN_SK_FM (" %c %-8X %pK %pK %2d %-16lu ")
#define CONN_LGR_FM (" %c %-8s %d %-4X %-4X %-8llu %-8llu %-8llu %-8llu\n")

struct smc_proc_private {
struct seq_net_private p;
Expand Down

0 comments on commit 3bc40ee

Please sign in to comment.