| 134 | } |
| 135 | |
| 136 | static int |
| 137 | kni_process_tx(uint16_t port_id, __rte_unused uint16_t queue_id, |
| 138 | struct rte_mbuf **pkts_burst, unsigned count) |
| 139 | { |
| 140 | /* read packet from kni ring(phy port) and transmit to kni */ |
| 141 | uint16_t nb_tx, nb_to_tx, nb_kni_tx = 0; |
| 142 | nb_tx = rte_ring_dequeue_burst(kni_rp[port_id], (void **)pkts_burst, count, NULL); |
| 143 | |
| 144 | /* |
| 145 | * The total ratelimit forwarded to the kernel, may a few more packets being sent, but it doesn’t matter, |
| 146 | * If there are too many processes, there is also the possibility that the control packet will be ratelimited. |
| 147 | */ |
| 148 | if (ff_global_cfg.kni.kernel_packets_ratelimit) { |
| 149 | if (likely(kni_rate_limt.kernel_packets < (uint64_t)ff_global_cfg.kni.kernel_packets_ratelimit)) { |
| 150 | nb_to_tx = nb_tx; |
| 151 | } else { |
| 152 | nb_to_tx = 0; |
| 153 | } |
| 154 | kni_rate_limt.kernel_packets += nb_tx; |
| 155 | } else { |
| 156 | nb_to_tx = nb_tx; |
| 157 | } |
| 158 | |
| 159 | nb_kni_tx = rte_eth_tx_burst(kni_stat[port_id]->port_id, 0, pkts_burst, nb_to_tx); |
| 160 | |
| 161 | if(nb_kni_tx < nb_tx) { |
| 162 | uint16_t i; |
| 163 | for(i = nb_kni_tx; i < nb_tx; ++i) |
| 164 | rte_pktmbuf_free(pkts_burst[i]); |
| 165 | |
| 166 | kni_stat[port_id]->rx_dropped += (nb_tx - nb_kni_tx); |
| 167 | } |
| 168 | |
| 169 | kni_stat[port_id]->rx_packets += nb_kni_tx; |
| 170 | return 0; |
| 171 | } |
| 172 | |
| 173 | static int |
| 174 | kni_process_rx(uint16_t port_id, uint16_t queue_id, |
no test coverage detected