@@ -68,7 +68,6 @@ enum gid_attr_find_mask {
68
68
69
69
enum gid_table_entry_props {
70
70
GID_TABLE_ENTRY_INVALID = 1UL << 0 ,
71
- GID_TABLE_ENTRY_DEFAULT = 1UL << 1 ,
72
71
};
73
72
74
73
struct ib_gid_table_entry {
@@ -79,7 +78,7 @@ struct ib_gid_table_entry {
79
78
};
80
79
81
80
struct ib_gid_table {
82
- int sz ;
81
+ int sz ;
83
82
/* In RoCE, adding a GID to the table requires:
84
83
* (a) Find if this GID is already exists.
85
84
* (b) Find a free space.
@@ -94,10 +93,12 @@ struct ib_gid_table {
94
93
* rwlock. readers must hold only rwlock. All writers must be in a
95
94
* sleepable context.
96
95
*/
97
- struct mutex lock ;
96
+ struct mutex lock ;
98
97
/* rwlock protects data_vec[ix]->props. */
99
- rwlock_t rwlock ;
100
- struct ib_gid_table_entry * data_vec ;
98
+ rwlock_t rwlock ;
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
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
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
152
int ib_cache_gid_parse_type_str (const char * buf )
139
153
{
140
154
unsigned int i ;
@@ -308,7 +322,7 @@ static int find_gid(struct ib_gid_table *table, const union ib_gid *gid,
308
322
if (pempty && empty < 0 ) {
309
323
if (data -> props & GID_TABLE_ENTRY_INVALID &&
310
324
(default_gid ==
311
- !!( data -> props & GID_TABLE_ENTRY_DEFAULT ))) {
325
+ is_gid_index_default ( table , curr_index ))) {
312
326
/*
313
327
* Found an invalid (free) entry; allocate it.
314
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
360
continue ;
347
361
348
362
if (mask & GID_ATTR_FIND_MASK_DEFAULT &&
349
- !!(data -> props & GID_TABLE_ENTRY_DEFAULT ) !=
350
- default_gid )
363
+ is_gid_index_default (table , curr_index ) != default_gid )
351
364
continue ;
352
365
353
366
found = curr_index ;
@@ -795,11 +808,9 @@ static void gid_table_reserve_default(struct ib_device *ib_dev, u8 port,
795
808
796
809
roce_gid_type_mask = roce_gid_type_mask_support (ib_dev , port );
797
810
num_default_gids = hweight_long (roce_gid_type_mask );
798
- for (i = 0 ; i < num_default_gids && i < table -> sz ; i ++ ) {
799
- struct ib_gid_table_entry * entry = & table -> data_vec [i ];
800
-
801
- entry -> props |= GID_TABLE_ENTRY_DEFAULT ;
802
- }
811
+ /* Reserve starting indices for default GIDs */
812
+ for (i = 0 ; i < num_default_gids && i < table -> sz ; i ++ )
813
+ table -> default_gid_indices |= BIT (i );
803
814
}
804
815
805
816
0 commit comments