@@ -10334,6 +10334,118 @@ static int get_reachability_groups_log(int argc, char **argv, struct command *cm
1033410334 return err ;
1033510335}
1033610336
10337+ static int get_reachability_association_desc (struct nvme_dev * dev , struct nvme_get_log_args * args ,
10338+ __u64 offset ,
10339+ struct nvme_reachability_associations_log * * logp )
10340+ {
10341+ int err ;
10342+ struct nvme_reachability_associations_log * log = * logp ;
10343+ __u16 i ;
10344+ __u32 len ;
10345+
10346+ for (i = 0 ; i < le16_to_cpu (log -> nrad ); i ++ ) {
10347+ len = sizeof (* log -> rad );
10348+ err = get_log_offset (dev , args , & offset , len , (void * * )& log );
10349+ if (err )
10350+ goto err_free ;
10351+ len = le32_to_cpu (log -> rad [i ].nrid ) * sizeof (* log -> rad [i ].rgid );
10352+ err = get_log_offset (dev , args , & offset , len , (void * * )& log );
10353+ if (err )
10354+ goto err_free ;
10355+ }
10356+
10357+ * logp = log ;
10358+ return 0 ;
10359+
10360+ err_free :
10361+ free (log );
10362+ * logp = NULL ;
10363+ return err ;
10364+ }
10365+
10366+ static int get_reachability_associations (struct nvme_dev * dev , bool rao , bool rae ,
10367+ struct nvme_reachability_associations_log * * logp )
10368+ {
10369+ int err ;
10370+ struct nvme_reachability_associations_log * log ;
10371+ __u64 log_len = sizeof (* log );
10372+ struct nvme_get_log_args args = {
10373+ .args_size = sizeof (args ),
10374+ .fd = dev_fd (dev ),
10375+ .timeout = NVME_DEFAULT_IOCTL_TIMEOUT ,
10376+ .lid = NVME_LOG_LID_REACHABILITY_ASSOCIATIONS ,
10377+ .nsid = NVME_NSID_ALL ,
10378+ .lsp = rao ,
10379+ .rae = rae ,
10380+ };
10381+
10382+ log = nvme_alloc (log_len );
10383+ if (!log )
10384+ return - ENOMEM ;
10385+
10386+ err = nvme_cli_get_log_reachability_associations (dev , rao , rae , log_len , log );
10387+ if (err )
10388+ goto err_free ;
10389+
10390+ err = get_reachability_association_desc (dev , & args , log_len , & log );
10391+ if (err )
10392+ goto err_free ;
10393+
10394+ * logp = log ;
10395+ return 0 ;
10396+
10397+ err_free :
10398+ free (log );
10399+ return err ;
10400+ }
10401+
10402+ static int get_reachability_associations_log (int argc , char * * argv , struct command * cmd ,
10403+ struct plugin * plugin )
10404+ {
10405+ const char * desc = "Retrieve Reachability Associations Log, show it" ;
10406+ const char * rao = "Return Associations Only" ;
10407+ nvme_print_flags_t flags ;
10408+ int err ;
10409+
10410+ _cleanup_free_ struct nvme_reachability_associations_log * log = NULL ;
10411+
10412+ _cleanup_nvme_dev_ struct nvme_dev * dev = NULL ;
10413+
10414+ struct config {
10415+ bool rao ;
10416+ bool rae ;
10417+ };
10418+
10419+ struct config cfg = {
10420+ .rao = false,
10421+ .rae = false,
10422+ };
10423+
10424+ NVME_ARGS (opts ,
10425+ OPT_FLAG ("associations-only" , 'a' , & cfg .rao , rao ),
10426+ OPT_FLAG ("rae" , 'r' , & cfg .rae , rae ));
10427+
10428+ err = parse_and_open (& dev , argc , argv , desc , opts );
10429+ if (err )
10430+ return err ;
10431+
10432+ err = validate_output_format (nvme_cfg .output_format , & flags );
10433+ if (err < 0 ) {
10434+ nvme_show_error ("Invalid output format" );
10435+ return err ;
10436+ }
10437+
10438+ err = get_reachability_associations (dev , cfg .rao , cfg .rae , & log );
10439+ if (!err )
10440+ nvme_show_reachability_associations_log (log , flags );
10441+ else if (err > 0 )
10442+ nvme_show_status (err );
10443+ else
10444+ nvme_show_perror ("reachability associations log" );
10445+
10446+ return err ;
10447+ }
10448+
1033710449void register_extension (struct plugin * plugin )
1033810450{
1033910451 plugin -> parent = & nvme ;
0 commit comments