This source file includes following definitions.
- is_x_10g_port
- mbox_cmd_log_entry
- core_ticks_per_usec
- us_to_core_ticks
- core_ticks_to_us
- t4vf_wr_mbox
- t4vf_wr_mbox_ns
- is_t4
- hash_mac_addr
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
57 enum 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
77 struct 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
107 typedef u16 fw_port_cap16_t;
108 typedef u32 fw_port_cap32_t;
109
110 enum fw_caps {
111 FW_CAPS_UNKNOWN = 0,
112 FW_CAPS16 = 1,
113 FW_CAPS32 = 2,
114 };
115
116 enum cc_pause {
117 PAUSE_RX = 1 << 0,
118 PAUSE_TX = 1 << 1,
119 PAUSE_AUTONEG = 1 << 2
120 };
121
122 enum cc_fec {
123 FEC_AUTO = 1 << 0,
124 FEC_RS = 1 << 1,
125 FEC_BASER_RS = 1 << 2,
126 };
127
128 struct link_config {
129 fw_port_cap32_t pcaps;
130 fw_port_cap32_t acaps;
131 fw_port_cap32_t lpacaps;
132
133 fw_port_cap32_t speed_caps;
134 u32 speed;
135
136 enum cc_pause requested_fc;
137 enum cc_pause fc;
138 enum cc_pause advertised_fc;
139
140 enum cc_fec auto_fec;
141 enum cc_fec requested_fec;
142 enum cc_fec fec;
143
144 unsigned char autoneg;
145
146 unsigned char link_ok;
147 unsigned char link_down_rc;
148 };
149
150
151
152
153 static inline bool is_x_10g_port(const struct link_config *lc)
154 {
155 fw_port_cap32_t speeds, high_speeds;
156
157 speeds = FW_PORT_CAP32_SPEED_V(FW_PORT_CAP32_SPEED_G(lc->pcaps));
158 high_speeds =
159 speeds & ~(FW_PORT_CAP32_SPEED_100M | FW_PORT_CAP32_SPEED_1G);
160
161 return high_speeds != 0;
162 }
163
164
165
166
167 struct dev_params {
168 u32 fwrev;
169 u32 tprev;
170 };
171
172
173
174
175
176
177 struct sge_params {
178 u32 sge_control;
179 u32 sge_control2;
180 u32 sge_host_page_size;
181 u32 sge_egress_queues_per_page;
182 u32 sge_ingress_queues_per_page;
183 u32 sge_vf_hps;
184 u32 sge_vf_eq_qpp;
185 u32 sge_vf_iq_qpp;
186 u32 sge_fl_buffer_size[16];
187 u32 sge_ingress_rx_threshold;
188 u32 sge_congestion_control;
189 u32 sge_timer_value_0_and_1;
190 u32 sge_timer_value_2_and_3;
191 u32 sge_timer_value_4_and_5;
192 };
193
194
195
196
197 struct vpd_params {
198 u32 cclk;
199 };
200
201
202 struct arch_specific_params {
203 u32 sge_fl_db;
204 u16 mps_tcam_size;
205 };
206
207
208
209
210 struct rss_params {
211 unsigned int mode;
212 union {
213 struct {
214 unsigned int synmapen:1;
215 unsigned int syn4tupenipv6:1;
216 unsigned int syn2tupenipv6:1;
217 unsigned int syn4tupenipv4:1;
218 unsigned int syn2tupenipv4:1;
219 unsigned int ofdmapen:1;
220 unsigned int tnlmapen:1;
221 unsigned int tnlalllookup:1;
222 unsigned int hashtoeplitz:1;
223 } basicvirtual;
224 } u;
225 };
226
227
228
229
230 union rss_vi_config {
231 struct {
232 u16 defaultq;
233 unsigned int ip6fourtupen:1;
234 unsigned int ip6twotupen:1;
235 unsigned int ip4fourtupen:1;
236 unsigned int ip4twotupen:1;
237 int udpen;
238 } basicvirtual;
239 };
240
241
242
243
244 struct vf_resources {
245 unsigned int nvi;
246 unsigned int neq;
247 unsigned int nethctrl;
248 unsigned int niqflint;
249 unsigned int niq;
250 unsigned int tc;
251 unsigned int pmask;
252 unsigned int nexactf;
253 unsigned int r_caps;
254 unsigned int wx_caps;
255 };
256
257
258
259
260 struct adapter_params {
261 struct dev_params dev;
262 struct sge_params sge;
263 struct vpd_params vpd;
264 struct rss_params rss;
265 struct vf_resources vfres;
266 struct arch_specific_params arch;
267 enum chip_type chip;
268 u8 nports;
269 u8 fw_caps_support;
270 };
271
272
273
274
275
276 struct mbox_cmd {
277 u64 cmd[MBOX_LEN / 8];
278 u64 timestamp;
279 u32 seqno;
280 s16 access;
281 s16 execute;
282 };
283
284 struct mbox_cmd_log {
285 unsigned int size;
286 unsigned int cursor;
287 u32 seqno;
288
289 };
290
291
292
293
294 static inline struct mbox_cmd *mbox_cmd_log_entry(struct mbox_cmd_log *log,
295 unsigned int entry_idx)
296 {
297 return &((struct mbox_cmd *)&(log)[1])[entry_idx];
298 }
299
300 #include "adapter.h"
301
302 #ifndef PCI_VENDOR_ID_CHELSIO
303 # define PCI_VENDOR_ID_CHELSIO 0x1425
304 #endif
305
306 #define for_each_port(adapter, iter) \
307 for (iter = 0; iter < (adapter)->params.nports; iter++)
308
309 static inline unsigned int core_ticks_per_usec(const struct adapter *adapter)
310 {
311 return adapter->params.vpd.cclk / 1000;
312 }
313
314 static inline unsigned int us_to_core_ticks(const struct adapter *adapter,
315 unsigned int us)
316 {
317 return (us * adapter->params.vpd.cclk) / 1000;
318 }
319
320 static inline unsigned int core_ticks_to_us(const struct adapter *adapter,
321 unsigned int ticks)
322 {
323 return (ticks * 1000) / adapter->params.vpd.cclk;
324 }
325
326 int t4vf_wr_mbox_core(struct adapter *, const void *, int, void *, bool);
327
328 static inline int t4vf_wr_mbox(struct adapter *adapter, const void *cmd,
329 int size, void *rpl)
330 {
331 return t4vf_wr_mbox_core(adapter, cmd, size, rpl, true);
332 }
333
334 static inline int t4vf_wr_mbox_ns(struct adapter *adapter, const void *cmd,
335 int size, void *rpl)
336 {
337 return t4vf_wr_mbox_core(adapter, cmd, size, rpl, false);
338 }
339
340 #define CHELSIO_PCI_ID_VER(dev_id) ((dev_id) >> 12)
341
342 static inline int is_t4(enum chip_type chip)
343 {
344 return CHELSIO_CHIP_VERSION(chip) == CHELSIO_T4;
345 }
346
347
348
349
350
351
352
353
354 static inline int hash_mac_addr(const u8 *addr)
355 {
356 u32 a = ((u32)addr[0] << 16) | ((u32)addr[1] << 8) | addr[2];
357 u32 b = ((u32)addr[3] << 16) | ((u32)addr[4] << 8) | addr[5];
358
359 a ^= b;
360 a ^= (a >> 12);
361 a ^= (a >> 6);
362 return a & 0x3f;
363 }
364
365 int t4vf_wait_dev_ready(struct adapter *);
366 int t4vf_port_init(struct adapter *, int);
367
368 int t4vf_fw_reset(struct adapter *);
369 int t4vf_set_params(struct adapter *, unsigned int, const u32 *, const u32 *);
370
371 int t4vf_fl_pkt_align(struct adapter *adapter);
372 enum t4_bar2_qtype { T4_BAR2_QTYPE_EGRESS, T4_BAR2_QTYPE_INGRESS };
373 int t4vf_bar2_sge_qregs(struct adapter *adapter,
374 unsigned int qid,
375 enum t4_bar2_qtype qtype,
376 u64 *pbar2_qoffset,
377 unsigned int *pbar2_qid);
378
379 unsigned int t4vf_get_pf_from_vf(struct adapter *);
380 int t4vf_get_sge_params(struct adapter *);
381 int t4vf_get_vpd_params(struct adapter *);
382 int t4vf_get_dev_params(struct adapter *);
383 int t4vf_get_rss_glb_config(struct adapter *);
384 int t4vf_get_vfres(struct adapter *);
385
386 int t4vf_read_rss_vi_config(struct adapter *, unsigned int,
387 union rss_vi_config *);
388 int t4vf_write_rss_vi_config(struct adapter *, unsigned int,
389 union rss_vi_config *);
390 int t4vf_config_rss_range(struct adapter *, unsigned int, int, int,
391 const u16 *, int);
392
393 int t4vf_alloc_vi(struct adapter *, int);
394 int t4vf_free_vi(struct adapter *, int);
395 int t4vf_enable_vi(struct adapter *adapter, unsigned int viid, bool rx_en,
396 bool tx_en);
397 int t4vf_enable_pi(struct adapter *adapter, struct port_info *pi, bool rx_en,
398 bool tx_en);
399 int t4vf_identify_port(struct adapter *, unsigned int, unsigned int);
400
401 int t4vf_set_rxmode(struct adapter *, unsigned int, int, int, int, int, int,
402 bool);
403 int t4vf_alloc_mac_filt(struct adapter *, unsigned int, bool, unsigned int,
404 const u8 **, u16 *, u64 *, bool);
405 int t4vf_free_mac_filt(struct adapter *, unsigned int, unsigned int naddr,
406 const u8 **, bool);
407 int t4vf_change_mac(struct adapter *, unsigned int, int, const u8 *, bool);
408 int t4vf_set_addr_hash(struct adapter *, unsigned int, bool, u64, bool);
409 int t4vf_get_port_stats(struct adapter *, int, struct t4vf_port_stats *);
410
411 int t4vf_iq_free(struct adapter *, unsigned int, unsigned int, unsigned int,
412 unsigned int);
413 int t4vf_eth_eq_free(struct adapter *, unsigned int);
414
415 int t4vf_update_port_info(struct port_info *pi);
416 int t4vf_handle_fw_rpl(struct adapter *, const __be64 *);
417 int t4vf_prep_adapter(struct adapter *);
418 int t4vf_get_vf_mac_acl(struct adapter *adapter, unsigned int pf,
419 unsigned int *naddr, u8 *addr);
420 int t4vf_get_vf_vlan_acl(struct adapter *adapter);
421
422 #endif