Ben Menchaca | 84f3663 | 2014-02-28 20:57:38 +0000 | [diff] [blame] | 1 | /* |
| 2 | ************************************************************************** |
Kyle Swenson | a0ac159 | 2021-05-21 08:08:08 -0600 | [diff] [blame^] | 3 | * Copyright (c) 2014-2015, 2018-2021 The Linux Foundation. All rights reserved. |
Ben Menchaca | 84f3663 | 2014-02-28 20:57:38 +0000 | [diff] [blame] | 4 | * Permission to use, copy, modify, and/or distribute this software for |
| 5 | * any purpose with or without fee is hereby granted, provided that the |
| 6 | * above copyright notice and this permission notice appear in all copies. |
| 7 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 8 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 9 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
| 10 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 11 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 12 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT |
| 13 | * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 14 | ************************************************************************** |
| 15 | */ |
| 16 | |
Kyle Swenson | 1aa0e0d | 2021-03-18 14:20:24 -0600 | [diff] [blame] | 17 | extern int ecm_classifier_accel_delay_pkts; /* Default slow path packets allowed before the acceleration */ |
| 18 | |
Ben Menchaca | 84f3663 | 2014-02-28 20:57:38 +0000 | [diff] [blame] | 19 | struct ecm_classifier_instance; |
| 20 | |
| 21 | /* |
| 22 | * Classifier types. |
| 23 | * MUST BE RECORDED IN ASCENDING ORDER OF PRIORITY |
| 24 | */ |
| 25 | enum ecm_classifier_types { |
| 26 | ECM_CLASSIFIER_TYPE_DEFAULT = 0, /* MUST BE FIRST, Default classifier */ |
Murat Sezgin | f4f7ab4 | 2018-10-12 17:01:46 -0700 | [diff] [blame] | 27 | #ifdef ECM_CLASSIFIER_MARK_ENABLE |
| 28 | ECM_CLASSIFIER_TYPE_MARK, /* Mark classifier */ |
| 29 | #endif |
Hai Shalom | 81f4e20 | 2014-06-04 09:30:27 -0700 | [diff] [blame] | 30 | #ifdef ECM_CLASSIFIER_HYFI_ENABLE |
Ben Menchaca | 84f3663 | 2014-02-28 20:57:38 +0000 | [diff] [blame] | 31 | ECM_CLASSIFIER_TYPE_HYFI, /* HyFi classifier */ |
Hai Shalom | 81f4e20 | 2014-06-04 09:30:27 -0700 | [diff] [blame] | 32 | #endif |
Murat Sezgin | b3731e8 | 2014-11-26 12:20:59 -0800 | [diff] [blame] | 33 | #ifdef ECM_CLASSIFIER_DSCP_ENABLE |
Gareth Williams | 8932a91 | 2014-06-11 18:06:25 -0700 | [diff] [blame] | 34 | ECM_CLASSIFIER_TYPE_DSCP, /* Provides DSCP and DSCP remarking support */ |
Murat Sezgin | b3731e8 | 2014-11-26 12:20:59 -0800 | [diff] [blame] | 35 | #endif |
Kyle Swenson | 1aa0e0d | 2021-03-18 14:20:24 -0600 | [diff] [blame] | 36 | #ifdef ECM_CLASSIFIER_MSCS_ENABLE |
| 37 | ECM_CLASSIFIER_TYPE_MSCS, /* Mirrored Stream Classification Signalling(MSCS) classifier */ |
| 38 | #endif |
| 39 | #ifdef ECM_CLASSIFIER_EMESH_ENABLE |
| 40 | ECM_CLASSIFIER_TYPE_EMESH, /* E-Mesh classifier */ |
| 41 | #endif |
Murat Sezgin | b3731e8 | 2014-11-26 12:20:59 -0800 | [diff] [blame] | 42 | #ifdef ECM_CLASSIFIER_NL_ENABLE |
Ben Menchaca | 84f3663 | 2014-02-28 20:57:38 +0000 | [diff] [blame] | 43 | ECM_CLASSIFIER_TYPE_NL, /* Provides netlink interface */ |
Murat Sezgin | b3731e8 | 2014-11-26 12:20:59 -0800 | [diff] [blame] | 44 | #endif |
Murat Sezgin | a05befb | 2019-10-08 17:00:37 -0700 | [diff] [blame] | 45 | #ifdef ECM_CLASSIFIER_OVS_ENABLE |
| 46 | ECM_CLASSIFIER_TYPE_OVS, /* OVS classifier */ |
| 47 | #endif |
Gareth Williams | dcda9b9 | 2015-05-13 10:08:15 +0100 | [diff] [blame] | 48 | #ifdef ECM_CLASSIFIER_PCC_ENABLE |
| 49 | ECM_CLASSIFIER_TYPE_PCC, /* Parental control subsystem support classifier */ |
| 50 | #endif |
Ben Menchaca | 84f3663 | 2014-02-28 20:57:38 +0000 | [diff] [blame] | 51 | ECM_CLASSIFIER_TYPES, /* MUST BE LAST */ |
| 52 | }; |
| 53 | typedef enum ecm_classifier_types ecm_classifier_type_t; |
| 54 | |
| 55 | /* |
| 56 | * enum ecm_classifier_relevances |
| 57 | * Whether a classifier is relevant to a connection |
| 58 | */ |
| 59 | enum ecm_classifier_relevances { |
| 60 | ECM_CLASSIFIER_RELEVANCE_MAYBE = 0, /* Classifier has not yet determined relevance */ |
| 61 | ECM_CLASSIFIER_RELEVANCE_NO, /* Classifier is not relevant to a connection (classifier will be unassigned from the connection after returning this from a process() call) */ |
| 62 | ECM_CLASSIFIER_RELEVANCE_YES, /* Classifier is relevant to the connection, process actions will be inspected by the front end when returning this from a process() call */ |
| 63 | }; |
| 64 | typedef enum ecm_classifier_relevances ecm_classifier_relevence_t; |
| 65 | |
| 66 | /* |
| 67 | * enum ecm_classifier_acceleration_modes |
| 68 | * Modes in which a connection may be accelerated |
Murat Sezgin | d701ac5 | 2014-08-20 14:02:30 -0700 | [diff] [blame] | 69 | * |
| 70 | * These are used by a classifier to indicate its desire to accelerate. |
Ben Menchaca | 84f3663 | 2014-02-28 20:57:38 +0000 | [diff] [blame] | 71 | */ |
| 72 | enum ecm_classifier_acceleration_modes { |
| 73 | ECM_CLASSIFIER_ACCELERATION_MODE_DONT_CARE = 0, /* Classifier does not care if the connection is accelerated */ |
| 74 | ECM_CLASSIFIER_ACCELERATION_MODE_NO, /* Connection must not be accelerated */ |
| 75 | ECM_CLASSIFIER_ACCELERATION_MODE_ACCEL, /* Connection can be accelerated whenever */ |
| 76 | }; |
| 77 | typedef enum ecm_classifier_acceleration_modes ecm_classifier_acceleration_mode_t; |
| 78 | |
| 79 | /* |
| 80 | * Process actions |
| 81 | * A process result, that is relevant, may contain zero or more actions for the front end. |
| 82 | * Due to the parallel processing nature of classifiers, *usually* the action(s) of the highest priority |
| 83 | * classifier will override any lower priority actions. This is up to front end discretion, of course. |
| 84 | */ |
Gareth Williams | 27c3db1 | 2014-06-11 17:37:56 -0700 | [diff] [blame] | 85 | #define ECM_CLASSIFIER_PROCESS_ACTION_DROP 0x00000001 /* Drop */ |
| 86 | #define ECM_CLASSIFIER_PROCESS_ACTION_QOS_TAG 0x00000002 /* Contains flow & return qos tags */ |
Ben Menchaca | 84f3663 | 2014-02-28 20:57:38 +0000 | [diff] [blame] | 87 | #define ECM_CLASSIFIER_PROCESS_ACTION_ACCEL_MODE 0x00000004 /* Contains an accel mode */ |
| 88 | #define ECM_CLASSIFIER_PROCESS_ACTION_TIMER_GROUP 0x00000008 /* Contains a timer group change */ |
Murat Sezgin | 62c9283 | 2015-03-06 16:08:31 -0800 | [diff] [blame] | 89 | |
| 90 | #ifdef ECM_CLASSIFIER_DSCP_ENABLE |
Gareth Williams | bd03e23 | 2014-06-11 17:55:28 -0700 | [diff] [blame] | 91 | #define ECM_CLASSIFIER_PROCESS_ACTION_DSCP 0x00000010 /* Contains DSCP marking information */ |
| 92 | #define ECM_CLASSIFIER_PROCESS_ACTION_DSCP_DENY 0x00000020 /* Denies any DSCP changes */ |
Manish Verma | ed49378 | 2019-05-27 12:56:02 +0530 | [diff] [blame] | 93 | |
| 94 | #define ECM_CLASSIFIER_PROCESS_ACTION_IGS_QOS_TAG 0x00000040 /* Contains flow & return ingress qos tags */ |
Murat Sezgin | 62c9283 | 2015-03-06 16:08:31 -0800 | [diff] [blame] | 95 | #endif |
Ben Menchaca | 84f3663 | 2014-02-28 20:57:38 +0000 | [diff] [blame] | 96 | |
Murat Sezgin | 964bfd8 | 2019-11-18 14:28:37 -0800 | [diff] [blame] | 97 | #ifdef ECM_CLASSIFIER_OVS_ENABLE |
| 98 | #define ECM_CLASSIFIER_PROCESS_ACTION_OVS_VLAN_TAG 0x00000080 /* Contains OVS VLAN tags */ |
Suman Ghosh | e1c939c | 2019-11-12 20:43:04 +0530 | [diff] [blame] | 99 | #define ECM_CLASSIFIER_PROCESS_ACTION_OVS_VLAN_QINQ_TAG 0x00000100 /* Contains OVS QinQ VLAN tags */ |
| 100 | #define ECM_CLASSIFIER_PROCESS_ACTION_OVS_MCAST_DENY_ACCEL 0x00000200 /* Multicast OVS flow */ |
Murat Sezgin | 964bfd8 | 2019-11-18 14:28:37 -0800 | [diff] [blame] | 101 | #endif |
| 102 | |
Kyle Swenson | 1aa0e0d | 2021-03-18 14:20:24 -0600 | [diff] [blame] | 103 | #ifdef ECM_CLASSIFIER_EMESH_ENABLE |
| 104 | #define ECM_CLASSIFIER_PROCESS_ACTION_EMESH_SP_FLOW 0x00000400 /* Mark the E-MESH Service Prioritization flow */ |
| 105 | #endif |
| 106 | |
| 107 | #define ECM_CLASSIFIER_PROCESS_ACTION_TIMER_GROUP_NO_TOUCH 0x00000400 /* Do not update CI time */ |
| 108 | |
Kyle Swenson | a0ac159 | 2021-05-21 08:08:08 -0600 | [diff] [blame^] | 109 | #ifdef ECM_CLASSIFIER_PCC_ENABLE |
| 110 | #define ECM_CLASSIFIER_PROCESS_ACTION_MIRROR_ENABLED 0x00000800 /* Contains mirror dynamic interface number */ |
| 111 | #endif |
| 112 | |
Ben Menchaca | 84f3663 | 2014-02-28 20:57:38 +0000 | [diff] [blame] | 113 | /* |
| 114 | * struct ecm_classifier_process_response |
| 115 | * Response structure returned by a process call |
| 116 | */ |
| 117 | struct ecm_classifier_process_response { |
| 118 | ecm_classifier_relevence_t relevance; /* Is this classifier relevant to the connection? */ |
| 119 | uint32_t became_relevant; /* DB time the classifier became relevant or not relevant, if relevance is maybe this field is not relevant! */ |
| 120 | |
| 121 | uint32_t process_actions; /* Actions this process response contains */ |
| 122 | |
| 123 | /* |
| 124 | * The following fields are only to be inspected if this response is relevant AND the process_actions indicates so |
| 125 | */ |
| 126 | bool drop; /* Drop packet at hand */ |
Gareth Williams | 27c3db1 | 2014-06-11 17:37:56 -0700 | [diff] [blame] | 127 | uint32_t flow_qos_tag; /* QoS tag to use for the packet */ |
| 128 | uint32_t return_qos_tag; /* QoS tag to use for the packet */ |
Kyle Swenson | 1aa0e0d | 2021-03-18 14:20:24 -0600 | [diff] [blame] | 129 | #ifdef ECM_CLASSIFIER_DSCP_ENABLE |
| 130 | #ifdef ECM_CLASSIFIER_DSCP_IGS |
Manish Verma | ed49378 | 2019-05-27 12:56:02 +0530 | [diff] [blame] | 131 | uint16_t igs_flow_qos_tag; /* Ingress QoS tag to use for the packet */ |
| 132 | uint16_t igs_return_qos_tag; /* Ingress QoS tag to use for the return packet */ |
Kyle Swenson | 1aa0e0d | 2021-03-18 14:20:24 -0600 | [diff] [blame] | 133 | #endif |
Gareth Williams | bd03e23 | 2014-06-11 17:55:28 -0700 | [diff] [blame] | 134 | uint8_t flow_dscp; /* DSCP mark for flow */ |
| 135 | uint8_t return_dscp; /* DSCP mark for return */ |
Murat Sezgin | 62c9283 | 2015-03-06 16:08:31 -0800 | [diff] [blame] | 136 | #endif |
Murat Sezgin | 964bfd8 | 2019-11-18 14:28:37 -0800 | [diff] [blame] | 137 | #ifdef ECM_CLASSIFIER_OVS_ENABLE |
| 138 | uint32_t ingress_vlan_tag[2]; /* Ingress VLAN tags */ |
| 139 | uint32_t egress_vlan_tag[2]; /* Egress VLAN tags */ |
Suman Ghosh | a11fc92 | 2020-01-08 14:34:03 +0530 | [diff] [blame] | 140 | #ifdef ECM_MULTICAST_ENABLE |
| 141 | int32_t egress_netdev_index[ECM_DB_MULTICAST_IF_MAX]; /* Multicast egress net device interface index */ |
| 142 | uint32_t egress_mc_vlan_tag[ECM_DB_MULTICAST_IF_MAX][2]; /* Multicast egress VLAN tags */ |
| 143 | #endif |
Murat Sezgin | 964bfd8 | 2019-11-18 14:28:37 -0800 | [diff] [blame] | 144 | #endif |
Kyle Swenson | a0ac159 | 2021-05-21 08:08:08 -0600 | [diff] [blame^] | 145 | #ifdef ECM_CLASSIFIER_PCC_ENABLE |
| 146 | int flow_mirror_ifindex; /* Flow mirror device index value */ |
| 147 | int return_mirror_ifindex; /* Return mirror device index value */ |
| 148 | #endif |
Ben Menchaca | 84f3663 | 2014-02-28 20:57:38 +0000 | [diff] [blame] | 149 | ecm_classifier_acceleration_mode_t accel_mode; /* Acceleration needed for this connection */ |
| 150 | ecm_db_timer_group_t timer_group; /* Timer group the connection should be in */ |
| 151 | }; |
| 152 | |
| 153 | /* |
Murat Sezgin | b267606 | 2015-06-12 17:05:31 -0700 | [diff] [blame] | 154 | * Sync rule structure. |
| 155 | * Acceleration engine's sync parameters will be stored |
| 156 | * in this data structure to update the classifiers. |
| 157 | */ |
| 158 | struct ecm_classifier_rule_sync { |
Murat Sezgin | e53be91 | 2020-01-07 16:04:57 -0800 | [diff] [blame] | 159 | uint32_t tx_packet_count[ECM_CONN_DIR_MAX]; |
| 160 | uint32_t tx_byte_count[ECM_CONN_DIR_MAX]; |
| 161 | uint32_t rx_packet_count[ECM_CONN_DIR_MAX]; |
| 162 | uint32_t rx_byte_count[ECM_CONN_DIR_MAX]; |
Murat Sezgin | b267606 | 2015-06-12 17:05:31 -0700 | [diff] [blame] | 163 | uint32_t reason; |
| 164 | }; |
| 165 | |
| 166 | /* |
| 167 | * Create rule structure. |
| 168 | * Additional create rule parameters from the classifiers |
| 169 | * will be copied to this data structure before pushing them to |
| 170 | * the underlying accelaration engine. |
| 171 | */ |
| 172 | struct ecm_classifier_rule_create { |
Kyle Swenson | a0ac159 | 2021-05-21 08:08:08 -0600 | [diff] [blame^] | 173 | #ifdef ECM_CLASSIFIER_EMESH_ENABLE |
| 174 | struct sk_buff *skb; |
| 175 | #endif |
Murat Sezgin | b267606 | 2015-06-12 17:05:31 -0700 | [diff] [blame] | 176 | }; |
| 177 | |
| 178 | /* |
Ben Menchaca | 84f3663 | 2014-02-28 20:57:38 +0000 | [diff] [blame] | 179 | * To be implemented by all classifiers |
| 180 | */ |
| 181 | typedef void (*ecm_classifier_ref_method_t)(struct ecm_classifier_instance *ci); |
| 182 | typedef int (*ecm_classifier_deref_callback_t)(struct ecm_classifier_instance *ci); |
| 183 | typedef void (*ecm_classifier_process_callback_t)(struct ecm_classifier_instance *ci, ecm_tracker_sender_type_t sender, struct ecm_tracker_ip_header *ip_hdr, struct sk_buff *skb, struct ecm_classifier_process_response *process_response); |
| 184 | /* Process new data for connection, process_response is populated with the response of processing */ |
Murat Sezgin | b267606 | 2015-06-12 17:05:31 -0700 | [diff] [blame] | 185 | typedef void (*ecm_classifier_sync_from_v4_callback_t)(struct ecm_classifier_instance *ci, struct ecm_classifier_rule_create *ecrc); |
| 186 | /* Sync the accel engine state with state from the classifier */ |
| 187 | typedef void (*ecm_classifier_sync_to_v4_callback_t)(struct ecm_classifier_instance *ci, struct ecm_classifier_rule_sync *sync); |
| 188 | /* Sync the classifier state with current accel engine state */ |
| 189 | typedef void (*ecm_classifier_sync_from_v6_callback_t)(struct ecm_classifier_instance *ci, struct ecm_classifier_rule_create *ecrc); |
| 190 | /* Sync the accel engine state with state from the classifier */ |
| 191 | typedef void (*ecm_classifier_sync_to_v6_callback_t)(struct ecm_classifier_instance *ci, struct ecm_classifier_rule_sync *sync); |
| 192 | /* Sync the classifier state with current accel engine state */ |
Ben Menchaca | 84f3663 | 2014-02-28 20:57:38 +0000 | [diff] [blame] | 193 | typedef ecm_classifier_type_t (*ecm_classifier_type_get_callback_t)(struct ecm_classifier_instance *ci); |
| 194 | /* Get type of classifier this is */ |
| 195 | typedef bool (*ecm_classifier_reclassify_allowed_get_callback_t)(struct ecm_classifier_instance *ci); |
| 196 | /* Get whether reclassification is allowed */ |
| 197 | typedef void (*ecm_classifier_reclassify_callback_t)(struct ecm_classifier_instance *ci); |
| 198 | /* Reclassify */ |
| 199 | typedef void (*ecm_classifier_last_process_response_get_callback_t)(struct ecm_classifier_instance *ci, struct ecm_classifier_process_response *process_response); |
| 200 | /* Get last process response */ |
Gareth Williams | f98d419 | 2015-03-11 16:55:41 +0000 | [diff] [blame] | 201 | #ifdef ECM_STATE_OUTPUT_ENABLE |
Gareth Williams | d5618a8 | 2015-05-20 11:13:32 +0100 | [diff] [blame] | 202 | typedef int (*ecm_classifier_state_get_callback_t)(struct ecm_classifier_instance *ci, struct ecm_state_file_instance *sfi); |
| 203 | /* Get state output. Returns 0 upon success. */ |
Gareth Williams | f98d419 | 2015-03-11 16:55:41 +0000 | [diff] [blame] | 204 | #endif |
Ben Menchaca | 84f3663 | 2014-02-28 20:57:38 +0000 | [diff] [blame] | 205 | |
| 206 | /* |
Murat Sezgin | e34b017 | 2015-11-05 21:58:14 -0800 | [diff] [blame] | 207 | * Determines if a connection should be kept. |
| 208 | */ |
| 209 | typedef bool (*ecm_classifier_should_keep_connection_t) |
| 210 | (struct ecm_classifier_instance *ci, uint8_t *mac); |
| 211 | |
| 212 | /* |
Ben Menchaca | 84f3663 | 2014-02-28 20:57:38 +0000 | [diff] [blame] | 213 | * Base class for all types of classifiers |
| 214 | */ |
| 215 | struct ecm_classifier_instance { |
| 216 | struct ecm_classifier_instance *ca_next; /* DB use only: Connection assignment next pointer */ |
| 217 | struct ecm_classifier_instance *ca_prev; /* DB use only: Connection assignment prev pointer */ |
| 218 | |
| 219 | ecm_classifier_process_callback_t process; /* Process new skb */ |
| 220 | ecm_classifier_sync_from_v4_callback_t sync_from_v4; |
Murat Sezgin | b267606 | 2015-06-12 17:05:31 -0700 | [diff] [blame] | 221 | /* Sync the accel engine with state from the classifier */ |
| 222 | ecm_classifier_sync_to_v4_callback_t sync_to_v4;/* Sync the classifier with state from the accel engine */ |
Ben Menchaca | 84f3663 | 2014-02-28 20:57:38 +0000 | [diff] [blame] | 223 | ecm_classifier_sync_from_v6_callback_t sync_from_v6; |
Murat Sezgin | b267606 | 2015-06-12 17:05:31 -0700 | [diff] [blame] | 224 | /* Sync the accel engine with state from the classifier */ |
| 225 | ecm_classifier_sync_to_v6_callback_t sync_to_v6;/* Sync the classifier with state from the accel engine */ |
Ben Menchaca | 84f3663 | 2014-02-28 20:57:38 +0000 | [diff] [blame] | 226 | ecm_classifier_type_get_callback_t type_get; /* Get type of classifier */ |
| 227 | ecm_classifier_reclassify_allowed_get_callback_t reclassify_allowed; |
| 228 | /* Get whether reclassification is allowed */ |
| 229 | ecm_classifier_reclassify_callback_t reclassify; |
| 230 | /* Reclassify */ |
| 231 | ecm_classifier_last_process_response_get_callback_t last_process_response_get; |
| 232 | /* Return last process response */ |
Murat Sezgin | e34b017 | 2015-11-05 21:58:14 -0800 | [diff] [blame] | 233 | ecm_classifier_should_keep_connection_t should_keep_connection; |
| 234 | /* Check if connection should be kept when FDB updates */ |
Gareth Williams | f98d419 | 2015-03-11 16:55:41 +0000 | [diff] [blame] | 235 | #ifdef ECM_STATE_OUTPUT_ENABLE |
Gareth Williams | d5618a8 | 2015-05-20 11:13:32 +0100 | [diff] [blame] | 236 | ecm_classifier_state_get_callback_t state_get; |
| 237 | /* Return its state */ |
Gareth Williams | f98d419 | 2015-03-11 16:55:41 +0000 | [diff] [blame] | 238 | #endif |
Ben Menchaca | 84f3663 | 2014-02-28 20:57:38 +0000 | [diff] [blame] | 239 | ecm_classifier_ref_method_t ref; |
| 240 | ecm_classifier_deref_callback_t deref; |
| 241 | }; |
| 242 | |
Gareth Williams | f98d419 | 2015-03-11 16:55:41 +0000 | [diff] [blame] | 243 | #ifdef ECM_STATE_OUTPUT_ENABLE |
Ben Menchaca | 84f3663 | 2014-02-28 20:57:38 +0000 | [diff] [blame] | 244 | /* |
Gareth Williams | d5618a8 | 2015-05-20 11:13:32 +0100 | [diff] [blame] | 245 | * ecm_classifier_process_response_state_get() |
| 246 | * Output detail for the process response |
Ben Menchaca | 84f3663 | 2014-02-28 20:57:38 +0000 | [diff] [blame] | 247 | * |
Gareth Williams | d5618a8 | 2015-05-20 11:13:32 +0100 | [diff] [blame] | 248 | * Returns 0 on success. |
Ben Menchaca | 84f3663 | 2014-02-28 20:57:38 +0000 | [diff] [blame] | 249 | */ |
Gareth Williams | d5618a8 | 2015-05-20 11:13:32 +0100 | [diff] [blame] | 250 | static inline int ecm_classifier_process_response_state_get(struct ecm_state_file_instance *sfi, struct ecm_classifier_process_response *pr) |
Ben Menchaca | 84f3663 | 2014-02-28 20:57:38 +0000 | [diff] [blame] | 251 | { |
Gareth Williams | d5618a8 | 2015-05-20 11:13:32 +0100 | [diff] [blame] | 252 | int result; |
| 253 | |
| 254 | if ((result = ecm_state_prefix_add(sfi, "pr"))) { |
| 255 | return result; |
| 256 | } |
Ben Menchaca | 84f3663 | 2014-02-28 20:57:38 +0000 | [diff] [blame] | 257 | |
| 258 | if (pr->relevance == ECM_CLASSIFIER_RELEVANCE_NO) { |
Gareth Williams | d5618a8 | 2015-05-20 11:13:32 +0100 | [diff] [blame] | 259 | return ecm_state_write(sfi, "relevant", "%s", "no"); |
Ben Menchaca | 84f3663 | 2014-02-28 20:57:38 +0000 | [diff] [blame] | 260 | } |
| 261 | |
| 262 | if (pr->process_actions & ECM_CLASSIFIER_PROCESS_ACTION_DROP) { |
| 263 | if (pr->drop) { |
Gareth Williams | d5618a8 | 2015-05-20 11:13:32 +0100 | [diff] [blame] | 264 | if ((result = ecm_state_write(sfi, "drop", "yes"))) { |
| 265 | return result; |
| 266 | } |
Ben Menchaca | 84f3663 | 2014-02-28 20:57:38 +0000 | [diff] [blame] | 267 | } else { |
Gareth Williams | d5618a8 | 2015-05-20 11:13:32 +0100 | [diff] [blame] | 268 | if ((result = ecm_state_write(sfi, "drop", "no"))) { |
| 269 | return result; |
| 270 | } |
Ben Menchaca | 84f3663 | 2014-02-28 20:57:38 +0000 | [diff] [blame] | 271 | } |
| 272 | } |
| 273 | |
Ben Menchaca | 84f3663 | 2014-02-28 20:57:38 +0000 | [diff] [blame] | 274 | if (pr->relevance == ECM_CLASSIFIER_RELEVANCE_MAYBE) { |
Gareth Williams | d5618a8 | 2015-05-20 11:13:32 +0100 | [diff] [blame] | 275 | if ((result = ecm_state_write(sfi, "accel", "denied"))) { |
| 276 | return result; |
| 277 | } |
| 278 | if ((result = ecm_state_write(sfi, "relevant", "maybe"))) { |
| 279 | return result; |
| 280 | } |
Ben Menchaca | 84f3663 | 2014-02-28 20:57:38 +0000 | [diff] [blame] | 281 | } else { |
Gareth Williams | d5618a8 | 2015-05-20 11:13:32 +0100 | [diff] [blame] | 282 | if ((result = ecm_state_write(sfi, "relevant", "yes"))) { |
| 283 | return result; |
| 284 | } |
| 285 | if (pr->process_actions & ECM_CLASSIFIER_PROCESS_ACTION_ACCEL_MODE) { |
| 286 | if (pr->accel_mode == ECM_CLASSIFIER_ACCELERATION_MODE_ACCEL) { |
| 287 | if ((result = ecm_state_write(sfi, "accel", "wanted"))) { |
| 288 | return result; |
| 289 | } |
| 290 | } |
| 291 | else if (pr->accel_mode == ECM_CLASSIFIER_ACCELERATION_MODE_NO) { |
| 292 | if ((result = ecm_state_write(sfi, "accel", "denied"))) { |
| 293 | return result; |
| 294 | } |
| 295 | } |
| 296 | /* Else don't care */ |
| 297 | } |
Ben Menchaca | 84f3663 | 2014-02-28 20:57:38 +0000 | [diff] [blame] | 298 | } |
| 299 | |
Murat Sezgin | 964bfd8 | 2019-11-18 14:28:37 -0800 | [diff] [blame] | 300 | #ifdef ECM_CLASSIFIER_OVS_ENABLE |
| 301 | if (pr->process_actions & ECM_CLASSIFIER_PROCESS_ACTION_OVS_VLAN_TAG) { |
Suman Ghosh | a11fc92 | 2020-01-08 14:34:03 +0530 | [diff] [blame] | 302 | #ifdef ECM_MULTICAST_ENABLE |
| 303 | int i; |
| 304 | #endif |
Suman Ghosh | a11fc92 | 2020-01-08 14:34:03 +0530 | [diff] [blame] | 305 | /* |
| 306 | * TODO: Clean up the function later to print classifier |
| 307 | * specific data in each classifier’s state_get function. |
| 308 | */ |
Suman Ghosh | a33d7df | 2020-01-31 21:45:20 +0530 | [diff] [blame] | 309 | if (pr->ingress_vlan_tag[0] != ECM_FRONT_END_VLAN_ID_NOT_CONFIGURED) { |
Suman Ghosh | a11fc92 | 2020-01-08 14:34:03 +0530 | [diff] [blame] | 310 | if ((result = ecm_state_write(sfi, "ingress_vlan_tag[0]", "0x%x", pr->ingress_vlan_tag[0]))) { |
| 311 | return result; |
| 312 | } |
Murat Sezgin | 964bfd8 | 2019-11-18 14:28:37 -0800 | [diff] [blame] | 313 | } |
Suman Ghosh | a11fc92 | 2020-01-08 14:34:03 +0530 | [diff] [blame] | 314 | |
Suman Ghosh | a33d7df | 2020-01-31 21:45:20 +0530 | [diff] [blame] | 315 | if (pr->ingress_vlan_tag[1] != ECM_FRONT_END_VLAN_ID_NOT_CONFIGURED) { |
Suman Ghosh | a11fc92 | 2020-01-08 14:34:03 +0530 | [diff] [blame] | 316 | if ((result = ecm_state_write(sfi, "ingress_vlan_tag[1]", "0x%x", pr->ingress_vlan_tag[1]))) { |
| 317 | return result; |
| 318 | } |
Murat Sezgin | 964bfd8 | 2019-11-18 14:28:37 -0800 | [diff] [blame] | 319 | } |
Suman Ghosh | a11fc92 | 2020-01-08 14:34:03 +0530 | [diff] [blame] | 320 | |
Kyle Swenson | 1aa0e0d | 2021-03-18 14:20:24 -0600 | [diff] [blame] | 321 | if (pr->egress_vlan_tag[0] != ECM_FRONT_END_VLAN_ID_NOT_CONFIGURED) { |
| 322 | if ((result = ecm_state_write(sfi, "egress_vlan_tag[0]", "0x%x", pr->egress_vlan_tag[0]))) { |
| 323 | return result; |
| 324 | } |
| 325 | } |
| 326 | |
Suman Ghosh | a33d7df | 2020-01-31 21:45:20 +0530 | [diff] [blame] | 327 | if (pr->egress_vlan_tag[1] != ECM_FRONT_END_VLAN_ID_NOT_CONFIGURED) { |
Suman Ghosh | a11fc92 | 2020-01-08 14:34:03 +0530 | [diff] [blame] | 328 | if ((result = ecm_state_write(sfi, "egress_vlan_tag[1]", "0x%x", pr->egress_vlan_tag[1]))) { |
| 329 | return result; |
| 330 | } |
Murat Sezgin | 964bfd8 | 2019-11-18 14:28:37 -0800 | [diff] [blame] | 331 | } |
Suman Ghosh | a11fc92 | 2020-01-08 14:34:03 +0530 | [diff] [blame] | 332 | |
| 333 | #ifdef ECM_MULTICAST_ENABLE |
| 334 | for (i = 0; i < ECM_DB_MULTICAST_IF_MAX; i++) { |
Kyle Swenson | 1aa0e0d | 2021-03-18 14:20:24 -0600 | [diff] [blame] | 335 | struct net_device *dev; |
Suman Ghosh | a11fc92 | 2020-01-08 14:34:03 +0530 | [diff] [blame] | 336 | |
Kyle Swenson | 1aa0e0d | 2021-03-18 14:20:24 -0600 | [diff] [blame] | 337 | if (pr->egress_mc_vlan_tag[i][0] == ECM_FRONT_END_VLAN_ID_NOT_CONFIGURED) { |
Suman Ghosh | a11fc92 | 2020-01-08 14:34:03 +0530 | [diff] [blame] | 338 | continue; |
| 339 | } |
| 340 | |
Kyle Swenson | 1aa0e0d | 2021-03-18 14:20:24 -0600 | [diff] [blame] | 341 | dev = dev_get_by_index(&init_net, pr->egress_netdev_index[i]); |
| 342 | if (dev) { |
| 343 | if ((result = ecm_state_write(sfi, "port_egress", "%s", dev->name))) { |
| 344 | dev_put(dev); |
| 345 | return result; |
| 346 | } |
| 347 | dev_put(dev); |
| 348 | } |
| 349 | |
| 350 | if ((result = ecm_state_write(sfi, "port_egress_vlan_tag[0]", "0x%x", pr->egress_mc_vlan_tag[i][0]))) { |
Suman Ghosh | a11fc92 | 2020-01-08 14:34:03 +0530 | [diff] [blame] | 351 | return result; |
| 352 | } |
| 353 | |
Kyle Swenson | 1aa0e0d | 2021-03-18 14:20:24 -0600 | [diff] [blame] | 354 | if (pr->egress_mc_vlan_tag[i][1] != ECM_FRONT_END_VLAN_ID_NOT_CONFIGURED) { |
| 355 | if ((result = ecm_state_write(sfi, "port_egress_vlan_tag[1]", "0x%x", pr->egress_mc_vlan_tag[i][1]))) { |
| 356 | return result; |
| 357 | } |
Suman Ghosh | a11fc92 | 2020-01-08 14:34:03 +0530 | [diff] [blame] | 358 | } |
| 359 | } |
| 360 | #endif |
Murat Sezgin | 964bfd8 | 2019-11-18 14:28:37 -0800 | [diff] [blame] | 361 | } |
| 362 | #endif |
| 363 | |
Gareth Williams | d5618a8 | 2015-05-20 11:13:32 +0100 | [diff] [blame] | 364 | if (pr->process_actions & ECM_CLASSIFIER_PROCESS_ACTION_QOS_TAG) { |
| 365 | if ((result = ecm_state_write(sfi, "flow_qos_tag", "%u", pr->flow_qos_tag))) { |
| 366 | return result; |
| 367 | } |
| 368 | if ((result = ecm_state_write(sfi, "return_qos_tag", "%u", pr->return_qos_tag))) { |
| 369 | return result; |
| 370 | } |
| 371 | } |
Kyle Swenson | 1aa0e0d | 2021-03-18 14:20:24 -0600 | [diff] [blame] | 372 | #ifdef ECM_CLASSIFIER_DSCP_ENABLE |
| 373 | #ifdef ECM_CLASSIFIER_DSCP_IGS |
Manish Verma | ed49378 | 2019-05-27 12:56:02 +0530 | [diff] [blame] | 374 | if (pr->process_actions & ECM_CLASSIFIER_PROCESS_ACTION_IGS_QOS_TAG) { |
| 375 | if ((result = ecm_state_write(sfi, "igs_flow_qos_tag", "%u", pr->igs_flow_qos_tag))) { |
| 376 | return result; |
| 377 | } |
| 378 | if ((result = ecm_state_write(sfi, "igs_return_qos_tag", "%u", pr->igs_return_qos_tag))) { |
| 379 | return result; |
| 380 | } |
| 381 | } |
Kyle Swenson | 1aa0e0d | 2021-03-18 14:20:24 -0600 | [diff] [blame] | 382 | #endif |
Gareth Williams | d5618a8 | 2015-05-20 11:13:32 +0100 | [diff] [blame] | 383 | if (pr->process_actions & ECM_CLASSIFIER_PROCESS_ACTION_DSCP) { |
| 384 | if ((result = ecm_state_write(sfi, "flow_dscp", "%u", pr->flow_dscp))) { |
| 385 | return result; |
| 386 | } |
| 387 | if ((result = ecm_state_write(sfi, "return_dscp", "%u", pr->return_dscp))) { |
| 388 | return result; |
| 389 | } |
| 390 | } |
| 391 | #endif |
Kyle Swenson | 1aa0e0d | 2021-03-18 14:20:24 -0600 | [diff] [blame] | 392 | |
Gareth Williams | d5618a8 | 2015-05-20 11:13:32 +0100 | [diff] [blame] | 393 | if (pr->process_actions & ECM_CLASSIFIER_PROCESS_ACTION_TIMER_GROUP) { |
| 394 | if ((result = ecm_state_write(sfi, "timer_group", "%d", pr->timer_group))) { |
| 395 | return result; |
| 396 | } |
| 397 | } |
| 398 | |
| 399 | return ecm_state_prefix_remove(sfi); |
Ben Menchaca | 84f3663 | 2014-02-28 20:57:38 +0000 | [diff] [blame] | 400 | } |
Gareth Williams | f98d419 | 2015-03-11 16:55:41 +0000 | [diff] [blame] | 401 | #endif |
| 402 | |
Murat Sezgin | c725ad8 | 2016-04-13 17:12:50 -0700 | [diff] [blame] | 403 | extern struct ecm_classifier_instance *ecm_classifier_assign_classifier(struct ecm_db_connection_instance *ci, ecm_classifier_type_t type); |
| 404 | extern bool ecm_classifier_reclassify(struct ecm_db_connection_instance *ci, int assignment_count, struct ecm_classifier_instance *assignments[]); |