From patchwork Thu Apr 27 06:11:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Amrani, Ram" X-Patchwork-Id: 9702401 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 91F37601D3 for ; Thu, 27 Apr 2017 06:11:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 824EF285EA for ; Thu, 27 Apr 2017 06:11:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7767A285F3; Thu, 27 Apr 2017 06:11:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 22E60285EA for ; Thu, 27 Apr 2017 06:11:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933099AbdD0GLo (ORCPT ); Thu, 27 Apr 2017 02:11:44 -0400 Received: from mx0b-0016ce01.pphosted.com ([67.231.156.153]:36282 "EHLO mx0b-0016ce01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932866AbdD0GLn (ORCPT ); Thu, 27 Apr 2017 02:11:43 -0400 Received: from pps.filterd (m0085408.ppops.net [127.0.0.1]) by mx0b-0016ce01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v3R680vn015222; Wed, 26 Apr 2017 23:11:36 -0700 Received: from avcashub1.qlogic.com ([198.186.0.116]) by mx0b-0016ce01.pphosted.com with ESMTP id 2a3ahu0233-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Wed, 26 Apr 2017 23:11:36 -0700 Received: from lb-tlvb-ramrani.il.qlogic.org (10.185.6.119) by qlc.com (10.1.4.191) with Microsoft SMTP Server id 14.3.235.1; Wed, 26 Apr 2017 23:11:36 -0700 From: Ram Amrani To: , , CC: , , , Ram Amrani Subject: [rdma-core 2/4] libqedr: fail post_send on WR overflow Date: Thu, 27 Apr 2017 09:11:06 +0300 Message-ID: <1493273468-23774-3-git-send-email-Ram.Amrani@cavium.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1493273468-23774-1-git-send-email-Ram.Amrani@cavium.com> References: <1493273468-23774-1-git-send-email-Ram.Amrani@cavium.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5800 definitions=8510 signatures=668453 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1703280000 definitions=main-1704270101 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Post send will fail if it is full, thus preventing an overflow. Signed-off-by: Ram Amrani --- providers/qedr/qelr_verbs.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/providers/qedr/qelr_verbs.c b/providers/qedr/qelr_verbs.c index 8d94a12..7419540 100644 --- a/providers/qedr/qelr_verbs.c +++ b/providers/qedr/qelr_verbs.c @@ -70,6 +70,11 @@ static void qelr_inc_sw_prod_u16(struct qelr_qp_hwq_info *info) info->prod = (info->prod + 1) % info->max_wr; } +static inline int qelr_wq_is_full(struct qelr_qp_hwq_info *info) +{ + return (((info->prod + 1) % info->max_wr) == info->cons); +} + int qelr_query_device(struct ibv_context *context, struct ibv_device_attr *attr) { @@ -1144,6 +1149,14 @@ static inline int qelr_can_post_send(struct qelr_devctx *cxt, return -EINVAL; } + /* WR overflow */ + if (qelr_wq_is_full(&qp->sq)) { + DP_ERR(cxt->dbg_fp, + "error: WQ is full. Post send on QP %p failed (this error appears only once)\n", + qp); + return -ENOMEM; + } + /* WQE overflow */ if (qelr_chain_get_elem_left_u32(&qp->sq.chain) < QELR_MAX_SQ_WQE_SIZE) {