Linux kernel & device driver programming

Cross-Referenced Linux and Device Driver Code

[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ]
Version: [ 2.6.11.8 ] [ 2.6.25 ] [ 2.6.25.8 ] [ 2.6.31.13 ] Architecture: [ i386 ]
  1 /* bnx2i_sysfs.c: Broadcom NetXtreme II iSCSI driver.
  2  *
  3  * Copyright (c) 2004 - 2009 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 (anilgv@broadcom.com)
 10  */
 11 
 12 #include "bnx2i.h"
 13 
 14 /**
 15  * bnx2i_dev_to_hba - maps dev pointer to adapter struct
 16  * @dev:        device pointer
 17  *
 18  * Map device to hba structure
 19  */
 20 static inline struct bnx2i_hba *bnx2i_dev_to_hba(struct device *dev)
 21 {
 22         struct Scsi_Host *shost = class_to_shost(dev);
 23         return iscsi_host_priv(shost);
 24 }
 25 
 26 
 27 /**
 28  * bnx2i_show_sq_info - return(s currently configured send queue (SQ) size
 29  * @dev:        device pointer
 30  * @buf:        buffer to return current SQ size parameter
 31  *
 32  * Returns current SQ size parameter, this paramater determines the number
 33  * outstanding iSCSI commands supported on a connection
 34  */
 35 static ssize_t bnx2i_show_sq_info(struct device *dev,
 36                                   struct device_attribute *attr, char *buf)
 37 {
 38         struct bnx2i_hba *hba = bnx2i_dev_to_hba(dev);
 39 
 40         return sprintf(buf, "0x%x\n", hba->max_sqes);
 41 }
 42 
 43 
 44 /**
 45  * bnx2i_set_sq_info - update send queue (SQ) size parameter
 46  * @dev:        device pointer
 47  * @buf:        buffer to return current SQ size parameter
 48  * @count:      parameter buffer size
 49  *
 50  * Interface for user to change shared queue size allocated for each conn
 51  * Must be within SQ limits and a power of 2. For the latter this is needed
 52  * because of how libiscsi preallocates tasks.
 53  */
 54 static ssize_t bnx2i_set_sq_info(struct device *dev,
 55                                  struct device_attribute *attr,
 56                                  const char *buf, size_t count)
 57 {
 58         struct bnx2i_hba *hba = bnx2i_dev_to_hba(dev);
 59         u32 val;
 60         int max_sq_size;
 61 
 62         if (hba->ofld_conns_active)
 63                 goto skip_config;
 64 
 65         if (test_bit(BNX2I_NX2_DEV_57710, &hba->cnic_dev_type))
 66                 max_sq_size = BNX2I_5770X_SQ_WQES_MAX;
 67         else
 68                 max_sq_size = BNX2I_570X_SQ_WQES_MAX;
 69 
 70         if (sscanf(buf, " 0x%x ", &val) > 0) {
 71                 if ((val >= BNX2I_SQ_WQES_MIN) && (val <= max_sq_size) &&
 72                     (is_power_of_2(val)))
 73                         hba->max_sqes = val;
 74         }
 75 
 76         return count;
 77 
 78 skip_config:
 79         printk(KERN_ERR "bnx2i: device busy, cannot change SQ size\n");
 80         return 0;
 81 }
 82 
 83 
 84 /**
 85  * bnx2i_show_ccell_info - returns command cell (HQ) size
 86  * @dev:        device pointer
 87  * @buf:        buffer to return current SQ size parameter
 88  *
 89  * returns per-connection TCP history queue size parameter
 90  */
 91 static ssize_t bnx2i_show_ccell_info(struct device *dev,
 92                                      struct device_attribute *attr, char *buf)
 93 {
 94         struct bnx2i_hba *hba = bnx2i_dev_to_hba(dev);
 95 
 96         return sprintf(buf, "0x%x\n", hba->num_ccell);
 97 }
 98 
 99 
100 /**
101  * bnx2i_get_link_state - set command cell (HQ) size
102  * @dev:        device pointer
103  * @buf:        buffer to return current SQ size parameter
104  * @count:      parameter buffer size
105  *
106  * updates per-connection TCP history queue size parameter
107  */
108 static ssize_t bnx2i_set_ccell_info(struct device *dev,
109                                     struct device_attribute *attr,
110                                     const char *buf, size_t count)
111 {
112         u32 val;
113         struct bnx2i_hba *hba = bnx2i_dev_to_hba(dev);
114 
115         if (hba->ofld_conns_active)
116                 goto skip_config;
117 
118         if (sscanf(buf, " 0x%x ", &val) > 0) {
119                 if ((val >= BNX2I_CCELLS_MIN) &&
120                     (val <= BNX2I_CCELLS_MAX)) {
121                         hba->num_ccell = val;
122                 }
123         }
124 
125         return count;
126 
127 skip_config:
128         printk(KERN_ERR "bnx2i: device busy, cannot change CCELL size\n");
129         return 0;
130 }
131 
132 
133 static DEVICE_ATTR(sq_size, S_IRUGO | S_IWUSR,
134                    bnx2i_show_sq_info, bnx2i_set_sq_info);
135 static DEVICE_ATTR(num_ccell, S_IRUGO | S_IWUSR,
136                    bnx2i_show_ccell_info, bnx2i_set_ccell_info);
137 
138 struct device_attribute *bnx2i_dev_attributes[] = {
139         &dev_attr_sq_size,
140         &dev_attr_num_ccell,
141         NULL
142 };
143 
  This page was automatically generated by the LXR engine.