ice: add support for devmem/io_uring Rx and Tx
Alexander Lobakin
maintainerv5 cover ice: add support for devmem/io_uring Rx and Tx
Now that ice uses libeth for managing Rx buffers and supports configurable header split, it's ready to get support for sending and receiving packets with unreadable (to the kernel) frags.
Extend libeth just a little bit to allow creating PPs with custom memory providers and make sure ice works correctly with the netdev ops locking. Then add the full set of queue_mgmt_ops and don't unmap unreadable frags on Tx completion.
No perf regressions for the regular flows and no code duplication implied.
Credits to the fbnic developers, whose code helped me understand the memory providers and queue_mgmt_ops logics and served as a reference.
Alexander Lobakin (5):
libeth: pass Rx queue index to PP when creating a fill queue
libeth: handle creating pools with unreadable buffers
ice: migrate to netdev ops lock
ice: implement Rx queue management ops
ice: add support for transmitting unreadable frags
drivers/net/ethernet/intel/ice/ice_base.h | 2 + drivers/net/ethernet/intel/ice/ice_lib.h | 18 +- drivers/net/ethernet/intel/ice/ice_txrx.h | 2 + drivers/net/ethernet/intel/idpf/idpf_txrx.h | 2 + include/net/libeth/rx.h | 2 + include/net/libeth/tx.h | 2 +- drivers/net/ethernet/intel/iavf/iavf_txrx.c | 1 + drivers/net/ethernet/intel/ice/ice_base.c | 247 +++++++++++++++---- drivers/net/ethernet/intel/ice/ice_dcb_lib.c | 15 +- drivers/net/ethernet/intel/ice/ice_eswitch.c | 26 +- drivers/net/ethernet/intel/ice/ice_lib.c | 227 +++++++++++++---- drivers/net/ethernet/intel/ice/ice_main.c | 79 +++--- drivers/net/ethernet/intel/ice/ice_sf_eth.c | 4 + drivers/net/ethernet/intel/ice/ice_txrx.c | 43 +++- drivers/net/ethernet/intel/ice/ice_xsk.c | 4 +- drivers/net/ethernet/intel/idpf/idpf_txrx.c | 13 + drivers/net/ethernet/intel/libeth/rx.c | 43 ++++ 17 files changed, 566 insertions(+), 164 deletions(-)
---
Note: apply to net-next, not Tony's next-queue (ready to be sent as a PR).
From v4[0]:
* rebase on top of the latest net-next;
* 3/5: fix the last [hopefully] missing netdev lock (E-Switch code,
Simon), rechecked with our internal Intel's Sashiko setup;
* 3/5: pick fixes for .ndo_bpf() and safe mode from Kohei.
From v3[1]:
* rebase on top of recent Larysa's changes;
* 3/5: fix the last locking inconsistencies (Jakub);
* 3/5: pick a kdoc fix from Tony.
From v2[2]:
* rebase on top of net-next-7.0;
* 3/5: fix [hopefully] all inconsistent locking (Jakub, Tony);
* 4/5: pick a hotfix from Kohei.
From v1[3]:
* rebase on top of the latest next-queue;
* fix a typo 'rxq_ixd' -> 'rxq_idx' (Tony).
Testing hints:
* regular Rx and Tx for regressions;
* <kernel root>/tools/testing/selftests/drivers/net/hw/ contains scripts for testing netmem Rx and Tx, namely devmem.py and iou-zcrx.py (read the documentation first).
[0] https://lore.kernel.org/intel-wired-lan/[email protected]
[1] https://lore.kernel.org/intel-wired-lan/[email protected]
[2] https://lore.kernel.org/intel-wired-lan/[email protected]
[3] https://lore.kernel.org/intel-wired-lan/[email protected]
Signature · 1 line
2.54.0
Alexander Lobakin
maintainerPATCH v5 1/5 libeth: pass Rx queue index to PP when creating a fill queue
Since recently, page_pool_create() accepts optional stack index of the Rx queue which the pool will be created for. It can then be used on control path for stuff like memory providers. Add the same field to libeth_fq and pass the index from all the drivers using libeth for managing Rx to simplify implementing MP support later.
idpf has one libeth_fq per buffer/fill queue and each Rx queue has two fill queues, but since fill queues can never be shared, we can store the corresponding Rx queue index there during the initialization to pass it to libeth.
--- drivers/net/ethernet/intel/idpf/idpf_txrx.h | 2 ++ include/net/libeth/rx.h | 2 ++ drivers/net/ethernet/intel/iavf/iavf_txrx.c | 1 + drivers/net/ethernet/intel/ice/ice_base.c | 2 ++ drivers/net/ethernet/intel/idpf/idpf_txrx.c | 13 +++++++++++++ drivers/net/ethernet/intel/libeth/rx.c | 1 + 6 files changed, 21 insertions(+)
drivers/net/ethernet/intel/idpf/idpf_txrx.h +2 -0
@@ -748,6 +748,7 @@ libeth_cacheline_set_assert(struct idpf_tx_queue, 64,* @size: Length of descriptor ring in bytes * @dma: Physical address of ring * @q_vector: Backreference to associated vector +* @rxq_idx: stack index of the corresponding Rx queue * @rx_buffer_low_watermark: RX buffer low watermark * @rx_hbuf_size: Header buffer size * @rx_buf_size: Buffer size
@@ -791,6 +792,7 @@ struct idpf_buf_queue {dma_addr_t dma;struct idpf_q_vector *q_vector; +u16 rxq_idx;u16 rx_buffer_low_watermark;u16 rx_hbuf_size;
include/net/libeth/rx.h +2 -0
@@ -71,6 +71,7 @@ enum libeth_fqe_type {* @xdp: flag indicating whether XDP is enabled * @buf_len: HW-writeable length per each buffer * @nid: ID of the closest NUMA node with memory +* @idx: stack index of the corresponding Rx queue */ struct libeth_fq { struct_group_tagged(libeth_fq_fp, fp,
@@ -88,6 +89,7 @@ struct libeth_fq {u32 buf_len;int nid; +u32 idx; };int libeth_rx_fq_create (struct libeth_fq *fq,struct napi_struct *napi);
drivers/net/ethernet/intel/iavf/iavf_txrx.c +1 -0
@@ -771,6 +771,7 @@ int iavf_setup_rx_descriptors(struct iavf_ring *rx_ring) .count = rx_ring->count, .buf_len = LIBIE_MAX_RX_BUF_LEN, .nid = NUMA_NO_NODE, + .idx = rx_ring->queue_index, };int ret;
drivers/net/ethernet/intel/ice/ice_base.c +2 -0
@@ -609,6 +609,7 @@ static int ice_rxq_pp_create(struct ice_rx_ring *rq)struct libeth_fq fq = { .count = rq->count, .nid =NUMA_NO_NODE , + .idx = rq->q_index, .hsplit = rq->vsi->hsplit, .xdp =ice_is_xdp_ena_vsi (rq->vsi), .buf_len =LIBIE_MAX_RX_BUF_LEN ,
@@ -631,6 +632,7 @@ static int ice_rxq_pp_create(struct ice_rx_ring *rq) .count = rq->count, .type = LIBETH_FQE_HDR, .nid = NUMA_NO_NODE, + .idx = rq->q_index, .xdp = ice_is_xdp_ena_vsi(rq->vsi), };
drivers/net/ethernet/intel/idpf/idpf_txrx.c +13 -0
@@ -557,6 +557,7 @@ static int idpf_rx_hdr_buf_alloc_all(struct idpf_buf_queue *bufq) .type = LIBETH_FQE_HDR, .xdp = idpf_xdp_enabled(bufq->q_vector->vport), .nid = idpf_q_vector_to_mem(bufq->q_vector), + .idx = bufq->rxq_idx, };int ret;
@@ -699,6 +700,7 @@ static int idpf_rx_bufs_init_singleq(struct idpf_rx_queue *rxq) .type = LIBETH_FQE_MTU, .buf_len = IDPF_RX_MAX_BUF_SZ, .nid = idpf_q_vector_to_mem(rxq->q_vector), + .idx = rxq->idx, };int ret;
@@ -759,6 +761,7 @@ static int idpf_rx_bufs_init(struct idpf_buf_queue *bufq, .hsplit = idpf_queue_has(HSPLIT_EN, bufq), .xdp = idpf_xdp_enabled(bufq->q_vector->vport), .nid = idpf_q_vector_to_mem(bufq->q_vector), + .idx = bufq->rxq_idx, };int ret;
@@ -1913,6 +1916,16 @@ static int idpf_rxq_group_alloc(struct idpf_vport *vport,LIBETH_RX_LL_LEN ;idpf_rxq_set_descids (rsrc, q); } + +if (!idpf_is_queue_model_split (rsrc->rxq_model)) +continue ; + +for (u32 j =0 ; j < rsrc->num_bufqs_per_qgrp; j++) { +struct idpf_buf_queue *bufq; + + bufq = &rx_qgrp->splitq.bufq_sets[j].bufq; + bufq->rxq_idx = rx_qgrp->splitq.rxq_sets[0 ]->rxq.idx; + } } err_alloc:
drivers/net/ethernet/intel/libeth/rx.c +1 -0
@@ -156,6 +156,7 @@ int libeth_rx_fq_create(struct libeth_fq *fq, struct napi_struct *napi) .order = LIBETH_RX_PAGE_ORDER, .pool_size = fq->count, .nid = fq->nid, + .queue_idx = fq->idx, .dev = napi->dev->dev.parent, .netdev = napi->dev, .napi = napi,
Signature · 1 line
2.54.0
Alexander Lobakin
maintainerPATCH v5 2/5 libeth: handle creating pools with unreadable buffers
In reply to Alexander Lobakinlibeth uses netmems for quite some time already, so in order to support unreadable frags / memory providers, it only needs to set PP_FLAG_ALLOW_UNREADABLE_NETMEM when needed.
Also add a couple sanity checks to make sure the driver didn't mess up the configuration options and, in case when an MP is installed, return the truesize always equal to PAGE_SIZE, so that libeth_rx_alloc() will never try to allocate frags. Memory providers manage buffers on their own and expect 1:1 buffer / HW Rx descriptor association.
Bonus: mention in the libeth_sqe_type description that LIBETH_SQE_EMPTY should also be used for netmem Tx SQEs -- they don't need DMA unmapping.
--- include/net/libeth/tx.h | 2 +- drivers/net/ethernet/intel/libeth/rx.c | 42 ++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-)
include/net/libeth/tx.h +1 -1
@@ -12,7 +12,7 @@/** * enum libeth_sqe_type - type of &libeth_sqe to act on Tx completion -* @LIBETH_SQE_EMPTY: unused/empty OR XDP_TX/XSk frame, no action required +* @LIBETH_SQE_EMPTY: empty OR netmem/XDP_TX/XSk frame, no action required * @LIBETH_SQE_CTX: context descriptor with empty SQE, no action required * @LIBETH_SQE_SLAB: kmalloc-allocated buffer, unmap and kfree() * @LIBETH_SQE_FRAG: mapped skb frag, only unmap DMA
drivers/net/ethernet/intel/libeth/rx.c +42 -0
63 lines not on this page · raw message
Signature · 1 line
2.54.0
Re: [PATCH iwl-next v5 2/5] libeth: handle creating pools with unreadable buffers
Quoted 9 lines · Alexander Lobakin
libeth uses netmems for quite some time already, so in order to support unreadable frags / memory providers, it only needs to set
PP_FLAG_ALLOW_UNREADABLE_NETMEMwhen needed.
Also add a couple sanity checks to make sure the driver didn't mess up the configuration options and, in case when an MP is installed, return the truesize always equal toPAGE_SIZE, so thatlibeth_rx_alloc()will never try to allocate frags. Memory providers manage buffers on their own and expect 1:1 buffer / HW Rx descriptor association.
Maybe I'm misreading it, but providers don't expect that. It's fine to use page_pool_alloc_frag_netmem() and friends, just like bnxt and other drivers do. net_iovs are refcounted in the same way as normal pages. Hope it helps.
Signature · 1 line
Pavel Begunkov
Alexander Lobakin
maintainerRe: [PATCH iwl-next v5 2/5] libeth: handle creating pools with unreadable buffers
From: Pavel Begunkov <[email protected]>
Date: Sun, 2 Aug 2026 14:02:11 +0100
Quoted 11 lines · Alexander Lobakin
Quoted 9 lines
libeth uses netmems for quite some time already, so in order to support unreadable frags / memory providers, it only needs to set
PP_FLAG_ALLOW_UNREADABLE_NETMEMwhen needed.
Also add a couple sanity checks to make sure the driver didn't mess up the configuration options and, in case when an MP is installed, return the truesize always equal toPAGE_SIZE, so thatlibeth_rx_alloc()will never try to allocate frags. Memory providers manage buffers on their own and expect 1:1 buffer / HW Rx descriptor association.
Quoted 4 lines
Maybe I'm misreading it, but providers don't expect that. It's fine to use
page_pool_alloc_frag_netmem()and friends, just like bnxt and other drivers do.net_iovsare refcounted in the same way as normal pages. Hope it helps.
Thanks, I'll double check. I could've misunderstood and done that due to the unrelated problem which was fixed recently in the core.
Olek
Alexander Lobakin
maintainerPATCH v5 3/5 ice: migrate to netdev ops lock
In reply to Alexander LobakinQueue management ops unconditionally enable netdev locking. The same lock is taken by default by several NAPI configuration functions, such as napi_enable() and netif_napi_set_irq().
Request ops locking in advance and make sure we use the _locked counterparts of those functions to avoid deadlocks, taking the lock manually where needed (suspend/resume, queue rebuild and resets).
--- drivers/net/ethernet/intel/ice/ice_base.h | 2 + drivers/net/ethernet/intel/ice/ice_lib.h | 13 +- drivers/net/ethernet/intel/ice/ice_base.c | 63 ++++- drivers/net/ethernet/intel/ice/ice_dcb_lib.c | 15 +- drivers/net/ethernet/intel/ice/ice_eswitch.c | 26 ++- drivers/net/ethernet/intel/ice/ice_lib.c | 227 +++++++++++++++---- drivers/net/ethernet/intel/ice/ice_main.c | 78 ++++--- drivers/net/ethernet/intel/ice/ice_sf_eth.c | 3 + drivers/net/ethernet/intel/ice/ice_xsk.c | 4 +- 9 files changed, 324 insertions(+), 107 deletions(-)
drivers/net/ethernet/intel/ice/ice_base.h +2 -0
@@ -12,8 +12,10 @@ int __ice_vsi_get_qs(struct ice_qs_cfg *qs_cfg);int ice_vsi_ctrl_one_rx_ring (struct ice_vsi *vsi,bool ena,u16 rxq_idx,bool wait);int ice_vsi_wait_one_rx_ring (struct ice_vsi *vsi,bool ena,u16 rxq_idx); +int ice_vsi_alloc_q_vectors_locked (struct ice_vsi *vsi);int ice_vsi_alloc_q_vectors (struct ice_vsi *vsi);void ice_vsi_map_rings_to_vectors (struct ice_vsi *vsi); +void ice_vsi_free_q_vectors_locked (struct ice_vsi *vsi);void ice_vsi_free_q_vectors (struct ice_vsi *vsi);int ice_vsi_cfg_single_txq (struct ice_vsi *vsi,struct ice_tx_ring **tx_rings,u16 q_idx);
drivers/net/ethernet/intel/ice/ice_lib.h +9 -4
@@ -53,19 +53,24 @@ struct ice_vsi * ice_vsi_setup(struct ice_pf *pf, struct ice_vsi_cfg_params *params);void ice_vsi_set_napi_queues (struct ice_vsi *vsi); -void ice_napi_add (struct ice_vsi *vsi); - +void ice_vsi_set_napi_queues_locked (struct ice_vsi *vsi);void ice_vsi_clear_napi_queues (struct ice_vsi *vsi); +void ice_vsi_clear_napi_queues_locked (struct ice_vsi *vsi); + +void ice_napi_add (struct ice_vsi *vsi);int ice_vsi_release (struct ice_vsi *vsi);void ice_vsi_close (struct ice_vsi *vsi); -int ice_ena_vsi (struct ice_vsi *vsi,bool locked); +int ice_ena_vsi_locked (struct ice_vsi *vsi); +int ice_ena_vsi (struct ice_vsi *vsi);void ice_vsi_decfg (struct ice_vsi *vsi); -void ice_dis_vsi (struct ice_vsi *vsi,bool locked); +void ice_dis_vsi_locked (struct ice_vsi *vsi); +void ice_dis_vsi (struct ice_vsi *vsi); +int ice_vsi_rebuild_locked (struct ice_vsi *vsi,u32 vsi_flags);int ice_vsi_rebuild (struct ice_vsi *vsi,u32 vsi_flags);int ice_vsi_cfg (struct ice_vsi *vsi);struct ice_vsi *ice_vsi_alloc (struct ice_pf *pf);
drivers/net/ethernet/intel/ice/ice_base.c +54 -9
104 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_dcb_lib.c +7 -8
@@ -273,14 +273,13 @@ void ice_vsi_cfg_dcb_rings(struct ice_vsi *vsi)* ice_dcb_ena_dis_vsi - disable certain VSIs for DCB config/reconfig * @pf: pointer to the PF instance * @ena: true to enable VSIs, false to disable -* @locked: true if caller holds RTNL lock, false otherwise * * Before a new DCB configuration can be applied, VSIs of type PF, SWITCHDEV * and CHNL need to be brought down. Following completion of DCB configuration * the VSIs that were downed need to be brought up again. This helper function * does both. */ -static void ice_dcb_ena_dis_vsi (struct ice_pf *pf,bool ena,bool locked) +static void ice_dcb_ena_dis_vsi (struct ice_pf *pf,bool ena) {int i;
@@ -294,9 +293,9 @@ static void ice_dcb_ena_dis_vsi(struct ice_pf *pf, bool ena, bool locked)case ICE_VSI_CHNL :case ICE_VSI_PF :if (ena) -ice_ena_vsi (vsi, locked); +ice_ena_vsi (vsi);else -ice_dis_vsi (vsi, locked); +ice_dis_vsi (vsi);break ;default :continue ;
@@ -416,7 +415,7 @@ int ice_pf_dcb_cfg(struct ice_pf *pf, struct ice_dcbx_cfg *new_cfg, bool locked)rtnl_lock ();/* disable VSIs affected by DCB changes */ -ice_dcb_ena_dis_vsi (pf, false, true); +ice_dcb_ena_dis_vsi (pf, false);memcpy (curr_cfg, new_cfg,sizeof (*curr_cfg));memcpy (&curr_cfg->etsrec, &curr_cfg->etscfg,sizeof (curr_cfg->etsrec));
@@ -445,7 +444,7 @@ int ice_pf_dcb_cfg(struct ice_pf *pf, struct ice_dcbx_cfg *new_cfg, bool locked) out:/* enable previously downed VSIs */ -ice_dcb_ena_dis_vsi (pf, true, true); +ice_dcb_ena_dis_vsi (pf, true);if (!locked)rtnl_unlock (); free_cfg:
@@ -1107,7 +1106,7 @@ ice_dcb_process_lldp_set_mib_change(struct ice_pf *pf,rtnl_lock ();/* disable VSIs affected by DCB changes */ -ice_dcb_ena_dis_vsi (pf, false, true); +ice_dcb_ena_dis_vsi (pf, false); ret =ice_query_port_ets (pi, &buf,sizeof (buf),NULL );if (ret) {
@@ -1119,7 +1118,7 @@ ice_dcb_process_lldp_set_mib_change(struct ice_pf *pf,ice_pf_dcb_recfg (pf, false);/* enable previously downed VSIs */ -ice_dcb_ena_dis_vsi (pf, true, true); +ice_dcb_ena_dis_vsi (pf, true); unlock_rtnl:rtnl_unlock (); out:
drivers/net/ethernet/intel/ice/ice_eswitch.c +21 -5
@@ -23,10 +23,16 @@ static int ice_eswitch_setup_env(struct ice_pf *pf)struct net_device *netdev = uplink_vsi->netdev;bool if_running =netif_running (netdev);struct ice_vsi_vlan_ops *vlan_ops; +int ret; + +if (if_running && !test_and_set_bit (ICE_VSI_DOWN , uplink_vsi->state)) { +netdev_lock (netdev); + ret =ice_down (uplink_vsi); +netdev_unlock (netdev); -if (if_running && !test_and_set_bit (ICE_VSI_DOWN , uplink_vsi->state)) -if (ice_down (uplink_vsi)) +if (ret)return -ENODEV ; + }ice_remove_vsi_fltr (&pf->hw, uplink_vsi->idx);ice_vsi_cfg_sw_lldp (uplink_vsi, true, false);
@@ -53,8 +59,14 @@ static int ice_eswitch_setup_env(struct ice_pf *pf)if (ice_vsi_update_local_lb (uplink_vsi, true)) goto err_override_local_lb; -if (if_running &&ice_up (uplink_vsi)) - goto err_up; +if (if_running) { +netdev_lock (netdev); + ret =ice_up (uplink_vsi); +netdev_unlock (netdev); + +if (ret) + goto err_up; + }return 0 ;
@@ -74,8 +86,12 @@ static int ice_eswitch_setup_env(struct ice_pf *pf)ice_fltr_add_mac_and_broadcast (uplink_vsi, uplink_vsi->port_info->mac.perm_addr,ICE_FWD_TO_VSI ); -if (if_running) + +if (if_running) { +netdev_lock (netdev);ice_up (uplink_vsi); +netdev_unlock (netdev); + }return -ENODEV ; }
drivers/net/ethernet/intel/ice/ice_lib.c +183 -44
398 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_main.c +43 -35
212 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_sf_eth.c +3 -0
@@ -58,6 +58,7 @@ static int ice_sf_cfg_netdev(struct ice_dynamic_port *dyn_port,eth_hw_addr_set (netdev, dyn_port->hw_addr);ether_addr_copy (netdev->perm_addr, dyn_port->hw_addr); netdev->netdev_ops = &ice_sf_netdev_ops; + netdev->request_ops_lock = true;SET_NETDEV_DEVLINK_PORT (netdev, devlink_port); err =register_netdev (netdev);
@@ -183,7 +184,9 @@ static void ice_sf_dev_remove(struct auxiliary_device *adev) devlink =priv_to_devlink (sf_dev->priv);devl_lock (devlink); +netdev_lock (vsi->netdev);ice_vsi_close (vsi); +netdev_unlock (vsi->netdev);ice_sf_decfg_netdev (vsi);ice_devlink_destroy_sf_dev_port (sf_dev);
drivers/net/ethernet/intel/ice/ice_xsk.c +2 -2
@@ -33,9 +33,9 @@ ice_qvec_toggle_napi(struct ice_vsi *vsi, struct ice_q_vector *q_vector,return ;if (enable) -napi_enable (&q_vector->napi); +napi_enable_locked (&q_vector->napi);else -napi_disable (&q_vector->napi); +napi_disable_locked (&q_vector->napi); }/**
Signature · 1 line
2.54.0
Simon Horman
reviewerRe: [PATCH iwl-next v5 3/5] ice: migrate to netdev ops lock
From: 'Simon Horman' <[email protected]>
This is an AI-generated review of your patch. The human sending this email has considered the AI review valid, or at least plausible. Full review at: https://sashiko.dev
---
ice: migrate to netdev ops lock
This commit migrates queue management operations to use netdev locking. It updates several NAPI and VSI configuration functions to use their _locked variants to avoid deadlocks, taking the lock manually where needed.
Quoted 4 lines
drivers/net/ethernet/intel/ice/ice_dcb_lib.c +0
-0
[ ... ]
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_dcb_lib.c +1
-1@@ -1107,7 +1106,7 @@ ice_dcb_process_lldp_set_mib_change(struct ice_pf *pf,rtnl_lock ();/* disable VSIs affected by DCB changes */ -ice_dcb_ena_dis_vsi (pf, false, true); +ice_dcb_ena_dis_vsi (pf, false); ret =ice_query_port_ets (pi, &buf,sizeof (buf),NULL );if (ret) {
drivers/net/ethernet/intel/ice/ice_dcb_lib.c ice_dcb_process_lldp_set_mib_change(struct ice_pf *pf, · line 1124
Quoted 8 lines
drivers/net/ethernet/intel/ice/ice_dcb_lib.c +1
-1@@ -1119,7 +1118,7 @@ ice_dcb_process_lldp_set_mib_change(struct ice_pf *pf,ice_pf_dcb_recfg (pf, false);/* enable previously downed VSIs */ -ice_dcb_ena_dis_vsi (pf, true, true); +ice_dcb_ena_dis_vsi (pf, true); unlock_rtnl:rtnl_unlock (); out:
This wasn't introduced by this patch, but does this error path leave VSIs permanently disabled?
If ice_query_port_ets() fails, the code jumps to unlock_rtnl, bypassing the call to ice_dcb_ena_dis_vsi(pf, true). This seems to leave the affected VSIs (including the main PF interface) in a disabled state (ICE_VSI_DOWN) with ICE_VSI_NEEDS_RESTART set, which could result in a denial of service.
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_eswitch.c +2
-0@@ -23,10 +23,16 @@ static int ice_eswitch_setup_env(struct ice_pf *pf)struct net_device *netdev = uplink_vsi->netdev;bool if_running =netif_running (netdev);struct ice_vsi_vlan_ops *vlan_ops; +int ret; +
drivers/net/ethernet/intel/ice/ice_eswitch.c static int ice_eswitch_setup_env(struct ice_pf *pf) · line 35
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_eswitch.c +6
-2+if (if_running && !test_and_set_bit (ICE_VSI_DOWN , uplink_vsi->state)) { +netdev_lock (netdev); + ret =ice_down (uplink_vsi); +netdev_unlock (netdev); -if (if_running && !test_and_set_bit (ICE_VSI_DOWN , uplink_vsi->state)) -if (ice_down (uplink_vsi)) +if (ret)return -ENODEV ; + }
Simon says: It seems that the topic of locks in this patch has come up
again ¯\_(ツ)_/¯
Does manipulating the state bit outside of netdev_lock create a race condition with interface teardown?
If the interface is concurrently brought down, ndo_stop (which holds netdev_lock) would call ice_vsi_close(). Because ICE_VSI_DOWN is already set by the test_and_set_bit() call above, ice_vsi_close() would skip calling ice_down() and immediately proceed to free the Tx/Rx rings.
This would leave the hardware queues active and performing DMA operations into freed memory, potentially causing a use-after-free.
Alexander Lobakin
maintainerRe: [PATCH iwl-next v5 3/5] ice: migrate to netdev ops lock
From: Simon Horman <[email protected]>
Date: Fri, 8 May 2026 14:28:29 +0100
Quoted 71 lines
From: 'Simon Horman' <[email protected]>
This is an AI-generated review of your patch. The human sending this email has considered the AI review valid, or at least plausible. Full review at: https://sashiko.dev
---
ice: migrate to netdev ops lockThis commit migrates queue management operations to use netdev locking. It updates several NAPI and VSI configuration functions to use their
_lockedvariants to avoid deadlocks, taking the lock manually where needed.Quoted 4 lines
drivers/net/ethernet/intel/ice/ice_dcb_lib.c +0
-0[ ... ]
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_dcb_lib.c +1
-1@@ -1107,7 +1106,7 @@ ice_dcb_process_lldp_set_mib_change(struct ice_pf *pf,rtnl_lock ();/* disable VSIs affected by DCB changes */ -ice_dcb_ena_dis_vsi (pf, false, true); +ice_dcb_ena_dis_vsi (pf, false); ret =ice_query_port_ets (pi, &buf,sizeof (buf),NULL );if (ret) {drivers/net/ethernet/intel/ice/ice_dcb_lib.c ice_dcb_process_lldp_set_mib_change(struct ice_pf *pf, · line 1124
Quoted 8 lines
drivers/net/ethernet/intel/ice/ice_dcb_lib.c +1
-1@@ -1119,7 +1118,7 @@ ice_dcb_process_lldp_set_mib_change(struct ice_pf *pf,ice_pf_dcb_recfg (pf, false);/* enable previously downed VSIs */ -ice_dcb_ena_dis_vsi (pf, true, true); +ice_dcb_ena_dis_vsi (pf, true); unlock_rtnl:rtnl_unlock (); out:This wasn't introduced by this patch, but does this error path leave VSIs permanently disabled?
If
ice_query_port_ets()fails, the code jumps tounlock_rtnl, bypassing the call toice_dcb_ena_dis_vsi(pf, true). This seems to leave the affected VSIs (including the main PF interface) in a disabled state (ICE_VSI_DOWN) withICE_VSI_NEEDS_RESTARTset, which could result in a denial of service.Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_eswitch.c +2
-0@@ -23,10 +23,16 @@ static int ice_eswitch_setup_env(struct ice_pf *pf)struct net_device *netdev = uplink_vsi->netdev;bool if_running =netif_running (netdev);struct ice_vsi_vlan_ops *vlan_ops; +int ret; +drivers/net/ethernet/intel/ice/ice_eswitch.c static int ice_eswitch_setup_env(struct ice_pf *pf) · line 35
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_eswitch.c +6
-2+if (if_running && !test_and_set_bit (ICE_VSI_DOWN , uplink_vsi->state)) { +netdev_lock (netdev); + ret =ice_down (uplink_vsi); +netdev_unlock (netdev); -if (if_running && !test_and_set_bit (ICE_VSI_DOWN , uplink_vsi->state)) -if (ice_down (uplink_vsi)) +if (ret)return -ENODEV ; + }Simon says: It seems that the topic of locks in this patch has come up
again ¯\_(ツ)_/¯Does manipulating the state bit outside of
netdev_lockcreate a race condition with interface teardown?
Quoted 7 lines
If the interface is concurrently brought down,
ndo_stop(which holdsnetdev_lock) would callice_vsi_close(). BecauseICE_VSI_DOWNis already set by thetest_and_set_bit()call above,ice_vsi_close()would skip callingice_down()and immediately proceed to free the Tx/Rx rings.This would leave the hardware queues active and performing DMA operations into freed memory, potentially causing a use-after-free.
I ran Sashiko internally a couple times and it hasn't found these =\
Anyway, now that I anyway need to adjust the series after .ndo_set_rx_mode_asyn() landed, I'll take a look at this, too.
(I hate this series already. I feel like if Sashiko was alive when other
vendors were switching to the netdev lock, they'd have the same drama)
(I was planning to add devmem/io_uring support to idpf after this lands,
but given that idpf is way more confusing and inconsistent in locking, I'm not sure I'll have enough patience :D)
Thanks,
Olek
Simon Horman
reviewerRe: [PATCH iwl-next v5 3/5] ice: migrate to netdev ops lock
Quoted 82 lines · Alexander Lobakin
From: Simon Horman <[email protected]>
Date: Fri, 8 May 2026 14:28:29 +0100Quoted 71 lines
From: 'Simon Horman' <[email protected]>
This is an AI-generated review of your patch. The human sending this email has considered the AI review valid, or at least plausible. Full review at: https://sashiko.dev
---
ice: migrate to netdev ops lockThis commit migrates queue management operations to use netdev locking. It updates several NAPI and VSI configuration functions to use their
_lockedvariants to avoid deadlocks, taking the lock manually where needed.Quoted 4 lines
drivers/net/ethernet/intel/ice/ice_dcb_lib.c +0
-0[ ... ]
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_dcb_lib.c +1
-1@@ -1107,7 +1106,7 @@ ice_dcb_process_lldp_set_mib_change(struct ice_pf *pf,rtnl_lock ();/* disable VSIs affected by DCB changes */ -ice_dcb_ena_dis_vsi (pf, false, true); +ice_dcb_ena_dis_vsi (pf, false); ret =ice_query_port_ets (pi, &buf,sizeof (buf),NULL );if (ret) {drivers/net/ethernet/intel/ice/ice_dcb_lib.c ice_dcb_process_lldp_set_mib_change(struct ice_pf *pf, · line 1124
Quoted 8 lines
drivers/net/ethernet/intel/ice/ice_dcb_lib.c +1
-1@@ -1119,7 +1118,7 @@ ice_dcb_process_lldp_set_mib_change(struct ice_pf *pf,ice_pf_dcb_recfg (pf, false);/* enable previously downed VSIs */ -ice_dcb_ena_dis_vsi (pf, true, true); +ice_dcb_ena_dis_vsi (pf, true); unlock_rtnl:rtnl_unlock (); out:This wasn't introduced by this patch, but does this error path leave VSIs permanently disabled?
If
ice_query_port_ets()fails, the code jumps tounlock_rtnl, bypassing the call toice_dcb_ena_dis_vsi(pf, true). This seems to leave the affected VSIs (including the main PF interface) in a disabled state (ICE_VSI_DOWN) withICE_VSI_NEEDS_RESTARTset, which could result in a denial of service.Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_eswitch.c +2
-0@@ -23,10 +23,16 @@ static int ice_eswitch_setup_env(struct ice_pf *pf)struct net_device *netdev = uplink_vsi->netdev;bool if_running =netif_running (netdev);struct ice_vsi_vlan_ops *vlan_ops; +int ret; +drivers/net/ethernet/intel/ice/ice_eswitch.c static int ice_eswitch_setup_env(struct ice_pf *pf) · line 35
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_eswitch.c +6
-2+if (if_running && !test_and_set_bit (ICE_VSI_DOWN , uplink_vsi->state)) { +netdev_lock (netdev); + ret =ice_down (uplink_vsi); +netdev_unlock (netdev); -if (if_running && !test_and_set_bit (ICE_VSI_DOWN , uplink_vsi->state)) -if (ice_down (uplink_vsi)) +if (ret)return -ENODEV ; + }Simon says: It seems that the topic of locks in this patch has come up
again ¯\_(ツ)_/¯Does manipulating the state bit outside of
netdev_lockcreate a race condition with interface teardown?Quoted 7 lines
If the interface is concurrently brought down,
ndo_stop(which holdsnetdev_lock) would callice_vsi_close(). BecauseICE_VSI_DOWNis already set by thetest_and_set_bit()call above,ice_vsi_close()would skip callingice_down()and immediately proceed to free the Tx/Rx rings.This would leave the hardware queues active and performing DMA operations into freed memory, potentially causing a use-after-free.
Quoted 7 lines
I ran Sashiko internally a couple times and it hasn't found these =\
Anyway, now that I anyway need to adjust the series after .ndo_set_rx_mode_asyn() landed, I'll take a look at this, too.
(I hate this series already. I feel like if Sashiko was alive when other
vendors were switching to the netdev lock, they'd have the same drama)
Life is certainly different with Sashiko.
No question about it.
Quoted 7 lines
(I was planning to add devmem/io_uring support to idpf after this lands,
but given that idpf is way more confusing and inconsistent in locking, I'm not sure I'll have enough patience :D)Thanks,
Olek
Alexander Lobakin
maintainerPATCH v5 4/5 ice: implement Rx queue management ops
In reply to Alexander LobakinNow ice is ready to get queue_mgmt_ops support. It already has API to disable/reconfig/enable one particular queue (for XSk). Reuse as much of its code as possible to implement Rx queue management callbacks and vice versa -- ice_queue_mem_{alloc,free}() can be reused during ifup/ifdown to elide code duplication. With this, ice passes the io_uring zcrx selftests, meaning the Rx part of netmem/MP support is done.
--- drivers/net/ethernet/intel/ice/ice_lib.h | 5 + drivers/net/ethernet/intel/ice/ice_txrx.h | 2 + drivers/net/ethernet/intel/ice/ice_base.c | 182 +++++++++++++++----- drivers/net/ethernet/intel/ice/ice_main.c | 2 +- drivers/net/ethernet/intel/ice/ice_sf_eth.c | 2 +- drivers/net/ethernet/intel/ice/ice_txrx.c | 26 ++- 6 files changed, 165 insertions(+), 54 deletions(-)
drivers/net/ethernet/intel/ice/ice_lib.h +5 -0
@@ -4,6 +4,8 @@#ifndef _ICE_LIB_H_#define _ICE_LIB_H_ +#include <net/netdev_queues.h> +#include "ice.h" #include "ice_vlan.h"
@@ -135,4 +137,7 @@ void ice_clear_feature_support(struct ice_pf *pf, enum ice_feature f);void ice_init_feature_support (struct ice_pf *pf);bool ice_vsi_is_rx_queue_active (struct ice_vsi *vsi);void ice_vsi_update_l2tsel (struct ice_vsi *vsi,enum ice_l2tsel l2tsel); + +extern const struct netdev_queue_mgmt_ops ice_queue_mgmt_ops; +#endif /* !_ICE_LIB_H_ */
drivers/net/ethernet/intel/ice/ice_txrx.h +2 -0
@@ -462,6 +462,8 @@ u16 ice_select_queue(struct net_device *dev, struct sk_buff *skb, struct net_device *sb_dev);void ice_clean_tx_ring (struct ice_tx_ring *tx_ring); +void ice_queue_mem_free (struct net_device *dev,void *per_queue_mem); +void ice_zero_rx_ring (struct ice_rx_ring *rx_ring);void ice_clean_rx_ring (struct ice_rx_ring *rx_ring);int ice_setup_tx_ring (struct ice_tx_ring *tx_ring);int ice_setup_rx_ring (struct ice_rx_ring *rx_ring);
drivers/net/ethernet/intel/ice/ice_base.c +138 -44
245 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_main.c +1 -1
@@ -3452,7 +3452,7 @@ static void ice_set_ops(struct ice_vsi *vsi) } netdev->netdev_ops = &ice_netdev_ops; - netdev->request_ops_lock = true; + netdev->queue_mgmt_ops = &ice_queue_mgmt_ops; netdev->udp_tunnel_nic_info = &pf->hw.udp_tunnel_nic; netdev->xdp_metadata_ops = &ice_xdp_md_ops;ice_set_ethtool_ops (netdev);
drivers/net/ethernet/intel/ice/ice_sf_eth.c +1 -1
@@ -58,7 +58,7 @@ static int ice_sf_cfg_netdev(struct ice_dynamic_port *dyn_port,eth_hw_addr_set (netdev, dyn_port->hw_addr);ether_addr_copy (netdev->perm_addr, dyn_port->hw_addr); netdev->netdev_ops = &ice_sf_netdev_ops; - netdev->request_ops_lock = true; + netdev->queue_mgmt_ops = &ice_queue_mgmt_ops;SET_NETDEV_DEVLINK_PORT (netdev, devlink_port); err =register_netdev (netdev);
drivers/net/ethernet/intel/ice/ice_txrx.c +18 -8
@@ -531,17 +531,13 @@ void ice_rxq_pp_destroy(struct ice_rx_ring *rq) rq->hdr_pp =NULL ; } -/** -* ice_clean_rx_ring - Free Rx buffers -* @rx_ring: ring to be cleaned -*/ -void ice_clean_rx_ring (struct ice_rx_ring *rx_ring) +void ice_queue_mem_free (struct net_device *dev,void *per_queue_mem) { -u32 size; +struct ice_rx_ring *rx_ring = per_queue_mem;if (rx_ring->xsk_pool) {ice_xsk_clean_rx_ring (rx_ring); - goto rx_skip_free; +return ; }/* ring already cleared, nothing to do */
@@ -570,8 +566,12 @@ void ice_clean_rx_ring(struct ice_rx_ring *rx_ring) }ice_rxq_pp_destroy (rx_ring); +} + +void ice_zero_rx_ring (struct ice_rx_ring *rx_ring) +{ +size_t size; -rx_skip_free:/* Zero out the descriptor ring */ size =ALIGN (rx_ring->count *sizeof (union ice_32byte_rx_desc ),PAGE_SIZE );
@@ -581,6 +581,16 @@ void ice_clean_rx_ring(struct ice_rx_ring *rx_ring) rx_ring->next_to_use =0 ; } +/** +* ice_clean_rx_ring - Free Rx buffers +* @rx_ring: ring to be cleaned +*/ +void ice_clean_rx_ring (struct ice_rx_ring *rx_ring) +{ +ice_queue_mem_free (rx_ring->netdev, rx_ring); +ice_zero_rx_ring (rx_ring); +} +/** * ice_free_rx_ring - Free Rx resources * @rx_ring: ring to clean the resources from
Signature · 1 line
2.54.0
Simon Horman
reviewerRe: [Intel-wired-lan] [PATCH iwl-next v5 4/5] ice: implement Rx queue management ops
From: 'Simon Horman' <[email protected]>
This is an AI-generated review of your patch. The human sending this email has considered the AI review valid, or at least plausible. Full review at: https://sashiko.dev
---
ice: implement Rx queue management ops
This commit wires the ice driver into the netdev queue management ops framework, reusing the existing per-queue disable/reconfig/enable paths originally added for XSk. With it, ice reportedly passes the io_uring zcrx selftests.
Quoted 4 lines
drivers/net/ethernet/intel/ice/ice_base.c +0
-0
[ ... ]
Quoted 32 lines
drivers/net/ethernet/intel/ice/ice_base.c +28
-0@@ -1577,3 +1593,81 @@ int ice_qp_ena(struct ice_vsi *vsi, u16 q_idx)return fail; } + +/** +* ice_qp_ena - Enables a queue pair +* @vsi: VSI of interest +* @q_idx: ring index in array +* +* Returns 0 on success, negative on failure. +*/ +int ice_qp_ena (struct ice_vsi *vsi,u16 q_idx) +{ +return __ice_qp_ena (vsi, q_idx,ice_vsi_cfg_single_rxq (vsi, q_idx)); +} + +static int ice_queue_start (struct net_device *dev, +struct netdev_queue_config *qcfg, +void *per_queue_mem,int idx) +{ +const struct ice_netdev_priv *priv =netdev_priv (dev); +struct ice_rx_ring *real = priv->vsi->rx_rings[idx]; +struct ice_rx_ring *new = per_queue_mem; +struct napi_struct *napi; +int ret; + + real->pp = new->pp; + real->rx_fqes = new->rx_fqes; + real->hdr_fqes = new->hdr_fqes; + real->hdr_pp = new->hdr_pp; +
drivers/net/ethernet/intel/ice/ice_base.c int ice_qp_ena(struct ice_vsi *vsi, u16 q_idx) · line 1633
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_base.c +10
-0+ real->hdr_truesize = new->hdr_truesize; + real->truesize = new->truesize; + real->rx_hdr_len = new->rx_hdr_len; + real->rx_buf_len = new->rx_buf_len; + +memcpy (&real->xdp_rxq, &new->xdp_rxq,sizeof (new->xdp_rxq)); + + ret =ice_setup_rx_ctx (real); +if (ret) +return ret;
Simon says: I believe that the issue flagged immediately below is
a false positive; the cleanup logic unwinds things correctly.
However, the two other issues flagged further down do seem to be of concern.
ice_queue_start() eagerly copies new->pp, new->rx_fqes, new->hdr_pp, new->hdr_fqes and the entire new->xdp_rxq into real before ice_setup_rx_ctx() has succeeded.
If ice_setup_rx_ctx() returns an error here, the function bails out with real already pointing at new_mem's page pools and fqes arrays.
The core netdev_rx_queue_reconfig() rollback then invokes ndo_queue_start(dev, qcfg_old, old_mem, rxq_idx), which repeats the same eager overwrite using old_mem and calls ice_setup_rx_ctx() again. If the second ice_setup_rx_ctx() also fails, the core proceeds to ndo_queue_mem_free(dev, old_mem), and ice_queue_mem_free() will tear down the page pools whose pointers real->pp / real->hdr_pp are still aliasing.
Would it be safer to stash the existing real->pp / real->rx_fqes / real->hdr_pp / real->hdr_fqes / real->xdp_rxq on entry and restore them if ice_setup_rx_ctx() fails, so that a failed rollback cannot leave real with dangling pointers to a pool that ice_queue_mem_free() is about to destroy?
drivers/net/ethernet/intel/ice/ice_base.c int ice_qp_ena(struct ice_vsi *vsi, u16 q_idx) · line 1643
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_base.c +10
-0+ + napi = &real->q_vector->napi; + +page_pool_enable_direct_recycling (real->pp, napi); +if (real->hdr_pp) +page_pool_enable_direct_recycling (real->hdr_pp, napi); + + ret =ice_alloc_rx_bufs (real,ICE_DESC_UNUSED (real)); + +return __ice_qp_ena (priv->vsi, idx, ret);
ice_alloc_rx_bufs() is declared bool and returns !!cleaned_count, so it yields 0 on full success and 1 on partial/failed allocation:
bool ice_alloc_rx_bufs(struct ice_rx_ring *rx_ring, unsigned int cleaned_count)
{
...
return !!cleaned_count;
}That bool is then passed straight into __ice_qp_ena()'s fail parameter, which only overwrites fail via 'if (!fail) fail = err;', so a value of 1 propagates unchanged to ice_queue_start()'s return value.
netdev_rx_queue_reconfig() treats any non-zero return as failure and propagates it back to userspace (netlink, ethtool, io_uring zcrx install), where the callers expect a negative errno.
Before this patch, ice_qp_ena() obtained its fail value from ice_vsi_cfg_single_rxq(), which returns a signed errno.
Should this be converted to a proper negative errno before being handed to __ice_qp_ena(), for example:
ret = ice_alloc_rx_bufs(real, ICE_DESC_UNUSED(real)) ? -ENOMEM : 0;
Quoted 12 lines
drivers/net/ethernet/intel/ice/ice_base.c +12
-0+} + +static int ice_queue_stop (struct net_device *dev,void *per_queue_mem, +int idx) +{ +const struct ice_netdev_priv *priv =netdev_priv (dev); +struct ice_rx_ring *real = priv->vsi->rx_rings[idx]; +int ret; + + ret =__ice_qp_dis (priv->vsi, idx); +if (ret) +return ret;
drivers/net/ethernet/intel/ice/ice_base.c int ice_qp_ena(struct ice_vsi *vsi, u16 q_idx) · line 1665
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_base.c +10
-0+ +page_pool_disable_direct_recycling (real->pp); +if (real->hdr_pp) +page_pool_disable_direct_recycling (real->hdr_pp); + +ice_zero_rx_ring (real); +memcpy (per_queue_mem, real,sizeof (*real)); + +return 0 ; +}
Can this leak inflight page pool buffers?
ice_zero_rx_ring(real) is called before the memcpy to per_queue_mem, and ice_zero_rx_ring() resets both indices:
void ice_zero_rx_ring(struct ice_rx_ring *rx_ring)
{
...
rx_ring->next_to_clean = 0;
rx_ring->next_to_use = 0;
}So per_queue_mem captures a ring where next_to_clean == next_to_use == 0.
The core then invokes ndo_queue_mem_free(dev, old_mem), and the recycle loop in ice_queue_mem_free() is guarded by exactly those two indices:
void ice_queue_mem_free(struct net_device *dev, void *per_queue_mem)
{
...
for (u32 i = rx_ring->next_to_clean; i != rx_ring->next_to_use; ) {
libeth_rx_recycle_slow(rx_ring->rx_fqes[i].netmem);
if (rx_ring->hdr_pp)
libeth_rx_recycle_slow(rx_ring->hdr_fqes[i].netmem);
if (unlikely(++i == rx_ring->count))
i = 0;
}
...
ice_rxq_pp_destroy(rx_ring);
}With 0 != 0 false on entry, the loop never runs, so any buffers that were in rx_fqes[old_ntc..old_ntu) (and hdr_fqes[] when header split is on) are never returned via libeth_rx_recycle_slow(). ice_rxq_pp_destroy() then kvfree()s the fqes arrays and calls page_pool_destroy() with outstanding inflight references that are no longer tracked anywhere.
The new ice_clean_rx_ring() wrapper keeps the original ordering:
void ice_clean_rx_ring(struct ice_rx_ring *rx_ring)
{
ice_queue_mem_free(rx_ring->netdev, rx_ring);
ice_zero_rx_ring(rx_ring);
}Should ice_queue_stop() follow the same ordering and perform the memcpy before ice_zero_rx_ring(real), so the recycle loop in ice_queue_mem_free() sees the real ntc/ntu values?
Quoted 8 lines
drivers/net/ethernet/intel/ice/ice_base.c +8
-0+ +const struct netdev_queue_mgmt_ops ice_queue_mgmt_ops = { + .ndo_queue_mem_alloc = ice_queue_mem_alloc, + .ndo_queue_mem_free = ice_queue_mem_free, + .ndo_queue_mem_size =sizeof (struct ice_rx_ring ), + .ndo_queue_start = ice_queue_start, + .ndo_queue_stop = ice_queue_stop, +};
[ ... ]
Simon Horman
reviewerRe: [Intel-wired-lan] [PATCH iwl-next v5 4/5] ice: implement Rx queue management ops
Quoted 5 lines · Simon Horman
From: 'Simon Horman' <[email protected]>
This is an AI-generated review of your patch. The human sending this email has considered the AI review valid, or at least plausible. Full review at: https://sashiko.dev
Sorry, the line above should have referenced
https://netdev-ai.bots.linux.dev/sashiko/
There is also a review of this patch available on https://sashiko.dev
Which I plan to forward separately.
...
Alexander Lobakin
maintainerRe: [Intel-wired-lan] [PATCH iwl-next v5 4/5] ice: implement Rx queue management ops
In reply to Simon HormanFrom: Simon Horman <[email protected]>
Date: Fri, 8 May 2026 15:08:00 +0100
Quoted 57 lines
From: 'Simon Horman' <[email protected]>
This is an AI-generated review of your patch. The human sending this email has considered the AI review valid, or at least plausible. Full review at: https://sashiko.dev
---
ice: implement Rx queue management opsThis commit wires the ice driver into the netdev queue management ops framework, reusing the existing per-queue disable/reconfig/enable paths originally added for XSk. With it, ice reportedly passes the
io_uringzcrx selftests.Quoted 4 lines
drivers/net/ethernet/intel/ice/ice_base.c +0
-0[ ... ]
Quoted 37 lines
drivers/net/ethernet/intel/ice/ice_base.c +33
-0@@ -1577,3 +1593,81 @@ int ice_qp_ena(struct ice_vsi *vsi, u16 q_idx)return fail; } + +/** +* ice_qp_ena - Enables a queue pair +* @vsi: VSI of interest +* @q_idx: ring index in array +* +* Returns 0 on success, negative on failure. +*/ +int ice_qp_ena (struct ice_vsi *vsi,u16 q_idx) +{ +return __ice_qp_ena (vsi, q_idx,ice_vsi_cfg_single_rxq (vsi, q_idx)); +} + +static int ice_queue_start (struct net_device *dev, +struct netdev_queue_config *qcfg, +void *per_queue_mem,int idx) +{ +const struct ice_netdev_priv *priv =netdev_priv (dev); +struct ice_rx_ring *real = priv->vsi->rx_rings[idx]; +struct ice_rx_ring *new = per_queue_mem; +struct napi_struct *napi; +int ret; + + real->pp = new->pp; + real->rx_fqes = new->rx_fqes; + real->hdr_fqes = new->hdr_fqes; + real->hdr_pp = new->hdr_pp; + + real->hdr_truesize = new->hdr_truesize; + real->truesize = new->truesize; + real->rx_hdr_len = new->rx_hdr_len; + real->rx_buf_len = new->rx_buf_len; +
Quoted 8 lines
drivers/net/ethernet/intel/ice/ice_base.c int ice_qp_ena(struct ice_vsi *vsi, u16 q_idx) · line 1633
Quoted 5 lines
drivers/net/ethernet/intel/ice/ice_base.c +5
-0+memcpy (&real->xdp_rxq, &new->xdp_rxq,sizeof (new->xdp_rxq)); + + ret =ice_setup_rx_ctx (real); +if (ret) +return ret;Simon says: I believe that the issue flagged immediately below is
a false positive; the cleanup logic unwinds things correctly.
Yup, our Sashiko also had concerns about this piece, but I rechecked and seems like it's a FP.
Quoted 7 lines
However, the two other issues flagged further down do seem to be of concern.
ice_queue_start()eagerly copiesnew->pp,new->rx_fqes,new->hdr_pp,new->hdr_fqesand the entirenew->xdp_rxqinto real beforeice_setup_rx_ctx()has succeeded.
[...]
Quoted 111 lines
drivers/net/ethernet/intel/ice/ice_base.c int ice_qp_ena(struct ice_vsi *vsi, u16 q_idx) · line 1643
Quoted 11 lines
drivers/net/ethernet/intel/ice/ice_base.c +10
-0+ + napi = &real->q_vector->napi; + +page_pool_enable_direct_recycling (real->pp, napi); +if (real->hdr_pp) +page_pool_enable_direct_recycling (real->hdr_pp, napi); + + ret =ice_alloc_rx_bufs (real,ICE_DESC_UNUSED (real)); + +return __ice_qp_ena (priv->vsi, idx, ret);
ice_alloc_rx_bufs()is declared bool and returns !!cleaned_count, so it yields 0 on full success and 1 on partial/failed allocation:bool
ice_alloc_rx_bufs(struct ice_rx_ring *rx_ring, unsigned int cleaned_count){ ... return !!cleaned_count; }That bool is then passed straight into __ice_qp_ena()'s fail parameter, which only overwrites fail via 'if (!fail) fail = err;', so a value of 1 propagates unchanged to ice_queue_start()'s return value.
netdev_rx_queue_reconfig()treats any non-zero return as failure and propagates it back to userspace (netlink, ethtool,io_uringzcrx install), where the callers expect a negative errno.Before this patch,
ice_qp_ena()obtained its fail value fromice_vsi_cfg_single_rxq(), which returns a signed errno.Should this be converted to a proper negative errno before being handed to
__ice_qp_ena(), for example:ret = ice_alloc_rx_bufs(real, ICE_DESC_UNUSED(real)) ? -ENOMEM : 0;Quoted 12 lines
drivers/net/ethernet/intel/ice/ice_base.c +12
-0+} + +static int ice_queue_stop (struct net_device *dev,void *per_queue_mem, +int idx) +{ +const struct ice_netdev_priv *priv =netdev_priv (dev); +struct ice_rx_ring *real = priv->vsi->rx_rings[idx]; +int ret; + + ret =__ice_qp_dis (priv->vsi, idx); +if (ret) +return ret;drivers/net/ethernet/intel/ice/ice_base.c int ice_qp_ena(struct ice_vsi *vsi, u16 q_idx) · line 1665
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_base.c +10
-0+ +page_pool_disable_direct_recycling (real->pp); +if (real->hdr_pp) +page_pool_disable_direct_recycling (real->hdr_pp); + +ice_zero_rx_ring (real); +memcpy (per_queue_mem, real,sizeof (*real)); + +return 0 ; +}Can this leak inflight page pool buffers?
ice_zero_rx_ring(real)is called before the memcpy toper_queue_mem, andice_zero_rx_ring()resets both indices:void
ice_zero_rx_ring(struct ice_rx_ring *rx_ring){ ... rx_ring->next_to_clean = 0; rx_ring->next_to_use = 0; }So
per_queue_memcaptures a ring wherenext_to_clean==next_to_use== 0.The core then invokes
ndo_queue_mem_free(dev, old_mem), and the recycle loop inice_queue_mem_free()is guarded by exactly those two indices:void
ice_queue_mem_free(struct net_device *dev, void *per_queue_mem){ ... for (u32 i = rx_ring->next_to_clean; i != rx_ring->next_to_use; ) { libeth_rx_recycle_slow(rx_ring->rx_fqes[i].netmem); if (rx_ring->hdr_pp) libeth_rx_recycle_slow(rx_ring->hdr_fqes[i].netmem); if (unlikely(++i == rx_ring->count)) i = 0; } ... ice_rxq_pp_destroy(rx_ring); }With 0 != 0 false on entry, the loop never runs, so any buffers that were in rx_fqes[old_ntc..old_ntu) (and hdr_fqes[] when header split is on) are never returned via
libeth_rx_recycle_slow().ice_rxq_pp_destroy()then kvfree()s the fqes arrays and callspage_pool_destroy()with outstanding inflight references that are no longer tracked anywhere.The new
ice_clean_rx_ring()wrapper keeps the original ordering:void
ice_clean_rx_ring(struct ice_rx_ring *rx_ring){ ice_queue_mem_free(rx_ring->netdev, rx_ring); ice_zero_rx_ring(rx_ring); }Should
ice_queue_stop()follow the same ordering and perform the memcpy beforeice_zero_rx_ring(real), so the recycle loop inice_queue_mem_free()sees the real ntc/ntu values?
Quoted 8 lines
drivers/net/ethernet/intel/ice/ice_base.c int ice_qp_ena(struct ice_vsi *vsi, u16 q_idx) · line 1673
Quoted 8 lines
drivers/net/ethernet/intel/ice/ice_base.c +8
-0+ +const struct netdev_queue_mgmt_ops ice_queue_mgmt_ops = { + .ndo_queue_mem_alloc = ice_queue_mem_alloc, + .ndo_queue_mem_free = ice_queue_mem_free, + .ndo_queue_mem_size =sizeof (struct ice_rx_ring ), + .ndo_queue_start = ice_queue_start, + .ndo_queue_stop = ice_queue_stop, +};
Those two are new to me, I'll double check.
Thanks,
Olek
Simon Horman
reviewerRe: [PATCH iwl-next v5 4/5] ice: implement Rx queue management ops
In reply to Alexander LobakinFrom: 'Simon Horman' <[email protected]>
This is an AI-generated review of your patch. The human sending this email has considered the AI review valid, or at least plausible. Full review at: https://sashiko.dev
---
ice: implement Rx queue management ops
Now ice is ready to get queue_mgmt_ops support. It already has API to disable/reconfig/enable one particular queue (for XSk). Reuse as much of its code as possible to implement Rx queue management callbacks and vice versa -- ice_queue_mem_{alloc,free}() can be reused during ifup/ifdown to elide code duplication. With this, ice passes the io_uring zcrx selftests, meaning the Rx part of netmem/MP support is done.
Quoted 12 lines
drivers/net/ethernet/intel/ice/ice_base.c +4
-0@@ -653,6 +653,43 @@ static int ice_rxq_pp_create(struct ice_rx_ring *rq)return err; } +static int ice_queue_mem_alloc (struct net_device *dev, +struct netdev_queue_config *qcfg, +void *per_queue_mem,int idx) +{
drivers/net/ethernet/intel/ice/ice_base.c static int ice_rxq_pp_create(struct ice_rx_ring *rq) · line 669
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_base.c +10
-0+const struct ice_netdev_priv *priv =netdev_priv (dev); +const struct ice_rx_ring *real = priv->vsi->rx_rings[idx]; +struct ice_rx_ring *new = per_queue_mem; +int ret; + + new->count = real->count; + new->netdev = real->netdev; + new->q_index = real->q_index; + new->q_vector = real->q_vector; + new->vsi = real->vsi;
Is it safe to assume netdev_priv(dev) returns the correct VSI here? For a loopback VSI (ICE_VSI_LB), it shares the PF's netdev, so priv->vsi resolves to the PF VSI.
Could this copy the PF VSI pointers to the loopback ring and cause hardware context corruption later?
[ ... ]
drivers/net/ethernet/intel/ice/ice_base.c static void ice_qp_reset_stats(struct ice_vsi *vsi, u16 q_idx) · line 1492
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_base.c +1
-8-/** -* ice_qp_dis - Disables a queue pair -* @vsi: VSI of interest -* @q_idx: ring index in array -* -* Returns 0 on success, negative on failure. -*/ -int ice_qp_dis (struct ice_vsi *vsi,u16 q_idx) +static int __ice_qp_dis (struct ice_vsi *vsi,u16 q_idx) {
Could this cause TX data corruption? This function appears to call synchronize_net() before netif_tx_stop_queue(), meaning the RCU barrier completes before the queue actually stops.
Concurrent transmissions might then race with ring modifications.
[ ... ]
Quoted 9 lines
drivers/net/ethernet/intel/ice/ice_base.c +9
-0+static int ice_queue_start (struct net_device *dev, +struct netdev_queue_config *qcfg, +void *per_queue_mem,int idx) +{ +const struct ice_netdev_priv *priv =netdev_priv (dev); +struct ice_rx_ring *real = priv->vsi->rx_rings[idx]; +struct ice_rx_ring *new = per_queue_mem; +struct napi_struct *napi; +int ret;
[ ... ]
drivers/net/ethernet/intel/ice/ice_base.c int ice_qp_ena(struct ice_vsi *vsi, u16 q_idx) · line 1644
Quoted 4 lines
drivers/net/ethernet/intel/ice/ice_base.c +4
-0+ ret =ice_alloc_rx_bufs (real,ICE_DESC_UNUSED (real)); + +return __ice_qp_ena (priv->vsi, idx, ret); +}
Does this cause a use-after-free via hardware DMA?
ice_alloc_rx_bufs() returns a boolean true (1) on success. This is passed to __ice_qp_ena() as the fail argument, which returns it back. Since ice_queue_start() returns a non-zero value, the core networking stack assumes failure and frees the queue memory, while the hardware queue remains active and DMAs into freed memory.
drivers/net/ethernet/intel/ice/ice_base.c int ice_qp_ena(struct ice_vsi *vsi, u16 q_idx) · line 1653
Quoted 9 lines
drivers/net/ethernet/intel/ice/ice_base.c +9
-0+ +static int ice_queue_stop (struct net_device *dev,void *per_queue_mem, +int idx) +{ +const struct ice_netdev_priv *priv =netdev_priv (dev); +struct ice_rx_ring *real = priv->vsi->rx_rings[idx]; +int ret; + + ret =__ice_qp_dis (priv->vsi, idx);
Does calling __ice_qp_dis() from ice_queue_stop() disrupt the global interface carrier state and TX queues?
__ice_qp_dis() calls netif_carrier_off() and cleans TX rings, but ice_queue_stop() is intended to be a granular, per-RX-queue operation.
drivers/net/ethernet/intel/ice/ice_base.c int ice_qp_ena(struct ice_vsi *vsi, u16 q_idx) · line 1657
Quoted 4 lines
drivers/net/ethernet/intel/ice/ice_base.c +4
-0+if (ret) +return ret; + +page_pool_disable_direct_recycling (real->pp);
Can this dereference a NULL pointer if the queue is configured with an AF_XDP zero-copy socket?
In that case, a standard page pool is not created and real->pp might be NULL, causing a panic in page_pool_disable_direct_recycling().
drivers/net/ethernet/intel/ice/ice_base.c int ice_qp_ena(struct ice_vsi *vsi, u16 q_idx) · line 1662
Quoted 5 lines
drivers/net/ethernet/intel/ice/ice_base.c +5
-0+if (real->hdr_pp) +page_pool_disable_direct_recycling (real->hdr_pp); + +ice_zero_rx_ring (real); +memcpy (per_queue_mem, real,sizeof (*real));
Could this lead to a memory leak of RX ring buffers?
ice_zero_rx_ring() clears the next_to_clean and next_to_use indices to 0 before the memcpy(). When the stack calls ice_queue_mem_free(per_queue_mem), it skips cleaning because next_to_clean == next_to_use, leaking all active skbs and page pool buffers.
Also, does this memcpy() leave dangling pointers in real that can lead to a double-free?
The dynamically allocated pointers like rx_fqes and pp are not set to NULL in real. When the interface is brought down later, ice_clean_rx_ring(real) may attempt to destroy the already-freed page pools again.
Quoted 3 lines
drivers/net/ethernet/intel/ice/ice_base.c +3
-0+ +return 0 ; +}
Alexander Lobakin
maintainerPATCH v5 5/5 ice: add support for transmitting unreadable frags
In reply to Alexander LobakinAdvertise netmem Tx support in ice. The only change needed is to set ICE_TX_BUF_FRAG conditionally, only when skb_frag_is_net_iov() is false. Otherwise, the Tx buffer type will be ICE_TX_BUF_EMPTY and the driver will skip the DMA unmapping operation.
--- drivers/net/ethernet/intel/ice/ice_main.c | 1 + drivers/net/ethernet/intel/ice/ice_sf_eth.c | 1 + drivers/net/ethernet/intel/ice/ice_txrx.c | 17 +++++++++++++---- 3 files changed, 15 insertions(+), 4 deletions(-)
drivers/net/ethernet/intel/ice/ice_main.c +1 -0
@@ -3453,6 +3453,7 @@ static void ice_set_ops(struct ice_vsi *vsi) netdev->netdev_ops = &ice_netdev_ops; netdev->queue_mgmt_ops = &ice_queue_mgmt_ops; + netdev->netmem_tx = true; netdev->udp_tunnel_nic_info = &pf->hw.udp_tunnel_nic; netdev->xdp_metadata_ops = &ice_xdp_md_ops;ice_set_ethtool_ops (netdev);
drivers/net/ethernet/intel/ice/ice_sf_eth.c +1 -0
@@ -59,6 +59,7 @@ static int ice_sf_cfg_netdev(struct ice_dynamic_port *dyn_port,ether_addr_copy (netdev->perm_addr, dyn_port->hw_addr); netdev->netdev_ops = &ice_sf_netdev_ops; netdev->queue_mgmt_ops = &ice_queue_mgmt_ops; + netdev->netmem_tx = true;SET_NETDEV_DEVLINK_PORT (netdev, devlink_port); err =register_netdev (netdev);
drivers/net/ethernet/intel/ice/ice_txrx.c +13 -4
@@ -113,11 +113,17 @@ ice_prgm_fdir_fltr(struct ice_vsi *vsi, struct ice_fltr_desc *fdir_desc,static void ice_unmap_and_free_tx_buf (struct ice_tx_ring *ring,struct ice_tx_buf *tx_buf) { -if (tx_buf->type !=ICE_TX_BUF_XDP_TX &&dma_unmap_len (tx_buf, len)) +switch (tx_buf->type) { +case ICE_TX_BUF_DUMMY : +case ICE_TX_BUF_FRAG : +case ICE_TX_BUF_SKB : +case ICE_TX_BUF_XDP_XMIT :dma_unmap_page (ring->dev,dma_unmap_addr (tx_buf, dma),dma_unmap_len (tx_buf, len),DMA_TO_DEVICE ); +break ; + }switch (tx_buf->type) {case ICE_TX_BUF_DUMMY :
@@ -338,12 +344,14 @@ static bool ice_clean_tx_irq(struct ice_tx_ring *tx_ring, int napi_budget) }/* unmap any remaining paged data */ -if (dma_unmap_len (tx_buf, len)) { +if (tx_buf->type !=ICE_TX_BUF_EMPTY ) {dma_unmap_page (tx_ring->dev,dma_unmap_addr (tx_buf, dma),dma_unmap_len (tx_buf, len),DMA_TO_DEVICE ); +dma_unmap_len_set (tx_buf, len,0 ); + tx_buf->type =ICE_TX_BUF_EMPTY ; } }ice_trace (clean_tx_irq_unmap_eop, tx_ring, tx_desc, tx_buf);
@@ -1495,7 +1503,8 @@ ice_tx_map(struct ice_tx_ring *tx_ring, struct ice_tx_buf *first, DMA_TO_DEVICE); tx_buf = &tx_ring->tx_buf[i]; - tx_buf->type =ICE_TX_BUF_FRAG ; +if (!skb_frag_is_net_iov (frag)) + tx_buf->type =ICE_TX_BUF_FRAG ; }/* record SW timestamp if HW timestamp is not available */
@@ -2377,7 +2386,7 @@ void ice_clean_ctrl_tx_irq(struct ice_tx_ring *tx_ring) }/* unmap the data header */ -if (dma_unmap_len (tx_buf, len)) +if (tx_buf->type !=ICE_TX_BUF_EMPTY ) dma_unmap_single(tx_ring->dev, dma_unmap_addr(tx_buf, dma), dma_unmap_len(tx_buf, len),
Signature · 1 line
2.54.0
Simon Horman
reviewerRe: [PATCH iwl-next v5 5/5] ice: add support for transmitting unreadable frags
From: 'Simon Horman' <[email protected]>
This is an AI-generated review of your patch. The human sending this email has considered the AI review valid, or at least plausible. Full review at: https://sashiko.dev
---
ice: add support for transmitting unreadable frags
This commit advertises netmem Tx support in the ice driver. It modifies the transmit path to conditionally set the buffer type to ICE_TX_BUF_FRAG only when the fragment is not a net_iov, allowing the driver to skip DMA unmapping operations for unreadable fragments.
drivers/net/ethernet/intel/ice/ice_main.c static void ice_set_ops(struct ice_vsi *vsi) · line 3457
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_main.c +1
-0@@ -3453,6 +3453,7 @@ static void ice_set_ops(struct ice_vsi *vsi) netdev->netdev_ops = &ice_netdev_ops; netdev->queue_mgmt_ops = &ice_queue_mgmt_ops; + netdev->netmem_tx = true; netdev->udp_tunnel_nic_info = &pf->hw.udp_tunnel_nic;
By setting netmem_tx to true here, the driver accepts packets containing net_iov fragments. If a net_iov packet exceeds ICE_MAX_BUF_TXD fragments, it appears it will fall back to linearization in the transmit path.
Since __skb_linearize() uses CPU memory accessors that expect a valid struct page, will this cause an invalid memory access when skb_frag_page() returns a net_iov pointer?
Should the driver explicitly drop highly fragmented net_iov packets instead of attempting to linearize them?
[ ... ]
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_txrx.c +1
-1@@ -113,11 +113,17 @@ ice_prgm_fdir_fltr(struct ice_vsi *vsi, struct ice_fltr_desc *fdir_desc,static void ice_unmap_and_free_tx_buf (struct ice_tx_ring *ring,struct ice_tx_buf *tx_buf) { -if (tx_buf->type !=ICE_TX_BUF_XDP_TX &&dma_unmap_len (tx_buf, len)) +switch (tx_buf->type) {
drivers/net/ethernet/intel/ice/ice_txrx.c ice_prgm_fdir_fltr(struct ice_vsi *vsi, struct ice_fltr_desc *fdir_desc, · line 126
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_txrx.c +6
-0+case ICE_TX_BUF_DUMMY : +case ICE_TX_BUF_FRAG : +case ICE_TX_BUF_SKB : +case ICE_TX_BUF_XDP_XMIT :dma_unmap_page (ring->dev,dma_unmap_addr (tx_buf, dma),dma_unmap_len (tx_buf, len),DMA_TO_DEVICE ); +break ; + }
Does removing the dma_unmap_len() check alter the safety of the DMA error recovery path?
If a mapping fails in ice_tx_map(), execution jumps to dma_error and calls ice_unmap_and_free_tx_buf(). Since the failure happens before dma_unmap_len_set() updates the descriptor, it seems this might unconditionally unmap using stale descriptor state.
Could this result in 0-length unmaps or erroneously unmapping persistent net_iov memory?
[ ... ]
Quoted 5 lines
drivers/net/ethernet/intel/ice/ice_txrx.c +0
-1@@ -338,12 +344,14 @@ static bool ice_clean_tx_irq(struct ice_tx_ring *tx_ring, int napi_budget) }/* unmap any remaining paged data */ -if (dma_unmap_len (tx_buf, len)) {
drivers/net/ethernet/intel/ice/ice_txrx.c static bool ice_clean_tx_irq(struct ice_tx_ring *tx_ring, int napi_budget) · line 356
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_txrx.c +3
-0+if (tx_buf->type !=ICE_TX_BUF_EMPTY ) {dma_unmap_page (tx_ring->dev,dma_unmap_addr (tx_buf, dma),dma_unmap_len (tx_buf, len),DMA_TO_DEVICE ); +dma_unmap_len_set (tx_buf, len,0 ); + tx_buf->type =ICE_TX_BUF_EMPTY ; } }
When mapping a net_iov fragment in ice_tx_map(), the descriptor is populated with the length and DMA address, but tx_buf->type remains ICE_TX_BUF_EMPTY.
Because dma_unmap_len_set(tx_buf, len, 0) is now placed inside the tx_buf->type != ICE_TX_BUF_EMPTY check, does this skip clearing the len and dma fields for net_iov descriptors when they are returned to the free pool?
If these descriptor fields are leaked, could they be incorrectly unmapped later if the descriptor is reused and a subsequent mapping fails?
Alexander Lobakin
maintainerFrom: Alexander Lobakin <[email protected]>
Date: Tue, 5 May 2026 17:29:18 +0200
Quoted 11 lines
Now that ice uses libeth for managing Rx buffers and supports configurable header split, it's ready to get support for sending and receiving packets with unreadable (to the kernel) frags.
Extend libeth just a little bit to allow creating PPs with custom memory providers and make sure ice works correctly with the netdev ops locking. Then add the full set of
queue_mgmt_opsand don't unmap unreadable frags on Tx completion.
No perf regressions for the regular flows and no code duplication implied.
Quoted 3 lines
Credits to the fbnic developers, whose code helped me understand the memory providers and
queue_mgmt_opslogics and served as a reference.
Hi,
A week ago .ndo_set_rx_mode_async() was introduced.
I didn't know that it's mandatory to switch to it when converting to netdev_ops lock.
So I guess I'll need a new respin :c
Thanks,
Olek