/* If a UFID is not provided, determine one based on the key. */
if (!ufidp && key && key_len
&& !dpif_netdev_flow_from_nlattrs(key, key_len, &flow, false)) {
- dpif_flow_hash(pmd->dp->dpif, &flow, sizeof flow, &ufid);
+ odp_flow_key_hash(&flow, sizeof flow, &ufid);
ufidp = &ufid;
}
((uint8_t *)&masked_flow)[i] = ((uint8_t *)&match->flow)[i] &
((uint8_t *)&match->wc)[i];
}
- dpif_flow_hash(NULL, &masked_flow, sizeof(struct flow), mega_ufid);
+ odp_flow_key_hash(&masked_flow, sizeof masked_flow, mega_ufid);
}
static struct dp_netdev_flow *
if (put->ufid) {
ufid = *put->ufid;
} else {
- dpif_flow_hash(dpif, &match.flow, sizeof match.flow, &ufid);
+ odp_flow_key_hash(&match.flow, sizeof match.flow, &ufid);
}
/* The Netlink encoding of datapath flow keys cannot express
ofpbuf_clear(actions);
ofpbuf_clear(put_actions);
- dpif_flow_hash(pmd->dp->dpif, &match.flow, sizeof match.flow, &ufid);
+ odp_flow_key_hash(&match.flow, sizeof match.flow, &ufid);
error = dp_netdev_upcall(pmd, packet, &match.flow, &match.wc,
&ufid, DPIF_UC_MISS, NULL, actions,
put_actions);
struct dp_packet *packet;
DP_PACKET_BATCH_FOR_EACH (i, packet, packets_) {
flow_extract(packet, &flow);
- dpif_flow_hash(dp->dpif, &flow, sizeof flow, &ufid);
+ odp_flow_key_hash(&flow, sizeof flow, &ufid);
dp_execute_userspace_action(pmd, packet, should_steal, &flow,
&ufid, &actions, userdata);
}
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. */
}
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;
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;
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. */
/* 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;
}
}
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;
}
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. */
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];
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) {
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) {
}
}
-/* Places the hash of the 'key_len' bytes starting at 'key' into '*hash'. */
-void
-dpif_flow_hash(const struct dpif *dpif OVS_UNUSED,
- const void *key, size_t key_len, ovs_u128 *hash)
-{
- static struct ovsthread_once once = OVSTHREAD_ONCE_INITIALIZER;
- static uint32_t secret;
-
- if (ovsthread_once_start(&once)) {
- secret = random_uint32();
- ovsthread_once_done(&once);
- }
- hash_bytes128(key, key_len, secret, hash);
- uuid_set_bits_v4((struct uuid *)hash);
-}
-
/* Deletes all flows from 'dpif'. Returns 0 if successful, otherwise a
* positive errno value. */
int
bool dpif_probe_feature(struct dpif *, const char *name,
const struct ofpbuf *key, const struct ofpbuf *actions,
const ovs_u128 *ufid);
-void dpif_flow_hash(const struct dpif *, const void *key, size_t key_len,
- ovs_u128 *hash);
int dpif_flow_flush(struct dpif *);
int dpif_flow_put(struct dpif *, enum dpif_flow_put_flags,
const struct nlattr *key, size_t key_len,
/* A callback to process an upcall, currently implemented only by dpif-netdev.
*
* The caller provides the 'packet' and 'flow' to process, the corresponding
- * 'ufid' as generated by dpif_flow_hash(), the polling thread id 'pmd_id',
+ * 'ufid' as generated by odp_flow_key_hash(), the polling thread id 'pmd_id',
* the 'type' of the upcall, and if 'type' is DPIF_UC_ACTION then the
* 'userdata' attached to the action.
*
}
}
-uint32_t
-odp_flow_key_hash(const struct nlattr *key, size_t key_len)
+/* Places the hash of the 'key_len' bytes starting at 'key' into '*hash'.
+ * Generated value has format of random UUID. */
+void
+odp_flow_key_hash(const void *key, size_t key_len, ovs_u128 *hash)
{
- BUILD_ASSERT_DECL(!(NLA_ALIGNTO % sizeof(uint32_t)));
- return hash_bytes32(ALIGNED_CAST(const uint32_t *, key), key_len, 0);
+ static struct ovsthread_once once = OVSTHREAD_ONCE_INITIALIZER;
+ static uint32_t secret;
+
+ if (ovsthread_once_start(&once)) {
+ secret = random_uint32();
+ ovsthread_once_done(&once);
+ }
+ hash_bytes128(key, key_len, secret, hash);
+ uuid_set_bits_v4((struct uuid *)hash);
}
static void
void odp_flow_key_from_flow(const struct odp_flow_key_parms *, struct ofpbuf *);
void odp_flow_key_from_mask(const struct odp_flow_key_parms *, struct ofpbuf *);
-uint32_t odp_flow_key_hash(const struct nlattr *, size_t);
+void odp_flow_key_hash(const void *key, size_t key_len, ovs_u128 *hash);
/* Estimated space needed for metadata. */
enum { ODP_KEY_METADATA_SIZE = 9 * 8 };
ofpbuf_use_stack(&key, &keybuf, sizeof keybuf);
odp_flow_key_from_flow(&odp_parms, &key);
- dpif_flow_hash(backer->dpif, key.data, key.size, &ufid);
+ odp_flow_key_hash(key.data, key.size, &ufid);
enable_ufid = dpif_probe_feature(backer->dpif, "UFID", &key, NULL, &ufid);