net/mlx5_core: Flow counters infrastructure
[cascardo/linux.git] / drivers / net / ethernet / mellanox / mlx5 / core / fs_core.h
index d607e56..aa41a73 100644 (file)
@@ -45,8 +45,10 @@ enum fs_node_type {
 };
 
 enum fs_flow_table_type {
-       FS_FT_NIC_RX     = 0x0,
-       FS_FT_FDB        = 0X4,
+       FS_FT_NIC_RX          = 0x0,
+       FS_FT_ESW_EGRESS_ACL  = 0x2,
+       FS_FT_ESW_INGRESS_ACL = 0x3,
+       FS_FT_FDB             = 0X4,
 };
 
 enum fs_fte_status {
@@ -79,6 +81,7 @@ struct mlx5_flow_rule {
 struct mlx5_flow_table {
        struct fs_node                  node;
        u32                             id;
+       u16                             vport;
        unsigned int                    max_fte;
        unsigned int                    level;
        enum fs_flow_table_type         type;
@@ -93,6 +96,28 @@ struct mlx5_flow_table {
        struct list_head                fwd_rules;
 };
 
+struct mlx5_fc_cache {
+       u64 packets;
+       u64 bytes;
+       u64 lastuse;
+};
+
+struct mlx5_fc {
+       struct list_head list;
+
+       /* last{packets,bytes} members are used when calculating the delta since
+        * last reading
+        */
+       u64 lastpackets;
+       u64 lastbytes;
+
+       u16 id;
+       bool deleted;
+       bool aging;
+
+       struct mlx5_fc_cache cache ____cacheline_aligned_in_smp;
+};
+
 /* Type of children is mlx5_flow_rule */
 struct fs_fte {
        struct fs_node                  node;
@@ -102,6 +127,7 @@ struct fs_fte {
        u32                             index;
        u32                             action;
        enum fs_fte_status              status;
+       struct mlx5_fc                  *counter;
 };
 
 /* Type of children is mlx5_flow_table/namespace */
@@ -143,6 +169,9 @@ struct mlx5_flow_root_namespace {
        struct mutex                    chain_lock;
 };
 
+int mlx5_init_fc_stats(struct mlx5_core_dev *dev);
+void mlx5_cleanup_fc_stats(struct mlx5_core_dev *dev);
+
 int mlx5_init_fs(struct mlx5_core_dev *dev);
 void mlx5_cleanup_fs(struct mlx5_core_dev *dev);