ft_pack.c (27836B)
1 /* 2 * 3 * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. 4 * 5 * Copyright 2007-2019 Broadcom Inc. All rights reserved. 6 * 7 * File: ft_pack.c 8 * Purpose: FT pack and unpack routines for: 9 * - FT Control messages 10 * 11 * 12 * FT control messages 13 * 14 * FT messages between the Host CPU and uController are sent 15 * using the uc_message module which allows short messages 16 * to be passed (see include/soc/shared/mos_msg_common.h) 17 * 18 * Additional information for a given message (a long message) is passed 19 * using DMA. The FT control message types defines the format 20 * for these long messages. 21 * 22 * This file is shared between SDK and uKernel. 23 */ 24 25 #include <shared/pack.h> 26 #include <soc/shared/ft.h> 27 #include <soc/shared/ft_msg.h> 28 #include <soc/shared/ft_pack.h> 29 30 /* 31 * This is the SDK's messaging version when compiling for uKernel and the 32 * uKernel's msg version when compiling for SDK 33 */ 34 uint32 ft_msg_version = 0; 35 36 /* 37 * FT Initialization control message packing 38 */ 39 uint8* 40 shr_ft_msg_ctrl_init_pack(uint8 *buf, shr_ft_msg_ctrl_init_t *msg) 41 { 42 int i, j; 43 44 _SHR_PACK_U32(buf, msg->flags); 45 _SHR_PACK_U32(buf, msg->max_groups); 46 47 _SHR_PACK_U8(buf, msg->num_pipes); 48 49 for (i = 0; i < msg->num_pipes; i++) { 50 _SHR_PACK_U32(buf, msg->pipe[i].max_flows); 51 52 _SHR_PACK_U8(buf, msg->pipe[i].num_ctr_pools); 53 for (j = 0; j < msg->pipe[i].num_ctr_pools; j++) { 54 _SHR_PACK_U8(buf, msg->pipe[i].ctr_pools[j]); 55 _SHR_PACK_U16(buf, msg->pipe[i].ctr_pool_size[j]); 56 } 57 } 58 59 _SHR_PACK_U32(buf, msg->rx_channel); 60 _SHR_PACK_U16(buf, msg->max_export_pkt_length); 61 _SHR_PACK_U32(buf, msg->cur_time_secs); 62 63 _SHR_PACK_U32(buf, msg->export_interval_msecs); 64 _SHR_PACK_U32(buf, msg->scan_interval_usecs); 65 _SHR_PACK_U32(buf, msg->age_timer_tick_msecs); 66 67 _SHR_PACK_U8(buf, msg->num_elph_profiles); 68 69 if (ft_msg_version >= FT_MSG_VERSION_1) { 70 _SHR_PACK_U16(buf, msg->fsp_reinject_max_length); 71 } 72 73 return buf; 74 } 75 76 /* 77 * FT Initialization control message 78 */ 79 uint8* 80 shr_ft_msg_ctrl_init_unpack(uint8 *buf, shr_ft_msg_ctrl_init_t *msg) 81 { 82 int i, j; 83 84 _SHR_UNPACK_U32(buf, msg->flags); 85 _SHR_UNPACK_U32(buf, msg->max_groups); 86 87 _SHR_UNPACK_U8(buf, msg->num_pipes); 88 89 for (i = 0; i < msg->num_pipes; i++) { 90 _SHR_UNPACK_U32(buf, msg->pipe[i].max_flows); 91 92 _SHR_UNPACK_U8(buf, msg->pipe[i].num_ctr_pools); 93 for (j = 0; j < msg->pipe[i].num_ctr_pools; j++) { 94 _SHR_UNPACK_U8(buf, msg->pipe[i].ctr_pools[j]); 95 _SHR_UNPACK_U16(buf, msg->pipe[i].ctr_pool_size[j]); 96 } 97 } 98 99 _SHR_UNPACK_U32(buf, msg->rx_channel); 100 _SHR_UNPACK_U16(buf, msg->max_export_pkt_length); 101 _SHR_UNPACK_U32(buf, msg->cur_time_secs); 102 103 _SHR_UNPACK_U32(buf, msg->export_interval_msecs); 104 _SHR_UNPACK_U32(buf, msg->scan_interval_usecs); 105 _SHR_UNPACK_U32(buf, msg->age_timer_tick_msecs); 106 107 _SHR_UNPACK_U8(buf, msg->num_elph_profiles); 108 109 if (ft_msg_version >= FT_MSG_VERSION_1) { 110 _SHR_UNPACK_U16(buf, msg->fsp_reinject_max_length); 111 } 112 113 return buf; 114 } 115 116 /* 117 * EM key format export pack 118 */ 119 uint8* 120 shr_ft_msg_ctrl_em_key_format_pack(uint8 *buf, 121 shr_ft_msg_ctrl_em_key_format_t *msg) 122 { 123 int i, j; 124 125 126 _SHR_PACK_U16(buf, msg->key_size); 127 _SHR_PACK_U8(buf, msg->num_qual); 128 for (i = 0; i < msg->num_qual; i++) { 129 _SHR_PACK_U8(buf, msg->qual[i]); 130 _SHR_PACK_U8(buf, msg->qual_parts[i].num_parts); 131 132 for (j = 0; j < msg->qual_parts[i].num_parts; j++) { 133 _SHR_PACK_U16(buf, msg->qual_parts[i].offset[j]); 134 _SHR_PACK_U8(buf, msg->qual_parts[i].width[j]); 135 } 136 } 137 138 return buf; 139 } 140 141 /* 142 * EM group create - pack 143 */ 144 uint8* 145 shr_ft_msg_ctrl_em_group_create_pack(uint8 *buf, 146 shr_ft_msg_ctrl_em_group_create_t *msg) 147 { 148 int i, j; 149 150 _SHR_PACK_U8(buf, msg->group_idx); 151 _SHR_PACK_U8(buf, msg->num_pipes); 152 for (i = 0; i < msg->num_pipes; i++) { 153 _SHR_PACK_U8(buf, msg->lt_id[i]); 154 } 155 _SHR_PACK_U32(buf, msg->aset); 156 _SHR_PACK_U16(buf, msg->key_size); 157 _SHR_PACK_U8(buf, msg->num_qual); 158 for (i = 0; i < msg->num_qual; i++) { 159 _SHR_PACK_U8(buf, msg->qual_info[i].qual); 160 _SHR_PACK_U8(buf, msg->qual_info[i].num_parts); 161 162 for (j = 0; j < msg->qual_info[i].num_parts; j++) { 163 _SHR_PACK_U16(buf, msg->qual_info[i].part_offset[j]); 164 _SHR_PACK_U8(buf, msg->qual_info[i].part_width[j]); 165 } 166 167 _SHR_PACK_U16(buf, msg->qual_info[i].width); 168 _SHR_PACK_U8(buf, msg->qual_info[i].base_offset); 169 _SHR_PACK_U8(buf, msg->qual_info[i].relative_offset); 170 } 171 172 _SHR_PACK_U8(buf, msg->num_tp); 173 for (i = 0; i < msg->num_tp; i++) { 174 _SHR_PACK_U8(buf, msg->tp_info[i].param); 175 _SHR_PACK_U8(buf, msg->tp_info[i].num_qual); 176 _SHR_PACK_U8(buf, msg->tp_info[i].udf); 177 for (j = 0; j < msg->tp_info[i].num_qual; j++) { 178 _SHR_PACK_U8(buf, msg->tp_info[i].qual[j]); 179 } 180 } 181 182 return buf; 183 } 184 185 /* 186 * EM group create - unpack 187 */ 188 uint8* 189 shr_ft_msg_ctrl_em_group_create_unpack(uint8 *buf, 190 shr_ft_msg_ctrl_em_group_create_t *msg) 191 { 192 int i, j; 193 194 _SHR_UNPACK_U8(buf, msg->group_idx); 195 _SHR_UNPACK_U8(buf, msg->num_pipes); 196 for (i = 0; i < msg->num_pipes; i++) { 197 _SHR_UNPACK_U8(buf, msg->lt_id[i]); 198 } 199 _SHR_UNPACK_U32(buf, msg->aset); 200 _SHR_UNPACK_U16(buf, msg->key_size); 201 _SHR_UNPACK_U8(buf, msg->num_qual); 202 for (i = 0; i < msg->num_qual; i++) { 203 _SHR_UNPACK_U8(buf, msg->qual_info[i].qual); 204 _SHR_UNPACK_U8(buf, msg->qual_info[i].num_parts); 205 206 for (j = 0; j < msg->qual_info[i].num_parts; j++) { 207 _SHR_UNPACK_U16(buf, msg->qual_info[i].part_offset[j]); 208 _SHR_UNPACK_U8(buf, msg->qual_info[i].part_width[j]); 209 } 210 211 _SHR_UNPACK_U16(buf, msg->qual_info[i].width); 212 _SHR_UNPACK_U8(buf, msg->qual_info[i].base_offset); 213 _SHR_UNPACK_U8(buf, msg->qual_info[i].relative_offset); 214 } 215 216 _SHR_UNPACK_U8(buf, msg->num_tp); 217 for (i = 0; i < msg->num_tp; i++) { 218 _SHR_UNPACK_U8(buf, msg->tp_info[i].param); 219 _SHR_UNPACK_U8(buf, msg->tp_info[i].num_qual); 220 _SHR_UNPACK_U8(buf, msg->tp_info[i].udf); 221 for (j = 0; j < msg->tp_info[i].num_qual; j++) { 222 _SHR_UNPACK_U8(buf, msg->tp_info[i].qual[j]); 223 } 224 } 225 226 return buf; 227 } 228 229 /* 230 * EM key format export unpack 231 */ 232 uint8* 233 shr_ft_msg_ctrl_em_key_format_unpack(uint8 *buf, 234 shr_ft_msg_ctrl_em_key_format_t *msg) 235 { 236 int i, j; 237 238 239 _SHR_UNPACK_U16(buf, msg->key_size); 240 _SHR_UNPACK_U8(buf, msg->num_qual); 241 for (i = 0; i < msg->num_qual; i++) { 242 _SHR_UNPACK_U8(buf, msg->qual[i]); 243 _SHR_UNPACK_U8(buf, msg->qual_parts[i].num_parts); 244 245 for (j = 0; j < msg->qual_parts[i].num_parts; j++) { 246 _SHR_UNPACK_U16(buf, msg->qual_parts[i].offset[j]); 247 _SHR_UNPACK_U8(buf, msg->qual_parts[i].width[j]); 248 } 249 } 250 251 return buf; 252 } 253 254 /* 255 * Group create pack 256 */ 257 uint8* 258 shr_ft_msg_ctrl_group_create_pack(uint8 *buf, 259 shr_ft_msg_ctrl_group_create_t *msg) 260 { 261 _SHR_PACK_U16(buf, msg->group_idx); 262 _SHR_PACK_U32(buf, msg->flags); 263 _SHR_PACK_U32(buf, msg->flow_limit); 264 _SHR_PACK_U32(buf, msg->aging_interval_msecs); 265 _SHR_PACK_U32(buf, msg->domain_id); 266 267 return buf; 268 } 269 270 /* 271 * Group create unpack 272 */ 273 uint8* 274 shr_ft_msg_ctrl_group_create_unpack(uint8 *buf, 275 shr_ft_msg_ctrl_group_create_t *msg) 276 { 277 _SHR_UNPACK_U16(buf, msg->group_idx); 278 _SHR_UNPACK_U32(buf, msg->flags); 279 _SHR_UNPACK_U32(buf, msg->flow_limit); 280 _SHR_UNPACK_U32(buf, msg->aging_interval_msecs); 281 _SHR_UNPACK_U32(buf, msg->domain_id); 282 283 return buf; 284 } 285 286 /* 287 * Group get pack 288 */ 289 uint8* 290 shr_ft_msg_ctrl_group_get_pack(uint8* buf, shr_ft_msg_ctrl_group_get_t *msg) 291 { 292 _SHR_PACK_U16(buf, msg->group_idx); 293 _SHR_PACK_U32(buf, msg->flags); 294 _SHR_PACK_U32(buf, msg->flow_limit); 295 _SHR_PACK_U32(buf, msg->flow_count); 296 _SHR_PACK_U32(buf, msg->domain_id); 297 _SHR_PACK_U32(buf, msg->aging_interval); 298 _SHR_PACK_U16(buf, msg->elph_profile_id); 299 _SHR_PACK_U16(buf, msg->qos_profile_id); 300 _SHR_PACK_U16(buf, msg->collector_id); 301 _SHR_PACK_U16(buf, msg->template_id); 302 303 return buf; 304 } 305 306 /* 307 * Group get unpack 308 */ 309 uint8* 310 shr_ft_msg_ctrl_group_get_unpack(uint8* buf, shr_ft_msg_ctrl_group_get_t *msg) 311 { 312 _SHR_UNPACK_U16(buf, msg->group_idx); 313 _SHR_UNPACK_U32(buf, msg->flags); 314 _SHR_UNPACK_U32(buf, msg->flow_limit); 315 _SHR_UNPACK_U32(buf, msg->flow_count); 316 _SHR_UNPACK_U32(buf, msg->domain_id); 317 _SHR_UNPACK_U32(buf, msg->aging_interval); 318 _SHR_UNPACK_U16(buf, msg->elph_profile_id); 319 _SHR_UNPACK_U16(buf, msg->qos_profile_id); 320 _SHR_UNPACK_U16(buf, msg->collector_id); 321 _SHR_UNPACK_U16(buf, msg->template_id); 322 323 return buf; 324 } 325 326 327 /* 328 * Group update pack 329 */ 330 uint8* 331 shr_ft_msg_ctrl_group_update_pack(uint8* buf, 332 shr_ft_msg_ctrl_group_update_t *msg) 333 { 334 _SHR_PACK_U16(buf, msg->group_idx); 335 _SHR_PACK_U32(buf, msg->flags); 336 _SHR_PACK_U32(buf, msg->update); 337 _SHR_PACK_U32(buf, msg->param0); 338 339 return buf; 340 } 341 342 /* 343 * Group update unpack 344 */ 345 uint8* 346 shr_ft_msg_ctrl_group_update_unpack(uint8* buf, 347 shr_ft_msg_ctrl_group_update_t *msg) 348 { 349 _SHR_UNPACK_U16(buf, msg->group_idx); 350 _SHR_UNPACK_U32(buf, msg->flags); 351 _SHR_UNPACK_U32(buf, msg->update); 352 _SHR_UNPACK_U32(buf, msg->param0); 353 354 return buf; 355 } 356 357 /* 358 * Create IPFIX template - pack 359 */ 360 uint8* 361 shr_ft_msg_ctrl_template_create_pack(uint8* buf, shr_ft_msg_ctrl_template_create_t *msg) 362 { 363 int i; 364 365 _SHR_PACK_U16(buf, msg->id); 366 _SHR_PACK_U32(buf, msg->flags); 367 _SHR_PACK_U16(buf, msg->set_id); 368 369 _SHR_PACK_U8(buf, msg->num_info_elems); 370 for (i = 0; i < msg->num_info_elems; i++) { 371 _SHR_PACK_U8(buf, msg->info_elems[i]); 372 _SHR_PACK_U16(buf, msg->data_size[i]); 373 } 374 375 return buf; 376 } 377 378 /* 379 * Create IPFIX template - unpack 380 */ 381 uint8* 382 shr_ft_msg_ctrl_template_create_unpack(uint8* buf, shr_ft_msg_ctrl_template_create_t *msg) 383 { 384 int i; 385 386 _SHR_UNPACK_U16(buf, msg->id); 387 _SHR_UNPACK_U32(buf, msg->flags); 388 _SHR_UNPACK_U16(buf, msg->set_id); 389 390 _SHR_UNPACK_U8(buf, msg->num_info_elems); 391 for (i = 0; i < msg->num_info_elems; i++) { 392 _SHR_UNPACK_U8(buf, msg->info_elems[i]); 393 _SHR_UNPACK_U16(buf, msg->data_size[i]); 394 } 395 396 return buf; 397 } 398 399 /* 400 * Get IPFIX template - pack 401 */ 402 uint8* 403 shr_ft_msg_ctrl_template_get_pack(uint8* buf, shr_ft_msg_ctrl_template_get_t *msg) 404 { 405 int i; 406 407 _SHR_PACK_U16(buf, msg->id); 408 _SHR_PACK_U32(buf, msg->flags); 409 _SHR_PACK_U16(buf, msg->set_id); 410 411 _SHR_PACK_U8(buf, msg->num_info_elems); 412 for (i = 0; i < msg->num_info_elems; i++) { 413 _SHR_PACK_U8(buf, msg->info_elems[i]); 414 _SHR_PACK_U16(buf, msg->data_size[i]); 415 } 416 417 return buf; 418 } 419 420 /* 421 * Get IPFIX template - unpack 422 */ 423 uint8* 424 shr_ft_msg_ctrl_template_get_unpack(uint8* buf, shr_ft_msg_ctrl_template_get_t *msg) 425 { 426 int i; 427 428 _SHR_UNPACK_U16(buf, msg->id); 429 _SHR_UNPACK_U32(buf, msg->flags); 430 _SHR_UNPACK_U16(buf, msg->set_id); 431 432 _SHR_UNPACK_U8(buf, msg->num_info_elems); 433 for (i = 0; i < msg->num_info_elems; i++) { 434 _SHR_UNPACK_U8(buf, msg->info_elems[i]); 435 _SHR_UNPACK_U16(buf, msg->data_size[i]); 436 } 437 438 return buf; 439 } 440 441 /* 442 * Create collector - pack 443 */ 444 uint8* 445 shr_ft_msg_ctrl_collector_create_pack(uint8* buf, shr_ft_msg_ctrl_collector_create_t *msg) 446 { 447 int i; 448 449 _SHR_PACK_U16(buf, msg->id); 450 _SHR_PACK_U32(buf, msg->flags); 451 _SHR_PACK_U16(buf, msg->encap_length); 452 453 for (i = 0; i < msg->encap_length; i++) { 454 _SHR_PACK_U8(buf, msg->encap[i]); 455 } 456 457 _SHR_PACK_U16(buf, msg->mtu); 458 _SHR_PACK_U32(buf, msg->ip_base_checksum); 459 _SHR_PACK_U32(buf, msg->udp_base_checksum); 460 _SHR_PACK_U16(buf, msg->ip_offset); 461 _SHR_PACK_U16(buf, msg->udp_offset); 462 463 if (ft_msg_version >= FT_MSG_VERSION_1) { 464 _SHR_PACK_U32(buf, msg->component_id); 465 _SHR_PACK_U16(buf, msg->system_id_length); 466 for (i = 0; i < msg->system_id_length; i++) { 467 _SHR_PACK_U8(buf, msg->system_id[i]); 468 } 469 } 470 return buf; 471 } 472 473 /* 474 * Create collector - unpack 475 */ 476 uint8* 477 shr_ft_msg_ctrl_collector_create_unpack(uint8* buf, shr_ft_msg_ctrl_collector_create_t *msg) 478 { 479 int i; 480 481 _SHR_UNPACK_U16(buf, msg->id); 482 _SHR_UNPACK_U32(buf, msg->flags); 483 _SHR_UNPACK_U16(buf, msg->encap_length); 484 485 for (i = 0; i < msg->encap_length; i++) { 486 _SHR_UNPACK_U8(buf, msg->encap[i]); 487 } 488 489 _SHR_UNPACK_U16(buf, msg->mtu); 490 _SHR_UNPACK_U32(buf, msg->ip_base_checksum); 491 _SHR_UNPACK_U32(buf, msg->udp_base_checksum); 492 _SHR_UNPACK_U16(buf, msg->ip_offset); 493 _SHR_UNPACK_U16(buf, msg->udp_offset); 494 495 if (ft_msg_version >= FT_MSG_VERSION_1) { 496 _SHR_UNPACK_U32(buf, msg->component_id); 497 _SHR_UNPACK_U16(buf, msg->system_id_length); 498 for (i = 0; i < msg->system_id_length; i++) { 499 _SHR_UNPACK_U8(buf, msg->system_id[i]); 500 } 501 } 502 503 return buf; 504 } 505 506 /* 507 * Get collector - pack 508 */ 509 uint8* 510 shr_ft_msg_ctrl_collector_get_pack(uint8* buf, shr_ft_msg_ctrl_collector_get_t *msg) 511 { 512 int i; 513 514 _SHR_PACK_U16(buf, msg->id); 515 _SHR_PACK_U32(buf, msg->flags); 516 _SHR_PACK_U16(buf, msg->encap_length); 517 518 for (i = 0; i < msg->encap_length; i++) { 519 _SHR_PACK_U8(buf, msg->encap[i]); 520 } 521 522 _SHR_PACK_U16(buf, msg->mtu); 523 _SHR_PACK_U16(buf, msg->ip_base_checksum); 524 _SHR_PACK_U16(buf, msg->udp_base_checksum); 525 _SHR_PACK_U16(buf, msg->ip_offset); 526 _SHR_PACK_U16(buf, msg->udp_offset); 527 528 if (ft_msg_version >= FT_MSG_VERSION_1) { 529 _SHR_PACK_U32(buf, msg->component_id); 530 _SHR_PACK_U16(buf, msg->system_id_length); 531 for (i = 0; i < msg->system_id_length; i++) { 532 _SHR_PACK_U8(buf, msg->system_id[i]); 533 } 534 } 535 536 return buf; 537 } 538 539 /* 540 * Get collector - unpack 541 */ 542 uint8* 543 shr_ft_msg_ctrl_collector_get_unpack(uint8* buf, shr_ft_msg_ctrl_collector_get_t *msg) 544 { 545 int i; 546 547 _SHR_UNPACK_U16(buf, msg->id); 548 _SHR_UNPACK_U32(buf, msg->flags); 549 _SHR_UNPACK_U16(buf, msg->encap_length); 550 551 for (i = 0; i < msg->encap_length; i++) { 552 _SHR_UNPACK_U8(buf, msg->encap[i]); 553 } 554 555 _SHR_UNPACK_U16(buf, msg->mtu); 556 _SHR_UNPACK_U16(buf, msg->ip_base_checksum); 557 _SHR_UNPACK_U16(buf, msg->udp_base_checksum); 558 _SHR_UNPACK_U16(buf, msg->ip_offset); 559 _SHR_UNPACK_U16(buf, msg->udp_offset); 560 561 if (ft_msg_version >= FT_MSG_VERSION_1) { 562 _SHR_UNPACK_U32(buf, msg->component_id); 563 _SHR_UNPACK_U16(buf, msg->system_id_length); 564 for (i = 0; i < msg->system_id_length; i++) { 565 _SHR_UNPACK_U8(buf, msg->system_id[i]); 566 } 567 } 568 569 return buf; 570 } 571 572 /* 573 * Get data associated with a flow - pack 574 */ 575 uint8* 576 shr_ft_msg_ctrl_group_flow_data_get_pack(uint8* buf, 577 shr_ft_msg_ctrl_group_flow_data_get_t *msg) 578 { 579 int i; 580 581 _SHR_PACK_U16(buf, msg->group_idx); 582 _SHR_PACK_U32(buf, msg->src_ip); 583 _SHR_PACK_U32(buf, msg->dst_ip); 584 _SHR_PACK_U16(buf, msg->l4_src_port); 585 _SHR_PACK_U16(buf, msg->l4_dst_port); 586 _SHR_PACK_U8(buf, msg->ip_protocol); 587 588 if (ft_msg_version >= FT_MSG_VERSION_1) { 589 _SHR_PACK_U32(buf, msg->vnid); 590 _SHR_PACK_U32(buf, msg->inner_src_ip); 591 _SHR_PACK_U32(buf, msg->inner_dst_ip); 592 _SHR_PACK_U16(buf, msg->inner_l4_src_port); 593 _SHR_PACK_U16(buf, msg->inner_l4_dst_port); 594 _SHR_PACK_U8(buf, msg->inner_ip_protocol); 595 _SHR_PACK_U8(buf, msg->custom_length); 596 for (i = 0; i < msg->custom_length; i++) { 597 _SHR_PACK_U8(buf, msg->custom[i]); 598 } 599 } 600 601 if (ft_msg_version >= FT_MSG_VERSION_2) { 602 _SHR_PACK_U16(buf, msg->in_port); 603 } 604 605 return buf; 606 } 607 608 /* 609 * Get data associated with a flow - unpack 610 */ 611 uint8* 612 shr_ft_msg_ctrl_group_flow_data_get_unpack(uint8* buf, 613 shr_ft_msg_ctrl_group_flow_data_get_t *msg) 614 { 615 int i; 616 617 _SHR_UNPACK_U16(buf, msg->group_idx); 618 _SHR_UNPACK_U32(buf, msg->src_ip); 619 _SHR_UNPACK_U32(buf, msg->dst_ip); 620 _SHR_UNPACK_U16(buf, msg->l4_src_port); 621 _SHR_UNPACK_U16(buf, msg->l4_dst_port); 622 _SHR_UNPACK_U8(buf, msg->ip_protocol); 623 624 if (ft_msg_version >= FT_MSG_VERSION_1) { 625 _SHR_UNPACK_U32(buf, msg->vnid); 626 _SHR_UNPACK_U32(buf, msg->inner_src_ip); 627 _SHR_UNPACK_U32(buf, msg->inner_dst_ip); 628 _SHR_UNPACK_U16(buf, msg->inner_l4_src_port); 629 _SHR_UNPACK_U16(buf, msg->inner_l4_dst_port); 630 _SHR_UNPACK_U8(buf, msg->inner_ip_protocol); 631 _SHR_UNPACK_U8(buf, msg->custom_length); 632 for (i = 0; i < msg->custom_length; i++) { 633 _SHR_UNPACK_U8(buf, msg->custom[i]); 634 } 635 } 636 if (ft_msg_version >= FT_MSG_VERSION_2) { 637 _SHR_UNPACK_U16(buf, msg->in_port); 638 } 639 640 return buf; 641 } 642 643 /* 644 * Data associated with a flow - pack 645 */ 646 uint8* 647 shr_ft_msg_ctrl_group_flow_data_get_reply_pack( 648 uint8* buf, 649 shr_ft_msg_ctrl_group_flow_data_get_reply_t *msg) 650 { 651 int i; 652 653 _SHR_PACK_U32(buf, msg->pkt_count_upper); 654 _SHR_PACK_U32(buf, msg->pkt_count_lower); 655 _SHR_PACK_U32(buf, msg->byte_count_upper); 656 _SHR_PACK_U32(buf, msg->byte_count_lower); 657 _SHR_PACK_U32(buf, msg->flow_start_ts_upper); 658 _SHR_PACK_U32(buf, msg->flow_start_ts_lower); 659 _SHR_PACK_U32(buf, msg->obs_ts_upper); 660 _SHR_PACK_U32(buf, msg->obs_ts_lower); 661 if (ft_msg_version >= FT_MSG_VERSION_1) { 662 _SHR_PACK_U8(buf, msg->num_drop_reasons); 663 for (i = 0; i < msg->num_drop_reasons; i++) { 664 _SHR_PACK_U16(buf, msg->drop_reasons[i]); 665 } 666 } 667 return buf; 668 } 669 670 /* 671 * Data associated with a flow - unpack 672 */ 673 uint8* 674 shr_ft_msg_ctrl_group_flow_data_get_reply_unpack( 675 uint8* buf, 676 shr_ft_msg_ctrl_group_flow_data_get_reply_t *msg) 677 { 678 int i; 679 680 _SHR_UNPACK_U32(buf, msg->pkt_count_upper); 681 _SHR_UNPACK_U32(buf, msg->pkt_count_lower); 682 _SHR_UNPACK_U32(buf, msg->byte_count_upper); 683 _SHR_UNPACK_U32(buf, msg->byte_count_lower); 684 _SHR_UNPACK_U32(buf, msg->flow_start_ts_upper); 685 _SHR_UNPACK_U32(buf, msg->flow_start_ts_lower); 686 _SHR_UNPACK_U32(buf, msg->obs_ts_upper); 687 _SHR_UNPACK_U32(buf, msg->obs_ts_lower); 688 if (ft_msg_version >= FT_MSG_VERSION_1) { 689 _SHR_UNPACK_U8(buf, msg->num_drop_reasons); 690 for (i = 0; i < msg->num_drop_reasons; i++) { 691 _SHR_UNPACK_U16(buf, msg->drop_reasons[i]); 692 } 693 } 694 695 return buf; 696 } 697 698 /* 699 * SER event - pack 700 */ 701 uint8* 702 shr_ft_msg_ctrl_ser_event_pack(uint8* buf, shr_ft_msg_ctrl_ser_event_t *msg) 703 { 704 _SHR_PACK_U32(buf, msg->flags); 705 _SHR_PACK_U8(buf, msg->pipe); 706 _SHR_PACK_U32(buf, msg->mem); 707 _SHR_PACK_U32(buf, msg->index); 708 709 return buf; 710 } 711 712 /* 713 * SER event - unpack 714 */ 715 uint8* 716 shr_ft_msg_ctrl_ser_event_unpack(uint8* buf, shr_ft_msg_ctrl_ser_event_t *msg) 717 { 718 _SHR_UNPACK_U32(buf, msg->flags); 719 _SHR_UNPACK_U8(buf, msg->pipe); 720 _SHR_UNPACK_U32(buf, msg->mem); 721 _SHR_UNPACK_U32(buf, msg->index); 722 723 return buf; 724 } 725 726 727 /* 728 * Template set transmit - pack 729 */ 730 uint8* 731 shr_ft_msg_ctrl_template_xmit_pack(uint8* buf, 732 shr_ft_msg_ctrl_template_xmit_t *msg) 733 { 734 int i; 735 736 _SHR_PACK_U32(buf, msg->flags); 737 _SHR_PACK_U16(buf, msg->template_id); 738 _SHR_PACK_U16(buf, msg->collector_id); 739 _SHR_PACK_U16(buf, msg->initial_burst); 740 _SHR_PACK_U16(buf, msg->interval_secs); 741 _SHR_PACK_U16(buf, msg->encap_length); 742 743 for (i = 0; i < msg->encap_length; i++) { 744 _SHR_PACK_U8(buf, msg->encap[i]); 745 } 746 747 return buf; 748 } 749 750 /* 751 * Template set transmit - unpack 752 */ 753 uint8* 754 shr_ft_msg_ctrl_template_xmit_unpack(uint8* buf, 755 shr_ft_msg_ctrl_template_xmit_t *msg) 756 { 757 int i; 758 759 _SHR_UNPACK_U32(buf, msg->flags); 760 _SHR_UNPACK_U16(buf, msg->template_id); 761 _SHR_UNPACK_U16(buf, msg->collector_id); 762 _SHR_UNPACK_U16(buf, msg->initial_burst); 763 _SHR_UNPACK_U16(buf, msg->interval_secs); 764 _SHR_UNPACK_U16(buf, msg->encap_length); 765 766 for (i = 0; i < msg->encap_length; i++) { 767 _SHR_UNPACK_U8(buf, msg->encap[i]); 768 } 769 770 return buf; 771 } 772 773 /* 774 * Add elephant profile - pack 775 */ 776 uint8* 777 shr_ft_msg_ctrl_elph_profile_create_pack(uint8* buf, 778 shr_ft_msg_ctrl_elph_profile_create_t *msg) 779 { 780 int i; 781 782 _SHR_PACK_U8(buf, msg->profile_idx); 783 _SHR_PACK_U8(buf, msg->num_filters); 784 785 for (i = 0; i < msg->num_filters; i++) { 786 _SHR_PACK_U16(buf, msg->filters[i].scan_count); 787 _SHR_PACK_U32(buf, msg->filters[i].size_threshold_bytes_upper_32); 788 _SHR_PACK_U32(buf, msg->filters[i].size_threshold_bytes_lower_32); 789 _SHR_PACK_U32(buf, msg->filters[i].rate_high_threshold); 790 _SHR_PACK_U32(buf, msg->filters[i].rate_low_threshold); 791 _SHR_PACK_U8(buf, msg->filters[i].incr_rate); 792 } 793 return buf; 794 } 795 796 /* 797 * Add elephant profile - unpack 798 */ 799 uint8* 800 shr_ft_msg_ctrl_elph_profile_create_unpack(uint8* buf, 801 shr_ft_msg_ctrl_elph_profile_create_t *msg) 802 { 803 int i; 804 805 _SHR_UNPACK_U8(buf, msg->profile_idx); 806 _SHR_UNPACK_U8(buf, msg->num_filters); 807 808 for (i = 0; i < msg->num_filters; i++) { 809 _SHR_UNPACK_U16(buf, msg->filters[i].scan_count); 810 _SHR_UNPACK_U32(buf, msg->filters[i].size_threshold_bytes_upper_32); 811 _SHR_UNPACK_U32(buf, msg->filters[i].size_threshold_bytes_lower_32); 812 _SHR_UNPACK_U32(buf, msg->filters[i].rate_high_threshold); 813 _SHR_UNPACK_U32(buf, msg->filters[i].rate_low_threshold); 814 _SHR_UNPACK_U8(buf, msg->filters[i].incr_rate); 815 } 816 return buf; 817 } 818 819 /* 820 * Get elephant profile - pack 821 */ 822 uint8* 823 shr_ft_msg_ctrl_elph_profile_get_pack(uint8* buf, 824 shr_ft_msg_ctrl_elph_profile_get_t *msg) 825 { 826 int i; 827 828 _SHR_PACK_U8(buf, msg->profile_idx); 829 _SHR_PACK_U8(buf, msg->num_filters); 830 831 for (i = 0; i < msg->num_filters; i++) { 832 _SHR_PACK_U32(buf, msg->filters[i].size_threshold_bytes_upper_32); 833 _SHR_PACK_U32(buf, msg->filters[i].size_threshold_bytes_lower_32); 834 _SHR_PACK_U32(buf, msg->filters[i].rate_high_threshold); 835 _SHR_PACK_U32(buf, msg->filters[i].rate_low_threshold); 836 } 837 return buf; 838 } 839 840 /* 841 * Get elephant profile - unpack 842 */ 843 uint8* 844 shr_ft_msg_ctrl_elph_profile_get_unpack(uint8* buf, 845 shr_ft_msg_ctrl_elph_profile_get_t *msg) 846 { 847 int i; 848 849 _SHR_UNPACK_U8(buf, msg->profile_idx); 850 _SHR_UNPACK_U8(buf, msg->num_filters); 851 852 for (i = 0; i < msg->num_filters; i++) { 853 _SHR_UNPACK_U32(buf, msg->filters[i].size_threshold_bytes_upper_32); 854 _SHR_UNPACK_U32(buf, msg->filters[i].size_threshold_bytes_lower_32); 855 _SHR_UNPACK_U32(buf, msg->filters[i].rate_high_threshold); 856 _SHR_UNPACK_U32(buf, msg->filters[i].rate_low_threshold); 857 } 858 return buf; 859 } 860 861 /* 862 * Get learn stats - pack 863 */ 864 uint8* 865 shr_ft_msg_ctrl_stats_learn_get_pack(uint8* buf, 866 shr_ft_msg_ctrl_stats_learn_t *msg) 867 { 868 int i; 869 870 _SHR_PACK_U16(buf, msg->num_status); 871 for (i = 0; i < msg->num_status; i++) { 872 _SHR_PACK_U32(buf, msg->count[i]); 873 _SHR_PACK_U32(buf, msg->avg_usecs[i]); 874 } 875 return buf; 876 } 877 878 /* 879 * Get learn stats - unpack 880 */ 881 uint8* 882 shr_ft_msg_ctrl_stats_learn_get_unpack(uint8* buf, 883 shr_ft_msg_ctrl_stats_learn_t *msg) 884 { 885 int i; 886 887 _SHR_UNPACK_U16(buf, msg->num_status); 888 for (i = 0; i < msg->num_status; i++) { 889 _SHR_UNPACK_U32(buf, msg->count[i]); 890 _SHR_UNPACK_U32(buf, msg->avg_usecs[i]); 891 } 892 return buf; 893 } 894 895 /* 896 * Get export stats - pack 897 */ 898 uint8* 899 shr_ft_msg_ctrl_stats_export_get_pack(uint8* buf, 900 shr_ft_msg_ctrl_stats_export_t *msg) 901 { 902 _SHR_PACK_U32(buf, msg->num_pkts); 903 _SHR_PACK_U32(buf, msg->num_flows); 904 _SHR_PACK_U32(buf, msg->ts); 905 _SHR_PACK_U32(buf, msg->seq_num); 906 907 return buf; 908 } 909 910 /* 911 * Get export stats - unpack 912 */ 913 uint8* 914 shr_ft_msg_ctrl_stats_export_get_unpack(uint8* buf, 915 shr_ft_msg_ctrl_stats_export_t *msg) 916 { 917 _SHR_UNPACK_U32(buf, msg->num_pkts); 918 _SHR_UNPACK_U32(buf, msg->num_flows); 919 _SHR_UNPACK_U32(buf, msg->ts); 920 _SHR_UNPACK_U32(buf, msg->seq_num); 921 922 return buf; 923 } 924 925 /* 926 * Get age stats - pack 927 */ 928 uint8* 929 shr_ft_msg_ctrl_stats_age_get_pack(uint8* buf, 930 shr_ft_msg_ctrl_stats_age_t *msg) 931 { 932 _SHR_PACK_U32(buf, msg->num_flows); 933 934 return buf; 935 } 936 937 /* 938 * Get age stats - unpack 939 */ 940 uint8* 941 shr_ft_msg_ctrl_stats_age_get_unpack(uint8* buf, 942 shr_ft_msg_ctrl_stats_age_t *msg) 943 { 944 _SHR_UNPACK_U32(buf, msg->num_flows); 945 946 return buf; 947 } 948 949 /* 950 * Get elph stats - pack 951 */ 952 uint8* 953 shr_ft_msg_ctrl_stats_elph_get_pack(uint8* buf, 954 shr_ft_msg_ctrl_stats_elph_t *msg) 955 { 956 int i, j; 957 958 _SHR_PACK_U16(buf, msg->num_states); 959 _SHR_PACK_U16(buf, msg->num_actions); 960 961 for (i = 0; i < msg->num_states; i++) { 962 for (j = 0; j < msg->num_actions; j++) { 963 _SHR_PACK_U32(buf, msg->trans_count[i][j]); 964 } 965 } 966 967 return buf; 968 } 969 970 /* 971 * Get elph stats - unpack 972 */ 973 uint8* 974 shr_ft_msg_ctrl_stats_elph_get_unpack(uint8* buf, 975 shr_ft_msg_ctrl_stats_elph_t *msg) 976 { 977 int i, j; 978 979 _SHR_UNPACK_U16(buf, msg->num_states); 980 _SHR_UNPACK_U16(buf, msg->num_actions); 981 982 for (i = 0; i < msg->num_states; i++) { 983 for (j = 0; j < msg->num_actions; j++) { 984 _SHR_UNPACK_U32(buf, msg->trans_count[i][j]); 985 } 986 } 987 988 return buf; 989 } 990 991 /* 992 * SDK features - pack 993 */ 994 uint8* 995 shr_ft_msg_ctrl_sdk_features_pack(uint8* buf, 996 shr_ft_msg_ctrl_sdk_features_t *msg) 997 { 998 _SHR_PACK_U32(buf, msg->features); 999 _SHR_PACK_U8(buf, msg->cfg_mode); 1000 1001 return buf; 1002 } 1003 1004 /* 1005 * SDK features - unpack 1006 */ 1007 uint8* 1008 shr_ft_msg_ctrl_sdk_features_unpack(uint8* buf, 1009 shr_ft_msg_ctrl_sdk_features_t *msg) 1010 { 1011 _SHR_UNPACK_U32(buf, msg->features); 1012 _SHR_UNPACK_U8(buf, msg->cfg_mode); 1013 1014 return buf; 1015 } 1016 1017 /* 1018 * uC features - pack 1019 */ 1020 uint8* 1021 shr_ft_msg_ctrl_uc_features_pack(uint8* buf, 1022 shr_ft_msg_ctrl_uc_features_t *msg) 1023 { 1024 _SHR_PACK_U32(buf, msg->features); 1025 1026 return buf; 1027 } 1028 1029 /* 1030 * uC features - unpack 1031 */ 1032 uint8* 1033 shr_ft_msg_ctrl_uc_features_unpack(uint8* buf, 1034 shr_ft_msg_ctrl_uc_features_t *msg) 1035 { 1036 _SHR_UNPACK_U32(buf, msg->features); 1037 1038 return buf; 1039 } 1040 1041 /* 1042 * Group actions set - pack 1043 */ 1044 uint8* 1045 shr_ft_msg_ctrl_group_actions_set_pack(uint8* buf, 1046 shr_ft_msg_ctrl_group_actions_set_t *msg) 1047 { 1048 _SHR_PACK_U16(buf, msg->group_idx); 1049 _SHR_PACK_U32(buf, msg->actions); 1050 _SHR_PACK_U16(buf, msg->fsp_cosq); 1051 1052 return buf; 1053 } 1054 1055 /* 1056 * Group actions set - unpack 1057 */ 1058 uint8* 1059 shr_ft_msg_ctrl_group_actions_set_unpack(uint8* buf, 1060 shr_ft_msg_ctrl_group_actions_set_t *msg) 1061 { 1062 _SHR_UNPACK_U16(buf, msg->group_idx); 1063 _SHR_UNPACK_U32(buf, msg->actions); 1064 _SHR_UNPACK_U16(buf, msg->fsp_cosq); 1065 1066 return buf; 1067 }