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