platform/kernel/linux-starfive.git
3 years agonet: ipa: validate memory regions unconditionally
Alex Elder [Wed, 9 Jun 2021 22:34:55 +0000 (17:34 -0500)]
net: ipa: validate memory regions unconditionally

Do memory region descriptor validation unconditionally, rather than
having it depend on IPA_VALIDATION being defined.

Pass the address of a memory region descriptor rather than a memory
ID to ipa_mem_valid().

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: ipa: store memory region id in descriptor
Alex Elder [Wed, 9 Jun 2021 22:34:54 +0000 (17:34 -0500)]
net: ipa: store memory region id in descriptor

Store the memory region ID in the memory descriptor structure.  This
is a move toward *not* indexing the array by the ID, but for now we
must still specify those index values.  Define an explicitly
undefined region ID, value 0, so uninitialized entries in the array
won't use an otherwise valid ID.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: ipa: define IPA_MEM_END_MARKER
Alex Elder [Wed, 9 Jun 2021 22:34:53 +0000 (17:34 -0500)]
net: ipa: define IPA_MEM_END_MARKER

Define a new pseudo memory region identifer that specifies the
offset at the end of IPA resident memory.  Use it instead of
IPA_MEM_UC_EVENT_RING in places where the size of that region was
defined to be 0.

The size of the IPA_MEM_END_MARKER pseudo region must be zero.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: dsa: sja1105: Fix assigned yet unused return code rc
Colin Ian King [Wed, 9 Jun 2021 17:43:53 +0000 (18:43 +0100)]
net: dsa: sja1105: Fix assigned yet unused return code rc

The return code variable rc is being set to return error values in two
places in sja1105_mdiobus_base_tx_register and yet it is not being
returned, the function always returns 0 instead. Fix this by replacing
the return 0 with the return code rc.

Addresses-Coverity: ("Unused value")
Fixes: 5a8f09748ee7 ("net: dsa: sja1105: register the MDIO buses for 100base-T1 and 100base-TX")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agostmmac: prefetch right address
Matteo Croce [Wed, 9 Jun 2021 17:23:03 +0000 (19:23 +0200)]
stmmac: prefetch right address

To support XDP, a headroom is prepended to the packet data.
Consider this offset when doing a prefetch.

Fixes: da5ec7f22a0f ("net: stmmac: refactor stmmac_init_rx_buffers for stmmac_reinit_rx_buffers")
Signed-off-by: Matteo Croce <mcroce@microsoft.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agomlxsw: thermal: Fix null dereference of NULL temperature parameter
Colin Ian King [Wed, 9 Jun 2021 17:56:57 +0000 (18:56 +0100)]
mlxsw: thermal: Fix null dereference of NULL temperature parameter

The call to mlxsw_thermal_module_temp_and_thresholds_get passes a NULL
pointer for the temperature and this can be dereferenced in this function
if the mlxsw_reg_query call fails.  The simplist fix is to pass the
address of dummy temperature variable instead of a NULL pointer.

Addresses-Coverity: ("Explicit null dereferenced")
Fixes: 72a64c2fe9d8 ("mlxsw: thermal: Read module temperature thresholds using MTMP register")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: ethernet: rmnet: Always subtract MAP header
Kristian Evensen [Wed, 9 Jun 2021 14:32:49 +0000 (16:32 +0200)]
net: ethernet: rmnet: Always subtract MAP header

Commit e1d9a90a9bfd ("net: ethernet: rmnet: Support for ingress MAPv5
checksum offload") broke ingress handling for devices where
RMNET_FLAGS_INGRESS_MAP_CKSUMV5 or RMNET_FLAGS_INGRESS_MAP_CKSUMV4 are
not set. Unless either of these flags are set, the MAP header is not
removed. This commit restores the original logic by ensuring that the
MAP header is removed for all MAP packets.

Fixes: e1d9a90a9bfd ("net: ethernet: rmnet: Support for ingress MAPv5 checksum offload")
Signed-off-by: Kristian Evensen <kristian.evensen@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: ena: make symbol 'ena_alloc_map_page' static
Wei Yongjun [Wed, 9 Jun 2021 14:25:06 +0000 (14:25 +0000)]
net: ena: make symbol 'ena_alloc_map_page' static

The sparse tool complains as follows:

drivers/net/ethernet/amazon/ena/ena_netdev.c:978:13: warning:
 symbol 'ena_alloc_map_page' was not declared. Should it be static?

This symbol is not used outside of ena_netdev.c, so marks it static.

Fixes: 947c54c395cb ("net: ena: Use dev_alloc() in RX buffer allocation")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: phy: realtek: net: Fix less than zero comparison of a u16
Colin Ian King [Wed, 9 Jun 2021 17:17:48 +0000 (18:17 +0100)]
net: phy: realtek: net: Fix less than zero comparison of a u16

The comparisons of the u16 values priv->phycr1 and priv->phycr2 to less
than zero always false because they are unsigned. Fix this by using an
int for the assignment and less than zero check.

Addresses-Coverity: ("Unsigned compared against 0")
Fixes: 0a4355c2b7f8 ("net: phy: realtek: add dt property to disable CLKOUT clock")
Fixes: d90db36a9e74 ("net: phy: realtek: add dt property to enable ALDPS mode")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: stmmac: Fix missing { } around two statements in an if statement
Colin Ian King [Wed, 9 Jun 2021 17:05:12 +0000 (18:05 +0100)]
net: stmmac: Fix missing { } around two statements in an if statement

There are missing { } around a block of code on an if statement. Fix this
by adding them in.

Addresses-Coverity: ("Nesting level does not match indentation")
Fixes: 46682cb86a37 ("net: stmmac: enable Intel mGbE 2.5Gbps link speed")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: ethernet: ti: cpsw-phy-sel: Use devm_platform_ioremap_resource_byname()
Yang Yingliang [Wed, 9 Jun 2021 13:51:38 +0000 (21:51 +0800)]
net: ethernet: ti: cpsw-phy-sel: Use devm_platform_ioremap_resource_byname()

Use the devm_platform_ioremap_resource_byname() helper instead of
calling platform_get_resource_byname() and devm_ioremap_resource()
separately.

Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agoMerge branch 'mvpp2-prefetch'
David S. Miller [Wed, 9 Jun 2021 22:26:50 +0000 (15:26 -0700)]
Merge branch 'mvpp2-prefetch'

Matteo Croce says:

====================
mvpp2: prefetch data early

These two patches prefetch some data from RAM so to reduce stall
and speedup the packet processing.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agomvpp2: prefetch page
Matteo Croce [Wed, 9 Jun 2021 13:47:14 +0000 (15:47 +0200)]
mvpp2: prefetch page

Most of the time during the RX is caused by the compound_head() call
done at the end of the RX loop:

       │     build_skb():
       [...]
       │     static inline struct page *compound_head(struct page *page)
       │     {
       │     unsigned long head = READ_ONCE(page->compound_head);
 65.23 │       ldr  x2, [x1, #8]

Prefetch the page struct as soon as possible, to speedup the RX path
noticeabily by a ~3-4% packet rate in a drop test.

       │     build_skb():
       [...]
       │     static inline struct page *compound_head(struct page *page)
       │     {
       │     unsigned long head = READ_ONCE(page->compound_head);
 17.92 │       ldr  x2, [x1, #8]

Signed-off-by: Matteo Croce <mcroce@microsoft.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agomvpp2: prefetch right address
Matteo Croce [Wed, 9 Jun 2021 13:47:13 +0000 (15:47 +0200)]
mvpp2: prefetch right address

In the RX buffer, the received data starts after a headroom used to
align the IP header and to allow prepending headers efficiently.
The prefetch() should take this into account, and prefetch from
the very start of the received data.

We can see that ether_addr_equal_64bits(), which is the first function
to access the data, drops from the top of the perf top output.

prefetch(data):

Overhead  Shared Object     Symbol
  11.64%  [kernel]          [k] eth_type_trans

prefetch(data + MVPP2_MH_SIZE + MVPP2_SKB_HEADROOM):

Overhead  Shared Object     Symbol
  13.42%  [kernel]          [k] build_skb
  10.35%  [mvpp2]           [k] mvpp2_rx
   9.35%  [kernel]          [k] __netif_receive_skb_core
   8.24%  [kernel]          [k] kmem_cache_free
   7.97%  [kernel]          [k] dev_gro_receive
   7.68%  [kernel]          [k] page_pool_put_page
   7.32%  [kernel]          [k] kmem_cache_alloc
   7.09%  [mvpp2]           [k] mvpp2_bm_pool_put
   3.36%  [kernel]          [k] eth_type_trans

Also, move the eth_type_trans() call a bit down, to give the RAM more
time to prefetch the data.

Signed-off-by: Matteo Croce <mcroce@microsoft.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: ethernet: ti: am65-cpts: Use devm_platform_ioremap_resource_byname()
Yang Yingliang [Wed, 9 Jun 2021 13:45:37 +0000 (21:45 +0800)]
net: ethernet: ti: am65-cpts: Use devm_platform_ioremap_resource_byname()

Use the devm_platform_ioremap_resource_byname() helper instead of
calling platform_get_resource_byname() and devm_ioremap_resource()
separately.

Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: stmmac: Use devm_platform_ioremap_resource_byname()
Yang Yingliang [Wed, 9 Jun 2021 13:36:55 +0000 (21:36 +0800)]
net: stmmac: Use devm_platform_ioremap_resource_byname()

Use the devm_platform_ioremap_resource_byname() helper instead of
calling platform_get_resource_byname() and devm_ioremap_resource()
separately.

Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: sgi: ioc3-eth: check return value after calling platform_get_resource()
Yang Yingliang [Wed, 9 Jun 2021 13:25:15 +0000 (21:25 +0800)]
net: sgi: ioc3-eth: check return value after calling platform_get_resource()

It will cause null-ptr-deref if platform_get_resource() returns NULL,
we need check the return value.

Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agoRevert "nvme-tcp-offload: ULP Series"
Shai Malin [Wed, 9 Jun 2021 10:49:18 +0000 (13:49 +0300)]
Revert "nvme-tcp-offload: ULP Series"

This reverts commits:
762411542050dbe27c7c96f13c57f93da5d9b89a
     nvme: NVME_TCP_OFFLOAD should not default to m
5ff5622ea1f16d535f1be4e478e712ef48fe183b:
     Merge branch 'NVMeTCP-Offload-ULP'

As requested on the mailing-list: https://lore.kernel.org/netdev/SJ0PR18MB3882C20793EA35A3E8DAE300CC379@SJ0PR18MB3882.namprd18.prod.outlook.com/
This patch will revert the nvme-tcp-offload ULP from net-next.

The nvme-tcp-offload ULP series will continue to be considered only on
linux-nvme@lists.infradead.org.

Signed-off-by: Prabhakar Kushwaha <pkushwaha@marvell.com>
Signed-off-by: Michal Kalderon <mkalderon@marvell.com>
Signed-off-by: Ariel Elior <aelior@marvell.com>
Signed-off-by: Shai Malin <smalin@marvell.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: usb: asix: ax88772: Fix less than zero comparison of a u16
Colin Ian King [Wed, 9 Jun 2021 10:24:48 +0000 (11:24 +0100)]
net: usb: asix: ax88772: Fix less than zero comparison of a u16

The comparison of the u16 priv->phy_addr < 0 is always false because
phy_addr is unsigned. Fix this by assigning the return from the call
to function asix_read_phy_addr to int ret and using this for the
less than zero error check comparison.

Fixes: 7e88b11a862a ("net: usb: asix: refactor asix_read_phy_addr() and handle errors on return")
Addresses-Coverity: ("Unsigned compared against 0")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: usb: asix: Fix less than zero comparison of a u16
Colin Ian King [Wed, 9 Jun 2021 10:24:47 +0000 (11:24 +0100)]
net: usb: asix: Fix less than zero comparison of a u16

The comparison of the u16 priv->phy_addr < 0 is always false because
phy_addr is unsigned. Fix this by assigning the return from the call
to function asix_read_phy_addr to int ret and using this for the
less than zero error check comparison.

Addresses-Coverity: ("Unsigned compared against 0")
Fixes: e532a096be0e ("net: usb: asix: ax88772: add phylib support")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agoMerge git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf-next
David S. Miller [Wed, 9 Jun 2021 21:50:35 +0000 (14:50 -0700)]
Merge git://git./linux/kernel/git/pablo/nf-next

Pablo Neira Ayuso says:

====================
Netfilter updates for net-next

The following patchset contains Netfilter updates for net-next:

1) Add nfgenmsg field to nfnetlink's struct nfnl_info and use it.

2) Remove nft_ctx_init_from_elemattr() and nft_ctx_init_from_setattr()
   helper functions.

3) Add the nf_ct_pernet() helper function to fetch the conntrack
   pernetns data area.

4) Expose TCP and UDP flowtable offload timeouts through sysctl,
   from Oz Shlomo.

5) Add nfnetlink_hook subsystem to fetch the netfilter hook
   pipeline configuration, from Florian Westphal. This also includes
   a new field to annotate the hook type as metadata.

6) Fix unsafe memory access to non-linear skbuff in the new SCTP
   chunk support for nft_exthdr, from Phil Sutter.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonetdevsim: delete unnecessary debugfs checking
Dan Carpenter [Wed, 9 Jun 2021 09:56:45 +0000 (12:56 +0300)]
netdevsim: delete unnecessary debugfs checking

In normal situations where the driver doesn't dereference
"nsim_node->ddir" or "nsim_node->rate_parent" itself then we are not
supposed to check the return from debugfs functions.  In the case of
debugfs_create_dir() the check was wrong as well because it doesn't
return NULL, it returns error pointers.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agodevlink: Fix error message in devlink_rate_set_ops_supported()
Dan Carpenter [Wed, 9 Jun 2021 09:54:31 +0000 (12:54 +0300)]
devlink: Fix error message in devlink_rate_set_ops_supported()

The WARN_ON() macro takes a condition, it doesn't take a message.  Use
WARN() instead.

Fixes: 1897db2ec310 ("devlink: Allow setting tx rate for devlink rate leaf objects")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: dsa: qca8k: check the correct variable in qca8k_set_mac_eee()
Dan Carpenter [Wed, 9 Jun 2021 09:53:03 +0000 (12:53 +0300)]
net: dsa: qca8k: check the correct variable in qca8k_set_mac_eee()

This code check "reg" but "ret" was intended so the error handling will
never trigger.

Fixes: 7c9896e37807 ("net: dsa: qca8k: check return value of read functions correctly")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: dsa: qca8k: fix an endian bug in qca8k_get_ethtool_stats()
Dan Carpenter [Wed, 9 Jun 2021 09:52:12 +0000 (12:52 +0300)]
net: dsa: qca8k: fix an endian bug in qca8k_get_ethtool_stats()

The "hi" variable is a u64 but the qca8k_read() writes to the top 32
bits of it.  That will work on little endian systems but it's a bit
subtle.  It's cleaner to make declare "hi" as a u32.  We will still need
to cast it when we shift it later on in the function but that's fine.

Fixes: 7c9896e37807 ("net: dsa: qca8k: check return value of read functions correctly")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agoMerge branch 'lapbther-cleanups'
David S. Miller [Wed, 9 Jun 2021 21:02:58 +0000 (14:02 -0700)]
Merge branch 'lapbther-cleanups'

Peng Li says:

====================
net: lapbether: clean up some code style issues

This patchset clean up some code style issues.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: lapbether: fix the code style issue about line length
Peng Li [Wed, 9 Jun 2021 09:39:55 +0000 (17:39 +0800)]
net: lapbether: fix the code style issue about line length

According to the chackpatch.pl,
line length of 123 exceeds 100 columns, so fix it.

Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: lapbether: fix the alignment issue
Peng Li [Wed, 9 Jun 2021 09:39:54 +0000 (17:39 +0800)]
net: lapbether: fix the alignment issue

Alignment should match open parenthesis.

Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: lapbether: replace comparison to NULL with "lapbeth_get_x25_dev"
Peng Li [Wed, 9 Jun 2021 09:39:53 +0000 (17:39 +0800)]
net: lapbether: replace comparison to NULL with "lapbeth_get_x25_dev"

According to the chackpatch.pl, comparison to NULL could
be written "lapbeth_get_x25_dev".

Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: lapbether: fix the comments style issue
Peng Li [Wed, 9 Jun 2021 09:39:52 +0000 (17:39 +0800)]
net: lapbether: fix the comments style issue

Networking block comments don't use an empty /* line,
use /* Comment...

Block comments use * on subsequent lines.
Block comments use a trailing */ on a separate line.

This patch fixes the comments style issues.

Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: lapbether: remove unnecessary out of memory message
Peng Li [Wed, 9 Jun 2021 09:39:51 +0000 (17:39 +0800)]
net: lapbether: remove unnecessary out of memory message

This patch removes unnecessary out of memory message,
to fix the following checkpatch.pl warning:
"WARNING: Possible unnecessary 'out of memory' message"

Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: lapbether: remove trailing whitespaces
Peng Li [Wed, 9 Jun 2021 09:39:50 +0000 (17:39 +0800)]
net: lapbether: remove trailing whitespaces

This patch removes trailing whitespaces.

Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: lapbether: move out assignment in if condition
Peng Li [Wed, 9 Jun 2021 09:39:49 +0000 (17:39 +0800)]
net: lapbether: move out assignment in if condition

Should not use assignment in if condition.

Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: lapbether: add blank line after declarations
Peng Li [Wed, 9 Jun 2021 09:39:48 +0000 (17:39 +0800)]
net: lapbether: add blank line after declarations

This patch fixes the checkpatch error about missing a blank line
after declarations.

Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: lapbether: remove redundant blank line
Peng Li [Wed, 9 Jun 2021 09:39:47 +0000 (17:39 +0800)]
net: lapbether: remove redundant blank line

This patch the redundant blank line.

Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: hns3: use list_move_tail instead of list_del/list_add_tail in hclge_main.c
Baokun Li [Wed, 9 Jun 2021 07:20:56 +0000 (15:20 +0800)]
net: hns3: use list_move_tail instead of list_del/list_add_tail in hclge_main.c

Using list_move_tail() instead of list_del() + list_add_tail() in hclge_main.c.

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Baokun Li <libaokun1@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: hns3: use list_move_tail instead of list_del/list_add_tail in hclgevf_main.c
Baokun Li [Wed, 9 Jun 2021 07:17:20 +0000 (15:17 +0800)]
net: hns3: use list_move_tail instead of list_del/list_add_tail in hclgevf_main.c

Using list_move_tail() instead of list_del() + list_add_tail() in hclgevf_main.c.

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Baokun Li <libaokun1@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonfp: use list_move instead of list_del/list_add in nfp_cppcore.c
Baokun Li [Wed, 9 Jun 2021 07:09:21 +0000 (15:09 +0800)]
nfp: use list_move instead of list_del/list_add in nfp_cppcore.c

Using list_move() instead of list_del() + list_add() in nfp_cppcore.c.

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Baokun Li <libaokun1@huawei.com>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet/x25: fix a mistake in grammar
gushengxian [Wed, 9 Jun 2021 03:03:17 +0000 (20:03 -0700)]
net/x25: fix a mistake in grammar

Fix a mistake in grammar.

Signed-off-by: gushengxian <gushengxian@yulong.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: ethernet: ravb: Use devm_platform_get_and_ioremap_resource()
Yang Yingliang [Wed, 9 Jun 2021 01:24:44 +0000 (09:24 +0800)]
net: ethernet: ravb: Use devm_platform_get_and_ioremap_resource()

Use devm_platform_get_and_ioremap_resource() to simplify
code.

Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Reviewed-by: Sergei Shtylyov <sergei.shtylyov@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: dsa: b53: Do not force CPU to be always tagged
Florian Fainelli [Tue, 8 Jun 2021 21:22:04 +0000 (14:22 -0700)]
net: dsa: b53: Do not force CPU to be always tagged

Commit ca8931948344 ("net: dsa: b53: Keep CPU port as tagged in all
VLANs") forced the CPU port to be always tagged in any VLAN membership.
This was necessary back then because we did not support Broadcom tags
for all configurations so the only way to differentiate tagged and
untagged traffic while DSA_TAG_PROTO_NONE was used was to force the CPU
port into being always tagged.

With most configurations enabling Broadcom tags, especially after
8fab459e69ab ("net: dsa: b53: Enable Broadcom tags for 531x5/539x
families") we do not need to apply this unconditional force tagging of
the CPU port in all VLANs.

A helper function is introduced to faciliate the encapsulation of the
specific condition requiring the CPU port to be tagged in all VLANs and
the dsa_switch_ops::untag_bridge_pvid boolean is moved to when
dsa_switch_ops::setup is called when we have already determined the
tagging protocol we will be using.

Reported-by: Matthew Hagan <mnhagan88@gmail.com>
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
Tested-by: Matthew Hagan <mnhagan88@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonetfilter: nf_tables: move base hook annotation to init helper
Florian Westphal [Tue, 8 Jun 2021 21:06:07 +0000 (23:06 +0200)]
netfilter: nf_tables: move base hook annotation to init helper

coverity scanner says:
2187  if (nft_is_base_chain(chain)) {
vvv   CID 1505166:  Memory - corruptions  (UNINIT)
vvv   Using uninitialized value "basechain".
2188  basechain->ops.hook_ops_type = NF_HOOK_OP_NF_TABLES;

... I don't see how nft_is_base_chain() can evaluate to true
while basechain pointer is garbage.

However, it seems better to place the NF_HOOK_OP_NF_TABLES annotation
in nft_basechain_hook_init() instead.

Reported-by: coverity-bot <keescook+coverity-bot@chromium.org>
Addresses-Coverity-ID: 1505166 ("Memory - corruptions")
Fixes: 65b8b7bfc5284f ("netfilter: annotate nf_tables base hook ops")
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
3 years agonetfilter: nfnetlink_hook: add depends-on nftables
Florian Westphal [Tue, 8 Jun 2021 20:53:22 +0000 (22:53 +0200)]
netfilter: nfnetlink_hook: add depends-on nftables

nfnetlink_hook.c: In function 'nfnl_hook_put_nft_chain_info':
nfnetlink_hook.c:76:7: error: implicit declaration of 'nft_is_active'

This macro is only defined when NF_TABLES is enabled.
While its possible to also add an ifdef-guard, the infrastructure
is currently not useful without nf_tables.

Reported-by: kernel test robot <lkp@intel.com>
Fixes: 252956528caa ("netfilter: add new hook nfnl subsystem")
Suggested-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
3 years agonetfilter: nfnetlink_hook: fix array index out-of-bounds error
Colin Ian King [Tue, 8 Jun 2021 15:34:08 +0000 (16:34 +0100)]
netfilter: nfnetlink_hook: fix array index out-of-bounds error

Currently the array net->nf.hooks_ipv6 is accessed by index hook
before hook is sanity checked. Fix this by moving the sanity check
to before the array access.

Addresses-Coverity: ("Out-of-bounds access")
Fixes: e2cf17d3774c ("netfilter: add new hook nfnl subsystem")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
3 years agonet: appletalk: fix some mistakes in grammar
gushengxian [Wed, 9 Jun 2021 01:52:57 +0000 (18:52 -0700)]
net: appletalk: fix some mistakes in grammar

Fix some mistakes in grammar.

Signed-off-by: gushengxian <gushengxian@yulong.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonetfilter: nft_exthdr: Fix for unsafe packet data read
Phil Sutter [Tue, 8 Jun 2021 09:40:57 +0000 (11:40 +0200)]
netfilter: nft_exthdr: Fix for unsafe packet data read

While iterating through an SCTP packet's chunks, skb_header_pointer() is
called for the minimum expected chunk header size. If (that part of) the
skbuff is non-linear, the following memcpy() may read data past
temporary buffer '_sch'. Use skb_copy_bits() instead which does the
right thing in this situation.

Fixes: 133dc203d77df ("netfilter: nft_exthdr: Support SCTP chunks")
Suggested-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Phil Sutter <phil@nwl.cc>
Reviewed-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
3 years agonet: stmmac: explicitly deassert GMAC_AHB_RESET
Matthew Hagan [Tue, 8 Jun 2021 18:59:06 +0000 (19:59 +0100)]
net: stmmac: explicitly deassert GMAC_AHB_RESET

We are currently assuming that GMAC_AHB_RESET will already be deasserted
by the bootloader. However if this has not been done, probing of the GMAC
will fail. To remedy this we must ensure GMAC_AHB_RESET has been deasserted
prior to probing.

v2 changes:
 - remove NULL condition check for stmmac_ahb_rst in stmmac_main.c
 - unwrap dev_err() message in stmmac_main.c
 - add PTR_ERR() around plat->stmmac_ahb_rst in stmmac_platform.c

v3 changes:
 - add error pointer to dev_err() output
 - add reset_control_assert(stmmac_ahb_rst) in stmmac_dvr_remove
 - revert PTR_ERR() around plat->stmmac_ahb_rst since this is performed
   on the returned value of ret by the calling function

Signed-off-by: Matthew Hagan <mnhagan88@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agosh_eth: Use devm_platform_get_and_ioremap_resource()
Yang Yingliang [Tue, 8 Jun 2021 13:57:18 +0000 (21:57 +0800)]
sh_eth: Use devm_platform_get_and_ioremap_resource()

Use devm_platform_get_and_ioremap_resource() to simplify
code.

Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Reviewed-by: Sergei Shtylyov <sergei.shtylyov@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: nixge: simplify code with devm platform functions
Yang Yingliang [Tue, 8 Jun 2021 13:56:22 +0000 (21:56 +0800)]
net: nixge: simplify code with devm platform functions

Use devm_platform_get_and_ioremap_resource() and
devm_platform_ioremap_resource_byname to simplify
code.

Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: dsa: felix: set TX flow control according to the phylink_mac_link_up resolution
Vladimir Oltean [Tue, 8 Jun 2021 11:16:51 +0000 (14:16 +0300)]
net: dsa: felix: set TX flow control according to the phylink_mac_link_up resolution

Instead of relying on the static initialization done by ocelot_init_port()
which enables flow control unconditionally, set SYS_PAUSE_CFG_PAUSE_ENA
according to the parameters negotiated by the PHY.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: x25: Use list_for_each_entry() to simplify code in x25_forward.c
Wang Hai [Tue, 8 Jun 2021 13:30:07 +0000 (13:30 +0000)]
net: x25: Use list_for_each_entry() to simplify code in x25_forward.c

Convert list_for_each() to list_for_each_entry() where
applicable. This simplifies the code.

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Wang Hai <wanghai38@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agoethernet/qlogic: Use list_for_each_entry() to simplify code in qlcnic_hw.c
Wang Hai [Tue, 8 Jun 2021 13:29:08 +0000 (13:29 +0000)]
ethernet/qlogic: Use list_for_each_entry() to simplify code in qlcnic_hw.c

Convert list_for_each() to list_for_each_entry() where
applicable. This simplifies the code.

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Wang Hai <wanghai38@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: stmmac: fix NPD with phylink_set_pcs if there is no MDIO bus
Vladimir Oltean [Tue, 8 Jun 2021 13:10:37 +0000 (16:10 +0300)]
net: stmmac: fix NPD with phylink_set_pcs if there is no MDIO bus

priv->plat->mdio_bus_data is optional, some platforms may not set it,
however we proceed to look straight at priv->plat->mdio_bus_data->has_xpcs.

Since the xpcs is instantiated based on the has_xpcs property, we can
avoid looking at the priv->plat->mdio_bus_data structure altogether and
just check for the presence of the xpcs pointer.

Fixes: 11059740e616 ("net: pcs: xpcs: convert to phylink_pcs_ops")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: lapb: Use list_for_each_entry() to simplify code in lapb_iface.c
Wang Hai [Tue, 8 Jun 2021 08:13:01 +0000 (08:13 +0000)]
net: lapb: Use list_for_each_entry() to simplify code in lapb_iface.c

Convert list_for_each() to list_for_each_entry() where
applicable. This simplifies the code.

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Wang Hai <wanghai38@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: x25: Use list_for_each_entry() to simplify code in x25_link.c
Wang Hai [Tue, 8 Jun 2021 08:05:05 +0000 (08:05 +0000)]
net: x25: Use list_for_each_entry() to simplify code in x25_link.c

Convert list_for_each() to list_for_each_entry() where
applicable. This simplifies the code.

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Wang Hai <wanghai38@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: qede: Use list_for_each_entry() to simplify code
Wang Hai [Tue, 8 Jun 2021 07:57:37 +0000 (07:57 +0000)]
net: qede: Use list_for_each_entry() to simplify code

Convert list_for_each() to list_for_each_entry() where
applicable. This simplifies the code.

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Wang Hai <wanghai38@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agoMerge branch 'hns3-RAS'
David S. Miller [Tue, 8 Jun 2021 21:43:31 +0000 (14:43 -0700)]
Merge branch 'hns3-RAS'

Guangbin Huang says:

====================
net: hns3: add RAS compatibility adaptation solution

This patchset adds RAS compatibility adaptation solution for new devices.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: hns3: add error handling compatibility during initialization
Jiaran Zhang [Tue, 8 Jun 2021 13:08:31 +0000 (21:08 +0800)]
net: hns3: add error handling compatibility during initialization

During initialization, the driver logs and clears the hw errors that
already occurred. For device supports imp-handle ras capability, it
needs handle different error status, otherwise it may cause wrong reset.

So fix it by adding a new processing branch.

Signed-off-by: Jiaran Zhang <zhangjiaran@huawei.com>
Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: hns3: update error recovery module and type
Jiaran Zhang [Tue, 8 Jun 2021 13:08:30 +0000 (21:08 +0800)]
net: hns3: update error recovery module and type

Update error recovery module and type for RoCE.

The enumeration values of module names and error types are not sorted
in sequence. If use the current printing mode, they cannot be correctly
printed.

Use the index mode, If mod_id and type_id match the enumerated value,
display the corresponding information.

Signed-off-by: Jiaran Zhang <zhangjiaran@huawei.com>
Signed-off-by: Weihang Li <liweihang@huawei.com>
Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: hns3: add support for imp-handle ras capability
Jiaran Zhang [Tue, 8 Jun 2021 13:08:29 +0000 (21:08 +0800)]
net: hns3: add support for imp-handle ras capability

IMP(Intelligent Management Processor) firmware add a new feature to
handle and consolidate RAS information for new devices, NIC driver
only needs to query the reported RAS information. NIC driver adds
support for this feature.

Driver queries device capability to check whether IMP support this
feature, If yes, execute the new RAS processing branch.

In order to add a method to check whether PF supports imp-handle RAS
feature, add dumping this info in debugfs.

Signed-off-by: Jiaran Zhang <zhangjiaran@huawei.com>
Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: hns3: add the RAS compatibility adaptation solution
Jiaran Zhang [Tue, 8 Jun 2021 13:08:28 +0000 (21:08 +0800)]
net: hns3: add the RAS compatibility adaptation solution

To adapt to hardware modification and ensure that the driver is
compatible with the original error handling content, we need to add the
RAS compatibility adaptation solution.

Add a processing branch to the driver during error handling. In the new
processing branch, NIC fault information is integrated by the IMP. An
interaction command is added between the driver and IMP to query
and clear the fault source and interrupt source. The IMP integrates
error information and reports the highest reset level to the driver.

Signed-off-by: Jiaran Zhang <zhangjiaran@huawei.com>
Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: hns3: add support for handling all errors through MSI-X
Yufeng Mo [Tue, 8 Jun 2021 13:08:27 +0000 (21:08 +0800)]
net: hns3: add support for handling all errors through MSI-X

Currently, hardware errors can be reported through AER or MSI-X mode.
However, the AER mode is intended to handle only bus errors, but not
hardware errors. On the other hand, virtual machines cannot handle
AER errors. When an AER error is reported, virtual machines will be
suspended. So add support for handling all these hardware errors
through MSI-X mode which depends on a newer version of firmware,
and reserve the handler of the AER mode for compatibility.

Signed-off-by: Yufeng Mo <moyufeng@huawei.com>
Signed-off-by: Jiaran Zhang <zhangjiaran@huawei.com>
Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agoMerge branch 'ena-updates'
David S. Miller [Tue, 8 Jun 2021 21:41:10 +0000 (14:41 -0700)]
Merge branch 'ena-updates'

Shay Agroskin says:

====================
se build_skb and reorganize some code in ENA

this patchset introduces several changes:

- Use build_skb() on RX side.
  This allows to ensure that the headers are in the linear part

- Batch some code into functions and remove some of the code to make it more
  readable and less error prone

- Fix RST format and outdated description in ENA documentation

- Improve cache alignment in the code
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: ena: re-organize code to improve readability
Shay Agroskin [Tue, 8 Jun 2021 16:01:18 +0000 (19:01 +0300)]
net: ena: re-organize code to improve readability

Restructure some ethtool to a switch-case blocks to make it more uniform
with other similar functions.
Also restructure variable declaration to create reversed x-mas tree.

Signed-off-by: Arthur Kiyanovski <akiyano@amazon.com>
Signed-off-by: Shay Agroskin <shayagr@amazon.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: ena: Use dev_alloc() in RX buffer allocation
Shay Agroskin [Tue, 8 Jun 2021 16:01:17 +0000 (19:01 +0300)]
net: ena: Use dev_alloc() in RX buffer allocation

Use dev_alloc() when allocating RX buffers instead of specifying the
allocation flags explicitly. This result in same behaviour with less
code.

Also move the page allocation and its DMA mapping into a function. This
creates a logical block, which may help understanding the code.

Signed-off-by: Shay Agroskin <shayagr@amazon.com>
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: ena: aggregate doorbell common operations into a function
Shay Agroskin [Tue, 8 Jun 2021 16:01:16 +0000 (19:01 +0300)]
net: ena: aggregate doorbell common operations into a function

The ena_ring_tx_doorbell() is introduced to call the doorbell and
increase the driver's corresponding stat.

Signed-off-by: Ido Segev <idose@amazon.com>
Signed-off-by: Shay Agroskin <shayagr@amazon.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: ena: fix RST format in ENA documentation file
Shay Agroskin [Tue, 8 Jun 2021 16:01:15 +0000 (19:01 +0300)]
net: ena: fix RST format in ENA documentation file

The documentation file used to be written in markdown format but was
converted to reStructuredText (rst).

The converted file doesn't keep up with rst format requirements which
results in hard-to-read text.

This patch fixes the formatting of the file. The patch also
* Highlights and emphasizes some lines to improve readability
* Rephrases some hard-to-understand text
* Updates outdated function descriptions.
* Removes TSO description which falsely claims the driver supports it

Signed-off-by: Shay Agroskin <shayagr@amazon.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: ena: Remove module param and change message severity
Shay Agroskin [Tue, 8 Jun 2021 16:01:14 +0000 (19:01 +0300)]
net: ena: Remove module param and change message severity

Remove the module param 'debug' which allows to specify the message
level of the driver. This value can be specified using ethtool command.
Also reduce the message level of LLQ support to be a warning since it is
not an indication of an error.

Signed-off-by: Arthur Kiyanovski <akiyano@amazon.com>
Signed-off-by: Shay Agroskin <shayagr@amazon.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: ena: add jiffies of last napi call to stats
Shay Agroskin [Tue, 8 Jun 2021 16:01:13 +0000 (19:01 +0300)]
net: ena: add jiffies of last napi call to stats

There are instances when we want to know when the last napi was
called for debugging.

On stuck / heavy loaded CPUs, the ena napi handler might not be
called for a long period of time. This stat can help us to
determine how much time passed since the last execution of napi.

Signed-off-by: Sameeh Jubran <sameehj@amazon.com>
Signed-off-by: Shay Agroskin <shayagr@amazon.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: ena: use build_skb() in RX path
Shay Agroskin [Tue, 8 Jun 2021 16:01:12 +0000 (19:01 +0300)]
net: ena: use build_skb() in RX path

This patch converts the RX path to use build_skb() for packets larger
than copybreak (set to 256 by default). This function makes the first
descriptor's page to be the linear part of the sk_buff struct buffer.

Also remove the SKB description from the README since most of it no
longer relevant and the parts that are left don't add information.

Signed-off-by: Shay Agroskin <shayagr@amazon.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: ena: Improve error logging in driver
Shay Agroskin [Tue, 8 Jun 2021 16:01:11 +0000 (19:01 +0300)]
net: ena: Improve error logging in driver

Add prints to improve logging of driver's errors.

Signed-off-by: Arthur Kiyanovski <akiyano@amazon.com>
Signed-off-by: Shay Agroskin <shayagr@amazon.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: ena: Remove unused code
Shay Agroskin [Tue, 8 Jun 2021 16:01:10 +0000 (19:01 +0300)]
net: ena: Remove unused code

The ENA_DEFAULT_MIN_RX_BUFF_ALLOC_SIZE macro,
ena_xdp_queues_present() function and SUSPEND_RESUME enums aren't used
in the driver, and so not needed.

Signed-off-by: Arthur Kiyanovski <akiyano@amazon.com>
Signed-off-by: Gal Pressman <galpress@amazon.com>
Signed-off-by: Sameeh Jubran <sameehj@amazon.com>
Signed-off-by: Shay Agroskin <shayagr@amazon.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: ena: optimize data access in fast-path code
Shay Agroskin [Tue, 8 Jun 2021 16:01:09 +0000 (19:01 +0300)]
net: ena: optimize data access in fast-path code

This tweaks several small places to improve the data access in fast
path:

* Remove duplicates of first_interrupt flag and surround it with
  WRITE/READ_ONCE macros:

  The flag is used to detect HW disorders in its
  interrupt communication with the driver. The flag is set when an
  interrupt is received and used in the health check function
  (ena_timer_service()) to help it find irregularities.

* Reorder some fields in ena_napi struct to take better advantage of
  cache access pattern.

* Move XDP TX queue number to a variable to save its calculation for
  every packet.

* Use likely in a condition to improve branch prediction

The 'first_interrupt' and 'interrupt_masked' flags were moved to reside
in the same cache line as the first fields of 'napi' struct. This
placement ensures that all memory accessed during upper-half handler
reside in the same cacheline (napi_schedule_irqoff() only accesses
'state' and 'poll_list' fields which are at the beginning of napi
struct).

Signed-off-by: Sameeh Jubran <sameehj@amazon.com>
Signed-off-by: Shay Agroskin <shayagr@amazon.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agoMerge branch 'mlxsw-various-updates'
David S. Miller [Tue, 8 Jun 2021 21:39:07 +0000 (14:39 -0700)]
Merge branch 'mlxsw-various-updates'

Ido Schimmel says:

====================
mlxsw: Various updates

This patchset contains various updates for mlxsw. The most significant
change is the long overdue removal of the abort mechanism in the first
two patches.

Patches #1-#2 remove the route abort mechanism. This change is long
overdue and explained in detail in the commit message.

Patch #3 sets ports down in a few selftests that forgot to do so.
Discovered using a BPF tool (WIP) that monitors ASIC resources.

Patch #4 fixes an issue introduced by commit 557c4d2f780c ("selftests:
devlink_lib: add check for devlink device existence").

Patches #5-#8 modify the driver to read transceiver module's temperature
thresholds using MTMP register (when supported) instead of directly from
the module's EEPROM using MCIA register. This is both more reliable and
more efficient as now the module's temperature and thresholds are read
using one transaction instead of three.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agomlxsw: thermal: Read module temperature thresholds using MTMP register
Mykola Kostenok [Tue, 8 Jun 2021 12:44:14 +0000 (15:44 +0300)]
mlxsw: thermal: Read module temperature thresholds using MTMP register

mlxsw_thermal_module_trips_update() is used to update the trip points of
the module's thermal zone. Currently, this is done by querying the
thresholds from the module's EEPROM via MCIA register. This data does
not pass validation and in some cases can be unreliable. For example,
due to some problem with transceiver module.

Previous patch made it possible to read module's temperature and
thresholds via MTMP register. Therefore, extend
mlxsw_thermal_module_trips_update() to use the thresholds queried from
MTMP, if valid.

This is both more reliable and more efficient than current method, as
temperature and thresholds are queried in one transaction instead of
three. This is significant when working over a slow bus such as I2C.

Signed-off-by: Mykola Kostenok <c_mykolak@nvidia.com>
Acked-by: Vadim Pasternak <vadimp@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agomlxsw: thermal: Add function for reading module temperature and thresholds
Mykola Kostenok [Tue, 8 Jun 2021 12:44:13 +0000 (15:44 +0300)]
mlxsw: thermal: Add function for reading module temperature and thresholds

Provide new function mlxsw_thermal_module_temp_and_thresholds_get() for
reading temperature and temperature thresholds by a single operation.
The motivation is to reduce the number of transactions with the device
which is important when operating over a slow bus such as I2C.

Currently, the sole caller of the function is only using it to read the
module's temperature. The next patch will also use it to query the
module's temperature thresholds.

Signed-off-by: Mykola Kostenok <c_mykolak@nvidia.com>
Acked-by: Vadim Pasternak <vadimp@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agomlxsw: core_env: Read module temperature thresholds using MTMP register
Mykola Kostenok [Tue, 8 Jun 2021 12:44:12 +0000 (15:44 +0300)]
mlxsw: core_env: Read module temperature thresholds using MTMP register

Currently, module temperature thresholds are obtained from Management
Cable Info Access (MCIA) register by specifying the thresholds offsets
within module EEPROM layout. This data does not pass validation and in
some cases can be unreliable. For example, due to some problem with the
module.

Add support for a new feature provided by Management Temperature (MTMP)
register for sanitization of temperature thresholds values.

Extend mlxsw_env_module_temp_thresholds_get() to get temperature
thresholds through MTMP field 'max_operational_temperature' - if it is
not zero, feature is supported. Otherwise fallback to old method and get
the thresholds through MCIA.

Signed-off-by: Mykola Kostenok <c_mykolak@nvidia.com>
Acked-by: Vadim Pasternak <vadimp@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agomlxsw: reg: Extend MTMP register with new threshold field
Mykola Kostenok [Tue, 8 Jun 2021 12:44:11 +0000 (15:44 +0300)]
mlxsw: reg: Extend MTMP register with new threshold field

Extend Management Temperature (MTMP) register with new field specifying
the maximum temperature threshold.

Extend mlxsw_reg_mtmp_unpack() function with two extra arguments,
providing high and maximum temperature thresholds. For modules, these
thresholds correspond to critical and emergency thresholds that are read
from the module's EEPROM.

Signed-off-by: Mykola Kostenok <c_mykolak@nvidia.com>
Acked-by: Vadim Pasternak <vadimp@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agoselftests: devlink_lib: Fix bouncing of netdevsim DEVLINK_DEV
Petr Machata [Tue, 8 Jun 2021 12:44:10 +0000 (15:44 +0300)]
selftests: devlink_lib: Fix bouncing of netdevsim DEVLINK_DEV

In the commit referenced below, a check was added to devlink_lib that
asserts the existence of a devlink device referenced by $DEVLINK_DEV.
Unfortunately, several netdevsim tests point DEVLINK_DEV at a device that
does not exist at the time that devlink_lib is sourced. Thus these tests
spuriously fail.

Fix this by introducing an override. By setting DEVLINK_DEV to an empty
string, the user declares their intention to handle DEVLINK_DEV management
on their own.

In all netdevsim tests that use devlink_lib and set DEVLINK_DEV, set
instead an empty DEVLINK_DEV just before sourcing devlink_lib, and set it
to the correct value right afterwards.

Fixes: 557c4d2f780c ("selftests: devlink_lib: add check for devlink device existence")
Signed-off-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agoselftests: Clean forgotten resources as part of cleanup()
Amit Cohen [Tue, 8 Jun 2021 12:44:09 +0000 (15:44 +0300)]
selftests: Clean forgotten resources as part of cleanup()

Several tests do not set some ports down as part of their cleanup(),
resulting in IPv6 link-local addresses and associated routes not being
deleted.

These leaks were found using a BPF tool that monitors ASIC resources.

Solve this by setting the ports down at the end of the tests.

Signed-off-by: Amit Cohen <amcohen@nvidia.com>
Reviewed-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agoselftests: router_scale: Do not count failed routes
Amit Cohen [Tue, 8 Jun 2021 12:44:08 +0000 (15:44 +0300)]
selftests: router_scale: Do not count failed routes

To check how many routes are installed in hardware, the test runs "ip
route" and greps for "offload", which includes routes with state
"offload_failed".

Till now, this wrong check was not found because after one failure in
route insertion, the driver moved to "abort" mode, which means that user
cannot try to add more routes.

The previous patch removed the abort mechanism and now failed routes are
counted as offloaded.

Fix this by not considering routes with "offload_failed" flag as
offloaded.

Signed-off-by: Amit Cohen <amcohen@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agomlxsw: spectrum_router: Remove abort mechanism
Amit Cohen [Tue, 8 Jun 2021 12:44:07 +0000 (15:44 +0300)]
mlxsw: spectrum_router: Remove abort mechanism

The abort mechanism was introduced in commit 8e05fd7166c6 ("fib: hook
IPv4 fib for hardware offload") with the purpose of falling back to
software-based routing in case of a route programming error in hardware.
The process is irreversible and requires users to reload the offloading
driver or reboot the machine.

While this approach might make sense in theory, it makes very little
sense in practice. In the case of high speed ASICs such as the Spectrum
ASIC, the abort mechanism effectively kills the machine upon a non-fatal
error such as a route programming error.

Such an extreme policy does not belong in the kernel, especially when
user space can simply try to reprogram the route following the
RTM_NEWROUTE failure notification.

Therefore, remove the abort mechanism.

Signed-off-by: Amit Cohen <amcohen@nvidia.com>
Reviewed-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agoMerge branch 'dsa-sja1110'
David S. Miller [Tue, 8 Jun 2021 21:37:16 +0000 (14:37 -0700)]
Merge branch 'dsa-sja1110'

Vladimir Oltean says:

====================
Add NXP SJA1110 support to the sja1105 DSA driver

The NXP SJA1110 is an automotive Ethernet switch with an embedded Arm
Cortex-M7 microcontroller. The switch has 11 ports (10 external + one
for the DSA-style connection to the microcontroller).
The microcontroller can be disabled and the switch can be controlled
over SPI, a la SJA1105 - this is how this driver handles things.

There are some integrated NXP PHYs (100base-T1 and 100base-TX). Their
initialization is handled by their own PHY drivers, the switch is only
concerned with enabling register accesses to them, by registering two
MDIO buses.

Changes in v3:
- Make sure the VLAN retagging port is enabled and functional
- Dropped SGMII PCS from this series

Changes in v2:
- converted nxp,sja1105 DT bindings to YAML
- registered the PCS MDIO bus and forced auto-probing off for all PHY
  addresses for this bus
- changed the container node name for the 2 MDIO buses from "mdio" to
  "mdios" to avoid matching on the mdio.yaml schema (it's just a
  container node, not an MDIO bus)
- fixed an uninitialized "offset" variable usage in
  sja1110_pcs_mdio_{read,write}
- using the mdiobus_c45_addr macro instead of open-coding that operation
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: dsa: sja1105: register the MDIO buses for 100base-T1 and 100base-TX
Vladimir Oltean [Tue, 8 Jun 2021 09:25:38 +0000 (12:25 +0300)]
net: dsa: sja1105: register the MDIO buses for 100base-T1 and 100base-TX

The SJA1110 contains two types of integrated PHYs: one 100base-TX PHY
and multiple 100base-T1 PHYs.

The access procedure for the 100base-T1 PHYs is also different than it
is for the 100base-TX one. So we register 2 MDIO buses, one for the
base-TX and the other for the base-T1. Each bus has an OF node which is
a child of the "mdio" subnode of the switch, and they are recognized by
compatible string.

Cc: Russell King <linux@armlinux.org.uk>
Cc: Heiner Kallweit <hkallweit1@gmail.com>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: devicetree@vger.kernel.org
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: dsa: sja1105: make sure the retagging port is enabled for SJA1110
Vladimir Oltean [Tue, 8 Jun 2021 09:25:37 +0000 (12:25 +0300)]
net: dsa: sja1105: make sure the retagging port is enabled for SJA1110

The SJA1110 has an extra configuration in the General Parameters Table
through which the user can select the buffer reservation config.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: dsa: sja1105: add support for the SJA1110 switch family
Vladimir Oltean [Tue, 8 Jun 2021 09:25:36 +0000 (12:25 +0300)]
net: dsa: sja1105: add support for the SJA1110 switch family

The SJA1110 is basically an SJA1105 with more ports, some integrated
PHYs (100base-T1 and 100base-TX) and an embedded microcontroller which
can be disabled, and the switch core can be controlled by a host running
Linux, over SPI.

This patch contains:
- the static and dynamic config packing functions, for the tables that
  are common with SJA1105
- one more static config tables which is "unique" to the SJA1110
  (actually it is a rehash of stuff that was placed somewhere else in
  SJA1105): the PCP Remapping Table
- a reset and clock configuration procedure for the SJA1110 switch.
  This resets just the switch subsystem, and gates off the clock which
  powers on the embedded microcontroller.
- an RGMII delay configuration procedure for SJA1110, which is very
  similar to SJA1105, but different enough for us to be unable to reuse
  it (this is a pattern that repeats itself)
- some adaptations to dynamic config table entries which are no longer
  programmed in the same way. For example, to delete a VLAN, you used to
  write an entry through the dynamic reconfiguration interface with the
  desired VLAN ID, and with the VALIDENT bit set to false. Now, the VLAN
  table entries contain a TYPE_ENTRY field, which must be set to zero
  (in a backwards-incompatible way) in order for the entry to be deleted,
  or to some other entry for the VLAN to match "inner tagged" or "outer
  tagged" packets.
- a similar thing for the static config: the xMII Mode Parameters Table
  encoding for SGMII and MII (the latter just when attached to a
  100base-TX PHY) just isn't what it used to be in SJA1105. They are
  identical, except there is an extra "special" bit which needs to be
  set. Set it.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agodt-bindings: net: dsa: sja1105: add SJA1110 bindings
Vladimir Oltean [Tue, 8 Jun 2021 09:25:35 +0000 (12:25 +0300)]
dt-bindings: net: dsa: sja1105: add SJA1110 bindings

There are 4 variations of the SJA1110 switch which have a different set
of MII protocols supported per port. Document the compatible strings.

Also, the SJA1110 optionally supports 2 internal MDIO buses for 2
different types of Ethernet PHYs. Document a container node called
"mdios" which has 2 subnodes "mdio@0" and "mdio@1", identifiable via
compatible string, under which the driver finds the internal PHYs.

Cc: Rob Herring <robh+dt@kernel.org>
Cc: devicetree@vger.kernel.org
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agoMerge branch 'wwan-improvements'
David S. Miller [Tue, 8 Jun 2021 21:33:44 +0000 (14:33 -0700)]
Merge branch 'wwan-improvements'

Sergey Ryazanov says:

====================
net: WWAN subsystem improvements

While working on WWAN netdev creation support, I notice a few things
that could be done to make the wwan subsystem more developer and user
friendly. This series implements them.

The series begins with a WWAN HW simulator designed simplify testing
and make the WWAN subsystem available for a wider audience. The next two
patches are intended to make the code a bit more clearer. This is
followed by a few patches to make the port device naming more
user-friendly. The series is finishes with a set of changes that allow
the WWAN AT port to be used with terminal emulation software.

All changes were tested with the HW simulator that was introduced in
this series, as well as with a Huawei E3372 LTE modem (a CDC-NCM
device), which I finally found on my desk.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: wwan: core: purge rx queue on port close
Sergey Ryazanov [Tue, 8 Jun 2021 04:02:41 +0000 (07:02 +0300)]
net: wwan: core: purge rx queue on port close

Purge the rx queue as soon as a user closes the port, just after the
port stop callback invocation. This is to prevent feeding a user that
will open the port next time with outdated and possibly unrelated
data.

While at it also remove the odd skb_queue_purge() call in the port
device destroy callback. The queue will be purged just before the
callback is ivoncated in the wwan_remove_port() function.

Signed-off-by: Sergey Ryazanov <ryazanov.s.a@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: wwan: core: implement terminal ioctls for AT port
Sergey Ryazanov [Tue, 8 Jun 2021 04:02:40 +0000 (07:02 +0300)]
net: wwan: core: implement terminal ioctls for AT port

It is not unreasonable to assume that users will use terminal emulation
software to communicate directly with a WWAN device over the AT port.
But terminal emulators  will refuse to work with a device that does not
support terminal IOCTLs (e.g. TCGETS, TCSETS, TIOCMSET, etc.). To make
it possible to interact with the WWAN AT port using a terminal emulator,
implement a minimal set of terminal IOCTLs.

The implementation is rather stub, no passed data are actually used to
control a port behaviour. An obtained configuration is kept inside the
port structure and returned back by a request. The latter is done to
fool a program that will test the configuration status by comparing the
readed back data from the device with earlier configured ones.

Tested with fresh versions of minicom and picocom terminal apps.

MBIM, QMI and other ports for binary protocols can hardly be considered
a terminal device, so terminal IOCTLs are only implemented for the AT
port.

Signed-off-by: Sergey Ryazanov <ryazanov.s.a@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: wwan: core: implement TIOCINQ ioctl
Sergey Ryazanov [Tue, 8 Jun 2021 04:02:39 +0000 (07:02 +0300)]
net: wwan: core: implement TIOCINQ ioctl

It is quite common for a userpace program to fetch the buffered amount
of data in the rx queue to avoid the read block. Implement the TIOCINQ
ioctl to make the migration to the WWAN port usage smooth.

Despite the fact that the read call will return no more data than the
size of a first skb in the queue, TIOCINQ returns the entire amount of
buffered data (sum of all queued skbs). This is done to prevent the
breaking of programs that optimize reading, avoiding it if the buffered
amount of data is too small.

Signed-off-by: Sergey Ryazanov <ryazanov.s.a@gmail.com>
Reviewed-by: Loic Poulain <loic.poulain@linaro.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: wwan: core: expand ports number limit
Sergey Ryazanov [Tue, 8 Jun 2021 04:02:38 +0000 (07:02 +0300)]
net: wwan: core: expand ports number limit

Currently, we limit the total ports number to 256. It is quite common
for PBX or SMS gateway to be equipped with a lot of modems. In now days,
a modem could have 2-4 control ports or even more, what only accelerates
the ports exhausing rate.

To avoid facing the port number limitation issue reports, increase the
limit up the maximum number of minors (i.e. up to 1 << MINORBITS).

Signed-off-by: Sergey Ryazanov <ryazanov.s.a@gmail.com>
Reviewed-by: Loic Poulain <loic.poulain@linaro.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: wwan: core: make port names more user-friendly
Sergey Ryazanov [Tue, 8 Jun 2021 04:02:37 +0000 (07:02 +0300)]
net: wwan: core: make port names more user-friendly

At the moment, the port name is allocated based on the parent device
name, port id and the port type. Where the port id specifies nothing but
the ports registration order and is only used to make the port name
unique.

Most likely, to configure a WWAN device, the user will look for a port
of a specific type (e.g. AT port or MBIM port, etc.). The current naming
scheme can make it difficult to find a port of a specific type.

Consider a WWAN device that has 3 ports: AT port, MBIM port, and another
one AT port. With the global port index, the port names will be:
* wwan0p1at
* wwan0p2mbim
* wwan0p3at

To find the MBIM port, user should know in advance the device ports
composition (i.e. the user should know that the MBIM port is the 2nd
one) or carefully examine the whole ports list. It is not unusual for
USB modems to have a different composition, even if they are build on a
same chipset. Moreover, some modems able to change the ports composition
based on the user's configuration. All this makes port names fully
unpredictable.

To make naming more user-friendly, remove the global port id and
enumerate ports by its type. E.g.:
* wwan0p1at   -> wwan0at0
* wwan0p2mbim -> wwan0mbim0
* wwan0p3at   -> wwan0at1

With this naming scheme, the first AT port name will always be wwanXat0,
the first MBIM port name will always be wwanXmbim0, etc.

Signed-off-by: Sergey Ryazanov <ryazanov.s.a@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: wwan: core: spell port device name in lowercase
Sergey Ryazanov [Tue, 8 Jun 2021 04:02:36 +0000 (07:02 +0300)]
net: wwan: core: spell port device name in lowercase

Usually a device name is spelled in lowercase, let us follow this
practice in the WWAN subsystem as well. The bottom line is that such
name is easier to type.

To keep the device type attribute contents more natural (i.e., spell
abbreviations in uppercase), while making the device name lowercase,
turn the port type strings array to an array of structure that contains
both the port type name and the device name suffix.

Signed-off-by: Sergey Ryazanov <ryazanov.s.a@gmail.com>
Reviewed-by: Loic Poulain <loic.poulain@linaro.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: wwan: core: init port type string array using enum values
Sergey Ryazanov [Tue, 8 Jun 2021 04:02:35 +0000 (07:02 +0300)]
net: wwan: core: init port type string array using enum values

This array is indexed by port type. Make it self-descriptive by using
the port type enum values as indices in the array initializer.

Signed-off-by: Sergey Ryazanov <ryazanov.s.a@gmail.com>
Reviewed-by: Loic Poulain <loic.poulain@linaro.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: wwan: make WWAN_PORT_MAX meaning less surprised
Sergey Ryazanov [Tue, 8 Jun 2021 04:02:34 +0000 (07:02 +0300)]
net: wwan: make WWAN_PORT_MAX meaning less surprised

It is quite unusual when some value can not be equal to a defined range
max value. Also most subsystems defines FOO_TYPE_MAX as a maximum valid
value. So turn the WAN_PORT_MAX meaning from the number of supported
port types to the maximum valid port type.

Signed-off-by: Sergey Ryazanov <ryazanov.s.a@gmail.com>
Reviewed-by: Loic Poulain <loic.poulain@linaro.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agowwan_hwsim: add debugfs management interface
Sergey Ryazanov [Tue, 8 Jun 2021 04:02:33 +0000 (07:02 +0300)]
wwan_hwsim: add debugfs management interface

wwan_hwsim creates and removes simulated control ports on module loading
and unloading. It would be helpful to be able to create/remove devices
and ports at run-time to trigger wwan port (un-)register actions without
module reloading.

Some simulator objects (e.g. ports) do not have the underling device and
it is not possible to fully manage the simulator via sysfs. wwan_hsim
intend for developers, so implement it as a self-contained debugfs based
management interface.

Signed-off-by: Sergey Ryazanov <ryazanov.s.a@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agowwan_hwsim: WWAN device simulator
Sergey Ryazanov [Tue, 8 Jun 2021 04:02:32 +0000 (07:02 +0300)]
wwan_hwsim: WWAN device simulator

This driver simulates a set of WWAN device with a set of AT control
ports. It can be used to test WWAN kernel framework as well as user
space tools.

Signed-off-by: Sergey Ryazanov <ryazanov.s.a@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agoMerge branch 'stmmac-25gbps'
David S. Miller [Tue, 8 Jun 2021 21:31:43 +0000 (14:31 -0700)]
Merge branch 'stmmac-25gbps'

Michael Sit Wei Hong says:

====================
Enable 2.5Gbps speed for stmmac

Intel mGbE supports 2.5Gbps link speed by overclocking the clock rate
by 2.5 times to support 2.5Gbps link speed. In this mode, the serdes/PHY
operates at a serial baud rate of 3.125 Gbps and the PCS data path and
GMII interface of the MAC operate at 312.5 MHz instead of 125 MHz.
This is configured in the BIOS during boot up. The kernel driver is not able
access to modify the clock rate for 1Gbps/2.5G mode on the fly. The way to
determine the current 1G/2.5G mode is by reading a dedicated adhoc
register through mdio bus.

Changes:
v5 -> v6
 patch 1/3
 - Check if mdio_bus_data is populated to prevent NULL pointer dereferencing
   when accesing mdio_bus_data member

v4 -> v5
 patch 1/3
 - Rebase to latest code changes after Vladimir's code is merged and fix
   build warnings

v3 -> v4
 patch 1/3
 - Rebase to latest code and Initialize 'found' to 0 to avoid build warning

 patch 2/3
 - Fix indentation issue from v3

v2 -> v3
 patch 1/3
 -New patch added to restructure the code. enabling reading the dedicated
  adhoc register to determine link speed mode.

 patch 2/3
 -Restructure for 2.5G speed to use 2500BaseX configuration as the
  PHY interface.

 patch 3/3
 -Restructure to read serdes registers to set max_speed and configure to
  use 2500BaseX in 2.5G speeds.

v1 -> v2
 patch 1/2
 -Remove MAC supported link speed masking

 patch 2/2
 -Add supported link speed masking in the PCS

iperf3 and ping for 2.5Gbps and regression test on 10M/100M/1000Mbps
is done to prevent regresson issues.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
3 years agonet: stmmac: enable Intel mGbE 2.5Gbps link speed
Voon Weifeng [Tue, 8 Jun 2021 03:51:58 +0000 (11:51 +0800)]
net: stmmac: enable Intel mGbE 2.5Gbps link speed

The Intel mGbE supports 2.5Gbps link speed by increasing the clock rate by
2.5 times of the original rate. In this mode, the serdes/PHY operates at a
serial baud rate of 3.125 Gbps and the PCS data path and GMII interface of
the MAC operate at 312.5 MHz instead of 125 MHz.

For Intel mGbE, the overclocking of 2.5 times clock rate to support 2.5G is
only able to be configured in the BIOS during boot time. Kernel driver has
no access to modify the clock rate for 1Gbps/2.5G mode. The way to
determined the current 1G/2.5G mode is by reading a dedicated adhoc
register through mdio bus. In short, after the system boot up, it is either
in 1G mode or 2.5G mode which not able to be changed on the fly.

Compared to 1G mode, the 2.5G mode selects the 2500BASEX as PHY interface and
disables the xpcs_an_inband. This is to cater for some PHYs that only
supports 2500BASEX PHY interface with no autonegotiation.

v2: remove MAC supported link speed masking
v3: Restructure  to introduce intel_speed_mode_2500() to read serdes registers
    for max speed supported and select the appropritate configuration.
    Use max_speed to determine the supported link speed mask.

Signed-off-by: Voon Weifeng <weifeng.voon@intel.com>
Signed-off-by: Michael Sit Wei Hong <michael.wei.hong.sit@intel.com>
Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>