Skip to content

Commit f91084e

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 f0aed95 commit f91084e

File tree

4 files changed

+56
-14
lines changed

4 files changed

+56
-14
lines changed

cli/diag.c

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

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

1742-
ret = switchtec_diag_pattern_mon_get(dev, port_id, 0, &mon_pat, &err_cnt);
1750+
ret = switchtec_diag_pattern_mon_get(dev, port_id, 0, &mon_pat,
1751+
&err_cnt);
17431752
if (ret) {
17441753
switchtec_perror("pattern_mon_get");
17451754
return -1;
@@ -1759,11 +1768,15 @@ static int print_pattern_mode(struct switchtec_dev *dev,
17591768
for (lane_id = 1; lane_id < port->cfg_lnk_width; lane_id++) {
17601769
ret = switchtec_diag_pattern_mon_get(dev, port_id,
17611770
lane_id, NULL, &err_cnt);
1762-
printf(" Lane %-2d Errors: 0x%llx\n", lane_id,
1763-
err_cnt);
1764-
if (ret) {
1771+
if (ret == 0x70b02) {
1772+
printf(" Lane %d has the pattern monitor disabled.\n",
1773+
lane_id);
1774+
} else if (ret) {
17651775
switchtec_perror("pattern_mon_get");
17661776
return -1;
1777+
} else {
1778+
printf(" Lane %-2d Errors: 0x%llx\n",
1779+
lane_id, err_cnt);
17671780
}
17681781
}
17691782
}
@@ -1786,7 +1799,9 @@ static int pattern(int argc, char **argv)
17861799
int monitor;
17871800
int pattern;
17881801
int inject_errs;
1802+
int link_speed;
17891803
} cfg = {
1804+
.link_speed = SWITCHTEC_DIAG_PAT_LINK_DISABLED,
17901805
.port_id = -1,
17911806
.pattern = SWITCHTEC_DIAG_PATTERN_PRBS_31,
17921807
};
@@ -1808,6 +1823,10 @@ static int pattern(int argc, char **argv)
18081823
required_argument,
18091824
"pattern to generate or monitor for (default: PRBS31)",
18101825
.choices = pattern_types},
1826+
{"speed", 's', "SPEED", CFG_CHOICES, &cfg.link_speed,
1827+
required_argument,
1828+
"link speed that applies to the pattern generator (default: GEN1)",
1829+
.choices = pat_gen_link_speeds},
18111830
{NULL}};
18121831

18131832
argconfig_parse(argc, argv, CMD_DESC_PATTERN, opts, &cfg, sizeof(cfg));
@@ -1823,6 +1842,12 @@ static int pattern(int argc, char **argv)
18231842
return -1;
18241843
}
18251844

1845+
if (cfg.link_speed && cfg.monitor) {
1846+
fprintf(stderr,
1847+
"Cannot enable link speed -s / --speed on pattern monitor\n");
1848+
return -1;
1849+
}
1850+
18261851
ret = get_port(cfg.dev, cfg.port_id, &cfg.port);
18271852
if (ret)
18281853
return ret;
@@ -1844,7 +1869,7 @@ static int pattern(int argc, char **argv)
18441869

18451870
if (cfg.generate) {
18461871
ret = switchtec_diag_pattern_gen_set(cfg.dev, cfg.port_id,
1847-
cfg.pattern);
1872+
cfg.pattern, cfg.link_speed);
18481873
if (ret) {
18491874
switchtec_perror("pattern_gen_set");
18501875
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
@@ -633,13 +633,17 @@ int switchtec_diag_loopback_get(struct switchtec_dev *dev,
633633
* @return 0 on success, error code on failure
634634
*/
635635
int switchtec_diag_pattern_gen_set(struct switchtec_dev *dev, int port_id,
636-
enum switchtec_diag_pattern type)
636+
enum switchtec_diag_pattern type,
637+
enum switchtec_diag_pattern_link_rate link_speed)
637638
{
638639
struct switchtec_diag_pat_gen_in in = {
639640
.sub_cmd = MRPC_PAT_GEN_SET_GEN,
640641
.port_id = port_id,
641642
.pattern_type = type,
643+
.lane_id = link_speed
642644
};
645+
if (switchtec_is_gen5(dev))
646+
in.sub_cmd = MRPC_PAT_GEN_SET_GEN_GEN5;
643647

644648
return switchtec_cmd(dev, MRPC_PAT_GEN, &in, sizeof(in), NULL, 0);
645649
}
@@ -653,7 +657,7 @@ int switchtec_diag_pattern_gen_set(struct switchtec_dev *dev, int port_id,
653657
* @return 0 on success, error code on failure
654658
*/
655659
int switchtec_diag_pattern_gen_get(struct switchtec_dev *dev, int port_id,
656-
enum switchtec_diag_pattern *type)
660+
enum switchtec_diag_pattern *type)
657661
{
658662
struct switchtec_diag_pat_gen_in in = {
659663
.sub_cmd = MRPC_PAT_GEN_GET_GEN,
@@ -703,8 +707,8 @@ int switchtec_diag_pattern_mon_set(struct switchtec_dev *dev, int port_id,
703707
* @return 0 on success, error code on failure
704708
*/
705709
int switchtec_diag_pattern_mon_get(struct switchtec_dev *dev, int port_id,
706-
int lane_id, enum switchtec_diag_pattern *type,
707-
unsigned long long *err_cnt)
710+
int lane_id, enum switchtec_diag_pattern *type,
711+
unsigned long long *err_cnt)
708712
{
709713
struct switchtec_diag_pat_gen_in in = {
710714
.sub_cmd = MRPC_PAT_GEN_GET_MON,

0 commit comments

Comments
 (0)