Commit Graph

62 Commits

Author SHA1 Message Date
Hans Petter Selasky
156b40b62b Free hardware queue resource after port is stopped in the mlx4en(4)
driver. Else if the port is up the resource might still be busy and
the MTT free will fail.

PR:			216493
MFC after:		3 days
Sponsored by:		Mellanox Technologies
2017-06-01 10:39:00 +00:00
Hans Petter Selasky
fe3ca95c9d mlx4: Use the CQ quota for SRIOV when creating completion EQs
When creating EQs to handle CQ completion events for the PF or for
VFs, we create enough EQE entries to handle completions for the max
number of CQs that can use that EQ.

When SRIOV is activated, the max number of CQs a VF (or the PF) can
obtain is its CQ quota (determined by the Hypervisor resource
tracker).  Therefore, when creating an EQ, the number of EQE entries
that the VF should request for that EQ is the CQ quota value (and not
the total number of CQs available in the firmware).

Under SRIOV, the PF, also must use its CQ quota, because the resource
tracker also controls how many CQs the PF can obtain.

Using the firmware total CQs instead of the CQ quota when creating EQs
resulted wasting MTT entries, due to allocating more EQEs than were
needed.

MFC after:		3 days
Sponsored by:		Mellanox Technologies
2017-05-19 12:22:48 +00:00
Hans Petter Selasky
791c9d7848 Don't free uninitialized sysctl contexts in the mlx4en driver. This
can cause NULL pointer panics during failed device attach.

Differential Revision:	https://reviews.freebsd.org/D8876
MFC after:		1 week
Sponsored by:		Mellanox Technologies
2017-04-27 14:39:52 +00:00
Hans Petter Selasky
08c6504d07 Improve code readability and fix compilation error when using clang 4.x.
Found by:		emaste @
MFC after:		1 week
Sponsored by:		Mellanox Technologies
2017-02-15 18:31:09 +00:00
Hans Petter Selasky
64968e7065 Change mlx4 QP allocation scheme.
When using Blue-Flame, BF, the QPN overrides the VLAN, CV, and SV
fields in the WQE. Thus, BF may only be used for QPNs with bits 6,7
unset.

The current ethernet driver code reserves a TX QP range with 256b
alignment.

This is wrong because if there are more than 64 TX QPs in use, QPNs >=
base + 65 will have bits 6/7 set.

This problem is not specific for the Ethernet driver, any entity that
tries to reserve more than 64 BF-enabled QPs should fail. Also, using
ranges is not necessary here and is wasteful.

The new mechanism introduced here will support reservation for "Eth
QPs eligible for BF" for all drivers: bare-metal, multi-PF, and VFs
(when hypervisors support WC in VMs). The flow we use is:

1. In mlx4_en, allocate Tx QPs one by one instead of a range allocation,
   and request "BF enabled QPs" if BF is supported for the function

2. In the ALLOC_RES FW command, change param1 to:
a. param1[23:0]  - number of QPs
b. param1[31-24] - flags controlling QPs reservation

Bit 31 refers to Eth blueflame supported QPs. Those QPs must have bits
6 and 7 unset in order to be used in Ethernet.

Bits 24-30 of the flags are currently reserved.

When a function tries to allocate a QP, it states the required
attributes for this QP. Those attributes are considered "best-effort".
If an attribute, such as Ethernet BF enabled QP, is a must-have
attribute, the function has to check that attribute is supported
before trying to do the allocation.

In a lower layer of the code, mlx4_qp_reserve_range masks out the bits
which are unsupported. If SRIOV is used, the PF validates those
attributes and masks out unsupported attributes as well. In order to
notify VFs which attributes are supported, the VF uses QUERY_FUNC_CAP
command. This command's mailbox is filled by the PF, which notifies
which QP allocation attributes it supports.

Obtained from:		Linux (dual BSD/GPLv2 licensed)
Submitted by:		Dexuan Cui @ microsoft . com
Differential Revision:	https://reviews.freebsd.org/D8868
MFC after:		2 weeks
Sponsored by:		Mellanox Technologies
2017-02-10 15:28:18 +00:00
Hans Petter Selasky
2cebcdc7b6 Flexible and asymmetric allocation of EQs and MSI-X vectors for PF/VFs.
Previously, the mlx4 driver queried the firmware in order to get the
number of supported EQs. Under SRIOV, since this was done before the
driver notified the firmware how many VFs it actually needs, the
firmware had to take into account a worst case scenario and always
allocated four EQs per VF, where one was used for events while the
others were used for completions. Now, when the firmware supports the
asymmetric allocation scheme, denoted by exposing num_sys_eqs > 0 (-->
MLX4_DEV_CAP_FLAG2_SYS_EQS), we use the QUERY_FUNC command to query
the firmware before enabling SRIOV. Thus we can get more EQs and MSI-X
vectors per function. Moreover, when running in the new
firmware/driver mode, the limitation that the number of EQs should be
a power of two is lifted.

Obtained from:		Linux (dual BSD/GPLv2 licensed)
Submitted by:		Dexuan Cui @ microsoft . com
Differential Revision:	https://reviews.freebsd.org/D8867
MFC after:		2 weeks
Sponsored by:		Mellanox Technologies
2017-02-10 15:22:21 +00:00
Ed Maste
f0473bfa82 mlx(4): remove date from log message
Further to r310425, go one step further and just remove the date.

Reviewed by:	hselasky
Differential Revision:	https://reviews.freebsd.org/D8888
2016-12-23 20:14:05 +00:00
Ed Maste
07b2e5c92a mlx: avoid use of __DATE__ to make build reproducible
Reviewed by:	hselasky
Differential Revision:	https://reviews.freebsd.org/D8886
2016-12-22 18:26:21 +00:00
Dimitry Andric
a3228a75a0 After r310171, the kernel version of sscanf() has format string checking
enabled.  This results in a -Werror warning in mlx4ib:

    sys/dev/mlx4/mlx4_ib/mlx4_ib_sysfs.c:90:22: error: format specifies type 'unsigned long long *' but the argument has type 'u64 *' (aka 'unsigned long *') [-Werror,-Wformat]
            sscanf(buf, "%llx", &sysadmin_ag_val);
                         ~~~~   ^~~~~~~~~~~~~~~~

Change sysadmin_ag_val to unsigned long long to avoid the warning.

Reviewed by:	hselasky
MFC after:	3 days
Differential Revision: https://reviews.freebsd.org/D8831
2016-12-18 15:21:38 +00:00
Hans Petter Selasky
d3e8d4784d Fix initialisation of mlx4_pci_table's .driver_data fields.
MFC after:		1 week
Differential Revision:	https://reviews.freebsd.org/D8791
Sponsored by:		Mellanox Technologies
Submitted by:		Dexuan Cui <decui@microsoft.com>
2016-12-14 14:13:44 +00:00
Hans Petter Selasky
b133b47342 Fix indentation and remove duplicate queue stopped stats increment.
Found by:	Ryan Stone <rysto32@gmail.com>
Sponsored by:	Mellanox Technologies
MFC after:	1 week
2016-10-28 12:36:59 +00:00
Hans Petter Selasky
97549c34ec Move the ConnectX-3 and ConnectX-2 driver from sys/ofed into sys/dev/mlx4
like other PCI network drivers. The sys/ofed directory is now mainly
reserved for generic infiniband code, with exception of the mthca driver.

- Add new manual page, mlx4en(4), describing how to configure and load
mlx4en.

- All relevant driver C-files are now prefixed mlx4, mlx4_en and
mlx4_ib respectivly to avoid object filename collisions when compiling
the kernel. This also fixes an issue with proper dependency file
generation for the C-files in question.

- Device mlxen is now device mlx4en and depends on device mlx4, see
mlx4en(4). Only the network device name remains unchanged.

- The mlx4 and mlx4en modules are now built by default on i386 and
amd64 targets. Only building the mlx4ib module depends on
WITH_OFED=YES .

Sponsored by:	Mellanox Technologies
2016-09-30 08:23:06 +00:00