Lines Matching refs:cfhsi
71 struct cfhsi *cfhsi = (struct cfhsi *)arg; in cfhsi_inactivity_tout() local
73 netdev_dbg(cfhsi->ndev, "%s.\n", in cfhsi_inactivity_tout()
77 if (!test_bit(CFHSI_SHUTDOWN, &cfhsi->bits)) in cfhsi_inactivity_tout()
78 queue_work(cfhsi->wq, &cfhsi->wake_down_work); in cfhsi_inactivity_tout()
81 static void cfhsi_update_aggregation_stats(struct cfhsi *cfhsi, in cfhsi_update_aggregation_stats() argument
89 hpad = 1 + PAD_POW2((info->hdr_len + 1), cfhsi->cfg.head_align); in cfhsi_update_aggregation_stats()
90 tpad = PAD_POW2((skb->len + hpad), cfhsi->cfg.tail_align); in cfhsi_update_aggregation_stats()
94 cfhsi->aggregation_len += len; in cfhsi_update_aggregation_stats()
96 cfhsi->aggregation_len -= len; in cfhsi_update_aggregation_stats()
99 static bool cfhsi_can_send_aggregate(struct cfhsi *cfhsi) in cfhsi_can_send_aggregate() argument
103 if (cfhsi->cfg.aggregation_timeout == 0) in cfhsi_can_send_aggregate()
107 if (cfhsi->qhead[i].qlen) in cfhsi_can_send_aggregate()
112 if (cfhsi->qhead[CFHSI_PRIO_BEBK].qlen >= CFHSI_MAX_PKTS) in cfhsi_can_send_aggregate()
118 static struct sk_buff *cfhsi_dequeue(struct cfhsi *cfhsi) in cfhsi_dequeue() argument
124 skb = skb_dequeue(&cfhsi->qhead[i]); in cfhsi_dequeue()
132 static int cfhsi_tx_queue_len(struct cfhsi *cfhsi) in cfhsi_tx_queue_len() argument
136 len += skb_queue_len(&cfhsi->qhead[i]); in cfhsi_tx_queue_len()
140 static void cfhsi_abort_tx(struct cfhsi *cfhsi) in cfhsi_abort_tx() argument
145 spin_lock_bh(&cfhsi->lock); in cfhsi_abort_tx()
146 skb = cfhsi_dequeue(cfhsi); in cfhsi_abort_tx()
150 cfhsi->ndev->stats.tx_errors++; in cfhsi_abort_tx()
151 cfhsi->ndev->stats.tx_dropped++; in cfhsi_abort_tx()
152 cfhsi_update_aggregation_stats(cfhsi, skb, -1); in cfhsi_abort_tx()
153 spin_unlock_bh(&cfhsi->lock); in cfhsi_abort_tx()
156 cfhsi->tx_state = CFHSI_TX_STATE_IDLE; in cfhsi_abort_tx()
157 if (!test_bit(CFHSI_SHUTDOWN, &cfhsi->bits)) in cfhsi_abort_tx()
158 mod_timer(&cfhsi->inactivity_timer, in cfhsi_abort_tx()
159 jiffies + cfhsi->cfg.inactivity_timeout); in cfhsi_abort_tx()
160 spin_unlock_bh(&cfhsi->lock); in cfhsi_abort_tx()
163 static int cfhsi_flush_fifo(struct cfhsi *cfhsi) in cfhsi_flush_fifo() argument
169 netdev_dbg(cfhsi->ndev, "%s.\n", in cfhsi_flush_fifo()
173 ret = cfhsi->ops->cfhsi_fifo_occupancy(cfhsi->ops, in cfhsi_flush_fifo()
176 netdev_warn(cfhsi->ndev, in cfhsi_flush_fifo()
185 set_bit(CFHSI_FLUSH_FIFO, &cfhsi->bits); in cfhsi_flush_fifo()
186 ret = cfhsi->ops->cfhsi_rx(buffer, fifo_occupancy, in cfhsi_flush_fifo()
187 cfhsi->ops); in cfhsi_flush_fifo()
189 clear_bit(CFHSI_FLUSH_FIFO, &cfhsi->bits); in cfhsi_flush_fifo()
190 netdev_warn(cfhsi->ndev, in cfhsi_flush_fifo()
197 ret = wait_event_interruptible_timeout(cfhsi->flush_fifo_wait, in cfhsi_flush_fifo()
198 !test_bit(CFHSI_FLUSH_FIFO, &cfhsi->bits), ret); in cfhsi_flush_fifo()
201 netdev_warn(cfhsi->ndev, in cfhsi_flush_fifo()
207 netdev_warn(cfhsi->ndev, in cfhsi_flush_fifo()
217 static int cfhsi_tx_frm(struct cfhsi_desc *desc, struct cfhsi *cfhsi) in cfhsi_tx_frm() argument
224 skb = cfhsi_dequeue(cfhsi); in cfhsi_tx_frm()
240 hpad = 1 + PAD_POW2((info->hdr_len + 1), cfhsi->cfg.head_align); in cfhsi_tx_frm()
241 tpad = PAD_POW2((skb->len + hpad), cfhsi->cfg.tail_align); in cfhsi_tx_frm()
251 spin_lock_bh(&cfhsi->lock); in cfhsi_tx_frm()
252 cfhsi->ndev->stats.tx_packets++; in cfhsi_tx_frm()
253 cfhsi->ndev->stats.tx_bytes += skb->len; in cfhsi_tx_frm()
254 cfhsi_update_aggregation_stats(cfhsi, skb, -1); in cfhsi_tx_frm()
255 spin_unlock_bh(&cfhsi->lock); in cfhsi_tx_frm()
274 skb = cfhsi_dequeue(cfhsi); in cfhsi_tx_frm()
282 hpad = 1 + PAD_POW2((info->hdr_len + 1), cfhsi->cfg.head_align); in cfhsi_tx_frm()
283 tpad = PAD_POW2((skb->len + hpad), cfhsi->cfg.tail_align); in cfhsi_tx_frm()
293 spin_lock_bh(&cfhsi->lock); in cfhsi_tx_frm()
294 cfhsi->ndev->stats.tx_packets++; in cfhsi_tx_frm()
295 cfhsi->ndev->stats.tx_bytes += skb->len; in cfhsi_tx_frm()
296 cfhsi_update_aggregation_stats(cfhsi, skb, -1); in cfhsi_tx_frm()
297 spin_unlock_bh(&cfhsi->lock); in cfhsi_tx_frm()
323 if (cfhsi_can_send_aggregate(cfhsi)) in cfhsi_tx_frm()
331 static void cfhsi_start_tx(struct cfhsi *cfhsi) in cfhsi_start_tx() argument
333 struct cfhsi_desc *desc = (struct cfhsi_desc *)cfhsi->tx_buf; in cfhsi_start_tx()
336 netdev_dbg(cfhsi->ndev, "%s.\n", __func__); in cfhsi_start_tx()
338 if (test_bit(CFHSI_SHUTDOWN, &cfhsi->bits)) in cfhsi_start_tx()
343 len = cfhsi_tx_frm(desc, cfhsi); in cfhsi_start_tx()
345 spin_lock_bh(&cfhsi->lock); in cfhsi_start_tx()
346 if (unlikely(cfhsi_tx_queue_len(cfhsi))) { in cfhsi_start_tx()
347 spin_unlock_bh(&cfhsi->lock); in cfhsi_start_tx()
351 cfhsi->tx_state = CFHSI_TX_STATE_IDLE; in cfhsi_start_tx()
353 mod_timer(&cfhsi->inactivity_timer, in cfhsi_start_tx()
354 jiffies + cfhsi->cfg.inactivity_timeout); in cfhsi_start_tx()
355 spin_unlock_bh(&cfhsi->lock); in cfhsi_start_tx()
360 res = cfhsi->ops->cfhsi_tx(cfhsi->tx_buf, len, cfhsi->ops); in cfhsi_start_tx()
362 netdev_err(cfhsi->ndev, "%s: TX error %d.\n", in cfhsi_start_tx()
367 static void cfhsi_tx_done(struct cfhsi *cfhsi) in cfhsi_tx_done() argument
369 netdev_dbg(cfhsi->ndev, "%s.\n", __func__); in cfhsi_tx_done()
371 if (test_bit(CFHSI_SHUTDOWN, &cfhsi->bits)) in cfhsi_tx_done()
378 spin_lock_bh(&cfhsi->lock); in cfhsi_tx_done()
379 if (cfhsi->flow_off_sent && in cfhsi_tx_done()
380 cfhsi_tx_queue_len(cfhsi) <= cfhsi->cfg.q_low_mark && in cfhsi_tx_done()
381 cfhsi->cfdev.flowctrl) { in cfhsi_tx_done()
383 cfhsi->flow_off_sent = 0; in cfhsi_tx_done()
384 cfhsi->cfdev.flowctrl(cfhsi->ndev, ON); in cfhsi_tx_done()
387 if (cfhsi_can_send_aggregate(cfhsi)) { in cfhsi_tx_done()
388 spin_unlock_bh(&cfhsi->lock); in cfhsi_tx_done()
389 cfhsi_start_tx(cfhsi); in cfhsi_tx_done()
391 mod_timer(&cfhsi->aggregation_timer, in cfhsi_tx_done()
392 jiffies + cfhsi->cfg.aggregation_timeout); in cfhsi_tx_done()
393 spin_unlock_bh(&cfhsi->lock); in cfhsi_tx_done()
401 struct cfhsi *cfhsi; in cfhsi_tx_done_cb() local
403 cfhsi = container_of(cb_ops, struct cfhsi, cb_ops); in cfhsi_tx_done_cb()
404 netdev_dbg(cfhsi->ndev, "%s.\n", in cfhsi_tx_done_cb()
407 if (test_bit(CFHSI_SHUTDOWN, &cfhsi->bits)) in cfhsi_tx_done_cb()
409 cfhsi_tx_done(cfhsi); in cfhsi_tx_done_cb()
412 static int cfhsi_rx_desc(struct cfhsi_desc *desc, struct cfhsi *cfhsi) in cfhsi_rx_desc() argument
421 netdev_err(cfhsi->ndev, "%s: Invalid descriptor.\n", in cfhsi_rx_desc()
443 netdev_err(cfhsi->ndev, "%s: Invalid length.\n", in cfhsi_rx_desc()
451 netdev_err(cfhsi->ndev, "%s: Out of memory !\n", in cfhsi_rx_desc()
462 skb->dev = cfhsi->ndev; in cfhsi_rx_desc()
475 cfhsi->ndev->stats.rx_packets++; in cfhsi_rx_desc()
476 cfhsi->ndev->stats.rx_bytes += len; in cfhsi_rx_desc()
492 netdev_err(cfhsi->ndev, in cfhsi_rx_desc()
529 static int cfhsi_rx_pld(struct cfhsi_desc *desc, struct cfhsi *cfhsi) in cfhsi_rx_pld() argument
539 netdev_err(cfhsi->ndev, "%s: Invalid descriptor.\n", in cfhsi_rx_pld()
549 while (nfrms < cfhsi->rx_state.nfrms) { in cfhsi_rx_pld()
573 netdev_err(cfhsi->ndev, "%s: Invalid length.\n", in cfhsi_rx_pld()
581 netdev_err(cfhsi->ndev, "%s: Out of memory !\n", in cfhsi_rx_pld()
583 cfhsi->rx_state.nfrms = nfrms; in cfhsi_rx_pld()
593 skb->dev = cfhsi->ndev; in cfhsi_rx_pld()
605 cfhsi->ndev->stats.rx_packets++; in cfhsi_rx_pld()
606 cfhsi->ndev->stats.rx_bytes += len; in cfhsi_rx_pld()
617 static void cfhsi_rx_done(struct cfhsi *cfhsi) in cfhsi_rx_done() argument
625 desc = (struct cfhsi_desc *)cfhsi->rx_buf; in cfhsi_rx_done()
627 netdev_dbg(cfhsi->ndev, "%s\n", __func__); in cfhsi_rx_done()
629 if (test_bit(CFHSI_SHUTDOWN, &cfhsi->bits)) in cfhsi_rx_done()
633 spin_lock_bh(&cfhsi->lock); in cfhsi_rx_done()
634 mod_timer_pending(&cfhsi->inactivity_timer, in cfhsi_rx_done()
635 jiffies + cfhsi->cfg.inactivity_timeout); in cfhsi_rx_done()
636 spin_unlock_bh(&cfhsi->lock); in cfhsi_rx_done()
638 if (cfhsi->rx_state.state == CFHSI_RX_STATE_DESC) { in cfhsi_rx_done()
644 rx_buf = cfhsi->rx_buf; in cfhsi_rx_done()
649 rx_buf = cfhsi->rx_flip_buf; in cfhsi_rx_done()
651 rx_buf = cfhsi->rx_flip_buf; in cfhsi_rx_done()
654 if (cfhsi->rx_state.pld_len > 0 && in cfhsi_rx_done()
659 cfhsi->rx_state.pld_len); in cfhsi_rx_done()
661 cfhsi->rx_state.piggy_desc = true; in cfhsi_rx_done()
693 if (test_bit(CFHSI_AWAKE, &cfhsi->bits)) { in cfhsi_rx_done()
695 netdev_dbg(cfhsi->ndev, "%s: Start RX.\n", in cfhsi_rx_done()
698 res = cfhsi->ops->cfhsi_rx(rx_ptr, rx_len, in cfhsi_rx_done()
699 cfhsi->ops); in cfhsi_rx_done()
701 netdev_err(cfhsi->ndev, "%s: RX error %d.\n", in cfhsi_rx_done()
703 cfhsi->ndev->stats.rx_errors++; in cfhsi_rx_done()
704 cfhsi->ndev->stats.rx_dropped++; in cfhsi_rx_done()
708 if (cfhsi->rx_state.state == CFHSI_RX_STATE_DESC) { in cfhsi_rx_done()
710 if (cfhsi_rx_desc(desc, cfhsi) < 0) in cfhsi_rx_done()
714 if (cfhsi_rx_pld(desc, cfhsi) < 0) in cfhsi_rx_done()
718 if (cfhsi_rx_desc(piggy_desc, cfhsi) < 0) in cfhsi_rx_done()
726 memset(&cfhsi->rx_state, 0, sizeof(cfhsi->rx_state)); in cfhsi_rx_done()
727 cfhsi->rx_state.state = rx_state; in cfhsi_rx_done()
728 cfhsi->rx_ptr = rx_ptr; in cfhsi_rx_done()
729 cfhsi->rx_len = rx_len; in cfhsi_rx_done()
730 cfhsi->rx_state.pld_len = desc_pld_len; in cfhsi_rx_done()
731 cfhsi->rx_state.piggy_desc = desc->header & CFHSI_PIGGY_DESC; in cfhsi_rx_done()
733 if (rx_buf != cfhsi->rx_buf) in cfhsi_rx_done()
734 swap(cfhsi->rx_buf, cfhsi->rx_flip_buf); in cfhsi_rx_done()
738 netdev_err(cfhsi->ndev, "%s: Out of sync.\n", __func__); in cfhsi_rx_done()
740 cfhsi->rx_buf, CFHSI_DESC_SZ); in cfhsi_rx_done()
741 schedule_work(&cfhsi->out_of_sync_work); in cfhsi_rx_done()
746 struct cfhsi *cfhsi = (struct cfhsi *)arg; in cfhsi_rx_slowpath() local
748 netdev_dbg(cfhsi->ndev, "%s.\n", in cfhsi_rx_slowpath()
751 cfhsi_rx_done(cfhsi); in cfhsi_rx_slowpath()
756 struct cfhsi *cfhsi; in cfhsi_rx_done_cb() local
758 cfhsi = container_of(cb_ops, struct cfhsi, cb_ops); in cfhsi_rx_done_cb()
759 netdev_dbg(cfhsi->ndev, "%s.\n", in cfhsi_rx_done_cb()
762 if (test_bit(CFHSI_SHUTDOWN, &cfhsi->bits)) in cfhsi_rx_done_cb()
765 if (test_and_clear_bit(CFHSI_FLUSH_FIFO, &cfhsi->bits)) in cfhsi_rx_done_cb()
766 wake_up_interruptible(&cfhsi->flush_fifo_wait); in cfhsi_rx_done_cb()
768 cfhsi_rx_done(cfhsi); in cfhsi_rx_done_cb()
773 struct cfhsi *cfhsi = NULL; in cfhsi_wake_up() local
778 cfhsi = container_of(work, struct cfhsi, wake_up_work); in cfhsi_wake_up()
780 if (test_bit(CFHSI_SHUTDOWN, &cfhsi->bits)) in cfhsi_wake_up()
783 if (unlikely(test_bit(CFHSI_AWAKE, &cfhsi->bits))) { in cfhsi_wake_up()
786 clear_bit(CFHSI_WAKE_UP, &cfhsi->bits); in cfhsi_wake_up()
787 clear_bit(CFHSI_WAKE_UP_ACK, &cfhsi->bits); in cfhsi_wake_up()
792 cfhsi->ops->cfhsi_wake_up(cfhsi->ops); in cfhsi_wake_up()
794 netdev_dbg(cfhsi->ndev, "%s: Start waiting.\n", in cfhsi_wake_up()
799 ret = wait_event_interruptible_timeout(cfhsi->wake_up_wait, in cfhsi_wake_up()
801 &cfhsi->bits), ret); in cfhsi_wake_up()
804 netdev_err(cfhsi->ndev, "%s: Signalled: %ld.\n", in cfhsi_wake_up()
807 clear_bit(CFHSI_WAKE_UP, &cfhsi->bits); in cfhsi_wake_up()
808 cfhsi->ops->cfhsi_wake_down(cfhsi->ops); in cfhsi_wake_up()
815 netdev_dbg(cfhsi->ndev, "%s: Timeout.\n", in cfhsi_wake_up()
819 WARN_ON(cfhsi->ops->cfhsi_fifo_occupancy(cfhsi->ops, in cfhsi_wake_up()
822 netdev_dbg(cfhsi->ndev, "%s: Bytes in FIFO: %u.\n", in cfhsi_wake_up()
826 WARN_ON(cfhsi->ops->cfhsi_get_peer_wake(cfhsi->ops, in cfhsi_wake_up()
830 netdev_err(cfhsi->ndev, "%s: CA Wake missed !.\n", in cfhsi_wake_up()
834 clear_bit(CFHSI_WAKE_UP_ACK, &cfhsi->bits); in cfhsi_wake_up()
840 clear_bit(CFHSI_WAKE_UP, &cfhsi->bits); in cfhsi_wake_up()
841 cfhsi->ops->cfhsi_wake_down(cfhsi->ops); in cfhsi_wake_up()
845 netdev_dbg(cfhsi->ndev, "%s: Woken.\n", in cfhsi_wake_up()
849 set_bit(CFHSI_AWAKE, &cfhsi->bits); in cfhsi_wake_up()
850 clear_bit(CFHSI_WAKE_UP, &cfhsi->bits); in cfhsi_wake_up()
853 netdev_dbg(cfhsi->ndev, "%s: Start RX.\n", __func__); in cfhsi_wake_up()
854 res = cfhsi->ops->cfhsi_rx(cfhsi->rx_ptr, cfhsi->rx_len, cfhsi->ops); in cfhsi_wake_up()
857 netdev_err(cfhsi->ndev, "%s: RX err %d.\n", __func__, res); in cfhsi_wake_up()
860 clear_bit(CFHSI_WAKE_UP_ACK, &cfhsi->bits); in cfhsi_wake_up()
862 spin_lock_bh(&cfhsi->lock); in cfhsi_wake_up()
865 if (!cfhsi_tx_queue_len(cfhsi)) { in cfhsi_wake_up()
866 netdev_dbg(cfhsi->ndev, "%s: Peer wake, start timer.\n", in cfhsi_wake_up()
869 mod_timer(&cfhsi->inactivity_timer, in cfhsi_wake_up()
870 jiffies + cfhsi->cfg.inactivity_timeout); in cfhsi_wake_up()
871 spin_unlock_bh(&cfhsi->lock); in cfhsi_wake_up()
875 netdev_dbg(cfhsi->ndev, "%s: Host wake.\n", in cfhsi_wake_up()
878 spin_unlock_bh(&cfhsi->lock); in cfhsi_wake_up()
881 len = cfhsi_tx_frm((struct cfhsi_desc *)cfhsi->tx_buf, cfhsi); in cfhsi_wake_up()
885 res = cfhsi->ops->cfhsi_tx(cfhsi->tx_buf, len, cfhsi->ops); in cfhsi_wake_up()
887 netdev_err(cfhsi->ndev, "%s: TX error %d.\n", in cfhsi_wake_up()
889 cfhsi_abort_tx(cfhsi); in cfhsi_wake_up()
892 netdev_err(cfhsi->ndev, in cfhsi_wake_up()
901 struct cfhsi *cfhsi = NULL; in cfhsi_wake_down() local
905 cfhsi = container_of(work, struct cfhsi, wake_down_work); in cfhsi_wake_down()
906 netdev_dbg(cfhsi->ndev, "%s.\n", __func__); in cfhsi_wake_down()
908 if (test_bit(CFHSI_SHUTDOWN, &cfhsi->bits)) in cfhsi_wake_down()
912 cfhsi->ops->cfhsi_wake_down(cfhsi->ops); in cfhsi_wake_down()
916 ret = wait_event_interruptible_timeout(cfhsi->wake_down_wait, in cfhsi_wake_down()
918 &cfhsi->bits), ret); in cfhsi_wake_down()
921 netdev_err(cfhsi->ndev, "%s: Signalled: %ld.\n", in cfhsi_wake_down()
928 netdev_err(cfhsi->ndev, "%s: Timeout.\n", __func__); in cfhsi_wake_down()
931 WARN_ON(cfhsi->ops->cfhsi_get_peer_wake(cfhsi->ops, in cfhsi_wake_down()
934 netdev_err(cfhsi->ndev, "%s: CA Wake missed !.\n", in cfhsi_wake_down()
940 WARN_ON(cfhsi->ops->cfhsi_fifo_occupancy(cfhsi->ops, in cfhsi_wake_down()
952 netdev_err(cfhsi->ndev, "%s: FIFO Timeout.\n", __func__); in cfhsi_wake_down()
955 clear_bit(CFHSI_AWAKE, &cfhsi->bits); in cfhsi_wake_down()
958 cfhsi->ops->cfhsi_rx_cancel(cfhsi->ops); in cfhsi_wake_down()
963 struct cfhsi *cfhsi = NULL; in cfhsi_out_of_sync() local
965 cfhsi = container_of(work, struct cfhsi, out_of_sync_work); in cfhsi_out_of_sync()
968 dev_close(cfhsi->ndev); in cfhsi_out_of_sync()
974 struct cfhsi *cfhsi = NULL; in cfhsi_wake_up_cb() local
976 cfhsi = container_of(cb_ops, struct cfhsi, cb_ops); in cfhsi_wake_up_cb()
977 netdev_dbg(cfhsi->ndev, "%s.\n", in cfhsi_wake_up_cb()
980 set_bit(CFHSI_WAKE_UP_ACK, &cfhsi->bits); in cfhsi_wake_up_cb()
981 wake_up_interruptible(&cfhsi->wake_up_wait); in cfhsi_wake_up_cb()
983 if (test_bit(CFHSI_SHUTDOWN, &cfhsi->bits)) in cfhsi_wake_up_cb()
987 if (!test_and_set_bit(CFHSI_WAKE_UP, &cfhsi->bits)) in cfhsi_wake_up_cb()
988 queue_work(cfhsi->wq, &cfhsi->wake_up_work); in cfhsi_wake_up_cb()
993 struct cfhsi *cfhsi = NULL; in cfhsi_wake_down_cb() local
995 cfhsi = container_of(cb_ops, struct cfhsi, cb_ops); in cfhsi_wake_down_cb()
996 netdev_dbg(cfhsi->ndev, "%s.\n", in cfhsi_wake_down_cb()
1000 set_bit(CFHSI_WAKE_DOWN_ACK, &cfhsi->bits); in cfhsi_wake_down_cb()
1001 wake_up_interruptible(&cfhsi->wake_down_wait); in cfhsi_wake_down_cb()
1006 struct cfhsi *cfhsi = (struct cfhsi *)arg; in cfhsi_aggregation_tout() local
1008 netdev_dbg(cfhsi->ndev, "%s.\n", in cfhsi_aggregation_tout()
1011 cfhsi_start_tx(cfhsi); in cfhsi_aggregation_tout()
1016 struct cfhsi *cfhsi = NULL; in cfhsi_xmit() local
1024 cfhsi = netdev_priv(dev); in cfhsi_xmit()
1044 spin_lock_bh(&cfhsi->lock); in cfhsi_xmit()
1047 cfhsi_update_aggregation_stats(cfhsi, skb, 1); in cfhsi_xmit()
1050 skb_queue_tail(&cfhsi->qhead[prio], skb); in cfhsi_xmit()
1053 if (WARN_ON(test_bit(CFHSI_SHUTDOWN, &cfhsi->bits))) { in cfhsi_xmit()
1054 spin_unlock_bh(&cfhsi->lock); in cfhsi_xmit()
1055 cfhsi_abort_tx(cfhsi); in cfhsi_xmit()
1060 if (!cfhsi->flow_off_sent && in cfhsi_xmit()
1061 cfhsi_tx_queue_len(cfhsi) > cfhsi->cfg.q_high_mark && in cfhsi_xmit()
1062 cfhsi->cfdev.flowctrl) { in cfhsi_xmit()
1063 cfhsi->flow_off_sent = 1; in cfhsi_xmit()
1064 cfhsi->cfdev.flowctrl(cfhsi->ndev, OFF); in cfhsi_xmit()
1067 if (cfhsi->tx_state == CFHSI_TX_STATE_IDLE) { in cfhsi_xmit()
1068 cfhsi->tx_state = CFHSI_TX_STATE_XFER; in cfhsi_xmit()
1075 cfhsi_can_send_aggregate(cfhsi) && in cfhsi_xmit()
1076 del_timer(&cfhsi->aggregation_timer) > 0; in cfhsi_xmit()
1077 spin_unlock_bh(&cfhsi->lock); in cfhsi_xmit()
1079 cfhsi_start_tx(cfhsi); in cfhsi_xmit()
1084 timer_active = del_timer_sync(&cfhsi->inactivity_timer); in cfhsi_xmit()
1086 spin_unlock_bh(&cfhsi->lock); in cfhsi_xmit()
1089 struct cfhsi_desc *desc = (struct cfhsi_desc *)cfhsi->tx_buf; in cfhsi_xmit()
1094 len = cfhsi_tx_frm(desc, cfhsi); in cfhsi_xmit()
1098 res = cfhsi->ops->cfhsi_tx(cfhsi->tx_buf, len, cfhsi->ops); in cfhsi_xmit()
1100 netdev_err(cfhsi->ndev, "%s: TX error %d.\n", in cfhsi_xmit()
1102 cfhsi_abort_tx(cfhsi); in cfhsi_xmit()
1106 if (!test_and_set_bit(CFHSI_WAKE_UP, &cfhsi->bits)) in cfhsi_xmit()
1107 queue_work(cfhsi->wq, &cfhsi->wake_up_work); in cfhsi_xmit()
1118 struct cfhsi *cfhsi = netdev_priv(dev); in cfhsi_setup() local
1127 skb_queue_head_init(&cfhsi->qhead[i]); in cfhsi_setup()
1128 cfhsi->cfdev.link_select = CAIF_LINK_HIGH_BANDW; in cfhsi_setup()
1129 cfhsi->cfdev.use_frag = false; in cfhsi_setup()
1130 cfhsi->cfdev.use_stx = false; in cfhsi_setup()
1131 cfhsi->cfdev.use_fcs = false; in cfhsi_setup()
1132 cfhsi->ndev = dev; in cfhsi_setup()
1133 cfhsi->cfg = hsi_default_config; in cfhsi_setup()
1138 struct cfhsi *cfhsi = netdev_priv(ndev); in cfhsi_open() local
1141 clear_bit(CFHSI_SHUTDOWN, &cfhsi->bits); in cfhsi_open()
1144 cfhsi->tx_state = CFHSI_TX_STATE_IDLE; in cfhsi_open()
1145 cfhsi->rx_state.state = CFHSI_RX_STATE_DESC; in cfhsi_open()
1148 cfhsi->flow_off_sent = 0; in cfhsi_open()
1154 cfhsi->tx_buf = kzalloc(CFHSI_BUF_SZ_TX, GFP_KERNEL); in cfhsi_open()
1155 if (!cfhsi->tx_buf) { in cfhsi_open()
1164 cfhsi->rx_buf = kzalloc(CFHSI_BUF_SZ_RX, GFP_KERNEL); in cfhsi_open()
1165 if (!cfhsi->rx_buf) { in cfhsi_open()
1170 cfhsi->rx_flip_buf = kzalloc(CFHSI_BUF_SZ_RX, GFP_KERNEL); in cfhsi_open()
1171 if (!cfhsi->rx_flip_buf) { in cfhsi_open()
1177 cfhsi->cfg.aggregation_timeout = hsi_default_config.aggregation_timeout; in cfhsi_open()
1180 cfhsi->rx_ptr = cfhsi->rx_buf; in cfhsi_open()
1181 cfhsi->rx_len = CFHSI_DESC_SZ; in cfhsi_open()
1184 spin_lock_init(&cfhsi->lock); in cfhsi_open()
1187 cfhsi->cb_ops.tx_done_cb = cfhsi_tx_done_cb; in cfhsi_open()
1188 cfhsi->cb_ops.rx_done_cb = cfhsi_rx_done_cb; in cfhsi_open()
1189 cfhsi->cb_ops.wake_up_cb = cfhsi_wake_up_cb; in cfhsi_open()
1190 cfhsi->cb_ops.wake_down_cb = cfhsi_wake_down_cb; in cfhsi_open()
1193 INIT_WORK(&cfhsi->wake_up_work, cfhsi_wake_up); in cfhsi_open()
1194 INIT_WORK(&cfhsi->wake_down_work, cfhsi_wake_down); in cfhsi_open()
1195 INIT_WORK(&cfhsi->out_of_sync_work, cfhsi_out_of_sync); in cfhsi_open()
1198 clear_bit(CFHSI_WAKE_UP_ACK, &cfhsi->bits); in cfhsi_open()
1199 clear_bit(CFHSI_WAKE_DOWN_ACK, &cfhsi->bits); in cfhsi_open()
1200 clear_bit(CFHSI_WAKE_UP, &cfhsi->bits); in cfhsi_open()
1201 clear_bit(CFHSI_AWAKE, &cfhsi->bits); in cfhsi_open()
1204 cfhsi->wq = create_singlethread_workqueue(cfhsi->ndev->name); in cfhsi_open()
1205 if (!cfhsi->wq) { in cfhsi_open()
1206 netdev_err(cfhsi->ndev, "%s: Failed to create work queue.\n", in cfhsi_open()
1213 init_waitqueue_head(&cfhsi->wake_up_wait); in cfhsi_open()
1214 init_waitqueue_head(&cfhsi->wake_down_wait); in cfhsi_open()
1215 init_waitqueue_head(&cfhsi->flush_fifo_wait); in cfhsi_open()
1218 init_timer(&cfhsi->inactivity_timer); in cfhsi_open()
1219 cfhsi->inactivity_timer.data = (unsigned long)cfhsi; in cfhsi_open()
1220 cfhsi->inactivity_timer.function = cfhsi_inactivity_tout; in cfhsi_open()
1222 init_timer(&cfhsi->rx_slowpath_timer); in cfhsi_open()
1223 cfhsi->rx_slowpath_timer.data = (unsigned long)cfhsi; in cfhsi_open()
1224 cfhsi->rx_slowpath_timer.function = cfhsi_rx_slowpath; in cfhsi_open()
1226 init_timer(&cfhsi->aggregation_timer); in cfhsi_open()
1227 cfhsi->aggregation_timer.data = (unsigned long)cfhsi; in cfhsi_open()
1228 cfhsi->aggregation_timer.function = cfhsi_aggregation_tout; in cfhsi_open()
1231 res = cfhsi->ops->cfhsi_up(cfhsi->ops); in cfhsi_open()
1233 netdev_err(cfhsi->ndev, in cfhsi_open()
1240 res = cfhsi_flush_fifo(cfhsi); in cfhsi_open()
1242 netdev_err(cfhsi->ndev, "%s: Can't flush FIFO: %d.\n", in cfhsi_open()
1249 cfhsi->ops->cfhsi_down(cfhsi->ops); in cfhsi_open()
1251 destroy_workqueue(cfhsi->wq); in cfhsi_open()
1253 kfree(cfhsi->rx_flip_buf); in cfhsi_open()
1255 kfree(cfhsi->rx_buf); in cfhsi_open()
1257 kfree(cfhsi->tx_buf); in cfhsi_open()
1264 struct cfhsi *cfhsi = netdev_priv(ndev); in cfhsi_close() local
1268 set_bit(CFHSI_SHUTDOWN, &cfhsi->bits); in cfhsi_close()
1271 flush_workqueue(cfhsi->wq); in cfhsi_close()
1274 del_timer_sync(&cfhsi->inactivity_timer); in cfhsi_close()
1275 del_timer_sync(&cfhsi->rx_slowpath_timer); in cfhsi_close()
1276 del_timer_sync(&cfhsi->aggregation_timer); in cfhsi_close()
1279 cfhsi->ops->cfhsi_rx_cancel(cfhsi->ops); in cfhsi_close()
1282 destroy_workqueue(cfhsi->wq); in cfhsi_close()
1285 tx_buf = cfhsi->tx_buf; in cfhsi_close()
1286 rx_buf = cfhsi->rx_buf; in cfhsi_close()
1287 flip_buf = cfhsi->rx_flip_buf; in cfhsi_close()
1289 cfhsi_abort_tx(cfhsi); in cfhsi_close()
1292 cfhsi->ops->cfhsi_down(cfhsi->ops); in cfhsi_close()
1303 struct cfhsi *cfhsi = netdev_priv(dev); in cfhsi_uninit() local
1306 list_del(&cfhsi->list); in cfhsi_uninit()
1316 static void cfhsi_netlink_parms(struct nlattr *data[], struct cfhsi *cfhsi) in cfhsi_netlink_parms() argument
1333 cfhsi->cfg.inactivity_timeout = inactivity_timeout * HZ / 1000; in cfhsi_netlink_parms()
1334 if (cfhsi->cfg.inactivity_timeout == 0) in cfhsi_netlink_parms()
1335 cfhsi->cfg.inactivity_timeout = 1; in cfhsi_netlink_parms()
1336 else if (cfhsi->cfg.inactivity_timeout > NEXT_TIMER_MAX_DELTA) in cfhsi_netlink_parms()
1337 cfhsi->cfg.inactivity_timeout = NEXT_TIMER_MAX_DELTA; in cfhsi_netlink_parms()
1342 cfhsi->cfg.aggregation_timeout = nla_get_u32(data[i]); in cfhsi_netlink_parms()
1346 cfhsi->cfg.head_align = nla_get_u32(data[i]); in cfhsi_netlink_parms()
1350 cfhsi->cfg.tail_align = nla_get_u32(data[i]); in cfhsi_netlink_parms()
1354 cfhsi->cfg.q_high_mark = nla_get_u32(data[i]); in cfhsi_netlink_parms()
1358 cfhsi->cfg.q_low_mark = nla_get_u32(data[i]); in cfhsi_netlink_parms()
1389 struct cfhsi *cfhsi = netdev_priv(dev); in caif_hsi_fill_info() local
1392 cfhsi->cfg.inactivity_timeout) || in caif_hsi_fill_info()
1394 cfhsi->cfg.aggregation_timeout) || in caif_hsi_fill_info()
1396 cfhsi->cfg.head_align) || in caif_hsi_fill_info()
1398 cfhsi->cfg.tail_align) || in caif_hsi_fill_info()
1400 cfhsi->cfg.q_high_mark) || in caif_hsi_fill_info()
1402 cfhsi->cfg.q_low_mark)) in caif_hsi_fill_info()
1411 struct cfhsi *cfhsi = NULL; in caif_hsi_newlink() local
1416 cfhsi = netdev_priv(dev); in caif_hsi_newlink()
1417 cfhsi_netlink_parms(data, cfhsi); in caif_hsi_newlink()
1426 cfhsi->ops = (*get_ops)(); in caif_hsi_newlink()
1427 if (!cfhsi->ops) { in caif_hsi_newlink()
1433 cfhsi->ops->cb_ops = &cfhsi->cb_ops; in caif_hsi_newlink()
1439 list_add_tail(&cfhsi->list, &cfhsi_list); in caif_hsi_newlink()
1449 .priv_size = sizeof(struct cfhsi),
1463 struct cfhsi *cfhsi; in cfhsi_exit_module() local
1469 cfhsi = list_entry(list_node, struct cfhsi, list); in cfhsi_exit_module()
1470 unregister_netdev(cfhsi->ndev); in cfhsi_exit_module()