Commit 9aee73bf authored by Adam Wujek's avatar Adam Wujek 💬

Merge branch 'adam-snmp2'

Please not that some commits had non backward compatible changes in MIB.
However, end result of MIB is backward compatible.
parents f0bdc562 a08d32c7
......@@ -70,44 +70,6 @@ config REMOTE_SYSLOG_UDP
help
Select UDP to send system logs. If not set, TCP is used.
config SNMP_TRAPSINK_ADDRESS
string "Static IP address or name where to send SNMPv1 traps"
help
If not empty, the address or name is ussed as "trapsink"
destination in the SNMP configuration file for the switch.
It empty, no v1 traps are generated. If both this and
the following TRAP2SINK_ADDRESS are set, snmpd sends two
traps (one per protocol version). Trapcommunity is "public"
(not configurable so far).
config SNMP_TRAP2SINK_ADDRESS
string "Static IP address or name where to send SNMPv2c traps"
help
If not empty, the address or name is ussed as "trap2sink"
destination in the SNMP configuration file for the switch.
It empty, no v2c traps are generated. Trapcommunity is "public"
(not configurable so far).
config SNMP_RO_COMMUNITY
string "Read-only community name for SNMP V1/V2 management"
default "public"
help
If not empty, the 'community' name is a sort of password,
that travels as clear text (we don't support encrypted SNMPv3
yet). The default is good for testing, but should be changed
for production. Please note, however, that the switch processes
SNMP only on the CPU Ethernet port (the copper "management" port).
config SNMP_RW_COMMUNITY
string "Read-write community name for SNMP V1/V2 management"
default "private"
help
If not empty, the 'community' name is a sort of password,
that travels as clear text (we don't support encrypted SNMPv3
yet). The default is good for testing, but should be changed
for production. Please note, however, that the switch processes
SNMP only on the CPU Ethernet port (the copper "management" port).
config WRS_LOG_HAL
string "Logging directions for the WR hal"
default "daemon.info"
......@@ -231,7 +193,7 @@ menu "SFP and Media Timing Configuration"
config SFP00_PARAMS
string "Parameters for one SFP device type"
default "name=AXGE-1254-0531,tx=10,rx=10,wl_txrx=1310+1490"
default "vn=Axcen Photonics,pn=AXGE-1254-0531,tx=10,rx=10,wl_txrx=1310+1490"
help
This parameter, and the following ones, are used to
configure the timing parameters of a specific SFP
......@@ -242,7 +204,7 @@ config SFP00_PARAMS
config SFP01_PARAMS
string "Parameters for one SFP device type"
default "name=AXGE-3454-0531,tx=10,rx=10,wl_txrx=1490+1310"
default "vn=Axcen Photonics,pn=AXGE-3454-0531,tx=10,rx=10,wl_txrx=1490+1310"
config SFP02_PARAMS
string "Parameters for one SFP device type"
......@@ -361,8 +323,76 @@ config PTP_CUSTOM
endchoice
menu "Management configuration"
config SNMP_TRAPSINK_ADDRESS
string "Static IP address or name where to send SNMPv1 traps"
help
If not empty, the address or name is ussed as "trapsink"
destination in the SNMP configuration file for the switch.
It empty, no v1 traps are generated. If both this and
the following TRAP2SINK_ADDRESS are set, snmpd sends two
traps (one per protocol version). Trapcommunity is "public"
(not configurable so far).
config SNMP_TRAP2SINK_ADDRESS
string "Static IP address or name where to send SNMPv2c traps"
help
If not empty, the address or name is ussed as "trap2sink"
destination in the SNMP configuration file for the switch.
It empty, no v2c traps are generated. Trapcommunity is "public"
(not configurable so far).
config SNMP_RO_COMMUNITY
string "Read-only community name for SNMP V1/V2 management"
default "public"
help
If not empty, the 'community' name is a sort of password,
that travels as clear text (we don't support encrypted SNMPv3
yet). The default is good for testing, but should be changed
for production. Please note, however, that the switch processes
SNMP only on the CPU Ethernet port (the copper "management" port).
config SNMP_RW_COMMUNITY
string "Read-write community name for SNMP V1/V2 management"
default "private"
help
If not empty, the 'community' name is a sort of password,
that travels as clear text (we don't support encrypted SNMPv3
yet). The default is good for testing, but should be changed
for production. Please note, however, that the switch processes
SNMP only on the CPU Ethernet port (the copper "management" port).
config SNMP_TEMP_THOLD_FPGA
int "Threshold level for FPGA temperature"
default "0"
help
Threshold level for FPGA temperature, when exceeded warning is
notified by WR-SWITCH-MIB::tempWarning
config SNMP_TEMP_THOLD_PLL
int "Threshold level for PLL temperature"
default "0"
help
Threshold level for PLL temperature, when exceeded warning is
notified by WR-SWITCH-MIB::tempWarning
config SNMP_TEMP_THOLD_PSL
int "Threshold level for Power Supply Left (PSL) temperature"
default "0"
help
Threshold level for Power Supply Left (PSL) temperature, when
exceeded warning is notified by WR-SWITCH-MIB::tempWarning
config SNMP_TEMP_THOLD_PSR
int "Threshold level for Power Supply Right (PSR) temperature"
default "0"
help
Threshold level for Power Supply Right (PSR) temperature, when
exceeded warning is notified by WR-SWITCH-MIB::tempWarning
endmenu
config PTP_CUSTOM_FILENAME
string "Pathname for your custom ppsi.conf"
depends on PTP_CUSTOM
default "/wr/etc/ppsi-custom.conf"
......@@ -564,12 +564,6 @@ but sooner or later I'll fix it. As a side effect, I now use
the two contexts concurrently in an ambiguous way. No, I'm not
proud of this code.
I don't feel confident with all the data structures as yet, and there
still is some magic in all of this. This is confirmed by a buglet in
the current code, that makes @i{snmpwalk} always return one item after
the end of the table -- most likely I need to fix @t{next_entry()}
to return @t{NULL} earlier.
@c =========================================================================
@node wrsPpsi
@section wrsPpsi
......
......@@ -1490,10 +1490,8 @@ RPC servers are created in the following places:
@table @code
@item userspace/wrsw_rtud/rtud_exports.c
@c FIXME: rtud should use shmem for status
The socket is called @t{rtud} and is used by the @i{rtu_stat}
program to gather runtime information, and by @i{wrs_vlans}
The socket is called @t{rtud} and is used by @i{wrs_vlans}
to request actual actions.
@item userspace/ppsi/arch-wrs/wrs-startup.c
......@@ -1507,9 +1505,8 @@ RPC servers are created in the following places:
This channel is called @t{wrsw_hal} but the code uses is through
the macro @t{WRSW_HAL_SERVER_ADDR}. The RPC server is used
both for status and commands, but status is already exported
in shared memory, and we are converting the clients; status
RPC calls will be removed soon.
only for commands. All clients use shared memory to get status
information.
@item wrpc-sw::ipc/rt_ipc.c
......@@ -1522,28 +1519,17 @@ Clients are created in the following places:
@table @code
@item userspace/tools/rtu_stat.c
@c FIXME: rtu_stat should use shmem
The tool connects to @i{rtud} to get runtime information.
@item userspace/tools/wrs_vlans.c
@t{wrs_vlans} connects to the @i{rtud} to request configuration
actions related to vlan setup.
@item userspace/wrsw_hal/hal_exports.c
@c FIXME: don't check with a socket, but with the shmem mechanism
A temporary client is created to check whether a HAL process
is already running.
actions related to vlan setup. All status information is passed
through shared memory.
@item userspace/tools/wr_mon.c
@c FIXME: wr_mon should use shmem
The tty-based monitoring interface connects to @i{ptpd} (@i{ppsi})
to get run-time information. It is going to be moved to
shared memory.
to enable or disable tracking. All status information is passed
from @i{HAL} and @i{ppsi} through shared memory.
@item userspace/libwr/hal_client.c
......@@ -1600,13 +1586,6 @@ the processes (excluding the @sc{rt} subsystem).
Called by library code (@t{halexp_lock_cmd}) but not used.
Called by @i{ppsi} directly in @t{wrs-time.c}.
@item rtud::get_fd_list
@itemx rtud::get_vd_list
@c FIXME: shmem these
Called by @i{rtu_stat} to report information. They can be
moved to shared memory.
@item rtud::clear_entries
@itemx rtud::add_entry
......
......@@ -217,13 +217,6 @@ interface with gateware is now simpler than it was, but software still
has remnants of old data structure. Also, the multi-threaded approach
is overkill, and the program could benefit from a simplification.
@item The SFP code needs to be cleaned up. There is unsafe string
management in 16-wide non-terminated fields, and we don't really
report all the information we have (we should copy all SFP
information to shmem: we are almost there but not completely).
Moreover, using the device name without the vendor
name is unsafe: some vendors use generic device names.
@item The @t{TRACE} support it not really working. We have serious
warning messages that were never reported. We should really print
everything to stderr and let syslog manage it (according to user
......
......@@ -464,6 +464,15 @@ value is changed by the web interface, proper action is taken.
default. Community values are strings and they default to
@t{public} and @t{private}.
@item CONFIG_SNMP_TEMP_THOLD_FPGA
@itemx CONFIG_SNMP_TEMP_THOLD_PLL
@itemx CONFIG_SNMP_TEMP_THOLD_PSL
@itemx CONFIG_SNMP_TEMP_THOLD_PSR
Threshold levels for FPGA, PLL, Power Supply Left (PSL) and Power
Supply Right (PSR) temperature sensors. When any temperature exceeds
threshold level SNMP object @t{WR-SWITCH-MIB::tempWarning} will change
accordingly.
@item CONFIG_WRS_LOG_HAL
@itemx CONFIG_WRS_LOG_RTU
@itemx CONFIG_WRS_LOG_PTP
......@@ -553,7 +562,7 @@ This is, for explanation's sake, an example of such items:
@smallexample
CONFIG_PORT09_PARAMS="name=wr9,tx=226214,rx=226758,role=slave,fiber=2"
CONFIG_SFP00_PARAMS="name=AXGE-1254-0531,tx=0,rx=0,wl_txrx=1310+1490"
CONFIG_SFP00_PARAMS="pn=AXGE-1254-0531,tx=0,rx=0,wl_txrx=1310+1490"
CONFIG_FIBER02_PARAMS="alpha_1310_1490=2.6787e-04"
@end smallexample
......@@ -589,6 +598,35 @@ wavelength, and is determined, again, by calibration.
Please note that only one alpha value is provided, because the
opposite one (@t{alpha_1490_1310}) is calculated by software.
@subheading SFP name matching
SFP matching is based on vendor name (@i{vn}), part number (@i{pn}) and vendor
serial (@i{vs}). While matching SFP's values are compared with values stored in
@t{CONFIG_SFPXX_PARAMS}.
First try is to match all SFP identifiers (@i{vn}, @i{pn} and @i{vs}) with
stored in config. If match is not successful, @i{vn} and @i{pn} of SFP are
compared only with config entries without vendor serial. If match is still not
found SFP's values are compared with config entries, which has defined only
part number. Such approach prevents matching SFPs to config entires with
defined serial.
Below are shown matching examples:
@smallexample
CONFIG_SFP00_PARAMS="vn=Axcen Photonics,pn=AXGE-3454-0531,vs=AX12390009629,tx=0,rx=0,..."
@end smallexample
Above config may be matched only to one SFP.
@smallexample
CONFIG_SFP01_PARAMS="vn=Axcen Photonics,pn=AXGE-3454-0531,tx=0,rx=0,wl_txrx=1310+1490"
@end smallexample
Above config may be matched only to SFP with vendor name "Axcen Photonics" and
part number "AXGE-3454-0531", with exception to these SFPs that were matched to
example like above (with vendor serial defined).
@smallexample
CONFIG_SFP02_PARAMS="pn=AXGE-3454-0531,tx=0,rx=0,wl_txrx=1310+1490"
@end smallexample
Config above will be matched to all SFPs with part number "AXGE-3454-0531",
that were not matched by configs above.
@subheading Other Deployments
The example above matches the choices we make at CERN, where our
......@@ -1232,10 +1270,6 @@ This a summary of the available tables and scalars:
@end table
@b{Note:} due to a buglet of mine, there is an extra item at
the end of each table (@t{96.100.2} and @t{96.100.3.2}. It makes no
harm, so its removal is not high priority.
@c @b{Note:} due to a bug in management of 64-bit values in @i{net-snmp},
@c we are using a bad work-around in the code, that may cause wrong values
@c to be returned by other versions of the agent, where this bug is fixed.
......@@ -1296,6 +1330,14 @@ WR-SWITCH-MIB::wrsDateTAI.0 = Counter64: 1406623390
WR-SWITCH-MIB::wrsDateString.0 = STRING: 2014-07-29-08:43:10
@end smallexample
Another example is to print all objects exported by switch.
@smallexample
snmpwalk -c public -v 2c wrs -m all \
-M ${WRS_OUTPUT_DIR}/build/buildroot-2011.11/output/build/netsnmp-5.6.1.1/mibs/\
:${WR_SWITCH_SW}/userspace/snmpd/ \
1
@end smallexample
@c ==========================================================================
@node show-pstats
@section show-pstats
......
......@@ -86,46 +86,12 @@ typedef struct {
*/
/* Prototypes of functions that call on rpc */
extern int halexp_check_running(void);
extern int halexp_reset_port(const char *port_name);
extern int halexp_calibration_cmd(const char *port_name, int command, int on_off);
extern int halexp_lock_cmd(const char *port_name, int command, int priority);
extern int halexp_pps_cmd(int cmd, hexp_pps_params_t *params);
/* Export structures, shared by server and client for argument matching */
#ifdef HAL_EXPORT_STRUCTURES
//int halexp_check_running();
struct minipc_pd __rpcdef_check_running = {
.name = "check_running",
.retval = MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int),
.args = {
MINIPC_ARG_END,
},
};
//int halexp_reset_port(const char *port_name);
struct minipc_pd __rpcdef_reset_port = {
.name = "reset_port",
.retval = MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int),
.args = {
MINIPC_ARG_ENCODE(MINIPC_ATYPE_STRING, char *),
MINIPC_ARG_END,
},
};
//int halexp_calibration_cmd(const char *port_name, int command, int on_off);
struct minipc_pd __rpcdef_calibration_cmd = {
.name = "calibration_cmd",
.retval = MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int),
.args = {
MINIPC_ARG_ENCODE(MINIPC_ATYPE_STRING, char *),
MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int),
MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int),
MINIPC_ARG_END,
},
};
//int halexp_lock_cmd(const char *port_name, int command, int priority);
struct minipc_pd __rpcdef_lock_cmd = {
.name = "lock_cmd",
......
......@@ -4,43 +4,14 @@
#include <stdio.h>
#include <stdlib.h>
typedef struct{
int valid;
char slave_servo_state[32];
char sync_source[32];
int tracking_enabled;
int64_t mu;
int64_t delay_ms;
int64_t delta_tx_m;
int64_t delta_rx_m;
int64_t delta_tx_s;
int64_t delta_rx_s;
int64_t fiber_asymmetry;
int64_t total_asymmetry;
int64_t cur_offset;
int64_t cur_setpoint;
int64_t cur_skew;
int64_t update_count;
} ptpdexp_sync_state_t ;
#define PTPDEXP_COMMAND_TRACKING 1
#define PTPDEXP_COMMAND_MAN_ADJUST_PHASE 2
extern int ptpdexp_get_sync_state(ptpdexp_sync_state_t *state);
extern int ptpdexp_cmd(int cmd, int value);
/* Export structures, shared by server and client for argument matching */
#ifdef PTP_EXPORT_STRUCTURES
//int ptpdexp_get_sync_state(ptpdexp_sync_state_t *state);
struct minipc_pd __rpcdef_get_sync_state = {
.name = "get_sync_state",
.retval = MINIPC_ARG_ENCODE(MINIPC_ATYPE_STRUCT, ptpdexp_sync_state_t),
.args = {
MINIPC_ARG_END,
},
};
//int ptpdexp_cmd(int cmd, int value);
struct minipc_pd __rpcdef_cmd = {
.name = "cmd",
......
......@@ -28,6 +28,7 @@
#include <libwr/pio.h>
#include <libwr/fan.h>
#include <libwr/hal_shmem.h>
#include <at91_softpwm.h>
......@@ -39,7 +40,10 @@
#include "spwm-regs.h"
#include <libwr/util.h>
#define FAN_TEMP_SENSOR_ADDR 0x4c
#define TEMP_SENSOR_ADDR_FPGA 0x4A /* (7bits addr) IC19 Below FPGA */
#define TEMP_SENSOR_ADDR_PLL 0x4C /* (7bits addr) IC18 PLLs */
#define TEMP_SENSOR_ADDR_PSL 0x49 /* (7bits addr) IC20 Power supply left */
#define TEMP_SENSOR_ADDR_PSR 0x4D /* (7bits addr) IC17 Power supply right */
#define DESIRED_TEMPERATURE 55.0
......@@ -204,7 +208,7 @@ static int shw_init_i2c_sensors()
return 0;
}
int shw_init_fans()
int shw_init_fans(void)
{
uint32_t val = 0;
......@@ -250,7 +254,11 @@ int shw_init_fans()
shw_init_i2c_sensors();
tmp100_write_reg(FAN_TEMP_SENSOR_ADDR, 1, 0x60); // 12-bit resolution
/* set all to 12-bit resolution */
tmp100_write_reg(TEMP_SENSOR_ADDR_FPGA, 1, 0x60);
tmp100_write_reg(TEMP_SENSOR_ADDR_PLL, 1, 0x60);
tmp100_write_reg(TEMP_SENSOR_ADDR_PSL, 1, 0x60);
tmp100_write_reg(TEMP_SENSOR_ADDR_PSR, 1, 0x60);
pi_init(&fan_pi);
......@@ -263,17 +271,24 @@ int shw_init_fans()
* Reads out the temperature and drives the fan accordingly
* note: This call is done by hal_main.c:hal_update()
*/
void shw_update_fans()
void shw_update_fans(struct hal_temp_sensors *sensors)
{
static int64_t last_tics = -1;
int64_t cur_tics = shw_get_tics();
if (fan_update_timeout > 0
&& (last_tics < 0 || (cur_tics - last_tics) > fan_update_timeout)) {
float t_cur = tmp100_read_temp(FAN_TEMP_SENSOR_ADDR);
/* drive fan based on PLL temperature */
float t_cur = tmp100_read_temp(TEMP_SENSOR_ADDR_PLL);
float drive = pi_update(&fan_pi, t_cur - DESIRED_TEMPERATURE);
//pr_info("t=%f,pwm=%f\n",t_cur , drive);
shw_pwm_speed(0xFF, drive / 1000); //enable two and one
/* update sensor values */
sensors->fpga = tmp100_read_reg(TEMP_SENSOR_ADDR_FPGA, 0, 2);
sensors->pll = tmp100_read_reg(TEMP_SENSOR_ADDR_PLL, 0, 2);
sensors->psl = tmp100_read_reg(TEMP_SENSOR_ADDR_PSL, 0, 2);
sensors->psr = tmp100_read_reg(TEMP_SENSOR_ADDR_PSR, 0, 2);
last_tics = cur_tics;
}
}
......@@ -6,15 +6,10 @@
#define HAL_EXPORT_STRUCTURES
#include <hal/hal_exports.h>
#include <libwr/shmem.h>
#include <libwr/hal_shmem.h>
#define DEFAULT_TO 200000 /* ms */
static struct minipc_ch *hal_ch;
static struct wrs_shm_head *hal_head;
static struct hal_port_state *hal_ports;
static int hal_nports;
int halexp_lock_cmd(const char *port_name, int command, int priority)
{
......@@ -39,17 +34,6 @@ int halexp_pps_cmd(int cmd, hexp_pps_params_t * params)
/* Some clients call this, some call the client_init() defined later */
int halexp_client_try_connect(int retries, int timeout)
{
struct hal_shmem_header *h;
struct hal_port_state *p;
hal_head = wrs_shm_get(wrs_shm_hal,"", WRS_SHM_READ);
if (!hal_head)
return -1;
h = (void *)hal_head + hal_head->data_off;
hal_nports = h->nports;
p = wrs_shm_follow(hal_head, h->ports);
hal_ports = p; /* This is used in later calls */
for (;;) {
hal_ch =
minipc_client_create(WRSW_HAL_SERVER_ADDR,
......@@ -67,8 +51,3 @@ int halexp_client_try_connect(int retries, int timeout)
return -1;
}
int halexp_client_init()
{
return halexp_client_try_connect(0, 0);
}
#ifndef I2C_SFP_H
#define I2C_SFP_H
#ifndef I2C_IO_H
#define I2C_IO_H
#include "i2c.h"
......@@ -25,4 +25,4 @@ int shw_i2c_io_scan(uint8_t * dev_map);
int shw_get_hw_ver();
uint8_t shw_get_fpga_type();
#endif //I2C_SFP_H
#endif //I2C_IO_H
......@@ -520,7 +520,7 @@ int shw_sfp_read_header(int num, struct shw_sfp_header *head)
ret = shw_sfp_module_scan();
if (!(ret & (1 << num)))
return -1;
return -2;
ret =
shw_sfp_read(num, I2C_SFP_ADDRESS, 0x0,
......@@ -562,14 +562,28 @@ int shw_sfp_read_db(void)
int error, val, index;
for (index = 0; ; index++) {
error = libwr_cfg_convert2("SFP%02i_PARAMS", "name",
error = libwr_cfg_convert2("SFP%02i_PARAMS", "pn",
LIBWR_STRING, s, index);
if (error)
return 0; /* no more, no error */
sfp = calloc(1, sizeof(*sfp));
strncpy(sfp->part_num, s, sizeof(sfp->part_num));
error = libwr_cfg_convert2("SFP%02i_PARAMS", "vn",
LIBWR_STRING, s, index);
/* copy vendor name if found */
if (!error)
strncpy(sfp->vendor_name, s, sizeof(sfp->vendor_name));
sfp->vendor_serial[0] = 0;
error = libwr_cfg_convert2("SFP%02i_PARAMS", "vs",
LIBWR_STRING, s, index);
/* copy serial name if found */
if (!error)
strncpy(sfp->vendor_serial, s,
sizeof(sfp->vendor_serial));
sfp->flags = SFP_FLAG_CLASS_DATA; /* never used */
/* These are uint32_t as I write this. So use "int val" */
......@@ -605,45 +619,60 @@ int shw_sfp_read_db(void)
return 0;
}
struct shw_sfp_caldata *shw_sfp_get_cal_data(int num)
struct shw_sfp_caldata *shw_sfp_get_cal_data(int num,
struct shw_sfp_header *head)
{
uint32_t ret;
struct shw_sfp_header head;
struct shw_sfp_caldata *t;
struct shw_sfp_caldata *other = NULL;
struct shw_sfp_caldata *match_pn_vn = NULL;
struct shw_sfp_caldata *match_pn = NULL;
char *vn = (char *)head->vendor_name;
char *pn = (char *)head->vendor_pn;
char *vs = (char *)head->vendor_serial;
int i;
ret = shw_sfp_module_scan();
if (!(ret & (1 << num))) {
printf("sfp not inserted into slot: %d\n", num);
return NULL;
/* Replace spaces at the end of strings with 0 needed for
* string comparison inside shw_sfp_get_cal_data.
* String may contain spaces, standard says only about space padding */
for (i = 15; i >= 0 ; i--) {
if (vn[i] != 0x20)
break;
vn[i] = 0;
}
if (shw_sfp_read_header(num, &head) < 0) {
printf("failed to read sfp header for slot %d\n", num);
return NULL;
for (i = 15; i >= 0 ; i--) {
if (pn[i] != 0x20)
break;
pn[i] = 0;
}
char *pn = (char *)head.vendor_pn;
char *vs = (char *)head.vendor_serial;
int i;
for (i = 0; i < 16; i++) {
if (pn[i] == 0x20)
pn[i] = 0;
if (vs[i] == 0x20)
vs[i] = 0;
for (i = 15; i >= 0 ; i--) {
if (vs[i] != 0x20)
break;
vs[i] = 0;
}
t = shw_sfp_cal_list;
/* In the first pass, look for serial number */
while (t) {
// printf("search1 %s %s\n", t->part_num, t->vendor_serial);
if (strncmp(pn, t->part_num, 16) == 0
&& strncmp(t->vendor_serial, "", 16) == 0)
other = t;
else if (strncmp(pn, t->part_num, 16) == 0
&& strncmp(vs, t->vendor_serial, 16) == 0)
if (t->vendor_name[0] == 0
&& strncmp(pn, t->part_num, 16) == 0
&& t->vendor_serial[0] == 0)
/* matched pn, but vn and vs not defined */
match_pn = t;
else if (strncmp(vn, t->vendor_name, 16) == 0
&& strncmp(pn, t->part_num, 16) == 0
&& t->vendor_serial[0] == 0)
/* matched vn, pn, but vs not defined */
match_pn_vn = t;
else if (strncmp(vn, t->vendor_name, 16) == 0
&& strncmp(pn, t->part_num, 16) == 0
&& strncmp(vs, t->vendor_serial, 16) == 0)
/* matched vn, pn, vs */
return t;
t = t->next;
}
if (other)
return other;
if (match_pn_vn)
return match_pn_vn;
if (match_pn)
return match_pn;
return NULL;
}
#ifndef __LIBWR_FAN_H
#define __LIBWR_FAN_H
#include <libwr/hal_shmem.h>
#define SHW_FAN_UPDATETO_DEFAULT 5
int shw_init_fans();
void shw_update_fans();
int shw_init_fans(void);
void shw_update_fans(struct hal_temp_sensors *sensors);
#endif /* __LIBWR_FAN_H */
......@@ -4,7 +4,6 @@
#include <hal/hal_exports.h>
int halexp_client_init();
int halexp_client_try_connect(int retries, int timeout);
#endif /* __LIBWR_HAL_CLIENT_H */
......@@ -102,12 +102,24 @@ struct hal_port_state {
uint32_t ep_base;
};
struct hal_temp_sensors {
int fpga; /* IC19 */
int pll; /* IC18 */
int psl; /* IC20 Power Supply Left (PSL) */
int psr; /* IC17 Power Supply Right (PSR) */
int fpga_thold; /* Threshold value for FPGA temperature */
int pll_thold; /* Threshold value for PLL temperature */
int psl_thold; /* Threshold value for PSL temperature */
int psr_thold; /* Threshold value for PSR temperature */
};
/* This is the overall structure stored in shared memory */
#define HAL_SHMEM_VERSION 4 /* Version 4 because of new fields in struct
* hal_port_state */
#define HAL_SHMEM_VERSION 6 /* Version 6 because of new structure
* hal_temp_sensors in hal_shmem_header */
struct hal_shmem_header {
int nports;
struct hal_port_state *ports;
struct hal_temp_sensors temp;
};
static inline int state_up(int state)
......
......@@ -20,14 +20,23 @@
#define SFP_FLAG_CLASS_DATA (1 << 0)
#define SFP_FLAG_DEVICE_DATA (1 << 1)
#define SFP_FLAG_1GbE (1 << 2) /* SFP is 1GbE */
#define SFP_FLAG_IN_DB (1 << 3) /* SFP is present in data base */
#define SFP_SPEED_1Gb 0x0D /* Speed of SFP in 100MB/s. According to
* SFF-8472.PDF: By convention 1.25 Gb/s
* should be rounded up to 0Dh (13 in
* units of 100 MBd) for Ethernet
* 1000BASE-X. */
struct shw_sfp_caldata {
int flags;
uint32_t flags;
/*