root/drivers/scsi/ufs/ufs-sysfs.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. ufschd_uic_link_state_to_string
  2. ufschd_ufs_dev_pwr_mode_to_string
  3. ufs_sysfs_pm_lvl_store
  4. rpm_lvl_show
  5. rpm_lvl_store
  6. rpm_target_dev_state_show
  7. rpm_target_link_state_show
  8. spm_lvl_show
  9. spm_lvl_store
  10. spm_target_dev_state_show
  11. spm_target_link_state_show
  12. ufshcd_auto_hibern8_update
  13. ufshcd_ahit_to_us
  14. ufshcd_us_to_ahit
  15. auto_hibern8_show
  16. auto_hibern8_store
  17. ufs_sysfs_read_desc_param
  18. dyn_cap_needed_attribute_show
  19. ufs_sysfs_add_nodes
  20. ufs_sysfs_remove_nodes

   1 // SPDX-License-Identifier: GPL-2.0
   2 // Copyright (C) 2018 Western Digital Corporation
   3 
   4 #include <linux/err.h>
   5 #include <linux/string.h>
   6 #include <linux/bitfield.h>
   7 #include <asm/unaligned.h>
   8 
   9 #include "ufs.h"
  10 #include "ufs-sysfs.h"
  11 
  12 static const char *ufschd_uic_link_state_to_string(
  13                         enum uic_link_state state)
  14 {
  15         switch (state) {
  16         case UIC_LINK_OFF_STATE:        return "OFF";
  17         case UIC_LINK_ACTIVE_STATE:     return "ACTIVE";
  18         case UIC_LINK_HIBERN8_STATE:    return "HIBERN8";
  19         default:                        return "UNKNOWN";
  20         }
  21 }
  22 
  23 static const char *ufschd_ufs_dev_pwr_mode_to_string(
  24                         enum ufs_dev_pwr_mode state)
  25 {
  26         switch (state) {
  27         case UFS_ACTIVE_PWR_MODE:       return "ACTIVE";
  28         case UFS_SLEEP_PWR_MODE:        return "SLEEP";
  29         case UFS_POWERDOWN_PWR_MODE:    return "POWERDOWN";
  30         default:                        return "UNKNOWN";
  31         }
  32 }
  33 
  34 static inline ssize_t ufs_sysfs_pm_lvl_store(struct device *dev,
  35                                              struct device_attribute *attr,
  36                                              const char *buf, size_t count,
  37                                              bool rpm)
  38 {
  39         struct ufs_hba *hba = dev_get_drvdata(dev);
  40         unsigned long flags, value;
  41 
  42         if (kstrtoul(buf, 0, &value))
  43                 return -EINVAL;
  44 
  45         if (value >= UFS_PM_LVL_MAX)
  46                 return -EINVAL;
  47 
  48         spin_lock_irqsave(hba->host->host_lock, flags);
  49         if (rpm)
  50                 hba->rpm_lvl = value;
  51         else
  52                 hba->spm_lvl = value;
  53         spin_unlock_irqrestore(hba->host->host_lock, flags);
  54         return count;
  55 }
  56 
  57 static ssize_t rpm_lvl_show(struct device *dev,
  58                 struct device_attribute *attr, char *buf)
  59 {
  60         struct ufs_hba *hba = dev_get_drvdata(dev);
  61 
  62         return sprintf(buf, "%d\n", hba->rpm_lvl);
  63 }
  64 
  65 static ssize_t rpm_lvl_store(struct device *dev,
  66                 struct device_attribute *attr, const char *buf, size_t count)
  67 {
  68         return ufs_sysfs_pm_lvl_store(dev, attr, buf, count, true);
  69 }
  70 
  71 static ssize_t rpm_target_dev_state_show(struct device *dev,
  72                 struct device_attribute *attr, char *buf)
  73 {
  74         struct ufs_hba *hba = dev_get_drvdata(dev);
  75 
  76         return sprintf(buf, "%s\n", ufschd_ufs_dev_pwr_mode_to_string(
  77                         ufs_pm_lvl_states[hba->rpm_lvl].dev_state));
  78 }
  79 
  80 static ssize_t rpm_target_link_state_show(struct device *dev,
  81                 struct device_attribute *attr, char *buf)
  82 {
  83         struct ufs_hba *hba = dev_get_drvdata(dev);
  84 
  85         return sprintf(buf, "%s\n", ufschd_uic_link_state_to_string(
  86                         ufs_pm_lvl_states[hba->rpm_lvl].link_state));
  87 }
  88 
  89 static ssize_t spm_lvl_show(struct device *dev,
  90                 struct device_attribute *attr, char *buf)
  91 {
  92         struct ufs_hba *hba = dev_get_drvdata(dev);
  93 
  94         return sprintf(buf, "%d\n", hba->spm_lvl);
  95 }
  96 
  97 static ssize_t spm_lvl_store(struct device *dev,
  98                 struct device_attribute *attr, const char *buf, size_t count)
  99 {
 100         return ufs_sysfs_pm_lvl_store(dev, attr, buf, count, false);
 101 }
 102 
 103 static ssize_t spm_target_dev_state_show(struct device *dev,
 104                 struct device_attribute *attr, char *buf)
 105 {
 106         struct ufs_hba *hba = dev_get_drvdata(dev);
 107 
 108         return sprintf(buf, "%s\n", ufschd_ufs_dev_pwr_mode_to_string(
 109                                 ufs_pm_lvl_states[hba->spm_lvl].dev_state));
 110 }
 111 
 112 static ssize_t spm_target_link_state_show(struct device *dev,
 113                 struct device_attribute *attr, char *buf)
 114 {
 115         struct ufs_hba *hba = dev_get_drvdata(dev);
 116 
 117         return sprintf(buf, "%s\n", ufschd_uic_link_state_to_string(
 118                                 ufs_pm_lvl_states[hba->spm_lvl].link_state));
 119 }
 120 
 121 static void ufshcd_auto_hibern8_update(struct ufs_hba *hba, u32 ahit)
 122 {
 123         unsigned long flags;
 124 
 125         if (!ufshcd_is_auto_hibern8_supported(hba))
 126                 return;
 127 
 128         spin_lock_irqsave(hba->host->host_lock, flags);
 129         if (hba->ahit != ahit)
 130                 hba->ahit = ahit;
 131         spin_unlock_irqrestore(hba->host->host_lock, flags);
 132         if (!pm_runtime_suspended(hba->dev)) {
 133                 pm_runtime_get_sync(hba->dev);
 134                 ufshcd_hold(hba, false);
 135                 ufshcd_auto_hibern8_enable(hba);
 136                 ufshcd_release(hba);
 137                 pm_runtime_put(hba->dev);
 138         }
 139 }
 140 
 141 /* Convert Auto-Hibernate Idle Timer register value to microseconds */
 142 static int ufshcd_ahit_to_us(u32 ahit)
 143 {
 144         int timer = FIELD_GET(UFSHCI_AHIBERN8_TIMER_MASK, ahit);
 145         int scale = FIELD_GET(UFSHCI_AHIBERN8_SCALE_MASK, ahit);
 146 
 147         for (; scale > 0; --scale)
 148                 timer *= UFSHCI_AHIBERN8_SCALE_FACTOR;
 149 
 150         return timer;
 151 }
 152 
 153 /* Convert microseconds to Auto-Hibernate Idle Timer register value */
 154 static u32 ufshcd_us_to_ahit(unsigned int timer)
 155 {
 156         unsigned int scale;
 157 
 158         for (scale = 0; timer > UFSHCI_AHIBERN8_TIMER_MASK; ++scale)
 159                 timer /= UFSHCI_AHIBERN8_SCALE_FACTOR;
 160 
 161         return FIELD_PREP(UFSHCI_AHIBERN8_TIMER_MASK, timer) |
 162                FIELD_PREP(UFSHCI_AHIBERN8_SCALE_MASK, scale);
 163 }
 164 
 165 static ssize_t auto_hibern8_show(struct device *dev,
 166                                  struct device_attribute *attr, char *buf)
 167 {
 168         struct ufs_hba *hba = dev_get_drvdata(dev);
 169 
 170         if (!ufshcd_is_auto_hibern8_supported(hba))
 171                 return -EOPNOTSUPP;
 172 
 173         return snprintf(buf, PAGE_SIZE, "%d\n", ufshcd_ahit_to_us(hba->ahit));
 174 }
 175 
 176 static ssize_t auto_hibern8_store(struct device *dev,
 177                                   struct device_attribute *attr,
 178                                   const char *buf, size_t count)
 179 {
 180         struct ufs_hba *hba = dev_get_drvdata(dev);
 181         unsigned int timer;
 182 
 183         if (!ufshcd_is_auto_hibern8_supported(hba))
 184                 return -EOPNOTSUPP;
 185 
 186         if (kstrtouint(buf, 0, &timer))
 187                 return -EINVAL;
 188 
 189         if (timer > UFSHCI_AHIBERN8_MAX)
 190                 return -EINVAL;
 191 
 192         ufshcd_auto_hibern8_update(hba, ufshcd_us_to_ahit(timer));
 193 
 194         return count;
 195 }
 196 
 197 static DEVICE_ATTR_RW(rpm_lvl);
 198 static DEVICE_ATTR_RO(rpm_target_dev_state);
 199 static DEVICE_ATTR_RO(rpm_target_link_state);
 200 static DEVICE_ATTR_RW(spm_lvl);
 201 static DEVICE_ATTR_RO(spm_target_dev_state);
 202 static DEVICE_ATTR_RO(spm_target_link_state);
 203 static DEVICE_ATTR_RW(auto_hibern8);
 204 
 205 static struct attribute *ufs_sysfs_ufshcd_attrs[] = {
 206         &dev_attr_rpm_lvl.attr,
 207         &dev_attr_rpm_target_dev_state.attr,
 208         &dev_attr_rpm_target_link_state.attr,
 209         &dev_attr_spm_lvl.attr,
 210         &dev_attr_spm_target_dev_state.attr,
 211         &dev_attr_spm_target_link_state.attr,
 212         &dev_attr_auto_hibern8.attr,
 213         NULL
 214 };
 215 
 216 static const struct attribute_group ufs_sysfs_default_group = {
 217         .attrs = ufs_sysfs_ufshcd_attrs,
 218 };
 219 
 220 static ssize_t ufs_sysfs_read_desc_param(struct ufs_hba *hba,
 221                                   enum desc_idn desc_id,
 222                                   u8 desc_index,
 223                                   u8 param_offset,
 224                                   u8 *sysfs_buf,
 225                                   u8 param_size)
 226 {
 227         u8 desc_buf[8] = {0};
 228         int ret;
 229 
 230         if (param_size > 8)
 231                 return -EINVAL;
 232 
 233         ret = ufshcd_read_desc_param(hba, desc_id, desc_index,
 234                                 param_offset, desc_buf, param_size);
 235         if (ret)
 236                 return -EINVAL;
 237         switch (param_size) {
 238         case 1:
 239                 ret = sprintf(sysfs_buf, "0x%02X\n", *desc_buf);
 240                 break;
 241         case 2:
 242                 ret = sprintf(sysfs_buf, "0x%04X\n",
 243                         get_unaligned_be16(desc_buf));
 244                 break;
 245         case 4:
 246                 ret = sprintf(sysfs_buf, "0x%08X\n",
 247                         get_unaligned_be32(desc_buf));
 248                 break;
 249         case 8:
 250                 ret = sprintf(sysfs_buf, "0x%016llX\n",
 251                         get_unaligned_be64(desc_buf));
 252                 break;
 253         }
 254 
 255         return ret;
 256 }
 257 
 258 #define UFS_DESC_PARAM(_name, _puname, _duname, _size)                  \
 259 static ssize_t _name##_show(struct device *dev,                         \
 260         struct device_attribute *attr, char *buf)                       \
 261 {                                                                       \
 262         struct ufs_hba *hba = dev_get_drvdata(dev);                     \
 263         return ufs_sysfs_read_desc_param(hba, QUERY_DESC_IDN_##_duname, \
 264                 0, _duname##_DESC_PARAM##_puname, buf, _size);          \
 265 }                                                                       \
 266 static DEVICE_ATTR_RO(_name)
 267 
 268 #define UFS_DEVICE_DESC_PARAM(_name, _uname, _size)                     \
 269         UFS_DESC_PARAM(_name, _uname, DEVICE, _size)
 270 
 271 UFS_DEVICE_DESC_PARAM(device_type, _DEVICE_TYPE, 1);
 272 UFS_DEVICE_DESC_PARAM(device_class, _DEVICE_CLASS, 1);
 273 UFS_DEVICE_DESC_PARAM(device_sub_class, _DEVICE_SUB_CLASS, 1);
 274 UFS_DEVICE_DESC_PARAM(protocol, _PRTCL, 1);
 275 UFS_DEVICE_DESC_PARAM(number_of_luns, _NUM_LU, 1);
 276 UFS_DEVICE_DESC_PARAM(number_of_wluns, _NUM_WLU, 1);
 277 UFS_DEVICE_DESC_PARAM(boot_enable, _BOOT_ENBL, 1);
 278 UFS_DEVICE_DESC_PARAM(descriptor_access_enable, _DESC_ACCSS_ENBL, 1);
 279 UFS_DEVICE_DESC_PARAM(initial_power_mode, _INIT_PWR_MODE, 1);
 280 UFS_DEVICE_DESC_PARAM(high_priority_lun, _HIGH_PR_LUN, 1);
 281 UFS_DEVICE_DESC_PARAM(secure_removal_type, _SEC_RMV_TYPE, 1);
 282 UFS_DEVICE_DESC_PARAM(support_security_lun, _SEC_LU, 1);
 283 UFS_DEVICE_DESC_PARAM(bkops_termination_latency, _BKOP_TERM_LT, 1);
 284 UFS_DEVICE_DESC_PARAM(initial_active_icc_level, _ACTVE_ICC_LVL, 1);
 285 UFS_DEVICE_DESC_PARAM(specification_version, _SPEC_VER, 2);
 286 UFS_DEVICE_DESC_PARAM(manufacturing_date, _MANF_DATE, 2);
 287 UFS_DEVICE_DESC_PARAM(manufacturer_id, _MANF_ID, 2);
 288 UFS_DEVICE_DESC_PARAM(rtt_capability, _RTT_CAP, 1);
 289 UFS_DEVICE_DESC_PARAM(rtc_update, _FRQ_RTC, 2);
 290 UFS_DEVICE_DESC_PARAM(ufs_features, _UFS_FEAT, 1);
 291 UFS_DEVICE_DESC_PARAM(ffu_timeout, _FFU_TMT, 1);
 292 UFS_DEVICE_DESC_PARAM(queue_depth, _Q_DPTH, 1);
 293 UFS_DEVICE_DESC_PARAM(device_version, _DEV_VER, 2);
 294 UFS_DEVICE_DESC_PARAM(number_of_secure_wpa, _NUM_SEC_WPA, 1);
 295 UFS_DEVICE_DESC_PARAM(psa_max_data_size, _PSA_MAX_DATA, 4);
 296 UFS_DEVICE_DESC_PARAM(psa_state_timeout, _PSA_TMT, 1);
 297 
 298 static struct attribute *ufs_sysfs_device_descriptor[] = {
 299         &dev_attr_device_type.attr,
 300         &dev_attr_device_class.attr,
 301         &dev_attr_device_sub_class.attr,
 302         &dev_attr_protocol.attr,
 303         &dev_attr_number_of_luns.attr,
 304         &dev_attr_number_of_wluns.attr,
 305         &dev_attr_boot_enable.attr,
 306         &dev_attr_descriptor_access_enable.attr,
 307         &dev_attr_initial_power_mode.attr,
 308         &dev_attr_high_priority_lun.attr,
 309         &dev_attr_secure_removal_type.attr,
 310         &dev_attr_support_security_lun.attr,
 311         &dev_attr_bkops_termination_latency.attr,
 312         &dev_attr_initial_active_icc_level.attr,
 313         &dev_attr_specification_version.attr,
 314         &dev_attr_manufacturing_date.attr,
 315         &dev_attr_manufacturer_id.attr,
 316         &dev_attr_rtt_capability.attr,
 317         &dev_attr_rtc_update.attr,
 318         &dev_attr_ufs_features.attr,
 319         &dev_attr_ffu_timeout.attr,
 320         &dev_attr_queue_depth.attr,
 321         &dev_attr_device_version.attr,
 322         &dev_attr_number_of_secure_wpa.attr,
 323         &dev_attr_psa_max_data_size.attr,
 324         &dev_attr_psa_state_timeout.attr,
 325         NULL,
 326 };
 327 
 328 static const struct attribute_group ufs_sysfs_device_descriptor_group = {
 329         .name = "device_descriptor",
 330         .attrs = ufs_sysfs_device_descriptor,
 331 };
 332 
 333 #define UFS_INTERCONNECT_DESC_PARAM(_name, _uname, _size)               \
 334         UFS_DESC_PARAM(_name, _uname, INTERCONNECT, _size)
 335 
 336 UFS_INTERCONNECT_DESC_PARAM(unipro_version, _UNIPRO_VER, 2);
 337 UFS_INTERCONNECT_DESC_PARAM(mphy_version, _MPHY_VER, 2);
 338 
 339 static struct attribute *ufs_sysfs_interconnect_descriptor[] = {
 340         &dev_attr_unipro_version.attr,
 341         &dev_attr_mphy_version.attr,
 342         NULL,
 343 };
 344 
 345 static const struct attribute_group ufs_sysfs_interconnect_descriptor_group = {
 346         .name = "interconnect_descriptor",
 347         .attrs = ufs_sysfs_interconnect_descriptor,
 348 };
 349 
 350 #define UFS_GEOMETRY_DESC_PARAM(_name, _uname, _size)                   \
 351         UFS_DESC_PARAM(_name, _uname, GEOMETRY, _size)
 352 
 353 UFS_GEOMETRY_DESC_PARAM(raw_device_capacity, _DEV_CAP, 8);
 354 UFS_GEOMETRY_DESC_PARAM(max_number_of_luns, _MAX_NUM_LUN, 1);
 355 UFS_GEOMETRY_DESC_PARAM(segment_size, _SEG_SIZE, 4);
 356 UFS_GEOMETRY_DESC_PARAM(allocation_unit_size, _ALLOC_UNIT_SIZE, 1);
 357 UFS_GEOMETRY_DESC_PARAM(min_addressable_block_size, _MIN_BLK_SIZE, 1);
 358 UFS_GEOMETRY_DESC_PARAM(optimal_read_block_size, _OPT_RD_BLK_SIZE, 1);
 359 UFS_GEOMETRY_DESC_PARAM(optimal_write_block_size, _OPT_WR_BLK_SIZE, 1);
 360 UFS_GEOMETRY_DESC_PARAM(max_in_buffer_size, _MAX_IN_BUF_SIZE, 1);
 361 UFS_GEOMETRY_DESC_PARAM(max_out_buffer_size, _MAX_OUT_BUF_SIZE, 1);
 362 UFS_GEOMETRY_DESC_PARAM(rpmb_rw_size, _RPMB_RW_SIZE, 1);
 363 UFS_GEOMETRY_DESC_PARAM(dyn_capacity_resource_policy, _DYN_CAP_RSRC_PLC, 1);
 364 UFS_GEOMETRY_DESC_PARAM(data_ordering, _DATA_ORDER, 1);
 365 UFS_GEOMETRY_DESC_PARAM(max_number_of_contexts, _MAX_NUM_CTX, 1);
 366 UFS_GEOMETRY_DESC_PARAM(sys_data_tag_unit_size, _TAG_UNIT_SIZE, 1);
 367 UFS_GEOMETRY_DESC_PARAM(sys_data_tag_resource_size, _TAG_RSRC_SIZE, 1);
 368 UFS_GEOMETRY_DESC_PARAM(secure_removal_types, _SEC_RM_TYPES, 1);
 369 UFS_GEOMETRY_DESC_PARAM(memory_types, _MEM_TYPES, 2);
 370 UFS_GEOMETRY_DESC_PARAM(sys_code_memory_max_alloc_units,
 371         _SCM_MAX_NUM_UNITS, 4);
 372 UFS_GEOMETRY_DESC_PARAM(sys_code_memory_capacity_adjustment_factor,
 373         _SCM_CAP_ADJ_FCTR, 2);
 374 UFS_GEOMETRY_DESC_PARAM(non_persist_memory_max_alloc_units,
 375         _NPM_MAX_NUM_UNITS, 4);
 376 UFS_GEOMETRY_DESC_PARAM(non_persist_memory_capacity_adjustment_factor,
 377         _NPM_CAP_ADJ_FCTR, 2);
 378 UFS_GEOMETRY_DESC_PARAM(enh1_memory_max_alloc_units,
 379         _ENM1_MAX_NUM_UNITS, 4);
 380 UFS_GEOMETRY_DESC_PARAM(enh1_memory_capacity_adjustment_factor,
 381         _ENM1_CAP_ADJ_FCTR, 2);
 382 UFS_GEOMETRY_DESC_PARAM(enh2_memory_max_alloc_units,
 383         _ENM2_MAX_NUM_UNITS, 4);
 384 UFS_GEOMETRY_DESC_PARAM(enh2_memory_capacity_adjustment_factor,
 385         _ENM2_CAP_ADJ_FCTR, 2);
 386 UFS_GEOMETRY_DESC_PARAM(enh3_memory_max_alloc_units,
 387         _ENM3_MAX_NUM_UNITS, 4);
 388 UFS_GEOMETRY_DESC_PARAM(enh3_memory_capacity_adjustment_factor,
 389         _ENM3_CAP_ADJ_FCTR, 2);
 390 UFS_GEOMETRY_DESC_PARAM(enh4_memory_max_alloc_units,
 391         _ENM4_MAX_NUM_UNITS, 4);
 392 UFS_GEOMETRY_DESC_PARAM(enh4_memory_capacity_adjustment_factor,
 393         _ENM4_CAP_ADJ_FCTR, 2);
 394 
 395 static struct attribute *ufs_sysfs_geometry_descriptor[] = {
 396         &dev_attr_raw_device_capacity.attr,
 397         &dev_attr_max_number_of_luns.attr,
 398         &dev_attr_segment_size.attr,
 399         &dev_attr_allocation_unit_size.attr,
 400         &dev_attr_min_addressable_block_size.attr,
 401         &dev_attr_optimal_read_block_size.attr,
 402         &dev_attr_optimal_write_block_size.attr,
 403         &dev_attr_max_in_buffer_size.attr,
 404         &dev_attr_max_out_buffer_size.attr,
 405         &dev_attr_rpmb_rw_size.attr,
 406         &dev_attr_dyn_capacity_resource_policy.attr,
 407         &dev_attr_data_ordering.attr,
 408         &dev_attr_max_number_of_contexts.attr,
 409         &dev_attr_sys_data_tag_unit_size.attr,
 410         &dev_attr_sys_data_tag_resource_size.attr,
 411         &dev_attr_secure_removal_types.attr,
 412         &dev_attr_memory_types.attr,
 413         &dev_attr_sys_code_memory_max_alloc_units.attr,
 414         &dev_attr_sys_code_memory_capacity_adjustment_factor.attr,
 415         &dev_attr_non_persist_memory_max_alloc_units.attr,
 416         &dev_attr_non_persist_memory_capacity_adjustment_factor.attr,
 417         &dev_attr_enh1_memory_max_alloc_units.attr,
 418         &dev_attr_enh1_memory_capacity_adjustment_factor.attr,
 419         &dev_attr_enh2_memory_max_alloc_units.attr,
 420         &dev_attr_enh2_memory_capacity_adjustment_factor.attr,
 421         &dev_attr_enh3_memory_max_alloc_units.attr,
 422         &dev_attr_enh3_memory_capacity_adjustment_factor.attr,
 423         &dev_attr_enh4_memory_max_alloc_units.attr,
 424         &dev_attr_enh4_memory_capacity_adjustment_factor.attr,
 425         NULL,
 426 };
 427 
 428 static const struct attribute_group ufs_sysfs_geometry_descriptor_group = {
 429         .name = "geometry_descriptor",
 430         .attrs = ufs_sysfs_geometry_descriptor,
 431 };
 432 
 433 #define UFS_HEALTH_DESC_PARAM(_name, _uname, _size)                     \
 434         UFS_DESC_PARAM(_name, _uname, HEALTH, _size)
 435 
 436 UFS_HEALTH_DESC_PARAM(eol_info, _EOL_INFO, 1);
 437 UFS_HEALTH_DESC_PARAM(life_time_estimation_a, _LIFE_TIME_EST_A, 1);
 438 UFS_HEALTH_DESC_PARAM(life_time_estimation_b, _LIFE_TIME_EST_B, 1);
 439 
 440 static struct attribute *ufs_sysfs_health_descriptor[] = {
 441         &dev_attr_eol_info.attr,
 442         &dev_attr_life_time_estimation_a.attr,
 443         &dev_attr_life_time_estimation_b.attr,
 444         NULL,
 445 };
 446 
 447 static const struct attribute_group ufs_sysfs_health_descriptor_group = {
 448         .name = "health_descriptor",
 449         .attrs = ufs_sysfs_health_descriptor,
 450 };
 451 
 452 #define UFS_POWER_DESC_PARAM(_name, _uname, _index)                     \
 453 static ssize_t _name##_index##_show(struct device *dev,                 \
 454         struct device_attribute *attr, char *buf)                       \
 455 {                                                                       \
 456         struct ufs_hba *hba = dev_get_drvdata(dev);                     \
 457         return ufs_sysfs_read_desc_param(hba, QUERY_DESC_IDN_POWER, 0,  \
 458                 PWR_DESC##_uname##_0 + _index * 2, buf, 2);             \
 459 }                                                                       \
 460 static DEVICE_ATTR_RO(_name##_index)
 461 
 462 UFS_POWER_DESC_PARAM(active_icc_levels_vcc, _ACTIVE_LVLS_VCC, 0);
 463 UFS_POWER_DESC_PARAM(active_icc_levels_vcc, _ACTIVE_LVLS_VCC, 1);
 464 UFS_POWER_DESC_PARAM(active_icc_levels_vcc, _ACTIVE_LVLS_VCC, 2);
 465 UFS_POWER_DESC_PARAM(active_icc_levels_vcc, _ACTIVE_LVLS_VCC, 3);
 466 UFS_POWER_DESC_PARAM(active_icc_levels_vcc, _ACTIVE_LVLS_VCC, 4);
 467 UFS_POWER_DESC_PARAM(active_icc_levels_vcc, _ACTIVE_LVLS_VCC, 5);
 468 UFS_POWER_DESC_PARAM(active_icc_levels_vcc, _ACTIVE_LVLS_VCC, 6);
 469 UFS_POWER_DESC_PARAM(active_icc_levels_vcc, _ACTIVE_LVLS_VCC, 7);
 470 UFS_POWER_DESC_PARAM(active_icc_levels_vcc, _ACTIVE_LVLS_VCC, 8);
 471 UFS_POWER_DESC_PARAM(active_icc_levels_vcc, _ACTIVE_LVLS_VCC, 9);
 472 UFS_POWER_DESC_PARAM(active_icc_levels_vcc, _ACTIVE_LVLS_VCC, 10);
 473 UFS_POWER_DESC_PARAM(active_icc_levels_vcc, _ACTIVE_LVLS_VCC, 11);
 474 UFS_POWER_DESC_PARAM(active_icc_levels_vcc, _ACTIVE_LVLS_VCC, 12);
 475 UFS_POWER_DESC_PARAM(active_icc_levels_vcc, _ACTIVE_LVLS_VCC, 13);
 476 UFS_POWER_DESC_PARAM(active_icc_levels_vcc, _ACTIVE_LVLS_VCC, 14);
 477 UFS_POWER_DESC_PARAM(active_icc_levels_vcc, _ACTIVE_LVLS_VCC, 15);
 478 UFS_POWER_DESC_PARAM(active_icc_levels_vccq, _ACTIVE_LVLS_VCCQ, 0);
 479 UFS_POWER_DESC_PARAM(active_icc_levels_vccq, _ACTIVE_LVLS_VCCQ, 1);
 480 UFS_POWER_DESC_PARAM(active_icc_levels_vccq, _ACTIVE_LVLS_VCCQ, 2);
 481 UFS_POWER_DESC_PARAM(active_icc_levels_vccq, _ACTIVE_LVLS_VCCQ, 3);
 482 UFS_POWER_DESC_PARAM(active_icc_levels_vccq, _ACTIVE_LVLS_VCCQ, 4);
 483 UFS_POWER_DESC_PARAM(active_icc_levels_vccq, _ACTIVE_LVLS_VCCQ, 5);
 484 UFS_POWER_DESC_PARAM(active_icc_levels_vccq, _ACTIVE_LVLS_VCCQ, 6);
 485 UFS_POWER_DESC_PARAM(active_icc_levels_vccq, _ACTIVE_LVLS_VCCQ, 7);
 486 UFS_POWER_DESC_PARAM(active_icc_levels_vccq, _ACTIVE_LVLS_VCCQ, 8);
 487 UFS_POWER_DESC_PARAM(active_icc_levels_vccq, _ACTIVE_LVLS_VCCQ, 9);
 488 UFS_POWER_DESC_PARAM(active_icc_levels_vccq, _ACTIVE_LVLS_VCCQ, 10);
 489 UFS_POWER_DESC_PARAM(active_icc_levels_vccq, _ACTIVE_LVLS_VCCQ, 11);
 490 UFS_POWER_DESC_PARAM(active_icc_levels_vccq, _ACTIVE_LVLS_VCCQ, 12);
 491 UFS_POWER_DESC_PARAM(active_icc_levels_vccq, _ACTIVE_LVLS_VCCQ, 13);
 492 UFS_POWER_DESC_PARAM(active_icc_levels_vccq, _ACTIVE_LVLS_VCCQ, 14);
 493 UFS_POWER_DESC_PARAM(active_icc_levels_vccq, _ACTIVE_LVLS_VCCQ, 15);
 494 UFS_POWER_DESC_PARAM(active_icc_levels_vccq2, _ACTIVE_LVLS_VCCQ2, 0);
 495 UFS_POWER_DESC_PARAM(active_icc_levels_vccq2, _ACTIVE_LVLS_VCCQ2, 1);
 496 UFS_POWER_DESC_PARAM(active_icc_levels_vccq2, _ACTIVE_LVLS_VCCQ2, 2);
 497 UFS_POWER_DESC_PARAM(active_icc_levels_vccq2, _ACTIVE_LVLS_VCCQ2, 3);
 498 UFS_POWER_DESC_PARAM(active_icc_levels_vccq2, _ACTIVE_LVLS_VCCQ2, 4);
 499 UFS_POWER_DESC_PARAM(active_icc_levels_vccq2, _ACTIVE_LVLS_VCCQ2, 5);
 500 UFS_POWER_DESC_PARAM(active_icc_levels_vccq2, _ACTIVE_LVLS_VCCQ2, 6);
 501 UFS_POWER_DESC_PARAM(active_icc_levels_vccq2, _ACTIVE_LVLS_VCCQ2, 7);
 502 UFS_POWER_DESC_PARAM(active_icc_levels_vccq2, _ACTIVE_LVLS_VCCQ2, 8);
 503 UFS_POWER_DESC_PARAM(active_icc_levels_vccq2, _ACTIVE_LVLS_VCCQ2, 9);
 504 UFS_POWER_DESC_PARAM(active_icc_levels_vccq2, _ACTIVE_LVLS_VCCQ2, 10);
 505 UFS_POWER_DESC_PARAM(active_icc_levels_vccq2, _ACTIVE_LVLS_VCCQ2, 11);
 506 UFS_POWER_DESC_PARAM(active_icc_levels_vccq2, _ACTIVE_LVLS_VCCQ2, 12);
 507 UFS_POWER_DESC_PARAM(active_icc_levels_vccq2, _ACTIVE_LVLS_VCCQ2, 13);
 508 UFS_POWER_DESC_PARAM(active_icc_levels_vccq2, _ACTIVE_LVLS_VCCQ2, 14);
 509 UFS_POWER_DESC_PARAM(active_icc_levels_vccq2, _ACTIVE_LVLS_VCCQ2, 15);
 510 
 511 static struct attribute *ufs_sysfs_power_descriptor[] = {
 512         &dev_attr_active_icc_levels_vcc0.attr,
 513         &dev_attr_active_icc_levels_vcc1.attr,
 514         &dev_attr_active_icc_levels_vcc2.attr,
 515         &dev_attr_active_icc_levels_vcc3.attr,
 516         &dev_attr_active_icc_levels_vcc4.attr,
 517         &dev_attr_active_icc_levels_vcc5.attr,
 518         &dev_attr_active_icc_levels_vcc6.attr,
 519         &dev_attr_active_icc_levels_vcc7.attr,
 520         &dev_attr_active_icc_levels_vcc8.attr,
 521         &dev_attr_active_icc_levels_vcc9.attr,
 522         &dev_attr_active_icc_levels_vcc10.attr,
 523         &dev_attr_active_icc_levels_vcc11.attr,
 524         &dev_attr_active_icc_levels_vcc12.attr,
 525         &dev_attr_active_icc_levels_vcc13.attr,
 526         &dev_attr_active_icc_levels_vcc14.attr,
 527         &dev_attr_active_icc_levels_vcc15.attr,
 528         &dev_attr_active_icc_levels_vccq0.attr,
 529         &dev_attr_active_icc_levels_vccq1.attr,
 530         &dev_attr_active_icc_levels_vccq2.attr,
 531         &dev_attr_active_icc_levels_vccq3.attr,
 532         &dev_attr_active_icc_levels_vccq4.attr,
 533         &dev_attr_active_icc_levels_vccq5.attr,
 534         &dev_attr_active_icc_levels_vccq6.attr,
 535         &dev_attr_active_icc_levels_vccq7.attr,
 536         &dev_attr_active_icc_levels_vccq8.attr,
 537         &dev_attr_active_icc_levels_vccq9.attr,
 538         &dev_attr_active_icc_levels_vccq10.attr,
 539         &dev_attr_active_icc_levels_vccq11.attr,
 540         &dev_attr_active_icc_levels_vccq12.attr,
 541         &dev_attr_active_icc_levels_vccq13.attr,
 542         &dev_attr_active_icc_levels_vccq14.attr,
 543         &dev_attr_active_icc_levels_vccq15.attr,
 544         &dev_attr_active_icc_levels_vccq20.attr,
 545         &dev_attr_active_icc_levels_vccq21.attr,
 546         &dev_attr_active_icc_levels_vccq22.attr,
 547         &dev_attr_active_icc_levels_vccq23.attr,
 548         &dev_attr_active_icc_levels_vccq24.attr,
 549         &dev_attr_active_icc_levels_vccq25.attr,
 550         &dev_attr_active_icc_levels_vccq26.attr,
 551         &dev_attr_active_icc_levels_vccq27.attr,
 552         &dev_attr_active_icc_levels_vccq28.attr,
 553         &dev_attr_active_icc_levels_vccq29.attr,
 554         &dev_attr_active_icc_levels_vccq210.attr,
 555         &dev_attr_active_icc_levels_vccq211.attr,
 556         &dev_attr_active_icc_levels_vccq212.attr,
 557         &dev_attr_active_icc_levels_vccq213.attr,
 558         &dev_attr_active_icc_levels_vccq214.attr,
 559         &dev_attr_active_icc_levels_vccq215.attr,
 560         NULL,
 561 };
 562 
 563 static const struct attribute_group ufs_sysfs_power_descriptor_group = {
 564         .name = "power_descriptor",
 565         .attrs = ufs_sysfs_power_descriptor,
 566 };
 567 
 568 #define UFS_STRING_DESCRIPTOR(_name, _pname)                            \
 569 static ssize_t _name##_show(struct device *dev,                         \
 570         struct device_attribute *attr, char *buf)                       \
 571 {                                                                       \
 572         u8 index;                                                       \
 573         struct ufs_hba *hba = dev_get_drvdata(dev);                     \
 574         int ret;                                                        \
 575         int desc_len = QUERY_DESC_MAX_SIZE;                             \
 576         u8 *desc_buf;                                                   \
 577                                                                         \
 578         desc_buf = kzalloc(QUERY_DESC_MAX_SIZE, GFP_ATOMIC);            \
 579         if (!desc_buf)                                                  \
 580                 return -ENOMEM;                                         \
 581         ret = ufshcd_query_descriptor_retry(hba,                        \
 582                 UPIU_QUERY_OPCODE_READ_DESC, QUERY_DESC_IDN_DEVICE,     \
 583                 0, 0, desc_buf, &desc_len);                             \
 584         if (ret) {                                                      \
 585                 ret = -EINVAL;                                          \
 586                 goto out;                                               \
 587         }                                                               \
 588         index = desc_buf[DEVICE_DESC_PARAM##_pname];                    \
 589         kfree(desc_buf);                                                \
 590         desc_buf = NULL;                                                \
 591         ret = ufshcd_read_string_desc(hba, index, &desc_buf,            \
 592                                       SD_ASCII_STD);                    \
 593         if (ret < 0)                                                    \
 594                 goto out;                                               \
 595         ret = snprintf(buf, PAGE_SIZE, "%s\n", desc_buf);               \
 596 out:                                                                    \
 597         kfree(desc_buf);                                                \
 598         return ret;                                                     \
 599 }                                                                       \
 600 static DEVICE_ATTR_RO(_name)
 601 
 602 UFS_STRING_DESCRIPTOR(manufacturer_name, _MANF_NAME);
 603 UFS_STRING_DESCRIPTOR(product_name, _PRDCT_NAME);
 604 UFS_STRING_DESCRIPTOR(oem_id, _OEM_ID);
 605 UFS_STRING_DESCRIPTOR(serial_number, _SN);
 606 UFS_STRING_DESCRIPTOR(product_revision, _PRDCT_REV);
 607 
 608 static struct attribute *ufs_sysfs_string_descriptors[] = {
 609         &dev_attr_manufacturer_name.attr,
 610         &dev_attr_product_name.attr,
 611         &dev_attr_oem_id.attr,
 612         &dev_attr_serial_number.attr,
 613         &dev_attr_product_revision.attr,
 614         NULL,
 615 };
 616 
 617 static const struct attribute_group ufs_sysfs_string_descriptors_group = {
 618         .name = "string_descriptors",
 619         .attrs = ufs_sysfs_string_descriptors,
 620 };
 621 
 622 #define UFS_FLAG(_name, _uname)                                         \
 623 static ssize_t _name##_show(struct device *dev,                         \
 624         struct device_attribute *attr, char *buf)                       \
 625 {                                                                       \
 626         bool flag;                                                      \
 627         struct ufs_hba *hba = dev_get_drvdata(dev);                     \
 628         if (ufshcd_query_flag(hba, UPIU_QUERY_OPCODE_READ_FLAG,         \
 629                 QUERY_FLAG_IDN##_uname, &flag))                         \
 630                 return -EINVAL;                                         \
 631         return sprintf(buf, "%s\n", flag ? "true" : "false");           \
 632 }                                                                       \
 633 static DEVICE_ATTR_RO(_name)
 634 
 635 UFS_FLAG(device_init, _FDEVICEINIT);
 636 UFS_FLAG(permanent_wpe, _PERMANENT_WPE);
 637 UFS_FLAG(power_on_wpe, _PWR_ON_WPE);
 638 UFS_FLAG(bkops_enable, _BKOPS_EN);
 639 UFS_FLAG(life_span_mode_enable, _LIFE_SPAN_MODE_ENABLE);
 640 UFS_FLAG(phy_resource_removal, _FPHYRESOURCEREMOVAL);
 641 UFS_FLAG(busy_rtc, _BUSY_RTC);
 642 UFS_FLAG(disable_fw_update, _PERMANENTLY_DISABLE_FW_UPDATE);
 643 
 644 static struct attribute *ufs_sysfs_device_flags[] = {
 645         &dev_attr_device_init.attr,
 646         &dev_attr_permanent_wpe.attr,
 647         &dev_attr_power_on_wpe.attr,
 648         &dev_attr_bkops_enable.attr,
 649         &dev_attr_life_span_mode_enable.attr,
 650         &dev_attr_phy_resource_removal.attr,
 651         &dev_attr_busy_rtc.attr,
 652         &dev_attr_disable_fw_update.attr,
 653         NULL,
 654 };
 655 
 656 static const struct attribute_group ufs_sysfs_flags_group = {
 657         .name = "flags",
 658         .attrs = ufs_sysfs_device_flags,
 659 };
 660 
 661 #define UFS_ATTRIBUTE(_name, _uname)                                    \
 662 static ssize_t _name##_show(struct device *dev,                         \
 663         struct device_attribute *attr, char *buf)                       \
 664 {                                                                       \
 665         struct ufs_hba *hba = dev_get_drvdata(dev);                     \
 666         u32 value;                                                      \
 667         if (ufshcd_query_attr(hba, UPIU_QUERY_OPCODE_READ_ATTR,         \
 668                 QUERY_ATTR_IDN##_uname, 0, 0, &value))                  \
 669                 return -EINVAL;                                         \
 670         return sprintf(buf, "0x%08X\n", value);                         \
 671 }                                                                       \
 672 static DEVICE_ATTR_RO(_name)
 673 
 674 UFS_ATTRIBUTE(boot_lun_enabled, _BOOT_LU_EN);
 675 UFS_ATTRIBUTE(current_power_mode, _POWER_MODE);
 676 UFS_ATTRIBUTE(active_icc_level, _ACTIVE_ICC_LVL);
 677 UFS_ATTRIBUTE(ooo_data_enabled, _OOO_DATA_EN);
 678 UFS_ATTRIBUTE(bkops_status, _BKOPS_STATUS);
 679 UFS_ATTRIBUTE(purge_status, _PURGE_STATUS);
 680 UFS_ATTRIBUTE(max_data_in_size, _MAX_DATA_IN);
 681 UFS_ATTRIBUTE(max_data_out_size, _MAX_DATA_OUT);
 682 UFS_ATTRIBUTE(reference_clock_frequency, _REF_CLK_FREQ);
 683 UFS_ATTRIBUTE(configuration_descriptor_lock, _CONF_DESC_LOCK);
 684 UFS_ATTRIBUTE(max_number_of_rtt, _MAX_NUM_OF_RTT);
 685 UFS_ATTRIBUTE(exception_event_control, _EE_CONTROL);
 686 UFS_ATTRIBUTE(exception_event_status, _EE_STATUS);
 687 UFS_ATTRIBUTE(ffu_status, _FFU_STATUS);
 688 UFS_ATTRIBUTE(psa_state, _PSA_STATE);
 689 UFS_ATTRIBUTE(psa_data_size, _PSA_DATA_SIZE);
 690 
 691 static struct attribute *ufs_sysfs_attributes[] = {
 692         &dev_attr_boot_lun_enabled.attr,
 693         &dev_attr_current_power_mode.attr,
 694         &dev_attr_active_icc_level.attr,
 695         &dev_attr_ooo_data_enabled.attr,
 696         &dev_attr_bkops_status.attr,
 697         &dev_attr_purge_status.attr,
 698         &dev_attr_max_data_in_size.attr,
 699         &dev_attr_max_data_out_size.attr,
 700         &dev_attr_reference_clock_frequency.attr,
 701         &dev_attr_configuration_descriptor_lock.attr,
 702         &dev_attr_max_number_of_rtt.attr,
 703         &dev_attr_exception_event_control.attr,
 704         &dev_attr_exception_event_status.attr,
 705         &dev_attr_ffu_status.attr,
 706         &dev_attr_psa_state.attr,
 707         &dev_attr_psa_data_size.attr,
 708         NULL,
 709 };
 710 
 711 static const struct attribute_group ufs_sysfs_attributes_group = {
 712         .name = "attributes",
 713         .attrs = ufs_sysfs_attributes,
 714 };
 715 
 716 static const struct attribute_group *ufs_sysfs_groups[] = {
 717         &ufs_sysfs_default_group,
 718         &ufs_sysfs_device_descriptor_group,
 719         &ufs_sysfs_interconnect_descriptor_group,
 720         &ufs_sysfs_geometry_descriptor_group,
 721         &ufs_sysfs_health_descriptor_group,
 722         &ufs_sysfs_power_descriptor_group,
 723         &ufs_sysfs_string_descriptors_group,
 724         &ufs_sysfs_flags_group,
 725         &ufs_sysfs_attributes_group,
 726         NULL,
 727 };
 728 
 729 #define UFS_LUN_DESC_PARAM(_pname, _puname, _duname, _size)             \
 730 static ssize_t _pname##_show(struct device *dev,                        \
 731         struct device_attribute *attr, char *buf)                       \
 732 {                                                                       \
 733         struct scsi_device *sdev = to_scsi_device(dev);                 \
 734         struct ufs_hba *hba = shost_priv(sdev->host);                   \
 735         u8 lun = ufshcd_scsi_to_upiu_lun(sdev->lun);                    \
 736         if (!ufs_is_valid_unit_desc_lun(lun))                           \
 737                 return -EINVAL;                                         \
 738         return ufs_sysfs_read_desc_param(hba, QUERY_DESC_IDN_##_duname, \
 739                 lun, _duname##_DESC_PARAM##_puname, buf, _size);        \
 740 }                                                                       \
 741 static DEVICE_ATTR_RO(_pname)
 742 
 743 #define UFS_UNIT_DESC_PARAM(_name, _uname, _size)                       \
 744         UFS_LUN_DESC_PARAM(_name, _uname, UNIT, _size)
 745 
 746 UFS_UNIT_DESC_PARAM(boot_lun_id, _BOOT_LUN_ID, 1);
 747 UFS_UNIT_DESC_PARAM(lun_write_protect, _LU_WR_PROTECT, 1);
 748 UFS_UNIT_DESC_PARAM(lun_queue_depth, _LU_Q_DEPTH, 1);
 749 UFS_UNIT_DESC_PARAM(psa_sensitive, _PSA_SENSITIVE, 1);
 750 UFS_UNIT_DESC_PARAM(lun_memory_type, _MEM_TYPE, 1);
 751 UFS_UNIT_DESC_PARAM(data_reliability, _DATA_RELIABILITY, 1);
 752 UFS_UNIT_DESC_PARAM(logical_block_size, _LOGICAL_BLK_SIZE, 1);
 753 UFS_UNIT_DESC_PARAM(logical_block_count, _LOGICAL_BLK_COUNT, 8);
 754 UFS_UNIT_DESC_PARAM(erase_block_size, _ERASE_BLK_SIZE, 4);
 755 UFS_UNIT_DESC_PARAM(provisioning_type, _PROVISIONING_TYPE, 1);
 756 UFS_UNIT_DESC_PARAM(physical_memory_resourse_count, _PHY_MEM_RSRC_CNT, 8);
 757 UFS_UNIT_DESC_PARAM(context_capabilities, _CTX_CAPABILITIES, 2);
 758 UFS_UNIT_DESC_PARAM(large_unit_granularity, _LARGE_UNIT_SIZE_M1, 1);
 759 
 760 static struct attribute *ufs_sysfs_unit_descriptor[] = {
 761         &dev_attr_boot_lun_id.attr,
 762         &dev_attr_lun_write_protect.attr,
 763         &dev_attr_lun_queue_depth.attr,
 764         &dev_attr_psa_sensitive.attr,
 765         &dev_attr_lun_memory_type.attr,
 766         &dev_attr_data_reliability.attr,
 767         &dev_attr_logical_block_size.attr,
 768         &dev_attr_logical_block_count.attr,
 769         &dev_attr_erase_block_size.attr,
 770         &dev_attr_provisioning_type.attr,
 771         &dev_attr_physical_memory_resourse_count.attr,
 772         &dev_attr_context_capabilities.attr,
 773         &dev_attr_large_unit_granularity.attr,
 774         NULL,
 775 };
 776 
 777 const struct attribute_group ufs_sysfs_unit_descriptor_group = {
 778         .name = "unit_descriptor",
 779         .attrs = ufs_sysfs_unit_descriptor,
 780 };
 781 
 782 static ssize_t dyn_cap_needed_attribute_show(struct device *dev,
 783         struct device_attribute *attr, char *buf)
 784 {
 785         u32 value;
 786         struct scsi_device *sdev = to_scsi_device(dev);
 787         struct ufs_hba *hba = shost_priv(sdev->host);
 788         u8 lun = ufshcd_scsi_to_upiu_lun(sdev->lun);
 789 
 790         if (ufshcd_query_attr(hba, UPIU_QUERY_OPCODE_READ_ATTR,
 791                 QUERY_ATTR_IDN_DYN_CAP_NEEDED, lun, 0, &value))
 792                 return -EINVAL;
 793         return sprintf(buf, "0x%08X\n", value);
 794 }
 795 static DEVICE_ATTR_RO(dyn_cap_needed_attribute);
 796 
 797 static struct attribute *ufs_sysfs_lun_attributes[] = {
 798         &dev_attr_dyn_cap_needed_attribute.attr,
 799         NULL,
 800 };
 801 
 802 const struct attribute_group ufs_sysfs_lun_attributes_group = {
 803         .attrs = ufs_sysfs_lun_attributes,
 804 };
 805 
 806 void ufs_sysfs_add_nodes(struct device *dev)
 807 {
 808         int ret;
 809 
 810         ret = sysfs_create_groups(&dev->kobj, ufs_sysfs_groups);
 811         if (ret)
 812                 dev_err(dev,
 813                         "%s: sysfs groups creation failed (err = %d)\n",
 814                         __func__, ret);
 815 }
 816 
 817 void ufs_sysfs_remove_nodes(struct device *dev)
 818 {
 819         sysfs_remove_groups(&dev->kobj, ufs_sysfs_groups);
 820 }

/* [<][>][^][v][top][bottom][index][help] */