All of lore.kernel.org
 help / color / mirror / Atom feed
From: Saeed Mahameed <saeedm@mellanox.com>
To: "David S. Miller" <davem@davemloft.net>
Cc: netdev@vger.kernel.org, Saeed Mahameed <saeedm@mellanox.com>,
	Tariq Toukan <tariqt@mellanox.com>
Subject: [net 05/10] net/mlx5e: XDP, Avoid checksum complete when XDP prog is loaded
Date: Tue,  9 Apr 2019 12:36:31 -0700	[thread overview]
Message-ID: <20190409193636.13663-6-saeedm@mellanox.com> (raw)
In-Reply-To: <20190409193636.13663-1-saeedm@mellanox.com>

XDP programs might change packets data contents which will make the
reported skb checksum (checksum complete) invalid.

When XDP programs are loaded/unloaded set/clear rx RQs
MLX5E_RQ_STATE_NO_CSUM_COMPLETE flag.

Fixes: 86994156c736 ("net/mlx5e: XDP fast RX drop bpf programs support")
Reviewed-by: Tariq Toukan <tariqt@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c | 3 ++-
 drivers/net/ethernet/mellanox/mlx5/core/en_main.c    | 6 +++++-
 drivers/net/ethernet/mellanox/mlx5/core/en_rx.c      | 3 ++-
 3 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
index 5efce4a3ff79..76a3d01a489e 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
@@ -1768,7 +1768,8 @@ static int set_pflag_rx_no_csum_complete(struct net_device *netdev, bool enable)
 	struct mlx5e_channel *c;
 	int i;
 
-	if (!test_bit(MLX5E_STATE_OPENED, &priv->state))
+	if (!test_bit(MLX5E_STATE_OPENED, &priv->state) ||
+	    priv->channels.params.xdp_prog)
 		return 0;
 
 	for (i = 0; i < channels->num; i++) {
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index 002e2adb3722..4187c43b20ad 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -951,7 +951,11 @@ static int mlx5e_open_rq(struct mlx5e_channel *c,
 	if (params->rx_dim_enabled)
 		__set_bit(MLX5E_RQ_STATE_AM, &c->rq.state);
 
-	if (MLX5E_GET_PFLAG(params, MLX5E_PFLAG_RX_NO_CSUM_COMPLETE))
+	/* We disable csum_complete when XDP is enabled since
+	 * XDP programs might manipulate packets which will render
+	 * skb->checksum incorrect.
+	 */
+	if (MLX5E_GET_PFLAG(params, MLX5E_PFLAG_RX_NO_CSUM_COMPLETE) || c->xdp)
 		__set_bit(MLX5E_RQ_STATE_NO_CSUM_COMPLETE, &c->rq.state);
 
 	return 0;
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
index 3dde5c7e0739..91af48344743 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
@@ -752,7 +752,8 @@ static inline void mlx5e_handle_csum(struct net_device *netdev,
 		return;
 	}
 
-	if (unlikely(test_bit(MLX5E_RQ_STATE_NO_CSUM_COMPLETE, &rq->state)))
+	/* True when explicitly set via priv flag, or XDP prog is loaded */
+	if (test_bit(MLX5E_RQ_STATE_NO_CSUM_COMPLETE, &rq->state))
 		goto csum_unnecessary;
 
 	/* CQE csum doesn't cover padding octets in short ethernet
-- 
2.20.1


  parent reply	other threads:[~2019-04-09 19:37 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-09 19:36 [pull request][net 00/10] Mellanox, mlx5 fixes 2019-04-09 Saeed Mahameed
2019-04-09 19:36 ` [net 01/10] net/mlx5: FPGA, tls, hold rcu read lock a bit longer Saeed Mahameed
2019-04-09 19:36 ` [net 02/10] net/mlx5: FPGA, tls, idr remove on flow delete Saeed Mahameed
2019-04-09 19:36 ` [net 03/10] net/mlx5e: Skip un-needed tx recover if interface state is down Saeed Mahameed
2019-04-09 19:36 ` [net 04/10] net/mlx5e: Use fail-safe channels reopen in tx reporter recover Saeed Mahameed
2019-04-09 19:36 ` Saeed Mahameed [this message]
2019-04-09 19:36 ` [net 06/10] net/mlx5e: Rx, Fixup skb checksum for packets with tail padding Saeed Mahameed
2019-04-09 19:36 ` [net 07/10] net/mlx5e: Rx, Check ip headers sanity Saeed Mahameed
2019-04-09 19:36 ` [net 08/10] net/mlx5e: Protect against non-uplink representor for encap Saeed Mahameed
2019-04-09 19:36 ` [net 09/10] Revert "net/mlx5e: Enable reporting checksum unnecessary also for L3 packets" Saeed Mahameed
2019-04-09 19:36 ` [net 10/10] net/mlx5e: Switch to Toeplitz RSS hash by default Saeed Mahameed
2019-04-11 21:12 ` [pull request][net 00/10] Mellanox, mlx5 fixes 2019-04-09 David Miller
2019-04-14 22:12 ` David Miller

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=20190409193636.13663-6-saeedm@mellanox.com \
    --to=saeedm@mellanox.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=tariqt@mellanox.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.