Commit 5dc16268 authored by Dhananjay Phadke's avatar Dhananjay Phadke Committed by Jeff Garzik

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: default avatarDhananjay Phadke <dhananjay@netxen.com>
Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
parent 53a01e00
...@@ -309,23 +309,26 @@ struct netxen_ring_ctx { ...@@ -309,23 +309,26 @@ struct netxen_ring_ctx {
((cmd_desc)->port_ctxid |= ((var) & 0xF0)) ((cmd_desc)->port_ctxid |= ((var) & 0xF0))
#define netxen_set_cmd_desc_flags(cmd_desc, val) \ #define netxen_set_cmd_desc_flags(cmd_desc, val) \
((cmd_desc)->flags_opcode &= ~cpu_to_le16(0x7f), \ (cmd_desc)->flags_opcode = ((cmd_desc)->flags_opcode & \
(cmd_desc)->flags_opcode |= cpu_to_le16((val) & 0x7f)) ~cpu_to_le16(0x7f)) | cpu_to_le16((val) & 0x7f)
#define netxen_set_cmd_desc_opcode(cmd_desc, val) \ #define netxen_set_cmd_desc_opcode(cmd_desc, val) \
((cmd_desc)->flags_opcode &= ~cpu_to_le16(0x3f<<7), \ (cmd_desc)->flags_opcode = ((cmd_desc)->flags_opcode & \
(cmd_desc)->flags_opcode |= cpu_to_le16(((val & 0x3f)<<7))) ~cpu_to_le16((u16)0x3f << 7)) | cpu_to_le16(((val) & 0x3f) << 7)
#define netxen_set_cmd_desc_num_of_buff(cmd_desc, val) \ #define netxen_set_cmd_desc_num_of_buff(cmd_desc, val) \
((cmd_desc)->num_of_buffers_total_length &= ~cpu_to_le32(0xff), \ (cmd_desc)->num_of_buffers_total_length = \
(cmd_desc)->num_of_buffers_total_length |= cpu_to_le32((val) & 0xff)) ((cmd_desc)->num_of_buffers_total_length & \
~cpu_to_le32(0xff)) | cpu_to_le32((val) & 0xff)
#define netxen_set_cmd_desc_totallength(cmd_desc, val) \ #define netxen_set_cmd_desc_totallength(cmd_desc, val) \
((cmd_desc)->num_of_buffers_total_length &= ~cpu_to_le32(0xffffff00), \ (cmd_desc)->num_of_buffers_total_length = \
(cmd_desc)->num_of_buffers_total_length |= cpu_to_le32(val << 8)) ((cmd_desc)->num_of_buffers_total_length & \
~cpu_to_le32((u32)0xffffff << 8)) | \
cpu_to_le32(((val) & 0xffffff) << 8)
#define netxen_get_cmd_desc_opcode(cmd_desc) \ #define netxen_get_cmd_desc_opcode(cmd_desc) \
((le16_to_cpu((cmd_desc)->flags_opcode) >> 7) & 0x003F) ((le16_to_cpu((cmd_desc)->flags_opcode) >> 7) & 0x003f)
#define netxen_get_cmd_desc_totallength(cmd_desc) \ #define netxen_get_cmd_desc_totallength(cmd_desc) \
(le32_to_cpu((cmd_desc)->num_of_buffers_total_length) >> 8) ((le32_to_cpu((cmd_desc)->num_of_buffers_total_length) >> 8) & 0xffffff)
struct cmd_desc_type0 { struct cmd_desc_type0 {
u8 tcp_hdr_offset; /* For LSO only */ u8 tcp_hdr_offset; /* For LSO only */
...@@ -412,29 +415,29 @@ struct rcv_desc { ...@@ -412,29 +415,29 @@ struct rcv_desc {
#define netxen_get_sts_desc_lro_last_frag(status_desc) \ #define netxen_get_sts_desc_lro_last_frag(status_desc) \
(((status_desc)->lro & 0x80) >> 7) (((status_desc)->lro & 0x80) >> 7)
#define netxen_get_sts_port(status_desc) \ #define netxen_get_sts_port(sts_data) \
(le64_to_cpu((status_desc)->status_desc_data) & 0x0F) ((sts_data) & 0x0F)
#define netxen_get_sts_status(status_desc) \ #define netxen_get_sts_status(sts_data) \
((le64_to_cpu((status_desc)->status_desc_data) >> 4) & 0x0F) (((sts_data) >> 4) & 0x0F)
#define netxen_get_sts_type(status_desc) \ #define netxen_get_sts_type(sts_data) \
((le64_to_cpu((status_desc)->status_desc_data) >> 8) & 0x0F) (((sts_data) >> 8) & 0x0F)
#define netxen_get_sts_totallength(status_desc) \ #define netxen_get_sts_totallength(sts_data) \
((le64_to_cpu((status_desc)->status_desc_data) >> 12) & 0xFFFF) (((sts_data) >> 12) & 0xFFFF)
#define netxen_get_sts_refhandle(status_desc) \ #define netxen_get_sts_refhandle(sts_data) \
((le64_to_cpu((status_desc)->status_desc_data) >> 28) & 0xFFFF) (((sts_data) >> 28) & 0xFFFF)
#define netxen_get_sts_prot(status_desc) \ #define netxen_get_sts_prot(sts_data) \
((le64_to_cpu((status_desc)->status_desc_data) >> 44) & 0x0F) (((sts_data) >> 44) & 0x0F)
#define netxen_get_sts_opcode(sts_data) \
(((sts_data) >> 58) & 0x03F)
#define netxen_get_sts_owner(status_desc) \ #define netxen_get_sts_owner(status_desc) \
((le64_to_cpu((status_desc)->status_desc_data) >> 56) & 0x03) ((le64_to_cpu((status_desc)->status_desc_data) >> 56) & 0x03)
#define netxen_get_sts_opcode(status_desc) \ #define netxen_set_sts_owner(status_desc, val) { \
((le64_to_cpu((status_desc)->status_desc_data) >> 58) & 0x03F) (status_desc)->status_desc_data = \
((status_desc)->status_desc_data & \
#define netxen_clear_sts_owner(status_desc) \ ~cpu_to_le64(0x3ULL << 56)) | \
((status_desc)->status_desc_data &= \ cpu_to_le64((u64)((val) & 0x3) << 56); \
~cpu_to_le64(((unsigned long long)3) << 56 )) }
#define netxen_set_sts_owner(status_desc, val) \
((status_desc)->status_desc_data |= \
cpu_to_le64(((unsigned long long)((val) & 0x3)) << 56 ))
struct status_desc { struct status_desc {
/* Bit pattern: 0-3 port, 4-7 status, 8-11 type, 12-27 total_length /* Bit pattern: 0-3 port, 4-7 status, 8-11 type, 12-27 total_length
......
...@@ -1070,16 +1070,17 @@ netxen_process_rcv(struct netxen_adapter *adapter, int ctxid, ...@@ -1070,16 +1070,17 @@ netxen_process_rcv(struct netxen_adapter *adapter, int ctxid,
{ {
struct pci_dev *pdev = adapter->pdev; struct pci_dev *pdev = adapter->pdev;
struct net_device *netdev = adapter->netdev; struct net_device *netdev = adapter->netdev;
int index = netxen_get_sts_refhandle(desc); u64 sts_data = le64_to_cpu(desc->status_desc_data);
int index = netxen_get_sts_refhandle(sts_data);
struct netxen_recv_context *recv_ctx = &(adapter->recv_ctx[ctxid]); struct netxen_recv_context *recv_ctx = &(adapter->recv_ctx[ctxid]);
struct netxen_rx_buffer *buffer; struct netxen_rx_buffer *buffer;
struct sk_buff *skb; struct sk_buff *skb;
u32 length = netxen_get_sts_totallength(desc); u32 length = netxen_get_sts_totallength(sts_data);
u32 desc_ctx; u32 desc_ctx;
struct netxen_rcv_desc_ctx *rcv_desc; struct netxen_rcv_desc_ctx *rcv_desc;
int ret; int ret;
desc_ctx = netxen_get_sts_type(desc); desc_ctx = netxen_get_sts_type(sts_data);
if (unlikely(desc_ctx >= NUM_RCV_DESC_RINGS)) { if (unlikely(desc_ctx >= NUM_RCV_DESC_RINGS)) {
printk("%s: %s Bad Rcv descriptor ring\n", printk("%s: %s Bad Rcv descriptor ring\n",
netxen_nic_driver_name, netdev->name); netxen_nic_driver_name, netdev->name);
...@@ -1119,7 +1120,7 @@ netxen_process_rcv(struct netxen_adapter *adapter, int ctxid, ...@@ -1119,7 +1120,7 @@ netxen_process_rcv(struct netxen_adapter *adapter, int ctxid,
skb = (struct sk_buff *)buffer->skb; skb = (struct sk_buff *)buffer->skb;
if (likely(adapter->rx_csum && if (likely(adapter->rx_csum &&
netxen_get_sts_status(desc) == STATUS_CKSUM_OK)) { netxen_get_sts_status(sts_data) == STATUS_CKSUM_OK)) {
adapter->stats.csummed++; adapter->stats.csummed++;
skb->ip_summed = CHECKSUM_UNNECESSARY; skb->ip_summed = CHECKSUM_UNNECESSARY;
} else } else
...@@ -1209,7 +1210,6 @@ u32 netxen_process_rcv_ring(struct netxen_adapter *adapter, int ctxid, int max) ...@@ -1209,7 +1210,6 @@ u32 netxen_process_rcv_ring(struct netxen_adapter *adapter, int ctxid, int max)
break; break;
} }
netxen_process_rcv(adapter, ctxid, desc); netxen_process_rcv(adapter, ctxid, desc);
netxen_clear_sts_owner(desc);
netxen_set_sts_owner(desc, STATUS_OWNER_PHANTOM); netxen_set_sts_owner(desc, STATUS_OWNER_PHANTOM);
consumer = (consumer + 1) & (adapter->max_rx_desc_count - 1); consumer = (consumer + 1) & (adapter->max_rx_desc_count - 1);
count++; count++;
......
...@@ -1152,16 +1152,8 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev) ...@@ -1152,16 +1152,8 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
} }
} }
i = netxen_get_cmd_desc_totallength(&hw->cmd_desc_head[saved_producer]);
hw->cmd_desc_head[saved_producer].flags_opcode =
cpu_to_le16(hw->cmd_desc_head[saved_producer].flags_opcode);
hw->cmd_desc_head[saved_producer].num_of_buffers_total_length =
cpu_to_le32(hw->cmd_desc_head[saved_producer].
num_of_buffers_total_length);
spin_lock_bh(&adapter->tx_lock); spin_lock_bh(&adapter->tx_lock);
adapter->stats.txbytes += i; adapter->stats.txbytes += skb->len;
/* Code to update the adapter considering how many producer threads /* Code to update the adapter considering how many producer threads
are currently working */ are currently working */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment