Skip to content

Commit

Permalink
pktmem: Fix warning
Browse files Browse the repository at this point in the history
JIRA: RTOS-555
  • Loading branch information
agkaminski committed Aug 10, 2023
1 parent d80d6e0 commit 5d1b27d
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions drivers/pktmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*
* %LICENSE%
*/

#include "physmmap.h"
#include "pktmem.h"
#include "lwip/mem.h"
Expand All @@ -16,17 +17,17 @@

#include <stdio.h>
#include <string.h>
#include <arch.h>


#define CACHE_LINE_SIZE 64
#define PAGE_SIZE 4096

#define TRUE_LRU 0


#define PKT_BUF_SIZE (2048 - CACHE_LINE_SIZE)
#define PKT_BUF_CNT (size_t)((PAGE_SIZE - CACHE_LINE_SIZE) / PKT_BUF_SIZE)
#define PKT_BUF_IDX 11 // log2(PAGE_SIZE) - ceil(log2(PKT_BUF_CNT))
#define PKT_BUF_CNT (size_t)((_PAGE_SIZE - CACHE_LINE_SIZE) / PKT_BUF_SIZE)
#define PKT_BUF_IDX 11 /* log2(_PAGE_SIZE) - ceil(log2(PKT_BUF_CNT)) */
#define PKT_BUF_CACHE_SIZE 16


Expand Down Expand Up @@ -65,8 +66,8 @@ static void net_listDel(buf_page_head_t *ph)

static void net_freePktBuf(void *p)
{
buf_page_head_t *ph = (void *)((uintptr_t)p & ~(PAGE_SIZE - 1));
unsigned which = ((size_t)p & (PAGE_SIZE - 1)) >> PKT_BUF_IDX;
buf_page_head_t *ph = (void *)((uintptr_t)p & ~(_PAGE_SIZE - 1));
unsigned which = ((size_t)p & (_PAGE_SIZE - 1)) >> PKT_BUF_IDX;
unsigned old_mask;

old_mask = ph->free_mask;
Expand All @@ -76,7 +77,7 @@ static void net_freePktBuf(void *p)
if (pkt_bufs_free > PKT_BUF_CACHE_SIZE && ph->free_mask == (1 << PKT_BUF_CNT) - 1) {
if (old_mask)
net_listDel(ph);
munmap(ph, PAGE_SIZE);
munmap(ph, _PAGE_SIZE);
pkt_bufs_free -= PKT_BUF_CNT;
return;
}
Expand Down Expand Up @@ -113,7 +114,7 @@ static ssize_t net_allocPktBuf(void **bufp)
if (!pkt_bufs_free) {
SYS_ARCH_UNPROTECT(old_level);

ph = dmammap(PAGE_SIZE);
ph = dmammap(_PAGE_SIZE);
if (!ph) {
printf("mmap: no memory?\n");
return 0;
Expand Down

0 comments on commit 5d1b27d

Please sign in to comment.