LCOV - code coverage report
Current view: top level - plugins/avf - input.c (source / functions) Hit Total Coverage
Test: coverage-filtered.info Lines: 2 293 0.7 %
Date: 2023-07-05 22:20:52 Functions: 7 18 38.9 %

          Line data    Source code
       1             : /*
       2             :  *------------------------------------------------------------------
       3             :  * Copyright (c) 2018 Cisco and/or its affiliates.
       4             :  * Licensed under the Apache License, Version 2.0 (the "License");
       5             :  * you may not use this file except in compliance with the License.
       6             :  * You may obtain a copy of the License at:
       7             :  *
       8             :  *     http://www.apache.org/licenses/LICENSE-2.0
       9             :  *
      10             :  * Unless required by applicable law or agreed to in writing, software
      11             :  * distributed under the License is distributed on an "AS IS" BASIS,
      12             :  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      13             :  * See the License for the specific language governing permissions and
      14             :  * limitations under the License.
      15             :  *------------------------------------------------------------------
      16             :  */
      17             : 
      18             : #include <vlib/vlib.h>
      19             : #include <vlib/unix/unix.h>
      20             : #include <vlib/pci/pci.h>
      21             : #include <vnet/ethernet/ethernet.h>
      22             : #include <vnet/interface/rx_queue_funcs.h>
      23             : 
      24             : #include <avf/avf.h>
      25             : 
      26             : #define foreach_avf_input_error \
      27             :   _(BUFFER_ALLOC, "buffer alloc error")
      28             : 
      29             : typedef enum
      30             : {
      31             : #define _(f,s) AVF_INPUT_ERROR_##f,
      32             :   foreach_avf_input_error
      33             : #undef _
      34             :     AVF_INPUT_N_ERROR,
      35             : } avf_input_error_t;
      36             : 
      37             : static __clib_unused char *avf_input_error_strings[] = {
      38             : #define _(n,s) s,
      39             :   foreach_avf_input_error
      40             : #undef _
      41             : };
      42             : 
      43             : #define AVF_INPUT_REFILL_TRESHOLD 32
      44             : 
      45             : static_always_inline void
      46           0 : avf_rx_desc_write (avf_rx_desc_t * d, u64 addr)
      47             : {
      48             : #ifdef CLIB_HAVE_VEC256
      49           0 :   u64x4 v = { addr, 0, 0, 0 };
      50           0 :   u64x4_store_unaligned (v, (void *) d);
      51             : #else
      52           0 :   d->qword[0] = addr;
      53           0 :   d->qword[1] = 0;
      54             : #endif
      55           0 : }
      56             : 
      57             : static_always_inline void
      58           0 : avf_rxq_refill (vlib_main_t * vm, vlib_node_runtime_t * node, avf_rxq_t * rxq,
      59             :                 int use_va_dma)
      60             : {
      61             :   u16 n_refill, mask, n_alloc, slot, size;
      62             :   vlib_buffer_t *b[8];
      63             :   avf_rx_desc_t *d, *first_d;
      64             :   void *p[8];
      65             : 
      66           0 :   size = rxq->size;
      67           0 :   mask = size - 1;
      68           0 :   n_refill = mask - rxq->n_enqueued;
      69           0 :   if (PREDICT_TRUE (n_refill <= AVF_INPUT_REFILL_TRESHOLD))
      70           0 :     return;
      71             : 
      72           0 :   slot = (rxq->next - n_refill - 1) & mask;
      73             : 
      74           0 :   n_refill &= ~7;           /* round to 8 */
      75           0 :   n_alloc =
      76           0 :     vlib_buffer_alloc_to_ring_from_pool (vm, rxq->bufs, slot, size, n_refill,
      77           0 :                                          rxq->buffer_pool_index);
      78             : 
      79           0 :   if (PREDICT_FALSE (n_alloc != n_refill))
      80             :     {
      81           0 :       vlib_error_count (vm, node->node_index,
      82             :                         AVF_INPUT_ERROR_BUFFER_ALLOC, 1);
      83           0 :       if (n_alloc)
      84           0 :         vlib_buffer_free_from_ring (vm, rxq->bufs, slot, size, n_alloc);
      85           0 :       return;
      86             :     }
      87             : 
      88           0 :   rxq->n_enqueued += n_alloc;
      89           0 :   first_d = rxq->descs;
      90             : 
      91           0 :   ASSERT (slot % 8 == 0);
      92             : 
      93           0 :   while (n_alloc >= 8)
      94             :     {
      95           0 :       d = first_d + slot;
      96             : 
      97           0 :       if (use_va_dma)
      98             :         {
      99           0 :           vlib_get_buffers_with_offset (vm, rxq->bufs + slot, p, 8,
     100             :                                         sizeof (vlib_buffer_t));
     101           0 :           avf_rx_desc_write (d + 0, pointer_to_uword (p[0]));
     102           0 :           avf_rx_desc_write (d + 1, pointer_to_uword (p[1]));
     103           0 :           avf_rx_desc_write (d + 2, pointer_to_uword (p[2]));
     104           0 :           avf_rx_desc_write (d + 3, pointer_to_uword (p[3]));
     105           0 :           avf_rx_desc_write (d + 4, pointer_to_uword (p[4]));
     106           0 :           avf_rx_desc_write (d + 5, pointer_to_uword (p[5]));
     107           0 :           avf_rx_desc_write (d + 6, pointer_to_uword (p[6]));
     108           0 :           avf_rx_desc_write (d + 7, pointer_to_uword (p[7]));
     109             :         }
     110             :       else
     111             :         {
     112           0 :           vlib_get_buffers (vm, rxq->bufs + slot, b, 8);
     113           0 :           avf_rx_desc_write (d + 0, vlib_buffer_get_pa (vm, b[0]));
     114           0 :           avf_rx_desc_write (d + 1, vlib_buffer_get_pa (vm, b[1]));
     115           0 :           avf_rx_desc_write (d + 2, vlib_buffer_get_pa (vm, b[2]));
     116           0 :           avf_rx_desc_write (d + 3, vlib_buffer_get_pa (vm, b[3]));
     117           0 :           avf_rx_desc_write (d + 4, vlib_buffer_get_pa (vm, b[4]));
     118           0 :           avf_rx_desc_write (d + 5, vlib_buffer_get_pa (vm, b[5]));
     119           0 :           avf_rx_desc_write (d + 6, vlib_buffer_get_pa (vm, b[6]));
     120           0 :           avf_rx_desc_write (d + 7, vlib_buffer_get_pa (vm, b[7]));
     121             :         }
     122             : 
     123             :       /* next */
     124           0 :       slot = (slot + 8) & mask;
     125           0 :       n_alloc -= 8;
     126             :     }
     127             : 
     128           0 :   avf_tail_write (rxq->qrx_tail, slot);
     129             : }
     130             : 
     131             : 
     132             : static_always_inline uword
     133           0 : avf_rx_attach_tail (vlib_main_t * vm, vlib_buffer_t * bt, vlib_buffer_t * b,
     134             :                     u64 qw1, avf_rx_tail_t * t)
     135             : {
     136           0 :   vlib_buffer_t *hb = b;
     137           0 :   u32 tlnifb = 0, i = 0;
     138             : 
     139           0 :   if (qw1 & AVF_RXD_STATUS_EOP)
     140           0 :     return 0;
     141             : 
     142           0 :   while ((qw1 & AVF_RXD_STATUS_EOP) == 0)
     143             :     {
     144           0 :       ASSERT (i < AVF_RX_MAX_DESC_IN_CHAIN - 1);
     145           0 :       ASSERT (qw1 & AVF_RXD_STATUS_DD);
     146           0 :       qw1 = t->qw1s[i];
     147           0 :       b->next_buffer = t->buffers[i];
     148           0 :       b->flags |= VLIB_BUFFER_NEXT_PRESENT;
     149           0 :       b = vlib_get_buffer (vm, b->next_buffer);
     150           0 :       vlib_buffer_copy_template (b, bt);
     151           0 :       tlnifb += b->current_length = qw1 >> AVF_RXD_LEN_SHIFT;
     152           0 :       i++;
     153             :     }
     154             : 
     155           0 :   hb->total_length_not_including_first_buffer = tlnifb;
     156           0 :   hb->flags |= VLIB_BUFFER_TOTAL_LENGTH_VALID;
     157           0 :   return tlnifb;
     158             : }
     159             : 
     160             : static_always_inline void
     161           0 : avf_process_flow_offload (avf_device_t *ad, avf_per_thread_data_t *ptd,
     162             :                           uword n_rx_packets)
     163             : {
     164             :   uword n;
     165             :   avf_flow_lookup_entry_t *fle;
     166             : 
     167           0 :   for (n = 0; n < n_rx_packets; n++)
     168             :     {
     169           0 :       if ((ptd->qw1s[n] & AVF_RXD_STATUS_FLM) == 0)
     170           0 :         continue;
     171             : 
     172           0 :       fle = pool_elt_at_index (ad->flow_lookup_entries, ptd->flow_ids[n]);
     173             : 
     174           0 :       if (fle->next_index != (u16) ~0)
     175             :         {
     176           0 :           ptd->next[n] = fle->next_index;
     177             :         }
     178             : 
     179           0 :       if (fle->flow_id != ~0)
     180             :         {
     181           0 :           ptd->bufs[n]->flow_id = fle->flow_id;
     182             :         }
     183             : 
     184           0 :       if (fle->buffer_advance != ~0)
     185             :         {
     186           0 :           vlib_buffer_advance (ptd->bufs[n], fle->buffer_advance);
     187             :         }
     188             :     }
     189           0 : }
     190             : 
     191             : static_always_inline uword
     192           0 : avf_process_rx_burst (vlib_main_t * vm, vlib_node_runtime_t * node,
     193             :                       avf_per_thread_data_t * ptd, u32 n_left,
     194             :                       int maybe_multiseg)
     195             : {
     196             :   vlib_buffer_t bt;
     197           0 :   vlib_buffer_t **b = ptd->bufs;
     198           0 :   u64 *qw1 = ptd->qw1s;
     199           0 :   avf_rx_tail_t *tail = ptd->tails;
     200           0 :   uword n_rx_bytes = 0;
     201             : 
     202             :   /* copy template into local variable - will save per packet load */
     203           0 :   vlib_buffer_copy_template (&bt, &ptd->buffer_template);
     204             : 
     205           0 :   while (n_left >= 4)
     206             :     {
     207           0 :       if (n_left >= 12)
     208             :         {
     209           0 :           vlib_prefetch_buffer_header (b[8], LOAD);
     210           0 :           vlib_prefetch_buffer_header (b[9], LOAD);
     211           0 :           vlib_prefetch_buffer_header (b[10], LOAD);
     212           0 :           vlib_prefetch_buffer_header (b[11], LOAD);
     213             :         }
     214             : 
     215           0 :       vlib_buffer_copy_template (b[0], &bt);
     216           0 :       vlib_buffer_copy_template (b[1], &bt);
     217           0 :       vlib_buffer_copy_template (b[2], &bt);
     218           0 :       vlib_buffer_copy_template (b[3], &bt);
     219             : 
     220           0 :       n_rx_bytes += b[0]->current_length = qw1[0] >> AVF_RXD_LEN_SHIFT;
     221           0 :       n_rx_bytes += b[1]->current_length = qw1[1] >> AVF_RXD_LEN_SHIFT;
     222           0 :       n_rx_bytes += b[2]->current_length = qw1[2] >> AVF_RXD_LEN_SHIFT;
     223           0 :       n_rx_bytes += b[3]->current_length = qw1[3] >> AVF_RXD_LEN_SHIFT;
     224             : 
     225           0 :       if (maybe_multiseg)
     226             :         {
     227           0 :           n_rx_bytes += avf_rx_attach_tail (vm, &bt, b[0], qw1[0], tail + 0);
     228           0 :           n_rx_bytes += avf_rx_attach_tail (vm, &bt, b[1], qw1[1], tail + 1);
     229           0 :           n_rx_bytes += avf_rx_attach_tail (vm, &bt, b[2], qw1[2], tail + 2);
     230           0 :           n_rx_bytes += avf_rx_attach_tail (vm, &bt, b[3], qw1[3], tail + 3);
     231             :         }
     232             : 
     233             :       /* next */
     234           0 :       qw1 += 4;
     235           0 :       tail += 4;
     236           0 :       b += 4;
     237           0 :       n_left -= 4;
     238             :     }
     239             : 
     240           0 :   while (n_left)
     241             :     {
     242           0 :       vlib_buffer_copy_template (b[0], &bt);
     243             : 
     244           0 :       n_rx_bytes += b[0]->current_length = qw1[0] >> AVF_RXD_LEN_SHIFT;
     245             : 
     246           0 :       if (maybe_multiseg)
     247           0 :         n_rx_bytes += avf_rx_attach_tail (vm, &bt, b[0], qw1[0], tail + 0);
     248             : 
     249             :       /* next */
     250           0 :       qw1 += 1;
     251           0 :       tail += 1;
     252           0 :       b += 1;
     253           0 :       n_left -= 1;
     254             :     }
     255           0 :   return n_rx_bytes;
     256             : }
     257             : 
     258             : static_always_inline uword
     259           0 : avf_device_input_inline (vlib_main_t *vm, vlib_node_runtime_t *node,
     260             :                          vlib_frame_t *frame, avf_device_t *ad, u16 qid,
     261             :                          int with_flows)
     262             : {
     263           0 :   avf_main_t *am = &avf_main;
     264           0 :   vnet_main_t *vnm = vnet_get_main ();
     265           0 :   u32 thr_idx = vlib_get_thread_index ();
     266           0 :   avf_per_thread_data_t *ptd =
     267           0 :     vec_elt_at_index (am->per_thread_data, thr_idx);
     268           0 :   avf_rxq_t *rxq = vec_elt_at_index (ad->rxqs, qid);
     269           0 :   u32 n_trace, n_rx_packets = 0, n_rx_bytes = 0;
     270           0 :   u16 n_tail_desc = 0;
     271           0 :   u64 or_qw1 = 0;
     272             :   u32 *bi, *to_next, n_left_to_next;
     273           0 :   vlib_buffer_t *bt = &ptd->buffer_template;
     274           0 :   u32 next_index = VNET_DEVICE_INPUT_NEXT_ETHERNET_INPUT;
     275           0 :   u16 next = rxq->next;
     276           0 :   u16 size = rxq->size;
     277           0 :   u16 mask = size - 1;
     278           0 :   avf_rx_desc_t *d, *fd = rxq->descs;
     279             : #ifdef CLIB_HAVE_VEC256
     280           0 :   u64x4 q1x4, or_q1x4 = { 0 };
     281             :   u32x4 fdidx4;
     282           0 :   u64x4 dd_eop_mask4 = u64x4_splat (AVF_RXD_STATUS_DD | AVF_RXD_STATUS_EOP);
     283             : #elif defined(CLIB_HAVE_VEC128)
     284           0 :   u32x4 q1x4_lo, q1x4_hi, or_q1x4 = { 0 };
     285             :   u32x4 fdidx4;
     286           0 :   u32x4 dd_eop_mask4 = u32x4_splat (AVF_RXD_STATUS_DD | AVF_RXD_STATUS_EOP);
     287             : #endif
     288           0 :   int single_next = 1;
     289             : 
     290             :   /* is there anything on the ring */
     291           0 :   d = fd + next;
     292           0 :   if ((d->qword[1] & AVF_RXD_STATUS_DD) == 0)
     293           0 :     goto done;
     294             : 
     295           0 :   if (PREDICT_FALSE (ad->per_interface_next_index != ~0))
     296           0 :     next_index = ad->per_interface_next_index;
     297             : 
     298           0 :   if (PREDICT_FALSE (vnet_device_input_have_features (ad->sw_if_index)))
     299           0 :     vnet_feature_start_device_input_x1 (ad->sw_if_index, &next_index, bt);
     300             : 
     301           0 :   vlib_get_new_next_frame (vm, node, next_index, to_next, n_left_to_next);
     302             : 
     303             :   /* fetch up to AVF_RX_VECTOR_SZ from the rx ring, unflatten them and
     304             :      copy needed data from descriptor to rx vector */
     305           0 :   bi = to_next;
     306             : 
     307           0 :   while (n_rx_packets < AVF_RX_VECTOR_SZ)
     308             :     {
     309           0 :       if (next + 11 < size)
     310             :         {
     311           0 :           int stride = 8;
     312           0 :           clib_prefetch_load ((void *) (fd + (next + stride)));
     313           0 :           clib_prefetch_load ((void *) (fd + (next + stride + 1)));
     314           0 :           clib_prefetch_load ((void *) (fd + (next + stride + 2)));
     315           0 :           clib_prefetch_load ((void *) (fd + (next + stride + 3)));
     316             :         }
     317             : 
     318             : #ifdef CLIB_HAVE_VEC256
     319           0 :       if (n_rx_packets >= AVF_RX_VECTOR_SZ - 4 || next >= size - 4)
     320           0 :         goto one_by_one;
     321             : 
     322           0 :       q1x4 = u64x4_gather ((void *) &d[0].qword[1], (void *) &d[1].qword[1],
     323           0 :                            (void *) &d[2].qword[1], (void *) &d[3].qword[1]);
     324             : 
     325             :       /* not all packets are ready or at least one of them is chained */
     326           0 :       if (!u64x4_is_equal (q1x4 & dd_eop_mask4, dd_eop_mask4))
     327           0 :         goto one_by_one;
     328             : 
     329           0 :       or_q1x4 |= q1x4;
     330             : 
     331           0 :       u64x4_store_unaligned (q1x4, ptd->qw1s + n_rx_packets);
     332             : #elif defined(CLIB_HAVE_VEC128)
     333           0 :       if (n_rx_packets >= AVF_RX_VECTOR_SZ - 4 || next >= size - 4)
     334           0 :         goto one_by_one;
     335             : 
     336           0 :       q1x4_lo =
     337           0 :         u32x4_gather ((void *) &d[0].qword[1], (void *) &d[1].qword[1],
     338           0 :                       (void *) &d[2].qword[1], (void *) &d[3].qword[1]);
     339             : 
     340             :       /* not all packets are ready or at least one of them is chained */
     341           0 :       if (!u32x4_is_equal (q1x4_lo & dd_eop_mask4, dd_eop_mask4))
     342           0 :         goto one_by_one;
     343             : 
     344           0 :       q1x4_hi = u32x4_gather (
     345           0 :         (void *) &d[0].qword[1] + 4, (void *) &d[1].qword[1] + 4,
     346           0 :         (void *) &d[2].qword[1] + 4, (void *) &d[3].qword[1] + 4);
     347             : 
     348           0 :       or_q1x4 |= q1x4_lo;
     349           0 :       ptd->qw1s[n_rx_packets + 0] = (u64) q1x4_hi[0] << 32 | (u64) q1x4_lo[0];
     350           0 :       ptd->qw1s[n_rx_packets + 1] = (u64) q1x4_hi[1] << 32 | (u64) q1x4_lo[1];
     351           0 :       ptd->qw1s[n_rx_packets + 2] = (u64) q1x4_hi[2] << 32 | (u64) q1x4_lo[2];
     352           0 :       ptd->qw1s[n_rx_packets + 3] = (u64) q1x4_hi[3] << 32 | (u64) q1x4_lo[3];
     353             : #endif
     354             : #if defined(CLIB_HAVE_VEC256) || defined(CLIB_HAVE_VEC128)
     355             : 
     356           0 :       if (with_flows)
     357             :         {
     358           0 :           fdidx4 = u32x4_gather (
     359           0 :             (void *) &d[0].fdid_flex_hi, (void *) &d[1].fdid_flex_hi,
     360           0 :             (void *) &d[2].fdid_flex_hi, (void *) &d[3].fdid_flex_hi);
     361           0 :           u32x4_store_unaligned (fdidx4, ptd->flow_ids + n_rx_packets);
     362             :         }
     363             : 
     364           0 :       vlib_buffer_copy_indices (bi, rxq->bufs + next, 4);
     365             : 
     366             :       /* next */
     367           0 :       next = (next + 4) & mask;
     368           0 :       d = fd + next;
     369           0 :       n_rx_packets += 4;
     370           0 :       bi += 4;
     371           0 :       continue;
     372           0 :     one_by_one:
     373             : #endif
     374           0 :       clib_prefetch_load ((void *) (fd + ((next + 8) & mask)));
     375             : 
     376           0 :       if (avf_rxd_is_not_dd (d))
     377           0 :         break;
     378             : 
     379           0 :       bi[0] = rxq->bufs[next];
     380             : 
     381             :       /* deal with chained buffers */
     382           0 :       if (PREDICT_FALSE (avf_rxd_is_not_eop (d)))
     383             :         {
     384           0 :           u16 tail_desc = 0;
     385           0 :           u16 tail_next = next;
     386           0 :           avf_rx_tail_t *tail = ptd->tails + n_rx_packets;
     387             :           avf_rx_desc_t *td;
     388             :           do
     389             :             {
     390           0 :               tail_next = (tail_next + 1) & mask;
     391           0 :               td = fd + tail_next;
     392             : 
     393             :               /* bail out in case of incomplete transaction */
     394           0 :               if (avf_rxd_is_not_dd (td))
     395           0 :                 goto no_more_desc;
     396             : 
     397           0 :               or_qw1 |= tail->qw1s[tail_desc] = td[0].qword[1];
     398           0 :               tail->buffers[tail_desc] = rxq->bufs[tail_next];
     399           0 :               tail_desc++;
     400             :             }
     401           0 :           while (avf_rxd_is_not_eop (td));
     402           0 :           next = tail_next;
     403           0 :           n_tail_desc += tail_desc;
     404             :         }
     405             : 
     406           0 :       or_qw1 |= ptd->qw1s[n_rx_packets] = d[0].qword[1];
     407           0 :       if (PREDICT_FALSE (with_flows))
     408             :         {
     409           0 :           ptd->flow_ids[n_rx_packets] = d[0].fdid_flex_hi;
     410             :         }
     411             : 
     412             :       /* next */
     413           0 :       next = (next + 1) & mask;
     414           0 :       d = fd + next;
     415           0 :       n_rx_packets++;
     416           0 :       bi++;
     417             :     }
     418           0 : no_more_desc:
     419             : 
     420           0 :   if (n_rx_packets == 0)
     421           0 :     goto done;
     422             : 
     423           0 :   rxq->next = next;
     424           0 :   rxq->n_enqueued -= n_rx_packets + n_tail_desc;
     425             : 
     426             :   /* avoid eating our own tail */
     427           0 :   rxq->descs[(next + rxq->n_enqueued) & mask].qword[1] = 0;
     428             : 
     429             : #if defined(CLIB_HAVE_VEC256) || defined(CLIB_HAVE_VEC128)
     430           0 :   or_qw1 |= or_q1x4[0] | or_q1x4[1] | or_q1x4[2] | or_q1x4[3];
     431             : #endif
     432             : 
     433           0 :   vlib_get_buffers (vm, to_next, ptd->bufs, n_rx_packets);
     434             : 
     435           0 :   vnet_buffer (bt)->sw_if_index[VLIB_RX] = ad->sw_if_index;
     436           0 :   vnet_buffer (bt)->sw_if_index[VLIB_TX] = ~0;
     437           0 :   bt->buffer_pool_index = rxq->buffer_pool_index;
     438           0 :   bt->ref_count = 1;
     439             : 
     440           0 :   if (n_tail_desc)
     441           0 :     n_rx_bytes = avf_process_rx_burst (vm, node, ptd, n_rx_packets, 1);
     442             :   else
     443           0 :     n_rx_bytes = avf_process_rx_burst (vm, node, ptd, n_rx_packets, 0);
     444             : 
     445             :   /* the MARKed packets may have different next nodes */
     446           0 :   if (PREDICT_FALSE (with_flows && (or_qw1 & AVF_RXD_STATUS_FLM)))
     447             :     {
     448             :       u32 n;
     449           0 :       single_next = 0;
     450           0 :       for (n = 0; n < n_rx_packets; n++)
     451           0 :         ptd->next[n] = next_index;
     452             : 
     453           0 :       avf_process_flow_offload (ad, ptd, n_rx_packets);
     454             :     }
     455             : 
     456             :   /* packet trace if enabled */
     457           0 :   if (PREDICT_FALSE ((n_trace = vlib_get_trace_count (vm, node))))
     458             :     {
     459           0 :       u32 n_left = n_rx_packets;
     460             :       u32 i, j;
     461           0 :       u16 *next_indices = ptd->next;
     462             : 
     463           0 :       i = 0;
     464           0 :       while (n_trace && n_left)
     465             :         {
     466           0 :           vlib_buffer_t *b = ptd->bufs[i];
     467           0 :           if (PREDICT_FALSE (single_next == 0))
     468           0 :             next_index = next_indices[0];
     469             : 
     470           0 :           if (PREDICT_TRUE
     471             :               (vlib_trace_buffer
     472             :                (vm, node, next_index, b, /* follow_chain */ 0)))
     473             :             {
     474             :               avf_input_trace_t *tr =
     475           0 :                 vlib_add_trace (vm, node, b, sizeof (*tr));
     476           0 :               tr->next_index = next_index;
     477           0 :               tr->qid = qid;
     478           0 :               tr->hw_if_index = ad->hw_if_index;
     479           0 :               tr->qw1s[0] = ptd->qw1s[i];
     480           0 :               tr->flow_id =
     481           0 :                 (tr->qw1s[0] & AVF_RXD_STATUS_FLM) ? ptd->flow_ids[i] : 0;
     482           0 :               for (j = 1; j < AVF_RX_MAX_DESC_IN_CHAIN; j++)
     483           0 :                 tr->qw1s[j] = ptd->tails[i].qw1s[j - 1];
     484             : 
     485           0 :               n_trace--;
     486             :             }
     487             : 
     488             :           /* next */
     489           0 :           n_left--;
     490           0 :           i++;
     491           0 :           next_indices++;
     492             :         }
     493           0 :       vlib_set_trace_count (vm, node, n_trace);
     494             :     }
     495             : 
     496             :   /* enqueu the packets to the next nodes */
     497           0 :   if (PREDICT_FALSE (with_flows && (or_qw1 & AVF_RXD_STATUS_FLM)))
     498             :     {
     499             :       /* release next node's frame vector, in this case we use
     500             :          vlib_buffer_enqueue_to_next to place the packets
     501             :        */
     502           0 :       vlib_put_next_frame (vm, node, next_index, n_left_to_next);
     503             : 
     504             :       /* enqueue buffers to the next node */
     505           0 :       vlib_buffer_enqueue_to_next (vm, node, to_next, ptd->next, n_rx_packets);
     506             :     }
     507             :   else
     508             :     {
     509           0 :       if (PREDICT_TRUE (next_index == VNET_DEVICE_INPUT_NEXT_ETHERNET_INPUT))
     510             :         {
     511             :           vlib_next_frame_t *nf;
     512             :           vlib_frame_t *f;
     513             :           ethernet_input_frame_t *ef;
     514           0 :           nf = vlib_node_runtime_get_next_frame (vm, node, next_index);
     515           0 :           f = vlib_get_frame (vm, nf->frame);
     516           0 :           f->flags = ETH_INPUT_FRAME_F_SINGLE_SW_IF_IDX;
     517             : 
     518           0 :           ef = vlib_frame_scalar_args (f);
     519           0 :           ef->sw_if_index = ad->sw_if_index;
     520           0 :           ef->hw_if_index = ad->hw_if_index;
     521             : 
     522           0 :           if ((or_qw1 & AVF_RXD_ERROR_IPE) == 0)
     523           0 :             f->flags |= ETH_INPUT_FRAME_F_IP4_CKSUM_OK;
     524           0 :           vlib_frame_no_append (f);
     525             :         }
     526             : 
     527           0 :       n_left_to_next -= n_rx_packets;
     528           0 :       vlib_put_next_frame (vm, node, next_index, n_left_to_next);
     529             :     }
     530             : 
     531           0 :   vlib_increment_combined_counter (vnm->interface_main.combined_sw_if_counters
     532             :                                    + VNET_INTERFACE_COUNTER_RX, thr_idx,
     533             :                                    ad->hw_if_index, n_rx_packets, n_rx_bytes);
     534             : 
     535           0 : done:
     536             :   /* refill rx ring */
     537           0 :   if (ad->flags & AVF_DEVICE_F_VA_DMA)
     538           0 :     avf_rxq_refill (vm, node, rxq, 1 /* use_va_dma */ );
     539             :   else
     540           0 :     avf_rxq_refill (vm, node, rxq, 0 /* use_va_dma */ );
     541             : 
     542           0 :   return n_rx_packets;
     543             : }
     544             : 
     545        2795 : VLIB_NODE_FN (avf_input_node) (vlib_main_t * vm, vlib_node_runtime_t * node,
     546             :                                vlib_frame_t * frame)
     547             : {
     548           0 :   u32 n_rx = 0;
     549             :   vnet_hw_if_rxq_poll_vector_t *pv;
     550             : 
     551           0 :   pv = vnet_hw_if_get_rxq_poll_vector (vm, node);
     552             : 
     553           0 :   for (int i = 0; i < vec_len (pv); i++)
     554             :     {
     555           0 :       avf_device_t *ad = avf_get_device (pv[i].dev_instance);
     556           0 :       if ((ad->flags & AVF_DEVICE_F_ADMIN_UP) == 0)
     557           0 :         continue;
     558           0 :       if (PREDICT_FALSE (ad->flags & AVF_DEVICE_F_RX_FLOW_OFFLOAD))
     559           0 :         n_rx +=
     560           0 :           avf_device_input_inline (vm, node, frame, ad, pv[i].queue_id, 1);
     561             :       else
     562           0 :         n_rx +=
     563           0 :           avf_device_input_inline (vm, node, frame, ad, pv[i].queue_id, 0);
     564             :     }
     565             : 
     566           0 :   return n_rx;
     567             : }
     568             : 
     569             : /* *INDENT-OFF* */
     570      164680 : VLIB_REGISTER_NODE (avf_input_node) = {
     571             :   .name = "avf-input",
     572             :   .sibling_of = "device-input",
     573             :   .format_trace = format_avf_input_trace,
     574             :   .type = VLIB_NODE_TYPE_INPUT,
     575             :   .state = VLIB_NODE_STATE_DISABLED,
     576             :   .n_errors = AVF_INPUT_N_ERROR,
     577             :   .error_strings = avf_input_error_strings,
     578             :   .flags = VLIB_NODE_FLAG_TRACE_SUPPORTED,
     579             : };
     580             : 
     581             : /* *INDENT-ON* */
     582             : 
     583             : 
     584             : /*
     585             :  * fd.io coding-style-patch-verification: ON
     586             :  *
     587             :  * Local Variables:
     588             :  * eval: (c-set-style "gnu")
     589             :  * End:
     590             :  */

Generated by: LCOV version 1.14