USB: usb-storage: unusual_devs update for Super TOP SATA bridge
[linux/fpc-iii.git] / drivers / scsi / bnx2i / bnx2i_sysfs.c
blob83a77f7244d27dc63c01eb4d790ec3d5dbf23577
1 /* bnx2i_sysfs.c: Broadcom NetXtreme II iSCSI driver.
3 * Copyright (c) 2004 - 2011 Broadcom Corporation
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation.
9 * Written by: Anil Veerabhadrappa (anilgv@broadcom.com)
10 * Maintained by: Eddie Wai (eddie.wai@broadcom.com)
13 #include "bnx2i.h"
15 /**
16 * bnx2i_dev_to_hba - maps dev pointer to adapter struct
17 * @dev: device pointer
19 * Map device to hba structure
21 static inline struct bnx2i_hba *bnx2i_dev_to_hba(struct device *dev)
23 struct Scsi_Host *shost = class_to_shost(dev);
24 return iscsi_host_priv(shost);
28 /**
29 * bnx2i_show_sq_info - return(s currently configured send queue (SQ) size
30 * @dev: device pointer
31 * @buf: buffer to return current SQ size parameter
33 * Returns current SQ size parameter, this paramater determines the number
34 * outstanding iSCSI commands supported on a connection
36 static ssize_t bnx2i_show_sq_info(struct device *dev,
37 struct device_attribute *attr, char *buf)
39 struct bnx2i_hba *hba = bnx2i_dev_to_hba(dev);
41 return sprintf(buf, "0x%x\n", hba->max_sqes);
45 /**
46 * bnx2i_set_sq_info - update send queue (SQ) size parameter
47 * @dev: device pointer
48 * @buf: buffer to return current SQ size parameter
49 * @count: parameter buffer size
51 * Interface for user to change shared queue size allocated for each conn
52 * Must be within SQ limits and a power of 2. For the latter this is needed
53 * because of how libiscsi preallocates tasks.
55 static ssize_t bnx2i_set_sq_info(struct device *dev,
56 struct device_attribute *attr,
57 const char *buf, size_t count)
59 struct bnx2i_hba *hba = bnx2i_dev_to_hba(dev);
60 u32 val;
61 int max_sq_size;
63 if (hba->ofld_conns_active)
64 goto skip_config;
66 if (test_bit(BNX2I_NX2_DEV_57710, &hba->cnic_dev_type))
67 max_sq_size = BNX2I_5770X_SQ_WQES_MAX;
68 else
69 max_sq_size = BNX2I_570X_SQ_WQES_MAX;
71 if (sscanf(buf, " 0x%x ", &val) > 0) {
72 if ((val >= BNX2I_SQ_WQES_MIN) && (val <= max_sq_size) &&
73 (is_power_of_2(val)))
74 hba->max_sqes = val;
77 return count;
79 skip_config:
80 printk(KERN_ERR "bnx2i: device busy, cannot change SQ size\n");
81 return 0;
85 /**
86 * bnx2i_show_ccell_info - returns command cell (HQ) size
87 * @dev: device pointer
88 * @buf: buffer to return current SQ size parameter
90 * returns per-connection TCP history queue size parameter
92 static ssize_t bnx2i_show_ccell_info(struct device *dev,
93 struct device_attribute *attr, char *buf)
95 struct bnx2i_hba *hba = bnx2i_dev_to_hba(dev);
97 return sprintf(buf, "0x%x\n", hba->num_ccell);
102 * bnx2i_get_link_state - set command cell (HQ) size
103 * @dev: device pointer
104 * @buf: buffer to return current SQ size parameter
105 * @count: parameter buffer size
107 * updates per-connection TCP history queue size parameter
109 static ssize_t bnx2i_set_ccell_info(struct device *dev,
110 struct device_attribute *attr,
111 const char *buf, size_t count)
113 u32 val;
114 struct bnx2i_hba *hba = bnx2i_dev_to_hba(dev);
116 if (hba->ofld_conns_active)
117 goto skip_config;
119 if (sscanf(buf, " 0x%x ", &val) > 0) {
120 if ((val >= BNX2I_CCELLS_MIN) &&
121 (val <= BNX2I_CCELLS_MAX)) {
122 hba->num_ccell = val;
126 return count;
128 skip_config:
129 printk(KERN_ERR "bnx2i: device busy, cannot change CCELL size\n");
130 return 0;
134 static DEVICE_ATTR(sq_size, S_IRUGO | S_IWUSR,
135 bnx2i_show_sq_info, bnx2i_set_sq_info);
136 static DEVICE_ATTR(num_ccell, S_IRUGO | S_IWUSR,
137 bnx2i_show_ccell_info, bnx2i_set_ccell_info);
139 struct device_attribute *bnx2i_dev_attributes[] = {
140 &dev_attr_sq_size,
141 &dev_attr_num_ccell,
142 NULL