Lines Matching full:rx

62 } rx = {  variable
63 .fifo = Z_FIFO_INITIALIZER(rx.fifo),
69 if (cmac_mbox_read(&rx.type, 1) != 1) { in h4_get_type()
71 rx.type = BT_HCI_H4_NONE; in h4_get_type()
75 switch (rx.type) { in h4_get_type()
77 rx.remaining = sizeof(rx.evt); in h4_get_type()
78 rx.hdr_len = rx.remaining; in h4_get_type()
81 rx.remaining = sizeof(rx.acl); in h4_get_type()
82 rx.hdr_len = rx.remaining; in h4_get_type()
86 rx.remaining = sizeof(rx.iso); in h4_get_type()
87 rx.hdr_len = rx.remaining; in h4_get_type()
92 LOG_ERR("Unknown H:4 type 0x%02x", rx.type); in h4_get_type()
93 rx.type = BT_HCI_H4_NONE; in h4_get_type()
99 int bytes_read = rx.hdr_len - rx.remaining; in h4_read_hdr()
102 ret = cmac_mbox_read(rx.hdr + bytes_read, rx.remaining); in h4_read_hdr()
106 rx.remaining -= ret; in h4_read_hdr()
114 if (!rx.remaining) { in get_acl_hdr()
115 struct bt_hci_acl_hdr *hdr = &rx.acl; in get_acl_hdr()
117 rx.remaining = sys_le16_to_cpu(hdr->len); in get_acl_hdr()
118 LOG_DBG("Got ACL header. Payload %u bytes", rx.remaining); in get_acl_hdr()
119 rx.have_hdr = true; in get_acl_hdr()
127 if (!rx.remaining) { in get_iso_hdr()
128 struct bt_hci_iso_hdr *hdr = &rx.iso; in get_iso_hdr()
130 rx.remaining = bt_iso_hdr_len(sys_le16_to_cpu(hdr->len)); in get_iso_hdr()
131 LOG_DBG("Got ISO header. Payload %u bytes", rx.remaining); in get_iso_hdr()
132 rx.have_hdr = true; in get_iso_hdr()
138 struct bt_hci_evt_hdr *hdr = &rx.evt; in get_evt_hdr()
142 if (rx.hdr_len == sizeof(*hdr) && rx.remaining < sizeof(*hdr)) { in get_evt_hdr()
143 switch (rx.evt.evt) { in get_evt_hdr()
145 rx.remaining++; in get_evt_hdr()
146 rx.hdr_len++; in get_evt_hdr()
151 if (!rx.remaining) { in get_evt_hdr()
152 if (rx.evt.evt == BT_HCI_EVT_LE_META_EVENT && in get_evt_hdr()
153 (rx.hdr[sizeof(*hdr)] == BT_HCI_EVT_LE_ADVERTISING_REPORT)) { in get_evt_hdr()
155 rx.discardable = true; in get_evt_hdr()
158 rx.remaining = hdr->len - (rx.hdr_len - sizeof(*hdr)); in get_evt_hdr()
160 rx.have_hdr = true; in get_evt_hdr()
167 net_buf_add_mem(buf, rx.hdr, rx.hdr_len); in copy_hdr()
172 rx.type = BT_HCI_H4_NONE; in reset_rx()
173 rx.remaining = 0U; in reset_rx()
174 rx.have_hdr = false; in reset_rx()
175 rx.hdr_len = 0U; in reset_rx()
176 rx.discardable = false; in reset_rx()
181 LOG_DBG("type 0x%02x, evt 0x%02x", rx.type, rx.evt.evt); in get_rx()
183 switch (rx.type) { in get_rx()
185 return bt_buf_get_evt(rx.evt.evt, rx.discardable, timeout); in get_rx()
199 if (rx.deferred) { in rx_isr_start()
200 rx.deferred = false; in rx_isr_start()
224 LOG_DBG("rx.buf %p", rx.buf); in rx_thread()
230 if (rx.have_hdr && !rx.buf) { in rx_thread()
231 rx.buf = get_rx(K_FOREVER); in rx_thread()
232 LOG_DBG("Got rx.buf %p", rx.buf); in rx_thread()
233 if (rx.remaining > net_buf_tailroom(rx.buf)) { in rx_thread()
235 rx.discard = rx.remaining; in rx_thread()
238 copy_hdr(rx.buf); in rx_thread()
245 buf = k_fifo_get(&rx.fifo, K_FOREVER); in rx_thread()
253 * is receiving data so fast that rx.fifo never in rx_thread()
260 buf = k_fifo_get(&rx.fifo, K_NO_WAIT); in rx_thread()
284 if (!rx.buf) { in read_payload()
287 rx.buf = get_rx(K_NO_WAIT); in read_payload()
288 if (!rx.buf) { in read_payload()
289 if (rx.discardable) { in read_payload()
290 LOG_WRN("Discarding event 0x%02x", rx.evt.evt); in read_payload()
291 rx.discard = rx.remaining; in read_payload()
297 rx.deferred = true; in read_payload()
301 LOG_DBG("Allocated rx.buf %p", rx.buf); in read_payload()
303 buf_tailroom = net_buf_tailroom(rx.buf); in read_payload()
304 if (buf_tailroom < rx.remaining) { in read_payload()
305 LOG_ERR("Not enough space in buffer %u/%zu", rx.remaining, buf_tailroom); in read_payload()
306 rx.discard = rx.remaining; in read_payload()
311 copy_hdr(rx.buf); in read_payload()
314 read = cmac_mbox_read(net_buf_tail(rx.buf), rx.remaining); in read_payload()
320 net_buf_add(rx.buf, read); in read_payload()
321 rx.remaining -= read; in read_payload()
323 LOG_DBG("got %d bytes, remaining %u", read, rx.remaining); in read_payload()
324 LOG_DBG("Payload (len %u): %s", rx.buf->len, bt_hex(rx.buf->data, rx.buf->len)); in read_payload()
326 if (rx.remaining) { in read_payload()
330 buf = rx.buf; in read_payload()
331 rx.buf = NULL; in read_payload()
333 if (rx.type == BT_HCI_H4_EVT) { in read_payload()
341 LOG_DBG("Putting buf %p to rx fifo", buf); in read_payload()
342 k_fifo_put(&rx.fifo, buf); in read_payload()
347 switch (rx.type) { in read_header()
368 if (rx.have_hdr && rx.buf) { in read_header()
369 if (rx.remaining > net_buf_tailroom(rx.buf)) { in read_header()
371 rx.discard = rx.remaining; in read_header()
374 copy_hdr(rx.buf); in read_header()
381 LOG_DBG("remaining %u discard %u have_hdr %u rx.buf %p len %u", rx.remaining, rx.discard, in process_rx()
382 rx.have_hdr, rx.buf, rx.buf ? rx.buf->len : 0); in process_rx()
384 if (rx.discard) { in process_rx()
385 rx.discard -= h4_discard(rx.discard); in process_rx()
389 if (rx.have_hdr) { in process_rx()
399 while (!rx.deferred && cmac_mbox_has_data()) { in cmac_read_req()