lkml.org 
[lkml]   [2022]   [Jan]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH net-next 14/15] net: hns3: refactor VF tqp stats APIs with new common tqp stats APIs
    Date
    From: Jie Wang <wangjie125@huawei.com>

    This patch firstly uses new tqp struct(hclge_comm_tqp) and removes the
    old VF tqp struct(hclgevf_tqp). All the tqp stats members used in VF module
    are modified according to the new hclge_comm_tqp.

    Secondly VF tqp stats APIs are refactored to use new common tqp stats APIs.
    The old tqp stats APIs in VF are deleted.

    Signed-off-by: Jie Wang <wangjie125@huawei.com>
    ---
    .../hisilicon/hns3/hns3vf/hclgevf_main.c | 125 ++----------------
    .../hisilicon/hns3/hns3vf/hclgevf_main.h | 20 +--
    2 files changed, 11 insertions(+), 134 deletions(-)

    diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
    index 3c42ca50f590..5b2379252478 100644
    --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
    +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
    @@ -121,108 +121,13 @@ static struct hclgevf_dev *hclgevf_ae_get_hdev(struct hnae3_handle *handle)
    return container_of(handle, struct hclgevf_dev, nic);
    }

    -static int hclgevf_tqps_update_stats(struct hnae3_handle *handle)
    -{
    - struct hnae3_knic_private_info *kinfo = &handle->kinfo;
    - struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle);
    - struct hclge_desc desc;
    - struct hclgevf_tqp *tqp;
    - int status;
    - int i;
    -
    - for (i = 0; i < kinfo->num_tqps; i++) {
    - tqp = container_of(kinfo->tqp[i], struct hclgevf_tqp, q);
    - hclgevf_cmd_setup_basic_desc(&desc,
    - HCLGEVF_OPC_QUERY_RX_STATUS,
    - true);
    -
    - desc.data[0] = cpu_to_le32(tqp->index & 0x1ff);
    - status = hclgevf_cmd_send(&hdev->hw, &desc, 1);
    - if (status) {
    - dev_err(&hdev->pdev->dev,
    - "Query tqp stat fail, status = %d,queue = %d\n",
    - status, i);
    - return status;
    - }
    - tqp->tqp_stats.rcb_rx_ring_pktnum_rcd +=
    - le32_to_cpu(desc.data[1]);
    -
    - hclgevf_cmd_setup_basic_desc(&desc, HCLGEVF_OPC_QUERY_TX_STATUS,
    - true);
    -
    - desc.data[0] = cpu_to_le32(tqp->index & 0x1ff);
    - status = hclgevf_cmd_send(&hdev->hw, &desc, 1);
    - if (status) {
    - dev_err(&hdev->pdev->dev,
    - "Query tqp stat fail, status = %d,queue = %d\n",
    - status, i);
    - return status;
    - }
    - tqp->tqp_stats.rcb_tx_ring_pktnum_rcd +=
    - le32_to_cpu(desc.data[1]);
    - }
    -
    - return 0;
    -}
    -
    -static u64 *hclgevf_tqps_get_stats(struct hnae3_handle *handle, u64 *data)
    -{
    - struct hnae3_knic_private_info *kinfo = &handle->kinfo;
    - struct hclgevf_tqp *tqp;
    - u64 *buff = data;
    - int i;
    -
    - for (i = 0; i < kinfo->num_tqps; i++) {
    - tqp = container_of(kinfo->tqp[i], struct hclgevf_tqp, q);
    - *buff++ = tqp->tqp_stats.rcb_tx_ring_pktnum_rcd;
    - }
    - for (i = 0; i < kinfo->num_tqps; i++) {
    - tqp = container_of(kinfo->tqp[i], struct hclgevf_tqp, q);
    - *buff++ = tqp->tqp_stats.rcb_rx_ring_pktnum_rcd;
    - }
    -
    - return buff;
    -}
    -
    -static int hclgevf_tqps_get_sset_count(struct hnae3_handle *handle, int strset)
    -{
    - struct hnae3_knic_private_info *kinfo = &handle->kinfo;
    -
    - return kinfo->num_tqps * 2;
    -}
    -
    -static u8 *hclgevf_tqps_get_strings(struct hnae3_handle *handle, u8 *data)
    -{
    - struct hnae3_knic_private_info *kinfo = &handle->kinfo;
    - u8 *buff = data;
    - int i;
    -
    - for (i = 0; i < kinfo->num_tqps; i++) {
    - struct hclgevf_tqp *tqp = container_of(kinfo->tqp[i],
    - struct hclgevf_tqp, q);
    - snprintf(buff, ETH_GSTRING_LEN, "txq%u_pktnum_rcd",
    - tqp->index);
    - buff += ETH_GSTRING_LEN;
    - }
    -
    - for (i = 0; i < kinfo->num_tqps; i++) {
    - struct hclgevf_tqp *tqp = container_of(kinfo->tqp[i],
    - struct hclgevf_tqp, q);
    - snprintf(buff, ETH_GSTRING_LEN, "rxq%u_pktnum_rcd",
    - tqp->index);
    - buff += ETH_GSTRING_LEN;
    - }
    -
    - return buff;
    -}
    -
    static void hclgevf_update_stats(struct hnae3_handle *handle,
    struct net_device_stats *net_stats)
    {
    struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle);
    int status;

    - status = hclgevf_tqps_update_stats(handle);
    + status = hclge_comm_tqps_update_stats(handle, &hdev->hw.hw);
    if (status)
    dev_err(&hdev->pdev->dev,
    "VF update of TQPS stats fail, status = %d.\n",
    @@ -234,7 +139,7 @@ static int hclgevf_get_sset_count(struct hnae3_handle *handle, int strset)
    if (strset == ETH_SS_TEST)
    return -EOPNOTSUPP;
    else if (strset == ETH_SS_STATS)
    - return hclgevf_tqps_get_sset_count(handle, strset);
    + return hclge_comm_tqps_get_sset_count(handle);

    return 0;
    }
    @@ -245,12 +150,12 @@ static void hclgevf_get_strings(struct hnae3_handle *handle, u32 strset,
    u8 *p = (char *)data;

    if (strset == ETH_SS_STATS)
    - p = hclgevf_tqps_get_strings(handle, p);
    + p = hclge_comm_tqps_get_strings(handle, p);
    }

    static void hclgevf_get_stats(struct hnae3_handle *handle, u64 *data)
    {
    - hclgevf_tqps_get_stats(handle, data);
    + hclge_comm_tqps_get_stats(handle, data);
    }

    static void hclgevf_build_send_msg(struct hclge_vf_to_pf_msg *msg, u8 code,
    @@ -416,11 +321,11 @@ static int hclgevf_get_pf_media_type(struct hclgevf_dev *hdev)

    static int hclgevf_alloc_tqps(struct hclgevf_dev *hdev)
    {
    - struct hclgevf_tqp *tqp;
    + struct hclge_comm_tqp *tqp;
    int i;

    hdev->htqp = devm_kcalloc(&hdev->pdev->dev, hdev->num_tqps,
    - sizeof(struct hclgevf_tqp), GFP_KERNEL);
    + sizeof(struct hclge_comm_tqp), GFP_KERNEL);
    if (!hdev->htqp)
    return -ENOMEM;

    @@ -958,18 +863,6 @@ static int hclgevf_tqp_enable(struct hnae3_handle *handle, bool enable)
    return 0;
    }

    -static void hclgevf_reset_tqp_stats(struct hnae3_handle *handle)
    -{
    - struct hnae3_knic_private_info *kinfo = &handle->kinfo;
    - struct hclgevf_tqp *tqp;
    - int i;
    -
    - for (i = 0; i < kinfo->num_tqps; i++) {
    - tqp = container_of(kinfo->tqp[i], struct hclgevf_tqp, q);
    - memset(&tqp->tqp_stats, 0, sizeof(tqp->tqp_stats));
    - }
    -}
    -
    static int hclgevf_get_host_mac_addr(struct hclgevf_dev *hdev, u8 *p)
    {
    struct hclge_vf_to_pf_msg send_msg;
    @@ -2033,7 +1926,7 @@ static void hclgevf_periodic_service_task(struct hclgevf_dev *hdev)
    }

    if (!(hdev->serv_processed_cnt % HCLGEVF_STATS_TIMER_INTERVAL))
    - hclgevf_tqps_update_stats(handle);
    + hclge_comm_tqps_update_stats(handle, &hdev->hw.hw);

    /* VF does not need to request link status when this bit is set, because
    * PF will push its link status to VFs when link status changed.
    @@ -2332,7 +2225,7 @@ static int hclgevf_ae_start(struct hnae3_handle *handle)
    clear_bit(HCLGEVF_STATE_DOWN, &hdev->state);
    clear_bit(HCLGEVF_STATE_PF_PUSH_LINK_STATUS, &hdev->state);

    - hclgevf_reset_tqp_stats(handle);
    + hclge_comm_reset_tqp_stats(handle);

    hclgevf_request_link_info(hdev);

    @@ -2350,7 +2243,7 @@ static void hclgevf_ae_stop(struct hnae3_handle *handle)
    if (hdev->reset_type != HNAE3_VF_RESET)
    hclgevf_reset_tqp(handle);

    - hclgevf_reset_tqp_stats(handle);
    + hclge_comm_reset_tqp_stats(handle);
    hclgevf_update_link_status(hdev, 0);
    }

    diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h
    index 50e347a2ed18..502ca1ce1a90 100644
    --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h
    +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h
    @@ -11,6 +11,7 @@
    #include "hclgevf_cmd.h"
    #include "hnae3.h"
    #include "hclge_comm_rss.h"
    +#include "hclge_comm_tqp_stats.h"

    #define HCLGEVF_MOD_VERSION "1.0"
    #define HCLGEVF_DRIVER_NAME "hclgevf"
    @@ -148,23 +149,6 @@ struct hclgevf_hw {
    struct hclgevf_mac mac;
    };

    -/* TQP stats */
    -struct hlcgevf_tqp_stats {
    - /* query_tqp_tx_queue_statistics, opcode id: 0x0B03 */
    - u64 rcb_tx_ring_pktnum_rcd; /* 32bit */
    - /* query_tqp_rx_queue_statistics, opcode id: 0x0B13 */
    - u64 rcb_rx_ring_pktnum_rcd; /* 32bit */
    -};
    -
    -struct hclgevf_tqp {
    - struct device *dev; /* device for DMA mapping */
    - struct hnae3_queue q;
    - struct hlcgevf_tqp_stats tqp_stats;
    - u16 index; /* global index in a NIC controller */
    -
    - bool alloced;
    -};
    -
    struct hclgevf_cfg {
    u8 tc_num;
    u16 tqp_desc_num;
    @@ -270,7 +254,7 @@ struct hclgevf_dev {

    struct delayed_work service_task;

    - struct hclgevf_tqp *htqp;
    + struct hclge_comm_tqp *htqp;

    struct hnae3_handle nic;
    struct hnae3_handle roce;
    --
    2.33.0
    \
     
     \ /
      Last update: 2022-01-05 15:39    [W:2.702 / U:0.004 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site