diff options
author | Sandeep Gopalpet <Sandeep.Kumar@freescale.com> | 2009-11-02 02:03:00 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-11-03 02:40:55 -0500 |
commit | a12f801d4b349bc57622584e70e45a4ccbef53b6 (patch) | |
tree | 1b081795127d9e47aa5bac516fededa736dfc394 /drivers/net/gianfar_sysfs.c | |
parent | 123b43e9716115302a0095e14f2c545811712715 (diff) |
gianfar: Add per queue structure support
This patch introduces per tx and per rx queue structures.
Earlier the members of these structures were inside the
gfar_private structure.
Moving forward if we want to support multiple queues, we need
to refactor the gfar_private structure so that introduction of
multiple queues is easier.
Signed-off-by: Sandeep Gopalpet <Sandeep.Kumar@freescale.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/gianfar_sysfs.c')
-rw-r--r-- | drivers/net/gianfar_sysfs.c | 43 |
1 files changed, 30 insertions, 13 deletions
diff --git a/drivers/net/gianfar_sysfs.c b/drivers/net/gianfar_sysfs.c index dd26da74f27a..9c664f85705c 100644 --- a/drivers/net/gianfar_sysfs.c +++ b/drivers/net/gianfar_sysfs.c | |||
@@ -8,8 +8,9 @@ | |||
8 | * | 8 | * |
9 | * Author: Andy Fleming | 9 | * Author: Andy Fleming |
10 | * Maintainer: Kumar Gala (galak@kernel.crashing.org) | 10 | * Maintainer: Kumar Gala (galak@kernel.crashing.org) |
11 | * Modifier: Sandeep Gopalpet <sandeep.kumar@freescale.com> | ||
11 | * | 12 | * |
12 | * Copyright (c) 2002-2005 Freescale Semiconductor, Inc. | 13 | * Copyright 2002-2009 Freescale Semiconductor, Inc. |
13 | * | 14 | * |
14 | * This program is free software; you can redistribute it and/or modify it | 15 | * This program is free software; you can redistribute it and/or modify it |
15 | * under the terms of the GNU General Public License as published by the | 16 | * under the terms of the GNU General Public License as published by the |
@@ -49,6 +50,7 @@ static ssize_t gfar_set_bd_stash(struct device *dev, | |||
49 | const char *buf, size_t count) | 50 | const char *buf, size_t count) |
50 | { | 51 | { |
51 | struct gfar_private *priv = netdev_priv(to_net_dev(dev)); | 52 | struct gfar_private *priv = netdev_priv(to_net_dev(dev)); |
53 | struct gfar_priv_rx_q *rx_queue = NULL; | ||
52 | int new_setting = 0; | 54 | int new_setting = 0; |
53 | u32 temp; | 55 | u32 temp; |
54 | unsigned long flags; | 56 | unsigned long flags; |
@@ -56,6 +58,8 @@ static ssize_t gfar_set_bd_stash(struct device *dev, | |||
56 | if (!(priv->device_flags & FSL_GIANFAR_DEV_HAS_BD_STASHING)) | 58 | if (!(priv->device_flags & FSL_GIANFAR_DEV_HAS_BD_STASHING)) |
57 | return count; | 59 | return count; |
58 | 60 | ||
61 | rx_queue = priv->rx_queue; | ||
62 | |||
59 | /* Find out the new setting */ | 63 | /* Find out the new setting */ |
60 | if (!strncmp("on", buf, count - 1) || !strncmp("1", buf, count - 1)) | 64 | if (!strncmp("on", buf, count - 1) || !strncmp("1", buf, count - 1)) |
61 | new_setting = 1; | 65 | new_setting = 1; |
@@ -65,7 +69,7 @@ static ssize_t gfar_set_bd_stash(struct device *dev, | |||
65 | else | 69 | else |
66 | return count; | 70 | return count; |
67 | 71 | ||
68 | spin_lock_irqsave(&priv->rxlock, flags); | 72 | spin_lock_irqsave(&rx_queue->rxlock, flags); |
69 | 73 | ||
70 | /* Set the new stashing value */ | 74 | /* Set the new stashing value */ |
71 | priv->bd_stash_en = new_setting; | 75 | priv->bd_stash_en = new_setting; |
@@ -79,7 +83,7 @@ static ssize_t gfar_set_bd_stash(struct device *dev, | |||
79 | 83 | ||
80 | gfar_write(&priv->regs->attr, temp); | 84 | gfar_write(&priv->regs->attr, temp); |
81 | 85 | ||
82 | spin_unlock_irqrestore(&priv->rxlock, flags); | 86 | spin_unlock_irqrestore(&rx_queue->rxlock, flags); |
83 | 87 | ||
84 | return count; | 88 | return count; |
85 | } | 89 | } |
@@ -99,6 +103,7 @@ static ssize_t gfar_set_rx_stash_size(struct device *dev, | |||
99 | const char *buf, size_t count) | 103 | const char *buf, size_t count) |
100 | { | 104 | { |
101 | struct gfar_private *priv = netdev_priv(to_net_dev(dev)); | 105 | struct gfar_private *priv = netdev_priv(to_net_dev(dev)); |
106 | struct gfar_priv_rx_q *rx_queue = NULL; | ||
102 | unsigned int length = simple_strtoul(buf, NULL, 0); | 107 | unsigned int length = simple_strtoul(buf, NULL, 0); |
103 | u32 temp; | 108 | u32 temp; |
104 | unsigned long flags; | 109 | unsigned long flags; |
@@ -106,7 +111,9 @@ static ssize_t gfar_set_rx_stash_size(struct device *dev, | |||
106 | if (!(priv->device_flags & FSL_GIANFAR_DEV_HAS_BUF_STASHING)) | 111 | if (!(priv->device_flags & FSL_GIANFAR_DEV_HAS_BUF_STASHING)) |
107 | return count; | 112 | return count; |
108 | 113 | ||
109 | spin_lock_irqsave(&priv->rxlock, flags); | 114 | rx_queue = priv->rx_queue; |
115 | |||
116 | spin_lock_irqsave(&rx_queue->rxlock, flags); | ||
110 | if (length > priv->rx_buffer_size) | 117 | if (length > priv->rx_buffer_size) |
111 | goto out; | 118 | goto out; |
112 | 119 | ||
@@ -131,7 +138,7 @@ static ssize_t gfar_set_rx_stash_size(struct device *dev, | |||
131 | gfar_write(&priv->regs->attr, temp); | 138 | gfar_write(&priv->regs->attr, temp); |
132 | 139 | ||
133 | out: | 140 | out: |
134 | spin_unlock_irqrestore(&priv->rxlock, flags); | 141 | spin_unlock_irqrestore(&rx_queue->rxlock, flags); |
135 | 142 | ||
136 | return count; | 143 | return count; |
137 | } | 144 | } |
@@ -154,6 +161,7 @@ static ssize_t gfar_set_rx_stash_index(struct device *dev, | |||
154 | const char *buf, size_t count) | 161 | const char *buf, size_t count) |
155 | { | 162 | { |
156 | struct gfar_private *priv = netdev_priv(to_net_dev(dev)); | 163 | struct gfar_private *priv = netdev_priv(to_net_dev(dev)); |
164 | struct gfar_priv_rx_q *rx_queue = NULL; | ||
157 | unsigned short index = simple_strtoul(buf, NULL, 0); | 165 | unsigned short index = simple_strtoul(buf, NULL, 0); |
158 | u32 temp; | 166 | u32 temp; |
159 | unsigned long flags; | 167 | unsigned long flags; |
@@ -161,7 +169,9 @@ static ssize_t gfar_set_rx_stash_index(struct device *dev, | |||
161 | if (!(priv->device_flags & FSL_GIANFAR_DEV_HAS_BUF_STASHING)) | 169 | if (!(priv->device_flags & FSL_GIANFAR_DEV_HAS_BUF_STASHING)) |
162 | return count; | 170 | return count; |
163 | 171 | ||
164 | spin_lock_irqsave(&priv->rxlock, flags); | 172 | rx_queue = priv->rx_queue; |
173 | |||
174 | spin_lock_irqsave(&rx_queue->rxlock, flags); | ||
165 | if (index > priv->rx_stash_size) | 175 | if (index > priv->rx_stash_size) |
166 | goto out; | 176 | goto out; |
167 | 177 | ||
@@ -176,7 +186,7 @@ static ssize_t gfar_set_rx_stash_index(struct device *dev, | |||
176 | gfar_write(&priv->regs->attreli, flags); | 186 | gfar_write(&priv->regs->attreli, flags); |
177 | 187 | ||
178 | out: | 188 | out: |
179 | spin_unlock_irqrestore(&priv->rxlock, flags); | 189 | spin_unlock_irqrestore(&rx_queue->rxlock, flags); |
180 | 190 | ||
181 | return count; | 191 | return count; |
182 | } | 192 | } |
@@ -198,6 +208,7 @@ static ssize_t gfar_set_fifo_threshold(struct device *dev, | |||
198 | const char *buf, size_t count) | 208 | const char *buf, size_t count) |
199 | { | 209 | { |
200 | struct gfar_private *priv = netdev_priv(to_net_dev(dev)); | 210 | struct gfar_private *priv = netdev_priv(to_net_dev(dev)); |
211 | struct gfar_priv_tx_q *tx_queue = NULL; | ||
201 | unsigned int length = simple_strtoul(buf, NULL, 0); | 212 | unsigned int length = simple_strtoul(buf, NULL, 0); |
202 | u32 temp; | 213 | u32 temp; |
203 | unsigned long flags; | 214 | unsigned long flags; |
@@ -205,7 +216,9 @@ static ssize_t gfar_set_fifo_threshold(struct device *dev, | |||
205 | if (length > GFAR_MAX_FIFO_THRESHOLD) | 216 | if (length > GFAR_MAX_FIFO_THRESHOLD) |
206 | return count; | 217 | return count; |
207 | 218 | ||
208 | spin_lock_irqsave(&priv->txlock, flags); | 219 | tx_queue = priv->tx_queue; |
220 | |||
221 | spin_lock_irqsave(&tx_queue->txlock, flags); | ||
209 | 222 | ||
210 | priv->fifo_threshold = length; | 223 | priv->fifo_threshold = length; |
211 | 224 | ||
@@ -214,7 +227,7 @@ static ssize_t gfar_set_fifo_threshold(struct device *dev, | |||
214 | temp |= length; | 227 | temp |= length; |
215 | gfar_write(&priv->regs->fifo_tx_thr, temp); | 228 | gfar_write(&priv->regs->fifo_tx_thr, temp); |
216 | 229 | ||
217 | spin_unlock_irqrestore(&priv->txlock, flags); | 230 | spin_unlock_irqrestore(&tx_queue->txlock, flags); |
218 | 231 | ||
219 | return count; | 232 | return count; |
220 | } | 233 | } |
@@ -235,6 +248,7 @@ static ssize_t gfar_set_fifo_starve(struct device *dev, | |||
235 | const char *buf, size_t count) | 248 | const char *buf, size_t count) |
236 | { | 249 | { |
237 | struct gfar_private *priv = netdev_priv(to_net_dev(dev)); | 250 | struct gfar_private *priv = netdev_priv(to_net_dev(dev)); |
251 | struct gfar_priv_tx_q *tx_queue = NULL; | ||
238 | unsigned int num = simple_strtoul(buf, NULL, 0); | 252 | unsigned int num = simple_strtoul(buf, NULL, 0); |
239 | u32 temp; | 253 | u32 temp; |
240 | unsigned long flags; | 254 | unsigned long flags; |
@@ -242,7 +256,8 @@ static ssize_t gfar_set_fifo_starve(struct device *dev, | |||
242 | if (num > GFAR_MAX_FIFO_STARVE) | 256 | if (num > GFAR_MAX_FIFO_STARVE) |
243 | return count; | 257 | return count; |
244 | 258 | ||
245 | spin_lock_irqsave(&priv->txlock, flags); | 259 | tx_queue = priv->tx_queue; |
260 | spin_lock_irqsave(&tx_queue->txlock, flags); | ||
246 | 261 | ||
247 | priv->fifo_starve = num; | 262 | priv->fifo_starve = num; |
248 | 263 | ||
@@ -251,7 +266,7 @@ static ssize_t gfar_set_fifo_starve(struct device *dev, | |||
251 | temp |= num; | 266 | temp |= num; |
252 | gfar_write(&priv->regs->fifo_tx_starve, temp); | 267 | gfar_write(&priv->regs->fifo_tx_starve, temp); |
253 | 268 | ||
254 | spin_unlock_irqrestore(&priv->txlock, flags); | 269 | spin_unlock_irqrestore(&tx_queue->txlock, flags); |
255 | 270 | ||
256 | return count; | 271 | return count; |
257 | } | 272 | } |
@@ -273,6 +288,7 @@ static ssize_t gfar_set_fifo_starve_off(struct device *dev, | |||
273 | const char *buf, size_t count) | 288 | const char *buf, size_t count) |
274 | { | 289 | { |
275 | struct gfar_private *priv = netdev_priv(to_net_dev(dev)); | 290 | struct gfar_private *priv = netdev_priv(to_net_dev(dev)); |
291 | struct gfar_priv_tx_q *tx_queue = NULL; | ||
276 | unsigned int num = simple_strtoul(buf, NULL, 0); | 292 | unsigned int num = simple_strtoul(buf, NULL, 0); |
277 | u32 temp; | 293 | u32 temp; |
278 | unsigned long flags; | 294 | unsigned long flags; |
@@ -280,7 +296,8 @@ static ssize_t gfar_set_fifo_starve_off(struct device *dev, | |||
280 | if (num > GFAR_MAX_FIFO_STARVE_OFF) | 296 | if (num > GFAR_MAX_FIFO_STARVE_OFF) |
281 | return count; | 297 | return count; |
282 | 298 | ||
283 | spin_lock_irqsave(&priv->txlock, flags); | 299 | tx_queue = priv->tx_queue; |
300 | spin_lock_irqsave(&tx_queue->txlock, flags); | ||
284 | 301 | ||
285 | priv->fifo_starve_off = num; | 302 | priv->fifo_starve_off = num; |
286 | 303 | ||
@@ -289,7 +306,7 @@ static ssize_t gfar_set_fifo_starve_off(struct device *dev, | |||
289 | temp |= num; | 306 | temp |= num; |
290 | gfar_write(&priv->regs->fifo_tx_starve_shutoff, temp); | 307 | gfar_write(&priv->regs->fifo_tx_starve_shutoff, temp); |
291 | 308 | ||
292 | spin_unlock_irqrestore(&priv->txlock, flags); | 309 | spin_unlock_irqrestore(&tx_queue->txlock, flags); |
293 | 310 | ||
294 | return count; | 311 | return count; |
295 | } | 312 | } |