OK, what about something like this:
vnet_hw_interface_t * host_intf = vnet_get_sup_hw_interface (vnm, sw_if_index);
vlib_frame_t *to_frame = vlib_get_frame_to_node (vm, node_index);
vlib_frame_t *host_if_frame = vlib_get_frame_to_node(vm,
host_intf->tx_node_index);
u32 *to_next = vlib_frame_vector_args (to_frame);
u32 *intf_host_to_next = vlib_frame_vector_args (host_if_frame);
while (n_left_from > 0)
{
u32 cbi0[2];
u16 n_cloned = vlib_buffer_clone (vm, from]0], &cbi0, 2,
VLIB_BUFFER_CLONE_HEAD_SIZE);
to_next[0] = cbi0[0];
intf_host_to_next[0] = cbi0[1];
// check n_cloned == 2
from++;
to_next++;
intf_host_to_next++;
n_left_from--;
}
host_if_frame->n_vectors = from_frame->n_vectors; // adjust if check n_cloned
== 2 fails
to_frame->n_vectors = from_frame->n_vectors;; // adjust if check n_cloned == 2
fails
vlib_put_frame_to_node (vm, host_interface_node_index, host_if_frame);
vlib_put_frame_to_node (vm, node_index, to_frame);
return from_frame->n_vectors;
> On 08.04.2021., at 15:05, David Gohberg <[email protected]> wrote:
>
> > why do you need to open host_if_frame for each packet
>
> If you refer to the fact that I can just create one frame outside the loop,
> you are correct :).
> I tried to get the code to the simplest working example that will correctly
> mirror the packets so I started to "dumb down" things :) I'm aware
> that it is not efficient.
>
> > why do you use vlib_get_frame_to_node instead of simply registering next
> > indices like 99% of VPP nodes are doing….
>
> I followed this code example from the documentation:
> https://fdio-vpp.readthedocs.io/en/latest/gettingstarted/developers/vnet.html?highlight=quad#enqueueing-packets-for-lookup-and-transmission
> Is there a better way of doing this?
>
>
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#19152): https://lists.fd.io/g/vpp-dev/message/19152
Mute This Topic: https://lists.fd.io/mt/81938105/21656
Group Owner: [email protected]
Unsubscribe: https://lists.fd.io/g/vpp-dev/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-