Skip to content

Commit 86f255e

Browse files
committed
Add support for Gen5 pattern mon/gen
Add support for the MRPC pattern generator and monitor set/get commands. Sets the sub command ID to the correct version depending on gen. New command line arg with the pattern gen function for the link speed that the pattern generator command needs in the gen5 spec.
1 parent 52aa171 commit 86f255e

File tree

4 files changed

+58
-14
lines changed

4 files changed

+58
-14
lines changed

cli/diag.c

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1713,6 +1713,14 @@ static const struct argconfig_choice pattern_types[] = {
17131713
{}
17141714
};
17151715

1716+
static const struct argconfig_choice pat_gen_link_speeds[] = {
1717+
{"GEN1", SWITCHTEC_DIAG_PAT_LINK_GEN1, "GEN1 Pattern Generator Speed"},
1718+
{"GEN2", SWITCHTEC_DIAG_PAT_LINK_GEN2, "GEN2 Pattern Generator Speed"},
1719+
{"GEN3", SWITCHTEC_DIAG_PAT_LINK_GEN3, "GEN3 Pattern Generator Speed"},
1720+
{"GEN4", SWITCHTEC_DIAG_PAT_LINK_GEN4, "GEN4 Pattern Generator Speed"},
1721+
{"GEN5", SWITCHTEC_DIAG_PAT_LINK_GEN5, "GEN5 Pattern Generator Speed"},
1722+
};
1723+
17161724
static const char *pattern_to_str(enum switchtec_diag_pattern type)
17171725
{
17181726
const struct argconfig_choice *s;
@@ -1738,7 +1746,8 @@ static int print_pattern_mode(struct switchtec_dev *dev,
17381746
return -1;
17391747
}
17401748

1741-
ret = switchtec_diag_pattern_mon_get(dev, port_id, 0, &mon_pat, &err_cnt);
1749+
ret = switchtec_diag_pattern_mon_get(dev, port_id, 0, &mon_pat,
1750+
&err_cnt);
17421751
if (ret) {
17431752
switchtec_perror("pattern_mon_get");
17441753
return -1;
@@ -1758,12 +1767,18 @@ static int print_pattern_mode(struct switchtec_dev *dev,
17581767
for (lane_id = 1; lane_id < port->cfg_lnk_width; lane_id++) {
17591768
ret = switchtec_diag_pattern_mon_get(dev, port_id,
17601769
lane_id, NULL, &err_cnt);
1761-
printf(" Lane %-2d Errors: 0x%llx\n", lane_id,
1762-
err_cnt);
1763-
if (ret) {
1770+
if (ret == 0x70b02) {
1771+
printf(" Lane %d has the pattern monitor disabled.\n",
1772+
lane_id);
1773+
}
1774+
else if (ret) {
17641775
switchtec_perror("pattern_mon_get");
17651776
return -1;
17661777
}
1778+
else {
1779+
printf(" Lane %-2d Errors: 0x%llx\n",
1780+
lane_id, err_cnt);
1781+
}
17671782
}
17681783
}
17691784

@@ -1785,7 +1800,9 @@ static int pattern(int argc, char **argv)
17851800
int monitor;
17861801
int pattern;
17871802
int inject_errs;
1803+
int link_speed;
17881804
} cfg = {
1805+
.link_speed = SWITCHTEC_DIAG_PAT_LINK_DISABLED,
17891806
.port_id = -1,
17901807
.pattern = SWITCHTEC_DIAG_PATTERN_PRBS_31,
17911808
};
@@ -1807,6 +1824,10 @@ static int pattern(int argc, char **argv)
18071824
required_argument,
18081825
"pattern to generate or monitor for (default: PRBS31)",
18091826
.choices = pattern_types},
1827+
{"speed", 's', "SPEED", CFG_CHOICES, &cfg.link_speed,
1828+
required_argument,
1829+
"link speed that applies to the pattern generator (default: GEN1)",
1830+
.choices = pat_gen_link_speeds},
18101831
{NULL}};
18111832

18121833
argconfig_parse(argc, argv, CMD_DESC_PATTERN, opts, &cfg, sizeof(cfg));
@@ -1822,6 +1843,12 @@ static int pattern(int argc, char **argv)
18221843
return -1;
18231844
}
18241845

1846+
if (cfg.link_speed && cfg.monitor) {
1847+
fprintf (stderr,
1848+
"Cannot enable link speed -s / --speed on pattern monitor\n");
1849+
return -1;
1850+
}
1851+
18251852
ret = get_port(cfg.dev, cfg.port_id, &cfg.port);
18261853
if (ret)
18271854
return ret;
@@ -1843,7 +1870,7 @@ static int pattern(int argc, char **argv)
18431870

18441871
if (cfg.generate) {
18451872
ret = switchtec_diag_pattern_gen_set(cfg.dev, cfg.port_id,
1846-
cfg.pattern);
1873+
cfg.pattern, cfg.link_speed);
18471874
if (ret) {
18481875
switchtec_perror("pattern_gen_set");
18491876
return -1;

inc/switchtec/mrpc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ enum mrpc_sub_cmd {
273273
MRPC_PAT_GEN_GET_MON = 7,
274274
MRPC_PAT_GEN_SET_MON = 8,
275275
MRPC_PAT_GEN_INJ_ERR = 9,
276+
MRPC_PAT_GEN_SET_GEN_GEN5 = 10,
276277

277278
MRPC_EYE_OBSERVE_START = 0,
278279
MRPC_EYE_OBSERVE_FETCH = 1,

inc/switchtec/switchtec.h

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1284,6 +1284,15 @@ enum switchtec_diag_pattern {
12841284
SWITCHTEC_DIAG_PATTERN_PRBS_DISABLED,
12851285
};
12861286

1287+
enum switchtec_diag_pattern_link_rate {
1288+
SWITCHTEC_DIAG_PAT_LINK_DISABLED = 0,
1289+
SWITCHTEC_DIAG_PAT_LINK_GEN1 = 1,
1290+
SWITCHTEC_DIAG_PAT_LINK_GEN2 = 2,
1291+
SWITCHTEC_DIAG_PAT_LINK_GEN3 = 3,
1292+
SWITCHTEC_DIAG_PAT_LINK_GEN4 = 4,
1293+
SWITCHTEC_DIAG_PAT_LINK_GEN5 = 5,
1294+
};
1295+
12871296
enum switchtec_diag_ltssm_speed {
12881297
SWITCHTEC_DIAG_LTSSM_GEN1 = 0,
12891298
SWITCHTEC_DIAG_LTSSM_GEN2 = 1,
@@ -1341,14 +1350,17 @@ int switchtec_diag_loopback_get(struct switchtec_dev *dev, int port_id,
13411350
int *enabled,
13421351
enum switchtec_diag_ltssm_speed *ltssm_speed);
13431352
int switchtec_diag_pattern_gen_set(struct switchtec_dev *dev, int port_id,
1344-
enum switchtec_diag_pattern type);
1353+
enum switchtec_diag_pattern type,
1354+
enum switchtec_diag_pattern_link_rate
1355+
link_speed);
13451356
int switchtec_diag_pattern_gen_get(struct switchtec_dev *dev, int port_id,
1346-
enum switchtec_diag_pattern *type);
1357+
enum switchtec_diag_pattern *type);
13471358
int switchtec_diag_pattern_mon_set(struct switchtec_dev *dev, int port_id,
1348-
enum switchtec_diag_pattern type);
1359+
enum switchtec_diag_pattern type);
13491360
int switchtec_diag_pattern_mon_get(struct switchtec_dev *dev, int port_id,
1350-
int lane_id, enum switchtec_diag_pattern *type,
1351-
unsigned long long *err_cnt);
1361+
int lane_id,
1362+
enum switchtec_diag_pattern *type,
1363+
unsigned long long *err_cnt);
13521364
int switchtec_diag_pattern_inject(struct switchtec_dev *dev, int port_id,
13531365
unsigned int err_cnt);
13541366

lib/diag.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -635,13 +635,17 @@ int switchtec_diag_loopback_get(struct switchtec_dev *dev,
635635
* @return 0 on success, error code on failure
636636
*/
637637
int switchtec_diag_pattern_gen_set(struct switchtec_dev *dev, int port_id,
638-
enum switchtec_diag_pattern type)
638+
enum switchtec_diag_pattern type,
639+
enum switchtec_diag_pattern_link_rate link_speed)
639640
{
640641
struct switchtec_diag_pat_gen_in in = {
641642
.sub_cmd = MRPC_PAT_GEN_SET_GEN,
642643
.port_id = port_id,
643644
.pattern_type = type,
645+
.lane_id = link_speed
644646
};
647+
if (switchtec_is_gen5(dev))
648+
in.sub_cmd = MRPC_PAT_GEN_SET_GEN_GEN5;
645649

646650
return switchtec_cmd(dev, MRPC_PAT_GEN, &in, sizeof(in), NULL, 0);
647651
}
@@ -655,7 +659,7 @@ int switchtec_diag_pattern_gen_set(struct switchtec_dev *dev, int port_id,
655659
* @return 0 on success, error code on failure
656660
*/
657661
int switchtec_diag_pattern_gen_get(struct switchtec_dev *dev, int port_id,
658-
enum switchtec_diag_pattern *type)
662+
enum switchtec_diag_pattern *type)
659663
{
660664
struct switchtec_diag_pat_gen_in in = {
661665
.sub_cmd = MRPC_PAT_GEN_GET_GEN,
@@ -705,8 +709,8 @@ int switchtec_diag_pattern_mon_set(struct switchtec_dev *dev, int port_id,
705709
* @return 0 on success, error code on failure
706710
*/
707711
int switchtec_diag_pattern_mon_get(struct switchtec_dev *dev, int port_id,
708-
int lane_id, enum switchtec_diag_pattern *type,
709-
unsigned long long *err_cnt)
712+
int lane_id, enum switchtec_diag_pattern *type,
713+
unsigned long long *err_cnt)
710714
{
711715
struct switchtec_diag_pat_gen_in in = {
712716
.sub_cmd = MRPC_PAT_GEN_GET_MON,

0 commit comments

Comments
 (0)