aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/libfc/fc_rport.c
diff options
context:
space:
mode:
authorDan Williams <dan.j.williams@intel.com>2009-09-08 20:55:21 -0400
committerDan Williams <dan.j.williams@intel.com>2009-09-08 20:55:21 -0400
commitbbb20089a3275a19e475dbc21320c3742e3ca423 (patch)
tree216fdc1cbef450ca688135c5b8969169482d9a48 /drivers/scsi/libfc/fc_rport.c
parent3e48e656903e9fd8bc805c6a2c4264d7808d315b (diff)
parent657a77fa7284d8ae28dfa48f1dc5d919bf5b2843 (diff)
Merge branch 'dmaengine' into async-tx-next
Conflicts: crypto/async_tx/async_xor.c drivers/dma/ioat/dma_v2.h drivers/dma/ioat/pci.c drivers/md/raid5.c
Diffstat (limited to 'drivers/scsi/libfc/fc_rport.c')
-rw-r--r--drivers/scsi/libfc/fc_rport.c126
1 files changed, 53 insertions, 73 deletions
diff --git a/drivers/scsi/libfc/fc_rport.c b/drivers/scsi/libfc/fc_rport.c
index 747d73c5c8af..7162385f52eb 100644
--- a/drivers/scsi/libfc/fc_rport.c
+++ b/drivers/scsi/libfc/fc_rport.c
@@ -55,14 +55,6 @@
55#include <scsi/libfc.h> 55#include <scsi/libfc.h>
56#include <scsi/fc_encode.h> 56#include <scsi/fc_encode.h>
57 57
58static int fc_rport_debug;
59
60#define FC_DEBUG_RPORT(fmt...) \
61 do { \
62 if (fc_rport_debug) \
63 FC_DBG(fmt); \
64 } while (0)
65
66struct workqueue_struct *rport_event_queue; 58struct workqueue_struct *rport_event_queue;
67 59
68static void fc_rport_enter_plogi(struct fc_rport *); 60static void fc_rport_enter_plogi(struct fc_rport *);
@@ -97,7 +89,7 @@ static const char *fc_rport_state_names[] = {
97static void fc_rport_rogue_destroy(struct device *dev) 89static void fc_rport_rogue_destroy(struct device *dev)
98{ 90{
99 struct fc_rport *rport = dev_to_rport(dev); 91 struct fc_rport *rport = dev_to_rport(dev);
100 FC_DEBUG_RPORT("Destroying rogue rport (%6x)\n", rport->port_id); 92 FC_RPORT_DBG(rport, "Destroying rogue rport\n");
101 kfree(rport); 93 kfree(rport);
102} 94}
103 95
@@ -263,8 +255,8 @@ static void fc_rport_work(struct work_struct *work)
263 255
264 fc_rport_state_enter(new_rport, RPORT_ST_READY); 256 fc_rport_state_enter(new_rport, RPORT_ST_READY);
265 } else { 257 } else {
266 FC_DBG("Failed to create the rport for port " 258 printk(KERN_WARNING "libfc: Failed to allocate "
267 "(%6x).\n", ids.port_id); 259 " memory for rport (%6x)\n", ids.port_id);
268 event = RPORT_EV_FAILED; 260 event = RPORT_EV_FAILED;
269 } 261 }
270 if (rport->port_id != FC_FID_DIR_SERV) 262 if (rport->port_id != FC_FID_DIR_SERV)
@@ -309,7 +301,7 @@ int fc_rport_login(struct fc_rport *rport)
309 301
310 mutex_lock(&rdata->rp_mutex); 302 mutex_lock(&rdata->rp_mutex);
311 303
312 FC_DEBUG_RPORT("Login to port (%6x)\n", rport->port_id); 304 FC_RPORT_DBG(rport, "Login to port\n");
313 305
314 fc_rport_enter_plogi(rport); 306 fc_rport_enter_plogi(rport);
315 307
@@ -329,16 +321,13 @@ int fc_rport_login(struct fc_rport *rport)
329int fc_rport_logoff(struct fc_rport *rport) 321int fc_rport_logoff(struct fc_rport *rport)
330{ 322{
331 struct fc_rport_libfc_priv *rdata = rport->dd_data; 323 struct fc_rport_libfc_priv *rdata = rport->dd_data;
332 struct fc_lport *lport = rdata->local_port;
333 324
334 mutex_lock(&rdata->rp_mutex); 325 mutex_lock(&rdata->rp_mutex);
335 326
336 FC_DEBUG_RPORT("Remove port (%6x)\n", rport->port_id); 327 FC_RPORT_DBG(rport, "Remove port\n");
337 328
338 if (rdata->rp_state == RPORT_ST_NONE) { 329 if (rdata->rp_state == RPORT_ST_NONE) {
339 FC_DEBUG_RPORT("(%6x): Port (%6x) in NONE state," 330 FC_RPORT_DBG(rport, "Port in NONE state, not removing\n");
340 " not removing", fc_host_port_id(lport->host),
341 rport->port_id);
342 mutex_unlock(&rdata->rp_mutex); 331 mutex_unlock(&rdata->rp_mutex);
343 goto out; 332 goto out;
344 } 333 }
@@ -379,7 +368,7 @@ static void fc_rport_enter_ready(struct fc_rport *rport)
379 368
380 fc_rport_state_enter(rport, RPORT_ST_READY); 369 fc_rport_state_enter(rport, RPORT_ST_READY);
381 370
382 FC_DEBUG_RPORT("Port (%6x) is Ready\n", rport->port_id); 371 FC_RPORT_DBG(rport, "Port is Ready\n");
383 372
384 rdata->event = RPORT_EV_CREATED; 373 rdata->event = RPORT_EV_CREATED;
385 queue_work(rport_event_queue, &rdata->event_work); 374 queue_work(rport_event_queue, &rdata->event_work);
@@ -436,8 +425,8 @@ static void fc_rport_error(struct fc_rport *rport, struct fc_frame *fp)
436{ 425{
437 struct fc_rport_libfc_priv *rdata = rport->dd_data; 426 struct fc_rport_libfc_priv *rdata = rport->dd_data;
438 427
439 FC_DEBUG_RPORT("Error %ld in state %s, retries %d\n", 428 FC_RPORT_DBG(rport, "Error %ld in state %s, retries %d\n",
440 PTR_ERR(fp), fc_rport_state(rport), rdata->retries); 429 PTR_ERR(fp), fc_rport_state(rport), rdata->retries);
441 430
442 switch (rdata->rp_state) { 431 switch (rdata->rp_state) {
443 case RPORT_ST_PLOGI: 432 case RPORT_ST_PLOGI:
@@ -478,9 +467,9 @@ static void fc_rport_error_retry(struct fc_rport *rport, struct fc_frame *fp)
478 if (PTR_ERR(fp) == -FC_EX_CLOSED) 467 if (PTR_ERR(fp) == -FC_EX_CLOSED)
479 return fc_rport_error(rport, fp); 468 return fc_rport_error(rport, fp);
480 469
481 if (rdata->retries < rdata->local_port->max_retry_count) { 470 if (rdata->retries < rdata->local_port->max_rport_retry_count) {
482 FC_DEBUG_RPORT("Error %ld in state %s, retrying\n", 471 FC_RPORT_DBG(rport, "Error %ld in state %s, retrying\n",
483 PTR_ERR(fp), fc_rport_state(rport)); 472 PTR_ERR(fp), fc_rport_state(rport));
484 rdata->retries++; 473 rdata->retries++;
485 /* no additional delay on exchange timeouts */ 474 /* no additional delay on exchange timeouts */
486 if (PTR_ERR(fp) == -FC_EX_TIMEOUT) 475 if (PTR_ERR(fp) == -FC_EX_TIMEOUT)
@@ -517,12 +506,11 @@ static void fc_rport_plogi_resp(struct fc_seq *sp, struct fc_frame *fp,
517 506
518 mutex_lock(&rdata->rp_mutex); 507 mutex_lock(&rdata->rp_mutex);
519 508
520 FC_DEBUG_RPORT("Received a PLOGI response from port (%6x)\n", 509 FC_RPORT_DBG(rport, "Received a PLOGI response\n");
521 rport->port_id);
522 510
523 if (rdata->rp_state != RPORT_ST_PLOGI) { 511 if (rdata->rp_state != RPORT_ST_PLOGI) {
524 FC_DBG("Received a PLOGI response, but in state %s\n", 512 FC_RPORT_DBG(rport, "Received a PLOGI response, but in state "
525 fc_rport_state(rport)); 513 "%s\n", fc_rport_state(rport));
526 if (IS_ERR(fp)) 514 if (IS_ERR(fp))
527 goto err; 515 goto err;
528 goto out; 516 goto out;
@@ -583,8 +571,8 @@ static void fc_rport_enter_plogi(struct fc_rport *rport)
583 struct fc_lport *lport = rdata->local_port; 571 struct fc_lport *lport = rdata->local_port;
584 struct fc_frame *fp; 572 struct fc_frame *fp;
585 573
586 FC_DEBUG_RPORT("Port (%6x) entered PLOGI state from %s state\n", 574 FC_RPORT_DBG(rport, "Port entered PLOGI state from %s state\n",
587 rport->port_id, fc_rport_state(rport)); 575 fc_rport_state(rport));
588 576
589 fc_rport_state_enter(rport, RPORT_ST_PLOGI); 577 fc_rport_state_enter(rport, RPORT_ST_PLOGI);
590 578
@@ -628,12 +616,11 @@ static void fc_rport_prli_resp(struct fc_seq *sp, struct fc_frame *fp,
628 616
629 mutex_lock(&rdata->rp_mutex); 617 mutex_lock(&rdata->rp_mutex);
630 618
631 FC_DEBUG_RPORT("Received a PRLI response from port (%6x)\n", 619 FC_RPORT_DBG(rport, "Received a PRLI response\n");
632 rport->port_id);
633 620
634 if (rdata->rp_state != RPORT_ST_PRLI) { 621 if (rdata->rp_state != RPORT_ST_PRLI) {
635 FC_DBG("Received a PRLI response, but in state %s\n", 622 FC_RPORT_DBG(rport, "Received a PRLI response, but in state "
636 fc_rport_state(rport)); 623 "%s\n", fc_rport_state(rport));
637 if (IS_ERR(fp)) 624 if (IS_ERR(fp))
638 goto err; 625 goto err;
639 goto out; 626 goto out;
@@ -663,7 +650,7 @@ static void fc_rport_prli_resp(struct fc_seq *sp, struct fc_frame *fp,
663 fc_rport_enter_rtv(rport); 650 fc_rport_enter_rtv(rport);
664 651
665 } else { 652 } else {
666 FC_DBG("Bad ELS response\n"); 653 FC_RPORT_DBG(rport, "Bad ELS response for PRLI command\n");
667 rdata->event = RPORT_EV_FAILED; 654 rdata->event = RPORT_EV_FAILED;
668 fc_rport_state_enter(rport, RPORT_ST_NONE); 655 fc_rport_state_enter(rport, RPORT_ST_NONE);
669 queue_work(rport_event_queue, &rdata->event_work); 656 queue_work(rport_event_queue, &rdata->event_work);
@@ -695,12 +682,11 @@ static void fc_rport_logo_resp(struct fc_seq *sp, struct fc_frame *fp,
695 682
696 mutex_lock(&rdata->rp_mutex); 683 mutex_lock(&rdata->rp_mutex);
697 684
698 FC_DEBUG_RPORT("Received a LOGO response from port (%6x)\n", 685 FC_RPORT_DBG(rport, "Received a LOGO response\n");
699 rport->port_id);
700 686
701 if (rdata->rp_state != RPORT_ST_LOGO) { 687 if (rdata->rp_state != RPORT_ST_LOGO) {
702 FC_DEBUG_RPORT("Received a LOGO response, but in state %s\n", 688 FC_RPORT_DBG(rport, "Received a LOGO response, but in state "
703 fc_rport_state(rport)); 689 "%s\n", fc_rport_state(rport));
704 if (IS_ERR(fp)) 690 if (IS_ERR(fp))
705 goto err; 691 goto err;
706 goto out; 692 goto out;
@@ -715,7 +701,7 @@ static void fc_rport_logo_resp(struct fc_seq *sp, struct fc_frame *fp,
715 if (op == ELS_LS_ACC) { 701 if (op == ELS_LS_ACC) {
716 fc_rport_enter_rtv(rport); 702 fc_rport_enter_rtv(rport);
717 } else { 703 } else {
718 FC_DBG("Bad ELS response\n"); 704 FC_RPORT_DBG(rport, "Bad ELS response for LOGO command\n");
719 rdata->event = RPORT_EV_LOGO; 705 rdata->event = RPORT_EV_LOGO;
720 fc_rport_state_enter(rport, RPORT_ST_NONE); 706 fc_rport_state_enter(rport, RPORT_ST_NONE);
721 queue_work(rport_event_queue, &rdata->event_work); 707 queue_work(rport_event_queue, &rdata->event_work);
@@ -745,8 +731,8 @@ static void fc_rport_enter_prli(struct fc_rport *rport)
745 } *pp; 731 } *pp;
746 struct fc_frame *fp; 732 struct fc_frame *fp;
747 733
748 FC_DEBUG_RPORT("Port (%6x) entered PRLI state from %s state\n", 734 FC_RPORT_DBG(rport, "Port entered PRLI state from %s state\n",
749 rport->port_id, fc_rport_state(rport)); 735 fc_rport_state(rport));
750 736
751 fc_rport_state_enter(rport, RPORT_ST_PRLI); 737 fc_rport_state_enter(rport, RPORT_ST_PRLI);
752 738
@@ -784,12 +770,11 @@ static void fc_rport_rtv_resp(struct fc_seq *sp, struct fc_frame *fp,
784 770
785 mutex_lock(&rdata->rp_mutex); 771 mutex_lock(&rdata->rp_mutex);
786 772
787 FC_DEBUG_RPORT("Received a RTV response from port (%6x)\n", 773 FC_RPORT_DBG(rport, "Received a RTV response\n");
788 rport->port_id);
789 774
790 if (rdata->rp_state != RPORT_ST_RTV) { 775 if (rdata->rp_state != RPORT_ST_RTV) {
791 FC_DBG("Received a RTV response, but in state %s\n", 776 FC_RPORT_DBG(rport, "Received a RTV response, but in state "
792 fc_rport_state(rport)); 777 "%s\n", fc_rport_state(rport));
793 if (IS_ERR(fp)) 778 if (IS_ERR(fp))
794 goto err; 779 goto err;
795 goto out; 780 goto out;
@@ -844,8 +829,8 @@ static void fc_rport_enter_rtv(struct fc_rport *rport)
844 struct fc_rport_libfc_priv *rdata = rport->dd_data; 829 struct fc_rport_libfc_priv *rdata = rport->dd_data;
845 struct fc_lport *lport = rdata->local_port; 830 struct fc_lport *lport = rdata->local_port;
846 831
847 FC_DEBUG_RPORT("Port (%6x) entered RTV state from %s state\n", 832 FC_RPORT_DBG(rport, "Port entered RTV state from %s state\n",
848 rport->port_id, fc_rport_state(rport)); 833 fc_rport_state(rport));
849 834
850 fc_rport_state_enter(rport, RPORT_ST_RTV); 835 fc_rport_state_enter(rport, RPORT_ST_RTV);
851 836
@@ -875,8 +860,8 @@ static void fc_rport_enter_logo(struct fc_rport *rport)
875 struct fc_lport *lport = rdata->local_port; 860 struct fc_lport *lport = rdata->local_port;
876 struct fc_frame *fp; 861 struct fc_frame *fp;
877 862
878 FC_DEBUG_RPORT("Port (%6x) entered LOGO state from %s state\n", 863 FC_RPORT_DBG(rport, "Port entered LOGO state from %s state\n",
879 rport->port_id, fc_rport_state(rport)); 864 fc_rport_state(rport));
880 865
881 fc_rport_state_enter(rport, RPORT_ST_LOGO); 866 fc_rport_state_enter(rport, RPORT_ST_LOGO);
882 867
@@ -983,14 +968,13 @@ static void fc_rport_recv_plogi_req(struct fc_rport *rport,
983 968
984 fh = fc_frame_header_get(fp); 969 fh = fc_frame_header_get(fp);
985 970
986 FC_DEBUG_RPORT("Received PLOGI request from port (%6x) " 971 FC_RPORT_DBG(rport, "Received PLOGI request while in state %s\n",
987 "while in state %s\n", ntoh24(fh->fh_s_id), 972 fc_rport_state(rport));
988 fc_rport_state(rport));
989 973
990 sid = ntoh24(fh->fh_s_id); 974 sid = ntoh24(fh->fh_s_id);
991 pl = fc_frame_payload_get(fp, sizeof(*pl)); 975 pl = fc_frame_payload_get(fp, sizeof(*pl));
992 if (!pl) { 976 if (!pl) {
993 FC_DBG("incoming PLOGI from %x too short\n", sid); 977 FC_RPORT_DBG(rport, "Received PLOGI too short\n");
994 WARN_ON(1); 978 WARN_ON(1);
995 /* XXX TBD: send reject? */ 979 /* XXX TBD: send reject? */
996 fc_frame_free(fp); 980 fc_frame_free(fp);
@@ -1012,26 +996,26 @@ static void fc_rport_recv_plogi_req(struct fc_rport *rport,
1012 */ 996 */
1013 switch (rdata->rp_state) { 997 switch (rdata->rp_state) {
1014 case RPORT_ST_INIT: 998 case RPORT_ST_INIT:
1015 FC_DEBUG_RPORT("incoming PLOGI from %6x wwpn %llx state INIT " 999 FC_RPORT_DBG(rport, "Received PLOGI, wwpn %llx state INIT "
1016 "- reject\n", sid, (unsigned long long)wwpn); 1000 "- reject\n", (unsigned long long)wwpn);
1017 reject = ELS_RJT_UNSUP; 1001 reject = ELS_RJT_UNSUP;
1018 break; 1002 break;
1019 case RPORT_ST_PLOGI: 1003 case RPORT_ST_PLOGI:
1020 FC_DEBUG_RPORT("incoming PLOGI from %x in PLOGI state %d\n", 1004 FC_RPORT_DBG(rport, "Received PLOGI in PLOGI state %d\n",
1021 sid, rdata->rp_state); 1005 rdata->rp_state);
1022 if (wwpn < lport->wwpn) 1006 if (wwpn < lport->wwpn)
1023 reject = ELS_RJT_INPROG; 1007 reject = ELS_RJT_INPROG;
1024 break; 1008 break;
1025 case RPORT_ST_PRLI: 1009 case RPORT_ST_PRLI:
1026 case RPORT_ST_READY: 1010 case RPORT_ST_READY:
1027 FC_DEBUG_RPORT("incoming PLOGI from %x in logged-in state %d " 1011 FC_RPORT_DBG(rport, "Received PLOGI in logged-in state %d "
1028 "- ignored for now\n", sid, rdata->rp_state); 1012 "- ignored for now\n", rdata->rp_state);
1029 /* XXX TBD - should reset */ 1013 /* XXX TBD - should reset */
1030 break; 1014 break;
1031 case RPORT_ST_NONE: 1015 case RPORT_ST_NONE:
1032 default: 1016 default:
1033 FC_DEBUG_RPORT("incoming PLOGI from %x in unexpected " 1017 FC_RPORT_DBG(rport, "Received PLOGI in unexpected "
1034 "state %d\n", sid, rdata->rp_state); 1018 "state %d\n", rdata->rp_state);
1035 fc_frame_free(fp); 1019 fc_frame_free(fp);
1036 return; 1020 return;
1037 break; 1021 break;
@@ -1115,9 +1099,8 @@ static void fc_rport_recv_prli_req(struct fc_rport *rport,
1115 1099
1116 fh = fc_frame_header_get(rx_fp); 1100 fh = fc_frame_header_get(rx_fp);
1117 1101
1118 FC_DEBUG_RPORT("Received PRLI request from port (%6x) " 1102 FC_RPORT_DBG(rport, "Received PRLI request while in state %s\n",
1119 "while in state %s\n", ntoh24(fh->fh_s_id), 1103 fc_rport_state(rport));
1120 fc_rport_state(rport));
1121 1104
1122 switch (rdata->rp_state) { 1105 switch (rdata->rp_state) {
1123 case RPORT_ST_PRLI: 1106 case RPORT_ST_PRLI:
@@ -1252,9 +1235,8 @@ static void fc_rport_recv_prlo_req(struct fc_rport *rport, struct fc_seq *sp,
1252 1235
1253 fh = fc_frame_header_get(fp); 1236 fh = fc_frame_header_get(fp);
1254 1237
1255 FC_DEBUG_RPORT("Received PRLO request from port (%6x) " 1238 FC_RPORT_DBG(rport, "Received PRLO request while in state %s\n",
1256 "while in state %s\n", ntoh24(fh->fh_s_id), 1239 fc_rport_state(rport));
1257 fc_rport_state(rport));
1258 1240
1259 if (rdata->rp_state == RPORT_ST_NONE) { 1241 if (rdata->rp_state == RPORT_ST_NONE) {
1260 fc_frame_free(fp); 1242 fc_frame_free(fp);
@@ -1286,9 +1268,8 @@ static void fc_rport_recv_logo_req(struct fc_rport *rport, struct fc_seq *sp,
1286 1268
1287 fh = fc_frame_header_get(fp); 1269 fh = fc_frame_header_get(fp);
1288 1270
1289 FC_DEBUG_RPORT("Received LOGO request from port (%6x) " 1271 FC_RPORT_DBG(rport, "Received LOGO request while in state %s\n",
1290 "while in state %s\n", ntoh24(fh->fh_s_id), 1272 fc_rport_state(rport));
1291 fc_rport_state(rport));
1292 1273
1293 if (rdata->rp_state == RPORT_ST_NONE) { 1274 if (rdata->rp_state == RPORT_ST_NONE) {
1294 fc_frame_free(fp); 1275 fc_frame_free(fp);
@@ -1308,7 +1289,6 @@ static void fc_rport_flush_queue(void)
1308 flush_workqueue(rport_event_queue); 1289 flush_workqueue(rport_event_queue);
1309} 1290}
1310 1291
1311
1312int fc_rport_init(struct fc_lport *lport) 1292int fc_rport_init(struct fc_lport *lport)
1313{ 1293{
1314 if (!lport->tt.rport_create) 1294 if (!lport->tt.rport_create)
@@ -1330,7 +1310,7 @@ int fc_rport_init(struct fc_lport *lport)
1330} 1310}
1331EXPORT_SYMBOL(fc_rport_init); 1311EXPORT_SYMBOL(fc_rport_init);
1332 1312
1333int fc_setup_rport() 1313int fc_setup_rport(void)
1334{ 1314{
1335 rport_event_queue = create_singlethread_workqueue("fc_rport_eq"); 1315 rport_event_queue = create_singlethread_workqueue("fc_rport_eq");
1336 if (!rport_event_queue) 1316 if (!rport_event_queue)
@@ -1339,7 +1319,7 @@ int fc_setup_rport()
1339} 1319}
1340EXPORT_SYMBOL(fc_setup_rport); 1320EXPORT_SYMBOL(fc_setup_rport);
1341 1321
1342void fc_destroy_rport() 1322void fc_destroy_rport(void)
1343{ 1323{
1344 destroy_workqueue(rport_event_queue); 1324 destroy_workqueue(rport_event_queue);
1345} 1325}