Welcome to the Linux Foundation Forum!

network device No buffer Space

Hello i created Network driver that uses the uart port to send and recive. My driver works with some issues. I was able to ping but always afther a few pings i get

ping: sendmsg: No buffer space available driver

I checked the kernel logs but i could not see anything.

this is how i recive data:

  1. struct stm32_port *stm32_port = netdev_priv(my_net);
  2. struct sk_buff *skb;
  3. unsigned char *dma_start;
  4.  
  5. dma_start = stm32_port->rx_buf + (RX_BUF_L - stm32_port->last_res);
  6. print_hex_dump(KERN_DEBUG, "data: ", DUMP_PREFIX_OFFSET, 16, 1, dma_start, 16, true);
  7.  
  8. skb = dev_alloc_skb(dma_size + 2);
  9. if (!skb) {
  10. if (printk_ratelimit( ))
  11. printk(KERN_NOTICE "snull rx: low on mem - packet dropped\n");
  12. my_net->stats.rx_dropped++;
  13. //goto error;
  14. }
  15.  
  16. memcpy(skb_put(skb, dma_size), dma_start, dma_size);
  17.  
  18. /* Write metadata, and then pass to the receive level */
  19. skb->dev = my_net;
  20. skb->protocol = eth_type_trans(skb, my_net);
  21. skb->ip_summed = CHECKSUM_NONE; // let the OS check the checksum
  22. my_net->stats.rx_packets++;
  23. my_net->stats.rx_bytes += dma_size;
  24. netif_rx(skb);
  25.  
  26. port->icount.rx += dma_size;
  27. stm32_port->last_res -= dma_size;
  28. if (stm32_port->last_res == 0)
  29. stm32_port->last_res = RX_BUF_L; //dma_count

Here is how i send my data:

  1. struct stm32_port *lp = netdev_priv(ndev);
  2. struct uart_port *port = &lp->port;
  3. struct sk_buff *sk_buff;
  4. struct dma_async_tx_descriptor *desc = NULL;
  5. struct stm32_usart_offsets *ofs = &lp->info->ofs;
  6. unsigned pktlen = skb->len;
  7. dma_cookie_t cookie;
  8. int ret = 0;
  9.  
  10. //print_hex_dump(KERN_DEBUG, "data: ", DUMP_PREFIX_OFFSET, 16, 1, skb->data, 16, true);
  11.  
  12. netif_stop_queue(ndev);
  13.  
  14. sk_buff = skb_get(skb);
  15.  
  16. if (ofs->icr == UNDEF_REG){
  17. stm32_usart_clr_bits(port, ofs->isr, USART_SR_TC);
  18. }else{
  19. writel_relaxed(USART_ICR_TCCF, port->membase + ofs->icr);
  20. }
  21.  
  22. memcpy(&lp->tx_buf[0], sk_buff->data, pktlen);
  23. desc = dmaengine_prep_slave_single(lp->tx_ch,
  24. lp->tx_dma_buf,
  25. pktlen,
  26. DMA_MEM_TO_DEV,
  27. DMA_PREP_INTERRUPT);
  28.  
  29. if (!desc){
  30. goto fallback_err;
  31. }
  32.  
  33. cookie = dmaengine_submit(desc);
  34. ret = dma_submit_error(cookie);
  35. if (ret) {
  36. /* dma no yet started, safe to free resources */
  37. dmaengine_terminate_async(lp->tx_ch);
  38. goto fallback_err;
  39. }
  40.  
  41. /* Issue pending DMA TX requests */
  42. dma_async_issue_pending(lp->tx_ch);
  43.  
  44. stm32_usart_set_bits(port, ofs->cr3, USART_CR3_DMAT);
  45.  
  46. /* rely on TXE irq (mask or unmask) for sending remaining data */
  47. stm32_usart_tx_interrupt_disable(port);
  48.  
  49. ndev->stats.tx_packets++;
  50. ndev->stats.tx_bytes += pktlen;
  51.  
  52. fallback_err:
  53. skb_tx_timestamp(skb);
  54. dev_kfree_skb (skb);
  55. netif_start_queue(ndev);
  56. return NETDEV_TX_OK;

The error from the icmp always apears around 13 Pings when i start again same.

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Categories

Upcoming Training