Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1c36cf91 authored by Parav Pandit's avatar Parav Pandit Committed by Jason Gunthorpe
Browse files

IB/core: Store default GID property per-table instead of per-entry



There are at max one or two default GIDs for RoCE. Instead of storing
a default GID property for all the GIDs, store default GID indices as
individual bit per table.

This allows a future simplification to get rid of the GID property field.

Signed-off-by: default avatarParav Pandit <parav@mellanox.com>
Signed-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent a1a4caee
Loading
Loading
Loading
Loading
+24 −13
Original line number Original line Diff line number Diff line
@@ -68,7 +68,6 @@ enum gid_attr_find_mask {


enum gid_table_entry_props {
enum gid_table_entry_props {
	GID_TABLE_ENTRY_INVALID		= 1UL << 0,
	GID_TABLE_ENTRY_INVALID		= 1UL << 0,
	GID_TABLE_ENTRY_DEFAULT		= 1UL << 1,
};
};


struct ib_gid_table_entry {
struct ib_gid_table_entry {
@@ -97,6 +96,8 @@ struct ib_gid_table {
	struct mutex			lock;
	struct mutex			lock;
	/* rwlock protects data_vec[ix]->props. */
	/* rwlock protects data_vec[ix]->props. */
	rwlock_t			rwlock;
	rwlock_t			rwlock;
	/* bit field, each bit indicates the index of default GID */
	u32				default_gid_indices;
	struct ib_gid_table_entry	*data_vec;
	struct ib_gid_table_entry	*data_vec;
};
};


@@ -135,6 +136,19 @@ bool rdma_is_zero_gid(const union ib_gid *gid)
}
}
EXPORT_SYMBOL(rdma_is_zero_gid);
EXPORT_SYMBOL(rdma_is_zero_gid);


/** is_gid_index_default - Check if a given index belongs to
 * reserved default GIDs or not.
 * @table:	GID table pointer
 * @index:	Index to check in GID table
 * Returns true if index is one of the reserved default GID index otherwise
 * returns false.
 */
static bool is_gid_index_default(const struct ib_gid_table *table,
				 unsigned int index)
{
	return index < 32 && (BIT(index) & table->default_gid_indices);
}

int ib_cache_gid_parse_type_str(const char *buf)
int ib_cache_gid_parse_type_str(const char *buf)
{
{
	unsigned int i;
	unsigned int i;
@@ -308,7 +322,7 @@ static int find_gid(struct ib_gid_table *table, const union ib_gid *gid,
		if (pempty && empty < 0) {
		if (pempty && empty < 0) {
			if (data->props & GID_TABLE_ENTRY_INVALID &&
			if (data->props & GID_TABLE_ENTRY_INVALID &&
			    (default_gid ==
			    (default_gid ==
			     !!(data->props & GID_TABLE_ENTRY_DEFAULT))) {
				is_gid_index_default(table, curr_index))) {
				/*
				/*
				 * Found an invalid (free) entry; allocate it.
				 * Found an invalid (free) entry; allocate it.
				 * If default GID is requested, then our
				 * If default GID is requested, then our
@@ -346,8 +360,7 @@ static int find_gid(struct ib_gid_table *table, const union ib_gid *gid,
			continue;
			continue;


		if (mask & GID_ATTR_FIND_MASK_DEFAULT &&
		if (mask & GID_ATTR_FIND_MASK_DEFAULT &&
		    !!(data->props & GID_TABLE_ENTRY_DEFAULT) !=
		    is_gid_index_default(table, curr_index) != default_gid)
		    default_gid)
			continue;
			continue;


		found = curr_index;
		found = curr_index;
@@ -795,11 +808,9 @@ static void gid_table_reserve_default(struct ib_device *ib_dev, u8 port,


	roce_gid_type_mask = roce_gid_type_mask_support(ib_dev, port);
	roce_gid_type_mask = roce_gid_type_mask_support(ib_dev, port);
	num_default_gids = hweight_long(roce_gid_type_mask);
	num_default_gids = hweight_long(roce_gid_type_mask);
	for (i = 0; i < num_default_gids && i < table->sz; i++) {
	/* Reserve starting indices for default GIDs */
		struct ib_gid_table_entry *entry = &table->data_vec[i];
	for (i = 0; i < num_default_gids && i < table->sz; i++)

		table->default_gid_indices |= BIT(i);
		entry->props |= GID_TABLE_ENTRY_DEFAULT;
	}
}
}