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

Commit cb12a8e2 authored by Parav Pandit's avatar Parav Pandit Committed by Jason Gunthorpe
Browse files

IB/cm: Introduce and use helper function to get cm_port from path



Introduce and use helper function get_cm_port_from_path() to get
cm_port based on the the path record entry.

Reviewed-by: default avatarDaniel Jurgens <danielj@mellanox.com>
Signed-off-by: default avatarParav Pandit <parav@mellanox.com>
Signed-off-by: default avatarLeon Romanovsky <leon@kernel.org>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent 0a514159
Loading
Loading
Loading
Loading
+13 −4
Original line number Diff line number Diff line
@@ -482,13 +482,11 @@ static int add_cm_id_to_port_list(struct cm_id_private *cm_id_priv,
	return ret;
}

static int cm_init_av_by_path(struct sa_path_rec *path, struct cm_av *av,
			      struct cm_id_private *cm_id_priv)
static struct cm_port *get_cm_port_from_path(struct sa_path_rec *path)
{
	struct cm_device *cm_dev;
	struct cm_port *port = NULL;
	unsigned long flags;
	int ret;
	u8 p;
	struct net_device *ndev = ib_get_ndev_from_path(path);

@@ -505,9 +503,20 @@ static int cm_init_av_by_path(struct sa_path_rec *path, struct cm_av *av,

	if (ndev)
		dev_put(ndev);
	return port;
}

static int cm_init_av_by_path(struct sa_path_rec *path, struct cm_av *av,
			      struct cm_id_private *cm_id_priv)
{
	struct cm_device *cm_dev;
	struct cm_port *port;
	int ret;

	port = get_cm_port_from_path(path);
	if (!port)
		return -EINVAL;
	cm_dev = port->cm_dev;

	ret = ib_find_cached_pkey(cm_dev->ib_device, port->port_num,
				  be16_to_cpu(path->pkey), &av->pkey_index);