]> git.karo-electronics.de Git - mv-sheeva.git/blob - drivers/staging/bcm/Bcmnet.c
beceem: remove useless debug function entry messages
[mv-sheeva.git] / drivers / staging / bcm / Bcmnet.c
1 #include "headers.h"
2
3 struct net_device *gblpnetdev;
4 /***************************************************************************************/
5 /* proto-type of lower function */
6
7 static INT bcm_open(struct net_device *dev)
8 {
9     PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(dev);
10
11     if(Adapter->fw_download_done==FALSE)
12         return -EINVAL;
13         if(Adapter->LinkUpStatus == 1){
14                 if(netif_queue_stopped(Adapter->dev)){
15                         netif_carrier_on(Adapter->dev);
16                         netif_start_queue(Adapter->dev);
17                 }
18         }
19
20     return 0;
21 }
22
23 static INT bcm_close(struct net_device *dev)
24 {
25    PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(dev);
26
27         if(!netif_queue_stopped(dev)) {
28                 netif_carrier_off(dev);
29             netif_stop_queue(dev);
30         }
31     return 0;
32 }
33
34 static struct net_device_stats *bcm_get_stats(struct net_device *dev)
35 {
36         PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(dev);
37         struct net_device_stats*        netstats = &dev->stats;
38
39         netstats->rx_packets = atomic_read(&Adapter->RxRollOverCount)*64*1024
40                 + Adapter->PrevNumRecvDescs;
41         netstats->rx_bytes = atomic_read(&Adapter->GoodRxByteCount)
42                 + atomic_read(&Adapter->BadRxByteCount);
43
44         netstats->rx_dropped = atomic_read(&Adapter->RxPacketDroppedCount);
45         netstats->rx_errors  = atomic_read(&Adapter->RxPacketDroppedCount);
46         netstats->tx_bytes   = atomic_read(&Adapter->GoodTxByteCount);
47         netstats->tx_packets = atomic_read(&Adapter->TxTotalPacketCount);
48         netstats->tx_dropped = atomic_read(&Adapter->TxDroppedPacketCount);
49
50         return netstats;
51 }
52
53 static u16 bcm_select_queue(struct net_device *dev, struct sk_buff *skb)
54 {
55         return ClassifyPacket(netdev_priv(dev), skb);
56 }
57
58
59 /*******************************************************************
60 * Function    - bcm_transmit()
61 *
62 * Description - This is the main transmit function for our virtual
63 *                               interface(eth0). It handles the ARP packets. It
64 *                               clones this packet and then Queue it to a suitable
65 *                               Queue. Then calls the transmit_packet().
66 *
67 * Parameter   -  skb - Pointer to the socket buffer structure
68 *                                dev - Pointer to the virtual net device structure
69 *
70 *********************************************************************/
71
72 static netdev_tx_t bcm_transmit(struct sk_buff *skb, struct net_device *dev)
73 {
74         PMINI_ADAPTER      Adapter = GET_BCM_ADAPTER(dev);
75         u16 qindex = skb_get_queue_mapping(skb);
76
77         if (Adapter->device_removed || !Adapter->LinkUpStatus)
78                 goto drop;
79
80         if (Adapter->TransferMode != IP_PACKET_ONLY_MODE )
81                 goto drop;
82
83         if (INVALID_QUEUE_INDEX==qindex)
84                 goto drop;
85
86         if (Adapter->PackInfo[qindex].uiCurrentPacketsOnHost >= SF_MAX_ALLOWED_PACKETS_TO_BACKUP)
87                 return NETDEV_TX_BUSY;
88
89         /* Now Enqueue the packet */
90         BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL,
91                         "bcm_transmit Enqueueing the Packet To Queue %d",qindex);
92         spin_lock(&Adapter->PackInfo[qindex].SFQueueLock);
93         Adapter->PackInfo[qindex].uiCurrentBytesOnHost += skb->len;
94         Adapter->PackInfo[qindex].uiCurrentPacketsOnHost++;
95
96         *((B_UINT32 *)skb->cb + SKB_CB_LATENCY_OFFSET ) = jiffies;
97         ENQUEUEPACKET(Adapter->PackInfo[qindex].FirstTxQueue,
98                       Adapter->PackInfo[qindex].LastTxQueue, skb);
99         atomic_inc(&Adapter->TotalPacketCount);
100         spin_unlock(&Adapter->PackInfo[qindex].SFQueueLock);
101
102         BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_OSAL_DBG, DBG_LVL_ALL,"ENQ: \n");
103
104         /* FIXME - this is racy and incorrect, replace with work queue */
105         if (!atomic_read(&Adapter->TxPktAvail)) {
106                 atomic_set(&Adapter->TxPktAvail, 1);
107                 wake_up(&Adapter->tx_packet_wait_queue);
108         }
109         return NETDEV_TX_OK;
110
111  drop:
112         dev_kfree_skb(skb);
113         return NETDEV_TX_OK;
114 }
115
116
117
118 /**
119 @ingroup init_functions
120 Register other driver entry points with the kernel
121 */
122 static const struct net_device_ops bcmNetDevOps = {
123     .ndo_open           = bcm_open,
124     .ndo_stop           = bcm_close,
125     .ndo_get_stats      = bcm_get_stats,
126     .ndo_start_xmit     = bcm_transmit,
127     .ndo_change_mtu     = eth_change_mtu,
128     .ndo_set_mac_address = eth_mac_addr,
129     .ndo_validate_addr  = eth_validate_addr,
130     .ndo_select_queue   = bcm_select_queue,
131 };
132
133 static struct device_type wimax_type = {
134         .name   = "wimax",
135 };
136
137 static int bcm_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
138 {
139         cmd->supported          = 0;
140         cmd->advertising        = 0;
141         cmd->speed              = SPEED_10000;
142         cmd->duplex             = DUPLEX_FULL;
143         cmd->port               = PORT_TP;
144         cmd->phy_address        = 0;
145         cmd->transceiver        = XCVR_INTERNAL;
146         cmd->autoneg            = AUTONEG_DISABLE;
147         cmd->maxtxpkt           = 0;
148         cmd->maxrxpkt           = 0;
149         return 0;
150 }
151
152 static void bcm_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
153 {
154         PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(dev);
155         PS_INTERFACE_ADAPTER psIntfAdapter = Adapter->pvInterfaceAdapter;
156         struct usb_device *udev = interface_to_usbdev(psIntfAdapter->interface);
157
158         strcpy(info->driver, DRV_NAME);
159         strcpy(info->version, DRV_VERSION);
160         snprintf(info->fw_version, sizeof(info->fw_version), "%u.%u",
161                  Adapter->uiFlashLayoutMajorVersion,
162                  Adapter->uiFlashLayoutMinorVersion);
163
164         usb_make_path(udev, info->bus_info, sizeof(info->bus_info));
165 }
166
167 static u32 bcm_get_link(struct net_device *dev)
168 {
169         PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(dev);
170
171         return Adapter->LinkUpStatus;
172 }
173
174 static const struct ethtool_ops bcm_ethtool_ops = {
175         .get_settings   = bcm_get_settings,
176         .get_drvinfo    = bcm_get_drvinfo,
177         .get_link       = bcm_get_link,
178 };
179
180 int register_networkdev(PMINI_ADAPTER Adapter)
181 {
182         struct net_device *net = Adapter->dev;
183         int result;
184
185         net->netdev_ops = &bcmNetDevOps;
186         net->ethtool_ops = &bcm_ethtool_ops;
187         net->mtu          = MTU_SIZE; /* 1400 Bytes */
188         net->tx_queue_len = TX_QLEN;
189         net->flags |= IFF_NOARP;
190         net->flags &= ~(IFF_BROADCAST|IFF_MULTICAST);
191
192         netif_carrier_off(net);
193
194         SET_NETDEV_DEVTYPE(net, &wimax_type);
195
196         /* Read the MAC Address from EEPROM */
197         ReadMacAddressFromNVM(Adapter);
198
199         result = register_netdev(net);
200         if (result == 0)
201                 gblpnetdev = Adapter->dev = net;
202         else {
203                 Adapter->dev = NULL;
204                 free_netdev(net);
205         }
206
207         return result;
208 }
209
210 static int bcm_init(void)
211 {
212         printk(KERN_INFO "%s, %s\n", DRV_DESCRIPTION, DRV_VERSION);
213         printk(KERN_INFO "%s\n", DRV_COPYRIGHT);
214
215         return InterfaceInitialize();
216 }
217
218
219 static void bcm_exit(void)
220 {
221         InterfaceExit();
222 }
223
224 module_init(bcm_init);
225 module_exit(bcm_exit);
226
227 MODULE_DESCRIPTION(DRV_DESCRIPTION);
228 MODULE_VERSION(DRV_VERSION);
229 MODULE_LICENSE ("GPL");
230