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/t4_hw.h"
40#include "../cxgb4/t4fw_api.h"
41
42#define CHELSIO_CHIP_CODE(version, revision) (((version) << 4) | (revision))
43#define CHELSIO_CHIP_VERSION(code) (((code) >> 4) & 0xf)
44#define CHELSIO_CHIP_RELEASE(code) ((code) & 0xf)
45
46
47
48
49
50
51
52
53#define CHELSIO_T4 0x4
54#define CHELSIO_T5 0x5
55#define CHELSIO_T6 0x6
56
57enum chip_type {
58 T4_A1 = CHELSIO_CHIP_CODE(CHELSIO_T4, 1),
59 T4_A2 = CHELSIO_CHIP_CODE(CHELSIO_T4, 2),
60 T4_FIRST_REV = T4_A1,
61 T4_LAST_REV = T4_A2,
62
63 T5_A0 = CHELSIO_CHIP_CODE(CHELSIO_T5, 0),
64 T5_A1 = CHELSIO_CHIP_CODE(CHELSIO_T5, 1),
65 T5_FIRST_REV = T5_A0,
66 T5_LAST_REV = T5_A1,
67};
68
69
70
71
72#define FW_LEN16(fw_struct) FW_CMD_LEN16_V(sizeof(fw_struct) / 16)
73
74
75
76
77struct t4vf_port_stats {
78
79
80
81 u64 tx_bcast_bytes;
82 u64 tx_bcast_frames;
83 u64 tx_mcast_bytes;
84 u64 tx_mcast_frames;
85 u64 tx_ucast_bytes;
86 u64 tx_ucast_frames;
87 u64 tx_drop_frames;
88 u64 tx_offload_bytes;
89 u64 tx_offload_frames;
90
91
92
93
94 u64 rx_bcast_bytes;
95 u64 rx_bcast_frames;
96 u64 rx_mcast_bytes;
97 u64 rx_mcast_frames;
98 u64 rx_ucast_bytes;
99 u64 rx_ucast_frames;
100
101 u64 rx_err_frames;
102};
103
104
105
106
107struct link_config {
108 unsigned int supported;
109 unsigned int advertising;
110 unsigned short lp_advertising;
111 unsigned int requested_speed;
112 unsigned int speed;
113 unsigned char requested_fc;
114 unsigned char fc;
115 unsigned char autoneg;
116 unsigned char link_ok;
117};
118
119enum {
120 PAUSE_RX = 1 << 0,
121 PAUSE_TX = 1 << 1,
122 PAUSE_AUTONEG = 1 << 2
123};
124
125
126
127
128struct dev_params {
129 u32 fwrev;
130 u32 tprev;
131};
132
133
134
135
136
137
138struct sge_params {
139 u32 sge_control;
140 u32 sge_control2;
141 u32 sge_host_page_size;
142 u32 sge_egress_queues_per_page;
143 u32 sge_ingress_queues_per_page;
144 u32 sge_vf_hps;
145 u32 sge_vf_eq_qpp;
146 u32 sge_vf_iq_qpp;
147 u32 sge_fl_buffer_size[16];
148 u32 sge_ingress_rx_threshold;
149 u32 sge_congestion_control;
150 u32 sge_timer_value_0_and_1;
151 u32 sge_timer_value_2_and_3;
152 u32 sge_timer_value_4_and_5;
153};
154
155
156
157
158struct vpd_params {
159 u32 cclk;
160};
161
162
163struct arch_specific_params {
164 u32 sge_fl_db;
165 u16 mps_tcam_size;
166};
167
168
169
170
171struct rss_params {
172 unsigned int mode;
173 union {
174 struct {
175 unsigned int synmapen:1;
176 unsigned int syn4tupenipv6:1;
177 unsigned int syn2tupenipv6:1;
178 unsigned int syn4tupenipv4:1;
179 unsigned int syn2tupenipv4:1;
180 unsigned int ofdmapen:1;
181 unsigned int tnlmapen:1;
182 unsigned int tnlalllookup:1;
183 unsigned int hashtoeplitz:1;
184 } basicvirtual;
185 } u;
186};
187
188
189
190
191union rss_vi_config {
192 struct {
193 u16 defaultq;
194 unsigned int ip6fourtupen:1;
195 unsigned int ip6twotupen:1;
196 unsigned int ip4fourtupen:1;
197 unsigned int ip4twotupen:1;
198 int udpen;
199 } basicvirtual;
200};
201
202
203
204
205struct vf_resources {
206 unsigned int nvi;
207 unsigned int neq;
208 unsigned int nethctrl;
209 unsigned int niqflint;
210 unsigned int niq;
211 unsigned int tc;
212 unsigned int pmask;
213 unsigned int nexactf;
214 unsigned int r_caps;
215 unsigned int wx_caps;
216};
217
218
219
220
221struct adapter_params {
222 struct dev_params dev;
223 struct sge_params sge;
224 struct vpd_params vpd;
225 struct rss_params rss;
226 struct vf_resources vfres;
227 struct arch_specific_params arch;
228 enum chip_type chip;
229 u8 nports;
230};
231
232
233
234
235
236struct mbox_cmd {
237 u64 cmd[MBOX_LEN / 8];
238 u64 timestamp;
239 u32 seqno;
240 s16 access;
241 s16 execute;
242};
243
244struct mbox_cmd_log {
245 unsigned int size;
246 unsigned int cursor;
247 u32 seqno;
248
249};
250
251
252
253
254static inline struct mbox_cmd *mbox_cmd_log_entry(struct mbox_cmd_log *log,
255 unsigned int entry_idx)
256{
257 return &((struct mbox_cmd *)&(log)[1])[entry_idx];
258}
259
260#include "adapter.h"
261
262#ifndef PCI_VENDOR_ID_CHELSIO
263# define PCI_VENDOR_ID_CHELSIO 0x1425
264#endif
265
266#define for_each_port(adapter, iter) \
267 for (iter = 0; iter < (adapter)->params.nports; iter++)
268
269static inline bool is_10g_port(const struct link_config *lc)
270{
271 return (lc->supported & FW_PORT_CAP_SPEED_10G) != 0;
272}
273
274
275
276
277static inline bool is_x_10g_port(const struct link_config *lc)
278{
279 unsigned int speeds, high_speeds;
280
281 speeds = FW_PORT_CAP_SPEED_V(FW_PORT_CAP_SPEED_G(lc->supported));
282 high_speeds = speeds & ~(FW_PORT_CAP_SPEED_100M | FW_PORT_CAP_SPEED_1G);
283
284 return high_speeds != 0;
285}
286
287static inline unsigned int core_ticks_per_usec(const struct adapter *adapter)
288{
289 return adapter->params.vpd.cclk / 1000;
290}
291
292static inline unsigned int us_to_core_ticks(const struct adapter *adapter,
293 unsigned int us)
294{
295 return (us * adapter->params.vpd.cclk) / 1000;
296}
297
298static inline unsigned int core_ticks_to_us(const struct adapter *adapter,
299 unsigned int ticks)
300{
301 return (ticks * 1000) / adapter->params.vpd.cclk;
302}
303
304int t4vf_wr_mbox_core(struct adapter *, const void *, int, void *, bool);
305
306static inline int t4vf_wr_mbox(struct adapter *adapter, const void *cmd,
307 int size, void *rpl)
308{
309 return t4vf_wr_mbox_core(adapter, cmd, size, rpl, true);
310}
311
312static inline int t4vf_wr_mbox_ns(struct adapter *adapter, const void *cmd,
313 int size, void *rpl)
314{
315 return t4vf_wr_mbox_core(adapter, cmd, size, rpl, false);
316}
317
318#define CHELSIO_PCI_ID_VER(dev_id) ((dev_id) >> 12)
319
320static inline int is_t4(enum chip_type chip)
321{
322 return CHELSIO_CHIP_VERSION(chip) == CHELSIO_T4;
323}
324
325
326
327
328
329
330
331
332static inline int hash_mac_addr(const u8 *addr)
333{
334 u32 a = ((u32)addr[0] << 16) | ((u32)addr[1] << 8) | addr[2];
335 u32 b = ((u32)addr[3] << 16) | ((u32)addr[4] << 8) | addr[5];
336
337 a ^= b;
338 a ^= (a >> 12);
339 a ^= (a >> 6);
340 return a & 0x3f;
341}
342
343int t4vf_wait_dev_ready(struct adapter *);
344int t4vf_port_init(struct adapter *, int);
345
346int t4vf_fw_reset(struct adapter *);
347int t4vf_set_params(struct adapter *, unsigned int, const u32 *, const u32 *);
348
349int t4vf_fl_pkt_align(struct adapter *adapter);
350enum t4_bar2_qtype { T4_BAR2_QTYPE_EGRESS, T4_BAR2_QTYPE_INGRESS };
351int t4vf_bar2_sge_qregs(struct adapter *adapter,
352 unsigned int qid,
353 enum t4_bar2_qtype qtype,
354 u64 *pbar2_qoffset,
355 unsigned int *pbar2_qid);
356
357int t4vf_get_sge_params(struct adapter *);
358int t4vf_get_vpd_params(struct adapter *);
359int t4vf_get_dev_params(struct adapter *);
360int t4vf_get_rss_glb_config(struct adapter *);
361int t4vf_get_vfres(struct adapter *);
362
363int t4vf_read_rss_vi_config(struct adapter *, unsigned int,
364 union rss_vi_config *);
365int t4vf_write_rss_vi_config(struct adapter *, unsigned int,
366 union rss_vi_config *);
367int t4vf_config_rss_range(struct adapter *, unsigned int, int, int,
368 const u16 *, int);
369
370int t4vf_alloc_vi(struct adapter *, int);
371int t4vf_free_vi(struct adapter *, int);
372int t4vf_enable_vi(struct adapter *, unsigned int, bool, bool);
373int t4vf_identify_port(struct adapter *, unsigned int, unsigned int);
374
375int t4vf_set_rxmode(struct adapter *, unsigned int, int, int, int, int, int,
376 bool);
377int t4vf_alloc_mac_filt(struct adapter *, unsigned int, bool, unsigned int,
378 const u8 **, u16 *, u64 *, bool);
379int t4vf_free_mac_filt(struct adapter *, unsigned int, unsigned int naddr,
380 const u8 **, bool);
381int t4vf_change_mac(struct adapter *, unsigned int, int, const u8 *, bool);
382int t4vf_set_addr_hash(struct adapter *, unsigned int, bool, u64, bool);
383int t4vf_get_port_stats(struct adapter *, int, struct t4vf_port_stats *);
384
385int t4vf_iq_free(struct adapter *, unsigned int, unsigned int, unsigned int,
386 unsigned int);
387int t4vf_eth_eq_free(struct adapter *, unsigned int);
388
389int t4vf_handle_fw_rpl(struct adapter *, const __be64 *);
390int t4vf_prep_adapter(struct adapter *);
391
392#endif
393