免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1150 | 回复: 0

libata reading notes - io operation part 3 [复制链接]

论坛徽章:
0
发表于 2010-01-13 21:32 |显示全部楼层

                IO operation part 3: how libata connects to SCSI layer
scsi_request_fn -> scsi_dispatch_cmd -> queuecommand (ata_scsi_queuecmd)
-> __ata_scsi_queuecmd -> ata_scsi_translate -> ata_qc_issue
-> ahci_qc_prep ahci_qc_issue
scsi_request_fn
Each block device has a request_queue associated with it, the IO
requests from kernel block layer (bio, block layer will try to merge
bio according to the elevator algorithm, bios which request data in the
near area are merged into one struct request in request_queue) are
collected on this queue. Block driver needs to provide a request_fn
to handle the requests (for SCSI deivce, it is scsi_request_fn)
scsi_request_fn -> scsi_dispatch_cmd
scsi_host_template:queuecommand(scsi_cmnd, scsi_done)
Through this function call, the SCSI layer will call into lower level
driver (f.e ata_scsi_queuecmd to the libata layer).
scsi_done() will be called when the scsi_cmnd is finished by the lower
level driver, and through this function the lower level driver calls
back to the SCSI layer.
ata_scsi_queuecmd
Find the corresponding ata_port and ata_deivce and call
__ata_scsi_queuecmd to do the real work.
ata_scsi_queuecmd -> __ata_scsi_queuecmd
Find appropriate translate function used for translating scsi command
block to ata command (ata_taskfile) f.e ata_scsi_rw_xlat translates
SCSI r/w command into an ATA one. In libata layer, a command for an ATA
device is represented by a ata_qeueued_cmd.
ata_scsi_queuecmd -> __ata_scsi_queuecmd -> ata_scsi_translate
Find an empty command slot (ata_queued_cmd) in ata_port and init this
ata_queued_cmd from the scsi_cmnd, including memory buffer address used
for DMA
    qc->scsidone = scsi_done
    qc->complete_fn = ata_scsi_qc_complete
    When the ata command is finished, complete_fn will be called
        (which will call scsidone to call back to SCSI layer).
ata_qc_issue() -> ata_port_operations:qc_prep qc_issue
This will call into ATA host controller driver, f.e for ahci controller
driver to do command setup and command issue. For ahci driver, it needs
to setup the command table, including command FIS, dma address..
(see ahci_qc_prep ahci_qc_issue for details).
               
               
               
               
               

本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u3/100604/showart_2148208.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP