History

Merge branch 'gianfar-next'

Claudiu Manoil says: ==================== gianfar: ARM port driver updates (2/2) The 2nd round of driver updates to make gianfar portable on ARM, for the ARM based SoC that integrates eTSEC - "ls1021a". The patches address the bulk of remaining endianess issues - handling DMA fields (BD and FCB), and device tree properties. ====================

David S. Miller committed 11 years ago

Commit 12028822 parents 5a2f78d 55917642 files · +138 −96Browse files

Unified · Split

2 files
  1. drivers/net/ethernet/freescale/gianfar.c +118 −84
  2. drivers/net/ethernet/freescale/gianfar.h +20 −12
drivers/net/ethernet/freescale/gianfar.c+118−84
@@ -158,7 +158,7 @@ static void gfar_init_rxbdp(struct gfar_priv_rx_q *rx_queue, struct rxbd8 *bdp, · 157 unmodified lines
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, · 1 unmodified line
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
172static int gfar_init_bds(struct net_device *ndev)172static int gfar_init_bds(struct net_device *ndev)
@@ -200,7 +200,8 @@ static int gfar_init_bds(struct net_device *ndev) · 27 unmodified lines
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 = &regs->rfbptr0;207 rfbptr = &regs->rfbptr0;
@@ -214,7 +215,7 @@ static int gfar_init_bds(struct net_device *ndev) · 7 unmodified lines
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, · 475 unmodified lines
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) · 54 unmodified lines
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) · 7 unmodified lines
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) · 12 unmodified lines
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) · 34 unmodified lines
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) · 13 unmodified lines
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 }
886 904
887 stash_len = of_get_property(np, "rx-stash-len", NULL);905 err = of_property_read_u32(np, "rx-stash-len", &stash_len);
888 906
889 if (stash_len)907 if (err == 0)
890 priv->rx_stash_size = *stash_len;908 priv->rx_stash_size = stash_len;
891 909
892 stash_idx = of_get_property(np, "rx-stash-idx", NULL);910 err = of_property_read_u32(np, "rx-stash-idx", &stash_idx);
893 911
894 if (stash_idx)912 if (err == 0)
895 priv->rx_stash_index = *stash_idx;913 priv->rx_stash_index = stash_idx;
896 914
897 if (stash_len || stash_idx)915 if (stash_len || stash_idx)
898 priv->device_flags |= FSL_GIANFAR_DEV_HAS_BUF_STASHING;916 priv->device_flags |= FSL_GIANFAR_DEV_HAS_BUF_STASHING;
@@ -919,15 +937,15 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev) · 20 unmodified lines
919 FSL_GIANFAR_DEV_HAS_EXTENDED_HASH |937 FSL_GIANFAR_DEV_HAS_EXTENDED_HASH |
920 FSL_GIANFAR_DEV_HAS_TIMER;938 FSL_GIANFAR_DEV_HAS_TIMER;
921 939
922 ctype = of_get_property(np, "phy-connection-type", NULL);940 err = of_property_read_string(np, "phy-connection-type", &ctype);
923 941
924 /* We only care about rgmii-id. The rest are autodetected */942 /* We only care about rgmii-id. The rest are autodetected */
925 if (ctype && !strcmp(ctype, "rgmii-id"))943 if (err == 0 && !strcmp(ctype, "rgmii-id"))
926 priv->interface = PHY_INTERFACE_MODE_RGMII_ID;944 priv->interface = PHY_INTERFACE_MODE_RGMII_ID;
927 else945 else
928 priv->interface = PHY_INTERFACE_MODE_MII;946 priv->interface = PHY_INTERFACE_MODE_MII;
929 947
930 if (of_get_property(np, "fsl,magic-packet", NULL))948 if (of_find_property(np, "fsl,magic-packet", NULL))
931 priv->device_flags |= FSL_GIANFAR_DEV_HAS_MAGIC_PACKET;949 priv->device_flags |= FSL_GIANFAR_DEV_HAS_MAGIC_PACKET;
932 950
933 priv->phy_node = of_parse_phandle(np, "phy-handle", 0);951 priv->phy_node = of_parse_phandle(np, "phy-handle", 0);
@@ -1884,14 +1902,15 @@ static void free_skb_tx_queue(struct gfar_priv_tx_q *tx_queue) · 950 unmodified lines
1884 if (!tx_queue->tx_skbuff[i])1902 if (!tx_queue->tx_skbuff[i])
1885 continue;1903 continue;
1886 1904
1887 dma_unmap_single(priv->dev, txbdp->bufPtr,1905 dma_unmap_single(priv->dev, be32_to_cpu(txbdp->bufPtr),
1888 txbdp->length, DMA_TO_DEVICE);1906 be16_to_cpu(txbdp->length), DMA_TO_DEVICE);
1889 txbdp->lstatus = 0;1907 txbdp->lstatus = 0;
1890 for (j = 0; j < skb_shinfo(tx_queue->tx_skbuff[i])->nr_frags;1908 for (j = 0; j < skb_shinfo(tx_queue->tx_skbuff[i])->nr_frags;
1891 j++) {1909 j++) {
1892 txbdp++;1910 txbdp++;
1893 dma_unmap_page(priv->dev, txbdp->bufPtr,1911 dma_unmap_page(priv->dev, be32_to_cpu(txbdp->bufPtr),
1894 txbdp->length, DMA_TO_DEVICE);1912 be16_to_cpu(txbdp->length),
1913 DMA_TO_DEVICE);
1895 }1914 }
1896 txbdp++;1915 txbdp++;
1897 dev_kfree_skb_any(tx_queue->tx_skbuff[i]);1916 dev_kfree_skb_any(tx_queue->tx_skbuff[i]);
@@ -1911,7 +1930,7 @@ static void free_skb_rx_queue(struct gfar_priv_rx_q *rx_queue) · 13 unmodified lines
1911 1930
1912 for (i = 0; i < rx_queue->rx_ring_size; i++) {1931 for (i = 0; i < rx_queue->rx_ring_size; i++) {
1913 if (rx_queue->rx_skbuff[i]) {1932 if (rx_queue->rx_skbuff[i]) {
1914 dma_unmap_single(priv->dev, rxbdp->bufPtr,1933 dma_unmap_single(priv->dev, be32_to_cpu(rxbdp->bufPtr),
1915 priv->rx_buffer_size,1934 priv->rx_buffer_size,
1916 DMA_FROM_DEVICE);1935 DMA_FROM_DEVICE);
1917 dev_kfree_skb_any(rx_queue->rx_skbuff[i]);1936 dev_kfree_skb_any(rx_queue->rx_skbuff[i]);
@@ -2167,16 +2186,16 @@ static inline void gfar_tx_checksum(struct sk_buff *skb, struct txfcb *fcb, · 249 unmodified lines
2167 */2186 */
2168 if (ip_hdr(skb)->protocol == IPPROTO_UDP) {2187 if (ip_hdr(skb)->protocol == IPPROTO_UDP) {
2169 flags |= TXFCB_UDP;2188 flags |= TXFCB_UDP;
2170 fcb->phcs = udp_hdr(skb)->check;2189 fcb->phcs = (__force __be16)(udp_hdr(skb)->check);
2171 } else2190 } else
2172 fcb->phcs = tcp_hdr(skb)->check;2191 fcb->phcs = (__force __be16)(tcp_hdr(skb)->check);
2173 2192
2174 /* l3os is the distance between the start of the2193 /* l3os is the distance between the start of the
2175 * frame (skb->data) and the start of the IP hdr.2194 * frame (skb->data) and the start of the IP hdr.
2176 * l4os is the distance between the start of the2195 * l4os is the distance between the start of the
2177 * l3 hdr and the l4 hdr2196 * l3 hdr and the l4 hdr
2178 */2197 */
2179 fcb->l3os = (u16)(skb_network_offset(skb) - fcb_length);2198 fcb->l3os = (u8)(skb_network_offset(skb) - fcb_length);
2180 fcb->l4os = skb_network_header_len(skb);2199 fcb->l4os = skb_network_header_len(skb);
2181 2200
2182 fcb->flags = flags;2201 fcb->flags = flags;
@@ -2185,7 +2204,7 @@ static inline void gfar_tx_checksum(struct sk_buff *skb, struct txfcb *fcb, · 2 unmodified lines
2185void inline gfar_tx_vlan(struct sk_buff *skb, struct txfcb *fcb)2204void inline gfar_tx_vlan(struct sk_buff *skb, struct txfcb *fcb)
2186{2205{
2187 fcb->flags |= TXFCB_VLN;2206 fcb->flags |= TXFCB_VLN;
2188 fcb->vlctl = skb_vlan_tag_get(skb);2207 fcb->vlctl = cpu_to_be16(skb_vlan_tag_get(skb));
2189}2208}
2190 2209
2191static inline struct txbd8 *skip_txbd(struct txbd8 *bdp, int stride,2210static inline struct txbd8 *skip_txbd(struct txbd8 *bdp, int stride,
@@ -2298,7 +2317,7 @@ static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev) · 106 unmodified lines
2298 tx_queue->stats.tx_packets++;2317 tx_queue->stats.tx_packets++;
2299 2318
2300 txbdp = txbdp_start = tx_queue->cur_tx;2319 txbdp = txbdp_start = tx_queue->cur_tx;
2301 lstatus = txbdp->lstatus;2320 lstatus = be32_to_cpu(txbdp->lstatus);
2302 2321
2303 /* Time stamp insertion requires one additional TxBD */2322 /* Time stamp insertion requires one additional TxBD */
2304 if (unlikely(do_tstamp))2323 if (unlikely(do_tstamp))
@@ -2306,11 +2325,14 @@ static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev) · 1 unmodified line
2306 tx_queue->tx_ring_size);2325 tx_queue->tx_ring_size);
2307 2326
2308 if (nr_frags == 0) {2327 if (nr_frags == 0) {
2309 if (unlikely(do_tstamp))2328 if (unlikely(do_tstamp)) {
2310 txbdp_tstamp->lstatus |= BD_LFLAG(TXBD_LAST |2329 u32 lstatus_ts = be32_to_cpu(txbdp_tstamp->lstatus);
2311 TXBD_INTERRUPT);2330
2312 else2331 lstatus_ts |= BD_LFLAG(TXBD_LAST | TXBD_INTERRUPT);
2332 txbdp_tstamp->lstatus = cpu_to_be32(lstatus_ts);
2333 } else {
2313 lstatus |= BD_LFLAG(TXBD_LAST | TXBD_INTERRUPT);2334 lstatus |= BD_LFLAG(TXBD_LAST | TXBD_INTERRUPT);
2335 }
2314 } else {2336 } else {
2315 /* Place the fragment addresses and lengths into the TxBDs */2337 /* Place the fragment addresses and lengths into the TxBDs */
2316 for (i = 0; i < nr_frags; i++) {2338 for (i = 0; i < nr_frags; i++) {
@@ -2320,7 +2342,7 @@ static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev) · 3 unmodified lines
2320 2342
2321 frag_len = skb_shinfo(skb)->frags[i].size;2343 frag_len = skb_shinfo(skb)->frags[i].size;
2322 2344
2323 lstatus = txbdp->lstatus | frag_len |2345 lstatus = be32_to_cpu(txbdp->lstatus) | frag_len |
2324 BD_LFLAG(TXBD_READY);2346 BD_LFLAG(TXBD_READY);
2325 2347
2326 /* Handle the last BD specially */2348 /* Handle the last BD specially */
@@ -2336,11 +2358,11 @@ static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev) · 9 unmodified lines
2336 goto dma_map_err;2358 goto dma_map_err;
2337 2359
2338 /* set the TxBD length and buffer pointer */2360 /* set the TxBD length and buffer pointer */
2339 txbdp->bufPtr = bufaddr;2361 txbdp->bufPtr = cpu_to_be32(bufaddr);
2340 txbdp->lstatus = lstatus;2362 txbdp->lstatus = cpu_to_be32(lstatus);
2341 }2363 }
2342 2364
2343 lstatus = txbdp_start->lstatus;2365 lstatus = be32_to_cpu(txbdp_start->lstatus);
2344 }2366 }
2345 2367
2346 /* Add TxPAL between FCB and frame if required */2368 /* Add TxPAL between FCB and frame if required */
@@ -2388,7 +2410,7 @@ static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev) · 41 unmodified lines
2388 if (unlikely(dma_mapping_error(priv->dev, bufaddr)))2410 if (unlikely(dma_mapping_error(priv->dev, bufaddr)))
2389 goto dma_map_err;2411 goto dma_map_err;
2390 2412
2391 txbdp_start->bufPtr = bufaddr;2413 txbdp_start->bufPtr = cpu_to_be32(bufaddr);
2392 2414
2393 /* If time stamping is requested one additional TxBD must be set up. The2415 /* If time stamping is requested one additional TxBD must be set up. The
2394 * first TxBD points to the FCB and must have a data length of2416 * first TxBD points to the FCB and must have a data length of
@@ -2396,9 +2418,15 @@ static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev) · 1 unmodified line
2396 * the full frame length.2418 * the full frame length.
2397 */2419 */
2398 if (unlikely(do_tstamp)) {2420 if (unlikely(do_tstamp)) {
2399 txbdp_tstamp->bufPtr = txbdp_start->bufPtr + fcb_len;2421 u32 lstatus_ts = be32_to_cpu(txbdp_tstamp->lstatus);
2400 txbdp_tstamp->lstatus |= BD_LFLAG(TXBD_READY) |2422
2401 (skb_headlen(skb) - fcb_len);2423 bufaddr = be32_to_cpu(txbdp_start->bufPtr);
2424 bufaddr += fcb_len;
2425 lstatus_ts |= BD_LFLAG(TXBD_READY) |
2426 (skb_headlen(skb) - fcb_len);
2427
2428 txbdp_tstamp->bufPtr = cpu_to_be32(bufaddr);
2429 txbdp_tstamp->lstatus = cpu_to_be32(lstatus_ts);
2402 lstatus |= BD_LFLAG(TXBD_CRC | TXBD_READY) | GMAC_FCB_LEN;2430 lstatus |= BD_LFLAG(TXBD_CRC | TXBD_READY) | GMAC_FCB_LEN;
2403 } else {2431 } else {
2404 lstatus |= BD_LFLAG(TXBD_CRC | TXBD_READY) | skb_headlen(skb);2432 lstatus |= BD_LFLAG(TXBD_CRC | TXBD_READY) | skb_headlen(skb);
@@ -2421,7 +2449,7 @@ static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev) · 16 unmodified lines
2421 2449
2422 gfar_wmb();2450 gfar_wmb();
2423 2451
2424 txbdp_start->lstatus = lstatus;2452 txbdp_start->lstatus = cpu_to_be32(lstatus);
2425 2453
2426 gfar_wmb(); /* force lstatus write before tx_skbuff */2454 gfar_wmb(); /* force lstatus write before tx_skbuff */
2427 2455
@@ -2460,13 +2488,14 @@ dma_map_err: · 32 unmodified lines
2460 if (do_tstamp)2488 if (do_tstamp)
2461 txbdp = next_txbd(txbdp, base, tx_queue->tx_ring_size);2489 txbdp = next_txbd(txbdp, base, tx_queue->tx_ring_size);
2462 for (i = 0; i < nr_frags; i++) {2490 for (i = 0; i < nr_frags; i++) {
2463 lstatus = txbdp->lstatus;2491 lstatus = be32_to_cpu(txbdp->lstatus);
2464 if (!(lstatus & BD_LFLAG(TXBD_READY)))2492 if (!(lstatus & BD_LFLAG(TXBD_READY)))
2465 break;2493 break;
2466 2494
2467 txbdp->lstatus = lstatus & ~BD_LFLAG(TXBD_READY);2495 lstatus &= ~BD_LFLAG(TXBD_READY);
2468 bufaddr = txbdp->bufPtr;2496 txbdp->lstatus = cpu_to_be32(lstatus);
2469 dma_unmap_page(priv->dev, bufaddr, txbdp->length,2497 bufaddr = be32_to_cpu(txbdp->bufPtr);
2498 dma_unmap_page(priv->dev, bufaddr, be16_to_cpu(txbdp->length),
2470 DMA_TO_DEVICE);2499 DMA_TO_DEVICE);
2471 txbdp = next_txbd(txbdp, base, tx_queue->tx_ring_size);2500 txbdp = next_txbd(txbdp, base, tx_queue->tx_ring_size);
2472 }2501 }
@@ -2607,7 +2636,7 @@ static void gfar_clean_tx_ring(struct gfar_priv_tx_q *tx_queue) · 134 unmodified lines
2607 2636
2608 lbdp = skip_txbd(bdp, nr_txbds - 1, base, tx_ring_size);2637 lbdp = skip_txbd(bdp, nr_txbds - 1, base, tx_ring_size);
2609 2638
2610 lstatus = lbdp->lstatus;2639 lstatus = be32_to_cpu(lbdp->lstatus);
2611 2640
2612 /* Only clean completed frames */2641 /* Only clean completed frames */
2613 if ((lstatus & BD_LFLAG(TXBD_READY)) &&2642 if ((lstatus & BD_LFLAG(TXBD_READY)) &&
@@ -2616,11 +2645,12 @@ static void gfar_clean_tx_ring(struct gfar_priv_tx_q *tx_queue) · 2 unmodified lines
2616 2645
2617 if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_IN_PROGRESS)) {2646 if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_IN_PROGRESS)) {
2618 next = next_txbd(bdp, base, tx_ring_size);2647 next = next_txbd(bdp, base, tx_ring_size);
2619 buflen = next->length + GMAC_FCB_LEN + GMAC_TXPAL_LEN;2648 buflen = be16_to_cpu(next->length) +
2649 GMAC_FCB_LEN + GMAC_TXPAL_LEN;
2620 } else2650 } else
2621 buflen = bdp->length;2651 buflen = be16_to_cpu(bdp->length);
2622 2652
2623 dma_unmap_single(priv->dev, bdp->bufPtr,2653 dma_unmap_single(priv->dev, be32_to_cpu(bdp->bufPtr),
2624 buflen, DMA_TO_DEVICE);2654 buflen, DMA_TO_DEVICE);
2625 2655
2626 if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_IN_PROGRESS)) {2656 if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_IN_PROGRESS)) {
@@ -2631,17 +2661,18 @@ static void gfar_clean_tx_ring(struct gfar_priv_tx_q *tx_queue) · 4 unmodified lines
2631 shhwtstamps.hwtstamp = ns_to_ktime(*ns);2661 shhwtstamps.hwtstamp = ns_to_ktime(*ns);
2632 skb_pull(skb, GMAC_FCB_LEN + GMAC_TXPAL_LEN);2662 skb_pull(skb, GMAC_FCB_LEN + GMAC_TXPAL_LEN);
2633 skb_tstamp_tx(skb, &shhwtstamps);2663 skb_tstamp_tx(skb, &shhwtstamps);
2634 bdp->lstatus &= BD_LFLAG(TXBD_WRAP);2664 gfar_clear_txbd_status(bdp);
2635 bdp = next;2665 bdp = next;
2636 }2666 }
2637 2667
2638 bdp->lstatus &= BD_LFLAG(TXBD_WRAP);2668 gfar_clear_txbd_status(bdp);
2639 bdp = next_txbd(bdp, base, tx_ring_size);2669 bdp = next_txbd(bdp, base, tx_ring_size);
2640 2670
2641 for (i = 0; i < frags; i++) {2671 for (i = 0; i < frags; i++) {
2642 dma_unmap_page(priv->dev, bdp->bufPtr,2672 dma_unmap_page(priv->dev, be32_to_cpu(bdp->bufPtr),
2643 bdp->length, DMA_TO_DEVICE);2673 be16_to_cpu(bdp->length),
2644 bdp->lstatus &= BD_LFLAG(TXBD_WRAP);2674 DMA_TO_DEVICE);
2675 gfar_clear_txbd_status(bdp);
2645 bdp = next_txbd(bdp, base, tx_ring_size);2676 bdp = next_txbd(bdp, base, tx_ring_size);
2646 }2677 }
2647 2678
@@ -2798,13 +2829,13 @@ static inline void gfar_rx_checksum(struct sk_buff *skb, struct rxfcb *fcb) · 150 unmodified lines
2798 * were verified, then we tell the kernel that no2829 * were verified, then we tell the kernel that no
2799 * checksumming is necessary. Otherwise, it is [FIXME]2830 * checksumming is necessary. Otherwise, it is [FIXME]
2800 */2831 */
2801 if ((fcb->flags & RXFCB_CSUM_MASK) == (RXFCB_CIP | RXFCB_CTU))2832 if ((be16_to_cpu(fcb->flags) & RXFCB_CSUM_MASK) ==
2833 (RXFCB_CIP | RXFCB_CTU))
2802 skb->ip_summed = CHECKSUM_UNNECESSARY;2834 skb->ip_summed = CHECKSUM_UNNECESSARY;
2803 else2835 else
2804 skb_checksum_none_assert(skb);2836 skb_checksum_none_assert(skb);
2805}2837}
2806 2838
2807
2808/* gfar_process_frame() -- handle one incoming packet if skb isn't NULL. */2839/* gfar_process_frame() -- handle one incoming packet if skb isn't NULL. */
2809static void gfar_process_frame(struct net_device *dev, struct sk_buff *skb,2840static void gfar_process_frame(struct net_device *dev, struct sk_buff *skb,
2810 int amount_pull, struct napi_struct *napi)2841 int amount_pull, struct napi_struct *napi)
@@ -2846,8 +2877,9 @@ static void gfar_process_frame(struct net_device *dev, struct sk_buff *skb, · 35 unmodified lines
2846 * RXFCB_VLN is pseudo randomly set.2877 * RXFCB_VLN is pseudo randomly set.
2847 */2878 */
2848 if (dev->features & NETIF_F_HW_VLAN_CTAG_RX &&2879 if (dev->features & NETIF_F_HW_VLAN_CTAG_RX &&
2849 fcb->flags & RXFCB_VLN)2880 be16_to_cpu(fcb->flags) & RXFCB_VLN)
2850 __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), fcb->vlctl);2881 __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q),
2882 be16_to_cpu(fcb->vlctl));
2851 2883
2852 /* Send the packet up the stack */2884 /* Send the packet up the stack */
2853 napi_gro_receive(napi, skb);2885 napi_gro_receive(napi, skb);
@@ -2874,7 +2906,7 @@ int gfar_clean_rx_ring(struct gfar_priv_rx_q *rx_queue, int rx_work_limit) · 20 unmodified lines
2874 2906
2875 amount_pull = priv->uses_rxfcb ? GMAC_FCB_LEN : 0;2907 amount_pull = priv->uses_rxfcb ? GMAC_FCB_LEN : 0;
2876 2908
2877 while (!((bdp->status & RXBD_EMPTY) || (--rx_work_limit < 0))) {2909 while (!(be16_to_cpu(bdp->status) & RXBD_EMPTY) && rx_work_limit--) {
2878 struct sk_buff *newskb;2910 struct sk_buff *newskb;
2879 dma_addr_t bufaddr;2911 dma_addr_t bufaddr;
2880 2912
@@ -2885,21 +2917,22 @@ int gfar_clean_rx_ring(struct gfar_priv_rx_q *rx_queue, int rx_work_limit) · 4 unmodified lines
2885 2917
2886 skb = rx_queue->rx_skbuff[rx_queue->skb_currx];2918 skb = rx_queue->rx_skbuff[rx_queue->skb_currx];
2887 2919
2888 dma_unmap_single(priv->dev, bdp->bufPtr,2920 dma_unmap_single(priv->dev, be32_to_cpu(bdp->bufPtr),
2889 priv->rx_buffer_size, DMA_FROM_DEVICE);2921 priv->rx_buffer_size, DMA_FROM_DEVICE);
2890 2922
2891 if (unlikely(!(bdp->status & RXBD_ERR) &&2923 if (unlikely(!(be16_to_cpu(bdp->status) & RXBD_ERR) &&
2892 bdp->length > priv->rx_buffer_size))2924 be16_to_cpu(bdp->length) > priv->rx_buffer_size))
2893 bdp->status = RXBD_LARGE;2925 bdp->status = cpu_to_be16(RXBD_LARGE);
2894 2926
2895 /* We drop the frame if we failed to allocate a new buffer */2927 /* We drop the frame if we failed to allocate a new buffer */
2896 if (unlikely(!newskb || !(bdp->status & RXBD_LAST) ||2928 if (unlikely(!newskb ||
2897 bdp->status & RXBD_ERR)) {2929 !(be16_to_cpu(bdp->status) & RXBD_LAST) ||
2898 count_errors(bdp->status, dev);2930 be16_to_cpu(bdp->status) & RXBD_ERR)) {
2931 count_errors(be16_to_cpu(bdp->status), dev);
2899 2932
2900 if (unlikely(!newskb)) {2933 if (unlikely(!newskb)) {
2901 newskb = skb;2934 newskb = skb;
2902 bufaddr = bdp->bufPtr;2935 bufaddr = be32_to_cpu(bdp->bufPtr);
2903 } else if (skb)2936 } else if (skb)
2904 dev_kfree_skb(skb);2937 dev_kfree_skb(skb);
2905 } else {2938 } else {
@@ -2908,7 +2941,8 @@ int gfar_clean_rx_ring(struct gfar_priv_rx_q *rx_queue, int rx_work_limit) · 2 unmodified lines
2908 howmany++;2941 howmany++;
2909 2942
2910 if (likely(skb)) {2943 if (likely(skb)) {
2911 pkt_len = bdp->length - ETH_FCS_LEN;2944 pkt_len = be16_to_cpu(bdp->length) -
2945 ETH_FCS_LEN;
2912 /* Remove the FCS from the packet length */2946 /* Remove the FCS from the packet length */
2913 skb_put(skb, pkt_len);2947 skb_put(skb, pkt_len);
2914 rx_queue->stats.rx_bytes += pkt_len;2948 rx_queue->stats.rx_bytes += pkt_len;
drivers/net/ethernet/freescale/gianfar.h+20−12
@@ -544,12 +544,12 @@ struct txbd8 · 543 unmodified lines
544{544{
545 union {545 union {
546 struct {546 struct {
547 u16 status; /* Status Fields */547 __be16 status; /* Status Fields */
548 u16 length; /* Buffer length */548 __be16 length; /* Buffer length */
549 };549 };
550 u32 lstatus;550 __be32 lstatus;
551 };551 };
552 u32 bufPtr; /* Buffer Pointer */552 __be32 bufPtr; /* Buffer Pointer */
553};553};
554 554
555struct txfcb {555struct txfcb {
@@ -557,28 +557,28 @@ struct txfcb { · 1 unmodified line
557 u8 ptp; /* Flag to enable tx timestamping */557 u8 ptp; /* Flag to enable tx timestamping */
558 u8 l4os; /* Level 4 Header Offset */558 u8 l4os; /* Level 4 Header Offset */
559 u8 l3os; /* Level 3 Header Offset */559 u8 l3os; /* Level 3 Header Offset */
560 u16 phcs; /* Pseudo-header Checksum */560 __be16 phcs; /* Pseudo-header Checksum */
561 u16 vlctl; /* VLAN control word */561 __be16 vlctl; /* VLAN control word */
562};562};
563 563
564struct rxbd8564struct rxbd8
565{565{
566 union {566 union {
567 struct {567 struct {
568 u16 status; /* Status Fields */568 __be16 status; /* Status Fields */
569 u16 length; /* Buffer Length */569 __be16 length; /* Buffer Length */
570 };570 };
571 u32 lstatus;571 __be32 lstatus;
572 };572 };
573 u32 bufPtr; /* Buffer Pointer */573 __be32 bufPtr; /* Buffer Pointer */
574};574};
575 575
576struct rxfcb {576struct rxfcb {
577 u16 flags;577 __be16 flags;
578 u8 rq; /* Receive Queue index */578 u8 rq; /* Receive Queue index */
579 u8 pro; /* Layer 4 Protocol */579 u8 pro; /* Layer 4 Protocol */
580 u16 reserved;580 u16 reserved;
581 u16 vlctl; /* VLAN control word */581 __be16 vlctl; /* VLAN control word */
582};582};
583 583
584struct gianfar_skb_cb {584struct gianfar_skb_cb {
@@ -1287,6 +1287,14 @@ static inline void gfar_wmb(void) · 702 unmodified lines
1287#endif1287#endif
1288}1288}
1289 1289
1290static inline void gfar_clear_txbd_status(struct txbd8 *bdp)
1291{
1292 u32 lstatus = be32_to_cpu(bdp->lstatus);
1293
1294 lstatus &= BD_LFLAG(TXBD_WRAP);
1295 bdp->lstatus = cpu_to_be32(lstatus);
1296}
1297
1290irqreturn_t gfar_receive(int irq, void *dev_id);1298irqreturn_t gfar_receive(int irq, void *dev_id);
1291int startup_gfar(struct net_device *dev);1299int startup_gfar(struct net_device *dev);
1292void stop_gfar(struct net_device *dev);1300void stop_gfar(struct net_device *dev);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t