Skip to content

Commit

Permalink
odp-execute: Rename 'may_steal' to 'should_steal'.
Browse files Browse the repository at this point in the history
Signed-off-by: Darrell Ball <dlu998@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
  • Loading branch information
darball1 authored and blp committed May 23, 2018
1 parent a8ab588 commit 7d7ded7
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 30 deletions.
4 changes: 2 additions & 2 deletions lib/dp-packet.h
Expand Up @@ -792,9 +792,9 @@ dp_packet_batch_clone(struct dp_packet_batch *dst,
}

static inline void
dp_packet_delete_batch(struct dp_packet_batch *batch, bool may_steal)
dp_packet_delete_batch(struct dp_packet_batch *batch, bool should_steal)
{
if (may_steal) {
if (should_steal) {
struct dp_packet *packet;

DP_PACKET_BATCH_FOR_EACH (i, packet, batch) {
Expand Down
27 changes: 14 additions & 13 deletions lib/dpif-netdev.c
Expand Up @@ -647,7 +647,8 @@ static int dpif_netdev_open(const struct dpif_class *, const char *name,
bool create, struct dpif **);
static void dp_netdev_execute_actions(struct dp_netdev_pmd_thread *pmd,
struct dp_packet_batch *,
bool may_steal, const struct flow *flow,
bool should_steal,
const struct flow *flow,
const struct nlattr *actions,
size_t actions_len);
static void dp_netdev_input(struct dp_netdev_pmd_thread *,
Expand Down Expand Up @@ -5594,7 +5595,7 @@ push_tnl_action(const struct dp_netdev_pmd_thread *pmd,

static void
dp_execute_userspace_action(struct dp_netdev_pmd_thread *pmd,
struct dp_packet *packet, bool may_steal,
struct dp_packet *packet, bool should_steal,
struct flow *flow, ovs_u128 *ufid,
struct ofpbuf *actions,
const struct nlattr *userdata)
Expand All @@ -5609,16 +5610,16 @@ dp_execute_userspace_action(struct dp_netdev_pmd_thread *pmd,
NULL);
if (!error || error == ENOSPC) {
dp_packet_batch_init_packet(&b, packet);
dp_netdev_execute_actions(pmd, &b, may_steal, flow,
dp_netdev_execute_actions(pmd, &b, should_steal, flow,
actions->data, actions->size);
} else if (may_steal) {
} else if (should_steal) {
dp_packet_delete(packet);
}
}

static void
dp_execute_cb(void *aux_, struct dp_packet_batch *packets_,
const struct nlattr *a, bool may_steal)
const struct nlattr *a, bool should_steal)
OVS_NO_THREAD_SAFETY_ANALYSIS
{
struct dp_netdev_execute_aux *aux = aux_;
Expand All @@ -5635,7 +5636,7 @@ dp_execute_cb(void *aux_, struct dp_packet_batch *packets_,
struct dp_packet *packet;
struct dp_packet_batch out;

if (!may_steal) {
if (!should_steal) {
dp_packet_batch_clone(&out, packets_);
dp_packet_batch_reset_cutlen(packets_);
packets_ = &out;
Expand Down Expand Up @@ -5688,7 +5689,7 @@ dp_execute_cb(void *aux_, struct dp_packet_batch *packets_,
if (p) {
struct dp_packet_batch tnl_pkt;

if (!may_steal) {
if (!should_steal) {
dp_packet_batch_clone(&tnl_pkt, packets_);
packets_ = &tnl_pkt;
dp_packet_batch_reset_cutlen(orig_packets_);
Expand Down Expand Up @@ -5728,7 +5729,7 @@ dp_execute_cb(void *aux_, struct dp_packet_batch *packets_,
ofpbuf_init(&actions, 0);

if (packets_->trunc) {
if (!may_steal) {
if (!should_steal) {
dp_packet_batch_clone(&usr_pkt, packets_);
packets_ = &usr_pkt;
clone = true;
Expand All @@ -5742,7 +5743,7 @@ dp_execute_cb(void *aux_, struct dp_packet_batch *packets_,
DP_PACKET_BATCH_FOR_EACH (i, packet, packets_) {
flow_extract(packet, &flow);
dpif_flow_hash(dp->dpif, &flow, sizeof flow, &ufid);
dp_execute_userspace_action(pmd, packet, may_steal, &flow,
dp_execute_userspace_action(pmd, packet, should_steal, &flow,
&ufid, &actions, userdata);
}

Expand All @@ -5761,7 +5762,7 @@ dp_execute_cb(void *aux_, struct dp_packet_batch *packets_,
if (*depth < MAX_RECIRC_DEPTH) {
struct dp_packet_batch recirc_pkts;

if (!may_steal) {
if (!should_steal) {
dp_packet_batch_clone(&recirc_pkts, packets_);
packets_ = &recirc_pkts;
}
Expand Down Expand Up @@ -5934,18 +5935,18 @@ dp_execute_cb(void *aux_, struct dp_packet_batch *packets_,
OVS_NOT_REACHED();
}

dp_packet_delete_batch(packets_, may_steal);
dp_packet_delete_batch(packets_, should_steal);
}

static void
dp_netdev_execute_actions(struct dp_netdev_pmd_thread *pmd,
struct dp_packet_batch *packets,
bool may_steal, const struct flow *flow,
bool should_steal, const struct flow *flow,
const struct nlattr *actions, size_t actions_len)
{
struct dp_netdev_execute_aux aux = { pmd, flow };

odp_execute_actions(&aux, packets, may_steal, actions,
odp_execute_actions(&aux, packets, should_steal, actions,
actions_len, dp_execute_cb);
}

Expand Down
6 changes: 3 additions & 3 deletions lib/dpif.c
Expand Up @@ -1162,7 +1162,7 @@ struct dpif_execute_helper_aux {
* meaningful. */
static void
dpif_execute_helper_cb(void *aux_, struct dp_packet_batch *packets_,
const struct nlattr *action, bool may_steal)
const struct nlattr *action, bool should_steal)
{
struct dpif_execute_helper_aux *aux = aux_;
int type = nl_attr_type(action);
Expand Down Expand Up @@ -1234,7 +1234,7 @@ dpif_execute_helper_cb(void *aux_, struct dp_packet_batch *packets_,
|| type == OVS_ACTION_ATTR_TUNNEL_POP
|| type == OVS_ACTION_ATTR_USERSPACE)) {
dp_packet_reset_cutlen(packet);
if (!may_steal) {
if (!should_steal) {
packet = clone = dp_packet_clone(packet);
}
dp_packet_set_size(packet, dp_packet_size(packet) - cutlen);
Expand Down Expand Up @@ -1279,7 +1279,7 @@ dpif_execute_helper_cb(void *aux_, struct dp_packet_batch *packets_,
case __OVS_ACTION_ATTR_MAX:
OVS_NOT_REACHED();
}
dp_packet_delete_batch(packets_, may_steal);
dp_packet_delete_batch(packets_, should_steal);
}

/* Executes 'execute' by performing most of the actions in userspace and
Expand Down
18 changes: 9 additions & 9 deletions lib/netdev-dpdk.c
Expand Up @@ -272,7 +272,7 @@ struct dpdk_qos_ops {
* For all QoS implementations it should always be non-null.
*/
int (*qos_run)(struct qos_conf *qos_conf, struct rte_mbuf **pkts,
int pkt_cnt, bool may_steal);
int pkt_cnt, bool should_steal);
};

/* dpdk_qos_ops for each type of user space QoS implementation */
Expand Down Expand Up @@ -1803,7 +1803,7 @@ netdev_dpdk_policer_pkt_handle(struct rte_meter_srtcm *meter,
static int
netdev_dpdk_policer_run(struct rte_meter_srtcm *meter,
struct rte_mbuf **pkts, int pkt_cnt,
bool may_steal)
bool should_steal)
{
int i = 0;
int cnt = 0;
Expand All @@ -1819,7 +1819,7 @@ netdev_dpdk_policer_run(struct rte_meter_srtcm *meter,
}
cnt++;
} else {
if (may_steal) {
if (should_steal) {
rte_pktmbuf_free(pkt);
}
}
Expand All @@ -1830,13 +1830,13 @@ netdev_dpdk_policer_run(struct rte_meter_srtcm *meter,

static int
ingress_policer_run(struct ingress_policer *policer, struct rte_mbuf **pkts,
int pkt_cnt, bool may_steal)
int pkt_cnt, bool should_steal)
{
int cnt = 0;

rte_spinlock_lock(&policer->policer_lock);
cnt = netdev_dpdk_policer_run(&policer->in_policer, pkts,
pkt_cnt, may_steal);
pkt_cnt, should_steal);
rte_spinlock_unlock(&policer->policer_lock);

return cnt;
Expand Down Expand Up @@ -2016,13 +2016,13 @@ netdev_dpdk_rxq_recv(struct netdev_rxq *rxq, struct dp_packet_batch *batch,

static inline int
netdev_dpdk_qos_run(struct netdev_dpdk *dev, struct rte_mbuf **pkts,
int cnt, bool may_steal)
int cnt, bool should_steal)
{
struct qos_conf *qos_conf = ovsrcu_get(struct qos_conf *, &dev->qos_conf);

if (qos_conf) {
rte_spinlock_lock(&qos_conf->lock);
cnt = qos_conf->ops->qos_run(qos_conf, pkts, cnt, may_steal);
cnt = qos_conf->ops->qos_run(qos_conf, pkts, cnt, should_steal);
rte_spinlock_unlock(&qos_conf->lock);
}

Expand Down Expand Up @@ -3655,14 +3655,14 @@ egress_policer_qos_is_equal(const struct qos_conf *conf,

static int
egress_policer_run(struct qos_conf *conf, struct rte_mbuf **pkts, int pkt_cnt,
bool may_steal)
bool should_steal)
{
int cnt = 0;
struct egress_policer *policer =
CONTAINER_OF(conf, struct egress_policer, qos_conf);

cnt = netdev_dpdk_policer_run(&policer->egress_meter, pkts,
pkt_cnt, may_steal);
pkt_cnt, should_steal);

return cnt;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/odp-execute.c
Expand Up @@ -713,9 +713,9 @@ odp_execute_actions(void *dp, struct dp_packet_batch *batch, bool steal,
if (dp_execute_action) {
/* Allow 'dp_execute_action' to steal the packet data if we do
* not need it any more. */
bool may_steal = steal && last_action;
bool should_steal = steal && last_action;

dp_execute_action(dp, batch, a, may_steal);
dp_execute_action(dp, batch, a, should_steal);

if (last_action || batch->count == 0) {
/* We do not need to free the packets.
Expand Down
2 changes: 1 addition & 1 deletion lib/odp-execute.h
Expand Up @@ -29,7 +29,7 @@ struct pkt_metadata;
struct dp_packet_batch;

typedef void (*odp_execute_cb)(void *dp, struct dp_packet_batch *batch,
const struct nlattr *action, bool may_steal);
const struct nlattr *action, bool should_steal);

/* Actions that need to be executed in the context of a datapath are handed
* to 'dp_execute_action', if non-NULL. Currently this is called only for
Expand Down

0 comments on commit 7d7ded7

Please sign in to comment.