OSDN Git Service

tomoyo/tomoyo-test1.git
19 months agonet/mlx5e: Fix SQ SW state layout in SQ devlink health diagnostics
Adham Faris [Wed, 15 Mar 2023 14:36:22 +0000 (16:36 +0200)]
net/mlx5e: Fix SQ SW state layout in SQ devlink health diagnostics

Remove nesting level before SQ's SW state title and before SQ's SW
state capabilities line.

Preceding the SQ's SW state with a nameless nesting, wraps the inner SW
state map/dictionary with a nameless dictionary which is prohibited in
JSON file format.

Removing preceding SW state nest by removing function call
devlink_fmsg_obj_nest_start() and devlink_fmsg_obj_nest_end().

Signed-off-by: Adham Faris <afaris@nvidia.com>
Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
19 months agonet/mlx5e: Fix RQ SW state layout in RQ devlink health diagnostics
Adham Faris [Wed, 15 Mar 2023 13:12:45 +0000 (15:12 +0200)]
net/mlx5e: Fix RQ SW state layout in RQ devlink health diagnostics

Remove nesting level before RQ's SW state title and before RQ's SW
state capabilities line.

Preceding the RQ's SW state with a nameless nesting, wraps the inner SW
state map/dictionary with a nameless dictionary which is prohibited in
JSON file format.

Removing preceding SW state nest by removing function call
devlink_fmsg_obj_nest_start() and devlink_fmsg_obj_nest_end().

Signed-off-by: Adham Faris <afaris@nvidia.com>
Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
19 months agonet/mlx5e: Rename misleading skb_pc/cc references in ptp code
Gal Pressman [Mon, 30 Jan 2023 13:52:08 +0000 (15:52 +0200)]
net/mlx5e: Rename misleading skb_pc/cc references in ptp code

The 'skb_pc/cc' naming is misleading as the values hold the
producer/consumer indices (masked values), not the counters. Rename to
'skb_pi/ci'.

Signed-off-by: Gal Pressman <gal@nvidia.com>
Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
Reviewed-by: Rahul Rameshbabu <rrameshbabu@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
Reviewed-by: Adham Faris <afaris@nvidia.com>
19 months agonet/mlx5: Update cyclecounter shift value to improve ptp free running mode precision
Rahul Rameshbabu [Wed, 8 Mar 2023 16:18:22 +0000 (08:18 -0800)]
net/mlx5: Update cyclecounter shift value to improve ptp free running mode precision

Multiplier values are equivalent to 2^(shift constant) since all mlx5
devices advertise a 1Ghz frequency for the internal timer. The previous
shift constant of 23 led to internal timer adjustments only taking place
when the provided adjustment values were greater than or equal to ~120 ppb
or ~7864 scaled ppm. Using a shift constant of 31 enables adjustments when
an adjustment parameter is greater than or equal to ~0.47 ppb or ~30.8
scaled ppm.

Signed-off-by: Rahul Rameshbabu <rrameshbabu@nvidia.com>
Reviewed-by: Gal Pressman <gal@nvidia.com>
Reviewed-by: Bar Shapira <bshapira@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
19 months agonet/mlx5e: Remove redundant macsec code
Emeel Hakim [Thu, 29 Dec 2022 15:17:47 +0000 (17:17 +0200)]
net/mlx5e: Remove redundant macsec code

Currently macsec_fs_tx_create uses memset to set
two parameters to zeros when they are already
initialized to zeros.

Don't pass macsec_ctx to mlx5e_macsec_fs_add_rule
since it's not used.

Signed-off-by: Emeel Hakim <ehakim@nvidia.com>
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
Reviewed-by: Raed Salem <raeds@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
19 months agonet/mlx5e: TC, Remove sample and ct limitation
Paul Blakey [Wed, 25 Jan 2023 10:03:58 +0000 (12:03 +0200)]
net/mlx5e: TC, Remove sample and ct limitation

Sample action before a ct nat action was not supported when only
chain was restored on misses. As to work around that limitation,
ct action was reordered to be first (so if hw misses on ct
action, packet wasn't modified). This reordering wasn't possible
if there was a sample action before the ct nat action, as we had to
sample the packet before the nat operation.

Now that the misses continue from the relevant tc ct action
in software and ct action is no longer reordered, this case
is supported.

Remove this limitation.

Signed-off-by: Paul Blakey <paulb@nvidia.com>
Reviewed-by: Roi Dayan <roid@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
19 months agonet/mlx5e: TC, Remove mirror and ct limitation
Paul Blakey [Wed, 25 Jan 2023 10:01:47 +0000 (12:01 +0200)]
net/mlx5e: TC, Remove mirror and ct limitation

Mirror action before a ct nat action was not supported when only
chain was restored on misses. As to work around that limitation,
ct action was reordered to be first (so if hw misses on ct
action, packet wasn't modified). This reordering wasn't possible
if there was mirror action before the ct nat action, as we had to
mirror the packet before the nat operation.

Now that the misses continue from the relevant tc ct action
in software and ct action is no longer reordered, this case
is supported.

Remove this limitation.

Signed-off-by: Paul Blakey <paulb@nvidia.com>
Reviewed-by: Roi Dayan <roid@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
19 months agonet/mlx5e: TC, Remove tuple rewrite and ct limitation
Paul Blakey [Wed, 25 Jan 2023 09:56:28 +0000 (11:56 +0200)]
net/mlx5e: TC, Remove tuple rewrite and ct limitation

Tuple rewrite and ct action was not supported when only chain was
restored on misses. To work around that limitation, ct action was
reordered to be first (so if hw misses on ct action, packet wasn't
modified). This reordering wasn't possible for tuple rewrite
actions before ct action since the ct action result was
dependent on the tuple info.

Now that the misses continue from the relevant tc ct action
in software and ct action is no longer reordered, this case
is supported.

Remove this limitation.

Signed-off-by: Paul Blakey <paulb@nvidia.com>
Reviewed-by: Roi Dayan <roid@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
19 months agonet/mlx5e: TC, Remove multiple ct actions limitation
Paul Blakey [Mon, 23 Jan 2023 08:46:10 +0000 (10:46 +0200)]
net/mlx5e: TC, Remove multiple ct actions limitation

Multiple ct actions was not supported when only chain was
restored on misses, as CT is a modifying action which could
modify the packet and cause the sw ct rule to not match again
and continue processing.

Now that the misses continue from the relevant tc ct action
in software, this case is supported.

Remove this limitation.

Signed-off-by: Paul Blakey <paulb@nvidia.com>
Reviewed-by: Roi Dayan <roid@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
19 months agonet/mlx5e: TC, Remove special handling of CT action
Paul Blakey [Wed, 25 Jan 2023 14:41:05 +0000 (16:41 +0200)]
net/mlx5e: TC, Remove special handling of CT action

CT action has special treating as a per-flow action since
it was assumed to be singular and reordered to be first on
the action list.

This isn't the case anymore, and can be converted to just a
FWD to pre_ct + MODIFY_HEAD, and handled per post_act rule.

Remove special handling of CT action, and offload it while
post parsing each ct attribute.

Signed-off-by: Paul Blakey <paulb@nvidia.com>
Reviewed-by: Roi Dayan <roid@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
19 months agonet/mlx5e: TC, Remove CT action reordering
Paul Blakey [Sun, 4 Dec 2022 14:53:56 +0000 (16:53 +0200)]
net/mlx5e: TC, Remove CT action reordering

CT action reordering was done as a workaround when CT misses
used to restore the relevant filter's tc chain and continuing sw processing
from that chain. As such, there was a need to reorder CT action to be before
any packet modifying actions (e.g mac rewrite).

Currently (after patch "net/mlx5e: TC, Set CT miss to the specific ct
action instance"), CT misses continues from the relevant ct action in
software, and so reordering isn't needed anymore.

Remove the reordering.

Signed-off-by: Paul Blakey <paulb@nvidia.com>
Reviewed-by: Roi Dayan <roid@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
19 months agonet/mlx5e: CT: Use per action stats
Paul Blakey [Sun, 12 Feb 2023 17:11:07 +0000 (19:11 +0200)]
net/mlx5e: CT: Use per action stats

CT action can miss in a middle of an action list, use
per action stats to correctly report stats for missed
packets.

Signed-off-by: Paul Blakey <paulb@nvidia.com>
Reviewed-by: Roi Dayan <roid@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
19 months agonet/mlx5e: TC, Move main flow attribute cleanup to helper func
Paul Blakey [Wed, 25 Jan 2023 09:54:22 +0000 (11:54 +0200)]
net/mlx5e: TC, Move main flow attribute cleanup to helper func

Actions that can be setup per flow attribute (so per split rule)
are cleaned up from mlx5_free_flow_attr(), mlx5e_tc_del_fdb_flow(),
and free_flow_post_acts().

Remove the duplication by re-using the helper function for
the main flow attribute and split rules attributes.

Signed-off-by: Paul Blakey <paulb@nvidia.com>
Reviewed-by: Roi Dayan <roid@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
19 months agonet/mlx5e: TC, Remove unused vf_tun variable
Paul Blakey [Thu, 1 Dec 2022 10:04:58 +0000 (12:04 +0200)]
net/mlx5e: TC, Remove unused vf_tun variable

vf_tun is being assigned but never being used so remove it.

Signed-off-by: Paul Blakey <paulb@nvidia.com>
Reviewed-by: Roi Dayan <roid@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
19 months agonet/mlx5e: Set default can_offload action
Paul Blakey [Mon, 13 Mar 2023 13:38:52 +0000 (15:38 +0200)]
net/mlx5e: Set default can_offload action

Many parsers of tc actions just return true on their can_offload()
implementation, without checking the input flow/action.
Set the default can_offload action to true (allow), and avoid
having many can_offload implementations that do just that.

This patch doesn't change any functionality.

Signed-off-by: Paul Blakey <paulb@nvidia.com>
Reviewed-by: Roi Dayan <roid@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
19 months agonet/sched: sch_mqprio: use netlink payload helpers
Pedro Tammela [Tue, 4 Apr 2023 20:34:49 +0000 (17:34 -0300)]
net/sched: sch_mqprio: use netlink payload helpers

For the sake of readability, use the netlink payload helpers from
the 'nla_get_*()' family to parse the attributes.

tdc results:
1..5
ok 1 9903 - Add mqprio Qdisc to multi-queue device (8 queues)
ok 2 453a - Delete nonexistent mqprio Qdisc
ok 3 5292 - Delete mqprio Qdisc twice
ok 4 45a9 - Add mqprio Qdisc to single-queue device
ok 5 2ba9 - Show mqprio class

Acked-by: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: Pedro Tammela <pctammela@mojatatu.com>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Link: https://lore.kernel.org/r/20230404203449.1627033-1-pctammela@mojatatu.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
19 months agodt-bindings: net: dsa: brcm,sf2: Drop unneeded "#address-cells/#size-cells"
Rob Herring [Tue, 4 Apr 2023 20:41:52 +0000 (15:41 -0500)]
dt-bindings: net: dsa: brcm,sf2: Drop unneeded "#address-cells/#size-cells"

There's no need for "#address-cells/#size-cells" in the brcm,sf2 node as
no immediate child nodes have an address. What was probably intended was
to put them in the 'ports' node, but that's not necessary as that is
covered by ethernet-switch.yaml via dsa.yaml.

Signed-off-by: Rob Herring <robh@kernel.org>
Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Link: https://lore.kernel.org/r/20230404204152.635400-1-robh@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
19 months agodt-bindings: net: ethernet-switch: Make "#address-cells/#size-cells" required
Rob Herring [Tue, 4 Apr 2023 20:42:13 +0000 (15:42 -0500)]
dt-bindings: net: ethernet-switch: Make "#address-cells/#size-cells" required

The schema doesn't allow for a single (unaddressed) ethernet port node
nor does a single port switch make much sense. So if there's always
multiple child nodes, "#address-cells" and "#size-cells" should be
required.

Signed-off-by: Rob Herring <robh@kernel.org>
Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Link: https://lore.kernel.org/r/20230404204213.635773-1-robh@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
19 months agoMerge tag 'wireless-next-2023-04-05' of git://git.kernel.org/pub/scm/linux/kernel...
Jakub Kicinski [Thu, 6 Apr 2023 00:25:02 +0000 (17:25 -0700)]
Merge tag 'wireless-next-2023-04-05' of git://git./linux/kernel/git/wireless/wireless-next

Kalle Valo says:

====================
wireless-next patches for v6.3

Smaller pull request this time, sending this early to fix the conflict
in mac80211. Nothing really special this time, only smaller changes.

 * enable Wi-Fi 7 (EHT) mesh support

* tag 'wireless-next-2023-04-05' of git://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless-next: (37 commits)
  wifi: rt2x00: Fix memory leak when handling surveys
  wifi: b43legacy: Remove the unused function prev_slot()
  wifi: rtw89: Remove redundant pci_clear_master
  wifi: rtw89: fix potential race condition between napi_init and napi_enable
  wifi: rtw89: config EDCCA threshold during scan to prevent TX failed
  wifi: rtw89: fix incorrect channel info during scan due to ppdu_sts filtering
  wifi: rtw89: remove superfluous H2C of join_info
  wifi: rtw89: set data lowest rate according to AP supported rate
  wifi: rtw89: add counters of register-based H2C/C2H
  wifi: rtw89: coex: Update Wi-Fi Bluetooth coexistence version to 7.0.1
  wifi: rtw89: coex: Add report control v5 variation
  wifi: rtw89: coex: Update RTL8852B LNA2 hardware parameter
  wifi: rtw89: coex: Not to enable firmware report when WiFi is power saving
  wifi: rtw89: coex: Add LPS protocol radio state for RTL8852B
  bcma: remove unused mips_read32 function
  bcma: Use of_address_to_resource()
  wifi: mwifiex: remove unused evt_buf variable
  wifi: brcmsmac: ampdu: remove unused suc_mpdu variable
  wifi: rtlwifi: fix incorrect error codes in rtl_debugfs_set_write_reg()
  wifi: rtlwifi: fix incorrect error codes in rtl_debugfs_set_write_rfreg()
  ...
====================

Link: https://lore.kernel.org/r/20230405111037.4792BC43443@smtp.kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
19 months agoMerge tag 'linux-can-next-for-6.4-20230404-2' of git://git.kernel.org/pub/scm/linux...
Jakub Kicinski [Thu, 6 Apr 2023 00:06:02 +0000 (17:06 -0700)]
Merge tag 'linux-can-next-for-6.4-20230404-2' of git://git./linux/kernel/git/mkl/linux-can-next

Marc Kleine-Budde says:

====================
pull-request: can-next 2023-04-04-2

The first patch is by Oliver Hartkopp and makes the maximum pdu size
of the CAN ISOTP protocol configurable.

The following 5 patches are by Dario Binacchi and add support for the
bxCAN controller by ST.

Geert Uytterhoeven's patch for the rcar_canfd driver fixes a sparse
warning.

Peng Fan's patch adds an optional power-domains property to the
flexcan device tree binding.

Frank Jungclaus adds support for CAN_CTRLMODE_BERR_REPORTING to the
esd_usb driver.

The last patch is by Oliver Hartkopp and converts the USB IDs of the
kvaser_usb driver to hexadecimal values.

* tag 'linux-can-next-for-6.4-20230404-2' of git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can-next:
  kvaser_usb: convert USB IDs to hexadecimal values
  can: esd_usb: Add support for CAN_CTRLMODE_BERR_REPORTING
  dt-bindings: can: fsl,flexcan: add optional power-domains property
  can: rcar_canfd: rcar_canfd_probe(): fix plain integer in transceivers[] init
  can: bxcan: add support for ST bxCAN controller
  ARM: dts: stm32: add pin map for CAN controller on stm32f4
  ARM: dts: stm32: add CAN support on stm32f429
  dt-bindings: net: can: add STM32 bxcan DT bindings
  dt-bindings: arm: stm32: add compatible for syscon gcan node
  can: isotp: add module parameter for maximum pdu size
====================

Link: https://lore.kernel.org/r/20230404145908.1714400-1-mkl@pengutronix.de
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
19 months agonet: qrtr: correct types of trace event parameters
Simon Horman [Mon, 3 Apr 2023 15:43:16 +0000 (17:43 +0200)]
net: qrtr: correct types of trace event parameters

The arguments passed to the trace events are of type unsigned int,
however the signature of the events used __le32 parameters.

I may be missing the point here, but sparse flagged this and it
does seem incorrect to me.

  net/qrtr/ns.c: note: in included file (through include/trace/trace_events.h, include/trace/define_trace.h, include/trace/events/qrtr.h):
  ./include/trace/events/qrtr.h:11:1: warning: cast to restricted __le32
  ./include/trace/events/qrtr.h:11:1: warning: restricted __le32 degrades to integer
  ./include/trace/events/qrtr.h:11:1: warning: restricted __le32 degrades to integer
  ... (a lot more similar warnings)
  net/qrtr/ns.c:115:47:    expected restricted __le32 [usertype] service
  net/qrtr/ns.c:115:47:    got unsigned int service
  net/qrtr/ns.c:115:61: warning: incorrect type in argument 2 (different base types)
  ... (a lot more similar warnings)

Fixes: dfddb54043f0 ("net: qrtr: Add tracepoint support")
Reviewed-by: Manivannan Sadhasivam <mani@kernel.org>
Signed-off-by: Simon Horman <horms@kernel.org>
Link: https://lore.kernel.org/r/20230402-qrtr-trace-types-v1-1-92ad55008dd3@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
19 months agonet: phy: meson-gxl: enable edpd tunable support for G12A internal PHY
Heiner Kallweit [Mon, 3 Apr 2023 19:35:46 +0000 (21:35 +0200)]
net: phy: meson-gxl: enable edpd tunable support for G12A internal PHY

Enable EDPD PHY tunable support for the G12A internal PHY, reusing the
recently added tunable support in the smsc driver.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Acked-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Link: https://lore.kernel.org/r/8d309575-067c-7321-33cf-6ffac11f7c8d@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
19 months agokvaser_usb: convert USB IDs to hexadecimal values
Oliver Hartkopp [Wed, 29 Mar 2023 09:09:15 +0000 (11:09 +0200)]
kvaser_usb: convert USB IDs to hexadecimal values

USB IDs are usually represented in 16 bit hexadecimal values. To match
the common representation in lsusb and for searching USB IDs in the
internet convert the decimal values to lowercase hexadecimal.

changes since v1: https://lore.kernel.org/all/20230327175344.4668-1-socketcan@hartkopp.net
- drop the aligned block indentation (suggested by Jimmy)
- use lowercase hex values (suggested by Alex)

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
Acked-by: Jimmy Assarsson <extja@kvaser.com>
Reviewed-by: Alexander Dahl <ada@thorsis.com>
Link: https://lore.kernel.org/all/20230329090915.3127-1-socketcan@hartkopp.net
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
19 months agocan: esd_usb: Add support for CAN_CTRLMODE_BERR_REPORTING
Frank Jungclaus [Thu, 30 Mar 2023 18:44:46 +0000 (20:44 +0200)]
can: esd_usb: Add support for CAN_CTRLMODE_BERR_REPORTING

Announce that the driver supports CAN_CTRLMODE_BERR_REPORTING by means
of priv->can.ctrlmode_supported. Until now berr reporting always has
been active without taking care of the berr-reporting parameter given
to an "ip link set ..." command.

Additionally apply some changes to function esd_usb_rx_event():
- If berr reporting is off and it is also no state change, then
immediately return.
- Unconditionally (even in case of the above "immediate return") store
tx- and rx-error counters, so directly use priv->bec.txerr and
priv->bec.rxerr instead of intermediate variables.
- Not directly related, but to better point out the linkage between a
failed alloc_can_err_skb() and stats->rx_dropped++:
Move the increment of the rx_dropped statistic counter (back) to
directly behind the err_skb allocation.

Signed-off-by: Frank Jungclaus <frank.jungclaus@esd.eu>
Link: https://lore.kernel.org/all/20230330184446.2802135-1-frank.jungclaus@esd.eu
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
19 months agodt-bindings: can: fsl,flexcan: add optional power-domains property
Peng Fan [Tue, 28 Mar 2023 05:46:02 +0000 (13:46 +0800)]
dt-bindings: can: fsl,flexcan: add optional power-domains property

Add optional power-domains property for i.MX8 usage.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Acked-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/all/20230328054602.1974255-1-peng.fan@oss.nxp.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
19 months agocan: rcar_canfd: rcar_canfd_probe(): fix plain integer in transceivers[] init
Geert Uytterhoeven [Wed, 29 Mar 2023 06:40:55 +0000 (08:40 +0200)]
can: rcar_canfd: rcar_canfd_probe(): fix plain integer in transceivers[] init

Fix the following compile warning with C=1:

| drivers/net/can/rcar/rcar_canfd.c:1852:59: warning: Using plain integer as NULL pointer

Fixes: a0340df7eca4f28e ("can: rcar_canfd: Add transceiver support")
Reported-by: Jakub Kicinski <kuba@kernel.org>
Link: https://lore.kernel.org/r/20230328145658.7fdbc394@kernel.org
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Steen Hegelund <Steen.Hegelund@microchip.com>
Link: https://lore.kernel.org/all/7f7b0dde0caa2d2977b4fb5b65b63036e75f5022.1680071972.git.geert+renesas@glider.be
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
19 months agoMerge branch 'vsock-return-errors-other-than-enomem-to-socket'
Paolo Abeni [Tue, 4 Apr 2023 10:46:26 +0000 (12:46 +0200)]
Merge branch 'vsock-return-errors-other-than-enomem-to-socket'

Arseniy Krasnov says:

====================
vsock: return errors other than -ENOMEM to socket

this patchset removes behaviour, where error code returned from any
transport was always switched to ENOMEM. This works in the same way as
patch from Bobby Eshleman:
commit c43170b7e157 ("vsock: return errors other than -ENOMEM to socket"),
but for receive calls. VMCI transport is also updated (both tx and rx
SOCK_STREAM callbacks), because it returns VMCI specific error code to
af_vsock.c (like VMCI_ERROR_*). Tx path is already merged to net, so it
was excluded from patchset in v4. At the same time, virtio and Hyper-V
transports are using general error codes, so there is no need to update
them.

vsock_test suite is also updated.

Link to v1:
https://lore.kernel.org/netdev/97f19214-ba04-c47e-7486-72e8aa16c690@sberdevices.ru/
Link to v2:
https://lore.kernel.org/netdev/60abc0da-0412-6e25-eeb0-8e32e3ec21e7@sberdevices.ru/
Link to v3:
https://lore.kernel.org/netdev/dead4842-333a-015e-028b-302151336ff9@sberdevices.ru/
====================

Link: https://lore.kernel.org/r/0d20e25a-640c-72c1-2dcb-7a53a05e3132@sberdevices.ru
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
19 months agovsock/test: update expected return values
Arseniy Krasnov [Mon, 3 Apr 2023 11:26:18 +0000 (14:26 +0300)]
vsock/test: update expected return values

This updates expected return values for invalid buffer test. Now such
values are returned from transport, not from af_vsock.c.

Signed-off-by: Arseniy Krasnov <AVKrasnov@sberdevices.ru>
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
19 months agovsock: return errors other than -ENOMEM to socket
Arseniy Krasnov [Mon, 3 Apr 2023 11:25:12 +0000 (14:25 +0300)]
vsock: return errors other than -ENOMEM to socket

This removes behaviour, where error code returned from any transport
was always switched to ENOMEM. This works in the same way as:
commit
c43170b7e157 ("vsock: return errors other than -ENOMEM to socket"),
but for receive calls.

Signed-off-by: Arseniy Krasnov <AVKrasnov@sberdevices.ru>
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
19 months agovsock/vmci: convert VMCI error code to -ENOMEM on receive
Arseniy Krasnov [Mon, 3 Apr 2023 11:24:17 +0000 (14:24 +0300)]
vsock/vmci: convert VMCI error code to -ENOMEM on receive

This adds conversion of VMCI specific error code to general -ENOMEM. It
is preparation for the next patch, which changes af_vsock.c behaviour
on receive to pass value returned from transport to the user.

Signed-off-by: Arseniy Krasnov <AVKrasnov@sberdevices.ru>
Reviewed-by: Vishnu Dasa <vdasa@vmware.com>
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
19 months agoMerge branch 'sfc-support-unicast-ptp'
Jakub Kicinski [Tue, 4 Apr 2023 02:02:53 +0000 (19:02 -0700)]
Merge branch 'sfc-support-unicast-ptp'

Íñigo Huguet says:

====================
sfc: support unicast PTP

Unicast PTP was not working with sfc NICs.

The reason was that these NICs don't timestamp all incoming packets,
but instead they only timestamp packets of the queues that are selected
for that. Currently, only one RX queue is configured for timestamp: the
RX queue of the PTP channel. The packets that are put in the PTP RX
queue are selected according to firmware filters configured from the
driver.

Multicast PTP was already working because the needed filters are known
in advance, so they're inserted when PTP is enabled. This patches
add the ability to dynamically add filters for unicast addresses,
extracted from the TX PTP-event packets.

Since we don't know in advance how many filters we'll need, some info
about the filters need to be saved. This will allow to check if a filter
already exists or if a filter is too old and should be removed.

Note that the previous point is unnecessary for multicast filters, but
I've opted to change how they're handled to match the new unicast's
filters to avoid having duplicate insert/remove_filters functions,
once for each type of filter.

Tested: With ptp4l, all combinations of IPv4/IPv6, master/slave and
unicast/multicast

Reported-by: Yalin Li <yalli@redhat.com>
====================

Link: https://lore.kernel.org/r/20230331111404.17256-1-ihuguet@redhat.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
19 months agosfc: remove expired unicast PTP filters
Íñigo Huguet [Fri, 31 Mar 2023 11:14:04 +0000 (13:14 +0200)]
sfc: remove expired unicast PTP filters

Filters inserted to support unicast PTP mode might become unused after
some time, so we need to remove them to avoid accumulating many of them.

Refresh the expiration time of a filter each time it's used. Then check
periodically if any filter hasn't been used for a long time (30s) and
remove it.

Reported-by: Yalin Li <yalli@redhat.com>
Signed-off-by: Íñigo Huguet <ihuguet@redhat.com>
Reviewed-by: Edward Cree <ecree.xilinx@gmail.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
19 months agosfc: support unicast PTP
Íñigo Huguet [Fri, 31 Mar 2023 11:14:03 +0000 (13:14 +0200)]
sfc: support unicast PTP

When sending a PTP event packet, add the correct filters that will make
that future incoming unicast PTP event packets will be timestamped.
The unicast address for the filter is gotten from the outgoing skb
before sending it.

Until now they were not timestamped because only filters that match with
the PTP multicast addressed were being configured into the NIC for the
PTP special channel. Packets received through different channels are not
timestamped, getting "received SYNC without timestamp" error in ptp4l.

Note that the inserted filters are never removed unless the NIC is stopped
or reconfigured, so efx_ptp_stop is called. Removal of old filters will
be handled by the next patch.

Additionally, cleanup a bit efx_ptp_xmit_skb_mc to use the reverse xmas
tree convention and remove an unnecessary assignment to rc variable in
void function.

Reported-by: Yalin Li <yalli@redhat.com>
Signed-off-by: Íñigo Huguet <ihuguet@redhat.com>
Reviewed-by: Edward Cree <ecree.xilinx@gmail.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
19 months agosfc: allow insertion of filters for unicast PTP
Íñigo Huguet [Fri, 31 Mar 2023 11:14:02 +0000 (13:14 +0200)]
sfc: allow insertion of filters for unicast PTP

Add a second list for unicast filters and generalize the
efx_ptp_insert/remove_filters functions to allow acting in any of the 2
lists.

No filters for unicast are inserted yet. That will be done in the next
patch.

The reason to use 2 different lists instead of a single one is that, in
next patches, we will want to check if unicast filters are already added
and if they're expired. We don't need that for multicast filters.

Reported-by: Yalin Li <yalli@redhat.com>
Signed-off-by: Íñigo Huguet <ihuguet@redhat.com>
Reviewed-by: Edward Cree <ecree.xilinx@gmail.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
19 months agosfc: store PTP filters in a list
Íñigo Huguet [Fri, 31 Mar 2023 11:14:01 +0000 (13:14 +0200)]
sfc: store PTP filters in a list

Instead of using a fixed sized array for the PTP filters, use a list.

This is not actually necessary at this point because the filters for
multicast PTP are a fixed number, but this is a preparation for the
following patches adding support for unicast PTP.

To avoid confusion with the new struct type efx_ptp_rxfilter, change the
name of some local variables from rxfilter to spec, given they're of the
type efx_filter_spec.

Reported-by: Yalin Li <yalli@redhat.com>
Signed-off-by: Íñigo Huguet <ihuguet@redhat.com>
Reviewed-by: Edward Cree <ecree.xilinx@gmail.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
19 months agowifi: rt2x00: Fix memory leak when handling surveys
Armin Wolf [Thu, 30 Mar 2023 21:56:37 +0000 (23:56 +0200)]
wifi: rt2x00: Fix memory leak when handling surveys

When removing a rt2x00 device, its associated channel surveys
are not freed, causing a memory leak observable with kmemleak:

unreferenced object 0xffff9620f0881a00 (size 512):
  comm "systemd-udevd", pid 2290, jiffies 4294906974 (age 33.768s)
  hex dump (first 32 bytes):
    70 44 12 00 00 00 00 00 92 8a 00 00 00 00 00 00  pD..............
    00 00 00 00 00 00 00 00 ab 87 01 00 00 00 00 00  ................
  backtrace:
    [<ffffffffb0ed858b>] __kmalloc+0x4b/0x130
    [<ffffffffc1b0f29b>] rt2800_probe_hw+0xc2b/0x1380 [rt2800lib]
    [<ffffffffc1a9496e>] rt2800usb_probe_hw+0xe/0x60 [rt2800usb]
    [<ffffffffc1ae491a>] rt2x00lib_probe_dev+0x21a/0x7d0 [rt2x00lib]
    [<ffffffffc1b3b83e>] rt2x00usb_probe+0x1be/0x980 [rt2x00usb]
    [<ffffffffc05981e2>] usb_probe_interface+0xe2/0x310 [usbcore]
    [<ffffffffb13be2d5>] really_probe+0x1a5/0x410
    [<ffffffffb13be5c8>] __driver_probe_device+0x78/0x180
    [<ffffffffb13be6fe>] driver_probe_device+0x1e/0x90
    [<ffffffffb13be972>] __driver_attach+0xd2/0x1c0
    [<ffffffffb13bbc57>] bus_for_each_dev+0x77/0xd0
    [<ffffffffb13bd2a2>] bus_add_driver+0x112/0x210
    [<ffffffffb13bfc6c>] driver_register+0x5c/0x120
    [<ffffffffc0596ae8>] usb_register_driver+0x88/0x150 [usbcore]
    [<ffffffffb0c011c4>] do_one_initcall+0x44/0x220
    [<ffffffffb0d6134c>] do_init_module+0x4c/0x220

Fix this by freeing the channel surveys on device removal.

Tested with a RT3070 based USB wireless adapter.

Fixes: 5447626910f5 ("rt2x00: save survey for every channel visited")
Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Acked-by: Stanislaw Gruszka <stf_xl@wp.pl>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230330215637.4332-1-W_Armin@gmx.de
19 months agowifi: b43legacy: Remove the unused function prev_slot()
Jiapeng Chong [Thu, 30 Mar 2023 02:18:41 +0000 (10:18 +0800)]
wifi: b43legacy: Remove the unused function prev_slot()

The function prev_slot is defined in the dma.c file, but not called
elsewhere, so remove this unused function.

drivers/net/wireless/broadcom/b43legacy/dma.c:130:19: warning: unused function 'prev_slot'.

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Link: https://bugzilla.openanolis.cn/show_bug.cgi?id=4642
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Acked-by: Larry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230330021841.67724-1-jiapeng.chong@linux.alibaba.com
19 months agowifi: rtw89: Remove redundant pci_clear_master
Cai Huoqing [Thu, 23 Mar 2023 11:26:13 +0000 (19:26 +0800)]
wifi: rtw89: Remove redundant pci_clear_master

Remove pci_clear_master to simplify the code,
the bus-mastering is also cleared in do_pci_disable_device,
like this:
./drivers/pci/pci.c:2197
static void do_pci_disable_device(struct pci_dev *dev)
{
u16 pci_command;

pci_read_config_word(dev, PCI_COMMAND, &pci_command);
if (pci_command & PCI_COMMAND_MASTER) {
pci_command &= ~PCI_COMMAND_MASTER;
pci_write_config_word(dev, PCI_COMMAND, pci_command);
}

pcibios_disable_device(dev);
}.
And dev->is_busmaster is set to 0 in pci_disable_device.

Signed-off-by: Cai Huoqing <cai.huoqing@linux.dev>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Acked-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230323112613.7550-5-cai.huoqing@linux.dev
19 months agowifi: rtw89: fix potential race condition between napi_init and napi_enable
Ping-Ke Shih [Thu, 23 Mar 2023 08:28:39 +0000 (16:28 +0800)]
wifi: rtw89: fix potential race condition between napi_init and napi_enable

A race condition can happen if netdev is registered, but NAPI isn't
initialized yet, and meanwhile user space starts the netdev that will
enable NAPI. Then, it hits BUG_ON():

 kernel BUG at net/core/dev.c:6423!
 invalid opcode: 0000 [#1] PREEMPT SMP NOPTI
 CPU: 0 PID: 417 Comm: iwd Not tainted 6.2.7-slab-dirty #3 eb0f5a8a9d91
 Hardware name: LENOVO 21DL/LNVNB161216, BIOS JPCN20WW(V1.06) 09/20/2022
 RIP: 0010:napi_enable+0x3f/0x50
 Code: 48 89 c2 48 83 e2 f6 f6 81 89 08 00 00 02 74 0d 48 83 ...
 RSP: 0018:ffffada1414f3548 EFLAGS: 00010246
 RAX: 0000000000000000 RBX: ffffa01425802080 RCX: 0000000000000000
 RDX: 00000000000002ff RSI: ffffada14e50c614 RDI: ffffa01425808dc0
 RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000
 R10: 0000000000000001 R11: 0000000000000100 R12: ffffa01425808f58
 R13: 0000000000000000 R14: ffffa01423498940 R15: 0000000000000001
 FS:  00007f5577c0a740(0000) GS:ffffa0169fc00000(0000) knlGS:0000000000000000
 CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
 CR2: 00007f5577a19972 CR3: 0000000125a7a000 CR4: 0000000000750ef0
 PKRU: 55555554
 Call Trace:
  <TASK>
  rtw89_pci_ops_start+0x1c/0x70 [rtw89_pci 6cbc75429515c181cbc386478d5cfb32ffc5a0f8]
  rtw89_core_start+0xbe/0x160 [rtw89_core fe07ecb874820b6d778370d4acb6ef8a37847f22]
  rtw89_ops_start+0x26/0x40 [rtw89_core fe07ecb874820b6d778370d4acb6ef8a37847f22]
  drv_start+0x42/0x100 [mac80211 c07fa22af8c3cf3f7d7ab3884ca990784d72e2d2]
  ieee80211_do_open+0x311/0x7d0 [mac80211 c07fa22af8c3cf3f7d7ab3884ca990784d72e2d2]
  ieee80211_open+0x6a/0x90 [mac80211 c07fa22af8c3cf3f7d7ab3884ca990784d72e2d2]
  __dev_open+0xe0/0x180
  __dev_change_flags+0x1da/0x250
  dev_change_flags+0x26/0x70
  do_setlink+0x37c/0x12c0
  ? ep_poll_callback+0x246/0x290
  ? __nla_validate_parse+0x61/0xd00
  ? __wake_up_common_lock+0x8f/0xd0

To fix this, follow Jonas' suggestion to switch the order of these
functions and move register netdev to be the last step of PCI probe.
Also, correct the error handling of rtw89_core_register_hw().

Fixes: e3ec7017f6a2 ("rtw89: add Realtek 802.11ax driver")
Cc: stable@vger.kernel.org
Reported-by: Hyeonggon Yoo <42.hyeyoo@gmail.com>
Link: https://lore.kernel.org/linux-wireless/CAOiHx=n7EwK2B9CnBR07FVA=sEzFagb8TkS4XC_qBNq8OwcYUg@mail.gmail.com/T/#t
Suggested-by: Jonas Gorski <jonas.gorski@gmail.com>
Tested-by: Larry Finger<Larry.Finger@lwfinger.net>
Reviewed-by: Larry Finger<Larry.Finger@lwfinger.net>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230323082839.20474-1-pkshih@realtek.com
19 months agowifi: rtw89: config EDCCA threshold during scan to prevent TX failed
Chih-Kang Chang [Wed, 22 Mar 2023 06:02:38 +0000 (14:02 +0800)]
wifi: rtw89: config EDCCA threshold during scan to prevent TX failed

Need to configure EDCCA threshold to default value before scan, and recall
original value after scan to prevent probe request can't be sent out.

Signed-off-by: Chih-Kang Chang <gary.chang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230322060238.43922-1-pkshih@realtek.com
19 months agowifi: rtw89: fix incorrect channel info during scan due to ppdu_sts filtering
Chih-Kang Chang [Mon, 20 Mar 2023 09:31:12 +0000 (17:31 +0800)]
wifi: rtw89: fix incorrect channel info during scan due to ppdu_sts filtering

We use ppdu_sts to obtain channel information from hardware, to ensure
that the scan results have correct channel information. However, some of
ppdu_sts that is filtered by the to_self check is also needed for the scan
results. Therefore, we modify the filter part in front of CFO count.

Signed-off-by: Chih-Kang Chang <gary.chang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230320093112.30466-3-pkshih@realtek.com
19 months agowifi: rtw89: remove superfluous H2C of join_info
Chin-Yen Lee [Mon, 20 Mar 2023 09:31:11 +0000 (17:31 +0800)]
wifi: rtw89: remove superfluous H2C of join_info

We find that when starting WoWLAN, the second join_info H2C is
unnecessary and leads WoWLAN not enter power save mode if using new
firmware, so remove it.

Signed-off-by: Chin-Yen Lee <timlee@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230320093112.30466-2-pkshih@realtek.com
19 months agowifi: rtw89: set data lowest rate according to AP supported rate
Chih-Kang Chang [Mon, 20 Mar 2023 09:31:10 +0000 (17:31 +0800)]
wifi: rtw89: set data lowest rate according to AP supported rate

By default the driver uses the 1M and 6M rate (0x0) for data frames in
2 GHz and 5/6 GHz bands respectively. But the rate that might not AP
supported. Therefore, We modify the data lowest rate according to the
lowest of AP supported rate.

Signed-off-by: Chih-Kang Chang <gary.chang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230320093112.30466-1-pkshih@realtek.com
19 months agowifi: rtw89: add counters of register-based H2C/C2H
Ping-Ke Shih [Thu, 16 Mar 2023 06:39:56 +0000 (14:39 +0800)]
wifi: rtw89: add counters of register-based H2C/C2H

The register-based H2C/C2H are used to exchange information between driver
and firmware, but only apply to narrow area because its data size is
smaller than regular packet-based H2C/C2H.

This kind of H2C/C2H must be paired. To identify if any H2C/C2H is missing,
update counters to help diagnose this kind of problems.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230316063956.71687-1-pkshih@realtek.com
19 months agowifi: rtw89: coex: Update Wi-Fi Bluetooth coexistence version to 7.0.1
Ching-Te Ku [Tue, 14 Mar 2023 02:06:17 +0000 (10:06 +0800)]
wifi: rtw89: coex: Update Wi-Fi Bluetooth coexistence version to 7.0.1

Update driver with the supported firmware version of the below item.
Bluetooth firmware BT_Coex_Ver: 0x07
Wi-Fi firmware version:
  RTL8852C->v0.27.56.10
  RTL8852A->v0.24.36
  RTL8852B->v0.29.29

Signed-off-by: Ching-Te Ku <ku920601@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230314020617.28193-6-pkshih@realtek.com
19 months agowifi: rtw89: coex: Add report control v5 variation
Ching-Te Ku [Tue, 14 Mar 2023 02:06:16 +0000 (10:06 +0800)]
wifi: rtw89: coex: Add report control v5 variation

In order to reduce firmware code size cost, remove some counter value from
the structure. But firmware didn't update version code. To parse the
correct report, add another variation version v105 to parse it.

Signed-off-by: Ching-Te Ku <ku920601@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230314020617.28193-5-pkshih@realtek.com
19 months agowifi: rtw89: coex: Update RTL8852B LNA2 hardware parameter
Ching-Te Ku [Tue, 14 Mar 2023 02:06:15 +0000 (10:06 +0800)]
wifi: rtw89: coex: Update RTL8852B LNA2 hardware parameter

The LNA gain didn't set before, it will lead some WiFi RX issue.
And the setting can increase both of WiFi & BT performance while
they are both RX.

Signed-off-by: Ching-Te Ku <ku920601@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230314020617.28193-4-pkshih@realtek.com
19 months agowifi: rtw89: coex: Not to enable firmware report when WiFi is power saving
Ching-Te Ku [Tue, 14 Mar 2023 02:06:14 +0000 (10:06 +0800)]
wifi: rtw89: coex: Not to enable firmware report when WiFi is power saving

If driver enable firmware report during WiFi power saving, the
firmware timer will lead to some power saving issue like,
fail to enter LPS, can not leave LPS or some unexpected issue.

Signed-off-by: Ching-Te Ku <ku920601@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230314020617.28193-3-pkshih@realtek.com
19 months agowifi: rtw89: coex: Add LPS protocol radio state for RTL8852B
Ching-Te Ku [Tue, 14 Mar 2023 02:06:13 +0000 (10:06 +0800)]
wifi: rtw89: coex: Add LPS protocol radio state for RTL8852B

This LPS state will not turn off RF, and it can still do some basic
traffic, only RTL8852B has the state. Coexistence need let Bluetooth
know WiFi is still alive to prevent some Bluetooth performance issue.

Signed-off-by: Ching-Te Ku <ku920601@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230314020617.28193-2-pkshih@realtek.com
19 months agoMerge branch 'mt7988-support'
David S. Miller [Mon, 3 Apr 2023 09:13:01 +0000 (10:13 +0100)]
Merge branch 'mt7988-support'

Daniel Golle says:

====================
net: dsa: add support for MT7988

The MediaTek MT7988 SoC comes with a built-in switch very similar to
previous MT7530 and MT7531. However, the switch address space is mapped
into the SoCs memory space rather than being connected via MDIO.
Using MMIO simplifies register access and also removes the need for a bus
lock, and for that reason also makes interrupt handling more light-weight.

Note that this is different from previous SoCs like MT7621 and MT7623N
which also came with an integrated MT7530-like switch which yet had to be
accessed via MDIO.

Split-off the part of the driver registering an MDIO driver, then add
another module acting as MMIO/platform driver.

The whole series has been tested on various MediaTek boards:
 * MT7623A + MT7530 (BPi-R2)
 * MT7986A + MT7531 (BPi-R3)
 * MT7988A reference board

Changes since v1:
 * use 'internal' PHY mode where appropriate
 * use regmap_update_bits in mt7530_rmw
 * improve dt-bindings

Changes since RFC v3:
 * WARN_ON_ONCE if register read fails
 * move probing of the reset GPIO and reset controller link out of
   common  probe function, as they are not actually common

Changes since RFC v2:
 * split into many small commits to ease review
 * introduce helper functions to reduce code duplication
 * use helpers for locking to make lock-skipping easier and less ugly
   to implement.
 * add dt-bindings for mediatek,mt7988-switch

Changes since initial RFC:
 * use regmap for register access and move register access to bus-
   specific driver
 * move initialization of MT7531 SGMII PCS to MDIO driver
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
19 months agodt-bindings: net: dsa: mediatek,mt7530: add mediatek,mt7988-switch
Daniel Golle [Mon, 3 Apr 2023 01:19:51 +0000 (02:19 +0100)]
dt-bindings: net: dsa: mediatek,mt7530: add mediatek,mt7988-switch

Add documentation for the built-in switch which can be found in the
MediaTek MT7988 SoC.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
19 months agonet: dsa: mt7530: introduce driver for MT7988 built-in switch
Daniel Golle [Mon, 3 Apr 2023 01:19:40 +0000 (02:19 +0100)]
net: dsa: mt7530: introduce driver for MT7988 built-in switch

Add driver for the built-in Gigabit Ethernet switch which can be found
in the MediaTek MT7988 SoC.

The switch shares most of its design with MT7530 and MT7531, but has
it's registers mapped into the SoCs register space rather than being
connected externally or internally via MDIO.

Introduce a new platform driver to support that.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
19 months agonet: dsa: mt7530: skip locking if MDIO bus isn't present
Daniel Golle [Mon, 3 Apr 2023 01:19:28 +0000 (02:19 +0100)]
net: dsa: mt7530: skip locking if MDIO bus isn't present

As MT7530 and MT7531 internally use 32-bit wide registers, each access
to any register of the switch requires several operations on the MDIO
bus. Hence if there is congruent access, e.g. due to PCS or PHY
polling, this can mess up and interfere with another ongoing register
access sequence.

However, the MDIO bus mutex is only relevant for MDIO-connected
switches. Prepare switches which have there registers directly mapped
into the SoCs register space via MMIO which do not require such
locking. There we can simply use regmap's default locking mechanism.

Hence guard mutex operations to only be performed in case of MDIO
connected switches.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
19 months agonet: dsa: mt7530: introduce separate MDIO driver
Daniel Golle [Mon, 3 Apr 2023 01:19:13 +0000 (02:19 +0100)]
net: dsa: mt7530: introduce separate MDIO driver

Split MT7530 switch driver into a common part and a part specific
for MDIO connected switches and multi-chip modules.
Move MDIO-specific functions to newly introduced mt7530-mdio.c while
keeping the common parts in mt7530.c.
Introduce new Kconfig symbol CONFIG_NET_DSA_MT7530_MDIO which is
implied by CONFIG_NET_DSA_MT7530.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
19 months agonet: dsa: mt7530: split-off common parts from mt7531_setup
Daniel Golle [Mon, 3 Apr 2023 01:19:02 +0000 (02:19 +0100)]
net: dsa: mt7530: split-off common parts from mt7531_setup

MT7988 shares a significant part of the setup function with MT7531.
Split-off those parts into a shared function which is going to be used
also by mt7988_setup.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
19 months agonet: dsa: mt7530: introduce mt7530_remove_common helper function
Daniel Golle [Mon, 3 Apr 2023 01:18:50 +0000 (02:18 +0100)]
net: dsa: mt7530: introduce mt7530_remove_common helper function

Move commonly used parts from mt7530_remove into new
mt7530_remove_common helper function which will be used by both,
mt7530_remove and the to-be-introduced mt7988_remove.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
19 months agonet: dsa: mt7530: introduce mt7530_probe_common helper function
Daniel Golle [Mon, 3 Apr 2023 01:18:39 +0000 (02:18 +0100)]
net: dsa: mt7530: introduce mt7530_probe_common helper function

Move commonly used parts from mt7530_probe into new mt7530_probe_common
helper function which will be used by both, mt7530_probe and the
to-be-introduced mt7988_probe.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
19 months agonet: dsa: mt7530: move p5_intf_modes() function to mt7530.c
Daniel Golle [Mon, 3 Apr 2023 01:18:28 +0000 (02:18 +0100)]
net: dsa: mt7530: move p5_intf_modes() function to mt7530.c

In preparation of splitting mt7530.c into a driver for MDIO-connected
as well as MDIO-accessed built-in switches on one hand and MMIO-accessed
built-in switches move the p5_inft_modes() function from mt7530.h to
mt7530.c. The function is only needed there and will trigger a compiler
warning about a defined but unused function otherwise when including
mt7530.h in the to-be-introduced bus-specific drivers.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
19 months agonet: dsa: mt7530: introduce mutex helpers
Daniel Golle [Mon, 3 Apr 2023 01:18:16 +0000 (02:18 +0100)]
net: dsa: mt7530: introduce mutex helpers

As the MDIO bus lock only needs to be involved if actually operating
on an MDIO-connected switch we will need to skip locking for built-in
switches which are accessed via MMIO.
Create helper functions which simplify that upcoming change.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
19 months agonet: dsa: mt7530: move SGMII PCS creation to mt7530_probe function
Daniel Golle [Mon, 3 Apr 2023 01:18:04 +0000 (02:18 +0100)]
net: dsa: mt7530: move SGMII PCS creation to mt7530_probe function

Move creating the SGMII PCS from mt753x_setup() to the more appropriate
mt7530_probe() function.
This is done also in preparation of moving all functions related to
MDIO-connected MT753x switches to a separate module.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
19 months agonet: dsa: mt7530: use regmap to access switch register space
Daniel Golle [Mon, 3 Apr 2023 01:17:52 +0000 (02:17 +0100)]
net: dsa: mt7530: use regmap to access switch register space

Use regmap API to access the switch register space.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
19 months agonet: dsa: mt7530: use unlocked regmap accessors
Daniel Golle [Mon, 3 Apr 2023 01:17:40 +0000 (02:17 +0100)]
net: dsa: mt7530: use unlocked regmap accessors

Instead of wrapping the locked register accessor functions, use the
unlocked variants and add locking wrapper functions to let regmap
handle the locking.

This is a preparation towards being able to always use regmap to
access switch registers instead of open-coded accessor functions.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
19 months agonet: dsa: mt7530: refactor SGMII PCS creation
Daniel Golle [Mon, 3 Apr 2023 01:17:30 +0000 (02:17 +0100)]
net: dsa: mt7530: refactor SGMII PCS creation

Instead of macro templates use a dedidated function and allocated
regmap_config when creating the regmaps for the pcs-mtk-lynxi
instances.
This is in preparation to switching to use unlocked regmap accessors
and have regmap's locking API handle locking for us.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
19 months agonet: dsa: mt7530: make some noise if register read fails
Daniel Golle [Mon, 3 Apr 2023 01:17:19 +0000 (02:17 +0100)]
net: dsa: mt7530: make some noise if register read fails

Simply returning the negative error value instead of the read value
doesn't seem like a good idea. Return 0 instead and add WARN_ON_ONCE(1)
so this kind of error will not go unnoticed.

Suggested-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
19 months agoMerge branch 'phy-smsc-edpd-tunable'
David S. Miller [Mon, 3 Apr 2023 09:08:43 +0000 (10:08 +0100)]
Merge branch 'phy-smsc-edpd-tunable'

Heiner Kallweit says:

====================
net: phy: smsc: add support for edpd tunable

This adds support for the EDPD PHY tunable.
Per default EDPD is disabled in interrupt mode, the tunable can be used
to override this, e.g. if the link partner doesn't use EDPD.
The interval to check for energy can be chosen between 1000ms and
2000ms. Note that this value consists of the 1000ms phylib interval
for state machine runs plus the time to wait for energy being detected.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
19 months agonet: phy: smsc: enable edpd tunable support
Heiner Kallweit [Sun, 2 Apr 2023 15:17:35 +0000 (17:17 +0200)]
net: phy: smsc: enable edpd tunable support

Enable EDPD PHY tunable support for all drivers using
lan87xx_read_status.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
19 months agonet: phy: smsc: add support for edpd tunable
Heiner Kallweit [Sun, 2 Apr 2023 15:16:56 +0000 (17:16 +0200)]
net: phy: smsc: add support for edpd tunable

This adds support for the EDPD PHY tunable.
Per default EDPD is disabled in interrupt mode, the tunable can be used
to override this, e.g. if the link partner doesn't use EDPD.
The interval to check for energy can be chosen between 1000ms and
2000ms. Note that this value consists of the 1000ms phylib interval
for state machine runs plus the time to wait for energy being detected.

v2:
- consider that phylib core holds phydev->lock when calling the
  phy tunable hooks

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
19 months agonet: phy: smsc: prepare for making edpd wait period configurable
Heiner Kallweit [Sun, 2 Apr 2023 15:14:35 +0000 (17:14 +0200)]
net: phy: smsc: prepare for making edpd wait period configurable

Add a member edpd_max_wait_ms to the private data structure in preparation
of making the wait period configurable by supporting the edpd phy tunable.

v2:
- rename constant to EDPD_MAX_WAIT_DFLT_MS

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
19 months agonet: phy: smsc: add flag edpd_mode_set_by_user
Heiner Kallweit [Sun, 2 Apr 2023 15:13:35 +0000 (17:13 +0200)]
net: phy: smsc: add flag edpd_mode_set_by_user

Add flag edpd_mode_set_by_user in preparation of adding edpd phy tunable
support. This flag will allow users to override the default behavior
of edpd being disabled if interrupt mode is used.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
19 months agonet: phy: smsc: clear edpd_enable if interrupt mode is used
Heiner Kallweit [Sun, 2 Apr 2023 15:13:05 +0000 (17:13 +0200)]
net: phy: smsc: clear edpd_enable if interrupt mode is used

Clear edpd_enable if interupt mode is used, this avoids
having to check for PHY_POLL multiple times.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
19 months agonet: phy: smsc: add helper smsc_phy_config_edpd
Heiner Kallweit [Sun, 2 Apr 2023 15:12:20 +0000 (17:12 +0200)]
net: phy: smsc: add helper smsc_phy_config_edpd

Add helper smsc_phy_config_edpd() and explicitly clear bit
MII_LAN83C185_EDPWRDOWN is edpd_enable isn't set.
Boot loader may have left whatever value.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
19 months agonet: phy: smsc: rename flag energy_enable
Heiner Kallweit [Sun, 2 Apr 2023 15:11:40 +0000 (17:11 +0200)]
net: phy: smsc: rename flag energy_enable

Rename the flag to edpd_enable, as we're not enabling energy but
edpd (energy detect power down) mode. In addition change the
type to a bit field member in preparation of adding further flags.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
19 months agoMerge branch 'dsa_master_ioctl-notifier'
David S. Miller [Mon, 3 Apr 2023 09:04:27 +0000 (10:04 +0100)]
Merge branch 'dsa_master_ioctl-notifier'

Vladimir Oltean says:

====================
net: Convert dsa_master_ioctl() to netdev notifier

This is preparatory work in order for Maxim Georgiev to be able to start
the API conversion process of hardware timestamping from ndo_eth_ioctl()
to ndo_hwtstamp_set():
https://lore.kernel.org/netdev/20230331045619.40256-1-glipus@gmail.com/

In turn, Maxim Georgiev's work is a preparation so that Köry Maincent is
able to make the active hardware timestamping layer selectable by user
space.
https://lore.kernel.org/netdev/20230308135936.761794-1-kory.maincent@bootlin.com/

So, quite some dependency chain.

Before this patch set, DSA prevented the conversion of any networking
driver from the ndo_eth_ioctl() API to the ndo_hwtstamp_set() API,
because it wanted to validate the hwtstamping settings on the DSA
master, and it was only coded up to do this using the old API.

After this patch set, a new netdev notifier exists, which does not
depend on anything that would constitute the "soon-to-be-legacy" API,
but rather, it uses a newly introduced struct kernel_hwtstamp_config,
and it doesn't issue any ioctl at all, being thus compatible both with
ndo_eth_ioctl(), and with the not-yet-introduced, but now possible,
ndo_hwtstamp_set().
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
19 months agonet: create a netdev notifier for DSA to reject PTP on DSA master
Vladimir Oltean [Sun, 2 Apr 2023 12:37:55 +0000 (15:37 +0300)]
net: create a netdev notifier for DSA to reject PTP on DSA master

The fact that PTP 2-step TX timestamping is broken on DSA switches if
the master also timestamps the same packets is documented by commit
f685e609a301 ("net: dsa: Deny PTP on master if switch supports it").
We attempt to help the users avoid shooting themselves in the foot by
making DSA reject the timestamping ioctls on an interface that is a DSA
master, and the switch tree beneath it contains switches which are aware
of PTP.

The only problem is that there isn't an established way of intercepting
ndo_eth_ioctl calls, so DSA creates avoidable burden upon the network
stack by creating a struct dsa_netdevice_ops with overlaid function
pointers that are manually checked from the relevant call sites. There
used to be 2 such dsa_netdevice_ops, but now, ndo_eth_ioctl is the only
one left.

There is an ongoing effort to migrate driver-visible hardware timestamping
control from the ndo_eth_ioctl() based API to a new ndo_hwtstamp_set()
model, but DSA actively prevents that migration, since dsa_master_ioctl()
is currently coded to manually call the master's legacy ndo_eth_ioctl(),
and so, whenever a network device driver would be converted to the new
API, DSA's restrictions would be circumvented, because any device could
be used as a DSA master.

The established way for unrelated modules to react on a net device event
is via netdevice notifiers. So we create a new notifier which gets
called whenever there is an attempt to change hardware timestamping
settings on a device.

Finally, there is another reason why a netdev notifier will be a good
idea, besides strictly DSA, and this has to do with PHY timestamping.

With ndo_eth_ioctl(), all MAC drivers must manually call
phy_has_hwtstamp() before deciding whether to act upon SIOCSHWTSTAMP,
otherwise they must pass this ioctl to the PHY driver via
phy_mii_ioctl().

With the new ndo_hwtstamp_set() API, it will be desirable to simply not
make any calls into the MAC device driver when timestamping should be
performed at the PHY level.

But there exist drivers, such as the lan966x switch, which need to
install packet traps for PTP regardless of whether they are the layer
that provides the hardware timestamps, or the PHY is. That would be
impossible to support with the new API.

The proposal there, too, is to introduce a netdev notifier which acts as
a better cue for switching drivers to add or remove PTP packet traps,
than ndo_hwtstamp_set(). The one introduced here "almost" works there as
well, except for the fact that packet traps should only be installed if
the PHY driver succeeded to enable hardware timestamping, whereas here,
we need to deny hardware timestamping on the DSA master before it
actually gets enabled. This is why this notifier is called "PRE_", and
the notifier that would get used for PHY timestamping and packet traps
would be called NETDEV_CHANGE_HWTSTAMP. This isn't a new concept, for
example NETDEV_CHANGEUPPER and NETDEV_PRECHANGEUPPER do the same thing.

In expectation of future netlink UAPI, we also pass a non-NULL extack
pointer to the netdev notifier, and we make DSA populate it with an
informative reason for the rejection. To avoid making it go to waste, we
make the ioctl-based dev_set_hwtstamp() create a fake extack and print
the message to the kernel log.

Link: https://lore.kernel.org/netdev/20230401191215.tvveoi3lkawgg6g4@skbuf/
Link: https://lore.kernel.org/netdev/20230310164451.ls7bbs6pdzs4m6pw@skbuf/
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>
19 months agonet: dsa: make dsa_port_supports_hwtstamp() construct a fake ifreq
Vladimir Oltean [Sun, 2 Apr 2023 12:37:54 +0000 (15:37 +0300)]
net: dsa: make dsa_port_supports_hwtstamp() construct a fake ifreq

dsa_master_ioctl() is in the process of getting converted to a different
API, where we won't have access to a struct ifreq * anymore, but rather,
to a struct kernel_hwtstamp_config.

Since ds->ops->port_hwtstamp_get() still uses struct ifreq *, this
creates a difficult situation where we have to make up such a dummy
pointer.

The conversion is a bit messy, because it forces a "good" implementation
of ds->ops->port_hwtstamp_get() to return -EFAULT in copy_to_user()
because of the NULL ifr->ifr_data pointer. However, it works, and it is
only a transient step until ds->ops->port_hwtstamp_get() gets converted
to the new API which passes struct kernel_hwtstamp_config and does not
call copy_to_user().

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>
19 months agonet: add struct kernel_hwtstamp_config and make net_hwtstamp_validate() use it
Vladimir Oltean [Sun, 2 Apr 2023 12:37:53 +0000 (15:37 +0300)]
net: add struct kernel_hwtstamp_config and make net_hwtstamp_validate() use it

Jakub Kicinski suggested that we may want to add new UAPI for
controlling hardware timestamping through netlink in the future, and in
that case, we will be limited to the struct hwtstamp_config that is
currently passed in fixed binary format through the SIOCGHWTSTAMP and
SIOCSHWTSTAMP ioctls. It would be good if new kernel code already
started operating on an extensible kernel variant of that structure,
similar in concept to struct kernel_ethtool_coalesce vs struct
ethtool_coalesce.

Since struct hwtstamp_config is in include/uapi/linux/net_tstamp.h, here
we introduce include/linux/net_tstamp.h which shadows that other header,
but also includes it, so that existing includers of this header work as
before. In addition to that, we add the definition for the kernel-only
structure, and a helper which translates all fields by manual copying.
I am doing a manual copy in order to not force the alignment (or type)
of the fields of struct kernel_hwtstamp_config to be the same as of
struct hwtstamp_config, even though now, they are the same.

Link: https://lore.kernel.org/netdev/20230330223519.36ce7d23@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>
19 months agonet: move copy_from_user() out of net_hwtstamp_validate()
Vladimir Oltean [Sun, 2 Apr 2023 12:37:52 +0000 (15:37 +0300)]
net: move copy_from_user() out of net_hwtstamp_validate()

The kernel will want to start using the more meaningful struct
hwtstamp_config pointer in more places, so move the copy_from_user() at
the beginning of dev_set_hwtstamp() in order to get to that, and pass
this argument to net_hwtstamp_validate().

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>
19 months agonet: promote SIOCSHWTSTAMP and SIOCGHWTSTAMP ioctls to dedicated handlers
Vladimir Oltean [Sun, 2 Apr 2023 12:37:51 +0000 (15:37 +0300)]
net: promote SIOCSHWTSTAMP and SIOCGHWTSTAMP ioctls to dedicated handlers

DSA does not want to intercept all ioctls handled by dev_eth_ioctl(),
only SIOCSHWTSTAMP. This can be seen from commit f685e609a301 ("net:
dsa: Deny PTP on master if switch supports it"). However, the way in
which the dsa_ndo_eth_ioctl() is called would suggest otherwise.

Split the handling of SIOCSHWTSTAMP and SIOCGHWTSTAMP ioctls into
separate case statements of dev_ifsioc(), and make each one call its own
sub-function. This also removes the dsa_ndo_eth_ioctl() call from
dev_eth_ioctl(), which from now on exclusively handles PHY ioctls.

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>
19 months agonet: simplify handling of dsa_ndo_eth_ioctl() return code
Vladimir Oltean [Sun, 2 Apr 2023 12:37:50 +0000 (15:37 +0300)]
net: simplify handling of dsa_ndo_eth_ioctl() return code

In the expression "x == 0 || x != -95", the term "x == 0" does not
change the expression's logical value, because 0 != -95, and so,
if x is 0, the expression would still be true by virtue of the second
term. If x is non-zero, the expression depends on the truth value of
the second term anyway. As such, the first term is redundant and can
be deleted.

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>
19 months agonet: don't abuse "default" case for unknown ioctl in dev_ifsioc()
Vladimir Oltean [Sun, 2 Apr 2023 12:37:49 +0000 (15:37 +0300)]
net: don't abuse "default" case for unknown ioctl in dev_ifsioc()

The "switch (cmd)" block from dev_ifsioc() gained a bit too much
unnecessary manual handling of "cmd" in the "default" case, starting
with the private ioctls.

Clean that up by using the "ellipsis" gcc extension, adding separate
cases for the rest of the ioctls, and letting the default case only
return -EINVAL.

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>
19 months agonet: alteon: remove unused len variable
Tom Rix [Fri, 31 Mar 2023 20:55:45 +0000 (16:55 -0400)]
net: alteon: remove unused len variable

clang with W=1 reports
drivers/net/ethernet/alteon/acenic.c:2438:10: error: variable
  'len' set but not used [-Werror,-Wunused-but-set-variable]
                int i, len = 0;
                       ^
This variable is not used so remove it.

Signed-off-by: Tom Rix <trix@redhat.com>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
19 months agoMerge branch 'mlxsw-transceiver-trip-points'
David S. Miller [Sun, 2 Apr 2023 12:42:30 +0000 (13:42 +0100)]
Merge branch 'mlxsw-transceiver-trip-points'

Petr Machata says:

====================
mlxsw: Use static trip points for transceiver modules

Ido Schimmel writes:

See patch #1 for motivation and implementation details.

Patches #2-#3 are simple cleanups as a result of the changes in the
first patch.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
19 months agomlxsw: core_thermal: Simplify transceiver module get_temp() callback
Ido Schimmel [Fri, 31 Mar 2023 14:17:32 +0000 (16:17 +0200)]
mlxsw: core_thermal: Simplify transceiver module get_temp() callback

The get_temp() callback of a thermal zone associated with a transceiver
module no longer needs to read the temperature thresholds of the module.
Therefore, simplify the callback by only reading the temperature.

Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: Vadim Pasternak <vadimp@nvidia.com>
Signed-off-by: Petr Machata <petrm@nvidia.com>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
19 months agomlxsw: core_thermal: Make mlxsw_thermal_module_init() void
Ido Schimmel [Fri, 31 Mar 2023 14:17:31 +0000 (16:17 +0200)]
mlxsw: core_thermal: Make mlxsw_thermal_module_init() void

The function can no longer fail so make it void and remove the
associated error path.

Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: Vadim Pasternak <vadimp@nvidia.com>
Signed-off-by: Petr Machata <petrm@nvidia.com>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
19 months agomlxsw: core_thermal: Use static trip points for transceiver modules
Ido Schimmel [Fri, 31 Mar 2023 14:17:30 +0000 (16:17 +0200)]
mlxsw: core_thermal: Use static trip points for transceiver modules

The driver registers a thermal zone for each transceiver module and
tries to set the trip point temperatures according to the thresholds
read from the transceiver. If a threshold cannot be read or if a
transceiver is unplugged, the trip point temperature is set to zero,
which means that it is disabled as far as the thermal subsystem is
concerned.

A recent change in the thermal core made it so that such trip points are
no longer marked as disabled, which lead the thermal subsystem to
incorrectly set the associated cooling devices to the their maximum
state [1]. A fix to restore this behavior was merged in commit
f1b80a3878b2 ("thermal: core: Restore behavior regarding invalid trip
points"). However, the thermal maintainer suggested to not rely on this
behavior and instead always register a valid array of trip points [2].

Therefore, create a static array of trip points with sane defaults
(suggested by Vadim) and register it with the thermal zone of each
transceiver module. User space can choose to override these defaults
using the thermal zone sysfs interface since these files are writeable.

Before:

 $ cat /sys/class/thermal/thermal_zone11/type
 mlxsw-module11
 $ cat /sys/class/thermal/thermal_zone11/trip_point_*_temp
 65000
 75000
 80000

After:

 $ cat /sys/class/thermal/thermal_zone11/type
 mlxsw-module11
 $ cat /sys/class/thermal/thermal_zone11/trip_point_*_temp
 55000
 65000
 80000

Also tested by reverting commit f1b80a3878b2 ("thermal: core: Restore
behavior regarding invalid trip points") and making sure that the
associated cooling devices are not set to their maximum state.

[1] https://lore.kernel.org/linux-pm/ZA3CFNhU4AbtsP4G@shredder/
[2] https://lore.kernel.org/linux-pm/f78e6b70-a963-c0ca-a4b2-0d4c6aeef1fb@linaro.org/

Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: Vadim Pasternak <vadimp@nvidia.com>
Signed-off-by: Petr Machata <petrm@nvidia.com>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
19 months agonet: minor reshuffle of napi_struct
Jakub Kicinski [Fri, 31 Mar 2023 04:47:31 +0000 (21:47 -0700)]
net: minor reshuffle of napi_struct

napi_id is read by GRO and drivers to mark skbs, and it currently
sits at the end of the structure, in a mostly unused cache line.
Move it up into a hole, and separate the clearly control path
fields from the important ones.

Before:

struct napi_struct {
struct list_head           poll_list;            /*     0    16 */
long unsigned int          state;                /*    16     8 */
int                        weight;               /*    24     4 */
int                        defer_hard_irqs_count; /*    28     4 */
long unsigned int          gro_bitmask;          /*    32     8 */
int                        (*poll)(struct napi_struct *, int); /*    40     8 */
int                        poll_owner;           /*    48     4 */

/* XXX 4 bytes hole, try to pack */

struct net_device *        dev;                  /*    56     8 */
/* --- cacheline 1 boundary (64 bytes) --- */
struct gro_list            gro_hash[8];          /*    64   192 */
/* --- cacheline 4 boundary (256 bytes) --- */
struct sk_buff *           skb;                  /*   256     8 */
struct list_head           rx_list;              /*   264    16 */
int                        rx_count;             /*   280     4 */

/* XXX 4 bytes hole, try to pack */

struct hrtimer             timer;                /*   288    64 */

/* XXX last struct has 4 bytes of padding */

/* --- cacheline 5 boundary (320 bytes) was 32 bytes ago --- */
struct list_head           dev_list;             /*   352    16 */
struct hlist_node          napi_hash_node;       /*   368    16 */
/* --- cacheline 6 boundary (384 bytes) --- */
unsigned int               napi_id;              /*   384     4 */

/* XXX 4 bytes hole, try to pack */

struct task_struct *       thread;               /*   392     8 */

/* size: 400, cachelines: 7, members: 17 */
/* sum members: 388, holes: 3, sum holes: 12 */
/* paddings: 1, sum paddings: 4 */
/* last cacheline: 16 bytes */
};

After:

struct napi_struct {
struct list_head           poll_list;            /*     0    16 */
long unsigned int          state;                /*    16     8 */
int                        weight;               /*    24     4 */
int                        defer_hard_irqs_count; /*    28     4 */
long unsigned int          gro_bitmask;          /*    32     8 */
int                        (*poll)(struct napi_struct *, int); /*    40     8 */
int                        poll_owner;           /*    48     4 */

/* XXX 4 bytes hole, try to pack */

struct net_device *        dev;                  /*    56     8 */
/* --- cacheline 1 boundary (64 bytes) --- */
struct gro_list            gro_hash[8];          /*    64   192 */
/* --- cacheline 4 boundary (256 bytes) --- */
struct sk_buff *           skb;                  /*   256     8 */
struct list_head           rx_list;              /*   264    16 */
int                        rx_count;             /*   280     4 */
unsigned int               napi_id;              /*   284     4 */
struct hrtimer             timer;                /*   288    64 */

/* XXX last struct has 4 bytes of padding */

/* --- cacheline 5 boundary (320 bytes) was 32 bytes ago --- */
struct task_struct *       thread;               /*   352     8 */
struct list_head           dev_list;             /*   360    16 */
struct hlist_node          napi_hash_node;       /*   376    16 */

/* size: 392, cachelines: 7, members: 17 */
/* sum members: 388, holes: 1, sum holes: 4 */
/* paddings: 1, sum paddings: 4 */
/* forced alignments: 1 */
/* last cacheline: 8 bytes */
} __attribute__((__aligned__(8)));

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
19 months agoi40e: Add support for VF to specify its primary MAC address
Sylwester Dziedziuch [Thu, 30 Mar 2023 17:00:22 +0000 (10:00 -0700)]
i40e: Add support for VF to specify its primary MAC address

Currently in the i40e driver there is no implementation of different
MAC address handling depending on whether it is a legacy or primary.
Introduce new checks for VF to be able to specify its primary MAC
address based on the VIRTCHNL_ETHER_ADDR_PRIMARY type.

Primary MAC address are treated differently compared to legacy
ones in a scenario where:
1. If a unicast MAC is being added and it's specified as
VIRTCHNL_ETHER_ADDR_PRIMARY, then replace the current
default_lan_addr.addr.
2. If a unicast MAC is being deleted and it's type
is specified as VIRTCHNL_ETHER_ADDR_PRIMARY, then zero the
hw_lan_addr.addr.

Signed-off-by: Sylwester Dziedziuch <sylwesterx.dziedziuch@intel.com>
Signed-off-by: Mateusz Palczewski <mateusz.palczewski@intel.com>
Tested-by: Rafal Romanowski <rafal.romanowski@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
19 months agoMerge branch '100GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/next...
Jakub Kicinski [Sat, 1 Apr 2023 04:41:11 +0000 (21:41 -0700)]
Merge branch '100GbE' of git://git./linux/kernel/git/tnguy/next-queue

Tony Nguyen says:

====================
Intel Wired LAN Driver Updates 2023-03-30 (documentation, ice)

This series contains updates to driver documentation and the ice driver.

Tony removes links and addresses related to the out-of-tree driver from the
Intel ethernet driver documentation.

Jake removes a comment that is no longer valid to the ice driver.

* '100GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/next-queue:
  ice: remove comment about not supporting driver reinit
  Documentation/eth/intel: Remove references to SourceForge
  Documentation/eth/intel: Update address for driver support
====================

Link: https://lore.kernel.org/r/20230330165935.2503604-1-anthony.l.nguyen@intel.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
19 months agoMerge tag 'nf-next-2023-03-30' of https://git.kernel.org/pub/scm/linux/kernel/git...
Jakub Kicinski [Fri, 31 Mar 2023 17:39:33 +0000 (10:39 -0700)]
Merge tag 'nf-next-2023-03-30' of https://git./linux/kernel/git/netfilter/nf-next

Florian Westphal says:

====================
netfilter updates for net-next

1. No need to disable BH in nfnetlink proc handler, freeing happens
   via call_rcu.
2. Expose classid in nfetlink_queue, from Eric Sage.
3. Fix nfnetlink message description comments, from Matthieu De Beule.
4. Allow removal of offloaded connections via ctnetlink, from Paul Blakey.

* tag 'nf-next-2023-03-30' of https://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf-next:
  netfilter: ctnetlink: Support offloaded conntrack entry deletion
  netfilter: Correct documentation errors in nf_tables.h
  netfilter: nfnetlink_queue: enable classid socket info retrieval
  netfilter: nfnetlink_log: remove rcu_bh usage
====================

Link: https://lore.kernel.org/r/20230331104809.2959-1-fw@strlen.de
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
19 months agodt-bindings: net: fec: add power-domains property
Peng Fan [Tue, 28 Mar 2023 06:15:18 +0000 (14:15 +0800)]
dt-bindings: net: fec: add power-domains property

Add optional power domains property

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20230328061518.1985981-1-peng.fan@oss.nxp.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
19 months agobcma: remove unused mips_read32 function
Tom Rix [Fri, 24 Mar 2023 19:06:47 +0000 (15:06 -0400)]
bcma: remove unused mips_read32 function

clang with W=1 reports
drivers/bcma/driver_mips.c:49:19: error: unused function
  'mips_read32' [-Werror,-Wunused-function]
static inline u32 mips_read32(struct bcma_drv_mips *mcore,
                  ^
This function is not used so remove it.

Signed-off-by: Tom Rix <trix@redhat.com>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230324190647.2654293-1-trix@redhat.com
19 months agobcma: Use of_address_to_resource()
Rob Herring [Sun, 19 Mar 2023 16:31:59 +0000 (11:31 -0500)]
bcma: Use of_address_to_resource()

Replace of_get_address() and of_translate_address() calls with single
call to of_address_to_resource().

Signed-off-by: Rob Herring <robh@kernel.org>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230319163159.225773-1-robh@kernel.org
19 months agowifi: mwifiex: remove unused evt_buf variable
Tom Rix [Wed, 29 Mar 2023 13:14:44 +0000 (09:14 -0400)]
wifi: mwifiex: remove unused evt_buf variable

clang with W=1 reports
drivers/net/wireless/marvell/mwifiex/11h.c:198:6: error: variable
  'evt_buf' set but not used [-Werror,-Wunused-but-set-variable]
        u8 *evt_buf;
            ^
This variable is not used so remove it.

Signed-off-by: Tom Rix <trix@redhat.com>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230329131444.1809018-1-trix@redhat.com
19 months agowifi: brcmsmac: ampdu: remove unused suc_mpdu variable
Tom Rix [Mon, 27 Mar 2023 15:11:51 +0000 (11:11 -0400)]
wifi: brcmsmac: ampdu: remove unused suc_mpdu variable

clang with W=1 reports
drivers/net/wireless/broadcom/brcm80211/brcmsmac/ampdu.c:848:5: error: variable
  'suc_mpdu' set but not used [-Werror,-Wunused-but-set-variable]
        u8 suc_mpdu = 0, tot_mpdu = 0;
           ^
This variable is not used so remove it.

Signed-off-by: Tom Rix <trix@redhat.com>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230327151151.1771350-1-trix@redhat.com
19 months agowifi: rtlwifi: fix incorrect error codes in rtl_debugfs_set_write_reg()
Wei Chen [Sun, 26 Mar 2023 05:42:17 +0000 (05:42 +0000)]
wifi: rtlwifi: fix incorrect error codes in rtl_debugfs_set_write_reg()

If there is a failure during copy_from_user or user-provided data buffer is
invalid, rtl_debugfs_set_write_reg should return negative error code instead
of a positive value count.

Fix this bug by returning correct error code. Moreover, the check of buffer
against null is removed since it will be handled by copy_from_user.

Fixes: 610247f46feb ("rtlwifi: Improve debugging by using debugfs")
Signed-off-by: Wei Chen <harperchen1110@gmail.com>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230326054217.93492-1-harperchen1110@gmail.com
19 months agowifi: rtlwifi: fix incorrect error codes in rtl_debugfs_set_write_rfreg()
Wei Chen [Sun, 26 Mar 2023 05:31:38 +0000 (05:31 +0000)]
wifi: rtlwifi: fix incorrect error codes in rtl_debugfs_set_write_rfreg()

If there is a failure during copy_from_user or user-provided data buffer
is invalid, rtl_debugfs_set_write_rfreg should return negative error code
instead of a positive value count.

Fix this bug by returning correct error code. Moreover, the check of buffer
against null is removed since it will be handled by copy_from_user.

Fixes: 610247f46feb ("rtlwifi: Improve debugging by using debugfs")
Signed-off-by: Wei Chen <harperchen1110@gmail.com>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230326053138.91338-1-harperchen1110@gmail.com
19 months agowifi: brcmsmac: remove unused has_5g variable
Tom Rix [Sat, 25 Mar 2023 13:03:43 +0000 (09:03 -0400)]
wifi: brcmsmac: remove unused has_5g variable

clang with W=1 reports
drivers/net/wireless/broadcom/brcm80211/brcmsmac/mac80211_if.c:1051:6: error:
  variable 'has_5g' set but not used [-Werror,-Wunused-but-set-variable]
        int has_5g = 0;
            ^
This variable is not used so remove it.

Signed-off-by: Tom Rix <trix@redhat.com>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230325130343.1334209-1-trix@redhat.com
19 months agowifi: b43legacy: remove unused freq_r3A_value function
Tom Rix [Fri, 24 Mar 2023 13:50:22 +0000 (09:50 -0400)]
wifi: b43legacy: remove unused freq_r3A_value function

clang with W=1 reports
drivers/net/wireless/broadcom/b43legacy/radio.c:1713:5: error:
  unused function 'freq_r3A_value' [-Werror,-Wunused-function]
u16 freq_r3A_value(u16 frequency)
    ^
This function is not used so remove it.

Signed-off-by: Tom Rix <trix@redhat.com>
Acked-by: Larry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230324135022.2649735-1-trix@redhat.com
19 months agowifi: rtlwifi: Replace fake flex-array with flex-array member
Gustavo A. R. Silva [Fri, 24 Mar 2023 01:11:35 +0000 (19:11 -0600)]
wifi: rtlwifi: Replace fake flex-array with flex-array member

Zero-length arrays as fake flexible arrays are deprecated and we are
moving towards adopting C99 flexible-array members instead.

Address the following warning found with GCC-13 and
-fstrict-flex-arrays=3 enabled:
In function ‘fortify_memset_chk’,
    inlined from ‘rtl_usb_probe’ at drivers/net/wireless/realtek/rtlwifi/usb.c:1044:2:
./include/linux/fortify-string.h:430:25: warning: call to ‘__write_overflow_field’ declared with attribute warning: detected write beyond size of field (1st parameter); maybe use struct_group()? [-Wattribute-warning]
  430 |                         __write_overflow_field(p_size_field, size);
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This helps with the ongoing efforts to tighten the FORTIFY_SOURCE
routines on memcpy() and help us make progress towards globally
enabling -fstrict-flex-arrays=3 [1].

Link: https://github.com/KSPP/linux/issues/21
Link: https://github.com/KSPP/linux/issues/277
Link: https://gcc.gnu.org/pipermail/gcc-patches/2022-October/602902.html
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Acked-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/ZBz4x+MWoI/f65o1@work
19 months agowifi: rtw88: Remove redundant pci_clear_master
Cai Huoqing [Thu, 23 Mar 2023 11:26:12 +0000 (19:26 +0800)]
wifi: rtw88: Remove redundant pci_clear_master

Remove pci_clear_master to simplify the code,
the bus-mastering is also cleared in do_pci_disable_device,
like this:
./drivers/pci/pci.c:2197
static void do_pci_disable_device(struct pci_dev *dev)
{
u16 pci_command;

pci_read_config_word(dev, PCI_COMMAND, &pci_command);
if (pci_command & PCI_COMMAND_MASTER) {
pci_command &= ~PCI_COMMAND_MASTER;
pci_write_config_word(dev, PCI_COMMAND, pci_command);
}

pcibios_disable_device(dev);
}.
And dev->is_busmaster is set to 0 in pci_disable_device.

Signed-off-by: Cai Huoqing <cai.huoqing@linux.dev>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Reviewed-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230323112613.7550-4-cai.huoqing@linux.dev