Skip to contentSkip to conversation

Interrupts helper in libie

PATCH In review Michal Swiatkowski 4 participants 21 messages Sep 11 – Nov 7

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v2 cover Interrupts helper in libie

Hi,

To not copy the same code to handle interrupts in ixd driver move it to libie_irq module and use in both idpf and ixd.

First part is changing current idpf code to make it more friendly to be moved to the lib. Basically there is no need to store MSI-X entries in separate table. Instead of that store it in xarray which also replace custom lifo implementation.

Patch with libie is about moving the code to the new module. No functional changes here, just moving the code or adding some more descriptions.

The irq code is similar in ice. One patch also coverd the changes in ice driver.

Last patches is the implementation in ixd driver. To manage MSI-X it needs to first map correct regions. Do this using virtchnl command, similiary as in idpf.

v1 --> v2: [1]
* patch 05
- New struct idpf_rdma_irq { entries, map, num } replaces adapter->rdma_msix_entries and adapter->num_rdma_msix_entries. idpf_idc.c is now touched by this patch to follow the rename.
- Removed the idpf_rdma_entry_to_index() helper. v1 reverse-looked-up the libie index from msix_entry.entry on every free; v2 stores the struct msi_map directly in rdma_irq->map[].
- idpf_rdma_intr_init() now allocates rdma_irq->map as well and unwinds both arrays on failure; idpf_rdma_intr_free() frees both.
- libie_irq_deinit() sets irq->pdev = NULL at the end.
- libie_get_irq() gains an "if (!irq->pdev) return NULL;" guard.
- libie_irq_free() guard changed from "if (!map.virq || map.index < 0)" to "if (map.virq <= 0 || map.index < 0)".
- idpf_vport_intr_alloc(): tmp_irqs changed from __free(kfree) to a plain pointer with an explicit kfree() on every error path and on success; loop variable i hoisted to function scope.
- idpf_mb_intr_init(): the libie_irq_alloc() call moved above the index check (cosmetic).

* patch 06
- Dropped Reviewed-by: Ahmed Zaki <[email protected]>.
- Otherwise only context churn from the idpf_rdma_irq change in patch 05.

* patch 07
- Dropped Reviewed-by: Ahmed Zaki <[email protected]>.
- include/linux/net/intel/libie/irq.h no longer includes <linux/net/intel/virtchnl2.h>; it forward declares
struct virtchnl2_get_capabilities and struct virtchnl2_alloc_vectors instead.

* patch 08
- Commit message corrected. v1 claimed the allocation order was preserved

- LIBIE_IRQ_ANY is now introduced here rather than in patch 05: the enum value, the kernel-doc entries, and the struct xa_limit local plus the dynamic-then-static fallback in libie_get_irq() all moved into this patch.

* patch 09
- Removed the hardcoded PF_PCI_0/1/2 offset and size defines from ixd_lan_regs.h and the static ixd_running_regions[] table. ixd_iomap_running_regions() now computes the three ranges around the mailbox and reset registers from PF_FW_MBX, PFGEN_RTRIG and pci_resource_len().
- ixd_start_regions[] made static, with a comment explaining it stays mapped for the whole driver life.
- uint i -> unsigned int i in ixd_iomap_is_not_start_region().
- New ixd_fill_caps() requests VIRTCHNL2_CAP_LAN_MEMORY_REGIONS in GET_CAPS, and new ixd_is_cap_ena() helper. ixd_vc_dev_init() now selects the path based on the negotiated capability instead of sending the command and falling back on error.
- ixd_handle_lan_mmio_regions(): bounds check uses struct_size(recv_mmio, mem_reg, num_regions) instead of the open-coded sizeof() + sizeof() * n; zero-size padding regions are skipped; the unused err variable is gone.

* patch 10
- Register addresses are resolved once and cached in the new adapter->mb_dyn_ctl and adapter->oicr_ena via the new ixd_mailbox_irq_regs_init(), with a NULL check returning -EINVAL. v1 called libie_pci_get_mmio_addr() on every enable with no NULL check.
- New ixd_mailbox_irq_disable().
- ixd_mailbox_irq_deinit() rewritten: early return on the flag, disable the interrupt in HW, then cancel_delayed_work_sync(&adapter->mbx_task) before free_irq(). v1 instead re-queued mbx_task after freeing the irq.
- ixd_mailbox_irq_init() now handles kasprintf() returning NULL (frees the libie irq, returns -ENOMEM). v1 passed a possibly NULL name to request_irq().
- ixd_remove(): ixd_deinit_interrupts() moved earlier, before libie_ctlq_xn_shutdown() and ixd_trigger_reset(), instead of after them.

[1] https://lore.kernel.org/netdev/[email protected]/

Michal Swiatkowski (10):
idpf: store HW vectors information
idpf: fill q_vector interrupt registers one by one
idpf: get rid of msix_entries array
idpf: drop v_idx from q_vector structure
libie, idpf: move irq code to libie
libie, idpf: move hardware irq info struct to libie libie, idpf: move parsing alloc vectors command to libie
ice: use libie_irq for interrupts managing
ixd: support for getting lan memory regions
ixd: use interrupt for mailbox communication

 drivers/net/ethernet/intel/Kconfig            |   1 +
 drivers/net/ethernet/intel/ice/ice.h          |   5 +-
 drivers/net/ethernet/intel/ice/ice_base.c     |   4 +-
 drivers/net/ethernet/intel/ice/ice_idc.c      |   4 +-
 drivers/net/ethernet/intel/ice/ice_irq.c      | 181 +-------
 drivers/net/ethernet/intel/ice/ice_irq.h      |  14 -
 drivers/net/ethernet/intel/ice/ice_lib.c      |   3 -
 drivers/net/ethernet/intel/ice/ice_main.c     |  15 +-
 drivers/net/ethernet/intel/idpf/Kconfig       |   1 +
 drivers/net/ethernet/intel/idpf/idpf.h        |  88 ++--
 drivers/net/ethernet/intel/idpf/idpf_dev.c    | 108 ++---
 drivers/net/ethernet/intel/idpf/idpf_idc.c    |   6 +-
 drivers/net/ethernet/intel/idpf/idpf_lib.c    | 425 +++++-------------
 drivers/net/ethernet/intel/idpf/idpf_main.c   |   3 +-
 drivers/net/ethernet/intel/idpf/idpf_txrx.c   | 142 +++---
 drivers/net/ethernet/intel/idpf/idpf_txrx.h   |  23 +-
 drivers/net/ethernet/intel/idpf/idpf_vf_dev.c | 109 ++---
 .../net/ethernet/intel/idpf/idpf_virtchnl.c   | 159 +------
 .../net/ethernet/intel/idpf/idpf_virtchnl.h   |   9 +-
 drivers/net/ethernet/intel/ixd/Kconfig        |   1 +
 drivers/net/ethernet/intel/ixd/ixd.h          |  31 ++
 drivers/net/ethernet/intel/ixd/ixd_ctlq.c     |   8 +-
 drivers/net/ethernet/intel/ixd/ixd_lan_regs.h |  10 +
 drivers/net/ethernet/intel/ixd/ixd_lib.c      | 126 ++++++
 drivers/net/ethernet/intel/ixd/ixd_main.c     | 133 +++++-
 drivers/net/ethernet/intel/ixd/ixd_virtchnl.c |  90 +++-
 drivers/net/ethernet/intel/libie/Kconfig      |   6 +
 drivers/net/ethernet/intel/libie/Makefile     |   4 +
 drivers/net/ethernet/intel/libie/irq.c        | 368 +++++++++++++++
 include/linux/net/intel/libie/irq.h           | 120 +++++
 30 files changed, 1250 insertions(+), 947 deletions(-)
 create mode 100644 drivers/net/ethernet/intel/libie/irq.c
 create mode 100644 include/linux/net/intel/libie/irq.h
Signature · 1 line
2.49.0
#1 lore raw

PATCH v2 1/10 idpf: store HW vectors information

Currently hardware vectors information (registers address and HW indexes) is stored in virtchnl command. When this information is needed they are parsed and returned. There is a need for alloc/free array for this information each time it is called.

Information about indexes and registers are parsed in two similar functions. Create one parse function for both and store it in irq_info structure to use whenever it is needed.

Stored virtchnl command still has to exist, because it is used when sending dealloc message.

Make intr_reg_init() functions (for VF and PF) return void to simplify code. With stored irq information there is no need to alloc an array for it, so these functions can't fail.

Previously mailbox vector wasn't filled in idpf_intr_reg_init() function. Store the mailbox information in irq_info.vectors to have everything in one place. Because of that tweak index in few places by adding IDPF_MBX_Q_VEC (when allocatig or iterrating) or not substracting IDPF_MBX_Q_VEC from q_vector_idxs, because it is no needed now.

---
 drivers/net/ethernet/intel/idpf/idpf.h        |  41 +++-
 drivers/net/ethernet/intel/idpf/idpf_dev.c    |  51 ++---
 drivers/net/ethernet/intel/idpf/idpf_lib.c    |  34 +---
 drivers/net/ethernet/intel/idpf/idpf_txrx.c   |  42 +---
 drivers/net/ethernet/intel/idpf/idpf_txrx.h   |  13 --
 drivers/net/ethernet/intel/idpf/idpf_vf_dev.c |  51 ++---
 .../net/ethernet/intel/idpf/idpf_virtchnl.c   | 184 ++++++++----------
 .../net/ethernet/intel/idpf/idpf_virtchnl.h   |   6 -
 8 files changed, 176 insertions(+), 246 deletions(-)
drivers/net/ethernet/intel/idpf/idpf.h +39 -2
index df9e42bfeaa2..84b145431693 100644
@@ -36,6 +36,7 @@ struct idpf_rss_data;
 #define IDPF_NUM_FILTERS_PER_MSG	20
 #define IDPF_NUM_DFLT_MBX_Q		2	/* includes both TX and RX */
 #define IDPF_DFLT_MBX_Q_LEN		64
+#define IDPF_MBX_IRQ_INDEX		0
 /* maximum number of times to try before resetting mailbox */
 #define IDPF_MB_MAX_ERR			20
 #define IDPF_NUM_CHUNKS_PER_MSG(struct_sz, chunk_sz)	\
@@ -204,8 +205,8 @@ struct idpf_vport_max_q {
 struct idpf_reg_ops {
 	void (*ctlq_reg_init)(struct libie_mmio_info *mmio,
 			      struct libie_ctlq_create_info *cctlq_info);
-	int (*intr_reg_init)(struct idpf_vport *vport,
-			     struct idpf_q_vec_rsrc *rsrc);
+	void (*intr_reg_init)(struct idpf_vport *vport,
+			      struct idpf_q_vec_rsrc *rsrc);
 	void (*mb_intr_reg_init)(struct idpf_adapter *adapter);
 	void (*reset_reg_init)(struct idpf_adapter *adapter);
 	void (*trigger_reset)(struct idpf_adapter *adapter,
@@ -614,6 +615,40 @@ struct idpf_vport_config {
 	     iter = (++__##iter) < &(adapter)->vports[(adapter)->max_vports] ? \
 	     *__##iter : NULL)
 
+/**
+ * struct idpf_vec_regs - hardware registers related to vector
+ * @dyn_ctl: Dynamic control interrupt register offset
+ * @itrn: Interrupt Throttling Rate register offset
+ * @itrn_index_spacing: Register spacing between ITR registers of the same
+ *			vector
+ */
+struct idpf_vec_regs {
+	u32 dyn_ctl;
+	u32 itrn;
+	u32 itrn_index_spacing;
+};
+
+/**
+ * struct idpf_hw_vector - single hardware vector info
+ * @regs: address of irq registers
+ * @idx: hardware vector index
+ */
+struct idpf_hw_vector {
+	struct idpf_vec_regs regs;
+	int idx;
+};
+
+/**
+ * struct idpf_irq_info - hardware data needed to setup irq
+ * @vectors: allocated during initialization store hardware information
+ *	     for all vectors that can be used on a whole device
+ * @num: amount of vectors stored here
+ */
+struct idpf_irq_info {
+	struct idpf_hw_vector *vectors;
+	int num;
+};
+
 /**
  * struct idpf_adapter - Device data struct generated on probe
  * @pdev: PCI device struct given on probe
@@ -633,6 +668,7 @@ struct idpf_vport_config {
  * @msix_entries: MSIX table
  * @num_rdma_msix_entries: Available number of MSIX vectors for RDMA
  * @rdma_msix_entries: RDMA MSIX table
+ * @irq_info: hardware data needed to setup irq
  * @req_vec_chunks: Requested vector chunk data
  * @mb_vector: Mailbox vector data
  * @vector_stack: Stack to store the msix vector indexes
@@ -693,6 +729,7 @@ struct idpf_adapter {
 	u16 num_rdma_msix_entries;
 	struct msix_entry *rdma_msix_entries;
 	struct virtchnl2_alloc_vectors *req_vec_chunks;
+	struct idpf_irq_info irq_info;
 	struct idpf_q_vector mb_vector;
 	struct idpf_vector_lifo vector_stack;
 	irqreturn_t (*irq_mb_handler)(int irq, void *data);
drivers/net/ethernet/intel/idpf/idpf_dev.c +18 -33

94 lines not on this page · raw message

drivers/net/ethernet/intel/idpf/idpf_lib.c +8 -26
index 5d61ecb73a40..36bb6a268042 100644
@@ -305,16 +305,14 @@ int idpf_req_rel_vector_indexes(struct idpf_adapter *adapter,
  */
 int idpf_intr_req(struct idpf_adapter *adapter)
 {
-	u16 num_lan_vecs, min_lan_vecs, num_rdma_vecs = 0, min_rdma_vecs = 0;
+	int num_rdma_vecs = 0, min_rdma_vecs = 0, num_lan_vecs = 0;
 	u16 default_vports = idpf_get_default_vports(adapter);
-	int num_q_vecs, total_vecs, num_vec_ids;
-	int min_vectors, actual_vecs, err;
+	int min_vectors, actual_vecs, min_lan_vecs, err;
+	int num_q_vecs, total_vecs;
 	unsigned int vector;
-	u16 *vecids;
 	int i;
 
 	total_vecs = idpf_get_reserved_vecs(adapter);
-	num_lan_vecs = total_vecs;
 	if (idpf_is_rdma_cap_ena(adapter)) {
 		num_rdma_vecs = idpf_get_reserved_rdma_vecs(adapter);
 		min_rdma_vecs = IDPF_MIN_RDMA_VEC;
@@ -376,28 +374,15 @@ int idpf_intr_req(struct idpf_adapter *adapter)
 		goto free_rdma_msix;
 	}
 
-	adapter->mb_vector.v_idx = le16_to_cpu(adapter->caps.mailbox_vector_id);
-
-	vecids = kcalloc(actual_vecs, sizeof(u16), GFP_KERNEL);
-	if (!vecids) {
-		err = -ENOMEM;
-		goto free_msix;
-	}
-
-	num_vec_ids = idpf_get_vec_ids(adapter, vecids, actual_vecs,
-				       &adapter->req_vec_chunks->vchunks);
-	if (num_vec_ids < actual_vecs) {
-		err = -EINVAL;
-		goto free_vecids;
-	}
-
 	for (vector = 0; vector < num_lan_vecs; vector++) {
-		adapter->msix_entries[vector].entry = vecids[vector];
+		adapter->msix_entries[vector].entry =
+			adapter->irq_info.vectors[vector].idx;
 		adapter->msix_entries[vector].vector =
 			pci_irq_vector(adapter->pdev, vector);
 	}
 	for (i = 0; i < num_rdma_vecs; vector++, i++) {
-		adapter->rdma_msix_entries[i].entry = vecids[vector];
+		adapter->rdma_msix_entries[i].entry =
+			adapter->irq_info.vectors[vector].idx;
 		adapter->rdma_msix_entries[i].vector =
 			pci_irq_vector(adapter->pdev, vector);
 	}
@@ -414,20 +399,17 @@ int idpf_intr_req(struct idpf_adapter *adapter)
 	/* Fill MSIX vector lifo stack with vector indexes */
 	err = idpf_init_vector_stack(adapter);
 	if (err)
-		goto free_vecids;
+		goto free_msix;
 
 	err = idpf_mb_intr_init(adapter);
 	if (err)
 		goto deinit_vec_stack;
 	idpf_mb_irq_enable(adapter);
-	kfree(vecids);
 
 	return 0;
 
 deinit_vec_stack:
 	idpf_deinit_vector_stack(adapter);
-free_vecids:
-	kfree(vecids);
 free_msix:
 	kfree(adapter->msix_entries);
 	adapter->msix_entries = NULL;
drivers/net/ethernet/intel/idpf/idpf_txrx.c +7 -35

65 lines not on this page · raw message

drivers/net/ethernet/intel/idpf/idpf_txrx.h +0 -13
index dce07fbb6e77..ecff84df776d 100644
@@ -318,19 +318,6 @@ enum idpf_queue_flags_t {
 #define idpf_queue_assign(f, q, v)			\
 	__assign_bit(__IDPF_Q_##f, (q)->flags, v)
 
-/**
- * struct idpf_vec_regs
- * @dyn_ctl_reg: Dynamic control interrupt register offset
- * @itrn_reg: Interrupt Throttling Rate register offset
- * @itrn_index_spacing: Register spacing between ITR registers of the same
- *			vector
- */
-struct idpf_vec_regs {
-	u32 dyn_ctl_reg;
-	u32 itrn_reg;
-	u32 itrn_index_spacing;
-};
-
 /**
  * struct idpf_intr_reg
  * @dyn_ctl: Dynamic control interrupt register
drivers/net/ethernet/intel/idpf/idpf_vf_dev.c +18 -33

94 lines not on this page · raw message

drivers/net/ethernet/intel/idpf/idpf_virtchnl.c +86 -98

214 lines not on this page · raw message

drivers/net/ethernet/intel/idpf/idpf_virtchnl.h +0 -6
index 5d27805ff40f..ec4c79191c85 100644
@@ -10,7 +10,6 @@
 
 struct idpf_adapter;
 struct idpf_netdev_priv;
-struct idpf_vec_regs;
 struct idpf_vport;
 struct idpf_vport_max_q;
 struct idpf_vport_config;
@@ -21,8 +20,6 @@ void idpf_deinit_dflt_mbx(struct idpf_adapter *adapter);
 int idpf_vc_core_init(struct idpf_adapter *adapter);
 void idpf_vc_core_deinit(struct idpf_adapter *adapter);
 
-int idpf_get_reg_intr_vecs(struct idpf_adapter *adapter,
-			   struct idpf_vec_regs *reg_vals, int num_vecs);
 int idpf_queue_reg_init(struct idpf_vport *vport,
 			struct idpf_q_vec_rsrc *rsrc,
 			struct idpf_queue_id_reg_info *chunks);
@@ -129,9 +126,6 @@ int idpf_send_delete_queues_msg(struct idpf_adapter *adapter,
 
 int idpf_vport_alloc_vec_indexes(struct idpf_vport *vport,
 				 struct idpf_q_vec_rsrc *rsrc);
-int idpf_get_vec_ids(struct idpf_adapter *adapter,
-		     u16 *vecids, int num_vecids,
-		     struct virtchnl2_vector_chunks *chunks);
 int idpf_send_alloc_vectors_msg(struct idpf_adapter *adapter, u16 num_vectors);
 int idpf_send_dealloc_vectors_msg(struct idpf_adapter *adapter);
 int idpf_send_map_unmap_queue_vector_msg(struct idpf_adapter *adapter,
Signature · 1 line
2.49.0
Tested-by on v2 1/10
#2 lore raw

RE: [PATCH iwl-next v2 01/10] idpf: store HW vectors information

Quoted 31 lines

-----Original Message-----
From: Michal Swiatkowski <[email protected]>
Sent: Friday, September 11, 2026 5:49 AM
To: [email protected]
Cc: [email protected]; Michal Swiatkowski <[email protected]>; Loktionov, Aleksandr <[email protected]>
Subject: [PATCH iwl-next v2 01/10] idpf: store HW vectors information

Currently hardware vectors information (registers address and HW indexes) is stored in virtchnl command. When this information is needed they are parsed and returned. There is a need for alloc/free array for this information each time it is called.

Information about indexes and registers are parsed in two similar functions. Create one parse function for both and store it in irq_info structure to use whenever it is needed.

Stored virtchnl command still has to exist, because it is used when sending dealloc message.

Make intr_reg_init() functions (for VF and PF) return void to simplify code. With stored irq information there is no need to alloc an array for it, so these functions can't fail.

Previously mailbox vector wasn't filled in idpf_intr_reg_init() function. Store the mailbox information in irq_info.vectors to have everything in one place. Because of that tweak index in few places by adding IDPF_MBX_Q_VEC (when allocatig or iterrating) or not substracting IDPF_MBX_Q_VEC from q_vector_idxs, because it is no needed now.

Quoted 3 lines

---

#3 lore raw

PATCH v2 2/10 idpf: fill q_vector interrupt registers one by one

In reply to Michal Swiatkowski

Most structures pointer used in *_intr_reg_init() are already used in idpf_vport_intr_req_irq(). Use it by rewriting *_intr_reg_init() to fill one q_vector in one call.

---
 drivers/net/ethernet/intel/idpf/idpf.h        |  7 +-
 drivers/net/ethernet/intel/idpf/idpf_dev.c    | 91 +++++++++---------
 drivers/net/ethernet/intel/idpf/idpf_txrx.c   |  7 +-
 drivers/net/ethernet/intel/idpf/idpf_vf_dev.c | 92 ++++++++++---------
 4 files changed, 105 insertions(+), 92 deletions(-)
drivers/net/ethernet/intel/idpf/idpf.h +5 -2
index 84b145431693..5eafabacd167 100644
@@ -197,6 +197,7 @@ struct idpf_vport_max_q {
  * struct idpf_reg_ops - Device specific register operation function pointers
  * @ctlq_reg_init: Mailbox control queue register initialization
  * @intr_reg_init: Traffic interrupt register initialization
+ * @noirq_intr_reg_init: Vector without interrupt register initialization
  * @mb_intr_reg_init: Mailbox interrupt register initialization
  * @reset_reg_init: Reset register initialization
  * @trigger_reset: Trigger a reset to occur
@@ -205,8 +206,10 @@ struct idpf_vport_max_q {
 struct idpf_reg_ops {
 	void (*ctlq_reg_init)(struct libie_mmio_info *mmio,
 			      struct libie_ctlq_create_info *cctlq_info);
-	void (*intr_reg_init)(struct idpf_vport *vport,
-			      struct idpf_q_vec_rsrc *rsrc);
+	void (*intr_reg_init)(struct idpf_adapter *adapter,
+			      struct idpf_q_vector *q_vector, u16 idx);
+	void (*noirq_intr_reg_init)(struct idpf_adapter *adapter,
+				    struct idpf_q_vec_rsrc *rsrc, u16 idx);
 	void (*mb_intr_reg_init)(struct idpf_adapter *adapter);
 	void (*reset_reg_init)(struct idpf_adapter *adapter);
 	void (*trigger_reset)(struct idpf_adapter *adapter,
drivers/net/ethernet/intel/idpf/idpf_dev.c +47 -44

112 lines not on this page · raw message

drivers/net/ethernet/intel/idpf/idpf_txrx.c +5 -2
index 2b21f599f569..00c8fe692821 100644
@@ -4054,6 +4054,9 @@ static int idpf_vport_intr_req_irq(struct idpf_vport *vport,
 	const char *drv_name, *if_name, *vec_name;
 	int vector, err, irq_num, vidx;
 
+	vidx = rsrc->q_vector_idxs[rsrc->num_q_vectors];
+	adapter->dev_ops.reg_ops.noirq_intr_reg_init(adapter, rsrc, vidx);
+
 	drv_name = dev_driver_string(&adapter->pdev->dev);
 	if_name = netdev_name(vport->netdev);
 
@@ -4064,6 +4067,8 @@ static int idpf_vport_intr_req_irq(struct idpf_vport *vport,
 		vidx = rsrc->q_vector_idxs[vector];
 		irq_num = adapter->msix_entries[vidx].vector;
 
+		adapter->dev_ops.reg_ops.intr_reg_init(adapter, q_vector, vidx);
+
 		if (q_vector->num_rxq && q_vector->num_txq)
 			vec_name = "TxRx";
 		else if (q_vector->num_rxq)
@@ -4649,8 +4654,6 @@ int idpf_vport_intr_init(struct idpf_vport *vport, struct idpf_q_vec_rsrc *rsrc)
 	idpf_vport_intr_map_vector_to_qs(vport, rsrc);
 	idpf_vport_intr_napi_add_all(vport, rsrc);
 
-	vport->adapter->dev_ops.reg_ops.intr_reg_init(vport, rsrc);
-
 	err = idpf_vport_intr_req_irq(vport, rsrc);
 	if (err)
 		goto unroll_vectors_alloc;
drivers/net/ethernet/intel/idpf/idpf_vf_dev.c +48 -44

113 lines not on this page · raw message

Signature · 1 line
2.49.0
Tested-by on v2 2/10
#4 lore raw

RE: [PATCH iwl-next v2 02/10] idpf: fill q_vector interrupt registers one by one

Quoted 11 lines

-----Original Message-----
From: Michal Swiatkowski <[email protected]>
Sent: Friday, September 11, 2026 5:49 AM
To: [email protected]
Cc: [email protected]; Michal Swiatkowski <[email protected]>; Loktionov, Aleksandr <[email protected]>; Chittim, Madhu <[email protected]>
Subject: [PATCH iwl-next v2 02/10] idpf: fill q_vector interrupt registers one by one

Quoted 8 lines

Most structures pointer used in *_intr_reg_init() are already used in idpf_vport_intr_req_irq(). Use it by rewriting *_intr_reg_init() to fill one q_vector in one call.

---

#5 lore raw

PATCH v2 3/10 idpf: get rid of msix_entries array

In reply to Michal Swiatkowski

There is no special need for storing MSI-X info in one array. Instead move this data into q_vector where it is commonly used. With that one layer of accessing correct kernel irq line number can be dropped.

Moving pci_irq_vector() after q_vectors creation will be useful when switching to dynamic irq allocation.

---
 drivers/net/ethernet/intel/idpf/idpf.h      |  2 -
 drivers/net/ethernet/intel/idpf/idpf_lib.c  | 45 ++++++---------
 drivers/net/ethernet/intel/idpf/idpf_txrx.c | 61 +++++++++++----------
 drivers/net/ethernet/intel/idpf/idpf_txrx.h |  5 +-
 4 files changed, 51 insertions(+), 62 deletions(-)
drivers/net/ethernet/intel/idpf/idpf.h +0 -2
index 5eafabacd167..86e5bb30ecc6 100644
@@ -668,7 +668,6 @@ struct idpf_irq_info {
  * @xnm: Xn transaction manager
  * @num_avail_msix: Available number of MSIX vectors
  * @num_msix_entries: Number of entries in MSIX table
- * @msix_entries: MSIX table
  * @num_rdma_msix_entries: Available number of MSIX vectors for RDMA
  * @rdma_msix_entries: RDMA MSIX table
  * @irq_info: hardware data needed to setup irq
@@ -728,7 +727,6 @@ struct idpf_adapter {
 	struct libie_ctlq_xn_manager *xnm;
 	u16 num_avail_msix;
 	u16 num_msix_entries;
-	struct msix_entry *msix_entries;
 	u16 num_rdma_msix_entries;
 	struct msix_entry *rdma_msix_entries;
 	struct virtchnl2_alloc_vectors *req_vec_chunks;
drivers/net/ethernet/intel/idpf/idpf_lib.c +16 -29

104 lines not on this page · raw message

drivers/net/ethernet/intel/idpf/idpf_txrx.c +31 -30

144 lines not on this page · raw message

drivers/net/ethernet/intel/idpf/idpf_txrx.h +4 -1
index ecff84df776d..57e61936ffda 100644
@@ -6,6 +6,7 @@
 
 #include <linux/dim.h>
 #include <linux/net/intel/virtchnl2_lan_desc.h>
+#include <linux/pci.h>
 
 #include <net/libeth/cache.h>
 #include <net/libeth/types.h>
@@ -377,6 +378,7 @@ struct idpf_intr_reg {
  * @rx_intr_mode: Dynamic ITR or not
  * @rx_itr_idx: RX ITR index
  * @v_idx: Vector index
+ * @irq: kernel and driver irq numbers
  */
 struct idpf_q_vector {
 	__cacheline_group_begin_aligned(read_mostly);
@@ -418,12 +420,13 @@ struct idpf_q_vector {
 	__cacheline_group_begin_aligned(cold);
 	u16 v_idx;
 
+	struct msi_map irq;
 	__cacheline_group_end_aligned(cold);
 };
 libeth_cacheline_set_assert(struct idpf_q_vector, 136,
 			    56 + sizeof(struct napi_struct) +
 			    2 * sizeof(struct dim),
-			    8);
+			    8 + sizeof(struct msi_map));
 
 struct idpf_rx_queue_stats {
 	u64_stats_t packets;
Signature · 1 line
2.49.0
Tested-by on v2 3/10
#6 lore raw

RE: [PATCH iwl-next v2 03/10] idpf: get rid of msix_entries array

Quoted 14 lines

-----Original Message-----
From: Michal Swiatkowski <[email protected]>
Sent: Friday, September 11, 2026 5:49 AM
To: [email protected]
Cc: [email protected]; Michal Swiatkowski <[email protected]>; Loktionov, Aleksandr <[email protected]>; Zaremba, Larysa <[email protected]>; Chittim, Madhu <[email protected]>
Subject: [PATCH iwl-next v2 03/10] idpf: get rid of msix_entries array

There is no special need for storing MSI-X info in one array. Instead move this data into q_vector where it is commonly used. With that one layer of accessing correct kernel irq line number can be dropped.

Quoted 8 lines

Moving pci_irq_vector() after q_vectors creation will be useful when switching to dynamic irq allocation.

---

#7 lore raw

PATCH v2 4/10 idpf: drop v_idx from q_vector structure

In reply to Michal Swiatkowski

Storing another index related to irq in q_vector can be misleading. It is only used when matching q_vectors with queues. It can be obtained using 0-based software irq index.

Use irq.index (from q_vector) and get the hardware irq index (q_vector->v_idx earlier) from irq_info structure.

---
 drivers/net/ethernet/intel/idpf/idpf.h          |  2 +-
 drivers/net/ethernet/intel/idpf/idpf_txrx.c     |  4 +---
 drivers/net/ethernet/intel/idpf/idpf_txrx.h     |  5 +----
 drivers/net/ethernet/intel/idpf/idpf_virtchnl.c | 11 +++++++----
 4 files changed, 10 insertions(+), 12 deletions(-)
drivers/net/ethernet/intel/idpf/idpf.h +1 -1
index 86e5bb30ecc6..785d551c795d 100644
@@ -301,7 +301,7 @@ struct idpf_fsteer_fltr {
  * @q_vectors: array of queue vectors
  * @q_vector_idxs: starting index of queue vectors
  * @num_q_vectors: number of IRQ vectors allocated
- * @noirq_v_idx: ID of the NOIRQ vector
+ * @noirq_v_idx: software IRQ index used to get hardware vector information
  * @noirq_dyn_ctl_ena: value to write to the above to enable it
  * @noirq_dyn_ctl: register to enable/disable the vector for NOIRQ queues
  * @txq_grps: array of TX queue groups
drivers/net/ethernet/intel/idpf/idpf_txrx.c +1 -3
index c75fc1fc4f64..2a3dd04ebe23 100644
@@ -4511,8 +4511,6 @@ static int idpf_vport_intr_init_vec_idx(struct idpf_vport *vport,
 	for (i = 0; i < rsrc->num_q_vectors; i++) {
 		struct idpf_q_vector *q_vector = &rsrc->q_vectors[i];
 
-		q_vector->v_idx =
-			adapter->irq_info.vectors[rsrc->q_vector_idxs[i]].idx;
 		q_vector->irq.index = rsrc->q_vector_idxs[i];
 		q_vector->irq.virq = pci_irq_vector(adapter->pdev,
 						    q_vector->irq.index);
@@ -4520,7 +4518,7 @@ static int idpf_vport_intr_init_vec_idx(struct idpf_vport *vport,
 			return q_vector->irq.virq;
 	}
 
-	rsrc->noirq_v_idx = adapter->irq_info.vectors[rsrc->q_vector_idxs[i]].idx;
+	rsrc->noirq_v_idx = rsrc->q_vector_idxs[i];
 
 	return 0;
 }
drivers/net/ethernet/intel/idpf/idpf_txrx.h +1 -4
index 57e61936ffda..9a2e3665277f 100644
@@ -377,7 +377,6 @@ struct idpf_intr_reg {
  * @rx_itr_value: RX interrupt throttling rate
  * @rx_intr_mode: Dynamic ITR or not
  * @rx_itr_idx: RX ITR index
- * @v_idx: Vector index
  * @irq: kernel and driver irq numbers
  */
 struct idpf_q_vector {
@@ -418,15 +417,13 @@ struct idpf_q_vector {
 	__cacheline_group_end_aligned(read_write);
 
 	__cacheline_group_begin_aligned(cold);
-	u16 v_idx;
-
 	struct msi_map irq;
 	__cacheline_group_end_aligned(cold);
 };
 libeth_cacheline_set_assert(struct idpf_q_vector, 136,
 			    56 + sizeof(struct napi_struct) +
 			    2 * sizeof(struct dim),
-			    8 + sizeof(struct msi_map));
+			    sizeof(struct msi_map));
 
 struct idpf_rx_queue_stats {
 	u64_stats_t packets;
drivers/net/ethernet/intel/idpf/idpf_virtchnl.c +7 -4
index 267ac9fa3846..90f3c40c7928 100644
@@ -1848,12 +1848,14 @@ idpf_prep_map_unmap_queue_set_vector_msg(u32 vport_id, void *buf,
  * idpf_send_map_unmap_queue_set_vector_msg - send virtchnl map or unmap
  *					      queue set vector message
  * @qs: set of the queues to map or unmap
+ * @info: interrupts info to map software index to firmware one
  * @map: true for map and false for unmap
  *
  * Return: 0 on success, -errno on failure.
  */
 static int
 idpf_send_map_unmap_queue_set_vector_msg(const struct idpf_queue_set *qs,
+					 const struct idpf_irq_info *info,
 					 bool map)
 {
 	struct virtchnl2_queue_vector *vqv __free(kfree) = NULL;
@@ -1893,7 +1895,7 @@ idpf_send_map_unmap_queue_set_vector_msg(const struct idpf_queue_set *qs,
 				vec = q->rxq->q_vector;
 
 			if (vec) {
-				v_idx = vec->v_idx;
+				v_idx = vec->irq.index;
 				itr_idx = vec->rx_itr_idx;
 			} else {
 				v_idx = qs->qv_rsrc->noirq_v_idx;
@@ -1913,7 +1915,7 @@ idpf_send_map_unmap_queue_set_vector_msg(const struct idpf_queue_set *qs,
 				vec = q->txq->q_vector;
 
 			if (vec) {
-				v_idx = vec->v_idx;
+				v_idx = vec->irq.index;
 				itr_idx = vec->tx_itr_idx;
 			} else {
 				v_idx = qs->qv_rsrc->noirq_v_idx;
@@ -1925,7 +1927,7 @@ idpf_send_map_unmap_queue_set_vector_msg(const struct idpf_queue_set *qs,
 		}
 
 		vqv[i].queue_id = cpu_to_le32(qid);
-		vqv[i].vector_id = cpu_to_le16(v_idx);
+		vqv[i].vector_id = cpu_to_le16(info->vectors[v_idx].idx);
 		vqv[i].itr_idx = cpu_to_le32(itr_idx);
 	}
 
@@ -1989,7 +1991,8 @@ int idpf_send_map_unmap_queue_vector_msg(struct idpf_adapter *adapter,
 	if (k != num_q)
 		return -EINVAL;
 
-	return idpf_send_map_unmap_queue_set_vector_msg(qs, map);
+	return idpf_send_map_unmap_queue_set_vector_msg(qs, &adapter->irq_info,
+							map);
 }
 
 /**
Signature · 1 line
2.49.0
Tested-by on v2 4/10
#8 lore raw

RE: [PATCH iwl-next v2 04/10] idpf: drop v_idx from q_vector structure

Quoted 14 lines

-----Original Message-----
From: Michal Swiatkowski <[email protected]>
Sent: Friday, September 11, 2026 5:49 AM
To: [email protected]
Cc: [email protected]; Michal Swiatkowski <[email protected]>; Zaremba, Larysa <[email protected]>; Loktionov, Aleksandr <[email protected]>
Subject: [PATCH iwl-next v2 04/10] idpf: drop v_idx from q_vector structure

Storing another index related to irq in q_vector can be misleading. It is only used when matching q_vectors with queues. It can be obtained using 0-based software irq index.

Quoted 7 lines

Use irq.index (from q_vector) and get the hardware irq index (q_vector->v_idx earlier) from irq_info structure.

---

#9 lore raw

PATCH v2 5/10 libie, idpf: move irq code to libie

In reply to Michal Swiatkowski

Management of irqs is the same in idpf and ixd driver. Move the common code to separate lib to reuse it in ixd.

libie_irq keeps the allocated interrupts in an xarray split into two index ranges: LIBIE_IRQ_STATIC for the vectors that must exist for the device to be functional at all (mailbox, the minimum per default vport, RDMA), and LIBIE_IRQ_DYNAMIC for the rest.

libie_irq_init() allocates the static range with pci_alloc_irq_vectors() at probe. When the platform supports post-enable MSI-X allocation, libie_irq_alloc() backs the dynamic range with pci_msix_alloc_irq_at() on demand, so vectors are only claimed once a vport actually needs them; when it does not, the whole range is allocated up front and LIBIE_IRQ_DYNAMIC is transparently served from the static pool.

libie_irq_reserve() hands out an index without an MSI-X vector behind it, for queues that are mapped to a vector but never raise an interrupt (the idpf NOIRQ vector used by XDP send queues).

Move getting irq slot before allocating q_vectors array. Alloc only q_vectors for which there is an available interrupt.

Allocating more lead to the situation where there are unused q_vector which can be confused.

---
 drivers/net/ethernet/intel/idpf/Kconfig       |   1 +
 drivers/net/ethernet/intel/idpf/idpf.h        |  74 +---
 drivers/net/ethernet/intel/idpf/idpf_idc.c    |   6 +-
 drivers/net/ethernet/intel/idpf/idpf_lib.c    | 382 ++++++------------
 drivers/net/ethernet/intel/idpf/idpf_main.c   |   3 +-
 drivers/net/ethernet/intel/idpf/idpf_txrx.c   | 104 +++--
 drivers/net/ethernet/intel/idpf/idpf_txrx.h   |   2 +-
 .../net/ethernet/intel/idpf/idpf_virtchnl.c   |  45 +--
 .../net/ethernet/intel/idpf/idpf_virtchnl.h   |   3 +-
 drivers/net/ethernet/intel/libie/Kconfig      |   6 +
 drivers/net/ethernet/intel/libie/Makefile     |   4 +
 drivers/net/ethernet/intel/libie/irq.c        | 256 ++++++++++++
 include/linux/net/intel/libie/irq.h           |  75 ++++
 13 files changed, 560 insertions(+), 401 deletions(-)
 create mode 100644 drivers/net/ethernet/intel/libie/irq.c
 create mode 100644 include/linux/net/intel/libie/irq.h
drivers/net/ethernet/intel/idpf/Kconfig +1 -0
index 586df3a4afe9..6e21e4749904 100644
@@ -8,6 +8,7 @@ config IDPF
 	select DIMLIB
 	select LIBIE_CP
 	select LIBETH_XDP
+	select LIBIE_IRQ
 	help
 	  This driver supports Intel(R) Infrastructure Data Path Function
 	  devices.
drivers/net/ethernet/intel/idpf/idpf.h +17 -57

140 lines not on this page · raw message

drivers/net/ethernet/intel/idpf/idpf_idc.c +3 -3
index b6cd1c25ae5d..5d15bef6eec3 100644
@@ -396,14 +396,14 @@ idpf_idc_init_msix_data(struct idpf_adapter *adapter)
 	struct iidc_rdma_core_dev_info *cdev_info;
 	struct iidc_rdma_priv_dev_info *privd;
 
-	if (!adapter->rdma_msix_entries)
+	if (!adapter->rdma_irq.entries)
 		return;
 
 	cdev_info = adapter->cdev_info;
 	privd = cdev_info->iidc_priv;
 
-	privd->msix_entries = adapter->rdma_msix_entries;
-	privd->msix_count = adapter->num_rdma_msix_entries;
+	privd->msix_entries = adapter->rdma_irq.entries;
+	privd->msix_count = adapter->rdma_irq.num;
 }
 
 /**
drivers/net/ethernet/intel/idpf/idpf_lib.c +115 -267

527 lines not on this page · raw message

drivers/net/ethernet/intel/idpf/idpf_main.c +1 -2
index 1e4dd9b713a0..e27ad0e6e4e6 100644
@@ -18,6 +18,7 @@ MODULE_IMPORT_NS("LIBETH");
 MODULE_IMPORT_NS("LIBIE_CP");
 MODULE_IMPORT_NS("LIBIE_PCI");
 MODULE_IMPORT_NS("LIBETH_XDP");
+MODULE_IMPORT_NS("LIBIE_IRQ");
 MODULE_LICENSE("GPL");
 
 /**
@@ -177,7 +178,6 @@ static void idpf_remove(struct pci_dev *pdev)
 	adapter->netdevs = NULL;
 
 	mutex_destroy(&adapter->vport_ctrl_lock);
-	mutex_destroy(&adapter->vector_lock);
 	mutex_destroy(&adapter->queue_lock);
 	mutex_destroy(&adapter->vc_buf_lock);
 
@@ -338,7 +338,6 @@ static int idpf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	adapter->msg_enable = netif_msg_init(-1, IDPF_AVAIL_NETIF_M);
 
 	mutex_init(&adapter->vport_ctrl_lock);
-	mutex_init(&adapter->vector_lock);
 	mutex_init(&adapter->queue_lock);
 	mutex_init(&adapter->vc_buf_lock);
 
drivers/net/ethernet/intel/idpf/idpf_txrx.c +73 -31

196 lines not on this page · raw message

drivers/net/ethernet/intel/idpf/idpf_txrx.h +1 -1
index 9a2e3665277f..f40a0a67d7ea 100644
@@ -1079,7 +1079,7 @@ int idpf_vport_queues_alloc(struct idpf_vport *vport,
 			    struct idpf_q_vec_rsrc *rsrc);
 void idpf_vport_queues_rel(struct idpf_vport *vport,
 			   struct idpf_q_vec_rsrc *rsrc);
-void idpf_vport_intr_rel(struct idpf_q_vec_rsrc *rsrc);
+void idpf_vport_intr_rel(struct idpf_q_vec_rsrc *rsrc, struct libie_irq *irq);
 int idpf_vport_intr_alloc(struct idpf_vport *vport,
 			  struct idpf_q_vec_rsrc *rsrc);
 void idpf_vport_intr_update_itr_ena_irq(struct idpf_q_vector *q_vector);
drivers/net/ethernet/intel/idpf/idpf_virtchnl.c +7 -38

68 lines not on this page · raw message

drivers/net/ethernet/intel/idpf/idpf_virtchnl.h +1 -2
index ec4c79191c85..8fad35a8c64c 100644
@@ -124,8 +124,7 @@ int idpf_send_delete_queues_msg(struct idpf_adapter *adapter,
 				struct idpf_queue_id_reg_info *chunks,
 				u32 vport_id);
 
-int idpf_vport_alloc_vec_indexes(struct idpf_vport *vport,
-				 struct idpf_q_vec_rsrc *rsrc);
+void idpf_vport_set_num_q_vectors(struct idpf_q_vec_rsrc *rsrc, u16 xdpqs);
 int idpf_send_alloc_vectors_msg(struct idpf_adapter *adapter, u16 num_vectors);
 int idpf_send_dealloc_vectors_msg(struct idpf_adapter *adapter);
 int idpf_send_map_unmap_queue_vector_msg(struct idpf_adapter *adapter,
drivers/net/ethernet/intel/libie/Kconfig +6 -0
index 9c5fdebb6766..47fb77191604 100644
@@ -37,3 +37,9 @@ config LIBIE_PCI
 	help
 	  Helper functions for management of PCI resources belonging
 	  to networking devices.
+
+config LIBIE_IRQ
+	tristate
+	help
+	  Helpers used to manage irqs by drivers, take care of managing static
+	  and dynamic interrupts, using xarray to store irqs and track usage.
drivers/net/ethernet/intel/libie/Makefile +4 -0
index 3065aa057798..380af47398d8 100644
@@ -20,3 +20,7 @@ libie_fwlog-y			:= fwlog.o
 obj-$(CONFIG_LIBIE_PCI)		+= libie_pci.o
 
 libie_pci-y			:= pci.o
+
+obj-$(CONFIG_LIBIE_IRQ)		+= libie_irq.o
+
+libie_irq-y			:= irq.o
drivers/net/ethernet/intel/libie/irq.c new file +256 -0

256 lines not on this page · raw message

include/linux/net/intel/libie/irq.h new file +75 -0

75 lines not on this page · raw message

Signature · 1 line
2.49.0
Tested-by on v2 5/10
#10 lore raw

RE: [PATCH iwl-next v2 05/10] libie, idpf: move irq code to libie

Quoted 32 lines

-----Original Message-----
From: Michal Swiatkowski <[email protected]>
Sent: Friday, September 11, 2026 5:49 AM
To: [email protected]
Cc: [email protected]; Michal Swiatkowski <[email protected]>; Loktionov, Aleksandr <[email protected]>; Zaremba, Larysa <[email protected]>
Subject: [PATCH iwl-next v2 05/10] libie, idpf: move irq code to libie

Management of irqs is the same in idpf and ixd driver. Move the common code to separate lib to reuse it in ixd.

libie_irq keeps the allocated interrupts in an xarray split into two index ranges: LIBIE_IRQ_STATIC for the vectors that must exist for the device to be functional at all (mailbox, the minimum per default vport, RDMA), and LIBIE_IRQ_DYNAMIC for the rest.

libie_irq_init() allocates the static range with pci_alloc_irq_vectors() at probe. When the platform supports post-enable MSI-X allocation, libie_irq_alloc() backs the dynamic range with pci_msix_alloc_irq_at() on demand, so vectors are only claimed once a vport actually needs them; when it does not, the whole range is allocated up front and LIBIE_IRQ_DYNAMIC is transparently served from the static pool.

libie_irq_reserve() hands out an index without an MSI-X vector behind it, for queues that are mapped to a vector but never raise an interrupt (the idpf NOIRQ vector used by XDP send queues).

Move getting irq slot before allocating q_vectors array. Alloc only q_vectors for which there is an available interrupt.

Quoted 7 lines

Allocating more lead to the situation where there are unused q_vector which can be confused.

---

#11 lore raw

PATCH v2 6/10 libie, idpf: move hardware irq info struct to libie

In reply to Michal Swiatkowski

Manually move definition related to irq info from idpf to libie_irq. s/idpf_/libie_

It will be used by idpf and ixd driver.

---
 drivers/net/ethernet/intel/idpf/idpf.h        | 36 +------------------
 drivers/net/ethernet/intel/idpf/idpf_dev.c    |  2 +-
 drivers/net/ethernet/intel/idpf/idpf_vf_dev.c |  2 +-
 .../net/ethernet/intel/idpf/idpf_virtchnl.c   |  8 ++---
 include/linux/net/intel/libie/irq.h           | 34 ++++++++++++++++++
 5 files changed, 41 insertions(+), 41 deletions(-)
drivers/net/ethernet/intel/idpf/idpf.h +1 -35
index 51f447135693..33ee30424b77 100644
@@ -577,40 +577,6 @@ struct idpf_vport_config {
 	     iter = (++__##iter) < &(adapter)->vports[(adapter)->max_vports] ? \
 	     *__##iter : NULL)
 
-/**
- * struct idpf_vec_regs - hardware registers related to vector
- * @dyn_ctl: Dynamic control interrupt register offset
- * @itrn: Interrupt Throttling Rate register offset
- * @itrn_index_spacing: Register spacing between ITR registers of the same
- *			vector
- */
-struct idpf_vec_regs {
-	u32 dyn_ctl;
-	u32 itrn;
-	u32 itrn_index_spacing;
-};
-
-/**
- * struct idpf_hw_vector - single hardware vector info
- * @regs: address of irq registers
- * @idx: hardware vector index
- */
-struct idpf_hw_vector {
-	struct idpf_vec_regs regs;
-	int idx;
-};
-
-/**
- * struct idpf_irq_info - hardware data needed to setup irq
- * @vectors: allocated during initialization store hardware information
- *	     for all vectors that can be used on a whole device
- * @num: amount of vectors stored here
- */
-struct idpf_irq_info {
-	struct idpf_hw_vector *vectors;
-	int num;
-};
-
 /**
  * struct idpf_rdma_irq - RDMA interrupt vectors data
  * @entries: MSIX table shared with the RDMA auxiliary device
@@ -695,7 +661,7 @@ struct idpf_adapter {
 	struct idpf_rdma_irq rdma_irq;
 	struct libie_irq irq;
 	struct virtchnl2_alloc_vectors *req_vec_chunks;
-	struct idpf_irq_info irq_info;
+	struct libie_irq_info irq_info;
 	struct idpf_q_vector mb_vector;
 	irqreturn_t (*irq_mb_handler)(int irq, void *data);
 
drivers/net/ethernet/intel/idpf/idpf_dev.c +1 -1
index cd947fd24ff6..61f5e8e4d20b 100644
@@ -87,7 +87,7 @@ static void idpf_noirq_intr_reg_init(struct idpf_adapter *adapter,
 static void idpf_intr_reg_init(struct idpf_adapter *adapter,
 			       struct idpf_q_vector *q_vector, u16 idx)
 {
-	struct idpf_hw_vector *v = &adapter->irq_info.vectors[idx];
+	struct libie_hw_vector *v = &adapter->irq_info.vectors[idx];
 	struct idpf_intr_reg *intr = &q_vector->intr_reg;
 	struct libie_mmio_info *mmio;
 	u32 rx_itr, tx_itr;
drivers/net/ethernet/intel/idpf/idpf_vf_dev.c +1 -1
index df3eabe12b18..4c1c2476613b 100644
@@ -86,7 +86,7 @@ static void idpf_vf_noirq_intr_reg_init(struct idpf_adapter *adapter,
 static void idpf_vf_intr_reg_init(struct idpf_adapter *adapter,
 				  struct idpf_q_vector *q_vector, u16 idx)
 {
-	struct idpf_hw_vector *v = &adapter->irq_info.vectors[idx];
+	struct libie_hw_vector *v = &adapter->irq_info.vectors[idx];
 	struct idpf_intr_reg *intr = &q_vector->intr_reg;
 	struct libie_mmio_info *mmio;
 	u32 rx_itr, tx_itr;
drivers/net/ethernet/intel/idpf/idpf_virtchnl.c +4 -4
index 65ddc6f893fc..20e471def235 100644
@@ -1855,7 +1855,7 @@ idpf_prep_map_unmap_queue_set_vector_msg(u32 vport_id, void *buf,
  */
 static int
 idpf_send_map_unmap_queue_set_vector_msg(const struct idpf_queue_set *qs,
-					 const struct idpf_irq_info *info,
+					 const struct libie_irq_info *info,
 					 bool map)
 {
 	struct virtchnl2_queue_vector *vqv __free(kfree) = NULL;
@@ -2238,14 +2238,14 @@ int idpf_send_add_queues_msg(struct idpf_adapter *adapter,
  *
  * Returns 0 on success, negative on failure.
  */
-static int idpf_create_vectors_info(struct idpf_irq_info *info,
+static int idpf_create_vectors_info(struct libie_irq_info *info,
 				    const struct virtchnl2_get_capabilities *caps,
 				    const struct virtchnl2_alloc_vectors *vectors,
 				    const u16 num_vectors)
 {
 	const struct virtchnl2_vector_chunks *chunks = &vectors->vchunks;
 	int all_vectors = num_vectors + IDPF_MBX_Q_VEC;
-	struct idpf_hw_vector *vector;
+	struct libie_hw_vector *vector;
 	int reg_cnt;
 
 	if (le16_to_cpu(vectors->num_vectors) < num_vectors)
@@ -2266,7 +2266,7 @@ static int idpf_create_vectors_info(struct idpf_irq_info *info,
 	for (int i = 0; i < le16_to_cpu(chunks->num_vchunks); i++) {
 		const struct virtchnl2_vector_chunk *chunk = &chunks->vchunks[i];
 		u32 dyn_spacing, itrn_spacing;
-		struct idpf_vec_regs reg_val;
+		struct libie_vec_regs reg_val;
 		u16 vec_id;
 
 		reg_val.dyn_ctl = le32_to_cpu(chunk->dynctl_reg_start);
include/linux/net/intel/libie/irq.h +34 -0
index 8af8fc22ab09..e219fde575d8 100644
@@ -64,6 +64,40 @@ struct libie_irq {
 	struct xarray entries;
 };
 
+/**
+ * struct libie_vec_regs - hardware registers related to vector
+ * @dyn_ctl: Dynamic control interrupt register offset
+ * @itrn: Interrupt Throttling Rate register offset
+ * @itrn_index_spacing: Register spacing between ITR registers of the same
+ *			vector
+ */
+struct libie_vec_regs {
+	u32 dyn_ctl;
+	u32 itrn;
+	u32 itrn_index_spacing;
+};
+
+/**
+ * struct libie_hw_vector - single hardware vector info
+ * @regs: address of irq registers
+ * @idx: hardware vector index
+ */
+struct libie_hw_vector {
+	struct libie_vec_regs regs;
+	int idx;
+};
+
+/**
+ * struct libie_irq_info - hardware data needed to setup irq
+ * @vectors: allocated during initialization store hardware information
+ *	     for all vectors that can be used on a whole device
+ * @num: amount of vectors stored here
+ */
+struct libie_irq_info {
+	struct libie_hw_vector *vectors;
+	int num;
+};
+
 int libie_irq_init(struct libie_irq *irq, struct pci_dev *pdev,
 		   int min, int max);
 void libie_irq_deinit(struct libie_irq *irq);
Signature · 1 line
2.49.0
Tested-by on v2 6/10
#12 lore raw

RE: [PATCH iwl-next v2 06/10] libie, idpf: move hardware irq info struct to libie

Quoted 9 lines

-----Original Message-----
From: Michal Swiatkowski <[email protected]>
Sent: Friday, September 11, 2026 5:49 AM
To: [email protected]
Cc: [email protected]; Michal Swiatkowski <[email protected]>
Subject: [PATCH iwl-next v2 06/10] libie, idpf: move hardware irq info struct to libie

Quoted 7 lines

Manually move definition related to irq info from idpf to libie_irq. s/idpf_/libie_

It will be used by idpf and ixd driver.

---

#13 lore raw

PATCH v2 7/10 libie, idpf: move parsing alloc vectors command to libie

In reply to Michal Swiatkowski

No functional changes. Just moving to make it available from other ipu drivers.

---
 .../net/ethernet/intel/idpf/idpf_virtchnl.c   | 85 +----------------
 drivers/net/ethernet/intel/libie/irq.c        | 92 +++++++++++++++++++
 include/linux/net/intel/libie/irq.h           |  9 ++
 3 files changed, 104 insertions(+), 82 deletions(-)
drivers/net/ethernet/intel/idpf/idpf_virtchnl.c +3 -82
index 20e471def235..3df6ad291e64 100644
@@ -2229,83 +2229,6 @@ int idpf_send_add_queues_msg(struct idpf_adapter *adapter,
 	return err;
 }
 
-/**
- * idpf_create_vectors_info - Save vectors information from firmware
- * @info: parsed information is stored here
- * @caps: virtchannel capabilities
- * @vectors: vector information from firmware to be parsed
- * @num_vectors: number of vectors
- *
- * Returns 0 on success, negative on failure.
- */
-static int idpf_create_vectors_info(struct libie_irq_info *info,
-				    const struct virtchnl2_get_capabilities *caps,
-				    const struct virtchnl2_alloc_vectors *vectors,
-				    const u16 num_vectors)
-{
-	const struct virtchnl2_vector_chunks *chunks = &vectors->vchunks;
-	int all_vectors = num_vectors + IDPF_MBX_Q_VEC;
-	struct libie_hw_vector *vector;
-	int reg_cnt;
-
-	if (le16_to_cpu(vectors->num_vectors) < num_vectors)
-		return -EINVAL;
-
-	info->vectors = kzalloc_objs(*info->vectors, all_vectors);
-	if (!info->vectors)
-		return -ENOMEM;
-	/* Mailbox irq information are stored in different places. Fill index 0
-	 * of our vectors info with capabilities and rest with information
-	 * from vector chunks.
-	 */
-	vector = &info->vectors[0];
-	vector->idx = le16_to_cpu(caps->mailbox_vector_id);
-	vector->regs.dyn_ctl = le32_to_cpu(caps->mailbox_dyn_ctl);
-	reg_cnt = IDPF_MBX_Q_VEC;
-
-	for (int i = 0; i < le16_to_cpu(chunks->num_vchunks); i++) {
-		const struct virtchnl2_vector_chunk *chunk = &chunks->vchunks[i];
-		u32 dyn_spacing, itrn_spacing;
-		struct libie_vec_regs reg_val;
-		u16 vec_id;
-
-		reg_val.dyn_ctl = le32_to_cpu(chunk->dynctl_reg_start);
-		reg_val.itrn = le32_to_cpu(chunk->itrn_reg_start);
-		reg_val.itrn_index_spacing =
-			le32_to_cpu(chunk->itrn_index_spacing);
-
-		dyn_spacing = le32_to_cpu(chunk->dynctl_reg_spacing);
-		itrn_spacing = le32_to_cpu(chunk->itrn_reg_spacing);
-		vec_id = le16_to_cpu(chunk->start_vector_id);
-
-		for (int j = 0; j < le16_to_cpu(chunk->num_vectors); j++) {
-			if (reg_cnt >= all_vectors)
-				break;
-
-			vector = &info->vectors[reg_cnt];
-
-			vector->regs = reg_val;
-			vector->idx = vec_id;
-
-			reg_val.dyn_ctl += dyn_spacing;
-			reg_val.itrn += itrn_spacing;
-
-			vec_id += 1;
-			reg_cnt += 1;
-		}
-	}
-
-	if (reg_cnt != all_vectors) {
-		kfree(info->vectors);
-		info->vectors = NULL;
-		return -EINVAL;
-	}
-
-	info->num = num_vectors + IDPF_MBX_Q_VEC;
-
-	return 0;
-}
-
 /**
  * idpf_send_alloc_vectors_msg - Send virtchnl alloc vectors message
  * @adapter: Driver specific private structure
@@ -2350,8 +2273,8 @@ int idpf_send_alloc_vectors_msg(struct idpf_adapter *adapter, u16 num_vectors)
 		goto free_rx_buf;
 	}
 
-	err = idpf_create_vectors_info(&adapter->irq_info, &adapter->caps,
-				       rcvd_vec, num_vectors);
+	err = libie_irq_create_info(&adapter->irq_info, &adapter->caps,
+				    rcvd_vec, num_vectors);
 	if (err)
 		idpf_send_dealloc_vectors_msg(adapter);
 
@@ -2378,9 +2301,7 @@ int idpf_send_dealloc_vectors_msg(struct idpf_adapter *adapter)
 	int buf_size, err;
 
 	/* dealloc vectors can fail, but irq_info still needs to be cleaned */
-	kfree(adapter->irq_info.vectors);
-	adapter->irq_info.vectors = NULL;
-	adapter->irq_info.num = 0;
+	libie_irq_destroy_info(&adapter->irq_info);
 
 	buf_size = struct_size(&ac->vchunks, vchunks,
 			       le16_to_cpu(ac->vchunks.num_vchunks));
drivers/net/ethernet/intel/libie/irq.c +92 -0

104 lines not on this page · raw message

include/linux/net/intel/libie/irq.h +9 -0
index e219fde575d8..8d5873f13871 100644
@@ -105,5 +105,14 @@ struct msi_map libie_irq_alloc(struct libie_irq *irq, enum libie_irq_type type);
 void libie_irq_free(struct libie_irq *irq, struct msi_map map);
 int libie_irq_reserve(struct libie_irq *irq);
 void libie_put_irq(struct libie_irq *irq, unsigned int index);
+/* IPU specific functions. */
+struct virtchnl2_get_capabilities;
+struct virtchnl2_alloc_vectors;
+
+void libie_irq_destroy_info(struct libie_irq_info *info);
+int libie_irq_create_info(struct libie_irq_info *info,
+			  const struct virtchnl2_get_capabilities *caps,
+			  const struct virtchnl2_alloc_vectors *vectors,
+			  const u16 num_vectors);
 
 #endif /* __LIBIE_IRQ_H */
Signature · 1 line
2.49.0
Tested-by on v2 7/10
#14 lore raw

RE: [PATCH iwl-next v2 07/10] libie, idpf: move parsing alloc vectors command to libie

Quoted 10 lines

-----Original Message-----
From: Michal Swiatkowski <[email protected]>
Sent: Friday, September 11, 2026 5:49 AM
To: [email protected]
Cc: [email protected]; Michal Swiatkowski <[email protected]>; Loktionov, Aleksandr <[email protected]>
Subject: [PATCH iwl-next v2 07/10] libie, idpf: move parsing alloc vectors command to libie

Quoted 5 lines

No functional changes. Just moving to make it available from other ipu drivers.

---

#15 lore raw

PATCH v2 8/10 ice: use libie_irq for interrupts managing

In reply to Michal Swiatkowski

Change interrupts code to fit the libie_irq calls.

There is not many difference. Bool for dynamic alloc in libie is changed to enum for static and dynamic. Rest code is the same. Instead of custom ice_irq_tracker there is libie_irq that tracks the interrupts.

Code fallback to static when there is not more dynamic. Previously it first used static part. Getting dynamic first better fit the lib code. It isn't breaking current driver code.

Dynamic alloc is always set to true if there is support. In libie_irq code check for dynamic support is done inside. LIBIE_IRQ_ANY can be always pass in case of getting interrupts for VSI. If there is no platform support it is changed to LIBIE_IRQ_STATIC inside libie code.

---
 drivers/net/ethernet/intel/Kconfig        |   1 +
 drivers/net/ethernet/intel/ice/ice.h      |   5 +-
 drivers/net/ethernet/intel/ice/ice_base.c |   4 +-
 drivers/net/ethernet/intel/ice/ice_idc.c  |   4 +-
 drivers/net/ethernet/intel/ice/ice_irq.c  | 181 ++--------------------
 drivers/net/ethernet/intel/ice/ice_irq.h  |  14 --
 drivers/net/ethernet/intel/ice/ice_lib.c  |   3 -
 drivers/net/ethernet/intel/ice/ice_main.c |  15 +-
 drivers/net/ethernet/intel/libie/irq.c    |  30 +++-
 include/linux/net/intel/libie/irq.h       |   2 +
 10 files changed, 51 insertions(+), 208 deletions(-)
drivers/net/ethernet/intel/Kconfig +1 -0
index 1228ae099b15..bd0dd8c28352 100644
@@ -301,6 +301,7 @@ config ICE
 	select LIBIE
 	select LIBIE_ADMINQ
 	select LIBIE_FWLOG if DEBUG_FS
+	select LIBIE_IRQ
 	select NET_DEVLINK
 	select PACKING
 	select PLDMFW
drivers/net/ethernet/intel/ice/ice.h +2 -3
index 6a158ee882a7..18ee6f0c1abc 100644
@@ -36,6 +36,7 @@
 #include <linux/bpf.h>
 #include <linux/btf.h>
 #include <linux/auxiliary_bus.h>
+#include <linux/net/intel/libie/irq.h>
 #include <linux/net/intel/virtchnl.h>
 #include <linux/cpu_rmap.h>
 #include <linux/dim.h>
@@ -351,8 +352,6 @@ struct ice_vsi {
 	u32 rx_buf_failed;
 	u32 rx_page_failed;
 	u16 num_q_vectors;
-	/* tell if only dynamic irq allocation is allowed */
-	bool irq_dyn_alloc;
 	bool hsplit:1;
 
 	u16 vsi_num;			/* HW (absolute) index of this VSI */
@@ -565,7 +564,7 @@ struct ice_pf {
 	struct devlink_port devlink_port;
 
 	/* OS reserved IRQ details */
-	struct ice_irq_tracker irq_tracker;
+	struct libie_irq irq;
 	struct ice_virt_irq_tracker virt_irq_tracker;
 
 	u16 ctrl_vsi_idx;		/* control VSI index in pf->vsi array */
drivers/net/ethernet/intel/ice/ice_base.c +2 -2
index 1667f686ff75..b592d3c389c0 100644
@@ -140,7 +140,7 @@ static int ice_vsi_alloc_q_vector(struct ice_vsi *vsi, u16 v_idx)
 		}
 	}
 
-	q_vector->irq = ice_alloc_irq(pf, vsi->irq_dyn_alloc);
+	q_vector->irq = libie_irq_alloc(&pf->irq, LIBIE_IRQ_ANY);
 	if (q_vector->irq.index < 0) {
 		err = -ENOMEM;
 		goto err_free_q_vector;
@@ -209,7 +209,7 @@ static void ice_free_q_vector(struct ice_vsi *vsi, int v_idx)
 	    ice_get_vf_ctrl_vsi(pf, vsi))
 		goto free_q_vector;
 
-	ice_free_irq(pf, q_vector->irq);
+	libie_irq_free(&pf->irq, q_vector->irq);
 
 free_q_vector:
 	kfree(q_vector);
drivers/net/ethernet/intel/ice/ice_idc.c +2 -2
index 102d63c3018b..337ba65b6318 100644
@@ -239,7 +239,7 @@ int ice_alloc_rdma_qvector(struct iidc_rdma_core_dev_info *cdev,
 		return -EINVAL;
 
 	pf = pci_get_drvdata(cdev->pdev);
-	map = ice_alloc_irq(pf, true);
+	map = libie_irq_alloc(&pf->irq, LIBIE_IRQ_ANY);
 	if (map.index < 0)
 		return -ENOMEM;
 
@@ -268,7 +268,7 @@ void ice_free_rdma_qvector(struct iidc_rdma_core_dev_info *cdev,
 
 	map.index = entry->entry;
 	map.virq = entry->vector;
-	ice_free_irq(pf, map);
+	libie_irq_free(&pf->irq, map);
 }
 EXPORT_SYMBOL_GPL(ice_free_rdma_qvector);
 
drivers/net/ethernet/intel/ice/ice_irq.c +9 -172

218 lines not on this page · raw message

drivers/net/ethernet/intel/ice/ice_irq.h +0 -14
index b2f9dbafd57e..a4ecf50e9ccf 100644
@@ -4,17 +4,6 @@
 #ifndef _ICE_IRQ_H_
 #define _ICE_IRQ_H_
 
-struct ice_irq_entry {
-	unsigned int index;
-	bool dynamic;	/* allocation type flag */
-};
-
-struct ice_irq_tracker {
-	struct xarray entries;
-	u16 num_entries;	/* total vectors available */
-	u16 num_static;	/* preallocated entries */
-};
-
 struct ice_virt_irq_tracker {
 	unsigned long *bm;	/* bitmap to track irq usage */
 	u32 num_entries;
@@ -28,9 +17,6 @@ struct ice_virt_irq_tracker {
 int ice_init_interrupt_scheme(struct ice_pf *pf);
 void ice_clear_interrupt_scheme(struct ice_pf *pf);
 
-struct msi_map ice_alloc_irq(struct ice_pf *pf, bool dyn_only);
-void ice_free_irq(struct ice_pf *pf, struct msi_map map);
-
 int ice_virt_get_irqs(struct ice_pf *pf, u32 needed);
 void ice_virt_free_irqs(struct ice_pf *pf, u32 index, u32 irqs);
 #endif
drivers/net/ethernet/intel/ice/ice_lib.c +0 -3
index 93e405dd6f5a..6eb758404f54 100644
@@ -211,7 +211,6 @@ static void ice_vsi_set_num_qs(struct ice_vsi *vsi)
 		vsi->alloc_txq = 1;
 		vsi->alloc_rxq = 1;
 		vsi->num_q_vectors = 1;
-		vsi->irq_dyn_alloc = true;
 		break;
 	case ICE_VSI_VF:
 		if (vf->num_req_qs)
@@ -572,8 +571,6 @@ ice_vsi_alloc_def(struct ice_vsi *vsi, struct ice_channel *ch)
 			return -ENOMEM;
 	}
 
-	vsi->irq_dyn_alloc = pci_msix_can_alloc_dyn(vsi->back->pdev);
-
 	switch (vsi->type) {
 	case ICE_VSI_PF:
 	case ICE_VSI_SF:
drivers/net/ethernet/intel/ice/ice_main.c +8 -7
index 4d63ebba36d6..12f8f2ebf119 100644
@@ -44,6 +44,7 @@ MODULE_IMPORT_NS("LIBETH_XDP");
 MODULE_IMPORT_NS("LIBIE");
 MODULE_IMPORT_NS("LIBIE_ADMINQ");
 MODULE_IMPORT_NS("LIBIE_FWLOG");
+MODULE_IMPORT_NS("LIBIE_IRQ");
 MODULE_LICENSE("GPL v2");
 MODULE_FIRMWARE(ICE_DDP_PKG_FILE);
 
@@ -3357,7 +3358,7 @@ static void ice_free_irq_msix_ll_ts(struct ice_pf *pf)
 	synchronize_irq(irq_num);
 	devm_free_irq(ice_pf_to_dev(pf), irq_num, pf);
 
-	ice_free_irq(pf, pf->ll_ts_irq);
+	libie_irq_free(&pf->irq, pf->ll_ts_irq);
 }
 
 /**
@@ -3378,7 +3379,7 @@ static void ice_free_irq_msix_misc(struct ice_pf *pf)
 	synchronize_irq(misc_irq_num);
 	devm_free_irq(ice_pf_to_dev(pf), misc_irq_num, pf);
 
-	ice_free_irq(pf, pf->oicr_irq);
+	libie_irq_free(&pf->irq, pf->oicr_irq);
 	if (pf->ll_ts_irq.index >= 0)
 		ice_free_irq_msix_ll_ts(pf);
 }
@@ -3447,7 +3448,7 @@ static int ice_req_irq_msix_misc(struct ice_pf *pf)
 		goto skip_req_irq;
 
 	/* reserve one vector in irq_tracker for misc interrupts */
-	irq = ice_alloc_irq(pf, false);
+	irq = libie_irq_alloc(&pf->irq, LIBIE_IRQ_STATIC);
 	if (irq.index < 0)
 		return irq.index;
 
@@ -3458,7 +3459,7 @@ static int ice_req_irq_msix_misc(struct ice_pf *pf)
 	if (err) {
 		dev_err(dev, "devm_request_threaded_irq for %s failed: %d\n",
 			pf->int_name, err);
-		ice_free_irq(pf, pf->oicr_irq);
+		libie_irq_free(&pf->irq, pf->oicr_irq);
 		return err;
 	}
 
@@ -3468,7 +3469,7 @@ static int ice_req_irq_msix_misc(struct ice_pf *pf)
 		goto skip_req_irq;
 	}
 
-	irq = ice_alloc_irq(pf, false);
+	irq = libie_irq_alloc(&pf->irq, LIBIE_IRQ_STATIC);
 	if (irq.index < 0)
 		return irq.index;
 
@@ -3478,7 +3479,7 @@ static int ice_req_irq_msix_misc(struct ice_pf *pf)
 	if (err) {
 		dev_err(dev, "devm_request_irq for %s failed: %d\n",
 			pf->int_name_ll_ts, err);
-		ice_free_irq(pf, pf->ll_ts_irq);
+		libie_irq_free(&pf->irq, pf->ll_ts_irq);
 		pf->ll_ts_irq.index = -ENOENT;
 		return err;
 	}
@@ -3963,7 +3964,7 @@ void ice_deinit_pf(struct ice_pf *pf)
 	if (pf->ptp.clock)
 		ptp_clock_unregister(pf->ptp.clock);
 
-	if (!xa_empty(&pf->irq_tracker.entries))
+	if (!xa_empty(&pf->irq.entries))
 		ice_free_irq_msix_misc(pf);
 
 	xa_destroy(&pf->dyn_ports);
drivers/net/ethernet/intel/libie/irq.c +25 -5
index d26ffeffdcb2..4da763943b14 100644
@@ -98,6 +98,7 @@ static struct libie_irq_entry *libie_get_irq(struct libie_irq *irq,
 					     enum libie_irq_type type)
 {
 	struct libie_irq_entry *entry;
+	struct xa_limit limit;
 	unsigned int index;
 
 	if (!irq->pdev)
@@ -113,9 +114,26 @@ static struct libie_irq_entry *libie_get_irq(struct libie_irq *irq,
 	if (!entry)
 		return NULL;
 
-	if (xa_alloc(&irq->entries, &index, entry, irq->limits[type],
-		     GFP_KERNEL))
-		goto free_entry;
+	/* If any, first try dynamic */
+	if (type == LIBIE_IRQ_ANY)
+		limit = irq->limits[LIBIE_IRQ_DYNAMIC];
+	else
+		limit = irq->limits[type];
+
+	if (xa_alloc(&irq->entries, &index, entry, limit, GFP_KERNEL)) {
+		if (type != LIBIE_IRQ_ANY)
+			goto free_entry;
+		/* Dynamic for any type failed, try static */
+		if (xa_alloc(&irq->entries, &index, entry,
+			     irq->limits[LIBIE_IRQ_STATIC], GFP_KERNEL))
+			goto free_entry;
+
+		type = LIBIE_IRQ_STATIC;
+	}
+
+	/* If still any it is dynamic */
+	if (type == LIBIE_IRQ_ANY)
+		type = LIBIE_IRQ_DYNAMIC;
 
 	entry->index = index;
 	entry->type = type;
@@ -149,6 +167,7 @@ EXPORT_SYMBOL_NS_GPL(libie_put_irq, "LIBIE_IRQ");
  *
  * For LIBIE_IRQ_DYNAMIC function allocs new interrupt and return it.
  * For LIBIE_IRQ_STATIC function returns already allocated one.
+ * For LIBIE_IRQ_ANY first try DYNAMIC, if it failed try STATIC
  *
  * The function should be called for getting irq information (index and virq)
  * for specific irq type. Returned information should be stored to use index for
@@ -202,8 +221,9 @@ EXPORT_SYMBOL_NS_GPL(libie_irq_alloc, "LIBIE_IRQ");
  * @irq: libie_irq structure
  * @map: msi_map structure returned from libie_alloc_irq()
  *
- * In case of dynamic allocation and LIBIE_IRQ_DYNAMIC type pci_msix_free_irq()
- * is called. Otherwise only free driver irq entry related resources.
+ * In case of dynamic allocation and LIBIE_IRQ_DYNAMIC (or LIBIE_IRQ_ANY)
+ * type pci_msix_free_irq() is called. Otherwise only free driver irq entry
+ * related resources.
  *
  * It is safe to call this function with map that doesn't exist in xarray
  * as long as the map.virq is 0 or negative. It is true when libie_irq_alloc()
include/linux/net/intel/libie/irq.h +2 -0
index 8d5873f13871..ff3f30b90ebd 100644
@@ -17,6 +17,7 @@
  * enum libie_irq_type - enum representing types of irq entries
  * @LIBIE_IRQ_STATIC: irq static allocated from kernel at driver probe
  * @LIBIE_IRQ_DYNAMIC: irq dynamic allocated during normal driver operation
+ * @LIBIE_IRQ_ANY: use when STATIC or DYNAMIC can be allocated
  * @LIBIE_IRQ_NUM_TYPES: must be the last one, used to define the array size
  *
  * Enum is used to get software irq indexes from some kind of pool. The pool is
@@ -31,6 +32,7 @@
 enum libie_irq_type {
 	LIBIE_IRQ_STATIC,
 	LIBIE_IRQ_DYNAMIC,
+	LIBIE_IRQ_ANY,
 	LIBIE_IRQ_NUM_TYPES,
 };
 
Signature · 1 line
2.49.0
Tested-by on v2 8/10
#16 lore raw

RE: [PATCH iwl-next v2 08/10] ice: use libie_irq for interrupts managing

Quoted 17 lines

-----Original Message-----
From: Michal Swiatkowski <[email protected]>
Sent: Friday, September 11, 2026 5:49 AM
To: [email protected]
Cc: [email protected]; Michal Swiatkowski <[email protected]>; Loktionov, Aleksandr <[email protected]>
Subject: [PATCH iwl-next v2 08/10] ice: use libie_irq for interrupts managing

Change interrupts code to fit the libie_irq calls.

There is not many difference. Bool for dynamic alloc in libie is changed to enum for static and dynamic. Rest code is the same. Instead of custom ice_irq_tracker there is libie_irq that tracks the interrupts.

Code fallback to static when there is not more dynamic. Previously it first used static part. Getting dynamic first better fit the lib code. It isn't breaking current driver code.

Dynamic alloc is always set to true if there is support. In libie_irq code check for dynamic support is done inside. LIBIE_IRQ_ANY can be always pass in case of getting interrupts for VSI. If there is no platform support it is changed to LIBIE_IRQ_STATIC inside libie code.

Quoted 11 lines
---
 drivers/net/ethernet/intel/Kconfig        |   1 +
 drivers/net/ethernet/intel/ice/ice.h      |   5 +-
 drivers/net/ethernet/intel/ice/ice_base.c |   4 +-
 drivers/net/ethernet/intel/ice/ice_idc.c  |   4 +-
 drivers/net/ethernet/intel/ice/ice_irq.c  | 181 ++--------------------  drivers/net/ethernet/intel/ice/ice_irq.h  |  14 --
 drivers/net/ethernet/intel/ice/ice_lib.c  |   3 -
 drivers/net/ethernet/intel/ice/ice_main.c |  15 +-
 drivers/net/ethernet/intel/libie/irq.c    |  30 +++-
 include/linux/net/intel/libie/irq.h       |   2 +
 10 files changed, 51 insertions(+), 208 deletions(-)
#17 lore raw

PATCH v2 9/10 ixd: support for getting lan memory regions

In reply to Michal Swiatkowski

Send and parse get lan memory regions command. Map the regions from the command response.

It is needed to set number of regions to not zero value even when just sending the command. Set it to 1 and add comment about that.

It is possible that get lan memory regions isn't supported. Driver should cover this situation by mapping regions needed for running.

---
 drivers/net/ethernet/intel/ixd/ixd.h          |   3 +
 drivers/net/ethernet/intel/ixd/ixd_main.c     | 131 +++++++++++++++---
 drivers/net/ethernet/intel/ixd/ixd_virtchnl.c |  90 +++++++++++-
 3 files changed, 201 insertions(+), 23 deletions(-)
drivers/net/ethernet/intel/ixd/ixd.h +3 -0
index 2a09ccba13d5..4a1590f937b5 100644
@@ -63,5 +63,8 @@ bool ixd_check_reset_complete(struct ixd_adapter *adapter);
 void ixd_init_task(struct work_struct *work);
 int ixd_init_dflt_mbx(struct ixd_adapter *adapter);
 void ixd_deinit_dflt_mbx(struct ixd_adapter *adapter);
+int ixd_iomap_running_regions(struct ixd_adapter *adapter);
+bool ixd_iomap_is_not_start_region(struct libie_mmio_info *info,
+				   struct libie_pci_mmio_region *reg);
 
 #endif /* _IXD_H_ */
drivers/net/ethernet/intel/ixd/ixd_main.c +109 -22

153 lines not on this page · raw message

drivers/net/ethernet/intel/ixd/ixd_virtchnl.c +89 -1

125 lines not on this page · raw message

Signature · 1 line
2.49.0
Tested-by on v2 9/10
#18 lore raw

RE: [PATCH iwl-next v2 09/10] ixd: support for getting lan memory regions

Quoted 18 lines

-----Original Message-----
From: Michal Swiatkowski <[email protected]>
Sent: 11 September 2026 18:19
To: [email protected]
Cc: [email protected]; Michal Swiatkowski <[email protected]>
Subject: [PATCH iwl-next v2 09/10] ixd: support for getting lan memory regions

Send and parse get lan memory regions command. Map the regions from the command response.

It is needed to set number of regions to not zero value even when just sending the command. Set it to 1 and add comment about that.

It is possible that get lan memory regions isn't supported. Driver should cover this situation by mapping regions needed for running.

Quoted 7 lines
---
 drivers/net/ethernet/intel/ixd/ixd.h          |   3 +
 drivers/net/ethernet/intel/ixd/ixd_main.c     | 131 +++++++++++++++---
 drivers/net/ethernet/intel/ixd/ixd_virtchnl.c |  90 +++++++++++-
 3 files changed, 201 insertions(+), 23 deletions(-)
#19 lore raw

PATCH v2 10/10 ixd: use interrupt for mailbox communication

In reply to Michal Swiatkowski

Switch from polling to interrupt for invoking mailbox operations when it is available.

Add flag to store the information about the mailbox interrupt. If interrupt is turned off mailbox will be handled by periodic workqueue. If it is enabled interrupt will take care of it.

---
 drivers/net/ethernet/intel/ixd/Kconfig        |   1 +
 drivers/net/ethernet/intel/ixd/ixd.h          |  28 ++++
 drivers/net/ethernet/intel/ixd/ixd_ctlq.c     |   8 +-
 drivers/net/ethernet/intel/ixd/ixd_lan_regs.h |  10 ++
 drivers/net/ethernet/intel/ixd/ixd_lib.c      | 126 ++++++++++++++++++
 drivers/net/ethernet/intel/ixd/ixd_main.c     |   2 +
 6 files changed, 173 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/ixd/Kconfig +1 -0
index 0a48b3bb7bc2..69c37c2cdb67 100644
@@ -6,6 +6,7 @@ config IXD
 	depends on PCI_MSI
 	select LIBIE_CP
 	select LIBIE_PCI
+	select LIBIE_IRQ
 	select NET_DEVLINK
 	help
 	  This driver supports Intel(R) Control Plane PCI Function
drivers/net/ethernet/intel/ixd/ixd.h +28 -0
index 4a1590f937b5..ed5ffe04f48d 100644
@@ -5,9 +5,20 @@
 #define _IXD_H_
 
 #include <linux/net/intel/libie/controlq.h>
+#include <linux/net/intel/libie/irq.h>
 
 #define IXD_INIT_TASK_DELAY_JIFFIES	msecs_to_jiffies(500)
 
+/**
+ * enum ixd_flags - Whole device flags
+ * @IXD_MB_INTR_MODE: Mailbox in interrupt mode
+ * @IXD_FLAGS_NBITS: Must be last
+ */
+enum ixd_flags {
+	IXD_MB_INTR_MODE,
+	IXD_FLAGS_NBITS,
+};
+
 /**
  * struct ixd_adapter - Data structure representing a CPF
  * @cp_ctx: Control plane communication context
@@ -24,6 +35,11 @@
  * @vc_ver.major: Negotiated major virtchnl version
  * @vc_ver.minor: Negotiated minor virtchnl version
  * @caps: Negotiated virtchnl capabilities
+ * @mb_irq: index and virq to track mailbox
+ * @irq: libie irq for interrupts management
+ * @mb_dyn_ctl: mailbox dynamic control register address
+ * @oicr_ena: direct OICR enable register address
+ * @flags: look at enum ixd_flags for more details
  */
 struct ixd_adapter {
 	struct libie_ctlq_ctx cp_ctx;
@@ -42,6 +58,11 @@ struct ixd_adapter {
 		u32 minor;
 	} vc_ver;
 	struct virtchnl2_get_capabilities caps;
+	struct msi_map mb_irq;
+	struct libie_irq irq;
+	void __iomem *mb_dyn_ctl;
+	void __iomem *oicr_ena;
+	DECLARE_BITMAP(flags, IXD_FLAGS_NBITS);
 };
 
 /**
@@ -55,6 +76,11 @@ static inline struct device *ixd_to_dev(struct ixd_adapter *adapter)
 	return &adapter->cp_ctx.mmio_info.pdev->dev;
 }
 
+static inline struct pci_dev *ixd_to_pdev(struct ixd_adapter *adapter)
+{
+	return adapter->cp_ctx.mmio_info.pdev;
+}
+
 void ixd_ctlq_reg_init(struct ixd_adapter *adapter,
 		       struct libie_ctlq_reg *ctlq_reg_tx,
 		       struct libie_ctlq_reg *ctlq_reg_rx);
@@ -66,5 +92,7 @@ void ixd_deinit_dflt_mbx(struct ixd_adapter *adapter);
 int ixd_iomap_running_regions(struct ixd_adapter *adapter);
 bool ixd_iomap_is_not_start_region(struct libie_mmio_info *info,
 				   struct libie_pci_mmio_region *reg);
+void ixd_deinit_interrupts(struct ixd_adapter *adapter);
+void ixd_mailbox_irq_enable(struct ixd_adapter *adapter);
 
 #endif /* _IXD_H_ */
drivers/net/ethernet/intel/ixd/ixd_ctlq.c +6 -2
index 8712e10c8c50..43daef30689a 100644
@@ -134,8 +134,12 @@ void ixd_ctlq_rx_task(struct work_struct *work)
 
 	adapter = container_of(work, struct ixd_adapter, mbx_task.work);
 
-	queue_delayed_work(system_dfl_wq, &adapter->mbx_task,
-			   IXD_CTLQ_RX_TASK_DELAY_JIFFIES);
+	if (test_bit(IXD_MB_INTR_MODE, adapter->flags))
+		/* Just re-enable irq in HW. */
+		ixd_mailbox_irq_enable(adapter);
+	else
+		queue_delayed_work(system_dfl_wq, &adapter->mbx_task,
+				   IXD_CTLQ_RX_TASK_DELAY_JIFFIES);
 
 	ixd_ctlq_recv_mb_msg(adapter);
 }
drivers/net/ethernet/intel/ixd/ixd_lan_regs.h +10 -0
index 58e58c75981b..b924ada5f831 100644
@@ -31,6 +31,16 @@
 #define PF_FW_ATQH			(PF_FW_MBX + 0x20)
 #define PF_FW_ATQT			(PF_FW_MBX + 0x24)
 
+/* Interrupts */
+#define PF_GLINT_DYN_CTL_INTENA_S	0
+#define PF_GLINT_DYN_CTL_INTENA_M	BIT(PF_GLINT_DYN_CTL_INTENA_S)
+#define PF_GLINT_DYN_CTL_ITR_INDX_S	3
+#define PF_GLINT_DYN_CTL_ITR_INDX_M	GENMASK(4, 3)
+
+/* Generic registers */
+#define PF_INT_DIR_OICR_ENA		0x08406000
+#define PF_INT_DIR_OICR_ENA_M		GENMASK(31, 0)
+
 /* Reset registers */
 #define PFGEN_RTRIG_REG_LEN		2048
 #define PFGEN_RTRIG			0x08407000	/* Device resets */
drivers/net/ethernet/intel/ixd/ixd_lib.c +126 -0

144 lines not on this page · raw message

drivers/net/ethernet/intel/ixd/ixd_main.c +2 -0
index 488a919f3b1b..e83550da3e9a 100644
@@ -9,6 +9,7 @@
 MODULE_DESCRIPTION("Intel(R) Control Plane Function Device Driver");
 MODULE_IMPORT_NS("LIBIE_CP");
 MODULE_IMPORT_NS("LIBIE_PCI");
+MODULE_IMPORT_NS("LIBIE_IRQ");
 MODULE_LICENSE("GPL");
 
 /**
@@ -25,6 +26,7 @@ static void ixd_remove(struct pci_dev *pdev)
 	ixd_devlink_unregister(adapter);
 
 	/* Leave the device clean on exit */
+	ixd_deinit_interrupts(adapter);
 	if (adapter->xnm)
 		libie_ctlq_xn_shutdown(adapter->xnm);
 	ixd_trigger_reset(adapter);
Signature · 1 line
2.49.0
Tested-by on v2 10/10
#20 lore raw

RE: [PATCH iwl-next v2 10/10] ixd: use interrupt for mailbox communication

Quoted 19 lines

-----Original Message-----
From: Michal Swiatkowski <[email protected]>
Sent: 11 September 2026 18:19
To: [email protected]
Cc: [email protected]; Michal Swiatkowski <[email protected]>; Loktionov, Aleksandr <[email protected]>
Subject: [PATCH iwl-next v2 10/10] ixd: use interrupt for mailbox communication

Switch from polling to interrupt for invoking mailbox operations when it is available.

Add flag to store the information about the mailbox interrupt. If interrupt is turned off mailbox will be handled by periodic workqueue.
If it is enabled interrupt will take care of it.

Quoted 9 lines
---
 drivers/net/ethernet/intel/ixd/Kconfig        |   1 +
 drivers/net/ethernet/intel/ixd/ixd.h          |  28 ++++
 drivers/net/ethernet/intel/ixd/ixd_ctlq.c     |   8 +-
 drivers/net/ethernet/intel/ixd/ixd_lan_regs.h |  10 ++
 drivers/net/ethernet/intel/ixd/ixd_lib.c      | 126 ++++++++++++++++++
 drivers/net/ethernet/intel/ixd/ixd_main.c     |   2 +
 6 files changed, 173 insertions(+), 2 deletions(-)