Hi,
Here's a preliminary patch that provides knobs for tuning two reboot
thresholds of the state machine. With this patch it is possible to smooth
modem stability over noisy telephone lines.
I will try to do the something similar for the CRC rate controls (97th and
90th reboot thresholds), any idea welcome.
One questionnable target of the patch is the ioctl_info structure, it should
probably use an union to shrink the structure size.
Cheers,
--
Alexis Deruelle <[EMAIL PROTECTED]>
Seulement dans eagleusb-crc/doc: man
diff -ur eagleusb/driver/eu_main.c eagleusb-crc/driver/eu_main.c
--- eagleusb/driver/eu_main.c 2005-01-18 00:07:22.000000000 +0100
+++ eagleusb-crc/driver/eu_main.c 2005-01-18 10:19:07.247269672 +0100
@@ -683,6 +683,8 @@
*/
ins->AdiModemSm.HeartbeatCounter = 0;
ins->AdiModemSm.CurrentAdiState = STATE_JUST_PLUGGED_IN;
+ ins->AdiModemSm.CrcRetrainThreshold = CRC_RETRAIN_THRESHOLD;
+ ins->AdiModemSm.LosDefectRetrainThreshold = LOS_DEFECT_RETRAIN_THRESHOLD;
init_timer(&ins->OAMTimer);
ins->OAMTimer.function = OAMTimerFunction;
@@ -1704,6 +1706,18 @@
else
retval = 0;
break;
+
+ case EU_IO_SETTING:
+ eu_report ("ioctl EU_IO_SETTING received\n");
+ if (pIOCTLinfo->crc_retrain_threshold != 0) {
+ ins->AdiModemSm.CrcRetrainThreshold = pIOCTLinfo->crc_retrain_threshold;
+ eu_report ("CRC retrain threshold set to %d\n", ins->AdiModemSm.CrcRetrainThreshold);
+ }
+ if (pIOCTLinfo->los_defect_retrain_threshold != 0) {
+ ins->AdiModemSm.LosDefectRetrainThreshold = pIOCTLinfo->los_defect_retrain_threshold;
+ eu_report ("LOS defect retrain threshold set to %d\n", ins->AdiModemSm.LosDefectRetrainThreshold);
+ }
+ break;
default:
/* Bad ioctl */
diff -ur eagleusb/driver/eu_types.h eagleusb-crc/driver/eu_types.h
--- eagleusb/driver/eu_types.h 2004-11-07 10:06:55.000000000 +0100
+++ eagleusb-crc/driver/eu_types.h 2005-01-18 10:17:06.746576908 +0100
@@ -36,6 +36,8 @@
*/
struct eu_ioctl_info
{
+ uint8_t crc_retrain_threshold;
+ uint8_t los_defect_retrain_threshold;
uint32_t idma_start;
uint32_t buffer_size;
uint8_t *buffer;
@@ -54,6 +56,7 @@
#if USE_CMVS
#define EU_IO_CMVS _IOW('U', 107, struct eu_ioctl_info)
#endif
+#define EU_IO_SETTING _IOW('U', 108, struct eu_ioctl_info)
/*
* Options description structure
@@ -419,6 +422,9 @@
uint8_t Block_CRC90;
uint8_t Block_CRC97;
+ uint8_t CrcRetrainThreshold;
+ uint8_t LosDefectRetrainThreshold;
+
uint32_t stats_Ne_Fast_Lod_Failure;
uint32_t stats_Ne_Fast_Hec_Failure;
@@ -667,7 +673,11 @@
* Number of OAM cells received
*/
#define STAT_CELLS_OAM_RCVD 0x0014
-
+/*
+ * Default reboot thresholds
+ */
+#define LOS_DEFECT_RETRAIN_THRESHOLD 2 /* about 1 */
+#define CRC_RETRAIN_THRESHOLD 4 /* about 10 secs of continuous CRC to cause retrain */
typedef struct eu_instance_s
{
diff -ur eagleusb/driver/Sm.c eagleusb-crc/driver/Sm.c
--- eagleusb/driver/Sm.c 2004-09-27 23:59:07.000000000 +0200
+++ eagleusb-crc/driver/Sm.c 2005-01-18 10:19:29.348911849 +0100
@@ -50,10 +50,6 @@
#define OPER_CHECK_FREQ 3
#define OPER_CHECK_FREQ_DETAIL 0xF
-#define LOS_DEFECT_RETRAIN_THRESHOLD 2 /* about 1 */
-#define CRC_RETRAIN_THRESHOLD 4 /* about 10 secs of continuous CRC to cause retrain */
-
-
#define RETRY_LIMIT 10
#define MAX_IDLE_COUNT 100
#define RETRAIN_ATTEMPTS 160
@@ -711,11 +707,12 @@
(DIAG_FLAGS_NEFASTCRC_MASK|DIAG_FLAGS_NEINTLCRC_MASK) ) != 0)
{
- if (++pAdiSM->CRC_count >= CRC_RETRAIN_THRESHOLD)
+ if (++pAdiSM->CRC_count >= pAdiSM->CrcRetrainThreshold)
{
eu_dbg (DBG_SM,"OPSTAT step1 CRC thresh RESET\n");
- eu_err("CRC count threshold reached. Rebooting\n");
+ eu_err("CRC count threshold (%d) reached. Rebooting\n",
+ pAdiSM->CrcRetrainThreshold);
ResetModemSM(pAdiSM);
}
}
@@ -728,11 +725,12 @@
if ((pAdiSM->flags & DIAG_FLAGS_NELOSDEFECT_MASK) != 0)
{
eu_err (" SM: LOS Defect\n");
- if (++pAdiSM->LOS_count >= LOS_DEFECT_RETRAIN_THRESHOLD)
+ if (++pAdiSM->LOS_count >= pAdiSM->LosDefectRetrainThreshold)
{
eu_dbg (DBG_SM,"OPSTAT step1 LOS thresh RESET\n");
- eu_report ("LOS Defect threshold reached. Rebooting\n");
+ eu_err ("LOS Defect threshold (%d) reached. Rebooting\n",
+ pAdiSM->LosDefectRetrainThreshold);
ResetModemSM(pAdiSM);
}
diff -ur eagleusb/driver/user/eaglectrl.c eagleusb-crc/driver/user/eaglectrl.c
--- eagleusb/driver/user/eaglectrl.c 2004-11-07 09:45:25.000000000 +0100
+++ eagleusb-crc/driver/user/eaglectrl.c 2005-01-18 10:20:28.761885450 +0100
@@ -109,6 +109,7 @@
#if USE_CMVS
#define DO_CMVS (1<<8)
#endif /* USE_CMVS */
+#define DO_SETTING (1<<9)
#define SKIP_BLANKS(p) \
while ((*(p) !='\0') && \
@@ -275,10 +276,12 @@
{"get-debug",no_argument,0,'g'},
{"set-debug",required_argument,0,'x'},
{"list-debug",no_argument,0,'l'},
+ {"crc-threshold",required_argument,0,'r'},
+ {"los-threshold",required_argument,0,'t'},
{0, 0, 0, 0}
};
-static char short_options[] = "hvf::d::s::o::ipwglx:";
+static char short_options[] = "hvf::d::s::o::ipwglx:r:t:";
/* Debug level accepted */
typedef struct
@@ -417,7 +420,8 @@
unsigned int options_set = 0;
int retcode = EXIT_SUCCESS;
unsigned int dbg_mask = 0;
-
+ unsigned int crc_threshold = 0;
+ unsigned int los_threshold = 0;
/* Parse options */
while ( 1 )
@@ -547,6 +551,26 @@
}
}
break;
+
+ case 'r':
+ options_set |= DO_SETTING;
+ if ( isdigit (optarg[0]) ) {
+ crc_threshold = strtoul(optarg, (char **)NULL, 16);
+ } else {
+ retcode = EXIT_FAILURE;
+ goto byebye;
+ }
+ break;
+
+ case 't':
+ options_set |= DO_SETTING;
+ if ( isdigit (optarg[0]) ) {
+ los_threshold = strtoul(optarg, (char **)NULL, 16);
+ } else {
+ retcode = EXIT_FAILURE;
+ goto byebye;
+ }
+ break;
}
}
@@ -631,6 +655,53 @@
retcode = send_dsp ( dsp_file );
}
+
+ if ( options_set & DO_SETTING )
+ {
+ int fd;
+ int other;
+ int res;
+ struct usbdevfs_ioctl ioc;
+ struct eu_ioctl_info ioc_info;
+ if ( geteuid() != 0 )
+ {
+ fprintf (stderr,"You must be root to do that !\n");
+ retcode = EXIT_FAILURE;
+ goto byebye;
+ }
+
+ fd = open_dev ( POST_FIRMWARE, NULL, &other );
+
+ if ( fd == -1 )
+ {
+ retcode = EXIT_FAILURE;
+
+ if (other)
+ {
+ display_device_type_help (POST_FIRMWARE);
+ }
+
+ goto byebye;
+ }
+
+ ioc_info.crc_retrain_threshold = crc_threshold;
+ ioc_info.los_defect_retrain_threshold = los_threshold;
+ ioc.ifno = 1;
+ ioc.ioctl_code = EU_IO_SETTING;
+ ioc.data = &ioc_info;
+
+ res = ioctl ( fd , USBDEVFS_IOCTL, &ioc ) ;
+
+ if ( res == -1 )
+ {
+ perror ("Unable to update driver settings");
+ retcode = EXIT_FAILURE;
+ close(fd);
+ goto byebye;
+ }
+
+ printf ("Settings successfully applied to driver.\n");
+ }
}
byebye:
@@ -1308,6 +1379,10 @@
printf (" or a list of debug flags separated by a comma. A list of\n");
printf (" available flags can be given by the --list-debug option.\n");
printf (" -l|--list-debug : Display a list of available flags for the debug-mask.\n");
+ printf (" -r|--crc-threshold : Set driver CRC count threshold <S>. When this threshold\n");
+ printf (" is reached the modem is rebooted (1-255).\n");
+ printf (" -t|--los-threshold : Set driver LOS count threshold <S>. When this threshold\n");
+ printf (" is reached the modem is rebooted (1-255).\n");
printf ("\n");
}