2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-31 06:15:47 +00:00

netdev: Change macro to function.

There was no reason that this should have been a macro.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Reviewed-by: Greg Rose <gvrose8192@gmail.com>
This commit is contained in:
Ben Pfaff
2017-11-13 12:40:29 -08:00
parent 1f3c6b2d23
commit 0d8efdc9ca

View File

@@ -2179,22 +2179,25 @@ 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) {
if (data->dpif_class == dpif_class
&& data->dpif_port.port_no == port_no) {
return data;
}
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;
}
}
return NULL;
}
@@ -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);