Commit 2ca13da7 authored by Jay Cliburn's avatar Jay Cliburn Committed by Jeff Garzik

atl1: fix excessively indented code

Move excessively indented code to separate functions.  Also move ring
pointer initialization to its own function.
Signed-off-by: default avatarJay Cliburn <jacliburn@bellsouth.net>
Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
parent 53ffb42c
...@@ -220,8 +220,6 @@ s32 atl1_setup_ring_resources(struct atl1_adapter *adapter) ...@@ -220,8 +220,6 @@ s32 atl1_setup_ring_resources(struct atl1_adapter *adapter)
tpd_ring->dma += offset; tpd_ring->dma += offset;
tpd_ring->desc = (u8 *) ring_header->desc + offset; tpd_ring->desc = (u8 *) ring_header->desc + offset;
tpd_ring->size = sizeof(struct tx_packet_desc) * tpd_ring->count; tpd_ring->size = sizeof(struct tx_packet_desc) * tpd_ring->count;
atomic_set(&tpd_ring->next_to_use, 0);
atomic_set(&tpd_ring->next_to_clean, 0);
/* init RFD ring */ /* init RFD ring */
rfd_ring->dma = tpd_ring->dma + tpd_ring->size; rfd_ring->dma = tpd_ring->dma + tpd_ring->size;
...@@ -229,8 +227,7 @@ s32 atl1_setup_ring_resources(struct atl1_adapter *adapter) ...@@ -229,8 +227,7 @@ s32 atl1_setup_ring_resources(struct atl1_adapter *adapter)
rfd_ring->dma += offset; rfd_ring->dma += offset;
rfd_ring->desc = (u8 *) tpd_ring->desc + (tpd_ring->size + offset); rfd_ring->desc = (u8 *) tpd_ring->desc + (tpd_ring->size + offset);
rfd_ring->size = sizeof(struct rx_free_desc) * rfd_ring->count; rfd_ring->size = sizeof(struct rx_free_desc) * rfd_ring->count;
rfd_ring->next_to_clean = 0;
atomic_set(&rfd_ring->next_to_use, 0);
/* init RRD ring */ /* init RRD ring */
rrd_ring->dma = rfd_ring->dma + rfd_ring->size; rrd_ring->dma = rfd_ring->dma + rfd_ring->size;
...@@ -238,8 +235,7 @@ s32 atl1_setup_ring_resources(struct atl1_adapter *adapter) ...@@ -238,8 +235,7 @@ s32 atl1_setup_ring_resources(struct atl1_adapter *adapter)
rrd_ring->dma += offset; rrd_ring->dma += offset;
rrd_ring->desc = (u8 *) rfd_ring->desc + (rfd_ring->size + offset); rrd_ring->desc = (u8 *) rfd_ring->desc + (rfd_ring->size + offset);
rrd_ring->size = sizeof(struct rx_return_desc) * rrd_ring->count; rrd_ring->size = sizeof(struct rx_return_desc) * rrd_ring->count;
rrd_ring->next_to_use = 0;
atomic_set(&rrd_ring->next_to_clean, 0);
/* init CMB */ /* init CMB */
adapter->cmb.dma = rrd_ring->dma + rrd_ring->size; adapter->cmb.dma = rrd_ring->dma + rrd_ring->size;
...@@ -263,6 +259,22 @@ s32 atl1_setup_ring_resources(struct atl1_adapter *adapter) ...@@ -263,6 +259,22 @@ s32 atl1_setup_ring_resources(struct atl1_adapter *adapter)
return -ENOMEM; return -ENOMEM;
} }
void atl1_init_ring_ptrs(struct atl1_adapter *adapter)
{
struct atl1_tpd_ring *tpd_ring = &adapter->tpd_ring;
struct atl1_rfd_ring *rfd_ring = &adapter->rfd_ring;
struct atl1_rrd_ring *rrd_ring = &adapter->rrd_ring;
atomic_set(&tpd_ring->next_to_use, 0);
atomic_set(&tpd_ring->next_to_clean, 0);
rfd_ring->next_to_clean = 0;
atomic_set(&rfd_ring->next_to_use, 0);
rrd_ring->next_to_use = 0;
atomic_set(&rrd_ring->next_to_clean, 0);
}
/* /*
* atl1_irq_enable - Enable default interrupt generation settings * atl1_irq_enable - Enable default interrupt generation settings
* @adapter: board private structure * @adapter: board private structure
...@@ -472,6 +484,31 @@ static u16 atl1_alloc_rx_buffers(struct atl1_adapter *adapter) ...@@ -472,6 +484,31 @@ static u16 atl1_alloc_rx_buffers(struct atl1_adapter *adapter)
return num_alloc; return num_alloc;
} }
static void atl1_clean_alloc_flag(struct atl1_adapter *adapter,
struct rx_return_desc *rrd, u16 offset)
{
struct atl1_rfd_ring *rfd_ring = &adapter->rfd_ring;
while (rfd_ring->next_to_clean != (rrd->buf_indx + offset)) {
rfd_ring->buffer_info[rfd_ring->next_to_clean].alloced = 0;
if (++rfd_ring->next_to_clean == rfd_ring->count) {
rfd_ring->next_to_clean = 0;
}
}
}
static void atl1_update_rfd_index(struct atl1_adapter *adapter,
struct rx_return_desc *rrd)
{
u16 num_buf;
num_buf = (rrd->xsz.xsum_sz.pkt_size + adapter->rx_buffer_len - 1) /
adapter->rx_buffer_len;
if (rrd->num_buf == num_buf)
/* clean alloc flag for bad rrd */
atl1_clean_alloc_flag(adapter, rrd, num_buf);
}
static void atl1_intr_rx(struct atl1_adapter *adapter) static void atl1_intr_rx(struct atl1_adapter *adapter)
{ {
int i, count; int i, count;
...@@ -509,26 +546,8 @@ static void atl1_intr_rx(struct atl1_adapter *adapter) ...@@ -509,26 +546,8 @@ static void atl1_intr_rx(struct atl1_adapter *adapter)
dev_printk(KERN_DEBUG, &adapter->pdev->dev, dev_printk(KERN_DEBUG, &adapter->pdev->dev,
"bad RRD\n"); "bad RRD\n");
/* see if update RFD index */ /* see if update RFD index */
if (rrd->num_buf > 1) { if (rrd->num_buf > 1)
u16 num_buf; atl1_update_rfd_index(adapter, rrd);
num_buf =
(rrd->xsz.xsum_sz.pkt_size +
adapter->rx_buffer_len -
1) / adapter->rx_buffer_len;
if (rrd->num_buf == num_buf) {
/* clean alloc flag for bad rrd */
while (rfd_ring->next_to_clean !=
(rrd->buf_indx + num_buf)) {
rfd_ring->buffer_info[rfd_ring->
next_to_clean].alloced = 0;
if (++rfd_ring->next_to_clean ==
rfd_ring->count) {
rfd_ring->
next_to_clean = 0;
}
}
}
}
/* update rrd */ /* update rrd */
rrd->xsz.valid = 0; rrd->xsz.valid = 0;
...@@ -542,12 +561,7 @@ static void atl1_intr_rx(struct atl1_adapter *adapter) ...@@ -542,12 +561,7 @@ static void atl1_intr_rx(struct atl1_adapter *adapter)
} }
rrd_ok: rrd_ok:
/* clean alloc flag for bad rrd */ /* clean alloc flag for bad rrd */
while (rfd_ring->next_to_clean != rrd->buf_indx) { atl1_clean_alloc_flag(adapter, rrd, 0);
rfd_ring->buffer_info[rfd_ring->next_to_clean].alloced =
0;
if (++rfd_ring->next_to_clean == rfd_ring->count)
rfd_ring->next_to_clean = 0;
}
buffer_info = &rfd_ring->buffer_info[rrd->buf_indx]; buffer_info = &rfd_ring->buffer_info[rrd->buf_indx];
if (++rfd_ring->next_to_clean == rfd_ring->count) if (++rfd_ring->next_to_clean == rfd_ring->count)
...@@ -1058,7 +1072,8 @@ static u32 atl1_configure(struct atl1_adapter *adapter) ...@@ -1058,7 +1072,8 @@ static u32 atl1_configure(struct atl1_adapter *adapter)
value <<= 16; value <<= 16;
value += adapter->rfd_ring.count; value += adapter->rfd_ring.count;
iowrite32(value, hw->hw_addr + REG_DESC_RFD_RRD_RING_SIZE); iowrite32(value, hw->hw_addr + REG_DESC_RFD_RRD_RING_SIZE);
iowrite32(adapter->tpd_ring.count, hw->hw_addr + REG_DESC_TPD_RING_SIZE); iowrite32(adapter->tpd_ring.count, hw->hw_addr +
REG_DESC_TPD_RING_SIZE);
/* Load Ptr */ /* Load Ptr */
iowrite32(1, hw->hw_addr + REG_LOAD_PTR); iowrite32(1, hw->hw_addr + REG_LOAD_PTR);
...@@ -1258,9 +1273,7 @@ static int atl1_tso(struct atl1_adapter *adapter, struct sk_buff *skb, ...@@ -1258,9 +1273,7 @@ static int atl1_tso(struct atl1_adapter *adapter, struct sk_buff *skb,
iph->tot_len = 0; iph->tot_len = 0;
iph->check = 0; iph->check = 0;
tcp_hdr(skb)->check = ~csum_tcpudp_magic(iph->saddr, tcp_hdr(skb)->check = ~csum_tcpudp_magic(iph->saddr,
iph->daddr, 0, iph->daddr, 0, IPPROTO_TCP, 0);
IPPROTO_TCP,
0);
ipofst = skb_network_offset(skb); ipofst = skb_network_offset(skb);
if (ipofst != ENET_HEADER_SIZE) /* 802.3 frame */ if (ipofst != ENET_HEADER_SIZE) /* 802.3 frame */
tso->tsopl |= 1 << TSO_PARAM_ETHTYPE_SHIFT; tso->tsopl |= 1 << TSO_PARAM_ETHTYPE_SHIFT;
...@@ -1721,6 +1734,7 @@ s32 atl1_up(struct atl1_adapter *adapter) ...@@ -1721,6 +1734,7 @@ s32 atl1_up(struct atl1_adapter *adapter)
/* hardware has been reset, we need to reload some things */ /* hardware has been reset, we need to reload some things */
atl1_set_multi(netdev); atl1_set_multi(netdev);
atl1_init_ring_ptrs(adapter);
atl1_restore_vlan(adapter); atl1_restore_vlan(adapter);
err = atl1_alloc_rx_buffers(adapter); err = atl1_alloc_rx_buffers(adapter);
if (unlikely(!err)) /* no RX BUFFER allocated */ if (unlikely(!err)) /* no RX BUFFER allocated */
......
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