Lines Matching full:rx
43 #define XACT_SEG_DATA(_seg) (&link.rx.buf->data[XACT_SEG_OFFSET(_seg)])
44 #define XACT_SEG_RECV(_seg) (link.rx.seg &= ~(1 << (_seg)))
90 } rx; member
143 static struct pb_adv link = { .rx = { .buf = &rx_buf } };
146 static void link_open(struct prov_rx *rx, struct net_buf_simple *buf);
147 static void link_ack(struct prov_rx *rx, struct net_buf_simple *buf);
148 static void link_close(struct prov_rx *rx, struct net_buf_simple *buf);
351 link.rx.id = XACT_ID_NVAL; in reset_adv_link()
362 link.rx.id = XACT_ID_MAX; in reset_adv_link()
367 link.rx.buf = &rx_buf; in reset_adv_link()
368 net_buf_simple_reset(link.rx.buf); in reset_adv_link()
417 if (!bt_mesh_fcs_check(link.rx.buf, link.rx.fcs)) { in prov_msg_recv()
422 gen_prov_ack_send(link.rx.id); in prov_msg_recv()
425 LOG_WRN("Unexpected msg 0x%02x on invalidated link", link.rx.buf->data[0]); in prov_msg_recv()
430 link.cb->recv(&bt_mesh_pb_adv, link.cb_data, link.rx.buf); in prov_msg_recv()
441 link.rx.seg = 0U; in protocol_timeout()
481 static void gen_prov_cont(struct prov_rx *rx, struct net_buf_simple *buf) in gen_prov_cont() argument
483 uint8_t seg = CONT_SEG_INDEX(rx->gpc); in gen_prov_cont()
492 if (!link.rx.seg && link.rx.id == rx->xact_id) { in gen_prov_cont()
495 gen_prov_ack_send(rx->xact_id); in gen_prov_cont()
501 if (!link.rx.seg && in gen_prov_cont()
502 next_transaction_id(link.rx.id) == rx->xact_id) { in gen_prov_cont()
505 link.rx.id = rx->xact_id; in gen_prov_cont()
507 net_buf_simple_reset(link.rx.buf); in gen_prov_cont()
509 link.rx.seg = SEG_NVAL; in gen_prov_cont()
510 link.rx.last_seg = SEG_NVAL; in gen_prov_cont()
513 } else if (rx->xact_id != link.rx.id) { in gen_prov_cont()
514 LOG_WRN("Data for unknown transaction (0x%x != 0x%x)", rx->xact_id, link.rx.id); in gen_prov_cont()
518 if (seg > link.rx.last_seg) { in gen_prov_cont()
524 if (!(link.rx.seg & BIT(seg))) { in gen_prov_cont()
530 LOG_WRN("Rx buffer overflow. Malformed generic prov frame?"); in gen_prov_cont()
537 if (seg == link.rx.last_seg && !(link.rx.seg & BIT(0))) { in gen_prov_cont()
540 expect_len = (link.rx.buf->len - 20U - in gen_prov_cont()
541 ((link.rx.last_seg - 1) * 23U)); in gen_prov_cont()
549 if (!link.rx.seg) { in gen_prov_cont()
554 static void gen_prov_ack(struct prov_rx *rx, struct net_buf_simple *buf) in gen_prov_ack() argument
562 if (rx->xact_id == link.tx.id) { in gen_prov_ack()
574 static void gen_prov_start(struct prov_rx *rx, struct net_buf_simple *buf) in gen_prov_start() argument
583 if (rx->xact_id == link.rx.id) { in gen_prov_start()
584 if (!link.rx.seg) { in gen_prov_start()
587 gen_prov_ack_send(rx->xact_id); in gen_prov_start()
593 if (!(link.rx.seg & BIT(0))) { in gen_prov_start()
597 } else if (rx->xact_id != next_transaction_id(link.rx.id)) { in gen_prov_start()
598 LOG_WRN("Unexpected xact 0x%x, expected 0x%x", rx->xact_id, in gen_prov_start()
599 next_transaction_id(link.rx.id)); in gen_prov_start()
603 net_buf_simple_reset(link.rx.buf); in gen_prov_start()
604 link.rx.buf->len = net_buf_simple_pull_be16(buf); in gen_prov_start()
605 link.rx.id = rx->xact_id; in gen_prov_start()
606 link.rx.fcs = net_buf_simple_pull_u8(buf); in gen_prov_start()
608 LOG_DBG("len %u last_seg %u total_len %u fcs 0x%02x", buf->len, START_LAST_SEG(rx->gpc), in gen_prov_start()
609 link.rx.buf->len, link.rx.fcs); in gen_prov_start()
611 if (link.rx.buf->len < 1) { in gen_prov_start()
617 if (link.rx.buf->len > link.rx.buf->size) { in gen_prov_start()
618 LOG_ERR("Too large provisioning PDU (%u bytes)", link.rx.buf->len); in gen_prov_start()
623 if (START_LAST_SEG(rx->gpc) > 0 && link.rx.buf->len <= 20U) { in gen_prov_start()
629 if (START_LAST_SEG(rx->gpc) != last_seg(link.rx.buf->len)) { in gen_prov_start()
630 LOG_ERR("Invalid SegN (%u, calculated %u)", START_LAST_SEG(rx->gpc), in gen_prov_start()
631 last_seg(link.rx.buf->len)); in gen_prov_start()
638 link.rx.last_seg = START_LAST_SEG(rx->gpc); in gen_prov_start()
640 if ((link.rx.seg & BIT(0)) && in gen_prov_start()
641 (find_msb_set((~link.rx.seg) & SEG_NVAL) - 1 > link.rx.last_seg)) { in gen_prov_start()
647 if (link.rx.seg) { in gen_prov_start()
648 seg = link.rx.seg; in gen_prov_start()
651 link.rx.seg = seg & ((1 << (START_LAST_SEG(rx->gpc) + 1)) - 1); in gen_prov_start()
652 memcpy(link.rx.buf->data, buf->data, buf->len); in gen_prov_start()
655 if (!link.rx.seg) { in gen_prov_start()
660 static void gen_prov_ctl(struct prov_rx *rx, struct net_buf_simple *buf) in gen_prov_ctl() argument
662 LOG_DBG("op 0x%02x len %u", BEARER_CTL(rx->gpc), buf->len); in gen_prov_ctl()
664 switch (BEARER_CTL(rx->gpc)) { in gen_prov_ctl()
666 link_open(rx, buf); in gen_prov_ctl()
673 link_ack(rx, buf); in gen_prov_ctl()
680 link_close(rx, buf); in gen_prov_ctl()
683 LOG_ERR("Unknown bearer opcode: 0x%02x", BEARER_CTL(rx->gpc)); in gen_prov_ctl()
686 bt_mesh_test_prov_invalid_bearer(BEARER_CTL(rx->gpc)); in gen_prov_ctl()
694 void (*func)(struct prov_rx *rx, struct net_buf_simple *buf);
704 static void gen_prov_recv(struct prov_rx *rx, struct net_buf_simple *buf) in gen_prov_recv() argument
706 if (buf->len < gen_prov[GPCF(rx->gpc)].min_len) { in gen_prov_recv()
707 LOG_ERR("Too short GPC message type %u", GPCF(rx->gpc)); in gen_prov_recv()
712 gen_prov[GPCF(rx->gpc)].require_link) { in gen_prov_recv()
717 gen_prov[GPCF(rx->gpc)].func(rx, buf); in gen_prov_recv()
877 * Link management rx
880 static void link_open(struct prov_rx *rx, struct net_buf_simple *buf) in link_open() argument
893 if (link.id != rx->link_id) { in link_open()
916 link.id = rx->link_id; in link_open()
918 net_buf_simple_reset(link.rx.buf); in link_open()
932 static void link_ack(struct prov_rx *rx, struct net_buf_simple *buf) in link_ack() argument
949 static void link_close(struct prov_rx *rx, struct net_buf_simple *buf) in link_close() argument
966 struct prov_rx rx; in bt_mesh_pb_adv_recv() local
977 rx.link_id = net_buf_simple_pull_be32(buf); in bt_mesh_pb_adv_recv()
978 rx.xact_id = net_buf_simple_pull_u8(buf); in bt_mesh_pb_adv_recv()
979 rx.gpc = net_buf_simple_pull_u8(buf); in bt_mesh_pb_adv_recv()
981 if (atomic_test_bit(link.flags, ADV_LINK_ACTIVE) && link.id != rx.link_id) { in bt_mesh_pb_adv_recv()
985 LOG_DBG("link_id 0x%08x xact_id 0x%x", rx.link_id, rx.xact_id); in bt_mesh_pb_adv_recv()
987 gen_prov_recv(&rx, buf); in bt_mesh_pb_adv_recv()
1011 link.rx.id = XACT_ID_NVAL; in prov_link_open()
1020 net_buf_simple_reset(link.rx.buf); in prov_link_open()
1039 link.rx.id = XACT_ID_MAX; in prov_link_accept()