diff options
author | Linus Torvalds <torvalds@g5.osdl.org> | 2006-01-09 18:12:52 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-01-09 18:12:52 -0500 |
commit | 1fd5a46dd6bbca3a1275465120caf4748872c2a7 (patch) | |
tree | c24862a43f57974394ebb58a1d9005e4093e3bf7 /drivers | |
parent | 2cc6055060d975e8c7601f4a1c68ef2d3050b4e9 (diff) | |
parent | dff2c03534f525813342ab8dec90c5bb1ee07471 (diff) |
Merge master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/crypto/padlock-aes.c | 26 | ||||
-rw-r--r-- | drivers/crypto/padlock.h | 2 | ||||
-rw-r--r-- | drivers/net/Kconfig | 13 | ||||
-rw-r--r-- | drivers/net/Makefile | 1 | ||||
-rw-r--r-- | drivers/net/hamradio/mkiss.c | 2 | ||||
-rw-r--r-- | drivers/net/ifb.c | 294 |
6 files changed, 323 insertions, 15 deletions
diff --git a/drivers/crypto/padlock-aes.c b/drivers/crypto/padlock-aes.c index 71407c578afe..64819aa7cac4 100644 --- a/drivers/crypto/padlock-aes.c +++ b/drivers/crypto/padlock-aes.c | |||
@@ -99,9 +99,6 @@ byte(const uint32_t x, const unsigned n) | |||
99 | return x >> (n << 3); | 99 | return x >> (n << 3); |
100 | } | 100 | } |
101 | 101 | ||
102 | #define uint32_t_in(x) le32_to_cpu(*(const uint32_t *)(x)) | ||
103 | #define uint32_t_out(to, from) (*(uint32_t *)(to) = cpu_to_le32(from)) | ||
104 | |||
105 | #define E_KEY ctx->E | 102 | #define E_KEY ctx->E |
106 | #define D_KEY ctx->D | 103 | #define D_KEY ctx->D |
107 | 104 | ||
@@ -294,6 +291,7 @@ static int | |||
294 | aes_set_key(void *ctx_arg, const uint8_t *in_key, unsigned int key_len, uint32_t *flags) | 291 | aes_set_key(void *ctx_arg, const uint8_t *in_key, unsigned int key_len, uint32_t *flags) |
295 | { | 292 | { |
296 | struct aes_ctx *ctx = aes_ctx(ctx_arg); | 293 | struct aes_ctx *ctx = aes_ctx(ctx_arg); |
294 | const __le32 *key = (const __le32 *)in_key; | ||
297 | uint32_t i, t, u, v, w; | 295 | uint32_t i, t, u, v, w; |
298 | uint32_t P[AES_EXTENDED_KEY_SIZE]; | 296 | uint32_t P[AES_EXTENDED_KEY_SIZE]; |
299 | uint32_t rounds; | 297 | uint32_t rounds; |
@@ -313,10 +311,10 @@ aes_set_key(void *ctx_arg, const uint8_t *in_key, unsigned int key_len, uint32_t | |||
313 | ctx->E = ctx->e_data; | 311 | ctx->E = ctx->e_data; |
314 | ctx->D = ctx->e_data; | 312 | ctx->D = ctx->e_data; |
315 | 313 | ||
316 | E_KEY[0] = uint32_t_in (in_key); | 314 | E_KEY[0] = le32_to_cpu(key[0]); |
317 | E_KEY[1] = uint32_t_in (in_key + 4); | 315 | E_KEY[1] = le32_to_cpu(key[1]); |
318 | E_KEY[2] = uint32_t_in (in_key + 8); | 316 | E_KEY[2] = le32_to_cpu(key[2]); |
319 | E_KEY[3] = uint32_t_in (in_key + 12); | 317 | E_KEY[3] = le32_to_cpu(key[3]); |
320 | 318 | ||
321 | /* Prepare control words. */ | 319 | /* Prepare control words. */ |
322 | memset(&ctx->cword, 0, sizeof(ctx->cword)); | 320 | memset(&ctx->cword, 0, sizeof(ctx->cword)); |
@@ -343,17 +341,17 @@ aes_set_key(void *ctx_arg, const uint8_t *in_key, unsigned int key_len, uint32_t | |||
343 | break; | 341 | break; |
344 | 342 | ||
345 | case 24: | 343 | case 24: |
346 | E_KEY[4] = uint32_t_in (in_key + 16); | 344 | E_KEY[4] = le32_to_cpu(key[4]); |
347 | t = E_KEY[5] = uint32_t_in (in_key + 20); | 345 | t = E_KEY[5] = le32_to_cpu(key[5]); |
348 | for (i = 0; i < 8; ++i) | 346 | for (i = 0; i < 8; ++i) |
349 | loop6 (i); | 347 | loop6 (i); |
350 | break; | 348 | break; |
351 | 349 | ||
352 | case 32: | 350 | case 32: |
353 | E_KEY[4] = uint32_t_in (in_key + 16); | 351 | E_KEY[4] = le32_to_cpu(in_key[4]); |
354 | E_KEY[5] = uint32_t_in (in_key + 20); | 352 | E_KEY[5] = le32_to_cpu(in_key[5]); |
355 | E_KEY[6] = uint32_t_in (in_key + 24); | 353 | E_KEY[6] = le32_to_cpu(in_key[6]); |
356 | t = E_KEY[7] = uint32_t_in (in_key + 28); | 354 | t = E_KEY[7] = le32_to_cpu(in_key[7]); |
357 | for (i = 0; i < 7; ++i) | 355 | for (i = 0; i < 7; ++i) |
358 | loop8 (i); | 356 | loop8 (i); |
359 | break; | 357 | break; |
@@ -468,6 +466,8 @@ static unsigned int aes_decrypt_cbc(const struct cipher_desc *desc, u8 *out, | |||
468 | 466 | ||
469 | static struct crypto_alg aes_alg = { | 467 | static struct crypto_alg aes_alg = { |
470 | .cra_name = "aes", | 468 | .cra_name = "aes", |
469 | .cra_driver_name = "aes-padlock", | ||
470 | .cra_priority = 300, | ||
471 | .cra_flags = CRYPTO_ALG_TYPE_CIPHER, | 471 | .cra_flags = CRYPTO_ALG_TYPE_CIPHER, |
472 | .cra_blocksize = AES_BLOCK_SIZE, | 472 | .cra_blocksize = AES_BLOCK_SIZE, |
473 | .cra_ctxsize = sizeof(struct aes_ctx), | 473 | .cra_ctxsize = sizeof(struct aes_ctx), |
diff --git a/drivers/crypto/padlock.h b/drivers/crypto/padlock.h index 3cf2b7a12348..b78489bc298a 100644 --- a/drivers/crypto/padlock.h +++ b/drivers/crypto/padlock.h | |||
@@ -17,7 +17,7 @@ | |||
17 | 17 | ||
18 | /* Control word. */ | 18 | /* Control word. */ |
19 | struct cword { | 19 | struct cword { |
20 | int __attribute__ ((__packed__)) | 20 | unsigned int __attribute__ ((__packed__)) |
21 | rounds:4, | 21 | rounds:4, |
22 | algo:3, | 22 | algo:3, |
23 | keygen:1, | 23 | keygen:1, |
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index 733bc25b2bf9..4959800a18d7 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig | |||
@@ -27,6 +27,19 @@ config NETDEVICES | |||
27 | # that for each of the symbols. | 27 | # that for each of the symbols. |
28 | if NETDEVICES | 28 | if NETDEVICES |
29 | 29 | ||
30 | config IFB | ||
31 | tristate "Intermediate Functional Block support" | ||
32 | depends on NET_CLS_ACT | ||
33 | ---help--- | ||
34 | This is an intermidiate driver that allows sharing of | ||
35 | resources. | ||
36 | To compile this driver as a module, choose M here: the module | ||
37 | will be called ifb. If you want to use more than one ifb | ||
38 | device at a time, you need to compile this driver as a module. | ||
39 | Instead of 'ifb', the devices will then be called 'ifb0', | ||
40 | 'ifb1' etc. | ||
41 | Look at the iproute2 documentation directory for usage etc | ||
42 | |||
30 | config DUMMY | 43 | config DUMMY |
31 | tristate "Dummy net driver support" | 44 | tristate "Dummy net driver support" |
32 | ---help--- | 45 | ---help--- |
diff --git a/drivers/net/Makefile b/drivers/net/Makefile index b74a7cb5bae6..00e72b12fb92 100644 --- a/drivers/net/Makefile +++ b/drivers/net/Makefile | |||
@@ -125,6 +125,7 @@ ifeq ($(CONFIG_SLIP_COMPRESSED),y) | |||
125 | endif | 125 | endif |
126 | 126 | ||
127 | obj-$(CONFIG_DUMMY) += dummy.o | 127 | obj-$(CONFIG_DUMMY) += dummy.o |
128 | obj-$(CONFIG_IFB) += ifb.o | ||
128 | obj-$(CONFIG_DE600) += de600.o | 129 | obj-$(CONFIG_DE600) += de600.o |
129 | obj-$(CONFIG_DE620) += de620.o | 130 | obj-$(CONFIG_DE620) += de620.o |
130 | obj-$(CONFIG_LANCE) += lance.o | 131 | obj-$(CONFIG_LANCE) += lance.o |
diff --git a/drivers/net/hamradio/mkiss.c b/drivers/net/hamradio/mkiss.c index 41b3d83c2ab8..f4424cf886c5 100644 --- a/drivers/net/hamradio/mkiss.c +++ b/drivers/net/hamradio/mkiss.c | |||
@@ -515,6 +515,7 @@ static void ax_encaps(struct net_device *dev, unsigned char *icp, int len) | |||
515 | count = kiss_esc(p, (unsigned char *)ax->xbuff, len); | 515 | count = kiss_esc(p, (unsigned char *)ax->xbuff, len); |
516 | } | 516 | } |
517 | } | 517 | } |
518 | spin_unlock_bh(&ax->buflock); | ||
518 | 519 | ||
519 | set_bit(TTY_DO_WRITE_WAKEUP, &ax->tty->flags); | 520 | set_bit(TTY_DO_WRITE_WAKEUP, &ax->tty->flags); |
520 | actual = ax->tty->driver->write(ax->tty, ax->xbuff, count); | 521 | actual = ax->tty->driver->write(ax->tty, ax->xbuff, count); |
@@ -524,7 +525,6 @@ static void ax_encaps(struct net_device *dev, unsigned char *icp, int len) | |||
524 | ax->dev->trans_start = jiffies; | 525 | ax->dev->trans_start = jiffies; |
525 | ax->xleft = count - actual; | 526 | ax->xleft = count - actual; |
526 | ax->xhead = ax->xbuff + actual; | 527 | ax->xhead = ax->xbuff + actual; |
527 | spin_unlock_bh(&ax->buflock); | ||
528 | } | 528 | } |
529 | 529 | ||
530 | /* Encapsulate an AX.25 packet and kick it into a TTY queue. */ | 530 | /* Encapsulate an AX.25 packet and kick it into a TTY queue. */ |
diff --git a/drivers/net/ifb.c b/drivers/net/ifb.c new file mode 100644 index 000000000000..1b699259b4ec --- /dev/null +++ b/drivers/net/ifb.c | |||
@@ -0,0 +1,294 @@ | |||
1 | /* drivers/net/ifb.c: | ||
2 | |||
3 | The purpose of this driver is to provide a device that allows | ||
4 | for sharing of resources: | ||
5 | |||
6 | 1) qdiscs/policies that are per device as opposed to system wide. | ||
7 | ifb allows for a device which can be redirected to thus providing | ||
8 | an impression of sharing. | ||
9 | |||
10 | 2) Allows for queueing incoming traffic for shaping instead of | ||
11 | dropping. | ||
12 | |||
13 | The original concept is based on what is known as the IMQ | ||
14 | driver initially written by Martin Devera, later rewritten | ||
15 | by Patrick McHardy and then maintained by Andre Correa. | ||
16 | |||
17 | You need the tc action mirror or redirect to feed this device | ||
18 | packets. | ||
19 | |||
20 | This program is free software; you can redistribute it and/or | ||
21 | modify it under the terms of the GNU General Public License | ||
22 | as published by the Free Software Foundation; either version | ||
23 | 2 of the License, or (at your option) any later version. | ||
24 | |||
25 | Authors: Jamal Hadi Salim (2005) | ||
26 | |||
27 | */ | ||
28 | |||
29 | |||
30 | #include <linux/config.h> | ||
31 | #include <linux/module.h> | ||
32 | #include <linux/kernel.h> | ||
33 | #include <linux/netdevice.h> | ||
34 | #include <linux/etherdevice.h> | ||
35 | #include <linux/init.h> | ||
36 | #include <linux/moduleparam.h> | ||
37 | #include <net/pkt_sched.h> | ||
38 | |||
39 | #define TX_TIMEOUT (2*HZ) | ||
40 | |||
41 | #define TX_Q_LIMIT 32 | ||
42 | struct ifb_private { | ||
43 | struct net_device_stats stats; | ||
44 | struct tasklet_struct ifb_tasklet; | ||
45 | int tasklet_pending; | ||
46 | /* mostly debug stats leave in for now */ | ||
47 | unsigned long st_task_enter; /* tasklet entered */ | ||
48 | unsigned long st_txq_refl_try; /* transmit queue refill attempt */ | ||
49 | unsigned long st_rxq_enter; /* receive queue entered */ | ||
50 | unsigned long st_rx2tx_tran; /* receive to trasmit transfers */ | ||
51 | unsigned long st_rxq_notenter; /*receiveQ not entered, resched */ | ||
52 | unsigned long st_rx_frm_egr; /* received from egress path */ | ||
53 | unsigned long st_rx_frm_ing; /* received from ingress path */ | ||
54 | unsigned long st_rxq_check; | ||
55 | unsigned long st_rxq_rsch; | ||
56 | struct sk_buff_head rq; | ||
57 | struct sk_buff_head tq; | ||
58 | }; | ||
59 | |||
60 | static int numifbs = 1; | ||
61 | |||
62 | static void ri_tasklet(unsigned long dev); | ||
63 | static int ifb_xmit(struct sk_buff *skb, struct net_device *dev); | ||
64 | static struct net_device_stats *ifb_get_stats(struct net_device *dev); | ||
65 | static int ifb_open(struct net_device *dev); | ||
66 | static int ifb_close(struct net_device *dev); | ||
67 | |||
68 | static void ri_tasklet(unsigned long dev) | ||
69 | { | ||
70 | |||
71 | struct net_device *_dev = (struct net_device *)dev; | ||
72 | struct ifb_private *dp = netdev_priv(_dev); | ||
73 | struct net_device_stats *stats = &dp->stats; | ||
74 | struct sk_buff *skb; | ||
75 | |||
76 | dp->st_task_enter++; | ||
77 | if ((skb = skb_peek(&dp->tq)) == NULL) { | ||
78 | dp->st_txq_refl_try++; | ||
79 | if (spin_trylock(&_dev->xmit_lock)) { | ||
80 | dp->st_rxq_enter++; | ||
81 | while ((skb = skb_dequeue(&dp->rq)) != NULL) { | ||
82 | skb_queue_tail(&dp->tq, skb); | ||
83 | dp->st_rx2tx_tran++; | ||
84 | } | ||
85 | spin_unlock(&_dev->xmit_lock); | ||
86 | } else { | ||
87 | /* reschedule */ | ||
88 | dp->st_rxq_notenter++; | ||
89 | goto resched; | ||
90 | } | ||
91 | } | ||
92 | |||
93 | while ((skb = skb_dequeue(&dp->tq)) != NULL) { | ||
94 | u32 from = G_TC_FROM(skb->tc_verd); | ||
95 | |||
96 | skb->tc_verd = 0; | ||
97 | skb->tc_verd = SET_TC_NCLS(skb->tc_verd); | ||
98 | stats->tx_packets++; | ||
99 | stats->tx_bytes +=skb->len; | ||
100 | if (from & AT_EGRESS) { | ||
101 | dp->st_rx_frm_egr++; | ||
102 | dev_queue_xmit(skb); | ||
103 | } else if (from & AT_INGRESS) { | ||
104 | |||
105 | dp->st_rx_frm_ing++; | ||
106 | netif_rx(skb); | ||
107 | } else { | ||
108 | dev_kfree_skb(skb); | ||
109 | stats->tx_dropped++; | ||
110 | } | ||
111 | } | ||
112 | |||
113 | if (spin_trylock(&_dev->xmit_lock)) { | ||
114 | dp->st_rxq_check++; | ||
115 | if ((skb = skb_peek(&dp->rq)) == NULL) { | ||
116 | dp->tasklet_pending = 0; | ||
117 | if (netif_queue_stopped(_dev)) | ||
118 | netif_wake_queue(_dev); | ||
119 | } else { | ||
120 | dp->st_rxq_rsch++; | ||
121 | spin_unlock(&_dev->xmit_lock); | ||
122 | goto resched; | ||
123 | } | ||
124 | spin_unlock(&_dev->xmit_lock); | ||
125 | } else { | ||
126 | resched: | ||
127 | dp->tasklet_pending = 1; | ||
128 | tasklet_schedule(&dp->ifb_tasklet); | ||
129 | } | ||
130 | |||
131 | } | ||
132 | |||
133 | static void __init ifb_setup(struct net_device *dev) | ||
134 | { | ||
135 | /* Initialize the device structure. */ | ||
136 | dev->get_stats = ifb_get_stats; | ||
137 | dev->hard_start_xmit = ifb_xmit; | ||
138 | dev->open = &ifb_open; | ||
139 | dev->stop = &ifb_close; | ||
140 | |||
141 | /* Fill in device structure with ethernet-generic values. */ | ||
142 | ether_setup(dev); | ||
143 | dev->tx_queue_len = TX_Q_LIMIT; | ||
144 | dev->change_mtu = NULL; | ||
145 | dev->flags |= IFF_NOARP; | ||
146 | dev->flags &= ~IFF_MULTICAST; | ||
147 | SET_MODULE_OWNER(dev); | ||
148 | random_ether_addr(dev->dev_addr); | ||
149 | } | ||
150 | |||
151 | static int ifb_xmit(struct sk_buff *skb, struct net_device *dev) | ||
152 | { | ||
153 | struct ifb_private *dp = netdev_priv(dev); | ||
154 | struct net_device_stats *stats = &dp->stats; | ||
155 | int ret = 0; | ||
156 | u32 from = G_TC_FROM(skb->tc_verd); | ||
157 | |||
158 | stats->tx_packets++; | ||
159 | stats->tx_bytes+=skb->len; | ||
160 | |||
161 | if (!from || !skb->input_dev) { | ||
162 | dropped: | ||
163 | dev_kfree_skb(skb); | ||
164 | stats->rx_dropped++; | ||
165 | return ret; | ||
166 | } else { | ||
167 | /* | ||
168 | * note we could be going | ||
169 | * ingress -> egress or | ||
170 | * egress -> ingress | ||
171 | */ | ||
172 | skb->dev = skb->input_dev; | ||
173 | skb->input_dev = dev; | ||
174 | if (from & AT_INGRESS) { | ||
175 | skb_pull(skb, skb->dev->hard_header_len); | ||
176 | } else { | ||
177 | if (!(from & AT_EGRESS)) { | ||
178 | goto dropped; | ||
179 | } | ||
180 | } | ||
181 | } | ||
182 | |||
183 | if (skb_queue_len(&dp->rq) >= dev->tx_queue_len) { | ||
184 | netif_stop_queue(dev); | ||
185 | } | ||
186 | |||
187 | dev->trans_start = jiffies; | ||
188 | skb_queue_tail(&dp->rq, skb); | ||
189 | if (!dp->tasklet_pending) { | ||
190 | dp->tasklet_pending = 1; | ||
191 | tasklet_schedule(&dp->ifb_tasklet); | ||
192 | } | ||
193 | |||
194 | return ret; | ||
195 | } | ||
196 | |||
197 | static struct net_device_stats *ifb_get_stats(struct net_device *dev) | ||
198 | { | ||
199 | struct ifb_private *dp = netdev_priv(dev); | ||
200 | struct net_device_stats *stats = &dp->stats; | ||
201 | |||
202 | pr_debug("tasklets stats %ld:%ld:%ld:%ld:%ld:%ld:%ld:%ld:%ld \n", | ||
203 | dp->st_task_enter, dp->st_txq_refl_try, dp->st_rxq_enter, | ||
204 | dp->st_rx2tx_tran dp->st_rxq_notenter, dp->st_rx_frm_egr, | ||
205 | dp->st_rx_frm_ing, dp->st_rxq_check, dp->st_rxq_rsch ); | ||
206 | |||
207 | return stats; | ||
208 | } | ||
209 | |||
210 | static struct net_device **ifbs; | ||
211 | |||
212 | /* Number of ifb devices to be set up by this module. */ | ||
213 | module_param(numifbs, int, 0); | ||
214 | MODULE_PARM_DESC(numifbs, "Number of ifb devices"); | ||
215 | |||
216 | static int ifb_close(struct net_device *dev) | ||
217 | { | ||
218 | struct ifb_private *dp = netdev_priv(dev); | ||
219 | |||
220 | tasklet_kill(&dp->ifb_tasklet); | ||
221 | netif_stop_queue(dev); | ||
222 | skb_queue_purge(&dp->rq); | ||
223 | skb_queue_purge(&dp->tq); | ||
224 | return 0; | ||
225 | } | ||
226 | |||
227 | static int ifb_open(struct net_device *dev) | ||
228 | { | ||
229 | struct ifb_private *dp = netdev_priv(dev); | ||
230 | |||
231 | tasklet_init(&dp->ifb_tasklet, ri_tasklet, (unsigned long)dev); | ||
232 | skb_queue_head_init(&dp->rq); | ||
233 | skb_queue_head_init(&dp->tq); | ||
234 | netif_start_queue(dev); | ||
235 | |||
236 | return 0; | ||
237 | } | ||
238 | |||
239 | static int __init ifb_init_one(int index) | ||
240 | { | ||
241 | struct net_device *dev_ifb; | ||
242 | int err; | ||
243 | |||
244 | dev_ifb = alloc_netdev(sizeof(struct ifb_private), | ||
245 | "ifb%d", ifb_setup); | ||
246 | |||
247 | if (!dev_ifb) | ||
248 | return -ENOMEM; | ||
249 | |||
250 | if ((err = register_netdev(dev_ifb))) { | ||
251 | free_netdev(dev_ifb); | ||
252 | dev_ifb = NULL; | ||
253 | } else { | ||
254 | ifbs[index] = dev_ifb; | ||
255 | } | ||
256 | |||
257 | return err; | ||
258 | } | ||
259 | |||
260 | static void ifb_free_one(int index) | ||
261 | { | ||
262 | unregister_netdev(ifbs[index]); | ||
263 | free_netdev(ifbs[index]); | ||
264 | } | ||
265 | |||
266 | static int __init ifb_init_module(void) | ||
267 | { | ||
268 | int i, err = 0; | ||
269 | ifbs = kmalloc(numifbs * sizeof(void *), GFP_KERNEL); | ||
270 | if (!ifbs) | ||
271 | return -ENOMEM; | ||
272 | for (i = 0; i < numifbs && !err; i++) | ||
273 | err = ifb_init_one(i); | ||
274 | if (err) { | ||
275 | while (--i >= 0) | ||
276 | ifb_free_one(i); | ||
277 | } | ||
278 | |||
279 | return err; | ||
280 | } | ||
281 | |||
282 | static void __exit ifb_cleanup_module(void) | ||
283 | { | ||
284 | int i; | ||
285 | |||
286 | for (i = 0; i < numifbs; i++) | ||
287 | ifb_free_one(i); | ||
288 | kfree(ifbs); | ||
289 | } | ||
290 | |||
291 | module_init(ifb_init_module); | ||
292 | module_exit(ifb_cleanup_module); | ||
293 | MODULE_LICENSE("GPL"); | ||
294 | MODULE_AUTHOR("Jamal Hadi Salim"); | ||