⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 claw.c

📁 linux-2.6.15.6
💻 C
📖 第 1 页 / 共 5 页
字号:
	CLAW_DBF_TEXT(4,trace,"freebufs");	if (privptr->p_buff_ccw != NULL) {        	free_pages((unsigned long)privptr->p_buff_ccw,	        	(int)pages_to_order_of_mag(privptr->p_buff_ccw_num));	}	CLAW_DBF_TEXT(4,trace,"freeread");        if (privptr->p_env->read_size < PAGE_SIZE) {	    if (privptr->p_buff_read != NULL) {                free_pages((unsigned long)privptr->p_buff_read,		      (int)pages_to_order_of_mag(privptr->p_buff_read_num));		}        }        else {                p_buf=privptr->p_read_active_first;                while (p_buf!=NULL) {                        free_pages((unsigned long)p_buf->p_buffer,			     (int)pages_to_order_of_mag(			     	privptr->p_buff_pages_perread ));                        p_buf=p_buf->next;                }        }	 CLAW_DBF_TEXT(4,trace,"freewrit");        if (privptr->p_env->write_size < PAGE_SIZE ) {                free_pages((unsigned long)privptr->p_buff_write,		      (int)pages_to_order_of_mag(privptr->p_buff_write_num));        }        else {                p_buf=privptr->p_write_active_first;                while (p_buf!=NULL) {                        free_pages((unsigned long)p_buf->p_buffer,			      (int)pages_to_order_of_mag(			      privptr->p_buff_pages_perwrite ));                        p_buf=p_buf->next;                }        }	 CLAW_DBF_TEXT(4,trace,"clearptr");	privptr->buffs_alloc = 0;        privptr->p_buff_ccw=NULL;        privptr->p_buff_read=NULL;        privptr->p_buff_write=NULL;        privptr->system_validate_comp=0;        privptr->release_pend=0;        /*      Remove any writes that were pending and reset all reads   */        p_this_ccw=privptr->p_read_active_first;        while (p_this_ccw!=NULL) {                p_this_ccw->header.length=0xffff;                p_this_ccw->header.opcode=0xff;                p_this_ccw->header.flag=0x00;                p_this_ccw=p_this_ccw->next;        }        while (privptr->p_write_active_first!=NULL) {                p_this_ccw=privptr->p_write_active_first;                p_this_ccw->header.flag=CLAW_PENDING;                privptr->p_write_active_first=p_this_ccw->next;                p_this_ccw->next=privptr->p_write_free_chain;                privptr->p_write_free_chain=p_this_ccw;                ++privptr->write_free_count;        }        privptr->p_write_active_last=NULL;        privptr->mtc_logical_link = -1;        privptr->mtc_skipping = 1;        privptr->mtc_offset=0;        if (((privptr->channel[READ].last_dstat |		privptr->channel[WRITE].last_dstat) &		~(DEV_STAT_CHN_END | DEV_STAT_DEV_END)) != 0x00) {                printk(KERN_WARNING "%s: channel problems during close - "			"read: %02x -  write: %02x\n",                dev->name,		privptr->channel[READ].last_dstat,		privptr->channel[WRITE].last_dstat);		 CLAW_DBF_TEXT(2,trace,"badclose");        }#ifdef FUNCTRACE	printk(KERN_INFO "%s:%s Exit on line %d\n",		dev->name,__FUNCTION__,__LINE__);#endif	CLAW_DBF_TEXT(4,trace,"rlsexit");        return 0;}      /* end of claw_release     *//*-------------------------------------------------------------------**       claw_write_retry                                             **                                                                    **--------------------------------------------------------------------*/static voidclaw_write_retry ( struct chbk *p_ch ){        struct net_device  *dev=p_ch->ndev;#ifdef FUNCTRACE        printk(KERN_INFO "%s:%s Enter\n",dev->name,__FUNCTION__);        printk(KERN_INFO "claw: variable p_ch =\n");        dumpit((char *) p_ch, sizeof(struct chbk));#endif	CLAW_DBF_TEXT(4,trace,"w_retry");        if (p_ch->claw_state == CLAW_STOP) {#ifdef FUNCTRACE		printk(KERN_INFO "%s:%s Exit on line %d\n",			dev->name,__FUNCTION__,__LINE__);#endif        	return;        }#ifdef DEBUGMSG        printk( KERN_INFO "%s:%s  state-%02x\n" ,		dev->name,		__FUNCTION__,		p_ch->claw_state);#endif	claw_strt_out_IO( dev );#ifdef FUNCTRACE	printk(KERN_INFO "%s:%s Exit on line %d\n",		dev->name,__FUNCTION__,__LINE__);#endif	CLAW_DBF_TEXT(4,trace,"rtry_xit");        return;}      /* end of claw_write_retry      *//*-------------------------------------------------------------------**       claw_write_next                                              **                                                                    **--------------------------------------------------------------------*/static voidclaw_write_next ( struct chbk * p_ch ){        struct net_device  *dev;        struct claw_privbk *privptr=NULL;	struct sk_buff *pk_skb;	int	rc;#ifdef FUNCTRACE        printk(KERN_INFO "%s:%s Enter  \n",p_ch->ndev->name,__FUNCTION__);        printk(KERN_INFO "%s: variable p_ch =\n",p_ch->ndev->name);        dumpit((char *) p_ch, sizeof(struct chbk));#endif	CLAW_DBF_TEXT(4,trace,"claw_wrt");        if (p_ch->claw_state == CLAW_STOP)                return;        dev = (struct net_device *) p_ch->ndev;	privptr = (struct claw_privbk *) dev->priv;        claw_free_wrt_buf( dev );	if ((privptr->write_free_count > 0) &&	    !skb_queue_empty(&p_ch->collect_queue)) {	  	pk_skb = claw_pack_skb(privptr);		while (pk_skb != NULL) {			rc = claw_hw_tx( pk_skb, dev,1);			if (privptr->write_free_count > 0) {	   			pk_skb = claw_pack_skb(privptr);			} else				pk_skb = NULL;		}	}        if (privptr->p_write_active_first!=NULL) {                claw_strt_out_IO(dev);        }#ifdef FUNCTRACE	printk(KERN_INFO "%s:%s Exit on line %d\n",		dev->name,__FUNCTION__,__LINE__);#endif        return;}      /* end of claw_write_next      *//*-------------------------------------------------------------------**                                                                    **       claw_timer                                                   **--------------------------------------------------------------------*/static voidclaw_timer ( struct chbk * p_ch ){#ifdef FUNCTRACE        printk(KERN_INFO "%s:%s Entry\n",p_ch->ndev->name,__FUNCTION__);        printk(KERN_INFO "%s: variable p_ch =\n",p_ch->ndev->name);        dumpit((char *) p_ch, sizeof(struct chbk));#endif	CLAW_DBF_TEXT(4,trace,"timer");        p_ch->flag |= CLAW_TIMER;        wake_up(&p_ch->wait);#ifdef FUNCTRACE	printk(KERN_INFO "%s:%s Exit on line %d\n",		p_ch->ndev->name,__FUNCTION__,__LINE__);#endif        return;}      /* end of claw_timer  *//***       functions*//*-------------------------------------------------------------------**                                                                    **     pages_to_order_of_mag                                          **                                                                    **    takes a number of pages from 1 to 512 and returns the           **    log(num_pages)/log(2) get_free_pages() needs a base 2 order     **    of magnitude get_free_pages() has an upper order of 9           **--------------------------------------------------------------------*/static int inlinepages_to_order_of_mag(int num_of_pages){	int	order_of_mag=1;		/* assume 2 pages */	int	nump=2;#ifdef FUNCTRACE        printk(KERN_INFO "%s Enter pages = %d \n",__FUNCTION__,num_of_pages);#endif	CLAW_DBF_TEXT_(5,trace,"pages%d",num_of_pages);	if (num_of_pages == 1)   {return 0; }  /* magnitude of 0 = 1 page */	/* 512 pages = 2Meg on 4k page systems */	if (num_of_pages >= 512) {return 9; }	/* we have two or more pages order is at least 1 */	for (nump=2 ;nump <= 512;nump*=2) {	  if (num_of_pages <= nump)		  break;	  order_of_mag +=1;	}	if (order_of_mag > 9) { order_of_mag = 9; }  /* I know it's paranoid */#ifdef FUNCTRACE        printk(KERN_INFO "%s Exit on line %d, order = %d\n",	__FUNCTION__,__LINE__, order_of_mag);#endif	CLAW_DBF_TEXT_(5,trace,"mag%d",order_of_mag);	return order_of_mag;}/*-------------------------------------------------------------------**                                                                    **     add_claw_reads                                                 **                                                                    **--------------------------------------------------------------------*/static intadd_claw_reads(struct net_device *dev, struct ccwbk* p_first,	struct ccwbk* p_last){        struct claw_privbk *privptr;        struct ccw1  temp_ccw;        struct endccw * p_end;#ifdef IOTRACE        struct ccwbk*  p_buf;#endif#ifdef FUNCTRACE        printk(KERN_INFO "%s:%s Enter  \n",dev->name,__FUNCTION__);#endif#ifdef DEBUGMSG        printk(KERN_INFO "dev\n");        dumpit((char *) dev, sizeof(struct net_device));        printk(KERN_INFO "p_first\n");        dumpit((char *) p_first, sizeof(struct ccwbk));        printk(KERN_INFO "p_last\n");        dumpit((char *) p_last, sizeof(struct ccwbk));#endif	CLAW_DBF_TEXT(4,trace,"addreads");        privptr = dev->priv;        p_end = privptr->p_end_ccw;        /* first CCW and last CCW contains a new set of read channel programs        *       to apend the running channel programs        */        if ( p_first==NULL) {#ifdef FUNCTRACE		printk(KERN_INFO "%s:%s Exit on line %d\n",			dev->name,__FUNCTION__,__LINE__);#endif		CLAW_DBF_TEXT(4,trace,"addexit");                return 0;        }        /* set up ending CCW sequence for this segment */        if (p_end->read1) {                p_end->read1=0x00;    /*  second ending CCW is now active */                /*      reset ending CCWs and setup TIC CCWs              */                p_end->read2_nop2.cmd_code = CCW_CLAW_CMD_READFF;                p_end->read2_nop2.flags  = CCW_FLAG_SLI | CCW_FLAG_SKIP;                p_last->r_TIC_1.cda =(__u32)__pa(&p_end->read2_nop1);                p_last->r_TIC_2.cda =(__u32)__pa(&p_end->read2_nop1);                p_end->read2_nop2.cda=0;                p_end->read2_nop2.count=1;        }        else {                p_end->read1=0x01;  /* first ending CCW is now active */                /*      reset ending CCWs and setup TIC CCWs          */                p_end->read1_nop2.cmd_code = CCW_CLAW_CMD_READFF;                p_end->read1_nop2.flags  = CCW_FLAG_SLI | CCW_FLAG_SKIP;                p_last->r_TIC_1.cda = (__u32)__pa(&p_end->read1_nop1);                p_last->r_TIC_2.cda = (__u32)__pa(&p_end->read1_nop1);                p_end->read1_nop2.cda=0;                p_end->read1_nop2.count=1;        }        if ( privptr-> p_read_active_first ==NULL ) {#ifdef DEBUGMSG                printk(KERN_INFO "%s:%s p_read_active_frist == NULL \n",			dev->name,__FUNCTION__);                printk(KERN_INFO "%s:%s Read active first/last changed \n",			dev->name,__FUNCTION__);#endif                privptr-> p_read_active_first= p_first;  /*    set new first */                privptr-> p_read_active_last = p_last;   /*    set new last  */        }        else {#ifdef DEBUGMSG                printk(KERN_INFO "%s:%s Read in progress \n",		dev->name,__FUNCTION__);#endif                /* set up TIC ccw  */                temp_ccw.cda= (__u32)__pa(&p_first->read);                temp_ccw.count=0;                temp_ccw.flags=0;                temp_ccw.cmd_code = CCW_CLAW_CMD_TIC;                if (p_end->read1) {               /* first set of CCW's is chained to the new read              */               /* chain, so the second set is chained to the active chain.   */               /* Therefore modify the second set to point to the new        */               /* read chain set up TIC CCWs                                 */               /* make sure we update the CCW so channel doesn't fetch it    */               /* when it's only half done                                   */                        memcpy( &p_end->read2_nop2, &temp_ccw ,				sizeof(struct ccw1));                        privptr->p_read_active_last->r_TIC_1.cda=				(__u32)__pa(&p_first->read);                        privptr->p_read_active_last->r_TIC_2.cda=				(__u32)__pa(&p_first->read);                }                else {                        /* make sure we update the CCW so channel doesn't   */			/* fetch it when it is only half done               */                        memcpy( &p_end->read1_nop2, &temp_ccw ,				sizeof(struct ccw1));                        privptr->p_read_active_last->r_TIC_1.cda=				(__u32)__pa(&p_first->read);                        privptr->p_read_active_last->r_TIC_2.cda=				(__u32)__pa(&p_first->read);                }                /*      chain in new set of blocks                              */                privptr->p_read_active_last->next = p_first;                privptr->p_read_active_last=p_last;        } /* end of if ( privptr-> p_read_active_first ==NULL)  */#ifdef IOTRACE        printk(KERN_INFO "%s:%s  dump p_last CCW BK \n",dev->name,__FUNCTION__);        dumpit((char *)p_last, sizeof(struct ccwbk));        printk(KERN_INFO "%s:%s  dump p_end CCW BK \n",dev->name,__FUNCTION__);        dumpit((char *)p_end, sizeof(struct endccw));        printk(KERN_INFO "%s:%s dump p_first CCW BK \n",dev->name,__FUNCTION__);        dumpit((char *)p_first, sizeof(struct ccwbk));        printk(KERN_INFO "%s:%s Dump Active CCW chain \n",		dev->name,__FUNCTION__);        p_buf=privptr->p_read_active_first;        while (p_buf!=NULL) {                dumpit((char *)p_buf, sizeof(struct ccwbk));                p_buf=p_buf->next;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -