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 size of a filter or route table entry */ 14 #define IPA_TABLE_ENTRY_SIZE sizeof(__le64) /* Holds a physical address */ 15 16 /* The maximum number of filter table entries (IPv4, IPv6; hashed or not) */ 17 #define IPA_FILTER_COUNT_MAX 14 18 19 /* The maximum number of route table entries (IPv4, IPv6; hashed or not) */ 20 #define IPA_ROUTE_COUNT_MAX 15 21 22 #ifdef IPA_VALIDATE 23 24 /** 25 * ipa_table_valid() - Validate route and filter table memory regions 26 * @ipa: IPA pointer 27 28 * Return: true if all regions are valid, false otherwise 29 */ 30 bool ipa_table_valid(struct ipa *ipa); 31 32 /** 33 * ipa_filter_map_valid() - Validate a filter table endpoint bitmap 34 * @ipa: IPA pointer 35 * 36 * Return: true if all regions are valid, false otherwise 37 */ 38 bool ipa_filter_map_valid(struct ipa *ipa, u32 filter_mask); 39 40 #else /* !IPA_VALIDATE */ 41 42 static inline bool ipa_table_valid(struct ipa *ipa) 43 { 44 return true; 45 } 46 47 static inline bool ipa_filter_map_valid(struct ipa *ipa, u32 filter_mask) 48 { 49 return true; 50 } 51 52 #endif /* !IPA_VALIDATE */ 53 54 /** 55 * ipa_table_hash_support() - Return true if hashed tables are supported 56 * @ipa: IPA pointer 57 */ 58 static inline bool ipa_table_hash_support(struct ipa *ipa) 59 { 60 return ipa->version != IPA_VERSION_4_2; 61 } 62 63 /** 64 * ipa_table_reset() - Reset filter and route tables entries to "none" 65 * @ipa: IPA pointer 66 * @modem: Whether to reset modem or AP entries 67 */ 68 void ipa_table_reset(struct ipa *ipa, bool modem); 69 70 /** 71 * ipa_table_hash_flush() - Synchronize hashed filter and route updates 72 * @ipa: IPA pointer 73 */ 74 int ipa_table_hash_flush(struct ipa *ipa); 75 76 /** 77 * ipa_table_setup() - Set up filter and route tables 78 * @ipa: IPA pointer 79 */ 80 int ipa_table_setup(struct ipa *ipa); 81 82 /** 83 * ipa_table_teardown() - Inverse of ipa_table_setup() 84 * @ipa: IPA pointer 85 */ 86 void ipa_table_teardown(struct ipa *ipa); 87 88 /** 89 * ipa_table_config() - Configure filter and route tables 90 * @ipa: IPA pointer 91 */ 92 void ipa_table_config(struct ipa *ipa); 93 94 /** 95 * ipa_table_deconfig() - Inverse of ipa_table_config() 96 * @ipa: IPA pointer 97 */ 98 void ipa_table_deconfig(struct ipa *ipa); 99 100 /** 101 * ipa_table_init() - Do early initialization of filter and route tables 102 * @ipa: IPA pointer 103 */ 104 int ipa_table_init(struct ipa *ipa); 105 106 /** 107 * ipa_table_exit() - Inverse of ipa_table_init() 108 * @ipa: IPA pointer 109 */ 110 void ipa_table_exit(struct ipa *ipa); 111 112 #endif /* _IPA_TABLE_H_ */ 113