Skip to content

[doc]: Add gnmi feedback design for SmartSwitch #1759

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
158 changes: 158 additions & 0 deletions doc/smart-switch/gnmi-feedback/smart-switch-gnmi-feedback-design.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
# Smart Switch GNMI feedback design <!-- omit in toc -->

## Table of content <!-- omit in toc -->

- [Revision](#revision)
- [Overview](#overview)
- [Requirement](#requirement)
- [Sequence flow](#sequence-flow)
- [Set/Remove](#setremove)
- [Message](#message)
- [Get](#get)
- [Subscribe](#subscribe)
- [Table](#table)
- [APPL STATE DB](#appl-state-db)
- [Example 1 DASH\_ROUTE\_TABLE](#example-1-dash_route_table)
- [Example 2 DASH\_ROUTING\_APPLIANCE\_TABLE](#example-2-dash_routing_appliance_table)

## Revision

| Rev | Date | Author | Change Description |
| :---: | :---: | :----: | ------------------ |
| 0.1 | | Ze Gan | Initial version. |

## Overview

The controller communicates with SmartSwitch via the GNMI interface. To enhance configuration efficiency, we provide batch GNMI operations to the GNMI client, allowing it to submit multiple operations in a single request. This document covers two communication channels: the external channel between the GNMI client and server, and the internal channel between the GNMI server and DPU SAI.

## Requirement

- Support for multiple operations in a single request
- Non-child objects must always include the version ID field
- The GNMI server supports set, remove, get, and subscribe operations
- The GNMI client can proactively subscribe to or get objects/tables via object key or table name

| Child object |
| ----------------- |
| DASH_ACL_RULE |
| DASH_ROUTE |
| DASH_ROUTE_RULE |
| DASH_VNET_MAPPING |


## Sequence flow

### Set/Remove

```mermaid
sequenceDiagram
participant GC as GNMI Client
box NPU SONiC
participant GS as GNMI Server
participant AD as APP DB
participant ASD as APP STATE DB
end
Note over AD, ASD: DPUx Redis
box DPU SONiC
participant ZMQ as ZMQ
participant SW as SWSS
participant SY as SYNCD
end

GC ->> GS: Update commands
loop Each commands:
GS --) AD: Insert object
GS ->> ZMQ: Update command
end
GS -->> GC:
ZMQ ->> SW: Consume commands
SW ->> SY: SAI call
SY -->> SW:
alt Set command
SW ->> ASD: Update command result
Note over ZMQ: Include result code and version ID (If it's non-child object)
else Del command
SW ->> ASD: Remove objects
end

```

### Message

### Get

```mermaid
sequenceDiagram
participant GC as GNMI Client
box NPU SONiC
participant GS as GNMI Server
participant ASD as APP STATE DB
end
Note over ASD: DPUx Redis

GC ->> GS: Query object or table result
GS ->> ASD: Get object via key or get objects via table name
ASD -->> GS: Query results
GS -->> GC: Query result

```

### Subscribe

```mermaid
sequenceDiagram
participant GC as GNMI Client
box NPU SONiC
participant GS as GNMI Server
participant ASD as APP STATE DB
end
Note over ASD: DPUx Redis
participant DPU as DPU

GC ->> GS: Subscribe object or table
GS ->> GS: Register subscribe events
GS ->> ASD: Get object via key or get objects via table name
Note over ASD: Cache result before subscribe
ASD -->> GS: Query results
GS -->> GC: Query results
loop Each commands
alt Set command
DPU ->> ASD: Update command result
else Del command
DPU ->> ASD: Remove objects
end
end
ASD -->> GS: Proactively push results
GS -->> GC: Proactively push results

```

## Table

### APPL STATE DB

DASH state table in APPL STATE DB, table name is the same as DASH table, key is the same, and fields are result and version ID if it's not a child object.
Copy link
Contributor

@ganglyu ganglyu Jul 30, 2024

Choose a reason for hiding this comment

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

Can we add an example for DASH_ROUTE_GROUP_TABLE?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here is just an example, more tables will be on the dash hld document.


#### Example 1 DASH_ROUTE_TABLE

```text
DASH_ROUTE_TABLE:{{group_id}}:{{prefix}}
"result": {{result}}

key = DASH_ROUTE_TABLE:group_id:prefix
; field = value
result = uint32 0 for success, > 0 for error code
```

#### Example 2 DASH_ROUTING_APPLIANCE_TABLE

```
DASH_ROUTE_GROUP_TABLE:{{group_id}}
"result": {{result}}
"version_id": {{string}}

key = DASH_ROUTE_GROUP_TABLE:group_id
; field = value
result = uint32 0 for success, > 0 for error code
version_id = string, Indicate the unique version of metadata of route group. E.G. "1", "1.1".
```