Initial commit: TXW82x FPV v2.7.0.7-42229 SDK + project sources

This commit is contained in:
2026-07-06 11:30:13 +08:00
commit e76462eeb7
3451 changed files with 1415300 additions and 0 deletions

38
sdk/include/lib/skb/skb.h Normal file
View File

@@ -0,0 +1,38 @@
#ifndef _HGIC_SKB_H_
#define _HGIC_SKB_H_
#include "lib/skb/skbuff.h"
#include "lib/skb/skbpool.h"
#ifdef __cplusplus
extern "C" {
#endif
#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);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,42 @@
#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);
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);
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

View File

@@ -0,0 +1,34 @@
#ifndef _HGIC_SKBPOOL_H_
#define _HGIC_SKBPOOL_H_
#ifdef __cplusplus
extern "C" {
#endif
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),
SKBPOOL_FLAGS_ALIGN_32 = BIT(4),
SKBPOOL_FLAGS_TAIL_ALIGN_4 = BIT(5),
SKBPOOL_FLAGS_TAIL_ALIGN_16 = BIT(6),
SKBPOOL_FLAGS_TAIL_ALIGN_32 = BIT(7),
};
extern uint32 skbpool_time(void);
extern int32 skbpool_init(uint32 start_addr, uint32 end_addr, uint32 max, uint8 flags);
extern uint32 skbpool_freesize(int8 tx);
extern uint32 skbpool_tx_used(void);
extern uint32 skbpool_rx_used(void);
extern int32 skbpool_collect_init(void);
extern int32 skbpool_totalsize(void);
extern void skbpool_status(uint32 *status_buf, uint32 size, uint32 mini_size);
extern int32 skbpool_max_usage(uint8 tx_max, uint8 rx_max);
extern int32 skbpool_add_region(uint32 start_addr, uint32 end_addr);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,64 @@
#ifndef _HGIC_SKBUFF_H_
#define _HGIC_SKBUFF_H_
#ifdef __cplusplus
extern "C" {
#endif
#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, unreachable:1, rev:3;
uint64 lifetime;
void *txinfo;
void *sta;
/////////////////////////////////////
atomic_t users;
void (*free)(void *free_priv, struct sk_buff *skb);
void *free_priv;
};
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);
#ifdef __cplusplus
}
#endif
#endif