Skip to content

Commit f3f5baf

Browse files
authored
Merge pull request #13 from MicrochipTech/feature/eom
EOM Changes as per 4P eye capture
2 parents 4446b93 + 1257fd2 commit f3f5baf

File tree

8 files changed

+234
-477
lines changed

8 files changed

+234
-477
lines changed

cli/diag.c

Lines changed: 44 additions & 349 deletions
Large diffs are not rendered by default.

cli/graph.c

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ static void draw_status(WINDOW *win, int x_off, int x_cnt, const char *status)
134134
mvwprintw(win, 0, 0, " ");
135135
for (i = 0; i < x_cnt * 2 + x_off; i++)
136136
mvwaddch(win, 1, i, ' ');
137-
mvwprintw(win, 1, x_off, status);
137+
mvwprintw(win, 1, x_off, "%s",status);
138138
wrefresh(win);
139139
}
140140

@@ -374,6 +374,56 @@ void graph_init(void)
374374
curses_initialized = true;
375375
}
376376

377+
void get_screen_coords(int x, int y, int *sx, int *sy) {
378+
*sx = x*X_SCALE + 5;
379+
*sy = y/Y_SCALE;
380+
}
381+
382+
void plot_point(int x, int y)
383+
{
384+
mvprintw(y/Y_SCALE, x*X_SCALE, "O (%d,%d)", x-Y_PRINT_OFFSET, y-X_PRINT_OFFSET);
385+
}
386+
387+
int eye_plot_graph(int *data)
388+
{
389+
initscr();
390+
noecho();
391+
curs_set(FALSE);
392+
// Draw axes
393+
for (int x = 0; x <= PLOT_WIDTH; ++x)
394+
mvaddch(0, (x*X_SCALE) + 5, '-'); // X-axis at the top
395+
for (int y = 0; y <= PLOT_HEIGHT; ++y)
396+
mvaddch(y/Y_SCALE, 5, '|'); // Y-axis at the left
397+
// Draw scale on X-axis
398+
for (int x = 0; x <= PLOT_WIDTH; x += 5)
399+
{
400+
mvaddch(0, (x*X_SCALE) + 5, '+');
401+
mvprintw(1, (x*X_SCALE) + 5, "%d", x);
402+
}
403+
// Draw scale on Y-axis
404+
for (int y = 0; y <= PLOT_HEIGHT; y += 10) {
405+
mvaddch(y/Y_SCALE, 5, '+');
406+
mvprintw(y/Y_SCALE, 0, "%2d", y);
407+
}
408+
409+
//Adjusting the eye points to plot from 0 to 42 for x-axis and 0 t0 100 for Y-axis
410+
//as ncurses library did not support negative ploting
411+
data[0] = data[0] + X_LAYOUT_SHIFT;
412+
data[1] = data[1] + X_LAYOUT_SHIFT;
413+
data[2] = data[2] + Y_LAYOUT_SHIFT;
414+
data[3] = data[3] + Y_LAYOUT_SHIFT;
415+
416+
// Plot some points (example)
417+
plot_point(data[0] + Y_PRINT_OFFSET, Y_LAYOUT_SHIFT + X_PRINT_OFFSET); // (10,5)
418+
plot_point(data[1] + Y_PRINT_OFFSET, Y_LAYOUT_SHIFT + X_PRINT_OFFSET); // (20,10)
419+
plot_point(X_LAYOUT_SHIFT + Y_PRINT_OFFSET, data[2] + X_PRINT_OFFSET); // (30,15)
420+
plot_point(X_LAYOUT_SHIFT + Y_PRINT_OFFSET, data[3] + X_PRINT_OFFSET); // (35,18)
421+
422+
refresh();
423+
getch();
424+
endwin();
425+
return 0;
426+
}
377427
#else /* defined(HAVE_LIBCURSES) || defined(HAVE_LIBNCURSES) */
378428

379429
int graph_draw_win(struct range *X, struct range *Y, int *data, int *shades,

cli/graph.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,23 @@
5757
#define GRAPH_PLUS GRAPH_TEXT_PLUS
5858
#endif
5959

60+
#define PLOT_WIDTH 42
61+
#define PLOT_HEIGHT 100// Map data coordinates to screen coordinates (top-left origin)
62+
#define Y_SCALE 2
63+
#define X_SCALE 4
64+
#define X_PRINT_OFFSET 1
65+
#define Y_PRINT_OFFSET 2
66+
#define X_LAYOUT_SHIFT 21
67+
#define Y_LAYOUT_SHIFT 50
68+
6069
struct range;
6170

71+
typedef struct {
72+
int x;
73+
int y;
74+
}point_t;
75+
76+
6277
typedef int graph_anim_fn(struct range *X, struct range *Y, int *data,
6378
int *shades, char *status, bool *redraw, void *opaque);
6479

@@ -69,4 +84,6 @@ int graph_draw_win(struct range *X, struct range *Y, int *data, int *shades,
6984
const char *title, char x_title, char y_title, char *status,
7085
graph_anim_fn *anim, void *opaque);
7186

87+
int eye_plot_graph(int *data);
88+
7289
#endif

inc/switchtec/diag.h

Lines changed: 61 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -187,18 +187,31 @@ struct switchtec_diag_pat_gen_out {
187187
uint32_t err_cnt_hi;
188188
};
189189

190+
#pragma pack (push,1)
190191
struct switchtec_diag_port_eye_start {
191192
uint8_t sub_cmd;
192193
uint8_t resvd1[3];
193-
uint32_t resvd2;
194-
uint32_t lane_mask[4];
195-
int16_t x_start;
196-
int16_t y_start;
197-
int16_t x_end;
198-
int16_t y_end;
199-
uint16_t x_step;
200-
uint16_t y_step;
201-
uint32_t step_interval;
194+
/*defines the lane ID to run */
195+
uint8_t lane_id;
196+
/*Target BER type */
197+
uint8_t target_ber_type;
198+
/*Defines the maximum numbers of errors*/
199+
uint8_t max_allowed_ber_errors;
200+
/*Defines the confidence Level*/
201+
uint8_t confidence_lvl;
202+
/*defines the horizontal step size*/
203+
int8_t x_step;
204+
/*defines the vertical step size*/
205+
int8_t y_step;
206+
/*Defines the vertical sweep at x1 for six point capture*/
207+
int8_t v_sweep_at_x1;
208+
/*Defines the vertical sweep at x2 for six point capture*/
209+
int8_t v_sweep_at_x2;
210+
/*Defines the Time in recovery before link down value for EOM*/
211+
uint32_t eom_time_in_recov_in_us;
212+
/*defines the error method 0-parity error method, 1-l2r error method*/
213+
uint8_t eom_error_method;
214+
uint8_t reserved[3];
202215
};
203216

204217
struct switchtec_diag_port_eye_cmd {
@@ -213,27 +226,21 @@ struct switchtec_diag_port_eye_fetch {
213226
uint8_t data_mode;
214227
uint8_t resvd1;
215228
uint8_t status;
216-
uint32_t time_remaining;
217-
uint32_t lane_mask[4];
218-
uint8_t x_start;
219-
uint8_t resvd2;
220-
int16_t y_start;
221-
uint8_t data_count_lo;
222-
uint8_t frame_status;
223-
uint8_t resvd3;
224-
uint8_t data_count_hi;
225-
union {
226-
struct {
227-
uint32_t error_cnt_lo;
228-
uint32_t error_cnt_hi;
229-
uint32_t sample_cnt_lo;
230-
uint32_t sample_cnt_hi;
231-
} raw[62];
232-
struct {
233-
uint16_t ratio;
234-
} ratio[496];
235-
};
229+
int32_t eye_left;
230+
int32_t eye_right;
231+
int32_t eye_top_x1;
232+
int32_t eye_bottom_x1;
233+
int32_t eye_top_x2;
234+
int32_t eye_bottom_x2;
235+
};
236+
237+
struct switchtec_diag_port_eye_data {
238+
int32_t eye_left;
239+
int32_t eye_right;
240+
int32_t eye_top_x1;
241+
int32_t eye_bottom_x1;
236242
};
243+
#pragma pack(pop)
237244

238245
struct switchtec_diag_cross_hair_in {
239246
uint8_t sub_cmd;
@@ -272,5 +279,30 @@ struct switchtec_diag_cross_hair_get {
272279
};
273280
};
274281

282+
typedef enum {
283+
/* command error code for Start, fetch and cancel */
284+
EOM_SUCCESS, /* EOM general result, means no error */
285+
286+
/* Error codes for EOM Start sub command */
287+
EOM_FAILED_TO_START, /* EOM Failed to Start*/
288+
EOM_INVALID_PARAMETER, /* EOM parameter error */
289+
EOM_PREV_CMD_NOT_FINISHED, /* EOM cmd error, the previous cmd has not finished */
290+
291+
/* Error codes for EOM Fetch Sub command */
292+
EOM_IN_PROGRESS, /* EOM in progress, but no output data yet */
293+
EOM_NOT_RUNNING, /*EOM Not running*/
294+
295+
/* Error codes for EOM Cancel sub command*/
296+
EOM_FAILED_TO_CANCEL, /*EOM Failed to cancel*/
297+
298+
/* error codes for EOM Running state machine*/
299+
EOM_SPEED_IS_NOT_GEN3_OR_4, /* EOM Speed is not Gen3 or 4*/
300+
EOM_MARGIN_CODE_OUT_OF_RANGE, /* EOM Margin code out of range*/
301+
EOM_WAITING_FOR_HARDWARE, /* EOM waiting for hardware*/
302+
303+
/*Invalid error code*/
304+
EOM_ERROR = 0xFF,
305+
} mrpc_stat_eom_enum;
306+
275307
#endif
276308
/**@}*/

inc/switchtec/mrpc.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -259,12 +259,12 @@ enum mrpc_sub_cmd {
259259
MRPC_PAT_GEN_SET_MON = 8,
260260
MRPC_PAT_GEN_INJ_ERR = 9,
261261

262-
MRPC_EYE_OBSERVE_START = 0,
263-
MRPC_EYE_OBSERVE_FETCH = 1,
264-
MRPC_EYE_OBSERVE_CANCEL = 2,
265-
MRPC_EYE_OBSERVE_SET_DATA_MODE = 3,
266-
MRPC_EYE_OBSERVE_GET_DATA_MODE = 4,
267-
262+
MRPC_EYE_OBSERVE_START = 6,
263+
MRPC_EYE_OBSERVE_FETCH = 7,
264+
MRPC_EYE_OBSERVE_6PT_START = 8,
265+
MRPC_EYE_OBSERVE_6PT_FETCH = 9,
266+
MRPC_EYE_OBSERVE_CANCEL = 0xa,
267+
268268
MRPC_CROSS_HAIR_ENABLE = 0,
269269
MRPC_CROSS_HAIR_DISABLE = 1,
270270
MRPC_CROSS_HAIR_GET = 2,

inc/switchtec/switchtec.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include <stdlib.h>
4141
#include <stdint.h>
4242
#include <stdio.h>
43+
#include "diag.h"
4344

4445
#ifdef __cplusplus
4546
extern "C" {
@@ -1241,11 +1242,8 @@ int switchtec_diag_cross_hair_get(struct switchtec_dev *dev, int start_lane_id,
12411242

12421243
int switchtec_diag_eye_set_mode(struct switchtec_dev *dev,
12431244
enum switchtec_diag_eye_data_mode mode);
1244-
int switchtec_diag_eye_start(struct switchtec_dev *dev, int lane_mask[4],
1245-
struct range *x_range, struct range *y_range,
1246-
int step_interval);
1247-
int switchtec_diag_eye_fetch(struct switchtec_dev *dev, double *pixels,
1248-
size_t pixel_cnt, int *lane_id);
1245+
int switchtec_diag_eye_start(struct switchtec_dev *dev, int lane_id, unsigned int error_threshold);
1246+
int switchtec_diag_eye_fetch(struct switchtec_dev *dev, struct switchtec_diag_port_eye_data *data_out);
12491247
int switchtec_diag_eye_cancel(struct switchtec_dev *dev);
12501248

12511249
int switchtec_diag_loopback_set(struct switchtec_dev *dev, int port_id,

0 commit comments

Comments
 (0)