Received: by 10.223.185.111 with SMTP id b44csp1006251wrg; Fri, 9 Mar 2018 19:01:14 -0800 (PST) X-Google-Smtp-Source: AG47ELtRp4koXerfWnGe/54qeqO+YPuD1z4KJ0yWeQ2Ah+59H5VO9Pzo5ctKNNo28WrDWQEFekj5 X-Received: by 2002:a17:902:9882:: with SMTP id s2-v6mr689866plp.196.1520650874870; Fri, 09 Mar 2018 19:01:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520650874; cv=none; d=google.com; s=arc-20160816; b=kLg3yPv+lIkEmV4q10XzeggUW1FunQ1BjZUlMFerSxFREMgBU1OGgUJuZEWGOZ2ZdK PFtXzCf1FJpk1fYNmiFBW/oXV8cskDTWnbEak+Z4dFuY84EPzqmogMw8cYyOTIjSY+Kg DkQr/8nxaPyfgiQVVTZzMHn1AEQ5JTNFxiVwOPt2rB+oLTG6oYMvX5XZErL37PwdLHgm IOyFVr9yEU8faVKUe8B8VNOIpiVKAkta56bJ4CokdIW767NmjOhCo8S2CHl3Xm0nxv8x cZPcBXyENve6bMaOtL1zAnr0NJgxHDMfwPOjjNFEkqf5+yI0IMXhUCAH0Uqiz+HC30It N8gg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=WTqKthdxbOUIcsPJXXzsQRl6/YGKCS3gx5K4IaGEJjs=; b=MAfOYCP0h56mevkLAJ3mZCJLM+gfoawCIDHsvZUCFPejmGZDAUHFbw/coxwsvmfpBR Q1cHvlwXceD6096Ij/Wj160T8RUiwwVA12g5W58PMk+8IAqpwYRTwuof/vEtXmf6Ahkd h8d/TLZU+CTs667zhtBdHKLqBz5xM7+y+eWlXgo93r7d0Gl0BU0FC+HSClES7uOYlL8m QjT/fHCF5XKS0liEsxIQozimda0rQjKZJyRZIewjpdtSk9M1oDUEeF6lUUiSPKmbvhkE Su/n/pLOXrSjPTzZDK7hZZ16J3lh4LEvLVZSgUV8wZO96X6ljacSaFdRKJ/Fb7H1Zefd LT7w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n8si1943727pff.122.2018.03.09.19.01.00; Fri, 09 Mar 2018 19:01:14 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752027AbeCJC7W (ORCPT + 99 others); Fri, 9 Mar 2018 21:59:22 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:6224 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932343AbeCJC5i (ORCPT ); Fri, 9 Mar 2018 21:57:38 -0500 Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 9FABBBCC07577; Sat, 10 Mar 2018 10:57:21 +0800 (CST) Received: from linux-ioko.site (10.71.200.31) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.361.1; Sat, 10 Mar 2018 10:57:16 +0800 From: Peng Li To: CC: , , , , Subject: [PATCH net-next 06/12] net: hns3: add support for querying pfc puase packets statistic Date: Sat, 10 Mar 2018 11:29:27 +0800 Message-ID: <1520652573-75644-7-git-send-email-lipeng321@huawei.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1520652573-75644-1-git-send-email-lipeng321@huawei.com> References: <1520652573-75644-1-git-send-email-lipeng321@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.71.200.31] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Signed-off-by: Peng Li --- .../net/ethernet/hisilicon/hns3/hns3pf/hclge_dcb.c | 14 ++++++ .../net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c | 53 ++++++++++++++++++++++ .../net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.h | 6 +++ 3 files changed, 73 insertions(+) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_dcb.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_dcb.c index 407cfab..955f0e3 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_dcb.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_dcb.c @@ -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; } diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c index 4134a82..885f25c 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c @@ -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; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.h index c30c85b..2dbe177 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.h @@ -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 -- 2.9.3