[TFRC]: Migrate TX history to singly-linked lis
This patch was based on another made by Gerrit Renker, his changelog was: ------------------------------------------------------ The patch set migrates TFRC TX history to a singly-linked list. The details are: * use of a consistent naming scheme (all TFRC functions now begin with `tfrc_'); * allocation and cleanup are taken care of internally; * provision of a lookup function, which is used by the CCID TX infrastructure to determine the time a packet was sent (in turn used for RTT sampling); * integration of the new interface with the present use in CCID3. ------------------------------------------------------ Simplifications I did: . removing the tfrc_tx_hist_head that had a pointer to the list head and another for the slabcache. . No need for creating a slabcache for each CCID that wants to use the TFRC tx history routines, create a single slabcache when the dccp_tfrc_lib module init routine is called. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:

committed by
David S. Miller

orang tua
ea4f76ae13
melakukan
276f2edc52
@@ -277,7 +277,7 @@ void dccp_li_update_li(struct sock *sk,
|
||||
|
||||
EXPORT_SYMBOL_GPL(dccp_li_update_li);
|
||||
|
||||
static __init int dccp_li_init(void)
|
||||
int __init dccp_li_init(void)
|
||||
{
|
||||
dccp_li_cachep = kmem_cache_create("dccp_li_hist",
|
||||
sizeof(struct dccp_li_hist_entry),
|
||||
@@ -285,10 +285,10 @@ static __init int dccp_li_init(void)
|
||||
return dccp_li_cachep == NULL ? -ENOBUFS : 0;
|
||||
}
|
||||
|
||||
static __exit void dccp_li_exit(void)
|
||||
void dccp_li_exit(void)
|
||||
{
|
||||
kmem_cache_destroy(dccp_li_cachep);
|
||||
if (dccp_li_cachep != NULL) {
|
||||
kmem_cache_destroy(dccp_li_cachep);
|
||||
dccp_li_cachep = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
module_init(dccp_li_init);
|
||||
module_exit(dccp_li_exit);
|
||||
|
@@ -1,7 +1,8 @@
|
||||
/*
|
||||
* net/dccp/packet_history.c
|
||||
*
|
||||
* Copyright (c) 2005-6 The University of Waikato, Hamilton, New Zealand.
|
||||
* Copyright (c) 2007 The University of Aberdeen, Scotland, UK
|
||||
* Copyright (c) 2005-7 The University of Waikato, Hamilton, New Zealand.
|
||||
*
|
||||
* An implementation of the DCCP protocol
|
||||
*
|
||||
@@ -39,93 +40,48 @@
|
||||
#include "packet_history.h"
|
||||
|
||||
/*
|
||||
* Transmitter History Routines
|
||||
* Transmitter History Routines
|
||||
*/
|
||||
struct dccp_tx_hist *dccp_tx_hist_new(const char *name)
|
||||
static struct kmem_cache *tfrc_tx_hist;
|
||||
|
||||
struct tfrc_tx_hist_entry *
|
||||
tfrc_tx_hist_find_entry(struct tfrc_tx_hist_entry *head, u64 seqno)
|
||||
{
|
||||
struct dccp_tx_hist *hist = kmalloc(sizeof(*hist), GFP_ATOMIC);
|
||||
static const char dccp_tx_hist_mask[] = "tx_hist_%s";
|
||||
char *slab_name;
|
||||
while (head != NULL && head->seqno != seqno)
|
||||
head = head->next;
|
||||
|
||||
if (hist == NULL)
|
||||
goto out;
|
||||
|
||||
slab_name = kmalloc(strlen(name) + sizeof(dccp_tx_hist_mask) - 1,
|
||||
GFP_ATOMIC);
|
||||
if (slab_name == NULL)
|
||||
goto out_free_hist;
|
||||
|
||||
sprintf(slab_name, dccp_tx_hist_mask, name);
|
||||
hist->dccptxh_slab = kmem_cache_create(slab_name,
|
||||
sizeof(struct dccp_tx_hist_entry),
|
||||
0, SLAB_HWCACHE_ALIGN,
|
||||
NULL);
|
||||
if (hist->dccptxh_slab == NULL)
|
||||
goto out_free_slab_name;
|
||||
out:
|
||||
return hist;
|
||||
out_free_slab_name:
|
||||
kfree(slab_name);
|
||||
out_free_hist:
|
||||
kfree(hist);
|
||||
hist = NULL;
|
||||
goto out;
|
||||
return head;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(tfrc_tx_hist_find_entry);
|
||||
|
||||
EXPORT_SYMBOL_GPL(dccp_tx_hist_new);
|
||||
|
||||
void dccp_tx_hist_delete(struct dccp_tx_hist *hist)
|
||||
int tfrc_tx_hist_add(struct tfrc_tx_hist_entry **headp, u64 seqno)
|
||||
{
|
||||
const char* name = kmem_cache_name(hist->dccptxh_slab);
|
||||
struct tfrc_tx_hist_entry *entry = kmem_cache_alloc(tfrc_tx_hist, gfp_any());
|
||||
|
||||
kmem_cache_destroy(hist->dccptxh_slab);
|
||||
kfree(name);
|
||||
kfree(hist);
|
||||
if (entry == NULL)
|
||||
return -ENOBUFS;
|
||||
entry->seqno = seqno;
|
||||
entry->stamp = ktime_get_real();
|
||||
entry->next = *headp;
|
||||
*headp = entry;
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(tfrc_tx_hist_add);
|
||||
|
||||
EXPORT_SYMBOL_GPL(dccp_tx_hist_delete);
|
||||
|
||||
struct dccp_tx_hist_entry *
|
||||
dccp_tx_hist_find_entry(const struct list_head *list, const u64 seq)
|
||||
void tfrc_tx_hist_purge(struct tfrc_tx_hist_entry **headp)
|
||||
{
|
||||
struct dccp_tx_hist_entry *packet = NULL, *entry;
|
||||
struct tfrc_tx_hist_entry *head = *headp;
|
||||
|
||||
list_for_each_entry(entry, list, dccphtx_node)
|
||||
if (entry->dccphtx_seqno == seq) {
|
||||
packet = entry;
|
||||
break;
|
||||
}
|
||||
while (head != NULL) {
|
||||
struct tfrc_tx_hist_entry *next = head->next;
|
||||
|
||||
return packet;
|
||||
}
|
||||
|
||||
EXPORT_SYMBOL_GPL(dccp_tx_hist_find_entry);
|
||||
|
||||
void dccp_tx_hist_purge(struct dccp_tx_hist *hist, struct list_head *list)
|
||||
{
|
||||
struct dccp_tx_hist_entry *entry, *next;
|
||||
|
||||
list_for_each_entry_safe(entry, next, list, dccphtx_node) {
|
||||
list_del_init(&entry->dccphtx_node);
|
||||
dccp_tx_hist_entry_delete(hist, entry);
|
||||
kmem_cache_free(tfrc_tx_hist, head);
|
||||
head = next;
|
||||
}
|
||||
|
||||
*headp = NULL;
|
||||
}
|
||||
|
||||
EXPORT_SYMBOL_GPL(dccp_tx_hist_purge);
|
||||
|
||||
void dccp_tx_hist_purge_older(struct dccp_tx_hist *hist,
|
||||
struct list_head *list,
|
||||
struct dccp_tx_hist_entry *packet)
|
||||
{
|
||||
struct dccp_tx_hist_entry *next;
|
||||
|
||||
list_for_each_entry_safe_continue(packet, next, list, dccphtx_node) {
|
||||
list_del_init(&packet->dccphtx_node);
|
||||
dccp_tx_hist_entry_delete(hist, packet);
|
||||
}
|
||||
}
|
||||
|
||||
EXPORT_SYMBOL_GPL(dccp_tx_hist_purge_older);
|
||||
EXPORT_SYMBOL_GPL(tfrc_tx_hist_purge);
|
||||
|
||||
/*
|
||||
* Receiver History Routines
|
||||
@@ -147,8 +103,7 @@ struct dccp_rx_hist *dccp_rx_hist_new(const char *name)
|
||||
sprintf(slab_name, dccp_rx_hist_mask, name);
|
||||
hist->dccprxh_slab = kmem_cache_create(slab_name,
|
||||
sizeof(struct dccp_rx_hist_entry),
|
||||
0, SLAB_HWCACHE_ALIGN,
|
||||
NULL);
|
||||
0, SLAB_HWCACHE_ALIGN, NULL);
|
||||
if (hist->dccprxh_slab == NULL)
|
||||
goto out_free_slab_name;
|
||||
out:
|
||||
@@ -293,6 +248,37 @@ void dccp_rx_hist_purge(struct dccp_rx_hist *hist, struct list_head *list)
|
||||
|
||||
EXPORT_SYMBOL_GPL(dccp_rx_hist_purge);
|
||||
|
||||
extern int __init dccp_li_init(void);
|
||||
extern void dccp_li_exit(void);
|
||||
|
||||
static __init int packet_history_init(void)
|
||||
{
|
||||
if (dccp_li_init() != 0)
|
||||
goto out;
|
||||
|
||||
tfrc_tx_hist = kmem_cache_create("tfrc_tx_hist",
|
||||
sizeof(struct tfrc_tx_hist_entry), 0,
|
||||
SLAB_HWCACHE_ALIGN, NULL);
|
||||
if (tfrc_tx_hist == NULL)
|
||||
goto out_li_exit;
|
||||
|
||||
return 0;
|
||||
out_li_exit:
|
||||
dccp_li_exit();
|
||||
out:
|
||||
return -ENOBUFS;
|
||||
}
|
||||
module_init(packet_history_init);
|
||||
|
||||
static __exit void packet_history_exit(void)
|
||||
{
|
||||
if (tfrc_tx_hist != NULL) {
|
||||
kmem_cache_destroy(tfrc_tx_hist);
|
||||
tfrc_tx_hist = NULL;
|
||||
}
|
||||
dccp_li_exit();
|
||||
}
|
||||
module_exit(packet_history_exit);
|
||||
|
||||
MODULE_AUTHOR("Ian McDonald <ian.mcdonald@jandi.co.nz>, "
|
||||
"Arnaldo Carvalho de Melo <acme@ghostprotocols.net>");
|
||||
|
@@ -1,10 +1,9 @@
|
||||
/*
|
||||
* net/dccp/packet_history.h
|
||||
* Packet RX/TX history data structures and routines for TFRC-based protocols.
|
||||
*
|
||||
* Copyright (c) 2007 The University of Aberdeen, Scotland, UK
|
||||
* Copyright (c) 2005-6 The University of Waikato, Hamilton, New Zealand.
|
||||
*
|
||||
* An implementation of the DCCP protocol
|
||||
*
|
||||
* This code has been developed by the University of Waikato WAND
|
||||
* research group. For further information please see http://www.wand.net.nz/
|
||||
* or e-mail Ian McDonald - ian.mcdonald@jandi.co.nz
|
||||
@@ -49,71 +48,23 @@
|
||||
#define TFRC_WIN_COUNT_PER_RTT 4
|
||||
#define TFRC_WIN_COUNT_LIMIT 16
|
||||
|
||||
/*
|
||||
* Transmitter History data structures and declarations
|
||||
/**
|
||||
* tfrc_tx_hist_entry - Simple singly-linked TX history list
|
||||
* @next: next oldest entry (LIFO order)
|
||||
* @seqno: sequence number of this entry
|
||||
* @stamp: send time of packet with sequence number @seqno
|
||||
*/
|
||||
struct dccp_tx_hist_entry {
|
||||
struct list_head dccphtx_node;
|
||||
u64 dccphtx_seqno:48,
|
||||
dccphtx_sent:1;
|
||||
u32 dccphtx_rtt;
|
||||
ktime_t dccphtx_tstamp;
|
||||
struct tfrc_tx_hist_entry {
|
||||
struct tfrc_tx_hist_entry *next;
|
||||
u64 seqno;
|
||||
ktime_t stamp;
|
||||
};
|
||||
|
||||
struct dccp_tx_hist {
|
||||
struct kmem_cache *dccptxh_slab;
|
||||
};
|
||||
extern int tfrc_tx_hist_add(struct tfrc_tx_hist_entry **headp, u64 seqno);
|
||||
extern void tfrc_tx_hist_purge(struct tfrc_tx_hist_entry **headp);
|
||||
|
||||
extern struct dccp_tx_hist *dccp_tx_hist_new(const char *name);
|
||||
extern void dccp_tx_hist_delete(struct dccp_tx_hist *hist);
|
||||
|
||||
static inline struct dccp_tx_hist_entry *
|
||||
dccp_tx_hist_entry_new(struct dccp_tx_hist *hist,
|
||||
const gfp_t prio)
|
||||
{
|
||||
struct dccp_tx_hist_entry *entry = kmem_cache_alloc(hist->dccptxh_slab,
|
||||
prio);
|
||||
|
||||
if (entry != NULL)
|
||||
entry->dccphtx_sent = 0;
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
static inline struct dccp_tx_hist_entry *
|
||||
dccp_tx_hist_head(struct list_head *list)
|
||||
{
|
||||
struct dccp_tx_hist_entry *head = NULL;
|
||||
|
||||
if (!list_empty(list))
|
||||
head = list_entry(list->next, struct dccp_tx_hist_entry,
|
||||
dccphtx_node);
|
||||
return head;
|
||||
}
|
||||
|
||||
extern struct dccp_tx_hist_entry *
|
||||
dccp_tx_hist_find_entry(const struct list_head *list,
|
||||
const u64 seq);
|
||||
|
||||
static inline void dccp_tx_hist_add_entry(struct list_head *list,
|
||||
struct dccp_tx_hist_entry *entry)
|
||||
{
|
||||
list_add(&entry->dccphtx_node, list);
|
||||
}
|
||||
|
||||
static inline void dccp_tx_hist_entry_delete(struct dccp_tx_hist *hist,
|
||||
struct dccp_tx_hist_entry *entry)
|
||||
{
|
||||
if (entry != NULL)
|
||||
kmem_cache_free(hist->dccptxh_slab, entry);
|
||||
}
|
||||
|
||||
extern void dccp_tx_hist_purge(struct dccp_tx_hist *hist,
|
||||
struct list_head *list);
|
||||
|
||||
extern void dccp_tx_hist_purge_older(struct dccp_tx_hist *hist,
|
||||
struct list_head *list,
|
||||
struct dccp_tx_hist_entry *next);
|
||||
extern struct tfrc_tx_hist_entry *
|
||||
tfrc_tx_hist_find_entry(struct tfrc_tx_hist_entry *head, u64 ackno);
|
||||
|
||||
/*
|
||||
* Receiver History data structures and declarations
|
||||
|
Reference in New Issue
Block a user