9dbc54e27a8043f2b17658348161e68e5540e10a
[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 #define IONIC_NOTIFYQ_LENGTH    64      /* must be a power of two */
18
19 #define IONIC_QCQ_F_INITED      BIT(0)
20 #define IONIC_QCQ_F_SG          BIT(1)
21 #define IONIC_QCQ_F_INTR        BIT(2)
22 #define IONIC_QCQ_F_NOTIFYQ     BIT(3)
23
24 /* Queue / Completion Queue */
25 struct ionic_qcq {
26         struct ionic_queue q;        /**< Queue */
27         struct ionic_cq cq;          /**< Completion Queue */
28         struct ionic_lif *lif;       /**< LIF */
29         struct rte_mempool *mb_pool; /**< mbuf pool to populate the RX ring */
30         const struct rte_memzone *base_z;
31         void *base;
32         rte_iova_t base_pa;
33         uint32_t total_size;
34         uint32_t flags;
35         struct ionic_intr_info intr;
36 };
37
38 #define IONIC_LIF_F_INITED              BIT(0)
39 #define IONIC_LIF_F_LINK_CHECK_NEEDED   BIT(1)
40
41 #define IONIC_LIF_NAME_MAX_SZ           (32)
42
43 struct ionic_lif {
44         struct ionic_adapter *adapter;
45         struct rte_eth_dev *eth_dev;
46         uint16_t port_id;  /**< Device port identifier */
47         uint16_t mtu;
48         uint32_t index;
49         uint32_t hw_index;
50         uint32_t state;
51         uint32_t kern_pid;
52         rte_spinlock_t adminq_lock;
53         rte_spinlock_t adminq_service_lock;
54         struct ionic_qcq *adminqcq;
55         struct ionic_qcq *notifyqcq;
56         struct ionic_doorbell __iomem *kern_dbpage;
57         uint64_t last_eid;
58         uint64_t features;
59         uint32_t hw_features;
60         uint32_t rx_mode;
61         char name[IONIC_LIF_NAME_MAX_SZ];
62         uint8_t mac_addr[RTE_ETHER_ADDR_LEN];
63         uint32_t info_sz;
64         struct ionic_lif_info *info;
65         rte_iova_t info_pa;
66         const struct rte_memzone *info_z;
67 };
68
69 int ionic_lif_identify(struct ionic_adapter *adapter);
70 int ionic_lifs_size(struct ionic_adapter *ionic);
71
72 int ionic_lif_alloc(struct ionic_lif *lif);
73 void ionic_lif_free(struct ionic_lif *lif);
74
75 int ionic_lif_init(struct ionic_lif *lif);
76 void ionic_lif_deinit(struct ionic_lif *lif);
77
78 int ionic_lif_start(struct ionic_lif *lif);
79 int ionic_lif_stop(struct ionic_lif *lif);
80
81 int ionic_lif_configure(struct ionic_lif *lif);
82 void ionic_lif_reset(struct ionic_lif *lif);
83
84 int ionic_intr_alloc(struct ionic_lif *lif, struct ionic_intr_info *intr);
85 void ionic_intr_free(struct ionic_lif *lif, struct ionic_intr_info *intr);
86
87 bool ionic_adminq_service(struct ionic_cq *cq, uint32_t cq_desc_index,
88         void *cb_arg);
89 int ionic_qcq_service(struct ionic_qcq *qcq, int budget, ionic_cq_cb cb,
90         void *cb_arg);
91
92 int ionic_lif_change_mtu(struct ionic_lif *lif, int new_mtu);
93
94 void ionic_qcq_free(struct ionic_qcq *qcq);
95
96 int ionic_qcq_enable(struct ionic_qcq *qcq);
97 int ionic_qcq_disable(struct ionic_qcq *qcq);
98
99 int ionic_lif_set_features(struct ionic_lif *lif);
100
101 int ionic_notifyq_handler(struct ionic_lif *lif, int budget);
102
103 #endif /* _IONIC_LIF_H_ */