net/ionic: support admin queue
[dpdk.git] / drivers / net / ionic / ionic_lif.h
1 /* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0)
2  * Copyright(c) 2018-2019 Pensando Systems, Inc. All rights reserved.
3  */
4
5 #ifndef _IONIC_LIF_H_
6 #define _IONIC_LIF_H_
7
8 #include <inttypes.h>
9
10 #include <rte_ethdev.h>
11 #include <rte_ether.h>
12
13 #include "ionic_osdep.h"
14 #include "ionic_dev.h"
15
16 #define IONIC_ADMINQ_LENGTH     16      /* must be a power of two */
17
18 #define IONIC_QCQ_F_INITED      BIT(0)
19 #define IONIC_QCQ_F_SG          BIT(1)
20 #define IONIC_QCQ_F_INTR        BIT(2)
21
22 /* Queue / Completion Queue */
23 struct ionic_qcq {
24         struct ionic_queue q;        /**< Queue */
25         struct ionic_cq cq;          /**< Completion Queue */
26         struct ionic_lif *lif;       /**< LIF */
27         struct rte_mempool *mb_pool; /**< mbuf pool to populate the RX ring */
28         const struct rte_memzone *base_z;
29         void *base;
30         rte_iova_t base_pa;
31         uint32_t total_size;
32         uint32_t flags;
33         struct ionic_intr_info intr;
34 };
35
36 #define IONIC_LIF_F_INITED              BIT(0)
37
38 #define IONIC_LIF_NAME_MAX_SZ           (32)
39
40 struct ionic_lif {
41         struct ionic_adapter *adapter;
42         struct rte_eth_dev *eth_dev;
43         uint16_t port_id;  /**< Device port identifier */
44         uint32_t index;
45         uint32_t hw_index;
46         uint32_t state;
47         uint32_t kern_pid;
48         rte_spinlock_t adminq_lock;
49         rte_spinlock_t adminq_service_lock;
50         struct ionic_qcq *adminqcq;
51         struct ionic_doorbell __iomem *kern_dbpage;
52         char name[IONIC_LIF_NAME_MAX_SZ];
53         uint32_t info_sz;
54         struct ionic_lif_info *info;
55         rte_iova_t info_pa;
56         const struct rte_memzone *info_z;
57 };
58
59 int ionic_lif_identify(struct ionic_adapter *adapter);
60 int ionic_lifs_size(struct ionic_adapter *ionic);
61
62 int ionic_lif_alloc(struct ionic_lif *lif);
63 void ionic_lif_free(struct ionic_lif *lif);
64
65 int ionic_lif_init(struct ionic_lif *lif);
66 void ionic_lif_deinit(struct ionic_lif *lif);
67
68 int ionic_lif_start(struct ionic_lif *lif);
69
70 int ionic_lif_configure(struct ionic_lif *lif);
71 void ionic_lif_reset(struct ionic_lif *lif);
72
73 int ionic_intr_alloc(struct ionic_lif *lif, struct ionic_intr_info *intr);
74 void ionic_intr_free(struct ionic_lif *lif, struct ionic_intr_info *intr);
75
76 bool ionic_adminq_service(struct ionic_cq *cq, uint32_t cq_desc_index,
77         void *cb_arg);
78 int ionic_qcq_service(struct ionic_qcq *qcq, int budget, ionic_cq_cb cb,
79         void *cb_arg);
80
81 void ionic_qcq_free(struct ionic_qcq *qcq);
82
83 int ionic_qcq_enable(struct ionic_qcq *qcq);
84 int ionic_qcq_disable(struct ionic_qcq *qcq);
85
86 #endif /* _IONIC_LIF_H_ */