Skip to content

[vpp] Dedicated binary-API socket and thread for asynchronous VPP events#1951

Open
nicholasching wants to merge 7 commits into
sonic-net:masterfrom
nicholasching:vpp_event_socket
Open

[vpp] Dedicated binary-API socket and thread for asynchronous VPP events#1951
nicholasching wants to merge 7 commits into
sonic-net:masterfrom
nicholasching:vpp_event_socket

Conversation

@nicholasching

Copy link
Copy Markdown

Description of PR

Summary:
Part of the SAIVPP unit-test framework (docker-sai-test-vpp, #1950, see its devdocs/). Carries the asynchronous VPP event stream on a dedicated binary-API socket and background thread, separate from the synchronous request/reply command path. This resolves a mutex deadlock between the command path and the async event path that blocked bring-up of the OCP sai_test suite at PORT_COUNT=32. Reviewers can start in vslib/vpp/vppxlate/SaiVppXlate.c.

Fixes # (N/A — no upstream issue)

Type of change

  • Bug fix
  • New feature
  • Refactor / cleanup
  • Documentation update
  • Test improvement

Approach

What is the motivation for this PR?

The synchronous command path and the asynchronous VPP event stream shared a single binary-API socket and the global __plugin_msg_base. At scale this deadlocked between the command path and the async event path, preventing the standalone SAIVPP UT (SaiSanityTest) from passing.

How did you do it?

In vslib/vpp/vppxlate/SaiVppXlate.c: introduced a dedicated event binary-API socket (event_socket_client_main / vat_event_main) and background thread; added event-connection message macros (M_EV / PING_EV / S_EV / WR_EV) that operate on the explicit per-connection socket via the vl_socket_client_*2() APIs; added a separate lock for the event connection; and made __plugin_msg_base thread-local so the command and event threads cannot race between setting the base and the following M()/PING().

How did you verify/test it?

Built into the docker-sai-test-vpp image and run against the OCP sai_test suite; the command-vs-event deadlock at 32 ports no longer occurs and SaiSanityTest passes. The change is orthogonal to the recently-merged route-flow-counter context-table rework (#1894) and ipinip support (#1860); rebased on current master and verified both coexist.

Any platform specific information?

VPP platform only (vslib/vpp/). No change to the synchronous command path or SAI semantics; the event connection is additive.

Documentation

Development notes for this work are in .azure-pipelines/docker-sai-test-vpp/devdocs/ in #1950.

@linux-foundation-easycla

linux-foundation-easycla Bot commented Jun 23, 2026

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: nicholasching / name: Nicholas Ching (f3ab3f9)

@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@nicholasching

Copy link
Copy Markdown
Author

It appears the checks are failing due to an upstream issue which should be resolved when #4696 is merged into sonic-swss.

@yue-fred-gao yue-fred-gao left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please trigger t1-lag-vpp sanity through PR in sonic-buildimage with this PR branch.

Comment thread vslib/vpp/vppxlate/SaiVppXlate.c Outdated
if (now >= hard_deadline || now >= idle_deadline) \
break; \
if (scm && scm->socket_enable) { \
vl_socket_client_read (1); \

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Miss the code to extend idle_deadline
_wr_rv = vl_socket_client_read (1);
if (_wr_rv == 0) {
idle_deadline = vat_time_now (vam) + 1.0;
if (idle_deadline > hard_deadline)
idle_deadline = hard_deadline;
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, thank you Fred. Fixed in 145026f now.

uword *ptr;

sw_if_index = htonl(mp->sw_if_index);
sw_if_index = ntohl(mp->sw_if_index);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Not sure how it works today or it never worked

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, Fred!

@@ -2972,21 +3160,23 @@ int vpp_get_interface_speed (const char *hwif_name, uint32_t *speed)

int vpp_sync_for_events ()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a comment that event handler running under EVENT_LOCK should never acquire VPP_LOCK to avoid cross lock.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! Added in 15a5298

@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@yue-fred-gao

Copy link
Copy Markdown
Contributor

The change looks good. If t1-lag-vpp sanity passes, I will approve the PR

@nicholasching

Copy link
Copy Markdown
Author

Thanks @yue-fred-gao. Test running now; should be ready by tomorrow morning!

@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@nicholasching

Copy link
Copy Markdown
Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@nicholasching

Copy link
Copy Markdown
Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@nicholasching

Copy link
Copy Markdown
Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@nicholasching

Copy link
Copy Markdown
Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@nicholasching

Copy link
Copy Markdown
Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@nicholasching

Copy link
Copy Markdown
Author

The t1-lag-vpp sanity test has passed on the associated sonic-buildimage PR: sonic-net/sonic-buildimage#28145

I have attached the results below:
Github Run: https://github.com/sonic-net/sonic-buildimage/runs/86538349140
Azure Build: https://dev.azure.com/mssonic/build/_build/results?buildId=1162024&view=logs&jobId=314bc92a-d36a-5eac-5c45-43e8f1288876

@nicholasching

Copy link
Copy Markdown
Author

/azpw run

@mssonicbld

Copy link
Copy Markdown
Collaborator

⚠️ Notice: /azpw run only runs failed jobs now. If you want to trigger a whole pipline run, please rebase your branch or close and reopen the PR.
💡 Tip: You can also use /azpw retry to retry failed jobs directly.

Retrying failed(or canceled) jobs...

@mssonicbld

Copy link
Copy Markdown
Collaborator

Retrying failed(or canceled) stages in build 1163729:

✅Stage TestAsan:

  • Job vstest: retried.

✅Stage Test:

  • Job vstest: retried.
  • Job vstest: retried.

@nicholasching

Copy link
Copy Markdown
Author

/azpw run

@mssonicbld

Copy link
Copy Markdown
Collaborator

⚠️ Notice: /azpw run only runs failed jobs now. If you want to trigger a whole pipline run, please rebase your branch or close and reopen the PR.
💡 Tip: You can also use /azpw retry to retry failed jobs directly.

Retrying failed(or canceled) jobs...

@mssonicbld

Copy link
Copy Markdown
Collaborator

Retrying failed(or canceled) stages in build 1163729:

✅Stage TestAsan:

  • Job vstest: retried.

✅Stage Test:

  • Job vstest: retried.
  • Job vstest: retried.

@nicholasching

Copy link
Copy Markdown
Author

/azpw run

@mssonicbld

Copy link
Copy Markdown
Collaborator

⚠️ Notice: /azpw run only runs failed jobs now. If you want to trigger a whole pipline run, please rebase your branch or close and reopen the PR.
💡 Tip: You can also use /azpw retry to retry failed jobs directly.

Retrying failed(or canceled) jobs...

@mssonicbld

Copy link
Copy Markdown
Collaborator

Retrying failed(or canceled) stages in build 1163729:

✅Stage TestAsan:

  • Job vstest: retried.

✅Stage Test:

  • Job vstest: retried.
  • Job vstest: retried.

dypet
dypet previously approved these changes Jul 14, 2026
@nicholasching

Copy link
Copy Markdown
Author

Hello @saiarcot895 @lolyu! The changes in this PR have previously been reviewed by @yue-fred-gao, received final approval from @dypet, and are now passing checks. Our team at Cisco currently does not have anyone with merge permissions. When you have a chance, could you please take a quick look and help us merge into master for SAIVPP UT feature?
https://github.com/yue-fred-gao/sonic-platform-vpp/blob/sai_vpp_unittest_hld/docs/HLD/saivpp-unittest-hld.md
Thanks!

Signed-off-by: Nicholas Ching <nicholaslching@gmail.com>
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@nicholasching

Copy link
Copy Markdown
Author

The t1-lag-vpp sanity test, applied to both #1951 and #1952 has passed on the associated sonic-buildimage PR: sonic-net/sonic-buildimage#28145

I have attached the results below:
Github Run: https://github.com/sonic-net/sonic-buildimage/runs/86968365539
Azure Build: https://dev.azure.com/mssonic/build/_build/results?buildId=1163779&view=results

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants