int InitPhonodeFromInfoEntry(InfoEntry *info, PhoNode *phonode) { memset(phonode, 0, sizeof(PhoNode)); memcpy(phonode->regid, info->regid, REG_ID_LEN); phonode->uport = info->uport; if (strlen(phonode->regid)) { BIT_SET(phonode->sflags, ISSET_REGID); BIT_SET(phonode->sflags, ISSET_UPORT); } phonode->ipaddress.l = info->ipaddress.l; phonode->realmId = info->realmId; memcpy(phonode->phone, info->phone, PHONE_NUM_LEN); memcpy(phonode->vpnPhone, info->vpnPhone, VPN_LEN); phonode->vpnExtLen = info->vpnExtLen; BIT_COPY(phonode->sflags, ISSET_IPADDRESS, info->sflags, ISSET_IPADDRESS); BIT_COPY(phonode->sflags, ISSET_PHONE, info->sflags, ISSET_PHONE); BIT_COPY(phonode->sflags, ISSET_VPNPHONE, info->sflags, ISSET_VPNPHONE); phonode->cap = info->cap; return(0); }
/* Link down event*/ static void ntb_transport_link_cleanup(struct ntb_transport_ctx *nt) { struct ntb_transport_qp *qp; struct _qpset qp_bitmap_alloc; unsigned i; BIT_COPY(QP_SETSIZE, &nt->qp_bitmap, &qp_bitmap_alloc); BIT_NAND(QP_SETSIZE, &qp_bitmap_alloc, &nt->qp_bitmap_free); /* Pass along the info to any clients */ for (i = 0; i < nt->qp_count; i++) if (test_bit(i, &qp_bitmap_alloc)) { qp = &nt->qp_vec[i]; ntb_qp_link_cleanup(qp); callout_drain(&qp->link_work); } if (!nt->link_is_up) callout_drain(&nt->link_work); /* * The scratchpad registers keep the values if the remote side * goes down, blast them now to give them a sane value the next * time they are accessed */ for (i = 0; i < IF_NTB_MAX_SPAD; i++) ntb_spad_write(nt->ntb, i, 0); }
static void ntb_transport_free(struct ntb_transport_ctx *nt) { struct ntb_softc *ntb = nt->ntb; struct _qpset qp_bitmap_alloc; uint8_t i; ntb_transport_link_cleanup(nt); taskqueue_drain(taskqueue_swi, &nt->link_cleanup); callout_drain(&nt->link_work); callout_drain(&nt->link_watchdog); BIT_COPY(QP_SETSIZE, &nt->qp_bitmap, &qp_bitmap_alloc); BIT_NAND(QP_SETSIZE, &qp_bitmap_alloc, &nt->qp_bitmap_free); /* Verify that all the QPs are freed */ for (i = 0; i < nt->qp_count; i++) if (test_bit(i, &qp_bitmap_alloc)) ntb_transport_free_queue(&nt->qp_vec[i]); ntb_link_disable(ntb); ntb_clear_ctx(ntb); for (i = 0; i < nt->mw_count; i++) ntb_free_mw(nt, i); free(nt->qp_vec, M_NTB_IF); }
static void ntb_transport_doorbell_callback(void *data, uint32_t vector) { struct ntb_transport_ctx *nt = data; struct ntb_transport_qp *qp; struct _qpset db_bits; uint64_t vec_mask; unsigned qp_num; BIT_COPY(QP_SETSIZE, &nt->qp_bitmap, &db_bits); BIT_NAND(QP_SETSIZE, &db_bits, &nt->qp_bitmap_free); vec_mask = ntb_db_vector_mask(nt->ntb, vector); while (vec_mask != 0) { qp_num = ffsll(vec_mask) - 1; if (test_bit(qp_num, &db_bits)) { qp = &nt->qp_vec[qp_num]; taskqueue_enqueue(taskqueue_swi, &qp->rxc_db_work); } vec_mask &= ~(1ull << qp_num); } }