xflow_macsec_cmn.c (25728B)
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: xflow_macsec_cmn.c 8 * Purpose: XFLOW_MACSEC software module intergation support 9 */ 10 11 #ifdef INCLUDE_XFLOW_MACSEC 12 13 #include <shared/bsl.h> 14 15 #include <soc/drv.h> 16 #include <soc/mem.h> 17 #include <soc/debug.h> 18 #include <soc/register.h> 19 #include <soc/memory.h> 20 21 #include <sal/core/libc.h> 22 #include <bcm/debug.h> 23 24 #include <bcm_int/common/xflow_macsec_cmn.h> 25 26 #include <bcm_int/control.h> 27 #include <bcm_int/esw_dispatch.h> 28 #include <bcm_int/esw/oam.h> 29 30 #define UNIT_VALID(unit) \ 31 { \ 32 if (!BCM_UNIT_VALID(unit)) { return BCM_E_UNIT; } \ 33 } 34 35 /* 36 * Function: 37 * bcm_common_xflow_macsec_init 38 * Purpose: 39 * Initialize XFLOW_MACSEC for the specified unit. 40 */ 41 int _bcm_common_xflow_macsec_init(int unit) 42 { 43 int rv = BCM_E_NONE; 44 UNIT_VALID(unit); 45 46 /* Initilaize the MACSEC module */ 47 if (soc_feature(unit, soc_feature_xflow_macsec)) { 48 XFLOW_MACSEC_LOCK(unit); 49 if (soc_feature(unit, soc_feature_xflow_macsec_stat)) { 50 /* Register counter collection callback. */ 51 soc_counter_extra_register(unit, _xflow_macsec_counters_collect); 52 } 53 rv = _bcm_xflow_macsec_init(unit); 54 XFLOW_MACSEC_UNLOCK(unit); 55 } 56 return rv; 57 } 58 59 /* 60 * Function: 61 * bcm_common_xflow_macsec_deinit 62 * Purpose: 63 * Deinitialize XFLOW_MACSEC for the specified unit. 64 */ 65 int _bcm_common_xflow_macsec_deinit(int unit) 66 { 67 int rv = BCM_E_NONE; 68 UNIT_VALID(unit); 69 70 /* Deinitilaize the MACSEC module */ 71 if (soc_feature(unit, soc_feature_xflow_macsec)) { 72 XFLOW_MACSEC_LOCK(unit); 73 if (soc_feature(unit, soc_feature_xflow_macsec_stat)) { 74 /* De-Register counter collection callback. */ 75 soc_counter_extra_unregister(unit, _xflow_macsec_counters_collect); 76 } 77 rv = _bcm_xflow_macsec_deinit(unit); 78 XFLOW_MACSEC_UNLOCK(unit); 79 } 80 return rv; 81 } 82 83 /* 84 * Function: 85 * bcm_common_xflow_macsec_sync 86 * Purpose: 87 * Warmboot sync XFLOW_MACSEC for the specified unit. 88 */ 89 int _bcm_common_xflow_macsec_sync(int unit) 90 { 91 int rv = BCM_E_NONE; 92 UNIT_VALID(unit); 93 94 #ifdef BCM_WARM_BOOT_SUPPORT 95 /* Sync the MACSEC module */ 96 if (soc_feature(unit, soc_feature_xflow_macsec)) { 97 XFLOW_MACSEC_LOCK(unit); 98 rv = xflow_macsec_wb_sync(unit); 99 XFLOW_MACSEC_UNLOCK(unit); 100 } 101 #endif 102 return rv; 103 } 104 105 /* Security Channel */ 106 107 /* 108 * Function: 109 * bcm_common_xflow_macsec_secure_chan_create 110 * Purpose: 111 * Create an XFLOW_MACSEC security channel 112 */ 113 int 114 bcm_common_xflow_macsec_secure_chan_create(int unit, 115 uint32 flags, 116 bcm_xflow_macsec_instance_id_t instance_id, 117 bcm_xflow_macsec_secure_chan_info_t *chan_info, 118 int priority, 119 bcm_xflow_macsec_secure_chan_id_t *chan_id) 120 { 121 int rv = BCM_E_UNAVAIL; 122 UNIT_VALID(unit); 123 124 if (soc_feature(unit, soc_feature_xflow_macsec)) { 125 XFLOW_MACSEC_LOCK(unit); 126 rv = xflow_macsec_secure_chan_create(unit, flags, 127 (xflow_macsec_secure_chan_info_t *)chan_info, 128 priority, 129 (xflow_macsec_secure_chan_id_t *)chan_id); 130 XFLOW_MACSEC_UNLOCK(unit); 131 } 132 return rv; 133 } 134 135 /* 136 * Function: 137 * bcm_common_xflow_macsec_secure_chan_set 138 * Purpose: 139 * Sets/Resets the value of one of the parameters 140 * of a given security channel. 141 */ 142 int 143 bcm_common_xflow_macsec_secure_chan_set(int unit, 144 uint32 flags, 145 bcm_xflow_macsec_secure_chan_id_t chan_id, 146 bcm_xflow_macsec_secure_chan_info_t *chan_info, 147 int priority) 148 { 149 int rv = BCM_E_UNAVAIL; 150 UNIT_VALID(unit); 151 152 if (soc_feature(unit, soc_feature_xflow_macsec)) { 153 XFLOW_MACSEC_LOCK(unit); 154 rv = xflow_macsec_secure_chan_set(unit, flags, chan_id, 155 (xflow_macsec_secure_chan_info_t *)chan_info, priority); 156 XFLOW_MACSEC_UNLOCK(unit); 157 } 158 return rv; 159 } 160 161 /* 162 * Function: 163 * bcm_common_xflow_macsec_secure_chan_get 164 * Purpose: 165 * Get the security channel configuration for a given SC index. 166 */ 167 int 168 bcm_common_xflow_macsec_secure_chan_get(int unit, 169 bcm_xflow_macsec_secure_chan_id_t chan_id, 170 bcm_xflow_macsec_secure_chan_info_t *chan_info, 171 int *priority) 172 { 173 int rv = BCM_E_UNAVAIL; 174 UNIT_VALID(unit); 175 176 if (soc_feature(unit, soc_feature_xflow_macsec)) { 177 XFLOW_MACSEC_LOCK(unit); 178 rv = xflow_macsec_secure_chan_get(unit, chan_id, chan_info, priority); 179 XFLOW_MACSEC_UNLOCK(unit); 180 } 181 return rv; 182 } 183 184 /* 185 * Function: 186 * bcm_common_xflow_macsec_secure_chan_destroy 187 * Purpose: 188 * Delete the given security channel. The corresponding SA must be 189 * destroyed first. 190 */ 191 int 192 bcm_common_xflow_macsec_secure_chan_destroy(int unit, 193 bcm_xflow_macsec_secure_chan_id_t chan_id) 194 { 195 int rv = BCM_E_UNAVAIL; 196 UNIT_VALID(unit); 197 198 if (soc_feature(unit, soc_feature_xflow_macsec)) { 199 XFLOW_MACSEC_LOCK(unit); 200 rv = xflow_macsec_secure_chan_destroy(unit, chan_id); 201 XFLOW_MACSEC_UNLOCK(unit); 202 } 203 return rv; 204 } 205 206 /* 207 * Function: 208 * bcm_common_xflow_macsec_secure_chan_info_t_init 209 * Purpose: 210 * Initialize the data structure. 211 */ 212 void 213 bcm_xflow_macsec_secure_chan_info_t_init( 214 bcm_xflow_macsec_secure_chan_info_t *chan_info) 215 { 216 xflow_macsec_secure_chan_info_t_init(chan_info); 217 } 218 219 /* 220 * Function: 221 * bcm_common_xflow_macsec_secure_chan_enable_set 222 * Purpose: 223 * Enable the Security Channel. 224 */ 225 int 226 bcm_common_xflow_macsec_secure_chan_enable_set(int unit, 227 bcm_xflow_macsec_secure_chan_id_t chan_id, 228 int enable) 229 { 230 int rv = BCM_E_UNAVAIL; 231 UNIT_VALID(unit); 232 233 if (soc_feature(unit, soc_feature_xflow_macsec)) { 234 XFLOW_MACSEC_LOCK(unit); 235 rv = xflow_macsec_secure_chan_enable_set(unit, chan_id, enable); 236 XFLOW_MACSEC_UNLOCK(unit); 237 } 238 return rv; 239 } 240 241 /* 242 * Function: 243 * bcm_common_xflow_macsec_secure_chan_enable_get 244 * Purpose: 245 * Check if the Security Channel is enabled. 246 */ 247 int 248 bcm_common_xflow_macsec_secure_chan_enable_get(int unit, 249 bcm_xflow_macsec_secure_chan_id_t chan_id, 250 int *enable) 251 { 252 int rv = BCM_E_UNAVAIL; 253 UNIT_VALID(unit); 254 255 if (soc_feature(unit, soc_feature_xflow_macsec)) { 256 XFLOW_MACSEC_LOCK(unit); 257 rv = xflow_macsec_secure_chan_enable_get(unit, chan_id, enable); 258 XFLOW_MACSEC_UNLOCK(unit); 259 } 260 return rv; 261 } 262 263 264 265 /* Security Association */ 266 267 /* 268 * Function: 269 * bcm_common_xflow_macsec_secure_assoc_create 270 * Purpose: 271 * Create the Security Association for the 272 * given Security Channel. 273 */ 274 int 275 bcm_common_xflow_macsec_secure_assoc_create(int unit, 276 uint32 flags, 277 bcm_xflow_macsec_secure_chan_id_t chan_id, 278 bcm_xflow_macsec_secure_assoc_info_t *assoc_info, 279 bcm_xflow_macsec_secure_assoc_id_t *assoc_id) 280 { 281 int rv = BCM_E_UNAVAIL; 282 UNIT_VALID(unit); 283 284 if (soc_feature(unit, soc_feature_xflow_macsec)) { 285 XFLOW_MACSEC_LOCK(unit); 286 rv = xflow_macsec_secure_assoc_create(unit, flags, 287 chan_id, assoc_info, assoc_id); 288 XFLOW_MACSEC_UNLOCK(unit); 289 } 290 return rv; 291 } 292 293 /* 294 * Function: 295 * bcm_common_xflow_macsec_secure_assoc_set 296 * Purpose: 297 * Sets/Resets the value of any of the parameters of 298 * a given security association. 299 */ 300 int 301 bcm_common_xflow_macsec_secure_assoc_set(int unit, 302 bcm_xflow_macsec_secure_assoc_id_t assoc_id, 303 bcm_xflow_macsec_secure_assoc_info_t *assoc_info) 304 { 305 int rv = BCM_E_UNAVAIL; 306 UNIT_VALID(unit); 307 308 if (soc_feature(unit, soc_feature_xflow_macsec)) { 309 XFLOW_MACSEC_LOCK(unit); 310 rv = xflow_macsec_secure_assoc_set(unit, assoc_id, 311 (xflow_macsec_secure_assoc_info_t *)assoc_info); 312 XFLOW_MACSEC_UNLOCK(unit); 313 } 314 return rv; 315 } 316 317 /* 318 * Function: 319 * bcm_common_xflow_macsec_secure_assoc_get 320 * Purpose: 321 * Retrieve the Security Association configuration and the 322 * SC index from the SA index. 323 */ 324 int 325 bcm_common_xflow_macsec_secure_assoc_get(int unit, 326 bcm_xflow_macsec_secure_assoc_id_t assoc_id, 327 bcm_xflow_macsec_secure_assoc_info_t *assoc_info, 328 bcm_xflow_macsec_secure_chan_id_t *chan_id) 329 { 330 int rv = BCM_E_UNAVAIL; 331 UNIT_VALID(unit); 332 333 if (soc_feature(unit, soc_feature_xflow_macsec)) { 334 XFLOW_MACSEC_LOCK(unit); 335 rv = xflow_macsec_secure_assoc_get(unit, assoc_id, assoc_info, chan_id); 336 XFLOW_MACSEC_UNLOCK(unit); 337 } 338 return rv; 339 } 340 341 /* 342 * Function: 343 * bcm_common_xflow_macsec_secure_assoc_destroy 344 * Purpose: 345 * Deletes the SA entry corresponding to the Security Association. 346 */ 347 int 348 bcm_common_xflow_macsec_secure_assoc_destroy(int unit, 349 bcm_xflow_macsec_secure_assoc_id_t assoc_id) 350 { 351 int rv = BCM_E_UNAVAIL; 352 UNIT_VALID(unit); 353 354 if (soc_feature(unit, soc_feature_xflow_macsec)) { 355 XFLOW_MACSEC_LOCK(unit); 356 rv = xflow_macsec_secure_assoc_destroy(unit, assoc_id); 357 XFLOW_MACSEC_UNLOCK(unit); 358 } 359 return rv; 360 } 361 362 /* 363 * Function: 364 * bcm_common_xflow_macsec_secure_assoc_info_t_init 365 * Purpose: 366 * Initialize the Security Association data structure. 367 */ 368 void 369 bcm_xflow_macsec_secure_assoc_info_t_init( 370 bcm_xflow_macsec_secure_assoc_info_t *assoc_info) 371 { 372 xflow_macsec_secure_assoc_info_t_init(assoc_info); 373 } 374 375 /* 376 * Function: 377 * bcm_common_xflow_macsec_decrypt_policy_create 378 * Purpose: 379 */ 380 int 381 bcm_common_xflow_macsec_decrypt_policy_create( 382 int unit, 383 uint32 flags, 384 bcm_xflow_macsec_instance_id_t instance_id, 385 bcm_xflow_macsec_decrypt_policy_info_t *policy_info, 386 bcm_xflow_macsec_policy_id_t *policy_id) 387 { 388 int rv = BCM_E_UNAVAIL; 389 UNIT_VALID(unit); 390 391 if (soc_feature(unit, soc_feature_xflow_macsec)) { 392 XFLOW_MACSEC_LOCK(unit); 393 flags |= XFLOW_MACSEC_DECRYPT; 394 rv = xflow_macsec_policy_create(unit, flags, policy_info, policy_id); 395 XFLOW_MACSEC_UNLOCK(unit); 396 } 397 return rv; 398 } 399 400 /* 401 * Function: 402 * bcm_common_xflow_macsec_decrypt_policy_destroy 403 * Purpose: 404 */ 405 int 406 bcm_common_xflow_macsec_decrypt_policy_destroy( 407 int unit, 408 bcm_xflow_macsec_policy_id_t policy_id) 409 { 410 int rv = BCM_E_UNAVAIL; 411 UNIT_VALID(unit); 412 413 if (soc_feature(unit, soc_feature_xflow_macsec)) { 414 XFLOW_MACSEC_LOCK(unit); 415 rv = xflow_macsec_policy_destroy(unit, policy_id); 416 XFLOW_MACSEC_UNLOCK(unit); 417 } 418 return rv; 419 } 420 421 /* 422 * Function: 423 * bcm_common_xflow_macsec_decrypt_policy_get 424 * Purpose: 425 */ 426 int 427 bcm_common_xflow_macsec_decrypt_policy_get( 428 int unit, 429 bcm_xflow_macsec_policy_id_t policy_id, 430 bcm_xflow_macsec_decrypt_policy_info_t *policy_info) 431 { 432 int rv = BCM_E_UNAVAIL; 433 UNIT_VALID(unit); 434 435 if (soc_feature(unit, soc_feature_xflow_macsec)) { 436 XFLOW_MACSEC_LOCK(unit); 437 rv = xflow_macsec_policy_get(unit, policy_id, policy_info); 438 XFLOW_MACSEC_UNLOCK(unit); 439 } 440 return rv; 441 } 442 443 /* 444 * Function: 445 * bcm_common_xflow_macsec_decrypt_policy_set 446 * Purpose: 447 */ 448 int 449 bcm_common_xflow_macsec_decrypt_policy_set( 450 int unit, 451 bcm_xflow_macsec_policy_id_t policy_id, 452 bcm_xflow_macsec_decrypt_policy_info_t *policy_info) 453 454 { 455 int rv = BCM_E_UNAVAIL; 456 UNIT_VALID(unit); 457 458 if (soc_feature(unit, soc_feature_xflow_macsec)) { 459 XFLOW_MACSEC_LOCK(unit); 460 rv = xflow_macsec_policy_set(unit, policy_id, policy_info); 461 XFLOW_MACSEC_UNLOCK(unit); 462 } 463 return rv; 464 } 465 466 /* 467 * Function: 468 * bcm_xflow_macsec_decrypt_policy_info_t_init 469 * Purpose: 470 * Initialize the data structure. 471 */ 472 void 473 bcm_xflow_macsec_decrypt_policy_info_t_init( 474 bcm_xflow_macsec_decrypt_policy_info_t *policy_info) 475 { 476 xflow_macsec_policy_info_t_init(policy_info); 477 } 478 479 /* 480 * Function: 481 * bcm_common_xflow_macsec_decrypt_flow_create 482 * Purpose: 483 */ 484 int 485 bcm_common_xflow_macsec_decrypt_flow_create(int unit, 486 uint32 flags, 487 bcm_xflow_macsec_instance_id_t instance_id, 488 bcm_xflow_macsec_decrypt_flow_info_t *flow_info, 489 int priority, 490 bcm_xflow_macsec_flow_id_t *flow_id) 491 { 492 int rv = BCM_E_UNAVAIL; 493 UNIT_VALID(unit); 494 495 if (soc_feature(unit, soc_feature_xflow_macsec)) { 496 XFLOW_MACSEC_LOCK(unit); 497 flags |= XFLOW_MACSEC_DECRYPT; 498 rv = xflow_macsec_flow_create(unit, flags, flow_info, priority, 499 flow_id); 500 XFLOW_MACSEC_UNLOCK(unit); 501 } 502 return rv; 503 } 504 505 /* 506 * Function: 507 * bcm_common_xflow_macsec_decrypt_flow_destroy 508 * Purpose: 509 */ 510 int 511 bcm_common_xflow_macsec_decrypt_flow_destroy(int unit, 512 bcm_xflow_macsec_flow_id_t flow_id) 513 { 514 int rv = BCM_E_UNAVAIL; 515 UNIT_VALID(unit); 516 517 if (soc_feature(unit, soc_feature_xflow_macsec)) { 518 XFLOW_MACSEC_LOCK(unit); 519 rv = xflow_macsec_flow_destroy(unit, flow_id); 520 XFLOW_MACSEC_UNLOCK(unit); 521 } 522 return rv; 523 } 524 525 /* 526 * Function: 527 * bcm_common_xflow_macsec_decrypt_flow_enable_get 528 * Purpose: 529 */ 530 int 531 bcm_common_xflow_macsec_decrypt_flow_enable_get(int unit, 532 bcm_xflow_macsec_flow_id_t flow_id, 533 int *enable) 534 535 { 536 int rv = BCM_E_UNAVAIL; 537 UNIT_VALID(unit); 538 539 if (soc_feature(unit, soc_feature_xflow_macsec)) { 540 XFLOW_MACSEC_LOCK(unit); 541 rv = xflow_macsec_flow_enable_get(unit, flow_id, enable); 542 XFLOW_MACSEC_UNLOCK(unit); 543 } 544 return rv; 545 } 546 547 /* 548 * Function: 549 * bcm_common_xflow_macsec_decrypt_flow_enable_set 550 * Purpose: 551 */ 552 int 553 bcm_common_xflow_macsec_decrypt_flow_enable_set(int unit, 554 bcm_xflow_macsec_flow_id_t flow_id, 555 int enable) 556 { 557 int rv = BCM_E_UNAVAIL; 558 UNIT_VALID(unit); 559 560 if (soc_feature(unit, soc_feature_xflow_macsec)) { 561 XFLOW_MACSEC_LOCK(unit); 562 rv = xflow_macsec_flow_enable_set(unit, flow_id, enable); 563 XFLOW_MACSEC_UNLOCK(unit); 564 } 565 return rv; 566 } 567 568 /* 569 * Function: 570 * bcm_common_xflow_macsec_decrypt_flow_get 571 * Purpose: 572 */ 573 int 574 bcm_common_xflow_macsec_decrypt_flow_get(int unit, 575 bcm_xflow_macsec_flow_id_t flow_id, 576 bcm_xflow_macsec_decrypt_flow_info_t *flow_info, 577 int *priority) 578 { 579 int rv = BCM_E_UNAVAIL; 580 UNIT_VALID(unit); 581 582 if (soc_feature(unit, soc_feature_xflow_macsec)) { 583 XFLOW_MACSEC_LOCK(unit); 584 rv = xflow_macsec_flow_get(unit, flow_id, flow_info, priority); 585 XFLOW_MACSEC_UNLOCK(unit); 586 } 587 return rv; 588 } 589 590 /* 591 * Function: 592 * bcm_common_xflow_macsec_decrypt_flow_set 593 * Purpose: 594 */ 595 int 596 bcm_common_xflow_macsec_decrypt_flow_set(int unit, 597 bcm_xflow_macsec_flow_id_t flow_id, 598 bcm_xflow_macsec_decrypt_flow_info_t *flow_info, 599 int priority) 600 601 { 602 int rv = BCM_E_UNAVAIL; 603 UNIT_VALID(unit); 604 605 if (soc_feature(unit, soc_feature_xflow_macsec)) { 606 XFLOW_MACSEC_LOCK(unit); 607 rv = xflow_macsec_flow_set(unit, flow_id, flow_info, priority); 608 XFLOW_MACSEC_UNLOCK(unit); 609 } 610 return rv; 611 } 612 613 /* 614 * Function: 615 * bcm_xflow_macsec_decrypt_flow_info_t_init 616 * Purpose: 617 * Initialize the data structure. 618 */ 619 void 620 bcm_xflow_macsec_decrypt_flow_info_t_init( 621 bcm_xflow_macsec_decrypt_flow_info_t *flow_info) 622 { 623 xflow_macsec_flow_info_t_init(flow_info); 624 } 625 626 /* 627 * Function: 628 * bcm_common_xflow_macsec_subport_id_get 629 * Purpose: 630 */ 631 int 632 bcm_common_xflow_macsec_subport_id_get(int unit, 633 bcm_xflow_macsec_id_t id, 634 bcm_xflow_macsec_subport_id_t *macsec_subport_id) 635 { 636 int rv = BCM_E_UNAVAIL; 637 UNIT_VALID(unit); 638 639 if (soc_feature(unit, soc_feature_xflow_macsec)) { 640 XFLOW_MACSEC_LOCK(unit); 641 rv = xflow_macsec_subport_id_get(unit, id, macsec_subport_id); 642 XFLOW_MACSEC_UNLOCK(unit); 643 } 644 return rv; 645 } 646 647 /* 648 * Function: 649 * bcm_common_xflow_macsec_control_set 650 * Purpose: 651 * Sets the value in HW for the macsec control type provided. 652 */ 653 int 654 bcm_common_xflow_macsec_control_set(int unit, uint32 flags, 655 bcm_xflow_macsec_instance_id_t instance_id, 656 bcm_xflow_macsec_control_t type, uint64 value) 657 { 658 int rv = BCM_E_UNAVAIL; 659 UNIT_VALID(unit); 660 661 if (soc_feature(unit, soc_feature_xflow_macsec)) { 662 XFLOW_MACSEC_LOCK(unit); 663 rv = xflow_macsec_control_set(unit, flags, type, value); 664 XFLOW_MACSEC_UNLOCK(unit); 665 } 666 return rv; 667 } 668 669 /* 670 * Function: 671 * bcm_common_xflow_macsec_control_get 672 * Purpose: 673 * Gets the value from HW for the macsec control type provided. 674 */ 675 int 676 bcm_common_xflow_macsec_control_get(int unit, uint32 flags, 677 bcm_xflow_macsec_instance_id_t instance_id, 678 bcm_xflow_macsec_control_t type, uint64 *value) 679 { 680 int rv = BCM_E_UNAVAIL; 681 UNIT_VALID(unit); 682 683 if (soc_feature(unit, soc_feature_xflow_macsec)) { 684 XFLOW_MACSEC_LOCK(unit); 685 rv = xflow_macsec_control_get(unit, flags, type, value); 686 XFLOW_MACSEC_UNLOCK(unit); 687 } 688 return rv; 689 } 690 691 int 692 bcm_common_xflow_macsec_stat_get( 693 int unit, 694 uint32 flags, 695 bcm_xflow_macsec_id_t id, 696 bcm_xflow_macsec_stat_type_t stat_type, 697 uint64 *value) 698 { 699 int rv = BCM_E_UNAVAIL; 700 UNIT_VALID(unit); 701 702 if (soc_feature(unit, soc_feature_xflow_macsec_stat)) { 703 XFLOW_MACSEC_LOCK(unit); 704 rv = xflow_macsec_stat_get(unit, flags, id, stat_type, value); 705 XFLOW_MACSEC_UNLOCK(unit); 706 } 707 return rv; 708 } 709 710 int 711 bcm_common_xflow_macsec_stat_set( 712 int unit, 713 uint32 flags, 714 bcm_xflow_macsec_id_t id, 715 bcm_xflow_macsec_stat_type_t stat_type, 716 uint64 value) 717 { 718 int rv = BCM_E_UNAVAIL; 719 UNIT_VALID(unit); 720 721 if (soc_feature(unit, soc_feature_xflow_macsec_stat)) { 722 XFLOW_MACSEC_LOCK(unit); 723 rv = xflow_macsec_stat_set(unit, flags, id, stat_type, value); 724 XFLOW_MACSEC_UNLOCK(unit); 725 } 726 return rv; 727 } 728 729 int 730 bcm_common_xflow_macsec_stat_multi_get( 731 int unit, 732 uint32 flags, 733 bcm_xflow_macsec_id_t id, 734 uint32 num_stats, 735 bcm_xflow_macsec_stat_type_t *stat_type_array, 736 uint64 *value_array) 737 { 738 int rv = BCM_E_UNAVAIL; 739 UNIT_VALID(unit); 740 741 if (soc_feature(unit, soc_feature_xflow_macsec_stat)) { 742 XFLOW_MACSEC_LOCK(unit); 743 rv = xflow_macsec_stat_multi_get(unit, flags, id, num_stats, 744 (xflow_macsec_stat_type_t *)stat_type_array, value_array); 745 XFLOW_MACSEC_UNLOCK(unit); 746 } 747 return rv; 748 } 749 750 int 751 bcm_common_xflow_macsec_stat_multi_set( 752 int unit, 753 uint32 flags, 754 bcm_xflow_macsec_id_t id, 755 uint32 num_stats, 756 bcm_xflow_macsec_stat_type_t *stat_type_array, 757 uint64 *value_array) 758 { 759 int rv = BCM_E_UNAVAIL; 760 UNIT_VALID(unit); 761 762 if (soc_feature(unit, soc_feature_xflow_macsec_stat)) { 763 XFLOW_MACSEC_LOCK(unit); 764 rv = xflow_macsec_stat_multi_set(unit, flags, id, num_stats, 765 (xflow_macsec_stat_type_t *)stat_type_array, value_array); 766 XFLOW_MACSEC_UNLOCK(unit); 767 } 768 return rv; 769 } 770 771 int 772 bcm_common_xflow_macsec_vlan_tpid_array_set( 773 int unit, 774 bcm_xflow_macsec_instance_id_t instance_id, 775 bcm_xflow_macsec_vlan_tpid_t *vlan_tpid) 776 { 777 int rv = BCM_E_UNAVAIL; 778 UNIT_VALID(unit); 779 780 if (soc_feature(unit, soc_feature_xflow_macsec)) { 781 XFLOW_MACSEC_LOCK(unit); 782 rv = xflow_macsec_vlan_tpid_array_set(unit, vlan_tpid); 783 XFLOW_MACSEC_UNLOCK(unit); 784 } 785 return rv; 786 } 787 788 int 789 bcm_common_xflow_macsec_vlan_tpid_array_get( 790 int unit, 791 bcm_xflow_macsec_instance_id_t instance_id, 792 bcm_xflow_macsec_vlan_tpid_t *vlan_tpid) 793 { 794 int rv = BCM_E_UNAVAIL; 795 UNIT_VALID(unit); 796 797 if (soc_feature(unit, soc_feature_xflow_macsec)) { 798 XFLOW_MACSEC_LOCK(unit); 799 rv = xflow_macsec_vlan_tpid_array_get(unit, vlan_tpid); 800 XFLOW_MACSEC_UNLOCK(unit); 801 } 802 return rv; 803 } 804 805 int 806 bcm_common_xflow_macsec_vlan_tpid_array_index_get( 807 int unit, 808 bcm_xflow_macsec_instance_id_t instance_id, 809 uint32 vlan_tpid, 810 uint8 *tpid_index_sel) 811 { 812 int rv = BCM_E_UNAVAIL; 813 UNIT_VALID(unit); 814 815 if (soc_feature(unit, soc_feature_xflow_macsec)) { 816 XFLOW_MACSEC_LOCK(unit); 817 rv = xflow_macsec_vlan_tpid_array_index_get(unit, vlan_tpid, 818 tpid_index_sel); 819 XFLOW_MACSEC_UNLOCK(unit); 820 } 821 return rv; 822 } 823 824 int bcm_common_xflow_macsec_mtu_set( 825 int unit, 826 int flags, 827 bcm_xflow_macsec_instance_id_t instance_id, 828 uint32 mtu, 829 bcm_xflow_macsec_mtu_t *mtu_sel) 830 { 831 int rv = BCM_E_UNAVAIL; 832 UNIT_VALID(unit); 833 834 if (soc_feature(unit, soc_feature_xflow_macsec)) { 835 XFLOW_MACSEC_LOCK(unit); 836 rv = xflow_macsec_mtu_set(unit, flags, mtu, 837 (xflow_macsec_mtu_t *)mtu_sel); 838 XFLOW_MACSEC_UNLOCK(unit); 839 } 840 return rv; 841 } 842 843 int bcm_common_xflow_macsec_mtu_get( 844 int unit, 845 int flags, 846 bcm_xflow_macsec_instance_id_t instance_id, 847 bcm_xflow_macsec_mtu_t mtu_sel, 848 uint32 *mtu) 849 { 850 int rv = BCM_E_UNAVAIL; 851 UNIT_VALID(unit); 852 853 if (soc_feature(unit, soc_feature_xflow_macsec)) { 854 XFLOW_MACSEC_LOCK(unit); 855 rv = xflow_macsec_mtu_get(unit, flags, mtu_sel, mtu); 856 XFLOW_MACSEC_UNLOCK(unit); 857 } 858 return rv; 859 } 860 861 int bcm_common_xflow_macsec_sectag_etype_set( 862 int unit, 863 int flags, 864 bcm_xflow_macsec_instance_id_t instance_id, 865 uint32 sectag_etype, 866 bcm_xflow_macsec_sectag_ethertype_t *sectag_etype_sel) 867 { 868 int rv = BCM_E_UNAVAIL; 869 UNIT_VALID(unit); 870 871 if (soc_feature(unit, soc_feature_xflow_macsec)) { 872 XFLOW_MACSEC_LOCK(unit); 873 rv = xflow_macsec_sectag_etype_set(unit, flags, sectag_etype, 874 (xflow_macsec_sectag_ethertype_t *)sectag_etype_sel); 875 XFLOW_MACSEC_UNLOCK(unit); 876 } 877 return rv; 878 } 879 880 int bcm_common_xflow_macsec_sectag_etype_get( 881 int unit, 882 bcm_xflow_macsec_instance_id_t instance_id, 883 bcm_xflow_macsec_sectag_ethertype_t sectag_etype_sel, 884 uint32 *sectag_etype) 885 { 886 int rv = BCM_E_UNAVAIL; 887 UNIT_VALID(unit); 888 889 if (soc_feature(unit, soc_feature_xflow_macsec)) { 890 XFLOW_MACSEC_LOCK(unit); 891 rv = xflow_macsec_sectag_etype_get(unit, sectag_etype_sel, 892 sectag_etype); 893 XFLOW_MACSEC_UNLOCK(unit); 894 } 895 return rv; 896 } 897 898 int bcm_common_xflow_macsec_secure_chan_info_traverse ( 899 int unit, 900 uint32 flags, 901 bcm_xflow_macsec_instance_id_t instance_id, 902 bcm_xflow_macsec_chan_traverse_cb callback, 903 void *user_data) 904 { 905 int rv = BCM_E_UNAVAIL; 906 UNIT_VALID(unit); 907 908 if (soc_feature(unit, soc_feature_xflow_macsec)) { 909 XFLOW_MACSEC_LOCK(unit); 910 rv = xflow_macsec_secure_chan_info_traverse(unit, flags, callback, 911 user_data); 912 XFLOW_MACSEC_UNLOCK(unit); 913 } 914 return rv; 915 } 916 917 int bcm_common_xflow_macsec_secure_assoc_traverse( 918 int unit, 919 bcm_xflow_macsec_secure_chan_id_t chan_id, 920 bcm_xflow_macsec_secure_assoc_traverse_cb callback, 921 void *user_data) 922 { 923 int rv = BCM_E_UNAVAIL; 924 UNIT_VALID(unit); 925 926 if (soc_feature(unit, soc_feature_xflow_macsec)) { 927 XFLOW_MACSEC_LOCK(unit); 928 rv = xflow_macsec_secure_assoc_traverse(unit, chan_id, callback, 929 user_data); 930 XFLOW_MACSEC_UNLOCK(unit); 931 } 932 return rv; 933 } 934 935 int bcm_common_xflow_macsec_event_register( 936 int unit, bcm_xflow_macsec_event_cb cb, 937 void *user_data) 938 { 939 int rv = BCM_E_UNAVAIL; 940 UNIT_VALID(unit); 941 942 if (soc_feature(unit, soc_feature_xflow_macsec)) { 943 XFLOW_MACSEC_LOCK(unit); 944 rv = xflow_macsec_event_register(unit, (xflow_macsec_event_cb)cb, 945 user_data); 946 XFLOW_MACSEC_UNLOCK(unit); 947 } 948 return rv; 949 } 950 951 int bcm_common_xflow_macsec_event_deregister( 952 int unit, bcm_xflow_macsec_event_cb cb) 953 { 954 int rv = BCM_E_UNAVAIL; 955 UNIT_VALID(unit); 956 957 if (soc_feature(unit, soc_feature_xflow_macsec)) { 958 XFLOW_MACSEC_LOCK(unit); 959 rv = xflow_macsec_event_deregister(unit, (xflow_macsec_event_cb)cb); 960 XFLOW_MACSEC_UNLOCK(unit); 961 } 962 return rv; 963 } 964 965 int 966 bcm_common_xflow_macsec_mac_addr_control_set( 967 int unit, 968 uint32 flags, 969 bcm_xflow_macsec_instance_id_t instance_id, 970 bcm_xflow_macsec_mac_addr_control_t control_type, 971 bcm_xflow_macsec_mac_addr_info_t *control_info) 972 { 973 int rv = BCM_E_UNAVAIL; 974 UNIT_VALID(unit); 975 976 if (!control_info || 977 (control_type != bcmXflowMacsecStationDstMac)) { 978 return BCM_E_PARAM; 979 } 980 if (soc_feature(unit, soc_feature_xflow_macsec)) { 981 XFLOW_MACSEC_LOCK(unit); 982 rv = xflow_macsec_station_mac_addr_set(unit, control_info->mac_addr); 983 XFLOW_MACSEC_UNLOCK(unit); 984 } 985 return rv; 986 } 987 988 int 989 bcm_common_xflow_macsec_mac_addr_control_get( 990 int unit, 991 uint32 flags, 992 bcm_xflow_macsec_instance_id_t instance_id, 993 bcm_xflow_macsec_mac_addr_control_t control_type, 994 bcm_xflow_macsec_mac_addr_info_t *control_info) 995 { 996 int rv = BCM_E_UNAVAIL; 997 UNIT_VALID(unit); 998 999 if (!control_info || 1000 (control_type != bcmXflowMacsecStationDstMac)) { 1001 return BCM_E_PARAM; 1002 } 1003 if (soc_feature(unit, soc_feature_xflow_macsec)) { 1004 XFLOW_MACSEC_LOCK(unit); 1005 rv = xflow_macsec_station_mac_addr_get(unit, control_info->mac_addr); 1006 XFLOW_MACSEC_UNLOCK(unit); 1007 } 1008 return rv; 1009 } 1010 1011 1012 #else 1013 int _xflow_macsec_cmn_not_empty; 1014 #endif /* INCLUDE_XFLOW_MACSEC */