| 50 | } |
| 51 | |
| 52 | uint16_t |
| 53 | sw_event_enqueue_burst(void *port, const struct rte_event ev[], uint16_t num) |
| 54 | { |
| 55 | int32_t i; |
| 56 | uint8_t new_ops[PORT_ENQUEUE_MAX_BURST_SIZE]; |
| 57 | struct sw_port *p = port; |
| 58 | struct sw_evdev *sw = (void *)p->sw; |
| 59 | uint32_t sw_inflights = rte_atomic32_read(&sw->inflights); |
| 60 | uint32_t credit_update_quanta = sw->credit_update_quanta; |
| 61 | int new = 0; |
| 62 | |
| 63 | if (num > PORT_ENQUEUE_MAX_BURST_SIZE) |
| 64 | num = PORT_ENQUEUE_MAX_BURST_SIZE; |
| 65 | |
| 66 | for (i = 0; i < num; i++) |
| 67 | new += (ev[i].op == RTE_EVENT_OP_NEW); |
| 68 | |
| 69 | if (unlikely(new > 0 && p->inflight_max < sw_inflights)) |
| 70 | return 0; |
| 71 | |
| 72 | if (p->inflight_credits < new) { |
| 73 | /* check if event enqueue brings port over max threshold */ |
| 74 | if (sw_inflights + credit_update_quanta > sw->nb_events_limit) |
| 75 | return 0; |
| 76 | |
| 77 | rte_atomic32_add(&sw->inflights, credit_update_quanta); |
| 78 | p->inflight_credits += (credit_update_quanta); |
| 79 | |
| 80 | /* If there are fewer inflight credits than new events, limit |
| 81 | * the number of enqueued events. |
| 82 | */ |
| 83 | num = (p->inflight_credits < new) ? p->inflight_credits : new; |
| 84 | } |
| 85 | |
| 86 | for (i = 0; i < num; i++) { |
| 87 | int op = ev[i].op; |
| 88 | int outstanding = p->outstanding_releases > 0; |
| 89 | const uint8_t invalid_qid = (ev[i].queue_id >= sw->qid_count); |
| 90 | |
| 91 | p->inflight_credits -= (op == RTE_EVENT_OP_NEW); |
| 92 | p->inflight_credits += (op == RTE_EVENT_OP_RELEASE) * |
| 93 | outstanding; |
| 94 | |
| 95 | new_ops[i] = sw_qe_flag_map[op]; |
| 96 | new_ops[i] &= ~(invalid_qid << QE_FLAG_VALID_SHIFT); |
| 97 | |
| 98 | /* FWD and RELEASE packets will both resolve to taken (assuming |
| 99 | * correct usage of the API), providing very high correct |
| 100 | * prediction rate. |
| 101 | */ |
| 102 | if ((new_ops[i] & QE_FLAG_COMPLETE) && outstanding) |
| 103 | p->outstanding_releases--; |
| 104 | |
| 105 | /* error case: branch to avoid touching p->stats */ |
| 106 | if (unlikely(invalid_qid && op != RTE_EVENT_OP_RELEASE)) { |
| 107 | p->stats.rx_dropped++; |
| 108 | p->inflight_credits++; |
| 109 | } |
no test coverage detected