1219820Sjeff/*
2219820Sjeff * Copyright (c) 2004 Topspin Communications.  All rights reserved.
3219820Sjeff * Copyright (c) 2005 Voltaire, Inc.  All rights reserved.
4219820Sjeff * Copyright (c) 2006 Intel Corporation.  All rights reserved.
5219820Sjeff *
6219820Sjeff * This software is available to you under a choice of one of two
7219820Sjeff * licenses.  You may choose to be licensed under the terms of the GNU
8219820Sjeff * General Public License (GPL) Version 2, available from the file
9219820Sjeff * COPYING in the main directory of this source tree, or the
10219820Sjeff * OpenIB.org BSD license below:
11219820Sjeff *
12219820Sjeff *     Redistribution and use in source and binary forms, with or
13219820Sjeff *     without modification, are permitted provided that the following
14219820Sjeff *     conditions are met:
15219820Sjeff *
16219820Sjeff *      - Redistributions of source code must retain the above
17219820Sjeff *        copyright notice, this list of conditions and the following
18219820Sjeff *        disclaimer.
19219820Sjeff *
20219820Sjeff *      - Redistributions in binary form must reproduce the above
21219820Sjeff *        copyright notice, this list of conditions and the following
22219820Sjeff *        disclaimer in the documentation and/or other materials
23219820Sjeff *        provided with the distribution.
24219820Sjeff *
25219820Sjeff * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26219820Sjeff * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27219820Sjeff * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28219820Sjeff * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
29219820Sjeff * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
30219820Sjeff * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31219820Sjeff * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32219820Sjeff * SOFTWARE.
33219820Sjeff */
34219820Sjeff
35219820Sjeff#ifndef SA_H
36219820Sjeff#define SA_H
37219820Sjeff
38219820Sjeff#include <rdma/ib_sa.h>
39219820Sjeff
40219820Sjeffstatic inline void ib_sa_client_get(struct ib_sa_client *client)
41219820Sjeff{
42219820Sjeff	atomic_inc(&client->users);
43219820Sjeff}
44219820Sjeff
45219820Sjeffstatic inline void ib_sa_client_put(struct ib_sa_client *client)
46219820Sjeff{
47219820Sjeff	if (atomic_dec_and_test(&client->users))
48219820Sjeff		complete(&client->comp);
49219820Sjeff}
50219820Sjeff
51219820Sjeffint ib_sa_check_selector(ib_sa_comp_mask comp_mask,
52219820Sjeff			 ib_sa_comp_mask selector_mask,
53219820Sjeff			 ib_sa_comp_mask value_mask,
54219820Sjeff			 u8 selector, u8 src_value, u8 dst_value);
55219820Sjeff
56219820Sjeffint ib_sa_pack_attr(void *dst, void *src, int attr_id);
57219820Sjeff
58219820Sjeffint ib_sa_unpack_attr(void *dst, void *src, int attr_id);
59219820Sjeff
60219820Sjeffint ib_sa_path_rec_query(struct ib_sa_client *client,
61219820Sjeff			 struct ib_device *device, u8 port_num,
62219820Sjeff			 struct ib_sa_path_rec *rec,
63219820Sjeff			 ib_sa_comp_mask comp_mask,
64219820Sjeff			 int timeout_ms, gfp_t gfp_mask,
65219820Sjeff			 void (*callback)(int status,
66219820Sjeff					  struct ib_sa_path_rec *resp,
67219820Sjeff					  void *context),
68219820Sjeff			 void *context,
69219820Sjeff			 struct ib_sa_query **sa_query);
70219820Sjeff
71219820Sjeffint sa_db_init(void);
72219820Sjeffvoid sa_db_cleanup(void);
73219820Sjeff
74219820Sjeffint ib_sa_mcmember_rec_query(struct ib_sa_client *client,
75219820Sjeff			     struct ib_device *device, u8 port_num,
76219820Sjeff			     u8 method,
77219820Sjeff			     struct ib_sa_mcmember_rec *rec,
78219820Sjeff			     ib_sa_comp_mask comp_mask,
79219820Sjeff			     int timeout_ms, gfp_t gfp_mask,
80219820Sjeff			     void (*callback)(int status,
81219820Sjeff					      struct ib_sa_mcmember_rec *resp,
82219820Sjeff					      void *context),
83219820Sjeff			     void *context,
84219820Sjeff			     struct ib_sa_query **sa_query);
85219820Sjeff
86219820Sjeffint mcast_init(void);
87219820Sjeffvoid mcast_cleanup(void);
88219820Sjeff
89219820Sjeffint ib_sa_informinfo_query(struct ib_sa_client *client,
90219820Sjeff			   struct ib_device *device, u8 port_num,
91219820Sjeff			   struct ib_sa_inform *rec,
92219820Sjeff			   int timeout_ms, gfp_t gfp_mask,
93219820Sjeff			   void (*callback)(int status,
94219820Sjeff					    struct ib_sa_inform *resp,
95219820Sjeff					    void *context),
96219820Sjeff			   void *context,
97219820Sjeff			   struct ib_sa_query **sa_query);
98219820Sjeff
99219820Sjeffint notice_dispatch(struct ib_device *device, u8 port_num,
100219820Sjeff		    struct ib_sa_notice *notice);
101219820Sjeff
102219820Sjeffint notice_init(void);
103219820Sjeffvoid notice_cleanup(void);
104219820Sjeff
105219820Sjeff#endif /* SA_H */
106