Skip to content

Commit a266ad6

Browse files
Alex Elderdavem330
authored andcommitted
net: ipa: introduce ipa_table_hash_support()
Introduce a new function to abstract the knowledge of whether hashed routing and filter tables are supported for a given IPA instance. IPA v4.2 is the only one that doesn't support hashed tables (now and for the foreseeable future), but the name of the helper function is better for explaining what's going on. Signed-off-by: Alex Elder <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 2d65ed7 commit a266ad6

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

drivers/net/ipa/ipa_cmd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ static bool ipa_cmd_register_write_valid(struct ipa *ipa)
268268
/* If hashed tables are supported, ensure the hash flush register
269269
* offset will fit in a register write IPA immediate command.
270270
*/
271-
if (ipa->version != IPA_VERSION_4_2) {
271+
if (ipa_table_hash_support(ipa)) {
272272
offset = ipa_reg_filt_rout_hash_flush_offset(ipa->version);
273273
name = "filter/route hash flush";
274274
if (!ipa_cmd_register_write_offset_valid(ipa, name, offset))

drivers/net/ipa/ipa_table.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// SPDX-License-Identifier: GPL-2.0
22

33
/* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
4-
* Copyright (C) 2018-2020 Linaro Ltd.
4+
* Copyright (C) 2018-2021 Linaro Ltd.
55
*/
66

77
#include <linux/types.h>
@@ -239,6 +239,11 @@ static void ipa_table_validate_build(void)
239239

240240
#endif /* !IPA_VALIDATE */
241241

242+
bool ipa_table_hash_support(struct ipa *ipa)
243+
{
244+
return ipa->version != IPA_VERSION_4_2;
245+
}
246+
242247
/* Zero entry count means no table, so just return a 0 address */
243248
static dma_addr_t ipa_table_addr(struct ipa *ipa, bool filter_mask, u16 count)
244249
{
@@ -412,8 +417,7 @@ int ipa_table_hash_flush(struct ipa *ipa)
412417
struct gsi_trans *trans;
413418
u32 val;
414419

415-
/* IPA version 4.2 does not support hashed tables */
416-
if (ipa->version == IPA_VERSION_4_2)
420+
if (!ipa_table_hash_support(ipa))
417421
return 0;
418422

419423
trans = ipa_cmd_trans_alloc(ipa, 1);
@@ -531,8 +535,7 @@ static void ipa_filter_config(struct ipa *ipa, bool modem)
531535
enum gsi_ee_id ee_id = modem ? GSI_EE_MODEM : GSI_EE_AP;
532536
u32 ep_mask = ipa->filter_map;
533537

534-
/* IPA version 4.2 has no hashed route tables */
535-
if (ipa->version == IPA_VERSION_4_2)
538+
if (!ipa_table_hash_support(ipa))
536539
return;
537540

538541
while (ep_mask) {
@@ -582,8 +585,7 @@ static void ipa_route_config(struct ipa *ipa, bool modem)
582585
{
583586
u32 route_id;
584587

585-
/* IPA version 4.2 has no hashed route tables */
586-
if (ipa->version == IPA_VERSION_4_2)
588+
if (!ipa_table_hash_support(ipa))
587589
return;
588590

589591
for (route_id = 0; route_id < IPA_ROUTE_COUNT_MAX; route_id++)

drivers/net/ipa/ipa_table.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* SPDX-License-Identifier: GPL-2.0 */
22

33
/* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
4-
* Copyright (C) 2019-2020 Linaro Ltd.
4+
* Copyright (C) 2019-2021 Linaro Ltd.
55
*/
66
#ifndef _IPA_TABLE_H_
77
#define _IPA_TABLE_H_
@@ -51,6 +51,12 @@ static inline bool ipa_filter_map_valid(struct ipa *ipa, u32 filter_mask)
5151

5252
#endif /* !IPA_VALIDATE */
5353

54+
/**
55+
* ipa_table_hash_support() - Return true if hashed tables are supported
56+
* @ipa: IPA pointer
57+
*/
58+
bool ipa_table_hash_support(struct ipa *ipa);
59+
5460
/**
5561
* ipa_table_reset() - Reset filter and route tables entries to "none"
5662
* @ipa: IPA pointer

0 commit comments

Comments
 (0)