summaryrefslogtreecommitdiff
path: root/lib/dpif-netlink.c
diff options
context:
space:
mode:
authorIlya Maximets <i.maximets@ovn.org>2019-12-08 18:09:53 +0100
committerIlya Maximets <i.maximets@ovn.org>2020-01-08 16:02:37 +0100
commit7a5e0ee7cc1c8911d3b0085a066facab076647d5 (patch)
treec2755c6dfa2a932dcbb0c2137d5dd54855e90fb5 /lib/dpif-netlink.c
parente988b8abeec9d4be94b519c5d4ed4586ff71fde0 (diff)
downloadopenvswitch-7a5e0ee7cc1c8911d3b0085a066facab076647d5.tar.gz
dpif: Turn dpif_flow_hash function into generic odp_flow_key_hash.
Current implementation of dpif_flow_hash() doesn't depend on datapath interface and only complicates the callers by forcing them to figure out what is their current 'dpif'. If we'll need different hashing for different 'dpif's we'll implement an API for dpif-providers and each dpif implementation will be able to use their local function directly without calling it via dpif API. This change will allow us to not store 'dpif' pointer in the userspace datapath implementation which is broken and will be removed in next commits. This patch moves dpif_flow_hash() to odp-util module and replaces unused odp_flow_key_hash() by it, along with removing of unused 'dpif' argument. Signed-off-by: Ilya Maximets <i.maximets@ovn.org> Acked-by: Ben Pfaff <blp@ovn.org>
Diffstat (limited to 'lib/dpif-netlink.c')
-rw-r--r--lib/dpif-netlink.c27
1 files changed, 12 insertions, 15 deletions
diff --git a/lib/dpif-netlink.c b/lib/dpif-netlink.c
index 3d97c786e..d865c0bdb 100644
--- a/lib/dpif-netlink.c
+++ b/lib/dpif-netlink.c
@@ -155,7 +155,7 @@ static int dpif_netlink_flow_transact(struct dpif_netlink_flow *request,
struct ofpbuf **bufp);
static void dpif_netlink_flow_get_stats(const struct dpif_netlink_flow *,
struct dpif_flow_stats *);
-static void dpif_netlink_flow_to_dpif_flow(struct dpif *, struct dpif_flow *,
+static void dpif_netlink_flow_to_dpif_flow(struct dpif_flow *,
const struct dpif_netlink_flow *);
/* One of the dpif channels between the kernel and userspace. */
@@ -1569,7 +1569,7 @@ dpif_netlink_flow_dump_thread_destroy(struct dpif_flow_dump_thread *thread_)
}
static void
-dpif_netlink_flow_to_dpif_flow(struct dpif *dpif, struct dpif_flow *dpif_flow,
+dpif_netlink_flow_to_dpif_flow(struct dpif_flow *dpif_flow,
const struct dpif_netlink_flow *datapath_flow)
{
dpif_flow->key = datapath_flow->key;
@@ -1584,8 +1584,8 @@ dpif_netlink_flow_to_dpif_flow(struct dpif *dpif, struct dpif_flow *dpif_flow,
dpif_flow->ufid = datapath_flow->ufid;
} else {
ovs_assert(datapath_flow->key && datapath_flow->key_len);
- dpif_flow_hash(dpif, datapath_flow->key, datapath_flow->key_len,
- &dpif_flow->ufid);
+ odp_flow_key_hash(datapath_flow->key, datapath_flow->key_len,
+ &dpif_flow->ufid);
}
dpif_netlink_flow_get_stats(datapath_flow, &dpif_flow->stats);
dpif_flow->attrs.offloaded = false;
@@ -1763,8 +1763,7 @@ dpif_netlink_flow_dump_next(struct dpif_flow_dump_thread *thread_,
if (dump->up.terse || datapath_flow.actions) {
/* Common case: we don't want actions, or the flow includes
* actions. */
- dpif_netlink_flow_to_dpif_flow(&dpif->dpif, &flows[n_flows++],
- &datapath_flow);
+ dpif_netlink_flow_to_dpif_flow(&flows[n_flows++], &datapath_flow);
} else {
/* Rare case: the flow does not include actions. Retrieve this
* individual flow again to get the actions. */
@@ -1782,8 +1781,7 @@ dpif_netlink_flow_dump_next(struct dpif_flow_dump_thread *thread_,
/* Save this flow. Then exit, because we only have one buffer to
* handle this case. */
- dpif_netlink_flow_to_dpif_flow(&dpif->dpif, &flows[n_flows++],
- &datapath_flow);
+ dpif_netlink_flow_to_dpif_flow(&flows[n_flows++], &datapath_flow);
break;
}
}
@@ -1976,8 +1974,7 @@ dpif_netlink_operate__(struct dpif_netlink *dpif,
op->error = dpif_netlink_flow_from_ofpbuf(&reply, txn->reply);
if (!op->error) {
- dpif_netlink_flow_to_dpif_flow(&dpif->dpif, get->flow,
- &reply);
+ dpif_netlink_flow_to_dpif_flow(get->flow, &reply);
}
}
break;
@@ -2501,8 +2498,8 @@ dpif_netlink_queue_to_priority(const struct dpif *dpif OVS_UNUSED,
}
static int
-parse_odp_packet(const struct dpif_netlink *dpif, struct ofpbuf *buf,
- struct dpif_upcall *upcall, int *dp_ifindex)
+parse_odp_packet(struct ofpbuf *buf, struct dpif_upcall *upcall,
+ int *dp_ifindex)
{
static const struct nl_policy ovs_packet_policy[] = {
/* Always present. */
@@ -2543,7 +2540,7 @@ parse_odp_packet(const struct dpif_netlink *dpif, struct ofpbuf *buf,
upcall->key = CONST_CAST(struct nlattr *,
nl_attr_get(a[OVS_PACKET_ATTR_KEY]));
upcall->key_len = nl_attr_get_size(a[OVS_PACKET_ATTR_KEY]);
- dpif_flow_hash(&dpif->dpif, upcall->key, upcall->key_len, &upcall->ufid);
+ odp_flow_key_hash(upcall->key, upcall->key_len, &upcall->ufid);
upcall->userdata = a[OVS_PACKET_ATTR_USERDATA];
upcall->out_tun_key = a[OVS_PACKET_ATTR_EGRESS_TUN_KEY];
upcall->actions = a[OVS_PACKET_ATTR_ACTIONS];
@@ -2637,7 +2634,7 @@ dpif_netlink_recv_windows(struct dpif_netlink *dpif, uint32_t handler_id,
return error;
}
- error = parse_odp_packet(dpif, buf, upcall, &dp_ifindex);
+ error = parse_odp_packet(buf, upcall, &dp_ifindex);
if (!error && dp_ifindex == dpif->dp_ifindex) {
return 0;
} else if (error) {
@@ -2712,7 +2709,7 @@ dpif_netlink_recv__(struct dpif_netlink *dpif, uint32_t handler_id,
return error;
}
- error = parse_odp_packet(dpif, buf, upcall, &dp_ifindex);
+ error = parse_odp_packet(buf, upcall, &dp_ifindex);
if (!error && dp_ifindex == dpif->dp_ifindex) {
return 0;
} else if (error) {