8
8
*
9
9
* %LICENSE%
10
10
*/
11
+
11
12
#include "physmmap.h"
12
13
#include "pktmem.h"
13
14
#include "lwip/mem.h"
16
17
17
18
#include <stdio.h>
18
19
#include <string.h>
20
+ #include <arch.h>
19
21
20
22
21
23
#define CACHE_LINE_SIZE 64
22
- #define PAGE_SIZE 4096
23
24
24
25
#define TRUE_LRU 0
25
26
26
27
27
- #define PKT_BUF_SIZE (2048 - CACHE_LINE_SIZE)
28
- #define PKT_BUF_CNT (size_t)((PAGE_SIZE - CACHE_LINE_SIZE) / PKT_BUF_SIZE)
29
- #define PKT_BUF_IDX 11 // log2(PAGE_SIZE ) - ceil(log2(PKT_BUF_CNT))
28
+ #define PKT_BUF_SIZE (2048 - CACHE_LINE_SIZE)
29
+ #define PKT_BUF_CNT (size_t)((_PAGE_SIZE - CACHE_LINE_SIZE) / PKT_BUF_SIZE)
30
+ #define PKT_BUF_IDX 11 /* log2(_PAGE_SIZE ) - ceil(log2(PKT_BUF_CNT)) */
30
31
#define PKT_BUF_CACHE_SIZE 16
31
32
32
33
@@ -65,8 +66,8 @@ static void net_listDel(buf_page_head_t *ph)
65
66
66
67
static void net_freePktBuf (void * p )
67
68
{
68
- buf_page_head_t * ph = (void * )((uintptr_t )p & ~(PAGE_SIZE - 1 ));
69
- unsigned which = ((size_t )p & (PAGE_SIZE - 1 )) >> PKT_BUF_IDX ;
69
+ buf_page_head_t * ph = (void * )((uintptr_t )p & ~(_PAGE_SIZE - 1 ));
70
+ unsigned which = ((size_t )p & (_PAGE_SIZE - 1 )) >> PKT_BUF_IDX ;
70
71
unsigned old_mask ;
71
72
72
73
old_mask = ph -> free_mask ;
@@ -76,7 +77,7 @@ static void net_freePktBuf(void *p)
76
77
if (pkt_bufs_free > PKT_BUF_CACHE_SIZE && ph -> free_mask == (1 << PKT_BUF_CNT ) - 1 ) {
77
78
if (old_mask )
78
79
net_listDel (ph );
79
- munmap (ph , PAGE_SIZE );
80
+ munmap (ph , _PAGE_SIZE );
80
81
pkt_bufs_free -= PKT_BUF_CNT ;
81
82
return ;
82
83
}
@@ -113,7 +114,7 @@ static ssize_t net_allocPktBuf(void **bufp)
113
114
if (!pkt_bufs_free ) {
114
115
SYS_ARCH_UNPROTECT (old_level );
115
116
116
- ph = dmammap (PAGE_SIZE );
117
+ ph = dmammap (_PAGE_SIZE );
117
118
if (!ph ) {
118
119
printf ("mmap: no memory?\n" );
119
120
return 0 ;
0 commit comments