OSDN Git Service

android-x86/kernel.git
5 years agomt76: add driver for MT7603E and MT7628/7688
Felix Fietkau [Tue, 6 Nov 2018 12:47:23 +0000 (13:47 +0100)]
mt76: add driver for MT7603E and MT7628/7688

This driver is for a newer generation of 2x2 MediaTek 802.11n chipsets.
MT7603E is a PCIe chip.
MT7628 and MT7688 are MIPS SoC devices with built-in WLAN.
MT7688 is limited to 1x1

This driver fully supports AP, station, mesh, ad-hoc and monitor mode.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agodt-bindings: net: mt76: update binding for mt7603 driver
Felix Fietkau [Sat, 29 Dec 2018 12:22:11 +0000 (13:22 +0100)]
dt-bindings: net: mt76: update binding for mt7603 driver

In addition to MT7603E PCI devices, the driver supports the WLAN core on
MT7628/MT7688, which needs to be defined in DT.

Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76: add driver callback for when a sta is associated
Felix Fietkau [Wed, 30 Jan 2019 11:17:20 +0000 (12:17 +0100)]
mt76: add driver callback for when a sta is associated

MT7603 needs this to update the HT/VHT capabilities

Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76: remove no longer used routine declarations
Lorenzo Bianconi [Tue, 26 Feb 2019 11:19:04 +0000 (12:19 +0100)]
mt76: remove no longer used routine declarations

Remove following routine declarations that are no longer used
after commit cfca5f693c5d ("mt76usb: remove usb_mcu.c"):

- mt76u_mcu_complete_urb
- mt76u_deinit
- mt76u_buf_free
- mt76u_submit_urb

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76: usb: check urb->num_sgs limit in mt76u_process_rx_entry
Lorenzo Bianconi [Wed, 20 Feb 2019 09:20:37 +0000 (10:20 +0100)]
mt76: usb: check urb->num_sgs limit in mt76u_process_rx_entry

check nsgs value is less than urb->num_sgs in mt76u_process_rx_entry
in order to avoid an out-of-bound access of urb->sg array

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76: usb: simplify mt76u_tx_build_sg routine
Lorenzo Bianconi [Wed, 20 Feb 2019 22:35:18 +0000 (23:35 +0100)]
mt76: usb: simplify mt76u_tx_build_sg routine

Use skb_to_sgvec instad of skb_to_sgvec_nomark in mt76u_tx_build_sg.
Remove nsgs check in mt76u_tx_build_sg since it is already performed
by skb_to_sgvec

Suggested-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76: usb: simplify rx buffer allocation
Lorenzo Bianconi [Wed, 20 Feb 2019 22:35:17 +0000 (23:35 +0100)]
mt76: usb: simplify rx buffer allocation

Squash mt76u_buf_alloc_sg and mt76u_buf_alloc and remove duplicated
code. Reuse mt76u_refill_rx in mt76u_buf_alloc

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76: usb: introduce mt76u_fill_bulk_urb routine
Lorenzo Bianconi [Wed, 20 Feb 2019 22:35:16 +0000 (23:35 +0100)]
mt76: usb: introduce mt76u_fill_bulk_urb routine

Add mt76u_fill_bulk_urb to initialize tx/rx urbs and
remove duplicate code

Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76: usb: fix warning in mt76u_buf_free
Lorenzo Bianconi [Wed, 20 Feb 2019 23:57:19 +0000 (00:57 +0100)]
mt76: usb: fix warning in mt76u_buf_free

Fix following static checker warning in mt76u_buf_free:
  drivers/net/wireless/mediatek/mt76/usb.c:372 mt76u_buf_free()
  warn: address of 'urb->sg[i]' is non-NULL

There is no need to check sg page pointer since urb->num_sgs
has been already validated in mt76u_fill_rx_sg

Fixes: cb83585e1121 ("mt76: usb: fix possible memory leak in mt76u_buf_free")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76usb: remove usb_mcu.c
Stanislaw Gruszka [Wed, 20 Feb 2019 16:15:20 +0000 (17:15 +0100)]
mt76usb: remove usb_mcu.c

Don't need separate file just for kmalloc/kfree.

Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76usb: use synchronous msg for mcu command responses
Stanislaw Gruszka [Wed, 20 Feb 2019 16:15:19 +0000 (17:15 +0100)]
mt76usb: use synchronous msg for mcu command responses

Use usb_bulk_msg for reading MCU command responses. This simplify code
a lot.

Together with 97a3005759c ("mt76usb: allow mt76u_bulk_msg be used
for reads") it also fix possible problems with rx data buffers
not being aligned and contained within single page. After doing
page_frag_alloc(1024) consecutive page_frag_alloc(PAGE_SIZE) will
alloc PAGE_SIZE buffer at PAGE_SIZE - 1024 offset.

Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76usb: allow mt76u_bulk_msg be used for reads
Stanislaw Gruszka [Wed, 20 Feb 2019 16:15:18 +0000 (17:15 +0100)]
mt76usb: allow mt76u_bulk_msg be used for reads

Extend mt76u_bulk_msg() such it can be used for synchronous bulk reads.

Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76: mt76x02: set MT_TXOP_HLDR_TX40M_BLK_EN for mt76x2
Felix Fietkau [Mon, 25 Feb 2019 17:37:42 +0000 (18:37 +0100)]
mt76: mt76x02: set MT_TXOP_HLDR_TX40M_BLK_EN for mt76x2

It needs to be always enabled for 76x2 and conditionally enabled/disabled
for 76x0. Since mt76x2_mac_stop clears this bit, ensure that it is enabled
in mt76x02_edcca_init

Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76: mt76x2: unify mt76x2[u]_mac_resume
Felix Fietkau [Mon, 25 Feb 2019 16:32:44 +0000 (17:32 +0100)]
mt76: mt76x2: unify mt76x2[u]_mac_resume

They are now the same and short enough to be turned into an inline function

Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76: mt76x02: fix ED/CCA enabling/disabling
Felix Fietkau [Mon, 25 Feb 2019 16:25:38 +0000 (17:25 +0100)]
mt76: mt76x02: fix ED/CCA enabling/disabling

ED/CCA needs to be disable before stopping the MAC to avoid hangs from tx
being blocked. It must only be enabled again after the MAC has been started
again.
In many places this wasn't done properly, so fix this by always clearing
the relevant ED/CCA bits in mt76x2_mac_stop and set it up again after
channel change or calibration is done

Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76: mt76x02: issue watchdog reset on MCU request timeout
Felix Fietkau [Sun, 24 Feb 2019 22:16:45 +0000 (23:16 +0100)]
mt76: mt76x02: issue watchdog reset on MCU request timeout

MCU request timeout usually indicates that the device is no longer responsive,
and it usually does not recover without a reset

Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76: mt76x02: only reset beacon drift counter when enabling beacons
Felix Fietkau [Sun, 24 Feb 2019 12:03:18 +0000 (13:03 +0100)]
mt76: mt76x02: only reset beacon drift counter when enabling beacons

When the timer is already running, there is no need to reset the counter,
because the drift will remain the same.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76: mt76x02: fix beacon timer issue
Felix Fietkau [Sun, 24 Feb 2019 10:37:18 +0000 (11:37 +0100)]
mt76: mt76x02: fix beacon timer issue

When mt76x0 and mt76x2 beacon code was unified, it changed the order in which
beacon enable and beacon interval are configured.
Configuring beacon enable before beacon interval can in some cases cause
problems with the beacon timer, leading to clients not waking up properly
from powersave mode.
Fix this by changing the order back to interval first, then enable.

Fixes: cc726268e4dce ("mt76: move mt76x02_bss_info_changed in mt76x02-lib module")
Cc: stable@vger.kernel.org
Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76: mt76x02: fix beacon timer drift adjustment
Felix Fietkau [Sun, 24 Feb 2019 10:24:43 +0000 (11:24 +0100)]
mt76: mt76x02: fix beacon timer drift adjustment

Check the count before incrementing it to match vendor code behavior.
This defers the adjustment by one more tick, which should improve accuracy

Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76: mt76x02: fix TSF sync mode
Felix Fietkau [Sat, 23 Feb 2019 19:05:02 +0000 (20:05 +0100)]
mt76: mt76x02: fix TSF sync mode

MT_BEACON_TIME_CFG_SYNC_MODE needs to be set for AP mode, according to the
documentation. For other modes it should be irrelevant in this case.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agonet: fix double-free in bpf_lwt_xmit_reroute
Peter Oskolkov [Sun, 24 Feb 2019 02:25:01 +0000 (18:25 -0800)]
net: fix double-free in bpf_lwt_xmit_reroute

dst_output() frees skb when it fails (see, for example,
ip_finish_output2), so it must not be freed in this case.

Fixes: 3bd0b15281af ("bpf: add handling of BPF_LWT_REROUTE to lwt_bpf.c")
Signed-off-by: Peter Oskolkov <posk@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agoip_tunnel: Add ip tunnel tun_info type dst_cache in ip_tunnel_xmit
wenxu [Sun, 24 Feb 2019 00:24:45 +0000 (08:24 +0800)]
ip_tunnel: Add ip tunnel tun_info type dst_cache in ip_tunnel_xmit

ip l add dev tun type gretap key 1000

Non-tunnel-dst ip tunnel device can send packet through lwtunnel
This patch provide the tun_inf dst cache support for this mode.

Signed-off-by: wenxu <wenxu@ucloud.cn>
Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agoMerge branch 'dsa-mv88e6xxx-lockdep'
David S. Miller [Mon, 25 Feb 2019 06:21:23 +0000 (22:21 -0800)]
Merge branch 'dsa-mv88e6xxx-lockdep'

Andrew Lunn says:

====================
mv88e6xxx: Avoid false positive Lockdep splats

When acquiring the GPIO interrupt line for the switch, it is possible
to trigger lockdep splats. These are false positives, the mutex is in
a different IRQ descriptor. But fix it anyway, since it could mask
real locking issues.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agonet: dsa: mv88e6xxx: Release lock while requesting IRQ
Andrew Lunn [Sat, 23 Feb 2019 16:43:57 +0000 (17:43 +0100)]
net: dsa: mv88e6xxx: Release lock while requesting IRQ

There is no need to hold the register lock while requesting the GPIO
interrupt. By not holding it we can also avoid a false positive
lockdep splat.

Reported-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agonet: dsa: mv88e6xxx: Add lockdep classes to fix false positive splat
Andrew Lunn [Sat, 23 Feb 2019 16:43:56 +0000 (17:43 +0100)]
net: dsa: mv88e6xxx: Add lockdep classes to fix false positive splat

The following false positive lockdep splat has been observed.

======================================================
WARNING: possible circular locking dependency detected
4.20.0+ #302 Not tainted
------------------------------------------------------
systemd-udevd/160 is trying to acquire lock:
edea6080 (&chip->reg_lock){+.+.}, at: __setup_irq+0x640/0x704

but task is already holding lock:
edff0340 (&desc->request_mutex){+.+.}, at: __setup_irq+0xa0/0x704

which lock already depends on the new lock.

the existing dependency chain (in reverse order) is:

-> #1 (&desc->request_mutex){+.+.}:
       mutex_lock_nested+0x1c/0x24
       __setup_irq+0xa0/0x704
       request_threaded_irq+0xd0/0x150
       mv88e6xxx_probe+0x41c/0x694 [mv88e6xxx]
       mdio_probe+0x2c/0x54
       really_probe+0x200/0x2c4
       driver_probe_device+0x5c/0x174
       __driver_attach+0xd8/0xdc
       bus_for_each_dev+0x58/0x7c
       bus_add_driver+0xe4/0x1f0
       driver_register+0x7c/0x110
       mdio_driver_register+0x24/0x58
       do_one_initcall+0x74/0x2e8
       do_init_module+0x60/0x1d0
       load_module+0x1968/0x1ff4
       sys_finit_module+0x8c/0x98
       ret_fast_syscall+0x0/0x28
       0xbedf2ae8

-> #0 (&chip->reg_lock){+.+.}:
       __mutex_lock+0x50/0x8b8
       mutex_lock_nested+0x1c/0x24
       __setup_irq+0x640/0x704
       request_threaded_irq+0xd0/0x150
       mv88e6xxx_g2_irq_setup+0xcc/0x1b4 [mv88e6xxx]
       mv88e6xxx_probe+0x44c/0x694 [mv88e6xxx]
       mdio_probe+0x2c/0x54
       really_probe+0x200/0x2c4
       driver_probe_device+0x5c/0x174
       __driver_attach+0xd8/0xdc
       bus_for_each_dev+0x58/0x7c
       bus_add_driver+0xe4/0x1f0
       driver_register+0x7c/0x110
       mdio_driver_register+0x24/0x58
       do_one_initcall+0x74/0x2e8
       do_init_module+0x60/0x1d0
       load_module+0x1968/0x1ff4
       sys_finit_module+0x8c/0x98
       ret_fast_syscall+0x0/0x28
       0xbedf2ae8

other info that might help us debug this:

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&desc->request_mutex);
                               lock(&chip->reg_lock);
                               lock(&desc->request_mutex);
  lock(&chip->reg_lock);

&desc->request_mutex refer to two different mutex. #1 is the GPIO for
the chip interrupt. #2 is the chained interrupt between global 1 and
global 2.

Add lockdep classes to the GPIO interrupt to avoid this.

Reported-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agoip_tunnel: Add dst_cache support in lwtunnel_state of ip tunnel
wenxu [Sat, 23 Feb 2019 13:32:54 +0000 (21:32 +0800)]
ip_tunnel: Add dst_cache support in lwtunnel_state of ip tunnel

The lwtunnel_state is not init the dst_cache Which make the
ip_md_tunnel_xmit can't use the dst_cache. It will lookup
route table every packets.

Signed-off-by: wenxu <wenxu@ucloud.cn>
Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agotls: Return type of non-data records retrieved using MSG_PEEK in recvmsg
Vakul Garg [Sat, 23 Feb 2019 08:42:37 +0000 (08:42 +0000)]
tls: Return type of non-data records retrieved using MSG_PEEK in recvmsg

The patch enables returning 'type' in msghdr for records that are
retrieved with MSG_PEEK in recvmsg. Further it prevents records peeked
from socket from getting clubbed with any other record of different
type when records are subsequently dequeued from strparser.

For each record, we now retain its type in sk_buff's control buffer
cb[]. Inside control buffer, record's full length and offset are already
stored by strparser in 'struct strp_msg'. We store record type after
'struct strp_msg' inside 'struct tls_msg'. For tls1.2, the type is
stored just after record dequeue. For tls1.3, the type is stored after
record has been decrypted.

Inside process_rx_list(), before processing a non-data record, we check
that we must be able to return back the record type to the user
application. If not, the decrypted records in tls context's rx_list is
left there without consuming any data.

Fixes: 692d7b5d1f912 ("tls: Fix recvmsg() to be able to peek across multiple records")
Signed-off-by: Vakul Garg <vakul.garg@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agoMerge branch 'ipv4-v6-icmp-small-cleanup-and-update'
David S. Miller [Mon, 25 Feb 2019 05:57:26 +0000 (21:57 -0800)]
Merge branch 'ipv4-v6-icmp-small-cleanup-and-update'

Kefeng Wang says:

====================
ipv4/v6: icmp: small cleanup and update

v2:
- Add cover letter and user proper patch subject-prefix suggested-by Eric Dumazet

This patch series contains some small cleanup and update,
1) use icmp/v6_sk_exit when icmp_sk_init fails instead of open-code
2) use new percpu allocation interface for the ipv6.icmp_sk
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agoipv6: icmp: use percpu allocation
Kefeng Wang [Sat, 23 Feb 2019 07:28:28 +0000 (15:28 +0800)]
ipv6: icmp: use percpu allocation

Use percpu allocation for the ipv6.icmp_sk.

Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agoipv6: icmp: use icmpv6_sk_exit()
Kefeng Wang [Sat, 23 Feb 2019 07:28:27 +0000 (15:28 +0800)]
ipv6: icmp: use icmpv6_sk_exit()

Simply use icmpv6_sk_exit() when inet_ctl_sock_create() fail
in icmpv6_sk_init().

Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agoipv4: icmp: use icmp_sk_exit()
Kefeng Wang [Sat, 23 Feb 2019 07:28:26 +0000 (15:28 +0800)]
ipv4: icmp: use icmp_sk_exit()

Simply use icmp_sk_exit() when inet_ctl_sock_create() fail in icmp_sk_init().

Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agoila: Fix uninitialised return value in ila_xlat_nl_cmd_flush
Herbert Xu [Sat, 23 Feb 2019 05:30:47 +0000 (13:30 +0800)]
ila: Fix uninitialised return value in ila_xlat_nl_cmd_flush

This patch fixes an uninitialised return value error in
ila_xlat_nl_cmd_flush.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Fixes: 6c4128f65857 ("rhashtable: Remove obsolete...")
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agonet/sched: act_tunnel_key: Add dst_cache support
wenxu [Fri, 22 Feb 2019 07:58:12 +0000 (15:58 +0800)]
net/sched: act_tunnel_key: Add dst_cache support

The metadata_dst is not init the dst_cache which make the
ip_md_tunnel_xmit can't use the dst_cache. It will lookup
route table every packets.

Signed-off-by: wenxu <wenxu@ucloud.cn>
Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agoMerge branch 'code-optimizations-and-bugfixes-for-HNS3-driver'
David S. Miller [Mon, 25 Feb 2019 04:27:51 +0000 (20:27 -0800)]
Merge branch 'code-optimizations-and-bugfixes-for-HNS3-driver'

Huazhong Tan says:

====================
code optimizations & bugfixes for HNS3 driver

This patchset includes bugfixes and code optimizations for
the HNS3 ethernet controller driver.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agonet: hns3: fix improper error handling for hns3_client_start
Huazhong Tan [Sat, 23 Feb 2019 09:22:19 +0000 (17:22 +0800)]
net: hns3: fix improper error handling for hns3_client_start

If hns3_client_start() failed in the hns3_client_init(),
register_dev() should be undo in its error handling.

Fixes: a6d818e31d08 ("net: hns3: Add vport alive state checking support")
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agonet: hns3: fix setting of the hns reset_type for rdma hw errors
Shiju Jose [Sat, 23 Feb 2019 09:22:18 +0000 (17:22 +0800)]
net: hns3: fix setting of the hns reset_type for rdma hw errors

Presently the hns reset_type for the roce errors is set
in the hclge_log_and_clear_rocee_ras_error function.
This function is also called to detect and clear roce errors
while enabling the rdma error interrupts. However there is no hns
reset requested for this case. This can cause issue of wrong
reset_type used with subsequent hns reset as the
reset_type set in the above case was not cleared.

This patch moves setting of hns reset_type for the roce errors from
hclge_log_and_clear_rocee_ras_error function
to hclge_handle_rocee_ras_error.

Fixes: 630ba007f475 ("net: hns3: add handling of RDMA RAS errors")
Reported-by: Huazhong Tan <tanhuazhong@huawei.com>
Reported-by: Xiaofei Tan <tanxiaofei@huawei.com>
Signed-off-by: Shiju Jose <shiju.jose@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agonet: hns3: fix get VF RSS issue
Jian Shen [Sat, 23 Feb 2019 09:22:17 +0000 (17:22 +0800)]
net: hns3: fix get VF RSS issue

For revision 0x20, VF shares the same RSS config with PF.
In original codes, it always return 0 when query RSS hash
key for VF. This patch fixes it by return the hash key
got from PF.

Fixes: 374ad291762a ("net: hns3: net: hns3: Add RSS general configuration support for VF")
Signed-off-by: Jian Shen <shenjian15@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agonet: hns3: enable VF VLAN filter for each VF when initializing
Jian Shen [Sat, 23 Feb 2019 09:22:16 +0000 (17:22 +0800)]
net: hns3: enable VF VLAN filter for each VF when initializing

For revision 0x21, the switch of VF VLAN filter is per function.
It's necessary to enable VF VLAN filter for each VF when initializing.
Otherwise, VF will be able to receive broadcast packets with unknown
VLAN when PF enters promisc mode.

Fixes: 64d114f0a750 ("net: hns3: Add egress/ingress vlan filter for revision 0x21")
Signed-off-by: Jian Shen <shenjian15@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agonet: hns3: add support to config depth for tx|rx ring separately
Peng Li [Sat, 23 Feb 2019 09:22:15 +0000 (17:22 +0800)]
net: hns3: add support to config depth for tx|rx ring separately

This patch adds support to config depth for tx|rx ring separately
by ethtool command "-G".

Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agonet: hns3: remove hnae3_get_bit in data path
Yunsheng Lin [Sat, 23 Feb 2019 09:22:14 +0000 (17:22 +0800)]
net: hns3: remove hnae3_get_bit in data path

The hnae3_get_bit uses hnae3_get_field, and hnae3_get_field
masks the data, which is unnecessary in data path.

Signed-off-by: Yunsheng Lin <linyunsheng@huawei.com>
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agonet: hns3: replace hnae3_set_bit and hnae3_set_field in data path
Yunsheng Lin [Sat, 23 Feb 2019 09:22:13 +0000 (17:22 +0800)]
net: hns3: replace hnae3_set_bit and hnae3_set_field in data path

hnae3_set_bit and hnae3_set_field masks the data before setting
the field or bit, which is unnecessary because the data is already
zero initialized.

Suggested-by: John Garry <john.garry@huawei.com>
Signed-off-by: Yunsheng Lin <linyunsheng@huawei.com>
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agonet: hns3: add unlikely for error handling in data path
Yunsheng Lin [Sat, 23 Feb 2019 09:22:12 +0000 (17:22 +0800)]
net: hns3: add unlikely for error handling in data path

This patch adds unlikely hint for error handling in critical data
path.

Signed-off-by: Yunsheng Lin <linyunsheng@huawei.com>
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agonet: hns3: remove some ops in struct hns3_nic_ops
Yunsheng Lin [Sat, 23 Feb 2019 09:22:11 +0000 (17:22 +0800)]
net: hns3: remove some ops in struct hns3_nic_ops

The fill_desc ops has only one implementation, and
get_rxd_bnum has not been used, so this patch removes
them.

Signed-off-by: Yunsheng Lin <linyunsheng@huawei.com>
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agonet: hns3: limit some variable scope in critical data path
Yunsheng Lin [Sat, 23 Feb 2019 09:22:10 +0000 (17:22 +0800)]
net: hns3: limit some variable scope in critical data path

This patch limits some variables' scope as much as possible in
hns3_fill_desc.

Also, only set l3_type and l4_type when necessary.

Signed-off-by: Yunsheng Lin <linyunsheng@huawei.com>
Signed-off-by: Huazhong tan <tanhuazhong@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agonet: hns3: avoid mult + div op in critical data path
Yunsheng Lin [Sat, 23 Feb 2019 09:22:09 +0000 (17:22 +0800)]
net: hns3: avoid mult + div op in critical data path

This patch uses shift offset to avoid doing mult and div operation.

Signed-off-by: Yunsheng Lin <linyunsheng@huawei.com>
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agonet: hns3: add xps setting support for hns3 driver
Yunsheng Lin [Sat, 23 Feb 2019 09:22:08 +0000 (17:22 +0800)]
net: hns3: add xps setting support for hns3 driver

This patch adds xps setting support for hns3 driver based on
the interrupt affinity info.

Signed-off-by: Yunsheng Lin <linyunsheng@huawei.com>
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agoMerge branch 'mlxsw-spectrum_acl-Don-t-take-rtnl-mutex-for-region-rehash'
David S. Miller [Mon, 25 Feb 2019 04:25:30 +0000 (20:25 -0800)]
Merge branch 'mlxsw-spectrum_acl-Don-t-take-rtnl-mutex-for-region-rehash'

Ido Schimmel says:

====================
mlxsw: spectrum_acl: Don't take rtnl mutex for region rehash

Jiri says:

During region rehash, a new region is created with a more optimized set
of masks (ERPs). When transitioning to the new region, all the rules
from the old region are copied one-by-one to the new region. This
transition can be time consuming and currently done under RTNL lock.

In order to remove RTNL lock dependency during region rehash, introduce
multiple smaller locks guarding dedicated structures or parts of them.
That is the vast majority of this patchset. Only patch #1 is simple
cleanup and patches 12-15 are improving or introducing new selftests.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agoselftests: mlxsw: spectrum-2: Add massive delta rehash test
Jiri Pirko [Sun, 24 Feb 2019 06:46:34 +0000 (06:46 +0000)]
selftests: mlxsw: spectrum-2: Add massive delta rehash test

Do insertions and removal of filters during rehash in higher volumes.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agoselftests: mlxsw: spectrum-2: Check migrate end trace
Jiri Pirko [Sun, 24 Feb 2019 06:46:33 +0000 (06:46 +0000)]
selftests: mlxsw: spectrum-2: Check migrate end trace

Add checking of newly added trace.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agomlxsw: spectrum_acl: Add vregion migration end tracepoint
Jiri Pirko [Sun, 24 Feb 2019 06:46:33 +0000 (06:46 +0000)]
mlxsw: spectrum_acl: Add vregion migration end tracepoint

Hit the new tracepoint once the vregion migration ends.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agoselftests: mlxsw: spectrum-2: Add IPv6 variant of simple delta rehash test
Jiri Pirko [Sun, 24 Feb 2019 06:46:32 +0000 (06:46 +0000)]
selftests: mlxsw: spectrum-2: Add IPv6 variant of simple delta rehash test

Track the basic codepaths of delta rehash handling,
using mlxsw tracepoints. Use IPv6 addresses.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agomlxsw: spectrum_acl: Don't take mutex in mlxsw_sp_acl_tcam_vregion_rehash_work()
Jiri Pirko [Sun, 24 Feb 2019 06:46:31 +0000 (06:46 +0000)]
mlxsw: spectrum_acl: Don't take mutex in mlxsw_sp_acl_tcam_vregion_rehash_work()

Other mutexes are taking care of proper locking for this, no longer
needed to take RTNL mutex here.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agomlxsw: spectrum_acl: Remove RTNL lock assertions from ERP code
Jiri Pirko [Sun, 24 Feb 2019 06:46:30 +0000 (06:46 +0000)]
mlxsw: spectrum_acl: Remove RTNL lock assertions from ERP code

No longer require RTNL lock in this code. Newly introduced mutexes take
care of guarding objagg and bloom filter. There is no need to guard
gen_pool_alloc()/gen_pool_free() as they are fine to be called lockless.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agomlxsw: spectrum_acl: Don't take rtnl lock during vregion_rehash_intrvl_set()
Jiri Pirko [Sun, 24 Feb 2019 06:46:29 +0000 (06:46 +0000)]
mlxsw: spectrum_acl: Don't take rtnl lock during vregion_rehash_intrvl_set()

Relax dependency on rtnl mutex during vregion_rehash_intrvl_set(). The
vregion list is protected with newly introduced mutex.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agomlxsw: spectrum_acl: Introduce a mutex to guard objagg instance manipulation
Jiri Pirko [Sun, 24 Feb 2019 06:46:28 +0000 (06:46 +0000)]
mlxsw: spectrum_acl: Introduce a mutex to guard objagg instance manipulation

Protect objagg structures by adding a mutex to ERP code and take it
during the structure manipulation.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agomlxsw: spectrum_acl: Enable vregion rehash per-profile
Jiri Pirko [Sun, 24 Feb 2019 06:46:28 +0000 (06:46 +0000)]
mlxsw: spectrum_acl: Enable vregion rehash per-profile

For MR ACL profile is does not make sense to do periodical rehashes, as
there is only one mask in use during the whole vregion lifetime.
Therefore periodical work is scheduled but the rehash never happens.
So allow to enable/disable rehash for the whole group, which is added
per-profile. Disable rehashing for MR profile.

Addition to the vregion list is done only in case the rehash is enable
on the particular vregion. Also, the addition is moved after delayed
work init to avoid schedule of uninitialized work
from vregion_rehash_intrvl_set(). Symmetrically, deletion from
the list is done before canceling the delayed work so it is
not scheduled by vregion_rehash_intrvl_set() again.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agomlxsw: spectrum_acl: Introduce mutex to guard Bloom Filter updates
Jiri Pirko [Sun, 24 Feb 2019 06:46:27 +0000 (06:46 +0000)]
mlxsw: spectrum_acl: Introduce mutex to guard Bloom Filter updates

Bloom filter is shared within multiple regions. For updates, it needs to
be guarded by a separate mutex. Do that in order to not rely on RTNL
mutex.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agomlxsw: spectrum_acl: Introduce vregion mutex
Jiri Pirko [Sun, 24 Feb 2019 06:46:26 +0000 (06:46 +0000)]
mlxsw: spectrum_acl: Introduce vregion mutex

In order to remove dependency on RTNL, introduce a mutex
to guard vregion structure, list of chunks and list of entries in
chunks.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agomlxsw: spectrum_acl: Refactor vregion association code
Jiri Pirko [Sun, 24 Feb 2019 06:46:25 +0000 (06:46 +0000)]
mlxsw: spectrum_acl: Refactor vregion association code

Refactor existing _vchunk_assoc/_vchunk_deassoc() functions into
_vregion_get()/_vregion_put() to make the code simpler and prepared for
vregion locking.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agomlxsw: spectrum_acl: Introduce a mutex to guard region list updates
Jiri Pirko [Sun, 24 Feb 2019 06:46:24 +0000 (06:46 +0000)]
mlxsw: spectrum_acl: Introduce a mutex to guard region list updates

In order to remove RTNL lock dependency, it is needed to protect
the regions list in a group. Introduce a mutex to do the job.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agomlxsw: spectrum_acl: Split TCAM group structure into two
Jiri Pirko [Sun, 24 Feb 2019 06:46:23 +0000 (06:46 +0000)]
mlxsw: spectrum_acl: Split TCAM group structure into two

Make the existing group structure to contain fields needed for HW region
list manipulations. Move the rest of the fields into new vgroup struct.
This makes layering cleaner as the vgroup struct is on higher level than
low-level group struct. Also, this makes it possible to introduce
fine-grained locking.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agomlxsw: spectrum_acl: Remove unused ops field from group structure
Jiri Pirko [Sun, 24 Feb 2019 06:46:22 +0000 (06:46 +0000)]
mlxsw: spectrum_acl: Remove unused ops field from group structure

Never used, remove it.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agoMerge branch 'net-dsa-microchip-add-MIB-counters-support'
David S. Miller [Mon, 25 Feb 2019 01:49:59 +0000 (17:49 -0800)]
Merge branch 'net-dsa-microchip-add-MIB-counters-support'

Tristram Ha says:

====================
net: dsa: microchip: add MIB counters support

This series of patches is to modify the KSZ9477 DSA driver to read MIB
counters periodically to avoid overflow.

The MIB counters should be read only when there is link.  Otherwise it is
a waste of time as hardware never increases the counters.

Functions are added to check the port link status so that MIB counters
read call is used efficiently.

v4
- Use readx_poll_timeout
- Fix using mutex in a timer callback function problem
- use dp->slave directly instead of checking whether it is valid
- Add port_cleanup function in a separate patch
- Add a mutex so that changing device variables is safe

v3
- Use netif_carrier_ok instead of checking the phy device pointer

v2
- Create macro similar to readx_poll_timeout to use with switch
- Create ksz_port_cleanup function so that variables like on_ports and
  live_ports can be updated inside it

v1
- Use readx_poll_timeout
- Do not clear MIB counters when port is enabled
- Do not advertise 1000 half-duplex mode when port is enabled
- Do not use freeze function as MIB counters may miss counts
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agonet: dsa: microchip: add port_cleanup function
Tristram Ha [Sat, 23 Feb 2019 00:36:51 +0000 (16:36 -0800)]
net: dsa: microchip: add port_cleanup function

Add port_cleanup function to reset some device variables when the port is
disabled.  Add a mutex to make sure changing those variables is
thread-safe.

Signed-off-by: Tristram Ha <Tristram.Ha@microchip.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agonet: dsa: microchip: remove unnecessary include headers
Tristram Ha [Sat, 23 Feb 2019 00:36:50 +0000 (16:36 -0800)]
net: dsa: microchip: remove unnecessary include headers

Remove unnecessary header include.

Signed-off-by: Tristram Ha <Tristram.Ha@microchip.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agonet: dsa: microchip: get port link status
Tristram Ha [Sat, 23 Feb 2019 00:36:49 +0000 (16:36 -0800)]
net: dsa: microchip: get port link status

Get port link status to know whether to read MIB counters when the link
is going down.

Signed-off-by: Tristram Ha <Tristram.Ha@microchip.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agonet: dsa: microchip: add MIB counter reading support
Tristram Ha [Sat, 23 Feb 2019 00:36:48 +0000 (16:36 -0800)]
net: dsa: microchip: add MIB counter reading support

Add background MIB counter reading support.

Port MIB counters should only be read when there is link.  Otherwise it is
a waste of time as hardware never increases those counters.  There are
exceptions as some switches keep track of dropped counts no matter what.

Signed-off-by: Tristram Ha <Tristram.Ha@microchip.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agonet: dsa: microchip: prepare PHY for proper advertisement
Tristram Ha [Sat, 23 Feb 2019 00:36:47 +0000 (16:36 -0800)]
net: dsa: microchip: prepare PHY for proper advertisement

Prepare PHY for proper advertisement as sometimes the PHY in the switch
has its own problems even though it may share the PHY id from regular PHY
but the fixes in the PHY driver do not apply.

Signed-off-by: Tristram Ha <Tristram.Ha@microchip.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agoMerge branch 'net-phy-marvell10g-Add-2-5GBaseT-support'
David S. Miller [Mon, 25 Feb 2019 01:45:25 +0000 (17:45 -0800)]
Merge branch 'net-phy-marvell10g-Add-2-5GBaseT-support'

Maxime Chevallier says:

====================
net: phy: marvell10g: Add 2.5GBaseT support

This series adds the missing bits necessary to fully support 2.5GBaseT
in the Marvell Alaska PHYs.

The main points for that support are :

 - Making use of the .get_features call, recently introduced by Heiner
   and Andrew, that allows having a fully populated list of supported
   modes, including 2500BaseT.

 - Configuring the MII to 2500BaseX when establishing a link at 2.5G

 - Adding a small quirk to take into account the fact that some PHYs in
   the family won't report the correct supported abilities

The rest of the series consists of small cosmetic improvements such as
using the correct helper to set a linkmode bit and adding macros for the
PHY ids.

We also add support for the 88E2110 PHY, which doesn't require the
quirk, and support for 2500BaseT in the PPv2 driver, in order to have a
fully working setup on the MacchiatoBin board.

Changes since V1 : Fixed formatting issue in patch 01, rebased.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agonet: phy: marvell10g: add support for the 88x2110 PHY
Maxime Chevallier [Fri, 22 Feb 2019 23:37:44 +0000 (00:37 +0100)]
net: phy: marvell10g: add support for the 88x2110 PHY

This patch adds support for the 88x2110 PHY, which is similar to the
already supported 88x3310 PHY without the SFP interface.

It supports 10/100/1000BASET along with 2.5GBASET, 5GBASET and 10GBASET,
with the same interface modes that are used by the 3310.

This PHY don't have the same issue as the 88x3310 regarding 2.5/5G
abilities, and correctly follows the 802.3bz standard to list the
supported abilities.

Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Suggested-by: Antoine Tenart <antoine.tenart@bootlin.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agonet: mvpp2: Add 2.5GBaseT support
Maxime Chevallier [Fri, 22 Feb 2019 23:37:43 +0000 (00:37 +0100)]
net: mvpp2: Add 2.5GBaseT support

The PPv2 controller is able to support 2.5G speeds, allowing to use
2.5GBASET in conjunction with PHYs that use 2500BASEX as their MII
interface when using this mode.

Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agonet: phy: marvell10g: Force reading of 2.5/5G
Maxime Chevallier [Fri, 22 Feb 2019 23:37:42 +0000 (00:37 +0100)]
net: phy: marvell10g: Force reading of 2.5/5G

As per 802.3bz, if bit 14 of (1.11) "PMA Extended Abilities" indicates
whether or not we should read register (1.21) "2.52/5G PMA Extended
Abilities", which contains information on the support of 2.5GBASET and
5GBASET.

After testing on several variants of PHYS of this family, it appears
that bit 14 in (1.11) isn't always set when it should be.

PHYs 88X3310 (on MacchiatoBin) and 88E2010 do support 2.5G and 5GBASET,
but don't have 1.11.14 set. Their register 1.21 is filled with the
correct values, indicating 2.5G and 5G support.

PHYs 88E2110 do have their 1.11.14 bit set, as it should.

Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agonet: phy: marvell10g: Use a #define for 88X3310 family id
Maxime Chevallier [Fri, 22 Feb 2019 23:37:41 +0000 (00:37 +0100)]
net: phy: marvell10g: Use a #define for 88X3310 family id

The PHY ID corresponding to the 88X3310 is also used for other PHYs in
the same family, such as the 88E2010. Use a #define for the PHY id, that
ignores the last nibble.

Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agonet: phy: marvell10g: Use 2500BASEX when using 2.5GBASET
Maxime Chevallier [Fri, 22 Feb 2019 23:37:40 +0000 (00:37 +0100)]
net: phy: marvell10g: Use 2500BASEX when using 2.5GBASET

The Marvell Alaska family of PHYs supports 2.5GBaseT and 5GBaseT modes,
as defined in the 802.3bz specification.

Upon establishing a 2.5GBASET link, the PHY will reconfigure it's MII
interface to 2500BASEX.

At 5G, the PHY will reconfigure it's interface to 5GBASE-R, but this
mode isn't supported by any MAC for now.

This was tested with :
 - The 88X3310, which is on the MacchiatoBin
 - The 88E2010, an Alaska PHY that has no fiber interfaces, and is
   limited to 5G maximum speed.

Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agonet: phy: marvell10g: Use linkmode_set_bit helper instead of __set_bit
Maxime Chevallier [Fri, 22 Feb 2019 23:37:39 +0000 (00:37 +0100)]
net: phy: marvell10g: Use linkmode_set_bit helper instead of __set_bit

Cosmetic patch making use of helpers dedicated to linkmodes handling.

Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agonet: phy: marvell10g: Use get_features to get the PHY abilities
Maxime Chevallier [Fri, 22 Feb 2019 23:37:38 +0000 (00:37 +0100)]
net: phy: marvell10g: Use get_features to get the PHY abilities

The Alaska family of 10G PHYs has more abilities than the ones listed in
PHY_10GBIT_FULL_FEATURES, the exact list depending on the model.

Make use of the newly introduced .get_features call to build this list,
using genphy_c45_pma_read_abilities to build the list of supported
linkmodes, and adding autoneg ability based on what's reported by the AN
MMD.

.config_init is still used to validate the interface_mode.

Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agonet: phy: check PMAPMD link status only in genphy_c45_read_link
Heiner Kallweit [Fri, 22 Feb 2019 21:59:38 +0000 (22:59 +0100)]
net: phy: check PMAPMD link status only in genphy_c45_read_link

The current code reports a link as up if all devices (except a few
blacklisted ones) report the link as up. This breaks Aquantia AQCS109
for lower speeds because on this PHY the PCS link status reflects a
10G link only. For Marvell there's a similar issue, therefore PHYXS
device isn't checked.

There may be more PHYs where depending on the mode the link status
of only selected devices is relevant.

For now it seems to be sufficient to check the link status of the
PMAPMD device only. Leave the loop in the code to be prepared in
case we have to add functionality to check more than one device,
depending on the mode.

Successfully tested on a board with an AQCS109.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agoMerge branch 'net-switchdev-h-inclusion-removal'
David S. Miller [Mon, 25 Feb 2019 01:40:47 +0000 (17:40 -0800)]
Merge branch 'net-switchdev-h-inclusion-removal'

Florian Fainelli says:

====================
net: switchdev.h inclusion removal

This targets a few drivers that no longer to have net/switchdev.h
included.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agonet: Remove switchdev.h inclusion from team/bond/vlan
Florian Fainelli [Fri, 22 Feb 2019 20:31:34 +0000 (12:31 -0800)]
net: Remove switchdev.h inclusion from team/bond/vlan

This is no longer necessary after eca59f691566 ("net: Remove support for bridge bypass ndos from stacked devices")

Suggested-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Reviewed-by: Andy Gospodarek <andy@greyhouse.net>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agonfp: Remove switchdev.h inclusion
Florian Fainelli [Fri, 22 Feb 2019 20:31:33 +0000 (12:31 -0800)]
nfp: Remove switchdev.h inclusion

This is no longer necessary after a5084bb71fa4 ("nfp: Implement
ndo_get_port_parent_id()")

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Acked-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agonet: lantiq: Do not use eth_change_mtu()
Hauke Mehrtens [Fri, 22 Feb 2019 19:12:57 +0000 (20:12 +0100)]
net: lantiq: Do not use eth_change_mtu()

eth_change_mtu() is not needed any more, the networking subsystem will
call it automatically when this callback is not implemented.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agonet: phy: improve definition of __ETHTOOL_LINK_MODE_MASK_NBITS
Heiner Kallweit [Fri, 22 Feb 2019 18:25:59 +0000 (19:25 +0100)]
net: phy: improve definition of __ETHTOOL_LINK_MODE_MASK_NBITS

The way to define __ETHTOOL_LINK_MODE_MASK_NBITS seems to be overly
complicated, go with a standard approach instead.
Whilst we're at it, move the comment to the right place.

v2:
- rebased

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agoMerge branch 'net-protodown-support-for-macvlan-and-vxlan'
David S. Miller [Sun, 24 Feb 2019 21:01:05 +0000 (13:01 -0800)]
Merge branch 'net-protodown-support-for-macvlan-and-vxlan'

Andy Roulin says:

====================
net: protodown support for macvlan and vxlan

This patch series adds dev_change_proto_down_generic, a generic
implementation of ndo_change_proto_down, which sets the netdev carrier
state according to the new proto_down value.

This handler adds the ability to set protodown on macvlan and vxlan
interfaces in a generic way for use by control protocols like VRRPD.

Patch (1) introduces the handler in net/code/dev.c. Patch (2) and (3) add
support for change_proto_down in macvlan and vxlan drivers, respectively,
using the new function.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agovxlan: add ndo_change_proto_down support
Andy Roulin [Fri, 22 Feb 2019 18:06:38 +0000 (18:06 +0000)]
vxlan: add ndo_change_proto_down support

Add ndo_change_proto_down support through dev_change_proto_down_generic
for use by control protocols like VRRPD.

Signed-off-by: Andy Roulin <aroulin@cumulusnetworks.com>
Acked-by: Roopa Prabhu <roopa@cumulusnetworks.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agomacvlan: add ndo_change_proto_down support
Andy Roulin [Fri, 22 Feb 2019 18:06:37 +0000 (18:06 +0000)]
macvlan: add ndo_change_proto_down support

Add ndo_change_proto_down support through dev_change_proto_down_generic
for use by control protocols like VRRPD.

Signed-off-by: Andy Roulin <aroulin@cumulusnetworks.com>
Acked-by: Roopa Prabhu <roopa@cumulusnetworks.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agonet: dev: add generic protodown handler
Andy Roulin [Fri, 22 Feb 2019 18:06:36 +0000 (18:06 +0000)]
net: dev: add generic protodown handler

Introduce dev_change_proto_down_generic, a generic ndo_change_proto_down
implementation, which sets the netdev carrier state according to proto_down.

This adds the ability to set protodown on vxlan and macvlan devices in a
generic way for use by control protocols like VRRPD.

Signed-off-by: Andy Roulin <aroulin@cumulusnetworks.com>
Acked-by: Roopa Prabhu <roopa@cumulusnetworks.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agoMerge branch 'Add-tests-for-unlocked-flower-classifier-implementation'
David S. Miller [Sun, 24 Feb 2019 20:49:59 +0000 (12:49 -0800)]
Merge branch 'Add-tests-for-unlocked-flower-classifier-implementation'

Vlad Buslov says:

====================
Add tests for unlocked flower classifier implementation

Implement tests for tdc testsuite to verify concurrent rules update with
rtnl-unlocked flower classifier implementation. The goal of these tests
is to verify general flower classifier correctness by updating filters
on same classifier instance in parallel and to verify its atomicity by
concurrently updating filters in same handle range. All three filter
update operations (add, replace, delete) are tested.

Existing script tdc_batch.py is re-used for batch file generation. It is
extended with several optional CLI arguments that are needed for
concurrency tests. Thin wrapper tdc_multibatch.py is implemented on top
of tdc_batch.py to simplify its usage when generating multiple batch
files for several test configurations.

Parallelism in tests is implemented by running multiple instances of tc
in batch mode with xargs tool. Xargs is chosen for its ease of use and
because it is available by default on most modern Linux distributions.
====================

Acked-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agoselftests: concurrency: add test to verify parallel replace/delete
Vlad Buslov [Fri, 22 Feb 2019 14:00:47 +0000 (16:00 +0200)]
selftests: concurrency: add test to verify parallel replace/delete

Implement test that runs 5 instances of tc replace filter in parallel with
5 instances of tc del filter from same tp instance. Each instance uses its
own filter handle and key range.

Signed-off-by: Vlad Buslov <vladbu@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agoselftests: concurrency: add test to verify parallel add/delete
Vlad Buslov [Fri, 22 Feb 2019 14:00:46 +0000 (16:00 +0200)]
selftests: concurrency: add test to verify parallel add/delete

Implement test that runs 5 instances of tc add filter in parallel with 5
instances of tc del filter from same tp instance. Each instance uses its
own filter handle and key range.

Extend tdc_multibatch.py with additional options required to implement the
test: common prefix for all generated batch files, first value of filter
handle range, MAC address prefix modifier. These are necessary to allow
creating batch files with unique keys and handle ranges with multiple
invocation of tdc_multibatch.py helper script.

Signed-off-by: Vlad Buslov <vladbu@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agoselftests: concurrency: add test to verify concurrent delete
Vlad Buslov [Fri, 22 Feb 2019 14:00:45 +0000 (16:00 +0200)]
selftests: concurrency: add test to verify concurrent delete

Implement test that verifies concurrent deletion of rules by executing 10
tc instances that delete flower filters in same handle range. In this case
only one tc instance succeeds in deleting a filter with particular handle.
To mitigate expected failures of all other instances, run tc with 'force'
option to continue processing batch file in case of errors and expect xargs
to return code '123' that indicates that invocation of command(s) exited
with error in range 1-125.

Signed-off-by: Vlad Buslov <vladbu@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agoselftests: concurrency: add test to verify concurrent replace
Vlad Buslov [Fri, 22 Feb 2019 14:00:44 +0000 (16:00 +0200)]
selftests: concurrency: add test to verify concurrent replace

Implement test that verifies concurrent replacement of rules by executing
10 tc instances that replace flower filters in same handle range.

Extend tdc_multibatch.py script with new optional CLI argument that is used
to generate all batch files with same filter handle range.

Signed-off-by: Vlad Buslov <vladbu@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agoselftests: concurrency: add test to verify parallel rules replace
Vlad Buslov [Fri, 22 Feb 2019 14:00:43 +0000 (16:00 +0200)]
selftests: concurrency: add test to verify parallel rules replace

Implement test that verifies parallel rules replacement by adding 1 million
flower filters and then replacing them with 10 concurrent tc instances.

Signed-off-by: Vlad Buslov <vladbu@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agoselftests: concurrency: add test to verify parallel rules deletion
Vlad Buslov [Fri, 22 Feb 2019 14:00:42 +0000 (16:00 +0200)]
selftests: concurrency: add test to verify parallel rules deletion

Implement test that verifies parallel rules deletion by adding 1 million
flower filters and then deleting them with 10 concurrent tc instances.

Signed-off-by: Vlad Buslov <vladbu@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agoselftests: concurrency: add test to verify parallel rules insertion
Vlad Buslov [Fri, 22 Feb 2019 14:00:41 +0000 (16:00 +0200)]
selftests: concurrency: add test to verify parallel rules insertion

Implement test that verifies parallel rules insertion by adding 1 million
flower filters with 10 concurrent tc instances. Put it to standalone
'concurrency' category.

Implement tdc_multibatch.py helper script that is used to generate multiple
batch files for concurrent tc execution. Extend config with new 'BATCH_DIR'
variable to specify temporary output directory that is used to store batch
files generated by tdc_multibatch.py.

Signed-off-by: Vlad Buslov <vladbu@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agoselftests: tdc_batch.py: add options needed for concurrency tests
Vlad Buslov [Fri, 22 Feb 2019 14:00:40 +0000 (16:00 +0200)]
selftests: tdc_batch.py: add options needed for concurrency tests

Extend tdc_batch.py with several optional CLI arguments that are used for
implementation of concurrency tests in following patches in this set:

- Add optional argument to specify range of filter handles used in batch
  file [fitler_handle, filter_handle+number). This is needed for testing
  filter deletion where it is necessary to know exact handles of configured
  filters.

- Add optional argument to specify filter operation type (possible values
  are ['add', 'del', 'replace']) instead of hardcoded "add" value. This
  allows generation of batches for filter addition, deletion and
  replacement.

- Add optional argument to allow user to change mac address prefix that is
  used for all filters in batch. This is necessary to allow generating
  multiple batches with unique flower classifier keys.

Signed-off-by: Vlad Buslov <vladbu@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agonet: Skip GSO length estimation if transport header is not set
Maxim Mikityanskiy [Fri, 22 Feb 2019 12:55:22 +0000 (12:55 +0000)]
net: Skip GSO length estimation if transport header is not set

qdisc_pkt_len_init expects transport_header to be set for GSO packets.
Patch [1] skips transport_header validation for GSO packets that don't
have network_header set at the moment of calling virtio_net_hdr_to_skb,
and allows them to pass into the stack. After patch [2] no placeholder
value is assigned to transport_header if dissection fails, so this patch
adds a check to the place where the value of transport_header is used.

[1] https://patchwork.ozlabs.org/patch/1044429/
[2] https://patchwork.ozlabs.org/patch/1046122/

Signed-off-by: Maxim Mikityanskiy <maximmi@mellanox.com>
Acked-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agodoc: add phylink documentation to the networking book
Russell King [Fri, 22 Feb 2019 11:31:46 +0000 (11:31 +0000)]
doc: add phylink documentation to the networking book

Add some phylink documentation to the networking book detailing how
to convert network drivers from phylib to phylink.

Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agonet: phylink: update mac_config() documentation
Russell King [Fri, 22 Feb 2019 11:31:41 +0000 (11:31 +0000)]
net: phylink: update mac_config() documentation

A detail for mac_config() had been missed in the documentation for the
method - it is expected that the method will update the MAC to the
settings, rather than completely reprogram the MAC on each call.
Update the documentation for this method for this detail.

Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agonet: Use RCU_INIT_POINTER() to set sk_wq
Li RongQing [Fri, 22 Feb 2019 09:08:22 +0000 (17:08 +0800)]
net: Use RCU_INIT_POINTER() to set sk_wq

This pointer is RCU protected, so proper primitives should be used.

Signed-off-by: Zhang Yu <zhangyu31@baidu.com>
Signed-off-by: Li RongQing <lirongqing@baidu.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agonet: phy: let genphy_c45_read_abilities also check aneg capability
Heiner Kallweit [Fri, 22 Feb 2019 07:23:04 +0000 (08:23 +0100)]
net: phy: let genphy_c45_read_abilities also check aneg capability

When using genphy_c45_read_abilities() as get_features callback we
also have to set the autoneg capability in phydev->supported.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Signed-off-by: David S. Miller <davem@davemloft.net>