* [net-next 1/3] tcp: avoid useless copying and collapsing of just one skb
From: Koichiro Den @ 2017-10-14 7:27 UTC (permalink / raw)
To: netdev; +Cc: davem, kuznet, yoshfuji
In-Reply-To: <20171014072745.23462-1-den@klaipeden.com>
On the starting point chosen, it could be possible that just one skb
remains in between the range provided, leading to copying and re-insertion
of rb node, which is useless with respect to the rcv buf measurement.
This is rather probable in ooo queue case, in which non-contiguous bloated
packets have been queued up.
Signed-off-by: Koichiro Den <den@klaipeden.com>
---
net/ipv4/tcp_input.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index d0682ce2a5d6..1d785b5bf62d 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -4807,7 +4807,8 @@ tcp_collapse(struct sock *sk, struct sk_buff_head *list, struct rb_root *root,
start = TCP_SKB_CB(skb)->end_seq;
}
if (end_of_skbs ||
- (TCP_SKB_CB(skb)->tcp_flags & (TCPHDR_SYN | TCPHDR_FIN)))
+ (TCP_SKB_CB(skb)->tcp_flags & (TCPHDR_SYN | TCPHDR_FIN)) ||
+ (TCP_SKB_CB(skb)->seq == start && TCP_SKB_CB(skb)->end_seq == end))
return;
__skb_queue_head_init(&tmp);
--
2.9.4
^ permalink raw reply related
* [net-next 3/3] tcp: keep tcp_collapse controllable even after processing starts
From: Koichiro Den @ 2017-10-14 7:27 UTC (permalink / raw)
To: netdev; +Cc: davem, kuznet, yoshfuji
In-Reply-To: <20171014072745.23462-1-den@klaipeden.com>
Combining actual collapsing with reasoning for deciding the starting
point, we can apply its logic in a consistent manner such that we can
avoid costly yet not much useful collapsing. When collapsing to be
triggered, it's not rare that most of the skbs in the receive or ooo
queue are large ones without much metadata overhead. This also
simplifies code and makes it easier to apply logic in a fair manner.
Subtle subsidiary changes included:
- When the end_seq of the skb we are trying to collapse was larger than
the 'end' argument provided, we would end up copying to the 'end'
even though we couldn't collapse the original one. Current users of
tcp_collapse does not require such reserves so redefines it as the
point over which skbs whose seq passes guranteed not to be collapsed.
- Naturally tcp_collapse_ofo_queue shapes up and we no longer need
'tail' argument.
Signed-off-by: Koichiro Den <den@klaipeden.com>
---
net/ipv4/tcp_input.c | 197 +++++++++++++++++++++++----------------------------
1 file changed, 90 insertions(+), 107 deletions(-)
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 1a74457db0f3..5fb90cc0ae95 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -4756,108 +4756,117 @@ void tcp_rbtree_insert(struct rb_root *root, struct sk_buff *skb)
/* Collapse contiguous sequence of skbs head..tail with
* sequence numbers start..end.
- *
- * If tail is NULL, this means until the end of the queue.
- *
- * Segments with FIN/SYN are not collapsed (only because this
- * simplifies code)
*/
static void
tcp_collapse(struct sock *sk, struct sk_buff_head *list, struct rb_root *root,
- struct sk_buff *head, struct sk_buff *tail, u32 start, u32 end)
+ struct sk_buff *head, u32 start, u32 *end)
{
- struct sk_buff *skb = head, *n;
+ struct sk_buff *skb = head, *n, *nskb = NULL;
+ int copy = 0, offset, size;
struct sk_buff_head tmp;
- bool end_of_skbs;
- /* First, check that queue is collapsible and find
- * the point where collapsing can be useful.
- */
-restart:
- for (end_of_skbs = true; skb != NULL && skb != tail; skb = n) {
- /* If list is ooo queue, it will get purged when
- * this FIN will get moved to sk_receive_queue.
- * SYN packet is not expected here. We will get
- * error message when actual receiving.
- */
- if (TCP_SKB_CB(skb)->tcp_flags & (TCPHDR_FIN | TCPHDR_SYN))
- return;
+ if (!list)
+ __skb_queue_head_init(&tmp); /* To defer rb tree insertion */
- n = tcp_skb_next(skb, list);
-
- /* No new bits? It is possible on ofo queue. */
+ while (skb) {
if (!before(start, TCP_SKB_CB(skb)->end_seq)) {
skb = tcp_collapse_one(sk, skb, list, root);
- if (!skb)
- break;
- goto restart;
+ continue;
}
+ n = tcp_skb_next(skb, list);
- /* The first skb to collapse is:
- * - bloated or contains data before "start" or
- * overlaps to the next one.
- */
- if (tcp_win_from_space(skb->truesize) > skb->len ||
- before(TCP_SKB_CB(skb)->seq, start)) {
- end_of_skbs = false;
+examine:
+ /* Nothing beneficial to expect any more if SYN/FIN or last. */
+ if (!n ||
+ TCP_SKB_CB(skb)->tcp_flags & (TCPHDR_FIN | TCPHDR_SYN))
break;
+
+ /* If hole found, skip to the next. */
+ if (after(TCP_SKB_CB(n)->seq, TCP_SKB_CB(skb)->end_seq)) {
+ skb = n;
+ continue;
}
- if (n && n != tail &&
- TCP_SKB_CB(skb)->end_seq != TCP_SKB_CB(n)->seq) {
- end_of_skbs = false;
- break;
+ /* If the 2nd skb has no newer bits than the current one,
+ * just collapse and advance it to re-examine.
+ */
+ if (!after(TCP_SKB_CB(n)->end_seq, TCP_SKB_CB(skb)->end_seq)) {
+ n = tcp_collapse_one(sk, skb, list, root);
+ if (!n)
+ break;
+ goto examine;
}
- /* Decided to skip this, advance start seq. */
- start = TCP_SKB_CB(skb)->end_seq;
- }
- if (end_of_skbs ||
- (TCP_SKB_CB(skb)->seq == start && TCP_SKB_CB(skb)->end_seq == end))
- return;
+ /* If the next skb passes the end hint, finish. */
+ if (end && !before(TCP_SKB_CB(n)->seq, *end))
+ break;
- __skb_queue_head_init(&tmp);
+ /* If we can put more into the new skb created before, do so.
+ * Otherwise we conclude the processing is worth the effort
+ * only if the two skbs overlaps or either one is bloated.
+ */
+ if ((!nskb || !after(TCP_SKB_CB(skb)->seq,
+ TCP_SKB_CB(nskb)->end_seq)) &&
+ TCP_SKB_CB(n)->seq == TCP_SKB_CB(skb)->end_seq &&
+ tcp_win_from_space(skb->truesize) <= skb->len &&
+ tcp_win_from_space(n->truesize) <= n->len) {
+ skb = n;
+ continue;
+ }
- while (before(start, end)) {
- int copy = min_t(int, SKB_MAX_ORDER(0, 0), end - start);
- struct sk_buff *nskb;
+ /* Now we decide to take some action for the two.
+ * Note: at this point, the followings hold true:
+ * - start < TCP_SKB_CB(skb)->end_seq < TCP_SKB_CB(n)->end_seq
+ * - TCP_SKB_CB(skb)->seq < TCP_SKB_CB(n)->seq < end
+ *
+ * TODO: (split +) shift + collapse if it deserves. */
+ while (after(TCP_SKB_CB(n)->end_seq, start)) {
+ if (!copy) {
+ copy = !end ? SKB_MAX_ORDER(0, 0) :
+ min_t(int, SKB_MAX_ORDER(0, 0),
+ *end - start);
+ nskb = alloc_skb(copy, GFP_ATOMIC);
+ if (!nskb)
+ /* Trying to trim the last nskb does not
+ * help much, lets just abort.
+ */
+ goto end;
- nskb = alloc_skb(copy, GFP_ATOMIC);
- if (!nskb)
- break;
+ memcpy(nskb->cb, skb->cb, sizeof(skb->cb));
+ TCP_SKB_CB(nskb)->seq =
+ TCP_SKB_CB(nskb)->end_seq = start;
- memcpy(nskb->cb, skb->cb, sizeof(skb->cb));
- TCP_SKB_CB(nskb)->seq = TCP_SKB_CB(nskb)->end_seq = start;
- if (list)
- __skb_queue_before(list, skb, nskb);
- else
- __skb_queue_tail(&tmp, nskb); /* defer rbtree insertion */
- skb_set_owner_r(nskb, sk);
+ if (list)
+ __skb_queue_before(list, skb, nskb);
+ else
+ __skb_queue_tail(&tmp, nskb);
+ skb_set_owner_r(nskb, sk);
+ }
- /* Copy data, releasing collapsed skbs. */
- while (copy > 0) {
- int offset = start - TCP_SKB_CB(skb)->seq;
- int size = TCP_SKB_CB(skb)->end_seq - start;
+ /* Copy data, releasing collapsed skbs. */
+ offset = start - TCP_SKB_CB(skb)->seq;
+ size = TCP_SKB_CB(skb)->end_seq - start;
BUG_ON(offset < 0);
- if (size > 0) {
- size = min(copy, size);
- if (skb_copy_bits(skb, offset, skb_put(nskb, size), size))
- BUG();
- TCP_SKB_CB(nskb)->end_seq += size;
- copy -= size;
- start += size;
- }
- if (!before(start, TCP_SKB_CB(skb)->end_seq)) {
+ BUG_ON(size <= 0);
+
+ size = min(copy, size);
+ if (skb_copy_bits(skb, offset, skb_put(nskb, size),
+ size))
+ BUG();
+
+ TCP_SKB_CB(nskb)->end_seq += size;
+ copy -= size;
+ start += size;
+
+ if (!before(start, TCP_SKB_CB(skb)->seq))
skb = tcp_collapse_one(sk, skb, list, root);
- if (!skb || skb == tail)
- goto end;
- }
}
}
end:
- skb_queue_walk_safe(&tmp, skb, n)
- tcp_rbtree_insert(root, skb);
+ if (!list)
+ skb_queue_walk_safe(&tmp, skb, n)
+ tcp_rbtree_insert(root, skb);
}
/* Collapse ofo queue. Algorithm: select contiguous sequence of skbs
@@ -4866,37 +4875,12 @@ tcp_collapse(struct sock *sk, struct sk_buff_head *list, struct rb_root *root,
static void tcp_collapse_ofo_queue(struct sock *sk)
{
struct tcp_sock *tp = tcp_sk(sk);
- struct sk_buff *skb, *head;
- u32 start, end;
-
- skb = skb_rb_first(&tp->out_of_order_queue);
-new_range:
- if (!skb) {
- tp->ooo_last_skb = skb_rb_last(&tp->out_of_order_queue);
- return;
- }
- start = TCP_SKB_CB(skb)->seq;
- end = TCP_SKB_CB(skb)->end_seq;
+ struct sk_buff *head;
- for (head = skb;;) {
- skb = skb_rb_next(skb);
-
- /* Range is terminated when we see a gap or when
- * we are at the queue end.
- */
- if (!skb ||
- after(TCP_SKB_CB(skb)->seq, end) ||
- before(TCP_SKB_CB(skb)->end_seq, start)) {
- tcp_collapse(sk, NULL, &tp->out_of_order_queue,
- head, skb, start, end);
- goto new_range;
- }
-
- if (unlikely(before(TCP_SKB_CB(skb)->seq, start)))
- start = TCP_SKB_CB(skb)->seq;
- if (after(TCP_SKB_CB(skb)->end_seq, end))
- end = TCP_SKB_CB(skb)->end_seq;
- }
+ head = skb_rb_first(&tp->out_of_order_queue);
+ tcp_collapse(sk, NULL, &tp->out_of_order_queue,
+ head, TCP_SKB_CB(head)->seq, NULL);
+ tp->ooo_last_skb = skb_rb_last(&tp->out_of_order_queue);
}
/*
@@ -4965,8 +4949,7 @@ static int tcp_prune_queue(struct sock *sk)
if (!skb_queue_empty(&sk->sk_receive_queue))
tcp_collapse(sk, &sk->sk_receive_queue, NULL,
skb_peek(&sk->sk_receive_queue),
- NULL,
- tp->copied_seq, tp->rcv_nxt);
+ tp->copied_seq, &tp->rcv_nxt);
sk_mem_reclaim(sk);
if (atomic_read(&sk->sk_rmem_alloc) <= sk->sk_rcvbuf)
--
2.9.4
^ permalink raw reply related
* Re: [PATCH] ath10k: spectral: Simplify error checking
From: Christos Gkekas @ 2017-10-14 8:12 UTC (permalink / raw)
To: Kalle Valo
Cc: ath10k@lists.infradead.org, linux-wireless@vger.kernel.org,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
In-Reply-To: <87fuannse6.fsf@kamboji.qca.qualcomm.com>
On 13/10/17 12:28:50 +0000, Kalle Valo wrote:
> Christos Gkekas <chris.gekas@gmail.com> writes:
>
> > Variable val is unsigned so checking whether it is less than zero is
> > redundant.
> >
> > Signed-off-by: Christos Gkekas <chris.gekas@gmail.com>
> > ---
> > drivers/net/wireless/ath/ath10k/spectral.c | 5 +----
> > 1 file changed, 1 insertion(+), 4 deletions(-)
> >
> > diff --git a/drivers/net/wireless/ath/ath10k/spectral.c b/drivers/net/wireless/ath/ath10k/spectral.c
> > index dd9cc09..1867937 100644
> > --- a/drivers/net/wireless/ath/ath10k/spectral.c
> > +++ b/drivers/net/wireless/ath/ath10k/spectral.c
> > @@ -403,10 +403,7 @@ static ssize_t write_file_spectral_count(struct file *file,
> > return -EFAULT;
> >
> > buf[len] = '\0';
> > - if (kstrtoul(buf, 0, &val))
> > - return -EINVAL;
> > -
> > - if (val < 0 || val > 255)
> > + if (kstrtoul(buf, 0, &val) || val > 255)
> > return -EINVAL;
>
> Removing the check for negative is correct but I don't think you are
> simplifying anything, on the contrary it's harder to read. Please keep
> the two if statements separate.
>
> --
> Kalle Valo
You are right, will make the change and send a new patch.
Thanks for your time.
Christos Gkekas
^ permalink raw reply
* Re: [PATCH] ath9k: debug: Simplify error checking
From: Christos Gkekas @ 2017-10-14 8:16 UTC (permalink / raw)
To: Kalle Valo; +Cc: QCA ath9k Development, linux-wireless, netdev, linux-kernel
In-Reply-To: <87infjw6us.fsf@purkki.adurom.net>
On 13/10/17 15:49:15 +0300, Kalle Valo wrote:
> Christos Gkekas <chris.gekas@gmail.com> writes:
>
> > Variable val is unsigned so checking whether it is less than zero is
> > redundant.
> >
> > Signed-off-by: Christos Gkekas <chris.gekas@gmail.com>
> > ---
> > drivers/net/wireless/ath/ath9k/debug.c | 5 +----
> > 1 file changed, 1 insertion(+), 4 deletions(-)
> >
> > diff --git a/drivers/net/wireless/ath/ath9k/debug.c b/drivers/net/wireless/ath/ath9k/debug.c
> > index 01fa301..3b93c23 100644
> > --- a/drivers/net/wireless/ath/ath9k/debug.c
> > +++ b/drivers/net/wireless/ath/ath9k/debug.c
> > @@ -1164,10 +1164,7 @@ static ssize_t write_file_tpc(struct file *file, const char __user *user_buf,
> > return -EFAULT;
> >
> > buf[len] = '\0';
> > - if (kstrtoul(buf, 0, &val))
> > - return -EINVAL;
> > -
> > - if (val < 0 || val > 1)
> > + if (kstrtoul(buf, 0, &val) || val > 1)
> > return -EINVAL;
>
> Same as with the ath10k patch, please keep the two if statements
> separate.
>
> --
> Kalle Valo
Thanks, will submit an new, updated patch.
Christos Gkekas
^ permalink raw reply
* Re: [PATCH v3 0/6] staging: Introduce DPAA2 Ethernet Switch driver
From: Linus Walleij @ 2017-10-14 9:35 UTC (permalink / raw)
To: Razvan Stefanescu, linux-netdev, OpenWrt Development List
Cc: Greg KH, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org,
Alexander Graf, Arnd Bergmann, alexandru.marginean,
bogdan.purcareata, ruxandra.radulescu, laurentiu.tudor, stuyoder
In-Reply-To: <1507194974-12050-1-git-send-email-razvan.stefanescu@nxp.com>
On Thu, Oct 5, 2017 at 11:16 AM, Razvan Stefanescu
<razvan.stefanescu@nxp.com> wrote:
> This patchset introduces the Ethernet Switch Driver for Freescale/NXP SoCs
> with DPAA2 (DataPath Acceleration Architecture v2). The driver manages
> switch objects discovered on the fsl-mc bus. A description of the driver
> can be found in the associated README file.
>
> The patchset consists of:
> * A set of libraries containing APIs for configuring and controlling
> Management Complex (MC) switch objects
> * The DPAA2 Ethernet Switch driver
> * Patch adding ethtool support
So it appears that ethernet switches is a class of device that need their own
subsystem in Linux, before this driver can move out of staging.
I ran into the problem in OpenWRT that has these out-of-tree patches for
off-chip ethernet switches, conveniently placed under net/phy:
https://github.com/openwrt/openwrt/tree/master/target/linux/generic/files/drivers/net/phy
These are some 12 different ethernet switches. It is used in more or
less every home router out there.
It's not really working to have all of this out-of-tree, there must have been
discussions about the requirements for a proper ethernet switch subsystem.
I'm not a good net developers, just a grumpy user having to deal with all
of this out-of-tree code that's not helpful with changing interfaces like
device tree and so on.
Can you people who worked on this over the years pit in with your
requirements for an ethernet switch subsystem so we can house these
drivers in a proper way?
What we need AFAICT:
- Consensus on userspace ABI
- Consensus on ethtool extenstions
- Consensus on where in drivers/net this goes
You can kick me for not knowing what I'm talking about and how complex the
problem is now.
Yours,
Linus Walleij
^ permalink raw reply
* [PATCH] ath10k: spectral: Remove redundant check
From: Christos Gkekas @ 2017-10-14 9:41 UTC (permalink / raw)
To: Kalle Valo, ath10k, linux-wireless, netdev, linux-kernel; +Cc: Christos Gkekas
Variable val is unsigned, so checking whether it is less than zero is
redundant.
Signed-off-by: Christos Gkekas <chris.gekas@gmail.com>
---
drivers/net/wireless/ath/ath10k/spectral.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/wireless/ath/ath10k/spectral.c b/drivers/net/wireless/ath/ath10k/spectral.c
index dd9cc09..2048b1e 100644
--- a/drivers/net/wireless/ath/ath10k/spectral.c
+++ b/drivers/net/wireless/ath/ath10k/spectral.c
@@ -406,7 +406,7 @@ static ssize_t write_file_spectral_count(struct file *file,
if (kstrtoul(buf, 0, &val))
return -EINVAL;
- if (val < 0 || val > 255)
+ if (val > 255)
return -EINVAL;
mutex_lock(&ar->conf_mutex);
--
2.7.4
^ permalink raw reply related
* [PATCH] ath9k: debug: Remove redundant check
From: Christos Gkekas @ 2017-10-14 9:46 UTC (permalink / raw)
To: QCA ath9k Development, Kalle Valo, linux-wireless, netdev,
linux-kernel
Cc: Christos Gkekas
Variable val is unsigned, so checking whether it is less than zero is
redundant.
Signed-off-by: Christos Gkekas <chris.gekas@gmail.com>
---
drivers/net/wireless/ath/ath9k/debug.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/wireless/ath/ath9k/debug.c b/drivers/net/wireless/ath/ath9k/debug.c
index 01fa301..4f5f141 100644
--- a/drivers/net/wireless/ath/ath9k/debug.c
+++ b/drivers/net/wireless/ath/ath9k/debug.c
@@ -1167,7 +1167,7 @@ static ssize_t write_file_tpc(struct file *file, const char __user *user_buf,
if (kstrtoul(buf, 0, &val))
return -EINVAL;
- if (val < 0 || val > 1)
+ if (val > 1)
return -EINVAL;
tpc_enabled = !!val;
--
2.7.4
^ permalink raw reply related
* Re: [PATCH net-next v2 1/1] bridge: return error code when deleting Vlan
From: Nikolay Aleksandrov @ 2017-10-14 10:52 UTC (permalink / raw)
To: Roman Mashak
Cc: David Ahern, David Miller, Stephen Hemminger,
Linux Kernel Network Developers, Jamal Hadi Salim
In-Reply-To: <85d15rvxze.fsf@mojatatu.com>
On 13/10/17 19:00, Roman Mashak wrote:
> Nikolay Aleksandrov <nikolay@cumulusnetworks.com> writes:
>
>
> [...]
>
>>>> Why do you want to return the error code here? Walking the code paths
>>>> seems like ENOENT or err from switchdev_port_obj_del are the 2 error
>>>> possibilities.
>>>
>>> For example, if you attempt to delete a non-existing vlan on a port,
>>> the current code succeeds and also sends event :
>>>
>>> rtnetlink_rcv_msg
>>> rtnl_bridge_dellink
>>> br_dellink
>>> br_afspec
>>> br_vlan_info
>>>
>>> int br_dellink(..)
>>> {
>>> ...
>>> err = br_afspec()
>>> if (err == 0)
>>> br_ifinfo_notify(RTM_NEWLINK, p);
>>> }
>>>
>>> This is misleading, so a proper errcode has to be produced.
>>>
>>
>> True, but you also change the expected behaviour because now a user can
>> clear all vlans with one request (1 - 4094), and after the change that
>> will fail with a partial delete if some vlan was missing.
>
> Nikolay, would you like to have a crack at fixing this?
>
Sure, need to finish something and will cook up a patch next week.
Thanks,
Nik
^ permalink raw reply
* Re: [PATCH v3 0/6] staging: Introduce DPAA2 Ethernet Switch driver
From: Linus Walleij @ 2017-10-14 11:09 UTC (permalink / raw)
To: Razvan Stefanescu, OpenWrt Development List,
netdev@vger.kernel.org
Cc: devel@driverdev.osuosl.org, Arnd Bergmann, Greg KH,
alexandru.marginean, linux-kernel@vger.kernel.org, Alexander Graf,
stuyoder, bogdan.purcareata, laurentiu.tudor
In-Reply-To: <CACRpkdYJCzu9Ph8XMYXt=SSAX+ZaiwXqUGgWX5UvTabmMxmBNQ@mail.gmail.com>
Top posting and resending since netdev@vger.kernel.org
is the right mail address for this. Mea culpa.
Linus Walleij
On Sat, Oct 14, 2017 at 11:35 AM, Linus Walleij
<linus.walleij@linaro.org> wrote:
> On Thu, Oct 5, 2017 at 11:16 AM, Razvan Stefanescu
> <razvan.stefanescu@nxp.com> wrote:
>
>> This patchset introduces the Ethernet Switch Driver for Freescale/NXP SoCs
>> with DPAA2 (DataPath Acceleration Architecture v2). The driver manages
>> switch objects discovered on the fsl-mc bus. A description of the driver
>> can be found in the associated README file.
>>
>> The patchset consists of:
>> * A set of libraries containing APIs for configuring and controlling
>> Management Complex (MC) switch objects
>> * The DPAA2 Ethernet Switch driver
>> * Patch adding ethtool support
>
> So it appears that ethernet switches is a class of device that need their own
> subsystem in Linux, before this driver can move out of staging.
>
> I ran into the problem in OpenWRT that has these out-of-tree patches for
> off-chip ethernet switches, conveniently placed under net/phy:
> https://github.com/openwrt/openwrt/tree/master/target/linux/generic/files/drivers/net/phy
>
> These are some 12 different ethernet switches. It is used in more or
> less every home router out there.
>
> It's not really working to have all of this out-of-tree, there must have been
> discussions about the requirements for a proper ethernet switch subsystem.
>
> I'm not a good net developers, just a grumpy user having to deal with all
> of this out-of-tree code that's not helpful with changing interfaces like
> device tree and so on.
>
> Can you people who worked on this over the years pit in with your
> requirements for an ethernet switch subsystem so we can house these
> drivers in a proper way?
>
> What we need AFAICT:
>
> - Consensus on userspace ABI
> - Consensus on ethtool extenstions
> - Consensus on where in drivers/net this goes
>
> You can kick me for not knowing what I'm talking about and how complex the
> problem is now.
>
> Yours,
> Linus Walleij
^ permalink raw reply
* [RFC PATCH v2 0/5] TCP Wave
From: Natale Patriciello @ 2017-10-14 11:47 UTC (permalink / raw)
To: David S . Miller, Eric Dumazet
Cc: netdev, Ahmed Said, Natale Patriciello, Francesco Zampognaro,
Cesare Roseti
Hello,
after the round of review on our v1 patch (you can find the relevant
thread here [1]) we have improved our code of TCP Wave, a new congestion
control algorithm.
Context: TCP Wave (TCPW) replaces the window-based transmission paradigm
of the standard TCP with a burst-based transmission, the ACK-clock
scheduling with a self-managed timer and the RTT-based congestion
control loop with an Ack-based Capacity and Congestion Estimation (ACCE)
module. In non-technical words, it sends data down the stack when a
timer expires, and the timing of the received ACKs contribute to
updating this timer regularly. We have left many debug messages to help
people understand what is going on inside the module. We plan to remove
almost all of them in the final submission.
We added this new sender paradigm without deeply touching existing code;
we re-used the existing infrastructure (TCP pacing timer, added with
commit 218af599fa635b107cfe10acf3249c4dfe5e4123), thanks to the
suggestion of Eric Dumazet. In fact, we only added four (optional) new
congestion control functions:
+ /* get the expiration time for the pacing timer (optional) */
+ u64 (*get_pacing_time)(struct sock *sk);
+ /* the pacing timer is expired (optional) */
+ void (*pacing_timer_expired)(struct sock *sk);
+ /* get the # segs to send out when the timer expires (optional) */
+ u32 (*get_segs_per_round)(struct sock *sk);
+ /* the TCP has sent some segments (optional) */
+ void (*segments_sent)(struct sock *sk, u32 sent);
to manage the previously mentioned pacing timer. With these functions, a
congestion control can set the pacing time, be informed when it expires,
indicate how many segments can leave when it expires, and know how many
segments really left the TCP layer after it has expired.
Thanks to the reviewers' suggestions we believe that the code has
improved in clarity and performance. David Laight, Stephen Hemminger,
David Miller, Neal Cardwell, Eric Dumazet, and all others that replied
privately, thank you.
Again, we would greatly appreciate any feedback, comments, suggestions,
corrections and so on. Thank you for your attention.
Cesare, Francesco, Ahmed, Natale
[1] http://lists.openwall.net/netdev/2017/07/28/219
---
Changes in v2:
- Using TCP pacing timer instead of adding a new one
- Using ktime_t instead of jiffies to measure the time
- Avoided the use of custom debug facilities
- Cleaned the variable declarations
Natale Patriciello (5):
tcp: Added a function to retrieve pacing timer
tcp: implemented pacing_expired
tcp: added get_segs_per_round
tcp: added segment sent
wave: Added TCP Wave
MAINTAINERS | 6 +
include/net/tcp.h | 8 +
include/uapi/linux/inet_diag.h | 13 +
net/ipv4/Kconfig | 16 +
net/ipv4/Makefile | 1 +
net/ipv4/tcp_output.c | 61 ++-
net/ipv4/tcp_wave.c | 1035 ++++++++++++++++++++++++++++++++++++++++
7 files changed, 1127 insertions(+), 13 deletions(-)
create mode 100644 net/ipv4/tcp_wave.c
--
2.14.2
^ permalink raw reply
* [RFC PATCH v2 1/5] tcp: Added a function to retrieve pacing timer
From: Natale Patriciello @ 2017-10-14 11:47 UTC (permalink / raw)
To: David S . Miller, Eric Dumazet
Cc: netdev, Ahmed Said, Natale Patriciello, Francesco Zampognaro,
Cesare Roseti
In-Reply-To: <20171014114714.3694-1-natale.patriciello@gmail.com>
Allow congestion control modules to set a custom pacing time between
the transmission of segments.
Moreover, it is assumed that the time returned by the congestion module
in the past is firm, until the timer expires; therefore, do not re-start
the timer if it is already active.
Signed-off-by: Natale Patriciello <natale.patriciello@gmail.com>
---
include/net/tcp.h | 2 ++
net/ipv4/tcp_output.c | 36 +++++++++++++++++++++++++-----------
2 files changed, 27 insertions(+), 11 deletions(-)
diff --git a/include/net/tcp.h b/include/net/tcp.h
index 89974c5286d8..42c7aa96c4cf 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -1015,6 +1015,8 @@ struct tcp_congestion_ops {
/* get info for inet_diag (optional) */
size_t (*get_info)(struct sock *sk, u32 ext, int *attr,
union tcp_cc_info *info);
+ /* get the expiration time for the pacing timer (optional) */
+ u64 (*get_pacing_time)(struct sock *sk);
char name[TCP_CA_NAME_MAX];
struct module *owner;
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index 0bc9e46a5369..ec5977156c26 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -950,22 +950,36 @@ static bool tcp_needs_internal_pacing(const struct sock *sk)
return smp_load_acquire(&sk->sk_pacing_status) == SK_PACING_NEEDED;
}
+static bool tcp_pacing_timer_check(const struct sock *sk)
+{
+ return hrtimer_active(&tcp_sk(sk)->pacing_timer);
+}
+
static void tcp_internal_pacing(struct sock *sk, const struct sk_buff *skb)
{
+ const struct tcp_congestion_ops *ca_ops = inet_csk(sk)->icsk_ca_ops;
u64 len_ns;
- u32 rate;
if (!tcp_needs_internal_pacing(sk))
return;
- rate = sk->sk_pacing_rate;
- if (!rate || rate == ~0U)
- return;
-
- /* Should account for header sizes as sch_fq does,
- * but lets make things simple.
- */
- len_ns = (u64)skb->len * NSEC_PER_SEC;
- do_div(len_ns, rate);
+
+ if (ca_ops && ca_ops->get_pacing_time) {
+ if (tcp_pacing_timer_check(sk))
+ return;
+
+ len_ns = ca_ops->get_pacing_time(sk);
+ } else {
+ u32 rate = sk->sk_pacing_rate;
+
+ if (!rate || rate == ~0U)
+ return;
+
+ /* Should account for header sizes as sch_fq does,
+ * but lets make things simple.
+ */
+ len_ns = (u64)skb->len * NSEC_PER_SEC;
+ do_div(len_ns, rate);
+ }
hrtimer_start(&tcp_sk(sk)->pacing_timer,
ktime_add_ns(ktime_get(), len_ns),
HRTIMER_MODE_ABS_PINNED);
@@ -2123,7 +2137,7 @@ static int tcp_mtu_probe(struct sock *sk)
static bool tcp_pacing_check(const struct sock *sk)
{
return tcp_needs_internal_pacing(sk) &&
- hrtimer_active(&tcp_sk(sk)->pacing_timer);
+ tcp_pacing_timer_check(sk);
}
/* TCP Small Queues :
--
2.14.2
^ permalink raw reply related
* [RFC PATCH v2 2/5] tcp: implemented pacing_expired
From: Natale Patriciello @ 2017-10-14 11:47 UTC (permalink / raw)
To: David S . Miller, Eric Dumazet
Cc: netdev, Ahmed Said, Natale Patriciello, Francesco Zampognaro,
Cesare Roseti
In-Reply-To: <20171014114714.3694-1-natale.patriciello@gmail.com>
Inform the congestion control that the pacing timer, previously set,
has expired. The commit does not consider situations in which another
kind of timer has expired (e.g., a tail loss probe, a retransmission
timer...)
Signed-off-by: Natale Patriciello <natale.patriciello@gmail.com>
---
include/net/tcp.h | 2 ++
net/ipv4/tcp_output.c | 6 ++++++
2 files changed, 8 insertions(+)
diff --git a/include/net/tcp.h b/include/net/tcp.h
index 42c7aa96c4cf..e817f0669d0e 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -1017,6 +1017,8 @@ struct tcp_congestion_ops {
union tcp_cc_info *info);
/* get the expiration time for the pacing timer (optional) */
u64 (*get_pacing_time)(struct sock *sk);
+ /* the pacing timer is expired (optional) */
+ void (*pacing_timer_expired)(struct sock *sk);
char name[TCP_CA_NAME_MAX];
struct module *owner;
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index ec5977156c26..25b4cf0802f2 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -2241,6 +2241,7 @@ void tcp_chrono_stop(struct sock *sk, const enum tcp_chrono type)
static bool tcp_write_xmit(struct sock *sk, unsigned int mss_now, int nonagle,
int push_one, gfp_t gfp)
{
+ const struct tcp_congestion_ops *ca_ops = inet_csk(sk)->icsk_ca_ops;
struct tcp_sock *tp = tcp_sk(sk);
struct sk_buff *skb;
unsigned int tso_segs, sent_pkts;
@@ -2263,6 +2264,11 @@ static bool tcp_write_xmit(struct sock *sk, unsigned int mss_now, int nonagle,
max_segs = tcp_tso_segs(sk, mss_now);
tcp_mstamp_refresh(tp);
+
+ if (!tcp_pacing_timer_check(sk) &&
+ ca_ops && ca_ops->pacing_timer_expired)
+ ca_ops->pacing_timer_expired(sk);
+
while ((skb = tcp_send_head(sk))) {
unsigned int limit;
--
2.14.2
^ permalink raw reply related
* [RFC PATCH v2 3/5] tcp: added get_segs_per_round
From: Natale Patriciello @ 2017-10-14 11:47 UTC (permalink / raw)
To: David S . Miller, Eric Dumazet
Cc: netdev, Ahmed Said, Natale Patriciello, Francesco Zampognaro,
Cesare Roseti
In-Reply-To: <20171014114714.3694-1-natale.patriciello@gmail.com>
Usually, the pacing time is provided per-segment. In some occasion, this
time refers to the time between a group of segments. With this commit, add
the possibility for the congestion control module to tell the TCP socket
how many segments can be sent out before pausing and setting a pacing
timer.
Signed-off-by: Natale Patriciello <natale.patriciello@gmail.com>
---
include/net/tcp.h | 2 ++
net/ipv4/tcp_output.c | 13 +++++++++----
2 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/include/net/tcp.h b/include/net/tcp.h
index e817f0669d0e..3561eca5a61f 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -1019,6 +1019,8 @@ struct tcp_congestion_ops {
u64 (*get_pacing_time)(struct sock *sk);
/* the pacing timer is expired (optional) */
void (*pacing_timer_expired)(struct sock *sk);
+ /* get the # segs to send out when the timer expires (optional) */
+ u32 (*get_segs_per_round)(struct sock *sk);
char name[TCP_CA_NAME_MAX];
struct module *owner;
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index 25b4cf0802f2..e37941e4328b 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -2249,6 +2249,7 @@ static bool tcp_write_xmit(struct sock *sk, unsigned int mss_now, int nonagle,
int result;
bool is_cwnd_limited = false, is_rwnd_limited = false;
u32 max_segs;
+ u32 pacing_allowed_segs = 0;
sent_pkts = 0;
@@ -2265,14 +2266,18 @@ static bool tcp_write_xmit(struct sock *sk, unsigned int mss_now, int nonagle,
max_segs = tcp_tso_segs(sk, mss_now);
tcp_mstamp_refresh(tp);
- if (!tcp_pacing_timer_check(sk) &&
- ca_ops && ca_ops->pacing_timer_expired)
- ca_ops->pacing_timer_expired(sk);
+ if (!tcp_pacing_timer_check(sk)) {
+ pacing_allowed_segs = 1;
+ if (ca_ops && ca_ops->pacing_timer_expired)
+ ca_ops->pacing_timer_expired(sk);
+ if (ca_ops && ca_ops->get_segs_per_round)
+ pacing_allowed_segs = ca_ops->get_segs_per_round(sk);
+ }
while ((skb = tcp_send_head(sk))) {
unsigned int limit;
- if (tcp_pacing_check(sk))
+ if (sent_pkts >= pacing_allowed_segs)
break;
tso_segs = tcp_init_tso_segs(skb, mss_now);
--
2.14.2
^ permalink raw reply related
* [RFC PATCH v2 4/5] tcp: added segment sent
From: Natale Patriciello @ 2017-10-14 11:47 UTC (permalink / raw)
To: David S . Miller, Eric Dumazet
Cc: netdev, Ahmed Said, Natale Patriciello, Francesco Zampognaro,
Cesare Roseti
In-Reply-To: <20171014114714.3694-1-natale.patriciello@gmail.com>
Inform the congestion control of the number of segment sent in normal
conditions, it means segments that left the node without involving
recovery or retransmission procedures.
Signed-off-by: Natale Patriciello <natale.patriciello@gmail.com>
---
include/net/tcp.h | 2 ++
net/ipv4/tcp_output.c | 10 +++++++++-
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/include/net/tcp.h b/include/net/tcp.h
index 3561eca5a61f..aebe225ab8b1 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -1021,6 +1021,8 @@ struct tcp_congestion_ops {
void (*pacing_timer_expired)(struct sock *sk);
/* get the # segs to send out when the timer expires (optional) */
u32 (*get_segs_per_round)(struct sock *sk);
+ /* the TCP has sent some segments (optional) */
+ void (*segments_sent)(struct sock *sk, u32 sent);
char name[TCP_CA_NAME_MAX];
struct module *owner;
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index e37941e4328b..ef50202659da 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -2250,6 +2250,7 @@ static bool tcp_write_xmit(struct sock *sk, unsigned int mss_now, int nonagle,
bool is_cwnd_limited = false, is_rwnd_limited = false;
u32 max_segs;
u32 pacing_allowed_segs = 0;
+ bool notify = false;
sent_pkts = 0;
@@ -2268,8 +2269,12 @@ static bool tcp_write_xmit(struct sock *sk, unsigned int mss_now, int nonagle,
if (!tcp_pacing_timer_check(sk)) {
pacing_allowed_segs = 1;
- if (ca_ops && ca_ops->pacing_timer_expired)
+
+ if (ca_ops && ca_ops->pacing_timer_expired) {
ca_ops->pacing_timer_expired(sk);
+ notify = true;
+ }
+
if (ca_ops && ca_ops->get_segs_per_round)
pacing_allowed_segs = ca_ops->get_segs_per_round(sk);
}
@@ -2348,6 +2353,9 @@ static bool tcp_write_xmit(struct sock *sk, unsigned int mss_now, int nonagle,
break;
}
+ if (ca_ops && notify && ca_ops->segments_sent)
+ ca_ops->segments_sent(sk, sent_pkts);
+
if (is_rwnd_limited)
tcp_chrono_start(sk, TCP_CHRONO_RWND_LIMITED);
else
--
2.14.2
^ permalink raw reply related
* [RFC PATCH v2 5/5] wave: Added TCP Wave
From: Natale Patriciello @ 2017-10-14 11:47 UTC (permalink / raw)
To: David S . Miller, Eric Dumazet
Cc: netdev, Ahmed Said, Natale Patriciello, Francesco Zampognaro,
Cesare Roseti
In-Reply-To: <20171014114714.3694-1-natale.patriciello@gmail.com>
TCP Wave (TCPW) replaces the window-based transmission paradigm of the
standard TCP with a burst-based transmission, the ACK-clock scheduling
with a self-managed timer and the RTT-based congestion control loop
with an Ack-based Capacity and Congestion Estimation (ACCE) module. In
non-technical words, it sends data down the stack when its internal
timer expires, and the timing of the received ACKs contribute to
updating this timer regularly.
It is the first TCP congestion control that uses the timing constraint
developed in the Linux kernel.
Signed-off-by: Natale Patriciello <natale.patriciello@gmail.com>
Tested-by: Ahmed Said <ahmed.said@uniroma2.it>
---
MAINTAINERS | 6 +
include/uapi/linux/inet_diag.h | 13 +
net/ipv4/Kconfig | 16 +
net/ipv4/Makefile | 1 +
net/ipv4/tcp_output.c | 4 +-
net/ipv4/tcp_wave.c | 1035 ++++++++++++++++++++++++++++++++++++++++
6 files changed, 1074 insertions(+), 1 deletion(-)
create mode 100644 net/ipv4/tcp_wave.c
diff --git a/MAINTAINERS b/MAINTAINERS
index 2d3d750b19c0..b59815dcda67 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -13024,6 +13024,12 @@ W: http://tcp-lp-mod.sourceforge.net/
S: Maintained
F: net/ipv4/tcp_lp.c
+TCP WAVE MODULE
+M: "Natale Patriciello" <natale.patriciello@gmail.com>
+W: http://tlcsat.uniroma2.it/tcpwave4linux/
+S: Maintained
+F: net/ipv4/tcp_wave.c
+
TDA10071 MEDIA DRIVER
M: Antti Palosaari <crope@iki.fi>
L: linux-media@vger.kernel.org
diff --git a/include/uapi/linux/inet_diag.h b/include/uapi/linux/inet_diag.h
index f52ff62bfabe..2f204844e580 100644
--- a/include/uapi/linux/inet_diag.h
+++ b/include/uapi/linux/inet_diag.h
@@ -142,6 +142,7 @@ enum {
INET_DIAG_PAD,
INET_DIAG_MARK,
INET_DIAG_BBRINFO,
+ INET_DIAG_WAVEINFO,
INET_DIAG_CLASS_ID,
INET_DIAG_MD5SIG,
__INET_DIAG_MAX,
@@ -188,9 +189,21 @@ struct tcp_bbr_info {
__u32 bbr_cwnd_gain; /* cwnd gain shifted left 8 bits */
};
+/* INET_DIAG_WAVEINFO */
+
+struct tcp_wave_info {
+ __u32 tx_timer;
+ __u16 burst;
+ __u32 previous_ack_t_disp;
+ __u32 min_rtt;
+ __u32 avg_rtt;
+ __u32 max_rtt;
+};
+
union tcp_cc_info {
struct tcpvegas_info vegas;
struct tcp_dctcp_info dctcp;
struct tcp_bbr_info bbr;
+ struct tcp_wave_info wave;
};
#endif /* _UAPI_INET_DIAG_H_ */
diff --git a/net/ipv4/Kconfig b/net/ipv4/Kconfig
index 91a2557942fa..de23b3a04b98 100644
--- a/net/ipv4/Kconfig
+++ b/net/ipv4/Kconfig
@@ -492,6 +492,18 @@ config TCP_CONG_BIC
increase provides TCP friendliness.
See http://www.csc.ncsu.edu/faculty/rhee/export/bitcp/
+config TCP_CONG_WAVE
+ tristate "Wave TCP"
+ default m
+ ---help---
+ TCP Wave (TCPW) replaces the window-based transmission paradigm of the
+ standard TCP with a burst-based transmission, the ACK-clock scheduling
+ with a self-managed timer and the RTT-based congestion control loop with
+ an Ack-based Capacity and Congestion Estimation (ACCE) module. In
+ non-technical words, it sends data down the stack when its internal
+ timer expires, and the timing of the received ACKs contribute to
+ updating this timer regularly.
+
config TCP_CONG_CUBIC
tristate "CUBIC TCP"
default y
@@ -690,6 +702,9 @@ choice
config DEFAULT_CUBIC
bool "Cubic" if TCP_CONG_CUBIC=y
+ config DEFAULT_WAVE
+ bool "Wave" if TCP_CONG_WAVE=y
+
config DEFAULT_HTCP
bool "Htcp" if TCP_CONG_HTCP=y
@@ -729,6 +744,7 @@ config DEFAULT_TCP_CONG
string
default "bic" if DEFAULT_BIC
default "cubic" if DEFAULT_CUBIC
+ default "wave" if DEFAULT_WAVE
default "htcp" if DEFAULT_HTCP
default "hybla" if DEFAULT_HYBLA
default "vegas" if DEFAULT_VEGAS
diff --git a/net/ipv4/Makefile b/net/ipv4/Makefile
index afcb435adfbe..bdc8cd1a804a 100644
--- a/net/ipv4/Makefile
+++ b/net/ipv4/Makefile
@@ -47,6 +47,7 @@ obj-$(CONFIG_TCP_CONG_BBR) += tcp_bbr.o
obj-$(CONFIG_TCP_CONG_BIC) += tcp_bic.o
obj-$(CONFIG_TCP_CONG_CDG) += tcp_cdg.o
obj-$(CONFIG_TCP_CONG_CUBIC) += tcp_cubic.o
+obj-$(CONFIG_TCP_CONG_WAVE) += tcp_wave.o
obj-$(CONFIG_TCP_CONG_DCTCP) += tcp_dctcp.o
obj-$(CONFIG_TCP_CONG_WESTWOOD) += tcp_westwood.o
obj-$(CONFIG_TCP_CONG_HSTCP) += tcp_highspeed.o
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index ef50202659da..40ec467e5afd 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -2527,7 +2527,9 @@ void tcp_push_one(struct sock *sk, unsigned int mss_now)
{
struct sk_buff *skb = tcp_send_head(sk);
- BUG_ON(!skb || skb->len < mss_now);
+ /* Don't be forced to send not meaningful data */
+ if (!skb || skb->len < mss_now)
+ return;
tcp_write_xmit(sk, mss_now, TCP_NAGLE_PUSH, 1, sk->sk_allocation);
}
diff --git a/net/ipv4/tcp_wave.c b/net/ipv4/tcp_wave.c
new file mode 100644
index 000000000000..f5a1e1412caf
--- /dev/null
+++ b/net/ipv4/tcp_wave.c
@@ -0,0 +1,1035 @@
+/*
+ * TCP Wave
+ *
+ * Copyright 2017 Natale Patriciello <natale.patriciello@gmail.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#define pr_fmt(fmt) "WAVE: " fmt
+
+#include <net/tcp.h>
+#include <linux/inet_diag.h>
+#include <linux/module.h>
+
+#define NOW ktime_to_us(ktime_get())
+#define SPORT(sk) ntohs(inet_sk(sk)->inet_sport)
+#define DPORT(sk) ntohs(inet_sk(sk)->inet_dport)
+
+static uint init_burst __read_mostly = 10;
+static uint min_burst __read_mostly = 3;
+static uint init_timer_ms __read_mostly = 200;
+static uint beta_ms __read_mostly = 150;
+
+module_param(init_burst, uint, 0644);
+MODULE_PARM_DESC(init_burst, "initial burst (segments)");
+module_param(min_burst, uint, 0644);
+MODULE_PARM_DESC(min_burst, "minimum burst (segments)");
+module_param(init_timer_ms, uint, 0644);
+MODULE_PARM_DESC(init_timer_ms, "initial timer (ms)");
+module_param(beta_ms, uint, 0644);
+MODULE_PARM_DESC(beta_ms, "beta parameter (ms)");
+
+/* Shift factor for the exponentially weighted average. */
+#define AVG_SCALE 20
+#define AVG_UNIT BIT(AVG_SCALE)
+
+/* Tell if the driver is initialized (init has been called) */
+#define FLAG_INIT 0x1
+/* Tell if, as sender, the driver is started (after TX_START) */
+#define FLAG_START 0x2
+/* If it's true, we save the sent size as a burst */
+#define FLAG_SAVE 0x4
+
+/* List for saving the size of sent burst over time */
+struct wavetcp_burst_hist {
+ u16 size; /* The burst size */
+ struct list_head list; /* Kernel list declaration */
+};
+
+static bool test_flag(u8 flags, u8 value)
+{
+ return (flags & value) == value;
+}
+
+static void set_flag(u8 *flags, u8 value)
+{
+ *flags |= value;
+}
+
+static void clear_flag(u8 *flags, u8 value)
+{
+ *flags &= ~(value);
+}
+
+static bool ktime_is_null(ktime_t kt)
+{
+ return ktime_compare(kt, ns_to_ktime(0)) == 0;
+}
+
+/* TCP Wave private struct */
+struct wavetcp {
+ u8 flags; /* The module flags */
+ u32 tx_timer; /* The current transmission timer (us) */
+ u8 burst; /* The current burst size (segments) */
+ s8 delta_segments; /* Difference between sent and burst size */
+ u16 pkts_acked; /* The segments acked in the round */
+ u8 backup_pkts_acked;
+ u8 aligned_acks_rcv; /* The number of ACKs received in a round */
+ u8 heuristic_scale; /* Heuristic scale, to divide the RTT */
+ ktime_t previous_ack_t_disp; /* Previous ack_train_disp Value */
+ ktime_t first_ack_time; /* First ACK time of the round */
+ ktime_t last_ack_time; /* Last ACK time of the round */
+ u32 backup_first_ack_time_us; /* Backup value of the first ack time */
+ u32 previous_rtt; /* RTT of the previous acked segment */
+ u32 first_rtt; /* First RTT of the round */
+ u32 min_rtt; /* Minimum RTT of the round */
+ u32 avg_rtt; /* Average RTT of the previous round */
+ u32 max_rtt; /* Maximum RTT */
+ u8 stab_factor; /* Stability factor */
+ struct kmem_cache *cache; /* The memory for saving the burst sizes */
+ struct wavetcp_burst_hist *history; /* The burst history */
+};
+
+/* Called to setup Wave for the current socket after it enters the CONNECTED
+ * state (i.e., called after the SYN-ACK is received). The slow start should be
+ * 0 (see wavetcp_get_ssthresh) and we set the initial cwnd to the initial
+ * burst.
+ *
+ * After the ACK of the SYN-ACK is sent, the TCP will add a bit of delay to
+ * permit the queueing of data from the application, otherwise we will end up
+ * in a scattered situation (we have one segment -> send it -> no other segment,
+ * don't set the timer -> slightly after, another segment come and we loop).
+ *
+ * At the first expiration, the cwnd will be large enough to push init_burst
+ * segments out.
+ */
+static void wavetcp_init(struct sock *sk)
+{
+ struct wavetcp *ca = inet_csk_ca(sk);
+ struct tcp_sock *tp = tcp_sk(sk);
+
+ pr_debug("%llu sport: %u [%s]\n", NOW, SPORT(sk), __func__);
+
+ /* Setting the initial Cwnd to 0 will not call the TX_START event */
+ tp->snd_ssthresh = 0;
+ tp->snd_cwnd = init_burst;
+
+ /* Used to avoid to take the SYN-ACK measurements */
+ ca->flags = 0;
+ ca->flags = FLAG_INIT | FLAG_SAVE;
+
+ ca->burst = init_burst;
+ ca->delta_segments = init_burst;
+ ca->tx_timer = init_timer_ms * USEC_PER_MSEC;
+ ca->pkts_acked = 0;
+ ca->backup_pkts_acked = 0;
+ ca->aligned_acks_rcv = 0;
+ ca->first_ack_time = ns_to_ktime(0);
+ ca->backup_first_ack_time_us = 0;
+ ca->heuristic_scale = 0;
+ ca->first_rtt = 0;
+ ca->min_rtt = -1; /* a lot of time */
+ ca->avg_rtt = 0;
+ ca->max_rtt = 0;
+ ca->stab_factor = 0;
+ ca->previous_ack_t_disp = ns_to_ktime(0);
+
+ ca->history = kmalloc(sizeof(*ca->history), GFP_KERNEL);
+
+ /* Init the history of bwnd */
+ INIT_LIST_HEAD(&ca->history->list);
+
+ /* Init our cache pool for the bwnd history */
+ ca->cache = KMEM_CACHE(wavetcp_burst_hist, 0);
+
+ cmpxchg(&sk->sk_pacing_status, SK_PACING_NONE, SK_PACING_NEEDED);
+}
+
+static void wavetcp_release(struct sock *sk)
+{
+ struct wavetcp *ca = inet_csk_ca(sk);
+ struct wavetcp_burst_hist *tmp;
+ struct list_head *pos, *q;
+
+ if (!test_flag(ca->flags, FLAG_INIT))
+ return;
+
+ pr_debug("%llu sport: %u [%s]\n", NOW, SPORT(sk), __func__);
+
+ list_for_each_safe(pos, q, &ca->history->list) {
+ tmp = list_entry(pos, struct wavetcp_burst_hist, list);
+ list_del(pos);
+ kmem_cache_free(ca->cache, tmp);
+ }
+
+ kfree(ca->history);
+ kmem_cache_destroy(ca->cache);
+}
+
+/* Please explain that we will be forever in congestion avoidance. */
+static u32 wavetcp_recalc_ssthresh(struct sock *sk)
+{
+ pr_debug("%llu [%s]\n", NOW, __func__);
+ return 0;
+}
+
+static void wavetcp_state(struct sock *sk, u8 new_state)
+{
+ struct wavetcp *ca = inet_csk_ca(sk);
+
+ if (!test_flag(ca->flags, FLAG_INIT))
+ return;
+
+ switch (new_state) {
+ case TCP_CA_Open:
+ pr_debug("%llu sport: %u [%s] set CA_Open\n", NOW,
+ SPORT(sk), __func__);
+ /* We have fully recovered, so reset some variables */
+ ca->delta_segments = 0;
+ break;
+ default:
+ pr_debug("%llu sport: %u [%s] set state %u, ignored\n",
+ NOW, SPORT(sk), __func__, new_state);
+ }
+}
+
+static u32 wavetcp_undo_cwnd(struct sock *sk)
+{
+ struct tcp_sock *tp = tcp_sk(sk);
+
+ /* Not implemented yet. We stick to the decision made earlier */
+ pr_debug("%llu [%s]\n", NOW, __func__);
+ return tp->snd_cwnd;
+}
+
+/* Add the size of the burst in the history of bursts */
+static void wavetcp_insert_burst(struct wavetcp *ca, u32 burst)
+{
+ struct wavetcp_burst_hist *cur;
+
+ pr_debug("%llu [%s] adding %u segment in the history of burst\n", NOW,
+ __func__, burst);
+ /* Take the memory from the pre-allocated pool */
+ cur = (struct wavetcp_burst_hist *)kmem_cache_alloc(ca->cache,
+ GFP_KERNEL);
+ BUG_ON(!cur);
+
+ cur->size = burst;
+ list_add_tail(&cur->list, &ca->history->list);
+}
+
+static void wavetcp_cwnd_event(struct sock *sk, enum tcp_ca_event event)
+{
+ struct wavetcp *ca = inet_csk_ca(sk);
+
+ if (!test_flag(ca->flags, FLAG_INIT))
+ return;
+
+ switch (event) {
+ case CA_EVENT_TX_START:
+ /* first transmit when no packets in flight */
+ pr_debug("%llu sport: %u [%s] TX_START\n", NOW,
+ SPORT(sk), __func__);
+
+ set_flag(&ca->flags, FLAG_START);
+
+ break;
+ default:
+ pr_debug("%llu sport: %u [%s] got event %u, ignored\n",
+ NOW, SPORT(sk), __func__, event);
+ break;
+ }
+}
+
+static void wavetcp_adj_mode(struct sock *sk, unsigned long delta_rtt)
+{
+ struct wavetcp *ca = inet_csk_ca(sk);
+
+ ca->stab_factor = ca->avg_rtt / ca->tx_timer;
+
+ ca->min_rtt = -1; /* a lot of time */
+ ca->avg_rtt = ca->max_rtt;
+ ca->tx_timer = init_timer_ms * USEC_PER_MSEC;
+
+ pr_debug("%llu sport: %u [%s] stab_factor %u, timer %u us, avg_rtt %u us\n",
+ NOW, SPORT(sk), __func__, ca->stab_factor,
+ ca->tx_timer, ca->avg_rtt);
+}
+
+static void wavetcp_tracking_mode(struct sock *sk, u64 delta_rtt,
+ ktime_t ack_train_disp)
+{
+ struct wavetcp *ca = inet_csk_ca(sk);
+
+ if (ktime_is_null(ack_train_disp)) {
+ pr_debug("%llu sport: %u [%s] ack_train_disp is 0. Impossible to do tracking.\n",
+ NOW, SPORT(sk), __func__);
+ return;
+ }
+
+ ca->tx_timer = (ktime_to_us(ack_train_disp) + (delta_rtt / 2));
+
+ if (ca->tx_timer == 0) {
+ pr_debug("%llu sport: %u [%s] WARNING: tx timer is 0"
+ ", forcefully set it to 1000 us\n",
+ NOW, SPORT(sk), __func__);
+ ca->tx_timer = 1000;
+ }
+
+ pr_debug("%llu sport: %u [%s] tx timer is %u us\n",
+ NOW, SPORT(sk), __func__, ca->tx_timer);
+}
+
+/* The weight a is:
+ *
+ * a = (first_rtt - min_rtt) / first_rtt
+ *
+ */
+static u64 wavetcp_compute_weight(u32 first_rtt, u32 min_rtt)
+{
+ u64 diff = first_rtt - min_rtt;
+
+ diff = diff * AVG_UNIT;
+
+ return diff / first_rtt;
+}
+
+static ktime_t heuristic_ack_train_disp(struct sock *sk,
+ const struct rate_sample *rs,
+ u32 burst)
+{
+ struct wavetcp *ca = inet_csk_ca(sk);
+ ktime_t ack_train_disp = ns_to_ktime(0);
+ ktime_t interval = ns_to_ktime(0);
+ ktime_t backup_first_ack = ns_to_ktime(0);
+
+ if (rs->interval_us <= 0) {
+ pr_debug("%llu sport: %u [%s] WARNING is not possible "
+ "to heuristically calculate ack_train_disp, returning 0."
+ "Delivered %u, interval_us %li\n",
+ NOW, SPORT(sk), __func__,
+ rs->delivered, rs->interval_us);
+ return ack_train_disp;
+ }
+
+ interval = ns_to_ktime(rs->interval_us * NSEC_PER_USEC);
+ backup_first_ack = ns_to_ktime(ca->backup_first_ack_time_us * NSEC_PER_USEC);
+
+ /* The heuristic takes the RTT of the first ACK, the RTT of the
+ * latest ACK, and uses the difference as ack_train_disp.
+ *
+ * If the sample for the first and last ACK are the same (e.g.,
+ * one ACK per burst) we use as the latest option the value of
+ * interval_us (which is the RTT). However, this value is
+ * exponentially lowered each time we don't have any valid
+ * sample (i.e., we perform a division by 2, by 4, and so on).
+ * The increased transmitted rate, if it is out of the capacity
+ * of the bottleneck, will be compensated by an higher
+ * delta_rtt, and so limited by the adjustment algorithm. This
+ * is a blind search, but we do not have any valid sample...
+ */
+ if (ktime_compare(interval, backup_first_ack) > 0) {
+ /* first heuristic */
+ ack_train_disp = ktime_sub(interval, backup_first_ack);
+ } else {
+ /* this branch avoids an overflow. However, reaching
+ * this point means that the ACK train is not aligned
+ * with the sent burst.
+ */
+ ack_train_disp = ktime_sub(backup_first_ack, interval);
+ }
+
+ if (ktime_is_null(ack_train_disp)) {
+ /* Blind search */
+ u32 blind_interval_us = rs->interval_us >> ca->heuristic_scale;
+ ++ca->heuristic_scale;
+ ack_train_disp = ns_to_ktime(blind_interval_us * NSEC_PER_USEC);
+ pr_debug("%llu sport: %u [%s] we received one BIG ack."
+ " Doing an heuristic with scale %u, interval_us"
+ " %li us, and setting ack_train_disp to %lli us\n",
+ NOW, SPORT(sk), __func__, ca->heuristic_scale,
+ rs->interval_us, ktime_to_us(ack_train_disp));
+ } else {
+ pr_debug("%llu sport: %u [%s] we got the first ack with"
+ " interval %u us, the last (this) with interval %li us."
+ " Doing a substraction and setting ack_train_disp"
+ " to %lli us\n", NOW, SPORT(sk), __func__,
+ ca->backup_first_ack_time_us, rs->interval_us,
+ ktime_to_us(ack_train_disp));
+ }
+
+ return ack_train_disp;
+}
+
+/* In case that round_burst == current_burst:
+ *
+ * ack_train_disp = last - first * (rcv_ack/rcv_ack-1)
+ * |__________| |_________________|
+ * left right
+ *
+ * else (assuming left is last - first)
+ *
+ * left
+ * ack_train_disp = ------------ * current_burst
+ * round_burst
+ */
+static ktime_t get_ack_train_disp(const ktime_t *last_ack_time,
+ const ktime_t *first_ack_time,
+ u8 aligned_acks_rcv, u32 round_burst,
+ u32 current_burst)
+{
+ u64 left = ktime_to_ns(*last_ack_time) - ktime_to_ns(*first_ack_time);
+ u64 right;
+
+ if (round_burst == current_burst) {
+ right = (aligned_acks_rcv * AVG_UNIT) / (aligned_acks_rcv - 1);
+ pr_debug("%llu [%s] last %lli us, first %lli us, acks %u round_burst %u current_burst %u\n",
+ NOW, __func__, ktime_to_us(*last_ack_time),
+ ktime_to_us(*first_ack_time), aligned_acks_rcv,
+ round_burst, current_burst);
+ } else {
+ right = current_burst;
+ left *= AVG_UNIT;
+ left = left / round_burst;
+ pr_debug("%llu [%s] last %lli us, first %lli us, small_round_burst %u\n",
+ NOW, __func__, ktime_to_us(*last_ack_time),
+ ktime_to_us(*first_ack_time), round_burst);
+ }
+
+ return ns_to_ktime((left * right) / AVG_UNIT);
+}
+
+static ktime_t calculate_ack_train_disp(struct sock *sk,
+ const struct rate_sample *rs,
+ u32 burst, u64 delta_rtt_us)
+{
+ struct wavetcp *ca = inet_csk_ca(sk);
+ ktime_t ack_train_disp = ns_to_ktime(0);
+
+ if (ktime_is_null(ca->first_ack_time) || ca->aligned_acks_rcv <= 1) {
+ /* We don't have the initial bound of the burst,
+ * or we don't have samples to do measurements
+ */
+ if (ktime_is_null(ca->previous_ack_t_disp))
+ /* do heuristic without saving anything */
+ return heuristic_ack_train_disp(sk, rs, burst);
+
+ /* Returning the previous value */
+ return ca->previous_ack_t_disp;
+ }
+
+ /* If we have a complete burst, the value returned by get_ack_train_disp
+ * is safe to use. Otherwise, it can be a bad approximation, so it's better
+ * to use the previous value. Of course, if we don't have such value,
+ * a bad approximation is better than nothing.
+ */
+ if (burst == ca->burst || ktime_is_null(ca->previous_ack_t_disp))
+ ack_train_disp = get_ack_train_disp(&ca->last_ack_time,
+ &ca->first_ack_time,
+ ca->aligned_acks_rcv,
+ burst, ca->burst);
+ else
+ return ca->previous_ack_t_disp;
+
+ if (ktime_is_null(ack_train_disp)) {
+ /* Use the plain previous value */
+ pr_debug("%llu sport: %u [%s] use_plain previous_ack_train_disp %lli us, ack_train_disp %lli us\n",
+ NOW, SPORT(sk), __func__,
+ ktime_to_us(ca->previous_ack_t_disp),
+ ktime_to_us(ack_train_disp));
+ return ca->previous_ack_t_disp;
+ }
+
+ /* We have a real sample! */
+ ca->heuristic_scale = 0;
+ ca->previous_ack_t_disp = ack_train_disp;
+
+ pr_debug("%llu sport: %u [%s] previous_ack_train_disp %lli us, final_ack_train_disp %lli us\n",
+ NOW, SPORT(sk), __func__, ktime_to_us(ca->previous_ack_t_disp),
+ ktime_to_us(ack_train_disp));
+
+ return ack_train_disp;
+}
+
+static u32 calculate_avg_rtt(struct sock *sk)
+{
+ const struct wavetcp *ca = inet_csk_ca(sk);
+
+ /* Why the if?
+ *
+ * a = (first_rtt - min_rtt) / first_rtt = 1 - (min_rtt/first_rtt)
+ *
+ * avg_rtt_0 = (1 - a) * first_rtt
+ * = (1 - (1 - (min_rtt/first_rtt))) * first_rtt
+ * = first_rtt - (first_rtt - min_rtt)
+ * = min_rtt
+ *
+ *
+ * And.. what happen in the else branch? We calculate first a (scaled by
+ * 1024), then do the substraction (1-a) by keeping in the consideration
+ * the scale, and in the end coming back to the result removing the
+ * scaling.
+ *
+ * We divide the equation
+ *
+ * AvgRtt = a * AvgRtt + (1-a)*Rtt
+ *
+ * in two part properly scaled, left and right, and then having a sum of
+ * the two parts to avoid (possible) overflow.
+ */
+ if (ca->avg_rtt == 0) {
+ pr_debug("%llu sport: %u [%s] returning min_rtt %u\n",
+ NOW, SPORT(sk), __func__, ca->min_rtt);
+ return ca->min_rtt;
+ } else if (ca->first_rtt > 0) {
+ u32 old_value = ca->avg_rtt;
+ u64 right;
+ u64 left;
+ u64 a;
+
+ a = wavetcp_compute_weight(ca->first_rtt, ca->min_rtt);
+
+ left = (a * ca->avg_rtt) / AVG_UNIT;
+ right = ((AVG_UNIT - a) * ca->first_rtt) / AVG_UNIT;
+
+ pr_debug("%llu sport: %u [%s] previous avg %u us, first_rtt %u us, "
+ "min %u us, a (shifted) %llu, calculated avg %u us\n",
+ NOW, SPORT(sk), __func__, old_value, ca->first_rtt,
+ ca->min_rtt, a, (u32)left + (u32)right);
+ return (u32)left + (u32)right;
+ }
+
+ pr_debug("%llu sport: %u [%s] Can't calculate avg_rtt.\n",
+ NOW, SPORT(sk), __func__);
+ return 0;
+}
+
+static u64 calculate_delta_rtt(const struct wavetcp *ca)
+{
+ return ca->avg_rtt - ca->min_rtt;
+}
+
+static void wavetcp_round_terminated(struct sock *sk,
+ const struct rate_sample *rs,
+ u32 burst)
+{
+ struct wavetcp *ca = inet_csk_ca(sk);
+ ktime_t ack_train_disp;
+ u64 delta_rtt_us;
+ u32 avg_rtt;
+
+ avg_rtt = calculate_avg_rtt(sk);
+ if (avg_rtt != 0)
+ ca->avg_rtt = avg_rtt;
+
+ /* If we have to wait, let's wait */
+ if (ca->stab_factor > 0) {
+ --ca->stab_factor;
+ pr_debug("%llu sport: %u [%s] reached burst %u, not applying (stab left: %u)\n",
+ NOW, SPORT(sk), __func__, burst, ca->stab_factor);
+ return;
+ }
+
+ delta_rtt_us = calculate_delta_rtt(ca);
+ ack_train_disp = calculate_ack_train_disp(sk, rs, burst, delta_rtt_us);
+
+ pr_debug("%llu sport: %u [%s] reached burst %u, drtt %llu, atd %lli\n",
+ NOW, SPORT(sk), __func__, burst, delta_rtt_us,
+ ktime_to_us(ack_train_disp));
+
+ /* delta_rtt_us is in us, beta_ms in ms */
+ if (delta_rtt_us > beta_ms * USEC_PER_MSEC)
+ wavetcp_adj_mode(sk, delta_rtt_us);
+ else
+ wavetcp_tracking_mode(sk, delta_rtt_us, ack_train_disp);
+}
+
+static void wavetcp_reset_round(struct wavetcp *ca)
+{
+ ca->first_ack_time = ns_to_ktime(0);
+ ca->last_ack_time = ca->first_ack_time;
+ ca->backup_first_ack_time_us = 0;
+ ca->aligned_acks_rcv = 0;
+ ca->first_rtt = 0;
+}
+
+static void wavetcp_middle_round(struct sock *sk, ktime_t *last_ack_time,
+ const ktime_t *now)
+{
+ pr_debug("%llu sport: %u [%s]", NOW, SPORT(sk), __func__);
+ *last_ack_time = *now;
+}
+
+static void wavetcp_begin_round(struct sock *sk, ktime_t *first_ack_time,
+ ktime_t *last_ack_time, const ktime_t *now)
+{
+ pr_debug("%llu sport: %u [%s]", NOW, SPORT(sk), __func__);
+ *first_ack_time = *now;
+ *last_ack_time = *now;
+ pr_debug("%llu sport: %u [%s], first %lli\n", NOW, SPORT(sk),
+ __func__, ktime_to_us(*first_ack_time));
+}
+
+static void wavetcp_rtt_measurements(struct sock *sk, s32 rtt_us,
+ s32 interval_us)
+{
+ struct wavetcp *ca = inet_csk_ca(sk);
+
+ if (ca->backup_first_ack_time_us == 0 && interval_us > 0)
+ ca->backup_first_ack_time_us = interval_us;
+
+ if (rtt_us <= 0)
+ return;
+
+ ca->previous_rtt = rtt_us;
+
+ /* Check the first RTT in the round */
+ if (ca->first_rtt == 0) {
+ ca->first_rtt = rtt_us;
+
+ /* Check the minimum RTT we have seen */
+ if (rtt_us < ca->min_rtt) {
+ ca->min_rtt = rtt_us;
+ pr_debug("%llu sport: %u [%s] min rtt %u\n", NOW,
+ SPORT(sk), __func__, rtt_us);
+ }
+
+ /* Check the maximum RTT we have seen */
+ if (rtt_us > ca->max_rtt) {
+ ca->max_rtt = rtt_us;
+ pr_debug("%llu sport: %u [%s] max rtt %u\n", NOW,
+ SPORT(sk), __func__, rtt_us);
+ }
+ }
+}
+
+static void wavetcp_end_round(struct sock *sk, const struct rate_sample *rs,
+ const ktime_t *now)
+{
+ struct wavetcp *ca = inet_csk_ca(sk);
+ struct wavetcp_burst_hist *tmp;
+ struct list_head *pos;
+
+ pr_debug("%llu [%s]", NOW, __func__);
+ pos = ca->history->list.next;
+ tmp = list_entry(pos, struct wavetcp_burst_hist, list);
+
+ if (!tmp || ca->pkts_acked < tmp->size) {
+ pr_debug("%llu sport: %u [%s] WARNING: Something wrong\n",
+ NOW, SPORT(sk), __func__);
+ return;
+ }
+
+ /* The position we are is end_round, but if the following is false,
+ * in reality we are at the beginning of the next round,
+ * and the previous middle was an end. In the other case,
+ * update last_ack_time with the current time, and the number of
+ * received acks.
+ */
+ if (rs->rtt_us >= ca->previous_rtt) {
+ ++ca->aligned_acks_rcv;
+ ca->last_ack_time = *now;
+ }
+
+ /* If the round terminates without a sample of RTT, use the average */
+ if (ca->first_rtt == 0) {
+ ca->first_rtt = ca->avg_rtt;
+ pr_debug("%llu sport: %u [%s] Using the average value for first_rtt %u\n",
+ NOW, SPORT(sk), __func__, ca->first_rtt);
+ }
+
+ if (tmp->size > min_burst) {
+ wavetcp_round_terminated(sk, rs, tmp->size);
+ } else {
+ pr_debug("%llu sport: %u [%s] skipping burst of %u segments\n",
+ NOW, SPORT(sk), __func__, tmp->size);
+ }
+
+ /* Consume the burst history if it's a cumulative ACK for many bursts */
+ while (tmp && ca->pkts_acked >= tmp->size) {
+ ca->pkts_acked -= tmp->size;
+
+ /* Delete the burst from the history */
+ pr_debug("%llu sport: %u [%s] deleting burst of %u segments\n",
+ NOW, SPORT(sk), __func__, tmp->size);
+ list_del(pos);
+ kmem_cache_free(ca->cache, tmp);
+
+ /* Take next burst */
+ pos = ca->history->list.next;
+ tmp = list_entry(pos, struct wavetcp_burst_hist, list);
+ }
+
+ wavetcp_reset_round(ca);
+
+ /* We have to emulate a beginning of the round in case this RTT is less than
+ * the previous one
+ */
+ if (rs->rtt_us > 0 && rs->rtt_us < ca->previous_rtt) {
+ pr_debug("%llu sport: %u [%s] Emulating the beginning, set the first_rtt to %u\n",
+ NOW, SPORT(sk), __func__, ca->first_rtt);
+
+ /* Emulate the beginning of the round using as "now"
+ * the time of the previous ACK
+ */
+ wavetcp_begin_round(sk, &ca->first_ack_time,
+ &ca->last_ack_time, now);
+ /* Emulate a middle round with the current time */
+ wavetcp_middle_round(sk, &ca->last_ack_time, now);
+
+ /* Take the measurements for the RTT. If we are not emulating a
+ * beginning, then let the real begin to take it
+ */
+ wavetcp_rtt_measurements(sk, rs->rtt_us, rs->interval_us);
+
+ /* Emulate the reception of one aligned ack, this */
+ ca->aligned_acks_rcv = 1;
+ } else if (rs->rtt_us > 0) {
+ ca->previous_rtt = rs->rtt_us;
+ }
+}
+
+static void wavetcp_cong_control(struct sock *sk, const struct rate_sample *rs)
+{
+ ktime_t now = ktime_get();
+ struct wavetcp *ca = inet_csk_ca(sk);
+ struct wavetcp_burst_hist *tmp;
+ struct list_head *pos;
+
+ if (!test_flag(ca->flags, FLAG_INIT))
+ return;
+
+ pr_debug("%llu sport: %u [%s] prior_delivered %u, delivered %i, interval_us %li, "
+ "rtt_us %li, losses %i, ack_sack %u, prior_in_flight %u, is_app %i,"
+ " is_retrans %i\n", NOW, SPORT(sk), __func__,
+ rs->prior_delivered, rs->delivered, rs->interval_us,
+ rs->rtt_us, rs->losses, rs->acked_sacked, rs->prior_in_flight,
+ rs->is_app_limited, rs->is_retrans);
+
+ pos = ca->history->list.next;
+ tmp = list_entry(pos, struct wavetcp_burst_hist, list);
+
+ if (!tmp)
+ return;
+
+ /* Train management.*/
+ ca->pkts_acked += rs->acked_sacked;
+
+ if (ca->previous_rtt < rs->rtt_us)
+ pr_debug("%llu sport: %u [%s] previous < rtt: %u < %li",
+ NOW, SPORT(sk), __func__, ca->previous_rtt,
+ rs->rtt_us);
+ else
+ pr_debug("%llu sport: %u [%s] previous >= rtt: %u >= %li",
+ NOW, SPORT(sk), __func__, ca->previous_rtt,
+ rs->rtt_us);
+
+ /* We have three possibilities: beginning, middle, end.
+ * - Beginning: is the moment in which we receive the first ACK for
+ * the round
+ * - Middle: we are receiving ACKs but still not as many to cover a
+ * complete burst
+ * - End: the other end ACKed sufficient bytes to declare a round
+ * completed
+ */
+ if (ca->pkts_acked < tmp->size) {
+ /* The way to discriminate between beginning and end is thanks
+ * to ca->first_ack_time, which is zeroed at the end of a run
+ */
+ if (ktime_is_null(ca->first_ack_time)) {
+ wavetcp_begin_round(sk, &ca->first_ack_time,
+ &ca->last_ack_time, &now);
+ ++ca->aligned_acks_rcv;
+ ca->backup_pkts_acked = ca->pkts_acked - rs->acked_sacked;
+
+ pr_debug("%llu sport: %u [%s] first ack of the train\n",
+ NOW, SPORT(sk), __func__);
+ } else {
+ if (rs->rtt_us >= ca->previous_rtt) {
+ wavetcp_middle_round(sk, &ca->last_ack_time, &now);
+ ++ca->aligned_acks_rcv;
+ pr_debug("%llu sport: %u [%s] middle aligned ack (tot %u)\n",
+ NOW, SPORT(sk), __func__,
+ ca->aligned_acks_rcv);
+ } else if (rs->rtt_us > 0) {
+ /* This is the real round beginning! */
+ ca->aligned_acks_rcv = 1;
+ ca->pkts_acked = ca->backup_pkts_acked + rs->acked_sacked;
+
+ wavetcp_begin_round(sk, &ca->first_ack_time,
+ &ca->last_ack_time, &now);
+
+ pr_debug("%llu sport: %u [%s] changed beginning to NOW\n",
+ NOW, SPORT(sk), __func__);
+ }
+ }
+
+ /* Take RTT measurements for min and max measurments. For the
+ * end of the burst, do it manually depending on the case
+ */
+ wavetcp_rtt_measurements(sk, rs->rtt_us, rs->interval_us);
+ } else {
+ wavetcp_end_round(sk, rs, &now);
+ }
+}
+
+/* Invoked each time we receive an ACK. Obviously, this function also gets
+ * called when we receive the SYN-ACK, but we ignore it thanks to the
+ * FLAG_INIT flag.
+ *
+ * We close the cwnd of the amount of segments acked, because we don't like
+ * sending out segments if the timer is not expired. Without doing this, we
+ * would end with cwnd - in_flight > 0.
+ */
+static void wavetcp_acked(struct sock *sk, const struct ack_sample *sample)
+{
+ struct wavetcp *ca = inet_csk_ca(sk);
+ struct tcp_sock *tp = tcp_sk(sk);
+
+ if (!test_flag(ca->flags, FLAG_INIT))
+ return;
+
+ if (tp->snd_cwnd < sample->pkts_acked) {
+ /* We sent some scattered segments, so the burst segments and
+ * the ACK we get is not aligned.
+ */
+ pr_debug("%llu sport: %u [%s] delta_seg %i\n",
+ NOW, SPORT(sk), __func__, ca->delta_segments);
+
+ ca->delta_segments += sample->pkts_acked - tp->snd_cwnd;
+ }
+
+ pr_debug("%llu sport: %u [%s] pkts_acked %u, rtt_us %i, in_flight %u "
+ ", cwnd %u, seq ack %u, delta %i\n", NOW, SPORT(sk),
+ __func__, sample->pkts_acked, sample->rtt_us,
+ sample->in_flight, tp->snd_cwnd, tp->snd_una,
+ ca->delta_segments);
+
+ /* Brutally set the cwnd in order to not let segment out */
+ tp->snd_cwnd = tcp_packets_in_flight(tp);
+}
+
+/* The TCP informs us that the timer is expired (or has never been set). We can
+ * infer the latter by the FLAG_STARTED flag: if it's false, don't increase the
+ * cwnd, because it is at its default value (init_burst) and we still have to
+ * transmit the first burst.
+ */
+static void wavetcp_timer_expired(struct sock *sk)
+{
+ struct wavetcp *ca = inet_csk_ca(sk);
+ struct tcp_sock *tp = tcp_sk(sk);
+ u32 current_burst = ca->burst;
+
+ if (!test_flag(ca->flags, FLAG_START) ||
+ !test_flag(ca->flags, FLAG_INIT)) {
+ pr_debug("%llu sport: %u [%s] returning because of flags, leaving cwnd %u\n",
+ NOW, SPORT(sk), __func__, tp->snd_cwnd);
+ return;
+ }
+
+ pr_debug("%llu sport: %u [%s] starting with delta %u current_burst %u\n",
+ NOW, SPORT(sk), __func__, ca->delta_segments, current_burst);
+
+ if (ca->delta_segments < 0) {
+ /* In the previous round, we sent more than the allowed burst,
+ * so reduce the current burst.
+ */
+ BUG_ON(current_burst > ca->delta_segments);
+ current_burst += ca->delta_segments; /* please *reduce* */
+
+ /* Right now, we should send "current_burst" segments out */
+
+ if (tcp_packets_in_flight(tp) > tp->snd_cwnd) {
+ /* For some reasons (e.g., tcp loss probe)
+ * we sent something outside the allowed window.
+ * Add the amount of segments into the burst, in order
+ * to effectively send the previous "current_burst"
+ * segments, but without touching delta_segments.
+ */
+ u32 diff = tcp_packets_in_flight(tp) - tp->snd_cwnd;
+
+ current_burst += diff;
+ pr_debug("%llu sport: %u [%s] adding %u to balance "
+ "segments sent out of window", NOW,
+ SPORT(sk), __func__, diff);
+ }
+ }
+
+ ca->delta_segments = current_burst;
+ pr_debug("%llu sport: %u [%s] setting delta_seg %u current burst %u\n",
+ NOW, SPORT(sk), __func__, ca->delta_segments, current_burst);
+
+ if (current_burst < min_burst) {
+ pr_debug("%llu sport: %u [%s] WARNING !! not min_burst",
+ NOW, SPORT(sk), __func__);
+ ca->delta_segments += min_burst - current_burst;
+ current_burst = min_burst;
+ }
+
+ tp->snd_cwnd += current_burst;
+ set_flag(&ca->flags, FLAG_SAVE);
+
+ pr_debug("%llu sport: %u [%s], increased window of %u segments, "
+ "total %u, delta %i, in_flight %u\n", NOW, SPORT(sk),
+ __func__, ca->burst, tp->snd_cwnd, ca->delta_segments,
+ tcp_packets_in_flight(tp));
+
+ if (tp->snd_cwnd - tcp_packets_in_flight(tp) > current_burst) {
+ pr_debug("%llu sport: %u [%s] WARNING! "
+ " cwnd %u, in_flight %u, current burst %u\n",
+ NOW, SPORT(sk), __func__, tp->snd_cwnd,
+ tcp_packets_in_flight(tp), current_burst);
+ }
+}
+
+static u64 wavetcp_get_timer(struct sock *sk)
+{
+ struct wavetcp *ca = inet_csk_ca(sk);
+ u64 timer;
+
+ BUG_ON(!test_flag(ca->flags, FLAG_INIT));
+
+ timer = min_t(u64,
+ ca->tx_timer * NSEC_PER_USEC,
+ init_timer_ms * NSEC_PER_MSEC);
+
+ /* Very low pacing rate. Ideally, we don't need pacing. */
+ sk->sk_max_pacing_rate = 1;
+
+ pr_debug("%llu sport: %u [%s] returning timer of %llu ns\n",
+ NOW, SPORT(sk), __func__, timer);
+
+ return timer;
+}
+
+static void wavetcp_segment_sent(struct sock *sk, u32 sent)
+{
+ struct tcp_sock *tp = tcp_sk(sk);
+ struct wavetcp *ca = inet_csk_ca(sk);
+
+ if (!test_flag(ca->flags, FLAG_START)) {
+ pr_debug("%llu sport: %u [%s] !START\n",
+ NOW, SPORT(sk), __func__);
+ return;
+ }
+
+ if (test_flag(ca->flags, FLAG_SAVE) && sent > 0) {
+ wavetcp_insert_burst(ca, sent);
+ clear_flag(&ca->flags, FLAG_SAVE);
+ } else {
+ pr_debug("%llu sport: %u [%s] not saving burst, sent %u\n",
+ NOW, SPORT(sk), __func__, sent);
+ }
+
+ if (sent > ca->burst) {
+ pr_debug("%llu sport: %u [%s] WARNING! sent %u, burst %u"
+ " cwnd %u delta_seg %i\n, TSO very probable", NOW,
+ SPORT(sk), __func__, sent, ca->burst,
+ tp->snd_cwnd, ca->delta_segments);
+ }
+
+ ca->delta_segments -= sent;
+
+ if (ca->delta_segments >= 0 &&
+ ca->burst > sent &&
+ tcp_packets_in_flight(tp) <= tp->snd_cwnd) {
+ /* Reduce the cwnd accordingly, because we didn't sent enough
+ * to cover it (we are app limited probably)
+ */
+ u32 diff = ca->burst - sent;
+
+ if (tp->snd_cwnd >= diff)
+ tp->snd_cwnd -= diff;
+ else
+ tp->snd_cwnd = 0;
+ pr_debug("%llu sport: %u [%s] reducing cwnd by %u, value %u\n",
+ NOW, SPORT(sk), __func__,
+ ca->burst - sent, tp->snd_cwnd);
+ }
+}
+
+static size_t wavetcp_get_info(struct sock *sk, u32 ext, int *attr,
+ union tcp_cc_info *info)
+{
+ pr_debug("%llu [%s] ext=%u", NOW, __func__, ext);
+
+ if (ext & (1 << (INET_DIAG_WAVEINFO - 1))) {
+ struct wavetcp *ca = inet_csk_ca(sk);
+
+ memset(&info->wave, 0, sizeof(info->wave));
+ info->wave.tx_timer = ca->tx_timer;
+ info->wave.burst = ca->burst;
+ info->wave.previous_ack_t_disp = ca->previous_ack_t_disp;
+ info->wave.min_rtt = ca->min_rtt;
+ info->wave.avg_rtt = ca->avg_rtt;
+ info->wave.max_rtt = ca->max_rtt;
+ *attr = INET_DIAG_WAVEINFO;
+ return sizeof(info->wave);
+ }
+ return 0;
+}
+
+static u32 wavetcp_sndbuf_expand(struct sock *sk)
+{
+ return 10;
+}
+
+static u32 wavetcp_get_segs_per_round(struct sock *sk)
+{
+ struct wavetcp *ca = inet_csk_ca(sk);
+
+ return ca->burst;
+}
+
+static struct tcp_congestion_ops wave_cong_tcp __read_mostly = {
+ .init = wavetcp_init,
+ .get_info = wavetcp_get_info,
+ .release = wavetcp_release,
+ .ssthresh = wavetcp_recalc_ssthresh,
+/* .cong_avoid = wavetcp_cong_avoid, */
+ .cong_control = wavetcp_cong_control,
+ .set_state = wavetcp_state,
+ .undo_cwnd = wavetcp_undo_cwnd,
+ .cwnd_event = wavetcp_cwnd_event,
+ .pkts_acked = wavetcp_acked,
+ .sndbuf_expand = wavetcp_sndbuf_expand,
+ .get_pacing_time = wavetcp_get_timer,
+ .pacing_timer_expired = wavetcp_timer_expired,
+ .get_segs_per_round = wavetcp_get_segs_per_round,
+ .segments_sent = wavetcp_segment_sent,
+ .owner = THIS_MODULE,
+ .name = "wave",
+};
+
+static int __init wavetcp_register(void)
+{
+ BUILD_BUG_ON(sizeof(struct wavetcp) > ICSK_CA_PRIV_SIZE);
+
+ return tcp_register_congestion_control(&wave_cong_tcp);
+}
+
+static void __exit wavetcp_unregister(void)
+{
+ tcp_unregister_congestion_control(&wave_cong_tcp);
+}
+
+module_init(wavetcp_register);
+module_exit(wavetcp_unregister);
+
+MODULE_AUTHOR("Natale Patriciello");
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("WAVE TCP");
+MODULE_VERSION("0.2");
--
2.14.2
^ permalink raw reply related
* Re: [PATCH v3 1/2] dt-bindings: add device tree binding for Allwinner XR819 SDIO Wi-Fi
From: icenowy-h8G6r0blFSE @ 2017-10-14 12:00 UTC (permalink / raw)
To: Kalle Valo
Cc: devicetree-u79uwXL29TY76Z2rM5mHXA, Arend van Spriel,
netdev-u79uwXL29TY76Z2rM5mHXA,
linux-wireless-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
linux-sunxi-/JYPxA39Uh5TLH3MbocFFw, Rob Herring, Maxime Ripard,
Chen-Yu Tsai, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
In-Reply-To: <878tgq5beu.fsf-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
在 2017-10-05 14:58,Kalle Valo 写道:
> Icenowy Zheng <icenowy-h8G6r0blFSE@public.gmane.org> writes:
>
>> 于 2017年10月4日 GMT+08:00 下午6:11:45, Maxime Ripard
>> <maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org> 写到:
>>> On Wed, Oct 04, 2017 at 10:02:48AM +0000, Arend van Spriel wrote:
>>>> On 10/4/2017 11:03 AM, Icenowy Zheng wrote:
>>>> >
>>>> >
>>>> > 于 2017年10月4日 GMT+08:00 下午5:02:17, Kalle Valo <kvalo-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
>>> 写到:
>>>> > > Icenowy Zheng <icenowy-h8G6r0blFSE@public.gmane.org> writes:
>>>> > >
>>>> > > > Allwinner XR819 is a SDIO Wi-Fi chip, which has the
>>> functionality to
>>>> > > use
>>>> > > > an out-of-band interrupt pin instead of SDIO in-band interrupt.
>>>> > > >
>>>> > > > Add the device tree binding of this chip, in order to make it
>>>> > > possible
>>>> > > > to add this interrupt pin to device trees.
>>>> > > >
>>>> > > > Signed-off-by: Icenowy Zheng <icenowy-h8G6r0blFSE@public.gmane.org>
>>>> > > > Acked-by: Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
>>>> > > > ---
>>>> > > > Changes in v3:
>>>> > > > - Renames the node name.
>>>> > > > - Adds ACK from Rob.
>>>> > > > Changes in v2:
>>>> > > > - Removed status property in example.
>>>> > > > - Added required property reg.
>>>> > > >
>>>> > > > .../bindings/net/wireless/allwinner,xr819.txt | 38
>>>> > > ++++++++++++++++++++++
>>>> > > > 1 file changed, 38 insertions(+)
>>>> > > > create mode 100644
>>>> > >
>>> Documentation/devicetree/bindings/net/wireless/allwinner,xr819.txt
>>>> > >
>>>> > > Like I asked already last time, AFAICS there is no upstream xr819
>>>> > > wireless driver in drivers/net/wireless directory. Do we still
>>> accept
>>>> > > bindings like this for out-of-tree drivers?
>>>> >
>>>> > See esp8089.
>>>> >
>>>> > There's also no in-tree driver for it.
>>>>
>>>> The question is whether we should. The above might be a precedent,
>>> but it
>>>> may not necessarily be the way to go. The commit message for esp8089
>>> seems
>>>> to hint that there is intent to have an in-tree driver:
>>>>
>>>> """
>>>> Note that at this point there only is an out of tree driver for
>>> this
>>>> hardware, there is no clear timeline / path for merging this.
>>> Still
>>>> I believe it would be good to specify the binding for this in
>>> tree
>>>> now, so that any future migration to an in tree driver will not
>>> cause
>>>> compatiblity issues.
>>>>
>>>> Cc: Icenowy Zheng <icenowy-ymACFijhrKM@public.gmane.org>
>>>> Signed-off-by: Hans de Goede <hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
>>>> Signed-off-by: Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
>>>> """
>>>>
>>>> Regardless the bindings are in principle independent of the kernel
>>> and just
>>>> describing hardware. I think there have been discussions to move the
>>>> bindings to their own repository, but apparently it was decided
>>> otherwise.
>>>
>>> Yeah, I guess especially how it could be merged with the cw1200
>>> driver
>>> would be very relevant to that commit log.
>>
>> The cw1200 driver seems to still have some legacy platform
>> data. Maybe they should also be convert to DT.
>> (Or maybe compatible = "allwinner,xr819" is enough, as
>> xr819 is a specified variant of cw1200 family)
>
> Ah, so the upstream cw1200 driver supports xr819? Has anyone tested
> that? Or does cw1200 more changes than just adding the DT support?
The support of XR819 in CW1200 driver is far more difficult than I
imagined -- the codedrop used in the mainlined CW1200 driver seems to
be so old that it's before XR819 (which seems to be based on CW1160),
and there's a large number of problems to adapt it to a modern CW1200
variant.
P.S. could you apply this device tree binding patch now?
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* [PATCH v2] pch_gbe: Switch to new PCI IRQ allocation API
From: Andy Shevchenko @ 2017-10-14 14:04 UTC (permalink / raw)
To: David S . Miller, netdev; +Cc: Andy Shevchenko
This removes custom flag handling.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe.h | 3 +-
.../net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c | 42 +++++++++-------------
2 files changed, 17 insertions(+), 28 deletions(-)
diff --git a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe.h b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe.h
index 8d710a3b4db0..697e29dd4bd3 100644
--- a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe.h
+++ b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe.h
@@ -613,7 +613,6 @@ struct pch_gbe_privdata {
* @rx_ring: Pointer of Rx descriptor ring structure
* @rx_buffer_len: Receive buffer length
* @tx_queue_len: Transmit queue length
- * @have_msi: PCI MSI mode flag
* @pch_gbe_privdata: PCI Device ID driver_data
*/
@@ -623,6 +622,7 @@ struct pch_gbe_adapter {
atomic_t irq_sem;
struct net_device *netdev;
struct pci_dev *pdev;
+ int irq;
struct net_device *polling_netdev;
struct napi_struct napi;
struct pch_gbe_hw hw;
@@ -637,7 +637,6 @@ struct pch_gbe_adapter {
struct pch_gbe_rx_ring *rx_ring;
unsigned long rx_buffer_len;
unsigned long tx_queue_len;
- bool have_msi;
bool rx_stop_flag;
int hwts_tx_en;
int hwts_rx_en;
diff --git a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
index 5ae9681a2da7..457ee80307ea 100644
--- a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
+++ b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
@@ -781,11 +781,8 @@ static void pch_gbe_free_irq(struct pch_gbe_adapter *adapter)
{
struct net_device *netdev = adapter->netdev;
- free_irq(adapter->pdev->irq, netdev);
- if (adapter->have_msi) {
- pci_disable_msi(adapter->pdev);
- netdev_dbg(netdev, "call pci_disable_msi\n");
- }
+ free_irq(adapter->irq, netdev);
+ pci_free_irq_vectors(adapter->pdev);
}
/**
@@ -799,7 +796,7 @@ static void pch_gbe_irq_disable(struct pch_gbe_adapter *adapter)
atomic_inc(&adapter->irq_sem);
iowrite32(0, &hw->reg->INT_EN);
ioread32(&hw->reg->INT_ST);
- synchronize_irq(adapter->pdev->irq);
+ synchronize_irq(adapter->irq);
netdev_dbg(adapter->netdev, "INT_EN reg : 0x%08x\n",
ioread32(&hw->reg->INT_EN));
@@ -1903,30 +1900,23 @@ static int pch_gbe_request_irq(struct pch_gbe_adapter *adapter)
{
struct net_device *netdev = adapter->netdev;
int err;
- int flags;
- flags = IRQF_SHARED;
- adapter->have_msi = false;
- err = pci_enable_msi(adapter->pdev);
- netdev_dbg(netdev, "call pci_enable_msi\n");
- if (err) {
- netdev_dbg(netdev, "call pci_enable_msi - Error: %d\n", err);
- } else {
- flags = 0;
- adapter->have_msi = true;
- }
- err = request_irq(adapter->pdev->irq, &pch_gbe_intr,
- flags, netdev->name, netdev);
+ err = pci_alloc_irq_vectors(adapter->pdev, 1, 1, PCI_IRQ_ALL_TYPES);
+ if (err < 0)
+ return err;
+
+ adapter->irq = pci_irq_vector(adapter->pdev, 0);
+
+ err = request_irq(adapter->irq, &pch_gbe_intr, IRQF_SHARED,
+ netdev->name, netdev);
if (err)
netdev_err(netdev, "Unable to allocate interrupt Error: %d\n",
err);
- netdev_dbg(netdev,
- "adapter->have_msi : %d flags : 0x%04x return : 0x%04x\n",
- adapter->have_msi, flags, err);
+ netdev_dbg(netdev, "have_msi : %d return : 0x%04x\n",
+ pci_dev_msi_enabled(adapter->pdev), err);
return err;
}
-
/**
* pch_gbe_up - Up GbE network device
* @adapter: Board private structure
@@ -2399,9 +2389,9 @@ static void pch_gbe_netpoll(struct net_device *netdev)
{
struct pch_gbe_adapter *adapter = netdev_priv(netdev);
- disable_irq(adapter->pdev->irq);
- pch_gbe_intr(adapter->pdev->irq, netdev);
- enable_irq(adapter->pdev->irq);
+ disable_irq(adapter->irq);
+ pch_gbe_intr(adapter->irq, netdev);
+ enable_irq(adapter->irq);
}
#endif
--
2.14.2
^ permalink raw reply related
* Re: Kernel Performance Tuning for High Volume SCTP traffic
From: Traiano Welcome @ 2017-10-14 14:29 UTC (permalink / raw)
To: David Laight; +Cc: linux-sctp@vger.kernel.org, netdev@vger.kernel.org
In-Reply-To: <063D6719AE5E284EB5DD2968C1650D6DD00950DD@AcuExch.aculab.com>
I've upped the value of the following sctp and udp related parameters,
in the hope that this would help:
sysctl -w net.core.rmem_max=900000000
sysctl -w net.core.wmem_max=900000000
sysctl -w net.sctp.sctp_mem="2100000000 2100000000 2100000000"
sysctl -w net.sctp.sctp_rmem="2100000000 2100000000 2100000000"
sysctl -w net.sctp.sctp_wmem="2100000000 2100000000 2100000000"
sysctl -w net.ipv4.udp_mem="5000000000 5000000000 5000000000"
sysctl -w net.ipv4.udp_mem="10000000000 10000000000 10000000000"
However, I'm still seeing rapidly incrementing rx discards reported on the NIC:
:~# ethtool -S ens4f1 | egrep -i rx_discards
[0]: rx_discards: 6390805462
[1]: rx_discards: 6659315919
[2]: rx_discards: 6542570026
[3]: rx_discards: 6431513008
[4]: rx_discards: 6436779078
[5]: rx_discards: 6665897051
[6]: rx_discards: 6167985560
[7]: rx_discards: 11340068788
rx_discards: 56634934892
Despite the fact that I've set the NIC ring buffer on the Netextreme
interface to he maximum:
:~# ethtool -g ens4f0
Ring parameters for ens4f0:
Pre-set maximums:
RX: 4078
RX Mini: 0
RX Jumbo: 0
TX: 4078
Current hardware settings:
RX: 4078
RX Mini: 0
RX Jumbo: 0
TX: 4078
I see no ip errors at the physical interface:
ethtool -S ens4f0 | egrep phy_ip_err_discard| tail -1
rx_phy_ip_err_discards: 0
Could anyone suggest alternative approaches I might take to optimising
the system's handling of SCTP traffic?
On Sat, Oct 14, 2017 at 12:35 AM, David Laight <David.Laight@aculab.com> wrote:
> From: Traiano Welcome
>> Sent: 13 October 2017 17:04
>> On Fri, Oct 13, 2017 at 11:56 PM, David Laight <David.Laight@aculab.com> wrote:
>> > From: Traiano Welcome
>> >
>> > (copied to netdev)
>> >> Sent: 13 October 2017 07:16
>> >> To: linux-sctp@vger.kernel.org
>> >> Subject: Kernel Performance Tuning for High Volume SCTP traffic
>> >>
>> >> Hi List
>> >>
>> >> I'm running a linux server processing high volumes of SCTP traffic and
>> >> am seeing large numbers of packet overruns (ifconfig output).
>> >
>> > I'd guess that overruns indicate that the ethernet MAC is failing to
>> > copy the receive frames into kernel memory.
>> > It is probably running out of receive buffers, but might be
>> > suffering from a lack of bus bandwidth.
>> > MAC drivers usually discard receive frames if they can't get
>> > a replacement buffer - so you shouldn't run out of rx buffers.
>> >
>> > This means the errors are probably below SCTP - so changing SCTP parameters
>> > is unlikely to help.
>>
>> Does this mean that tuning UDP performance could help ? Or do you mean
>> hardware (NIC) performance could be the issue?
>
> I'd certainly check UDP performance.
>
> David
>
^ permalink raw reply
* Re: usb/net/rt2x00: warning in rt2800_eeprom_word_index
From: Dmitry Vyukov @ 2017-10-14 14:38 UTC (permalink / raw)
To: Stanislaw Gruszka
Cc: Andrey Konovalov, Helmut Schaa, Kalle Valo, linux-wireless,
netdev, LKML, Kostya Serebryany, syzkaller
In-Reply-To: <20171012072529.GB2686@redhat.com>
On Thu, Oct 12, 2017 at 9:25 AM, Stanislaw Gruszka <sgruszka@redhat.com> wrote:
> Hi
>
> On Mon, Oct 09, 2017 at 07:50:53PM +0200, Andrey Konovalov wrote:
>> I've got the following report while fuzzing the kernel with syzkaller.
>>
>> On commit 8a5776a5f49812d29fe4b2d0a2d71675c3facf3f (4.14-rc4).
>>
>> I'm not sure whether this is a bug in the driver, or just a way to
>> report misbehaving device. In the latter case this shouldn't be a
>> WARN() call, since WARN() means bug in the kernel.
>
> This is about wrong EEPROM, which reported 3 tx streams on
> non 3 antenna device. I think WARN() is justified and thanks
> to the call trace I was actually able to to understand what
> happened.
>
> In general I do not think WARN() only means a kernel bug, it
> can be F/W or H/W bug too.
Hi Stanislaw,
Printing messages is fine. Printing stacks is fine. Just please make
them distinguishable from kernel bugs and don't kill the whole
possibility of automated Linux kernel testing. That's an important
capability.
Thanks
^ permalink raw reply
* Re: [PATCH v2] net: ftgmac100: Request clock and set speed
From: kbuild test robot @ 2017-10-14 14:53 UTC (permalink / raw)
To: Joel Stanley
Cc: kbuild-all, David S . Miller, Benjamin Herrenschmidt, netdev,
linux-kernel, Andrew Jeffery
In-Reply-To: <20171012033201.12845-1-joel@jms.id.au>
[-- Attachment #1: Type: text/plain, Size: 7465 bytes --]
Hi Joel,
[auto build test ERROR on net-next/master]
[also build test ERROR on v4.14-rc4 next-20171013]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Joel-Stanley/net-ftgmac100-Request-clock-and-set-speed/20171014-195836
config: arm-allmodconfig (attached as .config)
compiler: arm-linux-gnueabi-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=arm
All error/warnings (new ones prefixed by >>):
>> drivers/net//ethernet/faraday/ftgmac100.c:1742:40: warning: 'struct ftgmac100_priv' declared inside parameter list will not be visible outside of this definition or declaration
static void ftgmac100_setup_clk(struct ftgmac100_priv *priv)
^~~~~~~~~~~~~~
drivers/net//ethernet/faraday/ftgmac100.c: In function 'ftgmac100_setup_clk':
>> drivers/net//ethernet/faraday/ftgmac100.c:1744:6: error: dereferencing pointer to incomplete type 'struct ftgmac100_priv'
priv->clk = devm_clk_get(&pdev->dev, NULL);
^~
>> drivers/net//ethernet/faraday/ftgmac100.c:1744:28: error: 'pdev' undeclared (first use in this function)
priv->clk = devm_clk_get(&pdev->dev, NULL);
^~~~
drivers/net//ethernet/faraday/ftgmac100.c:1744:28: note: each undeclared identifier is reported only once for each function it appears in
drivers/net//ethernet/faraday/ftgmac100.c: In function 'ftgmac100_probe':
>> drivers/net//ethernet/faraday/ftgmac100.c:1855:23: error: passing argument 1 of 'ftgmac100_setup_clk' from incompatible pointer type [-Werror=incompatible-pointer-types]
ftgmac100_setup_clk(priv);
^~~~
drivers/net//ethernet/faraday/ftgmac100.c:1742:13: note: expected 'struct ftgmac100_priv *' but argument is of type 'struct ftgmac100 *'
static void ftgmac100_setup_clk(struct ftgmac100_priv *priv)
^~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
vim +1744 drivers/net//ethernet/faraday/ftgmac100.c
1741
> 1742 static void ftgmac100_setup_clk(struct ftgmac100_priv *priv)
1743 {
> 1744 priv->clk = devm_clk_get(&pdev->dev, NULL);
1745 if (IS_ERR(priv->clk))
1746 return;
1747
1748 clk_prepare_enable(priv->clk);
1749
1750 /* Aspeed specifies a 100MHz clock is required for up to
1751 * 1000Mbit link speeds. As NCSI is limited to 100Mbit, 25MHz
1752 * is sufficient
1753 */
1754 clk_set_rate(priv->clk, priv->is_ncsi ? FTGMAC_25MHZ :
1755 FTGMAC_100MHZ);
1756 }
1757
1758 static int ftgmac100_probe(struct platform_device *pdev)
1759 {
1760 struct resource *res;
1761 int irq;
1762 struct net_device *netdev;
1763 struct ftgmac100 *priv;
1764 struct device_node *np;
1765 int err = 0;
1766
1767 if (!pdev)
1768 return -ENODEV;
1769
1770 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1771 if (!res)
1772 return -ENXIO;
1773
1774 irq = platform_get_irq(pdev, 0);
1775 if (irq < 0)
1776 return irq;
1777
1778 /* setup net_device */
1779 netdev = alloc_etherdev(sizeof(*priv));
1780 if (!netdev) {
1781 err = -ENOMEM;
1782 goto err_alloc_etherdev;
1783 }
1784
1785 SET_NETDEV_DEV(netdev, &pdev->dev);
1786
1787 netdev->ethtool_ops = &ftgmac100_ethtool_ops;
1788 netdev->netdev_ops = &ftgmac100_netdev_ops;
1789 netdev->watchdog_timeo = 5 * HZ;
1790
1791 platform_set_drvdata(pdev, netdev);
1792
1793 /* setup private data */
1794 priv = netdev_priv(netdev);
1795 priv->netdev = netdev;
1796 priv->dev = &pdev->dev;
1797 INIT_WORK(&priv->reset_task, ftgmac100_reset_task);
1798
1799 /* map io memory */
1800 priv->res = request_mem_region(res->start, resource_size(res),
1801 dev_name(&pdev->dev));
1802 if (!priv->res) {
1803 dev_err(&pdev->dev, "Could not reserve memory region\n");
1804 err = -ENOMEM;
1805 goto err_req_mem;
1806 }
1807
1808 priv->base = ioremap(res->start, resource_size(res));
1809 if (!priv->base) {
1810 dev_err(&pdev->dev, "Failed to ioremap ethernet registers\n");
1811 err = -EIO;
1812 goto err_ioremap;
1813 }
1814
1815 netdev->irq = irq;
1816
1817 /* Enable pause */
1818 priv->tx_pause = true;
1819 priv->rx_pause = true;
1820 priv->aneg_pause = true;
1821
1822 /* MAC address from chip or random one */
1823 ftgmac100_initial_mac(priv);
1824
1825 np = pdev->dev.of_node;
1826 if (np && (of_device_is_compatible(np, "aspeed,ast2400-mac") ||
1827 of_device_is_compatible(np, "aspeed,ast2500-mac"))) {
1828 priv->rxdes0_edorr_mask = BIT(30);
1829 priv->txdes0_edotr_mask = BIT(30);
1830 priv->is_aspeed = true;
1831 } else {
1832 priv->rxdes0_edorr_mask = BIT(15);
1833 priv->txdes0_edotr_mask = BIT(15);
1834 }
1835
1836 if (np && of_get_property(np, "use-ncsi", NULL)) {
1837 if (!IS_ENABLED(CONFIG_NET_NCSI)) {
1838 dev_err(&pdev->dev, "NCSI stack not enabled\n");
1839 goto err_ncsi_dev;
1840 }
1841
1842 dev_info(&pdev->dev, "Using NCSI interface\n");
1843 priv->use_ncsi = true;
1844 priv->ndev = ncsi_register_dev(netdev, ftgmac100_ncsi_handler);
1845 if (!priv->ndev)
1846 goto err_ncsi_dev;
1847 } else {
1848 priv->use_ncsi = false;
1849 err = ftgmac100_setup_mdio(netdev);
1850 if (err)
1851 goto err_setup_mdio;
1852 }
1853
1854 if (priv->is_aspeed)
> 1855 ftgmac100_setup_clk(priv);
1856
1857 /* Default ring sizes */
1858 priv->rx_q_entries = priv->new_rx_q_entries = DEF_RX_QUEUE_ENTRIES;
1859 priv->tx_q_entries = priv->new_tx_q_entries = DEF_TX_QUEUE_ENTRIES;
1860
1861 /* Base feature set */
1862 netdev->hw_features = NETIF_F_RXCSUM | NETIF_F_HW_CSUM |
1863 NETIF_F_GRO | NETIF_F_SG | NETIF_F_HW_VLAN_CTAG_RX |
1864 NETIF_F_HW_VLAN_CTAG_TX;
1865
1866 if (priv->use_ncsi)
1867 netdev->hw_features |= NETIF_F_HW_VLAN_CTAG_FILTER;
1868
1869 /* AST2400 doesn't have working HW checksum generation */
1870 if (np && (of_device_is_compatible(np, "aspeed,ast2400-mac")))
1871 netdev->hw_features &= ~NETIF_F_HW_CSUM;
1872 if (np && of_get_property(np, "no-hw-checksum", NULL))
1873 netdev->hw_features &= ~(NETIF_F_HW_CSUM | NETIF_F_RXCSUM);
1874 netdev->features |= netdev->hw_features;
1875
1876 /* register network device */
1877 err = register_netdev(netdev);
1878 if (err) {
1879 dev_err(&pdev->dev, "Failed to register netdev\n");
1880 goto err_register_netdev;
1881 }
1882
1883 netdev_info(netdev, "irq %d, mapped at %p\n", netdev->irq, priv->base);
1884
1885 return 0;
1886
1887 err_ncsi_dev:
1888 err_register_netdev:
1889 ftgmac100_destroy_mdio(netdev);
1890 err_setup_mdio:
1891 iounmap(priv->base);
1892 err_ioremap:
1893 release_resource(priv->res);
1894 err_req_mem:
1895 free_netdev(netdev);
1896 err_alloc_etherdev:
1897 return err;
1898 }
1899
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 64016 bytes --]
^ permalink raw reply
* Re: [PATCH 3/3] ARM: dts: gr-peach: Add ETHER pin group
From: Andrew Lunn @ 2017-10-14 15:13 UTC (permalink / raw)
To: jacopo mondi; +Cc: Geert Uytterhoeven, Chris Brandt, f.fainelli, netdev
In-Reply-To: <20171006122445.GA30375@w540>
> > So your binding whats to look something like
> >
> > ether: ethernet@e8203000 {
> > compatible = "renesas,ether-r7s72100";
> > reg = <0xe8203000 0x800>,
> > <0xe8204800 0x200>;
> > interrupts = <GIC_SPI 327 IRQ_TYPE_LEVEL_HIGH>;
> > clocks = <&mstp7_clks R7S72100_CLK_ETHER>;
> > power-domains = <&cpg_clocks>;
> > phy-mode = "mii";
> > phy-handle = <&phy0>;
> > #address-cells = <1>;
> > #size-cells = <0>;
> >
> > mdio: bus-bus {
> > #address-cells = <1>;
> > #size-cells = <0>;
> >
> > phy0: ethernet-phy@1 {
> > reg = <1>;
>
> Why reg = <1> ?
> Shouldn't this be 0, or even better with no reg property at all?
This is the address of the PHY on the MDIO bus. There can be up to 32
devices on the bus. I have no idea what address your PHY is using, so
i just picked a value. 0 can be special, so i avoided it.
Andrew
^ permalink raw reply
* Re: [net-next 1/3] tcp: avoid useless copying and collapsing of just one skb
From: Eric Dumazet @ 2017-10-14 15:42 UTC (permalink / raw)
To: Koichiro Den; +Cc: netdev, davem, kuznet, yoshfuji
In-Reply-To: <20171014072745.23462-2-den@klaipeden.com>
On Sat, 2017-10-14 at 16:27 +0900, Koichiro Den wrote:
> On the starting point chosen, it could be possible that just one skb
> remains in between the range provided, leading to copying and re-insertion
> of rb node, which is useless with respect to the rcv buf measurement.
> This is rather probable in ooo queue case, in which non-contiguous bloated
> packets have been queued up.
>
> Signed-off-by: Koichiro Den <den@klaipeden.com>
> ---
> net/ipv4/tcp_input.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
> index d0682ce2a5d6..1d785b5bf62d 100644
> --- a/net/ipv4/tcp_input.c
> +++ b/net/ipv4/tcp_input.c
> @@ -4807,7 +4807,8 @@ tcp_collapse(struct sock *sk, struct sk_buff_head *list, struct rb_root *root,
> start = TCP_SKB_CB(skb)->end_seq;
> }
> if (end_of_skbs ||
> - (TCP_SKB_CB(skb)->tcp_flags & (TCPHDR_SYN | TCPHDR_FIN)))
> + (TCP_SKB_CB(skb)->tcp_flags & (TCPHDR_SYN | TCPHDR_FIN)) ||
> + (TCP_SKB_CB(skb)->seq == start && TCP_SKB_CB(skb)->end_seq == end))
> return;
>
> __skb_queue_head_init(&tmp);
What do you mean by useless ?
Surely if this skb contains 17 segments (some USB drivers allocate 8KB
per frame), we want to collapse them to save memory.
So I do not agree with this patch.
^ permalink raw reply
* Re: [net-next 2/3] tcp: do not tcp_collapse once SYN or FIN found
From: Eric Dumazet @ 2017-10-14 15:43 UTC (permalink / raw)
To: Koichiro Den; +Cc: netdev, davem, kuznet, yoshfuji
In-Reply-To: <20171014072745.23462-3-den@klaipeden.com>
On Sat, 2017-10-14 at 16:27 +0900, Koichiro Den wrote:
> Since 9f5afeae5152 ("tcp: use an RB tree for ooo receive queue")
> applied, we no longer need to continue to search for the starting
> point once we encounter FIN packet. Same reasoning for SYN packet
> since commit 9d691539eea2d ("tcp: do not enqueue skb with SYN flag"),
> that would help us with error message when actual receiving.
Very confusing changelog or patch.
What exact problem do you want to solve ?
^ permalink raw reply
* Re: [net-next 3/3] tcp: keep tcp_collapse controllable even after processing starts
From: Eric Dumazet @ 2017-10-14 15:46 UTC (permalink / raw)
To: Koichiro Den; +Cc: netdev, davem, kuznet, yoshfuji
In-Reply-To: <20171014072745.23462-4-den@klaipeden.com>
On Sat, 2017-10-14 at 16:27 +0900, Koichiro Den wrote:
> Combining actual collapsing with reasoning for deciding the starting
> point, we can apply its logic in a consistent manner such that we can
> avoid costly yet not much useful collapsing. When collapsing to be
> triggered, it's not rare that most of the skbs in the receive or ooo
> queue are large ones without much metadata overhead. This also
> simplifies code and makes it easier to apply logic in a fair manner.
>
> Subtle subsidiary changes included:
> - When the end_seq of the skb we are trying to collapse was larger than
> the 'end' argument provided, we would end up copying to the 'end'
> even though we couldn't collapse the original one. Current users of
> tcp_collapse does not require such reserves so redefines it as the
> point over which skbs whose seq passes guranteed not to be collapsed.
> - Naturally tcp_collapse_ofo_queue shapes up and we no longer need
> 'tail' argument.
I am not inclined to review such a large change, without you providing
actual numbers.
We have a problem in TCP right now, that receiver announces a too big
window, and that is the main reason we trigger collapsing.
I would rather fix the root cause.
^ permalink raw reply
* [PATCH] net/ncsi: Delete an error message for a failed memory allocation in ncsi_rsp_handler_gc()
From: SF Markus Elfring @ 2017-10-14 16:19 UTC (permalink / raw)
To: netdev, David S. Miller, Gavin Shan, Samuel Mendoza-Jonas
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 14 Oct 2017 18:03:11 +0200
Omit an extra message for a memory allocation failure in this function.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
net/ncsi/ncsi-rsp.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/net/ncsi/ncsi-rsp.c b/net/ncsi/ncsi-rsp.c
index 265b9a892d41..eb3611ffbb62 100644
--- a/net/ncsi/ncsi-rsp.c
+++ b/net/ncsi/ncsi-rsp.c
@@ -686,11 +686,8 @@ static int ncsi_rsp_handler_gc(struct ncsi_request *nr)
size = sizeof(*ncf) + cnt * entry_size;
ncf = kzalloc(size, GFP_ATOMIC);
- if (!ncf) {
- pr_warn("%s: Cannot alloc filter table (%d)\n",
- __func__, i);
+ if (!ncf)
return -ENOMEM;
- }
ncf->index = i;
ncf->total = cnt;
--
2.14.2
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox