aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/s390/scsi/zfcp_aux.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/s390/scsi/zfcp_aux.c')
-rw-r--r--drivers/s390/scsi/zfcp_aux.c91
1 files changed, 50 insertions, 41 deletions
diff --git a/drivers/s390/scsi/zfcp_aux.c b/drivers/s390/scsi/zfcp_aux.c
index 395cfc6a344f..9cd789b8acd4 100644
--- a/drivers/s390/scsi/zfcp_aux.c
+++ b/drivers/s390/scsi/zfcp_aux.c
@@ -1,18 +1,8 @@
1/* 1/*
2 * This file is part of the zfcp device driver for
3 * FCP adapters for IBM System z9 and zSeries.
2 * 4 *
3 * linux/drivers/s390/scsi/zfcp_aux.c 5 * (C) Copyright IBM Corp. 2002, 2006
4 *
5 * FCP adapter driver for IBM eServer zSeries
6 *
7 * (C) Copyright IBM Corp. 2002, 2004
8 *
9 * Author(s): Martin Peschke <mpeschke@de.ibm.com>
10 * Raimund Schroeder <raimund.schroeder@de.ibm.com>
11 * Aron Zeh
12 * Wolfgang Taphorn
13 * Stefan Bader <stefan.bader@de.ibm.com>
14 * Heiko Carstens <heiko.carstens@de.ibm.com>
15 * Andreas Herrmann <aherrman@de.ibm.com>
16 * 6 *
17 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -29,6 +19,20 @@
29 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
30 */ 20 */
31 21
22/*
23 * Driver authors:
24 * Martin Peschke (originator of the driver)
25 * Raimund Schroeder
26 * Aron Zeh
27 * Wolfgang Taphorn
28 * Stefan Bader
29 * Heiko Carstens (kernel 2.6 port of the driver)
30 * Andreas Herrmann
31 * Maxim Shchetynin
32 * Volker Sameske
33 * Ralph Wuerthner
34 */
35
32#include "zfcp_ext.h" 36#include "zfcp_ext.h"
33 37
34/* accumulated log level (module parameter) */ 38/* accumulated log level (module parameter) */
@@ -75,15 +79,9 @@ static struct miscdevice zfcp_cfdc_misc = {
75/* declare driver module init/cleanup functions */ 79/* declare driver module init/cleanup functions */
76module_init(zfcp_module_init); 80module_init(zfcp_module_init);
77 81
78MODULE_AUTHOR("Heiko Carstens <heiko.carstens@de.ibm.com>, " 82MODULE_AUTHOR("IBM Deutschland Entwicklung GmbH - linux390@de.ibm.com");
79 "Andreas Herrman <aherrman@de.ibm.com>, "
80 "Martin Peschke <mpeschke@de.ibm.com>, "
81 "Raimund Schroeder <raimund.schroeder@de.ibm.com>, "
82 "Wolfgang Taphorn <taphorn@de.ibm.com>, "
83 "Aron Zeh <arzeh@de.ibm.com>, "
84 "IBM Deutschland Entwicklung GmbH");
85MODULE_DESCRIPTION 83MODULE_DESCRIPTION
86 ("FCP (SCSI over Fibre Channel) HBA driver for IBM eServer zSeries"); 84 ("FCP (SCSI over Fibre Channel) HBA driver for IBM System z9 and zSeries");
87MODULE_LICENSE("GPL"); 85MODULE_LICENSE("GPL");
88 86
89module_param(device, charp, 0400); 87module_param(device, charp, 0400);
@@ -291,12 +289,11 @@ zfcp_cfdc_dev_ioctl(struct file *file, unsigned int command,
291 goto out; 289 goto out;
292 } 290 }
293 291
294 sg_list = kmalloc(sizeof(struct zfcp_sg_list), GFP_KERNEL); 292 sg_list = kzalloc(sizeof(struct zfcp_sg_list), GFP_KERNEL);
295 if (sg_list == NULL) { 293 if (sg_list == NULL) {
296 retval = -ENOMEM; 294 retval = -ENOMEM;
297 goto out; 295 goto out;
298 } 296 }
299 memset(sg_list, 0, sizeof(*sg_list));
300 297
301 if (command != ZFCP_CFDC_IOC) { 298 if (command != ZFCP_CFDC_IOC) {
302 ZFCP_LOG_INFO("IOC request code 0x%x invalid\n", command); 299 ZFCP_LOG_INFO("IOC request code 0x%x invalid\n", command);
@@ -478,14 +475,13 @@ zfcp_sg_list_alloc(struct zfcp_sg_list *sg_list, size_t size)
478 sg_list->count = size >> PAGE_SHIFT; 475 sg_list->count = size >> PAGE_SHIFT;
479 if (size & ~PAGE_MASK) 476 if (size & ~PAGE_MASK)
480 sg_list->count++; 477 sg_list->count++;
481 sg_list->sg = kmalloc(sg_list->count * sizeof(struct scatterlist), 478 sg_list->sg = kcalloc(sg_list->count, sizeof(struct scatterlist),
482 GFP_KERNEL); 479 GFP_KERNEL);
483 if (sg_list->sg == NULL) { 480 if (sg_list->sg == NULL) {
484 sg_list->count = 0; 481 sg_list->count = 0;
485 retval = -ENOMEM; 482 retval = -ENOMEM;
486 goto out; 483 goto out;
487 } 484 }
488 memset(sg_list->sg, 0, sg_list->count * sizeof(struct scatterlist));
489 485
490 for (i = 0, sg = sg_list->sg; i < sg_list->count; i++, sg++) { 486 for (i = 0, sg = sg_list->sg; i < sg_list->count; i++, sg++) {
491 sg->length = min(size, PAGE_SIZE); 487 sg->length = min(size, PAGE_SIZE);
@@ -744,7 +740,7 @@ struct zfcp_unit *
744zfcp_unit_enqueue(struct zfcp_port *port, fcp_lun_t fcp_lun) 740zfcp_unit_enqueue(struct zfcp_port *port, fcp_lun_t fcp_lun)
745{ 741{
746 struct zfcp_unit *unit, *tmp_unit; 742 struct zfcp_unit *unit, *tmp_unit;
747 scsi_lun_t scsi_lun; 743 unsigned int scsi_lun;
748 int found; 744 int found;
749 745
750 /* 746 /*
@@ -758,10 +754,9 @@ zfcp_unit_enqueue(struct zfcp_port *port, fcp_lun_t fcp_lun)
758 if (unit) 754 if (unit)
759 return NULL; 755 return NULL;
760 756
761 unit = kmalloc(sizeof (struct zfcp_unit), GFP_KERNEL); 757 unit = kzalloc(sizeof (struct zfcp_unit), GFP_KERNEL);
762 if (!unit) 758 if (!unit)
763 return NULL; 759 return NULL;
764 memset(unit, 0, sizeof (struct zfcp_unit));
765 760
766 /* initialise reference count stuff */ 761 /* initialise reference count stuff */
767 atomic_set(&unit->refcount, 0); 762 atomic_set(&unit->refcount, 0);
@@ -929,13 +924,12 @@ zfcp_adapter_enqueue(struct ccw_device *ccw_device)
929 */ 924 */
930 925
931 /* try to allocate new adapter data structure (zeroed) */ 926 /* try to allocate new adapter data structure (zeroed) */
932 adapter = kmalloc(sizeof (struct zfcp_adapter), GFP_KERNEL); 927 adapter = kzalloc(sizeof (struct zfcp_adapter), GFP_KERNEL);
933 if (!adapter) { 928 if (!adapter) {
934 ZFCP_LOG_INFO("error: allocation of base adapter " 929 ZFCP_LOG_INFO("error: allocation of base adapter "
935 "structure failed\n"); 930 "structure failed\n");
936 goto out; 931 goto out;
937 } 932 }
938 memset(adapter, 0, sizeof (struct zfcp_adapter));
939 933
940 ccw_device->handler = NULL; 934 ccw_device->handler = NULL;
941 935
@@ -997,12 +991,6 @@ zfcp_adapter_enqueue(struct ccw_device *ccw_device)
997 /* intitialise SCSI ER timer */ 991 /* intitialise SCSI ER timer */
998 init_timer(&adapter->scsi_er_timer); 992 init_timer(&adapter->scsi_er_timer);
999 993
1000 /* set FC service class used per default */
1001 adapter->fc_service_class = ZFCP_FC_SERVICE_CLASS_DEFAULT;
1002
1003 sprintf(adapter->name, "%s", zfcp_get_busid_by_adapter(adapter));
1004 ASCEBC(adapter->name, strlen(adapter->name));
1005
1006 /* mark adapter unusable as long as sysfs registration is not complete */ 994 /* mark adapter unusable as long as sysfs registration is not complete */
1007 atomic_set_mask(ZFCP_STATUS_COMMON_REMOVE, &adapter->status); 995 atomic_set_mask(ZFCP_STATUS_COMMON_REMOVE, &adapter->status);
1008 996
@@ -1139,10 +1127,9 @@ zfcp_port_enqueue(struct zfcp_adapter *adapter, wwn_t wwpn, u32 status,
1139 return NULL; 1127 return NULL;
1140 } 1128 }
1141 1129
1142 port = kmalloc(sizeof (struct zfcp_port), GFP_KERNEL); 1130 port = kzalloc(sizeof (struct zfcp_port), GFP_KERNEL);
1143 if (!port) 1131 if (!port)
1144 return NULL; 1132 return NULL;
1145 memset(port, 0, sizeof (struct zfcp_port));
1146 1133
1147 /* initialise reference count stuff */ 1134 /* initialise reference count stuff */
1148 atomic_set(&port->refcount, 0); 1135 atomic_set(&port->refcount, 0);
@@ -1354,18 +1341,19 @@ static void
1354zfcp_fsf_incoming_els_plogi(struct zfcp_adapter *adapter, 1341zfcp_fsf_incoming_els_plogi(struct zfcp_adapter *adapter,
1355 struct fsf_status_read_buffer *status_buffer) 1342 struct fsf_status_read_buffer *status_buffer)
1356{ 1343{
1357 logi *els_logi = (logi *) status_buffer->payload; 1344 struct fsf_plogi *els_plogi;
1358 struct zfcp_port *port; 1345 struct zfcp_port *port;
1359 unsigned long flags; 1346 unsigned long flags;
1360 1347
1348 els_plogi = (struct fsf_plogi *) status_buffer->payload;
1361 read_lock_irqsave(&zfcp_data.config_lock, flags); 1349 read_lock_irqsave(&zfcp_data.config_lock, flags);
1362 list_for_each_entry(port, &adapter->port_list_head, list) { 1350 list_for_each_entry(port, &adapter->port_list_head, list) {
1363 if (port->wwpn == (*(wwn_t *) & els_logi->nport_wwn)) 1351 if (port->wwpn == (*(wwn_t *) &els_plogi->serv_param.wwpn))
1364 break; 1352 break;
1365 } 1353 }
1366 read_unlock_irqrestore(&zfcp_data.config_lock, flags); 1354 read_unlock_irqrestore(&zfcp_data.config_lock, flags);
1367 1355
1368 if (!port || (port->wwpn != (*(wwn_t *) & els_logi->nport_wwn))) { 1356 if (!port || (port->wwpn != (*(wwn_t *) &els_plogi->serv_param.wwpn))) {
1369 ZFCP_LOG_DEBUG("ignored incoming PLOGI for nonexisting port " 1357 ZFCP_LOG_DEBUG("ignored incoming PLOGI for nonexisting port "
1370 "with d_id 0x%08x on adapter %s\n", 1358 "with d_id 0x%08x on adapter %s\n",
1371 status_buffer->d_id, 1359 status_buffer->d_id,
@@ -1760,4 +1748,25 @@ zfcp_handle_els_rjt(u32 sq, struct zfcp_ls_rjt_par *rjt_par)
1760 return ret; 1748 return ret;
1761} 1749}
1762 1750
1751/**
1752 * zfcp_plogi_evaluate - evaluate PLOGI playload and copy important fields
1753 * into zfcp_port structure
1754 * @port: zfcp_port structure
1755 * @plogi: plogi payload
1756 */
1757void
1758zfcp_plogi_evaluate(struct zfcp_port *port, struct fsf_plogi *plogi)
1759{
1760 port->maxframe_size = plogi->serv_param.common_serv_param[7] |
1761 ((plogi->serv_param.common_serv_param[6] & 0x0F) << 8);
1762 if (plogi->serv_param.class1_serv_param[0] & 0x80)
1763 port->supported_classes |= FC_COS_CLASS1;
1764 if (plogi->serv_param.class2_serv_param[0] & 0x80)
1765 port->supported_classes |= FC_COS_CLASS2;
1766 if (plogi->serv_param.class3_serv_param[0] & 0x80)
1767 port->supported_classes |= FC_COS_CLASS3;
1768 if (plogi->serv_param.class4_serv_param[0] & 0x80)
1769 port->supported_classes |= FC_COS_CLASS4;
1770}
1771
1763#undef ZFCP_LOG_AREA 1772#undef ZFCP_LOG_AREA