mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-24 03:24:55 +08:00
0b609b5575
net/dccp/ccids/ccid2.c:190: warning: Function parameter or member 'hc' not described in 'ccid2_update_used_window' net/dccp/ccids/ccid2.c:190: warning: Function parameter or member 'new_wnd' not described in 'ccid2_update_used_window' net/dccp/ccids/ccid2.c:360: warning: Function parameter or member 'sk' not described in 'ccid2_rtt_estimator' net/dccp/ccids/ccid3.c:112: warning: Function parameter or member 'sk' not described in 'ccid3_hc_tx_update_x' net/dccp/ccids/ccid3.c:159: warning: Function parameter or member 'hc' not described in 'ccid3_hc_tx_update_s' net/dccp/ccids/ccid3.c:268: warning: Function parameter or member 'sk' not described in 'ccid3_hc_tx_send_packet' net/dccp/ccids/ccid3.c:667: warning: Function parameter or member 'sk' not described in 'ccid3_first_li' net/dccp/ccids/ccid3.c:85: warning: Function parameter or member 'hc' not described in 'ccid3_update_send_interval' net/dccp/ccids/lib/loss_interval.c:85: warning: Function parameter or member 'lh' not described in 'tfrc_lh_update_i_mean' net/dccp/ccids/lib/loss_interval.c:85: warning: Function parameter or member 'skb' not described in 'tfrc_lh_update_i_mean' net/dccp/ccids/lib/packet_history.c:392: warning: Function parameter or member 'h' not described in 'tfrc_rx_hist_sample_rtt' net/dccp/ccids/lib/packet_history.c:392: warning: Function parameter or member 'skb' not described in 'tfrc_rx_hist_sample_rtt' net/dccp/feat.c:1003: warning: Function parameter or member 'dreq' not described in 'dccp_feat_server_ccid_dependencies' net/dccp/feat.c:1040: warning: Function parameter or member 'array_len' not described in 'dccp_feat_prefer' net/dccp/feat.c:1040: warning: Function parameter or member 'array' not described in 'dccp_feat_prefer' net/dccp/feat.c:1040: warning: Function parameter or member 'preferred_value' not described in 'dccp_feat_prefer' net/dccp/output.c:151: warning: Function parameter or member 'dp' not described in 'dccp_determine_ccmps' net/dccp/output.c:242: warning: Function parameter or member 'sk' not described in 'dccp_xmit_packet' net/dccp/output.c:305: warning: Function parameter or member 'sk' not described in 'dccp_flush_write_queue' net/dccp/output.c:305: warning: Function parameter or member 'time_budget' not described in 'dccp_flush_write_queue' net/dccp/output.c:378: warning: Function parameter or member 'sk' not described in 'dccp_retransmit_skb' net/dccp/qpolicy.c:88: warning: Function parameter or member '' not described in 'dccp_qpolicy_operations' net/dccp/qpolicy.c:88: warning: Function parameter or member '{' not described in 'dccp_qpolicy_operations' net/dccp/qpolicy.c:88: warning: Function parameter or member 'params' not described in 'dccp_qpolicy_operations' Signed-off-by: Andrew Lunn <andrew@lunn.ch> Link: https://lore.kernel.org/r/20201028011412.931250-1-andrew@lunn.ch Signed-off-by: Jakub Kicinski <kuba@kernel.org>
137 lines
3.3 KiB
C
137 lines
3.3 KiB
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
/*
|
|
* net/dccp/qpolicy.c
|
|
*
|
|
* Policy-based packet dequeueing interface for DCCP.
|
|
*
|
|
* Copyright (c) 2008 Tomasz Grobelny <tomasz@grobelny.oswiecenia.net>
|
|
*/
|
|
#include "dccp.h"
|
|
|
|
/*
|
|
* Simple Dequeueing Policy:
|
|
* If tx_qlen is different from 0, enqueue up to tx_qlen elements.
|
|
*/
|
|
static void qpolicy_simple_push(struct sock *sk, struct sk_buff *skb)
|
|
{
|
|
skb_queue_tail(&sk->sk_write_queue, skb);
|
|
}
|
|
|
|
static bool qpolicy_simple_full(struct sock *sk)
|
|
{
|
|
return dccp_sk(sk)->dccps_tx_qlen &&
|
|
sk->sk_write_queue.qlen >= dccp_sk(sk)->dccps_tx_qlen;
|
|
}
|
|
|
|
static struct sk_buff *qpolicy_simple_top(struct sock *sk)
|
|
{
|
|
return skb_peek(&sk->sk_write_queue);
|
|
}
|
|
|
|
/*
|
|
* Priority-based Dequeueing Policy:
|
|
* If tx_qlen is different from 0 and the queue has reached its upper bound
|
|
* of tx_qlen elements, replace older packets lowest-priority-first.
|
|
*/
|
|
static struct sk_buff *qpolicy_prio_best_skb(struct sock *sk)
|
|
{
|
|
struct sk_buff *skb, *best = NULL;
|
|
|
|
skb_queue_walk(&sk->sk_write_queue, skb)
|
|
if (best == NULL || skb->priority > best->priority)
|
|
best = skb;
|
|
return best;
|
|
}
|
|
|
|
static struct sk_buff *qpolicy_prio_worst_skb(struct sock *sk)
|
|
{
|
|
struct sk_buff *skb, *worst = NULL;
|
|
|
|
skb_queue_walk(&sk->sk_write_queue, skb)
|
|
if (worst == NULL || skb->priority < worst->priority)
|
|
worst = skb;
|
|
return worst;
|
|
}
|
|
|
|
static bool qpolicy_prio_full(struct sock *sk)
|
|
{
|
|
if (qpolicy_simple_full(sk))
|
|
dccp_qpolicy_drop(sk, qpolicy_prio_worst_skb(sk));
|
|
return false;
|
|
}
|
|
|
|
/**
|
|
* struct dccp_qpolicy_operations - TX Packet Dequeueing Interface
|
|
* @push: add a new @skb to the write queue
|
|
* @full: indicates that no more packets will be admitted
|
|
* @top: peeks at whatever the queueing policy defines as its `top'
|
|
* @params: parameter passed to policy operation
|
|
*/
|
|
struct dccp_qpolicy_operations {
|
|
void (*push) (struct sock *sk, struct sk_buff *skb);
|
|
bool (*full) (struct sock *sk);
|
|
struct sk_buff* (*top) (struct sock *sk);
|
|
__be32 params;
|
|
};
|
|
|
|
static struct dccp_qpolicy_operations qpol_table[DCCPQ_POLICY_MAX] = {
|
|
[DCCPQ_POLICY_SIMPLE] = {
|
|
.push = qpolicy_simple_push,
|
|
.full = qpolicy_simple_full,
|
|
.top = qpolicy_simple_top,
|
|
.params = 0,
|
|
},
|
|
[DCCPQ_POLICY_PRIO] = {
|
|
.push = qpolicy_simple_push,
|
|
.full = qpolicy_prio_full,
|
|
.top = qpolicy_prio_best_skb,
|
|
.params = DCCP_SCM_PRIORITY,
|
|
},
|
|
};
|
|
|
|
/*
|
|
* Externally visible interface
|
|
*/
|
|
void dccp_qpolicy_push(struct sock *sk, struct sk_buff *skb)
|
|
{
|
|
qpol_table[dccp_sk(sk)->dccps_qpolicy].push(sk, skb);
|
|
}
|
|
|
|
bool dccp_qpolicy_full(struct sock *sk)
|
|
{
|
|
return qpol_table[dccp_sk(sk)->dccps_qpolicy].full(sk);
|
|
}
|
|
|
|
void dccp_qpolicy_drop(struct sock *sk, struct sk_buff *skb)
|
|
{
|
|
if (skb != NULL) {
|
|
skb_unlink(skb, &sk->sk_write_queue);
|
|
kfree_skb(skb);
|
|
}
|
|
}
|
|
|
|
struct sk_buff *dccp_qpolicy_top(struct sock *sk)
|
|
{
|
|
return qpol_table[dccp_sk(sk)->dccps_qpolicy].top(sk);
|
|
}
|
|
|
|
struct sk_buff *dccp_qpolicy_pop(struct sock *sk)
|
|
{
|
|
struct sk_buff *skb = dccp_qpolicy_top(sk);
|
|
|
|
if (skb != NULL) {
|
|
/* Clear any skb fields that we used internally */
|
|
skb->priority = 0;
|
|
skb_unlink(skb, &sk->sk_write_queue);
|
|
}
|
|
return skb;
|
|
}
|
|
|
|
bool dccp_qpolicy_param_ok(struct sock *sk, __be32 param)
|
|
{
|
|
/* check if exactly one bit is set */
|
|
if (!param || (param & (param - 1)))
|
|
return false;
|
|
return (qpol_table[dccp_sk(sk)->dccps_qpolicy].params & param) == param;
|
|
}
|