Skip to contentSkip to conversation

Introduce XDP to ena

RFC Superseded [email protected] 2 participants 7 messages Oct 31, 2019 – Nov 2, 2019

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover Introduce XDP to ena

From: Sameeh Jubran <[email protected]>

This patchset includes 3 patches:
* XDP_DROP implementation
* XDP_TX implementation
* A fix for an issue which might occur due to the XDP_TX patch. I see fit to place it as a standalone patch for clarity.

Difference from RFC v1 (XDP_DROP patch):
* Initialized xdp.rxq pointer
* Updated max_mtu on attachment of xdp and removed the check from ena_change_mtu()
* Moved the xdp execution from ena_rx_skb() to ena_clean_rx_irq()
* Moved xdp buff (struct xdp_buff) from rx_ring to the local stack
* Started using netlink's extack mechanism to deliver error messages to the user

Sameeh Jubran (3):
net: ena: implement XDP drop support
net: ena: Implement XDP_TX action
net: ena: Add first_interrupt field to napi struct

 drivers/net/ethernet/amazon/ena/ena_ethtool.c |   4 +-
 drivers/net/ethernet/amazon/ena/ena_netdev.c  | 839 ++++++++++++++++--
 drivers/net/ethernet/amazon/ena/ena_netdev.h  |  70 ++
 3 files changed, 815 insertions(+), 98 deletions(-)
Signature · 1 line
2.17.1
#1 lore raw

RFC v2 1/3 net: ena: implement XDP drop support

From: Sameeh Jubran <[email protected]>

This commit implements the basic functionality of drop/pass logic in the ena driver.

---
 drivers/net/ethernet/amazon/ena/ena_netdev.c | 132 +++++++++++++++++--
 drivers/net/ethernet/amazon/ena/ena_netdev.h |  29 ++++
 2 files changed, 152 insertions(+), 9 deletions(-)
drivers/net/ethernet/amazon/ena/ena_netdev.c +123 -9
index d46a91200..f3f042031 100644
@@ -33,10 +33,10 @@
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
 #ifdef CONFIG_RFS_ACCEL
+#include <linux/bpf_trace.h>
 #include <linux/cpu_rmap.h>
 #endif /* CONFIG_RFS_ACCEL */
 #include <linux/ethtool.h>
-#include <linux/if_vlan.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/numa.h>
@@ -105,6 +105,79 @@ static void update_rx_ring_mtu(struct ena_adapter *adapter, int mtu)
 		adapter->rx_ring[i].mtu = mtu;
 }
 
+static int ena_xdp_execute(struct ena_ring *rx_ring, struct xdp_buff *xdp)
+{
+	struct bpf_prog *xdp_prog = rx_ring->xdp_bpf_prog;
+	u32 verdict = XDP_PASS;
+
+	rcu_read_lock();
+
+	if (!xdp_prog)
+		goto out;
+
+	verdict = bpf_prog_run_xdp(xdp_prog, xdp);
+
+	if (unlikely(verdict == XDP_ABORTED))
+		trace_xdp_exception(rx_ring->netdev, xdp_prog, verdict);
+	else if (unlikely(verdict >= XDP_TX))
+		bpf_warn_invalid_xdp_action(verdict);
+out:
+	rcu_read_unlock();
+	return verdict;
+}
+
+static int ena_xdp_set(struct net_device *netdev, struct netdev_bpf *bpf)
+{
+	struct ena_adapter *adapter = netdev_priv(netdev);
+	struct bpf_prog *prog = bpf->prog;
+	struct bpf_prog *old_bpf_prog;
+	int i, prev_mtu;
+
+	if (ena_xdp_allowed(adapter)) {
+		old_bpf_prog = xchg(&adapter->xdp_bpf_prog, prog);
+
+		for (i = 0; i < adapter->num_io_queues; i++)
+			xchg(&adapter->rx_ring[i].xdp_bpf_prog, prog);
+
+		if (old_bpf_prog)
+			bpf_prog_put(old_bpf_prog);
+
+		prev_mtu = netdev->max_mtu;
+		netdev->max_mtu = prog ? ENA_XDP_MAX_MTU : adapter->max_mtu;
+		netif_info(adapter, drv, adapter->netdev, "xdp program set, changging the max_mtu from %d to %d",
+			   prev_mtu, netdev->max_mtu);
+
+	} else {
+		netif_err(adapter, drv, adapter->netdev, "Failed to set xdp program, the current MTU (%d) is larger than the maximal allowed MTU (%lu) while xdp is on",
+			  netdev->mtu, ENA_XDP_MAX_MTU);
+		NL_SET_ERR_MSG_MOD(bpf->extack, "Failed to set xdp program, the current MTU is larger than the maximal allowed MTU. Check the dmesg for more info");
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+/* This is the main xdp callback, it's used by the kernel to set/unset the xdp
+ * program as well as to query the current xdp program id.
+ */
+static int ena_xdp(struct net_device *netdev, struct netdev_bpf *bpf)
+{
+	struct ena_adapter *adapter = netdev_priv(netdev);
+
+	switch (bpf->command) {
+	case XDP_SETUP_PROG:
+		return ena_xdp_set(netdev, bpf);
+	case XDP_QUERY_PROG:
+		bpf->prog_id = adapter->xdp_bpf_prog ?
+			adapter->xdp_bpf_prog->aux->id : 0;
+		break;
+	default:
+		NL_SET_ERR_MSG_MOD(bpf->extack, "Unsupported XDP command");
+		return -EINVAL;
+	}
+	return 0;
+}
+
 static int ena_change_mtu(struct net_device *dev, int new_mtu)
 {
 	struct ena_adapter *adapter = netdev_priv(dev);
@@ -417,6 +490,9 @@ static void ena_free_rx_resources(struct ena_adapter *adapter,
 
 	vfree(rx_ring->free_ids);
 	rx_ring->free_ids = NULL;
+
+	xdp_rxq_info_unreg_mem_model(&rx_ring->xdp_rxq);
+	xdp_rxq_info_unreg(&rx_ring->xdp_rxq);
 }
 
 /* ena_setup_all_rx_resources - allocate I/O Rx queues resources for all queues
@@ -1051,13 +1127,16 @@ static int ena_clean_rx_irq(struct ena_ring *rx_ring, struct napi_struct *napi,
 	u32 res_budget, work_done;
 
 	struct ena_com_rx_ctx ena_rx_ctx;
+	struct ena_rx_buffer *rx_info;
 	struct ena_adapter *adapter;
-	struct sk_buff *skb;
+	int xdp_verdict = XDP_PASS;
+	struct sk_buff *skb = NULL;
 	int refill_required;
 	int refill_threshold;
-	int rc = 0;
-	int total_len = 0;
+	struct xdp_buff xdp;
 	int rx_copybreak_pkt = 0;
+	int total_len = 0;
+	int rc = 0;
 	int i;
 
 	netif_dbg(rx_ring->adapter, rx_status, rx_ring->netdev,
@@ -1082,12 +1161,24 @@ static int ena_clean_rx_irq(struct ena_ring *rx_ring, struct napi_struct *napi,
 			  rx_ring->qid, ena_rx_ctx.descs, ena_rx_ctx.l3_proto,
 			  ena_rx_ctx.l4_proto, ena_rx_ctx.hash);
 
+		if (ena_xdp_present_ring(rx_ring)) {
+			rx_info = &rx_ring->rx_buffer_info[rx_ring->ena_bufs[0].req_id];
+			xdp.data = page_address(rx_info->page) +
+				rx_info->page_offset;
+			xdp.data_meta = xdp.data;
+			xdp.data_hard_start = xdp.data -
+				rx_info->page_offset;
+			xdp.data_end = xdp.data + rx_ring->ena_bufs[0].len;
+			xdp_verdict = ena_xdp_execute(rx_ring, &xdp);
+		}
+
 		/* allocate skb and fill it */
-		skb = ena_rx_skb(rx_ring, rx_ring->ena_bufs, ena_rx_ctx.descs,
-				 &next_to_clean);
+		if (xdp_verdict == XDP_PASS)
+			skb = ena_rx_skb(rx_ring, rx_ring->ena_bufs,
+					 ena_rx_ctx.descs, &next_to_clean);
 
 		/* exit if we failed to retrieve a buffer */
-		if (unlikely(!skb)) {
+		if (!skb) {
 			for (i = 0; i < ena_rx_ctx.descs; i++) {
 				rx_ring->free_ids[next_to_clean] =
 					rx_ring->ena_bufs[i].req_id;
@@ -1727,12 +1818,34 @@ static int ena_create_io_rx_queue(struct ena_adapter *adapter, int qid)
 		netif_err(adapter, ifup, adapter->netdev,
 			  "Failed to get RX queue handlers. RX queue num %d rc: %d\n",
 			  qid, rc);
-		ena_com_destroy_io_queue(ena_dev, ena_qid);
-		return rc;
+		goto err;
 	}
 
 	ena_com_update_numa_node(rx_ring->ena_com_io_cq, ctx.numa_node);
 
+	rc = xdp_rxq_info_reg(&rx_ring->xdp_rxq, adapter->netdev, qid);
+
+	if (rc) {
+		netif_err(adapter, ifup, adapter->netdev,
+			  "Failed to register xdp rx queue info. RX queue num %d rc: %d\n",
+			  qid, rc);
+		goto err;
+	}
+
+	rc = xdp_rxq_info_reg_mem_model(&rx_ring->xdp_rxq, MEM_TYPE_PAGE_SHARED,
+					NULL);
+
+	if (rc) {
+		netif_err(adapter, ifup, adapter->netdev,
+			  "Failed to register xdp rx queue info memory model. RX queue num %d rc: %d\n",
+			  qid, rc);
+		xdp_rxq_info_unreg(&rx_ring->xdp_rxq);
+		goto err;
+	}
+
+	return rc;
+err:
+	ena_com_destroy_io_queue(ena_dev, ena_qid);
 	return rc;
 }
 
@@ -2568,6 +2681,7 @@ static const struct net_device_ops ena_netdev_ops = {
 	.ndo_change_mtu		= ena_change_mtu,
 	.ndo_set_mac_address	= NULL,
 	.ndo_validate_addr	= eth_validate_addr,
+	.ndo_bpf		= ena_xdp,
 };
 
 static int ena_device_validate_params(struct ena_adapter *adapter,
drivers/net/ethernet/amazon/ena/ena_netdev.h +29 -0
index bffd778f2..baaeeeeb0 100644
@@ -36,6 +36,7 @@
 #include <linux/bitops.h>
 #include <linux/dim.h>
 #include <linux/etherdevice.h>
+#include <linux/if_vlan.h>
 #include <linux/inetdevice.h>
 #include <linux/interrupt.h>
 #include <linux/netdevice.h>
@@ -142,6 +143,14 @@
 
 #define ENA_MMIO_DISABLE_REG_READ	BIT(0)
 
+/* The max MTU size is configured to be the ethernet frame without the overhead
+ * of the ethernet header, which can have VLAN header, and the frame check
+ * sequence (FCS).
+ * The buffer sizes we share with the device are defined to be ENA_PAGE_SIZE
+ */
+#define ENA_XDP_MAX_MTU (ENA_PAGE_SIZE - ETH_HLEN - ETH_FCS_LEN - \
+				VLAN_HLEN - XDP_PACKET_HEADROOM)
+
 struct ena_irq {
 	irq_handler_t handler;
 	void *data;
@@ -291,6 +300,8 @@ struct ena_ring {
 
 	u8 *push_buf_intermediate_buf;
 	int empty_rx_queue;
+	struct bpf_prog *xdp_bpf_prog;
+	struct xdp_rxq_info xdp_rxq;
 } ____cacheline_aligned;
 
 struct ena_stats_dev {
@@ -379,6 +390,9 @@ struct ena_adapter {
 	u32 last_monitored_tx_qid;
 
 	enum ena_regs_reset_reason_types reset_reason;
+
+	/* XDP structures */
+	struct bpf_prog *xdp_bpf_prog;
 };
 
 void ena_set_ethtool_ops(struct net_device *netdev);
@@ -394,4 +408,19 @@ int ena_update_queue_count(struct ena_adapter *adapter, u32 new_channel_count);
 
 int ena_get_sset_count(struct net_device *netdev, int sset);
 
+static inline bool ena_xdp_present(struct ena_adapter *adapter)
+{
+	return !!adapter->xdp_bpf_prog;
+}
+
+static inline bool ena_xdp_present_ring(struct ena_ring *ring)
+{
+	return !!ring->xdp_bpf_prog;
+}
+
+static inline bool ena_xdp_allowed(struct ena_adapter *adapter)
+{
+	return adapter->netdev->mtu <= ENA_XDP_MAX_MTU;
+}
+
 #endif /* !(ENA_H) */
Signature · 1 line
2.17.1
#2 lore raw

Re: [RFC V2 net-next v2 1/3] net: ena: implement XDP drop support

reproduce: wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree…

Hi,

[FYI, it's a private test report for your RFC patch.] [auto build test WARNING on net-next/master]

url:    https://github.com/0day-ci/linux/commits/sameehj-amazon-com/Introduce-XDP-to-ena/20191102-124204
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git c23fcbbc6aa4e0bb615e8a7f23e1f32aec235a1c
config: ia64-allmodconfig (attached as .config)
compiler: ia64-linux-gcc (GCC) 7.4.0

reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=7.4.0 make.cross ARCH=ia64

If you fix the issue, kindly add following tag

All warnings (new ones prefixed by >>):

In file included from arch/ia64/include/uapi/asm/intrinsics.h:22:0,

                    from arch/ia64/include/asm/intrinsics.h:11,
                    from arch/ia64/include/asm/bitops.h:19,
                    from include/linux/bitops.h:26,
                    from include/linux/kernel.h:12,
                    from include/linux/list.h:9,
                    from include/linux/timer.h:5,
                    from include/linux/netdevice.h:24,
                    from include/trace/events/xdp.h:8,
                    from include/linux/bpf_trace.h:5,
                    from drivers/net/ethernet/amazon/ena/ena_netdev.c:36:
   drivers/net/ethernet/amazon/ena/ena_netdev.c: In function 'ena_xdp_set':
   arch/ia64/include/uapi/asm/cmpxchg.h:57:2: warning: value computed is not used [-Wunused-value]
    ((__typeof__(*(ptr))) __xchg((unsigned long) (x), (ptr), sizeof(*(ptr))))
    ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/net/ethernet/amazon/ena/ena_netdev.c:140:4: note: in expansion of macro 'xchg'
       xchg(&adapter->rx_ring[i].xdp_bpf_prog, prog);
       ^~~~

vim +/xchg +140 drivers/net/ethernet/amazon/ena/ena_netdev.c

34
35 #ifdef CONFIG_RFS_ACCEL

  > 36	#include <linux/bpf_trace.h>
    37	#include <linux/cpu_rmap.h>
    38	#endif /* CONFIG_RFS_ACCEL */
    39	#include <linux/ethtool.h>
    40	#include <linux/kernel.h>
    41	#include <linux/module.h>
    42	#include <linux/numa.h>
    43	#include <linux/pci.h>
    44	#include <linux/utsname.h>
    45	#include <linux/version.h>
    46	#include <linux/vmalloc.h>
    47	#include <net/ip.h>
    48	
    49	#include "ena_netdev.h"
    50	#include "ena_pci_id_tbl.h"
    51	
    52	static char version[] = DEVICE_NAME " v" DRV_MODULE_VERSION "\n";
    53	
    54	MODULE_AUTHOR("Amazon.com, Inc. or its affiliates");
    55	MODULE_DESCRIPTION(DEVICE_NAME);
    56	MODULE_LICENSE("GPL");
    57	MODULE_VERSION(DRV_MODULE_VERSION);
    58	
    59	/* Time in jiffies before concluding the transmitter is hung. */
    60	#define TX_TIMEOUT  (5 * HZ)
    61	
    62	#define ENA_NAPI_BUDGET 64
    63	
    64	#define DEFAULT_MSG_ENABLE (NETIF_MSG_DRV | NETIF_MSG_PROBE | NETIF_MSG_IFUP | \
    65			NETIF_MSG_TX_DONE | NETIF_MSG_TX_ERR | NETIF_MSG_RX_ERR)
    66	static int debug = -1;
    67	module_param(debug, int, 0);
    68	MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)");
    69	
    70	static struct ena_aenq_handlers aenq_handlers;
    71	
    72	static struct workqueue_struct *ena_wq;
    73	
    74	MODULE_DEVICE_TABLE(pci, ena_pci_tbl);
    75	
    76	static int ena_rss_init_default(struct ena_adapter *adapter);
    77	static void check_for_admin_com_state(struct ena_adapter *adapter);
    78	static void ena_destroy_device(struct ena_adapter *adapter, bool graceful);
    79	static int ena_restore_device(struct ena_adapter *adapter);
    80	
    81	static void ena_tx_timeout(struct net_device *dev)
    82	{
    83		struct ena_adapter *adapter = netdev_priv(dev);
    84	
    85		/* Change the state of the device to trigger reset
    86		 * Check that we are not in the middle or a trigger already
    87		 */
    88	
    89		if (test_and_set_bit(ENA_FLAG_TRIGGER_RESET, &adapter->flags))
    90			return;
    91	
    92		adapter->reset_reason = ENA_REGS_RESET_OS_NETDEV_WD;
    93		u64_stats_update_begin(&adapter->syncp);
    94		adapter->dev_stats.tx_timeout++;
    95		u64_stats_update_end(&adapter->syncp);
    96	
    97		netif_err(adapter, tx_err, dev, "Transmit time out\n");
    98	}
    99	
   100	static void update_rx_ring_mtu(struct ena_adapter *adapter, int mtu)
   101	{
   102		int i;
   103	
   104		for (i = 0; i < adapter->num_io_queues; i++)
   105			adapter->rx_ring[i].mtu = mtu;
   106	}
   107	
   108	static int ena_xdp_execute(struct ena_ring *rx_ring, struct xdp_buff *xdp)
   109	{
   110		struct bpf_prog *xdp_prog = rx_ring->xdp_bpf_prog;
   111		u32 verdict = XDP_PASS;
   112	
   113		rcu_read_lock();
   114	
   115		if (!xdp_prog)
   116			goto out;
   117	
   118		verdict = bpf_prog_run_xdp(xdp_prog, xdp);
   119	
   120		if (unlikely(verdict == XDP_ABORTED))
   121			trace_xdp_exception(rx_ring->netdev, xdp_prog, verdict);
   122		else if (unlikely(verdict >= XDP_TX))
   123			bpf_warn_invalid_xdp_action(verdict);
   124	out:
   125		rcu_read_unlock();
   126		return verdict;
   127	}
   128	
   129	static int ena_xdp_set(struct net_device *netdev, struct netdev_bpf *bpf)
   130	{
   131		struct ena_adapter *adapter = netdev_priv(netdev);
   132		struct bpf_prog *prog = bpf->prog;
   133		struct bpf_prog *old_bpf_prog;
   134		int i, prev_mtu;
   135	
   136		if (ena_xdp_allowed(adapter)) {
   137			old_bpf_prog = xchg(&adapter->xdp_bpf_prog, prog);
   138	
   139			for (i = 0; i < adapter->num_io_queues; i++)
 > 140				xchg(&adapter->rx_ring[i].xdp_bpf_prog, prog);

141
142 if (old_bpf_prog)
143 bpf_prog_put(old_bpf_prog);
144
145 prev_mtu = netdev->max_mtu;
146 netdev->max_mtu = prog ? ENA_XDP_MAX_MTU : adapter->max_mtu;
147 netif_info(adapter, drv, adapter->netdev, "xdp program set, changging the max_mtu from %d to %d",
148 prev_mtu, netdev->max_mtu);
149
150 } else {
151 netif_err(adapter, drv, adapter->netdev, "Failed to set xdp program, the current MTU (%d) is larger than the maximal allowed MTU (%lu) while xdp is on",
152 netdev->mtu, ENA_XDP_MAX_MTU);
153 NL_SET_ERR_MSG_MOD(bpf->extack, "Failed to set xdp program, the current MTU is larger than the maximal allowed MTU. Check the dmesg for more info");
154 return -EINVAL;
155 }
156
157 return 0;
158 }
159

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

#3 lore raw

Re: [RFC V2 net-next v2 1/3] net: ena: implement XDP drop support

In reply to [email protected]
reproduce:

Hi,

[FYI, it's a private test report for your RFC patch.] [auto build test ERROR on net-next/master]

url:    https://github.com/0day-ci/linux/commits/sameehj-amazon-com/Introduce-XDP-to-ena/20191102-124204
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git c23fcbbc6aa4e0bb615e8a7f23e1f32aec235a1c
config: i386-randconfig-g002-201943 (attached as .config)
compiler: gcc-7 (Debian 7.4.0-14) 7.4.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

If you fix the issue, kindly add following tag

All errors (new ones prefixed by >>):

drivers/net/ethernet/amazon/ena/ena_netdev.c: In function 'ena_xdp_execute':

>> drivers/net/ethernet/amazon/ena/ena_netdev.c:121:3: error: implicit declaration of function 'trace_xdp_exception'; did you mean 'fixup_exception'? [-Werror=implicit-function-declaration]
      trace_xdp_exception(rx_ring->netdev, xdp_prog, verdict);
      ^~~~~~~~~~~~~~~~~~~
      fixup_exception

cc1: some warnings being treated as errors

vim +121 drivers/net/ethernet/amazon/ena/ena_netdev.c

107
108 static int ena_xdp_execute(struct ena_ring *rx_ring, struct xdp_buff *xdp)
109 {
110 struct bpf_prog *xdp_prog = rx_ring->xdp_bpf_prog;
111 u32 verdict = XDP_PASS;
112
113 rcu_read_lock();
114
115 if (!xdp_prog)
116 goto out;
117
118 verdict = bpf_prog_run_xdp(xdp_prog, xdp);
119
120 if (unlikely(verdict == XDP_ABORTED))

 > 121			trace_xdp_exception(rx_ring->netdev, xdp_prog, verdict);

122 else if (unlikely(verdict >= XDP_TX))
123 bpf_warn_invalid_xdp_action(verdict);
124 out:
125 rcu_read_unlock();
126 return verdict;
127 }
128

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

#4 lore raw

RFC v2 2/3 net: ena: Implement XDP_TX action

In reply to [email protected]

From: Sameeh Jubran <[email protected]>

This commit implements the XDP_TX action in the ena driver. We allocate separate tx queues for the XDP_TX. We currently allow xdp only when there is enough queues to allocate for xdp.

---
 drivers/net/ethernet/amazon/ena/ena_ethtool.c |   4 +-
 drivers/net/ethernet/amazon/ena/ena_netdev.c  | 743 +++++++++++++++---
 drivers/net/ethernet/amazon/ena/ena_netdev.h  |  44 +-
 3 files changed, 681 insertions(+), 110 deletions(-)
drivers/net/ethernet/amazon/ena/ena_ethtool.c +3 -1
index a3250dcf7..745fffd42 100644
@@ -744,7 +744,9 @@ static int ena_set_channels(struct net_device *netdev,
 	struct ena_adapter *adapter = netdev_priv(netdev);
 	u32 count = channels->combined_count;
 	/* The check for max value is already done in ethtool */
-	if (count < ENA_MIN_NUM_IO_QUEUES)
+	if (count < ENA_MIN_NUM_IO_QUEUES ||
+	    (ena_xdp_present(adapter) &&
+	    !ena_xdp_legal_queue_count(adapter, channels->combined_count)))
 		return -EINVAL;
 
 	return ena_update_queue_count(adapter, count);
drivers/net/ethernet/amazon/ena/ena_netdev.c +636 -107

1,106 lines not on this page · raw message

drivers/net/ethernet/amazon/ena/ena_netdev.h +42 -2

81 lines not on this page · raw message

Signature · 1 line
2.17.1
#5 lore raw

RFC v2 3/3 net: ena: Add first_interrupt field to napi struct

In reply to [email protected]

From: Sameeh Jubran <[email protected]>

The first_interrupt field is accessed in ena_intr_msix_io() upon receiving an interrupt.The rx_ring and tx_ring fields of napi can be NULL when receiving interrupt for xdp queues. This patch fixes the issue by moving the field to the ena_napi struct.

---
 drivers/net/ethernet/amazon/ena/ena_netdev.c | 6 ++++--
 drivers/net/ethernet/amazon/ena/ena_netdev.h | 1 +
 2 files changed, 5 insertions(+), 2 deletions(-)
drivers/net/ethernet/amazon/ena/ena_netdev.c +4 -2
index 5a90163fa..97b333d07 100644
@@ -1809,6 +1809,9 @@ static int ena_io_poll(struct napi_struct *napi, int budget)
 	tx_ring = ena_napi->tx_ring;
 	rx_ring = ena_napi->rx_ring;
 
+	tx_ring->first_interrupt = ena_napi->first_interrupt;
+	rx_ring->first_interrupt = ena_napi->first_interrupt;
+
 	tx_budget = tx_ring->ring_size / ENA_TX_POLL_BUDGET_DIVIDER;
 
 	if (!test_bit(ENA_FLAG_DEV_UP, &tx_ring->adapter->flags) ||
@@ -1880,8 +1883,7 @@ static irqreturn_t ena_intr_msix_io(int irq, void *data)
 {
 	struct ena_napi *ena_napi = data;
 
-	ena_napi->tx_ring->first_interrupt = true;
-	ena_napi->rx_ring->first_interrupt = true;
+	ena_napi->first_interrupt = true;
 
 	napi_schedule_irqoff(&ena_napi->napi);
 
drivers/net/ethernet/amazon/ena/ena_netdev.h +1 -0
index cb0804947..c666a9cac 100644
@@ -168,6 +168,7 @@ struct ena_napi {
 	struct ena_ring *tx_ring;
 	struct ena_ring *rx_ring;
 	struct ena_ring *xdp_ring;
+	bool first_interrupt;
 	u32 qid;
 	struct dim dim;
 };
Signature · 1 line
2.17.1
#6 lore raw
In reply to [email protected]

This was resent by mistake, please ignore.

Quoted 45 lines

-----Original Message-----
From: [email protected] <[email protected]>
Sent: Thursday, October 31, 2019 6:36 PM
To: [email protected]; [email protected]
Cc: Jubran, Samih <[email protected]>; Woodhouse, David <[email protected]>; Machulsky, Zorik <[email protected]>; Matushevsky, Alexander <[email protected]>; Bshara, Saeed <[email protected]>; Wilson, Matt <[email protected]>; Liguori, Anthony <[email protected]>; Bshara, Nafea <[email protected]>; Tzalik, Guy <[email protected]>; Belgazal, Netanel <[email protected]>; Saidi, Ali <[email protected]>; Herrenschmidt, Benjamin <[email protected]>; Kiyanovski, Arthur <[email protected]>
Subject: [RFC V2 net-next v2 0/3] Introduce XDP to ena

From: Sameeh Jubran <[email protected]>

This patchset includes 3 patches:
* XDP_DROP implementation
* XDP_TX implementation
* A fix for an issue which might occur due to the XDP_TX patch. I see fit to place it as a standalone patch for clarity.

Difference from RFC v1 (XDP_DROP patch):
* Initialized xdp.rxq pointer
* Updated max_mtu on attachment of xdp and removed the check from ena_change_mtu()
* Moved the xdp execution from ena_rx_skb() to ena_clean_rx_irq()
* Moved xdp buff (struct xdp_buff) from rx_ring to the local stack
* Started using netlink's extack mechanism to deliver error messages to the user

Sameeh Jubran (3):
net: ena: implement XDP drop support
net: ena: Implement XDP_TX action
net: ena: Add first_interrupt field to napi struct

 drivers/net/ethernet/amazon/ena/ena_ethtool.c |   4 +-
 drivers/net/ethernet/amazon/ena/ena_netdev.c  | 839
++++++++++++++++--  drivers/net/ethernet/amazon/ena/ena_netdev.h  |
70 ++
 3 files changed, 815 insertions(+), 98 deletions(-)

--
2.17.1