diff mbox series

[intel-net,v2,3/6] ixgbe: add correct exception tracing for XDP

Message ID 20210510093854.31652-4-magnus.karlsson@gmail.com
State New
Headers show
Series i40e: ice: ixgbe: ixgbevf: igb: igc: add correct exception tracing for XDP | expand

Commit Message

Magnus Karlsson May 10, 2021, 9:38 a.m. UTC
From: Magnus Karlsson <magnus.karlsson@intel.com>

Add missing exception tracing to XDP when a number of different
errors can occur. The support was only partial. Several errors
where not logged which would confuse the user quite a lot not
knowing where and why the packets disappeared.

Fixes: 33fdc82f0883 ("ixgbe: add support for XDP_TX action")
Fixes: d0bcacd0a130 ("ixgbe: add AF_XDP zero-copy Rx support")
Reported-by: Jesper Dangaard Brouer <brouer@redhat.com>
Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
---
 drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 16 ++++++++--------
 drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c  | 14 ++++++++------
 2 files changed, 16 insertions(+), 14 deletions(-)

Comments

Jambekar, Vishakha May 28, 2021, 4:16 a.m. UTC | #1
> -----Original Message-----

> From: Intel-wired-lan <intel-wired-lan-bounces@osuosl.org> On Behalf Of

> Magnus Karlsson

> Sent: Monday, May 10, 2021 3:09 PM

> To: Karlsson, Magnus <magnus.karlsson@intel.com>; intel-wired-

> lan@lists.osuosl.org; Nguyen, Anthony L <anthony.l.nguyen@intel.com>;

> Fijalkowski, Maciej <maciej.fijalkowski@intel.com>

> Cc: netdev@vger.kernel.org; brouer@redhat.com

> Subject: [Intel-wired-lan] [PATCH intel-net v2 3/6] ixgbe: add correct

> exception tracing for XDP

> 

> From: Magnus Karlsson <magnus.karlsson@intel.com>

> 

> Add missing exception tracing to XDP when a number of different errors can

> occur. The support was only partial. Several errors where not logged which

> would confuse the user quite a lot not knowing where and why the packets

> disappeared.

> 

> Fixes: 33fdc82f0883 ("ixgbe: add support for XDP_TX action")

> Fixes: d0bcacd0a130 ("ixgbe: add AF_XDP zero-copy Rx support")

> Reported-by: Jesper Dangaard Brouer <brouer@redhat.com>

> Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>

> ---

>  drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 16 ++++++++--------

> drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c  | 14 ++++++++------

>  2 files changed, 16 insertions(+), 14 deletions(-)

> 


Tested-by: Vishakha Jambekar<vishakha.jambekar@intel.com>
diff mbox series

Patch

diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index c5ec17d19c59..2ac5b82676f3 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -2213,23 +2213,23 @@  static struct sk_buff *ixgbe_run_xdp(struct ixgbe_adapter *adapter,
 		break;
 	case XDP_TX:
 		xdpf = xdp_convert_buff_to_frame(xdp);
-		if (unlikely(!xdpf)) {
-			result = IXGBE_XDP_CONSUMED;
-			break;
-		}
+		if (unlikely(!xdpf))
+			goto out_failure;
 		result = ixgbe_xmit_xdp_ring(adapter, xdpf);
+		if (result == IXGBE_XDP_CONSUMED)
+			goto out_failure;
 		break;
 	case XDP_REDIRECT:
 		err = xdp_do_redirect(adapter->netdev, xdp, xdp_prog);
-		if (!err)
-			result = IXGBE_XDP_REDIR;
-		else
-			result = IXGBE_XDP_CONSUMED;
+		if (err)
+			goto out_failure;
+		result = IXGBE_XDP_REDIR;
 		break;
 	default:
 		bpf_warn_invalid_xdp_action(act);
 		fallthrough;
 	case XDP_ABORTED:
+out_failure:
 		trace_xdp_exception(rx_ring->netdev, xdp_prog, act);
 		fallthrough; /* handle aborts by dropping packet */
 	case XDP_DROP:
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c
index 91ad5b902673..f72d2978263b 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c
@@ -106,9 +106,10 @@  static int ixgbe_run_xdp_zc(struct ixgbe_adapter *adapter,
 
 	if (likely(act == XDP_REDIRECT)) {
 		err = xdp_do_redirect(rx_ring->netdev, xdp, xdp_prog);
-		result = !err ? IXGBE_XDP_REDIR : IXGBE_XDP_CONSUMED;
+		if (err)
+			goto out_failure;
 		rcu_read_unlock();
-		return result;
+		return IXGBE_XDP_REDIR;
 	}
 
 	switch (act) {
@@ -116,16 +117,17 @@  static int ixgbe_run_xdp_zc(struct ixgbe_adapter *adapter,
 		break;
 	case XDP_TX:
 		xdpf = xdp_convert_buff_to_frame(xdp);
-		if (unlikely(!xdpf)) {
-			result = IXGBE_XDP_CONSUMED;
-			break;
-		}
+		if (unlikely(!xdpf))
+			goto out_failure;
 		result = ixgbe_xmit_xdp_ring(adapter, xdpf);
+		if (result == IXGBE_XDP_CONSUMED)
+			goto out_failure;
 		break;
 	default:
 		bpf_warn_invalid_xdp_action(act);
 		fallthrough;
 	case XDP_ABORTED:
+out_failure:
 		trace_xdp_exception(rx_ring->netdev, xdp_prog, act);
 		fallthrough; /* handle aborts by dropping packet */
 	case XDP_DROP: