xhci: Add completion code to the debug ouput of unhandled transfer events
[deliverable/linux.git] / drivers / target / target_core_configfs.c
index 79f9296a08ae7195d859c5ba200b2b990f78c0de..75d89adfccc025f7fa862c5c7aba157113b001ea 100644 (file)
 #include "target_core_rd.h"
 #include "target_core_xcopy.h"
 
+#define TB_CIT_SETUP(_name, _item_ops, _group_ops, _attrs)             \
+static void target_core_setup_##_name##_cit(struct se_subsystem_api *sa) \
+{                                                                      \
+       struct target_backend_cits *tbc = &sa->tb_cits;                 \
+       struct config_item_type *cit = &tbc->tb_##_name##_cit;          \
+                                                                       \
+       cit->ct_item_ops = _item_ops;                                   \
+       cit->ct_group_ops = _group_ops;                                 \
+       cit->ct_attrs = _attrs;                                         \
+       cit->ct_owner = sa->owner;                                      \
+       pr_debug("Setup generic %s\n", __stringify(_name));             \
+}
+
 extern struct t10_alua_lu_gp *default_lu_gp;
 
 static LIST_HEAD(g_tf_list);
@@ -126,48 +139,57 @@ static struct config_group *target_core_register_fabric(
 
        pr_debug("Target_Core_ConfigFS: REGISTER -> group: %p name:"
                        " %s\n", group, name);
-       /*
-        * Below are some hardcoded request_module() calls to automatically
-        * local fabric modules when the following is called:
-        *
-        * mkdir -p /sys/kernel/config/target/$MODULE_NAME
-        *
-        * Note that this does not limit which TCM fabric module can be
-        * registered, but simply provids auto loading logic for modules with
-        * mkdir(2) system calls with known TCM fabric modules.
-        */
-       if (!strncmp(name, "iscsi", 5)) {
+
+       tf = target_core_get_fabric(name);
+       if (!tf) {
+               pr_err("target_core_register_fabric() trying autoload for %s\n",
+                       name);
+
                /*
-                * Automatically load the LIO Target fabric module when the
-                * following is called:
+                * Below are some hardcoded request_module() calls to automatically
+                * local fabric modules when the following is called:
                 *
-                * mkdir -p $CONFIGFS/target/iscsi
-                */
-               ret = request_module("iscsi_target_mod");
-               if (ret < 0) {
-                       pr_err("request_module() failed for"
-                               " iscsi_target_mod.ko: %d\n", ret);
-                       return ERR_PTR(-EINVAL);
-               }
-       } else if (!strncmp(name, "loopback", 8)) {
-               /*
-                * Automatically load the tcm_loop fabric module when the
-                * following is called:
+                * mkdir -p /sys/kernel/config/target/$MODULE_NAME
                 *
-                * mkdir -p $CONFIGFS/target/loopback
+                * Note that this does not limit which TCM fabric module can be
+                * registered, but simply provids auto loading logic for modules with
+                * mkdir(2) system calls with known TCM fabric modules.
                 */
-               ret = request_module("tcm_loop");
-               if (ret < 0) {
-                       pr_err("request_module() failed for"
-                               " tcm_loop.ko: %d\n", ret);
-                       return ERR_PTR(-EINVAL);
+
+               if (!strncmp(name, "iscsi", 5)) {
+                       /*
+                        * Automatically load the LIO Target fabric module when the
+                        * following is called:
+                        *
+                        * mkdir -p $CONFIGFS/target/iscsi
+                        */
+                       ret = request_module("iscsi_target_mod");
+                       if (ret < 0) {
+                               pr_err("request_module() failed for"
+                                      " iscsi_target_mod.ko: %d\n", ret);
+                               return ERR_PTR(-EINVAL);
+                       }
+               } else if (!strncmp(name, "loopback", 8)) {
+                       /*
+                        * Automatically load the tcm_loop fabric module when the
+                        * following is called:
+                        *
+                        * mkdir -p $CONFIGFS/target/loopback
+                        */
+                       ret = request_module("tcm_loop");
+                       if (ret < 0) {
+                               pr_err("request_module() failed for"
+                                      " tcm_loop.ko: %d\n", ret);
+                               return ERR_PTR(-EINVAL);
+                       }
                }
+
+               tf = target_core_get_fabric(name);
        }
 
-       tf = target_core_get_fabric(name);
        if (!tf) {
                pr_err("target_core_get_fabric() failed for %s\n",
-                       name);
+                      name);
                return ERR_PTR(-EINVAL);
        }
        pr_debug("Target_Core_ConfigFS: REGISTER -> Located fabric:"
@@ -562,198 +584,21 @@ EXPORT_SYMBOL(target_fabric_configfs_deregister);
 // Stop functions called by external Target Fabrics Modules
 //############################################################################*/
 
-/* Start functions for struct config_item_type target_core_dev_attrib_cit */
-
-#define DEF_DEV_ATTRIB_SHOW(_name)                                     \
-static ssize_t target_core_dev_show_attr_##_name(                      \
-       struct se_dev_attrib *da,                                       \
-       char *page)                                                     \
-{                                                                      \
-       return snprintf(page, PAGE_SIZE, "%u\n",                        \
-               (u32)da->da_dev->dev_attrib._name);                     \
-}
-
-#define DEF_DEV_ATTRIB_STORE(_name)                                    \
-static ssize_t target_core_dev_store_attr_##_name(                     \
-       struct se_dev_attrib *da,                                       \
-       const char *page,                                               \
-       size_t count)                                                   \
-{                                                                      \
-       unsigned long val;                                              \
-       int ret;                                                        \
-                                                                       \
-       ret = kstrtoul(page, 0, &val);                          \
-       if (ret < 0) {                                                  \
-               pr_err("kstrtoul() failed with"         \
-                       " ret: %d\n", ret);                             \
-               return -EINVAL;                                         \
-       }                                                               \
-       ret = se_dev_set_##_name(da->da_dev, (u32)val);                 \
-                                                                       \
-       return (!ret) ? count : -EINVAL;                                \
-}
-
-#define DEF_DEV_ATTRIB(_name)                                          \
-DEF_DEV_ATTRIB_SHOW(_name);                                            \
-DEF_DEV_ATTRIB_STORE(_name);
-
-#define DEF_DEV_ATTRIB_RO(_name)                                       \
-DEF_DEV_ATTRIB_SHOW(_name);
+/* Start functions for struct config_item_type tb_dev_attrib_cit */
 
 CONFIGFS_EATTR_STRUCT(target_core_dev_attrib, se_dev_attrib);
-#define SE_DEV_ATTR(_name, _mode)                                      \
-static struct target_core_dev_attrib_attribute                         \
-                       target_core_dev_attrib_##_name =                \
-               __CONFIGFS_EATTR(_name, _mode,                          \
-               target_core_dev_show_attr_##_name,                      \
-               target_core_dev_store_attr_##_name);
-
-#define SE_DEV_ATTR_RO(_name);                                         \
-static struct target_core_dev_attrib_attribute                         \
-                       target_core_dev_attrib_##_name =                \
-       __CONFIGFS_EATTR_RO(_name,                                      \
-       target_core_dev_show_attr_##_name);
-
-DEF_DEV_ATTRIB(emulate_model_alias);
-SE_DEV_ATTR(emulate_model_alias, S_IRUGO | S_IWUSR);
-
-DEF_DEV_ATTRIB(emulate_dpo);
-SE_DEV_ATTR(emulate_dpo, S_IRUGO | S_IWUSR);
-
-DEF_DEV_ATTRIB(emulate_fua_write);
-SE_DEV_ATTR(emulate_fua_write, S_IRUGO | S_IWUSR);
-
-DEF_DEV_ATTRIB(emulate_fua_read);
-SE_DEV_ATTR(emulate_fua_read, S_IRUGO | S_IWUSR);
-
-DEF_DEV_ATTRIB(emulate_write_cache);
-SE_DEV_ATTR(emulate_write_cache, S_IRUGO | S_IWUSR);
-
-DEF_DEV_ATTRIB(emulate_ua_intlck_ctrl);
-SE_DEV_ATTR(emulate_ua_intlck_ctrl, S_IRUGO | S_IWUSR);
-
-DEF_DEV_ATTRIB(emulate_tas);
-SE_DEV_ATTR(emulate_tas, S_IRUGO | S_IWUSR);
-
-DEF_DEV_ATTRIB(emulate_tpu);
-SE_DEV_ATTR(emulate_tpu, S_IRUGO | S_IWUSR);
-
-DEF_DEV_ATTRIB(emulate_tpws);
-SE_DEV_ATTR(emulate_tpws, S_IRUGO | S_IWUSR);
-
-DEF_DEV_ATTRIB(emulate_caw);
-SE_DEV_ATTR(emulate_caw, S_IRUGO | S_IWUSR);
-
-DEF_DEV_ATTRIB(emulate_3pc);
-SE_DEV_ATTR(emulate_3pc, S_IRUGO | S_IWUSR);
-
-DEF_DEV_ATTRIB(pi_prot_type);
-SE_DEV_ATTR(pi_prot_type, S_IRUGO | S_IWUSR);
-
-DEF_DEV_ATTRIB_RO(hw_pi_prot_type);
-SE_DEV_ATTR_RO(hw_pi_prot_type);
-
-DEF_DEV_ATTRIB(pi_prot_format);
-SE_DEV_ATTR(pi_prot_format, S_IRUGO | S_IWUSR);
-
-DEF_DEV_ATTRIB(enforce_pr_isids);
-SE_DEV_ATTR(enforce_pr_isids, S_IRUGO | S_IWUSR);
-
-DEF_DEV_ATTRIB(is_nonrot);
-SE_DEV_ATTR(is_nonrot, S_IRUGO | S_IWUSR);
-
-DEF_DEV_ATTRIB(emulate_rest_reord);
-SE_DEV_ATTR(emulate_rest_reord, S_IRUGO | S_IWUSR);
-
-DEF_DEV_ATTRIB(force_pr_aptpl);
-SE_DEV_ATTR(force_pr_aptpl, S_IRUGO | S_IWUSR);
-
-DEF_DEV_ATTRIB_RO(hw_block_size);
-SE_DEV_ATTR_RO(hw_block_size);
-
-DEF_DEV_ATTRIB(block_size);
-SE_DEV_ATTR(block_size, S_IRUGO | S_IWUSR);
-
-DEF_DEV_ATTRIB_RO(hw_max_sectors);
-SE_DEV_ATTR_RO(hw_max_sectors);
-
-DEF_DEV_ATTRIB(fabric_max_sectors);
-SE_DEV_ATTR(fabric_max_sectors, S_IRUGO | S_IWUSR);
-
-DEF_DEV_ATTRIB(optimal_sectors);
-SE_DEV_ATTR(optimal_sectors, S_IRUGO | S_IWUSR);
-
-DEF_DEV_ATTRIB_RO(hw_queue_depth);
-SE_DEV_ATTR_RO(hw_queue_depth);
-
-DEF_DEV_ATTRIB(queue_depth);
-SE_DEV_ATTR(queue_depth, S_IRUGO | S_IWUSR);
-
-DEF_DEV_ATTRIB(max_unmap_lba_count);
-SE_DEV_ATTR(max_unmap_lba_count, S_IRUGO | S_IWUSR);
-
-DEF_DEV_ATTRIB(max_unmap_block_desc_count);
-SE_DEV_ATTR(max_unmap_block_desc_count, S_IRUGO | S_IWUSR);
-
-DEF_DEV_ATTRIB(unmap_granularity);
-SE_DEV_ATTR(unmap_granularity, S_IRUGO | S_IWUSR);
-
-DEF_DEV_ATTRIB(unmap_granularity_alignment);
-SE_DEV_ATTR(unmap_granularity_alignment, S_IRUGO | S_IWUSR);
-
-DEF_DEV_ATTRIB(max_write_same_len);
-SE_DEV_ATTR(max_write_same_len, S_IRUGO | S_IWUSR);
-
 CONFIGFS_EATTR_OPS(target_core_dev_attrib, se_dev_attrib, da_group);
 
-static struct configfs_attribute *target_core_dev_attrib_attrs[] = {
-       &target_core_dev_attrib_emulate_model_alias.attr,
-       &target_core_dev_attrib_emulate_dpo.attr,
-       &target_core_dev_attrib_emulate_fua_write.attr,
-       &target_core_dev_attrib_emulate_fua_read.attr,
-       &target_core_dev_attrib_emulate_write_cache.attr,
-       &target_core_dev_attrib_emulate_ua_intlck_ctrl.attr,
-       &target_core_dev_attrib_emulate_tas.attr,
-       &target_core_dev_attrib_emulate_tpu.attr,
-       &target_core_dev_attrib_emulate_tpws.attr,
-       &target_core_dev_attrib_emulate_caw.attr,
-       &target_core_dev_attrib_emulate_3pc.attr,
-       &target_core_dev_attrib_pi_prot_type.attr,
-       &target_core_dev_attrib_hw_pi_prot_type.attr,
-       &target_core_dev_attrib_pi_prot_format.attr,
-       &target_core_dev_attrib_enforce_pr_isids.attr,
-       &target_core_dev_attrib_force_pr_aptpl.attr,
-       &target_core_dev_attrib_is_nonrot.attr,
-       &target_core_dev_attrib_emulate_rest_reord.attr,
-       &target_core_dev_attrib_hw_block_size.attr,
-       &target_core_dev_attrib_block_size.attr,
-       &target_core_dev_attrib_hw_max_sectors.attr,
-       &target_core_dev_attrib_fabric_max_sectors.attr,
-       &target_core_dev_attrib_optimal_sectors.attr,
-       &target_core_dev_attrib_hw_queue_depth.attr,
-       &target_core_dev_attrib_queue_depth.attr,
-       &target_core_dev_attrib_max_unmap_lba_count.attr,
-       &target_core_dev_attrib_max_unmap_block_desc_count.attr,
-       &target_core_dev_attrib_unmap_granularity.attr,
-       &target_core_dev_attrib_unmap_granularity_alignment.attr,
-       &target_core_dev_attrib_max_write_same_len.attr,
-       NULL,
-};
-
 static struct configfs_item_operations target_core_dev_attrib_ops = {
        .show_attribute         = target_core_dev_attrib_attr_show,
        .store_attribute        = target_core_dev_attrib_attr_store,
 };
 
-static struct config_item_type target_core_dev_attrib_cit = {
-       .ct_item_ops            = &target_core_dev_attrib_ops,
-       .ct_attrs               = target_core_dev_attrib_attrs,
-       .ct_owner               = THIS_MODULE,
-};
+TB_CIT_SETUP(dev_attrib, &target_core_dev_attrib_ops, NULL, NULL);
 
-/* End functions for struct config_item_type target_core_dev_attrib_cit */
+/* End functions for struct config_item_type tb_dev_attrib_cit */
 
-/*  Start functions for struct config_item_type target_core_dev_wwn_cit */
+/*  Start functions for struct config_item_type tb_dev_wwn_cit */
 
 CONFIGFS_EATTR_STRUCT(target_core_dev_wwn, t10_wwn);
 #define SE_DEV_WWN_ATTR(_name, _mode)                                  \
@@ -984,15 +829,11 @@ static struct configfs_item_operations target_core_dev_wwn_ops = {
        .store_attribute        = target_core_dev_wwn_attr_store,
 };
 
-static struct config_item_type target_core_dev_wwn_cit = {
-       .ct_item_ops            = &target_core_dev_wwn_ops,
-       .ct_attrs               = target_core_dev_wwn_attrs,
-       .ct_owner               = THIS_MODULE,
-};
+TB_CIT_SETUP(dev_wwn, &target_core_dev_wwn_ops, NULL, target_core_dev_wwn_attrs);
 
-/*  End functions for struct config_item_type target_core_dev_wwn_cit */
+/*  End functions for struct config_item_type tb_dev_wwn_cit */
 
-/*  Start functions for struct config_item_type target_core_dev_pr_cit */
+/*  Start functions for struct config_item_type tb_dev_pr_cit */
 
 CONFIGFS_EATTR_STRUCT(target_core_dev_pr, se_device);
 #define SE_DEV_PR_ATTR(_name, _mode)                                   \
@@ -1453,15 +1294,11 @@ static struct configfs_item_operations target_core_dev_pr_ops = {
        .store_attribute        = target_core_dev_pr_attr_store,
 };
 
-static struct config_item_type target_core_dev_pr_cit = {
-       .ct_item_ops            = &target_core_dev_pr_ops,
-       .ct_attrs               = target_core_dev_pr_attrs,
-       .ct_owner               = THIS_MODULE,
-};
+TB_CIT_SETUP(dev_pr, &target_core_dev_pr_ops, NULL, target_core_dev_pr_attrs);
 
-/*  End functions for struct config_item_type target_core_dev_pr_cit */
+/*  End functions for struct config_item_type tb_dev_pr_cit */
 
-/*  Start functions for struct config_item_type target_core_dev_cit */
+/*  Start functions for struct config_item_type tb_dev_cit */
 
 static ssize_t target_core_show_dev_info(void *p, char *page)
 {
@@ -1925,7 +1762,7 @@ static struct target_core_configfs_attribute target_core_attr_dev_lba_map = {
        .store  = target_core_store_dev_lba_map,
 };
 
-static struct configfs_attribute *lio_core_dev_attrs[] = {
+static struct configfs_attribute *target_core_dev_attrs[] = {
        &target_core_attr_dev_info.attr,
        &target_core_attr_dev_control.attr,
        &target_core_attr_dev_alias.attr,
@@ -1984,13 +1821,9 @@ static struct configfs_item_operations target_core_dev_item_ops = {
        .store_attribute        = target_core_dev_store,
 };
 
-static struct config_item_type target_core_dev_cit = {
-       .ct_item_ops            = &target_core_dev_item_ops,
-       .ct_attrs               = lio_core_dev_attrs,
-       .ct_owner               = THIS_MODULE,
-};
+TB_CIT_SETUP(dev, &target_core_dev_item_ops, NULL, target_core_dev_attrs);
 
-/* End functions for struct config_item_type target_core_dev_cit */
+/* End functions for struct config_item_type tb_dev_cit */
 
 /* Start functions for struct config_item_type target_core_alua_lu_gp_cit */
 
@@ -2670,7 +2503,7 @@ static struct config_item_type target_core_alua_tg_pt_gp_cit = {
 
 /* End functions for struct config_item_type target_core_alua_tg_pt_gp_cit */
 
-/* Start functions for struct config_item_type target_core_alua_tg_pt_gps_cit */
+/* Start functions for struct config_item_type tb_alua_tg_pt_gps_cit */
 
 static struct config_group *target_core_alua_create_tg_pt_gp(
        struct config_group *group,
@@ -2721,12 +2554,9 @@ static struct configfs_group_operations target_core_alua_tg_pt_gps_group_ops = {
        .drop_item              = &target_core_alua_drop_tg_pt_gp,
 };
 
-static struct config_item_type target_core_alua_tg_pt_gps_cit = {
-       .ct_group_ops           = &target_core_alua_tg_pt_gps_group_ops,
-       .ct_owner               = THIS_MODULE,
-};
+TB_CIT_SETUP(dev_alua_tg_pt_gps, NULL, &target_core_alua_tg_pt_gps_group_ops, NULL);
 
-/* End functions for struct config_item_type target_core_alua_tg_pt_gps_cit */
+/* End functions for struct config_item_type tb_alua_tg_pt_gps_cit */
 
 /* Start functions for struct config_item_type target_core_alua_cit */
 
@@ -2744,7 +2574,7 @@ static struct config_item_type target_core_alua_cit = {
 
 /* End functions for struct config_item_type target_core_alua_cit */
 
-/* Start functions for struct config_item_type target_core_stat_cit */
+/* Start functions for struct config_item_type tb_dev_stat_cit */
 
 static struct config_group *target_core_stat_mkdir(
        struct config_group *group,
@@ -2765,12 +2595,9 @@ static struct configfs_group_operations target_core_stat_group_ops = {
        .drop_item              = &target_core_stat_rmdir,
 };
 
-static struct config_item_type target_core_stat_cit = {
-       .ct_group_ops           = &target_core_stat_group_ops,
-       .ct_owner               = THIS_MODULE,
-};
+TB_CIT_SETUP(dev_stat, NULL, &target_core_stat_group_ops, NULL);
 
-/* End functions for struct config_item_type target_core_stat_cit */
+/* End functions for struct config_item_type tb_dev_stat_cit */
 
 /* Start functions for struct config_item_type target_core_hba_cit */
 
@@ -2806,17 +2633,17 @@ static struct config_group *target_core_make_subdev(
        if (!dev_cg->default_groups)
                goto out_free_device;
 
-       config_group_init_type_name(dev_cg, name, &target_core_dev_cit);
+       config_group_init_type_name(dev_cg, name, &t->tb_cits.tb_dev_cit);
        config_group_init_type_name(&dev->dev_attrib.da_group, "attrib",
-                       &target_core_dev_attrib_cit);
+                       &t->tb_cits.tb_dev_attrib_cit);
        config_group_init_type_name(&dev->dev_pr_group, "pr",
-                       &target_core_dev_pr_cit);
+                       &t->tb_cits.tb_dev_pr_cit);
        config_group_init_type_name(&dev->t10_wwn.t10_wwn_group, "wwn",
-                       &target_core_dev_wwn_cit);
+                       &t->tb_cits.tb_dev_wwn_cit);
        config_group_init_type_name(&dev->t10_alua.alua_tg_pt_gps_group,
-                       "alua", &target_core_alua_tg_pt_gps_cit);
+                       "alua", &t->tb_cits.tb_dev_alua_tg_pt_gps_cit);
        config_group_init_type_name(&dev->dev_stat_grps.stat_group,
-                       "statistics", &target_core_stat_cit);
+                       "statistics", &t->tb_cits.tb_dev_stat_cit);
 
        dev_cg->default_groups[0] = &dev->dev_attrib.da_group;
        dev_cg->default_groups[1] = &dev->dev_pr_group;
@@ -3110,6 +2937,17 @@ static struct config_item_type target_core_cit = {
 
 /* Stop functions for struct config_item_type target_core_hba_cit */
 
+void target_core_setup_sub_cits(struct se_subsystem_api *sa)
+{
+       target_core_setup_dev_cit(sa);
+       target_core_setup_dev_attrib_cit(sa);
+       target_core_setup_dev_pr_cit(sa);
+       target_core_setup_dev_wwn_cit(sa);
+       target_core_setup_dev_alua_tg_pt_gps_cit(sa);
+       target_core_setup_dev_stat_cit(sa);
+}
+EXPORT_SYMBOL(target_core_setup_sub_cits);
+
 static int __init target_core_init_configfs(void)
 {
        struct config_group *target_cg, *hba_cg = NULL, *alua_cg = NULL;
This page took 0.045684 seconds and 5 git commands to generate.