linux/drivers/net/ethernet/mellanox/mlx5/core/en/fs.h
<<
>>
Prefs
   1/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
   2/* Copyright (c) 2018 Mellanox Technologies. */
   3
   4#ifndef __MLX5E_FLOW_STEER_H__
   5#define __MLX5E_FLOW_STEER_H__
   6
   7#include "mod_hdr.h"
   8#include "lib/fs_ttc.h"
   9
  10struct mlx5e_post_act;
  11
  12enum {
  13        MLX5E_TC_FT_LEVEL = 0,
  14        MLX5E_TC_TTC_FT_LEVEL,
  15};
  16
  17struct mlx5e_tc_table {
  18        /* Protects the dynamic assignment of the t parameter
  19         * which is the nic tc root table.
  20         */
  21        struct mutex                    t_lock;
  22        struct mlx5_flow_table          *t;
  23        struct mlx5_fs_chains           *chains;
  24        struct mlx5e_post_act           *post_act;
  25
  26        struct rhashtable               ht;
  27
  28        struct mod_hdr_tbl mod_hdr;
  29        struct mutex hairpin_tbl_lock; /* protects hairpin_tbl */
  30        DECLARE_HASHTABLE(hairpin_tbl, 8);
  31
  32        struct notifier_block     netdevice_nb;
  33        struct netdev_net_notifier      netdevice_nn;
  34
  35        struct mlx5_tc_ct_priv         *ct;
  36        struct mapping_ctx             *mapping;
  37};
  38
  39struct mlx5e_flow_table {
  40        int num_groups;
  41        struct mlx5_flow_table *t;
  42        struct mlx5_flow_group **g;
  43};
  44
  45struct mlx5e_l2_rule {
  46        u8  addr[ETH_ALEN + 2];
  47        struct mlx5_flow_handle *rule;
  48};
  49
  50#define MLX5E_L2_ADDR_HASH_SIZE BIT(BITS_PER_BYTE)
  51
  52struct mlx5e_promisc_table {
  53        struct mlx5e_flow_table ft;
  54        struct mlx5_flow_handle *rule;
  55};
  56
  57/* Forward declaration and APIs to get private fields of vlan_table */
  58struct mlx5e_vlan_table;
  59unsigned long *mlx5e_vlan_get_active_svlans(struct mlx5e_vlan_table *vlan);
  60struct mlx5_flow_table *mlx5e_vlan_get_flowtable(struct mlx5e_vlan_table *vlan);
  61
  62struct mlx5e_l2_table {
  63        struct mlx5e_flow_table    ft;
  64        struct hlist_head          netdev_uc[MLX5E_L2_ADDR_HASH_SIZE];
  65        struct hlist_head          netdev_mc[MLX5E_L2_ADDR_HASH_SIZE];
  66        struct mlx5e_l2_rule       broadcast;
  67        struct mlx5e_l2_rule       allmulti;
  68        struct mlx5_flow_handle    *trap_rule;
  69        bool                       broadcast_enabled;
  70        bool                       allmulti_enabled;
  71        bool                       promisc_enabled;
  72};
  73
  74#define MLX5E_NUM_INDIR_TIRS (MLX5_NUM_TT - 1)
  75
  76#define MLX5_HASH_IP            (MLX5_HASH_FIELD_SEL_SRC_IP   |\
  77                                 MLX5_HASH_FIELD_SEL_DST_IP)
  78#define MLX5_HASH_IP_L4PORTS    (MLX5_HASH_FIELD_SEL_SRC_IP   |\
  79                                 MLX5_HASH_FIELD_SEL_DST_IP   |\
  80                                 MLX5_HASH_FIELD_SEL_L4_SPORT |\
  81                                 MLX5_HASH_FIELD_SEL_L4_DPORT)
  82#define MLX5_HASH_IP_IPSEC_SPI  (MLX5_HASH_FIELD_SEL_SRC_IP   |\
  83                                 MLX5_HASH_FIELD_SEL_DST_IP   |\
  84                                 MLX5_HASH_FIELD_SEL_IPSEC_SPI)
  85
  86/* NIC prio FTS */
  87enum {
  88        MLX5E_PROMISC_FT_LEVEL,
  89        MLX5E_VLAN_FT_LEVEL,
  90        MLX5E_L2_FT_LEVEL,
  91        MLX5E_TTC_FT_LEVEL,
  92        MLX5E_INNER_TTC_FT_LEVEL,
  93        MLX5E_FS_TT_UDP_FT_LEVEL = MLX5E_INNER_TTC_FT_LEVEL + 1,
  94        MLX5E_FS_TT_ANY_FT_LEVEL = MLX5E_INNER_TTC_FT_LEVEL + 1,
  95#ifdef CONFIG_MLX5_EN_TLS
  96        MLX5E_ACCEL_FS_TCP_FT_LEVEL = MLX5E_INNER_TTC_FT_LEVEL + 1,
  97#endif
  98#ifdef CONFIG_MLX5_EN_ARFS
  99        MLX5E_ARFS_FT_LEVEL = MLX5E_INNER_TTC_FT_LEVEL + 1,
 100#endif
 101#ifdef CONFIG_MLX5_EN_IPSEC
 102        MLX5E_ACCEL_FS_ESP_FT_LEVEL = MLX5E_INNER_TTC_FT_LEVEL + 1,
 103        MLX5E_ACCEL_FS_ESP_FT_ERR_LEVEL,
 104#endif
 105};
 106
 107struct mlx5e_priv;
 108
 109#ifdef CONFIG_MLX5_EN_RXNFC
 110
 111struct mlx5e_ethtool_table {
 112        struct mlx5_flow_table *ft;
 113        int                    num_rules;
 114};
 115
 116#define ETHTOOL_NUM_L3_L4_FTS 7
 117#define ETHTOOL_NUM_L2_FTS 4
 118
 119struct mlx5e_ethtool_steering {
 120        struct mlx5e_ethtool_table      l3_l4_ft[ETHTOOL_NUM_L3_L4_FTS];
 121        struct mlx5e_ethtool_table      l2_ft[ETHTOOL_NUM_L2_FTS];
 122        struct list_head                rules;
 123        int                             tot_num_rules;
 124};
 125
 126void mlx5e_ethtool_init_steering(struct mlx5e_priv *priv);
 127void mlx5e_ethtool_cleanup_steering(struct mlx5e_priv *priv);
 128int mlx5e_ethtool_set_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd);
 129int mlx5e_ethtool_get_rxnfc(struct net_device *dev,
 130                            struct ethtool_rxnfc *info, u32 *rule_locs);
 131#else
 132static inline void mlx5e_ethtool_init_steering(struct mlx5e_priv *priv)    { }
 133static inline void mlx5e_ethtool_cleanup_steering(struct mlx5e_priv *priv) { }
 134static inline int mlx5e_ethtool_set_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd)
 135{ return -EOPNOTSUPP; }
 136static inline int mlx5e_ethtool_get_rxnfc(struct net_device *dev,
 137                                          struct ethtool_rxnfc *info, u32 *rule_locs)
 138{ return -EOPNOTSUPP; }
 139#endif /* CONFIG_MLX5_EN_RXNFC */
 140
 141#ifdef CONFIG_MLX5_EN_ARFS
 142struct mlx5e_arfs_tables;
 143
 144int mlx5e_arfs_create_tables(struct mlx5e_priv *priv);
 145void mlx5e_arfs_destroy_tables(struct mlx5e_priv *priv);
 146int mlx5e_arfs_enable(struct mlx5e_priv *priv);
 147int mlx5e_arfs_disable(struct mlx5e_priv *priv);
 148int mlx5e_rx_flow_steer(struct net_device *dev, const struct sk_buff *skb,
 149                        u16 rxq_index, u32 flow_id);
 150#else
 151static inline int mlx5e_arfs_create_tables(struct mlx5e_priv *priv) { return 0; }
 152static inline void mlx5e_arfs_destroy_tables(struct mlx5e_priv *priv) {}
 153static inline int mlx5e_arfs_enable(struct mlx5e_priv *priv) { return -EOPNOTSUPP; }
 154static inline int mlx5e_arfs_disable(struct mlx5e_priv *priv) { return -EOPNOTSUPP; }
 155#endif
 156
 157#ifdef CONFIG_MLX5_EN_TLS
 158struct mlx5e_accel_fs_tcp;
 159#endif
 160
 161struct mlx5e_fs_udp;
 162struct mlx5e_fs_any;
 163struct mlx5e_ptp_fs;
 164
 165struct mlx5e_flow_steering {
 166        struct mlx5_flow_namespace      *ns;
 167        struct mlx5_flow_namespace      *egress_ns;
 168#ifdef CONFIG_MLX5_EN_RXNFC
 169        struct mlx5e_ethtool_steering   ethtool;
 170#endif
 171        struct mlx5e_tc_table           tc;
 172        struct mlx5e_promisc_table      promisc;
 173        struct mlx5e_vlan_table         *vlan;
 174        struct mlx5e_l2_table           l2;
 175        struct mlx5_ttc_table           *ttc;
 176        struct mlx5_ttc_table           *inner_ttc;
 177#ifdef CONFIG_MLX5_EN_ARFS
 178        struct mlx5e_arfs_tables       *arfs;
 179#endif
 180#ifdef CONFIG_MLX5_EN_TLS
 181        struct mlx5e_accel_fs_tcp      *accel_tcp;
 182#endif
 183        struct mlx5e_fs_udp            *udp;
 184        struct mlx5e_fs_any            *any;
 185        struct mlx5e_ptp_fs            *ptp_fs;
 186};
 187
 188void mlx5e_set_ttc_params(struct mlx5e_priv *priv,
 189                          struct ttc_params *ttc_params, bool tunnel);
 190
 191void mlx5e_destroy_ttc_table(struct mlx5e_priv *priv);
 192int mlx5e_create_ttc_table(struct mlx5e_priv *priv);
 193
 194void mlx5e_destroy_flow_table(struct mlx5e_flow_table *ft);
 195
 196void mlx5e_enable_cvlan_filter(struct mlx5e_priv *priv);
 197void mlx5e_disable_cvlan_filter(struct mlx5e_priv *priv);
 198
 199int mlx5e_create_flow_steering(struct mlx5e_priv *priv);
 200void mlx5e_destroy_flow_steering(struct mlx5e_priv *priv);
 201
 202int mlx5e_fs_init(struct mlx5e_priv *priv);
 203void mlx5e_fs_cleanup(struct mlx5e_priv *priv);
 204
 205int mlx5e_add_vlan_trap(struct mlx5e_priv *priv, int  trap_id, int tir_num);
 206void mlx5e_remove_vlan_trap(struct mlx5e_priv *priv);
 207int mlx5e_add_mac_trap(struct mlx5e_priv *priv, int  trap_id, int tir_num);
 208void mlx5e_remove_mac_trap(struct mlx5e_priv *priv);
 209
 210#endif /* __MLX5E_FLOW_STEER_H__ */
 211
 212