aboutsummaryrefslogtreecommitdiffstats
path: root/include/scsi/libfcoe.h
diff options
context:
space:
mode:
authorRobert Love <robert.w.love@intel.com>2013-09-05 03:47:27 -0400
committerRobert Love <robert.w.love@intel.com>2013-10-11 16:25:40 -0400
commit9d34876f820d55c94bd0b2a2ed3d2e2976cbd997 (patch)
treeee7dd415c30b57215841214959d00c0470787e51 /include/scsi/libfcoe.h
parent1c2c1b4fbd413fd814807768d2aba9023722ed76 (diff)
libfcoe: Make fcoe_sysfs optional / fix fnic NULL exception
fnic doesn't use any of the create/destroy/enable/disable interfaces either from the (legacy) module paramaters or the (new) fcoe_sysfs interfaces. When fcoe_sysfs was introduced fnic wasn't changed since it wasn't using the interfaces. libfcoe incorrectly assumed that that all of its users were using fcoe_sysfs and when adding and deleting FCFs would assume the existance of a fcoe_ctlr_device. fnic was not allocating this structure because it doesn't care about the standard user interfaces (fnic starts on link only). If/When libfcoe tried to use the fcoe_ctlr_device's lock for the first time a NULL pointer exception would be triggered. Since fnic doesn't care about sysfs or user interfaces, the solution is to drop libfcoe's assumption that all drivers are using fcoe_sysfs. This patch accomplishes this by changing some of the structure relationships. We need a way to determine when a LLD is using fcoe_sysfs or not and we can do that by checking for the existance of the fcoe_ctlr_device. Prior to this patch, it was assumed that the fcoe_ctlr structure was allocated with the fcoe_ctlr_device and immediately followed it in memory. To reach the fcoe_ctlr_device we would simply go back in memory from the fcoe_ctlr to get the fcoe_ctlr_device. Since fnic doesn't allocate the fcoe_ctlr_device, we cannot keep that assumption. This patch adds a pointer from the fcoe_ctlr to the fcoe_ctlr_device. For bnx2fc and fcoe we will continue to allocate the two structures together, but then we'll set the ctlr->cdev pointer to point at the fcoe_ctlr_device. fnic will not change and will continue to allocate the fcoe_ctlr itself, and ctlr->cdev will remain NULL. When libfcoe adds fcoe_fcf's to the fcoe_ctlr it will check if ctlr->cdev is set and only if so will it continue to interact with fcoe_sysfs. Signed-off-by: Robert Love <robert.w.love@intel.com> Acked-by: Neil Horman <nhorman@tuxdriver.com> Tested-by: Hiral Patel <hiralpat@cisco.com>
Diffstat (limited to 'include/scsi/libfcoe.h')
-rw-r--r--include/scsi/libfcoe.h7
1 files changed, 6 insertions, 1 deletions
diff --git a/include/scsi/libfcoe.h b/include/scsi/libfcoe.h
index 4427393115ea..de7e3ee60f0c 100644
--- a/include/scsi/libfcoe.h
+++ b/include/scsi/libfcoe.h
@@ -90,6 +90,7 @@ enum fip_state {
90 * @lp: &fc_lport: libfc local port. 90 * @lp: &fc_lport: libfc local port.
91 * @sel_fcf: currently selected FCF, or NULL. 91 * @sel_fcf: currently selected FCF, or NULL.
92 * @fcfs: list of discovered FCFs. 92 * @fcfs: list of discovered FCFs.
93 * @cdev: (Optional) pointer to sysfs fcoe_ctlr_device.
93 * @fcf_count: number of discovered FCF entries. 94 * @fcf_count: number of discovered FCF entries.
94 * @sol_time: time when a multicast solicitation was last sent. 95 * @sol_time: time when a multicast solicitation was last sent.
95 * @sel_time: time after which to select an FCF. 96 * @sel_time: time after which to select an FCF.
@@ -127,6 +128,7 @@ struct fcoe_ctlr {
127 struct fc_lport *lp; 128 struct fc_lport *lp;
128 struct fcoe_fcf *sel_fcf; 129 struct fcoe_fcf *sel_fcf;
129 struct list_head fcfs; 130 struct list_head fcfs;
131 struct fcoe_ctlr_device *cdev;
130 u16 fcf_count; 132 u16 fcf_count;
131 unsigned long sol_time; 133 unsigned long sol_time;
132 unsigned long sel_time; 134 unsigned long sel_time;
@@ -168,8 +170,11 @@ static inline void *fcoe_ctlr_priv(const struct fcoe_ctlr *ctlr)
168 return (void *)(ctlr + 1); 170 return (void *)(ctlr + 1);
169} 171}
170 172
173/*
174 * This assumes that the fcoe_ctlr (x) is allocated with the fcoe_ctlr_device.
175 */
171#define fcoe_ctlr_to_ctlr_dev(x) \ 176#define fcoe_ctlr_to_ctlr_dev(x) \
172 (struct fcoe_ctlr_device *)(((struct fcoe_ctlr_device *)(x)) - 1) 177 (x)->cdev
173 178
174/** 179/**
175 * struct fcoe_fcf - Fibre-Channel Forwarder 180 * struct fcoe_fcf - Fibre-Channel Forwarder