Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 or BSD-3-Clause */
0002 /*
0003  * Copyright(c) 2015, 2016 Intel Corporation.
0004  */
0005 
0006 #ifndef _LINUX_H
0007 #define _LINUX_H
0008 /*
0009  * This header file is for OPA-specific definitions which are
0010  * required by the HFI driver, and which aren't yet in the Linux
0011  * IB core. We'll collect these all here, then merge them into
0012  * the kernel when that's convenient.
0013  */
0014 
0015 /* OPA SMA attribute IDs */
0016 #define OPA_ATTRIB_ID_CONGESTION_INFO       cpu_to_be16(0x008b)
0017 #define OPA_ATTRIB_ID_HFI_CONGESTION_LOG    cpu_to_be16(0x008f)
0018 #define OPA_ATTRIB_ID_HFI_CONGESTION_SETTING    cpu_to_be16(0x0090)
0019 #define OPA_ATTRIB_ID_CONGESTION_CONTROL_TABLE  cpu_to_be16(0x0091)
0020 
0021 /* OPA PMA attribute IDs */
0022 #define OPA_PM_ATTRIB_ID_PORT_STATUS        cpu_to_be16(0x0040)
0023 #define OPA_PM_ATTRIB_ID_CLEAR_PORT_STATUS  cpu_to_be16(0x0041)
0024 #define OPA_PM_ATTRIB_ID_DATA_PORT_COUNTERS cpu_to_be16(0x0042)
0025 #define OPA_PM_ATTRIB_ID_ERROR_PORT_COUNTERS    cpu_to_be16(0x0043)
0026 #define OPA_PM_ATTRIB_ID_ERROR_INFO     cpu_to_be16(0x0044)
0027 
0028 /* OPA status codes */
0029 #define OPA_PM_STATUS_REQUEST_TOO_LARGE     cpu_to_be16(0x100)
0030 
0031 static inline u8 port_states_to_logical_state(struct opa_port_states *ps)
0032 {
0033     return ps->portphysstate_portstate & OPA_PI_MASK_PORT_STATE;
0034 }
0035 
0036 static inline u8 port_states_to_phys_state(struct opa_port_states *ps)
0037 {
0038     return ((ps->portphysstate_portstate &
0039           OPA_PI_MASK_PORT_PHYSICAL_STATE) >> 4) & 0xf;
0040 }
0041 
0042 /*
0043  * OPA port physical states
0044  * IB Volume 1, Table 146 PortInfo/IB Volume 2 Section 5.4.2(1) PortPhysState
0045  * values are the same in OmniPath Architecture. OPA leverages some of the same
0046  * concepts as InfiniBand, but has a few other states as well.
0047  *
0048  * When writing, only values 0-3 are valid, other values are ignored.
0049  * When reading, 0 is reserved.
0050  *
0051  * Returned by the ibphys_portstate() routine.
0052  */
0053 enum opa_port_phys_state {
0054     /* Values 0-7 have the same meaning in OPA as in InfiniBand. */
0055 
0056     IB_PORTPHYSSTATE_NOP = 0,
0057     /* 1 is reserved */
0058     IB_PORTPHYSSTATE_POLLING = 2,
0059     IB_PORTPHYSSTATE_DISABLED = 3,
0060     IB_PORTPHYSSTATE_TRAINING = 4,
0061     IB_PORTPHYSSTATE_LINKUP = 5,
0062     IB_PORTPHYSSTATE_LINK_ERROR_RECOVERY = 6,
0063     IB_PORTPHYSSTATE_PHY_TEST = 7,
0064     /* 8 is reserved */
0065 
0066     /*
0067      * Offline: Port is quiet (transmitters disabled) due to lack of
0068      * physical media, unsupported media, or transition between link up
0069      * and next link up attempt
0070      */
0071     OPA_PORTPHYSSTATE_OFFLINE = 9,
0072 
0073     /* 10 is reserved */
0074 
0075     /*
0076      * Phy_Test: Specific test patterns are transmitted, and receiver BER
0077      * can be monitored. This facilitates signal integrity testing for the
0078      * physical layer of the port.
0079      */
0080     OPA_PORTPHYSSTATE_TEST = 11,
0081 
0082     OPA_PORTPHYSSTATE_MAX = 11,
0083     /* values 12-15 are reserved/ignored */
0084 };
0085 
0086 #endif /* _LINUX_H */