From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 24755A04C2; Mon, 25 Nov 2019 12:36:14 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id CA5405B3E; Mon, 25 Nov 2019 12:35:54 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by dpdk.org (Postfix) with ESMTP id 07E864CA6 for ; Mon, 25 Nov 2019 12:35:50 +0100 (CET) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id xAPBYf3k003169 for ; Mon, 25 Nov 2019 03:35:50 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=pfpt0818; bh=RO8TFtEPzykTibChLvF/h5Lsm6bkBfjSFuRdQJblZrE=; b=YZP4e8AiRUpgKK6C6fqY3R5OpvVnoN8eAk+SCV8dXwgR/s/mdsMb6JbaunegXemRLySf W0H2xs82JaDB6J5GprE8VqOaSPoEplsAWq+ljn48Yg5aIIQ+XpySH3YVEbgDwRmOffOY 5q+7cBzOdrznnZDmR8udkX7XHtJhuaY3kK5ogPYeTQPOBLP6FeFrpWjjmitCzg4MI6C8 Ng9tiWLTbnZ9+9ZH/ZWoxvpZcjKyuLtAADDrrybBD9BoabOmg/UgF4Kre+KnAYFZZgqu 6vQ+11HVRVULDqmEEgTOLUmgCb3KUWxKhFema30bfdEwZy6797ZsojWe4+8K/dXZ5OFF OQ== Received: from sc-exch02.marvell.com ([199.233.58.182]) by mx0b-0016f401.pphosted.com with ESMTP id 2wg3kshs1n-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Mon, 25 Nov 2019 03:35:50 -0800 Received: from SC-EXCH03.marvell.com (10.93.176.83) by SC-EXCH02.marvell.com (10.93.176.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 25 Nov 2019 03:35:49 -0800 Received: from maili.marvell.com (10.93.176.43) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Mon, 25 Nov 2019 03:35:49 -0800 Received: from localhost.localdomain (unknown [10.28.34.200]) by maili.marvell.com (Postfix) with ESMTP id BE3123F7040; Mon, 25 Nov 2019 03:35:47 -0800 (PST) From: Sunil Kumar Kori To: Jerin Jacob , Nithin Dabilpuram , Vamsi Attunuru CC: , Sunil Kumar Kori Date: Mon, 25 Nov 2019 17:05:36 +0530 Message-ID: <20191125113537.25266-4-skori@marvell.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191125113537.25266-1-skori@marvell.com> References: <20191125113537.25266-1-skori@marvell.com> MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,18.0.572 definitions=2019-11-25_03:2019-11-21,2019-11-25 signatures=0 Subject: [dpdk-dev] [PATCH 4/5] common/octeontx2: add polling based response mbox message X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Currently otx2_mbox_get_rsp get response once AF driver interrupts after completion. But this funciton will get into deadlock if called in another interrupt context. To avoid it, implemented another version of this function which polls on dedicated memory for a given timeout. Also after clearing interrupt, there could UP messages available for processing. So irq handler must check mbox messages. Signed-off-by: Sunil Kumar Kori --- drivers/common/octeontx2/otx2_mbox.c | 58 +++++++++++++++++++ drivers/common/octeontx2/otx2_mbox.h | 7 +++ .../rte_common_octeontx2_version.map | 7 +++ 3 files changed, 72 insertions(+) diff --git a/drivers/common/octeontx2/otx2_mbox.c b/drivers/common/octeontx2/otx2_mbox.c index ad8e0c3aa..af34fd19d 100644 --- a/drivers/common/octeontx2/otx2_mbox.c +++ b/drivers/common/octeontx2/otx2_mbox.c @@ -11,6 +11,7 @@ #include #include "otx2_mbox.h" +#include "otx2_dev.h" #define RVU_AF_AFPF_MBOX0 (0x02000) #define RVU_AF_AFPF_MBOX1 (0x02008) @@ -245,6 +246,63 @@ otx2_mbox_get_rsp(struct otx2_mbox *mbox, int devid, void **msg) return msghdr->rc; } +/** + * @internal + * Polling for given wait time to get mailbox response + */ +int +otx2_mbox_get_rsp_poll_tmo(struct otx2_mbox *mbox, int devid, void **msg, + uint32_t wait) +{ + struct otx2_mbox_dev *mdev = &mbox->dev[devid]; + uint32_t timeout = 0, sleep = 1; + struct mbox_msghdr *msghdr; + uint64_t rsp_reg = 0; + uintptr_t reg_addr; + uint64_t offset; + + rte_rmb(); + + offset = mbox->rx_start + + RTE_ALIGN(sizeof(struct mbox_hdr), MBOX_MSG_ALIGN); + msghdr = (struct mbox_msghdr *)((uintptr_t)mdev->mbase + offset); + + reg_addr = mbox->reg_base + mbox->intr_offset; + while (!rsp_reg) { + rte_rmb(); + rsp_reg = otx2_read64(reg_addr); + + if (timeout >= wait) + return -ETIMEDOUT; + + rte_delay_ms(sleep); + timeout += sleep; + } + + if (msg != NULL) + *msg = msghdr; + + /* Clear interrupt */ + otx2_write64(rsp_reg, reg_addr); + + /* Reset mbox */ + otx2_mbox_reset(mbox, 0); + + return msghdr->rc; +} + +/** + * @internal + * Polling for 5 seconds to get mailbox response + */ +int +otx2_mbox_get_rsp_poll(struct otx2_mbox *mbox, int devid, void **msg) +{ + uint32_t wait = 5 * MS_PER_S; /* 5 Seconds */ + + return otx2_mbox_get_rsp_poll_tmo(mbox, devid, msg, wait); +} + /** * @internal * Wait and get mailbox response with timeout diff --git a/drivers/common/octeontx2/otx2_mbox.h b/drivers/common/octeontx2/otx2_mbox.h index 162d12468..237d4cf45 100644 --- a/drivers/common/octeontx2/otx2_mbox.h +++ b/drivers/common/octeontx2/otx2_mbox.h @@ -1570,6 +1570,13 @@ void otx2_mbox_msg_send(struct otx2_mbox *mbox, int devid); int otx2_mbox_wait_for_rsp(struct otx2_mbox *mbox, int devid); int otx2_mbox_wait_for_rsp_tmo(struct otx2_mbox *mbox, int devid, uint32_t tmo); int otx2_mbox_get_rsp(struct otx2_mbox *mbox, int devid, void **msg); + +__rte_experimental +int otx2_mbox_get_rsp_poll(struct otx2_mbox *mbox, int devid, void **msg); +__rte_experimental +int otx2_mbox_get_rsp_poll_tmo(struct otx2_mbox *mbox, int devid, void **msg, + uint32_t tmo); + int otx2_mbox_get_rsp_tmo(struct otx2_mbox *mbox, int devid, void **msg, uint32_t tmo); int otx2_mbox_get_availmem(struct otx2_mbox *mbox, int devid); diff --git a/drivers/common/octeontx2/rte_common_octeontx2_version.map b/drivers/common/octeontx2/rte_common_octeontx2_version.map index adad21a2d..dcbca2444 100644 --- a/drivers/common/octeontx2/rte_common_octeontx2_version.map +++ b/drivers/common/octeontx2/rte_common_octeontx2_version.map @@ -33,3 +33,10 @@ DPDK_20.0 { local: *; }; + +EXPERIMENTAL { + global: + + otx2_mbox_get_rsp_poll; + otx2_mbox_get_rsp_poll_tmo; +}; -- 2.17.1