0001
0002
0003
0004 #ifndef NFP_NET_REPR_H
0005 #define NFP_NET_REPR_H
0006
0007 struct metadata_dst;
0008 struct nfp_app;
0009 struct nfp_net;
0010 struct nfp_port;
0011
0012 #include <net/dst_metadata.h>
0013
0014
0015
0016
0017
0018
0019 struct nfp_reprs {
0020 unsigned int num_reprs;
0021 struct net_device __rcu *reprs[];
0022 };
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033 struct nfp_repr_pcpu_stats {
0034 u64 rx_packets;
0035 u64 rx_bytes;
0036 u64 tx_packets;
0037 u64 tx_bytes;
0038 u64 tx_drops;
0039 struct u64_stats_sync syncp;
0040 };
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051 struct nfp_repr {
0052 struct net_device *netdev;
0053 struct metadata_dst *dst;
0054 struct nfp_port *port;
0055 struct nfp_app *app;
0056 struct nfp_repr_pcpu_stats __percpu *stats;
0057 void *app_priv;
0058 };
0059
0060
0061
0062
0063
0064
0065
0066
0067 enum nfp_repr_type {
0068 NFP_REPR_TYPE_PHYS_PORT,
0069 NFP_REPR_TYPE_PF,
0070 NFP_REPR_TYPE_VF,
0071
0072 __NFP_REPR_TYPE_MAX,
0073 };
0074 #define NFP_REPR_TYPE_MAX (__NFP_REPR_TYPE_MAX - 1)
0075
0076 extern const struct net_device_ops nfp_repr_netdev_ops;
0077
0078 static inline bool nfp_netdev_is_nfp_repr(struct net_device *netdev)
0079 {
0080 return netdev->netdev_ops == &nfp_repr_netdev_ops;
0081 }
0082
0083 static inline int nfp_repr_get_port_id(struct net_device *netdev)
0084 {
0085 struct nfp_repr *priv = netdev_priv(netdev);
0086
0087 return priv->dst->u.port_info.port_id;
0088 }
0089
0090 struct net_device *
0091 nfp_repr_get_locked(struct nfp_app *app, struct nfp_reprs *set,
0092 unsigned int id);
0093
0094 void nfp_repr_inc_rx_stats(struct net_device *netdev, unsigned int len);
0095 void
0096 nfp_repr_transfer_features(struct net_device *netdev, struct net_device *lower);
0097 int nfp_repr_init(struct nfp_app *app, struct net_device *netdev,
0098 u32 cmsg_port_id, struct nfp_port *port,
0099 struct net_device *pf_netdev);
0100 void nfp_repr_free(struct net_device *netdev);
0101 struct net_device *
0102 nfp_repr_alloc_mqs(struct nfp_app *app, unsigned int txqs, unsigned int rxqs);
0103 void nfp_repr_clean_and_free(struct nfp_repr *repr);
0104 void nfp_reprs_clean_and_free(struct nfp_app *app, struct nfp_reprs *reprs);
0105 void nfp_reprs_clean_and_free_by_type(struct nfp_app *app,
0106 enum nfp_repr_type type);
0107 struct nfp_reprs *nfp_reprs_alloc(unsigned int num_reprs);
0108 int nfp_reprs_resync_phys_ports(struct nfp_app *app);
0109
0110 static inline struct net_device *nfp_repr_alloc(struct nfp_app *app)
0111 {
0112 return nfp_repr_alloc_mqs(app, 1, 1);
0113 }
0114 #endif