diff options
| -rw-r--r-- | drivers/net/ethernet/freescale/gianfar.c | 202 | ||||
| -rw-r--r-- | drivers/net/ethernet/freescale/gianfar.h | 32 |
2 files changed, 138 insertions, 96 deletions
diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c index 7bf3682cdf47..70fa6887f940 100644 --- a/drivers/net/ethernet/freescale/gianfar.c +++ b/drivers/net/ethernet/freescale/gianfar.c | |||
| @@ -158,7 +158,7 @@ static void gfar_init_rxbdp(struct gfar_priv_rx_q *rx_queue, struct rxbd8 *bdp, | |||
| 158 | { | 158 | { |
| 159 | u32 lstatus; | 159 | u32 lstatus; |
| 160 | 160 | ||
| 161 | bdp->bufPtr = buf; | 161 | bdp->bufPtr = cpu_to_be32(buf); |
| 162 | 162 | ||
| 163 | lstatus = BD_LFLAG(RXBD_EMPTY | RXBD_INTERRUPT); | 163 | lstatus = BD_LFLAG(RXBD_EMPTY | RXBD_INTERRUPT); |
| 164 | if (bdp == rx_queue->rx_bd_base + rx_queue->rx_ring_size - 1) | 164 | if (bdp == rx_queue->rx_bd_base + rx_queue->rx_ring_size - 1) |
| @@ -166,7 +166,7 @@ static void gfar_init_rxbdp(struct gfar_priv_rx_q *rx_queue, struct rxbd8 *bdp, | |||
| 166 | 166 | ||
| 167 | gfar_wmb(); | 167 | gfar_wmb(); |
| 168 | 168 | ||
| 169 | bdp->lstatus = lstatus; | 169 | bdp->lstatus = cpu_to_be32(lstatus); |
| 170 | } | 170 | } |
| 171 | 171 | ||
| 172 | static int gfar_init_bds(struct net_device *ndev) | 172 | static int gfar_init_bds(struct net_device *ndev) |
| @@ -200,7 +200,8 @@ static int gfar_init_bds(struct net_device *ndev) | |||
| 200 | 200 | ||
| 201 | /* Set the last descriptor in the ring to indicate wrap */ | 201 | /* Set the last descriptor in the ring to indicate wrap */ |
| 202 | txbdp--; | 202 | txbdp--; |
| 203 | txbdp->status |= TXBD_WRAP; | 203 | txbdp->status = cpu_to_be16(be16_to_cpu(txbdp->status) | |
| 204 | TXBD_WRAP); | ||
| 204 | } | 205 | } |
| 205 | 206 | ||
| 206 | rfbptr = ®s->rfbptr0; | 207 | rfbptr = ®s->rfbptr0; |
| @@ -214,7 +215,7 @@ static int gfar_init_bds(struct net_device *ndev) | |||
| 214 | struct sk_buff *skb = rx_queue->rx_skbuff[j]; | 215 | struct sk_buff *skb = rx_queue->rx_skbuff[j]; |
| 215 | 216 | ||
| 216 | if (skb) { | 217 | if (skb) { |
| 217 | bufaddr = rxbdp->bufPtr; | 218 | bufaddr = be32_to_cpu(rxbdp->bufPtr); |
| 218 | } else { | 219 | } else { |
| 219 | skb = gfar_new_skb(ndev, &bufaddr); | 220 | skb = gfar_new_skb(ndev, &bufaddr); |
| 220 | if (!skb) { | 221 | if (!skb) { |
| @@ -696,19 +697,28 @@ static int gfar_parse_group(struct device_node *np, | |||
| 696 | grp->priv = priv; | 697 | grp->priv = priv; |
| 697 | spin_lock_init(&grp->grplock); | 698 | spin_lock_init(&grp->grplock); |
| 698 | if (priv->mode == MQ_MG_MODE) { | 699 | if (priv->mode == MQ_MG_MODE) { |
| 699 | u32 *rxq_mask, *txq_mask; | 700 | u32 rxq_mask, txq_mask; |
| 700 | rxq_mask = (u32 *)of_get_property(np, "fsl,rx-bit-map", NULL); | 701 | int ret; |
| 701 | txq_mask = (u32 *)of_get_property(np, "fsl,tx-bit-map", NULL); | 702 | |
| 703 | grp->rx_bit_map = (DEFAULT_MAPPING >> priv->num_grps); | ||
| 704 | grp->tx_bit_map = (DEFAULT_MAPPING >> priv->num_grps); | ||
| 705 | |||
| 706 | ret = of_property_read_u32(np, "fsl,rx-bit-map", &rxq_mask); | ||
| 707 | if (!ret) { | ||
| 708 | grp->rx_bit_map = rxq_mask ? | ||
| 709 | rxq_mask : (DEFAULT_MAPPING >> priv->num_grps); | ||
| 710 | } | ||
| 711 | |||
| 712 | ret = of_property_read_u32(np, "fsl,tx-bit-map", &txq_mask); | ||
| 713 | if (!ret) { | ||
| 714 | grp->tx_bit_map = txq_mask ? | ||
| 715 | txq_mask : (DEFAULT_MAPPING >> priv->num_grps); | ||
| 716 | } | ||
| 702 | 717 | ||
| 703 | if (priv->poll_mode == GFAR_SQ_POLLING) { | 718 | if (priv->poll_mode == GFAR_SQ_POLLING) { |
| 704 | /* One Q per interrupt group: Q0 to G0, Q1 to G1 */ | 719 | /* One Q per interrupt group: Q0 to G0, Q1 to G1 */ |
| 705 | grp->rx_bit_map = (DEFAULT_MAPPING >> priv->num_grps); | 720 | grp->rx_bit_map = (DEFAULT_MAPPING >> priv->num_grps); |
| 706 | grp->tx_bit_map = (DEFAULT_MAPPING >> priv->num_grps); | 721 | grp->tx_bit_map = (DEFAULT_MAPPING >> priv->num_grps); |
| 707 | } else { /* GFAR_MQ_POLLING */ | ||
| 708 | grp->rx_bit_map = rxq_mask ? | ||
| 709 | *rxq_mask : (DEFAULT_MAPPING >> priv->num_grps); | ||
| 710 | grp->tx_bit_map = txq_mask ? | ||
| 711 | *txq_mask : (DEFAULT_MAPPING >> priv->num_grps); | ||
| 712 | } | 722 | } |
| 713 | } else { | 723 | } else { |
| 714 | grp->rx_bit_map = 0xFF; | 724 | grp->rx_bit_map = 0xFF; |
| @@ -769,11 +779,10 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev) | |||
| 769 | struct gfar_private *priv = NULL; | 779 | struct gfar_private *priv = NULL; |
| 770 | struct device_node *np = ofdev->dev.of_node; | 780 | struct device_node *np = ofdev->dev.of_node; |
| 771 | struct device_node *child = NULL; | 781 | struct device_node *child = NULL; |
| 772 | const u32 *stash; | 782 | struct property *stash; |
| 773 | const u32 *stash_len; | 783 | u32 stash_len = 0; |
| 774 | const u32 *stash_idx; | 784 | u32 stash_idx = 0; |
| 775 | unsigned int num_tx_qs, num_rx_qs; | 785 | unsigned int num_tx_qs, num_rx_qs; |
| 776 | u32 *tx_queues, *rx_queues; | ||
| 777 | unsigned short mode, poll_mode; | 786 | unsigned short mode, poll_mode; |
| 778 | 787 | ||
| 779 | if (!np) | 788 | if (!np) |
| @@ -787,10 +796,6 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev) | |||
| 787 | poll_mode = GFAR_SQ_POLLING; | 796 | poll_mode = GFAR_SQ_POLLING; |
| 788 | } | 797 | } |
| 789 | 798 | ||
| 790 | /* parse the num of HW tx and rx queues */ | ||
| 791 | tx_queues = (u32 *)of_get_property(np, "fsl,num_tx_queues", NULL); | ||
| 792 | rx_queues = (u32 *)of_get_property(np, "fsl,num_rx_queues", NULL); | ||
| 793 | |||
| 794 | if (mode == SQ_SG_MODE) { | 799 | if (mode == SQ_SG_MODE) { |
| 795 | num_tx_qs = 1; | 800 | num_tx_qs = 1; |
| 796 | num_rx_qs = 1; | 801 | num_rx_qs = 1; |
| @@ -809,8 +814,17 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev) | |||
| 809 | num_tx_qs = num_grps; /* one txq per int group */ | 814 | num_tx_qs = num_grps; /* one txq per int group */ |
| 810 | num_rx_qs = num_grps; /* one rxq per int group */ | 815 | num_rx_qs = num_grps; /* one rxq per int group */ |
| 811 | } else { /* GFAR_MQ_POLLING */ | 816 | } else { /* GFAR_MQ_POLLING */ |
| 812 | num_tx_qs = tx_queues ? *tx_queues : 1; | 817 | u32 tx_queues, rx_queues; |
| 813 | num_rx_qs = rx_queues ? *rx_queues : 1; | 818 | int ret; |
| 819 | |||
| 820 | /* parse the num of HW tx and rx queues */ | ||
| 821 | ret = of_property_read_u32(np, "fsl,num_tx_queues", | ||
| 822 | &tx_queues); | ||
| 823 | num_tx_qs = ret ? 1 : tx_queues; | ||
| 824 | |||
| 825 | ret = of_property_read_u32(np, "fsl,num_rx_queues", | ||
| 826 | &rx_queues); | ||
| 827 | num_rx_qs = ret ? 1 : rx_queues; | ||
| 814 | } | 828 | } |
| 815 | } | 829 | } |
| 816 | 830 | ||
| @@ -851,13 +865,17 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev) | |||
| 851 | if (err) | 865 | if (err) |
| 852 | goto rx_alloc_failed; | 866 | goto rx_alloc_failed; |
| 853 | 867 | ||
| 868 | err = of_property_read_string(np, "model", &model); | ||
| 869 | if (err) { | ||
| 870 | pr_err("Device model property missing, aborting\n"); | ||
| 871 | goto rx_alloc_failed; | ||
| 872 | } | ||
| 873 | |||
| 854 | /* Init Rx queue filer rule set linked list */ | 874 | /* Init Rx queue filer rule set linked list */ |
| 855 | INIT_LIST_HEAD(&priv->rx_list.list); | 875 | INIT_LIST_HEAD(&priv->rx_list.list); |
| 856 | priv->rx_list.count = 0; | 876 | priv->rx_list.count = 0; |
| 857 | mutex_init(&priv->rx_queue_access); | 877 | mutex_init(&priv->rx_queue_access); |
| 858 | 878 | ||
| 859 | model = of_get_property(np, "model", NULL); | ||
| 860 | |||
| 861 | for (i = 0; i < MAXGROUPS; i++) | 879 | for (i = 0; i < MAXGROUPS; i++) |
| 862 | priv->gfargrp[i].regs = NULL; | 880 | priv->gfargrp[i].regs = NULL; |
| 863 | 881 | ||
| @@ -877,22 +895,22 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev) | |||
| 877 | goto err_grp_init; | 895 | goto err_grp_init; |
| 878 | } | 896 | } |
| 879 | 897 | ||
| 880 | stash = of_get_property(np, "bd-stash", NULL); | 898 | stash = of_find_property(np, "bd-stash", NULL); |
| 881 | 899 | ||
| 882 | if (stash) { | 900 | if (stash) { |
| 883 | priv->device_flags |= FSL_GIANFAR_DEV_HAS_BD_STASHING; | 901 | priv->device_flags |= FSL_GIANFAR_DEV_HAS_BD_STASHING; |
| 884 | priv->bd_stash_en = 1; | 902 | priv->bd_stash_en = 1; |
| 885 | } | 903 | } |
