mirror of https://github.com/xemu-project/xemu.git
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1 iQEcBAABAgAGBQJaCk9uAAoJEO8Ells5jWIRj+4H/iY9KX/YNuifChitg29e5GpF 0SCxCjI1bMtnRzAhGDS3YKoLbLo/pePR4sNnZgEvrc3kt+JXxabP1+suSsQQ39k+ 4Iv2qEMXBralmB6RkldjEMMTEz6VHW/bbCUnKqOZnHWVoZ71CO2n6mbaGljbY6ft qhPZ9dRKL9Lv8sPKr1hzlsI/b8mMulJ96PZIuwWTxEDoTmeyjCn7WAotPcccjUGt Vg3nMx2HphDpUctqrcmcA667pXgo4eUcRyxfVmdtxIvVR7Mox4Mave8nPch9WgzO XhDc0zd1MLoW2mv+lPiM0a9Y4VCXoHzQ/ZF+WSBMTsZ5P+jOTmaN2YrZq82v7bA= =Rgs2 -----END PGP SIGNATURE----- Merge remote-tracking branch 'remotes/jasowang/tags/net-pull-request' into staging # gpg: Signature made Tue 14 Nov 2017 02:05:34 GMT # gpg: using RSA key 0xEF04965B398D6211 # gpg: Good signature from "Jason Wang (Jason Wang on RedHat) <jasowang@redhat.com>" # gpg: WARNING: This key is not certified with sufficiently trusted signatures! # gpg: It is not certain that the signature belongs to the owner. # Primary key fingerprint: 215D 46F4 8246 689E C77F 3562 EF04 965B 398D 6211 * remotes/jasowang/tags/net-pull-request: net/socket: fix coverity issue Add new PCI ID for i82559a Fix eepro100 simple transmission mode colo: Consolidate the duplicate code chunk into a routine colo-compare: Fix comments colo-compare: compare the packet in a specified Connection colo-compare: Insert packet into the suitable position of packet queue directly net: fix check for number of parameters to -netdev socket Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
commit
9895606363
|
@ -132,6 +132,7 @@ typedef struct {
|
|||
const char *name;
|
||||
const char *desc;
|
||||
uint16_t device_id;
|
||||
uint16_t alt_device_id;
|
||||
uint8_t revision;
|
||||
uint16_t subsystem_vendor_id;
|
||||
uint16_t subsystem_id;
|
||||
|
@ -276,6 +277,7 @@ typedef struct {
|
|||
/* Quasi static device properties (no need to save them). */
|
||||
uint16_t stats_size;
|
||||
bool has_extended_tcb_support;
|
||||
bool use_alt_device_id;
|
||||
} EEPRO100State;
|
||||
|
||||
/* Word indices in EEPROM. */
|
||||
|
@ -774,23 +776,11 @@ static void tx_command(EEPRO100State *s)
|
|||
}
|
||||
assert(tcb_bytes <= sizeof(buf));
|
||||
while (size < tcb_bytes) {
|
||||
uint32_t tx_buffer_address = ldl_le_pci_dma(&s->dev, tbd_address);
|
||||
uint16_t tx_buffer_size = lduw_le_pci_dma(&s->dev, tbd_address + 4);
|
||||
#if 0
|
||||
uint16_t tx_buffer_el = lduw_le_pci_dma(&s->dev, tbd_address + 6);
|
||||
#endif
|
||||
if (tx_buffer_size == 0) {
|
||||
/* Prevent an endless loop. */
|
||||
logout("loop in %s:%u\n", __FILE__, __LINE__);
|
||||
break;
|
||||
}
|
||||
tbd_address += 8;
|
||||
TRACE(RXTX, logout
|
||||
("TBD (simplified mode): buffer address 0x%08x, size 0x%04x\n",
|
||||
tx_buffer_address, tx_buffer_size));
|
||||
tx_buffer_size = MIN(tx_buffer_size, sizeof(buf) - size);
|
||||
pci_dma_read(&s->dev, tx_buffer_address, &buf[size], tx_buffer_size);
|
||||
size += tx_buffer_size;
|
||||
tbd_address, tcb_bytes));
|
||||
pci_dma_read(&s->dev, tbd_address, &buf[size], tcb_bytes);
|
||||
size += tcb_bytes;
|
||||
}
|
||||
if (tbd_array == 0xffffffff) {
|
||||
/* Simplified mode. Was already handled by code above. */
|
||||
|
@ -1867,6 +1857,14 @@ static void e100_nic_realize(PCIDevice *pci_dev, Error **errp)
|
|||
|
||||
TRACE(OTHER, logout("\n"));
|
||||
|
||||
/* By default, the i82559a adapter uses the legacy PCI ID (for the
|
||||
* i82557). This allows the PCI ID to be changed to the alternate
|
||||
* i82559 ID if needed.
|
||||
*/
|
||||
if (s->use_alt_device_id && strcmp(info->name, "i82559a") == 0) {
|
||||
pci_config_set_device_id(s->dev.config, info->alt_device_id);
|
||||
}
|
||||
|
||||
s->device = info->device;
|
||||
|
||||
e100_pci_reset(s, &local_err);
|
||||
|
@ -1986,6 +1984,7 @@ static E100PCIDeviceInfo e100_devices[] = {
|
|||
.desc = "Intel i82559A Ethernet",
|
||||
.device = i82559A,
|
||||
.device_id = PCI_DEVICE_ID_INTEL_82557,
|
||||
.alt_device_id = PCI_DEVICE_ID_INTEL_82559,
|
||||
.revision = 0x06,
|
||||
.stats_size = 80,
|
||||
.has_extended_tcb_support = true,
|
||||
|
@ -2079,6 +2078,8 @@ static E100PCIDeviceInfo *eepro100_get_class(EEPRO100State *s)
|
|||
|
||||
static Property e100_properties[] = {
|
||||
DEFINE_NIC_PROPERTIES(EEPRO100State, conf),
|
||||
DEFINE_PROP_BOOL("x-use-alt-device-id", EEPRO100State, use_alt_device_id,
|
||||
true),
|
||||
DEFINE_PROP_END_OF_LIST(),
|
||||
};
|
||||
|
||||
|
|
|
@ -10,6 +10,10 @@
|
|||
.driver = "virtio-tablet-device",\
|
||||
.property = "wheel-axis",\
|
||||
.value = "false",\
|
||||
},{\
|
||||
.driver = "i82559a",\
|
||||
.property = "x-use-alt-device-id",\
|
||||
.value = "false",\
|
||||
},
|
||||
|
||||
#define HW_COMPAT_2_9 \
|
||||
|
|
|
@ -70,6 +70,7 @@ extern bool pci_available;
|
|||
/* Intel (0x8086) */
|
||||
#define PCI_DEVICE_ID_INTEL_82551IT 0x1209
|
||||
#define PCI_DEVICE_ID_INTEL_82557 0x1229
|
||||
#define PCI_DEVICE_ID_INTEL_82559 0x1030
|
||||
#define PCI_DEVICE_ID_INTEL_82801IR 0x2922
|
||||
|
||||
/* Red Hat / Qumranet (for QEMU) -- see pci-ids.txt */
|
||||
|
|
|
@ -112,11 +112,31 @@ static gint seq_sorter(Packet *a, Packet *b, gpointer data)
|
|||
return ntohl(atcp->th_seq) - ntohl(btcp->th_seq);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return 1 on success, if return 0 means the
|
||||
* packet will be dropped
|
||||
*/
|
||||
static int colo_insert_packet(GQueue *queue, Packet *pkt)
|
||||
{
|
||||
if (g_queue_get_length(queue) <= MAX_QUEUE_SIZE) {
|
||||
if (pkt->ip->ip_p == IPPROTO_TCP) {
|
||||
g_queue_insert_sorted(queue,
|
||||
pkt,
|
||||
(GCompareDataFunc)seq_sorter,
|
||||
NULL);
|
||||
} else {
|
||||
g_queue_push_tail(queue, pkt);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return 0 on success, if return -1 means the pkt
|
||||
* is unsupported(arp and ipv6) and will be sent later
|
||||
*/
|
||||
static int packet_enqueue(CompareState *s, int mode)
|
||||
static int packet_enqueue(CompareState *s, int mode, Connection **con)
|
||||
{
|
||||
ConnectionKey key;
|
||||
Packet *pkt = NULL;
|
||||
|
@ -149,32 +169,17 @@ static int packet_enqueue(CompareState *s, int mode)
|
|||
}
|
||||
|
||||
if (mode == PRIMARY_IN) {
|
||||
if (g_queue_get_length(&conn->primary_list) <=
|
||||
MAX_QUEUE_SIZE) {
|
||||
g_queue_push_tail(&conn->primary_list, pkt);
|
||||
if (conn->ip_proto == IPPROTO_TCP) {
|
||||
g_queue_sort(&conn->primary_list,
|
||||
(GCompareDataFunc)seq_sorter,
|
||||
NULL);
|
||||
}
|
||||
} else {
|
||||
if (!colo_insert_packet(&conn->primary_list, pkt)) {
|
||||
error_report("colo compare primary queue size too big,"
|
||||
"drop packet");
|
||||
}
|
||||
} else {
|
||||
if (g_queue_get_length(&conn->secondary_list) <=
|
||||
MAX_QUEUE_SIZE) {
|
||||
g_queue_push_tail(&conn->secondary_list, pkt);
|
||||
if (conn->ip_proto == IPPROTO_TCP) {
|
||||
g_queue_sort(&conn->secondary_list,
|
||||
(GCompareDataFunc)seq_sorter,
|
||||
NULL);
|
||||
}
|
||||
} else {
|
||||
if (!colo_insert_packet(&conn->secondary_list, pkt)) {
|
||||
error_report("colo compare secondary queue size too big,"
|
||||
"drop packet");
|
||||
}
|
||||
}
|
||||
con = &conn;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -475,7 +480,9 @@ static void colo_old_packet_check(void *opaque)
|
|||
|
||||
/*
|
||||
* Called from the compare thread on the primary
|
||||
* for compare connection
|
||||
* for compare packet with secondary list of the
|
||||
* specified connection when a new packet was
|
||||
* queued to it.
|
||||
*/
|
||||
static void colo_compare_connection(void *opaque, void *user_data)
|
||||
{
|
||||
|
@ -724,28 +731,30 @@ static void compare_set_vnet_hdr(Object *obj,
|
|||
static void compare_pri_rs_finalize(SocketReadState *pri_rs)
|
||||
{
|
||||
CompareState *s = container_of(pri_rs, CompareState, pri_rs);
|
||||
Connection *conn = NULL;
|
||||
|
||||
if (packet_enqueue(s, PRIMARY_IN)) {
|
||||
if (packet_enqueue(s, PRIMARY_IN, &conn)) {
|
||||
trace_colo_compare_main("primary: unsupported packet in");
|
||||
compare_chr_send(s,
|
||||
pri_rs->buf,
|
||||
pri_rs->packet_len,
|
||||
pri_rs->vnet_hdr_len);
|
||||
} else {
|
||||
/* compare connection */
|
||||
g_queue_foreach(&s->conn_list, colo_compare_connection, s);
|
||||
/* compare packet in the specified connection */
|
||||
colo_compare_connection(conn, s);
|
||||
}
|
||||
}
|
||||
|
||||
static void compare_sec_rs_finalize(SocketReadState *sec_rs)
|
||||
{
|
||||
CompareState *s = container_of(sec_rs, CompareState, sec_rs);
|
||||
Connection *conn = NULL;
|
||||
|
||||
if (packet_enqueue(s, SECONDARY_IN)) {
|
||||
if (packet_enqueue(s, SECONDARY_IN, &conn)) {
|
||||
trace_colo_compare_main("secondary: unsupported packet in");
|
||||
} else {
|
||||
/* compare connection */
|
||||
g_queue_foreach(&s->conn_list, colo_compare_connection, s);
|
||||
/* compare packet in the specified connection */
|
||||
colo_compare_connection(conn, s);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
18
net/colo.c
18
net/colo.c
|
@ -82,6 +82,14 @@ int parse_packet_early(Packet *pkt)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void extract_ip_and_port(uint32_t tmp_ports, ConnectionKey *key, Packet *pkt)
|
||||
{
|
||||
key->src = pkt->ip->ip_src;
|
||||
key->dst = pkt->ip->ip_dst;
|
||||
key->src_port = ntohs(tmp_ports >> 16);
|
||||
key->dst_port = ntohs(tmp_ports & 0xffff);
|
||||
}
|
||||
|
||||
void fill_connection_key(Packet *pkt, ConnectionKey *key)
|
||||
{
|
||||
uint32_t tmp_ports;
|
||||
|
@ -97,17 +105,11 @@ void fill_connection_key(Packet *pkt, ConnectionKey *key)
|
|||
case IPPROTO_SCTP:
|
||||
case IPPROTO_UDPLITE:
|
||||
tmp_ports = *(uint32_t *)(pkt->transport_header);
|
||||
key->src = pkt->ip->ip_src;
|
||||
key->dst = pkt->ip->ip_dst;
|
||||
key->src_port = ntohs(tmp_ports & 0xffff);
|
||||
key->dst_port = ntohs(tmp_ports >> 16);
|
||||
extract_ip_and_port(tmp_ports, key, pkt);
|
||||
break;
|
||||
case IPPROTO_AH:
|
||||
tmp_ports = *(uint32_t *)(pkt->transport_header + 4);
|
||||
key->src = pkt->ip->ip_src;
|
||||
key->dst = pkt->ip->ip_dst;
|
||||
key->src_port = ntohs(tmp_ports & 0xffff);
|
||||
key->dst_port = ntohs(tmp_ports >> 16);
|
||||
extract_ip_and_port(tmp_ports, key, pkt);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
|
@ -76,6 +76,7 @@ typedef struct Connection {
|
|||
uint32_t connection_key_hash(const void *opaque);
|
||||
int connection_key_equal(const void *opaque1, const void *opaque2);
|
||||
int parse_packet_early(Packet *pkt);
|
||||
void extract_ip_and_port(uint32_t tmp_ports, ConnectionKey *key, Packet *pkt);
|
||||
void fill_connection_key(Packet *pkt, ConnectionKey *key);
|
||||
void reverse_connection_key(ConnectionKey *key);
|
||||
Connection *connection_new(ConnectionKey *key);
|
||||
|
|
|
@ -373,7 +373,7 @@ static NetSocketState *net_socket_fd_init_dgram(NetClientState *peer,
|
|||
net_socket_read_poll(s, true);
|
||||
|
||||
/* mcast: save bound address as dst */
|
||||
if (is_connected) {
|
||||
if (is_connected && mcast != NULL) {
|
||||
s->dgram_dst = saddr;
|
||||
snprintf(nc->info_str, sizeof(nc->info_str),
|
||||
"socket: fd=%d (cloned mcast=%s:%d)",
|
||||
|
@ -695,8 +695,8 @@ int net_init_socket(const Netdev *netdev, const char *name,
|
|||
assert(netdev->type == NET_CLIENT_DRIVER_SOCKET);
|
||||
sock = &netdev->u.socket;
|
||||
|
||||
if (sock->has_listen + sock->has_connect + sock->has_mcast +
|
||||
sock->has_udp > 1) {
|
||||
if (sock->has_fd + sock->has_listen + sock->has_connect + sock->has_mcast +
|
||||
sock->has_udp != 1) {
|
||||
error_setg(errp, "exactly one of listen=, connect=, mcast= or udp="
|
||||
" is required");
|
||||
return -1;
|
||||
|
|
|
@ -2047,7 +2047,7 @@ that the card should have; this option currently only affects virtio cards; set
|
|||
@var{v} = 0 to disable MSI-X. If no @option{-net} option is specified, a single
|
||||
NIC is created. QEMU can emulate several different models of network card.
|
||||
Valid values for @var{type} are
|
||||
@code{virtio}, @code{i82551}, @code{i82557b}, @code{i82559er},
|
||||
@code{virtio}, @code{i82551}, @code{i82557b}, @code{i82559a}, @code{i82559er},
|
||||
@code{ne2k_pci}, @code{ne2k_isa}, @code{pcnet}, @code{rtl8139},
|
||||
@code{e1000}, @code{smc91c111}, @code{lance} and @code{mcf_fec}.
|
||||
Not all devices are supported on all targets. Use @code{-net nic,model=help}
|
||||
|
|
Loading…
Reference in New Issue