lfsr: crank it 128 times before using the sequence
Signed-off-by: Jens Axboe <axboe@kernel.dk>
diff --git a/lib/lfsr.c b/lib/lfsr.c
index 64442ab..01c97cb 100644
--- a/lib/lfsr.c
+++ b/lib/lfsr.c
@@ -3,7 +3,7 @@
#include "lfsr.h"
/*
- * Trom table 3 of
+ * From table 3 of
*
* http://www.xilinx.com/support/documentation/application_notes/xapp052.pdf
*/
@@ -202,6 +202,8 @@
},
};
+#define FIO_LFSR_CRANKS 128
+
static uint64_t __lfsr_next(uint64_t v, struct lfsr_taps *lt)
{
uint64_t xor_mask = 0;
@@ -235,7 +237,7 @@
int i;
for (i = 0; lfsr_taps[i].length; i++)
- if ((1UL << lfsr_taps[i].length) >= size)
+ if (((1UL << lfsr_taps[i].length) + FIO_LFSR_CRANKS) >= size)
return &lfsr_taps[i];
return NULL;
@@ -260,5 +262,8 @@
break;
}
+ for (i = 0; i < FIO_LFSR_CRANKS; i++)
+ fl->last_val = __lfsr_next(fl->last_val, &fl->taps);
+
return 0;
}