LinuxKPI: SKB update
- skb_reset_tail_pointer(): we do not do offsets so do a plain reset - skb_add_rx_frag(): adjust data_len to keep track of the frag - based on that implement skb_is_nonlinear() and skb_linearize() - implement build_skb() and adjust linuxkpi_kfree_skb() and ddb macro. Sponsored by: The FreeBSD Foundation (partially) MFC after: 3 days
This commit is contained in:
parent
7a6bcfb44d
commit
5504bd59a3
@ -143,7 +143,8 @@ struct sk_buff {
|
|||||||
uint16_t l4hdroff; /* transport header offset from *head */
|
uint16_t l4hdroff; /* transport header offset from *head */
|
||||||
uint32_t priority;
|
uint32_t priority;
|
||||||
uint16_t qmap; /* queue mapping */
|
uint16_t qmap; /* queue mapping */
|
||||||
uint16_t _spareu16_0;
|
uint16_t _flags; /* Internal flags. */
|
||||||
|
#define _SKB_FLAGS_SKBEXTFRAG 0x0001
|
||||||
enum sk_buff_pkt_type pkt_type;
|
enum sk_buff_pkt_type pkt_type;
|
||||||
|
|
||||||
/* "Scratch" area for layers to store metadata. */
|
/* "Scratch" area for layers to store metadata. */
|
||||||
@ -174,6 +175,7 @@ struct sk_buff {
|
|||||||
|
|
||||||
struct sk_buff *linuxkpi_alloc_skb(size_t, gfp_t);
|
struct sk_buff *linuxkpi_alloc_skb(size_t, gfp_t);
|
||||||
struct sk_buff *linuxkpi_dev_alloc_skb(size_t, gfp_t);
|
struct sk_buff *linuxkpi_dev_alloc_skb(size_t, gfp_t);
|
||||||
|
struct sk_buff *linuxkpi_build_skb(void *, size_t);
|
||||||
void linuxkpi_kfree_skb(struct sk_buff *);
|
void linuxkpi_kfree_skb(struct sk_buff *);
|
||||||
|
|
||||||
struct sk_buff *linuxkpi_skb_copy(struct sk_buff *, gfp_t);
|
struct sk_buff *linuxkpi_skb_copy(struct sk_buff *, gfp_t);
|
||||||
@ -241,6 +243,16 @@ dev_kfree_skb_irq(struct sk_buff *skb)
|
|||||||
dev_kfree_skb(skb);
|
dev_kfree_skb(skb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline struct sk_buff *
|
||||||
|
build_skb(void *data, unsigned int fragsz)
|
||||||
|
{
|
||||||
|
struct sk_buff *skb;
|
||||||
|
|
||||||
|
skb = linuxkpi_build_skb(data, fragsz);
|
||||||
|
SKB_TRACE(skb);
|
||||||
|
return (skb);
|
||||||
|
}
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
/* XXX BZ review this one for terminal condition as Linux "queues" are special. */
|
/* XXX BZ review this one for terminal condition as Linux "queues" are special. */
|
||||||
@ -467,6 +479,7 @@ skb_add_rx_frag(struct sk_buff *skb, int fragno, struct page *page,
|
|||||||
shinfo->frags[fragno].size = size;
|
shinfo->frags[fragno].size = size;
|
||||||
shinfo->nr_frags = fragno + 1;
|
shinfo->nr_frags = fragno + 1;
|
||||||
skb->len += size;
|
skb->len += size;
|
||||||
|
skb->data_len += size;
|
||||||
skb->truesize += truesize;
|
skb->truesize += truesize;
|
||||||
|
|
||||||
/* XXX TODO EXTEND truesize? */
|
/* XXX TODO EXTEND truesize? */
|
||||||
@ -748,13 +761,6 @@ skb_frag_size(const skb_frag_t *frag)
|
|||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool
|
|
||||||
skb_is_nonlinear(struct sk_buff *skb)
|
|
||||||
{
|
|
||||||
SKB_TRACE(skb);
|
|
||||||
return ((skb->data_len > 0) ? true : false);
|
|
||||||
}
|
|
||||||
|
|
||||||
#define skb_walk_frags(_skb, _frag) \
|
#define skb_walk_frags(_skb, _frag) \
|
||||||
for ((_frag) = (_skb); false; (_frag)++)
|
for ((_frag) = (_skb); false; (_frag)++)
|
||||||
|
|
||||||
@ -859,6 +865,13 @@ skb_network_header(struct sk_buff *skb)
|
|||||||
return (skb->head + skb->l3hdroff);
|
return (skb->head + skb->l3hdroff);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline bool
|
||||||
|
skb_is_nonlinear(struct sk_buff *skb)
|
||||||
|
{
|
||||||
|
SKB_TRACE(skb);
|
||||||
|
return ((skb->data_len > 0) ? true : false);
|
||||||
|
}
|
||||||
|
|
||||||
static inline int
|
static inline int
|
||||||
__skb_linearize(struct sk_buff *skb)
|
__skb_linearize(struct sk_buff *skb)
|
||||||
{
|
{
|
||||||
@ -867,6 +880,13 @@ __skb_linearize(struct sk_buff *skb)
|
|||||||
return (ENXIO);
|
return (ENXIO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
skb_linearize(struct sk_buff *skb)
|
||||||
|
{
|
||||||
|
|
||||||
|
return (skb_is_nonlinear(skb) ? __skb_linearize(skb) : 0);
|
||||||
|
}
|
||||||
|
|
||||||
static inline int
|
static inline int
|
||||||
pskb_expand_head(struct sk_buff *skb, int x, int len, gfp_t gfp)
|
pskb_expand_head(struct sk_buff *skb, int x, int len, gfp_t gfp)
|
||||||
{
|
{
|
||||||
@ -940,7 +960,10 @@ skb_reset_tail_pointer(struct sk_buff *skb)
|
|||||||
{
|
{
|
||||||
|
|
||||||
SKB_TRACE(skb);
|
SKB_TRACE(skb);
|
||||||
|
#ifdef SKB_DOING_OFFSETS_US_NOT
|
||||||
skb->tail = (uint8_t *)(uintptr_t)(skb->data - skb->head);
|
skb->tail = (uint8_t *)(uintptr_t)(skb->data - skb->head);
|
||||||
|
#endif
|
||||||
|
skb->tail = skb->data;
|
||||||
SKB_TRACE(skb);
|
SKB_TRACE(skb);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -969,14 +992,6 @@ skb_copy_from_linear_data(const struct sk_buff *skb, void *dst, size_t len)
|
|||||||
memcpy(dst, skb->data, len);
|
memcpy(dst, skb->data, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline struct sk_buff *
|
|
||||||
build_skb(void *data, unsigned int fragsz)
|
|
||||||
{
|
|
||||||
|
|
||||||
SKB_TODO();
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline int
|
static inline int
|
||||||
skb_pad(struct sk_buff *skb, int pad)
|
skb_pad(struct sk_buff *skb, int pad)
|
||||||
{
|
{
|
||||||
@ -1002,15 +1017,6 @@ napi_consume_skb(struct sk_buff *skb, int budget)
|
|||||||
SKB_TODO();
|
SKB_TODO();
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool
|
|
||||||
skb_linearize(struct sk_buff *skb)
|
|
||||||
{
|
|
||||||
|
|
||||||
SKB_TRACE(skb);
|
|
||||||
SKB_TODO();
|
|
||||||
return (false);
|
|
||||||
}
|
|
||||||
|
|
||||||
#define SKB_WITH_OVERHEAD(_s) \
|
#define SKB_WITH_OVERHEAD(_s) \
|
||||||
(_s) - ALIGN(sizeof(struct skb_shared_info), CACHE_LINE_SIZE)
|
(_s) - ALIGN(sizeof(struct skb_shared_info), CACHE_LINE_SIZE)
|
||||||
|
|
||||||
|
@ -150,6 +150,28 @@ linuxkpi_dev_alloc_skb(size_t size, gfp_t gfp)
|
|||||||
return (skb);
|
return (skb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct sk_buff *
|
||||||
|
linuxkpi_build_skb(void *data, size_t fragsz)
|
||||||
|
{
|
||||||
|
struct sk_buff *skb;
|
||||||
|
|
||||||
|
if (data == NULL || fragsz == 0)
|
||||||
|
return (NULL);
|
||||||
|
|
||||||
|
/* Just allocate a skb without data area. */
|
||||||
|
skb = linuxkpi_alloc_skb(0, GFP_KERNEL);
|
||||||
|
if (skb == NULL)
|
||||||
|
return (NULL);
|
||||||
|
|
||||||
|
skb->_flags |= _SKB_FLAGS_SKBEXTFRAG;
|
||||||
|
skb->truesize = fragsz;
|
||||||
|
skb->head = skb->data = data;
|
||||||
|
skb_reset_tail_pointer(skb); /* XXX is that correct? */
|
||||||
|
skb->end = (void *)((uintptr_t)skb->head + fragsz);
|
||||||
|
|
||||||
|
return (skb);
|
||||||
|
}
|
||||||
|
|
||||||
struct sk_buff *
|
struct sk_buff *
|
||||||
linuxkpi_skb_copy(struct sk_buff *skb, gfp_t gfp)
|
linuxkpi_skb_copy(struct sk_buff *skb, gfp_t gfp)
|
||||||
{
|
{
|
||||||
@ -233,6 +255,13 @@ linuxkpi_kfree_skb(struct sk_buff *skb)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((skb->_flags & _SKB_FLAGS_SKBEXTFRAG) != 0) {
|
||||||
|
void *p;
|
||||||
|
|
||||||
|
p = skb->head;
|
||||||
|
skb_free_frag(p);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef __LP64__
|
#ifdef __LP64__
|
||||||
if (__predict_true(linuxkpi_skb_memlimit == 0))
|
if (__predict_true(linuxkpi_skb_memlimit == 0))
|
||||||
free(skb, M_LKPISKB);
|
free(skb, M_LKPISKB);
|
||||||
@ -268,6 +297,7 @@ DB_SHOW_COMMAND(skb, db_show_skb)
|
|||||||
skb->pkt_type, skb->dev, skb->sk);
|
skb->pkt_type, skb->dev, skb->sk);
|
||||||
db_printf("\tcsum_offset %d csum_start %d ip_summed %d protocol %d\n",
|
db_printf("\tcsum_offset %d csum_start %d ip_summed %d protocol %d\n",
|
||||||
skb->csum_offset, skb->csum_start, skb->ip_summed, skb->protocol);
|
skb->csum_offset, skb->csum_start, skb->ip_summed, skb->protocol);
|
||||||
|
db_printf("\t_flags %#06x\n", skb->_flags); /* XXX-BZ print names? */
|
||||||
db_printf("\thead %p data %p tail %p end %p\n",
|
db_printf("\thead %p data %p tail %p end %p\n",
|
||||||
skb->head, skb->data, skb->tail, skb->end);
|
skb->head, skb->data, skb->tail, skb->end);
|
||||||
db_printf("\tshinfo %p m %p m_free_func %p\n",
|
db_printf("\tshinfo %p m %p m_free_func %p\n",
|
||||||
@ -298,7 +328,6 @@ DB_SHOW_COMMAND(skb, db_show_skb)
|
|||||||
}
|
}
|
||||||
db_printf("}\n");
|
db_printf("}\n");
|
||||||
|
|
||||||
db_printf("\t_spareu16_0 %#06x __scratch[0] %p\n",
|
db_printf("\t__scratch[0] %p\n", skb->__scratch);
|
||||||
skb->_spareu16_0, skb->__scratch);
|
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user