^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Copyright(c) 2011 - 2012 Intel Corporation. All rights reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Maintained at www.Open-FCoE.org
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/etherdevice.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/ctype.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <scsi/fcoe_sysfs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <scsi/libfcoe.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) * OK to include local libfcoe.h for debug_logging, but cannot include
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) * <scsi/libfcoe.h> otherwise non-netdev based fcoe solutions would have
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) * have to include more than fcoe_sysfs.h.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include "libfcoe.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) static atomic_t ctlr_num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) static atomic_t fcf_num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) * fcoe_fcf_dev_loss_tmo: the default number of seconds that fcoe sysfs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) * should insulate the loss of a fcf.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) static unsigned int fcoe_fcf_dev_loss_tmo = 1800; /* seconds */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) module_param_named(fcf_dev_loss_tmo, fcoe_fcf_dev_loss_tmo,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) uint, S_IRUGO|S_IWUSR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) MODULE_PARM_DESC(fcf_dev_loss_tmo,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) "Maximum number of seconds that libfcoe should"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) " insulate the loss of a fcf. Once this value is"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) " exceeded, the fcf is removed.");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) * These are used by the fcoe_*_show_function routines, they
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) * are intentionally placed in the .c file as they're not intended
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) * for use throughout the code.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) #define fcoe_ctlr_id(x) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) ((x)->id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) #define fcoe_ctlr_work_q_name(x) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) ((x)->work_q_name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) #define fcoe_ctlr_work_q(x) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) ((x)->work_q)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) #define fcoe_ctlr_devloss_work_q_name(x) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) ((x)->devloss_work_q_name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) #define fcoe_ctlr_devloss_work_q(x) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) ((x)->devloss_work_q)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) #define fcoe_ctlr_mode(x) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) ((x)->mode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) #define fcoe_ctlr_fcf_dev_loss_tmo(x) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) ((x)->fcf_dev_loss_tmo)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) #define fcoe_ctlr_link_fail(x) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) ((x)->lesb.lesb_link_fail)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) #define fcoe_ctlr_vlink_fail(x) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) ((x)->lesb.lesb_vlink_fail)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) #define fcoe_ctlr_miss_fka(x) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) ((x)->lesb.lesb_miss_fka)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) #define fcoe_ctlr_symb_err(x) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) ((x)->lesb.lesb_symb_err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) #define fcoe_ctlr_err_block(x) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) ((x)->lesb.lesb_err_block)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) #define fcoe_ctlr_fcs_error(x) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) ((x)->lesb.lesb_fcs_error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) #define fcoe_ctlr_enabled(x) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) ((x)->enabled)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) #define fcoe_fcf_state(x) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) ((x)->state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) #define fcoe_fcf_fabric_name(x) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) ((x)->fabric_name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) #define fcoe_fcf_switch_name(x) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) ((x)->switch_name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) #define fcoe_fcf_fc_map(x) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) ((x)->fc_map)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) #define fcoe_fcf_vfid(x) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) ((x)->vfid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) #define fcoe_fcf_mac(x) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) ((x)->mac)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) #define fcoe_fcf_priority(x) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) ((x)->priority)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) #define fcoe_fcf_fka_period(x) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) ((x)->fka_period)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) #define fcoe_fcf_dev_loss_tmo(x) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) ((x)->dev_loss_tmo)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) #define fcoe_fcf_selected(x) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) ((x)->selected)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) #define fcoe_fcf_vlan_id(x) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) ((x)->vlan_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) * dev_loss_tmo attribute
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) static int fcoe_str_to_dev_loss(const char *buf, unsigned long *val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) ret = kstrtoul(buf, 0, val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) * Check for overflow; dev_loss_tmo is u32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) if (*val > UINT_MAX)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) static int fcoe_fcf_set_dev_loss_tmo(struct fcoe_fcf_device *fcf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) unsigned long val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) if ((fcf->state == FCOE_FCF_STATE_UNKNOWN) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) (fcf->state == FCOE_FCF_STATE_DISCONNECTED) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) (fcf->state == FCOE_FCF_STATE_DELETED))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) return -EBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) * Check for overflow; dev_loss_tmo is u32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) if (val > UINT_MAX)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) fcoe_fcf_dev_loss_tmo(fcf) = val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) #define FCOE_DEVICE_ATTR(_prefix, _name, _mode, _show, _store) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) struct device_attribute device_attr_fcoe_##_prefix##_##_name = \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) __ATTR(_name, _mode, _show, _store)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) #define fcoe_ctlr_show_function(field, format_string, sz, cast) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) static ssize_t show_fcoe_ctlr_device_##field(struct device *dev, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) struct device_attribute *attr, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) char *buf) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) struct fcoe_ctlr_device *ctlr = dev_to_ctlr(dev); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) if (ctlr->f->get_fcoe_ctlr_##field) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) ctlr->f->get_fcoe_ctlr_##field(ctlr); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) return snprintf(buf, sz, format_string, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) cast fcoe_ctlr_##field(ctlr)); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) #define fcoe_fcf_show_function(field, format_string, sz, cast) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) static ssize_t show_fcoe_fcf_device_##field(struct device *dev, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) struct device_attribute *attr, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) char *buf) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) struct fcoe_fcf_device *fcf = dev_to_fcf(dev); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) struct fcoe_ctlr_device *ctlr = fcoe_fcf_dev_to_ctlr_dev(fcf); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) if (ctlr->f->get_fcoe_fcf_##field) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) ctlr->f->get_fcoe_fcf_##field(fcf); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) return snprintf(buf, sz, format_string, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) cast fcoe_fcf_##field(fcf)); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) #define fcoe_ctlr_private_show_function(field, format_string, sz, cast) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) static ssize_t show_fcoe_ctlr_device_##field(struct device *dev, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) struct device_attribute *attr, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) char *buf) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) struct fcoe_ctlr_device *ctlr = dev_to_ctlr(dev); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) return snprintf(buf, sz, format_string, cast fcoe_ctlr_##field(ctlr)); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) #define fcoe_fcf_private_show_function(field, format_string, sz, cast) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) static ssize_t show_fcoe_fcf_device_##field(struct device *dev, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) struct device_attribute *attr, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) char *buf) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) struct fcoe_fcf_device *fcf = dev_to_fcf(dev); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) return snprintf(buf, sz, format_string, cast fcoe_fcf_##field(fcf)); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) #define fcoe_ctlr_private_rd_attr(field, format_string, sz) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) fcoe_ctlr_private_show_function(field, format_string, sz, ) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) static FCOE_DEVICE_ATTR(ctlr, field, S_IRUGO, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) show_fcoe_ctlr_device_##field, NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) #define fcoe_ctlr_rd_attr(field, format_string, sz) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) fcoe_ctlr_show_function(field, format_string, sz, ) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) static FCOE_DEVICE_ATTR(ctlr, field, S_IRUGO, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) show_fcoe_ctlr_device_##field, NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) #define fcoe_fcf_rd_attr(field, format_string, sz) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) fcoe_fcf_show_function(field, format_string, sz, ) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) static FCOE_DEVICE_ATTR(fcf, field, S_IRUGO, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) show_fcoe_fcf_device_##field, NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) #define fcoe_fcf_private_rd_attr(field, format_string, sz) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) fcoe_fcf_private_show_function(field, format_string, sz, ) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) static FCOE_DEVICE_ATTR(fcf, field, S_IRUGO, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) show_fcoe_fcf_device_##field, NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) #define fcoe_ctlr_private_rd_attr_cast(field, format_string, sz, cast) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) fcoe_ctlr_private_show_function(field, format_string, sz, (cast)) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) static FCOE_DEVICE_ATTR(ctlr, field, S_IRUGO, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) show_fcoe_ctlr_device_##field, NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) #define fcoe_fcf_private_rd_attr_cast(field, format_string, sz, cast) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) fcoe_fcf_private_show_function(field, format_string, sz, (cast)) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) static FCOE_DEVICE_ATTR(fcf, field, S_IRUGO, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) show_fcoe_fcf_device_##field, NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) #define fcoe_enum_name_search(title, table_type, table) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) static const char *get_fcoe_##title##_name(enum table_type table_key) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) if (table_key < 0 || table_key >= ARRAY_SIZE(table)) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) return NULL; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) return table[table_key]; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) static char *fip_conn_type_names[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) [ FIP_CONN_TYPE_UNKNOWN ] = "Unknown",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) [ FIP_CONN_TYPE_FABRIC ] = "Fabric",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) [ FIP_CONN_TYPE_VN2VN ] = "VN2VN",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) fcoe_enum_name_search(ctlr_mode, fip_conn_type, fip_conn_type_names)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) static enum fip_conn_type fcoe_parse_mode(const char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) for (i = 0; i < ARRAY_SIZE(fip_conn_type_names); i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) if (strcasecmp(buf, fip_conn_type_names[i]) == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) return i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) return FIP_CONN_TYPE_UNKNOWN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) static char *fcf_state_names[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) [ FCOE_FCF_STATE_UNKNOWN ] = "Unknown",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) [ FCOE_FCF_STATE_DISCONNECTED ] = "Disconnected",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) [ FCOE_FCF_STATE_CONNECTED ] = "Connected",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) fcoe_enum_name_search(fcf_state, fcf_state, fcf_state_names)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) #define FCOE_FCF_STATE_MAX_NAMELEN 50
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) static ssize_t show_fcf_state(struct device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) struct device_attribute *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) struct fcoe_fcf_device *fcf = dev_to_fcf(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) const char *name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) name = get_fcoe_fcf_state_name(fcf->state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) if (!name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) return snprintf(buf, FCOE_FCF_STATE_MAX_NAMELEN, "%s\n", name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) static FCOE_DEVICE_ATTR(fcf, state, S_IRUGO, show_fcf_state, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) #define FCOE_MAX_MODENAME_LEN 20
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) static ssize_t show_ctlr_mode(struct device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) struct device_attribute *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) struct fcoe_ctlr_device *ctlr = dev_to_ctlr(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) const char *name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) name = get_fcoe_ctlr_mode_name(ctlr->mode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) if (!name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) return snprintf(buf, FCOE_MAX_MODENAME_LEN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) "%s\n", name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) static ssize_t store_ctlr_mode(struct device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) struct device_attribute *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) const char *buf, size_t count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) struct fcoe_ctlr_device *ctlr = dev_to_ctlr(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) char mode[FCOE_MAX_MODENAME_LEN + 1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) if (count > FCOE_MAX_MODENAME_LEN)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) strncpy(mode, buf, count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) if (mode[count - 1] == '\n')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) mode[count - 1] = '\0';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) mode[count] = '\0';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) switch (ctlr->enabled) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) case FCOE_CTLR_ENABLED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) LIBFCOE_SYSFS_DBG(ctlr, "Cannot change mode when enabled.\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) return -EBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) case FCOE_CTLR_DISABLED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) if (!ctlr->f->set_fcoe_ctlr_mode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) LIBFCOE_SYSFS_DBG(ctlr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) "Mode change not supported by LLD.\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) return -ENOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) ctlr->mode = fcoe_parse_mode(mode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) if (ctlr->mode == FIP_CONN_TYPE_UNKNOWN) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) LIBFCOE_SYSFS_DBG(ctlr, "Unknown mode %s provided.\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) ctlr->f->set_fcoe_ctlr_mode(ctlr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) LIBFCOE_SYSFS_DBG(ctlr, "Mode changed to %s.\n", buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) return count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) case FCOE_CTLR_UNUSED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) LIBFCOE_SYSFS_DBG(ctlr, "Mode change not supported.\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) return -ENOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) static FCOE_DEVICE_ATTR(ctlr, mode, S_IRUGO | S_IWUSR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) show_ctlr_mode, store_ctlr_mode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) static ssize_t store_ctlr_enabled(struct device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) struct device_attribute *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) const char *buf, size_t count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) struct fcoe_ctlr_device *ctlr = dev_to_ctlr(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) bool enabled;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) if (*buf == '1')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) enabled = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) else if (*buf == '0')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) enabled = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) switch (ctlr->enabled) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) case FCOE_CTLR_ENABLED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) if (enabled)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) return count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) ctlr->enabled = FCOE_CTLR_DISABLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) case FCOE_CTLR_DISABLED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) if (!enabled)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) return count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) ctlr->enabled = FCOE_CTLR_ENABLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) case FCOE_CTLR_UNUSED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) return -ENOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) rc = ctlr->f->set_fcoe_ctlr_enabled(ctlr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) return count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) static char *ctlr_enabled_state_names[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) [ FCOE_CTLR_ENABLED ] = "1",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) [ FCOE_CTLR_DISABLED ] = "0",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) fcoe_enum_name_search(ctlr_enabled_state, ctlr_enabled_state,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) ctlr_enabled_state_names)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) #define FCOE_CTLR_ENABLED_MAX_NAMELEN 50
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) static ssize_t show_ctlr_enabled_state(struct device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) struct device_attribute *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) struct fcoe_ctlr_device *ctlr = dev_to_ctlr(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) const char *name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) name = get_fcoe_ctlr_enabled_state_name(ctlr->enabled);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) if (!name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) return snprintf(buf, FCOE_CTLR_ENABLED_MAX_NAMELEN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) "%s\n", name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) static FCOE_DEVICE_ATTR(ctlr, enabled, S_IRUGO | S_IWUSR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) show_ctlr_enabled_state,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) store_ctlr_enabled);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) static ssize_t store_ctlr_fip_resp(struct device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) struct device_attribute *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) const char *buf, size_t count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) struct fcoe_ctlr_device *ctlr = dev_to_ctlr(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) struct fcoe_ctlr *fip = fcoe_ctlr_device_priv(ctlr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) mutex_lock(&fip->ctlr_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) if ((buf[1] == '\0') || ((buf[1] == '\n') && (buf[2] == '\0'))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) if (buf[0] == '1') {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) fip->fip_resp = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) mutex_unlock(&fip->ctlr_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) return count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) if (buf[0] == '0') {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) fip->fip_resp = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) mutex_unlock(&fip->ctlr_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) return count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) mutex_unlock(&fip->ctlr_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) static ssize_t show_ctlr_fip_resp(struct device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) struct device_attribute *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) struct fcoe_ctlr_device *ctlr = dev_to_ctlr(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) struct fcoe_ctlr *fip = fcoe_ctlr_device_priv(ctlr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) return sprintf(buf, "%d\n", fip->fip_resp ? 1 : 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) static FCOE_DEVICE_ATTR(ctlr, fip_vlan_responder, S_IRUGO | S_IWUSR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) show_ctlr_fip_resp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) store_ctlr_fip_resp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) fcoe_ctlr_var_store(u32 *var, const char *buf, size_t count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) unsigned long v;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) err = kstrtoul(buf, 10, &v);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) if (err || v > UINT_MAX)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) *var = v;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) return count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) static ssize_t store_ctlr_r_a_tov(struct device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) struct device_attribute *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) const char *buf, size_t count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) struct fcoe_ctlr_device *ctlr_dev = dev_to_ctlr(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) struct fcoe_ctlr *ctlr = fcoe_ctlr_device_priv(ctlr_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) if (ctlr_dev->enabled == FCOE_CTLR_ENABLED)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) return -EBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) if (ctlr_dev->enabled == FCOE_CTLR_DISABLED)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) return fcoe_ctlr_var_store(&ctlr->lp->r_a_tov, buf, count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) return -ENOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) static ssize_t show_ctlr_r_a_tov(struct device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) struct device_attribute *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) struct fcoe_ctlr_device *ctlr_dev = dev_to_ctlr(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) struct fcoe_ctlr *ctlr = fcoe_ctlr_device_priv(ctlr_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) return sprintf(buf, "%d\n", ctlr->lp->r_a_tov);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) static FCOE_DEVICE_ATTR(ctlr, r_a_tov, S_IRUGO | S_IWUSR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) show_ctlr_r_a_tov, store_ctlr_r_a_tov);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) static ssize_t store_ctlr_e_d_tov(struct device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) struct device_attribute *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) const char *buf, size_t count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) struct fcoe_ctlr_device *ctlr_dev = dev_to_ctlr(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) struct fcoe_ctlr *ctlr = fcoe_ctlr_device_priv(ctlr_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) if (ctlr_dev->enabled == FCOE_CTLR_ENABLED)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) return -EBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) if (ctlr_dev->enabled == FCOE_CTLR_DISABLED)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) return fcoe_ctlr_var_store(&ctlr->lp->e_d_tov, buf, count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) return -ENOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) static ssize_t show_ctlr_e_d_tov(struct device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) struct device_attribute *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) struct fcoe_ctlr_device *ctlr_dev = dev_to_ctlr(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) struct fcoe_ctlr *ctlr = fcoe_ctlr_device_priv(ctlr_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) return sprintf(buf, "%d\n", ctlr->lp->e_d_tov);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) static FCOE_DEVICE_ATTR(ctlr, e_d_tov, S_IRUGO | S_IWUSR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) show_ctlr_e_d_tov, store_ctlr_e_d_tov);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) store_private_fcoe_ctlr_fcf_dev_loss_tmo(struct device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) struct device_attribute *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) const char *buf, size_t count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) struct fcoe_ctlr_device *ctlr = dev_to_ctlr(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) struct fcoe_fcf_device *fcf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) unsigned long val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) rc = fcoe_str_to_dev_loss(buf, &val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) fcoe_ctlr_fcf_dev_loss_tmo(ctlr) = val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) mutex_lock(&ctlr->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) list_for_each_entry(fcf, &ctlr->fcfs, peers)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) fcoe_fcf_set_dev_loss_tmo(fcf, val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) mutex_unlock(&ctlr->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) return count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) fcoe_ctlr_private_show_function(fcf_dev_loss_tmo, "%d\n", 20, );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) static FCOE_DEVICE_ATTR(ctlr, fcf_dev_loss_tmo, S_IRUGO | S_IWUSR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) show_fcoe_ctlr_device_fcf_dev_loss_tmo,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) store_private_fcoe_ctlr_fcf_dev_loss_tmo);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) /* Link Error Status Block (LESB) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) fcoe_ctlr_rd_attr(link_fail, "%u\n", 20);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) fcoe_ctlr_rd_attr(vlink_fail, "%u\n", 20);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) fcoe_ctlr_rd_attr(miss_fka, "%u\n", 20);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) fcoe_ctlr_rd_attr(symb_err, "%u\n", 20);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) fcoe_ctlr_rd_attr(err_block, "%u\n", 20);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) fcoe_ctlr_rd_attr(fcs_error, "%u\n", 20);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) fcoe_fcf_private_rd_attr_cast(fabric_name, "0x%llx\n", 20, unsigned long long);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) fcoe_fcf_private_rd_attr_cast(switch_name, "0x%llx\n", 20, unsigned long long);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) fcoe_fcf_private_rd_attr(priority, "%u\n", 20);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) fcoe_fcf_private_rd_attr(fc_map, "0x%x\n", 20);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) fcoe_fcf_private_rd_attr(vfid, "%u\n", 20);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) fcoe_fcf_private_rd_attr(mac, "%pM\n", 20);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) fcoe_fcf_private_rd_attr(fka_period, "%u\n", 20);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) fcoe_fcf_rd_attr(selected, "%u\n", 20);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) fcoe_fcf_rd_attr(vlan_id, "%u\n", 20);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) fcoe_fcf_private_show_function(dev_loss_tmo, "%d\n", 20, )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) store_fcoe_fcf_dev_loss_tmo(struct device *dev, struct device_attribute *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) const char *buf, size_t count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) struct fcoe_fcf_device *fcf = dev_to_fcf(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) unsigned long val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) rc = fcoe_str_to_dev_loss(buf, &val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) rc = fcoe_fcf_set_dev_loss_tmo(fcf, val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) return count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) static FCOE_DEVICE_ATTR(fcf, dev_loss_tmo, S_IRUGO | S_IWUSR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) show_fcoe_fcf_device_dev_loss_tmo,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) store_fcoe_fcf_dev_loss_tmo);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) static struct attribute *fcoe_ctlr_lesb_attrs[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) &device_attr_fcoe_ctlr_link_fail.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) &device_attr_fcoe_ctlr_vlink_fail.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) &device_attr_fcoe_ctlr_miss_fka.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) &device_attr_fcoe_ctlr_symb_err.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) &device_attr_fcoe_ctlr_err_block.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) &device_attr_fcoe_ctlr_fcs_error.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) static struct attribute_group fcoe_ctlr_lesb_attr_group = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) .name = "lesb",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) .attrs = fcoe_ctlr_lesb_attrs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) static struct attribute *fcoe_ctlr_attrs[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) &device_attr_fcoe_ctlr_fip_vlan_responder.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) &device_attr_fcoe_ctlr_fcf_dev_loss_tmo.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) &device_attr_fcoe_ctlr_r_a_tov.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) &device_attr_fcoe_ctlr_e_d_tov.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) &device_attr_fcoe_ctlr_enabled.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) &device_attr_fcoe_ctlr_mode.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) static struct attribute_group fcoe_ctlr_attr_group = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) .attrs = fcoe_ctlr_attrs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) static const struct attribute_group *fcoe_ctlr_attr_groups[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) &fcoe_ctlr_attr_group,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) &fcoe_ctlr_lesb_attr_group,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) static struct attribute *fcoe_fcf_attrs[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) &device_attr_fcoe_fcf_fabric_name.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) &device_attr_fcoe_fcf_switch_name.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) &device_attr_fcoe_fcf_dev_loss_tmo.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) &device_attr_fcoe_fcf_fc_map.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) &device_attr_fcoe_fcf_vfid.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) &device_attr_fcoe_fcf_mac.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) &device_attr_fcoe_fcf_priority.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) &device_attr_fcoe_fcf_fka_period.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) &device_attr_fcoe_fcf_state.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) &device_attr_fcoe_fcf_selected.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) &device_attr_fcoe_fcf_vlan_id.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) NULL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) static struct attribute_group fcoe_fcf_attr_group = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) .attrs = fcoe_fcf_attrs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) static const struct attribute_group *fcoe_fcf_attr_groups[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) &fcoe_fcf_attr_group,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) static struct bus_type fcoe_bus_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) static int fcoe_bus_match(struct device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) struct device_driver *drv)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) if (dev->bus == &fcoe_bus_type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) * fcoe_ctlr_device_release() - Release the FIP ctlr memory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) * @dev: Pointer to the FIP ctlr's embedded device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) * Called when the last FIP ctlr reference is released.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) static void fcoe_ctlr_device_release(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) struct fcoe_ctlr_device *ctlr = dev_to_ctlr(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) kfree(ctlr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) * fcoe_fcf_device_release() - Release the FIP fcf memory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) * @dev: Pointer to the fcf's embedded device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) * Called when the last FIP fcf reference is released.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) static void fcoe_fcf_device_release(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) struct fcoe_fcf_device *fcf = dev_to_fcf(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) kfree(fcf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) static const struct device_type fcoe_ctlr_device_type = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) .name = "fcoe_ctlr",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) .groups = fcoe_ctlr_attr_groups,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) .release = fcoe_ctlr_device_release,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) static const struct device_type fcoe_fcf_device_type = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) .name = "fcoe_fcf",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) .groups = fcoe_fcf_attr_groups,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) .release = fcoe_fcf_device_release,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) static ssize_t ctlr_create_store(struct bus_type *bus, const char *buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) size_t count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) return fcoe_ctlr_create_store(bus, buf, count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) static BUS_ATTR_WO(ctlr_create);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) static ssize_t ctlr_destroy_store(struct bus_type *bus, const char *buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) size_t count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) return fcoe_ctlr_destroy_store(bus, buf, count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) static BUS_ATTR_WO(ctlr_destroy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) static struct attribute *fcoe_bus_attrs[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) &bus_attr_ctlr_create.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) &bus_attr_ctlr_destroy.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) ATTRIBUTE_GROUPS(fcoe_bus);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) static struct bus_type fcoe_bus_type = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) .name = "fcoe",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685) .match = &fcoe_bus_match,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) .bus_groups = fcoe_bus_groups,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) * fcoe_ctlr_device_flush_work() - Flush a FIP ctlr's workqueue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) * @ctlr: Pointer to the FIP ctlr whose workqueue is to be flushed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) static void fcoe_ctlr_device_flush_work(struct fcoe_ctlr_device *ctlr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) if (!fcoe_ctlr_work_q(ctlr)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) printk(KERN_ERR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697) "ERROR: FIP Ctlr '%d' attempted to flush work, "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) "when no workqueue created.\n", ctlr->id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) dump_stack();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) flush_workqueue(fcoe_ctlr_work_q(ctlr));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) * fcoe_ctlr_device_queue_work() - Schedule work for a FIP ctlr's workqueue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) * @ctlr: Pointer to the FIP ctlr who owns the devloss workqueue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) * @work: Work to queue for execution
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) * Return value:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) * 1 on success / 0 already queued / < 0 for error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714) static int fcoe_ctlr_device_queue_work(struct fcoe_ctlr_device *ctlr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715) struct work_struct *work)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) if (unlikely(!fcoe_ctlr_work_q(ctlr))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) printk(KERN_ERR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719) "ERROR: FIP Ctlr '%d' attempted to queue work, "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) "when no workqueue created.\n", ctlr->id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) dump_stack();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726) return queue_work(fcoe_ctlr_work_q(ctlr), work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730) * fcoe_ctlr_device_flush_devloss() - Flush a FIP ctlr's devloss workqueue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731) * @ctlr: Pointer to FIP ctlr whose workqueue is to be flushed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733) static void fcoe_ctlr_device_flush_devloss(struct fcoe_ctlr_device *ctlr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735) if (!fcoe_ctlr_devloss_work_q(ctlr)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736) printk(KERN_ERR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737) "ERROR: FIP Ctlr '%d' attempted to flush work, "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738) "when no workqueue created.\n", ctlr->id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739) dump_stack();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743) flush_workqueue(fcoe_ctlr_devloss_work_q(ctlr));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747) * fcoe_ctlr_device_queue_devloss_work() - Schedule work for a FIP ctlr's devloss workqueue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748) * @ctlr: Pointer to the FIP ctlr who owns the devloss workqueue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 749) * @work: Work to queue for execution
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750) * @delay: jiffies to delay the work queuing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752) * Return value:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753) * 1 on success / 0 already queued / < 0 for error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755) static int fcoe_ctlr_device_queue_devloss_work(struct fcoe_ctlr_device *ctlr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 756) struct delayed_work *work,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 757) unsigned long delay)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 758) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 759) if (unlikely(!fcoe_ctlr_devloss_work_q(ctlr))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 760) printk(KERN_ERR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 761) "ERROR: FIP Ctlr '%d' attempted to queue work, "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 762) "when no workqueue created.\n", ctlr->id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 763) dump_stack();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 764)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 765) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 766) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 767)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 768) return queue_delayed_work(fcoe_ctlr_devloss_work_q(ctlr), work, delay);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 769) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 770)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 771) static int fcoe_fcf_device_match(struct fcoe_fcf_device *new,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 772) struct fcoe_fcf_device *old)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 773) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 774) if (new->switch_name == old->switch_name &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 775) new->fabric_name == old->fabric_name &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 776) new->fc_map == old->fc_map &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 777) ether_addr_equal(new->mac, old->mac))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 778) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 779) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 780) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 781)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 782) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 783) * fcoe_ctlr_device_add() - Add a FIP ctlr to sysfs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 784) * @parent: The parent device to which the fcoe_ctlr instance
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 785) * should be attached
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 786) * @f: The LLD's FCoE sysfs function template pointer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 787) * @priv_size: Size to be allocated with the fcoe_ctlr_device for the LLD
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 788) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 789) * This routine allocates a FIP ctlr object with some additional memory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 790) * for the LLD. The FIP ctlr is initialized, added to sysfs and then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 791) * attributes are added to it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 792) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 793) struct fcoe_ctlr_device *fcoe_ctlr_device_add(struct device *parent,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 794) struct fcoe_sysfs_function_template *f,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 795) int priv_size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 796) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 797) struct fcoe_ctlr_device *ctlr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 798) int error = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 799)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 800) ctlr = kzalloc(sizeof(struct fcoe_ctlr_device) + priv_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 801) GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 802) if (!ctlr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 803) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 804)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 805) ctlr->id = atomic_inc_return(&ctlr_num) - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 806) ctlr->f = f;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 807) ctlr->mode = FIP_CONN_TYPE_FABRIC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 808) INIT_LIST_HEAD(&ctlr->fcfs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 809) mutex_init(&ctlr->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 810) ctlr->dev.parent = parent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 811) ctlr->dev.bus = &fcoe_bus_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 812) ctlr->dev.type = &fcoe_ctlr_device_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 813)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 814) ctlr->fcf_dev_loss_tmo = fcoe_fcf_dev_loss_tmo;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 815)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 816) snprintf(ctlr->work_q_name, sizeof(ctlr->work_q_name),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 817) "ctlr_wq_%d", ctlr->id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 818) ctlr->work_q = create_singlethread_workqueue(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 819) ctlr->work_q_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 820) if (!ctlr->work_q)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 821) goto out_del;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 822)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 823) snprintf(ctlr->devloss_work_q_name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 824) sizeof(ctlr->devloss_work_q_name),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 825) "ctlr_dl_wq_%d", ctlr->id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 826) ctlr->devloss_work_q = create_singlethread_workqueue(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 827) ctlr->devloss_work_q_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 828) if (!ctlr->devloss_work_q)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 829) goto out_del_q;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 830)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 831) dev_set_name(&ctlr->dev, "ctlr_%d", ctlr->id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 832) error = device_register(&ctlr->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 833) if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 834) goto out_del_q2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 835)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 836) return ctlr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 837)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 838) out_del_q2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 839) destroy_workqueue(ctlr->devloss_work_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 840) ctlr->devloss_work_q = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 841) out_del_q:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 842) destroy_workqueue(ctlr->work_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 843) ctlr->work_q = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 844) out_del:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 845) kfree(ctlr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 846) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 847) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 848) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 849) EXPORT_SYMBOL_GPL(fcoe_ctlr_device_add);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 850)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 851) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 852) * fcoe_ctlr_device_delete() - Delete a FIP ctlr and its subtree from sysfs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 853) * @ctlr: A pointer to the ctlr to be deleted
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 854) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 855) * Deletes a FIP ctlr and any fcfs attached
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 856) * to it. Deleting fcfs will cause their childen
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 857) * to be deleted as well.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 858) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 859) * The ctlr is detached from sysfs and it's resources
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 860) * are freed (work q), but the memory is not freed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 861) * until its last reference is released.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 862) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 863) * This routine expects no locks to be held before
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 864) * calling.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 865) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 866) * TODO: Currently there are no callbacks to clean up LLD data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 867) * for a fcoe_fcf_device. LLDs must keep this in mind as they need
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 868) * to clean up each of their LLD data for all fcoe_fcf_device before
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 869) * calling fcoe_ctlr_device_delete.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 870) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 871) void fcoe_ctlr_device_delete(struct fcoe_ctlr_device *ctlr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 872) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 873) struct fcoe_fcf_device *fcf, *next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 874) /* Remove any attached fcfs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 875) mutex_lock(&ctlr->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 876) list_for_each_entry_safe(fcf, next,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 877) &ctlr->fcfs, peers) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 878) list_del(&fcf->peers);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 879) fcf->state = FCOE_FCF_STATE_DELETED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 880) fcoe_ctlr_device_queue_work(ctlr, &fcf->delete_work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 881) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 882) mutex_unlock(&ctlr->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 883)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 884) fcoe_ctlr_device_flush_work(ctlr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 885)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 886) destroy_workqueue(ctlr->devloss_work_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 887) ctlr->devloss_work_q = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 888) destroy_workqueue(ctlr->work_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 889) ctlr->work_q = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 890)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 891) device_unregister(&ctlr->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 892) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 893) EXPORT_SYMBOL_GPL(fcoe_ctlr_device_delete);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 894)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 895) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 896) * fcoe_fcf_device_final_delete() - Final delete routine
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 897) * @work: The FIP fcf's embedded work struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 898) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 899) * It is expected that the fcf has been removed from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 900) * the FIP ctlr's list before calling this routine.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 901) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 902) static void fcoe_fcf_device_final_delete(struct work_struct *work)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 903) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 904) struct fcoe_fcf_device *fcf =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 905) container_of(work, struct fcoe_fcf_device, delete_work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 906) struct fcoe_ctlr_device *ctlr = fcoe_fcf_dev_to_ctlr_dev(fcf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 907)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 908) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 909) * Cancel any outstanding timers. These should really exist
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 910) * only when rmmod'ing the LLDD and we're asking for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 911) * immediate termination of the rports
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 912) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 913) if (!cancel_delayed_work(&fcf->dev_loss_work))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 914) fcoe_ctlr_device_flush_devloss(ctlr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 915)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 916) device_unregister(&fcf->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 917) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 918)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 919) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 920) * fip_timeout_deleted_fcf() - Delete a fcf when the devloss timer fires
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 921) * @work: The FIP fcf's embedded work struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 922) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 923) * Removes the fcf from the FIP ctlr's list of fcfs and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 924) * queues the final deletion.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 925) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 926) static void fip_timeout_deleted_fcf(struct work_struct *work)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 927) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 928) struct fcoe_fcf_device *fcf =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 929) container_of(work, struct fcoe_fcf_device, dev_loss_work.work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 930) struct fcoe_ctlr_device *ctlr = fcoe_fcf_dev_to_ctlr_dev(fcf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 931)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 932) mutex_lock(&ctlr->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 933)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 934) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 935) * If the fcf is deleted or reconnected before the timer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 936) * fires the devloss queue will be flushed, but the state will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 937) * either be CONNECTED or DELETED. If that is the case we
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 938) * cancel deleting the fcf.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 939) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 940) if (fcf->state != FCOE_FCF_STATE_DISCONNECTED)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 941) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 942)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 943) dev_printk(KERN_ERR, &fcf->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 944) "FIP fcf connection time out: removing fcf\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 945)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 946) list_del(&fcf->peers);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 947) fcf->state = FCOE_FCF_STATE_DELETED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 948) fcoe_ctlr_device_queue_work(ctlr, &fcf->delete_work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 949)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 950) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 951) mutex_unlock(&ctlr->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 952) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 953)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 954) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 955) * fcoe_fcf_device_delete() - Delete a FIP fcf
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 956) * @fcf: Pointer to the fcf which is to be deleted
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 957) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 958) * Queues the FIP fcf on the devloss workqueue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 959) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 960) * Expects the ctlr_attrs mutex to be held for fcf
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 961) * state change.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 962) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 963) void fcoe_fcf_device_delete(struct fcoe_fcf_device *fcf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 964) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 965) struct fcoe_ctlr_device *ctlr = fcoe_fcf_dev_to_ctlr_dev(fcf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 966) int timeout = fcf->dev_loss_tmo;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 967)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 968) if (fcf->state != FCOE_FCF_STATE_CONNECTED)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 969) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 970)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 971) fcf->state = FCOE_FCF_STATE_DISCONNECTED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 972)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 973) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 974) * FCF will only be re-connected by the LLD calling
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 975) * fcoe_fcf_device_add, and it should be setting up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 976) * priv then.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 977) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 978) fcf->priv = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 979)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 980) fcoe_ctlr_device_queue_devloss_work(ctlr, &fcf->dev_loss_work,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 981) timeout * HZ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 982) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 983) EXPORT_SYMBOL_GPL(fcoe_fcf_device_delete);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 984)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 985) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 986) * fcoe_fcf_device_add() - Add a FCoE sysfs fcoe_fcf_device to the system
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 987) * @ctlr: The fcoe_ctlr_device that will be the fcoe_fcf_device parent
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 988) * @new_fcf: A temporary FCF used for lookups on the current list of fcfs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 989) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 990) * Expects to be called with the ctlr->lock held
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 991) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 992) struct fcoe_fcf_device *fcoe_fcf_device_add(struct fcoe_ctlr_device *ctlr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 993) struct fcoe_fcf_device *new_fcf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 994) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 995) struct fcoe_fcf_device *fcf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 996) int error = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 997)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 998) list_for_each_entry(fcf, &ctlr->fcfs, peers) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 999) if (fcoe_fcf_device_match(new_fcf, fcf)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1000) if (fcf->state == FCOE_FCF_STATE_CONNECTED)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1001) return fcf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1002)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1003) fcf->state = FCOE_FCF_STATE_CONNECTED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1004)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1005) if (!cancel_delayed_work(&fcf->dev_loss_work))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1006) fcoe_ctlr_device_flush_devloss(ctlr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1007)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1008) return fcf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1009) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1010) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1011)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1012) fcf = kzalloc(sizeof(struct fcoe_fcf_device), GFP_ATOMIC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1013) if (unlikely(!fcf))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1014) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1015)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1016) INIT_WORK(&fcf->delete_work, fcoe_fcf_device_final_delete);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1017) INIT_DELAYED_WORK(&fcf->dev_loss_work, fip_timeout_deleted_fcf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1018)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1019) fcf->dev.parent = &ctlr->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1020) fcf->dev.bus = &fcoe_bus_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1021) fcf->dev.type = &fcoe_fcf_device_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1022) fcf->id = atomic_inc_return(&fcf_num) - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1023) fcf->state = FCOE_FCF_STATE_UNKNOWN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1024)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1025) fcf->dev_loss_tmo = ctlr->fcf_dev_loss_tmo;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1026)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1027) dev_set_name(&fcf->dev, "fcf_%d", fcf->id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1028)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1029) fcf->fabric_name = new_fcf->fabric_name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1030) fcf->switch_name = new_fcf->switch_name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1031) fcf->fc_map = new_fcf->fc_map;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1032) fcf->vfid = new_fcf->vfid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1033) memcpy(fcf->mac, new_fcf->mac, ETH_ALEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1034) fcf->priority = new_fcf->priority;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1035) fcf->fka_period = new_fcf->fka_period;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1036) fcf->selected = new_fcf->selected;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1037)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1038) error = device_register(&fcf->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1039) if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1040) goto out_del;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1041)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1042) fcf->state = FCOE_FCF_STATE_CONNECTED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1043) list_add_tail(&fcf->peers, &ctlr->fcfs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1044)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1045) return fcf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1046)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1047) out_del:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1048) kfree(fcf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1049) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1050) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1051) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1052) EXPORT_SYMBOL_GPL(fcoe_fcf_device_add);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1053)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1054) int __init fcoe_sysfs_setup(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1055) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1056) atomic_set(&ctlr_num, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1057) atomic_set(&fcf_num, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1058)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1059) return bus_register(&fcoe_bus_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1060) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1061)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1062) void __exit fcoe_sysfs_teardown(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1063) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1064) bus_unregister(&fcoe_bus_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1065) }