162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 or BSD-3-Clause */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Copyright(c) 2015, 2016 Intel Corporation. 462306a36Sopenharmony_ci */ 562306a36Sopenharmony_ci 662306a36Sopenharmony_ci#ifndef _LINUX_H 762306a36Sopenharmony_ci#define _LINUX_H 862306a36Sopenharmony_ci/* 962306a36Sopenharmony_ci * This header file is for OPA-specific definitions which are 1062306a36Sopenharmony_ci * required by the HFI driver, and which aren't yet in the Linux 1162306a36Sopenharmony_ci * IB core. We'll collect these all here, then merge them into 1262306a36Sopenharmony_ci * the kernel when that's convenient. 1362306a36Sopenharmony_ci */ 1462306a36Sopenharmony_ci 1562306a36Sopenharmony_ci/* OPA SMA attribute IDs */ 1662306a36Sopenharmony_ci#define OPA_ATTRIB_ID_CONGESTION_INFO cpu_to_be16(0x008b) 1762306a36Sopenharmony_ci#define OPA_ATTRIB_ID_HFI_CONGESTION_LOG cpu_to_be16(0x008f) 1862306a36Sopenharmony_ci#define OPA_ATTRIB_ID_HFI_CONGESTION_SETTING cpu_to_be16(0x0090) 1962306a36Sopenharmony_ci#define OPA_ATTRIB_ID_CONGESTION_CONTROL_TABLE cpu_to_be16(0x0091) 2062306a36Sopenharmony_ci 2162306a36Sopenharmony_ci/* OPA PMA attribute IDs */ 2262306a36Sopenharmony_ci#define OPA_PM_ATTRIB_ID_PORT_STATUS cpu_to_be16(0x0040) 2362306a36Sopenharmony_ci#define OPA_PM_ATTRIB_ID_CLEAR_PORT_STATUS cpu_to_be16(0x0041) 2462306a36Sopenharmony_ci#define OPA_PM_ATTRIB_ID_DATA_PORT_COUNTERS cpu_to_be16(0x0042) 2562306a36Sopenharmony_ci#define OPA_PM_ATTRIB_ID_ERROR_PORT_COUNTERS cpu_to_be16(0x0043) 2662306a36Sopenharmony_ci#define OPA_PM_ATTRIB_ID_ERROR_INFO cpu_to_be16(0x0044) 2762306a36Sopenharmony_ci 2862306a36Sopenharmony_ci/* OPA status codes */ 2962306a36Sopenharmony_ci#define OPA_PM_STATUS_REQUEST_TOO_LARGE cpu_to_be16(0x100) 3062306a36Sopenharmony_ci 3162306a36Sopenharmony_cistatic inline u8 port_states_to_logical_state(struct opa_port_states *ps) 3262306a36Sopenharmony_ci{ 3362306a36Sopenharmony_ci return ps->portphysstate_portstate & OPA_PI_MASK_PORT_STATE; 3462306a36Sopenharmony_ci} 3562306a36Sopenharmony_ci 3662306a36Sopenharmony_cistatic inline u8 port_states_to_phys_state(struct opa_port_states *ps) 3762306a36Sopenharmony_ci{ 3862306a36Sopenharmony_ci return ((ps->portphysstate_portstate & 3962306a36Sopenharmony_ci OPA_PI_MASK_PORT_PHYSICAL_STATE) >> 4) & 0xf; 4062306a36Sopenharmony_ci} 4162306a36Sopenharmony_ci 4262306a36Sopenharmony_ci/* 4362306a36Sopenharmony_ci * OPA port physical states 4462306a36Sopenharmony_ci * IB Volume 1, Table 146 PortInfo/IB Volume 2 Section 5.4.2(1) PortPhysState 4562306a36Sopenharmony_ci * values are the same in OmniPath Architecture. OPA leverages some of the same 4662306a36Sopenharmony_ci * concepts as InfiniBand, but has a few other states as well. 4762306a36Sopenharmony_ci * 4862306a36Sopenharmony_ci * When writing, only values 0-3 are valid, other values are ignored. 4962306a36Sopenharmony_ci * When reading, 0 is reserved. 5062306a36Sopenharmony_ci * 5162306a36Sopenharmony_ci * Returned by the ibphys_portstate() routine. 5262306a36Sopenharmony_ci */ 5362306a36Sopenharmony_cienum opa_port_phys_state { 5462306a36Sopenharmony_ci /* Values 0-7 have the same meaning in OPA as in InfiniBand. */ 5562306a36Sopenharmony_ci 5662306a36Sopenharmony_ci IB_PORTPHYSSTATE_NOP = 0, 5762306a36Sopenharmony_ci /* 1 is reserved */ 5862306a36Sopenharmony_ci IB_PORTPHYSSTATE_POLLING = 2, 5962306a36Sopenharmony_ci IB_PORTPHYSSTATE_DISABLED = 3, 6062306a36Sopenharmony_ci IB_PORTPHYSSTATE_TRAINING = 4, 6162306a36Sopenharmony_ci IB_PORTPHYSSTATE_LINKUP = 5, 6262306a36Sopenharmony_ci IB_PORTPHYSSTATE_LINK_ERROR_RECOVERY = 6, 6362306a36Sopenharmony_ci IB_PORTPHYSSTATE_PHY_TEST = 7, 6462306a36Sopenharmony_ci /* 8 is reserved */ 6562306a36Sopenharmony_ci 6662306a36Sopenharmony_ci /* 6762306a36Sopenharmony_ci * Offline: Port is quiet (transmitters disabled) due to lack of 6862306a36Sopenharmony_ci * physical media, unsupported media, or transition between link up 6962306a36Sopenharmony_ci * and next link up attempt 7062306a36Sopenharmony_ci */ 7162306a36Sopenharmony_ci OPA_PORTPHYSSTATE_OFFLINE = 9, 7262306a36Sopenharmony_ci 7362306a36Sopenharmony_ci /* 10 is reserved */ 7462306a36Sopenharmony_ci 7562306a36Sopenharmony_ci /* 7662306a36Sopenharmony_ci * Phy_Test: Specific test patterns are transmitted, and receiver BER 7762306a36Sopenharmony_ci * can be monitored. This facilitates signal integrity testing for the 7862306a36Sopenharmony_ci * physical layer of the port. 7962306a36Sopenharmony_ci */ 8062306a36Sopenharmony_ci OPA_PORTPHYSSTATE_TEST = 11, 8162306a36Sopenharmony_ci 8262306a36Sopenharmony_ci OPA_PORTPHYSSTATE_MAX = 11, 8362306a36Sopenharmony_ci /* values 12-15 are reserved/ignored */ 8462306a36Sopenharmony_ci}; 8562306a36Sopenharmony_ci 8662306a36Sopenharmony_ci#endif /* _LINUX_H */ 87