opa_compat.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /* SPDX-License-Identifier: GPL-2.0 or BSD-3-Clause */
  2. /*
  3. * Copyright(c) 2015, 2016 Intel Corporation.
  4. */
  5. #ifndef _LINUX_H
  6. #define _LINUX_H
  7. /*
  8. * This header file is for OPA-specific definitions which are
  9. * required by the HFI driver, and which aren't yet in the Linux
  10. * IB core. We'll collect these all here, then merge them into
  11. * the kernel when that's convenient.
  12. */
  13. /* OPA SMA attribute IDs */
  14. #define OPA_ATTRIB_ID_CONGESTION_INFO cpu_to_be16(0x008b)
  15. #define OPA_ATTRIB_ID_HFI_CONGESTION_LOG cpu_to_be16(0x008f)
  16. #define OPA_ATTRIB_ID_HFI_CONGESTION_SETTING cpu_to_be16(0x0090)
  17. #define OPA_ATTRIB_ID_CONGESTION_CONTROL_TABLE cpu_to_be16(0x0091)
  18. /* OPA PMA attribute IDs */
  19. #define OPA_PM_ATTRIB_ID_PORT_STATUS cpu_to_be16(0x0040)
  20. #define OPA_PM_ATTRIB_ID_CLEAR_PORT_STATUS cpu_to_be16(0x0041)
  21. #define OPA_PM_ATTRIB_ID_DATA_PORT_COUNTERS cpu_to_be16(0x0042)
  22. #define OPA_PM_ATTRIB_ID_ERROR_PORT_COUNTERS cpu_to_be16(0x0043)
  23. #define OPA_PM_ATTRIB_ID_ERROR_INFO cpu_to_be16(0x0044)
  24. /* OPA status codes */
  25. #define OPA_PM_STATUS_REQUEST_TOO_LARGE cpu_to_be16(0x100)
  26. static inline u8 port_states_to_logical_state(struct opa_port_states *ps)
  27. {
  28. return ps->portphysstate_portstate & OPA_PI_MASK_PORT_STATE;
  29. }
  30. static inline u8 port_states_to_phys_state(struct opa_port_states *ps)
  31. {
  32. return ((ps->portphysstate_portstate &
  33. OPA_PI_MASK_PORT_PHYSICAL_STATE) >> 4) & 0xf;
  34. }
  35. /*
  36. * OPA port physical states
  37. * IB Volume 1, Table 146 PortInfo/IB Volume 2 Section 5.4.2(1) PortPhysState
  38. * values are the same in OmniPath Architecture. OPA leverages some of the same
  39. * concepts as InfiniBand, but has a few other states as well.
  40. *
  41. * When writing, only values 0-3 are valid, other values are ignored.
  42. * When reading, 0 is reserved.
  43. *
  44. * Returned by the ibphys_portstate() routine.
  45. */
  46. enum opa_port_phys_state {
  47. /* Values 0-7 have the same meaning in OPA as in InfiniBand. */
  48. IB_PORTPHYSSTATE_NOP = 0,
  49. /* 1 is reserved */
  50. IB_PORTPHYSSTATE_POLLING = 2,
  51. IB_PORTPHYSSTATE_DISABLED = 3,
  52. IB_PORTPHYSSTATE_TRAINING = 4,
  53. IB_PORTPHYSSTATE_LINKUP = 5,
  54. IB_PORTPHYSSTATE_LINK_ERROR_RECOVERY = 6,
  55. IB_PORTPHYSSTATE_PHY_TEST = 7,
  56. /* 8 is reserved */
  57. /*
  58. * Offline: Port is quiet (transmitters disabled) due to lack of
  59. * physical media, unsupported media, or transition between link up
  60. * and next link up attempt
  61. */
  62. OPA_PORTPHYSSTATE_OFFLINE = 9,
  63. /* 10 is reserved */
  64. /*
  65. * Phy_Test: Specific test patterns are transmitted, and receiver BER
  66. * can be monitored. This facilitates signal integrity testing for the
  67. * physical layer of the port.
  68. */
  69. OPA_PORTPHYSSTATE_TEST = 11,
  70. OPA_PORTPHYSSTATE_MAX = 11,
  71. /* values 12-15 are reserved/ignored */
  72. };
  73. #endif /* _LINUX_H */