2 * Copyright (c) 2011-2012 Intel Corporation. All rights reserved.
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.
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
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.
17 * Maintained at www.Open-FCoE.org
23 #include <linux/if_ether.h>
24 #include <linux/device.h>
25 #include <scsi/fc/fc_fcoe.h>
27 struct fcoe_ctlr_device
;
28 struct fcoe_fcf_device
;
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 (*set_fcoe_ctlr_mode
)(struct fcoe_ctlr_device
*);
38 int (*set_fcoe_ctlr_enabled
)(struct fcoe_ctlr_device
*);
39 void (*get_fcoe_fcf_selected
)(struct fcoe_fcf_device
*);
40 void (*get_fcoe_fcf_vlan_id
)(struct fcoe_fcf_device
*);
43 #define dev_to_ctlr(d) \
44 container_of((d), struct fcoe_ctlr_device, dev)
47 FIP_CONN_TYPE_UNKNOWN
,
52 enum ctlr_enabled_state
{
58 struct fcoe_ctlr_device
{
62 struct fcoe_sysfs_function_template
*f
;
64 struct list_head fcfs
;
66 struct workqueue_struct
*work_q
;
67 char devloss_work_q_name
[20];
68 struct workqueue_struct
*devloss_work_q
;
72 enum fip_conn_type mode
;
74 enum ctlr_enabled_state enabled
;
76 /* expected in host order for displaying */
77 struct fcoe_fc_els_lesb lesb
;
80 static inline void *fcoe_ctlr_device_priv(const struct fcoe_ctlr_device
*ctlr
)
82 return (void *)(ctlr
+ 1);
87 FCOE_FCF_STATE_UNKNOWN
,
88 FCOE_FCF_STATE_DISCONNECTED
,
89 FCOE_FCF_STATE_CONNECTED
,
90 FCOE_FCF_STATE_DELETED
,
93 struct fcoe_fcf_device
{
96 struct list_head peers
;
97 struct work_struct delete_work
;
98 struct delayed_work dev_loss_work
;
101 enum fcf_state state
;
114 #define dev_to_fcf(d) \
115 container_of((d), struct fcoe_fcf_device, dev)
116 /* parentage should never be missing */
117 #define fcoe_fcf_dev_to_ctlr_dev(x) \
118 dev_to_ctlr((x)->dev.parent)
119 #define fcoe_fcf_device_priv(x) \
122 struct fcoe_ctlr_device
*fcoe_ctlr_device_add(struct device
*parent
,
123 struct fcoe_sysfs_function_template
*f
,
125 void fcoe_ctlr_device_delete(struct fcoe_ctlr_device
*);
126 struct fcoe_fcf_device
*fcoe_fcf_device_add(struct fcoe_ctlr_device
*,
127 struct fcoe_fcf_device
*);
128 void fcoe_fcf_device_delete(struct fcoe_fcf_device
*);
130 int __init
fcoe_sysfs_setup(void);
131 void __exit
fcoe_sysfs_teardown(void);
133 #endif /* FCOE_SYSFS */