diff options
Diffstat (limited to 'drivers/net/ethernet/moxa/moxart_ether.c')
-rw-r--r-- | drivers/net/ethernet/moxa/moxart_ether.c | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/drivers/net/ethernet/moxa/moxart_ether.c b/drivers/net/ethernet/moxa/moxart_ether.c index 5020fd47825d..2f12c88c66ab 100644 --- a/drivers/net/ethernet/moxa/moxart_ether.c +++ b/drivers/net/ethernet/moxa/moxart_ether.c | |||
@@ -206,7 +206,7 @@ static int moxart_rx_poll(struct napi_struct *napi, int budget) | |||
206 | int rx_head = priv->rx_head; | 206 | int rx_head = priv->rx_head; |
207 | int rx = 0; | 207 | int rx = 0; |
208 | 208 | ||
209 | while (1) { | 209 | while (rx < budget) { |
210 | desc = priv->rx_desc_base + (RX_REG_DESC_SIZE * rx_head); | 210 | desc = priv->rx_desc_base + (RX_REG_DESC_SIZE * rx_head); |
211 | desc0 = readl(desc + RX_REG_OFFSET_DESC0); | 211 | desc0 = readl(desc + RX_REG_OFFSET_DESC0); |
212 | 212 | ||
@@ -218,7 +218,7 @@ static int moxart_rx_poll(struct napi_struct *napi, int budget) | |||
218 | net_dbg_ratelimited("packet error\n"); | 218 | net_dbg_ratelimited("packet error\n"); |
219 | priv->stats.rx_dropped++; | 219 | priv->stats.rx_dropped++; |
220 | priv->stats.rx_errors++; | 220 | priv->stats.rx_errors++; |
221 | continue; | 221 | goto rx_next; |
222 | } | 222 | } |
223 | 223 | ||
224 | len = desc0 & RX_DESC0_FRAME_LEN_MASK; | 224 | len = desc0 & RX_DESC0_FRAME_LEN_MASK; |
@@ -226,13 +226,19 @@ static int moxart_rx_poll(struct napi_struct *napi, int budget) | |||
226 | if (len > RX_BUF_SIZE) | 226 | if (len > RX_BUF_SIZE) |
227 | len = RX_BUF_SIZE; | 227 | len = RX_BUF_SIZE; |
228 | 228 | ||
229 | skb = build_skb(priv->rx_buf[rx_head], priv->rx_buf_size); | 229 | dma_sync_single_for_cpu(&ndev->dev, |
230 | priv->rx_mapping[rx_head], | ||
231 | priv->rx_buf_size, DMA_FROM_DEVICE); | ||
232 | skb = netdev_alloc_skb_ip_align(ndev, len); | ||
233 | |||
230 | if (unlikely(!skb)) { | 234 | if (unlikely(!skb)) { |
231 | net_dbg_ratelimited("build_skb failed\n"); | 235 | net_dbg_ratelimited("netdev_alloc_skb_ip_align failed\n"); |
232 | priv->stats.rx_dropped++; | 236 | priv->stats.rx_dropped++; |
233 | priv->stats.rx_errors++; | 237 | priv->stats.rx_errors++; |
238 | goto rx_next; | ||
234 | } | 239 | } |
235 | 240 | ||
241 | memcpy(skb->data, priv->rx_buf[rx_head], len); | ||
236 | skb_put(skb, len); | 242 | skb_put(skb, len); |
237 | skb->protocol = eth_type_trans(skb, ndev); | 243 | skb->protocol = eth_type_trans(skb, ndev); |
238 | napi_gro_receive(&priv->napi, skb); | 244 | napi_gro_receive(&priv->napi, skb); |
@@ -244,18 +250,15 @@ static int moxart_rx_poll(struct napi_struct *napi, int budget) | |||
244 | if (desc0 & RX_DESC0_MULTICAST) | 250 | if (desc0 & RX_DESC0_MULTICAST) |
245 | priv->stats.multicast++; | 251 | priv->stats.multicast++; |
246 | 252 | ||
253 | rx_next: | ||
247 | writel(RX_DESC0_DMA_OWN, desc + RX_REG_OFFSET_DESC0); | 254 | writel(RX_DESC0_DMA_OWN, desc + RX_REG_OFFSET_DESC0); |
248 | 255 | ||
249 | rx_head = RX_NEXT(rx_head); | 256 | rx_head = RX_NEXT(rx_head); |
250 | priv->rx_head = rx_head; | 257 | priv->rx_head = rx_head; |
251 | |||
252 | if (rx >= budget) | ||
253 | break; | ||
254 | } | 258 | } |
255 | 259 | ||
256 | if (rx < budget) { | 260 | if (rx < budget) { |
257 | napi_gro_flush(napi, false); | 261 | napi_complete(napi); |
258 | __napi_complete(napi); | ||
259 | } | 262 | } |
260 | 263 | ||
261 | priv->reg_imr |= RPKT_FINISH_M; | 264 | priv->reg_imr |= RPKT_FINISH_M; |
@@ -346,10 +349,12 @@ static int moxart_mac_start_xmit(struct sk_buff *skb, struct net_device *ndev) | |||
346 | len = ETH_ZLEN; | 349 | len = ETH_ZLEN; |
347 | } | 350 | } |
348 | 351 | ||
349 | txdes1 = readl(desc + TX_REG_OFFSET_DESC1); | 352 | dma_sync_single_for_device(&ndev->dev, priv->tx_mapping[tx_head], |
350 | txdes1 |= TX_DESC1_LTS | TX_DESC1_FTS; | 353 | priv->tx_buf_size, DMA_TO_DEVICE); |
351 | txdes1 &= ~(TX_DESC1_FIFO_COMPLETE | TX_DESC1_INTR_COMPLETE); | 354 | |
352 | txdes1 |= (len & TX_DESC1_BUF_SIZE_MASK); | 355 | txdes1 = TX_DESC1_LTS | TX_DESC1_FTS | (len & TX_DESC1_BUF_SIZE_MASK); |
356 | if (tx_head == TX_DESC_NUM_MASK) | ||
357 | txdes1 |= TX_DESC1_END; | ||
353 | writel(txdes1, desc + TX_REG_OFFSET_DESC1); | 358 | writel(txdes1, desc + TX_REG_OFFSET_DESC1); |
354 | writel(TX_DESC0_DMA_OWN, desc + TX_REG_OFFSET_DESC0); | 359 | writel(TX_DESC0_DMA_OWN, desc + TX_REG_OFFSET_DESC0); |
355 | 360 | ||
@@ -465,8 +470,7 @@ static int moxart_mac_probe(struct platform_device *pdev) | |||
465 | spin_lock_init(&priv->txlock); | 470 | spin_lock_init(&priv->txlock); |
466 | 471 | ||
467 | priv->tx_buf_size = TX_BUF_SIZE; | 472 | priv->tx_buf_size = TX_BUF_SIZE; |
468 | priv->rx_buf_size = RX_BUF_SIZE + | 473 | priv->rx_buf_size = RX_BUF_SIZE; |
469 | SKB_DATA_ALIGN(sizeof(struct skb_shared_info)); | ||
470 | 474 | ||
471 | priv->tx_desc_base = dma_alloc_coherent(NULL, TX_REG_DESC_SIZE * | 475 | priv->tx_desc_base = dma_alloc_coherent(NULL, TX_REG_DESC_SIZE * |
472 | TX_DESC_NUM, &priv->tx_base, | 476 | TX_DESC_NUM, &priv->tx_base, |