From patchwork Wed Jun 4 08:52:45 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Selvin Xavier X-Patchwork-Id: 4292591 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 0260B9F333 for ; Wed, 4 Jun 2014 08:55:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3163520176 for ; Wed, 4 Jun 2014 08:55:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4A4302017E for ; Wed, 4 Jun 2014 08:55:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751830AbaFDIzj (ORCPT ); Wed, 4 Jun 2014 04:55:39 -0400 Received: from cmexedge1.ext.emulex.com ([138.239.224.99]:35800 "EHLO CMEXEDGE1.ext.emulex.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751662AbaFDIzi (ORCPT ); Wed, 4 Jun 2014 04:55:38 -0400 Received: from CMEXHTCAS1.ad.emulex.com (138.239.115.217) by CMEXEDGE1.ext.emulex.com (138.239.224.99) with Microsoft SMTP Server (TLS) id 14.3.174.1; Wed, 4 Jun 2014 01:56:28 -0700 Received: from localhost.localdomain (10.192.201.1) by smtp.emulex.com (138.239.115.207) with Microsoft SMTP Server id 14.3.174.1; Wed, 4 Jun 2014 01:55:34 -0700 From: Selvin Xavier To: CC: , Selvin Xavier , "Devesh Sharma" , Somnath Kotur Subject: [PATCH for-next 14/15] RDMA/ocrdma: Initialize the GID table while Date: Wed, 4 Jun 2014 14:22:45 +0530 X-Mailer: git-send-email 1.6.0.2 In-Reply-To: <1401871966-20408-14-git-send-email-selvin.xavier@emulex.com> References: <1401871966-20408-1-git-send-email-selvin.xavier@emulex.com> <1401871966-20408-2-git-send-email-selvin.xavier@emulex.com> <1401871966-20408-3-git-send-email-selvin.xavier@emulex.com> <1401871966-20408-4-git-send-email-selvin.xavier@emulex.com> <1401871966-20408-5-git-send-email-selvin.xavier@emulex.com> <1401871966-20408-6-git-send-email-selvin.xavier@emulex.com> <1401871966-20408-7-git-send-email-selvin.xavier@emulex.com> <1401871966-20408-8-git-send-email-selvin.xavier@emulex.com> <1401871966-20408-9-git-send-email-selvin.xavier@emulex.com> <1401871966-20408-10-git-send-email-selvin.xavier@emulex.com> <1401871966-20408-11-git-send-email-selvin.xavier@emulex.com> <1401871966-20408-12-git-send-email-selvin.xavier@emulex.com> <1401871966-20408-13-git-send-email-selvin.xavier@emulex.com> <1401871966-20408-14-git-send-email-selvin.xavier@emulex.com> MIME-Version: 1.0 Message-ID: <93ffe543-df92-432f-8f7e-05c34efb8950@CMEXHTCAS1.ad.emulex.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=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 Current GID table gets updated only at the time of inet notification. Fixing this by initializing the table at the time of device registration. Signed-off-by: Selvin Xavier Signed-off-by: Devesh Sharma Signed-off-by: Somnath Kotur --- drivers/infiniband/hw/ocrdma/ocrdma_main.c | 53 ++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_main.c b/drivers/infiniband/hw/ocrdma/ocrdma_main.c index 0d90c7f..256a06b 100644 --- a/drivers/infiniband/hw/ocrdma/ocrdma_main.c +++ b/drivers/infiniband/hw/ocrdma/ocrdma_main.c @@ -388,6 +388,58 @@ static void ocrdma_remove_sysfiles(struct ocrdma_dev *dev) device_remove_file(&dev->ibdev.dev, ocrdma_attributes[i]); } +static void ocrdma_init_ipv4_gids(struct ocrdma_dev *dev, + struct net_device *net) +{ + struct in_device *in_dev; + union ib_gid gid; + in_dev = in_dev_get(net); + if (in_dev) { + for_ifa(in_dev) { + ipv6_addr_set_v4mapped(ifa->ifa_address, + (struct in6_addr *)&gid); + ocrdma_add_sgid(dev, &gid); + } + endfor_ifa(in_dev); + in_dev_put(in_dev); + } +} + +static void ocrdma_init_ipv6_gids(struct ocrdma_dev *dev, + struct net_device *net) +{ +#if IS_ENABLED(CONFIG_IPV6) + struct inet6_dev *in6_dev; + union ib_gid *pgid; + struct inet6_ifaddr *ifp; + in6_dev = in6_dev_get(net); + if (in6_dev) { + read_lock_bh(&in6_dev->lock); + list_for_each_entry(ifp, &in6_dev->addr_list, if_list) { + pgid = (union ib_gid *)&ifp->addr; + ocrdma_add_sgid(dev, pgid); + } + read_unlock_bh(&in6_dev->lock); + in6_dev_put(in6_dev); + } +#endif +} + +static void ocrdma_init_gid_table(struct ocrdma_dev *dev) +{ + struct net_device *net_dev; + + for_each_netdev(&init_net, net_dev) { + struct net_device *real_dev = rdma_vlan_dev_real_dev(net_dev) ? + rdma_vlan_dev_real_dev(net_dev) : net_dev; + + if (real_dev == dev->nic_info.netdev) { + ocrdma_init_ipv4_gids(dev, net_dev); + ocrdma_init_ipv6_gids(dev, net_dev); + } + } +} + static struct ocrdma_dev *ocrdma_add(struct be_dev_info *dev_info) { int status = 0, i; @@ -416,6 +468,7 @@ static struct ocrdma_dev *ocrdma_add(struct be_dev_info *dev_info) goto alloc_err; ocrdma_init_service_level(dev); + ocrdma_init_gid_table(dev); status = ocrdma_register_device(dev); if (status) goto alloc_err;