perf intel-pt: Factor out intel_pt_8b_tsc()
[linux/fpc-iii.git] / drivers / scsi / bnx2i / bnx2i_sysfs.c
blob6d56fd60cb2b2a4f2ec514581cf29cb88110c24f
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
15 #include "bnx2i.h"
17 /**
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);
30 /**
31 * bnx2i_show_sq_info - return(s currently configured send queue (SQ) size
32 * @dev: device pointer
33 * @buf: buffer to return current SQ size parameter
35 * Returns current SQ size parameter, this paramater determines the number
36 * outstanding iSCSI commands supported on a connection
38 static ssize_t bnx2i_show_sq_info(struct device *dev,
39 struct device_attribute *attr, char *buf)
41 struct bnx2i_hba *hba = bnx2i_dev_to_hba(dev);
43 return sprintf(buf, "0x%x\n", hba->max_sqes);
47 /**
48 * bnx2i_set_sq_info - update send queue (SQ) size parameter
49 * @dev: device pointer
50 * @buf: buffer to return current SQ size parameter
51 * @count: parameter buffer size
53 * Interface for user to change shared queue size allocated for each conn
54 * Must be within SQ limits and a power of 2. For the latter this is needed
55 * because of how libiscsi preallocates tasks.
57 static ssize_t bnx2i_set_sq_info(struct device *dev,
58 struct device_attribute *attr,
59 const char *buf, size_t count)
61 struct bnx2i_hba *hba = bnx2i_dev_to_hba(dev);
62 u32 val;
63 int max_sq_size;
65 if (hba->ofld_conns_active)
66 goto skip_config;
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;
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;
79 return count;
81 skip_config:
82 printk(KERN_ERR "bnx2i: device busy, cannot change SQ size\n");
83 return 0;
87 /**
88 * bnx2i_show_ccell_info - returns command cell (HQ) size
89 * @dev: device pointer
90 * @buf: buffer to return current SQ size parameter
92 * returns per-connection TCP history queue size parameter
94 static ssize_t bnx2i_show_ccell_info(struct device *dev,
95 struct device_attribute *attr, char *buf)
97 struct bnx2i_hba *hba = bnx2i_dev_to_hba(dev);
99 return sprintf(buf, "0x%x\n", hba->num_ccell);
104 * bnx2i_get_link_state - set command cell (HQ) size
105 * @dev: device pointer
106 * @buf: buffer to return current SQ size parameter
107 * @count: parameter buffer size
109 * updates per-connection TCP history queue size parameter
111 static ssize_t bnx2i_set_ccell_info(struct device *dev,
112 struct device_attribute *attr,
113 const char *buf, size_t count)
115 u32 val;
116 struct bnx2i_hba *hba = bnx2i_dev_to_hba(dev);
118 if (hba->ofld_conns_active)
119 goto skip_config;
121 if (sscanf(buf, " 0x%x ", &val) > 0) {
122 if ((val >= BNX2I_CCELLS_MIN) &&
123 (val <= BNX2I_CCELLS_MAX)) {
124 hba->num_ccell = val;
128 return count;
130 skip_config:
131 printk(KERN_ERR "bnx2i: device busy, cannot change CCELL size\n");
132 return 0;
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);
141 struct device_attribute *bnx2i_dev_attributes[] = {
142 &dev_attr_sq_size,
143 &dev_attr_num_ccell,
144 NULL