2 * DHD Protocol Module for CDC and BDC.
4 * $Copyright Open Broadcom Corporation$
6 * $Id: dhd_cdc.c 492377 2014-07-21 19:54:06Z $
8 * BDC is like CDC, except it includes a header for data packets to convey
9 * packet priority over the bus, and flags (e.g. to indicate checksum status
10 * for dongle offload.)
18 #include <bcmendian.h>
20 #include <dngl_stats.h>
22 #include <dhd_proto.h>
28 #include <wlfc_proto.h>
33 #define RETRIES 2 /* # of retries to retrieve matching ioctl response */
34 #define BUS_HEADER_LEN (24+DHD_SDALIGN) /* Must be at least SDPCM_RESERVE
35 * defined in dhd_sdio.c (amount of header tha might be added)
36 * plus any space that might be needed for alignment padding.
38 #define ROUND_UP_MARGIN 2048 /* Biggest SDIO block size possible for
39 * round off at the end of buffer
42 typedef struct dhd_prot {
46 uint8 bus_header[BUS_HEADER_LEN];
48 unsigned char buf[WLC_IOCTL_MAXLEN + ROUND_UP_MARGIN];
53 dhdcdc_msg(dhd_pub_t *dhd)
56 dhd_prot_t *prot = dhd->prot;
57 int len = ltoh32(prot->msg.len) + sizeof(cdc_ioctl_t);
59 DHD_TRACE(("%s: Enter\n", __FUNCTION__));
61 DHD_OS_WAKE_LOCK(dhd);
63 /* NOTE : cdc->msg.len holds the desired length of the buffer to be
64 * returned. Only up to CDC_MAX_MSG_SIZE of this buffer area
65 * is actually sent to the dongle
67 if (len > CDC_MAX_MSG_SIZE)
68 len = CDC_MAX_MSG_SIZE;
71 err = dhd_bus_txctl(dhd->bus, (uchar*)&prot->msg, len);
73 DHD_OS_WAKE_UNLOCK(dhd);
78 dhdcdc_cmplt(dhd_pub_t *dhd, uint32 id, uint32 len)
81 int cdc_len = len + sizeof(cdc_ioctl_t);
82 dhd_prot_t *prot = dhd->prot;
84 DHD_TRACE(("%s: Enter\n", __FUNCTION__));
88 ret = dhd_bus_rxctl(dhd->bus, (uchar*)&prot->msg, cdc_len);
91 } while (CDC_IOC_ID(ltoh32(prot->msg.flags)) != id);
98 dhdcdc_query_ioctl(dhd_pub_t *dhd, int ifidx, uint cmd, void *buf, uint len, uint8 action)
100 dhd_prot_t *prot = dhd->prot;
101 cdc_ioctl_t *msg = &prot->msg;
102 int ret = 0, retries = 0;
103 uint32 id, flags = 0;
105 DHD_TRACE(("%s: Enter\n", __FUNCTION__));
106 DHD_CTL(("%s: cmd %d len %d\n", __FUNCTION__, cmd, len));
109 /* Respond "bcmerror" and "bcmerrorstr" with local cache */
110 if (cmd == WLC_GET_VAR && buf)
112 if (!strcmp((char *)buf, "bcmerrorstr"))
114 strncpy((char *)buf, bcmerrorstr(dhd->dongle_error), BCME_STRLEN);
117 else if (!strcmp((char *)buf, "bcmerror"))
119 *(int *)buf = dhd->dongle_error;
124 memset(msg, 0, sizeof(cdc_ioctl_t));
126 msg->cmd = htol32(cmd);
127 msg->len = htol32(len);
128 msg->flags = (++prot->reqid << CDCF_IOC_ID_SHIFT);
129 CDC_SET_IF_IDX(msg, ifidx);
130 /* add additional action bits */
131 action &= WL_IOCTL_ACTION_MASK;
132 msg->flags |= (action << CDCF_IOC_ACTION_SHIFT);
133 msg->flags = htol32(msg->flags);
136 memcpy(prot->buf, buf, len);
138 if ((ret = dhdcdc_msg(dhd)) < 0) {
139 if (!dhd->hang_was_sent)
140 DHD_ERROR(("dhdcdc_query_ioctl: dhdcdc_msg failed w/status %d\n", ret));
145 /* wait for interrupt and get first fragment */
146 if ((ret = dhdcdc_cmplt(dhd, prot->reqid, len)) < 0)
149 flags = ltoh32(msg->flags);
150 id = (flags & CDCF_IOC_ID_MASK) >> CDCF_IOC_ID_SHIFT;
152 if ((id < prot->reqid) && (++retries < RETRIES))
154 if (id != prot->reqid) {
155 DHD_ERROR(("%s: %s: unexpected request id %d (expected %d)\n",
156 dhd_ifname(dhd, ifidx), __FUNCTION__, id, prot->reqid));
161 /* Copy info buffer */
166 memcpy(buf, (void*) prot->buf, len);
169 /* Check the ERROR flag */
170 if (flags & CDCF_IOC_ERROR)
172 ret = ltoh32(msg->status);
173 /* Cache error from dongle */
174 dhd->dongle_error = ret;
183 dhdcdc_set_ioctl(dhd_pub_t *dhd, int ifidx, uint cmd, void *buf, uint len, uint8 action)
185 dhd_prot_t *prot = dhd->prot;
186 cdc_ioctl_t *msg = &prot->msg;
190 DHD_TRACE(("%s: Enter\n", __FUNCTION__));
191 DHD_CTL(("%s: cmd %d len %d\n", __FUNCTION__, cmd, len));
193 if (dhd->busstate == DHD_BUS_DOWN) {
194 DHD_ERROR(("%s : bus is down. we have nothing to do\n", __FUNCTION__));
198 /* don't talk to the dongle if fw is about to be reloaded */
199 if (dhd->hang_was_sent) {
200 DHD_ERROR(("%s: HANG was sent up earlier. Not talking to the chip\n",
205 memset(msg, 0, sizeof(cdc_ioctl_t));
207 msg->cmd = htol32(cmd);
208 msg->len = htol32(len);
209 msg->flags = (++prot->reqid << CDCF_IOC_ID_SHIFT);
210 CDC_SET_IF_IDX(msg, ifidx);
211 /* add additional action bits */
212 action &= WL_IOCTL_ACTION_MASK;
213 msg->flags |= (action << CDCF_IOC_ACTION_SHIFT) | CDCF_IOC_SET;
214 msg->flags = htol32(msg->flags);
217 memcpy(prot->buf, buf, len);
219 if ((ret = dhdcdc_msg(dhd)) < 0) {
220 DHD_ERROR(("%s: dhdcdc_msg failed w/status %d\n", __FUNCTION__, ret));
224 if ((ret = dhdcdc_cmplt(dhd, prot->reqid, len)) < 0)
227 flags = ltoh32(msg->flags);
228 id = (flags & CDCF_IOC_ID_MASK) >> CDCF_IOC_ID_SHIFT;
230 if (id != prot->reqid) {
231 DHD_ERROR(("%s: %s: unexpected request id %d (expected %d)\n",
232 dhd_ifname(dhd, ifidx), __FUNCTION__, id, prot->reqid));
237 /* Check the ERROR flag */
238 if (flags & CDCF_IOC_ERROR)
240 ret = ltoh32(msg->status);
241 /* Cache error from dongle */
242 dhd->dongle_error = ret;
251 dhd_prot_ioctl(dhd_pub_t *dhd, int ifidx, wl_ioctl_t * ioc, void * buf, int len)
253 dhd_prot_t *prot = dhd->prot;
256 static int error_cnt = 0;
258 if ((dhd->busstate == DHD_BUS_DOWN) || dhd->hang_was_sent) {
259 DHD_ERROR(("%s : bus is down. we have nothing to do\n", __FUNCTION__));
263 DHD_TRACE(("%s: Enter\n", __FUNCTION__));
265 ASSERT(len <= WLC_IOCTL_MAXLEN);
267 if (len > WLC_IOCTL_MAXLEN)
270 if (prot->pending == TRUE) {
271 DHD_ERROR(("CDC packet is pending!!!! cmd=0x%x (%lu) lastcmd=0x%x (%lu)\n",
272 ioc->cmd, (unsigned long)ioc->cmd, prot->lastcmd,
273 (unsigned long)prot->lastcmd));
274 if ((ioc->cmd == WLC_SET_VAR) || (ioc->cmd == WLC_GET_VAR)) {
275 DHD_TRACE(("iovar cmd=%s\n", (char*)buf));
280 prot->pending = TRUE;
281 prot->lastcmd = ioc->cmd;
283 if (action & WL_IOCTL_ACTION_SET)
284 ret = dhdcdc_set_ioctl(dhd, ifidx, ioc->cmd, buf, len, action);
286 ret = dhdcdc_query_ioctl(dhd, ifidx, ioc->cmd, buf, len, action);
288 ioc->used = ret - sizeof(cdc_ioctl_t);
290 // terence 20130805: send hang event to wpa_supplicant
298 /* Too many programs assume ioctl() returns 0 on success */
302 cdc_ioctl_t *msg = &prot->msg;
303 ioc->needed = ltoh32(msg->len); /* len == needed when set/query fails from dongle */
306 /* Intercept the wme_dp ioctl here */
307 if ((!ret) && (ioc->cmd == WLC_SET_VAR) && (!strcmp(buf, "wme_dp"))) {
310 slen = strlen("wme_dp") + 1;
311 if (len >= (int)(slen + sizeof(int)))
312 bcopy(((char *)buf + slen), &val, sizeof(int));
313 dhd->wme_dp = (uint8) ltoh32(val);
316 prot->pending = FALSE;
324 dhd_prot_iovar_op(dhd_pub_t *dhdp, const char *name,
325 void *params, int plen, void *arg, int len, bool set)
327 return BCME_UNSUPPORTED;
331 dhd_prot_dump(dhd_pub_t *dhdp, struct bcmstrbuf *strbuf)
333 bcm_bprintf(strbuf, "Protocol CDC: reqid %d\n", dhdp->prot->reqid);
335 dhd_wlfc_dump(dhdp, strbuf);
339 /* The FreeBSD PKTPUSH could change the packet buf pinter
340 so we need to make it changable
342 #define PKTBUF pktbuf
344 dhd_prot_hdrpush(dhd_pub_t *dhd, int ifidx, void *PKTBUF)
347 struct bdc_header *h;
350 DHD_TRACE(("%s: Enter\n", __FUNCTION__));
353 /* Push BDC header used to convey priority for buses that don't */
355 PKTPUSH(dhd->osh, PKTBUF, BDC_HEADER_LEN);
357 h = (struct bdc_header *)PKTDATA(dhd->osh, PKTBUF);
359 h->flags = (BDC_PROTO_VER << BDC_FLAG_VER_SHIFT);
360 if (PKTSUMNEEDED(PKTBUF))
361 h->flags |= BDC_FLAG_SUM_NEEDED;
364 h->priority = (PKTPRIO(PKTBUF) & BDC_PRIORITY_MASK);
368 BDC_SET_IF_IDX(h, ifidx);
370 #undef PKTBUF /* Only defined in the above routine */
373 dhd_prot_hdrlen(dhd_pub_t *dhd, void *PKTBUF)
377 /* Length of BDC(+WLFC) headers pushed */
378 hdrlen = BDC_HEADER_LEN + (((struct bdc_header *)PKTBUF)->dataOffset * 4);
384 dhd_prot_hdrpull(dhd_pub_t *dhd, int *ifidx, void *pktbuf, uchar *reorder_buf_info,
385 uint *reorder_info_len)
388 struct bdc_header *h;
390 uint8 data_offset = 0;
392 DHD_TRACE(("%s: Enter\n", __FUNCTION__));
395 if (reorder_info_len)
396 *reorder_info_len = 0;
397 /* Pop BDC header used to convey priority for buses that don't */
399 if (PKTLEN(dhd->osh, pktbuf) < BDC_HEADER_LEN) {
400 DHD_ERROR(("%s: rx data too short (%d < %d)\n", __FUNCTION__,
401 PKTLEN(dhd->osh, pktbuf), BDC_HEADER_LEN));
405 h = (struct bdc_header *)PKTDATA(dhd->osh, pktbuf);
408 /* for tx packet, skip the analysis */
409 data_offset = h->dataOffset;
410 PKTPULL(dhd->osh, pktbuf, BDC_HEADER_LEN);
414 if ((*ifidx = BDC_GET_IF_IDX(h)) >= DHD_MAX_IFS) {
415 DHD_ERROR(("%s: rx data ifnum out of range (%d)\n",
416 __FUNCTION__, *ifidx));
420 if (((h->flags & BDC_FLAG_VER_MASK) >> BDC_FLAG_VER_SHIFT) != BDC_PROTO_VER) {
421 DHD_ERROR(("%s: non-BDC packet received, flags = 0x%x\n",
422 dhd_ifname(dhd, *ifidx), h->flags));
423 if (((h->flags & BDC_FLAG_VER_MASK) >> BDC_FLAG_VER_SHIFT) == BDC_PROTO_VER_1)
429 if (h->flags & BDC_FLAG_SUM_GOOD) {
430 DHD_INFO(("%s: BDC packet received with good rx-csum, flags 0x%x\n",
431 dhd_ifname(dhd, *ifidx), h->flags));
432 PKTSETSUMGOOD(pktbuf, TRUE);
435 PKTSETPRIO(pktbuf, (h->priority & BDC_PRIORITY_MASK));
436 data_offset = h->dataOffset;
437 PKTPULL(dhd->osh, pktbuf, BDC_HEADER_LEN);
441 #if (NDISVER < 0x0630)
442 if (PKTLEN(dhd->osh, pktbuf) < (uint32) (data_offset << 2)) {
443 DHD_ERROR(("%s: rx data too short (%d < %d)\n", __FUNCTION__,
444 PKTLEN(dhd->osh, pktbuf), (data_offset * 4)));
447 #endif /* #if defined(NDISVER) */
448 #endif /* (NDISVER < 0x0630) */
451 if (!DHD_PKTTAG_PKTDIR(PKTTAG(pktbuf))) {
453 - parse txstatus only for packets that came from the firmware
455 dhd_wlfc_parse_header_info(dhd, pktbuf, (data_offset << 2),
456 reorder_buf_info, reorder_info_len);
459 #endif /* PROP_TXSTATUS */
462 PKTPULL(dhd->osh, pktbuf, (data_offset << 2));
468 dhd_prot_attach(dhd_pub_t *dhd)
472 if (!(cdc = (dhd_prot_t *)DHD_OS_PREALLOC(dhd, DHD_PREALLOC_PROT, sizeof(dhd_prot_t)))) {
473 DHD_ERROR(("%s: kmalloc failed\n", __FUNCTION__));
476 memset(cdc, 0, sizeof(dhd_prot_t));
478 /* ensure that the msg buf directly follows the cdc msg struct */
479 if ((uintptr)(&cdc->msg + 1) != (uintptr)cdc->buf) {
480 DHD_ERROR(("dhd_prot_t is not correctly defined\n"));
486 dhd->hdrlen += BDC_HEADER_LEN;
488 dhd->maxctl = WLC_IOCTL_MAXLEN + sizeof(cdc_ioctl_t) + ROUND_UP_MARGIN;
493 DHD_OS_PREFREE(dhd, cdc, sizeof(dhd_prot_t));
497 /* ~NOTE~ What if another thread is waiting on the semaphore? Holding it? */
499 dhd_prot_detach(dhd_pub_t *dhd)
502 dhd_wlfc_deinit(dhd);
504 DHD_OS_PREFREE(dhd, dhd->prot, sizeof(dhd_prot_t));
509 dhd_prot_dstats(dhd_pub_t *dhd)
513 dhd->dstats.tx_packets = dhd->tx_packets;
514 dhd->dstats.tx_errors = dhd->tx_errors;
515 dhd->dstats.rx_packets = dhd->rx_packets;
516 dhd->dstats.rx_errors = dhd->rx_errors;
517 dhd->dstats.rx_dropped = dhd->rx_dropped;
518 dhd->dstats.multicast = dhd->rx_multicast;
523 dhd_sync_with_dongle(dhd_pub_t *dhd)
526 wlc_rev_info_t revinfo;
527 DHD_TRACE(("%s: Enter\n", __FUNCTION__));
530 /* Get the device rev info */
531 memset(&revinfo, 0, sizeof(revinfo));
532 ret = dhd_wl_ioctl_cmd(dhd, WLC_GET_REVINFO, &revinfo, sizeof(revinfo), FALSE, 0);
537 dhd_process_cid_mac(dhd, TRUE);
539 ret = dhd_preinit_ioctls(dhd);
542 dhd_process_cid_mac(dhd, FALSE);
544 /* Always assumes wl for now */
551 int dhd_prot_init(dhd_pub_t *dhd)
557 dhd_prot_stop(dhd_pub_t *dhd)
559 /* Nothing to do for CDC */
564 dhd_get_hostreorder_pkts(void *osh, struct reorder_info *ptr, void **pkt,
565 uint32 *pkt_count, void **pplast, uint8 start, uint8 end)
567 void *plast = NULL, *p;
570 if (ptr->pend_pkts == 0) {
571 DHD_REORDER(("%s: no packets in reorder queue \n", __FUNCTION__));
578 p = (void *)(ptr->p[start]);
579 ptr->p[start] = NULL;
585 PKTSETNEXT(osh, plast, p);
591 if (start > ptr->max_idx)
593 } while (start != end);
595 *pkt_count = pkt_cnt;
596 ptr->pend_pkts -= (uint8)pkt_cnt;
600 dhd_process_pkt_reorder_info(dhd_pub_t *dhd, uchar *reorder_info_buf, uint reorder_info_len,
601 void **pkt, uint32 *pkt_count)
603 uint8 flow_id, max_idx, cur_idx, exp_idx;
604 struct reorder_info *ptr;
606 void *cur_pkt, *plast = NULL;
610 if (pkt_count != NULL)
615 flow_id = reorder_info_buf[WLHOST_REORDERDATA_FLOWID_OFFSET];
616 flags = reorder_info_buf[WLHOST_REORDERDATA_FLAGS_OFFSET];
618 DHD_REORDER(("flow_id %d, flags 0x%02x, idx(%d, %d, %d)\n", flow_id, flags,
619 reorder_info_buf[WLHOST_REORDERDATA_CURIDX_OFFSET],
620 reorder_info_buf[WLHOST_REORDERDATA_EXPIDX_OFFSET],
621 reorder_info_buf[WLHOST_REORDERDATA_MAXIDX_OFFSET]));
623 /* validate flags and flow id */
625 DHD_ERROR(("%s: invalid flags...so ignore this packet\n", __FUNCTION__));
633 ptr = dhd->reorder_bufs[flow_id];
634 if (flags & WLHOST_REORDERDATA_DEL_FLOW) {
635 uint32 buf_size = sizeof(struct reorder_info);
637 DHD_REORDER(("%s: Flags indicating to delete a flow id %d\n",
638 __FUNCTION__, flow_id));
641 DHD_REORDER(("%s: received flags to cleanup, but no flow (%d) yet\n",
642 __FUNCTION__, flow_id));
648 dhd_get_hostreorder_pkts(dhd->osh, ptr, pkt, &cnt, &plast,
649 ptr->exp_idx, ptr->exp_idx);
650 /* set it to the last packet */
652 PKTSETNEXT(dhd->osh, plast, cur_pkt);
657 DHD_ERROR(("%s: del flow: something fishy, pending packets %d\n",
663 buf_size += ((ptr->max_idx + 1) * sizeof(void *));
664 MFREE(dhd->osh, ptr, buf_size);
665 dhd->reorder_bufs[flow_id] = NULL;
669 /* all the other cases depend on the existance of the reorder struct for that flow id */
671 uint32 buf_size_alloc = sizeof(reorder_info_t);
672 max_idx = reorder_info_buf[WLHOST_REORDERDATA_MAXIDX_OFFSET];
674 buf_size_alloc += ((max_idx + 1) * sizeof(void*));
675 /* allocate space to hold the buffers, index etc */
677 DHD_REORDER(("%s: alloc buffer of size %d size, reorder info id %d, maxidx %d\n",
678 __FUNCTION__, buf_size_alloc, flow_id, max_idx));
679 ptr = (struct reorder_info *)MALLOC(dhd->osh, buf_size_alloc);
681 DHD_ERROR(("%s: Malloc failed to alloc buffer\n", __FUNCTION__));
685 bzero(ptr, buf_size_alloc);
686 dhd->reorder_bufs[flow_id] = ptr;
687 ptr->p = (void *)(ptr+1);
688 ptr->max_idx = max_idx;
690 if (flags & WLHOST_REORDERDATA_NEW_HOLE) {
691 DHD_REORDER(("%s: new hole, so cleanup pending buffers\n", __FUNCTION__));
692 if (ptr->pend_pkts) {
693 dhd_get_hostreorder_pkts(dhd->osh, ptr, pkt, &cnt, &plast,
694 ptr->exp_idx, ptr->exp_idx);
697 ptr->cur_idx = reorder_info_buf[WLHOST_REORDERDATA_CURIDX_OFFSET];
698 ptr->exp_idx = reorder_info_buf[WLHOST_REORDERDATA_EXPIDX_OFFSET];
699 ptr->max_idx = reorder_info_buf[WLHOST_REORDERDATA_MAXIDX_OFFSET];
700 ptr->p[ptr->cur_idx] = cur_pkt;
704 else if (flags & WLHOST_REORDERDATA_CURIDX_VALID) {
705 cur_idx = reorder_info_buf[WLHOST_REORDERDATA_CURIDX_OFFSET];
706 exp_idx = reorder_info_buf[WLHOST_REORDERDATA_EXPIDX_OFFSET];
709 if ((exp_idx == ptr->exp_idx) && (cur_idx != ptr->exp_idx)) {
710 /* still in the current hole */
711 /* enqueue the current on the buffer chain */
712 if (ptr->p[cur_idx] != NULL) {
713 DHD_REORDER(("%s: HOLE: ERROR buffer pending..free it\n",
715 PKTFREE(dhd->osh, ptr->p[cur_idx], TRUE);
716 ptr->p[cur_idx] = NULL;
718 ptr->p[cur_idx] = cur_pkt;
720 ptr->cur_idx = cur_idx;
721 DHD_REORDER(("%s: fill up a hole..pending packets is %d\n",
722 __FUNCTION__, ptr->pend_pkts));
726 else if (ptr->exp_idx == cur_idx) {
727 /* got the right one ..flush from cur to exp and update exp */
728 DHD_REORDER(("%s: got the right one now, cur_idx is %d\n",
729 __FUNCTION__, cur_idx));
730 if (ptr->p[cur_idx] != NULL) {
731 DHD_REORDER(("%s: Error buffer pending..free it\n",
733 PKTFREE(dhd->osh, ptr->p[cur_idx], TRUE);
734 ptr->p[cur_idx] = NULL;
736 ptr->p[cur_idx] = cur_pkt;
739 ptr->cur_idx = cur_idx;
740 ptr->exp_idx = exp_idx;
742 dhd_get_hostreorder_pkts(dhd->osh, ptr, pkt, &cnt, &plast,
745 DHD_REORDER(("%s: freeing up buffers %d, still pending %d\n",
746 __FUNCTION__, cnt, ptr->pend_pkts));
750 bool flush_current = FALSE;
751 /* both cur and exp are moved now .. */
752 DHD_REORDER(("%s:, flow %d, both moved, cur %d(%d), exp %d(%d)\n",
753 __FUNCTION__, flow_id, ptr->cur_idx, cur_idx,
754 ptr->exp_idx, exp_idx));
755 if (flags & WLHOST_REORDERDATA_FLUSH_ALL)
756 end_idx = ptr->exp_idx;
760 /* flush pkts first */
761 dhd_get_hostreorder_pkts(dhd->osh, ptr, pkt, &cnt, &plast,
762 ptr->exp_idx, end_idx);
764 if (cur_idx == ptr->max_idx) {
766 flush_current = TRUE;
768 if (exp_idx == cur_idx + 1)
769 flush_current = TRUE;
773 PKTSETNEXT(dhd->osh, plast, cur_pkt);
779 ptr->p[cur_idx] = cur_pkt;
782 ptr->exp_idx = exp_idx;
783 ptr->cur_idx = cur_idx;
789 /* no real packet but update to exp_seq...that means explicit window move */
790 exp_idx = reorder_info_buf[WLHOST_REORDERDATA_EXPIDX_OFFSET];
792 DHD_REORDER(("%s: move the window, cur_idx is %d, exp is %d, new exp is %d\n",
793 __FUNCTION__, ptr->cur_idx, ptr->exp_idx, exp_idx));
794 if (flags & WLHOST_REORDERDATA_FLUSH_ALL)
795 end_idx = ptr->exp_idx;
799 dhd_get_hostreorder_pkts(dhd->osh, ptr, pkt, &cnt, &plast, ptr->exp_idx, end_idx);
801 PKTSETNEXT(dhd->osh, plast, cur_pkt);
806 /* set the new expected idx */
807 ptr->exp_idx = exp_idx;