In netdev_send_batch(), I'd change 'c' to a size_t and rename it
"buffers_len".  That way it's a bit clearer what it is.

Acked-by: Ethan Jackson <et...@nicira.com>


On Fri, May 23, 2014 at 11:04 AM, Daniele Di Proietto
<ddiproie...@vmware.com> wrote:
> Signed-off-by: Daniele Di Proietto <ddiproie...@vmware.com>
> ---
>  lib/dpif-netdev.c            | 13 ++++++++---
>  lib/dpif.c                   | 12 ++++++----
>  lib/odp-execute.c            | 54 
> ++++++++++++++++++++++++++++++--------------
>  lib/odp-execute.h            |  8 +++----
>  ofproto/ofproto-dpif-xlate.c |  3 ++-
>  5 files changed, 61 insertions(+), 29 deletions(-)
>
> diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
> index d50452f..43bfc20 100644
> --- a/lib/dpif-netdev.c
> +++ b/lib/dpif-netdev.c
> @@ -2108,8 +2108,8 @@ struct dp_netdev_execute_aux {
>  };
>
>  static void
> -dp_execute_cb(void *aux_, struct ofpbuf *packet,
> -              struct pkt_metadata *md,
> +dp_execute_cb(void *aux_, struct ofpbuf **packets, int c,
> +              struct pkt_metadata **pmd,
>                const struct nlattr *a, bool may_steal)
>      OVS_NO_THREAD_SAFETY_ANALYSIS
>  {
> @@ -2117,6 +2117,13 @@ dp_execute_cb(void *aux_, struct ofpbuf *packet,
>      int type = nl_attr_type(a);
>      struct dp_netdev_port *p;
>      uint32_t *depth = recirc_depth_get();
> +    struct ofpbuf * packet;
> +    struct pkt_metadata * md;
> +
> +    ovs_assert(c==1);
> +
> +    packet = packets[0];
> +    md = pmd[0];
>
>      switch ((enum ovs_action_attr)type) {
>      case OVS_ACTION_ATTR_OUTPUT:
> @@ -2203,7 +2210,7 @@ dp_netdev_execute_actions(struct dp_netdev *dp, const 
> struct miniflow *key,
>  {
>      struct dp_netdev_execute_aux aux = {dp, key};
>
> -    odp_execute_actions(&aux, packet, may_steal, md,
> +    odp_execute_actions(&aux, &packet, 1, may_steal, &md,
>                          actions, actions_len, dp_execute_cb);
>  }
>
> diff --git a/lib/dpif.c b/lib/dpif.c
> index 84dba28..517e33a 100644
> --- a/lib/dpif.c
> +++ b/lib/dpif.c
> @@ -1058,13 +1058,16 @@ struct dpif_execute_helper_aux {
>  /* This is called for actions that need the context of the datapath to be
>   * meaningful. */
>  static void
> -dpif_execute_helper_cb(void *aux_, struct ofpbuf *packet,
> -                       struct pkt_metadata *md,
> +dpif_execute_helper_cb(void *aux_, struct ofpbuf **packets, int c,
> +                       struct pkt_metadata **md,
>                         const struct nlattr *action, bool may_steal 
> OVS_UNUSED)
>  {
>      struct dpif_execute_helper_aux *aux = aux_;
>      struct dpif_execute execute;
>      int type = nl_attr_type(action);
> +    struct ofpbuf * packet = packets[0];
> +
> +    ovs_assert(c == 1);
>
>      switch ((enum ovs_action_attr)type) {
>      case OVS_ACTION_ATTR_OUTPUT:
> @@ -1072,7 +1075,7 @@ dpif_execute_helper_cb(void *aux_, struct ofpbuf 
> *packet,
>          execute.actions = action;
>          execute.actions_len = NLA_ALIGN(action->nla_len);
>          execute.packet = packet;
> -        execute.md = *md;
> +        execute.md = **md;
>          execute.needs_help = false;
>          aux->error = aux->dpif->dpif_class->execute(aux->dpif, &execute);
>          break;
> @@ -1100,10 +1103,11 @@ static int
>  dpif_execute_with_help(struct dpif *dpif, struct dpif_execute *execute)
>  {
>      struct dpif_execute_helper_aux aux = {dpif, 0};
> +    struct pkt_metadata * md = &execute->md;
>
>      COVERAGE_INC(dpif_execute_with_help);
>
> -    odp_execute_actions(&aux, execute->packet, false, &execute->md,
> +    odp_execute_actions(&aux, &execute->packet, 1, false, &md,
>                          execute->actions, execute->actions_len,
>                          dpif_execute_helper_cb);
>      return aux.error;
> diff --git a/lib/odp-execute.c b/lib/odp-execute.c
> index 12ad679..8463832 100644
> --- a/lib/odp-execute.c
> +++ b/lib/odp-execute.c
> @@ -151,8 +151,8 @@ odp_execute_set_action(struct ofpbuf *packet, const 
> struct nlattr *a,
>  }
>
>  static void
> -odp_execute_actions__(void *dp, struct ofpbuf *packet, bool steal,
> -                      struct pkt_metadata *,
> +odp_execute_actions__(void *dp, struct ofpbuf **packets, int c, bool steal,
> +                      struct pkt_metadata **,
>                        const struct nlattr *actions, size_t actions_len,
>                        odp_execute_cb dp_execute_action, bool more_actions);
>
> @@ -186,20 +186,22 @@ odp_execute_sample(void *dp, struct ofpbuf *packet, 
> bool steal,
>          }
>      }
>
> -    odp_execute_actions__(dp, packet, steal, md, nl_attr_get(subactions),
> +    odp_execute_actions__(dp, &packet, 1, steal, &md, 
> nl_attr_get(subactions),
>                            nl_attr_get_size(subactions), dp_execute_action,
>                            more_actions);
>  }
>
>  static void
> -odp_execute_actions__(void *dp, struct ofpbuf *packet, bool steal,
> -                      struct pkt_metadata *md,
> +odp_execute_actions__(void *dp, struct ofpbuf **packets, int c, bool steal,
> +                      struct pkt_metadata **md,
>                        const struct nlattr *actions, size_t actions_len,
>                        odp_execute_cb dp_execute_action, bool more_actions)
>  {
>      const struct nlattr *a;
>      unsigned int left;
>
> +    int i;
> +
>      NL_ATTR_FOR_EACH_UNSAFE (a, left, actions, actions_len) {
>          int type = nl_attr_type(a);
>
> @@ -215,37 +217,51 @@ odp_execute_actions__(void *dp, struct ofpbuf *packet, 
> bool steal,
>                  bool may_steal = steal && (!more_actions
>                                             && left <= NLA_ALIGN(a->nla_len)
>                                             && type != 
> OVS_ACTION_ATTR_RECIRC);
> -                dp_execute_action(dp, packet, md, a, may_steal);
> +                dp_execute_action(dp, packets, c, md, a, may_steal);
>              }
>              break;
>
>          case OVS_ACTION_ATTR_PUSH_VLAN: {
>              const struct ovs_action_push_vlan *vlan = nl_attr_get(a);
> -            eth_push_vlan(packet, htons(ETH_TYPE_VLAN), vlan->vlan_tci);
> +
> +            for (i = 0; i < c; i++) {
> +                eth_push_vlan(packets[i], htons(ETH_TYPE_VLAN), 
> vlan->vlan_tci);
> +            }
>              break;
>          }
>
>          case OVS_ACTION_ATTR_POP_VLAN:
> -            eth_pop_vlan(packet);
> +            for (i = 0; i < c; i++) {
> +                eth_pop_vlan(packets[i]);
> +            }
>              break;
>
>          case OVS_ACTION_ATTR_PUSH_MPLS: {
>              const struct ovs_action_push_mpls *mpls = nl_attr_get(a);
> -            push_mpls(packet, mpls->mpls_ethertype, mpls->mpls_lse);
> +            for (i = 0; i < c; i++) {
> +                push_mpls(packets[i], mpls->mpls_ethertype, mpls->mpls_lse);
> +            }
>              break;
>           }
>
>          case OVS_ACTION_ATTR_POP_MPLS:
> -            pop_mpls(packet, nl_attr_get_be16(a));
> +            for (i = 0; i < c; i++) {
> +                pop_mpls(packets[i], nl_attr_get_be16(a));
> +            }
>              break;
>
>          case OVS_ACTION_ATTR_SET:
> -            odp_execute_set_action(packet, nl_attr_get(a), md);
> +            for (i = 0; i < c; i++) {
> +                odp_execute_set_action(packets[i], nl_attr_get(a), md[i]);
> +            }
>              break;
>
>          case OVS_ACTION_ATTR_SAMPLE:
> -            odp_execute_sample(dp, packet, steal, md, a, dp_execute_action,
> -                               more_actions || left > NLA_ALIGN(a->nla_len));
> +            for (i = 0; i < c; i++) {
> +                odp_execute_sample(dp, packets[i], steal, md[i], a,
> +                                   dp_execute_action,
> +                                   more_actions || left > 
> NLA_ALIGN(a->nla_len));
> +            }
>              break;
>
>          case OVS_ACTION_ATTR_UNSPEC:
> @@ -256,16 +272,20 @@ odp_execute_actions__(void *dp, struct ofpbuf *packet, 
> bool steal,
>  }
>
>  void
> -odp_execute_actions(void *dp, struct ofpbuf *packet, bool steal,
> -                    struct pkt_metadata *md,
> +odp_execute_actions(void *dp, struct ofpbuf **packets, int c, bool steal,
> +                    struct pkt_metadata **md,
>                      const struct nlattr *actions, size_t actions_len,
>                      odp_execute_cb dp_execute_action)
>  {
> -    odp_execute_actions__(dp, packet, steal, md, actions, actions_len,
> +    odp_execute_actions__(dp, packets, c, steal, md, actions, actions_len,
>                            dp_execute_action, false);
>
>      if (!actions_len && steal) {
>          /* Drop action. */
> -        ofpbuf_delete(packet);
> +        int i = 0;
> +
> +        for (i = 0; i < c; i++) {
> +            ofpbuf_delete(packets[i]);
> +        }
>      }
>  }
> diff --git a/lib/odp-execute.h b/lib/odp-execute.h
> index 91f0c51..c5378a1 100644
> --- a/lib/odp-execute.h
> +++ b/lib/odp-execute.h
> @@ -27,16 +27,16 @@ struct nlattr;
>  struct ofpbuf;
>  struct pkt_metadata;
>
> -typedef void (*odp_execute_cb)(void *dp, struct ofpbuf *packet,
> -                               struct pkt_metadata *,
> +typedef void (*odp_execute_cb)(void *dp, struct ofpbuf **packets, int c,
> +                               struct pkt_metadata **,
>                                 const struct nlattr *action, bool may_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
>   * actions OVS_ACTION_ATTR_OUTPUT and OVS_ACTION_ATTR_USERSPACE so
>   * 'dp_execute_action' needs to handle only these. */
> -void odp_execute_actions(void *dp, struct ofpbuf *packet, bool steal,
> -                    struct pkt_metadata *,
> +void odp_execute_actions(void *dp, struct ofpbuf **packets, int c, bool 
> steal,
> +                    struct pkt_metadata **,
>                      const struct nlattr *actions, size_t actions_len,
>                      odp_execute_cb dp_execute_action);
>  #endif
> diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c
> index 022c4c7..d315680 100644
> --- a/ofproto/ofproto-dpif-xlate.c
> +++ b/ofproto/ofproto-dpif-xlate.c
> @@ -2331,6 +2331,7 @@ execute_controller_action(struct xlate_ctx *ctx, int 
> len,
>      struct ofproto_packet_in *pin;
>      struct ofpbuf *packet;
>      struct pkt_metadata md = PKT_METADATA_INITIALIZER(0);
> +    struct pkt_metadata *pmd = &md;
>
>      ctx->xout->slow |= SLOW_CONTROLLER;
>      if (!ctx->xin->packet) {
> @@ -2343,7 +2344,7 @@ execute_controller_action(struct xlate_ctx *ctx, int 
> len,
>                                            &ctx->xout->odp_actions,
>                                            &ctx->xout->wc);
>
> -    odp_execute_actions(NULL, packet, false, &md,
> +    odp_execute_actions(NULL, &packet, 1, false, &pmd,
>                          ofpbuf_data(&ctx->xout->odp_actions),
>                          ofpbuf_size(&ctx->xout->odp_actions), NULL);
>
> --
> 2.0.0.rc0
>
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to