net/mlx5e: Add support to get ethtool flow rules
[cascardo/linux.git] / drivers / net / ethernet / mellanox / mlx5 / core / en.h
index da885c0..1365cdc 100644 (file)
@@ -44,6 +44,7 @@
 #include <linux/mlx5/vport.h>
 #include <linux/mlx5/transobj.h>
 #include <linux/rhashtable.h>
+#include <net/switchdev.h>
 #include "wq.h"
 #include "mlx5_core.h"
 #include "en_stats.h"
@@ -453,7 +454,7 @@ enum mlx5e_traffic_types {
 };
 
 enum {
-       MLX5E_STATE_ASYNC_EVENTS_ENABLE,
+       MLX5E_STATE_ASYNC_EVENTS_ENABLED,
        MLX5E_STATE_OPENED,
        MLX5E_STATE_DESTROYING,
 };
@@ -543,8 +544,24 @@ enum {
        MLX5E_ARFS_FT_LEVEL
 };
 
+struct mlx5e_ethtool_table {
+       struct mlx5_flow_table *ft;
+       int                    num_rules;
+};
+
+#define ETHTOOL_NUM_L3_L4_FTS 7
+#define ETHTOOL_NUM_L2_FTS 4
+
+struct mlx5e_ethtool_steering {
+       struct mlx5e_ethtool_table      l3_l4_ft[ETHTOOL_NUM_L3_L4_FTS];
+       struct mlx5e_ethtool_table      l2_ft[ETHTOOL_NUM_L2_FTS];
+       struct list_head                rules;
+       int                             tot_num_rules;
+};
+
 struct mlx5e_flow_steering {
        struct mlx5_flow_namespace      *ns;
+       struct mlx5e_ethtool_steering   ethtool;
        struct mlx5e_tc_table           tc;
        struct mlx5e_vlan_table         vlan;
        struct mlx5e_l2_table           l2;
@@ -552,9 +569,15 @@ struct mlx5e_flow_steering {
        struct mlx5e_arfs_tables        arfs;
 };
 
-struct mlx5e_direct_tir {
-       u32              tirn;
+struct mlx5e_rqt {
        u32              rqtn;
+       bool             enabled;
+};
+
+struct mlx5e_tir {
+       u32               tirn;
+       struct mlx5e_rqt  rqt;
+       struct list_head  list;
 };
 
 enum {
@@ -562,6 +585,22 @@ enum {
        MLX5E_NIC_PRIO
 };
 
+struct mlx5e_profile {
+       void    (*init)(struct mlx5_core_dev *mdev,
+                       struct net_device *netdev,
+                       const struct mlx5e_profile *profile, void *ppriv);
+       void    (*cleanup)(struct mlx5e_priv *priv);
+       int     (*init_rx)(struct mlx5e_priv *priv);
+       void    (*cleanup_rx)(struct mlx5e_priv *priv);
+       int     (*init_tx)(struct mlx5e_priv *priv);
+       void    (*cleanup_tx)(struct mlx5e_priv *priv);
+       void    (*enable)(struct mlx5e_priv *priv);
+       void    (*disable)(struct mlx5e_priv *priv);
+       void    (*update_stats)(struct mlx5e_priv *priv);
+       int     (*max_nch)(struct mlx5_core_dev *mdev);
+       int     max_tc;
+};
+
 struct mlx5e_priv {
        /* priv data path fields - start */
        struct mlx5e_sq            **txq_to_sq_map;
@@ -570,18 +609,14 @@ struct mlx5e_priv {
 
        unsigned long              state;
        struct mutex               state_lock; /* Protects Interface state */
-       struct mlx5_uar            cq_uar;
-       u32                        pdn;
-       u32                        tdn;
-       struct mlx5_core_mkey      mkey;
        struct mlx5_core_mkey      umr_mkey;
        struct mlx5e_rq            drop_rq;
 
        struct mlx5e_channel     **channel;
        u32                        tisn[MLX5E_MAX_NUM_TC];
-       u32                        indir_rqtn;
-       u32                        indir_tirn[MLX5E_NUM_INDIR_TIRS];
-       struct mlx5e_direct_tir    direct_tir[MLX5E_MAX_NUM_CHANNELS];
+       struct mlx5e_rqt           indir_rqt;
+       struct mlx5e_tir           indir_tir[MLX5E_NUM_INDIR_TIRS];
+       struct mlx5e_tir           direct_tir[MLX5E_MAX_NUM_CHANNELS];
        u32                        tx_rates[MLX5E_MAX_NUM_SQS];
 
        struct mlx5e_flow_steering fs;
@@ -599,6 +634,8 @@ struct mlx5e_priv {
        struct mlx5e_stats         stats;
        struct mlx5e_tstamp        tstamp;
        u16 q_counter;
+       const struct mlx5e_profile *profile;
+       void                      *ppriv;
 };
 
 enum mlx5e_link_mode {
@@ -680,6 +717,16 @@ int mlx5e_create_flow_steering(struct mlx5e_priv *priv);
 void mlx5e_destroy_flow_steering(struct mlx5e_priv *priv);
 void mlx5e_init_l2_addr(struct mlx5e_priv *priv);
 void mlx5e_destroy_flow_table(struct mlx5e_flow_table *ft);
+int mlx5e_ethtool_get_flow(struct mlx5e_priv *priv, struct ethtool_rxnfc *info,
+                          int location);
+int mlx5e_ethtool_get_all_flows(struct mlx5e_priv *priv,
+                               struct ethtool_rxnfc *info, u32 *rule_locs);
+int mlx5e_ethtool_flow_replace(struct mlx5e_priv *priv,
+                              struct ethtool_rx_flow_spec *fs);
+int mlx5e_ethtool_flow_remove(struct mlx5e_priv *priv,
+                             int location);
+void mlx5e_ethtool_init_steering(struct mlx5e_priv *priv);
+void mlx5e_ethtool_cleanup_steering(struct mlx5e_priv *priv);
 void mlx5e_set_rx_mode_work(struct work_struct *work);
 
 void mlx5e_fill_hwstamp(struct mlx5e_tstamp *clock, u64 timestamp,
@@ -788,5 +835,39 @@ int mlx5e_rx_flow_steer(struct net_device *dev, const struct sk_buff *skb,
 #endif
 
 u16 mlx5e_get_max_inline_cap(struct mlx5_core_dev *mdev);
+int mlx5e_create_tir(struct mlx5_core_dev *mdev,
+                    struct mlx5e_tir *tir, u32 *in, int inlen);
+void mlx5e_destroy_tir(struct mlx5_core_dev *mdev,
+                      struct mlx5e_tir *tir);
+int mlx5e_create_mdev_resources(struct mlx5_core_dev *mdev);
+void mlx5e_destroy_mdev_resources(struct mlx5_core_dev *mdev);
+int mlx5e_refresh_tirs_self_loopback_enable(struct mlx5_core_dev *mdev);
+
+struct mlx5_eswitch_rep;
+int mlx5e_vport_rep_load(struct mlx5_eswitch *esw,
+                        struct mlx5_eswitch_rep *rep);
+void mlx5e_vport_rep_unload(struct mlx5_eswitch *esw,
+                           struct mlx5_eswitch_rep *rep);
+int mlx5e_nic_rep_load(struct mlx5_eswitch *esw, struct mlx5_eswitch_rep *rep);
+void mlx5e_nic_rep_unload(struct mlx5_eswitch *esw,
+                         struct mlx5_eswitch_rep *rep);
+int mlx5e_add_sqs_fwd_rules(struct mlx5e_priv *priv);
+void mlx5e_remove_sqs_fwd_rules(struct mlx5e_priv *priv);
+int mlx5e_attr_get(struct net_device *dev, struct switchdev_attr *attr);
+
+int mlx5e_create_direct_rqts(struct mlx5e_priv *priv);
+void mlx5e_destroy_rqt(struct mlx5e_priv *priv, struct mlx5e_rqt *rqt);
+int mlx5e_create_direct_tirs(struct mlx5e_priv *priv);
+void mlx5e_destroy_direct_tirs(struct mlx5e_priv *priv);
+int mlx5e_create_tises(struct mlx5e_priv *priv);
+void mlx5e_cleanup_nic_tx(struct mlx5e_priv *priv);
+int mlx5e_close(struct net_device *netdev);
+int mlx5e_open(struct net_device *netdev);
+void mlx5e_update_stats_work(struct work_struct *work);
+void *mlx5e_create_netdev(struct mlx5_core_dev *mdev,
+                         const struct mlx5e_profile *profile, void *ppriv);
+void mlx5e_destroy_netdev(struct mlx5_core_dev *mdev, struct mlx5e_priv *priv);
+struct rtnl_link_stats64 *
+mlx5e_get_stats(struct net_device *dev, struct rtnl_link_stats64 *stats);
 
 #endif /* __MLX5_EN_H__ */