Damjan Marion | b4d8927 | 2016-05-12 22:14:45 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2016 Cisco and/or its affiliates. |
| 3 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | * you may not use this file except in compliance with the License. |
| 5 | * You may obtain a copy of the License at: |
| 6 | * |
| 7 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | * |
| 9 | * Unless required by applicable law or agreed to in writing, software |
| 10 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | * See the License for the specific language governing permissions and |
| 13 | * limitations under the License. |
| 14 | */ |
| 15 | |
| 16 | #ifndef included_vnet_optics_sfp_h |
| 17 | #define included_vnet_optics_sfp_h |
| 18 | |
| 19 | #include <vppinfra/format.h> |
| 20 | |
| 21 | #define foreach_sfp_id \ |
Damjan Marion | c45e190 | 2018-09-24 15:17:36 +0200 | [diff] [blame] | 22 | _ (UNKNOWN, "unknown") \ |
| 23 | _ (GBIC, "GBIC") \ |
| 24 | _ (ON_MB, "on-motherboard") \ |
| 25 | _ (SFP, "SFP/SFP+/SFP28") \ |
| 26 | _ (300_PIN_XBI, "300-pin-XBI") \ |
| 27 | _ (XENPAK, "XENPAK") \ |
| 28 | _ (XFP, "XFP") \ |
| 29 | _ (XFF, "XFF") \ |
| 30 | _ (XFP_E, "XFP-E") \ |
| 31 | _ (XPAK, "XPAK") \ |
| 32 | _ (X2, "X2") \ |
| 33 | _ (DWDM_SFP, "DWDM-SFP") \ |
| 34 | _ (QSFP, "QSFP") \ |
| 35 | _ (QSFP_PLUS, "QSFP+") \ |
| 36 | _ (CXP, "CXP") \ |
| 37 | _ (SMM_HD_4X, "SMM-HD-4X") \ |
| 38 | _ (SMM_HD_8X, "SMM-HD-8X") \ |
| 39 | _ (QSFP28, "QSFP28") \ |
| 40 | _ (CXP2, "CXP2") \ |
| 41 | _ (SMM_HD_4X_FAN, "SMM-HD-4X-fanout") \ |
| 42 | _ (SMM_HD_8X_FAN, "SMM-HD-8X-fanout") \ |
| 43 | _ (CDFP, "CDFP") \ |
| 44 | _ (MQSFP, "microQSFP") \ |
| 45 | _ (QSFP_DD, "QSFP-DD") \ |
Damjan Marion | b4d8927 | 2016-05-12 22:14:45 +0200 | [diff] [blame] | 46 | |
Damjan Marion | 00a9dca | 2016-08-17 17:05:46 +0200 | [diff] [blame] | 47 | typedef enum |
| 48 | { |
Damjan Marion | c45e190 | 2018-09-24 15:17:36 +0200 | [diff] [blame] | 49 | #define _(f,s) SFP_ID_##f, |
Damjan Marion | b4d8927 | 2016-05-12 22:14:45 +0200 | [diff] [blame] | 50 | foreach_sfp_id |
| 51 | #undef _ |
| 52 | } sfp_id_t; |
| 53 | |
Damjan Marion | 00a9dca | 2016-08-17 17:05:46 +0200 | [diff] [blame] | 54 | typedef struct |
| 55 | { |
Damjan Marion | b4d8927 | 2016-05-12 22:14:45 +0200 | [diff] [blame] | 56 | u8 id; |
| 57 | u8 extended_id; |
| 58 | u8 connector_type; |
| 59 | u8 compatibility[8]; |
| 60 | u8 encoding; |
| 61 | u8 nominal_bit_rate_100mbits_per_sec; |
| 62 | u8 reserved13; |
Damjan Marion | c45e190 | 2018-09-24 15:17:36 +0200 | [diff] [blame] | 63 | u8 length[5]; |
| 64 | u8 device_tech; |
Damjan Marion | b4d8927 | 2016-05-12 22:14:45 +0200 | [diff] [blame] | 65 | u8 vendor_name[16]; |
Damjan Marion | c45e190 | 2018-09-24 15:17:36 +0200 | [diff] [blame] | 66 | u8 ext_module_codes; |
Damjan Marion | b4d8927 | 2016-05-12 22:14:45 +0200 | [diff] [blame] | 67 | u8 vendor_oui[3]; |
| 68 | u8 vendor_part_number[16]; |
Damjan Marion | c45e190 | 2018-09-24 15:17:36 +0200 | [diff] [blame] | 69 | u8 vendor_revision[2]; |
Damjan Marion | b4d8927 | 2016-05-12 22:14:45 +0200 | [diff] [blame] | 70 | /* 16 bit value network byte order. */ |
Damjan Marion | c45e190 | 2018-09-24 15:17:36 +0200 | [diff] [blame] | 71 | u8 wavelength_or_att[2]; |
| 72 | u8 wavelength_tolerance_or_att[2]; |
| 73 | u8 max_case_temp; |
| 74 | u8 cc_base; |
Damjan Marion | b4d8927 | 2016-05-12 22:14:45 +0200 | [diff] [blame] | 75 | |
Damjan Marion | c45e190 | 2018-09-24 15:17:36 +0200 | [diff] [blame] | 76 | u8 link_codes; |
| 77 | u8 options[3]; |
Damjan Marion | b4d8927 | 2016-05-12 22:14:45 +0200 | [diff] [blame] | 78 | u8 vendor_serial_number[16]; |
| 79 | u8 vendor_date_code[8]; |
| 80 | u8 reserved92[3]; |
| 81 | u8 checksum_63_to_94; |
| 82 | u8 vendor_specific[32]; |
| 83 | u8 reserved128[384]; |
| 84 | |
| 85 | /* Vendor specific data follows. */ |
| 86 | u8 vendor_specific1[0]; |
| 87 | } sfp_eeprom_t; |
| 88 | |
| 89 | always_inline uword |
| 90 | sfp_eeprom_is_valid (sfp_eeprom_t * e) |
| 91 | { |
| 92 | int i; |
| 93 | u8 sum = 0; |
| 94 | for (i = 0; i < 63; i++) |
| 95 | sum += ((u8 *) e)[i]; |
Damjan Marion | c45e190 | 2018-09-24 15:17:36 +0200 | [diff] [blame] | 96 | return sum == e->cc_base; |
Damjan Marion | b4d8927 | 2016-05-12 22:14:45 +0200 | [diff] [blame] | 97 | } |
| 98 | |
| 99 | /* _ (byte_index, bit_index, name) */ |
| 100 | #define foreach_sfp_compatibility \ |
Damjan Marion | c45e190 | 2018-09-24 15:17:36 +0200 | [diff] [blame] | 101 | _ (0, 0, 40g_active_cable) \ |
| 102 | _ (0, 1, 40g_base_lr4) \ |
| 103 | _ (0, 2, 40g_base_sr4) \ |
| 104 | _ (0, 3, 40g_base_cr4) \ |
Damjan Marion | b4d8927 | 2016-05-12 22:14:45 +0200 | [diff] [blame] | 105 | _ (0, 4, 10g_base_sr) \ |
| 106 | _ (0, 5, 10g_base_lr) \ |
Damjan Marion | c45e190 | 2018-09-24 15:17:36 +0200 | [diff] [blame] | 107 | _ (0, 5, 10g_base_lrm) \ |
| 108 | _ (1, 3, 40g_otn) \ |
Damjan Marion | b4d8927 | 2016-05-12 22:14:45 +0200 | [diff] [blame] | 109 | _ (1, 2, oc48_long_reach) \ |
| 110 | _ (1, 1, oc48_intermediate_reach) \ |
| 111 | _ (1, 0, oc48_short_reach) \ |
| 112 | _ (2, 6, oc12_long_reach) \ |
| 113 | _ (2, 5, oc12_intermediate_reach) \ |
| 114 | _ (2, 4, oc12_short_reach) \ |
| 115 | _ (2, 2, oc3_long_reach) \ |
| 116 | _ (2, 1, oc3_intermediate_reach) \ |
| 117 | _ (2, 0, oc3_short_reach) \ |
| 118 | _ (3, 3, 1g_base_t) \ |
| 119 | _ (3, 2, 1g_base_cx) \ |
| 120 | _ (3, 1, 1g_base_lx) \ |
| 121 | _ (3, 0, 1g_base_sx) |
| 122 | |
Damjan Marion | 00a9dca | 2016-08-17 17:05:46 +0200 | [diff] [blame] | 123 | typedef enum |
| 124 | { |
Damjan Marion | b4d8927 | 2016-05-12 22:14:45 +0200 | [diff] [blame] | 125 | #define _(a,b,f) SFP_COMPATIBILITY_##f, |
| 126 | foreach_sfp_compatibility |
| 127 | #undef _ |
Damjan Marion | 00a9dca | 2016-08-17 17:05:46 +0200 | [diff] [blame] | 128 | SFP_N_COMPATIBILITY, |
Damjan Marion | b4d8927 | 2016-05-12 22:14:45 +0200 | [diff] [blame] | 129 | } sfp_compatibility_t; |
| 130 | |
| 131 | u32 sfp_is_comatible (sfp_eeprom_t * e, sfp_compatibility_t c); |
| 132 | |
| 133 | format_function_t format_sfp_eeprom; |
| 134 | |
| 135 | #endif /* included_vnet_optics_sfp_h */ |
Damjan Marion | 00a9dca | 2016-08-17 17:05:46 +0200 | [diff] [blame] | 136 | |
| 137 | /* |
| 138 | * fd.io coding-style-patch-verification: ON |
| 139 | * |
| 140 | * Local Variables: |
| 141 | * eval: (c-set-style "gnu") |
| 142 | * End: |
| 143 | */ |