diff options
author | Parav Pandit <parav@mellanox.com> | 2018-06-05 01:40:14 -0400 |
---|---|---|
committer | Jason Gunthorpe <jgg@mellanox.com> | 2018-06-18 00:32:04 -0400 |
commit | 1c36cf912ad19c99592c7d089aed5d1c321a678a (patch) | |
tree | b07f40f4ec6dda31729d245396032858531a7e80 /drivers/infiniband/core/cache.c | |
parent | a1a4caeebac95875eaf6c8afb5a9784566484b2e (diff) |
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: Parav Pandit <parav@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Diffstat (limited to 'drivers/infiniband/core/cache.c')
-rw-r--r-- | drivers/infiniband/core/cache.c | 37 |
1 files changed, 24 insertions, 13 deletions
diff --git a/drivers/infiniband/core/cache.c b/drivers/infiniband/core/cache.c index 0415548eb5f3..d4751f94a93a 100644 --- a/drivers/infiniband/core/cache.c +++ b/drivers/infiniband/core/cache.c | |||
@@ -68,7 +68,6 @@ enum gid_attr_find_mask { | |||
68 | 68 | ||
69 | enum gid_table_entry_props { | 69 | enum gid_table_entry_props { |
70 | GID_TABLE_ENTRY_INVALID = 1UL << 0, | 70 | GID_TABLE_ENTRY_INVALID = 1UL << 0, |
71 | GID_TABLE_ENTRY_DEFAULT = 1UL << 1, | ||
72 | }; | 71 | }; |
73 | 72 | ||
74 | struct ib_gid_table_entry { | 73 | struct ib_gid_table_entry { |
@@ -79,7 +78,7 @@ struct ib_gid_table_entry { | |||
79 | }; | 78 | }; |
80 | 79 | ||
81 | struct ib_gid_table { | 80 | struct ib_gid_table { |
82 | int sz; | 81 | int sz; |
83 | /* In RoCE, adding a GID to the table requires: | 82 | /* In RoCE, adding a GID to the table requires: |
84 | * (a) Find if this GID is already exists. | 83 | * (a) Find if this GID is already exists. |
85 | * (b) Find a free space. | 84 | * (b) Find a free space. |
@@ -94,10 +93,12 @@ struct ib_gid_table { | |||
94 | * rwlock. readers must hold only rwlock. All writers must be in a | 93 | * rwlock. readers must hold only rwlock. All writers must be in a |
95 | * sleepable context. | 94 | * sleepable context. |
96 | */ | 95 | */ |
97 | struct mutex lock; | 96 | struct mutex lock; |
98 | /* rwlock protects data_vec[ix]->props. */ | 97 | /* rwlock protects data_vec[ix]->props. */ |
99 | rwlock_t rwlock; | 98 | rwlock_t rwlock; |
100 | struct ib_gid_table_entry *data_vec; | 99 | /* bit field, each bit indicates the index of default GID */ |
100 | u32 default_gid_indices; | ||
101 | struct ib_gid_table_entry *data_vec; | ||
101 | }; | 102 | }; |
102 | 103 | ||
103 | static void dispatch_gid_change_event(struct ib_device *ib_dev, u8 port) | 104 | static void dispatch_gid_change_event(struct ib_device *ib_dev, u8 port) |
@@ -135,6 +136,19 @@ bool rdma_is_zero_gid(const union ib_gid *gid) | |||
135 | } | 136 | } |
136 | EXPORT_SYMBOL(rdma_is_zero_gid); | 137 | EXPORT_SYMBOL(rdma_is_zero_gid); |
137 | 138 | ||
139 | /** is_gid_index_default - Check if a given index belongs to | ||
140 | * reserved default GIDs or not. | ||
141 | * @table: GID table pointer | ||
142 | * @index: Index to check in GID table | ||
143 | * Returns true if index is one of the reserved default GID index otherwise | ||
144 | * returns false. | ||
145 | */ | ||
146 | static bool is_gid_index_default(const struct ib_gid_table *table, | ||
147 | unsigned int index) | ||
148 | { | ||
149 | return index < 32 && (BIT(index) & table->default_gid_indices); | ||
150 | } | ||
151 | |||
138 | int ib_cache_gid_parse_type_str(const char *buf) | 152 | int ib_cache_gid_parse_type_str(const char *buf) |
139 | { | 153 | { |
140 | unsigned int i; | 154 | unsigned int i; |
@@ -308,7 +322,7 @@ static int find_gid(struct ib_gid_table *table, const union ib_gid *gid, | |||
308 | if (pempty && empty < 0) { | 322 | if (pempty && empty < 0) { |
309 | if (data->props & GID_TABLE_ENTRY_INVALID && | 323 | if (data->props & GID_TABLE_ENTRY_INVALID && |
310 | (default_gid == | 324 | (default_gid == |
311 | !!(data->props & GID_TABLE_ENTRY_DEFAULT))) { | 325 | is_gid_index_default(table, curr_index))) { |
312 | /* | 326 | /* |
313 | * Found an invalid (free) entry; allocate it. | 327 | * Found an invalid (free) entry; allocate it. |
314 | * If default GID is requested, then our | 328 | * 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, | |||
346 | continue; | 360 | continue; |
347 | 361 | ||
348 | if (mask & GID_ATTR_FIND_MASK_DEFAULT && | 362 | if (mask & GID_ATTR_FIND_MASK_DEFAULT && |
349 | !!(data->props & GID_TABLE_ENTRY_DEFAULT) != | 363 | is_gid_index_default(table, curr_index) != default_gid) |
350 | default_gid) | ||
351 | continue; | 364 | continue; |
352 | 365 | ||
353 | found = curr_index; | 366 | found = curr_index; |
@@ -795,11 +808,9 @@ static void gid_table_reserve_default(struct ib_device *ib_dev, u8 port, | |||
795 | 808 | ||
796 | roce_gid_type_mask = roce_gid_type_mask_support(ib_dev, port); | 809 | roce_gid_type_mask = roce_gid_type_mask_support(ib_dev, port); |
797 | num_default_gids = hweight_long(roce_gid_type_mask); | 810 | num_default_gids = hweight_long(roce_gid_type_mask); |
798 | for (i = 0; i < num_default_gids && i < table->sz; i++) { | 811 | /* Reserve starting indices for default GIDs */ |
799 | struct ib_gid_table_entry *entry = &table->data_vec[i]; | 812 | for (i = 0; i < num_default_gids && i < table->sz; i++) |
800 | 813 | table->default_gid_indices |= BIT(i); | |
801 | entry->props |= GID_TABLE_ENTRY_DEFAULT; | ||
802 | } | ||
803 | } | 814 | } |
804 | 815 | ||
805 | 816 | ||