Skip to content

Commit 6fa7b09

Browse files
aghaffarkhahRaj998
authored andcommitted
First cut of Diag gNOI micro service
1 parent 6a007f2 commit 6fa7b09

File tree

2 files changed

+250
-0
lines changed

2 files changed

+250
-0
lines changed

diag/BUILD.bazel

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
load("@io_bazel_rules_go//proto:go_proto_library.bzl", "go_proto_library")
2+
3+
proto_library(
4+
name = "diag_proto",
5+
srcs = ["diag.proto"],
6+
)
7+
8+
go_proto_library(
9+
name = "go_default_library",
10+
srcs = ["diag.proto"],
11+
visibility = ["//visibility:public"],
12+
rules_go_repo_only_for_internal_use = "@",
13+
has_services = 1,
14+
)

diag/diag.proto

+236
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,236 @@
1+
//
2+
// Copyright 2017 Google Inc. All Rights Reserved.
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
//
16+
17+
// This file defines the gNOI APIs used to perform diagnostic operations on a
18+
// switching box.
19+
syntax = "proto3";
20+
21+
package gnoi.diag;
22+
23+
// The Diag service exports to main set of RPCs:
24+
// 1- BERT related RPCs: Used to perform Bit Error Rate Test (BERT)
25+
// operation on a set of ports.
26+
// 2- BURNING related RPCs: Used to perform a vendor-provide Burnin test on the
27+
// switch to ensure the box is ready to start serving traffic. Burnin tests
28+
// are typically run by HwOps in the datacenter, as part of turnup or repair
29+
// workflow.
30+
service Diag {
31+
// Starts BERT operation on a set of ports. Each BERT operation is uniquely
32+
// identified by an ID, which is given by the caller. The caller can then
33+
// use this ID (as well as the list of the ports) to stop the BERT operation
34+
// and/or get the BERT results. This RPC is expected to return an error status
35+
// in the the following situations:
36+
// - When BERT operation is not supported on any of the ports specified by
37+
// the request.
38+
// - When BERT is already in progress on any port specified by the request.
39+
// - In case of any low-level HW/SW internal errors.
40+
// The RPC returns an OK status of none of these situations is encountered.
41+
rpc StartBERT(StartBERTRequest) returns(StartBERTResponse) {}
42+
43+
// Stops an already in-progress BERT operation on a set of ports. The caller
44+
// uses the BERT operation ID it previously used when starting the operation
45+
// to stop it. The RPC is expected to return an error status in the following
46+
// situations:
47+
// - When there is at least one BERT operation in progress on a port which
48+
// cannot be stopped in the middle of the operation (either due to lack of
49+
// support or internal problems).
50+
// - When no BERT operation, which matches the given BERT operation ID, is in
51+
// progress or completed on any of the ports specified by the request.
52+
// - When the BERT operation ID does not match the in progress or completed
53+
// BERT operation on any of the ports specified by the request.
54+
// The RPC returns an OK status of none of these situations is encountered.
55+
// Note that a BERT operation is considered completed if switch has a
56+
// record of it. Also note that it is OK to receive a stop request for a port
57+
// which has completed BERT, as long as the recorded BERT operation ID matches
58+
// the one specified by the request.
59+
rpc StopBERT(StopBERTRequest) returns(StopBERTResponse) {}
60+
61+
// Gets BERT results during the BERT operation or after it completes. The
62+
// caller uses the BERT operation ID it previously used when starting the
63+
// operation to query it. The switch is expected to keep the results for
64+
// last N BERT operations for some amount of time, as specified by the
65+
// product requirement. This RPC is expected to return error status in the
66+
// following situations:
67+
// - When no BERT operation, which matches the given BERT operation ID, is in
68+
// progress or completed on any of the ports specified by the request.
69+
// - When the BERT operation ID does not match the in progress or completed
70+
// BERT operation on any of the ports specified by the request.
71+
// The RPC returns an OK status of none of these situations is encountered.
72+
// Note that a BERT operation is considered completed if switch has a
73+
// record of it.
74+
rpc GetBERTResult(GetBERTResultRequest) returns(GetBERTResultResponse) {}
75+
76+
// TODO(aghaffar): Add BURNIN related RPCs.
77+
}
78+
79+
// Common sequence generating monic polynomials used for PRBS.
80+
enum PrbsPolynomial {
81+
PRBS_POLYNOMIAL_UNKNOWN = 0; // default invalid choice.
82+
PRBS_POLYNOMIAL_PRBS7 = 1;
83+
PRBS_POLYNOMIAL_PRBS9 = 2;
84+
PRBS_POLYNOMIAL_PRBS15 = 3;
85+
PRBS_POLYNOMIAL_PRBS20 = 4;
86+
PRBS_POLYNOMIAL_PRBS23 = 5;
87+
PRBS_POLYNOMIAL_PRBS31 = 6;
88+
}
89+
90+
// Status returned for each per-port BERT request.
91+
enum BertStatus {
92+
// default invalid choice.
93+
BERT_STATUS_UNKNOWN = 0;
94+
// BERT requests (Start, Stop, GetStatus) were processed successfully.
95+
BERT_STATUS_OK = 1;
96+
// The specified port was not found.
97+
BERT_STATUS_NON_EXISTENT_PORT = 2;
98+
// HW error was encountered while performing BERT operation.
99+
BERT_STATUS_HARDWARE_ACCESS_ERROR = 3;
100+
// PRBS generating polynomial is not supported by the target.
101+
BERT_STATUS_UNSUPPORTED_PRBS_POLYNOMIAL = 4;
102+
// There is already a BERT running on the specified port. Returned when
103+
// `StartBert` RPC tries to add run BERT on an already in-use port.
104+
BERT_STATUS_PORT_ALREADY_IN_BERT = 5;
105+
// There is no BERT running on the specified port. Returned when `StopBert`
106+
// or `GetBertResult` RPC was called for an idle port.
107+
BERT_STATUS_PORT_NOT_RUNNING_BERT = 6;
108+
// The specified test duration is too small.
109+
BERT_STATUS_TEST_DURATION_TOO_SHORT = 7;
110+
// The specified test duration is larger than maximum allowed.
111+
BERT_STATUS_TEST_DURATION_TOO_LONG = 8;
112+
// The given BERT operation ID is not known. Returned for `StopBert` and
113+
// `GetBertResult` RPCs.
114+
BERT_STATUS_BERT_OPERATION_ID_NOT_FOUND = 9;
115+
// The given BERT operation ID is already in use. Returned when `StartBert`
116+
// RPC uses an ID which is already memorized for a BERT operation.
117+
BERT_STATUS_BERT_OPERATION_ID_ALREADY_IN_USE = 10;
118+
// Failure to get the peer lock.
119+
BERT_STATUS_PEER_LOCK_FAILURE = 11;
120+
// Lost the peer lock after locking once.
121+
BERT_STATUS_PEER_LOCK_LOST = 12;
122+
// Misc internal errors that cannot be categorized by any of the previous
123+
// error codes.
124+
BERT_STATUS_INTERNAL_ERROR = 13;
125+
}
126+
127+
message StartBERTRequest {
128+
// Per port BERT start requests.
129+
message PerPortRequest {
130+
// Path to the interface corresponding to the port.
131+
gnoi.Path interface = 1; // required
132+
// The selected PRBS generating polynomial for BERT.
133+
PrbsPolynomial prbs_polynomial = 2;
134+
// BERT duration in mins. Must be a positive number.
135+
uint32 test_duration_in_mins = 3; // required
136+
}
137+
// Unique BERT operation ID specified by the client. Multiple BERTs run on
138+
// different ports can have the same BERT operation ID. This ID will be used
139+
// later to stop the operation and/or get its results.
140+
string bert_operation_id = 1;
141+
// All the per-port BERTs that are considered one BERT operation and have the
142+
// same BERT operation ID.
143+
repeated PerPortRequest per_port_requests = 2;
144+
}
145+
146+
message StartBERTResponse {
147+
// Per-port BERT start responses.
148+
message PerPortResponse {
149+
// Path to the interface corresponding to the port.
150+
gnoi.Path interface = 1;
151+
// BERT start status for this port.
152+
BertStatus status = 2;
153+
}
154+
// The same BERT operation ID given by the request.
155+
string bert_operation_id = 1;
156+
// Captures the results of starting BERT on a per-port basis.
157+
repeated PerPortResponse per_port_responses = 2;
158+
}
159+
160+
message StopBERTRequest {
161+
// Per-port BERT stop requests.
162+
message PerPortRequest {
163+
// Path to the interface corresponding to the port.
164+
gnoi.Path interface = 1;
165+
}
166+
// The same BERT operation ID given when BERT operation was started.
167+
string bert_operation_id = 1;
168+
// All the per-port BERTs that need to be stopped. Must be part of the BERT
169+
// operation specified by the `bert_operation_id` above.
170+
repeated PerPortRequest per_port_requests = 2;
171+
}
172+
173+
message StopBERTResponse {
174+
// Per-port BERT stop responses.
175+
message PerPortResponse {
176+
// Path to the interface corresponding to the port.
177+
gnoi.Path interface = 1;
178+
// BERT stop status for this port.
179+
BertStatus status = 2;
180+
}
181+
// The same BERT operation ID given by the request.
182+
string bert_operation_id = 1;
183+
// Captures the results of stopping BERT on a per-port basis.
184+
repeated PerPortResponse per_port_responses = 2;
185+
}
186+
187+
message GetBERTResultRequest {
188+
// Per-port BERT get result requests.
189+
message PerPortRequest {
190+
// Path to the interface corresponding to the port.
191+
gnoi.Path interface = 1;
192+
}
193+
// The same BERT operation ID given when BERT operation was started.
194+
string bert_operation_id = 1;
195+
// All the per-port BERTs result of which we want to query. Must be part of
196+
// the BERT operation specified by the `bert_operation_id` above.
197+
repeated PerPortRequest per_port_requests = 2;
198+
// If set to true, the results for all the per-port BERTs will be returned.
199+
// `bert_operation_id` and `per_port_requests` will be ignored will be
200+
// ignored in that case.
201+
bool result_from_all_ports = 3;
202+
}
203+
204+
message GetBERTResultResponse {
205+
// Per-port BERT results/status.
206+
message PerPortResponse {
207+
// Path to the interface corresponding to the port.
208+
gnoi.Path interface = 1;
209+
// BERT result get status for this port. Only if the status is
210+
// BERT_STATUS_OK the rest of the fields below are meaningful.
211+
BertStatus status = 2;
212+
// The ID of the BERT operation running on this port. Since the caller
213+
// can query the BERT results for all the ports, ID can potentially be
214+
// different for different ports.
215+
string bert_operation_id = 3;
216+
// The selected PRBS generating polynomial for BERT on this port.
217+
PrbsPolynomial prbs_polynomial = 4;
218+
// The last time BERT started on this port.
219+
uint64 last_bert_start_timestamp = 5;
220+
// The last time BERT results were read for this port.
221+
uint64 last_bert_get_result_timestamp = 6;
222+
// Indicate whether BERT peer lock has was established. If false,
223+
// `bert_lock_lost`, `error_count_per_minute`, and `total_errors` will not
224+
// be meaningful.
225+
bool peer_lock_established = 7;
226+
// Indicate whether BERT peer lock was lost after being established
227+
// once.
228+
bool peer_lock_lost = 8;
229+
// Sequence of bit errors per min since lock was established.
230+
repeated uint32 error_count_per_minute = 9;
231+
// Total number of bit errors accumulated since lock was established.
232+
uint64 total_errors = 10;
233+
}
234+
// Captures the BERT results on a per-port basis.
235+
repeated PerPortResponse per_port_responses = 1;
236+
}

0 commit comments

Comments
 (0)