Skip to content

Commit 2d5e244

Browse files
Per Lane PRBS statuses and statistics
Signed-off-by: Spandan Dasgupta <[email protected]>
1 parent f56f534 commit 2d5e244

File tree

5 files changed

+474
-0
lines changed

5 files changed

+474
-0
lines changed
Lines changed: 307 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,307 @@
1+
# [SAI] PRBS Per Lane Enhancements
2+
3+
-------------------------------------------------------------------------------
4+
5+
Title | PRBS Per Lane Enhancements
6+
-------------|-----------------------------------------------------------------
7+
Authors | Spandan Dasgupta, Chris Nitin Adonis Petrus, Rajkumar P R, Ravindranath C K (Marvell)
8+
Status | In review
9+
Type | Standards track
10+
Created | 2025-09-10
11+
SAI-Version | 1.17
12+
13+
-------------------------------------------------------------------------------
14+
15+
## 1.0 Introduction
16+
17+
PRBS (Pseudo-Random Bit Sequence) is used to test the integrity of high-speed serial links by generating and checking random data patterns. It helps validate serdes performance and physical connectivity.
18+
19+
SAI currently provides the following port attributes to fetch PRBS related status.
20+
21+
```c
22+
/**
23+
* @brief Attribute data for #SAI_PORT_ATTR_PRBS_LOCK_STATUS
24+
*
25+
* PRBS lock status: 1 for locked, 0 for unlocked
26+
*
27+
* @type bool
28+
* @flags READ_ONLY
29+
*/
30+
SAI_PORT_ATTR_PRBS_LOCK_STATUS,
31+
32+
/**
33+
* @brief Attribute data for #SAI_PORT_ATTR_PRBS_RX_STATUS
34+
*
35+
* @type sai_port_prbs_rx_status_t
36+
* @flags READ_ONLY
37+
*/
38+
SAI_PORT_ATTR_PRBS_RX_STATUS,
39+
40+
/**
41+
* @brief Attribute data for #SAI_PORT_ATTR_PRBS_RX_STATE
42+
* Used for clear on read status/count register.
43+
* Adapter should return SAI_STATUS_NOT_SUPPORTED if not supported.
44+
*
45+
* @type sai_prbs_rx_state_t
46+
* @flags READ_ONLY
47+
*/
48+
SAI_PORT_ATTR_PRBS_RX_STATE,
49+
```
50+
51+
In addition, SAI also provides **SAI_PORT_STAT_PRBS_ERROR_COUNT** as a port stat to fetch error count for PRBS.
52+
53+
```c
54+
/** PRBS Error Count */
55+
SAI_PORT_STAT_PRBS_ERROR_COUNT,
56+
```
57+
58+
## 2.0 Problem Statement
59+
60+
Link quality and error characteristics can vary significantly between lanes due to manufacturing variations, signal integrity issues, or physical connectivity problems. Existing SAI PRBS (Pseudo-Random Bit Sequence) support provides only port-level statistics, which can mask lane-specific issues and hinder effective diagnostics.
61+
62+
To address this limitation, there is a need for per-lane PRBS status and error reporting. By exposing PRBS lock status, receive state, and error counters for each individual lane, operators and diagnostic tools can more accurately pinpoint the source of link degradation and perform targeted corrective actions.
63+
64+
However, simply reporting raw error counts per lane is insufficient for comprehensive link assessment. Error counts are affected by test duration and link speed, making it difficult to compare results across links or over time. To provide a normalized, meaningful metric, Bit Error Rate (BER) is commonly used.
65+
66+
In practice, BER values are extremely small and are typically represented as floating-point numbers. However, SAI does not support floating-point data types. To enable accurate and portable BER representation, a new datatype is introduced.
67+
68+
69+
## 3.0 Proposed SAI Enhancement
70+
71+
1) New structure for a list of PRBS Rx states:
72+
73+
```c
74+
/**
75+
* @brief Defines PRBS Rx states for list of all serdes lanes
76+
*/
77+
typedef struct _sai_prbs_rx_state_list_t
78+
{
79+
uint32_t count;
80+
sai_prbs_rx_state_t *list;
81+
} sai_prbs_rx_state_list_t;
82+
```
83+
84+
Also, include the new list to **sai_attribute_value_t** union.
85+
86+
```c
87+
...Existing union members
88+
/** @validonly meta->attrvaluetype == SAI_ATTR_VALUE_TYPE_PRBS_RX_STATE_LIST */
89+
sai_prbs_rx_state_list_t prbs_rx_state_list;
90+
} sai_attribute_value_t;
91+
92+
```
93+
94+
2) New port attributes for per lane alternative of existing attributes **SAI_PORT_ATTR_PRBS_LOCK_STATUS**, **SAI_PORT_ATTR_PRBS_RX_STATUS** and **SAI_PORT_ATTR_PRBS_RX_STATE**:
95+
96+
```c
97+
/**
98+
* @brief Per Lane PRBS Lock Status
99+
*
100+
* Per lane list of lock status for PRBS.
101+
* The values are of type sai_u8_list_t where the count is the number of lanes in
102+
* a port and the list specifies list of values for each lane.
103+
* PRBS lock status: 1 for locked, 0 for unlocked
104+
*
105+
* @type sai_u8_list_t
106+
* @flags READ_ONLY
107+
*/
108+
SAI_PORT_ATTR_PRBS_PER_LANE_LOCK_STATUS_LIST,
109+
110+
/**
111+
* @brief Per Lane PRBS Rx Status
112+
*
113+
* Per lane list of Rx status for PRBS.
114+
* The values are of type sai_s32_list_t where the count is the number of lanes in
115+
* a port and the list specifies list of values of type sai_port_prbs_rx_status_t
116+
* for each lane.
117+
*
118+
* @type sai_s32_list_t sai_port_prbs_rx_status_t
119+
* @flags READ_ONLY
120+
*/
121+
SAI_PORT_ATTR_PRBS_RX_STATUS_LIST,
122+
123+
/**
124+
* @brief Per Lane PRBS Rx State
125+
*
126+
* Per lane list of Rx state for PRBS.
127+
* The values are of type sai_prbs_rx_state_list_t where the count is the number
128+
* of lanes in a port and the list specifies list of values of type sai_prbs_rx_state_t
129+
* for each lane.
130+
* Used for clear on read status/count register.
131+
* Adapter should return SAI_STATUS_NOT_SUPPORTED if not supported.
132+
*
133+
* @type sai_prbs_rx_state_list_t
134+
* @flags READ_ONLY
135+
*/
136+
SAI_PORT_ATTR_PRBS_PER_LANE_RX_STATE_LIST,
137+
```
138+
139+
3) New port stats for PRBS error count per lane for relative lanes 0 to 15:
140+
141+
```c
142+
143+
/** Per Lane PRBS Error Count Range Start*/
144+
SAI_PORT_STAT_PRBS_ERROR_COUNT_LANE_RANGE_BASE = 0x00004000,
145+
146+
/** Per Lane PRBS Error Count For lane in index 0*/
147+
SAI_PORT_STAT_PRBS_ERROR_COUNT_LANE_0 = SAI_PORT_STAT_PRBS_ERROR_COUNT_LANE_RANGE_BASE,
148+
149+
/** Per Lane PRBS Error Count For lane in index 1*/
150+
SAI_PORT_STAT_PRBS_ERROR_COUNT_LANE_1,
151+
152+
/** Per Lane PRBS Error Count For lane in index 2*/
153+
SAI_PORT_STAT_PRBS_ERROR_COUNT_LANE_2,
154+
155+
/** Per Lane PRBS Error Count For lane in index 3*/
156+
SAI_PORT_STAT_PRBS_ERROR_COUNT_LANE_3,
157+
158+
/** Per Lane PRBS Error Count For lane in index 4*/
159+
SAI_PORT_STAT_PRBS_ERROR_COUNT_LANE_4,
160+
161+
/** Per Lane PRBS Error Count For lane in index 5*/
162+
SAI_PORT_STAT_PRBS_ERROR_COUNT_LANE_5,
163+
164+
/** Per Lane PRBS Error Count For lane in index 6*/
165+
SAI_PORT_STAT_PRBS_ERROR_COUNT_LANE_6,
166+
167+
/** Per Lane PRBS Error Count For lane in index 7*/
168+
SAI_PORT_STAT_PRBS_ERROR_COUNT_LANE_7,
169+
170+
/** Per Lane PRBS Error Count For lane in index 8*/
171+
SAI_PORT_STAT_PRBS_ERROR_COUNT_LANE_8,
172+
173+
/** Per Lane PRBS Error Count For lane in index 9*/
174+
SAI_PORT_STAT_PRBS_ERROR_COUNT_LANE_9,
175+
176+
/** Per Lane PRBS Error Count For lane in index 10*/
177+
SAI_PORT_STAT_PRBS_ERROR_COUNT_LANE_10,
178+
179+
/** Per Lane PRBS Error Count For lane in index 11*/
180+
SAI_PORT_STAT_PRBS_ERROR_COUNT_LANE_11,
181+
182+
/** Per Lane PRBS Error Count For lane in index 12*/
183+
SAI_PORT_STAT_PRBS_ERROR_COUNT_LANE_12,
184+
185+
/** Per Lane PRBS Error Count For lane in index 13*/
186+
SAI_PORT_STAT_PRBS_ERROR_COUNT_LANE_13,
187+
188+
/** Per Lane PRBS Error Count For lane in index 14*/
189+
SAI_PORT_STAT_PRBS_ERROR_COUNT_LANE_14,
190+
191+
/** Per Lane PRBS Error Count For lane in index 15*/
192+
SAI_PORT_STAT_PRBS_ERROR_COUNT_LANE_15,
193+
194+
/** Per Lane PRBS Error Count Range END*/
195+
SAI_PORT_STAT_PRBS_ERROR_COUNT_LANE_RANGE_END = 0x00004fff,
196+
```
197+
198+
4) New datatype to represent PRBS Bit Error Rate (BER):
199+
200+
Bit error rate (BER) offers a more precise evaluation of PRBS than error counts, as it normalizes errors against the total number of transmitted bits. This enables consistent and meaningful assessment of link quality across varying data rates and test durations.
201+
202+
BER is typically a floating point number. SAI does not support floating point data types. Hence, introduce a new datatype to represent the exponent and mantissa information.
203+
204+
```c
205+
/*
206+
*Represents BER as: mantissa * 10^(-exponent)
207+
*/
208+
typedef struct _sai_prbs_bit_error_rate_t
209+
{
210+
uint8_t exponent; /* Negative exponent as in 10^-exponent */
211+
uint64_t mantissa; /* Significant digits of the BER, to be multiplied by 10^(-exponent) */
212+
} sai_prbs_bit_error_rate_t;
213+
```
214+
215+
Consider an example BER of 1.83258 x 10^-14. **mantissa** can be 183528 and **exponent** can be 19, i.e. **mantissa x 10^exponent**. The **mantissa** can contain at max 19 digits as 10^21 > MAX_UINT64 > 10^20.
216+
217+
Also, introduce a list for the above datatype.
218+
219+
```c
220+
typedef struct _sai_prbs_bit_error_rate_list_t
221+
{
222+
uint32_t count;
223+
sai_prbs_bit_error_rate_t *list;
224+
} sai_prbs_bit_error_rate_list_t;
225+
```
226+
227+
Add both the above types to **sai_attribute_value_t** union.
228+
229+
```c
230+
...Existing union members
231+
/** @validonly meta->attrvaluetype == SAI_ATTR_VALUE_TYPE_PRBS_BIT_ERROR_RATE */
232+
sai_prbs_bit_error_rate_t prbs_ber;
233+
234+
/** @validonly meta->attrvaluetype == SAI_ATTR_VALUE_TYPE_PRBS_BIT_ERROR_RATE_LIST */
235+
sai_prbs_bit_error_rate_list_t prbs_ber_list;
236+
} sai_attribute_value_t;
237+
238+
```
239+
240+
5) New port attributes for PRBS Bit Error Rate (BER):
241+
242+
```c
243+
244+
/**
245+
* @brief Per Lane PRBS Bit Error Rate (BER)
246+
*
247+
* Per lane list of PRBS Bit Error Rate (BER).
248+
* The values are of type sai_prbs_bit_error_rate_list_t where the count is the number
249+
* of lanes in a port and the list specifies list of values of type sai_prbs_bit_error_rate_t
250+
* for each lane.
251+
* BER will be (error count/bits transmitted) = BER.mantissa * (10^-BER.exponent)
252+
*
253+
* @type sai_prbs_bit_error_rate_list_t
254+
* @flags READ_ONLY
255+
*/
256+
SAI_PORT_ATTR_PRBS_PER_LANE_BER_LIST,
257+
```
258+
259+
## 4.0 API Example
260+
261+
Let us take an example port **prbs_port_oid** with 8 lanes.
262+
263+
### Get PRBS per lane lock status, lock loss status, rx status, rx state and bit error rate
264+
265+
```c
266+
sai_attr_list[attr_count].id = SAI_PORT_ATTR_PRBS_PER_LANE_LOCK_STATUS_LIST;
267+
sai_attr_list[attr_count].value.u8list.count = 8;
268+
sai_attr_list[attr_count].value.u8list.list = malloc(sizeof(sai_uint8_t)*sai_attr_list[attr_count++].value.u8list.count);
269+
270+
sai_attr_list[attr_count].id = SAI_PORT_ATTR_PRBS_PER_LANE_RX_STATUS_LIST;
271+
sai_attr_list[attr_count].value.u32list.count = 8;
272+
sai_attr_list[attr_count].value.u32list.list = malloc(sizeof(sai_uint32_t)*sai_attr_list[attr_count++].value.u32list.count);
273+
274+
sai_attr_list[attr_count].id = SAI_PORT_ATTR_PRBS_PER_LANE_RX_STATE_LIST;
275+
sai_attr_list[attr_count].value.prbs_rx_state_list.count = 8;
276+
sai_attr_list[attr_count].value.prbs_rx_state_list.list = malloc(sizeof(sai_prbs_rx_state_t)*sai_attr_list[attr_count++].value.prbs_rx_state_list.count);
277+
278+
sai_attr_list[attr_count].id = SAI_PORT_ATTR_PRBS_PER_LANE_BER_LIST;
279+
sai_attr_list[attr_count].value.prbs_ber_list.count = 8;
280+
sai_attr_list[attr_count].value.prbs_ber_list.list = malloc(sizeof(sai_prbs_bit_error_rate_t)*sai_attr_list[attr_count++].value.prbs_ber_list.count);
281+
282+
sai_get_port_attribute_fn(
283+
prbs_port_oid,
284+
attr_count,
285+
sai_attr_list);
286+
287+
```
288+
289+
### Get PRBS per lane error count stat
290+
291+
```c
292+
counter_id_list[num_counters++].id = SAI_PORT_STAT_PRBS_ERROR_COUNT_LANE_0;
293+
counter_id_list[num_counters++].id = SAI_PORT_STAT_PRBS_ERROR_COUNT_LANE_1;
294+
counter_id_list[num_counters++].id = SAI_PORT_STAT_PRBS_ERROR_COUNT_LANE_2;
295+
counter_id_list[num_counters++].id = SAI_PORT_STAT_PRBS_ERROR_COUNT_LANE_3;
296+
counter_id_list[num_counters++].id = SAI_PORT_STAT_PRBS_ERROR_COUNT_LANE_4;
297+
counter_id_list[num_counters++].id = SAI_PORT_STAT_PRBS_ERROR_COUNT_LANE_5;
298+
counter_id_list[num_counters++].id = SAI_PORT_STAT_PRBS_ERROR_COUNT_LANE_6;
299+
counter_id_list[num_counters++].id = SAI_PORT_STAT_PRBS_ERROR_COUNT_LANE_7;
300+
301+
sai_get_port_stats_fn(
302+
prbs_port_oid,
303+
num_counters,
304+
counter_id_list,
305+
&counters);
306+
```
307+

0 commit comments

Comments
 (0)