This source file includes following definitions.
- nfp_netdev_is_nfp_repr
- nfp_repr_get_port_id
- nfp_repr_alloc
1
2
3
4 #ifndef NFP_NET_REPR_H
5 #define NFP_NET_REPR_H
6
7 struct metadata_dst;
8 struct nfp_app;
9 struct nfp_net;
10 struct nfp_port;
11
12 #include <net/dst_metadata.h>
13
14
15
16
17
18
19 struct nfp_reprs {
20 unsigned int num_reprs;
21 struct net_device __rcu *reprs[0];
22 };
23
24
25
26
27
28
29
30
31
32
33 struct nfp_repr_pcpu_stats {
34 u64 rx_packets;
35 u64 rx_bytes;
36 u64 tx_packets;
37 u64 tx_bytes;
38 u64 tx_drops;
39 struct u64_stats_sync syncp;
40 };
41
42
43
44
45
46
47
48
49
50
51 struct nfp_repr {
52 struct net_device *netdev;
53 struct metadata_dst *dst;
54 struct nfp_port *port;
55 struct nfp_app *app;
56 struct nfp_repr_pcpu_stats __percpu *stats;
57 void *app_priv;
58 };
59
60
61
62
63
64
65
66
67 enum nfp_repr_type {
68 NFP_REPR_TYPE_PHYS_PORT,
69 NFP_REPR_TYPE_PF,
70 NFP_REPR_TYPE_VF,
71
72 __NFP_REPR_TYPE_MAX,
73 };
74 #define NFP_REPR_TYPE_MAX (__NFP_REPR_TYPE_MAX - 1)
75
76 extern const struct net_device_ops nfp_repr_netdev_ops;
77
78 static inline bool nfp_netdev_is_nfp_repr(struct net_device *netdev)
79 {
80 return netdev->netdev_ops == &nfp_repr_netdev_ops;
81 }
82
83 static inline int nfp_repr_get_port_id(struct net_device *netdev)
84 {
85 struct nfp_repr *priv = netdev_priv(netdev);
86
87 return priv->dst->u.port_info.port_id;
88 }
89
90 struct net_device *
91 nfp_repr_get_locked(struct nfp_app *app, struct nfp_reprs *set,
92 unsigned int id);
93
94 void nfp_repr_inc_rx_stats(struct net_device *netdev, unsigned int len);
95 void
96 nfp_repr_transfer_features(struct net_device *netdev, struct net_device *lower);
97 int nfp_repr_init(struct nfp_app *app, struct net_device *netdev,
98 u32 cmsg_port_id, struct nfp_port *port,
99 struct net_device *pf_netdev);
100 void nfp_repr_free(struct net_device *netdev);
101 struct net_device *
102 nfp_repr_alloc_mqs(struct nfp_app *app, unsigned int txqs, unsigned int rxqs);
103 void nfp_repr_clean_and_free(struct nfp_repr *repr);
104 void nfp_reprs_clean_and_free(struct nfp_app *app, struct nfp_reprs *reprs);
105 void nfp_reprs_clean_and_free_by_type(struct nfp_app *app,
106 enum nfp_repr_type type);
107 struct nfp_reprs *nfp_reprs_alloc(unsigned int num_reprs);
108 int nfp_reprs_resync_phys_ports(struct nfp_app *app);
109
110 static inline struct net_device *nfp_repr_alloc(struct nfp_app *app)
111 {
112 return nfp_repr_alloc_mqs(app, 1, 1);
113 }
114 #endif