Skip to content

Commit e085733

Browse files
committed
pktmem: Fix warning
JIRA: RTOS-555
1 parent d80d6e0 commit e085733

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

drivers/pktmem.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
*
99
* %LICENSE%
1010
*/
11+
1112
#include "physmmap.h"
1213
#include "pktmem.h"
1314
#include "lwip/mem.h"
@@ -16,17 +17,17 @@
1617

1718
#include <stdio.h>
1819
#include <string.h>
20+
#include <arch.h>
1921

2022

2123
#define CACHE_LINE_SIZE 64
22-
#define PAGE_SIZE 4096
2324

2425
#define TRUE_LRU 0
2526

2627

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)) */
3031
#define PKT_BUF_CACHE_SIZE 16
3132

3233

@@ -65,8 +66,8 @@ static void net_listDel(buf_page_head_t *ph)
6566

6667
static void net_freePktBuf(void *p)
6768
{
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;
7071
unsigned old_mask;
7172

7273
old_mask = ph->free_mask;
@@ -76,7 +77,7 @@ static void net_freePktBuf(void *p)
7677
if (pkt_bufs_free > PKT_BUF_CACHE_SIZE && ph->free_mask == (1 << PKT_BUF_CNT) - 1) {
7778
if (old_mask)
7879
net_listDel(ph);
79-
munmap(ph, PAGE_SIZE);
80+
munmap(ph, _PAGE_SIZE);
8081
pkt_bufs_free -= PKT_BUF_CNT;
8182
return;
8283
}
@@ -113,7 +114,7 @@ static ssize_t net_allocPktBuf(void **bufp)
113114
if (!pkt_bufs_free) {
114115
SYS_ARCH_UNPROTECT(old_level);
115116

116-
ph = dmammap(PAGE_SIZE);
117+
ph = dmammap(_PAGE_SIZE);
117118
if (!ph) {
118119
printf("mmap: no memory?\n");
119120
return 0;

0 commit comments

Comments
 (0)