odp-util: Remove odp_in_port from struct odp_flow_key_parms.
authorJesse Gross <jesse@kernel.org>
Thu, 9 Jun 2016 20:32:50 +0000 (13:32 -0700)
committerJesse Gross <jesse@kernel.org>
Mon, 13 Jun 2016 20:28:39 +0000 (13:28 -0700)
When calling odp_flow_key_from_flow (or _mask), the in_port included
as part of the flow is ignored and must be explicitly passed as a
separate parameter. This is because the assumption was that the flow's
version would often be in OFP format, rather than ODP.

However, at this point all flows that are ready for serialization in
netlink format already have their in_port properly set to ODP format.
As a result, every caller needs to explicitly initialize the extra
paramter to the value that is in the flow. This switches to just use
the value in the flow to simply things and avoid the possibility of
forgetting to initialize the extra parameter.

Signed-off-by: Jesse Gross <jesse@kernel.org>
Acked-by: Daniele Di Proietto <diproiettod@vmware.com>
lib/dpif-netdev.c
lib/odp-util.c
lib/odp-util.h
lib/tnl-ports.c
ofproto/ofproto-dpif-upcall.c
tests/test-odp.c

index fcfd22e..f42d2da 100644 (file)
@@ -1942,14 +1942,12 @@ dp_netdev_flow_to_dpif_flow(const struct dp_netdev_flow *netdev_flow,
         /* Key */
         offset = key_buf->size;
         flow->key = ofpbuf_tail(key_buf);
-        odp_parms.odp_in_port = netdev_flow->flow.in_port.odp_port;
         odp_flow_key_from_flow(&odp_parms, key_buf);
         flow->key_len = key_buf->size - offset;
 
         /* Mask */
         offset = mask_buf->size;
         flow->mask = ofpbuf_tail(mask_buf);
-        odp_parms.odp_in_port = wc.masks.in_port.odp_port;
         odp_parms.key_buf = key_buf;
         odp_flow_key_from_mask(&odp_parms, mask_buf);
         flow->mask_len = mask_buf->size - offset;
@@ -3518,7 +3516,6 @@ dp_netdev_upcall(struct dp_netdev_pmd_thread *pmd, struct dp_packet *packet_,
         struct odp_flow_key_parms odp_parms = {
             .flow = flow,
             .mask = &wc->masks,
-            .odp_in_port = flow->in_port.odp_port,
             .support = dp_netdev_support,
         };
 
index d9ace90..289b969 100644 (file)
@@ -4274,10 +4274,10 @@ odp_flow_key_from_flow__(const struct odp_flow_key_parms *parms,
         nl_msg_put_u32(buf, OVS_KEY_ATTR_DP_HASH, data->dp_hash);
     }
 
-    /* Add an ingress port attribute if this is a mask or 'odp_in_port'
+    /* Add an ingress port attribute if this is a mask or 'in_port.odp_port'
      * is not the magical value "ODPP_NONE". */
-    if (export_mask || parms->odp_in_port != ODPP_NONE) {
-        nl_msg_put_odp_port(buf, OVS_KEY_ATTR_IN_PORT, parms->odp_in_port);
+    if (export_mask || flow->in_port.odp_port != ODPP_NONE) {
+        nl_msg_put_odp_port(buf, OVS_KEY_ATTR_IN_PORT, data->in_port.odp_port);
     }
 
     eth_key = nl_msg_put_unspec_uninit(buf, OVS_KEY_ATTR_ETHERNET,
index 51cf5c3..2c3cc8c 100644 (file)
@@ -194,12 +194,6 @@ struct odp_flow_key_parms {
     const struct flow *flow;
     const struct flow *mask;
 
-   /* 'flow->in_port' is ignored (since it is likely to be an OpenFlow port
-    * number rather than a datapath port number).  Instead, if 'odp_in_port'
-    * is anything other than ODPP_NONE, it is included in 'buf' as the input
-    * port. */
-    odp_port_t odp_in_port;
-
     /* Indicates support for various fields. If the datapath supports a field,
      * then it will always be serialised. */
     struct odp_support support;
index e8d43f0..e945eae 100644 (file)
@@ -316,7 +316,6 @@ tnl_port_show_v(struct ds *ds)
         miniflow_expand(p->cr.match.flow, &flow);
 
         /* Key. */
-        odp_parms.odp_in_port = flow.in_port.odp_port;
         odp_parms.support.recirc = true;
         ofpbuf_use_stack(&buf, &keybuf, sizeof keybuf);
         odp_flow_key_from_flow(&odp_parms, &buf);
@@ -324,7 +323,6 @@ tnl_port_show_v(struct ds *ds)
         key_len = buf.size;
 
         /* mask*/
-        odp_parms.odp_in_port = wc.masks.in_port.odp_port;
         odp_parms.support.recirc = false;
         ofpbuf_use_stack(&buf, &maskbuf, sizeof maskbuf);
         odp_flow_key_from_mask(&odp_parms, &buf);
index 9400ef9..b947da9 100644 (file)
@@ -1491,16 +1491,13 @@ ukey_create_from_upcall(struct upcall *upcall, struct flow_wildcards *wc)
         /* dpif-netdev doesn't provide a netlink-formatted flow key in the
          * upcall, so convert the upcall's flow here. */
         ofpbuf_use_stack(&keybuf, &keystub, sizeof keystub);
-        odp_parms.odp_in_port = upcall->flow->in_port.odp_port;
         odp_flow_key_from_flow(&odp_parms, &keybuf);
     }
 
     atomic_read_relaxed(&enable_megaflows, &megaflow);
     ofpbuf_use_stack(&maskbuf, &maskstub, sizeof maskstub);
     if (megaflow) {
-        odp_parms.odp_in_port = wc->masks.in_port.odp_port;
         odp_parms.key_buf = &keybuf;
-
         odp_flow_key_from_mask(&odp_parms, &maskbuf);
     }
 
index 602a6b6..8e4db09 100644 (file)
@@ -86,7 +86,6 @@ parse_keys(bool wc_keys)
             /* Convert cls_rule back to odp_key. */
             ofpbuf_uninit(&odp_key);
             ofpbuf_init(&odp_key, 0);
-            odp_parms.odp_in_port = flow.in_port.odp_port;
             odp_flow_key_from_flow(&odp_parms, &odp_key);
 
             if (odp_key.size > ODPUTIL_FLOW_KEY_BYTES) {