bool vnt_receive_frame(struct vnt_private *priv, struct vnt_rx_desc *curr_rd) { struct vnt_rd_info *rd_info = curr_rd->rd_info; struct sk_buff *skb; u16 frame_size; skb = rd_info->skb; dma_unmap_single(&priv->pcid->dev, rd_info->skb_dma, priv->rx_buf_sz, DMA_FROM_DEVICE); frame_size = le16_to_cpu(curr_rd->rd1.req_count) - le16_to_cpu(curr_rd->rd0.res_count); if ((frame_size > 2364) || (frame_size < 33)) { /* Frame Size error drop this packet.*/ dev_dbg(&priv->pcid->dev, "Wrong frame size %d\n", frame_size); dev_kfree_skb_irq(skb); return true; } if (vnt_rx_data(priv, skb, frame_size)) return true; dev_kfree_skb_irq(skb); return true; }
bool vnt_receive_frame(struct vnt_private *priv, PSRxDesc curr_rd) { PDEVICE_RD_INFO rd_info = curr_rd->pRDInfo; struct sk_buff *skb; u16 frame_size; skb = rd_info->skb; dma_unmap_single(&priv->pcid->dev, rd_info->skb_dma, priv->rx_buf_sz, DMA_FROM_DEVICE); frame_size = le16_to_cpu(curr_rd->m_rd1RD1.wReqCount) - cpu_to_le16(curr_rd->m_rd0RD0.wResCount); if ((frame_size > 2364) || (frame_size < 33)) { /* Frame Size error drop this packet.*/ dev_dbg(&priv->pcid->dev, "Wrong frame size %d\n", frame_size); dev_kfree_skb_irq(skb); return true; } if (vnt_rx_data(priv, skb, frame_size)) return true; dev_kfree_skb_irq(skb); return true; }
static void vnt_submit_rx_urb_complete(struct urb *urb) { struct vnt_rcb *rcb = urb->context; struct vnt_private *priv = rcb->priv; switch (urb->status) { case 0: break; case -ECONNRESET: case -ENOENT: case -ESHUTDOWN: return; case -ETIMEDOUT: default: dev_dbg(&priv->usb->dev, "BULK In failed %d\n", urb->status); break; } if (urb->actual_length) { if (vnt_rx_data(priv, rcb, urb->actual_length)) { rcb->skb = dev_alloc_skb(priv->rx_buf_sz); if (!rcb->skb) { dev_dbg(&priv->usb->dev, "Failed to re-alloc rx skb\n"); rcb->in_use = false; return; } } else { skb_push(rcb->skb, skb_headroom(rcb->skb)); skb_trim(rcb->skb, 0); } urb->transfer_buffer = skb_put(rcb->skb, skb_tailroom(rcb->skb)); } if (usb_submit_urb(urb, GFP_ATOMIC)) { dev_dbg(&priv->usb->dev, "Failed to re submit rx skb\n"); rcb->in_use = false; } }