1
2
3
4
5
6
7#ifndef HFI1_NETDEV_H
8#define HFI1_NETDEV_H
9
10#include "hfi.h"
11
12#include <linux/netdevice.h>
13#include <linux/xarray.h>
14
15
16
17
18
19
20
21
22struct hfi1_netdev_rxq {
23 struct napi_struct napi;
24 struct hfi1_netdev_rx *rx;
25 struct hfi1_ctxtdata *rcd;
26};
27
28
29
30
31
32#define HFI1_MAX_NETDEV_CTXTS 8
33
34
35#define NUM_NETDEV_MAP_ENTRIES HFI1_MAX_NETDEV_CTXTS
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51struct hfi1_netdev_rx {
52 struct net_device rx_napi;
53 struct hfi1_devdata *dd;
54 struct hfi1_netdev_rxq *rxq;
55 int num_rx_q;
56 int rmt_start;
57 struct xarray dev_tbl;
58
59 atomic_t enabled;
60
61 atomic_t netdevs;
62};
63
64static inline
65int hfi1_netdev_ctxt_count(struct hfi1_devdata *dd)
66{
67 return dd->netdev_rx->num_rx_q;
68}
69
70static inline
71struct hfi1_ctxtdata *hfi1_netdev_get_ctxt(struct hfi1_devdata *dd, int ctxt)
72{
73 return dd->netdev_rx->rxq[ctxt].rcd;
74}
75
76static inline
77int hfi1_netdev_get_free_rmt_idx(struct hfi1_devdata *dd)
78{
79 return dd->netdev_rx->rmt_start;
80}
81
82static inline
83void hfi1_netdev_set_free_rmt_idx(struct hfi1_devdata *dd, int rmt_idx)
84{
85 dd->netdev_rx->rmt_start = rmt_idx;
86}
87
88u32 hfi1_num_netdev_contexts(struct hfi1_devdata *dd, u32 available_contexts,
89 struct cpumask *cpu_mask);
90
91void hfi1_netdev_enable_queues(struct hfi1_devdata *dd);
92void hfi1_netdev_disable_queues(struct hfi1_devdata *dd);
93int hfi1_netdev_rx_init(struct hfi1_devdata *dd);
94int hfi1_netdev_rx_destroy(struct hfi1_devdata *dd);
95int hfi1_alloc_rx(struct hfi1_devdata *dd);
96void hfi1_free_rx(struct hfi1_devdata *dd);
97int hfi1_netdev_add_data(struct hfi1_devdata *dd, int id, void *data);
98void *hfi1_netdev_remove_data(struct hfi1_devdata *dd, int id);
99void *hfi1_netdev_get_data(struct hfi1_devdata *dd, int id);
100void *hfi1_netdev_get_first_data(struct hfi1_devdata *dd, int *start_id);
101
102
103int hfi1_netdev_rx_napi(struct napi_struct *napi, int budget);
104
105#endif
106