Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 55ee3ab2 authored by Matan Barak's avatar Matan Barak Committed by Doug Ledford
Browse files

IB/core: Add netdev and gid attributes paramteres to cache



Adding an ability to query the IB cache by a netdev and get the
attributes of a GID. These parameters are necessary in order to
successfully resolve the required GID (when the netdevice is known)
and get the Ethernet L2 attributes from a GID.

Signed-off-by: default avatarMatan Barak <matanb@mellanox.com>
Reviewed-By: default avatarDevesh Sharma <devesh.sharma@avagotech.com>
Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
parent fbfb6625
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -649,21 +649,23 @@ static int gid_table_setup_one(struct ib_device *ib_dev)
int ib_get_cached_gid(struct ib_device *device,
		      u8                port_num,
		      int               index,
		      union ib_gid     *gid)
		      union ib_gid     *gid,
		      struct ib_gid_attr *gid_attr)
{
	if (port_num < rdma_start_port(device) || port_num > rdma_end_port(device))
		return -EINVAL;

	return __ib_cache_gid_get(device, port_num, index, gid, NULL);
	return __ib_cache_gid_get(device, port_num, index, gid, gid_attr);
}
EXPORT_SYMBOL(ib_get_cached_gid);

int ib_find_cached_gid(struct ib_device *device,
		       const union ib_gid *gid,
		       struct net_device *ndev,
		       u8               *port_num,
		       u16              *index)
{
	return ib_cache_gid_find(device, gid, NULL, port_num, index);
	return ib_cache_gid_find(device, gid, ndev, port_num, index);
}
EXPORT_SYMBOL(ib_find_cached_gid);

@@ -845,7 +847,7 @@ static void ib_cache_update(struct ib_device *device,
	if (!use_roce_gid_table) {
		for (i = 0;  i < gid_cache->table_len; ++i) {
			ret = ib_query_gid(device, port, i,
					   gid_cache->table + i);
					   gid_cache->table + i, NULL);
			if (ret) {
				printk(KERN_WARNING "ib_query_gid failed (%d) for %s (index %d)\n",
				       ret, device->name, i);
+3 −2
Original line number Diff line number Diff line
@@ -365,7 +365,7 @@ static int cm_init_av_by_path(struct ib_sa_path_rec *path, struct cm_av *av)
	read_lock_irqsave(&cm.device_lock, flags);
	list_for_each_entry(cm_dev, &cm.device_list, list) {
		if (!ib_find_cached_gid(cm_dev->ib_device, &path->sgid,
					&p, NULL)) {
					NULL, &p, NULL)) {
			port = cm_dev->port[p-1];
			break;
		}
@@ -1643,7 +1643,8 @@ static int cm_req_handler(struct cm_work *work)
	ret = cm_init_av_by_path(&work->path[0], &cm_id_priv->av);
	if (ret) {
		ib_get_cached_gid(work->port->cm_dev->ib_device,
				  work->port->port_num, 0, &work->path[0].sgid);
				  work->port->port_num, 0, &work->path[0].sgid,
				  NULL);
		ib_send_cm_rej(cm_id, IB_CM_REJ_INVALID_GID,
			       &work->path[0].sgid, sizeof work->path[0].sgid,
			       NULL, 0);
+6 −4
Original line number Diff line number Diff line
@@ -438,7 +438,7 @@ static inline int cma_validate_port(struct ib_device *device, u8 port,
	if ((dev_type != ARPHRD_INFINIBAND) && rdma_protocol_ib(device, port))
		return ret;

	ret = ib_find_cached_gid(device, gid, &found_port, NULL);
	ret = ib_find_cached_gid(device, gid, NULL, &found_port, NULL);
	if (port != found_port)
		return -ENODEV;

@@ -531,7 +531,9 @@ static int cma_resolve_ib_dev(struct rdma_id_private *id_priv)
			if (ib_find_cached_pkey(cur_dev->device, p, pkey, &index))
				continue;

			for (i = 0; !ib_get_cached_gid(cur_dev->device, p, i, &gid); i++) {
			for (i = 0; !ib_get_cached_gid(cur_dev->device, p, i,
						       &gid, NULL);
			     i++) {
				if (!memcmp(&gid, dgid, sizeof(gid))) {
					cma_dev = cur_dev;
					sgid = gid;
@@ -718,7 +720,7 @@ static int cma_modify_qp_rtr(struct rdma_id_private *id_priv,
		goto out;

	ret = ib_query_gid(id_priv->id.device, id_priv->id.port_num,
			   qp_attr.ah_attr.grh.sgid_index, &sgid);
			   qp_attr.ah_attr.grh.sgid_index, &sgid, NULL);
	if (ret)
		goto out;

@@ -2426,7 +2428,7 @@ static int cma_bind_loopback(struct rdma_id_private *id_priv)
	p = 1;

port_found:
	ret = ib_get_cached_gid(cma_dev->device, p, 0, &gid);
	ret = ib_get_cached_gid(cma_dev->device, p, 0, &gid, NULL);
	if (ret)
		goto out;

+12 −5
Original line number Diff line number Diff line
@@ -672,14 +672,20 @@ EXPORT_SYMBOL(ib_query_port);
 * @port_num:Port number to query
 * @index:GID table index to query
 * @gid:Returned GID
 * @attr: Returned GID attributes related to this GID index (only in RoCE).
 *   NULL means ignore.
 *
 * ib_query_gid() fetches the specified GID table entry.
 */
int ib_query_gid(struct ib_device *device,
		 u8 port_num, int index, union ib_gid *gid)
		 u8 port_num, int index, union ib_gid *gid,
		 struct ib_gid_attr *attr)
{
	if (rdma_cap_roce_gid_table(device, port_num))
		return ib_get_cached_gid(device, port_num, index, gid);
		return ib_get_cached_gid(device, port_num, index, gid, attr);

	if (attr)
		return -EINVAL;

	return device->query_gid(device, port_num, index, gid);
}
@@ -819,12 +825,13 @@ EXPORT_SYMBOL(ib_modify_port);
 *   a specified GID value occurs.
 * @device: The device to query.
 * @gid: The GID value to search for.
 * @ndev: The ndev related to the GID 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)
		struct net_device *ndev, u8 *port_num, u16 *index)
{
	union ib_gid tmp_gid;
	int ret, port, i;
@@ -832,14 +839,14 @@ int ib_find_gid(struct ib_device *device, union ib_gid *gid,
	for (port = rdma_start_port(device); port <= rdma_end_port(device); ++port) {
		if (rdma_cap_roce_gid_table(device, port)) {
			if (!ib_cache_gid_find_by_port(device, gid, port,
						       NULL, index)) {
						       ndev, index)) {
				*port_num = port;
				return 0;
			}
		}

		for (i = 0; i < device->port_immutable[port].gid_tbl_len; ++i) {
			ret = ib_query_gid(device, port, i, &tmp_gid);
			ret = ib_query_gid(device, port, i, &tmp_gid, NULL);
			if (ret)
				return ret;
			if (!memcmp(&tmp_gid, gid, sizeof *gid)) {
+1 −1
Original line number Diff line number Diff line
@@ -1877,7 +1877,7 @@ static inline int rcv_has_same_gid(const struct ib_mad_agent_private *mad_agent_
					  ((1 << lmc) - 1)));
		} else {
			if (ib_get_cached_gid(device, port_num,
					      attr.grh.sgid_index, &sgid))
					      attr.grh.sgid_index, &sgid, NULL))
				return 0;
			return !memcmp(sgid.raw, rwc->recv_buf.grh->dgid.raw,
				       16);
Loading