Commit Graph

405 Commits

Author SHA1 Message Date
Huisong Li
fafa81dece net/hns3: support multiple TC MAC pause
MAC PAUSE can take effect on a single TC or multiple TCs, depending on the
hardware. For example, the Kunpeng 920 supports MAC pause in a single TC,
and the Kunpeng 930 supports MAC pause in multiple TCs. This patch
supports MAC PAUSE in multiple TC for some hardware.

Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
2021-07-13 11:41:32 +02:00
Chengchang Tang
0f5bf5a856 net/hns3: support VLAN filter state modify for VF
Since the HW limitation for VF, the VLAN filter is default enabled, and
is not allowed to be closed. Now, the limitation has been removed in
Kunpeng930 network engine, so this patch add support for VF to modify the
VLAN filter state.

A capabilities bit is added to differentiate between different platforms
and achieve compatibility. When the VF runs on an incomatible platform or
an incompatible kernel-mode driver version is used, the VF behavior is
the same as that before.

Signed-off-by: Chengchang Tang <tangchengchang@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
2021-07-13 11:41:32 +02:00
Chengchang Tang
2735b35538 net/hns3: query basic info for VF
There are some features of VF depend on PF, so it's necessary for VF
to know whether current PF supports. Therefore, the final capability
set of VF will be composed of the capability set of hardware and the
capability set of PF.

For compatibility reasons, the mailbox HNS3_MBX_GET_TCINFO has been
modified to obatin more basic information about the current PF, including
the communication interface version and current PF capabilities set.

Signed-off-by: Chengchang Tang <tangchengchang@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
2021-07-13 11:41:32 +02:00
Chengwen Feng
699fa1d40e net/hns3: fix Arm SVE build with GCC 8.3
If the target machine has SVE feature (e.g. '-march=armv8.2-a+sve'),
and compiler is gcc-8.3, it will fail, the error is arm_sve.h:
no such file or directory.

The solution:
a. If RTE_HAS_SVE_ACLE defined (it means the minimum instruction set
support SVE ACLE) then compiles it.
b. Else if the compiler support SVE ACLE then compiles it.
c. Otherwise don't compile it.

Fixes: 8c25b02b08 ("net/hns3: fix enabling SVE Rx/Tx")
Fixes: 952ebacce4 ("net/hns3: support SVE Rx")
Cc: stable@dpdk.org

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Acked-by: Ruifeng Wang <ruifeng.wang@arm.com>
2021-07-09 22:25:31 +02:00
Huisong Li
fc18d1b4b8 net/hns3: fix traffic management
In a multi-TC scenario, if the length of packets destined for different
TCs is different, for example, 64B and 1500B packets destined for TC0 and
TC1 respectively. There is a problem that the bandwidth of the TC to which
large packets are sent is preempted by the TC to which small packets are
sent on the Kunpeng 920 network engine. As a result, the TC bandwidth
accuracy is inaccurate.

To solve this problem, this patch made the following adjustments:
1/ During initialization, firmware reports the capability bit indicating
whether the TM function is supported.
2/ The command word for configuring TC and port rate limiting is added,
instead of reusing the existing command word. And firmware configured
to the correct module.
3/ When the PF driver is loaded, firmware completes the default
initialization of the TC and port.

Fixes: c09c7847d8 ("net/hns3: support traffic management")
Cc: stable@dpdk.org

Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
2021-07-02 19:03:03 +02:00
Chengwen Feng
23e317dd1f net/hns3: support Tx push quick doorbell for performance
Kunpeng 930 support Tx push mode which could improve performance.
It works like below:
 1. Add PCIe bar45 which support driver direct write the Tx descriptor
    or tail reg to it.
 2. Support three operations: a) direct write one Tx descriptor, b)
    direct write two Tx descriptors, c) direct write tail reg.
 3. The original tail reg located at bar23, the above bar45 tail reg
    could provide better bandwidth from the hardware perspective.

The hns3 driver only support direct write tail reg (also have the name
of quick doorbell), the detail:
Considering compatibility, firmware will report Tx push capa if the
hardware support it.

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
2021-07-02 19:03:03 +02:00
Hongbo Zheng
eed962f51d net/hns3: remove unnecessary blank lines
Delete redundant blank lines to make:
1.Return value judgment follow the function call.
2.No blank lines at the end of a code block defined by braces.

Signed-off-by: Hongbo Zheng <zhenghongbo3@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
2021-07-02 19:03:03 +02:00
Huisong Li
5b96963f9d net/hns3: fix maximum queues on configuration failure
The "cfg_max_queues" maintains configured max queue numbers from user,
and is equal to the maximum of "nb_rx_queues" and "nb_tx_queues" in
"dev->data".

From the ethdev layer framework, "nb_rx/tx_queues" in "dev->data" were set
to zero in rte_eth_dev_configure() if ops.dev_configure in PMD fails to be
executed, In addition, if ops.dev_configure in HNS3 PMD failed, the fake
queues are also cleared on a device that does not support independent Rx/Tx
queues.

Therefore, the "cfg_max_queues" should be also set to zero when
dev_configure fails.

Fixes: fa29fe45a7 ("net/hns3: support queue start and stop")
Cc: stable@dpdk.org

Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
2021-07-02 19:03:03 +02:00
Chengchang Tang
d8c497c55a net/hns3: fix VLAN strip log
When the current VLAN stripping is set, the log print always prompts
that the enabling fails, bug if may actually be the disabling failure.

Fixes: 411d23b9ea ("net/hns3: support VLAN")
Cc: stable@dpdk.org

Signed-off-by: Chengchang Tang <tangchengchang@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
2021-07-02 19:03:03 +02:00
Huisong Li
a2ddaac12b net/hns3: fix fake queue rollback
When the device supports independent Rx/Tx queues, fake queues do not need
to be created in unequal Rx/Tx queues case. However, dev_configure fails
to be executed on the device supported independent Rx/Tx queues, the
current rollback code logic contains the fake queue. As a result, the fake
queue is created. When dev_configure is successfully called again, these
fake queues still exists and are configured to the hardware.

Fixes: fa29fe45a7 ("net/hns3: support queue start and stop")
Cc: stable@dpdk.org

Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
2021-07-02 19:03:03 +02:00
Huisong Li
4d8cce2678 net/hns3: fix delay for waiting to stop Rx/Tx
When the primary process executes dev_stop or is being reset, the packet
sending and receiving functions is changed. In this moment, the primary
process requests secondary processes to change their Rx/Tx functions, and
delays a period of time in case of crashes when queues are still in use.
The delay time depends on the number of queues actually used, instead of
the maximum number of queues supported by the device.

Fixes: 23d4b61fee ("net/hns3: support multiple process")
Cc: stable@dpdk.org

Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
2021-07-02 19:03:03 +02:00
Hongbo Zheng
b25987fa7e net/hns3: increase VF reset retry maximum
When the device is very busy, VF reset may have to be
retried many times to succeed, leading to the current
max reset fail retry count not enough.

Modify max reset fail retry count to 30 to enhance
the reliability of reset function.

Fixes: 2790c64647 ("net/hns3: support device reset")
Cc: stable@dpdk.org

Signed-off-by: Hongbo Zheng <zhenghongbo3@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
2021-07-02 19:03:03 +02:00
David Marchand
d07fc02fb4 drivers/net: fix memzone allocations for DMA memory
Caught by code review.

Using a random name for memzone allocations can result in init failures
in the unlikely case that a name collision occurs.
Use a simple sequential generator on 64 bits.

Fixes: 3f50f072ff ("i40e: fix memzone freeing")
Fixes: 22b123a36d ("net/avf: initialize PMD")
Fixes: 5f0978e962 ("net/ice/base: add OS specific implementation")
Fixes: 737f30e1c3 ("net/hns3: support command interface with firmware")
Cc: stable@dpdk.org

Signed-off-by: David Marchand <david.marchand@redhat.com>
Acked-by: Min Hu (Connor) <humin29@huawei.com>
Acked-by: Haiyue Wang <haiyue.wang@intel.com>
2021-07-07 14:30:30 +02:00
Huisong Li
d1ced85a7e net/hns3: fix link speed when VF device is down
When the port is link down state, it is meaningless to display the
port link speed. It should be an undefined state.

Fixes: 59fad0f321 ("net/hns3: support link update operation")
Cc: stable@dpdk.org

Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
2021-05-18 12:30:14 +02:00
Huisong Li
b67bdfc8f6 net/hns3: fix DCB reconfiguration
Whether the enable bit of the pfc ("pfc_en") is changed or not is one of
the conditions for reconfiguring the DCB. Currently, pfc_en is not
rolled back when DCB configuration fails. This patch fixes it.

Fixes: 62e3ccc2b9 ("net/hns3: support flow control")
Cc: stable@dpdk.org

Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
2021-05-18 12:30:14 +02:00
Huisong Li
0b92fa1eb0 net/hns3: fix DCB configuration
Currently, the DCB configuration takes effect in the dev_start stage, and
the mapping between TCs and queues are also updated in this stage.
However, the DCB configuration is delivered in the dev_configure stage.

If the configuration fails, it should be intercepted in this stage. If
the configuration succeeds, the user should be able to obtain the
corresponding updated information, such as the mapping between TCs and
queues. So this patch moves DCB configuration to dev_configure.

Fixes: 62e3ccc2b9 ("net/hns3: support flow control")
Cc: stable@dpdk.org

Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
2021-05-18 12:30:14 +02:00
Huisong Li
47ce649fd3 net/hns3: remove meaningless packet buffer rollback
Packet buffer allocation and hardware pause configuration fail normally
when a reset occurs. If the execution fails, rollback of the packet
buffer still fails. So this rollback is meaningless.

Fixes: 62e3ccc2b9 ("net/hns3: support flow control")
Cc: stable@dpdk.org

Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
2021-05-18 12:30:14 +02:00
Huisong Li
19603f63fb net/hns3: fix requested FC mode rollback
Currently, the "requested_fc_mode" lacks rollback when enabling link
FC or PFC fails.
For example, this may result an incorrect FC mode after a reset.

Fixes: d4fdb71a0e ("net/hns3: fix flow control mode")
Fixes: 62e3ccc2b9 ("net/hns3: support flow control")
Cc: stable@dpdk.org

Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
2021-05-18 12:30:14 +02:00
Huisong Li
16c08f07ab net/hns3: fix Rx/Tx queue numbers check
The Rx/Tx queue numbers should be greater than TC number, this patch adds
this check for PF before updating the mapping between TC and queue.

Fixes: a951c1ed3a ("net/hns3: support different numbers of Rx and Tx queues")
Fixes: 76d794566d ("net/hns3: maximize queue number")
Cc: stable@dpdk.org

Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
2021-05-18 12:30:14 +02:00
Chengwen Feng
ab8c500585 net/hns3: fail setting FEC if one bit mode is not supported
If the FEC mode was not supported, it should return error code.

This patch also adds a space when log error info.

Fixes: 9bf2ea8dbc ("net/hns3: support FEC")
Cc: stable@dpdk.org

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
2021-05-11 20:07:59 +02:00
Chengwen Feng
ac8962e965 net/hns3: fix ordering in secondary process initialization
The memory barrier is used to ensure that the response is returned
only after the Tx/Rx function is set, it should place after the Rx/Tx
function is set.

Fixes: 23d4b61fee ("net/hns3: support multiple process")
Cc: stable@dpdk.org

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
2021-05-11 20:07:59 +02:00
Chengwen Feng
db6a165adc net/hns3: fix secondary process request start/stop Rx/Tx
This secondary process should not send request to start/stop Rx/Tx,
this patch fixes it.

Fixes: 23d4b61fee ("net/hns3: support multiple process")
Cc: stable@dpdk.org

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
2021-05-11 20:07:59 +02:00
Chengwen Feng
34a9a44a32 net/hns3: fix mailbox message ID in log
The mailbox message id is uint8_t, but the unsupported mailbox message
id was logged by uint16.

Fixes: 463e748964 ("net/hns3: support mailbox")
Cc: stable@dpdk.org

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
2021-05-11 20:07:59 +02:00
Chengwen Feng
ffb62592f8 net/hns3: fix TM QCN error event report by MSI-X
The TM QCN error event should report by RAS other than MSIX.

Also this patch adds fifo int enable configuration before the TM QCN
error event is enabled.

Fixes: f53a793bb7 ("net/hns3: add more hardware error types")
Fixes: 3903c05382 ("net/hns3: remove read when enabling TM QCN error event")
Cc: stable@dpdk.org

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
2021-05-11 19:34:17 +02:00
Chengwen Feng
7ab816640c net/hns3: fix querying flow director counter for out param
The hardware doesn't support counting the number of bytes that through
the fdir rule. Therefore, the corresponding out parameters (e.g.
bytes_set/bytes) is set to zero.

Fixes: fcba820d9b ("net/hns3: support flow director")
Cc: stable@dpdk.org

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
2021-05-11 18:29:06 +02:00
Hongbo Zheng
9c552087dc net/hns3: fix VF alive notification after config restore
Currently in the VF reset scenario, the VF performs the set
alive operation before restoring the configuration completed,
which may cause the hardware to work in an abnormal state.

This patch fix this problem by set VF alive after restoring
the configuration is completed.

Fixes: a5475d61fa ("net/hns3: support VF")
Cc: stable@dpdk.org

Signed-off-by: Hongbo Zheng <zhenghongbo3@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
2021-05-11 18:28:43 +02:00
Chengwen Feng
7d01f89fa6 net/hns3: clear hash map on flow director clear
The fdir hash map hold the pointers of fdir rule elements, it needs to
be set to NULL when clear all fdir rules.

Fixes: fcba820d9b ("net/hns3: support flow director")
Cc: stable@dpdk.org

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
2021-05-11 18:27:25 +02:00
Chengwen Feng
f4e5c18ffa net/hns3: fix log on flow director clear
If clear FDIR rules fail, the error code was logged, but the error code
was useless because it was the sum of all fail code.

This patch fixes it by log the success cnt and fail cnt.

Fixes: fcba820d9b ("net/hns3: support flow director")
Fixes: 8eed8acc81 ("net/hns3: add error code to some logs")
Cc: stable@dpdk.org

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
2021-05-11 18:27:25 +02:00
Chengwen Feng
d9fb708a00 net/hns3: return error on PCI config write failure
This patch returns error code when calling rte_pci_write_config() API.

Fixes: 6dd32ded17 ("net/hns3: check PCI config space write")
Cc: stable@dpdk.org

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
2021-05-11 18:27:25 +02:00
David Marchand
eeded2044a log: register with standardized names
Let's try to enforce the convention where most drivers use a pmd. logtype
with their class reflected in it, and libraries use a lib. logtype.

Introduce two new macros:
- RTE_LOG_REGISTER_DEFAULT can be used when a single logtype is
  used in a component. It is associated to the default name provided
  by the build system,
- RTE_LOG_REGISTER_SUFFIX can be used when multiple logtypes are used,
  and then the passed name is appended to the default name,

RTE_LOG_REGISTER is left untouched for existing external users
and for components that do not comply with the convention.

There is a new Meson variable log_prefix to adapt the default name
for baseband (pmd.bb.), bus (no pmd.) and mempool (no pmd.) classes.

Note: achieved with below commands + reverted change on net/bonding +
edits on crypto/virtio, compress/mlx5, regex/mlx5

$ git grep -l RTE_LOG_REGISTER drivers/ |
  while read file; do
    pattern=${file##drivers/};
    class=${pattern%%/*};
    pattern=${pattern#$class/};
    drv=${pattern%%/*};
    case "$class" in
      baseband) pattern=pmd.bb.$drv;;
      bus) pattern=bus.$drv;;
      mempool) pattern=mempool.$drv;;
      *) pattern=pmd.$class.$drv;;
    esac
    sed -i -e 's/RTE_LOG_REGISTER(\(.*\), '$pattern',/RTE_LOG_REGISTER_DEFAULT(\1,/' $file;
    sed -i -e 's/RTE_LOG_REGISTER(\(.*\), '$pattern'\.\(.*\),/RTE_LOG_REGISTER_SUFFIX(\1, \2,/' $file;
  done

$ git grep -l RTE_LOG_REGISTER lib/ |
  while read file; do
    pattern=${file##lib/};
    pattern=lib.${pattern%%/*};
    sed -i -e 's/RTE_LOG_REGISTER(\(.*\), '$pattern',/RTE_LOG_REGISTER_DEFAULT(\1,/' $file;
    sed -i -e 's/RTE_LOG_REGISTER(\(.*\), '$pattern'\.\(.*\),/RTE_LOG_REGISTER_SUFFIX(\1, \2,/' $file;
  done

Signed-off-by: David Marchand <david.marchand@redhat.com>
Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
2021-05-11 15:17:55 +02:00
Thomas Monjalon
0d655820e0 net/hns3: fix debug build
The variable "dev" is not used in hns3_get_tx_prep_needed()
in the case of RTE_LIBRTE_ETHDEV_DEBUG:
drivers/net/hns3/hns3_rxtx.c:4213:45: error: unused parameter ‘dev’

Fixes: d7ec2c0765 ("net/hns3: select Tx prepare based on Tx offload")
Cc: stable@dpdk.org

Reported-by: David Marchand <david.marchand@redhat.com>
Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Acked-by: David Marchand <david.marchand@redhat.com>
2021-05-07 15:19:54 +02:00
Chengwen Feng
b80c527a9c net/hns3: increase readability in logs
Some logs format u64 variables, mostly using hexadecimal which was not
readable.
This patch formats most u64 variables in decimal, and add '0x' prefix
to the ones that are not adjusted.

Fixes: c37ca66f2b ("net/hns3: support RSS")
Fixes: 2790c64647 ("net/hns3: support device reset")
Fixes: 8839c5e202 ("net/hns3: support device stats")
Cc: stable@dpdk.org

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
2021-05-04 18:12:45 +02:00
Chengwen Feng
cdf3e4f300 net/hns3: remove unused VMDq code
VMDq is not supported yet, so remove the unused code.

Fixes: d51867db65 ("net/hns3: add initialization")
Fixes: 1265b5372d ("net/hns3: add some definitions for data structure and macro")
Cc: stable@dpdk.org

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
2021-05-04 18:12:45 +02:00
Chengwen Feng
3903c05382 net/hns3: remove read when enabling TM QCN error event
According to the HW manual, the read operation is unnecessary when
enabling TM QCN error event, so remove it.

Fixes: f53a793bb7 ("net/hns3: add more hardware error types")
Cc: stable@dpdk.org

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
2021-05-04 18:12:45 +02:00
Chengwen Feng
2d408d0609 net/hns3: fix vector Rx burst limitation
Currently, driver uses the macro HNS3_DEFAULT_RX_BURST whose value is
32 to limit the vector Rx burst size, as a result, the burst size
can't exceed 32.

This patch fixes this problem by support big burst size.
Also adjust HNS3_DEFAULT_RX_BURST to 64 as it performs better than 32.

Fixes: a3d4f4d291 ("net/hns3: support NEON Rx")
Fixes: 952ebacce4 ("net/hns3: support SVE Rx")
Cc: stable@dpdk.org

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
2021-05-04 18:02:14 +02:00
Chengwen Feng
cc9dbd9aac net/hns3: log flow director configuration
The rte flow interface does not support the API of the capability
set. Therefore, fdir configuration logs are added to facilitate
debugging.

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
2021-05-04 18:02:14 +02:00
Chengwen Feng
9261fd3caf net/hns3: improve IO path data cache usage
This patch improves data cache usage by:
1. Rearrange the rxq frequency accessed fields in the IO path to the
   first 128B.
2. Rearrange the txq frequency accessed fields in the IO path to the
   first 64B.
3. Make sure ptype table align cacheline size which is 128B instead of
   min cacheline size which is 64B because the L1/L2 is 64B and L3 is
   128B on Kunpeng ARM platform.

The performance gains are 1.5% in 64B packet macfwd scenarios.

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
2021-05-04 18:02:14 +02:00
Chengwen Feng
77d1f6b1af net/hns3: use existing macro to get array size
This patch uses RTE_DIM() instead of ARRAY_SIZE().

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
2021-05-04 18:02:14 +02:00
Chengwen Feng
2aca65258e net/hns3: refactor optimised register write
This patch modifies hns3_write_reg_opt() API implementation because
the rte_write32() already uses rte_io_wmb().

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
2021-05-04 18:02:14 +02:00
Chengwen Feng
116e3399c0 net/hns3: remove some unused capabilities
This patch deletes some unused capabilities, include:
1. Delete some unused firmware capabilities definition, which are:
   UDP_GSO, ATR, INT_QL, SIMPLE_BD, TX_PUSH, FEC and PAUSE.
2. Delete some unused driver capabilities definition, which are:
   UDP_GSO, TX_PUSH.
3. Also redefine HNS3_DEV_SUPPORT_*  as enum type, and change some of
   the values. Note: the HNS3_DEV_SUPPORT_* values is used only inside
   the driver, so it's safe to change the values.

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
2021-05-04 18:02:14 +02:00
Min Hu (Connor)
4801f0403b net/hns3: fix IEEE 1588 PTP for scalar scattered Rx
When jumbo frame is enabled, Rx function will choose 'Scalar Scattered'
function which has no PTP handling.

This patch fixes it by adding PTP handling in 'Scalar Scattered'
function.

Fixes: 38b539d96e ("net/hns3: support IEEE 1588 PTP")

Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
2021-05-04 16:48:18 +02:00
Huisong Li
c70d8e99fb net/hns3: fix MAC enable failure rollback
If driver fails to enable MAC, it does not need to rollback the MAC
configuration. This patch fixes it.

Fixes: bdaf190f82 ("net/hns3: support link speed autoneg for PF")

Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
2021-05-04 16:12:04 +02:00
Chengchang Tang
d7ec2c0765 net/hns3: select Tx prepare based on Tx offload
Tx prepare should be called only when necessary to reduce the impact on
performance.

For partial TX offload, users need to call rte_eth_tx_prepare() to
invoke the tx_prepare callback of PMDs. In this callback, the PMDs
adjust the packet based on the offloading used by the user. (e.g. For
some PMDs, pseudo-headers need to be calculated when the TX cksum is
offloaded.)

However, for the users, they cannot grasp all the hardware and PMDs
characteristics. As a result, users cannot decide when they need to
actually call tx_prepare. Therefore, we should assume that the user
calls rte_eth_tx_prepare() when using any Tx offloading to ensure that
related functions work properly. Whether packets need to be adjusted
should be determined by PMDs. They can make judgments in the
dev_configure or queue_setup phase. When the related function is not
used, the pointer of tx_prepare should be set to NULL to reduce the
performance loss caused by invoking rte_eth_tx_repare().

In this patch, if tx_prepare is not required for the offloading used by
the users, the tx_prepare pointer will be set to NULL.

Fixes: bba6366983 ("net/hns3: support Rx/Tx and related operations")
Cc: stable@dpdk.org

Signed-off-by: Chengchang Tang <tangchengchang@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
2021-04-29 18:25:40 +02:00
Chengwen Feng
1f9d940d6d net/hns3: remove unused macros
The hns3_is_csq() and cmq_ring_to_dev() macro were defined in previous
version but never used.

Fixes: 737f30e1c3 ("net/hns3: support command interface with firmware")
Cc: stable@dpdk.org

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
2021-04-29 18:25:40 +02:00
Chengwen Feng
78dbb6f999 net/hns3: fix time delta calculation
Currently, driver uses gettimeofday() API to get the time, and
then calculate the time delta, the delta will be used mainly in
judging timeout process.

But the time which gets from gettimeofday() API isn't monotonically
increasing. The process may fail if the system time is changed.

We use the following scheme to fix it:
1. Add hns3_clock_gettime() API which will get the monotonically
   increasing time.
2. Add hns3_clock_calctime_ms() API which will get the milliseconds of
   the monotonically increasing time.
3. Add hns3_clock_calctime_ms() API which will calc the milliseconds of
   a given time.

Fixes: 2790c64647 ("net/hns3: support device reset")
Cc: stable@dpdk.org

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
2021-04-29 18:25:40 +02:00
Chengwen Feng
c9a63bb64e net/hns3: log time delta in decimal format
If the reset process cost too much time, driver will log one error
message which formats the time delta, but the formatting is using
hexadecimal which was not readable.

This patch fixes it by formatting in decimal format.

Fixes: 2790c64647 ("net/hns3: support device reset")
Cc: stable@dpdk.org

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
2021-04-29 18:25:40 +02:00
Chengwen Feng
bab23c5c63 net/hns3: support preferred burst size and queues in VF
This patch supports get preferred burst size and queues when call
rte_eth_dev_info_get() API with VF.

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
2021-04-29 18:25:40 +02:00
Huisong Li
230d4940ed net/hns3: fix link speed when port is down
When the port is link down state, it is meaningless to display the
port link speed. It should be an undefined state.

Fixes: 59fad0f321 ("net/hns3: support link update operation")
Cc: stable@dpdk.org

Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
2021-04-29 09:54:27 +02:00
Huisong Li
64308555d5 net/hns3: fix link status when port is stopped
When port is stopped, link down should be reported to user. For HNS3
PF driver, link status comes from link status of hardware. If the port
supports NCSI feature, hardware MAC will not be disabled. At this case,
even if the port is stopped, the link status is still Up. So driver
should set link down when the port is stopped.

Fixes: 59fad0f321 ("net/hns3: support link update operation")
Cc: stable@dpdk.org

Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
2021-04-29 09:54:27 +02:00
Chengwen Feng
fae9b062b0 net/hns3: fix handling link update
The link fails code should be parsed using the structure
hns3_mbx_vf_to_pf_cmd, else it will parse fail.

Fixes: 109e4dd1bd ("net/hns3: get link state change through mailbox")
Cc: stable@dpdk.org

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
2021-04-27 17:08:03 +02:00