aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/core/cache.c
diff options
context:
space:
mode:
authorDaniel Jurgens <danielj@mellanox.com>2017-05-19 08:48:51 -0400
committerPaul Moore <paul@paul-moore.com>2017-05-23 10:24:17 -0400
commit883c71feaf2e810e0331cf780c738cbb09e93b58 (patch)
tree35c4bf3f56bce25fd38c2ccab50eaa08ff9607ad /drivers/infiniband/core/cache.c
parent270e8573145a26de924e2dc644596332d400445b (diff)
IB/core: IB cache enhancements to support Infiniband security
Cache the subnet prefix and add a function to access it. Enforcing security requires frequent queries of the subnet prefix and the pkeys in the pkey table. Signed-off-by: Daniel Jurgens <danielj@mellanox.com> Reviewed-by: Eli Cohen <eli@mellanox.com> Reviewed-by: Leon Romanovsky <leonro@mellanox.com> Reviewed-by: James Morris <james.l.morris@oracle.com> Acked-by: Doug Ledford <dledford@redhat.com> Signed-off-by: Paul Moore <paul@paul-moore.com>
Diffstat (limited to 'drivers/infiniband/core/cache.c')
-rw-r--r--drivers/infiniband/core/cache.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/drivers/infiniband/core/cache.c b/drivers/infiniband/core/cache.c
index b1371eb9f46c..b9c0066b704e 100644
--- a/drivers/infiniband/core/cache.c
+++ b/drivers/infiniband/core/cache.c
@@ -911,6 +911,26 @@ int ib_get_cached_pkey(struct ib_device *device,
911} 911}
912EXPORT_SYMBOL(ib_get_cached_pkey); 912EXPORT_SYMBOL(ib_get_cached_pkey);
913 913
914int ib_get_cached_subnet_prefix(struct ib_device *device,
915 u8 port_num,
916 u64 *sn_pfx)
917{
918 unsigned long flags;
919 int p;
920
921 if (port_num < rdma_start_port(device) ||
922 port_num > rdma_end_port(device))
923 return -EINVAL;
924
925 p = port_num - rdma_start_port(device);
926 read_lock_irqsave(&device->cache.lock, flags);
927 *sn_pfx = device->cache.ports[p].subnet_prefix;
928 read_unlock_irqrestore(&device->cache.lock, flags);
929
930 return 0;
931}
932EXPORT_SYMBOL(ib_get_cached_subnet_prefix);
933
914int ib_find_cached_pkey(struct ib_device *device, 934int ib_find_cached_pkey(struct ib_device *device,
915 u8 port_num, 935 u8 port_num,
916 u16 pkey, 936 u16 pkey,
@@ -1108,6 +1128,8 @@ static void ib_cache_update(struct ib_device *device,
1108 device->cache.ports[port - rdma_start_port(device)].port_state = 1128 device->cache.ports[port - rdma_start_port(device)].port_state =
1109 tprops->state; 1129 tprops->state;
1110 1130
1131 device->cache.ports[port - rdma_start_port(device)].subnet_prefix =
1132 tprops->subnet_prefix;
1111 write_unlock_irq(&device->cache.lock); 1133 write_unlock_irq(&device->cache.lock);
1112 1134
1113 kfree(gid_cache); 1135 kfree(gid_cache);