net/mlx5: Create TC-miss priority and table
[sfrench/cifs-2.6.git] / drivers / net / ethernet / mellanox / mlx5 / core / eswitch_offloads.c
index d18a28a6e9a63a7b5f9c3cd15e6da7fda3db7dbb..7579f3402776cabe8191814f5c672a77abdb7128 100644 (file)
@@ -1634,7 +1634,21 @@ static int esw_create_offloads_fdb_tables(struct mlx5_eswitch *esw)
        }
        esw->fdb_table.offloads.slow_fdb = fdb;
 
-       err = esw_chains_create(esw, fdb);
+       /* Create empty TC-miss managed table. This allows plugging in following
+        * priorities without directly exposing their level 0 table to
+        * eswitch_offloads and passing it as miss_fdb to following call to
+        * esw_chains_create().
+        */
+       memset(&ft_attr, 0, sizeof(ft_attr));
+       ft_attr.prio = FDB_TC_MISS;
+       esw->fdb_table.offloads.tc_miss_table = mlx5_create_flow_table(root_ns, &ft_attr);
+       if (IS_ERR(esw->fdb_table.offloads.tc_miss_table)) {
+               err = PTR_ERR(esw->fdb_table.offloads.tc_miss_table);
+               esw_warn(dev, "Failed to create TC miss FDB Table err %d\n", err);
+               goto tc_miss_table_err;
+       }
+
+       err = esw_chains_create(esw, esw->fdb_table.offloads.tc_miss_table);
        if (err) {
                esw_warn(dev, "Failed to open fdb chains err(%d)\n", err);
                goto fdb_chains_err;
@@ -1779,6 +1793,8 @@ send_vport_meta_err:
 send_vport_err:
        esw_chains_destroy(esw, esw_chains(esw));
 fdb_chains_err:
+       mlx5_destroy_flow_table(esw->fdb_table.offloads.tc_miss_table);
+tc_miss_table_err:
        mlx5_destroy_flow_table(esw->fdb_table.offloads.slow_fdb);
 slow_fdb_err:
        /* Holds true only as long as DMFS is the default */
@@ -1806,6 +1822,7 @@ static void esw_destroy_offloads_fdb_tables(struct mlx5_eswitch *esw)
 
        esw_chains_destroy(esw, esw_chains(esw));
 
+       mlx5_destroy_flow_table(esw->fdb_table.offloads.tc_miss_table);
        mlx5_destroy_flow_table(esw->fdb_table.offloads.slow_fdb);
        /* Holds true only as long as DMFS is the default */
        mlx5_flow_namespace_set_mode(esw->fdb_table.offloads.ns,