diff options
Diffstat (limited to 'include/scsi/libfc.h')
| -rw-r--r-- | include/scsi/libfc.h | 82 |
1 files changed, 41 insertions, 41 deletions
diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h index 4b912eee33e5..14be49b44e84 100644 --- a/include/scsi/libfc.h +++ b/include/scsi/libfc.h | |||
| @@ -42,19 +42,6 @@ | |||
| 42 | #define FC_EX_TIMEOUT 1 /* Exchange timeout */ | 42 | #define FC_EX_TIMEOUT 1 /* Exchange timeout */ |
| 43 | #define FC_EX_CLOSED 2 /* Exchange closed */ | 43 | #define FC_EX_CLOSED 2 /* Exchange closed */ |
| 44 | 44 | ||
| 45 | /* some helpful macros */ | ||
| 46 | |||
| 47 | #define ntohll(x) be64_to_cpu(x) | ||
| 48 | #define htonll(x) cpu_to_be64(x) | ||
| 49 | |||
| 50 | #define ntoh24(p) (((p)[0] << 16) | ((p)[1] << 8) | ((p)[2])) | ||
| 51 | |||
| 52 | #define hton24(p, v) do { \ | ||
| 53 | p[0] = (((v) >> 16) & 0xFF); \ | ||
| 54 | p[1] = (((v) >> 8) & 0xFF); \ | ||
| 55 | p[2] = ((v) & 0xFF); \ | ||
| 56 | } while (0) | ||
| 57 | |||
| 58 | /** | 45 | /** |
| 59 | * enum fc_lport_state - Local port states | 46 | * enum fc_lport_state - Local port states |
| 60 | * @LPORT_ST_DISABLED: Disabled | 47 | * @LPORT_ST_DISABLED: Disabled |
| @@ -92,25 +79,25 @@ enum fc_disc_event { | |||
| 92 | /** | 79 | /** |
| 93 | * enum fc_rport_state - Remote port states | 80 | * enum fc_rport_state - Remote port states |
| 94 | * @RPORT_ST_INIT: Initialized | 81 | * @RPORT_ST_INIT: Initialized |
| 82 | * @RPORT_ST_FLOGI: Waiting for FLOGI completion for point-to-multipoint | ||
| 83 | * @RPORT_ST_PLOGI_WAIT: Waiting for peer to login for point-to-multipoint | ||
| 95 | * @RPORT_ST_PLOGI: Waiting for PLOGI completion | 84 | * @RPORT_ST_PLOGI: Waiting for PLOGI completion |
| 96 | * @RPORT_ST_PRLI: Waiting for PRLI completion | 85 | * @RPORT_ST_PRLI: Waiting for PRLI completion |
| 97 | * @RPORT_ST_RTV: Waiting for RTV completion | 86 | * @RPORT_ST_RTV: Waiting for RTV completion |
| 98 | * @RPORT_ST_READY: Ready for use | 87 | * @RPORT_ST_READY: Ready for use |
| 99 | * @RPORT_ST_LOGO: Remote port logout (LOGO) sent | ||
| 100 | * @RPORT_ST_ADISC: Discover Address sent | 88 | * @RPORT_ST_ADISC: Discover Address sent |
| 101 | * @RPORT_ST_DELETE: Remote port being deleted | 89 | * @RPORT_ST_DELETE: Remote port being deleted |
| 102 | * @RPORT_ST_RESTART: Remote port being deleted and will restart | ||
| 103 | */ | 90 | */ |
| 104 | enum fc_rport_state { | 91 | enum fc_rport_state { |
| 105 | RPORT_ST_INIT, | 92 | RPORT_ST_INIT, |
| 93 | RPORT_ST_FLOGI, | ||
| 94 | RPORT_ST_PLOGI_WAIT, | ||
| 106 | RPORT_ST_PLOGI, | 95 | RPORT_ST_PLOGI, |
| 107 | RPORT_ST_PRLI, | 96 | RPORT_ST_PRLI, |
| 108 | RPORT_ST_RTV, | 97 | RPORT_ST_RTV, |
| 109 | RPORT_ST_READY, | 98 | RPORT_ST_READY, |
| 110 | RPORT_ST_LOGO, | ||
| 111 | RPORT_ST_ADISC, | 99 | RPORT_ST_ADISC, |
| 112 | RPORT_ST_DELETE, | 100 | RPORT_ST_DELETE, |
| 113 | RPORT_ST_RESTART, | ||
| 114 | }; | 101 | }; |
| 115 | 102 | ||
| 116 | /** | 103 | /** |
| @@ -168,6 +155,7 @@ struct fc_rport_libfc_priv { | |||
| 168 | u16 flags; | 155 | u16 flags; |
| 169 | #define FC_RP_FLAGS_REC_SUPPORTED (1 << 0) | 156 | #define FC_RP_FLAGS_REC_SUPPORTED (1 << 0) |
| 170 | #define FC_RP_FLAGS_RETRY (1 << 1) | 157 | #define FC_RP_FLAGS_RETRY (1 << 1) |
| 158 | #define FC_RP_STARTED (1 << 2) | ||
| 171 | unsigned int e_d_tov; | 159 | unsigned int e_d_tov; |
| 172 | unsigned int r_a_tov; | 160 | unsigned int r_a_tov; |
| 173 | }; | 161 | }; |
| @@ -180,16 +168,18 @@ struct fc_rport_libfc_priv { | |||
| 180 | * @rp_state: Enumeration that tracks progress of PLOGI, PRLI, | 168 | * @rp_state: Enumeration that tracks progress of PLOGI, PRLI, |
| 181 | * and RTV exchanges | 169 | * and RTV exchanges |
| 182 | * @ids: The remote port identifiers and roles | 170 | * @ids: The remote port identifiers and roles |
| 183 | * @flags: REC and RETRY supported flags | 171 | * @flags: STARTED, REC and RETRY_SUPPORTED flags |
| 184 | * @max_seq: Maximum number of concurrent sequences | 172 | * @max_seq: Maximum number of concurrent sequences |
| 185 | * @disc_id: The discovery identifier | 173 | * @disc_id: The discovery identifier |
| 186 | * @maxframe_size: The maximum frame size | 174 | * @maxframe_size: The maximum frame size |
| 187 | * @retries: The retry count for the current state | 175 | * @retries: The retry count for the current state |
| 176 | * @major_retries: The retry count for the entire PLOGI/PRLI state machine | ||
| 188 | * @e_d_tov: Error detect timeout value (in msec) | 177 | * @e_d_tov: Error detect timeout value (in msec) |
| 189 | * @r_a_tov: Resource allocation timeout value (in msec) | 178 | * @r_a_tov: Resource allocation timeout value (in msec) |
| 190 | * @rp_mutex: The mutex that protects the remote port | 179 | * @rp_mutex: The mutex that protects the remote port |
| 191 | * @retry_work: Handle for retries | 180 | * @retry_work: Handle for retries |
| 192 | * @event_callback: Callback when READY, FAILED or LOGO states complete | 181 | * @event_callback: Callback when READY, FAILED or LOGO states complete |
| 182 | * @rcu: Structure used for freeing in an RCU-safe manner | ||
| 193 | */ | 183 | */ |
| 194 | struct fc_rport_priv { | 184 | struct fc_rport_priv { |
| 195 | struct fc_lport *local_port; | 185 | struct fc_lport *local_port; |
| @@ -202,6 +192,7 @@ struct fc_rport_priv { | |||
| 202 | u16 disc_id; | 192 | u16 disc_id; |
| 203 | u16 maxframe_size; | 193 | u16 maxframe_size; |
| 204 | unsigned int retries; | 194 | unsigned int retries; |
| 195 | unsigned int major_retries; | ||
| 205 | unsigned int e_d_tov; | 196 | unsigned int e_d_tov; |
| 206 | unsigned int r_a_tov; | 197 | unsigned int r_a_tov; |
| 207 | struct mutex rp_mutex; | 198 | struct mutex rp_mutex; |
| @@ -211,6 +202,7 @@ struct fc_rport_priv { | |||
| 211 | struct list_head peers; | 202 | struct list_head peers; |
| 212 | struct work_struct event_work; | 203 | struct work_struct event_work; |
| 213 | u32 supported_classes; | 204 | u32 supported_classes; |
| 205 | struct rcu_head rcu; | ||
| 214 | }; | 206 | }; |
| 215 | 207 | ||
| 216 | /** | 208 | /** |
| @@ -257,14 +249,12 @@ struct fcoe_dev_stats { | |||
| 257 | 249 | ||
| 258 | /** | 250 | /** |
| 259 | * struct fc_seq_els_data - ELS data used for passing ELS specific responses | 251 | * struct fc_seq_els_data - ELS data used for passing ELS specific responses |
| 260 | * @fp: The ELS frame | ||
| 261 | * @reason: The reason for rejection | 252 | * @reason: The reason for rejection |
| 262 | * @explan: The explaination of the rejection | 253 | * @explan: The explaination of the rejection |
| 263 | * | 254 | * |
| 264 | * Mainly used by the exchange manager layer. | 255 | * Mainly used by the exchange manager layer. |
| 265 | */ | 256 | */ |
| 266 | struct fc_seq_els_data { | 257 | struct fc_seq_els_data { |
| 267 | struct fc_frame *fp; | ||
| 268 | enum fc_els_rjt_reason reason; | 258 | enum fc_els_rjt_reason reason; |
| 269 | enum fc_els_rjt_explan explan; | 259 | enum fc_els_rjt_explan explan; |
| 270 | }; | 260 | }; |
| @@ -400,6 +390,7 @@ struct fc_seq { | |||
| 400 | * @esb_stat: ESB exchange status | 390 | * @esb_stat: ESB exchange status |
| 401 | * @r_a_tov: Resouce allocation time out value (in msecs) | 391 | * @r_a_tov: Resouce allocation time out value (in msecs) |
| 402 | * @seq_id: The next sequence ID to use | 392 | * @seq_id: The next sequence ID to use |
| 393 | * @encaps: encapsulation information for lower-level driver | ||
| 403 | * @f_ctl: F_CTL flags for the sequence | 394 | * @f_ctl: F_CTL flags for the sequence |
| 404 | * @fh_type: The frame type | 395 | * @fh_type: The frame type |
| 405 | * @class: The class of service | 396 | * @class: The class of service |
| @@ -431,6 +422,7 @@ struct fc_exch { | |||
| 431 | u32 esb_stat; | 422 | u32 esb_stat; |
| 432 | u32 r_a_tov; | 423 | u32 r_a_tov; |
| 433 | u8 seq_id; | 424 | u8 seq_id; |
| 425 | u8 encaps; | ||
| 434 | u32 f_ctl; | 426 | u32 f_ctl; |
| 435 | u8 fh_type; | 427 | u8 fh_type; |
| 436 | enum fc_class class; | 428 | enum fc_class class; |
| @@ -525,12 +517,11 @@ struct libfc_function_template { | |||
| 525 | struct fc_frame *); | 517 | struct fc_frame *); |
| 526 | 518 | ||
| 527 | /* | 519 | /* |
| 528 | * Send an ELS response using infomation from a previous | 520 | * Send an ELS response using infomation from the received frame. |
| 529 | * exchange and sequence. | ||
| 530 | * | 521 | * |
| 531 | * STATUS: OPTIONAL | 522 | * STATUS: OPTIONAL |
| 532 | */ | 523 | */ |
| 533 | void (*seq_els_rsp_send)(struct fc_seq *, enum fc_els_cmd, | 524 | void (*seq_els_rsp_send)(struct fc_frame *, enum fc_els_cmd, |
| 534 | struct fc_seq_els_data *); | 525 | struct fc_seq_els_data *); |
| 535 | 526 | ||
| 536 | /* | 527 | /* |
| @@ -562,6 +553,13 @@ struct libfc_function_template { | |||
| 562 | struct fc_seq *(*seq_start_next)(struct fc_seq *); | 553 | struct fc_seq *(*seq_start_next)(struct fc_seq *); |
| 563 | 554 | ||
| 564 | /* | 555 | /* |
| 556 | * Assign a sequence for an incoming request frame. | ||
| 557 | * | ||
| 558 | * STATUS: OPTIONAL | ||
| 559 | */ | ||
| 560 | struct fc_seq *(*seq_assign)(struct fc_lport *, struct fc_frame *); | ||
| 561 | |||
| 562 | /* | ||
| 565 | * Reset an exchange manager, completing all sequences and exchanges. | 563 | * Reset an exchange manager, completing all sequences and exchanges. |
| 566 | * If s_id is non-zero, reset only exchanges originating from that FID. | 564 | * If s_id is non-zero, reset only exchanges originating from that FID. |
| 567 | * If d_id is non-zero, reset only exchanges sending to that FID. | 565 | * If d_id is non-zero, reset only exchanges sending to that FID. |
| @@ -582,8 +580,7 @@ struct libfc_function_template { | |||
| 582 | * | 580 | * |
| 583 | * STATUS: OPTIONAL | 581 | * STATUS: OPTIONAL |
| 584 | */ | 582 | */ |
| 585 | void (*lport_recv)(struct fc_lport *, struct fc_seq *, | 583 | void (*lport_recv)(struct fc_lport *, struct fc_frame *); |
| 586 | struct fc_frame *); | ||
| 587 | 584 | ||
| 588 | /* | 585 | /* |
| 589 | * Reset the local port. | 586 | * Reset the local port. |
| @@ -645,8 +642,7 @@ struct libfc_function_template { | |||
| 645 | * | 642 | * |
| 646 | * STATUS: OPTIONAL | 643 | * STATUS: OPTIONAL |
| 647 | */ | 644 | */ |
| 648 | void (*rport_recv_req)(struct fc_seq *, struct fc_frame *, | 645 | void (*rport_recv_req)(struct fc_lport *, struct fc_frame *); |
| 649 | struct fc_lport *); | ||
| 650 | 646 | ||
| 651 | /* | 647 | /* |
| 652 | * lookup an rport by it's port ID. | 648 | * lookup an rport by it's port ID. |
| @@ -692,8 +688,7 @@ struct libfc_function_template { | |||
| 692 | * | 688 | * |
| 693 | * STATUS: OPTIONAL | 689 | * STATUS: OPTIONAL |
| 694 | */ | 690 | */ |
| 695 | void (*disc_recv_req)(struct fc_seq *, struct fc_frame *, | 691 | void (*disc_recv_req)(struct fc_lport *, struct fc_frame *); |
| 696 | struct fc_lport *); | ||
| 697 | 692 | ||
| 698 | /* | 693 | /* |
| 699 | * Start discovery for a local port. | 694 | * Start discovery for a local port. |
| @@ -731,7 +726,7 @@ struct libfc_function_template { | |||
| 731 | * @buf_len: Length of the discovery buffer | 726 | * @buf_len: Length of the discovery buffer |
| 732 | * @disc_id: Discovery ID | 727 | * @disc_id: Discovery ID |
| 733 | * @rports: List of discovered remote ports | 728 | * @rports: List of discovered remote ports |
| 734 | * @lport: The local port that discovery is for | 729 | * @priv: Private pointer for use by discovery code |
| 735 | * @disc_mutex: Mutex that protects the discovery context | 730 | * @disc_mutex: Mutex that protects the discovery context |
| 736 | * @partial_buf: Partial name buffer (if names are returned | 731 | * @partial_buf: Partial name buffer (if names are returned |
| 737 | * in multiple frames) | 732 | * in multiple frames) |
| @@ -747,7 +742,7 @@ struct fc_disc { | |||
| 747 | u16 disc_id; | 742 | u16 disc_id; |
| 748 | 743 | ||
| 749 | struct list_head rports; | 744 | struct list_head rports; |
| 750 | struct fc_lport *lport; | 745 | void *priv; |
| 751 | struct mutex disc_mutex; | 746 | struct mutex disc_mutex; |
| 752 | struct fc_gpn_ft_resp partial_buf; | 747 | struct fc_gpn_ft_resp partial_buf; |
| 753 | struct delayed_work disc_work; | 748 | struct delayed_work disc_work; |
| @@ -775,6 +770,7 @@ struct fc_disc { | |||
| 775 | * @dev_stats: FCoE device stats (TODO: libfc should not be | 770 | * @dev_stats: FCoE device stats (TODO: libfc should not be |
| 776 | * FCoE aware) | 771 | * FCoE aware) |
| 777 | * @retry_count: Number of retries in the current state | 772 | * @retry_count: Number of retries in the current state |
| 773 | * @port_id: FC Port ID | ||
| 778 | * @wwpn: World Wide Port Name | 774 | * @wwpn: World Wide Port Name |
| 779 | * @wwnn: World Wide Node Name | 775 | * @wwnn: World Wide Node Name |
| 780 | * @service_params: Common service parameters | 776 | * @service_params: Common service parameters |
| @@ -790,6 +786,7 @@ struct fc_disc { | |||
| 790 | * @mfs: The maximum Fibre Channel payload size | 786 | * @mfs: The maximum Fibre Channel payload size |
| 791 | * @max_retry_count: The maximum retry attempts | 787 | * @max_retry_count: The maximum retry attempts |
| 792 | * @max_rport_retry_count: The maximum remote port retry attempts | 788 | * @max_rport_retry_count: The maximum remote port retry attempts |
| 789 | * @rport_priv_size: Size needed by driver after struct fc_rport_priv | ||
| 793 | * @lro_xid: The maximum XID for LRO | 790 | * @lro_xid: The maximum XID for LRO |
| 794 | * @lso_max: The maximum large offload send size | 791 | * @lso_max: The maximum large offload send size |
| 795 | * @fcts: FC-4 type mask | 792 | * @fcts: FC-4 type mask |
| @@ -821,6 +818,7 @@ struct fc_lport { | |||
| 821 | u8 retry_count; | 818 | u8 retry_count; |
| 822 | 819 | ||
| 823 | /* Fabric information */ | 820 | /* Fabric information */ |
| 821 | u32 port_id; | ||
| 824 | u64 wwpn; | 822 | u64 wwpn; |
| 825 | u64 wwnn; | 823 | u64 wwnn; |
| 826 | unsigned int service_params; | 824 | unsigned int service_params; |
| @@ -835,9 +833,11 @@ struct fc_lport { | |||
| 835 | u32 lro_enabled:1; | 833 | u32 lro_enabled:1; |
| 836 | u32 does_npiv:1; | 834 | u32 does_npiv:1; |
| 837 | u32 npiv_enabled:1; | 835 | u32 npiv_enabled:1; |
| 836 | u32 point_to_multipoint:1; | ||
| 838 | u32 mfs; | 837 | u32 mfs; |
| 839 | u8 max_retry_count; | 838 | u8 max_retry_count; |
| 840 | u8 max_rport_retry_count; | 839 | u8 max_rport_retry_count; |
| 840 | u16 rport_priv_size; | ||
| 841 | u16 link_speed; | 841 | u16 link_speed; |
| 842 | u16 link_supported_speeds; | 842 | u16 link_supported_speeds; |
| 843 | u16 lro_xid; | 843 | u16 lro_xid; |
| @@ -918,15 +918,6 @@ static inline void fc_lport_free_stats(struct fc_lport *lport) | |||
| 918 | } | 918 | } |
| 919 | 919 | ||
| 920 | /** | 920 | /** |
| 921 | * fc_lport_get_stats() - Get a local port's statistics | ||
| 922 | * @lport: The local port whose statistics are to be retreived | ||
| 923 | */ | ||
| 924 | static inline struct fcoe_dev_stats *fc_lport_get_stats(struct fc_lport *lport) | ||
| 925 | { | ||
| 926 | return per_cpu_ptr(lport->dev_stats, smp_processor_id()); | ||
| 927 | } | ||
| 928 | |||
| 929 | /** | ||
| 930 | * lport_priv() - Return the private data from a local port | 921 | * lport_priv() - Return the private data from a local port |
| 931 | * @lport: The local port whose private data is to be retreived | 922 | * @lport: The local port whose private data is to be retreived |
| 932 | */ | 923 | */ |
| @@ -988,6 +979,7 @@ int fc_set_mfs(struct fc_lport *, u32 mfs); | |||
| 988 | struct fc_lport *libfc_vport_create(struct fc_vport *, int privsize); | 979 | struct fc_lport *libfc_vport_create(struct fc_vport *, int privsize); |
| 989 | struct fc_lport *fc_vport_id_lookup(struct fc_lport *, u32 port_id); | 980 | struct fc_lport *fc_vport_id_lookup(struct fc_lport *, u32 port_id); |
| 990 | int fc_lport_bsg_request(struct fc_bsg_job *); | 981 | int fc_lport_bsg_request(struct fc_bsg_job *); |
| 982 | void fc_lport_set_local_id(struct fc_lport *, u32 port_id); | ||
| 991 | 983 | ||
| 992 | /* | 984 | /* |
| 993 | * REMOTE PORT LAYER | 985 | * REMOTE PORT LAYER |
| @@ -1000,6 +992,11 @@ void fc_rport_terminate_io(struct fc_rport *); | |||
| 1000 | *****************************/ | 992 | *****************************/ |
| 1001 | int fc_disc_init(struct fc_lport *); | 993 | int fc_disc_init(struct fc_lport *); |
| 1002 | 994 | ||
| 995 | static inline struct fc_lport *fc_disc_lport(struct fc_disc *disc) | ||
| 996 | { | ||
| 997 | return container_of(disc, struct fc_lport, disc); | ||
| 998 | } | ||
| 999 | |||
| 1003 | /* | 1000 | /* |
| 1004 | * FCP LAYER | 1001 | * FCP LAYER |
| 1005 | *****************************/ | 1002 | *****************************/ |
| @@ -1031,6 +1028,10 @@ struct fc_seq *fc_elsct_send(struct fc_lport *, u32 did, | |||
| 1031 | void *arg, u32 timer_msec); | 1028 | void *arg, u32 timer_msec); |
| 1032 | void fc_lport_flogi_resp(struct fc_seq *, struct fc_frame *, void *); | 1029 | void fc_lport_flogi_resp(struct fc_seq *, struct fc_frame *, void *); |
| 1033 | void fc_lport_logo_resp(struct fc_seq *, struct fc_frame *, void *); | 1030 | void fc_lport_logo_resp(struct fc_seq *, struct fc_frame *, void *); |
| 1031 | void fc_fill_reply_hdr(struct fc_frame *, const struct fc_frame *, | ||
| 1032 | enum fc_rctl, u32 parm_offset); | ||
| 1033 | void fc_fill_hdr(struct fc_frame *, const struct fc_frame *, | ||
| 1034 | enum fc_rctl, u32 f_ctl, u16 seq_cnt, u32 parm_offset); | ||
| 1034 | 1035 | ||
| 1035 | 1036 | ||
| 1036 | /* | 1037 | /* |
| @@ -1053,7 +1054,6 @@ void fc_exch_mgr_reset(struct fc_lport *, u32 s_id, u32 d_id); | |||
| 1053 | * Functions for fc_functions_template | 1054 | * Functions for fc_functions_template |
| 1054 | */ | 1055 | */ |
| 1055 | void fc_get_host_speed(struct Scsi_Host *); | 1056 | void fc_get_host_speed(struct Scsi_Host *); |
| 1056 | void fc_get_host_port_type(struct Scsi_Host *); | ||
| 1057 | void fc_get_host_port_state(struct Scsi_Host *); | 1057 | void fc_get_host_port_state(struct Scsi_Host *); |
| 1058 | void fc_set_rport_loss_tmo(struct fc_rport *, u32 timeout); | 1058 | void fc_set_rport_loss_tmo(struct fc_rport *, u32 timeout); |
| 1059 | struct fc_host_statistics *fc_get_host_stats(struct Scsi_Host *); | 1059 | struct fc_host_statistics *fc_get_host_stats(struct Scsi_Host *); |
