5 * This file is provided under a dual BSD/GPLv2 license. When using or
6 * redistributing this file, you may do so under either license.
10 * Copyright(c) 2015 Intel Corporation.
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of version 2 of the GNU General Public License as
14 * published by the Free Software Foundation.
16 * This program is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * General Public License for more details.
23 * Copyright(c) 2015 Intel Corporation.
25 * Redistribution and use in source and binary forms, with or without
26 * modification, are permitted provided that the following conditions
29 * - Redistributions of source code must retain the above copyright
30 * notice, this list of conditions and the following disclaimer.
31 * - Redistributions in binary form must reproduce the above copyright
32 * notice, this list of conditions and the following disclaimer in
33 * the documentation and/or other materials provided with the
35 * - Neither the name of Intel Corporation nor the names of its
36 * contributors may be used to endorse or promote products derived
37 * from this software without specific prior written permission.
39 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
40 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
41 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
42 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
43 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
45 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
46 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
47 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
48 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
49 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
54 * This header file is for OPA-specific definitions which are
55 * required by the HFI driver, and which aren't yet in the Linux
56 * IB core. We'll collect these all here, then merge them into
57 * the kernel when that's convenient.
60 /* OPA SMA attribute IDs */
61 #define OPA_ATTRIB_ID_CONGESTION_INFO cpu_to_be16(0x008b)
62 #define OPA_ATTRIB_ID_HFI_CONGESTION_LOG cpu_to_be16(0x008f)
63 #define OPA_ATTRIB_ID_HFI_CONGESTION_SETTING cpu_to_be16(0x0090)
64 #define OPA_ATTRIB_ID_CONGESTION_CONTROL_TABLE cpu_to_be16(0x0091)
66 /* OPA PMA attribute IDs */
67 #define OPA_PM_ATTRIB_ID_PORT_STATUS cpu_to_be16(0x0040)
68 #define OPA_PM_ATTRIB_ID_CLEAR_PORT_STATUS cpu_to_be16(0x0041)
69 #define OPA_PM_ATTRIB_ID_DATA_PORT_COUNTERS cpu_to_be16(0x0042)
70 #define OPA_PM_ATTRIB_ID_ERROR_PORT_COUNTERS cpu_to_be16(0x0043)
71 #define OPA_PM_ATTRIB_ID_ERROR_INFO cpu_to_be16(0x0044)
73 /* OPA status codes */
74 #define OPA_PM_STATUS_REQUEST_TOO_LARGE cpu_to_be16(0x100)
76 static inline u8 port_states_to_logical_state(struct opa_port_states *ps)
78 return ps->portphysstate_portstate & OPA_PI_MASK_PORT_STATE;
81 static inline u8 port_states_to_phys_state(struct opa_port_states *ps)
83 return ((ps->portphysstate_portstate &
84 OPA_PI_MASK_PORT_PHYSICAL_STATE) >> 4) & 0xf;
88 * OPA port physical states
89 * IB Volume 1, Table 146 PortInfo/IB Volume 2 Section 5.4.2(1) PortPhysState
92 * When writing, only values 0-3 are valid, other values are ignored.
93 * When reading, 0 is reserved.
95 * Returned by the ibphys_portstate() routine.
97 enum opa_port_phys_state {
98 IB_PORTPHYSSTATE_NOP = 0,
100 IB_PORTPHYSSTATE_POLLING = 2,
101 IB_PORTPHYSSTATE_DISABLED = 3,
102 IB_PORTPHYSSTATE_TRAINING = 4,
103 IB_PORTPHYSSTATE_LINKUP = 5,
104 IB_PORTPHYSSTATE_LINK_ERROR_RECOVERY = 6,
105 IB_PORTPHYSSTATE_PHY_TEST = 7,
107 OPA_PORTPHYSSTATE_OFFLINE = 9,
108 OPA_PORTPHYSSTATE_GANGED = 10,
109 OPA_PORTPHYSSTATE_TEST = 11,
110 OPA_PORTPHYSSTATE_MAX = 11,
111 /* values 12-15 are reserved/ignored */
114 /* OPA_PORT_TYPE_* definitions - these belong in opa_port_info.h */
115 #define OPA_PORT_TYPE_UNKNOWN 0
116 #define OPA_PORT_TYPE_DISCONNECTED 1
117 /* port is not currently usable, CableInfo not available */
118 #define OPA_PORT_TYPE_FIXED 2
119 /* A fixed backplane port in a director class switch. All OPA ASICS */
120 #define OPA_PORT_TYPE_VARIABLE 3
121 /* A backplane port in a blade system, possibly mixed configuration */
122 #define OPA_PORT_TYPE_STANDARD 4
123 /* implies a SFF-8636 defined format for CableInfo (QSFP) */
124 #define OPA_PORT_TYPE_SI_PHOTONICS 5
125 /* A silicon photonics module implies TBD defined format for CableInfo
126 * as defined by Intel SFO group */
127 /* 6 - 15 are reserved */
129 #endif /* _LINUX_H */