Skip to content

Commit

Permalink
odp-util: Remove odp_in_port from struct odp_flow_key_parms.
Browse files Browse the repository at this point in the history
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 <[email protected]>
Acked-by: Daniele Di Proietto <[email protected]>
  • Loading branch information
jessegross committed Jun 13, 2016
1 parent d1d7816 commit 098d2a9
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 18 deletions.
3 changes: 0 additions & 3 deletions lib/dpif-netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
};

Expand Down
6 changes: 3 additions & 3 deletions lib/odp-util.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 0 additions & 6 deletions lib/odp-util.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 0 additions & 2 deletions lib/tnl-ports.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,15 +316,13 @@ 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);
key = buf.data;
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);
Expand Down
3 changes: 0 additions & 3 deletions ofproto/ofproto-dpif-upcall.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
1 change: 0 additions & 1 deletion tests/test-odp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 098d2a9

Please sign in to comment.