1 /* SPDX-License-Identifier: GPL-2.0 */ 2 3 /* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved. 4 * Copyright (C) 2019-2021 Linaro Ltd. 5 */ 6 #ifndef _IPA_TABLE_H_ 7 #define _IPA_TABLE_H_ 8 9 #include <linux/types.h> 10 11 struct ipa; 12 13 /* The maximum number of filter table entries (IPv4, IPv6; hashed or not) */ 14 #define IPA_FILTER_COUNT_MAX 14 15 16 /* The maximum number of route table entries (IPv4, IPv6; hashed or not) */ 17 #define IPA_ROUTE_COUNT_MAX 15 18 19 #ifdef IPA_VALIDATE 20 21 /** 22 * ipa_table_valid() - Validate route and filter table memory regions 23 * @ipa: IPA pointer 24 * 25 * Return: true if all regions are valid, false otherwise 26 */ 27 bool ipa_table_valid(struct ipa *ipa); 28 29 /** 30 * ipa_filter_map_valid() - Validate a filter table endpoint bitmap 31 * @ipa: IPA pointer 32 * @filter_mask: Filter table endpoint bitmap to check 33 * 34 * Return: true if all regions are valid, false otherwise 35 */ 36 bool ipa_filter_map_valid(struct ipa *ipa, u32 filter_mask); 37 38 #else /* !IPA_VALIDATE */ 39 40 static inline bool ipa_table_valid(struct ipa *ipa) 41 { 42 return true; 43 } 44 45 static inline bool ipa_filter_map_valid(struct ipa *ipa, u32 filter_mask) 46 { 47 return true; 48 } 49 50 #endif /* !IPA_VALIDATE */ 51 52 /** 53 * ipa_table_hash_support() - Return true if hashed tables are supported 54 * @ipa: IPA pointer 55 */ 56 static inline bool ipa_table_hash_support(struct ipa *ipa) 57 { 58 return ipa->version != IPA_VERSION_4_2; 59 } 60 61 /** 62 * ipa_table_reset() - Reset filter and route tables entries to "none" 63 * @ipa: IPA pointer 64 * @modem: Whether to reset modem or AP entries 65 */ 66 void ipa_table_reset(struct ipa *ipa, bool modem); 67 68 /** 69 * ipa_table_hash_flush() - Synchronize hashed filter and route updates 70 * @ipa: IPA pointer 71 */ 72 int ipa_table_hash_flush(struct ipa *ipa); 73 74 /** 75 * ipa_table_setup() - Set up filter and route tables 76 * @ipa: IPA pointer 77 */ 78 int ipa_table_setup(struct ipa *ipa); 79 80 /** 81 * ipa_table_teardown() - Inverse of ipa_table_setup() 82 * @ipa: IPA pointer 83 */ 84 void ipa_table_teardown(struct ipa *ipa); 85 86 /** 87 * ipa_table_config() - Configure filter and route tables 88 * @ipa: IPA pointer 89 */ 90 void ipa_table_config(struct ipa *ipa); 91 92 /** 93 * ipa_table_deconfig() - Inverse of ipa_table_config() 94 * @ipa: IPA pointer 95 */ 96 void ipa_table_deconfig(struct ipa *ipa); 97 98 /** 99 * ipa_table_init() - Do early initialization of filter and route tables 100 * @ipa: IPA pointer 101 */ 102 int ipa_table_init(struct ipa *ipa); 103 104 /** 105 * ipa_table_exit() - Inverse of ipa_table_init() 106 * @ipa: IPA pointer 107 */ 108 void ipa_table_exit(struct ipa *ipa); 109 110 #endif /* _IPA_TABLE_H_ */ 111