提交 c867bd26 编写于 作者: Y Yixian Liu 提交者: Xie XiuQi

RDMA/hns: Add interface to config lock free

driver inclusion
category: bugfix
bugzilla: NA
CVE: NA

In some scenarios, upper application can ensure that there is
no concurrency when processing io, thus lock free can be used
to improve performance.

Feature or Bugfix:Bugfix
Signed-off-by: NYixian Liu <liuyixian@huawei.com>
Reviewed-by: Nwangxi <wangxi11@huawei.com>
Reviewed-by: Noulijun <oulijun@huawei.com>
Reviewed-by: NYang Yingliang <yangyingliang@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 21b29899
...@@ -53,6 +53,35 @@ ...@@ -53,6 +53,35 @@
static int loopback; static int loopback;
static int is_d; static int is_d;
static bool qp_lock = true;
static bool cq_lock = true;
static inline void v2_spin_lock_irqsave(bool has_lock, spinlock_t *lock,
unsigned long *flags)
{
if (likely(has_lock))
spin_lock_irqsave(lock, *flags);
}
static inline void v2_spin_unlock_irqrestore(bool has_lock, spinlock_t *lock,
unsigned long *flags)
{
if (likely(has_lock))
spin_unlock_irqrestore(lock, *flags);
}
static inline void v2_spin_lock_irq(bool has_lock, spinlock_t *lock)
{
if (likely(has_lock))
spin_lock_irq(lock);
}
static inline void v2_spin_unlock_irq(bool has_lock, spinlock_t *lock)
{
if (likely(has_lock))
spin_unlock_irq(lock);
}
static void set_data_seg_v2(struct hns_roce_v2_wqe_data_seg *dseg, static void set_data_seg_v2(struct hns_roce_v2_wqe_data_seg *dseg,
struct ib_sge *sg) struct ib_sge *sg)
{ {
...@@ -269,7 +298,7 @@ static int hns_roce_v2_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, ...@@ -269,7 +298,7 @@ static int hns_roce_v2_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
struct hns_roce_v2_db sq_db; struct hns_roce_v2_db sq_db;
unsigned int sge_ind; unsigned int sge_ind;
unsigned int owner_bit; unsigned int owner_bit;
unsigned long flags; unsigned long flags = 0;
unsigned int ind; unsigned int ind;
void *wqe = NULL; void *wqe = NULL;
u32 tmp_len; u32 tmp_len;
...@@ -298,7 +327,7 @@ static int hns_roce_v2_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, ...@@ -298,7 +327,7 @@ static int hns_roce_v2_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
return -EINVAL; return -EINVAL;
} }
spin_lock_irqsave(&qp->sq.lock, flags); v2_spin_lock_irqsave(qp_lock, &qp->sq.lock, &flags);
ind = qp->sq_next_wqe; ind = qp->sq_next_wqe;
sge_ind = qp->next_sge; sge_ind = qp->next_sge;
rdfx_func_cnt(hr_dev, RDFX_FUNC_POST_SEND); rdfx_func_cnt(hr_dev, RDFX_FUNC_POST_SEND);
...@@ -601,7 +630,8 @@ static int hns_roce_v2_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, ...@@ -601,7 +630,8 @@ static int hns_roce_v2_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
} else { } else {
dev_err(dev, "Illegal qp(0x%x) type:0x%x\n", dev_err(dev, "Illegal qp(0x%x) type:0x%x\n",
ibqp->qp_num, ibqp->qp_type); ibqp->qp_num, ibqp->qp_type);
spin_unlock_irqrestore(&qp->sq.lock, flags); v2_spin_unlock_irqrestore(qp_lock, &qp->sq.lock,
&flags);
*bad_wr = wr; *bad_wr = wr;
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
...@@ -638,7 +668,7 @@ static int hns_roce_v2_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, ...@@ -638,7 +668,7 @@ static int hns_roce_v2_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
rdfx_put_rdfx_qp(hr_dev, ibqp->qp_num); rdfx_put_rdfx_qp(hr_dev, ibqp->qp_num);
qp->dfx_cnt[HNS_ROCE_QP_DFX_POST_SEND]++; qp->dfx_cnt[HNS_ROCE_QP_DFX_POST_SEND]++;
spin_unlock_irqrestore(&qp->sq.lock, flags); v2_spin_unlock_irqrestore(qp_lock, &qp->sq.lock, &flags);
return ret; return ret;
} }
...@@ -657,18 +687,18 @@ static int hns_roce_v2_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr, ...@@ -657,18 +687,18 @@ static int hns_roce_v2_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr,
struct hns_roce_v2_wqe_data_seg *dseg; struct hns_roce_v2_wqe_data_seg *dseg;
struct hns_roce_rinl_sge *sge_list; struct hns_roce_rinl_sge *sge_list;
struct device *dev = hr_dev->dev; struct device *dev = hr_dev->dev;
unsigned long flags; unsigned long flags = 0;
void *wqe = NULL; void *wqe = NULL;
int ret = 0; int ret = 0;
int nreq; int nreq;
int ind; int ind;
int i; int i;
spin_lock_irqsave(&hr_qp->rq.lock, flags); v2_spin_lock_irqsave(qp_lock, &hr_qp->rq.lock, &flags);
ind = hr_qp->rq.head & (hr_qp->rq.wqe_cnt - 1); ind = hr_qp->rq.head & (hr_qp->rq.wqe_cnt - 1);
if (hr_qp->state == IB_QPS_RESET) { if (hr_qp->state == IB_QPS_RESET) {
spin_unlock_irqrestore(&hr_qp->rq.lock, flags); v2_spin_unlock_irqrestore(qp_lock, &hr_qp->rq.lock, &flags);
*bad_wr = wr; *bad_wr = wr;
return -EINVAL; return -EINVAL;
} }
...@@ -742,7 +772,7 @@ static int hns_roce_v2_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr, ...@@ -742,7 +772,7 @@ static int hns_roce_v2_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr,
rdfx_put_rdfx_qp(hr_dev, hr_qp->qpn); rdfx_put_rdfx_qp(hr_dev, hr_qp->qpn);
hr_qp->dfx_cnt[HNS_ROCE_QP_DFX_POST_RECV]++; hr_qp->dfx_cnt[HNS_ROCE_QP_DFX_POST_RECV]++;
spin_unlock_irqrestore(&hr_qp->rq.lock, flags); v2_spin_unlock_irqrestore(qp_lock, &hr_qp->rq.lock, &flags);
return ret; return ret;
} }
...@@ -2760,9 +2790,9 @@ static void __hns_roce_v2_cq_clean(struct hns_roce_cq *hr_cq, u32 qpn, ...@@ -2760,9 +2790,9 @@ static void __hns_roce_v2_cq_clean(struct hns_roce_cq *hr_cq, u32 qpn,
static void hns_roce_v2_cq_clean(struct hns_roce_cq *hr_cq, u32 qpn, static void hns_roce_v2_cq_clean(struct hns_roce_cq *hr_cq, u32 qpn,
struct hns_roce_srq *srq) struct hns_roce_srq *srq)
{ {
spin_lock_irq(&hr_cq->lock); v2_spin_lock_irq(cq_lock, &hr_cq->lock);
__hns_roce_v2_cq_clean(hr_cq, qpn, srq); __hns_roce_v2_cq_clean(hr_cq, qpn, srq);
spin_unlock_irq(&hr_cq->lock); v2_spin_unlock_irq(cq_lock, &hr_cq->lock);
} }
static void hns_roce_v2_write_cqc(struct hns_roce_dev *hr_dev, static void hns_roce_v2_write_cqc(struct hns_roce_dev *hr_dev,
...@@ -3204,10 +3234,10 @@ static int hns_roce_v2_poll_cq(struct ib_cq *ibcq, int num_entries, ...@@ -3204,10 +3234,10 @@ static int hns_roce_v2_poll_cq(struct ib_cq *ibcq, int num_entries,
{ {
struct hns_roce_cq *hr_cq = to_hr_cq(ibcq); struct hns_roce_cq *hr_cq = to_hr_cq(ibcq);
struct hns_roce_qp *cur_qp = NULL; struct hns_roce_qp *cur_qp = NULL;
unsigned long flags; unsigned long flags = 0;
int npolled; int npolled;
spin_lock_irqsave(&hr_cq->lock, flags); v2_spin_lock_irqsave(cq_lock, &hr_cq->lock, &flags);
rdfx_func_cnt(to_hr_dev(ibcq->device), RDFX_FUNC_POLL_CQ); rdfx_func_cnt(to_hr_dev(ibcq->device), RDFX_FUNC_POLL_CQ);
rdfx_get_rdfx_cq(to_hr_dev(ibcq->device), hr_cq->cqn); rdfx_get_rdfx_cq(to_hr_dev(ibcq->device), hr_cq->cqn);
...@@ -3233,7 +3263,7 @@ static int hns_roce_v2_poll_cq(struct ib_cq *ibcq, int num_entries, ...@@ -3233,7 +3263,7 @@ static int hns_roce_v2_poll_cq(struct ib_cq *ibcq, int num_entries,
rdfx_set_rdfx_cq_ci(to_hr_dev(ibcq->device), hr_cq); rdfx_set_rdfx_cq_ci(to_hr_dev(ibcq->device), hr_cq);
rdfx_put_rdfx_cq(to_hr_dev(ibcq->device), hr_cq->cqn); rdfx_put_rdfx_cq(to_hr_dev(ibcq->device), hr_cq->cqn);
spin_unlock_irqrestore(&hr_cq->lock, flags); v2_spin_unlock_irqrestore(cq_lock, &hr_cq->lock, &flags);
return npolled; return npolled;
} }
...@@ -5054,6 +5084,7 @@ static int hns_roce_v2_destroy_qp_common(struct hns_roce_dev *hr_dev, ...@@ -5054,6 +5084,7 @@ static int hns_roce_v2_destroy_qp_common(struct hns_roce_dev *hr_dev,
hns_roce_get_cqs(&hr_qp->ibqp, &send_cq, &recv_cq); hns_roce_get_cqs(&hr_qp->ibqp, &send_cq, &recv_cq);
if (cq_lock)
hns_roce_lock_cqs(send_cq, recv_cq); hns_roce_lock_cqs(send_cq, recv_cq);
if (!is_user) { if (!is_user) {
...@@ -5065,6 +5096,7 @@ static int hns_roce_v2_destroy_qp_common(struct hns_roce_dev *hr_dev, ...@@ -5065,6 +5096,7 @@ static int hns_roce_v2_destroy_qp_common(struct hns_roce_dev *hr_dev,
hns_roce_qp_remove(hr_dev, hr_qp); hns_roce_qp_remove(hr_dev, hr_qp);
if (cq_lock)
hns_roce_unlock_cqs(send_cq, recv_cq); hns_roce_unlock_cqs(send_cq, recv_cq);
hns_roce_qp_free(hr_dev, hr_qp); hns_roce_qp_free(hr_dev, hr_qp);
...@@ -7163,3 +7195,7 @@ module_param(loopback, int, 0444); ...@@ -7163,3 +7195,7 @@ module_param(loopback, int, 0444);
MODULE_PARM_DESC(loopback, "default: 0"); MODULE_PARM_DESC(loopback, "default: 0");
module_param(is_d, int, 0444); module_param(is_d, int, 0444);
MODULE_PARM_DESC(is_d, "default: 0"); MODULE_PARM_DESC(is_d, "default: 0");
module_param(qp_lock, bool, 0444);
MODULE_PARM_DESC(qp_lock, "default: true");
module_param(cq_lock, bool, 0444);
MODULE_PARM_DESC(cq_lock, "default: true");
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册