Commit 242187aa authored by Mark Einon's avatar Mark Einon Committed by Greg Kroah-Hartman

staging: et131x: Refactor nic_rx_pkts() to remove indenting

In nic_rx_pkts() some large chunks of code are indented in 'if (len)'
sections. Refactor the code to remove these indents and re-join longer
split lines.
Signed-off-by: default avatarMark Einon <mark.einon@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 788ca84a
...@@ -2561,8 +2561,7 @@ static void et131x_rx_dma_memory_free(struct et131x_adapter *adapter) ...@@ -2561,8 +2561,7 @@ static void et131x_rx_dma_memory_free(struct et131x_adapter *adapter)
/* Free Packet Status Ring */ /* Free Packet Status Ring */
if (rx_ring->ps_ring_virtaddr) { if (rx_ring->ps_ring_virtaddr) {
pktstat_ringsize = pktstat_ringsize = sizeof(struct pkt_stat_desc) *
sizeof(struct pkt_stat_desc) *
adapter->rx_ring.psr_num_entries; adapter->rx_ring.psr_num_entries;
dma_free_coherent(&adapter->pdev->dev, pktstat_ringsize, dma_free_coherent(&adapter->pdev->dev, pktstat_ringsize,
...@@ -2748,7 +2747,7 @@ static struct rfd *nic_rx_pkts(struct et131x_adapter *adapter) ...@@ -2748,7 +2747,7 @@ static struct rfd *nic_rx_pkts(struct et131x_adapter *adapter)
struct rx_ring *rx_local = &adapter->rx_ring; struct rx_ring *rx_local = &adapter->rx_ring;
struct rx_status_block *status; struct rx_status_block *status;
struct pkt_stat_desc *psr; struct pkt_stat_desc *psr;
struct rfd *rfd; struct rfd *rfd = NULL;
u32 i; u32 i;
u8 *buf; u8 *buf;
unsigned long flags; unsigned long flags;
...@@ -2758,6 +2757,7 @@ static struct rfd *nic_rx_pkts(struct et131x_adapter *adapter) ...@@ -2758,6 +2757,7 @@ static struct rfd *nic_rx_pkts(struct et131x_adapter *adapter)
u32 len; u32 len;
u32 word0; u32 word0;
u32 word1; u32 word1;
struct sk_buff *skb = NULL;
/* RX Status block is written by the DMA engine prior to every /* RX Status block is written by the DMA engine prior to every
* interrupt. It contains the next to be used entry in the Packet * interrupt. It contains the next to be used entry in the Packet
...@@ -2768,16 +2768,14 @@ static struct rfd *nic_rx_pkts(struct et131x_adapter *adapter) ...@@ -2768,16 +2768,14 @@ static struct rfd *nic_rx_pkts(struct et131x_adapter *adapter)
/* Check the PSR and wrap bits do not match */ /* Check the PSR and wrap bits do not match */
if ((word1 & 0x1FFF) == (rx_local->local_psr_full & 0x1FFF)) if ((word1 & 0x1FFF) == (rx_local->local_psr_full & 0x1FFF))
/* Looks like this ring is not updated yet */ return NULL; /* Looks like this ring is not updated yet */
return NULL;
/* The packet status ring indicates that data is available. */ /* The packet status ring indicates that data is available. */
psr = (struct pkt_stat_desc *) (rx_local->ps_ring_virtaddr) + psr = (struct pkt_stat_desc *) (rx_local->ps_ring_virtaddr) +
(rx_local->local_psr_full & 0xFFF); (rx_local->local_psr_full & 0xFFF);
/* Grab any information that is required once the PSR is /* Grab any information that is required once the PSR is advanced,
* advanced, since we can no longer rely on the memory being * since we can no longer rely on the memory being accurate
* accurate
*/ */
len = psr->word1 & 0xFFFF; len = psr->word1 & 0xFFFF;
ring_index = (psr->word1 >> 26) & 0x03; ring_index = (psr->word1 >> 26) & 0x03;
...@@ -2794,8 +2792,7 @@ static struct rfd *nic_rx_pkts(struct et131x_adapter *adapter) ...@@ -2794,8 +2792,7 @@ static struct rfd *nic_rx_pkts(struct et131x_adapter *adapter)
rx_local->local_psr_full ^= 0x1000; rx_local->local_psr_full ^= 0x1000;
} }
writel(rx_local->local_psr_full, writel(rx_local->local_psr_full, &adapter->regs->rxdma.psr_full_offset);
&adapter->regs->rxdma.psr_full_offset);
if (ring_index > 1 || if (ring_index > 1 ||
(ring_index == 0 && (ring_index == 0 &&
...@@ -2804,21 +2801,18 @@ static struct rfd *nic_rx_pkts(struct et131x_adapter *adapter) ...@@ -2804,21 +2801,18 @@ static struct rfd *nic_rx_pkts(struct et131x_adapter *adapter)
buff_index > rx_local->fbr[0]->num_entries - 1)) { buff_index > rx_local->fbr[0]->num_entries - 1)) {
/* Illegal buffer or ring index cannot be used by S/W*/ /* Illegal buffer or ring index cannot be used by S/W*/
dev_err(&adapter->pdev->dev, dev_err(&adapter->pdev->dev,
"NICRxPkts PSR Entry %d indicates " "NICRxPkts PSR Entry %d indicates length of %d and/or bad bi(%d)\n",
"length of %d and/or bad bi(%d)\n", rx_local->local_psr_full & 0xFFF, len, buff_index);
rx_local->local_psr_full & 0xFFF,
len, buff_index);
return NULL; return NULL;
} }
/* Get and fill the RFD. */ /* Get and fill the RFD. */
spin_lock_irqsave(&adapter->rcv_lock, flags); spin_lock_irqsave(&adapter->rcv_lock, flags);
rfd = NULL;
element = rx_local->recv_list.next; element = rx_local->recv_list.next;
rfd = (struct rfd *) list_entry(element, struct rfd, list_node); rfd = (struct rfd *) list_entry(element, struct rfd, list_node);
if (rfd == NULL) { if (!rfd) {
spin_unlock_irqrestore(&adapter->rcv_lock, flags); spin_unlock_irqrestore(&adapter->rcv_lock, flags);
return NULL; return NULL;
} }
...@@ -2831,31 +2825,30 @@ static struct rfd *nic_rx_pkts(struct et131x_adapter *adapter) ...@@ -2831,31 +2825,30 @@ static struct rfd *nic_rx_pkts(struct et131x_adapter *adapter)
rfd->bufferindex = buff_index; rfd->bufferindex = buff_index;
rfd->ringindex = ring_index; rfd->ringindex = ring_index;
/* In V1 silicon, there is a bug which screws up filtering of /* In V1 silicon, there is a bug which screws up filtering of runt
* runt packets. Therefore runt packet filtering is disabled * packets. Therefore runt packet filtering is disabled in the MAC and
* in the MAC and the packets are dropped here. They are * the packets are dropped here. They are also counted here.
* also counted here.
*/ */
if (len < (NIC_MIN_PACKET_SIZE + 4)) { if (len < (NIC_MIN_PACKET_SIZE + 4)) {
adapter->stats.rx_other_errs++; adapter->stats.rx_other_errs++;
len = 0; len = 0;
} }
if (len) { if (len == 0) {
rfd->len = 0;
goto out;
}
/* Determine if this is a multicast packet coming in */ /* Determine if this is a multicast packet coming in */
if ((word0 & ALCATEL_MULTICAST_PKT) && if ((word0 & ALCATEL_MULTICAST_PKT) &&
!(word0 & ALCATEL_BROADCAST_PKT)) { !(word0 & ALCATEL_BROADCAST_PKT)) {
/* Promiscuous mode and Multicast mode are /* Promiscuous mode and Multicast mode are not mutually
* not mutually exclusive as was first * exclusive as was first thought. I guess Promiscuous is just
* thought. I guess Promiscuous is just * considered a super-set of the other filters. Generally filter
* considered a super-set of the other * is 0x2b when in promiscuous mode.
* filters. Generally filter is 0x2b when in */
* promiscuous mode. if ((adapter->packet_filter & ET131X_PACKET_TYPE_MULTICAST)
*/ && !(adapter->packet_filter & ET131X_PACKET_TYPE_PROMISCUOUS)
if ((adapter->packet_filter &
ET131X_PACKET_TYPE_MULTICAST)
&& !(adapter->packet_filter &
ET131X_PACKET_TYPE_PROMISCUOUS)
&& !(adapter->packet_filter & && !(adapter->packet_filter &
ET131X_PACKET_TYPE_ALL_MULTICAST)) { ET131X_PACKET_TYPE_ALL_MULTICAST)) {
/* /*
...@@ -2865,35 +2858,25 @@ static struct rfd *nic_rx_pkts(struct et131x_adapter *adapter) ...@@ -2865,35 +2858,25 @@ static struct rfd *nic_rx_pkts(struct et131x_adapter *adapter)
buf = rx_local->fbr[(ring_index == 0 ? 1 : 0)]-> buf = rx_local->fbr[(ring_index == 0 ? 1 : 0)]->
virt[buff_index]; virt[buff_index];
/* Loop through our list to see if the /* Loop through our list to see if the destination
* destination address of this packet * address of this packet matches one in our list.
* matches one in our list. */
*/ for (i = 0; i < adapter->multicast_addr_count; i++) {
for (i = 0; i < adapter->multicast_addr_count; if (buf[0] == adapter->multicast_list[i][0]
i++) { && buf[1] == adapter->multicast_list[i][1]
if (buf[0] == && buf[2] == adapter->multicast_list[i][2]
adapter->multicast_list[i][0] && buf[3] == adapter->multicast_list[i][3]
&& buf[1] == && buf[4] == adapter->multicast_list[i][4]
adapter->multicast_list[i][1] && buf[5] == adapter->multicast_list[i][5]) {
&& buf[2] ==
adapter->multicast_list[i][2]
&& buf[3] ==
adapter->multicast_list[i][3]
&& buf[4] ==
adapter->multicast_list[i][4]
&& buf[5] ==
adapter->multicast_list[i][5]) {
break; break;
} }
} }
/* If our index is equal to the number /* If our index is equal to the number of Multicast
* of Multicast address we have, then * address we have, then this means we did not find this
* this means we did not find this * packet's matching address in our list. Set the len to
* packet's matching address in our * zero, so we free our RFD when we return from this
* list. Set the len to zero, * function.
* so we free our RFD when we return
* from this function.
*/ */
if (i == adapter->multicast_addr_count) if (i == adapter->multicast_addr_count)
len = 0; len = 0;
...@@ -2901,36 +2884,32 @@ static struct rfd *nic_rx_pkts(struct et131x_adapter *adapter) ...@@ -2901,36 +2884,32 @@ static struct rfd *nic_rx_pkts(struct et131x_adapter *adapter)
if (len > 0) if (len > 0)
adapter->stats.multicast_pkts_rcvd++; adapter->stats.multicast_pkts_rcvd++;
} else if (word0 & ALCATEL_BROADCAST_PKT) } else if (word0 & ALCATEL_BROADCAST_PKT) {
adapter->stats.broadcast_pkts_rcvd++; adapter->stats.broadcast_pkts_rcvd++;
else } else {
/* Not sure what this counter measures in /* Not sure what this counter measures in promiscuous mode.
* promiscuous mode. Perhaps we should check * Perhaps we should check the MAC address to see if it is
* the MAC address to see if it is directed * directed to us in promiscuous mode.
* to us in promiscuous mode.
*/ */
adapter->stats.unicast_pkts_rcvd++; adapter->stats.unicast_pkts_rcvd++;
} }
if (len > 0) { if (len == 0) {
struct sk_buff *skb = NULL; rfd->len = 0;
goto out;
}
/*rfd->len = len - 4; */
rfd->len = len; rfd->len = len;
skb = dev_alloc_skb(rfd->len + 2); skb = dev_alloc_skb(rfd->len + 2);
if (!skb) { if (!skb) {
dev_err(&adapter->pdev->dev, dev_err(&adapter->pdev->dev, "Couldn't alloc an SKB for Rx\n");
"Couldn't alloc an SKB for Rx\n");
return NULL; return NULL;
} }
adapter->net_stats.rx_bytes += rfd->len; adapter->net_stats.rx_bytes += rfd->len;
/* /* Note - ring_index for fbr[] array is reversed, 1 for FBR0 etc */
* Note - ring_index for fbr[] array is reversed,
* 1 for FBR0 etc
*/
memcpy(skb_put(skb, rfd->len), memcpy(skb_put(skb, rfd->len),
rx_local->fbr[(ring_index == 0 ? 1 : 0)]->virt[buff_index], rx_local->fbr[(ring_index == 0 ? 1 : 0)]->virt[buff_index],
rfd->len); rfd->len);
...@@ -2938,12 +2917,9 @@ static struct rfd *nic_rx_pkts(struct et131x_adapter *adapter) ...@@ -2938,12 +2917,9 @@ static struct rfd *nic_rx_pkts(struct et131x_adapter *adapter)
skb->dev = adapter->netdev; skb->dev = adapter->netdev;
skb->protocol = eth_type_trans(skb, adapter->netdev); skb->protocol = eth_type_trans(skb, adapter->netdev);
skb->ip_summed = CHECKSUM_NONE; skb->ip_summed = CHECKSUM_NONE;
netif_rx_ni(skb); netif_rx_ni(skb);
} else {
rfd->len = 0;
}
out:
nic_return_rfd(adapter, rfd); nic_return_rfd(adapter, rfd);
return rfd; return rfd;
} }
...@@ -3907,8 +3883,7 @@ static void et131x_error_timer_handler(unsigned long data) ...@@ -3907,8 +3883,7 @@ static void et131x_error_timer_handler(unsigned long data)
} }
/* This is a periodic timer, so reschedule */ /* This is a periodic timer, so reschedule */
mod_timer(&adapter->error_timer, jiffies + mod_timer(&adapter->error_timer, jiffies + TX_ERROR_PERIOD * HZ / 1000);
TX_ERROR_PERIOD * HZ / 1000);
} }
/** /**
......
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