diff --git a/include/xor_codes/xor_hd_code_defs.h b/include/xor_codes/xor_hd_code_defs.h index 64468a2..df15e80 100644 --- a/include/xor_codes/xor_hd_code_defs.h +++ b/include/xor_codes/xor_hd_code_defs.h @@ -34,6 +34,9 @@ unsigned int g_12_6_4_hd_code_data_bms[] = { 7, 14, 28, 56, 49, 35, 13, 26, 52, unsigned int g_10_5_3_hd_code_parity_bms[] = { 163, 300, 337, 582, 664 }; unsigned int g_10_5_3_hd_code_data_bms[] = { 5, 9, 10, 18, 20, 3, 12, 17, 6, 24 }; +unsigned int g_3_3_3_hd_code_parity_bms[] = { 5, 6, 3 }; +unsigned int g_3_3_3_hd_code_data_bms[] = { 5, 6, 3}; + // The rest were generated via the "goldilocks" code algorithm unsigned int g_6_6_3_hd_code_parity_bms[] = { 3, 48, 36, 24, 9, 6 }; @@ -123,10 +126,13 @@ unsigned int * hd3_m5_data[11] = { 0, 0, 0, 0, 0, g_5_5_3_hd_code_data_bms, g_6_ unsigned int * hd3_m6_parity[16] = { 0, 0, 0, 0, 0, 0, g_6_6_3_hd_code_parity_bms, g_7_6_3_hd_code_parity_bms, g_8_6_3_hd_code_parity_bms, g_9_6_3_hd_code_parity_bms, g_10_6_3_hd_code_parity_bms, g_11_6_3_hd_code_parity_bms, g_12_6_3_hd_code_parity_bms, g_13_6_3_hd_code_parity_bms, g_14_6_3_hd_code_parity_bms, g_15_6_3_hd_code_parity_bms }; unsigned int * hd3_m6_data[16] = { 0, 0, 0, 0, 0, 0, g_6_6_3_hd_code_data_bms, g_7_6_3_hd_code_data_bms, g_8_6_3_hd_code_data_bms, g_9_6_3_hd_code_data_bms, g_10_6_3_hd_code_data_bms, g_11_6_3_hd_code_data_bms, g_12_6_3_hd_code_data_bms, g_13_6_3_hd_code_data_bms, g_14_6_3_hd_code_data_bms, g_15_6_3_hd_code_data_bms }; +unsigned int * hd3_m3_parity[4] = { 0, 0, 0, g_3_3_3_hd_code_parity_bms }; +unsigned int * hd3_m3_data[4] = { 0, 0, 0, g_3_3_3_hd_code_data_bms }; + unsigned int ** parity_bm_hd4 [7] = { 0, 0, 0, 0, 0, hd4_m5_parity, hd4_m6_parity }; unsigned int ** data_bm_hd4 [7] = { 0, 0, 0, 0, 0, hd4_m5_data, hd4_m6_data }; -unsigned int ** parity_bm_hd3 [7] = { 0, 0, 0, 0, 0, hd3_m5_parity, hd3_m6_parity }; -unsigned int ** data_bm_hd3 [7] = { 0, 0, 0, 0, 0, hd3_m5_data, hd3_m6_data }; +unsigned int ** parity_bm_hd3 [7] = { 0, 0, 0, hd3_m3_parity, 0, hd3_m5_parity, hd3_m6_parity }; +unsigned int ** data_bm_hd3 [7] = { 0, 0, 0, hd3_m3_data, 0, hd3_m5_data, hd3_m6_data }; #define PARITY_BM_ARY(k, m, hd) (hd == 3) ? parity_bm_hd3[m][k] : parity_bm_hd4[m][k] #define DATA_BM_ARY(k, m, hd) (hd == 3) ? data_bm_hd3[m][k] : data_bm_hd4[m][k] diff --git a/src/builtin/xor_codes/xor_hd_code.c b/src/builtin/xor_codes/xor_hd_code.c index d34e2d3..5c4d052 100644 --- a/src/builtin/xor_codes/xor_hd_code.c +++ b/src/builtin/xor_codes/xor_hd_code.c @@ -664,6 +664,8 @@ xor_code_t* init_xor_hd_code(int k, int m, int hd) if (k <= 10 && k >= 5) { is_valid = 1; } + } else if (m == 3) { + is_valid = 1; } } diff --git a/test/builtin/xor_codes/test_xor_hd_code.c b/test/builtin/xor_codes/test_xor_hd_code.c index 497b052..f40621b 100644 --- a/test/builtin/xor_codes/test_xor_hd_code.c +++ b/test/builtin/xor_codes/test_xor_hd_code.c @@ -238,6 +238,11 @@ int run_test(int k, int m, int hd) fprintf(stderr, "Running (%d, %d, %d):\n", k, m, hd); switch(k+m) { + case 6: + if (hd == 3) { + ret = test_hd_code(code_desc, NUM_6_3_COMBS, failure_combs_6_3); + } + break; case 10: if (hd == 3) { ret = test_hd_code(code_desc, NUM_10_3_COMBS, failure_combs_10_3); @@ -348,6 +353,11 @@ int main() { int ret = 0; int i; + + ret = run_test(3, 3, 3); + if (ret != 0) { + return ret; + } for (i=6; i < 16; i++) { ret = run_test(i, 6, 3); diff --git a/test/builtin/xor_codes/test_xor_hd_code.h b/test/builtin/xor_codes/test_xor_hd_code.h index eb96d05..9a1676f 100644 --- a/test/builtin/xor_codes/test_xor_hd_code.h +++ b/test/builtin/xor_codes/test_xor_hd_code.h @@ -22,6 +22,8 @@ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#define NUM_6_3_COMBS 21 +int failure_combs_6_3[NUM_6_3_COMBS][4] = {{0, -1, -1, -1}, {1, -1, -1, -1}, {2, -1, -1, -1}, {3, -1, -1, -1}, {4, -1, -1, -1}, {5, -1, -1, -1}, {0, 1, -1, -1}, {0, 2, -1, -1}, {0, 3, -1, -1}, {0, 4, -1, -1}, {0, 5, -1, -1}, {1, 2, -1, -1}, {1, 3, -1, -1}, {1, 4, -1, -1}, {1, 5, -1, -1}, {2, 3, -1, -1}, {2, 4, -1, -1}, {2, 5, -1, -1}, {3, 4, -1, -1}, {3, 5, -1, -1}, {4, 5, -1, -1}} ; #define NUM_10_3_COMBS 55 int failure_combs_10_3[NUM_10_3_COMBS][4] = {{0, -1, -1, -1}, {1, -1, -1, -1}, {2, -1, -1, -1}, {3, -1, -1, -1}, {4, -1, -1, -1}, {5, -1, -1, -1}, {6, -1, -1, -1}, {7, -1, -1, -1}, {8, -1, -1, -1}, {9, -1, -1, -1}, {0, 1, -1, -1}, {0, 2, -1, -1}, {0, 3, -1, -1}, {0, 4, -1, -1}, {0, 5, -1, -1}, {0, 6, -1, -1}, {0, 7, -1, -1}, {0, 8, -1, -1}, {0, 9, -1, -1}, {1, 2, -1, -1}, {1, 3, -1, -1}, {1, 4, -1, -1}, {1, 5, -1, -1}, {1, 6, -1, -1}, {1, 7, -1, -1}, {1, 8, -1, -1}, {1, 9, -1, -1}, {2, 3, -1, -1}, {2, 4, -1, -1}, {2, 5, -1, -1}, {2, 6, -1, -1}, {2, 7, -1, -1}, {2, 8, -1, -1}, {2, 9, -1, -1}, {3, 4, -1, -1}, {3, 5, -1, -1}, {3, 6, -1, -1}, {3, 7, -1, -1}, {3, 8, -1, -1}, {3, 9, -1, -1}, {4, 5, -1, -1}, {4, 6, -1, -1}, {4, 7, -1, -1}, {4, 8, -1, -1}, {4, 9, -1, -1}, {5, 6, -1, -1}, {5, 7, -1, -1}, {5, 8, -1, -1}, {5, 9, -1, -1}, {6, 7, -1, -1}, {6, 8, -1, -1}, {6, 9, -1, -1}, {7, 8, -1, -1}, {7, 9, -1, -1}, {8, 9, -1, -1}} ; #define NUM_10_4_COMBS 175 diff --git a/test/liberasurecode_test.c b/test/liberasurecode_test.c index 548d070..6291be5 100644 --- a/test/liberasurecode_test.c +++ b/test/liberasurecode_test.c @@ -58,9 +58,9 @@ struct ec_args null_args = { }; struct ec_args flat_xor_hd_args = { - .k = 10, - .m = 6, - .hd = 4, + .k = 3, + .m = 3, + .hd = 3, .ct = CHKSUM_NONE, };