Skip to content

Commit aa9ddaa

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 2f980a4 commit aa9ddaa

File tree

4 files changed

+52
-10
lines changed

4 files changed

+52
-10
lines changed

cli/diag.c

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1769,6 +1769,14 @@ static const struct argconfig_choice pattern_types[] = {
17691769
{}
17701770
};
17711771

1772+
static const struct argconfig_choice pat_gen_link_speeds[] = {
1773+
{"GEN1", SWITCHTEC_DIAG_PAT_LINK_GEN1, "GEN1 Pattern Generator Speed"},
1774+
{"GEN2", SWITCHTEC_DIAG_PAT_LINK_GEN2, "GEN2 Pattern Generator Speed"},
1775+
{"GEN3", SWITCHTEC_DIAG_PAT_LINK_GEN3, "GEN3 Pattern Generator Speed"},
1776+
{"GEN4", SWITCHTEC_DIAG_PAT_LINK_GEN4, "GEN4 Pattern Generator Speed"},
1777+
{"GEN5", SWITCHTEC_DIAG_PAT_LINK_GEN5, "GEN5 Pattern Generator Speed"},
1778+
};
1779+
17721780
static const char *pattern_to_str(enum switchtec_diag_pattern type)
17731781
{
17741782
const struct argconfig_choice *s;
@@ -1794,7 +1802,8 @@ static int print_pattern_mode(struct switchtec_dev *dev,
17941802
return -1;
17951803
}
17961804

1797-
ret = switchtec_diag_pattern_mon_get(dev, port_id, 0, &mon_pat, &err_cnt);
1805+
ret = switchtec_diag_pattern_mon_get(dev, port_id, 0, &mon_pat,
1806+
&err_cnt);
17981807
if (ret) {
17991808
switchtec_perror("pattern_mon_get");
18001809
return -1;
@@ -1814,12 +1823,18 @@ static int print_pattern_mode(struct switchtec_dev *dev,
18141823
for (lane_id = 1; lane_id < port->cfg_lnk_width; lane_id++) {
18151824
ret = switchtec_diag_pattern_mon_get(dev, port_id,
18161825
lane_id, NULL, &err_cnt);
1817-
printf(" Lane %-2d Errors: 0x%llx\n", lane_id,
1818-
err_cnt);
1819-
if (ret) {
1826+
if (ret == 0x70b02) {
1827+
printf(" Lane %d has the pattern monitor disabled.\n",
1828+
lane_id);
1829+
}
1830+
else if (ret) {
18201831
switchtec_perror("pattern_mon_get");
18211832
return -1;
18221833
}
1834+
else {
1835+
printf(" Lane %-2d Errors: 0x%llx\n",
1836+
lane_id, err_cnt);
1837+
}
18231838
}
18241839
}
18251840

@@ -1841,7 +1856,9 @@ static int pattern(int argc, char **argv)
18411856
int monitor;
18421857
int pattern;
18431858
int inject_errs;
1859+
int link_speed;
18441860
} cfg = {
1861+
.link_speed = SWITCHTEC_DIAG_PAT_LINK_DISABLED,
18451862
.port_id = -1,
18461863
.pattern = SWITCHTEC_DIAG_PATTERN_PRBS_31,
18471864
};
@@ -1863,6 +1880,10 @@ static int pattern(int argc, char **argv)
18631880
required_argument,
18641881
"pattern to generate or monitor for (default: PRBS31)",
18651882
.choices = pattern_types},
1883+
{"speed", 's', "SPEED", CFG_CHOICES, &cfg.link_speed,
1884+
required_argument,
1885+
"link speed that applies to the pattern generator (default: GEN1)",
1886+
.choices = pat_gen_link_speeds},
18661887
{NULL}};
18671888

18681889
argconfig_parse(argc, argv, CMD_DESC_PATTERN, opts, &cfg, sizeof(cfg));
@@ -1878,6 +1899,12 @@ static int pattern(int argc, char **argv)
18781899
return -1;
18791900
}
18801901

1902+
if (cfg.link_speed && cfg.monitor) {
1903+
fprintf (stderr,
1904+
"Cannot enable link speed -s / --speed on pattern monitor\n");
1905+
return -1;
1906+
}
1907+
18811908
ret = get_port(cfg.dev, cfg.port_id, &cfg.port);
18821909
if (ret)
18831910
return ret;
@@ -1899,7 +1926,7 @@ static int pattern(int argc, char **argv)
18991926

19001927
if (cfg.generate) {
19011928
ret = switchtec_diag_pattern_gen_set(cfg.dev, cfg.port_id,
1902-
cfg.pattern);
1929+
cfg.pattern, cfg.link_speed);
19031930
if (ret) {
19041931
switchtec_perror("pattern_gen_set");
19051932
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: 11 additions & 1 deletion
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,
@@ -1338,7 +1347,8 @@ int switchtec_diag_loopback_set_gen5(struct switchtec_dev *dev, int port_id,
13381347
int switchtec_diag_loopback_get(struct switchtec_dev *dev, int port_id,
13391348
int *enabled, enum switchtec_diag_ltssm_speed *ltssm_speed);
13401349
int switchtec_diag_pattern_gen_set(struct switchtec_dev *dev, int port_id,
1341-
enum switchtec_diag_pattern type);
1350+
enum switchtec_diag_pattern type,
1351+
enum switchtec_diag_pattern_link_rate link_speed);
13421352
int switchtec_diag_pattern_gen_get(struct switchtec_dev *dev, int port_id,
13431353
enum switchtec_diag_pattern *type);
13441354
int switchtec_diag_pattern_mon_set(struct switchtec_dev *dev, int port_id,

lib/diag.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -524,13 +524,17 @@ int switchtec_diag_loopback_get(struct switchtec_dev *dev,
524524
* @return 0 on success, error code on failure
525525
*/
526526
int switchtec_diag_pattern_gen_set(struct switchtec_dev *dev, int port_id,
527-
enum switchtec_diag_pattern type)
527+
enum switchtec_diag_pattern type,
528+
enum switchtec_diag_pattern_link_rate link_speed)
528529
{
529530
struct switchtec_diag_pat_gen_in in = {
530531
.sub_cmd = MRPC_PAT_GEN_SET_GEN,
531532
.port_id = port_id,
532533
.pattern_type = type,
534+
.lane_id = link_speed
533535
};
536+
if (switchtec_is_gen5(dev))
537+
in.sub_cmd = MRPC_PAT_GEN_SET_GEN_GEN5;
534538

535539
return switchtec_cmd(dev, MRPC_PAT_GEN, &in, sizeof(in), NULL, 0);
536540
}
@@ -544,7 +548,7 @@ int switchtec_diag_pattern_gen_set(struct switchtec_dev *dev, int port_id,
544548
* @return 0 on success, error code on failure
545549
*/
546550
int switchtec_diag_pattern_gen_get(struct switchtec_dev *dev, int port_id,
547-
enum switchtec_diag_pattern *type)
551+
enum switchtec_diag_pattern *type)
548552
{
549553
struct switchtec_diag_pat_gen_in in = {
550554
.sub_cmd = MRPC_PAT_GEN_GET_GEN,
@@ -594,8 +598,8 @@ int switchtec_diag_pattern_mon_set(struct switchtec_dev *dev, int port_id,
594598
* @return 0 on success, error code on failure
595599
*/
596600
int switchtec_diag_pattern_mon_get(struct switchtec_dev *dev, int port_id,
597-
int lane_id, enum switchtec_diag_pattern *type,
598-
unsigned long long *err_cnt)
601+
int lane_id, enum switchtec_diag_pattern *type,
602+
unsigned long long *err_cnt)
599603
{
600604
struct switchtec_diag_pat_gen_in in = {
601605
.sub_cmd = MRPC_PAT_GEN_GET_MON,

0 commit comments

Comments
 (0)