aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/devices/nic/sfp.h
blob: a1ac7997a44f18ff5aae8df4245cba9d616a164f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/*
 * Copyright (c) 2016 Cisco and/or its affiliates.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at:
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef included_vnet_optics_sfp_h
#define included_vnet_optics_sfp_h

#include <vppinfra/format.h>

#define foreach_sfp_id				\
  _ (unknown)					\
  _ (gbic)					\
  _ (on_motherboard)				\
  _ (sfp)

typedef enum
{
#define _(f) SFP_ID_##f,
  foreach_sfp_id
#undef _
} sfp_id_t;

typedef struct
{
  u8 id;
  u8 extended_id;
  u8 connector_type;
  u8 compatibility[8];
  u8 encoding;
  u8 nominal_bit_rate_100mbits_per_sec;
  u8 reserved13;
  u8 link_length[5];
  u8 reserved19;
  u8 vendor_name[16];
  u8 reserved36;
  u8 vendor_oui[3];
  u8 vendor_part_number[16];
  u8 vendor_revision[4];
  /* 16 bit value network byte order. */
  u8 laser_wavelength_in_nm[2];
  u8 reserved62;
  u8 checksum_0_to_62;

  u8 options[2];
  u8 max_bit_rate_margin_percent;
  u8 min_bit_rate_margin_percent;
  u8 vendor_serial_number[16];
  u8 vendor_date_code[8];
  u8 reserved92[3];
  u8 checksum_63_to_94;
  u8 vendor_specific[32];
  u8 reserved128[384];

  /* Vendor specific data follows. */
  u8 vendor_specific1[0];
} sfp_eeprom_t;

always_inline uword
sfp_eeprom_is_valid (sfp_eeprom_t * e)
{
  int i;
  u8 sum = 0;
  for (i = 0; i < 63; i++)
    sum += ((u8 *) e)[i];
  return sum == e->checksum_0_to_62;
}

/* _ (byte_index, bit_index, name) */
#define foreach_sfp_compatibility		\
  _ (0, 4, 10g_base_sr)				\
  _ (0, 5, 10g_base_lr)				\
  _ (1, 2, oc48_long_reach)			\
  _ (1, 1, oc48_intermediate_reach)		\
  _ (1, 0, oc48_short_reach)			\
  _ (2, 6, oc12_long_reach)			\
  _ (2, 5, oc12_intermediate_reach)		\
  _ (2, 4, oc12_short_reach)			\
  _ (2, 2, oc3_long_reach)			\
  _ (2, 1, oc3_intermediate_reach)		\
  _ (2, 0, oc3_short_reach)			\
  _ (3, 3, 1g_base_t)				\
  _ (3, 2, 1g_base_cx)				\
  _ (3, 1, 1g_base_lx)				\
  _ (3, 0, 1g_base_sx)

typedef enum
{
#define _(a,b,f) SFP_COMPATIBILITY_##f,
  foreach_sfp_compatibility
#undef _
    SFP_N_COMPATIBILITY,
} sfp_compatibility_t;

u32 sfp_is_comatible (sfp_eeprom_t * e, sfp_compatibility_t c);

format_function_t format_sfp_eeprom;

#endif /* included_vnet_optics_sfp_h */

/*
 * fd.io coding-style-patch-verification: ON
 *
 * Local Variables:
 * eval: (c-set-style "gnu")
 * End:
 */
e - run release binary" @echo " debug - run debug binary with debugger" @echo " debug-release - run release binary with debugger" @echo " build-vat - build vpp-api-test tool" @echo " run-vat - run vpp-api-test tool" @echo " pkg-deb - build DEB packages" @echo " pkg-rpm - build RPM packages" @echo " ctags - (re)generate ctags database" @echo " cscope - (re)generate cscope database" @echo " doxygen - (re)generate documentation" @echo " wipe-doxygen - wipe all generated documentation" @echo "" @echo "Make Arguments:" @echo " V=[0|1] - set build verbosity level" @echo " STARTUP_CONF=<path> - startup configuration file" @echo " (e.g. /etc/vpp/startup.conf)" @echo " STARTUP_DIR=<path> - startup drectory (e.g. /etc/vpp)" @echo " It also sets STARTUP_CONF if" @echo " startup.conf file is present" @echo " GDB=<path> - gdb binary to use for debugging" @echo " PLATFORM=<name> - target platform. default is vpp" @echo "" @echo "Current Argumernt Values:" @echo " V = $(V)" @echo " STARTUP_CONF = $(STARTUP_CONF)" @echo " STARTUP_DIR = $(STARTUP_DIR)" @echo " GDB = $(GDB)" @echo " PLATFORM = $(PLATFORM)" @echo " DPDK_VERSION = $(DPDK_VERSION)" $(BR)/.bootstrap.ok: ifeq ($(OS_ID),ubuntu) @MISSING=$$(apt-get install -y -qq -s $(DEB_DEPENDS) | grep "^Inst ") ; \ if [ -n "$$MISSING" ] ; then \ echo "\nPlease install missing packages: \n$$MISSING\n" ; \ echo "by executing \"make install-dep\"\n" ; \ exit 1 ; \ fi ; \ exit 0 endif @echo "SOURCE_PATH = $(WS_ROOT)" > $(BR)/build-config.mk @echo "#!/bin/bash\n" > $(BR)/path_setup @echo 'export PATH=$(BR)/tools/ccache-bin:$$PATH' >> $(BR)/path_setup @echo 'export PATH=$(BR)/tools/bin:$$PATH' >> $(BR)/path_setup @echo 'export CCACHE_DIR=$(CCACHE_DIR)' >> $(BR)/path_setup ifeq ("$(wildcard /usr/bin/ccache )","") @echo "WARNING: Please install ccache AYEC and re-run this script" else @rm -rf $(BR)/tools/ccache-bin @mkdir -p $(BR)/tools/ccache-bin @ln -s /usr/bin/ccache $(BR)/tools/ccache-bin/gcc @ln -s /usr/bin/ccache $(BR)/tools/ccache-bin/g++ endif @make -C $(BR) V=$(V) is_build_tool=yes vppapigen-install @touch $@ bootstrap: $(BR)/.bootstrap.ok install-dep: ifeq ($(OS_ID),ubuntu) ifeq ($(OS_VERSION_ID),14.04) @sudo -E apt-get $(CONFIRM) install software-properties-common @sudo -E add-apt-repository $(CONFIRM) ppa:openjdk-r/ppa @sudo -E apt-get update endif @sudo -E apt-get $(CONFIRM) install $(DEB_DEPENDS) else ifneq ("$(wildcard /etc/redhat-release)","") @sudo yum groupinstall $(CONFIRM) $(RPM_DEPENDS_GROUPS) @sudo yum install $(CONFIRM) $(RPM_DEPENDS) @sudo yum install $(CONFIRM) --enablerepo=epel $(EPEL_DEPENDS) @sudo debuginfo-install $(CONFIRM) glibc-2.17-106.el7_2.4.x86_64 openssl-libs-1.0.1e-51.el7_2.4.x86_64 zlib-1.2.7-15.el7.x86_64 else $(error "This option currently works only on Ubuntu or Centos systems") endif define make @make -C $(BR) PLATFORM=$(PLATFORM) TAG=$(1) $(2) endef build: $(BR)/.bootstrap.ok $(call make,$(PLATFORM)_debug,vpp-install) wipe: $(BR)/.bootstrap.ok $(call make,$(PLATFORM)_debug,vpp-wipe) rebuild: wipe build build-release: $(BR)/.bootstrap.ok $(call make,$(PLATFORM),vpp-install) wipe-release: $(BR)/.bootstrap.ok $(call make,$(PLATFORM),vpp-wipe) rebuild-release: wipe-release build-release STARTUP_DIR ?= $(PWD) ifeq ("$(wildcard $(STARTUP_CONF))","") define run @echo "WARNING: STARTUP_CONF not defined or file doesn't exist." @echo " Running with minimal startup config: $(MINIMAL_STARTUP_CONF)\n" @cd $(STARTUP_DIR) && sudo $(1) $(MINIMAL_STARTUP_CONF) endef else define run @cd $(STARTUP_DIR) && sudo $(1) -c $(STARTUP_CONF) endef endif %.files: .FORCE @find . \( -name '*\.[chyS]' -o -name '*\.java' -o -name '*\.lex' \) -and \ \( -not -path './build-root*' -o -path \ './build-root/build-vpp_debug-native/dpdk*' \) > $@ .FORCE: run: $(call run, $(BR)/install-$(PLATFORM)_debug-native/vpp/bin/vpp) run-release: $(call run, $(BR)/install-$(PLATFORM)-native/vpp/bin/vpp) debug: $(call run, $(GDB) $(GDB_ARGS) --args $(BR)/install-$(PLATFORM)_debug-native/vpp/bin/vpp) debug-release: $(call run, $(GDB) $(GDB_ARGS) --args $(BR)/install-$(PLATFORM)-native/vpp/bin/vpp) build-vat: $(call make,$(PLATFORM)_debug,vpp-api-test-install) run-vat: @sudo $(BR)/install-$(PLATFORM)_debug-native/vpp-api-test/bin/vpp_api_test pkg-deb: $(call make,$(PLATFORM),install-deb) pkg-rpm: $(call make,$(PLATFORM),install-rpm) ctags: ctags.files @ctags --totals --tag-relative -L $< @rm $< cscope: cscope.files @cscope -b -q -v # # Build the documentation # DOXY_INPUT = \ README.md \ vppinfra \ svm \ vlib \ vlib-api \ vnet \ vpp \ vpp-api doxygen: @mkdir -p "$(BR)/docs" ROOT="$(WS_ROOT)" \ BUILD_ROOT="$(BR)" \ INPUT="$(addprefix $(WS_ROOT)/,$(DOXY_INPUT))" \ HTML=YES \ VERSION="`git describe --tags --dirty`" \ doxygen doxygen/doxygen.cfg wipe-doxygen: rm -rf "$(BR)/docs"