net/hinic: add device initialization
[dpdk.git] / drivers / net / hinic / hinic_pmd_tx.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2017 Huawei Technologies Co., Ltd
3  */
4
5 #ifndef _HINIC_PMD_TX_H_
6 #define _HINIC_PMD_TX_H_
7
8 #define HINIC_DEFAULT_TX_FREE_THRESH    32
9 #define HINIC_MAX_TX_FREE_BULK          64
10
11 #define HINIC_GET_WQ_HEAD(txq)          ((txq)->wq->queue_buf_vaddr)
12
13 #define HINIC_GET_WQ_TAIL(txq)          \
14                 ((txq)->wq->queue_buf_vaddr + (txq)->wq->wq_buf_size)
15
16 #define HINIC_TX_CKSUM_OFFLOAD_MASK (   \
17                 PKT_TX_IP_CKSUM |       \
18                 PKT_TX_TCP_CKSUM |      \
19                 PKT_TX_UDP_CKSUM |      \
20                 PKT_TX_SCTP_CKSUM |     \
21                 PKT_TX_OUTER_IP_CKSUM | \
22                 PKT_TX_TCP_SEG)
23
24 enum sq_wqe_type {
25         SQ_NORMAL_WQE = 0,
26 };
27
28 /* tx offload info */
29 struct hinic_tx_offload_info {
30         u8 outer_l2_len;
31         u8 outer_l3_type;
32         u8 outer_l3_len;
33
34         u8 inner_l2_len;
35         u8 inner_l3_type;
36         u8 inner_l3_len;
37
38         u8 tunnel_length;
39         u8 tunnel_type;
40         u8 inner_l4_type;
41         u8 inner_l4_len;
42
43         u8 payload_offset;
44         u8 inner_l4_tcp_udp;
45 };
46
47 /* tx sge info */
48 struct hinic_wqe_info {
49         u16 pi;
50         u16 owner;
51         u16 around;
52         u16 seq_wqebbs;
53         u16 sge_cnt;
54         u16 cpy_mbuf_cnt;
55 };
56
57 struct hinic_sq_ctrl {
58         u32     ctrl_fmt;
59         u32     queue_info;
60 };
61
62 struct hinic_sq_task {
63         u32             pkt_info0;
64         u32             pkt_info1;
65         u32             pkt_info2;
66         u32             ufo_v6_identify;
67         u32             pkt_info4;
68         u32             rsvd5;
69 };
70
71 struct hinic_sq_bufdesc {
72         struct hinic_sge sge;
73         u32     rsvd;
74 };
75
76 struct hinic_sq_wqe {
77         /* sq wqe control section */
78         struct hinic_sq_ctrl            ctrl;
79
80         /* sq task control section */
81         struct hinic_sq_task            task;
82
83         /* sq sge section start address, 1~127 sges */
84         struct hinic_sq_bufdesc     buf_descs[0];
85 };
86
87 struct hinic_txq_stats {
88         u64 packets;
89         u64 bytes;
90         u64 rl_drop;
91         u64 tx_busy;
92         u64 off_errs;
93         u64 cpy_pkts;
94         u64 burst_pkts;
95 };
96
97 struct hinic_tx_info {
98         struct rte_mbuf *mbuf;
99         int wqebb_cnt;
100         struct rte_mbuf *cpy_mbuf;
101 };
102
103 struct hinic_txq {
104         /* cacheline0 */
105         struct hinic_nic_dev *nic_dev;
106         struct hinic_wq *wq;
107         struct hinic_sq *sq;
108         volatile u16 *cons_idx_addr;
109         struct hinic_tx_info *tx_info;
110
111         u16 tx_free_thresh;
112         u16 port_id;
113         u16 q_id;
114         u16 q_depth;
115         u32 cos;
116
117         /* cacheline1 */
118         struct hinic_txq_stats txq_stats;
119         u64 sq_head_addr;
120         u64 sq_bot_sge_addr;
121 };
122
123 int hinic_setup_tx_resources(struct hinic_txq *txq);
124
125 void hinic_free_all_tx_resources(struct rte_eth_dev *eth_dev);
126
127 void hinic_free_all_tx_mbuf(struct rte_eth_dev *eth_dev);
128
129 void hinic_free_tx_resources(struct hinic_txq *txq);
130
131 u16 hinic_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, u16 nb_pkts);
132
133 void hinic_free_all_tx_skbs(struct hinic_txq *txq);
134
135 void hinic_txq_get_stats(struct hinic_txq *txq, struct hinic_txq_stats *stats);
136
137 void hinic_txq_stats_reset(struct hinic_txq *txq);
138
139 int hinic_create_sq(struct hinic_hwdev *hwdev, u16 q_id, u16 sq_depth);
140
141 void hinic_destroy_sq(struct hinic_hwdev *hwdev, u16 q_id);
142
143 #endif /* _HINIC_PMD_TX_H_ */