1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36#ifndef __T4VF_COMMON_H__
37#define __T4VF_COMMON_H__
38
39#include "../cxgb4/t4fw_api.h"
40
41#define CHELSIO_CHIP_CODE(version, revision) (((version) << 4) | (revision))
42#define CHELSIO_CHIP_VERSION(code) (((code) >> 4) & 0xf)
43#define CHELSIO_CHIP_RELEASE(code) ((code) & 0xf)
44
45
46
47
48
49
50
51
52#define CHELSIO_T4 0x4
53#define CHELSIO_T5 0x5
54
55enum chip_type {
56 T4_A1 = CHELSIO_CHIP_CODE(CHELSIO_T4, 1),
57 T4_A2 = CHELSIO_CHIP_CODE(CHELSIO_T4, 2),
58 T4_FIRST_REV = T4_A1,
59 T4_LAST_REV = T4_A2,
60
61 T5_A0 = CHELSIO_CHIP_CODE(CHELSIO_T5, 0),
62 T5_A1 = CHELSIO_CHIP_CODE(CHELSIO_T5, 1),
63 T5_FIRST_REV = T5_A0,
64 T5_LAST_REV = T5_A1,
65};
66
67
68
69
70#define FW_LEN16(fw_struct) FW_CMD_LEN16(sizeof(fw_struct) / 16)
71
72
73
74
75struct t4vf_port_stats {
76
77
78
79 u64 tx_bcast_bytes;
80 u64 tx_bcast_frames;
81 u64 tx_mcast_bytes;
82 u64 tx_mcast_frames;
83 u64 tx_ucast_bytes;
84 u64 tx_ucast_frames;
85 u64 tx_drop_frames;
86 u64 tx_offload_bytes;
87 u64 tx_offload_frames;
88
89
90
91
92 u64 rx_bcast_bytes;
93 u64 rx_bcast_frames;
94 u64 rx_mcast_bytes;
95 u64 rx_mcast_frames;
96 u64 rx_ucast_bytes;
97 u64 rx_ucast_frames;
98
99 u64 rx_err_frames;
100};
101
102
103
104
105struct link_config {
106 unsigned int supported;
107 unsigned int advertising;
108 unsigned short requested_speed;
109 unsigned short speed;
110 unsigned char requested_fc;
111 unsigned char fc;
112 unsigned char autoneg;
113 unsigned char link_ok;
114};
115
116enum {
117 PAUSE_RX = 1 << 0,
118 PAUSE_TX = 1 << 1,
119 PAUSE_AUTONEG = 1 << 2
120};
121
122
123
124
125struct dev_params {
126 u32 fwrev;
127 u32 tprev;
128};
129
130
131
132
133
134
135struct sge_params {
136 u32 sge_control;
137 u32 sge_host_page_size;
138 u32 sge_queues_per_page;
139 u32 sge_user_mode_limits;
140 u32 sge_fl_buffer_size[16];
141 u32 sge_ingress_rx_threshold;
142 u32 sge_timer_value_0_and_1;
143 u32 sge_timer_value_2_and_3;
144 u32 sge_timer_value_4_and_5;
145};
146
147
148
149
150struct vpd_params {
151 u32 cclk;
152};
153
154
155
156
157struct rss_params {
158 unsigned int mode;
159 union {
160 struct {
161 unsigned int synmapen:1;
162 unsigned int syn4tupenipv6:1;
163 unsigned int syn2tupenipv6:1;
164 unsigned int syn4tupenipv4:1;
165 unsigned int syn2tupenipv4:1;
166 unsigned int ofdmapen:1;
167 unsigned int tnlmapen:1;
168 unsigned int tnlalllookup:1;
169 unsigned int hashtoeplitz:1;
170 } basicvirtual;
171 } u;
172};
173
174
175
176
177union rss_vi_config {
178 struct {
179 u16 defaultq;
180 unsigned int ip6fourtupen:1;
181 unsigned int ip6twotupen:1;
182 unsigned int ip4fourtupen:1;
183 unsigned int ip4twotupen:1;
184 int udpen;
185 } basicvirtual;
186};
187
188
189
190
191struct vf_resources {
192 unsigned int nvi;
193 unsigned int neq;
194 unsigned int nethctrl;
195 unsigned int niqflint;
196 unsigned int niq;
197 unsigned int tc;
198 unsigned int pmask;
199 unsigned int nexactf;
200 unsigned int r_caps;
201 unsigned int wx_caps;
202};
203
204
205
206
207struct adapter_params {
208 struct dev_params dev;
209 struct sge_params sge;
210 struct vpd_params vpd;
211 struct rss_params rss;
212 struct vf_resources vfres;
213 enum chip_type chip;
214 u8 nports;
215};
216
217#include "adapter.h"
218
219#ifndef PCI_VENDOR_ID_CHELSIO
220# define PCI_VENDOR_ID_CHELSIO 0x1425
221#endif
222
223#define for_each_port(adapter, iter) \
224 for (iter = 0; iter < (adapter)->params.nports; iter++)
225
226static inline bool is_10g_port(const struct link_config *lc)
227{
228 return (lc->supported & SUPPORTED_10000baseT_Full) != 0;
229}
230
231static inline unsigned int core_ticks_per_usec(const struct adapter *adapter)
232{
233 return adapter->params.vpd.cclk / 1000;
234}
235
236static inline unsigned int us_to_core_ticks(const struct adapter *adapter,
237 unsigned int us)
238{
239 return (us * adapter->params.vpd.cclk) / 1000;
240}
241
242static inline unsigned int core_ticks_to_us(const struct adapter *adapter,
243 unsigned int ticks)
244{
245 return (ticks * 1000) / adapter->params.vpd.cclk;
246}
247
248int t4vf_wr_mbox_core(struct adapter *, const void *, int, void *, bool);
249
250static inline int t4vf_wr_mbox(struct adapter *adapter, const void *cmd,
251 int size, void *rpl)
252{
253 return t4vf_wr_mbox_core(adapter, cmd, size, rpl, true);
254}
255
256static inline int t4vf_wr_mbox_ns(struct adapter *adapter, const void *cmd,
257 int size, void *rpl)
258{
259 return t4vf_wr_mbox_core(adapter, cmd, size, rpl, false);
260}
261
262static inline int is_t4(enum chip_type chip)
263{
264 return CHELSIO_CHIP_VERSION(chip) == CHELSIO_T4;
265}
266
267int t4vf_wait_dev_ready(struct adapter *);
268int t4vf_port_init(struct adapter *, int);
269
270int t4vf_fw_reset(struct adapter *);
271int t4vf_query_params(struct adapter *, unsigned int, const u32 *, u32 *);
272int t4vf_set_params(struct adapter *, unsigned int, const u32 *, const u32 *);
273
274int t4vf_get_sge_params(struct adapter *);
275int t4vf_get_vpd_params(struct adapter *);
276int t4vf_get_dev_params(struct adapter *);
277int t4vf_get_rss_glb_config(struct adapter *);
278int t4vf_get_vfres(struct adapter *);
279
280int t4vf_read_rss_vi_config(struct adapter *, unsigned int,
281 union rss_vi_config *);
282int t4vf_write_rss_vi_config(struct adapter *, unsigned int,
283 union rss_vi_config *);
284int t4vf_config_rss_range(struct adapter *, unsigned int, int, int,
285 const u16 *, int);
286
287int t4vf_alloc_vi(struct adapter *, int);
288int t4vf_free_vi(struct adapter *, int);
289int t4vf_enable_vi(struct adapter *, unsigned int, bool, bool);
290int t4vf_identify_port(struct adapter *, unsigned int, unsigned int);
291
292int t4vf_set_rxmode(struct adapter *, unsigned int, int, int, int, int, int,
293 bool);
294int t4vf_alloc_mac_filt(struct adapter *, unsigned int, bool, unsigned int,
295 const u8 **, u16 *, u64 *, bool);
296int t4vf_change_mac(struct adapter *, unsigned int, int, const u8 *, bool);
297int t4vf_set_addr_hash(struct adapter *, unsigned int, bool, u64, bool);
298int t4vf_get_port_stats(struct adapter *, int, struct t4vf_port_stats *);
299
300int t4vf_iq_free(struct adapter *, unsigned int, unsigned int, unsigned int,
301 unsigned int);
302int t4vf_eth_eq_free(struct adapter *, unsigned int);
303
304int t4vf_handle_fw_rpl(struct adapter *, const __be64 *);
305
306#endif
307