diff options
author | Joe Eykholt <jeykholt@cisco.com> | 2009-08-25 17:01:01 -0400 |
---|---|---|
committer | James Bottomley <James.Bottomley@suse.de> | 2009-09-10 13:07:42 -0400 |
commit | f211fa514a07326c0f9364c0e6ed17e38860172f (patch) | |
tree | 9c2c54fee556816f36211185b6d6df0812b9acec /include | |
parent | a46f327aa5caf2cce138e98ddd863b6cca0e71e2 (diff) |
[SCSI] libfc: make rport structure optional
Allow a struct fc_rport_priv to have no fc_rport associated with it.
This sets up to remove the need for "rogue" rports.
Add a few fields to fc_rport_priv that are needed before the fc_rport
is created. These are the ids, maxframe_size, classes, and rport pointer.
Remove the macro PRIV_TO_RPORT(). Just use rdata->rport where appropriate.
To take the place of the get_device()/put_device ops that were used to
hold both the rport and rdata, add a reference count to rdata structures
using kref. When kref_get decrements the refcount to zero, a new template
function releasing the rdata should be called. This will take care of
freeing the rdata and releasing the hold on the rport (for now). After
subsequent patches make the rport truly optional, this release function
will simply free the rdata.
Remove the simple inline function fc_rport_set_name(), which becomes
semanticly ambiguous otherwise. The caller will set the port_name and
node_name in the rdata->Ids, which will later be copied to the rport
when it its created.
Signed-off-by: Joe Eykholt <jeykholt@cisco.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Diffstat (limited to 'include')
-rw-r--r-- | include/scsi/libfc.h | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h index 2473167464c2..a94d216d2207 100644 --- a/include/scsi/libfc.h +++ b/include/scsi/libfc.h | |||
@@ -76,11 +76,7 @@ do { \ | |||
76 | (port_id), ##args)) | 76 | (port_id), ##args)) |
77 | 77 | ||
78 | #define FC_RPORT_DBG(rdata, fmt, args...) \ | 78 | #define FC_RPORT_DBG(rdata, fmt, args...) \ |
79 | do { \ | 79 | FC_RPORT_ID_DBG((rdata)->local_port, (rdata)->ids.port_id, fmt, ##args) |
80 | struct fc_lport *lport = rdata->local_port; \ | ||
81 | struct fc_rport *rport = PRIV_TO_RPORT(rdata); \ | ||
82 | FC_RPORT_ID_DBG(lport, rport->port_id, fmt, ##args); \ | ||
83 | } while (0) | ||
84 | 80 | ||
85 | #define FC_FCP_DBG(pkt, fmt, args...) \ | 81 | #define FC_FCP_DBG(pkt, fmt, args...) \ |
86 | FC_CHECK_LOGGING(FC_FCP_LOGGING, \ | 82 | FC_CHECK_LOGGING(FC_FCP_LOGGING, \ |
@@ -195,9 +191,13 @@ struct fc_rport_operations { | |||
195 | /** | 191 | /** |
196 | * struct fc_rport_libfc_priv - libfc internal information about a remote port | 192 | * struct fc_rport_libfc_priv - libfc internal information about a remote port |
197 | * @local_port: Fibre Channel host port instance | 193 | * @local_port: Fibre Channel host port instance |
194 | * @rport: transport remote port | ||
195 | * @kref: reference counter | ||
198 | * @rp_state: state tracks progress of PLOGI, PRLI, and RTV exchanges | 196 | * @rp_state: state tracks progress of PLOGI, PRLI, and RTV exchanges |
197 | * @ids: remote port identifiers and roles | ||
199 | * @flags: REC and RETRY supported flags | 198 | * @flags: REC and RETRY supported flags |
200 | * @max_seq: maximum number of concurrent sequences | 199 | * @max_seq: maximum number of concurrent sequences |
200 | * @maxframe_size: maximum frame size | ||
201 | * @retries: retry count in current state | 201 | * @retries: retry count in current state |
202 | * @e_d_tov: error detect timeout value (in msec) | 202 | * @e_d_tov: error detect timeout value (in msec) |
203 | * @r_a_tov: resource allocation timeout value (in msec) | 203 | * @r_a_tov: resource allocation timeout value (in msec) |
@@ -207,11 +207,15 @@ struct fc_rport_operations { | |||
207 | */ | 207 | */ |
208 | struct fc_rport_libfc_priv { | 208 | struct fc_rport_libfc_priv { |
209 | struct fc_lport *local_port; | 209 | struct fc_lport *local_port; |
210 | struct fc_rport *rport; | ||
211 | struct kref kref; | ||
210 | enum fc_rport_state rp_state; | 212 | enum fc_rport_state rp_state; |
213 | struct fc_rport_identifiers ids; | ||
211 | u16 flags; | 214 | u16 flags; |
212 | #define FC_RP_FLAGS_REC_SUPPORTED (1 << 0) | 215 | #define FC_RP_FLAGS_REC_SUPPORTED (1 << 0) |
213 | #define FC_RP_FLAGS_RETRY (1 << 1) | 216 | #define FC_RP_FLAGS_RETRY (1 << 1) |
214 | u16 max_seq; | 217 | u16 max_seq; |
218 | u16 maxframe_size; | ||
215 | unsigned int retries; | 219 | unsigned int retries; |
216 | unsigned int e_d_tov; | 220 | unsigned int e_d_tov; |
217 | unsigned int r_a_tov; | 221 | unsigned int r_a_tov; |
@@ -222,19 +226,12 @@ struct fc_rport_libfc_priv { | |||
222 | struct fc_rport_operations *ops; | 226 | struct fc_rport_operations *ops; |
223 | struct list_head peers; | 227 | struct list_head peers; |
224 | struct work_struct event_work; | 228 | struct work_struct event_work; |
229 | u32 supported_classes; | ||
225 | }; | 230 | }; |
226 | 231 | ||
227 | #define PRIV_TO_RPORT(x) \ | ||
228 | ((struct fc_rport *)((void *)(x) - sizeof(struct fc_rport))) | ||
229 | #define RPORT_TO_PRIV(x) \ | 232 | #define RPORT_TO_PRIV(x) \ |
230 | ((struct fc_rport_libfc_priv *)((void *)(x) + sizeof(struct fc_rport))) | 233 | ((struct fc_rport_libfc_priv *)((void *)(x) + sizeof(struct fc_rport))) |
231 | 234 | ||
232 | static inline void fc_rport_set_name(struct fc_rport *rport, u64 wwpn, u64 wwnn) | ||
233 | { | ||
234 | rport->node_name = wwnn; | ||
235 | rport->port_name = wwpn; | ||
236 | } | ||
237 | |||
238 | /* | 235 | /* |
239 | * fcoe stats structure | 236 | * fcoe stats structure |
240 | */ | 237 | */ |
@@ -609,6 +606,12 @@ struct libfc_function_template { | |||
609 | struct fc_rport_priv *(*rport_lookup)(const struct fc_lport *, u32); | 606 | struct fc_rport_priv *(*rport_lookup)(const struct fc_lport *, u32); |
610 | 607 | ||
611 | /* | 608 | /* |
609 | * Destroy an rport after final kref_put(). | ||
610 | * The argument is a pointer to the kref inside the fc_rport_priv. | ||
611 | */ | ||
612 | void (*rport_destroy)(struct kref *); | ||
613 | |||
614 | /* | ||
612 | * Send a fcp cmd from fsp pkt. | 615 | * Send a fcp cmd from fsp pkt. |
613 | * Called with the SCSI host lock unlocked and irqs disabled. | 616 | * Called with the SCSI host lock unlocked and irqs disabled. |
614 | * | 617 | * |