Skip to content

Commit 2bff74b

Browse files
resolved alignements
1 parent da8fafe commit 2bff74b

File tree

4 files changed

+104
-106
lines changed

4 files changed

+104
-106
lines changed

cli/diag.c

Lines changed: 36 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,6 @@ int eye_observe_dev(struct switchtec_dev *dev, unsigned int error_threshold,
211211
}
212212

213213
ret = switchtec_diag_eye_fetch(dev, &data_out);
214-
215214
memcpy(&eye_data[0], &data_out, sizeof(struct switchtec_diag_port_eye_data));
216215

217216
if (!ret) {
@@ -220,19 +219,18 @@ int eye_observe_dev(struct switchtec_dev *dev, unsigned int error_threshold,
220219
}
221220
else {
222221
ret = switchtec_diag_eye_6p_start(dev, lane_id, error_threshold);
223-
if (ret) {
224-
switchtec_perror("eye_start");
225-
}
226-
227-
ret = switchtec_diag_eye_6p_data_fetch(dev, &data_6p_out);
222+
if (ret) {
223+
switchtec_perror("eye_start");
224+
}
228225

229-
memcpy(&eye_6p_data[0], &data_6p_out, sizeof(struct switchtec_diag_port_6p_eye_data));
226+
ret = switchtec_diag_eye_6p_data_fetch(dev, &data_6p_out);
227+
memcpy(&eye_6p_data[0], &data_6p_out, sizeof(struct switchtec_diag_port_6p_eye_data));
230228

231-
if (!ret) {
232-
w2h_score = calculate_w2h_score(&data_6p_out);
233-
printf("W2H Score for Lane %d is %d\n", lane_id, w2h_score);
234-
eye_plot_graph(eye_6p_data, true, w2h_score);
235-
}
229+
if (!ret) {
230+
w2h_score = calculate_w2h_score(&data_6p_out);
231+
printf("W2H Score for Lane %d is %d\n", lane_id, w2h_score);
232+
eye_plot_graph(eye_6p_data, true, w2h_score);
233+
}
236234
}
237235

238236
return 0;
@@ -258,19 +256,19 @@ static int w2h(int argc, char **argv)
258256
.v_step = 1,
259257
};
260258
const struct argconfig_options opts[] = {
261-
DEVICE_OPTION,
262-
{"format", 'f', "FMT", CFG_CHOICES, &cfg.fmt, required_argument,
263-
"output format (default: " FMT_DEFAULT_STR ")",
264-
.choices=output_fmt_choices},
265-
{"lane", 'l', "LANE_ID", CFG_NONNEGATIVE, &cfg.lane_id,
266-
required_argument, "lane id within the port to observe"},
267-
{"error threshold", 't',"ERROR THRESHOLD", CFG_NONNEGATIVE, &cfg.error_threshold,
268-
optional_argument, "Maximum allowed errors"},
269-
{"t-step", 's', "NUM", CFG_NONNEGATIVE, &cfg.t_step,
270-
required_argument, "time step (default 1)"},
271-
{"v-step", 'S', "NUM", CFG_NONNEGATIVE, &cfg.v_step,
272-
required_argument, "voltage step (default: 5)"},
273-
{NULL}};
259+
DEVICE_OPTION,
260+
{"format", 'f', "FMT", CFG_CHOICES, &cfg.fmt, required_argument,
261+
"output format (default: " FMT_DEFAULT_STR ")",
262+
.choices=output_fmt_choices},
263+
{"lane", 'l', "LANE_ID", CFG_NONNEGATIVE, &cfg.lane_id,
264+
required_argument, "lane id within the port to observe"},
265+
{"error threshold", 't',"ERROR THRESHOLD", CFG_NONNEGATIVE, &cfg.error_threshold,
266+
optional_argument, "Maximum allowed errors"},
267+
{"t-step", 's', "NUM", CFG_NONNEGATIVE, &cfg.t_step,
268+
required_argument, "time step (default 1)"},
269+
{"v-step", 'S', "NUM", CFG_NONNEGATIVE, &cfg.v_step,
270+
required_argument, "voltage step (default: 5)"},
271+
{NULL}};
274272

275273
argconfig_parse(argc, argv, CMD_DESC_EYE_W2H, opts, &cfg,
276274
sizeof(cfg));
@@ -300,19 +298,19 @@ static int eye(int argc, char **argv)
300298
.v_step = 1,
301299
};
302300
const struct argconfig_options opts[] = {
303-
DEVICE_OPTION,
304-
{"format", 'f', "FMT", CFG_CHOICES, &cfg.fmt, required_argument,
305-
"output format (default: " FMT_DEFAULT_STR ")",
306-
.choices=output_fmt_choices},
307-
{"lane", 'l', "LANE_ID", CFG_NONNEGATIVE, &cfg.lane_id,
308-
required_argument, "lane id within the port to observe"},
309-
{"error threshold", 't',"ERROR THRESHOLD", CFG_NONNEGATIVE, &cfg.error_threshold,
310-
optional_argument, "Maximum allowed errors"},
311-
{"t-step", 's', "NUM", CFG_NONNEGATIVE, &cfg.t_step,
312-
required_argument, "time step (default 1)"},
313-
{"v-step", 'S', "NUM", CFG_NONNEGATIVE, &cfg.v_step,
314-
required_argument, "voltage step (default: 5)"},
315-
{NULL}};
301+
DEVICE_OPTION,
302+
{"format", 'f', "FMT", CFG_CHOICES, &cfg.fmt, required_argument,
303+
"output format (default: " FMT_DEFAULT_STR ")",
304+
.choices=output_fmt_choices},
305+
{"lane", 'l', "LANE_ID", CFG_NONNEGATIVE, &cfg.lane_id,
306+
required_argument, "lane id within the port to observe"},
307+
{"error threshold", 't',"ERROR THRESHOLD", CFG_NONNEGATIVE, &cfg.error_threshold,
308+
optional_argument, "Maximum allowed errors"},
309+
{"t-step", 's', "NUM", CFG_NONNEGATIVE, &cfg.t_step,
310+
required_argument, "time step (default 1)"},
311+
{"v-step", 'S', "NUM", CFG_NONNEGATIVE, &cfg.v_step,
312+
required_argument, "voltage step (default: 5)"},
313+
{NULL}};
316314

317315
argconfig_parse(argc, argv, CMD_DESC_EYE, opts, &cfg,
318316
sizeof(cfg));

cli/graph.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ int eye_plot_graph(int *data, bool plot_6p_points, unsigned int w2h_score)
409409
snprintf(legend, sizeof(legend), "W2H SCORE = %u", w2h_score);
410410

411411
if (plot_6p_points == true) {
412-
mvprintw(0, COLS - strlen(legend) - 1, "%s", legend);
412+
mvprintw(0, COLS - strlen(legend) - 1, "%s", legend);
413413
}
414414

415415
//Adjusting the eye points to plot from 0 to 42 for x-axis and 0 t0 100 for Y-axis
@@ -420,22 +420,22 @@ int eye_plot_graph(int *data, bool plot_6p_points, unsigned int w2h_score)
420420
data[3] = data[3] + Y_LAYOUT_SHIFT;
421421

422422
if(plot_6p_points == true) {
423-
data[4] = data[4] + Y_LAYOUT_SHIFT;
424-
data[5] = data[5] + Y_LAYOUT_SHIFT;
423+
data[4] = data[4] + Y_LAYOUT_SHIFT;
424+
data[5] = data[5] + Y_LAYOUT_SHIFT;
425425
}
426426

427427
plot_point(data[0] + Y_PRINT_OFFSET, Y_LAYOUT_SHIFT + X_PRINT_OFFSET);
428428
plot_point(data[1] + Y_PRINT_OFFSET, Y_LAYOUT_SHIFT + X_PRINT_OFFSET);
429429

430430
if(plot_6p_points == true) {
431-
plot_point((X_LAYOUT_SHIFT + Y_PRINT_OFFSET) - 3, data[2] + X_PRINT_OFFSET);
432-
plot_point((X_LAYOUT_SHIFT + Y_PRINT_OFFSET) - 3, data[3] + X_PRINT_OFFSET);
433-
plot_point((X_LAYOUT_SHIFT + Y_PRINT_OFFSET) + 3, data[4] + X_PRINT_OFFSET);
434-
plot_point((X_LAYOUT_SHIFT + Y_PRINT_OFFSET) + 3, data[5] + X_PRINT_OFFSET);
431+
plot_point((X_LAYOUT_SHIFT + Y_PRINT_OFFSET) - 3, data[2] + X_PRINT_OFFSET);
432+
plot_point((X_LAYOUT_SHIFT + Y_PRINT_OFFSET) - 3, data[3] + X_PRINT_OFFSET);
433+
plot_point((X_LAYOUT_SHIFT + Y_PRINT_OFFSET) + 3, data[4] + X_PRINT_OFFSET);
434+
plot_point((X_LAYOUT_SHIFT + Y_PRINT_OFFSET) + 3, data[5] + X_PRINT_OFFSET);
435435
}
436436
else {
437-
plot_point(X_LAYOUT_SHIFT + Y_PRINT_OFFSET, data[2] + X_PRINT_OFFSET);
438-
plot_point(X_LAYOUT_SHIFT + Y_PRINT_OFFSET, data[3] + X_PRINT_OFFSET);
437+
plot_point(X_LAYOUT_SHIFT + Y_PRINT_OFFSET, data[2] + X_PRINT_OFFSET);
438+
plot_point(X_LAYOUT_SHIFT + Y_PRINT_OFFSET, data[3] + X_PRINT_OFFSET);
439439
}
440440

441441
mvprintw(LINES - 1, 0, "Press 'q' to quit.");

inc/switchtec/diag.h

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -199,24 +199,24 @@ struct switchtec_diag_port_eye_start {
199199
/*defines the lane ID to run */
200200
uint8_t lane_id;
201201
/*Target BER type */
202-
uint8_t target_ber_type;
203-
/*Defines the maximum numbers of errors*/
204-
uint8_t max_allowed_ber_errors;
205-
/*Defines the confidence Level*/
206-
uint8_t confidence_lvl;
207-
/*defines the horizontal step size*/
208-
int8_t x_step;
209-
/*defines the vertical step size*/
210-
int8_t y_step;
211-
/*Defines the vertical sweep at x1 for six point capture*/
212-
int8_t v_sweep_at_x1;
213-
/*Defines the vertical sweep at x2 for six point capture*/
214-
int8_t v_sweep_at_x2;
215-
/*Defines the Time in recovery before link down value for EOM*/
216-
uint32_t eom_time_in_recov_in_us;
217-
/*defines the error method 0-parity error method, 1-l2r error method*/
218-
uint8_t eom_error_method;
219-
uint8_t reserved[3];
202+
uint8_t target_ber_type;
203+
/*Defines the maximum numbers of errors*/
204+
uint8_t max_allowed_ber_errors;
205+
/*Defines the confidence Level*/
206+
uint8_t confidence_lvl;
207+
/*defines the horizontal step size*/
208+
int8_t x_step;
209+
/*defines the vertical step size*/
210+
int8_t y_step;
211+
/*Defines the vertical sweep at x1 for six point capture*/
212+
int8_t v_sweep_at_x1;
213+
/*Defines the vertical sweep at x2 for six point capture*/
214+
int8_t v_sweep_at_x2;
215+
/*Defines the Time in recovery before link down value for EOM*/
216+
uint32_t eom_time_in_recov_in_us;
217+
/*defines the error method 0-parity error method, 1-l2r error method*/
218+
uint8_t eom_error_method;
219+
uint8_t reserved[3];
220220
};
221221

222222
struct switchtec_diag_port_eye_cmd {

lib/diag.c

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -160,30 +160,30 @@ static int switchtec_diag_eye_cmd(struct switchtec_dev *dev, void *in,
160160

161161
int switchtec_diag_eye_6p_start(struct switchtec_dev *dev, int lane, unsigned int error_threshold)
162162
{
163-
int err;
164-
int ret;
165-
struct switchtec_diag_port_eye_start in = {
166-
.sub_cmd = MRPC_EYE_OBSERVE_6PT_START,
167-
.lane_id = lane,
168-
.target_ber_type = 0,
169-
.max_allowed_ber_errors = error_threshold,
170-
.confidence_lvl = 95,
171-
.x_step = 1,
172-
.y_step = 1,
173-
.v_sweep_at_x1 = -3,
174-
.v_sweep_at_x2 = 3,
175-
.eom_time_in_recov_in_us = 0,
176-
.eom_error_method = 1,
177-
};
178-
179-
ret = switchtec_diag_eye_cmd(dev, &in, sizeof(in));
180-
181-
/* Add delay so hardware has enough time to start */
182-
err = errno;
183-
usleep(200000);
184-
errno = err;
185-
186-
return ret;
163+
int err;
164+
int ret;
165+
struct switchtec_diag_port_eye_start in = {
166+
.sub_cmd = MRPC_EYE_OBSERVE_6PT_START,
167+
.lane_id = lane,
168+
.target_ber_type = 0,
169+
.max_allowed_ber_errors = error_threshold,
170+
.confidence_lvl = 95,
171+
.x_step = 1,
172+
.y_step = 1,
173+
.v_sweep_at_x1 = -3,
174+
.v_sweep_at_x2 = 3,
175+
.eom_time_in_recov_in_us = 0,
176+
.eom_error_method = 1,
177+
};
178+
179+
ret = switchtec_diag_eye_cmd(dev, &in, sizeof(in));
180+
181+
/* Add delay so hardware has enough time to start */
182+
err = errno;
183+
usleep(200000);
184+
errno = err;
185+
186+
return ret;
187187
}
188188

189189

@@ -223,16 +223,16 @@ int switchtec_diag_eye_start(struct switchtec_dev *dev, int lane, unsigned int e
223223
}
224224

225225
const char* diag_eom_status_string[] = {
226-
"Success",
226+
"Success",
227227
"Failed to Start",
228228
"Invalid Parameters",
229229
"Previous Command Not Finished",
230-
"In progress",
231-
"Not Running",
232-
"Failed to cancel",
233-
"Speed is not Gen3 or Gen4",
234-
"Margin Code Out of Range",
235-
"Waiting for Hardware"
230+
"In progress",
231+
"Not Running",
232+
"Failed to cancel",
233+
"Speed is not Gen3 or Gen4",
234+
"Margin Code Out of Range",
235+
"Waiting for Hardware"
236236
};
237237

238238
int switchtec_diag_eye_6p_data_fetch(struct switchtec_dev *dev, struct switchtec_diag_port_6p_eye_data *data_out)
@@ -318,16 +318,16 @@ int switchtec_diag_eye_fetch(struct switchtec_dev *dev, struct switchtec_diag_po
318318
goto retry;
319319
}
320320
else if(out.status == EOM_SUCCESS) {
321-
printf("Eye Left %d\n", out.eye_left);
322-
printf("Eye Right %d\n", out.eye_right);
323-
printf("Eye top %d\n", out.eye_top_x1);
324-
printf("Eye Bottom %d\n", out.eye_bottom_x1);
325-
326-
data.eye_left = out.eye_left;
327-
data.eye_right = out.eye_right;
328-
data.eye_top_x1 = out.eye_top_x1;
329-
data.eye_bottom_x1 = out.eye_bottom_x1;
330-
memcpy(data_out, &data, sizeof(struct switchtec_diag_port_eye_data));
321+
printf("Eye Left %d\n", out.eye_left);
322+
printf("Eye Right %d\n", out.eye_right);
323+
printf("Eye top %d\n", out.eye_top_x1);
324+
printf("Eye Bottom %d\n", out.eye_bottom_x1);
325+
326+
data.eye_left = out.eye_left;
327+
data.eye_right = out.eye_right;
328+
data.eye_top_x1 = out.eye_top_x1;
329+
data.eye_bottom_x1 = out.eye_bottom_x1;
330+
memcpy(data_out, &data, sizeof(struct switchtec_diag_port_eye_data));
331331
}
332332
else {
333333
printf("EOM Status %s\n", diag_eom_status_string[out.status]);

0 commit comments

Comments
 (0)