Lines Matching +full:tx +full:- +full:rx

1 // SPDX-License-Identifier: GPL-2.0-only
38 struct plfxlc_usb_tx *tx = &usb->tx; in plfxlc_send_packet_from_data_queue() local
43 spin_lock_irqsave(&tx->lock, flags); in plfxlc_send_packet_from_data_queue()
44 last_served_sidx = usb->sidx; in plfxlc_send_packet_from_data_queue()
46 usb->sidx = (usb->sidx + 1) % MAX_STA_NUM; in plfxlc_send_packet_from_data_queue()
47 if (!(tx->station[usb->sidx].flag & STATION_CONNECTED_FLAG)) in plfxlc_send_packet_from_data_queue()
49 if (!(tx->station[usb->sidx].flag & STATION_FIFO_FULL_FLAG)) in plfxlc_send_packet_from_data_queue()
50 skb = skb_peek(&tx->station[usb->sidx].data_list); in plfxlc_send_packet_from_data_queue()
51 } while ((usb->sidx != last_served_sidx) && (!skb)); in plfxlc_send_packet_from_data_queue()
54 skb = skb_dequeue(&tx->station[usb->sidx].data_list); in plfxlc_send_packet_from_data_queue()
55 plfxlc_usb_wreq_async(usb, skb->data, skb->len, USB_REQ_DATA_TX, in plfxlc_send_packet_from_data_queue()
57 if (skb_queue_len(&tx->station[usb->sidx].data_list) <= 60) in plfxlc_send_packet_from_data_queue()
60 spin_unlock_irqrestore(&tx->lock, flags); in plfxlc_send_packet_from_data_queue()
71 struct plfxlc_usb_tx *tx; in rx_urb_complete() local
83 if (!urb->context) { in rx_urb_complete()
87 usb = urb->context; in rx_urb_complete()
89 if (usb->initialized != 1) { in rx_urb_complete()
94 tx = &usb->tx; in rx_urb_complete()
95 switch (urb->status) { in rx_urb_complete()
98 case -ESHUTDOWN: in rx_urb_complete()
99 case -EINVAL: in rx_urb_complete()
100 case -ENODEV: in rx_urb_complete()
101 case -ENOENT: in rx_urb_complete()
102 case -ECONNRESET: in rx_urb_complete()
103 case -EPIPE: in rx_urb_complete()
104 dev_dbg(plfxlc_urb_dev(urb), "urb %p error %d\n", urb, urb->status); in rx_urb_complete()
107 dev_dbg(plfxlc_urb_dev(urb), "urb %p error %d\n", urb, urb->status); in rx_urb_complete()
108 if (tx->submitted_urbs++ < PURELIFI_URB_RETRY_MAX) { in rx_urb_complete()
110 tx->submitted_urbs++); in rx_urb_complete()
114 tx->submitted_urbs = 0; in rx_urb_complete()
119 buffer = urb->transfer_buffer; in rx_urb_complete()
123 if (urb->actual_length != (PLF_MSG_STATUS_OFFSET + 1)) { in rx_urb_complete()
124 if (usb->initialized && usb->link_up) in rx_urb_complete()
133 dev_dbg(&usb->intf->dev, in rx_urb_complete()
135 tx->mac_fifo_full = 1; in rx_urb_complete()
137 tx->station[sidx].flag |= STATION_FIFO_FULL_FLAG; in rx_urb_complete()
140 dev_dbg(&usb->intf->dev, "FIFO full packet receipt\n"); in rx_urb_complete()
143 tx->station[sidx].flag &= STATION_ACTIVE_FLAG; in rx_urb_complete()
148 usb->link_up = 1; in rx_urb_complete()
149 dev_dbg(&usb->intf->dev, "ST_CONNECT_MSG packet receipt\n"); in rx_urb_complete()
152 usb->link_up = 0; in rx_urb_complete()
153 dev_dbg(&usb->intf->dev, "ST_DISCONN_MSG packet receipt\n"); in rx_urb_complete()
156 dev_dbg(&usb->intf->dev, "Unknown packet receipt\n"); in rx_urb_complete()
177 &urb->transfer_dma); in alloc_rx_urb()
186 urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; in alloc_rx_urb()
195 usb_free_coherent(urb->dev, urb->transfer_buffer_length, in free_rx_urb()
196 urb->transfer_buffer, urb->transfer_dma); in free_rx_urb()
202 struct plfxlc_usb_rx *rx = &usb->rx; in __lf_x_usb_enable_rx() local
206 r = -ENOMEM; in __lf_x_usb_enable_rx()
217 spin_lock_irq(&rx->lock); in __lf_x_usb_enable_rx()
221 if (rx->urbs) { in __lf_x_usb_enable_rx()
222 spin_unlock_irq(&rx->lock); in __lf_x_usb_enable_rx()
226 rx->urbs = urbs; in __lf_x_usb_enable_rx()
227 rx->urbs_count = RX_URBS_COUNT; in __lf_x_usb_enable_rx()
228 spin_unlock_irq(&rx->lock); in __lf_x_usb_enable_rx()
241 spin_lock_irq(&rx->lock); in __lf_x_usb_enable_rx()
242 rx->urbs = NULL; in __lf_x_usb_enable_rx()
243 rx->urbs_count = 0; in __lf_x_usb_enable_rx()
244 spin_unlock_irq(&rx->lock); in __lf_x_usb_enable_rx()
256 struct plfxlc_usb_rx *rx = &usb->rx; in plfxlc_usb_enable_rx() local
259 mutex_lock(&rx->setup_mutex); in plfxlc_usb_enable_rx()
262 usb->rx_usb_enabled = 1; in plfxlc_usb_enable_rx()
264 mutex_unlock(&rx->setup_mutex); in plfxlc_usb_enable_rx()
271 struct plfxlc_usb_rx *rx = &usb->rx; in __lf_x_usb_disable_rx() local
277 spin_lock_irqsave(&rx->lock, flags); in __lf_x_usb_disable_rx()
278 urbs = rx->urbs; in __lf_x_usb_disable_rx()
279 count = rx->urbs_count; in __lf_x_usb_disable_rx()
280 spin_unlock_irqrestore(&rx->lock, flags); in __lf_x_usb_disable_rx()
290 rx->urbs = NULL; in __lf_x_usb_disable_rx()
291 rx->urbs_count = 0; in __lf_x_usb_disable_rx()
296 struct plfxlc_usb_rx *rx = &usb->rx; in plfxlc_usb_disable_rx() local
298 mutex_lock(&rx->setup_mutex); in plfxlc_usb_disable_rx()
300 usb->rx_usb_enabled = 0; in plfxlc_usb_disable_rx()
301 mutex_unlock(&rx->setup_mutex); in plfxlc_usb_disable_rx()
306 struct plfxlc_usb_tx *tx = &usb->tx; in plfxlc_usb_disable_tx() local
309 clear_bit(PLF_BIT_ENABLED, &tx->enabled); in plfxlc_usb_disable_tx()
311 /* kill all submitted tx-urbs */ in plfxlc_usb_disable_tx()
312 usb_kill_anchored_urbs(&tx->submitted); in plfxlc_usb_disable_tx()
314 spin_lock_irqsave(&tx->lock, flags); in plfxlc_usb_disable_tx()
315 WARN_ON(!skb_queue_empty(&tx->submitted_skbs)); in plfxlc_usb_disable_tx()
316 WARN_ON(tx->submitted_urbs != 0); in plfxlc_usb_disable_tx()
317 tx->submitted_urbs = 0; in plfxlc_usb_disable_tx()
318 spin_unlock_irqrestore(&tx->lock, flags); in plfxlc_usb_disable_tx()
327 struct plfxlc_usb_tx *tx = &usb->tx; in plfxlc_usb_enable_tx() local
330 spin_lock_irqsave(&tx->lock, flags); in plfxlc_usb_enable_tx()
331 set_bit(PLF_BIT_ENABLED, &tx->enabled); in plfxlc_usb_enable_tx()
332 tx->submitted_urbs = 0; in plfxlc_usb_enable_tx()
334 tx->stopped = 0; in plfxlc_usb_enable_tx()
335 spin_unlock_irqrestore(&tx->lock, flags); in plfxlc_usb_enable_tx()
344 skb = urb->context; in plfxlc_tx_urb_complete()
349 usb = &plfxlc_hw_mac(info->rate_driver_data[0])->chip.usb; in plfxlc_tx_urb_complete()
351 switch (urb->status) { in plfxlc_tx_urb_complete()
354 case -ESHUTDOWN: in plfxlc_tx_urb_complete()
355 case -EINVAL: in plfxlc_tx_urb_complete()
356 case -ENODEV: in plfxlc_tx_urb_complete()
357 case -ENOENT: in plfxlc_tx_urb_complete()
358 case -ECONNRESET: in plfxlc_tx_urb_complete()
359 case -EPIPE: in plfxlc_tx_urb_complete()
360 dev_dbg(plfxlc_urb_dev(urb), "urb %p error %d\n", urb, urb->status); in plfxlc_tx_urb_complete()
363 dev_dbg(plfxlc_urb_dev(urb), "urb %p error %d\n", urb, urb->status); in plfxlc_tx_urb_complete()
367 plfxlc_mac_tx_to_dev(skb, urb->status); in plfxlc_tx_urb_complete()
374 struct plfxlc_usb_rx *rx = &usb->rx; in init_usb_rx() local
376 spin_lock_init(&rx->lock); in init_usb_rx()
377 mutex_init(&rx->setup_mutex); in init_usb_rx()
379 if (interface_to_usbdev(usb->intf)->speed == USB_SPEED_HIGH) in init_usb_rx()
380 rx->usb_packet_size = 512; in init_usb_rx()
382 rx->usb_packet_size = 64; in init_usb_rx()
384 if (rx->fragment_length != 0) in init_usb_rx()
390 struct plfxlc_usb_tx *tx = &usb->tx; in init_usb_tx() local
392 spin_lock_init(&tx->lock); in init_usb_tx()
393 clear_bit(PLF_BIT_ENABLED, &tx->enabled); in init_usb_tx()
394 tx->stopped = 0; in init_usb_tx()
395 skb_queue_head_init(&tx->submitted_skbs); in init_usb_tx()
396 init_usb_anchor(&tx->submitted); in init_usb_tx()
403 usb->intf = usb_get_intf(intf); in plfxlc_usb_init()
404 usb_set_intfdata(usb->intf, hw); in plfxlc_usb_init()
414 usb_set_intfdata(usb->intf, NULL); in plfxlc_usb_release()
415 usb_put_intf(usb->intf); in plfxlc_usb_release()
450 u8 *buffer_dst = usb_req->buf; in get_usb_req()
453 usb_req->id = cpu_to_be32(usb_req_id); in get_usb_req()
454 usb_req->len = cpu_to_be32(0); in get_usb_req()
457 * for the Rx MAC to know its exact length. in get_usb_req()
459 if (usb_req->id == cpu_to_be32(USB_REQ_BEACON_WR)) { in get_usb_req()
477 memset(buffer_dst, 0, PURELIFI_BYTE_NUM_ALIGNMENT - in get_usb_req()
480 buffer_dst += PURELIFI_BYTE_NUM_ALIGNMENT - in get_usb_req()
483 temp_usb_len += PURELIFI_BYTE_NUM_ALIGNMENT - in get_usb_req()
487 usb_req->len = cpu_to_be32(temp_usb_len); in get_usb_req()
495 struct usb_device *udev = interface_to_usbdev(usb->ez_usb); in plfxlc_usb_wreq_async()
501 return -ENOMEM; in plfxlc_usb_wreq_async()
507 dev_err(&udev->dev, "Async write submit failed (%d)\n", r); in plfxlc_usb_wreq_async()
529 r = -ENOMEM; in plfxlc_usb_wreq()
540 r = -ENOMEM; in plfxlc_usb_wreq()
541 dev_err(&udev->dev, "usb_bulk_msg failed (%d)\n", r); in plfxlc_usb_wreq()
549 struct plfxlc_usb *usb = from_timer(usb, t, tx.tx_retry_timer); in slif_data_plane_sap_timer_callb()
552 timer_setup(&usb->tx.tx_retry_timer, in slif_data_plane_sap_timer_callb()
554 mod_timer(&usb->tx.tx_retry_timer, jiffies + TX_RETRY_BACKOFF_JIFF); in slif_data_plane_sap_timer_callb()
560 struct plfxlc_usb_tx *tx = &usb->tx; in sta_queue_cleanup_timer_callb() local
563 for (sidx = 0; sidx < MAX_STA_NUM - 1; sidx++) { in sta_queue_cleanup_timer_callb()
564 if (!(tx->station[sidx].flag & STATION_CONNECTED_FLAG)) in sta_queue_cleanup_timer_callb()
566 if (tx->station[sidx].flag & STATION_HEARTBEAT_FLAG) { in sta_queue_cleanup_timer_callb()
567 tx->station[sidx].flag ^= STATION_HEARTBEAT_FLAG; in sta_queue_cleanup_timer_callb()
569 eth_zero_addr(tx->station[sidx].mac); in sta_queue_cleanup_timer_callb()
570 tx->station[sidx].flag = 0; in sta_queue_cleanup_timer_callb()
573 timer_setup(&usb->sta_queue_cleanup, in sta_queue_cleanup_timer_callb()
575 mod_timer(&usb->sta_queue_cleanup, jiffies + STA_QUEUE_CLEANUP_JIFF); in sta_queue_cleanup_timer_callb()
583 struct plfxlc_usb_tx *tx; in probe() local
593 r = -ENOMEM; in probe()
597 chip = &plfxlc_hw_mac(hw)->chip; in probe()
598 usb = &chip->usb; in probe()
599 usb->ez_usb = intf; in probe()
600 tx = &usb->tx; in probe()
604 dev_err(&intf->dev, "MAC and Serial upload failed (%d)\n", r); in probe()
608 chip->unit_type = STA; in probe()
609 dev_err(&intf->dev, "Unit type is station"); in probe()
613 dev_err(&intf->dev, "Init mac failed (%d)\n", r); in probe()
619 dev_err(&intf->dev, "Register device failed (%d)\n", r); in probe()
623 if ((le16_to_cpu(interface_to_usbdev(intf)->descriptor.idVendor) == in probe()
625 (le16_to_cpu(interface_to_usbdev(intf)->descriptor.idProduct) == in probe()
632 dev_err(&intf->dev, "FPGA download failed (%d)\n", r); in probe()
636 tx->mac_fifo_full = 0; in probe()
637 spin_lock_init(&tx->lock); in probe()
642 dev_err(&intf->dev, "usb_init_hw failed (%d)\n", r); in probe()
649 dev_dbg(&intf->dev, "chip_switch_radio_on failed (%d)\n", r); in probe()
656 dev_dbg(&intf->dev, "chip_set_rate failed (%d)\n", r); in probe()
661 r = plfxlc_usb_wreq(usb->ez_usb, in probe()
664 dev_dbg(&intf->dev, "MAC_WR failure (%d)\n", r); in probe()
670 /* Initialise the data plane Tx queue */ in probe()
672 skb_queue_head_init(&tx->station[i].data_list); in probe()
673 tx->station[i].flag = 0; in probe()
676 tx->station[STA_BROADCAST_INDEX].flag |= STATION_CONNECTED_FLAG; in probe()
678 tx->station[STA_BROADCAST_INDEX].mac[i] = 0xFF; in probe()
680 timer_setup(&tx->tx_retry_timer, slif_data_plane_sap_timer_callb, 0); in probe()
681 tx->tx_retry_timer.expires = jiffies + TX_RETRY_BACKOFF_JIFF; in probe()
682 add_timer(&tx->tx_retry_timer); in probe()
684 timer_setup(&usb->sta_queue_cleanup, in probe()
686 usb->sta_queue_cleanup.expires = jiffies + STA_QUEUE_CLEANUP_JIFF; in probe()
687 add_timer(&usb->sta_queue_cleanup); in probe()
690 usb->initialized = true; in probe()
698 dev_err(&intf->dev, "pureLifi:Device error"); in probe()
715 usb = &mac->chip.usb; in disconnect()
717 del_timer_sync(&usb->tx.tx_retry_timer); in disconnect()
718 del_timer_sync(&usb->sta_queue_cleanup); in disconnect()
722 plfxlc_chip_disable_rxtx(&mac->chip); in disconnect()
745 if (usb->was_running) in plfxlc_usb_resume()
746 set_bit(PURELIFI_DEVICE_RUNNING, &mac->flags); in plfxlc_usb_resume()
748 usb_queue_reset_device(usb->intf); in plfxlc_usb_resume()
752 if (mac->type != NL80211_IFTYPE_UNSPECIFIED) { in plfxlc_usb_resume()
768 usb->initialized = false; in plfxlc_usb_stop()
777 if (!hw || intf->condition != USB_INTERFACE_BOUND) in pre_reset()
781 usb = &mac->chip.usb; in pre_reset()
783 usb->was_running = test_bit(PURELIFI_DEVICE_RUNNING, &mac->flags); in pre_reset()
796 if (!hw || intf->condition != USB_INTERFACE_BOUND) in post_reset()
800 usb = &mac->chip.usb; in post_reset()
802 if (usb->was_running) in post_reset()
822 return &mac->chip.usb; in get_plfxlc_usb()
832 return -ENODEV; in suspend()
833 if (pl->initialized == 0) in suspend()
835 pl->was_running = test_bit(PURELIFI_DEVICE_RUNNING, &mac->flags); in suspend()
845 return -ENODEV; in resume()
846 if (pl->was_running) in resume()
891 MODULE_FIRMWARE("plfxlc/lifi-x.bin");