mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	RDMA/hns: Combine enable flags of qp
It's easier to understand and maintain enable flags of qp using a single field in type of unsigned long than defining a field for every flags in the structure hns_roce_qp, and we can add new flags for features more conveniently in the future. Link: https://lore.kernel.org/r/1588674607-25337-4-git-send-email-liweihang@huawei.com Signed-off-by: Lang Cheng <chenglang@huawei.com> Signed-off-by: Weihang Li <liweihang@huawei.com> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
This commit is contained in:
		
							parent
							
								
									30661322b8
								
							
						
					
					
						commit
						90ae0b57e4
					
				
					 3 changed files with 15 additions and 16 deletions
				
			
		| 
						 | 
				
			
			@ -131,8 +131,8 @@ enum {
 | 
			
		|||
};
 | 
			
		||||
 | 
			
		||||
enum {
 | 
			
		||||
	HNS_ROCE_SUPPORT_RQ_RECORD_DB = 1 << 0,
 | 
			
		||||
	HNS_ROCE_SUPPORT_SQ_RECORD_DB = 1 << 1,
 | 
			
		||||
	HNS_ROCE_QP_CAP_RQ_RECORD_DB = BIT(0),
 | 
			
		||||
	HNS_ROCE_QP_CAP_SQ_RECORD_DB = BIT(1),
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
enum {
 | 
			
		||||
| 
						 | 
				
			
			@ -623,8 +623,7 @@ struct hns_roce_qp {
 | 
			
		|||
	struct hns_roce_wq	rq;
 | 
			
		||||
	struct hns_roce_db	rdb;
 | 
			
		||||
	struct hns_roce_db	sdb;
 | 
			
		||||
	u8			rdb_en;
 | 
			
		||||
	u8			sdb_en;
 | 
			
		||||
	unsigned long		en_flags;
 | 
			
		||||
	u32			doorbell_qpn;
 | 
			
		||||
	u32			sq_signal_bits;
 | 
			
		||||
	struct hns_roce_wq	sq;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3619,7 +3619,7 @@ static void modify_qp_reset_to_init(struct ib_qp *ibqp,
 | 
			
		|||
	roce_set_field(context->byte_24_mtu_tc, V2_QPC_BYTE_24_VLAN_ID_M,
 | 
			
		||||
		       V2_QPC_BYTE_24_VLAN_ID_S, 0xfff);
 | 
			
		||||
 | 
			
		||||
	if (hr_qp->rdb_en)
 | 
			
		||||
	if (hr_qp->en_flags & HNS_ROCE_QP_CAP_RQ_RECORD_DB)
 | 
			
		||||
		roce_set_bit(context->byte_68_rq_db,
 | 
			
		||||
			     V2_QPC_BYTE_68_RQ_RECORD_EN_S, 1);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -750,8 +750,8 @@ static int alloc_qp_db(struct hns_roce_dev *hr_dev, struct hns_roce_qp *hr_qp,
 | 
			
		|||
					  "Failed to map user SQ doorbell\n");
 | 
			
		||||
				goto err_out;
 | 
			
		||||
			}
 | 
			
		||||
			hr_qp->sdb_en = 1;
 | 
			
		||||
			resp->cap_flags |= HNS_ROCE_SUPPORT_SQ_RECORD_DB;
 | 
			
		||||
			hr_qp->en_flags |= HNS_ROCE_QP_CAP_SQ_RECORD_DB;
 | 
			
		||||
			resp->cap_flags |= HNS_ROCE_QP_CAP_SQ_RECORD_DB;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if (user_qp_has_rdb(hr_dev, init_attr, udata, resp)) {
 | 
			
		||||
| 
						 | 
				
			
			@ -762,8 +762,8 @@ static int alloc_qp_db(struct hns_roce_dev *hr_dev, struct hns_roce_qp *hr_qp,
 | 
			
		|||
					  "Failed to map user RQ doorbell\n");
 | 
			
		||||
				goto err_sdb;
 | 
			
		||||
			}
 | 
			
		||||
			hr_qp->rdb_en = 1;
 | 
			
		||||
			resp->cap_flags |= HNS_ROCE_SUPPORT_RQ_RECORD_DB;
 | 
			
		||||
			hr_qp->en_flags |= HNS_ROCE_QP_CAP_RQ_RECORD_DB;
 | 
			
		||||
			resp->cap_flags |= HNS_ROCE_QP_CAP_RQ_RECORD_DB;
 | 
			
		||||
		}
 | 
			
		||||
	} else {
 | 
			
		||||
		/* QP doorbell register address */
 | 
			
		||||
| 
						 | 
				
			
			@ -780,13 +780,13 @@ static int alloc_qp_db(struct hns_roce_dev *hr_dev, struct hns_roce_qp *hr_qp,
 | 
			
		|||
				goto err_out;
 | 
			
		||||
			}
 | 
			
		||||
			*hr_qp->rdb.db_record = 0;
 | 
			
		||||
			hr_qp->rdb_en = 1;
 | 
			
		||||
			hr_qp->en_flags |= HNS_ROCE_QP_CAP_RQ_RECORD_DB;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return 0;
 | 
			
		||||
err_sdb:
 | 
			
		||||
	if (udata && hr_qp->sdb_en)
 | 
			
		||||
	if (udata && hr_qp->en_flags & HNS_ROCE_QP_CAP_SQ_RECORD_DB)
 | 
			
		||||
		hns_roce_db_unmap_user(uctx, &hr_qp->sdb);
 | 
			
		||||
err_out:
 | 
			
		||||
	return ret;
 | 
			
		||||
| 
						 | 
				
			
			@ -799,12 +799,12 @@ static void free_qp_db(struct hns_roce_dev *hr_dev, struct hns_roce_qp *hr_qp,
 | 
			
		|||
		udata, struct hns_roce_ucontext, ibucontext);
 | 
			
		||||
 | 
			
		||||
	if (udata) {
 | 
			
		||||
		if (hr_qp->rdb_en)
 | 
			
		||||
		if (hr_qp->en_flags & HNS_ROCE_QP_CAP_RQ_RECORD_DB)
 | 
			
		||||
			hns_roce_db_unmap_user(uctx, &hr_qp->rdb);
 | 
			
		||||
		if (hr_qp->sdb_en)
 | 
			
		||||
		if (hr_qp->en_flags & HNS_ROCE_QP_CAP_SQ_RECORD_DB)
 | 
			
		||||
			hns_roce_db_unmap_user(uctx, &hr_qp->sdb);
 | 
			
		||||
	} else {
 | 
			
		||||
		if (hr_qp->rdb_en)
 | 
			
		||||
		if (hr_qp->en_flags & HNS_ROCE_QP_CAP_RQ_RECORD_DB)
 | 
			
		||||
			hns_roce_free_db(hr_dev, &hr_qp->rdb);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1178,10 +1178,10 @@ int hns_roce_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
 | 
			
		|||
 | 
			
		||||
	if (ibqp->uobject &&
 | 
			
		||||
	    (attr_mask & IB_QP_STATE) && new_state == IB_QPS_ERR) {
 | 
			
		||||
		if (hr_qp->sdb_en == 1) {
 | 
			
		||||
		if (hr_qp->en_flags & HNS_ROCE_QP_CAP_SQ_RECORD_DB) {
 | 
			
		||||
			hr_qp->sq.head = *(int *)(hr_qp->sdb.virt_addr);
 | 
			
		||||
 | 
			
		||||
			if (hr_qp->rdb_en == 1)
 | 
			
		||||
			if (hr_qp->en_flags & HNS_ROCE_QP_CAP_RQ_RECORD_DB)
 | 
			
		||||
				hr_qp->rq.head = *(int *)(hr_qp->rdb.virt_addr);
 | 
			
		||||
		} else {
 | 
			
		||||
			ibdev_warn(&hr_dev->ib_dev,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue