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

📄 aic94xx_scb.c

📁 linux 内核源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
				sas_task_abort(task);				break;			}		}		if (!failed_dev) {			ASD_DPRINTK("%s: Can't find task (tc=%d) to abort!\n",				    __FUNCTION__, tc_abort);			goto out;		}		/*		 * Now abort everything else for that device (hba?) so		 * that the EH will wake up and do something.		 */		list_for_each_entry_safe(a, b, &asd_ha->seq.pend_q, list) {			struct sas_task *task = ascb->uldd_task;			if (task &&			    task->dev == failed_dev &&			    a->tc_index != tc_abort)				sas_task_abort(task);		}		goto out;	}	case REQ_DEVICE_RESET: {		struct asd_ascb *a;		u16 conn_handle;		unsigned long flags;		struct sas_task *last_dev_task = NULL;		conn_handle = *((u16*)(&dl->status_block[1]));		conn_handle = le16_to_cpu(conn_handle);		ASD_DPRINTK("%s: REQ_DEVICE_RESET, reason=0x%X\n", __FUNCTION__,			    dl->status_block[3]);		/* Find the last pending task for the device... */		list_for_each_entry(a, &asd_ha->seq.pend_q, list) {			u16 x;			struct domain_device *dev;			struct sas_task *task = a->uldd_task;			if (!task)				continue;			dev = task->dev;			x = (unsigned long)dev->lldd_dev;			if (x == conn_handle)				last_dev_task = task;		}		if (!last_dev_task) {			ASD_DPRINTK("%s: Device reset for idle device %d?\n",				    __FUNCTION__, conn_handle);			goto out;		}		/* ...and set the reset flag */		spin_lock_irqsave(&last_dev_task->task_state_lock, flags);		last_dev_task->task_state_flags |= SAS_TASK_NEED_DEV_RESET;		spin_unlock_irqrestore(&last_dev_task->task_state_lock, flags);		/* Kill all pending tasks for the device */		list_for_each_entry(a, &asd_ha->seq.pend_q, list) {			u16 x;			struct domain_device *dev;			struct sas_task *task = a->uldd_task;			if (!task)				continue;			dev = task->dev;			x = (unsigned long)dev->lldd_dev;			if (x == conn_handle)				sas_task_abort(task);		}		goto out;	}	case SIGNAL_NCQ_ERROR:		ASD_DPRINTK("%s: SIGNAL_NCQ_ERROR\n", __FUNCTION__);		goto out;	case CLEAR_NCQ_ERROR:		ASD_DPRINTK("%s: CLEAR_NCQ_ERROR\n", __FUNCTION__);		goto out;	}	sb_opcode &= ~DL_PHY_MASK;	switch (sb_opcode) {	case BYTES_DMAED:		ASD_DPRINTK("%s: phy%d: BYTES_DMAED\n", __FUNCTION__, phy_id);		asd_bytes_dmaed_tasklet(ascb, dl, edb, phy_id);		break;	case PRIMITIVE_RECVD:		ASD_DPRINTK("%s: phy%d: PRIMITIVE_RECVD\n", __FUNCTION__,			    phy_id);		asd_primitive_rcvd_tasklet(ascb, dl, phy_id);		break;	case PHY_EVENT:		ASD_DPRINTK("%s: phy%d: PHY_EVENT\n", __FUNCTION__, phy_id);		asd_phy_event_tasklet(ascb, dl);		break;	case LINK_RESET_ERROR:		ASD_DPRINTK("%s: phy%d: LINK_RESET_ERROR\n", __FUNCTION__,			    phy_id);		asd_link_reset_err_tasklet(ascb, dl, phy_id);		break;	case TIMER_EVENT:		ASD_DPRINTK("%s: phy%d: TIMER_EVENT, lost dw sync\n",			    __FUNCTION__, phy_id);		asd_turn_led(asd_ha, phy_id, 0);		/* the device is gone */		sas_phy_disconnected(sas_phy);		asd_deform_port(asd_ha, phy);		sas_ha->notify_port_event(sas_phy, PORTE_TIMER_EVENT);		break;	default:		ASD_DPRINTK("%s: phy%d: unknown event:0x%x\n", __FUNCTION__,			    phy_id, sb_opcode);		ASD_DPRINTK("edb is 0x%x! dl->opcode is 0x%x\n",			    edb, dl->opcode);		ASD_DPRINTK("sb_opcode : 0x%x, phy_id: 0x%x\n",			    sb_opcode, phy_id);		ASD_DPRINTK("escb: vaddr: 0x%p, "			    "dma_handle: 0x%llx, next: 0x%llx, "			    "index:%d, opcode:0x%02x\n",			    ascb->dma_scb.vaddr,			    (unsigned long long)ascb->dma_scb.dma_handle,			    (unsigned long long)			    le64_to_cpu(ascb->scb->header.next_scb),			    le16_to_cpu(ascb->scb->header.index),			    ascb->scb->header.opcode);		break;	}out:	asd_invalidate_edb(ascb, edb);}int asd_init_post_escbs(struct asd_ha_struct *asd_ha){	struct asd_seq_data *seq = &asd_ha->seq;	int i;	for (i = 0; i < seq->num_escbs; i++)		seq->escb_arr[i]->tasklet_complete = escb_tasklet_complete;	ASD_DPRINTK("posting %d escbs\n", i);	return asd_post_escb_list(asd_ha, seq->escb_arr[0], seq->num_escbs);}/* ---------- CONTROL PHY ---------- */#define CONTROL_PHY_STATUS (CURRENT_DEVICE_PRESENT | CURRENT_OOB_DONE   \			    | CURRENT_SPINUP_HOLD | CURRENT_GTO_TIMEOUT \			    | CURRENT_OOB_ERROR)/** * control_phy_tasklet_complete -- tasklet complete for CONTROL PHY ascb * @ascb: pointer to an ascb * @dl: pointer to the done list entry * * This function completes a CONTROL PHY scb and frees the ascb. * A note on LEDs: *  - an LED blinks if there is IO though it, *  - if a device is connected to the LED, it is lit, *  - if no device is connected to the LED, is is dimmed (off). */static void control_phy_tasklet_complete(struct asd_ascb *ascb,					 struct done_list_struct *dl){	struct asd_ha_struct *asd_ha = ascb->ha;	struct scb *scb = ascb->scb;	struct control_phy *control_phy = &scb->control_phy;	u8 phy_id = control_phy->phy_id;	struct asd_phy *phy = &ascb->ha->phys[phy_id];	u8 status     = dl->status_block[0];	u8 oob_status = dl->status_block[1];	u8 oob_mode   = dl->status_block[2];	/* u8 oob_signals= dl->status_block[3]; */	if (status != 0) {		ASD_DPRINTK("%s: phy%d status block opcode:0x%x\n",			    __FUNCTION__, phy_id, status);		goto out;	}	switch (control_phy->sub_func) {	case DISABLE_PHY:		asd_ha->hw_prof.enabled_phys &= ~(1 << phy_id);		asd_turn_led(asd_ha, phy_id, 0);		asd_control_led(asd_ha, phy_id, 0);		ASD_DPRINTK("%s: disable phy%d\n", __FUNCTION__, phy_id);		break;	case ENABLE_PHY:		asd_control_led(asd_ha, phy_id, 1);		if (oob_status & CURRENT_OOB_DONE) {			asd_ha->hw_prof.enabled_phys |= (1 << phy_id);			get_lrate_mode(phy, oob_mode);			asd_turn_led(asd_ha, phy_id, 1);			ASD_DPRINTK("%s: phy%d, lrate:0x%x, proto:0x%x\n",				    __FUNCTION__, phy_id,phy->sas_phy.linkrate,				    phy->sas_phy.iproto);		} else if (oob_status & CURRENT_SPINUP_HOLD) {			asd_ha->hw_prof.enabled_phys |= (1 << phy_id);			asd_turn_led(asd_ha, phy_id, 1);			ASD_DPRINTK("%s: phy%d, spinup hold\n", __FUNCTION__,				    phy_id);		} else if (oob_status & CURRENT_ERR_MASK) {			asd_turn_led(asd_ha, phy_id, 0);			ASD_DPRINTK("%s: phy%d: error: oob status:0x%02x\n",				    __FUNCTION__, phy_id, oob_status);		} else if (oob_status & (CURRENT_HOT_PLUG_CNCT					 | CURRENT_DEVICE_PRESENT))  {			asd_ha->hw_prof.enabled_phys |= (1 << phy_id);			asd_turn_led(asd_ha, phy_id, 1);			ASD_DPRINTK("%s: phy%d: hot plug or device present\n",				    __FUNCTION__, phy_id);		} else {			asd_ha->hw_prof.enabled_phys |= (1 << phy_id);			asd_turn_led(asd_ha, phy_id, 0);			ASD_DPRINTK("%s: phy%d: no device present: "				    "oob_status:0x%x\n",				    __FUNCTION__, phy_id, oob_status);		}		break;	case RELEASE_SPINUP_HOLD:	case PHY_NO_OP:	case EXECUTE_HARD_RESET:		ASD_DPRINTK("%s: phy%d: sub_func:0x%x\n", __FUNCTION__,			    phy_id, control_phy->sub_func);		/* XXX finish */		break;	default:		ASD_DPRINTK("%s: phy%d: sub_func:0x%x?\n", __FUNCTION__,			    phy_id, control_phy->sub_func);		break;	}out:	asd_ascb_free(ascb);}static inline void set_speed_mask(u8 *speed_mask, struct asd_phy_desc *pd){	/* disable all speeds, then enable defaults */	*speed_mask = SAS_SPEED_60_DIS | SAS_SPEED_30_DIS | SAS_SPEED_15_DIS		| SATA_SPEED_30_DIS | SATA_SPEED_15_DIS;	switch (pd->max_sas_lrate) {	case SAS_LINK_RATE_6_0_GBPS:		*speed_mask &= ~SAS_SPEED_60_DIS;	default:	case SAS_LINK_RATE_3_0_GBPS:		*speed_mask &= ~SAS_SPEED_30_DIS;	case SAS_LINK_RATE_1_5_GBPS:		*speed_mask &= ~SAS_SPEED_15_DIS;	}	switch (pd->min_sas_lrate) {	case SAS_LINK_RATE_6_0_GBPS:		*speed_mask |= SAS_SPEED_30_DIS;	case SAS_LINK_RATE_3_0_GBPS:		*speed_mask |= SAS_SPEED_15_DIS;	default:	case SAS_LINK_RATE_1_5_GBPS:		/* nothing to do */		;	}	switch (pd->max_sata_lrate) {	case SAS_LINK_RATE_3_0_GBPS:		*speed_mask &= ~SATA_SPEED_30_DIS;	default:	case SAS_LINK_RATE_1_5_GBPS:		*speed_mask &= ~SATA_SPEED_15_DIS;	}	switch (pd->min_sata_lrate) {	case SAS_LINK_RATE_3_0_GBPS:		*speed_mask |= SATA_SPEED_15_DIS;	default:	case SAS_LINK_RATE_1_5_GBPS:		/* nothing to do */		;	}}/** * asd_build_control_phy -- build a CONTROL PHY SCB * @ascb: pointer to an ascb * @phy_id: phy id to control, integer * @subfunc: subfunction, what to actually to do the phy * * This function builds a CONTROL PHY scb.  No allocation of any kind * is performed. @ascb is allocated with the list function. * The caller can override the ascb->tasklet_complete to point * to its own callback function.  It must call asd_ascb_free() * at its tasklet complete function. * See the default implementation. */void asd_build_control_phy(struct asd_ascb *ascb, int phy_id, u8 subfunc){	struct asd_phy *phy = &ascb->ha->phys[phy_id];	struct scb *scb = ascb->scb;	struct control_phy *control_phy = &scb->control_phy;	scb->header.opcode = CONTROL_PHY;	control_phy->phy_id = (u8) phy_id;	control_phy->sub_func = subfunc;	switch (subfunc) {	case EXECUTE_HARD_RESET:  /* 0x81 */	case ENABLE_PHY:          /* 0x01 */		/* decide hot plug delay */		control_phy->hot_plug_delay = HOTPLUG_DELAY_TIMEOUT;		/* decide speed mask */		set_speed_mask(&control_phy->speed_mask, phy->phy_desc);		/* initiator port settings are in the hi nibble */		if (phy->sas_phy.role == PHY_ROLE_INITIATOR)			control_phy->port_type = SAS_PROTO_ALL << 4;		else if (phy->sas_phy.role == PHY_ROLE_TARGET)			control_phy->port_type = SAS_PROTO_ALL;		else			control_phy->port_type =				(SAS_PROTO_ALL << 4) | SAS_PROTO_ALL;		/* link reset retries, this should be nominal */		control_phy->link_reset_retries = 10;	case RELEASE_SPINUP_HOLD: /* 0x02 */		/* decide the func_mask */		control_phy->func_mask = FUNCTION_MASK_DEFAULT;		if (phy->phy_desc->flags & ASD_SATA_SPINUP_HOLD)			control_phy->func_mask &= ~SPINUP_HOLD_DIS;		else			control_phy->func_mask |= SPINUP_HOLD_DIS;	}	control_phy->conn_handle = cpu_to_le16(0xFFFF);	ascb->tasklet_complete = control_phy_tasklet_complete;}/* ---------- INITIATE LINK ADM TASK ---------- */static void link_adm_tasklet_complete(struct asd_ascb *ascb,				      struct done_list_struct *dl){	u8 opcode = dl->opcode;	struct initiate_link_adm *link_adm = &ascb->scb->link_adm;	u8 phy_id = link_adm->phy_id;	if (opcode != TC_NO_ERROR) {		asd_printk("phy%d: link adm task 0x%x completed with error "			   "0x%x\n", phy_id, link_adm->sub_func, opcode);	}	ASD_DPRINTK("phy%d: link adm task 0x%x: 0x%x\n",		    phy_id, link_adm->sub_func, opcode);	asd_ascb_free(ascb);}void asd_build_initiate_link_adm_task(struct asd_ascb *ascb, int phy_id,				      u8 subfunc){	struct scb *scb = ascb->scb;	struct initiate_link_adm *link_adm = &scb->link_adm;	scb->header.opcode = INITIATE_LINK_ADM_TASK;	link_adm->phy_id = phy_id;	link_adm->sub_func = subfunc;	link_adm->conn_handle = cpu_to_le16(0xFFFF);	ascb->tasklet_complete = link_adm_tasklet_complete;}/* ---------- SCB timer ---------- *//** * asd_ascb_timedout -- called when a pending SCB's timer has expired * @data: unsigned long, a pointer to the ascb in question * * This is the default timeout function which does the most necessary. * Upper layers can implement their own timeout function, say to free * resources they have with this SCB, and then call this one at the * end of their timeout function.  To do this, one should initialize * the ascb->timer.{function, data, expires} prior to calling the post * funcion.  The timer is started by the post function. */void asd_ascb_timedout(unsigned long data){	struct asd_ascb *ascb = (void *) data;	struct asd_seq_data *seq = &ascb->ha->seq;	unsigned long flags;	ASD_DPRINTK("scb:0x%x timed out\n", ascb->scb->header.opcode);	spin_lock_irqsave(&seq->pend_q_lock, flags);	seq->pending--;	list_del_init(&ascb->list);	spin_unlock_irqrestore(&seq->pend_q_lock, flags);	asd_ascb_free(ascb);}/* ---------- CONTROL PHY ---------- *//* Given the spec value, return a driver value. */static const int phy_func_table[] = {	[PHY_FUNC_NOP]        = PHY_NO_OP,	[PHY_FUNC_LINK_RESET] = ENABLE_PHY,	[PHY_FUNC_HARD_RESET] = EXECUTE_HARD_RESET,	[PHY_FUNC_DISABLE]    = DISABLE_PHY,	[PHY_FUNC_RELEASE_SPINUP_HOLD] = RELEASE_SPINUP_HOLD,};int asd_control_phy(struct asd_sas_phy *phy, enum phy_func func, void *arg){	struct asd_ha_struct *asd_ha = phy->ha->lldd_ha;	struct asd_phy_desc *pd = asd_ha->phys[phy->id].phy_desc;	struct asd_ascb *ascb;	struct sas_phy_linkrates *rates;	int res = 1;	switch (func) {	case PHY_FUNC_CLEAR_ERROR_LOG:		return -ENOSYS;	case PHY_FUNC_SET_LINK_RATE:		rates = arg;		if (rates->minimum_linkrate) {			pd->min_sas_lrate = rates->minimum_linkrate;			pd->min_sata_lrate = rates->minimum_linkrate;		}		if (rates->maximum_linkrate) {			pd->max_sas_lrate = rates->maximum_linkrate;			pd->max_sata_lrate = rates->maximum_linkrate;		}		func = PHY_FUNC_LINK_RESET;		break;	default:		break;	}	ascb = asd_ascb_alloc_list(asd_ha, &res, GFP_KERNEL);	if (!ascb)		return -ENOMEM;	asd_build_control_phy(ascb, phy->id, phy_func_table[func]);	res = asd_post_ascb_list(asd_ha, ascb , 1);	if (res)		asd_ascb_free(ascb);	return res;}

⌨️ 快捷键说明

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