aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOr Gerlitz <ogerlitz@mellanox.com>2017-03-21 09:59:13 -0400
committerDavid S. Miller <davem@davemloft.net>2017-03-22 15:11:12 -0400
commitd85cdccbb3fe9a632ec9d0f4e4526c8c84fc3523 (patch)
treea616add22f6240e7f1236708bf178bbce36bbfd8
parent1f30a86c58093046dc3e49c23d2618894e098f7a (diff)
net/mlx5e: Change the TC offload rule add/del code path to be per NIC or E-Switch
Refactor the code to deal with add/del TC rules to have handler per NIC/E-switch offloading use case, and push the latter into the e-switch code. This provides better separation and is to be used in down-stream patch for applying a fix. Fixes: bffaa916588e ("net/mlx5: E-Switch, Add control for inline mode") Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com> Reviewed-by: Roi Dayan <roid@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_tc.c59
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/eswitch.h5
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c14
3 files changed, 58 insertions, 20 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
index 79481f4cf264..2825b5665456 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
@@ -133,6 +133,23 @@ err_create_ft:
133 return rule; 133 return rule;
134} 134}
135 135
136static void mlx5e_tc_del_nic_flow(struct mlx5e_priv *priv,
137 struct mlx5e_tc_flow *flow)
138{
139 struct mlx5_fc *counter = NULL;
140
141 if (!IS_ERR(flow->rule)) {
142 counter = mlx5_flow_rule_counter(flow->rule);
143 mlx5_del_flow_rules(flow->rule);
144 mlx5_fc_destroy(priv->mdev, counter);
145 }
146
147 if (!mlx5e_tc_num_filters(priv) && (priv->fs.tc.t)) {
148 mlx5_destroy_flow_table(priv->fs.tc.t);
149 priv->fs.tc.t = NULL;
150 }
151}
152
136static struct mlx5_flow_handle * 153static struct mlx5_flow_handle *
137mlx5e_tc_add_fdb_flow(struct mlx5e_priv *priv, 154mlx5e_tc_add_fdb_flow(struct mlx5e_priv *priv,
138 struct mlx5_flow_spec *spec, 155 struct mlx5_flow_spec *spec,
@@ -149,7 +166,24 @@ mlx5e_tc_add_fdb_flow(struct mlx5e_priv *priv,
149} 166}
150 167
151static void mlx5e_detach_encap(struct mlx5e_priv *priv, 168static void mlx5e_detach_encap(struct mlx5e_priv *priv,
152 struct mlx5e_tc_flow *flow) { 169 struct mlx5e_tc_flow *flow);
170
171static void mlx5e_tc_del_fdb_flow(struct mlx5e_priv *priv,
172 struct mlx5e_tc_flow *flow)
173{
174 struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
175
176 mlx5_eswitch_del_offloaded_rule(esw, flow->rule, flow->attr);
177
178 mlx5_eswitch_del_vlan_action(esw, flow->attr);
179
180 if (flow->attr->action & MLX5_FLOW_CONTEXT_ACTION_ENCAP)
181 mlx5e_detach_encap(priv, flow);
182}
183
184static void mlx5e_detach_encap(struct mlx5e_priv *priv,
185 struct mlx5e_tc_flow *flow)
186{
153 struct list_head *next = flow->encap.next; 187 struct list_head *next = flow->encap.next;
154 188
155 list_del(&flow->encap); 189 list_del(&flow->encap);
@@ -173,25 +207,10 @@ static void mlx5e_detach_encap(struct mlx5e_priv *priv,
173static void mlx5e_tc_del_flow(struct mlx5e_priv *priv, 207static void mlx5e_tc_del_flow(struct mlx5e_priv *priv,
174 struct mlx5e_tc_flow *flow) 208 struct mlx5e_tc_flow *flow)
175{ 209{
176 struct mlx5_eswitch *esw = priv->mdev->priv.eswitch; 210 if (flow->flags & MLX5E_TC_FLOW_ESWITCH)
177 struct mlx5_fc *counter = NULL; 211 mlx5e_tc_del_fdb_flow(priv, flow);
178 212 else
179 if (!IS_ERR(flow->rule)) { 213 mlx5e_tc_del_nic_flow(priv, flow);
180 counter = mlx5_flow_rule_counter(flow->rule);
181 mlx5_del_flow_rules(flow->rule);
182 mlx5_fc_destroy(priv->mdev, counter);
183 }
184
185 if (flow->flags & MLX5E_TC_FLOW_ESWITCH) {
186 mlx5_eswitch_del_vlan_action(esw, flow->attr);
187 if (flow->attr->action & MLX5_FLOW_CONTEXT_ACTION_ENCAP)
188 mlx5e_detach_encap(priv, flow);
189 }
190
191 if (!mlx5e_tc_num_filters(priv) && (priv->fs.tc.t)) {
192 mlx5_destroy_flow_table(priv->fs.tc.t);
193 priv->fs.tc.t = NULL;
194 }
195} 214}
196 215
197static void parse_vxlan_attr(struct mlx5_flow_spec *spec, 216static void parse_vxlan_attr(struct mlx5_flow_spec *spec,
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
index 5b78883d5654..9227a83a97e3 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
@@ -271,6 +271,11 @@ struct mlx5_flow_handle *
271mlx5_eswitch_add_offloaded_rule(struct mlx5_eswitch *esw, 271mlx5_eswitch_add_offloaded_rule(struct mlx5_eswitch *esw,
272 struct mlx5_flow_spec *spec, 272 struct mlx5_flow_spec *spec,
273 struct mlx5_esw_flow_attr *attr); 273 struct mlx5_esw_flow_attr *attr);
274void
275mlx5_eswitch_del_offloaded_rule(struct mlx5_eswitch *esw,
276 struct mlx5_flow_handle *rule,
277 struct mlx5_esw_flow_attr *attr);
278
274struct mlx5_flow_handle * 279struct mlx5_flow_handle *
275mlx5_eswitch_create_vport_rx_rule(struct mlx5_eswitch *esw, int vport, u32 tirn); 280mlx5_eswitch_create_vport_rx_rule(struct mlx5_eswitch *esw, int vport, u32 tirn);
276 281
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
index 4f5b0d47d5f3..bfabefe20ac0 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
@@ -97,6 +97,20 @@ mlx5_eswitch_add_offloaded_rule(struct mlx5_eswitch *esw,
97 return rule; 97 return rule;
98} 98}
99 99
100void
101mlx5_eswitch_del_offloaded_rule(struct mlx5_eswitch *esw,
102 struct mlx5_flow_handle *rule,
103 struct mlx5_esw_flow_attr *attr)
104{
105 struct mlx5_fc *counter = NULL;
106
107 if (!IS_ERR(rule)) {
108 counter = mlx5_flow_rule_counter(rule);
109 mlx5_del_flow_rules(rule);
110 mlx5_fc_destroy(esw->dev, counter);
111 }
112}
113
100static int esw_set_global_vlan_pop(struct mlx5_eswitch *esw, u8 val) 114static int esw_set_global_vlan_pop(struct mlx5_eswitch *esw, u8 val)
101{ 115{
102 struct mlx5_eswitch_rep *rep; 116 struct mlx5_eswitch_rep *rep;