aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/bnx2.c
diff options
context:
space:
mode:
authorBenjamin Li <benli@broadcom.com>2008-05-17 01:20:27 -0400
committerDavid S. Miller <davem@davemloft.net>2008-05-17 01:20:27 -0400
commit10343cca2bad3f9fdad214385bed0a9aadf4ffd4 (patch)
treedf91bca59ccc1316b918935c348e8bcb840ba121 /drivers/net/bnx2.c
parent601d3d18b2c1e4c197aa3cd902fb77bd99c41f10 (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>
Diffstat (limited to 'drivers/net/bnx2.c')
-rw-r--r--drivers/net/bnx2.c78
1 files changed, 6 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
3221static int 3221static int
3222load_cpu_fw(struct bnx2 *bp, struct cpu_reg *cpu_reg, struct fw_info *fw) 3222load_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)
3303static int 3303static int
3304bnx2_init_cpus(struct bnx2 *bp) 3304bnx2_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
3459init_cpu_err: 3393init_cpu_err:
3460 vfree(text); 3394 vfree(text);