]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.10.7/net-mlx5e-change-the-tc-offload-rule-add-del-code-path-to-be-per-nic-or-e-switch.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.10.7 / net-mlx5e-change-the-tc-offload-rule-add-del-code-path-to-be-per-nic-or-e-switch.patch
1 From foo@baz Mon Mar 27 18:18:08 CEST 2017
2 From: Or Gerlitz <ogerlitz@mellanox.com>
3 Date: Tue, 21 Mar 2017 15:59:13 +0200
4 Subject: net/mlx5e: Change the TC offload rule add/del code path to be per NIC or E-Switch
5
6 From: Or Gerlitz <ogerlitz@mellanox.com>
7
8
9 [ Upstream commit d85cdccbb3fe9a632ec9d0f4e4526c8c84fc3523 ]
10
11 Refactor the code to deal with add/del TC rules to have handler per NIC/E-switch
12 offloading use case, and push the latter into the e-switch code. This provides
13 better separation and is to be used in down-stream patch for applying a fix.
14
15 Fixes: bffaa916588e ("net/mlx5: E-Switch, Add control for inline mode")
16 Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
17 Reviewed-by: Roi Dayan <roid@mellanox.com>
18 Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
19 Signed-off-by: David S. Miller <davem@davemloft.net>
20 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
21 ---
22 drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 57 ++++++++-----
23 drivers/net/ethernet/mellanox/mlx5/core/eswitch.h | 5 +
24 drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c | 14 +++
25 3 files changed, 58 insertions(+), 18 deletions(-)
26
27 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
28 +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
29 @@ -128,6 +128,23 @@ err_create_ft:
30 return rule;
31 }
32
33 +static void mlx5e_tc_del_nic_flow(struct mlx5e_priv *priv,
34 + struct mlx5e_tc_flow *flow)
35 +{
36 + struct mlx5_fc *counter = NULL;
37 +
38 + if (!IS_ERR(flow->rule)) {
39 + counter = mlx5_flow_rule_counter(flow->rule);
40 + mlx5_del_flow_rules(flow->rule);
41 + mlx5_fc_destroy(priv->mdev, counter);
42 + }
43 +
44 + if (!mlx5e_tc_num_filters(priv) && (priv->fs.tc.t)) {
45 + mlx5_destroy_flow_table(priv->fs.tc.t);
46 + priv->fs.tc.t = NULL;
47 + }
48 +}
49 +
50 static struct mlx5_flow_handle *
51 mlx5e_tc_add_fdb_flow(struct mlx5e_priv *priv,
52 struct mlx5_flow_spec *spec,
53 @@ -144,7 +161,24 @@ mlx5e_tc_add_fdb_flow(struct mlx5e_priv
54 }
55
56 static void mlx5e_detach_encap(struct mlx5e_priv *priv,
57 - struct mlx5e_tc_flow *flow) {
58 + struct mlx5e_tc_flow *flow);
59 +
60 +static void mlx5e_tc_del_fdb_flow(struct mlx5e_priv *priv,
61 + struct mlx5e_tc_flow *flow)
62 +{
63 + struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
64 +
65 + mlx5_eswitch_del_offloaded_rule(esw, flow->rule, flow->attr);
66 +
67 + mlx5_eswitch_del_vlan_action(esw, flow->attr);
68 +
69 + if (flow->attr->action & MLX5_FLOW_CONTEXT_ACTION_ENCAP)
70 + mlx5e_detach_encap(priv, flow);
71 +}
72 +
73 +static void mlx5e_detach_encap(struct mlx5e_priv *priv,
74 + struct mlx5e_tc_flow *flow)
75 +{
76 struct list_head *next = flow->encap.next;
77
78 list_del(&flow->encap);
79 @@ -169,24 +203,11 @@ static void mlx5e_tc_del_flow(struct mlx
80 struct mlx5e_tc_flow *flow)
81 {
82 struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
83 - struct mlx5_fc *counter = NULL;
84
85 - if (!IS_ERR(flow->rule)) {
86 - counter = mlx5_flow_rule_counter(flow->rule);
87 - mlx5_del_flow_rules(flow->rule);
88 - mlx5_fc_destroy(priv->mdev, counter);
89 - }
90 -
91 - if (esw && esw->mode == SRIOV_OFFLOADS) {
92 - mlx5_eswitch_del_vlan_action(esw, flow->attr);
93 - if (flow->attr->action & MLX5_FLOW_CONTEXT_ACTION_ENCAP)
94 - mlx5e_detach_encap(priv, flow);
95 - }
96 -
97 - if (!mlx5e_tc_num_filters(priv) && (priv->fs.tc.t)) {
98 - mlx5_destroy_flow_table(priv->fs.tc.t);
99 - priv->fs.tc.t = NULL;
100 - }
101 + if (esw && esw->mode == SRIOV_OFFLOADS)
102 + mlx5e_tc_del_fdb_flow(priv, flow);
103 + else
104 + mlx5e_tc_del_nic_flow(priv, flow);
105 }
106
107 static void parse_vxlan_attr(struct mlx5_flow_spec *spec,
108 --- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
109 +++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
110 @@ -263,6 +263,11 @@ struct mlx5_flow_handle *
111 mlx5_eswitch_add_offloaded_rule(struct mlx5_eswitch *esw,
112 struct mlx5_flow_spec *spec,
113 struct mlx5_esw_flow_attr *attr);
114 +void
115 +mlx5_eswitch_del_offloaded_rule(struct mlx5_eswitch *esw,
116 + struct mlx5_flow_handle *rule,
117 + struct mlx5_esw_flow_attr *attr);
118 +
119 struct mlx5_flow_handle *
120 mlx5_eswitch_create_vport_rx_rule(struct mlx5_eswitch *esw, int vport, u32 tirn);
121
122 --- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
123 +++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
124 @@ -97,6 +97,20 @@ mlx5_eswitch_add_offloaded_rule(struct m
125 return rule;
126 }
127
128 +void
129 +mlx5_eswitch_del_offloaded_rule(struct mlx5_eswitch *esw,
130 + struct mlx5_flow_handle *rule,
131 + struct mlx5_esw_flow_attr *attr)
132 +{
133 + struct mlx5_fc *counter = NULL;
134 +
135 + if (!IS_ERR(rule)) {
136 + counter = mlx5_flow_rule_counter(rule);
137 + mlx5_del_flow_rules(rule);
138 + mlx5_fc_destroy(esw->dev, counter);
139 + }
140 +}
141 +
142 static int esw_set_global_vlan_pop(struct mlx5_eswitch *esw, u8 val)
143 {
144 struct mlx5_eswitch_rep *rep;