1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2014-2019 Broadcom
12 #define ULP_FLAG_FC_THREAD BIT(0)
13 #define ULP_FC_TIMER 1/* Timer freq in Sec Flow Counters */
15 /* Macros to extract packet/byte counters from a 64-bit flow counter. */
16 #define FLOW_CNTR_BYTE_WIDTH 36
17 #define FLOW_CNTR_BYTE_MASK (((uint64_t)1 << FLOW_CNTR_BYTE_WIDTH) - 1)
19 #define FLOW_CNTR_PKTS(v) ((v) >> FLOW_CNTR_BYTE_WIDTH)
20 #define FLOW_CNTR_BYTES(v) ((v) & FLOW_CNTR_BYTE_MASK)
22 struct sw_acc_counter {
28 struct hw_fc_mem_info {
30 * [out] mem_va, pointer to the allocated memory.
34 * [out] mem_pa, physical address of the allocated memory.
40 struct bnxt_ulp_fc_info {
41 struct sw_acc_counter *sw_acc_tbl[TF_DIR_MAX];
42 struct hw_fc_mem_info shadow_hw_tbl[TF_DIR_MAX];
45 pthread_mutex_t fc_lock;
49 ulp_fc_mgr_init(struct bnxt_ulp_context *ctxt);
52 * Release all resources in the flow counter manager for this ulp context
54 * ctxt [in] The ulp context for the flow counter manager
57 ulp_fc_mgr_deinit(struct bnxt_ulp_context *ctxt);
60 * Setup the Flow counter timer thread that will fetch/accumulate raw counter
61 * data from the chip's internal flow counters
63 * ctxt [in] The ulp context for the flow counter manager
66 ulp_fc_mgr_thread_start(struct bnxt_ulp_context *ctxt);
69 * Alarm handler that will issue the TF-Core API to fetch
70 * data from the chip's internal flow counters
72 * ctxt [in] The ulp context for the flow counter manager
75 ulp_fc_mgr_alarm_cb(void *arg);
78 * Cancel the alarm handler
80 * ctxt [in] The ulp context for the flow counter manager
83 void ulp_fc_mgr_thread_cancel(struct bnxt_ulp_context *ctxt);
86 * Set the starting index that indicates the first HW flow
89 * ctxt [in] The ulp context for the flow counter manager
91 * dir [in] The direction of the flow
93 * start_idx [in] The HW flow counter ID
96 int ulp_fc_mgr_start_idx_set(struct bnxt_ulp_context *ctxt, enum tf_dir dir,
100 * Set the corresponding SW accumulator table entry based on
101 * the difference between this counter ID and the starting
102 * counter ID. Also, keep track of num of active counter enabled
105 * ctxt [in] The ulp context for the flow counter manager
107 * dir [in] The direction of the flow
109 * hw_cntr_id [in] The HW flow counter ID
112 int ulp_fc_mgr_cntr_set(struct bnxt_ulp_context *ctxt, enum tf_dir dir,
113 uint32_t hw_cntr_id);
115 * Reset the corresponding SW accumulator table entry based on
116 * the difference between this counter ID and the starting
119 * ctxt [in] The ulp context for the flow counter manager
121 * dir [in] The direction of the flow
123 * hw_cntr_id [in] The HW flow counter ID
126 int ulp_fc_mgr_cntr_reset(struct bnxt_ulp_context *ctxt, enum tf_dir dir,
127 uint32_t hw_cntr_id);
129 * Check if the starting HW counter ID value is set in the
130 * flow counter manager.
132 * ctxt [in] The ulp context for the flow counter manager
134 * dir [in] The direction of the flow
137 bool ulp_fc_mgr_start_idx_isset(struct bnxt_ulp_context *ctxt, enum tf_dir dir);
140 * Check if the alarm thread that walks through the flows is started
142 * ctxt [in] The ulp context for the flow counter manager
146 bool ulp_fc_mgr_thread_isstarted(struct bnxt_ulp_context *ctxt);
148 #endif /* _ULP_FC_MGR_H_ */