]> git.karo-electronics.de Git - mv-sheeva.git/commitdiff
beceem: support multiple queues
authorStephen Hemminger <stephen.hemminger@vyatta.com>
Mon, 1 Nov 2010 03:55:21 +0000 (23:55 -0400)
committerStephen Hemminger <stephen.hemminger@vyatta.com>
Mon, 1 Nov 2010 13:54:39 +0000 (09:54 -0400)
Current kernels have multi-queue support which can be used by
this device. This has the advantage that a single type of traffic
will not block other types.

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
drivers/staging/bcm/Bcmnet.c
drivers/staging/bcm/InterfaceInit.c
drivers/staging/bcm/Prototypes.h
drivers/staging/bcm/Qos.c
drivers/staging/bcm/Transmit.c

index e3575ad65e9156d9770e3f6331ab088de50c056b..5b466174a5802f844f14db54e8b46b1afa4e6b36 100644 (file)
@@ -54,6 +54,71 @@ static struct net_device_stats *bcm_get_stats(struct net_device *dev)
        return netstats;
 }
 
+static u16 bcm_select_queue(struct net_device *dev, struct sk_buff *skb)
+{
+       return ClassifyPacket(netdev_priv(dev), skb);
+}
+
+
+/*******************************************************************
+* Function    -        bcm_transmit()
+*
+* Description - This is the main transmit function for our virtual
+*                              interface(eth0). It handles the ARP packets. It
+*                              clones this packet and then Queue it to a suitable
+*                              Queue. Then calls the transmit_packet().
+*
+* Parameter   -         skb - Pointer to the socket buffer structure
+*                               dev - Pointer to the virtual net device structure
+*
+*********************************************************************/
+
+static netdev_tx_t bcm_transmit(struct sk_buff *skb, struct net_device *dev)
+{
+       PMINI_ADAPTER      Adapter = GET_BCM_ADAPTER(dev);
+       u16 qindex = skb_get_queue_mapping(skb);
+
+       if (Adapter->device_removed || !Adapter->LinkUpStatus)
+               goto drop;
+
+       if (Adapter->TransferMode != IP_PACKET_ONLY_MODE )
+               goto drop;
+
+       if (INVALID_QUEUE_INDEX==qindex)
+               goto drop;
+
+       if (Adapter->PackInfo[qindex].uiCurrentPacketsOnHost >= SF_MAX_ALLOWED_PACKETS_TO_BACKUP)
+               return NETDEV_TX_BUSY;
+
+       /* Now Enqueue the packet */
+       BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL,
+                       "bcm_transmit Enqueueing the Packet To Queue %d",qindex);
+       spin_lock(&Adapter->PackInfo[qindex].SFQueueLock);
+       Adapter->PackInfo[qindex].uiCurrentBytesOnHost += skb->len;
+       Adapter->PackInfo[qindex].uiCurrentPacketsOnHost++;
+
+       *((B_UINT32 *)skb->cb + SKB_CB_LATENCY_OFFSET ) = jiffies;
+       ENQUEUEPACKET(Adapter->PackInfo[qindex].FirstTxQueue,
+                     Adapter->PackInfo[qindex].LastTxQueue, skb);
+       atomic_inc(&Adapter->TotalPacketCount);
+       spin_unlock(&Adapter->PackInfo[qindex].SFQueueLock);
+
+       BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_OSAL_DBG, DBG_LVL_ALL,"ENQ: \n");
+
+       /* FIXME - this is racy and incorrect, replace with work queue */
+       if (!atomic_read(&Adapter->TxPktAvail)) {
+               atomic_set(&Adapter->TxPktAvail, 1);
+               wake_up(&Adapter->tx_packet_wait_queue);
+       }
+       return NETDEV_TX_OK;
+
+ drop:
+       dev_kfree_skb(skb);
+       return NETDEV_TX_OK;
+}
+
+
+
 /**
 @ingroup init_functions
 Register other driver entry points with the kernel
@@ -66,6 +131,7 @@ static const struct net_device_ops bcmNetDevOps = {
     .ndo_change_mtu    = eth_change_mtu,
     .ndo_set_mac_address = eth_mac_addr,
     .ndo_validate_addr = eth_validate_addr,
+    .ndo_select_queue  = bcm_select_queue,
 };
 
 static struct device_type wimax_type = {
index 14866e9c8cd2ecc6adea3f5f8df09a5d1f096620..845ced1670eeb4a6c331172a23833d50a9eab5d6 100644 (file)
@@ -188,7 +188,7 @@ usbbcm_device_probe(struct usb_interface *intf, const struct usb_device_id *id)
        PS_INTERFACE_ADAPTER psIntfAdapter;
        struct net_device *ndev;
 
-       ndev = alloc_etherdev(sizeof(MINI_ADAPTER));
+       ndev = alloc_etherdev_mq(sizeof(MINI_ADAPTER), NO_OF_QUEUES);
        if(ndev == NULL) {
                dev_err(&udev->dev, DRV_NAME ": no memory for device\n");
                return -ENOMEM;
index 8ca6b9eb4e34f9bbb4dd631916a8b19601dc3be1..a4b57bb07fa111e01ec9b15058063466d0382c44 100644 (file)
@@ -46,13 +46,12 @@ VOID PruneQueueAllSF(PMINI_ADAPTER Adapter);
 
 INT SearchSfid(PMINI_ADAPTER Adapter,UINT uiSfid);
 
-USHORT GetPacketQueueIndex(PMINI_ADAPTER Adapter, /**<Pointer to the driver control structure */
-                                                               struct sk_buff* Packet /**< Pointer to the Packet to be sent*/
-                                                               );
+USHORT ClassifyPacket(PMINI_ADAPTER Adapter,struct sk_buff* skb);
+
+BOOLEAN MatchSrcPort(S_CLASSIFIER_RULE *pstClassifierRule,USHORT ushSrcPort);
+BOOLEAN MatchDestPort(S_CLASSIFIER_RULE *pstClassifierRule,USHORT ushSrcPort);
+BOOLEAN MatchProtocol(S_CLASSIFIER_RULE *pstClassifierRule,UCHAR ucProtocol);
 
-VOID
-reply_to_arp_request(struct sk_buff *skb  /**<sk_buff of ARP request*/
-                                               );
 
 INT SetupNextSend(PMINI_ADAPTER Adapter, /**<Logical Adapter*/
                                        struct sk_buff *Packet, /**<data buffer*/
@@ -66,9 +65,6 @@ INT SendControlPacket(PMINI_ADAPTER Adapter, /**<Logical Adapter*/
                                                        char *pControlPacket/**<Control Packet*/
                                                        );
 
-INT bcm_transmit(struct sk_buff *skb,          /**< skb */
-                                       struct net_device *dev  /**< net device pointer */
-                                       );
 
 int register_networkdev(PMINI_ADAPTER Adapter);
 
index 6e40646290464ea5ab3552171feed8a32b33ee29..f85a5a85ad5cd667e122ec82d65d6c90ce64d85a 100644 (file)
@@ -4,13 +4,6 @@ This file contains the routines related to Quality of Service.
 */
 #include "headers.h"
 
-BOOLEAN MatchSrcIpAddress(S_CLASSIFIER_RULE *pstClassifierRule,ULONG ulSrcIP);
-BOOLEAN MatchTos(S_CLASSIFIER_RULE *pstClassifierRule,UCHAR ucTypeOfService);
-BOOLEAN MatchSrcPort(S_CLASSIFIER_RULE *pstClassifierRule,USHORT ushSrcPort);
-BOOLEAN MatchDestPort(S_CLASSIFIER_RULE *pstClassifierRule,USHORT ushDestPort);
-BOOLEAN MatchProtocol(S_CLASSIFIER_RULE *pstClassifierRule,UCHAR ucProtocol);
-BOOLEAN MatchDestIpAddress(S_CLASSIFIER_RULE *pstClassifierRule,ULONG ulDestIP);
-USHORT ClassifyPacket(PMINI_ADAPTER Adapter,struct sk_buff* skb);
 void EThCSGetPktInfo(PMINI_ADAPTER Adapter,PVOID pvEthPayload,PS_ETHCS_PKT_INFO pstEthCsPktInfo);
 BOOLEAN EThCSClassifyPkt(PMINI_ADAPTER Adapter,struct sk_buff* skb,PS_ETHCS_PKT_INFO pstEthCsPktInfo,S_CLASSIFIER_RULE *pstClassifierRule, B_UINT8 EthCSCupport);
 
@@ -312,29 +305,6 @@ USHORT     IpVersion4(PMINI_ADAPTER Adapter, /**< Pointer to the driver control stru
 
        return bClassificationSucceed;
 }
-/**
-@ingroup tx_functions
-@return  Queue Index based on priority.
-*/
-USHORT GetPacketQueueIndex(PMINI_ADAPTER Adapter, /**<Pointer to the driver control structure */
-                                                               struct sk_buff* Packet /**< Pointer to the Packet to be sent*/
-                                                               )
-{
-       USHORT                  usIndex=-1;
-       BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, QUEUE_INDEX, DBG_LVL_ALL, "=====>");
-
-       if(NULL==Adapter || NULL==Packet)
-       {
-               BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, QUEUE_INDEX, DBG_LVL_ALL, "Got NULL Values<======");
-               return -1;
-       }
-
-       usIndex = ClassifyPacket(Adapter,Packet);
-
-       BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, QUEUE_INDEX, DBG_LVL_ALL, "Got Queue Index %x",usIndex);
-       BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, QUEUE_INDEX, DBG_LVL_ALL, "GetPacketQueueIndex <==============");
-       return usIndex;
-}
 
 VOID PruneQueueAllSF(PMINI_ADAPTER Adapter)
 {
index 4b94d822578cedd469897dbb75eae07dd327cc5d..734bbbd14e223a9f2ebcfa2d16f33498878a58d0 100644 (file)
@@ -35,67 +35,6 @@ SendPacketFromQueue->SetupNextSend->bcm_cmd53
 
 #include "headers.h"
 
-/*******************************************************************
-* Function    -        bcm_transmit()
-*
-* Description - This is the main transmit function for our virtual
-*                              interface(eth0). It handles the ARP packets. It
-*                              clones this packet and then Queue it to a suitable
-*                              Queue. Then calls the transmit_packet().
-*
-* Parameter   -         skb - Pointer to the socket buffer structure
-*                               dev - Pointer to the virtual net device structure
-*
-* Returns     -         zero (success) or -ve value (failure)
-*
-*********************************************************************/
-
-netdev_tx_t bcm_transmit(struct sk_buff *skb, struct net_device *dev)
-{
-       PMINI_ADAPTER           Adapter = GET_BCM_ADAPTER(dev);
-       SHORT qindex;
-
-       if (Adapter->device_removed || !Adapter->LinkUpStatus)
-               goto drop;
-
-       if (Adapter->TransferMode != IP_PACKET_ONLY_MODE )
-               goto drop;
-
-       qindex = GetPacketQueueIndex(Adapter, skb);
-
-       if (INVALID_QUEUE_INDEX==qindex)
-               goto drop;
-
-       if (Adapter->PackInfo[qindex].uiCurrentPacketsOnHost >= SF_MAX_ALLOWED_PACKETS_TO_BACKUP)
-               return NETDEV_TX_BUSY;
-
-       /* Now Enqueue the packet */
-       BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL,
-                       "bcm_transmit Enqueueing the Packet To Queue %d",qindex);
-       spin_lock(&Adapter->PackInfo[qindex].SFQueueLock);
-       Adapter->PackInfo[qindex].uiCurrentBytesOnHost += skb->len;
-       Adapter->PackInfo[qindex].uiCurrentPacketsOnHost++;
-
-       *((B_UINT32 *)skb->cb + SKB_CB_LATENCY_OFFSET ) = jiffies;
-       ENQUEUEPACKET(Adapter->PackInfo[qindex].FirstTxQueue,
-                     Adapter->PackInfo[qindex].LastTxQueue, skb);
-       atomic_inc(&Adapter->TotalPacketCount);
-       spin_unlock(&Adapter->PackInfo[qindex].SFQueueLock);
-
-       BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_OSAL_DBG, DBG_LVL_ALL,"ENQ: \n");
-
-       /* FIXME - this is racy and incorrect, replace with work queue */
-       if (!atomic_read(&Adapter->TxPktAvail)) {
-               atomic_set(&Adapter->TxPktAvail, 1);
-               wake_up(&Adapter->tx_packet_wait_queue);
-       }
-       return NETDEV_TX_OK;
-
- drop:
-       dev_kfree_skb(skb);
-       return NETDEV_TX_OK;
-}
-
 
 /**
 @ingroup ctrl_pkt_functions