mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	qedr: Convert srqidr to XArray
Signed-off-by: Matthew Wilcox <willy@infradead.org> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
This commit is contained in:
		
							parent
							
								
									b6014f9e5f
								
							
						
					
					
						commit
						9fd15987ed
					
				
					 3 changed files with 7 additions and 41 deletions
				
			
		| 
						 | 
					@ -39,7 +39,6 @@
 | 
				
			||||||
#include <linux/iommu.h>
 | 
					#include <linux/iommu.h>
 | 
				
			||||||
#include <linux/pci.h>
 | 
					#include <linux/pci.h>
 | 
				
			||||||
#include <net/addrconf.h>
 | 
					#include <net/addrconf.h>
 | 
				
			||||||
#include <linux/idr.h>
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <linux/qed/qed_chain.h>
 | 
					#include <linux/qed/qed_chain.h>
 | 
				
			||||||
#include <linux/qed/qed_if.h>
 | 
					#include <linux/qed/qed_if.h>
 | 
				
			||||||
| 
						 | 
					@ -759,8 +758,8 @@ static void qedr_affiliated_event(void *context, u8 e_code, void *fw_handle)
 | 
				
			||||||
		break;
 | 
							break;
 | 
				
			||||||
	case EVENT_TYPE_SRQ:
 | 
						case EVENT_TYPE_SRQ:
 | 
				
			||||||
		srq_id = (u16)roce_handle64;
 | 
							srq_id = (u16)roce_handle64;
 | 
				
			||||||
		spin_lock_irqsave(&dev->srqidr.idr_lock, flags);
 | 
							xa_lock_irqsave(&dev->srqs, flags);
 | 
				
			||||||
		srq = idr_find(&dev->srqidr.idr, srq_id);
 | 
							srq = xa_load(&dev->srqs, srq_id);
 | 
				
			||||||
		if (srq) {
 | 
							if (srq) {
 | 
				
			||||||
			ibsrq = &srq->ibsrq;
 | 
								ibsrq = &srq->ibsrq;
 | 
				
			||||||
			if (ibsrq->event_handler) {
 | 
								if (ibsrq->event_handler) {
 | 
				
			||||||
| 
						 | 
					@ -774,7 +773,7 @@ static void qedr_affiliated_event(void *context, u8 e_code, void *fw_handle)
 | 
				
			||||||
				  "SRQ event with NULL pointer ibsrq. Handle=%llx\n",
 | 
									  "SRQ event with NULL pointer ibsrq. Handle=%llx\n",
 | 
				
			||||||
				  roce_handle64);
 | 
									  roce_handle64);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		spin_unlock_irqrestore(&dev->srqidr.idr_lock, flags);
 | 
							xa_unlock_irqrestore(&dev->srqs, flags);
 | 
				
			||||||
		DP_NOTICE(dev, "SRQ event %d on handle %p\n", e_code, srq);
 | 
							DP_NOTICE(dev, "SRQ event %d on handle %p\n", e_code, srq);
 | 
				
			||||||
	default:
 | 
						default:
 | 
				
			||||||
		break;
 | 
							break;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -33,7 +33,7 @@
 | 
				
			||||||
#define __QEDR_H__
 | 
					#define __QEDR_H__
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <linux/pci.h>
 | 
					#include <linux/pci.h>
 | 
				
			||||||
#include <linux/idr.h>
 | 
					#include <linux/xarray.h>
 | 
				
			||||||
#include <rdma/ib_addr.h>
 | 
					#include <rdma/ib_addr.h>
 | 
				
			||||||
#include <linux/qed/qed_if.h>
 | 
					#include <linux/qed/qed_if.h>
 | 
				
			||||||
#include <linux/qed/qed_chain.h>
 | 
					#include <linux/qed/qed_chain.h>
 | 
				
			||||||
| 
						 | 
					@ -123,11 +123,6 @@ struct qedr_device_attr {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define QEDR_ENET_STATE_BIT	(0)
 | 
					#define QEDR_ENET_STATE_BIT	(0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct qedr_idr {
 | 
					 | 
				
			||||||
	spinlock_t idr_lock; /* Protect idr data-structure */
 | 
					 | 
				
			||||||
	struct idr idr;
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
struct qedr_dev {
 | 
					struct qedr_dev {
 | 
				
			||||||
	struct ib_device	ibdev;
 | 
						struct ib_device	ibdev;
 | 
				
			||||||
	struct qed_dev		*cdev;
 | 
						struct qed_dev		*cdev;
 | 
				
			||||||
| 
						 | 
					@ -172,7 +167,7 @@ struct qedr_dev {
 | 
				
			||||||
	struct qedr_qp		*gsi_qp;
 | 
						struct qedr_qp		*gsi_qp;
 | 
				
			||||||
	enum qed_rdma_type	rdma_type;
 | 
						enum qed_rdma_type	rdma_type;
 | 
				
			||||||
	struct xarray		qps;
 | 
						struct xarray		qps;
 | 
				
			||||||
	struct qedr_idr		srqidr;
 | 
						struct xarray		srqs;
 | 
				
			||||||
	struct workqueue_struct *iwarp_wq;
 | 
						struct workqueue_struct *iwarp_wq;
 | 
				
			||||||
	u16			iwarp_max_mtu;
 | 
						u16			iwarp_max_mtu;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1380,11 +1380,6 @@ static int qedr_alloc_srq_kernel_params(struct qedr_srq *srq,
 | 
				
			||||||
	return rc;
 | 
						return rc;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int qedr_idr_add(struct qedr_dev *dev, struct qedr_idr *qidr,
 | 
					 | 
				
			||||||
			void *ptr, u32 id);
 | 
					 | 
				
			||||||
static void qedr_idr_remove(struct qedr_dev *dev,
 | 
					 | 
				
			||||||
			    struct qedr_idr *qidr, u32 id);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
struct ib_srq *qedr_create_srq(struct ib_pd *ibpd,
 | 
					struct ib_srq *qedr_create_srq(struct ib_pd *ibpd,
 | 
				
			||||||
			       struct ib_srq_init_attr *init_attr,
 | 
								       struct ib_srq_init_attr *init_attr,
 | 
				
			||||||
			       struct ib_udata *udata)
 | 
								       struct ib_udata *udata)
 | 
				
			||||||
| 
						 | 
					@ -1467,7 +1462,7 @@ struct ib_srq *qedr_create_srq(struct ib_pd *ibpd,
 | 
				
			||||||
			goto err2;
 | 
								goto err2;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	rc = qedr_idr_add(dev, &dev->srqidr, srq, srq->srq_id);
 | 
						rc = xa_insert_irq(&dev->srqs, srq->srq_id, srq, GFP_KERNEL);
 | 
				
			||||||
	if (rc)
 | 
						if (rc)
 | 
				
			||||||
		goto err2;
 | 
							goto err2;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1496,7 +1491,7 @@ int qedr_destroy_srq(struct ib_srq *ibsrq)
 | 
				
			||||||
	struct qedr_dev *dev = get_qedr_dev(ibsrq->device);
 | 
						struct qedr_dev *dev = get_qedr_dev(ibsrq->device);
 | 
				
			||||||
	struct qedr_srq *srq = get_qedr_srq(ibsrq);
 | 
						struct qedr_srq *srq = get_qedr_srq(ibsrq);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	qedr_idr_remove(dev, &dev->srqidr, srq->srq_id);
 | 
						xa_erase_irq(&dev->srqs, srq->srq_id);
 | 
				
			||||||
	in_params.srq_id = srq->srq_id;
 | 
						in_params.srq_id = srq->srq_id;
 | 
				
			||||||
	dev->ops->rdma_destroy_srq(dev->rdma_ctx, &in_params);
 | 
						dev->ops->rdma_destroy_srq(dev->rdma_ctx, &in_params);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1596,29 +1591,6 @@ static inline void qedr_qp_user_print(struct qedr_dev *dev, struct qedr_qp *qp)
 | 
				
			||||||
		 qp->usq.buf_len, qp->urq.buf_addr, qp->urq.buf_len);
 | 
							 qp->usq.buf_len, qp->urq.buf_addr, qp->urq.buf_len);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int qedr_idr_add(struct qedr_dev *dev, struct qedr_idr *qidr,
 | 
					 | 
				
			||||||
			void *ptr, u32 id)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	int rc;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	idr_preload(GFP_KERNEL);
 | 
					 | 
				
			||||||
	spin_lock_irq(&qidr->idr_lock);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	rc = idr_alloc(&qidr->idr, ptr, id, id + 1, GFP_ATOMIC);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	spin_unlock_irq(&qidr->idr_lock);
 | 
					 | 
				
			||||||
	idr_preload_end();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return rc < 0 ? rc : 0;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static void qedr_idr_remove(struct qedr_dev *dev, struct qedr_idr *qidr, u32 id)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	spin_lock_irq(&qidr->idr_lock);
 | 
					 | 
				
			||||||
	idr_remove(&qidr->idr, id);
 | 
					 | 
				
			||||||
	spin_unlock_irq(&qidr->idr_lock);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static inline void
 | 
					static inline void
 | 
				
			||||||
qedr_iwarp_populate_user_qp(struct qedr_dev *dev,
 | 
					qedr_iwarp_populate_user_qp(struct qedr_dev *dev,
 | 
				
			||||||
			    struct qedr_qp *qp,
 | 
								    struct qedr_qp *qp,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue