github.com/google/syzkaller@v0.0.0-20240517125934-c0f1611a36d6/sys/linux/socket_nvme_of_tcp.txt (about) 1 # Copyright 2018 syzkaller project authors. All rights reserved. 2 # Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. 3 4 include <linux/nvme-tcp.h> 5 include <linux/sizes.h> 6 include <linux/nvme.h> 7 include <linux/socket.h> 8 include <uapi/linux/in.h> 9 include <linux/net.h> 10 11 ######################################### 12 ### Generic NVMe over TCP ### 13 14 nvme_of_msg { 15 pdu nvme_tcp_pdu 16 payload optional[buffer[in]] 17 } [packed] 18 19 nvme_tcp_pdu [ 20 icreq nvme_tcp_icreq_pdu 21 icresp nvme_tcp_icresp_pdu 22 cmd nvme_tcp_cmd_pdu 23 rsp nvme_tcp_rsp_pdu 24 r2t nvme_tcp_r2t_pdu 25 data_h2c nvme_tcp_data_pdu_h2c 26 data_h2c_hdigest nvme_tcp_data_pdu_h2c_hdigest 27 data_h2c_no_hdigest nvme_tcp_data_pdu_h2c_no_hdigest 28 data_c2h nvme_tcp_data_pdu_c2h 29 ] 30 31 type nvme_tcp_hdr_t_const[PDU_TYPE, HLEN_SIZE] { 32 type const[PDU_TYPE, int8] 33 flags flags[nvme_tcp_pdu_flags, int8] 34 hlen const[HLEN_SIZE, int8] 35 pdo int8 36 plen int32 37 } [packed] 38 39 type nvme_tcp_hdr_t_const_pdo[PDU_TYPE, HLEN_SIZE, PDO_SIZE] { 40 type const[PDU_TYPE, int8] 41 flags flags[nvme_tcp_pdu_flags, int8] 42 hlen const[HLEN_SIZE, int8] 43 pdo const[PDO_SIZE, int8] 44 plen int32 45 } [packed] 46 47 type nvme_tcp_hdr_t_const_plen[PDU_TYPE, HLEN_SIZE, PLEN_SIZE] { 48 type const[PDU_TYPE, int8] 49 flags flags[nvme_tcp_pdu_flags, int8] 50 hlen const[HLEN_SIZE, int8] 51 pdo int8 52 plen const[PLEN_SIZE, int32] 53 } [packed] 54 55 nvme_tcp_pdu_flags = NVME_TCP_F_HDGST, NVME_TCP_F_DDGST, NVME_TCP_F_DATA_LAST, NVME_TCP_F_DATA_SUCCESS 56 57 nvme_tcp_digest_option = NVME_TCP_HDR_DIGEST_ENABLE, NVME_TCP_DATA_DIGEST_ENABLE 58 59 nvme_tcp_fatal_error_status = 0, NVME_TCP_FES_INVALID_PDU_HDR, NVME_TCP_FES_PDU_SEQ_ERR, NVME_TCP_FES_HDR_DIGEST_ERR, NVME_TCP_FES_DATA_OUT_OF_RANGE, NVME_TCP_FES_R2T_LIMIT_EXCEEDED, NVME_TCP_FES_DATA_LIMIT_EXCEEDED, NVME_TCP_FES_UNSUPPORTED_PARAM 60 61 nvme_tcp_pfv = NVME_TCP_PFV_1_0 62 63 define NVME_TCP_DATA_PDU_SIZE sizeof(struct nvme_tcp_data_pdu) 64 define NVME_TCP_ICREQ_PDU_SIZE sizeof(struct nvme_tcp_icreq_pdu) 65 define NVME_TCP_CMD_PDU_SIZE sizeof(struct nvme_tcp_cmd_pdu) 66 define NVME_TCP_ICRESP_PDU_SIZE sizeof(struct nvme_tcp_icresp_pdu) 67 68 define NVME_TCP_DISC_PORT 8009 69 define NVME_TCP_ADMIN_CCSZ SZ_8K 70 define NVME_TCP_DIGEST_LENGTH 4 71 define NVME_TCP_MIN_MAXH2CDATA 4096 72 73 ### End of generic ### 74 ######################################### 75 76 ######################################### 77 ### nvme_tcp_data_pdu ### 78 79 type nvme_tcp_data_pdu[HDR_TYPE] { 80 hdr HDR_TYPE 81 command_id int16 82 ttag int16 83 data_offset int32 84 data_length int32 85 rsvd array[int8, 4] 86 } [size[NVME_TCP_DATA_PDU_SIZE]] 87 88 type nvme_tcp_hdr_data_pdu_h2c nvme_tcp_hdr_t_const[nvme_tcp_h2c_data, NVME_TCP_DATA_PDU_SIZE] 89 type nvme_tcp_data_pdu_h2c nvme_tcp_data_pdu[nvme_tcp_hdr_data_pdu_h2c] 90 91 type nvme_tcp_hdr_data_pdu_h2c_hdigest nvme_tcp_hdr_t_const_pdo[nvme_tcp_h2c_data, NVME_TCP_DATA_PDU_SIZE, NVME_TCP_HDR_H2C_DIGEST_PDO_HDIGEST] 92 type nvme_tcp_data_pdu_h2c_hdigest nvme_tcp_data_pdu[nvme_tcp_hdr_data_pdu_h2c_hdigest] 93 94 type nvme_tcp_hdr_data_pdu_h2c_no_hdigest nvme_tcp_hdr_t_const_pdo[nvme_tcp_h2c_data, NVME_TCP_DATA_PDU_SIZE, NVME_TCP_HDR_H2C_DIGEST_PDO_NO_HDIGEST] 95 type nvme_tcp_data_pdu_h2c_no_hdigest nvme_tcp_data_pdu[nvme_tcp_hdr_data_pdu_h2c_no_hdigest] 96 97 type nvme_tcp_hdr_data_pdu_c2h nvme_tcp_hdr_t_const[nvme_tcp_c2h_data, NVME_TCP_DATA_PDU_SIZE] 98 type nvme_tcp_data_pdu_c2h nvme_tcp_data_pdu[nvme_tcp_hdr_data_pdu_c2h] 99 100 define NVME_TCP_HDR_H2C_DIGEST_PDO_HDIGEST NVME_TCP_DATA_PDU_SIZE + NVME_TCP_DIGEST_LENGTH 101 define NVME_TCP_HDR_H2C_DIGEST_PDO_NO_HDIGEST NVME_TCP_DATA_PDU_SIZE 102 define NVME_TCP_HDR_H2C_DIGEST_PLEN_HDIGEST_DDIGEST NVME_TCP_HDR_H2C_DIGEST_PDO_HDIGEST + NVME_TCP_DIGEST_LENGTH 103 104 ### End of nvme_tcp_r2t_pdu ### 105 ######################################### 106 107 ######################################### 108 ### nvme_tcp_r2t_pdu ### 109 110 nvme_tcp_r2t_pdu { 111 hdr nvme_tcp_hdr_r2t_pdu 112 command_id int16 113 ttag int16 114 r2t_offset int32 115 r2t_length int32 116 rsvd array[const[0, int8], 4] 117 } [size[NVME_TCP_DATA_PDU_SIZE]] 118 119 type nvme_tcp_hdr_r2t_pdu nvme_tcp_hdr_t_const[nvme_tcp_r2t, NVME_TCP_DATA_PDU_SIZE] 120 121 ### End of nvme_tcp_r2t_pdu ### 122 ######################################### 123 124 ######################################### 125 ### nvme_tcp_rsp_pdu ### 126 127 nvme_tcp_rsp_pdu { 128 hdr nvme_tcp_hdr_rsp_pdu 129 cqe nvme_completion 130 } [size[NVME_TCP_DATA_PDU_SIZE]] 131 132 nvme_completion { 133 result nvme_result 134 sq_head int16 135 sq_id int16 136 command_id int16 137 status flags[nvme_tcp_fatal_error_status, int16] 138 } [packed] 139 140 nvme_result [ 141 u16 int16 142 u32 int32 143 u64 int64 144 ] 145 146 type nvme_tcp_hdr_rsp_pdu nvme_tcp_hdr_t_const[nvme_tcp_rsp, NVME_TCP_DATA_PDU_SIZE] 147 148 ### End of nvme_tcp_rsp_pdu ### 149 ######################################### 150 151 ######################################### 152 ### nvme_tcp_icresp_pdu ### 153 154 nvme_tcp_icresp_pdu { 155 hdr nvme_tcp_hdr_icresp_pdu 156 pfv flags[nvme_tcp_pfv, int16] 157 # Linux NVMe driver only support cpda = 0 158 cpda const[0, int8] 159 digest flags[nvme_tcp_digest_option, int8] 160 maxdata int32 161 rsvd array[const[0, int8], 112] 162 } [size[NVME_TCP_ICRESP_PDU_SIZE]] 163 164 type nvme_tcp_hdr_icresp_pdu nvme_tcp_hdr_t_const[nvme_tcp_icresp, NVME_TCP_ICRESP_PDU_SIZE] 165 166 ### End of nvme_tcp_icresp_pdu ### 167 ######################################### 168 169 ######################################### 170 ### nvme_tcp_icreq_pdu ### 171 172 nvme_tcp_icreq_pdu { 173 hdr nvme_tcp_hdr_icreq_pdu 174 pfv flags[nvme_tcp_pfv, int16] 175 # Linux NVMe driver only support hcpda = 0 176 hpda const[0, int8] 177 digest flags[nvme_tcp_digest_option, int8] 178 maxr2t int32 179 rsvd array[const[0, int8], 112] 180 } [size[NVME_TCP_ICREQ_PDU_SIZE]] 181 182 type nvme_tcp_hdr_icreq_pdu nvme_tcp_hdr_t_const_plen[nvme_tcp_icreq, NVME_TCP_ICREQ_PDU_SIZE, NVME_TCP_ICREQ_PDU_SIZE] 183 184 ### End of nvme_tcp_icreq_pdu ### 185 ######################################### 186 187 ######################################### 188 ### nvme_tcp_cmd_pdu ### 189 190 nvme_tcp_cmd_pdu { 191 hdr nvme_tcp_hdr_cmd_pdu 192 cmd nvme_command 193 } [size[NVME_TCP_CMD_PDU_SIZE]] 194 195 type nvme_tcp_hdr_cmd_pdu nvme_tcp_hdr_t_const_plen[nvme_tcp_cmd, NVME_TCP_CMD_PDU_SIZE, NVME_TCP_CMD_PDU_SIZE] 196 197 nvme_command { 198 anon_union nvme_command_union 199 } 200 201 nvme_command_union [ 202 common nvme_common_command 203 rw nvme_rw_command 204 identify nvme_identify 205 features nvme_features 206 create_cq nvme_create_cq 207 create_sq nvme_create_sq 208 delete_queue nvme_delete_queue 209 dlfw nvme_download_firmware 210 format nvme_format_cmd 211 dsm nvme_dsm_cmd 212 write_zeroes nvme_write_zeroes_cmd 213 zms nvme_zone_mgmt_send_cmd 214 zmr nvme_zone_mgmt_recv_cmd 215 abort nvme_abort_cmd 216 fabrics nvmf_common_command 217 connect nvmf_connect_command 218 prop_set nvmf_property_set_command 219 prop_get nvmf_property_get_command 220 auth_common nvmf_auth_common_command 221 auth_send nvmf_auth_send_command 222 auth_receive nvmf_auth_receive_command 223 dbbuf nvme_dbbuf 224 directive nvme_directive_cmd 225 get_log_page nvme_get_log_page_command 226 ] 227 228 nvme_get_log_page_command { 229 opcode const[nvme_admin_get_log_page, int8] 230 flags int8 231 command_id int16 232 nsid int32 233 rsvd2 array[const[0, int64], 2] 234 dptr nvme_data_ptr 235 lid int8 236 lsp int8 237 numdl int16 238 numdu int16 239 rsvd11 const[0, int16] 240 anon_union nvme_get_log_page_command_anon_union 241 rsvd14 array[const[0, int8], 3] 242 csi int8 243 rsvd15 const[0, int32] 244 } 245 246 nvme_get_log_page_command_anon_union [ 247 anon_struct nvme_get_log_page_command_anon_union_anon_struct 248 lpo int64 249 ] 250 251 nvme_get_log_page_command_anon_union_anon_struct { 252 lpol int32 253 lpou int32 254 } 255 256 nvme_download_firmware { 257 opcode const[nvme_admin_download_fw, int8] 258 flags int8 259 command_id int16 260 rsvd1 array[const[0, int32], 5] 261 dptr nvme_data_ptr 262 numd int32 263 offset int32 264 rsvd12 array[const[0, int32], 4] 265 } 266 267 nvme_format_cmd { 268 opcode const[nvme_admin_format_nvm, int8] 269 flags int8 270 command_id int16 271 nsid int32 272 rsvd2 array[const[0, int64], 4] 273 cdw10 int32 274 rsvd11 array[const[0, int32], 5] 275 } 276 277 nvme_dsm_cmd { 278 opcode const[nvme_cmd_dsm, int8] 279 flags int8 280 command_id int16 281 nsid int32 282 rsvd2 array[const[0, int64], 2] 283 dptr nvme_data_ptr 284 nr int32 285 attributes int32 286 rsvd12 array[const[0, int32], 4] 287 } 288 289 nvme_write_zeroes_cmd { 290 opcode const[nvme_cmd_write_zeroes, int8] 291 flags int8 292 command_id int16 293 nsid int32 294 rsvd2 const[0, int64] 295 metadata int64 296 dptr nvme_data_ptr 297 slba int64 298 length int16 299 control int16 300 dsmgmt int32 301 reftag int32 302 apptag int16 303 appmask int16 304 } 305 306 nvme_zone_mgmt_send_cmd { 307 opcode const[nvme_cmd_zone_mgmt_send, int8] 308 flags int8 309 command_id int16 310 nsid int32 311 cdw2 array[int32, 2] 312 metadata int64 313 dptr nvme_data_ptr 314 slba int64 315 cdw12 int32 316 zsa int8 317 select_all int8 318 rsvd13 array[const[0, int8], 2] 319 cdw14 array[int32, 2] 320 } 321 322 nvme_zone_mgmt_recv_cmd { 323 opcode const[nvme_cmd_zone_mgmt_recv, int8] 324 flags int8 325 command_id int16 326 nsid int32 327 rsvd2 array[const[0, int64], 2] 328 dptr nvme_data_ptr 329 slba int64 330 numd int32 331 zra int8 332 zrasf int8 333 pr int8 334 rsvd13 const[0, int8] 335 cdw14 array[int32, 2] 336 } 337 338 nvme_abort_cmd { 339 opcode const[nvme_admin_abort_cmd, int8] 340 flags int8 341 command_id int16 342 rsvd1 array[const[0, int32], 9] 343 sqid int16 344 cid int16 345 rsvd11 array[const[0, int32], 5] 346 } 347 348 nvmf_common_command { 349 opcode const[nvme_fabrics_command, int8] 350 resv1 int8 351 command_id int16 352 fctype int8 353 resv2 array[int8, 35] 354 ts array[int8, 24] 355 } 356 357 nvmf_connect_command { 358 opcode const[nvme_fabrics_command, int8] 359 resv1 const[0x40, int8] 360 command_id const[0x0, int16] 361 fctype const[nvme_fabrics_type_connect, int8] 362 resv2 array[int8, 19] 363 dptr nvme_data_ptr 364 recfmt int16 365 qid int16 366 sqsize int16 367 cattr int8 368 resv3 int8 369 kato int32 370 resv4 array[int8, 12] 371 } 372 373 nvmf_property_set_command { 374 opcode const[nvme_fabrics_command, int8] 375 resv1 int8 376 command_id int16 377 fctype const[nvme_fabrics_type_property_set, int8] 378 resv2 array[int8, 35] 379 attrib const[0x0, int8] 380 resv3 array[int8, 3] 381 offset int32 382 value int64 383 resv4 array[int8, 8] 384 } 385 386 nvmf_property_get_command { 387 opcode const[nvme_fabrics_command, int8] 388 resv1 int8 389 command_id int16 390 fctype const[nvme_fabrics_type_property_get, int8] 391 resv2 array[int8, 35] 392 attrib int8 393 resv3 array[int8, 3] 394 offset int32 395 resv4 array[int8, 16] 396 } 397 398 nvmf_auth_common_command { 399 opcode const[nvme_fabrics_command, int8] 400 resv1 int8 401 command_id int16 402 fctype int8 403 resv2 array[int8, 19] 404 dptr nvme_data_ptr 405 resv3 int8 406 spsp0 int8 407 spsp1 int8 408 secp int8 409 al_tl int32 410 resv4 array[int8, 16] 411 } 412 413 nvmf_auth_send_command { 414 opcode const[nvme_fabrics_command, int8] 415 resv1 int8 416 command_id int16 417 fctype const[nvme_fabrics_type_auth_send, int8] 418 resv2 array[int8, 19] 419 dptr nvme_data_ptr 420 resv3 int8 421 spsp0 flags[sps_flags, int8] 422 spsp1 flags[sps_flags, int8] 423 secp flags[secp_flags, int8] 424 tl int32 425 resv4 array[int8, 16] 426 } 427 428 secp_flags = NVME_AUTH_DHCHAP_PROTOCOL_IDENTIFIER, 0x0 429 sps_flags = 0x1, 0x2 430 431 nvmf_auth_receive_command { 432 opcode const[nvme_fabrics_command, int8] 433 resv1 int8 434 command_id int16 435 fctype const[nvme_fabrics_type_auth_receive, int8] 436 resv2 array[int8, 19] 437 dptr nvme_data_ptr 438 resv3 int8 439 spsp0 flags[sps_flags, int8] 440 spsp1 flags[sps_flags, int8] 441 secp flags[secp_flags, int8] 442 al int32 443 resv4 array[int8, 16] 444 } 445 446 nvme_dbbuf { 447 opcode const[nvme_admin_dbbuf, int8] 448 flags int8 449 command_id int16 450 rsvd1 array[const[0, int32], 5] 451 prp1 int64 452 prp2 int64 453 rsvd12 array[const[0, int32], 6] 454 } 455 456 nvme_directive_cmd { 457 opcode flags[nvme_admin_directive_opcodes, int8] 458 flags int8 459 command_id int16 460 nsid int32 461 rsvd2 array[const[0, int64], 2] 462 dptr nvme_data_ptr 463 numd int32 464 doper int8 465 dtype int8 466 dspec int16 467 endir int8 468 tdtype int8 469 rsvd15 const[0, int16] 470 rsvd16 array[int32, 3] 471 } 472 473 nvme_admin_directive_opcodes = nvme_admin_directive_send, nvme_admin_directive_recv 474 ##################### 475 ##################### 476 477 nvme_delete_queue { 478 opcode const[nvme_admin_delete_cq, int8] 479 flags int8 480 command_id int16 481 rsvd1 array[const[0, int32], 9] 482 qid int16 483 rsvd10 const[0, int16] 484 rsvd11 array[const[0, int32], 5] 485 } 486 487 nvme_create_sq { 488 opcode const[nvme_admin_create_sq, int8] 489 flags int8 490 command_id int16 491 rsvd1 array[const[0, int32], 5] 492 prp1 int64 493 rsvd8 const[0, int64] 494 sqid int16 495 qsize int16 496 sq_flags int16 497 cqid int16 498 rsvd12 array[const[0, int32], 4] 499 } 500 501 nvme_create_cq { 502 opcode const[nvme_admin_create_cq, int8] 503 flags int8 504 command_id int16 505 rsvd1 array[const[0, int32], 5] 506 prp1 int64 507 rsvd8 const[0, int64] 508 cqid int16 509 qsize int16 510 cq_flags int16 511 irq_vector int16 512 rsvd12 array[const[0, int32], 4] 513 } 514 515 nvme_features { 516 opcode flags[nvme_features_opcodes, int8] 517 flags int8 518 command_id int16 519 nsid int32 520 rsvd2 array[const[0, int64], 2] 521 dptr nvme_data_ptr 522 fid int32 523 dword11 int32 524 dword12 int32 525 dword13 int32 526 dword14 int32 527 dword15 int32 528 } 529 530 nvme_features_opcodes = nvme_admin_set_features, nvme_admin_get_features 531 532 nvme_identify { 533 opcode const[nvme_admin_identify, int8] 534 flags int8 535 command_id int16 536 nsid int32 537 rsvd2 array[const[0, int64], 2] 538 dptr nvme_data_ptr 539 cns int8 540 rsvd3 const[0, int8] 541 ctrlid int16 542 rsvd11 array[const[0, int8], 3] 543 csi int8 544 rsvd12 array[const[0, int32], 4] 545 } 546 547 nvme_common_command { 548 opcode flags[nvme_common_command_opcodes, int8] 549 flags int8 550 command_id int16 551 nsid int32 552 cdw2 array[int32, 2] 553 metadata int64 554 dptr nvme_data_ptr 555 cdws cdws_struct_group 556 } 557 558 nvme_common_command_opcodes = nvme_cmd_resv_report, nvme_fabrics_command, nvme_cmd_write, nvme_admin_async_event, nvme_cmd_flush, nvme_cmd_read, nvme_cmd_write_zeroes, nvme_cmd_dsm, nvme_admin_security_recv, nvme_admin_security_send, nvme_cmd_flush, nvme_admin_get_log_page, nvme_admin_identify, nvme_admin_abort_cmd, nvme_admin_set_features, nvme_admin_get_features, nvme_admin_async_event, nvme_admin_keep_alive 559 560 cdws_struct_group [ 561 cdws_anon cdws_anon_struct 562 cdws cdws_anon_struct 563 ] 564 565 cdws_anon_struct { 566 cdw10 int32 567 cdw11 int32 568 cdw12 int32 569 cdw13 int32 570 cdw14 int32 571 cdw15 int32 572 } 573 574 nvme_data_ptr [ 575 anon_struct nvme_data_ptr_anon_struct 576 sgl nvme_sgl_desc 577 ksgl nvme_keyed_sgl_desc 578 ] 579 580 nvme_data_ptr_anon_struct { 581 prp1 int64 582 prp2 int64 583 } [packed] 584 585 nvme_sgl_desc { 586 addr int64 587 length int32 588 rsvd array[const[0, int8], 3] 589 type int8 590 } [packed] 591 592 nvme_keyed_sgl_desc { 593 addr int64 594 length array[int8, 3] 595 key array[int8, 4] 596 type int8 597 } [packed] 598 599 nvme_rw_command { 600 opcode flags[nvme_opcodes_rw, int8] 601 flags int8 602 command_id int16 603 nsid int32 604 cdw2 int32 605 cdw3 int32 606 metadata int64 607 dptr nvme_data_ptr 608 slba int64 609 length int16 610 control int16 611 dsmgmt int32 612 reftag int32 613 apptag int16 614 appmask int16 615 } 616 617 nvme_opcodes_rw = nvme_cmd_write, nvme_cmd_read, nvme_cmd_zone_append 618 619 ### End of nvme_tcp_cmd_pdu ### 620 ######################################### 621 622 ######################################### 623 624 resource nvme_sock[sock] 625 626 syz_socket_connect_nvme_tcp() nvme_sock 627 628 sendto$inet_nvme_of_msg(fd nvme_sock, pdu ptr[in, nvme_of_msg], len len[pdu], f const[0], addr const[0], addrlen const[0]) 629 sendto$inet_nvme_pdu(fd nvme_sock, pdu ptr[in, nvme_tcp_pdu], len len[pdu], f const[0], addr const[0], addrlen const[0]) 630 sendto$inet_nvme_icreq_pdu(fd nvme_sock, pdu ptr[in, nvme_tcp_icreq_pdu], len len[pdu], f const[0], addr const[0], addrlen const[0]) 631 recvmsg$inet_nvme(fd nvme_sock, msg ptr[inout, recv_msghdr], f flags[recv_flags]) 632 recvfrom$inet_nvme(fd nvme_sock, buf buffer[out], len len[buf], f flags[recv_flags], addr ptr[in, sockaddr_storage, opt], addrlen len[addr])