LCOV - code coverage report
Current view: top level - drivers/event/cnxk - cnxk_eventdev.h (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 8 0.0 %
Date: 2024-01-22 15:35:40 Functions: 0 2 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 15 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright(C) 2021 Marvell.
       3                 :            :  */
       4                 :            : 
       5                 :            : #ifndef __CNXK_EVENTDEV_H__
       6                 :            : #define __CNXK_EVENTDEV_H__
       7                 :            : 
       8                 :            : #include <string.h>
       9                 :            : 
      10                 :            : #include <cryptodev_pmd.h>
      11                 :            : #include <rte_devargs.h>
      12                 :            : #include <rte_ethdev.h>
      13                 :            : #include <rte_event_crypto_adapter.h>
      14                 :            : #include <rte_event_eth_rx_adapter.h>
      15                 :            : #include <rte_event_eth_tx_adapter.h>
      16                 :            : #include <rte_kvargs.h>
      17                 :            : #include <rte_mbuf_pool_ops.h>
      18                 :            : #include <rte_pci.h>
      19                 :            : 
      20                 :            : #include <eventdev_pmd_pci.h>
      21                 :            : 
      22                 :            : #include "cnxk_eventdev_dp.h"
      23                 :            : 
      24                 :            : #include "roc_platform.h"
      25                 :            : #include "roc_sso.h"
      26                 :            : 
      27                 :            : #include "cnxk_tim_evdev.h"
      28                 :            : 
      29                 :            : #define CNXK_SSO_XAE_CNT   "xae_cnt"
      30                 :            : #define CNXK_SSO_GGRP_QOS  "qos"
      31                 :            : #define CNXK_SSO_FORCE_BP  "force_rx_bp"
      32                 :            : #define CN9K_SSO_SINGLE_WS "single_ws"
      33                 :            : #define CN10K_SSO_GW_MODE  "gw_mode"
      34                 :            : #define CN10K_SSO_STASH    "stash"
      35                 :            : 
      36                 :            : #define CNXK_SSO_MAX_PROFILES 2
      37                 :            : 
      38                 :            : #define NSEC2USEC(__ns)         ((__ns) / 1E3)
      39                 :            : #define USEC2NSEC(__us)         ((__us)*1E3)
      40                 :            : #define NSEC2TICK(__ns, __freq) (((__ns) * (__freq)) / 1E9)
      41                 :            : 
      42                 :            : #define CN9K_SSOW_GET_BASE_ADDR(_GW) ((_GW)-SSOW_LF_GWS_OP_GET_WORK0)
      43                 :            : #define CN9K_DUAL_WS_NB_WS           2
      44                 :            : 
      45                 :            : #define CN10K_GW_MODE_NONE     0
      46                 :            : #define CN10K_GW_MODE_PREF     1
      47                 :            : #define CN10K_GW_MODE_PREF_WFE 2
      48                 :            : 
      49                 :            : #define CNXK_QOS_NORMALIZE(val, min, max, cnt)                                 \
      50                 :            :         (min + val / ((max + cnt - 1) / cnt))
      51                 :            : #define CNXK_SSO_FLUSH_RETRY_MAX 0xfff
      52                 :            : 
      53                 :            : #define CNXK_VALID_DEV_OR_ERR_RET(dev, drv_name, err_val)                      \
      54                 :            :         do {                                                                   \
      55                 :            :                 if (strncmp(dev->driver->name, drv_name, strlen(drv_name)))    \
      56                 :            :                         return -err_val;                                       \
      57                 :            :         } while (0)
      58                 :            : 
      59                 :            : typedef void *(*cnxk_sso_init_hws_mem_t)(void *dev, uint8_t port_id);
      60                 :            : typedef void (*cnxk_sso_hws_setup_t)(void *dev, void *ws, uintptr_t grp_base);
      61                 :            : typedef void (*cnxk_sso_hws_release_t)(void *dev, void *ws);
      62                 :            : typedef int (*cnxk_sso_link_t)(void *dev, void *ws, uint16_t *map, uint16_t nb_link,
      63                 :            :                                uint8_t profile);
      64                 :            : typedef int (*cnxk_sso_unlink_t)(void *dev, void *ws, uint16_t *map, uint16_t nb_link,
      65                 :            :                                  uint8_t profile);
      66                 :            : typedef void (*cnxk_handle_event_t)(void *arg, struct rte_event ev);
      67                 :            : typedef void (*cnxk_sso_hws_reset_t)(void *arg, void *ws);
      68                 :            : typedef int (*cnxk_sso_hws_flush_t)(void *ws, uint8_t queue_id, uintptr_t base,
      69                 :            :                                     cnxk_handle_event_t fn, void *arg);
      70                 :            : 
      71                 :            : struct cnxk_sso_qos {
      72                 :            :         uint16_t queue;
      73                 :            :         uint16_t taq_prcnt;
      74                 :            :         uint16_t iaq_prcnt;
      75                 :            : };
      76                 :            : 
      77                 :            : struct cnxk_sso_stash {
      78                 :            :         uint16_t queue;
      79                 :            :         uint16_t stash_offset;
      80                 :            :         uint16_t stash_length;
      81                 :            : };
      82                 :            : 
      83                 :            : struct cnxk_sso_evdev {
      84                 :            :         struct roc_sso sso;
      85                 :            :         uint8_t max_event_queues;
      86                 :            :         uint8_t max_event_ports;
      87                 :            :         uint8_t is_timeout_deq;
      88                 :            :         uint8_t nb_event_queues;
      89                 :            :         uint8_t nb_event_ports;
      90                 :            :         uint8_t configured;
      91                 :            :         uint32_t deq_tmo_ns;
      92                 :            :         uint32_t min_dequeue_timeout_ns;
      93                 :            :         uint32_t max_dequeue_timeout_ns;
      94                 :            :         int32_t max_num_events;
      95                 :            :         int32_t num_events;
      96                 :            :         uint64_t xaq_lmt;
      97                 :            :         int64_t *fc_cache_space;
      98                 :            :         rte_iova_t fc_iova;
      99                 :            :         uint64_t rx_offloads;
     100                 :            :         uint64_t tx_offloads;
     101                 :            :         uint64_t adptr_xae_cnt;
     102                 :            :         uint16_t rx_adptr_pool_cnt;
     103                 :            :         uint64_t *rx_adptr_pools;
     104                 :            :         uint64_t *tx_adptr_data;
     105                 :            :         size_t tx_adptr_data_sz;
     106                 :            :         uint16_t max_port_id;
     107                 :            :         uint16_t max_queue_id[RTE_MAX_ETHPORTS];
     108                 :            :         uint8_t tx_adptr_configured;
     109                 :            :         uint32_t tx_adptr_active_mask;
     110                 :            :         uint16_t tim_adptr_ring_cnt;
     111                 :            :         uint16_t *timer_adptr_rings;
     112                 :            :         uint64_t *timer_adptr_sz;
     113                 :            :         uint16_t vec_pool_cnt;
     114                 :            :         uint64_t *vec_pools;
     115                 :            :         struct cnxk_timesync_info *tstamp[RTE_MAX_ETHPORTS];
     116                 :            :         /* Dev args */
     117                 :            :         uint32_t xae_cnt;
     118                 :            :         uint16_t qos_queue_cnt;
     119                 :            :         struct cnxk_sso_qos *qos_parse_data;
     120                 :            :         uint8_t force_ena_bp;
     121                 :            :         /* CN9K */
     122                 :            :         uint8_t dual_ws;
     123                 :            :         /* CN10K */
     124                 :            :         uint32_t gw_mode;
     125                 :            :         uint16_t stash_cnt;
     126                 :            :         struct cnxk_sso_stash *stash_parse_data;
     127                 :            : } __rte_cache_aligned;
     128                 :            : 
     129                 :            : /* Event port a.k.a GWS */
     130                 :            : struct cn9k_sso_hws {
     131                 :            :         uint64_t base;
     132                 :            :         uint64_t gw_wdata;
     133                 :            :         void *lookup_mem;
     134                 :            :         uint8_t swtag_req;
     135                 :            :         uint8_t hws_id;
     136                 :            :         /* PTP timestamp */
     137                 :            :         struct cnxk_timesync_info **tstamp;
     138                 :            :         /* Add Work Fastpath data */
     139                 :            :         uint64_t xaq_lmt __rte_cache_aligned;
     140                 :            :         uint64_t *fc_mem;
     141                 :            :         uintptr_t grp_base;
     142                 :            :         /* Tx Fastpath data */
     143                 :            :         uint64_t lso_tun_fmt __rte_cache_aligned;
     144                 :            :         uint8_t tx_adptr_data[];
     145                 :            : } __rte_cache_aligned;
     146                 :            : 
     147                 :            : struct cn9k_sso_hws_dual {
     148                 :            :         uint64_t base[2]; /* Ping and Pong */
     149                 :            :         uint64_t gw_wdata;
     150                 :            :         void *lookup_mem;
     151                 :            :         uint8_t swtag_req;
     152                 :            :         uint8_t vws; /* Ping pong bit */
     153                 :            :         uint8_t hws_id;
     154                 :            :         /* PTP timestamp */
     155                 :            :         struct cnxk_timesync_info **tstamp;
     156                 :            :         /* Add Work Fastpath data */
     157                 :            :         uint64_t xaq_lmt __rte_cache_aligned;
     158                 :            :         uint64_t *fc_mem;
     159                 :            :         uintptr_t grp_base;
     160                 :            :         /* Tx Fastpath data */
     161                 :            :         uint64_t lso_tun_fmt __rte_cache_aligned;
     162                 :            :         uint8_t tx_adptr_data[];
     163                 :            : } __rte_cache_aligned;
     164                 :            : 
     165                 :            : struct cnxk_sso_hws_cookie {
     166                 :            :         const struct rte_eventdev *event_dev;
     167                 :            :         bool configured;
     168                 :            : } __rte_cache_aligned;
     169                 :            : 
     170                 :            : static inline int
     171                 :          0 : parse_kvargs_flag(const char *key, const char *value, void *opaque)
     172                 :            : {
     173                 :            :         RTE_SET_USED(key);
     174                 :            : 
     175                 :          0 :         *(uint8_t *)opaque = !!atoi(value);
     176                 :          0 :         return 0;
     177                 :            : }
     178                 :            : 
     179                 :            : static inline int
     180                 :          0 : parse_kvargs_value(const char *key, const char *value, void *opaque)
     181                 :            : {
     182                 :            :         RTE_SET_USED(key);
     183                 :            : 
     184                 :          0 :         *(uint32_t *)opaque = (uint32_t)atoi(value);
     185                 :          0 :         return 0;
     186                 :            : }
     187                 :            : 
     188                 :            : static inline struct cnxk_sso_evdev *
     189                 :            : cnxk_sso_pmd_priv(const struct rte_eventdev *event_dev)
     190                 :            : {
     191   [ #  #  #  #  :          0 :         return event_dev->data->dev_private;
          #  #  #  #  #  
             #  #  #  # ]
     192                 :            : }
     193                 :            : 
     194                 :            : static inline struct cnxk_sso_hws_cookie *
     195                 :            : cnxk_sso_hws_get_cookie(void *ws)
     196                 :            : {
     197         [ #  # ]:          0 :         return RTE_PTR_SUB(ws, sizeof(struct cnxk_sso_hws_cookie));
     198                 :            : }
     199                 :            : 
     200                 :            : /* Configuration functions */
     201                 :            : int cnxk_sso_xae_reconfigure(struct rte_eventdev *event_dev);
     202                 :            : int cnxk_sso_xaq_allocate(struct cnxk_sso_evdev *dev);
     203                 :            : void cnxk_sso_updt_xae_cnt(struct cnxk_sso_evdev *dev, void *data,
     204                 :            :                            uint32_t event_type);
     205                 :            : 
     206                 :            : /* Common ops API. */
     207                 :            : int cnxk_sso_init(struct rte_eventdev *event_dev);
     208                 :            : int cnxk_sso_fini(struct rte_eventdev *event_dev);
     209                 :            : int cnxk_sso_remove(struct rte_pci_device *pci_dev);
     210                 :            : void cnxk_sso_info_get(struct cnxk_sso_evdev *dev,
     211                 :            :                        struct rte_event_dev_info *dev_info);
     212                 :            : int cnxk_sso_dev_validate(const struct rte_eventdev *event_dev,
     213                 :            :                           uint32_t deq_depth, uint32_t enq_depth);
     214                 :            : int cnxk_setup_event_ports(const struct rte_eventdev *event_dev,
     215                 :            :                            cnxk_sso_init_hws_mem_t init_hws_mem,
     216                 :            :                            cnxk_sso_hws_setup_t hws_setup);
     217                 :            : void cnxk_sso_restore_links(const struct rte_eventdev *event_dev,
     218                 :            :                             cnxk_sso_link_t link_fn);
     219                 :            : void cnxk_sso_queue_def_conf(struct rte_eventdev *event_dev, uint8_t queue_id,
     220                 :            :                              struct rte_event_queue_conf *queue_conf);
     221                 :            : int cnxk_sso_queue_setup(struct rte_eventdev *event_dev, uint8_t queue_id,
     222                 :            :                          const struct rte_event_queue_conf *queue_conf);
     223                 :            : void cnxk_sso_queue_release(struct rte_eventdev *event_dev, uint8_t queue_id);
     224                 :            : int cnxk_sso_queue_attribute_set(struct rte_eventdev *event_dev,
     225                 :            :                                  uint8_t queue_id, uint32_t attr_id,
     226                 :            :                                  uint64_t attr_value);
     227                 :            : void cnxk_sso_port_def_conf(struct rte_eventdev *event_dev, uint8_t port_id,
     228                 :            :                             struct rte_event_port_conf *port_conf);
     229                 :            : int cnxk_sso_port_setup(struct rte_eventdev *event_dev, uint8_t port_id,
     230                 :            :                         cnxk_sso_hws_setup_t hws_setup_fn);
     231                 :            : int cnxk_sso_timeout_ticks(struct rte_eventdev *event_dev, uint64_t ns,
     232                 :            :                            uint64_t *tmo_ticks);
     233                 :            : int cnxk_sso_start(struct rte_eventdev *event_dev,
     234                 :            :                    cnxk_sso_hws_reset_t reset_fn,
     235                 :            :                    cnxk_sso_hws_flush_t flush_fn);
     236                 :            : void cnxk_sso_stop(struct rte_eventdev *event_dev,
     237                 :            :                    cnxk_sso_hws_reset_t reset_fn,
     238                 :            :                    cnxk_sso_hws_flush_t flush_fn);
     239                 :            : int cnxk_sso_close(struct rte_eventdev *event_dev, cnxk_sso_unlink_t unlink_fn);
     240                 :            : int cnxk_sso_selftest(const char *dev_name);
     241                 :            : void cnxk_sso_dump(struct rte_eventdev *event_dev, FILE *f);
     242                 :            : 
     243                 :            : /* Stats API. */
     244                 :            : int cnxk_sso_xstats_get_names(const struct rte_eventdev *event_dev,
     245                 :            :                               enum rte_event_dev_xstats_mode mode,
     246                 :            :                               uint8_t queue_port_id,
     247                 :            :                               struct rte_event_dev_xstats_name *xstats_names,
     248                 :            :                               uint64_t *ids, unsigned int size);
     249                 :            : int cnxk_sso_xstats_get(const struct rte_eventdev *event_dev,
     250                 :            :                         enum rte_event_dev_xstats_mode mode,
     251                 :            :                         uint8_t queue_port_id, const uint64_t ids[],
     252                 :            :                         uint64_t values[], unsigned int n);
     253                 :            : int cnxk_sso_xstats_reset(struct rte_eventdev *event_dev,
     254                 :            :                           enum rte_event_dev_xstats_mode mode,
     255                 :            :                           int16_t queue_port_id, const uint64_t ids[],
     256                 :            :                           uint32_t n);
     257                 :            : 
     258                 :            : /* CN9K */
     259                 :            : void cn9k_sso_set_rsrc(void *arg);
     260                 :            : 
     261                 :            : /* Common adapter ops */
     262                 :            : int cnxk_sso_rx_adapter_queue_add(
     263                 :            :         const struct rte_eventdev *event_dev, const struct rte_eth_dev *eth_dev,
     264                 :            :         int32_t rx_queue_id,
     265                 :            :         const struct rte_event_eth_rx_adapter_queue_conf *queue_conf);
     266                 :            : int cnxk_sso_rx_adapter_queue_del(const struct rte_eventdev *event_dev,
     267                 :            :                                   const struct rte_eth_dev *eth_dev,
     268                 :            :                                   int32_t rx_queue_id);
     269                 :            : int cnxk_sso_rx_adapter_start(const struct rte_eventdev *event_dev,
     270                 :            :                               const struct rte_eth_dev *eth_dev);
     271                 :            : int cnxk_sso_rx_adapter_stop(const struct rte_eventdev *event_dev,
     272                 :            :                              const struct rte_eth_dev *eth_dev);
     273                 :            : int cnxk_sso_tx_adapter_queue_add(const struct rte_eventdev *event_dev,
     274                 :            :                                   const struct rte_eth_dev *eth_dev,
     275                 :            :                                   int32_t tx_queue_id);
     276                 :            : int cnxk_sso_tx_adapter_queue_del(const struct rte_eventdev *event_dev,
     277                 :            :                                   const struct rte_eth_dev *eth_dev,
     278                 :            :                                   int32_t tx_queue_id);
     279                 :            : int cnxk_sso_tx_adapter_start(uint8_t id, const struct rte_eventdev *event_dev);
     280                 :            : int cnxk_sso_tx_adapter_stop(uint8_t id, const struct rte_eventdev *event_dev);
     281                 :            : int cnxk_sso_tx_adapter_free(uint8_t id, const struct rte_eventdev *event_dev);
     282                 :            : int cnxk_crypto_adapter_qp_add(const struct rte_eventdev *event_dev,
     283                 :            :                                const struct rte_cryptodev *cdev, int32_t queue_pair_id,
     284                 :            :                                const struct rte_event_crypto_adapter_queue_conf *conf);
     285                 :            : int cnxk_crypto_adapter_qp_del(const struct rte_cryptodev *cdev, int32_t queue_pair_id);
     286                 :            : 
     287                 :            : #endif /* __CNXK_EVENTDEV_H__ */

Generated by: LCOV version 1.14