@@ -4734,6 +4734,76 @@ static void json_reachability_associations_log(struct nvme_reachability_associat
47344734 json_print (r );
47354735}
47364736
4737+ static void json_host_discovery_log (struct nvme_host_discover_log * log )
4738+ {
4739+ struct json_object * r = json_create_object ();
4740+ __u32 i ;
4741+ __u16 j ;
4742+ struct nvme_host_ext_discover_log * hedlpe ;
4743+ struct nvmf_ext_attr * exat ;
4744+ __u32 thdlpl = le32_to_cpu (log -> thdlpl );
4745+ __u32 tel ;
4746+ __u16 numexat ;
4747+ char json_str [STR_LEN ];
4748+ struct json_object * hedlpe_o ;
4749+ struct json_object * tsas_o ;
4750+ struct json_object * exat_o ;
4751+ int n = 0 ;
4752+
4753+ obj_add_uint64 (r , "genctr" , le64_to_cpu (log -> genctr ));
4754+ obj_add_uint64 (r , "numrec" , le64_to_cpu (log -> numrec ));
4755+ obj_add_uint (r , "recfmt" , le16_to_cpu (log -> recfmt ));
4756+ obj_add_uint_02x (r , "hdlpf" , log -> hdlpf );
4757+ obj_add_uint (r , "thdlpl" , thdlpl );
4758+
4759+ for (i = sizeof (* log ); i < le32_to_cpu (log -> thdlpl ); i += tel ) {
4760+ hedlpe_o = json_create_object ();
4761+ hedlpe = (void * )log + i ;
4762+ tel = le32_to_cpu (hedlpe -> tel );
4763+ numexat = le16_to_cpu (hedlpe -> numexat );
4764+ obj_add_str (hedlpe_o , "trtype" , nvmf_trtype_str (hedlpe -> trtype ));
4765+ obj_add_str (hedlpe_o , "adrfam" ,
4766+ strlen (hedlpe -> traddr ) ? nvmf_adrfam_str (hedlpe -> adrfam ) : "" );
4767+ obj_add_str (hedlpe_o , "eflags" , nvmf_eflags_str (le16_to_cpu (hedlpe -> eflags )));
4768+ obj_add_str (hedlpe_o , "hostnqn" , hedlpe -> hostnqn );
4769+ obj_add_str (hedlpe_o , "traddr" , hedlpe -> traddr );
4770+ tsas_o = json_create_object ();
4771+ switch (hedlpe -> trtype ) {
4772+ case NVMF_TRTYPE_RDMA :
4773+ obj_add_str (tsas_o , "prtype" , nvmf_prtype_str (hedlpe -> tsas .rdma .prtype ));
4774+ obj_add_str (tsas_o , "qptype" , nvmf_qptype_str (hedlpe -> tsas .rdma .qptype ));
4775+ obj_add_str (tsas_o , "cms" , nvmf_cms_str (hedlpe -> tsas .rdma .cms ));
4776+ obj_add_uint_0nx (tsas_o , "pkey" , le16_to_cpu (hedlpe -> tsas .rdma .pkey ), 4 );
4777+ break ;
4778+ case NVMF_TRTYPE_TCP :
4779+ obj_add_str (tsas_o , "sectype" , nvmf_sectype_str (hedlpe -> tsas .tcp .sectype ));
4780+ break ;
4781+ default :
4782+ obj_d (tsas_o , "common" , (unsigned char * )hedlpe -> tsas .common ,
4783+ sizeof (hedlpe -> tsas .common ), 16 , 1 );
4784+ break ;
4785+ }
4786+ obj_add_obj (hedlpe_o , "tsas" , tsas_o );
4787+ obj_add_uint (hedlpe_o , "tel" , tel );
4788+ obj_add_uint (hedlpe_o , "numexat" , numexat );
4789+
4790+ exat = hedlpe -> exat ;
4791+ for (j = 0 ; j < numexat ; j ++ ) {
4792+ exat_o = json_create_object ();
4793+ snprintf (json_str , sizeof (json_str ), "exat: %d" , j );
4794+ obj_add_uint (exat_o , "exattype" , le16_to_cpu (exat -> exattype ));
4795+ obj_add_uint (exat_o , "exatlen" , le16_to_cpu (exat -> exatlen ));
4796+ printf (":\n" );
4797+ obj_d (exat_o , "exatval" , (unsigned char * )exat -> exatval ,
4798+ le16_to_cpu (exat -> exatlen ), 16 , 1 );
4799+ obj_add_obj (hedlpe_o , json_str , exat_o );
4800+ exat = nvmf_exat_ptr_next (exat );
4801+ }
4802+ snprintf (json_str , sizeof (json_str ), "hedlpe: %d" , n ++ );
4803+ obj_add_obj (r , json_str , hedlpe_o );
4804+ }
4805+ }
4806+
47374807static struct print_ops json_print_ops = {
47384808 /* libnvme types.h print functions */
47394809 .ana_log = json_ana_log ,
@@ -4806,6 +4876,7 @@ static struct print_ops json_print_ops = {
48064876 .dispersed_ns_psub_log = json_dispersed_ns_psub_log ,
48074877 .reachability_groups_log = json_reachability_groups_log ,
48084878 .reachability_associations_log = json_reachability_associations_log ,
4879+ .host_discovery_log = json_host_discovery_log ,
48094880
48104881 /* libnvme tree print functions */
48114882 .list_item = json_list_item ,
0 commit comments