Lines Matching defs:pegasus
43 #include "pegasus.h"
52 static const char driver_name[] = "pegasus";
67 #include "pegasus.h"
79 * IDs as the Belkin F5D5050, so we need to teach the pegasus driver to
81 * case anyway, seeing as the pegasus is for "Wired" adaptors.
86 #include "pegasus.h"
115 pegasus_t *pegasus = urb->context;
118 if (!pegasus)
123 if (pegasus->flags & ETH_REGS_CHANGE) {
124 pegasus->flags &= ~ETH_REGS_CHANGE;
125 pegasus->flags |= ETH_REGS_CHANGED;
126 update_eth_regs_async(pegasus);
136 netif_dbg(pegasus, drv, pegasus->net,
140 pegasus->flags &= ~ETH_REGS_CHANGED;
141 wake_up(&pegasus->ctrl_wait);
144 static int get_registers(pegasus_t *pegasus, __u16 indx, __u16 size,
153 netif_warn(pegasus, drv, pegasus->net,
157 add_wait_queue(&pegasus->ctrl_wait, &wait);
159 while (pegasus->flags & ETH_REGS_CHANGED)
161 remove_wait_queue(&pegasus->ctrl_wait, &wait);
164 pegasus->dr.bRequestType = PEGASUS_REQT_READ;
165 pegasus->dr.bRequest = PEGASUS_REQ_GET_REGS;
166 pegasus->dr.wValue = cpu_to_le16(0);
167 pegasus->dr.wIndex = cpu_to_le16(indx);
168 pegasus->dr.wLength = cpu_to_le16(size);
169 pegasus->ctrl_urb->transfer_buffer_length = size;
171 usb_fill_control_urb(pegasus->ctrl_urb, pegasus->usb,
172 usb_rcvctrlpipe(pegasus->usb, 0),
173 (char *) &pegasus->dr,
174 buffer, size, ctrl_callback, pegasus);
176 add_wait_queue(&pegasus->ctrl_wait, &wait);
180 if ((ret = usb_submit_urb(pegasus->ctrl_urb, GFP_ATOMIC))) {
183 netif_device_detach(pegasus->net);
185 netif_err(pegasus, drv, pegasus->net,
192 remove_wait_queue(&pegasus->ctrl_wait, &wait);
199 static int set_registers(pegasus_t *pegasus, __u16 indx, __u16 size,
208 netif_warn(pegasus, drv, pegasus->net,
213 add_wait_queue(&pegasus->ctrl_wait, &wait);
215 while (pegasus->flags & ETH_REGS_CHANGED)
217 remove_wait_queue(&pegasus->ctrl_wait, &wait);
220 pegasus->dr.bRequestType = PEGASUS_REQT_WRITE;
221 pegasus->dr.bRequest = PEGASUS_REQ_SET_REGS;
222 pegasus->dr.wValue = cpu_to_le16(0);
223 pegasus->dr.wIndex = cpu_to_le16(indx);
224 pegasus->dr.wLength = cpu_to_le16(size);
225 pegasus->ctrl_urb->transfer_buffer_length = size;
227 usb_fill_control_urb(pegasus->ctrl_urb, pegasus->usb,
228 usb_sndctrlpipe(pegasus->usb, 0),
229 (char *) &pegasus->dr,
230 buffer, size, ctrl_callback, pegasus);
232 add_wait_queue(&pegasus->ctrl_wait, &wait);
235 if ((ret = usb_submit_urb(pegasus->ctrl_urb, GFP_ATOMIC))) {
237 netif_device_detach(pegasus->net);
238 netif_err(pegasus, drv, pegasus->net,
245 remove_wait_queue(&pegasus->ctrl_wait, &wait);
251 static int set_register(pegasus_t *pegasus, __u16 indx, __u8 data)
259 netif_warn(pegasus, drv, pegasus->net,
263 add_wait_queue(&pegasus->ctrl_wait, &wait);
265 while (pegasus->flags & ETH_REGS_CHANGED)
267 remove_wait_queue(&pegasus->ctrl_wait, &wait);
270 pegasus->dr.bRequestType = PEGASUS_REQT_WRITE;
271 pegasus->dr.bRequest = PEGASUS_REQ_SET_REG;
272 pegasus->dr.wValue = cpu_to_le16(data);
273 pegasus->dr.wIndex = cpu_to_le16(indx);
274 pegasus->dr.wLength = cpu_to_le16(1);
275 pegasus->ctrl_urb->transfer_buffer_length = 1;
277 usb_fill_control_urb(pegasus->ctrl_urb, pegasus->usb,
278 usb_sndctrlpipe(pegasus->usb, 0),
279 (char *) &pegasus->dr,
280 tmp, 1, ctrl_callback, pegasus);
282 add_wait_queue(&pegasus->ctrl_wait, &wait);
285 if ((ret = usb_submit_urb(pegasus->ctrl_urb, GFP_ATOMIC))) {
287 netif_device_detach(pegasus->net);
289 netif_err(pegasus, drv, pegasus->net,
296 remove_wait_queue(&pegasus->ctrl_wait, &wait);
302 static int update_eth_regs_async(pegasus_t *pegasus)
306 pegasus->dr.bRequestType = PEGASUS_REQT_WRITE;
307 pegasus->dr.bRequest = PEGASUS_REQ_SET_REGS;
308 pegasus->dr.wValue = cpu_to_le16(0);
309 pegasus->dr.wIndex = cpu_to_le16(EthCtrl0);
310 pegasus->dr.wLength = cpu_to_le16(3);
311 pegasus->ctrl_urb->transfer_buffer_length = 3;
313 usb_fill_control_urb(pegasus->ctrl_urb, pegasus->usb,
314 usb_sndctrlpipe(pegasus->usb, 0),
315 (char *) &pegasus->dr,
316 pegasus->eth_regs, 3, ctrl_callback, pegasus);
318 if ((ret = usb_submit_urb(pegasus->ctrl_urb, GFP_ATOMIC))) {
320 netif_device_detach(pegasus->net);
321 netif_err(pegasus, drv, pegasus->net,
329 static int read_mii_word(pegasus_t *pegasus, __u8 phy, __u8 indx, __u16 *regd)
336 set_register(pegasus, PhyCtrl, 0);
337 set_registers(pegasus, PhyAddr, sizeof(data), data);
338 set_register(pegasus, PhyCtrl, (indx | PHY_READ));
340 ret = get_registers(pegasus, PhyCtrl, 1, data);
350 ret = get_registers(pegasus, PhyData, 2, ®di);
355 netif_warn(pegasus, drv, pegasus->net, "%s failed\n", __func__);
362 pegasus_t *pegasus = (pegasus_t *) netdev_priv(dev);
365 read_mii_word(pegasus, phy_id, loc, &res);
369 static int write_mii_word(pegasus_t *pegasus, __u8 phy, __u8 indx, __u16 regd)
377 set_register(pegasus, PhyCtrl, 0);
378 set_registers(pegasus, PhyAddr, sizeof(data), data);
379 set_register(pegasus, PhyCtrl, (indx | PHY_WRITE));
381 ret = get_registers(pegasus, PhyCtrl, 1, data);
394 netif_warn(pegasus, drv, pegasus->net, "%s failed\n", __func__);
400 pegasus_t *pegasus = (pegasus_t *) netdev_priv(dev);
402 write_mii_word(pegasus, phy_id, loc, val);
405 static int read_eprom_word(pegasus_t *pegasus, __u8 index, __u16 *retdata)
412 set_register(pegasus, EpromCtrl, 0);
413 set_register(pegasus, EpromOffset, index);
414 set_register(pegasus, EpromCtrl, EPROM_READ);
417 ret = get_registers(pegasus, EpromCtrl, 1, &tmp);
426 ret = get_registers(pegasus, EpromData, 2, &retdatai);
431 netif_warn(pegasus, drv, pegasus->net, "%s failed\n", __func__);
436 static inline void enable_eprom_write(pegasus_t *pegasus)
441 get_registers(pegasus, EthCtrl2, 1, &tmp);
442 set_register(pegasus, EthCtrl2, tmp | EPROM_WR_ENABLE);
445 static inline void disable_eprom_write(pegasus_t *pegasus)
450 get_registers(pegasus, EthCtrl2, 1, &tmp);
451 set_register(pegasus, EpromCtrl, 0);
452 set_register(pegasus, EthCtrl2, tmp & ~EPROM_WR_ENABLE);
455 static int write_eprom_word(pegasus_t *pegasus, __u8 index, __u16 data)
462 set_registers(pegasus, EpromOffset, 4, d);
463 enable_eprom_write(pegasus);
464 set_register(pegasus, EpromOffset, index);
465 set_registers(pegasus, EpromData, 2, &le_data);
466 set_register(pegasus, EpromCtrl, EPROM_WRITE);
469 ret = get_registers(pegasus, EpromCtrl, 1, &tmp);
475 disable_eprom_write(pegasus);
482 netif_warn(pegasus, drv, pegasus->net, "%s failed\n", __func__);
487 static inline void get_node_id(pegasus_t *pegasus, __u8 *id)
493 read_eprom_word(pegasus, i, &w16);
498 static void set_ethernet_addr(pegasus_t *pegasus)
502 if (pegasus->features & PEGASUS_II) {
503 get_registers(pegasus, 0x10, sizeof(node_id), node_id);
505 get_node_id(pegasus, node_id);
506 set_registers(pegasus, EthID, sizeof(node_id), node_id);
508 memcpy(pegasus->net->dev_addr, node_id, sizeof(node_id));
511 static inline int reset_mac(pegasus_t *pegasus)
516 set_register(pegasus, EthCtrl1, data);
518 get_registers(pegasus, EthCtrl1, 1, &data);
522 if (mii_mode && (pegasus->features & HAS_HOME_PNA))
523 set_register(pegasus, Gpio1, 0x34);
525 set_register(pegasus, Gpio1, 0x26);
526 set_register(pegasus, Gpio0, pegasus->features);
527 set_register(pegasus, Gpio0, DEFAULT_GPIO_SET);
534 if (usb_dev_id[pegasus->dev_index].vendor == VENDOR_LINKSYS ||
535 usb_dev_id[pegasus->dev_index].vendor == VENDOR_DLINK) {
536 set_register(pegasus, Gpio0, 0x24);
537 set_register(pegasus, Gpio0, 0x26);
539 if (usb_dev_id[pegasus->dev_index].vendor == VENDOR_ELCON) {
541 read_mii_word(pegasus, 3, 0x1b, &auxmode);
542 write_mii_word(pegasus, 3, 0x1b, auxmode | 4);
552 pegasus_t *pegasus = netdev_priv(dev);
555 read_mii_word(pegasus, pegasus->phy, MII_LPA, &linkpart);
566 memcpy(pegasus->eth_regs, data, sizeof(data));
567 ret = set_registers(pegasus, EthCtrl0, 3, data);
569 if (usb_dev_id[pegasus->dev_index].vendor == VENDOR_LINKSYS ||
570 usb_dev_id[pegasus->dev_index].vendor == VENDOR_LINKSYS2 ||
571 usb_dev_id[pegasus->dev_index].vendor == VENDOR_DLINK) {
573 read_mii_word(pegasus, 0, 0x1b, &auxmode);
574 write_mii_word(pegasus, 0, 0x1b, auxmode | 4);
580 static void fill_skb_pool(pegasus_t *pegasus)
585 if (pegasus->rx_pool[i])
587 pegasus->rx_pool[i] = dev_alloc_skb(PEGASUS_MTU + 2);
592 if (pegasus->rx_pool[i] == NULL)
594 skb_reserve(pegasus->rx_pool[i], 2);
598 static void free_skb_pool(pegasus_t *pegasus)
603 if (pegasus->rx_pool[i]) {
604 dev_kfree_skb(pegasus->rx_pool[i]);
605 pegasus->rx_pool[i] = NULL;
610 static inline struct sk_buff *pull_skb(pegasus_t * pegasus)
616 if (likely(pegasus->rx_pool[i] != NULL)) {
617 skb = pegasus->rx_pool[i];
618 pegasus->rx_pool[i] = NULL;
627 pegasus_t *pegasus = urb->context;
634 if (!pegasus)
637 net = pegasus->net;
645 netif_dbg(pegasus, rx_err, net, "reset MAC\n");
646 pegasus->flags &= ~PEGASUS_RX_BUSY;
649 netif_warn(pegasus, rx_err, net, "no rx stall recovery\n");
654 netif_dbg(pegasus, ifdown, net, "rx unlink, %d\n", status);
657 netif_dbg(pegasus, rx_err, net, "RX status %d\n", status);
666 netif_dbg(pegasus, rx_err, net,
668 pegasus->stats.rx_errors++;
670 pegasus->stats.rx_length_errors++;
672 pegasus->stats.rx_crc_errors++;
674 pegasus->stats.rx_frame_errors++;
677 if (pegasus->chip == 0x8513) {
680 pegasus->rx_skb->data += 2;
696 * at this point we are sure pegasus->rx_skb != NULL
699 skb_put(pegasus->rx_skb, pkt_len);
700 pegasus->rx_skb->protocol = eth_type_trans(pegasus->rx_skb, net);
701 netif_rx(pegasus->rx_skb);
702 pegasus->stats.rx_packets++;
703 pegasus->stats.rx_bytes += pkt_len;
705 if (pegasus->flags & PEGASUS_UNPLUG)
708 spin_lock(&pegasus->rx_pool_lock);
709 pegasus->rx_skb = pull_skb(pegasus);
710 spin_unlock(&pegasus->rx_pool_lock);
712 if (pegasus->rx_skb == NULL)
715 usb_fill_bulk_urb(pegasus->rx_urb, pegasus->usb,
716 usb_rcvbulkpipe(pegasus->usb, 1),
717 pegasus->rx_skb->data, PEGASUS_MTU + 8,
718 read_bulk_callback, pegasus);
719 rx_status = usb_submit_urb(pegasus->rx_urb, GFP_ATOMIC);
721 netif_device_detach(pegasus->net);
723 pegasus->flags |= PEGASUS_RX_URB_FAIL;
726 pegasus->flags &= ~PEGASUS_RX_URB_FAIL;
732 tasklet_schedule(&pegasus->rx_tl);
737 pegasus_t *pegasus;
741 pegasus = (pegasus_t *) data;
742 if (pegasus->flags & PEGASUS_UNPLUG)
745 spin_lock_irqsave(&pegasus->rx_pool_lock, flags);
746 fill_skb_pool(pegasus);
747 if (pegasus->flags & PEGASUS_RX_URB_FAIL)
748 if (pegasus->rx_skb)
750 if (pegasus->rx_skb == NULL)
751 pegasus->rx_skb = pull_skb(pegasus);
752 if (pegasus->rx_skb == NULL) {
753 netif_warn(pegasus, rx_err, pegasus->net, "low on memory\n");
754 tasklet_schedule(&pegasus->rx_tl);
757 usb_fill_bulk_urb(pegasus->rx_urb, pegasus->usb,
758 usb_rcvbulkpipe(pegasus->usb, 1),
759 pegasus->rx_skb->data, PEGASUS_MTU + 8,
760 read_bulk_callback, pegasus);
762 status = usb_submit_urb(pegasus->rx_urb, GFP_ATOMIC);
764 netif_device_detach(pegasus->net);
766 pegasus->flags |= PEGASUS_RX_URB_FAIL;
767 tasklet_schedule(&pegasus->rx_tl);
769 pegasus->flags &= ~PEGASUS_RX_URB_FAIL;
772 spin_unlock_irqrestore(&pegasus->rx_pool_lock, flags);
777 pegasus_t *pegasus = urb->context;
781 if (!pegasus)
784 net = pegasus->net;
792 netif_warn(pegasus, tx_err, net, "no tx stall recovery\n");
797 netif_dbg(pegasus, ifdown, net, "tx unlink, %d\n", status);
800 netif_info(pegasus, tx_err, net, "TX status %d\n", status);
812 pegasus_t *pegasus = urb->context;
816 if (!pegasus)
818 net = pegasus->net;
831 netif_dbg(pegasus, timer, net, "intr status %d\n", status);
840 pegasus->stats.tx_errors++;
842 pegasus->stats.tx_fifo_errors++;
844 pegasus->stats.tx_aborted_errors++;
846 pegasus->stats.tx_window_errors++;
855 pegasus->stats.rx_missed_errors += ((d[3] & 0x7f) << 8) | d[4];
860 netif_device_detach(pegasus->net);
862 netif_err(pegasus, timer, net,
868 pegasus_t *pegasus = netdev_priv(net);
869 netif_warn(pegasus, timer, net, "tx timeout\n");
870 usb_unlink_urb(pegasus->tx_urb);
871 pegasus->stats.tx_errors++;
877 pegasus_t *pegasus = netdev_priv(net);
884 ((__le16 *) pegasus->tx_buff)[0] = cpu_to_le16(l16);
885 skb_copy_from_linear_data(skb, pegasus->tx_buff + 2, skb->len);
886 usb_fill_bulk_urb(pegasus->tx_urb, pegasus->usb,
887 usb_sndbulkpipe(pegasus->usb, 2),
888 pegasus->tx_buff, count,
889 write_bulk_callback, pegasus);
890 if ((res = usb_submit_urb(pegasus->tx_urb, GFP_ATOMIC))) {
891 netif_warn(pegasus, tx_err, net, "fail tx, %d\n", res);
898 netif_device_detach(pegasus->net);
901 pegasus->stats.tx_errors++;
905 pegasus->stats.tx_packets++;
906 pegasus->stats.tx_bytes += skb->len;
918 static inline void disable_net_traffic(pegasus_t *pegasus)
922 set_registers(pegasus, EthCtrl0, sizeof(tmp), &tmp);
925 static inline void get_interrupt_interval(pegasus_t *pegasus)
930 read_eprom_word(pegasus, 4, &data);
932 if (pegasus->usb->speed != USB_SPEED_HIGH) {
934 netif_info(pegasus, timer, pegasus->net,
940 write_eprom_word(pegasus, 4, data);
944 pegasus->intr_interval = interval;
949 pegasus_t *pegasus = netdev_priv(net);
952 if (read_mii_word(pegasus, pegasus->phy, MII_BMSR, &tmp))
961 static void free_all_urbs(pegasus_t *pegasus)
963 usb_free_urb(pegasus->intr_urb);
964 usb_free_urb(pegasus->tx_urb);
965 usb_free_urb(pegasus->rx_urb);
966 usb_free_urb(pegasus->ctrl_urb);
969 static void unlink_all_urbs(pegasus_t *pegasus)
971 usb_kill_urb(pegasus->intr_urb);
972 usb_kill_urb(pegasus->tx_urb);
973 usb_kill_urb(pegasus->rx_urb);
974 usb_kill_urb(pegasus->ctrl_urb);
977 static int alloc_urbs(pegasus_t *pegasus)
979 pegasus->ctrl_urb = usb_alloc_urb(0, GFP_KERNEL);
980 if (!pegasus->ctrl_urb)
982 pegasus->rx_urb = usb_alloc_urb(0, GFP_KERNEL);
983 if (!pegasus->rx_urb) {
984 usb_free_urb(pegasus->ctrl_urb);
987 pegasus->tx_urb = usb_alloc_urb(0, GFP_KERNEL);
988 if (!pegasus->tx_urb) {
989 usb_free_urb(pegasus->rx_urb);
990 usb_free_urb(pegasus->ctrl_urb);
993 pegasus->intr_urb = usb_alloc_urb(0, GFP_KERNEL);
994 if (!pegasus->intr_urb) {
995 usb_free_urb(pegasus->tx_urb);
996 usb_free_urb(pegasus->rx_urb);
997 usb_free_urb(pegasus->ctrl_urb);
1006 pegasus_t *pegasus = netdev_priv(net);
1009 if (pegasus->rx_skb == NULL)
1010 pegasus->rx_skb = pull_skb(pegasus);
1014 if (!pegasus->rx_skb)
1017 res = set_registers(pegasus, EthID, 6, net->dev_addr);
1019 usb_fill_bulk_urb(pegasus->rx_urb, pegasus->usb,
1020 usb_rcvbulkpipe(pegasus->usb, 1),
1021 pegasus->rx_skb->data, PEGASUS_MTU + 8,
1022 read_bulk_callback, pegasus);
1023 if ((res = usb_submit_urb(pegasus->rx_urb, GFP_KERNEL))) {
1025 netif_device_detach(pegasus->net);
1026 netif_dbg(pegasus, ifup, net, "failed rx_urb, %d\n", res);
1030 usb_fill_int_urb(pegasus->intr_urb, pegasus->usb,
1031 usb_rcvintpipe(pegasus->usb, 3),
1032 pegasus->intr_buff, sizeof(pegasus->intr_buff),
1033 intr_callback, pegasus, pegasus->intr_interval);
1034 if ((res = usb_submit_urb(pegasus->intr_urb, GFP_KERNEL))) {
1036 netif_device_detach(pegasus->net);
1037 netif_dbg(pegasus, ifup, net, "failed intr_urb, %d\n", res);
1038 usb_kill_urb(pegasus->rx_urb);
1041 if ((res = enable_net_traffic(net, pegasus->usb))) {
1042 netif_dbg(pegasus, ifup, net,
1045 usb_kill_urb(pegasus->rx_urb);
1046 usb_kill_urb(pegasus->intr_urb);
1047 free_skb_pool(pegasus);
1052 netif_dbg(pegasus, ifup, net, "open\n");
1060 pegasus_t *pegasus = netdev_priv(net);
1063 if (!(pegasus->flags & PEGASUS_UNPLUG))
1064 disable_net_traffic(pegasus);
1065 tasklet_kill(&pegasus->rx_tl);
1066 unlink_all_urbs(pegasus);
1074 pegasus_t *pegasus = netdev_priv(dev);
1077 usb_make_path(pegasus->usb, info->bus_info, sizeof(info->bus_info));
1086 pegasus_t *pegasus = netdev_priv(dev);
1089 wol->wolopts = pegasus->wolopts;
1095 pegasus_t *pegasus = netdev_priv(dev);
1106 pegasus->eth_regs[0] |= 0x10;
1108 pegasus->eth_regs[0] &= ~0x10;
1109 pegasus->wolopts = wol->wolopts;
1110 return set_register(pegasus, WakeupControl, reg78);
1124 pegasus_t *pegasus;
1126 pegasus = netdev_priv(dev);
1127 mii_ethtool_gset(&pegasus->mii, ecmd);
1134 pegasus_t *pegasus = netdev_priv(dev);
1135 return mii_ethtool_sset(&pegasus->mii, ecmd);
1140 pegasus_t *pegasus = netdev_priv(dev);
1141 return mii_nway_restart(&pegasus->mii);
1146 pegasus_t *pegasus = netdev_priv(dev);
1147 return mii_link_ok(&pegasus->mii);
1152 pegasus_t *pegasus = netdev_priv(dev);
1153 return pegasus->msg_enable;
1158 pegasus_t *pegasus = netdev_priv(dev);
1159 pegasus->msg_enable = v;
1177 pegasus_t *pegasus = netdev_priv(net);
1182 data[0] = pegasus->phy;
1184 read_mii_word(pegasus, data[0], data[1] & 0x1f, &data[3]);
1190 write_mii_word(pegasus, pegasus->phy, data[1] & 0x1f, data[2]);
1201 pegasus_t *pegasus = netdev_priv(net);
1204 pegasus->eth_regs[EthCtrl2] |= RX_PROMISCUOUS;
1205 netif_info(pegasus, link, net, "Promiscuous mode enabled\n");
1207 pegasus->eth_regs[EthCtrl0] |= RX_MULTICAST;
1208 pegasus->eth_regs[EthCtrl2] &= ~RX_PROMISCUOUS;
1209 netif_dbg(pegasus, link, net, "set allmulti\n");
1211 pegasus->eth_regs[EthCtrl0] &= ~RX_MULTICAST;
1212 pegasus->eth_regs[EthCtrl2] &= ~RX_PROMISCUOUS;
1215 pegasus->ctrl_urb->status = 0;
1217 pegasus->flags |= ETH_REGS_CHANGE;
1218 ctrl_callback(pegasus->ctrl_urb);
1221 static __u8 mii_phy_probe(pegasus_t *pegasus)
1227 read_mii_word(pegasus, i, MII_BMSR, &tmp);
1237 static inline void setup_pegasus_II(pegasus_t *pegasus)
1241 set_register(pegasus, Reg1d, 0);
1242 set_register(pegasus, Reg7b, 1);
1244 if ((pegasus->features & HAS_HOME_PNA) && mii_mode)
1245 set_register(pegasus, Reg7b, 0);
1247 set_register(pegasus, Reg7b, 2);
1249 set_register(pegasus, 0x83, data);
1250 get_registers(pegasus, 0x83, 1, &data);
1253 pegasus->chip = 0x8513;
1255 pegasus->chip = 0;
1257 set_register(pegasus, 0x80, 0xc0);
1258 set_register(pegasus, 0x83, 0xff);
1259 set_register(pegasus, 0x84, 0x01);
1261 if (pegasus->features & HAS_HOME_PNA && mii_mode)
1262 set_register(pegasus, Reg81, 6);
1264 set_register(pegasus, Reg81, 2);
1274 pegasus_t *pegasus = container_of(work, pegasus_t, carrier_check.work);
1275 set_carrier(pegasus->net);
1276 if (!(pegasus->flags & PEGASUS_UNPLUG)) {
1277 queue_delayed_work(pegasus_workqueue, &pegasus->carrier_check,
1315 pegasus_t *pegasus;
1323 pegasus_workqueue = create_singlethread_workqueue("pegasus");
1331 net = alloc_etherdev(sizeof(struct pegasus));
1337 pegasus = netdev_priv(net);
1338 pegasus->dev_index = dev_index;
1339 init_waitqueue_head(&pegasus->ctrl_wait);
1341 if (!alloc_urbs(pegasus)) {
1346 tasklet_init(&pegasus->rx_tl, rx_fixup, (unsigned long) pegasus);
1348 INIT_DELAYED_WORK(&pegasus->carrier_check, check_carrier);
1350 pegasus->intf = intf;
1351 pegasus->usb = dev;
1352 pegasus->net = net;
1358 pegasus->mii.dev = net;
1359 pegasus->mii.mdio_read = mdio_read;
1360 pegasus->mii.mdio_write = mdio_write;
1361 pegasus->mii.phy_id_mask = 0x1f;
1362 pegasus->mii.reg_num_mask = 0x1f;
1363 spin_lock_init(&pegasus->rx_pool_lock);
1364 pegasus->msg_enable = netif_msg_init(msg_level, NETIF_MSG_DRV
1367 pegasus->features = usb_dev_id[dev_index].private;
1368 get_interrupt_interval(pegasus);
1369 if (reset_mac(pegasus)) {
1374 set_ethernet_addr(pegasus);
1375 fill_skb_pool(pegasus);
1376 if (pegasus->features & PEGASUS_II) {
1378 setup_pegasus_II(pegasus);
1380 pegasus->phy = mii_phy_probe(pegasus);
1381 if (pegasus->phy == 0xff) {
1383 pegasus->phy = 1;
1385 pegasus->mii.phy_id = pegasus->phy;
1386 usb_set_intfdata(intf, pegasus);
1392 queue_delayed_work(pegasus_workqueue, &pegasus->carrier_check,
1403 free_skb_pool(pegasus);
1405 free_all_urbs(pegasus);
1416 struct pegasus *pegasus = usb_get_intfdata(intf);
1419 if (!pegasus) {
1424 pegasus->flags |= PEGASUS_UNPLUG;
1425 cancel_delayed_work(&pegasus->carrier_check);
1426 unregister_netdev(pegasus->net);
1428 unlink_all_urbs(pegasus);
1429 free_all_urbs(pegasus);
1430 free_skb_pool(pegasus);
1431 if (pegasus->rx_skb != NULL) {
1432 dev_kfree_skb(pegasus->rx_skb);
1433 pegasus->rx_skb = NULL;
1435 free_netdev(pegasus->net);
1441 struct pegasus *pegasus = usb_get_intfdata(intf);
1443 netif_device_detach(pegasus->net);
1444 cancel_delayed_work(&pegasus->carrier_check);
1445 if (netif_running(pegasus->net)) {
1446 usb_kill_urb(pegasus->rx_urb);
1447 usb_kill_urb(pegasus->intr_urb);
1454 struct pegasus *pegasus = usb_get_intfdata(intf);
1456 netif_device_attach(pegasus->net);
1457 if (netif_running(pegasus->net)) {
1458 pegasus->rx_urb->status = 0;
1459 pegasus->rx_urb->actual_length = 0;
1460 read_bulk_callback(pegasus->rx_urb);
1462 pegasus->intr_urb->status = 0;
1463 pegasus->intr_urb->actual_length = 0;
1464 intr_callback(pegasus->intr_urb);
1466 queue_delayed_work(pegasus_workqueue, &pegasus->carrier_check,