nvmf/vfio-user: failure should return -1 with errno set
This is required by libvfio-user APIs. Change-Id: I675a3be0a9650d146c8d37e42debf1191656903b Signed-off-by: John Levon <john.levon@nutanix.com> Signed-off-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/7472 Community-CI: Broadcom CI Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com> Reviewed-by: <dongx.yi@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
3df11166e7
commit
1f5cb5b1ae
@ -1264,7 +1264,8 @@ handle_dbl_access(struct nvmf_vfio_user_ctrlr *ctrlr, uint32_t *buf,
|
|||||||
if (count != sizeof(uint32_t)) {
|
if (count != sizeof(uint32_t)) {
|
||||||
SPDK_ERRLOG("%s: bad doorbell buffer size %ld\n",
|
SPDK_ERRLOG("%s: bad doorbell buffer size %ld\n",
|
||||||
ctrlr_id(ctrlr), count);
|
ctrlr_id(ctrlr), count);
|
||||||
return -EINVAL;
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
pos -= NVMF_VFIO_USER_DOORBELLS_OFFSET;
|
pos -= NVMF_VFIO_USER_DOORBELLS_OFFSET;
|
||||||
@ -1272,7 +1273,8 @@ handle_dbl_access(struct nvmf_vfio_user_ctrlr *ctrlr, uint32_t *buf,
|
|||||||
/* pos must be dword aligned */
|
/* pos must be dword aligned */
|
||||||
if ((pos & 0x3) != 0) {
|
if ((pos & 0x3) != 0) {
|
||||||
SPDK_ERRLOG("%s: bad doorbell offset %#lx\n", ctrlr_id(ctrlr), pos);
|
SPDK_ERRLOG("%s: bad doorbell offset %#lx\n", ctrlr_id(ctrlr), pos);
|
||||||
return -EINVAL;
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* convert byte offset to array index */
|
/* convert byte offset to array index */
|
||||||
@ -1284,7 +1286,8 @@ handle_dbl_access(struct nvmf_vfio_user_ctrlr *ctrlr, uint32_t *buf,
|
|||||||
* asynchronous event
|
* asynchronous event
|
||||||
*/
|
*/
|
||||||
SPDK_ERRLOG("%s: bad doorbell index %#lx\n", ctrlr_id(ctrlr), pos);
|
SPDK_ERRLOG("%s: bad doorbell index %#lx\n", ctrlr_id(ctrlr), pos);
|
||||||
return -EINVAL;
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_write) {
|
if (is_write) {
|
||||||
@ -1325,13 +1328,14 @@ access_bar0_fn(vfu_ctx_t *vfu_ctx, char *buf, size_t count, loff_t pos,
|
|||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
assert(ret < 0);
|
assert(errno != 0);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Construct a Fabric Property Get/Set command and send it */
|
/* Construct a Fabric Property Get/Set command and send it */
|
||||||
req = get_nvmf_vfio_user_req(ctrlr->qp[0]);
|
req = get_nvmf_vfio_user_req(ctrlr->qp[0]);
|
||||||
if (req == NULL) {
|
if (req == NULL) {
|
||||||
|
errno = ENOBUFS;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1373,14 +1377,16 @@ access_pci_config(vfu_ctx_t *vfu_ctx, char *buf, size_t count, loff_t offset,
|
|||||||
if (is_write) {
|
if (is_write) {
|
||||||
SPDK_ERRLOG("%s: write %#lx-%#lx not supported\n",
|
SPDK_ERRLOG("%s: write %#lx-%#lx not supported\n",
|
||||||
endpoint_id(endpoint), offset, offset + count);
|
endpoint_id(endpoint), offset, offset + count);
|
||||||
return -EINVAL;
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (offset + count > PCI_CFG_SPACE_EXP_SIZE) {
|
if (offset + count > PCI_CFG_SPACE_EXP_SIZE) {
|
||||||
SPDK_ERRLOG("%s: access past end of extended PCI configuration space, want=%ld+%ld, max=%d\n",
|
SPDK_ERRLOG("%s: access past end of extended PCI configuration space, want=%ld+%ld, max=%d\n",
|
||||||
endpoint_id(endpoint), offset, count,
|
endpoint_id(endpoint), offset, count,
|
||||||
PCI_CFG_SPACE_EXP_SIZE);
|
PCI_CFG_SPACE_EXP_SIZE);
|
||||||
return -ERANGE;
|
errno = ERANGE;
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(buf, ((unsigned char *)endpoint->pci_config_space) + offset, count);
|
memcpy(buf, ((unsigned char *)endpoint->pci_config_space) + offset, count);
|
||||||
|
Loading…
Reference in New Issue
Block a user