Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add background event handling for CASE establish #24099

Merged
merged 47 commits into from
Feb 15, 2023

Conversation

mlepage-google
Copy link
Contributor

CASE session establishment has operations which are costly, such as checking certificate chains. The handshake messages are processed in the event thread, so while these operations occur, other events cannot be processed. This delays responses, and can cause the event queue to fill entirely, which is fatal.

This commit adds support for background event processing, and uses it to process the most costly operations during CASESesssion::HandleSigma3.

  • add platform support for background event processing: ScheduleBackgroundWork, RunBackgroundEventLoop, etc.
  • add device config flags for enabling/disabling and configuration
  • add implementation for FreeRTOS platform
  • refactor some CASESession operations so they can be static, avoiding use of member variables
  • break HandlSigma3 into 3 parts A/B/C:
    • HandleSigma3a (foreground, processes incoming message)
    • HandleSigma3b (background, performs most costly operations)
    • HandleSigma3c (foreground, sends status report)

This breakup of HandleSigma3 was done in a fairly straightforward manner so it could be clearer, during review, that behaviour has not substantially changed. A subsequent commit should clean it up further by introducing helper code for managing the foreground/background work, lifetime of work object, when to send status report and/or abort pending establish, etc.

Also still to do is implementation for other platforms, and for other messages in CASESession (e.g. Sigma2), and for other costly operations (e.g. PASESession).

Currently, CASE session establishment is simplified:

  • only one pairing session is active at a time
  • it's always the same CASESession object in CASEServer
  • the two classes are higly coupled (e.g. CASEServer relies upon CASESession aborting the pending establish if an error occurs)

Therefore, HandleSigma3b can rely upon the lifetime of the CASESession object, use an additional state and sequence number to synchronize work across foreground/background, and avoid use of member variables. If and when CASE session establishment becomes more complex, assumptions should be revisited.

TESTING

Testing was performed on M5Stack (ESP32) by commissioning using the Google Home app on Android.

First, baseline behaviour with background events disabled:

  • If no errors, commissioning succeeds as before
  • If HandleSigma3a fails and sends a status report, pairing retries promptly and succeeds
  • If HandleSigma3a fails and cannot send a status report, pairing retries after about a minute and succeeds
  • If HandleSigma3c succeeds but cannot send a status report, pairing retries after about a minute and succeeds

Next, improved behaviour with background events enabled:

  • If no errors, commissioning succeeds as before
  • If HandleSigma3a fails and sends a status report, pairing retries promptly and succeeds
    • (this includes failure to schedule HandleSigma3b)
  • If HandleSigma3b fails and sends a status report, pairing retries promptly and succeeds
  • If HandleSigma3c fails and sends a status report, pairing retries promptly and succeeds
  • If HandleSigma3c succeeds but cannot send a status report, pairing retries after about a minute and succeeds
  • If HandleSigma3b is starved (scheduled but does not complete), after several minutes the failsafe timer fires, then Home app allows try again, which then succeeds
  • If HandleSigma3b is delayed (completes late), the sequence number is unexpected, so no status report is sent, then after several minutes the failsafe timer fires, then Home app allows try again, which then succeeds

CASE session establishment has operations which are costly, such as
checking certificate chains. The handshake messages are processed in the
event thread, so while these operations occur, other events cannot be
processed. This delays responses, and can cause the event queue to fill
entirely, which is fatal.

This commit adds support for background event processing, and uses it to
process the most costly operations during CASESesssion::HandleSigma3.

- add platform support for background event processing:
  ScheduleBackgroundWork, RunBackgroundEventLoop, etc.
- add device config flags for enabling/disabling and configuration
- add implementation for FreeRTOS platform
- refactor some CASESession operations so they can be static, avoiding
  use of member variables
- break HandlSigma3 into 3 parts A/B/C:
  - HandleSigma3a (foreground, processes incoming message)
  - HandleSigma3b (background, performs most costly operations)
  - HandleSigma3c (foreground, sends status report)

This breakup of HandleSigma3 was done in a fairly straightforward manner
so it could be clearer, during review, that behaviour has not
substantially changed. A subsequent commit should clean it up further by
introducing helper code for managing the foreground/background work,
lifetime of work object, when to send status report and/or abort pending
establish, etc.

Also still to do is implementation for other platforms, and for other
messages in CASESession (e.g. Sigma2), and for other costly operations
(e.g. PASESession).

Currently, CASE session establishment is simplified:

- only one pairing session is active at a time
- it's always the same CASESession object in CASEServer
- the two classes are higly coupled (e.g. CASEServer relies upon
  CASESession aborting the pending establish if an error occurs)

Therefore, HandleSigma3b can rely upon the lifetime of the CASESession
object, use an additional state and sequence number to synchronize
work across foreground/background, and avoid use of member variables.
If and when CASE session establishment becomes more complex, assumptions
should be revisited.

TESTING

Testing was performed on M5Stack (ESP32) by commissioning using the
Google Home app on Android.

First, baseline behaviour with background events disabled:

- If no errors, commissioning succeeds as before
- If HandleSigma3a fails and sends a status report,
  pairing retries promptly and succeeds
- If HandleSigma3a fails and cannot send a status report,
  pairing retries after about a minute and succeeds
- If HandleSigma3c succeeds but cannot send a status report,
  pairing retries after about a minute and succeeds

Next, improved behaviour with background events enabled:

- If no errors, commissioning succeeds as before
- If HandleSigma3a fails and sends a status report,
  pairing retries promptly and succeeds
  - (this includes failure to schedule HandleSigma3b)
- If HandleSigma3b fails and sends a status report,
  pairing retries promptly and succeeds
- If HandleSigma3c fails and sends a status report,
  pairing retries promptly and succeeds
- If HandleSigma3c succeeds but cannot send a status report,
  pairing retries after about a minute and succeeds
- If HandleSigma3b is starved (scheduled but does not complete),
  after several minutes the failsafe timer fires, then Home app
  allows try again, which then succeeds
- If HandleSigma3b is delayed (completes late), the sequence number
  is unexpected, so no status report is sent, then
  after several minutes the failsafe timer fires, then Home app
  allows try again, which then succeeds
@github-actions
Copy link

github-actions bot commented Dec 15, 2022

PR #24099: Size comparison from b49c3ed to 3a80c45

Increases above 0.2%:

platform target config section b49c3ed 3a80c45 change % change
bl602 lighting-app bl602 (read/write) 1356258 1363966 7708 0.6
.bss 86977 93737 6760 7.8
bl602+rpc (read/write) 1402034 1409734 7700 0.5
.bss 95017 101777 6760 7.1
bl702 lighting-app bl702 (read/write) 1196143 1203863 7720 0.6
.bss 67102 73862 6760 10.1
bl702+rpc (read/write) 1284651 1292355 7704 0.6
.bss 75118 81878 6760 9.0
efr32 lighting-app BRD4161A+rpc (read/write) 976292 983988 7696 0.8
.bss 152172 159020 6848 4.5
BRD4161A+rs911x (read/write) 1038648 1046336 7688 0.7
.bss 186648 193496 6848 3.7
BRD4187C (read/write) 1149676 1157560 7884 0.7
.bss 138568 145416 6848 4.9
lock-app BRD4161A+wf200 (read/write) 1069088 1078224 9136 0.9
.bss 158184 166712 8528 5.4
window-app BRD4187C (read/write) 1142312 1150196 7884 0.7
.bss 139984 146832 6848 4.9
qpg lighting-app qpg6105+debug .bss 100348 107084 6736 6.7
lock-app qpg6105+debug .bss 95828 102564 6736 7.0
Increases (23 builds for bl602, bl702, cc13x2_26x2, efr32, esp32, k32w, qpg)
platform target config section b49c3ed 3a80c45 change % change
bl602 lighting-app bl602 (read/write) 1356258 1363966 7708 0.6
.bss 86977 93737 6760 7.8
.text 1039050 1039860 810 0.1
bl602+rpc (read/write) 1402034 1409734 7700 0.5
.bss 95017 101777 6760 7.1
.text 1070472 1071284 812 0.1
bl702 lighting-app bl702 (read/write) 1196143 1203863 7720 0.6
.bss 67102 73862 6760 10.1
.debug_abbrev 1529020 1529946 926 0.1
.debug_aranges 132568 132648 80 0.1
.debug_frame 486468 486836 368 0.1
.debug_info 39187066 39214737 27671 0.1
.debug_line 5149996 5154978 4982 0.1
.debug_loc 3381237 3384365 3128 0.1
.debug_ranges 363808 364272 464 0.1
.debug_str 3480446 3482471 2025 0.1
.rodata 116352 116496 144 0.1
.strtab 569095 569253 158 0.0
.symtab 172176 172224 48 0.0
.text 956734 957550 816 0.1
bl702+rpc (read/write) 1284651 1292355 7704 0.6
.bss 75118 81878 6760 9.0
.debug_abbrev 1676352 1677260 908 0.1
.debug_aranges 140688 140768 80 0.1
.debug_frame 513888 514256 368 0.1
.debug_info 43479486 43507597 28111 0.1
.debug_line 5539445 5544417 4972 0.1
.debug_loc 3575958 3579057 3099 0.1
.debug_ranges 387344 387808 464 0.1
.debug_str 3882844 3884869 2025 0.1
.rodata 130112 130240 128 0.1
.strtab 629379 629537 158 0.0
.symtab 190352 190400 48 0.0
.text 1030716 1031532 816 0.1
cc13x2_26x2 all-clusters-app LP_CC2652R7 (read only) 679811 680623 812 0.1
.bss 81140 81172 32 0.0
.rodata 90003 90127 124 0.1
.text 589496 590184 688 0.1
all-clusters-minimal-app LP_CC2652R7 (read only) 644067 644879 812 0.1
(read/write) 157916 157948 32 0.0
.bss 80420 80452 32 0.0
.rodata 79139 79263 124 0.2
.text 564608 565296 688 0.1
lock-ftd LP_CC2652R7 (read only) 677343 678163 820 0.1
.bss 78788 78820 32 0.0
.rodata 77423 77555 132 0.2
.text 599440 600128 688 0.1
lock-mtd LP_CC2652R7 (read only) 662139 662955 816 0.1
.bss 74052 74084 32 0.0
.rodata 103507 103635 128 0.1
.text 558152 558840 688 0.1
pump-app LP_CC2652R7 (read only) 690271 691087 816 0.1
.bss 78756 78788 32 0.0
.rodata 90943 91071 128 0.1
.text 598844 599532 688 0.1
pump-controller-app LP_CC2652R7 (read only) 674179 675003 824 0.1
.bss 78860 78892 32 0.0
.rodata 86499 86627 128 0.1
.text 587200 587896 696 0.1
shell LP_CC2652R7 (read only) 671026 671846 820 0.1
.bss 83468 83500 32 0.0
.rodata 86738 86870 132 0.2
.text 583972 584660 688 0.1
efr32 lighting-app BRD4161A+rpc (read/write) 976292 983988 7696 0.8
.bss 152172 159020 6848 4.5
.text 821932 822780 848 0.1
BRD4161A+rs911x (read/write) 1038648 1046336 7688 0.7
.bss 186648 193496 6848 3.7
.text 849968 850804 836 0.1
BRD4187C (read/write) 1149676 1157560 7884 0.7
.bss 138568 145416 6848 4.9
.text 983996 985032 1036 0.1
lock-app BRD4161A+wf200 (read/write) 1069088 1078224 9136 0.9
.bss 158184 166712 8528 5.4
.text 908860 909468 608 0.1
window-app BRD4187C (read/write) 1142312 1150196 7884 0.7
.bss 139984 146832 6848 4.9
.text 975192 976228 1036 0.1
esp32 all-clusters-app c3devkit (read only) 1219358 1220440 1082 0.1
(read/write) 1790858 1791146 288 0.0
.dram0.bss 76912 76944 32 0.0
.flash.rodata 248296 248552 256 0.1
.flash.text 1219358 1220440 1082 0.1
m5stack (read only) 1233347 1234123 776 0.1
(read/write) 564107 564375 268 0.0
.dram0.bss 82064 82096 32 0.0
.flash.rodata 314100 314336 236 0.1
.flash.text 1227963 1228739 776 0.1
k32w contact k32w0+release (read/write) 662652 663340 688 0.1
.bss 77032 77064 32 0.0
.text 564404 565060 656 0.1
light k32w0+release (read/write) 673216 674072 856 0.1
.bss 74824 74856 32 0.0
.text 593604 594428 824 0.1
lock k32w0+release (read/write) 634188 634860 672 0.1
.bss 75584 75616 32 0.0
.text 553796 554436 640 0.1
qpg lighting-app qpg6105+debug (read/write) 1151180 1151988 808 0.1
.bss 100348 107084 6736 6.7
.text 598280 599088 808 0.1
lock-app qpg6105+debug (read/write) 1117476 1118292 816 0.1
.bss 95828 102564 6736 7.0
.text 564572 565388 816 0.1
Decreases (6 builds for cc13x2_26x2)
platform target config section b49c3ed 3a80c45 change % change
cc13x2_26x2 all-clusters-app LP_CC2652R7 (read/write) 171636 170856 -780 -0.5
lock-ftd LP_CC2652R7 (read/write) 171664 170876 -788 -0.5
lock-mtd LP_CC2652R7 (read/write) 182132 181348 -784 -0.4
pump-app LP_CC2652R7 (read/write) 159472 158688 -784 -0.5
pump-controller-app LP_CC2652R7 (read/write) 175668 174876 -792 -0.5
shell LP_CC2652R7 (read/write) 182748 181960 -788 -0.4
Full report (23 builds for bl602, bl702, cc13x2_26x2, efr32, esp32, k32w, qpg)
platform target config section b49c3ed 3a80c45 change % change
bl602 lighting-app bl602 (read/write) 1356258 1363966 7708 0.6
.bss 86977 93737 6760 7.8
.data 9984 9984 0 0.0
.text 1039050 1039860 810 0.1
bl602+rpc (read/write) 1402034 1409734 7700 0.5
.bss 95017 101777 6760 7.1
.data 10384 10384 0 0.0
.text 1070472 1071284 812 0.1
bl702 lighting-app bl702 (read only) 3262 3262 0 0.0
(read/write) 1196143 1203863 7720 0.6
.bleromro 6296 6296 0 0.0
.bleromrw 124 124 0 0.0
.boot2 688 688 0 0.0
.bss 67102 73862 6760 10.1
.bss_psram 30048 30048 0 0.0
.comment 48 48 0 0.0
.data 4048 4048 0 0.0
.debug_abbrev 1529020 1529946 926 0.1
.debug_aranges 132568 132648 80 0.1
.debug_frame 486468 486836 368 0.1
.debug_info 39187066 39214737 27671 0.1
.debug_line 5149996 5154978 4982 0.1
.debug_loc 3381237 3384365 3128 0.1
.debug_ranges 363808 364272 464 0.1
.debug_str 3480446 3482471 2025 0.1
.hbn 509 509 0 0.0
.hbn_noinit 260 260 0 0.0
.init 342 342 0 0.0
.init_array 144 144 0 0.0
.psram 0 0 0 0.0
.riscv.attributes 47 47 0 0.0
.rodata 116352 116496 144 0.1
.rsvd 3188 3188 0 0.0
.shstrtab 293 293 0 0.0
.stack 2048 2048 0 0.0
.strtab 569095 569253 158 0.0
.symtab 172176 172224 48 0.0
.tcm_data 36 36 0 0.0
.tcmcode 3262 3262 0 0.0
.text 0 0 0 0.0
956734 957550 816 0.1
bl702+rpc (read only) 3262 3262 0 0.0
(read/write) 1284651 1292355 7704 0.6
.bleromro 6296 6296 0 0.0
.bleromrw 124 124 0 0.0
.boot2 688 688 0 0.0
.bss 75118 81878 6760 9.0
.bss_psram 30304 30304 0 0.0
.comment 48 48 0 0.0
.data 4576 4576 0 0.0
.debug_abbrev 1676352 1677260 908 0.1
.debug_aranges 140688 140768 80 0.1
.debug_frame 513888 514256 368 0.1
.debug_info 43479486 43507597 28111 0.1
.debug_line 5539445 5544417 4972 0.1
.debug_loc 3575958 3579057 3099 0.1
.debug_ranges 387344 387808 464 0.1
.debug_str 3882844 3884869 2025 0.1
.hbn 509 509 0 0.0
.hbn_noinit 260 260 0 0.0
.init 342 342 0 0.0
.init_array 160 160 0 0.0
.psram 0 0 0 0.0
.riscv.attributes 47 47 0 0.0
.rodata 130112 130240 128 0.1
.rsvd 3188 3188 0 0.0
.shstrtab 293 293 0 0.0
.stack 2048 2048 0 0.0
.strtab 629379 629537 158 0.0
.symtab 190352 190400 48 0.0
.tcm_data 36 36 0 0.0
.tcmcode 3262 3262 0 0.0
.text 0 0 0 0.0
1030716 1031532 816 0.1
cc13x2_26x2 all-clusters-app LP_CC2652R7 (read only) 679811 680623 812 0.1
(read/write) 171636 170856 -780 -0.5
.bss 81140 81172 32 0.0
.data 3380 3380 0 0.0
.rodata 90003 90127 124 0.1
.text 589496 590184 688 0.1
all-clusters-minimal-app LP_CC2652R7 (read only) 644067 644879 812 0.1
(read/write) 157916 157948 32 0.0
.bss 80420 80452 32 0.0
.data 3380 3380 0 0.0
.rodata 79139 79263 124 0.2
.text 564608 565296 688 0.1
lock-ftd LP_CC2652R7 (read only) 677343 678163 820 0.1
(read/write) 171664 170876 -788 -0.5
.bss 78788 78820 32 0.0
.data 3304 3304 0 0.0
.rodata 77423 77555 132 0.2
.text 599440 600128 688 0.1
lock-mtd LP_CC2652R7 (read only) 662139 662955 816 0.1
(read/write) 182132 181348 -784 -0.4
.bss 74052 74084 32 0.0
.data 3304 3304 0 0.0
.rodata 103507 103635 128 0.1
.text 558152 558840 688 0.1
pump-app LP_CC2652R7 (read only) 690271 691087 816 0.1
(read/write) 159472 158688 -784 -0.5
.bss 78756 78788 32 0.0
.data 3296 3296 0 0.0
.rodata 90943 91071 128 0.1
.text 598844 599532 688 0.1
pump-controller-app LP_CC2652R7 (read only) 674179 675003 824 0.1
(read/write) 175668 174876 -792 -0.5
.bss 78860 78892 32 0.0
.data 3292 3292 0 0.0
.rodata 86499 86627 128 0.1
.text 587200 587896 696 0.1
shell LP_CC2652R7 (read only) 671026 671846 820 0.1
(read/write) 182748 181960 -788 -0.4
.bss 83468 83500 32 0.0
.data 3376 3376 0 0.0
.rodata 86738 86870 132 0.2
.text 583972 584660 688 0.1
efr32 lighting-app BRD4161A+rpc (read/write) 976292 983988 7696 0.8
.bss 152172 159020 6848 4.5
.data 2168 2168 0 0.0
.text 821932 822780 848 0.1
BRD4161A+rs911x (read/write) 1038648 1046336 7688 0.7
.bss 186648 193496 6848 3.7
.data 2012 2012 0 0.0
.text 849968 850804 836 0.1
BRD4187C (read/write) 1149676 1157560 7884 0.7
.bss 138568 145416 6848 4.9
.data 2516 2516 0 0.0
.text 983996 985032 1036 0.1
lock-app BRD4161A+wf200 (read/write) 1069088 1078224 9136 0.9
.bss 158184 166712 8528 5.4
.data 2020 2020 0 0.0
.text 908860 909468 608 0.1
window-app BRD4187C (read/write) 1142312 1150196 7884 0.7
.bss 139984 146832 6848 4.9
.data 2540 2540 0 0.0
.text 975192 976228 1036 0.1
esp32 all-clusters-app c3devkit (read only) 1219358 1220440 1082 0.1
(read/write) 1790858 1791146 288 0.0
.dram0.bss 76912 76944 32 0.0
.dram0.data 13928 13928 0 0.0
.flash.rodata 248296 248552 256 0.1
.flash.text 1219358 1220440 1082 0.1
.iram0.text 71188 71188 0 0.0
m5stack (read only) 1233347 1234123 776 0.1
(read/write) 564107 564375 268 0.0
.dram0.bss 82064 82096 32 0.0
.dram0.data 34224 34224 0 0.0
.flash.rodata 314100 314336 236 0.1
.flash.text 1227963 1228739 776 0.1
.iram0.text 124803 124803 0 0.0
k32w contact k32w0+release (read/write) 662652 663340 688 0.1
.bss 77032 77064 32 0.0
.data 2104 2104 0 0.0
.text 564404 565060 656 0.1
light k32w0+release (read/write) 673216 674072 856 0.1
.bss 74824 74856 32 0.0
.data 2060 2060 0 0.0
.text 593604 594428 824 0.1
lock k32w0+release (read/write) 634188 634860 672 0.1
.bss 75584 75616 32 0.0
.data 2080 2080 0 0.0
.text 553796 554436 640 0.1
qpg lighting-app qpg6105+debug (read/write) 1151180 1151988 808 0.1
.bss 100348 107084 6736 6.7
.data 840 840 0 0.0
.text 598280 599088 808 0.1
lock-app qpg6105+debug (read/write) 1117476 1118292 816 0.1
.bss 95828 102564 6736 7.0
.data 836 836 0 0.0
.text 564572 565388 816 0.1

examples/platform/esp32/common/CHIPDeviceManager.cpp Outdated Show resolved Hide resolved
src/credentials/FabricTable.h Outdated Show resolved Hide resolved
src/include/platform/CHIPDeviceEvent.h Outdated Show resolved Hide resolved
src/include/platform/PlatformManager.h Outdated Show resolved Hide resolved
src/include/platform/PlatformManager.h Outdated Show resolved Hide resolved
src/protocols/secure_channel/CASEServer.cpp Outdated Show resolved Hide resolved
src/protocols/secure_channel/CASESession.cpp Outdated Show resolved Hide resolved
src/protocols/secure_channel/CASESession.cpp Outdated Show resolved Hide resolved
src/protocols/secure_channel/CASESession.cpp Outdated Show resolved Hide resolved
@github-actions
Copy link

PR #24099: Size comparison from 02bc67e to 9ffd859

Increases (1 build for cc32xx)
platform target config section 02bc67e 9ffd859 change % change
cc32xx lock CC3235SF_LAUNCHXL (read only) 640233 641097 864 0.1
(read/write) 204084 204108 24 0.0
.bss 197488 197512 24 0.0
.debug_abbrev 928439 928959 520 0.1
.debug_aranges 87352 87448 96 0.1
.debug_frame 299840 300116 276 0.1
.debug_info 20194443 20216665 22222 0.1
.debug_line 2649822 2652677 2855 0.1
.debug_loc 2785969 2789296 3327 0.1
.debug_ranges 280696 281192 496 0.2
.debug_str 3001474 3003605 2131 0.1
.rodata 105585 105633 48 0.0
.strtab 375840 376279 439 0.1
.symtab 255856 256080 224 0.1
.text 532524 533344 820 0.2
Full report (1 build for cc32xx)
platform target config section 02bc67e 9ffd859 change % change
cc32xx lock CC3235SF_LAUNCHXL 0 0 0 0.0
(read only) 640233 641097 864 0.1
(read/write) 204084 204108 24 0.0
.ARM.attributes 44 44 0 0.0
.ARM.exidx 8 8 0 0.0
.bss 197488 197512 24 0.0
.comment 194 194 0 0.0
.data 1476 1476 0 0.0
.debug_abbrev 928439 928959 520 0.1
.debug_aranges 87352 87448 96 0.1
.debug_frame 299840 300116 276 0.1
.debug_info 20194443 20216665 22222 0.1
.debug_line 2649822 2652677 2855 0.1
.debug_loc 2785969 2789296 3327 0.1
.debug_ranges 280696 281192 496 0.2
.debug_str 3001474 3003605 2131 0.1
.ramVecs 780 780 0 0.0
.resetVecs 64 64 0 0.0
.rodata 105585 105633 48 0.0
.shstrtab 232 232 0 0.0
.stab 204 204 0 0.0
.stabstr 441 441 0 0.0
.stack 2048 2048 0 0.0
.strtab 375840 376279 439 0.1
.symtab 255856 256080 224 0.1
.text 532524 533344 820 0.2

@mlepage-google mlepage-google marked this pull request as ready for review February 13, 2023 20:41
@github-actions
Copy link

PR #24099: Size comparison from b3c599d to 77ef3cc

Increases (1 build for cc32xx)
platform target config section b3c599d 77ef3cc change % change
cc32xx lock CC3235SF_LAUNCHXL (read only) 640361 641225 864 0.1
(read/write) 204084 204108 24 0.0
.bss 197488 197512 24 0.0
.debug_abbrev 928461 928981 520 0.1
.debug_aranges 87352 87448 96 0.1
.debug_frame 299840 300116 276 0.1
.debug_info 20180781 20203004 22223 0.1
.debug_line 2649926 2652781 2855 0.1
.debug_loc 2786017 2789344 3327 0.1
.debug_ranges 280728 281224 496 0.2
.debug_str 3005287 3007418 2131 0.1
.rodata 105633 105681 48 0.0
.strtab 375902 376341 439 0.1
.symtab 255856 256080 224 0.1
.text 532604 533424 820 0.2
Full report (1 build for cc32xx)
platform target config section b3c599d 77ef3cc change % change
cc32xx lock CC3235SF_LAUNCHXL 0 0 0 0.0
(read only) 640361 641225 864 0.1
(read/write) 204084 204108 24 0.0
.ARM.attributes 44 44 0 0.0
.ARM.exidx 8 8 0 0.0
.bss 197488 197512 24 0.0
.comment 194 194 0 0.0
.data 1476 1476 0 0.0
.debug_abbrev 928461 928981 520 0.1
.debug_aranges 87352 87448 96 0.1
.debug_frame 299840 300116 276 0.1
.debug_info 20180781 20203004 22223 0.1
.debug_line 2649926 2652781 2855 0.1
.debug_loc 2786017 2789344 3327 0.1
.debug_ranges 280728 281224 496 0.2
.debug_str 3005287 3007418 2131 0.1
.ramVecs 780 780 0 0.0
.resetVecs 64 64 0 0.0
.rodata 105633 105681 48 0.0
.shstrtab 232 232 0 0.0
.stab 204 204 0 0.0
.stabstr 441 441 0 0.0
.stack 2048 2048 0 0.0
.strtab 375902 376341 439 0.1
.symtab 255856 256080 224 0.1
.text 532604 533424 820 0.2

@mspang
Copy link
Contributor

mspang commented Feb 14, 2023

We would like to see the crypto abstraction itself admit asynchronous implementations, in particular of OperationalKeystore::SignWithOpKeyPair as that is the critical API to securing operational private keys.

Doing it this way has a few limitations:

  • Based on the docs of the background queue, I guess we are ruling out concurrent execution of crypto operations.
  • Since the operations are still synchronous, an implementation that executes the work out of process is still forced to block. While blocking a secondary thread is much less harmful that blocking the main thread, it's unnecessary.

Changing the crypto APIs to be asynchronous will fix those limitations - SignOpWithKeyPair should take a callback to indicate when the work is done.

@github-actions
Copy link

github-actions bot commented Feb 15, 2023

PR #24099: Size comparison from a6d2883 to 42c8fbf

Increases above 0.2%:

platform target config section a6d2883 42c8fbf change % change
esp32 all-clusters-app c3devkit (read/write) 1519706 1585426 65720 4.3
Increases (43 builds for bl602, bl702, cc13x2_26x2, cc32xx, cyw30739, efr32, esp32, k32w, linux, mbed, nrfconnect, psoc6, qpg, telink)
platform target config section a6d2883 42c8fbf change % change
bl602 lighting-app bl602 (read/write) 1347010 1348038 1028 0.1
.bss 94810 94834 24 0.0
.text 1023524 1024368 844 0.1
bl602+rpc (read/write) 1392458 1393470 1012 0.1
.bss 102858 102882 24 0.0
.text 1054458 1055300 842 0.1
bl702 lighting-app bl702 (read/write) 1185363 1186395 1032 0.1
.bss 69913 69937 24 0.0
.debug_abbrev 1551885 1552807 922 0.1
.debug_aranges 134280 134376 96 0.1
.debug_frame 491764 492068 304 0.1
.debug_info 40624236 40650165 25929 0.1
.debug_line 5277493 5281823 4330 0.1
.debug_loc 3409452 3411681 2229 0.1
.debug_ranges 371744 372240 496 0.1
.debug_str 3559730 3561847 2117 0.1
.rodata 107328 107488 160 0.1
.strtab 572957 573396 439 0.1
.symtab 173536 173616 80 0.0
.text 952920 953764 844 0.1
bl702+rpc (read/write) 1278519 1279551 1032 0.1
.bss 77961 77985 24 0.0
.debug_abbrev 1700393 1701297 904 0.1
.debug_aranges 142512 142608 96 0.1
.debug_frame 519512 519816 304 0.1
.debug_info 45033171 45059523 26352 0.1
.debug_line 5676500 5680819 4319 0.1
.debug_loc 3606370 3608557 2187 0.1
.debug_ranges 395512 396008 496 0.1
.debug_str 3963222 3965339 2117 0.1
.rodata 121968 122128 160 0.1
.strtab 634016 634455 439 0.1
.symtab 192000 192080 80 0.0
.text 1030320 1031162 842 0.1
cc13x2_26x2 all-clusters-app LP_CC2652R7 (read only) 678395 679099 704 0.1
.bss 80884 80908 24 0.0
.rodata 88403 88443 40 0.0
.text 589676 590340 664 0.1
all-clusters-minimal-app LP_CC2652R7 (read only) 642219 642923 704 0.1
(read/write) 157576 157600 24 0.0
.bss 80076 80100 24 0.0
.rodata 78195 78235 40 0.1
.text 563704 564368 664 0.1
lock-ftd LP_CC2652R7 (read only) 675279 676007 728 0.1
.bss 78324 78348 24 0.0
.rodata 76703 76751 48 0.1
.text 598096 598776 680 0.1
lock-mtd LP_CC2652R7 (read only) 661707 662427 720 0.1
.bss 73580 73604 24 0.0
.rodata 103291 103331 40 0.0
.text 557936 558616 680 0.1
pump-app LP_CC2652R7 (read only) 688339 689059 720 0.1
.bss 78292 78316 24 0.0
.rodata 90827 90875 48 0.1
.text 597032 597704 672 0.1
pump-controller-app LP_CC2652R7 (read only) 673707 674443 736 0.1
.bss 78404 78428 24 0.0
.rodata 86867 86923 56 0.1
.text 586360 587040 680 0.1
shell LP_CC2652R7 (read only) 669658 670370 712 0.1
.bss 82956 82980 24 0.0
.rodata 85154 85202 48 0.1
.text 584192 584856 664 0.1
cc32xx lock CC3235SF_LAUNCHXL (read only) 640577 641433 856 0.1
(read/write) 204100 204124 24 0.0
.bss 197504 197528 24 0.0
.debug_abbrev 930806 931326 520 0.1
.debug_aranges 87360 87456 96 0.1
.debug_frame 299864 300140 276 0.1
.debug_info 20307078 20329767 22689 0.1
.debug_line 2654650 2657506 2856 0.1
.debug_loc 2787110 2790415 3305 0.1
.debug_ranges 280904 281400 496 0.2
.debug_str 3001983 3004114 2131 0.1
.rodata 105665 105713 48 0.0
.strtab 375952 376391 439 0.1
.symtab 255888 256112 224 0.1
.text 532792 533596 804 0.2
cyw30739 light cyw930739m2evb_01 (read/write) 585014 585678 664 0.1
.app_xip_area 461800 462440 640 0.1
.bss 65656 65680 24 0.0
lock cyw930739m2evb_01 (read/write) 588986 589650 664 0.1
.app_xip_area 460476 461116 640 0.1
.bss 70944 70968 24 0.0
ota-requestor-no-progress-logging cyw930739m2evb_01 (read/write) 550202 550954 752 0.1
.app_xip_area 432492 433220 728 0.2
.bss 60200 60224 24 0.0
efr32 lighting-app BRD4161A+rs9116 (read/write) 1038816 1039688 872 0.1
.bss 181584 181608 24 0.0
.text 855164 856012 848 0.1
BRD4187C (read/write) 1135744 1136816 1072 0.1
.bss 133264 133288 24 0.0
.text 975352 976400 1048 0.1
lock-app BRD4161A+wf200 (read/write) 1066416 1067144 728 0.1
.bss 153104 153128 24 0.0
.text 911236 911940 704 0.1
window-app BRD4187C (read/write) 1137360 1138424 1064 0.1
.bss 134856 134880 24 0.0
.text 975336 976376 1040 0.1
esp32 all-clusters-app c3devkit (read only) 1047848 1048660 812 0.1
(read/write) 1519706 1585426 65720 4.3
.dram0.bss 77968 77992 24 0.0
.flash.rodata 221728 221880 152 0.1
.flash.text 1047848 1048660 812 0.1
m5stack (read only) 1100195 1100867 672 0.1
(read/write) 501351 501515 164 0.0
.dram0.bss 83016 83040 24 0.0
.flash.rodata 250484 250624 140 0.1
.flash.text 1094811 1095483 672 0.1
k32w contact k32w0+release (read/write) 668916 669740 824 0.1
.bss 77644 77668 24 0.0
.text 569960 570760 800 0.1
light k32w0+release (read/write) 667764 668596 832 0.1
.bss 77340 77364 24 0.0
.text 569124 569932 808 0.1
lock k32w0+release (read/write) 624576 625400 824 0.1
.bss 75476 75500 24 0.0
.text 544240 545040 800 0.1
linux chip-tool-ipv6only arm64 (read only) 12001540 12005652 4112 0.0
(read/write) 727720 727768 48 0.0
.data.rel.ro 670008 670056 48 0.0
.rodata 584148 584180 32 0.0
.text 9690628 9694660 4032 0.0
thermostat-no-ble arm64 (read only) 2512388 2516436 4048 0.2
(read/write) 145256 145320 64 0.0
.bss 56472 56488 16 0.0
.data.rel.ro 77496 77544 48 0.1
.rodata 151136 151184 48 0.0
.text 2099136 2103088 3952 0.2
mbed lock-app CY8CPROTO_062_4343W+release (read/write) 2464912 2467736 2824 0.1
.bss 215908 215932 24 0.0
.text 1427556 1430380 2824 0.2
nrfconnect all-clusters-app nrf52840dk_nrf52840 (read/write) 1162552 1163296 744 0.1
bss 143539 143563 24 0.0
rodata 134468 134508 40 0.0
text 804656 805372 716 0.1
nrf7002dk_nrf5340_cpuapp (read/write) 1367836 1368660 824 0.1
bss 106002 106026 24 0.0
rodata 211900 211940 40 0.0
text 764428 765148 720 0.1
all-clusters-minimal-app nrf52840dk_nrf52840 (read/write) 1108548 1109308 760 0.1
bss 142695 142719 24 0.0
rodata 111456 111496 40 0.0
text 774636 775356 720 0.1
psoc6 all-clusters cy8ckit_062s2_43012 (read/write) 1757956 1758908 952 0.1
.bss 189816 189840 24 0.0
.debug_abbrev 1254352 1254858 506 0.0
.debug_aranges 111416 111512 96 0.1
.debug_frame 374040 374312 272 0.1
.debug_info 28027823 28053119 25296 0.1
.debug_line 3789424 3792308 2884 0.1
.debug_loc 3682009 3685156 3147 0.1
.debug_ranges 362608 363128 520 0.1
.debug_str 3509822 3511953 2131 0.1
.strtab 578434 578873 439 0.1
.symtab 425104 425360 256 0.1
.text 1557080 1558008 928 0.1
all-clusters-minimal cy8ckit_062s2_43012 (read/write) 1699540 1700500 960 0.1
.bss 189008 189032 24 0.0
.debug_abbrev 1239987 1240493 506 0.0
.debug_aranges 110680 110776 96 0.1
.debug_frame 376484 376756 272 0.1
.debug_info 27574458 27599754 25296 0.1
.debug_line 3797920 3800820 2900 0.1
.debug_loc 3665740 3668887 3147 0.1
.debug_ranges 360576 361096 520 0.1
.debug_str 3495575 3497706 2131 0.1
.strtab 539642 540081 439 0.1
.symtab 410384 410640 256 0.1
.text 1499480 1500416 936 0.1
light cy8ckit_062s2_43012 (read/write) 1612596 1613564 968 0.1
.bss 180896 180920 24 0.0
.debug_abbrev 1074285 1074791 506 0.0
.debug_aranges 102888 102984 96 0.1
.debug_frame 346900 347172 272 0.1
.debug_info 22913745 22938559 24814 0.1
.debug_line 3350067 3352943 2876 0.1
.debug_loc 3343673 3346821 3148 0.1
.debug_ranges 319752 320272 520 0.2
.debug_str 3298532 3300663 2131 0.1
.strtab 474810 475249 439 0.1
.symtab 378128 378384 256 0.1
.text 1420848 1421792 944 0.1
lock cy8ckit_062s2_43012 (read/write) 1646852 1647796 944 0.1
.bss 185864 185888 24 0.0
.debug_abbrev 1076025 1076531 506 0.0
.debug_aranges 103328 103424 96 0.1
.debug_frame 348860 349132 272 0.1
.debug_info 23144485 23169300 24815 0.1
.debug_line 3351827 3354698 2871 0.1
.debug_loc 3366614 3369764 3150 0.1
.debug_ranges 321664 322184 520 0.2
.debug_str 3315820 3317951 2131 0.1
.strtab 478223 478662 439 0.1
.symtab 380320 380576 256 0.1
.text 1450128 1451048 920 0.1
qpg lighting-app qpg6105+debug (read/write) 1149220 1149940 720 0.1
.bss 99908 99932 24 0.0
.text 596320 597040 720 0.1
lock-app qpg6105+debug (read/write) 1116964 1117676 712 0.1
.bss 96404 96428 24 0.0
.text 564060 564772 712 0.1
telink all-clusters-app tlsr9518adk80d (read/write) 1013700 1014548 848 0.1
bss 97912 97936 24 0.0
text 684662 685446 784 0.1
all-clusters-minimal-app tlsr9518adk80d (read/write) 950084 950932 848 0.1
bss 96964 96988 24 0.0
text 646938 647722 784 0.1
contact-sensor-app tlsr9518adk80d (read/write) 854944 855800 856 0.1
bss 89084 89108 24 0.0
text 577836 578624 788 0.1
light-switch-app tlsr9518adk80d (read/write) 870700 871548 848 0.1
bss 89168 89192 24 0.0
text 591882 592668 786 0.1
lighting-app tlsr9518adk80d (read/write) 948036 948892 856 0.1
bss 97320 97344 24 0.0
text 657284 658070 786 0.1
ota-requestor-app tlsr9518adk80d (read/write) 882036 882884 848 0.1
bss 90120 90144 24 0.0
text 601626 602414 788 0.1
thermostat tlsr9518adk80d (read/write) 874904 875752 848 0.1
bss 90560 90584 24 0.0
text 593464 594250 786 0.1
Decreases (10 builds for cc13x2_26x2, psoc6)
platform target config section a6d2883 42c8fbf change % change
cc13x2_26x2 all-clusters-app LP_CC2652R7 (read/write) 172796 172116 -680 -0.4
lock-ftd LP_CC2652R7 (read/write) 173264 172560 -704 -0.4
lock-mtd LP_CC2652R7 (read/write) 182092 181396 -696 -0.4
pump-app LP_CC2652R7 (read/write) 160940 160244 -696 -0.4
pump-controller-app LP_CC2652R7 (read/write) 175684 174972 -712 -0.4
shell LP_CC2652R7 (read/write) 183604 182916 -688 -0.4
psoc6 all-clusters cy8ckit_062s2_43012 (read only) 840856 840832 -24 -0.0
.heap 840856 840832 -24 -0.0
all-clusters-minimal cy8ckit_062s2_43012 (read only) 841672 841648 -24 -0.0
.heap 841672 841648 -24 -0.0
light cy8ckit_062s2_43012 (read only) 849984 849960 -24 -0.0
.heap 849984 849960 -24 -0.0
lock cy8ckit_062s2_43012 (read only) 845008 844984 -24 -0.0
.heap 845008 844984 -24 -0.0
Full report (43 builds for bl602, bl702, cc13x2_26x2, cc32xx, cyw30739, efr32, esp32, k32w, linux, mbed, nrfconnect, psoc6, qpg, telink)
platform target config section a6d2883 42c8fbf change % change
bl602 lighting-app bl602 (read/write) 1347010 1348038 1028 0.1
.bss 94810 94834 24 0.0
.data 9736 9736 0 0.0
.text 1023524 1024368 844 0.1
bl602+rpc (read/write) 1392458 1393470 1012 0.1
.bss 102858 102882 24 0.0
.data 10128 10128 0 0.0
.text 1054458 1055300 842 0.1
bl702 lighting-app bl702 (read only) 3358 3358 0 0.0
(read/write) 1185363 1186395 1032 0.1
.bleromro 6342 6342 0 0.0
.bleromrw 124 124 0 0.0
.boot2 292 292 0 0.0
.bss 69913 69937 24 0.0
.bss_psram 30064 30064 0 0.0
.comment 48 48 0 0.0
.data 4056 4056 0 0.0
.debug_abbrev 1551885 1552807 922 0.1
.debug_aranges 134280 134376 96 0.1
.debug_frame 491764 492068 304 0.1
.debug_info 40624236 40650165 25929 0.1
.debug_line 5277493 5281823 4330 0.1
.debug_loc 3409452 3411681 2229 0.1
.debug_ranges 371744 372240 496 0.1
.debug_str 3559730 3561847 2117 0.1
.hbn 536 536 0 0.0
.hbn_noinit 260 260 0 0.0
.init 342 342 0 0.0
.init_array 144 144 0 0.0
.psram 0 0 0 0.0
.riscv.attributes 47 47 0 0.0
.rodata 107328 107488 160 0.1
.rsvd 2960 2960 0 0.0
.sha_ocram 72 72 0 0.0
.shstrtab 304 304 0 0.0
.stack 2048 2048 0 0.0
.strtab 572957 573396 439 0.1
.symtab 173536 173616 80 0.0
.tcm_data 36 36 0 0.0
.tcmcode 3358 3358 0 0.0
.text 0 0 0 0.0
952920 953764 844 0.1
bl702+rpc (read only) 3358 3358 0 0.0
(read/write) 1278519 1279551 1032 0.1
.bleromro 6342 6342 0 0.0
.bleromrw 124 124 0 0.0
.boot2 292 292 0 0.0
.bss 77961 77985 24 0.0
.bss_psram 30320 30320 0 0.0
.comment 48 48 0 0.0
.data 4608 4608 0 0.0
.debug_abbrev 1700393 1701297 904 0.1
.debug_aranges 142512 142608 96 0.1
.debug_frame 519512 519816 304 0.1
.debug_info 45033171 45059523 26352 0.1
.debug_line 5676500 5680819 4319 0.1
.debug_loc 3606370 3608557 2187 0.1
.debug_ranges 395512 396008 496 0.1
.debug_str 3963222 3965339 2117 0.1
.hbn 536 536 0 0.0
.hbn_noinit 260 260 0 0.0
.init 342 342 0 0.0
.init_array 160 160 0 0.0
.psram 0 0 0 0.0
.riscv.attributes 47 47 0 0.0
.rodata 121968 122128 160 0.1
.rsvd 2960 2960 0 0.0
.sha_ocram 72 72 0 0.0
.shstrtab 304 304 0 0.0
.stack 2048 2048 0 0.0
.strtab 634016 634455 439 0.1
.symtab 192000 192080 80 0.0
.tcm_data 36 36 0 0.0
.tcmcode 3358 3358 0 0.0
.text 0 0 0 0.0
1030320 1031162 842 0.1
cc13x2_26x2 all-clusters-app LP_CC2652R7 (read only) 678395 679099 704 0.1
(read/write) 172796 172116 -680 -0.4
.bss 80884 80908 24 0.0
.data 3384 3384 0 0.0
.rodata 88403 88443 40 0.0
.text 589676 590340 664 0.1
all-clusters-minimal-app LP_CC2652R7 (read only) 642219 642923 704 0.1
(read/write) 157576 157600 24 0.0
.bss 80076 80100 24 0.0
.data 3384 3384 0 0.0
.rodata 78195 78235 40 0.1
.text 563704 564368 664 0.1
lock-ftd LP_CC2652R7 (read only) 675279 676007 728 0.1
(read/write) 173264 172560 -704 -0.4
.bss 78324 78348 24 0.0
.data 3312 3312 0 0.0
.rodata 76703 76751 48 0.1
.text 598096 598776 680 0.1
lock-mtd LP_CC2652R7 (read only) 661707 662427 720 0.1
(read/write) 182092 181396 -696 -0.4
.bss 73580 73604 24 0.0
.data 3312 3312 0 0.0
.rodata 103291 103331 40 0.0
.text 557936 558616 680 0.1
pump-app LP_CC2652R7 (read only) 688339 689059 720 0.1
(read/write) 160940 160244 -696 -0.4
.bss 78292 78316 24 0.0
.data 3276 3276 0 0.0
.rodata 90827 90875 48 0.1
.text 597032 597704 672 0.1
pump-controller-app LP_CC2652R7 (read only) 673707 674443 736 0.1
(read/write) 175684 174972 -712 -0.4
.bss 78404 78428 24 0.0
.data 3300 3300 0 0.0
.rodata 86867 86923 56 0.1
.text 586360 587040 680 0.1
shell LP_CC2652R7 (read only) 669658 670370 712 0.1
(read/write) 183604 182916 -688 -0.4
.bss 82956 82980 24 0.0
.data 3380 3380 0 0.0
.rodata 85154 85202 48 0.1
.text 584192 584856 664 0.1
cc32xx lock CC3235SF_LAUNCHXL (read only) 640577 641433 856 0.1
(read/write) 204100 204124 24 0.0
.ARM.attributes 44 44 0 0.0
.ARM.exidx 8 8 0 0.0
.bss 197504 197528 24 0.0
.comment 194 194 0 0.0
.data 1476 1476 0 0.0
.debug_abbrev 930806 931326 520 0.1
.debug_aranges 87360 87456 96 0.1
.debug_frame 299864 300140 276 0.1
.debug_info 20307078 20329767 22689 0.1
.debug_line 2654650 2657506 2856 0.1
.debug_loc 2787110 2790415 3305 0.1
.debug_ranges 280904 281400 496 0.2
.debug_str 3001983 3004114 2131 0.1
.ramVecs 780 780 0 0.0
.resetVecs 64 64 0 0.0
.rodata 105665 105713 48 0.0
.shstrtab 232 232 0 0.0
.stab 204 204 0 0.0
.stabstr 441 441 0 0.0
.stack 2048 2048 0 0.0
.strtab 375952 376391 439 0.1
.symtab 255888 256112 224 0.1
.text 0 0 0 0.0
532792 533596 804 0.2
cyw30739 light cyw930739m2evb_01 (read/write) 585014 585678 664 0.1
.app_xip_area 461800 462440 640 0.1
.bss 65656 65680 24 0.0
.data 736 736 0 0.0
.rodata 0 0 0 0.0
.text 112 112 0 0.0
lock cyw930739m2evb_01 (read/write) 588986 589650 664 0.1
.app_xip_area 460476 461116 640 0.1
.bss 70944 70968 24 0.0
.data 744 744 0 0.0
.rodata 0 0 0 0.0
.text 112 112 0 0.0
ota-requestor-no-progress-logging cyw930739m2evb_01 (read/write) 550202 550954 752 0.1
.app_xip_area 432492 433220 728 0.2
.bss 60200 60224 24 0.0
.data 692 692 0 0.0
.rodata 0 0 0 0.0
.text 112 112 0 0.0
efr32 lighting-app BRD4161A+rs9116 (read/write) 1038816 1039688 872 0.1
.bss 181584 181608 24 0.0
.data 2044 2044 0 0.0
.text 855164 856012 848 0.1
BRD4187C (read/write) 1135744 1136816 1072 0.1
.bss 133264 133288 24 0.0
.data 2532 2532 0 0.0
.text 975352 976400 1048 0.1
lock-app BRD4161A+wf200 (read/write) 1066416 1067144 728 0.1
.bss 153104 153128 24 0.0
.data 2052 2052 0 0.0
.text 911236 911940 704 0.1
window-app BRD4187C (read/write) 1137360 1138424 1064 0.1
.bss 134856 134880 24 0.0
.data 2572 2572 0 0.0
.text 975336 976376 1040 0.1
esp32 all-clusters-app c3devkit (read only) 1047848 1048660 812 0.1
(read/write) 1519706 1585426 65720 4.3
.dram0.bss 77968 77992 24 0.0
.dram0.data 13792 13792 0 0.0
.flash.rodata 221728 221880 152 0.1
.flash.text 1047848 1048660 812 0.1
.iram0.text 72896 72896 0 0.0
m5stack (read only) 1100195 1100867 672 0.1
(read/write) 501351 501515 164 0.0
.dram0.bss 83016 83040 24 0.0
.dram0.data 34080 34080 0 0.0
.flash.rodata 250484 250624 140 0.1
.flash.text 1094811 1095483 672 0.1
.iram0.text 124855 124855 0 0.0
k32w contact k32w0+release (read/write) 668916 669740 824 0.1
.bss 77644 77668 24 0.0
.data 2200 2200 0 0.0
.text 569960 570760 800 0.1
light k32w0+release (read/write) 667764 668596 832 0.1
.bss 77340 77364 24 0.0
.data 2188 2188 0 0.0
.text 569124 569932 808 0.1
lock k32w0+release (read/write) 624576 625400 824 0.1
.bss 75476 75500 24 0.0
.data 2132 2132 0 0.0
.text 544240 545040 800 0.1
linux chip-tool-ipv6only arm64 (read only) 12001540 12005652 4112 0.0
(read/write) 727720 727768 48 0.0
.bss 34248 34248 0 0.0
.data 3008 3008 0 0.0
.data.rel.ro 670008 670056 48 0.0
.dynamic 560 560 0 0.0
.got 15256 15256 0 0.0
.init 24 24 0 0.0
.init_array 208 208 0 0.0
.rodata 584148 584180 32 0.0
.text 9690628 9694660 4032 0.0
thermostat-no-ble arm64 (read only) 2512388 2516436 4048 0.2
(read/write) 145256 145320 64 0.0
.bss 56472 56488 16 0.0
.data 1824 1824 0 0.0
.data.rel.ro 77496 77544 48 0.1
.dynamic 560 560 0 0.0
.got 5408 5408 0 0.0
.init 24 24 0 0.0
.init_array 432 432 0 0.0
.rodata 151136 151184 48 0.0
.text 2099136 2103088 3952 0.2
mbed lock-app CY8CPROTO_062_4343W+release (read only) 6224 6224 0 0.0
(read/write) 2464912 2467736 2824 0.1
.bss 215908 215932 24 0.0
.data 5880 5880 0 0.0
.text 1427556 1430380 2824 0.2
nrfconnect all-clusters-app nrf52840dk_nrf52840 (read only) 4 4 0 0.0
(read/write) 1162552 1163296 744 0.1
bss 143539 143563 24 0.0
rodata 134468 134508 40 0.0
text 804656 805372 716 0.1
nrf7002dk_nrf5340_cpuapp (read only) 4 4 0 0.0
(read/write) 1367836 1368660 824 0.1
bss 106002 106026 24 0.0
rodata 211900 211940 40 0.0
text 764428 765148 720 0.1
all-clusters-minimal-app nrf52840dk_nrf52840 (read only) 4 4 0 0.0
(read/write) 1108548 1109308 760 0.1
bss 142695 142719 24 0.0
rodata 111456 111496 40 0.0
text 774636 775356 720 0.1
psoc6 all-clusters cy8ckit_062s2_43012 0 0 0 0.0
(read only) 840856 840832 -24 -0.0
(read/write) 1757956 1758908 952 0.1
.ARM.attributes 46 46 0 0.0
.ARM.exidx 8 8 0 0.0
.bss 189816 189840 24 0.0
.comment 200 200 0 0.0
.copy.table 24 24 0 0.0
.cy_m0p_image 6216 6216 0 0.0
.cy_sharedmem 8 8 0 0.0
.data 2672 2672 0 0.0
.debug_abbrev 1254352 1254858 506 0.0
.debug_aranges 111416 111512 96 0.1
.debug_frame 374040 374312 272 0.1
.debug_info 28027823 28053119 25296 0.1
.debug_line 3789424 3792308 2884 0.1
.debug_loc 3682009 3685156 3147 0.1
.debug_ranges 362608 363128 520 0.1
.debug_str 3509822 3511953 2131 0.1
.heap 840856 840832 -24 -0.0
.noinit 148 148 0 0.0
.ramVectors 736 736 0 0.0
.shstrtab 288 288 0 0.0
.stab 156 156 0 0.0
.stabstr 335 335 0 0.0
.stack_dummy 4096 4096 0 0.0
.strtab 578434 578873 439 0.1
.symtab 425104 425360 256 0.1
.text 1557080 1558008 928 0.1
.zero.table 8 8 0 0.0
all-clusters-minimal cy8ckit_062s2_43012 0 0 0 0.0
(read only) 841672 841648 -24 -0.0
(read/write) 1699540 1700500 960 0.1
.ARM.attributes 46 46 0 0.0
.ARM.exidx 8 8 0 0.0
.bss 189008 189032 24 0.0
.comment 200 200 0 0.0
.copy.table 24 24 0 0.0
.cy_m0p_image 6216 6216 0 0.0
.cy_sharedmem 8 8 0 0.0
.data 2664 2664 0 0.0
.debug_abbrev 1239987 1240493 506 0.0
.debug_aranges 110680 110776 96 0.1
.debug_frame 376484 376756 272 0.1
.debug_info 27574458 27599754 25296 0.1
.debug_line 3797920 3800820 2900 0.1
.debug_loc 3665740 3668887 3147 0.1
.debug_ranges 360576 361096 520 0.1
.debug_str 3495575 3497706 2131 0.1
.heap 841672 841648 -24 -0.0
.noinit 148 148 0 0.0
.ramVectors 736 736 0 0.0
.shstrtab 288 288 0 0.0
.stab 156 156 0 0.0
.stabstr 335 335 0 0.0
.stack_dummy 4096 4096 0 0.0
.strtab 539642 540081 439 0.1
.symtab 410384 410640 256 0.1
.text 1499480 1500416 936 0.1
.zero.table 8 8 0 0.0
light cy8ckit_062s2_43012 0 0 0 0.0
(read only) 849984 849960 -24 -0.0
(read/write) 1612596 1613564 968 0.1
.ARM.attributes 46 46 0 0.0
.ARM.exidx 8 8 0 0.0
.bss 180896 180920 24 0.0
.comment 200 200 0 0.0
.copy.table 24 24 0 0.0
.cy_m0p_image 6216 6216 0 0.0
.cy_sharedmem 8 8 0 0.0
.data 2464 2464 0 0.0
.debug_abbrev 1074285 1074791 506 0.0
.debug_aranges 102888 102984 96 0.1
.debug_frame 346900 347172 272 0.1
.debug_info 22913745 22938559 24814 0.1
.debug_line 3350067 3352943 2876 0.1
.debug_loc 3343673 3346821 3148 0.1
.debug_ranges 319752 320272 520 0.2
.debug_str 3298532 3300663 2131 0.1
.heap 849984 849960 -24 -0.0
.noinit 148 148 0 0.0
.ramVectors 736 736 0 0.0
.shstrtab 288 288 0 0.0
.stab 156 156 0 0.0
.stabstr 335 335 0 0.0
.stack_dummy 4096 4096 0 0.0
.strtab 474810 475249 439 0.1
.symtab 378128 378384 256 0.1
.text 1420848 1421792 944 0.1
.zero.table 8 8 0 0.0
lock cy8ckit_062s2_43012 0 0 0 0.0
(read only) 845008 844984 -24 -0.0
(read/write) 1646852 1647796 944 0.1
.ARM.attributes 46 46 0 0.0
.ARM.exidx 8 8 0 0.0
.bss 185864 185888 24 0.0
.comment 200 200 0 0.0
.copy.table 24 24 0 0.0
.cy_m0p_image 6216 6216 0 0.0
.cy_sharedmem 8 8 0 0.0
.data 2472 2472 0 0.0
.debug_abbrev 1076025 1076531 506 0.0
.debug_aranges 103328 103424 96 0.1
.debug_frame 348860 349132 272 0.1
.debug_info 23144485 23169300 24815 0.1
.debug_line 3351827 3354698 2871 0.1
.debug_loc 3366614 3369764 3150 0.1
.debug_ranges 321664 322184 520 0.2
.debug_str 3315820 3317951 2131 0.1
.heap 845008 844984 -24 -0.0
.noinit 148 148 0 0.0
.ramVectors 736 736 0 0.0
.shstrtab 288 288 0 0.0
.stab 156 156 0 0.0
.stabstr 335 335 0 0.0
.stack_dummy 4096 4096 0 0.0
.strtab 478223 478662 439 0.1
.symtab 380320 380576 256 0.1
.text 1450128 1451048 920 0.1
.zero.table 8 8 0 0.0
qpg lighting-app qpg6105+debug (read/write) 1149220 1149940 720 0.1
.bss 99908 99932 24 0.0
.data 848 848 0 0.0
.text 596320 597040 720 0.1
lock-app qpg6105+debug (read/write) 1116964 1117676 712 0.1
.bss 96404 96428 24 0.0
.data 860 860 0 0.0
.text 564060 564772 712 0.1
telink all-clusters-app tlsr9518adk80d (read only) 4 4 0 0.0
(read/write) 1013700 1014548 848 0.1
bss 97912 97936 24 0.0
text 684662 685446 784 0.1
all-clusters-minimal-app tlsr9518adk80d (read only) 4 4 0 0.0
(read/write) 950084 950932 848 0.1
bss 96964 96988 24 0.0
text 646938 647722 784 0.1
contact-sensor-app tlsr9518adk80d (read only) 4 4 0 0.0
(read/write) 854944 855800 856 0.1
bss 89084 89108 24 0.0
text 577836 578624 788 0.1
light-switch-app tlsr9518adk80d (read only) 4 4 0 0.0
(read/write) 870700 871548 848 0.1
bss 89168 89192 24 0.0
text 591882 592668 786 0.1
lighting-app tlsr9518adk80d (read only) 4 4 0 0.0
(read/write) 948036 948892 856 0.1
bss 97320 97344 24 0.0
text 657284 658070 786 0.1
ota-requestor-app tlsr9518adk80d (read only) 4 4 0 0.0
(read/write) 882036 882884 848 0.1
bss 90120 90144 24 0.0
text 601626 602414 788 0.1
thermostat tlsr9518adk80d (read only) 4 4 0 0.0
(read/write) 874904 875752 848 0.1
bss 90560 90584 24 0.0
text 593464 594250 786 0.1

@andy31415 andy31415 merged commit 6c1cb33 into project-chip:master Feb 15, 2023
mlepage-google added a commit to mlepage-google/connectedhomeip that referenced this pull request Mar 9, 2023
Since the task priorities were adjusted for project-chip#24099
(and maybe even before?) the factory reset RPC would
time out, breaking any test which relies on the RPC
successfully completing.

This is because the reset is happening immediately,
before whatever is handling the RPC can complete.

Reducing the FreeRTOS task priority just before the
reset "fixes" it. (Maybe there's a better fix?)

Tested on Mighty Gecko SiLabs board.
mlepage-google added a commit that referenced this pull request Mar 10, 2023
Since the task priorities were adjusted for #24099
(and maybe even before?) the factory reset RPC would
time out, breaking any test which relies on the RPC
successfully completing.

This is because the reset is happening immediately,
before whatever is handling the RPC can complete.

Reducing the FreeRTOS task priority just before the
reset "fixes" it. (Maybe there's a better fix?)

Tested on Mighty Gecko SiLabs board.
lecndav pushed a commit to lecndav/connectedhomeip that referenced this pull request Mar 22, 2023
* Add background event handling for CASE establish

CASE session establishment has operations which are costly, such as
checking certificate chains. The handshake messages are processed in the
event thread, so while these operations occur, other events cannot be
processed. This delays responses, and can cause the event queue to fill
entirely, which is fatal.

This commit adds support for background event processing, and uses it to
process the most costly operations during CASESesssion::HandleSigma3.

- add platform support for background event processing:
  ScheduleBackgroundWork, RunBackgroundEventLoop, etc.
- add device config flags for enabling/disabling and configuration
- add implementation for FreeRTOS platform
- refactor some CASESession operations so they can be static, avoiding
  use of member variables
- break HandlSigma3 into 3 parts A/B/C:
  - HandleSigma3a (foreground, processes incoming message)
  - HandleSigma3b (background, performs most costly operations)
  - HandleSigma3c (foreground, sends status report)

This breakup of HandleSigma3 was done in a fairly straightforward manner
so it could be clearer, during review, that behaviour has not
substantially changed. A subsequent commit should clean it up further by
introducing helper code for managing the foreground/background work,
lifetime of work object, when to send status report and/or abort pending
establish, etc.

Also still to do is implementation for other platforms, and for other
messages in CASESession (e.g. Sigma2), and for other costly operations
(e.g. PASESession).

Currently, CASE session establishment is simplified:

- only one pairing session is active at a time
- it's always the same CASESession object in CASEServer
- the two classes are higly coupled (e.g. CASEServer relies upon
  CASESession aborting the pending establish if an error occurs)

Therefore, HandleSigma3b can rely upon the lifetime of the CASESession
object, use an additional state and sequence number to synchronize
work across foreground/background, and avoid use of member variables.
If and when CASE session establishment becomes more complex, assumptions
should be revisited.

TESTING

Testing was performed on M5Stack (ESP32) by commissioning using the
Google Home app on Android.

First, baseline behaviour with background events disabled:

- If no errors, commissioning succeeds as before
- If HandleSigma3a fails and sends a status report,
  pairing retries promptly and succeeds
- If HandleSigma3a fails and cannot send a status report,
  pairing retries after about a minute and succeeds
- If HandleSigma3c succeeds but cannot send a status report,
  pairing retries after about a minute and succeeds

Next, improved behaviour with background events enabled:

- If no errors, commissioning succeeds as before
- If HandleSigma3a fails and sends a status report,
  pairing retries promptly and succeeds
  - (this includes failure to schedule HandleSigma3b)
- If HandleSigma3b fails and sends a status report,
  pairing retries promptly and succeeds
- If HandleSigma3c fails and sends a status report,
  pairing retries promptly and succeeds
- If HandleSigma3c succeeds but cannot send a status report,
  pairing retries after about a minute and succeeds
- If HandleSigma3b is starved (scheduled but does not complete),
  after several minutes the failsafe timer fires, then Home app
  allows try again, which then succeeds
- If HandleSigma3b is delayed (completes late), the sequence number
  is unexpected, so no status report is sent, then
  after several minutes the failsafe timer fires, then Home app
  allows try again, which then succeeds

* Remove WIP code

* Address some comments from code review

* Remove cruft from testing.

* Remove some conditional compilation

* Remove some conditional compilation

* Move function back where it was

Had more related changes, but they're all removed, so remove this
change also.

* Add some documentation

Change error code also.

* Use platform new/delete

* Undo changes that are merely reordering

Cleanup can occur in a subsequent commit.

* Undo changes that are merely reordering

Cleanup can occur in a subsequent commit.

* Remove include file fix (C/C++)

* Add documentation to background processing API

* Use alternate fabrics table API

* Improve documentation

* Add assertion

* Undo some unrelated cleanup

* Update src/protocols/secure_channel/CASESession.cpp

Co-authored-by: Boris Zbarsky <bzbarsky@apple.com>

* Ensure root cert buf keeps span

* Restyled by whitespace

* Restyled by clang-format

* Add new functions to GenericPlatformManagerImpl

So all platforms build and work, even if they don't use the new feature.

* Attempt to fix build errors on some platforms

Apparently initializing structs with anonymous unions is challenging.

* Improving host test environment

This commit has a bunch of extra logging etc. to flush out any more
CI issues.

* Remove log statements and clean up

* Update fake PlatformManagerImpl

* Increase timeout on fake linux CI

* Redo changes to make tests work

Undo previous changes to test/app contexts, and go back to just fixing
the tests more surgically and contained.

Passes Linux host tests and Linux fake platform tests now.

* Undo SetSystemLayerForTesting

nRF/Zephyr tests don't like this not being cleaned up.
May fix Darwin too?

* Change fake linux tests timeout back to 15 mins

* Restyle

* Init/shutdown platform mgr in TestCASESession

Seems needed on Darwin.

---------

Co-authored-by: Boris Zbarsky <bzbarsky@apple.com>
Co-authored-by: Restyled.io <commits@restyled.io>
lecndav pushed a commit to lecndav/connectedhomeip that referenced this pull request Mar 22, 2023
Since the task priorities were adjusted for project-chip#24099
(and maybe even before?) the factory reset RPC would
time out, breaking any test which relies on the RPC
successfully completing.

This is because the reset is happening immediately,
before whatever is handling the RPC can complete.

Reducing the FreeRTOS task priority just before the
reset "fixes" it. (Maybe there's a better fix?)

Tested on Mighty Gecko SiLabs board.
mwswartwout pushed a commit to mwswartwout/connectedhomeip that referenced this pull request Mar 27, 2023
Since the task priorities were adjusted for project-chip#24099
(and maybe even before?) the factory reset RPC would
time out, breaking any test which relies on the RPC
successfully completing.

This is because the reset is happening immediately,
before whatever is handling the RPC can complete.

Reducing the FreeRTOS task priority just before the
reset "fixes" it. (Maybe there's a better fix?)

Tested on Mighty Gecko SiLabs board.
@mlepage-google mlepage-google deleted the async-sigma3 branch April 28, 2023 18:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants