Interrupts helper in libie
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.
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 | 70 +-- drivers/net/ethernet/intel/idpf/idpf_dev.c | 108 ++--- drivers/net/ethernet/intel/idpf/idpf_lib.c | 430 +++++------------- drivers/net/ethernet/intel/idpf/idpf_main.c | 3 +- drivers/net/ethernet/intel/idpf/idpf_txrx.c | 136 +++--- 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 | 162 +------ .../net/ethernet/intel/idpf/idpf_virtchnl.h | 9 +- drivers/net/ethernet/intel/ixd/Kconfig | 1 + drivers/net/ethernet/intel/ixd/ixd.h | 27 ++ drivers/net/ethernet/intel/ixd/ixd_ctlq.c | 8 +- drivers/net/ethernet/intel/ixd/ixd_lan_regs.h | 18 + drivers/net/ethernet/intel/ixd/ixd_lib.c | 93 ++++ drivers/net/ethernet/intel/ixd/ixd_main.c | 127 +++++- drivers/net/ethernet/intel/ixd/ixd_virtchnl.c | 70 +++ drivers/net/ethernet/intel/libie/Kconfig | 6 + drivers/net/ethernet/intel/libie/Makefile | 4 + drivers/net/ethernet/intel/libie/irq.c | 363 +++++++++++++++ include/linux/net/intel/libie/irq.h | 118 +++++ 29 files changed, 1174 insertions(+), 939 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
PATCH 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 | 187 +++++++++--------- .../net/ethernet/intel/idpf/idpf_virtchnl.h | 6 - 8 files changed, 179 insertions(+), 246 deletions(-)
drivers/net/ethernet/intel/idpf/idpf.h +39 -2
@@ -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
@@ -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
@@ -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 +89 -98
217 lines not on this page · raw message
drivers/net/ethernet/intel/idpf/idpf_virtchnl.h +0 -6
@@ -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
PATCH 2/10 idpf: fill q_vector interrupt registers one by one
In reply to Michal SwiatkowskiMost 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
@@ -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
@@ -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
PATCH 3/10 idpf: get rid of msix_entries array
In reply to Michal SwiatkowskiThere 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
@@ -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
@@ -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
PATCH 4/10 idpf: drop v_idx from q_vector structure
In reply to Michal SwiatkowskiStoring 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
@@ -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
@@ -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
@@ -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
@@ -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
PATCH 5/10 libie, idpf: move irq code to libie
In reply to Michal SwiatkowskiManagement 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 | 56 +-- drivers/net/ethernet/intel/idpf/idpf_lib.c | 387 ++++++------------ drivers/net/ethernet/intel/idpf/idpf_main.c | 3 +- drivers/net/ethernet/intel/idpf/idpf_txrx.c | 98 +++-- 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 | 252 ++++++++++++ include/linux/net/intel/libie/irq.h | 75 ++++ 12 files changed, 538 insertions(+), 394 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
@@ -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 +3 -53
120 lines not on this page · raw message
drivers/net/ethernet/intel/idpf/idpf_lib.c +120 -267
532 lines not on this page · raw message
drivers/net/ethernet/intel/idpf/idpf_main.c +1 -2
@@ -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 +67 -31
187 lines not on this page · raw message
drivers/net/ethernet/intel/idpf/idpf_txrx.h +1 -1
@@ -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
@@ -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
@@ -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
@@ -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 +252 -0
252 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
PATCH 6/10 libie, idpf: move hardware irq info struct to libie
In reply to Michal SwiatkowskiManually 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
@@ -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_adapter - Device data struct generated on probe * @pdev: PCI device struct given on probe
@@ -685,7 +651,7 @@ struct idpf_adapter {struct msix_entry *rdma_msix_entries;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
@@ -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
@@ -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
@@ -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
@@ -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
PATCH 7/10 libie, idpf: move parsing alloc vectors command to libie
In reply to Michal SwiatkowskiNo 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 | 91 +++++++++++++++++++ include/linux/net/intel/libie/irq.h | 7 ++ 3 files changed, 101 insertions(+), 82 deletions(-)
drivers/net/ethernet/intel/idpf/idpf_virtchnl.c +3 -82
@@ -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)/* Unroll getting vectors and leave it in clean state for * the next try.
@@ -2381,9 +2304,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 +91 -0
97 lines not on this page · raw message
include/linux/net/intel/libie/irq.h +7 -0
@@ -5,6 +5,7 @@#define __LIBIE_IRQ_H#include <linux/pci.h> +#include <linux/net/intel/virtchnl2.h> /* In whole code in libie_irq index means the software 0-based irq index * for driver purpose, virq means the linux irq line number. Index can be used
@@ -105,5 +106,11 @@ 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. */ +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
PATCH 8/10 ice: use libie_irq for interrupts managing
In reply to Michal SwiatkowskiChange 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.
Previous code fallback to STATIC when there is not more dynamic. Do the same by introducing ANY type in libie_irq.
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
@@ -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
@@ -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>
@@ -352,8 +353,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 */
@@ -566,7 +565,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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -96,6 +96,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;/* Change entry type if dynamic isn't supported. Reflect correct type
@@ -108,9 +109,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;
@@ -144,6 +162,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
@@ -197,8 +216,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
@@ -18,6 +18,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
@@ -32,6 +33,7 @@enum libie_irq_type {LIBIE_IRQ_STATIC ,LIBIE_IRQ_DYNAMIC , +LIBIE_IRQ_ANY ,LIBIE_IRQ_NUM_TYPES , };
Signature · 1 line
2.49.0
PATCH 9/10 ixd: support for getting lan memory regions
In reply to Michal SwiatkowskiSend 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_lan_regs.h | 8 ++ drivers/net/ethernet/intel/ixd/ixd_main.c | 125 +++++++++++++++--- drivers/net/ethernet/intel/ixd/ixd_virtchnl.c | 70 ++++++++++ 4 files changed, 184 insertions(+), 22 deletions(-)
drivers/net/ethernet/intel/ixd/ixd.h +3 -0
@@ -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_lan_regs.h +8 -0
@@ -39,6 +39,14 @@#define PFGEN_CTRL 0x0840700C/* PFR trigger */ #define PFGEN_CTRL_PFSWR BIT(0) +/* Default register mapping */ +#define PF_PCI_0 0x0 +#define PF_PCI_0_SIZE 0x08400000 +#define PF_PCI_1 0x08401000 +#define PF_PCI_1_SIZE 0x6000 +#define PF_PCI_2 0x08408000 +#define PF_PCI_2_SIZE 0x37F8000 +/** * struct ixd_bar_region - BAR region description * @offset: BAR region offset
drivers/net/ethernet/intel/ixd/ixd_main.c +103 -22
152 lines not on this page · raw message
drivers/net/ethernet/intel/ixd/ixd_virtchnl.c +70 -0
87 lines not on this page · raw message
Signature · 1 line
2.49.0
PATCH 10/10 ixd: use interrupt for mailbox communication
In reply to Michal SwiatkowskiSwitch 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 | 24 +++++ 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 | 93 +++++++++++++++++++ drivers/net/ethernet/intel/ixd/ixd_main.c | 2 + 6 files changed, 136 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/ixd/Kconfig +1 -0
@@ -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 +24 -0
@@ -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,9 @@* @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 +* @flags: look at enum ixd_flags for more details */ struct ixd_adapter {struct libie_ctlq_ctx cp_ctx;
@@ -42,6 +56,9 @@ struct ixd_adapter {u32 minor; } vc_ver;struct virtchnl2_get_capabilities caps; +struct msi_map mb_irq; +struct libie_irq irq; +DECLARE_BITMAP (flags,IXD_FLAGS_NBITS ); };/**
@@ -55,6 +72,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 +88,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
@@ -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
@@ -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 +93 -0
111 lines not on this page · raw message
drivers/net/ethernet/intel/ixd/ixd_main.c +2 -0
@@ -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" );/**
@@ -28,6 +29,7 @@ static void ixd_remove(struct pci_dev *pdev)if (adapter->xnm)libie_ctlq_xn_shutdown (adapter->xnm);ixd_trigger_reset (adapter); +ixd_deinit_interrupts (adapter);ixd_deinit_dflt_mbx (adapter);libie_pci_unmap_all_mmio_regions (&adapter->cp_ctx.mmio_info);
Signature · 1 line
2.49.0