This source file includes following definitions.
- bna_mac_find
1
2
3
4
5
6
7
8
9
10
11 #ifndef __BNA_H__
12 #define __BNA_H__
13
14 #include "bfa_defs.h"
15 #include "bfa_ioc.h"
16 #include "bfi_enet.h"
17 #include "bna_types.h"
18
19 extern const u32 bna_napi_dim_vector[][BNA_BIAS_T_MAX];
20
21
22
23 #define bna_is_small_rxq(_id) ((_id) & 0x1)
24
25
26
27
28
29 #define BNA_SET_DMA_ADDR(_addr, _bna_dma_addr) \
30 do { \
31 u64 tmp_addr = \
32 cpu_to_be64((u64)(_addr)); \
33 (_bna_dma_addr)->msb = ((struct bna_dma_addr *)&tmp_addr)->msb; \
34 (_bna_dma_addr)->lsb = ((struct bna_dma_addr *)&tmp_addr)->lsb; \
35 } while (0)
36
37
38
39
40
41 #define BNA_GET_DMA_ADDR(_bna_dma_addr, _addr) \
42 do { \
43 (_addr) = ((((u64)ntohl((_bna_dma_addr)->msb))) << 32) \
44 | ((ntohl((_bna_dma_addr)->lsb) & 0xffffffff)); \
45 } while (0)
46
47 #define BNA_TXQ_WI_NEEDED(_vectors) (((_vectors) + 3) >> 2)
48
49 #define BNA_QE_INDX_ADD(_qe_idx, _qe_num, _q_depth) \
50 ((_qe_idx) = ((_qe_idx) + (_qe_num)) & ((_q_depth) - 1))
51
52 #define BNA_QE_INDX_INC(_idx, _q_depth) BNA_QE_INDX_ADD(_idx, 1, _q_depth)
53
54 #define BNA_Q_INDEX_CHANGE(_old_idx, _updated_idx, _q_depth) \
55 (((_updated_idx) - (_old_idx)) & ((_q_depth) - 1))
56
57 #define BNA_QE_FREE_CNT(_q_ptr, _q_depth) \
58 (((_q_ptr)->consumer_index - (_q_ptr)->producer_index - 1) & \
59 ((_q_depth) - 1))
60 #define BNA_QE_IN_USE_CNT(_q_ptr, _q_depth) \
61 ((((_q_ptr)->producer_index - (_q_ptr)->consumer_index)) & \
62 (_q_depth - 1))
63
64 #define BNA_LARGE_PKT_SIZE 1000
65
66 #define BNA_UPDATE_PKT_CNT(_pkt, _len) \
67 do { \
68 if ((_len) > BNA_LARGE_PKT_SIZE) { \
69 (_pkt)->large_pkt_cnt++; \
70 } else { \
71 (_pkt)->small_pkt_cnt++; \
72 } \
73 } while (0)
74
75 #define call_rxf_stop_cbfn(rxf) \
76 do { \
77 if ((rxf)->stop_cbfn) { \
78 void (*cbfn)(struct bna_rx *); \
79 struct bna_rx *cbarg; \
80 cbfn = (rxf)->stop_cbfn; \
81 cbarg = (rxf)->stop_cbarg; \
82 (rxf)->stop_cbfn = NULL; \
83 (rxf)->stop_cbarg = NULL; \
84 cbfn(cbarg); \
85 } \
86 } while (0)
87
88 #define call_rxf_start_cbfn(rxf) \
89 do { \
90 if ((rxf)->start_cbfn) { \
91 void (*cbfn)(struct bna_rx *); \
92 struct bna_rx *cbarg; \
93 cbfn = (rxf)->start_cbfn; \
94 cbarg = (rxf)->start_cbarg; \
95 (rxf)->start_cbfn = NULL; \
96 (rxf)->start_cbarg = NULL; \
97 cbfn(cbarg); \
98 } \
99 } while (0)
100
101 #define call_rxf_cam_fltr_cbfn(rxf) \
102 do { \
103 if ((rxf)->cam_fltr_cbfn) { \
104 void (*cbfn)(struct bnad *, struct bna_rx *); \
105 struct bnad *cbarg; \
106 cbfn = (rxf)->cam_fltr_cbfn; \
107 cbarg = (rxf)->cam_fltr_cbarg; \
108 (rxf)->cam_fltr_cbfn = NULL; \
109 (rxf)->cam_fltr_cbarg = NULL; \
110 cbfn(cbarg, rxf->rx); \
111 } \
112 } while (0)
113
114 #define is_xxx_enable(mode, bitmask, xxx) ((bitmask & xxx) && (mode & xxx))
115
116 #define is_xxx_disable(mode, bitmask, xxx) ((bitmask & xxx) && !(mode & xxx))
117
118 #define xxx_enable(mode, bitmask, xxx) \
119 do { \
120 bitmask |= xxx; \
121 mode |= xxx; \
122 } while (0)
123
124 #define xxx_disable(mode, bitmask, xxx) \
125 do { \
126 bitmask |= xxx; \
127 mode &= ~xxx; \
128 } while (0)
129
130 #define xxx_inactive(mode, bitmask, xxx) \
131 do { \
132 bitmask &= ~xxx; \
133 mode &= ~xxx; \
134 } while (0)
135
136 #define is_promisc_enable(mode, bitmask) \
137 is_xxx_enable(mode, bitmask, BNA_RXMODE_PROMISC)
138
139 #define is_promisc_disable(mode, bitmask) \
140 is_xxx_disable(mode, bitmask, BNA_RXMODE_PROMISC)
141
142 #define promisc_enable(mode, bitmask) \
143 xxx_enable(mode, bitmask, BNA_RXMODE_PROMISC)
144
145 #define promisc_disable(mode, bitmask) \
146 xxx_disable(mode, bitmask, BNA_RXMODE_PROMISC)
147
148 #define promisc_inactive(mode, bitmask) \
149 xxx_inactive(mode, bitmask, BNA_RXMODE_PROMISC)
150
151 #define is_default_enable(mode, bitmask) \
152 is_xxx_enable(mode, bitmask, BNA_RXMODE_DEFAULT)
153
154 #define is_default_disable(mode, bitmask) \
155 is_xxx_disable(mode, bitmask, BNA_RXMODE_DEFAULT)
156
157 #define default_enable(mode, bitmask) \
158 xxx_enable(mode, bitmask, BNA_RXMODE_DEFAULT)
159
160 #define default_disable(mode, bitmask) \
161 xxx_disable(mode, bitmask, BNA_RXMODE_DEFAULT)
162
163 #define default_inactive(mode, bitmask) \
164 xxx_inactive(mode, bitmask, BNA_RXMODE_DEFAULT)
165
166 #define is_allmulti_enable(mode, bitmask) \
167 is_xxx_enable(mode, bitmask, BNA_RXMODE_ALLMULTI)
168
169 #define is_allmulti_disable(mode, bitmask) \
170 is_xxx_disable(mode, bitmask, BNA_RXMODE_ALLMULTI)
171
172 #define allmulti_enable(mode, bitmask) \
173 xxx_enable(mode, bitmask, BNA_RXMODE_ALLMULTI)
174
175 #define allmulti_disable(mode, bitmask) \
176 xxx_disable(mode, bitmask, BNA_RXMODE_ALLMULTI)
177
178 #define allmulti_inactive(mode, bitmask) \
179 xxx_inactive(mode, bitmask, BNA_RXMODE_ALLMULTI)
180
181 #define GET_RXQS(rxp, q0, q1) do { \
182 switch ((rxp)->type) { \
183 case BNA_RXP_SINGLE: \
184 (q0) = rxp->rxq.single.only; \
185 (q1) = NULL; \
186 break; \
187 case BNA_RXP_SLR: \
188 (q0) = rxp->rxq.slr.large; \
189 (q1) = rxp->rxq.slr.small; \
190 break; \
191 case BNA_RXP_HDS: \
192 (q0) = rxp->rxq.hds.data; \
193 (q1) = rxp->rxq.hds.hdr; \
194 break; \
195 } \
196 } while (0)
197
198 #define bna_tx_rid_mask(_bna) ((_bna)->tx_mod.rid_mask)
199
200 #define bna_rx_rid_mask(_bna) ((_bna)->rx_mod.rid_mask)
201
202 #define bna_tx_from_rid(_bna, _rid, _tx) \
203 do { \
204 struct bna_tx_mod *__tx_mod = &(_bna)->tx_mod; \
205 struct bna_tx *__tx; \
206 _tx = NULL; \
207 list_for_each_entry(__tx, &__tx_mod->tx_active_q, qe) { \
208 if (__tx->rid == (_rid)) { \
209 (_tx) = __tx; \
210 break; \
211 } \
212 } \
213 } while (0)
214
215 #define bna_rx_from_rid(_bna, _rid, _rx) \
216 do { \
217 struct bna_rx_mod *__rx_mod = &(_bna)->rx_mod; \
218 struct bna_rx *__rx; \
219 _rx = NULL; \
220 list_for_each_entry(__rx, &__rx_mod->rx_active_q, qe) { \
221 if (__rx->rid == (_rid)) { \
222 (_rx) = __rx; \
223 break; \
224 } \
225 } \
226 } while (0)
227
228 #define bna_mcam_mod_free_q(_bna) (&(_bna)->mcam_mod.free_q)
229
230 #define bna_mcam_mod_del_q(_bna) (&(_bna)->mcam_mod.del_q)
231
232 #define bna_ucam_mod_free_q(_bna) (&(_bna)->ucam_mod.free_q)
233
234 #define bna_ucam_mod_del_q(_bna) (&(_bna)->ucam_mod.del_q)
235
236
237
238 static inline struct bna_mac *bna_mac_find(struct list_head *q, const u8 *addr)
239 {
240 struct bna_mac *mac;
241
242 list_for_each_entry(mac, q, qe)
243 if (ether_addr_equal(mac->addr, addr))
244 return mac;
245 return NULL;
246 }
247
248 #define bna_attr(_bna) (&(_bna)->ioceth.attr)
249
250
251
252
253
254
255 void bna_bfi_stats_clr_rsp(struct bna *bna, struct bfi_msgq_mhdr *msghdr);
256
257
258 void bna_res_req(struct bna_res_info *res_info);
259 void bna_mod_res_req(struct bna *bna, struct bna_res_info *res_info);
260 void bna_init(struct bna *bna, struct bnad *bnad,
261 struct bfa_pcidev *pcidev,
262 struct bna_res_info *res_info);
263 void bna_mod_init(struct bna *bna, struct bna_res_info *res_info);
264 void bna_uninit(struct bna *bna);
265 int bna_num_txq_set(struct bna *bna, int num_txq);
266 int bna_num_rxp_set(struct bna *bna, int num_rxp);
267 void bna_hw_stats_get(struct bna *bna);
268
269
270 struct bna_mac *bna_cam_mod_mac_get(struct list_head *head);
271 struct bna_mcam_handle *bna_mcam_mod_handle_get(struct bna_mcam_mod *mod);
272 void bna_mcam_mod_handle_put(struct bna_mcam_mod *mcam_mod,
273 struct bna_mcam_handle *handle);
274
275
276
277
278 void bna_mbox_handler(struct bna *bna, u32 intr_status);
279
280
281
282
283 void bna_ethport_cb_rx_started(struct bna_ethport *ethport);
284 void bna_ethport_cb_rx_stopped(struct bna_ethport *ethport);
285
286
287
288
289 void bna_bfi_tx_enet_start_rsp(struct bna_tx *tx,
290 struct bfi_msgq_mhdr *msghdr);
291 void bna_bfi_tx_enet_stop_rsp(struct bna_tx *tx,
292 struct bfi_msgq_mhdr *msghdr);
293 void bna_bfi_bw_update_aen(struct bna_tx_mod *tx_mod);
294
295
296 void bna_tx_mod_init(struct bna_tx_mod *tx_mod, struct bna *bna,
297 struct bna_res_info *res_info);
298 void bna_tx_mod_uninit(struct bna_tx_mod *tx_mod);
299
300
301 void bna_tx_mod_start(struct bna_tx_mod *tx_mod, enum bna_tx_type type);
302 void bna_tx_mod_stop(struct bna_tx_mod *tx_mod, enum bna_tx_type type);
303 void bna_tx_mod_fail(struct bna_tx_mod *tx_mod);
304
305
306 void bna_tx_res_req(int num_txq, int txq_depth,
307 struct bna_res_info *res_info);
308 struct bna_tx *bna_tx_create(struct bna *bna, struct bnad *bnad,
309 struct bna_tx_config *tx_cfg,
310 const struct bna_tx_event_cbfn *tx_cbfn,
311 struct bna_res_info *res_info, void *priv);
312 void bna_tx_destroy(struct bna_tx *tx);
313 void bna_tx_enable(struct bna_tx *tx);
314 void bna_tx_disable(struct bna_tx *tx, enum bna_cleanup_type type,
315 void (*cbfn)(void *, struct bna_tx *));
316 void bna_tx_cleanup_complete(struct bna_tx *tx);
317 void bna_tx_coalescing_timeo_set(struct bna_tx *tx, int coalescing_timeo);
318
319
320
321
322 void bna_bfi_rx_enet_start_rsp(struct bna_rx *rx,
323 struct bfi_msgq_mhdr *msghdr);
324 void bna_bfi_rx_enet_stop_rsp(struct bna_rx *rx,
325 struct bfi_msgq_mhdr *msghdr);
326 void bna_bfi_rxf_cfg_rsp(struct bna_rxf *rxf, struct bfi_msgq_mhdr *msghdr);
327 void bna_bfi_rxf_mcast_add_rsp(struct bna_rxf *rxf,
328 struct bfi_msgq_mhdr *msghdr);
329 void bna_bfi_rxf_ucast_set_rsp(struct bna_rxf *rxf,
330 struct bfi_msgq_mhdr *msghdr);
331
332
333 void bna_rx_mod_init(struct bna_rx_mod *rx_mod, struct bna *bna,
334 struct bna_res_info *res_info);
335 void bna_rx_mod_uninit(struct bna_rx_mod *rx_mod);
336
337
338 void bna_rx_mod_start(struct bna_rx_mod *rx_mod, enum bna_rx_type type);
339 void bna_rx_mod_stop(struct bna_rx_mod *rx_mod, enum bna_rx_type type);
340 void bna_rx_mod_fail(struct bna_rx_mod *rx_mod);
341
342
343 void bna_rx_res_req(struct bna_rx_config *rx_config,
344 struct bna_res_info *res_info);
345 struct bna_rx *bna_rx_create(struct bna *bna, struct bnad *bnad,
346 struct bna_rx_config *rx_cfg,
347 const struct bna_rx_event_cbfn *rx_cbfn,
348 struct bna_res_info *res_info, void *priv);
349 void bna_rx_destroy(struct bna_rx *rx);
350 void bna_rx_enable(struct bna_rx *rx);
351 void bna_rx_disable(struct bna_rx *rx, enum bna_cleanup_type type,
352 void (*cbfn)(void *, struct bna_rx *));
353 void bna_rx_cleanup_complete(struct bna_rx *rx);
354 void bna_rx_coalescing_timeo_set(struct bna_rx *rx, int coalescing_timeo);
355 void bna_rx_dim_reconfig(struct bna *bna, const u32 vector[][BNA_BIAS_T_MAX]);
356 void bna_rx_dim_update(struct bna_ccb *ccb);
357 enum bna_cb_status bna_rx_ucast_set(struct bna_rx *rx, const u8 *ucmac);
358 enum bna_cb_status bna_rx_ucast_listset(struct bna_rx *rx, int count,
359 const u8 *uclist);
360 enum bna_cb_status bna_rx_mcast_add(struct bna_rx *rx, const u8 *mcmac,
361 void (*cbfn)(struct bnad *,
362 struct bna_rx *));
363 enum bna_cb_status bna_rx_mcast_listset(struct bna_rx *rx, int count,
364 const u8 *mcmac);
365 void
366 bna_rx_mcast_delall(struct bna_rx *rx);
367 enum bna_cb_status
368 bna_rx_mode_set(struct bna_rx *rx, enum bna_rxmode rxmode,
369 enum bna_rxmode bitmask);
370 void bna_rx_vlan_add(struct bna_rx *rx, int vlan_id);
371 void bna_rx_vlan_del(struct bna_rx *rx, int vlan_id);
372 void bna_rx_vlanfilter_enable(struct bna_rx *rx);
373 void bna_rx_vlan_strip_enable(struct bna_rx *rx);
374 void bna_rx_vlan_strip_disable(struct bna_rx *rx);
375
376
377
378 int bna_enet_mtu_get(struct bna_enet *enet);
379
380
381 void bna_enet_cb_tx_stopped(struct bna_enet *enet);
382 void bna_enet_cb_rx_stopped(struct bna_enet *enet);
383
384
385 void bna_enet_enable(struct bna_enet *enet);
386 void bna_enet_disable(struct bna_enet *enet, enum bna_cleanup_type type,
387 void (*cbfn)(void *));
388 void bna_enet_pause_config(struct bna_enet *enet,
389 struct bna_pause_config *pause_config);
390 void bna_enet_mtu_set(struct bna_enet *enet, int mtu,
391 void (*cbfn)(struct bnad *));
392 void bna_enet_perm_mac_get(struct bna_enet *enet, u8 *mac);
393
394
395
396
397 void bna_ioceth_enable(struct bna_ioceth *ioceth);
398 void bna_ioceth_disable(struct bna_ioceth *ioceth,
399 enum bna_cleanup_type type);
400
401
402
403
404 void bnad_cb_ethport_link_status(struct bnad *bnad,
405 enum bna_link_status status);
406
407
408 void bnad_cb_ioceth_ready(struct bnad *bnad);
409 void bnad_cb_ioceth_failed(struct bnad *bnad);
410 void bnad_cb_ioceth_disabled(struct bnad *bnad);
411 void bnad_cb_mbox_intr_enable(struct bnad *bnad);
412 void bnad_cb_mbox_intr_disable(struct bnad *bnad);
413
414
415 void bnad_cb_stats_get(struct bnad *bnad, enum bna_cb_status status,
416 struct bna_stats *stats);
417
418 #endif