Skip to content

Commit 03a92fe

Browse files
IronShendavem330
authored andcommitted
net: hns3: add support for FD counter in debugfs
Previously, the flow director counter is not enabled. To improve the maintainability for chechking whether flow director hit or not, enable flow director counter for each function, and add debugfs query inerface to query the counters for each function. The debugfs command is below: cat fd_counter func_id hit_times pf 0 vf0 0 vf1 0 Signed-off-by: Jian Shen <[email protected]> Signed-off-by: Guangbin Huang <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent c948b46 commit 03a92fe

File tree

5 files changed

+62
-2
lines changed

5 files changed

+62
-2
lines changed

drivers/net/ethernet/hisilicon/hns3/hnae3.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ enum hnae3_dbg_cmd {
290290
HNAE3_DBG_CMD_RX_QUEUE_INFO,
291291
HNAE3_DBG_CMD_TX_QUEUE_INFO,
292292
HNAE3_DBG_CMD_FD_TCAM,
293+
HNAE3_DBG_CMD_FD_COUNTER,
293294
HNAE3_DBG_CMD_MAC_TNL_STATUS,
294295
HNAE3_DBG_CMD_SERV_INFO,
295296
HNAE3_DBG_CMD_UNKNOWN,

drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,13 @@ static struct hns3_dbg_cmd_info hns3_dbg_cmd[] = {
323323
.buf_len = HNS3_DBG_READ_LEN,
324324
.init = hns3_dbg_common_file_init,
325325
},
326+
{
327+
.name = "fd_counter",
328+
.cmd = HNAE3_DBG_CMD_FD_COUNTER,
329+
.dentry = HNS3_DBG_DENTRY_FD,
330+
.buf_len = HNS3_DBG_READ_LEN,
331+
.init = hns3_dbg_common_file_init,
332+
},
326333
};
327334

328335
static struct hns3_dbg_cap_info hns3_dbg_cap[] = {

drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ enum hclge_opcode_type {
248248
HCLGE_OPC_FD_KEY_CONFIG = 0x1202,
249249
HCLGE_OPC_FD_TCAM_OP = 0x1203,
250250
HCLGE_OPC_FD_AD_OP = 0x1204,
251+
HCLGE_OPC_FD_CNT_OP = 0x1205,
251252
HCLGE_OPC_FD_USER_DEF_OP = 0x1207,
252253

253254
/* MDIO command */
@@ -1109,6 +1110,14 @@ struct hclge_fd_ad_config_cmd {
11091110
u8 rsv2[8];
11101111
};
11111112

1113+
struct hclge_fd_ad_cnt_read_cmd {
1114+
u8 rsv0[4];
1115+
__le16 index;
1116+
u8 rsv1[2];
1117+
__le64 cnt;
1118+
u8 rsv2[8];
1119+
};
1120+
11121121
#define HCLGE_FD_USER_DEF_OFT_S 0
11131122
#define HCLGE_FD_USER_DEF_OFT_M GENMASK(14, 0)
11141123
#define HCLGE_FD_USER_DEF_EN_B 15

drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1549,6 +1549,39 @@ static int hclge_dbg_dump_fd_tcam(struct hclge_dev *hdev, char *buf, int len)
15491549
return ret;
15501550
}
15511551

1552+
static int hclge_dbg_dump_fd_counter(struct hclge_dev *hdev, char *buf, int len)
1553+
{
1554+
u8 func_num = pci_num_vf(hdev->pdev) + 1; /* pf and enabled vf num */
1555+
struct hclge_fd_ad_cnt_read_cmd *req;
1556+
char str_id[HCLGE_DBG_ID_LEN];
1557+
struct hclge_desc desc;
1558+
int pos = 0;
1559+
int ret;
1560+
u64 cnt;
1561+
u8 i;
1562+
1563+
pos += scnprintf(buf + pos, len - pos,
1564+
"func_id\thit_times\n");
1565+
1566+
for (i = 0; i < func_num; i++) {
1567+
hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_FD_CNT_OP, true);
1568+
req = (struct hclge_fd_ad_cnt_read_cmd *)desc.data;
1569+
req->index = cpu_to_le16(i);
1570+
ret = hclge_cmd_send(&hdev->hw, &desc, 1);
1571+
if (ret) {
1572+
dev_err(&hdev->pdev->dev, "failed to get fd counter, ret = %d\n",
1573+
ret);
1574+
return ret;
1575+
}
1576+
cnt = le64_to_cpu(req->cnt);
1577+
hclge_dbg_get_func_id_str(str_id, i);
1578+
pos += scnprintf(buf + pos, len - pos,
1579+
"%s\t%llu\n", str_id, cnt);
1580+
}
1581+
1582+
return 0;
1583+
}
1584+
15521585
int hclge_dbg_dump_rst_info(struct hclge_dev *hdev, char *buf, int len)
15531586
{
15541587
int pos = 0;
@@ -2375,6 +2408,10 @@ static const struct hclge_dbg_func hclge_dbg_cmd_func[] = {
23752408
.cmd = HNAE3_DBG_CMD_VLAN_CONFIG,
23762409
.dbg_dump = hclge_dbg_dump_vlan_config,
23772410
},
2411+
{
2412+
.cmd = HNAE3_DBG_CMD_FD_COUNTER,
2413+
.dbg_dump = hclge_dbg_dump_fd_counter,
2414+
},
23782415
};
23792416

23802417
int hclge_dbg_read_cmd(struct hnae3_handle *handle, enum hnae3_dbg_cmd cmd,

drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6000,8 +6000,14 @@ static int hclge_config_action(struct hclge_dev *hdev, u8 stage,
60006000
ad_data.queue_id = rule->queue_id;
60016001
}
60026002

6003-
ad_data.use_counter = false;
6004-
ad_data.counter_id = 0;
6003+
if (hdev->fd_cfg.cnt_num[HCLGE_FD_STAGE_1]) {
6004+
ad_data.use_counter = true;
6005+
ad_data.counter_id = rule->vf_id %
6006+
hdev->fd_cfg.cnt_num[HCLGE_FD_STAGE_1];
6007+
} else {
6008+
ad_data.use_counter = false;
6009+
ad_data.counter_id = 0;
6010+
}
60056011

60066012
ad_data.use_next_stage = false;
60076013
ad_data.next_input_key = 0;

0 commit comments

Comments
 (0)