diff options
author | Benjamin Li <benli@broadcom.com> | 2008-05-17 01:20:27 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-05-17 01:20:27 -0400 |
commit | 10343cca2bad3f9fdad214385bed0a9aadf4ffd4 (patch) | |
tree | df91bca59ccc1316b918935c348e8bcb840ba121 | |
parent | 601d3d18b2c1e4c197aa3cd902fb77bd99c41f10 (diff) |
bnx2: Pre-initialize struct cpu_reg.
Instead of assigning values for the struct cpu_reg's at runtime,
we already know these values at compile time. Therefore, we can use
designated initializers, to initialize these structures and not have
to incur this assignment cost at run-time.
Signed-off-by: Benjamin Li <benli@broadcom.com>
Signed-off-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/bnx2.c | 78 | ||||
-rw-r--r-- | drivers/net/bnx2_fw.h | 80 |
2 files changed, 86 insertions, 72 deletions
diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c index 1534eed4c35a..e1787a1e1e73 100644 --- a/drivers/net/bnx2.c +++ b/drivers/net/bnx2.c | |||
@@ -3219,7 +3219,7 @@ load_rv2p_fw(struct bnx2 *bp, __le32 *rv2p_code, u32 rv2p_code_len, | |||
3219 | } | 3219 | } |
3220 | 3220 | ||
3221 | static int | 3221 | static int |
3222 | load_cpu_fw(struct bnx2 *bp, struct cpu_reg *cpu_reg, struct fw_info *fw) | 3222 | load_cpu_fw(struct bnx2 *bp, const struct cpu_reg *cpu_reg, struct fw_info *fw) |
3223 | { | 3223 | { |
3224 | u32 offset; | 3224 | u32 offset; |
3225 | u32 val; | 3225 | u32 val; |
@@ -3303,7 +3303,6 @@ load_cpu_fw(struct bnx2 *bp, struct cpu_reg *cpu_reg, struct fw_info *fw) | |||
3303 | static int | 3303 | static int |
3304 | bnx2_init_cpus(struct bnx2 *bp) | 3304 | bnx2_init_cpus(struct bnx2 *bp) |
3305 | { | 3305 | { |
3306 | struct cpu_reg cpu_reg; | ||
3307 | struct fw_info *fw; | 3306 | struct fw_info *fw; |
3308 | int rc, rv2p_len; | 3307 | int rc, rv2p_len; |
3309 | void *text, *rv2p; | 3308 | void *text, *rv2p; |
@@ -3339,122 +3338,57 @@ bnx2_init_cpus(struct bnx2 *bp) | |||
3339 | load_rv2p_fw(bp, text, rc /* == len */, RV2P_PROC2); | 3338 | load_rv2p_fw(bp, text, rc /* == len */, RV2P_PROC2); |
3340 | 3339 | ||
3341 | /* Initialize the RX Processor. */ | 3340 | /* Initialize the RX Processor. */ |
3342 | cpu_reg.mode = BNX2_RXP_CPU_MODE; | ||
3343 | cpu_reg.mode_value_halt = BNX2_RXP_CPU_MODE_SOFT_HALT; | ||
3344 | cpu_reg.mode_value_sstep = BNX2_RXP_CPU_MODE_STEP_ENA; | ||
3345 | cpu_reg.state = BNX2_RXP_CPU_STATE; | ||
3346 | cpu_reg.state_value_clear = 0xffffff; | ||
3347 | cpu_reg.gpr0 = BNX2_RXP_CPU_REG_FILE; | ||
3348 | cpu_reg.evmask = BNX2_RXP_CPU_EVENT_MASK; | ||
3349 | cpu_reg.pc = BNX2_RXP_CPU_PROGRAM_COUNTER; | ||
3350 | cpu_reg.inst = BNX2_RXP_CPU_INSTRUCTION; | ||
3351 | cpu_reg.bp = BNX2_RXP_CPU_HW_BREAKPOINT; | ||
3352 | cpu_reg.spad_base = BNX2_RXP_SCRATCH; | ||
3353 | cpu_reg.mips_view_base = 0x8000000; | ||
3354 | |||
3355 | if (CHIP_NUM(bp) == CHIP_NUM_5709) | 3341 | if (CHIP_NUM(bp) == CHIP_NUM_5709) |
3356 | fw = &bnx2_rxp_fw_09; | 3342 | fw = &bnx2_rxp_fw_09; |
3357 | else | 3343 | else |
3358 | fw = &bnx2_rxp_fw_06; | 3344 | fw = &bnx2_rxp_fw_06; |
3359 | 3345 | ||
3360 | fw->text = text; | 3346 | fw->text = text; |
3361 | rc = load_cpu_fw(bp, &cpu_reg, fw); | 3347 | rc = load_cpu_fw(bp, &cpu_reg_rxp, fw); |
3362 | if (rc) | 3348 | if (rc) |
3363 | goto init_cpu_err; | 3349 | goto init_cpu_err; |
3364 | 3350 | ||
3365 | /* Initialize the TX Processor. */ | 3351 | /* Initialize the TX Processor. */ |
3366 | cpu_reg.mode = BNX2_TXP_CPU_MODE; | ||
3367 | cpu_reg.mode_value_halt = BNX2_TXP_CPU_MODE_SOFT_HALT; | ||
3368 | cpu_reg.mode_value_sstep = BNX2_TXP_CPU_MODE_STEP_ENA; | ||
3369 | cpu_reg.state = BNX2_TXP_CPU_STATE; | ||
3370 | cpu_reg.state_value_clear = 0xffffff; | ||
3371 | cpu_reg.gpr0 = BNX2_TXP_CPU_REG_FILE; | ||
3372 | cpu_reg.evmask = BNX2_TXP_CPU_EVENT_MASK; | ||
3373 | cpu_reg.pc = BNX2_TXP_CPU_PROGRAM_COUNTER; | ||
3374 | cpu_reg.inst = BNX2_TXP_CPU_INSTRUCTION; | ||
3375 | cpu_reg.bp = BNX2_TXP_CPU_HW_BREAKPOINT; | ||
3376 | cpu_reg.spad_base = BNX2_TXP_SCRATCH; | ||
3377 | cpu_reg.mips_view_base = 0x8000000; | ||
3378 | |||
3379 | if (CHIP_NUM(bp) == CHIP_NUM_5709) | 3352 | if (CHIP_NUM(bp) == CHIP_NUM_5709) |
3380 | fw = &bnx2_txp_fw_09; | 3353 | fw = &bnx2_txp_fw_09; |
3381 | else | 3354 | else |
3382 | fw = &bnx2_txp_fw_06; | 3355 | fw = &bnx2_txp_fw_06; |
3383 | 3356 | ||
3384 | fw->text = text; | 3357 | fw->text = text; |
3385 | rc = load_cpu_fw(bp, &cpu_reg, fw); | 3358 | rc = load_cpu_fw(bp, &cpu_reg_txp, fw); |
3386 | if (rc) | 3359 | if (rc) |
3387 | goto init_cpu_err; | 3360 | goto init_cpu_err; |
3388 | 3361 | ||
3389 | /* Initialize the TX Patch-up Processor. */ | 3362 | /* Initialize the TX Patch-up Processor. */ |
3390 | cpu_reg.mode = BNX2_TPAT_CPU_MODE; | ||
3391 | cpu_reg.mode_value_halt = BNX2_TPAT_CPU_MODE_SOFT_HALT; | ||
3392 | cpu_reg.mode_value_sstep = BNX2_TPAT_CPU_MODE_STEP_ENA; | ||
3393 | cpu_reg.state = BNX2_TPAT_CPU_STATE; | ||
3394 | cpu_reg.state_value_clear = 0xffffff; | ||
3395 | cpu_reg.gpr0 = BNX2_TPAT_CPU_REG_FILE; | ||
3396 | cpu_reg.evmask = BNX2_TPAT_CPU_EVENT_MASK; | ||
3397 | cpu_reg.pc = BNX2_TPAT_CPU_PROGRAM_COUNTER; | ||
3398 | cpu_reg.inst = BNX2_TPAT_CPU_INSTRUCTION; | ||
3399 | cpu_reg.bp = BNX2_TPAT_CPU_HW_BREAKPOINT; | ||
3400 | cpu_reg.spad_base = BNX2_TPAT_SCRATCH; | ||
3401 | cpu_reg.mips_view_base = 0x8000000; | ||
3402 | |||
3403 | if (CHIP_NUM(bp) == CHIP_NUM_5709) | 3363 | if (CHIP_NUM(bp) == CHIP_NUM_5709) |
3404 | fw = &bnx2_tpat_fw_09; | 3364 | fw = &bnx2_tpat_fw_09; |
3405 | else | 3365 | else |
3406 | fw = &bnx2_tpat_fw_06; | 3366 | fw = &bnx2_tpat_fw_06; |
3407 | 3367 | ||
3408 | fw->text = text; | 3368 | fw->text = text; |
3409 | rc = load_cpu_fw(bp, &cpu_reg, fw); | 3369 | rc = load_cpu_fw(bp, &cpu_reg_tpat, fw); |
3410 | if (rc) | 3370 | if (rc) |
3411 | goto init_cpu_err; | 3371 | goto init_cpu_err; |
3412 | 3372 | ||
3413 | /* Initialize the Completion Processor. */ | 3373 | /* Initialize the Completion Processor. */ |
3414 | cpu_reg.mode = BNX2_COM_CPU_MODE; | ||
3415 | cpu_reg.mode_value_halt = BNX2_COM_CPU_MODE_SOFT_HALT; | ||
3416 | cpu_reg.mode_value_sstep = BNX2_COM_CPU_MODE_STEP_ENA; | ||
3417 | cpu_reg.state = BNX2_COM_CPU_STATE; | ||
3418 | cpu_reg.state_value_clear = 0xffffff; | ||
3419 | cpu_reg.gpr0 = BNX2_COM_CPU_REG_FILE; | ||
3420 | cpu_reg.evmask = BNX2_COM_CPU_EVENT_MASK; | ||
3421 | cpu_reg.pc = BNX2_COM_CPU_PROGRAM_COUNTER; | ||
3422 | cpu_reg.inst = BNX2_COM_CPU_INSTRUCTION; | ||
3423 | cpu_reg.bp = BNX2_COM_CPU_HW_BREAKPOINT; | ||
3424 | cpu_reg.spad_base = BNX2_COM_SCRATCH; | ||
3425 | cpu_reg.mips_view_base = 0x8000000; | ||
3426 | |||
3427 | if (CHIP_NUM(bp) == CHIP_NUM_5709) | 3374 | if (CHIP_NUM(bp) == CHIP_NUM_5709) |
3428 | fw = &bnx2_com_fw_09; | 3375 | fw = &bnx2_com_fw_09; |
3429 | else | 3376 | else |
3430 | fw = &bnx2_com_fw_06; | 3377 | fw = &bnx2_com_fw_06; |
3431 | 3378 | ||
3432 | fw->text = text; | 3379 | fw->text = text; |
3433 | rc = load_cpu_fw(bp, &cpu_reg, fw); | 3380 | rc = load_cpu_fw(bp, &cpu_reg_com, fw); |
3434 | if (rc) | 3381 | if (rc) |
3435 | goto init_cpu_err; | 3382 | goto init_cpu_err; |
3436 | 3383 | ||
3437 | /* Initialize the Command Processor. */ | 3384 | /* Initialize the Command Processor. */ |
3438 | cpu_reg.mode = BNX2_CP_CPU_MODE; | ||
3439 | cpu_reg.mode_value_halt = BNX2_CP_CPU_MODE_SOFT_HALT; | ||
3440 | cpu_reg.mode_value_sstep = BNX2_CP_CPU_MODE_STEP_ENA; | ||
3441 | cpu_reg.state = BNX2_CP_CPU_STATE; | ||
3442 | cpu_reg.state_value_clear = 0xffffff; | ||
3443 | cpu_reg.gpr0 = BNX2_CP_CPU_REG_FILE; | ||
3444 | cpu_reg.evmask = BNX2_CP_CPU_EVENT_MASK; | ||
3445 | cpu_reg.pc = BNX2_CP_CPU_PROGRAM_COUNTER; | ||
3446 | cpu_reg.inst = BNX2_CP_CPU_INSTRUCTION; | ||
3447 | cpu_reg.bp = BNX2_CP_CPU_HW_BREAKPOINT; | ||
3448 | cpu_reg.spad_base = BNX2_CP_SCRATCH; | ||
3449 | cpu_reg.mips_view_base = 0x8000000; | ||
3450 | |||
3451 | if (CHIP_NUM(bp) == CHIP_NUM_5709) | 3385 | if (CHIP_NUM(bp) == CHIP_NUM_5709) |
3452 | fw = &bnx2_cp_fw_09; | 3386 | fw = &bnx2_cp_fw_09; |
3453 | else | 3387 | else |
3454 | fw = &bnx2_cp_fw_06; | 3388 | fw = &bnx2_cp_fw_06; |
3455 | 3389 | ||
3456 | fw->text = text; | 3390 | fw->text = text; |
3457 | rc = load_cpu_fw(bp, &cpu_reg, fw); | 3391 | rc = load_cpu_fw(bp, &cpu_reg_cp, fw); |
3458 | 3392 | ||
3459 | init_cpu_err: | 3393 | init_cpu_err: |
3460 | vfree(text); | 3394 | vfree(text); |
diff --git a/drivers/net/bnx2_fw.h b/drivers/net/bnx2_fw.h index 3b839d4626fe..e4b1de435567 100644 --- a/drivers/net/bnx2_fw.h +++ b/drivers/net/bnx2_fw.h | |||
@@ -886,6 +886,23 @@ static struct fw_info bnx2_com_fw_06 = { | |||
886 | .rodata = bnx2_COM_b06FwRodata, | 886 | .rodata = bnx2_COM_b06FwRodata, |
887 | }; | 887 | }; |
888 | 888 | ||
889 | /* Initialized Values for the Completion Processor. */ | ||
890 | static const struct cpu_reg cpu_reg_com = { | ||
891 | .mode = BNX2_COM_CPU_MODE, | ||
892 | .mode_value_halt = BNX2_COM_CPU_MODE_SOFT_HALT, | ||
893 | .mode_value_sstep = BNX2_COM_CPU_MODE_STEP_ENA, | ||
894 | .state = BNX2_COM_CPU_STATE, | ||
895 | .state_value_clear = 0xffffff, | ||
896 | .gpr0 = BNX2_COM_CPU_REG_FILE, | ||
897 | .evmask = BNX2_COM_CPU_EVENT_MASK, | ||
898 | .pc = BNX2_COM_CPU_PROGRAM_COUNTER, | ||
899 | .inst = BNX2_COM_CPU_INSTRUCTION, | ||
900 | .bp = BNX2_COM_CPU_HW_BREAKPOINT, | ||
901 | .spad_base = BNX2_COM_SCRATCH, | ||
902 | .mips_view_base = 0x8000000, | ||
903 | }; | ||
904 | |||
905 | |||
889 | static u8 bnx2_CP_b06FwText[] = { | 906 | static u8 bnx2_CP_b06FwText[] = { |
890 | 0x9d, 0xbc, 0x0d, 0x78, 0x13, 0xe7, 0x99, 0x2e, 0x7c, 0xcf, 0x48, 0xb2, | 907 | 0x9d, 0xbc, 0x0d, 0x78, 0x13, 0xe7, 0x99, 0x2e, 0x7c, 0xcf, 0x48, 0xb2, |
891 | 0x65, 0x5b, 0xb6, 0xc7, 0xb6, 0x0c, 0x22, 0x65, 0x41, 0x83, 0x47, 0x20, | 908 | 0x65, 0x5b, 0xb6, 0xc7, 0xb6, 0x0c, 0x22, 0x65, 0x41, 0x83, 0x47, 0x20, |
@@ -2167,6 +2184,22 @@ static struct fw_info bnx2_cp_fw_06 = { | |||
2167 | .rodata = bnx2_CP_b06FwRodata, | 2184 | .rodata = bnx2_CP_b06FwRodata, |
2168 | }; | 2185 | }; |
2169 | 2186 | ||
2187 | /* Initialized Values the Command Processor. */ | ||
2188 | static const struct cpu_reg cpu_reg_cp = { | ||
2189 | .mode = BNX2_CP_CPU_MODE, | ||
2190 | .mode_value_halt = BNX2_CP_CPU_MODE_SOFT_HALT, | ||
2191 | .mode_value_sstep = BNX2_CP_CPU_MODE_STEP_ENA, | ||
2192 | .state = BNX2_CP_CPU_STATE, | ||
2193 | .state_value_clear = 0xffffff, | ||
2194 | .gpr0 = BNX2_CP_CPU_REG_FILE, | ||
2195 | .evmask = BNX2_CP_CPU_EVENT_MASK, | ||
2196 | .pc = BNX2_CP_CPU_PROGRAM_COUNTER, | ||
2197 | .inst = BNX2_CP_CPU_INSTRUCTION, | ||
2198 | .bp = BNX2_CP_CPU_HW_BREAKPOINT, | ||
2199 | .spad_base = BNX2_CP_SCRATCH, | ||
2200 | .mips_view_base = 0x8000000, | ||
2201 | }; | ||
2202 | |||
2170 | static u8 bnx2_RXP_b06FwText[] = { | 2203 | static u8 bnx2_RXP_b06FwText[] = { |
2171 | 0xec, 0x5b, 0x5d, 0x70, 0x5c, 0xd7, 0x5d, 0xff, 0xdf, 0xb3, 0x2b, 0x69, | 2204 | 0xec, 0x5b, 0x5d, 0x70, 0x5c, 0xd7, 0x5d, 0xff, 0xdf, 0xb3, 0x2b, 0x69, |
2172 | 0x2d, 0x4b, 0xf2, 0x95, 0xbc, 0x71, 0x56, 0xa9, 0x92, 0xec, 0x5a, 0x57, | 2205 | 0x2d, 0x4b, 0xf2, 0x95, 0xbc, 0x71, 0x56, 0xa9, 0x92, 0xec, 0x5a, 0x57, |
@@ -2946,6 +2979,22 @@ static struct fw_info bnx2_rxp_fw_06 = { | |||
2946 | .rodata = bnx2_RXP_b06FwRodata, | 2979 | .rodata = bnx2_RXP_b06FwRodata, |
2947 | }; | 2980 | }; |
2948 | 2981 | ||
2982 | /* Initialized Values for the RX Processor. */ | ||
2983 | static const struct cpu_reg cpu_reg_rxp = { | ||
2984 | .mode = BNX2_RXP_CPU_MODE, | ||
2985 | .mode_value_halt = BNX2_RXP_CPU_MODE_SOFT_HALT, | ||
2986 | .mode_value_sstep = BNX2_RXP_CPU_MODE_STEP_ENA, | ||
2987 | .state = BNX2_RXP_CPU_STATE, | ||
2988 | .state_value_clear = 0xffffff, | ||
2989 | .gpr0 = BNX2_RXP_CPU_REG_FILE, | ||
2990 | .evmask = BNX2_RXP_CPU_EVENT_MASK, | ||
2991 | .pc = BNX2_RXP_CPU_PROGRAM_COUNTER, | ||
2992 | .inst = BNX2_RXP_CPU_INSTRUCTION, | ||
2993 | .bp = BNX2_RXP_CPU_HW_BREAKPOINT, | ||
2994 | .spad_base = BNX2_RXP_SCRATCH, | ||
2995 | .mips_view_base = 0x8000000, | ||
2996 | }; | ||
2997 | |||
2949 | static u8 bnx2_rv2p_proc1[] = { | 2998 | static u8 bnx2_rv2p_proc1[] = { |
2950 | /* Date: 12/07/2007 15:02 */ | 2999 | /* Date: 12/07/2007 15:02 */ |
2951 | 0xd5, 0x56, 0x41, 0x6b, 0x13, 0x51, 0x10, 0x9e, 0xdd, 0x6c, 0xbb, 0xdb, | 3000 | 0xd5, 0x56, 0x41, 0x6b, 0x13, 0x51, 0x10, 0x9e, 0xdd, 0x6c, 0xbb, 0xdb, |
@@ -3651,6 +3700,22 @@ static struct fw_info bnx2_tpat_fw_06 = { | |||
3651 | .rodata = bnx2_TPAT_b06FwRodata, | 3700 | .rodata = bnx2_TPAT_b06FwRodata, |
3652 | }; | 3701 | }; |
3653 | 3702 | ||
3703 | /* Initialized Values for the TX Patch-up Processor. */ | ||
3704 | static const struct cpu_reg cpu_reg_tpat = { | ||
3705 | .mode = BNX2_TPAT_CPU_MODE, | ||
3706 | .mode_value_halt = BNX2_TPAT_CPU_MODE_SOFT_HALT, | ||
3707 | .mode_value_sstep = BNX2_TPAT_CPU_MODE_STEP_ENA, | ||
3708 | .state = BNX2_TPAT_CPU_STATE, | ||
3709 | .state_value_clear = 0xffffff, | ||
3710 | .gpr0 = BNX2_TPAT_CPU_REG_FILE, | ||
3711 | .evmask = BNX2_TPAT_CPU_EVENT_MASK, | ||
3712 | .pc = BNX2_TPAT_CPU_PROGRAM_COUNTER, | ||
3713 | .inst = BNX2_TPAT_CPU_INSTRUCTION, | ||
3714 | .bp = BNX2_TPAT_CPU_HW_BREAKPOINT, | ||
3715 | .spad_base = BNX2_TPAT_SCRATCH, | ||
3716 | .mips_view_base = 0x8000000, | ||
3717 | }; | ||
3718 | |||
3654 | static u8 bnx2_TXP_b06FwText[] = { | 3719 | static u8 bnx2_TXP_b06FwText[] = { |
3655 | 0xad, 0x7b, 0x7f, 0x70, 0x9b, 0x75, 0x7a, 0xe7, 0xe7, 0xd5, 0x0f, 0x5b, | 3720 | 0xad, 0x7b, 0x7f, 0x70, 0x9b, 0x75, 0x7a, 0xe7, 0xe7, 0xd5, 0x0f, 0x5b, |
3656 | 0xb2, 0x65, 0x59, 0x0e, 0x4a, 0x90, 0x77, 0xbd, 0x8d, 0x5e, 0xf4, 0xca, | 3721 | 0xb2, 0x65, 0x59, 0x0e, 0x4a, 0x90, 0x77, 0xbd, 0x8d, 0x5e, 0xf4, 0xca, |
@@ -4531,3 +4596,18 @@ static struct fw_info bnx2_txp_fw_06 = { | |||
4531 | .rodata = bnx2_TXP_b06FwRodata, | 4596 | .rodata = bnx2_TXP_b06FwRodata, |
4532 | }; | 4597 | }; |
4533 | 4598 | ||
4599 | /* Initialized Values for the TX Processor. */ | ||
4600 | static const struct cpu_reg cpu_reg_txp = { | ||
4601 | .mode = BNX2_TXP_CPU_MODE, | ||
4602 | .mode_value_halt = BNX2_TXP_CPU_MODE_SOFT_HALT, | ||
4603 | .mode_value_sstep = BNX2_TXP_CPU_MODE_STEP_ENA, | ||
4604 | .state = BNX2_TXP_CPU_STATE, | ||
4605 | .state_value_clear = 0xffffff, | ||
4606 | .gpr0 = BNX2_TXP_CPU_REG_FILE, | ||
4607 | .evmask = BNX2_TXP_CPU_EVENT_MASK, | ||
4608 | .pc = BNX2_TXP_CPU_PROGRAM_COUNTER, | ||
4609 | .inst = BNX2_TXP_CPU_INSTRUCTION, | ||
4610 | .bp = BNX2_TXP_CPU_HW_BREAKPOINT, | ||
4611 | .spad_base = BNX2_TXP_SCRATCH, | ||
4612 | .mips_view_base = 0x8000000, | ||
4613 | }; | ||