diff options
author | Roland Dreier <roland@topspin.com> | 2005-01-14 23:19:30 -0800 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-01-14 23:19:30 -0800 |
commit | 246b4c10a1fb1b31a796c5c177cf3c2724f1bf9a (patch) | |
tree | f8c7d839efed999ac8ca667f86bc1e4da4796a87 /drivers | |
parent | 76e696e047482a6ee2fa898321f2298fda21548a (diff) | |
download | history-246b4c10a1fb1b31a796c5c177cf3c2724f1bf9a.tar.gz |
[PATCH] InfiniBand/core: add ib_find_cached_gid function
Add a new function to find a port on a device given a GID by searching the
cached GID tables. Document all cache functions in ib_cache.h. Rename
existing functions to better match format of verb routines.
Signed-off by: Sean Hefty <sean.hefty@intel.com>
Signed-off-by: Roland Dreier <roland@topspin.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/infiniband/core/cache.c | 65 | ||||
-rw-r--r-- | drivers/infiniband/hw/mthca/mthca_av.c | 2 | ||||
-rw-r--r-- | drivers/infiniband/hw/mthca/mthca_qp.c | 4 | ||||
-rw-r--r-- | drivers/infiniband/include/ib_cache.h | 62 | ||||
-rw-r--r-- | drivers/infiniband/ulp/ipoib/ipoib_ib.c | 2 | ||||
-rw-r--r-- | drivers/infiniband/ulp/ipoib/ipoib_verbs.c | 4 |
6 files changed, 112 insertions, 27 deletions
diff --git a/drivers/infiniband/core/cache.c b/drivers/infiniband/core/cache.c index d115b4f79a7929..f70fbfa11da773 100644 --- a/drivers/infiniband/core/cache.c +++ b/drivers/infiniband/core/cache.c @@ -65,8 +65,8 @@ static inline int end_port(struct ib_device *device) return device->node_type == IB_NODE_SWITCH ? 0 : device->phys_port_cnt; } -int ib_cached_gid_get(struct ib_device *device, - u8 port, +int ib_get_cached_gid(struct ib_device *device, + u8 port_num, int index, union ib_gid *gid) { @@ -74,12 +74,12 @@ int ib_cached_gid_get(struct ib_device *device, unsigned long flags; int ret = 0; - if (port < start_port(device) || port > end_port(device)) + if (port_num < start_port(device) || port_num > end_port(device)) return -EINVAL; read_lock_irqsave(&device->cache.lock, flags); - cache = device->cache.gid_cache[port - start_port(device)]; + cache = device->cache.gid_cache[port_num - start_port(device)]; if (index < 0 || index >= cache->table_len) ret = -EINVAL; @@ -90,10 +90,45 @@ int ib_cached_gid_get(struct ib_device *device, return ret; } -EXPORT_SYMBOL(ib_cached_gid_get); +EXPORT_SYMBOL(ib_get_cached_gid); -int ib_cached_pkey_get(struct ib_device *device, - u8 port, +int ib_find_cached_gid(struct ib_device *device, + union ib_gid *gid, + u8 *port_num, + u16 *index) +{ + struct ib_gid_cache *cache; + unsigned long flags; + int p, i; + int ret = -ENOENT; + + *port_num = -1; + if (index) + *index = -1; + + read_lock_irqsave(&device->cache.lock, flags); + + for (p = 0; p <= end_port(device) - start_port(device); ++p) { + cache = device->cache.gid_cache[p]; + for (i = 0; i < cache->table_len; ++i) { + if (!memcmp(gid, &cache->table[i], sizeof *gid)) { + *port_num = p; + if (index) + *index = i; + ret = 0; + goto found; + } + } + } +found: + read_unlock_irqrestore(&device->cache.lock, flags); + + return ret; +} +EXPORT_SYMBOL(ib_find_cached_gid); + +int ib_get_cached_pkey(struct ib_device *device, + u8 port_num, int index, u16 *pkey) { @@ -101,12 +136,12 @@ int ib_cached_pkey_get(struct ib_device *device, unsigned long flags; int ret = 0; - if (port < start_port(device) || port > end_port(device)) + if (port_num < start_port(device) || port_num > end_port(device)) return -EINVAL; read_lock_irqsave(&device->cache.lock, flags); - cache = device->cache.pkey_cache[port - start_port(device)]; + cache = device->cache.pkey_cache[port_num - start_port(device)]; if (index < 0 || index >= cache->table_len) ret = -EINVAL; @@ -117,10 +152,10 @@ int ib_cached_pkey_get(struct ib_device *device, return ret; } -EXPORT_SYMBOL(ib_cached_pkey_get); +EXPORT_SYMBOL(ib_get_cached_pkey); -int ib_cached_pkey_find(struct ib_device *device, - u8 port, +int ib_find_cached_pkey(struct ib_device *device, + u8 port_num, u16 pkey, u16 *index) { @@ -129,12 +164,12 @@ int ib_cached_pkey_find(struct ib_device *device, int i; int ret = -ENOENT; - if (port < start_port(device) || port > end_port(device)) + if (port_num < start_port(device) || port_num > end_port(device)) return -EINVAL; read_lock_irqsave(&device->cache.lock, flags); - cache = device->cache.pkey_cache[port - start_port(device)]; + cache = device->cache.pkey_cache[port_num - start_port(device)]; *index = -1; @@ -149,7 +184,7 @@ int ib_cached_pkey_find(struct ib_device *device, return ret; } -EXPORT_SYMBOL(ib_cached_pkey_find); +EXPORT_SYMBOL(ib_find_cached_pkey); static void ib_cache_update(struct ib_device *device, u8 port) diff --git a/drivers/infiniband/hw/mthca/mthca_av.c b/drivers/infiniband/hw/mthca/mthca_av.c index c4865130f7c18b..ee7f1dc3a39118 100644 --- a/drivers/infiniband/hw/mthca/mthca_av.c +++ b/drivers/infiniband/hw/mthca/mthca_av.c @@ -159,7 +159,7 @@ int mthca_read_ah(struct mthca_dev *dev, struct mthca_ah *ah, (be32_to_cpu(ah->av->sl_tclass_flowlabel) >> 20) & 0xff; header->grh.flow_label = ah->av->sl_tclass_flowlabel & cpu_to_be32(0xfffff); - ib_cached_gid_get(&dev->ib_dev, + ib_get_cached_gid(&dev->ib_dev, be32_to_cpu(ah->av->port_pd) >> 24, ah->av->gid_index, &header->grh.source_gid); diff --git a/drivers/infiniband/hw/mthca/mthca_qp.c b/drivers/infiniband/hw/mthca/mthca_qp.c index 40261e76b27064..8fc2b62dcb7838 100644 --- a/drivers/infiniband/hw/mthca/mthca_qp.c +++ b/drivers/infiniband/hw/mthca/mthca_qp.c @@ -1190,11 +1190,11 @@ static int build_mlx_header(struct mthca_dev *dev, struct mthca_sqp *sqp, sqp->ud_header.lrh.source_lid = 0xffff; sqp->ud_header.bth.solicited_event = !!(wr->send_flags & IB_SEND_SOLICITED); if (!sqp->qp.ibqp.qp_num) - ib_cached_pkey_get(&dev->ib_dev, sqp->port, + ib_get_cached_pkey(&dev->ib_dev, sqp->port, sqp->pkey_index, &sqp->ud_header.bth.pkey); else - ib_cached_pkey_get(&dev->ib_dev, sqp->port, + ib_get_cached_pkey(&dev->ib_dev, sqp->port, wr->wr.ud.pkey_index, &sqp->ud_header.bth.pkey); cpu_to_be16s(&sqp->ud_header.bth.pkey); diff --git a/drivers/infiniband/include/ib_cache.h b/drivers/infiniband/include/ib_cache.h index 211baa03bc8a40..44ef6bb9b9df49 100644 --- a/drivers/infiniband/include/ib_cache.h +++ b/drivers/infiniband/include/ib_cache.h @@ -37,16 +37,66 @@ #include <ib_verbs.h> -int ib_cached_gid_get(struct ib_device *device, - u8 port, +/** + * ib_get_cached_gid - Returns a cached GID table entry + * @device: The device to query. + * @port_num: The port number of the device to query. + * @index: The index into the cached GID table to query. + * @gid: The GID value found at the specified index. + * + * ib_get_cached_gid() fetches the specified GID table entry stored in + * the local software cache. + */ +int ib_get_cached_gid(struct ib_device *device, + u8 port_num, int index, union ib_gid *gid); -int ib_cached_pkey_get(struct ib_device *device_handle, - u8 port, + +/** + * ib_find_cached_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 cached GID table where the GID was found. This + * parameter may be NULL. + * + * ib_find_cached_gid() searches for the specified GID value in + * the local software cache. + */ +int ib_find_cached_gid(struct ib_device *device, + union ib_gid *gid, + u8 *port_num, + u16 *index); + +/** + * ib_get_cached_pkey - Returns a cached PKey table entry + * @device: The device to query. + * @port_num: The port number of the device to query. + * @index: The index into the cached PKey table to query. + * @pkey: The PKey value found at the specified index. + * + * ib_get_cached_pkey() fetches the specified PKey table entry stored in + * the local software cache. + */ +int ib_get_cached_pkey(struct ib_device *device_handle, + u8 port_num, int index, u16 *pkey); -int ib_cached_pkey_find(struct ib_device *device, - u8 port, + +/** + * ib_find_cached_pkey - Returns the PKey table index where a specified + * PKey value occurs. + * @device: The device to query. + * @port_num: The port number of the device to search for the PKey. + * @pkey: The PKey value to search for. + * @index: The index into the cached PKey table where the PKey was found. + * + * ib_find_cached_pkey() searches the specified PKey table in + * the local software cache. + */ +int ib_find_cached_pkey(struct ib_device *device, + u8 port_num, u16 pkey, u16 *index); diff --git a/drivers/infiniband/ulp/ipoib/ipoib_ib.c b/drivers/infiniband/ulp/ipoib/ipoib_ib.c index 77b511bc57b08b..4495563278053c 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_ib.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_ib.c @@ -630,7 +630,7 @@ static void ipoib_pkey_dev_check_presence(struct net_device *dev) struct ipoib_dev_priv *priv = netdev_priv(dev); u16 pkey_index = 0; - if (ib_cached_pkey_find(priv->ca, priv->port, priv->pkey, &pkey_index)) + if (ib_find_cached_pkey(priv->ca, priv->port, priv->pkey, &pkey_index)) clear_bit(IPOIB_PKEY_ASSIGNED, &priv->flags); else set_bit(IPOIB_PKEY_ASSIGNED, &priv->flags); diff --git a/drivers/infiniband/ulp/ipoib/ipoib_verbs.c b/drivers/infiniband/ulp/ipoib/ipoib_verbs.c index 262f2598cfef48..56c8bdcd836253 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_verbs.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_verbs.c @@ -49,7 +49,7 @@ int ipoib_mcast_attach(struct net_device *dev, u16 mlid, union ib_gid *mgid) if (!qp_attr) goto out; - if (ib_cached_pkey_find(priv->ca, priv->port, priv->pkey, &pkey_index)) { + if (ib_find_cached_pkey(priv->ca, priv->port, priv->pkey, &pkey_index)) { clear_bit(IPOIB_PKEY_ASSIGNED, &priv->flags); ret = -ENXIO; goto out; @@ -104,7 +104,7 @@ int ipoib_qp_create(struct net_device *dev) * The port has to be assigned to the respective IB partition in * advance. */ - ret = ib_cached_pkey_find(priv->ca, priv->port, priv->pkey, &pkey_index); + ret = ib_find_cached_pkey(priv->ca, priv->port, priv->pkey, &pkey_index); if (ret) { clear_bit(IPOIB_PKEY_ASSIGNED, &priv->flags); return ret; |