* [RFC] vDPA: Trying to make sense of config data
@ 2024-08-22 18:21 Carlos Bilbao
2024-08-23 14:51 ` Carlos Bilbao
0 siblings, 1 reply; 3+ messages in thread
From: Carlos Bilbao @ 2024-08-22 18:21 UTC (permalink / raw)
To: virtualization, mst, jasowang; +Cc: kvm, netdev, linux-kernel
Hello folks,
I'm using the code below to retrieve configuration data for my vDPA file
via ioctl. I get as output:
Configuration data (24 bytes):
5a c3 5f 68 48 a9 01 00 08 00 dc 05 00 00 00 00
00 00 00 00 00 00 00 00
ASCII representation:
Z._hH...................
Could a good Samaritan point me in the right direction for the docs I need
to understand these values and convert them to a human-readable format?
hank you in advance!
Regards,
Carlos
---
void check_config(int fd) {
uint32_t size;
struct vhost_vdpa_config *config;
uint8_t *buf;
if (ioctl(fd, VHOST_VDPA_GET_CONFIG_SIZE, &size) < 0) {
perror("ioctl failed");
return;
}
config = malloc(sizeof(struct vhost_vdpa_config) + size);
if (!config) {
perror("malloc failed");
return;
}
memset(config, 0, sizeof(struct vhost_vdpa_config) + size);
config->len = size;
config->off = 0;
buf = config->buf;
if (ioctl(fd, VHOST_VDPA_GET_CONFIG, config) < 0) {
perror("ioctl failed");
} else {
printf("Configuration data (%u bytes):\n", size);
/* Print the data in a human-readable format */
for (unsigned int i = 0; i < size; i++) {
if (i % 16 == 0 && i != 0) printf("\n");
printf("%02x ", buf[i]);
}
printf("\n");
printf("ASCII representation:\n");
for (unsigned int i = 0; i < size; i++) {
if (buf[i] >= 32 && buf[i] <= 126) {
printf("%c", buf[i]);
} else {
printf(".");
}
}
printf("\n");
}
free(config);
}
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFC] vDPA: Trying to make sense of config data
2024-08-22 18:21 [RFC] vDPA: Trying to make sense of config data Carlos Bilbao
@ 2024-08-23 14:51 ` Carlos Bilbao
2024-08-27 18:16 ` Michael S. Tsirkin
0 siblings, 1 reply; 3+ messages in thread
From: Carlos Bilbao @ 2024-08-23 14:51 UTC (permalink / raw)
To: virtualization, mst, jasowang; +Cc: kvm, netdev, linux-kernel
Hello again,
Answering my own question:
https://elixir.bootlin.com/linux/v6.10.2/source/include/uapi/linux/virtio_net.h#L92
Thanks, Carlos
On 8/22/24 1:21 PM, Carlos Bilbao wrote:
> Hello folks,
>
> I'm using the code below to retrieve configuration data for my vDPA file
> via ioctl. I get as output:
>
> Configuration data (24 bytes):
> 5a c3 5f 68 48 a9 01 00 08 00 dc 05 00 00 00 00
> 00 00 00 00 00 00 00 00
> ASCII representation:
> Z._hH...................
>
> Could a good Samaritan point me in the right direction for the docs I need
> to understand these values and convert them to a human-readable format?
> hank you in advance!
>
> Regards,
> Carlos
>
> ---
>
> void check_config(int fd) {
>
> uint32_t size;
> struct vhost_vdpa_config *config;
> uint8_t *buf;
>
> if (ioctl(fd, VHOST_VDPA_GET_CONFIG_SIZE, &size) < 0) {
> perror("ioctl failed");
> return;
> }
>
> config = malloc(sizeof(struct vhost_vdpa_config) + size);
> if (!config) {
> perror("malloc failed");
> return;
> }
>
> memset(config, 0, sizeof(struct vhost_vdpa_config) + size);
> config->len = size;
> config->off = 0;
>
> buf = config->buf;
>
> if (ioctl(fd, VHOST_VDPA_GET_CONFIG, config) < 0) {
> perror("ioctl failed");
> } else {
> printf("Configuration data (%u bytes):\n", size);
>
> /* Print the data in a human-readable format */
> for (unsigned int i = 0; i < size; i++) {
> if (i % 16 == 0 && i != 0) printf("\n");
> printf("%02x ", buf[i]);
> }
> printf("\n");
>
> printf("ASCII representation:\n");
> for (unsigned int i = 0; i < size; i++) {
> if (buf[i] >= 32 && buf[i] <= 126) {
> printf("%c", buf[i]);
> } else {
> printf(".");
> }
> }
> printf("\n");
> }
>
> free(config);
> }
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFC] vDPA: Trying to make sense of config data
2024-08-23 14:51 ` Carlos Bilbao
@ 2024-08-27 18:16 ` Michael S. Tsirkin
0 siblings, 0 replies; 3+ messages in thread
From: Michael S. Tsirkin @ 2024-08-27 18:16 UTC (permalink / raw)
To: Carlos Bilbao; +Cc: virtualization, jasowang, kvm, netdev, linux-kernel
On Fri, Aug 23, 2024 at 09:51:24AM -0500, Carlos Bilbao wrote:
> Hello again,
>
> Answering my own question:
>
> https://elixir.bootlin.com/linux/v6.10.2/source/include/uapi/linux/virtio_net.h#L92
>
> Thanks, Carlos
Right. kernel.org would be the official source for that header.
Or if you want it in english, that would be the virtio spec.
--
MST
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-08-27 18:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-22 18:21 [RFC] vDPA: Trying to make sense of config data Carlos Bilbao
2024-08-23 14:51 ` Carlos Bilbao
2024-08-27 18:16 ` Michael S. Tsirkin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).