 /* 
 /* 
static int sbdma_add_rcvbuffer(sbmacdma_t *d,struct sk_buff *sb){	sbdmadscr_t *dsc;	sbdmadscr_t *nextdsc;	struct sk_buff *sb_new = NULL;	int pktsize = ENET_PACKET_SIZE;		/* get pointer to our current place in the ring */		dsc = d->sbdma_addptr;	nextdsc = SBDMA_NEXTBUF(d,sbdma_addptr);		/*	 * figure out if the ring is full - if the next descriptor	 * is the same as the one that we're going to remove from	 * the ring, the ring is full	 */		if (nextdsc == d->sbdma_remptr) {		return -ENOSPC;	}	/* 	 * Allocate a sk_buff if we don't already have one.  	 * If we do have an sk_buff, reset it so that it's empty.	 *	 * Note: sk_buffs don't seem to be guaranteed to have any sort	 * of alignment when they are allocated.  Therefore, allocate enough	 * extra space to make sure that:	 *	 *    1. the data does not start in the middle of a cache line.	 *    2. The data does not end in the middle of a cache line	 *    3. The buffer can be aligned such that the IP addresses are 	 *       naturally aligned.	 *	 *  Remember, the SOCs MAC writes whole cache lines at a time,	 *  without reading the old contents first.  So, if the sk_buff's	 *  data portion starts in the middle of a cache line, the SOC	 *  DMA will trash the beginning (and ending) portions.	 */		if (sb == NULL) {		sb_new = dev_alloc_skb(ENET_PACKET_SIZE + SMP_CACHE_BYTES * 2 + ETHER_ALIGN);		if (sb_new == NULL) {			printk(KERN_INFO "%s: sk_buff allocation failed\n",			       d->sbdma_eth->sbm_dev->name);			return -ENOBUFS;		}		sbdma_align_skb(sb_new, SMP_CACHE_BYTES, ETHER_ALIGN);		/* mark skbuff owned by our device */		sb_new->dev = d->sbdma_eth->sbm_dev;	}	else {		sb_new = sb;		/* 		 * nothing special to reinit buffer, it's already aligned		 * and sb->data already points to a good place.		 */	}		/*	 * fill in the descriptor 	 */	#ifdef CONFIG_SBMAC_COALESCE	/*	 * Do not interrupt per DMA transfer.	 */	dsc->dscr_a = virt_to_phys(sb_new->data) |		V_DMA_DSCRA_A_SIZE(NUMCACHEBLKS(pktsize+ETHER_ALIGN)) | 0;#else	dsc->dscr_a = virt_to_phys(sb_new->data) |		V_DMA_DSCRA_A_SIZE(NUMCACHEBLKS(pktsize+ETHER_ALIGN)) |		M_DMA_DSCRA_INTERRUPT;#endif	/* receiving: no options */	dsc->dscr_b = 0;		/*	 * fill in the context 	 */		d->sbdma_ctxtable[dsc-d->sbdma_dscrtable] = sb_new;		/* 	 * point at next packet 	 */		d->sbdma_addptr = nextdsc;		/* 	 * Give the buffer to the DMA engine.	 */		__raw_writeq(1, d->sbdma_dscrcnt);		return 0;					/* we did it */}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/74b0247fbd4b6ed1693a420d85cf50267d840ef4/sb1250-mac.c/buggy/drivers/net/sb1250-mac.c