3 #define DRV_NAME "beceem"
4 #define DRV_VERSION "5.2.7.3P1"
5 #define DRV_DESCRIPTION "Beceem Communications Inc. WiMAX driver"
6 #define DRV_COPYRIGHT "Copyright 2010. Beceem Communications Inc"
9 struct net_device *gblpnetdev;
10 /***************************************************************************************/
11 /* proto-type of lower function */
13 static INT bcm_open(struct net_device *dev)
15 PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(dev);
17 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "======>");
18 if(Adapter->fw_download_done==FALSE)
21 if(Adapter->LinkUpStatus == 1){
22 if(netif_queue_stopped(Adapter->dev)){
23 netif_carrier_on(Adapter->dev);
24 netif_start_queue(Adapter->dev);
28 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "<======");
32 static INT bcm_close(struct net_device *dev)
34 PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(dev);
36 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "=====>");
38 if(!netif_queue_stopped(dev)) {
39 netif_carrier_off(dev);
40 netif_stop_queue(dev);
42 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL,"<=====");
46 static struct net_device_stats *bcm_get_stats(struct net_device *dev)
48 PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(dev);
49 struct net_device_stats* netstats = &dev->stats;
51 netstats->rx_packets = atomic_read(&Adapter->RxRollOverCount)*64*1024
52 + Adapter->PrevNumRecvDescs;
53 netstats->rx_bytes = atomic_read(&Adapter->GoodRxByteCount)
54 + atomic_read(&Adapter->BadRxByteCount);
56 netstats->rx_dropped = atomic_read(&Adapter->RxPacketDroppedCount);
57 netstats->rx_errors = atomic_read(&Adapter->RxPacketDroppedCount);
58 netstats->tx_bytes = atomic_read(&Adapter->GoodTxByteCount);
59 netstats->tx_packets = atomic_read(&Adapter->TxTotalPacketCount);
60 netstats->tx_dropped = atomic_read(&Adapter->TxDroppedPacketCount);
66 @ingroup init_functions
67 Register other driver entry points with the kernel
69 static const struct net_device_ops bcmNetDevOps = {
71 .ndo_stop = bcm_close,
72 .ndo_get_stats = bcm_get_stats,
73 .ndo_start_xmit = bcm_transmit,
74 .ndo_change_mtu = eth_change_mtu,
75 .ndo_set_mac_address = eth_mac_addr,
76 .ndo_validate_addr = eth_validate_addr,
79 static struct device_type wimax_type = {
83 static int bcm_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
87 cmd->speed = SPEED_10000;
88 cmd->duplex = DUPLEX_FULL;
91 cmd->transceiver = XCVR_INTERNAL;
92 cmd->autoneg = AUTONEG_DISABLE;
98 static void bcm_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
100 PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(dev);
101 PS_INTERFACE_ADAPTER psIntfAdapter = Adapter->pvInterfaceAdapter;
102 struct usb_device *udev = interface_to_usbdev(psIntfAdapter->interface);
104 strcpy(info->driver, DRV_NAME);
105 strcpy(info->version, DRV_VERSION);
106 snprintf(info->fw_version, sizeof(info->fw_version), "%u.%u",
107 Adapter->uiFlashLayoutMajorVersion,
108 Adapter->uiFlashLayoutMinorVersion);
110 usb_make_path(udev, info->bus_info, sizeof(info->bus_info));
113 static u32 bcm_get_link(struct net_device *dev)
115 PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(dev);
117 return Adapter->LinkUpStatus;
120 static const struct ethtool_ops bcm_ethtool_ops = {
121 .get_settings = bcm_get_settings,
122 .get_drvinfo = bcm_get_drvinfo,
123 .get_link = bcm_get_link,
126 int register_networkdev(PMINI_ADAPTER Adapter)
128 struct net_device *net;
130 PS_INTERFACE_ADAPTER psIntfAdapter = Adapter->pvInterfaceAdapter;
131 struct usb_interface *uintf = psIntfAdapter->interface;
134 net = alloc_etherdev(sizeof(PMINI_ADAPTER));
136 pr_notice("bcmnet: no memory for device\n");
140 Adapter->dev = net; /* FIXME - only allows one adapter! */
141 temp = netdev_priv(net);
144 net->netdev_ops = &bcmNetDevOps;
145 net->ethtool_ops = &bcm_ethtool_ops;
146 net->mtu = MTU_SIZE; /* 1400 Bytes */
147 net->tx_queue_len = TX_QLEN;
149 SET_NETDEV_DEV(net, &uintf->dev);
150 SET_NETDEV_DEVTYPE(net, &wimax_type);
152 /* Read the MAC Address from EEPROM */
153 ReadMacAddressFromNVM(Adapter);
155 result = register_netdev(net);
157 gblpnetdev = Adapter->dev = net;
166 void bcm_unregister_networkdev(PMINI_ADAPTER Adapter)
168 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Unregistering the Net Dev...\n");
170 unregister_netdev(Adapter->dev);
175 static int bcm_init(void)
177 printk(KERN_INFO "%s, %s\n", DRV_DESCRIPTION, DRV_VERSION);
178 printk(KERN_INFO "%s\n", DRV_COPYRIGHT);
180 return InterfaceInitialize();
184 static void bcm_exit(void)
189 module_init(bcm_init);
190 module_exit(bcm_exit);
192 MODULE_DESCRIPTION(DRV_DESCRIPTION);
193 MODULE_VERSION(DRV_VERSION);
194 MODULE_LICENSE ("GPL");