* [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
* [PATCH] fix typo in skbuff.c
From: Wenhua Shi @ 2017-10-14 16:51 UTC (permalink / raw)
To: davem; +Cc: netdev, linux-kernel
---
net/core/skbuff.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 16982de6..e62476be 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -1896,7 +1896,7 @@ void *__pskb_pull_tail(struct sk_buff *skb, int delta)
}
/* If we need update frag list, we are in troubles.
- * Certainly, it possible to add an offset to skb data,
+ * Certainly, it is possible to add an offset to skb data,
* but taking into account that pulling is expected to
* be very rare operation, it is worth to fight against
* further bloating skb head and crucify ourselves here instead.
--
2.11.0
^ permalink raw reply related
* Re: [net-next V7 PATCH 4/5] bpf: cpumap add tracepoints
From: David Miller @ 2017-10-14 16:54 UTC (permalink / raw)
To: brouer
Cc: netdev, jakub.kicinski, mst, pavel.odintsov, jasowang, mchan,
john.fastabend, peter.waskiewicz.jr, ast, borkmann,
alexei.starovoitov, andy
In-Reply-To: <150781122498.9409.14999232908601389565.stgit@firesoul>
From: Jesper Dangaard Brouer <brouer@redhat.com>
Date: Thu, 12 Oct 2017 14:27:05 +0200
> @@ -355,7 +360,10 @@ struct bpf_cpu_map_entry *__cpu_map_entry_alloc(u32 qsize, u32 cpu, int map_id)
> err = ptr_ring_init(rcpu->queue, qsize, gfp);
> if (err)
> goto free_queue;
> - rcpu->qsize = qsize
> +
> + rcpu->cpu = cpu;
> + rcpu->map_id = map_id;
> + rcpu->qsize = qsize;
>
> /* Setup kthread */
> rcpu->kthread = kthread_create_on_node(cpu_map_kthread_run, rcpu, numa,
So this fixes a build failure (missing final semicolon) introduced by
an earlier patch in the series, please fix this up so that this series
is properly bisectable.
^ permalink raw reply
* [PATCH] netrom: Delete an error message for a failed memory allocation in nr_proto_init()
From: SF Markus Elfring @ 2017-10-14 17:33 UTC (permalink / raw)
To: linux-hams, netdev, David S. Miller, Ralf Bächle
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 14 Oct 2017 18:48:18 +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/netrom/af_netrom.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
index ebf16f7f9089..568d6a148bf2 100644
--- a/net/netrom/af_netrom.c
+++ b/net/netrom/af_netrom.c
@@ -1408,10 +1408,8 @@ static int __init nr_proto_init(void)
}
dev_nr = kzalloc(nr_ndevs * sizeof(struct net_device *), GFP_KERNEL);
- if (dev_nr == NULL) {
- printk(KERN_ERR "NET/ROM: nr_proto_init - unable to allocate device array\n");
+ if (!dev_nr)
return -1;
- }
for (i = 0; i < nr_ndevs; i++) {
char name[IFNAMSIZ];
--
2.14.2
^ permalink raw reply related
* Re: [PATCH net-next] icmp: don't fail on fragment reassembly time exceeded
From: David Miller @ 2017-10-14 18:05 UTC (permalink / raw)
To: mcroce; +Cc: netdev
In-Reply-To: <20171012141237.2209-1-mcroce@redhat.com>
From: Matteo Croce <mcroce@redhat.com>
Date: Thu, 12 Oct 2017 16:12:37 +0200
> The ICMP implementation currently replies to an ICMP time exceeded message
> (type 11) with an ICMP host unreachable message (type 3, code 1).
>
> However, time exceeded messages can either represent "time to live exceeded
> in transit" (code 0) or "fragment reassembly time exceeded" (code 1).
>
> Unconditionally replying to "fragment reassembly time exceeded" with
> host unreachable messages might cause unjustified connection resets
> which are now easily triggered as UFO has been removed, because, in turn,
> sending large buffers triggers IP fragmentation.
>
> The issue can be easily reproduced by running a lot of UDP streams
> which is likely to trigger IP fragmentation:
>
> # start netserver in the test namespace
> ip netns add test
> ip netns exec test netserver
>
> # create a VETH pair
> ip link add name veth0 type veth peer name veth0 netns test
> ip link set veth0 up
> ip -n test link set veth0 up
>
> for i in $(seq 20 29); do
> # assign addresses to both ends
> ip addr add dev veth0 192.168.$i.1/24
> ip -n test addr add dev veth0 192.168.$i.2/24
>
> # start the traffic
> netperf -L 192.168.$i.1 -H 192.168.$i.2 -t UDP_STREAM -l 0 &
> done
>
> # wait
> send_data: data send error: No route to host (errno 113)
> netperf: send_omni: send_data failed: No route to host
>
> We need to differentiate instead: if fragment reassembly time exceeded
> is reported, we need to silently drop the packet,
> if time to live exceeded is reported, maintain the current behaviour.
> In both cases increment the related error count "icmpInTimeExcds".
>
> While at it, fix a typo in a comment, and convert the if statement
> into a switch to mate it more readable.
>
> Signed-off-by: Matteo Croce <mcroce@redhat.com>
Looks good, applied, thank you!
^ permalink raw reply
* Re: [PATCH net-next v2 0/2] net: stmmac: Improvements for multi-queuing and for AVB
From: David Miller @ 2017-10-14 18:12 UTC (permalink / raw)
To: Jose.Abreu; +Cc: netdev, Joao.Pinto, peppe.cavallaro, alexandre.torgue
In-Reply-To: <cover.1507888312.git.joabreu@synopsys.com>
From: Jose Abreu <Jose.Abreu@synopsys.com>
Date: Fri, 13 Oct 2017 10:58:35 +0100
> Two improvements for stmmac: First one corrects the available fifo
> size per queue, second one corrects enabling of AVB queues. More
> info in commit log.
Series applied, thanks.
^ permalink raw reply
* Re: [PATCH net-next 00/12] nfp: bpf: support direct packet access
From: David Miller @ 2017-10-14 18:13 UTC (permalink / raw)
To: jakub.kicinski; +Cc: netdev, oss-drivers
In-Reply-To: <20171012173418.4029-1-jakub.kicinski@netronome.com>
From: Jakub Kicinski <jakub.kicinski@netronome.com>
Date: Thu, 12 Oct 2017 10:34:06 -0700
> The core of this series is direct packet access support. With a
> small change to the verifier, the offloaded code can now make
> use of DPA. We need to be careful to use kernel (after initial
> translation) offsets in our JIT. Direct packet access also brings
> us to the problem of eBPF endianness. After considering the
> changes necessary we decided to not support translation on both
> BE and LE hosts, for now.
>
> This series contains two fixes - one for compare instructions and
> one for ineffective jne optimization. I chose to include fixes
> in this set because the code in -net works only with unreleased
> PoC FW (ABI version 1) and therefore nobody outside of Netronome
> can exercise it anyway.
Series applied, thank you.
^ permalink raw reply
* Re: [PATCH net-next v5 0/5] bpf: security: New file mode and LSM hooks for eBPF object permission control
From: David Miller @ 2017-10-14 18:27 UTC (permalink / raw)
To: chenbofeng.kernel
Cc: netdev, jeffv, alexei.starovoitov, lorenzo, daniel, sds,
james.l.morris, paul, fengc
In-Reply-To: <20171012205510.36028-1-chenbofeng.kernel@gmail.com>
Hmmm, this doesn't build for me:
security/selinux/hooks.c: In function ‘bpf_fd_pass’:
security/selinux/hooks.c:6325:40: error: ‘SECCLASS_BPF_MAP’ undeclared (first use in this function); did you mean ‘SECCLASS_BPF’?
ret = avc_has_perm(sid, bpfsec->sid, SECCLASS_BPF_MAP,
^~~~~~~~~~~~~~~~
SECCLASS_BPF
security/selinux/hooks.c:6325:40: note: each undeclared identifier is reported only once for each function it appears in
security/selinux/hooks.c:6332:40: error: ‘SECCLASS_BPF_PROG’ undeclared (first use in this function); did you mean ‘SECCLASS_BPF_MAP’?
ret = avc_has_perm(sid, bpfsec->sid, SECCLASS_BPF_PROG,
^~~~~~~~~~~~~~~~~
SECCLASS_BPF_MAP
^ permalink raw reply
* [for-next 01/12] net/mlx5: File renaming towards ptp core implementation
From: Saeed Mahameed @ 2017-10-14 18:48 UTC (permalink / raw)
To: David S. Miller, Doug Ledford
Cc: netdev-u79uwXL29TY76Z2rM5mHXA, linux-rdma-u79uwXL29TY76Z2rM5mHXA,
Leon Romanovsky, Feras Daoud, Eitan Rabin, Saeed Mahameed
In-Reply-To: <20171014184827.18491-1-saeedm-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
From: Feras Daoud <ferasda-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
en_clock.c renamed clock.c and moved to lib/ as first step
towards relocating code to core part of the driver to allow
sharing between Ethernet and Infiniband.
Signed-off-by: Feras Daoud <ferasda-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
Signed-off-by: Eitan Rabin <rabin-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
Signed-off-by: Saeed Mahameed <saeedm-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
---
drivers/net/ethernet/mellanox/mlx5/core/Kconfig | 2 +-
drivers/net/ethernet/mellanox/mlx5/core/Makefile | 4 ++--
drivers/net/ethernet/mellanox/mlx5/core/{en_clock.c => lib/clock.c} | 0
3 files changed, 3 insertions(+), 3 deletions(-)
rename drivers/net/ethernet/mellanox/mlx5/core/{en_clock.c => lib/clock.c} (100%)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/Kconfig b/drivers/net/ethernet/mellanox/mlx5/core/Kconfig
index fdaef00465d7..25deaa5a534c 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/Kconfig
+++ b/drivers/net/ethernet/mellanox/mlx5/core/Kconfig
@@ -6,6 +6,7 @@ config MLX5_CORE
tristate "Mellanox Technologies ConnectX-4 and Connect-IB core driver"
depends on MAY_USE_DEVLINK
depends on PCI
+ imply PTP_1588_CLOCK
default n
---help---
Core driver for low level functionality of the ConnectX-4 and
@@ -29,7 +30,6 @@ config MLX5_CORE_EN
bool "Mellanox Technologies ConnectX-4 Ethernet support"
depends on NETDEVICES && ETHERNET && INET && PCI && MLX5_CORE
depends on IPV6=y || IPV6=n || MLX5_CORE=m
- imply PTP_1588_CLOCK
default n
---help---
Ethernet support in Mellanox Technologies ConnectX-4 NIC.
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/Makefile b/drivers/net/ethernet/mellanox/mlx5/core/Makefile
index 87a3099808f3..d9621b2152d3 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/Makefile
+++ b/drivers/net/ethernet/mellanox/mlx5/core/Makefile
@@ -4,7 +4,7 @@ subdir-ccflags-y += -I$(src)
mlx5_core-y := main.o cmd.o debugfs.o fw.o eq.o uar.o pagealloc.o \
health.o mcg.o cq.o srq.o alloc.o qp.o port.o mr.o pd.o \
mad.o transobj.o vport.o sriov.o fs_cmd.o fs_core.o \
- fs_counters.o rl.o lag.o dev.o wq.o lib/gid.o \
+ fs_counters.o rl.o lag.o dev.o wq.o lib/gid.o lib/clock.o \
diag/fs_tracepoint.o
mlx5_core-$(CONFIG_MLX5_ACCEL) += accel/ipsec.o
@@ -13,7 +13,7 @@ mlx5_core-$(CONFIG_MLX5_FPGA) += fpga/cmd.o fpga/core.o fpga/conn.o fpga/sdk.o \
fpga/ipsec.o
mlx5_core-$(CONFIG_MLX5_CORE_EN) += en_main.o en_common.o en_fs.o en_ethtool.o \
- en_tx.o en_rx.o en_rx_am.o en_txrx.o en_clock.o vxlan.o \
+ en_tx.o en_rx.o en_rx_am.o en_txrx.o vxlan.o \
en_arfs.o en_fs_ethtool.o en_selftest.o
mlx5_core-$(CONFIG_MLX5_MPFS) += lib/mpfs.o
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_clock.c b/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
similarity index 100%
rename from drivers/net/ethernet/mellanox/mlx5/core/en_clock.c
rename to drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
--
2.14.2
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" 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 related
* [for-next 03/12] net/mlx5e: IPoIB, Move underlay QP init/uninit to separate functions
From: Saeed Mahameed @ 2017-10-14 18:48 UTC (permalink / raw)
To: David S. Miller, Doug Ledford
Cc: netdev-u79uwXL29TY76Z2rM5mHXA, linux-rdma-u79uwXL29TY76Z2rM5mHXA,
Leon Romanovsky, Alex Vesker, Leon Romanovsky, Saeed Mahameed
In-Reply-To: <20171014184827.18491-1-saeedm-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
From: Alex Vesker <valex-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
During the creation of the underlay QP the PKEY index is unknown, the
PKEY index is known only when calling ndo_open.
PKEY index attached to the QP during state modification.
Splitting the functions will also make the code symmetric and more
readable. This split is also required for later PKEY support to be
called with the PKEY index during ndo_open.
Signed-off-by: Alex Vesker <valex-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
Reviewed-by: Erez Shitrit <erezsh-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
Signed-off-by: Leon Romanovsky <leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Signed-off-by: Saeed Mahameed <saeedm-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
---
.../net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c | 108 +++++++++++++--------
1 file changed, 70 insertions(+), 38 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c b/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c
index 14dfb577691b..feb94db6b921 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c
@@ -108,11 +108,68 @@ static void mlx5i_cleanup(struct mlx5e_priv *priv)
/* Do nothing .. */
}
+static int mlx5i_init_underlay_qp(struct mlx5e_priv *priv)
+{
+ struct mlx5_core_dev *mdev = priv->mdev;
+ struct mlx5i_priv *ipriv = priv->ppriv;
+ struct mlx5_core_qp *qp = &ipriv->qp;
+ struct mlx5_qp_context *context;
+ int ret;
+
+ /* QP states */
+ context = kzalloc(sizeof(*context), GFP_KERNEL);
+ if (!context)
+ return -ENOMEM;
+
+ context->flags = cpu_to_be32(MLX5_QP_PM_MIGRATED << 11);
+ context->pri_path.port = 1;
+ context->qkey = cpu_to_be32(IB_DEFAULT_Q_KEY);
+
+ ret = mlx5_core_qp_modify(mdev, MLX5_CMD_OP_RST2INIT_QP, 0, context, qp);
+ if (ret) {
+ mlx5_core_err(mdev, "Failed to modify qp RST2INIT, err: %d\n", ret);
+ goto err_qp_modify_to_err;
+ }
+ memset(context, 0, sizeof(*context));
+
+ ret = mlx5_core_qp_modify(mdev, MLX5_CMD_OP_INIT2RTR_QP, 0, context, qp);
+ if (ret) {
+ mlx5_core_err(mdev, "Failed to modify qp INIT2RTR, err: %d\n", ret);
+ goto err_qp_modify_to_err;
+ }
+
+ ret = mlx5_core_qp_modify(mdev, MLX5_CMD_OP_RTR2RTS_QP, 0, context, qp);
+ if (ret) {
+ mlx5_core_err(mdev, "Failed to modify qp RTR2RTS, err: %d\n", ret);
+ goto err_qp_modify_to_err;
+ }
+
+ kfree(context);
+ return 0;
+
+err_qp_modify_to_err:
+ mlx5_core_qp_modify(mdev, MLX5_CMD_OP_2ERR_QP, 0, &context, qp);
+ kfree(context);
+ return ret;
+}
+
+static void mlx5i_uninit_underlay_qp(struct mlx5e_priv *priv)
+{
+ struct mlx5i_priv *ipriv = priv->ppriv;
+ struct mlx5_core_dev *mdev = priv->mdev;
+ struct mlx5_qp_context context;
+ int err;
+
+ err = mlx5_core_qp_modify(mdev, MLX5_CMD_OP_2RST_QP, 0, &context,
+ &ipriv->qp);
+ if (err)
+ mlx5_core_err(mdev, "Failed to modify qp 2RST, err: %d\n", err);
+}
+
#define MLX5_QP_ENHANCED_ULP_STATELESS_MODE 2
static int mlx5i_create_underlay_qp(struct mlx5_core_dev *mdev, struct mlx5_core_qp *qp)
{
- struct mlx5_qp_context *context = NULL;
u32 *in = NULL;
void *addr_path;
int ret = 0;
@@ -140,38 +197,7 @@ static int mlx5i_create_underlay_qp(struct mlx5_core_dev *mdev, struct mlx5_core
goto out;
}
- /* QP states */
- context = kzalloc(sizeof(*context), GFP_KERNEL);
- if (!context) {
- ret = -ENOMEM;
- goto out;
- }
-
- context->flags = cpu_to_be32(MLX5_QP_PM_MIGRATED << 11);
- context->pri_path.port = 1;
- context->qkey = cpu_to_be32(IB_DEFAULT_Q_KEY);
-
- ret = mlx5_core_qp_modify(mdev, MLX5_CMD_OP_RST2INIT_QP, 0, context, qp);
- if (ret) {
- mlx5_core_err(mdev, "Failed to modify qp RST2INIT, err: %d\n", ret);
- goto out;
- }
- memset(context, 0, sizeof(*context));
-
- ret = mlx5_core_qp_modify(mdev, MLX5_CMD_OP_INIT2RTR_QP, 0, context, qp);
- if (ret) {
- mlx5_core_err(mdev, "Failed to modify qp INIT2RTR, err: %d\n", ret);
- goto out;
- }
-
- ret = mlx5_core_qp_modify(mdev, MLX5_CMD_OP_RTR2RTS_QP, 0, context, qp);
- if (ret) {
- mlx5_core_err(mdev, "Failed to modify qp RTR2RTS, err: %d\n", ret);
- goto out;
- }
-
out:
- kfree(context);
kvfree(in);
return ret;
}
@@ -192,13 +218,23 @@ static int mlx5i_init_tx(struct mlx5e_priv *priv)
return err;
}
+ err = mlx5i_init_underlay_qp(priv);
+ if (err) {
+ mlx5_core_warn(priv->mdev, "intilize underlay QP failed, %d\n", err);
+ goto err_destroy_underlay_qp;
+ }
+
err = mlx5e_create_tis(priv->mdev, 0 /* tc */, ipriv->qp.qpn, &priv->tisn[0]);
if (err) {
mlx5_core_warn(priv->mdev, "create tis failed, %d\n", err);
- return err;
+ goto err_destroy_underlay_qp;
}
return 0;
+
+err_destroy_underlay_qp:
+ mlx5i_destroy_underlay_qp(priv->mdev, &ipriv->qp);
+ return err;
}
static void mlx5i_cleanup_tx(struct mlx5e_priv *priv)
@@ -381,12 +417,8 @@ static int mlx5i_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
static void mlx5i_dev_cleanup(struct net_device *dev)
{
struct mlx5e_priv *priv = mlx5i_epriv(dev);
- struct mlx5_core_dev *mdev = priv->mdev;
- struct mlx5i_priv *ipriv = priv->ppriv;
- struct mlx5_qp_context context;
- /* detach qp from flow-steering by reset it */
- mlx5_core_qp_modify(mdev, MLX5_CMD_OP_2RST_QP, 0, &context, &ipriv->qp);
+ mlx5i_uninit_underlay_qp(priv);
}
static int mlx5i_open(struct net_device *netdev)
--
2.14.2
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" 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 related
* [for-next 08/12] net/mlx5e: IPoIB, Use hash-table to map between QPN to child netdev
From: Saeed Mahameed @ 2017-10-14 18:48 UTC (permalink / raw)
To: David S. Miller, Doug Ledford
Cc: netdev-u79uwXL29TY76Z2rM5mHXA, linux-rdma-u79uwXL29TY76Z2rM5mHXA,
Leon Romanovsky, Alex Vesker, Saeed Mahameed
In-Reply-To: <20171014184827.18491-1-saeedm-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
From: Alex Vesker <valex-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
This change is needed for PKEY support, since the RQs are shared
between the child interface and the parent. The parent is responsible
for NAPI and the precessing of RX completions. Using the dqpn in the
completion descriptor we set the corresponding child IPoIB netdevice
on the SKB.
The mapping between the dqpn and the netdevice is done using a HT,
each mlx5 IPoIB interface registers its mapping on creation.
Signed-off-by: Alex Vesker <valex-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
Reviewed-by: Erez Shitrit <erezsh-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
Signed-off-by: Saeed Mahameed <saeedm-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
---
drivers/net/ethernet/mellanox/mlx5/core/Makefile | 2 +-
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | 20 ++-
.../net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c | 16 +++
.../net/ethernet/mellanox/mlx5/core/ipoib/ipoib.h | 12 ++
.../ethernet/mellanox/mlx5/core/ipoib/ipoib_vlan.c | 136 +++++++++++++++++++++
5 files changed, 184 insertions(+), 2 deletions(-)
create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib_vlan.c
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/Makefile b/drivers/net/ethernet/mellanox/mlx5/core/Makefile
index d9621b2152d3..100fe4ecad9b 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/Makefile
+++ b/drivers/net/ethernet/mellanox/mlx5/core/Makefile
@@ -22,7 +22,7 @@ mlx5_core-$(CONFIG_MLX5_ESWITCH) += eswitch.o eswitch_offloads.o en_rep.o en_tc.
mlx5_core-$(CONFIG_MLX5_CORE_EN_DCB) += en_dcbnl.o
-mlx5_core-$(CONFIG_MLX5_CORE_IPOIB) += ipoib/ipoib.o ipoib/ethtool.o
+mlx5_core-$(CONFIG_MLX5_CORE_IPOIB) += ipoib/ipoib.o ipoib/ethtool.o ipoib/ipoib_vlan.o
mlx5_core-$(CONFIG_MLX5_EN_IPSEC) += en_accel/ipsec.o en_accel/ipsec_rxtx.o \
en_accel/ipsec_stats.o
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
index 7e3bfe62ef6e..2c3f2e9b6983 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
@@ -1163,11 +1163,25 @@ static inline void mlx5i_complete_rx_cqe(struct mlx5e_rq *rq,
u32 cqe_bcnt,
struct sk_buff *skb)
{
- struct net_device *netdev = rq->netdev;
+ struct net_device *netdev;
char *pseudo_header;
+ u32 qpn;
u8 *dgid;
u8 g;
+ qpn = be32_to_cpu(cqe->sop_drop_qpn) & 0xffffff;
+ netdev = mlx5i_pkey_get_netdev(rq->netdev, qpn);
+
+ /* No mapping present, cannot process SKB. This might happen if a child
+ * interface is going down while having unprocessed CQEs on parent RQ
+ */
+ if (unlikely(!netdev)) {
+ /* TODO: add drop counters support */
+ skb->dev = NULL;
+ pr_warn_once("Unable to map QPN %u to dev - dropping skb\n", qpn);
+ return;
+ }
+
g = (be32_to_cpu(cqe->flags_rqpn) >> 28) & 3;
dgid = skb->data + MLX5_IB_GRH_DGID_OFFSET;
if ((!g) || dgid[0] != 0xff)
@@ -1230,6 +1244,10 @@ void mlx5i_handle_rx_cqe(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe)
goto wq_free_wqe;
mlx5i_complete_rx_cqe(rq, cqe, cqe_bcnt, skb);
+ if (unlikely(!skb->dev)) {
+ dev_kfree_skb_any(skb);
+ goto wq_free_wqe;
+ }
napi_gro_receive(rq->cq.napi, skb);
wq_free_wqe:
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c b/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c
index 679c1f9af642..c479fe54a6ca 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c
@@ -382,6 +382,9 @@ static int mlx5i_dev_init(struct net_device *dev)
dev->dev_addr[2] = (ipriv->qp.qpn >> 8) & 0xff;
dev->dev_addr[3] = (ipriv->qp.qpn) & 0xff;
+ /* Add QPN to net-device mapping to HT */
+ mlx5i_pkey_add_qpn(dev ,ipriv->qp.qpn);
+
return 0;
}
@@ -402,8 +405,12 @@ static int mlx5i_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
static void mlx5i_dev_cleanup(struct net_device *dev)
{
struct mlx5e_priv *priv = mlx5i_epriv(dev);
+ struct mlx5i_priv *ipriv = priv->ppriv;
mlx5i_uninit_underlay_qp(priv);
+
+ /* Delete QPN to net-device mapping from HT */
+ mlx5i_pkey_del_qpn(dev, ipriv->qp.qpn);
}
static int mlx5i_open(struct net_device *netdev)
@@ -590,6 +597,12 @@ struct net_device *mlx5_rdma_netdev_alloc(struct mlx5_core_dev *mdev,
if (!epriv->wq)
goto err_free_netdev;
+ err = mlx5i_pkey_qpn_ht_init(netdev);
+ if (err) {
+ mlx5_core_warn(mdev, "allocate qpn_to_netdev ht failed\n");
+ goto destroy_wq;
+ }
+
profile->init(mdev, netdev, profile, ipriv);
mlx5e_attach_netdev(epriv);
@@ -605,6 +618,8 @@ struct net_device *mlx5_rdma_netdev_alloc(struct mlx5_core_dev *mdev,
return netdev;
+destroy_wq:
+ destroy_workqueue(epriv->wq);
err_free_netdev:
free_netdev(netdev);
free_mdev_resources:
@@ -623,6 +638,7 @@ void mlx5_rdma_netdev_free(struct net_device *netdev)
mlx5e_detach_netdev(priv);
profile->cleanup(priv);
destroy_workqueue(priv->wq);
+ mlx5i_pkey_qpn_ht_cleanup(netdev);
free_netdev(netdev);
mlx5e_destroy_mdev_resources(mdev);
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.h b/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.h
index 9a729883c3b3..e313f6d90729 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.h
@@ -51,9 +51,21 @@ struct mlx5i_priv {
struct mlx5_core_qp qp;
u32 qkey;
u16 pkey_index;
+ struct mlx5i_pkey_qpn_ht *qpn_htbl;
char *mlx5e_priv[0];
};
+/* Allocate/Free underlay QPN to net-device hash table */
+int mlx5i_pkey_qpn_ht_init(struct net_device *netdev);
+void mlx5i_pkey_qpn_ht_cleanup(struct net_device *netdev);
+
+/* Add/Remove an underlay QPN to net-device mapping to/from the hash table */
+int mlx5i_pkey_add_qpn(struct net_device *netdev, u32 qpn);
+int mlx5i_pkey_del_qpn(struct net_device *netdev, u32 qpn);
+
+/* Get the net-device corresponding to the given underlay QPN */
+struct net_device *mlx5i_pkey_get_netdev(struct net_device *netdev, u32 qpn);
+
/* Extract mlx5e_priv from IPoIB netdev */
#define mlx5i_epriv(netdev) ((void *)(((struct mlx5i_priv *)netdev_priv(netdev))->mlx5e_priv))
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib_vlan.c b/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib_vlan.c
new file mode 100644
index 000000000000..e4d39aa1f552
--- /dev/null
+++ b/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib_vlan.c
@@ -0,0 +1,136 @@
+/*
+ * Copyright (c) 2017, Mellanox Technologies. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <linux/hash.h>
+#include "ipoib.h"
+
+#define MLX5I_MAX_LOG_PKEY_SUP 7
+
+struct qpn_to_netdev {
+ struct net_device *netdev;
+ struct hlist_node hlist;
+ u32 underlay_qpn;
+};
+
+struct mlx5i_pkey_qpn_ht {
+ struct hlist_head buckets[1 << MLX5I_MAX_LOG_PKEY_SUP];
+ spinlock_t ht_lock; /* Synchronise with NAPI */
+};
+
+int mlx5i_pkey_qpn_ht_init(struct net_device *netdev)
+{
+ struct mlx5i_priv *ipriv = netdev_priv(netdev);
+ struct mlx5i_pkey_qpn_ht *qpn_htbl;
+
+ qpn_htbl = kzalloc(sizeof(*qpn_htbl), GFP_KERNEL);
+ if (!qpn_htbl)
+ return -ENOMEM;
+
+ ipriv->qpn_htbl = qpn_htbl;
+ spin_lock_init(&qpn_htbl->ht_lock);
+
+ return 0;
+}
+
+void mlx5i_pkey_qpn_ht_cleanup(struct net_device *netdev)
+{
+ struct mlx5i_priv *ipriv = netdev_priv(netdev);
+
+ kfree(ipriv->qpn_htbl);
+}
+
+static struct qpn_to_netdev *mlx5i_find_qpn_to_netdev_node(struct hlist_head *buckets,
+ u32 qpn)
+{
+ struct hlist_head *h = &buckets[hash_32(qpn, MLX5I_MAX_LOG_PKEY_SUP)];
+ struct qpn_to_netdev *node;
+
+ hlist_for_each_entry(node, h, hlist) {
+ if (node->underlay_qpn == qpn)
+ return node;
+ }
+
+ return NULL;
+}
+
+int mlx5i_pkey_add_qpn(struct net_device *netdev, u32 qpn)
+{
+ struct mlx5i_priv *ipriv = netdev_priv(netdev);
+ struct mlx5i_pkey_qpn_ht *ht = ipriv->qpn_htbl;
+ u8 key = hash_32(qpn, MLX5I_MAX_LOG_PKEY_SUP);
+ struct qpn_to_netdev *new_node;
+
+ new_node = kzalloc(sizeof(*new_node), GFP_KERNEL);
+ if (!new_node)
+ return -ENOMEM;
+
+ new_node->netdev = netdev;
+ new_node->underlay_qpn = qpn;
+ spin_lock_bh(&ht->ht_lock);
+ hlist_add_head(&new_node->hlist, &ht->buckets[key]);
+ spin_unlock_bh(&ht->ht_lock);
+
+ return 0;
+}
+
+int mlx5i_pkey_del_qpn(struct net_device *netdev, u32 qpn)
+{
+ struct mlx5e_priv *epriv = mlx5i_epriv(netdev);
+ struct mlx5i_priv *ipriv = epriv->ppriv;
+ struct mlx5i_pkey_qpn_ht *ht = ipriv->qpn_htbl;
+ struct qpn_to_netdev *node;
+
+ node = mlx5i_find_qpn_to_netdev_node(ht->buckets, qpn);
+ if (!node) {
+ mlx5_core_warn(epriv->mdev, "QPN to netdev delete from HT failed\n");
+ return -EINVAL;
+ }
+
+ spin_lock_bh(&ht->ht_lock);
+ hlist_del_init(&node->hlist);
+ spin_unlock_bh(&ht->ht_lock);
+ kfree(node);
+
+ return 0;
+}
+
+struct net_device *mlx5i_pkey_get_netdev(struct net_device *netdev, u32 qpn)
+{
+ struct mlx5i_priv *ipriv = netdev_priv(netdev);
+ struct qpn_to_netdev *node;
+
+ node = mlx5i_find_qpn_to_netdev_node(ipriv->qpn_htbl->buckets, qpn);
+ if (!node)
+ return NULL;
+
+ return node->netdev;
+}
--
2.14.2
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" 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 related
* [for-next 11/12] net/mlx5e: IPoIB, Add PKEY child interface ethtool ops
From: Saeed Mahameed @ 2017-10-14 18:48 UTC (permalink / raw)
To: David S. Miller, Doug Ledford
Cc: netdev-u79uwXL29TY76Z2rM5mHXA, linux-rdma-u79uwXL29TY76Z2rM5mHXA,
Leon Romanovsky, Alex Vesker, Saeed Mahameed
In-Reply-To: <20171014184827.18491-1-saeedm-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
From: Alex Vesker <valex-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
Similar to VLAN interfaces child interfaces have limited ethtool
support. In current code the main limitation that does not
allow child interface ethtool configuration is due to shared
resources which are managed by the parent.
Signed-off-by: Alex Vesker <valex-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
Reviewed-by: Erez Shitrit <erezsh-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
Signed-off-by: Saeed Mahameed <saeedm-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
---
drivers/net/ethernet/mellanox/mlx5/core/ipoib/ethtool.c | 5 +++++
drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.h | 1 +
drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib_vlan.c | 4 ++--
3 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ethtool.c b/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ethtool.c
index 43c126c63955..6f338a9219c8 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ethtool.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ethtool.c
@@ -250,3 +250,8 @@ const struct ethtool_ops mlx5i_ethtool_ops = {
.get_link_ksettings = mlx5i_get_link_ksettings,
.get_link = ethtool_op_get_link,
};
+
+const struct ethtool_ops mlx5i_pkey_ethtool_ops = {
+ .get_drvinfo = mlx5i_get_drvinfo,
+ .get_link = ethtool_op_get_link,
+};
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.h b/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.h
index 80c0cfee7164..a50c1a19550e 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.h
@@ -39,6 +39,7 @@
#define MLX5I_MAX_NUM_TC 1
extern const struct ethtool_ops mlx5i_ethtool_ops;
+extern const struct ethtool_ops mlx5i_pkey_ethtool_ops;
#define MLX5_IB_GRH_BYTES 40
#define MLX5_IPOIB_ENCAP_LEN 4
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib_vlan.c b/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib_vlan.c
index d99bec6855de..531b02cc979b 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib_vlan.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib_vlan.c
@@ -279,8 +279,8 @@ static void mlx5i_pkey_init(struct mlx5_core_dev *mdev,
/* Override parent ndo */
netdev->netdev_ops = &mlx5i_pkey_netdev_ops;
- /* Currently no ethtool support */
- netdev->ethtool_ops = NULL;
+ /* Set child limited ethtool support */
+ netdev->ethtool_ops = &mlx5i_pkey_ethtool_ops;
/* Use dummy rqs */
priv->channels.params.log_rq_size = MLX5E_PARAMS_MINIMUM_LOG_RQ_SIZE;
--
2.14.2
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" 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 related
* [pull request][for-next 00/12] Mellanox, mlx5 IPoIB Muli Pkey support 2017-10-11
From: Saeed Mahameed @ 2017-10-14 18:48 UTC (permalink / raw)
To: David S. Miller, Doug Ledford
Cc: netdev, linux-rdma, Leon Romanovsky, Saeed Mahameed
Hi Dave and Doug,
This series includes updates for mlx5 IPoIB offloading driver from Alex
and Feras to add the support for Muli Pkey in the mlx5i ipoib offloading netdev,
to be merged into net-next and rdma-next trees.
Doug, I am sorry I couldn't base this on rc2 since the series needs and conflicts
with a fix that was submitted to rc3, so to keep things simple I based it on rc4,
I hope this is ok with you..
Please pull and let me know if there's any problem.
Thanks,
Saeed.
---
The following changes since commit 8a5776a5f49812d29fe4b2d0a2d71675c3facf3f:
Linux 4.14-rc4 (2017-10-08 20:53:29 -0700)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/mellanox/linux.git tags/mlx5-updates-2017-10-11
for you to fetch changes up to b5ae577741bec22b584fa704076ccd8221cad19d:
net/mlx5e: IPoIB, Modify rdma netdev allocate and free to support PKEY (2017-10-14 11:22:12 -0700)
----------------------------------------------------------------
mlx5-updates-2017-10-11: IPoIB Muli Pkey support
This series provides the support for IPoIB Multi Pkey.
InfiniBand Pkeys are the equivalent of Ethernet vlans.
Currently IPoIB device driver supports only default Pkey and IPoIB Pkey child
interfaces are not supported with IPoIB offloads mode, this series will add
the support for that by allowing creating mlx5 multiple IPoIB netdevices with
a non-default Pkey.
mlx5 IPoIB Pkey child interface is smaller version of mlx5i IPoIB interfaces and shares
most of its resources with the parent IPoIB interface, namely RX steering and ring
queue resources.
The only mlx5 resources a child Pkey interface will be creating are the TX rings,
since they should be assigned to a specific Pkey.
mlx5i Pkey netdev is implemented via new mlx5e netdev profile implemented in
mlx5/core/ipoib/ipoib_vlan.c.
The series starts with a refactoring of mlx5e PTP and mlx5 clock implementation
to move the code to be part of mlx5 core rather than mlx5e netdevice, in order to
make mlx5 clock and PTP registration part of the core to be shared with mlx5e
master Ethernet netdev/IPoIB parent netdev and mlx5_ib in the near future.
Add the support for attaching multiple underlay QPs for the different Pkeys
in mlx5 core RX steering.
Add Pkey index to rdma_netdev to add the ability to set PKEY index to lower
IPoIB offload netdev.
Use hash-table to map between DQPN (Destination QP number) to child netdev
for the IPoIB parent netdev to forward RX packets to the corresponding
child Pkey netdev, since the RX rings are shared.
The reset of the series adds the ipoib child Pkey: mlx5e netdev profile,
netdev nods implementation and minimal set of ethtool callbacks.
Thanks,
Saeed.
----------------------------------------------------------------
Alex Vesker (10):
net/mlx5e: IPoIB, Move underlay QP init/uninit to separate functions
net/mlx5: Support for attaching multiple underlay QPs to root flow table
IB/ipoib: Grab rtnl lock on heavy flush when calling ndo_open/stop
IB/ipoib: Add ability to set PKEY index to lower device driver
net/mlx5e: IPoIB, Support for setting PKEY index to underlay QP
net/mlx5e: IPoIB, Use hash-table to map between QPN to child netdev
net/mlx5e: IPoIB, Add PKEY child interface nic profile
net/mlx5e: IPoIB, Add PKEY child interface ndos
net/mlx5e: IPoIB, Add PKEY child interface ethtool ops
net/mlx5e: IPoIB, Modify rdma netdev allocate and free to support PKEY
Feras Daoud (2):
net/mlx5: File renaming towards ptp core implementation
net/mlx5: PTP code migration to driver core section
drivers/infiniband/ulp/ipoib/ipoib_ib.c | 15 +-
drivers/net/ethernet/mellanox/mlx5/core/Kconfig | 2 +-
drivers/net/ethernet/mellanox/mlx5/core/Makefile | 6 +-
drivers/net/ethernet/mellanox/mlx5/core/en.h | 39 +-
drivers/net/ethernet/mellanox/mlx5/core/en_clock.c | 619 ---------------------
.../net/ethernet/mellanox/mlx5/core/en_common.c | 1 +
.../net/ethernet/mellanox/mlx5/core/en_ethtool.c | 7 +-
drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 95 +++-
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | 37 +-
drivers/net/ethernet/mellanox/mlx5/core/en_tx.c | 6 +-
drivers/net/ethernet/mellanox/mlx5/core/eq.c | 3 +-
drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c | 13 +-
drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.h | 4 +-
drivers/net/ethernet/mellanox/mlx5/core/fs_core.c | 123 +++-
drivers/net/ethernet/mellanox/mlx5/core/fs_core.h | 7 +-
.../ethernet/mellanox/mlx5/core/ipoib/ethtool.c | 5 +
.../net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c | 260 ++++++---
.../net/ethernet/mellanox/mlx5/core/ipoib/ipoib.h | 36 ++
.../ethernet/mellanox/mlx5/core/ipoib/ipoib_vlan.c | 350 ++++++++++++
.../net/ethernet/mellanox/mlx5/core/lib/clock.c | 525 +++++++++++++++++
.../net/ethernet/mellanox/mlx5/core/lib/clock.h | 51 ++
drivers/net/ethernet/mellanox/mlx5/core/main.c | 4 +
.../net/ethernet/mellanox/mlx5/core/mlx5_core.h | 1 +
include/linux/mlx5/driver.h | 24 +
24 files changed, 1437 insertions(+), 796 deletions(-)
delete mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en_clock.c
create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib_vlan.c
create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/lib/clock.h
^ permalink raw reply
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