diff options
author | Maor Gottlieb <maorg@mellanox.com> | 2016-06-06 11:09:35 -0400 |
---|---|---|
committer | Leon Romanovsky <leon@kernel.org> | 2016-08-18 11:49:59 -0400 |
commit | 87d22483ce68e609818d61e3a65361f5634c6cd6 (patch) | |
tree | b842f7bc6c6f10b54bb6f20a920f5bb5203a9a0b | |
parent | cea824d416522ce63d83b45fc0dc53c0f5b68cee (diff) |
net/mlx5: Add sniffer namespaces
Add sniffer TX and RX namespaces to receive ingoing and outgoing
traffic.
Each outgoing/incoming packet is duplicated and steered to the sniffer
TX/RX namespace in addition to the regular flow.
Signed-off-by: Maor Gottlieb <maorg@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
-rw-r--r-- | drivers/net/ethernet/mellanox/mlx5/core/fs_core.c | 58 | ||||
-rw-r--r-- | drivers/net/ethernet/mellanox/mlx5/core/fs_core.h | 4 | ||||
-rw-r--r-- | include/linux/mlx5/fs.h | 2 |
3 files changed, 64 insertions, 0 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c index ac414b7f366e..f5571a5a57c5 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c | |||
@@ -1427,6 +1427,16 @@ struct mlx5_flow_namespace *mlx5_get_flow_namespace(struct mlx5_core_dev *dev, | |||
1427 | return &steering->esw_ingress_root_ns->ns; | 1427 | return &steering->esw_ingress_root_ns->ns; |
1428 | else | 1428 | else |
1429 | return NULL; | 1429 | return NULL; |
1430 | case MLX5_FLOW_NAMESPACE_SNIFFER_RX: | ||
1431 | if (steering->sniffer_rx_root_ns) | ||
1432 | return &steering->sniffer_rx_root_ns->ns; | ||
1433 | else | ||
1434 | return NULL; | ||
1435 | case MLX5_FLOW_NAMESPACE_SNIFFER_TX: | ||
1436 | if (steering->sniffer_tx_root_ns) | ||
1437 | return &steering->sniffer_tx_root_ns->ns; | ||
1438 | else | ||
1439 | return NULL; | ||
1430 | default: | 1440 | default: |
1431 | return NULL; | 1441 | return NULL; |
1432 | } | 1442 | } |
@@ -1726,10 +1736,46 @@ void mlx5_cleanup_fs(struct mlx5_core_dev *dev) | |||
1726 | cleanup_root_ns(steering->esw_egress_root_ns); | 1736 | cleanup_root_ns(steering->esw_egress_root_ns); |
1727 | cleanup_root_ns(steering->esw_ingress_root_ns); | 1737 | cleanup_root_ns(steering->esw_ingress_root_ns); |
1728 | cleanup_root_ns(steering->fdb_root_ns); | 1738 | cleanup_root_ns(steering->fdb_root_ns); |
1739 | cleanup_root_ns(steering->sniffer_rx_root_ns); | ||
1740 | cleanup_root_ns(steering->sniffer_tx_root_ns); | ||
1729 | mlx5_cleanup_fc_stats(dev); | 1741 | mlx5_cleanup_fc_stats(dev); |
1730 | kfree(steering); | 1742 | kfree(steering); |
1731 | } | 1743 | } |
1732 | 1744 | ||
1745 | static int init_sniffer_tx_root_ns(struct mlx5_flow_steering *steering) | ||
1746 | { | ||
1747 | struct fs_prio *prio; | ||
1748 | |||
1749 | steering->sniffer_tx_root_ns = create_root_ns(steering, FS_FT_SNIFFER_TX); | ||
1750 | if (!steering->sniffer_tx_root_ns) | ||
1751 | return -ENOMEM; | ||
1752 | |||
1753 | /* Create single prio */ | ||
1754 | prio = fs_create_prio(&steering->sniffer_tx_root_ns->ns, 0, 1); | ||
1755 | if (IS_ERR(prio)) { | ||
1756 | cleanup_root_ns(steering->sniffer_tx_root_ns); | ||
1757 | return PTR_ERR(prio); | ||
1758 | } | ||
1759 | return 0; | ||
1760 | } | ||
1761 | |||
1762 | static int init_sniffer_rx_root_ns(struct mlx5_flow_steering *steering) | ||
1763 | { | ||
1764 | struct fs_prio *prio; | ||
1765 | |||
1766 | steering->sniffer_rx_root_ns = create_root_ns(steering, FS_FT_SNIFFER_RX); | ||
1767 | if (!steering->sniffer_rx_root_ns) | ||
1768 | return -ENOMEM; | ||
1769 | |||
1770 | /* Create single prio */ | ||
1771 | prio = fs_create_prio(&steering->sniffer_rx_root_ns->ns, 0, 1); | ||
1772 | if (IS_ERR(prio)) { | ||
1773 | cleanup_root_ns(steering->sniffer_rx_root_ns); | ||
1774 | return PTR_ERR(prio); | ||
1775 | } | ||
1776 | return 0; | ||
1777 | } | ||
1778 | |||
1733 | static int init_fdb_root_ns(struct mlx5_flow_steering *steering) | 1779 | static int init_fdb_root_ns(struct mlx5_flow_steering *steering) |
1734 | { | 1780 | { |
1735 | struct fs_prio *prio; | 1781 | struct fs_prio *prio; |
@@ -1826,6 +1872,18 @@ int mlx5_init_fs(struct mlx5_core_dev *dev) | |||
1826 | } | 1872 | } |
1827 | } | 1873 | } |
1828 | 1874 | ||
1875 | if (MLX5_CAP_FLOWTABLE_SNIFFER_RX(dev, ft_support)) { | ||
1876 | err = init_sniffer_rx_root_ns(steering); | ||
1877 | if (err) | ||
1878 | goto err; | ||
1879 | } | ||
1880 | |||
1881 | if (MLX5_CAP_FLOWTABLE_SNIFFER_TX(dev, ft_support)) { | ||
1882 | err = init_sniffer_tx_root_ns(steering); | ||
1883 | if (err) | ||
1884 | goto err; | ||
1885 | } | ||
1886 | |||
1829 | return 0; | 1887 | return 0; |
1830 | err: | 1888 | err: |
1831 | mlx5_cleanup_fs(dev); | 1889 | mlx5_cleanup_fs(dev); |
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.h b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.h index 23e46e35413f..71ff03bceabb 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.h | |||
@@ -49,6 +49,8 @@ enum fs_flow_table_type { | |||
49 | FS_FT_ESW_EGRESS_ACL = 0x2, | 49 | FS_FT_ESW_EGRESS_ACL = 0x2, |
50 | FS_FT_ESW_INGRESS_ACL = 0x3, | 50 | FS_FT_ESW_INGRESS_ACL = 0x3, |
51 | FS_FT_FDB = 0X4, | 51 | FS_FT_FDB = 0X4, |
52 | FS_FT_SNIFFER_RX = 0X5, | ||
53 | FS_FT_SNIFFER_TX = 0X6, | ||
52 | }; | 54 | }; |
53 | 55 | ||
54 | enum fs_flow_table_op_mod { | 56 | enum fs_flow_table_op_mod { |
@@ -66,6 +68,8 @@ struct mlx5_flow_steering { | |||
66 | struct mlx5_flow_root_namespace *fdb_root_ns; | 68 | struct mlx5_flow_root_namespace *fdb_root_ns; |
67 | struct mlx5_flow_root_namespace *esw_egress_root_ns; | 69 | struct mlx5_flow_root_namespace *esw_egress_root_ns; |
68 | struct mlx5_flow_root_namespace *esw_ingress_root_ns; | 70 | struct mlx5_flow_root_namespace *esw_ingress_root_ns; |
71 | struct mlx5_flow_root_namespace *sniffer_tx_root_ns; | ||
72 | struct mlx5_flow_root_namespace *sniffer_rx_root_ns; | ||
69 | }; | 73 | }; |
70 | 74 | ||
71 | struct fs_node { | 75 | struct fs_node { |
diff --git a/include/linux/mlx5/fs.h b/include/linux/mlx5/fs.h index 8803212fc3aa..93ebc5e21334 100644 --- a/include/linux/mlx5/fs.h +++ b/include/linux/mlx5/fs.h | |||
@@ -63,6 +63,8 @@ enum mlx5_flow_namespace_type { | |||
63 | MLX5_FLOW_NAMESPACE_FDB, | 63 | MLX5_FLOW_NAMESPACE_FDB, |
64 | MLX5_FLOW_NAMESPACE_ESW_EGRESS, | 64 | MLX5_FLOW_NAMESPACE_ESW_EGRESS, |
65 | MLX5_FLOW_NAMESPACE_ESW_INGRESS, | 65 | MLX5_FLOW_NAMESPACE_ESW_INGRESS, |
66 | MLX5_FLOW_NAMESPACE_SNIFFER_RX, | ||
67 | MLX5_FLOW_NAMESPACE_SNIFFER_TX, | ||
66 | }; | 68 | }; |
67 | 69 | ||
68 | struct mlx5_flow_table; | 70 | struct mlx5_flow_table; |