Lines Matching refs:opt
68 } opt = { variable
99 #define ARG(l, s, t, opt, addr, desc) { l, s, t, &opt.addr, desc } argument
102 ARG("opcode", 'o', arg_uint8, opt, opcode,
104 ARG("cdw2", '2', arg_uint32, opt, cdw2,
106 ARG("cdw3", '3', arg_uint32, opt, cdw3,
108 ARG("cdw10", '4', arg_uint32, opt, cdw10,
110 ARG("cdw11", '5', arg_uint32, opt, cdw11,
112 ARG("cdw12", '6', arg_uint32, opt, cdw12,
114 ARG("cdw13", '7', arg_uint32, opt, cdw13,
116 ARG("cdw14", '8', arg_uint32, opt, cdw14,
118 ARG("cdw15", '9', arg_uint32, opt, cdw15,
120 ARG("data-len", 'l', arg_uint32, opt, data_len,
122 ARG("metadata-len", 'm', arg_uint32, opt, metadata_len,
124 ARG("flags", 'f', arg_uint8, opt, flags,
126 ARG("input-file", 'i', arg_path, opt, ifn,
128 ARG("namespace-id", 'n', arg_uint32, opt, nsid,
130 ARG("prefill", 'p', arg_uint8, opt, prefill,
132 ARG("rsvd", 'R', arg_uint16, opt, rsvd,
134 ARG("timeout", 't', arg_uint32, opt, timeout,
136 ARG("raw-binary", 'b', arg_none, opt, binary,
138 ARG("dry-run", 'd', arg_none, opt, dry_run,
140 ARG("read", 'r', arg_none, opt, read,
142 ARG("show-command", 's', arg_none, opt, show_command,
144 ARG("write", 'w', arg_none, opt, write,
150 { arg_string, &opt.dev, "controller-id|namespace-id" },
164 open_dev(opt.dev, &fd, 1, 1); in passthru()
166 if (opt.read && opt.write) in passthru()
168 if (opt.data_len != 0 && !opt.read && !opt.write) in passthru()
170 if (*opt.ifn && (ifd = open(opt.ifn, O_RDONLY)) == -1) { in passthru()
171 warn("open %s", opt.ifn); in passthru()
175 if (opt.metadata_len != 0) { in passthru()
176 if (posix_memalign(&metadata, getpagesize(), opt.metadata_len)) { in passthru()
182 if (opt.metadata_len != 0) in passthru()
185 if (opt.data_len) { in passthru()
186 if (posix_memalign(&data, getpagesize(), opt.data_len)) { in passthru()
187 warn("can't allocate %d bytes for data", opt.data_len); in passthru()
190 memset(data, opt.prefill, opt.data_len); in passthru()
191 if (opt.write && in passthru()
192 (bytes_read = read(ifd, data, opt.data_len)) != in passthru()
193 opt.data_len) { in passthru()
195 *opt.ifn ? opt.ifn : "stdin", in passthru()
196 opt.data_len, bytes_read); in passthru()
200 if (opt.show_command) { in passthru()
201 fprintf(stderr, "opcode : %#02x\n", opt.opcode); in passthru()
202 fprintf(stderr, "flags : %#02x\n", opt.flags); in passthru()
203 fprintf(stderr, "rsvd1 : %#04x\n", opt.rsvd); in passthru()
204 fprintf(stderr, "nsid : %#04x\n", opt.nsid); in passthru()
205 fprintf(stderr, "cdw2 : %#08x\n", opt.cdw2); in passthru()
206 fprintf(stderr, "cdw3 : %#08x\n", opt.cdw3); in passthru()
207 fprintf(stderr, "data_len : %#08x\n", opt.data_len); in passthru()
208 fprintf(stderr, "metadata_len : %#08x\n", opt.metadata_len); in passthru()
211 fprintf(stderr, "cdw10 : %#08x\n", opt.cdw10); in passthru()
212 fprintf(stderr, "cdw11 : %#08x\n", opt.cdw11); in passthru()
213 fprintf(stderr, "cdw12 : %#08x\n", opt.cdw12); in passthru()
214 fprintf(stderr, "cdw13 : %#08x\n", opt.cdw13); in passthru()
215 fprintf(stderr, "cdw14 : %#08x\n", opt.cdw14); in passthru()
216 fprintf(stderr, "cdw15 : %#08x\n", opt.cdw15); in passthru()
217 fprintf(stderr, "timeout_ms : %d\n", opt.timeout); in passthru()
219 if (opt.dry_run) { in passthru()
226 pt.cmd.opc = opt.opcode; in passthru()
227 pt.cmd.fuse = opt.flags; in passthru()
228 pt.cmd.cid = htole16(opt.rsvd); in passthru()
229 pt.cmd.nsid = opt.nsid; /* XXX note: kernel overrides this */ in passthru()
230 pt.cmd.rsvd2 = htole32(opt.cdw2); in passthru()
231 pt.cmd.rsvd3 = htole32(opt.cdw3); in passthru()
232 pt.cmd.cdw10 = htole32(opt.cdw10); in passthru()
233 pt.cmd.cdw11 = htole32(opt.cdw11); in passthru()
234 pt.cmd.cdw12 = htole32(opt.cdw12); in passthru()
235 pt.cmd.cdw13 = htole32(opt.cdw13); in passthru()
236 pt.cmd.cdw14 = htole32(opt.cdw14); in passthru()
237 pt.cmd.cdw15 = htole32(opt.cdw15); in passthru()
239 pt.len = opt.data_len; in passthru()
240 pt.is_read = opt.read; in passthru()
245 if (!opt.binary) in passthru()
247 if (opt.read) { in passthru()
248 if (opt.binary) in passthru()
249 write(STDOUT_FILENO, data, opt.data_len); in passthru()
252 print_hex(data, opt.data_len); in passthru()