1 #include <linux/skbuff.h>
5 void resize_skb_rx(struct sk_buff
*skb
, unsigned int size
, int is_cell
)
7 if((u32
)skb
< 0x80000000)
10 printk("resize_skb_rx problem: skb = %08X, size = %d, is_cell = %d\n", (u32
)skb
, size
, is_cell
);
13 skb
->data
= (unsigned char*)(((u32
)skb
->head
+ 16 + (DMA_ALIGNMENT
- 1)) & ~(DMA_ALIGNMENT
- 1));
14 skb
->tail
= skb
->data
;
16 /* Set up other state */
19 #if defined(CONFIG_IMQ) || defined (CONFIG_IMQ_MODULE)
26 struct sk_buff
* alloc_skb_rx(void)
30 /* allocate memroy including trailer and padding */
31 skb
= dev_alloc_skb(ppe_dev
.aal5
.rx_buffer_size
+ DMA_ALIGNMENT
);
34 /* must be burst length alignment */
35 if ( ((u32
)skb
->data
& (DMA_ALIGNMENT
- 1)) != 0 )
36 skb_reserve(skb
, ~((u32
)skb
->data
+ (DMA_ALIGNMENT
- 1)) & (DMA_ALIGNMENT
- 1));
37 /* put skb in reserved area "skb->data - 4" */
38 *((u32
*)skb
->data
- 1) = (u32
)skb
;
39 /* invalidate cache */
40 dma_cache_inv((unsigned long)skb
->head
, (u32
)skb
->end
- (u32
)skb
->head
);
45 void atm_free_tx_skb_vcc(struct sk_buff
*skb
)
49 if ( (u32
)skb
<= 0x80000000 )
52 printk("atm_free_tx_skb_vcc: skb = %08X\n", (u32
)skb
);
56 vcc
= ATM_SKB(skb
)->vcc
;
57 if ( vcc
!= NULL
&& vcc
->pop
!= NULL
)
59 if ( atomic_read(&skb
->users
) == 0 )
62 printk("atm_free_tx_skb_vcc(vcc->pop): skb->users == 0, skb = %08X\n", (u32
)skb
);
69 if ( atomic_read(&skb
->users
) == 0 )
72 printk("atm_free_tx_skb_vcc(dev_kfree_skb_any): skb->users == 0, skb = %08X\n", (u32
)skb
);
75 dev_kfree_skb_any(skb
);
79 struct sk_buff
* alloc_skb_tx(unsigned int size
)
83 /* allocate memory including header and padding */
84 size
+= TX_INBAND_HEADER_LENGTH
+ MAX_TX_PACKET_ALIGN_BYTES
+ MAX_TX_PACKET_PADDING_BYTES
;
85 size
&= ~(DMA_ALIGNMENT
- 1);
86 skb
= dev_alloc_skb(size
+ DMA_ALIGNMENT
);
87 /* must be burst length alignment */
89 skb_reserve(skb
, (~((u32
)skb
->data
+ (DMA_ALIGNMENT
- 1)) & (DMA_ALIGNMENT
- 1)) + TX_INBAND_HEADER_LENGTH
);
93 struct sk_buff
* atm_alloc_tx(struct atm_vcc
*vcc
, unsigned int size
)
99 if ( ((size
+ TX_INBAND_HEADER_LENGTH
+ MAX_TX_PACKET_ALIGN_BYTES
+ MAX_TX_PACKET_PADDING_BYTES
) & ~(DMA_ALIGNMENT
- 1)) > ppe_dev
.aal5
.tx_max_packet_size
)
101 printk("atm_alloc_tx: oversize packet\n");
104 /* send buffer overflow */
105 if ( atomic_read(&vcc
->sk
.sk_wmem_alloc
) && !atm_may_send(vcc
, size
) )
107 printk("atm_alloc_tx: send buffer overflow\n");
110 conn
= find_vcc(vcc
);
113 printk("atm_alloc_tx: unknown VCC\n");
117 skb
= dev_alloc_skb(size
);
120 printk("atm_alloc_tx: sk buffer is used up\n");
123 #define ATM_PDU_OVHD 0
124 atomic_add(skb
->truesize
+ ATM_PDU_OVHD
, &vcc
->sk
.sk_wmem_alloc
);