diff options
author | Robert Love <robert.w.love@intel.com> | 2012-05-22 22:06:21 -0400 |
---|---|---|
committer | James Bottomley <JBottomley@Parallels.com> | 2012-05-23 04:40:09 -0400 |
commit | 9a74e884ee71dbf3d0967b0321d7b4529a04826c (patch) | |
tree | 29cf0211927a3e54908f2dffa9ebde18794d6ed6 /include/scsi/fcoe_sysfs.h | |
parent | fd8f89027d816cb023edf6bfd4c744f194150a05 (diff) |
[SCSI] libfcoe: Add fcoe_sysfs
This patch adds a 'fcoe bus' infrastructure to the kernel
that is driven by changes to libfcoe which allow LLDs to
present FIP (FCoE Initialization Protocol) discovered
entities and their attributes to user space via sysfs.
This patch adds the following APIs-
fcoe_ctlr_device_add
fcoe_ctlr_device_delete
fcoe_fcf_device_add
fcoe_fcf_device_delete
They allow the LLD to expose the FCoE ENode Controller
and any discovered FCFs (Fibre Channel Forwarders, e.g.
FCoE switches) to the user. Each of these new devices
has their own bus_type so that they are grouped together
for easy lookup from a user space application. Each
new class has an attribute_group to expose attributes
for any created instances. The attributes are-
fcoe_ctlr_device
* fcf_dev_loss_tmo
* lesb_link_fail
* lesb_vlink_fail
* lesb_miss_fka
* lesb_symb_err
* lesb_err_block
* lesb_fcs_error
fcoe_fcf_device
* fabric_name
* switch_name
* priority
* selected
* fc_map
* vfid
* mac
* fka_peroid
* fabric_state
* dev_loss_tmo
A device loss infrastructre similar to the FC Transport's
is also added by this patch. It is nice to have so that a
link flapping adapter doesn't continually advance the count
used to identify the discovered FCF. FCFs will exist in a
"Disconnected" state until either the timer expires or the
FCF is rediscovered and becomes "Connected."
This patch generates a few checkpatch.pl WARNINGS that
I'm not sure what to do about. They're macros modeled
around the FC Transport attribute building macros, which
have the same 'feature' where the caller can ommit a cast
in the argument list and no cast occurs in the code. I'm
not sure how to keep the code condensed while keeping the
macros. Any advice would be appreciated.
Signed-off-by: Robert Love <robert.w.love@intel.com>
Tested-by: Ross Brattain <ross.b.brattain@intel.com>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Diffstat (limited to 'include/scsi/fcoe_sysfs.h')
-rw-r--r-- | include/scsi/fcoe_sysfs.h | 124 |
1 files changed, 124 insertions, 0 deletions
diff --git a/include/scsi/fcoe_sysfs.h b/include/scsi/fcoe_sysfs.h new file mode 100644 index 000000000000..604cb9bb3e76 --- /dev/null +++ b/include/scsi/fcoe_sysfs.h | |||
@@ -0,0 +1,124 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2011-2012 Intel Corporation. All rights reserved. | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify it | ||
5 | * under the terms and conditions of the GNU General Public License, | ||
6 | * version 2, as published by the Free Software Foundation. | ||
7 | * | ||
8 | * This program is distributed in the hope it will be useful, but WITHOUT | ||
9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
11 | * more details. | ||
12 | * | ||
13 | * You should have received a copy of the GNU General Public License along with | ||
14 | * this program; if not, write to the Free Software Foundation, Inc., | ||
15 | * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. | ||
16 | * | ||
17 | * Maintained at www.Open-FCoE.org | ||
18 | */ | ||
19 | |||
20 | #ifndef FCOE_SYSFS | ||
21 | #define FCOE_SYSFS | ||
22 | |||
23 | #include <linux/if_ether.h> | ||
24 | #include <linux/device.h> | ||
25 | #include <scsi/fc/fc_fcoe.h> | ||
26 | |||
27 | struct fcoe_ctlr_device; | ||
28 | struct fcoe_fcf_device; | ||
29 | |||
30 | struct fcoe_sysfs_function_template { | ||
31 | void (*get_fcoe_ctlr_link_fail)(struct fcoe_ctlr_device *); | ||
32 | void (*get_fcoe_ctlr_vlink_fail)(struct fcoe_ctlr_device *); | ||
33 | void (*get_fcoe_ctlr_miss_fka)(struct fcoe_ctlr_device *); | ||
34 | void (*get_fcoe_ctlr_symb_err)(struct fcoe_ctlr_device *); | ||
35 | void (*get_fcoe_ctlr_err_block)(struct fcoe_ctlr_device *); | ||
36 | void (*get_fcoe_ctlr_fcs_error)(struct fcoe_ctlr_device *); | ||
37 | void (*get_fcoe_ctlr_mode)(struct fcoe_ctlr_device *); | ||
38 | void (*get_fcoe_fcf_selected)(struct fcoe_fcf_device *); | ||
39 | void (*get_fcoe_fcf_vlan_id)(struct fcoe_fcf_device *); | ||
40 | }; | ||
41 | |||
42 | #define dev_to_ctlr(d) \ | ||
43 | container_of((d), struct fcoe_ctlr_device, dev) | ||
44 | |||
45 | enum fip_conn_type { | ||
46 | FIP_CONN_TYPE_UNKNOWN, | ||
47 | FIP_CONN_TYPE_FABRIC, | ||
48 | FIP_CONN_TYPE_VN2VN, | ||
49 | }; | ||
50 | |||
51 | struct fcoe_ctlr_device { | ||
52 | u32 id; | ||
53 | |||
54 | struct device dev; | ||
55 | struct fcoe_sysfs_function_template *f; | ||
56 | |||
57 | struct list_head fcfs; | ||
58 | char work_q_name[20]; | ||
59 | struct workqueue_struct *work_q; | ||
60 | char devloss_work_q_name[20]; | ||
61 | struct workqueue_struct *devloss_work_q; | ||
62 | struct mutex lock; | ||
63 | |||
64 | int fcf_dev_loss_tmo; | ||
65 | enum fip_conn_type mode; | ||
66 | |||
67 | /* expected in host order for displaying */ | ||
68 | struct fcoe_fc_els_lesb lesb; | ||
69 | }; | ||
70 | |||
71 | static inline void *fcoe_ctlr_device_priv(const struct fcoe_ctlr_device *ctlr) | ||
72 | { | ||
73 | return (void *)(ctlr + 1); | ||
74 | } | ||
75 | |||
76 | /* fcf states */ | ||
77 | enum fcf_state { | ||
78 | FCOE_FCF_STATE_UNKNOWN, | ||
79 | FCOE_FCF_STATE_DISCONNECTED, | ||
80 | FCOE_FCF_STATE_CONNECTED, | ||
81 | FCOE_FCF_STATE_DELETED, | ||
82 | }; | ||
83 | |||
84 | struct fcoe_fcf_device { | ||
85 | u32 id; | ||
86 | struct device dev; | ||
87 | struct list_head peers; | ||
88 | struct work_struct delete_work; | ||
89 | struct delayed_work dev_loss_work; | ||
90 | u32 dev_loss_tmo; | ||
91 | void *priv; | ||
92 | enum fcf_state state; | ||
93 | |||
94 | u64 fabric_name; | ||
95 | u64 switch_name; | ||
96 | u32 fc_map; | ||
97 | u16 vfid; | ||
98 | u8 mac[ETH_ALEN]; | ||
99 | u8 priority; | ||
100 | u32 fka_period; | ||
101 | u8 selected; | ||
102 | u16 vlan_id; | ||
103 | }; | ||
104 | |||
105 | #define dev_to_fcf(d) \ | ||
106 | container_of((d), struct fcoe_fcf_device, dev) | ||
107 | /* parentage should never be missing */ | ||
108 | #define fcoe_fcf_dev_to_ctlr_dev(x) \ | ||
109 | dev_to_ctlr((x)->dev.parent) | ||
110 | #define fcoe_fcf_device_priv(x) \ | ||
111 | ((x)->priv) | ||
112 | |||
113 | struct fcoe_ctlr_device *fcoe_ctlr_device_add(struct device *parent, | ||
114 | struct fcoe_sysfs_function_template *f, | ||
115 | int priv_size); | ||
116 | void fcoe_ctlr_device_delete(struct fcoe_ctlr_device *); | ||
117 | struct fcoe_fcf_device *fcoe_fcf_device_add(struct fcoe_ctlr_device *, | ||
118 | struct fcoe_fcf_device *); | ||
119 | void fcoe_fcf_device_delete(struct fcoe_fcf_device *); | ||
120 | |||
121 | int __init fcoe_sysfs_setup(void); | ||
122 | void __exit fcoe_sysfs_teardown(void); | ||
123 | |||
124 | #endif /* FCOE_SYSFS */ | ||