aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2018-09-24 15:17:36 +0200
committerNeale Ranns <nranns@cisco.com>2018-09-25 12:16:57 +0000
commitc45e190f70e0317b62eeec23ad92a80b81e0b384 (patch)
tree9bfdc43d65562da147585a6efb7e042fefc75275 /src
parentfe4e48f617f3e0f62880adebdcfb5989aa4e6db7 (diff)
dpdk: show pluggable info in 'show hardware'
module: id SFP/SFP+/SFP28, compatibility: 40g_active_cable vendor: Amphenol, part NDCCGF-I202 revision: C, serial: APF1711202351C, date code: 170318 cable length: 2m Change-Id: Ife35607b4f078f7b56737fe066ad4cbd247a7504 Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/dpdk/device/format.c28
-rw-r--r--src/plugins/ixge/ixge.c4
-rw-r--r--src/vnet/ethernet/sfp.c9
-rw-r--r--src/vnet/ethernet/sfp.h58
4 files changed, 78 insertions, 21 deletions
diff --git a/src/plugins/dpdk/device/format.c b/src/plugins/dpdk/device/format.c
index eed7e2862d3..5cb03b85dab 100644
--- a/src/plugins/dpdk/device/format.c
+++ b/src/plugins/dpdk/device/format.c
@@ -22,6 +22,7 @@
#include <dlfcn.h>
#include <vnet/ethernet/ethernet.h>
+#include <vnet/ethernet/sfp.h>
#include <dpdk/device/dpdk.h>
#include <dpdk/device/dpdk_priv.h>
@@ -496,6 +497,30 @@ format_dpdk_device_errors (u8 * s, va_list * args)
return s;
}
+static u8 *
+format_dpdk_device_module_info (u8 * s, va_list * args)
+{
+ dpdk_device_t *xd = va_arg (*args, dpdk_device_t *);
+ struct rte_eth_dev_module_info mi = { 0 };
+ struct rte_dev_eeprom_info ei = { 0 };
+
+ if (rte_eth_dev_get_module_info (xd->port_id, &mi) != 0)
+ return format (s, "unknown");
+
+ ei.length = mi.eeprom_len;
+ ei.data = clib_mem_alloc (mi.eeprom_len);
+
+ if (rte_eth_dev_get_module_eeprom (xd->port_id, &ei) == 0)
+ {
+ s = format (s, "%U", format_sfp_eeprom, ei.data);
+ }
+ else
+ s = format (s, "eeprom read error");
+
+ clib_mem_free (ei.data);
+ return s;
+}
+
static const char *
ptr2sname (void *p)
{
@@ -567,6 +592,9 @@ format_dpdk_device (u8 * s, va_list * args)
vec_free (s2);
}
+ s = format (s, "%Umodule: %U\n", format_white_space, indent + 2,
+ format_dpdk_device_module_info, xd);
+
s = format (s, "%Umax rx packet len: %d\n", format_white_space,
indent + 2, di.max_rx_pktlen);
s = format (s, "%Upromiscuous: unicast %s all-multicast %s\n",
diff --git a/src/plugins/ixge/ixge.c b/src/plugins/ixge/ixge.c
index c13537da74e..aa14eac7fd7 100644
--- a/src/plugins/ixge/ixge.c
+++ b/src/plugins/ixge/ixge.c
@@ -359,7 +359,7 @@ ixge_sfp_phy_init (ixge_device_t * xd)
vlib_i2c_read_eeprom (ib, 0x50, 0, 128, (u8 *) & xd->sfp_eeprom);
if (vlib_i2c_bus_timed_out (ib) || !sfp_eeprom_is_valid (&xd->sfp_eeprom))
- xd->sfp_eeprom.id = SFP_ID_unknown;
+ xd->sfp_eeprom.id = SFP_ID_UNKNOWN;
else
{
/* FIXME 5 => SR/LR eeprom ID. */
@@ -2364,7 +2364,7 @@ format_ixge_device (u8 * s, va_list * args)
s = format (s, "\n%U", format_white_space, indent + 2);
if (phy->mdio_address != ~0)
s = format (s, "PHY address %d, id 0x%x", phy->mdio_address, phy->id);
- else if (xd->sfp_eeprom.id == SFP_ID_sfp)
+ else if (xd->sfp_eeprom.id == SFP_ID_SFP)
s = format (s, "SFP %U", format_sfp_eeprom, &xd->sfp_eeprom);
else
s = format (s, "PHY not found");
diff --git a/src/vnet/ethernet/sfp.c b/src/vnet/ethernet/sfp.c
index 0ebdb99339b..182fdbf1d55 100644
--- a/src/vnet/ethernet/sfp.c
+++ b/src/vnet/ethernet/sfp.c
@@ -35,7 +35,7 @@ format_sfp_id (u8 * s, va_list * args)
char *t = 0;
switch (id)
{
-#define _(f) case SFP_ID_##f: t = #f; break;
+#define _(f,str) case SFP_ID_##f: t = str; break;
foreach_sfp_id
#undef _
default:
@@ -84,8 +84,7 @@ format_sfp_eeprom (u8 * s, va_list * args)
u32 indent = format_get_indent (s);
int i;
- if (e->id != SFP_ID_sfp)
- s = format (s, "id %U, ", format_sfp_id, e->id);
+ s = format (s, "id %U, ", format_sfp_id, e->id);
s = format (s, "compatibility:");
for (i = 0; i < SFP_N_COMPATIBILITY; i++)
@@ -105,6 +104,10 @@ format_sfp_eeprom (u8 * s, va_list * args)
e->vendor_serial_number, format_space_terminated,
sizeof (e->vendor_date_code), e->vendor_date_code);
+ if (e->length[4])
+ s = format (s, "\n%Ucable length: %um", format_white_space, indent,
+ e->length[4]);
+
return s;
}
diff --git a/src/vnet/ethernet/sfp.h b/src/vnet/ethernet/sfp.h
index a1ac7997a44..f4c62aaa0ca 100644
--- a/src/vnet/ethernet/sfp.h
+++ b/src/vnet/ethernet/sfp.h
@@ -19,14 +19,34 @@
#include <vppinfra/format.h>
#define foreach_sfp_id \
- _ (unknown) \
- _ (gbic) \
- _ (on_motherboard) \
- _ (sfp)
+ _ (UNKNOWN, "unknown") \
+ _ (GBIC, "GBIC") \
+ _ (ON_MB, "on-motherboard") \
+ _ (SFP, "SFP/SFP+/SFP28") \
+ _ (300_PIN_XBI, "300-pin-XBI") \
+ _ (XENPAK, "XENPAK") \
+ _ (XFP, "XFP") \
+ _ (XFF, "XFF") \
+ _ (XFP_E, "XFP-E") \
+ _ (XPAK, "XPAK") \
+ _ (X2, "X2") \
+ _ (DWDM_SFP, "DWDM-SFP") \
+ _ (QSFP, "QSFP") \
+ _ (QSFP_PLUS, "QSFP+") \
+ _ (CXP, "CXP") \
+ _ (SMM_HD_4X, "SMM-HD-4X") \
+ _ (SMM_HD_8X, "SMM-HD-8X") \
+ _ (QSFP28, "QSFP28") \
+ _ (CXP2, "CXP2") \
+ _ (SMM_HD_4X_FAN, "SMM-HD-4X-fanout") \
+ _ (SMM_HD_8X_FAN, "SMM-HD-8X-fanout") \
+ _ (CDFP, "CDFP") \
+ _ (MQSFP, "microQSFP") \
+ _ (QSFP_DD, "QSFP-DD") \
typedef enum
{
-#define _(f) SFP_ID_##f,
+#define _(f,s) SFP_ID_##f,
foreach_sfp_id
#undef _
} sfp_id_t;
@@ -40,21 +60,21 @@ typedef struct
u8 encoding;
u8 nominal_bit_rate_100mbits_per_sec;
u8 reserved13;
- u8 link_length[5];
- u8 reserved19;
+ u8 length[5];
+ u8 device_tech;
u8 vendor_name[16];
- u8 reserved36;
+ u8 ext_module_codes;
u8 vendor_oui[3];
u8 vendor_part_number[16];
- u8 vendor_revision[4];
+ u8 vendor_revision[2];
/* 16 bit value network byte order. */
- u8 laser_wavelength_in_nm[2];
- u8 reserved62;
- u8 checksum_0_to_62;
+ u8 wavelength_or_att[2];
+ u8 wavelength_tolerance_or_att[2];
+ u8 max_case_temp;
+ u8 cc_base;
- u8 options[2];
- u8 max_bit_rate_margin_percent;
- u8 min_bit_rate_margin_percent;
+ u8 link_codes;
+ u8 options[3];
u8 vendor_serial_number[16];
u8 vendor_date_code[8];
u8 reserved92[3];
@@ -73,13 +93,19 @@ sfp_eeprom_is_valid (sfp_eeprom_t * e)
u8 sum = 0;
for (i = 0; i < 63; i++)
sum += ((u8 *) e)[i];
- return sum == e->checksum_0_to_62;
+ return sum == e->cc_base;
}
/* _ (byte_index, bit_index, name) */
#define foreach_sfp_compatibility \
+ _ (0, 0, 40g_active_cable) \
+ _ (0, 1, 40g_base_lr4) \
+ _ (0, 2, 40g_base_sr4) \
+ _ (0, 3, 40g_base_cr4) \
_ (0, 4, 10g_base_sr) \
_ (0, 5, 10g_base_lr) \
+ _ (0, 5, 10g_base_lrm) \
+ _ (1, 3, 40g_otn) \
_ (1, 2, oc48_long_reach) \
_ (1, 1, oc48_intermediate_reach) \
_ (1, 0, oc48_short_reach) \