changelog shortlog graph tags branches changeset files revisions annotate raw help

Mercurial > core / lisp/ffi/uring/sq.lisp

changeset 299: cebda1469eb1
parent: ec6bdaa0e6f4
author: Richard Westhaver <ellis@rwest.io>
date: Fri, 26 Apr 2024 11:05:01 -0400
permissions: -rw-r--r--
description: comment out missing macros
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 
27 ;; used to send IO requests to the kernel
28 (defstruct submission-queue
29  (head 0 :type fixnum)
30  (tail 0 :type fixnum)
31  (queue (make-alien io-uring-sq) :type (alien io-uring-sq*))) ;; io-uring-sq*
32 
33 ;; 64-byte SQE
34 (defstruct submission-queue-entry
35  (opcode 0 :type octet)
36  (flags 0 :type octet)
37  (ioprio 0 :type (unsigned-byte 16))
38  (fd 0 :type sb-posix:file-descriptor)
39  (off 0 :type (unsigned-byte 64))
40  (addr 0 :type fixnum)
41  (len 0 :type fixnum)
42  (flags2 0 :type fixnum)
43  (user-data 0 :type fixnum)
44  (buf-index 0 :type fixnum)
45  (personality 0 :type fixnum)
46  (file-index 0 :type fixnum)
47  (addr2 0 :type (unsigned-byte 64))) ;; this is actually addr3. it's a u64 which is inside a struct, inside a union
48 
49 (defun u64-bytes (int)
50  (make-array 8 :element-type 'octet
51  :initial-contents
52  (loop for i from 0 below 8
53  collect (ldb (byte 8 (* i 8)) int))))
54 
55 ;; (defmethod build ((self submission-queue-entry) &key &allow-other-keys)
56 ;; (with-slots (opcode flags ioprio fd off addr len flags2 user-data buf-index personality file-index addr2) self
57 ;; (with-alien ((a (array unsigned-char 80)))
58 ;; (clone-octets-to-alien (u64-bytes addr2) a)
59 ;; ;; TODO
60 ;; ;; (with-io-uring-sqe res
61 ;; ;; ((opcode opcode) (flags flags) (ioprio ioprio) (fd fd) (off off) (addr addr) (len len)
62 ;; ;; (flags2 flags2) (user-data user-data) (buf-index buf-index) (personality personality)
63 ;; ;; (file-index file-index)
64 ;; ;; (addr2 a))
65 ;; ;; res)
66 ;; )))
67 
68 ;; 128-byte SQE
69 (defstruct submission-queue-entry-128
70  (opcode 0 :type octet)
71  (flags 0 :type octet)
72  (ioprio 0 :type (unsigned-byte 16))
73  (fd 0 :type sb-posix:file-descriptor)
74  (off 0 :type (unsigned-byte 64))
75  (addr 0 :type fixnum)
76  (len 0 :type fixnum)
77  (flags2 0 :type fixnum)
78  (user-data 0 :type fixnum)
79  (buf-index 0 :type fixnum)
80  (personality 0 :type fixnum)
81  (file-index 0 :type fixnum)
82  ;; with sqe128, this field contains the last 72 bytes of the 80 byte
83  ;; arbitrary command data field. The first 8 bytes live in the ADDR2
84  ;; slot of ENTRY.
85  (cmd (make-array 80 :element-type 'octet) :type (octet-vector 80)))
86 
87 ;; (defmethod build ((self submission-queue-entry-128) &key &allow-other-keys)
88 ;; (with-slots (opcode flags ioprio fd off addr len flags2 user-data buf-index personality file-index cmd) self
89 ;; (with-alien ((a (array unsigned-char 80)))
90 ;; (clone-octets-to-alien cmd a)
91 ;; ;; (with-io-uring-sqe res
92 ;; ;; ((opcode opcode) (flags flags) (ioprio ioprio) (fd fd) (off off) (addr addr) (len len)
93 ;; ;; (flags2 flags2) (user-data user-data) (buf-index buf-index) (personality personality)
94 ;; ;; (file-index file-index) (addr2 a))
95 ;; ;; res)
96 ;; )))
97 ;;; Flags
98 
99 ;; sync, needs-wakeup-p, dropped, overflowp, taskrunp, push,
100 ;; push-multiple, push* (unchecked), personality