@@ -168,11 +168,27 @@ int bf_sfp_get_cable_length_copper (int port, uint8_t* cable_len)
168168
169169bool bf_sfp_get_dom_support (int port )
170170{
171+ bool yes = false;
172+
171173 if (port > bf_plt_max_sfp ) {
172- return false;
174+ goto finish ;
175+ }
176+
177+ // idprom indicates ?
178+ if (SFF8472_DOM_SUPPORTED (bf_sfp_info_arr [port ].idprom )) {
179+ yes = true;
180+ goto finish ;
181+ }
182+
183+ // further check for special cases if idprom doesn't indicate it.
184+ // It seems DOM isn't indicated in A0h[92], but the DOM may be supported
185+ if (bf_sfp_info_arr [port ].ctrlmask & BF_TRANS_CTRLMASK_TRY_DOM ) {
186+ yes = true;
187+ goto finish ;
173188 }
174189
175- return SFF8472_DOM_SUPPORTED (bf_sfp_info_arr [port ].idprom );
190+ finish :
191+ return yes ;
176192}
177193
178194/** return sfp presence information
@@ -372,13 +388,9 @@ int bf_sfp_module_write (
372388/* Quite important. by tsihang. */
373389static int bf_sfp_set_idprom (int port )
374390{
375- sff_eeprom_t * se ;
376391 uint8_t id ;
377392 int rc = -1 ;
378393
379- if (port > bf_plt_max_sfp ) {
380- return -1 ;
381- }
382394 if (!bf_sfp_info_arr [port ].present ) {
383395 LOG_ERROR (" SFP %02d: IDProm set failed as SFP is not present" ,
384396 port );
@@ -392,21 +404,6 @@ static int bf_sfp_set_idprom (int port)
392404 return rc ;
393405 }
394406
395- se = & bf_sfp_sff_eeprom [port ];
396- memset (se , 0 , sizeof (sff_eeprom_t ));
397- rc = sff_eeprom_parse (se ,
398- bf_sfp_info_arr [port ].idprom );
399- /* sff_eeprom_parse is quite an importand API for most sfp.
400- * but it is still not ready for all kind of sfps.
401- * so override the failure here and keep tracking.
402- * by tsihang, 2022-06-17. */
403- #if 0
404- if (!se -> identified ) {
405- LOG_ERROR (" SFP %02d: IDProm set failed as SFP is not decodable <rc=%d>" ,
406- port , rc );
407- return rc ;
408- }
409- #endif
410407 id = bf_sfp_info_arr [port ].idprom [0 ];
411408 if ((id == SFP ) || (id == SFP_PLUS ) ||
412409 (id == SFP_28 )) {
@@ -415,6 +412,37 @@ static int bf_sfp_set_idprom (int port)
415412 MMFORMAT_SFF8472 ;
416413 }
417414
415+
416+ sff_eeprom_t * se = & bf_sfp_sff_eeprom [port ];
417+ sff_info_t * sff = & se -> info ;
418+ memset (se , 0 , sizeof (sff_eeprom_t ));
419+ rc = sff_eeprom_parse (se , bf_sfp_info_arr [port ].idprom );
420+ /* sff_eeprom_parse is quite an importand API for most sfp.
421+ * but it is still not ready for all kind of sfps.
422+ * so override the failure here and keep tracking.
423+ * by tsihang, 2022-06-17. */
424+ //if (!se->identified) {
425+ // LOG_ERROR (" SFP %02d: IDProm set failed as SFP is not decodable <rc=%d>",
426+ // port, rc);
427+ // return rc;
428+ //}
429+
430+ /* load from /etc/transceiver-cases.conf. */
431+ uint32_t ctrlmask = 0 , ctrlmask0 = 0 ;
432+ if (bf_qsfp_tc_entry_find ((char * )sff -> vendor ,
433+ (char * )sff -> model , NULL , & ctrlmask , false) == 0 ) {
434+ bf_sfp_ctrlmask_get (port , & ctrlmask0 );
435+ ctrlmask |= ctrlmask0 ;
436+ bf_sfp_ctrlmask_set (port , ctrlmask );
437+ }
438+
439+ //if(!strncmp(sff->vendor, "Asterfusion", 5) &&
440+ // !strncmp(sff->model, "TSST1000H1", 9)) {
441+ // bf_sfp_info_arr[port].ctrlmask |= BF_TRANS_CTRLMASK_TRY_DOM;
442+ //}
443+
444+ bf_sfp_sff_info_show (port , sff );
445+
418446 // change dirty
419447 bf_sfp_info_arr [port ].cache_dirty = false;
420448
@@ -516,9 +544,12 @@ void bf_sfp_debug_clear_all_presence_bits (void)
516544 */
517545int bf_sfp_update_cache (int port )
518546{
547+ int rc = 0 ;
548+
519549 if (port > bf_plt_max_sfp ) {
520550 return -1 ;
521551 }
552+
522553 bf_sfp_idprom_clr (port );
523554
524555 if (!bf_sfp_info_arr [port ].present ) {
@@ -557,18 +588,11 @@ int bf_sfp_update_cache (int port)
557588 bf_sfp_info_arr [port ].passive_cu = false;
558589 }
559590
560- sff_dom_info_t sdi ;
561- sff_eeprom_t * se ;
562- sff_info_t * sff ;
563- se = & bf_sfp_sff_eeprom [port ];
564- sff = & se -> info ;
565-
566591 // now that we know the memory map format, we can selectively read the
567592 // locations that are static into our cache.
568593 /* How to check whether there's A2h or not ?
569594 * by tsihang, 2021-07-29. */
570- if (SFF8472_DOM_SUPPORTED (
571- bf_sfp_info_arr [port ].idprom )) {
595+ if (bf_sfp_get_dom_support (port )) {
572596 if (bf_pltfm_sfp_read_module (port ,
573597 MAX_SFP_PAGE_SIZE , MAX_SFP_PAGE_SIZE ,
574598 bf_sfp_info_arr [port ].a2h )) {
@@ -578,19 +602,14 @@ int bf_sfp_update_cache (int port)
578602 }
579603 }
580604
581- sff_dom_info_get (& sdi , sff ,
582- bf_sfp_info_arr [port ].idprom ,
583- bf_sfp_info_arr [port ].a2h );
584605 LOG_DEBUG (
585- " SFP %2d : Spec %s : %s : %s : %s" , port ,
606+ " SFP %2d : Spec %s : %s : %s : %s <rc=%d> " , port ,
586607 bf_sfp_is_sff8472 (port ) ? "SFF-8472" : "Unknown" ,
587608 bf_sfp_is_passive_cu (port ) ? "Passive copper" : "Active/Optical" ,
588609 bf_sfp_is_flat_mem (port ) ? "Flat" : "Paged" ,
589- "Update cache complete" );
590- bf_sfp_sff_info_show (port , sff );
610+ "Update cache complete" , rc );
591611
592612 return 0 ;
593-
594613}
595614
596615/** get sfp info ptr
@@ -687,7 +706,7 @@ bool bf_sfp_get_chan_temp (int port,
687706 }
688707
689708 /* A2h, what should we do if there's no A2h ? */
690- if (!SFF8472_DOM_SUPPORTED ( bf_sfp_info_arr [ port ]. idprom )) {
709+ if (! bf_sfp_get_dom_support ( port )) {
691710 return -1 ;
692711 }
693712
@@ -725,7 +744,7 @@ bool bf_sfp_get_chan_volt (int port,
725744 }
726745
727746 /* A2h, what should we do if there's no A2h ? */
728- if (!SFF8472_DOM_SUPPORTED ( bf_sfp_info_arr [ port ]. idprom )) {
747+ if (! bf_sfp_get_dom_support ( port )) {
729748 return -1 ;
730749 }
731750
@@ -763,7 +782,7 @@ bool bf_sfp_get_chan_tx_bias (int port,
763782 }
764783
765784 /* A2h, what should we do if there's no A2h ? */
766- if (!SFF8472_DOM_SUPPORTED ( bf_sfp_info_arr [ port ]. idprom )) {
785+ if (! bf_sfp_get_dom_support ( port )) {
767786 return -1 ;
768787 }
769788
@@ -796,7 +815,7 @@ bool bf_sfp_get_chan_tx_pwr (int port,
796815 }
797816
798817 /* A2h, what should we do if there's no A2h ? */
799- if (!SFF8472_DOM_SUPPORTED ( bf_sfp_info_arr [ port ]. idprom )) {
818+ if (! bf_sfp_get_dom_support ( port )) {
800819 return -1 ;
801820 }
802821
@@ -829,7 +848,7 @@ bool bf_sfp_get_chan_rx_pwr (int port,
829848 }
830849
831850 /* A2h, what should we do if there's no A2h ? */
832- if (!SFF8472_DOM_SUPPORTED ( bf_sfp_info_arr [ port ]. idprom )) {
851+ if (! bf_sfp_get_dom_support ( port )) {
833852 return -1 ;
834853 }
835854
@@ -860,7 +879,7 @@ bool bf_sfp_update_optional_status (int port)
860879 }
861880
862881 /* A2h, what should we do if there's no A2h ? */
863- if (!SFF8472_DOM_SUPPORTED ( bf_sfp_info_arr [ port ]. idprom )) {
882+ if (! bf_sfp_get_dom_support ( port )) {
864883 return -1 ;
865884 }
866885
0 commit comments