Mellanox, mlx5 fixes 2020-07-30
Hi Dave,
This small patchset introduces some fixes to mlx5 driver.
Please pull and let me know if there is any problem.
For -stable v4.18:
('net/mlx5e: fix bpf_prog reference count leaks in mlx5e_alloc_rq')
For -stable v5.7:
('net/mlx5e: E-Switch, Add misc bit when misc fields changed for mirroring')
Thanks,
Saeed.
---
The following changes since commit 85496a29224188051b6135eb38da8afd4c584765:
net: gemini: Fix missing clk_disable_unprepare() in error path of gemini_ethernet_port_probe() (2020-07-30 17:45:13 -0700)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux.git tags/mlx5-fixes-2020-07-30
for you to fetch changes up to e692139e6af339a1495ef401b2d95f7f9d1c7a44:
net/mlx5e: fix bpf_prog reference count leaks in mlx5e_alloc_rq (2020-07-30 18:53:55 -0700)
----------------------------------------------------------------
mlx5-fixes-2020-07-30
----------------------------------------------------------------
Jianbo Liu (3):
net/mlx5e: CT: Support restore ipv6 tunnel
net/mlx5e: E-Switch, Add misc bit when misc fields changed for mirroring net/mlx5e: E-Switch, Specify flow_source for rule with no in_port
Xin Xiong (1):
net/mlx5e: fix bpf_prog reference count leaks in mlx5e_alloc_rq
.../net/ethernet/mellanox/mlx5/core/en/rep/tc.c | 30 +++++++++++++++------- .../ethernet/mellanox/mlx5/core/en/tc_tun_geneve.c | 2 ++ .../ethernet/mellanox/mlx5/core/en/tc_tun_gre.c | 2 ++ .../ethernet/mellanox/mlx5/core/en/tc_tun_vxlan.c | 2 ++ drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 4 +-- drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 1 + .../ethernet/mellanox/mlx5/core/eswitch_offloads.c | 19 +++++++++----- 7 files changed, 42 insertions(+), 18 deletions(-)
PATCH 1/4 net/mlx5e: CT: Support restore ipv6 tunnel
From: Jianbo Liu <[email protected]>
Currently the driver restores only IPv4 tunnel headers. Add support for restoring IPv6 tunnel header.
--- .../ethernet/mellanox/mlx5/core/en/rep/tc.c | 30 +++++++++++++------ 1 file changed, 21 insertions(+), 9 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c +21 -9
@@ -551,19 +551,31 @@ static bool mlx5e_restore_tunnel(struct mlx5e_priv *priv, struct sk_buff *skb, } } - tun_dst =tun_rx_dst (enc_opts.key.len); +if (key.enc_control.addr_type ==FLOW_DISSECTOR_KEY_IPV4_ADDRS ) { + tun_dst =__ip_tun_set_dst (key.enc_ipv4.src, key.enc_ipv4.dst, + key.enc_ip.tos, key.enc_ip.ttl, + key.enc_tp.dst,TUNNEL_KEY , +key32_to_tunnel_id (key.enc_key_id.keyid), + enc_opts.key.len); + }else if (key.enc_control.addr_type ==FLOW_DISSECTOR_KEY_IPV6_ADDRS ) { + tun_dst =__ipv6_tun_set_dst (&key.enc_ipv6.src, &key.enc_ipv6.dst, + key.enc_ip.tos, key.enc_ip.ttl, + key.enc_tp.dst,0 ,TUNNEL_KEY , +key32_to_tunnel_id (key.enc_key_id.keyid), + enc_opts.key.len); + }else { +netdev_dbg (priv->netdev, +"Couldn't restore tunnel, unsupported addr_type: %d\n" , + key.enc_control.addr_type); +return false; + } +if (!tun_dst) { -WARN_ON_ONCE (true); +netdev_dbg (priv->netdev,"Couldn't restore tunnel, no tun_dst\n" );return false; } -ip_tunnel_key_init (&tun_dst->u.tun_info.key, - key.enc_ipv4.src, key.enc_ipv4.dst, - key.enc_ip.tos, key.enc_ip.ttl, -0 ,/* label */ - key.enc_tp.src, key.enc_tp.dst, -key32_to_tunnel_id (key.enc_key_id.keyid), -TUNNEL_KEY ); + tun_dst->u.tun_info.key.tp_src = key.enc_tp.src;if (enc_opts.key.len) ip_tunnel_info_opts_set(&tun_dst->u.tun_info,
Signature · 1 line
2.26.2
PATCH 2/4 net/mlx5e: E-Switch, Add misc bit when misc fields changed for mirroring
In reply to Saeed MahameedFrom: Jianbo Liu <[email protected]>
The modified flow_context fields in FTE must be indicated in modify_enable bitmask. Previously, the misc bit in modify_enable is always set as source vport must be set for each rule. So, when parsing vxlan/gre/geneve/qinq rules, this bit is not set because those are all from the same misc fileds that source vport fields are located at, and we don't need to set the indicator twice.
After adding per vport tables for mirroring, misc bit is not set, then firmware syndrome happens. To fix it, set the bit wherever misc fileds are changed. This also makes it unnecessary to check misc fields and set the misc bit accordingly in metadata matching, so here remove it.
Besides, flow_source must be specified for uplink because firmware will check it and some actions are only allowed for packets received from uplink.
--- drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_geneve.c | 2 ++ drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_gre.c | 2 ++ drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_vxlan.c | 2 ++ drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 1 + drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c | 6 +++--- 5 files changed, 10 insertions(+), 3 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_geneve.c +2 -0
@@ -301,6 +301,8 @@ static int mlx5e_tc_tun_parse_geneve_params(struct mlx5e_priv *priv,MLX5_SET (fte_match_set_misc, misc_v, geneve_protocol_type,ETH_P_TEB ); } + spec->match_criteria_enable |=MLX5_MATCH_MISC_PARAMETERS ; +return 0 ; }
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_gre.c +2 -0
@@ -80,6 +80,8 @@ static int mlx5e_tc_tun_parse_gretap(struct mlx5e_priv *priv, gre_key.key, be32_to_cpu(enc_keyid.key->keyid)); } + spec->match_criteria_enable |=MLX5_MATCH_MISC_PARAMETERS ; +return 0 ; }
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_vxlan.c +2 -0
@@ -136,6 +136,8 @@ static int mlx5e_tc_tun_parse_vxlan(struct mlx5e_priv *priv,MLX5_SET (fte_match_set_misc, misc_v, vxlan_vni,be32_to_cpu (enc_keyid.key->keyid)); + spec->match_criteria_enable |=MLX5_MATCH_MISC_PARAMETERS ; +return 0 ; }
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +1 -0
@@ -2356,6 +2356,7 @@ static int __parse_cls_flower(struct mlx5e_priv *priv, match.key->vlan_priority); *match_level =MLX5_MATCH_L2 ; + spec->match_criteria_enable |=MLX5_MATCH_MISC_PARAMETERS ; } }
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +3 -3
@@ -259,9 +259,6 @@ mlx5_eswitch_set_rule_source_port(struct mlx5_eswitch *esw, mlx5_eswitch_get_vport_metadata_mask()); spec->match_criteria_enable |=MLX5_MATCH_MISC_PARAMETERS_2 ; - misc =MLX5_ADDR_OF (fte_match_param, spec->match_criteria, misc_parameters); -if (memchr_inv (misc,0 ,MLX5_ST_SZ_BYTES (fte_match_set_misc))) - spec->match_criteria_enable |=MLX5_MATCH_MISC_PARAMETERS ; }else { misc =MLX5_ADDR_OF (fte_match_param, spec->match_value, misc_parameters);MLX5_SET (fte_match_set_misc, misc, source_port, attr->in_rep->vport);
@@ -380,6 +377,9 @@ mlx5_eswitch_add_offloaded_rule(struct mlx5_eswitch *esw, flow_act.modify_hdr = attr->modify_hdr;if (split) { +if (MLX5_CAP_ESW_FLOWTABLE (esw->dev, flow_source) && + attr->in_rep->vport ==MLX5_VPORT_UPLINK ) + spec->flow_context.flow_source =MLX5_FLOW_CONTEXT_FLOW_SOURCE_UPLINK ; fdb =esw_vport_tbl_get (esw, attr); }else {if (attr->chain || attr->prio)
Signature · 1 line
2.26.2
PATCH 3/4 net/mlx5e: E-Switch, Specify flow_source for rule with no in_port
In reply to Saeed MahameedFrom: Jianbo Liu <[email protected]>
The flow_source must be specified, even for rule without matching source vport, because some actions are only allowed in uplink. Otherwise, rule can't be offloaded and firmware syndrome happens.
--- .../mellanox/mlx5/core/eswitch_offloads.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +12 -7
@@ -236,6 +236,15 @@ static struct mlx5_eswitch_rep *mlx5_eswitch_get_rep(struct mlx5_eswitch *esw,return &esw->offloads.vport_reps[idx]; } +static void +mlx5_eswitch_set_rule_flow_source (struct mlx5_eswitch *esw, +struct mlx5_flow_spec *spec, +struct mlx5_esw_flow_attr *attr) +{ +if (MLX5_CAP_ESW_FLOWTABLE (esw->dev, flow_source) && + attr && attr->in_rep && attr->in_rep->vport ==MLX5_VPORT_UPLINK ) + spec->flow_context.flow_source =MLX5_FLOW_CONTEXT_FLOW_SOURCE_UPLINK ; +} static void mlx5_eswitch_set_rule_source_port(struct mlx5_eswitch *esw,
@@ -276,10 +285,6 @@ mlx5_eswitch_set_rule_source_port(struct mlx5_eswitch *esw, spec->match_criteria_enable |=MLX5_MATCH_MISC_PARAMETERS ; } - -if (MLX5_CAP_ESW_FLOWTABLE (esw->dev, flow_source) && - attr->in_rep->vport ==MLX5_VPORT_UPLINK ) - spec->flow_context.flow_source =MLX5_FLOW_CONTEXT_FLOW_SOURCE_UPLINK ; } struct mlx5_flow_handle *
@@ -377,9 +382,6 @@ mlx5_eswitch_add_offloaded_rule(struct mlx5_eswitch *esw, flow_act.modify_hdr = attr->modify_hdr;if (split) { -if (MLX5_CAP_ESW_FLOWTABLE (esw->dev, flow_source) && - attr->in_rep->vport ==MLX5_VPORT_UPLINK ) - spec->flow_context.flow_source =MLX5_FLOW_CONTEXT_FLOW_SOURCE_UPLINK ; fdb =esw_vport_tbl_get (esw, attr); }else {if (attr->chain || attr->prio)
@@ -396,6 +398,8 @@ mlx5_eswitch_add_offloaded_rule(struct mlx5_eswitch *esw, goto err_esw_get; } +mlx5_eswitch_set_rule_flow_source (esw, spec, attr); +if (mlx5_eswitch_termtbl_required (esw, attr, &flow_act, spec)) rule =mlx5_eswitch_add_termtbl_rule (esw, fdb, spec, attr, &flow_act, dest, i);
@@ -462,6 +466,7 @@ mlx5_eswitch_add_fwd_rule(struct mlx5_eswitch *esw, i++;mlx5_eswitch_set_rule_source_port (esw, spec, attr); +mlx5_eswitch_set_rule_flow_source (esw, spec, attr);if (attr->outer_match_level !=MLX5_MATCH_NONE ) spec->match_criteria_enable |=MLX5_MATCH_OUTER_HEADERS ;
Signature · 1 line
2.26.2
PATCH 4/4 net/mlx5e: fix bpf_prog reference count leaks in mlx5e_alloc_rq
In reply to Saeed MahameedFrom: Xin Xiong <[email protected]>
The function invokes bpf_prog_inc(), which increases the reference count of a bpf_prog object "rq->xdp_prog" if the object isn't NULL.
The refcount leak issues take place in two error handling paths. When either mlx5_wq_ll_create() or mlx5_wq_cyc_create() fails, the function simply returns the error code and forgets to drop the reference count increased earlier, causing a reference count leak of "rq->xdp_prog".
Fix this issue by jumping to the error handling path err_rq_wq_destroy while either function fails.
--- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +2 -2
@@ -419,7 +419,7 @@ static int mlx5e_alloc_rq(struct mlx5e_channel *c, err =mlx5_wq_ll_create (mdev, &rqp->wq, rqc_wq, &rq->mpwqe.wq, &rq->wq_ctrl);if (err) -return err; + goto err_rq_wq_destroy; rq->mpwqe.wq.db = &rq->mpwqe.wq.db[MLX5_RCV_DBR ];
@@ -470,7 +470,7 @@ static int mlx5e_alloc_rq(struct mlx5e_channel *c, err =mlx5_wq_cyc_create (mdev, &rqp->wq, rqc_wq, &rq->wqe.wq, &rq->wq_ctrl);if (err) -return err; + goto err_rq_wq_destroy; rq->wqe.wq.db = &rq->wqe.wq.db[MLX5_RCV_DBR ];
Signature · 1 line
2.26.2
From: Saeed Mahameed <[email protected]>
Date: Thu, 30 Jul 2020 18:57:48 -0700
Quoted 3 lines
This small patchset introduces some fixes to mlx5 driver.
Please pull and let me know if there is any problem.
Pulled.
Quoted 5 lines
For -stable v4.18:
('net/mlx5e: fixbpf_progreference count leaks inmlx5e_alloc_rq')For -stable v5.7:
('net/mlx5e: E-Switch, Add misc bit when misc fields changed for mirroring')
Queued up, thanks.