On Wed, 23 Jul 2025, Stephen Hemminger wrote:

On Wed, 23 Jul 2025 06:13:27 +0400 (+04)
Ivan Malov <ivan.ma...@arknetworks.am> wrote:

 +static inline void
+eth_dev_mirror(uint16_t port_id, uint16_t queue_id, uint8_t direction,
+            struct rte_mbuf **pkts, uint16_t nb_pkts,
+            const struct rte_eth_mirror_conf *conf)
+{
+       struct rte_mbuf *tosend[RTE_MIRROR_BURST_SIZE];
+       unsigned int count = 0;
+       unsigned int i;
+
+       for (i = 0; i < nb_pkts; i++) {
+               struct rte_mbuf *m = pkts[i];
+               struct rte_mbuf *mc;
+
+               if (conf->flags & RTE_ETH_MIRROR_INDIRECT_FLAG) {
+                       mc = rte_pktmbuf_alloc(conf->mp);

Can 'rte_pktmbuf_alloc_bulk' be used prior to the 'for' loop? I do not insist.

+                       if (unlikely(mc == NULL))
+                               continue;
+
+                       /* Make both mbuf's point to the same data */
+                       rte_pktmbuf_attach(mc, m);
+               } else {
+                       mc = rte_pktmbuf_copy(m, conf->mp, 0, conf->snaplen);
+                       /* TODO: dropped stats? */
+                       if (unlikely(mc == NULL))
+                               continue;
+               }


Both sides could use a bulk allocated array, but would need new variant
of rte_pktmbuf_copy for that.

I see. I just meant may be something like this could be done before the loop.
if (conf->flags & RTE_ETH_MIRROR_INDIRECT_FLAG) {
    // do bulk alloc -> tosend
}
But OK, understood.

Thank you.


Reply via email to