0001
0002
0003
0004
0005
0006
0007 #ifndef HFI1_NETDEV_H
0008 #define HFI1_NETDEV_H
0009
0010 #include "hfi.h"
0011
0012 #include <linux/netdevice.h>
0013 #include <linux/xarray.h>
0014
0015
0016
0017
0018
0019
0020
0021
0022 struct hfi1_netdev_rxq {
0023 struct napi_struct napi;
0024 struct hfi1_netdev_rx *rx;
0025 struct hfi1_ctxtdata *rcd;
0026 };
0027
0028
0029
0030
0031
0032 #define HFI1_MAX_NETDEV_CTXTS 8
0033
0034
0035 #define NUM_NETDEV_MAP_ENTRIES HFI1_MAX_NETDEV_CTXTS
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051 struct hfi1_netdev_rx {
0052 struct net_device rx_napi;
0053 struct hfi1_devdata *dd;
0054 struct hfi1_netdev_rxq *rxq;
0055 int num_rx_q;
0056 int rmt_start;
0057 struct xarray dev_tbl;
0058
0059 atomic_t enabled;
0060
0061 atomic_t netdevs;
0062 };
0063
0064 static inline
0065 int hfi1_netdev_ctxt_count(struct hfi1_devdata *dd)
0066 {
0067 return dd->netdev_rx->num_rx_q;
0068 }
0069
0070 static inline
0071 struct hfi1_ctxtdata *hfi1_netdev_get_ctxt(struct hfi1_devdata *dd, int ctxt)
0072 {
0073 return dd->netdev_rx->rxq[ctxt].rcd;
0074 }
0075
0076 static inline
0077 int hfi1_netdev_get_free_rmt_idx(struct hfi1_devdata *dd)
0078 {
0079 return dd->netdev_rx->rmt_start;
0080 }
0081
0082 static inline
0083 void hfi1_netdev_set_free_rmt_idx(struct hfi1_devdata *dd, int rmt_idx)
0084 {
0085 dd->netdev_rx->rmt_start = rmt_idx;
0086 }
0087
0088 u32 hfi1_num_netdev_contexts(struct hfi1_devdata *dd, u32 available_contexts,
0089 struct cpumask *cpu_mask);
0090
0091 void hfi1_netdev_enable_queues(struct hfi1_devdata *dd);
0092 void hfi1_netdev_disable_queues(struct hfi1_devdata *dd);
0093 int hfi1_netdev_rx_init(struct hfi1_devdata *dd);
0094 int hfi1_netdev_rx_destroy(struct hfi1_devdata *dd);
0095 int hfi1_alloc_rx(struct hfi1_devdata *dd);
0096 void hfi1_free_rx(struct hfi1_devdata *dd);
0097 int hfi1_netdev_add_data(struct hfi1_devdata *dd, int id, void *data);
0098 void *hfi1_netdev_remove_data(struct hfi1_devdata *dd, int id);
0099 void *hfi1_netdev_get_data(struct hfi1_devdata *dd, int id);
0100 void *hfi1_netdev_get_first_data(struct hfi1_devdata *dd, int *start_id);
0101
0102
0103 int hfi1_netdev_rx_napi(struct napi_struct *napi, int budget);
0104
0105 #endif