diff options
Diffstat (limited to 'include/scsi/libfc.h')
| -rw-r--r-- | include/scsi/libfc.h | 138 |
1 files changed, 80 insertions, 58 deletions
diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h index 9f2876397dd..a2e126b86e3 100644 --- a/include/scsi/libfc.h +++ b/include/scsi/libfc.h | |||
| @@ -68,9 +68,6 @@ | |||
| 68 | /* | 68 | /* |
| 69 | * FC HBA status | 69 | * FC HBA status |
| 70 | */ | 70 | */ |
| 71 | #define FC_PAUSE (1 << 1) | ||
| 72 | #define FC_LINK_UP (1 << 0) | ||
| 73 | |||
| 74 | enum fc_lport_state { | 71 | enum fc_lport_state { |
| 75 | LPORT_ST_NONE = 0, | 72 | LPORT_ST_NONE = 0, |
| 76 | LPORT_ST_FLOGI, | 73 | LPORT_ST_FLOGI, |
| @@ -339,31 +336,17 @@ struct fc_exch { | |||
| 339 | 336 | ||
| 340 | struct libfc_function_template { | 337 | struct libfc_function_template { |
| 341 | 338 | ||
| 342 | /** | ||
| 343 | * Mandatory Fields | ||
| 344 | * | ||
| 345 | * These handlers must be implemented by the LLD. | ||
| 346 | */ | ||
| 347 | |||
| 348 | /* | 339 | /* |
| 349 | * Interface to send a FC frame | 340 | * Interface to send a FC frame |
| 350 | */ | ||
| 351 | int (*frame_send)(struct fc_lport *lp, struct fc_frame *fp); | ||
| 352 | |||
| 353 | /** | ||
| 354 | * Optional Fields | ||
| 355 | * | 341 | * |
| 356 | * The LLD may choose to implement any of the following handlers. | 342 | * STATUS: REQUIRED |
| 357 | * If LLD doesn't specify hander and leaves its pointer NULL then | ||
| 358 | * the default libfc function will be used for that handler. | ||
| 359 | */ | ||
| 360 | |||
| 361 | /** | ||
| 362 | * ELS/CT interfaces | ||
| 363 | */ | 343 | */ |
| 344 | int (*frame_send)(struct fc_lport *lp, struct fc_frame *fp); | ||
| 364 | 345 | ||
| 365 | /* | 346 | /* |
| 366 | * elsct_send - sends ELS/CT frame | 347 | * Interface to send ELS/CT frames |
| 348 | * | ||
| 349 | * STATUS: OPTIONAL | ||
| 367 | */ | 350 | */ |
| 368 | struct fc_seq *(*elsct_send)(struct fc_lport *lport, | 351 | struct fc_seq *(*elsct_send)(struct fc_lport *lport, |
| 369 | struct fc_rport *rport, | 352 | struct fc_rport *rport, |
| @@ -373,9 +356,6 @@ struct libfc_function_template { | |||
| 373 | struct fc_frame *fp, | 356 | struct fc_frame *fp, |
| 374 | void *arg), | 357 | void *arg), |
| 375 | void *arg, u32 timer_msec); | 358 | void *arg, u32 timer_msec); |
| 376 | /** | ||
| 377 | * Exhance Manager interfaces | ||
| 378 | */ | ||
| 379 | 359 | ||
| 380 | /* | 360 | /* |
| 381 | * Send the FC frame payload using a new exchange and sequence. | 361 | * Send the FC frame payload using a new exchange and sequence. |
| @@ -407,6 +387,8 @@ struct libfc_function_template { | |||
| 407 | * timer_msec argument is specified. The timer is canceled when | 387 | * timer_msec argument is specified. The timer is canceled when |
| 408 | * it fires or when the exchange is done. The exchange timeout handler | 388 | * it fires or when the exchange is done. The exchange timeout handler |
| 409 | * is registered by EM layer. | 389 | * is registered by EM layer. |
| 390 | * | ||
| 391 | * STATUS: OPTIONAL | ||
| 410 | */ | 392 | */ |
| 411 | struct fc_seq *(*exch_seq_send)(struct fc_lport *lp, | 393 | struct fc_seq *(*exch_seq_send)(struct fc_lport *lp, |
| 412 | struct fc_frame *fp, | 394 | struct fc_frame *fp, |
| @@ -418,14 +400,18 @@ struct libfc_function_template { | |||
| 418 | void *arg, unsigned int timer_msec); | 400 | void *arg, unsigned int timer_msec); |
| 419 | 401 | ||
| 420 | /* | 402 | /* |
| 421 | * send a frame using existing sequence and exchange. | 403 | * Send a frame using an existing sequence and exchange. |
| 404 | * | ||
| 405 | * STATUS: OPTIONAL | ||
| 422 | */ | 406 | */ |
| 423 | int (*seq_send)(struct fc_lport *lp, struct fc_seq *sp, | 407 | int (*seq_send)(struct fc_lport *lp, struct fc_seq *sp, |
| 424 | struct fc_frame *fp); | 408 | struct fc_frame *fp); |
| 425 | 409 | ||
| 426 | /* | 410 | /* |
| 427 | * Send ELS response using mainly infomation | 411 | * Send an ELS response using infomation from a previous |
| 428 | * in exchange and sequence in EM layer. | 412 | * exchange and sequence. |
| 413 | * | ||
| 414 | * STATUS: OPTIONAL | ||
| 429 | */ | 415 | */ |
| 430 | void (*seq_els_rsp_send)(struct fc_seq *sp, enum fc_els_cmd els_cmd, | 416 | void (*seq_els_rsp_send)(struct fc_seq *sp, enum fc_els_cmd els_cmd, |
| 431 | struct fc_seq_els_data *els_data); | 417 | struct fc_seq_els_data *els_data); |
| @@ -437,6 +423,8 @@ struct libfc_function_template { | |||
| 437 | * A timer_msec can be specified for abort timeout, if non-zero | 423 | * A timer_msec can be specified for abort timeout, if non-zero |
| 438 | * timer_msec value is specified then exchange resp handler | 424 | * timer_msec value is specified then exchange resp handler |
| 439 | * will be called with timeout error if no response to abort. | 425 | * will be called with timeout error if no response to abort. |
| 426 | * | ||
| 427 | * STATUS: OPTIONAL | ||
| 440 | */ | 428 | */ |
| 441 | int (*seq_exch_abort)(const struct fc_seq *req_sp, | 429 | int (*seq_exch_abort)(const struct fc_seq *req_sp, |
| 442 | unsigned int timer_msec); | 430 | unsigned int timer_msec); |
| @@ -444,6 +432,8 @@ struct libfc_function_template { | |||
| 444 | /* | 432 | /* |
| 445 | * Indicate that an exchange/sequence tuple is complete and the memory | 433 | * Indicate that an exchange/sequence tuple is complete and the memory |
| 446 | * allocated for the related objects may be freed. | 434 | * allocated for the related objects may be freed. |
| 435 | * | ||
| 436 | * STATUS: OPTIONAL | ||
| 447 | */ | 437 | */ |
| 448 | void (*exch_done)(struct fc_seq *sp); | 438 | void (*exch_done)(struct fc_seq *sp); |
| 449 | 439 | ||
| @@ -451,6 +441,8 @@ struct libfc_function_template { | |||
| 451 | * Assigns a EM and a free XID for an new exchange and then | 441 | * Assigns a EM and a free XID for an new exchange and then |
| 452 | * allocates a new exchange and sequence pair. | 442 | * allocates a new exchange and sequence pair. |
| 453 | * The fp can be used to determine free XID. | 443 | * The fp can be used to determine free XID. |
| 444 | * | ||
| 445 | * STATUS: OPTIONAL | ||
| 454 | */ | 446 | */ |
| 455 | struct fc_exch *(*exch_get)(struct fc_lport *lp, struct fc_frame *fp); | 447 | struct fc_exch *(*exch_get)(struct fc_lport *lp, struct fc_frame *fp); |
| 456 | 448 | ||
| @@ -458,12 +450,16 @@ struct libfc_function_template { | |||
| 458 | * Release previously assigned XID by exch_get API. | 450 | * Release previously assigned XID by exch_get API. |
| 459 | * The LLD may implement this if XID is assigned by LLD | 451 | * The LLD may implement this if XID is assigned by LLD |
| 460 | * in exch_get(). | 452 | * in exch_get(). |
| 453 | * | ||
| 454 | * STATUS: OPTIONAL | ||
| 461 | */ | 455 | */ |
| 462 | void (*exch_put)(struct fc_lport *lp, struct fc_exch_mgr *mp, | 456 | void (*exch_put)(struct fc_lport *lp, struct fc_exch_mgr *mp, |
| 463 | u16 ex_id); | 457 | u16 ex_id); |
| 464 | 458 | ||
| 465 | /* | 459 | /* |
| 466 | * Start a new sequence on the same exchange/sequence tuple. | 460 | * Start a new sequence on the same exchange/sequence tuple. |
| 461 | * | ||
| 462 | * STATUS: OPTIONAL | ||
| 467 | */ | 463 | */ |
| 468 | struct fc_seq *(*seq_start_next)(struct fc_seq *sp); | 464 | struct fc_seq *(*seq_start_next)(struct fc_seq *sp); |
| 469 | 465 | ||
| @@ -471,26 +467,38 @@ struct libfc_function_template { | |||
| 471 | * Reset an exchange manager, completing all sequences and exchanges. | 467 | * Reset an exchange manager, completing all sequences and exchanges. |
| 472 | * If s_id is non-zero, reset only exchanges originating from that FID. | 468 | * If s_id is non-zero, reset only exchanges originating from that FID. |
| 473 | * If d_id is non-zero, reset only exchanges sending to that FID. | 469 | * If d_id is non-zero, reset only exchanges sending to that FID. |
| 470 | * | ||
| 471 | * STATUS: OPTIONAL | ||
| 474 | */ | 472 | */ |
| 475 | void (*exch_mgr_reset)(struct fc_exch_mgr *, | 473 | void (*exch_mgr_reset)(struct fc_lport *, |
| 476 | u32 s_id, u32 d_id); | 474 | u32 s_id, u32 d_id); |
| 477 | 475 | ||
| 478 | void (*rport_flush_queue)(void); | 476 | /* |
| 479 | /** | 477 | * Flush the rport work queue. Generally used before shutdown. |
| 480 | * Local Port interfaces | 478 | * |
| 479 | * STATUS: OPTIONAL | ||
| 481 | */ | 480 | */ |
| 481 | void (*rport_flush_queue)(void); | ||
| 482 | 482 | ||
| 483 | /* | 483 | /* |
| 484 | * Receive a frame to a local port. | 484 | * Receive a frame for a local port. |
| 485 | * | ||
| 486 | * STATUS: OPTIONAL | ||
| 485 | */ | 487 | */ |
| 486 | void (*lport_recv)(struct fc_lport *lp, struct fc_seq *sp, | 488 | void (*lport_recv)(struct fc_lport *lp, struct fc_seq *sp, |
| 487 | struct fc_frame *fp); | 489 | struct fc_frame *fp); |
| 488 | 490 | ||
| 491 | /* | ||
| 492 | * Reset the local port. | ||
| 493 | * | ||
| 494 | * STATUS: OPTIONAL | ||
| 495 | */ | ||
| 489 | int (*lport_reset)(struct fc_lport *); | 496 | int (*lport_reset)(struct fc_lport *); |
| 490 | 497 | ||
| 491 | /** | 498 | /* |
| 492 | * Remote Port interfaces | 499 | * Create a remote port |
| 493 | */ | 500 | */ |
| 501 | struct fc_rport *(*rport_create)(struct fc_disc_port *); | ||
| 494 | 502 | ||
| 495 | /* | 503 | /* |
| 496 | * Initiates the RP state machine. It is called from the LP module. | 504 | * Initiates the RP state machine. It is called from the LP module. |
| @@ -500,26 +508,33 @@ struct libfc_function_template { | |||
| 500 | * - PLOGI | 508 | * - PLOGI |
| 501 | * - PRLI | 509 | * - PRLI |
| 502 | * - RTV | 510 | * - RTV |
| 511 | * | ||
| 512 | * STATUS: OPTIONAL | ||
| 503 | */ | 513 | */ |
| 504 | int (*rport_login)(struct fc_rport *rport); | 514 | int (*rport_login)(struct fc_rport *rport); |
| 505 | 515 | ||
| 506 | /* | 516 | /* |
| 507 | * Logoff, and remove the rport from the transport if | 517 | * Logoff, and remove the rport from the transport if |
| 508 | * it had been added. This will send a LOGO to the target. | 518 | * it had been added. This will send a LOGO to the target. |
| 519 | * | ||
| 520 | * STATUS: OPTIONAL | ||
| 509 | */ | 521 | */ |
| 510 | int (*rport_logoff)(struct fc_rport *rport); | 522 | int (*rport_logoff)(struct fc_rport *rport); |
| 511 | 523 | ||
| 512 | /* | 524 | /* |
| 513 | * Recieve a request from a remote port. | 525 | * Recieve a request from a remote port. |
| 526 | * | ||
| 527 | * STATUS: OPTIONAL | ||
| 514 | */ | 528 | */ |
| 515 | void (*rport_recv_req)(struct fc_seq *, struct fc_frame *, | 529 | void (*rport_recv_req)(struct fc_seq *, struct fc_frame *, |
| 516 | struct fc_rport *); | 530 | struct fc_rport *); |
| 517 | 531 | ||
| 518 | struct fc_rport *(*rport_lookup)(const struct fc_lport *, u32); | 532 | /* |
| 519 | 533 | * lookup an rport by it's port ID. | |
| 520 | /** | 534 | * |
| 521 | * FCP interfaces | 535 | * STATUS: OPTIONAL |
| 522 | */ | 536 | */ |
| 537 | struct fc_rport *(*rport_lookup)(const struct fc_lport *, u32); | ||
| 523 | 538 | ||
| 524 | /* | 539 | /* |
| 525 | * Send a fcp cmd from fsp pkt. | 540 | * Send a fcp cmd from fsp pkt. |
| @@ -527,30 +542,38 @@ struct libfc_function_template { | |||
| 527 | * | 542 | * |
| 528 | * The resp handler is called when FCP_RSP received. | 543 | * The resp handler is called when FCP_RSP received. |
| 529 | * | 544 | * |
| 545 | * STATUS: OPTIONAL | ||
| 530 | */ | 546 | */ |
| 531 | int (*fcp_cmd_send)(struct fc_lport *lp, struct fc_fcp_pkt *fsp, | 547 | int (*fcp_cmd_send)(struct fc_lport *lp, struct fc_fcp_pkt *fsp, |
| 532 | void (*resp)(struct fc_seq *, struct fc_frame *fp, | 548 | void (*resp)(struct fc_seq *, struct fc_frame *fp, |
| 533 | void *arg)); | 549 | void *arg)); |
| 534 | 550 | ||
| 535 | /* | 551 | /* |
| 536 | * Used at least durring linkdown and reset | 552 | * Cleanup the FCP layer, used durring link down and reset |
| 553 | * | ||
| 554 | * STATUS: OPTIONAL | ||
| 537 | */ | 555 | */ |
| 538 | void (*fcp_cleanup)(struct fc_lport *lp); | 556 | void (*fcp_cleanup)(struct fc_lport *lp); |
| 539 | 557 | ||
| 540 | /* | 558 | /* |
| 541 | * Abort all I/O on a local port | 559 | * Abort all I/O on a local port |
| 560 | * | ||
| 561 | * STATUS: OPTIONAL | ||
| 542 | */ | 562 | */ |
| 543 | void (*fcp_abort_io)(struct fc_lport *lp); | 563 | void (*fcp_abort_io)(struct fc_lport *lp); |
| 544 | 564 | ||
| 545 | /** | 565 | /* |
| 546 | * Discovery interfaces | 566 | * Receive a request for the discovery layer. |
| 567 | * | ||
| 568 | * STATUS: OPTIONAL | ||
| 547 | */ | 569 | */ |
| 548 | |||
| 549 | void (*disc_recv_req)(struct fc_seq *, | 570 | void (*disc_recv_req)(struct fc_seq *, |
| 550 | struct fc_frame *, struct fc_lport *); | 571 | struct fc_frame *, struct fc_lport *); |
| 551 | 572 | ||
| 552 | /* | 573 | /* |
| 553 | * Start discovery for a local port. | 574 | * Start discovery for a local port. |
| 575 | * | ||
| 576 | * STATUS: OPTIONAL | ||
| 554 | */ | 577 | */ |
| 555 | void (*disc_start)(void (*disc_callback)(struct fc_lport *, | 578 | void (*disc_start)(void (*disc_callback)(struct fc_lport *, |
| 556 | enum fc_disc_event), | 579 | enum fc_disc_event), |
| @@ -559,6 +582,8 @@ struct libfc_function_template { | |||
| 559 | /* | 582 | /* |
| 560 | * Stop discovery for a given lport. This will remove | 583 | * Stop discovery for a given lport. This will remove |
| 561 | * all discovered rports | 584 | * all discovered rports |
| 585 | * | ||
| 586 | * STATUS: OPTIONAL | ||
| 562 | */ | 587 | */ |
| 563 | void (*disc_stop) (struct fc_lport *); | 588 | void (*disc_stop) (struct fc_lport *); |
| 564 | 589 | ||
| @@ -566,6 +591,8 @@ struct libfc_function_template { | |||
| 566 | * Stop discovery for a given lport. This will block | 591 | * Stop discovery for a given lport. This will block |
| 567 | * until all discovered rports are deleted from the | 592 | * until all discovered rports are deleted from the |
| 568 | * FC transport class | 593 | * FC transport class |
| 594 | * | ||
| 595 | * STATUS: OPTIONAL | ||
| 569 | */ | 596 | */ |
| 570 | void (*disc_stop_final) (struct fc_lport *); | 597 | void (*disc_stop_final) (struct fc_lport *); |
| 571 | }; | 598 | }; |
| @@ -603,7 +630,8 @@ struct fc_lport { | |||
| 603 | 630 | ||
| 604 | /* Operational Information */ | 631 | /* Operational Information */ |
| 605 | struct libfc_function_template tt; | 632 | struct libfc_function_template tt; |
| 606 | u16 link_status; | 633 | u8 link_up; |
| 634 | u8 qfull; | ||
| 607 | enum fc_lport_state state; | 635 | enum fc_lport_state state; |
| 608 | unsigned long boot_time; | 636 | unsigned long boot_time; |
| 609 | 637 | ||
| @@ -637,7 +665,7 @@ struct fc_lport { | |||
| 637 | struct delayed_work disc_work; | 665 | struct delayed_work disc_work; |
| 638 | }; | 666 | }; |
| 639 | 667 | ||
| 640 | /** | 668 | /* |
| 641 | * FC_LPORT HELPER FUNCTIONS | 669 | * FC_LPORT HELPER FUNCTIONS |
| 642 | *****************************/ | 670 | *****************************/ |
| 643 | static inline void *lport_priv(const struct fc_lport *lp) | 671 | static inline void *lport_priv(const struct fc_lport *lp) |
| @@ -669,7 +697,7 @@ static inline void fc_lport_state_enter(struct fc_lport *lp, | |||
| 669 | } | 697 | } |
| 670 | 698 | ||
| 671 | 699 | ||
| 672 | /** | 700 | /* |
| 673 | * LOCAL PORT LAYER | 701 | * LOCAL PORT LAYER |
| 674 | *****************************/ | 702 | *****************************/ |
| 675 | int fc_lport_init(struct fc_lport *lp); | 703 | int fc_lport_init(struct fc_lport *lp); |
| @@ -704,12 +732,6 @@ void fc_linkup(struct fc_lport *); | |||
| 704 | void fc_linkdown(struct fc_lport *); | 732 | void fc_linkdown(struct fc_lport *); |
| 705 | 733 | ||
| 706 | /* | 734 | /* |
| 707 | * Pause and unpause traffic. | ||
| 708 | */ | ||
| 709 | void fc_pause(struct fc_lport *); | ||
| 710 | void fc_unpause(struct fc_lport *); | ||
| 711 | |||
| 712 | /* | ||
| 713 | * Configure the local port. | 735 | * Configure the local port. |
| 714 | */ | 736 | */ |
| 715 | int fc_lport_config(struct fc_lport *); | 737 | int fc_lport_config(struct fc_lport *); |
| @@ -725,19 +747,19 @@ int fc_lport_reset(struct fc_lport *); | |||
| 725 | int fc_set_mfs(struct fc_lport *lp, u32 mfs); | 747 | int fc_set_mfs(struct fc_lport *lp, u32 mfs); |
| 726 | 748 | ||
| 727 | 749 | ||
| 728 | /** | 750 | /* |
| 729 | * REMOTE PORT LAYER | 751 | * REMOTE PORT LAYER |
| 730 | *****************************/ | 752 | *****************************/ |
| 731 | int fc_rport_init(struct fc_lport *lp); | 753 | int fc_rport_init(struct fc_lport *lp); |
| 732 | void fc_rport_terminate_io(struct fc_rport *rp); | 754 | void fc_rport_terminate_io(struct fc_rport *rp); |
| 733 | 755 | ||
| 734 | /** | 756 | /* |
| 735 | * DISCOVERY LAYER | 757 | * DISCOVERY LAYER |
| 736 | *****************************/ | 758 | *****************************/ |
| 737 | int fc_disc_init(struct fc_lport *lp); | 759 | int fc_disc_init(struct fc_lport *lp); |
| 738 | 760 | ||
| 739 | 761 | ||
| 740 | /** | 762 | /* |
| 741 | * SCSI LAYER | 763 | * SCSI LAYER |
| 742 | *****************************/ | 764 | *****************************/ |
| 743 | /* | 765 | /* |
| @@ -798,7 +820,7 @@ int fc_change_queue_type(struct scsi_device *sdev, int tag_type); | |||
| 798 | */ | 820 | */ |
| 799 | void fc_fcp_destroy(struct fc_lport *); | 821 | void fc_fcp_destroy(struct fc_lport *); |
| 800 | 822 | ||
| 801 | /** | 823 | /* |
| 802 | * ELS/CT interface | 824 | * ELS/CT interface |
| 803 | *****************************/ | 825 | *****************************/ |
| 804 | /* | 826 | /* |
| @@ -807,7 +829,7 @@ void fc_fcp_destroy(struct fc_lport *); | |||
| 807 | int fc_elsct_init(struct fc_lport *lp); | 829 | int fc_elsct_init(struct fc_lport *lp); |
| 808 | 830 | ||
| 809 | 831 | ||
| 810 | /** | 832 | /* |
| 811 | * EXCHANGE MANAGER LAYER | 833 | * EXCHANGE MANAGER LAYER |
| 812 | *****************************/ | 834 | *****************************/ |
| 813 | /* | 835 | /* |
| @@ -916,7 +938,7 @@ struct fc_seq *fc_seq_start_next(struct fc_seq *sp); | |||
| 916 | * If s_id is non-zero, reset only exchanges originating from that FID. | 938 | * If s_id is non-zero, reset only exchanges originating from that FID. |
| 917 | * If d_id is non-zero, reset only exchanges sending to that FID. | 939 | * If d_id is non-zero, reset only exchanges sending to that FID. |
| 918 | */ | 940 | */ |
| 919 | void fc_exch_mgr_reset(struct fc_exch_mgr *, u32 s_id, u32 d_id); | 941 | void fc_exch_mgr_reset(struct fc_lport *, u32 s_id, u32 d_id); |
| 920 | 942 | ||
| 921 | /* | 943 | /* |
| 922 | * Functions for fc_functions_template | 944 | * Functions for fc_functions_template |
