qla_cfgln.c
来自「这个linux源代码是很全面的~基本完整了~使用c编译的~由于时间问题我没有亲自」· C语言 代码 · 共 680 行 · 第 1/2 页
C
680 行
/****************************************************************************** * QLOGIC LINUX SOFTWARE * * QLogic ISP2x00 device driver for Linux 2.4.x * Copyright (C) 2002 Qlogic Corporation * (www.qlogic.com) * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2, or (at your option) any * later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * ******************************************************************************//* * QLogic ISP2x00 Multi-path LUN Support Driver * Solaris specific functions * */#include "qlfo.h"#include "qla_cfg.h"#include "qla_gbl.h"/* * qla2x00_set_lun_data_from_config * Set lun_data byte from the configuration parameters. * * Input: * host -- pointer to host adapter structure. * port -- pointer to port * tgt -- target number * dev_no -- device number */voidqla2x00_set_lun_data_from_config(mp_host_t *host, fc_port_t *port, uint16_t tgt, uint16_t dev_no){ static char propbuf[512]; /* As big as largest search string */ int rval; int16_t lun, l; scsi_qla_host_t *ha = host->ha; mp_device_t *dp; static lun_bit_mask_t lun_mask; lun_bit_mask_t *mask_ptr = &lun_mask; mp_path_list_t *pathlist;#if 0 uint8_t control_byte;#endif mp_path_t *path; memset(&lun_mask, 0, sizeof(lun_bit_mask_t)); dp = host->mp_devs[tgt]; if (dp == NULL) { printk("qla2x00_set_lun_data_from_config: Target %d " "not found for hba %d\n",tgt, host->instance); return; } if ( (pathlist = dp->path_list) == NULL ) { printk("qla2x00_set_lun_data_from_config: path list " "not found for target %d\n", tgt); return; } if ((path = qla2x00_find_path_by_name(host, pathlist, port->port_name)) == NULL ) { printk("qla2x00_set_lun_data_from_config: No path found " "for target %d\n", tgt); return; } /* clear port information */ path->port = NULL;#if 0 /* 02/06/01 - move to build path tree */ /* * Get "target-N-device-N-control" if property is present then all * luns are visible. */ sprintf(propbuf, "scsi-qla%d-tgt-%d-di-%d-control", host->instance, tgt, dev_no); DEBUG3(printk("build_tree: %s\n",propbuf);) rval = qla2x00_get_prop_xstr(ha, propbuf, (uint8_t *)(&control_byte), sizeof(control_byte)); if (rval != -1) { if (!((control_byte & MP_MASK_HIDDEN) || (control_byte & MP_MASK_UNCONFIGURED))) { pathlist->visible = path->id; DEBUG(printk("qla2x00_set_lun_data_from_config: " "found visible path id %d hba %d\n", path->id, host->instance);) } else { pathlist->visible = PATH_INDEX_INVALID; /* 01/30 */ DEBUG(printk("qla2x00_set_lun_data_from_config: " "found hidden path id %d hba %d\n", path->id, host->instance);) } path->mp_byte = control_byte; DEBUG(printk("qla2x00_set_lun_data_from_config: " "control byte 0x%x for path id %d hba %d\n", path->mp_byte, path->id, host->instance);) }#endif /* Get "target-N-device-N-preferred" as a 256 bit lun_mask*/ sprintf(propbuf, "scsi-qla%ld-tgt-%d-di-%d-preferred", ha->instance, tgt, dev_no); DEBUG2(printk("build_tree: %s\n",propbuf);) rval = qla2x00_get_prop_xstr(ha, propbuf, (uint8_t *)(&lun_mask), sizeof(lun_mask)); if (rval == -1) { /* EMPTY */ DEBUG2(printk("qla2x00_set_lun_data_from_config: " "NO Preferred mask - ret %d\n", rval);) } else { if (rval != sizeof(lun_mask)) { /* EMPTY */ printk("qla2x00_set_lun_data_from_config: " "Preferred mask len %d is incorrect.\n", rval); } DEBUG3(printk("qla2x00_set_lun_data_from_config: " "Preferred mask read:\n");) DEBUG3(qla2x00_dump_buffer((char *)&lun_mask, sizeof(lun_mask));) for (lun = MAX_LUNS-1, l =0; lun >= 0; lun--, l++ ) { if (EXT_IS_LUN_BIT_SET(mask_ptr, lun)) { path->lun_data.data[l] |= LUN_DATA_PREFERRED_PATH; pathlist->current_path[l] = path->id; } else { path->lun_data.data[l] &= ~LUN_DATA_PREFERRED_PATH; } } } /* Get "target-N-device-N-lun-disable" as a 256 bit lun_mask*/ sprintf(propbuf, "scsi-qla%ld-tgt-%d-di-%d-lun-disabled", ha->instance, tgt, dev_no); DEBUG3(printk("build_tree: %s\n",propbuf);) rval = qla2x00_get_prop_xstr(ha, propbuf, (uint8_t *)&lun_mask, sizeof(lun_mask)); if (rval == -1) { /* default: all luns enabled */ for (lun = 0; lun < MAX_LUNS; lun++) { path->lun_data.data[lun] |= LUN_DATA_ENABLED; } } else { if (rval != sizeof(lun_mask)) { printk("qla2x00_set_lun_data_from_config: Enable " "mask has wrong size %d != %d\n", rval, (int)sizeof(lun_mask)); } else { for (lun = MAX_LUNS-1, l =0; lun >= 0; lun--, l++) { /* our bit mask is inverted */ if (!EXT_IS_LUN_BIT_SET(mask_ptr,lun)) path->lun_data.data[l] |= LUN_DATA_ENABLED; else path->lun_data.data[l] &= ~LUN_DATA_ENABLED; } } } DEBUG3(printk("qla2x00_set_lun_data_from_config: Luns data for " "device %p, instance %d, path id=%d\n", dp,host->instance,path->id);) DEBUG3(qla2x00_dump_buffer((char *)&path->lun_data.data[0], 64);) LEAVE("qla2x00_set_lun_data_from_config");}/* * qla2x00_cfg_build_path_tree * Find all path properties and build a path tree. The * resulting tree has no actual port assigned to it * until the port discovery is done by the lower level. * * Input: * ha = adapter block pointer. * * Context: * Kernel context. */voidqla2x00_cfg_build_path_tree( scsi_qla_host_t *ha){ static char propbuf[512]; uint8_t node_name[WWN_SIZE]; uint8_t port_name[WWN_SIZE]; fc_port_t *port; uint16_t dev_no = 0, tgt_no; int instance, rval; mp_host_t *host = NULL; uint8_t *name; int done, errors; uint8_t control_byte; ENTER("qla2x00_cfg_build_path_tree"); printk(KERN_INFO "qla02%d: ConfigRequired is set. \n", (int)ha->instance); DEBUG(printk("qla2x00_cfg_build_path_tree: hba =%d", (int)ha->instance);) /* Look for adapter nodename in properties */ sprintf(propbuf, "scsi-qla%ld-adapter-port", ha->instance); DEBUG(printk("build_tree: %s\n",propbuf);) rval = qla2x00_get_prop_xstr(ha, propbuf, port_name, WWN_SIZE); if (rval != WWN_SIZE) { return; } /* Does nodename match the host adapter nodename? */ name = &ha->init_cb->port_name[0]; if (!qla2x00_is_nodename_equal(name, port_name)) { printk(KERN_INFO "scsi(%d): Adapter nodenames don't match - ha = %p.\n", (int)ha->instance,ha); DEBUG(printk("qla(%d): Adapter nodenames don't match - " "ha = %p.\n", (int)host->instance,ha);) return; } instance = ha->instance; if ((host = qla2x00_alloc_host(ha)) == NULL) { printk(KERN_INFO "scsi(%d): Couldn't allocate host - ha = %p.\n", (int)instance,ha); } else { /* create a dummy port */ port = (fc_port_t *)KMEM_ZALLOC(sizeof (fc_port_t),9); if (port == NULL) { printk(KERN_INFO "scsi(%d): Couldn't allocate port.\n", (int)instance); DEBUG(printk("qla(%d): Couldn't allocate port.\n", (int)host->instance);) /* remove host */ return; } done = 0; errors = 0; /* For each target on the host bus adapter */ for (tgt_no = 0; tgt_no < MAX_MP_DEVICES && !done; tgt_no++) { /* get all paths for this target */ for (dev_no = 0; dev_no < MAX_PATHS_PER_DEVICE && !done ; dev_no++) { memset(port, 0, sizeof (fc_port_t)); /* * Get "target-N-device-N-node" is a 16-chars * number */ sprintf(propbuf, "scsi-qla%d-tgt-%d-di-%d-node", instance, tgt_no, dev_no); DEBUG(printk("build_tree: %s\n",propbuf);) rval = qla2x00_get_prop_xstr(ha, propbuf, node_name, WWN_SIZE); if (rval != WWN_SIZE) { errors++; if (errors == MAX_PATHS_PER_DEVICE) { done = 1; /* no more targets */ } continue; } errors = 0; memcpy(port->node_name, node_name, WWN_SIZE); /* * Get "target-N-device-N-port" is a 16-chars * number */ sprintf(propbuf, "scsi-qla%d-tgt-%d-di-%d-port", instance, tgt_no, dev_no); DEBUG(printk("build_tree: %s\n",propbuf);) rval = qla2x00_get_prop_xstr(ha, propbuf, port_name, WWN_SIZE); if (rval != WWN_SIZE) continue; memcpy(port->node_name, node_name, WWN_SIZE); memcpy(port->port_name, port_name, WWN_SIZE); port->flags |= FC_CONFIG; /* * Get "target-N-device-N-control" if property * is present then all luns are visible. */ sprintf(propbuf, "scsi-qla%d-tgt-%d-di-%d-control", instance, tgt_no, dev_no); DEBUG3(printk("build_tree: %s\n",propbuf);) rval = qla2x00_get_prop_xstr(ha, propbuf, (uint8_t *)(&control_byte), sizeof(control_byte)); if (rval == -1) { /* error getting string. go to next. */ continue; } DEBUG(printk("build_tree: control byte 0x%x\n", control_byte);) port->mp_byte = control_byte; DEBUG(printk("build_tree: update_mp_device " "host=%p, port=%p, tgt_no=%d\n", host, port, tgt_no);) qla2x00_update_mp_device(host, port, tgt_no);
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?