FD.io VPP  v17.01.1-3-gc6833f8
Vector Packet Processing
sfp.h
Go to the documentation of this file.
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 \
22  _ (unknown) \
23  _ (gbic) \
24  _ (on_motherboard) \
25  _ (sfp)
26 
27 typedef enum
28 {
29 #define _(f) SFP_ID_##f,
31 #undef _
32 } sfp_id_t;
33 
34 typedef struct
35 {
36  u8 id;
39  u8 compatibility[8];
43  u8 link_length[5];
45  u8 vendor_name[16];
47  u8 vendor_oui[3];
48  u8 vendor_part_number[16];
49  u8 vendor_revision[4];
50  /* 16 bit value network byte order. */
51  u8 laser_wavelength_in_nm[2];
54 
55  u8 options[2];
58  u8 vendor_serial_number[16];
59  u8 vendor_date_code[8];
60  u8 reserved92[3];
62  u8 vendor_specific[32];
63  u8 reserved128[384];
64 
65  /* Vendor specific data follows. */
66  u8 vendor_specific1[0];
67 } sfp_eeprom_t;
68 
71 {
72  int i;
73  u8 sum = 0;
74  for (i = 0; i < 63; i++)
75  sum += ((u8 *) e)[i];
76  return sum == e->checksum_0_to_62;
77 }
78 
79 /* _ (byte_index, bit_index, name) */
80 #define foreach_sfp_compatibility \
81  _ (0, 4, 10g_base_sr) \
82  _ (0, 5, 10g_base_lr) \
83  _ (1, 2, oc48_long_reach) \
84  _ (1, 1, oc48_intermediate_reach) \
85  _ (1, 0, oc48_short_reach) \
86  _ (2, 6, oc12_long_reach) \
87  _ (2, 5, oc12_intermediate_reach) \
88  _ (2, 4, oc12_short_reach) \
89  _ (2, 2, oc3_long_reach) \
90  _ (2, 1, oc3_intermediate_reach) \
91  _ (2, 0, oc3_short_reach) \
92  _ (3, 3, 1g_base_t) \
93  _ (3, 2, 1g_base_cx) \
94  _ (3, 1, 1g_base_lx) \
95  _ (3, 0, 1g_base_sx)
96 
97 typedef enum
98 {
99 #define _(a,b,f) SFP_COMPATIBILITY_##f,
101 #undef _
104 
106 
108 
109 #endif /* included_vnet_optics_sfp_h */
110 
111 /*
112  * fd.io coding-style-patch-verification: ON
113  *
114  * Local Variables:
115  * eval: (c-set-style "gnu")
116  * End:
117  */
u8 connector_type
Definition: sfp.h:38
sll srl srl sll sra u16x4 i
Definition: vector_sse2.h:343
u8 extended_id
Definition: sfp.h:37
u8 nominal_bit_rate_100mbits_per_sec
Definition: sfp.h:41
#define foreach_sfp_compatibility
Definition: sfp.h:80
static uword sfp_eeprom_is_valid(sfp_eeprom_t *e)
Definition: sfp.h:70
#define always_inline
Definition: clib.h:84
u8 min_bit_rate_margin_percent
Definition: sfp.h:57
u8 checksum_63_to_94
Definition: sfp.h:61
u8 id
Definition: sfp.h:36
u8 reserved36
Definition: sfp.h:46
format_function_t format_sfp_eeprom
Definition: sfp.h:107
u8 reserved62
Definition: sfp.h:52
u8 reserved13
Definition: sfp.h:42
svmdb_client_t * c
sfp_id_t
Definition: sfp.h:27
u8 encoding
Definition: sfp.h:40
unsigned int u32
Definition: types.h:88
u8 max_bit_rate_margin_percent
Definition: sfp.h:56
#define foreach_sfp_id
Definition: sfp.h:21
u8 *( format_function_t)(u8 *s, va_list *args)
Definition: format.h:48
sfp_compatibility_t
Definition: sfp.h:97
u64 uword
Definition: types.h:112
unsigned char u8
Definition: types.h:56
u8 reserved19
Definition: sfp.h:44
u8 checksum_0_to_62
Definition: sfp.h:53
u32 sfp_is_comatible(sfp_eeprom_t *e, sfp_compatibility_t c)
Definition: sfp.c:64