bnx2x: update VF to support newer PF drivers
[dpdk.git] / drivers / net / bnx2x / bnx2x_vfpf.h
1 /*
2  * Copyright (c) 2013-2015 Brocade Communications Systems, Inc.
3  *
4  * All rights reserved.
5  */
6
7 #ifndef BNX2X_VFPF_H
8 #define BNX2X_VFPF_H
9
10 #include "ecore_sp.h"
11
12 #define VLAN_HLEN 4
13
14 struct vf_resource_query {
15         uint8_t num_rxqs;
16         uint8_t num_txqs;
17         uint8_t num_sbs;
18         uint8_t num_mac_filters;
19         uint8_t num_vlan_filters;
20         uint8_t num_mc_filters;
21 };
22
23 #define BNX2X_VF_STATUS_SUCCESS         1
24 #define BNX2X_VF_STATUS_FAILURE         2
25 #define BNX2X_VF_STATUS_NO_RESOURCES    4
26 #define BNX2X_VF_BULLETIN_TRIES         5
27
28 #define BNX2X_VF_Q_FLAG_CACHE_ALIGN     0x0008
29 #define BNX2X_VF_Q_FLAG_STATS           0x0010
30 #define BNX2X_VF_Q_FLAG_OV              0x0020
31 #define BNX2X_VF_Q_FLAG_VLAN            0x0040
32 #define BNX2X_VF_Q_FLAG_COS             0x0080
33 #define BNX2X_VF_Q_FLAG_HC              0x0100
34 #define BNX2X_VF_Q_FLAG_DHC             0x0200
35 #define BNX2X_VF_Q_FLAG_LEADING_RSS     0x0400
36
37 #define TLV_BUFFER_SIZE                 1024
38
39 /* general tlv header (used for both vf->pf request and pf->vf response) */
40 struct channel_tlv {
41         uint16_t type;
42         uint16_t length;
43 };
44
45 struct vf_first_tlv {
46         uint16_t type;
47         uint16_t length;
48         uint32_t reply_offset;
49 };
50
51 struct tlv_buffer_size {
52         uint8_t tlv_buffer[TLV_BUFFER_SIZE];
53 };
54
55 /* tlv struct for all PF replies except acquire */
56 struct vf_common_reply_tlv {
57         uint16_t type;
58         uint16_t length;
59         uint8_t status;
60         uint8_t pad[3];
61 };
62
63 /* used to terminate and pad a tlv list */
64 struct channel_list_end_tlv {
65         uint16_t type;
66         uint16_t length;
67         uint32_t pad;
68 };
69
70 /* Acquire */
71 struct vf_acquire_tlv {
72         struct vf_first_tlv first_tlv;
73
74         uint8_t vf_id;
75         uint8_t pad[3];
76
77         struct vf_resource_query res_query;
78
79         uint64_t bulletin_addr;
80 };
81
82 /* simple operation request on queue */
83 struct vf_q_op_tlv {
84         struct vf_first_tlv     first_tlv;
85         uint8_t vf_qid;
86         uint8_t pad[3];
87 };
88
89 /* receive side scaling tlv */
90 struct vf_rss_tlv {
91         struct vf_first_tlv     first_tlv;
92         uint32_t                rss_flags;
93         uint8_t                 rss_result_mask;
94         uint8_t                 ind_table_size;
95         uint8_t                 rss_key_size;
96         uint8_t                 pad;
97         uint8_t                 ind_table[T_ETH_INDIRECTION_TABLE_SIZE];
98         uint32_t                rss_key[T_ETH_RSS_KEY]; /* hash values */
99 };
100
101 struct vf_resc {
102 #define BNX2X_VF_MAX_QUEUES_PER_VF         16
103 #define BNX2X_VF_MAX_SBS_PER_VF            16
104         uint16_t hw_sbs[BNX2X_VF_MAX_SBS_PER_VF];
105         uint8_t hw_qid[BNX2X_VF_MAX_QUEUES_PER_VF];
106         uint8_t num_rxqs;
107         uint8_t num_txqs;
108         uint8_t num_sbs;
109         uint8_t num_mac_filters;
110         uint8_t num_vlan_filters;
111         uint8_t num_mc_filters;
112         uint8_t permanent_mac_addr[ETH_ALEN];
113         uint8_t current_mac_addr[ETH_ALEN];
114         uint16_t pf_link_speed;
115         uint32_t pf_link_supported;
116 };
117
118 /* tlv struct holding reply for acquire */
119 struct vf_acquire_resp_tlv {
120         uint16_t type;
121         uint16_t length;
122         uint8_t status;
123         uint8_t pad1[3];
124         uint32_t chip_num;
125         uint8_t pad2[4];
126         char fw_ver[32];
127         uint16_t db_size;
128         uint8_t pad3[2];
129         struct vf_resc resc;
130 };
131
132 /* Init VF */
133 struct vf_init_tlv {
134         struct vf_first_tlv first_tlv;
135         uint64_t sb_addr[BNX2X_VF_MAX_SBS_PER_VF];
136         uint64_t spq_addr;
137         uint64_t stats_addr;
138         uint16_t stats_step;
139         uint32_t flags;
140         uint32_t pad[2];
141 };
142
143 struct vf_rxq_params {
144         /* physical addresses */
145         uint64_t rcq_addr;
146         uint64_t rcq_np_addr;
147         uint64_t rxq_addr;
148         uint64_t pad1;
149
150         /* sb + hc info */
151         uint8_t  vf_sb_id;
152         uint8_t  sb_cq_index;
153         uint16_t hc_rate;       /* desired interrupts per sec. */
154         /* rx buffer info */
155         uint16_t mtu;
156         uint16_t buf_sz;
157         uint16_t flags;         /* for BNX2X_VF_Q_FLAG_X flags */
158         uint16_t stat_id;       /* valid if BNX2X_VF_Q_FLAG_STATS */
159
160         uint8_t pad2[5];
161
162         uint8_t drop_flags;
163         uint8_t cache_line_log; /* BNX2X_VF_Q_FLAG_CACHE_ALIGN */
164         uint8_t pad3;
165 };
166
167 struct vf_txq_params {
168         /* physical addresses */
169         uint64_t txq_addr;
170
171         /* sb + hc info */
172         uint8_t  vf_sb_id;      /* index in hw_sbs[] */
173         uint8_t  sb_index;      /* Index in the SB */
174         uint16_t hc_rate;       /* desired interrupts per sec. */
175         uint32_t flags;         /* for BNX2X_VF_Q_FLAG_X flags */
176         uint16_t stat_id;       /* valid if BNX2X_VF_Q_FLAG_STATS */
177         uint8_t  traffic_type;  /* see in setup_context() */
178         uint8_t  pad;
179 };
180
181 /* Setup Queue */
182 struct vf_setup_q_tlv {
183         struct vf_first_tlv first_tlv;
184
185         struct vf_rxq_params rxq;
186         struct vf_txq_params txq;
187
188         uint8_t vf_qid;                 /* index in hw_qid[] */
189         uint8_t param_valid;
190         #define VF_RXQ_VALID            0x01
191         #define VF_TXQ_VALID            0x02
192         uint8_t pad[2];
193 };
194
195 /* Set Queue Filters */
196 struct vf_q_mac_vlan_filter {
197         uint32_t flags;
198         #define BNX2X_VF_Q_FILTER_DEST_MAC_VALID        0x01
199         #define BNX2X_VF_Q_FILTER_VLAN_TAG_VALID        0x02
200         #define BNX2X_VF_Q_FILTER_SET_MAC               0x100   /* set/clear */
201         uint8_t  mac[ETH_ALEN];
202         uint16_t vlan_tag;
203 };
204
205
206 #define _UP_ETH_ALEN    (6)
207
208 /* configure queue filters */
209 struct vf_set_q_filters_tlv {
210         struct vf_first_tlv first_tlv;
211
212         uint32_t flags;
213         #define BNX2X_VF_MAC_VLAN_CHANGED       0x01
214         #define BNX2X_VF_MULTICAST_CHANGED      0x02
215         #define BNX2X_VF_RX_MASK_CHANGED        0x04
216
217         uint8_t vf_qid;                 /* index in hw_qid[] */
218         uint8_t mac_filters_cnt;
219         uint8_t multicast_cnt;
220         uint8_t pad;
221
222         #define VF_MAX_MAC_FILTERS                      16
223         #define VF_MAX_VLAN_FILTERS                     16
224         #define VF_MAX_FILTERS                  (VF_MAX_MAC_FILTERS +\
225                                                         VF_MAX_VLAN_FILTERS)
226         struct vf_q_mac_vlan_filter filters[VF_MAX_FILTERS];
227
228         #define VF_MAX_MULTICAST_PER_VF                 32
229         uint8_t  multicast[VF_MAX_MULTICAST_PER_VF][_UP_ETH_ALEN];
230         unsigned long rx_mask;
231 };
232
233
234 /* close VF (disable VF) */
235 struct vf_close_tlv {
236         struct vf_first_tlv     first_tlv;
237         uint16_t                vf_id;  /* for debug */
238         uint8_t pad[2];
239 };
240
241 /* rlease the VF's acquired resources */
242 struct vf_release_tlv {
243         struct vf_first_tlv   first_tlv;
244         uint16_t                vf_id;  /* for debug */
245         uint8_t pad[2];
246 };
247
248 union query_tlvs {
249         struct vf_first_tlv             first_tlv;
250         struct vf_acquire_tlv           acquire;
251         struct vf_init_tlv              init;
252         struct vf_close_tlv             close;
253         struct vf_q_op_tlv              q_op;
254         struct vf_setup_q_tlv           setup_q;
255         struct vf_set_q_filters_tlv     set_q_filters;
256         struct vf_release_tlv           release;
257         struct vf_rss_tlv               update_rss;
258         struct channel_list_end_tlv     list_end;
259         struct tlv_buffer_size          tlv_buf_size;
260 };
261
262 union resp_tlvs {
263         struct vf_common_reply_tlv      common_reply;
264         struct vf_acquire_resp_tlv      acquire_resp;
265         struct channel_list_end_tlv     list_end;
266         struct tlv_buffer_size          tlv_buf_size;
267 };
268
269 /* struct allocated by VF driver, PF sends updates to VF via bulletin */
270 struct bnx2x_vf_bulletin {
271         uint32_t crc;                   /* crc of structure to ensure is not in
272                                          * mid-update
273                                          */
274         uint16_t version;
275         uint16_t length;
276
277         uint64_t valid_bitmap;  /* bitmap indicating wich fields
278                                          * hold valid values
279                                          */
280
281 #define MAC_ADDR_VALID          0       /* alert the vf that a new mac address
282                                          * is available for it
283                                          */
284 #define VLAN_VALID              1       /* when set, the vf should no access the
285                                          * vf channel
286                                          */
287 #define CHANNEL_DOWN            2       /* vf channel is disabled. VFs are not
288                                          * to attempt to send messages on the
289                                          * channel after this bit is set
290                                          */
291         uint8_t mac[ETH_ALEN];
292         uint8_t mac_pad[2];
293
294         uint16_t vlan;
295         uint8_t vlan_pad[6];
296 };
297
298 #define MAX_TLVS_IN_LIST 50
299 enum channel_tlvs {
300         BNX2X_VF_TLV_NONE, /* ends tlv sequence */
301         BNX2X_VF_TLV_ACQUIRE,
302         BNX2X_VF_TLV_INIT,
303         BNX2X_VF_TLV_SETUP_Q,
304         BNX2X_VF_TLV_SET_Q_FILTERS,
305         BNX2X_VF_TLV_ACTIVATE_Q,
306         BNX2X_VF_TLV_DEACTIVATE_Q,
307         BNX2X_VF_TLV_TEARDOWN_Q,
308         BNX2X_VF_TLV_CLOSE,
309         BNX2X_VF_TLV_RELEASE,
310         BNX2X_VF_TLV_UPDATE_RSS_OLD,
311         BNX2X_VF_TLV_PF_RELEASE_VF,
312         BNX2X_VF_TLV_LIST_END,
313         BNX2X_VF_TLV_FLR,
314         BNX2X_VF_TLV_PF_SET_MAC,
315         BNX2X_VF_TLV_PF_SET_VLAN,
316         BNX2X_VF_TLV_UPDATE_RSS,
317         BNX2X_VF_TLV_PHYS_PORT_ID,
318         BNX2X_VF_TLV_MAX
319 };
320
321 struct bnx2x_vf_mbx_msg {
322         union query_tlvs query[BNX2X_VF_MAX_QUEUES_PER_VF];
323         union resp_tlvs resp;
324 };
325
326 void bnx2x_add_tlv(void *tlvs_list, uint16_t offset, uint16_t type, uint16_t length);
327 int bnx2x_vf_set_mac(struct bnx2x_softc *sc, int set);
328 int bnx2x_vf_config_rss(struct bnx2x_softc *sc, struct ecore_config_rss_params *params);
329
330 #endif /* BNX2X_VFPF_H */