LCOV - code coverage report
Current view: top level - drivers/common/idpf - idpf_common_device.h (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 10 0.0 %
Date: 2024-01-22 15:55:54 Functions: 0 1 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 2 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright(c) 2023 Intel Corporation
       3                 :            :  */
       4                 :            : 
       5                 :            : #ifndef _IDPF_COMMON_DEVICE_H_
       6                 :            : #define _IDPF_COMMON_DEVICE_H_
       7                 :            : 
       8                 :            : #include <rte_mbuf_ptype.h>
       9                 :            : #include "base/idpf_prototype.h"
      10                 :            : #include "base/virtchnl2.h"
      11                 :            : #include "idpf_common_logs.h"
      12                 :            : 
      13                 :            : #define IDPF_DEV_ID_SRIOV       0x145C
      14                 :            : 
      15                 :            : #define IDPF_RSS_KEY_LEN        52
      16                 :            : 
      17                 :            : #define IDPF_CTLQ_ID            -1
      18                 :            : #define IDPF_CTLQ_LEN           64
      19                 :            : #define IDPF_DFLT_MBX_BUF_SIZE  4096
      20                 :            : 
      21                 :            : #define IDPF_DEFAULT_RXQ_NUM    16
      22                 :            : #define IDPF_RX_BUFQ_PER_GRP    2
      23                 :            : #define IDPF_RXQ_PER_GRP        1
      24                 :            : #define IDPF_DEFAULT_TXQ_NUM    16
      25                 :            : #define IDPF_TX_COMPLQ_PER_GRP  1
      26                 :            : #define IDPF_TXQ_PER_GRP        1
      27                 :            : 
      28                 :            : #define IDPF_MIN_FRAME_SIZE     14
      29                 :            : 
      30                 :            : #define IDPF_MAX_PKT_TYPE       1024
      31                 :            : 
      32                 :            : #define IDPF_DFLT_INTERVAL      16
      33                 :            : 
      34                 :            : #define IDPF_GET_PTYPE_SIZE(p)                                          \
      35                 :            :         (sizeof(struct virtchnl2_ptype) +                               \
      36                 :            :          (((p)->proto_id_count ? ((p)->proto_id_count - 1) : 0) * sizeof((p)->proto_id[0])))
      37                 :            : 
      38                 :            : struct idpf_adapter {
      39                 :            :         struct idpf_hw hw;
      40                 :            :         struct virtchnl2_version_info virtchnl_version;
      41                 :            :         struct virtchnl2_get_capabilities caps;
      42                 :            :         volatile uint32_t pend_cmd; /* pending command not finished */
      43                 :            :         uint32_t cmd_retval; /* return value of the cmd response from cp */
      44                 :            :         uint8_t *mbx_resp; /* buffer to store the mailbox response from cp */
      45                 :            : 
      46                 :            :         uint32_t ptype_tbl[IDPF_MAX_PKT_TYPE] __rte_cache_min_aligned;
      47                 :            : 
      48                 :            :         bool is_tx_singleq; /* true - single queue model, false - split queue model */
      49                 :            :         bool is_rx_singleq; /* true - single queue model, false - split queue model */
      50                 :            : 
      51                 :            :         /* For timestamp */
      52                 :            :         uint64_t time_hw;
      53                 :            : };
      54                 :            : 
      55                 :            : struct idpf_chunks_info {
      56                 :            :         uint32_t tx_start_qid;
      57                 :            :         uint32_t rx_start_qid;
      58                 :            :         /* Valid only if split queue model */
      59                 :            :         uint32_t tx_compl_start_qid;
      60                 :            :         uint32_t rx_buf_start_qid;
      61                 :            : 
      62                 :            :         uint64_t tx_qtail_start;
      63                 :            :         uint32_t tx_qtail_spacing;
      64                 :            :         uint64_t rx_qtail_start;
      65                 :            :         uint32_t rx_qtail_spacing;
      66                 :            :         uint64_t tx_compl_qtail_start;
      67                 :            :         uint32_t tx_compl_qtail_spacing;
      68                 :            :         uint64_t rx_buf_qtail_start;
      69                 :            :         uint32_t rx_buf_qtail_spacing;
      70                 :            : };
      71                 :            : 
      72                 :            : struct idpf_vport {
      73                 :            :         struct idpf_adapter *adapter; /* Backreference to associated adapter */
      74                 :            :         union {
      75                 :            :                 struct virtchnl2_create_vport info; /* virtchnl response info handling */
      76                 :            :                 uint8_t data[IDPF_DFLT_MBX_BUF_SIZE];
      77                 :            :         } vport_info;
      78                 :            :         uint16_t sw_idx; /* SW index in adapter->vports[]*/
      79                 :            :         uint16_t vport_id;
      80                 :            :         uint32_t txq_model;
      81                 :            :         uint32_t rxq_model;
      82                 :            :         uint16_t num_tx_q;
      83                 :            :         /* valid only if txq_model is split Q */
      84                 :            :         uint16_t num_tx_complq;
      85                 :            :         uint16_t num_rx_q;
      86                 :            :         /* valid only if rxq_model is split Q */
      87                 :            :         uint16_t num_rx_bufq;
      88                 :            : 
      89                 :            :         uint16_t max_mtu;
      90                 :            :         uint8_t default_mac_addr[VIRTCHNL_ETH_LENGTH_OF_ADDRESS];
      91                 :            : 
      92                 :            :         enum virtchnl_rss_algorithm rss_algorithm;
      93                 :            :         uint16_t rss_key_size;
      94                 :            :         uint16_t rss_lut_size;
      95                 :            : 
      96                 :            :         void *dev_data; /* Pointer to the device data */
      97                 :            :         uint16_t max_pkt_len; /* Maximum packet length */
      98                 :            : 
      99                 :            :         /* RSS info */
     100                 :            :         uint32_t *rss_lut;
     101                 :            :         uint8_t *rss_key;
     102                 :            :         uint64_t rss_hf;
     103                 :            :         uint64_t last_general_rss_hf;
     104                 :            : 
     105                 :            :         /* MSIX info*/
     106                 :            :         struct virtchnl2_queue_vector *qv_map; /* queue vector mapping */
     107                 :            :         uint16_t max_vectors;
     108                 :            :         struct virtchnl2_alloc_vectors *recv_vectors;
     109                 :            : 
     110                 :            :         /* Chunk info */
     111                 :            :         struct idpf_chunks_info chunks_info;
     112                 :            : 
     113                 :            :         uint16_t devarg_id;
     114                 :            : 
     115                 :            :         bool rx_vec_allowed;
     116                 :            :         bool tx_vec_allowed;
     117                 :            :         bool rx_use_avx512;
     118                 :            :         bool tx_use_avx512;
     119                 :            : 
     120                 :            :         struct virtchnl2_vport_stats eth_stats_offset;
     121                 :            : 
     122                 :            :         /* Event from ipf */
     123                 :            :         bool link_up;
     124                 :            :         uint32_t link_speed;
     125                 :            : };
     126                 :            : 
     127                 :            : /* Message type read in virtual channel from PF */
     128                 :            : enum idpf_vc_result {
     129                 :            :         IDPF_MSG_ERR = -1, /* Meet error when accessing admin queue */
     130                 :            :         IDPF_MSG_NON,      /* Read nothing from admin queue */
     131                 :            :         IDPF_MSG_SYS,      /* Read system msg from admin queue */
     132                 :            :         IDPF_MSG_CMD,      /* Read async command result */
     133                 :            : };
     134                 :            : 
     135                 :            : /* structure used for sending and checking response of virtchnl ops */
     136                 :            : struct idpf_cmd_info {
     137                 :            :         uint32_t ops;
     138                 :            :         uint8_t *in_args;       /* buffer for sending */
     139                 :            :         uint32_t in_args_size;  /* buffer size for sending */
     140                 :            :         uint8_t *out_buffer;    /* buffer for response */
     141                 :            :         uint32_t out_size;      /* buffer size for response */
     142                 :            : };
     143                 :            : 
     144                 :            : /* notify current command done. Only call in case execute
     145                 :            :  * _atomic_set_cmd successfully.
     146                 :            :  */
     147                 :            : static inline void
     148                 :            : notify_cmd(struct idpf_adapter *adapter, int msg_ret)
     149                 :            : {
     150                 :            :         adapter->cmd_retval = msg_ret;
     151                 :            :         /* Return value may be checked in anither thread, need to ensure the coherence. */
     152                 :            :         rte_wmb();
     153                 :          0 :         adapter->pend_cmd = VIRTCHNL2_OP_UNKNOWN;
     154                 :          0 : }
     155                 :            : 
     156                 :            : /* clear current command. Only call in case execute
     157                 :            :  * _atomic_set_cmd successfully.
     158                 :            :  */
     159                 :            : static inline void
     160                 :            : clear_cmd(struct idpf_adapter *adapter)
     161                 :            : {
     162                 :            :         /* Return value may be checked in anither thread, need to ensure the coherence. */
     163                 :            :         rte_wmb();
     164                 :          0 :         adapter->pend_cmd = VIRTCHNL2_OP_UNKNOWN;
     165                 :          0 :         adapter->cmd_retval = VIRTCHNL_STATUS_SUCCESS;
     166                 :          0 : }
     167                 :            : 
     168                 :            : /* Check there is pending cmd in execution. If none, set new command. */
     169                 :            : static inline bool
     170                 :          0 : atomic_set_cmd(struct idpf_adapter *adapter, uint32_t ops)
     171                 :            : {
     172                 :            :         uint32_t op_unk = VIRTCHNL2_OP_UNKNOWN;
     173                 :          0 :         bool ret = __atomic_compare_exchange(&adapter->pend_cmd, &op_unk, &ops,
     174                 :            :                                             0, __ATOMIC_ACQUIRE, __ATOMIC_ACQUIRE);
     175                 :            : 
     176         [ #  # ]:          0 :         if (!ret)
     177                 :          0 :                 DRV_LOG(ERR, "There is incomplete cmd %d", adapter->pend_cmd);
     178                 :            : 
     179                 :          0 :         return !ret;
     180                 :            : }
     181                 :            : 
     182                 :            : __rte_internal
     183                 :            : int idpf_adapter_init(struct idpf_adapter *adapter);
     184                 :            : __rte_internal
     185                 :            : int idpf_adapter_deinit(struct idpf_adapter *adapter);
     186                 :            : __rte_internal
     187                 :            : int idpf_vport_init(struct idpf_vport *vport,
     188                 :            :                     struct virtchnl2_create_vport *vport_req_info,
     189                 :            :                     void *dev_data);
     190                 :            : __rte_internal
     191                 :            : int idpf_vport_deinit(struct idpf_vport *vport);
     192                 :            : __rte_internal
     193                 :            : int idpf_vport_rss_config(struct idpf_vport *vport);
     194                 :            : __rte_internal
     195                 :            : int idpf_vport_irq_map_config(struct idpf_vport *vport, uint16_t nb_rx_queues);
     196                 :            : __rte_internal
     197                 :            : int idpf_vport_irq_unmap_config(struct idpf_vport *vport, uint16_t nb_rx_queues);
     198                 :            : __rte_internal
     199                 :            : int idpf_vport_info_init(struct idpf_vport *vport,
     200                 :            :                          struct virtchnl2_create_vport *vport_info);
     201                 :            : __rte_internal
     202                 :            : void idpf_vport_stats_update(struct virtchnl2_vport_stats *oes, struct virtchnl2_vport_stats *nes);
     203                 :            : __rte_internal
     204                 :            : int idpf_vport_irq_map_config_by_qids(struct idpf_vport *vport,
     205                 :            :                                       uint32_t *qids,
     206                 :            :                                       uint16_t nb_rx_queues);
     207                 :            : 
     208                 :            : #endif /* _IDPF_COMMON_DEVICE_H_ */

Generated by: LCOV version 1.14