Lines Matching refs:dev

43 static void sonic_msg_init(struct net_device *dev)  in sonic_msg_init()  argument
45 struct sonic_local *lp = netdev_priv(dev); in sonic_msg_init()
50 netif_dbg(lp, drv, dev, "%s", version); in sonic_msg_init()
53 static int sonic_alloc_descriptors(struct net_device *dev) in sonic_alloc_descriptors() argument
55 struct sonic_local *lp = netdev_priv(dev); in sonic_alloc_descriptors()
96 static int sonic_open(struct net_device *dev) in sonic_open() argument
98 struct sonic_local *lp = netdev_priv(dev); in sonic_open()
101 netif_dbg(lp, ifup, dev, "%s: initializing sonic driver\n", __func__); in sonic_open()
106 struct sk_buff *skb = netdev_alloc_skb(dev, SONIC_RBSIZE + 2); in sonic_open()
114 dev->name); in sonic_open()
137 dev->name); in sonic_open()
146 sonic_init(dev, true); in sonic_open()
148 netif_start_queue(dev); in sonic_open()
150 netif_dbg(lp, ifup, dev, "%s: Initialization done\n", __func__); in sonic_open()
156 static void sonic_quiesce(struct net_device *dev, u16 mask, bool may_sleep) in sonic_quiesce() argument
158 struct sonic_local * __maybe_unused lp = netdev_priv(dev); in sonic_quiesce()
177 static int sonic_close(struct net_device *dev) in sonic_close() argument
179 struct sonic_local *lp = netdev_priv(dev); in sonic_close()
182 netif_dbg(lp, ifdown, dev, "%s\n", __func__); in sonic_close()
184 netif_stop_queue(dev); in sonic_close()
190 sonic_quiesce(dev, SONIC_CR_ALL, true); in sonic_close()
223 static void sonic_tx_timeout(struct net_device *dev, unsigned int txqueue) in sonic_tx_timeout() argument
225 struct sonic_local *lp = netdev_priv(dev); in sonic_tx_timeout()
232 sonic_quiesce(dev, SONIC_CR_ALL, false); in sonic_tx_timeout()
249 sonic_init(dev, false); in sonic_tx_timeout()
251 netif_trans_update(dev); /* prevent tx timeout */ in sonic_tx_timeout()
252 netif_wake_queue(dev); in sonic_tx_timeout()
273 static int sonic_send_packet(struct sk_buff *skb, struct net_device *dev) in sonic_send_packet() argument
275 struct sonic_local *lp = netdev_priv(dev); in sonic_send_packet()
281 netif_dbg(lp, tx_queued, dev, "%s: skb=%p\n", __func__, skb); in sonic_send_packet()
296 pr_err_ratelimited("%s: failed to map tx DMA buffer.\n", dev->name); in sonic_send_packet()
305 sonic_tda_put(dev, entry, SONIC_TD_STATUS, 0); /* clear status */ in sonic_send_packet()
306 sonic_tda_put(dev, entry, SONIC_TD_FRAG_COUNT, 1); /* single fragment */ in sonic_send_packet()
307 sonic_tda_put(dev, entry, SONIC_TD_PKTSIZE, length); /* length of packet */ in sonic_send_packet()
308 sonic_tda_put(dev, entry, SONIC_TD_FRAG_PTR_L, laddr & 0xffff); in sonic_send_packet()
309 sonic_tda_put(dev, entry, SONIC_TD_FRAG_PTR_H, laddr >> 16); in sonic_send_packet()
310 sonic_tda_put(dev, entry, SONIC_TD_FRAG_SIZE, length); in sonic_send_packet()
311 sonic_tda_put(dev, entry, SONIC_TD_LINK, in sonic_send_packet()
312 sonic_tda_get(dev, entry, SONIC_TD_LINK) | SONIC_EOL); in sonic_send_packet()
314 sonic_tda_put(dev, lp->eol_tx, SONIC_TD_LINK, ~SONIC_EOL & in sonic_send_packet()
315 sonic_tda_get(dev, lp->eol_tx, SONIC_TD_LINK)); in sonic_send_packet()
317 netif_dbg(lp, tx_queued, dev, "%s: issuing Tx command\n", __func__); in sonic_send_packet()
330 netif_dbg(lp, tx_queued, dev, "%s: stopping queue\n", __func__); in sonic_send_packet()
331 netif_stop_queue(dev); in sonic_send_packet()
346 struct net_device *dev = dev_id; in sonic_interrupt() local
347 struct sonic_local *lp = netdev_priv(dev); in sonic_interrupt()
369 netif_dbg(lp, intr, dev, "%s: packet rx\n", __func__); in sonic_interrupt()
370 sonic_rx(dev); /* got packet(s) */ in sonic_interrupt()
386 netif_dbg(lp, intr, dev, "%s: tx done\n", __func__); in sonic_interrupt()
389 if ((td_status = sonic_tda_get(dev, entry, SONIC_TD_STATUS)) == 0) in sonic_interrupt()
394 lp->stats.tx_bytes += sonic_tda_get(dev, entry, SONIC_TD_PKTSIZE); in sonic_interrupt()
416 if (sonic_tda_get(dev, entry, SONIC_TD_LINK) & SONIC_EOL) { in sonic_interrupt()
424 netif_wake_queue(dev); /* The ring is no longer full */ in sonic_interrupt()
432 netif_dbg(lp, rx_err, dev, "%s: rx fifo overrun\n", in sonic_interrupt()
436 netif_dbg(lp, rx_err, dev, "%s: rx descriptors exhausted\n", in sonic_interrupt()
440 netif_dbg(lp, rx_err, dev, "%s: rx buffer area exceeded\n", in sonic_interrupt()
456 netif_dbg(lp, tx_err, dev, "%s: TXER intr, TCR %04x\n", in sonic_interrupt()
462 netif_stop_queue(dev); in sonic_interrupt()
470 dev->name); in sonic_interrupt()
500 static bool sonic_alloc_rb(struct net_device *dev, struct sonic_local *lp, in sonic_alloc_rb() argument
503 *new_skb = netdev_alloc_skb(dev, SONIC_RBSIZE + 2); in sonic_alloc_rb()
522 static void sonic_update_rra(struct net_device *dev, struct sonic_local *lp, in sonic_update_rra() argument
525 unsigned int entry = sonic_rr_entry(dev, SONIC_READ(SONIC_RWP)); in sonic_update_rra()
526 unsigned int end = sonic_rr_entry(dev, SONIC_READ(SONIC_RRP)); in sonic_update_rra()
533 buf = (sonic_rra_get(dev, entry, SONIC_RR_BUFADR_H) << 16) | in sonic_update_rra()
534 sonic_rra_get(dev, entry, SONIC_RR_BUFADR_L); in sonic_update_rra()
544 sonic_rra_put(dev, entry, SONIC_RR_BUFADR_H, new_addr >> 16); in sonic_update_rra()
545 sonic_rra_put(dev, entry, SONIC_RR_BUFADR_L, new_addr & 0xffff); in sonic_update_rra()
549 SONIC_WRITE(SONIC_RWP, sonic_rr_addr(dev, entry)); in sonic_update_rra()
555 static void sonic_rx(struct net_device *dev) in sonic_rx() argument
557 struct sonic_local *lp = netdev_priv(dev); in sonic_rx()
562 while (sonic_rda_get(dev, entry, SONIC_RD_IN_USE) == 0) { in sonic_rx()
563 u16 status = sonic_rda_get(dev, entry, SONIC_RD_STATUS); in sonic_rx()
569 u32 addr = (sonic_rda_get(dev, entry, in sonic_rx()
571 sonic_rda_get(dev, entry, SONIC_RD_PKTPTR_L); in sonic_rx()
579 if (sonic_alloc_rb(dev, lp, &new_skb, &new_laddr)) { in sonic_rx()
587 pkt_len = sonic_rda_get(dev, entry, in sonic_rx()
591 dev); in sonic_rx()
607 sonic_update_rra(dev, lp, addr, new_laddr); in sonic_rx()
612 sonic_rda_put(dev, entry, SONIC_RD_STATUS, 0); in sonic_rx()
613 sonic_rda_put(dev, entry, SONIC_RD_IN_USE, 1); in sonic_rx()
623 sonic_rda_put(dev, prev_entry, SONIC_RD_LINK, SONIC_EOL | in sonic_rx()
624 sonic_rda_get(dev, prev_entry, SONIC_RD_LINK)); in sonic_rx()
625 sonic_rda_put(dev, lp->eol_rx, SONIC_RD_LINK, ~SONIC_EOL & in sonic_rx()
626 sonic_rda_get(dev, lp->eol_rx, SONIC_RD_LINK)); in sonic_rx()
639 static struct net_device_stats *sonic_get_stats(struct net_device *dev) in sonic_get_stats() argument
641 struct sonic_local *lp = netdev_priv(dev); in sonic_get_stats()
658 static void sonic_multicast_list(struct net_device *dev) in sonic_multicast_list() argument
660 struct sonic_local *lp = netdev_priv(dev); in sonic_multicast_list()
669 if (dev->flags & IFF_PROMISC) { /* set promiscuous mode */ in sonic_multicast_list()
672 if ((dev->flags & IFF_ALLMULTI) || in sonic_multicast_list()
673 (netdev_mc_count(dev) > 15)) { in sonic_multicast_list()
678 netif_dbg(lp, ifup, dev, "%s: mc_count %d\n", __func__, in sonic_multicast_list()
679 netdev_mc_count(dev)); in sonic_multicast_list()
680 sonic_set_cam_enable(dev, 1); /* always enable our own address */ in sonic_multicast_list()
682 netdev_for_each_mc_addr(ha, dev) { in sonic_multicast_list()
684 sonic_cda_put(dev, i, SONIC_CD_CAP0, addr[1] << 8 | addr[0]); in sonic_multicast_list()
685 sonic_cda_put(dev, i, SONIC_CD_CAP1, addr[3] << 8 | addr[2]); in sonic_multicast_list()
686 sonic_cda_put(dev, i, SONIC_CD_CAP2, addr[5] << 8 | addr[4]); in sonic_multicast_list()
687 sonic_set_cam_enable(dev, sonic_get_cam_enable(dev) | (1 << i)); in sonic_multicast_list()
695 sonic_quiesce(dev, SONIC_CR_TXP, false); in sonic_multicast_list()
697 sonic_quiesce(dev, SONIC_CR_LCAM, false); in sonic_multicast_list()
702 netif_dbg(lp, ifup, dev, "%s: setting RCR=%x\n", __func__, rcr); in sonic_multicast_list()
711 static int sonic_init(struct net_device *dev, bool may_sleep) in sonic_init() argument
713 struct sonic_local *lp = netdev_priv(dev); in sonic_init()
733 sonic_quiesce(dev, SONIC_CR_ALL, may_sleep); in sonic_init()
738 netif_dbg(lp, ifup, dev, "%s: initialize receive resource area\n", in sonic_init()
744 sonic_rra_put(dev, i, SONIC_RR_BUFADR_L, bufadr_l); in sonic_init()
745 sonic_rra_put(dev, i, SONIC_RR_BUFADR_H, bufadr_h); in sonic_init()
746 sonic_rra_put(dev, i, SONIC_RR_BUFSIZE_L, SONIC_RBSIZE >> 1); in sonic_init()
747 sonic_rra_put(dev, i, SONIC_RR_BUFSIZE_H, 0); in sonic_init()
751 SONIC_WRITE(SONIC_RSA, sonic_rr_addr(dev, 0)); in sonic_init()
752 SONIC_WRITE(SONIC_REA, sonic_rr_addr(dev, SONIC_NUM_RRS)); in sonic_init()
753 SONIC_WRITE(SONIC_RRP, sonic_rr_addr(dev, 0)); in sonic_init()
754 SONIC_WRITE(SONIC_RWP, sonic_rr_addr(dev, SONIC_NUM_RRS - 1)); in sonic_init()
759 netif_dbg(lp, ifup, dev, "%s: issuing RRRA command\n", __func__); in sonic_init()
762 sonic_quiesce(dev, SONIC_CR_RRRA, may_sleep); in sonic_init()
769 netif_dbg(lp, ifup, dev, "%s: initialize receive descriptors\n", in sonic_init()
773 sonic_rda_put(dev, i, SONIC_RD_STATUS, 0); in sonic_init()
774 sonic_rda_put(dev, i, SONIC_RD_PKTLEN, 0); in sonic_init()
775 sonic_rda_put(dev, i, SONIC_RD_PKTPTR_L, 0); in sonic_init()
776 sonic_rda_put(dev, i, SONIC_RD_PKTPTR_H, 0); in sonic_init()
777 sonic_rda_put(dev, i, SONIC_RD_SEQNO, 0); in sonic_init()
778 sonic_rda_put(dev, i, SONIC_RD_IN_USE, 1); in sonic_init()
779 sonic_rda_put(dev, i, SONIC_RD_LINK, in sonic_init()
784 sonic_rda_put(dev, SONIC_NUM_RDS - 1, SONIC_RD_LINK, in sonic_init()
794 netif_dbg(lp, ifup, dev, "%s: initialize transmit descriptors\n", in sonic_init()
798 sonic_tda_put(dev, i, SONIC_TD_STATUS, 0); in sonic_init()
799 sonic_tda_put(dev, i, SONIC_TD_CONFIG, 0); in sonic_init()
800 sonic_tda_put(dev, i, SONIC_TD_PKTSIZE, 0); in sonic_init()
801 sonic_tda_put(dev, i, SONIC_TD_FRAG_COUNT, 0); in sonic_init()
802 sonic_tda_put(dev, i, SONIC_TD_LINK, in sonic_init()
808 sonic_tda_put(dev, SONIC_NUM_TDS - 1, SONIC_TD_LINK, in sonic_init()
819 sonic_cda_put(dev, 0, SONIC_CD_CAP0, dev->dev_addr[1] << 8 | dev->dev_addr[0]); in sonic_init()
820 sonic_cda_put(dev, 0, SONIC_CD_CAP1, dev->dev_addr[3] << 8 | dev->dev_addr[2]); in sonic_init()
821 sonic_cda_put(dev, 0, SONIC_CD_CAP2, dev->dev_addr[5] << 8 | dev->dev_addr[4]); in sonic_init()
822 sonic_set_cam_enable(dev, 1); in sonic_init()
825 sonic_cda_put(dev, i, SONIC_CD_ENTRY_POINTER, i); in sonic_init()
837 sonic_quiesce(dev, SONIC_CR_LCAM, may_sleep); in sonic_init()
849 netif_dbg(lp, ifup, dev, "%s: new status=%x\n", __func__, in sonic_init()