Andy Fleming | 7f7f531 | 2005-11-11 12:38:59 -0600 | [diff] [blame] | 1 | /* |
| 2 | * drivers/net/gianfar_sysfs.c |
| 3 | * |
| 4 | * Gianfar Ethernet Driver |
| 5 | * This driver is designed for the non-CPM ethernet controllers |
| 6 | * on the 85xx and 83xx family of integrated processors |
| 7 | * Based on 8260_io/fcc_enet.c |
| 8 | * |
| 9 | * Author: Andy Fleming |
Adrian Bunk | b56d55b | 2006-01-11 02:00:10 +0100 | [diff] [blame] | 10 | * Maintainer: Kumar Gala (galak@kernel.crashing.org) |
Sandeep Gopalpet | a12f801 | 2009-11-02 07:03:00 +0000 | [diff] [blame^] | 11 | * Modifier: Sandeep Gopalpet <sandeep.kumar@freescale.com> |
Andy Fleming | 7f7f531 | 2005-11-11 12:38:59 -0600 | [diff] [blame] | 12 | * |
Sandeep Gopalpet | a12f801 | 2009-11-02 07:03:00 +0000 | [diff] [blame^] | 13 | * Copyright 2002-2009 Freescale Semiconductor, Inc. |
Andy Fleming | 7f7f531 | 2005-11-11 12:38:59 -0600 | [diff] [blame] | 14 | * |
| 15 | * This program is free software; you can redistribute it and/or modify it |
| 16 | * under the terms of the GNU General Public License as published by the |
| 17 | * Free Software Foundation; either version 2 of the License, or (at your |
| 18 | * option) any later version. |
| 19 | * |
| 20 | * Sysfs file creation and management |
| 21 | */ |
| 22 | |
Andy Fleming | 7f7f531 | 2005-11-11 12:38:59 -0600 | [diff] [blame] | 23 | #include <linux/kernel.h> |
Andy Fleming | 7f7f531 | 2005-11-11 12:38:59 -0600 | [diff] [blame] | 24 | #include <linux/string.h> |
| 25 | #include <linux/errno.h> |
| 26 | #include <linux/unistd.h> |
| 27 | #include <linux/slab.h> |
| 28 | #include <linux/init.h> |
| 29 | #include <linux/delay.h> |
| 30 | #include <linux/etherdevice.h> |
| 31 | #include <linux/spinlock.h> |
| 32 | #include <linux/mm.h> |
| 33 | #include <linux/device.h> |
| 34 | |
| 35 | #include <asm/uaccess.h> |
| 36 | #include <linux/module.h> |
Andy Fleming | 7f7f531 | 2005-11-11 12:38:59 -0600 | [diff] [blame] | 37 | |
| 38 | #include "gianfar.h" |
| 39 | |
Kumar Gala | 4409d28 | 2007-02-12 23:40:06 -0600 | [diff] [blame] | 40 | static ssize_t gfar_show_bd_stash(struct device *dev, |
| 41 | struct device_attribute *attr, char *buf) |
Andy Fleming | 7f7f531 | 2005-11-11 12:38:59 -0600 | [diff] [blame] | 42 | { |
Kumar Gala | 4409d28 | 2007-02-12 23:40:06 -0600 | [diff] [blame] | 43 | struct gfar_private *priv = netdev_priv(to_net_dev(dev)); |
Andy Fleming | 7f7f531 | 2005-11-11 12:38:59 -0600 | [diff] [blame] | 44 | |
Kumar Gala | 4409d28 | 2007-02-12 23:40:06 -0600 | [diff] [blame] | 45 | return sprintf(buf, "%s\n", priv->bd_stash_en ? "on" : "off"); |
Andy Fleming | 7f7f531 | 2005-11-11 12:38:59 -0600 | [diff] [blame] | 46 | } |
| 47 | |
Kumar Gala | 4409d28 | 2007-02-12 23:40:06 -0600 | [diff] [blame] | 48 | static ssize_t gfar_set_bd_stash(struct device *dev, |
| 49 | struct device_attribute *attr, |
| 50 | const char *buf, size_t count) |
Andy Fleming | 7f7f531 | 2005-11-11 12:38:59 -0600 | [diff] [blame] | 51 | { |
Kumar Gala | 4409d28 | 2007-02-12 23:40:06 -0600 | [diff] [blame] | 52 | struct gfar_private *priv = netdev_priv(to_net_dev(dev)); |
Sandeep Gopalpet | a12f801 | 2009-11-02 07:03:00 +0000 | [diff] [blame^] | 53 | struct gfar_priv_rx_q *rx_queue = NULL; |
Andy Fleming | 7f7f531 | 2005-11-11 12:38:59 -0600 | [diff] [blame] | 54 | int new_setting = 0; |
| 55 | u32 temp; |
| 56 | unsigned long flags; |
| 57 | |
Andy Fleming | 4d7902f | 2009-02-04 16:43:44 -0800 | [diff] [blame] | 58 | if (!(priv->device_flags & FSL_GIANFAR_DEV_HAS_BD_STASHING)) |
| 59 | return count; |
| 60 | |
Sandeep Gopalpet | a12f801 | 2009-11-02 07:03:00 +0000 | [diff] [blame^] | 61 | rx_queue = priv->rx_queue; |
| 62 | |
Andy Fleming | 7f7f531 | 2005-11-11 12:38:59 -0600 | [diff] [blame] | 63 | /* Find out the new setting */ |
Kumar Gala | 4409d28 | 2007-02-12 23:40:06 -0600 | [diff] [blame] | 64 | if (!strncmp("on", buf, count - 1) || !strncmp("1", buf, count - 1)) |
Andy Fleming | 7f7f531 | 2005-11-11 12:38:59 -0600 | [diff] [blame] | 65 | new_setting = 1; |
Kumar Gala | 4409d28 | 2007-02-12 23:40:06 -0600 | [diff] [blame] | 66 | else if (!strncmp("off", buf, count - 1) |
| 67 | || !strncmp("0", buf, count - 1)) |
Andy Fleming | 7f7f531 | 2005-11-11 12:38:59 -0600 | [diff] [blame] | 68 | new_setting = 0; |
| 69 | else |
| 70 | return count; |
| 71 | |
Sandeep Gopalpet | a12f801 | 2009-11-02 07:03:00 +0000 | [diff] [blame^] | 72 | spin_lock_irqsave(&rx_queue->rxlock, flags); |
Andy Fleming | 7f7f531 | 2005-11-11 12:38:59 -0600 | [diff] [blame] | 73 | |
| 74 | /* Set the new stashing value */ |
| 75 | priv->bd_stash_en = new_setting; |
| 76 | |
| 77 | temp = gfar_read(&priv->regs->attr); |
Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 78 | |
Andy Fleming | 7f7f531 | 2005-11-11 12:38:59 -0600 | [diff] [blame] | 79 | if (new_setting) |
| 80 | temp |= ATTR_BDSTASH; |
| 81 | else |
| 82 | temp &= ~(ATTR_BDSTASH); |
| 83 | |
| 84 | gfar_write(&priv->regs->attr, temp); |
| 85 | |
Sandeep Gopalpet | a12f801 | 2009-11-02 07:03:00 +0000 | [diff] [blame^] | 86 | spin_unlock_irqrestore(&rx_queue->rxlock, flags); |
Andy Fleming | 7f7f531 | 2005-11-11 12:38:59 -0600 | [diff] [blame] | 87 | |
| 88 | return count; |
| 89 | } |
| 90 | |
Anton Vorontsov | b2f66d1 | 2009-02-01 00:54:16 -0800 | [diff] [blame] | 91 | static DEVICE_ATTR(bd_stash, 0644, gfar_show_bd_stash, gfar_set_bd_stash); |
Grant Likely | 35a84fd | 2007-12-01 22:12:45 -0700 | [diff] [blame] | 92 | |
Kumar Gala | 4409d28 | 2007-02-12 23:40:06 -0600 | [diff] [blame] | 93 | static ssize_t gfar_show_rx_stash_size(struct device *dev, |
| 94 | struct device_attribute *attr, char *buf) |
Andy Fleming | 7f7f531 | 2005-11-11 12:38:59 -0600 | [diff] [blame] | 95 | { |
Kumar Gala | 4409d28 | 2007-02-12 23:40:06 -0600 | [diff] [blame] | 96 | struct gfar_private *priv = netdev_priv(to_net_dev(dev)); |
Andy Fleming | 7f7f531 | 2005-11-11 12:38:59 -0600 | [diff] [blame] | 97 | |
| 98 | return sprintf(buf, "%d\n", priv->rx_stash_size); |
| 99 | } |
| 100 | |
Kumar Gala | 4409d28 | 2007-02-12 23:40:06 -0600 | [diff] [blame] | 101 | static ssize_t gfar_set_rx_stash_size(struct device *dev, |
| 102 | struct device_attribute *attr, |
| 103 | const char *buf, size_t count) |
Andy Fleming | 7f7f531 | 2005-11-11 12:38:59 -0600 | [diff] [blame] | 104 | { |
Kumar Gala | 4409d28 | 2007-02-12 23:40:06 -0600 | [diff] [blame] | 105 | struct gfar_private *priv = netdev_priv(to_net_dev(dev)); |
Sandeep Gopalpet | a12f801 | 2009-11-02 07:03:00 +0000 | [diff] [blame^] | 106 | struct gfar_priv_rx_q *rx_queue = NULL; |
Andy Fleming | 7f7f531 | 2005-11-11 12:38:59 -0600 | [diff] [blame] | 107 | unsigned int length = simple_strtoul(buf, NULL, 0); |
| 108 | u32 temp; |
| 109 | unsigned long flags; |
| 110 | |
Andy Fleming | 4d7902f | 2009-02-04 16:43:44 -0800 | [diff] [blame] | 111 | if (!(priv->device_flags & FSL_GIANFAR_DEV_HAS_BUF_STASHING)) |
| 112 | return count; |
| 113 | |
Sandeep Gopalpet | a12f801 | 2009-11-02 07:03:00 +0000 | [diff] [blame^] | 114 | rx_queue = priv->rx_queue; |
| 115 | |
| 116 | spin_lock_irqsave(&rx_queue->rxlock, flags); |
Andy Fleming | 7f7f531 | 2005-11-11 12:38:59 -0600 | [diff] [blame] | 117 | if (length > priv->rx_buffer_size) |
Andy Fleming | f162b9d | 2008-05-02 13:00:30 -0500 | [diff] [blame] | 118 | goto out; |
Andy Fleming | 7f7f531 | 2005-11-11 12:38:59 -0600 | [diff] [blame] | 119 | |
| 120 | if (length == priv->rx_stash_size) |
Andy Fleming | f162b9d | 2008-05-02 13:00:30 -0500 | [diff] [blame] | 121 | goto out; |
Andy Fleming | 7f7f531 | 2005-11-11 12:38:59 -0600 | [diff] [blame] | 122 | |
| 123 | priv->rx_stash_size = length; |
| 124 | |
| 125 | temp = gfar_read(&priv->regs->attreli); |
| 126 | temp &= ~ATTRELI_EL_MASK; |
| 127 | temp |= ATTRELI_EL(length); |
| 128 | gfar_write(&priv->regs->attreli, temp); |
| 129 | |
| 130 | /* Turn stashing on/off as appropriate */ |
| 131 | temp = gfar_read(&priv->regs->attr); |
| 132 | |
| 133 | if (length) |
| 134 | temp |= ATTR_BUFSTASH; |
| 135 | else |
| 136 | temp &= ~(ATTR_BUFSTASH); |
| 137 | |
| 138 | gfar_write(&priv->regs->attr, temp); |
| 139 | |
Andy Fleming | f162b9d | 2008-05-02 13:00:30 -0500 | [diff] [blame] | 140 | out: |
Sandeep Gopalpet | a12f801 | 2009-11-02 07:03:00 +0000 | [diff] [blame^] | 141 | spin_unlock_irqrestore(&rx_queue->rxlock, flags); |
Andy Fleming | 7f7f531 | 2005-11-11 12:38:59 -0600 | [diff] [blame] | 142 | |
| 143 | return count; |
| 144 | } |
| 145 | |
Anton Vorontsov | b2f66d1 | 2009-02-01 00:54:16 -0800 | [diff] [blame] | 146 | static DEVICE_ATTR(rx_stash_size, 0644, gfar_show_rx_stash_size, |
| 147 | gfar_set_rx_stash_size); |
Grant Likely | 35a84fd | 2007-12-01 22:12:45 -0700 | [diff] [blame] | 148 | |
Andy Fleming | 7f7f531 | 2005-11-11 12:38:59 -0600 | [diff] [blame] | 149 | /* Stashing will only be enabled when rx_stash_size != 0 */ |
Kumar Gala | 4409d28 | 2007-02-12 23:40:06 -0600 | [diff] [blame] | 150 | static ssize_t gfar_show_rx_stash_index(struct device *dev, |
| 151 | struct device_attribute *attr, |
| 152 | char *buf) |
Andy Fleming | 7f7f531 | 2005-11-11 12:38:59 -0600 | [diff] [blame] | 153 | { |
Kumar Gala | 4409d28 | 2007-02-12 23:40:06 -0600 | [diff] [blame] | 154 | struct gfar_private *priv = netdev_priv(to_net_dev(dev)); |
Andy Fleming | 7f7f531 | 2005-11-11 12:38:59 -0600 | [diff] [blame] | 155 | |
| 156 | return sprintf(buf, "%d\n", priv->rx_stash_index); |
| 157 | } |
| 158 | |
Kumar Gala | 4409d28 | 2007-02-12 23:40:06 -0600 | [diff] [blame] | 159 | static ssize_t gfar_set_rx_stash_index(struct device *dev, |
| 160 | struct device_attribute *attr, |
| 161 | const char *buf, size_t count) |
Andy Fleming | 7f7f531 | 2005-11-11 12:38:59 -0600 | [diff] [blame] | 162 | { |
Kumar Gala | 4409d28 | 2007-02-12 23:40:06 -0600 | [diff] [blame] | 163 | struct gfar_private *priv = netdev_priv(to_net_dev(dev)); |
Sandeep Gopalpet | a12f801 | 2009-11-02 07:03:00 +0000 | [diff] [blame^] | 164 | struct gfar_priv_rx_q *rx_queue = NULL; |
Andy Fleming | 7f7f531 | 2005-11-11 12:38:59 -0600 | [diff] [blame] | 165 | unsigned short index = simple_strtoul(buf, NULL, 0); |
| 166 | u32 temp; |
| 167 | unsigned long flags; |
| 168 | |
Andy Fleming | 4d7902f | 2009-02-04 16:43:44 -0800 | [diff] [blame] | 169 | if (!(priv->device_flags & FSL_GIANFAR_DEV_HAS_BUF_STASHING)) |
| 170 | return count; |
| 171 | |
Sandeep Gopalpet | a12f801 | 2009-11-02 07:03:00 +0000 | [diff] [blame^] | 172 | rx_queue = priv->rx_queue; |
| 173 | |
| 174 | spin_lock_irqsave(&rx_queue->rxlock, flags); |
Andy Fleming | 7f7f531 | 2005-11-11 12:38:59 -0600 | [diff] [blame] | 175 | if (index > priv->rx_stash_size) |
Andy Fleming | f162b9d | 2008-05-02 13:00:30 -0500 | [diff] [blame] | 176 | goto out; |
Andy Fleming | 7f7f531 | 2005-11-11 12:38:59 -0600 | [diff] [blame] | 177 | |
| 178 | if (index == priv->rx_stash_index) |
Andy Fleming | f162b9d | 2008-05-02 13:00:30 -0500 | [diff] [blame] | 179 | goto out; |
Andy Fleming | 7f7f531 | 2005-11-11 12:38:59 -0600 | [diff] [blame] | 180 | |
| 181 | priv->rx_stash_index = index; |
| 182 | |
| 183 | temp = gfar_read(&priv->regs->attreli); |
| 184 | temp &= ~ATTRELI_EI_MASK; |
| 185 | temp |= ATTRELI_EI(index); |
| 186 | gfar_write(&priv->regs->attreli, flags); |
| 187 | |
Andy Fleming | f162b9d | 2008-05-02 13:00:30 -0500 | [diff] [blame] | 188 | out: |
Sandeep Gopalpet | a12f801 | 2009-11-02 07:03:00 +0000 | [diff] [blame^] | 189 | spin_unlock_irqrestore(&rx_queue->rxlock, flags); |
Andy Fleming | 7f7f531 | 2005-11-11 12:38:59 -0600 | [diff] [blame] | 190 | |
| 191 | return count; |
| 192 | } |
| 193 | |
Anton Vorontsov | b2f66d1 | 2009-02-01 00:54:16 -0800 | [diff] [blame] | 194 | static DEVICE_ATTR(rx_stash_index, 0644, gfar_show_rx_stash_index, |
| 195 | gfar_set_rx_stash_index); |
Grant Likely | 35a84fd | 2007-12-01 22:12:45 -0700 | [diff] [blame] | 196 | |
Kumar Gala | 4409d28 | 2007-02-12 23:40:06 -0600 | [diff] [blame] | 197 | static ssize_t gfar_show_fifo_threshold(struct device *dev, |
| 198 | struct device_attribute *attr, |
| 199 | char *buf) |
Andy Fleming | 7f7f531 | 2005-11-11 12:38:59 -0600 | [diff] [blame] | 200 | { |
Kumar Gala | 4409d28 | 2007-02-12 23:40:06 -0600 | [diff] [blame] | 201 | struct gfar_private *priv = netdev_priv(to_net_dev(dev)); |
Andy Fleming | 7f7f531 | 2005-11-11 12:38:59 -0600 | [diff] [blame] | 202 | |
| 203 | return sprintf(buf, "%d\n", priv->fifo_threshold); |
| 204 | } |
| 205 | |
Kumar Gala | 4409d28 | 2007-02-12 23:40:06 -0600 | [diff] [blame] | 206 | static ssize_t gfar_set_fifo_threshold(struct device *dev, |
| 207 | struct device_attribute *attr, |
| 208 | const char *buf, size_t count) |
Andy Fleming | 7f7f531 | 2005-11-11 12:38:59 -0600 | [diff] [blame] | 209 | { |
Kumar Gala | 4409d28 | 2007-02-12 23:40:06 -0600 | [diff] [blame] | 210 | struct gfar_private *priv = netdev_priv(to_net_dev(dev)); |
Sandeep Gopalpet | a12f801 | 2009-11-02 07:03:00 +0000 | [diff] [blame^] | 211 | struct gfar_priv_tx_q *tx_queue = NULL; |
Andy Fleming | 7f7f531 | 2005-11-11 12:38:59 -0600 | [diff] [blame] | 212 | unsigned int length = simple_strtoul(buf, NULL, 0); |
| 213 | u32 temp; |
| 214 | unsigned long flags; |
| 215 | |
| 216 | if (length > GFAR_MAX_FIFO_THRESHOLD) |
| 217 | return count; |
| 218 | |
Sandeep Gopalpet | a12f801 | 2009-11-02 07:03:00 +0000 | [diff] [blame^] | 219 | tx_queue = priv->tx_queue; |
| 220 | |
| 221 | spin_lock_irqsave(&tx_queue->txlock, flags); |
Andy Fleming | 7f7f531 | 2005-11-11 12:38:59 -0600 | [diff] [blame] | 222 | |
| 223 | priv->fifo_threshold = length; |
| 224 | |
| 225 | temp = gfar_read(&priv->regs->fifo_tx_thr); |
| 226 | temp &= ~FIFO_TX_THR_MASK; |
| 227 | temp |= length; |
| 228 | gfar_write(&priv->regs->fifo_tx_thr, temp); |
| 229 | |
Sandeep Gopalpet | a12f801 | 2009-11-02 07:03:00 +0000 | [diff] [blame^] | 230 | spin_unlock_irqrestore(&tx_queue->txlock, flags); |
Andy Fleming | 7f7f531 | 2005-11-11 12:38:59 -0600 | [diff] [blame] | 231 | |
| 232 | return count; |
| 233 | } |
| 234 | |
Anton Vorontsov | b2f66d1 | 2009-02-01 00:54:16 -0800 | [diff] [blame] | 235 | static DEVICE_ATTR(fifo_threshold, 0644, gfar_show_fifo_threshold, |
| 236 | gfar_set_fifo_threshold); |
Grant Likely | 35a84fd | 2007-12-01 22:12:45 -0700 | [diff] [blame] | 237 | |
Kumar Gala | 4409d28 | 2007-02-12 23:40:06 -0600 | [diff] [blame] | 238 | static ssize_t gfar_show_fifo_starve(struct device *dev, |
| 239 | struct device_attribute *attr, char *buf) |
Andy Fleming | 7f7f531 | 2005-11-11 12:38:59 -0600 | [diff] [blame] | 240 | { |
Kumar Gala | 4409d28 | 2007-02-12 23:40:06 -0600 | [diff] [blame] | 241 | struct gfar_private *priv = netdev_priv(to_net_dev(dev)); |
Andy Fleming | 7f7f531 | 2005-11-11 12:38:59 -0600 | [diff] [blame] | 242 | |
| 243 | return sprintf(buf, "%d\n", priv->fifo_starve); |
| 244 | } |
| 245 | |
Kumar Gala | 4409d28 | 2007-02-12 23:40:06 -0600 | [diff] [blame] | 246 | static ssize_t gfar_set_fifo_starve(struct device *dev, |
| 247 | struct device_attribute *attr, |
| 248 | const char *buf, size_t count) |
Andy Fleming | 7f7f531 | 2005-11-11 12:38:59 -0600 | [diff] [blame] | 249 | { |
Kumar Gala | 4409d28 | 2007-02-12 23:40:06 -0600 | [diff] [blame] | 250 | struct gfar_private *priv = netdev_priv(to_net_dev(dev)); |
Sandeep Gopalpet | a12f801 | 2009-11-02 07:03:00 +0000 | [diff] [blame^] | 251 | struct gfar_priv_tx_q *tx_queue = NULL; |
Andy Fleming | 7f7f531 | 2005-11-11 12:38:59 -0600 | [diff] [blame] | 252 | unsigned int num = simple_strtoul(buf, NULL, 0); |
| 253 | u32 temp; |
| 254 | unsigned long flags; |
| 255 | |
| 256 | if (num > GFAR_MAX_FIFO_STARVE) |
| 257 | return count; |
| 258 | |
Sandeep Gopalpet | a12f801 | 2009-11-02 07:03:00 +0000 | [diff] [blame^] | 259 | tx_queue = priv->tx_queue; |
| 260 | spin_lock_irqsave(&tx_queue->txlock, flags); |
Andy Fleming | 7f7f531 | 2005-11-11 12:38:59 -0600 | [diff] [blame] | 261 | |
| 262 | priv->fifo_starve = num; |
| 263 | |
| 264 | temp = gfar_read(&priv->regs->fifo_tx_starve); |
| 265 | temp &= ~FIFO_TX_STARVE_MASK; |
| 266 | temp |= num; |
| 267 | gfar_write(&priv->regs->fifo_tx_starve, temp); |
| 268 | |
Sandeep Gopalpet | a12f801 | 2009-11-02 07:03:00 +0000 | [diff] [blame^] | 269 | spin_unlock_irqrestore(&tx_queue->txlock, flags); |
Andy Fleming | 7f7f531 | 2005-11-11 12:38:59 -0600 | [diff] [blame] | 270 | |
| 271 | return count; |
| 272 | } |
| 273 | |
Anton Vorontsov | b2f66d1 | 2009-02-01 00:54:16 -0800 | [diff] [blame] | 274 | static DEVICE_ATTR(fifo_starve, 0644, gfar_show_fifo_starve, |
| 275 | gfar_set_fifo_starve); |
Grant Likely | 35a84fd | 2007-12-01 22:12:45 -0700 | [diff] [blame] | 276 | |
Kumar Gala | 4409d28 | 2007-02-12 23:40:06 -0600 | [diff] [blame] | 277 | static ssize_t gfar_show_fifo_starve_off(struct device *dev, |
| 278 | struct device_attribute *attr, |
| 279 | char *buf) |
Andy Fleming | 7f7f531 | 2005-11-11 12:38:59 -0600 | [diff] [blame] | 280 | { |
Kumar Gala | 4409d28 | 2007-02-12 23:40:06 -0600 | [diff] [blame] | 281 | struct gfar_private *priv = netdev_priv(to_net_dev(dev)); |
Andy Fleming | 7f7f531 | 2005-11-11 12:38:59 -0600 | [diff] [blame] | 282 | |
| 283 | return sprintf(buf, "%d\n", priv->fifo_starve_off); |
| 284 | } |
| 285 | |
Kumar Gala | 4409d28 | 2007-02-12 23:40:06 -0600 | [diff] [blame] | 286 | static ssize_t gfar_set_fifo_starve_off(struct device *dev, |
| 287 | struct device_attribute *attr, |
| 288 | const char *buf, size_t count) |
Andy Fleming | 7f7f531 | 2005-11-11 12:38:59 -0600 | [diff] [blame] | 289 | { |
Kumar Gala | 4409d28 | 2007-02-12 23:40:06 -0600 | [diff] [blame] | 290 | struct gfar_private *priv = netdev_priv(to_net_dev(dev)); |
Sandeep Gopalpet | a12f801 | 2009-11-02 07:03:00 +0000 | [diff] [blame^] | 291 | struct gfar_priv_tx_q *tx_queue = NULL; |
Andy Fleming | 7f7f531 | 2005-11-11 12:38:59 -0600 | [diff] [blame] | 292 | unsigned int num = simple_strtoul(buf, NULL, 0); |
| 293 | u32 temp; |
| 294 | unsigned long flags; |
| 295 | |
| 296 | if (num > GFAR_MAX_FIFO_STARVE_OFF) |
| 297 | return count; |
| 298 | |
Sandeep Gopalpet | a12f801 | 2009-11-02 07:03:00 +0000 | [diff] [blame^] | 299 | tx_queue = priv->tx_queue; |
| 300 | spin_lock_irqsave(&tx_queue->txlock, flags); |
Andy Fleming | 7f7f531 | 2005-11-11 12:38:59 -0600 | [diff] [blame] | 301 | |
| 302 | priv->fifo_starve_off = num; |
| 303 | |
| 304 | temp = gfar_read(&priv->regs->fifo_tx_starve_shutoff); |
| 305 | temp &= ~FIFO_TX_STARVE_OFF_MASK; |
| 306 | temp |= num; |
| 307 | gfar_write(&priv->regs->fifo_tx_starve_shutoff, temp); |
| 308 | |
Sandeep Gopalpet | a12f801 | 2009-11-02 07:03:00 +0000 | [diff] [blame^] | 309 | spin_unlock_irqrestore(&tx_queue->txlock, flags); |
Andy Fleming | 7f7f531 | 2005-11-11 12:38:59 -0600 | [diff] [blame] | 310 | |
| 311 | return count; |
| 312 | } |
| 313 | |
Anton Vorontsov | b2f66d1 | 2009-02-01 00:54:16 -0800 | [diff] [blame] | 314 | static DEVICE_ATTR(fifo_starve_off, 0644, gfar_show_fifo_starve_off, |
| 315 | gfar_set_fifo_starve_off); |
Grant Likely | 35a84fd | 2007-12-01 22:12:45 -0700 | [diff] [blame] | 316 | |
Andy Fleming | 7f7f531 | 2005-11-11 12:38:59 -0600 | [diff] [blame] | 317 | void gfar_init_sysfs(struct net_device *dev) |
| 318 | { |
| 319 | struct gfar_private *priv = netdev_priv(dev); |
Grant Likely | 35a84fd | 2007-12-01 22:12:45 -0700 | [diff] [blame] | 320 | int rc; |
Andy Fleming | 7f7f531 | 2005-11-11 12:38:59 -0600 | [diff] [blame] | 321 | |
| 322 | /* Initialize the default values */ |
Andy Fleming | 7f7f531 | 2005-11-11 12:38:59 -0600 | [diff] [blame] | 323 | priv->fifo_threshold = DEFAULT_FIFO_TX_THR; |
| 324 | priv->fifo_starve = DEFAULT_FIFO_TX_STARVE; |
| 325 | priv->fifo_starve_off = DEFAULT_FIFO_TX_STARVE_OFF; |
Andy Fleming | 7f7f531 | 2005-11-11 12:38:59 -0600 | [diff] [blame] | 326 | |
| 327 | /* Create our sysfs files */ |
Grant Likely | 35a84fd | 2007-12-01 22:12:45 -0700 | [diff] [blame] | 328 | rc = device_create_file(&dev->dev, &dev_attr_bd_stash); |
| 329 | rc |= device_create_file(&dev->dev, &dev_attr_rx_stash_size); |
| 330 | rc |= device_create_file(&dev->dev, &dev_attr_rx_stash_index); |
| 331 | rc |= device_create_file(&dev->dev, &dev_attr_fifo_threshold); |
| 332 | rc |= device_create_file(&dev->dev, &dev_attr_fifo_starve); |
| 333 | rc |= device_create_file(&dev->dev, &dev_attr_fifo_starve_off); |
| 334 | if (rc) |
| 335 | dev_err(&dev->dev, "Error creating gianfar sysfs files.\n"); |
Andy Fleming | 7f7f531 | 2005-11-11 12:38:59 -0600 | [diff] [blame] | 336 | } |