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)
/* Free Packet Status Ring */
if (rx_ring->ps_ring_virtaddr) {
pktstat_ringsize =
sizeof(struct pkt_stat_desc) *
pktstat_ringsize = sizeof(struct pkt_stat_desc) *
adapter->rx_ring.psr_num_entries;
dma_free_coherent(&adapter->pdev->dev, pktstat_ringsize,
......@@ -2748,7 +2747,7 @@ static struct rfd *nic_rx_pkts(struct et131x_adapter *adapter)
struct rx_ring *rx_local = &adapter->rx_ring;
struct rx_status_block *status;
struct pkt_stat_desc *psr;
struct rfd *rfd;
struct rfd *rfd = NULL;
u32 i;
u8 *buf;
unsigned long flags;
......@@ -2758,6 +2757,7 @@ static struct rfd *nic_rx_pkts(struct et131x_adapter *adapter)
u32 len;
u32 word0;
u32 word1;
struct sk_buff *skb = NULL;
/* RX Status block is written by the DMA engine prior to every
* 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)
/* Check the PSR and wrap bits do not match */
if ((word1 & 0x1FFF) == (rx_local->local_psr_full & 0x1FFF))
/* Looks like this ring is not updated yet */
return NULL;
return NULL; /* Looks like this ring is not updated yet */
/* The packet status ring indicates that data is available. */
psr = (struct pkt_stat_desc *) (rx_local->ps_ring_virtaddr) +
(rx_local->local_psr_full & 0xFFF);
/* Grab any information that is required once the PSR is
* advanced, since we can no longer rely on the memory being
* accurate
/* Grab any information that is required once the PSR is advanced,
* since we can no longer rely on the memory being accurate
*/
len = psr->word1 & 0xFFFF;
ring_index = (psr->word1 >> 26) & 0x03;
......@@ -2794,8 +2792,7 @@ static struct rfd *nic_rx_pkts(struct et131x_adapter *adapter)
rx_local->local_psr_full ^= 0x1000;
}
writel(rx_local->local_psr_full,
&adapter->regs->rxdma.psr_full_offset);
writel(rx_local->local_psr_full, &adapter->regs->rxdma.psr_full_offset);
if (ring_index > 1 ||
(ring_index == 0 &&
......@@ -2804,21 +2801,18 @@ static struct rfd *nic_rx_pkts(struct et131x_adapter *adapter)
buff_index > rx_local->fbr[0]->num_entries - 1)) {
/* Illegal buffer or ring index cannot be used by S/W*/
dev_err(&adapter->pdev->dev,
"NICRxPkts PSR Entry %d indicates "
"length of %d and/or bad bi(%d)\n",
rx_local->local_psr_full & 0xFFF,
len, buff_index);
"NICRxPkts PSR Entry %d indicates length of %d and/or bad bi(%d)\n",
rx_local->local_psr_full & 0xFFF, len, buff_index);
return NULL;
}
/* Get and fill the RFD. */
spin_lock_irqsave(&adapter->rcv_lock, flags);
rfd = NULL;
element = rx_local->recv_list.next;
rfd = (struct rfd *) list_entry(element, struct rfd, list_node);
if (rfd == NULL) {
if (!rfd) {
spin_unlock_irqrestore(&adapter->rcv_lock, flags);
return NULL;
}
......@@ -2831,31 +2825,30 @@ static struct rfd *nic_rx_pkts(struct et131x_adapter *adapter)
rfd->bufferindex = buff_index;
rfd->ringindex = ring_index;
/* In V1 silicon, there is a bug which screws up filtering of
* runt packets. Therefore runt packet filtering is disabled
* in the MAC and the packets are dropped here. They are
* also counted here.
/* In V1 silicon, there is a bug which screws up filtering of runt
* packets. Therefore runt packet filtering is disabled in the MAC and
* the packets are dropped here. They are also counted here.
*/
if (len < (NIC_MIN_PACKET_SIZE + 4)) {
adapter->stats.rx_other_errs++;
len = 0;
}
if (len) {
if (len == 0) {
rfd->len = 0;
goto out;
}
/* Determine if this is a multicast packet coming in */
if ((word0 & ALCATEL_MULTICAST_PKT) &&
!(word0 & ALCATEL_BROADCAST_PKT)) {
/* Promiscuous mode and Multicast mode are
* not mutually exclusive as was first
* thought. I guess Promiscuous is just
* considered a super-set of the other
* filters. Generally filter is 0x2b when in
* promiscuous mode.
*/
if ((adapter->packet_filter &
ET131X_PACKET_TYPE_MULTICAST)
&& !(adapter->packet_filter &
ET131X_PACKET_TYPE_PROMISCUOUS)
/* Promiscuous mode and Multicast mode are not mutually
* exclusive as was first thought. I guess Promiscuous is just
* considered a super-set of the other filters. Generally filter
* is 0x2b when in promiscuous mode.
*/
if ((adapter->packet_filter & ET131X_PACKET_TYPE_MULTICAST)
&& !(adapter->packet_filter & ET131X_PACKET_TYPE_PROMISCUOUS)
&& !(adapter->packet_filter &
ET131X_PACKET_TYPE_ALL_MULTICAST)) {
/*
......@@ -2865,35 +2858,25 @@ static struct rfd *nic_rx_pkts(struct et131x_adapter *adapter)
buf = rx_local->fbr[(ring_index == 0 ? 1 : 0)]->
virt[buff_index];
/* Loop through our list to see if the
* destination address of this packet
* matches one in our list.
*/
for (i = 0; i < adapter->multicast_addr_count;
i++) {
if (buf[0] ==
adapter->multicast_list[i][0]
&& buf[1] ==
adapter->multicast_list[i][1]
&& 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]) {
/* Loop through our list to see if the destination
* address of this packet matches one in our list.
*/
for (i = 0; i < adapter->multicast_addr_count; i++) {
if (buf[0] == adapter->multicast_list[i][0]
&& buf[1] == adapter->multicast_list[i][1]
&& 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;
}
}
/* 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 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;
......@@ -2901,36 +2884,32 @@ static struct rfd *nic_rx_pkts(struct et131x_adapter *adapter)
if (len > 0)
adapter->stats.multicast_pkts_rcvd++;
} else if (word0 & ALCATEL_BROADCAST_PKT)
} 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.
} 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++;
}
if (len > 0) {
struct sk_buff *skb = NULL;
if (len == 0) {
rfd->len = 0;
goto out;
}
/*rfd->len = len - 4; */
rfd->len = len;
skb = dev_alloc_skb(rfd->len + 2);
if (!skb) {
dev_err(&adapter->pdev->dev,
"Couldn't alloc an SKB for Rx\n");
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
*/
/* 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);
......@@ -2938,12 +2917,9 @@ static struct rfd *nic_rx_pkts(struct et131x_adapter *adapter)
skb->dev = adapter->netdev;
skb->protocol = eth_type_trans(skb, adapter->netdev);
skb->ip_summed = CHECKSUM_NONE;
netif_rx_ni(skb);
} else {
rfd->len = 0;
}
out:
nic_return_rfd(adapter, rfd);
return rfd;
}
......@@ -3907,8 +3883,7 @@ static void et131x_error_timer_handler(unsigned long data)
}
/* This is a periodic timer, so reschedule */
mod_timer(&adapter->error_timer, jiffies +
TX_ERROR_PERIOD * HZ / 1000);
mod_timer(&adapter->error_timer, jiffies + 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