Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
Software for White Rabbit PTP Core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
29
Issues
29
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
CI / CD
CI / CD
Pipelines
Schedules
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
Software for White Rabbit PTP Core
Commits
2f2777b0
Commit
2f2777b0
authored
Oct 10, 2018
by
Adam Wujek
💬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lib/snmp: add wrpcSdbGroup to format sdb
Signed-off-by:
Adam Wujek
<
adam.wujek@cern.ch
>
parent
4f77dba8
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
147 additions
and
0 deletions
+147
-0
Kconfig
Kconfig
+7
-0
WR-WRPC-MIB.txt
lib/WR-WRPC-MIB.txt
+54
-0
snmp.c
lib/snmp.c
+86
-0
No files found.
Kconfig
View file @
2f2777b0
...
...
@@ -183,6 +183,13 @@ config SNMP_INIT
help
This option adds a branch wrpcInitScriptConfigGroup to the SNMP
config SNMP_SDB
depends on SNMP && GENSDBFS
default y
boolean "Adds support of generation of SDB via SNMP"
help
This option adds a branch wrpcSdbGroup to the SNMP
config SNMP_AUX_DIAG
depends on SNMP && AUX_DIAG
default y if AUX_DIAG
...
...
lib/WR-WRPC-MIB.txt
View file @
2f2777b0
...
...
@@ -773,7 +773,61 @@ wrpcInitScriptConfigLine OBJECT-TYPE
"Line to be added to the init script."
::= { wrpcInitScriptConfigGroup 2 }
-- ****************************************************************************
wrpcSdbGroup OBJECT IDENTIFIER ::= { wrpcCore 10 }
wrpcSdbApply OBJECT-TYPE
SYNTAX INTEGER {
na(0),
writeToFlash(1),
eraseFlash(50),
applySuccessful(100),
applyFailed(200),
applyFailedEmptyParam(201)
}
MAX-ACCESS read-write
STATUS current
DESCRIPTION
"Make a change to a init script
writeToFlash - Add a defined command from wrpcInitScriptConfigLine to the init script
eraseFlash - Erase init script in the flash.
applySuccessful - Configuration applied successfully.
applyFailed - Failed to update init script.
applyFailedEmptyParam - Failed to write to SDB, some params are empty is empty.
"
::= { wrpcSdbGroup 1 }
wrpcSdbMemType OBJECT-TYPE
SYNTAX INTEGER {
flash(0),
eeprom(1),
w1eeprom(2),
fram(3)
}
MAX-ACCESS read-write
STATUS current
DESCRIPTION
"Mem type"
::= { wrpcSdbGroup 2 }
wrpcSdbBaseAddr OBJECT-TYPE
SYNTAX Integer32
MAX-ACCESS read-write
STATUS current
DESCRIPTION
"Base addr"
::= { wrpcSdbGroup 3 }
wrpcSdbParam OBJECT-TYPE
SYNTAX Integer32
MAX-ACCESS read-write
STATUS current
DESCRIPTION
"Param"
::= { wrpcSdbGroup 4 }
-- ****************************************************************************
END
lib/snmp.c
View file @
2f2777b0
...
...
@@ -127,6 +127,10 @@
#define writeToFlash 1
#define applyFailedEmptyLine 201
/* new defines for oid_wrpcSdbApply, some are used from
* wrpcPtpConfigApply */
#define applyFailedEmptyParam 201
/* defines for wrpcTemperatureTable */
#define TABLE_ROW 1
#define TABLE_COL 0
...
...
@@ -220,6 +224,13 @@ static int ptp_config_apply_status;
static
int
ptp_restart_status
;
static
char
init_script_line
[
32
];
static
int
init_script_config_apply_status
;
/* related to wrpcSdbGroup */
static
int
sdb_apply_status
;
static
int
sdb_mem_type
=
-
1
;
static
int
sdb_base_addr
=
-
1
;
static
int
sdb_param
=
-
1
;
/* Keep the number of aux diag registers available in the FPGA bitstream */
static
uint32_t
aux_diag_reg_ro_num
;
static
uint32_t
aux_diag_reg_rw_num
;
...
...
@@ -268,6 +279,7 @@ static int set_p(uint8_t *buf, struct snmp_oid *obj);
static
int
set_ptp_restart
(
uint8_t
*
buf
,
struct
snmp_oid
*
obj
);
static
int
set_ptp_config
(
uint8_t
*
buf
,
struct
snmp_oid
*
obj
);
static
int
set_init_script_config
(
uint8_t
*
buf
,
struct
snmp_oid
*
obj
);
static
int
set_sdb
(
uint8_t
*
buf
,
struct
snmp_oid
*
obj
);
static
int
set_aux_diag
(
uint8_t
*
buf
,
struct
snmp_oid
*
obj
);
static
int
data_aux_diag
(
uint8_t
*
buf
,
struct
snmp_oid
*
obj
,
int
mode
);
...
...
@@ -285,6 +297,7 @@ static uint8_t oid_wrpcPortGroup[] = {0x2B,6,1,4,1,96,101,1,7};
/* Include wrpcSfpEntry into OID */
static
uint8_t
oid_wrpcSfpTable
[]
=
{
0x2B
,
6
,
1
,
4
,
1
,
96
,
101
,
1
,
8
,
1
};
static
uint8_t
oid_wrpcInitScriptConfigGroup
[]
=
{
0x2B
,
6
,
1
,
4
,
1
,
96
,
101
,
1
,
9
};
static
uint8_t
oid_wrpcSdbGroup
[]
=
{
0x2B
,
6
,
1
,
4
,
1
,
96
,
101
,
1
,
10
};
/* In below OIDs zeros will be replaced in the snmp_init function by values
* read from FPA */
static
uint8_t
oid_wrpcAuxRoTable
[]
=
{
0x2B
,
6
,
1
,
4
,
1
,
96
,
101
,
2
,
0
,
0
,
1
,
1
};
...
...
@@ -360,6 +373,13 @@ static uint8_t oid_wrpcSfpAlpha[] = {5};
static
uint8_t
oid_wrpcInitScriptConfigApply
[]
=
{
1
,
0
};
static
uint8_t
oid_wrpcInitScriptConfigLine
[]
=
{
2
,
0
};
/* oid_wrpcSdbGroup */
static
uint8_t
oid_wrpcSdbApply
[]
=
{
1
,
0
};
static
uint8_t
oid_wrpcSdbMemType
[]
=
{
2
,
0
};
static
uint8_t
oid_wrpcSdbBaseAddr
[]
=
{
3
,
0
};
static
uint8_t
oid_wrpcSdbParam
[]
=
{
4
,
0
};
/* NOTE: to have SNMP_GET_NEXT working properly this array has to be sorted by
OIDs */
/* wrpcVersionGroup */
...
...
@@ -460,6 +480,15 @@ static struct snmp_oid oid_array_wrpcInitScriptConfigGroup[] = {
{
0
,
}
};
/* wrpcSdbGroup */
static
struct
snmp_oid
oid_array_wrpcSdbGroup
[]
=
{
OID_FIELD_VAR
(
oid_wrpcSdbApply
,
get_p
,
set_sdb
,
ASN_INTEGER
,
&
sdb_apply_status
),
OID_FIELD_VAR
(
oid_wrpcSdbMemType
,
get_p
,
set_p
,
ASN_INTEGER
,
&
sdb_mem_type
),
OID_FIELD_VAR
(
oid_wrpcSdbBaseAddr
,
get_p
,
set_p
,
ASN_INTEGER
,
&
sdb_base_addr
),
OID_FIELD_VAR
(
oid_wrpcSdbParam
,
get_p
,
set_p
,
ASN_INTEGER
,
&
sdb_param
),
{
0
,
}
};
static
struct
snmp_oid
oid_array_wrpcAuxRoTable
[]
=
{
OID_FIELD_VAR
(
NULL
,
get_aux_diag
,
NO_SET
,
ASN_UNSIGNED
,
AUX_DIAG_RO
),
{
0
,
}
...
...
@@ -484,6 +513,9 @@ static struct snmp_oid_limb oid_limb_array[] = {
#ifdef CONFIG_SNMP_INIT
OID_LIMB_FIELD
(
oid_wrpcInitScriptConfigGroup
,
func_group
,
oid_array_wrpcInitScriptConfigGroup
),
#endif
#ifdef CONFIG_SNMP_SDB
OID_LIMB_FIELD
(
oid_wrpcSdbGroup
,
func_group
,
oid_array_wrpcSdbGroup
),
#endif
#ifdef CONFIG_SNMP_AUX_DIAG
OID_LIMB_FIELD
(
oid_wrpcAuxRoTable
,
func_aux_diag
,
oid_array_wrpcAuxRoTable
),
OID_LIMB_FIELD
(
oid_wrpcAuxRwTable
,
func_aux_diag
,
oid_array_wrpcAuxRwTable
),
...
...
@@ -1404,6 +1436,58 @@ static int set_init_script_config(uint8_t *buf, struct snmp_oid *obj)
return
ret
;
}
static
int
set_sdb
(
uint8_t
*
buf
,
struct
snmp_oid
*
obj
)
{
int
ret
;
int32_t
*
apply_mode
;
uint8_t
i2c_adr
=
FMC_EEPROM_ADR
;
int
blocksize
=
1
;
apply_mode
=
obj
->
p
;
ret
=
set_value
(
buf
,
obj
,
apply_mode
);
if
(
ret
<=
0
)
return
ret
;
snmp_verbose
(
"%s enter
\n
"
,
__func__
);
if
(
sdb_mem_type
==
-
1
||
sdb_base_addr
==
-
1
||
sdb_param
==
-
1
)
{
*
apply_mode
=
applyFailedEmptyParam
;
pp_printf
(
"%s wrong params
\n
"
,
__func__
);
return
ret
;
}
if
(
sdb_mem_type
==
MEM_FLASH
)
blocksize
=
sdb_param
*
1024
;
else
if
(
sdb_param
)
i2c_adr
=
sdb_param
;
switch
(
*
apply_mode
)
{
case
writeToFlash
:
snmp_verbose
(
"%s writeToFlash
\n
"
,
__func__
);
if
(
storage_gensdbfs
(
sdb_mem_type
,
sdb_base_addr
,
blocksize
,
i2c_adr
)
<
0
)
*
apply_mode
=
applyFailed
;
else
*
apply_mode
=
applySuccessful
;
break
;
case
eraseFlash
:
snmp_verbose
(
"%s eraseFlash
\n
"
,
__func__
);
if
(
storage_sdbfs_erase
(
sdb_mem_type
,
sdb_base_addr
,
blocksize
,
i2c_adr
)
<
0
)
*
apply_mode
=
applyFailed
;
else
*
apply_mode
=
applySuccessful
;
break
;
default:
*
apply_mode
=
applyFailed
;
}
return
ret
;
}
/*
* Perverse... snmpwalk does getnext anyways.
*
...
...
@@ -1578,6 +1662,8 @@ static int snmp_respond(uint8_t *buf)
oid_array_wrpcAuxRoTable
[
0
].
oid_len
=
0
;
oid_array_wrpcInitScriptConfigGroup
[
0
].
oid_len
=
0
;
(
void
)
oid_wrpcInitScriptConfigGroup
;
oid_array_wrpcSdbGroup
[
0
].
oid_len
=
0
;
(
void
)
oid_wrpcSdbGroup
;
}
for
(
a_i
=
0
,
h_i
=
0
;
a_i
<
sizeof
(
match_array
);
a_i
++
,
h_i
++
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment