summaryrefslogtreecommitdiff
path: root/drivers/staging/fsl-dpaa2
AgeCommit message (Collapse)Author
2021-03-10staging: dpaa2-switch: move the driver out of stagingIoana Ciornei
Now that the dpaa2-switch driver has basic I/O capabilities on the switch port net_devices and multiple bridging domains are supported, move the driver out of staging. The dpaa2-switch driver is placed right next to the dpaa2-eth driver since, in the near future, they will be sharing most of the data path. I didn't implement code reuse in this patch series because I wanted to keep it as small as possible. Also, the README is removed from staging with the intention to add proper rst documentation afterwards to actually match was is supported by the driver. Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2021-03-10staging: dpaa2-switch: prevent joining a bridge while VLAN uppers are presentIoana Ciornei
Each time a switch port joins a bridge, it will start to use a FDB table common with all the other switch ports that are under the same bridge. This means that any VLAN added prior to a bridge join, will retain its previous FDB table destination. With this patch, I choose to restrict when a switch port can change it's upper device (either join or leave) so that the driver does not have to delete all the previously installed VLANs from the previous FDB and add them into the new one. Thus, in the PRECHANGEUPPER notification we check if there are any VLAN type upper devices and if that's true, deny the CHANGEUPPER. This way, the user is not restricted in the topology but rather in the order in which the setup is done: it must first create the bridging domain layout and after that add the necessary VLAN devices if necessary. The teardown is similar, the VLAN devices will need to be destroyed prior to a change in the bridging layout. Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2021-03-10staging: dpaa2-switch: add fast-ageing on bridge leaveIoana Ciornei
Upon leaving a bridge, any MAC addresses learnt on the switch port prior to this point have to be removed so that we preserve the bridging domain configuration. Restructure the dpaa2_switch_port_fdb_dump() function in order to have a common dpaa2_switch_fdb_iterate() function between the FDB dump callback and the fast age procedure. To accomplish this, add a new callback - dpaa2_switch_fdb_cb_t - which will be called on each MAC addr and, depending on the situation, will either dump the FDB entry into a netlink message or will delete the address from the FDB table, in case of the fast-age. Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2021-03-10staging: dpaa2-switch: accept only vlan-aware upper devicesIoana Ciornei
The DPAA2 Switch is not capable to handle traffic in a VLAN unaware fashion, thus the previous handling of both the accepted upper devices and the SWITCHDEV_ATTR_ID_BRIDGE_VLAN_FILTERING flag was wrong. Fix this by checking if the bridge that we are joining is indeed VLAN aware, if not return an error. Also, the RX VLAN filtering feature is defined as 'on [fixed]' and the .ndo_vlan_rx_add_vid() and .ndo_vlan_rx_kill_vid() callbacks are implemented just by recreating a switchdev_obj_port_vlan object and then calling the same functions used on the switchdev notifier path. In addition, changing the vlan_filtering flag to 0 on a bridge under which a DPAA2 switch interface is present is not supported, thus rejected when SWITCHDEV_ATTR_ID_BRIDGE_VLAN_FILTERING is received with such a request. This patch is also adding the use of the switchdev_handle_port_attr_set function so that we can iterate through all the lower devices of the bridge that the notification was received on and actually catch if the user is trying to change the vlan_filtering state. Since on a VLAN filtering change the net_device is the bridge, we also move the dpaa2_switch_port_dev_check call so that we do not return NOTIFY_DONE right away. Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com> Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2021-03-10staging: dpaa2-switch: move the notifier register to module_init()Ioana Ciornei
Move the notifier blocks register into the module_init() step, instead of object probe, so that all DPSW devices probed by the dpaa2-switch driver can use the same notifiers. This will enable us to have a more straightforward approach in determining if an event is intended for an object managed by this driver or not. Previously, the dpaa2_switch_port_dev_check() function was forced to also check the notifier block beside the net_device_ops structure to determine if the event is for us or not. Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2021-03-10staging: dpaa2-switch: properly setup switching domainsIoana Ciornei
Until now, the DPAA2 switch was not capable to properly setup its switching domains depending on the existence, or lack thereof, of a upper bridge device. This meant that all switch ports of a DPSW object were switching by default even though they were not under the same bridge device. Another issue was the inability to actually add the CPU in the flooding domains (broadcast, unknown unicast etc) of a particular switch port. This meant that a simple ping on a switch interface was not possible since no broadcast ARP frame would actually reach the CPU queues. This patch tries to fix exactly these problems by: * Creating and managing a FDB table for each flooding domain. This means that when a switch interface is not bridged it will use its own FDB table. While in bridged mode all DPAA2 switch interfaces under the same upper will use the same FDB table, thus leverage the same FDB entries. * Adding a new MC firmware command - dpsw_set_egress_flood() - through which the driver can setup the flooding domains as needed. For example, when the switch interface is standalone, thus not in a bridge with any other DPAA2 switch port, it will setup its broadcast and unknown unicast flooding domains to only include the control interface (the queues that reach the CPU and the driver can dequeue from). This flooding domain changes when the interface joins a bridge and is configured to include, beside the control interface, all other DPAA2 switch interfaces. We impose a minimum limit of FDB tables available equal to the number of switch interfaces so that we guarantee that, in the maximal configuration - all interfaces are standalone, each switch port will have a private FDB table. At the same time, we only probe DPSW objects that have the flooding and broadcast replicators configured to be per FDB (DPSW_*_PER_FDB). Without this, the dpaa2-switch driver would not be able to configure multiple switching domains. At probe time, a FDB table will be allocated for each port. At a bridge join event, the switch port will either continue to use the current FDB table (if it's the first dpaa2-switch port to join that bridge) or will switch to use the FDB table associated with the port that it's already under the bridge. If a FDB switch is necessary, the private FDB table which was previously used will be returned to the pool of unused FDBs. Upon a bridge leave, the switch port needs a private FDB table thus it will search and get the first unused FDB table. This way, all the other ports remaining under the bridge will continue to use the same FDB table. Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com> Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2021-03-10staging: dpaa2-switch: enable the control interfaceIoana Ciornei
Enable the CTRL_IF of the switch object, now that all the pieces are in place (buffer and queue management, interrupts, NAPI instances etc). Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com> Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2021-03-10staging: dpaa2-switch: add .ndo_start_xmit() callbackIoana Ciornei
Implement the .ndo_start_xmit() callback for the switch port interfaces. For each of the switch ports, gather the corresponding queue destination ID (QDID) necessary for Tx enqueueing. We'll reserve 64 bytes for software annotations, where we keep a skb backpointer used on the Tx confirmation side for releasing the allocated memory. At the moment, we only support linear skbs. Also, add support for the Tx confirmation path which for the most part shares the code path with the normal Rx queue. Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2021-03-10staging: dpaa2-switch: handle Rx path on control interfaceIoana Ciornei
The dpaa2-ethsw supports only one Rx queue that is shared by all switch ports. This means that information about which port was the ingress port for a specific frame needs to be passed in metadata. In our case, the Flow Context (FLC) field from the frame descriptor holds this information. Besides the interface ID of the ingress port we also receive the virtual QDID of the port. Below is a visual description of the 64 bits of FLC. 63 47 31 15 0 +---------------------------------------------------+ | | | | | | RESERVED | IF_ID | RESERVED | IF QDID | | | | | | +---------------------------------------------------+ Because all switch ports share the same Rx and Tx conf queues, NAPI management takes into consideration when there is at least one switch interface open to enable the NAPI instance. The Rx path is common, for the most part, for both Rx and Tx conf with the mention that each of them has its own consume function of a frame descriptor. Dequeueing from a FQ, consuming dequeued store and also the NAPI poll function is common between both queues. Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com> Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2021-03-10staging: dpaa2-switch: setup dpioIoana Ciornei
Setup interrupts on the control interface queues. We do not force an exact affinity between the interrupts received from a specific queue and a cpu. Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com> Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2021-03-10staging: dpaa2-switch: setup buffer pool and RX path ringsIoana Ciornei
Allocate and setup a buffer pool, needed on the Rx path of the control interface. Also, define the Rx buffer size seen by the WRIOP from the PAGE_SIZE buffers seeded. Also, create the needed Rx rings for both frame queues used on the control interface. On the Rx path, when a pull-dequeue operation is performed on a software portal, available frame descriptors are put in a ring - a DMA memory storage - for further usage. Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com> Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2021-03-10staging: dpaa2-switch: get control interface attributesIoana Ciornei
Introduce a new structure to hold all necessary info related to an RX queue for the control interface and populate the FQ IDs. We only have one Rx queue and one Tx confirmation queue on the control interface, both shared by all the switch ports. Also, increase the minimum version of the object supported by the driver since for a basic switch driver support we'll be in need for some ABIs added in the latest version of firmware. Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com> Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2021-03-10staging: dpaa2-switch: remove obsolete .ndo_fdb_{add|del} callbacksIoana Ciornei
Since the dpaa2-switch already listens for SWITCHDEV_FDB_ADD_TO_DEVICE / SWITCHDEV_FDB_DEL_TO_DEVICE events emitted by the bridge, we don't need the bridge bypass operations, and now is a good time to delete them. All 'bridge fdb' commands need the 'master' flag specified now. In fact, having the obsolete .ndo_fdb_{add|del} callbacks would even complicate the bridge leave/join procedures without any real benefit. Every FDB entry is installed in an FDB ID as far as the hardware is concerned, and the dpaa2-switch ports change their FDB ID when they join or leave a bridge. So we would need to manually delete these FDB entries when the FDB ID changes. That's because, unlike FDB entries added through switchdev, where the bridge automatically deletes those on leave, there isn't anybody who will remove the static FDB entries installed via the bridge bypass operations upon a change in the upper device. Note that we still need .ndo_fdb_dump though. The dpaa2-switch does not emit any interrupts when a new address is learnt, so we cannot keep the bridge FDB in sync with the hardware FDB. Therefore, we need this callback to get a chance to print the FDB entries that were dynamically learnt by our hardware. Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com> Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2021-03-10staging: dpaa2-switch: fix up initial forwarding configuration done by firmwareIoana Ciornei
By default, the DPSW object is configured with VLAN ID 1 in the VLAN table, which all ports are member of. This entry in the VLAN table selects the same FDB ID for all ports, meaning that forwarding between ports is permitted. This is unlike the switchdev model, where each port should operate as standalone by default. To make the switch operate in standalone ports mode, we need the VLAN table to select a unique FDB ID for each port. In order to do that, we need to simply delete the VLAN 1 created automatically by firmware, and let dpaa2_switch_port_init take over, by readding VLAN ID 1, but pointing towards a unique FDB ID. Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2021-03-10staging: dpaa2-switch: remove broken learning and flooding supportIoana Ciornei
This patch is removing the current configuration of learning and flooding states per switch port because they are essentially broken in terms of integration with the switchdev APIs and the bridge understanding of these states. First of all, the learning state is a per switch port configuration while the dpaa2-switch driver was using it to configure the entire bridging domain. This is broken since the software learning state could be out of sync with the hardware state when ports from the same bridging domain are configured by the user with different learning parameters. The BR_FLOOD flag has been misinterpreted as well. Instead of denoting whether unicast traffic for which there is no FDB entry will be flooded towards a given port, the dpaa2-switch used the flag to configure whether or not a frame with an unknown destination received on a given port should be flooded or not. In summary, it was used as ingress setting instead of a egress one. Also, remove the unnecessary call to dpsw_if_set_broadcast() and the API definition. The HW default is to let all switch ports to be able to flood broadcast traffic thus there is no need to call the API again. Instead of trying to patch things up, just remove the support for the moment so that we'll add it back cleanly once the driver is out of staging. Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com> Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2021-02-20Merge tag 'staging-5.12-rc1' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging Pull staging and IIO driver updates from Greg KH: "Here is the "big" set of staging and IIO driver patches for 5.12-rc1. Nothing really huge in here, the number of staging tree patches has gone down for a bit, maybe there's only so much churn to happen in here at the moment. The IIO changes are: - new drivers - new DT bindings - new iio driver features with full details in the shortlog. The staging driver patches are just a lot of tiny coding style cleanups, along with some semi-larger hikey driver cleanups as those are _almost_ good enough to get out of the staging tree, but will probably have to wait until 5.13 to have happen. All of these have been in linux-next with no reported issues" * tag 'staging-5.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging: (189 commits) staging: hikey9xx: Fix alignment of function parameters staging: greybus: Fixed a misspelling in hid.c staging: wimax/i2400m: fix some byte order issues found by sparse staging: wimax: i2400m: fix some incorrect type warnings staging: greybus: minor code style fix staging:wlan-ng: use memdup_user instead of kmalloc/copy_from_user staging:r8188eu: use IEEE80211_FCTL_* kernel definitions staging: rtl8192e: remove multiple blank lines staging: greybus: Fixed alignment issue in hid.c staging: wfx: remove unused included header files staging: nvec: minor coding style fix staging: wimax: Fix some coding style problem staging: fbtft: add tearing signal detect staging: vt6656: Fixed issue with alignment in rf.c staging: qlge: Remove duplicate word in comment staging: rtl8723bs: remove obsolete commented out code staging: rtl8723bs: fix function comments to follow kernel-doc staging: wfx: avoid defining array of flexible struct staging: rtl8723bs: Replace one-element array with flexible-array member in struct ndis_80211_var_ie staging: Replace lkml.org links with lore ...
2021-02-12net: switchdev: pass flags and mask to both {PRE_,}BRIDGE_FLAGS attributesVladimir Oltean
This switchdev attribute offers a counterproductive API for a driver writer, because although br_switchdev_set_port_flag gets passed a "flags" and a "mask", those are passed piecemeal to the driver, so while the PRE_BRIDGE_FLAGS listener knows what changed because it has the "mask", the BRIDGE_FLAGS listener doesn't, because it only has the final value. But certain drivers can offload only certain combinations of settings, like for example they cannot change unicast flooding independently of multicast flooding - they must be both on or both off. The way the information is passed to switchdev makes drivers not expressive enough, and unable to reject this request ahead of time, in the PRE_BRIDGE_FLAGS notifier, so they are forced to reject it during the deferred BRIDGE_FLAGS attribute, where the rejection is currently ignored. This patch also changes drivers to make use of the "mask" field for edge detection when possible. Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> Reviewed-by: Grygorii Strashko <grygorii.strashko@ti.com> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2021-02-04staging: fsl-dpaa2: Switch from strlcpy to strscpyKumar Kartikeya Dwivedi
strlcpy is marked as deprecated in Documentation/process/deprecated.rst, and there is no functional difference when the caller expects truncation (when not checking the return value). strscpy is relatively better as it also avoids scanning the whole source string. This silences the related checkpatch warnings from: 5dbdb2d87c29 ("checkpatch: prefer strscpy to strlcpy") Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com> Link: https://lore.kernel.org/r/20210131172838.146706-4-memxor@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-01-11net: switchdev: remove the transaction structure from port attributesVladimir Oltean
Since the introduction of the switchdev API, port attributes were transmitted to drivers for offloading using a two-step transactional model, with a prepare phase that was supposed to catch all errors, and a commit phase that was supposed to never fail. Some classes of failures can never be avoided, like hardware access, or memory allocation. In the latter case, merely attempting to move the memory allocation to the preparation phase makes it impossible to avoid memory leaks, since commit 91cf8eceffc1 ("switchdev: Remove unused transaction item queue") which has removed the unused mechanism of passing on the allocated memory between one phase and another. It is time we admit that separating the preparation from the commit phase is something that is best left for the driver to decide, and not something that should be baked into the API, especially since there are no switchdev callers that depend on this. This patch removes the struct switchdev_trans member from switchdev port attribute notifier structures, and converts drivers to not look at this member. In part, this patch contains a revert of my previous commit 2e554a7a5d8a ("net: dsa: propagate switchdev vlan_filtering prepare phase to drivers"). For the most part, the conversion was trivial except for: - Rocker's world implementation based on Broadcom OF-DPA had an odd implementation of ofdpa_port_attr_bridge_flags_set. The conversion was done mechanically, by pasting the implementation twice, then only keeping the code that would get executed during prepare phase on top, then only keeping the code that gets executed during the commit phase on bottom, then simplifying the resulting code until this was obtained. - DSA's offloading of STP state, bridge flags, VLAN filtering and multicast router could be converted right away. But the ageing time could not, so a shim was introduced and this was left for a further commit. Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> Acked-by: Linus Walleij <linus.walleij@linaro.org> Acked-by: Jiri Pirko <jiri@nvidia.com> Reviewed-by: Kurt Kanzenbach <kurt@linutronix.de> # hellcreek Reviewed-by: Linus Walleij <linus.walleij@linaro.org> # RTL8366RB Reviewed-by: Ido Schimmel <idosch@nvidia.com> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2021-01-11net: switchdev: remove the transaction structure from port object notifiersVladimir Oltean
Since the introduction of the switchdev API, port objects were transmitted to drivers for offloading using a two-step transactional model, with a prepare phase that was supposed to catch all errors, and a commit phase that was supposed to never fail. Some classes of failures can never be avoided, like hardware access, or memory allocation. In the latter case, merely attempting to move the memory allocation to the preparation phase makes it impossible to avoid memory leaks, since commit 91cf8eceffc1 ("switchdev: Remove unused transaction item queue") which has removed the unused mechanism of passing on the allocated memory between one phase and another. It is time we admit that separating the preparation from the commit phase is something that is best left for the driver to decide, and not something that should be baked into the API, especially since there are no switchdev callers that depend on this. This patch removes the struct switchdev_trans member from switchdev port object notifier structures, and converts drivers to not look at this member. Where driver conversion is trivial (like in the case of the Marvell Prestera driver, NXP DPAA2 switch, TI CPSW, and Rocker drivers), it is done in this patch. Where driver conversion needs more attention (DSA, Mellanox Spectrum), the conversion is left for subsequent patches and here we only fake the prepare/commit phases at a lower level, just not in the switchdev notifier itself. Where the code has a natural structure that is best left alone as a preparation and a commit phase (as in the case of the Ocelot switch), that structure is left in place, just made to not depend upon the switchdev transactional model. Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Acked-by: Linus Walleij <linus.walleij@linaro.org> Acked-by: Jiri Pirko <jiri@nvidia.com> Reviewed-by: Ido Schimmel <idosch@nvidia.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2021-01-11net: switchdev: remove vid_begin -> vid_end range from VLAN objectsVladimir Oltean
The call path of a switchdev VLAN addition to the bridge looks something like this today: nbp_vlan_init | __br_vlan_set_default_pvid | | | | | br_afspec | | | | | | | v | | | br_process_vlan_info | | | | | | | v | | | br_vlan_info | | | / \ / | | / \ / | | / \ / | | / \ / v v v v v nbp_vlan_add br_vlan_add ------+ | ^ ^ | | | / | | | | / / / | \ br_vlan_get_master/ / v \ ^ / / br_vlan_add_existing \ | / / | \ | / / / \ | / / / \ | / / / \ | / / / v | | v / __vlan_add / / | / / | / v | / __vlan_vid_add | / \ | / v v v br_switchdev_port_vlan_add The ranges UAPI was introduced to the bridge in commit bdced7ef7838 ("bridge: support for multiple vlans and vlan ranges in setlink and dellink requests") (Jan 10 2015). But the VLAN ranges (parsed in br_afspec) have always been passed one by one, through struct bridge_vlan_info tmp_vinfo, to br_vlan_info. So the range never went too far in depth. Then Scott Feldman introduced the switchdev_port_bridge_setlink function in commit 47f8328bb1a4 ("switchdev: add new switchdev bridge setlink"). That marked the introduction of the SWITCHDEV_OBJ_PORT_VLAN, which made full use of the range. But switchdev_port_bridge_setlink was called like this: br_setlink -> br_afspec -> switchdev_port_bridge_setlink Basically, the switchdev and the bridge code were not tightly integrated. Then commit 41c498b9359e ("bridge: restore br_setlink back to original") came, and switchdev drivers were required to implement .ndo_bridge_setlink = switchdev_port_bridge_setlink for a while. In the meantime, commits such as 0944d6b5a2fa ("bridge: try switchdev op first in __vlan_vid_add/del") finally made switchdev penetrate the br_vlan_info() barrier and start to develop the call path we have today. But remember, br_vlan_info() still receives VLANs one by one. Then Arkadi Sharshevsky refactored the switchdev API in 2017 in commit 29ab586c3d83 ("net: switchdev: Remove bridge bypass support from switchdev") so that drivers would not implement .ndo_bridge_setlink any longer. The switchdev_port_bridge_setlink also got deleted. This refactoring removed the parallel bridge_setlink implementation from switchdev, and left the only switchdev VLAN objects to be the ones offloaded from __vlan_vid_add (basically RX filtering) and __vlan_add (the latter coming from commit 9c86ce2c1ae3 ("net: bridge: Notify about bridge VLANs")). That is to say, today the switchdev VLAN object ranges are not used in the kernel. Refactoring the above call path is a bit complicated, when the bridge VLAN call path is already a bit complicated. Let's go off and finish the job of commit 29ab586c3d83 by deleting the bogus iteration through the VLAN ranges from the drivers. Some aspects of this feature never made too much sense in the first place. For example, what is a range of VLANs all having the BRIDGE_VLAN_INFO_PVID flag supposed to mean, when a port can obviously have a single pvid? This particular configuration _is_ denied as of commit 6623c60dc28e ("bridge: vlan: enforce no pvid flag in vlan ranges"), but from an API perspective, the driver still has to play pretend, and only offload the vlan->vid_end as pvid. And the addition of a switchdev VLAN object can modify the flags of another, completely unrelated, switchdev VLAN object! (a VLAN that is PVID will invalidate the PVID flag from whatever other VLAN had previously been offloaded with switchdev and had that flag. Yet switchdev never notifies about that change, drivers are supposed to guess). Nonetheless, having a VLAN range in the API makes error handling look scarier than it really is - unwinding on errors and all of that. When in reality, no one really calls this API with more than one VLAN. It is all unnecessary complexity. And despite appearing pretentious (two-phase transactional model and all), the switchdev API is really sloppy because the VLAN addition and removal operations are not paired with one another (you can add a VLAN 100 times and delete it just once). The bridge notifies through switchdev of a VLAN addition not only when the flags of an existing VLAN change, but also when nothing changes. There are switchdev drivers out there who don't like adding a VLAN that has already been added, and those checks don't really belong at driver level. But the fact that the API contains ranges is yet another factor that prevents this from being addressed in the future. Of the existing switchdev pieces of hardware, it appears that only Mellanox Spectrum supports offloading more than one VLAN at a time, through mlxsw_sp_port_vlan_set. I have kept that code internal to the driver, because there is some more bookkeeping that makes use of it, but I deleted it from the switchdev API. But since the switchdev support for ranges has already been de facto deleted by a Mellanox employee and nobody noticed for 4 years, I'm going to assume it's not a biggie. Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> Reviewed-by: Ido Schimmel <idosch@nvidia.com> # switchdev and mlxsw Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Reviewed-by: Kurt Kanzenbach <kurt@linutronix.de> # hellcreek Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2020-12-15Merge tag 'staging-5.11-rc1' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging Pull staging / IIO driver updates from Greg KH: "Here is the big staging and IIO driver pull request for 5.11-rc1 Lots of different things in here: - loads of driver updates - so many coding style cleanups - new IIO drivers - Android ION code is finally removed from the tree - wimax drivers are moved to staging on their way out of the kernel Nothing really exciting, just the constant grind of kernel development :) All have been in linux-next for a while with no reported issues" * tag 'staging-5.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging: (341 commits) staging: olpc_dcon: Do not call platform_device_unregister() in dcon_probe() staging: most: Fix spelling mistake "tranceiver" -> "transceiver" staging: qlge: remove duplicate word in comment staging: comedi: mf6x4: Fix AI end-of-conversion detection staging: greybus: Add TODO item about modernizing the pwm code pinctrl: ralink: add a pinctrl driver for the rt2880 family dt-bindings: pinctrl: rt2880: add binding document staging: rtl8723bs: remove ELEMENT_ID enum staging: rtl8723bs: remove unused macros staging: rtl8723bs: replace EID_EXTCapability staging: rtl8723bs: replace EID_BSSIntolerantChlReport staging: rtl8723bs: replace EID_BSSCoexistence staging: rtl8723bs: replace _MME_IE_ staging: rtl8723bs: replace _WAPI_IE_ staging: rtl8723bs: replace _EXT_SUPPORTEDRATES_IE_ staging: rtl8723bs: replace _ERPINFO_IE_ staging: rtl8723bs: replace _CHLGETXT_IE_ staging: rtl8723bs: replace _COUNTRY_IE_ staging: rtl8723bs: replace _IBSS_PARA_IE_ staging: rtl8723bs: replace _TIM_IE_ ...
2020-11-23net: don't include ethtool.h from netdevice.hJakub Kicinski
linux/netdevice.h is included in very many places, touching any of its dependecies causes large incremental builds. Drop the linux/ethtool.h include, linux/netdevice.h just needs a forward declaration of struct ethtool_ops. Fix all the places which made use of this implicit include. Acked-by: Johannes Berg <johannes@sipsolutions.net> Acked-by: Shannon Nelson <snelson@pensando.io> Reviewed-by: Jesse Brandeburg <jesse.brandeburg@intel.com> Link: https://lore.kernel.org/r/20201120225052.1427503-1-kuba@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2020-11-23staging: dpaa2-switch: pack the firmware command structuresIoana Ciornei
The structures defined in the dpsw-cmd.h header file describe exactly the layout of commands accepted by the MC firmware. Make sure that all these structures are packed. Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com> Link: https://lore.kernel.org/r/20201119165017.806696-4-ciorneiioana@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-11-23staging: dpaa2-switch: make sure that the VLAN is not already configuredIoana Ciornei
When in the PREPARE state of a switchdev transaction, check if the requested VLAN is not already configured on the switch port. This keeps us from getting into a WARNING as below. [ 1389.683296] dpaa2_ethsw dpsw.0 eth0: VLAN 2 already configured [ 1389.689125] ------------[ cut here ]------------ [ 1389.694084] eth0: Commit of object (id=1) failed. [ 1389.698863] WARNING: CPU: 0 PID: 613 at net/switchdev/switchdev.c:277 switchdev_port_obj_add_now+0xcc/0x110 [ 1389.708589] Modules linked in: [ 1389.711634] CPU: 0 PID: 613 Comm: bridge Not tainted 5.9.0-rc2-next-20200828-00112-g7172078477c5 #59 [ 1389.720753] Hardware name: NXP Layerscape LX2160ARDB (DT) [ 1389.726139] pstate: 40000005 (nZcv daif -PAN -UAO BTYPE=--) [ 1389.731698] pc : switchdev_port_obj_add_now+0xcc/0x110 [ 1389.736824] lr : switchdev_port_obj_add_now+0xcc/0x110 Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com> Link: https://lore.kernel.org/r/20201119165017.806696-3-ciorneiioana@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-11-23staging: dpaa2-switch: export the 'no buffer' counter in ethtoolIonut-robert Aron
Export the DPSW_CNT_ING_NO_BUFFER_DISCARD counter in ethtool for each switch interface. This is useful for debugging purposes. Signed-off-by: Ionut-robert Aron <ionut-robert.aron@nxp.com> Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com> Link: https://lore.kernel.org/r/20201119165017.806696-2-ciorneiioana@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-10-10staging: dpaa2-switch: add a dpaa2_switch prefix to all functions in ethsw.cIoana Ciornei
Some static functions in the dpaa2-switch driver don't have a distinct prefix and this is becoming an inconvenience when looking at, for example, a perf top output and trying to determine easily which entries are dpaa2 switch related. Ammend this by adding the prefix to all the functions. Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com> Link: https://lore.kernel.org/r/20201009153000.14550-3-ioana.ciornei@nxp.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-10-10staging: dpaa2-switch: add a dpaa2_switch_ prefix to all functions in ↵Ioana Ciornei
ethsw-ethtool.c Some static functions in the dpaa2-switch driver don't have a distinct prefix and this is becoming an inconvenience when looking at, for example, a perf top output and trying to determine easily which entries are dpaa2 switch related. Ammend this by adding the prefix to all the functions. Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com> Link: https://lore.kernel.org/r/20201009153000.14550-2-ioana.ciornei@nxp.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-07-21staging: dpaa2-ethsw: check if there is space for a new VLANIoana Ciornei
Avoid getting into a WARNING as below by checking, while in the prepare state of the transactional operation, if there is space for a new VLAN. If we reached the maximum number, return an appropriate error. [ 6503.657564] eth3: Commit of object (id=1) failed. [ 6503.657588] WARNING: CPU: 2 PID: 17144 at net/switchdev/switchdev.c:277 switchdev_port_obj_add_now+0xcc/0x110 ... [ 6503.657628] x1 : 70887ce26695c500 x0 : 0000000000000000 [ 6503.657630] Call trace: [ 6503.657633] switchdev_port_obj_add_now+0xcc/0x110 [ 6503.657635] switchdev_port_obj_add+0x40/0xc0 [ 6503.657638] br_switchdev_port_vlan_add+0x50/0x78 [ 6503.657640] __vlan_add+0x2dc/0x758 [ 6503.657642] nbp_vlan_add+0xc0/0x180 [ 6503.657644] br_vlan_info.isra.0+0x68/0x128 [ 6503.657646] br_process_vlan_info+0x224/0x2f8 [ 6503.657647] br_afspec+0x158/0x188 [ 6503.657649] br_setlink+0x1a4/0x290 Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com> Link: https://lore.kernel.org/r/20200721091919.20394-7-ioana.ciornei@nxp.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-07-21staging: dpaa2-ethsw: read the port state from firmwareIoana Ciornei
Rely on the port state seen by the firmware since it will also be the one erroring out when trying to setup anything major when the port is up. Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com> Link: https://lore.kernel.org/r/20200721091919.20394-6-ioana.ciornei@nxp.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-07-21staging: dpaa2-ethsw: destroy workqueue after deregistering the notifiersIoana Ciornei
We should destroy the switch workqueue only after deregistering the switchdev notifiers. Without this fix, we could end up with switchdev notifications on a draining workqueue and also with a lock up since the netdevice reference count is increased (in port_switchdev_event) and not decreased ever (since the workqueue did not run). Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com> Link: https://lore.kernel.org/r/20200721091919.20394-5-ioana.ciornei@nxp.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-07-21staging: dpaa2-ethsw: setup the STP state for all installed VLANsIoana Ciornei
Setup the STP state for all VLANs installed on the port. This is also avoiding the error situation when the DEFAULT_VLAN_ID is not installed on the port (thus the firmware complains that it cannot setup the required STP state). Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com> Link: https://lore.kernel.org/r/20200721091919.20394-4-ioana.ciornei@nxp.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-07-21staging: dpaa2-ethsw: don't allow interfaces from different DPSWs to be bridgedIoana Ciornei
Error out when the user tries to bridge two switch interfaces that are from different DPSW instances. This is not supported by the hardware and we should reflect this into what the user is aware of. Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com> Link: https://lore.kernel.org/r/20200721091919.20394-3-ioana.ciornei@nxp.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-07-21staging: dpaa2-ethsw: verify the nofifier blockIoana Ciornei
Since now we have a notifier block for each DPSW instance probed, we have to also check that the netdev is indeed connected to the notifier received. Without this, we end up with the same switchdev callback being executed multiple times (because it would be received by all notifier blocks, not just the one intended to). Also, move the function higher in the source file because it will be used in later patches from multiple places. Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com> Link: https://lore.kernel.org/r/20200721091919.20394-2-ioana.ciornei@nxp.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-07-21staging: dpaa2-ethsw: fix switch/case fallthrough warningMarian Posteuca
Fix the fallthrough warning that is reported by checkpatch. Signed-off-by: Marian Posteuca <posteuca@mutex.one> Link: https://lore.kernel.org/r/20200720064205.10323-1-posteuca@mutex.one Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-07-15staging: dpaa2-ethsw: setup MAC address of switch netdevicesIoana Ciornei
At probe time, retrieve the MAC addresses of the switch ports using a firmware call and use that to setup the switch interface net_device instead of relying entirely on the user to configure a MAC address on the interface. In case a switch interface is not connected to a MAC, thus the dpsw_if_get_port_mac_addr() will return all zeroes, generate a random MAC address and use that. This new functionality is dependent on a firmware call which is available only on newer versions, so depending on the running DPSW object version skip this step. Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com> Link: https://lore.kernel.org/r/20200714133431.17532-7-ioana.ciornei@nxp.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-07-15staging: dpaa2-ethsw: store version information of the DPSW objectIoana Ciornei
Store the major and minor versions of the DPSW object in the ethsw structure. This will be used in a subsequent patch to make sure some commands are only called on the appropriate version of object. Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com> Link: https://lore.kernel.org/r/20200714133431.17532-6-ioana.ciornei@nxp.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-07-15staging: dpaa2-ethsw: disable switch ports are probe timeIoana Ciornei
The MC firmware will enable the switch interfaces at DPSW creation without waiting for an 'ifconfig up' on the switch interfaces. When this happens, the states held by the Linux software vs the firmware are not in sync. Make sure to disable the switch ports at probe time to not encounter this issue. Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com> Link: https://lore.kernel.org/r/20200714133431.17532-5-ioana.ciornei@nxp.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-07-15staging: dpaa2-ethsw: use netif_running when checking for port upIoana Ciornei
There are some cases where the switch interface needs to be disabled so that changes in the configuration can be made. In such cases, we should check for a running interface (bit __LINK_STATE_START of the netdev) instead of netif_carrier_ok(). This is because on open() we enable the switch interface even though the link up has not come out yet. Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com> Link: https://lore.kernel.org/r/20200714133431.17532-4-ioana.ciornei@nxp.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-07-15staging: dpaa2-ethsw: ignore state interrupts when the interface is not runningIoana Ciornei
Link state interrupts will be transmitted to the DPSW object even though the user has not yet issued a 'ifconfig up' on a switch interface. Don't act on those interrupts since there are of no interrest. Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com> Link: https://lore.kernel.org/r/20200714133431.17532-3-ioana.ciornei@nxp.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-07-15staging: dpaa2-ethsw: fix reported link stateIoana Ciornei
On the .ndo_open() callback set netif_carrier_off() until the link state interrupt is received so that the LOWER_UP flag does not show up incorrectly in the output of 'ip link show'. Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com> Link: https://lore.kernel.org/r/20200714133431.17532-2-ioana.ciornei@nxp.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-06-07Merge tag 'staging-5.8-rc1' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging Pull staging/IIO driver updates from Greg KH: "Here is the large set of staging and IIO driver changes for 5.8-rc1 Nothing major, but a lot of new IIO drivers are included in here, along with other core iio cleanups and changes. On the staging driver front, again, nothing noticable. No new deletions or additions, just a ton of tiny cleanups all over the tree done by a lot of different people. Most coding style, but many actual real fixes and cleanups that are nice to see. All of these have been in linux-next for a while with no reported issues" * tag 'staging-5.8-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging: (618 commits) staging: rtl8723bs: Use common packet header constants staging: sm750fb: Add names to proc_setBLANK args staging: most: usb: init return value in default path of switch/case expression staging: vchiq: Get rid of VCHIQ_SERVICE_OPENEND callback reason staging: vchiq: move vchiq_release_message() into vchiq staging: vchi: Get rid of C++ guards staging: vchi: Get rid of not implemented function declarations staging: vchi: Get rid of vchiq_status_to_vchi() staging: vchi: Get rid of vchi_service_set_option() staging: vchi: Merge vchi_msg_queue() into vchi_queue_kernel_message() staging: vchiq: Move copy callback handling into vchiq staging: vchi: Get rid of vchi_queue_user_message() staging: vchi: Get rid of vchi_service_destroy() staging: most: usb: use function sysfs_streq staging: most: usb: add missing put_device calls staging: most: usb: use correct error codes staging: most: usb: replace code to calculate array index staging: most: usb: don't use error path to exit function on success staging: most: usb: move allocation of URB out of critical section staging: most: usb: return 0 instead of variable ...
2020-04-30docs: networking: convert switchdev.txt to ReSTMauro Carvalho Chehab
- add SPDX header; - use copyright symbol; - adjust title markup; - mark code blocks and literals as such; - mark tables as such; - adjust identation, whitespaces and blank lines where needed; - add to networking/index.rst. Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
2020-04-13staging: fsl-dpaa2: ethsw: Fix parenthesis alignmentJohn B. Wyatt IV
Fix 2 parenthesis alignment issues. Reported by checkpatch. Signed-off-by: John B. Wyatt IV <jbwyatt4@gmail.com> Link: https://lore.kernel.org/r/20200402023310.816245-1-jbwyatt4@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-02-17staging: fsl-dpaa2: ethsw: ethsw.c: Fix line over 80 charactersSandesh Kenjana Ashok
Issue found by checkpatch. Signed-off-by: Sandesh Kenjana Ashok <sandeshkenjanaashok@gmail.com> Link: https://lore.kernel.org/r/20200214232143.GA20675@SandeshPC Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-11-13staging: dpaa2-ethsw: ordered workqueue should be per ethswIoana Ciornei
Create a different ordered workqueue per dpaa2-ethsw instance. Without this change, we overwrite the global queue and leak memory when probing multiple instances of the driver. Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com> Link: https://lore.kernel.org/r/1573491058-24766-5-git-send-email-ioana.ciornei@nxp.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-11-13staging: dpaa2-ethsw: move port switchdev blocking notifier per ethswIoana Ciornei
Register a different switchdev blocking notifier block per ethsw instance. When probing multiple dpaa2-ethsw instances, without this the register will fail. Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com> Link: https://lore.kernel.org/r/1573491058-24766-4-git-send-email-ioana.ciornei@nxp.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-11-13staging: dpaa2-ethsw: move port switchdev notifier per ethswIoana Ciornei
Register a different switchdev notifier block per ethsw instance. When probing multiple dpaa2-ethsw instances, without this the register will fail. Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com> Link: https://lore.kernel.org/r/1573491058-24766-3-git-send-email-ioana.ciornei@nxp.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-11-13staging: dpaa2-ethsw: move port notifier per ethswIoana Ciornei
Register a different net_device notifier block per ethsw instance. When probing multiple dpaa2-ethsw instances, without this the register will fail. Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com> Link: https://lore.kernel.org/r/1573491058-24766-2-git-send-email-ioana.ciornei@nxp.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-08-14staging: fsl-dpaa2/ethsw: do not force user to bring interface downIoana Ciornei
Link settings can be changed only when the interface is down. Disable and re-enable the interface, if necessary, behind the scenes so that we do not force users to an if down/up sequence. Reported-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com> Link: https://lore.kernel.org/r/1565700187-16048-11-git-send-email-ioana.ciornei@nxp.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>