Synchronize code, Modify the review comments to increase the reliability of the code Signed-off-by: veega2022 <zhuweijia@huawei.com> (cherry picked from commit d2a23f9ffed0201385c7864b9cd58312fb395cb6)
186 lines
6.0 KiB
Diff
186 lines
6.0 KiB
Diff
From 261fdd1cc832989c60b3940cd8b2aa6593bc94ea Mon Sep 17 00:00:00 2001
|
|
From: Yuyu Li <liyuyu6@huawei.com>
|
|
Date: Tue, 12 Nov 2024 20:17:06 +0800
|
|
Subject: [PATCH 25/27] Fix the logic of obtaining statistics on flow control
|
|
storm suppression
|
|
|
|
Previously, regardless of the direction specified by -d, FW would return the statistics
|
|
of flow control storm suppression in both directions. Now it only returns the statistic
|
|
in the specified direction. An example is shown:
|
|
|
|
hikptool nic_qos -i eth6 -g pfc_storm_para -d rx
|
|
|
|
before:
|
|
PFC STORM Information:
|
|
direction: rx
|
|
enabled: on
|
|
period: 2000ms
|
|
pfc threshold: 1000ms
|
|
recovery period: 500ms
|
|
rx storm suppression count: 14
|
|
|
|
after:
|
|
PFC STORM Information:
|
|
direction: rx
|
|
enabled: on
|
|
period: 2000ms
|
|
pfc threshold: 1000ms
|
|
recovery period: 500ms
|
|
storm count: 14
|
|
|
|
Signed-off-by: Yuyu Li <liyuyu6@huawei.com>
|
|
---
|
|
net/nic/nic_qos/hikp_nic_qos.c | 32 ++++++++++++++++++++++----------
|
|
net/nic/nic_qos/hikp_nic_qos.h | 14 +++++++++-----
|
|
2 files changed, 31 insertions(+), 15 deletions(-)
|
|
|
|
diff --git a/net/nic/nic_qos/hikp_nic_qos.c b/net/nic/nic_qos/hikp_nic_qos.c
|
|
index 81eb0ba..32f251e 100644
|
|
--- a/net/nic/nic_qos/hikp_nic_qos.c
|
|
+++ b/net/nic/nic_qos/hikp_nic_qos.c
|
|
@@ -56,7 +56,8 @@ static int hikp_nic_qos_cmd_help(struct major_cmd_ctrl *self, const char *argv)
|
|
|
|
static void hikp_nic_qos_show_pkt_buf(const void *data)
|
|
{
|
|
- struct nic_pkt_buf_info *pkt_buf = (struct nic_pkt_buf_info *)data;
|
|
+ struct qos_cmd_info *qos_info_pkt = (struct qos_cmd_info *)data;
|
|
+ struct nic_pkt_buf_info *pkt_buf = (struct nic_pkt_buf_info *)&qos_info_pkt->info;
|
|
struct nic_shared_buf *share_buf = &pkt_buf->share_buf;
|
|
struct nic_priv_buf *priv_buf = pkt_buf->priv_buf;
|
|
uint16_t tc_no;
|
|
@@ -88,11 +89,12 @@ static void hikp_nic_qos_show_pkt_buf(const void *data)
|
|
|
|
static void hikp_nic_qos_show_dcb_info(const void *data)
|
|
{
|
|
- struct nic_dcb_info *dcb = (struct nic_dcb_info *)data;
|
|
+ struct qos_cmd_info *qos_info_dcb = (struct qos_cmd_info *)data;
|
|
+ struct nic_dcb_info *dcb = (struct nic_dcb_info *)&qos_info_dcb->info;
|
|
struct nic_pfc_info *pfc = &dcb->pfc;
|
|
struct nic_ets_info *ets = &dcb->ets;
|
|
- uint16_t up;
|
|
uint16_t tc_no;
|
|
+ uint16_t up;
|
|
|
|
printf("PFC configuration\n");
|
|
printf(" PFC enable:");
|
|
@@ -125,7 +127,8 @@ static void hikp_nic_qos_show_dcb_info(const void *data)
|
|
|
|
static void hikp_nic_qos_show_pause_info(const void *data)
|
|
{
|
|
- struct nic_pause_info *pause = (struct nic_pause_info *)data;
|
|
+ struct qos_cmd_info *qos_info_pause = (struct qos_cmd_info *)data;
|
|
+ struct nic_pause_info *pause = (struct nic_pause_info *)&qos_info_pause->info;
|
|
|
|
printf("PAUSE Information\n");
|
|
if (pause->type == HIKP_NONE_PAUSE)
|
|
@@ -143,8 +146,10 @@ static void hikp_nic_qos_show_pause_info(const void *data)
|
|
|
|
static void hikp_nic_qos_show_pfc_storm_para(const void *data)
|
|
{
|
|
+ struct qos_cmd_info *qos_info_pfc = (struct qos_cmd_info *)data;
|
|
struct nic_pfc_storm_para *pfc_storm_para =
|
|
- (struct nic_pfc_storm_para *)data;
|
|
+ (struct nic_pfc_storm_para *)&qos_info_pfc->info;
|
|
+ uint32_t length = qos_info_pfc->length;
|
|
|
|
printf("PFC STORM Information:\n");
|
|
printf("direction: %s\n", pfc_storm_para->dir ? "tx" : "rx");
|
|
@@ -155,6 +160,11 @@ static void hikp_nic_qos_show_pfc_storm_para(const void *data)
|
|
printf("check times: %u\n", pfc_storm_para->times) :
|
|
printf("pfc threshold: %ums\n", pfc_storm_para->times);
|
|
printf("recovery period: %ums\n", pfc_storm_para->recovery_period_ms);
|
|
+
|
|
+ if (length < sizeof(struct nic_pfc_storm_para))
|
|
+ return;
|
|
+
|
|
+ printf("storm count: %u\n", pfc_storm_para->storm_count);
|
|
}
|
|
|
|
static int hikp_nic_qos_get_blk(struct hikp_cmd_header *req_header,
|
|
@@ -192,11 +202,11 @@ out:
|
|
}
|
|
|
|
static int hikp_nic_query_qos_feature(struct hikp_cmd_header *req_header, const struct bdf_t *bdf,
|
|
- union nic_qos_feature_info *data)
|
|
+ struct qos_cmd_info *qcmd_info)
|
|
{
|
|
+ size_t buf_len = sizeof(qcmd_info->info);
|
|
struct nic_qos_rsp_head rsp_head = {0};
|
|
struct nic_qos_req_para req_data;
|
|
- size_t buf_len = sizeof(*data);
|
|
uint32_t total_blk_size;
|
|
uint8_t total_blk_num;
|
|
uint8_t blk_id = 0;
|
|
@@ -207,7 +217,7 @@ static int hikp_nic_query_qos_feature(struct hikp_cmd_header *req_header, const
|
|
req_data.block_id = blk_id;
|
|
req_data.dir = g_qos_param.dir;
|
|
|
|
- ret = hikp_nic_qos_get_blk(req_header, &req_data, data, buf_len, &rsp_head);
|
|
+ ret = hikp_nic_qos_get_blk(req_header, &req_data, &qcmd_info->info, buf_len, &rsp_head);
|
|
if (ret != 0)
|
|
return ret;
|
|
|
|
@@ -220,13 +230,15 @@ static int hikp_nic_query_qos_feature(struct hikp_cmd_header *req_header, const
|
|
req_data.dir = g_qos_param.dir;
|
|
|
|
ret = hikp_nic_qos_get_blk(req_header, &req_data,
|
|
- (uint8_t *)data + total_blk_size,
|
|
+ (uint8_t *)&qcmd_info->info + total_blk_size,
|
|
buf_len - total_blk_size, &rsp_head);
|
|
if (ret != 0)
|
|
return ret;
|
|
total_blk_size += rsp_head.cur_blk_size;
|
|
}
|
|
|
|
+ qcmd_info->length = total_blk_size;
|
|
+
|
|
return ret;
|
|
}
|
|
|
|
@@ -234,9 +246,9 @@ static void hikp_nic_qos_cmd_execute(struct major_cmd_ctrl *self)
|
|
{
|
|
char *revision_id = g_qos_param.revision_id;
|
|
struct bdf_t *bdf = &g_qos_param.target.bdf;
|
|
- union nic_qos_feature_info qos_data = {0};
|
|
struct hikp_cmd_header req_header = {0};
|
|
const struct qos_feature_cmd *qos_cmd;
|
|
+ struct qos_cmd_info qos_data = {0};
|
|
int ret;
|
|
|
|
if (bdf->dev_id != 0) {
|
|
diff --git a/net/nic/nic_qos/hikp_nic_qos.h b/net/nic/nic_qos/hikp_nic_qos.h
|
|
index d55970a..77fbdd9 100644
|
|
--- a/net/nic/nic_qos/hikp_nic_qos.h
|
|
+++ b/net/nic/nic_qos/hikp_nic_qos.h
|
|
@@ -57,6 +57,7 @@ struct nic_pfc_storm_para {
|
|
uint32_t period_ms;
|
|
uint32_t times;
|
|
uint32_t recovery_period_ms;
|
|
+ uint32_t storm_count;
|
|
};
|
|
|
|
struct nic_ets_info {
|
|
@@ -87,11 +88,14 @@ struct nic_pause_info {
|
|
uint16_t rsv;
|
|
};
|
|
|
|
-union nic_qos_feature_info {
|
|
- struct nic_pkt_buf_info pkt_buf;
|
|
- struct nic_dcb_info dcb;
|
|
- struct nic_pause_info pause;
|
|
- struct nic_pfc_storm_para pfc_storm_para;
|
|
+struct qos_cmd_info {
|
|
+ uint32_t length;
|
|
+ union nic_qos_feature_info {
|
|
+ struct nic_pkt_buf_info pkt_buf;
|
|
+ struct nic_dcb_info dcb;
|
|
+ struct nic_pause_info pause;
|
|
+ struct nic_pfc_storm_para pfc_storm_para;
|
|
+ } info;
|
|
};
|
|
|
|
struct nic_qos_rsp_head {
|
|
--
|
|
2.45.0.windows.1
|
|
|