3 struct net_device
*gblpnetdev
;
5 static INT
bcm_open(struct net_device
*dev
)
7 struct bcm_mini_adapter
*Adapter
= GET_BCM_ADAPTER(dev
);
9 if (Adapter
->fw_download_done
== FALSE
) {
10 pr_notice(PFX
"%s: link up failed (download in progress)\n",
15 if (netif_msg_ifup(Adapter
))
16 pr_info(PFX
"%s: enabling interface\n", dev
->name
);
18 if (Adapter
->LinkUpStatus
) {
19 if (netif_msg_link(Adapter
))
20 pr_info(PFX
"%s: link up\n", dev
->name
);
22 netif_carrier_on(Adapter
->dev
);
23 netif_start_queue(Adapter
->dev
);
29 static INT
bcm_close(struct net_device
*dev
)
31 struct bcm_mini_adapter
*Adapter
= GET_BCM_ADAPTER(dev
);
33 if (netif_msg_ifdown(Adapter
))
34 pr_info(PFX
"%s: disabling interface\n", dev
->name
);
36 netif_carrier_off(dev
);
37 netif_stop_queue(dev
);
42 static u16
bcm_select_queue(struct net_device
*dev
, struct sk_buff
*skb
)
44 return ClassifyPacket(netdev_priv(dev
), skb
);
47 /*******************************************************************
48 * Function - bcm_transmit()
50 * Description - This is the main transmit function for our virtual
51 * interface(eth0). It handles the ARP packets. It
52 * clones this packet and then Queue it to a suitable
53 * Queue. Then calls the transmit_packet().
55 * Parameter - skb - Pointer to the socket buffer structure
56 * dev - Pointer to the virtual net device structure
58 *********************************************************************/
60 static netdev_tx_t
bcm_transmit(struct sk_buff
*skb
, struct net_device
*dev
)
62 struct bcm_mini_adapter
*Adapter
= GET_BCM_ADAPTER(dev
);
63 u16 qindex
= skb_get_queue_mapping(skb
);
66 if (Adapter
->device_removed
|| !Adapter
->LinkUpStatus
)
69 if (Adapter
->TransferMode
!= IP_PACKET_ONLY_MODE
)
72 if (INVALID_QUEUE_INDEX
== qindex
)
75 if (Adapter
->PackInfo
[qindex
].uiCurrentPacketsOnHost
>=
76 SF_MAX_ALLOWED_PACKETS_TO_BACKUP
)
77 return NETDEV_TX_BUSY
;
79 /* Now Enqueue the packet */
80 if (netif_msg_tx_queued(Adapter
))
81 pr_info(PFX
"%s: enqueueing packet to queue %d\n",
84 spin_lock(&Adapter
->PackInfo
[qindex
].SFQueueLock
);
85 Adapter
->PackInfo
[qindex
].uiCurrentBytesOnHost
+= skb
->len
;
86 Adapter
->PackInfo
[qindex
].uiCurrentPacketsOnHost
++;
88 *((B_UINT32
*) skb
->cb
+ SKB_CB_LATENCY_OFFSET
) = jiffies
;
89 ENQUEUEPACKET(Adapter
->PackInfo
[qindex
].FirstTxQueue
,
90 Adapter
->PackInfo
[qindex
].LastTxQueue
, skb
);
91 atomic_inc(&Adapter
->TotalPacketCount
);
92 spin_unlock(&Adapter
->PackInfo
[qindex
].SFQueueLock
);
94 /* FIXME - this is racy and incorrect, replace with work queue */
95 if (!atomic_read(&Adapter
->TxPktAvail
)) {
96 atomic_set(&Adapter
->TxPktAvail
, 1);
97 wake_up(&Adapter
->tx_packet_wait_queue
);
109 @ingroup init_functions
110 Register other driver entry points with the kernel
112 static const struct net_device_ops bcmNetDevOps
= {
113 .ndo_open
= bcm_open
,
114 .ndo_stop
= bcm_close
,
115 .ndo_start_xmit
= bcm_transmit
,
116 .ndo_change_mtu
= eth_change_mtu
,
117 .ndo_set_mac_address
= eth_mac_addr
,
118 .ndo_validate_addr
= eth_validate_addr
,
119 .ndo_select_queue
= bcm_select_queue
,
122 static struct device_type wimax_type
= {
126 static int bcm_get_settings(struct net_device
*dev
, struct ethtool_cmd
*cmd
)
129 cmd
->advertising
= 0;
130 cmd
->speed
= SPEED_10000
;
131 cmd
->duplex
= DUPLEX_FULL
;
133 cmd
->phy_address
= 0;
134 cmd
->transceiver
= XCVR_INTERNAL
;
135 cmd
->autoneg
= AUTONEG_DISABLE
;
141 static void bcm_get_drvinfo(struct net_device
*dev
,
142 struct ethtool_drvinfo
*info
)
144 struct bcm_mini_adapter
*Adapter
= GET_BCM_ADAPTER(dev
);
145 struct bcm_interface_adapter
*psIntfAdapter
= Adapter
->pvInterfaceAdapter
;
146 struct usb_device
*udev
= interface_to_usbdev(psIntfAdapter
->interface
);
148 strlcpy(info
->driver
, DRV_NAME
, sizeof(info
->driver
));
149 strlcpy(info
->version
, DRV_VERSION
, sizeof(info
->version
));
150 snprintf(info
->fw_version
, sizeof(info
->fw_version
), "%u.%u",
151 Adapter
->uiFlashLayoutMajorVersion
,
152 Adapter
->uiFlashLayoutMinorVersion
);
154 usb_make_path(udev
, info
->bus_info
, sizeof(info
->bus_info
));
157 static u32
bcm_get_link(struct net_device
*dev
)
159 struct bcm_mini_adapter
*Adapter
= GET_BCM_ADAPTER(dev
);
161 return Adapter
->LinkUpStatus
;
164 static u32
bcm_get_msglevel(struct net_device
*dev
)
166 struct bcm_mini_adapter
*Adapter
= GET_BCM_ADAPTER(dev
);
168 return Adapter
->msg_enable
;
171 static void bcm_set_msglevel(struct net_device
*dev
, u32 level
)
173 struct bcm_mini_adapter
*Adapter
= GET_BCM_ADAPTER(dev
);
175 Adapter
->msg_enable
= level
;
178 static const struct ethtool_ops bcm_ethtool_ops
= {
179 .get_settings
= bcm_get_settings
,
180 .get_drvinfo
= bcm_get_drvinfo
,
181 .get_link
= bcm_get_link
,
182 .get_msglevel
= bcm_get_msglevel
,
183 .set_msglevel
= bcm_set_msglevel
,
186 int register_networkdev(struct bcm_mini_adapter
*Adapter
)
188 struct net_device
*net
= Adapter
->dev
;
189 struct bcm_interface_adapter
*IntfAdapter
= Adapter
->pvInterfaceAdapter
;
190 struct usb_interface
*udev
= IntfAdapter
->interface
;
191 struct usb_device
*xdev
= IntfAdapter
->udev
;
195 net
->netdev_ops
= &bcmNetDevOps
;
196 net
->ethtool_ops
= &bcm_ethtool_ops
;
197 net
->mtu
= MTU_SIZE
; /* 1400 Bytes */
198 net
->tx_queue_len
= TX_QLEN
;
199 net
->flags
|= IFF_NOARP
;
201 netif_carrier_off(net
);
203 SET_NETDEV_DEVTYPE(net
, &wimax_type
);
205 /* Read the MAC Address from EEPROM */
206 result
= ReadMacAddressFromNVM(Adapter
);
207 if (result
!= STATUS_SUCCESS
) {
209 PFX
"Error in Reading the mac Address: %d", result
);
213 result
= register_netdev(net
);
217 gblpnetdev
= Adapter
->dev
;
219 if (netif_msg_probe(Adapter
))
220 dev_info(&udev
->dev
, PFX
"%s: register usb-%s-%s %pM\n",
221 net
->name
, xdev
->bus
->bus_name
, xdev
->devpath
,
227 void unregister_networkdev(struct bcm_mini_adapter
*Adapter
)
229 struct net_device
*net
= Adapter
->dev
;
230 struct bcm_interface_adapter
*IntfAdapter
= Adapter
->pvInterfaceAdapter
;
231 struct usb_interface
*udev
= IntfAdapter
->interface
;
232 struct usb_device
*xdev
= IntfAdapter
->udev
;
234 if (netif_msg_probe(Adapter
))
235 dev_info(&udev
->dev
, PFX
"%s: unregister usb-%s%s\n",
236 net
->name
, xdev
->bus
->bus_name
, xdev
->devpath
);
238 unregister_netdev(Adapter
->dev
);