aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/iseries_veth.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/iseries_veth.c')
-rw-r--r--drivers/net/iseries_veth.c98
1 files changed, 51 insertions, 47 deletions
diff --git a/drivers/net/iseries_veth.c b/drivers/net/iseries_veth.c
index 183ba97785b0..d5b08dc8a9f8 100644
--- a/drivers/net/iseries_veth.c
+++ b/drivers/net/iseries_veth.c
@@ -79,6 +79,8 @@
79#include <asm/iommu.h> 79#include <asm/iommu.h>
80#include <asm/vio.h> 80#include <asm/vio.h>
81 81
82#undef DEBUG
83
82#include "iseries_veth.h" 84#include "iseries_veth.h"
83 85
84MODULE_AUTHOR("Kyle Lucke <klucke@us.ibm.com>"); 86MODULE_AUTHOR("Kyle Lucke <klucke@us.ibm.com>");
@@ -176,11 +178,18 @@ static void veth_timed_ack(unsigned long connectionPtr);
176 * Utility functions 178 * Utility functions
177 */ 179 */
178 180
179#define veth_printk(prio, fmt, args...) \ 181#define veth_info(fmt, args...) \
180 printk(prio "%s: " fmt, __FILE__, ## args) 182 printk(KERN_INFO "iseries_veth: " fmt, ## args)
181 183
182#define veth_error(fmt, args...) \ 184#define veth_error(fmt, args...) \
183 printk(KERN_ERR "(%s:%3.3d) ERROR: " fmt, __FILE__, __LINE__ , ## args) 185 printk(KERN_ERR "iseries_veth: Error: " fmt, ## args)
186
187#ifdef DEBUG
188#define veth_debug(fmt, args...) \
189 printk(KERN_DEBUG "iseries_veth: " fmt, ## args)
190#else
191#define veth_debug(fmt, args...) do {} while (0)
192#endif
184 193
185static inline void veth_stack_push(struct veth_lpar_connection *cnx, 194static inline void veth_stack_push(struct veth_lpar_connection *cnx,
186 struct veth_msg *msg) 195 struct veth_msg *msg)
@@ -278,7 +287,7 @@ static void veth_take_cap(struct veth_lpar_connection *cnx,
278 HvLpEvent_Type_VirtualLan); 287 HvLpEvent_Type_VirtualLan);
279 288
280 if (cnx->state & VETH_STATE_GOTCAPS) { 289 if (cnx->state & VETH_STATE_GOTCAPS) {
281 veth_error("Received a second capabilities from lpar %d\n", 290 veth_error("Received a second capabilities from LPAR %d.\n",
282 cnx->remote_lp); 291 cnx->remote_lp);
283 event->base_event.xRc = HvLpEvent_Rc_BufferNotAvailable; 292 event->base_event.xRc = HvLpEvent_Rc_BufferNotAvailable;
284 HvCallEvent_ackLpEvent((struct HvLpEvent *) event); 293 HvCallEvent_ackLpEvent((struct HvLpEvent *) event);
@@ -297,7 +306,7 @@ static void veth_take_cap_ack(struct veth_lpar_connection *cnx,
297 306
298 spin_lock_irqsave(&cnx->lock, flags); 307 spin_lock_irqsave(&cnx->lock, flags);
299 if (cnx->state & VETH_STATE_GOTCAPACK) { 308 if (cnx->state & VETH_STATE_GOTCAPACK) {
300 veth_error("Received a second capabilities ack from lpar %d\n", 309 veth_error("Received a second capabilities ack from LPAR %d.\n",
301 cnx->remote_lp); 310 cnx->remote_lp);
302 } else { 311 } else {
303 memcpy(&cnx->cap_ack_event, event, 312 memcpy(&cnx->cap_ack_event, event,
@@ -314,8 +323,7 @@ static void veth_take_monitor_ack(struct veth_lpar_connection *cnx,
314 unsigned long flags; 323 unsigned long flags;
315 324
316 spin_lock_irqsave(&cnx->lock, flags); 325 spin_lock_irqsave(&cnx->lock, flags);
317 veth_printk(KERN_DEBUG, "Monitor ack returned for lpar %d\n", 326 veth_debug("cnx %d: lost connection.\n", cnx->remote_lp);
318 cnx->remote_lp);
319 cnx->state |= VETH_STATE_RESET; 327 cnx->state |= VETH_STATE_RESET;
320 veth_kick_statemachine(cnx); 328 veth_kick_statemachine(cnx);
321 spin_unlock_irqrestore(&cnx->lock, flags); 329 spin_unlock_irqrestore(&cnx->lock, flags);
@@ -336,8 +344,8 @@ static void veth_handle_ack(struct VethLpEvent *event)
336 veth_take_monitor_ack(cnx, event); 344 veth_take_monitor_ack(cnx, event);
337 break; 345 break;
338 default: 346 default:
339 veth_error("Unknown ack type %d from lpar %d\n", 347 veth_error("Unknown ack type %d from LPAR %d.\n",
340 event->base_event.xSubtype, rlp); 348 event->base_event.xSubtype, rlp);
341 }; 349 };
342} 350}
343 351
@@ -373,8 +381,8 @@ static void veth_handle_int(struct VethLpEvent *event)
373 veth_receive(cnx, event); 381 veth_receive(cnx, event);
374 break; 382 break;
375 default: 383 default:
376 veth_error("Unknown interrupt type %d from lpar %d\n", 384 veth_error("Unknown interrupt type %d from LPAR %d.\n",
377 event->base_event.xSubtype, rlp); 385 event->base_event.xSubtype, rlp);
378 }; 386 };
379} 387}
380 388
@@ -400,8 +408,8 @@ static int veth_process_caps(struct veth_lpar_connection *cnx)
400 || (remote_caps->ack_threshold > VETH_MAX_ACKS_PER_MSG) 408 || (remote_caps->ack_threshold > VETH_MAX_ACKS_PER_MSG)
401 || (remote_caps->ack_threshold == 0) 409 || (remote_caps->ack_threshold == 0)
402 || (cnx->ack_timeout == 0) ) { 410 || (cnx->ack_timeout == 0) ) {
403 veth_error("Received incompatible capabilities from lpar %d\n", 411 veth_error("Received incompatible capabilities from LPAR %d.\n",
404 cnx->remote_lp); 412 cnx->remote_lp);
405 return HvLpEvent_Rc_InvalidSubtypeData; 413 return HvLpEvent_Rc_InvalidSubtypeData;
406 } 414 }
407 415
@@ -418,8 +426,8 @@ static int veth_process_caps(struct veth_lpar_connection *cnx)
418 cnx->num_ack_events += num; 426 cnx->num_ack_events += num;
419 427
420 if (cnx->num_ack_events < num_acks_needed) { 428 if (cnx->num_ack_events < num_acks_needed) {
421 veth_error("Couldn't allocate enough ack events for lpar %d\n", 429 veth_error("Couldn't allocate enough ack events "
422 cnx->remote_lp); 430 "for LPAR %d.\n", cnx->remote_lp);
423 431
424 return HvLpEvent_Rc_BufferNotAvailable; 432 return HvLpEvent_Rc_BufferNotAvailable;
425 } 433 }
@@ -498,9 +506,8 @@ static void veth_statemachine(void *p)
498 } else { 506 } else {
499 if ( (rc != HvLpEvent_Rc_PartitionDead) 507 if ( (rc != HvLpEvent_Rc_PartitionDead)
500 && (rc != HvLpEvent_Rc_PathClosed) ) 508 && (rc != HvLpEvent_Rc_PathClosed) )
501 veth_error("Error sending monitor to " 509 veth_error("Error sending monitor to LPAR %d, "
502 "lpar %d, rc=%x\n", 510 "rc = %d\n", rlp, rc);
503 rlp, (int) rc);
504 511
505 /* Oh well, hope we get a cap from the other 512 /* Oh well, hope we get a cap from the other
506 * end and do better when that kicks us */ 513 * end and do better when that kicks us */
@@ -523,9 +530,9 @@ static void veth_statemachine(void *p)
523 } else { 530 } else {
524 if ( (rc != HvLpEvent_Rc_PartitionDead) 531 if ( (rc != HvLpEvent_Rc_PartitionDead)
525 && (rc != HvLpEvent_Rc_PathClosed) ) 532 && (rc != HvLpEvent_Rc_PathClosed) )
526 veth_error("Error sending caps to " 533 veth_error("Error sending caps to LPAR %d, "
527 "lpar %d, rc=%x\n", 534 "rc = %d\n", rlp, rc);
528 rlp, (int) rc); 535
529 /* Oh well, hope we get a cap from the other 536 /* Oh well, hope we get a cap from the other
530 * end and do better when that kicks us */ 537 * end and do better when that kicks us */
531 goto out; 538 goto out;
@@ -565,10 +572,8 @@ static void veth_statemachine(void *p)
565 add_timer(&cnx->ack_timer); 572 add_timer(&cnx->ack_timer);
566 cnx->state |= VETH_STATE_READY; 573 cnx->state |= VETH_STATE_READY;
567 } else { 574 } else {
568 veth_printk(KERN_ERR, "Caps rejected (rc=%d) by " 575 veth_error("Caps rejected by LPAR %d, rc = %d\n",
569 "lpar %d\n", 576 rlp, cnx->cap_ack_event.base_event.xRc);
570 cnx->cap_ack_event.base_event.xRc,
571 rlp);
572 goto cant_cope; 577 goto cant_cope;
573 } 578 }
574 } 579 }
@@ -581,8 +586,8 @@ static void veth_statemachine(void *p)
581 /* FIXME: we get here if something happens we really can't 586 /* FIXME: we get here if something happens we really can't
582 * cope with. The link will never work once we get here, and 587 * cope with. The link will never work once we get here, and
583 * all we can do is not lock the rest of the system up */ 588 * all we can do is not lock the rest of the system up */
584 veth_error("Badness on connection to lpar %d (state=%04lx) " 589 veth_error("Unrecoverable error on connection to LPAR %d, shutting down"
585 " - shutting down\n", rlp, cnx->state); 590 " (state = 0x%04lx)\n", rlp, cnx->state);
586 cnx->state |= VETH_STATE_SHUTDOWN; 591 cnx->state |= VETH_STATE_SHUTDOWN;
587 spin_unlock_irq(&cnx->lock); 592 spin_unlock_irq(&cnx->lock);
588} 593}
@@ -614,7 +619,7 @@ static int veth_init_connection(u8 rlp)
614 619
615 msgs = kmalloc(VETH_NUMBUFFERS * sizeof(struct veth_msg), GFP_KERNEL); 620 msgs = kmalloc(VETH_NUMBUFFERS * sizeof(struct veth_msg), GFP_KERNEL);
616 if (! msgs) { 621 if (! msgs) {
617 veth_error("Can't allocate buffers for lpar %d\n", rlp); 622 veth_error("Can't allocate buffers for LPAR %d.\n", rlp);
618 return -ENOMEM; 623 return -ENOMEM;
619 } 624 }
620 625
@@ -630,8 +635,7 @@ static int veth_init_connection(u8 rlp)
630 cnx->num_events = veth_allocate_events(rlp, 2 + VETH_NUMBUFFERS); 635 cnx->num_events = veth_allocate_events(rlp, 2 + VETH_NUMBUFFERS);
631 636
632 if (cnx->num_events < (2 + VETH_NUMBUFFERS)) { 637 if (cnx->num_events < (2 + VETH_NUMBUFFERS)) {
633 veth_error("Can't allocate events for lpar %d, only got %d\n", 638 veth_error("Can't allocate enough events for LPAR %d.\n", rlp);
634 rlp, cnx->num_events);
635 return -ENOMEM; 639 return -ENOMEM;
636 } 640 }
637 641
@@ -889,15 +893,13 @@ static struct net_device * __init veth_probe_one(int vlan, struct device *vdev)
889 893
890 rc = register_netdev(dev); 894 rc = register_netdev(dev);
891 if (rc != 0) { 895 if (rc != 0) {
892 veth_printk(KERN_ERR, 896 veth_error("Failed registering net device for vlan%d.\n", vlan);
893 "Failed to register ethernet device for vlan %d\n",
894 vlan);
895 free_netdev(dev); 897 free_netdev(dev);
896 return NULL; 898 return NULL;
897 } 899 }
898 900
899 veth_printk(KERN_DEBUG, "%s attached to iSeries vlan %d (lpar_map=0x%04x)\n", 901 veth_info("%s attached to iSeries vlan %d (LPAR map = 0x%.4X)\n",
900 dev->name, vlan, port->lpar_map); 902 dev->name, vlan, port->lpar_map);
901 903
902 return dev; 904 return dev;
903} 905}
@@ -1030,7 +1032,7 @@ static int veth_start_xmit(struct sk_buff *skb, struct net_device *dev)
1030 dev_kfree_skb(skb); 1032 dev_kfree_skb(skb);
1031 } else { 1033 } else {
1032 if (port->pending_skb) { 1034 if (port->pending_skb) {
1033 veth_error("%s: Tx while skb was pending!\n", 1035 veth_error("%s: TX while skb was pending!\n",
1034 dev->name); 1036 dev->name);
1035 dev_kfree_skb(skb); 1037 dev_kfree_skb(skb);
1036 spin_unlock_irqrestore(&port->pending_gate, flags); 1038 spin_unlock_irqrestore(&port->pending_gate, flags);
@@ -1066,10 +1068,10 @@ static void veth_recycle_msg(struct veth_lpar_connection *cnx,
1066 1068
1067 memset(&msg->data, 0, sizeof(msg->data)); 1069 memset(&msg->data, 0, sizeof(msg->data));
1068 veth_stack_push(cnx, msg); 1070 veth_stack_push(cnx, msg);
1069 } else 1071 } else if (cnx->state & VETH_STATE_OPEN) {
1070 if (cnx->state & VETH_STATE_OPEN) 1072 veth_error("Non-pending frame (# %d) acked by LPAR %d.\n",
1071 veth_error("Bogus frames ack from lpar %d (#%d)\n", 1073 cnx->remote_lp, msg->token);
1072 cnx->remote_lp, msg->token); 1074 }
1073} 1075}
1074 1076
1075static void veth_flush_pending(struct veth_lpar_connection *cnx) 1077static void veth_flush_pending(struct veth_lpar_connection *cnx)
@@ -1179,8 +1181,8 @@ static void veth_flush_acks(struct veth_lpar_connection *cnx)
1179 0, &cnx->pending_acks); 1181 0, &cnx->pending_acks);
1180 1182
1181 if (rc != HvLpEvent_Rc_Good) 1183 if (rc != HvLpEvent_Rc_Good)
1182 veth_error("Error 0x%x acking frames from lpar %d!\n", 1184 veth_error("Failed acking frames from LPAR %d, rc = %d\n",
1183 (unsigned)rc, cnx->remote_lp); 1185 cnx->remote_lp, (int)rc);
1184 1186
1185 cnx->num_pending_acks = 0; 1187 cnx->num_pending_acks = 0;
1186 memset(&cnx->pending_acks, 0xff, sizeof(cnx->pending_acks)); 1188 memset(&cnx->pending_acks, 0xff, sizeof(cnx->pending_acks));
@@ -1216,9 +1218,10 @@ static void veth_receive(struct veth_lpar_connection *cnx,
1216 /* make sure that we have at least 1 EOF entry in the 1218 /* make sure that we have at least 1 EOF entry in the
1217 * remaining entries */ 1219 * remaining entries */
1218 if (! (senddata->eofmask >> (startchunk + VETH_EOF_SHIFT))) { 1220 if (! (senddata->eofmask >> (startchunk + VETH_EOF_SHIFT))) {
1219 veth_error("missing EOF frag in event " 1221 veth_error("Missing EOF fragment in event "
1220 "eofmask=0x%x startchunk=%d\n", 1222 "eofmask = 0x%x startchunk = %d\n",
1221 (unsigned) senddata->eofmask, startchunk); 1223 (unsigned)senddata->eofmask,
1224 startchunk);
1222 break; 1225 break;
1223 } 1226 }
1224 1227
@@ -1237,8 +1240,9 @@ static void veth_receive(struct veth_lpar_connection *cnx,
1237 /* nchunks == # of chunks in this frame */ 1240 /* nchunks == # of chunks in this frame */
1238 1241
1239 if ((length - ETH_HLEN) > VETH_MAX_MTU) { 1242 if ((length - ETH_HLEN) > VETH_MAX_MTU) {
1240 veth_error("Received oversize frame from lpar %d " 1243 veth_error("Received oversize frame from LPAR %d "
1241 "(length=%d)\n", cnx->remote_lp, length); 1244 "(length = %d)\n",
1245 cnx->remote_lp, length);
1242 continue; 1246 continue;
1243 } 1247 }
1244 1248