rionet.c (0e90ed0e8b9b1c25040442f1d20c799751b1e727) rionet.c (abfc89c7b5347b869d1c48ddae027caf91a2300d)
1/*
2 * rionet - Ethernet driver over RapidIO messaging services
3 *
4 * Copyright 2005 MontaVista Software, Inc.
5 * Matt Porter <mporter@kernel.crashing.org>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the

--- 176 unchanged lines hidden (view full) ---

185 if ((rnet->tx_cnt + 1) > RIONET_TX_RING_SIZE) {
186 netif_stop_queue(ndev);
187 spin_unlock_irqrestore(&rnet->tx_lock, flags);
188 printk(KERN_ERR "%s: BUG! Tx Ring full when queue awake!\n",
189 ndev->name);
190 return NETDEV_TX_BUSY;
191 }
192
1/*
2 * rionet - Ethernet driver over RapidIO messaging services
3 *
4 * Copyright 2005 MontaVista Software, Inc.
5 * Matt Porter <mporter@kernel.crashing.org>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the

--- 176 unchanged lines hidden (view full) ---

185 if ((rnet->tx_cnt + 1) > RIONET_TX_RING_SIZE) {
186 netif_stop_queue(ndev);
187 spin_unlock_irqrestore(&rnet->tx_lock, flags);
188 printk(KERN_ERR "%s: BUG! Tx Ring full when queue awake!\n",
189 ndev->name);
190 return NETDEV_TX_BUSY;
191 }
192
193 if (eth->h_dest[0] & 0x01) {
193 if (is_multicast_ether_addr(eth->h_dest)) {
194 for (i = 0; i < RIO_MAX_ROUTE_ENTRIES(rnet->mport->sys_size);
195 i++)
196 if (rionet_active[i])
197 rionet_queue_tx_msg(skb, ndev,
198 rionet_active[i]);
199 } else if (RIONET_MAC_MATCH(eth->h_dest)) {
200 destid = RIONET_GET_DESTID(eth->h_dest);
201 if (rionet_active[destid])

--- 171 unchanged lines hidden (view full) ---

373 rio_release_inb_mbox(rnet->mport, RIONET_MAILBOX);
374 rio_release_outb_mbox(rnet->mport, RIONET_MAILBOX);
375
376 return 0;
377}
378
379static void rionet_remove(struct rio_dev *rdev)
380{
194 for (i = 0; i < RIO_MAX_ROUTE_ENTRIES(rnet->mport->sys_size);
195 i++)
196 if (rionet_active[i])
197 rionet_queue_tx_msg(skb, ndev,
198 rionet_active[i]);
199 } else if (RIONET_MAC_MATCH(eth->h_dest)) {
200 destid = RIONET_GET_DESTID(eth->h_dest);
201 if (rionet_active[destid])

--- 171 unchanged lines hidden (view full) ---

373 rio_release_inb_mbox(rnet->mport, RIONET_MAILBOX);
374 rio_release_outb_mbox(rnet->mport, RIONET_MAILBOX);
375
376 return 0;
377}
378
379static void rionet_remove(struct rio_dev *rdev)
380{
381 struct net_device *ndev = rio_get_drvdata(rdev);
381 struct net_device *ndev = NULL;
382 struct rionet_peer *peer, *tmp;
383
384 free_pages((unsigned long)rionet_active, rdev->net->hport->sys_size ?
385 __fls(sizeof(void *)) + 4 : 0);
386 unregister_netdev(ndev);
387 free_netdev(ndev);
388
389 list_for_each_entry_safe(peer, tmp, &rionet_peers, node) {

--- 38 unchanged lines hidden (view full) ---

428 .ndo_open = rionet_open,
429 .ndo_stop = rionet_close,
430 .ndo_start_xmit = rionet_start_xmit,
431 .ndo_change_mtu = eth_change_mtu,
432 .ndo_validate_addr = eth_validate_addr,
433 .ndo_set_mac_address = eth_mac_addr,
434};
435
382 struct rionet_peer *peer, *tmp;
383
384 free_pages((unsigned long)rionet_active, rdev->net->hport->sys_size ?
385 __fls(sizeof(void *)) + 4 : 0);
386 unregister_netdev(ndev);
387 free_netdev(ndev);
388
389 list_for_each_entry_safe(peer, tmp, &rionet_peers, node) {

--- 38 unchanged lines hidden (view full) ---

428 .ndo_open = rionet_open,
429 .ndo_stop = rionet_close,
430 .ndo_start_xmit = rionet_start_xmit,
431 .ndo_change_mtu = eth_change_mtu,
432 .ndo_validate_addr = eth_validate_addr,
433 .ndo_set_mac_address = eth_mac_addr,
434};
435
436static int rionet_setup_netdev(struct rio_mport *mport, struct net_device *ndev)
436static int rionet_setup_netdev(struct rio_mport *mport)
437{
438 int rc = 0;
437{
438 int rc = 0;
439 struct net_device *ndev = NULL;
439 struct rionet_private *rnet;
440 u16 device_id;
441
440 struct rionet_private *rnet;
441 u16 device_id;
442
443 /* Allocate our net_device structure */
444 ndev = alloc_etherdev(sizeof(struct rionet_private));
445 if (ndev == NULL) {
446 printk(KERN_INFO "%s: could not allocate ethernet device.\n",
447 DRV_NAME);
448 rc = -ENOMEM;
449 goto out;
450 }
451
442 rionet_active = (struct rio_dev **)__get_free_pages(GFP_KERNEL,
443 mport->sys_size ? __fls(sizeof(void *)) + 4 : 0);
444 if (!rionet_active) {
445 rc = -ENOMEM;
446 goto out;
447 }
448 memset((void *)rionet_active, 0, sizeof(void *) *
449 RIO_MAX_ROUTE_ENTRIES(mport->sys_size));

--- 39 unchanged lines hidden (view full) ---

489/*
490 * XXX Make multi-net safe
491 */
492static int rionet_probe(struct rio_dev *rdev, const struct rio_device_id *id)
493{
494 int rc = -ENODEV;
495 u32 lpef, lsrc_ops, ldst_ops;
496 struct rionet_peer *peer;
452 rionet_active = (struct rio_dev **)__get_free_pages(GFP_KERNEL,
453 mport->sys_size ? __fls(sizeof(void *)) + 4 : 0);
454 if (!rionet_active) {
455 rc = -ENOMEM;
456 goto out;
457 }
458 memset((void *)rionet_active, 0, sizeof(void *) *
459 RIO_MAX_ROUTE_ENTRIES(mport->sys_size));

--- 39 unchanged lines hidden (view full) ---

499/*
500 * XXX Make multi-net safe
501 */
502static int rionet_probe(struct rio_dev *rdev, const struct rio_device_id *id)
503{
504 int rc = -ENODEV;
505 u32 lpef, lsrc_ops, ldst_ops;
506 struct rionet_peer *peer;
497 struct net_device *ndev = NULL;
498
499 /* If local device is not rionet capable, give up quickly */
500 if (!rionet_capable)
501 goto out;
502
507
508 /* If local device is not rionet capable, give up quickly */
509 if (!rionet_capable)
510 goto out;
511
503 /* Allocate our net_device structure */
504 ndev = alloc_etherdev(sizeof(struct rionet_private));
505 if (ndev == NULL) {
506 printk(KERN_INFO "%s: could not allocate ethernet device.\n",
507 DRV_NAME);
508 rc = -ENOMEM;
509 goto out;
510 }
511
512 /*
513 * First time through, make sure local device is rionet
514 * capable, setup netdev, and set flags so this is skipped
515 * on later probes
516 */
517 if (!rionet_check) {
518 rio_local_read_config_32(rdev->net->hport, RIO_PEF_CAR, &lpef);
519 rio_local_read_config_32(rdev->net->hport, RIO_SRC_OPS_CAR,

--- 4 unchanged lines hidden (view full) ---

524 printk(KERN_ERR
525 "%s: local device is not network capable\n",
526 DRV_NAME);
527 rionet_check = 1;
528 rionet_capable = 0;
529 goto out;
530 }
531
512 /*
513 * First time through, make sure local device is rionet
514 * capable, setup netdev, and set flags so this is skipped
515 * on later probes
516 */
517 if (!rionet_check) {
518 rio_local_read_config_32(rdev->net->hport, RIO_PEF_CAR, &lpef);
519 rio_local_read_config_32(rdev->net->hport, RIO_SRC_OPS_CAR,

--- 4 unchanged lines hidden (view full) ---

524 printk(KERN_ERR
525 "%s: local device is not network capable\n",
526 DRV_NAME);
527 rionet_check = 1;
528 rionet_capable = 0;
529 goto out;
530 }
531
532 rc = rionet_setup_netdev(rdev->net->hport, ndev);
532 rc = rionet_setup_netdev(rdev->net->hport);
533 rionet_check = 1;
534 }
535
536 /*
537 * If the remote device has mailbox/doorbell capabilities,
538 * add it to the peer list.
539 */
540 if (dev_rionet_capable(rdev)) {
541 if (!(peer = kmalloc(sizeof(struct rionet_peer), GFP_KERNEL))) {
542 rc = -ENOMEM;
543 goto out;
544 }
545 peer->rdev = rdev;
546 list_add_tail(&peer->node, &rionet_peers);
547 }
548
533 rionet_check = 1;
534 }
535
536 /*
537 * If the remote device has mailbox/doorbell capabilities,
538 * add it to the peer list.
539 */
540 if (dev_rionet_capable(rdev)) {
541 if (!(peer = kmalloc(sizeof(struct rionet_peer), GFP_KERNEL))) {
542 rc = -ENOMEM;
543 goto out;
544 }
545 peer->rdev = rdev;
546 list_add_tail(&peer->node, &rionet_peers);
547 }
548
549 rio_set_drvdata(rdev, ndev);
550
551 out:
552 return rc;
553}
554
555static struct rio_device_id rionet_id_table[] = {
556 {RIO_DEVICE(RIO_ANY_ID, RIO_ANY_ID)}
557};
558

--- 19 unchanged lines hidden ---
549 out:
550 return rc;
551}
552
553static struct rio_device_id rionet_id_table[] = {
554 {RIO_DEVICE(RIO_ANY_ID, RIO_ANY_ID)}
555};
556

--- 19 unchanged lines hidden ---