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,9 +2561,8 @@ static void et131x_rx_dma_memory_free(struct et131x_adapter *adapter) ...@@ -2561,9 +2561,8 @@ 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,
rx_ring->ps_ring_virtaddr, rx_ring->ps_ring_virtaddr,
...@@ -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,119 +2825,101 @@ static struct rfd *nic_rx_pkts(struct et131x_adapter *adapter) ...@@ -2831,119 +2825,101 @@ 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) {
/* Determine if this is a multicast packet coming in */ rfd->len = 0;
if ((word0 & ALCATEL_MULTICAST_PKT) && goto out;
!(word0 & ALCATEL_BROADCAST_PKT)) { }
/* Promiscuous mode and Multicast mode are
* not mutually exclusive as was first /* Determine if this is a multicast packet coming in */
* thought. I guess Promiscuous is just if ((word0 & ALCATEL_MULTICAST_PKT) &&
* considered a super-set of the other !(word0 & ALCATEL_BROADCAST_PKT)) {
* filters. Generally filter is 0x2b when in /* Promiscuous mode and Multicast mode are not mutually
* promiscuous mode. * exclusive as was first thought. I guess Promiscuous is just
*/ * considered a super-set of the other filters. Generally filter
if ((adapter->packet_filter & * is 0x2b when in promiscuous mode.
ET131X_PACKET_TYPE_MULTICAST) */
&& !(adapter->packet_filter & if ((adapter->packet_filter & ET131X_PACKET_TYPE_MULTICAST)
ET131X_PACKET_TYPE_PROMISCUOUS) && !(adapter->packet_filter & ET131X_PACKET_TYPE_PROMISCUOUS)
&& !(adapter->packet_filter & && !(adapter->packet_filter &
ET131X_PACKET_TYPE_ALL_MULTICAST)) { ET131X_PACKET_TYPE_ALL_MULTICAST)) {
/* /*
* Note - ring_index for fbr[] array is reversed * Note - ring_index for fbr[] array is reversed
* 1 for FBR0 etc * 1 for FBR0 etc
*/ */
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] == break;
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;
}
} }
/* If our index is equal to the number
* of Multicast address we have, then
* this means we did not find this
* packet's matching address in our
* list. Set the len to zero,
* so we free our RFD when we return
* from this function.
*/
if (i == adapter->multicast_addr_count)
len = 0;
} }
if (len > 0) /* If our index is equal to the number of Multicast
adapter->stats.multicast_pkts_rcvd++; * address we have, then this means we did not find this
} else if (word0 & ALCATEL_BROADCAST_PKT) * packet's matching address in our list. Set the len to
adapter->stats.broadcast_pkts_rcvd++; * zero, so we free our RFD when we return from this
else * function.
/* Not sure what this counter measures in
* promiscuous mode. Perhaps we should check
* the MAC address to see if it is directed
* to us in promiscuous mode.
*/ */
adapter->stats.unicast_pkts_rcvd++; if (i == adapter->multicast_addr_count)
} len = 0;
}
if (len > 0) { if (len > 0)
struct sk_buff *skb = NULL; adapter->stats.multicast_pkts_rcvd++;
} else if (word0 & ALCATEL_BROADCAST_PKT) {
adapter->stats.broadcast_pkts_rcvd++;
} else {
/* Not sure what this counter measures in promiscuous mode.
* Perhaps we should check the MAC address to see if it is
* directed to us in promiscuous mode.
*/
adapter->stats.unicast_pkts_rcvd++;
}
/*rfd->len = len - 4; */ if (len == 0) {
rfd->len = len; rfd->len = 0;
goto out;
}
skb = dev_alloc_skb(rfd->len + 2); rfd->len = len;
if (!skb) {
dev_err(&adapter->pdev->dev,
"Couldn't alloc an SKB for Rx\n");
return NULL;
}
adapter->net_stats.rx_bytes += rfd->len; skb = dev_alloc_skb(rfd->len + 2);
if (!skb) {
dev_err(&adapter->pdev->dev, "Couldn't alloc an SKB for Rx\n");
return NULL;
}
/* adapter->net_stats.rx_bytes += rfd->len;
* Note - ring_index for fbr[] array is reversed,
* 1 for FBR0 etc
*/
memcpy(skb_put(skb, rfd->len),
rx_local->fbr[(ring_index == 0 ? 1 : 0)]->virt[buff_index],
rfd->len);
skb->dev = adapter->netdev; /* Note - ring_index for fbr[] array is reversed, 1 for FBR0 etc */
skb->protocol = eth_type_trans(skb, adapter->netdev); memcpy(skb_put(skb, rfd->len),
skb->ip_summed = CHECKSUM_NONE; rx_local->fbr[(ring_index == 0 ? 1 : 0)]->virt[buff_index],
rfd->len);
netif_rx_ni(skb); skb->dev = adapter->netdev;
} else { skb->protocol = eth_type_trans(skb, adapter->netdev);
rfd->len = 0; skb->ip_summed = CHECKSUM_NONE;
} netif_rx_ni(skb);
out:
nic_return_rfd(adapter, rfd); nic_return_rfd(adapter, rfd);
return rfd; return rfd;
} }
...@@ -3740,7 +3716,7 @@ static struct ethtool_ops et131x_ethtool_ops = { ...@@ -3740,7 +3716,7 @@ static struct ethtool_ops et131x_ethtool_ops = {
.get_drvinfo = et131x_get_drvinfo, .get_drvinfo = et131x_get_drvinfo,
.get_regs_len = et131x_get_regs_len, .get_regs_len = et131x_get_regs_len,
.get_regs = et131x_get_regs, .get_regs = et131x_get_regs,
.get_link = ethtool_op_get_link, .get_link = ethtool_op_get_link,
}; };
/** /**
* et131x_hwaddr_init - set up the MAC Address on the ET1310 * et131x_hwaddr_init - set up the MAC Address on the ET1310
...@@ -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