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