Skip to content

Commit 0190760

Browse files
committed
fix nits and format issues
remove duplicate tlp_inject command Comment Changes: Multiple additional formatting changes 80 char limit
1 parent d51e282 commit 0190760

7 files changed

Lines changed: 181 additions & 130 deletions

File tree

cli/diag.c

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1323,10 +1323,9 @@ static int switchtec_gen5_diag_eye_read(struct switchtec_dev *dev, int lane_id,
13231323
return ret;
13241324
}
13251325

1326-
/*Gen5 eye capture logic*/
13271326
static double *eye_capture_dev_gen5(struct switchtec_dev *dev,
1328-
int port_id, int lane_id, int num_lanes,
1329-
int capture_depth, int* num_phases, int* gen)
1327+
int port_id, int lane_id, int num_lanes,
1328+
int capture_depth, int* num_phases, int* gen)
13301329
{
13311330
int bin, j, ret, eye_status, first_lane, num_phases_l, stride;
13321331
int lane_mask[4] = {};
@@ -1345,7 +1344,8 @@ static double *eye_capture_dev_gen5(struct switchtec_dev *dev,
13451344
return NULL;
13461345
}
13471346

1348-
ret = switchtec_diag_eye_start(dev, lane_mask, NULL, NULL, 0, capture_depth);
1347+
ret = switchtec_diag_eye_start(dev, lane_mask, NULL, NULL, 0,
1348+
capture_depth);
13491349
if (ret) {
13501350
switchtec_perror("eye_run");
13511351
return NULL;
@@ -1378,8 +1378,8 @@ static double *eye_capture_dev_gen5(struct switchtec_dev *dev,
13781378
first_lane = switchtec_calc_lane_id(dev, port_id, lane_id, NULL);
13791379
for (j = 0; j < num_lanes; j++) {
13801380
for (bin = 0; bin < 64; bin++) {
1381-
ret = switchtec_gen5_diag_eye_read(dev, first_lane + j, bin,
1382-
&num_phases_l, tmp);
1381+
ret = switchtec_gen5_diag_eye_read(dev, first_lane + j,
1382+
bin, &num_phases_l, tmp);
13831383
if (ret) {
13841384
switchtec_perror("eye_read");
13851385
if (ber_data)
@@ -1389,15 +1389,16 @@ static double *eye_capture_dev_gen5(struct switchtec_dev *dev,
13891389

13901390
if (!ber_data) {
13911391
stride = 64 * num_phases_l;
1392-
ber_data = calloc(num_lanes * stride, sizeof(double));
1392+
ber_data = calloc(num_lanes * stride,
1393+
sizeof(double));
13931394
if (!ber_data) {
13941395
perror("allocating BER data");
13951396
return NULL;
13961397
}
13971398
}
13981399

1399-
memcpy(&ber_data[(j * stride) + (bin * num_phases_l)], tmp,
1400-
num_phases_l * sizeof(double));
1400+
memcpy(&ber_data[(j * stride) + (bin * num_phases_l)],
1401+
tmp, num_phases_l * sizeof(double));
14011402
}
14021403
}
14031404

@@ -1607,6 +1608,7 @@ static const struct argconfig_choice loopback_ltssm_speeds[] = {
16071608
{"GEN3", SWITCHTEC_DIAG_LTSSM_GEN3, "GEN3 LTSSM Speed"},
16081609
{"GEN4", SWITCHTEC_DIAG_LTSSM_GEN4, "GEN4 LTSSM Speed"},
16091610
{"GEN5", SWITCHTEC_DIAG_LTSSM_GEN5, "GEN5 LTSSM Speed"},
1611+
{}
16101612
};
16111613

16121614
static int print_loopback_mode(struct switchtec_dev *dev, int port_id)
@@ -1741,8 +1743,7 @@ static int loopback(int argc, char **argv)
17411743
ret = switchtec_diag_loopback_set_gen5(cfg.dev, cfg.port_id,
17421744
cfg.enable_parallel, cfg.enable_external,
17431745
cfg.enable_ltssm, cfg.speed);
1744-
}
1745-
else {
1746+
} else {
17461747
ret = switchtec_diag_loopback_set(cfg.dev, cfg.port_id,
17471748
enable, cfg.speed);
17481749
}
@@ -1798,7 +1799,8 @@ static int print_pattern_mode(struct switchtec_dev *dev,
17981799
return -1;
17991800
}
18001801

1801-
ret = switchtec_diag_pattern_mon_get(dev, port_id, 0, &mon_pat, &err_cnt);
1802+
ret = switchtec_diag_pattern_mon_get(dev, port_id, 0, &mon_pat,
1803+
&err_cnt);
18021804
if (ret) {
18031805
switchtec_perror("pattern_mon_get");
18041806
return -1;
@@ -1819,15 +1821,16 @@ static int print_pattern_mode(struct switchtec_dev *dev,
18191821
ret = switchtec_diag_pattern_mon_get(dev, port_id,
18201822
lane_id, NULL, &err_cnt);
18211823
if (ret == 0x70b02) {
1822-
printf(" Lane %d has the pattern monitor disabled.\n", lane_id);
1824+
printf(" Lane %d has the pattern monitor disabled.\n",
1825+
lane_id);
18231826
}
18241827
else if (ret) {
18251828
switchtec_perror("pattern_mon_get");
18261829
return -1;
18271830
}
18281831
else {
1829-
printf(" Lane %-2d Errors: 0x%llx\n", lane_id,
1830-
err_cnt);
1832+
printf(" Lane %-2d Errors: 0x%llx\n",
1833+
lane_id, err_cnt);
18311834
}
18321835
}
18331836
}
@@ -1993,7 +1996,7 @@ static int port_eq_txcoeff(int argc, char **argv)
19931996
int i, ret;
19941997

19951998
const struct argconfig_options opts[] = {
1996-
DEVICE_OPTION, FAR_END_OPTION, PORT_OPTION, PREV_OPTION, {NULL}
1999+
DEVICE_OPTION, FAR_END_OPTION, PORT_OPTION, PREV_OPTION, {}
19972000
};
19982001

19992002
ret = diag_parse_common_cfg(argc, argv, CMD_DESC_PORT_EQ_TXCOEFF,
@@ -2418,7 +2421,8 @@ static int linkerr_inject(int argc, char ** argv)
24182421
{NULL}
24192422
};
24202423

2421-
argconfig_parse(argc, argv, CMD_DESC_LNKERR_INJECT, opts, &cfg, sizeof(cfg));
2424+
argconfig_parse(argc, argv, CMD_DESC_LNKERR_INJECT, opts, &cfg,
2425+
sizeof(cfg));
24222426

24232427
uint8_t *ptr = (uint8_t *)&cfg + 5;
24242428
int total_en = 0;
@@ -2469,22 +2473,24 @@ static int linkerr_inject(int argc, char ** argv)
24692473

24702474
if (cfg.inject_dllp) {
24712475
ret = switchtec_inject_err_dllp(cfg.dev, cfg.phy_port,
2472-
cfg.dllp_data != NULL ? *dllp_data_dword : 0);
2476+
cfg.dllp_data != NULL ? *dllp_data_dword : 0);
24732477
free(dllp_data_dword);
24742478
}
24752479
if (cfg.inject_dllp_crc) {
24762480
if (cfg.dllp_rate > 4096) {
24772481
fprintf(stderr, "DLLP CRC rate out of range. Valid range is 0-4095.\n");
24782482
return -1;
24792483
}
2480-
ret = switchtec_inject_err_dllp_crc(cfg.dev, cfg.phy_port, cfg.enable, cfg.dllp_rate);
2484+
ret = switchtec_inject_err_dllp_crc(cfg.dev, cfg.phy_port,
2485+
cfg.enable, cfg.dllp_rate);
24812486
}
24822487
if (cfg.inject_tlp_lcrc) {
24832488
if (cfg.tlp_rate > 7) {
24842489
fprintf(stderr, "TLP LCRC rate out of range. Valid range is 0-7.\n");
24852490
return -1;
24862491
}
2487-
ret = switchtec_inject_err_tlp_lcrc(cfg.dev, cfg.phy_port, cfg.enable, cfg.tlp_rate);
2492+
ret = switchtec_inject_err_tlp_lcrc(cfg.dev, cfg.phy_port,
2493+
cfg.enable, cfg.tlp_rate);
24882494
if (ret)
24892495
return -1;
24902496
}
@@ -2499,7 +2505,8 @@ static int linkerr_inject(int argc, char ** argv)
24992505
fprintf(stderr, "Count out of range. Valid range is 0-255\n");
25002506
return -1;
25012507
}
2502-
ret = switchtec_inject_err_ack_nack(cfg.dev, cfg.phy_port, cfg.seq_num, cfg.count);
2508+
ret = switchtec_inject_err_ack_nack(cfg.dev, cfg.phy_port,
2509+
cfg.seq_num, cfg.count);
25032510
}
25042511
if (cfg.inject_cto) {
25052512
if (!switchtec_is_gen5(cfg.dev)) {
@@ -2528,7 +2535,6 @@ static const struct cmd commands[] = {
25282535
CMD(ltssm_log, CMD_DESC_LTSSM_LOG),
25292536
CMD(tlp_inject, CMD_TLP_INJECT),
25302537
CMD(aer_event_gen, CMD_DESC_AER_EVENT_GEN),
2531-
CMD(tlp_inject, CMD_TLP_INJECT),
25322538
CMD(linkerr_inject, CMD_DESC_LNKERR_INJECT),
25332539
{}
25342540
};

cli/graph.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -391,8 +391,9 @@ void graph_init(void)
391391
#endif /* defined(HAVE_LIBCURSES) || defined(HAVE_LIBNCURSES) */
392392

393393
int graph_draw_win_no_invert(struct range *X, struct range *Y, int *data,
394-
int *shades, const char *title, char x_title, char y_title,
395-
char *status, graph_anim_fn *anim, void *opaque)
394+
int *shades, const char *title, char x_title,
395+
char y_title, char *status, graph_anim_fn *anim,
396+
void *opaque)
396397
{
397398
graph_draw_text_no_invert(X, Y, data, title, x_title, y_title);
398399
return 0;
@@ -439,7 +440,8 @@ void graph_draw_text(struct range *X, struct range *Y, int *data,
439440
}
440441

441442
void graph_draw_text_no_invert(struct range *X, struct range *Y,
442-
int *data, const char *title, char x_title, char y_title)
443+
int *data, const char *title, char x_title,
444+
char y_title)
443445
{
444446
int stride = RANGE_CNT(X);
445447
int x, y, i = RANGE_CNT(Y) - 1;
@@ -461,7 +463,7 @@ void graph_draw_text_no_invert(struct range *X, struct range *Y,
461463
for_range(y, Y) {
462464
printf("%5d ", y);
463465
i = 0;
464-
for_range(x, X) {
466+
for_range(x, X) {
465467
space_ch = ' ';
466468
if (data[j * stride + i] == GRAPH_TEXT_HLINE ||
467469
data[j * stride + i] == GRAPH_TEXT_PLUS)

cli/graph.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,10 @@ int graph_draw_win(struct range *X, struct range *Y, int *data, int *shades,
6969
const char *title, char x_title, char y_title, char *status,
7070
graph_anim_fn *anim, void *opaque);
7171
void graph_draw_text_no_invert(struct range *X, struct range *Y,
72-
int *data, const char *title, char x_title, char y_title);
72+
int *data, const char *title, char x_title,
73+
char y_title);
7374
int graph_draw_win_no_invert(struct range *X, struct range *Y, int *data,
74-
int *shades, const char *title, char x_title, char y_title,
75-
char *status, graph_anim_fn *anim, void *opaque);
75+
int *shades, const char *title, char x_title,
76+
char y_title, char *status, graph_anim_fn *anim,
77+
void *opaque);
7678
#endif

inc/switchtec/diag.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -301,15 +301,10 @@ enum switchtec_aer_event_gen_result {
301301
};
302302

303303
struct switchtec_aer_event_gen_in {
304-
/** sub_cmd_id */
305304
uint8_t sub_cmd;
306-
/** physical port id */
307305
uint8_t phys_port_id;
308-
/** reserved */
309306
uint8_t reserved[2];
310-
/** err mask */
311307
uint32_t err_mask;
312-
/** HDR log */
313308
uint32_t hdr_log[4];
314309
};
315310

inc/switchtec/inject.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,27 @@
1+
/*
2+
* Microsemi Switchtec(tm) PCIe Management Library
3+
* Copyright (c) 2025, Microsemi Corporation
4+
*
5+
* Permission is hereby granted, free of charge, to any person obtaining a
6+
* copy of this software and associated documentation files (the "Software"),
7+
* to deal in the Software without restriction, including without limitation
8+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
9+
* and/or sell copies of the Software, and to permit persons to whom the
10+
* Software is furnished to do so, subject to the following conditions:
11+
*
12+
* The above copyright notice and this permission notice shall be included
13+
* in all copies or substantial portions of the Software.
14+
*
15+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16+
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
19+
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20+
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
21+
* OTHER DEALINGS IN THE SOFTWARE.
22+
*
23+
*/
24+
125
#include <switchtec/switchtec.h>
226
#include <stdint.h>
327

inc/switchtec/switchtec.h

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -430,14 +430,15 @@ int switchtec_calc_lane_mask(struct switchtec_dev *dev, int phys_port_id,
430430
*/
431431

432432
int switchtec_inject_err_dllp(struct switchtec_dev *dev, int phys_port_id,
433-
int data);
433+
int data);
434434
int switchtec_inject_err_dllp_crc(struct switchtec_dev *dev, int phys_port_id,
435-
int enable, uint16_t rate);
435+
int enable, uint16_t rate);
436436
int switchtec_inject_err_tlp_lcrc(struct switchtec_dev *dev, int phys_port_id,
437-
int enable, uint8_t rate);
438-
int switchtec_inject_err_tlp_seq_num(struct switchtec_dev *dev, int phys_port_id);
437+
int enable, uint8_t rate);
438+
int switchtec_inject_err_tlp_seq_num(struct switchtec_dev *dev,
439+
int phys_port_id);
439440
int switchtec_inject_err_ack_nack(struct switchtec_dev *dev, int phys_port_id,
440-
uint16_t seq_num, uint8_t count);
441+
uint16_t seq_num, uint8_t count);
441442
int switchtec_inject_err_cto(struct switchtec_dev *dev, int phys_port_id);
442443

443444
/**
@@ -1142,19 +1143,19 @@ struct switchtec_rem_port_eq_coeff {
11421143
};
11431144

11441145
enum lane_eq_dump_type_enum {
1145-
LANE_EQ_DUMP_TYPE_CURR, /**< current settings */
1146-
LANE_EQ_DUMP_TYPE_PREV, /**< previous link-up settings */
1147-
LANE_EQ_DUMP_TYPE_NUM /**< total number of dump types */
1146+
LANE_EQ_DUMP_TYPE_CURR, //!< Current settings
1147+
LANE_EQ_DUMP_TYPE_PREV, //!< Previous link-up settings
1148+
LANE_EQ_DUMP_TYPE_NUM //!< Total number of dump types
11481149
};
11491150

11501151
enum link_rate_enum {
1151-
PCIE_LINK_RATE_INV = 0, /**< invalid */
1152-
PCIE_LINK_RATE_GEN1 = 1, /**< Gen1, supports 2.5GT/s */
1153-
PCIE_LINK_RATE_GEN2 = 2, /**< Gen2, supports 2.5GT/s, 5GT/s */
1154-
PCIE_LINK_RATE_GEN3 = 3, /**< Gen3, supports 2.5GT/s, 5GT/s, 8GT/s */
1155-
PCIE_LINK_RATE_GEN4 = 4, /**< Gen4, supports 2.5GT/s, 5GT/s, 8GT/s, 16GT/s */
1156-
PCIE_LINK_RATE_GEN5 = 5, /**< Gen5, supports 2.5GT/s, 5GT/s, 8GT/s, 16GT/s, 32GT/s */
1157-
PCIE_LINK_RATE_NUM = 5 /**< total number of PCIe generations */
1152+
PCIE_LINK_RATE_INV = 0, //!< Invalid
1153+
PCIE_LINK_RATE_GEN1 = 1, //!< Gen1, supports 2.5GT/s
1154+
PCIE_LINK_RATE_GEN2 = 2, //!< Gen2, supports 2.5GT/s, 5GT/s
1155+
PCIE_LINK_RATE_GEN3 = 3, //!< Gen3, supports 2.5GT/s, 5GT/s, 8GT/s
1156+
PCIE_LINK_RATE_GEN4 = 4, //!< Gen4, supports 2.5GT/s, 5GT/s, 8GT/s, 16GT/s
1157+
PCIE_LINK_RATE_GEN5 = 5, //!< Gen5, supports 2.5GT/s, 5GT/s, 8GT/s, 16GT/s, 32GT/s
1158+
PCIE_LINK_RATE_NUM = 5 //!< Total number of PCIe generations
11581159
};
11591160

11601161
struct switchtec_port_eq_coeff_in {

0 commit comments

Comments
 (0)