LCOV - code coverage report
Current view: top level - lib/ring - rte_ring_elem_pvt.h (source / functions) Hit Total Coverage
Test: Code coverage Lines: 154 154 100.0 %
Date: 2025-01-02 22:41:34 Functions: 0 0 -
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 1374 3980 34.5 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  *
       3                 :            :  * Copyright (c) 2017,2018 HXT-semitech Corporation.
       4                 :            :  * Copyright (c) 2007-2009 Kip Macy kmacy@freebsd.org
       5                 :            :  * All rights reserved.
       6                 :            :  * Derived from FreeBSD's bufring.h
       7                 :            :  * Used as BSD-3 Licensed with permission from Kip Macy.
       8                 :            :  */
       9                 :            : 
      10                 :            : #ifndef _RTE_RING_ELEM_PVT_H_
      11                 :            : #define _RTE_RING_ELEM_PVT_H_
      12                 :            : 
      13                 :            : #if defined(RTE_TOOLCHAIN_GCC) && (GCC_VERSION >= 120000)
      14                 :            : #pragma GCC diagnostic push
      15                 :            : #pragma GCC diagnostic ignored "-Wstringop-overflow"
      16                 :            : #pragma GCC diagnostic ignored "-Wstringop-overread"
      17                 :            : #endif
      18                 :            : 
      19                 :            : static __rte_always_inline void
      20                 :            : __rte_ring_enqueue_elems_32(struct rte_ring *r, const uint32_t size,
      21                 :            :                 uint32_t idx, const void *obj_table, uint32_t n)
      22                 :            : {
      23                 :            :         unsigned int i;
      24                 :  179652867 :         uint32_t *ring = (uint32_t *)&r[1];
      25                 :            :         const uint32_t *obj = (const uint32_t *)obj_table;
      26                 :  179652867 :         if (likely(idx + n <= size)) {
      27   [ -  -  +  +  :     126965 :                 for (i = 0; i < (n & ~0x7); i += 8, idx += 8) {
          -  +  -  -  -  
          -  -  -  -  -  
          +  +  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  +  +  -  
          -  +  +  +  +  
          +  +  +  +  +  
          +  -  -  +  +  
          +  +  +  +  +  
                      + ]
      28                 :     112359 :                         ring[idx] = obj[i];
      29                 :     112359 :                         ring[idx + 1] = obj[i + 1];
      30                 :     112359 :                         ring[idx + 2] = obj[i + 2];
      31                 :     112359 :                         ring[idx + 3] = obj[i + 3];
      32                 :     112359 :                         ring[idx + 4] = obj[i + 4];
      33                 :     112359 :                         ring[idx + 5] = obj[i + 5];
      34                 :     112359 :                         ring[idx + 6] = obj[i + 6];
      35                 :     112359 :                         ring[idx + 7] = obj[i + 7];
      36                 :            :                 }
      37   [ -  -  -  -  :      14606 :                 switch (n & 0x7) {
          -  -  -  -  -  
          -  +  -  -  +  
          +  -  -  +  -  
          -  +  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  +  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          +  +  +  -  +  
          +  +  +  -  -  
          -  -  -  -  -  
          -  +  +  +  +  
          -  +  +  +  +  
          +  +  -  +  +  
          +  +  +  -  +  
          -  +  +  +  +  
          +  +  +  -  +  
          +  +  +  -  +  
          +  +  +  +  +  
          +  -  -  -  -  
          -  -  -  -  +  
          +  +  +  -  +  
          +  +  +  +  +  
          +  -  +  +  +  
          +  +  +  -  +  
          +  +  +  -  -  
          +  +  +  +  +  
                      + ]
      38                 :         15 :                 case 7:
      39                 :         15 :                         ring[idx++] = obj[i++]; /* fallthrough */
      40                 :       1057 :                 case 6:
      41                 :       1057 :                         ring[idx++] = obj[i++]; /* fallthrough */
      42                 :       5217 :                 case 5:
      43                 :       5217 :                         ring[idx++] = obj[i++]; /* fallthrough */
      44                 :       5225 :                 case 4:
      45                 :       5225 :                         ring[idx++] = obj[i++]; /* fallthrough */
      46                 :       5238 :                 case 3:
      47                 :       5238 :                         ring[idx++] = obj[i++]; /* fallthrough */
      48                 :       5316 :                 case 2:
      49                 :       5316 :                         ring[idx++] = obj[i++]; /* fallthrough */
      50                 :       9478 :                 case 1:
      51                 :  179647512 :                         ring[idx++] = obj[i++]; /* fallthrough */
      52                 :            :                 }
      53                 :            :         } else {
      54   [ -  -  -  -  :    1245397 :                 for (i = 0; idx < size; i++, idx++)
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  +  +  -  
          -  -  -  -  -  
          -  -  +  +  -  
          -  +  +  +  +  
          +  +  +  +  +  
          +  -  -  +  +  
          +  +  +  +  +  
                      + ]
      55                 :    1245170 :                         ring[idx] = obj[i];
      56                 :            :                 /* Start at the beginning */
      57   [ -  -  -  -  :    1249677 :                 for (idx = 0; i < n; i++, idx++)
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  +  +  -  
          -  -  -  -  -  
          -  -  +  +  -  
          -  +  +  +  +  
          +  +  +  +  +  
          +  -  -  +  +  
          +  +  +  +  +  
                      + ]
      58                 :    1249450 :                         ring[idx] = obj[i];
      59                 :            :         }
      60                 :            : }
      61                 :            : 
      62                 :            : static __rte_always_inline void
      63                 :            : __rte_ring_enqueue_elems_64(struct rte_ring *r, uint32_t prod_head,
      64                 :            :                 const void *obj_table, uint32_t n)
      65                 :            : {
      66                 :            :         unsigned int i;
      67                 :   52014871 :         const uint32_t size = r->size;
      68                 :   52014871 :         uint32_t idx = prod_head & r->mask;
      69                 :   52014871 :         uint64_t *ring = (uint64_t *)&r[1];
      70                 :            :         const unaligned_uint64_t *obj = (const unaligned_uint64_t *)obj_table;
      71   [ +  -  +  +  :   52014871 :         if (likely(idx + n <= size)) {
          +  -  +  +  -  
          -  +  -  -  -  
          +  +  -  -  +  
          +  -  -  -  -  
          -  -  +  +  -  
          -  -  -  -  -  
          +  -  -  -  +  
          -  -  -  +  -  
          -  -  -  -  -  
          -  +  -  -  -  
          -  -  -  -  -  
          -  -  -  -  +  
          -  -  -  -  -  
          -  -  -  +  +  
          -  -  +  +  +  
          +  +  +  +  +  
          +  +  -  -  +  
          +  +  +  +  +  
          +  +  +  +  -  
          -  +  +  +  +  
          +  +  +  +  +  
          +  -  -  +  +  
          +  +  +  +  +  
                      + ]
      72   [ -  +  +  +  :   65199801 :                 for (i = 0; i < (n & ~0x3); i += 4, idx += 4) {
          -  +  +  +  -  
          -  -  -  -  -  
          -  -  -  -  +  
          +  -  -  -  -  
          -  -  -  +  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  +  
          +  -  -  +  +  
          +  +  +  +  +  
          +  +  +  -  -  
          +  +  +  +  +  
          +  +  +  +  +  
          -  -  +  +  +  
          +  +  +  +  +  
          +  +  -  -  +  
          +  +  +  +  +  
                   +  + ]
      73                 :   13672260 :                         ring[idx] = obj[i];
      74                 :   13672260 :                         ring[idx + 1] = obj[i + 1];
      75                 :   13672260 :                         ring[idx + 2] = obj[i + 2];
      76                 :   13672260 :                         ring[idx + 3] = obj[i + 3];
      77                 :            :                 }
      78   [ -  -  +  -  :   51527541 :                 switch (n & 0x3) {
          -  +  +  +  -  
          -  +  -  +  +  
          +  +  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  +  +  
          +  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  +  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  +  +  
          +  -  -  -  -  
          +  +  +  +  -  
          +  +  +  -  +  
          +  +  +  +  +  
          +  +  +  +  +  
          -  -  -  -  +  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  -  
          -  -  -  -  +  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  -  -  
          -  -  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
                +  +  + ]
      79                 :         26 :                 case 3:
      80                 :         26 :                         ring[idx++] = obj[i++]; /* fallthrough */
      81                 :    6541840 :                 case 2:
      82                 :    6541840 :                         ring[idx++] = obj[i++]; /* fallthrough */
      83                 :   51479491 :                 case 1:
      84                 :   51754523 :                         ring[idx++] = obj[i++];
      85                 :            :                 }
      86                 :            :         } else {
      87   [ -  -  +  +  :    1747053 :                 for (i = 0; idx < size; i++, idx++)
          -  -  +  +  -  
          -  -  -  -  -  
          +  +  -  -  +  
          +  -  -  -  -  
          -  -  +  +  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  +  +  
          -  -  -  -  -  
          -  -  -  +  +  
          -  -  +  +  +  
          +  +  +  +  +  
          +  +  -  -  +  
          +  +  +  +  +  
          +  +  +  +  -  
          -  +  +  +  +  
          +  +  +  +  +  
          +  -  -  +  +  
          +  +  +  +  +  
                      + ]
      88                 :    1534755 :                         ring[idx] = obj[i];
      89                 :            :                 /* Start at the beginning */
      90   [ -  -  +  +  :    1691921 :                 for (idx = 0; i < n; i++, idx++)
          -  -  +  +  -  
          -  -  -  -  -  
          +  +  -  -  +  
          +  -  -  -  -  
          -  -  +  +  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  +  +  
          -  -  -  -  -  
          -  -  -  +  +  
          -  -  +  +  +  
          +  +  +  +  +  
          +  +  -  -  +  
          +  +  +  +  +  
          +  +  +  +  -  
          -  +  +  +  +  
          +  +  +  +  +  
          +  -  -  +  +  
          +  +  +  +  +  
                      + ]
      91                 :    1479623 :                         ring[idx] = obj[i];
      92                 :            :         }
      93                 :            : }
      94                 :            : 
      95                 :            : static __rte_always_inline void
      96                 :            : __rte_ring_enqueue_elems_128(struct rte_ring *r, uint32_t prod_head,
      97                 :            :                 const void *obj_table, uint32_t n)
      98                 :            : {
      99                 :            :         unsigned int i;
     100                 :      29916 :         const uint32_t size = r->size;
     101                 :      29916 :         uint32_t idx = prod_head & r->mask;
     102                 :      29916 :         rte_int128_t *ring = (rte_int128_t *)&r[1];
     103                 :            :         const rte_int128_t *obj = (const rte_int128_t *)obj_table;
     104   [ -  -  +  -  :      29916 :         if (likely(idx + n <= size)) {
          +  -  -  -  -  
          -  +  -  -  -  
          +  -  -  -  -  
          -  -  -  -  -  
          -  -  +  +  -  
          -  -  -  -  -  
          +  -  +  +  -  
          -  +  +  +  +  
          +  +  +  +  +  
          +  -  -  +  +  
          +  +  +  +  +  
                      + ]
     105   [ -  -  +  +  :     104293 :                 for (i = 0; i < (n & ~0x1); i += 2, idx += 2)
          -  -  -  -  -  
          -  +  +  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          +  +  -  +  +  
          +  +  +  +  +  
          +  +  +  +  -  
          -  +  +  +  +  
             +  +  +  + ]
     106                 :      78652 :                         memcpy((void *)(ring + idx),
     107                 :      78652 :                                 (const void *)(obj + i), 32);
     108   [ -  -  +  +  :      25641 :                 switch (n & 0x1) {
          -  -  -  -  -  
          -  +  +  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          +  +  +  -  +  
          +  +  +  +  +  
          +  +  +  +  -  
          -  +  +  +  +  
             +  +  +  + ]
     109                 :      23026 :                 case 1:
     110                 :      27144 :                         memcpy((void *)(ring + idx),
     111                 :      23026 :                                 (const void *)(obj + i), 16);
     112                 :            :                 }
     113                 :            :         } else {
     114   [ -  -  -  -  :     199519 :                 for (i = 0; idx < size; i++, idx++)
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  +  +  -  
          -  -  -  -  -  
          -  -  +  +  -  
          -  +  +  +  +  
          +  +  +  +  +  
          +  -  -  +  +  
          +  +  +  +  +  
                      + ]
     115                 :     199404 :                         memcpy((void *)(ring + idx),
     116                 :     199404 :                                 (const void *)(obj + i), 16);
     117                 :            :                 /* Start at the beginning */
     118   [ -  -  -  -  :     209354 :                 for (idx = 0; i < n; i++, idx++)
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  +  +  -  
          -  -  -  -  -  
          -  -  +  +  -  
          -  +  +  +  +  
          +  +  +  +  +  
          +  -  -  +  +  
          +  +  +  +  +  
                      + ]
     119                 :     209239 :                         memcpy((void *)(ring + idx),
     120                 :     209239 :                                 (const void *)(obj + i), 16);
     121                 :            :         }
     122                 :            : }
     123                 :            : 
     124                 :            : /* the actual enqueue of elements on the ring.
     125                 :            :  * Placed here since identical code needed in both
     126                 :            :  * single and multi producer enqueue functions.
     127                 :            :  */
     128                 :            : static __rte_always_inline void
     129                 :            : __rte_ring_enqueue_elems(struct rte_ring *r, uint32_t prod_head,
     130                 :            :                 const void *obj_table, uint32_t esize, uint32_t num)
     131                 :            : {
     132                 :            :         /* 8B and 16B copies implemented individually to retain
     133                 :            :          * the current performance.
     134                 :            :          */
     135   [ -  -  +  +  :      28643 :         if (esize == 8)
          -  +  -  -  -  
          -  -  -  -  -  
          +  +  -  -  -  
          -  -  -  -  -  
          -  -  +  +  -  
          -  -  -  -  -  
          -  -  +  +  -  
          -  +  +  +  +  
          +  +  +  +  +  
          +  -  -  +  +  
          +  +  +  +  +  
                      + ]
     136                 :            :                 __rte_ring_enqueue_elems_64(r, prod_head, obj_table, num);
     137   [ -  -  +  +  :      21755 :         else if (esize == 16)
          +  +  -  -  -  
          -  -  -  -  -  
          +  +  -  -  -  
          -  -  -  -  -  
          -  -  +  +  -  
          -  -  -  -  -  
          -  -  +  +  -  
          -  +  +  +  +  
          +  +  +  +  +  
          +  -  -  +  +  
          +  +  +  +  +  
                      + ]
     138                 :            :                 __rte_ring_enqueue_elems_128(r, prod_head, obj_table, num);
     139                 :            :         else {
     140                 :            :                 uint32_t idx, scale, nr_idx, nr_num, nr_size;
     141                 :            : 
     142                 :            :                 /* Normalize to uint32_t */
     143                 :      14833 :                 scale = esize / sizeof(uint32_t);
     144                 :       5524 :                 nr_num = num * scale;
     145                 :  179652867 :                 idx = prod_head & r->mask;
     146                 :      14833 :                 nr_idx = idx * scale;
     147   [ +  -  +  -  :  179652867 :                 nr_size = r->size * scale;
          +  -  -  -  +  
          -  +  -  +  -  
          +  -  +  -  -  
          -  -  -  -  -  
          -  -  -  +  -  
          -  -  -  -  -  
          -  -  +  +  -  
          -  +  +  +  +  
          +  +  +  +  +  
          +  -  -  +  +  
          +  +  +  +  +  
                      + ]
     148                 :            :                 __rte_ring_enqueue_elems_32(r, nr_size, nr_idx,
     149                 :            :                                 obj_table, nr_num);
     150                 :            :         }
     151                 :            : }
     152                 :            : 
     153                 :            : static __rte_always_inline void
     154                 :            : __rte_ring_dequeue_elems_32(struct rte_ring *r, const uint32_t size,
     155                 :            :                 uint32_t idx, void *obj_table, uint32_t n)
     156                 :            : {
     157                 :            :         unsigned int i;
     158                 :     418577 :         uint32_t *ring = (uint32_t *)&r[1];
     159                 :            :         uint32_t *obj = (uint32_t *)obj_table;
     160                 :     418577 :         if (likely(idx + n <= size)) {
     161   [ +  +  -  +  :     127923 :                 for (i = 0; i < (n & ~0x7); i += 8, idx += 8) {
          -  -  -  -  -  
          -  -  -  -  -  
          +  +  -  -  -  
          -  -  -  -  -  
          -  -  +  +  -  
          -  -  -  -  -  
          -  -  +  +  -  
          -  +  +  +  +  
          +  +  +  +  +  
          +  -  -  +  +  
          +  +  +  +  +  
                      + ]
     162                 :     112415 :                         obj[i] = ring[idx];
     163                 :     112415 :                         obj[i + 1] = ring[idx + 1];
     164                 :     112415 :                         obj[i + 2] = ring[idx + 2];
     165                 :     112415 :                         obj[i + 3] = ring[idx + 3];
     166                 :     112415 :                         obj[i + 4] = ring[idx + 4];
     167                 :     112415 :                         obj[i + 5] = ring[idx + 5];
     168                 :     112415 :                         obj[i + 6] = ring[idx + 6];
     169                 :     112415 :                         obj[i + 7] = ring[idx + 7];
     170                 :            :                 }
     171   [ -  +  -  -  :      15508 :                 switch (n & 0x7) {
          +  +  -  +  -  
          -  +  -  -  -  
          +  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  +  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  +  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          +  +  +  -  +  
          +  +  +  -  -  
          -  -  -  -  -  
          -  +  +  +  +  
          -  +  +  +  +  
          +  +  -  +  +  
          +  +  +  -  +  
          -  +  +  +  +  
          +  +  +  -  +  
          +  +  +  -  +  
          +  +  +  +  +  
          +  -  -  -  -  
          -  -  -  -  +  
          +  +  +  -  +  
          +  +  +  +  +  
          +  -  +  +  +  
          +  +  +  -  +  
          +  +  +  -  -  
          +  +  +  +  +  
                      + ]
     172                 :         15 :                 case 7:
     173                 :         15 :                         obj[i++] = ring[idx++]; /* fallthrough */
     174                 :       2008 :                 case 6:
     175                 :       2008 :                         obj[i++] = ring[idx++]; /* fallthrough */
     176                 :       6137 :                 case 5:
     177                 :       6137 :                         obj[i++] = ring[idx++]; /* fallthrough */
     178                 :       6145 :                 case 4:
     179                 :       6145 :                         obj[i++] = ring[idx++]; /* fallthrough */
     180                 :       6159 :                 case 3:
     181                 :       6159 :                         obj[i++] = ring[idx++]; /* fallthrough */
     182                 :       6246 :                 case 2:
     183                 :       6246 :                         obj[i++] = ring[idx++]; /* fallthrough */
     184                 :      10377 :                 case 1:
     185                 :     413219 :                         obj[i++] = ring[idx++]; /* fallthrough */
     186                 :            :                 }
     187                 :            :         } else {
     188   [ -  -  -  -  :    1245397 :                 for (i = 0; idx < size; i++, idx++)
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  +  +  -  
          -  -  -  -  -  
          -  -  +  +  -  
          -  +  +  +  +  
          +  +  +  +  +  
          +  -  -  +  +  
          +  +  +  +  +  
          +  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
                      # ]
     189                 :    1245170 :                         obj[i] = ring[idx];
     190                 :            :                 /* Start at the beginning */
     191   [ -  -  -  -  :    1249677 :                 for (idx = 0; i < n; i++, idx++)
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  +  +  -  
          -  -  -  -  -  
          -  -  +  +  -  
          -  +  +  +  +  
          +  +  +  +  +  
          +  -  -  +  +  
          +  +  +  +  +  
          +  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
                      # ]
     192                 :    1249450 :                         obj[i] = ring[idx];
     193                 :            :         }
     194                 :            : }
     195                 :            : 
     196                 :            : static __rte_always_inline void
     197                 :            : __rte_ring_dequeue_elems_64(struct rte_ring *r, uint32_t cons_head,
     198                 :            :                 void *obj_table, uint32_t n)
     199                 :            : {
     200                 :            :         unsigned int i;
     201                 :   52003274 :         const uint32_t size = r->size;
     202                 :   52003274 :         uint32_t idx = cons_head & r->mask;
     203                 :   52003274 :         uint64_t *ring = (uint64_t *)&r[1];
     204                 :            :         unaligned_uint64_t *obj = (unaligned_uint64_t *)obj_table;
     205   [ +  -  +  +  :   52003274 :         if (likely(idx + n <= size)) {
          +  +  +  +  -  
          -  -  -  -  -  
          +  -  -  -  +  
          -  -  -  -  -  
          -  -  +  +  -  
          -  -  -  -  -  
          -  -  -  -  +  
          -  -  -  -  -  
          -  -  -  -  -  
          -  +  -  -  -  
          -  -  -  -  -  
          -  -  -  +  +  
          -  -  -  -  -  
          -  -  -  +  +  
          -  -  +  +  +  
          +  +  +  +  +  
          +  +  -  -  +  
          +  +  +  +  +  
          +  +  +  +  -  
          -  +  +  +  +  
          +  +  +  +  +  
          +  -  -  +  +  
          +  +  +  +  +  
                      + ]
     206   [ +  +  +  +  :   65200861 :                 for (i = 0; i < (n & ~0x3); i += 4, idx += 4) {
          -  +  +  +  -  
          -  -  -  -  -  
          +  +  -  -  -  
          -  -  -  -  -  
          -  -  -  +  -  
          -  -  -  -  -  
          -  -  -  -  +  
          +  -  -  -  -  
          -  -  -  -  +  
          +  -  -  +  +  
          +  +  +  +  +  
          +  +  +  -  -  
          +  +  +  +  +  
          +  +  +  +  +  
          -  -  +  +  +  
          +  +  +  +  +  
          +  +  -  -  +  
          +  +  +  +  +  
                   +  + ]
     207                 :   13682811 :                         obj[i] = ring[idx];
     208                 :   13682811 :                         obj[i + 1] = ring[idx + 1];
     209                 :   13682811 :                         obj[i + 2] = ring[idx + 2];
     210                 :   13682811 :                         obj[i + 3] = ring[idx + 3];
     211                 :            :                 }
     212   [ -  +  +  -  :   51518050 :                 switch (n & 0x3) {
          -  +  +  +  -  
          -  +  -  +  +  
          +  +  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  +  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  +  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          +  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  +  +  
          +  -  -  -  -  
          +  +  +  +  -  
          +  +  +  -  +  
          +  +  +  +  +  
          +  +  +  +  +  
          -  -  -  -  +  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  -  
          -  -  -  -  +  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  -  -  
          -  -  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
                +  +  + ]
     213                 :         35 :                 case 3:
     214                 :         35 :                         obj[i++] = ring[idx++]; /* fallthrough */
     215                 :    6541819 :                 case 2:
     216                 :    6541819 :                         obj[i++] = ring[idx++]; /* fallthrough */
     217                 :   51480131 :                 case 1:
     218                 :   51754079 :                         obj[i++] = ring[idx++]; /* fallthrough */
     219                 :            :                 }
     220                 :            :         } else {
     221   [ -  -  +  +  :    1728981 :                 for (i = 0; idx < size; i++, idx++)
          +  +  +  +  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  +  +  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  +  +  
          -  -  -  -  -  
          -  -  -  +  +  
          -  -  +  +  +  
          +  +  +  +  +  
          +  +  -  -  +  
          +  +  +  +  +  
          +  +  +  +  -  
          -  +  +  +  +  
          +  +  +  +  +  
          +  -  -  +  +  
          +  +  +  +  +  
                      + ]
     222                 :    1517705 :                         obj[i] = ring[idx];
     223                 :            :                 /* Start at the beginning */
     224   [ -  -  +  +  :    1659135 :                 for (idx = 0; i < n; i++, idx++)
          +  +  +  +  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  +  +  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  +  +  
          -  -  -  -  -  
          -  -  -  +  +  
          -  -  +  +  +  
          +  +  +  +  +  
          +  +  -  -  +  
          +  +  +  +  +  
          +  +  +  +  -  
          -  +  +  +  +  
          +  +  +  +  +  
          +  -  -  +  +  
          +  +  +  +  +  
                      + ]
     225                 :    1447859 :                         obj[i] = ring[idx];
     226                 :            :         }
     227                 :            : }
     228                 :            : 
     229                 :            : static __rte_always_inline void
     230                 :            : __rte_ring_dequeue_elems_128(struct rte_ring *r, uint32_t cons_head,
     231                 :            :                 void *obj_table, uint32_t n)
     232                 :            : {
     233                 :            :         unsigned int i;
     234                 :      29668 :         const uint32_t size = r->size;
     235                 :      29668 :         uint32_t idx = cons_head & r->mask;
     236                 :      29668 :         rte_int128_t *ring = (rte_int128_t *)&r[1];
     237                 :            :         rte_int128_t *obj = (rte_int128_t *)obj_table;
     238   [ +  -  +  -  :      29668 :         if (likely(idx + n <= size)) {
          -  -  -  -  -  
          -  +  -  -  -  
          +  -  -  -  +  
          -  -  -  -  -  
          -  -  +  +  -  
          -  -  -  -  -  
          -  -  +  +  -  
          -  +  +  +  +  
          +  +  +  +  +  
          +  -  -  +  +  
          +  +  +  +  +  
                      + ]
     239   [ -  -  +  +  :     104184 :                 for (i = 0; i < (n & ~0x1); i += 2, idx += 2)
          -  -  -  -  -  
          -  +  +  -  -  
          +  +  -  -  +  
          +  -  -  -  -  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  -  
          -  +  +  +  +  
             +  +  +  + ]
     240                 :      78773 :                         memcpy((void *)(obj + i), (void *)(ring + idx), 32);
     241   [ -  -  +  +  :      25411 :                 switch (n & 0x1) {
          -  -  -  -  -  
          -  +  +  -  -  
          -  +  -  -  +  
          +  -  -  -  -  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  -  
          -  +  +  +  +  
             +  +  +  + ]
     242                 :      22785 :                 case 1:
     243                 :      26927 :                         memcpy((void *)(obj + i), (void *)(ring + idx), 16);
     244                 :            :                 }
     245                 :            :         } else {
     246   [ -  -  -  -  :     199519 :                 for (i = 0; idx < size; i++, idx++)
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  +  +  -  
          -  -  -  -  -  
          -  -  +  +  -  
          -  +  +  +  +  
          +  +  +  +  +  
          +  -  -  +  +  
          +  +  +  +  +  
                      + ]
     247                 :     199404 :                         memcpy((void *)(obj + i), (void *)(ring + idx), 16);
     248                 :            :                 /* Start at the beginning */
     249   [ -  -  -  -  :     209354 :                 for (idx = 0; i < n; i++, idx++)
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  +  +  -  
          -  -  -  -  -  
          -  -  +  +  -  
          -  +  +  +  +  
          +  +  +  +  +  
          +  -  -  +  +  
          +  +  +  +  +  
                      + ]
     250                 :     209239 :                         memcpy((void *)(obj + i), (void *)(ring + idx), 16);
     251                 :            :         }
     252                 :            : }
     253                 :            : 
     254                 :            : /* the actual dequeue of elements from the ring.
     255                 :            :  * Placed here since identical code needed in both
     256                 :            :  * single and multi producer enqueue functions.
     257                 :            :  */
     258                 :            : static __rte_always_inline void
     259                 :            : __rte_ring_dequeue_elems(struct rte_ring *r, uint32_t cons_head,
     260                 :            :                 void *obj_table, uint32_t esize, uint32_t num)
     261                 :            : {
     262                 :            :         /* 8B and 16B copies implemented individually to retain
     263                 :            :          * the current performance.
     264                 :            :          */
     265   [ -  +  +  +  :      29497 :         if (esize == 8)
          -  -  -  -  -  
          -  -  -  -  -  
          +  +  -  -  -  
          -  -  -  -  -  
          -  -  +  +  -  
          -  -  -  -  -  
          -  -  +  +  -  
          -  +  +  +  +  
          +  +  +  +  +  
          +  -  -  +  +  
          +  +  +  +  +  
                      + ]
     266                 :            :                 __rte_ring_dequeue_elems_64(r, cons_head, obj_table, num);
     267   [ +  +  +  +  :      22639 :         else if (esize == 16)
          -  -  -  -  -  
          -  -  -  -  -  
          +  +  -  -  -  
          -  -  -  -  -  
          -  -  +  +  -  
          -  -  -  -  -  
          -  -  +  +  -  
          -  +  +  +  +  
          +  +  +  +  +  
          +  -  -  +  +  
          +  +  +  +  +  
                      + ]
     268                 :            :                 __rte_ring_dequeue_elems_128(r, cons_head, obj_table, num);
     269                 :            :         else {
     270                 :            :                 uint32_t idx, scale, nr_idx, nr_num, nr_size;
     271                 :            : 
     272                 :            :                 /* Normalize to uint32_t */
     273                 :      15734 :                 scale = esize / sizeof(uint32_t);
     274                 :       7544 :                 nr_num = num * scale;
     275                 :     418577 :                 idx = cons_head & r->mask;
     276                 :      15734 :                 nr_idx = idx * scale;
     277   [ +  -  +  -  :     418577 :                 nr_size = r->size * scale;
          +  -  +  -  -  
          -  -  -  -  -  
          +  -  -  -  -  
          -  -  -  -  -  
          -  -  +  +  -  
          -  -  -  -  -  
          -  -  +  +  -  
          -  +  +  +  +  
          +  +  +  +  +  
          +  -  -  +  +  
          +  +  +  +  +  
          +  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
                      # ]
     278                 :            :                 __rte_ring_dequeue_elems_32(r, nr_size, nr_idx,
     279                 :            :                                 obj_table, nr_num);
     280                 :            :         }
     281                 :            : }
     282                 :            : 
     283                 :            : /* Between load and load. there might be cpu reorder in weak model
     284                 :            :  * (powerpc/arm).
     285                 :            :  * There are 2 choices for the users
     286                 :            :  * 1.use rmb() memory barrier
     287                 :            :  * 2.use one-direction load_acquire/store_release barrier
     288                 :            :  * It depends on performance test results.
     289                 :            :  */
     290                 :            : #ifdef RTE_USE_C11_MEM_MODEL
     291                 :            : #include "rte_ring_c11_pvt.h"
     292                 :            : #else
     293                 :            : #include "rte_ring_generic_pvt.h"
     294                 :            : #endif
     295                 :            : 
     296                 :            : /**
     297                 :            :  * @internal Enqueue several objects on the ring
     298                 :            :  *
     299                 :            :  * @param r
     300                 :            :  *   A pointer to the ring structure.
     301                 :            :  * @param obj_table
     302                 :            :  *   A pointer to a table of objects.
     303                 :            :  * @param esize
     304                 :            :  *   The size of ring element, in bytes. It must be a multiple of 4.
     305                 :            :  *   This must be the same value used while creating the ring. Otherwise
     306                 :            :  *   the results are undefined.
     307                 :            :  * @param n
     308                 :            :  *   The number of objects to add in the ring from the obj_table.
     309                 :            :  * @param behavior
     310                 :            :  *   RTE_RING_QUEUE_FIXED:    Enqueue a fixed number of items from a ring
     311                 :            :  *   RTE_RING_QUEUE_VARIABLE: Enqueue as many items as possible from ring
     312                 :            :  * @param is_sp
     313                 :            :  *   Indicates whether to use single producer or multi-producer head update
     314                 :            :  * @param free_space
     315                 :            :  *   returns the amount of space after the enqueue operation has finished
     316                 :            :  * @return
     317                 :            :  *   Actual number of objects enqueued.
     318                 :            :  *   If behavior == RTE_RING_QUEUE_FIXED, this will be 0 or n only.
     319                 :            :  */
     320                 :            : static __rte_always_inline unsigned int
     321                 :            : __rte_ring_do_enqueue_elem(struct rte_ring *r, const void *obj_table,
     322                 :            :                 unsigned int esize, unsigned int n,
     323                 :            :                 enum rte_ring_queue_behavior behavior, unsigned int is_sp,
     324                 :            :                 unsigned int *free_space)
     325                 :            : {
     326                 :            :         uint32_t prod_head, prod_next;
     327                 :            :         uint32_t free_entries;
     328                 :            : 
     329                 :            :         n = __rte_ring_move_prod_head(r, is_sp, n, behavior,
     330                 :            :                         &prod_head, &prod_next, &free_entries);
     331   [ -  +  -  -  :   44726321 :         if (n == 0)
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
                      + ]
     332                 :         43 :                 goto end;
     333                 :            : 
     334                 :            :         __rte_ring_enqueue_elems(r, prod_head, obj_table, esize, n);
     335                 :            : 
     336                 :            :         __rte_ring_update_tail(&r->prod, prod_head, prod_next, is_sp, 1);
     337   [ +  -  #  #  :   44743779 : end:
             #  #  #  # ]
     338   [ -  +  -  -  :       8310 :         if (free_space != NULL)
          -  +  -  +  -  
          +  -  -  -  +  
          -  +  -  +  -  
          -  -  +  -  +  
          -  +  -  -  -  
                +  -  + ]
     339                 :       9297 :                 *free_space = free_entries - n;
     340                 :            :         return n;
     341                 :            : }
     342                 :            : 
     343                 :            : /**
     344                 :            :  * @internal Dequeue several objects from the ring
     345                 :            :  *
     346                 :            :  * @param r
     347                 :            :  *   A pointer to the ring structure.
     348                 :            :  * @param obj_table
     349                 :            :  *   A pointer to a table of objects.
     350                 :            :  * @param esize
     351                 :            :  *   The size of ring element, in bytes. It must be a multiple of 4.
     352                 :            :  *   This must be the same value used while creating the ring. Otherwise
     353                 :            :  *   the results are undefined.
     354                 :            :  * @param n
     355                 :            :  *   The number of objects to pull from the ring.
     356                 :            :  * @param behavior
     357                 :            :  *   RTE_RING_QUEUE_FIXED:    Dequeue a fixed number of items from a ring
     358                 :            :  *   RTE_RING_QUEUE_VARIABLE: Dequeue as many items as possible from ring
     359                 :            :  * @param is_sc
     360                 :            :  *   Indicates whether to use single consumer or multi-consumer head update
     361                 :            :  * @param available
     362                 :            :  *   returns the number of remaining ring entries after the dequeue has finished
     363                 :            :  * @return
     364                 :            :  *   - Actual number of objects dequeued.
     365                 :            :  *     If behavior == RTE_RING_QUEUE_FIXED, this will be 0 or n only.
     366                 :            :  */
     367                 :            : static __rte_always_inline unsigned int
     368                 :            : __rte_ring_do_dequeue_elem(struct rte_ring *r, void *obj_table,
     369                 :            :                 unsigned int esize, unsigned int n,
     370                 :            :                 enum rte_ring_queue_behavior behavior, unsigned int is_sc,
     371                 :            :                 unsigned int *available)
     372                 :            : {
     373                 :            :         uint32_t cons_head, cons_next;
     374                 :            :         uint32_t entries;
     375                 :            : 
     376                 :            :         n = __rte_ring_move_cons_head(r, (int)is_sc, n, behavior,
     377                 :            :                         &cons_head, &cons_next, &entries);
     378   [ +  +  +  +  :   55473832 :         if (n == 0)
          -  +  -  +  -  
          -  -  +  -  -  
          -  +  -  -  -  
          +  -  -  -  -  
          -  -  -  +  -  
          -  -  -  -  -  
          -  +  -  -  -  
          -  -  -  -  +  
          -  -  -  -  -  
          +  -  -  -  +  
          -  +  -  +  -  
          -  -  +  -  +  
          -  +  -  -  -  
          +  -  +  -  +  
          -  -  -  +  -  
          +  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
                #  #  # ]
     379                 :   19833112 :                 goto end;
     380                 :            : 
     381                 :            :         __rte_ring_dequeue_elems(r, cons_head, obj_table, esize, n);
     382                 :            : 
     383                 :            :         __rte_ring_update_tail(&r->cons, cons_head, cons_next, is_sc, 0);
     384                 :            : 
     385   [ +  +  +  -  :   48909384 : end:
             +  -  +  - ]
     386   [ -  +  -  -  :       8280 :         if (available != NULL)
          -  +  -  +  -  
          +  -  -  -  +  
          -  +  -  +  -  
          -  -  +  -  +  
          -  +  -  -  -  
                +  -  + ]
     387                 :          2 :                 *available = entries - n;
     388                 :            :         return n;
     389                 :            : }
     390                 :            : 
     391                 :            : #if defined(RTE_TOOLCHAIN_GCC) && (GCC_VERSION >= 120000)
     392                 :            : #pragma GCC diagnostic pop
     393                 :            : #endif
     394                 :            : 
     395                 :            : #endif /* _RTE_RING_ELEM_PVT_H_ */

Generated by: LCOV version 1.14