Skip to content

Commit b0f617c

Browse files
Add custom SerDes attributes support in media_settings.json
1 parent 0830914 commit b0f617c

1 file changed

Lines changed: 107 additions & 0 deletions

File tree

doc/media-settings/Media-based-Port-settings.md

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,113 @@
140140

141141
![](key_selection_flow.png)
142142

143+
## Custom SerDes attributes
144+
145+
Custom SerDes attributes are vendor-specific SerDes settings that are not covered by standard `SAI_PORT_SERDES_*` attributes, especially those not suitable for public standardization in SAI (for example, proprietary ones). `SAI_PORT_SERDES_ATTR_CUSTOM_COLLECTION` was introduced to carry these settings as a single JSON string based attribute.
146+
147+
In media_settings.json, define custom attributes using keys prefixed with `CUSTOM:` (for example, `CUSTOM:XYZ`). xcvrd's media_settings_parser strips the prefix, and aggregates them into a single JSON string field `custom_serdes_attrs` in APPL_DB `PORT_TABLE`. The JSON format is a list of attribute objects, each with a per-lane `value` array sized for the logical port, and portsorch maps that field to `SAI_PORT_SERDES_ATTR_CUSTOM_COLLECTION`. portsorch doesn't interpret the contents; it simply passes it through to SAI.
148+
149+
### Value of `SAI_PORT_SERDES_ATTR_CUSTOM_COLLECTION` is a JSON string in the following format
150+
151+
```
152+
{
153+
"attributes": [
154+
{
155+
"XYZ": {
156+
"value": [10, 11, 12, 13]
157+
}
158+
},
159+
{
160+
"ABC": {
161+
"value": ["mode_a", "mode_b", "mode_c", "mode_d"]
162+
}
163+
}
164+
]
165+
}
166+
```
167+
168+
Note: The above JSON is formatted with spaces and newlines for readability to help understand the structure. The actual value written to APPL_DB by xcvrd is compressed (spaces and newlines removed) to achieve minimal payload size.
169+
170+
### Example media_settings.json with only custom attributes
171+
172+
```
173+
{
174+
"GLOBAL_MEDIA_SETTINGS": {
175+
"1-32": {
176+
"Default": {
177+
"CUSTOM:XYZ": {
178+
"lane0": 10,
179+
"lane1": 11,
180+
"lane2": 12,
181+
"lane3": 13
182+
},
183+
"CUSTOM:ABC": {
184+
"lane0": "mode_a",
185+
"lane1": "mode_b",
186+
"lane2": "mode_c",
187+
"lane3": "mode_d"
188+
}
189+
}
190+
}
191+
}
192+
}
193+
```
194+
195+
Example APPL_DB PORT_TABLE entry based on the above media_settings.json:
196+
197+
```
198+
# sonic-db-cli APPL_DB hgetall "PORT_TABLE:EthernetXXX"
199+
{
200+
...
201+
'custom_serdes_attrs': '{"attributes":[{"XYZ":{"value":[10,11,12,13]}},{"ABC":{"value":["mode_a","mode_b","mode_c","mode_d"]}}]}'
202+
...
203+
}
204+
```
205+
206+
### Example media_settings.json with mixed traditional and custom attributes
207+
208+
```
209+
{
210+
"GLOBAL_MEDIA_SETTINGS": {
211+
"1-32": {
212+
"Default": {
213+
"preemphasis": {
214+
"lane0": "0x112233",
215+
"lane1": "0x112233",
216+
"lane2": "0x112244",
217+
"lane3": "0x443322"
218+
},
219+
"idriver": {
220+
"lane0": "0xb",
221+
"lane1": "0xc",
222+
"lane2": "0xd",
223+
"lane3": "0xa"
224+
},
225+
"CUSTOM:XYZ": {
226+
"lane0": 10,
227+
"lane1": 11,
228+
"lane2": 12,
229+
"lane3": 13
230+
}
231+
}
232+
}
233+
}
234+
}
235+
```
236+
237+
Example APPL_DB PORT_TABLE entry based on the above media_settings.json:
238+
239+
```
240+
# sonic-db-cli APPL_DB hgetall "PORT_TABLE:EthernetXXX"
241+
{
242+
...
243+
'preemphasis': '0x112233,0x112233,0x112244,0x443322',
244+
'idriver': '0xb,0xc,0xd,0xa',
245+
'custom_serdes_attrs': '{"attributes":[{"XYZ":{"value":[10,11,12,13]}}]}'
246+
...
247+
}
248+
```
249+
143250
## Breakout Scenario:
144251

145252
              For breakout scenario, there is no special handling or modification that needs to be done to media_settings.json. Currently breakout in SONiC is done by modifying port_config.ini and platform related files and doing a config reload. This config reload will stop and restart most of the daemons. Thus this sequence will be similar to the normal reboot sequence. When xcvrd is stopped and restarted it notifies portsorch about all media just as in normal reboot scenario.

0 commit comments

Comments
 (0)