1 /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
2 /* Copyright (C) 2017-2018 Netronome Systems, Inc. */
12 #include <net/dst_metadata.h>
15 * struct nfp_reprs - container for representor netdevs
16 * @num_reprs: Number of elements in reprs array
17 * @reprs: Array of representor netdevs
20 unsigned int num_reprs
;
21 struct net_device __rcu
*reprs
[];
25 * struct nfp_repr_pcpu_stats
26 * @rx_packets: Received packets
27 * @rx_bytes: Received bytes
28 * @tx_packets: Transmitted packets
29 * @tx_bytes: Transmitted dropped
30 * @tx_drops: Packets dropped on transmit
31 * @syncp: Reference count
33 struct nfp_repr_pcpu_stats
{
39 struct u64_stats_sync syncp
;
43 * struct nfp_repr - priv data for representor netdevs
44 * @netdev: Back pointer to netdev
45 * @dst: Destination for packet TX
46 * @port: Port of representor
48 * @stats: Statistic of packets hitting CPU
49 * @app_priv: Pointer for APP data
52 struct net_device
*netdev
;
53 struct metadata_dst
*dst
;
54 struct nfp_port
*port
;
56 struct nfp_repr_pcpu_stats __percpu
*stats
;
61 * enum nfp_repr_type - type of representor
62 * @NFP_REPR_TYPE_PHYS_PORT: external NIC port
63 * @NFP_REPR_TYPE_PF: physical function
64 * @NFP_REPR_TYPE_VF: virtual function
65 * @__NFP_REPR_TYPE_MAX: number of representor types
68 NFP_REPR_TYPE_PHYS_PORT
,
74 #define NFP_REPR_TYPE_MAX (__NFP_REPR_TYPE_MAX - 1)
76 extern const struct net_device_ops nfp_repr_netdev_ops
;
78 static inline bool nfp_netdev_is_nfp_repr(struct net_device
*netdev
)
80 return netdev
->netdev_ops
== &nfp_repr_netdev_ops
;
83 static inline int nfp_repr_get_port_id(struct net_device
*netdev
)
85 struct nfp_repr
*priv
= netdev_priv(netdev
);
87 return priv
->dst
->u
.port_info
.port_id
;
91 nfp_repr_get_locked(struct nfp_app
*app
, struct nfp_reprs
*set
,
94 void nfp_repr_inc_rx_stats(struct net_device
*netdev
, unsigned int len
);
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
);
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
);
110 static inline struct net_device
*nfp_repr_alloc(struct nfp_app
*app
)
112 return nfp_repr_alloc_mqs(app
, 1, 1);
114 #endif /* NFP_NET_REPR_H */