Lines Matching refs:orb

212 /* Management orb opcodes */
261 void (*callback)(struct sbp2_orb * orb, struct sbp2_status * status);
401 struct sbp2_orb *orb = container_of(kref, struct sbp2_orb, kref);
403 kfree(orb);
412 struct sbp2_orb *orb = NULL, *iter;
435 /* Lookup the orb corresponding to this status write. */
442 orb = iter;
448 if (orb) {
449 orb->callback(orb, &status);
450 kref_put(&orb->kref, free_orb); /* orb callback reference */
461 struct sbp2_orb *orb = data;
466 * the orb before we get this callback. The status write
467 * handler above will assume the orb pointer transaction was
468 * successful and set the rcode to RCODE_COMPLETE for the orb.
473 spin_lock_irqsave(&orb->lu->tgt->lock, flags);
475 if (orb->rcode == -1)
476 orb->rcode = rcode;
477 if (orb->rcode != RCODE_COMPLETE) {
478 list_del(&orb->link);
479 spin_unlock_irqrestore(&orb->lu->tgt->lock, flags);
481 orb->callback(orb, NULL);
482 kref_put(&orb->kref, free_orb); /* orb callback reference */
484 spin_unlock_irqrestore(&orb->lu->tgt->lock, flags);
487 kref_put(&orb->kref, free_orb); /* transaction callback reference */
490 static void sbp2_send_orb(struct sbp2_orb *orb, struct sbp2_logical_unit *lu,
498 orb_pointer.low = cpu_to_be32(orb->request_bus);
500 orb->lu = lu;
502 list_add_tail(&orb->link, &lu->orb_list);
505 kref_get(&orb->kref); /* transaction callback reference */
506 kref_get(&orb->kref); /* orb callback reference */
508 fw_send_request(device->card, &orb->t, TCODE_WRITE_BLOCK_REQUEST,
510 &orb_pointer, 8, complete_transaction, orb);
516 struct sbp2_orb *orb, *next;
525 list_for_each_entry_safe(orb, next, &list, link) {
527 if (fw_cancel_transaction(device->card, &orb->t) == 0)
530 orb->rcode = RCODE_CANCELLED;
531 orb->callback(orb, NULL);
532 kref_put(&orb->kref, free_orb); /* orb callback reference */
541 struct sbp2_management_orb *orb =
545 memcpy(&orb->status, status, sizeof(*status));
546 complete(&orb->done);
554 struct sbp2_management_orb *orb;
561 orb = kzalloc(sizeof(*orb), GFP_NOIO);
562 if (orb == NULL)
565 kref_init(&orb->base.kref);
566 orb->response_bus =
567 dma_map_single(device->card->device, &orb->response,
568 sizeof(orb->response), DMA_FROM_DEVICE);
569 if (dma_mapping_error(device->card->device, orb->response_bus))
572 orb->request.response.high = 0;
573 orb->request.response.low = cpu_to_be32(orb->response_bus);
575 orb->request.misc = cpu_to_be32(
579 orb->request.length = cpu_to_be32(
580 MANAGEMENT_ORB_RESPONSE_LENGTH(sizeof(orb->response)));
582 orb->request.status_fifo.high =
584 orb->request.status_fifo.low =
589 orb->request.misc |= cpu_to_be32(
597 init_completion(&orb->done);
598 orb->base.callback = complete_management_orb;
600 orb->base.request_bus =
601 dma_map_single(device->card->device, &orb->request,
602 sizeof(orb->request), DMA_TO_DEVICE);
603 if (dma_mapping_error(device->card->device, orb->base.request_bus))
606 sbp2_send_orb(&orb->base, lu, node_id, generation,
609 wait_for_completion_timeout(&orb->done, msecs_to_jiffies(timeout));
614 orb->base.rcode);
618 if (orb->base.rcode != RCODE_COMPLETE) {
620 orb->base.rcode);
624 if (STATUS_GET_RESPONSE(orb->status) != 0 ||
625 STATUS_GET_SBP_STATUS(orb->status) != 0) {
627 STATUS_GET_RESPONSE(orb->status),
628 STATUS_GET_SBP_STATUS(orb->status));
634 dma_unmap_single(device->card->device, orb->base.request_bus,
635 sizeof(orb->request), DMA_TO_DEVICE);
637 dma_unmap_single(device->card->device, orb->response_bus,
638 sizeof(orb->response), DMA_FROM_DEVICE);
641 memcpy(response, orb->response, sizeof(orb->response));
642 kref_put(&orb->base.kref, free_orb);
1281 struct sbp2_command_orb *orb)
1283 scsi_dma_unmap(orb->cmd);
1285 if (orb->request.misc & cpu_to_be32(COMMAND_ORB_PAGE_TABLE_PRESENT))
1286 dma_unmap_single(card_device, orb->page_table_bus,
1287 sizeof(orb->page_table), DMA_TO_DEVICE);
1339 struct sbp2_command_orb *orb =
1364 orb->cmd->sense_buffer);
1367 * If the orb completes with status == NULL, something
1368 * went wrong, typically a bus reset happened mid-orb
1375 dma_unmap_single(device->card->device, orb->base.request_bus,
1376 sizeof(orb->request), DMA_TO_DEVICE);
1377 sbp2_unmap_scatterlist(device->card->device, orb);
1379 orb->cmd->result = result;
1380 scsi_done(orb->cmd);
1383 static int sbp2_map_scatterlist(struct sbp2_command_orb *orb,
1386 struct scatterlist *sg = scsi_sglist(orb->cmd);
1389 n = scsi_dma_map(orb->cmd);
1401 orb->request.data_descriptor.high =
1403 orb->request.data_descriptor.low =
1405 orb->request.misc |=
1411 orb->page_table[i].high = cpu_to_be32(sg_dma_len(sg) << 16);
1412 orb->page_table[i].low = cpu_to_be32(sg_dma_address(sg));
1415 orb->page_table_bus =
1416 dma_map_single(device->card->device, orb->page_table,
1417 sizeof(orb->page_table), DMA_TO_DEVICE);
1418 if (dma_mapping_error(device->card->device, orb->page_table_bus))
1428 orb->request.data_descriptor.high = cpu_to_be32(lu->tgt->address_high);
1429 orb->request.data_descriptor.low = cpu_to_be32(orb->page_table_bus);
1430 orb->request.misc |= cpu_to_be32(COMMAND_ORB_PAGE_TABLE_PRESENT |
1436 scsi_dma_unmap(orb->cmd);
1448 struct sbp2_command_orb *orb;
1451 orb = kzalloc(sizeof(*orb), GFP_ATOMIC);
1452 if (orb == NULL)
1456 orb->base.rcode = -1;
1457 kref_init(&orb->base.kref);
1458 orb->cmd = cmd;
1459 orb->request.next.high = cpu_to_be32(SBP2_ORB_NULL);
1460 orb->request.misc = cpu_to_be32(
1466 orb->request.misc |= cpu_to_be32(COMMAND_ORB_DIRECTION);
1471 if (scsi_sg_count(cmd) && sbp2_map_scatterlist(orb, device, lu) < 0)
1474 memcpy(orb->request.command_block, cmd->cmnd, cmd->cmd_len);
1476 orb->base.callback = complete_command_orb;
1477 orb->base.request_bus =
1478 dma_map_single(device->card->device, &orb->request,
1479 sizeof(orb->request), DMA_TO_DEVICE);
1480 if (dma_mapping_error(device->card->device, orb->base.request_bus)) {
1481 sbp2_unmap_scatterlist(device->card->device, orb);
1485 sbp2_send_orb(&orb->base, lu, lu->tgt->node_id, generation,
1489 kref_put(&orb->base.kref, free_orb);