1 /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */ 2 /* Copyright (C) 2018 Netronome Systems, Inc. */ 3 4 #ifndef __NFP_ABM_H__ 5 #define __NFP_ABM_H__ 1 6 7 #include <net/devlink.h> 8 9 struct nfp_app; 10 struct nfp_net; 11 12 #define NFP_ABM_PORTID_TYPE GENMASK(23, 16) 13 #define NFP_ABM_PORTID_ID GENMASK(7, 0) 14 15 /** 16 * struct nfp_abm - ABM NIC app structure 17 * @app: back pointer to nfp_app 18 * @pf_id: ID of our PF link 19 * @eswitch_mode: devlink eswitch mode, advanced functions only visible 20 * in switchdev mode 21 * @q_lvls: queue level control area 22 * @qm_stats: queue statistics symbol 23 */ 24 struct nfp_abm { 25 struct nfp_app *app; 26 unsigned int pf_id; 27 enum devlink_eswitch_mode eswitch_mode; 28 const struct nfp_rtsym *q_lvls; 29 const struct nfp_rtsym *qm_stats; 30 }; 31 32 /** 33 * struct nfp_alink_stats - ABM NIC statistics 34 * @tx_pkts: number of TXed packets 35 * @tx_bytes: number of TXed bytes 36 * @backlog_pkts: momentary backlog length (packets) 37 * @backlog_bytes: momentary backlog length (bytes) 38 * @overlimits: number of ECN marked TXed packets (accumulative) 39 * @drops: number of tail-dropped packets (accumulative) 40 */ 41 struct nfp_alink_stats { 42 u64 tx_pkts; 43 u64 tx_bytes; 44 u64 backlog_pkts; 45 u64 backlog_bytes; 46 u64 overlimits; 47 u64 drops; 48 }; 49 50 /** 51 * struct nfp_alink_xstats - extended ABM NIC statistics 52 * @ecn_marked: number of ECN marked TXed packets 53 * @pdrop: number of hard drops due to queue limit 54 */ 55 struct nfp_alink_xstats { 56 u64 ecn_marked; 57 u64 pdrop; 58 }; 59 60 /** 61 * struct nfp_red_qdisc - representation of single RED Qdisc 62 * @handle: handle of currently offloaded RED Qdisc 63 * @stats: statistics from last refresh 64 * @xstats: base of extended statistics 65 */ 66 struct nfp_red_qdisc { 67 u32 handle; 68 struct nfp_alink_stats stats; 69 struct nfp_alink_xstats xstats; 70 }; 71 72 /** 73 * struct nfp_abm_link - port tuple of a ABM NIC 74 * @abm: back pointer to nfp_abm 75 * @vnic: data vNIC 76 * @id: id of the data vNIC 77 * @queue_base: id of base to host queue within PCIe (not QC idx) 78 * @total_queues: number of PF queues 79 * @parent: handle of expected parent, i.e. handle of MQ, or TC_H_ROOT 80 * @num_qdiscs: number of currently used qdiscs 81 * @qdiscs: array of qdiscs 82 */ 83 struct nfp_abm_link { 84 struct nfp_abm *abm; 85 struct nfp_net *vnic; 86 unsigned int id; 87 unsigned int queue_base; 88 unsigned int total_queues; 89 u32 parent; 90 unsigned int num_qdiscs; 91 struct nfp_red_qdisc *qdiscs; 92 }; 93 94 void nfp_abm_ctrl_read_params(struct nfp_abm_link *alink); 95 int nfp_abm_ctrl_find_addrs(struct nfp_abm *abm); 96 int nfp_abm_ctrl_set_all_q_lvls(struct nfp_abm_link *alink, u32 val); 97 int nfp_abm_ctrl_set_q_lvl(struct nfp_abm_link *alink, unsigned int i, 98 u32 val); 99 int nfp_abm_ctrl_read_stats(struct nfp_abm_link *alink, 100 struct nfp_alink_stats *stats); 101 int nfp_abm_ctrl_read_q_stats(struct nfp_abm_link *alink, unsigned int i, 102 struct nfp_alink_stats *stats); 103 int nfp_abm_ctrl_read_xstats(struct nfp_abm_link *alink, 104 struct nfp_alink_xstats *xstats); 105 int nfp_abm_ctrl_read_q_xstats(struct nfp_abm_link *alink, unsigned int i, 106 struct nfp_alink_xstats *xstats); 107 u64 nfp_abm_ctrl_stat_non_sto(struct nfp_abm_link *alink, unsigned int i); 108 u64 nfp_abm_ctrl_stat_sto(struct nfp_abm_link *alink, unsigned int i); 109 int nfp_abm_ctrl_qm_enable(struct nfp_abm *abm); 110 int nfp_abm_ctrl_qm_disable(struct nfp_abm *abm); 111 #endif 112