aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc/sgi-xp/xpnet.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/misc/sgi-xp/xpnet.c')
-rw-r--r--drivers/misc/sgi-xp/xpnet.c109
1 files changed, 36 insertions, 73 deletions
diff --git a/drivers/misc/sgi-xp/xpnet.c b/drivers/misc/sgi-xp/xpnet.c
index 38552f37e53d..e41cb93b8c89 100644
--- a/drivers/misc/sgi-xp/xpnet.c
+++ b/drivers/misc/sgi-xp/xpnet.c
@@ -6,7 +6,6 @@
6 * Copyright (C) 1999-2008 Silicon Graphics, Inc. All rights reserved. 6 * Copyright (C) 1999-2008 Silicon Graphics, Inc. All rights reserved.
7 */ 7 */
8 8
9
10/* 9/*
11 * Cross Partition Network Interface (XPNET) support 10 * Cross Partition Network Interface (XPNET) support
12 * 11 *
@@ -21,7 +20,6 @@
21 * 20 *
22 */ 21 */
23 22
24
25#include <linux/module.h> 23#include <linux/module.h>
26#include <linux/kernel.h> 24#include <linux/kernel.h>
27#include <linux/init.h> 25#include <linux/init.h>
@@ -40,7 +38,6 @@
40#include <asm/atomic.h> 38#include <asm/atomic.h>
41#include "xp.h" 39#include "xp.h"
42 40
43
44/* 41/*
45 * The message payload transferred by XPC. 42 * The message payload transferred by XPC.
46 * 43 *
@@ -79,7 +76,6 @@ struct xpnet_message {
79#define XPNET_MSG_ALIGNED_SIZE (L1_CACHE_ALIGN(XPNET_MSG_SIZE)) 76#define XPNET_MSG_ALIGNED_SIZE (L1_CACHE_ALIGN(XPNET_MSG_SIZE))
80#define XPNET_MSG_NENTRIES (PAGE_SIZE / XPNET_MSG_ALIGNED_SIZE) 77#define XPNET_MSG_NENTRIES (PAGE_SIZE / XPNET_MSG_ALIGNED_SIZE)
81 78
82
83#define XPNET_MAX_KTHREADS (XPNET_MSG_NENTRIES + 1) 79#define XPNET_MAX_KTHREADS (XPNET_MSG_NENTRIES + 1)
84#define XPNET_MAX_IDLE_KTHREADS (XPNET_MSG_NENTRIES + 1) 80#define XPNET_MAX_IDLE_KTHREADS (XPNET_MSG_NENTRIES + 1)
85 81
@@ -91,9 +87,9 @@ struct xpnet_message {
91#define XPNET_VERSION_MAJOR(_v) ((_v) >> 4) 87#define XPNET_VERSION_MAJOR(_v) ((_v) >> 4)
92#define XPNET_VERSION_MINOR(_v) ((_v) & 0xf) 88#define XPNET_VERSION_MINOR(_v) ((_v) & 0xf)
93 89
94#define XPNET_VERSION _XPNET_VERSION(1,0) /* version 1.0 */ 90#define XPNET_VERSION _XPNET_VERSION(1,0) /* version 1.0 */
95#define XPNET_VERSION_EMBED _XPNET_VERSION(1,1) /* version 1.1 */ 91#define XPNET_VERSION_EMBED _XPNET_VERSION(1,1) /* version 1.1 */
96#define XPNET_MAGIC 0x88786984 /* "XNET" */ 92#define XPNET_MAGIC 0x88786984 /* "XNET" */
97 93
98#define XPNET_VALID_MSG(_m) \ 94#define XPNET_VALID_MSG(_m) \
99 ((XPNET_VERSION_MAJOR(_m->version) == XPNET_VERSION_MAJOR(XPNET_VERSION)) \ 95 ((XPNET_VERSION_MAJOR(_m->version) == XPNET_VERSION_MAJOR(XPNET_VERSION)) \
@@ -101,7 +97,6 @@ struct xpnet_message {
101 97
102#define XPNET_DEVICE_NAME "xp0" 98#define XPNET_DEVICE_NAME "xp0"
103 99
104
105/* 100/*
106 * When messages are queued with xpc_send_notify, a kmalloc'd buffer 101 * When messages are queued with xpc_send_notify, a kmalloc'd buffer
107 * of the following type is passed as a notification cookie. When the 102 * of the following type is passed as a notification cookie. When the
@@ -145,7 +140,6 @@ static DEFINE_SPINLOCK(xpnet_broadcast_lock);
145/* 32KB has been determined to be the ideal */ 140/* 32KB has been determined to be the ideal */
146#define XPNET_DEF_MTU (0x8000UL) 141#define XPNET_DEF_MTU (0x8000UL)
147 142
148
149/* 143/*
150 * The partition id is encapsulated in the MAC address. The following 144 * The partition id is encapsulated in the MAC address. The following
151 * define locates the octet the partid is in. 145 * define locates the octet the partid is in.
@@ -153,7 +147,6 @@ static DEFINE_SPINLOCK(xpnet_broadcast_lock);
153#define XPNET_PARTID_OCTET 1 147#define XPNET_PARTID_OCTET 1
154#define XPNET_LICENSE_OCTET 2 148#define XPNET_LICENSE_OCTET 2
155 149
156
157/* 150/*
158 * Define the XPNET debug device structure that is to be used with dev_dbg(), 151 * Define the XPNET debug device structure that is to be used with dev_dbg(),
159 * dev_err(), dev_warn(), and dev_info(). 152 * dev_err(), dev_warn(), and dev_info().
@@ -163,7 +156,7 @@ struct device_driver xpnet_dbg_name = {
163}; 156};
164 157
165struct device xpnet_dbg_subname = { 158struct device xpnet_dbg_subname = {
166 .bus_id = {0}, /* set to "" */ 159 .bus_id = {0}, /* set to "" */
167 .driver = &xpnet_dbg_name 160 .driver = &xpnet_dbg_name
168}; 161};
169 162
@@ -178,14 +171,13 @@ xpnet_receive(partid_t partid, int channel, struct xpnet_message *msg)
178 struct sk_buff *skb; 171 struct sk_buff *skb;
179 bte_result_t bret; 172 bte_result_t bret;
180 struct xpnet_dev_private *priv = 173 struct xpnet_dev_private *priv =
181 (struct xpnet_dev_private *) xpnet_device->priv; 174 (struct xpnet_dev_private *)xpnet_device->priv;
182
183 175
184 if (!XPNET_VALID_MSG(msg)) { 176 if (!XPNET_VALID_MSG(msg)) {
185 /* 177 /*
186 * Packet with a different XPC version. Ignore. 178 * Packet with a different XPC version. Ignore.
187 */ 179 */
188 xpc_received(partid, channel, (void *) msg); 180 xpc_received(partid, channel, (void *)msg);
189 181
190 priv->stats.rx_errors++; 182 priv->stats.rx_errors++;
191 183
@@ -194,14 +186,13 @@ xpnet_receive(partid_t partid, int channel, struct xpnet_message *msg)
194 dev_dbg(xpnet, "received 0x%lx, %d, %d, %d\n", msg->buf_pa, msg->size, 186 dev_dbg(xpnet, "received 0x%lx, %d, %d, %d\n", msg->buf_pa, msg->size,
195 msg->leadin_ignore, msg->tailout_ignore); 187 msg->leadin_ignore, msg->tailout_ignore);
196 188
197
198 /* reserve an extra cache line */ 189 /* reserve an extra cache line */
199 skb = dev_alloc_skb(msg->size + L1_CACHE_BYTES); 190 skb = dev_alloc_skb(msg->size + L1_CACHE_BYTES);
200 if (!skb) { 191 if (!skb) {
201 dev_err(xpnet, "failed on dev_alloc_skb(%d)\n", 192 dev_err(xpnet, "failed on dev_alloc_skb(%d)\n",
202 msg->size + L1_CACHE_BYTES); 193 msg->size + L1_CACHE_BYTES);
203 194
204 xpc_received(partid, channel, (void *) msg); 195 xpc_received(partid, channel, (void *)msg);
205 196
206 priv->stats.rx_errors++; 197 priv->stats.rx_errors++;
207 198
@@ -227,12 +218,13 @@ xpnet_receive(partid_t partid, int channel, struct xpnet_message *msg)
227 * Move the data over from the other side. 218 * Move the data over from the other side.
228 */ 219 */
229 if ((XPNET_VERSION_MINOR(msg->version) == 1) && 220 if ((XPNET_VERSION_MINOR(msg->version) == 1) &&
230 (msg->embedded_bytes != 0)) { 221 (msg->embedded_bytes != 0)) {
231 dev_dbg(xpnet, "copying embedded message. memcpy(0x%p, 0x%p, " 222 dev_dbg(xpnet, "copying embedded message. memcpy(0x%p, 0x%p, "
232 "%lu)\n", skb->data, &msg->data, 223 "%lu)\n", skb->data, &msg->data,
233 (size_t) msg->embedded_bytes); 224 (size_t)msg->embedded_bytes);
234 225
235 skb_copy_to_linear_data(skb, &msg->data, (size_t)msg->embedded_bytes); 226 skb_copy_to_linear_data(skb, &msg->data,
227 (size_t)msg->embedded_bytes);
236 } else { 228 } else {
237 dev_dbg(xpnet, "transferring buffer to the skb->data area;\n\t" 229 dev_dbg(xpnet, "transferring buffer to the skb->data area;\n\t"
238 "bte_copy(0x%p, 0x%p, %hu)\n", (void *)msg->buf_pa, 230 "bte_copy(0x%p, 0x%p, %hu)\n", (void *)msg->buf_pa,
@@ -250,10 +242,10 @@ xpnet_receive(partid_t partid, int channel, struct xpnet_message *msg)
250 dev_err(xpnet, "bte_copy(0x%p, 0x%p, 0x%hx) returned " 242 dev_err(xpnet, "bte_copy(0x%p, 0x%p, 0x%hx) returned "
251 "error=0x%x\n", (void *)msg->buf_pa, 243 "error=0x%x\n", (void *)msg->buf_pa,
252 (void *)__pa((u64)skb->data & 244 (void *)__pa((u64)skb->data &
253 ~(L1_CACHE_BYTES - 1)), 245 ~(L1_CACHE_BYTES - 1)),
254 msg->size, bret); 246 msg->size, bret);
255 247
256 xpc_received(partid, channel, (void *) msg); 248 xpc_received(partid, channel, (void *)msg);
257 249
258 priv->stats.rx_errors++; 250 priv->stats.rx_errors++;
259 251
@@ -262,7 +254,7 @@ xpnet_receive(partid_t partid, int channel, struct xpnet_message *msg)
262 } 254 }
263 255
264 dev_dbg(xpnet, "<skb->head=0x%p skb->data=0x%p skb->tail=0x%p " 256 dev_dbg(xpnet, "<skb->head=0x%p skb->data=0x%p skb->tail=0x%p "
265 "skb->end=0x%p skb->len=%d\n", (void *) skb->head, 257 "skb->end=0x%p skb->len=%d\n", (void *)skb->head,
266 (void *)skb->data, skb_tail_pointer(skb), skb_end_pointer(skb), 258 (void *)skb->data, skb_tail_pointer(skb), skb_end_pointer(skb),
267 skb->len); 259 skb->len);
268 260
@@ -275,16 +267,14 @@ xpnet_receive(partid_t partid, int channel, struct xpnet_message *msg)
275 (void *)skb->head, (void *)skb->data, skb_tail_pointer(skb), 267 (void *)skb->head, (void *)skb->data, skb_tail_pointer(skb),
276 skb_end_pointer(skb), skb->len); 268 skb_end_pointer(skb), skb->len);
277 269
278
279 xpnet_device->last_rx = jiffies; 270 xpnet_device->last_rx = jiffies;
280 priv->stats.rx_packets++; 271 priv->stats.rx_packets++;
281 priv->stats.rx_bytes += skb->len + ETH_HLEN; 272 priv->stats.rx_bytes += skb->len + ETH_HLEN;
282 273
283 netif_rx_ni(skb); 274 netif_rx_ni(skb);
284 xpc_received(partid, channel, (void *) msg); 275 xpc_received(partid, channel, (void *)msg);
285} 276}
286 277
287
288/* 278/*
289 * This is the handler which XPC calls during any sort of change in 279 * This is the handler which XPC calls during any sort of change in
290 * state or message reception on a connection. 280 * state or message reception on a connection.
@@ -295,20 +285,19 @@ xpnet_connection_activity(enum xpc_retval reason, partid_t partid, int channel,
295{ 285{
296 long bp; 286 long bp;
297 287
298
299 DBUG_ON(partid <= 0 || partid >= XP_MAX_PARTITIONS); 288 DBUG_ON(partid <= 0 || partid >= XP_MAX_PARTITIONS);
300 DBUG_ON(channel != XPC_NET_CHANNEL); 289 DBUG_ON(channel != XPC_NET_CHANNEL);
301 290
302 switch(reason) { 291 switch (reason) {
303 case xpcMsgReceived: /* message received */ 292 case xpcMsgReceived: /* message received */
304 DBUG_ON(data == NULL); 293 DBUG_ON(data == NULL);
305 294
306 xpnet_receive(partid, channel, (struct xpnet_message *) data); 295 xpnet_receive(partid, channel, (struct xpnet_message *)data);
307 break; 296 break;
308 297
309 case xpcConnected: /* connection completed to a partition */ 298 case xpcConnected: /* connection completed to a partition */
310 spin_lock_bh(&xpnet_broadcast_lock); 299 spin_lock_bh(&xpnet_broadcast_lock);
311 xpnet_broadcast_partitions |= 1UL << (partid -1 ); 300 xpnet_broadcast_partitions |= 1UL << (partid - 1);
312 bp = xpnet_broadcast_partitions; 301 bp = xpnet_broadcast_partitions;
313 spin_unlock_bh(&xpnet_broadcast_lock); 302 spin_unlock_bh(&xpnet_broadcast_lock);
314 303
@@ -321,7 +310,7 @@ xpnet_connection_activity(enum xpc_retval reason, partid_t partid, int channel,
321 310
322 default: 311 default:
323 spin_lock_bh(&xpnet_broadcast_lock); 312 spin_lock_bh(&xpnet_broadcast_lock);
324 xpnet_broadcast_partitions &= ~(1UL << (partid -1 )); 313 xpnet_broadcast_partitions &= ~(1UL << (partid - 1));
325 bp = xpnet_broadcast_partitions; 314 bp = xpnet_broadcast_partitions;
326 spin_unlock_bh(&xpnet_broadcast_lock); 315 spin_unlock_bh(&xpnet_broadcast_lock);
327 316
@@ -337,13 +326,11 @@ xpnet_connection_activity(enum xpc_retval reason, partid_t partid, int channel,
337 } 326 }
338} 327}
339 328
340
341static int 329static int
342xpnet_dev_open(struct net_device *dev) 330xpnet_dev_open(struct net_device *dev)
343{ 331{
344 enum xpc_retval ret; 332 enum xpc_retval ret;
345 333
346
347 dev_dbg(xpnet, "calling xpc_connect(%d, 0x%p, NULL, %ld, %ld, %ld, " 334 dev_dbg(xpnet, "calling xpc_connect(%d, 0x%p, NULL, %ld, %ld, %ld, "
348 "%ld)\n", XPC_NET_CHANNEL, xpnet_connection_activity, 335 "%ld)\n", XPC_NET_CHANNEL, xpnet_connection_activity,
349 XPNET_MSG_SIZE, XPNET_MSG_NENTRIES, XPNET_MAX_KTHREADS, 336 XPNET_MSG_SIZE, XPNET_MSG_NENTRIES, XPNET_MAX_KTHREADS,
@@ -364,7 +351,6 @@ xpnet_dev_open(struct net_device *dev)
364 return 0; 351 return 0;
365} 352}
366 353
367
368static int 354static int
369xpnet_dev_stop(struct net_device *dev) 355xpnet_dev_stop(struct net_device *dev)
370{ 356{
@@ -375,7 +361,6 @@ xpnet_dev_stop(struct net_device *dev)
375 return 0; 361 return 0;
376} 362}
377 363
378
379static int 364static int
380xpnet_dev_change_mtu(struct net_device *dev, int new_mtu) 365xpnet_dev_change_mtu(struct net_device *dev, int new_mtu)
381{ 366{
@@ -392,7 +377,6 @@ xpnet_dev_change_mtu(struct net_device *dev, int new_mtu)
392 return 0; 377 return 0;
393} 378}
394 379
395
396/* 380/*
397 * Required for the net_device structure. 381 * Required for the net_device structure.
398 */ 382 */
@@ -402,7 +386,6 @@ xpnet_dev_set_config(struct net_device *dev, struct ifmap *new_map)
402 return 0; 386 return 0;
403} 387}
404 388
405
406/* 389/*
407 * Return statistics to the caller. 390 * Return statistics to the caller.
408 */ 391 */
@@ -411,13 +394,11 @@ xpnet_dev_get_stats(struct net_device *dev)
411{ 394{
412 struct xpnet_dev_private *priv; 395 struct xpnet_dev_private *priv;
413 396
414 397 priv = (struct xpnet_dev_private *)dev->priv;
415 priv = (struct xpnet_dev_private *) dev->priv;
416 398
417 return &priv->stats; 399 return &priv->stats;
418} 400}
419 401
420
421/* 402/*
422 * Notification that the other end has received the message and 403 * Notification that the other end has received the message and
423 * DMA'd the skb information. At this point, they are done with 404 * DMA'd the skb information. At this point, they are done with
@@ -426,11 +407,9 @@ xpnet_dev_get_stats(struct net_device *dev)
426 */ 407 */
427static void 408static void
428xpnet_send_completed(enum xpc_retval reason, partid_t partid, int channel, 409xpnet_send_completed(enum xpc_retval reason, partid_t partid, int channel,
429 void *__qm) 410 void *__qm)
430{ 411{
431 struct xpnet_pending_msg *queued_msg = 412 struct xpnet_pending_msg *queued_msg = (struct xpnet_pending_msg *)__qm;
432 (struct xpnet_pending_msg *) __qm;
433
434 413
435 DBUG_ON(queued_msg == NULL); 414 DBUG_ON(queued_msg == NULL);
436 415
@@ -439,14 +418,13 @@ xpnet_send_completed(enum xpc_retval reason, partid_t partid, int channel,
439 418
440 if (atomic_dec_return(&queued_msg->use_count) == 0) { 419 if (atomic_dec_return(&queued_msg->use_count) == 0) {
441 dev_dbg(xpnet, "all acks for skb->head=-x%p\n", 420 dev_dbg(xpnet, "all acks for skb->head=-x%p\n",
442 (void *) queued_msg->skb->head); 421 (void *)queued_msg->skb->head);
443 422
444 dev_kfree_skb_any(queued_msg->skb); 423 dev_kfree_skb_any(queued_msg->skb);
445 kfree(queued_msg); 424 kfree(queued_msg);
446 } 425 }
447} 426}
448 427
449
450/* 428/*
451 * Network layer has formatted a packet (skb) and is ready to place it 429 * Network layer has formatted a packet (skb) and is ready to place it
452 * "on the wire". Prepare and send an xpnet_message to all partitions 430 * "on the wire". Prepare and send an xpnet_message to all partitions
@@ -469,16 +447,13 @@ xpnet_dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
469 struct xpnet_dev_private *priv; 447 struct xpnet_dev_private *priv;
470 u16 embedded_bytes; 448 u16 embedded_bytes;
471 449
472 450 priv = (struct xpnet_dev_private *)dev->priv;
473 priv = (struct xpnet_dev_private *) dev->priv;
474
475 451
476 dev_dbg(xpnet, ">skb->head=0x%p skb->data=0x%p skb->tail=0x%p " 452 dev_dbg(xpnet, ">skb->head=0x%p skb->data=0x%p skb->tail=0x%p "
477 "skb->end=0x%p skb->len=%d\n", (void *) skb->head, 453 "skb->end=0x%p skb->len=%d\n", (void *)skb->head,
478 (void *)skb->data, skb_tail_pointer(skb), skb_end_pointer(skb), 454 (void *)skb->data, skb_tail_pointer(skb), skb_end_pointer(skb),
479 skb->len); 455 skb->len);
480 456
481
482 /* 457 /*
483 * The xpnet_pending_msg tracks how many outstanding 458 * The xpnet_pending_msg tracks how many outstanding
484 * xpc_send_notifies are relying on this skb. When none 459 * xpc_send_notifies are relying on this skb. When none
@@ -487,16 +462,15 @@ xpnet_dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
487 queued_msg = kmalloc(sizeof(struct xpnet_pending_msg), GFP_ATOMIC); 462 queued_msg = kmalloc(sizeof(struct xpnet_pending_msg), GFP_ATOMIC);
488 if (queued_msg == NULL) { 463 if (queued_msg == NULL) {
489 dev_warn(xpnet, "failed to kmalloc %ld bytes; dropping " 464 dev_warn(xpnet, "failed to kmalloc %ld bytes; dropping "
490 "packet\n", sizeof(struct xpnet_pending_msg)); 465 "packet\n", sizeof(struct xpnet_pending_msg));
491 466
492 priv->stats.tx_errors++; 467 priv->stats.tx_errors++;
493 468
494 return -ENOMEM; 469 return -ENOMEM;
495 } 470 }
496 471
497
498 /* get the beginning of the first cacheline and end of last */ 472 /* get the beginning of the first cacheline and end of last */
499 start_addr = ((u64) skb->data & ~(L1_CACHE_BYTES - 1)); 473 start_addr = ((u64)skb->data & ~(L1_CACHE_BYTES - 1));
500 end_addr = L1_CACHE_ALIGN((u64)skb_tail_pointer(skb)); 474 end_addr = L1_CACHE_ALIGN((u64)skb_tail_pointer(skb));
501 475
502 /* calculate how many bytes to embed in the XPC message */ 476 /* calculate how many bytes to embed in the XPC message */
@@ -506,7 +480,6 @@ xpnet_dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
506 embedded_bytes = skb->len; 480 embedded_bytes = skb->len;
507 } 481 }
508 482
509
510 /* 483 /*
511 * Since the send occurs asynchronously, we set the count to one 484 * Since the send occurs asynchronously, we set the count to one
512 * and begin sending. Any sends that happen to complete before 485 * and begin sending. Any sends that happen to complete before
@@ -517,14 +490,13 @@ xpnet_dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
517 atomic_set(&queued_msg->use_count, 1); 490 atomic_set(&queued_msg->use_count, 1);
518 queued_msg->skb = skb; 491 queued_msg->skb = skb;
519 492
520
521 second_mac_octet = skb->data[XPNET_PARTID_OCTET]; 493 second_mac_octet = skb->data[XPNET_PARTID_OCTET];
522 if (second_mac_octet == 0xff) { 494 if (second_mac_octet == 0xff) {
523 /* we are being asked to broadcast to all partitions */ 495 /* we are being asked to broadcast to all partitions */
524 dp = xpnet_broadcast_partitions; 496 dp = xpnet_broadcast_partitions;
525 } else if (second_mac_octet != 0) { 497 } else if (second_mac_octet != 0) {
526 dp = xpnet_broadcast_partitions & 498 dp = xpnet_broadcast_partitions &
527 (1UL << (second_mac_octet - 1)); 499 (1UL << (second_mac_octet - 1));
528 } else { 500 } else {
529 /* 0 is an invalid partid. Ignore */ 501 /* 0 is an invalid partid. Ignore */
530 dp = 0; 502 dp = 0;
@@ -543,7 +515,6 @@ xpnet_dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
543 for (dest_partid = 1; dp && dest_partid < XP_MAX_PARTITIONS; 515 for (dest_partid = 1; dp && dest_partid < XP_MAX_PARTITIONS;
544 dest_partid++) { 516 dest_partid++) {
545 517
546
547 if (!(dp & (1UL << (dest_partid - 1)))) { 518 if (!(dp & (1UL << (dest_partid - 1)))) {
548 /* not destined for this partition */ 519 /* not destined for this partition */
549 continue; 520 continue;
@@ -552,7 +523,6 @@ xpnet_dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
552 /* remove this partition from the destinations mask */ 523 /* remove this partition from the destinations mask */
553 dp &= ~(1UL << (dest_partid - 1)); 524 dp &= ~(1UL << (dest_partid - 1));
554 525
555
556 /* found a partition to send to */ 526 /* found a partition to send to */
557 527
558 ret = xpc_allocate(dest_partid, XPC_NET_CHANNEL, 528 ret = xpc_allocate(dest_partid, XPC_NET_CHANNEL,
@@ -565,7 +535,7 @@ xpnet_dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
565 if (unlikely(embedded_bytes != 0)) { 535 if (unlikely(embedded_bytes != 0)) {
566 msg->version = XPNET_VERSION_EMBED; 536 msg->version = XPNET_VERSION_EMBED;
567 dev_dbg(xpnet, "calling memcpy(0x%p, 0x%p, 0x%lx)\n", 537 dev_dbg(xpnet, "calling memcpy(0x%p, 0x%p, 0x%lx)\n",
568 &msg->data, skb->data, (size_t) embedded_bytes); 538 &msg->data, skb->data, (size_t)embedded_bytes);
569 skb_copy_from_linear_data(skb, &msg->data, 539 skb_copy_from_linear_data(skb, &msg->data,
570 (size_t)embedded_bytes); 540 (size_t)embedded_bytes);
571 } else { 541 } else {
@@ -573,7 +543,7 @@ xpnet_dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
573 } 543 }
574 msg->magic = XPNET_MAGIC; 544 msg->magic = XPNET_MAGIC;
575 msg->size = end_addr - start_addr; 545 msg->size = end_addr - start_addr;
576 msg->leadin_ignore = (u64) skb->data - start_addr; 546 msg->leadin_ignore = (u64)skb->data - start_addr;
577 msg->tailout_ignore = end_addr - (u64)skb_tail_pointer(skb); 547 msg->tailout_ignore = end_addr - (u64)skb_tail_pointer(skb);
578 msg->buf_pa = __pa(start_addr); 548 msg->buf_pa = __pa(start_addr);
579 549
@@ -583,7 +553,6 @@ xpnet_dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
583 dest_partid, XPC_NET_CHANNEL, msg->buf_pa, msg->size, 553 dest_partid, XPC_NET_CHANNEL, msg->buf_pa, msg->size,
584 msg->leadin_ignore, msg->tailout_ignore); 554 msg->leadin_ignore, msg->tailout_ignore);
585 555
586
587 atomic_inc(&queued_msg->use_count); 556 atomic_inc(&queued_msg->use_count);
588 557
589 ret = xpc_send_notify(dest_partid, XPC_NET_CHANNEL, msg, 558 ret = xpc_send_notify(dest_partid, XPC_NET_CHANNEL, msg,
@@ -599,7 +568,6 @@ xpnet_dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
599 dev_dbg(xpnet, "no partitions to receive packet destined for " 568 dev_dbg(xpnet, "no partitions to receive packet destined for "
600 "%d\n", dest_partid); 569 "%d\n", dest_partid);
601 570
602
603 dev_kfree_skb(skb); 571 dev_kfree_skb(skb);
604 kfree(queued_msg); 572 kfree(queued_msg);
605 } 573 }
@@ -610,23 +578,20 @@ xpnet_dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
610 return 0; 578 return 0;
611} 579}
612 580
613
614/* 581/*
615 * Deal with transmit timeouts coming from the network layer. 582 * Deal with transmit timeouts coming from the network layer.
616 */ 583 */
617static void 584static void
618xpnet_dev_tx_timeout (struct net_device *dev) 585xpnet_dev_tx_timeout(struct net_device *dev)
619{ 586{
620 struct xpnet_dev_private *priv; 587 struct xpnet_dev_private *priv;
621 588
622 589 priv = (struct xpnet_dev_private *)dev->priv;
623 priv = (struct xpnet_dev_private *) dev->priv;
624 590
625 priv->stats.tx_errors++; 591 priv->stats.tx_errors++;
626 return; 592 return;
627} 593}
628 594
629
630static int __init 595static int __init
631xpnet_init(void) 596xpnet_init(void)
632{ 597{
@@ -634,7 +599,6 @@ xpnet_init(void)
634 u32 license_num; 599 u32 license_num;
635 int result = -ENOMEM; 600 int result = -ENOMEM;
636 601
637
638 if (!ia64_platform_is("sn2")) { 602 if (!ia64_platform_is("sn2")) {
639 return -ENODEV; 603 return -ENODEV;
640 } 604 }
@@ -672,7 +636,7 @@ xpnet_init(void)
672 license_num = sn_partition_serial_number_val(); 636 license_num = sn_partition_serial_number_val();
673 for (i = 3; i >= 0; i--) { 637 for (i = 3; i >= 0; i--) {
674 xpnet_device->dev_addr[XPNET_LICENSE_OCTET + i] = 638 xpnet_device->dev_addr[XPNET_LICENSE_OCTET + i] =
675 license_num & 0xff; 639 license_num & 0xff;
676 license_num = license_num >> 8; 640 license_num = license_num >> 8;
677 } 641 }
678 642
@@ -696,23 +660,22 @@ xpnet_init(void)
696 660
697 return result; 661 return result;
698} 662}
699module_init(xpnet_init);
700 663
664module_init(xpnet_init);
701 665
702static void __exit 666static void __exit
703xpnet_exit(void) 667xpnet_exit(void)
704{ 668{
705 dev_info(xpnet, "unregistering network device %s\n", 669 dev_info(xpnet, "unregistering network device %s\n",
706 xpnet_device[0].name); 670 xpnet_device[0].name);
707 671
708 unregister_netdev(xpnet_device); 672 unregister_netdev(xpnet_device);
709 673
710 free_netdev(xpnet_device); 674 free_netdev(xpnet_device);
711} 675}
712module_exit(xpnet_exit);
713 676
677module_exit(xpnet_exit);
714 678
715MODULE_AUTHOR("Silicon Graphics, Inc."); 679MODULE_AUTHOR("Silicon Graphics, Inc.");
716MODULE_DESCRIPTION("Cross Partition Network adapter (XPNET)"); 680MODULE_DESCRIPTION("Cross Partition Network adapter (XPNET)");
717MODULE_LICENSE("GPL"); 681MODULE_LICENSE("GPL");
718