From patchwork Wed Nov 4 15:30:21 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yevgeny Petrilin X-Patchwork-Id: 57537 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id nA4CWhJd022135 for ; Wed, 4 Nov 2009 12:32:43 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755816AbZKDMcg (ORCPT ); Wed, 4 Nov 2009 07:32:36 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1755815AbZKDMcg (ORCPT ); Wed, 4 Nov 2009 07:32:36 -0500 Received: from mail.mellanox.co.il ([194.90.237.43]:34541 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755816AbZKDMcf (ORCPT ); Wed, 4 Nov 2009 07:32:35 -0500 Received: from Internal Mail-Server by MTLPINE1 (envelope-from yevgenyp@mellanox.co.il) with SMTP; 4 Nov 2009 14:38:19 +0200 Received: from [10.4.12.75] ([10.4.12.75]) by mtlexch01.mtl.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 4 Nov 2009 14:32:39 +0200 Message-ID: <4AF19E0D.1030504@mellanox.co.il> Date: Wed, 04 Nov 2009 17:30:21 +0200 From: Yevgeny Petrilin User-Agent: Thunderbird 2.0.0.23 (X11/20090812) MIME-Version: 1.0 To: rdreier@cisco.com CC: linux-rdma@vger.kernel.org, netdev@vger.kernel.org, liranl@mellanox.co.il, tziporet@mellanox.co.il, yevgenyp@mellanox.co.il Subject: [PATCH 02/25] mlx4_core: add support for arbitrary bitmap sizes X-OriginalArrivalTime: 04 Nov 2009 12:32:39.0332 (UTC) FILETIME=[E587B640:01CA5D4A] Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org diff --git a/drivers/net/mlx4/alloc.c b/drivers/net/mlx4/alloc.c index ad95d5f..bc68cc3 100644 --- a/drivers/net/mlx4/alloc.c +++ b/drivers/net/mlx4/alloc.c @@ -177,6 +177,16 @@ int mlx4_bitmap_init(struct mlx4_bitmap *bitmap, u32 num, u32 mask, return 0; } +/* Like bitmap_init, but doesn't require 'num' to be a power of 2 or + * a non-trivial mask */ +int mlx4_bitmap_init_no_mask(struct mlx4_bitmap *bitmap, u32 num, + u32 reserved_bot, u32 reserved_top) +{ + u32 num_rounded = roundup_pow_of_two(num); + return mlx4_bitmap_init(bitmap, num_rounded, num_rounded - 1, + reserved_bot, num_rounded - num + reserved_top); +} + void mlx4_bitmap_cleanup(struct mlx4_bitmap *bitmap) { kfree(bitmap->table); diff --git a/drivers/net/mlx4/mlx4.h b/drivers/net/mlx4/mlx4.h index bc72d6e..5836c94 100644 --- a/drivers/net/mlx4/mlx4.h +++ b/drivers/net/mlx4/mlx4.h @@ -330,6 +330,8 @@ u32 mlx4_bitmap_alloc_range(struct mlx4_bitmap *bitmap, int cnt, int align); void mlx4_bitmap_free_range(struct mlx4_bitmap *bitmap, u32 obj, int cnt); int mlx4_bitmap_init(struct mlx4_bitmap *bitmap, u32 num, u32 mask, u32 reserved_bot, u32 resetrved_top); +int mlx4_bitmap_init_no_mask(struct mlx4_bitmap *bitmap, u32 num, + u32 reserved_bot, u32 reserved_top); void mlx4_bitmap_cleanup(struct mlx4_bitmap *bitmap); int mlx4_reset(struct mlx4_dev *dev);