Check out boilerplate examples of the form:

  vlib_buffer_t *bufs[VLIB_FRAME_SIZE], **b;
  u16 nexts[VLIB_FRAME_SIZE], *next;
  
  from = vlib_frame_vector_args (frame);
  n_left_from = frame->n_vectors;

  vlib_get_buffers (vm, from, bufs, n_left_from);
  b = bufs;
  next = nexts;

  while (n_left_from > 0)
    {
     <process b[0] or b[0..1] or b[0..3], set nexts[0..3], etc.> 

      b += 1 | 2 | 4;
      next += 1 | 2 | 4;
      n_left_from -= 1 | 2 | 4;
    }

  vlib_buffer_enqueue_to_next (vm, node, from, nexts, frame->n_vectors);

  return frame->n_vectors;

Damjan optimized the heck out of the buffer / frame / next handling code used 
in the example. 

The emacs-lisp boilerplate generator will cough up a working plugin skeleton of 
this form, if you answer "qs" when asked to pick a dispatch style. 

You'll probably be much happier using this pattern than trying to roll your own.

HTH... Dave

-----Original Message-----
From: Prashant Upadhyaya <praupadhy...@gmail.com> 
Sent: Monday, March 4, 2019 1:21 PM
To: Neale Ranns (nranns) <nra...@cisco.com>
Cc: Dave Barach (dbarach) <dbar...@cisco.com>; vpp-dev@lists.fd.io
Subject: Re: [vpp-dev] Regarding node on a feature arc

Hi Neale,

In one of the usecases I deviated from the normal boilerplate and started 
getting frames to target nodes with vlib_get_frame_to_node and doing put's to 
those, the advantage was that I could iterate through the entire input vector 
and queue up elements on frames of relevant nodes and then finally do a put of 
those frames when I returned from the node. It could be debated whether this 
should be done at all, but then the strategy was dependent on the index of 
vlib_node_t of the target node. Hence the question for the usecase when I don't 
have the next node index in terms of the vlib_node_t's index of the target node.

Regards
-Prashant




On Mon, Mar 4, 2019 at 9:31 PM Neale Ranns (nranns) <nra...@cisco.com> wrote:
>
>
> I'll bite __ why would you want to do that?
>
> /neale
>
> -----Message d'origine-----
> De : <vpp-dev@lists.fd.io> au nom de Prashant Upadhyaya 
> <praupadhy...@gmail.com> Date : lundi 4 mars 2019 à 16:06 À : "Dave 
> Barach (dbarach)" <dbar...@cisco.com> Cc : "vpp-dev@lists.fd.io" 
> <vpp-dev@lists.fd.io> Objet : Re: [vpp-dev] Regarding node on a 
> feature arc
>
>     Thanks Dave, this is cool !
>
>     Regards
>     -Prashant
>
>
>     On Mon, Mar 4, 2019 at 8:29 PM Dave Barach (dbarach) <dbar...@cisco.com> 
> wrote:
>     >
>     > You have: vlib_node_runtime_t *node. Use n = vlib_get_node(vm, 
> node->node_index) to recover the vlib_node_t.
>     >
>     > Index n->next_nodes to recover the node index corresponding to the next 
> index you have in mind: nNext = vlib_get_node (vm, n->next_nodes[i])
>     >
>     > HTH... Dave
>     >
>     > -----Original Message-----
>     > From: vpp-dev@lists.fd.io <vpp-dev@lists.fd.io> On Behalf Of Prashant 
> Upadhyaya
>     > Sent: Monday, March 4, 2019 9:29 AM
>     > To: vpp-dev@lists.fd.io
>     > Subject: [vpp-dev] Regarding node on a feature arc
>     >
>     > Hi,
>     >
>     > When a node is on a feature arc, a good practice for that node is to 
> inspect the next feature with vnet_feature_next, obtain the next0 from that 
> and send the packets to the next0. All this works properly.
>     >
>     > My question -- how can I obtain the true vlib_node_t pointer 
> corresponding to the next0 as obtained from vnet_feature_next ?
>     >
>     > Regards
>     > -Prashant
>
>
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.

View/Reply Online (#12422): https://lists.fd.io/g/vpp-dev/message/12422
Mute This Topic: https://lists.fd.io/mt/30213927/21656
Group Owner: vpp-dev+ow...@lists.fd.io
Unsubscribe: https://lists.fd.io/g/vpp-dev/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to