@@ -1082,69 +1082,29 @@ static int crosshair(int argc, char **argv)
10821082 return ret ;
10831083}
10841084
1085- int eye_observe_dev (struct switchtec_dev * dev , int port_id ,
1085+ int eye_observe_dev (struct switchtec_dev * dev , unsigned int error_threshold ,
10861086 int lane_id , int * gen )
10871087{
10881088 int ret ;
10891089 struct switchtec_diag_port_eye_data data_out ;
1090- unsigned int eye_data [6 ];
1090+ int eye_data [4 ];
10911091
1092- ret = switchtec_diag_eye_start (dev , lane_id );
1092+ ret = switchtec_diag_eye_start (dev , lane_id , error_threshold );
10931093 if (ret ) {
10941094 switchtec_perror ("eye_start" );
10951095 }
10961096
1097+ printf ("started\n" );
10971098 ret = switchtec_diag_eye_fetch (dev , & data_out );
10981099
1099- data_out .eye_left = abs (data_out .eye_left );
1100- data_out .eye_right = abs (data_out .eye_right );
1101- data_out .eye_top_x1 = abs (data_out .eye_top_x1 );
1102- data_out .eye_bottom_x1 = abs (data_out .eye_bottom_x1 );
1103-
1104- printf ("%d %d %d %d\n" , data_out .eye_left , data_out .eye_right , data_out .eye_top_x1 , data_out .eye_bottom_x1 );
11051100 memcpy (& eye_data [0 ], & data_out , sizeof (struct switchtec_diag_port_eye_data ));
1106- graph_draw_eom_win (eye_data , 4 ,"Eye Observation Monitor" ,"press q to quit" );
1107- return 0 ;
1108- }
1109-
1110- static int eye_graph (enum output_format fmt , struct range * X , struct range * Y ,
1111- double * pixels , const char * title ,
1112- struct switchtec_diag_cross_hair * ch )
1113- {
1114- size_t pixel_cnt = RANGE_CNT (X ) * RANGE_CNT (Y );
1115- int data [pixel_cnt ], shades [pixel_cnt ];
1116- const struct crosshair_chars * chars ;
1117- struct crosshair_chars chars_curses ;
1118- char status [50 ], * status_ptr = NULL ;
1119-
1120- eye_graph_data (X , Y , pixels , data , shades );
1121-
1122- if (ch ) {
1123- if (fmt == FMT_CURSES ) {
1124- graph_init ();
1125- chars_curses .hline = GRAPH_HLINE ;
1126- chars_curses .vline = GRAPH_VLINE ;
1127- chars_curses .plus = GRAPH_PLUS ;
1128- chars = & chars_curses ;
1129- } else {
1130- chars = crosshair_text_chars ();
1131- }
1132-
1133- crosshair_plot (X , Y , data , shades , ch , chars );
1134-
1135- sprintf (status , " W2H=%d" , crosshair_w2h (ch ));
1136- status_ptr = status ;
1137- }
1138-
1139- if (fmt == FMT_TEXT ) {
1140- graph_draw_text (X , Y , data , title , 'T' , 'V' );
1141- if (status_ptr )
1142- printf ("\n %s\n" , status_ptr );
1143- return 0 ;
1101+
1102+ if (!ret )
1103+ {
1104+ eye_plot_graph (eye_data );
11441105 }
1145-
1146- return graph_draw_win (X , Y , data , shades , title , 'T' , 'V' ,
1147- status_ptr , NULL , NULL );
1106+
1107+ return 0 ;
11481108}
11491109
11501110#define CMD_DESC_EYE "Capture PCIe Eye Errors"
@@ -1156,14 +1116,14 @@ static int eye(int argc, char **argv)
11561116 static struct {
11571117 struct switchtec_dev * dev ;
11581118 int fmt ;
1159- int port_id ;
11601119 int lane_id ;
1120+ unsigned int error_threshold ;
11611121 int t_step , v_step ;
11621122 } cfg = {
11631123 .fmt = FMT_DEFAULT ,
1164- .port_id = -1 ,
11651124 .lane_id = 0 ,
11661125 .t_step = 1 ,
1126+ .error_threshold = 4 ,
11671127 .v_step = 1 ,
11681128 };
11691129 const struct argconfig_options opts [] = {
@@ -1173,8 +1133,8 @@ static int eye(int argc, char **argv)
11731133 .choices = output_fmt_choices },
11741134 {"lane" , 'l' , "LANE_ID" , CFG_NONNEGATIVE , & cfg .lane_id ,
11751135 required_argument , "lane id within the port to observe" },
1176- { "port " , 'p' , "PORT_ID" , CFG_NONNEGATIVE , & cfg .port_id ,
1177- required_argument , "physical port ID to observe " },
1136+ { "error threshold " , 't' , "ERROR THRESHOLD" , CFG_NONNEGATIVE , & cfg .error_threshold ,
1137+ optional_argument , "Maximum allowed errors " },
11781138 {"t-step" , 's' , "NUM" , CFG_NONNEGATIVE , & cfg .t_step ,
11791139 required_argument , "time step (default 1)" },
11801140 {"v-step" , 'S' , "NUM" , CFG_NONNEGATIVE , & cfg .v_step ,
@@ -1184,7 +1144,7 @@ static int eye(int argc, char **argv)
11841144 argconfig_parse (argc , argv , CMD_DESC_EYE , opts , & cfg ,
11851145 sizeof (cfg ));
11861146
1187- ret = eye_observe_dev (cfg .dev , cfg .port_id , cfg .lane_id , & gen );
1147+ ret = eye_observe_dev (cfg .dev , cfg .lane_id , cfg .error_threshold , & gen );
11881148
11891149 return ret ;
11901150}
0 commit comments