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