diff options
Diffstat (limited to 'drivers/net/atl1/atl1_main.c')
-rw-r--r-- | drivers/net/atl1/atl1_main.c | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/drivers/net/atl1/atl1_main.c b/drivers/net/atl1/atl1_main.c index fd1e156f1747..56f6389a300e 100644 --- a/drivers/net/atl1/atl1_main.c +++ b/drivers/net/atl1/atl1_main.c | |||
@@ -59,6 +59,7 @@ | |||
59 | #include <linux/skbuff.h> | 59 | #include <linux/skbuff.h> |
60 | #include <linux/etherdevice.h> | 60 | #include <linux/etherdevice.h> |
61 | #include <linux/if_vlan.h> | 61 | #include <linux/if_vlan.h> |
62 | #include <linux/if_ether.h> | ||
62 | #include <linux/irqreturn.h> | 63 | #include <linux/irqreturn.h> |
63 | #include <linux/workqueue.h> | 64 | #include <linux/workqueue.h> |
64 | #include <linux/timer.h> | 65 | #include <linux/timer.h> |
@@ -120,8 +121,8 @@ static int __devinit atl1_sw_init(struct atl1_adapter *adapter) | |||
120 | struct atl1_hw *hw = &adapter->hw; | 121 | struct atl1_hw *hw = &adapter->hw; |
121 | struct net_device *netdev = adapter->netdev; | 122 | struct net_device *netdev = adapter->netdev; |
122 | 123 | ||
123 | hw->max_frame_size = netdev->mtu + ENET_HEADER_SIZE + ETHERNET_FCS_SIZE; | 124 | hw->max_frame_size = netdev->mtu + ETH_HLEN + ETH_FCS_LEN; |
124 | hw->min_frame_size = MINIMUM_ETHERNET_FRAME_SIZE; | 125 | hw->min_frame_size = ETH_ZLEN + ETH_FCS_LEN; |
125 | 126 | ||
126 | adapter->wol = 0; | 127 | adapter->wol = 0; |
127 | adapter->rx_buffer_len = (hw->max_frame_size + 7) & ~7; | 128 | adapter->rx_buffer_len = (hw->max_frame_size + 7) & ~7; |
@@ -314,7 +315,7 @@ err_nomem: | |||
314 | return -ENOMEM; | 315 | return -ENOMEM; |
315 | } | 316 | } |
316 | 317 | ||
317 | void atl1_init_ring_ptrs(struct atl1_adapter *adapter) | 318 | static void atl1_init_ring_ptrs(struct atl1_adapter *adapter) |
318 | { | 319 | { |
319 | struct atl1_tpd_ring *tpd_ring = &adapter->tpd_ring; | 320 | struct atl1_tpd_ring *tpd_ring = &adapter->tpd_ring; |
320 | struct atl1_rfd_ring *rfd_ring = &adapter->rfd_ring; | 321 | struct atl1_rfd_ring *rfd_ring = &adapter->rfd_ring; |
@@ -688,9 +689,9 @@ static int atl1_change_mtu(struct net_device *netdev, int new_mtu) | |||
688 | { | 689 | { |
689 | struct atl1_adapter *adapter = netdev_priv(netdev); | 690 | struct atl1_adapter *adapter = netdev_priv(netdev); |
690 | int old_mtu = netdev->mtu; | 691 | int old_mtu = netdev->mtu; |
691 | int max_frame = new_mtu + ENET_HEADER_SIZE + ETHERNET_FCS_SIZE; | 692 | int max_frame = new_mtu + ETH_HLEN + ETH_FCS_LEN; |
692 | 693 | ||
693 | if ((max_frame < MINIMUM_ETHERNET_FRAME_SIZE) || | 694 | if ((max_frame < ETH_ZLEN + ETH_FCS_LEN) || |
694 | (max_frame > MAX_JUMBO_FRAME_SIZE)) { | 695 | (max_frame > MAX_JUMBO_FRAME_SIZE)) { |
695 | dev_warn(&adapter->pdev->dev, "invalid MTU setting\n"); | 696 | dev_warn(&adapter->pdev->dev, "invalid MTU setting\n"); |
696 | return -EINVAL; | 697 | return -EINVAL; |
@@ -908,8 +909,8 @@ static u32 atl1_configure(struct atl1_adapter *adapter) | |||
908 | /* config DMA Engine */ | 909 | /* config DMA Engine */ |
909 | value = ((((u32) hw->dmar_block) & DMA_CTRL_DMAR_BURST_LEN_MASK) | 910 | value = ((((u32) hw->dmar_block) & DMA_CTRL_DMAR_BURST_LEN_MASK) |
910 | << DMA_CTRL_DMAR_BURST_LEN_SHIFT) | | 911 | << DMA_CTRL_DMAR_BURST_LEN_SHIFT) | |
911 | ((((u32) hw->dmaw_block) & DMA_CTRL_DMAR_BURST_LEN_MASK) | 912 | ((((u32) hw->dmaw_block) & DMA_CTRL_DMAW_BURST_LEN_MASK) |
912 | << DMA_CTRL_DMAR_BURST_LEN_SHIFT) | DMA_CTRL_DMAR_EN | | 913 | << DMA_CTRL_DMAW_BURST_LEN_SHIFT) | DMA_CTRL_DMAR_EN | |
913 | DMA_CTRL_DMAW_EN; | 914 | DMA_CTRL_DMAW_EN; |
914 | value |= (u32) hw->dma_ord; | 915 | value |= (u32) hw->dma_ord; |
915 | if (atl1_rcb_128 == hw->rcb_value) | 916 | if (atl1_rcb_128 == hw->rcb_value) |
@@ -917,7 +918,10 @@ static u32 atl1_configure(struct atl1_adapter *adapter) | |||
917 | iowrite32(value, hw->hw_addr + REG_DMA_CTRL); | 918 | iowrite32(value, hw->hw_addr + REG_DMA_CTRL); |
918 | 919 | ||
919 | /* config CMB / SMB */ | 920 | /* config CMB / SMB */ |
920 | value = hw->cmb_rrd | ((u32) hw->cmb_tpd << 16); | 921 | value = (hw->cmb_tpd > adapter->tpd_ring.count) ? |
922 | hw->cmb_tpd : adapter->tpd_ring.count; | ||
923 | value <<= 16; | ||
924 | value |= hw->cmb_rrd; | ||
921 | iowrite32(value, hw->hw_addr + REG_CMB_WRITE_TH); | 925 | iowrite32(value, hw->hw_addr + REG_CMB_WRITE_TH); |
922 | value = hw->cmb_rx_timer | ((u32) hw->cmb_tx_timer << 16); | 926 | value = hw->cmb_rx_timer | ((u32) hw->cmb_tx_timer << 16); |
923 | iowrite32(value, hw->hw_addr + REG_CMB_WRITE_TIMER); | 927 | iowrite32(value, hw->hw_addr + REG_CMB_WRITE_TIMER); |
@@ -1334,7 +1338,7 @@ rrd_ok: | |||
1334 | skb = buffer_info->skb; | 1338 | skb = buffer_info->skb; |
1335 | length = le16_to_cpu(rrd->xsz.xsum_sz.pkt_size); | 1339 | length = le16_to_cpu(rrd->xsz.xsum_sz.pkt_size); |
1336 | 1340 | ||
1337 | skb_put(skb, length - ETHERNET_FCS_SIZE); | 1341 | skb_put(skb, length - ETH_FCS_LEN); |
1338 | 1342 | ||
1339 | /* Receive Checksum Offload */ | 1343 | /* Receive Checksum Offload */ |
1340 | atl1_rx_checksum(adapter, rrd, skb); | 1344 | atl1_rx_checksum(adapter, rrd, skb); |
@@ -1422,7 +1426,7 @@ static void atl1_intr_tx(struct atl1_adapter *adapter) | |||
1422 | netif_wake_queue(adapter->netdev); | 1426 | netif_wake_queue(adapter->netdev); |
1423 | } | 1427 | } |
1424 | 1428 | ||
1425 | static u16 tpd_avail(struct atl1_tpd_ring *tpd_ring) | 1429 | static u16 atl1_tpd_avail(struct atl1_tpd_ring *tpd_ring) |
1426 | { | 1430 | { |
1427 | u16 next_to_clean = atomic_read(&tpd_ring->next_to_clean); | 1431 | u16 next_to_clean = atomic_read(&tpd_ring->next_to_clean); |
1428 | u16 next_to_use = atomic_read(&tpd_ring->next_to_use); | 1432 | u16 next_to_use = atomic_read(&tpd_ring->next_to_use); |
@@ -1453,7 +1457,7 @@ static int atl1_tso(struct atl1_adapter *adapter, struct sk_buff *skb, | |||
1453 | tcp_hdr(skb)->check = ~csum_tcpudp_magic(iph->saddr, | 1457 | tcp_hdr(skb)->check = ~csum_tcpudp_magic(iph->saddr, |
1454 | iph->daddr, 0, IPPROTO_TCP, 0); | 1458 | iph->daddr, 0, IPPROTO_TCP, 0); |
1455 | ipofst = skb_network_offset(skb); | 1459 | ipofst = skb_network_offset(skb); |
1456 | if (ipofst != ENET_HEADER_SIZE) /* 802.3 frame */ | 1460 | if (ipofst != ETH_HLEN) /* 802.3 frame */ |
1457 | tso->tsopl |= 1 << TSO_PARAM_ETHTYPE_SHIFT; | 1461 | tso->tsopl |= 1 << TSO_PARAM_ETHTYPE_SHIFT; |
1458 | 1462 | ||
1459 | tso->tsopl |= (iph->ihl & | 1463 | tso->tsopl |= (iph->ihl & |
@@ -1708,7 +1712,7 @@ static int atl1_xmit_frame(struct sk_buff *skb, struct net_device *netdev) | |||
1708 | return NETDEV_TX_LOCKED; | 1712 | return NETDEV_TX_LOCKED; |
1709 | } | 1713 | } |
1710 | 1714 | ||
1711 | if (tpd_avail(&adapter->tpd_ring) < count) { | 1715 | if (atl1_tpd_avail(&adapter->tpd_ring) < count) { |
1712 | /* not enough descriptors */ | 1716 | /* not enough descriptors */ |
1713 | netif_stop_queue(netdev); | 1717 | netif_stop_queue(netdev); |
1714 | spin_unlock_irqrestore(&adapter->lock, flags); | 1718 | spin_unlock_irqrestore(&adapter->lock, flags); |