18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci/* Copyright(c) 2017 - 2019 Pensando Systems, Inc */ 38c2ecf20Sopenharmony_ci 48c2ecf20Sopenharmony_ci#ifndef _IONIC_STATS_H_ 58c2ecf20Sopenharmony_ci#define _IONIC_STATS_H_ 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ci#define IONIC_STAT_TO_OFFSET(type, stat_name) (offsetof(type, stat_name)) 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci#define IONIC_STAT_DESC(type, stat_name) { \ 108c2ecf20Sopenharmony_ci .name = #stat_name, \ 118c2ecf20Sopenharmony_ci .offset = IONIC_STAT_TO_OFFSET(type, stat_name) \ 128c2ecf20Sopenharmony_ci} 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci#define IONIC_PORT_STAT_DESC(stat_name) \ 158c2ecf20Sopenharmony_ci IONIC_STAT_DESC(struct ionic_port_stats, stat_name) 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci#define IONIC_LIF_STAT_DESC(stat_name) \ 188c2ecf20Sopenharmony_ci IONIC_STAT_DESC(struct ionic_lif_sw_stats, stat_name) 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci#define IONIC_TX_STAT_DESC(stat_name) \ 218c2ecf20Sopenharmony_ci IONIC_STAT_DESC(struct ionic_tx_stats, stat_name) 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_ci#define IONIC_RX_STAT_DESC(stat_name) \ 248c2ecf20Sopenharmony_ci IONIC_STAT_DESC(struct ionic_rx_stats, stat_name) 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ci#define IONIC_TX_Q_STAT_DESC(stat_name) \ 278c2ecf20Sopenharmony_ci IONIC_STAT_DESC(struct ionic_queue, stat_name) 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_ci#define IONIC_CQ_STAT_DESC(stat_name) \ 308c2ecf20Sopenharmony_ci IONIC_STAT_DESC(struct ionic_cq, stat_name) 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci#define IONIC_INTR_STAT_DESC(stat_name) \ 338c2ecf20Sopenharmony_ci IONIC_STAT_DESC(struct ionic_intr_info, stat_name) 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ci#define IONIC_NAPI_STAT_DESC(stat_name) \ 368c2ecf20Sopenharmony_ci IONIC_STAT_DESC(struct ionic_napi_stats, stat_name) 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ci/* Interface structure for a particalar stats group */ 398c2ecf20Sopenharmony_cistruct ionic_stats_group_intf { 408c2ecf20Sopenharmony_ci void (*get_strings)(struct ionic_lif *lif, u8 **buf); 418c2ecf20Sopenharmony_ci void (*get_values)(struct ionic_lif *lif, u64 **buf); 428c2ecf20Sopenharmony_ci u64 (*get_count)(struct ionic_lif *lif); 438c2ecf20Sopenharmony_ci}; 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_ciextern const struct ionic_stats_group_intf ionic_stats_groups[]; 468c2ecf20Sopenharmony_ciextern const int ionic_num_stats_grps; 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_ci#define IONIC_READ_STAT64(base_ptr, desc_ptr) \ 498c2ecf20Sopenharmony_ci (*((u64 *)(((u8 *)(base_ptr)) + (desc_ptr)->offset))) 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_ci#define IONIC_READ_STAT_LE64(base_ptr, desc_ptr) \ 528c2ecf20Sopenharmony_ci __le64_to_cpu(*((__le64 *)(((u8 *)(base_ptr)) + (desc_ptr)->offset))) 538c2ecf20Sopenharmony_ci 548c2ecf20Sopenharmony_cistruct ionic_stat_desc { 558c2ecf20Sopenharmony_ci char name[ETH_GSTRING_LEN]; 568c2ecf20Sopenharmony_ci u64 offset; 578c2ecf20Sopenharmony_ci}; 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_ci#endif /* _IONIC_STATS_H_ */ 60