aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/bnx2x_main.c
diff options
context:
space:
mode:
authorEilon Greenstein <eilong@broadcom.com>2009-08-12 04:23:44 -0400
committerDavid S. Miller <davem@davemloft.net>2009-08-13 02:02:53 -0400
commit5ff7b6d4c129a430e355b2f88162a36d9e058f88 (patch)
tree6d7597ea63c1e0d1137b3102fd4d2be5f995cdfb /drivers/net/bnx2x_main.c
parent0d28e49a2616b927bca5fde0f16dfdfd2a501107 (diff)
bnx2x: Remove the init_dmae field from bp
Moved the dmae_command from the heap to the stack. This will save 56 bytes per bnx2x structure. As a side benefit, we can also reduce the time the dmae_mutex is held. This is because do we not need to hold this mutex when setting up the dmae command. The memory where is dmae command is stored is not a shared resource and doesn not need to be protected. Signed-off-by: Benjamin Li <benli@broadcom.com> Signed-off-by: Eilon Greenstein <eilong@broadcom.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/bnx2x_main.c')
-rw-r--r--drivers/net/bnx2x_main.c94
1 files changed, 47 insertions, 47 deletions
diff --git a/drivers/net/bnx2x_main.c b/drivers/net/bnx2x_main.c
index 276d8467b8c1..59aacd84d7e1 100644
--- a/drivers/net/bnx2x_main.c
+++ b/drivers/net/bnx2x_main.c
@@ -203,7 +203,7 @@ static void bnx2x_post_dmae(struct bnx2x *bp, struct dmae_command *dmae,
203void bnx2x_write_dmae(struct bnx2x *bp, dma_addr_t dma_addr, u32 dst_addr, 203void bnx2x_write_dmae(struct bnx2x *bp, dma_addr_t dma_addr, u32 dst_addr,
204 u32 len32) 204 u32 len32)
205{ 205{
206 struct dmae_command *dmae = &bp->init_dmae; 206 struct dmae_command dmae;
207 u32 *wb_comp = bnx2x_sp(bp, wb_comp); 207 u32 *wb_comp = bnx2x_sp(bp, wb_comp);
208 int cnt = 200; 208 int cnt = 200;
209 209
@@ -216,43 +216,43 @@ void bnx2x_write_dmae(struct bnx2x *bp, dma_addr_t dma_addr, u32 dst_addr,
216 return; 216 return;
217 } 217 }
218 218
219 mutex_lock(&bp->dmae_mutex); 219 memset(&dmae, 0, sizeof(struct dmae_command));
220
221 memset(dmae, 0, sizeof(struct dmae_command));
222 220
223 dmae->opcode = (DMAE_CMD_SRC_PCI | DMAE_CMD_DST_GRC | 221 dmae.opcode = (DMAE_CMD_SRC_PCI | DMAE_CMD_DST_GRC |
224 DMAE_CMD_C_DST_PCI | DMAE_CMD_C_ENABLE | 222 DMAE_CMD_C_DST_PCI | DMAE_CMD_C_ENABLE |
225 DMAE_CMD_SRC_RESET | DMAE_CMD_DST_RESET | 223 DMAE_CMD_SRC_RESET | DMAE_CMD_DST_RESET |
226#ifdef __BIG_ENDIAN 224#ifdef __BIG_ENDIAN
227 DMAE_CMD_ENDIANITY_B_DW_SWAP | 225 DMAE_CMD_ENDIANITY_B_DW_SWAP |
228#else 226#else
229 DMAE_CMD_ENDIANITY_DW_SWAP | 227 DMAE_CMD_ENDIANITY_DW_SWAP |
230#endif 228#endif
231 (BP_PORT(bp) ? DMAE_CMD_PORT_1 : DMAE_CMD_PORT_0) | 229 (BP_PORT(bp) ? DMAE_CMD_PORT_1 : DMAE_CMD_PORT_0) |
232 (BP_E1HVN(bp) << DMAE_CMD_E1HVN_SHIFT)); 230 (BP_E1HVN(bp) << DMAE_CMD_E1HVN_SHIFT));
233 dmae->src_addr_lo = U64_LO(dma_addr); 231 dmae.src_addr_lo = U64_LO(dma_addr);
234 dmae->src_addr_hi = U64_HI(dma_addr); 232 dmae.src_addr_hi = U64_HI(dma_addr);
235 dmae->dst_addr_lo = dst_addr >> 2; 233 dmae.dst_addr_lo = dst_addr >> 2;
236 dmae->dst_addr_hi = 0; 234 dmae.dst_addr_hi = 0;
237 dmae->len = len32; 235 dmae.len = len32;
238 dmae->comp_addr_lo = U64_LO(bnx2x_sp_mapping(bp, wb_comp)); 236 dmae.comp_addr_lo = U64_LO(bnx2x_sp_mapping(bp, wb_comp));
239 dmae->comp_addr_hi = U64_HI(bnx2x_sp_mapping(bp, wb_comp)); 237 dmae.comp_addr_hi = U64_HI(bnx2x_sp_mapping(bp, wb_comp));
240 dmae->comp_val = DMAE_COMP_VAL; 238 dmae.comp_val = DMAE_COMP_VAL;
241 239
242 DP(BNX2X_MSG_OFF, "DMAE: opcode 0x%08x\n" 240 DP(BNX2X_MSG_OFF, "DMAE: opcode 0x%08x\n"
243 DP_LEVEL "src_addr [%x:%08x] len [%d *4] " 241 DP_LEVEL "src_addr [%x:%08x] len [%d *4] "
244 "dst_addr [%x:%08x (%08x)]\n" 242 "dst_addr [%x:%08x (%08x)]\n"
245 DP_LEVEL "comp_addr [%x:%08x] comp_val 0x%08x\n", 243 DP_LEVEL "comp_addr [%x:%08x] comp_val 0x%08x\n",
246 dmae->opcode, dmae->src_addr_hi, dmae->src_addr_lo, 244 dmae.opcode, dmae.src_addr_hi, dmae.src_addr_lo,
247 dmae->len, dmae->dst_addr_hi, dmae->dst_addr_lo, dst_addr, 245 dmae.len, dmae.dst_addr_hi, dmae.dst_addr_lo, dst_addr,
248 dmae->comp_addr_hi, dmae->comp_addr_lo, dmae->comp_val); 246 dmae.comp_addr_hi, dmae.comp_addr_lo, dmae.comp_val);
249 DP(BNX2X_MSG_OFF, "data [0x%08x 0x%08x 0x%08x 0x%08x]\n", 247 DP(BNX2X_MSG_OFF, "data [0x%08x 0x%08x 0x%08x 0x%08x]\n",
250 bp->slowpath->wb_data[0], bp->slowpath->wb_data[1], 248 bp->slowpath->wb_data[0], bp->slowpath->wb_data[1],
251 bp->slowpath->wb_data[2], bp->slowpath->wb_data[3]); 249 bp->slowpath->wb_data[2], bp->slowpath->wb_data[3]);
252 250
251 mutex_lock(&bp->dmae_mutex);
252
253 *wb_comp = 0; 253 *wb_comp = 0;
254 254
255 bnx2x_post_dmae(bp, dmae, INIT_DMAE_C(bp)); 255 bnx2x_post_dmae(bp, &dmae, INIT_DMAE_C(bp));
256 256
257 udelay(5); 257 udelay(5);
258 258
@@ -276,7 +276,7 @@ void bnx2x_write_dmae(struct bnx2x *bp, dma_addr_t dma_addr, u32 dst_addr,
276 276
277void bnx2x_read_dmae(struct bnx2x *bp, u32 src_addr, u32 len32) 277void bnx2x_read_dmae(struct bnx2x *bp, u32 src_addr, u32 len32)
278{ 278{
279 struct dmae_command *dmae = &bp->init_dmae; 279 struct dmae_command dmae;
280 u32 *wb_comp = bnx2x_sp(bp, wb_comp); 280 u32 *wb_comp = bnx2x_sp(bp, wb_comp);
281 int cnt = 200; 281 int cnt = 200;
282 282
@@ -291,41 +291,41 @@ void bnx2x_read_dmae(struct bnx2x *bp, u32 src_addr, u32 len32)
291 return; 291 return;
292 } 292 }
293 293
294 mutex_lock(&bp->dmae_mutex); 294 memset(&dmae, 0, sizeof(struct dmae_command));
295
296 memset(bnx2x_sp(bp, wb_data[0]), 0, sizeof(u32) * 4);
297 memset(dmae, 0, sizeof(struct dmae_command));
298 295
299 dmae->opcode = (DMAE_CMD_SRC_GRC | DMAE_CMD_DST_PCI | 296 dmae.opcode = (DMAE_CMD_SRC_GRC | DMAE_CMD_DST_PCI |
300 DMAE_CMD_C_DST_PCI | DMAE_CMD_C_ENABLE | 297 DMAE_CMD_C_DST_PCI | DMAE_CMD_C_ENABLE |
301 DMAE_CMD_SRC_RESET | DMAE_CMD_DST_RESET | 298 DMAE_CMD_SRC_RESET | DMAE_CMD_DST_RESET |
302#ifdef __BIG_ENDIAN 299#ifdef __BIG_ENDIAN
303 DMAE_CMD_ENDIANITY_B_DW_SWAP | 300 DMAE_CMD_ENDIANITY_B_DW_SWAP |
304#else 301#else
305 DMAE_CMD_ENDIANITY_DW_SWAP | 302 DMAE_CMD_ENDIANITY_DW_SWAP |
306#endif 303#endif
307 (BP_PORT(bp) ? DMAE_CMD_PORT_1 : DMAE_CMD_PORT_0) | 304 (BP_PORT(bp) ? DMAE_CMD_PORT_1 : DMAE_CMD_PORT_0) |
308 (BP_E1HVN(bp) << DMAE_CMD_E1HVN_SHIFT)); 305 (BP_E1HVN(bp) << DMAE_CMD_E1HVN_SHIFT));
309 dmae->src_addr_lo = src_addr >> 2; 306 dmae.src_addr_lo = src_addr >> 2;
310 dmae->src_addr_hi = 0; 307 dmae.src_addr_hi = 0;
311 dmae->dst_addr_lo = U64_LO(bnx2x_sp_mapping(bp, wb_data)); 308 dmae.dst_addr_lo = U64_LO(bnx2x_sp_mapping(bp, wb_data));
312 dmae->dst_addr_hi = U64_HI(bnx2x_sp_mapping(bp, wb_data)); 309 dmae.dst_addr_hi = U64_HI(bnx2x_sp_mapping(bp, wb_data));
313 dmae->len = len32; 310 dmae.len = len32;
314 dmae->comp_addr_lo = U64_LO(bnx2x_sp_mapping(bp, wb_comp)); 311 dmae.comp_addr_lo = U64_LO(bnx2x_sp_mapping(bp, wb_comp));
315 dmae->comp_addr_hi = U64_HI(bnx2x_sp_mapping(bp, wb_comp)); 312 dmae.comp_addr_hi = U64_HI(bnx2x_sp_mapping(bp, wb_comp));
316 dmae->comp_val = DMAE_COMP_VAL; 313 dmae.comp_val = DMAE_COMP_VAL;
317 314
318 DP(BNX2X_MSG_OFF, "DMAE: opcode 0x%08x\n" 315 DP(BNX2X_MSG_OFF, "DMAE: opcode 0x%08x\n"
319 DP_LEVEL "src_addr [%x:%08x] len [%d *4] " 316 DP_LEVEL "src_addr [%x:%08x] len [%d *4] "
320 "dst_addr [%x:%08x (%08x)]\n" 317 "dst_addr [%x:%08x (%08x)]\n"
321 DP_LEVEL "comp_addr [%x:%08x] comp_val 0x%08x\n", 318 DP_LEVEL "comp_addr [%x:%08x] comp_val 0x%08x\n",
322 dmae->opcode, dmae->src_addr_hi, dmae->src_addr_lo, 319 dmae.opcode, dmae.src_addr_hi, dmae.src_addr_lo,
323 dmae->len, dmae->dst_addr_hi, dmae->dst_addr_lo, src_addr, 320 dmae.len, dmae.dst_addr_hi, dmae.dst_addr_lo, src_addr,
324 dmae->comp_addr_hi, dmae->comp_addr_lo, dmae->comp_val); 321 dmae.comp_addr_hi, dmae.comp_addr_lo, dmae.comp_val);
325 322
323 mutex_lock(&bp->dmae_mutex);
324
325 memset(bnx2x_sp(bp, wb_data[0]), 0, sizeof(u32) * 4);
326 *wb_comp = 0; 326 *wb_comp = 0;
327 327
328 bnx2x_post_dmae(bp, dmae, INIT_DMAE_C(bp)); 328 bnx2x_post_dmae(bp, &dmae, INIT_DMAE_C(bp));
329 329
330 udelay(5); 330 udelay(5);
331 331