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
158158 {
159159 u32 lstatus;
160160
161− bdp->bufPtr = buf;
161+ bdp->bufPtr = cpu_to_be32(buf);
162162
163163 lstatus = BD_LFLAG(RXBD_EMPTY | RXBD_INTERRUPT);
164164 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
166166
167167 gfar_wmb();
168168
169− bdp->lstatus = lstatus;
169+ bdp->lstatus = cpu_to_be32(lstatus);
170170 }
171171
172172 static int gfar_init_bds(struct net_device *ndev)
@@ -200,7 +200,8 @@ static int gfar_init_bds(struct net_device *ndev) · 27 unmodified lines
200200
201201 /* Set the last descriptor in the ring to indicate wrap */
202202 txbdp--;
203− txbdp->status |= TXBD_WRAP;
203+ txbdp->status = cpu_to_be16(be16_to_cpu(txbdp->status) |
204+ TXBD_WRAP);
204205 }
205206
206207 rfbptr = &regs->rfbptr0;
@@ -214,7 +215,7 @@ static int gfar_init_bds(struct net_device *ndev) · 7 unmodified lines
214215 struct sk_buff *skb = rx_queue->rx_skbuff[j];
215216
216217 if (skb) {
217− bufaddr = rxbdp->bufPtr;
218+ bufaddr = be32_to_cpu(rxbdp->bufPtr);
218219 } else {
219220 skb = gfar_new_skb(ndev, &bufaddr);
220221 if (!skb) {
@@ -696,19 +697,28 @@ static int gfar_parse_group(struct device_node *np, · 475 unmodified lines
696697 grp->priv = priv;
697698 spin_lock_init(&grp->grplock);
698699 if (priv->mode == MQ_MG_MODE) {
699− u32 *rxq_mask, *txq_mask;
700− rxq_mask = (u32 *)of_get_property(np, "fsl,rx-bit-map", NULL);
701− txq_mask = (u32 *)of_get_property(np, "fsl,tx-bit-map", NULL);
700+ u32 rxq_mask, txq_mask;
701+ int ret;
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+ }
702717
703718 if (priv->poll_mode == GFAR_SQ_POLLING) {
704719 /* One Q per interrupt group: Q0 to G0, Q1 to G1 */
705720 grp->rx_bit_map = (DEFAULT_MAPPING >> priv->num_grps);
706721 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);
712722 }
713723 } else {
714724 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
769779 struct gfar_private *priv = NULL;
770780 struct device_node *np = ofdev->dev.of_node;
771781 struct device_node *child = NULL;
772− const u32 *stash;
773− const u32 *stash_len;
774− const u32 *stash_idx;
782+ struct property *stash;
783+ u32 stash_len = 0;
784+ u32 stash_idx = 0;
775785 unsigned int num_tx_qs, num_rx_qs;
776− u32 *tx_queues, *rx_queues;
777786 unsigned short mode, poll_mode;
778787
779788 if (!np)
@@ -787,10 +796,6 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev) · 7 unmodified lines
787796 poll_mode = GFAR_SQ_POLLING;
788797 }
789798
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−
794799 if (mode == SQ_SG_MODE) {
795800 num_tx_qs = 1;
796801 num_rx_qs = 1;
@@ -809,8 +814,17 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev) · 12 unmodified lines
809814 num_tx_qs = num_grps; /* one txq per int group */
810815 num_rx_qs = num_grps; /* one rxq per int group */
811816 } else { /* GFAR_MQ_POLLING */
812− num_tx_qs = tx_queues ? *tx_queues : 1;
813− num_rx_qs = rx_queues ? *rx_queues : 1;
817+ u32 tx_queues, rx_queues;
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;
814828 }
815829 }
816830
@@ -851,13 +865,17 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev) · 34 unmodified lines
851865 if (err)
852866 goto rx_alloc_failed;
853867
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+
854874 /* Init Rx queue filer rule set linked list */
855875 INIT_LIST_HEAD(&priv->rx_list.list);
856876 priv->rx_list.count = 0;
857877 mutex_init(&priv->rx_queue_access);
858878
859− model = of_get_property(np, "model", NULL);
860−
861879 for (i = 0; i < MAXGROUPS; i++)
862880 priv->gfargrp[i].regs = NULL;
863881
@@ -877,22 +895,22 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev) · 13 unmodified lines
877895 goto err_grp_init;
878896 }
879897
880− stash = of_get_property(np, "bd-stash", NULL);
898+ stash = of_find_property(np, "bd-stash", NULL);
881899
882900 if (stash) {
883901 priv->device_flags |= FSL_GIANFAR_DEV_HAS_BD_STASHING;
884902 priv->bd_stash_en = 1;
885903 }
886904
887− stash_len = of_get_property(np, "rx-stash-len", NULL);
905+ err = of_property_read_u32(np, "rx-stash-len", &stash_len);
888906
889− if (stash_len)
890− priv->rx_stash_size = *stash_len;
907+ if (err == 0)
908+ priv->rx_stash_size = stash_len;
891909
892− stash_idx = of_get_property(np, "rx-stash-idx", NULL);
910+ err = of_property_read_u32(np, "rx-stash-idx", &stash_idx);
893911
894− if (stash_idx)
895− priv->rx_stash_index = *stash_idx;
912+ if (err == 0)
913+ priv->rx_stash_index = stash_idx;
896914
897915 if (stash_len || stash_idx)
898916 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
919937 FSL_GIANFAR_DEV_HAS_EXTENDED_HASH |
920938 FSL_GIANFAR_DEV_HAS_TIMER;
921939
922− ctype = of_get_property(np, "phy-connection-type", NULL);
940+ err = of_property_read_string(np, "phy-connection-type", &ctype);
923941
924942 /* 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"))
926944 priv->interface = PHY_INTERFACE_MODE_RGMII_ID;
927945 else
928946 priv->interface = PHY_INTERFACE_MODE_MII;
929947
930− if (of_get_property(np, "fsl,magic-packet", NULL))
948+ if (of_find_property(np, "fsl,magic-packet", NULL))
931949 priv->device_flags |= FSL_GIANFAR_DEV_HAS_MAGIC_PACKET;
932950
933951 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
18841902 if (!tx_queue->tx_skbuff[i])
18851903 continue;
18861904
1887− dma_unmap_single(priv->dev, txbdp->bufPtr,
1888− txbdp->length, DMA_TO_DEVICE);
1905+ dma_unmap_single(priv->dev, be32_to_cpu(txbdp->bufPtr),
1906+ be16_to_cpu(txbdp->length), DMA_TO_DEVICE);
18891907 txbdp->lstatus = 0;
18901908 for (j = 0; j < skb_shinfo(tx_queue->tx_skbuff[i])->nr_frags;
18911909 j++) {
18921910 txbdp++;
1893− dma_unmap_page(priv->dev, txbdp->bufPtr,
1894− txbdp->length, DMA_TO_DEVICE);
1911+ dma_unmap_page(priv->dev, be32_to_cpu(txbdp->bufPtr),
1912+ be16_to_cpu(txbdp->length),
1913+ DMA_TO_DEVICE);
18951914 }
18961915 txbdp++;
18971916 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
19111930
19121931 for (i = 0; i < rx_queue->rx_ring_size; i++) {
19131932 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),
19151934 priv->rx_buffer_size,
19161935 DMA_FROM_DEVICE);
19171936 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
21672186 */
21682187 if (ip_hdr(skb)->protocol == IPPROTO_UDP) {
21692188 flags |= TXFCB_UDP;
2170− fcb->phcs = udp_hdr(skb)->check;
2189+ fcb->phcs = (__force __be16)(udp_hdr(skb)->check);
21712190 } else
2172− fcb->phcs = tcp_hdr(skb)->check;
2191+ fcb->phcs = (__force __be16)(tcp_hdr(skb)->check);
21732192
21742193 /* l3os is the distance between the start of the
21752194 * frame (skb->data) and the start of the IP hdr.
21762195 * l4os is the distance between the start of the
21772196 * l3 hdr and the l4 hdr
21782197 */
2179− fcb->l3os = (u16)(skb_network_offset(skb) - fcb_length);
2198+ fcb->l3os = (u8)(skb_network_offset(skb) - fcb_length);
21802199 fcb->l4os = skb_network_header_len(skb);
21812200
21822201 fcb->flags = flags;
@@ -2185,7 +2204,7 @@ static inline void gfar_tx_checksum(struct sk_buff *skb, struct txfcb *fcb, · 2 unmodified lines
21852204 void inline gfar_tx_vlan(struct sk_buff *skb, struct txfcb *fcb)
21862205 {
21872206 fcb->flags |= TXFCB_VLN;
2188− fcb->vlctl = skb_vlan_tag_get(skb);
2207+ fcb->vlctl = cpu_to_be16(skb_vlan_tag_get(skb));
21892208 }
21902209
21912210 static 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
22982317 tx_queue->stats.tx_packets++;
22992318
23002319 txbdp = txbdp_start = tx_queue->cur_tx;
2301− lstatus = txbdp->lstatus;
2320+ lstatus = be32_to_cpu(txbdp->lstatus);
23022321
23032322 /* Time stamp insertion requires one additional TxBD */
23042323 if (unlikely(do_tstamp))
@@ -2306,11 +2325,14 @@ static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev) · 1 unmodified line
23062325 tx_queue->tx_ring_size);
23072326
23082327 if (nr_frags == 0) {
2309− if (unlikely(do_tstamp))
2310− txbdp_tstamp->lstatus |= BD_LFLAG(TXBD_LAST |
2311− TXBD_INTERRUPT);
2312− else
2328+ if (unlikely(do_tstamp)) {
2329+ u32 lstatus_ts = be32_to_cpu(txbdp_tstamp->lstatus);
2330+
2331+ lstatus_ts |= BD_LFLAG(TXBD_LAST | TXBD_INTERRUPT);
2332+ txbdp_tstamp->lstatus = cpu_to_be32(lstatus_ts);
2333+ } else {
23132334 lstatus |= BD_LFLAG(TXBD_LAST | TXBD_INTERRUPT);
2335+ }
23142336 } else {
23152337 /* Place the fragment addresses and lengths into the TxBDs */
23162338 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
23202342
23212343 frag_len = skb_shinfo(skb)->frags[i].size;
23222344
2323− lstatus = txbdp->lstatus | frag_len |
2345+ lstatus = be32_to_cpu(txbdp->lstatus) | frag_len |
23242346 BD_LFLAG(TXBD_READY);
23252347
23262348 /* 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
23362358 goto dma_map_err;
23372359
23382360 /* set the TxBD length and buffer pointer */
2339− txbdp->bufPtr = bufaddr;
2340− txbdp->lstatus = lstatus;
2361+ txbdp->bufPtr = cpu_to_be32(bufaddr);
2362+ txbdp->lstatus = cpu_to_be32(lstatus);
23412363 }
23422364
2343− lstatus = txbdp_start->lstatus;
2365+ lstatus = be32_to_cpu(txbdp_start->lstatus);
23442366 }
23452367
23462368 /* 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
23882410 if (unlikely(dma_mapping_error(priv->dev, bufaddr)))
23892411 goto dma_map_err;
23902412
2391− txbdp_start->bufPtr = bufaddr;
2413+ txbdp_start->bufPtr = cpu_to_be32(bufaddr);
23922414
23932415 /* If time stamping is requested one additional TxBD must be set up. The
23942416 * 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
23962418 * the full frame length.
23972419 */
23982420 if (unlikely(do_tstamp)) {
2399− txbdp_tstamp->bufPtr = txbdp_start->bufPtr + fcb_len;
2400− txbdp_tstamp->lstatus |= BD_LFLAG(TXBD_READY) |
2401− (skb_headlen(skb) - fcb_len);
2421+ u32 lstatus_ts = be32_to_cpu(txbdp_tstamp->lstatus);
2422+
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);
24022430 lstatus |= BD_LFLAG(TXBD_CRC | TXBD_READY) | GMAC_FCB_LEN;
24032431 } else {
24042432 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
24212449
24222450 gfar_wmb();
24232451
2424− txbdp_start->lstatus = lstatus;
2452+ txbdp_start->lstatus = cpu_to_be32(lstatus);
24252453
24262454 gfar_wmb(); /* force lstatus write before tx_skbuff */
24272455
@@ -2460,13 +2488,14 @@ dma_map_err: · 32 unmodified lines
24602488 if (do_tstamp)
24612489 txbdp = next_txbd(txbdp, base, tx_queue->tx_ring_size);
24622490 for (i = 0; i < nr_frags; i++) {
2463− lstatus = txbdp->lstatus;
2491+ lstatus = be32_to_cpu(txbdp->lstatus);
24642492 if (!(lstatus & BD_LFLAG(TXBD_READY)))
24652493 break;
24662494
2467− txbdp->lstatus = lstatus & ~BD_LFLAG(TXBD_READY);
2468− bufaddr = txbdp->bufPtr;
2469− dma_unmap_page(priv->dev, bufaddr, txbdp->length,
2495+ lstatus &= ~BD_LFLAG(TXBD_READY);
2496+ txbdp->lstatus = cpu_to_be32(lstatus);
2497+ bufaddr = be32_to_cpu(txbdp->bufPtr);
2498+ dma_unmap_page(priv->dev, bufaddr, be16_to_cpu(txbdp->length),
24702499 DMA_TO_DEVICE);
24712500 txbdp = next_txbd(txbdp, base, tx_queue->tx_ring_size);
24722501 }
@@ -2607,7 +2636,7 @@ static void gfar_clean_tx_ring(struct gfar_priv_tx_q *tx_queue) · 134 unmodified lines
26072636
26082637 lbdp = skip_txbd(bdp, nr_txbds - 1, base, tx_ring_size);
26092638
2610− lstatus = lbdp->lstatus;
2639+ lstatus = be32_to_cpu(lbdp->lstatus);
26112640
26122641 /* Only clean completed frames */
26132642 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
26162645
26172646 if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_IN_PROGRESS)) {
26182647 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;
26202650 } else
2621− buflen = bdp->length;
2651+ buflen = be16_to_cpu(bdp->length);
26222652
2623− dma_unmap_single(priv->dev, bdp->bufPtr,
2653+ dma_unmap_single(priv->dev, be32_to_cpu(bdp->bufPtr),
26242654 buflen, DMA_TO_DEVICE);
26252655
26262656 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
26312661 shhwtstamps.hwtstamp = ns_to_ktime(*ns);
26322662 skb_pull(skb, GMAC_FCB_LEN + GMAC_TXPAL_LEN);
26332663 skb_tstamp_tx(skb, &shhwtstamps);
2634− bdp->lstatus &= BD_LFLAG(TXBD_WRAP);
2664+ gfar_clear_txbd_status(bdp);
26352665 bdp = next;
26362666 }
26372667
2638− bdp->lstatus &= BD_LFLAG(TXBD_WRAP);
2668+ gfar_clear_txbd_status(bdp);
26392669 bdp = next_txbd(bdp, base, tx_ring_size);
26402670
26412671 for (i = 0; i < frags; i++) {
2642− dma_unmap_page(priv->dev, bdp->bufPtr,
2643− bdp->length, DMA_TO_DEVICE);
2644− bdp->lstatus &= BD_LFLAG(TXBD_WRAP);
2672+ dma_unmap_page(priv->dev, be32_to_cpu(bdp->bufPtr),
2673+ be16_to_cpu(bdp->length),
2674+ DMA_TO_DEVICE);
2675+ gfar_clear_txbd_status(bdp);
26452676 bdp = next_txbd(bdp, base, tx_ring_size);
26462677 }
26472678
@@ -2798,13 +2829,13 @@ static inline void gfar_rx_checksum(struct sk_buff *skb, struct rxfcb *fcb) · 150 unmodified lines
27982829 * were verified, then we tell the kernel that no
27992830 * checksumming is necessary. Otherwise, it is [FIXME]
28002831 */
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))
28022834 skb->ip_summed = CHECKSUM_UNNECESSARY;
28032835 else
28042836 skb_checksum_none_assert(skb);
28052837 }
28062838
2807−
28082839 /* gfar_process_frame() -- handle one incoming packet if skb isn't NULL. */
28092840 static void gfar_process_frame(struct net_device *dev, struct sk_buff *skb,
28102841 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
28462877 * RXFCB_VLN is pseudo randomly set.
28472878 */
28482879 if (dev->features & NETIF_F_HW_VLAN_CTAG_RX &&
2849− fcb->flags & RXFCB_VLN)
2850− __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), fcb->vlctl);
2880+ be16_to_cpu(fcb->flags) & RXFCB_VLN)
2881+ __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q),
2882+ be16_to_cpu(fcb->vlctl));
28512883
28522884 /* Send the packet up the stack */
28532885 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
28742906
28752907 amount_pull = priv->uses_rxfcb ? GMAC_FCB_LEN : 0;
28762908
2877− while (!((bdp->status & RXBD_EMPTY) || (--rx_work_limit < 0))) {
2909+ while (!(be16_to_cpu(bdp->status) & RXBD_EMPTY) && rx_work_limit--) {
28782910 struct sk_buff *newskb;
28792911 dma_addr_t bufaddr;
28802912
@@ -2885,21 +2917,22 @@ int gfar_clean_rx_ring(struct gfar_priv_rx_q *rx_queue, int rx_work_limit) · 4 unmodified lines
28852917
28862918 skb = rx_queue->rx_skbuff[rx_queue->skb_currx];
28872919
2888− dma_unmap_single(priv->dev, bdp->bufPtr,
2920+ dma_unmap_single(priv->dev, be32_to_cpu(bdp->bufPtr),
28892921 priv->rx_buffer_size, DMA_FROM_DEVICE);
28902922
2891− if (unlikely(!(bdp->status & RXBD_ERR) &&
2892− bdp->length > priv->rx_buffer_size))
2893− bdp->status = RXBD_LARGE;
2923+ if (unlikely(!(be16_to_cpu(bdp->status) & RXBD_ERR) &&
2924+ be16_to_cpu(bdp->length) > priv->rx_buffer_size))
2925+ bdp->status = cpu_to_be16(RXBD_LARGE);
28942926
28952927 /* We drop the frame if we failed to allocate a new buffer */
2896− if (unlikely(!newskb || !(bdp->status & RXBD_LAST) ||
2897− bdp->status & RXBD_ERR)) {
2898− count_errors(bdp->status, dev);
2928+ if (unlikely(!newskb ||
2929+ !(be16_to_cpu(bdp->status) & RXBD_LAST) ||
2930+ be16_to_cpu(bdp->status) & RXBD_ERR)) {
2931+ count_errors(be16_to_cpu(bdp->status), dev);
28992932
29002933 if (unlikely(!newskb)) {
29012934 newskb = skb;
2902− bufaddr = bdp->bufPtr;
2935+ bufaddr = be32_to_cpu(bdp->bufPtr);
29032936 } else if (skb)
29042937 dev_kfree_skb(skb);
29052938 } else {
@@ -2908,7 +2941,8 @@ int gfar_clean_rx_ring(struct gfar_priv_rx_q *rx_queue, int rx_work_limit) · 2 unmodified lines
29082941 howmany++;
29092942
29102943 if (likely(skb)) {
2911− pkt_len = bdp->length - ETH_FCS_LEN;
2944+ pkt_len = be16_to_cpu(bdp->length) -
2945+ ETH_FCS_LEN;
29122946 /* Remove the FCS from the packet length */
29132947 skb_put(skb, pkt_len);
29142948 rx_queue->stats.rx_bytes += pkt_len;
drivers/net/ethernet/freescale/gianfar.h+20−12
@@ -544,12 +544,12 @@ struct txbd8 · 543 unmodified lines
544544 {
545545 union {
546546 struct {
547− u16 status; /* Status Fields */
548− u16 length; /* Buffer length */
547+ __be16 status; /* Status Fields */
548+ __be16 length; /* Buffer length */
549549 };
550− u32 lstatus;
550+ __be32 lstatus;
551551 };
552− u32 bufPtr; /* Buffer Pointer */
552+ __be32 bufPtr; /* Buffer Pointer */
553553 };
554554
555555 struct txfcb {
@@ -557,28 +557,28 @@ struct txfcb { · 1 unmodified line
557557 u8 ptp; /* Flag to enable tx timestamping */
558558 u8 l4os; /* Level 4 Header Offset */
559559 u8 l3os; /* Level 3 Header Offset */
560− u16 phcs; /* Pseudo-header Checksum */
561− u16 vlctl; /* VLAN control word */
560+ __be16 phcs; /* Pseudo-header Checksum */
561+ __be16 vlctl; /* VLAN control word */
562562 };
563563
564564 struct rxbd8
565565 {
566566 union {
567567 struct {
568− u16 status; /* Status Fields */
569− u16 length; /* Buffer Length */
568+ __be16 status; /* Status Fields */
569+ __be16 length; /* Buffer Length */
570570 };
571− u32 lstatus;
571+ __be32 lstatus;
572572 };
573− u32 bufPtr; /* Buffer Pointer */
573+ __be32 bufPtr; /* Buffer Pointer */
574574 };
575575
576576 struct rxfcb {
577− u16 flags;
577+ __be16 flags;
578578 u8 rq; /* Receive Queue index */
579579 u8 pro; /* Layer 4 Protocol */
580580 u16 reserved;
581− u16 vlctl; /* VLAN control word */
581+ __be16 vlctl; /* VLAN control word */
582582 };
583583
584584 struct gianfar_skb_cb {
@@ -1287,6 +1287,14 @@ static inline void gfar_wmb(void) · 702 unmodified lines
12871287 #endif
12881288 }
12891289
1290+static 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+
12901298 irqreturn_t gfar_receive(int irq, void *dev_id);
12911299 int startup_gfar(struct net_device *dev);
12921300 void 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