All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH V1 net 0/7] ENA driver bug fixes
@ 2022-12-29  7:30 darinzon
  2022-12-29  7:30 ` [PATCH V1 net 1/7] net: ena: Fix toeplitz initial hash value darinzon
                   ` (7 more replies)
  0 siblings, 8 replies; 11+ messages in thread
From: darinzon @ 2022-12-29  7:30 UTC (permalink / raw)
  To: David Miller, Jakub Kicinski, netdev
  Cc: David Arinzon, Machulsky, Zorik, Matushevsky, Alexander,
	Saeed Bshara, Bshara, Nafea, Saidi, Ali, Kiyanovski, Arthur,
	Dagan, Noam, Agroskin, Shay, Itzko, Shahar, Abboud, Osama

From: David Arinzon <darinzon@amazon.com>

ENA driver bug fixes

David Arinzon (7):
  net: ena: Fix toeplitz initial hash value
  net: ena: Don't register memory info on XDP exchange
  net: ena: Account for the number of processed bytes in XDP
  net: ena: Use bitmask to indicate packet redirection
  net: ena: Fix rx_copybreak value update
  net: ena: Set default value for RX interrupt moderation
  net: ena: Update NUMA TPH hint register upon NUMA node update

 drivers/net/ethernet/amazon/ena/ena_com.c     | 29 ++-----
 drivers/net/ethernet/amazon/ena/ena_ethtool.c |  6 +-
 drivers/net/ethernet/amazon/ena/ena_netdev.c  | 83 ++++++++++++++-----
 drivers/net/ethernet/amazon/ena/ena_netdev.h  | 17 +++-
 4 files changed, 85 insertions(+), 50 deletions(-)

-- 
2.38.1


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH V1 net 1/7] net: ena: Fix toeplitz initial hash value
  2022-12-29  7:30 [PATCH V1 net 0/7] ENA driver bug fixes darinzon
@ 2022-12-29  7:30 ` darinzon
  2022-12-29  7:30 ` [PATCH V1 net 2/7] net: ena: Don't register memory info on XDP exchange darinzon
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: darinzon @ 2022-12-29  7:30 UTC (permalink / raw)
  To: David Miller, Jakub Kicinski, netdev
  Cc: David Arinzon, Machulsky, Zorik, Matushevsky, Alexander,
	Saeed Bshara, Bshara, Nafea, Saidi, Ali, Kiyanovski, Arthur,
	Dagan, Noam, Agroskin, Shay, Itzko, Shahar, Abboud, Osama,
	Nati Koler

From: David Arinzon <darinzon@amazon.com>

On driver initialization, RSS hash initial value is set to zero,
instead of the default value. This happens because we pass NULL as
the RSS key parameter, which caused us to never initialize
the RSS hash value.

This patch fixes it by making sure the initial value is set, no matter
what the value of the RSS key is.

Fixes: 91a65b7d3ed8 ("net: ena: fix potential crash when rxfh key is NULL")
Signed-off-by: Nati Koler <nkoler@amazon.com>
Signed-off-by: David Arinzon <darinzon@amazon.com>
---
 drivers/net/ethernet/amazon/ena/ena_com.c | 29 +++++++----------------
 1 file changed, 9 insertions(+), 20 deletions(-)

diff --git a/drivers/net/ethernet/amazon/ena/ena_com.c b/drivers/net/ethernet/amazon/ena/ena_com.c
index 8c8b4c88c7de..451c3a1b6255 100644
--- a/drivers/net/ethernet/amazon/ena/ena_com.c
+++ b/drivers/net/ethernet/amazon/ena/ena_com.c
@@ -2400,29 +2400,18 @@ int ena_com_fill_hash_function(struct ena_com_dev *ena_dev,
 		return -EOPNOTSUPP;
 	}
 
-	switch (func) {
-	case ENA_ADMIN_TOEPLITZ:
-		if (key) {
-			if (key_len != sizeof(hash_key->key)) {
-				netdev_err(ena_dev->net_device,
-					   "key len (%u) doesn't equal the supported size (%zu)\n",
-					   key_len, sizeof(hash_key->key));
-				return -EINVAL;
-			}
-			memcpy(hash_key->key, key, key_len);
-			rss->hash_init_val = init_val;
-			hash_key->key_parts = key_len / sizeof(hash_key->key[0]);
+	if ((func == ENA_ADMIN_TOEPLITZ) && key) {
+		if (key_len != sizeof(hash_key->key)) {
+			netdev_err(ena_dev->net_device,
+				   "key len (%u) doesn't equal the supported size (%zu)\n",
+				   key_len, sizeof(hash_key->key));
+			return -EINVAL;
 		}
-		break;
-	case ENA_ADMIN_CRC32:
-		rss->hash_init_val = init_val;
-		break;
-	default:
-		netdev_err(ena_dev->net_device, "Invalid hash function (%d)\n",
-			   func);
-		return -EINVAL;
+		memcpy(hash_key->key, key, key_len);
+		hash_key->key_parts = key_len / sizeof(hash_key->key[0]);
 	}
 
+	rss->hash_init_val = init_val;
 	old_func = rss->hash_func;
 	rss->hash_func = func;
 	rc = ena_com_set_hash_function(ena_dev);
-- 
2.38.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH V1 net 2/7] net: ena: Don't register memory info on XDP exchange
  2022-12-29  7:30 [PATCH V1 net 0/7] ENA driver bug fixes darinzon
  2022-12-29  7:30 ` [PATCH V1 net 1/7] net: ena: Fix toeplitz initial hash value darinzon
@ 2022-12-29  7:30 ` darinzon
  2022-12-29  7:30 ` [PATCH V1 net 3/7] net: ena: Account for the number of processed bytes in XDP darinzon
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: darinzon @ 2022-12-29  7:30 UTC (permalink / raw)
  To: David Miller, Jakub Kicinski, netdev
  Cc: David Arinzon, Machulsky, Zorik, Matushevsky, Alexander,
	Saeed Bshara, Bshara, Nafea, Saidi, Ali, Kiyanovski, Arthur,
	Dagan, Noam, Agroskin, Shay, Itzko, Shahar, Abboud, Osama

From: David Arinzon <darinzon@amazon.com>

Since the queues aren't destroyed when we only exchange XDP programs,
there's no need to re-register them again.

Fixes: 548c4940b9f1 ("net: ena: Implement XDP_TX action")
Signed-off-by: Shay Agroskin <shayagr@amazon.com>
Signed-off-by: David Arinzon <darinzon@amazon.com>
---
 drivers/net/ethernet/amazon/ena/ena_netdev.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.c b/drivers/net/ethernet/amazon/ena/ena_netdev.c
index a95529a69cbb..6ba9b06719a0 100644
--- a/drivers/net/ethernet/amazon/ena/ena_netdev.c
+++ b/drivers/net/ethernet/amazon/ena/ena_netdev.c
@@ -512,16 +512,18 @@ static void ena_xdp_exchange_program_rx_in_range(struct ena_adapter *adapter,
 						 struct bpf_prog *prog,
 						 int first, int count)
 {
+	struct bpf_prog *old_bpf_prog;
 	struct ena_ring *rx_ring;
 	int i = 0;
 
 	for (i = first; i < count; i++) {
 		rx_ring = &adapter->rx_ring[i];
-		xchg(&rx_ring->xdp_bpf_prog, prog);
-		if (prog) {
+		old_bpf_prog = xchg(&rx_ring->xdp_bpf_prog, prog);
+
+		if (!old_bpf_prog && prog) {
 			ena_xdp_register_rxq_info(rx_ring);
 			rx_ring->rx_headroom = XDP_PACKET_HEADROOM;
-		} else {
+		} else if (old_bpf_prog && !prog) {
 			ena_xdp_unregister_rxq_info(rx_ring);
 			rx_ring->rx_headroom = NET_SKB_PAD;
 		}
-- 
2.38.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH V1 net 3/7] net: ena: Account for the number of processed bytes in XDP
  2022-12-29  7:30 [PATCH V1 net 0/7] ENA driver bug fixes darinzon
  2022-12-29  7:30 ` [PATCH V1 net 1/7] net: ena: Fix toeplitz initial hash value darinzon
  2022-12-29  7:30 ` [PATCH V1 net 2/7] net: ena: Don't register memory info on XDP exchange darinzon
@ 2022-12-29  7:30 ` darinzon
  2022-12-29  7:30 ` [PATCH V1 net 4/7] net: ena: Use bitmask to indicate packet redirection darinzon
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: darinzon @ 2022-12-29  7:30 UTC (permalink / raw)
  To: David Miller, Jakub Kicinski, netdev
  Cc: David Arinzon, Machulsky, Zorik, Matushevsky, Alexander,
	Saeed Bshara, Bshara, Nafea, Saidi, Ali, Kiyanovski, Arthur,
	Dagan, Noam, Agroskin, Shay, Itzko, Shahar, Abboud, Osama

From: David Arinzon <darinzon@amazon.com>

The size of packets that were forwarded or dropped by XDP wasn't added
to the total processed bytes statistic.

Fixes: 548c4940b9f1 ("net: ena: Implement XDP_TX action")
Signed-off-by: Shay Agroskin <shayagr@amazon.com>
Signed-off-by: David Arinzon <darinzon@amazon.com>
---
 drivers/net/ethernet/amazon/ena/ena_netdev.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.c b/drivers/net/ethernet/amazon/ena/ena_netdev.c
index 6ba9b06719a0..9ae86bd3d457 100644
--- a/drivers/net/ethernet/amazon/ena/ena_netdev.c
+++ b/drivers/net/ethernet/amazon/ena/ena_netdev.c
@@ -1719,6 +1719,7 @@ static int ena_clean_rx_irq(struct ena_ring *rx_ring, struct napi_struct *napi,
 			}
 			if (xdp_verdict != XDP_PASS) {
 				xdp_flags |= xdp_verdict;
+				total_len += ena_rx_ctx.ena_bufs[0].len;
 				res_budget--;
 				continue;
 			}
-- 
2.38.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH V1 net 4/7] net: ena: Use bitmask to indicate packet redirection
  2022-12-29  7:30 [PATCH V1 net 0/7] ENA driver bug fixes darinzon
                   ` (2 preceding siblings ...)
  2022-12-29  7:30 ` [PATCH V1 net 3/7] net: ena: Account for the number of processed bytes in XDP darinzon
@ 2022-12-29  7:30 ` darinzon
  2022-12-29  7:30 ` [PATCH V1 net 5/7] net: ena: Fix rx_copybreak value update darinzon
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: darinzon @ 2022-12-29  7:30 UTC (permalink / raw)
  To: David Miller, Jakub Kicinski, netdev
  Cc: David Arinzon, Machulsky, Zorik, Matushevsky, Alexander,
	Saeed Bshara, Bshara, Nafea, Saidi, Ali, Kiyanovski, Arthur,
	Dagan, Noam, Agroskin, Shay, Itzko, Shahar, Abboud, Osama

From: David Arinzon <darinzon@amazon.com>

Redirecting packets with XDP Redirect is done in two phases:
1. A packet is passed by the driver to the kernel using
   xdp_do_redirect().
2. After finishing polling for new packets the driver lets the kernel
   know that it can now process the redirected packet using
   xdp_do_flush_map().
   The packets' redirection is handled in the napi context of the
   queue that called xdp_do_redirect()

To avoid calling xdp_do_flush_map() each time the driver first checks
whether any packets were redirected, using
	xdp_flags |= xdp_verdict;
and
	if (xdp_flags & XDP_REDIRECT)
	    xdp_do_flush_map()

essentially treating XDP instructions as a bitmask, which isn't the case:
    enum xdp_action {
	    XDP_ABORTED = 0,
	    XDP_DROP,
	    XDP_PASS,
	    XDP_TX,
	    XDP_REDIRECT,
    };

Given the current possible values of xdp_action, the current design
doesn't have a bug (since XDP_REDIRECT = 100b), but it is still
flawed.

This patch makes the driver use a bitmask instead, to avoid future
issues.

Fixes: a318c70ad152 ("net: ena: introduce XDP redirect implementation")
Signed-off-by: Shay Agroskin <shayagr@amazon.com>
Signed-off-by: David Arinzon <darinzon@amazon.com>
---
 drivers/net/ethernet/amazon/ena/ena_netdev.c | 26 ++++++++++++--------
 drivers/net/ethernet/amazon/ena/ena_netdev.h |  9 +++++++
 2 files changed, 25 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.c b/drivers/net/ethernet/amazon/ena/ena_netdev.c
index 9ae86bd3d457..a67f55e5f755 100644
--- a/drivers/net/ethernet/amazon/ena/ena_netdev.c
+++ b/drivers/net/ethernet/amazon/ena/ena_netdev.c
@@ -374,9 +374,9 @@ static int ena_xdp_xmit(struct net_device *dev, int n,
 
 static int ena_xdp_execute(struct ena_ring *rx_ring, struct xdp_buff *xdp)
 {
+	u32 verdict = ENA_XDP_PASS;
 	struct bpf_prog *xdp_prog;
 	struct ena_ring *xdp_ring;
-	u32 verdict = XDP_PASS;
 	struct xdp_frame *xdpf;
 	u64 *xdp_stat;
 
@@ -393,7 +393,7 @@ static int ena_xdp_execute(struct ena_ring *rx_ring, struct xdp_buff *xdp)
 		if (unlikely(!xdpf)) {
 			trace_xdp_exception(rx_ring->netdev, xdp_prog, verdict);
 			xdp_stat = &rx_ring->rx_stats.xdp_aborted;
-			verdict = XDP_ABORTED;
+			verdict = ENA_XDP_DROP;
 			break;
 		}
 
@@ -409,29 +409,35 @@ static int ena_xdp_execute(struct ena_ring *rx_ring, struct xdp_buff *xdp)
 
 		spin_unlock(&xdp_ring->xdp_tx_lock);
 		xdp_stat = &rx_ring->rx_stats.xdp_tx;
+		verdict = ENA_XDP_TX;
 		break;
 	case XDP_REDIRECT:
 		if (likely(!xdp_do_redirect(rx_ring->netdev, xdp, xdp_prog))) {
 			xdp_stat = &rx_ring->rx_stats.xdp_redirect;
+			verdict = ENA_XDP_REDIRECT;
 			break;
 		}
 		trace_xdp_exception(rx_ring->netdev, xdp_prog, verdict);
 		xdp_stat = &rx_ring->rx_stats.xdp_aborted;
-		verdict = XDP_ABORTED;
+		verdict = ENA_XDP_DROP;
 		break;
 	case XDP_ABORTED:
 		trace_xdp_exception(rx_ring->netdev, xdp_prog, verdict);
 		xdp_stat = &rx_ring->rx_stats.xdp_aborted;
+		verdict = ENA_XDP_DROP;
 		break;
 	case XDP_DROP:
 		xdp_stat = &rx_ring->rx_stats.xdp_drop;
+		verdict = ENA_XDP_DROP;
 		break;
 	case XDP_PASS:
 		xdp_stat = &rx_ring->rx_stats.xdp_pass;
+		verdict = ENA_XDP_PASS;
 		break;
 	default:
 		bpf_warn_invalid_xdp_action(rx_ring->netdev, xdp_prog, verdict);
 		xdp_stat = &rx_ring->rx_stats.xdp_invalid;
+		verdict = ENA_XDP_DROP;
 	}
 
 	ena_increase_stat(xdp_stat, 1, &rx_ring->syncp);
@@ -1621,12 +1627,12 @@ static int ena_xdp_handle_buff(struct ena_ring *rx_ring, struct xdp_buff *xdp)
 	 * we expect, then we simply drop it
 	 */
 	if (unlikely(rx_ring->ena_bufs[0].len > ENA_XDP_MAX_MTU))
-		return XDP_DROP;
+		return ENA_XDP_DROP;
 
 	ret = ena_xdp_execute(rx_ring, xdp);
 
 	/* The xdp program might expand the headers */
-	if (ret == XDP_PASS) {
+	if (ret == ENA_XDP_PASS) {
 		rx_info->page_offset = xdp->data - xdp->data_hard_start;
 		rx_ring->ena_bufs[0].len = xdp->data_end - xdp->data;
 	}
@@ -1665,7 +1671,7 @@ static int ena_clean_rx_irq(struct ena_ring *rx_ring, struct napi_struct *napi,
 	xdp_init_buff(&xdp, ENA_PAGE_SIZE, &rx_ring->xdp_rxq);
 
 	do {
-		xdp_verdict = XDP_PASS;
+		xdp_verdict = ENA_XDP_PASS;
 		skb = NULL;
 		ena_rx_ctx.ena_bufs = rx_ring->ena_bufs;
 		ena_rx_ctx.max_bufs = rx_ring->sgl_size;
@@ -1693,7 +1699,7 @@ static int ena_clean_rx_irq(struct ena_ring *rx_ring, struct napi_struct *napi,
 			xdp_verdict = ena_xdp_handle_buff(rx_ring, &xdp);
 
 		/* allocate skb and fill it */
-		if (xdp_verdict == XDP_PASS)
+		if (xdp_verdict == ENA_XDP_PASS)
 			skb = ena_rx_skb(rx_ring,
 					 rx_ring->ena_bufs,
 					 ena_rx_ctx.descs,
@@ -1711,13 +1717,13 @@ static int ena_clean_rx_irq(struct ena_ring *rx_ring, struct napi_struct *napi,
 				/* Packets was passed for transmission, unmap it
 				 * from RX side.
 				 */
-				if (xdp_verdict == XDP_TX || xdp_verdict == XDP_REDIRECT) {
+				if (xdp_verdict & ENA_XDP_FORWARDED) {
 					ena_unmap_rx_buff(rx_ring,
 							  &rx_ring->rx_buffer_info[req_id]);
 					rx_ring->rx_buffer_info[req_id].page = NULL;
 				}
 			}
-			if (xdp_verdict != XDP_PASS) {
+			if (xdp_verdict != ENA_XDP_PASS) {
 				xdp_flags |= xdp_verdict;
 				total_len += ena_rx_ctx.ena_bufs[0].len;
 				res_budget--;
@@ -1763,7 +1769,7 @@ static int ena_clean_rx_irq(struct ena_ring *rx_ring, struct napi_struct *napi,
 		ena_refill_rx_bufs(rx_ring, refill_required);
 	}
 
-	if (xdp_flags & XDP_REDIRECT)
+	if (xdp_flags & ENA_XDP_REDIRECT)
 		xdp_do_flush_map();
 
 	return work_done;
diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.h b/drivers/net/ethernet/amazon/ena/ena_netdev.h
index 1bdce99bf688..290ae9bf47ee 100644
--- a/drivers/net/ethernet/amazon/ena/ena_netdev.h
+++ b/drivers/net/ethernet/amazon/ena/ena_netdev.h
@@ -409,6 +409,15 @@ enum ena_xdp_errors_t {
 	ENA_XDP_NO_ENOUGH_QUEUES,
 };
 
+enum ENA_XDP_ACTIONS {
+	ENA_XDP_PASS		= 0,
+	ENA_XDP_TX		= BIT(0),
+	ENA_XDP_REDIRECT	= BIT(1),
+	ENA_XDP_DROP		= BIT(2)
+};
+
+#define ENA_XDP_FORWARDED (ENA_XDP_TX | ENA_XDP_REDIRECT)
+
 static inline bool ena_xdp_present(struct ena_adapter *adapter)
 {
 	return !!adapter->xdp_bpf_prog;
-- 
2.38.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH V1 net 5/7] net: ena: Fix rx_copybreak value update
  2022-12-29  7:30 [PATCH V1 net 0/7] ENA driver bug fixes darinzon
                   ` (3 preceding siblings ...)
  2022-12-29  7:30 ` [PATCH V1 net 4/7] net: ena: Use bitmask to indicate packet redirection darinzon
@ 2022-12-29  7:30 ` darinzon
  2022-12-29  7:30 ` [PATCH V1 net 6/7] net: ena: Set default value for RX interrupt moderation darinzon
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: darinzon @ 2022-12-29  7:30 UTC (permalink / raw)
  To: David Miller, Jakub Kicinski, netdev
  Cc: David Arinzon, Machulsky, Zorik, Matushevsky, Alexander,
	Saeed Bshara, Bshara, Nafea, Saidi, Ali, Kiyanovski, Arthur,
	Dagan, Noam, Agroskin, Shay, Itzko, Shahar, Abboud, Osama

From: David Arinzon <darinzon@amazon.com>

Make the upper bound on rx_copybreak tighter, by
making sure it is smaller than the minimum of mtu and
ENA_PAGE_SIZE. With the current upper bound of mtu,
rx_copybreak can be larger than a page. Such large
rx_copybreak will not bring any performance benefit to
the user and therefore makes no sense.

In addition, the value update was only reflected in
the adapter structure, but not applied for each ring,
causing it to not take effect.

Fixes: 1738cd3ed342 ("net: ena: Add a driver for Amazon Elastic Network Adapters (ENA)")
Signed-off-by: Osama Abboud <osamaabb@amazon.com>
Signed-off-by: Arthur Kiyanovski <akiyano@amazon.com>
Signed-off-by: David Arinzon <darinzon@amazon.com>
---
 drivers/net/ethernet/amazon/ena/ena_ethtool.c |  6 +-----
 drivers/net/ethernet/amazon/ena/ena_netdev.c  | 18 ++++++++++++++++++
 drivers/net/ethernet/amazon/ena/ena_netdev.h  |  2 ++
 3 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/amazon/ena/ena_ethtool.c b/drivers/net/ethernet/amazon/ena/ena_ethtool.c
index 48ae6d810f8f..8da79eedc057 100644
--- a/drivers/net/ethernet/amazon/ena/ena_ethtool.c
+++ b/drivers/net/ethernet/amazon/ena/ena_ethtool.c
@@ -887,11 +887,7 @@ static int ena_set_tunable(struct net_device *netdev,
 	switch (tuna->id) {
 	case ETHTOOL_RX_COPYBREAK:
 		len = *(u32 *)data;
-		if (len > adapter->netdev->mtu) {
-			ret = -EINVAL;
-			break;
-		}
-		adapter->rx_copybreak = len;
+		ret = ena_set_rx_copybreak(adapter, len);
 		break;
 	default:
 		ret = -EINVAL;
diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.c b/drivers/net/ethernet/amazon/ena/ena_netdev.c
index a67f55e5f755..80a726932e81 100644
--- a/drivers/net/ethernet/amazon/ena/ena_netdev.c
+++ b/drivers/net/ethernet/amazon/ena/ena_netdev.c
@@ -2814,6 +2814,24 @@ int ena_update_queue_sizes(struct ena_adapter *adapter,
 	return dev_was_up ? ena_up(adapter) : 0;
 }
 
+int ena_set_rx_copybreak(struct ena_adapter *adapter, u32 rx_copybreak)
+{
+	struct ena_ring *rx_ring;
+	int i;
+
+	if (rx_copybreak > min_t(u16, adapter->netdev->mtu, ENA_PAGE_SIZE))
+		return -EINVAL;
+
+	adapter->rx_copybreak = rx_copybreak;
+
+	for (i = 0; i < adapter->num_io_queues; i++) {
+		rx_ring = &adapter->rx_ring[i];
+		rx_ring->rx_copybreak = rx_copybreak;
+	}
+
+	return 0;
+}
+
 int ena_update_queue_count(struct ena_adapter *adapter, u32 new_channel_count)
 {
 	struct ena_com_dev *ena_dev = adapter->ena_dev;
diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.h b/drivers/net/ethernet/amazon/ena/ena_netdev.h
index 290ae9bf47ee..f9d862b630fa 100644
--- a/drivers/net/ethernet/amazon/ena/ena_netdev.h
+++ b/drivers/net/ethernet/amazon/ena/ena_netdev.h
@@ -392,6 +392,8 @@ int ena_update_queue_sizes(struct ena_adapter *adapter,
 
 int ena_update_queue_count(struct ena_adapter *adapter, u32 new_channel_count);
 
+int ena_set_rx_copybreak(struct ena_adapter *adapter, u32 rx_copybreak);
+
 int ena_get_sset_count(struct net_device *netdev, int sset);
 
 static inline void ena_reset_device(struct ena_adapter *adapter,
-- 
2.38.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH V1 net 6/7] net: ena: Set default value for RX interrupt moderation
  2022-12-29  7:30 [PATCH V1 net 0/7] ENA driver bug fixes darinzon
                   ` (4 preceding siblings ...)
  2022-12-29  7:30 ` [PATCH V1 net 5/7] net: ena: Fix rx_copybreak value update darinzon
@ 2022-12-29  7:30 ` darinzon
  2022-12-29  7:30 ` [PATCH V1 net 7/7] net: ena: Update NUMA TPH hint register upon NUMA node update darinzon
  2022-12-30  7:50 ` [PATCH V1 net 0/7] ENA driver bug fixes patchwork-bot+netdevbpf
  7 siblings, 0 replies; 11+ messages in thread
From: darinzon @ 2022-12-29  7:30 UTC (permalink / raw)
  To: David Miller, Jakub Kicinski, netdev
  Cc: David Arinzon, Machulsky, Zorik, Matushevsky, Alexander,
	Saeed Bshara, Bshara, Nafea, Saidi, Ali, Kiyanovski, Arthur,
	Dagan, Noam, Agroskin, Shay, Itzko, Shahar, Abboud, Osama

From: David Arinzon <darinzon@amazon.com>

RX ring can be NULL in XDP use cases where only TX queues
are configured. In this scenario, the RX interrupt moderation
value sent to the device remains in its default value of 0.

In this change, setting the default value of the RX interrupt
moderation to be the same as of the TX.

Fixes: 548c4940b9f1 ("net: ena: Implement XDP_TX action")
Signed-off-by: David Arinzon <darinzon@amazon.com>
---
 drivers/net/ethernet/amazon/ena/ena_netdev.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.c b/drivers/net/ethernet/amazon/ena/ena_netdev.c
index 80a726932e81..99f80c2d560a 100644
--- a/drivers/net/ethernet/amazon/ena/ena_netdev.c
+++ b/drivers/net/ethernet/amazon/ena/ena_netdev.c
@@ -1823,8 +1823,9 @@ static void ena_adjust_adaptive_rx_intr_moderation(struct ena_napi *ena_napi)
 static void ena_unmask_interrupt(struct ena_ring *tx_ring,
 					struct ena_ring *rx_ring)
 {
+	u32 rx_interval = tx_ring->smoothed_interval;
 	struct ena_eth_io_intr_reg intr_reg;
-	u32 rx_interval = 0;
+
 	/* Rx ring can be NULL when for XDP tx queues which don't have an
 	 * accompanying rx_ring pair.
 	 */
-- 
2.38.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH V1 net 7/7] net: ena: Update NUMA TPH hint register upon NUMA node update
  2022-12-29  7:30 [PATCH V1 net 0/7] ENA driver bug fixes darinzon
                   ` (5 preceding siblings ...)
  2022-12-29  7:30 ` [PATCH V1 net 6/7] net: ena: Set default value for RX interrupt moderation darinzon
@ 2022-12-29  7:30 ` darinzon
  2022-12-30  7:50 ` [PATCH V1 net 0/7] ENA driver bug fixes patchwork-bot+netdevbpf
  7 siblings, 0 replies; 11+ messages in thread
From: darinzon @ 2022-12-29  7:30 UTC (permalink / raw)
  To: David Miller, Jakub Kicinski, netdev
  Cc: David Arinzon, Machulsky, Zorik, Matushevsky, Alexander,
	Saeed Bshara, Bshara, Nafea, Saidi, Ali, Kiyanovski, Arthur,
	Dagan, Noam, Agroskin, Shay, Itzko, Shahar, Abboud, Osama

From: David Arinzon <darinzon@amazon.com>

The device supports a PCIe optimization hint, which indicates on
which NUMA the queue is currently processed. This hint is utilized
by PCIe in order to reduce its access time by accessing the
correct NUMA resources and maintaining cache coherence.

The driver calls the register update for the hint (called TPH -
TLP Processing Hint) during the NAPI loop.

Though the update is expected upon a NUMA change (when a queue
is moved from one NUMA to the other), the current logic performs
a register update when the queue is moved to a different CPU,
but the CPU is not necessarily in a different NUMA.

The changes include:
1. Performing the TPH update only when the queue has switched
a NUMA node.
2. Moving the TPH update call to be triggered only when NAPI was
scheduled from interrupt context, as opposed to a busy-polling loop.
This is due to the fact that during busy-polling, the frequency
of CPU switches for a particular queue is significantly higher,
thus, the likelihood to switch NUMA is much higher. Therefore,
providing the frequent updates to the device upon a NUMA update
are unlikely to be beneficial.

Fixes: 1738cd3ed342 ("net: ena: Add a driver for Amazon Elastic Network Adapters (ENA)")
Signed-off-by: David Arinzon <darinzon@amazon.com>
---
 drivers/net/ethernet/amazon/ena/ena_netdev.c | 27 +++++++++++++-------
 drivers/net/ethernet/amazon/ena/ena_netdev.h |  6 +++--
 2 files changed, 22 insertions(+), 11 deletions(-)

diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.c b/drivers/net/ethernet/amazon/ena/ena_netdev.c
index 99f80c2d560a..e8ad5ea31aff 100644
--- a/drivers/net/ethernet/amazon/ena/ena_netdev.c
+++ b/drivers/net/ethernet/amazon/ena/ena_netdev.c
@@ -680,6 +680,7 @@ static void ena_init_io_rings_common(struct ena_adapter *adapter,
 	ring->ena_dev = adapter->ena_dev;
 	ring->per_napi_packets = 0;
 	ring->cpu = 0;
+	ring->numa_node = 0;
 	ring->no_interrupt_event_cnt = 0;
 	u64_stats_init(&ring->syncp);
 }
@@ -783,6 +784,7 @@ static int ena_setup_tx_resources(struct ena_adapter *adapter, int qid)
 	tx_ring->next_to_use = 0;
 	tx_ring->next_to_clean = 0;
 	tx_ring->cpu = ena_irq->cpu;
+	tx_ring->numa_node = node;
 	return 0;
 
 err_push_buf_intermediate_buf:
@@ -915,6 +917,7 @@ static int ena_setup_rx_resources(struct ena_adapter *adapter,
 	rx_ring->next_to_clean = 0;
 	rx_ring->next_to_use = 0;
 	rx_ring->cpu = ena_irq->cpu;
+	rx_ring->numa_node = node;
 
 	return 0;
 }
@@ -1863,20 +1866,27 @@ static void ena_update_ring_numa_node(struct ena_ring *tx_ring,
 	if (likely(tx_ring->cpu == cpu))
 		goto out;
 
+	tx_ring->cpu = cpu;
+	if (rx_ring)
+		rx_ring->cpu = cpu;
+
 	numa_node = cpu_to_node(cpu);
+
+	if (likely(tx_ring->numa_node == numa_node))
+		goto out;
+
 	put_cpu();
 
 	if (numa_node != NUMA_NO_NODE) {
 		ena_com_update_numa_node(tx_ring->ena_com_io_cq, numa_node);
-		if (rx_ring)
+		tx_ring->numa_node = numa_node;
+		if (rx_ring) {
+			rx_ring->numa_node = numa_node;
 			ena_com_update_numa_node(rx_ring->ena_com_io_cq,
 						 numa_node);
+		}
 	}
 
-	tx_ring->cpu = cpu;
-	if (rx_ring)
-		rx_ring->cpu = cpu;
-
 	return;
 out:
 	put_cpu();
@@ -1997,11 +2007,10 @@ static int ena_io_poll(struct napi_struct *napi, int budget)
 			if (ena_com_get_adaptive_moderation_enabled(rx_ring->ena_dev))
 				ena_adjust_adaptive_rx_intr_moderation(ena_napi);
 
+			ena_update_ring_numa_node(tx_ring, rx_ring);
 			ena_unmask_interrupt(tx_ring, rx_ring);
 		}
 
-		ena_update_ring_numa_node(tx_ring, rx_ring);
-
 		ret = rx_work_done;
 	} else {
 		ret = budget;
@@ -2386,7 +2395,7 @@ static int ena_create_io_tx_queue(struct ena_adapter *adapter, int qid)
 	ctx.mem_queue_type = ena_dev->tx_mem_queue_type;
 	ctx.msix_vector = msix_vector;
 	ctx.queue_size = tx_ring->ring_size;
-	ctx.numa_node = cpu_to_node(tx_ring->cpu);
+	ctx.numa_node = tx_ring->numa_node;
 
 	rc = ena_com_create_io_queue(ena_dev, &ctx);
 	if (rc) {
@@ -2454,7 +2463,7 @@ static int ena_create_io_rx_queue(struct ena_adapter *adapter, int qid)
 	ctx.mem_queue_type = ENA_ADMIN_PLACEMENT_POLICY_HOST;
 	ctx.msix_vector = msix_vector;
 	ctx.queue_size = rx_ring->ring_size;
-	ctx.numa_node = cpu_to_node(rx_ring->cpu);
+	ctx.numa_node = rx_ring->numa_node;
 
 	rc = ena_com_create_io_queue(ena_dev, &ctx);
 	if (rc) {
diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.h b/drivers/net/ethernet/amazon/ena/ena_netdev.h
index f9d862b630fa..2cb141079474 100644
--- a/drivers/net/ethernet/amazon/ena/ena_netdev.h
+++ b/drivers/net/ethernet/amazon/ena/ena_netdev.h
@@ -262,9 +262,11 @@ struct ena_ring {
 	bool disable_meta_caching;
 	u16 no_interrupt_event_cnt;
 
-	/* cpu for TPH */
+	/* cpu and NUMA for TPH */
 	int cpu;
-	 /* number of tx/rx_buffer_info's entries */
+	int numa_node;
+
+	/* number of tx/rx_buffer_info's entries */
 	int ring_size;
 
 	enum ena_admin_placement_policy_type tx_mem_queue_type;
-- 
2.38.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH V1 net 0/7] ENA driver bug fixes
  2022-12-29  7:30 [PATCH V1 net 0/7] ENA driver bug fixes darinzon
                   ` (6 preceding siblings ...)
  2022-12-29  7:30 ` [PATCH V1 net 7/7] net: ena: Update NUMA TPH hint register upon NUMA node update darinzon
@ 2022-12-30  7:50 ` patchwork-bot+netdevbpf
  7 siblings, 0 replies; 11+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-12-30  7:50 UTC (permalink / raw)
  To: darinzon
  Cc: davem, kuba, netdev, zorik, matua, saeedb, nafea, alisaidi,
	akiyano, ndagan, shayagr, itzko, osamaabb

Hello:

This series was applied to netdev/net.git (master)
by David S. Miller <davem@davemloft.net>:

On Thu, 29 Dec 2022 07:30:04 +0000 you wrote:
> From: David Arinzon <darinzon@amazon.com>
> 
> ENA driver bug fixes
> 
> David Arinzon (7):
>   net: ena: Fix toeplitz initial hash value
>   net: ena: Don't register memory info on XDP exchange
>   net: ena: Account for the number of processed bytes in XDP
>   net: ena: Use bitmask to indicate packet redirection
>   net: ena: Fix rx_copybreak value update
>   net: ena: Set default value for RX interrupt moderation
>   net: ena: Update NUMA TPH hint register upon NUMA node update
> 
> [...]

Here is the summary with links:
  - [V1,net,1/7] net: ena: Fix toeplitz initial hash value
    https://git.kernel.org/netdev/net/c/332b49ff637d
  - [V1,net,2/7] net: ena: Don't register memory info on XDP exchange
    https://git.kernel.org/netdev/net/c/9c9e539956fa
  - [V1,net,3/7] net: ena: Account for the number of processed bytes in XDP
    https://git.kernel.org/netdev/net/c/c7f5e34d9063
  - [V1,net,4/7] net: ena: Use bitmask to indicate packet redirection
    https://git.kernel.org/netdev/net/c/59811faa2c54
  - [V1,net,5/7] net: ena: Fix rx_copybreak value update
    https://git.kernel.org/netdev/net/c/c7062aaee099
  - [V1,net,6/7] net: ena: Set default value for RX interrupt moderation
    https://git.kernel.org/netdev/net/c/e712f3e4920b
  - [V1,net,7/7] net: ena: Update NUMA TPH hint register upon NUMA node update
    https://git.kernel.org/netdev/net/c/a8ee104f986e

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH V1 net 0/7] ENA driver bug fixes
  2020-03-16 12:38 akiyano
@ 2020-03-16 22:00 ` David Miller
  0 siblings, 0 replies; 11+ messages in thread
From: David Miller @ 2020-03-16 22:00 UTC (permalink / raw)
  To: akiyano
  Cc: netdev, dwmw, zorik, matua, saeedb, msw, aliguori, nafea,
	gtzalik, netanel, alisaidi, benh, ndagan, shayagr, sameehj

From: <akiyano@amazon.com>
Date: Mon, 16 Mar 2020 14:38:17 +0200

> From: Arthur Kiyanovski <akiyano@amazon.com>
> 
> ENA driver bug fixes

Please repost this series, removing the patches that aren't actually bug
fixes but that are rather just cleanups.

Thank you.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH V1 net 0/7] ENA driver bug fixes
@ 2020-03-16 12:38 akiyano
  2020-03-16 22:00 ` David Miller
  0 siblings, 1 reply; 11+ messages in thread
From: akiyano @ 2020-03-16 12:38 UTC (permalink / raw)
  To: davem, netdev
  Cc: Arthur Kiyanovski, dwmw, zorik, matua, saeedb, msw, aliguori,
	nafea, gtzalik, netanel, alisaidi, benh, ndagan, shayagr,
	sameehj

From: Arthur Kiyanovski <akiyano@amazon.com>

ENA driver bug fixes

Arthur Kiyanovski (7):
  net: ena: fix incorrect setting of the number of msix vectors
  net: ena: avoid unnecessary admin command when RSS function set fails
  net: ena: fix inability to set RSS hash function without changing the
    key
  net: ena: remove code that does nothing
  net: ena: fix request of incorrect number of IRQ vectors
  net: ena: avoid memory access violation by validating req_id properly
  net: ena: fix continuous keep-alive resets

 drivers/net/ethernet/amazon/ena/ena_com.c     | 17 ++++++++----
 drivers/net/ethernet/amazon/ena/ena_com.h     | 21 ++++++++++-----
 drivers/net/ethernet/amazon/ena/ena_ethtool.c | 15 +++++------
 drivers/net/ethernet/amazon/ena/ena_netdev.c  | 27 +++++++++++++------
 4 files changed, 52 insertions(+), 28 deletions(-)

-- 
2.17.1


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2022-12-30  7:50 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-29  7:30 [PATCH V1 net 0/7] ENA driver bug fixes darinzon
2022-12-29  7:30 ` [PATCH V1 net 1/7] net: ena: Fix toeplitz initial hash value darinzon
2022-12-29  7:30 ` [PATCH V1 net 2/7] net: ena: Don't register memory info on XDP exchange darinzon
2022-12-29  7:30 ` [PATCH V1 net 3/7] net: ena: Account for the number of processed bytes in XDP darinzon
2022-12-29  7:30 ` [PATCH V1 net 4/7] net: ena: Use bitmask to indicate packet redirection darinzon
2022-12-29  7:30 ` [PATCH V1 net 5/7] net: ena: Fix rx_copybreak value update darinzon
2022-12-29  7:30 ` [PATCH V1 net 6/7] net: ena: Set default value for RX interrupt moderation darinzon
2022-12-29  7:30 ` [PATCH V1 net 7/7] net: ena: Update NUMA TPH hint register upon NUMA node update darinzon
2022-12-30  7:50 ` [PATCH V1 net 0/7] ENA driver bug fixes patchwork-bot+netdevbpf
  -- strict thread matches above, loose matches on Subject: below --
2020-03-16 12:38 akiyano
2020-03-16 22:00 ` David Miller

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.