aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaor Gottlieb <maorg@mellanox.com>2016-03-07 11:51:45 -0500
committerDoug Ledford <dledford@redhat.com>2016-03-10 09:22:06 -0500
commit153fefbf34e5079c2dd69490f5f23373758d2e9c (patch)
treeec529dd63611b40a6c54a39ff835e794eb0a9867
parent0e451e883bd13ce616f439e2414b8c17fa28318a (diff)
net/mlx5_core: Create anchor of last flow table
Create an empty flow table in the end of NIC rx namesapce. Adding this flow table simplify the implementation of "forward to next prio" rules. Signed-off-by: Maor Gottlieb <maorg@mellanox.com> Reviewed-by: Matan Barak <matanb@mellanox.com> Signed-off-by: Doug Ledford <dledford@redhat.com>
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/fs_core.c40
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/fs_core.h6
-rw-r--r--include/linux/mlx5/fs.h1
3 files changed, 46 insertions, 1 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
index 6f68dba8d7ed..a2781ee0fd15 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
@@ -77,6 +77,9 @@
77#define KERNEL_NUM_PRIOS 1 77#define KERNEL_NUM_PRIOS 1
78#define KENREL_MIN_LEVEL 2 78#define KENREL_MIN_LEVEL 2
79 79
80#define ANCHOR_MAX_FT 1
81#define ANCHOR_NUM_PRIOS 1
82#define ANCHOR_MIN_LEVEL (BY_PASS_MIN_LEVEL + 1)
80struct node_caps { 83struct node_caps {
81 size_t arr_sz; 84 size_t arr_sz;
82 long *caps; 85 long *caps;
@@ -92,7 +95,7 @@ static struct init_tree_node {
92 int max_ft; 95 int max_ft;
93} root_fs = { 96} root_fs = {
94 .type = FS_TYPE_NAMESPACE, 97 .type = FS_TYPE_NAMESPACE,
95 .ar_size = 3, 98 .ar_size = 4,
96 .children = (struct init_tree_node[]) { 99 .children = (struct init_tree_node[]) {
97 ADD_PRIO(0, BY_PASS_MIN_LEVEL, 0, 100 ADD_PRIO(0, BY_PASS_MIN_LEVEL, 0,
98 FS_REQUIRED_CAPS(FS_CAP(flow_table_properties_nic_receive.flow_modify_en), 101 FS_REQUIRED_CAPS(FS_CAP(flow_table_properties_nic_receive.flow_modify_en),
@@ -108,6 +111,8 @@ static struct init_tree_node {
108 FS_CAP(flow_table_properties_nic_receive.identified_miss_table_mode), 111 FS_CAP(flow_table_properties_nic_receive.identified_miss_table_mode),
109 FS_CAP(flow_table_properties_nic_receive.flow_table_modify)), 112 FS_CAP(flow_table_properties_nic_receive.flow_table_modify)),
110 ADD_NS(ADD_MULTIPLE_PRIO(LEFTOVERS_NUM_PRIOS, LEFTOVERS_MAX_FT))), 113 ADD_NS(ADD_MULTIPLE_PRIO(LEFTOVERS_NUM_PRIOS, LEFTOVERS_MAX_FT))),
114 ADD_PRIO(0, ANCHOR_MIN_LEVEL, 0, {},
115 ADD_NS(ADD_MULTIPLE_PRIO(ANCHOR_NUM_PRIOS, ANCHOR_MAX_FT))),
111 } 116 }
112}; 117};
113 118
@@ -1126,6 +1131,7 @@ struct mlx5_flow_namespace *mlx5_get_flow_namespace(struct mlx5_core_dev *dev,
1126 case MLX5_FLOW_NAMESPACE_BYPASS: 1131 case MLX5_FLOW_NAMESPACE_BYPASS:
1127 case MLX5_FLOW_NAMESPACE_KERNEL: 1132 case MLX5_FLOW_NAMESPACE_KERNEL:
1128 case MLX5_FLOW_NAMESPACE_LEFTOVERS: 1133 case MLX5_FLOW_NAMESPACE_LEFTOVERS:
1134 case MLX5_FLOW_NAMESPACE_ANCHOR:
1129 prio = type; 1135 prio = type;
1130 break; 1136 break;
1131 case MLX5_FLOW_NAMESPACE_FDB: 1137 case MLX5_FLOW_NAMESPACE_FDB:
@@ -1351,6 +1357,25 @@ static void set_prio_attrs(struct mlx5_flow_root_namespace *root_ns)
1351 } 1357 }
1352} 1358}
1353 1359
1360#define ANCHOR_PRIO 0
1361#define ANCHOR_SIZE 1
1362static int create_anchor_flow_table(struct mlx5_core_dev
1363 *dev)
1364{
1365 struct mlx5_flow_namespace *ns = NULL;
1366 struct mlx5_flow_table *ft;
1367
1368 ns = mlx5_get_flow_namespace(dev, MLX5_FLOW_NAMESPACE_ANCHOR);
1369 if (!ns)
1370 return -EINVAL;
1371 ft = mlx5_create_flow_table(ns, ANCHOR_PRIO, ANCHOR_SIZE);
1372 if (IS_ERR(ft)) {
1373 mlx5_core_err(dev, "Failed to create last anchor flow table");
1374 return PTR_ERR(ft);
1375 }
1376 return 0;
1377}
1378
1354static int init_root_ns(struct mlx5_core_dev *dev) 1379static int init_root_ns(struct mlx5_core_dev *dev)
1355{ 1380{
1356 1381
@@ -1363,6 +1388,9 @@ static int init_root_ns(struct mlx5_core_dev *dev)
1363 1388
1364 set_prio_attrs(dev->priv.root_ns); 1389 set_prio_attrs(dev->priv.root_ns);
1365 1390
1391 if (create_anchor_flow_table(dev))
1392 goto cleanup;
1393
1366 return 0; 1394 return 0;
1367 1395
1368cleanup: 1396cleanup:
@@ -1392,6 +1420,15 @@ static void cleanup_single_prio_root_ns(struct mlx5_core_dev *dev,
1392 root_ns = NULL; 1420 root_ns = NULL;
1393} 1421}
1394 1422
1423static void destroy_flow_tables(struct fs_prio *prio)
1424{
1425 struct mlx5_flow_table *iter;
1426 struct mlx5_flow_table *tmp;
1427
1428 fs_for_each_ft_safe(iter, tmp, prio)
1429 mlx5_destroy_flow_table(iter);
1430}
1431
1395static void cleanup_root_ns(struct mlx5_core_dev *dev) 1432static void cleanup_root_ns(struct mlx5_core_dev *dev)
1396{ 1433{
1397 struct mlx5_flow_root_namespace *root_ns = dev->priv.root_ns; 1434 struct mlx5_flow_root_namespace *root_ns = dev->priv.root_ns;
@@ -1420,6 +1457,7 @@ static void cleanup_root_ns(struct mlx5_core_dev *dev)
1420 list); 1457 list);
1421 1458
1422 fs_get_obj(obj_iter_prio2, iter_prio2); 1459 fs_get_obj(obj_iter_prio2, iter_prio2);
1460 destroy_flow_tables(obj_iter_prio2);
1423 if (tree_remove_node(iter_prio2)) { 1461 if (tree_remove_node(iter_prio2)) {
1424 mlx5_core_warn(dev, 1462 mlx5_core_warn(dev,
1425 "Priority %d wasn't destroyed, refcount > 1\n", 1463 "Priority %d wasn't destroyed, refcount > 1\n",
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.h b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.h
index 00245fd7e4bc..574a903180ed 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.h
@@ -142,6 +142,9 @@ void mlx5_cleanup_fs(struct mlx5_core_dev *dev);
142#define fs_list_for_each_entry(pos, root) \ 142#define fs_list_for_each_entry(pos, root) \
143 list_for_each_entry(pos, root, node.list) 143 list_for_each_entry(pos, root, node.list)
144 144
145#define fs_list_for_each_entry_safe(pos, tmp, root) \
146 list_for_each_entry_safe(pos, tmp, root, node.list)
147
145#define fs_for_each_ns_or_ft_reverse(pos, prio) \ 148#define fs_for_each_ns_or_ft_reverse(pos, prio) \
146 list_for_each_entry_reverse(pos, &(prio)->node.children, list) 149 list_for_each_entry_reverse(pos, &(prio)->node.children, list)
147 150
@@ -157,6 +160,9 @@ void mlx5_cleanup_fs(struct mlx5_core_dev *dev);
157#define fs_for_each_ft(pos, prio) \ 160#define fs_for_each_ft(pos, prio) \
158 fs_list_for_each_entry(pos, &(prio)->node.children) 161 fs_list_for_each_entry(pos, &(prio)->node.children)
159 162
163#define fs_for_each_ft_safe(pos, tmp, prio) \
164 fs_list_for_each_entry_safe(pos, tmp, &(prio)->node.children)
165
160#define fs_for_each_fg(pos, ft) \ 166#define fs_for_each_fg(pos, ft) \
161 fs_list_for_each_entry(pos, &(ft)->node.children) 167 fs_list_for_each_entry(pos, &(ft)->node.children)
162 168
diff --git a/include/linux/mlx5/fs.h b/include/linux/mlx5/fs.h
index 8230caa3fb6e..72adf53fdcba 100644
--- a/include/linux/mlx5/fs.h
+++ b/include/linux/mlx5/fs.h
@@ -52,6 +52,7 @@ enum mlx5_flow_namespace_type {
52 MLX5_FLOW_NAMESPACE_BYPASS, 52 MLX5_FLOW_NAMESPACE_BYPASS,
53 MLX5_FLOW_NAMESPACE_KERNEL, 53 MLX5_FLOW_NAMESPACE_KERNEL,
54 MLX5_FLOW_NAMESPACE_LEFTOVERS, 54 MLX5_FLOW_NAMESPACE_LEFTOVERS,
55 MLX5_FLOW_NAMESPACE_ANCHOR,
55 MLX5_FLOW_NAMESPACE_FDB, 56 MLX5_FLOW_NAMESPACE_FDB,
56}; 57};
57 58