20 #include <linux/module.h>
21 #include <linux/types.h>
22 #include <linux/kernel.h>
39 "Maximum number of seconds that libfcoe should"
40 " insulate the loss of a fcf. Once this value is"
41 " exceeded, the fcf is removed.");
48 #define fcoe_ctlr_id(x) \
50 #define fcoe_ctlr_work_q_name(x) \
52 #define fcoe_ctlr_work_q(x) \
54 #define fcoe_ctlr_devloss_work_q_name(x) \
55 ((x)->devloss_work_q_name)
56 #define fcoe_ctlr_devloss_work_q(x) \
58 #define fcoe_ctlr_mode(x) \
60 #define fcoe_ctlr_fcf_dev_loss_tmo(x) \
61 ((x)->fcf_dev_loss_tmo)
62 #define fcoe_ctlr_link_fail(x) \
63 ((x)->lesb.lesb_link_fail)
64 #define fcoe_ctlr_vlink_fail(x) \
65 ((x)->lesb.lesb_vlink_fail)
66 #define fcoe_ctlr_miss_fka(x) \
67 ((x)->lesb.lesb_miss_fka)
68 #define fcoe_ctlr_symb_err(x) \
69 ((x)->lesb.lesb_symb_err)
70 #define fcoe_ctlr_err_block(x) \
71 ((x)->lesb.lesb_err_block)
72 #define fcoe_ctlr_fcs_error(x) \
73 ((x)->lesb.lesb_fcs_error)
74 #define fcoe_fcf_state(x) \
76 #define fcoe_fcf_fabric_name(x) \
78 #define fcoe_fcf_switch_name(x) \
80 #define fcoe_fcf_fc_map(x) \
82 #define fcoe_fcf_vfid(x) \
84 #define fcoe_fcf_mac(x) \
86 #define fcoe_fcf_priority(x) \
88 #define fcoe_fcf_fka_period(x) \
90 #define fcoe_fcf_dev_loss_tmo(x) \
92 #define fcoe_fcf_selected(x) \
94 #define fcoe_fcf_vlan_id(x) \
100 static int fcoe_str_to_dev_loss(
const char *
buf,
unsigned long *
val)
104 ret = kstrtoul(buf, 0, val);
133 #define FCOE_DEVICE_ATTR(_prefix, _name, _mode, _show, _store) \
134 struct device_attribute device_attr_fcoe_##_prefix##_##_name = \
135 __ATTR(_name, _mode, _show, _store)
137 #define fcoe_ctlr_show_function(field, format_string, sz, cast) \
138 static ssize_t show_fcoe_ctlr_device_##field(struct device *dev, \
139 struct device_attribute *attr, \
142 struct fcoe_ctlr_device *ctlr = dev_to_ctlr(dev); \
143 if (ctlr->f->get_fcoe_ctlr_##field) \
144 ctlr->f->get_fcoe_ctlr_##field(ctlr); \
145 return snprintf(buf, sz, format_string, \
146 cast fcoe_ctlr_##field(ctlr)); \
149 #define fcoe_fcf_show_function(field, format_string, sz, cast) \
150 static ssize_t show_fcoe_fcf_device_##field(struct device *dev, \
151 struct device_attribute *attr, \
154 struct fcoe_fcf_device *fcf = dev_to_fcf(dev); \
155 struct fcoe_ctlr_device *ctlr = fcoe_fcf_dev_to_ctlr_dev(fcf); \
156 if (ctlr->f->get_fcoe_fcf_##field) \
157 ctlr->f->get_fcoe_fcf_##field(fcf); \
158 return snprintf(buf, sz, format_string, \
159 cast fcoe_fcf_##field(fcf)); \
162 #define fcoe_ctlr_private_show_function(field, format_string, sz, cast) \
163 static ssize_t show_fcoe_ctlr_device_##field(struct device *dev, \
164 struct device_attribute *attr, \
167 struct fcoe_ctlr_device *ctlr = dev_to_ctlr(dev); \
168 return snprintf(buf, sz, format_string, cast fcoe_ctlr_##field(ctlr)); \
171 #define fcoe_fcf_private_show_function(field, format_string, sz, cast) \
172 static ssize_t show_fcoe_fcf_device_##field(struct device *dev, \
173 struct device_attribute *attr, \
176 struct fcoe_fcf_device *fcf = dev_to_fcf(dev); \
177 return snprintf(buf, sz, format_string, cast fcoe_fcf_##field(fcf)); \
180 #define fcoe_ctlr_private_rd_attr(field, format_string, sz) \
181 fcoe_ctlr_private_show_function(field, format_string, sz, ) \
182 static FCOE_DEVICE_ATTR(ctlr, field, S_IRUGO, \
183 show_fcoe_ctlr_device_##field, NULL)
185 #define fcoe_ctlr_rd_attr(field, format_string, sz) \
186 fcoe_ctlr_show_function(field, format_string, sz, ) \
187 static FCOE_DEVICE_ATTR(ctlr, field, S_IRUGO, \
188 show_fcoe_ctlr_device_##field, NULL)
190 #define fcoe_fcf_rd_attr(field, format_string, sz) \
191 fcoe_fcf_show_function(field, format_string, sz, ) \
192 static FCOE_DEVICE_ATTR(fcf, field, S_IRUGO, \
193 show_fcoe_fcf_device_##field, NULL)
195 #define fcoe_fcf_private_rd_attr(field, format_string, sz) \
196 fcoe_fcf_private_show_function(field, format_string, sz, ) \
197 static FCOE_DEVICE_ATTR(fcf, field, S_IRUGO, \
198 show_fcoe_fcf_device_##field, NULL)
200 #define fcoe_ctlr_private_rd_attr_cast(field, format_string, sz, cast) \
201 fcoe_ctlr_private_show_function(field, format_string, sz, (cast)) \
202 static FCOE_DEVICE_ATTR(ctlr, field, S_IRUGO, \
203 show_fcoe_ctlr_device_##field, NULL)
205 #define fcoe_fcf_private_rd_attr_cast(field, format_string, sz, cast) \
206 fcoe_fcf_private_show_function(field, format_string, sz, (cast)) \
207 static FCOE_DEVICE_ATTR(fcf, field, S_IRUGO, \
208 show_fcoe_fcf_device_##field, NULL)
210 #define fcoe_enum_name_search(title, table_type, table) \
211 static const char *get_fcoe_##title##_name(enum table_type table_key) \
216 for (i = 0; i < ARRAY_SIZE(table); i++) { \
217 if (table[i].value == table_key) { \
218 name = table[i].name; \
228 } fcf_state_names[] = {
234 #define FCOE_FCF_STATE_MAX_NAMELEN 50
242 name = get_fcoe_fcf_state_name(fcf->
state);
252 } fip_conn_type_names[] = {
258 #define FCOE_CTLR_MODE_MAX_NAMELEN 50
267 if (ctlr->
f->get_fcoe_ctlr_mode)
268 ctlr->
f->get_fcoe_ctlr_mode(ctlr);
270 name = get_fcoe_ctlr_mode_name(ctlr->
mode);
277 show_ctlr_mode,
NULL);
280 store_private_fcoe_ctlr_fcf_dev_loss_tmo(
struct device *
dev,
289 rc = fcoe_str_to_dev_loss(buf, &val);
296 fcoe_fcf_set_dev_loss_tmo(fcf, val);
302 show_fcoe_ctlr_device_fcf_dev_loss_tmo,
303 store_private_fcoe_ctlr_fcf_dev_loss_tmo);
326 const char *buf,
size_t count)
332 rc = fcoe_str_to_dev_loss(buf, &val);
336 rc = fcoe_fcf_set_dev_loss_tmo(fcf, val);
342 show_fcoe_fcf_device_dev_loss_tmo,
343 store_fcoe_fcf_dev_loss_tmo);
345 static struct attribute *fcoe_ctlr_lesb_attrs[] = {
346 &device_attr_fcoe_ctlr_link_fail.attr,
347 &device_attr_fcoe_ctlr_vlink_fail.attr,
348 &device_attr_fcoe_ctlr_miss_fka.attr,
349 &device_attr_fcoe_ctlr_symb_err.attr,
350 &device_attr_fcoe_ctlr_err_block.attr,
351 &device_attr_fcoe_ctlr_fcs_error.attr,
357 .attrs = fcoe_ctlr_lesb_attrs,
360 static struct attribute *fcoe_ctlr_attrs[] = {
361 &device_attr_fcoe_ctlr_fcf_dev_loss_tmo.attr,
362 &device_attr_fcoe_ctlr_mode.attr,
367 .attrs = fcoe_ctlr_attrs,
371 &fcoe_ctlr_attr_group,
372 &fcoe_ctlr_lesb_attr_group,
376 static struct attribute *fcoe_fcf_attrs[] = {
377 &device_attr_fcoe_fcf_fabric_name.attr,
378 &device_attr_fcoe_fcf_switch_name.attr,
379 &device_attr_fcoe_fcf_dev_loss_tmo.attr,
380 &device_attr_fcoe_fcf_fc_map.attr,
381 &device_attr_fcoe_fcf_vfid.attr,
382 &device_attr_fcoe_fcf_mac.attr,
383 &device_attr_fcoe_fcf_priority.attr,
384 &device_attr_fcoe_fcf_fka_period.attr,
385 &device_attr_fcoe_fcf_state.attr,
386 &device_attr_fcoe_fcf_selected.attr,
387 &device_attr_fcoe_fcf_vlan_id.attr,
392 .attrs = fcoe_fcf_attrs,
396 &fcoe_fcf_attr_group,
402 static int fcoe_bus_match(
struct device *dev,
416 static void fcoe_ctlr_device_release(
struct device *dev)
428 static void fcoe_fcf_device_release(
struct device *dev)
436 .groups = fcoe_ctlr_attr_groups,
437 .release = fcoe_ctlr_device_release,
442 .groups = fcoe_fcf_attr_groups,
443 .release = fcoe_fcf_device_release,
448 .match = &fcoe_bus_match,
459 "ERROR: FIP Ctlr '%d' attempted to flush work, "
460 "when no workqueue created.\n", ctlr->
id);
481 "ERROR: FIP Ctlr '%d' attempted to queue work, "
482 "when no workqueue created.\n", ctlr->
id);
499 "ERROR: FIP Ctlr '%d' attempted to flush work, "
500 "when no workqueue created.\n", ctlr->
id);
523 "ERROR: FIP Ctlr '%d' attempted to queue work, "
524 "when no workqueue created.\n", ctlr->
id);
538 new->fc_map == old->
fc_map &&
539 compare_ether_addr(new->mac, old->
mac) == 0)
569 INIT_LIST_HEAD(&ctlr->
fcfs);
571 ctlr->
dev.parent = parent;
578 "ctlr_wq_%d", ctlr->
id);
586 "ctlr_dl_wq_%d", ctlr->
id);
687 static void fip_timeout_deleted_fcf(
struct work_struct *work)
705 "FIP fcf connection time out: removing fcf\n");
760 if (fcoe_fcf_device_match(new_fcf, fcf)) {
780 fcf->
dev.parent = &ctlr->
dev;