summaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)AuthorFilesLines
2019-08-11drop_monitor: Make drop queue length configurableIdo Schimmel2-3/+17
In packet alert mode, each CPU holds a list of dropped skbs that need to be processed in process context and sent to user space. To avoid exhausting the system's memory the maximum length of this queue is currently set to 1000. Allow users to tune the length of this queue according to their needs. The configured length is reported to user space when drop monitor configuration is queried. Signed-off-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2019-08-11drop_monitor: Add a command to query current configurationIdo Schimmel2-0/+50
Users should be able to query the current configuration of drop monitor before they start using it. Add a command to query the existing configuration which currently consists of alert mode and packet truncation length. Signed-off-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2019-08-11drop_monitor: Allow truncation of dropped packetsIdo Schimmel2-0/+21
When sending dropped packets to user space it is not always necessary to copy the entire packet as usually only the headers are of interest. Allow user to specify the truncation length and add the original length of the packet as additional metadata to the netlink message. By default no truncation is performed. Signed-off-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2019-08-11drop_monitor: Add packet alert modeIdo Schimmel2-2/+305
So far drop monitor supported only one alert mode in which a summary of locations in which packets were recently dropped was sent to user space. This alert mode is sufficient in order to understand that packets were dropped, but lacks information to perform a more detailed analysis. Add a new alert mode in which the dropped packet itself is passed to user space along with metadata: The drop location (as program counter and resolved symbol), ingress netdevice and drop timestamp. More metadata can be added in the future. To avoid performing expensive operations in the context in which kfree_skb() is invoked (can be hard IRQ), the dropped skb is cloned and queued on per-CPU skb drop list. Then, in process context the netlink message is allocated, prepared and finally sent to user space. The per-CPU skb drop list is limited to 1000 skbs to prevent exhausting the system's memory. Subsequent patches will make this limit configurable and also add a counter that indicates how many skbs were tail dropped. Signed-off-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2019-08-11drop_monitor: Add alert mode operationsIdo Schimmel2-6/+41
The next patch is going to add another alert mode in which the dropped packet is notified to user space, instead of only a summary of recent drops. Abstract the differences between the modes by adding alert mode operations. The operations are selected based on the currently configured mode and associated with the probes and the work item just before tracing starts. Signed-off-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2019-08-11drop_monitor: Require CAP_NET_ADMIN for drop monitor configurationIdo Schimmel1-0/+1
Currently, the configure command does not do anything but return an error. Subsequent patches will enable the command to change various configuration options such as alert mode and packet truncation. Similar to other netlink-based configuration channels, make sure only users with the CAP_NET_ADMIN capability set can execute this command. Signed-off-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2019-08-11drop_monitor: Reset per-CPU data before starting to traceIdo Schimmel1-3/+7
The function reset_per_cpu_data() allocates and prepares a new skb for the summary netlink alert message ('NET_DM_CMD_ALERT'). The new skb is stored in the per-CPU 'data' variable and the old is returned. The function is invoked during module initialization and from the workqueue, before an alert is sent. This means that it is possible to receive an alert with stale data, if we stopped tracing when the hysteresis timer ('data->send_timer') was pending. Instead of invoking the function during module initialization, invoke it just before we start tracing and ensure we get a fresh skb. This also allows us to remove the calls to initialize the timer and the work item from the module initialization path, since both could have been triggered by the error paths of reset_per_cpu_data(). Signed-off-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2019-08-11drop_monitor: Initialize timer and work item upon tracing enableIdo Schimmel1-5/+19
The timer and work item are currently initialized once during module init, but subsequent patches will need to associate different functions with the work item, based on the configured alert mode. Allow subsequent patches to make that change by initializing and de-initializing these objects during tracing enable and disable. This also guarantees that once the request to disable tracing returns, no more netlink notifications will be generated. Signed-off-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2019-08-11drop_monitor: Split tracing enable / disable to different functionsIdo Schimmel1-28/+51
Subsequent patches will need to enable / disable tracing based on the configured alerting mode. Reduce the nesting level and prepare for the introduction of this functionality by splitting the tracing enable / disable operations into two different functions. Signed-off-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2019-08-10Merge branch 'Networking-driver-debugfs-cleanups'David S. Miller37-805/+175
Greg Kroah-Hartman says: ==================== Networking driver debugfs cleanups There is no need to test the result of any debugfs call anymore. The debugfs core warns the user if something fails, and the return value of a debugfs call can always be fed back into another debugfs call with no problems. Also, debugfs is for debugging, so if there are problems with debugfs (i.e. the system is out of memory) the rest of the kernel should not change behavior, so testing for debugfs calls is pointless and not the goal of debugfs at all. This series cleans up a lot of networking drivers and some wimax code that was calling debugfs and trying to do something with the return value that it didn't need to. Removing this logic makes the code smaller, easier to understand, and use less run-time memory in some cases, all good things. The series is against net-next, and have no dependancies between any of them if they want to go through any random tree/order. Or, if wanted, I can take them through my driver-core tree where other debugfs cleanups are being slowly fed during major merge windows. v3: fix build warning in i2400m, I thought I had caught them all :( add acks from some reviewers v2: fix up build warnings, it's as if I never even built these. Ugh, so sorry for wasting people's time with the v1 series. I need to stop relying on 0-day as it isn't working well anymore :( ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2019-08-10ieee802154: no need to check return value of debugfs_create functionsGreg Kroah-Hartman3-33/+9
When calling debugfs functions, there is no need to ever check the return value. The function can work or not, but the code logic should never do something different based on this. Cc: Alexander Aring <alex.aring@gmail.com> Cc: "David S. Miller" <davem@davemloft.net> Cc: Harry Morris <h.morris@cascoda.com> Cc: linux-wpan@vger.kernel.org Cc: netdev@vger.kernel.org Acked-by: Stefan Schmidt <stefan@datenfreihafen.org> Acked-by: Michael Hennerich <michael.hennerich@analog.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: David S. Miller <davem@davemloft.net>
2019-08-10ixgbe: no need to check return value of debugfs_create functionsGreg Kroah-Hartman1-17/+5
When calling debugfs functions, there is no need to ever check the return value. The function can work or not, but the code logic should never do something different based on this. Cc: Jeff Kirsher <jeffrey.t.kirsher@intel.com> Cc: "David S. Miller" <davem@davemloft.net> Cc: intel-wired-lan@lists.osuosl.org Cc: netdev@vger.kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: David S. Miller <davem@davemloft.net>
2019-08-10i40e: no need to check return value of debugfs_create functionsGreg Kroah-Hartman1-18/+4
When calling debugfs functions, there is no need to ever check the return value. The function can work or not, but the code logic should never do something different based on this. Cc: Jeff Kirsher <jeffrey.t.kirsher@intel.com> Cc: "David S. Miller" <davem@davemloft.net> Cc: intel-wired-lan@lists.osuosl.org Cc: netdev@vger.kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: David S. Miller <davem@davemloft.net>
2019-08-10fm10k: no need to check return value of debugfs_create functionsGreg Kroah-Hartman1-2/+0
When calling debugfs functions, there is no need to ever check the return value. The function can work or not, but the code logic should never do something different based on this. Cc: Jeff Kirsher <jeffrey.t.kirsher@intel.com> Cc: "David S. Miller" <davem@davemloft.net> Cc: intel-wired-lan@lists.osuosl.org Cc: netdev@vger.kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: David S. Miller <davem@davemloft.net>
2019-08-10mvpp2: no need to check return value of debugfs_create functionsGreg Kroah-Hartman1-18/+1
When calling debugfs functions, there is no need to ever check the return value. The function can work or not, but the code logic should never do something different based on this. Cc: "David S. Miller" <davem@davemloft.net> Cc: Maxime Chevallier <maxime.chevallier@bootlin.com> Cc: Nick Desaulniers <ndesaulniers@google.com> Cc: Nathan Huckleberry <nhuck@google.com> Cc: netdev@vger.kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: David S. Miller <davem@davemloft.net>
2019-08-10skge: no need to check return value of debugfs_create functionsGreg Kroah-Hartman1-30/+9
When calling debugfs functions, there is no need to ever check the return value. The function can work or not, but the code logic should never do something different based on this. Cc: Mirko Lindner <mlindner@marvell.com> Cc: Stephen Hemminger <stephen@networkplumber.org> Cc: "David S. Miller" <davem@davemloft.net> Cc: netdev@vger.kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: David S. Miller <davem@davemloft.net>
2019-08-10qca: no need to check return value of debugfs_create functionsGreg Kroah-Hartman1-10/+3
When calling debugfs functions, there is no need to ever check the return value. The function can work or not, but the code logic should never do something different based on this. Cc: "David S. Miller" <davem@davemloft.net> Cc: Stefan Wahren <stefan.wahren@i2se.com> Cc: Michael Heimpold <michael.heimpold@i2se.com> Cc: Yangtao Li <tiny.windzz@gmail.com> Cc: netdev@vger.kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: David S. Miller <davem@davemloft.net>
2019-08-10dpaa2: no need to check return value of debugfs_create functionsGreg Kroah-Hartman2-50/+7
When calling debugfs functions, there is no need to ever check the return value. The function can work or not, but the code logic should never do something different based on this. Because we don't care about the individual files, we can remove the stored dentry for the files, as they are not needed to be kept track of at all. Cc: Ioana Radulescu <ruxandra.radulescu@nxp.com> Cc: "David S. Miller" <davem@davemloft.net> Cc: netdev@vger.kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: David S. Miller <davem@davemloft.net>
2019-08-10stmmac: no need to check return value of debugfs_create functionsGreg Kroah-Hartman2-46/+8
When calling debugfs functions, there is no need to ever check the return value. The function can work or not, but the code logic should never do something different based on this. Because we don't care about the individual files, we can remove the stored dentry for the files, as they are not needed to be kept track of at all. Cc: Giuseppe Cavallaro <peppe.cavallaro@st.com> Cc: Alexandre Torgue <alexandre.torgue@st.com> Cc: Jose Abreu <joabreu@synopsys.com> Cc: "David S. Miller" <davem@davemloft.net> Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com> Cc: netdev@vger.kernel.org Cc: linux-stm32@st-md-mailman.stormreply.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: David S. Miller <davem@davemloft.net>
2019-08-10nfp: no need to check return value of debugfs_create functionsGreg Kroah-Hartman1-16/+1
When calling debugfs functions, there is no need to ever check the return value. The function can work or not, but the code logic should never do something different based on this. Cc: "David S. Miller" <davem@davemloft.net> Cc: Alexei Starovoitov <ast@kernel.org> Cc: Daniel Borkmann <daniel@iogearbox.net> Cc: Jesper Dangaard Brouer <hawk@kernel.org> Cc: John Fastabend <john.fastabend@gmail.com> Cc: Edwin Peer <edwin.peer@netronome.com> Cc: Yangtao Li <tiny.windzz@gmail.com> Cc: Simon Horman <simon.horman@netronome.com> Cc: oss-drivers@netronome.com Cc: netdev@vger.kernel.org Acked-by: Jakub Kicinski <jakub.kicinski@netronome.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: David S. Miller <davem@davemloft.net>
2019-08-10hns3: no need to check return value of debugfs_create functionsGreg Kroah-Hartman1-15/+2
When calling debugfs functions, there is no need to ever check the return value. The function can work or not, but the code logic should never do something different based on this. Cc: Yisen Zhuang <yisen.zhuang@huawei.com> Cc: Salil Mehta <salil.mehta@huawei.com> Cc: "David S. Miller" <davem@davemloft.net> Cc: netdev@vger.kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: David S. Miller <davem@davemloft.net>
2019-08-10cxgb4: no need to check return value of debugfs_create functionsGreg Kroah-Hartman3-20/+9
When calling debugfs functions, there is no need to ever check the return value. The function can work or not, but the code logic should never do something different based on this. If a debugfs call fails, it will properly warn in the syslog, there's no need for all individual drivers to also print a message, so that is one more reason to not care about checking the return values. Cc: Vishal Kulkarni <vishal@chelsio.com> Cc: "David S. Miller" <davem@davemloft.net> Cc: Casey Leedom <leedom@chelsio.com> Cc: netdev@vger.kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: David S. Miller <davem@davemloft.net>
2019-08-10bnxt: no need to check return value of debugfs_create functionsGreg Kroah-Hartman2-29/+11
When calling debugfs functions, there is no need to ever check the return value. The function can work or not, but the code logic should never do something different based on this. This cleans up a lot of unneeded code and logic around the debugfs files, making all of this much simpler and easier to understand. Cc: Michael Chan <michael.chan@broadcom.com> Cc: "David S. Miller" <davem@davemloft.net> Cc: netdev@vger.kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: David S. Miller <davem@davemloft.net>
2019-08-10xgbe: no need to check return value of debugfs_create functionsGreg Kroah-Hartman1-76/+31
When calling debugfs functions, there is no need to ever check the return value. The function can work or not, but the code logic should never do something different based on this. This cleans up a lot of unneeded code and logic around the debugfs files, making all of this much simpler and easier to understand. Cc: Tom Lendacky <thomas.lendacky@amd.com> Cc: "David S. Miller" <davem@davemloft.net> Cc: netdev@vger.kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: David S. Miller <davem@davemloft.net>
2019-08-10mlx5: no need to check return value of debugfs_create functionsGreg Kroah-Hartman7-163/+24
When calling debugfs functions, there is no need to ever check the return value. The function can work or not, but the code logic should never do something different based on this. This cleans up a lot of unneeded code and logic around the debugfs files, making all of this much simpler and easier to understand as we don't need to keep the dentries saved anymore. Cc: Saeed Mahameed <saeedm@mellanox.com> Cc: Leon Romanovsky <leon@kernel.org> Cc: netdev@vger.kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: David S. Miller <davem@davemloft.net>
2019-08-10bonding: no need to print a message if debugfs_create_dir() failsGreg Kroah-Hartman1-5/+0
The debugfs core now will print a message if this function fails, so don't duplicate that logic. Also, no need to change the code logic if the call fails either, as no debugfs calls should interrupt normal kernel code for any reason. Cc: Jay Vosburgh <j.vosburgh@gmail.com> Cc: Veaceslav Falico <vfalico@gmail.com> Cc: Andy Gospodarek <andy@greyhouse.net> Cc: "David S. Miller" <davem@davemloft.net> Cc: netdev@vger.kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: David S. Miller <davem@davemloft.net>
2019-08-10wimax: no need to check return value of debugfs_create functionsGreg Kroah-Hartman8-257/+51
When calling debugfs functions, there is no need to ever check the return value. The function can work or not, but the code logic should never do something different based on this. This cleans up a lot of unneeded code and logic around the debugfs wimax files, making all of this much simpler and easier to understand. Cc: Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com> Cc: linux-wimax@intel.com Cc: netdev@vger.kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: David S. Miller <davem@davemloft.net>
2019-08-09Merge tag 'mlx5-updates-2019-08-09' of ↵David S. Miller11-140/+340
git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux Saeed Mahameed says: ==================== mlx5-updates-2019-08-09 This series includes update to mlx5 ethernet and core driver: In first #11 patches, Vlad submits part 2 of 3 part series to allow TC flow handling for concurrent execution. 1) TC flow handling for concurrent execution (part 2) Vald Says: ========== Refactor data structures that are shared between flows in tc. Currently, all cls API hardware offloads driver callbacks require caller to hold rtnl lock when calling them. Cls API has already been updated to update software filters in parallel (on classifiers that support unlocked execution), however hardware offloads code still obtains rtnl lock before calling driver tc callbacks. This set implements support for unlocked execution of tc hairpin, mod_hdr and encap subsystem. The changed implemented in these subsystems are very similar in general. The main difference is that hairpin is accessed through mlx5e_tc_table (legacy mode), mod_hdr is accessed through both mlx5e_tc_table and mlx5_esw_offload (legacy and switchdev modes) and encap is only accessed through mlx5_esw_offload (switchdev mode). 1.1) Hairpin handling and structure mlx5e_hairpin_entry refactored in following way: - Hairpin structure is extended with atomic reference counter. This approach allows to lookup of hairpin entry and obtain reference to it with hairpin_tbl_lock protection and then continue using the entry unlocked (including provisioning to hardware). - To support unlocked provisioning of hairpin entry to hardware, the entry is extended with 'res_ready' completion and is inserted to hairpin_tbl before calling the firmware. With this approach any concurrent users that attempt to use the same hairpin entry wait for completion first to prevent access to entries that are not fully initialized. - Hairpin entry is extended with new flows_lock spinlock to protect the list when multiple concurrent tc instances update flows attached to the same hairpin entry. 1.2) Modify header handling code and structure mlx5e_mod_hdr_entry are refactored in the following way: - Mod_hdr structure is extended with atomic reference counter. This approach allows to lookup of mod_hdr entry and obtain reference to it with mod_hdr_tbl_lock protection and then continue using the entry unlocked (including provisioning to hardware). - To support unlocked provisioning of mod_hdr entry to hardware, the entry is extended with 'res_ready' completion and is inserted to mod_hdr_tbl before calling the firmware. With this approach any concurrent users that attempt to use the same mod_hdr entry wait for completion first to prevent access to entries that are not fully initialized. - Mod_Hdr entry is extended with new flows_lock spinlock to protect the list when multiple concurrent tc instances update flows attached to the same mod_hdr entry. 1.3) Encapsulation handling code and Structure mlx5e_encap_entry are refactored in the following way: - encap structure is extended with atomic reference counter. This approach allows to lookup of encap entry and obtain reference to it with encap_tbl_lock protection and then continue using the entry unlocked (including provisioning to hardware). - To support unlocked provisioning of encap entry to hardware, the entry is extended with 'res_ready' completion and is inserted to encap_tbl before calling the firmware. With this approach any concurrent users that attempt to use the same encap entry wait for completion first to prevent access to entries that are not fully initialized. - As a difference from approach used to refactor hairpin and mod_hdr, encap entry is not extended with any per-entry fine-grained lock. Instead, encap_table_lock is used to synchronize all operations on encap table and instances of mlx5e_encap_entry. This is necessary because single flow can be attached to multiple encap entries simultaneously. During new flow creation or neigh update event all of encaps that flow is attached to must be accessed together as in atomic manner, which makes usage of per-entry lock infeasible. - Encap entry is extended with new flows_lock spinlock to protect the list when multiple concurrent tc instances update flows attached to the same encap entry. ========== 3) Parav improves the way port representors report their parent ID and port index. 4) Use refcount_t for refcount in vxlan data base from Chuhong Yuan ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2019-08-09tc-testing: added tdc tests for matchall filterRoman Mashak1-0/+391
Signed-off-by: Roman Mashak <mrv@mojatatu.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2019-08-09selftests: Fix detection of nettest command in fcnal-testDavid Ahern1-32/+6
Most of the tests run by fcnal-test.sh relies on the nettest command. Rather than trying to cover all of the individual tests, check for the binary only at the beginning. Also removes the need for log_error which is undefined. Fixes: 6f9d5cacfe07 ("selftests: Setup for functional tests for fib and socket lookups") Signed-off-by: David Ahern <dsahern@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2019-08-09net/mlx5e: Use refcount_t for refcountChuhong Yuan1-4/+5
refcount_t is better for reference counters since its implementation can prevent overflows. So convert atomic_t ref counters to refcount_t. Signed-off-by: Chuhong Yuan <hslester96@gmail.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
2019-08-09net/mlx5e: Use vhca_id in generating representor port_indexParav Pandit1-4/+16
It is desired to use unique port indices when multiple pci devices' devlink instance have the same switch-id. Make use of vhca-id to generate such unique devlink port indices. Signed-off-by: Parav Pandit <parav@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
2019-08-09net/mlx5e: Simplify querying port representor parent idParav Pandit1-13/+3
System image GUID doesn't depend on eswitch switchdev mode. Hence, remove the check which simplifies the code. Signed-off-by: Parav Pandit <parav@mellanox.com> Reviewed-by: Vu Pham <vuhuong@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
2019-08-09net/mlx5: E-switch, Removed unused hwidParav Pandit2-6/+1
Currently mlx5_eswitch_rep stores same hw ID for all representors. However it is never used from this structure. It is always used from mlx5_vport. Hence, remove unused field. Signed-off-by: Parav Pandit <parav@mellanox.com> Reviewed-by: Vu Pham <vuhuong@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
2019-08-09net/mlx5e: Allow concurrent creation of encap entriesVlad Buslov2-6/+29
Encap entries creation is fully synchronized by encap_tbl_lock. In order to allow concurrent allocation of hardware resources used to offload encapsulation, extend mlx5e_encap_entry with 'res_ready' completion. Move call to mlx5e_tc_tun_create_header_ipv{4|6}() out of encap_tbl_lock critical section. Modify code that attaches new flows to existing encap to wait for 'res_ready' completion before using the entry. Insert encap entry to table before provisioning it to hardware and modify all users of the encap table to verify that encap was fully initialized by checking completion result for non-zero value (and to wait for 'res_ready' completion, if necessary). Signed-off-by: Vlad Buslov <vladbu@mellanox.com> Reviewed-by: Roi Dayan <roid@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
2019-08-09net/mlx5e: Protect encap hash table with mutexVlad Buslov3-10/+36
To remove dependency on rtnl lock, protect encap hash table from concurrent modifications with new "encap_tbl_lock" mutex. Use the mutex to protect internal encap entry state from concurrent modification. This is necessary because a flow can be attached to multiple encap entries simultaneously, which significantly complicates using finer grained per-entry lock. Signed-off-by: Vlad Buslov <vladbu@mellanox.com> Reviewed-by: Roi Dayan <roid@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
2019-08-09net/mlx5e: Extend encap entry with reference counterVlad Buslov4-28/+64
List of flows attached to encap entry is used as implicit reference counter (encap entry is deallocated when list becomes free) and as a mechanism to obtain encap entry that flow is attached to (through list head). This is not safe when concurrent modification of list of flows attached to encap entry is possible. Proper atomic reference counter is required to support concurrent access. As a preparation for extending encap with reference counting, extract code that lookups and deletes encap entry into standalone put/get helpers. In order to remove this dependency on external locking, extend encap entry with reference counter to manage its lifetime and extend flow structure with direct pointer to encap entry that flow is attached to. Signed-off-by: Vlad Buslov <vladbu@mellanox.com> Reviewed-by: Jianbo Liu <jianbol@mellanox.com> Reviewed-by: Roi Dayan <roid@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
2019-08-09net/mlx5e: Allow concurrent creation of mod_hdr entriesVlad Buslov1-12/+29
Mod_hdr entries creation is fully synchronized by mod_hdr_tbl->lock. In order to allow concurrent allocation of hardware resources used to offload header rewrite, extend mlx5e_mod_hdr_entry with 'res_ready' completion. Move call to mlx5_modify_header_alloc() out of mod_hdr_tbl->lock critical section. Modify code that attaches new flows to existing mh to wait for 'res_ready' completion before using the entry. Insert mh to mod_hdr table before provisioning it to hardware and modify all users of mod_hdr table to verify that mh was fully initialized by checking completion result for negative value (and to wait for 'res_ready' completion, if necessary). Signed-off-by: Vlad Buslov <vladbu@mellanox.com> Reviewed-by: Roi Dayan <roid@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
2019-08-09net/mlx5e: Protect mod_hdr hash table with mutexVlad Buslov3-10/+28
To remove dependency on rtnl lock, protect mod_hdr hash table from concurrent modifications with new mutex. Implement helper function to get flow namespace to prevent code duplication. Signed-off-by: Vlad Buslov <vladbu@mellanox.com> Reviewed-by: Roi Dayan <roid@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
2019-08-09net/mlx5e: Protect mod header entry flows list with spinlockVlad Buslov1-0/+7
To remove dependency on rtnl lock, extend mod header entry with spinlock and use it to protect list of flows attached to mod header entry from concurrent modifications. Signed-off-by: Vlad Buslov <vladbu@mellanox.com> Reviewed-by: Jianbo Liu <jianbol@mellanox.com> Reviewed-by: Roi Dayan <roid@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
2019-08-09net/mlx5e: Extend mod header entry with reference counterVlad Buslov5-43/+61
List of flows attached to mod header entry is used as implicit reference counter (mod header entry is deallocated when list becomes free) and as a mechanism to obtain mod header entry that flow is attached to (through list head). This is not safe when concurrent modification of list of flows attached to mod header entry is possible. Proper atomic reference counter is required to support concurrent access. As a preparation for extending mod header with reference counting, extract code that lookups and deletes mod header entry into standalone put/get helpers. In order to remove this dependency on external locking, extend mod header entry with reference counter to manage its lifetime and extend flow structure with direct pointer to mod header entry that flow is attached to. To remove code duplication between legacy and switchdev mode implementations that both support mod_hdr functionality, store mod_hdr table in dedicated structure used by both fdb and kernel namespaces. New table structure is extended with table lock by one of the following patches in this series. Implement helper function to get correct mod_hdr table depending on flow namespace. Signed-off-by: Vlad Buslov <vladbu@mellanox.com> Reviewed-by: Jianbo Liu <jianbol@mellanox.com> Reviewed-by: Roi Dayan <roid@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
2019-08-09net/mlx5e: Allow concurrent creation of hairpin entriesVlad Buslov1-19/+46
Hairpin entries creation is fully synchronized by hairpin_tbl_lock. In order to allow concurrent initialization of mlx5e_hairpin structure instances and provisioning of hairpin entries to hardware, extend mlx5e_hairpin_entry with 'res_ready' completion. Move call to mlx5e_hairpin_create() out of hairpin_tbl_lock critical section. Modify code that attaches new flows to existing hpe to wait for 'res_ready' completion before using the hpe. Insert hpe to hairpin table before provisioning it to hardware and modify all users of hairpin table to verify that hpe was fully initialized by checking hpe->hp pointer (and to wait for 'res_ready' completion, if necessary). Modify dead peer update event handling function to save hpe's to temporary list with their reference counter incremented. Wait for completion of hpe's in temporary list and update their 'peer_gone' flag outside of hairpin_tbl_lock critical section. Signed-off-by: Vlad Buslov <vladbu@mellanox.com> Reviewed-by: Roi Dayan <roid@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
2019-08-09net/mlx5e: Protect hairpin hash table with mutexVlad Buslov2-4/+18
To remove dependency on rtnl lock, protect hairpin hash table from concurrent modifications with new "hairpin_tbl_lock" mutex. Signed-off-by: Vlad Buslov <vladbu@mellanox.com> Reviewed-by: Roi Dayan <roid@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
2019-08-09net/mlx5e: Protect hairpin entry flows list with spinlockVlad Buslov1-0/+8
To remove dependency on rtnl lock, extend hairpin entry with spinlock and use it to protect list of flows attached to hairpin entry from concurrent modifications. Signed-off-by: Vlad Buslov <vladbu@mellanox.com> Reviewed-by: Jianbo Liu <jianbol@mellanox.com> Reviewed-by: Roi Dayan <roid@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
2019-08-09net/mlx5e: Extend hairpin entry with reference counterVlad Buslov1-18/+26
List of flows attached to hairpin entry is used as implicit reference counter (hairpin entry is deallocated when list becomes free) and as a mechanism to obtain hairpin entry that flow is attached to (through list head). This is not safe when concurrent modification of list of flows attached to hairpin entry is possible. Proper atomic reference counter is required to support concurrent access. As a preparation for extending hairpin with reference counting, extract code that deletes hairpin entry into standalone function. In order to remove this dependency on external locking, extend hairpin entry with reference counter to manage its lifetime and extend flow structure with direct pointer to hairpin entry that flow is attached to. Signed-off-by: Vlad Buslov <vladbu@mellanox.com> Reviewed-by: Jianbo Liu <jianbol@mellanox.com> Reviewed-by: Roi Dayan <roid@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
2019-08-09Merge branch 'hns3-next'David S. Miller11-242/+615
Huazhong Tan says: ==================== net: hns3: add some bugfixes & optimizations & cleanups for HNS3 driver This patch-set includes code optimizations, bugfixes and cleanups for the HNS3 ethernet controller driver. [patch 01/12] fixes a GFP flag error. [patch 02/12] fixes a VF interrupt error. [patch 03/12] adds a cleanup for VLAN handling. [patch 04/12] fixes a bug in debugfs. [patch 05/12] modifies pause displaying format. [patch 06/12] adds more DFX information for ethtool -d. [patch 07/12] adds more TX statistics information. [patch 08/12] adds a check for TX BD number. [patch 09/12] adds a cleanup for dumping NCL_CONFIG. [patch 10/12] refines function for querying MAC pause statistics. [patch 11/12] adds a handshake with VF when doing PF reset. [patch 12/12] refines some macro definitions. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2019-08-09net: hns3: refine some macro definitionsGuojia Liao2-3/+3
Macro arguments should be enclosed in parentheses, in case of expression argument, but parentheses of pure number in macro definition should be removed for simplicity. Signed-off-by: Guojia Liao <liaoguojia@huawei.com> Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com> Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2019-08-09net: hns3: add handshake with VF for PF resetHuazhong Tan2-8/+55
Before PF asserting function reset, it should make sure that all its VFs have been ready, otherwise, it will cause some hardware errors. So this patch adds function hclge_func_reset_sync_vf() to synchronize VF before asserting PF function reset. For new firmware which supports command HCLGE_OPC_QUERY_VF_RST_RDY, we will try to query VFs' ready status within 30 seconds. And keep the old implementation for compatible with firmware which does not support this command. Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com> Reviewed-by: Yunsheng Lin <linyunsheng@huawei.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2019-08-09net: hns3: refine MAC pause statistics querying functionYufeng Mo3-14/+20
This patch refines the interface for querying MAC pause statistics, and adds structure hns3_mac_stats to keep the count of TX & RX. Signed-off-by: Yufeng Mo <moyufeng@huawei.com> Reviewed-by: Peng Li <lipeng321@huawei.com> Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2019-08-09net: hns3: add function display NCL_CONFIG infoYufeng Mo1-22/+30
This adds a new function hclge_ncl_config_data_print() to print the data of NCL_CONFIG, to make the code more readable. Also, using macro replaces some magic number. Signed-off-by: Yufeng Mo <moyufeng@huawei.com> Reviewed-by: Peng Li <lipeng321@huawei.com> Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com> Signed-off-by: David S. Miller <davem@davemloft.net>