* @brief Updates queue average in condition when queue is empty * * Note: packet is never dropped in this particular case. * * @param red_cfg [in] config pointer to a RED configuration parameter structure * @param red [in,out] data pointer to RED runtime data * @param time [in] current time stamp * * @return Operation status * @retval 0 enqueue the packet * @retval 1 drop the packet base
| 193 | * @retval 2 drop the packet based on mark probability criterion |
| 194 | */ |
| 195 | static inline int |
| 196 | rte_red_enqueue_empty(const struct rte_red_config *red_cfg, |
| 197 | struct rte_red *red, |
| 198 | const uint64_t time) |
| 199 | { |
| 200 | uint64_t time_diff = 0, m = 0; |
| 201 | |
| 202 | RTE_ASSERT(red_cfg != NULL); |
| 203 | RTE_ASSERT(red != NULL); |
| 204 | |
| 205 | red->count ++; |
| 206 | |
| 207 | /** |
| 208 | * We compute avg but we don't compare avg against |
| 209 | * min_th or max_th, nor calculate drop probability |
| 210 | */ |
| 211 | time_diff = time - red->q_time; |
| 212 | |
| 213 | /** |
| 214 | * m is the number of packets that might have arrived while the queue was empty. |
| 215 | * In this case we have time stamps provided by scheduler in byte units (bytes |
| 216 | * transmitted on network port). Such time stamp translates into time units as |
| 217 | * port speed is fixed but such approach simplifies the code. |
| 218 | */ |
| 219 | m = time_diff / RTE_RED_S; |
| 220 | |
| 221 | /** |
| 222 | * Check that m will fit into 16-bit unsigned integer |
| 223 | */ |
| 224 | if (m >= RTE_RED_2POW16) { |
| 225 | red->avg = 0; |
| 226 | } else { |
| 227 | red->avg = (red->avg >> RTE_RED_SCALING) * __rte_red_calc_qempty_factor(red_cfg->wq_log2, (uint16_t) m); |
| 228 | } |
| 229 | |
| 230 | return 0; |
| 231 | } |
| 232 | |
| 233 | /** |
| 234 | * Drop probability (Sally Floyd and Van Jacobson): |
no test coverage detected