From b85d8d61a6c3b9c2fa578fa62c795a93544764af Mon Sep 17 00:00:00 2001 From: pravin shelar Date: Thu, 28 Jul 2011 09:05:25 -0700 Subject: [PATCH] Datapath action should not refer to controller ODP_ACTION_ATTR_CONTROLLER in the kernel actually sends packets to userspace, not the controller. To make it generic rename this action to ODP_ACTION_ATTR_USERSPACE. Signed-off-by: Pravin B Shelar --- AUTHORS | 1 + datapath/actions.c | 6 +++--- datapath/datapath.c | 10 +++++----- include/openvswitch/datapath-protocol.h | 10 +++++----- lib/dpif-netdev.c | 12 ++++++------ lib/dpif.h | 4 ++-- lib/odp-util.c | 6 +++--- ofproto/ofproto-dpif.c | 4 ++-- 8 files changed, 27 insertions(+), 26 deletions(-) diff --git a/AUTHORS b/AUTHORS index 62c19d5e..aeb32629 100644 --- a/AUTHORS +++ b/AUTHORS @@ -24,6 +24,7 @@ Martin Casado casado@nicira.com Natasha Gude natasha@nicira.com Neil McKee neil.mckee@inmon.com Paul Fazzone pfazzone@nicira.com +Pravin B Shelar pshelar@nicira.com Reid Price reid@nicira.com Romain Lenglet romain.lenglet@berabera.info Sajjad Lateef slateef@nicira.com diff --git a/datapath/actions.c b/datapath/actions.c index ed61039a..78712c6a 100644 --- a/datapath/actions.c +++ b/datapath/actions.c @@ -218,7 +218,7 @@ error: kfree_skb(skb); } -static int output_control(struct datapath *dp, struct sk_buff *skb, u64 arg) +static int output_userspace(struct datapath *dp, struct sk_buff *skb, u64 arg) { struct dp_upcall_info upcall; @@ -262,8 +262,8 @@ static int do_execute_actions(struct datapath *dp, struct sk_buff *skb, prev_port = nla_get_u32(a); break; - case ODP_ACTION_ATTR_CONTROLLER: - err = output_control(dp, skb, nla_get_u64(a)); + case ODP_ACTION_ATTR_USERSPACE: + err = output_userspace(dp, skb, nla_get_u64(a)); break; case ODP_ACTION_ATTR_SET_TUNNEL: diff --git a/datapath/datapath.c b/datapath/datapath.c index d1493445..a964c27f 100644 --- a/datapath/datapath.c +++ b/datapath/datapath.c @@ -84,7 +84,7 @@ EXPORT_SYMBOL(dp_ioctl_hook); static LIST_HEAD(dps); static struct vport *new_vport(const struct vport_parms *); -static int queue_control_packets(struct datapath *, struct sk_buff *, +static int queue_userspace_packets(struct datapath *, struct sk_buff *, const struct dp_upcall_info *); /* Must be called with rcu_read_lock, genl_mutex, or RTNL lock. */ @@ -415,7 +415,7 @@ int dp_upcall(struct datapath *dp, struct sk_buff *skb, const struct dp_upcall_i skb = nskb; } - err = queue_control_packets(dp, skb, upcall_info); + err = queue_userspace_packets(dp, skb, upcall_info); if (err) goto err; @@ -438,7 +438,7 @@ err: * 'upcall_info'. There will be only one packet unless we broke up a GSO * packet. */ -static int queue_control_packets(struct datapath *dp, struct sk_buff *skb, +static int queue_userspace_packets(struct datapath *dp, struct sk_buff *skb, const struct dp_upcall_info *upcall_info) { u32 group = packet_mc_group(dp, upcall_info->cmd); @@ -552,7 +552,7 @@ static int validate_actions(const struct nlattr *attr) nla_for_each_nested(a, attr, rem) { static const u32 action_lens[ODP_ACTION_ATTR_MAX + 1] = { [ODP_ACTION_ATTR_OUTPUT] = 4, - [ODP_ACTION_ATTR_CONTROLLER] = 8, + [ODP_ACTION_ATTR_USERSPACE] = 8, [ODP_ACTION_ATTR_SET_DL_TCI] = 2, [ODP_ACTION_ATTR_STRIP_VLAN] = 0, [ODP_ACTION_ATTR_SET_DL_SRC] = ETH_ALEN, @@ -575,7 +575,7 @@ static int validate_actions(const struct nlattr *attr) case ODP_ACTION_ATTR_UNSPEC: return -EINVAL; - case ODP_ACTION_ATTR_CONTROLLER: + case ODP_ACTION_ATTR_USERSPACE: case ODP_ACTION_ATTR_STRIP_VLAN: case ODP_ACTION_ATTR_SET_DL_SRC: case ODP_ACTION_ATTR_SET_DL_DST: diff --git a/include/openvswitch/datapath-protocol.h b/include/openvswitch/datapath-protocol.h index e7708ef1..0b755e8f 100644 --- a/include/openvswitch/datapath-protocol.h +++ b/include/openvswitch/datapath-protocol.h @@ -145,7 +145,7 @@ enum odp_packet_cmd { /* Kernel-to-user notifications. */ ODP_PACKET_CMD_MISS, /* Flow table miss. */ - ODP_PACKET_CMD_ACTION, /* ODP_ACTION_ATTR_CONTROLLER action. */ + ODP_PACKET_CMD_ACTION, /* ODP_ACTION_ATTR_USERSPACE action. */ ODP_PACKET_CMD_SAMPLE, /* Sampled packet. */ /* User commands. */ @@ -157,14 +157,14 @@ enum odp_packet_cmd { * @ODP_PACKET_ATTR_PACKET: Present for all notifications. Contains the entire * packet as received, from the start of the Ethernet header onward. For * %ODP_PACKET_CMD_ACTION, %ODP_PACKET_ATTR_PACKET reflects changes made by - * actions preceding %ODP_ACTION_ATTR_CONTROLLER, but %ODP_PACKET_ATTR_KEY is + * actions preceding %ODP_ACTION_ATTR_USERSPACE, but %ODP_PACKET_ATTR_KEY is * the flow key extracted from the packet as originally received. * @ODP_PACKET_ATTR_KEY: Present for all notifications. Contains the flow key * extracted from the packet as nested %ODP_KEY_ATTR_* attributes. This allows * userspace to adapt its flow setup strategy by comparing its notion of the * flow key against the kernel's. * @ODP_PACKET_ATTR_USERDATA: Present for an %ODP_PACKET_CMD_ACTION - * notification if the %ODP_ACTION_ATTR_CONTROLLER, action's argument was + * notification if the %ODP_ACTION_ATTR_USERSPACE, action's argument was * nonzero. * @ODP_PACKET_ATTR_SAMPLE_POOL: Present for %ODP_PACKET_CMD_SAMPLE. Contains * the number of packets processed so far that were candidates for sampling. @@ -179,7 +179,7 @@ enum odp_packet_attr { ODP_PACKET_ATTR_UNSPEC, ODP_PACKET_ATTR_PACKET, /* Packet data. */ ODP_PACKET_ATTR_KEY, /* Nested ODP_KEY_ATTR_* attributes. */ - ODP_PACKET_ATTR_USERDATA, /* u64 ODP_ACTION_ATTR_CONTROLLER arg. */ + ODP_PACKET_ATTR_USERDATA, /* u64 ODP_ACTION_ATTR_USERSPACE arg. */ ODP_PACKET_ATTR_SAMPLE_POOL, /* # sampling candidate packets so far. */ ODP_PACKET_ATTR_ACTIONS, /* Nested ODP_ACTION_ATTR_* attributes. */ __ODP_PACKET_ATTR_MAX @@ -409,7 +409,7 @@ enum odp_flow_attr { enum odp_action_type { ODP_ACTION_ATTR_UNSPEC, ODP_ACTION_ATTR_OUTPUT, /* Output to switch port. */ - ODP_ACTION_ATTR_CONTROLLER, /* Send copy to controller. */ + ODP_ACTION_ATTR_USERSPACE, /* Send copy to userspace. */ ODP_ACTION_ATTR_SET_DL_TCI, /* Set the 802.1q TCI value. */ ODP_ACTION_ATTR_STRIP_VLAN, /* Strip the 802.1q header. */ ODP_ACTION_ATTR_SET_DL_SRC, /* Ethernet source address. */ diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index 3b93a4cf..d48d7ae1 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -146,7 +146,7 @@ static int do_add_port(struct dp_netdev *, const char *devname, static int do_del_port(struct dp_netdev *, uint16_t port_no); static int dpif_netdev_open(const struct dpif_class *, const char *name, bool create, struct dpif **); -static int dp_netdev_output_control(struct dp_netdev *, const struct ofpbuf *, +static int dp_netdev_output_userspace(struct dp_netdev *, const struct ofpbuf *, int queue_no, const struct flow *, uint64_t arg); static int dp_netdev_execute_actions(struct dp_netdev *, @@ -707,7 +707,7 @@ dpif_netdev_validate_actions(const struct nlattr *actions, } break; - case ODP_ACTION_ATTR_CONTROLLER: + case ODP_ACTION_ATTR_USERSPACE: break; case ODP_ACTION_ATTR_SET_DL_TCI: @@ -1088,7 +1088,7 @@ dp_netdev_port_input(struct dp_netdev *dp, struct dp_netdev_port *port, dp->n_hit++; } else { dp->n_missed++; - dp_netdev_output_control(dp, packet, DPIF_UC_MISS, &key, 0); + dp_netdev_output_userspace(dp, packet, DPIF_UC_MISS, &key, 0); } } @@ -1252,7 +1252,7 @@ dp_netdev_output_port(struct dp_netdev *dp, struct ofpbuf *packet, } static int -dp_netdev_output_control(struct dp_netdev *dp, const struct ofpbuf *packet, +dp_netdev_output_userspace(struct dp_netdev *dp, const struct ofpbuf *packet, int queue_no, const struct flow *flow, uint64_t arg) { struct dp_netdev_queue *q = &dp->queues[queue_no]; @@ -1299,8 +1299,8 @@ dp_netdev_execute_actions(struct dp_netdev *dp, dp_netdev_output_port(dp, packet, nl_attr_get_u32(a)); break; - case ODP_ACTION_ATTR_CONTROLLER: - dp_netdev_output_control(dp, packet, DPIF_UC_ACTION, + case ODP_ACTION_ATTR_USERSPACE: + dp_netdev_output_userspace(dp, packet, DPIF_UC_ACTION, key, nl_attr_get_u64(a)); break; diff --git a/lib/dpif.h b/lib/dpif.h index 4a71153a..4df23184 100644 --- a/lib/dpif.h +++ b/lib/dpif.h @@ -155,7 +155,7 @@ int dpif_execute(struct dpif *, enum dpif_upcall_type { DPIF_UC_MISS, /* Miss in flow table. */ - DPIF_UC_ACTION, /* ODP_ACTION_ATTR_CONTROLLER action. */ + DPIF_UC_ACTION, /* ODP_ACTION_ATTR_USERSPACE action. */ DPIF_UC_SAMPLE, /* Packet sampling. */ DPIF_N_UC_TYPES }; @@ -177,7 +177,7 @@ struct dpif_upcall { size_t key_len; /* Length of 'key' in bytes. */ /* DPIF_UC_ACTION only. */ - uint64_t userdata; /* Argument to ODP_ACTION_ATTR_CONTROLLER. */ + uint64_t userdata; /* Argument to ODP_ACTION_ATTR_USERSPACE. */ /* DPIF_UC_SAMPLE only. */ uint32_t sample_pool; /* # of sampling candidate packets so far. */ diff --git a/lib/odp-util.c b/lib/odp-util.c index d7a3118b..93f8f8a0 100644 --- a/lib/odp-util.c +++ b/lib/odp-util.c @@ -41,7 +41,7 @@ odp_action_len(uint16_t type) switch ((enum odp_action_type) type) { case ODP_ACTION_ATTR_OUTPUT: return 4; - case ODP_ACTION_ATTR_CONTROLLER: return 8; + case ODP_ACTION_ATTR_USERSPACE: return 8; case ODP_ACTION_ATTR_SET_DL_TCI: return 2; case ODP_ACTION_ATTR_STRIP_VLAN: return 0; case ODP_ACTION_ATTR_SET_DL_SRC: return ETH_ADDR_LEN; @@ -99,8 +99,8 @@ format_odp_action(struct ds *ds, const struct nlattr *a) case ODP_ACTION_ATTR_OUTPUT: ds_put_format(ds, "%"PRIu16, nl_attr_get_u32(a)); break; - case ODP_ACTION_ATTR_CONTROLLER: - ds_put_format(ds, "ctl(%"PRIu64")", nl_attr_get_u64(a)); + case ODP_ACTION_ATTR_USERSPACE: + ds_put_format(ds, "userspace(%"PRIu64")", nl_attr_get_u64(a)); break; case ODP_ACTION_ATTR_SET_TUNNEL: ds_put_format(ds, "set_tunnel(%#"PRIx64")", diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c index 1165570a..8bd6f752 100644 --- a/ofproto/ofproto-dpif.c +++ b/ofproto/ofproto-dpif.c @@ -2047,7 +2047,7 @@ execute_odp_actions(struct ofproto_dpif *ofproto, const struct flow *flow, struct ofpbuf *packet) { if (actions_len == NLA_ALIGN(NLA_HDRLEN + sizeof(uint64_t)) - && odp_actions->nla_type == ODP_ACTION_ATTR_CONTROLLER) { + && odp_actions->nla_type == ODP_ACTION_ATTR_USERSPACE) { /* As an optimization, avoid a round-trip from userspace to kernel to * userspace. This also avoids possibly filling up kernel packet * buffers along the way. */ @@ -2956,7 +2956,7 @@ xlate_output_action__(struct action_xlate_ctx *ctx, break; case OFPP_CONTROLLER: commit_odp_actions(ctx); - nl_msg_put_u64(ctx->odp_actions, ODP_ACTION_ATTR_CONTROLLER, max_len); + nl_msg_put_u64(ctx->odp_actions, ODP_ACTION_ATTR_USERSPACE, max_len); break; case OFPP_LOCAL: add_output_action(ctx, OFPP_LOCAL); -- 2.30.2