import our SDK modifications#1
Open
KanjiMonster wants to merge 29 commits intobisdn/mainfrom
Open
Conversation
Allow overriding CC/CXX to allow using ccache for faster recompilation. Signed-off-by: Jonas Gorski <jonas.gorski@bisdn.de>
The default log path, "bcm.log", results in the BCM log being written to /usr/sbin/bcm.log. This commit moves the default path to the much more appropriate /var/log/bcm.log. Signed-off-by: Roger Luethi <roger.luethi@bisdn.de>
Parse and pass a MACaddress to KNET when creating netinterfaces. Any zero mac address will be ignored and only triggers a randomized MAC address generation. Signed-off-by: Jonas Gorski <jonas.gorski@bisdn.de>
Add support for the Delta AG7648 LED updater thread as a runtime option. Signed-off-by: Jonas Gorski <jonas.gorski@bisdn.de>
Add support for the Delta AG5648 LED values as a runtime option. Signed-off-by: Jonas Gorski <jonas.gorski@bisdn.de>
Add support for supplying a json encoded array of LED data values to
program based on link speed:
[
{
"speed": 10,
"value": "0x1"
},
{
"speed": 100,
"value": "0x3"
},
...
]
So each object has two items, "speed" and "value", where speed is an
int, and value a string, containing a base 16 encoded LED value.
String was chosen as json lacks an unsigned int type, or other integer
representations than base 10.
Signed-off-by: Jonas Gorski <jonas.gorski@bisdn.de>
Linux 5.6 switch proc from generic file_operations to proc_ops, so update the code accordingly. Signed-off-by: Jonas Gorski <jonas.gorski@bisdn.de>
With kernel 5.9 unlocked and compat ioctl is always on, so the defines do not exist anymore, so define them ourselves for 5.9+. Signed-off-by: Jonas Gorski <jonas.gorski@bisdn.de>
Update linux-kernel-bde for 5.10: - dma now always requires a device - ioremap_nocache was dropped Signed-off-by: Jonas Gorski <jonas.gorski@bisdn.de>
The CPU port will always add a vlan tag, but we can check the header for the state at reception. If it was received untagged, strip the vlan tag to forward the packet as received to the kernel. Different ASICs use different DCBs, which have the information stored at different places. Add a function checking these, based on the documented dcb types in OpenBCM/sdk-6.5.24/include/soc/shared/dcbformat/. For now only support a subset of dcb types which we only care about. Signed-off-by: Jonas Gorski <jonas.gorski@bisdn.de>
We set netif carrier, so we can just use ethtool_op_get_link. Signed-off-by: Jonas Gorski <jonas.gorski@bisdn.de>
To allow better emulation of physical port devices, extend the link state settings to also include link speed and duplex. These are implemented as additional passable argument into proc link entry, allowing multiple arguments as a comma separated list. Signed-off-by: Jonas Gorski <jonas.gorski@bisdn.de>
To allow programs like ethtool access to the link speed, implement the get_link_ksettings callback. Signed-off-by: Jonas Gorski <jonas.gorski@bisdn.de>
If we have no link, the current speed/duplex is unknown. Signed-off-by: Jonas Gorski <jonas.gorski@bisdn.de>
When creating a netif, the netif will be registered and made available
to userspace before its private data is initialized.
This creates a window where accessing the device (e.g. opening it) may
cause a null pointer access since netdev_priv() isn't populated yet.
E.g. bkn_open will get priv->sinfo and access its fields:
bkn_open(struct net_device *dev)
{
bkn_priv_t *priv = netdev_priv(dev);
bkn_switch_info_t *sinfo = priv->sinfo;
But sinfo is only set *after* the netdev registration:
if ((dev = bkn_init_ndev(ma, kmsg->netif.name)) == NULL) {
kmsg->hdr.status = KCOM_E_RESOURCE;
return sizeof(kcom_msg_hdr_t);
}
priv = netdev_priv(dev);
priv->dev = dev;
priv->sinfo = sinfo;
This can easily happen if a network manager like systemd-networkd tries
to configure and enable the network interface as soon as it is created.
Fix this by delaying register_netdev() until after the private data is
populated, with added code to undo any additional changes in case the
registration fails.
Signed-off-by: Jonas Gorski <jonas.gorski@bisdn.de>
Instead of using partially randomized mac addresses with a Broadcom OUI
prefix, use fully randomized mac addresses for generated virtualized
Ethernet devices.
To make sure the address is properly tagged as random, switch from
setting dev->dev_addr to using the helper functions
eth_hw_addr_{random,set}. Since these work on an existing device, we
need to move deciding whether to use a random mac into bkn_init_ndev.
Keep the Broadcom OUI prefixed MAC address for the base Ethernet device,
to make it more easily identifiable.
Signed-off-by: Jonas Gorski <jonas.gorski@bisdn.de>
When using KNET interfaces in a bridge, Linux will flood or forward any packets it sees according to default rules. This can be undesirable when the packet was already flooded or forwarded by the switch itself, since this will lead to the packets being duplicated. To avoid this Linux supports marking packets as forwarding offloaded, which prevents them from being forwarded in software, so add support for marking packets as such. Since this may break use cases where packets are redirected to the controller, but are expected to be flooded/forwarded in software, make this an optional flag per interface. Signed-off-by: Jonas Gorski <jonas.gorski@bisdn.de>
Linux 5.17 made netdev->dev_addr[] constant, so we cannot modify it anymore. Since bkn_set_mac_address() just directly sets the mac address, we can replace it with the generic eth_mac_addr() implementation, and set the IFF_LIVE_ADDR_CHANGE flag to allow MAC address changes while the device is up, as before. Signed-off-by: Jonas Gorski <jonas.gorski@bisdn.de>
Update kernel API usage for 5.18 and 5.19: 5.18 dropped pci_set_dma_mask(), which was just a wrapper for dma_set_mask(), so just call dma_set_mask() directly. 5.19 dropped the weight argument from netif_napi_add() as most users just passed the default value, and added a new call netif_napi_add_weight() for passing a custom weight value. Signed-off-by: Jonas Gorski <jonas.gorski@bisdn.de>
The Kernel stopped providing platform resources for IRQs of device tree backed platform devices[1], and instead requires calling platform_get_irq(), so do that. This also simplifies the code. [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=a1a2b7125e1079cfcc13a116aa3af3df2f9e002b Signed-off-by: Jonas Gorski <jonas.gorski@bisdn.de>
For currently unknown reasons the Broadcom ASIC does not update the DSCP field for packets sent to controller. But the DMA header does have the expected DSCP value. So use the DSCP value from the DMA header to update IP(v6) packets if set. Signed-off-by: Jonas Gorski <jonas.gorski@bisdn.de>
Do not include FCS and custom data header in tx byte counts. The custom header is never transmitted on the wire and consumed by the ASIC, so we should not count it, and we do not count it for rx bytes. Likewise, rx and tx bytes should exclude the FCS, so we need to substract it here as well. Signed-off-by: Jonas Gorski <jonas.gorski@bisdn.de>
In preparation to report accurate counts, switch to stat64. This has no effect on 64 bit, but for 32 bit this switches to 64 bit counters. Since 64 bit values cannot be written atomically, make use of u64_stat_sync helpers. Signed-off-by: Jonas Gorski <jonas.gorski@bisdn.de>
Automatically push hw counters to netif interfaces whenever the cached hw counters get updated. To accomplish this, add a thread to the SDK that iterates over all existing netifs and updates the counters if it's a port interface. To not have to poll, register a extra counters callback that gets called everytime the SDK counter thread collects counters, and triggers the knet counter update thread. Since the software counters are still interesting, delegate them to IFLA_OFFLOAD_XSTATS_CPU_HIT type offload stats, which seem to be the most appropriate. For now only use a subset of counters to keep the size reasonable, selected by matching the available counters [1] to rtnl_link_stats64 from the kernel [2]. [1] https://github.com/Broadcom-Network-Switching-Software/OpenBCM/blob/master/sdk-6.5.24/include/bcm/stat.h [2] https://elixir.bootlin.com/linux/v6.6.90/source/include/uapi/linux/if_link.h#L42 Signed-off-by: Jonas Gorski <jonas.gorski@bisdn.de>
BPDU packets are trapped to controller and never forwarded, so do not mark them as offloaded. This allows them to be forwarded/flooded in software if needed. Note that this requires configuring the switch ASIC to mark traffic as BPDU via appropriate L2 cache entries, and there is no inherent automatic classification. Signed-off-by: Jonas Gorski <jonas.gorski@bisdn.de>
MAX_ORDER was redefined and renamed as MAX_PAGE_ORDER in 6.8 with commit
23baf831a32c ("mm, treewide: redefine MAX_ORDER sanely").
Signed-off-by: Jonas Gorski <jonas.gorski@bisdn.de>
Update kernel API usage for kernel 6.11: * strscpy() was dropped, with strlcpy() being mostly a drop-in replacement * platform_driver::remove() now returns void instead of int * ethtool_ts_info was renamed to kernel_ethtool_ts_info Signed-off-by: Jonas Gorski <jonas.gorski@bisdn.de>
Add base support for tracked interfaces. Tracked interfaces fully represent switch ports, with tracked configuration and state. Since KNET allows multiple netifs for the same port, add a restriction for tracked interfaces that they only may be one per port. This also allows us storing a port -> netif lookup table. Signed-off-by: Jonas Gorski <jonas.gorski@bisdn.de>
Add a new message for SDK to send link state to KNET interfaces. For now only support the basic attributes: link, speed, and duplex. For ports created with the tracked, ignore any port state updates via the old interface. Signed-off-by: Jonas Gorski <jonas.gorski@bisdn.de>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Import our SDK modifications as commits. This will be used in the future instead of patchsets for our recipes. This does not include changes we inherited from OF-DPA, as these are "proprietary".
Mostly identical to the existing patches except for some minor white space and style fixes: