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