^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Copyright (c) 2004 Topspin Communications. All rights reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Copyright (c) 2005 Intel Corporation. All rights reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #ifndef _IB_CACHE_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #define _IB_CACHE_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <rdma/ib_verbs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) int rdma_query_gid(struct ib_device *device, u8 port_num, int index,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) union ib_gid *gid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) void *rdma_read_gid_hw_context(const struct ib_gid_attr *attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) const struct ib_gid_attr *rdma_find_gid(struct ib_device *device,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) const union ib_gid *gid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) enum ib_gid_type gid_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) struct net_device *ndev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) const struct ib_gid_attr *rdma_find_gid_by_port(struct ib_device *ib_dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) const union ib_gid *gid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) enum ib_gid_type gid_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) u8 port,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) struct net_device *ndev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) const struct ib_gid_attr *rdma_find_gid_by_filter(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) struct ib_device *device, const union ib_gid *gid, u8 port_num,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) bool (*filter)(const union ib_gid *gid, const struct ib_gid_attr *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) void *),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) void *context);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) int rdma_read_gid_l2_fields(const struct ib_gid_attr *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) u16 *vlan_id, u8 *smac);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) struct net_device *rdma_read_gid_attr_ndev_rcu(const struct ib_gid_attr *attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) * ib_get_cached_pkey - Returns a cached PKey table entry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) * @device: The device to query.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) * @port_num: The port number of the device to query.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) * @index: The index into the cached PKey table to query.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) * @pkey: The PKey value found at the specified index.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) * ib_get_cached_pkey() fetches the specified PKey table entry stored in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) * the local software cache.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) int ib_get_cached_pkey(struct ib_device *device_handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) u8 port_num,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) int index,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) u16 *pkey);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) * ib_find_cached_pkey - Returns the PKey table index where a specified
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) * PKey value occurs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) * @device: The device to query.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) * @port_num: The port number of the device to search for the PKey.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) * @pkey: The PKey value to search for.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) * @index: The index into the cached PKey table where the PKey was found.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) * ib_find_cached_pkey() searches the specified PKey table in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) * the local software cache.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) int ib_find_cached_pkey(struct ib_device *device,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) u8 port_num,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) u16 pkey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) u16 *index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) * ib_find_exact_cached_pkey - Returns the PKey table index where a specified
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) * PKey value occurs. Comparison uses the FULL 16 bits (incl membership bit)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) * @device: The device to query.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) * @port_num: The port number of the device to search for the PKey.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) * @pkey: The PKey value to search for.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) * @index: The index into the cached PKey table where the PKey was found.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) * ib_find_exact_cached_pkey() searches the specified PKey table in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) * the local software cache.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) int ib_find_exact_cached_pkey(struct ib_device *device,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) u8 port_num,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) u16 pkey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) u16 *index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) * ib_get_cached_lmc - Returns a cached lmc table entry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) * @device: The device to query.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) * @port_num: The port number of the device to query.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) * @lmc: The lmc value for the specified port for that device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) * ib_get_cached_lmc() fetches the specified lmc table entry stored in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) * the local software cache.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) int ib_get_cached_lmc(struct ib_device *device,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) u8 port_num,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) u8 *lmc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) * ib_get_cached_port_state - Returns a cached port state table entry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) * @device: The device to query.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) * @port_num: The port number of the device to query.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) * @port_state: port_state for the specified port for that device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) * ib_get_cached_port_state() fetches the specified port_state table entry stored in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) * the local software cache.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) int ib_get_cached_port_state(struct ib_device *device,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) u8 port_num,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) enum ib_port_state *port_active);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) bool rdma_is_zero_gid(const union ib_gid *gid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) const struct ib_gid_attr *rdma_get_gid_attr(struct ib_device *device,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) u8 port_num, int index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) void rdma_put_gid_attr(const struct ib_gid_attr *attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) void rdma_hold_gid_attr(const struct ib_gid_attr *attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) ssize_t rdma_query_gid_table(struct ib_device *device,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) struct ib_uverbs_gid_entry *entries,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) size_t max_entries);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) #endif /* _IB_CACHE_H */