Commit 8c5a3c94 authored by Adam Wujek's avatar Adam Wujek

dev/sfp: use 64bit to store alpha for SFPs

Signed-off-by: 's avatarAdam Wujek <adam.wujek@creotech.pl>
parent 655620ed
......@@ -25,13 +25,13 @@
* ----------------------------------------------
* | cal_ph_trans (4B) | SFP count (1B) |
* --------------------------------------------------------------------------------------------
* | SFP(1) part number (16B) | alpha (4B) | deltaTx (4B) | deltaRx (4B) | chksum(1B) |
* | SFP(1) part number (16B) | alpha (8B) | deltaTx (4B) | deltaRx (4B) | chksum(1B) |
* --------------------------------------------------------------------------------------------
* | SFP(2) part number (16B) | alpha (4B) | deltaTx (4B) | deltaRx (4B) | chksum(1B) |
* | SFP(2) part number (16B) | alpha (8B) | deltaTx (4B) | deltaRx (4B) | chksum(1B) |
* --------------------------------------------------------------------------------------------
* | (....) | (....) | (....) | (....) | (...) |
* --------------------------------------------------------------------------------------------
* | SFP(count) part number (16B) | alpha (4B) | deltaTx (4B) | deltaRx (4B) | chksum(1B) |
* | SFP(count) part number (16B) | alpha (8B) | deltaTx (4B) | deltaRx (4B) | chksum(1B) |
* --------------------------------------------------------------------------------------------
*
* Fields description:
......
......@@ -20,7 +20,7 @@
#include "storage.h"
/* Calibration data (from EEPROM if available) */
int32_t sfp_alpha = 73622176; /* default values if could not read EEPROM */
int64_t sfp_alpha = 1235332333756144; /* def values if could not read EEPROM */
int32_t sfp_deltaTx = 0;
int32_t sfp_deltaRx = 0;
int32_t sfp_in_db = 0;
......
......@@ -460,12 +460,12 @@ int set_persistent_mac(uint8_t portnum, uint8_t *mac)
* For each sfp we have
*
* - part number (16 bytes)
* - alpha (4 bytes)
* - alpha (8 bytes)
* - deltaTx (4 bytes)
* - delta Rx (4 bytes)
* - checksum (1 byte) (low order 8 bits of the sum of all bytes)
*
* the total is 29 bytes for each sfp (ugly, but we are byte-oriented anyways
* the total is 33 bytes for each sfp (ugly, but we are byte-oriented anyways
*/
......
......@@ -666,11 +666,13 @@ where \texttt{xx:xx:xx:xx:xx:xx} is the MAC address of your board.\\
Next, you should input calibration fixed delays values and alpha parameters. The
example below clears any existing entries and adds two Axcen transceivers with
$\Delta_{TX}$, $\Delta_{RX}$ and $\alpha$ parameters associated with them.
Please note that the $\alpha$ value is slit into two values. The most
significant 9 decimal digits and the least significant 9 decimal digits.
\begin{lstlisting}
wrc# sfp erase
wrc# sfp add AXGE-1254-0531 180750 148326 72169888
wrc# sfp add AXGE-3454-0531 180750 148326 -73685416
wrc# sfp add AXGE-1254-0531 180750 148326 1235332 333756144
wrc# sfp add AXGE-3454-0531 180750 148326 -1235332 333756144
\end{lstlisting}
To check the content of the SFP database you can execute the \textit{sfp show}
......@@ -1070,7 +1072,7 @@ Simple verification of performed actions:\\
The same add can also be achieved by performing \texttt{sfp add} command in
the WRPC's console:
\begin{lstlisting}
wrc# sfp add NEW-SFP 1111 2222 3333
wrc# sfp add NEW-SFP 1111 2222 0 3333
Update existing SFP entry
3 SFPs in DB
\end{lstlisting}
......@@ -1907,8 +1909,10 @@ tools used to build and run it, you can write to our mailing list
as VHDL generic parameters of the WR PTP Core. Command \code{sdb} is
available if \texttt{CONFIG\_GENSDBFS} is set.\\
\code{sfp add <PN> <deltaTx> <deltaRx> <alpha>} & stores calibration
parameters for SFP to a file in Flash/EEPROM \\
\code{sfp add <PN> <deltaTx> <deltaRx> <alphaH> <alphaL>} & stores calibration
parameters for SFP to a file in Flash/EEPROM. \code{<alphaL>} is the 9 lower
decimal digits of alpha value, \code{<alphaH>} are the 9 higher decimal
digits. For negative alpha values only \code{<alphaH>} is negative. \\
\code{sfp erase} & erases the SFP database stored in the Flash/EEPROM \\
......
......@@ -19,7 +19,7 @@
extern char sfp_pn[SFP_PN_LEN];
extern int32_t sfp_in_db;
extern int32_t sfp_alpha;
extern int64_t sfp_alpha;
extern int32_t sfp_deltaTx;
extern int32_t sfp_deltaRx;
......
......@@ -41,8 +41,10 @@
/* It should be:
* #define EE_BASE_INIT (EE_BASE_SFP + sizeof(sfpcount) + \
* SFPS_MAX * sizeof(struct s_sfpinfo))
* The used definition define the start of the init script 5 bytes
* The used definition define the start of the init script 21 bytes
* (sizeof(sfpcount) + sizeof(t24p)) before the end of SFP database.
* Edit: Since the alpha was changed to 64bit, the size of sizeof(struct s_sfpinfo)
* increased by 4. The error is now 5 + 16 = 21 bytes, not 5 as before.
* To make the init script working during the update of old versions of wrpc
* SFPS_MAX is limited to 3. Adding the 4th SFP will corrupt the init script
* anyway.
......@@ -73,7 +75,7 @@ struct storage_device;
struct s_sfpinfo {
char pn[SFP_PN_LEN];
int32_t alpha;
int64_t alpha;
int32_t dTx;
int32_t dRx;
uint8_t chksum;
......
......@@ -47,7 +47,7 @@ static int cmd_sfp(const char *args[])
return -EIO;
}
return 0;
} else if (args[4] && !strcasecmp(args[0], "add")) {
} else if (args[5] && !strcasecmp(args[0], "add")) {
temp = strnlen(args[1], SFP_PN_LEN);
for (i = 0; i < temp; ++i)
sfp.pn[i] = args[1][i];
......@@ -56,6 +56,9 @@ static int cmd_sfp(const char *args[])
sfp.dTx = atoi(args[2]);
sfp.dRx = atoi(args[3]);
sfp.alpha = atoi(args[4]);
sfp.alpha = sfp.alpha * 1000000000;
/* first value defines a sign */
sfp.alpha += (sfp.alpha < 0?-1:1) * atoi(args[5]);
temp = storage_get_sfp(&sfp, SFP_ADD, 0);
if (temp == EE_RET_DBFULL) {
pp_printf("SFP DB is full\n");
......@@ -83,7 +86,7 @@ static int cmd_sfp(const char *args[])
pp_printf("%d: PN:", i + 1);
for (temp = 0; temp < SFP_PN_LEN; ++temp)
pp_printf("%c", sfp.pn[temp]);
pp_printf(" dTx: %8d dRx: %8d alpha: %8d\n", sfp.dTx,
pp_printf(" dTx: %8d dRx: %8d alpha: %19Ld\n", sfp.dTx,
sfp.dRx, sfp.alpha);
}
return 0;
......@@ -112,7 +115,7 @@ static int cmd_sfp(const char *args[])
return ret;
}
/* match successful */
pp_printf("SFP matched, dTx=%d dRx=%d alpha=%d\n",
pp_printf("SFP matched, dTx=%d dRx=%d alpha=%Ld\n",
sfp_deltaTx, sfp_deltaRx, sfp_alpha);
return ret;
} else if (args[1] && !strcasecmp(args[0], "ena")) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment