Skip to contentSkip to conversation

Net patches

GIT PULL Applied Stefan Hajnoczi 2 participants 11 messages Jul 7, 2015

lore
Share & tools
lore
#0 lore raw

The following changes since commit f6e3035f75e5c6a73485335765ae070304c7a110:

Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream-smm' into staging (2015-07-06 23:37:53 +0100)

are available in the git repository at:

git://github.com/stefanha/qemu.git tags/net-pull-request

for you to fetch changes up to 849729bb796e0ecbb3f370f119682f2821dd1441:

rocker: tests: don't need to specify master/self when setting vlans (2015-07-07 13:13:22 +0100)

----------------------------------------------------------------

----------------------------------------------------------------

Brian Kress (1):
vmxnet3: Fix incorrect small packet padding

Gonglei (1):
rocker: fix memory leak

Scott Feldman (6):
rocker: don't queue receive pkts when port is disabled
rocker: fix misplaced break statement
rocker: fix missing break statements
rocker: return -1 when dropping packet on ingress
rocker: mark copy-to-cpu pkts as forwarding offloaded
rocker: tests: don't need to specify master/self when setting vlans

Stefan Hajnoczi (1):
e1000: flush packets when link comes up

 docs/specs/rocker.txt         |  4 ++++
 hw/net/e1000.c                |  3 +++
 hw/net/rocker/rocker.c        | 11 +++++++++--
 hw/net/rocker/rocker.h        |  2 +-
 hw/net/rocker/rocker_fp.c     | 18 ++++++++++--------
 hw/net/rocker/rocker_hw.h     |  1 +
 hw/net/rocker/rocker_of_dpa.c |  7 +++++--
 hw/net/rocker/rocker_world.c  |  2 +-
 hw/net/vmxnet3.c              | 12 ++++++------
 tests/rocker/bridge-vlan      |  4 ++--
 tests/rocker/bridge-vlan-stp  |  4 ++--
 11 files changed, 44 insertions(+), 24 deletions(-)
Signature · 1 line
2.4.3
#1 lore raw

[Qemu-devel] [PULL for-2.4 1/9] rocker: fix memory leak

From: Gonglei <[email protected]>

Meanwhile, using g_new0 instead of g_malloc0,
refer to commit 5839e53.

Message-id: [email protected]

---
 hw/net/rocker/rocker.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
hw/net/rocker/rocker.c +2 -1
index 4d25842..7e06015 100644
@@ -96,7 +96,7 @@ World *rocker_get_world(Rocker *r, enum rocker_world_type type)
 
 RockerSwitch *qmp_query_rocker(const char *name, Error **errp)
 {
-    RockerSwitch *rocker = g_malloc0(sizeof(*rocker));
+    RockerSwitch *rocker;
     Rocker *r;
 
     r = rocker_find(name);
@@ -106,6 +106,7 @@ RockerSwitch *qmp_query_rocker(const char *name, Error **errp)
         return NULL;
     }
 
+    rocker = g_new0(RockerSwitch, 1);
     rocker->name = g_strdup(r->name);
     rocker->id = r->switch_id;
     rocker->ports = r->fp_ports;
Signature · 1 line
2.4.3
#2 lore raw

[Qemu-devel] [PULL for-2.4 2/9] e1000: flush packets when link comes up

In reply to Stefan Hajnoczi

e1000_can_receive() checks the link up status register bit. If the bit is clear, packets will be queued and the peer may disable receive to avoid wasting CPU reading packets that cannot be delivered. The queue must be flushed once the link comes back up again.

This patch fixes broken e1000 receive with Mac OS X Snow Leopard guests and tap networking. Flushing the queue invokes the async send callback, which re-enables tap fd read.

Message-id: [email protected]

---
 hw/net/e1000.c | 3 +++
 1 file changed, 3 insertions(+)
hw/net/e1000.c +3 -0
index bab8e2a..5c6bcd0 100644
@@ -185,6 +185,9 @@ e1000_link_up(E1000State *s)
 {
     s->mac_reg[STATUS] |= E1000_STATUS_LU;
     s->phy_reg[PHY_STATUS] |= MII_SR_LINK_STATUS;
+
+    /* E1000_STATUS_LU is tested by e1000_can_receive() */
+    qemu_flush_queued_packets(qemu_get_queue(s->nic));
 }
 
 static bool
Signature · 1 line
2.4.3
#3 lore raw

[Qemu-devel] [PULL for-2.4 3/9] vmxnet3: Fix incorrect small packet padding

In reply to Stefan Hajnoczi

From: Brian Kress <[email protected]>

When running ESXi under qemu there is an issue with the ESXi guest discarding packets that are too short. The guest discards any packets under the normal minimum length for an ethernet packet (60). This results in odd behaviour where other hosts or VMs on other hosts can communicate with the ESXi guest just fine (since there's a physical NIC somewhere doing padding), but VMs on the host and the host itself cannot because the ARP request packets are too small for the ESXi host to accept.

Someone in the past thought this was worth fixing, and added code to the vmxnet3 qemu emulation such that if it is receiving packets smaller than 60 bytes to pad the packet out to 60. Unfortunately this code is wrong (or at least in the wrong place). It does so BEFORE before taking into account the vnet_hdr at the front of the packet added by the tap device. As a result, it might add padding, but it never adds enough. Specifically it adds 10 less (the length of the vnet_hdr) than it needs to.

The following (hopefully "obviously correct") patch simply swaps the order of processing the vnet header and the padding. With this patch an ESXi guest is able to communicate with the host or other local VMs.

---
 hw/net/vmxnet3.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
hw/net/vmxnet3.c +6 -6
index 104a0f5..706e060 100644
@@ -1879,6 +1879,12 @@ vmxnet3_receive(NetClientState *nc, const uint8_t *buf, size_t size)
         return -1;
     }
 
+    if (s->peer_has_vhdr) {
+        vmxnet_rx_pkt_set_vhdr(s->rx_pkt, (struct virtio_net_hdr *)buf);
+        buf += sizeof(struct virtio_net_hdr);
+        size -= sizeof(struct virtio_net_hdr);
+    }
+
     /* Pad to minimum Ethernet frame length */
     if (size < sizeof(min_buf)) {
         memcpy(min_buf, buf, size);
@@ -1887,12 +1893,6 @@ vmxnet3_receive(NetClientState *nc, const uint8_t *buf, size_t size)
         size = sizeof(min_buf);
     }
 
-    if (s->peer_has_vhdr) {
-        vmxnet_rx_pkt_set_vhdr(s->rx_pkt, (struct virtio_net_hdr *)buf);
-        buf += sizeof(struct virtio_net_hdr);
-        size -= sizeof(struct virtio_net_hdr);
-    }
-
     vmxnet_rx_pkt_set_packet_type(s->rx_pkt,
         get_eth_packet_type(PKT_GET_ETH_HDR(buf)));
 
Signature · 1 line
2.4.3
#4 lore raw

[Qemu-devel] [PULL for-2.4 4/9] rocker: don't queue receive pkts when port is disabled

In reply to Stefan Hajnoczi

From: Scott Feldman <[email protected]>

Commit 6e99c63 ("net/socket: Drop net_socket_can_send") changed the semantics around .can_receive for sockets to now require the device to flush queued pkts when transitioning to a .can_receive=true state. Rocker device was not flushing the queue on .can_receive=true transition, so the receiver was stuck.

But, turns out we really don't want any queuing at all on the port when the port is disabled, otherwise when the port transitions to enabled, we'd receive and forward stale pkts that really should have been dropped. So, let's remove .can_receive so avoid queuing and drop the pkt in .receive if the port is disabled.

Message-id: [email protected]

---
 hw/net/rocker/rocker_fp.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)
hw/net/rocker/rocker_fp.c +10 -8
index d8d934c..c693ae5 100644
@@ -125,18 +125,21 @@ int fp_port_eg(FpPort *port, const struct iovec *iov, int iovcnt)
     return ROCKER_OK;
 }
 
-static int fp_port_can_receive(NetClientState *nc)
-{
-    FpPort *port = qemu_get_nic_opaque(nc);
-
-    return port->enabled;
-}
-
 static ssize_t fp_port_receive_iov(NetClientState *nc, const struct iovec *iov,
                                    int iovcnt)
 {
     FpPort *port = qemu_get_nic_opaque(nc);
 
+    /* If the port is disabled, we want to drop this pkt
+     * now rather than queing it for later.  We don't want
+     * any stale pkts getting into the device when the port
+     * transitions to enabled.
+     */
+
+    if (!port->enabled) {
+        return -1;
+    }
+
     return world_ingress(port->world, port->pport, iov, iovcnt);
 }
 
@@ -165,7 +168,6 @@ static void fp_port_set_link_status(NetClientState *nc)
 static NetClientInfo fp_port_info = {
     .type = NET_CLIENT_OPTIONS_KIND_NIC,
     .size = sizeof(NICState),
-    .can_receive = fp_port_can_receive,
     .receive = fp_port_receive,
     .receive_iov = fp_port_receive_iov,
     .cleanup = fp_port_cleanup,
Signature · 1 line
2.4.3
#5 lore raw

[Qemu-devel] [PULL for-2.4 5/9] rocker: fix misplaced break statement

In reply to Stefan Hajnoczi

From: Scott Feldman <[email protected]>

Premature break in switch case block. This particular case (group L2 rewrite) will be used for L2 LAG and L3 ECMP support, neither of which are enabled in the guest driver at this time, but are under development.

Message-id: [email protected]

---
 hw/net/rocker/rocker_of_dpa.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/net/rocker/rocker_of_dpa.c +1 -1
index b25a17d..02b3896 100644
@@ -2525,7 +2525,6 @@ static void of_dpa_group_fill(void *key, void *value, void *user_data)
             ngroup->has_set_vlan_id = true;
             ngroup->set_vlan_id = ntohs(group->l2_rewrite.vlan_id);
         }
-        break;
         if (memcmp(group->l2_rewrite.src_mac.a, zero_mac.a, ETH_ALEN)) {
             ngroup->has_set_eth_src = true;
             ngroup->set_eth_src =
@@ -2536,6 +2535,7 @@ static void of_dpa_group_fill(void *key, void *value, void *user_data)
             ngroup->set_eth_dst =
                 qemu_mac_strdup_printf(group->l2_rewrite.dst_mac.a);
         }
+        break;
     case ROCKER_OF_DPA_GROUP_TYPE_L2_FLOOD:
     case ROCKER_OF_DPA_GROUP_TYPE_L2_MCAST:
         ngroup->has_vlan_id = true;
Signature · 1 line
2.4.3
#6 lore raw

[Qemu-devel] [PULL for-2.4 6/9] rocker: fix missing break statements

In reply to Stefan Hajnoczi

From: Scott Feldman <[email protected]>

Message-id: [email protected]

---
 hw/net/rocker/rocker.c | 2 ++
 1 file changed, 2 insertions(+)
hw/net/rocker/rocker.c +2 -0
index 7e06015..6e3d35a 100644
@@ -193,11 +193,13 @@ static int tx_consume(Rocker *r, DescInfo *info)
         if (!tlvs[ROCKER_TLV_TX_L3_CSUM_OFF]) {
             return -ROCKER_EINVAL;
         }
+        break;
     case ROCKER_TX_OFFLOAD_TSO:
         if (!tlvs[ROCKER_TLV_TX_TSO_MSS] ||
             !tlvs[ROCKER_TLV_TX_TSO_HDR_LEN]) {
             return -ROCKER_EINVAL;
         }
+        break;
     }
 
     if (tlvs[ROCKER_TLV_TX_L3_CSUM_OFF]) {
Signature · 1 line
2.4.3
#7 lore raw

[Qemu-devel] [PULL for-2.4 7/9] rocker: return -1 when dropping packet on ingress

In reply to Stefan Hajnoczi

From: Scott Feldman <[email protected]>

Message-id: [email protected]

---
 hw/net/rocker/rocker_world.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/net/rocker/rocker_world.c +1 -1
index b991e87..a6b18f1 100644
@@ -32,7 +32,7 @@ ssize_t world_ingress(World *world, uint32_t pport,
         return world->ops->ig(world, pport, iov, iovcnt);
     }
 
-    return iov_size(iov, iovcnt);
+    return -1;
 }
 
 int world_do_cmd(World *world, DescInfo *info,
Signature · 1 line
2.4.3
#8 lore raw

[Qemu-devel] [PULL for-2.4 8/9] rocker: mark copy-to-cpu pkts as forwarding offloaded

In reply to Stefan Hajnoczi

From: Scott Feldman <[email protected]>

For pkts copied to the CPU (to be processed by guest driver), mark the Rx descriptor with flag "OFFLOAD_FWD" to indicate device has already forwarded pkt. The guest driver will use this indicator to avoid duplicate forwarding in the guest OS.

Examples include bcast/mcast/unknown ucast pkts flooded to bridged ports. We want to avoid both the device and the guest bridge driver flooding these pkts, which would result in duplicates pkts on the wire. Packet sampling, such as sFlow, can also use this technique to mark pkts for the guest OS to record but otherwise drop.

Message-id: [email protected]

---
 docs/specs/rocker.txt         | 4 ++++
 hw/net/rocker/rocker.c        | 6 +++++-
 hw/net/rocker/rocker.h        | 2 +-
 hw/net/rocker/rocker_hw.h     | 1 +
 hw/net/rocker/rocker_of_dpa.c | 5 ++++-
 5 files changed, 15 insertions(+), 3 deletions(-)
docs/specs/rocker.txt +4 -0
index 0af5c61..1c74351 100644
@@ -637,6 +637,7 @@ The TLVs for Rx descriptor buffer are:
 				  (1 << 5): TCP packet
 				  (1 << 6): UDP packet
 				  (1 << 7): TCP/UDP csum good
+				  (1 << 8): Offload forward
 	RX_CSUM		2	IP calculated checksum:
 				  IPv4: IP payload csum
 				  IPv6: header and payload csum
@@ -645,6 +646,9 @@ The TLVs for Rx descriptor buffer are:
 	RX_FRAG_MAX_LEN	2	Packet maximum fragment length
 	RX_FRAG_LEN	2	Actual packet fragment length after receive
 
+Offload forward RX_FLAG indicates the device has already forwarded the packet
+so the host CPU should not also forward the packet.
+
 Possible status return codes in descriptor on completion are:
 
 	DESC_COMP_ERR	reason
hw/net/rocker/rocker.c +5 -1
index 6e3d35a..47d080f 100644
@@ -603,7 +603,7 @@ static DescRing *rocker_get_rx_ring_by_pport(Rocker *r,
 }
 
 int rx_produce(World *world, uint32_t pport,
-               const struct iovec *iov, int iovcnt)
+               const struct iovec *iov, int iovcnt, uint8_t copy_to_cpu)
 {
     Rocker *r = world_rocker(world);
     PCIDevice *dev = (PCIDevice *)r;
@@ -646,6 +646,10 @@ int rx_produce(World *world, uint32_t pport,
         goto out;
     }
 
+    if (copy_to_cpu) {
+        rx_flags |= ROCKER_RX_FLAGS_FWD_OFFLOAD;
+    }
+
     /* XXX calc rx flags/csum */
 
     tlv_size = rocker_tlv_total_size(sizeof(uint16_t)) + /* flags */
hw/net/rocker/rocker.h +1 -1
index b3310b6..f9c80f8 100644
@@ -77,7 +77,7 @@ int rocker_event_link_changed(Rocker *r, uint32_t pport, bool link_up);
 int rocker_event_mac_vlan_seen(Rocker *r, uint32_t pport, uint8_t *addr,
                                uint16_t vlan_id);
 int rx_produce(World *world, uint32_t pport,
-               const struct iovec *iov, int iovcnt);
+               const struct iovec *iov, int iovcnt, uint8_t copy_to_cpu);
 int rocker_port_eg(Rocker *r, uint32_t pport,
                    const struct iovec *iov, int iovcnt);
 
hw/net/rocker/rocker_hw.h +1 -0
index fe639ba..8c50830 100644
@@ -250,6 +250,7 @@ enum {
 #define ROCKER_RX_FLAGS_TCP                     (1 << 5)
 #define ROCKER_RX_FLAGS_UDP                     (1 << 6)
 #define ROCKER_RX_FLAGS_TCP_UDP_CSUM_GOOD       (1 << 7)
+#define ROCKER_RX_FLAGS_FWD_OFFLOAD             (1 << 8)
 
 /* Tx msg */
 enum {
hw/net/rocker/rocker_of_dpa.c +4 -1
index 02b3896..874fb01 100644
@@ -825,6 +825,8 @@ static OfDpaGroup *of_dpa_group_alloc(uint32_t id)
 static void of_dpa_output_l2_interface(OfDpaFlowContext *fc,
                                        OfDpaGroup *group)
 {
+    uint8_t copy_to_cpu = fc->action_set.apply.copy_to_cpu;
+
     if (group->l2_interface.pop_vlan) {
         of_dpa_flow_pkt_strip_vlan(fc);
     }
@@ -837,7 +839,8 @@ static void of_dpa_output_l2_interface(OfDpaFlowContext *fc,
      */
 
     if (group->l2_interface.out_pport == 0) {
-        rx_produce(fc->of_dpa->world, fc->in_pport, fc->iov, fc->iovcnt);
+        rx_produce(fc->of_dpa->world, fc->in_pport, fc->iov, fc->iovcnt,
+                   copy_to_cpu);
     } else if (group->l2_interface.out_pport != fc->in_pport) {
         rocker_port_eg(world_rocker(fc->of_dpa->world),
                        group->l2_interface.out_pport,
Signature · 1 line
2.4.3
#9 lore raw

[Qemu-devel] [PULL for-2.4 9/9] rocker: tests: don't need to specify master/self when setting vlans

In reply to Stefan Hajnoczi

From: Scott Feldman <[email protected]>

4.1 Linux kernel doesn't require specifying "master" or "self" when setting vlans on a port, so clean these up from the tests that use vlans.

Message-id: [email protected]

---
 tests/rocker/bridge-vlan     | 4 ++--
 tests/rocker/bridge-vlan-stp | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
tests/rocker/bridge-vlan +2 -2
index ef9e5f5..897d82c 100755
@@ -20,8 +20,8 @@ simp ssh tut sw1 --cmd "echo 1 | sudo dd of=/sys/class/net/br0/bridge/vlan_filte
 
 # add both ports to VLAN 57
 
-simp ssh tut sw1 --cmd "sudo /sbin/bridge vlan add vid 57 dev sw1p1 master self"
-simp ssh tut sw1 --cmd "sudo /sbin/bridge vlan add vid 57 dev sw1p2 master self"
+simp ssh tut sw1 --cmd "sudo /sbin/bridge vlan add vid 57 dev sw1p1"
+simp ssh tut sw1 --cmd "sudo /sbin/bridge vlan add vid 57 dev sw1p2"
 
 # turn off learning and flooding in SW
 
tests/rocker/bridge-vlan-stp +2 -2
index c660312..85d2646 100755
@@ -21,8 +21,8 @@ simp ssh tut sw1 --cmd "echo 1 | sudo dd of=/sys/class/net/br0/bridge/vlan_filte
 
 # add both ports to VLAN 57
 
-simp ssh tut sw1 --cmd "sudo /sbin/bridge vlan add vid 57 dev sw1p1 master self"
-simp ssh tut sw1 --cmd "sudo /sbin/bridge vlan add vid 57 dev sw1p2 master self"
+simp ssh tut sw1 --cmd "sudo /sbin/bridge vlan add vid 57 dev sw1p1"
+simp ssh tut sw1 --cmd "sudo /sbin/bridge vlan add vid 57 dev sw1p2"
 
 # turn off learning and flooding in SW
 
Signature · 1 line
2.4.3
#10 lore raw
In reply to Stefan Hajnoczi
Quoted 4 lines · Stefan Hajnoczi

The following changes since commit f6e3035f75e5c6a73485335765ae070304c7a110:

Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream-smm' into staging (2015-07-06 23:37:53 +0100)

Quoted 8 lines

are available in the git repository at:

git://github.com/stefanha/qemu.git tags/net-pull-request

for you to fetch changes up to 849729bb796e0ecbb3f370f119682f2821dd1441:

rocker: tests: don't need to specify master/self when setting vlans (2015-07-07 13:13:22 +0100)

Applied, thanks.

-- PMM