1 /* bnx2i_sysfs.c: QLogic NetXtreme II iSCSI driver.
3 * Copyright (c) 2004 - 2013 Broadcom Corporation
4 * Copyright (c) 2014, QLogic Corporation
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation.
10 * Written by: Anil Veerabhadrappa (anilgv@broadcom.com)
11 * Previously Maintained by: Eddie Wai (eddie.wai@broadcom.com)
12 * Maintained by: QLogic-Storage-Upstream@qlogic.com
18 * bnx2i_dev_to_hba - maps dev pointer to adapter struct
19 * @dev: device pointer
21 * Map device to hba structure
23 static inline struct bnx2i_hba
*bnx2i_dev_to_hba(struct device
*dev
)
25 struct Scsi_Host
*shost
= class_to_shost(dev
);
26 return iscsi_host_priv(shost
);
31 * bnx2i_show_sq_info - return(s currently configured send queue (SQ) size
32 * @dev: device pointer
33 * @attr: device attribute (unused)
34 * @buf: buffer to return current SQ size parameter
36 * Returns current SQ size parameter, this paramater determines the number
37 * outstanding iSCSI commands supported on a connection
39 static ssize_t
bnx2i_show_sq_info(struct device
*dev
,
40 struct device_attribute
*attr
, char *buf
)
42 struct bnx2i_hba
*hba
= bnx2i_dev_to_hba(dev
);
44 return sprintf(buf
, "0x%x\n", hba
->max_sqes
);
49 * bnx2i_set_sq_info - update send queue (SQ) size parameter
50 * @dev: device pointer
51 * @attr: device attribute (unused)
52 * @buf: buffer to return current SQ size parameter
53 * @count: parameter buffer size
55 * Interface for user to change shared queue size allocated for each conn
56 * Must be within SQ limits and a power of 2. For the latter this is needed
57 * because of how libiscsi preallocates tasks.
59 static ssize_t
bnx2i_set_sq_info(struct device
*dev
,
60 struct device_attribute
*attr
,
61 const char *buf
, size_t count
)
63 struct bnx2i_hba
*hba
= bnx2i_dev_to_hba(dev
);
67 if (hba
->ofld_conns_active
)
70 if (test_bit(BNX2I_NX2_DEV_57710
, &hba
->cnic_dev_type
))
71 max_sq_size
= BNX2I_5770X_SQ_WQES_MAX
;
73 max_sq_size
= BNX2I_570X_SQ_WQES_MAX
;
75 if (sscanf(buf
, " 0x%x ", &val
) > 0) {
76 if ((val
>= BNX2I_SQ_WQES_MIN
) && (val
<= max_sq_size
) &&
84 printk(KERN_ERR
"bnx2i: device busy, cannot change SQ size\n");
90 * bnx2i_show_ccell_info - returns command cell (HQ) size
91 * @dev: device pointer
92 * @attr: device attribute (unused)
93 * @buf: buffer to return current SQ size parameter
95 * returns per-connection TCP history queue size parameter
97 static ssize_t
bnx2i_show_ccell_info(struct device
*dev
,
98 struct device_attribute
*attr
, char *buf
)
100 struct bnx2i_hba
*hba
= bnx2i_dev_to_hba(dev
);
102 return sprintf(buf
, "0x%x\n", hba
->num_ccell
);
107 * bnx2i_get_link_state - set command cell (HQ) size
108 * @dev: device pointer
109 * @attr: device attribute (unused)
110 * @buf: buffer to return current SQ size parameter
111 * @count: parameter buffer size
113 * updates per-connection TCP history queue size parameter
115 static ssize_t
bnx2i_set_ccell_info(struct device
*dev
,
116 struct device_attribute
*attr
,
117 const char *buf
, size_t count
)
120 struct bnx2i_hba
*hba
= bnx2i_dev_to_hba(dev
);
122 if (hba
->ofld_conns_active
)
125 if (sscanf(buf
, " 0x%x ", &val
) > 0) {
126 if ((val
>= BNX2I_CCELLS_MIN
) &&
127 (val
<= BNX2I_CCELLS_MAX
)) {
128 hba
->num_ccell
= val
;
135 printk(KERN_ERR
"bnx2i: device busy, cannot change CCELL size\n");
140 static DEVICE_ATTR(sq_size
, S_IRUGO
| S_IWUSR
,
141 bnx2i_show_sq_info
, bnx2i_set_sq_info
);
142 static DEVICE_ATTR(num_ccell
, S_IRUGO
| S_IWUSR
,
143 bnx2i_show_ccell_info
, bnx2i_set_ccell_info
);
145 struct device_attribute
*bnx2i_dev_attributes
[] = {