1
0
mirror of https://github.com/corundum/corundum.git synced 2025-01-30 08:32:52 +08:00

modules/mqnic: Add statistics counter read support to mqnic kernel module

Signed-off-by: Alex Forencich <alex@alexforencich.com>
This commit is contained in:
Alex Forencich 2022-11-23 17:49:38 -08:00
parent 051dca3601
commit 979b7b6030
4 changed files with 75 additions and 0 deletions

View File

@ -15,6 +15,7 @@ mqnic-y += mqnic_ptp.o
mqnic-y += mqnic_i2c.o mqnic-y += mqnic_i2c.o
mqnic-y += mqnic_board.o mqnic-y += mqnic_board.o
mqnic-y += mqnic_clk_info.o mqnic-y += mqnic_clk_info.o
mqnic-y += mqnic_stats.o
mqnic-y += mqnic_tx.o mqnic-y += mqnic_tx.o
mqnic-y += mqnic_rx.o mqnic-y += mqnic_rx.o
mqnic-y += mqnic_cq.o mqnic-y += mqnic_cq.o

View File

@ -168,6 +168,7 @@ struct mqnic_dev {
struct mqnic_reg_block *rb_list; struct mqnic_reg_block *rb_list;
struct mqnic_reg_block *fw_id_rb; struct mqnic_reg_block *fw_id_rb;
struct mqnic_reg_block *if_rb; struct mqnic_reg_block *if_rb;
struct mqnic_reg_block *stats_rb;
struct mqnic_reg_block *clk_info_rb; struct mqnic_reg_block *clk_info_rb;
struct mqnic_reg_block *phc_rb; struct mqnic_reg_block *phc_rb;
@ -185,6 +186,11 @@ struct mqnic_dev {
u32 app_id; u32 app_id;
u32 stats_offset;
u32 stats_count;
u32 stats_stride;
u32 stats_flags;
u32 core_clk_nom_per_ns_num; u32 core_clk_nom_per_ns_num;
u32 core_clk_nom_per_ns_denom; u32 core_clk_nom_per_ns_denom;
u32 core_clk_nom_freq_hz; u32 core_clk_nom_freq_hz;
@ -581,6 +587,10 @@ u32 mqnic_get_ref_clk_nom_freq_hz(struct mqnic_dev *mdev);
u32 mqnic_get_core_clk_freq_hz(struct mqnic_dev *mdev); u32 mqnic_get_core_clk_freq_hz(struct mqnic_dev *mdev);
u32 mqnic_get_clk_freq_hz(struct mqnic_dev *mdev, int ch); u32 mqnic_get_clk_freq_hz(struct mqnic_dev *mdev, int ch);
// mqnic_stats.c
void mqnic_stats_init(struct mqnic_dev *mdev);
u64 mqnic_stats_read(struct mqnic_dev *mdev, int index);
// mqnic_eq.c // mqnic_eq.c
int mqnic_create_eq_ring(struct mqnic_if *interface, struct mqnic_eq_ring **ring_ptr, int mqnic_create_eq_ring(struct mqnic_if *interface, struct mqnic_eq_ring **ring_ptr,
int index, u8 __iomem *hw_addr); int index, u8 __iomem *hw_addr);

View File

@ -334,6 +334,7 @@ static int mqnic_common_probe(struct mqnic_dev *mqnic)
} }
mqnic_clk_info_init(mqnic); mqnic_clk_info_init(mqnic);
mqnic_stats_init(mqnic);
mqnic->phc_rb = mqnic_find_reg_block(mqnic->rb_list, MQNIC_RB_PHC_TYPE, MQNIC_RB_PHC_VER, 0); mqnic->phc_rb = mqnic_find_reg_block(mqnic->rb_list, MQNIC_RB_PHC_TYPE, MQNIC_RB_PHC_VER, 0);

View File

@ -0,0 +1,63 @@
// SPDX-License-Identifier: BSD-2-Clause-Views
/*
* Copyright 2022, The Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation
* are those of the authors and should not be interpreted as representing
* official policies, either expressed or implied, of The Regents of the
* University of California.
*/
#include "mqnic.h"
void mqnic_stats_init(struct mqnic_dev *mdev)
{
mdev->stats_rb = mqnic_find_reg_block(mdev->rb_list, MQNIC_RB_STATS_TYPE, MQNIC_RB_STATS_VER, 0);
if (!mdev->stats_rb)
return;
mdev->stats_offset = ioread32(mdev->stats_rb->regs + MQNIC_RB_STATS_REG_OFFSET);
mdev->stats_count = ioread32(mdev->stats_rb->regs + MQNIC_RB_STATS_REG_COUNT);
mdev->stats_stride = ioread32(mdev->stats_rb->regs + MQNIC_RB_STATS_REG_STRIDE);
mdev->stats_flags = ioread32(mdev->stats_rb->regs + MQNIC_RB_STATS_REG_FLAGS);
}
u64 mqnic_stats_read(struct mqnic_dev *mdev, int index)
{
u64 val;
if (!mdev->stats_rb || index < 0 || index >= mdev->stats_count)
return 0;
val = (u64)ioread32(mdev->hw_addr + mdev->stats_offset + index*8 + 0);
val |= (u64)ioread32(mdev->hw_addr + mdev->stats_offset + index*8 + 4) << 32;
return val;
}
EXPORT_SYMBOL(mqnic_stats_read);