mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 15:53:54 -06:00
net: multiqueue support
This patch adds basic multiqueue support for qemu. The idea is simple, an array of NetClientStates were introduced in NICState, parse_netdev() were extended to find and match all NetClientStates belongs to the backend and place their pointers in NICConf. Then qemu_new_nic can setup a N:N mapping between NICStates that belongs to a nic and NICStates belongs to the netdev. And a queue_index were introduced in NetClientState to track its index. After this, each peers of a NICState were abstracted as a queue. After this change, all NetClientState that belongs to the same backend/nic has the same id. When use want to change the link status, all NetClientStates that belongs to the same backend/nic will be also changed. When user want to delete a device or netdev, all NetClientStates that belongs to the same backend/nic will be deleted also. Changing or deleting an specific queue is not allowed. Signed-off-by: Jason Wang <jasowang@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
parent
f7860455fd
commit
1ceef9f273
6 changed files with 139 additions and 48 deletions
|
@ -9,24 +9,32 @@
|
|||
#include "migration/vmstate.h"
|
||||
#include "qapi-types.h"
|
||||
|
||||
#define MAX_QUEUE_NUM 1024
|
||||
|
||||
struct MACAddr {
|
||||
uint8_t a[6];
|
||||
};
|
||||
|
||||
/* qdev nic properties */
|
||||
|
||||
typedef struct NICPeers {
|
||||
NetClientState *ncs[MAX_QUEUE_NUM];
|
||||
} NICPeers;
|
||||
|
||||
typedef struct NICConf {
|
||||
MACAddr macaddr;
|
||||
NetClientState *peer;
|
||||
NICPeers peers;
|
||||
int32_t bootindex;
|
||||
int32_t queues;
|
||||
} NICConf;
|
||||
|
||||
#define DEFINE_NIC_PROPERTIES(_state, _conf) \
|
||||
DEFINE_PROP_MACADDR("mac", _state, _conf.macaddr), \
|
||||
DEFINE_PROP_VLAN("vlan", _state, _conf.peer), \
|
||||
DEFINE_PROP_NETDEV("netdev", _state, _conf.peer), \
|
||||
DEFINE_PROP_VLAN("vlan", _state, _conf.peers), \
|
||||
DEFINE_PROP_NETDEV("netdev", _state, _conf.peers), \
|
||||
DEFINE_PROP_INT32("bootindex", _state, _conf.bootindex, -1)
|
||||
|
||||
|
||||
/* Net clients */
|
||||
|
||||
typedef void (NetPoll)(NetClientState *, bool enable);
|
||||
|
@ -60,10 +68,11 @@ struct NetClientState {
|
|||
char info_str[256];
|
||||
unsigned receive_disabled : 1;
|
||||
NetClientDestructor *destructor;
|
||||
unsigned int queue_index;
|
||||
};
|
||||
|
||||
typedef struct NICState {
|
||||
NetClientState nc;
|
||||
NetClientState ncs[MAX_QUEUE_NUM];
|
||||
NICConf *conf;
|
||||
void *opaque;
|
||||
bool peer_deleted;
|
||||
|
@ -82,6 +91,7 @@ NICState *qemu_new_nic(NetClientInfo *info,
|
|||
const char *name,
|
||||
void *opaque);
|
||||
void qemu_del_nic(NICState *nic);
|
||||
NetClientState *qemu_get_subqueue(NICState *nic, int queue_index);
|
||||
NetClientState *qemu_get_queue(NICState *nic);
|
||||
NICState *qemu_get_nic(NetClientState *nc);
|
||||
void *qemu_get_nic_opaque(NetClientState *nc);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue