This source file includes following definitions.
- bnx2i_dev_to_hba
- bnx2i_show_sq_info
- bnx2i_set_sq_info
- bnx2i_show_ccell_info
- bnx2i_set_ccell_info
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 #include "bnx2i.h"
16
17
18
19
20
21
22
23 static inline struct bnx2i_hba *bnx2i_dev_to_hba(struct device *dev)
24 {
25 struct Scsi_Host *shost = class_to_shost(dev);
26 return iscsi_host_priv(shost);
27 }
28
29
30
31
32
33
34
35
36
37
38 static ssize_t bnx2i_show_sq_info(struct device *dev,
39 struct device_attribute *attr, char *buf)
40 {
41 struct bnx2i_hba *hba = bnx2i_dev_to_hba(dev);
42
43 return sprintf(buf, "0x%x\n", hba->max_sqes);
44 }
45
46
47
48
49
50
51
52
53
54
55
56
57 static ssize_t bnx2i_set_sq_info(struct device *dev,
58 struct device_attribute *attr,
59 const char *buf, size_t count)
60 {
61 struct bnx2i_hba *hba = bnx2i_dev_to_hba(dev);
62 u32 val;
63 int max_sq_size;
64
65 if (hba->ofld_conns_active)
66 goto skip_config;
67
68 if (test_bit(BNX2I_NX2_DEV_57710, &hba->cnic_dev_type))
69 max_sq_size = BNX2I_5770X_SQ_WQES_MAX;
70 else
71 max_sq_size = BNX2I_570X_SQ_WQES_MAX;
72
73 if (sscanf(buf, " 0x%x ", &val) > 0) {
74 if ((val >= BNX2I_SQ_WQES_MIN) && (val <= max_sq_size) &&
75 (is_power_of_2(val)))
76 hba->max_sqes = val;
77 }
78
79 return count;
80
81 skip_config:
82 printk(KERN_ERR "bnx2i: device busy, cannot change SQ size\n");
83 return 0;
84 }
85
86
87
88
89
90
91
92
93
94 static ssize_t bnx2i_show_ccell_info(struct device *dev,
95 struct device_attribute *attr, char *buf)
96 {
97 struct bnx2i_hba *hba = bnx2i_dev_to_hba(dev);
98
99 return sprintf(buf, "0x%x\n", hba->num_ccell);
100 }
101
102
103
104
105
106
107
108
109
110
111 static ssize_t bnx2i_set_ccell_info(struct device *dev,
112 struct device_attribute *attr,
113 const char *buf, size_t count)
114 {
115 u32 val;
116 struct bnx2i_hba *hba = bnx2i_dev_to_hba(dev);
117
118 if (hba->ofld_conns_active)
119 goto skip_config;
120
121 if (sscanf(buf, " 0x%x ", &val) > 0) {
122 if ((val >= BNX2I_CCELLS_MIN) &&
123 (val <= BNX2I_CCELLS_MAX)) {
124 hba->num_ccell = val;
125 }
126 }
127
128 return count;
129
130 skip_config:
131 printk(KERN_ERR "bnx2i: device busy, cannot change CCELL size\n");
132 return 0;
133 }
134
135
136 static DEVICE_ATTR(sq_size, S_IRUGO | S_IWUSR,
137 bnx2i_show_sq_info, bnx2i_set_sq_info);
138 static DEVICE_ATTR(num_ccell, S_IRUGO | S_IWUSR,
139 bnx2i_show_ccell_info, bnx2i_set_ccell_info);
140
141 struct device_attribute *bnx2i_dev_attributes[] = {
142 &dev_attr_sq_size,
143 &dev_attr_num_ccell,
144 NULL
145 };