Lines Matching refs:ndlc

22 #include "ndlc.h"
54 print_hex_dump(KERN_DEBUG, "ndlc: ", DUMP_PREFIX_OFFSET, \
58 int ndlc_open(struct llt_ndlc *ndlc)
61 ndlc->ops->enable(ndlc->phy_id);
66 void ndlc_close(struct llt_ndlc *ndlc)
69 ndlc->ops->disable(ndlc->phy_id);
73 int ndlc_send(struct llt_ndlc *ndlc, struct sk_buff *skb)
75 /* add ndlc header */
80 skb_queue_tail(&ndlc->send_q, skb);
82 schedule_work(&ndlc->sm_work);
88 static void llt_ndlc_send_queue(struct llt_ndlc *ndlc)
94 if (ndlc->send_q.qlen)
96 ndlc->send_q.qlen, ndlc->ack_pending_q.qlen);
98 while (ndlc->send_q.qlen) {
99 skb = skb_dequeue(&ndlc->send_q);
100 NDLC_DUMP_SKB("ndlc frame written", skb);
101 r = ndlc->ops->write(ndlc->phy_id, skb);
103 ndlc->hard_fault = r;
109 skb_queue_tail(&ndlc->ack_pending_q, skb);
111 /* start timer t1 for ndlc aknowledge */
112 ndlc->t1_active = true;
113 mod_timer(&ndlc->t1_timer, time_sent +
116 ndlc->t2_active = true;
117 mod_timer(&ndlc->t2_timer, time_sent +
122 static void llt_ndlc_requeue_data_pending(struct llt_ndlc *ndlc)
127 while ((skb = skb_dequeue_tail(&ndlc->ack_pending_q))) {
143 skb_queue_head(&ndlc->send_q, skb);
147 static void llt_ndlc_rcv_queue(struct llt_ndlc *ndlc)
153 if (ndlc->rcv_q.qlen)
154 pr_debug("rcvQlen=%d\n", ndlc->rcv_q.qlen);
156 while ((skb = skb_dequeue(&ndlc->rcv_q)) != NULL) {
162 del_timer_sync(&ndlc->t1_timer);
163 del_timer_sync(&ndlc->t2_timer);
164 ndlc->t2_active = false;
165 ndlc->t1_active = false;
168 llt_ndlc_requeue_data_pending(ndlc);
169 llt_ndlc_send_queue(ndlc);
170 /* start timer t1 for ndlc aknowledge */
172 ndlc->t1_active = true;
173 mod_timer(&ndlc->t1_timer, time_sent +
178 ndlc->t1_active = true;
179 mod_timer(&ndlc->t1_timer, time_sent +
188 nci_recv_frame(ndlc->ndev, skb);
195 struct llt_ndlc *ndlc = container_of(work, struct llt_ndlc, sm_work);
197 llt_ndlc_send_queue(ndlc);
198 llt_ndlc_rcv_queue(ndlc);
200 if (ndlc->t1_active && timer_pending(&ndlc->t1_timer) == 0) {
203 ndlc->t1_active = false;
205 llt_ndlc_requeue_data_pending(ndlc);
206 llt_ndlc_send_queue(ndlc);
209 if (ndlc->t2_active && timer_pending(&ndlc->t2_timer) == 0) {
211 ndlc->t2_active = false;
212 ndlc->t1_active = false;
213 del_timer_sync(&ndlc->t1_timer);
214 del_timer_sync(&ndlc->t2_timer);
215 ndlc_close(ndlc);
216 ndlc->hard_fault = -EREMOTEIO;
220 void ndlc_recv(struct llt_ndlc *ndlc, struct sk_buff *skb)
224 ndlc->hard_fault = -EREMOTEIO;
225 ndlc_close(ndlc);
228 skb_queue_tail(&ndlc->rcv_q, skb);
231 schedule_work(&ndlc->sm_work);
237 struct llt_ndlc *ndlc = (struct llt_ndlc *)data;
241 schedule_work(&ndlc->sm_work);
246 struct llt_ndlc *ndlc = (struct llt_ndlc *)data;
250 schedule_work(&ndlc->sm_work);
256 struct llt_ndlc *ndlc;
258 ndlc = devm_kzalloc(dev, sizeof(struct llt_ndlc), GFP_KERNEL);
259 if (!ndlc) {
260 nfc_err(dev, "Cannot allocate memory for ndlc.\n");
263 ndlc->ops = phy_ops;
264 ndlc->phy_id = phy_id;
265 ndlc->dev = dev;
267 *ndlc_id = ndlc;
270 init_timer(&ndlc->t1_timer);
271 ndlc->t1_timer.data = (unsigned long)ndlc;
272 ndlc->t1_timer.function = ndlc_t1_timeout;
274 init_timer(&ndlc->t2_timer);
275 ndlc->t2_timer.data = (unsigned long)ndlc;
276 ndlc->t2_timer.function = ndlc_t2_timeout;
278 skb_queue_head_init(&ndlc->rcv_q);
279 skb_queue_head_init(&ndlc->send_q);
280 skb_queue_head_init(&ndlc->ack_pending_q);
282 INIT_WORK(&ndlc->sm_work, llt_ndlc_sm_work);
284 return st21nfcb_nci_probe(ndlc, phy_headroom, phy_tailroom);
288 void ndlc_remove(struct llt_ndlc *ndlc)
291 del_timer_sync(&ndlc->t1_timer);
292 del_timer_sync(&ndlc->t2_timer);
293 ndlc->t2_active = false;
294 ndlc->t1_active = false;
296 skb_queue_purge(&ndlc->rcv_q);
297 skb_queue_purge(&ndlc->send_q);
299 st21nfcb_nci_remove(ndlc->ndev);
300 kfree(ndlc);