From patchwork Thu Sep 15 14:14:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuval Shaia X-Patchwork-Id: 9333745 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 ABE94607FD for ; Thu, 15 Sep 2016 14:14:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 97046297E2 for ; Thu, 15 Sep 2016 14:14:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8B8E3297E7; Thu, 15 Sep 2016 14:14:42 +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, UNPARSEABLE_RELAY 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 BB590297E2 for ; Thu, 15 Sep 2016 14:14:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933120AbcIOOOb (ORCPT ); Thu, 15 Sep 2016 10:14:31 -0400 Received: from userp1040.oracle.com ([156.151.31.81]:40041 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752318AbcIOOO2 (ORCPT ); Thu, 15 Sep 2016 10:14:28 -0400 Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u8FEEQlh025354 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 15 Sep 2016 14:14:26 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0021.oracle.com (8.13.8/8.13.8) with ESMTP id u8FEEPUs007735 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 15 Sep 2016 14:14:26 GMT Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by aserv0121.oracle.com (8.13.8/8.13.8) with ESMTP id u8FEENLf027588; Thu, 15 Sep 2016 14:14:24 GMT Received: from yuval-net-srv-ca.us.oracle.com (/10.211.3.188) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 15 Sep 2016 07:14:23 -0700 From: Yuval Shaia To: sean.hefty@intel.com, linux-rdma@vger.kernel.org Subject: [PATCH] ibacm: Handle EP expiration time Date: Thu, 15 Sep 2016 07:14:22 -0700 Message-Id: <1473948862-7461-1-git-send-email-yuval.shaia@oracle.com> X-Mailer: git-send-email 1.7.1 X-Source-IP: userv0021.oracle.com [156.151.31.71] 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 Old destination records are removed from EP's dest_map after timeout is expired in order to maintain a correct cache. Signed-off-by: Yuval Shaia --- prov/acmp/src/acmp.c | 34 +++++++++++++++++++++++++--------- 1 files changed, 25 insertions(+), 9 deletions(-) diff --git a/prov/acmp/src/acmp.c b/prov/acmp/src/acmp.c index ec64631..607c97f 100644 --- a/prov/acmp/src/acmp.c +++ b/prov/acmp/src/acmp.c @@ -356,6 +356,22 @@ acmp_put_dest(struct acmp_dest *dest) } } +/* Caller must hold ep lock. */ +static void +acmp_remove_dest(struct acmp_ep *ep, struct acmp_dest *dest) +{ + acm_log(2, "%s\n", dest->name); + tdelete(dest->address, &ep->dest_map[dest->addr_type - 1], + acmp_compare_dest); + acmp_put_dest(dest); +} + +static inline is_dest_ready(struct acmp_dest *dest) +{ + return dest->state == ACMP_READY && + dest->addr_timeout != 0xFFFFFFFFFFFFFFFF; +} + static struct acmp_dest * acmp_acquire_dest(struct acmp_ep *ep, uint8_t addr_type, const uint8_t *addr) { @@ -366,6 +382,15 @@ acmp_acquire_dest(struct acmp_ep *ep, uint8_t addr_type, const uint8_t *addr) acm_log(2, "%s\n", log_data); lock_acquire(&ep->lock); dest = acmp_get_dest(ep, addr_type, addr); + if (dest && is_dest_ready(dest)) { + acm_log(2, "Record valid for the next %ld minute(s)\n", + dest->addr_timeout - time_stamp_min()); + if (time_stamp_min() >= dest->addr_timeout) { + acm_log(2, "Record expiered\n"); + acmp_remove_dest(ep, dest); + dest = 0; + } + } if (!dest) { dest = acmp_alloc_dest(addr_type, addr); if (dest) { @@ -378,15 +403,6 @@ acmp_acquire_dest(struct acmp_ep *ep, uint8_t addr_type, const uint8_t *addr) return dest; } -/* Caller must hold ep lock. */ -//static void -//acmp_remove_dest(struct acmp_ep *ep, struct acmp_dest *dest) -//{ -// acm_log(2, "%s\n", dest->name); -// tdelete(dest->address, &ep->dest_map[dest->addr_type - 1], acmp_compare_dest); -// acmp_put_dest(dest); -//} - static struct acmp_request *acmp_alloc_req(uint64_t id, struct acm_msg *msg) { struct acmp_request *req;