[ovs-dev] [PATCH v2 02/12] openvswitch.h: Use odp_port_t for port numbers in userspace-only structs.
nickcooper-zhangtonghao
nic at opencloud.tech
Mon Jun 19 01:07:45 UTC 2017
Reviewed-by: nickcooper-zhangtonghao <nic at opencloud.tech>
> On Jun 19, 2017, at 7:29 AM, Ben Pfaff <blp at ovn.org> wrote:
>
> Using the correct type reduces the need for type conversions.
>
> Signed-off-by: Ben Pfaff <blp at ovn.org <mailto:blp at ovn.org>>
> ---
> datapath/linux/compat/include/linux/openvswitch.h | 4 ++--
> lib/dpif-netdev.c | 2 +-
> lib/netdev.c | 2 +-
> ofproto/ofproto-dpif-sflow.c | 2 +-
> ofproto/ofproto-dpif-xlate.c | 4 ++--
> 5 files changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/datapath/linux/compat/include/linux/openvswitch.h b/datapath/linux/compat/include/linux/openvswitch.h
> index 4c88de1d610d..24e51cb311d2 100644
> --- a/datapath/linux/compat/include/linux/openvswitch.h
> +++ b/datapath/linux/compat/include/linux/openvswitch.h
> @@ -714,8 +714,8 @@ struct ovs_action_hash {
> * this header to build final header according to actual packet parameters.
> */
> struct ovs_action_push_tnl {
> - uint32_t tnl_port;
> - uint32_t out_port;
> + odp_port_t tnl_port;
> + odp_port_t out_port;
> uint32_t header_len;
> uint32_t tnl_type; /* For logging. */
> uint32_t header[TNL_PUSH_HEADER_SIZE / 4];
> diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
> index 2b65dc74a269..f97e97ab2931 100644
> --- a/lib/dpif-netdev.c
> +++ b/lib/dpif-netdev.c
> @@ -4956,7 +4956,7 @@ push_tnl_action(const struct dp_netdev_pmd_thread *pmd,
>
> data = nl_attr_get(attr);
>
> - tun_port = pmd_tnl_port_cache_lookup(pmd, u32_to_odp(data->tnl_port));
> + tun_port = pmd_tnl_port_cache_lookup(pmd, data->tnl_port);
> if (!tun_port) {
> err = -EINVAL;
> goto error;
> diff --git a/lib/netdev.c b/lib/netdev.c
> index 001b7b37bb57..765bf4b9ccad 100644
> --- a/lib/netdev.c
> +++ b/lib/netdev.c
> @@ -831,7 +831,7 @@ netdev_push_header(const struct netdev *netdev,
> struct dp_packet *packet;
> DP_PACKET_BATCH_FOR_EACH (packet, batch) {
> netdev->netdev_class->push_header(packet, data);
> - pkt_metadata_init(&packet->md, u32_to_odp(data->out_port));
> + pkt_metadata_init(&packet->md, data->out_port);
> }
>
> return 0;
> diff --git a/ofproto/ofproto-dpif-sflow.c b/ofproto/ofproto-dpif-sflow.c
> index d9fddb1564b5..fc665a636853 100644
> --- a/ofproto/ofproto-dpif-sflow.c
> +++ b/ofproto/ofproto-dpif-sflow.c
> @@ -901,7 +901,7 @@ sflow_read_tnl_push_action(const struct nlattr *attr,
> const struct ip_header *ip
> = ALIGNED_CAST(const struct ip_header *, eth + 1);
>
> - sflow_actions->out_port = u32_to_odp(data->out_port);
> + sflow_actions->out_port = data->out_port;
>
> /* Ethernet. */
> /* TODO: SFlow does not currently define a MAC-in-MAC
> diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c
> index e15e3dec3f1c..48c4bad4ac0b 100644
> --- a/ofproto/ofproto-dpif-xlate.c
> +++ b/ofproto/ofproto-dpif-xlate.c
> @@ -3211,8 +3211,8 @@ build_tunnel_send(struct xlate_ctx *ctx, const struct xport *xport,
> if (err) {
> return err;
> }
> - tnl_push_data.tnl_port = odp_to_u32(tunnel_odp_port);
> - tnl_push_data.out_port = odp_to_u32(out_dev->odp_port);
> + tnl_push_data.tnl_port = tunnel_odp_port;
> + tnl_push_data.out_port = out_dev->odp_port;
>
> /* After tunnel header has been added, packet_type of flow and base_flow
> * need to be set to PT_ETH. */
> --
> 2.10.2
More information about the dev
mailing list