Skip to content

Commit 9ddc82b

Browse files
committed
1. uart_util supports eeprom writing.
2. Fix a module risk for X312P-T.
1 parent 130fc56 commit 9ddc82b

File tree

9 files changed

+282
-53
lines changed

9 files changed

+282
-53
lines changed

drivers/include/bf_port_mgmt/bf_port_mgmt_intf.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,8 @@ void bf_pltfm_pm_qsfp_simulate_all_removed (void);
494494

495495
void qsfp_luxtera_lpbk (int conn_id,
496496
bool near_lpbk);
497+
void qsfp_luxtera_hipwr (int conn_id,
498+
bool is_cmis);
497499

498500
void bf_pm_qsfp_luxtera_state_capture (
499501
int conn_id, uint8_t arr_0x3k[0x3000]);

drivers/include/bf_qsfp/bf_qsfp.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ extern "C" {
5959
#define BF_TRANS_CTRLMASK_IGNORE_DPAPPLY_STATE (1 << 25)
6060
#define BF_TRANS_CTRLMASK_REQUIRE_HIGH_PWR_INIT (1 << 26)
6161
#define BF_TRANS_CTRLMASK_REQUIRE_SOFTWARE_RST (1 << 27)
62+
#define BF_TRANS_CTRLMASK_REQUIRE_HIGH_PWR_MODE (1 << 28)
6263

6364
/* Cached state for [q]sfp_info[port].trans_state.
6465
* To be clarified, the belowing runtime state will not be updated

drivers/src/bf_port_mgmt/bf_pm_qsfp_mgmt.c

Lines changed: 117 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1850,6 +1850,12 @@ static int qsfp_fsm_poll_los (bf_dev_id_t dev_id,
18501850
return -1;
18511851
}
18521852

1853+
// skip trigger quick removal action until everything goes right.
1854+
if (platform_type_equal(AFN_X312PT) &&
1855+
(bf_pltfm_mgr_ctx()->flags & AF_PLAT_CTRL_HA_MODE)) {
1856+
return 0;
1857+
}
1858+
18531859
// CPLD told us this module is absent.
18541860
// Donot move FSM until removal is hanlded
18551861
//if (!bf_qsfp_is_present (conn_id)) {
@@ -1879,10 +1885,23 @@ static int qsfp_fsm_poll_los (bf_dev_id_t dev_id,
18791885
}
18801886

18811887
if (rc) {
1888+
// skip trigger quick removal action and disable chassis monitor.
1889+
// requires maunally op via command chassis-ctrlmask-set if everything goes right.
1890+
// Query the QSFP library for the qsfp presence mask
1891+
if (platform_type_equal(AFN_X312PT)) {
1892+
uint32_t lower_mask, upper_mask, cpu_mask;
1893+
if (bf_qsfp_get_transceiver_pres (&lower_mask,
1894+
&upper_mask, &cpu_mask) != 0) {
1895+
bf_pltfm_mgr_ctx()->flags |= AF_PLAT_CTRL_HA_MODE;
1896+
return 0;
1897+
}
1898+
}
1899+
18821900
/* Added by tsihang, 2023-03-21. */
18831901
// Detect and latch the removal
18841902
// state, so that can qsfp-scan handle the rest.
1885-
if (!qsfp_state[conn_id].qsfp_quick_removed) {
1903+
if (!platform_type_equal(AFN_X312PT) &&
1904+
!qsfp_state[conn_id].qsfp_quick_removed) {
18861905
bool is_present = 0;
18871906
bf_qsfp_detect_transceiver (conn_id, &is_present);
18881907
if (!is_present) {
@@ -2295,12 +2314,13 @@ static void qsfp_module_fsm_run (bf_dev_id_t
22952314
}
22962315
qsfp_state[conn_id].qsfp_quick_removed = false;
22972316

2317+
// checks for QSFPs with "special" requirements
2318+
qsfp_fsm_identify_model_requirements (conn_id);
2319+
bf_qsfp_ctrlmask_get(conn_id, &ctrlmask);
2320+
22982321
if (is_optical) {
22992322
int ch;
23002323

2301-
// checks for QSFPs with "special" requirements
2302-
qsfp_fsm_identify_model_requirements (conn_id);
2303-
23042324
// set initial state for each of the 4 channel FSMs
23052325
for (ch = 0; ch < CHANNEL_COUNT; ch++) {
23062326
qsfp_state[conn_id].per_ch_fsm[ch] =
@@ -2313,6 +2333,12 @@ static void qsfp_module_fsm_run (bf_dev_id_t
23132333
} else {
23142334
LOG_WARNING ("QSFP %2d : NOT OPTICAL ...",
23152335
conn_id);
2336+
/* Trigger high power mode. */
2337+
if (ctrlmask & BF_TRANS_CTRLMASK_REQUIRE_HIGH_PWR_MODE) {
2338+
LOG_WARNING ("QSFP %2d : trigger high power mode for module ...",
2339+
conn_id);
2340+
qsfp_luxtera_hipwr (conn_id, bf_qsfp_is_cmis(conn_id));
2341+
}
23162342
if (bf_pm_intf_is_device_family_tofino(dev_id)) {
23172343
qsfp_fsm_notify_bf_pltfm (dev_id, conn_id);
23182344
}
@@ -4874,6 +4900,93 @@ void qsfp_luxtera_lpbk (int conn_id,
48744900
near_lpbk ? "NEAR/ELEC." : "FAR/OPTICAL");
48754901
}
48764902

4903+
/*****************************************************************
4904+
*
4905+
*****************************************************************/
4906+
void qsfp_luxtera_hipwr (int conn_id,
4907+
bool is_cmis)
4908+
{
4909+
uint8_t pwd[] = {0x00, 0x00, 0x10, 0x11};
4910+
uint8_t wr[] = {0x10, 0x10, 0x10, 0x00};
4911+
uint8_t rd[] = {0x00, 0x00, 0x00, 0x00};
4912+
uint8_t pwr_class = 0x08, output_enb = 0x01;
4913+
uint8_t pg0 = 0x0, pg2 = 0x2;
4914+
int rc;
4915+
4916+
if (!is_cmis) {
4917+
rc = bf_fsm_qsfp_wr2 (conn_id, pg0, 0x7b, 4, pwd);
4918+
if (rc) {
4919+
LOG_WARNING (
4920+
"QSFP %2d : Error <%d> Setting pwd for high power mode",
4921+
conn_id, rc);
4922+
return;
4923+
}
4924+
}
4925+
4926+
if (is_cmis) {
4927+
rc = bf_fsm_qsfp_wr2 (conn_id, pg0, 0xc8, 1,
4928+
&pwr_class);
4929+
} else {
4930+
rc = bf_fsm_qsfp_wr2 (conn_id, pg2, 0x8b, 1,
4931+
&output_enb);
4932+
rc = bf_fsm_qsfp_wr2 (conn_id, pg2, 0x82, 4,
4933+
wr);
4934+
}
4935+
if (rc) {
4936+
LOG_WARNING ("QSFP %2d : Error <%d> Setting high power mode",
4937+
conn_id,
4938+
rc);
4939+
return;
4940+
}
4941+
4942+
if (is_cmis) {
4943+
rc = bf_fsm_qsfp_rd2 (conn_id, pg0, 0xc8, 1, &rd[0]);
4944+
if (rc) {
4945+
LOG_WARNING ("QSFP %2d : Error <%d> Reading byte 0xC8 for high power mode",
4946+
conn_id,
4947+
rc);
4948+
return;
4949+
}
4950+
if (rd[0] != pwr_class) {
4951+
LOG_WARNING ("QSFP %2d : Error <%d> Setting byte 0xC8 for high power mode",
4952+
conn_id,
4953+
rc);
4954+
return;
4955+
}
4956+
} else {
4957+
rc = bf_fsm_qsfp_rd2 (conn_id, pg2, 0x8b, 1, &rd[0]);
4958+
if (rc) {
4959+
LOG_WARNING ("QSFP %2d : Error <%d> Reading byte 0x8B for high power mode",
4960+
conn_id,
4961+
rc);
4962+
return;
4963+
}
4964+
if (rd[0] != output_enb) {
4965+
LOG_WARNING ("QSFP %2d : Error <%d> Setting byte 0x8B for high power mode",
4966+
conn_id,
4967+
rc);
4968+
return;
4969+
}
4970+
rc = bf_fsm_qsfp_rd2 (conn_id, pg2, 0x82, 4, &rd[0]);
4971+
if (rc) {
4972+
LOG_WARNING ("QSFP %2d : Error <%d> Reading byte 0x8B for high power mode",
4973+
conn_id,
4974+
rc);
4975+
return;
4976+
}
4977+
if ((rd[0] != wr[0]) ||
4978+
(rd[1] != wr[1]) ||
4979+
(rd[2] != wr[2]) ||
4980+
(rd[3] != wr[3])) {
4981+
LOG_WARNING ("QSFP %2d : Error <%d> Setting byte 0x82-0x85 for high power mode",
4982+
conn_id,
4983+
rc);
4984+
return;
4985+
}
4986+
}
4987+
LOG_DEBUG ("QSFP %2d : High power mode set.", conn_id);
4988+
}
4989+
48774990
bool bf_pm_qsfp_is_luxtera (int conn_id)
48784991
{
48794992
if (qsfp_needs_hi_pwr_init (conn_id)) {

drivers/src/bf_port_mgmt/bf_pm_sfp_mgmt.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -455,8 +455,12 @@ static int sfp_fsm_poll_los (bf_dev_id_t dev_id,
455455
if (platform_type_equal(AFN_X312PT) &&
456456
1/* TBD, sfp_pres_mask is truely set */ &&
457457
1/* TBD, error occured during PCA9548*/) {
458-
bf_pltfm_mgr_ctx()->flags |= AF_PLAT_CTRL_HA_MODE;
459-
return 0;
458+
uint32_t lower_mask, upper_mask;
459+
if (bf_sfp_get_transceiver_pres (&lower_mask,
460+
&upper_mask) != 0) {
461+
bf_pltfm_mgr_ctx()->flags |= AF_PLAT_CTRL_HA_MODE;
462+
return 0;
463+
}
460464
}
461465
// Detect and latch the removal
462466
// state, so that can sfp-scan handle the rest.

drivers/src/bf_qsfp/bf_qsfp_cli.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3017,6 +3017,7 @@ static int bf_pltfm_ucli_ucli__qsfp_module_show (
30173017
"%-30s = ±%.3f nm\n",
30183018
"Wavelength tolerance",
30193019
tolerance);
3020+
aim_printf (&uc->pvs, "\n");
30203021
}
30213022
bool ctrl_flag, tune_flag;
30223023
/* returns the wavelength controllable and tramsmitter tunable flags */
@@ -4403,10 +4404,17 @@ bf_pltfm_ucli_ucli__qsfp_wavelength_get (
44034404

44044405
bool is_cmis = bf_qsfp_is_cmis (port);
44054406
bool is_passive_cu = bf_qsfp_is_passive_cu (port);
4407+
if (is_passive_cu) {
4408+
aim_printf (&uc->pvs,
4409+
"Wavelength not available for module on port %d\n",
4410+
port);
4411+
return 0;
4412+
}
4413+
44064414
aim_printf (&uc->pvs,
44074415
"====================\n");
44084416
aim_printf (&uc->pvs,
4409-
"Info for Wavelength:\n");
4417+
"Info for wavelength:\n");
44104418
aim_printf (&uc->pvs,
44114419
"====================\n");
44124420

@@ -4439,6 +4447,7 @@ bf_pltfm_ucli_ucli__qsfp_wavelength_get (
44394447
"%-21s = %s\n",
44404448
"Wavelength tunable",
44414449
(tune_flag ? "True" : "False"));
4450+
aim_printf (&uc->pvs, "\n");
44424451
}
44434452

44444453
if (tune_flag) {

platforms/asterfusion-bf/src/bf_pltfm_uart/bf_pltfm_uart.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ uart_send (struct bf_pltfm_uart_ctx_t *ctx,
312312
size_t l = 0;
313313
int rc = 0;
314314

315-
if ((tx_len > 2) && ( tx_len != 20)) {
315+
if ((tx_len > 2) && (cmd != 0x01) && (cmd != 0x0E)) {
316316
LOG_ERROR (
317317
"%s[%d], "
318318
"uart.send(%s)"
@@ -334,11 +334,19 @@ uart_send (struct bf_pltfm_uart_ctx_t *ctx,
334334
l = sprintf ((char *)&buf[0],
335335
"uart_0x%02x_0x%02x", cmd,
336336
tx_buf[0]);
337+
} else if ((tx_len == 2) && (cmd == 0x01) && (tx_buf[0] == 0x00) && (tx_buf[1] == 0x01)) {
338+
l = sprintf ((char *)&buf[0],
339+
"uart_0x%02x_0x%02x_0x%02x",
340+
cmd, tx_buf[0], tx_buf[1]);
341+
} else if ((tx_len == 2) && (cmd == 0x01) && (tx_buf[1] != 0xaa)) {
342+
l = sprintf ((char *)&buf[0],
343+
"uart_0x%02x_0x%02x_%s",
344+
cmd, tx_buf[0], &tx_buf[1]);
337345
} else if (tx_len == 2) {
338346
l = sprintf ((char *)&buf[0],
339347
"uart_0x%02x_0x%02x_0x%02x",
340348
cmd, tx_buf[0], tx_buf[1]);
341-
} else if (tx_len == 20) {
349+
} else {
342350
l = sprintf ((char *)&buf[0],
343351
"uart_0x%02x_0x%02x_%s",
344352
cmd, tx_buf[0], &tx_buf[1]);

platforms/asterfusion-bf/src/platform_mgr/platform_health_mntr.c

Lines changed: 8 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ static void bf_pltfm_onlp_mntr_transceiver()
410410
int module;
411411
int max_sfp_modules;
412412
int max_qsfp_modules;
413-
uint8_t buf[MAX_QSFP_PAGE_SIZE * 6] = {0};
413+
uint8_t buf[MAX_QSFP_PAGE_SIZE * 4] = {0};
414414
uint32_t flags = bf_pltfm_mgr_ctx()->flags;
415415

416416
struct qsfp_ctx_t *qsfp, *qsfp_ctx;
@@ -491,14 +491,6 @@ static void bf_pltfm_onlp_mntr_transceiver()
491491
}
492492
}
493493

494-
495-
/* Providing limited memory pages should be enough since
496-
the claim is only for DDM information.
497-
SFF8436 & SFF8636: LP00h + UP(00-03)h, 128 * 5
498-
CMIS: LM + P(00-04)h, 128 * 6
499-
Thus we need a buffer of at least size 128 * 6.
500-
By SunZheng, 2025/04/11.
501-
*/
502494
if (bf_qsfp_get_cached_info (i,
503495
QSFP_PAGE0_LOWER, buf)) {
504496
continue;
@@ -508,33 +500,13 @@ static void bf_pltfm_onlp_mntr_transceiver()
508500
buf + MAX_QSFP_PAGE_SIZE)) {
509501
continue;
510502
}
511-
if (bf_qsfp_get_cached_info (
512-
i, QSFP_PAGE1,
513-
buf + MAX_QSFP_PAGE_SIZE * 2)) {
514-
continue;
515-
}
516-
if (bf_qsfp_get_cached_info (
517-
i, QSFP_PAGE2,
518-
buf + MAX_QSFP_PAGE_SIZE * 3)) {
519-
continue;
520-
}
521-
if (bf_qsfp_get_cached_info (
522-
i, QSFP_PAGE3,
523-
buf + MAX_QSFP_PAGE_SIZE * 4)) {
524-
continue;
525-
}
503+
#if 0
526504
if (bf_qsfp_is_cmis (i)) {
527-
if (bf_qsfp_get_cached_info (
528-
i, QSFP_PAGE4,
529-
buf + MAX_QSFP_PAGE_SIZE * 5)) {
530-
continue;
531-
}
532-
onlp_save (path, (char *)buf,
533-
MAX_QSFP_PAGE_SIZE * 6);
534-
} else {
535-
onlp_save (path, (char *)buf,
536-
MAX_QSFP_PAGE_SIZE * 5);
505+
continue;
537506
}
507+
#endif
508+
onlp_save (path, (char *)buf,
509+
MAX_QSFP_PAGE_SIZE * 2);
538510
}
539511
sprintf (path, ONLP_LOG_QSFP_PRES_PATH,
540512
"presence");
@@ -601,12 +573,12 @@ static void bf_pltfm_onlp_mntr_transceiver()
601573
continue;
602574
}
603575
if (bf_sfp_get_cached_info (i, 1,
604-
buf + MAX_QSFP_PAGE_SIZE) ) {
576+
buf + 2 * MAX_QSFP_PAGE_SIZE) ) {
605577
continue;
606578
}
607579
/* $ hexdump /var/asterfusion/qsfp_10_eeprom is helpful. */
608580
onlp_save (path, (char *)buf,
609-
MAX_QSFP_PAGE_SIZE * 2);
581+
MAX_QSFP_PAGE_SIZE * 4);
610582
}
611583
sprintf (path, ONLP_LOG_SFP_PRES_PATH,
612584
"presence");

0 commit comments

Comments
 (0)