0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033 #ifndef __MLX5E_REP_H__
0034 #define __MLX5E_REP_H__
0035
0036 #include <net/ip_tunnels.h>
0037 #include <linux/rhashtable.h>
0038 #include <linux/mutex.h>
0039 #include "eswitch.h"
0040 #include "en.h"
0041 #include "lib/port_tun.h"
0042
0043 #ifdef CONFIG_MLX5_ESWITCH
0044 extern const struct mlx5e_rx_handlers mlx5e_rx_handlers_rep;
0045
0046 struct mlx5e_neigh_update_table {
0047 struct rhashtable neigh_ht;
0048
0049
0050
0051
0052 struct list_head neigh_list;
0053
0054 struct mutex encap_lock;
0055 struct notifier_block netevent_nb;
0056 struct delayed_work neigh_stats_work;
0057 unsigned long min_interval;
0058 };
0059
0060 struct mlx5_tc_ct_priv;
0061 struct mlx5_tc_int_port_priv;
0062 struct mlx5e_rep_bond;
0063 struct mlx5e_tc_tun_encap;
0064 struct mlx5e_post_act;
0065 struct mlx5e_flow_meters;
0066
0067 struct mlx5_rep_uplink_priv {
0068
0069
0070
0071
0072
0073
0074
0075 struct list_head tc_indr_block_priv_list;
0076
0077 struct mlx5_tun_entropy tun_entropy;
0078
0079
0080 struct mutex unready_flows_lock;
0081 struct list_head unready_flows;
0082 struct work_struct reoffload_flows_work;
0083
0084
0085 struct mapping_ctx *tunnel_mapping;
0086
0087 struct mapping_ctx *tunnel_enc_opts_mapping;
0088
0089 struct mlx5e_post_act *post_act;
0090 struct mlx5_tc_ct_priv *ct_priv;
0091 struct mlx5e_tc_psample *tc_psample;
0092
0093
0094 struct mlx5e_rep_bond *bond;
0095
0096
0097 struct mlx5e_tc_tun_encap *encap;
0098
0099
0100 struct mlx5e_tc_int_port_priv *int_port_priv;
0101
0102 struct mlx5e_flow_meters *flow_meters;
0103 };
0104
0105 struct mlx5e_rep_priv {
0106 struct mlx5_eswitch_rep *rep;
0107 struct mlx5e_neigh_update_table neigh_update;
0108 struct net_device *netdev;
0109 struct mlx5_flow_table *root_ft;
0110 struct mlx5_flow_handle *vport_rx_rule;
0111 struct list_head vport_sqs_list;
0112 struct mlx5_rep_uplink_priv uplink_priv;
0113 struct rtnl_link_stats64 prev_vf_vport_stats;
0114 struct rhashtable tc_ht;
0115 };
0116
0117 static inline
0118 struct mlx5e_rep_priv *mlx5e_rep_to_rep_priv(struct mlx5_eswitch_rep *rep)
0119 {
0120 return rep->rep_data[REP_ETH].priv;
0121 }
0122
0123 struct mlx5e_neigh {
0124 union {
0125 __be32 v4;
0126 struct in6_addr v6;
0127 } dst_ip;
0128 int family;
0129 };
0130
0131 struct mlx5e_neigh_hash_entry {
0132 struct rhash_head rhash_node;
0133 struct mlx5e_neigh m_neigh;
0134 struct mlx5e_priv *priv;
0135 struct net_device *neigh_dev;
0136
0137
0138
0139
0140
0141 struct list_head neigh_list;
0142
0143
0144 spinlock_t encap_list_lock;
0145
0146 struct list_head encap_list;
0147
0148
0149
0150
0151
0152 refcount_t refcnt;
0153
0154
0155
0156
0157
0158 unsigned long reported_lastuse;
0159
0160 struct rcu_head rcu;
0161 };
0162
0163 enum {
0164
0165 MLX5_ENCAP_ENTRY_VALID = BIT(0),
0166 MLX5_REFORMAT_DECAP = BIT(1),
0167 MLX5_ENCAP_ENTRY_NO_ROUTE = BIT(2),
0168 };
0169
0170 struct mlx5e_decap_key {
0171 struct ethhdr key;
0172 };
0173
0174 struct mlx5e_decap_entry {
0175 struct mlx5e_decap_key key;
0176 struct list_head flows;
0177 struct hlist_node hlist;
0178 refcount_t refcnt;
0179 struct completion res_ready;
0180 int compl_result;
0181 struct mlx5_pkt_reformat *pkt_reformat;
0182 struct rcu_head rcu;
0183 };
0184
0185 struct mlx5e_mpls_info {
0186 u32 label;
0187 u8 tc;
0188 u8 bos;
0189 u8 ttl;
0190 };
0191
0192 struct mlx5e_encap_entry {
0193
0194 struct mlx5e_neigh_hash_entry *nhe;
0195
0196 struct list_head encap_list;
0197
0198
0199
0200 struct hlist_node encap_hlist;
0201 struct list_head flows;
0202 struct list_head route_list;
0203 struct mlx5_pkt_reformat *pkt_reformat;
0204 const struct ip_tunnel_info *tun_info;
0205 struct mlx5e_mpls_info mpls_info;
0206 unsigned char h_dest[ETH_ALEN];
0207
0208 struct net_device *out_dev;
0209 int route_dev_ifindex;
0210 struct mlx5e_tc_tunnel *tunnel;
0211 int reformat_type;
0212 u8 flags;
0213 char *encap_header;
0214 int encap_size;
0215 refcount_t refcnt;
0216 struct completion res_ready;
0217 int compl_result;
0218 struct rcu_head rcu;
0219 };
0220
0221 struct mlx5e_rep_sq {
0222 struct mlx5_flow_handle *send_to_vport_rule;
0223 struct mlx5_flow_handle *send_to_vport_rule_peer;
0224 u32 sqn;
0225 struct list_head list;
0226 };
0227
0228 int mlx5e_rep_init(void);
0229 void mlx5e_rep_cleanup(void);
0230 int mlx5e_rep_bond_init(struct mlx5e_rep_priv *rpriv);
0231 void mlx5e_rep_bond_cleanup(struct mlx5e_rep_priv *rpriv);
0232 int mlx5e_rep_bond_enslave(struct mlx5_eswitch *esw, struct net_device *netdev,
0233 struct net_device *lag_dev);
0234 void mlx5e_rep_bond_unslave(struct mlx5_eswitch *esw,
0235 const struct net_device *netdev,
0236 const struct net_device *lag_dev);
0237 int mlx5e_rep_bond_update(struct mlx5e_priv *priv, bool cleanup);
0238
0239 bool mlx5e_rep_has_offload_stats(const struct net_device *dev, int attr_id);
0240 int mlx5e_rep_get_offload_stats(int attr_id, const struct net_device *dev,
0241 void *sp);
0242
0243 bool mlx5e_is_uplink_rep(struct mlx5e_priv *priv);
0244 int mlx5e_add_sqs_fwd_rules(struct mlx5e_priv *priv);
0245 void mlx5e_remove_sqs_fwd_rules(struct mlx5e_priv *priv);
0246
0247 void mlx5e_rep_queue_neigh_stats_work(struct mlx5e_priv *priv);
0248
0249 bool mlx5e_eswitch_vf_rep(const struct net_device *netdev);
0250 bool mlx5e_eswitch_uplink_rep(const struct net_device *netdev);
0251 static inline bool mlx5e_eswitch_rep(const struct net_device *netdev)
0252 {
0253 return mlx5e_eswitch_vf_rep(netdev) ||
0254 mlx5e_eswitch_uplink_rep(netdev);
0255 }
0256
0257 #else
0258 static inline bool mlx5e_is_uplink_rep(struct mlx5e_priv *priv) { return false; }
0259 static inline int mlx5e_add_sqs_fwd_rules(struct mlx5e_priv *priv) { return 0; }
0260 static inline void mlx5e_remove_sqs_fwd_rules(struct mlx5e_priv *priv) {}
0261 static inline int mlx5e_rep_init(void) { return 0; };
0262 static inline void mlx5e_rep_cleanup(void) {};
0263 static inline bool mlx5e_rep_has_offload_stats(const struct net_device *dev,
0264 int attr_id) { return false; }
0265 static inline int mlx5e_rep_get_offload_stats(int attr_id,
0266 const struct net_device *dev,
0267 void *sp) { return -EOPNOTSUPP; }
0268 #endif
0269
0270 static inline bool mlx5e_is_vport_rep(struct mlx5e_priv *priv)
0271 {
0272 return (MLX5_ESWITCH_MANAGER(priv->mdev) && priv->ppriv);
0273 }
0274 #endif