/* ib_find_gid - Returns the port number and GID table index where a specified GID value occurs. @device: The device to query. @gid: The GID value to search for. @port_num: The port number of the device where the GID value was found. @index: The index into the GID table where the GID was found. This parameter may be NULL.  */
int ib_find_gid(struct ib_device *device, union ib_gid *gid, u8 *port_num, u16 *index)
/* ib_find_gid - Returns the port number and GID table index where a specified GID value occurs. @device: The device to query. @gid: The GID value to search for. @port_num: The port number of the device where the GID value was found. @index: The index into the GID table where the GID was found. This parameter may be NULL.  */
int ib_find_gid(struct ib_device *device, union ib_gid *gid, u8 *port_num, u16 *index)
{
	union ib_gid tmp_gid;
	int ret, port, i;
	for (port = start_port(device); port <= end_port(device); ++port) {
		for (i = 0; i < device->gid_tbl_len[port - start_port(device)]; ++i) {
			ret = ib_query_gid(device, port, i, &tmp_gid);
			if (ret)
				return ret;
			if (!memcmp(&tmp_gid, gid, sizeof *gid)) {
				*port_num = port;
				if (index)
					*index = i;
				return 0;
			}
		}
	}
	return -ENOENT;
}