[ovs-dev] [PATCH 2/3] netdev: Change macro to function.
Ben Pfaff
blp at ovn.org
Tue Nov 14 18:14:32 UTC 2017
On Mon, Nov 13, 2017 at 06:41:20PM -0800, Gregory Rose wrote:
>
>
> On 11/13/2017 2:04 PM, Ben Pfaff wrote:
> >There was no reason that this should have been a macro.
> >
> >Signed-off-by: Ben Pfaff <blp at ovn.org>
> >---
> > lib/netdev.c | 17 ++++++++++-------
> > 1 file changed, 10 insertions(+), 7 deletions(-)
> >
> >diff --git a/lib/netdev.c b/lib/netdev.c
> >index 7792b1b75681..8dd35864d7cb 100644
> >--- a/lib/netdev.c
> >+++ b/lib/netdev.c
> >@@ -2179,18 +2179,21 @@ struct ifindex_to_port_data {
> > const struct dpif_class *dpif_class;
> > };
> >-#define NETDEV_PORTS_HASH_INT(port, dpif) \
> >- hash_int(odp_to_u32(port),\
> >- hash_pointer(dpif, 0));
> >+static uint32_t
> >+netdev_ports_hash(odp_port_t port, const struct dpif_class *dpif_class)
> >+{
> >+ return hash_int(odp_to_u32(port), hash_pointer(dpif_class, 0));
> >+}
> > static struct port_to_netdev_data *
> > netdev_ports_lookup(odp_port_t port_no, const struct dpif_class *dpif_class)
> > OVS_REQUIRES(netdev_hmap_mutex)
> > {
> >- size_t hash = NETDEV_PORTS_HASH_INT(port_no, dpif_class);
> > struct port_to_netdev_data *data;
> >- HMAP_FOR_EACH_WITH_HASH (data, node, hash, &port_to_netdev) {
> >+ HMAP_FOR_EACH_WITH_HASH (data, node,
> >+ netdev_ports_hash(port_no, dpif_class),
> >+ &port_to_netdev) {
> > if (data->dpif_class == dpif_class
> > && data->dpif_port.port_no == port_no) {
> > return data;
> >@@ -2203,7 +2206,6 @@ int
> > netdev_ports_insert(struct netdev *netdev, const struct dpif_class *dpif_class,
> > struct dpif_port *dpif_port)
> > {
> >- size_t hash = NETDEV_PORTS_HASH_INT(dpif_port->port_no, dpif_class);
> > struct port_to_netdev_data *data;
> > struct ifindex_to_port_data *ifidx;
> > int ifindex = netdev_get_ifindex(netdev);
> >@@ -2228,7 +2230,8 @@ netdev_ports_insert(struct netdev *netdev, const struct dpif_class *dpif_class,
> > ifidx->port = dpif_port->port_no;
> > ifidx->dpif_class = dpif_class;
> >- hmap_insert(&port_to_netdev, &data->node, hash);
> >+ hmap_insert(&port_to_netdev, &data->node,
> >+ netdev_ports_hash(dpif_port->port_no, dpif_class));
> > hmap_insert(&ifindex_to_port, &ifidx->node, ifidx->ifindex);
> > ovs_mutex_unlock(&netdev_hmap_mutex);
> Much better.
>
> Reviewed-by: Greg Rose <gvrose8192 at gmail.com>
>
Thanks, I applied this to master.
More information about the dev
mailing list