aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ehea/ehea_main.c
diff options
context:
space:
mode:
authorJan-Bernd Themann <ossthema@de.ibm.com>2007-03-22 12:50:24 -0400
committerJeff Garzik <jeff@garzik.org>2007-04-28 11:01:01 -0400
commite542aa6bd50ba163253e60ba8e7e51c0d56162a7 (patch)
treebe7a13e513f73daff1353c08c661b85faad83449 /drivers/net/ehea/ehea_main.c
parent1eef4e04c95fb52a1a3885c8f53a822206fc9aa5 (diff)
ehea: code cleanup
This patch includes: - code cleanup related to resource management - extended error data gathering for resource management - removing trailing whitespaces Signed-off-by: Jan-Bernd Themann <themann@de.ibm.com> Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/net/ehea/ehea_main.c')
-rw-r--r--drivers/net/ehea/ehea_main.c95
1 files changed, 36 insertions, 59 deletions
diff --git a/drivers/net/ehea/ehea_main.c b/drivers/net/ehea/ehea_main.c
index db0d79ebae81..8bceb4e6bb82 100644
--- a/drivers/net/ehea/ehea_main.c
+++ b/drivers/net/ehea/ehea_main.c
@@ -546,19 +546,19 @@ static int ehea_poll(struct net_device *dev, int *budget)
546 cqe = ehea_poll_rq1(pr->qp, &wqe_index); 546 cqe = ehea_poll_rq1(pr->qp, &wqe_index);
547 cqe_skb = ehea_poll_cq(pr->send_cq); 547 cqe_skb = ehea_poll_cq(pr->send_cq);
548 548
549 if (!cqe && !cqe_skb) 549 if (!cqe && !cqe_skb)
550 return 0; 550 return 0;
551 551
552 if (!netif_rx_reschedule(dev, dev->quota)) 552 if (!netif_rx_reschedule(dev, dev->quota))
553 return 0; 553 return 0;
554 } 554 }
555 555
556 cqe = ehea_proc_rwqes(dev, pr, budget); 556 cqe = ehea_proc_rwqes(dev, pr, budget);
557 cqe_skb = ehea_proc_cqes(pr, 300); 557 cqe_skb = ehea_proc_cqes(pr, 300);
558 558
559 if (cqe || cqe_skb) 559 if (cqe || cqe_skb)
560 pr->poll_counter++; 560 pr->poll_counter++;
561 561
562 return 1; 562 return 1;
563} 563}
564 564
@@ -1011,7 +1011,7 @@ static int ehea_configure_port(struct ehea_port *port)
1011 else 1011 else
1012 cb0->default_qpn_arr[i] = 1012 cb0->default_qpn_arr[i] =
1013 port->port_res[0].qp->init_attr.qp_nr; 1013 port->port_res[0].qp->init_attr.qp_nr;
1014 1014
1015 if (netif_msg_ifup(port)) 1015 if (netif_msg_ifup(port))
1016 ehea_dump(cb0, sizeof(*cb0), "ehea_configure_port"); 1016 ehea_dump(cb0, sizeof(*cb0), "ehea_configure_port");
1017 1017
@@ -1033,52 +1033,35 @@ out:
1033 return ret; 1033 return ret;
1034} 1034}
1035 1035
1036static int ehea_gen_smrs(struct ehea_port_res *pr) 1036int ehea_gen_smrs(struct ehea_port_res *pr)
1037{ 1037{
1038 u64 hret; 1038 int ret;
1039 struct ehea_adapter *adapter = pr->port->adapter; 1039 struct ehea_adapter *adapter = pr->port->adapter;
1040 1040
1041 hret = ehea_h_register_smr(adapter->handle, adapter->mr.handle, 1041 ret = ehea_gen_smr(adapter, &adapter->mr, &pr->send_mr);
1042 adapter->mr.vaddr, EHEA_MR_ACC_CTRL, 1042 if (ret)
1043 adapter->pd, &pr->send_mr);
1044 if (hret != H_SUCCESS)
1045 goto out; 1043 goto out;
1046 1044
1047 hret = ehea_h_register_smr(adapter->handle, adapter->mr.handle, 1045 ret = ehea_gen_smr(adapter, &adapter->mr, &pr->recv_mr);
1048 adapter->mr.vaddr, EHEA_MR_ACC_CTRL, 1046 if (ret)
1049 adapter->pd, &pr->recv_mr); 1047 goto out_free;
1050 if (hret != H_SUCCESS)
1051 goto out_freeres;
1052 1048
1053 return 0; 1049 return 0;
1054 1050
1055out_freeres: 1051out_free:
1056 hret = ehea_h_free_resource(adapter->handle, pr->send_mr.handle); 1052 ehea_rem_mr(&pr->send_mr);
1057 if (hret != H_SUCCESS)
1058 ehea_error("failed freeing SMR");
1059out: 1053out:
1054 ehea_error("Generating SMRS failed\n");
1060 return -EIO; 1055 return -EIO;
1061} 1056}
1062 1057
1063static int ehea_rem_smrs(struct ehea_port_res *pr) 1058int ehea_rem_smrs(struct ehea_port_res *pr)
1064{ 1059{
1065 struct ehea_adapter *adapter = pr->port->adapter; 1060 if ((ehea_rem_mr(&pr->send_mr))
1066 int ret = 0; 1061 || (ehea_rem_mr(&pr->recv_mr)))
1067 u64 hret; 1062 return -EIO;
1068 1063 else
1069 hret = ehea_h_free_resource(adapter->handle, pr->send_mr.handle); 1064 return 0;
1070 if (hret != H_SUCCESS) {
1071 ret = -EIO;
1072 ehea_error("failed freeing send SMR for pr=%p", pr);
1073 }
1074
1075 hret = ehea_h_free_resource(adapter->handle, pr->recv_mr.handle);
1076 if (hret != H_SUCCESS) {
1077 ret = -EIO;
1078 ehea_error("failed freeing recv SMR for pr=%p", pr);
1079 }
1080
1081 return ret;
1082} 1065}
1083 1066
1084static int ehea_init_q_skba(struct ehea_q_skb_arr *q_skba, int max_q_entries) 1067static int ehea_init_q_skba(struct ehea_q_skb_arr *q_skba, int max_q_entries)
@@ -2243,7 +2226,7 @@ static int ehea_down(struct net_device *dev)
2243 ehea_free_interrupts(dev); 2226 ehea_free_interrupts(dev);
2244 2227
2245 for (i = 0; i < port->num_def_qps; i++) 2228 for (i = 0; i < port->num_def_qps; i++)
2246 while (test_bit(__LINK_STATE_RX_SCHED, 2229 while (test_bit(__LINK_STATE_RX_SCHED,
2247 &port->port_res[i].d_netdev->state)) 2230 &port->port_res[i].d_netdev->state))
2248 msleep(1); 2231 msleep(1);
2249 2232
@@ -2418,7 +2401,7 @@ static struct device *ehea_register_port(struct ehea_port *port,
2418 ehea_error("failed to register attributes, ret=%d", ret); 2401 ehea_error("failed to register attributes, ret=%d", ret);
2419 goto out_unreg_of_dev; 2402 goto out_unreg_of_dev;
2420 } 2403 }
2421 2404
2422 return &port->ofdev.dev; 2405 return &port->ofdev.dev;
2423 2406
2424out_unreg_of_dev: 2407out_unreg_of_dev:
@@ -2517,7 +2500,7 @@ struct ehea_port *ehea_setup_single_port(struct ehea_adapter *adapter,
2517 } 2500 }
2518 2501
2519 ret = ehea_get_jumboframe_status(port, &jumbo); 2502 ret = ehea_get_jumboframe_status(port, &jumbo);
2520 if (ret) 2503 if (ret)
2521 ehea_error("failed determining jumbo frame status for %s", 2504 ehea_error("failed determining jumbo frame status for %s",
2522 port->netdev->name); 2505 port->netdev->name);
2523 2506
@@ -2560,7 +2543,7 @@ static int ehea_setup_ports(struct ehea_adapter *adapter)
2560 2543
2561 lhea_dn = adapter->ebus_dev->ofdev.node; 2544 lhea_dn = adapter->ebus_dev->ofdev.node;
2562 while ((eth_dn = of_get_next_child(lhea_dn, eth_dn))) { 2545 while ((eth_dn = of_get_next_child(lhea_dn, eth_dn))) {
2563 2546
2564 dn_log_port_id = (u32*)get_property(eth_dn, "ibm,hea-port-no", 2547 dn_log_port_id = (u32*)get_property(eth_dn, "ibm,hea-port-no",
2565 NULL); 2548 NULL);
2566 if (!dn_log_port_id) { 2549 if (!dn_log_port_id) {
@@ -2574,7 +2557,7 @@ static int ehea_setup_ports(struct ehea_adapter *adapter)
2574 eth_dn); 2557 eth_dn);
2575 if (adapter->port[i]) 2558 if (adapter->port[i])
2576 ehea_info("%s -> logical port id #%d", 2559 ehea_info("%s -> logical port id #%d",
2577 adapter->port[i]->netdev->name, 2560 adapter->port[i]->netdev->name,
2578 *dn_log_port_id); 2561 *dn_log_port_id);
2579 i++; 2562 i++;
2580 }; 2563 };
@@ -2590,8 +2573,8 @@ static int ehea_setup_ports(struct ehea_adapter *adapter)
2590 return -EINVAL; 2573 return -EINVAL;
2591} 2574}
2592 2575
2593static struct device_node *ehea_get_eth_dn(struct ehea_adapter *adapter, 2576static struct device_node *ehea_get_eth_dn(struct ehea_adapter *adapter,
2594 u32 logical_port_id) 2577 u32 logical_port_id)
2595{ 2578{
2596 struct device_node *lhea_dn; 2579 struct device_node *lhea_dn;
2597 struct device_node *eth_dn = NULL; 2580 struct device_node *eth_dn = NULL;
@@ -2599,7 +2582,7 @@ static struct device_node *ehea_get_eth_dn(struct ehea_adapter *adapter,
2599 2582
2600 lhea_dn = adapter->ebus_dev->ofdev.node; 2583 lhea_dn = adapter->ebus_dev->ofdev.node;
2601 while ((eth_dn = of_get_next_child(lhea_dn, eth_dn))) { 2584 while ((eth_dn = of_get_next_child(lhea_dn, eth_dn))) {
2602 2585
2603 dn_log_port_id = (u32*)get_property(eth_dn, "ibm,hea-port-no", 2586 dn_log_port_id = (u32*)get_property(eth_dn, "ibm,hea-port-no",
2604 NULL); 2587 NULL);
2605 if (dn_log_port_id) 2588 if (dn_log_port_id)
@@ -2631,14 +2614,14 @@ static ssize_t ehea_probe_port(struct device *dev,
2631 port->netdev->name); 2614 port->netdev->name);
2632 return -EINVAL; 2615 return -EINVAL;
2633 } 2616 }
2634 2617
2635 eth_dn = ehea_get_eth_dn(adapter, logical_port_id); 2618 eth_dn = ehea_get_eth_dn(adapter, logical_port_id);
2636 2619
2637 if (!eth_dn) { 2620 if (!eth_dn) {
2638 ehea_info("no logical port with id %d found", logical_port_id); 2621 ehea_info("no logical port with id %d found", logical_port_id);
2639 return -EINVAL; 2622 return -EINVAL;
2640 } 2623 }
2641 2624
2642 port = ehea_setup_single_port(adapter, logical_port_id, eth_dn); 2625 port = ehea_setup_single_port(adapter, logical_port_id, eth_dn);
2643 2626
2644 of_node_put(eth_dn); 2627 of_node_put(eth_dn);
@@ -2652,8 +2635,8 @@ static ssize_t ehea_probe_port(struct device *dev,
2652 2635
2653 ehea_info("added %s (logical port id=%d)", port->netdev->name, 2636 ehea_info("added %s (logical port id=%d)", port->netdev->name,
2654 logical_port_id); 2637 logical_port_id);
2655 } else 2638 } else
2656 return -EIO; 2639 return -EIO;
2657 2640
2658 return (ssize_t) count; 2641 return (ssize_t) count;
2659} 2642}
@@ -2748,7 +2731,7 @@ static int __devinit ehea_probe_adapter(struct ibmebus_dev *dev,
2748 2731
2749 dev->ofdev.dev.driver_data = adapter; 2732 dev->ofdev.dev.driver_data = adapter;
2750 2733
2751 ret = ehea_reg_mr_adapter(adapter); 2734 ret = ehea_reg_kernel_mr(adapter, &adapter->mr);
2752 if (ret) { 2735 if (ret) {
2753 dev_err(&dev->ofdev.dev, "reg_mr_adapter failed\n"); 2736 dev_err(&dev->ofdev.dev, "reg_mr_adapter failed\n");
2754 goto out_free_ad; 2737 goto out_free_ad;
@@ -2813,7 +2796,7 @@ out_kill_eq:
2813 ehea_destroy_eq(adapter->neq); 2796 ehea_destroy_eq(adapter->neq);
2814 2797
2815out_free_res: 2798out_free_res:
2816 ehea_h_free_resource(adapter->handle, adapter->mr.handle); 2799 ehea_rem_mr(&adapter->mr);
2817 2800
2818out_free_ad: 2801out_free_ad:
2819 kfree(adapter); 2802 kfree(adapter);
@@ -2824,7 +2807,6 @@ out:
2824static int __devexit ehea_remove(struct ibmebus_dev *dev) 2807static int __devexit ehea_remove(struct ibmebus_dev *dev)
2825{ 2808{
2826 struct ehea_adapter *adapter = dev->ofdev.dev.driver_data; 2809 struct ehea_adapter *adapter = dev->ofdev.dev.driver_data;
2827 u64 hret;
2828 int i; 2810 int i;
2829 2811
2830 for (i = 0; i < EHEA_MAX_PORTS; i++) 2812 for (i = 0; i < EHEA_MAX_PORTS; i++)
@@ -2841,12 +2823,7 @@ static int __devexit ehea_remove(struct ibmebus_dev *dev)
2841 tasklet_kill(&adapter->neq_tasklet); 2823 tasklet_kill(&adapter->neq_tasklet);
2842 2824
2843 ehea_destroy_eq(adapter->neq); 2825 ehea_destroy_eq(adapter->neq);
2844 2826 ehea_rem_mr(&adapter->mr);
2845 hret = ehea_h_free_resource(adapter->handle, adapter->mr.handle);
2846 if (hret) {
2847 dev_err(&dev->ofdev.dev, "free_resource_mr failed");
2848 return -EIO;
2849 }
2850 kfree(adapter); 2827 kfree(adapter);
2851 return 0; 2828 return 0;
2852} 2829}