3 struct net_device
*gblpnetdev
;
4 /***************************************************************************************/
5 /* proto-type of lower function */
7 static INT
bcm_open(struct net_device
*dev
)
9 PMINI_ADAPTER Adapter
= GET_BCM_ADAPTER(dev
);
11 if(Adapter
->fw_download_done
==FALSE
)
13 if(Adapter
->LinkUpStatus
== 1){
14 if(netif_queue_stopped(Adapter
->dev
)){
15 netif_carrier_on(Adapter
->dev
);
16 netif_start_queue(Adapter
->dev
);
23 static INT
bcm_close(struct net_device
*dev
)
25 PMINI_ADAPTER Adapter
= GET_BCM_ADAPTER(dev
);
27 if(!netif_queue_stopped(dev
)) {
28 netif_carrier_off(dev
);
29 netif_stop_queue(dev
);
34 static struct net_device_stats
*bcm_get_stats(struct net_device
*dev
)
36 PMINI_ADAPTER Adapter
= GET_BCM_ADAPTER(dev
);
37 struct net_device_stats
* netstats
= &dev
->stats
;
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
);
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
);
53 static u16
bcm_select_queue(struct net_device
*dev
, struct sk_buff
*skb
)
55 return ClassifyPacket(netdev_priv(dev
), skb
);
59 /*******************************************************************
60 * Function - bcm_transmit()
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().
67 * Parameter - skb - Pointer to the socket buffer structure
68 * dev - Pointer to the virtual net device structure
70 *********************************************************************/
72 static netdev_tx_t
bcm_transmit(struct sk_buff
*skb
, struct net_device
*dev
)
74 PMINI_ADAPTER Adapter
= GET_BCM_ADAPTER(dev
);
75 u16 qindex
= skb_get_queue_mapping(skb
);
77 if (Adapter
->device_removed
|| !Adapter
->LinkUpStatus
)
80 if (Adapter
->TransferMode
!= IP_PACKET_ONLY_MODE
)
83 if (INVALID_QUEUE_INDEX
==qindex
)
86 if (Adapter
->PackInfo
[qindex
].uiCurrentPacketsOnHost
>= SF_MAX_ALLOWED_PACKETS_TO_BACKUP
)
87 return NETDEV_TX_BUSY
;
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
++;
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
);
102 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_TX
, TX_OSAL_DBG
, DBG_LVL_ALL
,"ENQ: \n");
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
);
119 @ingroup init_functions
120 Register other driver entry points with the kernel
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
,
133 static struct device_type wimax_type
= {
137 static int bcm_get_settings(struct net_device
*dev
, struct ethtool_cmd
*cmd
)
140 cmd
->advertising
= 0;
141 cmd
->speed
= SPEED_10000
;
142 cmd
->duplex
= DUPLEX_FULL
;
144 cmd
->phy_address
= 0;
145 cmd
->transceiver
= XCVR_INTERNAL
;
146 cmd
->autoneg
= AUTONEG_DISABLE
;
152 static void bcm_get_drvinfo(struct net_device
*dev
, struct ethtool_drvinfo
*info
)
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
);
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
);
164 usb_make_path(udev
, info
->bus_info
, sizeof(info
->bus_info
));
167 static u32
bcm_get_link(struct net_device
*dev
)
169 PMINI_ADAPTER Adapter
= GET_BCM_ADAPTER(dev
);
171 return Adapter
->LinkUpStatus
;
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
,
180 int register_networkdev(PMINI_ADAPTER Adapter
)
182 struct net_device
*net
= Adapter
->dev
;
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
);
192 netif_carrier_off(net
);
194 SET_NETDEV_DEVTYPE(net
, &wimax_type
);
196 /* Read the MAC Address from EEPROM */
197 ReadMacAddressFromNVM(Adapter
);
199 result
= register_netdev(net
);
201 gblpnetdev
= Adapter
->dev
= net
;
210 static int bcm_init(void)
212 printk(KERN_INFO
"%s, %s\n", DRV_DESCRIPTION
, DRV_VERSION
);
213 printk(KERN_INFO
"%s\n", DRV_COPYRIGHT
);
215 return InterfaceInitialize();
219 static void bcm_exit(void)
224 module_init(bcm_init
);
225 module_exit(bcm_exit
);
227 MODULE_DESCRIPTION(DRV_DESCRIPTION
);
228 MODULE_VERSION(DRV_VERSION
);
229 MODULE_LICENSE ("GPL");