Lines Matching refs:orb

260 	void (*callback)(struct sbp2_orb * orb, struct sbp2_status * status);
400 struct sbp2_orb *orb = container_of(kref, struct sbp2_orb, kref); in free_orb() local
402 kfree(orb); in free_orb()
411 struct sbp2_orb *orb = NULL, *iter; in sbp2_status_write() local
441 orb = iter; in sbp2_status_write()
447 if (orb) { in sbp2_status_write()
448 orb->callback(orb, &status); in sbp2_status_write()
449 kref_put(&orb->kref, free_orb); /* orb callback reference */ in sbp2_status_write()
460 struct sbp2_orb *orb = data; in complete_transaction() local
472 spin_lock_irqsave(&orb->lu->tgt->lock, flags); in complete_transaction()
474 if (orb->rcode == -1) in complete_transaction()
475 orb->rcode = rcode; in complete_transaction()
476 if (orb->rcode != RCODE_COMPLETE) { in complete_transaction()
477 list_del(&orb->link); in complete_transaction()
478 spin_unlock_irqrestore(&orb->lu->tgt->lock, flags); in complete_transaction()
480 orb->callback(orb, NULL); in complete_transaction()
481 kref_put(&orb->kref, free_orb); /* orb callback reference */ in complete_transaction()
483 spin_unlock_irqrestore(&orb->lu->tgt->lock, flags); in complete_transaction()
486 kref_put(&orb->kref, free_orb); /* transaction callback reference */ in complete_transaction()
489 static void sbp2_send_orb(struct sbp2_orb *orb, struct sbp2_logical_unit *lu, in sbp2_send_orb() argument
497 orb_pointer.low = cpu_to_be32(orb->request_bus); in sbp2_send_orb()
499 orb->lu = lu; in sbp2_send_orb()
501 list_add_tail(&orb->link, &lu->orb_list); in sbp2_send_orb()
504 kref_get(&orb->kref); /* transaction callback reference */ in sbp2_send_orb()
505 kref_get(&orb->kref); /* orb callback reference */ in sbp2_send_orb()
507 fw_send_request(device->card, &orb->t, TCODE_WRITE_BLOCK_REQUEST, in sbp2_send_orb()
509 &orb_pointer, 8, complete_transaction, orb); in sbp2_send_orb()
515 struct sbp2_orb *orb, *next; in sbp2_cancel_orbs() local
524 list_for_each_entry_safe(orb, next, &list, link) { in sbp2_cancel_orbs()
526 if (fw_cancel_transaction(device->card, &orb->t) == 0) in sbp2_cancel_orbs()
529 orb->rcode = RCODE_CANCELLED; in sbp2_cancel_orbs()
530 orb->callback(orb, NULL); in sbp2_cancel_orbs()
531 kref_put(&orb->kref, free_orb); /* orb callback reference */ in sbp2_cancel_orbs()
540 struct sbp2_management_orb *orb = in complete_management_orb() local
544 memcpy(&orb->status, status, sizeof(*status)); in complete_management_orb()
545 complete(&orb->done); in complete_management_orb()
553 struct sbp2_management_orb *orb; in sbp2_send_management_orb() local
560 orb = kzalloc(sizeof(*orb), GFP_NOIO); in sbp2_send_management_orb()
561 if (orb == NULL) in sbp2_send_management_orb()
564 kref_init(&orb->base.kref); in sbp2_send_management_orb()
565 orb->response_bus = in sbp2_send_management_orb()
566 dma_map_single(device->card->device, &orb->response, in sbp2_send_management_orb()
567 sizeof(orb->response), DMA_FROM_DEVICE); in sbp2_send_management_orb()
568 if (dma_mapping_error(device->card->device, orb->response_bus)) in sbp2_send_management_orb()
571 orb->request.response.high = 0; in sbp2_send_management_orb()
572 orb->request.response.low = cpu_to_be32(orb->response_bus); in sbp2_send_management_orb()
574 orb->request.misc = cpu_to_be32( in sbp2_send_management_orb()
578 orb->request.length = cpu_to_be32( in sbp2_send_management_orb()
579 MANAGEMENT_ORB_RESPONSE_LENGTH(sizeof(orb->response))); in sbp2_send_management_orb()
581 orb->request.status_fifo.high = in sbp2_send_management_orb()
583 orb->request.status_fifo.low = in sbp2_send_management_orb()
588 orb->request.misc |= cpu_to_be32( in sbp2_send_management_orb()
596 init_completion(&orb->done); in sbp2_send_management_orb()
597 orb->base.callback = complete_management_orb; in sbp2_send_management_orb()
599 orb->base.request_bus = in sbp2_send_management_orb()
600 dma_map_single(device->card->device, &orb->request, in sbp2_send_management_orb()
601 sizeof(orb->request), DMA_TO_DEVICE); in sbp2_send_management_orb()
602 if (dma_mapping_error(device->card->device, orb->base.request_bus)) in sbp2_send_management_orb()
605 sbp2_send_orb(&orb->base, lu, node_id, generation, in sbp2_send_management_orb()
608 wait_for_completion_timeout(&orb->done, msecs_to_jiffies(timeout)); in sbp2_send_management_orb()
613 orb->base.rcode); in sbp2_send_management_orb()
617 if (orb->base.rcode != RCODE_COMPLETE) { in sbp2_send_management_orb()
619 orb->base.rcode); in sbp2_send_management_orb()
623 if (STATUS_GET_RESPONSE(orb->status) != 0 || in sbp2_send_management_orb()
624 STATUS_GET_SBP_STATUS(orb->status) != 0) { in sbp2_send_management_orb()
626 STATUS_GET_RESPONSE(orb->status), in sbp2_send_management_orb()
627 STATUS_GET_SBP_STATUS(orb->status)); in sbp2_send_management_orb()
633 dma_unmap_single(device->card->device, orb->base.request_bus, in sbp2_send_management_orb()
634 sizeof(orb->request), DMA_TO_DEVICE); in sbp2_send_management_orb()
636 dma_unmap_single(device->card->device, orb->response_bus, in sbp2_send_management_orb()
637 sizeof(orb->response), DMA_FROM_DEVICE); in sbp2_send_management_orb()
640 memcpy(response, orb->response, sizeof(orb->response)); in sbp2_send_management_orb()
641 kref_put(&orb->base.kref, free_orb); in sbp2_send_management_orb()
1280 struct sbp2_command_orb *orb) in sbp2_unmap_scatterlist() argument
1282 scsi_dma_unmap(orb->cmd); in sbp2_unmap_scatterlist()
1284 if (orb->request.misc & cpu_to_be32(COMMAND_ORB_PAGE_TABLE_PRESENT)) in sbp2_unmap_scatterlist()
1285 dma_unmap_single(card_device, orb->page_table_bus, in sbp2_unmap_scatterlist()
1286 sizeof(orb->page_table), DMA_TO_DEVICE); in sbp2_unmap_scatterlist()
1338 struct sbp2_command_orb *orb = in complete_command_orb() local
1363 orb->cmd->sense_buffer); in complete_command_orb()
1374 dma_unmap_single(device->card->device, orb->base.request_bus, in complete_command_orb()
1375 sizeof(orb->request), DMA_TO_DEVICE); in complete_command_orb()
1376 sbp2_unmap_scatterlist(device->card->device, orb); in complete_command_orb()
1378 orb->cmd->result = result; in complete_command_orb()
1379 scsi_done(orb->cmd); in complete_command_orb()
1382 static int sbp2_map_scatterlist(struct sbp2_command_orb *orb, in sbp2_map_scatterlist() argument
1385 struct scatterlist *sg = scsi_sglist(orb->cmd); in sbp2_map_scatterlist()
1388 n = scsi_dma_map(orb->cmd); in sbp2_map_scatterlist()
1400 orb->request.data_descriptor.high = in sbp2_map_scatterlist()
1402 orb->request.data_descriptor.low = in sbp2_map_scatterlist()
1404 orb->request.misc |= in sbp2_map_scatterlist()
1410 orb->page_table[i].high = cpu_to_be32(sg_dma_len(sg) << 16); in sbp2_map_scatterlist()
1411 orb->page_table[i].low = cpu_to_be32(sg_dma_address(sg)); in sbp2_map_scatterlist()
1414 orb->page_table_bus = in sbp2_map_scatterlist()
1415 dma_map_single(device->card->device, orb->page_table, in sbp2_map_scatterlist()
1416 sizeof(orb->page_table), DMA_TO_DEVICE); in sbp2_map_scatterlist()
1417 if (dma_mapping_error(device->card->device, orb->page_table_bus)) in sbp2_map_scatterlist()
1427 orb->request.data_descriptor.high = cpu_to_be32(lu->tgt->address_high); in sbp2_map_scatterlist()
1428 orb->request.data_descriptor.low = cpu_to_be32(orb->page_table_bus); in sbp2_map_scatterlist()
1429 orb->request.misc |= cpu_to_be32(COMMAND_ORB_PAGE_TABLE_PRESENT | in sbp2_map_scatterlist()
1435 scsi_dma_unmap(orb->cmd); in sbp2_map_scatterlist()
1447 struct sbp2_command_orb *orb; in sbp2_scsi_queuecommand() local
1450 orb = kzalloc(sizeof(*orb), GFP_ATOMIC); in sbp2_scsi_queuecommand()
1451 if (orb == NULL) in sbp2_scsi_queuecommand()
1455 orb->base.rcode = -1; in sbp2_scsi_queuecommand()
1456 kref_init(&orb->base.kref); in sbp2_scsi_queuecommand()
1457 orb->cmd = cmd; in sbp2_scsi_queuecommand()
1458 orb->request.next.high = cpu_to_be32(SBP2_ORB_NULL); in sbp2_scsi_queuecommand()
1459 orb->request.misc = cpu_to_be32( in sbp2_scsi_queuecommand()
1465 orb->request.misc |= cpu_to_be32(COMMAND_ORB_DIRECTION); in sbp2_scsi_queuecommand()
1470 if (scsi_sg_count(cmd) && sbp2_map_scatterlist(orb, device, lu) < 0) in sbp2_scsi_queuecommand()
1473 memcpy(orb->request.command_block, cmd->cmnd, cmd->cmd_len); in sbp2_scsi_queuecommand()
1475 orb->base.callback = complete_command_orb; in sbp2_scsi_queuecommand()
1476 orb->base.request_bus = in sbp2_scsi_queuecommand()
1477 dma_map_single(device->card->device, &orb->request, in sbp2_scsi_queuecommand()
1478 sizeof(orb->request), DMA_TO_DEVICE); in sbp2_scsi_queuecommand()
1479 if (dma_mapping_error(device->card->device, orb->base.request_bus)) { in sbp2_scsi_queuecommand()
1480 sbp2_unmap_scatterlist(device->card->device, orb); in sbp2_scsi_queuecommand()
1484 sbp2_send_orb(&orb->base, lu, lu->tgt->node_id, generation, in sbp2_scsi_queuecommand()
1488 kref_put(&orb->base.kref, free_orb); in sbp2_scsi_queuecommand()