From c44615ae10c0df303b484f580d3c2cd0d1c5f8aa Mon Sep 17 00:00:00 2001 From: Russell King Date: Mon, 31 Mar 2014 13:45:52 +0100 Subject: net: fec: move bufdesc_ex flag into flags Add a new flags field to contain the mostly static driver configuration, the first of which is the bufdesc_ex flag. Signed-off-by: Russell King --- drivers/net/ethernet/freescale/fec.h | 3 +- drivers/net/ethernet/freescale/fec_main.c | 65 +++++++++++++++++-------------- 2 files changed, 37 insertions(+), 31 deletions(-) diff --git a/drivers/net/ethernet/freescale/fec.h b/drivers/net/ethernet/freescale/fec.h index 1757aa7eb473..34302a2bb5a1 100644 --- a/drivers/net/ethernet/freescale/fec.h +++ b/drivers/net/ethernet/freescale/fec.h @@ -311,6 +311,8 @@ struct fec_enet_private { char *tso_hdrs; dma_addr_t tso_hdrs_dma; + unsigned char flags; + struct mutex mutex; struct platform_device *pdev; @@ -329,7 +331,6 @@ struct fec_enet_private { int speed; struct completion mdio_done; int irq[FEC_IRQ_NUM]; - int bufdesc_ex; unsigned short pause_flag; unsigned short pause_mode; diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c index f67e83967a15..5ed94160f9ed 100644 --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c @@ -252,10 +252,14 @@ MODULE_PARM_DESC(macaddr, "FEC Ethernet MAC address"); /* Transmitter timeout */ #define TX_TIMEOUT (2 * HZ) +/* pause mode/flag */ #define FEC_PAUSE_FLAG_AUTONEG BIT(0) #define FEC_PAUSE_FLAG_RX BIT(1) #define FEC_PAUSE_FLAG_TX BIT(2) +/* flags */ +#define FEC_FLAG_BUFDESC_EX BIT(0) + #define TSO_HEADER_SIZE 128 /* Max number of allowed TCP segments for software TSO */ #define FEC_MAX_TSO_SEGS 100 @@ -273,7 +277,7 @@ fec_enet_tx_get(unsigned int index, struct fec_enet_private *fep) union bufdesc_u *base = fep->tx_bd_base; union bufdesc_u *bdp; - if (fep->bufdesc_ex) + if (fep->flags & FEC_FLAG_BUFDESC_EX) bdp = (union bufdesc_u *)(&base->ebd + index); else bdp = (union bufdesc_u *)(&base->bd + index); @@ -289,7 +293,7 @@ fec_enet_rx_get(unsigned int index, struct fec_enet_private *fep) index &= fep->rx_ring_size - 1; - if (fep->bufdesc_ex) + if (fep->flags & FEC_FLAG_BUFDESC_EX) bdp = (union bufdesc_u *)(&base->ebd + index); else bdp = (union bufdesc_u *)(&base->bd + index); @@ -408,7 +412,7 @@ fec_enet_txq_submit_frag_skb(struct sk_buff *skb, struct net_device *ndev) /* Handle the last BD specially */ if (frag == nr_frags - 1) { status |= (BD_ENET_TX_INTR | BD_ENET_TX_LAST); - if (fep->bufdesc_ex) { + if (fep->flags & FEC_FLAG_BUFDESC_EX) { estatus |= BD_ENET_TX_INT; if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP && fep->hwts_tx_en)) @@ -416,7 +420,7 @@ fec_enet_txq_submit_frag_skb(struct sk_buff *skb, struct net_device *ndev) } } - if (fep->bufdesc_ex) { + if (fep->flags & FEC_FLAG_BUFDESC_EX) { if (skb->ip_summed == CHECKSUM_PARTIAL) estatus |= BD_ENET_TX_PINS | BD_ENET_TX_IINS; bdp->ebd.cbd_bdu = 0; @@ -531,7 +535,7 @@ static int fec_enet_txq_submit_skb(struct sk_buff *skb, struct net_device *ndev) return ret; } else { status |= (BD_ENET_TX_INTR | BD_ENET_TX_LAST); - if (fep->bufdesc_ex) { + if (fep->flags & FEC_FLAG_BUFDESC_EX) { estatus = BD_ENET_TX_INT; if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP && fep->hwts_tx_en)) @@ -539,7 +543,7 @@ static int fec_enet_txq_submit_skb(struct sk_buff *skb, struct net_device *ndev) } } - if (fep->bufdesc_ex) { + if (fep->flags & FEC_FLAG_BUFDESC_EX) { if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP && fep->hwts_tx_en)) skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS; @@ -622,7 +626,7 @@ fec_enet_txq_put_data_tso(struct sk_buff *skb, struct net_device *ndev, bdp->bd.cbd_datlen = size; bdp->bd.cbd_bufaddr = addr; - if (fep->bufdesc_ex) { + if (fep->flags & FEC_FLAG_BUFDESC_EX) { if (skb->ip_summed == CHECKSUM_PARTIAL) estatus |= BD_ENET_TX_PINS | BD_ENET_TX_IINS; bdp->ebd.cbd_bdu = 0; @@ -634,7 +638,7 @@ fec_enet_txq_put_data_tso(struct sk_buff *skb, struct net_device *ndev, status |= (BD_ENET_TX_LAST | BD_ENET_TX_TC); if (is_last) { status |= BD_ENET_TX_INTR; - if (fep->bufdesc_ex) + if (fep->flags & FEC_FLAG_BUFDESC_EX) bdp->ebd.cbd_esc |= BD_ENET_TX_INT; } @@ -683,7 +687,7 @@ fec_enet_txq_put_hdr_tso(struct sk_buff *skb, struct net_device *ndev, bdp->bd.cbd_bufaddr = dmabuf; bdp->bd.cbd_datlen = hdr_len; - if (fep->bufdesc_ex) { + if (fep->flags & FEC_FLAG_BUFDESC_EX) { if (skb->ip_summed == CHECKSUM_PARTIAL) estatus |= BD_ENET_TX_PINS | BD_ENET_TX_IINS; bdp->ebd.cbd_bdu = 0; @@ -1006,7 +1010,7 @@ fec_restart(struct net_device *ndev) writel(1 << 8, fep->hwp + FEC_X_WMRK); } - if (fep->bufdesc_ex) + if (fep->flags & FEC_FLAG_BUFDESC_EX) ecntl |= (1 << 4); #ifndef CONFIG_M5272 @@ -1018,7 +1022,7 @@ fec_restart(struct net_device *ndev) writel(ecntl, fep->hwp + FEC_ECNTRL); writel(0, fep->hwp + FEC_R_DES_ACTIVE); - if (fep->bufdesc_ex) + if (fep->flags & FEC_FLAG_BUFDESC_EX) fec_ptp_start_cyclecounter(ndev); /* Enable interrupts we wish to service */ @@ -1155,8 +1159,8 @@ fec_enet_tx(struct net_device *ndev) ndev->stats.tx_bytes += skb->len; } - if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_IN_PROGRESS) && - fep->bufdesc_ex) { + if (fep->flags & FEC_FLAG_BUFDESC_EX && + unlikely(skb_shinfo(skb)->tx_flags & SKBTX_IN_PROGRESS)) { struct skb_shared_hwtstamps shhwtstamps; fec_enet_hwtstamp(fep, bdp->ebd.ts, &shhwtstamps); @@ -1283,8 +1287,9 @@ fec_enet_rx(struct net_device *ndev, int budget) /* If this is a VLAN packet remove the VLAN Tag */ vlan_packet_rcvd = false; - if ((ndev->features & NETIF_F_HW_VLAN_CTAG_RX) && - fep->bufdesc_ex && (bdp->ebd.cbd_esc & BD_ENET_RX_VLAN)) { + if (ndev->features & NETIF_F_HW_VLAN_CTAG_RX && + fep->flags & FEC_FLAG_BUFDESC_EX && + bdp->ebd.cbd_esc & BD_ENET_RX_VLAN) { /* Push and remove the vlan tag */ struct vlan_hdr *vlan_header = (struct vlan_hdr *) (data + ETH_HLEN); @@ -1319,11 +1324,11 @@ fec_enet_rx(struct net_device *ndev, int budget) skb->protocol = eth_type_trans(skb, ndev); /* Get receive timestamp from the skb */ - if (fep->hwts_rx_en && fep->bufdesc_ex) + if (fep->hwts_rx_en && fep->flags & FEC_FLAG_BUFDESC_EX) fec_enet_hwtstamp(fep, bdp->ebd.ts, skb_hwtstamps(skb)); - if (fep->bufdesc_ex && + if (fep->flags & FEC_FLAG_BUFDESC_EX && (fep->csum_flags & FLAG_RX_CSUM_ENABLED)) { if (!(bdp->ebd.cbd_esc & FLAG_RX_CSUM_ERROR)) { /* don't check it */ @@ -1345,7 +1350,7 @@ fec_enet_rx(struct net_device *ndev, int budget) dma_sync_single_for_device(&fep->pdev->dev, bdp->bd.cbd_bufaddr, FEC_ENET_RX_FRSIZE, DMA_FROM_DEVICE); rx_processing_done: - if (fep->bufdesc_ex) { + if (fep->flags & FEC_FLAG_BUFDESC_EX) { bdp->ebd.cbd_esc = BD_ENET_RX_INT; bdp->ebd.cbd_prot = 0; bdp->ebd.cbd_bdu = 0; @@ -1958,7 +1963,7 @@ static int fec_enet_get_ts_info(struct net_device *ndev, { struct fec_enet_private *fep = netdev_priv(ndev); - if (fep->bufdesc_ex) { + if (fep->flags & FEC_FLAG_BUFDESC_EX) { info->so_timestamping = SOF_TIMESTAMPING_TX_SOFTWARE | SOF_TIMESTAMPING_RX_SOFTWARE | @@ -2207,7 +2212,7 @@ static int fec_enet_ioctl(struct net_device *ndev, struct ifreq *rq, int cmd) if (!phydev) return -ENODEV; - if (fep->bufdesc_ex) { + if (fep->flags & FEC_FLAG_BUFDESC_EX) { if (cmd == SIOCSHWTSTAMP) return fec_ptp_set(ndev, rq); if (cmd == SIOCGHWTSTAMP) @@ -2280,7 +2285,7 @@ static int fec_enet_alloc_buffers(struct net_device *ndev) if (i == fep->rx_ring_size - 1) bdp->bd.cbd_sc |= BD_SC_WRAP; - if (fep->bufdesc_ex) + if (fep->flags & FEC_FLAG_BUFDESC_EX) bdp->ebd.cbd_esc = BD_ENET_RX_INT; } @@ -2297,7 +2302,7 @@ static int fec_enet_alloc_buffers(struct net_device *ndev) bdp->bd.cbd_sc = 0; bdp->bd.cbd_bufaddr = 0; - if (fep->bufdesc_ex) + if (fep->flags & FEC_FLAG_BUFDESC_EX) bdp->ebd.cbd_esc = BD_ENET_TX_INT; } @@ -2589,7 +2594,7 @@ static int fec_enet_init(struct net_device *ndev) fep->tx_wake_threshold = (fep->tx_ring_size - fep->tx_stop_threshold) / 2; bd_size = fep->tx_ring_size + fep->rx_ring_size; - if (fep->bufdesc_ex) + if (fep->flags & FEC_FLAG_BUFDESC_EX) bd_size *= sizeof(struct bufdesc_ex); else bd_size *= sizeof(struct bufdesc); @@ -2618,7 +2623,7 @@ static int fec_enet_init(struct net_device *ndev) /* Set receive and transmit descriptor base. */ fep->rx_bd_base = cbd_base; fep->rx_bd_dma = cbd_dma; - if (fep->bufdesc_ex) { + if (fep->flags & FEC_FLAG_BUFDESC_EX) { fep->tx_bd_base = (union bufdesc_u *) (&cbd_base->ebd + fep->rx_ring_size); fep->tx_bd_dma = cbd_dma + sizeof(struct bufdesc_ex) * @@ -2756,7 +2761,9 @@ fec_probe(struct platform_device *pdev) fep->pdev = pdev; fep->dev_id = dev_id++; - fep->bufdesc_ex = 0; + fep->flags = 0; + if (pdev->id_entry->driver_data & FEC_QUIRK_HAS_BUFDESC_EX) + fep->flags |= FEC_FLAG_BUFDESC_EX; platform_set_drvdata(pdev, ndev); @@ -2803,11 +2810,9 @@ fec_probe(struct platform_device *pdev) fep->ptp_clk_on = false; mutex_init(&fep->ptp_clk_mutex); fep->clk_ptp = devm_clk_get(&pdev->dev, "ptp"); - fep->bufdesc_ex = - pdev->id_entry->driver_data & FEC_QUIRK_HAS_BUFDESC_EX; if (IS_ERR(fep->clk_ptp)) { fep->clk_ptp = NULL; - fep->bufdesc_ex = 0; + fep->flags &= ~FEC_FLAG_BUFDESC_EX; } ret = fec_enet_clk_enable(ndev, true); @@ -2828,7 +2833,7 @@ fec_probe(struct platform_device *pdev) fec_reset_phy(pdev); - if (fep->bufdesc_ex) + if (fep->flags & FEC_FLAG_BUFDESC_EX) fec_ptp_init(pdev); ret = fec_enet_init(ndev); @@ -2862,7 +2867,7 @@ fec_probe(struct platform_device *pdev) if (ret) goto failed_register; - if (fep->bufdesc_ex && fep->ptp_clock) + if (fep->flags & FEC_FLAG_BUFDESC_EX && fep->ptp_clock) netdev_info(ndev, "registered PHC device %d\n", fep->dev_id); INIT_WORK(&fep->tx_timeout_work, fec_enet_timeout_work); -- cgit