|
| 1 | +# SAI TAM enhancements |
| 2 | +------------------------------------------------------------------------------- |
| 3 | + Title | SAI TAM enahncements |
| 4 | +-------------|----------------------------------------------------------------- |
| 5 | + Authors |<code> Rajkumar P R, Ganapathasaa K, Ravindranath C K (Marvell Technology Inc) </code> |
| 6 | + Status | In review |
| 7 | + Type | Standards track |
| 8 | + Created | 02/19/2025 |
| 9 | + |
| 10 | +------------------------------------------------------------------------------- |
| 11 | +## Overview |
| 12 | + |
| 13 | +This proposal enhances SAI TAM 2.0 by adding new reporting mode (sampling), a new transport type (GRE), header encapsulation attributes, and collector destination options (port/lag). |
| 14 | +Additionally, a new ACL action attribute is added to bind the TAM object to specific flow. |
| 15 | + |
| 16 | +## Requirements |
| 17 | +- Identify a flow using ACL and apply TAM action. |
| 18 | +- Support GRE transport type. |
| 19 | +- New TAM report modes and attributes to support the generation of report sampling. |
| 20 | +- Rate limit reports. |
| 21 | +- Support for missing collector attributes, such as source MAC, destination MAC (needed for GRE header encapsulation), and the destination interface to which reports are transmitted. |
| 22 | + |
| 23 | + |
| 24 | +## Report Format |
| 25 | + |
| 26 | +Example report generated with transport type GRE and vendor extension header. |
| 27 | +``` |
| 28 | + ------------------ |
| 29 | + | L2 | |
| 30 | + ------------------ |
| 31 | + | IPv4/IPv6 | |
| 32 | + ------------------ |
| 33 | + | GRE | |
| 34 | + ------------------ |
| 35 | + | Vendor hdr | |
| 36 | + ------------------ |
| 37 | + | Original pkt | |
| 38 | + | (Truncated) | |
| 39 | + ------------------ |
| 40 | + ``` |
| 41 | + |
| 42 | +### ACL action - TAM Object |
| 43 | +```c |
| 44 | ++ /** Bind a TAM object */ |
| 45 | ++ SAI_ACL_ACTION_TYPE_TAM_OBJECT = 0x0000003c, |
| 46 | + } sai_acl_action_type_t; |
| 47 | + |
| 48 | +``` |
| 49 | +```c |
| 50 | ++ /** |
| 51 | ++ * @brief ACL bind point for TAM object |
| 52 | ++ * |
| 53 | ++ * Bind (or unbind) a TAM object. |
| 54 | ++ * |
| 55 | ++ * @type sai_acl_action_data_t sai_object_id_t |
| 56 | ++ * @flags CREATE_AND_SET |
| 57 | ++ * @objects SAI_OBJECT_TYPE_TAM |
| 58 | ++ * @allownull true |
| 59 | ++ * @default disabled |
| 60 | ++ */ |
| 61 | ++ SAI_ACL_ENTRY_ATTR_ACTION_TAM_OBJECT = SAI_ACL_ENTRY_ATTR_ACTION_START + 0x3c, |
| 62 | ++ |
| 63 | ++ /** |
| 64 | ++ * @brief End of Rule Actions |
| 65 | ++ */ |
| 66 | ++ SAI_ACL_ENTRY_ATTR_ACTION_END = SAI_ACL_ENTRY_ATTR_ACTION_TAM_OBJECT, |
| 67 | + |
| 68 | +``` |
| 69 | +### TAM report mode |
| 70 | +#### Sampling |
| 71 | +Sending all the report events can overwhelm the collector. Sampling reduces the load on the collector by only sending |
| 72 | + 1 in every N events. |
| 73 | + |
| 74 | +```c |
| 75 | ++ /** Report in a sampling mode, one report is sent for every n reports */ |
| 76 | ++ SAI_TAM_REPORT_MODE_SAMPLING, |
| 77 | ++ |
| 78 | +``` |
| 79 | + |
| 80 | +### TAM report attributes |
| 81 | +```c |
| 82 | + |
| 83 | ++ /** |
| 84 | ++ * @brief Sampling rate (every 1/sample_rate) |
| 85 | ++ * |
| 86 | ++ * @type sai_uint32_t |
| 87 | ++ * @flags MANDATORY_ON_CREATE | CREATE_AND_SET |
| 88 | ++ * @condition SAI_TAM_REPORT_ATTR_REPORT_MODE == SAI_TAM_REPORT_MODE_SAMPLING |
| 89 | ++ */ |
| 90 | ++ SAI_TAM_REPORT_ATTR_SAMPLE_RATE, |
| 91 | ++ |
| 92 | ++ /** |
| 93 | ++ * @brief Maximum report rate per second |
| 94 | ++ * |
| 95 | ++ * Value 0 to no limit. |
| 96 | ++ * |
| 97 | ++ * @type sai_uint64_t |
| 98 | ++ * @flags CREATE_AND_SET |
| 99 | ++ * @default 0 |
| 100 | ++ * @validonly SAI_TAM_REPORT_ATTR_REPORT_MODE == SAI_TAM_REPORT_MODE_ALL |
| 101 | ++ */ |
| 102 | ++ SAI_TAM_REPORT_ATTR_MAX_REPORT_RATE, |
| 103 | ++ |
| 104 | ++ /** |
| 105 | ++ * @brief Maximum reports per burst |
| 106 | ++ * |
| 107 | ++ * @type sai_uint64_t |
| 108 | ++ * @flags CREATE_AND_SET |
| 109 | ++ * @default 0 |
| 110 | ++ * @validonly SAI_TAM_REPORT_ATTR_REPORT_MODE == SAI_TAM_REPORT_MODE_ALL |
| 111 | ++ */ |
| 112 | ++ SAI_TAM_REPORT_ATTR_MAX_REPORT_BURST, |
| 113 | + |
| 114 | +``` |
| 115 | +### TAM GRE transport type |
| 116 | +```c |
| 117 | ++ /** |
| 118 | ++ * @brief Transport GRE |
| 119 | ++ */ |
| 120 | ++ SAI_TAM_TRANSPORT_TYPE_GRE, |
| 121 | + |
| 122 | +} sai_tam_transport_type_t; |
| 123 | +``` |
| 124 | + |
| 125 | +### TAM transport attribute to set gre protocol |
| 126 | +```c |
| 127 | ++ /** |
| 128 | ++ * @brief GRE protocol Id |
| 129 | ++ * |
| 130 | ++ * @type sai_uint16_t |
| 131 | ++ * @flags MANDATORY_ON_CREATE | CREATE_AND_SET |
| 132 | ++ * @isvlan false |
| 133 | ++ * @condition SAI_TAM_TRANSPORT_ATTR_TRANSPORT_TYPE == SAI_TAM_TRANSPORT_TYPE_GRE |
| 134 | ++ */ |
| 135 | ++ SAI_TAM_TRANSPORT_ATTR_GRE_PROTOCOL_TYPE, |
| 136 | + |
| 137 | +``` |
| 138 | + |
| 139 | +### TAM collector attributes |
| 140 | +TAM collector is reachable via Desitination interface. |
| 141 | + |
| 142 | +```c |
| 143 | ++ /** |
| 144 | ++ * @brief Source MAC address |
| 145 | ++ * |
| 146 | ++ * Note: Applicable only when SAI_TAM_TRANSPORT_ATTR_TRANSPORT_TYPE != SAI_TAM_TRANSPORT_TYPE_NONE |
| 147 | ++ * |
| 148 | ++ * @type sai_mac_t |
| 149 | ++ * @flags CREATE_AND_SET |
| 150 | ++ * @default vendor |
| 151 | ++ */ |
| 152 | ++ SAI_TAM_COLLECTOR_ATTR_SRC_MAC, |
| 153 | ++ |
| 154 | ++ /** |
| 155 | ++ * @brief Destination MAC address |
| 156 | ++ * |
| 157 | ++ * Note: Applicable only when SAI_TAM_TRANSPORT_ATTR_TRANSPORT_TYPE != SAI_TAM_TRANSPORT_TYPE_NONE |
| 158 | ++ * |
| 159 | ++ * @type sai_mac_t |
| 160 | ++ * @flags CREATE_AND_SET |
| 161 | ++ * @default vendor |
| 162 | ++ */ |
| 163 | ++ SAI_TAM_COLLECTOR_ATTR_DST_MAC, |
| 164 | ++ |
| 165 | ++ /** |
| 166 | ++ * @brief Destination used to reach collector |
| 167 | ++ * |
| 168 | ++ * @type sai_object_id_t |
| 169 | ++ * @flags CREATE_AND_SET |
| 170 | ++ * @objects SAI_OBJECT_TYPE_PORT, SAI_OBJECT_TYPE_LAG, SAI_OBJECT_TYPE_SYSTEM_PORT |
| 171 | ++ * @allownull true |
| 172 | ++ * @default SAI_NULL_OBJECT_ID |
| 173 | ++ * @validonly SAI_TAM_COLLECTOR_ATTR_LOCALHOST == false |
| 174 | ++ */ |
| 175 | ++ SAI_TAM_COLLECTOR_ATTR_DESTINATION, |
| 176 | + |
| 177 | +``` |
| 178 | + |
| 179 | +## Sample workflow |
| 180 | +1. Create Transport object of type GRE |
| 181 | + |
| 182 | +```c |
| 183 | + count = 0; |
| 184 | + attr_list[count].id = SAI_TAM_TRANSPORT_ATTR_TRANSPORT_TYPE; |
| 185 | + attr_list[count].value.s32 = SAI_TAM_TRANSPORT_TYPE_GRE; |
| 186 | + count++; |
| 187 | + attr_list[count].id = SAI_TAM_TRANSPORT_ATTR_GRE_PROTOCOL_TYPE; |
| 188 | + attr_list[count].value.u16 = 0x8818; |
| 189 | + count++; |
| 190 | + |
| 191 | + rc = tam_api_p->create_tam_transport(&tam_transport_id, switch_id, count, attr_list); |
| 192 | + ASSERT_EQ(SAI_STATUS_SUCCESS, rc); |
| 193 | + |
| 194 | +``` |
| 195 | +2. Create a Collector object |
| 196 | +```c |
| 197 | + count = 0; |
| 198 | + memset(attr_list, 0, sizeof(attr_list)); |
| 199 | + attr_list[count].id = SAI_TAM_COLLECTOR_ATTR_TRANSPORT; |
| 200 | + attr_list[count].value.oid = tam_transport_id; |
| 201 | + count++; |
| 202 | + attr_list[count].id = SAI_TAM_COLLECTOR_ATTR_LOCALHOST; |
| 203 | + attr_list[count].value.oid = false; |
| 204 | + count++; |
| 205 | + attr_list[count].id = SAI_TAM_COLLECTOR_ATTR_SRC_IP; |
| 206 | + attr_list[count].value.ipaddr.addr_family = SAI_IP_ADDR_FAMILY_IPV4; |
| 207 | + attr_list[count].value.ipaddr.addr.ip4 = 0x0101010a; |
| 208 | + count++; |
| 209 | + attr_list[count].id = SAI_TAM_COLLECTOR_ATTR_SRC_MAC; |
| 210 | + memcpy(&attr_list[count].value.mac, &smac, sizeof(sai_mac_t)); |
| 211 | + count++; |
| 212 | +
|
| 213 | + attr_list[count].id = SAI_TAM_COLLECTOR_ATTR_DST_IP; |
| 214 | + attr_list[count].value.ipaddr.addr_family = SAI_IP_ADDR_FAMILY_IPV4; |
| 215 | + attr_list[count].value.ipaddr.addr.ip4 = 0x0101010b; |
| 216 | + count++; |
| 217 | + attr_list[count].id = SAI_TAM_COLLECTOR_ATTR_DST_MAC; |
| 218 | + memcpy(&attr_list[count].value.mac, &dmac, sizeof(sai_mac_t)); |
| 219 | + count++; |
| 220 | + attr_list[count].id = SAI_TAM_COLLECTOR_ATTR_DESTINATION; |
| 221 | + attr_list[count].value.oid = port2_oid; |
| 222 | + count++; |
| 223 | + attr_list[count].id = SAI_TAM_COLLECTOR_ATTR_DSCP_VALUE; |
| 224 | + attr_list[count].value.u8 = 8; |
| 225 | + count++; |
| 226 | +
|
| 227 | + rc = tam_api_p->create_tam_collector(&tam_collector_id, switch_id, count, attr_list); |
| 228 | +
|
| 229 | +``` |
| 230 | +3. Create a report object in sampling mode |
| 231 | +```c |
| 232 | + count = 0; |
| 233 | + memset(attr_list, 0, sizeof(attr_list)); |
| 234 | + |
| 235 | + attr_list[count].id = SAI_TAM_REPORT_ATTR_TYPE; |
| 236 | + attr_list[count].value.s32 = SAI_TAM_REPORT_TYPE_VENDOR_EXTN; |
| 237 | + count++; |
| 238 | + |
| 239 | + attr_list[count].id = SAI_TAM_REPORT_ATTR_REPORT_MODE; |
| 240 | + attr_list[count].value.s32 = SAI_TAM_REPORT_MODE_SAMPLING; |
| 241 | + count++; |
| 242 | + attr_list[count].id = SAI_TAM_REPORT_ATTR_SAMPLE_RATE; |
| 243 | + attr_list[count].value.u32 = 1000; |
| 244 | + count++; |
| 245 | + rc = tam_api_p->create_tam_report(&tam_report_id, switch_id, count, attr_list); |
| 246 | +``` |
| 247 | +4. Create event threshold object |
| 248 | +```c |
| 249 | + count = 0; |
| 250 | + memset(attr_list, 0, sizeof(attr_list)); |
| 251 | +
|
| 252 | + attr_list[count].id = SAI_TAM_EVENT_THRESHOLD_ATTR_LATENCY; |
| 253 | + attr_list[count].value.u32 = 8000; //nsec |
| 254 | + count++; |
| 255 | +
|
| 256 | + rc = tam_api_p->create_tam_event_threshold(&tam_event_threshold_id, switch_id, count, attr_list); |
| 257 | +
|
| 258 | +``` |
| 259 | +5. Create an event action object |
| 260 | +```c |
| 261 | + count = 0; |
| 262 | + memset(attr_list, 0, sizeof(attr_list)); |
| 263 | + |
| 264 | + attr_list[count].id = SAI_TAM_EVENT_ACTION_ATTR_REPORT_TYPE; |
| 265 | + attr_list[count].value.oid = tam_report_id; |
| 266 | + count++; |
| 267 | + |
| 268 | + rc = tam_api_p->create_tam_event_action(&tam_event_action_id, switch_id, count, attr_list); |
| 269 | + |
| 270 | +``` |
| 271 | +6. Create a tam event object |
| 272 | +```c |
| 273 | + count = 0; |
| 274 | + memset(attr_list, 0, sizeof(attr_list)); |
| 275 | +
|
| 276 | + attr_list[count].id = SAI_TAM_EVENT_ATTR_TYPE; |
| 277 | + attr_list[count].value.s32 = SAI_TAM_EVENT_TYPE_QUEUE_THRESHOLD; |
| 278 | + count++; |
| 279 | +
|
| 280 | + attr_list[count].id = SAI_TAM_EVENT_ATTR_ACTION_LIST; |
| 281 | +
|
| 282 | + attr_list[count].value.objlist.count = 1; |
| 283 | + attr_list[count].value.objlist.list = (sai_object_id_t *)malloc(1*sizeof(sai_object_id_t)); |
| 284 | + attr_list[count].value.objlist.list[0] = tam_event_action_id; |
| 285 | + count++; |
| 286 | +
|
| 287 | + attr_list[count].id = SAI_TAM_EVENT_ATTR_COLLECTOR_LIST; |
| 288 | + attr_list[count].value.objlist.count = 1; |
| 289 | + attr_list[count].value.objlist.list = (sai_object_id_t *)malloc(1*sizeof(sai_object_id_t)); |
| 290 | + attr_list[count].value.objlist.list[0] = tam_collector_id; |
| 291 | + count++; |
| 292 | +
|
| 293 | + attr_list[count].id = SAI_TAM_EVENT_ATTR_THRESHOLD; |
| 294 | + attr_list[count].value.oid = tam_event_threshold_id; |
| 295 | + count++; |
| 296 | +
|
| 297 | + rc = tam_api_p->create_tam_event(&tam_event_id, switch_id, count, attr_list); |
| 298 | +``` |
| 299 | +7. Create a TAM object |
| 300 | +```c |
| 301 | + count = 0; |
| 302 | + memset(attr_list, 0, sizeof(attr_list)); |
| 303 | + |
| 304 | + attr_list[count].id = SAI_TAM_ATTR_EVENT_OBJECTS_LIST; |
| 305 | + attr_list[count].value.objlist.count = 1; |
| 306 | + attr_list[count].value.objlist.list = (sai_object_id_t *)malloc(1*sizeof(sai_object_id_t)); |
| 307 | + attr_list[count].value.objlist.list[0] = tam_event_id; |
| 308 | + count++; |
| 309 | + |
| 310 | + attr_list[count].id = SAI_TAM_ATTR_TAM_BIND_POINT_TYPE_LIST; |
| 311 | + attr_list[count].value.objlist.count = 2; |
| 312 | + attr_list[count].value.objlist.list = (sai_object_id_t *)malloc(2*sizeof(sai_object_id_t)); |
| 313 | + attr_list[count].value.objlist.list[0] = SAI_TAM_BIND_POINT_TYPE_SWITCH; |
| 314 | + count++; |
| 315 | + |
| 316 | + rc = tam_api_p->create_tam(&tam_id, switch_id, count, attr_list); |
| 317 | +``` |
| 318 | +
|
| 319 | +8. Apply a TAM policy to an ACL flow. |
| 320 | +
|
| 321 | +```c |
| 322 | + bindpoint_type_arr[arr_idx++] = SAI_ACL_BIND_POINT_TYPE_SWITCH; |
| 323 | + sai_bindpoint_type_list.list = bindpoint_type_arr; |
| 324 | + sai_bindpoint_type_list.count = arr_idx; |
| 325 | +
|
| 326 | + ... |
| 327 | +
|
| 328 | + attr_list[count].value.s32list = sai_bindpoint_type_list; |
| 329 | + attr_list[count].id = SAI_ACL_TABLE_ATTR_ACL_BIND_POINT_TYPE_LIST; |
| 330 | + count++; |
| 331 | +
|
| 332 | + attr_list[count].id = SAI_ACL_TABLE_ATTR_FIELD_SRC_IP; |
| 333 | + attr_list[count].value.booldata = true; |
| 334 | + count++; |
| 335 | +
|
| 336 | + attr_list[count].id = SAI_ACL_TABLE_ATTR_ACL_ACTION_TYPE_LIST; |
| 337 | + attr_list[count].value.s32list.list = action_list; |
| 338 | + action_list[action_count++] = SAI_ACL_ACTION_TYPE_TAM_OBJECT; |
| 339 | + attr_list[count].value.s32list.count = action_count; |
| 340 | + count++; |
| 341 | +
|
| 342 | + rc = acl_api_p->create_acl_table(&acl_table_oid, switch_id, count, attr_list); |
| 343 | +
|
| 344 | + count = 0; |
| 345 | + memset(attr_list, 0, sizeof(attr_list)); |
| 346 | +
|
| 347 | + attr_list[count].id = SAI_ACL_ENTRY_ATTR_TABLE_ID; |
| 348 | + attr_list[count].value.oid = acl_table_oid; |
| 349 | + count++; |
| 350 | +
|
| 351 | + attr_list[count].id = SAI_ACL_ENTRY_ATTR_PRIORITY; |
| 352 | + attr_list[count].value.u32 = 0xFFFFFFFF; |
| 353 | + count++; |
| 354 | +
|
| 355 | + attr_list[count].id = SAI_ACL_ENTRY_ATTR_FIELD_SRC_IP; |
| 356 | + attr_list[count].value.aclfield.enable = true; |
| 357 | + attr_list[count].value.aclfield.data.ip4 = 0x01010101; |
| 358 | + attr_list[count].value.aclfield.mask.ip4 = 0xFFFF0000; |
| 359 | + count++; |
| 360 | +
|
| 361 | + attr_list[count].id = SAI_ACL_ENTRY_ATTR_ACTION_TAM_OBJECT; |
| 362 | + attr_list[count].value.aclaction.parameter.oid = tam_id; |
| 363 | + attr_list[count].value.aclaction.enable= true; |
| 364 | + count++; |
| 365 | +
|
| 366 | + rc = acl_api_p->create_acl_entry(&acl_entry_oid, switch_id, count, attr_list); |
| 367 | +``` |
| 368 | + |
| 369 | +#### Rate limit tam reports |
| 370 | +Example flow to create tam report object with rate limit configurations. |
| 371 | +Replace above step (3) with below api sequence. |
| 372 | +```c |
| 373 | + count = 0; |
| 374 | + memset(attr_list, 0, sizeof(attr_list)); |
| 375 | + |
| 376 | + attr_list[count].id = SAI_TAM_REPORT_ATTR_TYPE; |
| 377 | + attr_list[count].value.s32 = SAI_TAM_REPORT_TYPE_VENDOR_EXTN; |
| 378 | + count++; |
| 379 | + |
| 380 | + attr_list[count].id = SAI_TAM_REPORT_ATTR_REPORT_MODE; |
| 381 | + attr_list[count].value.s32 = SAI_TAM_REPORT_MODE_ALL; |
| 382 | + count++; |
| 383 | + attr_list[count].id = SAI_TAM_REPORT_ATTR_MAX_REPORT_RATE; |
| 384 | + attr_list[count].value.u32 = 512; |
| 385 | + count++; |
| 386 | + |
| 387 | + attr_list[count].id = SAI_TAM_REPORT_ATTR_MAX_REPORT_BURST; |
| 388 | + attr_list[count].value.u32 = 1024; |
| 389 | + count++; |
| 390 | + rc = tam_api_p->create_tam_report(&tam_report_id, switch_id, count, attr_list); |
| 391 | +``` |
0 commit comments