forked from Minki/linux
net: hns3: add support for querying pfc puase packets statistic
This patch add support for querying pfc puase packets statistic in hclge_ieee_getpfc, which is used to tell user how many pfc puase packets have been sent and received by this mac port. Signed-off-by: Yunsheng Lin <linyunsheng@huawei.com> Signed-off-by: Peng Li <lipeng321@huawei.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
f8d291f00b
commit
64fd2300fc
@ -205,9 +205,11 @@ static int hclge_ieee_setets(struct hnae3_handle *h, struct ieee_ets *ets)
|
||||
|
||||
static int hclge_ieee_getpfc(struct hnae3_handle *h, struct ieee_pfc *pfc)
|
||||
{
|
||||
u64 requests[HNAE3_MAX_TC], indications[HNAE3_MAX_TC];
|
||||
struct hclge_vport *vport = hclge_get_vport(h);
|
||||
struct hclge_dev *hdev = vport->back;
|
||||
u8 i, j, pfc_map, *prio_tc;
|
||||
int ret;
|
||||
|
||||
memset(pfc, 0, sizeof(*pfc));
|
||||
pfc->pfc_cap = hdev->pfc_max;
|
||||
@ -222,6 +224,18 @@ static int hclge_ieee_getpfc(struct hnae3_handle *h, struct ieee_pfc *pfc)
|
||||
}
|
||||
}
|
||||
|
||||
ret = hclge_pfc_tx_stats_get(hdev, requests);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = hclge_pfc_rx_stats_get(hdev, indications);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
for (i = 0; i < HCLGE_MAX_TC_NUM; i++) {
|
||||
pfc->requests[i] = requests[i];
|
||||
pfc->indications[i] = indications[i];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,9 @@ enum hclge_shaper_level {
|
||||
HCLGE_SHAPER_LVL_PF = 1,
|
||||
};
|
||||
|
||||
#define HCLGE_TM_PFC_PKT_GET_CMD_NUM 3
|
||||
#define HCLGE_TM_PFC_NUM_GET_PER_CMD 3
|
||||
|
||||
#define HCLGE_SHAPER_BS_U_DEF 5
|
||||
#define HCLGE_SHAPER_BS_S_DEF 20
|
||||
|
||||
@ -112,6 +115,56 @@ static int hclge_shaper_para_calc(u32 ir, u8 shaper_level,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int hclge_pfc_stats_get(struct hclge_dev *hdev,
|
||||
enum hclge_opcode_type opcode, u64 *stats)
|
||||
{
|
||||
struct hclge_desc desc[HCLGE_TM_PFC_PKT_GET_CMD_NUM];
|
||||
int ret, i, j;
|
||||
|
||||
if (!(opcode == HCLGE_OPC_QUERY_PFC_RX_PKT_CNT ||
|
||||
opcode == HCLGE_OPC_QUERY_PFC_TX_PKT_CNT))
|
||||
return -EINVAL;
|
||||
|
||||
for (i = 0; i < HCLGE_TM_PFC_PKT_GET_CMD_NUM; i++) {
|
||||
hclge_cmd_setup_basic_desc(&desc[i], opcode, true);
|
||||
if (i != (HCLGE_TM_PFC_PKT_GET_CMD_NUM - 1))
|
||||
desc[i].flag |= cpu_to_le16(HCLGE_CMD_FLAG_NEXT);
|
||||
else
|
||||
desc[i].flag &= ~cpu_to_le16(HCLGE_CMD_FLAG_NEXT);
|
||||
}
|
||||
|
||||
ret = hclge_cmd_send(&hdev->hw, desc, HCLGE_TM_PFC_PKT_GET_CMD_NUM);
|
||||
if (ret) {
|
||||
dev_err(&hdev->pdev->dev,
|
||||
"Get pfc pause stats fail, ret = %d.\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
for (i = 0; i < HCLGE_TM_PFC_PKT_GET_CMD_NUM; i++) {
|
||||
struct hclge_pfc_stats_cmd *pfc_stats =
|
||||
(struct hclge_pfc_stats_cmd *)desc[i].data;
|
||||
|
||||
for (j = 0; j < HCLGE_TM_PFC_NUM_GET_PER_CMD; j++) {
|
||||
u32 index = i * HCLGE_TM_PFC_PKT_GET_CMD_NUM + j;
|
||||
|
||||
if (index < HCLGE_MAX_TC_NUM)
|
||||
stats[index] =
|
||||
le64_to_cpu(pfc_stats->pkt_num[j]);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int hclge_pfc_rx_stats_get(struct hclge_dev *hdev, u64 *stats)
|
||||
{
|
||||
return hclge_pfc_stats_get(hdev, HCLGE_OPC_QUERY_PFC_RX_PKT_CNT, stats);
|
||||
}
|
||||
|
||||
int hclge_pfc_tx_stats_get(struct hclge_dev *hdev, u64 *stats)
|
||||
{
|
||||
return hclge_pfc_stats_get(hdev, HCLGE_OPC_QUERY_PFC_TX_PKT_CNT, stats);
|
||||
}
|
||||
|
||||
int hclge_mac_pause_en_cfg(struct hclge_dev *hdev, bool tx, bool rx)
|
||||
{
|
||||
struct hclge_desc desc;
|
||||
|
@ -109,6 +109,10 @@ struct hclge_cfg_pause_param_cmd {
|
||||
__le16 pause_trans_time;
|
||||
};
|
||||
|
||||
struct hclge_pfc_stats_cmd {
|
||||
__le64 pkt_num[3];
|
||||
};
|
||||
|
||||
struct hclge_port_shapping_cmd {
|
||||
__le32 port_shapping_para;
|
||||
};
|
||||
@ -130,4 +134,6 @@ int hclge_tm_map_cfg(struct hclge_dev *hdev);
|
||||
int hclge_tm_init_hw(struct hclge_dev *hdev);
|
||||
int hclge_mac_pause_en_cfg(struct hclge_dev *hdev, bool tx, bool rx);
|
||||
int hclge_pause_addr_cfg(struct hclge_dev *hdev, const u8 *mac_addr);
|
||||
int hclge_pfc_rx_stats_get(struct hclge_dev *hdev, u64 *stats);
|
||||
int hclge_pfc_tx_stats_get(struct hclge_dev *hdev, u64 *stats);
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user