-
Notifications
You must be signed in to change notification settings - Fork 0
/
nvme_response.go
51 lines (39 loc) · 901 Bytes
/
nvme_response.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package nvme
import (
"github.com/thirdmartini/go-nvme/protocol"
)
// DataSGLE is a Scatter gather entry for Data buffer writes
type DataSGLE struct {
Data []byte
}
type SGL []DataSGLE
const (
MaxSGL = 16
RequestNeedsData = 0x1
)
type NVMEResponse struct {
Type uint8
CID uint16
sgl [MaxSGL]DataSGLE
sglc int
Response protocol.CapsuleResponse
C2H protocol.C2HDataTransfer
State uint32 // state flags on the request
DataLength uint32 // how much data is needed to be received
NoReply bool // flags o // n the request
Shutdown bool
}
func (w *NVMEResponse) Reset() {
w.CID = 0
w.sglc = 0
w.NoReply = false
w.Shutdown = false
}
// Write this just sets our response buffers
func (w *NVMEResponse) Write(data []byte) {
w.sgl[w.sglc].Data = data
w.sglc++
}
func (w *NVMEResponse) SetStatus(code protocol.NVMEStatusCode) {
w.Response.SetStatus(code)
}