From: Leon Romanovsky <leon@kernel.org>
To: Paul Blakey <paulb@nvidia.com>
Cc: netdev@vger.kernel.org, Saeed Mahameed <saeedm@nvidia.com>,
Paolo Abeni <pabeni@redhat.com>, Jakub Kicinski <kuba@kernel.org>,
Eric Dumazet <edumazet@google.com>,
Jamal Hadi Salim <jhs@mojatatu.com>,
Cong Wang <xiyou.wangcong@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
Oz Shlomo <ozsh@nvidia.com>, Jiri Pirko <jiri@nvidia.com>,
Roi Dayan <roid@nvidia.com>, Vlad Buslov <vladbu@nvidia.com>
Subject: Re: [PATCH net-next v6 4/6] net/mlx5: Refactor tc miss handling to a single function
Date: Mon, 30 Jan 2023 11:33:22 +0200 [thread overview]
Message-ID: <Y9eO4rZ6zAyuNk6j@unreal> (raw)
In-Reply-To: <20230129101613.17201-5-paulb@nvidia.com>
On Sun, Jan 29, 2023 at 12:16:11PM +0200, Paul Blakey wrote:
> Move tc miss handling code to en_tc.c, and remove
> duplicate code.
>
> Signed-off-by: Paul Blakey <paulb@nvidia.com>
> Reviewed-by: Roi Dayan <roid@nvidia.com>
> ---
> .../ethernet/mellanox/mlx5/core/en/rep/tc.c | 225 ++----------------
> .../net/ethernet/mellanox/mlx5/core/en_rx.c | 4 +-
> .../net/ethernet/mellanox/mlx5/core/en_tc.c | 221 +++++++++++++++--
> .../net/ethernet/mellanox/mlx5/core/en_tc.h | 11 +-
> 4 files changed, 232 insertions(+), 229 deletions(-)
<...>
> void mlx5e_rep_tc_receive(struct mlx5_cqe64 *cqe, struct mlx5e_rq *rq,
> struct sk_buff *skb)
> {
> - u32 reg_c1 = be32_to_cpu(cqe->ft_metadata);
> + u32 reg_c1 = be32_to_cpu(cqe->ft_metadata), reg_c0, zone_restore_id, tunnel_id;
> struct mlx5e_tc_update_priv tc_priv = {};
> - struct mlx5_mapped_obj mapped_obj;
> + struct mlx5_rep_uplink_priv *uplink_priv;
> + struct mlx5e_rep_priv *uplink_rpriv;
> + struct mlx5_tc_ct_priv *ct_priv;
> + struct mapping_ctx *mapping_ctx;
> struct mlx5_eswitch *esw;
> - bool forward_tx = false;
> struct mlx5e_priv *priv;
> - u32 reg_c0;
> - int err;
>
> reg_c0 = (be32_to_cpu(cqe->sop_drop_qpn) & MLX5E_TC_FLOW_ID_MASK);
> if (!reg_c0 || reg_c0 == MLX5_FS_DEFAULT_FLOW_TAG)
> goto forward;
>
> - /* If reg_c0 is not equal to the default flow tag then skb->mark
> + /* If mapped_obj_id is not equal to the default flow tag then skb->mark
> * is not supported and must be reset back to 0.
> */
> skb->mark = 0;
>
> priv = netdev_priv(skb->dev);
> esw = priv->mdev->priv.eswitch;
> - err = mapping_find(esw->offloads.reg_c0_obj_pool, reg_c0, &mapped_obj);
> - if (err) {
> - netdev_dbg(priv->netdev,
> - "Couldn't find mapped object for reg_c0: %d, err: %d\n",
> - reg_c0, err);
> - goto free_skb;
> - }
> + mapping_ctx = esw->offloads.reg_c0_obj_pool;
> + zone_restore_id = reg_c1 & ESW_ZONE_ID_MASK;
> + tunnel_id = (reg_c1 >> ESW_TUN_OFFSET) & TUNNEL_ID_MASK;
>
> - if (mapped_obj.type == MLX5_MAPPED_OBJ_CHAIN) {
> - if (!mlx5e_restore_skb_chain(skb, mapped_obj.chain, reg_c1, &tc_priv) &&
> - !mlx5_ipsec_is_rx_flow(cqe))
> - goto free_skb;
> - } else if (mapped_obj.type == MLX5_MAPPED_OBJ_SAMPLE) {
> - mlx5e_restore_skb_sample(priv, skb, &mapped_obj, &tc_priv);
> - goto free_skb;
> - } else if (mapped_obj.type == MLX5_MAPPED_OBJ_INT_PORT_METADATA) {
> - if (!mlx5e_restore_skb_int_port(priv, skb, &mapped_obj, &tc_priv,
> - &forward_tx, reg_c1))
> - goto free_skb;
> - } else {
> - netdev_dbg(priv->netdev, "Invalid mapped object type: %d\n", mapped_obj.type);
> + uplink_rpriv = mlx5_eswitch_get_uplink_priv(esw, REP_ETH);
> + uplink_priv = &uplink_rpriv->uplink_priv;
> + ct_priv = uplink_priv->ct_priv;
> +
> + if (!mlx5_ipsec_is_rx_flow(cqe) &&
> + !mlx5e_tc_update_skb(cqe, skb, mapping_ctx, reg_c0, ct_priv, zone_restore_id, tunnel_id,
> + &tc_priv))
> goto free_skb;
> - }
>
> forward:
> - if (forward_tx)
> + if (tc_priv.skb_done)
> + goto free_skb;
> +
> + if (tc_priv.forward_tx)
> dev_queue_xmit(skb);
> else
> napi_gro_receive(rq->cq.napi, skb);
>
> - mlx5_rep_tc_post_napi_receive(&tc_priv);
> + if (tc_priv.fwd_dev)
> + dev_put(tc_priv.fwd_dev);
>
> return;
>
> free_skb:
> + WARN_ON(tc_priv.fwd_dev);
Kernel splat which can be triggered from the network by sending traffic
to the target is not good idea.
It is safer to remove this WARN_ON().
Thanks
next prev parent reply other threads:[~2023-01-30 9:35 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-29 10:16 [PATCH net-next v6 0/6] net/sched: cls_api: Support hardware miss to tc action Paul Blakey
2023-01-29 10:16 ` [PATCH net-next v6 1/6] " Paul Blakey
2023-01-29 10:16 ` [PATCH net-next v6 2/6] net/sched: flower: Move filter handle initialization earlier Paul Blakey
2023-01-29 10:16 ` [PATCH net-next v6 3/6] net/sched: flower: Support hardware miss to tc action Paul Blakey
2023-01-29 10:16 ` [PATCH net-next v6 4/6] net/mlx5: Refactor tc miss handling to a single function Paul Blakey
2023-01-30 9:33 ` Leon Romanovsky [this message]
2023-01-29 10:16 ` [PATCH net-next v6 5/6] net/mlx5e: Rename CHAIN_TO_REG to MAPPED_OBJ_TO_REG Paul Blakey
2023-01-29 10:16 ` [PATCH net-next v6 6/6] net/mlx5e: TC, Set CT miss to the specific ct action instance Paul Blakey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Y9eO4rZ6zAyuNk6j@unreal \
--to=leon@kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=jhs@mojatatu.com \
--cc=jiri@nvidia.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=ozsh@nvidia.com \
--cc=pabeni@redhat.com \
--cc=paulb@nvidia.com \
--cc=roid@nvidia.com \
--cc=saeedm@nvidia.com \
--cc=vladbu@nvidia.com \
--cc=xiyou.wangcong@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox