Coverage report: /home/ellis/comp/core/ffi/uring/sq.lisp

KindCoveredAll%
expression175 1.3
branch08 0.0
Key
Not instrumented
Conditionalized out
Executed
Not executed
 
Both branches taken
One branch taken
Neither branch taken
1
 ;;; uring/sq.lisp --- Submission Queue
2
 
3
 ;;
4
 
5
 ;;; Code:
6
 (in-package :uring)
7
 
8
 (defstruct submission-queue-offsets
9
   (head 0 :type fixnum)
10
   (tail 0 :type fixnum)
11
   (ring-mask 0 :type fixnum)
12
   (ring-entries 0 :type fixnum)
13
   (flags 0 :type fixnum)
14
   (dropped 0 :type fixnum)
15
   (array 0 :type fixnum)
16
   ;; resv1
17
   (user-addr 0 :type fixnum))
18
 
19
 (defmethod build ((self submission-queue-offsets) &key &allow-other-keys)
20
   (with-slots (head tail ring-mask ring-entries flags dropped array user-addr) self
21
     (with-io-sqring-offsets res
22
         ((head head) (tail tail) (ring-mask ring-mask) (ring-entries ring-entries) (flags flags)
23
          (dropped dropped) (array array) (user-addr user-addr))
24
       res)))
25
 
26
 ;; used to send IO requests to the kernel
27
 (defstruct submission-queue
28
   (head 0 :type fixnum)
29
   (tail 0 :type fixnum)
30
   (queue (make-alien io-uring-sq) :type (alien io-uring-sq*))) ;; io-uring-sq*
31
 
32
 ;; 64-byte SQE
33
 (defstruct submission-queue-entry
34
   (opcode 0 :type octet)
35
   (flags 0 :type octet)
36
   (ioprio 0 :type (unsigned-byte 16))
37
   (fd 0 :type sb-posix:file-descriptor)
38
   (off 0 :type (unsigned-byte 64))
39
   (addr 0 :type fixnum)
40
   (len 0 :type fixnum)
41
   (flags2 0 :type fixnum)
42
   (user-data 0 :type fixnum)
43
   (buf-index 0 :type fixnum)
44
   (personality 0 :type fixnum)
45
   (file-index 0 :type fixnum)
46
   (addr2 0 :type (unsigned-byte 64))) ;; this is actually addr3. it's a u64 which is inside a struct, inside a union
47
 
48
 (defun u64-bytes (int)
49
   (make-array 8 :element-type 'octet 
50
                 :initial-contents
51
                 (loop for i from 0 below 8
52
                       collect (ldb (byte 8 (* i 8)) int))))
53
 
54
 (defmethod build ((self submission-queue-entry) &key &allow-other-keys)
55
   (with-slots (opcode flags ioprio fd off addr len flags2 user-data buf-index personality file-index addr2) self
56
     (with-alien ((a (array unsigned-char 80)))
57
       (clone-octets-to-alien (u64-bytes addr2) a)
58
       ;; TODO
59
       ;; (with-io-uring-sqe res
60
       ;;     ((opcode opcode) (flags flags) (ioprio ioprio) (fd fd) (off off) (addr addr) (len len)
61
       ;;      (flags2 flags2) (user-data user-data) (buf-index buf-index) (personality personality)
62
       ;;      (file-index file-index)
63
       ;;      (addr2 a))
64
       ;;   res)
65
       )))
66
 
67
 ;; 128-byte SQE
68
 (defstruct submission-queue-entry-128
69
   (opcode 0 :type octet)
70
   (flags 0 :type octet)
71
   (ioprio 0 :type (unsigned-byte 16))
72
   (fd 0 :type sb-posix:file-descriptor)
73
   (off 0 :type (unsigned-byte 64))
74
   (addr 0 :type fixnum)
75
   (len 0 :type fixnum)
76
   (flags2 0 :type fixnum)
77
   (user-data 0 :type fixnum)
78
   (buf-index 0 :type fixnum)
79
   (personality 0 :type fixnum)
80
   (file-index 0 :type fixnum)
81
   ;; with sqe128, this field contains the last 72 bytes of the 80 byte
82
   ;; arbitrary command data field. The first 8 bytes live in the ADDR2
83
   ;; slot of ENTRY.
84
   (cmd (make-array 80 :element-type 'octet) :type (octet-vector 80)))
85
 
86
 (defmethod build ((self submission-queue-entry-128) &key &allow-other-keys)
87
   (with-slots (opcode flags ioprio fd off addr len flags2 user-data buf-index personality file-index cmd) self
88
     (with-alien ((a (array unsigned-char 80)))
89
       (clone-octets-to-alien cmd a)
90
       ;; (with-io-uring-sqe res
91
       ;;     ((opcode opcode) (flags flags) (ioprio ioprio) (fd fd) (off off) (addr addr) (len len)
92
       ;;      (flags2 flags2) (user-data user-data) (buf-index buf-index) (personality personality)
93
       ;;      (file-index file-index) (addr2 a))
94
       ;;   res)
95
       )))
96
 ;;; Flags
97
 
98
 ;; sync, needs-wakeup-p, dropped, overflowp, taskrunp, push,
99
 ;; push-multiple, push* (unchecked), personality