[MLX4] added support to new device. [mlnx: 4473]
[mirror/winof/.git] / hw / mthca / hca_utils.c
1 /*
2  * Copyright (c) 2005 SilverStorm Technologies.  All rights reserved.
3  * Copyright (c) 2004-2005 Mellanox Technologies, Inc. All rights reserved. 
4  *
5  * This software is available to you under the OpenIB.org BSD license
6  * below:
7  *
8  *     Redistribution and use in source and binary forms, with or
9  *     without modification, are permitted provided that the following
10  *     conditions are met:
11  *
12  *      - Redistributions of source code must retain the above
13  *        copyright notice, this list of conditions and the following
14  *        disclaimer.
15  *
16  *      - Redistributions in binary form must reproduce the above
17  *        copyright notice, this list of conditions and the following
18  *        disclaimer in the documentation and/or other materials
19  *        provided with the distribution.
20  *
21  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
25  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
26  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
27  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28  * SOFTWARE.
29  *
30  * $Id$
31  */
32
33
34 #include "mthca_dev.h"
35
36
37 #if defined(EVENT_TRACING)
38 #ifdef offsetof
39 #undef offsetof
40 #endif
41 #include "hca_data.tmh"
42 #endif
43
44
45 mthca_qp_access_t
46 map_qp_ibal_acl(
47         IN                              ib_access_t                                     ibal_acl)
48 {
49 #define IBAL_ACL(ifl,mfl) if (ibal_acl & ifl)   mthca_acl |= mfl
50         mthca_qp_access_t               mthca_acl = 0;
51
52         IBAL_ACL(IB_AC_RDMA_READ,MTHCA_ACCESS_REMOTE_READ);
53         IBAL_ACL(IB_AC_RDMA_WRITE,MTHCA_ACCESS_REMOTE_WRITE);
54         IBAL_ACL(IB_AC_ATOMIC,MTHCA_ACCESS_REMOTE_ATOMIC);
55         IBAL_ACL(IB_AC_LOCAL_WRITE,MTHCA_ACCESS_LOCAL_WRITE);
56         IBAL_ACL(IB_AC_MW_BIND,MTHCA_ACCESS_MW_BIND);
57
58         return mthca_acl;
59 }
60
61 /////////////////////////////////////////////////////////
62 /////////////////////////////////////////////////////////
63 ib_access_t
64 map_qp_mthca_acl(
65         IN                              mthca_qp_access_t                               mthca_acl)
66 {
67 #define ACL_IBAL(mfl,ifl) if (mthca_acl & mfl)   ibal_acl |= ifl
68         ib_access_t ibal_acl = 0;
69
70         ACL_IBAL(MTHCA_ACCESS_REMOTE_READ,IB_AC_RDMA_READ);
71         ACL_IBAL(MTHCA_ACCESS_REMOTE_WRITE,IB_AC_RDMA_WRITE);
72         ACL_IBAL(MTHCA_ACCESS_REMOTE_ATOMIC,IB_AC_ATOMIC);
73         ACL_IBAL(MTHCA_ACCESS_LOCAL_WRITE,IB_AC_LOCAL_WRITE);
74         ACL_IBAL(MTHCA_ACCESS_MW_BIND,IB_AC_MW_BIND);
75
76         return ibal_acl;
77 }
78
79