Staging: bcm: InterfaceRx.c: Outsourced code chunk
authorMatthias Beyer <mail@beyermatthias.de>
Mon, 30 Jun 2014 08:10:03 +0000 (10:10 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 8 Jul 2014 23:06:16 +0000 (16:06 -0700)
This patch outsources a chunk of code into a function.

Acked-by: Kevin McKinney <klmckinney1@gmail.com>
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/bcm/InterfaceRx.c

index 47b6de7ee80b1e30b5ecbc007216b127bfaf3b33..f2c323d6c1a2afacc49765146d923ba3bfc42bd0 100644 (file)
@@ -21,6 +21,73 @@ static void handle_control_packet(struct bcm_interface_adapter *interface,
        wake_up(&ad->process_rx_cntrlpkt);
 }
 
+static void format_eth_hdr_to_stack(struct bcm_interface_adapter *interface,
+                                   struct bcm_mini_adapter *ad,
+                                   struct bcm_leader *p_leader,
+                                   struct sk_buff *skb,
+                                   struct urb *urb,
+                                   UINT ui_index,
+                                   int queue_index,
+                                   bool b_header_supression_endabled,
+                                   int *process_done)
+{
+       /*
+        * Data Packet, Format a proper Ethernet Header
+        * and give it to the stack
+        */
+       BCM_DEBUG_PRINT(interface->psAdapter, DBG_TYPE_RX, RX_DATA,
+                       DBG_LVL_ALL, "Received Data pkt...");
+       skb_reserve(skb, 2 + SKB_RESERVE_PHS_BYTES);
+       memcpy(skb->data+ETH_HLEN, (PUCHAR)urb->transfer_buffer +
+              sizeof(struct bcm_leader), p_leader->PLength);
+       skb->dev = ad->dev;
+
+       /* currently skb->len has extra ETH_HLEN bytes in the beginning */
+       skb_put(skb, p_leader->PLength + ETH_HLEN);
+       ad->PackInfo[queue_index].uiTotalRxBytes += p_leader->PLength;
+       ad->PackInfo[queue_index].uiThisPeriodRxBytes += p_leader->PLength;
+       BCM_DEBUG_PRINT(interface->psAdapter, DBG_TYPE_RX, RX_DATA,
+                       DBG_LVL_ALL, "Received Data pkt of len :0x%X",
+                       p_leader->PLength);
+
+       if (netif_running(ad->dev)) {
+               /* Moving ahead by ETH_HLEN to the data ptr as received from FW */
+               skb_pull(skb, ETH_HLEN);
+               PHSReceive(ad, p_leader->Vcid, skb, &skb->len,
+                          NULL, b_header_supression_endabled);
+
+               if (!ad->PackInfo[queue_index].bEthCSSupport) {
+                       skb_push(skb, ETH_HLEN);
+
+                       memcpy(skb->data, skb->dev->dev_addr, 6);
+                       memcpy(skb->data+6, skb->dev->dev_addr, 6);
+                       (*(skb->data+11))++;
+                       *(skb->data+12) = 0x08;
+                       *(skb->data+13) = 0x00;
+                       p_leader->PLength += ETH_HLEN;
+               }
+
+               skb->protocol = eth_type_trans(skb, ad->dev);
+               *process_done = netif_rx(skb);
+       } else {
+               BCM_DEBUG_PRINT(interface->psAdapter, DBG_TYPE_RX,
+                               RX_DATA, DBG_LVL_ALL,
+                               "i/f not up hance freeing SKB...");
+               dev_kfree_skb(skb);
+       }
+
+       ++ad->dev->stats.rx_packets;
+       ad->dev->stats.rx_bytes += p_leader->PLength;
+
+       for (ui_index = 0; ui_index < MIBS_MAX_HIST_ENTRIES; ui_index++) {
+               if ((p_leader->PLength <=
+                   MIBS_PKTSIZEHIST_RANGE*(ui_index+1)) &&
+                       (p_leader->PLength > MIBS_PKTSIZEHIST_RANGE*(ui_index)))
+
+                       ad->aRxPktSizeHist[ui_index]++;
+       }
+}
+
 static int SearchVcid(struct bcm_mini_adapter *Adapter, unsigned short usVcid)
 {
        int iIndex = 0;
@@ -144,64 +211,10 @@ static void read_bulk_callback(struct urb *urb)
                handle_control_packet(psIntfAdapter, Adapter, pLeader, skb,
                                      urb);
        } else {
-               /*
-                * Data Packet, Format a proper Ethernet Header
-                * and give it to the stack
-                */
-               BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_RX, RX_DATA,
-                               DBG_LVL_ALL, "Received Data pkt...");
-               skb_reserve(skb, 2 + SKB_RESERVE_PHS_BYTES);
-               memcpy(skb->data+ETH_HLEN, (PUCHAR)urb->transfer_buffer +
-                      sizeof(struct bcm_leader), pLeader->PLength);
-               skb->dev = Adapter->dev;
-
-               /* currently skb->len has extra ETH_HLEN bytes in the beginning */
-               skb_put(skb, pLeader->PLength + ETH_HLEN);
-               Adapter->PackInfo[QueueIndex].uiTotalRxBytes +=
-                       pLeader->PLength;
-               Adapter->PackInfo[QueueIndex].uiThisPeriodRxBytes +=
-                       pLeader->PLength;
-               BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_RX, RX_DATA,
-                               DBG_LVL_ALL, "Received Data pkt of len :0x%X",
-                               pLeader->PLength);
-
-               if (netif_running(Adapter->dev)) {
-                       /* Moving ahead by ETH_HLEN to the data ptr as received from FW */
-                       skb_pull(skb, ETH_HLEN);
-                       PHSReceive(Adapter, pLeader->Vcid, skb, &skb->len,
-                                  NULL, bHeaderSupressionEnabled);
-
-                       if (!Adapter->PackInfo[QueueIndex].bEthCSSupport) {
-                               skb_push(skb, ETH_HLEN);
-
-                               memcpy(skb->data, skb->dev->dev_addr, 6);
-                               memcpy(skb->data+6, skb->dev->dev_addr, 6);
-                               (*(skb->data+11))++;
-                               *(skb->data+12) = 0x08;
-                               *(skb->data+13) = 0x00;
-                               pLeader->PLength += ETH_HLEN;
-                       }
-
-                       skb->protocol = eth_type_trans(skb, Adapter->dev);
-                       process_done = netif_rx(skb);
-               } else {
-                       BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_RX,
-                                       RX_DATA, DBG_LVL_ALL,
-                                       "i/f not up hance freeing SKB...");
-                       dev_kfree_skb(skb);
-               }
-
-               ++Adapter->dev->stats.rx_packets;
-               Adapter->dev->stats.rx_bytes += pLeader->PLength;
-
-               for (uiIndex = 0; uiIndex < MIBS_MAX_HIST_ENTRIES; uiIndex++) {
-                       if ((pLeader->PLength <=
-                           MIBS_PKTSIZEHIST_RANGE*(uiIndex+1)) &&
-                               (pLeader->PLength >
-                                MIBS_PKTSIZEHIST_RANGE*(uiIndex)))
-
-                               Adapter->aRxPktSizeHist[uiIndex]++;
-               }
+               format_eth_hdr_to_stack(psIntfAdapter, Adapter, pLeader, skb,
+                                       urb, uiIndex, QueueIndex,
+                                       bHeaderSupressionEnabled,
+                                       &process_done);
        }
        Adapter->PrevNumRecvDescs++;
        pRcb->bUsed = false;