net/pfe: add MAC and host interface initialisation
[dpdk.git] / drivers / net / pfe / pfe_hif.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright 2019 NXP
3  */
4
5 #ifndef _PFE_HIF_H_
6 #define _PFE_HIF_H_
7
8 #define HIF_CLIENT_QUEUES_MAX   16
9 #define HIF_RX_PKT_MIN_SIZE RTE_CACHE_LINE_SIZE
10 /*
11  * HIF_TX_DESC_NT value should be always greter than 4,
12  * Otherwise HIF_TX_POLL_MARK will become zero.
13  */
14 #define HIF_RX_DESC_NT          64
15 #define HIF_TX_DESC_NT          2048
16
17 enum {
18         PFE_CL_GEM0 = 0,
19         PFE_CL_GEM1,
20         HIF_CLIENTS_MAX
21 };
22
23 /*structure to store client queue info */
24 struct hif_rx_queue {
25         struct rx_queue_desc *base;
26         u32     size;
27         u32     write_idx;
28 };
29
30 struct hif_tx_queue {
31         struct tx_queue_desc *base;
32         u32     size;
33         u32     ack_idx;
34 };
35
36 /*Structure to store the client info */
37 struct hif_client {
38         unsigned int    rx_qn;
39         struct hif_rx_queue     rx_q[HIF_CLIENT_QUEUES_MAX];
40         unsigned int    tx_qn;
41         struct hif_tx_queue     tx_q[HIF_CLIENT_QUEUES_MAX];
42 };
43
44 /*HIF hardware buffer descriptor */
45 struct hif_desc {
46         u32 ctrl;
47         u32 status;
48         u32 data;
49         u32 next;
50 };
51
52 struct __hif_desc {
53         u32 ctrl;
54         u32 status;
55         u32 data;
56 };
57
58 struct hif_desc_sw {
59         dma_addr_t data;
60         u16 len;
61         u8 client_id;
62         u8 q_no;
63         u16 flags;
64 };
65
66 struct pfe_hif {
67         /* To store registered clients in hif layer */
68         struct hif_client client[HIF_CLIENTS_MAX];
69         struct hif_shm *shm;
70
71         void    *descr_baseaddr_v;
72         unsigned long   descr_baseaddr_p;
73
74         struct hif_desc *rx_base;
75         u32     rx_ring_size;
76         u32     rxtoclean_index;
77         void    *rx_buf_addr[HIF_RX_DESC_NT];
78         void    *rx_buf_vaddr[HIF_RX_DESC_NT];
79         int     rx_buf_len[HIF_RX_DESC_NT];
80         unsigned int qno;
81         unsigned int client_id;
82         unsigned int client_ctrl;
83         unsigned int started;
84         unsigned int setuped;
85
86         struct hif_desc *tx_base;
87         u32     tx_ring_size;
88         u32     txtosend;
89         u32     txtoclean;
90         u32     txavail;
91         u32     txtoflush;
92         struct hif_desc_sw tx_sw_queue[HIF_TX_DESC_NT];
93         int32_t epoll_fd; /**< File descriptor created for interrupt polling */
94
95 /* tx_lock synchronizes hif packet tx as well as pfe_hif structure access */
96         rte_spinlock_t tx_lock;
97 /* lock synchronizes hif rx queue processing */
98         rte_spinlock_t lock;
99         struct rte_device *dev;
100 };
101
102 int pfe_hif_init(struct pfe *pfe);
103 void pfe_hif_exit(struct pfe *pfe);
104 void pfe_hif_rx_idle(struct pfe_hif *hif);
105
106 #endif /* _PFE_HIF_H_ */