bfa: Brocade BFA FC SCSI driver submission (2nd try)
Subsystems (2)
PATCH 1/6 bfa: Brocade BFA FC SCSI driver submission (2nd try)
From: Jing Huang <[email protected]>
This patch contains code that interfaces to upper layer linux kernel, such as PCI, SCSI mid-layer and sysfs etc. It is created using 2.6.27-rc7 kernel.
--- drivers/scsi/bfa/bfad.c | 1339 ++++++++++++++++++ drivers/scsi/bfa/bfad_attr.c | 660 +++++++++ drivers/scsi/bfa/bfad_attr.h | 75 + drivers/scsi/bfa/bfad_drv.h | 340 ++++ drivers/scsi/bfa/bfad_fwimg.c | 86 + drivers/scsi/bfa/bfad_im.c | 1244 +++++++++++++++++ drivers/scsi/bfa/bfad_im.h | 197 ++ drivers/scsi/bfa/bfad_im_compat.h | 36 drivers/scsi/bfa/bfad_intr.c | 338 ++++ drivers/scsi/bfa/bfad_ipfc.h | 36 drivers/scsi/bfa/bfad_os.c | 58 drivers/scsi/bfa/bfad_sysfs.c | 2721 ++++++++++++++++++++++++++++++++++++++ drivers/scsi/bfa/bfad_sysfs.h | 30 drivers/scsi/bfa/bfad_tm.h | 59 drivers/scsi/bfa/bfad_trcmod.h | 52 15 files changed, 7271 insertions(+)
drivers/scsi/bfa/bfad_attr.c +660 -0
@@ -0,0 +1,660 @@ +/* +* Copyright (c) 2005-2008 Brocade Communications Systems, Inc. +* All rights reserved +* www.brocade.com +* +* Linux driver for Brocade Fibre Channel Host Bus Adapter. +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License (GPL) Version 2 as +* published by the Free Software Foundation +* +* 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. +*/ + +/** +* @file bfa_attr.c Linux driver configuration interface module. +*/ + +#include "bfad_drv.h" +#include "bfad_im.h" +#include "bfad_trcmod.h" +#include <scsi/scsi_transport.h> +#include "bfad_attr.h" + +/** +* @dg FC_transport_template FC transport template +* @{ +*/ + +/** +* @brief +* FC transport template entry, get SCSI target port ID. +*/ +void +bfad_im_get_starget_port_id (struct scsi_target *starget) +{ +struct Scsi_Host *shost; +struct bfad_im_port_s *im_port; +struct bfad_s *bfad; +struct bfad_itnim_s *itnim =NULL ; +u32 fc_id =-1 ; +unsigned long flags; + + shost =bfad_os_starget_to_shost (starget); + im_port = (struct bfad_im_port_s *) shost->hostdata[0 ]; + bfad = im_port->bfad; +spin_lock_irqsave (&bfad->bfad_lock, flags); + + itnim =bfad_os_get_itnim (im_port, starget->id); +if (itnim) + fc_id =bfa_fcs_itnim_get_fcid (&itnim->fcs_itnim); + +fc_starget_port_id (starget) = fc_id; +spin_unlock_irqrestore (&bfad->bfad_lock, flags); +} + +/** +* @brief +* FC transport template entry, get SCSI target nwwn. +*/ +void +bfad_im_get_starget_node_name (struct scsi_target *starget) +{ +struct Scsi_Host *shost; +struct bfad_im_port_s *im_port; +struct bfad_s *bfad; +struct bfad_itnim_s *itnim =NULL ; +u64 node_name =0 ; +unsigned long flags; + + shost =bfad_os_starget_to_shost (starget); + im_port = (struct bfad_im_port_s *) shost->hostdata[0 ]; + bfad = im_port->bfad; +spin_lock_irqsave (&bfad->bfad_lock, flags); + + itnim =bfad_os_get_itnim (im_port, starget->id); +if (itnim) + node_name =bfa_fcs_itnim_get_nwwn (&itnim->fcs_itnim); + +fc_starget_node_name (starget) =bfa_os_htonll (node_name); +spin_unlock_irqrestore (&bfad->bfad_lock, flags); +} + +/** +* @brief +* FC transport template entry, get SCSI target pwwn. +*/ +void +bfad_im_get_starget_port_name (struct scsi_target *starget) +{ +struct Scsi_Host *shost; +struct bfad_im_port_s *im_port; +struct bfad_s *bfad; +struct bfad_itnim_s *itnim =NULL ; +u64 port_name =0 ; +unsigned long flags; + + shost =bfad_os_starget_to_shost (starget); + im_port = (struct bfad_im_port_s *) shost->hostdata[0 ]; + bfad = im_port->bfad; +spin_lock_irqsave (&bfad->bfad_lock, flags); + + itnim =bfad_os_get_itnim (im_port, starget->id); +if (itnim) + port_name =bfa_fcs_itnim_get_pwwn (&itnim->fcs_itnim); + +fc_starget_port_name (starget) =bfa_os_htonll (port_name); +spin_unlock_irqrestore (&bfad->bfad_lock, flags); +} + +/** +* @brief +* FC transport template entry, get SCSI host port ID. +*/ +void +bfad_im_get_host_port_id (struct Scsi_Host *shost) +{ +struct bfad_im_port_s *im_port = + (struct bfad_im_port_s *) shost->hostdata[0 ]; +struct bfad_port_s *port = im_port->port; + +fc_host_port_id (shost) = +bfa_os_hton3b (bfa_fcs_port_get_fcid (port->fcs_port)); +} + +/** +* @brief +* FC transport template entry, issue a LIP. +*/ +int +bfad_im_issue_fc_host_lip (struct Scsi_Host *shost) +{ +return 0 ; +} + +/** +* @} +*/ + + + +struct Scsi_Host * +bfad_os_starget_to_shost (struct scsi_target *starget) +{ +return dev_to_shost (starget->dev.parent); +} + +/** +* @brief +* FC transport template entry, get SCSI host port type. +*/ +static void +bfad_im_get_host_port_type (struct Scsi_Host *shost) +{ +struct bfad_im_port_s *im_port = + (struct bfad_im_port_s *) shost->hostdata[0 ]; +struct bfad_s *bfad = im_port->bfad; +struct bfa_pport_attr_s attr; + +bfa_pport_get_attr (&bfad->bfa, &attr); + +switch (attr.port_type) { +case BFA_PPORT_TYPE_NPORT : +fc_host_port_type (shost) =FC_PORTTYPE_NPORT ; +break ; +case BFA_PPORT_TYPE_NLPORT : +fc_host_port_type (shost) =FC_PORTTYPE_NLPORT ; +break ; +case BFA_PPORT_TYPE_P2P : +fc_host_port_type (shost) =FC_PORTTYPE_PTP ; +break ; +case BFA_PPORT_TYPE_LPORT : +fc_host_port_type (shost) =FC_PORTTYPE_LPORT ; +break ; +default : +fc_host_port_type (shost) =FC_PORTTYPE_UNKNOWN ; +break ; + } +} + +/** +* @brief +* FC transport template entry, get SCSI host port state. +*/ +static void +bfad_im_get_host_port_state (struct Scsi_Host *shost) +{ +struct bfad_im_port_s *im_port = + (struct bfad_im_port_s *) shost->hostdata[0 ]; +struct bfad_s *bfad = im_port->bfad; +struct bfa_pport_attr_s attr; + +bfa_pport_get_attr (&bfad->bfa, &attr); + +switch (attr.port_state) { +case BFA_PPORT_ST_LINKDOWN : +fc_host_port_state (shost) =FC_PORTSTATE_LINKDOWN ; +break ; +case BFA_PPORT_ST_LINKUP : +fc_host_port_state (shost) =FC_PORTSTATE_ONLINE ; +break ; +case BFA_PPORT_ST_UNINIT : +case BFA_PPORT_ST_ENABLING_QWAIT : +case BFA_PPORT_ST_ENABLING : +case BFA_PPORT_ST_DISABLING_QWAIT : +case BFA_PPORT_ST_DISABLING : +case BFA_PPORT_ST_DISABLED : +case BFA_PPORT_ST_STOPPED : +case BFA_PPORT_ST_IOCDOWN : +default : +fc_host_port_state (shost) =FC_PORTSTATE_UNKNOWN ; +break ; + } +} + +/** +* @brief +* FC transport template entry, get SCSI host active fc4s. +*/ +static void +bfad_im_get_host_active_fc4s (struct Scsi_Host *shost) +{ +struct bfad_im_port_s *im_port = + (struct bfad_im_port_s *) shost->hostdata[0 ]; +struct bfad_port_s *port = im_port->port; + +memset (fc_host_active_fc4s (shost),0 , +sizeof (fc_host_active_fc4s (shost))); + +if (port-> + supported_fc4s & (BFA_PORT_ROLE_FCP_IM |BFA_PORT_ROLE_FCP_TM )) +fc_host_active_fc4s (shost)[2 ] =1 ; + +if (port->supported_fc4s &BFA_PORT_ROLE_FCP_IPFC ) +fc_host_active_fc4s (shost)[3 ] =0x20 ; + +fc_host_active_fc4s (shost)[7 ] =1 ; +} + +/** +* @brief +* FC transport template entry, get SCSI host link speed. +*/ +static void +bfad_im_get_host_speed (struct Scsi_Host *shost) +{ +struct bfad_im_port_s *im_port = + (struct bfad_im_port_s *) shost->hostdata[0 ]; +struct bfad_s *bfad = im_port->bfad; +struct bfa_pport_attr_s attr; + +bfa_pport_get_attr (&bfad->bfa, &attr); +switch (attr.speed) { +case BFA_PPORT_SPEED_8GBPS : +fc_host_speed (shost) =FC_PORTSPEED_8GBIT ; +break ; +case BFA_PPORT_SPEED_4GBPS : +fc_host_speed (shost) =FC_PORTSPEED_4GBIT ; +break ; +case BFA_PPORT_SPEED_2GBPS : +fc_host_speed (shost) =FC_PORTSPEED_2GBIT ; +break ; +case BFA_PPORT_SPEED_1GBPS : +fc_host_speed (shost) =FC_PORTSPEED_1GBIT ; +break ; +default : +fc_host_speed (shost) =FC_PORTSPEED_UNKNOWN ; +break ; + } +} + +/** +* @brief +* FC transport template entry, get SCSI host port type. +*/ +static void +bfad_im_get_host_fabric_name (struct Scsi_Host *shost) +{ +struct bfad_im_port_s *im_port = + (struct bfad_im_port_s *) shost->hostdata[0 ]; +struct bfad_port_s *port = im_port->port; +wwn_t fabric_nwwn =0 ; + + fabric_nwwn =bfa_fcs_port_get_fabric_name (port->fcs_port); + +fc_host_fabric_name (shost) = fabric_nwwn; + +} + +/** +* @brief +* FC transport template entry, get BFAD statistics. +*/ +static struct fc_host_statistics * +bfad_im_get_stats (struct Scsi_Host *shost) +{ +struct bfad_im_port_s *im_port = + (struct bfad_im_port_s *) shost->hostdata[0 ]; +struct bfad_s *bfad = im_port->bfad; +struct bfad_hal_comp fcomp; +struct fc_host_statistics *hstats; +bfa_status_t rc; +unsigned long flags; + + hstats = &bfad->link_stats; +init_completion (&fcomp.comp); +spin_lock_irqsave (&bfad->bfad_lock, flags); +memset (hstats,0 ,sizeof (struct fc_host_statistics )); + rc =bfa_pport_get_stats (&bfad->bfa, + (struct bfa_pport_stats_s *) hstats, + bfad_hcb_comp, &fcomp); +spin_unlock_irqrestore (&bfad->bfad_lock, flags); +if (rc !=BFA_STATUS_OK ) +return NULL ; + +wait_for_completion (&fcomp.comp); + +return hstats; +} + +/** +* @brief +* FC transport template entry, reset BFAD statistics. +*/ +static void +bfad_im_reset_stats (struct Scsi_Host *shost) +{ +struct bfad_im_port_s *im_port = + (struct bfad_im_port_s *) shost->hostdata[0 ]; +struct bfad_s *bfad = im_port->bfad; +struct bfad_hal_comp fcomp; +unsigned long flags; +bfa_status_t rc; + +init_completion (&fcomp.comp); +spin_lock_irqsave (&bfad->bfad_lock, flags); + rc =bfa_pport_clear_stats (&bfad->bfa, bfad_hcb_comp, &fcomp); +spin_unlock_irqrestore (&bfad->bfad_lock, flags); + +if (rc !=BFA_STATUS_OK ) +return ; + +wait_for_completion (&fcomp.comp); + +return ; +} + +/** +* @brief +* FC transport template entry, get rport loss timeout. +*/ +static void +bfad_im_get_rport_loss_tmo (struct fc_rport *rport) +{ +struct bfad_itnim_data_s *itnim_data = rport->dd_data; +struct bfad_itnim_s *itnim = itnim_data->itnim; +struct bfad_s *bfad = itnim->im->bfad; + + rport->dev_loss_tmo = bfad->cfg_data.rport_del_timeout; +} + +/** +* @brief +* FC transport template entry, set rport loss timeout. +*/ +static void +bfad_im_set_rport_loss_tmo (struct fc_rport *rport,u32 timeout) +{ +if (timeout >0 ) + rport->dev_loss_tmo = timeout; +else { +struct bfad_itnim_data_s *itnim_data = rport->dd_data; +struct bfad_itnim_s *itnim = itnim_data->itnim; +struct bfad_s *bfad = itnim->im->bfad; + rport->dev_loss_tmo = bfad->cfg_data.rport_del_timeout; + } + +} + +struct fc_function_template bfad_im_fc_function_template = { + +/* Target dynamic attributes */ + .get_starget_port_id = bfad_im_get_starget_port_id, + .show_starget_port_id =1 , + .get_starget_node_name = bfad_im_get_starget_node_name, + .show_starget_node_name =1 , + .get_starget_port_name = bfad_im_get_starget_port_name, + .show_starget_port_name =1 , + +/* Host dynamic attribute */ + .get_host_port_id = bfad_im_get_host_port_id, + .show_host_port_id =1 , + + .issue_fc_host_lip = bfad_im_issue_fc_host_lip, + +/* Host fixed attributes */ + .show_host_node_name =1 , + .show_host_port_name =1 , + .show_host_supported_classes =1 , + .show_host_supported_fc4s =1 , + .show_host_supported_speeds =1 , + .show_host_maxframe_size =1 , + +/* More host dynamic attributes */ + .show_host_port_type =1 , + .get_host_port_type = bfad_im_get_host_port_type, + .show_host_port_state =1 , + .get_host_port_state = bfad_im_get_host_port_state, + .show_host_active_fc4s =1 , + .get_host_active_fc4s = bfad_im_get_host_active_fc4s, + .show_host_speed =1 , + .get_host_speed = bfad_im_get_host_speed, + .show_host_fabric_name =1 , + .get_host_fabric_name = bfad_im_get_host_fabric_name, + + .show_host_symbolic_name =1 , + +/* Statistics */ + .get_fc_host_stats = bfad_im_get_stats, + .reset_fc_host_stats = bfad_im_reset_stats, + +/* Allocation length for host specific data */ + .dd_fcrport_size =sizeof (struct bfad_itnim_data_s *), + +/* Remote port fixed attributes */ + .show_rport_maxframe_size =1 , + .show_rport_supported_classes =1 , + .show_rport_dev_loss_tmo =1 , + .get_rport_dev_loss_tmo = bfad_im_get_rport_loss_tmo, + .set_rport_dev_loss_tmo = bfad_im_set_rport_loss_tmo, +}; + +/** +* @} +* @dg Scsi_Host_attrs SCSI host attributes +* @{ +*/ +static ssize_t +bfad_im_serial_num_show (struct device *dev,struct device_attribute *attr, +char *buf) +{ +struct Scsi_Host *shost =class_to_shost (dev); +struct bfad_im_port_s *im_port = + (struct bfad_im_port_s *) shost->hostdata[0 ]; +struct bfad_s *bfad = im_port->bfad; +struct bfa_ioc_attr_s ioc_attr; + +memset (&ioc_attr,0 ,sizeof (ioc_attr)); +bfa_get_attr (&bfad->bfa, &ioc_attr); +return snprintf (buf,PAGE_SIZE ,"%s\n" , + ioc_attr.adapter_attr.serial_num); +} + +static ssize_t +bfad_im_model_show (struct device *dev,struct device_attribute *attr, +char *buf) +{ +struct Scsi_Host *shost =class_to_shost (dev); +struct bfad_im_port_s *im_port = + (struct bfad_im_port_s *) shost->hostdata[0 ]; +struct bfad_s *bfad = im_port->bfad; +struct bfa_ioc_attr_s ioc_attr; + +memset (&ioc_attr,0 ,sizeof (ioc_attr)); +bfa_get_attr (&bfad->bfa, &ioc_attr); +return snprintf (buf,PAGE_SIZE ,"%s\n" , ioc_attr.adapter_attr.model); +} + +static ssize_t +bfad_im_model_desc_show (struct device *dev,struct device_attribute *attr, +char *buf) +{ +struct Scsi_Host *shost =class_to_shost (dev); +struct bfad_im_port_s *im_port = + (struct bfad_im_port_s *) shost->hostdata[0 ]; +struct bfad_s *bfad = im_port->bfad; +struct bfa_ioc_attr_s ioc_attr; + +memset (&ioc_attr,0 ,sizeof (ioc_attr)); +bfa_get_attr (&bfad->bfa, &ioc_attr); +return snprintf (buf,PAGE_SIZE ,"%s\n" , + ioc_attr.adapter_attr.model_descr); +} + +static ssize_t +bfad_im_node_name_show (struct device *dev,struct device_attribute *attr, +char *buf) +{ +struct Scsi_Host *shost =class_to_shost (dev); +struct bfad_im_port_s *im_port = + (struct bfad_im_port_s *) shost->hostdata[0 ]; +struct bfad_port_s *port = im_port->port; +u64 nwwn; + + nwwn =bfa_fcs_port_get_nwwn (port->fcs_port); +return snprintf (buf,PAGE_SIZE ,"0x%llx\n" ,bfa_os_htonll (nwwn)); +} + +static ssize_t +bfad_im_symbolic_name_show (struct device *dev,struct device_attribute *attr, +char *buf) +{ +struct Scsi_Host *shost =class_to_shost (dev); +struct bfad_im_port_s *im_port = + (struct bfad_im_port_s *) shost->hostdata[0 ]; +struct bfad_s *bfad = im_port->bfad; +struct bfa_ioc_attr_s ioc_attr; + +memset (&ioc_attr,0 ,sizeof (ioc_attr)); +bfa_get_attr (&bfad->bfa, &ioc_attr); + +return snprintf (buf,PAGE_SIZE ,"Brocade %s FV%s DV%s\n" , + ioc_attr.adapter_attr.model, + ioc_attr.adapter_attr.fw_ver,BFAD_DRIVER_VERSION ); +} + +static ssize_t +bfad_im_hw_version_show (struct device *dev,struct device_attribute *attr, +char *buf) +{ +struct Scsi_Host *shost =class_to_shost (dev); +struct bfad_im_port_s *im_port = + (struct bfad_im_port_s *) shost->hostdata[0 ]; +struct bfad_s *bfad = im_port->bfad; +struct bfa_ioc_attr_s ioc_attr; + +memset (&ioc_attr,0 ,sizeof (ioc_attr)); +bfa_get_attr (&bfad->bfa, &ioc_attr); +return snprintf (buf,PAGE_SIZE ,"%s\n" , ioc_attr.adapter_attr.hw_ver); +} + +static ssize_t +bfad_im_drv_version_show (struct device *dev,struct device_attribute *attr, +char *buf) +{ +return snprintf (buf,PAGE_SIZE ,"%s\n" ,BFAD_DRIVER_VERSION ); +} + +static ssize_t +bfad_im_optionrom_version_show (struct device *dev, +struct device_attribute *attr,char *buf) +{ +struct Scsi_Host *shost =class_to_shost (dev); +struct bfad_im_port_s *im_port = + (struct bfad_im_port_s *) shost->hostdata[0 ]; +struct bfad_s *bfad = im_port->bfad; +struct bfa_ioc_attr_s ioc_attr; + +memset (&ioc_attr,0 ,sizeof (ioc_attr)); +bfa_get_attr (&bfad->bfa, &ioc_attr); +return snprintf (buf,PAGE_SIZE ,"%s\n" , + ioc_attr.adapter_attr.optrom_ver); +} + +static ssize_t +bfad_im_fw_version_show (struct device *dev,struct device_attribute *attr, +char *buf) +{ +struct Scsi_Host *shost =class_to_shost (dev); +struct bfad_im_port_s *im_port = + (struct bfad_im_port_s *) shost->hostdata[0 ]; +struct bfad_s *bfad = im_port->bfad; +struct bfa_ioc_attr_s ioc_attr; + +memset (&ioc_attr,0 ,sizeof (ioc_attr)); +bfa_get_attr (&bfad->bfa, &ioc_attr); +return snprintf (buf,PAGE_SIZE ,"%s\n" , ioc_attr.adapter_attr.fw_ver); +} + +static ssize_t +bfad_im_num_of_ports_show (struct device *dev,struct device_attribute *attr, +char *buf) +{ +struct Scsi_Host *shost =class_to_shost (dev); +struct bfad_im_port_s *im_port = + (struct bfad_im_port_s *) shost->hostdata[0 ]; +struct bfad_s *bfad = im_port->bfad; +struct bfa_ioc_attr_s ioc_attr; + +memset (&ioc_attr,0 ,sizeof (ioc_attr)); +bfa_get_attr (&bfad->bfa, &ioc_attr); +return snprintf (buf,PAGE_SIZE ,"%d\n" , ioc_attr.adapter_attr.nports); +} + +static ssize_t +bfad_im_drv_name_show (struct device *dev,struct device_attribute *attr, +char *buf) +{ +return snprintf (buf,PAGE_SIZE ,"%s\n" ,BFAD_DRIVER_NAME ); +} + +static ssize_t +bfad_im_num_of_discovered_ports_show (struct device *dev, +struct device_attribute *attr,char *buf) +{ +struct Scsi_Host *shost =class_to_shost (dev); +struct bfad_im_port_s *im_port = + (struct bfad_im_port_s *) shost->hostdata[0 ]; +struct bfad_port_s *port = im_port->port; +struct bfad_s *bfad = im_port->bfad; +int nrports =2048 ; +wwn_t *rports =NULL ; +unsigned long flags; + + rports =kzalloc (sizeof (wwn_t) * nrports ,GFP_ATOMIC ); +if (rports ==NULL ) +return snprintf (buf,PAGE_SIZE ,"Failed\n" ); + +spin_lock_irqsave (&bfad->bfad_lock, flags); +bfa_fcs_port_get_rports (port->fcs_port, rports, &nrports); +spin_unlock_irqrestore (&bfad->bfad_lock, flags); +kfree (rports); + +return snprintf (buf,PAGE_SIZE ,"%d\n" , nrports); +} + +static DEVICE_ATTR(serial_number, S_IRUGO, + bfad_im_serial_num_show, NULL); +static DEVICE_ATTR(model, S_IRUGO, bfad_im_model_show, NULL); +static DEVICE_ATTR(model_description, S_IRUGO, + bfad_im_model_desc_show, NULL); +static DEVICE_ATTR(node_name, S_IRUGO, bfad_im_node_name_show, NULL); +static DEVICE_ATTR(symbolic_name, S_IRUGO, + bfad_im_symbolic_name_show, NULL); +static DEVICE_ATTR(hardware_version, S_IRUGO, + bfad_im_hw_version_show, NULL); +static DEVICE_ATTR(driver_version, S_IRUGO, + bfad_im_drv_version_show, NULL); +static DEVICE_ATTR(option_rom_version, S_IRUGO, + bfad_im_optionrom_version_show, NULL); +static DEVICE_ATTR(firmware_version, S_IRUGO, + bfad_im_fw_version_show, NULL); +static DEVICE_ATTR(number_of_ports, S_IRUGO, + bfad_im_num_of_ports_show, NULL); +static DEVICE_ATTR(driver_name, S_IRUGO, bfad_im_drv_name_show, NULL); +static DEVICE_ATTR(number_of_discovered_ports, S_IRUGO, + bfad_im_num_of_discovered_ports_show, NULL); + +struct device_attribute *bfad_im_host_attrs[] = { + &dev_attr_serial_number, + &dev_attr_model, + &dev_attr_model_description, + &dev_attr_node_name, + &dev_attr_symbolic_name, + &dev_attr_hardware_version, + &dev_attr_driver_version, + &dev_attr_option_rom_version, + &dev_attr_firmware_version, + &dev_attr_number_of_ports, + &dev_attr_driver_name, + &dev_attr_number_of_discovered_ports, +NULL , +}; + +/** +* @} +*/
drivers/scsi/bfa/bfad_attr.h +75 -0
75 lines not on this page · raw message
drivers/scsi/bfa/bfad.c +1339 -0
1,339 lines not on this page · raw message
drivers/scsi/bfa/bfad_drv.h +340 -0
340 lines not on this page · raw message
drivers/scsi/bfa/bfad_fwimg.c +86 -0
86 lines not on this page · raw message
drivers/scsi/bfa/bfad_im.c +1244 -0
500 lines not on this page · raw message
drivers/scsi/bfa/bfad_im.h +197 -0
197 lines not on this page · raw message
drivers/scsi/bfa/bfad_intr.c +338 -0
338 lines not on this page · raw message
drivers/scsi/bfa/bfad_os.c +58 -0
58 lines not on this page · raw message
drivers/scsi/bfa/bfad_sysfs.c +2721 -0
2,721 lines not on this page · raw message
drivers/scsi/bfa/bfad_tm.h +59 -0
59 lines not on this page · raw message
drivers/scsi/bfa/bfad_trcmod.h +52 -0
52 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
Quoted 3 lines · Jing Huang
+/**
+ * @filebfa_attr.cLinux driver configuration interface module.
+ */
What is this, kerneldoc isn't like this, right?
drivers/scsi/bfa/bfad_attr.c line 26
Quoted 5 lines
drivers/scsi/bfa/bfad_attr.c +5
-0+#include "bfad_drv.h" +#include "bfad_im.h" +#include "bfad_trcmod.h" +#include <scsi/scsi_transport.h> +#include "bfad_attr.h"
Why a scsi .h file after your local ones?
drivers/scsi/bfa/bfad_attr.c line 31
Quoted 5 lines
drivers/scsi/bfa/bfad_attr.c +5
-0+ +/** +* @dg FC_transport_template FC transport template +* @{ +*/
What is this?
Quoted 4 lines
+/**
+ * @brief
+ * FC transport template entry, get SCSI target port ID.
+ */
Same here, this looks very wierd. This goes for all of your function comments :(
thanks,
greg k-h
RE: [PATCH 1/6] bfa: Brocade BFA FC SCSI driver submission (2ndtry)
Hi Greg,
Those comments are used by doxygen. We use doxygen to generate documentation in my company. So I guess this contradicts to linux kerneldoc. I will look into this.
Yes, the scsi_xx.h file after local one seems strange, I will fix it.
Thanks
Jing
-----Original Message-----
From: Greg KH [mailto:[email protected]]
Sent: Thursday, September 25, 2008 7:53 PM
To: Jing Huang
Cc: [email protected]; [email protected]; [email protected]; Ramkumar Vadivelu; Srikanth Rayas (CW); Vinodh Ravindran
Subject: Re: [PATCH 1/6] bfa: Brocade BFA FC SCSI driver submission (2ndtry)
Quoted 3 lines · Jing Huang
+/**
+ * @filebfa_attr.cLinux driver configuration interface module.
+ */
What is this, kerneldoc isn't like this, right?
drivers/scsi/bfa/bfad_attr.c line 26
Quoted 5 lines
drivers/scsi/bfa/bfad_attr.c +5
-0+#include "bfad_drv.h" +#include "bfad_im.h" +#include "bfad_trcmod.h" +#include <scsi/scsi_transport.h> +#include "bfad_attr.h"
Why a scsi .h file after your local ones?
drivers/scsi/bfa/bfad_attr.c line 31
Quoted 5 lines
drivers/scsi/bfa/bfad_attr.c +5
-0+ +/** +* @dg FC_transport_template FC transport template +* @{ +*/
What is this?
Quoted 4 lines
+/**
+ * @brief
+ * FC transport template entry, get SCSI target port ID.
+ */
Same here, this looks very wierd. This goes for all of your function comments :(
thanks,
greg k-h
Re: [PATCH 1/6] bfa: Brocade BFA FC SCSI driver submission (2ndtry)
Quoted 5 lines · Jing Huang
Hi Greg,
Those comments are used by doxygen. We use doxygen to generate documentation in my company. So I guess this contradicts to linux kerneldoc. I will look into this.
Yes, please fix, the kernel does not use doxygen.
thanks,
greg k-h
Quoted 8 lines · Jing Huang
From: Jing Huang <[email protected]>
This patch contains code that interfaces to upper layer linux kernel, such as PCI, SCSI mid-layer and sysfs etc. It is created using 2.6.27-rc7 kernel.
Signed-off-by Jing Huang <[email protected]>
drivers/scsi/bfa/bfad.c line 577
Quoted 10 lines
drivers/scsi/bfa/bfad.c +10
-0+int +bfad_pci_init (struct pci_dev *pdev,struct bfad_s *bfad) +{ +unsigned long bar0_len; +int rc = -ENODEV ; + +if (pci_enable_device (pdev)) { +BFA_PRINTF (BFA_ERR ,"pci_enable_device fail %p\n" , pdev); + goto out; + }
You should use pcim_enable_device(). This would help you by simplifying your error and release code as it keeps track of freeing a bunch of resources. See Documentation/driver-model/devres.txt.
Quoted 13 lines
drivers/scsi/bfa/bfad.c +13
-0+ +if (pci_request_regions (pdev,BFAD_DRIVER_NAME )) + goto out_disable_device; + +pci_set_master (pdev); + + +if (pci_set_dma_mask (pdev,DMA_64BIT_MASK ) !=0 ) +if (pci_set_dma_mask (pdev,DMA_32BIT_MASK ) !=0 ) { +BFA_PRINTF (BFA_ERR ,"pci_set_dma_mask fail %p\n" , pdev); + goto out_release_region; + } +#ifdef SUPPORT_PCI_AER
drivers/scsi/bfa/bfad.c line 600
Quoted 10 lines
drivers/scsi/bfa/bfad.c +10
-0+/* +* Enable PCIE Advanced Error Recovery (AER) if the kernel version +* supports. +*/ +BFAD_ENABLE_PCIE_AER (pdev); +#endif + + bfad->pci_bar0_map =pci_resource_start (pdev,0 ); + bar0_len =pci_resource_len (pdev,0 ); + bfad->pci_bar0_kva =ioremap (bfad->pci_bar0_map, bar0_len);
bfad->pci_bar0_kva = pcim_iomap(pdev, 0, 0);
Quoted 7 lines
drivers/scsi/bfa/bfad.c +7
-0+ +if (bfad->pci_bar0_kva ==NULL ) { +BFA_DEV_PRINTF (bfad,BFA_ERR ,"Fail to map bar0\n" ); + goto out_release_region; + } + + bfad->hal_pcidev.pci_slot =PCI_SLOT (pdev->devfn);
drivers/scsi/bfa/bfad.c line 617
Quoted 10 lines
drivers/scsi/bfa/bfad.c +10
-0+ bfad->hal_pcidev.pci_func =PCI_FUNC (pdev->devfn); + bfad->hal_pcidev.pci_bar_kva = bfad->pci_bar0_kva; + bfad->hal_pcidev.device_id = pdev->device; + bfad->pci_name =pci_name (pdev); + + bfad->pci_attr.vendor_id = pdev->vendor; + bfad->pci_attr.device_id = pdev->device; + bfad->pci_attr.ssid = pdev->subsystem_device; + bfad->pci_attr.ssvid = pdev->subsystem_vendor; + bfad->pci_attr.pcifn =PCI_FUNC (pdev->devfn);
Why duplicate all this information?
Greetings,
Eike
Quoted 3 lines · Rolf Eike Beer
You should use
pcim_enable_device(). This would help you by simplifying your error and release code as it keeps track of freeing a bunch of resources. SeeDocumentation/driver-model/devres.txt.
I hate the devres stuff. It takes care of most things behind your back, but is terribly complex code and makes bugs next to impossible to track down. Don't add more users for it unless you really, really have to.
Signature · 4 lines
Matthew Wilcox Intel Open Source Technology Centre "Bill, look, we understand that you're interested in selling us this operating system, but compare it to ours. We can't possibly take such a retrograde step."
Quoted 8 lines · On Fri, 26 Sep 2008 06:22:19 -0600 Matthew Wilcox <[email protected]> wrote:
Quoted 3 lines · Rolf Eike Beer
You should use
pcim_enable_device(). This would help you by simplifying your error and release code as it keeps track of freeing a bunch of resources. SeeDocumentation/driver-model/devres.txt.I hate the devres stuff. It takes care of most things behind your back, but is terribly complex code and makes bugs next to impossible to track down. Don't add more users for it unless you really, really have to.
Each to his own. I find the devres code very useful, but then I spend an inordinate amount of time trying to sort out messes caused by developers forgetting to free resources.
Using devres is a very good way to avoid having strange half tested paths and leaks in your code, and if Matthew doesn't like the complexity of devres (its not that complex IMHO) then he can tidy up the implementation ;)
Alan