NVIDIA DOCA SDK Data Center on a Chip Framework Documentation
rtt_template.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2023 NVIDIA CORPORATION AND AFFILIATES. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without modification, are permitted
5  * provided that the following conditions are met:
6  * * Redistributions of source code must retain the above copyright notice, this list of
7  * conditions and the following disclaimer.
8  * * Redistributions in binary form must reproduce the above copyright notice, this list of
9  * conditions and the following disclaimer in the documentation and/or other materials
10  * provided with the distribution.
11  * * Neither the name of the NVIDIA CORPORATION nor the names of its contributors may be used
12  * to endorse or promote products derived from this software without specific prior written
13  * permission.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
16  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17  * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NVIDIA CORPORATION BE LIABLE
18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
19  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
20  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
21  * STRICT LIABILITY, OR TOR (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
22  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23  *
24  */
25 
26 #include <doca_pcc_dev.h>
27 #include <doca_pcc_dev_event.h>
29 
30 #include "utils.h"
31 #include "rtt_template_ctxt.h"
33 #include "rtt_template.h"
34 
35 #pragma clang diagnostic ignored "-Wunused-parameter"
36 
37 /* Algorithm parameters are defined in rtt_template_algo_params.h */
38 
39 /* Define the constants */
40 #define FF32BIT (0xffffffff)
41 #define DEC_FACTOR ((1 << 16) - param[RTT_TEMPLATE_UPDATE_FACTOR]) /* Rate decrease factor */
42 #define CNP_DEC_FACTOR ((1 << 16) - 2 * param[RTT_TEMPLATE_UPDATE_FACTOR]) /* CNP rate decrease factor */
43 #define NACK_DEC_FACTOR ((1 << 16) - 5 * param[RTT_TEMPLATE_UPDATE_FACTOR]) /* NACK rate decrease factor */
44 #define ABORT_TIME (300000) /* The time to abort rtt_req - in nanosec */
45 #define BW_MB_DEFAULT_FXP16 (BW_MB_DEFAULT << 16) /* Default BW in fixed point */
46 #define NP_RX_RATE_TH (58982) /* Threshold to update current rate according to NP RX rate. 0.9 in 16b fixed point */
47 #define HIGH_UTIL_THRESHOLD (55704) /* 0.85 in 16b fixed point */
48 #define HIGH_UTIL_DEC_FACTOR \
49  ((1 << 16) - 2 * param[RTT_TEMPLATE_UPDATE_FACTOR]) /* Rate decrease factor in high port utilization mode */
50 #define HIGH_UTIL_CNP_DEC_FACTOR \
51  ((1 << 16) - 4 * param[RTT_TEMPLATE_UPDATE_FACTOR]) /* CNP rate decrease factor in high port utilization mode \
52  */
53 #define HIGH_UTIL_NACK_DEC_FACTOR \
54  ((1 << 16) - 10 * param[RTT_TEMPLATE_UPDATE_FACTOR]) /* NACK rate decrease factor in high port utilization \
55  mode */
56 
57 typedef enum {
58  RTT_TEMPLATE_UPDATE_FACTOR = 0, /* configurable parameter of update factor */
59  RTT_TEMPLATE_AI = 1, /* configurable parameter of AI */
60  RTT_TEMPLATE_BASE_RTT = 2, /* configurable parameter of base rtt */
61  RTT_TEMPLATE_NEW_FLOW_RATE = 3, /* configurable parameter of new flow rate */
62  RTT_TEMPLATE_MIN_RATE = 4, /* configurable parameter of min rate */
63  RTT_TEMPLATE_MAX_DELAY = 5, /* configurable parameter of max delay */
64  RTT_TEMPLATE_PARAM_NUM /* Maximal number of configurable parameters */
66 
67 enum {
68  RTT_TEMPLATE_COUNTER_TX_EVENT = 0, /* tx event for rtt template user algorithm */
69  RTT_TEMPLATE_COUNTER_RTT_EVENT = 1, /* rtt event for rtt template user algorithm */
70  RTT_TEMPLATE_COUNTER_NUM /* Maximal number of counters */
72 
73 const volatile char rtt_template_desc[] = "Rtt template v0.1";
74 static const volatile char rtt_template_param_update_factor_desc[] = "UPDATE_FACTOR, update factor";
75 static const volatile char rtt_template_param_ai_desc[] = "AI, ai";
76 static const volatile char rtt_template_param_base_rtt_desc[] = "BASE_RTT, base rtt";
77 static const volatile char rtt_template_param_new_flow_rate_desc[] = "NEW_FLOW_RATE, new flow rate";
78 static const volatile char rtt_template_param_min_rate_desc[] = "MIN_RATE, min rate";
79 static const volatile char rtt_template_param_max_delay_desc[] = "MAX_DELAY, max delay";
80 static const volatile char rtt_template_counter_tx_desc[] = "COUNTER_TX_EVENT, number of tx events handled";
81 static const volatile char rtt_template_counter_rtt_desc[] = "COUNTER_RTT_EVENT, number of rtt events handled";
82 
83 void rtt_template_init(uint32_t algo_idx)
84 {
85  struct doca_pcc_dev_algo_meta_data algo_def = {0};
86 
87  algo_def.algo_id = 0xBFFF;
88  algo_def.algo_major_version = 0x00;
89  algo_def.algo_minor_version = 0x01;
90  algo_def.algo_desc_size = sizeof(rtt_template_desc);
91  algo_def.algo_desc_addr = (uint64_t)rtt_template_desc;
92 
93  uint32_t total_param_num = RTT_TEMPLATE_PARAM_NUM;
94  uint32_t total_counter_num = RTT_TEMPLATE_COUNTER_NUM;
95  uint32_t param_num = 0;
96  uint32_t counter_num = 0;
97 
98  doca_pcc_dev_algo_init_metadata(algo_idx, &algo_def, total_param_num, total_counter_num);
99 
101  param_num++,
104  1,
105  1,
109  param_num++,
110  AI,
111  AI_MAX,
112  1,
113  1,
115  (uint64_t)rtt_template_param_ai_desc);
117  param_num++,
118  BASE_RTT,
119  UINT32_MAX,
120  1,
121  1,
125  param_num++,
127  RATE_MAX,
128  1,
129  1,
133  param_num++,
134  MIN_RATE,
135  RATE_MAX,
136  1,
137  1,
141  param_num++,
142  MAX_DELAY,
143  UINT32_MAX,
144  1,
145  1,
148 
150  counter_num++,
151  UINT32_MAX,
152  2,
154  (uint64_t)rtt_template_counter_tx_desc);
156  counter_num++,
157  UINT32_MAX,
158  2,
161 }
162 
163 /*
164  * Entry point to core function of algorithm (reference code)
165  * This function adjusts rate based on CC events.
166  * It calculates the new rate parameters based on flow context data, rtt info and current rate.
167  *
168  * @ccctx [in]: A pointer to a flow context data retrieved by libpcc.
169  * @rtt [in]: The value of rtt.
170  * @cur_rate [in]: Current rate value
171  * @param [in]: A pointer to an array of parameters that are used to control algo behavior
172  * @is_high_util [in]: Flag to indicate if the port is in high utilization mode
173  * @norm_np_rx_rate [in]: Notification Point RX rate normalized in fxp
174  * @return: The new calculated rate value
175  */
176 static inline uint32_t algorithm_core(cc_ctxt_rtt_template_t *ccctx,
177  uint32_t rtt,
178  uint32_t cur_rate,
179  uint32_t *param,
180  uint8_t is_high_util,
181  uint32_t norm_np_rx_rate)
182 {
183  /* ##### Put your algorithm code in here #### */
184 
185  /* Example */
186  if (ccctx->flags.was_nack && (rtt >= param[RTT_TEMPLATE_MAX_DELAY])) {
187  /* NACK */
188  cur_rate = doca_pcc_dev_fxp_mult(is_high_util ? HIGH_UTIL_NACK_DEC_FACTOR : NACK_DEC_FACTOR, cur_rate);
189  ccctx->flags.was_nack = 0;
190  } else if (ccctx->flags.was_cnp || (rtt >= param[RTT_TEMPLATE_MAX_DELAY])) {
191  /* CNP */
192  cur_rate = doca_pcc_dev_fxp_mult(is_high_util ? HIGH_UTIL_CNP_DEC_FACTOR : CNP_DEC_FACTOR, cur_rate);
193  ccctx->flags.was_cnp = 0;
194  } else {
195  /* RTT */
196  if (rtt > param[RTT_TEMPLATE_BASE_RTT])
197  cur_rate = doca_pcc_dev_fxp_mult(is_high_util ? HIGH_UTIL_DEC_FACTOR : DEC_FACTOR, cur_rate);
198  else {
199 #ifdef DOCA_PCC_NP_RX_RATE
200  if (norm_np_rx_rate < NP_RX_RATE_TH) {
201  uint32_t inc_factor = doca_pcc_dev_fxp_recip(norm_np_rx_rate);
202  cur_rate = doca_pcc_dev_fxp_mult(inc_factor, cur_rate);
203  } else
204  cur_rate += param[RTT_TEMPLATE_AI];
205 #else
206  cur_rate += param[RTT_TEMPLATE_AI];
207 #endif
208  }
209  }
210 
211  if (cur_rate > DOCA_PCC_DEV_MAX_RATE)
212  cur_rate = DOCA_PCC_DEV_MAX_RATE;
213 
214  if (cur_rate < param[RTT_TEMPLATE_MIN_RATE])
215  cur_rate = param[RTT_TEMPLATE_MIN_RATE];
216  /* End of example */
217 
218  return cur_rate;
219 }
220 
221 /*
222  * Entry point to rtt template to handle roce tx event (reference code)
223  * This function updates flags for rtt measurement or re-send rtt_req if needed.
224  * It calculates the new rate parameters based on flow context data, event info and current rate.
225  *
226  * @event [in]: A pointer to an event data structure to be passed to extractor functions
227  * @cur_rate [in]: Current rate value
228  * @ccctx [in/out]: A pointer to a flow context data retrieved by libpcc.
229  * @results [out]: A pointer to result struct to update rate in HW.
230  */
231 static inline void rtt_template_handle_roce_tx(doca_pcc_dev_event_t *event,
232  uint32_t cur_rate,
233  cc_ctxt_rtt_template_t *ccctx,
234  doca_pcc_dev_results_t *results)
235 {
236  uint8_t rtt_req = 0;
237  uint32_t rtt_meas_psn = ccctx->rtt_meas_psn;
238  uint32_t timestamp = doca_pcc_dev_get_timestamp(event);
240 
241  if (unlikely((ev_attr.flags & DOCA_PCC_DEV_TX_FLAG_RTT_REQ_SENT) && (rtt_meas_psn == 0))) {
242  ccctx->rtt_meas_psn = 1;
243  ccctx->rtt_req_to_rtt_sent = 0;
244  ccctx->start_delay = timestamp;
245  } else {
246  /* Calculate rtt_till_now */
247  uint32_t rtt_till_now = (timestamp - ccctx->start_delay);
248 
249  if (unlikely(ccctx->start_delay > timestamp))
250  rtt_till_now += UINT32_MAX;
251  /* Abort RTT request flow - for cases event or packet was dropped */
252  if (rtt_meas_psn == 0) {
253  rtt_till_now = 0;
254  ccctx->rtt_req_to_rtt_sent += 1;
255  }
256  if (unlikely((rtt_till_now > ((uint32_t)ABORT_TIME << ccctx->abort_cnt)) ||
257  (ccctx->rtt_req_to_rtt_sent > 2))) {
258  rtt_req = 1;
259  if (rtt_till_now > ((uint32_t)ABORT_TIME << ccctx->abort_cnt))
260  ccctx->abort_cnt += 1;
261  ccctx->rtt_req_to_rtt_sent = 1;
262  }
263  }
264 
265  /* Update results buffer and context */
266  ccctx->cur_rate = cur_rate;
267  results->rate = cur_rate;
268  results->rtt_req = rtt_req;
269 }
270 
271 /*
272  * Entry point to rtt template to handle roce rtt event (reference code)
273  * This function calculates the rtt and calls core function to adjust rate.
274  * It calculates the new rate parameters based on flow context data, event info and current rate.
275  *
276  * @event [in]: A pointer to an event data structure to be passed to extractor functions
277  * @cur_rate [in]: Current rate value
278  * @param [in]: A pointer to an array of parameters that are used to control algo behavior
279  * @ccctx [in/out]: A pointer to a flow context data retrieved by libpcc.
280  * @results [out]: A pointer to result struct to update rate in HW.
281  */
282 static inline void rtt_template_handle_roce_rtt(doca_pcc_dev_event_t *event,
283  uint32_t cur_rate,
284  uint32_t *param,
285  cc_ctxt_rtt_template_t *ccctx,
286  doca_pcc_dev_results_t *results)
287 {
288  /*
289  * Check that this RTT event is the one we are waiting for.
290  * For cases we re-send RTT request by mistake due to abort flow for example.
291  */
292  uint32_t rtt_meas_psn = ccctx->rtt_meas_psn;
293 
294  if (unlikely(((rtt_meas_psn == 0) && (ccctx->rtt_req_to_rtt_sent == 0)))) {
295  results->rate = cur_rate;
296  results->rtt_req = 0;
297  return;
298  }
299 
300  /* We got RTT measurement */
301  /* Reset variables */
302  ccctx->rtt_meas_psn = 0;
303  ccctx->abort_cnt = 0;
304 
305  /* RTT calculation */
306 #ifdef DOCA_PCC_NP_RX_RATE
307  unsigned char *rtt_raw_data = doca_pcc_dev_get_rtt_raw_data(event);
308  uint32_t start_rtt = *((uint32_t *)(rtt_raw_data));
309 #else
310  uint32_t start_rtt = doca_pcc_dev_get_rtt_req_send_timestamp(event);
311 #endif
312 #ifdef TIME_SYNC
313  /* if there is a time sync between the nodes we can get one way delay */
314  uint32_t end_rtt = doca_pcc_dev_get_rtt_req_recv_timestamp(event);
315 #else
316  uint32_t end_rtt = doca_pcc_dev_get_timestamp(event);
317 #endif /* TIME_SYNC */
318  int32_t rtt = end_rtt - start_rtt;
319 
320  if (unlikely(end_rtt < start_rtt))
321  rtt += UINT32_MAX;
322  ccctx->rtt = rtt;
323 
324  /* Call to the core of the CC algorithm */
325 
326 #ifdef DOCA_PCC_SAMPLE_TX_BYTES
327  uint8_t is_high_tx_util =
328  (rtt_get_last_tx_port_util(doca_pcc_dev_get_ev_attr(event).port_num) > HIGH_UTIL_THRESHOLD);
329 #else
330  uint8_t is_high_tx_util = 0;
331 #endif
332 
333 #ifdef DOCA_PCC_NP_RX_RATE
334  uint32_t norm_np_rx_rate = (1 << 16);
335  uint32_t np_rx_bytes = *((uint32_t *)(rtt_raw_data + 4));
336  uint32_t delta_np_rx_bytes = np_rx_bytes - ccctx->last_np_rx_bytes;
337  if (ccctx->last_np_rx_bytes > np_rx_bytes) {
338  delta_np_rx_bytes += FF32BIT;
339  }
340  ccctx->last_np_rx_bytes = np_rx_bytes;
341  uint32_t delta_np_rx_256bytes = delta_np_rx_bytes >> 8;
342 
343  uint32_t np_rx_bytes_timestamp_us = *((uint32_t *)(rtt_raw_data + 8));
344  uint32_t delta_np_rx_bytes_timestamp_us = np_rx_bytes_timestamp_us - ccctx->last_np_rx_bytes_timestamp_us;
345  if (ccctx->last_np_rx_bytes_timestamp_us > np_rx_bytes_timestamp_us) {
346  delta_np_rx_bytes_timestamp_us += FF32BIT;
347  }
348  ccctx->last_np_rx_bytes_timestamp_us = np_rx_bytes_timestamp_us;
349 
350  // np_rate unit is MBps
351  uint32_t np_rx_rate =
352  doca_pcc_dev_mult(delta_np_rx_256bytes, doca_pcc_dev_fxp_recip(delta_np_rx_bytes_timestamp_us)) >>
353  8; // fxp16 Gbps
354 
355  if (np_rx_rate < BW_MB_DEFAULT_FXP16)
356  norm_np_rx_rate = doca_pcc_dev_mult(np_rx_rate, doca_pcc_dev_fxp_recip(BW_MB_DEFAULT)) >> 32;
357 #else
358  uint32_t norm_np_rx_rate = (1 << 16);
359 #endif
360 
361  cur_rate = algorithm_core(ccctx, rtt, cur_rate, param, is_high_tx_util, norm_np_rx_rate);
362 
363  ccctx->rtt_req_to_rtt_sent = 1;
364  ccctx->cur_rate = cur_rate;
365  results->rate = cur_rate;
366  results->rtt_req = 1;
367 }
368 
369 /*
370  * Entry point to rtt template to handle roce cnp events (reference code)
371  * This function puts the code for immediate reaction to CNPs.
372  * It calculates the new rate parameters based on flow context data, event info and current rate.
373  *
374  * @event [in]: A pointer to an event data structure to be passed to extractor functions
375  * @cur_rate [in]: Current rate value
376  * @ccctx [in/out]: A pointer to a flow context data retrieved by libpcc.
377  * @results [out]: A pointer to result struct to update rate in HW.
378  */
379 static inline void rtt_template_handle_roce_cnp(doca_pcc_dev_event_t *event,
380  uint32_t cur_rate,
381  cc_ctxt_rtt_template_t *ccctx,
382  doca_pcc_dev_results_t *results)
383 {
384  ccctx->flags.was_cnp = 1;
385 
386  /* ###### You can put the code for immediate reaction to CNPs ####### */
387  /*
388  * e.g:
389  * cur_rate =
390  */
391  results->rtt_req = 0;
392  results->rate = cur_rate;
393  ccctx->cur_rate = cur_rate;
394 }
395 
396 /*
397  * Entry point to rtt template to handle roce nack events (reference code)
398  * This function puts the code for immediate reaction to NACKs.
399  * It calculates the new rate parameters based on flow context data, event info and current rate.
400  *
401  * @event [in]: A pointer to an event data structure to be passed to extractor functions
402  * @cur_rate [in]: Current rate value
403  * @ccctx [in]: A pointer to a flow context data retrieved by libpcc.
404  * @results [out]: A pointer to result struct to update rate in HW.
405  */
406 static inline void rtt_template_handle_roce_nack(doca_pcc_dev_event_t *event,
407  uint32_t cur_rate,
408  cc_ctxt_rtt_template_t *ccctx,
409  doca_pcc_dev_results_t *results)
410 {
411  ccctx->flags.was_nack = 1;
412  results->rate = cur_rate;
413  ccctx->cur_rate = cur_rate;
414 }
415 
416 /*
417  * Entry point to rtt template to handle new flow (reference code)
418  * This function initializes the flow context.
419  * It calculates the new rate parameters based on flow context data, event info and current rate.
420  *
421  * @event [in]: A pointer to an event data structure to be passed to extractor functions
422  * @cur_rate [in]: Current rate value
423  * @param [in]: A pointer to an array of parameters that are used to control algo behavior
424  * @ccctx [in/out]: A pointer to a flow context data retrieved by libpcc.
425  * @results [out]: A pointer to result struct to update rate in HW.
426  */
427 static inline void rtt_template_handle_new_flow(doca_pcc_dev_event_t *event,
428  uint32_t cur_rate,
429  uint32_t *param,
430  cc_ctxt_rtt_template_t *ccctx,
431  doca_pcc_dev_results_t *results)
432 {
433  ccctx->cur_rate = param[RTT_TEMPLATE_NEW_FLOW_RATE];
434  ccctx->start_delay = doca_pcc_dev_get_timestamp(event);
435  ccctx->rtt_meas_psn = 0;
436  ccctx->rtt_req_to_rtt_sent = 1;
437  ccctx->abort_cnt = 0;
438  ccctx->flags.was_nack = 0;
439  results->rate = param[RTT_TEMPLATE_NEW_FLOW_RATE];
440  results->rtt_req = 1;
441 }
442 
444  uint32_t *param,
445  uint32_t *counter,
446  doca_pcc_dev_algo_ctxt_t *algo_ctxt,
447  doca_pcc_dev_results_t *results)
448 {
449  cc_ctxt_rtt_template_t *rtt_template_ctx = (cc_ctxt_rtt_template_t *)algo_ctxt;
451  uint32_t ev_type = ev_attr.ev_type;
452  uint32_t cur_rate = rtt_template_ctx->cur_rate;
453 
454  if (unlikely(cur_rate == 0)) {
455  rtt_template_handle_new_flow(event, cur_rate, param, rtt_template_ctx, results);
456  } else if (ev_type == DOCA_PCC_DEV_EVNT_ROCE_TX) {
457  rtt_template_handle_roce_tx(event, cur_rate, rtt_template_ctx, results);
458  /* Example code to update counter */
459  if (counter != NULL)
461  } else if (ev_type == DOCA_PCC_DEV_EVNT_RTT) {
462  rtt_template_handle_roce_rtt(event, cur_rate, param, rtt_template_ctx, results);
463  /* Example code to update counter */
464  if (counter != NULL)
466  } else if (ev_type == DOCA_PCC_DEV_EVNT_ROCE_CNP) {
467  rtt_template_handle_roce_cnp(event, cur_rate, rtt_template_ctx, results);
468  } else if (ev_type == DOCA_PCC_DEV_EVNT_ROCE_NACK) {
469  rtt_template_handle_roce_nack(event, cur_rate, rtt_template_ctx, results);
470  } else {
471  results->rate = cur_rate;
472  results->rtt_req = 0;
473  }
474 }
475 
477  uint32_t param_num,
478  const uint32_t *new_param_values,
479  uint32_t *params)
480 {
481  /* Example */
482  if ((param_num > RTT_TEMPLATE_PARAM_NUM) || (param_id_base >= RTT_TEMPLATE_PARAM_NUM))
484 
485  if ((new_param_values == NULL) || (params == NULL))
487 
488  return DOCA_PCC_DEV_STATUS_OK;
489  /* End of example */
490 }
#define NULL
Definition: __stddef_null.h:26
doca_telemetry_exporter_timestamp_t timestamp
#define unlikely(x)
Definition: utils.h:42
DOCA_STABLE doca_pcc_dev_error_t doca_pcc_dev_algo_init_counter(uint32_t algo_idx, uint32_t counter_id, uint32_t max_value, uint32_t permissions, uint32_t counter_desc_size, uint64_t counter_desc_addr)
Initialize a single counter for an algo.
DOCA_STABLE doca_pcc_dev_error_t doca_pcc_dev_algo_init_param(uint32_t algo_idx, uint32_t param_id, uint32_t default_value, uint32_t max_value, uint32_t min_value, uint32_t permissions, uint32_t param_desc_size, uint64_t param_desc_addr)
Initialize a single parameter for an algo.
DOCA_STABLE doca_pcc_dev_error_t doca_pcc_dev_algo_init_metadata(uint32_t algo_idx, const struct doca_pcc_dev_algo_meta_data *user_def, uint32_t param_num, uint32_t counter_num)
Initialize the algo database.
doca_pcc_dev_error_t
API functions return status.
@ DOCA_PCC_DEV_STATUS_OK
@ DOCA_PCC_DEV_STATUS_FAIL
DOCA_STABLE FORCE_INLINE uint32_t doca_pcc_dev_get_rtt_req_recv_timestamp(doca_pcc_dev_event_t *event)
For RTT events only, the time when RTT request is received.
DOCA_EXPERIMENTAL FORCE_INLINE unsigned char * doca_pcc_dev_get_rtt_raw_data(doca_pcc_dev_event_t *event)
Returns the user defined event data.
DOCA_STABLE FORCE_INLINE uint32_t doca_pcc_dev_get_rtt_req_send_timestamp(doca_pcc_dev_event_t *event)
For RTT events only, the time when RTT request is sent.
DOCA_STABLE FORCE_INLINE doca_pcc_dev_event_general_attr_t doca_pcc_dev_get_ev_attr(doca_pcc_dev_event_t *event)
For all events, return structure with general information such as event type, subtype,...
DOCA_STABLE FORCE_INLINE uint32_t doca_pcc_dev_get_timestamp(doca_pcc_dev_event_t *event)
For all events, timestamp of this event.
#define doca_pcc_dev_mult(a, b)
mult wrapper
#define doca_pcc_dev_fxp_recip(a_fp)
fixed point 16b reciprocal
#define doca_pcc_dev_fxp_mult(a, b)
fixed point 16b mult
#define DOCA_PCC_DEV_TX_FLAG_RTT_REQ_SENT
TX Flag: RTT packet sent.
Definition: doca_pcc_dev.h:99
#define DOCA_PCC_DEV_MAX_RATE
Max rate in rate limiter fixed point.
Definition: doca_pcc_dev.h:109
@ DOCA_PCC_DEV_EVNT_ROCE_TX
Definition: doca_pcc_dev.h:49
@ DOCA_PCC_DEV_EVNT_ROCE_CNP
Definition: doca_pcc_dev.h:48
@ DOCA_PCC_DEV_EVNT_ROCE_NACK
Definition: doca_pcc_dev.h:51
@ DOCA_PCC_DEV_EVNT_RTT
Definition: doca_pcc_dev.h:52
@ RTT_TEMPLATE_COUNTER_RTT_EVENT
Definition: rtt_template.c:67
@ RTT_TEMPLATE_COUNTER_NUM
Definition: rtt_template.c:68
@ RTT_TEMPLATE_COUNTER_TX_EVENT
Definition: rtt_template.c:66
#define NACK_DEC_FACTOR
Definition: rtt_template.c:43
static void rtt_template_handle_roce_rtt(doca_pcc_dev_event_t *event, uint32_t cur_rate, uint32_t *param, cc_ctxt_rtt_template_t *ccctx, doca_pcc_dev_results_t *results)
Definition: rtt_template.c:280
#define ABORT_TIME
Definition: rtt_template.c:44
rtt_template_params_t
Definition: rtt_template.c:55
@ RTT_TEMPLATE_BASE_RTT
Definition: rtt_template.c:58
@ RTT_TEMPLATE_UPDATE_FACTOR
Definition: rtt_template.c:56
@ RTT_TEMPLATE_NEW_FLOW_RATE
Definition: rtt_template.c:59
@ RTT_TEMPLATE_MIN_RATE
Definition: rtt_template.c:60
@ RTT_TEMPLATE_AI
Definition: rtt_template.c:57
@ RTT_TEMPLATE_PARAM_NUM
Definition: rtt_template.c:62
@ RTT_TEMPLATE_MAX_DELAY
Definition: rtt_template.c:61
#define HIGH_UTIL_DEC_FACTOR
Definition: rtt_template.c:48
const volatile char rtt_template_desc[]
Definition: rtt_template.c:71
#define BW_MB_DEFAULT_FXP16
Definition: rtt_template.c:45
#define NP_RX_RATE_TH
Definition: rtt_template.c:46
#define DEC_FACTOR
Definition: rtt_template.c:41
#define FF32BIT
Definition: rtt_template.c:40
#define HIGH_UTIL_NACK_DEC_FACTOR
Definition: rtt_template.c:52
void rtt_template_algo(doca_pcc_dev_event_t *event, uint32_t *param, uint32_t *counter, doca_pcc_dev_algo_ctxt_t *algo_ctxt, doca_pcc_dev_results_t *results)
Definition: rtt_template.c:441
static const volatile char rtt_template_param_min_rate_desc[]
Definition: rtt_template.c:76
static const volatile char rtt_template_counter_tx_desc[]
Definition: rtt_template.c:78
#define HIGH_UTIL_THRESHOLD
Definition: rtt_template.c:47
static void rtt_template_handle_roce_cnp(doca_pcc_dev_event_t *event, uint32_t cur_rate, cc_ctxt_rtt_template_t *ccctx, doca_pcc_dev_results_t *results)
Definition: rtt_template.c:377
static const volatile char rtt_template_param_ai_desc[]
Definition: rtt_template.c:73
#define CNP_DEC_FACTOR
Definition: rtt_template.c:42
static void rtt_template_handle_roce_nack(doca_pcc_dev_event_t *event, uint32_t cur_rate, cc_ctxt_rtt_template_t *ccctx, doca_pcc_dev_results_t *results)
Definition: rtt_template.c:404
static void rtt_template_handle_new_flow(doca_pcc_dev_event_t *event, uint32_t cur_rate, uint32_t *param, cc_ctxt_rtt_template_t *ccctx, doca_pcc_dev_results_t *results)
Definition: rtt_template.c:425
static void rtt_template_handle_roce_tx(doca_pcc_dev_event_t *event, uint32_t cur_rate, cc_ctxt_rtt_template_t *ccctx, doca_pcc_dev_results_t *results)
Definition: rtt_template.c:229
static uint32_t algorithm_core(cc_ctxt_rtt_template_t *ccctx, uint32_t rtt, uint32_t cur_rate, uint32_t *param, uint8_t is_high_util, uint32_t norm_np_rx_rate)
Definition: rtt_template.c:174
doca_pcc_dev_error_t rtt_template_set_algo_params(uint32_t param_id_base, uint32_t param_num, const uint32_t *new_param_values, uint32_t *params)
Definition: rtt_template.c:474
enum @31 rtt_template_counter_t
static const volatile char rtt_template_counter_rtt_desc[]
Definition: rtt_template.c:79
static const volatile char rtt_template_param_update_factor_desc[]
Definition: rtt_template.c:72
static const volatile char rtt_template_param_max_delay_desc[]
Definition: rtt_template.c:77
#define HIGH_UTIL_CNP_DEC_FACTOR
Definition: rtt_template.c:50
static const volatile char rtt_template_param_base_rtt_desc[]
Definition: rtt_template.c:74
void rtt_template_init(uint32_t algo_idx)
Definition: rtt_template.c:81
static const volatile char rtt_template_param_new_flow_rate_desc[]
Definition: rtt_template.c:75
#define MAX_DELAY
#define MIN_RATE
#define UPDATE_FACTOR_MAX
#define NEW_FLOW_RATE
#define BASE_RTT
#define UPDATE_FACTOR
#define BW_MB_DEFAULT
#define AI
#define RATE_MAX
#define AI_MAX
rtt_template_flags_t flags
This struct provides meta data for a pcc user algo.
CC algorithm results.
Definition: doca_pcc_dev.h:69