Merge tag 'msm-cleanup-for-3.7' of git://git.kernel.org/pub/scm/linux/kernel/git...
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / include / scsi / fcoe_sysfs.h
CommitLineData
9a74e884
RL
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
27struct fcoe_ctlr_device;
28struct fcoe_fcf_device;
29
30struct 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
45enum fip_conn_type {
46 FIP_CONN_TYPE_UNKNOWN,
47 FIP_CONN_TYPE_FABRIC,
48 FIP_CONN_TYPE_VN2VN,
49};
50
51struct 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
71static inline void *fcoe_ctlr_device_priv(const struct fcoe_ctlr_device *ctlr)
72{
73 return (void *)(ctlr + 1);
74}
75
76/* fcf states */
77enum fcf_state {
78 FCOE_FCF_STATE_UNKNOWN,
79 FCOE_FCF_STATE_DISCONNECTED,
80 FCOE_FCF_STATE_CONNECTED,
81 FCOE_FCF_STATE_DELETED,
82};
83
84struct 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
113struct fcoe_ctlr_device *fcoe_ctlr_device_add(struct device *parent,
114 struct fcoe_sysfs_function_template *f,
115 int priv_size);
116void fcoe_ctlr_device_delete(struct fcoe_ctlr_device *);
117struct fcoe_fcf_device *fcoe_fcf_device_add(struct fcoe_ctlr_device *,
118 struct fcoe_fcf_device *);
119void fcoe_fcf_device_delete(struct fcoe_fcf_device *);
120
121int __init fcoe_sysfs_setup(void);
122void __exit fcoe_sysfs_teardown(void);
123
124#endif /* FCOE_SYSFS */