1syntax = "proto3"; 2 3import "nvme.proto"; 4import "virtio_blk.proto"; 5import "nvmf_tcp.proto"; 6import "nvmf.proto"; 7 8// This file provides the generic definitions for the Storage Management Agent 9// gRPC calls. All of the methods are supposed to be idempotent. Errors are 10// reported as standard gRPC status codes. 11 12package sma; 13 14option go_package = "github.com/spdk/sma-goapi/v1alpha1"; 15 16// Enumeration defining types of devices 17enum DeviceType { 18 DEVICE_TYPE_INVALID = 0; 19 DEVICE_TYPE_NVME = 1; 20 DEVICE_TYPE_VIRTIO_BLK = 2; 21 DEVICE_TYPE_NVMF_TCP = 3; 22} 23 24// Volume's crypto parameters 25message VolumeCryptoParameters { 26 // Key to be used for encryption 27 bytes key = 1; 28 // Second key (only required by some ciphers) 29 bytes key2 = 2; 30 enum Cipher { 31 AES_CBC = 0; 32 AES_XTS = 1; 33 } 34 // Cipher to use 35 Cipher cipher = 3; 36 // Tweak mode - determine how nvme LBA is converted into tweak 37 enum TweakMode { 38 // default for SPDK bdev_crypto 39 // Tweak[127:0] = {64'b0, LBA[63:0]} 40 TWEAK_MODE_SIMPLE_LBA = 0; 41 42 // Tweak[127:0] = {1’b0, ~LBA[62:0], LBA[63:0]} 43 TWEAK_MODE_JOIN_NEG_LBA_WITH_LBA = 1; 44 45 // tweak is derived from nvme LBA that is internally incremented by 1 for every 512 bytes processed 46 // so initial lba = (BLOCK_SIZE_IN_BYTES / 512) * LBA 47 // Tweak[127:0] = {lba[127:0]} 48 TWEAK_MODE_INCR_512_FULL_LBA = 2; 49 50 // tweak is derived from nvme LBA that is internally incremented by 1 for every 512 bytes processed 51 // so initial lba = (BLOCK_SIZE_IN_BYTES / 512) * LBA 52 // Tweak[127:0] = {lba[63:0], 64'b0} 53 TWEAK_MODE_INCR_512_UPPER_LBA = 3; 54 } 55 TweakMode tweak_mode = 4; 56} 57 58// Parameters describing a volume 59message VolumeParameters { 60 // Volume GUID/UUID 61 bytes volume_id = 1; 62 oneof connection_params { 63 // NVMeoF volume 64 nvmf.VolumeConnectionParameters nvmf = 2; 65 } 66 // Crypto parameters (optional) 67 VolumeCryptoParameters crypto = 3; 68} 69 70// Create device request 71message CreateDeviceRequest { 72 // Volume to immediately attach to the created device. This field may be 73 // optional for some device types (e.g. NVMe), while it may be required for 74 // others (e.g. virtio-blk). 75 VolumeParameters volume = 1; 76 // Device-specific parameters 77 oneof params { 78 // NVMe parameters 79 nvme.DeviceParameters nvme = 2; 80 // Virtio-blk parameters 81 virtio_blk.DeviceParameters virtio_blk = 3; 82 // NVMe/TCP parameters 83 nvmf_tcp.DeviceParameters nvmf_tcp = 4; 84 } 85} 86 87// Create device response 88message CreateDeviceResponse { 89 // Device handle that can uniquely identify a device within an instance of 90 // Storage Management Agent 91 string handle = 1; 92} 93 94// Delete device request 95message DeleteDeviceRequest { 96 // Device handle 97 string handle = 1; 98} 99 100// Delete device response 101message DeleteDeviceResponse {} 102 103// Attach volume request 104message AttachVolumeRequest { 105 // Volume parameters 106 VolumeParameters volume = 1; 107 // Device handle 108 string device_handle = 2; 109} 110 111// Attach volume response 112message AttachVolumeResponse {} 113 114// Detach volume request 115message DetachVolumeRequest { 116 // Volume GUID/UUID 117 bytes volume_id = 1; 118 // Device handle 119 string device_handle = 2; 120} 121 122// Detach volume response 123message DetachVolumeResponse {} 124 125// QoS limit values. 0 means unlimited, while UINT64_MAX means to leave the 126// current limit value unchanged. If one of the limits isn't supported by a 127// given device/volume, it must be set to 0. 128message QosLimit { 129 // Read kIOPS 130 uint64 rd_iops = 1; 131 // Write kIOPS 132 uint64 wr_iops = 2; 133 // Read/write kIOPS 134 uint64 rw_iops = 3; 135 // Read bandwidth (MB/s) 136 uint64 rd_bandwidth = 4; 137 // Write bandwidth (MB/s) 138 uint64 wr_bandwidth = 5; 139 // Read/write bandwidth (MB/s) 140 uint64 rw_bandwidth = 6; 141} 142 143// SetQos request 144message SetQosRequest { 145 // Device handle 146 string device_handle = 1; 147 // GUID/UUID of a volume to configure QoS on. If this parameter is omitted, 148 // the QoS will be set up on the whole device (all volumes attached to that 149 // device will share QoS settings). Some device types might only support 150 // configuring QoS on per-device (volume_id must be empty) or per-volume level 151 // (volume_id cannot be empty). This information can be obtained by sending a 152 // GetQosCapabilities request. 153 bytes volume_id = 2; 154 // Maximum allowed IOPS/bandwidth 155 QosLimit maximum = 3; 156} 157 158// SetQos response 159message SetQosResponse {} 160 161// Get QoS capabilities request 162message GetQosCapabilitiesRequest { 163 // Type of a device to query for QoS capabilities 164 DeviceType device_type = 1; 165} 166 167// Get QoS capabilities response 168message GetQosCapabilitiesResponse { 169 message QosCapabilities { 170 // Read IOPS 171 bool rd_iops = 1; 172 // Write IOPS 173 bool wr_iops = 2; 174 // Read/write IOPS 175 bool rw_iops = 3; 176 // Read bandwidth 177 bool rd_bandwidth = 4; 178 // Write bandwidth 179 bool wr_bandwidth = 5; 180 // Read/write bandwidth 181 bool rw_bandwidth = 6; 182 } 183 // Device level maximum QoS limits 184 QosCapabilities max_device_caps = 1; 185 // Volume level maximum QoS limits 186 QosCapabilities max_volume_caps = 2; 187}; 188 189// Storage Management Agent gRPC service definition 190service StorageManagementAgent { 191 // Creates a new device. A device is an entity that can be used to expose 192 // volumes (e.g. an NVMeoF subsystem). 193 rpc CreateDevice (CreateDeviceRequest) 194 returns (CreateDeviceResponse) {} 195 // Deletes a device. It is only allowed to delete a device with volumes still 196 // attached if that device doesn't support attaching volumes through 197 // AttachVolume (e.g. virtio-blk). In other cases, it is forbidden and 198 // FAILED_PRECONDITION status will be returned. 199 rpc DeleteDevice (DeleteDeviceRequest) 200 returns (DeleteDeviceResponse) {} 201 // Attaches a volume to a specified device making it available through that 202 // device (e.g. for NVMeoF this results in adding a namespace to an NVMeoF 203 // subsystem). The type of volume doesn't need to match the type of device 204 // (e.g. it's perfectly fine to attach an NVMe/TCP volume to a virtio-blk 205 // device). 206 rpc AttachVolume (AttachVolumeRequest) 207 returns (AttachVolumeResponse) {} 208 // Detaches a volume from a device 209 rpc DetachVolume (DetachVolumeRequest) 210 returns (DetachVolumeResponse) {} 211 // Configures QoS on a device/volume 212 rpc SetQos (SetQosRequest) 213 returns (SetQosResponse) {} 214 // Returns QoS capabilities of a given device type 215 rpc GetQosCapabilities (GetQosCapabilitiesRequest) 216 returns (GetQosCapabilitiesResponse) {} 217} 218