Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

common/virtio_mi: Submit admin cmd again if returen EAGAIN #22

Merged
merged 1 commit into from
Oct 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions drivers/common/virtio/virtio_admin.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,21 +94,21 @@ struct virtio_admin_hdr {

typedef uint8_t virtio_admin_status;

/* status values that are transport, device and vendor independent */
#define VIRTIO_ADMIN_STATUS_COMMON_START 0
#define VIRTIO_ADMIN_STATUS_COMMON_END 63
/* Status Code (SC) that are transport, device and vendor independent */
#define VIRTIO_ADMIN_STATUS_COMMON_START 0
#define VIRTIO_ADMIN_STATUS_COMMON_END 31

/* status values that are transport specific */
#define VIRTIO_ADMIN_STATUS_TRANSPORT_START 64
#define VIRTIO_ADMIN_STATUS_TRANSPORT_END 127
/* Status Code (SC) that are transport specific */
#define VIRTIO_ADMIN_STATUS_TRANSPORT_START 32
#define VIRTIO_ADMIN_STATUS_TRANSPORT_END 63

/* status values that are device specific */
#define VIRTIO_ADMIN_STATUS_DEVICE_START 128
#define VIRTIO_ADMIN_STATUS_DEVICE_END 191
/* Status Code (SC) that are device specific */
#define VIRTIO_ADMIN_STATUS_DEVICE_START 64
#define VIRTIO_ADMIN_STATUS_DEVICE_END 95

/* status values that are reserved */
#define VIRTIO_ADMIN_STATUS_RESERVED_START 192
#define VIRTIO_ADMIN_STATUS_RESERVED_END 255
/* Status Code (SC) that are reserved */
#define VIRTIO_ADMIN_STATUS_RESERVED_START 96
#define VIRTIO_ADMIN_STATUS_RESERVED_END 127

/* Common status values */
#define VIRTIO_ADMIN_STATUS_COMMON_OK 0
Expand Down
13 changes: 13 additions & 0 deletions drivers/common/virtio/virtqueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,19 @@ struct virtio_admin_ctrl_hdr {
uint8_t cmd;
} __rte_packed;

#define VIRTIO_ADMIN_CMD_RETRY_CNT 120
#define VIRTIO_ADMIN_CMD_STATUS_DNR_BIT 0x80

/*
* Bits (6:0) - Status Code (SC)
* Indicate status information for the command
*
* Bit (7) - Do Not Retry (DNR)
* If set to 1, indicates that if the same command is submitted
* again - it is expected to fail.
* If cleared to 0, indicates that the same command is submitted
* again may succeed.
*/
typedef uint8_t virtio_admin_ctrl_ack;

#define VIRTIO_MAX_ADMIN_DATA 2048
Expand Down
11 changes: 10 additions & 1 deletion drivers/common/virtio_mi/lm.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ virtio_vdpa_send_admin_command(struct virtadmin_ctl *avq,
virtio_admin_ctrl_ack status = ~0;
struct virtio_admin_ctrl *result;
struct virtqueue *vq;
int i;

if (!avq) {
DRV_LOG(ERR, "Admin queue is not supported");
Expand All @@ -202,8 +203,16 @@ virtio_vdpa_send_admin_command(struct virtadmin_ctl *avq,
return -1;
}

result = virtio_vdpa_send_admin_command_split(avq, ctrl, dat_ctrl,
for (i = 0; i < VIRTIO_ADMIN_CMD_RETRY_CNT; i++) {
result = virtio_vdpa_send_admin_command_split(avq, ctrl, dat_ctrl,
dlen, pkt_num);
if(result->status && (!(result->status & VIRTIO_ADMIN_CMD_STATUS_DNR_BIT))) {
DRV_LOG(DEBUG, "No:%d cmd status:0x%x, submit again after 100ms", i, result->status);
usleep(100000);
}
else
break;
}

return result->status;
}
Expand Down