pure sdk for main

This commit is contained in:
divadiow
2025-08-27 09:51:58 +01:00
parent f0d033f1c9
commit 0571416e7c
3283 changed files with 1577720 additions and 1 deletions
+32
View File
@@ -0,0 +1,32 @@
#ifndef _HGIC_SKB_H_
#define _HGIC_SKB_H_
//#define SKB_TRACE
#include "lib/skb/skbuff.h"
#include "lib/skb/skbpool.h"
#ifdef SKB_TRACE
#define alloc_rx_skb(s) _alloc_rx_skb(s, __FUNCTION__, __LINE__)
#define alloc_tx_skb(s) _alloc_tx_skb(s, __FUNCTION__, __LINE__)
#define alloc_skb(s) _alloc_skb(s, __FUNCTION__, __LINE__)
#define skb_copy(s, f) _skb_copy(s, f, __FUNCTION__, __LINE__)
#define skb_clone(s, f) _skb_clone(s, f, __FUNCTION__, __LINE__)
#else
extern struct sk_buff *alloc_rx_skb(uint32 size);
extern struct sk_buff *alloc_tx_skb(uint32 size);
extern struct sk_buff *alloc_skb(uint32 size);
extern struct sk_buff *skb_copy(const struct sk_buff *skb, int32 flags);
extern struct sk_buff *skb_clone(struct sk_buff *skb, int32 flags);
#endif
extern struct sk_buff *_alloc_rx_skb(uint32 size, char *func, int32 line);
extern struct sk_buff *_alloc_tx_skb(uint32 size, char *func, int32 line);
extern struct sk_buff *_alloc_skb(uint32 size, char *func, int32 line);
extern struct sk_buff *_skb_copy(const struct sk_buff *skb, int32 flags, char *func, int32 line);
extern struct sk_buff *_skb_clone(struct sk_buff *skb, int32 flags, char *func, int32 line);
extern void kfree_skb(struct sk_buff *skb);
extern void copy_skb_header(struct sk_buff *n, const struct sk_buff *old);
extern struct sk_buff *alloc_heapskb(uint32 size);
#endif
+52
View File
@@ -0,0 +1,52 @@
#ifndef __SKB_LIST_H__
#define __SKB_LIST_H__
#include "lib/skb/skb.h"
#ifdef __cplusplus
extern "C" {
#endif
struct skb_list {
struct sk_buff *next, *prev;
uint32 count;
};
extern int32 skb_list_init(struct skb_list *list);
extern int32 skb_list_destroy(struct skb_list *list);
extern uint32 skb_list_count(struct skb_list *list);
#ifdef SKB_TRACE
#define skb_list_queue(list, skb) _skb_list_queue(list, skb, __FUNCTION__, __LINE__)
#define skb_list_dequeue(list) _skb_list_dequeue(list, __FUNCTION__, __LINE__)
#define skb_list_first(list) _skb_list_first(list, __FUNCTION__, __LINE__)
#define skb_list_last(list) _skb_list_last(list, __FUNCTION__, __LINE__)
#define skb_list_unlink(skb, list) _skb_list_unlink(skb, list, __FUNCTION__, __LINE__)
#define skb_list_queue_before(list, next, newsk) _skb_list_queue_before(list, next, newsk, __FUNCTION__, __LINE__)
#define skb_list_queue_after(list, prev, newsk) _skb_list_queue_after(list, prev, newsk, __FUNCTION__, __LINE__)
#else
extern int32 skb_list_queue(struct skb_list *list, struct sk_buff *skb);
extern struct sk_buff *skb_list_dequeue(struct skb_list *list);
extern struct sk_buff *skb_list_first(struct skb_list *list);
extern struct sk_buff *skb_list_last(struct skb_list *list);
extern int32 skb_list_unlink(struct sk_buff *skb, struct skb_list *list);
extern int32 skb_list_queue_before(struct skb_list *list, struct sk_buff *next, struct sk_buff *newsk);
extern int32 skb_list_queue_after(struct skb_list *list, struct sk_buff *prev, struct sk_buff *newsk);
#endif
extern int32 skb_list_move(struct skb_list *to_list, struct skb_list *from_list);
extern int32 _skb_list_queue(struct skb_list *list, struct sk_buff *skb, char *func, int32 line);
extern struct sk_buff *_skb_list_dequeue(struct skb_list *list, char *func, int32 line);
extern struct sk_buff *_skb_list_first(struct skb_list *list, char *func, int32 line);
extern struct sk_buff *_skb_list_last(struct skb_list *list, char *func, int32 line);
extern int32 _skb_list_unlink(struct sk_buff *skb, struct skb_list *list, char *func, int32 line);
extern int32 _skb_list_queue_before(struct skb_list *list, struct sk_buff *next, struct sk_buff *newsk, char *func, int32 line);
extern int32 _skb_list_queue_after(struct skb_list *list, struct sk_buff *prev, struct sk_buff *newsk, char *func, int32 line);
#ifdef __cplusplus
}
#endif
#endif
+18
View File
@@ -0,0 +1,18 @@
#ifndef _HGIC_SKBPOOL_H_
#define _HGIC_SKBPOOL_H_
enum SKBPOOL_FLAGS {
SKBPOOL_FLAGS_MGMTFRM_INHEAP = BIT(0),
SKBPOOL_FLAGS_LEAK_TRACE = BIT(1),
SKBPOOL_FLAGS_OVERFLOW_CHECK = BIT(2),
SKBPOOL_FLAGS_ALIGN_16 = BIT(3),
};
extern int32 skbpool_init(uint32 addr, uint32 size, uint32 max, uint8 flags);
extern uint32 skbpool_freesize(int8 tx);
extern int32 skbpool_collect_init(void);
extern void skbpool_status(uint32 *status_buf, uint32 size, uint32 mini_size);
extern int32 skbpool_max_usage(uint8 max);
extern int32 skbpool_add_region(uint32 addr, uint32 size);
#endif
+63
View File
@@ -0,0 +1,63 @@
#ifndef _HGIC_SKBUFF_H_
#define _HGIC_SKBUFF_H_
#include <osal/atomic.h>
#include <osal/string.h>
#include "list.h"
struct sk_buff {
struct sk_buff *next, *prev, *clone;
uint8 cb[12];
uint8 *tail;
uint8 *data;
uint8 *head;
uint8 *end;
/* clear below flags when skb free */
uint16 len;
uint16 priority:4, acked: 1, cloned: 1, lmaced: 1, pkt_type: 3, tx: 1, src_in: 1;
uint64 lifetime;
void *txinfo;
void *sta;
/////////////////////////////////////
atomic_t users;
void (*free)(void *free_priv, struct sk_buff *skb);
void *free_priv;
#ifdef SKB_TRACE
char *func;
int32 line;
uint32 magic;
#endif
};
uint8 *skb_put(struct sk_buff *skb, uint32 len);
uint8 *skb_push(struct sk_buff *skb, uint32 len);
uint8 *skb_pull(struct sk_buff *skb, uint32 len);
void skb_reserve(struct sk_buff *skb, int len);
static inline int skb_tailroom(const struct sk_buff *skb)
{
return (skb->end - skb->tail);
}
static inline unsigned int skb_headroom(const struct sk_buff *skb)
{
return skb->data - skb->head;
}
static inline int skb_dataroom(const struct sk_buff *skb)
{
return (skb->end - skb->data);
}
static inline struct sk_buff *skb_get(struct sk_buff *skb)
{
atomic_inc(&skb->users);
return skb;
}
void *skb_put_zero(struct sk_buff *skb, unsigned int len);
void *skb_put_data(struct sk_buff *skb, const void *data, unsigned int len);
#endif