Lines Matching +full:d +full:- +full:phy

1 // SPDX-License-Identifier: GPL-2.0-only
19 /* ---------- EMPTY SCB ---------- */
36 static void get_lrate_mode(struct asd_phy *phy, u8 oob_mode) in get_lrate_mode() argument
38 struct sas_phy *sas_phy = phy->sas_phy.phy; in get_lrate_mode()
43 phy->sas_phy.linkrate = SAS_LINK_RATE_6_0_GBPS; in get_lrate_mode()
44 phy->sas_phy.phy->negotiated_linkrate = SAS_LINK_RATE_6_0_GBPS; in get_lrate_mode()
47 phy->sas_phy.linkrate = SAS_LINK_RATE_3_0_GBPS; in get_lrate_mode()
48 phy->sas_phy.phy->negotiated_linkrate = SAS_LINK_RATE_3_0_GBPS; in get_lrate_mode()
51 phy->sas_phy.linkrate = SAS_LINK_RATE_1_5_GBPS; in get_lrate_mode()
52 phy->sas_phy.phy->negotiated_linkrate = SAS_LINK_RATE_1_5_GBPS; in get_lrate_mode()
55 sas_phy->negotiated_linkrate = phy->sas_phy.linkrate; in get_lrate_mode()
56 sas_phy->maximum_linkrate_hw = SAS_LINK_RATE_3_0_GBPS; in get_lrate_mode()
57 sas_phy->minimum_linkrate_hw = SAS_LINK_RATE_1_5_GBPS; in get_lrate_mode()
58 sas_phy->maximum_linkrate = phy->phy_desc->max_sas_lrate; in get_lrate_mode()
59 sas_phy->minimum_linkrate = phy->phy_desc->min_sas_lrate; in get_lrate_mode()
62 phy->sas_phy.oob_mode = SAS_OOB_MODE; in get_lrate_mode()
64 phy->sas_phy.oob_mode = SATA_OOB_MODE; in get_lrate_mode()
70 struct asd_ha_struct *asd_ha = ascb->ha; in asd_phy_event_tasklet()
71 int phy_id = dl->status_block[0] & DL_PHY_MASK; in asd_phy_event_tasklet()
72 struct asd_phy *phy = &asd_ha->phys[phy_id]; in asd_phy_event_tasklet() local
74 u8 oob_status = dl->status_block[1] & PHY_EVENTS_STATUS; in asd_phy_event_tasklet()
75 u8 oob_mode = dl->status_block[2]; in asd_phy_event_tasklet()
80 ASD_DPRINTK("phy%d: device unplugged\n", phy_id); in asd_phy_event_tasklet()
82 sas_phy_disconnected(&phy->sas_phy); in asd_phy_event_tasklet()
83 sas_notify_phy_event(&phy->sas_phy, PHYE_LOSS_OF_SIGNAL); in asd_phy_event_tasklet()
88 get_lrate_mode(phy, oob_mode); in asd_phy_event_tasklet()
89 ASD_DPRINTK("phy%d device plugged: lrate:0x%x, proto:0x%x\n", in asd_phy_event_tasklet()
90 phy_id, phy->sas_phy.linkrate, phy->sas_phy.iproto); in asd_phy_event_tasklet()
91 sas_notify_phy_event(&phy->sas_phy, PHYE_OOB_DONE); in asd_phy_event_tasklet()
96 sas_notify_phy_event(&phy->sas_phy, PHYE_SPINUP_HOLD); in asd_phy_event_tasklet()
100 ASD_DPRINTK("phy%d error while OOB: oob status:0x%x\n", phy_id, in asd_phy_event_tasklet()
101 dl->status_block[1]); in asd_phy_event_tasklet()
103 sas_phy_disconnected(&phy->sas_phy); in asd_phy_event_tasklet()
104 sas_notify_phy_event(&phy->sas_phy, PHYE_OOB_ERROR); in asd_phy_event_tasklet()
110 static unsigned ord_phy(struct asd_ha_struct *asd_ha, struct asd_phy *phy) in ord_phy() argument
112 u8 enabled_mask = asd_ha->hw_prof.enabled_phys; in ord_phy()
116 if (&asd_ha->phys[i] == phy) in ord_phy()
124 * asd_get_attached_sas_addr -- extract/generate attached SAS address
125 * @phy: pointer to asd_phy
135 static void asd_get_attached_sas_addr(struct asd_phy *phy, u8 *sas_addr) in asd_get_attached_sas_addr() argument
137 if (phy->sas_phy.frame_rcvd[0] == 0x34 in asd_get_attached_sas_addr()
138 && phy->sas_phy.oob_mode == SATA_OOB_MODE) { in asd_get_attached_sas_addr()
139 struct asd_ha_struct *asd_ha = phy->sas_phy.ha->lldd_ha; in asd_get_attached_sas_addr()
140 /* FIS device-to-host */ in asd_get_attached_sas_addr()
141 u64 addr = be64_to_cpu(*(__be64 *)phy->phy_desc->sas_addr); in asd_get_attached_sas_addr()
143 addr += asd_ha->hw_prof.sata_name_base + ord_phy(asd_ha, phy); in asd_get_attached_sas_addr()
147 (void *) phy->sas_phy.frame_rcvd; in asd_get_attached_sas_addr()
148 memcpy(sas_addr, idframe->sas_addr, SAS_ADDR_SIZE); in asd_get_attached_sas_addr()
152 static void asd_form_port(struct asd_ha_struct *asd_ha, struct asd_phy *phy) in asd_form_port() argument
157 struct asd_sas_phy *sas_phy = &phy->sas_phy; in asd_form_port()
160 spin_lock_irqsave(&asd_ha->asd_ports_lock, flags); in asd_form_port()
161 if (!phy->asd_port) { in asd_form_port()
163 port = &asd_ha->asd_ports[i]; in asd_form_port()
166 if (port->num_phys > 0 && in asd_form_port()
167 memcmp(port->sas_addr, sas_phy->sas_addr, in asd_form_port()
169 memcmp(port->attached_sas_addr, in asd_form_port()
170 sas_phy->attached_sas_addr, in asd_form_port()
176 if (port->num_phys == 0 && free_port == NULL) { in asd_form_port()
185 memcpy(port->sas_addr, sas_phy->sas_addr, in asd_form_port()
187 memcpy(port->attached_sas_addr, in asd_form_port()
188 sas_phy->attached_sas_addr, in asd_form_port()
191 port->num_phys++; in asd_form_port()
192 port->phy_mask |= (1U << sas_phy->id); in asd_form_port()
193 phy->asd_port = port; in asd_form_port()
195 ASD_DPRINTK("%s: updating phy_mask 0x%x for phy%d\n", in asd_form_port()
196 __func__, phy->asd_port->phy_mask, sas_phy->id); in asd_form_port()
197 asd_update_port_links(asd_ha, phy); in asd_form_port()
198 spin_unlock_irqrestore(&asd_ha->asd_ports_lock, flags); in asd_form_port()
201 static void asd_deform_port(struct asd_ha_struct *asd_ha, struct asd_phy *phy) in asd_deform_port() argument
203 struct asd_port *port = phy->asd_port; in asd_deform_port()
204 struct asd_sas_phy *sas_phy = &phy->sas_phy; in asd_deform_port()
207 spin_lock_irqsave(&asd_ha->asd_ports_lock, flags); in asd_deform_port()
209 port->num_phys--; in asd_deform_port()
210 port->phy_mask &= ~(1U << sas_phy->id); in asd_deform_port()
211 phy->asd_port = NULL; in asd_deform_port()
213 spin_unlock_irqrestore(&asd_ha->asd_ports_lock, flags); in asd_deform_port()
221 int edb_el = edb_id + ascb->edb_index; in asd_bytes_dmaed_tasklet()
222 struct asd_dma_tok *edb = ascb->ha->seq.edb_arr[edb_el]; in asd_bytes_dmaed_tasklet()
223 struct asd_phy *phy = &ascb->ha->phys[phy_id]; in asd_bytes_dmaed_tasklet() local
224 u16 size = ((dl->status_block[3] & 7) << 8) | dl->status_block[2]; in asd_bytes_dmaed_tasklet()
226 size = min(size, (u16) sizeof(phy->frame_rcvd)); in asd_bytes_dmaed_tasklet()
228 spin_lock_irqsave(&phy->sas_phy.frame_rcvd_lock, flags); in asd_bytes_dmaed_tasklet()
229 memcpy(phy->sas_phy.frame_rcvd, edb->vaddr, size); in asd_bytes_dmaed_tasklet()
230 phy->sas_phy.frame_rcvd_size = size; in asd_bytes_dmaed_tasklet()
231 asd_get_attached_sas_addr(phy, phy->sas_phy.attached_sas_addr); in asd_bytes_dmaed_tasklet()
232 spin_unlock_irqrestore(&phy->sas_phy.frame_rcvd_lock, flags); in asd_bytes_dmaed_tasklet()
233 asd_dump_frame_rcvd(phy, dl); in asd_bytes_dmaed_tasklet()
234 asd_form_port(ascb->ha, phy); in asd_bytes_dmaed_tasklet()
235 sas_notify_port_event(&phy->sas_phy, PORTE_BYTES_DMAED); in asd_bytes_dmaed_tasklet()
242 struct asd_ha_struct *asd_ha = ascb->ha; in asd_link_reset_err_tasklet()
243 struct sas_ha_struct *sas_ha = &asd_ha->sas_ha; in asd_link_reset_err_tasklet()
244 struct asd_sas_phy *sas_phy = sas_ha->sas_phy[phy_id]; in asd_link_reset_err_tasklet()
245 struct asd_phy *phy = &asd_ha->phys[phy_id]; in asd_link_reset_err_tasklet() local
246 u8 lr_error = dl->status_block[1]; in asd_link_reset_err_tasklet()
247 u8 retries_left = dl->status_block[2]; in asd_link_reset_err_tasklet()
251 ASD_DPRINTK("phy%d: Receive ID timer expired\n", phy_id); in asd_link_reset_err_tasklet()
254 ASD_DPRINTK("phy%d: Loss of signal\n", phy_id); in asd_link_reset_err_tasklet()
257 ASD_DPRINTK("phy%d: Loss of dword sync\n", phy_id); in asd_link_reset_err_tasklet()
260 ASD_DPRINTK("phy%d: Receive FIS timeout\n", phy_id); in asd_link_reset_err_tasklet()
263 ASD_DPRINTK("phy%d: unknown link reset error code: 0x%x\n", in asd_link_reset_err_tasklet()
270 asd_deform_port(asd_ha, phy); in asd_link_reset_err_tasklet()
275 struct asd_ascb *cp = asd_ascb_alloc_list(ascb->ha, &num, in asd_link_reset_err_tasklet()
281 ASD_DPRINTK("phy%d: retries:0 performing link reset seq\n", in asd_link_reset_err_tasklet()
284 if (asd_post_ascb_list(ascb->ha, cp, 1) != 0) in asd_link_reset_err_tasklet()
296 struct sas_ha_struct *sas_ha = &ascb->ha->sas_ha; in asd_primitive_rcvd_tasklet()
297 struct asd_sas_phy *sas_phy = sas_ha->sas_phy[phy_id]; in asd_primitive_rcvd_tasklet()
298 struct asd_ha_struct *asd_ha = ascb->ha; in asd_primitive_rcvd_tasklet()
299 struct asd_phy *phy = &asd_ha->phys[phy_id]; in asd_primitive_rcvd_tasklet() local
300 u8 reg = dl->status_block[1]; in asd_primitive_rcvd_tasklet()
301 u32 cont = dl->status_block[2] << ((reg & 3)*8); in asd_primitive_rcvd_tasklet()
311 ASD_DPRINTK("phy%d: BROADCAST change received:%d\n", in asd_primitive_rcvd_tasklet()
313 spin_lock_irqsave(&sas_phy->sas_prim_lock, flags); in asd_primitive_rcvd_tasklet()
314 sas_phy->sas_prim = ffs(cont); in asd_primitive_rcvd_tasklet()
315 spin_unlock_irqrestore(&sas_phy->sas_prim_lock, flags); in asd_primitive_rcvd_tasklet()
320 ASD_DPRINTK("phy%d: unknown BREAK\n", phy_id); in asd_primitive_rcvd_tasklet()
324 ASD_DPRINTK("phy%d: primitive reg:0x%x, cont:0x%04x\n", in asd_primitive_rcvd_tasklet()
332 ASD_DPRINTK("phy%d: HARD_RESET primitive rcvd\n", in asd_primitive_rcvd_tasklet()
335 * We have to re-enable the phys ourselves. */ in asd_primitive_rcvd_tasklet()
336 asd_deform_port(asd_ha, phy); in asd_primitive_rcvd_tasklet()
341 ASD_DPRINTK("phy%d: primitive reg:0x%x, cont:0x%04x\n", in asd_primitive_rcvd_tasklet()
348 dl->status_block[1]); in asd_primitive_rcvd_tasklet()
354 * asd_invalidate_edb -- invalidate an EDB and if necessary post the ESCB
364 struct asd_seq_data *seq = &ascb->ha->seq; in asd_invalidate_edb()
365 struct empty_scb *escb = &ascb->scb->escb; in asd_invalidate_edb()
366 struct sg_el *eb = &escb->eb[edb_id]; in asd_invalidate_edb()
367 struct asd_dma_tok *edb = seq->edb_arr[ascb->edb_index + edb_id]; in asd_invalidate_edb()
369 memset(edb->vaddr, 0, ASD_EDB_SIZE); in asd_invalidate_edb()
370 eb->flags |= ELEMENT_NOT_VALID; in asd_invalidate_edb()
371 escb->num_valid--; in asd_invalidate_edb()
373 if (escb->num_valid == 0) { in asd_invalidate_edb()
377 "index:%d, opcode:0x%02x\n", in asd_invalidate_edb()
378 ascb->dma_scb.vaddr, in asd_invalidate_edb()
379 (u64)ascb->dma_scb.dma_handle, in asd_invalidate_edb()
380 le64_to_cpu(ascb->scb->header.next_scb), in asd_invalidate_edb()
381 le16_to_cpu(ascb->scb->header.index), in asd_invalidate_edb()
382 ascb->scb->header.opcode); in asd_invalidate_edb()
384 escb->num_valid = ASD_EDBS_PER_SCB; in asd_invalidate_edb()
386 escb->eb[i].flags = 0; in asd_invalidate_edb()
387 if (!list_empty(&ascb->list)) in asd_invalidate_edb()
388 list_del_init(&ascb->list); in asd_invalidate_edb()
389 i = asd_post_escb_list(ascb->ha, ascb, 1); in asd_invalidate_edb()
391 asd_printk("couldn't post escb, err:%d\n", i); in asd_invalidate_edb()
398 struct asd_ha_struct *asd_ha = ascb->ha; in escb_tasklet_complete()
399 struct sas_ha_struct *sas_ha = &asd_ha->sas_ha; in escb_tasklet_complete()
400 int edb = (dl->opcode & DL_PHY_MASK) - 1; /* [0xc1,0xc7] -> [0,6] */ in escb_tasklet_complete()
401 u8 sb_opcode = dl->status_block[0]; in escb_tasklet_complete()
403 struct asd_sas_phy *sas_phy = sas_ha->sas_phy[phy_id]; in escb_tasklet_complete()
404 struct asd_phy *phy = &asd_ha->phys[phy_id]; in escb_tasklet_complete() local
407 ASD_DPRINTK("edb is 0x%x! dl->opcode is 0x%x\n", in escb_tasklet_complete()
408 edb, dl->opcode); in escb_tasklet_complete()
413 "index:%d, opcode:0x%02x\n", in escb_tasklet_complete()
414 ascb->dma_scb.vaddr, in escb_tasklet_complete()
415 (unsigned long long)ascb->dma_scb.dma_handle, in escb_tasklet_complete()
417 le64_to_cpu(ascb->scb->header.next_scb), in escb_tasklet_complete()
418 le16_to_cpu(ascb->scb->header.index), in escb_tasklet_complete()
419 ascb->scb->header.opcode); in escb_tasklet_complete()
430 __func__, dl->status_block[3]); in escb_tasklet_complete()
437 tc_abort = *((u16*)(&dl->status_block[1])); in escb_tasklet_complete()
440 list_for_each_entry_safe(a, b, &asd_ha->seq.pend_q, list) { in escb_tasklet_complete()
441 struct sas_task *task = a->uldd_task; in escb_tasklet_complete()
443 if (a->tc_index != tc_abort) in escb_tasklet_complete()
447 failed_dev = task->dev; in escb_tasklet_complete()
451 a->scb->header.opcode); in escb_tasklet_complete()
457 ASD_DPRINTK("%s: Can't find task (tc=%d) to abort!\n", in escb_tasklet_complete()
466 list_for_each_entry_safe(a, b, &asd_ha->seq.pend_q, list) { in escb_tasklet_complete()
467 struct sas_task *task = a->uldd_task; in escb_tasklet_complete()
470 task->dev == failed_dev && in escb_tasklet_complete()
471 a->tc_index != tc_abort) in escb_tasklet_complete()
483 conn_handle = *((u16*)(&dl->status_block[1])); in escb_tasklet_complete()
487 dl->status_block[3]); in escb_tasklet_complete()
490 list_for_each_entry(a, &asd_ha->seq.pend_q, list) { in escb_tasklet_complete()
493 struct sas_task *task = a->uldd_task; in escb_tasklet_complete()
497 dev = task->dev; in escb_tasklet_complete()
499 x = (unsigned long)dev->lldd_dev; in escb_tasklet_complete()
505 ASD_DPRINTK("%s: Device reset for idle device %d?\n", in escb_tasklet_complete()
511 spin_lock_irqsave(&last_dev_task->task_state_lock, flags); in escb_tasklet_complete()
512 last_dev_task->task_state_flags |= SAS_TASK_NEED_DEV_RESET; in escb_tasklet_complete()
513 spin_unlock_irqrestore(&last_dev_task->task_state_lock, flags); in escb_tasklet_complete()
516 list_for_each_entry(a, &asd_ha->seq.pend_q, list) { in escb_tasklet_complete()
519 struct sas_task *task = a->uldd_task; in escb_tasklet_complete()
523 dev = task->dev; in escb_tasklet_complete()
525 x = (unsigned long)dev->lldd_dev; in escb_tasklet_complete()
544 ASD_DPRINTK("%s: phy%d: BYTES_DMAED\n", __func__, phy_id); in escb_tasklet_complete()
548 ASD_DPRINTK("%s: phy%d: PRIMITIVE_RECVD\n", __func__, in escb_tasklet_complete()
553 ASD_DPRINTK("%s: phy%d: PHY_EVENT\n", __func__, phy_id); in escb_tasklet_complete()
557 ASD_DPRINTK("%s: phy%d: LINK_RESET_ERROR\n", __func__, in escb_tasklet_complete()
562 ASD_DPRINTK("%s: phy%d: TIMER_EVENT, lost dw sync\n", in escb_tasklet_complete()
567 asd_deform_port(asd_ha, phy); in escb_tasklet_complete()
571 ASD_DPRINTK("%s: phy%d: unknown event:0x%x\n", __func__, in escb_tasklet_complete()
573 ASD_DPRINTK("edb is 0x%x! dl->opcode is 0x%x\n", in escb_tasklet_complete()
574 edb, dl->opcode); in escb_tasklet_complete()
579 "index:%d, opcode:0x%02x\n", in escb_tasklet_complete()
580 ascb->dma_scb.vaddr, in escb_tasklet_complete()
581 (unsigned long long)ascb->dma_scb.dma_handle, in escb_tasklet_complete()
583 le64_to_cpu(ascb->scb->header.next_scb), in escb_tasklet_complete()
584 le16_to_cpu(ascb->scb->header.index), in escb_tasklet_complete()
585 ascb->scb->header.opcode); in escb_tasklet_complete()
595 struct asd_seq_data *seq = &asd_ha->seq; in asd_init_post_escbs()
598 for (i = 0; i < seq->num_escbs; i++) in asd_init_post_escbs()
599 seq->escb_arr[i]->tasklet_complete = escb_tasklet_complete; in asd_init_post_escbs()
601 ASD_DPRINTK("posting %d escbs\n", i); in asd_init_post_escbs()
602 return asd_post_escb_list(asd_ha, seq->escb_arr[0], seq->num_escbs); in asd_init_post_escbs()
605 /* ---------- CONTROL PHY ---------- */
612 * control_phy_tasklet_complete -- tasklet complete for CONTROL PHY ascb
616 * This function completes a CONTROL PHY scb and frees the ascb.
618 * - an LED blinks if there is IO though it,
619 * - if a device is connected to the LED, it is lit,
620 * - if no device is connected to the LED, is is dimmed (off).
625 struct asd_ha_struct *asd_ha = ascb->ha; in control_phy_tasklet_complete()
626 struct scb *scb = ascb->scb; in control_phy_tasklet_complete()
627 struct control_phy *control_phy = &scb->control_phy; in control_phy_tasklet_complete()
628 u8 phy_id = control_phy->phy_id; in control_phy_tasklet_complete()
629 struct asd_phy *phy = &ascb->ha->phys[phy_id]; in control_phy_tasklet_complete() local
631 u8 status = dl->status_block[0]; in control_phy_tasklet_complete()
632 u8 oob_status = dl->status_block[1]; in control_phy_tasklet_complete()
633 u8 oob_mode = dl->status_block[2]; in control_phy_tasklet_complete()
634 /* u8 oob_signals= dl->status_block[3]; */ in control_phy_tasklet_complete()
637 ASD_DPRINTK("%s: phy%d status block opcode:0x%x\n", in control_phy_tasklet_complete()
642 switch (control_phy->sub_func) { in control_phy_tasklet_complete()
644 asd_ha->hw_prof.enabled_phys &= ~(1 << phy_id); in control_phy_tasklet_complete()
647 ASD_DPRINTK("%s: disable phy%d\n", __func__, phy_id); in control_phy_tasklet_complete()
653 asd_ha->hw_prof.enabled_phys |= (1 << phy_id); in control_phy_tasklet_complete()
654 get_lrate_mode(phy, oob_mode); in control_phy_tasklet_complete()
656 ASD_DPRINTK("%s: phy%d, lrate:0x%x, proto:0x%x\n", in control_phy_tasklet_complete()
657 __func__, phy_id,phy->sas_phy.linkrate, in control_phy_tasklet_complete()
658 phy->sas_phy.iproto); in control_phy_tasklet_complete()
660 asd_ha->hw_prof.enabled_phys |= (1 << phy_id); in control_phy_tasklet_complete()
662 ASD_DPRINTK("%s: phy%d, spinup hold\n", __func__, in control_phy_tasklet_complete()
666 ASD_DPRINTK("%s: phy%d: error: oob status:0x%02x\n", in control_phy_tasklet_complete()
670 asd_ha->hw_prof.enabled_phys |= (1 << phy_id); in control_phy_tasklet_complete()
672 ASD_DPRINTK("%s: phy%d: hot plug or device present\n", in control_phy_tasklet_complete()
675 asd_ha->hw_prof.enabled_phys |= (1 << phy_id); in control_phy_tasklet_complete()
677 ASD_DPRINTK("%s: phy%d: no device present: " in control_phy_tasklet_complete()
685 ASD_DPRINTK("%s: phy%d: sub_func:0x%x\n", __func__, in control_phy_tasklet_complete()
686 phy_id, control_phy->sub_func); in control_phy_tasklet_complete()
690 ASD_DPRINTK("%s: phy%d: sub_func:0x%x?\n", __func__, in control_phy_tasklet_complete()
691 phy_id, control_phy->sub_func); in control_phy_tasklet_complete()
704 switch (pd->max_sas_lrate) { in set_speed_mask()
716 switch (pd->min_sas_lrate) { in set_speed_mask()
728 switch (pd->max_sata_lrate) { in set_speed_mask()
737 switch (pd->min_sata_lrate) { in set_speed_mask()
748 * asd_build_control_phy -- build a CONTROL PHY SCB
750 * @phy_id: phy id to control, integer
751 * @subfunc: subfunction, what to actually to do the phy
753 * This function builds a CONTROL PHY scb. No allocation of any kind
755 * The caller can override the ascb->tasklet_complete to point
762 struct asd_phy *phy = &ascb->ha->phys[phy_id]; in asd_build_control_phy() local
763 struct scb *scb = ascb->scb; in asd_build_control_phy()
764 struct control_phy *control_phy = &scb->control_phy; in asd_build_control_phy()
766 scb->header.opcode = CONTROL_PHY; in asd_build_control_phy()
767 control_phy->phy_id = (u8) phy_id; in asd_build_control_phy()
768 control_phy->sub_func = subfunc; in asd_build_control_phy()
774 control_phy->hot_plug_delay = HOTPLUG_DELAY_TIMEOUT; in asd_build_control_phy()
777 set_speed_mask(&control_phy->speed_mask, phy->phy_desc); in asd_build_control_phy()
780 if (phy->sas_phy.role == PHY_ROLE_INITIATOR) in asd_build_control_phy()
781 control_phy->port_type = SAS_PROTOCOL_ALL << 4; in asd_build_control_phy()
782 else if (phy->sas_phy.role == PHY_ROLE_TARGET) in asd_build_control_phy()
783 control_phy->port_type = SAS_PROTOCOL_ALL; in asd_build_control_phy()
785 control_phy->port_type = in asd_build_control_phy()
789 control_phy->link_reset_retries = 10; in asd_build_control_phy()
794 control_phy->func_mask = FUNCTION_MASK_DEFAULT; in asd_build_control_phy()
795 if (phy->phy_desc->flags & ASD_SATA_SPINUP_HOLD) in asd_build_control_phy()
796 control_phy->func_mask &= ~SPINUP_HOLD_DIS; in asd_build_control_phy()
798 control_phy->func_mask |= SPINUP_HOLD_DIS; in asd_build_control_phy()
801 control_phy->conn_handle = cpu_to_le16(0xFFFF); in asd_build_control_phy()
803 ascb->tasklet_complete = control_phy_tasklet_complete; in asd_build_control_phy()
806 /* ---------- INITIATE LINK ADM TASK ---------- */
813 u8 opcode = dl->opcode;
814 struct initiate_link_adm *link_adm = &ascb->scb->link_adm;
815 u8 phy_id = link_adm->phy_id;
818 asd_printk("phy%d: link adm task 0x%x completed with error "
819 "0x%x\n", phy_id, link_adm->sub_func, opcode);
821 ASD_DPRINTK("phy%d: link adm task 0x%x: 0x%x\n",
822 phy_id, link_adm->sub_func, opcode);
830 struct scb *scb = ascb->scb;
831 struct initiate_link_adm *link_adm = &scb->link_adm;
833 scb->header.opcode = INITIATE_LINK_ADM_TASK;
835 link_adm->phy_id = phy_id;
836 link_adm->sub_func = subfunc;
837 link_adm->conn_handle = cpu_to_le16(0xFFFF);
839 ascb->tasklet_complete = link_adm_tasklet_complete;
844 /* ---------- SCB timer ---------- */
847 * asd_ascb_timedout -- called when a pending SCB's timer has expired
854 * the ascb->timer.{function, expires} prior to calling the post
860 struct asd_seq_data *seq = &ascb->ha->seq; in asd_ascb_timedout()
863 ASD_DPRINTK("scb:0x%x timed out\n", ascb->scb->header.opcode); in asd_ascb_timedout()
865 spin_lock_irqsave(&seq->pend_q_lock, flags); in asd_ascb_timedout()
866 seq->pending--; in asd_ascb_timedout()
867 list_del_init(&ascb->list); in asd_ascb_timedout()
868 spin_unlock_irqrestore(&seq->pend_q_lock, flags); in asd_ascb_timedout()
873 /* ---------- CONTROL PHY ---------- */
884 int asd_control_phy(struct asd_sas_phy *phy, enum phy_func func, void *arg) in asd_control_phy() argument
886 struct asd_ha_struct *asd_ha = phy->ha->lldd_ha; in asd_control_phy()
887 struct asd_phy_desc *pd = asd_ha->phys[phy->id].phy_desc; in asd_control_phy()
895 return -ENOSYS; in asd_control_phy()
898 if (rates->minimum_linkrate) { in asd_control_phy()
899 pd->min_sas_lrate = rates->minimum_linkrate; in asd_control_phy()
900 pd->min_sata_lrate = rates->minimum_linkrate; in asd_control_phy()
902 if (rates->maximum_linkrate) { in asd_control_phy()
903 pd->max_sas_lrate = rates->maximum_linkrate; in asd_control_phy()
904 pd->max_sata_lrate = rates->maximum_linkrate; in asd_control_phy()
914 return -ENOMEM; in asd_control_phy()
916 asd_build_control_phy(ascb, phy->id, phy_func_table[func]); in asd_control_phy()