Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
bnx2i_sysfs.c
Go to the documentation of this file.
1 /* bnx2i_sysfs.c: Broadcom NetXtreme II iSCSI driver.
2  *
3  * Copyright (c) 2004 - 2012 Broadcom Corporation
4  *
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.
8  *
9  * Written by: Anil Veerabhadrappa ([email protected])
10  * Maintained by: Eddie Wai ([email protected])
11  */
12 
13 #include "bnx2i.h"
14 
21 static inline struct bnx2i_hba *bnx2i_dev_to_hba(struct device *dev)
22 {
23  struct Scsi_Host *shost = class_to_shost(dev);
24  return iscsi_host_priv(shost);
25 }
26 
27 
36 static ssize_t bnx2i_show_sq_info(struct device *dev,
37  struct device_attribute *attr, char *buf)
38 {
39  struct bnx2i_hba *hba = bnx2i_dev_to_hba(dev);
40 
41  return sprintf(buf, "0x%x\n", hba->max_sqes);
42 }
43 
44 
55 static ssize_t bnx2i_set_sq_info(struct device *dev,
56  struct device_attribute *attr,
57  const char *buf, size_t count)
58 {
59  struct bnx2i_hba *hba = bnx2i_dev_to_hba(dev);
60  u32 val;
61  int max_sq_size;
62 
63  if (hba->ofld_conns_active)
64  goto skip_config;
65 
67  max_sq_size = BNX2I_5770X_SQ_WQES_MAX;
68  else
69  max_sq_size = BNX2I_570X_SQ_WQES_MAX;
70 
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;
75  }
76 
77  return count;
78 
79 skip_config:
80  printk(KERN_ERR "bnx2i: device busy, cannot change SQ size\n");
81  return 0;
82 }
83 
84 
92 static ssize_t bnx2i_show_ccell_info(struct device *dev,
93  struct device_attribute *attr, char *buf)
94 {
95  struct bnx2i_hba *hba = bnx2i_dev_to_hba(dev);
96 
97  return sprintf(buf, "0x%x\n", hba->num_ccell);
98 }
99 
100 
109 static ssize_t bnx2i_set_ccell_info(struct device *dev,
110  struct device_attribute *attr,
111  const char *buf, size_t count)
112 {
113  u32 val;
114  struct bnx2i_hba *hba = bnx2i_dev_to_hba(dev);
115 
116  if (hba->ofld_conns_active)
117  goto skip_config;
118 
119  if (sscanf(buf, " 0x%x ", &val) > 0) {
120  if ((val >= BNX2I_CCELLS_MIN) &&
121  (val <= BNX2I_CCELLS_MAX)) {
122  hba->num_ccell = val;
123  }
124  }
125 
126  return count;
127 
128 skip_config:
129  printk(KERN_ERR "bnx2i: device busy, cannot change CCELL size\n");
130  return 0;
131 }
132 
133 
135  bnx2i_show_sq_info, bnx2i_set_sq_info);
137  bnx2i_show_ccell_info, bnx2i_set_ccell_info);
138 
140  &dev_attr_sq_size,
141  &dev_attr_num_ccell,
142  NULL
143 };