ImageVerifierCode 换一换
格式:DOCX , 页数:25 ,大小:23.03KB ,
资源ID:28195687      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/28195687.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(Linux内核SCSI子系统驱动架构资料.docx)为本站会员(b****5)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

Linux内核SCSI子系统驱动架构资料.docx

1、Linux内核SCSI子系统驱动架构资料SCSI子系统驱动架构 2013-2-2代码布局:一、读写数据流:drivers/scsi/scsi_lib.cscsi_execute_req=scsi_execute=blk_execute_rq=blk_execute_rq_nowait错误恢复:drivers/scsi/scsi_error.c内核线程scsi_error_handler=二、初始化:(本文!)-scsi高层(scsi磁盘)驱动:1代码分布2核心调用:drivers/scsi/sd.c(这里以scsi disk设备为例)同步执行部分:sd_probe异步执行部分:sd_probe

2、_async=sd_revalidate_disk=sd_spinup_disk-scsi子系统核心初始化:1代码分布2核心调用:scsi_init_queue();scsi_init_procfs();scsi_init_devinfo();scsi_init_hosts();scsi_init_sysctl();scsi_sysfs_register(); scsi_netlink_init();-scsi适配器驱动:1代码分布2核心调用:drivers/scsi/hosts.c1)、struct Scsi_Host *scsi_host_alloc(struct scsi_host_te

3、mplate *sht, int privsize) 2)、scsi_add_host(struct Scsi_Host *host,struct device *dev)=scsi_add_host_with_dma(host, dev, dev)int scsi_add_host_with_dma(struct Scsi_Host *shost, struct device *dev, struct device *dma_dev)3)、scsi_scan_host=do_scsi_scan_host=scsi_scan_host_selected=scsi_scan_channel =_

4、scsi_scan_target=scsi_probe_and_add_lun=scsi_probe_lun scsi_add_lun代码骨架:-scsi子系统核心初始化:drivers/scsi/scsi.c:static struct class shost_class = .name = scsi_host, .dev_release = scsi_host_cls_release,;static struct class sdev_class = .name = scsi_device, .dev_release = scsi_device_cls_release,;struct bu

5、s_type scsi_bus_type = .name = scsi, .match = scsi_bus_match, .uevent = scsi_bus_uevent,;subsys_initcall(init_scsi)=static int _init init_scsi(void) scsi_init_queue(); scsi_init_procfs(); scsi_init_devinfo();/ scsi_init_hosts();/ scsi_init_sysctl(); scsi_sysfs_register();/ scsi_netlink_init();int sc

6、si_init_hosts(void) return class_register(&shost_class);int scsi_sysfs_register(void)int error; error = bus_register(&scsi_bus_type); if (!error) class_register(&sdev_class); - scsi HBA驱动:(前端以dmx3191d为例)static struct scsi_host_template dmx3191d_driver_template = .name = Domex DMX3191D, .queuecommand

7、 = NCR5380_queue_command,. .,;static struct pci_device_id dmx3191d_pci_tbl = PCI_VENDOR_ID_DOMEX, PCI_DEVICE_ID_DOMEX_DMX3191D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4, ;static struct pci_driver dmx3191d_pci_driver = .name = DMX3191D_DRIVER_NAME, .id_table = dmx3191d_pci_tbl, .probe = dmx3191d_probe_one, .r

8、emove = _devexit_p(dmx3191d_remove_one),;module_init(dmx3191d_init);static int _init dmx3191d_init(void) return pci_register_driver(&dmx3191d_pci_driver);/调dmx3191d_probe_onestatic int _devinit dmx3191d_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) struct Scsi_Host *shost;. .; scsi

9、_host_alloc(&dmx3191d_driver_template,sizeof(struct NCR5380_hostdata);/- shost-irq = pdev-irq;request_irq(pdev-irq, NCR5380_intr, IRQF_SHARED,NAME, shost); . .; scsi_add_host(shost, &pdev-dev); scsi_scan_host(shost);-drivers/scsi/hosts.cstatic atomic_t scsi_host_next_hn; struct Scsi_Host *scsi_host_

10、alloc(struct scsi_host_template *sht, int privsize) struct Scsi_Host *shost; gfp_t gfp_mask = GFP_KERNEL; shost = kzalloc(sizeof(struct Scsi_Host) + privsize, gfp_mask); shost-host_no = atomic_inc_return(&scsi_host_next_hn) - 1; device_initialize(&shost-shost_gendev); shost-shost_gendev.bus = &scsi_

11、bus_type; shost-shost_gendev.type = &scsi_host_type;. .; device_initialize(&shost-shost_dev); shost-shost_dev.parent = &shost-shost_gendev; shost-shost_dev.class = &shost_class; return shost;include/scsi/scsi_host.hstatic inline int _must_check scsi_add_host(struct Scsi_Host *host, struct device *de

12、v) return scsi_add_host_with_dma(host, dev, dev);drivers/scsi/hosts.cint scsi_add_host_with_dma(struct Scsi_Host *shost, struct device *dev, struct device *dma_dev) struct scsi_host_template *sht = shost-hostt;. .; device_add(&shost-shost_gendev);/- device_add(&shost-shost_dev);. .;scsi_sysfs_add_ho

13、st(shost);. .;-drivers/scsi/scsi_scan.c#ifdef CONFIG_SCSI_SCAN_ASYNC /0#define SCSI_SCAN_TYPE_DEFAULT async#else#define SCSI_SCAN_TYPE_DEFAULT sync#endifstatic char scsi_scan_type6 = SCSI_SCAN_TYPE_DEFAULT;/变量的值可以在加载scsi中间层模块时通过模块参数设定,未设定则用上面的默认值module_param_string(scan, scsi_scan_type, sizeof(scsi_

14、scan_type), S_IRUGO);# define jiffies raid6_jiffies()/specify scanning or rescanning of all possible channels, (target) ids, or luns ,on a given shost.#define SCAN_WILD_CARD 0#define MAX_COMMAND_SIZE 16void scsi_scan_host(struct Scsi_Host *shost) struct task_struct *p; struct async_scan_data *data;

15、if (strncmp(scsi_scan_type, none, 4) = 0) return; data = scsi_prep_async_scan(shost);/异步扫描准备与判断 shost-async_scan = 1 if (!data) /如果data=null, shost-async_scan仍为0 do_scsi_scan_host(shost); return;/同步扫描逻辑,不需要任何准备工作 p = kthread_run(do_scan_async, data, scsi_scan_%d, shost-host_no);/异步扫描逻辑 if (IS_ERR(p)

16、/有错误时 do_scan_async(data);/shost-async_scan = 0static void do_scsi_scan_host(struct Scsi_Host *shost) if (shost-hostt-scan_finished) . .;/自定义的扫描逻辑 else /通配符SCAN_WILD_CARD 0 , 表示需要尝试所有可能的值/rescan=0,表示第一次扫描,为1,表示重新扫描,即这个接口还有其他地方调用! scsi_scan_host_selected(shost, SCAN_WILD_CARD, SCAN_WILD_CARD, SCAN_WI

17、LD_CARD, 0); int scsi_scan_host_selected(struct Scsi_Host *shost, unsigned int channel, unsigned int id, unsigned int lun, int rescan) . .;/shost-async_scan:是异步扫描标志,为1-异步扫描,0-同步扫描 if (!shost-async_scan) scsi_complete_async_scans();if (scsi_host_scan_allowed(shost) if (channel = SCAN_WILD_CARD) for (

18、channel = 0; channel max_channel; channel+) scsi_scan_channel(shost, channel, id, lun, rescan); else scsi_scan_channel(shost, channel, id, lun, rescan); static void scsi_scan_channel(struct Scsi_Host *shost, unsigned int channel, unsigned int id, unsigned int lun, int rescan) uint order_id; if (id =

19、 SCAN_WILD_CARD) for (id = 0; id max_id; +id) if (shost-reverse_ordering) order_id = shost-max_id - id - 1; else order_id = id; _scsi_scan_target(&shost-shost_gendev, channel, order_id, lun, rescan); else _scsi_scan_target(&shost-shost_gendev, channel, id, lun, rescan);/-static void _scsi_scan_targe

20、t(struct device *parent, unsigned int channel, unsigned int id, unsigned int lun, int rescan) struct Scsi_Host *shost = dev_to_shost(parent); int bflags = 0; int res; struct scsi_target *starget; if (shost-this_id = id) return; starget = scsi_alloc_target(parent, channel, id); if (lun != SCAN_WILD_C

21、ARD) scsi_probe_and_add_lun(starget, lun, NULL, NULL, rescan, NULL);/- goto out_reap; res = scsi_probe_and_add_lun(starget, 0, &bflags, NULL, rescan, NULL);/- if (res = SCSI_SCAN_LUN_PRESENT | res = SCSI_SCAN_TARGET_PRESENT) /会调用scsi_probe_and_add_lun if (scsi_report_lun_scan(starget, bflags, rescan

22、) != 0)/会调用scsi_probe_and_add_lun scsi_sequential_lun_scan(starget, bflags, starget-scsi_level, rescan); out_reap: scsi_target_reap(starget); put_device(&starget-dev);static int scsi_probe_and_add_lun(struct scsi_target *starget, uint lun, int *bflagsp, struct scsi_device *sdevp, int rescan, void *h

23、ostdata) struct scsi_device *sdev; unsigned char *result; int bflags, result_len = 256; struct Scsi_Host *shost = dev_to_shost(starget-dev.parent); sdev = scsi_device_lookup_by_target(starget, lun); if (sdev) if (rescan | !scsi_device_created(sdev) if (sdevp) *sdevp = sdev; else scsi_device_put(sdev

24、); if (bflagsp) *bflagsp = scsi_get_device_flags(sdev, sdev-vendor, sdev-model); return SCSI_SCAN_LUN_PRESENT; . .; else sdev = scsi_alloc_sdev(starget, lun, hostdata);/- result = kmalloc(result_len, GFP_ATOMIC | (shost-unchecked_isa_dma) ? _GFP_DMA : 0); scsi_probe_lun(sdev, result, result_len, &bf

25、lags);/- if (bflagsp) *bflagsp = bflags;. .; res = scsi_add_lun(sdev, result, &bflags, shost-async_scan);/-return res;static struct scsi_device *scsi_alloc_sdev(struct scsi_target *starget, unsigned int lun, void *hostdata) struct scsi_device *sdev; struct Scsi_Host *shost = dev_to_shost(starget-dev

26、.parent);. .; sdev = kzalloc(sizeof(*sdev) + shost-transportt-device_size, GFP_ATOMIC); . .; sdev-request_queue = scsi_alloc_queue(sdev); . .; scsi_sysfs_device_initialize(sdev);/-. .; return sdev;void scsi_sysfs_device_initialize(struct scsi_device *sdev) struct Scsi_Host *shost = sdev-host; struct scsi_target *starget = sdev-sdev_target; device_initialize(&sdev-sdev_gendev);/ sdev-sdev_gendev.bus = &scsi_bus_type; sdev-sdev_gendev.type = &scsi_dev_type;. .; device_initialize(&sdev-sdev_dev);/. .; sdev-scsi_level = starget-scsi_level;list_add_tail(&sdev-same_target_siblings, &starget-devi

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1