Lines Matching refs:sp
74 * sp ADSP Stream
78 int CalcRecvWdw(sp) /* (CCBPtr sp) */
79 CCBPtr sp;
83 bytes = calcRecvQ(sp);
84 bytes = sp->rbuflen - bytes; /* get what is left */
87 sp->rbufFull = 1; /* Save flag that our recv buf is full */
95 calcRecvQ(sp)
96 CCBPtr sp;
102 if (((sp->gref)->so)->so_rcv.sb_mb)
103 for (p = ((sp->gref)->so)->so_rcv.sb_mb; p; p = p->m_nextpkt)
109 if (sp->rData) { /* There is data in buffer */
110 if ((mb = sp->rbuf_mb)) {
116 if ((mb = sp->crbuf_mb))
132 * sp Connection control block
136 void CheckSend(sp) /* (CCBPtr sp) */
137 register CCBPtr sp;
154 if (sp->state == sClosed)
166 sp->callSend = 0; /* Clear flag */
174 if (sp->sendCtl) {
177 i = sp->sendCtl; /* get local copy bitmap of */
186 UAL_ASSIGN_HTON(sp->f.pktFirstByteSeq, sp->firstRtmtSeq);
188 UAS_ASSIGN_HTON(sp->of.version, netw(0x0100)); /* Fill in open connection parms */
189 UAS_ASSIGN_HTON(sp->of.dstCID, sp->remCID); /* Destination CID */
190 UAL_ASSIGN_HTON(sp->of.pktAttnRecvSeq, sp->attnRecvSeq);
191 bcopy((caddr_t) &sp->of, (caddr_t) dp, ADSP_OPEN_FRAME_LEN);
195 UAS_ASSIGN_HTON(sp->f.CID, sp->locCID);
197 sp->f.descriptor = ADSP_CONTROL_BIT | ADSP_CTL_OREQ;
199 UAS_ASSIGN_HTON(sp->f.CID, sp->locCID);
201 sp->f.descriptor = ADSP_CONTROL_BIT | ADSP_CTL_OACK;
203 UAS_ASSIGN_HTON(sp->f.CID, sp->locCID);
205 sp->f.descriptor = ADSP_CONTROL_BIT | ADSP_CTL_OREQACK;
208 UAS_ASSIGN(sp->f.CID, 0);
210 sp->f.descriptor = ADSP_CONTROL_BIT | ADSP_CTL_ODENY;
211 UAL_ASSIGN(sp->f.pktFirstByteSeq, 0);
223 RemoveTimerElem(&adspGlobal.slowTimers, &sp->ProbeTimer);
224 InsertTimerElem(&adspGlobal.slowTimers, &sp->ProbeTimer,
225 sp->openInterval+1);
229 UAL_ASSIGN_HTON(sp->f.pktFirstByteSeq, sp->sendSeq);
232 sp->state = sClosed; /* Now we're closed */
234 sp->f.descriptor = ADSP_CONTROL_BIT | ADSP_CTL_CLOSE;
237 sp->f.descriptor =
241 sp->f.descriptor = ADSP_CONTROL_BIT | ADSP_CTL_FRESET;
243 &sp->ResetTimer, sp->rtmtInterval+TX_DLY);
246 sp->f.descriptor = ADSP_CONTROL_BIT | ADSP_CTL_FRESET_ACK;
250 sp->f.descriptor = ADSP_CONTROL_BIT | ADSP_CTL_RETRANSMIT;
257 sp->sendCtl &= ~mask;
261 if (sp->sendAttnData) /* Send attn ready to go? */
263 sp->sendAttnData = 0; /* Clear Flags */
264 if (sp->sapb) {
265 sp->sendAttnAck = 0; /* This will also do an Attn Ack */
268 sp->f.descriptor = ADSP_ATTENTION_BIT | ADSP_ACK_REQ_BIT;
269 if (gbuf_cont(sp->sapb->mp)) {
270 gbuf_cont(mp) = gbuf_dupm(gbuf_cont(sp->sapb->mp));
279 sp->f.data[0] = high(sp->sapb->u.attnParams.attnCode);
280 sp->f.data[1] = low(sp->sapb->u.attnParams.attnCode);
281 InsertTimerElem(&adspGlobal.fastTimers, &sp->AttnTimer,
282 sp->rtmtInterval+TX_DLY);
287 if (sp->sendAttnAck) /* Send attn ack ready to go? */
290 sp->f.descriptor = ADSP_CONTROL_BIT | ADSP_ATTENTION_BIT;
291 sp->sendAttnAck = 0;
295 if ((sp->state == sOpen || sp->state == sClosing) && /* Correct state */
296 (!sp->waitingAck) && /* not waiting for an ACK */
297 (sp->sData) && /* have data to send */
298 (GTE(sp->sendWdwSeq,sp->sendSeq)) && /* they have room to accept it */
299 (sp->pktSendCnt < sp->pktSendMax)) /* haven't sent too many pkts
303 if ((datalen = attachData(sp, mp))) /* attach data to mp */
307 if (sp->sendDataAck) {
308 UAL_ASSIGN_HTON(sp->f.pktFirstByteSeq, sp->sendSeq); /* seq # of next byte */
310 sp->f.descriptor = ADSP_CONTROL_BIT;
320 adsp_sendddp(sp, mlist, 0, &sp->remoteAddress, DDP_ADSP);
326 UAL_ASSIGN_HTON(sp->f.pktFirstByteSeq, sp->attnSendSeq);
327 UAL_ASSIGN_HTON(sp->f.pktNextRecvSeq, sp->attnRecvSeq);
328 UAS_ASSIGN(sp->f.pktRecvWdw, 0); /* Always zero in attn pkt */
330 sp->sendDataAck = 0;
331 UAL_ASSIGN_HTON(sp->f.pktNextRecvSeq, sp->recvSeq);
332 UAS_ASSIGN_HTON(sp->f.pktRecvWdw, CalcRecvWdw(sp));
335 bcopy((caddr_t) &sp->f, (caddr_t) gbuf_wptr(mp), ADSP_FRAME_LEN + 2);
338 bcopy((caddr_t) &sp->f, (caddr_t) gbuf_wptr(mp), ADSP_FRAME_LEN);
348 if (sp->state == sClosed) { /* must have sent a close advice */
350 adsp_sendddp(sp, mlist, 0, &sp->remoteAddress, DDP_ADSP);
351 DoClose(sp, 0, -1); /* complete close! */
354 if (sp->state == sClosing) /* See if we were waiting on this write */
355 CheckOkToClose(sp);
368 void completepb(sp, pb)
369 register CCBPtr sp;
372 if (sp->gref && (sp->gref->info == (caddr_t)sp->sp_mp)) {
375 SndMsgUp(sp->gref, pb->mp);
376 NotifyUser(sp);
383 attachData(sp, mp)
384 register CCBPtr sp;
400 if (LT(sp->sendSeq, sp->firstRtmtSeq)) /* Sanity check on send seq */
401 sp->sendSeq = sp->firstRtmtSeq; /* seq must be oldest in buffer. */
410 UAL_ASSIGN_HTON(sp->f.pktFirstByteSeq, sp->sendSeq);
412 if ((smp = sp->sbuf_mb)) /* Get oldest header */
414 else if ((smp = sp->csbuf_mb))
418 sp->sData = 0;
424 seq = sp->firstRtmtSeq; /* Seq # of oldest in buffer */
425 while ((diff = (sp->sendSeq - seq)) >= ((bsize = gbuf_msgsize(smp)) + eom)) {
430 } else if (smp == sp->csbuf_mb) { /* seen the current one? */
433 } else if (sp->csbuf_mb) { /* look at it */
434 smp = sp->csbuf_mb;
454 if ((cnt < sp->sendBlocking) && !sp->writeFlush) {
455 InsertTimerElem(&adspGlobal.fastTimers, &sp->FlushTimer,
456 sp->sendInterval);
487 if ((diff = sp->sendWdwSeq + 1 - sp->sendSeq) <= cnt) {
494 sp->noXmitFlow = 1; /* Don't do flow control calc. */
529 sp->sendSeq += cnt + eom; /* Update sendSeq field */
531 if (GT(sp->sendSeq, sp->maxSendSeq)) /* Keep track of >st ever sent */
532 sp->maxSendSeq = sp->sendSeq;
535 sp->f.descriptor = ADSP_EOM_BIT;
537 sp->f.descriptor = 0;
539 if (sendAckReq || (++sp->pktSendCnt >= sp->pktSendMax)) {
541 sp->f.descriptor |= ADSP_ACK_REQ_BIT; /* We want an ack to this */
542 sp->waitingAck = 1; /* Flag that we're waiting */
543 sp->sendStamp = SysTicks(); /* Save time we sent request */
544 sp->timerSeq = sp->sendSeq; /* Save seq # we want acked */
545 InsertTimerElem(&adspGlobal.fastTimers, &sp->RetryTimer,
546 sp->rtmtInterval+TX_DLY);