aboutsummaryrefslogtreecommitdiffstats
path: root/include/scsi/libfc.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/scsi/libfc.h')
-rw-r--r--include/scsi/libfc.h169
1 files changed, 111 insertions, 58 deletions
diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h
index 9f2876397dda..a70eafaad084 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
74enum fc_lport_state { 71enum fc_lport_state {
75 LPORT_ST_NONE = 0, 72 LPORT_ST_NONE = 0,
76 LPORT_ST_FLOGI, 73 LPORT_ST_FLOGI,
@@ -248,6 +245,7 @@ struct fc_fcp_pkt {
248 */ 245 */
249 struct fcp_cmnd cdb_cmd; 246 struct fcp_cmnd cdb_cmd;
250 size_t xfer_len; 247 size_t xfer_len;
248 u16 xfer_ddp; /* this xfer is ddped */
251 u32 xfer_contig_end; /* offset of end of contiguous xfer */ 249 u32 xfer_contig_end; /* offset of end of contiguous xfer */
252 u16 max_payload; /* max payload size in bytes */ 250 u16 max_payload; /* max payload size in bytes */
253 251
@@ -270,6 +268,15 @@ struct fc_fcp_pkt {
270 u8 recov_retry; /* count of recovery retries */ 268 u8 recov_retry; /* count of recovery retries */
271 struct fc_seq *recov_seq; /* sequence for REC or SRR */ 269 struct fc_seq *recov_seq; /* sequence for REC or SRR */
272}; 270};
271/*
272 * FC_FCP HELPER FUNCTIONS
273 *****************************/
274static inline bool fc_fcp_is_read(const struct fc_fcp_pkt *fsp)
275{
276 if (fsp && fsp->cmd)
277 return fsp->cmd->sc_data_direction == DMA_FROM_DEVICE;
278 return false;
279}
273 280
274/* 281/*
275 * Structure and function definitions for managing Fibre Channel Exchanges 282 * Structure and function definitions for managing Fibre Channel Exchanges
@@ -339,31 +346,17 @@ struct fc_exch {
339 346
340struct libfc_function_template { 347struct libfc_function_template {
341 348
342 /**
343 * Mandatory Fields
344 *
345 * These handlers must be implemented by the LLD.
346 */
347
348 /* 349 /*
349 * Interface to send a FC frame 350 * 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 * 351 *
356 * The LLD may choose to implement any of the following handlers. 352 * 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 */ 353 */
354 int (*frame_send)(struct fc_lport *lp, struct fc_frame *fp);
364 355
365 /* 356 /*
366 * elsct_send - sends ELS/CT frame 357 * Interface to send ELS/CT frames
358 *
359 * STATUS: OPTIONAL
367 */ 360 */
368 struct fc_seq *(*elsct_send)(struct fc_lport *lport, 361 struct fc_seq *(*elsct_send)(struct fc_lport *lport,
369 struct fc_rport *rport, 362 struct fc_rport *rport,
@@ -373,9 +366,6 @@ struct libfc_function_template {
373 struct fc_frame *fp, 366 struct fc_frame *fp,
374 void *arg), 367 void *arg),
375 void *arg, u32 timer_msec); 368 void *arg, u32 timer_msec);
376 /**
377 * Exhance Manager interfaces
378 */
379 369
380 /* 370 /*
381 * Send the FC frame payload using a new exchange and sequence. 371 * Send the FC frame payload using a new exchange and sequence.
@@ -407,6 +397,8 @@ struct libfc_function_template {
407 * timer_msec argument is specified. The timer is canceled when 397 * timer_msec argument is specified. The timer is canceled when
408 * it fires or when the exchange is done. The exchange timeout handler 398 * it fires or when the exchange is done. The exchange timeout handler
409 * is registered by EM layer. 399 * is registered by EM layer.
400 *
401 * STATUS: OPTIONAL
410 */ 402 */
411 struct fc_seq *(*exch_seq_send)(struct fc_lport *lp, 403 struct fc_seq *(*exch_seq_send)(struct fc_lport *lp,
412 struct fc_frame *fp, 404 struct fc_frame *fp,
@@ -418,14 +410,33 @@ struct libfc_function_template {
418 void *arg, unsigned int timer_msec); 410 void *arg, unsigned int timer_msec);
419 411
420 /* 412 /*
421 * send a frame using existing sequence and exchange. 413 * Sets up the DDP context for a given exchange id on the given
414 * scatterlist if LLD supports DDP for large receive.
415 *
416 * STATUS: OPTIONAL
417 */
418 int (*ddp_setup)(struct fc_lport *lp, u16 xid,
419 struct scatterlist *sgl, unsigned int sgc);
420 /*
421 * Completes the DDP transfer and returns the length of data DDPed
422 * for the given exchange id.
423 *
424 * STATUS: OPTIONAL
425 */
426 int (*ddp_done)(struct fc_lport *lp, u16 xid);
427 /*
428 * Send a frame using an existing sequence and exchange.
429 *
430 * STATUS: OPTIONAL
422 */ 431 */
423 int (*seq_send)(struct fc_lport *lp, struct fc_seq *sp, 432 int (*seq_send)(struct fc_lport *lp, struct fc_seq *sp,
424 struct fc_frame *fp); 433 struct fc_frame *fp);
425 434
426 /* 435 /*
427 * Send ELS response using mainly infomation 436 * Send an ELS response using infomation from a previous
428 * in exchange and sequence in EM layer. 437 * exchange and sequence.
438 *
439 * STATUS: OPTIONAL
429 */ 440 */
430 void (*seq_els_rsp_send)(struct fc_seq *sp, enum fc_els_cmd els_cmd, 441 void (*seq_els_rsp_send)(struct fc_seq *sp, enum fc_els_cmd els_cmd,
431 struct fc_seq_els_data *els_data); 442 struct fc_seq_els_data *els_data);
@@ -437,6 +448,8 @@ struct libfc_function_template {
437 * A timer_msec can be specified for abort timeout, if non-zero 448 * A timer_msec can be specified for abort timeout, if non-zero
438 * timer_msec value is specified then exchange resp handler 449 * timer_msec value is specified then exchange resp handler
439 * will be called with timeout error if no response to abort. 450 * will be called with timeout error if no response to abort.
451 *
452 * STATUS: OPTIONAL
440 */ 453 */
441 int (*seq_exch_abort)(const struct fc_seq *req_sp, 454 int (*seq_exch_abort)(const struct fc_seq *req_sp,
442 unsigned int timer_msec); 455 unsigned int timer_msec);
@@ -444,6 +457,8 @@ struct libfc_function_template {
444 /* 457 /*
445 * Indicate that an exchange/sequence tuple is complete and the memory 458 * Indicate that an exchange/sequence tuple is complete and the memory
446 * allocated for the related objects may be freed. 459 * allocated for the related objects may be freed.
460 *
461 * STATUS: OPTIONAL
447 */ 462 */
448 void (*exch_done)(struct fc_seq *sp); 463 void (*exch_done)(struct fc_seq *sp);
449 464
@@ -451,6 +466,8 @@ struct libfc_function_template {
451 * Assigns a EM and a free XID for an new exchange and then 466 * Assigns a EM and a free XID for an new exchange and then
452 * allocates a new exchange and sequence pair. 467 * allocates a new exchange and sequence pair.
453 * The fp can be used to determine free XID. 468 * The fp can be used to determine free XID.
469 *
470 * STATUS: OPTIONAL
454 */ 471 */
455 struct fc_exch *(*exch_get)(struct fc_lport *lp, struct fc_frame *fp); 472 struct fc_exch *(*exch_get)(struct fc_lport *lp, struct fc_frame *fp);
456 473
@@ -458,12 +475,16 @@ struct libfc_function_template {
458 * Release previously assigned XID by exch_get API. 475 * Release previously assigned XID by exch_get API.
459 * The LLD may implement this if XID is assigned by LLD 476 * The LLD may implement this if XID is assigned by LLD
460 * in exch_get(). 477 * in exch_get().
478 *
479 * STATUS: OPTIONAL
461 */ 480 */
462 void (*exch_put)(struct fc_lport *lp, struct fc_exch_mgr *mp, 481 void (*exch_put)(struct fc_lport *lp, struct fc_exch_mgr *mp,
463 u16 ex_id); 482 u16 ex_id);
464 483
465 /* 484 /*
466 * Start a new sequence on the same exchange/sequence tuple. 485 * Start a new sequence on the same exchange/sequence tuple.
486 *
487 * STATUS: OPTIONAL
467 */ 488 */
468 struct fc_seq *(*seq_start_next)(struct fc_seq *sp); 489 struct fc_seq *(*seq_start_next)(struct fc_seq *sp);
469 490
@@ -471,26 +492,38 @@ struct libfc_function_template {
471 * Reset an exchange manager, completing all sequences and exchanges. 492 * Reset an exchange manager, completing all sequences and exchanges.
472 * If s_id is non-zero, reset only exchanges originating from that FID. 493 * 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. 494 * If d_id is non-zero, reset only exchanges sending to that FID.
495 *
496 * STATUS: OPTIONAL
474 */ 497 */
475 void (*exch_mgr_reset)(struct fc_exch_mgr *, 498 void (*exch_mgr_reset)(struct fc_lport *,
476 u32 s_id, u32 d_id); 499 u32 s_id, u32 d_id);
477 500
478 void (*rport_flush_queue)(void); 501 /*
479 /** 502 * Flush the rport work queue. Generally used before shutdown.
480 * Local Port interfaces 503 *
504 * STATUS: OPTIONAL
481 */ 505 */
506 void (*rport_flush_queue)(void);
482 507
483 /* 508 /*
484 * Receive a frame to a local port. 509 * Receive a frame for a local port.
510 *
511 * STATUS: OPTIONAL
485 */ 512 */
486 void (*lport_recv)(struct fc_lport *lp, struct fc_seq *sp, 513 void (*lport_recv)(struct fc_lport *lp, struct fc_seq *sp,
487 struct fc_frame *fp); 514 struct fc_frame *fp);
488 515
516 /*
517 * Reset the local port.
518 *
519 * STATUS: OPTIONAL
520 */
489 int (*lport_reset)(struct fc_lport *); 521 int (*lport_reset)(struct fc_lport *);
490 522
491 /** 523 /*
492 * Remote Port interfaces 524 * Create a remote port
493 */ 525 */
526 struct fc_rport *(*rport_create)(struct fc_disc_port *);
494 527
495 /* 528 /*
496 * Initiates the RP state machine. It is called from the LP module. 529 * Initiates the RP state machine. It is called from the LP module.
@@ -500,26 +533,33 @@ struct libfc_function_template {
500 * - PLOGI 533 * - PLOGI
501 * - PRLI 534 * - PRLI
502 * - RTV 535 * - RTV
536 *
537 * STATUS: OPTIONAL
503 */ 538 */
504 int (*rport_login)(struct fc_rport *rport); 539 int (*rport_login)(struct fc_rport *rport);
505 540
506 /* 541 /*
507 * Logoff, and remove the rport from the transport if 542 * Logoff, and remove the rport from the transport if
508 * it had been added. This will send a LOGO to the target. 543 * it had been added. This will send a LOGO to the target.
544 *
545 * STATUS: OPTIONAL
509 */ 546 */
510 int (*rport_logoff)(struct fc_rport *rport); 547 int (*rport_logoff)(struct fc_rport *rport);
511 548
512 /* 549 /*
513 * Recieve a request from a remote port. 550 * Recieve a request from a remote port.
551 *
552 * STATUS: OPTIONAL
514 */ 553 */
515 void (*rport_recv_req)(struct fc_seq *, struct fc_frame *, 554 void (*rport_recv_req)(struct fc_seq *, struct fc_frame *,
516 struct fc_rport *); 555 struct fc_rport *);
517 556
518 struct fc_rport *(*rport_lookup)(const struct fc_lport *, u32); 557 /*
519 558 * lookup an rport by it's port ID.
520 /** 559 *
521 * FCP interfaces 560 * STATUS: OPTIONAL
522 */ 561 */
562 struct fc_rport *(*rport_lookup)(const struct fc_lport *, u32);
523 563
524 /* 564 /*
525 * Send a fcp cmd from fsp pkt. 565 * Send a fcp cmd from fsp pkt.
@@ -527,30 +567,38 @@ struct libfc_function_template {
527 * 567 *
528 * The resp handler is called when FCP_RSP received. 568 * The resp handler is called when FCP_RSP received.
529 * 569 *
570 * STATUS: OPTIONAL
530 */ 571 */
531 int (*fcp_cmd_send)(struct fc_lport *lp, struct fc_fcp_pkt *fsp, 572 int (*fcp_cmd_send)(struct fc_lport *lp, struct fc_fcp_pkt *fsp,
532 void (*resp)(struct fc_seq *, struct fc_frame *fp, 573 void (*resp)(struct fc_seq *, struct fc_frame *fp,
533 void *arg)); 574 void *arg));
534 575
535 /* 576 /*
536 * Used at least durring linkdown and reset 577 * Cleanup the FCP layer, used durring link down and reset
578 *
579 * STATUS: OPTIONAL
537 */ 580 */
538 void (*fcp_cleanup)(struct fc_lport *lp); 581 void (*fcp_cleanup)(struct fc_lport *lp);
539 582
540 /* 583 /*
541 * Abort all I/O on a local port 584 * Abort all I/O on a local port
585 *
586 * STATUS: OPTIONAL
542 */ 587 */
543 void (*fcp_abort_io)(struct fc_lport *lp); 588 void (*fcp_abort_io)(struct fc_lport *lp);
544 589
545 /** 590 /*
546 * Discovery interfaces 591 * Receive a request for the discovery layer.
592 *
593 * STATUS: OPTIONAL
547 */ 594 */
548
549 void (*disc_recv_req)(struct fc_seq *, 595 void (*disc_recv_req)(struct fc_seq *,
550 struct fc_frame *, struct fc_lport *); 596 struct fc_frame *, struct fc_lport *);
551 597
552 /* 598 /*
553 * Start discovery for a local port. 599 * Start discovery for a local port.
600 *
601 * STATUS: OPTIONAL
554 */ 602 */
555 void (*disc_start)(void (*disc_callback)(struct fc_lport *, 603 void (*disc_start)(void (*disc_callback)(struct fc_lport *,
556 enum fc_disc_event), 604 enum fc_disc_event),
@@ -559,6 +607,8 @@ struct libfc_function_template {
559 /* 607 /*
560 * Stop discovery for a given lport. This will remove 608 * Stop discovery for a given lport. This will remove
561 * all discovered rports 609 * all discovered rports
610 *
611 * STATUS: OPTIONAL
562 */ 612 */
563 void (*disc_stop) (struct fc_lport *); 613 void (*disc_stop) (struct fc_lport *);
564 614
@@ -566,6 +616,8 @@ struct libfc_function_template {
566 * Stop discovery for a given lport. This will block 616 * Stop discovery for a given lport. This will block
567 * until all discovered rports are deleted from the 617 * until all discovered rports are deleted from the
568 * FC transport class 618 * FC transport class
619 *
620 * STATUS: OPTIONAL
569 */ 621 */
570 void (*disc_stop_final) (struct fc_lport *); 622 void (*disc_stop_final) (struct fc_lport *);
571}; 623};
@@ -603,7 +655,8 @@ struct fc_lport {
603 655
604 /* Operational Information */ 656 /* Operational Information */
605 struct libfc_function_template tt; 657 struct libfc_function_template tt;
606 u16 link_status; 658 u8 link_up;
659 u8 qfull;
607 enum fc_lport_state state; 660 enum fc_lport_state state;
608 unsigned long boot_time; 661 unsigned long boot_time;
609 662
@@ -626,6 +679,7 @@ struct fc_lport {
626 u16 link_speed; 679 u16 link_speed;
627 u16 link_supported_speeds; 680 u16 link_supported_speeds;
628 u16 lro_xid; /* max xid for fcoe lro */ 681 u16 lro_xid; /* max xid for fcoe lro */
682 unsigned int lso_max; /* max large send size */
629 struct fc_ns_fts fcts; /* FC-4 type masks */ 683 struct fc_ns_fts fcts; /* FC-4 type masks */
630 struct fc_els_rnid_gen rnid_gen; /* RNID information */ 684 struct fc_els_rnid_gen rnid_gen; /* RNID information */
631 685
@@ -637,7 +691,7 @@ struct fc_lport {
637 struct delayed_work disc_work; 691 struct delayed_work disc_work;
638}; 692};
639 693
640/** 694/*
641 * FC_LPORT HELPER FUNCTIONS 695 * FC_LPORT HELPER FUNCTIONS
642 *****************************/ 696 *****************************/
643static inline void *lport_priv(const struct fc_lport *lp) 697static inline void *lport_priv(const struct fc_lport *lp)
@@ -669,7 +723,7 @@ static inline void fc_lport_state_enter(struct fc_lport *lp,
669} 723}
670 724
671 725
672/** 726/*
673 * LOCAL PORT LAYER 727 * LOCAL PORT LAYER
674 *****************************/ 728 *****************************/
675int fc_lport_init(struct fc_lport *lp); 729int fc_lport_init(struct fc_lport *lp);
@@ -704,12 +758,6 @@ void fc_linkup(struct fc_lport *);
704void fc_linkdown(struct fc_lport *); 758void fc_linkdown(struct fc_lport *);
705 759
706/* 760/*
707 * Pause and unpause traffic.
708 */
709void fc_pause(struct fc_lport *);
710void fc_unpause(struct fc_lport *);
711
712/*
713 * Configure the local port. 761 * Configure the local port.
714 */ 762 */
715int fc_lport_config(struct fc_lport *); 763int fc_lport_config(struct fc_lport *);
@@ -725,19 +773,19 @@ int fc_lport_reset(struct fc_lport *);
725int fc_set_mfs(struct fc_lport *lp, u32 mfs); 773int fc_set_mfs(struct fc_lport *lp, u32 mfs);
726 774
727 775
728/** 776/*
729 * REMOTE PORT LAYER 777 * REMOTE PORT LAYER
730 *****************************/ 778 *****************************/
731int fc_rport_init(struct fc_lport *lp); 779int fc_rport_init(struct fc_lport *lp);
732void fc_rport_terminate_io(struct fc_rport *rp); 780void fc_rport_terminate_io(struct fc_rport *rp);
733 781
734/** 782/*
735 * DISCOVERY LAYER 783 * DISCOVERY LAYER
736 *****************************/ 784 *****************************/
737int fc_disc_init(struct fc_lport *lp); 785int fc_disc_init(struct fc_lport *lp);
738 786
739 787
740/** 788/*
741 * SCSI LAYER 789 * SCSI LAYER
742 *****************************/ 790 *****************************/
743/* 791/*
@@ -798,7 +846,12 @@ int fc_change_queue_type(struct scsi_device *sdev, int tag_type);
798 */ 846 */
799void fc_fcp_destroy(struct fc_lport *); 847void fc_fcp_destroy(struct fc_lport *);
800 848
801/** 849/*
850 * Set up direct-data placement for this I/O request
851 */
852void fc_fcp_ddp_setup(struct fc_fcp_pkt *fsp, u16 xid);
853
854/*
802 * ELS/CT interface 855 * ELS/CT interface
803 *****************************/ 856 *****************************/
804/* 857/*
@@ -807,7 +860,7 @@ void fc_fcp_destroy(struct fc_lport *);
807int fc_elsct_init(struct fc_lport *lp); 860int fc_elsct_init(struct fc_lport *lp);
808 861
809 862
810/** 863/*
811 * EXCHANGE MANAGER LAYER 864 * EXCHANGE MANAGER LAYER
812 *****************************/ 865 *****************************/
813/* 866/*
@@ -916,7 +969,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. 969 * 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. 970 * If d_id is non-zero, reset only exchanges sending to that FID.
918 */ 971 */
919void fc_exch_mgr_reset(struct fc_exch_mgr *, u32 s_id, u32 d_id); 972void fc_exch_mgr_reset(struct fc_lport *, u32 s_id, u32 d_id);
920 973
921/* 974/*
922 * Functions for fc_functions_template 975 * Functions for fc_functions_template