@@ -10,13 +10,13 @@ import sys
1010import pprint
1111from libnvme import nvme
1212
13- def disc_supp_str (disc_log_page_support ):
14- d = {
15- nvme.NVMF_LOG_DISC_LID_EXTDLPES : " Extended Discovery Log Page Entry Supported ( EXTDLPES) " ,
16- nvme.NVMF_LOG_DISC_LID_PLEOS : " Port Local Entries Only Supported ( PLEOS) " ,
17- nvme.NVMF_LOG_DISC_LID_ALLSUBES : " All NVM Subsystem Entries Supported ( ALLSUBES) " ,
13+ def disc_supp_str (dlp_supp_opts ):
14+ bitmap = {
15+ nvme.NVMF_LOG_DISC_LID_EXTDLPES : " EXTDLPES" ,
16+ nvme.NVMF_LOG_DISC_LID_PLEOS : " PLEOS" ,
17+ nvme.NVMF_LOG_DISC_LID_ALLSUBES : " ALLSUBES" ,
1818 }
19- return [txt for msk, txt in d .items() if disc_log_page_support & msk]
19+ return [txt for msk, txt in bitmap .items() if dlp_supp_opts & msk]
2020
2121root = nvme.root() # This is a singleton
2222root.log_level(' debug' ) # Optional: extra debug info
@@ -40,15 +40,15 @@ except Exception as e:
4040 sys.exit(f ' Failed to connect: { e} ' )
4141
4242supported_log_pages = ctrl.supported_log_pages()
43- if supported_log_pages is not None :
44- disc_log_page_support = supported_log_pages[nvme.NVME_LOG_LID_DISCOVER ]
45- print (f " LID { nvme.NVME_LOG_LID_DISCOVER :02x } h (Discovery), supports: { disc_supp_str(disc_log_page_support)} " )
43+ try :
44+ # Get the supported options for the Get Discovery Log Page command
45+ dlp_supp_opts = supported_log_pages[nvme.NVME_LOG_LID_DISCOVER ] >> 16
46+ except (TypeError , IndexError ):
47+ dlp_supp_opts = 0
4648
49+ print (f " LID { nvme.NVME_LOG_LID_DISCOVER :02x } h (Discovery), supports: { disc_supp_str(dlp_supp_opts)} " )
4750try :
48- if disc_log_page_support and (disc_log_page_support & nvme.NVMF_LOG_DISC_LID_PLEOS ):
49- lsp = nvme.NVMF_LOG_DISC_LSP_PLEO
50- else :
51- lsp = 0
51+ lsp = nvme.NVMF_LOG_DISC_LSP_PLEO if dlp_supp_opts & nvme.NVMF_LOG_DISC_LID_PLEOS else 0
5252 log_pages = ctrl.discover(lsp = lsp)
5353 print (pprint.pformat(log_pages))
5454except Exception as e:
0 commit comments