1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright (c) 2011-2012 Intel Corporation. All rights reserved.
5 * Maintained at www.Open-FCoE.org
11 #include <linux/if_ether.h>
12 #include <linux/device.h>
13 #include <scsi/fc/fc_fcoe.h>
15 struct fcoe_ctlr_device
;
16 struct fcoe_fcf_device
;
18 struct fcoe_sysfs_function_template
{
19 void (*get_fcoe_ctlr_link_fail
)(struct fcoe_ctlr_device
*);
20 void (*get_fcoe_ctlr_vlink_fail
)(struct fcoe_ctlr_device
*);
21 void (*get_fcoe_ctlr_miss_fka
)(struct fcoe_ctlr_device
*);
22 void (*get_fcoe_ctlr_symb_err
)(struct fcoe_ctlr_device
*);
23 void (*get_fcoe_ctlr_err_block
)(struct fcoe_ctlr_device
*);
24 void (*get_fcoe_ctlr_fcs_error
)(struct fcoe_ctlr_device
*);
25 void (*set_fcoe_ctlr_mode
)(struct fcoe_ctlr_device
*);
26 int (*set_fcoe_ctlr_enabled
)(struct fcoe_ctlr_device
*);
27 void (*get_fcoe_fcf_selected
)(struct fcoe_fcf_device
*);
28 void (*get_fcoe_fcf_vlan_id
)(struct fcoe_fcf_device
*);
31 #define dev_to_ctlr(d) \
32 container_of((d), struct fcoe_ctlr_device, dev)
35 FIP_CONN_TYPE_UNKNOWN
,
40 enum ctlr_enabled_state
{
46 struct fcoe_ctlr_device
{
50 struct fcoe_sysfs_function_template
*f
;
52 struct list_head fcfs
;
54 struct workqueue_struct
*work_q
;
55 char devloss_work_q_name
[20];
56 struct workqueue_struct
*devloss_work_q
;
60 enum fip_conn_type mode
;
62 enum ctlr_enabled_state enabled
;
64 /* expected in host order for displaying */
65 struct fcoe_fc_els_lesb lesb
;
68 static inline void *fcoe_ctlr_device_priv(const struct fcoe_ctlr_device
*ctlr
)
70 return (void *)(ctlr
+ 1);
75 FCOE_FCF_STATE_UNKNOWN
,
76 FCOE_FCF_STATE_DISCONNECTED
,
77 FCOE_FCF_STATE_CONNECTED
,
78 FCOE_FCF_STATE_DELETED
,
81 struct fcoe_fcf_device
{
84 struct list_head peers
;
85 struct work_struct delete_work
;
86 struct delayed_work dev_loss_work
;
102 #define dev_to_fcf(d) \
103 container_of((d), struct fcoe_fcf_device, dev)
104 /* parentage should never be missing */
105 #define fcoe_fcf_dev_to_ctlr_dev(x) \
106 dev_to_ctlr((x)->dev.parent)
107 #define fcoe_fcf_device_priv(x) \
110 struct fcoe_ctlr_device
*fcoe_ctlr_device_add(struct device
*parent
,
111 struct fcoe_sysfs_function_template
*f
,
113 void fcoe_ctlr_device_delete(struct fcoe_ctlr_device
*);
114 struct fcoe_fcf_device
*fcoe_fcf_device_add(struct fcoe_ctlr_device
*,
115 struct fcoe_fcf_device
*);
116 void fcoe_fcf_device_delete(struct fcoe_fcf_device
*);
118 int __init
fcoe_sysfs_setup(void);
119 void __exit
fcoe_sysfs_teardown(void);
121 #endif /* FCOE_SYSFS */