@@ -12,6 +12,7 @@ use async_std::task;
1212use clap:: { Parser , Subcommand } ;
1313use futures:: future:: join_all;
1414use libspdm:: libspdm_rs:: * ;
15+ use nix:: errno:: Errno ;
1516use nix:: unistd:: geteuid;
1617use sha2:: { Digest , Sha256 , Sha384 , Sha512 } ;
1718use std:: fs:: File ;
@@ -31,6 +32,7 @@ mod doe_pci_cfg;
3132mod io_buffers;
3233mod qemu_server;
3334mod request;
35+ mod scsi;
3436mod socket_client;
3537mod socket_server;
3638mod tcg_concise_evidence_binding;
@@ -43,6 +45,14 @@ struct Args {
4345 #[ command( subcommand) ]
4446 command : Commands ,
4547
48+ /// Use SCSI commands for the target device
49+ #[ arg( short, long, requires_ifs( [ ( "true" , "blk_dev_path" ) ] ) ) ]
50+ scsi : bool ,
51+
52+ /// Path to the SCSI block device
53+ #[ arg( long) ]
54+ blk_dev_path : Option < String > ,
55+
4656 /// Use the Linux PCIe extended configuration backend
4757 /// This is generally run on the Linux host machine
4858 #[ arg( short, long) ]
@@ -642,6 +652,9 @@ async fn main() -> Result<(), ()> {
642652
643653 let mut count = 0 ;
644654
655+ cli. scsi . then ( || {
656+ count += 1 ;
657+ } ) ;
645658 cli. doe_pci_cfg . then ( || {
646659 count += 1 ;
647660 } ) ;
@@ -704,8 +717,16 @@ async fn main() -> Result<(), ()> {
704717 error ! ( "Only MCTP supported over USB I2C" ) ;
705718 return Err ( ( ) ) ;
706719 }
707-
708720 usb_i2c:: register_device ( cntx_ptr, cli. usb_i2c_dev , cli. usb_i2c_baud ) ?;
721+ } else if cli. scsi {
722+ scsi:: cmd_scsi_get_info ( & cli. blk_dev_path . clone ( ) . unwrap ( ) ) . unwrap ( ) ;
723+ if let Err ( e) = scsi:: cmd_scsi_get_sec_info ( & cli. blk_dev_path . clone ( ) . unwrap ( ) ) {
724+ if e == Errno :: ENOTSUP {
725+ error ! ( "SPDM is not supported by this device" ) ;
726+ }
727+ return Err ( ( ) ) ;
728+ }
729+ scsi:: register_device ( cntx_ptr, & cli. blk_dev_path . clone ( ) . unwrap ( ) ) ?;
709730 } else if cli. qemu_server {
710731 if let Commands :: Request { .. } = cli. command {
711732 error ! ( "QEMU Server does not support running an SPDM requester" ) ;
@@ -730,6 +751,13 @@ async fn main() -> Result<(), ()> {
730751 spdm:: TransportLayer :: Mctp ,
731752 spdm:: LIBSPDM_MAX_SPDM_MSG_SIZE ,
732753 ) ?;
754+ } else if cli. scsi {
755+ spdm:: setup_transport_layer (
756+ cntx_ptr,
757+ spdm:: TransportLayer :: Storage ,
758+ spdm:: LIBSPDM_MAX_SPDM_MSG_SIZE ,
759+ )
760+ . unwrap ( ) ;
733761 } else {
734762 spdm:: setup_transport_layer (
735763 cntx_ptr,
0 commit comments