irdma: Misc cleanup
Subsystems (2)
cover irdma: Misc cleanup
This series contains miscellaneous clean up patches and update to how CQ lookup is done during AE events.
Krzysztof Czurylo (1):
RDMA/irdma: Add table based lookup for CQ pointer during an event
Mustafa Ismail (1):
RDMA/irdma: Cleanup and rename irdma_netdev_vlan_ipv6()
Sindhu Devale (2):
RDMA/irdma: Drop a local in irdma_sc_get_next_aeqe RDMA/irdma: Refactor error handling in create CQP
drivers/infiniband/hw/irdma/cm.c | 23 ++++++-------- drivers/infiniband/hw/irdma/ctrl.c | 5 +-- drivers/infiniband/hw/irdma/hw.c | 62 ++++++++++++++++++++++++------------- drivers/infiniband/hw/irdma/main.h | 6 +++- drivers/infiniband/hw/irdma/utils.c | 25 +++++++++++++++ drivers/infiniband/hw/irdma/verbs.c | 9 +++++- drivers/infiniband/hw/irdma/verbs.h | 2 ++ 7 files changed, 91 insertions(+), 41 deletions(-)
Signature · 1 line
1.8.3.1
PATCH 1/4 RDMA/irdma: Drop a local in irdma_sc_get_next_aeqe
From: Sindhu Devale <[email protected]>
Drop the local wqe_idx in irdma_sc_get_next_aeqe and instead store the wqe_idx in the info structure for all asynchronous events(AE) received. There is no reason it should be tied to a specific AE source.
--- drivers/infiniband/hw/irdma/ctrl.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/infiniband/hw/irdma/ctrl.c +1 -4
@@ -4004,7 +4004,6 @@ int irdma_sc_get_next_aeqe(struct irdma_sc_aeq *aeq, {u64 temp, compl_ctx;__le64 *aeqe; -u16 wqe_idx;u8 ae_src;u8 polarity;
@@ -4020,7 +4019,7 @@ int irdma_sc_get_next_aeqe(struct irdma_sc_aeq *aeq, aeqe, 16, false); ae_src = (u8 )FIELD_GET (IRDMA_AEQE_AESRC , temp); - wqe_idx = (u16 )FIELD_GET (IRDMA_AEQE_WQDESCIDX , temp); + info->wqe_idx = (u16 )FIELD_GET (IRDMA_AEQE_WQDESCIDX , temp); info->qp_cq_id = (u32 )FIELD_GET (IRDMA_AEQE_QPCQID_LOW , temp) | ((u32 )FIELD_GET (IRDMA_AEQE_QPCQID_HI , temp) <<18 ); info->ae_id = (u16 )FIELD_GET (IRDMA_AEQE_AECODE , temp);
@@ -4103,7 +4102,6 @@ int irdma_sc_get_next_aeqe(struct irdma_sc_aeq *aeq,case IRDMA_AE_SOURCE_RQ_0011 : info->qp = true; info->rq = true; - info->wqe_idx = wqe_idx; info->compl_ctx = compl_ctx;break ;case IRDMA_AE_SOURCE_CQ :
@@ -4117,7 +4115,6 @@ int irdma_sc_get_next_aeqe(struct irdma_sc_aeq *aeq,case IRDMA_AE_SOURCE_SQ_0111 : info->qp = true; info->sq = true; - info->wqe_idx = wqe_idx; info->compl_ctx = compl_ctx;break ;case IRDMA_AE_SOURCE_IN_RR_WR :
Signature · 1 line
1.8.3.1
PATCH 2/4 RDMA/irdma: Refactor error handling in create CQP
In reply to Shiraz SaleemFrom: Sindhu Devale <[email protected]>
In case of a failure in irdma_create_cqp, do not call irdma_destroy_cqp, but cleanup all the allocated resources in reverse order.
Drop the extra argument in irdma_destroy_cqp as its no longer needed.
--- drivers/infiniband/hw/irdma/hw.c | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-)
drivers/infiniband/hw/irdma/hw.c +21 -14
@@ -567,7 +567,7 @@ static void irdma_destroy_irq(struct irdma_pci_f *rf,* Issue destroy cqp request and * free the resources associated with the cqp */ -static void irdma_destroy_cqp (struct irdma_pci_f *rf,bool free_hwcqp) +static void irdma_destroy_cqp (struct irdma_pci_f *rf) {struct irdma_sc_dev *dev = &rf->sc_dev;struct irdma_cqp *cqp = &rf->cqp;
@@ -575,8 +575,8 @@ static void irdma_destroy_cqp(struct irdma_pci_f *rf, bool free_hwcqp)if (rf->cqp_cmpl_wq)destroy_workqueue (rf->cqp_cmpl_wq); -if (free_hwcqp) - status =irdma_sc_cqp_destroy (dev->cqp); + + status =irdma_sc_cqp_destroy (dev->cqp);if (status)ibdev_dbg (to_ibdev (dev),"ERR: Destroy CQP failed %d\n" , status);
@@ -920,8 +920,8 @@ static int irdma_create_cqp(struct irdma_pci_f *rf) cqp->scratch_array =kcalloc (sqsize,sizeof (*cqp->scratch_array),GFP_KERNEL );if (!cqp->scratch_array) { -kfree (cqp->cqp_requests); -return -ENOMEM ; + status = -ENOMEM ; + goto err_scratch; } dev->cqp = &cqp->sc_cqp;
@@ -931,15 +931,14 @@ static int irdma_create_cqp(struct irdma_pci_f *rf) cqp->sq.va =dma_alloc_coherent (dev->hw->device, cqp->sq.size, &cqp->sq.pa,GFP_KERNEL );if (!cqp->sq.va) { -kfree (cqp->scratch_array); -kfree (cqp->cqp_requests); -return -ENOMEM ; + status = -ENOMEM ; + goto err_sq; } status =irdma_obj_aligned_mem (rf, &mem,sizeof (struct irdma_cqp_ctx ),IRDMA_HOST_CTX_ALIGNMENT_M );if (status) - goto exit; + goto err_ctx; dev->cqp->host_ctx_pa = mem.pa; dev->cqp->host_ctx = mem.va;
@@ -965,7 +964,7 @@ static int irdma_create_cqp(struct irdma_pci_f *rf) status =irdma_sc_cqp_init (dev->cqp, &cqp_init_info);if (status) {ibdev_dbg (to_ibdev (dev),"ERR: cqp init status %d\n" , status); - goto exit; + goto err_ctx; }spin_lock_init (&cqp->req_lock);
@@ -976,7 +975,7 @@ static int irdma_create_cqp(struct irdma_pci_f *rf)ibdev_dbg (to_ibdev (dev),"ERR: cqp create failed - status %d maj_err %d min_err %d\n" , status, maj_err, min_err); - goto exit; + goto err_ctx; }INIT_LIST_HEAD (&cqp->cqp_avail_reqs);
@@ -990,8 +989,16 @@ static int irdma_create_cqp(struct irdma_pci_f *rf)init_waitqueue_head (&cqp->remove_wq);return 0 ; -exit: -irdma_destroy_cqp (rf, false); +err_ctx: +dma_free_coherent (dev->hw->device, cqp->sq.size, + cqp->sq.va, cqp->sq.pa); + cqp->sq.va =NULL ; +err_sq: +kfree (cqp->scratch_array); + cqp->scratch_array =NULL ; +err_scratch: +kfree (cqp->cqp_requests); + cqp->cqp_requests =NULL ;return status; }
@@ -1746,7 +1753,7 @@ void irdma_ctrl_deinit_hw(struct irdma_pci_f *rf) rf->reset, rf->rdma_ver); fallthrough;case CQP_CREATED : -irdma_destroy_cqp (rf, true); +irdma_destroy_cqp (rf); fallthrough;case INITIAL_STATE :irdma_del_init_mem (rf);
Signature · 1 line
1.8.3.1
PATCH 3/4 RDMA/irdma: Add table based lookup for CQ pointer during an event
In reply to Shiraz SaleemFrom: Krzysztof Czurylo <[email protected]>
Add a CQ table based loookup to allow quick search for CQ pointer having CQ ID in case of CQ related asynchrononous event. The table is implemented in a similar fashion to QP table.
Also add a reference counters for CQ. This is to prevent destroying CQ while an asynchronous event is being processed.
The memory resource table size is sized higher with this update, and this table doesn't need to be physically contiguous, so use a vzalloc vs kzalloc to allocate the table.
--- drivers/infiniband/hw/irdma/hw.c | 27 +++++++++++++++++++-------- drivers/infiniband/hw/irdma/main.h | 4 ++++ drivers/infiniband/hw/irdma/utils.c | 25 +++++++++++++++++++++++++ drivers/infiniband/hw/irdma/verbs.c | 7 +++++++ drivers/infiniband/hw/irdma/verbs.h | 2 ++ 5 files changed, 57 insertions(+), 8 deletions(-)
drivers/infiniband/hw/irdma/hw.c +19 -8
@@ -218,7 +218,6 @@ static void irdma_process_aeq(struct irdma_pci_f *rf)struct irdma_aeqe_info *info = &aeinfo;int ret;struct irdma_qp *iwqp =NULL ; -struct irdma_sc_cq *cq =NULL ;struct irdma_cq *iwcq =NULL ;struct irdma_sc_qp *qp =NULL ;struct irdma_qp_host_ctx_info *ctx_info =NULL ;
@@ -335,10 +334,18 @@ static void irdma_process_aeq(struct irdma_pci_f *rf)ibdev_err (&iwdev->ibdev,"Processing an iWARP related AE for CQ misc = 0x%04X\n" , info->ae_id); - cq = (struct irdma_sc_cq *)(unsigned long ) - info->compl_ctx; - iwcq = cq->back_cq; +spin_lock_irqsave (&rf->cqtable_lock, flags); + iwcq = rf->cq_table[info->qp_cq_id]; +if (!iwcq) { +spin_unlock_irqrestore (&rf->cqtable_lock, + flags); +ibdev_dbg (to_ibdev (dev), +"cq_id %d is already freed\n" , info->qp_cq_id); +continue ; + } +irdma_cq_add_ref (&iwcq->ibcq); +spin_unlock_irqrestore (&rf->cqtable_lock, flags);if (iwcq->ibcq.event_handler) {struct ib_event ibevent;
@@ -349,6 +356,7 @@ static void irdma_process_aeq(struct irdma_pci_f *rf) iwcq->ibcq.event_handler (&ibevent, iwcq->ibcq.cq_context); } +irdma_cq_rem_ref (&iwcq->ibcq);break ;case IRDMA_AE_RESET_NOT_SENT :case IRDMA_AE_LLP_DOUBT_REACHABILITY :
@@ -1555,7 +1563,7 @@ static void irdma_del_init_mem(struct irdma_pci_f *rf)kfree (dev->hmc_info->sd_table.sd_entry); dev->hmc_info->sd_table.sd_entry =NULL ; -kfree (rf->mem_rsrc); +vfree (rf->mem_rsrc); rf->mem_rsrc =NULL ;dma_free_coherent (rf->hw.device, rf->obj_mem.size, rf->obj_mem.va, rf->obj_mem.pa);
@@ -1951,10 +1959,12 @@ static void irdma_set_hw_rsrc(struct irdma_pci_f *rf) rf->allocated_arps = &rf->allocated_mcgs[BITS_TO_LONGS (rf->max_mcg)]; rf->qp_table = (struct irdma_qp **) (&rf->allocated_arps[BITS_TO_LONGS (rf->arp_table_size)]); + rf->cq_table = (struct irdma_cq **)(&rf->qp_table[rf->max_qp]);spin_lock_init (&rf->rsrc_lock);spin_lock_init (&rf->arp_lock);spin_lock_init (&rf->qptable_lock); +spin_lock_init (&rf->cqtable_lock);spin_lock_init (&rf->qh_list_lock); }
@@ -1975,6 +1985,7 @@ static u32 irdma_calc_mem_rsrc_size(struct irdma_pci_f *rf) rsrc_size +=sizeof (unsigned long ) *BITS_TO_LONGS (rf->max_ah); rsrc_size +=sizeof (unsigned long ) *BITS_TO_LONGS (rf->max_mcg); rsrc_size +=sizeof (struct irdma_qp **) * rf->max_qp; + rsrc_size +=sizeof (struct irdma_cq **) * rf->max_cq;return rsrc_size; }
@@ -2008,10 +2019,10 @@ u32 irdma_initialize_hw_rsrc(struct irdma_pci_f *rf) rf->max_mcg = rf->max_qp; rsrc_size =irdma_calc_mem_rsrc_size (rf); - rf->mem_rsrc =kzalloc (rsrc_size,GFP_KERNEL ); + rf->mem_rsrc =vzalloc (rsrc_size);if (!rf->mem_rsrc) { ret = -ENOMEM ; - goto mem_rsrc_kzalloc_fail; + goto mem_rsrc_vzalloc_fail; } rf->arp_table = (struct irdma_arp_entry *)rf->mem_rsrc;
@@ -2039,7 +2050,7 @@ u32 irdma_initialize_hw_rsrc(struct irdma_pci_f *rf)return 0 ; -mem_rsrc_kzalloc_fail: +mem_rsrc_vzalloc_fail:bitmap_free (rf->allocated_ws_nodes); rf->allocated_ws_nodes =NULL ;
drivers/infiniband/hw/irdma/main.h +4 -0
@@ -309,7 +309,9 @@ struct irdma_pci_f {spinlock_t arp_lock;/*protect ARP table access*/ spinlock_t rsrc_lock;/* protect HW resource array access */ spinlock_t qptable_lock;/*protect QP table access*/ +spinlock_t cqtable_lock;/*protect CQ table access*/ struct irdma_qp **qp_table; +struct irdma_cq **cq_table;spinlock_t qh_list_lock;/* protect mc_qht_list */ struct mc_table_list mc_qht_list;struct irdma_msix_vector *iw_msixtbl;
@@ -500,6 +502,8 @@ int irdma_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask, struct ib_udata *udata);int irdma_modify_qp_roce (struct ib_qp *ibqp,struct ib_qp_attr *attr,int attr_mask,struct ib_udata *udata); +void irdma_cq_add_ref (struct ib_cq *ibcq); +void irdma_cq_rem_ref (struct ib_cq *ibcq);void irdma_cq_wq_destroy (struct irdma_pci_f *rf,struct irdma_sc_cq *cq);void irdma_cleanup_pending_cqp_op (struct irdma_pci_f *rf);
drivers/infiniband/hw/irdma/utils.c +25 -0
@@ -760,6 +760,31 @@ void irdma_qp_rem_ref(struct ib_qp *ibqp)complete (&iwqp->free_qp); } +void irdma_cq_add_ref (struct ib_cq *ibcq) +{ +struct irdma_cq *iwcq =to_iwcq (ibcq); + +refcount_inc (&iwcq->refcnt); +} + +void irdma_cq_rem_ref (struct ib_cq *ibcq) +{ +struct ib_device *ibdev = ibcq->device; +struct irdma_device *iwdev =to_iwdev (ibdev); +struct irdma_cq *iwcq =to_iwcq (ibcq); +unsigned long flags; + +spin_lock_irqsave (&iwdev->rf->cqtable_lock, flags); +if (!refcount_dec_and_test (&iwcq->refcnt)) { +spin_unlock_irqrestore (&iwdev->rf->cqtable_lock, flags); +return ; + } + + iwdev->rf->cq_table[iwcq->cq_num] =NULL ; +spin_unlock_irqrestore (&iwdev->rf->cqtable_lock, flags); +complete (&iwcq->free_cq); +} +struct ib_device *to_ibdev (struct irdma_sc_dev *dev) { return &(container_of(dev, struct irdma_pci_f, sc_dev))->iwdev->ibdev;
drivers/infiniband/hw/irdma/verbs.c +7 -0
@@ -1805,6 +1805,9 @@ static int irdma_destroy_cq(struct ib_cq *ib_cq, struct ib_udata *udata)irdma_process_resize_list (iwcq, iwdev,NULL );spin_unlock_irqrestore (&iwcq->lock, flags); +irdma_cq_rem_ref (ib_cq); +wait_for_completion (&iwcq->free_cq); +irdma_cq_wq_destroy (iwdev->rf, cq);spin_lock_irqsave (&iwceq->ce_lock, flags);
@@ -2014,6 +2017,7 @@ static int irdma_create_cq(struct ib_cq *ibcq, cq = &iwcq->sc_cq; cq->back_cq = iwcq; +refcount_set (&iwcq->refcnt,1 );spin_lock_init (&iwcq->lock);INIT_LIST_HEAD (&iwcq->resize_list);INIT_LIST_HEAD (&iwcq->cmpl_generated);
@@ -2165,6 +2169,9 @@ static int irdma_create_cq(struct ib_cq *ibcq, goto cq_destroy; } } + rf->cq_table[cq_num] = iwcq; +init_completion (&iwcq->free_cq); +return 0 ; cq_destroy:irdma_cq_wq_destroy (rf, cq);
drivers/infiniband/hw/irdma/verbs.h +2 -0
@@ -122,6 +122,8 @@ struct irdma_cq {u32 cq_mem_size;struct irdma_dma_mem kmem;struct irdma_dma_mem kmem_shadow; +struct completion free_cq; +refcount_t refcnt;spinlock_t lock;/* for poll cq */ struct irdma_pbl *iwpbl;struct irdma_pbl *iwpbl_shadow;
Signature · 1 line
1.8.3.1
PATCH 4/4 RDMA/irdma: Cleanup and rename irdma_netdev_vlan_ipv6()
In reply to Shiraz SaleemFrom: Mustafa Ismail <[email protected]>
The return value from irdma_netdev_vlan_ipv6() is not used. Rename the functions and change to a void return.
--- drivers/infiniband/hw/irdma/cm.c | 23 ++++++++++------------- drivers/infiniband/hw/irdma/main.h | 2 +- drivers/infiniband/hw/irdma/verbs.c | 2 +- 3 files changed, 12 insertions(+), 15 deletions(-)
drivers/infiniband/hw/irdma/cm.c +10 -13
@@ -1591,21 +1591,20 @@ static u8 irdma_iw_get_vlan_prio(u32 *loc_addr, u8 prio, bool ipv4) }/** -* irdma_netdev_vlan_ipv6 - Gets the netdev and mac +* irdma_get_vlan_mac_ipv6 - Gets the vlan and mac * @addr: local IPv6 address * @vlan_id: vlan id for the given IPv6 address * @mac: mac address for the given IPv6 address * -* Returns the net_device of the IPv6 address and also sets the -* vlan id and mac for that address. +* Returns the vlan id and mac for an IPv6 address. */ -struct net_device *irdma_netdev_vlan_ipv6 (u32 *addr,u16 *vlan_id,u8 *mac) +void irdma_get_vlan_mac_ipv6 (u32 *addr,u16 *vlan_id,u8 *mac) {struct net_device *ip_dev =NULL ;struct in6_addr laddr6;if (!IS_ENABLED (CONFIG_IPV6 )) -return NULL ; +return ;irdma_copy_ip_htonl (laddr6.in6_u.u6_addr32, addr);if (vlan_id)
@@ -1624,8 +1623,6 @@ struct net_device *irdma_netdev_vlan_ipv6(u32 *addr, u16 *vlan_id, u8 *mac) } }rcu_read_unlock (); - -return ip_dev; }/**
@@ -3666,8 +3663,8 @@ int irdma_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param) cm_node->vlan_id =irdma_get_vlan_ipv4 (cm_node->loc_addr); }else { cm_node->ipv4 = false; -irdma_netdev_vlan_ipv6 (cm_node->loc_addr, &cm_node->vlan_id, -NULL ); +irdma_get_vlan_mac_ipv6 (cm_node->loc_addr, &cm_node->vlan_id, +NULL ); }ibdev_dbg (&iwdev->ibdev,"CM: Accept vlan_id=%d\n" , cm_node->vlan_id);
@@ -3875,8 +3872,8 @@ int irdma_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param) raddr6->sin6_addr.in6_u.u6_addr32); cm_info.loc_port =ntohs (laddr6->sin6_port); cm_info.rem_port =ntohs (raddr6->sin6_port); -irdma_netdev_vlan_ipv6 (cm_info.loc_addr, &cm_info.vlan_id, -NULL ); +irdma_get_vlan_mac_ipv6 (cm_info.loc_addr, &cm_info.vlan_id, +NULL ); } cm_info.cm_id = cm_id; cm_info.qh_qpid = iwdev->vsi.ilq->qp_id;
@@ -4005,8 +4002,8 @@ int irdma_create_listen(struct iw_cm_id *cm_id, int backlog) laddr6->sin6_addr.in6_u.u6_addr32); cm_info.loc_port =ntohs (laddr6->sin6_port);if (ipv6_addr_type (&laddr6->sin6_addr) !=IPV6_ADDR_ANY ) { -irdma_netdev_vlan_ipv6 (cm_info.loc_addr, - &cm_info.vlan_id,NULL ); +irdma_get_vlan_mac_ipv6 (cm_info.loc_addr, + &cm_info.vlan_id,NULL ); }else { cm_info.vlan_id =0xFFFF ; wildcard = true;
drivers/infiniband/hw/irdma/main.h +1 -1
@@ -533,7 +533,7 @@ void irdma_gen_ae(struct irdma_pci_f *rf, struct irdma_sc_qp *qp,void irdma_copy_ip_ntohl (u32 *dst,__be32 *src);void irdma_copy_ip_htonl (__be32 *dst,u32 *src);u16 irdma_get_vlan_ipv4 (u32 *addr); -struct net_device *irdma_netdev_vlan_ipv6 (u32 *addr,u16 *vlan_id,u8 *mac); +void irdma_get_vlan_mac_ipv6 (u32 *addr,u16 *vlan_id,u8 *mac);struct ib_mr *irdma_reg_phys_mr (struct ib_pd *ib_pd,u64 addr,u64 size,int acc,u64 *iova_start);int irdma_upload_qp_context (struct irdma_qp *iwqp,bool freeze,bool raw);
drivers/infiniband/hw/irdma/verbs.c +1 -1
@@ -3994,7 +3994,7 @@ static int irdma_attach_mcast(struct ib_qp *ibqp, union ib_gid *ibgid, u16 lid)if (!ipv6_addr_v4mapped ((struct in6_addr *)ibgid)) {irdma_copy_ip_ntohl (ip_addr, sgid_addr.saddr_in6.sin6_addr.in6_u.u6_addr32); -irdma_netdev_vlan_ipv6 (ip_addr, &vlan_id,NULL ); +irdma_get_vlan_mac_ipv6 (ip_addr, &vlan_id,NULL ); ipv4 = false; ibdev_dbg(&iwdev->ibdev, "VERBS: qp_id=%d, IP6address=%pI6\n", ibqp->qp_num,
Signature · 1 line
1.8.3.1
Leon Romanovsky
AppliedQuoted 10 lines · Shiraz Saleem
This series contains miscellaneous clean up patches and update to how CQ lookup is done during AE events.
Krzysztof Czurylo (1):
RDMA/irdma: Add table based lookup for CQ pointer during an eventMustafa Ismail (1):
RDMA/irdma: Cleanup and renameirdma_netdev_vlan_ipv6()[...]
Applied, thanks!
[1/4] RDMA/irdma: Drop a local in irdma_sc_get_next_aeqe
https://git.kernel.org/rdma/rdma/c/8cfc99dada35b8 [2/4] RDMA/irdma: Refactor error handling in create CQP https://git.kernel.org/rdma/rdma/c/133b1cba46c6c8 [3/4] RDMA/irdma: Add table based lookup for CQ pointer during an event https://git.kernel.org/rdma/rdma/c/e49bad785e550f [4/4] RDMA/irdma: Cleanup and rename irdma_netdev_vlan_ipv6() https://git.kernel.org/rdma/rdma/c/693e1cdebb50d2
Best regards,
Signature · 1 line
Leon Romanovsky <[email protected]>