]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
net/mlx5: E-Switch, Consider host PF for inline mode and vlan pop
authorBodong Wang <bodong@mellanox.com>
Fri, 28 Jun 2019 22:36:22 +0000 (22:36 +0000)
committerSaeed Mahameed <saeedm@mellanox.com>
Mon, 1 Jul 2019 23:40:31 +0000 (16:40 -0700)
When ECPF is the eswitch manager, host PF is treated like other VFs.
Driver should do the same for inline mode and vlan pop.

Add new iterators to include host PF if ECPF is the eswitch manager.

Signed-off-by: Bodong Wang <bodong@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
include/linux/mlx5/vport.h

index b256f397f112ef2de306f283d8ab5037202443d3..935b9429bb2aedcfc11d82e143a0e0a24e846954 100644 (file)
@@ -1891,6 +1891,7 @@ int mlx5_eswitch_init(struct mlx5_core_dev *dev)
 
        esw->dev = dev;
        esw->manager_vport = mlx5_eswitch_manager_vport(dev);
+       esw->first_host_vport = mlx5_eswitch_first_host_vport_num(dev);
 
        esw->work_queue = create_singlethread_workqueue("mlx5_esw_wq");
        if (!esw->work_queue) {
index bfc32bcbf544ea3511b2879fa2b479146a73ac39..f59183440d7f4c76d22f8aaddbf08b51d8f24f51 100644 (file)
@@ -227,6 +227,7 @@ struct mlx5_eswitch {
        int                     mode;
        int                     nvports;
        u16                     manager_vport;
+       u16                     first_host_vport;
        struct mlx5_esw_functions esw_funcs;
 };
 
@@ -422,6 +423,12 @@ static inline u16 mlx5_eswitch_manager_vport(struct mlx5_core_dev *dev)
                MLX5_VPORT_ECPF : MLX5_VPORT_PF;
 }
 
+static inline u16 mlx5_eswitch_first_host_vport_num(struct mlx5_core_dev *dev)
+{
+       return mlx5_core_is_ecpf_esw_manager(dev) ?
+               MLX5_VPORT_PF : MLX5_VPORT_FIRST_VF;
+}
+
 static inline bool mlx5_eswitch_is_funcs_handler(struct mlx5_core_dev *dev)
 {
        /* Ideally device should have the functions changed supported
@@ -518,6 +525,25 @@ void mlx5e_tc_clean_fdb_peer_flows(struct mlx5_eswitch *esw);
 #define mlx5_esw_for_each_vf_vport_num_reverse(esw, vport, nvfs)       \
        for ((vport) = (nvfs); (vport) >= MLX5_VPORT_FIRST_VF; (vport)--)
 
+/* Includes host PF (vport 0) if it's not esw manager. */
+#define mlx5_esw_for_each_host_func_rep(esw, i, rep, nvfs)     \
+       for ((i) = (esw)->first_host_vport;                     \
+            (rep) = &(esw)->offloads.vport_reps[i],            \
+            (i) <= (nvfs); (i)++)
+
+#define mlx5_esw_for_each_host_func_rep_reverse(esw, i, rep, nvfs)     \
+       for ((i) = (nvfs);                                              \
+            (rep) = &(esw)->offloads.vport_reps[i],                    \
+            (i) >= (esw)->first_host_vport; (i)--)
+
+#define mlx5_esw_for_each_host_func_vport(esw, vport, nvfs)    \
+       for ((vport) = (esw)->first_host_vport;                 \
+            (vport) <= (nvfs); (vport)++)
+
+#define mlx5_esw_for_each_host_func_vport_reverse(esw, vport, nvfs)    \
+       for ((vport) = (nvfs);                                          \
+            (vport) >= (esw)->first_host_vport; (vport)--)
+
 struct mlx5_vport *__must_check
 mlx5_eswitch_get_vport(struct mlx5_eswitch *esw, u16 vport_num);
 
index aecfb636fbc640ff2a693afd504a13adb106bcbe..50e5841c169810bc2bf2e421ece496fb7ef67518 100644 (file)
@@ -344,10 +344,10 @@ mlx5_eswitch_del_fwd_rule(struct mlx5_eswitch *esw,
 static int esw_set_global_vlan_pop(struct mlx5_eswitch *esw, u8 val)
 {
        struct mlx5_eswitch_rep *rep;
-       int vf_vport, err = 0;
+       int i, err = 0;
 
        esw_debug(esw->dev, "%s applying global %s policy\n", __func__, val ? "pop" : "none");
-       mlx5_esw_for_each_vf_rep(esw, vf_vport, rep, esw->esw_funcs.num_vfs) {
+       mlx5_esw_for_each_host_func_rep(esw, i, rep, esw->esw_funcs.num_vfs) {
                if (atomic_read(&rep->rep_data[REP_ETH].state) != REP_LOADED)
                        continue;
 
@@ -2330,7 +2330,7 @@ int mlx5_devlink_eswitch_inline_mode_set(struct devlink *devlink, u8 mode,
        if (err)
                goto out;
 
-       mlx5_esw_for_each_vf_vport_num(esw, vport, esw->esw_funcs.num_vfs) {
+       mlx5_esw_for_each_host_func_vport(esw, vport, esw->esw_funcs.num_vfs) {
                err = mlx5_modify_nic_vport_min_inline(dev, vport, mlx5_mode);
                if (err) {
                        NL_SET_ERR_MSG_MOD(extack,
@@ -2344,7 +2344,7 @@ int mlx5_devlink_eswitch_inline_mode_set(struct devlink *devlink, u8 mode,
 
 revert_inline_mode:
        num_vport = --vport;
-       mlx5_esw_for_each_vf_vport_num_reverse(esw, vport, num_vport)
+       mlx5_esw_for_each_host_func_vport_reverse(esw, vport, num_vport)
                mlx5_modify_nic_vport_min_inline(dev,
                                                 vport,
                                                 esw->offloads.inline_mode);
@@ -2389,9 +2389,10 @@ int mlx5_eswitch_inline_mode_get(struct mlx5_eswitch *esw, u8 *mode)
        }
 
 query_vports:
-       mlx5_esw_for_each_vf_vport_num(esw, vport, esw->esw_funcs.num_vfs) {
+       mlx5_query_nic_vport_min_inline(dev, esw->first_host_vport, &prev_mlx5_mode);
+       mlx5_esw_for_each_host_func_vport(esw, vport, esw->esw_funcs.num_vfs) {
                mlx5_query_nic_vport_min_inline(dev, vport, &mlx5_mode);
-               if (vport > 1 && prev_mlx5_mode != mlx5_mode)
+               if (prev_mlx5_mode != mlx5_mode)
                        return -EINVAL;
                prev_mlx5_mode = mlx5_mode;
        }
index c147acc7bf7089d56808770e4e3e4c0516b9f0aa..6cbf29229749287c632d7f2e64a1347f011de5b3 100644 (file)
@@ -58,6 +58,7 @@ enum {
        MLX5_CAP_INLINE_MODE_NOT_REQUIRED,
 };
 
+/* Vport number for each function must keep unchanged */
 enum {
        MLX5_VPORT_PF                   = 0x0,
        MLX5_VPORT_FIRST_VF             = 0x1,