@@ -4751,6 +4751,76 @@ static void json_reachability_associations_log(struct nvme_reachability_associat
47514751 json_print (r );
47524752}
47534753
4754+ static void json_host_discovery_log (struct nvme_host_discover_log * log )
4755+ {
4756+ struct json_object * r = json_create_object ();
4757+ __u32 i ;
4758+ __u16 j ;
4759+ struct nvme_host_ext_discover_log * hedlpe ;
4760+ struct nvmf_ext_attr * exat ;
4761+ __u32 thdlpl = le32_to_cpu (log -> thdlpl );
4762+ __u32 tel ;
4763+ __u16 numexat ;
4764+ char json_str [STR_LEN ];
4765+ struct json_object * hedlpe_o ;
4766+ struct json_object * tsas_o ;
4767+ struct json_object * exat_o ;
4768+ int n = 0 ;
4769+
4770+ obj_add_uint64 (r , "genctr" , le64_to_cpu (log -> genctr ));
4771+ obj_add_uint64 (r , "numrec" , le64_to_cpu (log -> numrec ));
4772+ obj_add_uint (r , "recfmt" , le16_to_cpu (log -> recfmt ));
4773+ obj_add_uint_02x (r , "hdlpf" , log -> hdlpf );
4774+ obj_add_uint (r , "thdlpl" , thdlpl );
4775+
4776+ for (i = sizeof (* log ); i < le32_to_cpu (log -> thdlpl ); i += tel ) {
4777+ hedlpe_o = json_create_object ();
4778+ hedlpe = (void * )log + i ;
4779+ tel = le32_to_cpu (hedlpe -> tel );
4780+ numexat = le16_to_cpu (hedlpe -> numexat );
4781+ obj_add_str (hedlpe_o , "trtype" , nvmf_trtype_str (hedlpe -> trtype ));
4782+ obj_add_str (hedlpe_o , "adrfam" ,
4783+ strlen (hedlpe -> traddr ) ? nvmf_adrfam_str (hedlpe -> adrfam ) : "" );
4784+ obj_add_str (hedlpe_o , "eflags" , nvmf_eflags_str (le16_to_cpu (hedlpe -> eflags )));
4785+ obj_add_str (hedlpe_o , "hostnqn" , hedlpe -> hostnqn );
4786+ obj_add_str (hedlpe_o , "traddr" , hedlpe -> traddr );
4787+ tsas_o = json_create_object ();
4788+ switch (hedlpe -> trtype ) {
4789+ case NVMF_TRTYPE_RDMA :
4790+ obj_add_str (tsas_o , "prtype" , nvmf_prtype_str (hedlpe -> tsas .rdma .prtype ));
4791+ obj_add_str (tsas_o , "qptype" , nvmf_qptype_str (hedlpe -> tsas .rdma .qptype ));
4792+ obj_add_str (tsas_o , "cms" , nvmf_cms_str (hedlpe -> tsas .rdma .cms ));
4793+ obj_add_uint_0nx (tsas_o , "pkey" , le16_to_cpu (hedlpe -> tsas .rdma .pkey ), 4 );
4794+ break ;
4795+ case NVMF_TRTYPE_TCP :
4796+ obj_add_str (tsas_o , "sectype" , nvmf_sectype_str (hedlpe -> tsas .tcp .sectype ));
4797+ break ;
4798+ default :
4799+ obj_d (tsas_o , "common" , (unsigned char * )hedlpe -> tsas .common ,
4800+ sizeof (hedlpe -> tsas .common ), 16 , 1 );
4801+ break ;
4802+ }
4803+ obj_add_obj (hedlpe_o , "tsas" , tsas_o );
4804+ obj_add_uint (hedlpe_o , "tel" , tel );
4805+ obj_add_uint (hedlpe_o , "numexat" , numexat );
4806+
4807+ exat = hedlpe -> exat ;
4808+ for (j = 0 ; j < numexat ; j ++ ) {
4809+ exat_o = json_create_object ();
4810+ snprintf (json_str , sizeof (json_str ), "exat: %d" , j );
4811+ obj_add_uint (exat_o , "exattype" , le16_to_cpu (exat -> exattype ));
4812+ obj_add_uint (exat_o , "exatlen" , le16_to_cpu (exat -> exatlen ));
4813+ printf (":\n" );
4814+ obj_d (exat_o , "exatval" , (unsigned char * )exat -> exatval ,
4815+ le16_to_cpu (exat -> exatlen ), 16 , 1 );
4816+ obj_add_obj (hedlpe_o , json_str , exat_o );
4817+ exat = nvmf_exat_ptr_next (exat );
4818+ }
4819+ snprintf (json_str , sizeof (json_str ), "hedlpe: %d" , n ++ );
4820+ obj_add_obj (r , json_str , hedlpe_o );
4821+ }
4822+ }
4823+
47544824static struct print_ops json_print_ops = {
47554825 /* libnvme types.h print functions */
47564826 .ana_log = json_ana_log ,
@@ -4823,6 +4893,7 @@ static struct print_ops json_print_ops = {
48234893 .dispersed_ns_psub_log = json_dispersed_ns_psub_log ,
48244894 .reachability_groups_log = json_reachability_groups_log ,
48254895 .reachability_associations_log = json_reachability_associations_log ,
4896+ .host_discovery_log = json_host_discovery_log ,
48264897
48274898 /* libnvme tree print functions */
48284899 .list_item = json_list_item ,
0 commit comments