* [v3 2/3] samples: pktgen: add helper functions for IP(v4/v6) CIDR parsing
From: Daniel T. Lee @ 2019-09-14 15:13 UTC (permalink / raw)
To: Jesper Dangaard Brouer, David S . Miller; +Cc: netdev
In-Reply-To: <20190914151353.18054-1-danieltimlee@gmail.com>
This commit adds CIDR parsing and IP validate helper function to parse
single IP or range of IP with CIDR. (e.g. 198.18.0.0/15)
Helpers will be used in prior to set target address in samples/pktgen.
Signed-off-by: Daniel T. Lee <danieltimlee@gmail.com>
---
Changes since v3:
* Set errexit option to stop script execution on error
samples/pktgen/functions.sh | 124 ++++++++++++++++++++++++++++++++++++
1 file changed, 124 insertions(+)
diff --git a/samples/pktgen/functions.sh b/samples/pktgen/functions.sh
index 4af4046d71be..87ae61701904 100644
--- a/samples/pktgen/functions.sh
+++ b/samples/pktgen/functions.sh
@@ -5,6 +5,8 @@
# Author: Jesper Dangaaard Brouer
# License: GPL
+set -o errexit
+
## -- General shell logging cmds --
function err() {
local exitcode=$1
@@ -163,6 +165,128 @@ function get_node_cpus()
echo $node_cpu_list
}
+# Extend shrunken IPv6 address.
+# fe80::42:bcff:fe84:e10a => fe80:0:0:0:42:bcff:fe84:e10a
+function extend_addr6()
+{
+ local addr=$1
+ local sep=: sep2=::
+ local sep_cnt=$(tr -cd $sep <<< $1 | wc -c)
+ local shrink
+
+ # separator count : should be between 2, 7.
+ if [[ $sep_cnt -lt 2 || $sep_cnt -gt 7 ]]; then
+ err 5 "Invalid IP6 address sep: $1"
+ fi
+
+ # if shrink '::' occurs multiple, it's malformed.
+ shrink=( $(egrep -o "$sep{2,}" <<< $addr) )
+ if [[ ${#shrink[@]} -ne 0 ]]; then
+ if [[ ${#shrink[@]} -gt 1 || ( ${shrink[0]} != $sep2 ) ]]; then
+ err 5 "Invalid IP$IP6 address shr: $1"
+ fi
+ fi
+
+ # add 0 at begin & end, and extend addr by adding :0
+ [[ ${addr:0:1} == $sep ]] && addr=0${addr}
+ [[ ${addr: -1} == $sep ]] && addr=${addr}0
+ echo "${addr/$sep2/$(printf ':0%.s' $(seq $[8-sep_cnt])):}"
+}
+
+
+# Given a single IP(v4/v6) address, whether it is valid.
+function validate_addr()
+{
+ # check function is called with (funcname)6
+ [[ ${FUNCNAME[1]: -1} == 6 ]] && local IP6=6
+ local len=$[ IP6 ? 8 : 4 ]
+ local max=$[ 2**(len*2)-1 ]
+ local addr sep
+
+ # set separator for each IP(v4/v6)
+ [[ $IP6 ]] && sep=: || sep=.
+ IFS=$sep read -a addr <<< $1
+
+ # array length
+ if [[ ${#addr[@]} != $len ]]; then
+ err 5 "Invalid IP$IP6 address: $1"
+ fi
+
+ # check each digit between 0, $max
+ for digit in "${addr[@]}"; do
+ [[ $IP6 ]] && digit=$[ 16#$digit ]
+ if [[ $digit -lt 0 || $digit -gt $max ]]; then
+ err 5 "Invalid IP$IP6 address: $1"
+ fi
+ done
+
+ return 0
+}
+
+function validate_addr6() { validate_addr $@ ; }
+
+# Given a single IP(v4/v6) or CIDR, return minimum and maximum IP addr.
+function parse_addr()
+{
+ # check function is called with (funcname)6
+ [[ ${FUNCNAME[1]: -1} == 6 ]] && local IP6=6
+ local bitlen=$[ IP6 ? 128 : 32 ]
+ local octet=$[ IP6 ? 16 : 8 ]
+
+ local addr=$1
+ local net prefix
+ local min_ip max_ip
+
+ IFS='/' read net prefix <<< $addr
+ [[ $IP6 ]] && net=$(extend_addr6 $net)
+ validate_addr$IP6 $net
+
+ if [[ $prefix -gt $bitlen ]]; then
+ err 5 "Invalid prefix: $prefix"
+ elif [[ -z $prefix ]]; then
+ min_ip=$net
+ max_ip=$net
+ else
+ # defining array for converting Decimal 2 Binary
+ # 00000000 00000001 00000010 00000011 00000100 ...
+ local d2b='{0..1}{0..1}{0..1}{0..1}{0..1}{0..1}{0..1}{0..1}'
+ [[ $IP6 ]] && d2b+=$d2b
+ eval local D2B=($d2b)
+
+ local remain=$[ bitlen-prefix ]
+ local min_mask max_mask
+ local min max
+ local ip_bit
+ local ip sep
+
+ # set separator for each IP(v4/v6)
+ [[ $IP6 ]] && sep=: || sep=.
+ IFS=$sep read -ra ip <<< $net
+
+ min_mask="$(printf '1%.s' $(seq $prefix))$(printf '0%.s' $(seq $remain))"
+ max_mask="$(printf '0%.s' $(seq $prefix))$(printf '1%.s' $(seq $remain))"
+
+ # calculate min/max ip with &,| operator
+ for i in "${!ip[@]}"; do
+ digit=$[ IP6 ? 16#${ip[$i]} : ${ip[$i]} ]
+ ip_bit=${D2B[$digit]}
+
+ idx=$[ octet*i ]
+ min[$i]=$[ 2#$ip_bit & 2#${min_mask:$idx:$octet} ]
+ max[$i]=$[ 2#$ip_bit | 2#${max_mask:$idx:$octet} ]
+ [[ $IP6 ]] && { min[$i]=$(printf '%X' ${min[$i]});
+ max[$i]=$(printf '%X' ${max[$i]}); }
+ done
+
+ min_ip=$(IFS=$sep; echo "${min[*]}")
+ max_ip=$(IFS=$sep; echo "${max[*]}")
+ fi
+
+ echo $min_ip $max_ip
+}
+
+function parse_addr6() { parse_addr $@ ; }
+
# Given a single or range of port(s), return minimum and maximum port number.
function parse_ports()
{
--
2.20.1
^ permalink raw reply related
* [v3 1/3] samples: pktgen: make variable consistent with option
From: Daniel T. Lee @ 2019-09-14 15:13 UTC (permalink / raw)
To: Jesper Dangaard Brouer, David S . Miller; +Cc: netdev
This commit changes variable names that can cause confusion.
For example, variable DST_MIN is quite confusing since the
keyword 'udp_dst_min' and keyword 'dst_min' is used with pg_ctrl.
On the following commit, 'dst_min' will be used to set destination IP,
and the existing variable name DST_MIN should be changed.
Variable names are matched to the exact keyword used with pg_ctrl.
Signed-off-by: Daniel T. Lee <danieltimlee@gmail.com>
---
.../pktgen_bench_xmit_mode_netif_receive.sh | 8 ++++----
.../pktgen/pktgen_bench_xmit_mode_queue_xmit.sh | 8 ++++----
samples/pktgen/pktgen_sample01_simple.sh | 16 ++++++++--------
samples/pktgen/pktgen_sample02_multiqueue.sh | 16 ++++++++--------
.../pktgen/pktgen_sample03_burst_single_flow.sh | 8 ++++----
samples/pktgen/pktgen_sample04_many_flows.sh | 8 ++++----
.../pktgen/pktgen_sample05_flow_per_thread.sh | 8 ++++----
...en_sample06_numa_awared_queue_irq_affinity.sh | 16 ++++++++--------
8 files changed, 44 insertions(+), 44 deletions(-)
diff --git a/samples/pktgen/pktgen_bench_xmit_mode_netif_receive.sh b/samples/pktgen/pktgen_bench_xmit_mode_netif_receive.sh
index e14b1a9144d9..9b74502c58f7 100755
--- a/samples/pktgen/pktgen_bench_xmit_mode_netif_receive.sh
+++ b/samples/pktgen/pktgen_bench_xmit_mode_netif_receive.sh
@@ -42,8 +42,8 @@ fi
[ -z "$BURST" ] && BURST=1024
[ -z "$COUNT" ] && COUNT="10000000" # Zero means indefinitely
if [ -n "$DST_PORT" ]; then
- read -r DST_MIN DST_MAX <<< $(parse_ports $DST_PORT)
- validate_ports $DST_MIN $DST_MAX
+ read -r UDP_DST_MIN UDP_DST_MAX <<< $(parse_ports $DST_PORT)
+ validate_ports $UDP_DST_MIN $UDP_DST_MAX
fi
# Base Config
@@ -76,8 +76,8 @@ for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do
if [ -n "$DST_PORT" ]; then
# Single destination port or random port range
pg_set $dev "flag UDPDST_RND"
- pg_set $dev "udp_dst_min $DST_MIN"
- pg_set $dev "udp_dst_max $DST_MAX"
+ pg_set $dev "udp_dst_min $UDP_DST_MIN"
+ pg_set $dev "udp_dst_max $UDP_DST_MAX"
fi
# Inject packet into RX path of stack
diff --git a/samples/pktgen/pktgen_bench_xmit_mode_queue_xmit.sh b/samples/pktgen/pktgen_bench_xmit_mode_queue_xmit.sh
index 82c3e504e056..0f332555b40d 100755
--- a/samples/pktgen/pktgen_bench_xmit_mode_queue_xmit.sh
+++ b/samples/pktgen/pktgen_bench_xmit_mode_queue_xmit.sh
@@ -25,8 +25,8 @@ if [[ -n "$BURST" ]]; then
fi
[ -z "$COUNT" ] && COUNT="10000000" # Zero means indefinitely
if [ -n "$DST_PORT" ]; then
- read -r DST_MIN DST_MAX <<< $(parse_ports $DST_PORT)
- validate_ports $DST_MIN $DST_MAX
+ read -r UDP_DST_MIN UDP_DST_MAX <<< $(parse_ports $DST_PORT)
+ validate_ports $UDP_DST_MIN $UDP_DST_MAX
fi
# Base Config
@@ -59,8 +59,8 @@ for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do
if [ -n "$DST_PORT" ]; then
# Single destination port or random port range
pg_set $dev "flag UDPDST_RND"
- pg_set $dev "udp_dst_min $DST_MIN"
- pg_set $dev "udp_dst_max $DST_MAX"
+ pg_set $dev "udp_dst_min $UDP_DST_MIN"
+ pg_set $dev "udp_dst_max $UDP_DST_MAX"
fi
# Inject packet into TX qdisc egress path of stack
diff --git a/samples/pktgen/pktgen_sample01_simple.sh b/samples/pktgen/pktgen_sample01_simple.sh
index d1702fdde8f3..063ec0998906 100755
--- a/samples/pktgen/pktgen_sample01_simple.sh
+++ b/samples/pktgen/pktgen_sample01_simple.sh
@@ -23,16 +23,16 @@ fi
[ -z "$DST_MAC" ] && usage && err 2 "Must specify -m dst_mac"
[ -z "$COUNT" ] && COUNT="100000" # Zero means indefinitely
if [ -n "$DST_PORT" ]; then
- read -r DST_MIN DST_MAX <<< $(parse_ports $DST_PORT)
- validate_ports $DST_MIN $DST_MAX
+ read -r UDP_DST_MIN UDP_DST_MAX <<< $(parse_ports $DST_PORT)
+ validate_ports $UDP_DST_MIN $UDP_DST_MAX
fi
# Base Config
DELAY="0" # Zero means max speed
# Flow variation random source port between min and max
-UDP_MIN=9
-UDP_MAX=109
+UDP_SRC_MIN=9
+UDP_SRC_MAX=109
# General cleanup everything since last run
# (especially important if other threads were configured by other scripts)
@@ -66,14 +66,14 @@ pg_set $DEV "dst$IP6 $DEST_IP"
if [ -n "$DST_PORT" ]; then
# Single destination port or random port range
pg_set $DEV "flag UDPDST_RND"
- pg_set $DEV "udp_dst_min $DST_MIN"
- pg_set $DEV "udp_dst_max $DST_MAX"
+ pg_set $DEV "udp_dst_min $UDP_DST_MIN"
+ pg_set $DEV "udp_dst_max $UDP_DST_MAX"
fi
# Setup random UDP port src range
pg_set $DEV "flag UDPSRC_RND"
-pg_set $DEV "udp_src_min $UDP_MIN"
-pg_set $DEV "udp_src_max $UDP_MAX"
+pg_set $DEV "udp_src_min $UDP_SRC_MIN"
+pg_set $DEV "udp_src_max $UDP_SRC_MAX"
# start_run
echo "Running... ctrl^C to stop" >&2
diff --git a/samples/pktgen/pktgen_sample02_multiqueue.sh b/samples/pktgen/pktgen_sample02_multiqueue.sh
index 7f7a9a27548f..a4726fb50197 100755
--- a/samples/pktgen/pktgen_sample02_multiqueue.sh
+++ b/samples/pktgen/pktgen_sample02_multiqueue.sh
@@ -21,8 +21,8 @@ DELAY="0" # Zero means max speed
[ -z "$CLONE_SKB" ] && CLONE_SKB="0"
# Flow variation random source port between min and max
-UDP_MIN=9
-UDP_MAX=109
+UDP_SRC_MIN=9
+UDP_SRC_MAX=109
# (example of setting default params in your script)
if [ -z "$DEST_IP" ]; then
@@ -30,8 +30,8 @@ if [ -z "$DEST_IP" ]; then
fi
[ -z "$DST_MAC" ] && DST_MAC="90:e2:ba:ff:ff:ff"
if [ -n "$DST_PORT" ]; then
- read -r DST_MIN DST_MAX <<< $(parse_ports $DST_PORT)
- validate_ports $DST_MIN $DST_MAX
+ read -r UDP_DST_MIN UDP_DST_MAX <<< $(parse_ports $DST_PORT)
+ validate_ports $UDP_DST_MIN $UDP_DST_MAX
fi
# General cleanup everything since last run
@@ -67,14 +67,14 @@ for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do
if [ -n "$DST_PORT" ]; then
# Single destination port or random port range
pg_set $dev "flag UDPDST_RND"
- pg_set $dev "udp_dst_min $DST_MIN"
- pg_set $dev "udp_dst_max $DST_MAX"
+ pg_set $dev "udp_dst_min $UDP_DST_MIN"
+ pg_set $dev "udp_dst_max $UDP_DST_MAX"
fi
# Setup random UDP port src range
pg_set $dev "flag UDPSRC_RND"
- pg_set $dev "udp_src_min $UDP_MIN"
- pg_set $dev "udp_src_max $UDP_MAX"
+ pg_set $dev "udp_src_min $UDP_SRC_MIN"
+ pg_set $dev "udp_src_max $UDP_SRC_MAX"
done
# start_run
diff --git a/samples/pktgen/pktgen_sample03_burst_single_flow.sh b/samples/pktgen/pktgen_sample03_burst_single_flow.sh
index b520637817ce..dfea91a09ccc 100755
--- a/samples/pktgen/pktgen_sample03_burst_single_flow.sh
+++ b/samples/pktgen/pktgen_sample03_burst_single_flow.sh
@@ -34,8 +34,8 @@ fi
[ -z "$CLONE_SKB" ] && CLONE_SKB="0" # No need for clones when bursting
[ -z "$COUNT" ] && COUNT="0" # Zero means indefinitely
if [ -n "$DST_PORT" ]; then
- read -r DST_MIN DST_MAX <<< $(parse_ports $DST_PORT)
- validate_ports $DST_MIN $DST_MAX
+ read -r UDP_DST_MIN UDP_DST_MAX <<< $(parse_ports $DST_PORT)
+ validate_ports $UDP_DST_MIN $UDP_DST_MAX
fi
# Base Config
@@ -67,8 +67,8 @@ for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do
if [ -n "$DST_PORT" ]; then
# Single destination port or random port range
pg_set $dev "flag UDPDST_RND"
- pg_set $dev "udp_dst_min $DST_MIN"
- pg_set $dev "udp_dst_max $DST_MAX"
+ pg_set $dev "udp_dst_min $UDP_DST_MIN"
+ pg_set $dev "udp_dst_max $UDP_DST_MAX"
fi
# Setup burst, for easy testing -b 0 disable bursting
diff --git a/samples/pktgen/pktgen_sample04_many_flows.sh b/samples/pktgen/pktgen_sample04_many_flows.sh
index 5b6e9d9cb5b5..7ea9b4a3acf6 100755
--- a/samples/pktgen/pktgen_sample04_many_flows.sh
+++ b/samples/pktgen/pktgen_sample04_many_flows.sh
@@ -18,8 +18,8 @@ source ${basedir}/parameters.sh
[ -z "$CLONE_SKB" ] && CLONE_SKB="0"
[ -z "$COUNT" ] && COUNT="0" # Zero means indefinitely
if [ -n "$DST_PORT" ]; then
- read -r DST_MIN DST_MAX <<< $(parse_ports $DST_PORT)
- validate_ports $DST_MIN $DST_MAX
+ read -r UDP_DST_MIN UDP_DST_MAX <<< $(parse_ports $DST_PORT)
+ validate_ports $UDP_DST_MIN $UDP_DST_MAX
fi
# NOTICE: Script specific settings
@@ -63,8 +63,8 @@ for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do
if [ -n "$DST_PORT" ]; then
# Single destination port or random port range
pg_set $dev "flag UDPDST_RND"
- pg_set $dev "udp_dst_min $DST_MIN"
- pg_set $dev "udp_dst_max $DST_MAX"
+ pg_set $dev "udp_dst_min $UDP_DST_MIN"
+ pg_set $dev "udp_dst_max $UDP_DST_MAX"
fi
# Randomize source IP-addresses
diff --git a/samples/pktgen/pktgen_sample05_flow_per_thread.sh b/samples/pktgen/pktgen_sample05_flow_per_thread.sh
index 0c06e63fbe97..fbfafe029e11 100755
--- a/samples/pktgen/pktgen_sample05_flow_per_thread.sh
+++ b/samples/pktgen/pktgen_sample05_flow_per_thread.sh
@@ -23,8 +23,8 @@ source ${basedir}/parameters.sh
[ -z "$BURST" ] && BURST=32
[ -z "$COUNT" ] && COUNT="0" # Zero means indefinitely
if [ -n "$DST_PORT" ]; then
- read -r DST_MIN DST_MAX <<< $(parse_ports $DST_PORT)
- validate_ports $DST_MIN $DST_MAX
+ read -r UDP_DST_MIN UDP_DST_MAX <<< $(parse_ports $DST_PORT)
+ validate_ports $UDP_DST_MIN $UDP_DST_MAX
fi
# Base Config
@@ -56,8 +56,8 @@ for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do
if [ -n "$DST_PORT" ]; then
# Single destination port or random port range
pg_set $dev "flag UDPDST_RND"
- pg_set $dev "udp_dst_min $DST_MIN"
- pg_set $dev "udp_dst_max $DST_MAX"
+ pg_set $dev "udp_dst_min $UDP_DST_MIN"
+ pg_set $dev "udp_dst_max $UDP_DST_MAX"
fi
# Setup source IP-addresses based on thread number
diff --git a/samples/pktgen/pktgen_sample06_numa_awared_queue_irq_affinity.sh b/samples/pktgen/pktgen_sample06_numa_awared_queue_irq_affinity.sh
index 97f0266c0356..755e662183f1 100755
--- a/samples/pktgen/pktgen_sample06_numa_awared_queue_irq_affinity.sh
+++ b/samples/pktgen/pktgen_sample06_numa_awared_queue_irq_affinity.sh
@@ -20,8 +20,8 @@ DELAY="0" # Zero means max speed
[ -z "$CLONE_SKB" ] && CLONE_SKB="0"
# Flow variation random source port between min and max
-UDP_MIN=9
-UDP_MAX=109
+UDP_SRC_MIN=9
+UDP_SRC_MAX=109
node=`get_iface_node $DEV`
irq_array=(`get_iface_irqs $DEV`)
@@ -36,8 +36,8 @@ if [ -z "$DEST_IP" ]; then
fi
[ -z "$DST_MAC" ] && DST_MAC="90:e2:ba:ff:ff:ff"
if [ -n "$DST_PORT" ]; then
- read -r DST_MIN DST_MAX <<< $(parse_ports $DST_PORT)
- validate_ports $DST_MIN $DST_MAX
+ read -r UDP_DST_MIN UDP_DST_MAX <<< $(parse_ports $DST_PORT)
+ validate_ports $UDP_DST_MIN $UDP_DST_MAX
fi
# General cleanup everything since last run
@@ -84,14 +84,14 @@ for ((i = 0; i < $THREADS; i++)); do
if [ -n "$DST_PORT" ]; then
# Single destination port or random port range
pg_set $dev "flag UDPDST_RND"
- pg_set $dev "udp_dst_min $DST_MIN"
- pg_set $dev "udp_dst_max $DST_MAX"
+ pg_set $dev "udp_dst_min $UDP_DST_MIN"
+ pg_set $dev "udp_dst_max $UDP_DST_MAX"
fi
# Setup random UDP port src range
pg_set $dev "flag UDPSRC_RND"
- pg_set $dev "udp_src_min $UDP_MIN"
- pg_set $dev "udp_src_max $UDP_MAX"
+ pg_set $dev "udp_src_min $UDP_SRC_MIN"
+ pg_set $dev "udp_src_max $UDP_SRC_MAX"
done
# start_run
--
2.20.1
^ permalink raw reply related
* Re: [PATCH net] ip6_gre: fix a dst leak in ip6erspan_tunnel_xmit
From: William Tu @ 2019-09-14 15:12 UTC (permalink / raw)
To: Xin Long; +Cc: network dev, David Miller
In-Reply-To: <1bfbf329c5b3649a6c6362350a0d609ff184deba.1568367947.git.lucien.xin@gmail.com>
On Fri, Sep 13, 2019 at 2:45 AM Xin Long <lucien.xin@gmail.com> wrote:
>
> In ip6erspan_tunnel_xmit(), if the skb will not be sent out, it has to
> be freed on the tx_err path. Otherwise when deleting a netns, it would
> cause dst/dev to leak, and dmesg shows:
>
> unregister_netdevice: waiting for lo to become free. Usage count = 1
>
> Fixes: ef7baf5e083c ("ip6_gre: add ip6 erspan collect_md mode")
> Signed-off-by: Xin Long <lucien.xin@gmail.com>
> ---
LGTM, thanks for the fix!
Acked-by: William Tu <u9012063@gmail.com>
> net/ipv6/ip6_gre.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
> index dd2d0b96..d5779d6 100644
> --- a/net/ipv6/ip6_gre.c
> +++ b/net/ipv6/ip6_gre.c
> @@ -968,7 +968,7 @@ static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,
> if (unlikely(!tun_info ||
> !(tun_info->mode & IP_TUNNEL_INFO_TX) ||
> ip_tunnel_info_af(tun_info) != AF_INET6))
> - return -EINVAL;
> + goto tx_err;
>
> key = &tun_info->key;
> memset(&fl6, 0, sizeof(fl6));
> --
> 2.1.0
>
^ permalink raw reply
* Re: [PATCH net-next] net: phylink: clarify where phylink should be used
From: Andrew Lunn @ 2019-09-14 15:08 UTC (permalink / raw)
To: Russell King
Cc: David S. Miller, Florian Fainelli, Heiner Kallweit,
Jonathan Corbet, netdev, linux-doc
In-Reply-To: <E1i94b6-0008TL-IR@rmk-PC.armlinux.org.uk>
On Sat, Sep 14, 2019 at 10:44:04AM +0100, Russell King wrote:
> Update the phylink documentation to make it clear that phylink is
> designed to be used on the MAC facing side of the link, rather than
> between a SFP and PHY.
>
> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply
* Re: [v2 2/3] samples: pktgen: add helper functions for IP(v4/v6) CIDR parsing
From: Daniel T. Lee @ 2019-09-14 15:02 UTC (permalink / raw)
To: Jesper Dangaard Brouer; +Cc: David S . Miller, netdev
In-Reply-To: <20190913144305.4bf38c04@carbon>
On Fri, Sep 13, 2019 at 9:43 PM Jesper Dangaard Brouer
<brouer@redhat.com> wrote:
>
> On Thu, 12 Sep 2019 03:48:06 +0900
> "Daniel T. Lee" <danieltimlee@gmail.com> wrote:
>
> > This commit adds CIDR parsing and IP validate helper function to parse
> > single IP or range of IP with CIDR. (e.g. 198.18.0.0/15)
> >
> > Helpers will be used in prior to set target address in samples/pktgen.
> >
> > Signed-off-by: Daniel T. Lee <danieltimlee@gmail.com>
> > ---
> > samples/pktgen/functions.sh | 122 ++++++++++++++++++++++++++++++++++++
> > 1 file changed, 122 insertions(+)
> >
> > diff --git a/samples/pktgen/functions.sh b/samples/pktgen/functions.sh
> > index 4af4046d71be..8be5a6b6c097 100644
> [...]
>
> > +# Given a single IP(v4/v6) or CIDR, return minimum and maximum IP addr.
> > +function parse_addr()
> > +{
> > + # check function is called with (funcname)6
> > + [[ ${FUNCNAME[1]: -1} == 6 ]] && local IP6=6
> > + local bitlen=$[ IP6 ? 128 : 32 ]
> > + local octet=$[ IP6 ? 16 : 8 ]
> > +
> > + local addr=$1
> > + local net prefix
> > + local min_ip max_ip
> > +
> > + IFS='/' read net prefix <<< $addr
> > + [[ $IP6 ]] && net=$(extend_addr6 $net)
> > + validate_addr$IP6 $net
> > +
> > + if [[ $prefix -gt $bitlen ]]; then
> > + err 5 "Invalid prefix: $prefix"
> > + elif [[ -z $prefix ]]; then
> > + min_ip=$net
> > + max_ip=$net
> > + else
> > + # defining array for converting Decimal 2 Binary
> > + # 00000000 00000001 00000010 00000011 00000100 ...
> > + local d2b='{0..1}{0..1}{0..1}{0..1}{0..1}{0..1}{0..1}{0..1}'
> > + [[ $IP6 ]] && d2b+=$d2b
> > + eval local D2B=($d2b)
>
> I must say this is a rather cool shell/bash trick to use an array for
> converting decimal numbers into binary.
>
Thank you for the compliment and for the detailed review.
> > +
> > + local shift=$[ bitlen-prefix ]
>
> Using a variable named 'shift' is slightly problematic for shell/bash
> code. It works, but it is just confusing.
>
> > + local min_mask max_mask
> > + local min max
> > + local ip_bit
> > + local ip sep
> > +
> > + # set separator for each IP(v4/v6)
> > + [[ $IP6 ]] && sep=: || sep=.
> > + IFS=$sep read -ra ip <<< $net
> > +
> > + min_mask="$(printf '1%.s' $(seq $prefix))$(printf '0%.s' $(seq $shift))"
> > + max_mask="$(printf '0%.s' $(seq $prefix))$(printf '1%.s' $(seq $shift))"
>
> Also a surprising shell trick to get binary numbers out of a prefix number.
>
> > +
> > + # calculate min/max ip with &,| operator
> > + for i in "${!ip[@]}"; do
> > + digit=$[ IP6 ? 16#${ip[$i]} : ${ip[$i]} ]
> > + ip_bit=${D2B[$digit]}
> > +
> > + idx=$[ octet*i ]
> > + min[$i]=$[ 2#$ip_bit & 2#${min_mask:$idx:$octet} ]
> > + max[$i]=$[ 2#$ip_bit | 2#${max_mask:$idx:$octet} ]
> > + [[ $IP6 ]] && { min[$i]=$(printf '%X' ${min[$i]});
> > + max[$i]=$(printf '%X' ${max[$i]}); }
> > + done
> > +
> > + min_ip=$(IFS=$sep; echo "${min[*]}")
> > + max_ip=$(IFS=$sep; echo "${max[*]}")
> > + fi
> > +
> > + echo $min_ip $max_ip
> > +}
>
> If you just fix the variable name 'shift' to something else, then I'm
> happy with this patch.
>
> Again, I'm very impressed with your shell/bash skills, I were certainly
> challenged when reviewing this :-)
>
I'll change the variable name to 'remain'.
Once again, I really appreciate your time and effort for the review.
Thank you.
Best,
Daniel
> --
> Best regards,
> Jesper Dangaard Brouer
> MSc.CS, Principal Kernel Engineer at Red Hat
> LinkedIn: http://www.linkedin.com/in/brouer
^ permalink raw reply
* Re: net: phy: micrel KSZ9031 ifdown ifup issue
From: Andrew Lunn @ 2019-09-14 14:54 UTC (permalink / raw)
To: Paul Thomas; +Cc: Florian Fainelli, Heiner Kallweit, David S. Miller, netdev
In-Reply-To: <CAD56B7fEGm439yn_MaWxbyfMUEtfjbijH8as99Xh2N+6bUQEGQ@mail.gmail.com>
On Fri, Sep 13, 2019 at 10:42:38AM -0400, Paul Thomas wrote:
> Hello,
>
> I think I'm seeing an issue with the PHY hardware or PHY driver. What
> happens is sometimes (but not always) when I do 'ip link set eth0
> down' followed by 'ip link set eth0 up' I don't ever see an
> auto-negotiation again. LEDs don't come on, ethtool reports 'Link
> detected: no'. Even physically unplugging and plugging the network
> cable doesn't bring it back. I have to do a reboot to get the
> networking back.
>
> When the networking is started I don't see any issue forcing
> negotiations by unplugging and plugging the cable. I get standard
> messages like this all day long:
> [ 21.031793] 003: macb ff0b0000.ethernet eth0: link down
> [ 26.142835] 003: macb ff0b0000.ethernet eth0: link up (1000/Full)
>
> One thing that makes me think this is the PHY is that we have another
> Ethernet port using the DP83867 PHY and I can always do ifdown/ifup
> with it.
>
> This is using a 5.2.10 kernel on arm64 zynqmp platform with the macb driver.
>
> Is this something anyone else has seen? I know there is some Errata
> with this part, but I'm hoping there is something to fix or work
> around this. Any thoughts on where to look or add debugging would
> appreciated.
Hi Paul
Are you using interrupts, or polling? If interrupts, try polling?
Seems unlikely, but you could be missing an interrupt.
There is a fix from Antoine Tenart which suggests asym pause can be an
issue? What pause setup are you using? But this is a known issue,
which 5.2 should have the fix for.
Andrew
^ permalink raw reply
* Re: [v2 3/3] samples: pktgen: allow to specify destination IP range (CIDR)
From: Daniel T. Lee @ 2019-09-14 14:51 UTC (permalink / raw)
To: Toke Høiland-Jørgensen
Cc: Jesper Dangaard Brouer, David S . Miller, netdev
In-Reply-To: <87ef0ks76q.fsf@toke.dk>
On Fri, Sep 13, 2019 at 9:37 PM Toke Høiland-Jørgensen <toke@redhat.com> wrote:
>
> Jesper Dangaard Brouer <brouer@redhat.com> writes:
>
> > On Thu, 12 Sep 2019 03:48:07 +0900
> > "Daniel T. Lee" <danieltimlee@gmail.com> wrote:
> >
> >> diff --git a/samples/pktgen/pktgen_sample01_simple.sh b/samples/pktgen/pktgen_sample01_simple.sh
> >> index 063ec0998906..08995fa70025 100755
> >> --- a/samples/pktgen/pktgen_sample01_simple.sh
> >> +++ b/samples/pktgen/pktgen_sample01_simple.sh
> >> @@ -22,6 +22,7 @@ fi
> >> # Example enforce param "-m" for dst_mac
> >> [ -z "$DST_MAC" ] && usage && err 2 "Must specify -m dst_mac"
> >> [ -z "$COUNT" ] && COUNT="100000" # Zero means indefinitely
> >> +[ -n "$DEST_IP" ] && read -r DST_MIN DST_MAX <<< $(parse_addr${IP6} $DEST_IP)
> >
> > The way the function "parse_addr" is called, in case of errors the
> > 'err()' function is called inside, but it will not stop the program
> > flow. Instead that function will "only" echo the "ERROR", but program
> > flow continues (even-thought 'err()' uses exit $exitcode).
> >
> > Maybe it is not solveable to get the exit/$?/status out? (I've tried
> > different options, but didn't find a way).
>
> `set -o errexit`? :)
>
I've just tested and Toke's solution works great!
It stops when the function gets error.
I'll update it to the next version.
Thanks for the review!
> -Toke
^ permalink raw reply
* Re: [PATCH] powerpc/kmcent2: update the ethernet devices' phy properties
From: Scott Wood @ 2019-09-14 14:29 UTC (permalink / raw)
To: Madalin-cristian Bucur, Valentin Longchamp
Cc: linuxppc-dev@lists.ozlabs.org, galak@kernel.crashing.org,
netdev@vger.kernel.org
In-Reply-To: <VI1PR04MB5567F47E3CAA778F96F25533ECA20@VI1PR04MB5567.eurprd04.prod.outlook.com>
On Thu, 2019-08-29 at 11:25 +0000, Madalin-cristian Bucur wrote:
> > -----Original Message-----
> > From: Scott Wood <oss@buserror.net>
> > Sent: Wednesday, August 28, 2019 7:19 AM
> > To: Valentin Longchamp <valentin@longchamp.me>; Madalin-cristian Bucur
> > <madalin.bucur@nxp.com>
> > Cc: linuxppc-dev@lists.ozlabs.org; galak@kernel.crashing.org;
> > netdev@vger.kernel.org
> > Subject: Re: [PATCH] powerpc/kmcent2: update the ethernet devices' phy
> > properties
> >
> > On Thu, 2019-08-08 at 23:09 +0200, Valentin Longchamp wrote:
> > > Le mar. 30 juil. 2019 à 11:44, Madalin-cristian Bucur
> > > <madalin.bucur@nxp.com> a écrit :
> > > >
> > > > > -----Original Message-----
> > > > >
> > > > > > Le dim. 14 juil. 2019 à 22:05, Valentin Longchamp
> > > > > > <valentin@longchamp.me> a écrit :
> > > > > > >
> > > > > > > Change all phy-connection-type properties to phy-mode that are
> > > > > > > better
> > > > > > > supported by the fman driver.
> > > > > > >
> > > > > > > Use the more readable fixed-link node for the 2 sgmii links.
> > > > > > >
> > > > > > > Change the RGMII link to rgmii-id as the clock delays are added
> >
> > by
> > > > > > > the
> > > > > > > phy.
> > > > > > >
> > > > > > > Signed-off-by: Valentin Longchamp <valentin@longchamp.me>
> > > > >
> > > > > I don't see any other uses of phy-mode in arch/powerpc/boot/dts/fsl,
> >
> > and
> > > > > I see
> > > > > lots of phy-connection-type with fman. Madalin, does this patch
> >
> > look
> > > > > OK?
> > > > >
> > > > > -Scott
> > > >
> > > > Hi,
> > > >
> > > > we are using "phy-connection-type" not "phy-mode" for the NXP (former
> > > > Freescale)
> > > > DPAA platforms. While the two seem to be interchangeable ("phy-mode"
> >
> > seems
> > > > to be
> > > > more recent, looking at the device tree bindings), the driver code in
> > > > Linux seems
> > > > to use one or the other, not both so one should stick with the variant
> >
> > the
> > > > driver
> > > > is using. To make things more complex, there may be dependencies in
> > > > bootloaders,
> > > > I see code in u-boot using only "phy-connection-type" or only "phy-
> >
> > mode".
> > > >
> > > > I'd leave "phy-connection-type" as is.
> > >
> > > So I have finally had time to have a look and now I understand what
> > > happens. You are right, there are bootloader dependencies: u-boot
> > > calls fdt_fixup_phy_connection() that somehow in our case adds (or
> > > changes if already in the device tree) the phy-connection-type
> > > property to a wrong value ! By having a phy-mode in the device tree,
> > > that is not changed by u-boot and by chance picked up by the kernel
> > > fman driver (of_get_phy_mode() ) over phy-connection-mode, the below
> > > patch fixes it for us.
> > >
> > > I agree with you, it's not correct to have both phy-connection-type
> > > and phy-mode. Ideally, u-boot on the board should be reworked so that
> > > it does not perform the above wrong fixup. However, in an "unfixed"
> > > .dtb (I have disabled fdt_fixup_phy_connection), the device tree in
> > > the end only has either phy-connection-type or phy-mode, according to
> > > what was chosen in the .dts file. And the fman driver works well with
> > > both (thanks to the call to of_get_phy_mode() ). I would therefore
> > > argue that even if all other DPAA platforms use phy-connection-type,
> > > phy-mode is valid as well. (Furthermore we already have hundreds of
> > > such boards in the field and we don't really support "remote" u-boot
> > > update, so the u-boot fix is going to be difficult for us to pull).
> > >
> > > Valentin
> >
> > Madalin, are you OK with the patch given this explanation?
> >
> > -Scott
> >
>
> Yes, I understand that it's the only option they have, given the inability
> to upgrade u-boot (this may prove to be an issue in the future, in other
> situations).
>
> Acked-by: Madalin Bucur <madalin.bucur@nxp.com>
Acked-by: Scott Wood <oss@buserror.net>
-Scott
^ permalink raw reply
* Re: [PATCH net-next v8 2/3] net: phy: add support for clause 37 auto-negotiation
From: Andrew Lunn @ 2019-09-14 14:17 UTC (permalink / raw)
To: Tao Ren
Cc: Florian Fainelli, Heiner Kallweit, David S . Miller,
Vladimir Oltean, Arun Parameswaran, Justin Chen, netdev,
linux-kernel, openbmc
In-Reply-To: <20190909204906.2191290-1-taoren@fb.com>
On Mon, Sep 09, 2019 at 01:49:06PM -0700, Tao Ren wrote:
> From: Heiner Kallweit <hkallweit1@gmail.com>
>
> This patch adds support for clause 37 1000Base-X auto-negotiation.
>
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
> Signed-off-by: Tao Ren <taoren@fb.com>
> Tested-by: René van Dorst <opensource@vdorst.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply
* Re: [PATCH v2 net-next 6/7] net: dsa: sja1105: Configure the Time-Aware Scheduler via tc-taprio offload
From: Vladimir Oltean @ 2019-09-14 13:40 UTC (permalink / raw)
To: kbuild test robot
Cc: kbuild-all, f.fainelli, vivien.didelot, andrew, davem,
vinicius.gomes, vedang.patel, richardcochran, weifeng.voon, jiri,
m-karicheri2, Jose.Abreu, ilias.apalodimas, jhs, xiyou.wangcong,
kurt.kanzenbach, joergen.andreasen, netdev
In-Reply-To: <201909141759.R0atrZ2e%lkp@intel.com>
On 14/09/2019, kbuild test robot <lkp@intel.com> wrote:
> Hi Vladimir,
>
> I love your patch! Yet something to improve:
>
> [auto build test ERROR on net-next/master]
>
> url:
> https://github.com/0day-ci/linux/commits/Vladimir-Oltean/tc-taprio-offload-for-SJA1105-DSA/20190914-154650
> config: i386-randconfig-b001-201936 (attached as .config)
> compiler: gcc-7 (Debian 7.4.0-11) 7.4.0
> reproduce:
> # save the attached .config to linux build tree
> make ARCH=i386
>
> If you fix the issue, kindly add following tag
> Reported-by: kbuild test robot <lkp@intel.com>
>
> All error/warnings (new ones prefixed by >>):
>
> In file included from drivers/net/dsa/sja1105/sja1105.h:23:0,
> from drivers/net/dsa/sja1105/sja1105_spi.c:8:
>>> drivers/net/dsa/sja1105/sja1105_tas.h:38:45: warning: 'struct
>>> sja1105_private' declared inside parameter list will not be visible
>>> outside of this definition or declaration
Oops, I didn't realize I need the "struct sja1105_private;"
forward-declaration even if CONFIG_NET_DSA_SJA1105_TAS is not defined.
Never mind, I'll just make all prototypes take "struct dsa_switch *ds"
so the forward-declaration won't be needed at all. I'll send out a v3
soon.
> static inline void sja1105_tas_setup(struct sja1105_private *priv) { }
> ^~~~~~~~~~~~~~~
> drivers/net/dsa/sja1105/sja1105_tas.h:40:48: warning: 'struct
> sja1105_private' declared inside parameter list will not be visible outside
> of this definition or declaration
> static inline void sja1105_tas_teardown(struct sja1105_private *priv) {
> }
> ^~~~~~~~~~~~~~~
> --
> In file included from drivers/net/dsa/sja1105/sja1105.h:23:0,
> from drivers/net/dsa/sja1105/sja1105_main.c:24:
>>> drivers/net/dsa/sja1105/sja1105_tas.h:38:45: warning: 'struct
>>> sja1105_private' declared inside parameter list will not be visible
>>> outside of this definition or declaration
> static inline void sja1105_tas_setup(struct sja1105_private *priv) { }
> ^~~~~~~~~~~~~~~
> drivers/net/dsa/sja1105/sja1105_tas.h:40:48: warning: 'struct
> sja1105_private' declared inside parameter list will not be visible outside
> of this definition or declaration
> static inline void sja1105_tas_teardown(struct sja1105_private *priv) {
> }
> ^~~~~~~~~~~~~~~
> drivers/net/dsa/sja1105/sja1105_main.c: In function 'sja1105_teardown':
>>> drivers/net/dsa/sja1105/sja1105_main.c:1731:23: error: passing argument 1
>>> of 'sja1105_tas_teardown' from incompatible pointer type
>>> [-Werror=incompatible-pointer-types]
> sja1105_tas_teardown(priv);
> ^~~~
> In file included from drivers/net/dsa/sja1105/sja1105.h:23:0,
> from drivers/net/dsa/sja1105/sja1105_main.c:24:
> drivers/net/dsa/sja1105/sja1105_tas.h:40:20: note: expected 'struct
> sja1105_private *' but argument is of type 'struct sja1105_private *'
> static inline void sja1105_tas_teardown(struct sja1105_private *priv) {
> }
> ^~~~~~~~~~~~~~~~~~~~
> drivers/net/dsa/sja1105/sja1105_main.c: In function 'sja1105_probe':
>>> drivers/net/dsa/sja1105/sja1105_main.c:2215:20: error: passing argument 1
>>> of 'sja1105_tas_setup' from incompatible pointer type
>>> [-Werror=incompatible-pointer-types]
> sja1105_tas_setup(priv);
> ^~~~
> In file included from drivers/net/dsa/sja1105/sja1105.h:23:0,
> from drivers/net/dsa/sja1105/sja1105_main.c:24:
> drivers/net/dsa/sja1105/sja1105_tas.h:38:20: note: expected 'struct
> sja1105_private *' but argument is of type 'struct sja1105_private *'
> static inline void sja1105_tas_setup(struct sja1105_private *priv) { }
> ^~~~~~~~~~~~~~~~~
> cc1: some warnings being treated as errors
>
> vim +/sja1105_tas_teardown +1731 drivers/net/dsa/sja1105/sja1105_main.c
>
> 1726
> 1727 static void sja1105_teardown(struct dsa_switch *ds)
> 1728 {
> 1729 struct sja1105_private *priv = ds->priv;
> 1730
>> 1731 sja1105_tas_teardown(priv);
> 1732 cancel_work_sync(&priv->tagger_data.rxtstamp_work);
> 1733 skb_queue_purge(&priv->tagger_data.skb_rxtstamp_queue);
> 1734 sja1105_ptp_clock_unregister(priv);
> 1735 sja1105_static_config_free(&priv->static_config);
> 1736 }
> 1737
>
> ---
> 0-DAY kernel test infrastructure Open Source Technology
> Center
> https://lists.01.org/pipermail/kbuild-all Intel
> Corporation
>
Thanks,
-Vladimir
^ permalink raw reply
* Re: pull-request: wireless-drivers-next 2019-09-14
From: David Miller @ 2019-09-14 13:08 UTC (permalink / raw)
To: kvalo; +Cc: linux-wireless, netdev, linux-kernel
In-Reply-To: <87r24jchgv.fsf@kamboji.qca.qualcomm.com>
From: Kalle Valo <kvalo@codeaurora.org>
Date: Sat, 14 Sep 2019 13:14:40 +0300
> here's a pull request to net-next tree for v5.4, more info below. Please
> let me know if there are any problems.
Pulled, thanks Kalle.
^ permalink raw reply
* pull-request: wireless-drivers-next 2019-09-14
From: Kalle Valo @ 2019-09-14 10:14 UTC (permalink / raw)
To: David Miller; +Cc: linux-wireless, netdev, linux-kernel
Hi Dave,
here's a pull request to net-next tree for v5.4, more info below. Please
let me know if there are any problems.
Kalle
The following changes since commit 172ca8308b0517ca2522a8c885755fd5c20294e7:
cxgb4: Fix spelling typos (2019-09-12 12:50:56 +0100)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/kvalo/wireless-drivers-next.git tags/wireless-drivers-next-for-davem-2019-09-14
for you to fetch changes up to f9e568754562e0f506e12aa899c378b4155080e9:
Merge ath-next from git://git.kernel.org/pub/scm/linux/kernel/git/kvalo/ath.git (2019-09-13 18:15:58 +0300)
----------------------------------------------------------------
wireless-drivers-next patches for 5.4
Last set of patches for 5.4. wil6210 and rtw88 being most active this
time, but ath9k also having a new module to load devices without
EEPROM.
Major changes:
wil6210
* add support for Enhanced Directional Multi-Gigabit (EDMG) channels 9-11
* add debugfs file to show PCM ring content
* report boottime_ns in scan results
ath9k
* add a separate loader for AR92XX (and older) pci(e) without eeprom
brcmfmac
* use the same wiphy after PCIe reset to not confuse the user space
rtw88
* enable interrupt migration
* enable AMSDU in AMPDU aggregation
* report RX power for each antenna
* enable to DPK and IQK calibration methods to improve performance
----------------------------------------------------------------
Ahmad Masri (1):
wil6210: fix PTK re-key race
Alexei Avshalom Lazar (2):
wil6210: Add EDMG channel support
wil6210: verify cid value is valid
Arnd Bergmann (1):
wcn36xx: use dynamic allocation for large variables
Ben Greear (1):
ath10k: free beacon buf later in vdev teardown
Chin-Yen Lee (1):
rtw88: 8822c: update pwr_seq to v13
Christian Lamparter (1):
ath9k: add loader for AR92XX (and older) pci(e)
Colin Ian King (4):
wil6210: fix wil_cid_valid with negative cid values
rtlwifi: rtl8821ae: make array static const and remove redundant assignment
bcma: make arrays pwr_info_offset and sprom_sizes static const, shrinks object size
ssb: make array pwr_info_offset static const, makes object smaller
Dedy Lansky (4):
wil6210: add wil_netif_rx() helper function
wil6210: add debugfs to show PMC ring content
wil6210: make sure DR bit is read before rest of the status message
wil6210: properly initialize discovery_expired_work
Hui Peng (1):
ath6kl: fix a NULL-ptr-deref bug in ath6kl_usb_alloc_urb_from_pipe()
Jia-Ju Bai (1):
ath6kl: Fix a possible null-pointer dereference in ath6kl_htc_mbox_create()
Kalle Valo (1):
Merge ath-next from git://git.kernel.org/.../kvalo/ath.git
Larry Finger (9):
rtlwifi: rtl8723ae: Remove unused GET_XXX and SET_XXX macros
rtlwifi: rtl8723ae: Replace local bit manipulation macros
rtlwifi: rtl8723ae: Convert macros that set descriptor
rtlwifi: rtl8723ae: Convert inline routines to little-endian words
rtlwifi: rtl8723be: Remove unused SET_XXX and GET_XXX macros
rtlwifi: rtl8723be: Replace local bit manipulation macros
rtlwifi: rtl8723be: Convert macros that set descriptor
rtlwifi: rtl8723be: Convert inline routines to little-endian words
rtlwifi: rtl8188ee: rtl8192ce: rtl8192de: rtl8723ae: rtl8821ae: Remove some unused bit manipulation macros
Lior David (3):
wil6210: use writel_relaxed in wil_debugfs_iomem_x32_set
wil6210: fix RX short frame check
wil6210: ignore reset errors for FW during probe
Lorenzo Bianconi (5):
ath9k: dynack: fix possible deadlock in ath_dynack_node_{de}init
ath9k: dyanck: introduce ath_dynack_set_timeout routine
ath9k: dynack: properly set last timeout timestamp in ath_dynack_reset
ath9k: dynack: set max timeout according to channel width
ath9k: dynack: set ackto to max timeout in ath_dynack_reset
Lubomir Rintel (1):
libertas: use mesh_wdev->ssid instead of priv->mesh_ssid
Luis Correia (1):
CREDITS: Update email address
Markus Elfring (1):
wil6210: Delete an unnecessary kfree() call in wil_tid_ampdu_rx_alloc()
Maya Erez (1):
wil6210: report boottime_ns in scan results
Michael Straube (3):
rtlwifi: rtl8192ce: replace _rtl92c_evm_db_to_percentage with generic version
rtlwifi: rtl8192cu: replace _rtl92c_evm_db_to_percentage with generic version
rtlwifi: rtl8192de: replace _rtl92d_evm_db_to_percentage with generic version
Navid Emamdoost (2):
ath9k_htc: release allocated buffer if timed out
ath9k: release allocated buffer if timed out
Nicolas Boichat (1):
ath10k: adjust skb length in ath10k_sdio_mbox_rx_packet
Rafał Miłecki (3):
brcmfmac: move "cfg80211_ops" pointer to another struct
brcmfmac: split brcmf_attach() and brcmf_detach() functions
brcmfmac: don't realloc wiphy during PCIe reset
Rakesh Pillai (1):
ath10k: fix channel info parsing for non tlv target
Tsang-Shian Lin (2):
rtw88: 8822c: Enable interrupt migration
rtw88: fix wrong rx power calculation
Tzu-En Huang (2):
rtw88: 8822c: add SW DPK support
rtw88: add dynamic cck pd mechanism
Wen Gong (2):
ath10k: add mic bytes for pmf management packet
ath10k: add reorder and change PN check logic for mac80211
Yan-Hsuan Chuang (5):
rtw88: 8822c: update PHY parameter to v38
rtw88: 8822c: add FW IQK support
rtw88: move IQK/DPK into phy_calibration
rtw88: allows to receive AMSDU in AMPDU
rtw88: report RX power for each antenna
YueHaibing (1):
carl9170: remove set but not used variable 'udev'
zhong jiang (2):
ath9k: Remove unneeded variable to store return value
brcmsmac: Use DIV_ROUND_CLOSEST directly to make it readable
CREDITS | 2 +-
drivers/bcma/sprom.c | 10 +-
drivers/net/wireless/ath/ath10k/htt_rx.c | 91 +-
drivers/net/wireless/ath/ath10k/htt_tx.c | 8 +
drivers/net/wireless/ath/ath10k/mac.c | 9 +-
drivers/net/wireless/ath/ath10k/sdio.c | 29 +-
drivers/net/wireless/ath/ath10k/wmi-tlv.c | 2 +-
drivers/net/wireless/ath/ath10k/wmi-tlv.h | 16 +
drivers/net/wireless/ath/ath10k/wmi.h | 8 -
drivers/net/wireless/ath/ath6kl/htc_mbox.c | 4 +-
drivers/net/wireless/ath/ath6kl/usb.c | 8 +
drivers/net/wireless/ath/ath9k/Kconfig | 16 +
drivers/net/wireless/ath/ath9k/Makefile | 2 +
.../net/wireless/ath/ath9k/ath9k_pci_owl_loader.c | 215 +
drivers/net/wireless/ath/ath9k/dynack.c | 101 +-
drivers/net/wireless/ath/ath9k/htc_drv_init.c | 4 +-
drivers/net/wireless/ath/ath9k/htc_hst.c | 3 +
drivers/net/wireless/ath/ath9k/wmi.c | 1 +
drivers/net/wireless/ath/carl9170/usb.c | 2 -
drivers/net/wireless/ath/wcn36xx/smd.c | 186 +-
drivers/net/wireless/ath/wil6210/cfg80211.c | 221 +-
drivers/net/wireless/ath/wil6210/debugfs.c | 16 +-
drivers/net/wireless/ath/wil6210/main.c | 4 +
drivers/net/wireless/ath/wil6210/netdev.c | 4 +
drivers/net/wireless/ath/wil6210/pcie_bus.c | 4 +-
drivers/net/wireless/ath/wil6210/pmc.c | 26 +
drivers/net/wireless/ath/wil6210/pmc.h | 1 +
drivers/net/wireless/ath/wil6210/rx_reorder.c | 1 -
drivers/net/wireless/ath/wil6210/txrx.c | 244 +-
drivers/net/wireless/ath/wil6210/txrx.h | 42 +
drivers/net/wireless/ath/wil6210/txrx_edma.c | 40 +-
drivers/net/wireless/ath/wil6210/txrx_edma.h | 12 +-
drivers/net/wireless/ath/wil6210/wil6210.h | 25 +-
drivers/net/wireless/ath/wil6210/wmi.c | 43 +-
drivers/net/wireless/ath/wil6210/wmi.h | 29 +-
.../net/wireless/broadcom/brcm80211/brcmfmac/bus.h | 4 +-
.../broadcom/brcm80211/brcmfmac/cfg80211.c | 1 -
.../broadcom/brcm80211/brcmfmac/cfg80211.h | 1 -
.../wireless/broadcom/brcm80211/brcmfmac/core.c | 42 +-
.../wireless/broadcom/brcm80211/brcmfmac/core.h | 1 +
.../wireless/broadcom/brcm80211/brcmfmac/pcie.c | 13 +-
.../wireless/broadcom/brcm80211/brcmfmac/sdio.c | 15 +-
.../net/wireless/broadcom/brcm80211/brcmfmac/usb.c | 34 +-
.../broadcom/brcm80211/brcmsmac/phy/phy_n.c | 14 +-
drivers/net/wireless/marvell/libertas/dev.h | 2 -
drivers/net/wireless/marvell/libertas/mesh.c | 31 +-
drivers/net/wireless/marvell/libertas/mesh.h | 3 +-
drivers/net/wireless/realtek/rtlwifi/base.h | 27 -
.../net/wireless/realtek/rtlwifi/rtl8188ee/def.h | 29 -
.../net/wireless/realtek/rtlwifi/rtl8192ce/def.h | 33 -
.../net/wireless/realtek/rtlwifi/rtl8192ce/trx.c | 23 +-
.../net/wireless/realtek/rtlwifi/rtl8192cu/mac.c | 18 +-
.../net/wireless/realtek/rtlwifi/rtl8192de/def.h | 31 -
.../net/wireless/realtek/rtlwifi/rtl8192de/trx.c | 18 +-
.../net/wireless/realtek/rtlwifi/rtl8723ae/def.h | 31 -
.../net/wireless/realtek/rtlwifi/rtl8723ae/trx.c | 212 +-
.../net/wireless/realtek/rtlwifi/rtl8723ae/trx.h | 794 +--
.../net/wireless/realtek/rtlwifi/rtl8723be/trx.c | 236 +-
.../net/wireless/realtek/rtlwifi/rtl8723be/trx.h | 718 +-
.../net/wireless/realtek/rtlwifi/rtl8821ae/def.h | 31 -
.../net/wireless/realtek/rtlwifi/rtl8821ae/phy.c | 4 +-
drivers/net/wireless/realtek/rtw88/coex.c | 2 +-
drivers/net/wireless/realtek/rtw88/coex.h | 1 +
drivers/net/wireless/realtek/rtw88/mac80211.c | 2 +-
drivers/net/wireless/realtek/rtw88/main.c | 1 +
drivers/net/wireless/realtek/rtw88/main.h | 56 +-
drivers/net/wireless/realtek/rtw88/phy.c | 145 +
drivers/net/wireless/realtek/rtw88/phy.h | 2 +
drivers/net/wireless/realtek/rtw88/reg.h | 17 +
drivers/net/wireless/realtek/rtw88/rtw8822b.c | 8 +-
drivers/net/wireless/realtek/rtw88/rtw8822c.c | 1188 +++-
drivers/net/wireless/realtek/rtw88/rtw8822c.h | 86 +
.../net/wireless/realtek/rtw88/rtw8822c_table.c | 6930 ++++++++++++++------
.../net/wireless/realtek/rtw88/rtw8822c_table.h | 3 +
drivers/net/wireless/realtek/rtw88/rx.c | 5 +
drivers/ssb/pci.c | 2 +-
76 files changed, 8589 insertions(+), 3654 deletions(-)
create mode 100644 drivers/net/wireless/ath/ath9k/ath9k_pci_owl_loader.c
^ permalink raw reply
* Re: [PATCH v2 net-next 6/7] net: dsa: sja1105: Configure the Time-Aware Scheduler via tc-taprio offload
From: kbuild test robot @ 2019-09-14 9:47 UTC (permalink / raw)
To: Vladimir Oltean
Cc: kbuild-all, f.fainelli, vivien.didelot, andrew, davem,
vinicius.gomes, vedang.patel, richardcochran, weifeng.voon, jiri,
m-karicheri2, Jose.Abreu, ilias.apalodimas, jhs, xiyou.wangcong,
kurt.kanzenbach, joergen.andreasen, netdev, Vladimir Oltean
In-Reply-To: <20190914011802.1602-7-olteanv@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 4173 bytes --]
Hi Vladimir,
I love your patch! Yet something to improve:
[auto build test ERROR on net-next/master]
url: https://github.com/0day-ci/linux/commits/Vladimir-Oltean/tc-taprio-offload-for-SJA1105-DSA/20190914-154650
config: i386-randconfig-b001-201936 (attached as .config)
compiler: gcc-7 (Debian 7.4.0-11) 7.4.0
reproduce:
# save the attached .config to linux build tree
make ARCH=i386
If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>
All error/warnings (new ones prefixed by >>):
In file included from drivers/net/dsa/sja1105/sja1105.h:23:0,
from drivers/net/dsa/sja1105/sja1105_spi.c:8:
>> drivers/net/dsa/sja1105/sja1105_tas.h:38:45: warning: 'struct sja1105_private' declared inside parameter list will not be visible outside of this definition or declaration
static inline void sja1105_tas_setup(struct sja1105_private *priv) { }
^~~~~~~~~~~~~~~
drivers/net/dsa/sja1105/sja1105_tas.h:40:48: warning: 'struct sja1105_private' declared inside parameter list will not be visible outside of this definition or declaration
static inline void sja1105_tas_teardown(struct sja1105_private *priv) { }
^~~~~~~~~~~~~~~
--
In file included from drivers/net/dsa/sja1105/sja1105.h:23:0,
from drivers/net/dsa/sja1105/sja1105_main.c:24:
>> drivers/net/dsa/sja1105/sja1105_tas.h:38:45: warning: 'struct sja1105_private' declared inside parameter list will not be visible outside of this definition or declaration
static inline void sja1105_tas_setup(struct sja1105_private *priv) { }
^~~~~~~~~~~~~~~
drivers/net/dsa/sja1105/sja1105_tas.h:40:48: warning: 'struct sja1105_private' declared inside parameter list will not be visible outside of this definition or declaration
static inline void sja1105_tas_teardown(struct sja1105_private *priv) { }
^~~~~~~~~~~~~~~
drivers/net/dsa/sja1105/sja1105_main.c: In function 'sja1105_teardown':
>> drivers/net/dsa/sja1105/sja1105_main.c:1731:23: error: passing argument 1 of 'sja1105_tas_teardown' from incompatible pointer type [-Werror=incompatible-pointer-types]
sja1105_tas_teardown(priv);
^~~~
In file included from drivers/net/dsa/sja1105/sja1105.h:23:0,
from drivers/net/dsa/sja1105/sja1105_main.c:24:
drivers/net/dsa/sja1105/sja1105_tas.h:40:20: note: expected 'struct sja1105_private *' but argument is of type 'struct sja1105_private *'
static inline void sja1105_tas_teardown(struct sja1105_private *priv) { }
^~~~~~~~~~~~~~~~~~~~
drivers/net/dsa/sja1105/sja1105_main.c: In function 'sja1105_probe':
>> drivers/net/dsa/sja1105/sja1105_main.c:2215:20: error: passing argument 1 of 'sja1105_tas_setup' from incompatible pointer type [-Werror=incompatible-pointer-types]
sja1105_tas_setup(priv);
^~~~
In file included from drivers/net/dsa/sja1105/sja1105.h:23:0,
from drivers/net/dsa/sja1105/sja1105_main.c:24:
drivers/net/dsa/sja1105/sja1105_tas.h:38:20: note: expected 'struct sja1105_private *' but argument is of type 'struct sja1105_private *'
static inline void sja1105_tas_setup(struct sja1105_private *priv) { }
^~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
vim +/sja1105_tas_teardown +1731 drivers/net/dsa/sja1105/sja1105_main.c
1726
1727 static void sja1105_teardown(struct dsa_switch *ds)
1728 {
1729 struct sja1105_private *priv = ds->priv;
1730
> 1731 sja1105_tas_teardown(priv);
1732 cancel_work_sync(&priv->tagger_data.rxtstamp_work);
1733 skb_queue_purge(&priv->tagger_data.skb_rxtstamp_queue);
1734 sja1105_ptp_clock_unregister(priv);
1735 sja1105_static_config_free(&priv->static_config);
1736 }
1737
---
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: 31701 bytes --]
^ permalink raw reply
* [PATCH net-next] net: phylink: clarify where phylink should be used
From: Russell King @ 2019-09-14 9:44 UTC (permalink / raw)
To: David S. Miller
Cc: Andrew Lunn, Florian Fainelli, Heiner Kallweit, Jonathan Corbet,
netdev, linux-doc
Update the phylink documentation to make it clear that phylink is
designed to be used on the MAC facing side of the link, rather than
between a SFP and PHY.
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
---
Documentation/networking/sfp-phylink.rst | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/Documentation/networking/sfp-phylink.rst b/Documentation/networking/sfp-phylink.rst
index 91446b431b70..a5e00a159d21 100644
--- a/Documentation/networking/sfp-phylink.rst
+++ b/Documentation/networking/sfp-phylink.rst
@@ -8,7 +8,8 @@ Overview
========
phylink is a mechanism to support hot-pluggable networking modules
-without needing to re-initialise the adapter on hot-plug events.
+directly connected to a MAC without needing to re-initialise the
+adapter on hot-plug events.
phylink supports conventional phylib-based setups, fixed link setups
and SFP (Small Formfactor Pluggable) modules at present.
--
2.7.4
^ permalink raw reply related
* Здравствуйте! Вас интересуют клиентские базы данных?
From: netdev @ 2019-09-13 19:22 UTC (permalink / raw)
To: netdev
Здравствуйте! Вас интересуют клиентские базы данных?
^ permalink raw reply
* Re: SFP support with RGMII MAC via RGMII to SERDES/SGMII PHY?
From: Russell King - ARM Linux admin @ 2019-09-14 8:48 UTC (permalink / raw)
To: Florian Fainelli; +Cc: George McCollister, netdev, Andrew Lunn, Heiner Kallweit
In-Reply-To: <6cd331e5-4e50-d061-439a-f97417645497@gmail.com>
On Fri, Sep 13, 2019 at 08:31:18PM -0700, Florian Fainelli wrote:
> +Russell, Andrew, Heiner,
>
> On 9/13/2019 9:44 AM, George McCollister wrote:
> > Every example of phylink SFP support I've seen is using an Ethernet
> > MAC with native SGMII.
> > Can phylink facilitate support of Fiber and Copper SFP modules
> > connected to an RGMII MAC if all of the following are true?
>
> I don't think that use case has been presented before, but phylink
> sounds like the tool that should help solve it. From your description
> below, it sounds like all the pieces are there to support it. Is the
> Ethernet MAC driver upstream?
It has been presented, and it's something I've been trying to support
for the last couple of years - in fact, I have patches in my tree that
support a very similar scenario on the Macchiatobin with the 88x3310
PHYs.
> > 1) The MAC is connected via RGMII to a transceiver/PHY (such as
> > Marvell 88E1512) which then connects to the SFP via SERDER/SGMII. If
> > you want to see a block diagram it's the first one here:
> > https://www.marvell.com/transceivers/assets/Alaska_88E1512-001_product_brief.pdf
As mentioned above, this is no different from the Macchiatobin,
where we have:
.-------- RJ45
MAC ---- 88x3310 PHY
`-------- SFP+
except instead of the MAC to PHY link being 10GBASE-R, it's RGMII,
and the PHY to SFP+ link is 10GBASE-R instead of 1000BASE-X.
Note that you're abusing the term "SGMII". SGMII is a Cisco
modification of the IEEE 802.3 1000BASE-X protocol. Fiber SFPs
exclusively use 1000BASE-X protocol. However, some copper SFPs
(with a RJ45) do use SGMII.
> > 2) The 1G Ethernet driver has been converted to use phylink.
This is not necessary for this scenario. The PHY driver needs to
be updated to know about SFP though.
See:
http://git.armlinux.org.uk/cgit/linux-arm.git/commit/?h=phy&id=ece56785ee0e9df40dc823fdc39ee74b4a7cd1c4
as an example of the 88x3310 supporting a SFP+ cage. This patch is
also necessary:
http://git.armlinux.org.uk/cgit/linux-arm.git/commit/?h=phy&id=ef2d699397ca28c7f89e01cc9e5037989096a990
and if anything is going to stand in the way of progress on this, it
is likely to be that patch. I'll be attempting to post these after
the next merge window (i.o.w. probably posting them in three weeks
time.)
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up
According to speedtest.net: 11.9Mbps down 500kbps up
^ permalink raw reply
* [PATCH] vhost: Fix compile time error
From: Guenter Roeck @ 2019-09-14 8:44 UTC (permalink / raw)
To: Michael S . Tsirkin
Cc: Jason Wang, kvm, virtualization, netdev, linux-kernel,
Greg Kroah-Hartman, Linus Torvalds, Guenter Roeck
Building vhost on 32-bit targets results in the following error.
drivers/vhost/vhost.c: In function 'translate_desc':
include/linux/compiler.h:549:38: error:
call to '__compiletime_assert_1879' declared with attribute error:
BUILD_BUG_ON failed: sizeof(_s) > sizeof(long)
Fixes: a89db445fbd7 ("vhost: block speculation of translated descriptors")
Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: Jason Wang <jasowang@redhat.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
drivers/vhost/vhost.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index acabf20b069e..102a0c877007 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -2074,7 +2074,7 @@ static int translate_desc(struct vhost_virtqueue *vq, u64 addr, u32 len,
_iov->iov_base = (void __user *)
((unsigned long)node->userspace_addr +
array_index_nospec((unsigned long)(addr - node->start),
- node->size));
+ (unsigned long)node->size));
s += size;
addr += size;
++ret;
--
2.7.4
^ permalink raw reply related
* Re: [PATCH 1/7] net/dsa: configure autoneg for CPU port
From: kbuild test robot @ 2019-09-14 7:16 UTC (permalink / raw)
To: Robert Beckett
Cc: kbuild-all, netdev, Robert Beckett, Andrew Lunn, Vivien Didelot,
Florian Fainelli, David S. Miller
In-Reply-To: <20190910154238.9155-2-bob.beckett@collabora.com>
Hi Robert,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on linus/master]
[cannot apply to v5.3-rc8 next-20190904]
[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/Robert-Beckett/net-dsa-mv88e6xxx-features-to-handle-network-storms/20190911-142233
reproduce:
# apt-get install sparse
# sparse version: v0.6.1-rc1-7-g2b96cd8-dirty
make ARCH=x86_64 allmodconfig
make C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__'
If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>
sparse warnings: (new ones prefixed by >>)
include/linux/sched.h:609:43: sparse: sparse: bad integer constant expression
include/linux/sched.h:609:73: sparse: sparse: invalid named zero-width bitfield `value'
include/linux/sched.h:610:43: sparse: sparse: bad integer constant expression
include/linux/sched.h:610:67: sparse: sparse: invalid named zero-width bitfield `bucket_id'
>> net/dsa/port.c:541:55: sparse: sparse: incompatible types for operation (|)
>> net/dsa/port.c:541:55: sparse: left side has type unsigned long *
>> net/dsa/port.c:541:55: sparse: right side has type unsigned long
vim +541 net/dsa/port.c
525
526 static int dsa_port_setup_phy_of(struct dsa_port *dp, bool enable)
527 {
528 struct dsa_switch *ds = dp->ds;
529 struct phy_device *phydev;
530 int port = dp->index;
531 int err = 0;
532
533 phydev = dsa_port_get_phy_device(dp);
534 if (!phydev)
535 return 0;
536
537 if (IS_ERR(phydev))
538 return PTR_ERR(phydev);
539
540 if (enable) {
> 541 phydev->supported = PHY_GBIT_FEATURES | SUPPORTED_MII |
542 SUPPORTED_AUI | SUPPORTED_FIBRE |
543 SUPPORTED_BNC | SUPPORTED_Pause |
544 SUPPORTED_Asym_Pause;
545 phydev->advertising = phydev->supported;
546
547 err = genphy_config_init(phydev);
548 if (err < 0)
549 goto err_put_dev;
550
551 err = genphy_config_aneg(phydev);
552 if (err < 0)
553 goto err_put_dev;
554
555 err = genphy_resume(phydev);
556 if (err < 0)
557 goto err_put_dev;
558
559 err = genphy_read_status(phydev);
560 if (err < 0)
561 goto err_put_dev;
562 } else {
563 err = genphy_suspend(phydev);
564 if (err < 0)
565 goto err_put_dev;
566 }
567
568 if (ds->ops->adjust_link)
569 ds->ops->adjust_link(ds, port, phydev);
570
571 dev_dbg(ds->dev, "enabled port's phy: %s", phydev_name(phydev));
572
573 err_put_dev:
574 put_device(&phydev->mdio.dev);
575 return err;
576 }
577
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
^ permalink raw reply
* [patch iproute2-next 2/2] devlink: extend reload command to add support for network namespace change
From: Jiri Pirko @ 2019-09-14 6:57 UTC (permalink / raw)
To: netdev
Cc: davem, idosch, dsahern, jakub.kicinski, tariqt, saeedm, kuznet,
yoshfuji, shuah, mlxsw
In-Reply-To: <20190914064608.26799-1-jiri@resnulli.us>
From: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
v3->v4:
- rebased on top of trap patches
- moved netns change to reload command instead of set
---
devlink/devlink.c | 31 +++++++++++++++++++++++++++----
include/uapi/linux/devlink.h | 4 ++++
man/man8/devlink-dev.8 | 12 ++++++++++++
3 files changed, 43 insertions(+), 4 deletions(-)
diff --git a/devlink/devlink.c b/devlink/devlink.c
index 8020d76dd7f7..6a28a7aa58a4 100644
--- a/devlink/devlink.c
+++ b/devlink/devlink.c
@@ -237,6 +237,7 @@ static void ifname_map_free(struct ifname_map *ifname_map)
#define DL_OPT_TRAP_NAME BIT(29)
#define DL_OPT_TRAP_ACTION BIT(30)
#define DL_OPT_TRAP_GROUP_NAME BIT(31)
+#define DL_OPT_NETNS BIT(32)
struct dl_opts {
uint64_t present; /* flags of present items */
@@ -276,6 +277,8 @@ struct dl_opts {
const char *trap_name;
const char *trap_group_name;
enum devlink_trap_action trap_action;
+ bool netns_is_pid;
+ uint32_t netns;
};
struct dl {
@@ -1412,6 +1415,22 @@ static int dl_argv_parse(struct dl *dl, uint64_t o_required,
if (err)
return err;
o_found |= DL_OPT_TRAP_ACTION;
+ } else if (dl_argv_match(dl, "netns") &&
+ (o_all & DL_OPT_NETNS)) {
+ const char *netns_str;
+
+ dl_arg_inc(dl);
+ err = dl_argv_str(dl, &netns_str);
+ if (err)
+ return err;
+ opts->netns = netns_get_fd(netns_str);
+ if (opts->netns < 0) {
+ err = dl_argv_uint32_t(dl, &opts->netns);
+ if (err)
+ return err;
+ opts->netns_is_pid = true;
+ }
+ o_found |= DL_OPT_NETNS;
} else {
pr_err("Unknown option \"%s\"\n", dl_argv(dl));
return -EINVAL;
@@ -1534,7 +1553,11 @@ static void dl_opts_put(struct nlmsghdr *nlh, struct dl *dl)
if (opts->present & DL_OPT_TRAP_ACTION)
mnl_attr_put_u8(nlh, DEVLINK_ATTR_TRAP_ACTION,
opts->trap_action);
-
+ if (opts->present & DL_OPT_NETNS)
+ mnl_attr_put_u32(nlh,
+ opts->netns_is_pid ? DEVLINK_ATTR_NETNS_PID :
+ DEVLINK_ATTR_NETNS_FD,
+ opts->netns);
}
static int dl_argv_parse_put(struct nlmsghdr *nlh, struct dl *dl,
@@ -1595,7 +1618,7 @@ static void cmd_dev_help(void)
pr_err(" devlink dev eswitch show DEV\n");
pr_err(" devlink dev param set DEV name PARAMETER value VALUE cmode { permanent | driverinit | runtime }\n");
pr_err(" devlink dev param show [DEV name PARAMETER]\n");
- pr_err(" devlink dev reload DEV\n");
+ pr_err(" devlink dev reload DEV [ netns { PID | NAME | ID } ]\n");
pr_err(" devlink dev info [ DEV ]\n");
pr_err(" devlink dev flash DEV file PATH [ component NAME ]\n");
}
@@ -2671,7 +2694,7 @@ static int cmd_dev_show(struct dl *dl)
static void cmd_dev_reload_help(void)
{
- pr_err("Usage: devlink dev reload [ DEV ]\n");
+ pr_err("Usage: devlink dev reload DEV [ netns { PID | NAME | ID } ]\n");
}
static int cmd_dev_reload(struct dl *dl)
@@ -2687,7 +2710,7 @@ static int cmd_dev_reload(struct dl *dl)
nlh = mnlg_msg_prepare(dl->nlg, DEVLINK_CMD_RELOAD,
NLM_F_REQUEST | NLM_F_ACK);
- err = dl_argv_parse_put(nlh, dl, DL_OPT_HANDLE, 0);
+ err = dl_argv_parse_put(nlh, dl, DL_OPT_HANDLE, DL_OPT_NETNS);
if (err)
return err;
diff --git a/include/uapi/linux/devlink.h b/include/uapi/linux/devlink.h
index d63cf9723f57..f2608cfc9706 100644
--- a/include/uapi/linux/devlink.h
+++ b/include/uapi/linux/devlink.h
@@ -412,6 +412,10 @@ enum devlink_attr {
DEVLINK_ATTR_RELOAD_FAILED, /* u8 0 or 1 */
+ DEVLINK_ATTR_NETNS_FD, /* u32 */
+ DEVLINK_ATTR_NETNS_PID, /* u32 */
+ DEVLINK_ATTR_NETNS_ID, /* u32 */
+
/* add new attributes above here, update the policy in devlink.c */
__DEVLINK_ATTR_MAX,
diff --git a/man/man8/devlink-dev.8 b/man/man8/devlink-dev.8
index 1804463b2321..0e1a5523fa7b 100644
--- a/man/man8/devlink-dev.8
+++ b/man/man8/devlink-dev.8
@@ -25,6 +25,13 @@ devlink-dev \- devlink device configuration
.ti -8
.B devlink dev help
+.ti -8
+.BR "devlink dev set"
+.IR DEV
+.RI "[ "
+.BI "netns { " PID " | " NAME " | " ID " }
+.RI "]"
+
.ti -8
.BR "devlink dev eswitch set"
.IR DEV
@@ -92,6 +99,11 @@ Format is:
.in +2
BUS_NAME/BUS_ADDRESS
+.SS devlink dev set - sets devlink device attributes
+
+.TP
+.BI "netns { " PID " | " NAME " | " ID " }
+
.SS devlink dev eswitch show - display devlink device eswitch attributes
.SS devlink dev eswitch set - sets devlink device eswitch attributes
--
2.21.0
^ permalink raw reply related
* [patch iproute2-next 1/2] devlink: introduce cmdline option to switch to a different namespace
From: Jiri Pirko @ 2019-09-14 6:57 UTC (permalink / raw)
To: netdev
Cc: davem, idosch, dsahern, jakub.kicinski, tariqt, saeedm, kuznet,
yoshfuji, shuah, mlxsw
In-Reply-To: <20190914064608.26799-1-jiri@resnulli.us>
From: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
v3->v4:
- rebased on top of trap patches
---
devlink/devlink.c | 12 ++++++++++--
man/man8/devlink.8 | 4 ++++
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/devlink/devlink.c b/devlink/devlink.c
index a1be8528c3c9..8020d76dd7f7 100644
--- a/devlink/devlink.c
+++ b/devlink/devlink.c
@@ -31,6 +31,7 @@
#include "mnlg.h"
#include "json_writer.h"
#include "utils.h"
+#include "namespace.h"
#define ESWITCH_MODE_LEGACY "legacy"
#define ESWITCH_MODE_SWITCHDEV "switchdev"
@@ -6748,7 +6749,7 @@ static int cmd_trap(struct dl *dl)
static void help(void)
{
pr_err("Usage: devlink [ OPTIONS ] OBJECT { COMMAND | help }\n"
- " devlink [ -f[orce] ] -b[atch] filename\n"
+ " devlink [ -f[orce] ] -b[atch] filename -N[etns] netnsname\n"
"where OBJECT := { dev | port | sb | monitor | dpipe | resource | region | health | trap }\n"
" OPTIONS := { -V[ersion] | -n[o-nice-names] | -j[son] | -p[retty] | -v[erbose] -s[tatistics] }\n");
}
@@ -6898,6 +6899,7 @@ int main(int argc, char **argv)
{ "pretty", no_argument, NULL, 'p' },
{ "verbose", no_argument, NULL, 'v' },
{ "statistics", no_argument, NULL, 's' },
+ { "Netns", required_argument, NULL, 'N' },
{ NULL, 0, NULL, 0 }
};
const char *batch_file = NULL;
@@ -6913,7 +6915,7 @@ int main(int argc, char **argv)
return EXIT_FAILURE;
}
- while ((opt = getopt_long(argc, argv, "Vfb:njpvs",
+ while ((opt = getopt_long(argc, argv, "Vfb:njpvsN:",
long_options, NULL)) >= 0) {
switch (opt) {
@@ -6942,6 +6944,12 @@ int main(int argc, char **argv)
case 's':
dl->stats = true;
break;
+ case 'N':
+ if (netns_switch(optarg)) {
+ ret = EXIT_FAILURE;
+ goto dl_free;
+ }
+ break;
default:
pr_err("Unknown option.\n");
help();
diff --git a/man/man8/devlink.8 b/man/man8/devlink.8
index 12d489440a3d..7f4eda568081 100644
--- a/man/man8/devlink.8
+++ b/man/man8/devlink.8
@@ -55,6 +55,10 @@ Turn on verbose output.
.BR "\-s" , " --statistics"
Output statistics.
+.TP
+.BR "\-N", " \-Netns " <NETNSNAME>
+Switches to the specified network namespace.
+
.SS
.I OBJECT
--
2.21.0
^ permalink raw reply related
* [patch iproute2-next] devlink: add reload failed indication
From: Jiri Pirko @ 2019-09-14 6:56 UTC (permalink / raw)
To: netdev; +Cc: dsahern, stephen, idosch, jakub.kicinski, tariqt, mlxsw
From: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
devlink/devlink.c | 22 +++++++++++++++-------
include/uapi/linux/devlink.h | 2 ++
2 files changed, 17 insertions(+), 7 deletions(-)
diff --git a/devlink/devlink.c b/devlink/devlink.c
index 2f084c020765..a1be8528c3c9 100644
--- a/devlink/devlink.c
+++ b/devlink/devlink.c
@@ -450,6 +450,7 @@ static const enum mnl_attr_data_type devlink_policy[DEVLINK_ATTR_MAX + 1] = {
[DEVLINK_ATTR_TRAP_GENERIC] = MNL_TYPE_FLAG,
[DEVLINK_ATTR_TRAP_METADATA] = MNL_TYPE_NESTED,
[DEVLINK_ATTR_TRAP_GROUP_NAME] = MNL_TYPE_STRING,
+ [DEVLINK_ATTR_RELOAD_FAILED] = MNL_TYPE_U8,
};
static const enum mnl_attr_data_type
@@ -1949,11 +1950,6 @@ static void pr_out_region_chunk(struct dl *dl, uint8_t *data, uint32_t len,
pr_out_region_chunk_end(dl);
}
-static void pr_out_dev(struct dl *dl, struct nlattr **tb)
-{
- pr_out_handle(dl, tb);
-}
-
static void pr_out_section_start(struct dl *dl, const char *name)
{
if (dl->json_output) {
@@ -2629,11 +2625,23 @@ static int cmd_dev_show_cb(const struct nlmsghdr *nlh, void *data)
struct dl *dl = data;
struct nlattr *tb[DEVLINK_ATTR_MAX + 1] = {};
struct genlmsghdr *genl = mnl_nlmsg_get_payload(nlh);
+ uint8_t reload_failed = 0;
mnl_attr_parse(nlh, sizeof(*genl), attr_cb, tb);
if (!tb[DEVLINK_ATTR_BUS_NAME] || !tb[DEVLINK_ATTR_DEV_NAME])
return MNL_CB_ERROR;
- pr_out_dev(dl, tb);
+
+ if (tb[DEVLINK_ATTR_RELOAD_FAILED])
+ reload_failed = mnl_attr_get_u8(tb[DEVLINK_ATTR_RELOAD_FAILED]);
+
+ if (reload_failed) {
+ __pr_out_handle_start(dl, tb, true, false);
+ pr_out_bool(dl, "reload_failed", true);
+ pr_out_handle_end(dl);
+ } else {
+ pr_out_handle(dl, tb);
+ }
+
return MNL_CB_OK;
}
@@ -3971,7 +3979,7 @@ static int cmd_mon_show_cb(const struct nlmsghdr *nlh, void *data)
if (!tb[DEVLINK_ATTR_BUS_NAME] || !tb[DEVLINK_ATTR_DEV_NAME])
return MNL_CB_ERROR;
pr_out_mon_header(genl->cmd);
- pr_out_dev(dl, tb);
+ pr_out_handle(dl, tb);
break;
case DEVLINK_CMD_PORT_GET: /* fall through */
case DEVLINK_CMD_PORT_SET: /* fall through */
diff --git a/include/uapi/linux/devlink.h b/include/uapi/linux/devlink.h
index 3fb683bee6ba..d63cf9723f57 100644
--- a/include/uapi/linux/devlink.h
+++ b/include/uapi/linux/devlink.h
@@ -410,6 +410,8 @@ enum devlink_attr {
DEVLINK_ATTR_TRAP_METADATA, /* nested */
DEVLINK_ATTR_TRAP_GROUP_NAME, /* string */
+ DEVLINK_ATTR_RELOAD_FAILED, /* u8 0 or 1 */
+
/* add new attributes above here, update the policy in devlink.c */
__DEVLINK_ATTR_MAX,
--
2.21.0
^ permalink raw reply related
* [patch net-next 10/15] netdevsim: add all ports in nsim_dev_create() and del them in destroy()
From: Jiri Pirko @ 2019-09-14 6:46 UTC (permalink / raw)
To: netdev
Cc: davem, idosch, dsahern, jakub.kicinski, tariqt, saeedm, kuznet,
yoshfuji, shuah, mlxsw
In-Reply-To: <20190914064608.26799-1-jiri@resnulli.us>
From: Jiri Pirko <jiri@mellanox.com>
Currently the probe/remove function does this separately. Put the
addition an deletion of ports into nsim_dev_create() and
nsim_dev_destroy().
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
drivers/net/netdevsim/dev.c | 175 +++++++++++++++++++-----------------
1 file changed, 93 insertions(+), 82 deletions(-)
diff --git a/drivers/net/netdevsim/dev.c b/drivers/net/netdevsim/dev.c
index d623501de3ea..65e02b933aa3 100644
--- a/drivers/net/netdevsim/dev.c
+++ b/drivers/net/netdevsim/dev.c
@@ -600,8 +600,92 @@ static const struct devlink_ops nsim_dev_devlink_ops = {
#define NSIM_DEV_MAX_MACS_DEFAULT 32
#define NSIM_DEV_TEST1_DEFAULT true
+static int __nsim_dev_port_add(struct nsim_dev *nsim_dev,
+ unsigned int port_index)
+{
+ struct nsim_dev_port *nsim_dev_port;
+ struct devlink_port *devlink_port;
+ int err;
+
+ nsim_dev_port = kzalloc(sizeof(*nsim_dev_port), GFP_KERNEL);
+ if (!nsim_dev_port)
+ return -ENOMEM;
+ nsim_dev_port->port_index = port_index;
+
+ devlink_port = &nsim_dev_port->devlink_port;
+ devlink_port_attrs_set(devlink_port, DEVLINK_PORT_FLAVOUR_PHYSICAL,
+ port_index + 1, 0, 0,
+ nsim_dev->switch_id.id,
+ nsim_dev->switch_id.id_len);
+ err = devlink_port_register(priv_to_devlink(nsim_dev), devlink_port,
+ port_index);
+ if (err)
+ goto err_port_free;
+
+ err = nsim_dev_port_debugfs_init(nsim_dev, nsim_dev_port);
+ if (err)
+ goto err_dl_port_unregister;
+
+ nsim_dev_port->ns = nsim_create(nsim_dev, nsim_dev_port);
+ if (IS_ERR(nsim_dev_port->ns)) {
+ err = PTR_ERR(nsim_dev_port->ns);
+ goto err_port_debugfs_exit;
+ }
+
+ devlink_port_type_eth_set(devlink_port, nsim_dev_port->ns->netdev);
+ list_add(&nsim_dev_port->list, &nsim_dev->port_list);
+
+ return 0;
+
+err_port_debugfs_exit:
+ nsim_dev_port_debugfs_exit(nsim_dev_port);
+err_dl_port_unregister:
+ devlink_port_unregister(devlink_port);
+err_port_free:
+ kfree(nsim_dev_port);
+ return err;
+}
+
+static void __nsim_dev_port_del(struct nsim_dev_port *nsim_dev_port)
+{
+ struct devlink_port *devlink_port = &nsim_dev_port->devlink_port;
+
+ list_del(&nsim_dev_port->list);
+ devlink_port_type_clear(devlink_port);
+ nsim_destroy(nsim_dev_port->ns);
+ nsim_dev_port_debugfs_exit(nsim_dev_port);
+ devlink_port_unregister(devlink_port);
+ kfree(nsim_dev_port);
+}
+
+static void nsim_dev_port_del_all(struct nsim_dev *nsim_dev)
+{
+ struct nsim_dev_port *nsim_dev_port, *tmp;
+
+ list_for_each_entry_safe(nsim_dev_port, tmp,
+ &nsim_dev->port_list, list)
+ __nsim_dev_port_del(nsim_dev_port);
+}
+
+static int nsim_dev_port_add_all(struct nsim_dev *nsim_dev,
+ unsigned int port_count)
+{
+ int i, err;
+
+ for (i = 0; i < port_count; i++) {
+ err = __nsim_dev_port_add(nsim_dev, i);
+ if (err)
+ goto err_port_del_all;
+ }
+ return 0;
+
+err_port_del_all:
+ nsim_dev_port_del_all(nsim_dev);
+ return err;
+}
+
static struct nsim_dev *
-nsim_dev_create(struct nsim_bus_dev *nsim_bus_dev, unsigned int port_count)
+nsim_dev_create(struct nsim_bus_dev *nsim_bus_dev)
{
struct nsim_dev *nsim_dev;
struct devlink *devlink;
@@ -656,9 +740,15 @@ nsim_dev_create(struct nsim_bus_dev *nsim_bus_dev, unsigned int port_count)
if (err)
goto err_debugfs_exit;
+ err = nsim_dev_port_add_all(nsim_dev, nsim_bus_dev->port_count);
+ if (err)
+ goto err_bpf_dev_exit;
+
devlink_params_publish(devlink);
return nsim_dev;
+err_bpf_dev_exit:
+ nsim_bpf_dev_exit(nsim_dev);
err_debugfs_exit:
nsim_dev_debugfs_exit(nsim_dev);
err_traps_exit:
@@ -683,6 +773,7 @@ static void nsim_dev_destroy(struct nsim_dev *nsim_dev)
{
struct devlink *devlink = priv_to_devlink(nsim_dev);
+ nsim_dev_port_del_all(nsim_dev);
nsim_bpf_dev_exit(nsim_dev);
nsim_dev_debugfs_exit(nsim_dev);
nsim_dev_traps_exit(devlink);
@@ -696,102 +787,22 @@ static void nsim_dev_destroy(struct nsim_dev *nsim_dev)
devlink_free(devlink);
}
-static int __nsim_dev_port_add(struct nsim_dev *nsim_dev,
- unsigned int port_index)
-{
- struct nsim_dev_port *nsim_dev_port;
- struct devlink_port *devlink_port;
- int err;
-
- nsim_dev_port = kzalloc(sizeof(*nsim_dev_port), GFP_KERNEL);
- if (!nsim_dev_port)
- return -ENOMEM;
- nsim_dev_port->port_index = port_index;
-
- devlink_port = &nsim_dev_port->devlink_port;
- devlink_port_attrs_set(devlink_port, DEVLINK_PORT_FLAVOUR_PHYSICAL,
- port_index + 1, 0, 0,
- nsim_dev->switch_id.id,
- nsim_dev->switch_id.id_len);
- err = devlink_port_register(priv_to_devlink(nsim_dev), devlink_port,
- port_index);
- if (err)
- goto err_port_free;
-
- err = nsim_dev_port_debugfs_init(nsim_dev, nsim_dev_port);
- if (err)
- goto err_dl_port_unregister;
-
- nsim_dev_port->ns = nsim_create(nsim_dev, nsim_dev_port);
- if (IS_ERR(nsim_dev_port->ns)) {
- err = PTR_ERR(nsim_dev_port->ns);
- goto err_port_debugfs_exit;
- }
-
- devlink_port_type_eth_set(devlink_port, nsim_dev_port->ns->netdev);
- list_add(&nsim_dev_port->list, &nsim_dev->port_list);
-
- return 0;
-
-err_port_debugfs_exit:
- nsim_dev_port_debugfs_exit(nsim_dev_port);
-err_dl_port_unregister:
- devlink_port_unregister(devlink_port);
-err_port_free:
- kfree(nsim_dev_port);
- return err;
-}
-
-static void __nsim_dev_port_del(struct nsim_dev_port *nsim_dev_port)
-{
- struct devlink_port *devlink_port = &nsim_dev_port->devlink_port;
-
- list_del(&nsim_dev_port->list);
- devlink_port_type_clear(devlink_port);
- nsim_destroy(nsim_dev_port->ns);
- nsim_dev_port_debugfs_exit(nsim_dev_port);
- devlink_port_unregister(devlink_port);
- kfree(nsim_dev_port);
-}
-
-static void nsim_dev_port_del_all(struct nsim_dev *nsim_dev)
-{
- struct nsim_dev_port *nsim_dev_port, *tmp;
-
- list_for_each_entry_safe(nsim_dev_port, tmp,
- &nsim_dev->port_list, list)
- __nsim_dev_port_del(nsim_dev_port);
-}
-
int nsim_dev_probe(struct nsim_bus_dev *nsim_bus_dev)
{
struct nsim_dev *nsim_dev;
- int i;
- int err;
- nsim_dev = nsim_dev_create(nsim_bus_dev, nsim_bus_dev->port_count);
+ nsim_dev = nsim_dev_create(nsim_bus_dev);
if (IS_ERR(nsim_dev))
return PTR_ERR(nsim_dev);
dev_set_drvdata(&nsim_bus_dev->dev, nsim_dev);
- for (i = 0; i < nsim_bus_dev->port_count; i++) {
- err = __nsim_dev_port_add(nsim_dev, i);
- if (err)
- goto err_port_del_all;
- }
return 0;
-
-err_port_del_all:
- nsim_dev_port_del_all(nsim_dev);
- nsim_dev_destroy(nsim_dev);
- return err;
}
void nsim_dev_remove(struct nsim_bus_dev *nsim_bus_dev)
{
struct nsim_dev *nsim_dev = dev_get_drvdata(&nsim_bus_dev->dev);
- nsim_dev_port_del_all(nsim_dev);
nsim_dev_destroy(nsim_dev);
}
--
2.21.0
^ permalink raw reply related
* [patch net-next 11/15] netdevsim: implement proper devlink reload
From: Jiri Pirko @ 2019-09-14 6:46 UTC (permalink / raw)
To: netdev
Cc: davem, idosch, dsahern, jakub.kicinski, tariqt, saeedm, kuznet,
yoshfuji, shuah, mlxsw
In-Reply-To: <20190914064608.26799-1-jiri@resnulli.us>
From: Jiri Pirko <jiri@mellanox.com>
During devlink reload, all driver objects should be reinstantiated with
the exception of devlink instance and devlink resources and params.
Move existing devlink_resource_size_get() calls into fib_create() just
before fib notifier is registered. Also, make sure that extack is
propagated down to fib_notifier_register() call.
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
drivers/net/netdevsim/dev.c | 137 +++++++++++++++++-------------
drivers/net/netdevsim/fib.c | 53 ++++++------
drivers/net/netdevsim/netdevsim.h | 8 +-
3 files changed, 109 insertions(+), 89 deletions(-)
diff --git a/drivers/net/netdevsim/dev.c b/drivers/net/netdevsim/dev.c
index 65e02b933aa3..ad376b443a34 100644
--- a/drivers/net/netdevsim/dev.c
+++ b/drivers/net/netdevsim/dev.c
@@ -466,37 +466,28 @@ static void nsim_dev_traps_exit(struct devlink *devlink)
kfree(nsim_dev->trap_data);
}
+static struct nsim_dev *
+nsim_dev_create(struct nsim_bus_dev *nsim_bus_dev, struct nsim_dev *nsim_dev,
+ struct netlink_ext_ack *extack);
+static void nsim_dev_destroy(struct nsim_dev *nsim_dev, bool reload);
+
static int nsim_dev_reload_down(struct devlink *devlink,
struct netlink_ext_ack *extack)
{
+ struct nsim_dev *nsim_dev = devlink_priv(devlink);
+
+ nsim_dev_destroy(nsim_dev, true);
return 0;
}
static int nsim_dev_reload_up(struct devlink *devlink,
struct netlink_ext_ack *extack)
+
{
struct nsim_dev *nsim_dev = devlink_priv(devlink);
- enum nsim_resource_id res_ids[] = {
- NSIM_RESOURCE_IPV4_FIB, NSIM_RESOURCE_IPV4_FIB_RULES,
- NSIM_RESOURCE_IPV6_FIB, NSIM_RESOURCE_IPV6_FIB_RULES
- };
- int i;
-
- for (i = 0; i < ARRAY_SIZE(res_ids); ++i) {
- int err;
- u64 val;
-
- err = devlink_resource_size_get(devlink, res_ids[i], &val);
- if (!err) {
- err = nsim_fib_set_max(nsim_dev->fib_data,
- res_ids[i], val, extack);
- if (err)
- return err;
- }
- }
- nsim_devlink_param_load_driverinit_values(devlink);
- return 0;
+ nsim_dev = nsim_dev_create(nsim_dev->nsim_bus_dev, nsim_dev, extack);
+ return PTR_ERR_OR_ZERO(nsim_dev);
}
#define NSIM_DEV_FLASH_SIZE 500000
@@ -685,15 +676,21 @@ static int nsim_dev_port_add_all(struct nsim_dev *nsim_dev,
}
static struct nsim_dev *
-nsim_dev_create(struct nsim_bus_dev *nsim_bus_dev)
+nsim_dev_create(struct nsim_bus_dev *nsim_bus_dev, struct nsim_dev *nsim_dev,
+ struct netlink_ext_ack *extack)
{
- struct nsim_dev *nsim_dev;
+ bool reload = !!nsim_dev;
struct devlink *devlink;
int err;
- devlink = devlink_alloc(&nsim_dev_devlink_ops, sizeof(*nsim_dev));
- if (!devlink)
- return ERR_PTR(-ENOMEM);
+ if (!reload) {
+ devlink = devlink_alloc(&nsim_dev_devlink_ops,
+ sizeof(*nsim_dev));
+ if (!devlink)
+ return ERR_PTR(-ENOMEM);
+ } else {
+ devlink = priv_to_devlink(nsim_dev);
+ }
nsim_dev = devlink_priv(devlink);
nsim_dev->nsim_bus_dev = nsim_bus_dev;
nsim_dev->switch_id.id_len = sizeof(nsim_dev->switch_id.id);
@@ -701,28 +698,35 @@ nsim_dev_create(struct nsim_bus_dev *nsim_bus_dev)
INIT_LIST_HEAD(&nsim_dev->port_list);
mutex_init(&nsim_dev->port_list_lock);
nsim_dev->fw_update_status = true;
- nsim_dev->max_macs = NSIM_DEV_MAX_MACS_DEFAULT;
- nsim_dev->test1 = NSIM_DEV_TEST1_DEFAULT;
- err = nsim_dev_resources_register(devlink);
- if (err)
- goto err_devlink_free;
+ if (!reload) {
+ err = nsim_dev_resources_register(devlink);
+ if (err)
+ goto err_devlink_free;
+ }
- nsim_dev->fib_data = nsim_fib_create(devlink);
+ nsim_dev->fib_data = nsim_fib_create(devlink, extack);
if (IS_ERR(nsim_dev->fib_data)) {
err = PTR_ERR(nsim_dev->fib_data);
goto err_resources_unregister;
}
- err = devlink_register(devlink, &nsim_bus_dev->dev);
- if (err)
- goto err_fib_destroy;
+ if (!reload) {
+ nsim_dev->max_macs = NSIM_DEV_MAX_MACS_DEFAULT;
+ nsim_dev->test1 = NSIM_DEV_TEST1_DEFAULT;
- err = devlink_params_register(devlink, nsim_devlink_params,
- ARRAY_SIZE(nsim_devlink_params));
- if (err)
- goto err_dl_unregister;
- nsim_devlink_set_params_init_values(nsim_dev, devlink);
+ err = devlink_register(devlink, &nsim_bus_dev->dev);
+ if (err)
+ goto err_fib_destroy;
+
+ err = devlink_params_register(devlink, nsim_devlink_params,
+ ARRAY_SIZE(nsim_devlink_params));
+ if (err)
+ goto err_dl_unregister;
+ nsim_devlink_set_params_init_values(nsim_dev, devlink);
+ } else {
+ nsim_devlink_param_load_driverinit_values(devlink);
+ }
err = nsim_dev_dummy_region_init(nsim_dev, devlink);
if (err)
@@ -744,7 +748,8 @@ nsim_dev_create(struct nsim_bus_dev *nsim_bus_dev)
if (err)
goto err_bpf_dev_exit;
- devlink_params_publish(devlink);
+ if (reload)
+ devlink_params_publish(devlink);
return nsim_dev;
err_bpf_dev_exit:
@@ -756,42 +761,54 @@ nsim_dev_create(struct nsim_bus_dev *nsim_bus_dev)
err_dummy_region_exit:
nsim_dev_dummy_region_exit(nsim_dev);
err_params_unregister:
- devlink_params_unregister(devlink, nsim_devlink_params,
- ARRAY_SIZE(nsim_devlink_params));
+ if (!reload) {
+ devlink_params_unregister(devlink, nsim_devlink_params,
+ ARRAY_SIZE(nsim_devlink_params));
err_dl_unregister:
- devlink_unregister(devlink);
+ devlink_unregister(devlink);
+ }
err_fib_destroy:
nsim_fib_destroy(devlink, nsim_dev->fib_data);
err_resources_unregister:
- devlink_resources_unregister(devlink, NULL);
+ if (!reload) {
+ devlink_resources_unregister(devlink, NULL);
err_devlink_free:
- devlink_free(devlink);
+ devlink_free(devlink);
+ }
return ERR_PTR(err);
}
-static void nsim_dev_destroy(struct nsim_dev *nsim_dev)
+static void nsim_dev_destroy(struct nsim_dev *nsim_dev, bool reload)
{
struct devlink *devlink = priv_to_devlink(nsim_dev);
- nsim_dev_port_del_all(nsim_dev);
- nsim_bpf_dev_exit(nsim_dev);
- nsim_dev_debugfs_exit(nsim_dev);
- nsim_dev_traps_exit(devlink);
- nsim_dev_dummy_region_exit(nsim_dev);
- devlink_params_unregister(devlink, nsim_devlink_params,
- ARRAY_SIZE(nsim_devlink_params));
- devlink_unregister(devlink);
- nsim_fib_destroy(devlink, nsim_dev->fib_data);
- devlink_resources_unregister(devlink, NULL);
- mutex_destroy(&nsim_dev->port_list_lock);
- devlink_free(devlink);
+ if (!devlink_is_reload_failed(devlink)) {
+ nsim_dev_port_del_all(nsim_dev);
+ nsim_bpf_dev_exit(nsim_dev);
+ nsim_dev_debugfs_exit(nsim_dev);
+ nsim_dev_traps_exit(devlink);
+ nsim_dev_dummy_region_exit(nsim_dev);
+ mutex_destroy(&nsim_dev->port_list_lock);
+ }
+ if (!reload) {
+ devlink_params_unregister(devlink, nsim_devlink_params,
+ ARRAY_SIZE(nsim_devlink_params));
+ devlink_unregister(devlink);
+ }
+ if (!devlink_is_reload_failed(devlink))
+ nsim_fib_destroy(devlink, nsim_dev->fib_data);
+ if (!reload) {
+ devlink_resources_unregister(devlink, NULL);
+ mutex_destroy(&nsim_dev->port_list_lock);
+ devlink_free(devlink);
+ }
}
int nsim_dev_probe(struct nsim_bus_dev *nsim_bus_dev)
{
struct nsim_dev *nsim_dev;
- nsim_dev = nsim_dev_create(nsim_bus_dev);
+ nsim_dev = nsim_dev_create(nsim_bus_dev, NULL, NULL);
if (IS_ERR(nsim_dev))
return PTR_ERR(nsim_dev);
dev_set_drvdata(&nsim_bus_dev->dev, nsim_dev);
@@ -803,7 +820,7 @@ void nsim_dev_remove(struct nsim_bus_dev *nsim_bus_dev)
{
struct nsim_dev *nsim_dev = dev_get_drvdata(&nsim_bus_dev->dev);
- nsim_dev_destroy(nsim_dev);
+ nsim_dev_destroy(nsim_dev, false);
}
static struct nsim_dev_port *
diff --git a/drivers/net/netdevsim/fib.c b/drivers/net/netdevsim/fib.c
index d2aeac0f4c2c..fdc682f3a09a 100644
--- a/drivers/net/netdevsim/fib.c
+++ b/drivers/net/netdevsim/fib.c
@@ -63,12 +63,10 @@ u64 nsim_fib_get_val(struct nsim_fib_data *fib_data,
return max ? entry->max : entry->num;
}
-int nsim_fib_set_max(struct nsim_fib_data *fib_data,
- enum nsim_resource_id res_id, u64 val,
- struct netlink_ext_ack *extack)
+static void nsim_fib_set_max(struct nsim_fib_data *fib_data,
+ enum nsim_resource_id res_id, u64 val)
{
struct nsim_fib_entry *entry;
- int err = 0;
switch (res_id) {
case NSIM_RESOURCE_IPV4_FIB:
@@ -84,20 +82,10 @@ int nsim_fib_set_max(struct nsim_fib_data *fib_data,
entry = &fib_data->ipv6.rules;
break;
default:
- return 0;
- }
-
- /* not allowing a new max to be less than curren occupancy
- * --> no means of evicting entries
- */
- if (val < entry->num) {
- NL_SET_ERR_MSG_MOD(extack, "New size is less than current occupancy");
- err = -EINVAL;
- } else {
- entry->max = val;
+ WARN_ON(1);
+ return;
}
-
- return err;
+ entry->max = val;
}
static int nsim_fib_rule_account(struct nsim_fib_entry *entry, bool add,
@@ -239,7 +227,28 @@ static u64 nsim_fib_ipv6_rules_res_occ_get(void *priv)
return nsim_fib_get_val(data, NSIM_RESOURCE_IPV6_FIB_RULES, false);
}
-struct nsim_fib_data *nsim_fib_create(struct devlink *devlink)
+static void nsim_fib_set_max_all(struct nsim_fib_data *data,
+ struct devlink *devlink)
+{
+ enum nsim_resource_id res_ids[] = {
+ NSIM_RESOURCE_IPV4_FIB, NSIM_RESOURCE_IPV4_FIB_RULES,
+ NSIM_RESOURCE_IPV6_FIB, NSIM_RESOURCE_IPV6_FIB_RULES
+ };
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(res_ids); i++) {
+ int err;
+ u64 val;
+
+ err = devlink_resource_size_get(devlink, res_ids[i], &val);
+ if (err)
+ val = (u64) -1;
+ nsim_fib_set_max(data, res_ids[i], val);
+ }
+}
+
+struct nsim_fib_data *nsim_fib_create(struct devlink *devlink,
+ struct netlink_ext_ack *extack)
{
struct nsim_fib_data *data;
int err;
@@ -248,15 +257,11 @@ struct nsim_fib_data *nsim_fib_create(struct devlink *devlink)
if (!data)
return ERR_PTR(-ENOMEM);
- data->ipv4.fib.max = (u64)-1;
- data->ipv4.rules.max = (u64)-1;
-
- data->ipv6.fib.max = (u64)-1;
- data->ipv6.rules.max = (u64)-1;
+ nsim_fib_set_max_all(data, devlink);
data->fib_nb.notifier_call = nsim_fib_event_nb;
err = register_fib_notifier(&init_net, &data->fib_nb,
- nsim_fib_dump_inconsistent, NULL);
+ nsim_fib_dump_inconsistent, extack);
if (err) {
pr_err("Failed to register fib notifier\n");
goto err_out;
diff --git a/drivers/net/netdevsim/netdevsim.h b/drivers/net/netdevsim/netdevsim.h
index ac506cf253b6..702d951fe160 100644
--- a/drivers/net/netdevsim/netdevsim.h
+++ b/drivers/net/netdevsim/netdevsim.h
@@ -173,13 +173,11 @@ int nsim_dev_port_add(struct nsim_bus_dev *nsim_bus_dev,
int nsim_dev_port_del(struct nsim_bus_dev *nsim_bus_dev,
unsigned int port_index);
-struct nsim_fib_data *nsim_fib_create(struct devlink *devlink);
-void nsim_fib_destroy(struct devlink *devlink, struct nsim_fib_data *data);
+struct nsim_fib_data *nsim_fib_create(struct devlink *devlink,
+ struct netlink_ext_ack *extack);
+void nsim_fib_destroy(struct devlink *devlink, struct nsim_fib_data *fib_data);
u64 nsim_fib_get_val(struct nsim_fib_data *fib_data,
enum nsim_resource_id res_id, bool max);
-int nsim_fib_set_max(struct nsim_fib_data *fib_data,
- enum nsim_resource_id res_id, u64 val,
- struct netlink_ext_ack *extack);
#if IS_ENABLED(CONFIG_XFRM_OFFLOAD)
void nsim_ipsec_init(struct netdevsim *ns);
--
2.21.0
^ permalink raw reply related
* [patch net-next 14/15] net: devlink: allow to change namespaces during reload
From: Jiri Pirko @ 2019-09-14 6:46 UTC (permalink / raw)
To: netdev
Cc: davem, idosch, dsahern, jakub.kicinski, tariqt, saeedm, kuznet,
yoshfuji, shuah, mlxsw
In-Reply-To: <20190914064608.26799-1-jiri@resnulli.us>
From: Jiri Pirko <jiri@mellanox.com>
All devlink instances are created in init_net and stay there for a
lifetime. Allow user to be able to move devlink instances into
namespaces during devlink reload operation. That ensures proper
re-instantiation of driver objects, including netdevices.
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
drivers/net/ethernet/mellanox/mlx4/main.c | 4 +
include/uapi/linux/devlink.h | 4 +
net/core/devlink.c | 155 ++++++++++++++++++++--
3 files changed, 155 insertions(+), 8 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c
index ef3f3d06ff1e..989d0882aaa9 100644
--- a/drivers/net/ethernet/mellanox/mlx4/main.c
+++ b/drivers/net/ethernet/mellanox/mlx4/main.c
@@ -3942,6 +3942,10 @@ static int mlx4_devlink_reload_down(struct devlink *devlink,
struct mlx4_dev *dev = &priv->dev;
struct mlx4_dev_persistent *persist = dev->persist;
+ if (!net_eq(devlink_net(devlink), &init_net)) {
+ NL_SET_ERR_MSG_MOD(extack, "Namespace change is not supported");
+ return -EOPNOTSUPP;
+ }
if (persist->num_vfs)
mlx4_warn(persist->dev, "Reload performed on PF, will cause reset on operating Virtual Functions\n");
mlx4_restart_one_down(persist->pdev);
diff --git a/include/uapi/linux/devlink.h b/include/uapi/linux/devlink.h
index 580b7a2e40e1..b558ea88b766 100644
--- a/include/uapi/linux/devlink.h
+++ b/include/uapi/linux/devlink.h
@@ -421,6 +421,10 @@ enum devlink_attr {
DEVLINK_ATTR_RELOAD_FAILED, /* u8 0 or 1 */
+ DEVLINK_ATTR_NETNS_FD, /* u32 */
+ DEVLINK_ATTR_NETNS_PID, /* u32 */
+ DEVLINK_ATTR_NETNS_ID, /* u32 */
+
/* add new attributes above here, update the policy in devlink.c */
__DEVLINK_ATTR_MAX,
diff --git a/net/core/devlink.c b/net/core/devlink.c
index 362cbbcca225..2a5db95cce3c 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -435,8 +435,16 @@ static void devlink_nl_post_doit(const struct genl_ops *ops,
{
struct devlink *devlink;
- devlink = devlink_get_from_info(info);
- if (~ops->internal_flags & DEVLINK_NL_FLAG_NO_LOCK)
+ /* When devlink changes netns, it would not be found
+ * by devlink_get_from_info(). So try if it is stored first.
+ */
+ if (ops->internal_flags & DEVLINK_NL_FLAG_NEED_DEVLINK) {
+ devlink = info->user_ptr[0];
+ } else {
+ devlink = devlink_get_from_info(info);
+ WARN_ON(IS_ERR(devlink));
+ }
+ if (!IS_ERR(devlink) && ~ops->internal_flags & DEVLINK_NL_FLAG_NO_LOCK)
mutex_unlock(&devlink->lock);
mutex_unlock(&devlink_mutex);
}
@@ -2675,6 +2683,73 @@ devlink_resources_validate(struct devlink *devlink,
return err;
}
+static struct net *devlink_netns_get(struct sk_buff *skb,
+ struct devlink *devlink,
+ struct genl_info *info)
+{
+ struct nlattr *netns_pid_attr = info->attrs[DEVLINK_ATTR_NETNS_PID];
+ struct nlattr *netns_fd_attr = info->attrs[DEVLINK_ATTR_NETNS_FD];
+ struct nlattr *netns_id_attr = info->attrs[DEVLINK_ATTR_NETNS_ID];
+ struct net *net;
+
+ if (!!netns_pid_attr + !!netns_fd_attr + !!netns_id_attr > 1) {
+ NL_SET_ERR_MSG(info->extack, "multiple netns identifying attributes specified");
+ return ERR_PTR(-EINVAL);
+ }
+
+ if (netns_pid_attr) {
+ net = get_net_ns_by_pid(nla_get_u32(netns_pid_attr));
+ } else if (netns_fd_attr) {
+ net = get_net_ns_by_fd(nla_get_u32(netns_fd_attr));
+ } else if (netns_id_attr) {
+ net = get_net_ns_by_id(sock_net(skb->sk),
+ nla_get_u32(netns_id_attr));
+ if (!net)
+ net = ERR_PTR(-EINVAL);
+ } else {
+ WARN_ON(1);
+ net = ERR_PTR(-EINVAL);
+ }
+ if (IS_ERR(net)) {
+ NL_SET_ERR_MSG(info->extack, "Unknown network namespace");
+ return ERR_PTR(-EINVAL);
+ }
+ if (!netlink_ns_capable(skb, net->user_ns, CAP_NET_ADMIN)) {
+ put_net(net);
+ return ERR_PTR(-EPERM);
+ }
+ return net;
+}
+
+static void devlink_param_notify(struct devlink *devlink,
+ unsigned int port_index,
+ struct devlink_param_item *param_item,
+ enum devlink_command cmd);
+
+static void devlink_reload_netns_change(struct devlink *devlink,
+ struct net *dest_net)
+{
+ struct devlink_param_item *param_item;
+
+ /* Userspace needs to be notified about devlink objects
+ * removed from original and entering new network namespace.
+ * The rest of the devlink objects are re-created during
+ * reload process so the notifications are generated separatelly.
+ */
+
+ list_for_each_entry(param_item, &devlink->param_list, list)
+ devlink_param_notify(devlink, 0, param_item,
+ DEVLINK_CMD_PARAM_DEL);
+ devlink_notify(devlink, DEVLINK_CMD_DEL);
+
+ devlink_net_set(devlink, dest_net);
+
+ devlink_notify(devlink, DEVLINK_CMD_NEW);
+ list_for_each_entry(param_item, &devlink->param_list, list)
+ devlink_param_notify(devlink, 0, param_item,
+ DEVLINK_CMD_PARAM_NEW);
+}
+
static bool devlink_reload_supported(struct devlink *devlink)
{
return devlink->ops->reload_down && devlink->ops->reload_up;
@@ -2695,9 +2770,27 @@ bool devlink_is_reload_failed(const struct devlink *devlink)
}
EXPORT_SYMBOL_GPL(devlink_is_reload_failed);
+static int devlink_reload(struct devlink *devlink, struct net *dest_net,
+ struct netlink_ext_ack *extack)
+{
+ int err;
+
+ err = devlink->ops->reload_down(devlink, extack);
+ if (err)
+ return err;
+
+ if (dest_net && !net_eq(dest_net, devlink_net(devlink)))
+ devlink_reload_netns_change(devlink, dest_net);
+
+ err = devlink->ops->reload_up(devlink, extack);
+ devlink_reload_failed_set(devlink, !!err);
+ return err;
+}
+
static int devlink_nl_cmd_reload(struct sk_buff *skb, struct genl_info *info)
{
struct devlink *devlink = info->user_ptr[0];
+ struct net *dest_net = NULL;
int err;
if (!devlink_reload_supported(devlink))
@@ -2708,11 +2801,20 @@ static int devlink_nl_cmd_reload(struct sk_buff *skb, struct genl_info *info)
NL_SET_ERR_MSG_MOD(info->extack, "resources size validation failed");
return err;
}
- err = devlink->ops->reload_down(devlink, info->extack);
- if (err)
- return err;
- err = devlink->ops->reload_up(devlink, info->extack);
- devlink_reload_failed_set(devlink, !!err);
+
+ if (info->attrs[DEVLINK_ATTR_NETNS_PID] ||
+ info->attrs[DEVLINK_ATTR_NETNS_FD] ||
+ info->attrs[DEVLINK_ATTR_NETNS_ID]) {
+ dest_net = devlink_netns_get(skb, devlink, info);
+ if (IS_ERR(dest_net))
+ return PTR_ERR(dest_net);
+ }
+
+ err = devlink_reload(devlink, dest_net, info->extack);
+
+ if (dest_net)
+ put_net(dest_net);
+
return err;
}
@@ -5794,6 +5896,9 @@ static const struct nla_policy devlink_nl_policy[DEVLINK_ATTR_MAX + 1] = {
[DEVLINK_ATTR_TRAP_NAME] = { .type = NLA_NUL_STRING },
[DEVLINK_ATTR_TRAP_ACTION] = { .type = NLA_U8 },
[DEVLINK_ATTR_TRAP_GROUP_NAME] = { .type = NLA_NUL_STRING },
+ [DEVLINK_ATTR_NETNS_PID] = { .type = NLA_U32 },
+ [DEVLINK_ATTR_NETNS_FD] = { .type = NLA_U32 },
+ [DEVLINK_ATTR_NETNS_ID] = { .type = NLA_U32 },
};
static const struct genl_ops devlink_nl_ops[] = {
@@ -8061,9 +8166,43 @@ int devlink_compat_switch_id_get(struct net_device *dev,
return 0;
}
+static void __net_exit devlink_pernet_pre_exit(struct net *net)
+{
+ struct devlink *devlink;
+ int err;
+
+ /* In case network namespace is getting destroyed, reload
+ * all devlink instances from this namespace into init_net.
+ */
+ mutex_lock(&devlink_mutex);
+ list_for_each_entry(devlink, &devlink_list, list) {
+ if (net_eq(devlink_net(devlink), net)) {
+ if (WARN_ON(!devlink_reload_supported(devlink)))
+ continue;
+ err = devlink_reload(devlink, &init_net, NULL);
+ if (err)
+ pr_warn("Failed to reload devlink instance into init_net\n");
+ }
+ }
+ mutex_unlock(&devlink_mutex);
+}
+
+static struct pernet_operations devlink_pernet_ops __net_initdata = {
+ .pre_exit = devlink_pernet_pre_exit,
+};
+
static int __init devlink_init(void)
{
- return genl_register_family(&devlink_nl_family);
+ int err;
+
+ err = genl_register_family(&devlink_nl_family);
+ if (err)
+ goto out;
+ err = register_pernet_subsys(&devlink_pernet_ops);
+
+out:
+ WARN_ON(err);
+ return err;
}
subsys_initcall(devlink_init);
--
2.21.0
^ permalink raw reply related
* [patch net-next 13/15] netdevsim: take devlink net instead of init_net
From: Jiri Pirko @ 2019-09-14 6:46 UTC (permalink / raw)
To: netdev
Cc: davem, idosch, dsahern, jakub.kicinski, tariqt, saeedm, kuznet,
yoshfuji, shuah, mlxsw
In-Reply-To: <20190914064608.26799-1-jiri@resnulli.us>
From: Jiri Pirko <jiri@mellanox.com>
Follow-up patch is going to allow to reload devlink instance into
different network namespace, so use devlink_net() helper instead
of init_net.
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
drivers/net/netdevsim/fib.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/netdevsim/fib.c b/drivers/net/netdevsim/fib.c
index fdc682f3a09a..13540dee7364 100644
--- a/drivers/net/netdevsim/fib.c
+++ b/drivers/net/netdevsim/fib.c
@@ -260,7 +260,7 @@ struct nsim_fib_data *nsim_fib_create(struct devlink *devlink,
nsim_fib_set_max_all(data, devlink);
data->fib_nb.notifier_call = nsim_fib_event_nb;
- err = register_fib_notifier(&init_net, &data->fib_nb,
+ err = register_fib_notifier(devlink_net(devlink), &data->fib_nb,
nsim_fib_dump_inconsistent, extack);
if (err) {
pr_err("Failed to register fib notifier\n");
@@ -300,6 +300,6 @@ void nsim_fib_destroy(struct devlink *devlink, struct nsim_fib_data *data)
NSIM_RESOURCE_IPV4_FIB_RULES);
devlink_resource_occ_get_unregister(devlink,
NSIM_RESOURCE_IPV4_FIB);
- unregister_fib_notifier(&init_net, &data->fib_nb);
+ unregister_fib_notifier(devlink_net(devlink), &data->fib_nb);
kfree(data);
}
--
2.21.0
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox