Simplify callers for ibv_resolve_eth_l2_from_gid() by let them pass NULL vid, in case that they aren't interested in it. Signed-off-by: Kamal Heib <kamalheib1@xxxxxxxxx> --- libibverbs/verbs.c | 11 +++++++---- providers/mlx5/verbs.c | 4 +--- providers/vmw_pvrdma/verbs.c | 3 +-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/libibverbs/verbs.c b/libibverbs/verbs.c index 9cdc361b5610..188bccbaf860 100644 --- a/libibverbs/verbs.c +++ b/libibverbs/verbs.c @@ -1021,10 +1021,12 @@ int ibv_resolve_eth_l2_from_gid(struct ibv_context *context, if (process_get_neigh(&neigh_handler)) goto free_resources; - ret_vid = neigh_get_vlan_id_from_dev(&neigh_handler); + if (vid) { + ret_vid = neigh_get_vlan_id_from_dev(&neigh_handler); - if (ret_vid <= 0xfff) - neigh_set_vlan_id(&neigh_handler, ret_vid); + if (ret_vid <= 0xfff) + neigh_set_vlan_id(&neigh_handler, ret_vid); + } /* We are using only Ethernet here */ ether_len = neigh_get_ll(&neigh_handler, @@ -1034,7 +1036,8 @@ int ibv_resolve_eth_l2_from_gid(struct ibv_context *context, if (ether_len <= 0) goto free_resources; - *vid = ret_vid; + if (vid) + *vid = ret_vid; ret = 0; diff --git a/providers/mlx5/verbs.c b/providers/mlx5/verbs.c index 7a655a174f7b..930d6cd3cc2d 100644 --- a/providers/mlx5/verbs.c +++ b/providers/mlx5/verbs.c @@ -2454,10 +2454,8 @@ struct ibv_ah *mlx5_create_ah(struct ibv_pd *pd, struct ibv_ah_attr *attr) ah->kern_ah = true; memcpy(ah->av.rmac, resp.dmac, ETHERNET_LL_SIZE); } else { - uint16_t vid; - if (ibv_resolve_eth_l2_from_gid(pd->context, attr, - ah->av.rmac, &vid)) + ah->av.rmac, NULL)) goto err; } } diff --git a/providers/vmw_pvrdma/verbs.c b/providers/vmw_pvrdma/verbs.c index b9819390ba8d..e27952bff1bb 100644 --- a/providers/vmw_pvrdma/verbs.c +++ b/providers/vmw_pvrdma/verbs.c @@ -190,7 +190,6 @@ struct ibv_ah *pvrdma_create_ah(struct ibv_pd *pd, struct pvrdma_ah *ah; struct pvrdma_av *av; struct ibv_port_attr port_attr; - uint16_t vlan_id; if (!attr->is_global) return NULL; @@ -224,7 +223,7 @@ struct ibv_ah *pvrdma_create_ah(struct ibv_pd *pd, if (port_attr.port_cap_flags & IBV_PORT_IP_BASED_GIDS) { if (!ibv_resolve_eth_l2_from_gid(pd->context, attr, - av->dmac, &vlan_id)) + av->dmac, NULL)) return &ah->ibv_ah; } else { if (!set_mac_from_gid(&attr->grh.dgid, av->dmac)) -- 2.20.1