655c20112823c9f147b0165b0689257b1b5cde8a
[deb_dpdk.git] / drivers / net / liquidio / lio_ethdev.h
1 /*
2  *   BSD LICENSE
3  *
4  *   Copyright(c) 2017 Cavium, Inc.. All rights reserved.
5  *   All rights reserved.
6  *
7  *   Redistribution and use in source and binary forms, with or without
8  *   modification, are permitted provided that the following conditions
9  *   are met:
10  *
11  *     * Redistributions of source code must retain the above copyright
12  *       notice, this list of conditions and the following disclaimer.
13  *     * Redistributions in binary form must reproduce the above copyright
14  *       notice, this list of conditions and the following disclaimer in
15  *       the documentation and/or other materials provided with the
16  *       distribution.
17  *     * Neither the name of Cavium, Inc. nor the names of its
18  *       contributors may be used to endorse or promote products derived
19  *       from this software without specific prior written permission.
20  *
21  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24  *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25  *   OWNER(S) OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26  *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27  *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28  *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29  *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  */
33
34 #ifndef _LIO_ETHDEV_H_
35 #define _LIO_ETHDEV_H_
36
37 #include <stdint.h>
38
39 #include "lio_struct.h"
40
41 /* timeout to check link state updates from firmware in us */
42 #define LIO_LSC_TIMEOUT         100000 /* 100000us (100ms) */
43 #define LIO_MAX_CMD_TIMEOUT     10000 /* 10000ms (10s) */
44
45 #define LIO_DEV(_eth_dev)               ((_eth_dev)->data->dev_private)
46
47 /* LIO Response condition variable */
48 struct lio_dev_ctrl_cmd {
49         struct rte_eth_dev *eth_dev;
50         uint64_t cond;
51 };
52
53 enum lio_bus_speed {
54         LIO_LINK_SPEED_UNKNOWN  = 0,
55         LIO_LINK_SPEED_10000    = 10000,
56         LIO_LINK_SPEED_25000    = 25000
57 };
58
59 struct octeon_if_cfg_info {
60         uint64_t iqmask;        /** mask for IQs enabled for the port */
61         uint64_t oqmask;        /** mask for OQs enabled for the port */
62         struct octeon_link_info linfo; /** initial link information */
63         char lio_firmware_version[LIO_FW_VERSION_LENGTH];
64 };
65
66 /** Stats for each NIC port in RX direction. */
67 struct octeon_rx_stats {
68         /* link-level stats */
69         uint64_t total_rcvd;
70         uint64_t bytes_rcvd;
71         uint64_t total_bcst;
72         uint64_t total_mcst;
73         uint64_t runts;
74         uint64_t ctl_rcvd;
75         uint64_t fifo_err; /* Accounts for over/under-run of buffers */
76         uint64_t dmac_drop;
77         uint64_t fcs_err;
78         uint64_t jabber_err;
79         uint64_t l2_err;
80         uint64_t frame_err;
81
82         /* firmware stats */
83         uint64_t fw_total_rcvd;
84         uint64_t fw_total_fwd;
85         uint64_t fw_total_fwd_bytes;
86         uint64_t fw_err_pko;
87         uint64_t fw_err_link;
88         uint64_t fw_err_drop;
89         uint64_t fw_rx_vxlan;
90         uint64_t fw_rx_vxlan_err;
91
92         /* LRO */
93         uint64_t fw_lro_pkts;   /* Number of packets that are LROed */
94         uint64_t fw_lro_octs;   /* Number of octets that are LROed */
95         uint64_t fw_total_lro;  /* Number of LRO packets formed */
96         uint64_t fw_lro_aborts; /* Number of times lRO of packet aborted */
97         uint64_t fw_lro_aborts_port;
98         uint64_t fw_lro_aborts_seq;
99         uint64_t fw_lro_aborts_tsval;
100         uint64_t fw_lro_aborts_timer;
101         /* intrmod: packet forward rate */
102         uint64_t fwd_rate;
103 };
104
105 /** Stats for each NIC port in RX direction. */
106 struct octeon_tx_stats {
107         /* link-level stats */
108         uint64_t total_pkts_sent;
109         uint64_t total_bytes_sent;
110         uint64_t mcast_pkts_sent;
111         uint64_t bcast_pkts_sent;
112         uint64_t ctl_sent;
113         uint64_t one_collision_sent;    /* Packets sent after one collision */
114         /* Packets sent after multiple collision */
115         uint64_t multi_collision_sent;
116         /* Packets not sent due to max collisions */
117         uint64_t max_collision_fail;
118         /* Packets not sent due to max deferrals */
119         uint64_t max_deferral_fail;
120         /* Accounts for over/under-run of buffers */
121         uint64_t fifo_err;
122         uint64_t runts;
123         uint64_t total_collisions; /* Total number of collisions detected */
124
125         /* firmware stats */
126         uint64_t fw_total_sent;
127         uint64_t fw_total_fwd;
128         uint64_t fw_total_fwd_bytes;
129         uint64_t fw_err_pko;
130         uint64_t fw_err_link;
131         uint64_t fw_err_drop;
132         uint64_t fw_err_tso;
133         uint64_t fw_tso;     /* number of tso requests */
134         uint64_t fw_tso_fwd; /* number of packets segmented in tso */
135         uint64_t fw_tx_vxlan;
136 };
137
138 struct octeon_link_stats {
139         struct octeon_rx_stats fromwire;
140         struct octeon_tx_stats fromhost;
141 };
142
143 union lio_if_cfg {
144         uint64_t if_cfg64;
145         struct {
146 #if RTE_BYTE_ORDER == RTE_BIG_ENDIAN
147                 uint64_t base_queue : 16;
148                 uint64_t num_iqueues : 16;
149                 uint64_t num_oqueues : 16;
150                 uint64_t gmx_port_id : 8;
151                 uint64_t vf_id : 8;
152 #else
153                 uint64_t vf_id : 8;
154                 uint64_t gmx_port_id : 8;
155                 uint64_t num_oqueues : 16;
156                 uint64_t num_iqueues : 16;
157                 uint64_t base_queue : 16;
158 #endif
159         } s;
160 };
161
162 struct lio_if_cfg_resp {
163         uint64_t rh;
164         struct octeon_if_cfg_info cfg_info;
165         uint64_t status;
166 };
167
168 struct lio_link_stats_resp {
169         uint64_t rh;
170         struct octeon_link_stats link_stats;
171         uint64_t status;
172 };
173
174 struct lio_link_status_resp {
175         uint64_t rh;
176         struct octeon_link_info link_info;
177         uint64_t status;
178 };
179
180 struct lio_rss_set {
181         struct param {
182 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
183                 uint64_t flags : 16;
184                 uint64_t hashinfo : 32;
185                 uint64_t itablesize : 16;
186                 uint64_t hashkeysize : 16;
187                 uint64_t reserved : 48;
188 #elif RTE_BYTE_ORDER == RTE_BIG_ENDIAN
189                 uint64_t itablesize : 16;
190                 uint64_t hashinfo : 32;
191                 uint64_t flags : 16;
192                 uint64_t reserved : 48;
193                 uint64_t hashkeysize : 16;
194 #endif
195         } param;
196
197         uint8_t itable[LIO_RSS_MAX_TABLE_SZ];
198         uint8_t key[LIO_RSS_MAX_KEY_SZ];
199 };
200
201 void lio_dev_rx_queue_release(void *rxq);
202
203 void lio_dev_tx_queue_release(void *txq);
204
205 #endif  /* _LIO_ETHDEV_H_ */