0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #include "bnx2i.h"
0016
0017
0018
0019
0020
0021
0022
0023 static inline struct bnx2i_hba *bnx2i_dev_to_hba(struct device *dev)
0024 {
0025 struct Scsi_Host *shost = class_to_shost(dev);
0026 return iscsi_host_priv(shost);
0027 }
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039 static ssize_t bnx2i_show_sq_info(struct device *dev,
0040 struct device_attribute *attr, char *buf)
0041 {
0042 struct bnx2i_hba *hba = bnx2i_dev_to_hba(dev);
0043
0044 return sprintf(buf, "0x%x\n", hba->max_sqes);
0045 }
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059 static ssize_t bnx2i_set_sq_info(struct device *dev,
0060 struct device_attribute *attr,
0061 const char *buf, size_t count)
0062 {
0063 struct bnx2i_hba *hba = bnx2i_dev_to_hba(dev);
0064 u32 val;
0065 int max_sq_size;
0066
0067 if (hba->ofld_conns_active)
0068 goto skip_config;
0069
0070 if (test_bit(BNX2I_NX2_DEV_57710, &hba->cnic_dev_type))
0071 max_sq_size = BNX2I_5770X_SQ_WQES_MAX;
0072 else
0073 max_sq_size = BNX2I_570X_SQ_WQES_MAX;
0074
0075 if (sscanf(buf, " 0x%x ", &val) > 0) {
0076 if ((val >= BNX2I_SQ_WQES_MIN) && (val <= max_sq_size) &&
0077 (is_power_of_2(val)))
0078 hba->max_sqes = val;
0079 }
0080
0081 return count;
0082
0083 skip_config:
0084 printk(KERN_ERR "bnx2i: device busy, cannot change SQ size\n");
0085 return 0;
0086 }
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097 static ssize_t bnx2i_show_ccell_info(struct device *dev,
0098 struct device_attribute *attr, char *buf)
0099 {
0100 struct bnx2i_hba *hba = bnx2i_dev_to_hba(dev);
0101
0102 return sprintf(buf, "0x%x\n", hba->num_ccell);
0103 }
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113
0114
0115 static ssize_t bnx2i_set_ccell_info(struct device *dev,
0116 struct device_attribute *attr,
0117 const char *buf, size_t count)
0118 {
0119 u32 val;
0120 struct bnx2i_hba *hba = bnx2i_dev_to_hba(dev);
0121
0122 if (hba->ofld_conns_active)
0123 goto skip_config;
0124
0125 if (sscanf(buf, " 0x%x ", &val) > 0) {
0126 if ((val >= BNX2I_CCELLS_MIN) &&
0127 (val <= BNX2I_CCELLS_MAX)) {
0128 hba->num_ccell = val;
0129 }
0130 }
0131
0132 return count;
0133
0134 skip_config:
0135 printk(KERN_ERR "bnx2i: device busy, cannot change CCELL size\n");
0136 return 0;
0137 }
0138
0139
0140 static DEVICE_ATTR(sq_size, S_IRUGO | S_IWUSR,
0141 bnx2i_show_sq_info, bnx2i_set_sq_info);
0142 static DEVICE_ATTR(num_ccell, S_IRUGO | S_IWUSR,
0143 bnx2i_show_ccell_info, bnx2i_set_ccell_info);
0144
0145 static struct attribute *bnx2i_dev_attributes[] = {
0146 &dev_attr_sq_size.attr,
0147 &dev_attr_num_ccell.attr,
0148 NULL
0149 };
0150
0151 static const struct attribute_group bnx2i_dev_attr_group = {
0152 .attrs = bnx2i_dev_attributes
0153 };
0154
0155 const struct attribute_group *bnx2i_dev_groups[] = {
0156 &bnx2i_dev_attr_group,
0157 NULL
0158 };