18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci******************************************************************************* 38c2ecf20Sopenharmony_ci** O.S : Linux 48c2ecf20Sopenharmony_ci** FILE NAME : arcmsr_attr.c 58c2ecf20Sopenharmony_ci** BY : Nick Cheng 68c2ecf20Sopenharmony_ci** Description: attributes exported to sysfs and device host 78c2ecf20Sopenharmony_ci******************************************************************************* 88c2ecf20Sopenharmony_ci** Copyright (C) 2002 - 2005, Areca Technology Corporation All rights reserved 98c2ecf20Sopenharmony_ci** 108c2ecf20Sopenharmony_ci** Web site: www.areca.com.tw 118c2ecf20Sopenharmony_ci** E-mail: support@areca.com.tw 128c2ecf20Sopenharmony_ci** 138c2ecf20Sopenharmony_ci** This program is free software; you can redistribute it and/or modify 148c2ecf20Sopenharmony_ci** it under the terms of the GNU General Public License version 2 as 158c2ecf20Sopenharmony_ci** published by the Free Software Foundation. 168c2ecf20Sopenharmony_ci** This program is distributed in the hope that it will be useful, 178c2ecf20Sopenharmony_ci** but WITHOUT ANY WARRANTY; without even the implied warranty of 188c2ecf20Sopenharmony_ci** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 198c2ecf20Sopenharmony_ci** GNU General Public License for more details. 208c2ecf20Sopenharmony_ci******************************************************************************* 218c2ecf20Sopenharmony_ci** Redistribution and use in source and binary forms, with or without 228c2ecf20Sopenharmony_ci** modification, are permitted provided that the following conditions 238c2ecf20Sopenharmony_ci** are met: 248c2ecf20Sopenharmony_ci** 1. Redistributions of source code must retain the above copyright 258c2ecf20Sopenharmony_ci** notice, this list of conditions and the following disclaimer. 268c2ecf20Sopenharmony_ci** 2. Redistributions in binary form must reproduce the above copyright 278c2ecf20Sopenharmony_ci** notice, this list of conditions and the following disclaimer in the 288c2ecf20Sopenharmony_ci** documentation and/or other materials provided with the distribution. 298c2ecf20Sopenharmony_ci** 3. The name of the author may not be used to endorse or promote products 308c2ecf20Sopenharmony_ci** derived from this software without specific prior written permission. 318c2ecf20Sopenharmony_ci** 328c2ecf20Sopenharmony_ci** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 338c2ecf20Sopenharmony_ci** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 348c2ecf20Sopenharmony_ci** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 358c2ecf20Sopenharmony_ci** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 368c2ecf20Sopenharmony_ci** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES(INCLUDING,BUT 378c2ecf20Sopenharmony_ci** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 388c2ecf20Sopenharmony_ci** DATA, OR PROFITS; OR BUSINESS INTERRUPTION)HOWEVER CAUSED AND ON ANY 398c2ecf20Sopenharmony_ci** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 408c2ecf20Sopenharmony_ci** (INCLUDING NEGLIGENCE OR OTHERWISE)ARISING IN ANY WAY OUT OF THE USE OF 418c2ecf20Sopenharmony_ci** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 428c2ecf20Sopenharmony_ci******************************************************************************* 438c2ecf20Sopenharmony_ci** For history of changes, see Documentation/scsi/ChangeLog.arcmsr 448c2ecf20Sopenharmony_ci** Firmware Specification, see Documentation/scsi/arcmsr_spec.rst 458c2ecf20Sopenharmony_ci******************************************************************************* 468c2ecf20Sopenharmony_ci*/ 478c2ecf20Sopenharmony_ci#include <linux/module.h> 488c2ecf20Sopenharmony_ci#include <linux/kernel.h> 498c2ecf20Sopenharmony_ci#include <linux/init.h> 508c2ecf20Sopenharmony_ci#include <linux/errno.h> 518c2ecf20Sopenharmony_ci#include <linux/delay.h> 528c2ecf20Sopenharmony_ci#include <linux/pci.h> 538c2ecf20Sopenharmony_ci#include <linux/circ_buf.h> 548c2ecf20Sopenharmony_ci 558c2ecf20Sopenharmony_ci#include <scsi/scsi_cmnd.h> 568c2ecf20Sopenharmony_ci#include <scsi/scsi_device.h> 578c2ecf20Sopenharmony_ci#include <scsi/scsi_host.h> 588c2ecf20Sopenharmony_ci#include <scsi/scsi_transport.h> 598c2ecf20Sopenharmony_ci#include "arcmsr.h" 608c2ecf20Sopenharmony_ci 618c2ecf20Sopenharmony_cistruct device_attribute *arcmsr_host_attrs[]; 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_cistatic ssize_t arcmsr_sysfs_iop_message_read(struct file *filp, 648c2ecf20Sopenharmony_ci struct kobject *kobj, 658c2ecf20Sopenharmony_ci struct bin_attribute *bin, 668c2ecf20Sopenharmony_ci char *buf, loff_t off, 678c2ecf20Sopenharmony_ci size_t count) 688c2ecf20Sopenharmony_ci{ 698c2ecf20Sopenharmony_ci struct device *dev = container_of(kobj,struct device,kobj); 708c2ecf20Sopenharmony_ci struct Scsi_Host *host = class_to_shost(dev); 718c2ecf20Sopenharmony_ci struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata; 728c2ecf20Sopenharmony_ci uint8_t *ptmpQbuffer; 738c2ecf20Sopenharmony_ci int32_t allxfer_len = 0; 748c2ecf20Sopenharmony_ci unsigned long flags; 758c2ecf20Sopenharmony_ci 768c2ecf20Sopenharmony_ci if (!capable(CAP_SYS_ADMIN)) 778c2ecf20Sopenharmony_ci return -EACCES; 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_ci /* do message unit read. */ 808c2ecf20Sopenharmony_ci ptmpQbuffer = (uint8_t *)buf; 818c2ecf20Sopenharmony_ci spin_lock_irqsave(&acb->rqbuffer_lock, flags); 828c2ecf20Sopenharmony_ci if (acb->rqbuf_getIndex != acb->rqbuf_putIndex) { 838c2ecf20Sopenharmony_ci unsigned int tail = acb->rqbuf_getIndex; 848c2ecf20Sopenharmony_ci unsigned int head = acb->rqbuf_putIndex; 858c2ecf20Sopenharmony_ci unsigned int cnt_to_end = CIRC_CNT_TO_END(head, tail, ARCMSR_MAX_QBUFFER); 868c2ecf20Sopenharmony_ci 878c2ecf20Sopenharmony_ci allxfer_len = CIRC_CNT(head, tail, ARCMSR_MAX_QBUFFER); 888c2ecf20Sopenharmony_ci if (allxfer_len > ARCMSR_API_DATA_BUFLEN) 898c2ecf20Sopenharmony_ci allxfer_len = ARCMSR_API_DATA_BUFLEN; 908c2ecf20Sopenharmony_ci 918c2ecf20Sopenharmony_ci if (allxfer_len <= cnt_to_end) 928c2ecf20Sopenharmony_ci memcpy(ptmpQbuffer, acb->rqbuffer + tail, allxfer_len); 938c2ecf20Sopenharmony_ci else { 948c2ecf20Sopenharmony_ci memcpy(ptmpQbuffer, acb->rqbuffer + tail, cnt_to_end); 958c2ecf20Sopenharmony_ci memcpy(ptmpQbuffer + cnt_to_end, acb->rqbuffer, allxfer_len - cnt_to_end); 968c2ecf20Sopenharmony_ci } 978c2ecf20Sopenharmony_ci acb->rqbuf_getIndex = (acb->rqbuf_getIndex + allxfer_len) % ARCMSR_MAX_QBUFFER; 988c2ecf20Sopenharmony_ci } 998c2ecf20Sopenharmony_ci if (acb->acb_flags & ACB_F_IOPDATA_OVERFLOW) { 1008c2ecf20Sopenharmony_ci struct QBUFFER __iomem *prbuffer; 1018c2ecf20Sopenharmony_ci acb->acb_flags &= ~ACB_F_IOPDATA_OVERFLOW; 1028c2ecf20Sopenharmony_ci prbuffer = arcmsr_get_iop_rqbuffer(acb); 1038c2ecf20Sopenharmony_ci if (arcmsr_Read_iop_rqbuffer_data(acb, prbuffer) == 0) 1048c2ecf20Sopenharmony_ci acb->acb_flags |= ACB_F_IOPDATA_OVERFLOW; 1058c2ecf20Sopenharmony_ci } 1068c2ecf20Sopenharmony_ci spin_unlock_irqrestore(&acb->rqbuffer_lock, flags); 1078c2ecf20Sopenharmony_ci return allxfer_len; 1088c2ecf20Sopenharmony_ci} 1098c2ecf20Sopenharmony_ci 1108c2ecf20Sopenharmony_cistatic ssize_t arcmsr_sysfs_iop_message_write(struct file *filp, 1118c2ecf20Sopenharmony_ci struct kobject *kobj, 1128c2ecf20Sopenharmony_ci struct bin_attribute *bin, 1138c2ecf20Sopenharmony_ci char *buf, loff_t off, 1148c2ecf20Sopenharmony_ci size_t count) 1158c2ecf20Sopenharmony_ci{ 1168c2ecf20Sopenharmony_ci struct device *dev = container_of(kobj,struct device,kobj); 1178c2ecf20Sopenharmony_ci struct Scsi_Host *host = class_to_shost(dev); 1188c2ecf20Sopenharmony_ci struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata; 1198c2ecf20Sopenharmony_ci int32_t user_len, cnt2end; 1208c2ecf20Sopenharmony_ci uint8_t *pQbuffer, *ptmpuserbuffer; 1218c2ecf20Sopenharmony_ci unsigned long flags; 1228c2ecf20Sopenharmony_ci 1238c2ecf20Sopenharmony_ci if (!capable(CAP_SYS_ADMIN)) 1248c2ecf20Sopenharmony_ci return -EACCES; 1258c2ecf20Sopenharmony_ci if (count > ARCMSR_API_DATA_BUFLEN) 1268c2ecf20Sopenharmony_ci return -EINVAL; 1278c2ecf20Sopenharmony_ci /* do message unit write. */ 1288c2ecf20Sopenharmony_ci ptmpuserbuffer = (uint8_t *)buf; 1298c2ecf20Sopenharmony_ci user_len = (int32_t)count; 1308c2ecf20Sopenharmony_ci spin_lock_irqsave(&acb->wqbuffer_lock, flags); 1318c2ecf20Sopenharmony_ci if (acb->wqbuf_putIndex != acb->wqbuf_getIndex) { 1328c2ecf20Sopenharmony_ci arcmsr_write_ioctldata2iop(acb); 1338c2ecf20Sopenharmony_ci spin_unlock_irqrestore(&acb->wqbuffer_lock, flags); 1348c2ecf20Sopenharmony_ci return 0; /*need retry*/ 1358c2ecf20Sopenharmony_ci } else { 1368c2ecf20Sopenharmony_ci pQbuffer = &acb->wqbuffer[acb->wqbuf_putIndex]; 1378c2ecf20Sopenharmony_ci cnt2end = ARCMSR_MAX_QBUFFER - acb->wqbuf_putIndex; 1388c2ecf20Sopenharmony_ci if (user_len > cnt2end) { 1398c2ecf20Sopenharmony_ci memcpy(pQbuffer, ptmpuserbuffer, cnt2end); 1408c2ecf20Sopenharmony_ci ptmpuserbuffer += cnt2end; 1418c2ecf20Sopenharmony_ci user_len -= cnt2end; 1428c2ecf20Sopenharmony_ci acb->wqbuf_putIndex = 0; 1438c2ecf20Sopenharmony_ci pQbuffer = acb->wqbuffer; 1448c2ecf20Sopenharmony_ci } 1458c2ecf20Sopenharmony_ci memcpy(pQbuffer, ptmpuserbuffer, user_len); 1468c2ecf20Sopenharmony_ci acb->wqbuf_putIndex += user_len; 1478c2ecf20Sopenharmony_ci acb->wqbuf_putIndex %= ARCMSR_MAX_QBUFFER; 1488c2ecf20Sopenharmony_ci if (acb->acb_flags & ACB_F_MESSAGE_WQBUFFER_CLEARED) { 1498c2ecf20Sopenharmony_ci acb->acb_flags &= 1508c2ecf20Sopenharmony_ci ~ACB_F_MESSAGE_WQBUFFER_CLEARED; 1518c2ecf20Sopenharmony_ci arcmsr_write_ioctldata2iop(acb); 1528c2ecf20Sopenharmony_ci } 1538c2ecf20Sopenharmony_ci spin_unlock_irqrestore(&acb->wqbuffer_lock, flags); 1548c2ecf20Sopenharmony_ci return count; 1558c2ecf20Sopenharmony_ci } 1568c2ecf20Sopenharmony_ci} 1578c2ecf20Sopenharmony_ci 1588c2ecf20Sopenharmony_cistatic ssize_t arcmsr_sysfs_iop_message_clear(struct file *filp, 1598c2ecf20Sopenharmony_ci struct kobject *kobj, 1608c2ecf20Sopenharmony_ci struct bin_attribute *bin, 1618c2ecf20Sopenharmony_ci char *buf, loff_t off, 1628c2ecf20Sopenharmony_ci size_t count) 1638c2ecf20Sopenharmony_ci{ 1648c2ecf20Sopenharmony_ci struct device *dev = container_of(kobj,struct device,kobj); 1658c2ecf20Sopenharmony_ci struct Scsi_Host *host = class_to_shost(dev); 1668c2ecf20Sopenharmony_ci struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata; 1678c2ecf20Sopenharmony_ci uint8_t *pQbuffer; 1688c2ecf20Sopenharmony_ci unsigned long flags; 1698c2ecf20Sopenharmony_ci 1708c2ecf20Sopenharmony_ci if (!capable(CAP_SYS_ADMIN)) 1718c2ecf20Sopenharmony_ci return -EACCES; 1728c2ecf20Sopenharmony_ci 1738c2ecf20Sopenharmony_ci arcmsr_clear_iop2drv_rqueue_buffer(acb); 1748c2ecf20Sopenharmony_ci acb->acb_flags |= 1758c2ecf20Sopenharmony_ci (ACB_F_MESSAGE_WQBUFFER_CLEARED 1768c2ecf20Sopenharmony_ci | ACB_F_MESSAGE_RQBUFFER_CLEARED 1778c2ecf20Sopenharmony_ci | ACB_F_MESSAGE_WQBUFFER_READED); 1788c2ecf20Sopenharmony_ci spin_lock_irqsave(&acb->rqbuffer_lock, flags); 1798c2ecf20Sopenharmony_ci acb->rqbuf_getIndex = 0; 1808c2ecf20Sopenharmony_ci acb->rqbuf_putIndex = 0; 1818c2ecf20Sopenharmony_ci spin_unlock_irqrestore(&acb->rqbuffer_lock, flags); 1828c2ecf20Sopenharmony_ci spin_lock_irqsave(&acb->wqbuffer_lock, flags); 1838c2ecf20Sopenharmony_ci acb->wqbuf_getIndex = 0; 1848c2ecf20Sopenharmony_ci acb->wqbuf_putIndex = 0; 1858c2ecf20Sopenharmony_ci spin_unlock_irqrestore(&acb->wqbuffer_lock, flags); 1868c2ecf20Sopenharmony_ci pQbuffer = acb->rqbuffer; 1878c2ecf20Sopenharmony_ci memset(pQbuffer, 0, sizeof (struct QBUFFER)); 1888c2ecf20Sopenharmony_ci pQbuffer = acb->wqbuffer; 1898c2ecf20Sopenharmony_ci memset(pQbuffer, 0, sizeof (struct QBUFFER)); 1908c2ecf20Sopenharmony_ci return 1; 1918c2ecf20Sopenharmony_ci} 1928c2ecf20Sopenharmony_ci 1938c2ecf20Sopenharmony_cistatic const struct bin_attribute arcmsr_sysfs_message_read_attr = { 1948c2ecf20Sopenharmony_ci .attr = { 1958c2ecf20Sopenharmony_ci .name = "mu_read", 1968c2ecf20Sopenharmony_ci .mode = S_IRUSR , 1978c2ecf20Sopenharmony_ci }, 1988c2ecf20Sopenharmony_ci .size = ARCMSR_API_DATA_BUFLEN, 1998c2ecf20Sopenharmony_ci .read = arcmsr_sysfs_iop_message_read, 2008c2ecf20Sopenharmony_ci}; 2018c2ecf20Sopenharmony_ci 2028c2ecf20Sopenharmony_cistatic const struct bin_attribute arcmsr_sysfs_message_write_attr = { 2038c2ecf20Sopenharmony_ci .attr = { 2048c2ecf20Sopenharmony_ci .name = "mu_write", 2058c2ecf20Sopenharmony_ci .mode = S_IWUSR, 2068c2ecf20Sopenharmony_ci }, 2078c2ecf20Sopenharmony_ci .size = ARCMSR_API_DATA_BUFLEN, 2088c2ecf20Sopenharmony_ci .write = arcmsr_sysfs_iop_message_write, 2098c2ecf20Sopenharmony_ci}; 2108c2ecf20Sopenharmony_ci 2118c2ecf20Sopenharmony_cistatic const struct bin_attribute arcmsr_sysfs_message_clear_attr = { 2128c2ecf20Sopenharmony_ci .attr = { 2138c2ecf20Sopenharmony_ci .name = "mu_clear", 2148c2ecf20Sopenharmony_ci .mode = S_IWUSR, 2158c2ecf20Sopenharmony_ci }, 2168c2ecf20Sopenharmony_ci .size = 1, 2178c2ecf20Sopenharmony_ci .write = arcmsr_sysfs_iop_message_clear, 2188c2ecf20Sopenharmony_ci}; 2198c2ecf20Sopenharmony_ci 2208c2ecf20Sopenharmony_ciint arcmsr_alloc_sysfs_attr(struct AdapterControlBlock *acb) 2218c2ecf20Sopenharmony_ci{ 2228c2ecf20Sopenharmony_ci struct Scsi_Host *host = acb->host; 2238c2ecf20Sopenharmony_ci int error; 2248c2ecf20Sopenharmony_ci 2258c2ecf20Sopenharmony_ci error = sysfs_create_bin_file(&host->shost_dev.kobj, &arcmsr_sysfs_message_read_attr); 2268c2ecf20Sopenharmony_ci if (error) { 2278c2ecf20Sopenharmony_ci printk(KERN_ERR "arcmsr: alloc sysfs mu_read failed\n"); 2288c2ecf20Sopenharmony_ci goto error_bin_file_message_read; 2298c2ecf20Sopenharmony_ci } 2308c2ecf20Sopenharmony_ci error = sysfs_create_bin_file(&host->shost_dev.kobj, &arcmsr_sysfs_message_write_attr); 2318c2ecf20Sopenharmony_ci if (error) { 2328c2ecf20Sopenharmony_ci printk(KERN_ERR "arcmsr: alloc sysfs mu_write failed\n"); 2338c2ecf20Sopenharmony_ci goto error_bin_file_message_write; 2348c2ecf20Sopenharmony_ci } 2358c2ecf20Sopenharmony_ci error = sysfs_create_bin_file(&host->shost_dev.kobj, &arcmsr_sysfs_message_clear_attr); 2368c2ecf20Sopenharmony_ci if (error) { 2378c2ecf20Sopenharmony_ci printk(KERN_ERR "arcmsr: alloc sysfs mu_clear failed\n"); 2388c2ecf20Sopenharmony_ci goto error_bin_file_message_clear; 2398c2ecf20Sopenharmony_ci } 2408c2ecf20Sopenharmony_ci return 0; 2418c2ecf20Sopenharmony_cierror_bin_file_message_clear: 2428c2ecf20Sopenharmony_ci sysfs_remove_bin_file(&host->shost_dev.kobj, &arcmsr_sysfs_message_write_attr); 2438c2ecf20Sopenharmony_cierror_bin_file_message_write: 2448c2ecf20Sopenharmony_ci sysfs_remove_bin_file(&host->shost_dev.kobj, &arcmsr_sysfs_message_read_attr); 2458c2ecf20Sopenharmony_cierror_bin_file_message_read: 2468c2ecf20Sopenharmony_ci return error; 2478c2ecf20Sopenharmony_ci} 2488c2ecf20Sopenharmony_ci 2498c2ecf20Sopenharmony_civoid arcmsr_free_sysfs_attr(struct AdapterControlBlock *acb) 2508c2ecf20Sopenharmony_ci{ 2518c2ecf20Sopenharmony_ci struct Scsi_Host *host = acb->host; 2528c2ecf20Sopenharmony_ci 2538c2ecf20Sopenharmony_ci sysfs_remove_bin_file(&host->shost_dev.kobj, &arcmsr_sysfs_message_clear_attr); 2548c2ecf20Sopenharmony_ci sysfs_remove_bin_file(&host->shost_dev.kobj, &arcmsr_sysfs_message_write_attr); 2558c2ecf20Sopenharmony_ci sysfs_remove_bin_file(&host->shost_dev.kobj, &arcmsr_sysfs_message_read_attr); 2568c2ecf20Sopenharmony_ci} 2578c2ecf20Sopenharmony_ci 2588c2ecf20Sopenharmony_ci 2598c2ecf20Sopenharmony_cistatic ssize_t 2608c2ecf20Sopenharmony_ciarcmsr_attr_host_driver_version(struct device *dev, 2618c2ecf20Sopenharmony_ci struct device_attribute *attr, char *buf) 2628c2ecf20Sopenharmony_ci{ 2638c2ecf20Sopenharmony_ci return snprintf(buf, PAGE_SIZE, 2648c2ecf20Sopenharmony_ci "%s\n", 2658c2ecf20Sopenharmony_ci ARCMSR_DRIVER_VERSION); 2668c2ecf20Sopenharmony_ci} 2678c2ecf20Sopenharmony_ci 2688c2ecf20Sopenharmony_cistatic ssize_t 2698c2ecf20Sopenharmony_ciarcmsr_attr_host_driver_posted_cmd(struct device *dev, 2708c2ecf20Sopenharmony_ci struct device_attribute *attr, char *buf) 2718c2ecf20Sopenharmony_ci{ 2728c2ecf20Sopenharmony_ci struct Scsi_Host *host = class_to_shost(dev); 2738c2ecf20Sopenharmony_ci struct AdapterControlBlock *acb = 2748c2ecf20Sopenharmony_ci (struct AdapterControlBlock *) host->hostdata; 2758c2ecf20Sopenharmony_ci return snprintf(buf, PAGE_SIZE, 2768c2ecf20Sopenharmony_ci "%4d\n", 2778c2ecf20Sopenharmony_ci atomic_read(&acb->ccboutstandingcount)); 2788c2ecf20Sopenharmony_ci} 2798c2ecf20Sopenharmony_ci 2808c2ecf20Sopenharmony_cistatic ssize_t 2818c2ecf20Sopenharmony_ciarcmsr_attr_host_driver_reset(struct device *dev, 2828c2ecf20Sopenharmony_ci struct device_attribute *attr, char *buf) 2838c2ecf20Sopenharmony_ci{ 2848c2ecf20Sopenharmony_ci struct Scsi_Host *host = class_to_shost(dev); 2858c2ecf20Sopenharmony_ci struct AdapterControlBlock *acb = 2868c2ecf20Sopenharmony_ci (struct AdapterControlBlock *) host->hostdata; 2878c2ecf20Sopenharmony_ci return snprintf(buf, PAGE_SIZE, 2888c2ecf20Sopenharmony_ci "%4d\n", 2898c2ecf20Sopenharmony_ci acb->num_resets); 2908c2ecf20Sopenharmony_ci} 2918c2ecf20Sopenharmony_ci 2928c2ecf20Sopenharmony_cistatic ssize_t 2938c2ecf20Sopenharmony_ciarcmsr_attr_host_driver_abort(struct device *dev, 2948c2ecf20Sopenharmony_ci struct device_attribute *attr, char *buf) 2958c2ecf20Sopenharmony_ci{ 2968c2ecf20Sopenharmony_ci struct Scsi_Host *host = class_to_shost(dev); 2978c2ecf20Sopenharmony_ci struct AdapterControlBlock *acb = 2988c2ecf20Sopenharmony_ci (struct AdapterControlBlock *) host->hostdata; 2998c2ecf20Sopenharmony_ci return snprintf(buf, PAGE_SIZE, 3008c2ecf20Sopenharmony_ci "%4d\n", 3018c2ecf20Sopenharmony_ci acb->num_aborts); 3028c2ecf20Sopenharmony_ci} 3038c2ecf20Sopenharmony_ci 3048c2ecf20Sopenharmony_cistatic ssize_t 3058c2ecf20Sopenharmony_ciarcmsr_attr_host_fw_model(struct device *dev, struct device_attribute *attr, 3068c2ecf20Sopenharmony_ci char *buf) 3078c2ecf20Sopenharmony_ci{ 3088c2ecf20Sopenharmony_ci struct Scsi_Host *host = class_to_shost(dev); 3098c2ecf20Sopenharmony_ci struct AdapterControlBlock *acb = 3108c2ecf20Sopenharmony_ci (struct AdapterControlBlock *) host->hostdata; 3118c2ecf20Sopenharmony_ci return snprintf(buf, PAGE_SIZE, 3128c2ecf20Sopenharmony_ci "%s\n", 3138c2ecf20Sopenharmony_ci acb->firm_model); 3148c2ecf20Sopenharmony_ci} 3158c2ecf20Sopenharmony_ci 3168c2ecf20Sopenharmony_cistatic ssize_t 3178c2ecf20Sopenharmony_ciarcmsr_attr_host_fw_version(struct device *dev, 3188c2ecf20Sopenharmony_ci struct device_attribute *attr, char *buf) 3198c2ecf20Sopenharmony_ci{ 3208c2ecf20Sopenharmony_ci struct Scsi_Host *host = class_to_shost(dev); 3218c2ecf20Sopenharmony_ci struct AdapterControlBlock *acb = 3228c2ecf20Sopenharmony_ci (struct AdapterControlBlock *) host->hostdata; 3238c2ecf20Sopenharmony_ci 3248c2ecf20Sopenharmony_ci return snprintf(buf, PAGE_SIZE, 3258c2ecf20Sopenharmony_ci "%s\n", 3268c2ecf20Sopenharmony_ci acb->firm_version); 3278c2ecf20Sopenharmony_ci} 3288c2ecf20Sopenharmony_ci 3298c2ecf20Sopenharmony_cistatic ssize_t 3308c2ecf20Sopenharmony_ciarcmsr_attr_host_fw_request_len(struct device *dev, 3318c2ecf20Sopenharmony_ci struct device_attribute *attr, char *buf) 3328c2ecf20Sopenharmony_ci{ 3338c2ecf20Sopenharmony_ci struct Scsi_Host *host = class_to_shost(dev); 3348c2ecf20Sopenharmony_ci struct AdapterControlBlock *acb = 3358c2ecf20Sopenharmony_ci (struct AdapterControlBlock *) host->hostdata; 3368c2ecf20Sopenharmony_ci 3378c2ecf20Sopenharmony_ci return snprintf(buf, PAGE_SIZE, 3388c2ecf20Sopenharmony_ci "%4d\n", 3398c2ecf20Sopenharmony_ci acb->firm_request_len); 3408c2ecf20Sopenharmony_ci} 3418c2ecf20Sopenharmony_ci 3428c2ecf20Sopenharmony_cistatic ssize_t 3438c2ecf20Sopenharmony_ciarcmsr_attr_host_fw_numbers_queue(struct device *dev, 3448c2ecf20Sopenharmony_ci struct device_attribute *attr, char *buf) 3458c2ecf20Sopenharmony_ci{ 3468c2ecf20Sopenharmony_ci struct Scsi_Host *host = class_to_shost(dev); 3478c2ecf20Sopenharmony_ci struct AdapterControlBlock *acb = 3488c2ecf20Sopenharmony_ci (struct AdapterControlBlock *) host->hostdata; 3498c2ecf20Sopenharmony_ci 3508c2ecf20Sopenharmony_ci return snprintf(buf, PAGE_SIZE, 3518c2ecf20Sopenharmony_ci "%4d\n", 3528c2ecf20Sopenharmony_ci acb->firm_numbers_queue); 3538c2ecf20Sopenharmony_ci} 3548c2ecf20Sopenharmony_ci 3558c2ecf20Sopenharmony_cistatic ssize_t 3568c2ecf20Sopenharmony_ciarcmsr_attr_host_fw_sdram_size(struct device *dev, 3578c2ecf20Sopenharmony_ci struct device_attribute *attr, char *buf) 3588c2ecf20Sopenharmony_ci{ 3598c2ecf20Sopenharmony_ci struct Scsi_Host *host = class_to_shost(dev); 3608c2ecf20Sopenharmony_ci struct AdapterControlBlock *acb = 3618c2ecf20Sopenharmony_ci (struct AdapterControlBlock *) host->hostdata; 3628c2ecf20Sopenharmony_ci 3638c2ecf20Sopenharmony_ci return snprintf(buf, PAGE_SIZE, 3648c2ecf20Sopenharmony_ci "%4d\n", 3658c2ecf20Sopenharmony_ci acb->firm_sdram_size); 3668c2ecf20Sopenharmony_ci} 3678c2ecf20Sopenharmony_ci 3688c2ecf20Sopenharmony_cistatic ssize_t 3698c2ecf20Sopenharmony_ciarcmsr_attr_host_fw_hd_channels(struct device *dev, 3708c2ecf20Sopenharmony_ci struct device_attribute *attr, char *buf) 3718c2ecf20Sopenharmony_ci{ 3728c2ecf20Sopenharmony_ci struct Scsi_Host *host = class_to_shost(dev); 3738c2ecf20Sopenharmony_ci struct AdapterControlBlock *acb = 3748c2ecf20Sopenharmony_ci (struct AdapterControlBlock *) host->hostdata; 3758c2ecf20Sopenharmony_ci 3768c2ecf20Sopenharmony_ci return snprintf(buf, PAGE_SIZE, 3778c2ecf20Sopenharmony_ci "%4d\n", 3788c2ecf20Sopenharmony_ci acb->firm_hd_channels); 3798c2ecf20Sopenharmony_ci} 3808c2ecf20Sopenharmony_ci 3818c2ecf20Sopenharmony_cistatic DEVICE_ATTR(host_driver_version, S_IRUGO, arcmsr_attr_host_driver_version, NULL); 3828c2ecf20Sopenharmony_cistatic DEVICE_ATTR(host_driver_posted_cmd, S_IRUGO, arcmsr_attr_host_driver_posted_cmd, NULL); 3838c2ecf20Sopenharmony_cistatic DEVICE_ATTR(host_driver_reset, S_IRUGO, arcmsr_attr_host_driver_reset, NULL); 3848c2ecf20Sopenharmony_cistatic DEVICE_ATTR(host_driver_abort, S_IRUGO, arcmsr_attr_host_driver_abort, NULL); 3858c2ecf20Sopenharmony_cistatic DEVICE_ATTR(host_fw_model, S_IRUGO, arcmsr_attr_host_fw_model, NULL); 3868c2ecf20Sopenharmony_cistatic DEVICE_ATTR(host_fw_version, S_IRUGO, arcmsr_attr_host_fw_version, NULL); 3878c2ecf20Sopenharmony_cistatic DEVICE_ATTR(host_fw_request_len, S_IRUGO, arcmsr_attr_host_fw_request_len, NULL); 3888c2ecf20Sopenharmony_cistatic DEVICE_ATTR(host_fw_numbers_queue, S_IRUGO, arcmsr_attr_host_fw_numbers_queue, NULL); 3898c2ecf20Sopenharmony_cistatic DEVICE_ATTR(host_fw_sdram_size, S_IRUGO, arcmsr_attr_host_fw_sdram_size, NULL); 3908c2ecf20Sopenharmony_cistatic DEVICE_ATTR(host_fw_hd_channels, S_IRUGO, arcmsr_attr_host_fw_hd_channels, NULL); 3918c2ecf20Sopenharmony_ci 3928c2ecf20Sopenharmony_cistruct device_attribute *arcmsr_host_attrs[] = { 3938c2ecf20Sopenharmony_ci &dev_attr_host_driver_version, 3948c2ecf20Sopenharmony_ci &dev_attr_host_driver_posted_cmd, 3958c2ecf20Sopenharmony_ci &dev_attr_host_driver_reset, 3968c2ecf20Sopenharmony_ci &dev_attr_host_driver_abort, 3978c2ecf20Sopenharmony_ci &dev_attr_host_fw_model, 3988c2ecf20Sopenharmony_ci &dev_attr_host_fw_version, 3998c2ecf20Sopenharmony_ci &dev_attr_host_fw_request_len, 4008c2ecf20Sopenharmony_ci &dev_attr_host_fw_numbers_queue, 4018c2ecf20Sopenharmony_ci &dev_attr_host_fw_sdram_size, 4028c2ecf20Sopenharmony_ci &dev_attr_host_fw_hd_channels, 4038c2ecf20Sopenharmony_ci NULL, 4048c2ecf20Sopenharmony_ci}; 405