0001
0002
0003
0004
0005
0006
0007
0008 #ifndef FCOE_SYSFS
0009 #define FCOE_SYSFS
0010
0011 #include <linux/if_ether.h>
0012 #include <linux/device.h>
0013 #include <scsi/fc/fc_fcoe.h>
0014
0015 struct fcoe_ctlr_device;
0016 struct fcoe_fcf_device;
0017
0018 struct fcoe_sysfs_function_template {
0019 void (*get_fcoe_ctlr_link_fail)(struct fcoe_ctlr_device *);
0020 void (*get_fcoe_ctlr_vlink_fail)(struct fcoe_ctlr_device *);
0021 void (*get_fcoe_ctlr_miss_fka)(struct fcoe_ctlr_device *);
0022 void (*get_fcoe_ctlr_symb_err)(struct fcoe_ctlr_device *);
0023 void (*get_fcoe_ctlr_err_block)(struct fcoe_ctlr_device *);
0024 void (*get_fcoe_ctlr_fcs_error)(struct fcoe_ctlr_device *);
0025 void (*set_fcoe_ctlr_mode)(struct fcoe_ctlr_device *);
0026 int (*set_fcoe_ctlr_enabled)(struct fcoe_ctlr_device *);
0027 void (*get_fcoe_fcf_selected)(struct fcoe_fcf_device *);
0028 void (*get_fcoe_fcf_vlan_id)(struct fcoe_fcf_device *);
0029 };
0030
0031 #define dev_to_ctlr(d) \
0032 container_of((d), struct fcoe_ctlr_device, dev)
0033
0034 enum fip_conn_type {
0035 FIP_CONN_TYPE_UNKNOWN,
0036 FIP_CONN_TYPE_FABRIC,
0037 FIP_CONN_TYPE_VN2VN,
0038 };
0039
0040 enum ctlr_enabled_state {
0041 FCOE_CTLR_ENABLED,
0042 FCOE_CTLR_DISABLED,
0043 FCOE_CTLR_UNUSED,
0044 };
0045
0046 struct fcoe_ctlr_device {
0047 u32 id;
0048
0049 struct device dev;
0050 struct fcoe_sysfs_function_template *f;
0051
0052 struct list_head fcfs;
0053 char work_q_name[20];
0054 struct workqueue_struct *work_q;
0055 char devloss_work_q_name[20];
0056 struct workqueue_struct *devloss_work_q;
0057 struct mutex lock;
0058
0059 int fcf_dev_loss_tmo;
0060 enum fip_conn_type mode;
0061
0062 enum ctlr_enabled_state enabled;
0063
0064
0065 struct fcoe_fc_els_lesb lesb;
0066 };
0067
0068 static inline void *fcoe_ctlr_device_priv(const struct fcoe_ctlr_device *ctlr)
0069 {
0070 return (void *)(ctlr + 1);
0071 }
0072
0073
0074 enum fcf_state {
0075 FCOE_FCF_STATE_UNKNOWN,
0076 FCOE_FCF_STATE_DISCONNECTED,
0077 FCOE_FCF_STATE_CONNECTED,
0078 FCOE_FCF_STATE_DELETED,
0079 };
0080
0081 struct fcoe_fcf_device {
0082 u32 id;
0083 struct device dev;
0084 struct list_head peers;
0085 struct work_struct delete_work;
0086 struct delayed_work dev_loss_work;
0087 u32 dev_loss_tmo;
0088 void *priv;
0089 enum fcf_state state;
0090
0091 u64 fabric_name;
0092 u64 switch_name;
0093 u32 fc_map;
0094 u16 vfid;
0095 u8 mac[ETH_ALEN];
0096 u8 priority;
0097 u32 fka_period;
0098 u8 selected;
0099 u16 vlan_id;
0100 };
0101
0102 #define dev_to_fcf(d) \
0103 container_of((d), struct fcoe_fcf_device, dev)
0104
0105 #define fcoe_fcf_dev_to_ctlr_dev(x) \
0106 dev_to_ctlr((x)->dev.parent)
0107 #define fcoe_fcf_device_priv(x) \
0108 ((x)->priv)
0109
0110 struct fcoe_ctlr_device *fcoe_ctlr_device_add(struct device *parent,
0111 struct fcoe_sysfs_function_template *f,
0112 int priv_size);
0113 void fcoe_ctlr_device_delete(struct fcoe_ctlr_device *);
0114 struct fcoe_fcf_device *fcoe_fcf_device_add(struct fcoe_ctlr_device *,
0115 struct fcoe_fcf_device *);
0116 void fcoe_fcf_device_delete(struct fcoe_fcf_device *);
0117
0118 int __init fcoe_sysfs_setup(void);
0119 void __exit fcoe_sysfs_teardown(void);
0120
0121 #endif