diff options
| author | Amir Vadai <amirva@mellanox.com> | 2016-05-13 08:55:41 -0400 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2016-05-16 13:43:51 -0400 |
| commit | 43a335e055bb7ebdc8a68ce7362ef26ef5bda92b (patch) | |
| tree | 0441f14934b5e341f12df45bc86bbca9c3dc3d03 /include/linux/mlx5 | |
| parent | bd5251dbf156b6bc0661a9409d46e47160df61dd (diff) | |
net/mlx5_core: Flow counters infrastructure
If a counter has the aging flag set when created, it is added to a list
of counters that will be queried periodically from a workqueue. query
result and last use timestamp are cached.
add/del counter must be very efficient since thousands of such
operations might be issued in a second.
There is only a single reference to counters without aging, therefore
no need for locks.
But, counters with aging enabled are stored in a list. In order to make
code as lockless as possible, all the list manipulation and access to
hardware is done from a single context - the periodic counters query
thread.
The hardware supports multiple counters per FTE, however currently we
are using one counter for each FTE.
Signed-off-by: Amir Vadai <amirva@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/linux/mlx5')
| -rw-r--r-- | include/linux/mlx5/driver.h | 14 | ||||
| -rw-r--r-- | include/linux/mlx5/fs.h | 5 |
2 files changed, 19 insertions, 0 deletions
diff --git a/include/linux/mlx5/driver.h b/include/linux/mlx5/driver.h index 9613143f0561..07b504f7eb84 100644 --- a/include/linux/mlx5/driver.h +++ b/include/linux/mlx5/driver.h | |||
| @@ -41,6 +41,7 @@ | |||
| 41 | #include <linux/slab.h> | 41 | #include <linux/slab.h> |
| 42 | #include <linux/vmalloc.h> | 42 | #include <linux/vmalloc.h> |
| 43 | #include <linux/radix-tree.h> | 43 | #include <linux/radix-tree.h> |
| 44 | #include <linux/workqueue.h> | ||
| 44 | 45 | ||
| 45 | #include <linux/mlx5/device.h> | 46 | #include <linux/mlx5/device.h> |
| 46 | #include <linux/mlx5/doorbell.h> | 47 | #include <linux/mlx5/doorbell.h> |
| @@ -457,6 +458,17 @@ struct mlx5_irq_info { | |||
| 457 | char name[MLX5_MAX_IRQ_NAME]; | 458 | char name[MLX5_MAX_IRQ_NAME]; |
| 458 | }; | 459 | }; |
| 459 | 460 | ||
| 461 | struct mlx5_fc_stats { | ||
| 462 | struct list_head list; | ||
| 463 | struct list_head addlist; | ||
| 464 | /* protect addlist add/splice operations */ | ||
| 465 | spinlock_t addlist_lock; | ||
| 466 | |||
| 467 | struct workqueue_struct *wq; | ||
| 468 | struct delayed_work work; | ||
| 469 | unsigned long next_query; | ||
| 470 | }; | ||
| 471 | |||
| 460 | struct mlx5_eswitch; | 472 | struct mlx5_eswitch; |
| 461 | 473 | ||
| 462 | struct mlx5_priv { | 474 | struct mlx5_priv { |
| @@ -520,6 +532,8 @@ struct mlx5_priv { | |||
| 520 | struct mlx5_flow_root_namespace *fdb_root_ns; | 532 | struct mlx5_flow_root_namespace *fdb_root_ns; |
| 521 | struct mlx5_flow_root_namespace *esw_egress_root_ns; | 533 | struct mlx5_flow_root_namespace *esw_egress_root_ns; |
| 522 | struct mlx5_flow_root_namespace *esw_ingress_root_ns; | 534 | struct mlx5_flow_root_namespace *esw_ingress_root_ns; |
| 535 | |||
| 536 | struct mlx5_fc_stats fc_stats; | ||
| 523 | }; | 537 | }; |
| 524 | 538 | ||
| 525 | enum mlx5_device_state { | 539 | enum mlx5_device_state { |
diff --git a/include/linux/mlx5/fs.h b/include/linux/mlx5/fs.h index c8b9ede1c20a..4b7a107d9c19 100644 --- a/include/linux/mlx5/fs.h +++ b/include/linux/mlx5/fs.h | |||
| @@ -127,4 +127,9 @@ int mlx5_modify_rule_destination(struct mlx5_flow_rule *rule, | |||
| 127 | struct mlx5_flow_destination *dest); | 127 | struct mlx5_flow_destination *dest); |
| 128 | 128 | ||
| 129 | struct mlx5_fc *mlx5_flow_rule_counter(struct mlx5_flow_rule *rule); | 129 | struct mlx5_fc *mlx5_flow_rule_counter(struct mlx5_flow_rule *rule); |
| 130 | struct mlx5_fc *mlx5_fc_create(struct mlx5_core_dev *dev, bool aging); | ||
| 131 | void mlx5_fc_destroy(struct mlx5_core_dev *dev, struct mlx5_fc *counter); | ||
| 132 | void mlx5_fc_query_cached(struct mlx5_fc *counter, | ||
| 133 | u64 *bytes, u64 *packets, u64 *lastuse); | ||
| 134 | |||
| 130 | #endif | 135 | #endif |
