aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/netxen/netxen_nic.h
diff options
context:
space:
mode:
authorDhananjay Phadke <dhananjay@netxen.com>2007-12-31 13:08:57 -0500
committerJeff Garzik <jeff@garzik.org>2008-01-12 17:35:38 -0500
commit5dc162682d4901025a02b7045f3112d569b4bab9 (patch)
tree410daa76d45f3f7aee13eb0750b890a9ba8ad49f /drivers/net/netxen/netxen_nic.h
parent53a01e00f8c78bc5875e09aca7749ea54bb09798 (diff)
netxen: fix byte-swapping in tx and rx
Here's the reworked patch. This cleans up some unnecessary byte-swapping while setting up tx and interpreting rx desc. The 64 bit rx status data should be converted to host endian format only once and the macros just need to extract bitfields. This saves a spate of interrupts on pseries blades caused by buggy (non) processing rx status ring. Signed-off-by: Dhananjay Phadke <dhananjay@netxen.com> Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/net/netxen/netxen_nic.h')
-rw-r--r--drivers/net/netxen/netxen_nic.h65
1 files changed, 34 insertions, 31 deletions
diff --git a/drivers/net/netxen/netxen_nic.h b/drivers/net/netxen/netxen_nic.h
index 2cefd8b43ac4..a8f63c47b3cd 100644
--- a/drivers/net/netxen/netxen_nic.h
+++ b/drivers/net/netxen/netxen_nic.h
@@ -309,23 +309,26 @@ struct netxen_ring_ctx {
309 ((cmd_desc)->port_ctxid |= ((var) & 0xF0)) 309 ((cmd_desc)->port_ctxid |= ((var) & 0xF0))
310 310
311#define netxen_set_cmd_desc_flags(cmd_desc, val) \ 311#define netxen_set_cmd_desc_flags(cmd_desc, val) \
312 ((cmd_desc)->flags_opcode &= ~cpu_to_le16(0x7f), \ 312 (cmd_desc)->flags_opcode = ((cmd_desc)->flags_opcode & \
313 (cmd_desc)->flags_opcode |= cpu_to_le16((val) & 0x7f)) 313 ~cpu_to_le16(0x7f)) | cpu_to_le16((val) & 0x7f)
314#define netxen_set_cmd_desc_opcode(cmd_desc, val) \ 314#define netxen_set_cmd_desc_opcode(cmd_desc, val) \
315 ((cmd_desc)->flags_opcode &= ~cpu_to_le16(0x3f<<7), \ 315 (cmd_desc)->flags_opcode = ((cmd_desc)->flags_opcode & \
316 (cmd_desc)->flags_opcode |= cpu_to_le16(((val & 0x3f)<<7))) 316 ~cpu_to_le16((u16)0x3f << 7)) | cpu_to_le16(((val) & 0x3f) << 7)
317 317
318#define netxen_set_cmd_desc_num_of_buff(cmd_desc, val) \ 318#define netxen_set_cmd_desc_num_of_buff(cmd_desc, val) \
319 ((cmd_desc)->num_of_buffers_total_length &= ~cpu_to_le32(0xff), \ 319 (cmd_desc)->num_of_buffers_total_length = \
320 (cmd_desc)->num_of_buffers_total_length |= cpu_to_le32((val) & 0xff)) 320 ((cmd_desc)->num_of_buffers_total_length & \
321 ~cpu_to_le32(0xff)) | cpu_to_le32((val) & 0xff)
321#define netxen_set_cmd_desc_totallength(cmd_desc, val) \ 322#define netxen_set_cmd_desc_totallength(cmd_desc, val) \
322 ((cmd_desc)->num_of_buffers_total_length &= ~cpu_to_le32(0xffffff00), \ 323 (cmd_desc)->num_of_buffers_total_length = \
323 (cmd_desc)->num_of_buffers_total_length |= cpu_to_le32(val << 8)) 324 ((cmd_desc)->num_of_buffers_total_length & \
325 ~cpu_to_le32((u32)0xffffff << 8)) | \
326 cpu_to_le32(((val) & 0xffffff) << 8)
324 327
325#define netxen_get_cmd_desc_opcode(cmd_desc) \ 328#define netxen_get_cmd_desc_opcode(cmd_desc) \
326 ((le16_to_cpu((cmd_desc)->flags_opcode) >> 7) & 0x003F) 329 ((le16_to_cpu((cmd_desc)->flags_opcode) >> 7) & 0x003f)
327#define netxen_get_cmd_desc_totallength(cmd_desc) \ 330#define netxen_get_cmd_desc_totallength(cmd_desc) \
328 (le32_to_cpu((cmd_desc)->num_of_buffers_total_length) >> 8) 331 ((le32_to_cpu((cmd_desc)->num_of_buffers_total_length) >> 8) & 0xffffff)
329 332
330struct cmd_desc_type0 { 333struct cmd_desc_type0 {
331 u8 tcp_hdr_offset; /* For LSO only */ 334 u8 tcp_hdr_offset; /* For LSO only */
@@ -412,29 +415,29 @@ struct rcv_desc {
412#define netxen_get_sts_desc_lro_last_frag(status_desc) \ 415#define netxen_get_sts_desc_lro_last_frag(status_desc) \
413 (((status_desc)->lro & 0x80) >> 7) 416 (((status_desc)->lro & 0x80) >> 7)
414 417
415#define netxen_get_sts_port(status_desc) \ 418#define netxen_get_sts_port(sts_data) \
416 (le64_to_cpu((status_desc)->status_desc_data) & 0x0F) 419 ((sts_data) & 0x0F)
417#define netxen_get_sts_status(status_desc) \ 420#define netxen_get_sts_status(sts_data) \
418 ((le64_to_cpu((status_desc)->status_desc_data) >> 4) & 0x0F) 421 (((sts_data) >> 4) & 0x0F)
419#define netxen_get_sts_type(status_desc) \ 422#define netxen_get_sts_type(sts_data) \
420 ((le64_to_cpu((status_desc)->status_desc_data) >> 8) & 0x0F) 423 (((sts_data) >> 8) & 0x0F)
421#define netxen_get_sts_totallength(status_desc) \ 424#define netxen_get_sts_totallength(sts_data) \
422 ((le64_to_cpu((status_desc)->status_desc_data) >> 12) & 0xFFFF) 425 (((sts_data) >> 12) & 0xFFFF)
423#define netxen_get_sts_refhandle(status_desc) \ 426#define netxen_get_sts_refhandle(sts_data) \
424 ((le64_to_cpu((status_desc)->status_desc_data) >> 28) & 0xFFFF) 427 (((sts_data) >> 28) & 0xFFFF)
425#define netxen_get_sts_prot(status_desc) \ 428#define netxen_get_sts_prot(sts_data) \
426 ((le64_to_cpu((status_desc)->status_desc_data) >> 44) & 0x0F) 429 (((sts_data) >> 44) & 0x0F)
430#define netxen_get_sts_opcode(sts_data) \
431 (((sts_data) >> 58) & 0x03F)
432
427#define netxen_get_sts_owner(status_desc) \ 433#define netxen_get_sts_owner(status_desc) \
428 ((le64_to_cpu((status_desc)->status_desc_data) >> 56) & 0x03) 434 ((le64_to_cpu((status_desc)->status_desc_data) >> 56) & 0x03)
429#define netxen_get_sts_opcode(status_desc) \ 435#define netxen_set_sts_owner(status_desc, val) { \
430 ((le64_to_cpu((status_desc)->status_desc_data) >> 58) & 0x03F) 436 (status_desc)->status_desc_data = \
431 437 ((status_desc)->status_desc_data & \
432#define netxen_clear_sts_owner(status_desc) \ 438 ~cpu_to_le64(0x3ULL << 56)) | \
433 ((status_desc)->status_desc_data &= \ 439 cpu_to_le64((u64)((val) & 0x3) << 56); \
434 ~cpu_to_le64(((unsigned long long)3) << 56 )) 440}
435#define netxen_set_sts_owner(status_desc, val) \
436 ((status_desc)->status_desc_data |= \
437 cpu_to_le64(((unsigned long long)((val) & 0x3)) << 56 ))
438 441
439struct status_desc { 442struct status_desc {
440 /* Bit pattern: 0-3 port, 4-7 status, 8-11 type, 12-27 total_length 443 /* Bit pattern: 0-3 port, 4-7 status, 8-11 type, 12-27 total_length