Skip to contentSkip to conversation

mlx4_core: add support for arbitrary bitmap sizes

PATCH In review Yevgeny Petrilin 3 participants 3 messages Nov 6, 2009 – Feb 4, 2010 2 messages not in the archive

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 2/25 mlx4_core: add support for arbitrary bitmap sizes

From: Liran Liss <[email protected]>

---
 drivers/net/mlx4/alloc.c |   10 ++++++++++
 drivers/net/mlx4/mlx4.h  |    2 ++
 2 files changed, 12 insertions(+), 0 deletions(-)
drivers/net/mlx4/alloc.c +10 -0
index ad95d5f..bc68cc3 100644
@@ -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);
drivers/net/mlx4/mlx4.h +2 -0
index bc72d6e..5836c94 100644
@@ -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);
Signature · 1 line
1.5.3.7
#2 lore raw
In reply to a message not in the archive

drivers/net/mlx4/alloc.c int mlx4_bitmap_init(struct mlx4_bitmap *bitmap, u32 num, u32 mask, · line 188

Quoted 7 lines
drivers/net/mlx4/alloc.c +7 -0
+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);
+}

I think I would really prefer things if we got rid of this wrapper. The mlx4_bitmap stuff is really there to handle the case where we want to have a mask and have the non-used bits cycle to avoid reusing QPN etc. If we have a bitmap with no mask that's no a power of 2 in size, there's really no value in the mlx4 wrapper -- we might as well just allocate a bitmap directly.

And since this is only used in one place (for the EQ tables) I think it makes sense to just open-code everything in the EQ code.

- R.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#4 lore raw
In reply to a message not in the archive
Quoted 12 lines

drivers/net/mlx4/alloc.c int mlx4_bitmap_init(struct mlx4_bitmap *bitmap, u32 num, u32 mask, · line 188

Quoted 7 lines
drivers/net/mlx4/alloc.c +7 -0
+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);
+}

I think I would really prefer things if we got rid of this wrapper. The mlx4_bitmap stuff is really there to handle the case where we want to have a mask and have the non-used bits cycle to avoid reusing QPN etc.
If we have a bitmap with no mask that's no a power of 2 in size, there's really no value in the mlx4 wrapper -- we might as well just allocate a bitmap > directly.

Quoted 1 line

And since this is only used in one place (for the EQ tables) I think it makes sense to just open-code everything in the EQ code.

I am preparing a new set of patches for SRIOV support, this change will be included-- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html