Skip to content

Commit

Permalink
Merge pull request #1625 from ganglyu/gnmi_path_update
Browse files Browse the repository at this point in the history
Signed-off-by: Gang Lv [email protected]

# What is the motivation for this PR?
GNMI native needs to support multi-asic device and smartswitch, so we need to update GNMI path schema.
  • Loading branch information
ganglyu authored Oct 29, 2024
2 parents ee01ad3 + c55cdd0 commit 1a5399b
Show file tree
Hide file tree
Showing 2 changed files with 833 additions and 747 deletions.
79 changes: 38 additions & 41 deletions doc/mgmt/gnmi/SONiC_GNMI_Server_Interface_Design.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,13 @@ The ultimate goal is to use SONiC Yang models for configuration, and we also nee

* We will follow OpenConfig specification to use origin field to support mixed schema.

* And we use the first element to specify the target database.
* We use the first element to specify the target database.

* We use the second element to specify the database instance:
* For single asic device, this element is "localhost"
* For multiple asic device, this element can be "localhost", "asic0", "asic1", ...
* For smartswitch device, this element can be "localhost", "dpu0", "dpu1", ...
* For smartswitch with multiple asic NPU, this element can be "localhost", "asic0", "asic1", ..., "dpu0", "dpu1", ...

A single request cannot have both SONiC YANG paths and ConfigDB/ApplDB schema paths.

Expand Down Expand Up @@ -214,15 +220,15 @@ With CONFIG_DB schema:

++++++++ Sending get request: ++++++++
path {
elem {name: "CONFIG_DB"} elem {name: "DEVICE_NEIGHBOR"}
elem {name: "CONFIG_DB"} elem {name: "localhost"} elem {name: "DEVICE_NEIGHBOR"}
}
encoding: JSON_IETF
++++++++ Recevied get response: ++++++++
notification {
update {
path {
origin: "sonic_db"
elem {name: "CONFIG_DB"} elem {name: "DEVICE_NEIGHBOR"} elem {name: "Ethernet8"}
elem {name: "CONFIG_DB"} elem {name: "localhost"} elem {name: "DEVICE_NEIGHBOR"} elem {name: "Ethernet8"}
}
val {
json_ietf_val: "{\"name\": \"Servers1\",\"port\": \"eth0\"}"
Expand All @@ -231,7 +237,7 @@ With CONFIG_DB schema:
update {
path {
origin: "sonic_db"
elem {name: "CONFIG_DB"} elem {name: "DEVICE_NEIGHBOR"} elem {name: "Ethernet96"}
elem {name: "CONFIG_DB"} elem {name: "localhost"} elem {name: "DEVICE_NEIGHBOR"} elem {name: "Ethernet96"}
}
val {
json_ietf_val: "{\"name\": \"Servers23\",\"port\": \"eth0\"}"
Expand All @@ -244,15 +250,15 @@ With CONFIG_YANG schema:
++++++++ Sending get request: ++++++++
path {
origin: "sonic_yang"
elem {name: "CONFIG_DB"} elem {name: "sonic-device_neighbor:sonic-device_neighbor"}
elem {name: "CONFIG_DB"} elem {name: "localhost"} elem {name: "sonic-device_neighbor:sonic-device_neighbor"}
}
encoding: JSON_IETF
++++++++ Recevied get response: ++++++++
notification {
update {
path {
origin: "sonic_yang"
elem {name: "CONFIG_DB"} elem {name: "sonic-device_neighbor:sonic-device_neighbor"} elem {name: "sonic-device_neighbor:DEVICE_NEIGHBOR"} elem {name: "DEVICE_NEIGHBOR_LIST" key {key: "name" value: "Ethernet8"}}
elem {name: "CONFIG_DB"} elem {name: "localhost"} elem {name: "sonic-device_neighbor:sonic-device_neighbor"} elem {name: "sonic-device_neighbor:DEVICE_NEIGHBOR"} elem {name: "DEVICE_NEIGHBOR_LIST" key {key: "name" value: "Ethernet8"}}
}
val {
json_ietf_val: "{\"name\": \"Servers1\",\"port\": \"eth0\"}"
Expand All @@ -261,7 +267,7 @@ With CONFIG_YANG schema:
update {
path {
origin: "sonic_yang"
elem {name: "CONFIG_DB"} elem {name: "sonic-device_neighbor:sonic-device_neighbor"} elem {name: "sonic-device_neighbor:DEVICE_NEIGHBOR"} elem {name: "DEVICE_NEIGHBOR_LIST" key {key: "name" value: "Ethernet96"}}
elem {name: "CONFIG_DB"} elem {name: "localhost"} elem {name: "sonic-device_neighbor:sonic-device_neighbor"} elem {name: "sonic-device_neighbor:DEVICE_NEIGHBOR"} elem {name: "DEVICE_NEIGHBOR_LIST" key {key: "name" value: "Ethernet96"}}
}
val {
json_ietf_val: "{\"name\": \"Servers23\",\"port\": \"eth0\"}"
Expand All @@ -277,13 +283,13 @@ With CONFIG_DB schema:
replace {
path {
origin: "sonic_db"
elem {name: "CONFIG_DB"} elem {name: "DEVICE_NEIGHBOR"} elem {name: "Ethernet96"}
elem {name: "CONFIG_DB"} elem {name: "localhost"} elem {name: "DEVICE_NEIGHBOR"} elem {name: "Ethernet96"}
}
}
replace {
path {
origin: "sonic_db"
elem {name: "CONFIG_DB"} elem {name: "DEVICE_NEIGHBOR"} elem {name: "Ethernet8"} elem {name: "port"}
elem {name: "CONFIG_DB"} elem {name: "localhost"} elem {name: "DEVICE_NEIGHBOR"} elem {name: "Ethernet8"} elem {name: "port"}
}
val {
json_ietf_val: "eth1"
Expand All @@ -293,14 +299,14 @@ With CONFIG_DB schema:
response {
path {
origin: "sonic_db"
elem {name: "CONFIG_DB"} elem {name: "DEVICE_NEIGHBOR"} elem {name: "Ethernet96"}
elem {name: "CONFIG_DB"} elem {name: "localhost"} elem {name: "DEVICE_NEIGHBOR"} elem {name: "Ethernet96"}
}
op: REPLACE
}
response {
path {
origin: "sonic_db"
elem {name: "CONFIG_DB"} elem {name: "DEVICE_NEIGHBOR"} elem {name: "Ethernet8"} elem {name: "port"}
elem {name: "CONFIG_DB"} elem {name: "localhost"} elem {name: "DEVICE_NEIGHBOR"} elem {name: "Ethernet8"} elem {name: "port"}
}
op: REPLACE
}
Expand All @@ -311,13 +317,13 @@ With CONFIG_YANG schema:
replace {
path {
origin: "sonic_yang"
elem {name: "CONFIG_DB"} elem {name: "sonic-device_neighbor:sonic-device_neighbor"} elem {name: "sonic-device_neighbor:DEVICE_NEIGHBOR"} elem {name: "DEVICE_NEIGHBOR_LIST" key {key: "name" value: "Ethernet96"}}
elem {name: "CONFIG_DB"} elem {name: "localhost"} elem {name: "sonic-device_neighbor:sonic-device_neighbor"} elem {name: "sonic-device_neighbor:DEVICE_NEIGHBOR"} elem {name: "DEVICE_NEIGHBOR_LIST" key {key: "name" value: "Ethernet96"}}
}
}
replace {
path {
origin: "sonic_yang"
elem {name: "CONFIG_DB"} elem {name: "sonic-device_neighbor:sonic-device_neighbor"} elem {name: "sonic-device_neighbor:DEVICE_NEIGHBOR"} elem {name: "DEVICE_NEIGHBOR_LIST" key {key: "name" value: "Ethernet8"}} elem {name: "port"}
elem {name: "CONFIG_DB"} elem {name: "localhost"} elem {name: "sonic-device_neighbor:sonic-device_neighbor"} elem {name: "sonic-device_neighbor:DEVICE_NEIGHBOR"} elem {name: "DEVICE_NEIGHBOR_LIST" key {key: "name" value: "Ethernet8"}} elem {name: "port"}
}
val {
json_ietf_val: "eth1"
Expand All @@ -327,14 +333,14 @@ With CONFIG_YANG schema:
response {
path {
origin: "sonic_yang"
elem {name: "CONFIG_DB"} elem {name: "sonic-device_neighbor:sonic-device_neighbor"} elem {name: "sonic-device_neighbor:DEVICE_NEIGHBOR"} elem {name: "DEVICE_NEIGHBOR_LIST" key {key: "name" value: "Ethernet96"}}
elem {name: "CONFIG_DB"} elem {name: "localhost"} elem {name: "sonic-device_neighbor:sonic-device_neighbor"} elem {name: "sonic-device_neighbor:DEVICE_NEIGHBOR"} elem {name: "DEVICE_NEIGHBOR_LIST" key {key: "name" value: "Ethernet96"}}
}
op: REPLACE
}
response {
path {
origin: "sonic_yang"
elem {name: "CONFIG_DB"} elem {name: "sonic-device_neighbor:sonic-device_neighbor"} elem {name: "sonic-device_neighbor:DEVICE_NEIGHBOR"} elem {name: "DEVICE_NEIGHBOR_LIST" key {key: "name" value: "Ethernet8"}} elem {name: "port"}
elem {name: "CONFIG_DB"} elem {name: "localhost"} elem {name: "sonic-device_neighbor:sonic-device_neighbor"} elem {name: "sonic-device_neighbor:DEVICE_NEIGHBOR"} elem {name: "DEVICE_NEIGHBOR_LIST" key {key: "name" value: "Ethernet8"}} elem {name: "port"}
}
op: REPLACE
}
Expand Down Expand Up @@ -364,7 +370,7 @@ Below table provides an example to translate from SetRequest to JsonPatch.
### Table 3: Translate Example
| SetRequest Format | JsonPatch Format |
| ---- | ---- |
| replace {<br>&ensp;path {<br>&ensp;&ensp;elem {name: "CONFIG_DB"} elem {name: "DEVICE_NEIGHBOR"} elem {name: "Ethernet96"}<br>&ensp;}<br>}<br>replace {<br>&ensp;path {<br>&ensp;&ensp;elem {name: "CONFIG_DB"} elem {name: "DEVICE_NEIGHBOR"} elem {name: "Ethernet8"} elem {name: "port"}<br>&ensp;}<br>&ensp;val { json_ietf_val: "eth1" }<br>} | [<br>&ensp;{<br>&ensp;&ensp;"op": "remove", "path": "/DEVICE_NEIGHBOR/Ethernet96"}, <br>&ensp;&ensp;{ "op": "add", "path": "/DEVICE_NEIGHBOR/Ethernet8/port", "value": "eth1"}<br>] |
| replace {<br>&ensp;path {<br>&ensp;&ensp;elem {name: "CONFIG_DB"} elem {name: "localhost"} elem {name: "DEVICE_NEIGHBOR"} elem {name: "Ethernet96"}<br>&ensp;}<br>}<br>replace {<br>&ensp;path {<br>&ensp;&ensp;elem {name: "CONFIG_DB"} elem {name: "localhost"} elem {name: "DEVICE_NEIGHBOR"} elem {name: "Ethernet8"} elem {name: "port"}<br>&ensp;}<br>&ensp;val { json_ietf_val: "eth1" }<br>} | [<br>&ensp;{<br>&ensp;&ensp;"op": "remove", "path": "/DEVICE_NEIGHBOR/Ethernet96"}, <br>&ensp;&ensp;{ "op": "add", "path": "/DEVICE_NEIGHBOR/Ethernet8/port", "value": "eth1"}<br>] |

#### 1.2.1.5 Full Configurations

Expand All @@ -374,21 +380,33 @@ SetRequest message will be:

++++++++ Sending set request: ++++++++
delete {
path { origin: "sonic_db" }
path {
origin: "sonic_db"
elem {name: "CONFIG_DB"} elem {name: "localhost"}
}
}
update {
path { origin: "sonic_db" }
path {
origin: "sonic_db"
elem {name: "CONFIG_DB"} elem {name: "localhost"}
}
val {
json_ietf_val: "{\"DEVICE_NEIGHBOR/Ethernet8/name\":\"Servers1\", \"DEVICE_NEIGHBOR/Ethernet8/port\":\"eth0\", \"DEVICE_NEIGHBOR/Ethernet96/name\":\"Servers23\", \"DEVICE_NEIGHBOR/Ethernet96/port\":\"eth0\", ...}"
}
}
++++++++ Recevied set response: ++++++++
response {
path { origin: "sonic_db" }
path {
origin: "sonic_db"
elem {name: "CONFIG_DB"} elem {name: "localhost"}
}
op: DELETE
}
response {
path { origin: "sonic_db" }
path {
origin: "sonic_db"
elem {name: "CONFIG_DB"} elem {name: "localhost"}
}
op: UPDATE
}

Expand Down Expand Up @@ -454,27 +472,6 @@ The full configuration request will be overwritten by subsequent full configurat

<img src="images/mixed requests.svg" alt="overwritten-config" width="800px"/>

#### 1.2.1.12 Backward Compatibility

SONiC telemetry is using prefix target to identify target database, and we will add a new target to support mixed schema.

enum Target {
option allow_alias = true;
APPL_DB = 0;
ASIC_DB = 1;
COUNTERS_DB = 2;
LOGLEVEL_DB = 3;
CONFIG_DB = 4;
// PFC_WD_DB shares the the same db number with FLEX_COUNTER_DB
PFC_WD_DB = 5;
FLEX_COUNTER_DB = 5;
STATE_DB = 6;
// For none-DB data
OTHERS = 100;
// For mixed schema
MIXED_SCHEMA = 101;
}


### 1.2.2 Container

Expand Down
Loading

0 comments on commit 1a5399b

Please sign in to comment.