From patchwork Thu Sep 17 10:38:02 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Or Gerlitz X-Patchwork-Id: 7205961 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id EE3999F39B for ; Thu, 17 Sep 2015 10:38:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0BF0C207D1 for ; Thu, 17 Sep 2015 10:38:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E6676207D7 for ; Thu, 17 Sep 2015 10:38:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751813AbbIQKi1 (ORCPT ); Thu, 17 Sep 2015 06:38:27 -0400 Received: from [193.47.165.129] ([193.47.165.129]:55556 "EHLO mellanox.co.il" rhost-flags-FAIL-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1751812AbbIQKiZ (ORCPT ); Thu, 17 Sep 2015 06:38:25 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from ogerlitz@mellanox.com) with ESMTPS (AES256-SHA encrypted); 17 Sep 2015 13:38:15 +0300 Received: from r-vnc04.mtr.labs.mlnx (r-vnc04.mtr.labs.mlnx [10.208.0.116]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id t8HAc5cS021826; Thu, 17 Sep 2015 13:38:05 +0300 From: Or Gerlitz To: Doug Ledford Cc: linux-rdma@vger.kernel.org, Christoph Lameter , Erez Shitrit , Or Gerlitz Subject: [PATCH rdma-rc 1/2] IB/ipoib: Add mechanism for ipoib neigh state change notifications Date: Thu, 17 Sep 2015 13:38:02 +0300 Message-Id: <1442486283-9699-2-git-send-email-ogerlitz@mellanox.com> X-Mailer: git-send-email 1.7.8.2 In-Reply-To: <1442486283-9699-1-git-send-email-ogerlitz@mellanox.com> References: <1442486283-9699-1-git-send-email-ogerlitz@mellanox.com> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Erez Shitrit Add callback function to the ipoib_neigh struct in order to add the ability to inform the object that holds the neigh on its current state. Each neigh object is kept by one and only one object (from type path_record or multicast object), now this object can act accordingly the change in the neigh state. The callback should pay attention to the context it runs on, and should act/run according to that context limitation, for example on the neigh reap flow, the neigh calls the callback under spinlock etc. Signed-off-by: Erez Shitrit Signed-off-by: Or Gerlitz --- drivers/infiniband/ulp/ipoib/ipoib.h | 11 +++++++++++ drivers/infiniband/ulp/ipoib/ipoib_main.c | 4 ++++ 2 files changed, 15 insertions(+) diff --git a/drivers/infiniband/ulp/ipoib/ipoib.h b/drivers/infiniband/ulp/ipoib/ipoib.h index ca28736..5b719e2 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib.h +++ b/drivers/infiniband/ulp/ipoib/ipoib.h @@ -417,6 +417,14 @@ struct ipoib_path { int valid; }; +enum ipoib_neigh_state { + IPOIB_NEIGH_CREATED, + IPOIB_NEIGH_REMOVED, +}; + +typedef int (*state_callback_fn)(struct ipoib_dev_priv *priv, + enum ipoib_neigh_state state, void *context); + struct ipoib_neigh { struct ipoib_ah *ah; #ifdef CONFIG_INFINIBAND_IPOIB_CM @@ -432,6 +440,9 @@ struct ipoib_neigh { struct rcu_head rcu; atomic_t refcnt; unsigned long alive; + /* add the ability to notify the objects that hold that neigh */ + state_callback_fn state_callback; + void *context; }; #define IPOIB_UD_MTU(ib_mtu) (ib_mtu - IPOIB_ENCAP_LEN) diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c index 36536ce..6176441 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_main.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c @@ -1179,6 +1179,10 @@ static void __ipoib_reap_neigh(struct ipoib_dev_priv *priv) rcu_assign_pointer(*np, rcu_dereference_protected(neigh->hnext, lockdep_is_held(&priv->lock))); + /* inform state if requested */ + if (neigh->state_callback != NULL) + neigh->state_callback(priv, IPOIB_NEIGH_REMOVED, neigh->context); + /* remove from path/mc list */ list_del(&neigh->list); call_rcu(&neigh->rcu, ipoib_neigh_reclaim);