summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* net/tls: support SM4 GCM/CCM algorithmTianjia Zhang2021-09-163-0/+110
| | | | | | | | | | The RFC8998 specification defines the use of the ShangMi algorithm cipher suites in TLS 1.3, and also supports the GCM/CCM mode using the SM4 algorithm. Signed-off-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com> Acked-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
* Revert "net: wwan: iosm: firmware flashing and coredump collection"Jakub Kicinski2021-09-1614-2054/+31
| | | | | | | | | | | | The devlink parameters are not the right mechanism to pass extra parameters to device flashing. The params added are also undocumented. This reverts commit 13bb8429ca98 ("net: wwan: iosm: firmware flashing and coredump collection"). Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
* octeontx2-pf: CN10K: Hide RPM stats over ethtoolHariprasad Kelam2021-09-162-15/+24
| | | | | | | | | | | | | | | CN10K MAC block (RPM) differs in number of stats compared to Octeontx2 MAC block (CGX). RPM supports stats for each class of PFC and error packets etc. It would be difficult for user to read stats from ethtool and map to their definition. New debugfs file is already added to read RPM stats along with their definition. This patch adds proper checks such that RPM stats will not be part of ethtool. Signed-off-by: Hariprasad Kelam <hkelam@marvell.com> Signed-off-by: Sunil Goutham <sgoutham@marvell.com> Signed-off-by: David S. Miller <davem@davemloft.net>
* net: thunderx: Make use of the helper function dev_err_probe()Cai Huoqing2021-09-163-8/+4
| | | | | | | | | | When possible use dev_err_probe help to properly deal with the PROBE_DEFER error, the benefit is that DEFER issue will be logged in the devices_deferred debugfs file. And using dev_err_probe() can reduce code size, and simplify the code. Signed-off-by: Cai Huoqing <caihuoqing@baidu.com> Signed-off-by: David S. Miller <davem@davemloft.net>
* net: hinic: Make use of the helper function dev_err_probe()Cai Huoqing2021-09-161-4/+2
| | | | | | | | | | When possible use dev_err_probe help to properly deal with the PROBE_DEFER error, the benefit is that DEFER issue will be logged in the devices_deferred debugfs file. And using dev_err_probe() can reduce code size, and simplify the code. Signed-off-by: Cai Huoqing <caihuoqing@baidu.com> Signed-off-by: David S. Miller <davem@davemloft.net>
* net: ethoc: Make use of the helper function dev_err_probe()Cai Huoqing2021-09-161-8/+4
| | | | | | | | | | When possible use dev_err_probe help to properly deal with the PROBE_DEFER error, the benefit is that DEFER issue will be logged in the devices_deferred debugfs file. And using dev_err_probe() can reduce code size, and simplify the code. Signed-off-by: Cai Huoqing <caihuoqing@baidu.com> Signed-off-by: David S. Miller <davem@davemloft.net>
* net: enetc: Make use of the helper function dev_err_probe()Cai Huoqing2021-09-164-20/+10
| | | | | | | | | | When possible use dev_err_probe help to properly deal with the PROBE_DEFER error, the benefit is that DEFER issue will be logged in the devices_deferred debugfs file. And using dev_err_probe() can reduce code size, and simplify the code. Signed-off-by: Cai Huoqing <caihuoqing@baidu.com> Signed-off-by: David S. Miller <davem@davemloft.net>
* net: chelsio: cxgb4vf: Make use of the helper function dev_err_probe()Cai Huoqing2021-09-161-4/+2
| | | | | | | | | | When possible use dev_err_probe help to properly deal with the PROBE_DEFER error, the benefit is that DEFER issue will be logged in the devices_deferred debugfs file. And using dev_err_probe() can reduce code size, and simplify the code. Signed-off-by: Cai Huoqing <caihuoqing@baidu.com> Signed-off-by: David S. Miller <davem@davemloft.net>
* net: atl1e: Make use of the helper function dev_err_probe()Cai Huoqing2021-09-161-4/+2
| | | | | | | | | | When possible use dev_err_probe help to properly deal with the PROBE_DEFER error, the benefit is that DEFER issue will be logged in the devices_deferred debugfs file. And using dev_err_probe() can reduce code size, and simplify the code. Signed-off-by: Cai Huoqing <caihuoqing@baidu.com> Signed-off-by: David S. Miller <davem@davemloft.net>
* net: atl1c: Make use of the helper function dev_err_probe()Cai Huoqing2021-09-161-4/+2
| | | | | | | | | | When possible use dev_err_probe help to properly deal with the PROBE_DEFER error, the benefit is that DEFER issue will be logged in the devices_deferred debugfs file. And using dev_err_probe() can reduce code size, and simplify the code. Signed-off-by: Cai Huoqing <caihuoqing@baidu.com> Signed-off-by: David S. Miller <davem@davemloft.net>
* net: arc_emac: Make use of the helper function dev_err_probe()Cai Huoqing2021-09-161-5/+4
| | | | | | | | | | When possible use dev_err_probe help to properly deal with the PROBE_DEFER error, the benefit is that DEFER issue will be logged in the devices_deferred debugfs file. And using dev_err_probe() can reduce code size, and simplify the code. Signed-off-by: Cai Huoqing <caihuoqing@baidu.com> Signed-off-by: David S. Miller <davem@davemloft.net>
* Merge branch 'mlxsw-Add-support-for-transceiver-modules-reset'David S. Miller2021-09-158-58/+281
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Ido Schimmel says: ==================== mlxsw: Add support for transceiver modules reset This patchset prepares mlxsw for future transceiver modules related [1] changes and adds reset support via the existing 'ETHTOOL_RESET' interface. Patches #1-#6 are relatively straightforward preparations. Patch #7 tracks the number of logical ports that are mapped to the transceiver module and the number of logical ports using it that are administratively up. Needed for both reset support and power mode policy support. Patches #8-#9 add required fields in device registers. Patch #10 implements support for ethtool_ops::reset in order to reset transceiver modules. [1] https://lore.kernel.org/netdev/20210824130344.1828076-1-idosch@idosch.org/ ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
| * mlxsw: Add support for transceiver modules resetIdo Schimmel2021-09-154-0/+77
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Implement support for ethtool_ops::reset in order to reset transceiver modules. The module backing the netdev is reset when the 'ETH_RESET_PHY' flag is set. After a successful reset, the flag is cleared by the driver and other flags are ignored. This is in accordance with the interface documentation: "The reset() operation must clear the flags for the components which were actually reset. On successful return, the flags indicate the components which were not reset, either because they do not exist in the hardware or because they cannot be reset independently. The driver must never reset any components that were not requested." Reset is useful in order to allow a module to transition out of a fault state. From section 6.3.2.12 in CMIS 5.0: "Except for a power cycle, the only exit path from the ModuleFault state is to perform a module reset by taking an action that causes the ResetS transition signal to become TRUE (see Table 6-11)". An error is returned when the netdev is administratively up: # ip link set dev swp11 up # ethtool --reset swp11 phy ETHTOOL_RESET 0x40 Cannot issue ETHTOOL_RESET: Invalid argument # ip link set dev swp11 down # ethtool --reset swp11 phy ETHTOOL_RESET 0x40 Components reset: 0x40 An error is returned when the module is shared by multiple ports (split ports) and the "phy-shared" flag is not set: # devlink port split swp11 count 4 # ethtool --reset swp11s0 phy ETHTOOL_RESET 0x40 Cannot issue ETHTOOL_RESET: Invalid argument # ethtool --reset swp11s0 phy-shared ETHTOOL_RESET 0x400000 Components reset: 0x400000 # devlink port unsplit swp11s0 # ethtool --reset swp11 phy ETHTOOL_RESET 0x40 Components reset: 0x40 An error is also returned when one of the ports using the module is administratively up: # devlink port split swp11 count 4 # ip link set dev swp11s1 up # ethtool --reset swp11s0 phy-shared ETHTOOL_RESET 0x400000 Cannot issue ETHTOOL_RESET: Invalid argument # ip link set dev swp11s1 down # ethtool --reset swp11s0 phy-shared ETHTOOL_RESET 0x400000 Components reset: 0x400000 Reset is performed by writing to the "rst" bit of the PMAOS register, which instructs the firmware to assert the reset signal connected to the module for a fixed amount of time. Signed-off-by: Ido Schimmel <idosch@nvidia.com> Signed-off-by: David S. Miller <davem@davemloft.net>
| * mlxsw: Make PMAOS pack function more genericIdo Schimmel2021-09-152-6/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | The PMAOS register has enable bits (e.g., PMAOS.ee) that allow changing only a subset of the fields, which is exactly what subsequent patches will need to do. Instead of passing multiple arguments to its pack function, only pass the module index and let the rest be set by the different callers. No functional changes intended. Signed-off-by: Ido Schimmel <idosch@nvidia.com> Signed-off-by: David S. Miller <davem@davemloft.net>
| * mlxsw: reg: Add fields to PMAOS registerIdo Schimmel2021-09-151-0/+26
| | | | | | | | | | | | | | | | | | | | The Ports Module Administrative and Operational Status (PMAOS) register configures and retrieves the per-module status. Extend it with fields required to support various module settings such as reset and power mode. Signed-off-by: Ido Schimmel <idosch@nvidia.com> Signed-off-by: David S. Miller <davem@davemloft.net>
| * mlxsw: Track per-module port statusIdo Schimmel2021-09-154-9/+113
| | | | | | | | | | | | | | | | | | | | | | | | | | In the common port module core, track the number of logical ports that are mapped to the port module and the number of logical ports using it that are administratively up. This will be used by later patches to potentially veto and control certain operations on the module, such as reset and setting its power mode. Signed-off-by: Ido Schimmel <idosch@nvidia.com> Signed-off-by: David S. Miller <davem@davemloft.net>
| * mlxsw: spectrum: Do not return an error in mlxsw_sp_port_module_unmap()Ido Schimmel2021-09-151-2/+2
| | | | | | | | | | | | | | The return value is never checked. Allows us to simplify a later patch. Signed-off-by: Ido Schimmel <idosch@nvidia.com> Signed-off-by: David S. Miller <davem@davemloft.net>
| * mlxsw: spectrum: Do not return an error in ndo_stop()Ido Schimmel2021-09-151-1/+2
| | | | | | | | | | | | | | | | The return value is not checked by the networking stack. Allows us to simplify a later patch. Signed-off-by: Ido Schimmel <idosch@nvidia.com> Signed-off-by: David S. Miller <davem@davemloft.net>
| * mlxsw: core_env: Convert 'module_info_lock' to a mutexIdo Schimmel2021-09-151-10/+13
| | | | | | | | | | | | | | | | | | | | | | After the previous patch, the lock is always taken in process context so it can be converted to a mutex. It is needed for future changes where we will need to be able to sleep when holding the lock. Convert the lock to a mutex. Signed-off-by: Ido Schimmel <idosch@nvidia.com> Signed-off-by: David S. Miller <davem@davemloft.net>
| * mlxsw: core_env: Defer handling of module temperature warning eventsIdo Schimmel2021-09-151-5/+34
| | | | | | | | | | | | | | | | | | | | | | | | Module temperature events are currently handled in softIRQ context, requiring the 'module_info_lock' to be a spin lock. In future patchsets we will need to be able to hold the lock while sleeping. Therefore, defer handling of these events using a work queue so that the next patch will be able to convert the lock to a mutex. Signed-off-by: Ido Schimmel <idosch@nvidia.com> Signed-off-by: David S. Miller <davem@davemloft.net>
| * mlxsw: core: Remove mlxsw_core_is_initialized()Ido Schimmel2021-09-153-15/+0
| | | | | | | | | | | | | | | | | | | | After the previous patch, the switch driver is always initialized last, making this function redundant. Remove it. Signed-off-by: Ido Schimmel <idosch@nvidia.com> Signed-off-by: David S. Miller <davem@davemloft.net>
| * mlxsw: core: Initialize switch driver lastIdo Schimmel2021-09-151-11/+10
|/ | | | | | | | | | | | | | | | | | | | | | | Commit 961cf99a074f ("mlxsw: core: Re-order initialization sequence") changed the initialization sequence so that the switch driver (e.g., mlxsw_spectrum) is initialized before registration with the hwmon and thermal subsystems. This was done in order to avoid situations where hwmon/thermal code uses features not supported by current firmware version, which is only validated as part of switch driver initialization. Later, commit b79cb787ac70 ("mlxsw: Move fw flashing code into core.c") moved firmware validation and flashing code from the switch driver to mlxsw_core so that it is performed before driver initialization. Therefore, change the initialization sequence back to its original form. In addition to being more straightforward, it will allow us to simplify parts of the code in subsequent patches and future patchsets. Signed-off-by: Ido Schimmel <idosch@nvidia.com> Signed-off-by: David S. Miller <davem@davemloft.net>
* Merge branch 'devlink-delete-publidh-api'David S. Miller2021-09-153-60/+2
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Leon Romanovsky says: ==================== devlink: Delete publish of single parameter API This short series removes the single parameter publish/unpublish API that does nothing expect mimics already existing devlink_paramss_*publish calls. In near future, we will be able to delete devlink_paramss_*publish too. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
| * devlink: Delete not-used single parameter notification APIsLeon Romanovsky2021-09-152-52/+0
| | | | | | | | | | | | | | | | | | | | There is no need in specific devlink_param_*publish(), because same output can be achieved by using devlink_params_*publish() in correct places. Signed-off-by: Leon Romanovsky <leonro@nvidia.com> Acked-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
| * net/mlx5: Publish and unpublish all devlink parameters at onceLeon Romanovsky2021-09-151-8/+2
|/ | | | | | | | | | | | | | | | | | | | | The devlink parameters were published in two steps despite being static and known in advance. First step was to use devlink_params_publish() which iterated over all known up to that point parameters and sent notification messages. In second step, the call was devlink_param_publish() that looped over same parameters list and sent notification for new parameters. In order to simplify the API, move devlink_params_publish() to be called when all parameters were already added and save the need to iterate over parameters list again. As a side effect, this change fixes the error unwind flow in which parameters were not marked as unpublished. Fixes: 82e6c96f04e1 ("net/mlx5: Register to devlink ingress VLAN filter trap") Signed-off-by: Leon Romanovsky <leonro@nvidia.com> Signed-off-by: David S. Miller <davem@davemloft.net>
* Merge branch 'qdisc-visibility'David S. Miller2021-09-159-1/+169
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Jakub Kicinski says: ==================== net: sched: update default qdisc visibility after Tx queue cnt changes Matthew noticed that number of children reported by mq does not match number of queues on reconfigured interfaces. For example if mq is instantiated when there is 8 queues it will always show 8 children, regardless of config being changed: # ethtool -L eth0 combined 8 # tc qdisc replace dev eth0 root handle 100: mq # tc qdisc show dev eth0 qdisc mq 100: root qdisc pfifo_fast 0: parent 100:8 bands 3 priomap 1 2 ... qdisc pfifo_fast 0: parent 100:7 bands 3 priomap 1 2 ... qdisc pfifo_fast 0: parent 100:6 bands 3 priomap 1 2 ... qdisc pfifo_fast 0: parent 100:5 bands 3 priomap 1 2 ... qdisc pfifo_fast 0: parent 100:4 bands 3 priomap 1 2 ... qdisc pfifo_fast 0: parent 100:3 bands 3 priomap 1 2 ... qdisc pfifo_fast 0: parent 100:2 bands 3 priomap 1 2 ... qdisc pfifo_fast 0: parent 100:1 bands 3 priomap 1 2 ... # ethtool -L eth0 combined 1 # tc qdisc show dev eth0 qdisc mq 100: root qdisc pfifo_fast 0: parent 100:8 bands 3 priomap 1 2 ... qdisc pfifo_fast 0: parent 100:7 bands 3 priomap 1 2 ... qdisc pfifo_fast 0: parent 100:6 bands 3 priomap 1 2 ... qdisc pfifo_fast 0: parent 100:5 bands 3 priomap 1 2 ... qdisc pfifo_fast 0: parent 100:4 bands 3 priomap 1 2 ... qdisc pfifo_fast 0: parent 100:3 bands 3 priomap 1 2 ... qdisc pfifo_fast 0: parent 100:2 bands 3 priomap 1 2 ... qdisc pfifo_fast 0: parent 100:1 bands 3 priomap 1 2 ... # ethtool -L eth0 combined 32 # tc qdisc show dev eth0 qdisc mq 100: root qdisc pfifo_fast 0: parent 100:8 bands 3 priomap 1 2 ... qdisc pfifo_fast 0: parent 100:7 bands 3 priomap 1 2 ... qdisc pfifo_fast 0: parent 100:6 bands 3 priomap 1 2 ... qdisc pfifo_fast 0: parent 100:5 bands 3 priomap 1 2 ... qdisc pfifo_fast 0: parent 100:4 bands 3 priomap 1 2 ... qdisc pfifo_fast 0: parent 100:3 bands 3 priomap 1 2 ... qdisc pfifo_fast 0: parent 100:2 bands 3 priomap 1 2 ... qdisc pfifo_fast 0: parent 100:1 bands 3 priomap 1 2 ... This patchset fixes this by hashing and unhasing the default child qdiscs as number of queues gets adjusted. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
| * selftests: net: test ethtool -L vs mqJakub Kicinski2021-09-152-1/+78
| | | | | | | | | | | | | | Add a selftest for checking mq children are visible after ethtool -L. Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
| * netdevsim: add ability to change channel countJakub Kicinski2021-09-152-0/+29
| | | | | | | | | | | | | | For testing visibility of mq/mqprio default children. Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
| * net: sched: update default qdisc visibility after Tx queue cnt changesJakub Kicinski2021-09-155-0/+62
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | mq / mqprio make the default child qdiscs visible. They only do so for the qdiscs which are within real_num_tx_queues when the device is registered. Depending on order of calls in the driver, or if user space changes config via ethtool -L the number of qdiscs visible under tc qdisc show will differ from the number of queues. This is confusing to users and potentially to system configuration scripts which try to make sure qdiscs have the right parameters. Add a new Qdisc_ops callback and make relevant qdiscs TTRT. Note that this uncovers the "shortcut" created by commit 1f27cde313d7 ("net: sched: use pfifo_fast for non real queues") The default child qdiscs beyond initial real_num_tx are always pfifo_fast, no matter what the sysfs setting is. Fixing this gets a little tricky because we'd need to keep a reference on whatever the default qdisc was at the time of creation. In practice this is likely an non-issue the qdiscs likely have to be configured to non-default settings, so whatever user space is doing such configuration can replace the pfifos... now that it will see them. Reported-by: Matthew Massey <matthewmassey@fb.com> Reviewed-by: Dave Taht <dave.taht@gmail.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
* Merge branch 'ibmvnic-next'David S. Miller2021-09-152-223/+427
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Sukadev Bhattiprolu says: ==================== ibmvnic: Reuse ltb, rx, tx pools It can take a long time to free and reallocate rx and tx pools and long term buffer (LTB) during each reset of the VNIC. This is specially true when the partition (LPAR) is heavily loaded and going through a Logical Partition Migration (LPM). The long drawn reset causes the LPAR to lose connectivity for extended periods of time and results in "RMC connection" errors and the LPM failing. What is worse is that during the LPM we could get a failover because of the lost connectivity. At that point, the vnic driver releases even the resources it has already allocated and starts over. As long as the resources we have already allocated are valid/applicable, we might as well hold on to them while trying to allocate the remaining resources. This patch set attempts to reuse the resources previously allocated as long as they are valid. It seems to vastly improve the time taken for the vnic reset and signficantly reduces the chances of getting the RMC connection errors. We do get still them occasionally, but appears to be for reasons other than memory allocation delays and those are still being investigated. If the backing devices for a vnic adapter are not "matched" (see "pool parameters" in patches 8 and 9) it is possible that we will still free all the resources and allocate them. If that becomes a common problem, we have to address it separately. Thanks to input and extensive testing from Brian King, Cris Forno, Dany Madden, Rick Lindsley. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
| * ibmvnic: Reuse tx pools when possibleSukadev Bhattiprolu2021-09-152-70/+147
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Rather than releasing the tx pools on every close and reallocating them on open, reuse the tx pools unless the pool parameters (number of pools, size of each pool or size of each buffer in a pool) have changed. If the pool parameters changed, then release the old pools (if any) and allocate new ones. Specifically release tx pools, if: - adapter is removed, - pool parameters change during reset, - we encounter an error when opening the adapter in response to a user request (in ibmvnic_open()). and don't release them: - in __ibmvnic_close() or - on errors in __ibmvnic_open() in the hope that we can reuse them during this or next reset. With these changes reset_tx_pools() can be dropped because its optimization is now included in init_tx_pools() itself. cleanup_tx_pools() releases all the skbs associated with the pool and is called from ibmvnic_cleanup(), which is called on every reset. Since we want to reuse skbs across resets, move cleanup_tx_pools() out of ibmvnic_cleanup() and call it only when user closes the adapter. Add two new adapter fields, ->prev_mtu, ->prev_tx_pool_size to track the previous values and use them to decide whether to reuse or realloc the pools. Reviewed-by: Rick Lindsley <ricklind@linux.vnet.ibm.com> Reviewed-by: Dany Madden <drt@linux.ibm.com> Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.ibm.com> Signed-off-by: David S. Miller <davem@davemloft.net>
| * ibmvnic: Reuse rx pools when possibleSukadev Bhattiprolu2021-09-152-64/+137
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Rather than releasing the rx pools on and reallocating them on every reset, reuse the rx pools unless the pool parameters (number of pools, size of each pool or size of each buffer in a pool) have changed. If the pool parameters changed, then release the old pools (if any) and allocate new ones. Specifically release rx pools, if: - adapter is removed, - pool parameters change during reset, - we encounter an error when opening the adapter in response to a user request (in ibmvnic_open()). and don't release them: - in __ibmvnic_close() or - on errors in __ibmvnic_open() in the hope that we can reuse them on the next reset. With these, reset_rx_pools() can be dropped because its optimzation is now included in init_rx_pools() itself. cleanup_rx_pools() releases all the skbs associated with the pool and is called from ibmvnic_cleanup(), which is called on every reset. Since we want to reuse skbs across resets, move cleanup_rx_pools() out of ibmvnic_cleanup() and call it only when user closes the adapter. Add two new adapter fields, ->prev_rx_buf_sz, ->prev_rx_pool_size to keep track of the previous values and use them to decide whether to reuse or realloc the pools. Reviewed-by: Rick Lindsley <ricklind@linux.vnet.ibm.com> Reviewed-by: Dany Madden <drt@linux.ibm.com> Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.ibm.com> Signed-off-by: David S. Miller <davem@davemloft.net>
| * ibmvnic: Reuse LTB when possibleSukadev Bhattiprolu2021-09-151-63/+74
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Reuse the long term buffer during a reset as long as its size has not changed. If the size has changed, free it and allocate a new one of the appropriate size. When we do this, alloc_long_term_buff() and reset_long_term_buff() become identical. Drop reset_long_term_buff(). Reviewed-by: Rick Lindsley <ricklind@linux.vnet.ibm.com> Reviewed-by: Dany Madden <drt@linux.ibm.com> Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.ibm.com> Signed-off-by: David S. Miller <davem@davemloft.net>
| * ibmvnic: Use bitmap for LTB map_idsSukadev Bhattiprolu2021-09-152-5/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In a follow-on patch, we will reuse long term buffers when possible. When doing so we have to be careful to properly assign map ids. We can no longer assign them sequentially because a lower map id may be available and we could wrap at 255 and collide with an in-use map id. Instead, use a bitmap to track active map ids and to find a free map id. Don't need to take locks here since the map_id only changes during reset and at that time only the reset worker thread should be using the adapter. Noticed this when analyzing an error Dany Madden ran into with the patch set. Reported-by: Dany Madden <drt@linux.ibm.com> Reviewed-by: Rick Lindsley <ricklind@linux.vnet.ibm.com> Reviewed-by: Dany Madden <drt@linux.ibm.com> Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.ibm.com> Signed-off-by: David S. Miller <davem@davemloft.net>
| * ibmvnic: init_tx_pools move loop-invariant codeSukadev Bhattiprolu2021-09-151-3/+2
| | | | | | | | | | | | | | | | | | In init_tx_pools() move some loop-invariant code out of the loop. Reviewed-by: Rick Lindsley <ricklind@linux.vnet.ibm.com> Reviewed-by: Dany Madden <drt@linux.ibm.com> Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.ibm.com> Signed-off-by: David S. Miller <davem@davemloft.net>
| * ibmvnic: Use/rename local vars in init_tx_poolsSukadev Bhattiprolu2021-09-151-14/+16
| | | | | | | | | | | | | | | | | | | | Use/rename local variables in init_tx_pools() for consistency with init_rx_pools() and for readability. Also add some comments Reviewed-by: Rick Lindsley <ricklind@linux.vnet.ibm.com> Reviewed-by: Dany Madden <drt@linux.ibm.com> Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.ibm.com> Signed-off-by: David S. Miller <davem@davemloft.net>
| * ibmvnic: Use/rename local vars in init_rx_poolsSukadev Bhattiprolu2021-09-152-9/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | To make the code more readable, use/rename some local variables. Basically we have a set of pools, num_pools. Each pool has a set of buffers, pool_size and each buffer is of size buff_size. pool_size is a bit ambiguous (whether size in bytes or buffers). Add a comment in the header file to make it explicit. Reviewed-by: Rick Lindsley <ricklind@linux.vnet.ibm.com> Reviewed-by: Dany Madden <drt@linux.ibm.com> Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.ibm.com> Signed-off-by: David S. Miller <davem@davemloft.net>
| * ibmvnic: Fix up some comments and messagesSukadev Bhattiprolu2021-09-151-6/+38
| | | | | | | | | | | | | | | | | | Add/update some comments/function headers and fix up some messages. Reviewed-by: Rick Lindsley <ricklind@linux.vnet.ibm.com> Reviewed-by: Dany Madden <drt@linux.ibm.com> Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.ibm.com> Signed-off-by: David S. Miller <davem@davemloft.net>
| * ibmvnic: Consolidate code in replenish_rx_pool()Sukadev Bhattiprolu2021-09-151-3/+7
|/ | | | | | | | | | For better readability, consolidate related code in replenish_rx_pool() and add some comments. Reviewed-by: Rick Lindsley <ricklind@linux.vnet.ibm.com> Reviewed-by: Dany Madden <drt@linux.ibm.com> Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.ibm.com> Signed-off-by: David S. Miller <davem@davemloft.net>
* Merge branch 'ptp-ocp-timecard-v13-fw'David S. Miller2021-09-152-136/+1343
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Jonathan Lemon says: ==================== timecard updates for v13 firmware This update mainly deals with features for the TimeCard v13 firmware. The signals provided from the external SMA connectors can be steered to different locations, and the generated SMA signals can be chosen. Future timecard revisions will allow selectable I/O on any of the SMA connectors, so name the attributes appropriately, and set up the ABI in preparation for the new features. The update also adds support for IRIG-B and DCF formats, as well as NMEA output. A ts_window_adjust tunable is also provided to fine-tune the PHC:SYS time mapping. -- v1: Earlier reviewed series was for v10 firmware, this is expanded to include the v13 features. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
| * docs: ABI: Add sysfs documentation for timecardJonathan Lemon2021-09-151-0/+174
| | | | | | | | | | | | | | | | This patch describes the sysfs interface implemented by the ptp_ocp driver, under /sys/class/timecard. Signed-off-by: Jonathan Lemon <jonathan.lemon@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
| * ptp: ocp: Add timestamp window adjustmentJonathan Lemon2021-09-151-11/+66
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The following process is used to read the PHC clock and correlate the reading with the "correct" system time. - get starting timestamp - issue PCI write command - issue PCI read command - get ending timestamp - read latched sec/nsec registers The write command is posted to PCI bus and returns. When the write arrives at the FPGA, the PHC time is latched into the sec/nsec registers, and a flag is set indicating the registers are valid. The read command returns this flag, and the time retrieval proceeds. Below is a non-scaled picture of the timing diagram involved. The PHC time corresponds to some SYS time between [start, end]. Userspace usually uses the midpoint between [start, end] to estimate the PCI delay and match this with the PHC time. [start] | | write |-------+ | | \ | read |----+ +----->| | \ * PHC time latched into register | \ | midpoint | +------->| | | | | | +----| | / | |<--------+ | [end] | | As the diagram indicates, the PHC time is latched before the midpoint, so the system clock time is slightly off the real PHC time. This shows up as a phase error with an oscilliscope. The workaround here is to provide a tunable which reduces (shrinks) the end time in the above diagram. This in turn moves the calculated midpoint so the system time and PHC time are in agreemment. Currently, the adjustment reduces the end time by 3/16th of the entire window. E.g.: [start, end] ==> [start, (end - (3/16 * end)], which produces reasonably good results. Also reduce delays by just writing to the clock control register instead of performing a read/modify/write sequence, as the contents of the control register are known. Signed-off-by: Jonathan Lemon <jonathan.lemon@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
| * ptp: ocp: Have FPGA fold in ns adjustment for adjtime.Jonathan Lemon2021-09-151-15/+25
| | | | | | | | | | | | | | | | | | | | | | | | The current implementation of adjtime uses gettime/settime to perform nanosecond adjustments. This introduces addtional phase errors due to delays. Instead, use the FPGA's ability to just apply the nanosecond adjustment to the clock directly. Signed-off-by: Jonathan Lemon <jonathan.lemon@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
| * ptp: ocp: Enable 4th timestamper / PPS generatorJonathan Lemon2021-09-151-8/+74
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A 4th timestamper is added which timestamps the output of the PHC. The clock nanosecond offset is not always zero, so when compared to other timestampers, this provides precise measurements. Also, the timestamper interrupt from the PHC can be used to generate a PPS signal for /dev/pps. Also allow PTP_CLK_REQ_PEROUT requests for a 1PPS output, but do not actually configure any output pins, this is done via sysfs. Signed-off-by: Jonathan Lemon <jonathan.lemon@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
| * ptp: ocp: Add second GNSS deviceJonathan Lemon2021-09-151-2/+15
| | | | | | | | | | | | | | | | | | | | | | Upcoming boards may have a second GNSS receiver, getting information from a different constellation than the first receiver, which provides some measure of anti-spoofing. Expose the sysfs attribute for this device, if detected. Signed-off-by: Jonathan Lemon <jonathan.lemon@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
| * ptp: ocp: Add NMEA outputJonathan Lemon2021-09-151-2/+55
| | | | | | | | | | | | | | | | | | | | The timecard can provide a NMEA-1083 ZDA (time and date) output string on a serial port, which can be used to drive other devices. Add the NMEA resources, and the serial port as a sysfs attribute. Signed-off-by: Jonathan Lemon <jonathan.lemon@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
| * ptp: ocp: Add debugfs entry for timecardJonathan Lemon2021-09-151-0/+233
| | | | | | | | | | | | | | Provide a view into the timecard internals for debugging. Signed-off-by: Jonathan Lemon <jonathan.lemon@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
| * ptp: ocp: Separate the init and info logicJonathan Lemon2021-09-151-36/+60
| | | | | | | | | | | | | | | | | | | | | | | | On startup, parts of the FPGA need to be initialized - break these out into their own functions, separate from the purely informational blocks. On startup, distrbute the UTC:TAI offset from the NMEA GNSS parser, if it is available. Signed-off-by: Jonathan Lemon <jonathan.lemon@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
| * ptp: ocp: Add sysfs attribute utc_tai_offsetJonathan Lemon2021-09-151-1/+48
| | | | | | | | | | | | | | | | | | IRIG and DCF output time in UTC, but the timecard operates on TAI internally. Add an attribute node which allows adding an offset to these modes before output. Signed-off-by: Jonathan Lemon <jonathan.lemon@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
| * ptp: ocp: Add IRIG-B output mode controlJonathan Lemon2021-09-151-0/+41
| | | | | | | | | | | | | | | | IRIG-B has several different output formats, the timecard defaults to using B007. Add a control which selects different output modes. Signed-off-by: Jonathan Lemon <jonathan.lemon@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>