Lines Matching full:pdu
149 nvmf_tcp_write_pdu(struct nvmf_tcp_qpair *qp, const void *pdu, size_t len) in nvmf_tcp_write_pdu() argument
154 cp = pdu; in nvmf_tcp_write_pdu()
223 nvmf_tcp_validate_pdu(struct nvmf_tcp_qpair *qp, struct nvmf_tcp_rxpdu *pdu, in nvmf_tcp_validate_pdu() argument
233 /* Determine how large of a PDU header to return for errors. */ in nvmf_tcp_validate_pdu()
234 ch = pdu->hdr; in nvmf_tcp_validate_pdu()
279 pdu->data_len = data_len; in nvmf_tcp_validate_pdu()
307 nvmf_tcp_read_pdu(struct nvmf_tcp_qpair *qp, struct nvmf_tcp_rxpdu *pdu) in nvmf_tcp_read_pdu() argument
313 memset(pdu, 0, sizeof(*pdu)); in nvmf_tcp_read_pdu()
325 pdu->hdr = &ch; in nvmf_tcp_read_pdu()
326 error = nvmf_tcp_validate_pdu(qp, pdu, sizeof(ch)); in nvmf_tcp_read_pdu()
327 pdu->hdr = NULL; in nvmf_tcp_read_pdu()
332 /* Read the rest of the PDU. */ in nvmf_tcp_read_pdu()
333 pdu->hdr = malloc(plen); in nvmf_tcp_read_pdu()
334 memcpy(pdu->hdr, &ch, sizeof(ch)); in nvmf_tcp_read_pdu()
335 error = nvmf_tcp_read_buffer(qp->s, pdu->hdr + 1, plen - sizeof(ch)); in nvmf_tcp_read_pdu()
338 error = nvmf_tcp_validate_pdu(qp, pdu, plen); in nvmf_tcp_read_pdu()
340 free(pdu->hdr); in nvmf_tcp_read_pdu()
341 pdu->hdr = NULL; in nvmf_tcp_read_pdu()
347 nvmf_tcp_free_pdu(struct nvmf_tcp_rxpdu *pdu) in nvmf_tcp_free_pdu() argument
349 free(pdu->hdr); in nvmf_tcp_free_pdu()
350 pdu->hdr = NULL; in nvmf_tcp_free_pdu()
354 nvmf_tcp_handle_term_req(struct nvmf_tcp_rxpdu *pdu) in nvmf_tcp_handle_term_req() argument
358 hdr = (void *)pdu->hdr; in nvmf_tcp_handle_term_req()
362 nvmf_tcp_free_pdu(pdu); in nvmf_tcp_handle_term_req()
368 struct nvmf_tcp_rxpdu *pdu) in nvmf_tcp_save_command_capsule() argument
374 cmd = (void *)pdu->hdr; in nvmf_tcp_save_command_capsule()
381 tc->rx_pdu = *pdu; in nvmf_tcp_save_command_capsule()
389 struct nvmf_tcp_rxpdu *pdu) in nvmf_tcp_save_response_capsule() argument
395 rsp = (void *)pdu->hdr; in nvmf_tcp_save_response_capsule()
403 tc->rx_pdu = *pdu; in nvmf_tcp_save_response_capsule()
418 * Construct and send a PDU that contains an optional data payload.
494 nvmf_tcp_handle_h2c_data(struct nvmf_tcp_qpair *qp, struct nvmf_tcp_rxpdu *pdu) in nvmf_tcp_handle_h2c_data() argument
501 h2c = (void *)pdu->hdr; in nvmf_tcp_handle_h2c_data()
505 pdu->hdr, le32toh(pdu->hdr->plen), pdu->hdr->hlen); in nvmf_tcp_handle_h2c_data()
506 nvmf_tcp_free_pdu(pdu); in nvmf_tcp_handle_h2c_data()
514 offsetof(struct nvme_tcp_h2c_data_hdr, ttag), pdu->hdr, in nvmf_tcp_handle_h2c_data()
515 le32toh(pdu->hdr->plen), pdu->hdr->hlen); in nvmf_tcp_handle_h2c_data()
516 nvmf_tcp_free_pdu(pdu); in nvmf_tcp_handle_h2c_data()
521 if (data_len != pdu->data_len) { in nvmf_tcp_handle_h2c_data()
524 offsetof(struct nvme_tcp_h2c_data_hdr, datal), pdu->hdr, in nvmf_tcp_handle_h2c_data()
525 le32toh(pdu->hdr->plen), pdu->hdr->hlen); in nvmf_tcp_handle_h2c_data()
526 nvmf_tcp_free_pdu(pdu); in nvmf_tcp_handle_h2c_data()
535 pdu->hdr, le32toh(pdu->hdr->plen), pdu->hdr->hlen); in nvmf_tcp_handle_h2c_data()
536 nvmf_tcp_free_pdu(pdu); in nvmf_tcp_handle_h2c_data()
542 NVME_TCP_TERM_REQ_FES_PDU_SEQUENCE_ERROR, 0, pdu->hdr, in nvmf_tcp_handle_h2c_data()
543 le32toh(pdu->hdr->plen), pdu->hdr->hlen); in nvmf_tcp_handle_h2c_data()
544 nvmf_tcp_free_pdu(pdu); in nvmf_tcp_handle_h2c_data()
549 ((pdu->hdr->flags & NVME_TCP_H2C_DATA_FLAGS_LAST_PDU) != 0)) { in nvmf_tcp_handle_h2c_data()
551 NVME_TCP_TERM_REQ_FES_PDU_SEQUENCE_ERROR, 0, pdu->hdr, in nvmf_tcp_handle_h2c_data()
552 le32toh(pdu->hdr->plen), pdu->hdr->hlen); in nvmf_tcp_handle_h2c_data()
553 nvmf_tcp_free_pdu(pdu); in nvmf_tcp_handle_h2c_data()
559 icd = (const char *)pdu->hdr + pdu->hdr->pdo; in nvmf_tcp_handle_h2c_data()
562 nvmf_tcp_free_pdu(pdu); in nvmf_tcp_handle_h2c_data()
567 nvmf_tcp_handle_c2h_data(struct nvmf_tcp_qpair *qp, struct nvmf_tcp_rxpdu *pdu) in nvmf_tcp_handle_c2h_data() argument
574 c2h = (void *)pdu->hdr; in nvmf_tcp_handle_c2h_data()
579 * XXX: Could be PDU sequence error if cccid is for a in nvmf_tcp_handle_c2h_data()
584 offsetof(struct nvme_tcp_c2h_data_hdr, cccid), pdu->hdr, in nvmf_tcp_handle_c2h_data()
585 le32toh(pdu->hdr->plen), pdu->hdr->hlen); in nvmf_tcp_handle_c2h_data()
586 nvmf_tcp_free_pdu(pdu); in nvmf_tcp_handle_c2h_data()
591 if (data_len != pdu->data_len) { in nvmf_tcp_handle_c2h_data()
594 offsetof(struct nvme_tcp_c2h_data_hdr, datal), pdu->hdr, in nvmf_tcp_handle_c2h_data()
595 le32toh(pdu->hdr->plen), pdu->hdr->hlen); in nvmf_tcp_handle_c2h_data()
596 nvmf_tcp_free_pdu(pdu); in nvmf_tcp_handle_c2h_data()
605 pdu->hdr, le32toh(pdu->hdr->plen), pdu->hdr->hlen); in nvmf_tcp_handle_c2h_data()
606 nvmf_tcp_free_pdu(pdu); in nvmf_tcp_handle_c2h_data()
612 NVME_TCP_TERM_REQ_FES_PDU_SEQUENCE_ERROR, 0, pdu->hdr, in nvmf_tcp_handle_c2h_data()
613 le32toh(pdu->hdr->plen), pdu->hdr->hlen); in nvmf_tcp_handle_c2h_data()
614 nvmf_tcp_free_pdu(pdu); in nvmf_tcp_handle_c2h_data()
619 ((pdu->hdr->flags & NVME_TCP_C2H_DATA_FLAGS_LAST_PDU) != 0)) { in nvmf_tcp_handle_c2h_data()
621 NVME_TCP_TERM_REQ_FES_PDU_SEQUENCE_ERROR, 0, pdu->hdr, in nvmf_tcp_handle_c2h_data()
622 le32toh(pdu->hdr->plen), pdu->hdr->hlen); in nvmf_tcp_handle_c2h_data()
623 nvmf_tcp_free_pdu(pdu); in nvmf_tcp_handle_c2h_data()
629 icd = (const char *)pdu->hdr + pdu->hdr->pdo; in nvmf_tcp_handle_c2h_data()
632 if ((pdu->hdr->flags & NVME_TCP_C2H_DATA_FLAGS_SUCCESS) != 0) { in nvmf_tcp_handle_c2h_data()
642 nvmf_tcp_free_pdu(pdu); in nvmf_tcp_handle_c2h_data()
651 nvmf_tcp_free_pdu(pdu); in nvmf_tcp_handle_c2h_data()
700 nvmf_tcp_handle_r2t(struct nvmf_tcp_qpair *qp, struct nvmf_tcp_rxpdu *pdu) in nvmf_tcp_handle_r2t() argument
707 r2t = (void *)pdu->hdr; in nvmf_tcp_handle_r2t()
713 offsetof(struct nvme_tcp_r2t_hdr, cccid), pdu->hdr, in nvmf_tcp_handle_r2t()
714 le32toh(pdu->hdr->plen), pdu->hdr->hlen); in nvmf_tcp_handle_r2t()
715 nvmf_tcp_free_pdu(pdu); in nvmf_tcp_handle_r2t()
722 NVME_TCP_TERM_REQ_FES_PDU_SEQUENCE_ERROR, 0, pdu->hdr, in nvmf_tcp_handle_r2t()
723 le32toh(pdu->hdr->plen), pdu->hdr->hlen); in nvmf_tcp_handle_r2t()
724 nvmf_tcp_free_pdu(pdu); in nvmf_tcp_handle_r2t()
736 pdu->hdr, le32toh(pdu->hdr->plen), pdu->hdr->hlen); in nvmf_tcp_handle_r2t()
737 nvmf_tcp_free_pdu(pdu); in nvmf_tcp_handle_r2t()
750 nvmf_tcp_free_pdu(pdu); in nvmf_tcp_handle_r2t()
757 struct nvmf_tcp_rxpdu pdu; in nvmf_tcp_receive_pdu() local
760 error = nvmf_tcp_read_pdu(qp, &pdu); in nvmf_tcp_receive_pdu()
764 switch (pdu.hdr->pdu_type) { in nvmf_tcp_receive_pdu()
770 return (nvmf_tcp_handle_term_req(&pdu)); in nvmf_tcp_receive_pdu()
772 return (nvmf_tcp_save_command_capsule(qp, &pdu)); in nvmf_tcp_receive_pdu()
774 return (nvmf_tcp_save_response_capsule(qp, &pdu)); in nvmf_tcp_receive_pdu()
776 return (nvmf_tcp_handle_h2c_data(qp, &pdu)); in nvmf_tcp_receive_pdu()
778 return (nvmf_tcp_handle_c2h_data(qp, &pdu)); in nvmf_tcp_receive_pdu()
780 return (nvmf_tcp_handle_r2t(qp, &pdu)); in nvmf_tcp_receive_pdu()
788 const struct nvme_tcp_ic_req *pdu; in nvmf_tcp_validate_ic_pdu() local
792 /* Determine how large of a PDU header to return for errors. */ in nvmf_tcp_validate_ic_pdu()
805 /* Controllers only receive PDUs with a PDU direction of 0. */ in nvmf_tcp_validate_ic_pdu()
807 na_error(na, "NVMe/TCP: Invalid PDU type %u", ch->pdu_type); in nvmf_tcp_validate_ic_pdu()
819 na_error(na, "NVMe/TCP: Invalid PDU type %u", ch->pdu_type); in nvmf_tcp_validate_ic_pdu()
828 na_error(na, "NVMe/TCP: Invalid PDU header flags %#x", in nvmf_tcp_validate_ic_pdu()
838 na_error(na, "NVMe/TCP: Invalid PDU header length %u", in nvmf_tcp_validate_ic_pdu()
848 na_error(na, "NVMe/TCP: Invalid PDU data offset %u", ch->pdo); in nvmf_tcp_validate_ic_pdu()
857 na_error(na, "NVMe/TCP: Invalid PDU length %u", plen); in nvmf_tcp_validate_ic_pdu()
865 pdu = (const struct nvme_tcp_ic_req *)ch; in nvmf_tcp_validate_ic_pdu()
866 if (le16toh(pdu->pfv) != 0) { in nvmf_tcp_validate_ic_pdu()
867 na_error(na, "NVMe/TCP: Unsupported PDU version %u", in nvmf_tcp_validate_ic_pdu()
868 le16toh(pdu->pfv)); in nvmf_tcp_validate_ic_pdu()
875 if (pdu->hpda > NVME_TCP_HPDA_MAX) { in nvmf_tcp_validate_ic_pdu()
876 na_error(na, "NVMe/TCP: Unsupported PDA %u", pdu->hpda); in nvmf_tcp_validate_ic_pdu()
883 if (pdu->dgst.bits.reserved != 0) { in nvmf_tcp_validate_ic_pdu()
896 struct nvme_tcp_ic_req *pdu) in nvmf_tcp_read_ic_req() argument
900 error = nvmf_tcp_read_buffer(qp->s, pdu, sizeof(*pdu)); in nvmf_tcp_read_ic_req()
907 return (nvmf_tcp_validate_ic_pdu(na, qp, &pdu->common, sizeof(*pdu))); in nvmf_tcp_read_ic_req()
912 struct nvme_tcp_ic_resp *pdu) in nvmf_tcp_read_ic_resp() argument
916 error = nvmf_tcp_read_buffer(qp->s, pdu, sizeof(*pdu)); in nvmf_tcp_read_ic_resp()
923 return (nvmf_tcp_validate_ic_pdu(na, qp, &pdu->common, sizeof(*pdu))); in nvmf_tcp_read_ic_resp()
1439 * Each PDU is arbitrarily capped at 256k. in tcp_send_controller_data()