net/vhost-vdpa: Report hashing capability
Report hashing capability so that virtio-net can deliver the correct capability information to the guest. Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com> Message-Id: <20250530-vdpa-v1-2-5af4109b1c19@daynix.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
parent
52f45faa4f
commit
14f521f491
3 changed files with 40 additions and 0 deletions
|
|
@ -60,6 +60,7 @@ typedef bool (HasVnetHdrLen)(NetClientState *, int);
|
|||
typedef void (SetOffload)(NetClientState *, int, int, int, int, int, int, int);
|
||||
typedef int (GetVnetHdrLen)(NetClientState *);
|
||||
typedef void (SetVnetHdrLen)(NetClientState *, int);
|
||||
typedef bool (GetVnetHashSupportedTypes)(NetClientState *, uint32_t *);
|
||||
typedef int (SetVnetLE)(NetClientState *, bool);
|
||||
typedef int (SetVnetBE)(NetClientState *, bool);
|
||||
typedef struct SocketReadState SocketReadState;
|
||||
|
|
@ -89,6 +90,7 @@ typedef struct NetClientInfo {
|
|||
SetVnetHdrLen *set_vnet_hdr_len;
|
||||
SetVnetLE *set_vnet_le;
|
||||
SetVnetBE *set_vnet_be;
|
||||
GetVnetHashSupportedTypes *get_vnet_hash_supported_types;
|
||||
NetAnnounce *announce;
|
||||
SetSteeringEBPF *set_steering_ebpf;
|
||||
NetCheckPeerType *check_peer_type;
|
||||
|
|
@ -189,6 +191,7 @@ void qemu_set_offload(NetClientState *nc, int csum, int tso4, int tso6,
|
|||
int ecn, int ufo, int uso4, int uso6);
|
||||
int qemu_get_vnet_hdr_len(NetClientState *nc);
|
||||
void qemu_set_vnet_hdr_len(NetClientState *nc, int len);
|
||||
bool qemu_get_vnet_hash_supported_types(NetClientState *nc, uint32_t *types);
|
||||
int qemu_set_vnet_le(NetClientState *nc, bool is_le);
|
||||
int qemu_set_vnet_be(NetClientState *nc, bool is_be);
|
||||
void qemu_macaddr_default_if_unset(MACAddr *macaddr);
|
||||
|
|
|
|||
|
|
@ -573,6 +573,15 @@ void qemu_set_vnet_hdr_len(NetClientState *nc, int len)
|
|||
nc->info->set_vnet_hdr_len(nc, len);
|
||||
}
|
||||
|
||||
bool qemu_get_vnet_hash_supported_types(NetClientState *nc, uint32_t *types)
|
||||
{
|
||||
if (!nc || !nc->info->get_vnet_hash_supported_types) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return nc->info->get_vnet_hash_supported_types(nc, types);
|
||||
}
|
||||
|
||||
int qemu_set_vnet_le(NetClientState *nc, bool is_le)
|
||||
{
|
||||
#if HOST_BIG_ENDIAN
|
||||
|
|
|
|||
|
|
@ -252,6 +252,32 @@ static bool vhost_vdpa_has_vnet_hdr(NetClientState *nc)
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool vhost_vdpa_get_vnet_hash_supported_types(NetClientState *nc,
|
||||
uint32_t *types)
|
||||
{
|
||||
assert(nc->info->type == NET_CLIENT_DRIVER_VHOST_VDPA);
|
||||
VhostVDPAState *s = DO_UPCAST(VhostVDPAState, nc, nc);
|
||||
uint64_t features = s->vhost_vdpa.dev->features;
|
||||
int fd = s->vhost_vdpa.shared->device_fd;
|
||||
struct {
|
||||
struct vhost_vdpa_config hdr;
|
||||
uint32_t supported_hash_types;
|
||||
} config;
|
||||
|
||||
if (!virtio_has_feature(features, VIRTIO_NET_F_HASH_REPORT) &&
|
||||
!virtio_has_feature(features, VIRTIO_NET_F_RSS)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
config.hdr.off = offsetof(struct virtio_net_config, supported_hash_types);
|
||||
config.hdr.len = sizeof(config.supported_hash_types);
|
||||
|
||||
assert(!ioctl(fd, VHOST_VDPA_GET_CONFIG, &config));
|
||||
*types = le32_to_cpu(config.supported_hash_types);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool vhost_vdpa_has_ufo(NetClientState *nc)
|
||||
{
|
||||
assert(nc->info->type == NET_CLIENT_DRIVER_VHOST_VDPA);
|
||||
|
|
@ -428,6 +454,7 @@ static NetClientInfo net_vhost_vdpa_info = {
|
|||
.stop = vhost_vdpa_net_client_stop,
|
||||
.cleanup = vhost_vdpa_cleanup,
|
||||
.has_vnet_hdr = vhost_vdpa_has_vnet_hdr,
|
||||
.get_vnet_hash_supported_types = vhost_vdpa_get_vnet_hash_supported_types,
|
||||
.has_ufo = vhost_vdpa_has_ufo,
|
||||
.set_vnet_le = vhost_vdpa_set_vnet_le,
|
||||
.check_peer_type = vhost_vdpa_check_peer_type,
|
||||
|
|
@ -1284,6 +1311,7 @@ static NetClientInfo net_vhost_vdpa_cvq_info = {
|
|||
.stop = vhost_vdpa_net_cvq_stop,
|
||||
.cleanup = vhost_vdpa_cleanup,
|
||||
.has_vnet_hdr = vhost_vdpa_has_vnet_hdr,
|
||||
.get_vnet_hash_supported_types = vhost_vdpa_get_vnet_hash_supported_types,
|
||||
.has_ufo = vhost_vdpa_has_ufo,
|
||||
.check_peer_type = vhost_vdpa_check_peer_type,
|
||||
.set_steering_ebpf = vhost_vdpa_set_steering_ebpf,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue