Skip to contentSkip to conversation

rocker device updates

PATCH Applied [email protected] 2 participants 7 messages Jul 1, 2015 – Jul 2, 2015

lore
Share & tools
lore
#0 lore raw

cover rocker device updates

From: Scott Feldman <[email protected]>

A couple of fixes reported by Paolo Bonzini and some changes to sync with current Linux 4.1 kernel rocker device driver.

Scott Feldman (5):
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

 docs/specs/rocker.txt         |    4 ++++
 hw/net/rocker/rocker.c        |    8 +++++++-
 hw/net/rocker/rocker.h        |    2 +-
 hw/net/rocker/rocker_hw.h     |    1 +
 hw/net/rocker/rocker_of_dpa.c |    7 +++++--
 hw/net/rocker/rocker_world.c  |    2 +-
 tests/rocker/bridge-vlan      |    4 ++--
 tests/rocker/bridge-vlan-stp  |    4 ++--
 8 files changed, 23 insertions(+), 9 deletions(-)
Signature · 1 line
1.7.10.4
#1 lore raw

PATCH 1/5 rocker: fix misplaced break statement

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.

---
 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
1.7.10.4
#2 lore raw

PATCH 2/5 rocker: fix missing break statements

In reply to [email protected]

From: Scott Feldman <[email protected]>

---
 hw/net/rocker/rocker.c |    2 ++
 1 file changed, 2 insertions(+)
hw/net/rocker/rocker.c +2 -0
index 4d25842..55ad317 100644
@@ -192,11 +192,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
1.7.10.4
#3 lore raw

PATCH 3/5 rocker: return -1 when dropping packet on ingress

In reply to [email protected]

From: Scott Feldman <[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
1.7.10.4
#4 lore raw

PATCH 4/5 rocker: mark copy-to-cpu pkts as forwarding offloaded

In reply to [email protected]

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.

---
 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 55ad317..a4892f2 100644
@@ -602,7 +602,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;
@@ -645,6 +645,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
1.7.10.4
#5 lore raw

PATCH 5/5 rocker: tests: don't need to specify master/self when setting vlans

In reply to [email protected]

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.

---
 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
1.7.10.4
#6 lore raw
In reply to [email protected]
Quoted 12 lines · On Wed, Jul 01, 2015 at 03:33:07AM -0700, [email protected] wrote:

From: Scott Feldman <[email protected]>

A couple of fixes reported by Paolo Bonzini and some changes to sync with current Linux 4.1 kernel rocker device driver.

Scott Feldman (5):
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

Quoted 13 lines
 docs/specs/rocker.txt         |    4 ++++
 hw/net/rocker/rocker.c        |    8 +++++++-
 hw/net/rocker/rocker.h        |    2 +-
 hw/net/rocker/rocker_hw.h     |    1 +
 hw/net/rocker/rocker_of_dpa.c |    7 +++++--
 hw/net/rocker/rocker_world.c  |    2 +-
 tests/rocker/bridge-vlan      |    4 ++--
 tests/rocker/bridge-vlan-stp  |    4 ++--
 8 files changed, 23 insertions(+), 9 deletions(-)
Signature · 1 line
1.7.10.4

Thanks, applied to my net tree:
https://github.com/stefanha/qemu/commits/net

Stefan