@@ -134,6 +134,22 @@ static void efx_ef10_filter_del_vlan_internal(struct efx_nic *efx,
134
134
static void efx_ef10_filter_del_vlan (struct efx_nic * efx , u16 vid );
135
135
static int efx_ef10_set_udp_tnl_ports (struct efx_nic * efx , bool unloading );
136
136
137
+ static u32 efx_ef10_filter_get_unsafe_id (u32 filter_id )
138
+ {
139
+ WARN_ON_ONCE (filter_id == EFX_EF10_FILTER_ID_INVALID );
140
+ return filter_id & (HUNT_FILTER_TBL_ROWS - 1 );
141
+ }
142
+
143
+ static unsigned int efx_ef10_filter_get_unsafe_pri (u32 filter_id )
144
+ {
145
+ return filter_id / (HUNT_FILTER_TBL_ROWS * 2 );
146
+ }
147
+
148
+ static u32 efx_ef10_make_filter_id (unsigned int pri , u16 idx )
149
+ {
150
+ return pri * HUNT_FILTER_TBL_ROWS * 2 + idx ;
151
+ }
152
+
137
153
static int efx_ef10_get_warm_boot_count (struct efx_nic * efx )
138
154
{
139
155
efx_dword_t reg ;
@@ -4194,7 +4210,7 @@ static s32 efx_ef10_filter_insert(struct efx_nic *efx,
4194
4210
4195
4211
/* If successful, return the inserted filter ID */
4196
4212
if (rc == 0 )
4197
- rc = match_pri * HUNT_FILTER_TBL_ROWS + ins_index ;
4213
+ rc = efx_ef10_make_filter_id ( match_pri , ins_index ) ;
4198
4214
4199
4215
wake_up_all (& table -> waitq );
4200
4216
out_unlock :
@@ -4217,7 +4233,7 @@ static int efx_ef10_filter_remove_internal(struct efx_nic *efx,
4217
4233
unsigned int priority_mask ,
4218
4234
u32 filter_id , bool by_index )
4219
4235
{
4220
- unsigned int filter_idx = filter_id % HUNT_FILTER_TBL_ROWS ;
4236
+ unsigned int filter_idx = efx_ef10_filter_get_unsafe_id ( filter_id ) ;
4221
4237
struct efx_ef10_filter_table * table = efx -> filter_state ;
4222
4238
MCDI_DECLARE_BUF (inbuf ,
4223
4239
MC_CMD_FILTER_OP_IN_HANDLE_OFST +
@@ -4244,7 +4260,7 @@ static int efx_ef10_filter_remove_internal(struct efx_nic *efx,
4244
4260
if (!spec ||
4245
4261
(!by_index &&
4246
4262
efx_ef10_filter_pri (table , spec ) !=
4247
- filter_id / HUNT_FILTER_TBL_ROWS )) {
4263
+ efx_ef10_filter_get_unsafe_pri ( filter_id ) )) {
4248
4264
rc = - ENOENT ;
4249
4265
goto out_unlock ;
4250
4266
}
@@ -4319,11 +4335,6 @@ static int efx_ef10_filter_remove_safe(struct efx_nic *efx,
4319
4335
filter_id , false);
4320
4336
}
4321
4337
4322
- static u32 efx_ef10_filter_get_unsafe_id (struct efx_nic * efx , u32 filter_id )
4323
- {
4324
- return filter_id % HUNT_FILTER_TBL_ROWS ;
4325
- }
4326
-
4327
4338
static void efx_ef10_filter_remove_unsafe (struct efx_nic * efx ,
4328
4339
enum efx_filter_priority priority ,
4329
4340
u32 filter_id )
@@ -4337,7 +4348,7 @@ static int efx_ef10_filter_get_safe(struct efx_nic *efx,
4337
4348
enum efx_filter_priority priority ,
4338
4349
u32 filter_id , struct efx_filter_spec * spec )
4339
4350
{
4340
- unsigned int filter_idx = filter_id % HUNT_FILTER_TBL_ROWS ;
4351
+ unsigned int filter_idx = efx_ef10_filter_get_unsafe_id ( filter_id ) ;
4341
4352
struct efx_ef10_filter_table * table = efx -> filter_state ;
4342
4353
const struct efx_filter_spec * saved_spec ;
4343
4354
int rc ;
@@ -4346,7 +4357,7 @@ static int efx_ef10_filter_get_safe(struct efx_nic *efx,
4346
4357
saved_spec = efx_ef10_filter_entry_spec (table , filter_idx );
4347
4358
if (saved_spec && saved_spec -> priority == priority &&
4348
4359
efx_ef10_filter_pri (table , saved_spec ) ==
4349
- filter_id / HUNT_FILTER_TBL_ROWS ) {
4360
+ efx_ef10_filter_get_unsafe_pri ( filter_id ) ) {
4350
4361
* spec = * saved_spec ;
4351
4362
rc = 0 ;
4352
4363
} else {
@@ -4398,7 +4409,7 @@ static u32 efx_ef10_filter_get_rx_id_limit(struct efx_nic *efx)
4398
4409
{
4399
4410
struct efx_ef10_filter_table * table = efx -> filter_state ;
4400
4411
4401
- return table -> rx_match_count * HUNT_FILTER_TBL_ROWS ;
4412
+ return table -> rx_match_count * HUNT_FILTER_TBL_ROWS * 2 ;
4402
4413
}
4403
4414
4404
4415
static s32 efx_ef10_filter_get_rx_ids (struct efx_nic * efx ,
@@ -4418,8 +4429,9 @@ static s32 efx_ef10_filter_get_rx_ids(struct efx_nic *efx,
4418
4429
count = - EMSGSIZE ;
4419
4430
break ;
4420
4431
}
4421
- buf [count ++ ] = (efx_ef10_filter_pri (table , spec ) *
4422
- HUNT_FILTER_TBL_ROWS +
4432
+ buf [count ++ ] =
4433
+ efx_ef10_make_filter_id (
4434
+ efx_ef10_filter_pri (table , spec ),
4423
4435
filter_idx );
4424
4436
}
4425
4437
}
@@ -4971,7 +4983,7 @@ static void efx_ef10_filter_mark_one_old(struct efx_nic *efx, uint16_t *id)
4971
4983
unsigned int filter_idx ;
4972
4984
4973
4985
if (* id != EFX_EF10_FILTER_ID_INVALID ) {
4974
- filter_idx = efx_ef10_filter_get_unsafe_id (efx , * id );
4986
+ filter_idx = efx_ef10_filter_get_unsafe_id (* id );
4975
4987
if (!table -> entry [filter_idx ].spec )
4976
4988
netif_dbg (efx , drv , efx -> net_dev ,
4977
4989
"marked null spec old %04x:%04x\n" , * id ,
@@ -5106,7 +5118,7 @@ static int efx_ef10_filter_insert_addr_list(struct efx_nic *efx,
5106
5118
rc = EFX_EF10_FILTER_ID_INVALID ;
5107
5119
}
5108
5120
}
5109
- ids [i ] = efx_ef10_filter_get_unsafe_id (efx , rc );
5121
+ ids [i ] = efx_ef10_filter_get_unsafe_id (rc );
5110
5122
}
5111
5123
5112
5124
if (multicast && rollback ) {
@@ -5130,7 +5142,7 @@ static int efx_ef10_filter_insert_addr_list(struct efx_nic *efx,
5130
5142
return rc ;
5131
5143
} else {
5132
5144
vlan -> default_filters [EFX_EF10_BCAST ] =
5133
- efx_ef10_filter_get_unsafe_id (efx , rc );
5145
+ efx_ef10_filter_get_unsafe_id (rc );
5134
5146
}
5135
5147
}
5136
5148
@@ -5225,7 +5237,7 @@ static int efx_ef10_filter_insert_def(struct efx_nic *efx,
5225
5237
id = & vlan -> default_filters [map [encap_type ]];
5226
5238
5227
5239
EFX_WARN_ON_PARANOID (* id != EFX_EF10_FILTER_ID_INVALID );
5228
- * id = efx_ef10_filter_get_unsafe_id (efx , rc );
5240
+ * id = efx_ef10_filter_get_unsafe_id (rc );
5229
5241
if (!nic_data -> workaround_26807 && !encap_type ) {
5230
5242
/* Also need an Ethernet broadcast filter */
5231
5243
efx_filter_init_rx (& spec , EFX_FILTER_PRI_AUTO ,
@@ -5250,7 +5262,7 @@ static int efx_ef10_filter_insert_def(struct efx_nic *efx,
5250
5262
vlan -> default_filters [EFX_EF10_BCAST ] !=
5251
5263
EFX_EF10_FILTER_ID_INVALID );
5252
5264
vlan -> default_filters [EFX_EF10_BCAST ] =
5253
- efx_ef10_filter_get_unsafe_id (efx , rc );
5265
+ efx_ef10_filter_get_unsafe_id (rc );
5254
5266
}
5255
5267
}
5256
5268
rc = 0 ;
0 commit comments