kernels/linux-2.4.0/drivers/ieee1394/ohci1394.c
/* Bottom half that processes sent packets */
Bottom half that processes sent packets
Bottom half that processes sent packets
static void dma_trm_bh(void *data)
{
	struct dma_trm_ctx *d = (struct dma_trm_ctx*)data;
	struct ti_ohci *ohci = (struct ti_ohci*)(d->ohci);
	struct hpsb_packet *packet, *nextpacket;
	unsigned long flags;
	u32 ack;
        size_t datasize;
	spin_lock_irqsave(&d->lock, flags);
	if (d->fifo_first==NULL) {
#if 0
		ohci1394_stop_context(ohci, d->ctrlClear, 
			     "Packet sent ack received but queue is empty");
#endif
		spin_unlock_irqrestore(&d->lock, flags);
		return;
	}
	while (d->fifo_first) {
		packet = d->fifo_first;
                datasize = d->fifo_first->data_size;
		if (datasize)
			ack = d->prg_cpu[d->sent_ind]->end.status>>16;
		else 
			ack = d->prg_cpu[d->sent_ind]->begin.status>>16;
		if (ack==0) 
			break;
#ifdef OHCI1394_DEBUG
		if (datasize)
			DBGMSG(ohci->id,
			       "Packet sent to node %d tcode=0x%X tLabel="
			       "0x%02X ack=0x%X spd=%d dataLength=%d ctx=%d", 
			       (d->prg_cpu[d->sent_ind]->data[1]>>16)&0x3f,
			       (d->prg_cpu[d->sent_ind]->data[0]>>4)&0xf,
			       (d->prg_cpu[d->sent_ind]->data[0]>>10)&0x3f,
			       ack&0x1f, (ack>>5)&0x3, 
			       d->prg_cpu[d->sent_ind]->data[3]>>16,
			       d->ctx);
		else 
			DBGMSG(ohci->id,
			       "Packet sent to node %d tcode=0x%X tLabel="
			       "0x%02X ack=0x%X spd=%d data=0x%08X ctx=%d", 
			       (d->prg_cpu[d->sent_ind]->data[1]>>16)&0x3f,
			       (d->prg_cpu[d->sent_ind]->data[0]>>4)&0xf,
			       (d->prg_cpu[d->sent_ind]->data[0]>>10)&0x3f,
			       ack&0x1f, (ack>>5)&0x3, 
			       d->prg_cpu[d->sent_ind]->data[3],
			       d->ctx);
#endif		
                nextpacket = packet->xnext;
		hpsb_packet_sent(ohci->host, packet, ack&0xf);
		if (datasize)
			pci_unmap_single(ohci->dev, 
					 d->prg_cpu[d->sent_ind]->end.address,
					 datasize, PCI_DMA_TODEVICE);
		d->sent_ind = (d->sent_ind+1)%d->num_desc;
		d->free_prgs++;
		d->fifo_first = nextpacket;
	}
	if (d->fifo_first==NULL) d->fifo_last=NULL;
	dma_trm_flush(ohci, d);
	spin_unlock_irqrestore(&d->lock, flags);
}
static void dma_trm_bh ( void * data ) { struct dma_trm_ctx * d = ( struct dma_trm_ctx * ) data ; struct ti_ohci * ohci = ( struct ti_ohci * ) ( d -> ohci ) ; struct hpsb_packet * packet , * nextpacket ; unsigned long flags ; u32 ack ; size_t datasize ; spin_lock_irqsave ( & d -> lock , flags ) ; if ( d -> fifo_first == NULL ) { #if 0 ohci1394_stop_context ( ohci , d -> ctrlClear , " " ) ; #endif spin_unlock_irqrestore ( & d -> lock , flags ) ; return ; } while ( d -> fifo_first ) { packet = d -> fifo_first ; datasize = d -> fifo_first -> data_size ; if ( datasize ) ack = d -> prg_cpu [ d -> sent_ind ] -> end . status >> 16 ; else ack = d -> prg_cpu [ d -> sent_ind ] -> begin . status >> 16 ; if ( ack == 0 ) break ; #ifdef OHCI1394_DEBUG if ( datasize ) DBGMSG ( ohci -> id , " " " " , ( d -> prg_cpu [ d -> sent_ind ] -> data [ 1 ] >> 16 ) & 0x3f , ( d -> prg_cpu [ d -> sent_ind ] -> data [ 0 ] >> 4 ) & 0xf , ( d -> prg_cpu [ d -> sent_ind ] -> data [ 0 ] >> 10 ) & 0x3f , ack & 0x1f , ( ack >> 5 ) & 0x3 , d -> prg_cpu [ d -> sent_ind ] -> data [ 3 ] >> 16 , d -> ctx ) ; else DBGMSG ( ohci -> id , " " " " , ( d -> prg_cpu [ d -> sent_ind ] -> data [ 1 ] >> 16 ) & 0x3f , ( d -> prg_cpu [ d -> sent_ind ] -> data [ 0 ] >> 4 ) & 0xf , ( d -> prg_cpu [ d -> sent_ind ] -> data [ 0 ] >> 10 ) & 0x3f , ack & 0x1f , ( ack >> 5 ) & 0x3 , d -> prg_cpu [ d -> sent_ind ] -> data [ 3 ] , d -> ctx ) ; #endif nextpacket = packet -> xnext ; hpsb_packet_sent ( ohci -> host , packet , ack & 0xf ) ; if ( datasize ) pci_unmap_single ( ohci -> dev , d -> prg_cpu [ d -> sent_ind ] -> end . address , datasize , PCI_DMA_TODEVICE ) ; d -> sent_ind = ( d -> sent_ind + 1 ) % d -> num_desc ; d -> free_prgs ++ ; d -> fifo_first = nextpacket ; } if ( d -> fifo_first == NULL ) d -> fifo_last = NULL ; dma_trm_flush ( ohci , d ) ; spin_unlock_irqrestore ( & d -> lock , flags ) ; }
Bottom half that processes sent packets
Bottom half that processes sent packets
/* this packet hasn't been sent yet*/