dpdk/drivers/crypto/bcmfs/bcmfs_qp.h
<<
>>
Prefs
   1/* SPDX-License-Identifier: BSD-3-Clause
   2 * Copyright(c) 2020 Broadcom
   3 * All rights reserved.
   4 */
   5
   6#ifndef _BCMFS_QP_H_
   7#define _BCMFS_QP_H_
   8
   9#include <rte_memzone.h>
  10
  11/* Maximum number of h/w queues supported by device */
  12#define BCMFS_MAX_HW_QUEUES             32
  13
  14/* H/W queue IO address space len */
  15#define BCMFS_HW_QUEUE_IO_ADDR_LEN      (64 * 1024)
  16
  17/* Maximum size of device ops name */
  18#define BCMFS_HW_OPS_NAMESIZE           32
  19
  20enum bcmfs_queue_type {
  21        /* TX or submission queue */
  22        BCMFS_RM_TXQ,
  23         /* Completion or receive queue */
  24        BCMFS_RM_CPLQ
  25};
  26
  27#define BCMFS_QP_IOBASE_XLATE(base, idx)        \
  28                ((base) + ((idx) * BCMFS_HW_QUEUE_IO_ADDR_LEN))
  29
  30/* Max pkts for preprocessing before submitting to h/w qp */
  31#define BCMFS_MAX_REQS_BUFF     64
  32
  33/* qp stats */
  34struct bcmfs_qp_stats {
  35        /* Count of all operations enqueued */
  36        uint64_t enqueued_count;
  37        /* Count of all operations dequeued */
  38        uint64_t dequeued_count;
  39        /* Total error count on operations enqueued */
  40        uint64_t enqueue_err_count;
  41        /* Total error count on operations dequeued */
  42        uint64_t dequeue_err_count;
  43};
  44
  45struct bcmfs_qp_config {
  46        /* Socket to allocate memory on */
  47        int socket_id;
  48        /* Mapped iobase for qp */
  49        void *iobase;
  50        /* nb_descriptors or requests a h/w queue can accommodate */
  51        uint16_t nb_descriptors;
  52        /* Maximum number of h/w descriptors needed by a request */
  53        uint16_t max_descs_req;
  54        /* h/w ops associated with qp */
  55        struct bcmfs_hw_queue_pair_ops *ops;
  56};
  57
  58struct bcmfs_queue {
  59        /* Base virt address */
  60        void *base_addr;
  61        /* Base iova */
  62        rte_iova_t base_phys_addr;
  63        /* Queue type */
  64        enum bcmfs_queue_type q_type;
  65        /* Queue size based on nb_descriptors and max_descs_reqs */
  66        uint32_t queue_size;
  67        union {
  68                /* s/w pointer for tx h/w queue*/
  69                uint32_t tx_write_ptr;
  70                /* s/w pointer for completion h/w queue*/
  71                uint32_t cmpl_read_ptr;
  72        };
  73        /* number of inflight descriptor accumulated  before next db ring */
  74        uint16_t descs_inflight;
  75        /* Memzone name */
  76        char memz_name[RTE_MEMZONE_NAMESIZE];
  77};
  78
  79struct bcmfs_qp {
  80        /* Queue-pair ID */
  81        uint16_t qpair_id;
  82        /* Mapped IO address */
  83        void *ioreg;
  84        /* A TX queue */
  85        struct bcmfs_queue tx_q;
  86        /* A Completion queue */
  87        struct bcmfs_queue cmpl_q;
  88        /* Number of requests queue can accommodate */
  89        uint32_t nb_descriptors;
  90        /* Number of pending requests and enqueued to h/w queue */
  91        uint16_t nb_pending_requests;
  92        /* A pool which act as a hash for <request-ID and virt address> pair */
  93        unsigned long *ctx_pool;
  94        /* virt address for mem allocated for bitmap */
  95        void *ctx_bmp_mem;
  96        /* Bitmap */
  97        struct rte_bitmap *ctx_bmp;
  98        /* Associated stats */
  99        struct bcmfs_qp_stats stats;
 100        /* h/w ops associated with qp */
 101        struct bcmfs_hw_queue_pair_ops *ops;
 102        /* bcmfs requests pool*/
 103        struct rte_mempool *sr_mp;
 104        /* a temporary buffer to keep message pointers */
 105        struct bcmfs_qp_message *infl_msgs[BCMFS_MAX_REQS_BUFF];
 106
 107} __rte_cache_aligned;
 108
 109/* Structure defining h/w queue pair operations */
 110struct bcmfs_hw_queue_pair_ops {
 111        /* ops name */
 112        char name[BCMFS_HW_OPS_NAMESIZE];
 113        /* Enqueue an object */
 114        int (*enq_one_req)(struct bcmfs_qp *qp, void *obj);
 115        /* Ring doorbell */
 116        void (*ring_db)(struct bcmfs_qp *qp);
 117        /* Dequeue objects */
 118        uint16_t (*dequeue)(struct bcmfs_qp *qp, void **obj,
 119                            uint16_t nb_ops);
 120        /* Start the h/w queue */
 121        int (*startq)(struct bcmfs_qp *qp);
 122        /* Stop the h/w queue */
 123        void (*stopq)(struct bcmfs_qp *qp);
 124};
 125
 126uint16_t
 127bcmfs_enqueue_op_burst(void *qp, void **ops, uint16_t nb_ops);
 128uint16_t
 129bcmfs_dequeue_op_burst(void *qp, void **ops, uint16_t nb_ops);
 130int
 131bcmfs_qp_release(struct bcmfs_qp **qp_addr);
 132int
 133bcmfs_qp_setup(struct bcmfs_qp **qp_addr,
 134               uint16_t queue_pair_id,
 135               struct bcmfs_qp_config *bcmfs_conf);
 136
 137/* stats functions*/
 138void bcmfs_qp_stats_get(struct bcmfs_qp **qp, int num_qp,
 139                        struct bcmfs_qp_stats *stats);
 140void bcmfs_qp_stats_reset(struct bcmfs_qp **qp, int num_qp);
 141
 142#endif /* _BCMFS_QP_H_ */
 143