@@ -92,7 +92,7 @@ vhost_kernel_ioctl(int fd, uint64_t request, void *arg)
ret = ioctl(fd, request, arg);
if (ret) {
PMD_DRV_LOG(ERR, "Vhost-kernel ioctl %"PRIu64" failed (%s)",
- request, strerror(errno));
+ request, rte_strerror(errno));
return -1;
}
@@ -428,7 +428,7 @@ vhost_kernel_setup(struct virtio_user_dev *dev)
for (i = 0; i < dev->max_queue_pairs; ++i) {
vhostfd = open(dev->path, O_RDWR);
if (vhostfd < 0) {
- PMD_DRV_LOG(ERR, "fail to open %s, %s", dev->path, strerror(errno));
+ PMD_DRV_LOG(ERR, "fail to open %s, %s", dev->path, rte_strerror(errno));
goto err_tapfds;
}
data->vhostfds[i] = vhostfd;
@@ -511,14 +511,14 @@ vhost_kernel_set_backend(int vhostfd, int tapfd)
f.index = 0;
if (ioctl(vhostfd, VHOST_NET_SET_BACKEND, &f) < 0) {
PMD_DRV_LOG(ERR, "VHOST_NET_SET_BACKEND fails, %s",
- strerror(errno));
+ rte_strerror(errno));
return -1;
}
f.index = 1;
if (ioctl(vhostfd, VHOST_NET_SET_BACKEND, &f) < 0) {
PMD_DRV_LOG(ERR, "VHOST_NET_SET_BACKEND fails, %s",
- strerror(errno));
+ rte_strerror(errno));
return -1;
}
@@ -13,6 +13,7 @@
#include <limits.h>
#include <rte_ether.h>
+#include <rte_errno.h>
#include "vhost_kernel_tap.h"
#include "../virtio_logs.h"
@@ -27,12 +28,12 @@ tap_support_features(unsigned int *tap_features)
tapfd = open(PATH_NET_TUN, O_RDWR);
if (tapfd < 0) {
PMD_DRV_LOG(ERR, "fail to open %s: %s",
- PATH_NET_TUN, strerror(errno));
+ PATH_NET_TUN, rte_strerror(errno));
return -1;
}
if (ioctl(tapfd, TUNGETFEATURES, tap_features) == -1) {
- PMD_DRV_LOG(ERR, "TUNGETFEATURES failed: %s", strerror(errno));
+ PMD_DRV_LOG(ERR, "TUNGETFEATURES failed: %s", rte_strerror(errno));
close(tapfd);
return -1;
}
@@ -49,11 +50,11 @@ tap_open(const char *ifname, unsigned int r_flags, bool multi_queue)
tapfd = open(PATH_NET_TUN, O_RDWR);
if (tapfd < 0) {
- PMD_DRV_LOG(ERR, "fail to open %s: %s", PATH_NET_TUN, strerror(errno));
+ PMD_DRV_LOG(ERR, "fail to open %s: %s", PATH_NET_TUN, rte_strerror(errno));
return -1;
}
if (fcntl(tapfd, F_SETFL, O_NONBLOCK) < 0) {
- PMD_DRV_LOG(ERR, "fcntl tapfd failed: %s", strerror(errno));
+ PMD_DRV_LOG(ERR, "fcntl tapfd failed: %s", rte_strerror(errno));
close(tapfd);
return -1;
}
@@ -68,12 +69,12 @@ tap_open(const char *ifname, unsigned int r_flags, bool multi_queue)
if (multi_queue) {
PMD_DRV_LOG(DEBUG,
"TUNSETIFF failed (will retry without IFF_MULTI_QUEUE): %s",
- strerror(errno));
+ rte_strerror(errno));
multi_queue = false;
goto retry_mono_q;
}
- PMD_DRV_LOG(ERR, "TUNSETIFF failed: %s", strerror(errno));
+ PMD_DRV_LOG(ERR, "TUNSETIFF failed: %s", rte_strerror(errno));
close(tapfd);
tapfd = -1;
}
@@ -88,7 +89,7 @@ tap_get_name(int tapfd, char **name)
memset(&ifr, 0, sizeof(ifr));
if (ioctl(tapfd, TUNGETIFF, (void *)&ifr) == -1) {
- PMD_DRV_LOG(ERR, "TUNGETIFF failed: %s", strerror(errno));
+ PMD_DRV_LOG(ERR, "TUNGETIFF failed: %s", rte_strerror(errno));
return -1;
}
ret = asprintf(name, "%s", ifr.ifr_name);
@@ -104,7 +105,7 @@ tap_get_flags(int tapfd, unsigned int *tap_flags)
memset(&ifr, 0, sizeof(ifr));
if (ioctl(tapfd, TUNGETIFF, (void *)&ifr) == -1) {
- PMD_DRV_LOG(ERR, "TUNGETIFF failed: %s", strerror(errno));
+ PMD_DRV_LOG(ERR, "TUNGETIFF failed: %s", rte_strerror(errno));
return -1;
}
*tap_flags = ifr.ifr_flags;
@@ -120,7 +121,7 @@ tap_set_mac(int tapfd, uint8_t *mac)
ifr.ifr_hwaddr.sa_family = ARPHRD_ETHER;
memcpy(ifr.ifr_hwaddr.sa_data, mac, RTE_ETHER_ADDR_LEN);
if (ioctl(tapfd, SIOCSIFHWADDR, (void *)&ifr) == -1) {
- PMD_DRV_LOG(ERR, "SIOCSIFHWADDR failed: %s", strerror(errno));
+ PMD_DRV_LOG(ERR, "SIOCSIFHWADDR failed: %s", rte_strerror(errno));
return -1;
}
return 0;
@@ -155,7 +156,7 @@ vhost_kernel_tap_set_offload(int fd, uint64_t features)
offload &= ~TUN_F_UFO;
if (ioctl(fd, TUNSETOFFLOAD, offload) != 0) {
PMD_DRV_LOG(ERR, "TUNSETOFFLOAD ioctl() failed: %s",
- strerror(errno));
+ rte_strerror(errno));
return -1;
}
}
@@ -175,12 +176,12 @@ vhost_kernel_tap_setup(int tapfd, int hdr_size, uint64_t features)
* max_mem_regions, supported in newer version linux kernel
*/
if (ioctl(tapfd, TUNSETVNETHDRSZ, &hdr_size) < 0) {
- PMD_DRV_LOG(ERR, "TUNSETVNETHDRSZ failed: %s", strerror(errno));
+ PMD_DRV_LOG(ERR, "TUNSETVNETHDRSZ failed: %s", rte_strerror(errno));
return -1;
}
if (ioctl(tapfd, TUNSETSNDBUF, &sndbuf) < 0) {
- PMD_DRV_LOG(ERR, "TUNSETSNDBUF failed: %s", strerror(errno));
+ PMD_DRV_LOG(ERR, "TUNSETSNDBUF failed: %s", rte_strerror(errno));
return -1;
}
@@ -136,7 +136,7 @@ vhost_user_write(int fd, struct vhost_user_msg *msg, int *fds, int fd_num)
} while (r < 0 && errno == EINTR);
if (r < 0)
- PMD_DRV_LOG(ERR, "Failed to send msg: %s", strerror(errno));
+ PMD_DRV_LOG(ERR, "Failed to send msg: %s", rte_strerror(errno));
return r;
}
@@ -149,7 +149,7 @@ vhost_user_read(int fd, struct vhost_user_msg *msg)
ret = recv(fd, (void *)msg, sz_hdr, 0);
if (ret < 0) {
- PMD_DRV_LOG(ERR, "Failed to recv msg header: %s", strerror(errno));
+ PMD_DRV_LOG(ERR, "Failed to recv msg header: %s", rte_strerror(errno));
return -1;
} else if (ret < sz_hdr) {
PMD_DRV_LOG(ERR, "Failed to recv msg hdr: %d instead of %d.",
@@ -175,7 +175,7 @@ vhost_user_read(int fd, struct vhost_user_msg *msg)
if (sz_payload) {
ret = recv(fd, (void *)((char *)msg + sz_hdr), sz_payload, 0);
if (ret < 0) {
- PMD_DRV_LOG(ERR, "Failed to recv msg payload: %s", strerror(errno));
+ PMD_DRV_LOG(ERR, "Failed to recv msg payload: %s", rte_strerror(errno));
return -1;
} else if (ret < sz_payload) {
PMD_DRV_LOG(ERR, "Failed to recv msg payload: %d instead of %u.",
@@ -750,7 +750,7 @@ vhost_user_start_server(struct virtio_user_dev *dev, struct sockaddr_un *un)
ret = bind(fd, (struct sockaddr *)un, sizeof(*un));
if (ret < 0) {
PMD_DRV_LOG(ERR, "failed to bind to %s: %s; remove it and try again",
- dev->path, strerror(errno));
+ dev->path, rte_strerror(errno));
return -1;
}
ret = listen(fd, MAX_VIRTIO_USER_BACKLOG);
@@ -761,13 +761,13 @@ vhost_user_start_server(struct virtio_user_dev *dev, struct sockaddr_un *un)
data->vhostfd = accept(fd, NULL, NULL);
if (data->vhostfd < 0) {
PMD_DRV_LOG(ERR, "Failed to accept initial client connection (%s)",
- strerror(errno));
+ rte_strerror(errno));
return -1;
}
flag = fcntl(fd, F_GETFL);
if (fcntl(fd, F_SETFL, flag | O_NONBLOCK) < 0) {
- PMD_DRV_LOG(ERR, "fcntl failed, %s", strerror(errno));
+ PMD_DRV_LOG(ERR, "fcntl failed, %s", rte_strerror(errno));
return -1;
}
@@ -835,15 +835,15 @@ vhost_user_setup(struct virtio_user_dev *dev)
fd = socket(AF_UNIX, SOCK_STREAM, 0);
if (fd < 0) {
- PMD_DRV_LOG(ERR, "socket() error, %s", strerror(errno));
+ PMD_DRV_LOG(ERR, "socket() error, %s", rte_strerror(errno));
goto err_data;
}
flag = fcntl(fd, F_GETFD);
if (flag == -1)
- PMD_DRV_LOG(WARNING, "fcntl get fd failed, %s", strerror(errno));
+ PMD_DRV_LOG(WARNING, "fcntl get fd failed, %s", rte_strerror(errno));
else if (fcntl(fd, F_SETFD, flag | FD_CLOEXEC) < 0)
- PMD_DRV_LOG(WARNING, "fcntl set fd failed, %s", strerror(errno));
+ PMD_DRV_LOG(WARNING, "fcntl set fd failed, %s", rte_strerror(errno));
memset(&un, 0, sizeof(un));
un.sun_family = AF_UNIX;
@@ -857,7 +857,7 @@ vhost_user_setup(struct virtio_user_dev *dev)
}
} else {
if (connect(fd, (struct sockaddr *)&un, sizeof(un)) < 0) {
- PMD_DRV_LOG(ERR, "connect error, %s", strerror(errno));
+ PMD_DRV_LOG(ERR, "connect error, %s", rte_strerror(errno));
goto err_socket;
}
data->vhostfd = fd;
@@ -93,7 +93,7 @@ vhost_vdpa_ioctl(int fd, uint64_t request, void *arg)
ret = ioctl(fd, request, arg);
if (ret) {
PMD_DRV_LOG(ERR, "Vhost-vDPA ioctl %"PRIu64" failed (%s)",
- request, strerror(errno));
+ request, rte_strerror(errno));
return -1;
}
@@ -187,7 +187,7 @@ vhost_vdpa_iotlb_batch_begin(struct virtio_user_dev *dev)
if (write(data->vhostfd, &msg, sizeof(msg)) != sizeof(msg)) {
PMD_DRV_LOG(ERR, "Failed to send IOTLB batch begin (%s)",
- strerror(errno));
+ rte_strerror(errno));
return -1;
}
@@ -213,7 +213,7 @@ vhost_vdpa_iotlb_batch_end(struct virtio_user_dev *dev)
if (write(data->vhostfd, &msg, sizeof(msg)) != sizeof(msg)) {
PMD_DRV_LOG(ERR, "Failed to send IOTLB batch end (%s)",
- strerror(errno));
+ rte_strerror(errno));
return -1;
}
@@ -244,7 +244,7 @@ vhost_vdpa_dma_map(struct virtio_user_dev *dev, void *addr,
if (write(data->vhostfd, &msg, sizeof(msg)) != sizeof(msg)) {
PMD_DRV_LOG(ERR, "Failed to send IOTLB update (%s)",
- strerror(errno));
+ rte_strerror(errno));
return -1;
}
@@ -273,7 +273,7 @@ vhost_vdpa_dma_unmap(struct virtio_user_dev *dev, __rte_unused void *addr,
if (write(data->vhostfd, &msg, sizeof(msg)) != sizeof(msg)) {
PMD_DRV_LOG(ERR, "Failed to send IOTLB invalidate (%s)",
- strerror(errno));
+ rte_strerror(errno));
return -1;
}
@@ -531,7 +531,7 @@ vhost_vdpa_setup(struct virtio_user_dev *dev)
data->vhostfd = open(dev->path, O_RDWR);
if (data->vhostfd < 0) {
PMD_DRV_LOG(ERR, "Failed to open %s: %s",
- dev->path, strerror(errno));
+ dev->path, rte_strerror(errno));
free(data);
return -1;
}
@@ -60,13 +60,13 @@ virtio_user_init_notify_queue(struct virtio_user_dev *dev, uint32_t queue_sel)
dev->callfds[queue_sel] = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK);
if (dev->callfds[queue_sel] < 0) {
PMD_DRV_LOG(ERR, "(%s) Failed to setup callfd for queue %u: %s",
- dev->path, queue_sel, strerror(errno));
+ dev->path, queue_sel, rte_strerror(errno));
return -1;
}
dev->kickfds[queue_sel] = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK);
if (dev->kickfds[queue_sel] < 0) {
PMD_DRV_LOG(ERR, "(%s) Failed to setup kickfd for queue %u: %s",
- dev->path, queue_sel, strerror(errno));
+ dev->path, queue_sel, rte_strerror(errno));
return -1;
}
@@ -1113,7 +1113,7 @@ virtio_user_control_queue_notify(struct virtqueue *vq, void *cookie)
if (!dev->notify_area) {
if (write(dev->kickfds[vq->vq_queue_index], ¬ify_data, sizeof(notify_data)) < 0)
PMD_DRV_LOG(ERR, "failed to kick backend: %s",
- strerror(errno));
+ rte_strerror(errno));
return;
} else if (!virtio_with_feature(&dev->hw, VIRTIO_F_NOTIFICATION_DATA)) {
rte_write16(vq->vq_queue_index, vq->notify_addr);
@@ -1358,7 +1358,7 @@ virtio_user_dev_server_reconnect(struct virtio_user_dev *dev)
if (dev->ops->get_features(dev, &dev->device_features) < 0) {
PMD_INIT_LOG(ERR, "get_features failed: %s",
- strerror(errno));
+ rte_strerror(errno));
return -1;
}
@@ -285,7 +285,7 @@ virtio_user_notify_queue(struct virtio_hw *hw, struct virtqueue *vq)
if (write(dev->kickfds[vq->vq_queue_index], ¬ify_data,
sizeof(notify_data)) < 0)
PMD_DRV_LOG(ERR, "failed to kick backend: %s",
- strerror(errno));
+ rte_strerror(errno));
return;
} else if (!virtio_with_feature(hw, VIRTIO_F_NOTIFICATION_DATA)) {
rte_write16(vq->vq_queue_index, vq->notify_addr);
@@ -417,7 +417,7 @@ vdpa_dynamic_major_num(void)
fp = fopen("/proc/devices", "r");
if (fp == NULL) {
PMD_INIT_LOG(ERR, "Cannot open /proc/devices: %s",
- strerror(errno));
+ rte_strerror(errno));
return UNNAMED_MAJOR;
}
@@ -444,7 +444,7 @@ virtio_user_backend_type(const char *path)
return VIRTIO_USER_BACKEND_VHOST_USER;
PMD_INIT_LOG(ERR, "Stat fails: %s (%s)", path,
- strerror(errno));
+ rte_strerror(errno));
return VIRTIO_USER_BACKEND_UNKNOWN;
}