LCOV - code coverage report
Current view: top level - lib/eal/common - eal_common_interrupts.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 83 249 33.3 %
Date: 2026-11-01 19:11:22 Functions: 13 28 46.4 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 36 118 30.5 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright(C) 2021 Marvell.
       3                 :            :  */
       4                 :            : 
       5                 :            : #include <stdlib.h>
       6                 :            : #include <string.h>
       7                 :            : #include <unistd.h>
       8                 :            : 
       9                 :            : #include <rte_errno.h>
      10                 :            : #include <rte_interrupts.h>
      11                 :            : #include <rte_log.h>
      12                 :            : #include <rte_malloc.h>
      13                 :            : 
      14                 :            : #include <eal_export.h>
      15                 :            : #include "eal_interrupts.h"
      16                 :            : #include "eal_private.h"
      17                 :            : 
      18                 :            : /* Macros to check for valid interrupt handle */
      19                 :            : #define CHECK_VALID_INTR_HANDLE(intr_handle) do { \
      20                 :            :         if (intr_handle == NULL) { \
      21                 :            :                 EAL_LOG(DEBUG, "%s, ln %d: Interrupt instance unallocated", __func__, __LINE__); \
      22                 :            :                 rte_errno = EINVAL; \
      23                 :            :                 goto fail; \
      24                 :            :         } \
      25                 :            : } while (0)
      26                 :            : 
      27                 :            : #define RTE_INTR_INSTANCE_KNOWN_FLAGS (RTE_INTR_INSTANCE_F_PRIVATE \
      28                 :            :         | RTE_INTR_INSTANCE_F_SHARED \
      29                 :            :         )
      30                 :            : 
      31                 :            : #define RTE_INTR_INSTANCE_USES_RTE_MEMORY(flags) \
      32                 :            :         (!!(flags & RTE_INTR_INSTANCE_F_SHARED))
      33                 :            : 
      34                 :            : RTE_EXPORT_SYMBOL(rte_intr_instance_alloc)
      35                 :        614 : struct rte_intr_handle *rte_intr_instance_alloc(uint32_t flags)
      36                 :            : {
      37                 :            :         struct rte_intr_handle *intr_handle;
      38                 :            :         bool uses_rte_memory;
      39                 :            : 
      40                 :            :         /* Check the flag passed by user, it should be part of the
      41                 :            :          * defined flags.
      42                 :            :          */
      43         [ -  + ]:        614 :         if ((flags & ~RTE_INTR_INSTANCE_KNOWN_FLAGS) != 0) {
      44                 :          0 :                 EAL_LOG(DEBUG, "Invalid alloc flag passed 0x%x", flags);
      45                 :          0 :                 rte_errno = EINVAL;
      46                 :          0 :                 return NULL;
      47                 :            :         }
      48                 :            : 
      49                 :        614 :         uses_rte_memory = RTE_INTR_INSTANCE_USES_RTE_MEMORY(flags);
      50         [ +  + ]:        614 :         if (uses_rte_memory)
      51                 :          4 :                 intr_handle = rte_zmalloc(NULL, sizeof(*intr_handle), 0);
      52                 :            :         else
      53                 :        610 :                 intr_handle = calloc(1, sizeof(*intr_handle));
      54         [ -  + ]:        614 :         if (intr_handle == NULL) {
      55                 :          0 :                 EAL_LOG(ERR, "Failed to allocate intr_handle");
      56                 :          0 :                 rte_errno = ENOMEM;
      57                 :          0 :                 return NULL;
      58                 :            :         }
      59                 :            : 
      60         [ +  + ]:        614 :         if (uses_rte_memory) {
      61                 :          4 :                 intr_handle->efds = rte_zmalloc(NULL,
      62                 :            :                         RTE_MAX_RXTX_INTR_VEC_ID * sizeof(int), 0);
      63                 :            :         } else {
      64                 :        610 :                 intr_handle->efds = calloc(RTE_MAX_RXTX_INTR_VEC_ID,
      65                 :            :                         sizeof(int));
      66                 :            :         }
      67         [ -  + ]:        614 :         if (intr_handle->efds == NULL) {
      68                 :          0 :                 EAL_LOG(ERR, "Fail to allocate event fd list");
      69                 :          0 :                 rte_errno = ENOMEM;
      70                 :          0 :                 goto fail;
      71                 :            :         }
      72         [ +  + ]:     314982 :         for (int i = 0; i < RTE_MAX_RXTX_INTR_VEC_ID; i++)
      73                 :     314368 :                 intr_handle->efds[i] = -1;
      74                 :            : 
      75         [ +  + ]:        614 :         if (uses_rte_memory) {
      76                 :          4 :                 intr_handle->elist = rte_zmalloc(NULL,
      77                 :            :                         RTE_MAX_RXTX_INTR_VEC_ID * sizeof(struct rte_epoll_event),
      78                 :            :                         0);
      79                 :            :         } else {
      80                 :        610 :                 intr_handle->elist = calloc(RTE_MAX_RXTX_INTR_VEC_ID,
      81                 :            :                         sizeof(struct rte_epoll_event));
      82                 :            :         }
      83         [ -  + ]:        614 :         if (intr_handle->elist == NULL) {
      84                 :          0 :                 EAL_LOG(ERR, "fail to allocate event fd list");
      85                 :          0 :                 rte_errno = ENOMEM;
      86                 :          0 :                 goto fail;
      87                 :            :         }
      88                 :            : 
      89                 :        614 :         intr_handle->fd = -1;
      90                 :        614 :         intr_handle->dev_fd = -1;
      91                 :        614 :         intr_handle->alloc_flags = flags;
      92                 :        614 :         intr_handle->nb_intr = RTE_MAX_RXTX_INTR_VEC_ID;
      93                 :            : 
      94                 :        614 :         return intr_handle;
      95                 :          0 : fail:
      96         [ #  # ]:          0 :         if (uses_rte_memory) {
      97                 :          0 :                 rte_free(intr_handle->efds);
      98                 :          0 :                 rte_free(intr_handle);
      99                 :            :         } else {
     100                 :          0 :                 free(intr_handle->efds);
     101                 :          0 :                 free(intr_handle);
     102                 :            :         }
     103                 :            :         return NULL;
     104                 :            : }
     105                 :            : 
     106                 :            : RTE_EXPORT_INTERNAL_SYMBOL(rte_intr_event_list_update)
     107                 :          0 : int rte_intr_event_list_update(struct rte_intr_handle *intr_handle, int size)
     108                 :            : {
     109                 :            :         struct rte_epoll_event *tmp_elist;
     110                 :            :         bool uses_rte_memory;
     111                 :            :         int *tmp_efds;
     112                 :            : 
     113         [ #  # ]:          0 :         CHECK_VALID_INTR_HANDLE(intr_handle);
     114                 :            : 
     115         [ #  # ]:          0 :         if (size == 0) {
     116                 :          0 :                 EAL_LOG(DEBUG, "Size can't be zero");
     117                 :          0 :                 rte_errno = EINVAL;
     118                 :          0 :                 goto fail;
     119                 :            :         }
     120                 :            : 
     121                 :            :         uses_rte_memory =
     122                 :          0 :                 RTE_INTR_INSTANCE_USES_RTE_MEMORY(intr_handle->alloc_flags);
     123         [ #  # ]:          0 :         if (uses_rte_memory) {
     124                 :          0 :                 tmp_efds = rte_realloc(intr_handle->efds, size * sizeof(int),
     125                 :            :                         0);
     126                 :            :         } else {
     127                 :          0 :                 tmp_efds = realloc(intr_handle->efds, size * sizeof(int));
     128                 :            :         }
     129         [ #  # ]:          0 :         if (tmp_efds == NULL) {
     130                 :          0 :                 EAL_LOG(ERR, "Failed to realloc the efds list");
     131                 :          0 :                 rte_errno = ENOMEM;
     132                 :          0 :                 goto fail;
     133                 :            :         }
     134                 :          0 :         intr_handle->efds = tmp_efds;
     135         [ #  # ]:          0 :         for (int i = intr_handle->nb_intr; i < size; i++)
     136                 :          0 :                 intr_handle->efds[i] = -1;
     137                 :            : 
     138         [ #  # ]:          0 :         if (uses_rte_memory) {
     139                 :          0 :                 tmp_elist = rte_realloc(intr_handle->elist,
     140                 :            :                         size * sizeof(struct rte_epoll_event), 0);
     141                 :            :         } else {
     142                 :          0 :                 tmp_elist = realloc(intr_handle->elist,
     143                 :            :                         size * sizeof(struct rte_epoll_event));
     144                 :            :         }
     145         [ #  # ]:          0 :         if (tmp_elist == NULL) {
     146                 :          0 :                 EAL_LOG(ERR, "Failed to realloc the event list");
     147                 :          0 :                 rte_errno = ENOMEM;
     148                 :          0 :                 goto fail;
     149                 :            :         }
     150                 :          0 :         intr_handle->elist = tmp_elist;
     151                 :            : 
     152                 :          0 :         intr_handle->nb_intr = size;
     153                 :            : 
     154                 :          0 :         return 0;
     155                 :          0 : fail:
     156                 :          0 :         return -rte_errno;
     157                 :            : }
     158                 :            : 
     159                 :            : RTE_EXPORT_SYMBOL(rte_intr_instance_free)
     160                 :        387 : void rte_intr_instance_free(struct rte_intr_handle *intr_handle)
     161                 :            : {
     162         [ +  - ]:        387 :         if (intr_handle == NULL)
     163                 :            :                 return;
     164         [ -  + ]:        387 :         if (rte_intr_fd_get(intr_handle) >= 0)
     165                 :          0 :                 EAL_LOG(NOTICE, "Some interrupt handle is leaking a FD: %d",
     166                 :            :                         rte_intr_fd_get(intr_handle));
     167         [ -  + ]:        387 :         if (rte_intr_dev_fd_get(intr_handle) >= 0)
     168                 :          0 :                 EAL_LOG(NOTICE, "Some interrupt handle is leaking a device FD: %d",
     169                 :            :                         rte_intr_dev_fd_get(intr_handle));
     170         [ +  + ]:     198531 :         for (int i = 0; i < intr_handle->nb_intr; i++) {
     171         [ -  + ]:     198144 :                 if (intr_handle->efds[i] >= 0)
     172                 :          0 :                         EAL_LOG(NOTICE, "Some interrupt handle is leaking an event FD: %d (index %d)",
     173                 :            :                                 intr_handle->efds[i], i);
     174                 :            :         }
     175         [ +  + ]:        387 :         if (RTE_INTR_INSTANCE_USES_RTE_MEMORY(intr_handle->alloc_flags)) {
     176                 :          4 :                 rte_free(intr_handle->efds);
     177                 :          4 :                 rte_free(intr_handle->elist);
     178                 :          4 :                 rte_free(intr_handle);
     179                 :            :         } else {
     180                 :        383 :                 free(intr_handle->efds);
     181                 :        383 :                 free(intr_handle->elist);
     182                 :        383 :                 free(intr_handle);
     183                 :            :         }
     184                 :            : }
     185                 :            : 
     186                 :            : RTE_EXPORT_SYMBOL(rte_intr_fd_set)
     187                 :        244 : int rte_intr_fd_set(struct rte_intr_handle *intr_handle, int fd)
     188                 :            : {
     189         [ -  + ]:        244 :         CHECK_VALID_INTR_HANDLE(intr_handle);
     190                 :            : 
     191                 :        244 :         intr_handle->fd = fd;
     192                 :            : 
     193                 :        244 :         return 0;
     194                 :            : fail:
     195                 :          0 :         return -rte_errno;
     196                 :            : }
     197                 :            : 
     198                 :            : RTE_EXPORT_SYMBOL(rte_intr_fd_get)
     199                 :    1301154 : int rte_intr_fd_get(const struct rte_intr_handle *intr_handle)
     200                 :            : {
     201         [ +  + ]:    1301154 :         CHECK_VALID_INTR_HANDLE(intr_handle);
     202                 :            : 
     203                 :    1301082 :         return intr_handle->fd;
     204                 :            : fail:
     205                 :         72 :         return -1;
     206                 :            : }
     207                 :            : 
     208                 :            : RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_intr_fd_close, 26.11)
     209                 :          5 : void rte_intr_fd_close(struct rte_intr_handle *intr_handle)
     210                 :            : {
     211                 :          5 :         int fd = rte_intr_fd_get(intr_handle);
     212                 :            : 
     213         [ +  + ]:          5 :         if (fd >= 0) {
     214                 :          3 :                 close(fd);
     215                 :          3 :                 rte_intr_fd_set(intr_handle, -1);
     216                 :            :         }
     217                 :          5 : }
     218                 :            : 
     219                 :            : RTE_EXPORT_SYMBOL(rte_intr_type_set)
     220                 :        239 : int rte_intr_type_set(struct rte_intr_handle *intr_handle,
     221                 :            :         enum rte_intr_handle_type type)
     222                 :            : {
     223         [ -  + ]:        239 :         CHECK_VALID_INTR_HANDLE(intr_handle);
     224                 :            : 
     225                 :        239 :         intr_handle->type = type;
     226                 :            : 
     227                 :        239 :         return 0;
     228                 :            : fail:
     229                 :          0 :         return -rte_errno;
     230                 :            : }
     231                 :            : 
     232                 :            : RTE_EXPORT_SYMBOL(rte_intr_type_get)
     233                 :     780106 : enum rte_intr_handle_type rte_intr_type_get(
     234                 :            :         const struct rte_intr_handle *intr_handle)
     235                 :            : {
     236         [ -  + ]:     780106 :         CHECK_VALID_INTR_HANDLE(intr_handle);
     237                 :            : 
     238                 :     780106 :         return intr_handle->type;
     239                 :            : fail:
     240                 :          0 :         return RTE_INTR_HANDLE_UNKNOWN;
     241                 :            : }
     242                 :            : 
     243                 :            : RTE_EXPORT_INTERNAL_SYMBOL(rte_intr_dev_fd_set)
     244                 :         10 : int rte_intr_dev_fd_set(struct rte_intr_handle *intr_handle, int fd)
     245                 :            : {
     246         [ -  + ]:         10 :         CHECK_VALID_INTR_HANDLE(intr_handle);
     247                 :            : 
     248                 :         10 :         intr_handle->dev_fd = fd;
     249                 :            : 
     250                 :         10 :         return 0;
     251                 :            : fail:
     252                 :          0 :         return -rte_errno;
     253                 :            : }
     254                 :            : 
     255                 :            : RTE_EXPORT_INTERNAL_SYMBOL(rte_intr_dev_fd_get)
     256                 :        409 : int rte_intr_dev_fd_get(const struct rte_intr_handle *intr_handle)
     257                 :            : {
     258         [ +  + ]:        409 :         CHECK_VALID_INTR_HANDLE(intr_handle);
     259                 :            : 
     260                 :        408 :         return intr_handle->dev_fd;
     261                 :            : fail:
     262                 :          1 :         return -1;
     263                 :            : }
     264                 :            : 
     265                 :            : RTE_EXPORT_INTERNAL_SYMBOL(rte_intr_dev_fd_close)
     266                 :          3 : void rte_intr_dev_fd_close(struct rte_intr_handle *intr_handle)
     267                 :            : {
     268                 :          3 :         int fd = rte_intr_dev_fd_get(intr_handle);
     269                 :            : 
     270         [ +  + ]:          3 :         if (fd >= 0) {
     271                 :          1 :                 close(fd);
     272                 :          1 :                 rte_intr_dev_fd_set(intr_handle, -1);
     273                 :            :         }
     274                 :          3 : }
     275                 :            : 
     276                 :            : RTE_EXPORT_INTERNAL_SYMBOL(rte_intr_max_intr_set)
     277                 :          0 : int rte_intr_max_intr_set(struct rte_intr_handle *intr_handle,
     278                 :            :                                  int max_intr)
     279                 :            : {
     280         [ #  # ]:          0 :         CHECK_VALID_INTR_HANDLE(intr_handle);
     281                 :            : 
     282         [ #  # ]:          0 :         if (max_intr > intr_handle->nb_intr) {
     283                 :          0 :                 EAL_LOG(DEBUG, "Maximum interrupt vector ID (%d) exceeds "
     284                 :            :                         "the number of available events (%d)", max_intr,
     285                 :            :                         intr_handle->nb_intr);
     286                 :          0 :                 rte_errno = ERANGE;
     287                 :          0 :                 goto fail;
     288                 :            :         }
     289                 :            : 
     290                 :          0 :         intr_handle->max_intr = max_intr;
     291                 :            : 
     292                 :          0 :         return 0;
     293                 :          0 : fail:
     294                 :          0 :         return -rte_errno;
     295                 :            : }
     296                 :            : 
     297                 :            : RTE_EXPORT_INTERNAL_SYMBOL(rte_intr_max_intr_get)
     298                 :          0 : int rte_intr_max_intr_get(const struct rte_intr_handle *intr_handle)
     299                 :            : {
     300         [ #  # ]:          0 :         CHECK_VALID_INTR_HANDLE(intr_handle);
     301                 :            : 
     302                 :          0 :         return intr_handle->max_intr;
     303                 :            : fail:
     304                 :          0 :         return -rte_errno;
     305                 :            : }
     306                 :            : 
     307                 :            : RTE_EXPORT_INTERNAL_SYMBOL(rte_intr_nb_efd_set)
     308                 :          8 : int rte_intr_nb_efd_set(struct rte_intr_handle *intr_handle, int nb_efd)
     309                 :            : {
     310         [ -  + ]:          8 :         CHECK_VALID_INTR_HANDLE(intr_handle);
     311                 :            : 
     312                 :          8 :         intr_handle->nb_efd = nb_efd;
     313                 :            : 
     314                 :          8 :         return 0;
     315                 :            : fail:
     316                 :          0 :         return -rte_errno;
     317                 :            : }
     318                 :            : 
     319                 :            : RTE_EXPORT_INTERNAL_SYMBOL(rte_intr_nb_efd_get)
     320                 :          8 : int rte_intr_nb_efd_get(const struct rte_intr_handle *intr_handle)
     321                 :            : {
     322         [ -  + ]:          8 :         CHECK_VALID_INTR_HANDLE(intr_handle);
     323                 :            : 
     324                 :          8 :         return intr_handle->nb_efd;
     325                 :            : fail:
     326                 :          0 :         return -rte_errno;
     327                 :            : }
     328                 :            : 
     329                 :            : RTE_EXPORT_INTERNAL_SYMBOL(rte_intr_nb_intr_get)
     330                 :          0 : int rte_intr_nb_intr_get(const struct rte_intr_handle *intr_handle)
     331                 :            : {
     332         [ #  # ]:          0 :         CHECK_VALID_INTR_HANDLE(intr_handle);
     333                 :            : 
     334                 :          0 :         return intr_handle->nb_intr;
     335                 :            : fail:
     336                 :          0 :         return -rte_errno;
     337                 :            : }
     338                 :            : 
     339                 :            : RTE_EXPORT_INTERNAL_SYMBOL(rte_intr_efd_counter_size_set)
     340                 :          0 : int rte_intr_efd_counter_size_set(struct rte_intr_handle *intr_handle,
     341                 :            :         uint8_t efd_counter_size)
     342                 :            : {
     343         [ #  # ]:          0 :         CHECK_VALID_INTR_HANDLE(intr_handle);
     344                 :            : 
     345                 :          0 :         intr_handle->efd_counter_size = efd_counter_size;
     346                 :            : 
     347                 :          0 :         return 0;
     348                 :            : fail:
     349                 :          0 :         return -rte_errno;
     350                 :            : }
     351                 :            : 
     352                 :            : RTE_EXPORT_INTERNAL_SYMBOL(rte_intr_efd_counter_size_get)
     353                 :          0 : int rte_intr_efd_counter_size_get(const struct rte_intr_handle *intr_handle)
     354                 :            : {
     355         [ #  # ]:          0 :         CHECK_VALID_INTR_HANDLE(intr_handle);
     356                 :            : 
     357                 :          0 :         return intr_handle->efd_counter_size;
     358                 :            : fail:
     359                 :          0 :         return -rte_errno;
     360                 :            : }
     361                 :            : 
     362                 :            : RTE_EXPORT_INTERNAL_SYMBOL(rte_intr_efds_index_get)
     363                 :          0 : int rte_intr_efds_index_get(const struct rte_intr_handle *intr_handle,
     364                 :            :         int index)
     365                 :            : {
     366         [ #  # ]:          0 :         CHECK_VALID_INTR_HANDLE(intr_handle);
     367                 :            : 
     368         [ #  # ]:          0 :         if (index >= intr_handle->nb_intr) {
     369                 :          0 :                 EAL_LOG(DEBUG, "Invalid index %d, max limit %d", index,
     370                 :            :                         intr_handle->nb_intr);
     371                 :          0 :                 rte_errno = EINVAL;
     372                 :          0 :                 goto fail;
     373                 :            :         }
     374                 :            : 
     375                 :          0 :         return intr_handle->efds[index];
     376                 :          0 : fail:
     377                 :          0 :         return -rte_errno;
     378                 :            : }
     379                 :            : 
     380                 :            : RTE_EXPORT_INTERNAL_SYMBOL(rte_intr_efds_index_set)
     381                 :          0 : int rte_intr_efds_index_set(struct rte_intr_handle *intr_handle,
     382                 :            :         int index, int fd)
     383                 :            : {
     384         [ #  # ]:          0 :         CHECK_VALID_INTR_HANDLE(intr_handle);
     385                 :            : 
     386         [ #  # ]:          0 :         if (index >= intr_handle->nb_intr) {
     387                 :          0 :                 EAL_LOG(DEBUG, "Invalid index %d, max limit %d", index,
     388                 :            :                         intr_handle->nb_intr);
     389                 :          0 :                 rte_errno = ERANGE;
     390                 :          0 :                 goto fail;
     391                 :            :         }
     392                 :            : 
     393                 :          0 :         intr_handle->efds[index] = fd;
     394                 :            : 
     395                 :          0 :         return 0;
     396                 :          0 : fail:
     397                 :          0 :         return -rte_errno;
     398                 :            : }
     399                 :            : 
     400                 :            : RTE_EXPORT_INTERNAL_SYMBOL(rte_intr_elist_index_get)
     401                 :          0 : struct rte_epoll_event *rte_intr_elist_index_get(
     402                 :            :         struct rte_intr_handle *intr_handle, int index)
     403                 :            : {
     404         [ #  # ]:          0 :         CHECK_VALID_INTR_HANDLE(intr_handle);
     405                 :            : 
     406         [ #  # ]:          0 :         if (index >= intr_handle->nb_intr) {
     407                 :          0 :                 EAL_LOG(DEBUG, "Invalid index %d, max limit %d", index,
     408                 :            :                         intr_handle->nb_intr);
     409                 :          0 :                 rte_errno = ERANGE;
     410                 :          0 :                 goto fail;
     411                 :            :         }
     412                 :            : 
     413                 :          0 :         return &intr_handle->elist[index];
     414                 :            : fail:
     415                 :            :         return NULL;
     416                 :            : }
     417                 :            : 
     418                 :            : RTE_EXPORT_INTERNAL_SYMBOL(rte_intr_elist_index_set)
     419                 :          0 : int rte_intr_elist_index_set(struct rte_intr_handle *intr_handle,
     420                 :            :         int index, struct rte_epoll_event elist)
     421                 :            : {
     422         [ #  # ]:          0 :         CHECK_VALID_INTR_HANDLE(intr_handle);
     423                 :            : 
     424         [ #  # ]:          0 :         if (index >= intr_handle->nb_intr) {
     425                 :          0 :                 EAL_LOG(DEBUG, "Invalid index %d, max limit %d", index,
     426                 :            :                         intr_handle->nb_intr);
     427                 :          0 :                 rte_errno = ERANGE;
     428                 :          0 :                 goto fail;
     429                 :            :         }
     430                 :            : 
     431                 :          0 :         intr_handle->elist[index] = elist;
     432                 :            : 
     433                 :          0 :         return 0;
     434                 :          0 : fail:
     435                 :          0 :         return -rte_errno;
     436                 :            : }
     437                 :            : 
     438                 :            : RTE_EXPORT_INTERNAL_SYMBOL(rte_intr_vec_list_alloc)
     439                 :          0 : int rte_intr_vec_list_alloc(struct rte_intr_handle *intr_handle,
     440                 :            :         const char *name, int size)
     441                 :            : {
     442         [ #  # ]:          0 :         CHECK_VALID_INTR_HANDLE(intr_handle);
     443                 :            : 
     444                 :            :         /* Vector list already allocated */
     445         [ #  # ]:          0 :         if (intr_handle->intr_vec != NULL)
     446                 :            :                 return 0;
     447                 :            : 
     448         [ #  # ]:          0 :         if (size > intr_handle->nb_intr) {
     449                 :          0 :                 EAL_LOG(DEBUG, "Invalid size %d, max limit %d", size,
     450                 :            :                         intr_handle->nb_intr);
     451                 :          0 :                 rte_errno = ERANGE;
     452                 :          0 :                 goto fail;
     453                 :            :         }
     454                 :            : 
     455         [ #  # ]:          0 :         if (RTE_INTR_INSTANCE_USES_RTE_MEMORY(intr_handle->alloc_flags))
     456                 :          0 :                 intr_handle->intr_vec = rte_zmalloc(name, size * sizeof(int), 0);
     457                 :            :         else
     458                 :          0 :                 intr_handle->intr_vec = calloc(size, sizeof(int));
     459         [ #  # ]:          0 :         if (intr_handle->intr_vec == NULL) {
     460                 :          0 :                 EAL_LOG(ERR, "Failed to allocate %d intr_vec", size);
     461                 :          0 :                 rte_errno = ENOMEM;
     462                 :          0 :                 goto fail;
     463                 :            :         }
     464                 :            : 
     465                 :          0 :         intr_handle->vec_list_size = size;
     466                 :            : 
     467                 :          0 :         return 0;
     468                 :          0 : fail:
     469                 :          0 :         return -rte_errno;
     470                 :            : }
     471                 :            : 
     472                 :            : RTE_EXPORT_INTERNAL_SYMBOL(rte_intr_vec_list_index_get)
     473                 :          0 : int rte_intr_vec_list_index_get(const struct rte_intr_handle *intr_handle,
     474                 :            :                                 int index)
     475                 :            : {
     476         [ #  # ]:          0 :         CHECK_VALID_INTR_HANDLE(intr_handle);
     477                 :            : 
     478         [ #  # ]:          0 :         if (index >= intr_handle->vec_list_size) {
     479                 :          0 :                 EAL_LOG(DEBUG, "Index %d greater than vec list size %d",
     480                 :            :                         index, intr_handle->vec_list_size);
     481                 :          0 :                 rte_errno = ERANGE;
     482                 :          0 :                 goto fail;
     483                 :            :         }
     484                 :            : 
     485                 :          0 :         return intr_handle->intr_vec[index];
     486                 :          0 : fail:
     487                 :          0 :         return -rte_errno;
     488                 :            : }
     489                 :            : 
     490                 :            : RTE_EXPORT_INTERNAL_SYMBOL(rte_intr_vec_list_index_set)
     491                 :          0 : int rte_intr_vec_list_index_set(struct rte_intr_handle *intr_handle,
     492                 :            :                                 int index, int vec)
     493                 :            : {
     494         [ #  # ]:          0 :         CHECK_VALID_INTR_HANDLE(intr_handle);
     495                 :            : 
     496         [ #  # ]:          0 :         if (index >= intr_handle->vec_list_size) {
     497                 :          0 :                 EAL_LOG(DEBUG, "Index %d greater than vec list size %d",
     498                 :            :                         index, intr_handle->vec_list_size);
     499                 :          0 :                 rte_errno = ERANGE;
     500                 :          0 :                 goto fail;
     501                 :            :         }
     502                 :            : 
     503                 :          0 :         intr_handle->intr_vec[index] = vec;
     504                 :            : 
     505                 :          0 :         return 0;
     506                 :          0 : fail:
     507                 :          0 :         return -rte_errno;
     508                 :            : }
     509                 :            : 
     510                 :            : RTE_EXPORT_INTERNAL_SYMBOL(rte_intr_vec_list_free)
     511                 :          8 : void rte_intr_vec_list_free(struct rte_intr_handle *intr_handle)
     512                 :            : {
     513         [ +  - ]:          8 :         if (intr_handle == NULL)
     514                 :            :                 return;
     515         [ +  - ]:          8 :         if (RTE_INTR_INSTANCE_USES_RTE_MEMORY(intr_handle->alloc_flags))
     516                 :          8 :                 rte_free(intr_handle->intr_vec);
     517                 :            :         else
     518                 :          0 :                 free(intr_handle->intr_vec);
     519                 :          8 :         intr_handle->intr_vec = NULL;
     520                 :          8 :         intr_handle->vec_list_size = 0;
     521                 :            : }
     522                 :            : 
     523                 :            : RTE_EXPORT_INTERNAL_SYMBOL(rte_intr_instance_windows_handle_get)
     524                 :          0 : void *rte_intr_instance_windows_handle_get(struct rte_intr_handle *intr_handle)
     525                 :            : {
     526         [ #  # ]:          0 :         CHECK_VALID_INTR_HANDLE(intr_handle);
     527                 :            : 
     528                 :          0 :         return intr_handle->windows_handle;
     529                 :            : fail:
     530                 :          0 :         return NULL;
     531                 :            : }
     532                 :            : 
     533                 :            : RTE_EXPORT_INTERNAL_SYMBOL(rte_intr_instance_windows_handle_set)
     534                 :          0 : int rte_intr_instance_windows_handle_set(struct rte_intr_handle *intr_handle,
     535                 :            :         void *windows_handle)
     536                 :            : {
     537         [ #  # ]:          0 :         CHECK_VALID_INTR_HANDLE(intr_handle);
     538                 :            : 
     539                 :          0 :         intr_handle->windows_handle = windows_handle;
     540                 :            : 
     541                 :          0 :         return 0;
     542                 :            : fail:
     543                 :          0 :         return -rte_errno;
     544                 :            : }

Generated by: LCOV version 1.14