1fe267a55SPedro F. Giffuni /*- 2fe267a55SPedro F. Giffuni * SPDX-License-Identifier: BSD-2-Clause OR GPL-2.0 3fe267a55SPedro F. Giffuni * 4aa0a1e58SJeff Roberson * Copyright (c) 2004 Topspin Communications. All rights reserved. 5aa0a1e58SJeff Roberson * Copyright (c) 2005 Intel Corporation. All rights reserved. 6aa0a1e58SJeff Roberson * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. 7aa0a1e58SJeff Roberson * 8aa0a1e58SJeff Roberson * This software is available to you under a choice of one of two 9aa0a1e58SJeff Roberson * licenses. You may choose to be licensed under the terms of the GNU 10aa0a1e58SJeff Roberson * General Public License (GPL) Version 2, available from the file 11aa0a1e58SJeff Roberson * COPYING in the main directory of this source tree, or the 12aa0a1e58SJeff Roberson * OpenIB.org BSD license below: 13aa0a1e58SJeff Roberson * 14aa0a1e58SJeff Roberson * Redistribution and use in source and binary forms, with or 15aa0a1e58SJeff Roberson * without modification, are permitted provided that the following 16aa0a1e58SJeff Roberson * conditions are met: 17aa0a1e58SJeff Roberson * 18aa0a1e58SJeff Roberson * - Redistributions of source code must retain the above 19aa0a1e58SJeff Roberson * copyright notice, this list of conditions and the following 20aa0a1e58SJeff Roberson * disclaimer. 21aa0a1e58SJeff Roberson * 22aa0a1e58SJeff Roberson * - Redistributions in binary form must reproduce the above 23aa0a1e58SJeff Roberson * copyright notice, this list of conditions and the following 24aa0a1e58SJeff Roberson * disclaimer in the documentation and/or other materials 25aa0a1e58SJeff Roberson * provided with the distribution. 26aa0a1e58SJeff Roberson * 27aa0a1e58SJeff Roberson * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 28aa0a1e58SJeff Roberson * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 29aa0a1e58SJeff Roberson * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 30aa0a1e58SJeff Roberson * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 31aa0a1e58SJeff Roberson * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 32aa0a1e58SJeff Roberson * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 33aa0a1e58SJeff Roberson * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 34aa0a1e58SJeff Roberson * SOFTWARE. 35aa0a1e58SJeff Roberson */ 36aa0a1e58SJeff Roberson 37aa0a1e58SJeff Roberson #ifndef _IB_CACHE_H 38aa0a1e58SJeff Roberson #define _IB_CACHE_H 39aa0a1e58SJeff Roberson 40aa0a1e58SJeff Roberson #include <rdma/ib_verbs.h> 41aa0a1e58SJeff Roberson 42aa0a1e58SJeff Roberson /** 43aa0a1e58SJeff Roberson * ib_get_cached_gid - Returns a cached GID table entry 44aa0a1e58SJeff Roberson * @device: The device to query. 45aa0a1e58SJeff Roberson * @port_num: The port number of the device to query. 46aa0a1e58SJeff Roberson * @index: The index into the cached GID table to query. 47aa0a1e58SJeff Roberson * @gid: The GID value found at the specified index. 48478d3005SHans Petter Selasky * @attr: The GID attribute found at the specified index (only in RoCE). 49478d3005SHans Petter Selasky * NULL means ignore (output parameter). 50aa0a1e58SJeff Roberson * 51aa0a1e58SJeff Roberson * ib_get_cached_gid() fetches the specified GID table entry stored in 52aa0a1e58SJeff Roberson * the local software cache. 53aa0a1e58SJeff Roberson */ 54aa0a1e58SJeff Roberson int ib_get_cached_gid(struct ib_device *device, 55aa0a1e58SJeff Roberson u8 port_num, 56aa0a1e58SJeff Roberson int index, 57478d3005SHans Petter Selasky union ib_gid *gid, 58478d3005SHans Petter Selasky struct ib_gid_attr *attr); 59aa0a1e58SJeff Roberson 60aa0a1e58SJeff Roberson /** 61aa0a1e58SJeff Roberson * ib_find_cached_gid - Returns the port number and GID table index where 62aa0a1e58SJeff Roberson * a specified GID value occurs. 63aa0a1e58SJeff Roberson * @device: The device to query. 64aa0a1e58SJeff Roberson * @gid: The GID value to search for. 65478d3005SHans Petter Selasky * @gid_type: The GID type to search for. 66478d3005SHans Petter Selasky * @ndev: In RoCE, the net device of the device. NULL means ignore. 67aa0a1e58SJeff Roberson * @port_num: The port number of the device where the GID value was found. 68aa0a1e58SJeff Roberson * @index: The index into the cached GID table where the GID was found. This 69aa0a1e58SJeff Roberson * parameter may be NULL. 70aa0a1e58SJeff Roberson * 71aa0a1e58SJeff Roberson * ib_find_cached_gid() searches for the specified GID value in 72aa0a1e58SJeff Roberson * the local software cache. 73aa0a1e58SJeff Roberson */ 74aa0a1e58SJeff Roberson int ib_find_cached_gid(struct ib_device *device, 75478d3005SHans Petter Selasky const union ib_gid *gid, 76478d3005SHans Petter Selasky enum ib_gid_type gid_type, 77*3e142e07SJustin Hibbits if_t ndev, 78aa0a1e58SJeff Roberson u8 *port_num, 79aa0a1e58SJeff Roberson u16 *index); 80aa0a1e58SJeff Roberson 81aa0a1e58SJeff Roberson /** 82478d3005SHans Petter Selasky * ib_find_cached_gid_by_port - Returns the GID table index where a specified 83478d3005SHans Petter Selasky * GID value occurs 84478d3005SHans Petter Selasky * @device: The device to query. 85478d3005SHans Petter Selasky * @gid: The GID value to search for. 86478d3005SHans Petter Selasky * @gid_type: The GID type to search for. 87478d3005SHans Petter Selasky * @port_num: The port number of the device where the GID value sould be 88478d3005SHans Petter Selasky * searched. 89478d3005SHans Petter Selasky * @ndev: In RoCE, the net device of the device. Null means ignore. 90478d3005SHans Petter Selasky * @index: The index into the cached GID table where the GID was found. This 91478d3005SHans Petter Selasky * parameter may be NULL. 92478d3005SHans Petter Selasky * 93478d3005SHans Petter Selasky * ib_find_cached_gid() searches for the specified GID value in 94478d3005SHans Petter Selasky * the local software cache. 95478d3005SHans Petter Selasky */ 96478d3005SHans Petter Selasky int ib_find_cached_gid_by_port(struct ib_device *device, 97478d3005SHans Petter Selasky const union ib_gid *gid, 98478d3005SHans Petter Selasky enum ib_gid_type gid_type, 99478d3005SHans Petter Selasky u8 port_num, 100*3e142e07SJustin Hibbits if_t ndev, 101478d3005SHans Petter Selasky u16 *index); 102478d3005SHans Petter Selasky 103478d3005SHans Petter Selasky int ib_find_gid_by_filter(struct ib_device *device, 104478d3005SHans Petter Selasky const union ib_gid *gid, 105478d3005SHans Petter Selasky u8 port_num, 106478d3005SHans Petter Selasky bool (*filter)(const union ib_gid *gid, 107478d3005SHans Petter Selasky const struct ib_gid_attr *, 108478d3005SHans Petter Selasky void *), 109478d3005SHans Petter Selasky void *context, u16 *index); 110478d3005SHans Petter Selasky /** 111aa0a1e58SJeff Roberson * ib_get_cached_pkey - Returns a cached PKey table entry 112aa0a1e58SJeff Roberson * @device: The device to query. 113aa0a1e58SJeff Roberson * @port_num: The port number of the device to query. 114aa0a1e58SJeff Roberson * @index: The index into the cached PKey table to query. 115aa0a1e58SJeff Roberson * @pkey: The PKey value found at the specified index. 116aa0a1e58SJeff Roberson * 117aa0a1e58SJeff Roberson * ib_get_cached_pkey() fetches the specified PKey table entry stored in 118aa0a1e58SJeff Roberson * the local software cache. 119aa0a1e58SJeff Roberson */ 120aa0a1e58SJeff Roberson int ib_get_cached_pkey(struct ib_device *device_handle, 121aa0a1e58SJeff Roberson u8 port_num, 122aa0a1e58SJeff Roberson int index, 123aa0a1e58SJeff Roberson u16 *pkey); 124aa0a1e58SJeff Roberson 125aa0a1e58SJeff Roberson /** 126aa0a1e58SJeff Roberson * ib_find_cached_pkey - Returns the PKey table index where a specified 127aa0a1e58SJeff Roberson * PKey value occurs. 128aa0a1e58SJeff Roberson * @device: The device to query. 129aa0a1e58SJeff Roberson * @port_num: The port number of the device to search for the PKey. 130aa0a1e58SJeff Roberson * @pkey: The PKey value to search for. 131aa0a1e58SJeff Roberson * @index: The index into the cached PKey table where the PKey was found. 132aa0a1e58SJeff Roberson * 133aa0a1e58SJeff Roberson * ib_find_cached_pkey() searches the specified PKey table in 134aa0a1e58SJeff Roberson * the local software cache. 135aa0a1e58SJeff Roberson */ 136aa0a1e58SJeff Roberson int ib_find_cached_pkey(struct ib_device *device, 137aa0a1e58SJeff Roberson u8 port_num, 138aa0a1e58SJeff Roberson u16 pkey, 139aa0a1e58SJeff Roberson u16 *index); 140aa0a1e58SJeff Roberson 141aa0a1e58SJeff Roberson /** 142b5c1e0cbSHans Petter Selasky * ib_find_exact_cached_pkey - Returns the PKey table index where a specified 143b5c1e0cbSHans Petter Selasky * PKey value occurs. Comparison uses the FULL 16 bits (incl membership bit) 144b5c1e0cbSHans Petter Selasky * @device: The device to query. 145b5c1e0cbSHans Petter Selasky * @port_num: The port number of the device to search for the PKey. 146b5c1e0cbSHans Petter Selasky * @pkey: The PKey value to search for. 147b5c1e0cbSHans Petter Selasky * @index: The index into the cached PKey table where the PKey was found. 148b5c1e0cbSHans Petter Selasky * 149b5c1e0cbSHans Petter Selasky * ib_find_exact_cached_pkey() searches the specified PKey table in 150b5c1e0cbSHans Petter Selasky * the local software cache. 151b5c1e0cbSHans Petter Selasky */ 152b5c1e0cbSHans Petter Selasky int ib_find_exact_cached_pkey(struct ib_device *device, 153b5c1e0cbSHans Petter Selasky u8 port_num, 154b5c1e0cbSHans Petter Selasky u16 pkey, 155b5c1e0cbSHans Petter Selasky u16 *index); 156b5c1e0cbSHans Petter Selasky 157b5c1e0cbSHans Petter Selasky /** 158aa0a1e58SJeff Roberson * ib_get_cached_lmc - Returns a cached lmc table entry 159aa0a1e58SJeff Roberson * @device: The device to query. 160aa0a1e58SJeff Roberson * @port_num: The port number of the device to query. 161aa0a1e58SJeff Roberson * @lmc: The lmc value for the specified port for that device. 162aa0a1e58SJeff Roberson * 163aa0a1e58SJeff Roberson * ib_get_cached_lmc() fetches the specified lmc table entry stored in 164aa0a1e58SJeff Roberson * the local software cache. 165aa0a1e58SJeff Roberson */ 166aa0a1e58SJeff Roberson int ib_get_cached_lmc(struct ib_device *device, 167aa0a1e58SJeff Roberson u8 port_num, 168aa0a1e58SJeff Roberson u8 *lmc); 169aa0a1e58SJeff Roberson 170aa0a1e58SJeff Roberson #endif /* _IB_CACHE_H */ 171