LCOV - code coverage report
Current view: top level - drivers/net/bnxt/tf_core - tfp.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 48 0.0 %
Date: 2024-01-22 16:13:49 Functions: 0 9 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 24 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * see the individual elements.
       3                 :            :  * Copyright(c) 2019-2023 Broadcom
       4                 :            :  * All rights reserved.
       5                 :            :  */
       6                 :            : 
       7                 :            : #include <rte_memcpy.h>
       8                 :            : #include <rte_byteorder.h>
       9                 :            : #include <rte_config.h>
      10                 :            : #include <rte_mbuf.h>
      11                 :            : #include <rte_ethdev.h>
      12                 :            : #include <rte_lcore.h>
      13                 :            : #include <rte_log.h>
      14                 :            : #include <rte_errno.h>
      15                 :            : #include <rte_malloc.h>
      16                 :            : #include <rte_spinlock.h>
      17                 :            : 
      18                 :            : #include "tf_core.h"
      19                 :            : #include "tfp.h"
      20                 :            : #include "bnxt.h"
      21                 :            : #include "bnxt_hwrm.h"
      22                 :            : #include "tf_msg_common.h"
      23                 :            : 
      24                 :            : /**
      25                 :            :  * Sends TruFlow msg to the TruFlow Firmware using
      26                 :            :  * a message specific HWRM message type.
      27                 :            :  *
      28                 :            :  * Returns success or failure code.
      29                 :            :  */
      30                 :            : int
      31                 :          0 : tfp_send_msg_direct(struct bnxt *bp,
      32                 :            :                     struct tfp_send_msg_parms *parms)
      33                 :            : {
      34                 :            :         int      rc = 0;
      35                 :            :         uint8_t  use_kong_mb = 1;
      36                 :            : 
      37         [ #  # ]:          0 :         if (parms == NULL)
      38                 :            :                 return -EINVAL;
      39                 :            : 
      40         [ #  # ]:          0 :         if (parms->mailbox == TF_CHIMP_MB)
      41                 :            :                 use_kong_mb = 0;
      42                 :            : 
      43                 :          0 :         rc = bnxt_hwrm_tf_message_direct(bp,
      44                 :            :                                          use_kong_mb,
      45                 :          0 :                                          parms->tf_type,
      46                 :          0 :                                          parms->req_data,
      47                 :            :                                          parms->req_size,
      48                 :          0 :                                          parms->resp_data,
      49                 :            :                                          parms->resp_size);
      50                 :            : 
      51                 :          0 :         return rc;
      52                 :            : }
      53                 :            : 
      54                 :            : /**
      55                 :            :  * Allocates zeroed memory from the heap.
      56                 :            :  *
      57                 :            :  * Returns success or failure code.
      58                 :            :  */
      59                 :            : int
      60                 :          0 : tfp_calloc(struct tfp_calloc_parms *parms)
      61                 :            : {
      62         [ #  # ]:          0 :         if (parms == NULL)
      63                 :            :                 return -EINVAL;
      64                 :            : 
      65                 :          0 :         parms->mem_va = rte_zmalloc("tf",
      66                 :          0 :                                     (parms->nitems * parms->size),
      67                 :          0 :                                     parms->alignment);
      68         [ #  # ]:          0 :         if (parms->mem_va == NULL) {
      69                 :          0 :                 TFP_DRV_LOG(ERR, "Allocate failed mem_va\n");
      70                 :          0 :                 return -ENOMEM;
      71                 :            :         }
      72                 :            : 
      73                 :          0 :         parms->mem_pa = (void *)((uintptr_t)rte_mem_virt2iova(parms->mem_va));
      74         [ #  # ]:          0 :         if (parms->mem_pa == (void *)((uintptr_t)RTE_BAD_IOVA)) {
      75                 :          0 :                 TFP_DRV_LOG(ERR, "Allocate failed mem_pa\n");
      76                 :          0 :                 return -ENOMEM;
      77                 :            :         }
      78                 :            : 
      79                 :            :         return 0;
      80                 :            : }
      81                 :            : 
      82                 :            : /**
      83                 :            :  * Frees the memory space pointed to by the provided pointer. The
      84                 :            :  * pointer must have been returned from the tfp_calloc().
      85                 :            :  */
      86                 :            : void
      87                 :          0 : tfp_free(void *addr)
      88                 :            : {
      89                 :          0 :         rte_free(addr);
      90                 :          0 : }
      91                 :            : 
      92                 :            : /**
      93                 :            :  * Copies n bytes from src memory to dest memory. The memory areas
      94                 :            :  * must not overlap.
      95                 :            :  */
      96                 :            : void
      97         [ #  # ]:          0 : tfp_memcpy(void *dest, void *src, size_t n)
      98                 :            : {
      99                 :            :         rte_memcpy(dest, src, n);
     100                 :          0 : }
     101                 :            : 
     102                 :            : /**
     103                 :            :  * Used to initialize portable spin lock
     104                 :            :  */
     105                 :            : void
     106                 :          0 : tfp_spinlock_init(struct tfp_spinlock_parms *parms)
     107                 :            : {
     108                 :            :         rte_spinlock_init(&parms->slock);
     109                 :          0 : }
     110                 :            : 
     111                 :            : /**
     112                 :            :  * Used to lock portable spin lock
     113                 :            :  */
     114                 :            : void
     115                 :          0 : tfp_spinlock_lock(struct tfp_spinlock_parms *parms)
     116                 :            : {
     117                 :          0 :         rte_spinlock_lock(&parms->slock);
     118                 :          0 : }
     119                 :            : 
     120                 :            : /**
     121                 :            :  * Used to unlock portable spin lock
     122                 :            :  */
     123                 :            : void
     124                 :          0 : tfp_spinlock_unlock(struct tfp_spinlock_parms *parms)
     125                 :            : {
     126                 :          0 :         rte_spinlock_unlock(&parms->slock);
     127                 :          0 : }
     128                 :            : 
     129                 :            : int
     130                 :          0 : tfp_get_fid(struct tf *tfp, uint16_t *fw_fid)
     131                 :            : {
     132                 :            :         struct bnxt *bp = NULL;
     133                 :            : 
     134         [ #  # ]:          0 :         if (tfp == NULL || fw_fid == NULL)
     135                 :            :                 return -EINVAL;
     136                 :            : 
     137                 :          0 :         bp = (struct bnxt *)tfp->bp;
     138         [ #  # ]:          0 :         if (bp == NULL)
     139                 :            :                 return -EINVAL;
     140                 :            : 
     141                 :          0 :         *fw_fid = bp->fw_fid;
     142                 :            : 
     143                 :          0 :         return 0;
     144                 :            : }
     145                 :            : 
     146                 :            : int
     147                 :          0 : tfp_get_pf(struct tf *tfp, uint16_t *pf)
     148                 :            : {
     149                 :            :         struct bnxt *bp = NULL;
     150                 :            : 
     151         [ #  # ]:          0 :         if (tfp == NULL || pf == NULL)
     152                 :            :                 return -EINVAL;
     153                 :            : 
     154                 :          0 :         bp = (struct bnxt *)tfp->bp;
     155   [ #  #  #  # ]:          0 :         if (BNXT_VF(bp) && bp->parent) {
     156                 :          0 :                 *pf = bp->parent->fid - 1;
     157                 :          0 :                 return 0;
     158         [ #  # ]:          0 :         } else if (BNXT_PF(bp)) {
     159                 :          0 :                 *pf = bp->fw_fid - 1;
     160                 :          0 :                 return 0;
     161                 :            :         }
     162                 :            :         return -EINVAL;
     163                 :            : }

Generated by: LCOV version 1.14