Skip to contentSkip to conversation

net/atlantic: Aquantia aQtion 10G NIC Family DPDK PMD driver

PATCH Superseded Igor Russkikh 2 participants 37 messages Oct 9, 2018 – Oct 10, 2018

Subsystems (2)

v4 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v4 cover net/atlantic: Aquantia aQtion 10G NIC Family DPDK PMD driver

Hello DPDK community!

Aquantia would like to contribute PMD for aQtion AQC10X NIC family:
https://www.aquantia.com/products/aqtion/chips/
These are 10G ethernet NICs with various features.

We do base this work on parts of the existing native linux kernel driver source (atlantic). Shared code is hw_atl hardware and registers access module.

We'd like to target this driver for 18.11 DPDK release timeline, it'd be good to hear comments from the community on how feasible is this.

This patchset implements basic driver infrastructure, vlan offloads, checksumm offloads, rss control, multiring, jumbo frames and other features.

Later on, we plan to share HW MACSEC offloads, rxflows and other features.

version 4 changes:
- fixed build errors with -Werror on gcc7
- validated build on arm64, freebsd x86_64
- PPC marked as unsupported arch
- stdbool.h is used instead of bool redefines

version 3 changes:
- patchset fixed to be incrementally buildable
- extra includes removed and cleaned up
- license changed to dual GPL-BSD for pieces shared with linux
- removed extra logging #defines
- misc comments from previous review session

version 2 changes:
- fixed build on freebsd (no ETIME const)
- fixed a bunch of checkpatch failures and warnings
- removed extra CFLAGS disabled warning
- making static arrays const

Igor Russkikh (9):
net/atlantic: logging macroes and some typedefs net/atlantic: hardware register access routines net/atlantic: hw_atl register declarations net/atlantic: firmware operations layer net/atlantic: b0 hardware layer main logic net/atlantic: RX side structures and implementation net/atlantic: RSS and RETA manipulation API net/atlantic: LED control DPDK and private APIs net/atlantic: documentation and rel notes

Pavel Belous (13):
net/atlantic: atlantic PMD driver skeleton net/atlantic: rte device start, stop, initial configuration net/atlantic: TX/RX function prototypes
net/atlantic: TX side structures and implementation net/atlantic: link status and interrupt management net/atlantic: device statistics, xstats
net/atlantic: support for RX/TX descriptors information net/atlantic: promisc and allmulti configuration net/atlantic: flow control configuration net/atlantic: MAC address manipulations
net/atlantic: VLAN filters and offloads
net/atlantic: eeprom and register manipulation routines net/atlantic: support for read MAC registers for debug purposes

 config/common_base                                |    5 +
 config/defconfig_ppc_64-power8-linuxapp-gcc       |    1 +
 doc/guides/nics/atlantic.rst                      |   53 +
 doc/guides/nics/features/atlantic.ini             |   37 +
 doc/guides/nics/index.rst                         |    1 +
 doc/guides/rel_notes/release_18_11.rst            |    5 +
 drivers/net/Makefile                              |    1 +
 drivers/net/atlantic/Makefile                     |   39 +
 drivers/net/atlantic/atl_common.h                 |   96 +
 drivers/net/atlantic/atl_ethdev.c                 | 1688 +++++++++++++++
 drivers/net/atlantic/atl_ethdev.h                 |  111 +
 drivers/net/atlantic/atl_hw_regs.c                |   52 +
 drivers/net/atlantic/atl_hw_regs.h                |   53 +
 drivers/net/atlantic/atl_logs.h                   |   31 +
 drivers/net/atlantic/atl_rxtx.c                   | 1347 ++++++++++++
 drivers/net/atlantic/atl_types.h                  |  186 ++
 drivers/net/atlantic/hw_atl/hw_atl_b0.c           |  510 +++++
 drivers/net/atlantic/hw_atl/hw_atl_b0.h           |   40 +
 drivers/net/atlantic/hw_atl/hw_atl_b0_internal.h  |  145 ++
 drivers/net/atlantic/hw_atl/hw_atl_llh.c          | 1490 +++++++++++++
 drivers/net/atlantic/hw_atl/hw_atl_llh.h          |  714 ++++++
 drivers/net/atlantic/hw_atl/hw_atl_llh_internal.h | 2407 +++++++++++++++++++++
 drivers/net/atlantic/hw_atl/hw_atl_utils.c        |  942 ++++++++
 drivers/net/atlantic/hw_atl/hw_atl_utils.h        |  510 +++++
 drivers/net/atlantic/hw_atl/hw_atl_utils_fw2x.c   |  618 ++++++
 drivers/net/atlantic/meson.build                  |   15 +
 drivers/net/atlantic/rte_pmd_atlantic.c           |   19 +
 drivers/net/atlantic/rte_pmd_atlantic.h           |   44 +
 drivers/net/atlantic/rte_pmd_atlantic_version.map |    4 +
 drivers/net/meson.build                           |    1 +
 mk/rte.app.mk                                     |    1 +
 31 files changed, 11166 insertions(+)
 create mode 100644 doc/guides/nics/atlantic.rst
 create mode 100644 doc/guides/nics/features/atlantic.ini
 create mode 100644 drivers/net/atlantic/Makefile
 create mode 100644 drivers/net/atlantic/atl_common.h
 create mode 100644 drivers/net/atlantic/atl_ethdev.c
 create mode 100644 drivers/net/atlantic/atl_ethdev.h
 create mode 100644 drivers/net/atlantic/atl_hw_regs.c
 create mode 100644 drivers/net/atlantic/atl_hw_regs.h
 create mode 100644 drivers/net/atlantic/atl_logs.h
 create mode 100644 drivers/net/atlantic/atl_rxtx.c
 create mode 100644 drivers/net/atlantic/atl_types.h
 create mode 100644 drivers/net/atlantic/hw_atl/hw_atl_b0.c
 create mode 100644 drivers/net/atlantic/hw_atl/hw_atl_b0.h
 create mode 100644 drivers/net/atlantic/hw_atl/hw_atl_b0_internal.h
 create mode 100644 drivers/net/atlantic/hw_atl/hw_atl_llh.c
 create mode 100644 drivers/net/atlantic/hw_atl/hw_atl_llh.h
 create mode 100644 drivers/net/atlantic/hw_atl/hw_atl_llh_internal.h
 create mode 100644 drivers/net/atlantic/hw_atl/hw_atl_utils.c
 create mode 100644 drivers/net/atlantic/hw_atl/hw_atl_utils.h
 create mode 100644 drivers/net/atlantic/hw_atl/hw_atl_utils_fw2x.c
 create mode 100644 drivers/net/atlantic/meson.build
 create mode 100644 drivers/net/atlantic/rte_pmd_atlantic.c
 create mode 100644 drivers/net/atlantic/rte_pmd_atlantic.h
 create mode 100644 drivers/net/atlantic/rte_pmd_atlantic_version.map
Signature · 1 line
2.7.4
#1 lore raw

PATCH v4 1/22 net/atlantic: atlantic PMD driver skeleton

From: Pavel Belous <[email protected]>

Makefile/meson build infrastructure, atl_ethdev minimal skeleton, header with aquantia aQtion NIC device and vendor IDs.

---
 config/common_base                                |   5 +
 config/defconfig_ppc_64-power8-linuxapp-gcc       |   1 +
 drivers/net/Makefile                              |   1 +
 drivers/net/atlantic/Makefile                     |  27 ++++
 drivers/net/atlantic/atl_common.h                 |  96 ++++++++++++
 drivers/net/atlantic/atl_ethdev.c                 | 170 ++++++++++++++++++++++
 drivers/net/atlantic/atl_ethdev.h                 |  15 ++
 drivers/net/atlantic/meson.build                  |   6 +
 drivers/net/atlantic/rte_pmd_atlantic_version.map |   4 +
 drivers/net/meson.build                           |   1 +
 mk/rte.app.mk                                     |   1 +
 11 files changed, 327 insertions(+)
 create mode 100644 drivers/net/atlantic/Makefile
 create mode 100644 drivers/net/atlantic/atl_common.h
 create mode 100644 drivers/net/atlantic/atl_ethdev.c
 create mode 100644 drivers/net/atlantic/atl_ethdev.h
 create mode 100644 drivers/net/atlantic/meson.build
 create mode 100644 drivers/net/atlantic/rte_pmd_atlantic_version.map
config/common_base +5 -0
index acc5211bcc17..090ed26d13a1 100644
@@ -641,6 +641,11 @@ CONFIG_RTE_LIBRTE_PMD_DPAA_EVENTDEV=n
 CONFIG_RTE_LIBRTE_PMD_DPAA2_EVENTDEV=n
 
 #
+# Compile Aquantia Atlantic PMD driver
+#
+CONFIG_RTE_LIBRTE_ATLANTIC_PMD=y
+
+#
 # Compile raw device support
 # EXPERIMENTAL: API may change without prior notice
 #
config/defconfig_ppc_64-power8-linuxapp-gcc +1 -0
index a52e22efcc9d..8cbf7ed50c15 100644
@@ -48,6 +48,7 @@ CONFIG_RTE_LIBRTE_EAL_VMWARE_TSC_MAP_SUPPORT=n
 
 # Note: Initially, all of the PMD drivers compilation are turned off on Power
 # Will turn on them only after the successful testing on Power
+CONFIG_RTE_LIBRTE_ATLANTIC_PMD=n
 CONFIG_RTE_LIBRTE_IXGBE_PMD=n
 CONFIG_RTE_LIBRTE_VIRTIO_PMD=y
 CONFIG_RTE_LIBRTE_VMXNET3_PMD=n
drivers/net/Makefile +1 -0
index 664398de983a..8ac6b9db5916 100644
@@ -10,6 +10,7 @@ endif
 
 DIRS-$(CONFIG_RTE_LIBRTE_PMD_AF_PACKET) += af_packet
 DIRS-$(CONFIG_RTE_LIBRTE_ARK_PMD) += ark
+DIRS-$(CONFIG_RTE_LIBRTE_ATLANTIC_PMD) += atlantic
 DIRS-$(CONFIG_RTE_LIBRTE_AVF_PMD) += avf
 DIRS-$(CONFIG_RTE_LIBRTE_AVP_PMD) += avp
 DIRS-$(CONFIG_RTE_LIBRTE_AXGBE_PMD) += axgbe
drivers/net/atlantic/Makefile new file +27 -0
new file mode 100644
index 000000000000..e42ce5b178ab
@@ -0,0 +1,27 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2018 Aquantia Corporation
+
+include $(RTE_SDK)/mk/rte.vars.mk
+
+#
+# library name
+#
+LIB = librte_pmd_atlantic.a
+
+CFLAGS += -O3
+CFLAGS += $(WERROR_FLAGS)
+
+EXPORT_MAP := rte_pmd_atlantic_version.map
+
+LIBABIVER := 1
+
+LDLIBS += -lrte_eal
+LDLIBS += -lrte_ethdev -lrte_net
+LDLIBS += -lrte_bus_pci
+
+#
+# all source are stored in SRCS-y
+#
+SRCS-$(CONFIG_RTE_LIBRTE_ATLANTIC_PMD) += atl_ethdev.c
+
+include $(RTE_SDK)/mk/rte.lib.mk
drivers/net/atlantic/atl_common.h new file +96 -0

96 lines not on this page · raw message

drivers/net/atlantic/atl_ethdev.c new file +170 -0

170 lines not on this page · raw message

drivers/net/atlantic/atl_ethdev.h new file +15 -0
new file mode 100644
index 000000000000..622806837379
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2018 Aquantia Corporation
+ */
+
+#ifndef _ATLANTIC_ETHDEV_H_
+#define _ATLANTIC_ETHDEV_H_
+#include <rte_errno.h>
+#include "rte_ethdev.h"
+/*
+ * Structure to store private data for each driver instance (for each port).
+ */
+struct atl_adapter {
+};
+
+#endif /* _ATLANTIC_ETHDEV_H_ */
drivers/net/atlantic/meson.build new file +6 -0
new file mode 100644
index 000000000000..c5a2546ef657
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2018 Aquantia Corporation
+
+sources = files(
+	'atl_ethdev.c',
+)
drivers/net/atlantic/rte_pmd_atlantic_version.map new file +4 -0
new file mode 100644
index 000000000000..521e51f411fb
@@ -0,0 +1,4 @@
+DPDK_18.11 {
+
+	local: *;
+};
drivers/net/meson.build +1 -0
index 5906283c2f5c..32374141a9ea 100644
@@ -3,6 +3,7 @@
 
 drivers = ['af_packet',
 	'ark',
+	'atlantic',
 	'avf',
 	'avp',
 	'axgbe', 'bonding',
mk/rte.app.mk +1 -0
index 32579e4b7587..009280701034 100644
@@ -123,6 +123,7 @@ endif
 
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_AF_PACKET)  += -lrte_pmd_af_packet
 _LDLIBS-$(CONFIG_RTE_LIBRTE_ARK_PMD)        += -lrte_pmd_ark
+_LDLIBS-$(CONFIG_RTE_LIBRTE_ATLANTIC_PMD)   += -lrte_pmd_atlantic
 _LDLIBS-$(CONFIG_RTE_LIBRTE_AVF_PMD)        += -lrte_pmd_avf
 _LDLIBS-$(CONFIG_RTE_LIBRTE_AVP_PMD)        += -lrte_pmd_avp
 _LDLIBS-$(CONFIG_RTE_LIBRTE_AXGBE_PMD)      += -lrte_pmd_axgbe
Signature · 1 line
2.7.4
#3 lore raw

PATCH v4 2/22 net/atlantic: logging macroes and some typedefs

In reply to Igor Russkikh
---
 drivers/net/atlantic/atl_ethdev.c | 16 ++++++++++++++++
 drivers/net/atlantic/atl_logs.h   | 31 +++++++++++++++++++++++++++++++
 drivers/net/atlantic/atl_types.h  | 25 +++++++++++++++++++++++++
 3 files changed, 72 insertions(+)
 create mode 100644 drivers/net/atlantic/atl_logs.h
 create mode 100644 drivers/net/atlantic/atl_types.h
drivers/net/atlantic/atl_ethdev.c +16 -0
index a9d7a5a49398..2e0331d987c3 100644
@@ -23,6 +23,9 @@ static int eth_atl_pci_remove(struct rte_pci_device *pci_dev);
 static void atl_dev_info_get(struct rte_eth_dev *dev,
 				struct rte_eth_dev_info *dev_info);
 
+int atl_logtype_init;
+int atl_logtype_driver;
+
 /*
  * The set of PCI devices this driver supports
  */
@@ -168,3 +171,16 @@ atl_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 RTE_PMD_REGISTER_PCI(net_atlantic, rte_atl_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_atlantic, pci_id_atl_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_atlantic, "* igb_uio | uio_pci_generic");
+
+RTE_INIT(atl_init_log);
+static void
+atl_init_log(void)
+{
+	atl_logtype_init = rte_log_register("pmd.atlantic.init");
+	if (atl_logtype_init >= 0)
+		rte_log_set_level(atl_logtype_init, RTE_LOG_DEBUG);
+	atl_logtype_driver = rte_log_register("pmd.atlantic.driver");
+	if (atl_logtype_driver >= 0)
+		rte_log_set_level(atl_logtype_driver, RTE_LOG_DEBUG);
+}
+
drivers/net/atlantic/atl_logs.h new file +31 -0
new file mode 100644
index 000000000000..e3dba334fe92
@@ -0,0 +1,31 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2018 Aquantia Corporation
+ */
+#ifndef ATL_LOGS_H
+#define ATL_LOGS_H
+
+#include <rte_log.h>
+
+extern int atl_logtype_init;
+
+#define PMD_INIT_LOG(level, fmt, args...) \
+	rte_log(RTE_LOG_ ## level, atl_logtype_init, \
+		"%s(): " fmt "\n", __func__, ##args)
+
+#define PMD_INIT_FUNC_TRACE() PMD_INIT_LOG(DEBUG, " >>")
+
+#define PMD_RX_LOG(level, fmt, args...) \
+	RTE_LOG_DP(level, PMD, "%s(): " fmt "\n", __func__, ## args)
+
+#define PMD_TX_LOG(level, fmt, args...) \
+	RTE_LOG_DP(level, PMD, "%s(): " fmt "\n", __func__, ## args)
+
+extern int atl_logtype_driver;
+#define PMD_DRV_LOG_RAW(level, fmt, args...) \
+	rte_log(RTE_LOG_ ## level, atl_logtype_driver, "%s(): " fmt, \
+		__func__, ## args)
+
+#define PMD_DRV_LOG(level, fmt, args...) \
+	PMD_DRV_LOG_RAW(level, fmt "\n", ## args)
+
+#endif
drivers/net/atlantic/atl_types.h new file +25 -0
new file mode 100644
index 000000000000..d8c2560807d3
@@ -0,0 +1,25 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2018 Aquantia Corporation
+ */
+#ifndef ATL_TYPES_H
+#define ATL_TYPES_H
+
+#include <stdint.h>
+#include <stddef.h>
+#include <inttypes.h>
+#include <string.h>
+#include <stdbool.h>
+
+
+typedef uint8_t		u8;
+typedef int8_t		s8;
+typedef uint16_t	u16;
+typedef int16_t		s16;
+typedef uint32_t	u32;
+typedef int32_t		s32;
+typedef uint64_t	u64;
+
+#define min(a, b)	RTE_MIN(a, b)
+#define max(a, b)	RTE_MAX(a, b)
+
+#endif
Signature · 1 line
2.7.4
#5 lore raw

PATCH v4 3/22 net/atlantic: hardware register access routines

In reply to Igor Russkikh
---
 drivers/net/atlantic/Makefile      |  1 +
 drivers/net/atlantic/atl_hw_regs.c | 52 +++++++++++++++++++++++++++++++++++++
 drivers/net/atlantic/atl_hw_regs.h | 53 ++++++++++++++++++++++++++++++++++++++
 drivers/net/atlantic/atl_types.h   |  4 +++
 drivers/net/atlantic/meson.build   |  1 +
 5 files changed, 111 insertions(+)
 create mode 100644 drivers/net/atlantic/atl_hw_regs.c
 create mode 100644 drivers/net/atlantic/atl_hw_regs.h
drivers/net/atlantic/Makefile +1 -0
index e42ce5b178ab..8613ced71732 100644
@@ -23,5 +23,6 @@ LDLIBS += -lrte_bus_pci
 # all source are stored in SRCS-y
 #
 SRCS-$(CONFIG_RTE_LIBRTE_ATLANTIC_PMD) += atl_ethdev.c
+SRCS-$(CONFIG_RTE_LIBRTE_ATLANTIC_PMD) += atl_hw_regs.c
 
 include $(RTE_SDK)/mk/rte.lib.mk
drivers/net/atlantic/atl_hw_regs.c new file +52 -0

52 lines not on this page · raw message

drivers/net/atlantic/atl_hw_regs.h new file +53 -0

53 lines not on this page · raw message

drivers/net/atlantic/atl_types.h +4 -0
index d8c2560807d3..725b0c4dc670 100644
@@ -22,4 +22,8 @@ typedef uint64_t	u64;
 #define min(a, b)	RTE_MIN(a, b)
 #define max(a, b)	RTE_MAX(a, b)
 
+struct aq_hw_s {
+	void *mmio;
+};
+
 #endif
drivers/net/atlantic/meson.build +1 -0
index c5a2546ef657..cd6a0f637a7d 100644
@@ -3,4 +3,5 @@
 
 sources = files(
 	'atl_ethdev.c',
+	'atl_hw_regs.c',
 )
Signature · 1 line
2.7.4
#6 lore raw

PATCH v4 4/22 net/atlantic: hw_atl register declarations

In reply to Igor Russkikh

This hw_atl layer is maintained in sync with linux kernel driver. It will generally be in sync with linux upstream.

---
 drivers/net/atlantic/Makefile                     |    3 +
 drivers/net/atlantic/hw_atl/hw_atl_llh.c          | 1490 +++++++++++++
 drivers/net/atlantic/hw_atl/hw_atl_llh.h          |  714 ++++++
 drivers/net/atlantic/hw_atl/hw_atl_llh_internal.h | 2407 +++++++++++++++++++++
 drivers/net/atlantic/meson.build                  |    1 +
 5 files changed, 4615 insertions(+)
 create mode 100644 drivers/net/atlantic/hw_atl/hw_atl_llh.c
 create mode 100644 drivers/net/atlantic/hw_atl/hw_atl_llh.h
 create mode 100644 drivers/net/atlantic/hw_atl/hw_atl_llh_internal.h
drivers/net/atlantic/Makefile +3 -0
index 8613ced71732..cae317badc0c 100644
@@ -19,10 +19,13 @@ LDLIBS += -lrte_eal
 LDLIBS += -lrte_ethdev -lrte_net
 LDLIBS += -lrte_bus_pci
 
+VPATH += $(SRCDIR)/hw_atl
+
 #
 # all source are stored in SRCS-y
 #
 SRCS-$(CONFIG_RTE_LIBRTE_ATLANTIC_PMD) += atl_ethdev.c
 SRCS-$(CONFIG_RTE_LIBRTE_ATLANTIC_PMD) += atl_hw_regs.c
+SRCS-$(CONFIG_RTE_LIBRTE_ATLANTIC_PMD) += hw_atl_llh.c
 
 include $(RTE_SDK)/mk/rte.lib.mk
drivers/net/atlantic/hw_atl/hw_atl_llh.c new file +1490 -0

1,490 lines not on this page · raw message

drivers/net/atlantic/hw_atl/hw_atl_llh.h new file +714 -0

714 lines not on this page · raw message

drivers/net/atlantic/hw_atl/hw_atl_llh_internal.h new file +2407 -0

783 lines not on this page · raw message

drivers/net/atlantic/meson.build +1 -0
index cd6a0f637a7d..055342ec9db7 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.7.4

Part of the diff is not shown here. View the raw message.

#8 lore raw

PATCH v4 5/22 net/atlantic: firmware operations layer

In reply to Igor Russkikh

AQC NICs comes in fields with two major
FW generations: 1x and 3x.

This is part of linux atlantic driver shared code, responsible for internal NIC firmware interactions, including link management ops, FW initialization, various lifecycle features.

---
 drivers/net/atlantic/Makefile                   |   2 +
 drivers/net/atlantic/atl_types.h                |  95 +++
 drivers/net/atlantic/hw_atl/hw_atl_utils.c      | 942 ++++++++++++++++++++++++
 drivers/net/atlantic/hw_atl/hw_atl_utils.h      | 510 +++++++++++++
 drivers/net/atlantic/hw_atl/hw_atl_utils_fw2x.c | 618 ++++++++++++++++
 drivers/net/atlantic/meson.build                |   2 +
 6 files changed, 2169 insertions(+)
 create mode 100644 drivers/net/atlantic/hw_atl/hw_atl_utils.c
 create mode 100644 drivers/net/atlantic/hw_atl/hw_atl_utils.h
 create mode 100644 drivers/net/atlantic/hw_atl/hw_atl_utils_fw2x.c
drivers/net/atlantic/Makefile +2 -0
index cae317badc0c..a291053b5ab7 100644
@@ -26,6 +26,8 @@ VPATH += $(SRCDIR)/hw_atl
 #
 SRCS-$(CONFIG_RTE_LIBRTE_ATLANTIC_PMD) += atl_ethdev.c
 SRCS-$(CONFIG_RTE_LIBRTE_ATLANTIC_PMD) += atl_hw_regs.c
+SRCS-$(CONFIG_RTE_LIBRTE_ATLANTIC_PMD) += hw_atl_utils.c
 SRCS-$(CONFIG_RTE_LIBRTE_ATLANTIC_PMD) += hw_atl_llh.c
+SRCS-$(CONFIG_RTE_LIBRTE_ATLANTIC_PMD) += hw_atl_utils_fw2x.c
 
 include $(RTE_SDK)/mk/rte.lib.mk
drivers/net/atlantic/atl_types.h +95 -0

103 lines not on this page · raw message

drivers/net/atlantic/hw_atl/hw_atl_utils.c new file +942 -0

942 lines not on this page · raw message

drivers/net/atlantic/hw_atl/hw_atl_utils.h new file +510 -0

510 lines not on this page · raw message

drivers/net/atlantic/hw_atl/hw_atl_utils_fw2x.c new file +618 -0

618 lines not on this page · raw message

drivers/net/atlantic/meson.build +2 -0
index 055342ec9db7..b05c97773541 100644
@@ -5,4 +5,6 @@ sources = files(
 	'atl_ethdev.c',
 	'atl_hw_regs.c',
 	'hw_atl/hw_atl_llh.c',
+	'hw_atl/hw_atl_utils_fw2x.c',
+	'hw_atl/hw_atl_utils.c',
 )
Signature · 1 line
2.7.4
#9 lore raw

PATCH v4 6/22 net/atlantic: b0 hardware layer main logic

In reply to Igor Russkikh

This is hw_atl logic layer derived from linux atlantic driver. It contains RX/TX hardware initialization sequences, various hw configuration.

---
 drivers/net/atlantic/Makefile                    |   1 +
 drivers/net/atlantic/atl_types.h                 |  15 +-
 drivers/net/atlantic/hw_atl/hw_atl_b0.c          | 510 +++++++++++++++++++++++
 drivers/net/atlantic/hw_atl/hw_atl_b0.h          |  40 ++
 drivers/net/atlantic/hw_atl/hw_atl_b0_internal.h | 145 +++++++
 drivers/net/atlantic/meson.build                 |   1 +
 6 files changed, 711 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/atlantic/hw_atl/hw_atl_b0.c
 create mode 100644 drivers/net/atlantic/hw_atl/hw_atl_b0.h
 create mode 100644 drivers/net/atlantic/hw_atl/hw_atl_b0_internal.h
drivers/net/atlantic/Makefile +1 -0
index a291053b5ab7..91306d71ba97 100644
@@ -29,5 +29,6 @@ SRCS-$(CONFIG_RTE_LIBRTE_ATLANTIC_PMD) += atl_hw_regs.c
 SRCS-$(CONFIG_RTE_LIBRTE_ATLANTIC_PMD) += hw_atl_utils.c
 SRCS-$(CONFIG_RTE_LIBRTE_ATLANTIC_PMD) += hw_atl_llh.c
 SRCS-$(CONFIG_RTE_LIBRTE_ATLANTIC_PMD) += hw_atl_utils_fw2x.c
+SRCS-$(CONFIG_RTE_LIBRTE_ATLANTIC_PMD) += hw_atl_b0.c
 
 include $(RTE_SDK)/mk/rte.lib.mk
drivers/net/atlantic/atl_types.h +14 -1
index af24da3a5a54..c9ebbf4e91d8 100644
@@ -9,7 +9,7 @@
 #include <inttypes.h>
 #include <string.h>
 #include <stdbool.h>
-
+#include <netinet/in.h>
 
 typedef uint8_t		u8;
 typedef int8_t		s8;
@@ -22,6 +22,7 @@ typedef uint64_t	u64;
 #define min(a, b)	RTE_MIN(a, b)
 #define max(a, b)	RTE_MAX(a, b)
 
+#include "hw_atl/hw_atl_b0_internal.h"
 #include "hw_atl/hw_atl_utils.h"
 
 struct aq_hw_link_status_s {
@@ -50,8 +51,18 @@ struct aq_stats_s {
 	u64 dma_oct_tc;
 };
 
+struct aq_rss_parameters {
+	u16 base_cpu_number;
+	u16 indirection_table_size;
+	u16 hash_secret_key_size;
+	u32 hash_secret_key[HW_ATL_B0_RSS_HASHKEY_BITS / 8];
+	u8 indirection_table[HW_ATL_B0_RSS_REDIRECTION_MAX];
+};
+
 struct aq_hw_cfg_s {
 	bool is_lro;
+	bool is_rss;
+	unsigned int num_rss_queues;
 	int wol;
 
 	int link_speed_msk;
@@ -60,6 +71,8 @@ struct aq_hw_cfg_s {
 	unsigned int vecs;
 
 	uint32_t flow_control;
+
+	struct aq_rss_parameters aq_rss;
 };
 
 struct aq_hw_s {
drivers/net/atlantic/hw_atl/hw_atl_b0.c new file +510 -0

510 lines not on this page · raw message

drivers/net/atlantic/hw_atl/hw_atl_b0.h new file +40 -0
new file mode 100644
index 000000000000..06feb56c1620
@@ -0,0 +1,40 @@
+/* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0) */
+/* Copyright (C) 2014-2017 aQuantia Corporation. */
+
+/* File hw_atl_b0.h: Declaration of abstract interface for Atlantic hardware
+ * specific functions.
+ */
+
+#ifndef HW_ATL_B0_H
+#define HW_ATL_B0_H
+
+int hw_atl_b0_hw_reset(struct aq_hw_s *self);
+int hw_atl_b0_hw_init(struct aq_hw_s *self, u8 *mac_addr);
+
+int hw_atl_b0_hw_ring_tx_init(struct aq_hw_s *self, uint64_t base_addr,
+		int index, int size, int cpu, int vec);
+int hw_atl_b0_hw_ring_rx_init(struct aq_hw_s *self, uint64_t base_addr,
+		int index, int size, int buff_size, int cpu, int vec);
+
+int hw_atl_b0_hw_start(struct aq_hw_s *self);
+
+int hw_atl_b0_hw_ring_rx_start(struct aq_hw_s *self, int index);
+int hw_atl_b0_hw_ring_tx_start(struct aq_hw_s *self, int index);
+
+
+int hw_atl_b0_hw_ring_tx_stop(struct aq_hw_s *self, int index);
+int hw_atl_b0_hw_ring_rx_stop(struct aq_hw_s *self, int index);
+
+
+int hw_atl_b0_hw_tx_ring_tail_update(struct aq_hw_s *self, int tail, int index);
+
+int hw_atl_b0_hw_rss_hash_set(struct aq_hw_s *self,
+				     struct aq_rss_parameters *rss_params);
+int hw_atl_b0_hw_rss_set(struct aq_hw_s *self,
+				struct aq_rss_parameters *rss_params);
+
+int hw_atl_b0_hw_irq_enable(struct aq_hw_s *self, u64 mask);
+int hw_atl_b0_hw_irq_disable(struct aq_hw_s *self, u64 mask);
+int hw_atl_b0_hw_irq_read(struct aq_hw_s *self, u64 *mask);
+
+#endif /* HW_ATL_B0_H */
drivers/net/atlantic/hw_atl/hw_atl_b0_internal.h new file +145 -0

145 lines not on this page · raw message

drivers/net/atlantic/meson.build +1 -0
index b05c97773541..a0ad8f088571 100644
@@ -4,6 +4,7 @@
 sources = files(
 	'atl_ethdev.c',
 	'atl_hw_regs.c',
+	'hw_atl/hw_atl_b0.c',
 	'hw_atl/hw_atl_llh.c',
 	'hw_atl/hw_atl_utils_fw2x.c',
 	'hw_atl/hw_atl_utils.c',
Signature · 1 line
2.7.4
#10 lore raw

PATCH v4 7/22 net/atlantic: rte device start, stop, initial configuration

In reply to Igor Russkikh

From: Pavel Belous <[email protected]>

Start, stop and reset are all done via hw_atl layer. Link interrupt configuration is also done here.

---
 drivers/net/atlantic/atl_ethdev.c | 158 ++++++++++++++++++++++++++++++++++++--
 drivers/net/atlantic/atl_ethdev.h |   9 +++
 drivers/net/atlantic/atl_types.h  |   4 +
 3 files changed, 164 insertions(+), 7 deletions(-)
drivers/net/atlantic/atl_ethdev.c +151 -7
index 2e0331d987c3..a28e10af9781 100644
@@ -6,6 +6,11 @@
 
 #include "atl_ethdev.h"
 #include "atl_common.h"
+#include "atl_hw_regs.h"
+#include "atl_logs.h"
+#include "hw_atl/hw_atl_llh.h"
+#include "hw_atl/hw_atl_b0.h"
+#include "hw_atl/hw_atl_b0_internal.h"
 
 static int eth_atl_dev_init(struct rte_eth_dev *eth_dev);
 static int eth_atl_dev_uninit(struct rte_eth_dev *eth_dev);
@@ -16,6 +21,13 @@ static void atl_dev_stop(struct rte_eth_dev *dev);
 static void atl_dev_close(struct rte_eth_dev *dev);
 static int  atl_dev_reset(struct rte_eth_dev *dev);
 
+static int atl_fw_version_get(struct rte_eth_dev *dev, char *fw_version,
+			      size_t fw_size);
+
+static void atl_dev_info_get(struct rte_eth_dev *dev,
+			       struct rte_eth_dev_info *dev_info);
+
+
 static int eth_atl_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 	struct rte_pci_device *pci_dev);
 static int eth_atl_pci_remove(struct rte_pci_device *pci_dev);
@@ -69,26 +81,99 @@ static const struct eth_dev_ops atl_eth_dev_ops = {
 	.dev_stop	      = atl_dev_stop,
 	.dev_close	      = atl_dev_close,
 	.dev_reset	      = atl_dev_reset,
-	.dev_infos_get        = atl_dev_info_get,
+
+	.fw_version_get       = atl_fw_version_get,
+	.dev_infos_get	      = atl_dev_info_get,
 };
 
+static inline int32_t
+atl_reset_hw(struct aq_hw_s *hw)
+{
+	return hw_atl_b0_hw_reset(hw);
+}
+
+static void
+atl_print_adapter_info(struct aq_hw_s *hw __rte_unused)
+{
+	PMD_INIT_LOG(DEBUG, "FW version: %u.%u.%u",
+			hw->fw_ver_actual >> 24,
+			(hw->fw_ver_actual >> 16) & 0xFF,
+			hw->fw_ver_actual & 0xFFFF);
+	PMD_INIT_LOG(DEBUG, "Driver version: %s", ATL_PMD_DRIVER_VERSION);
+}
+
 static int
 eth_atl_dev_init(struct rte_eth_dev *eth_dev)
 {
+	struct atl_adapter *adapter =
+		(struct atl_adapter *)eth_dev->data->dev_private;
+	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
+	struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
+	int err = 0;
+
+	PMD_INIT_FUNC_TRACE();
+
 	eth_dev->dev_ops = &atl_eth_dev_ops;
 
+	/* For secondary processes, the primary process has done all the work */
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+		return 0;
+
+	rte_eth_copy_pci_info(eth_dev, pci_dev);
+
+	/* Vendor and Device ID need to be set before init of shared code */
+	hw->device_id = pci_dev->id.device_id;
+	hw->vendor_id = pci_dev->id.vendor_id;
+	hw->mmio = (void *)pci_dev->mem_resource[0].addr;
+
+	/* Hardware configuration - hardcode */
+	adapter->hw_cfg.is_lro = false;
+	adapter->hw_cfg.wol = false;
+
+	hw->aq_nic_cfg = &adapter->hw_cfg;
+
 	/* Allocate memory for storing MAC addresses */
 	eth_dev->data->mac_addrs = rte_zmalloc("atlantic", ETHER_ADDR_LEN, 0);
-	if (eth_dev->data->mac_addrs == NULL)
+	if (eth_dev->data->mac_addrs == NULL) {
+		PMD_INIT_LOG(ERR, "MAC Malloc failed");
 		return -ENOMEM;
+	}
 
-	return 0;
+	err = hw_atl_utils_initfw(hw, &hw->aq_fw_ops);
+	if (err)
+		return err;
+
+	/* Copy the permanent MAC address */
+	if (hw->aq_fw_ops->get_mac_permanent(hw,
+			(u8 *)&eth_dev->data->mac_addrs[0]) != 0)
+		return -EINVAL;
+
+	return err;
 }
 
 static int
 eth_atl_dev_uninit(struct rte_eth_dev *eth_dev)
 {
+	struct aq_hw_s *hw;
+
+	PMD_INIT_FUNC_TRACE();
+
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+		return -EPERM;
+
+	hw = ATL_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
+
+	if (hw->adapter_stopped == 0)
+		atl_dev_close(eth_dev);
+
+	eth_dev->dev_ops = NULL;
+
 	rte_free(eth_dev->data->mac_addrs);
+	eth_dev->data->mac_addrs = NULL;
+
+#ifdef RTE_LIBRTE_SECURITY
+	rte_free(eth_dev->security_ctx);
+#endif
 
 	return 0;
 }
@@ -118,25 +203,62 @@ atl_dev_configure(struct rte_eth_dev *dev __rte_unused)
  * It returns 0 on success.
  */
 static int
-atl_dev_start(struct rte_eth_dev *dev __rte_unused)
+atl_dev_start(struct rte_eth_dev *dev)
 {
-	return 0;
+	struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	int status;
+	int err;
+
+	PMD_INIT_FUNC_TRACE();
+
+	/* stop adapter */
+	hw->adapter_stopped = 0;
+
+	/* reinitialize adapter
+	 * this calls reset and start
+	 */
+	status = atl_reset_hw(hw);
+	if (status != 0)
+		return -1;
+
+	err = hw_atl_b0_hw_init(hw, (uint8_t *)dev->data->mac_addrs);
+
+	hw_atl_b0_hw_start(hw);
+
+	atl_print_adapter_info(hw);
+
+	return err;
 }
 
 /*
  * Stop device: disable rx and tx functions to allow for reconfiguring.
  */
 static void
-atl_dev_stop(struct rte_eth_dev *dev __rte_unused)
+atl_dev_stop(struct rte_eth_dev *dev)
 {
+	struct aq_hw_s *hw =
+		ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+	/* reset the NIC */
+	atl_reset_hw(hw);
+	hw->adapter_stopped = 0;
+
 }
 
 /*
  * Reset and stop device.
  */
 static void
-atl_dev_close(struct rte_eth_dev *dev __rte_unused)
+atl_dev_close(struct rte_eth_dev *dev)
 {
+	struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+	PMD_INIT_FUNC_TRACE();
+
+	atl_reset_hw(hw);
+
+	atl_dev_stop(dev);
+	hw->adapter_stopped = 1;
 }
 
 static int
@@ -153,6 +275,28 @@ atl_dev_reset(struct rte_eth_dev *dev)
 	return ret;
 }
 
+static int
+atl_fw_version_get(struct rte_eth_dev *dev, char *fw_version, size_t fw_size)
+{
+	struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	uint32_t fw_ver = 0;
+	unsigned int ret = 0;
+
+	ret = hw_atl_utils_get_fw_version(hw, &fw_ver);
+	if (ret)
+		return 0;
+
+	ret = snprintf(fw_version, fw_size, "%u.%u.%u", fw_ver >> 24,
+		       (fw_ver >> 16) & 0xFFU, fw_ver & 0xFFFFU);
+
+	ret += 1; /* add string null-terminator */
+
+	if (fw_size < ret)
+		return ret;
+
+	return 0;
+}
+
 static void
 atl_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 {
drivers/net/atlantic/atl_ethdev.h +9 -0
index 622806837379..c0cc5475a091 100644
@@ -6,10 +6,19 @@
 #define _ATLANTIC_ETHDEV_H_
 #include <rte_errno.h>
 #include "rte_ethdev.h"
+
+#include "atl_types.h"
+#include "hw_atl/hw_atl_utils.h"
+
+#define ATL_DEV_PRIVATE_TO_HW(adapter) \
+	(&((struct atl_adapter *)adapter)->hw)
+
 /*
  * Structure to store private data for each driver instance (for each port).
  */
 struct atl_adapter {
+	struct aq_hw_s             hw;
+	struct aq_hw_cfg_s         hw_cfg;
 };
 
 #endif /* _ATLANTIC_ETHDEV_H_ */
drivers/net/atlantic/atl_types.h +4 -0
index c9ebbf4e91d8..37ad43a110f0 100644
@@ -76,6 +76,10 @@ struct aq_hw_cfg_s {
 };
 
 struct aq_hw_s {
+	u16 device_id;
+	u16 vendor_id;
+	bool adapter_stopped;
+
 	u8 rbl_enabled:1;
 	struct aq_hw_cfg_s *aq_nic_cfg;
 	const struct aq_fw_ops *aq_fw_ops;
Signature · 1 line
2.7.4
#12 lore raw

PATCH v4 8/22 net/atlantic: TX/RX function prototypes

In reply to Igor Russkikh

From: Pavel Belous <[email protected]>

---
 drivers/net/atlantic/Makefile     |  1 +
 drivers/net/atlantic/atl_ethdev.c | 20 ++++++++++++++++++-
 drivers/net/atlantic/atl_ethdev.h | 15 ++++++++++++++
 drivers/net/atlantic/atl_rxtx.c   | 42 +++++++++++++++++++++++++++++++++++++++
 drivers/net/atlantic/meson.build  |  1 +
 5 files changed, 78 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/atlantic/atl_rxtx.c
drivers/net/atlantic/Makefile +1 -0
index 91306d71ba97..b88da362146d 100644
@@ -24,6 +24,7 @@ VPATH += $(SRCDIR)/hw_atl
 #
 # all source are stored in SRCS-y
 #
+SRCS-$(CONFIG_RTE_LIBRTE_ATLANTIC_PMD) += atl_rxtx.c
 SRCS-$(CONFIG_RTE_LIBRTE_ATLANTIC_PMD) += atl_ethdev.c
 SRCS-$(CONFIG_RTE_LIBRTE_ATLANTIC_PMD) += atl_hw_regs.c
 SRCS-$(CONFIG_RTE_LIBRTE_ATLANTIC_PMD) += hw_atl_utils.c
drivers/net/atlantic/atl_ethdev.c +19 -1
index a28e10af9781..3f7a3d23d6bb 100644
@@ -114,6 +114,9 @@ eth_atl_dev_init(struct rte_eth_dev *eth_dev)
 	PMD_INIT_FUNC_TRACE();
 
 	eth_dev->dev_ops = &atl_eth_dev_ops;
+	eth_dev->rx_pkt_burst = &atl_recv_pkts;
+	eth_dev->tx_pkt_burst = &atl_xmit_pkts;
+	eth_dev->tx_pkt_prepare = &atl_prep_pkts;
 
 	/* For secondary processes, the primary process has done all the work */
 	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
@@ -167,6 +170,8 @@ eth_atl_dev_uninit(struct rte_eth_dev *eth_dev)
 		atl_dev_close(eth_dev);
 
 	eth_dev->dev_ops = NULL;
+	eth_dev->rx_pkt_burst = NULL;
+	eth_dev->tx_pkt_burst = NULL;
 
 	rte_free(eth_dev->data->mac_addrs);
 	eth_dev->data->mac_addrs = NULL;
@@ -224,10 +229,23 @@ atl_dev_start(struct rte_eth_dev *dev)
 	err = hw_atl_b0_hw_init(hw, (uint8_t *)dev->data->mac_addrs);
 
 	hw_atl_b0_hw_start(hw);
+	/* initialize transmission unit */
+	atl_tx_init(dev);
+
+	/* This can fail when allocating mbufs for descriptor rings */
+	err = atl_rx_init(dev);
+	if (err) {
+		PMD_INIT_LOG(ERR, "Unable to initialize RX hardware");
+		goto error;
+	}
 
 	atl_print_adapter_info(hw);
 
-	return err;
+	return 0;
+
+error:
+	PMD_INIT_LOG(ERR, "failure in atl_dev_start(): %d", err);
+	return -EIO;
 }
 
 /*
drivers/net/atlantic/atl_ethdev.h +15 -0
index c0cc5475a091..990e8e4e9978 100644
@@ -21,4 +21,19 @@ struct atl_adapter {
 	struct aq_hw_cfg_s         hw_cfg;
 };
 
+/*
+ * RX/TX function prototypes
+ */
+int atl_rx_init(struct rte_eth_dev *dev);
+int atl_tx_init(struct rte_eth_dev *dev);
+
+uint16_t atl_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
+		uint16_t nb_pkts);
+
+uint16_t atl_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
+		uint16_t nb_pkts);
+
+uint16_t atl_prep_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
+		uint16_t nb_pkts);
+
 #endif /* _ATLANTIC_ETHDEV_H_ */
drivers/net/atlantic/atl_rxtx.c new file +42 -0

42 lines not on this page · raw message

drivers/net/atlantic/meson.build +1 -0
index a0ad8f088571..28fb97cace6e 100644
@@ -2,6 +2,7 @@
 # Copyright(c) 2018 Aquantia Corporation
 
 sources = files(
+	'atl_rxtx.c',
 	'atl_ethdev.c',
 	'atl_hw_regs.c',
 	'hw_atl/hw_atl_b0.c',
Signature · 1 line
2.7.4
#13 lore raw

PATCH v4 9/22 net/atlantic: RX side structures and implementation

In reply to Igor Russkikh
---
 drivers/net/atlantic/Makefile     |   2 +-
 drivers/net/atlantic/atl_ethdev.c |  72 ++++-
 drivers/net/atlantic/atl_ethdev.h |  19 ++
 drivers/net/atlantic/atl_rxtx.c   | 622 +++++++++++++++++++++++++++++++++++++-
 4 files changed, 707 insertions(+), 8 deletions(-)
drivers/net/atlantic/Makefile +1 -1
index b88da362146d..62dcdbffa69c 100644
@@ -15,7 +15,7 @@ EXPORT_MAP := rte_pmd_atlantic_version.map
 
 LIBABIVER := 1
 
-LDLIBS += -lrte_eal
+LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -lrte_ring
 LDLIBS += -lrte_ethdev -lrte_net
 LDLIBS += -lrte_bus_pci
 
drivers/net/atlantic/atl_ethdev.c +70 -2

126 lines not on this page · raw message

drivers/net/atlantic/atl_ethdev.h +19 -0
index 990e8e4e9978..a9a9fc8fe7ff 100644
@@ -13,6 +13,10 @@
 #define ATL_DEV_PRIVATE_TO_HW(adapter) \
 	(&((struct atl_adapter *)adapter)->hw)
 
+#define ATL_DEV_TO_ADAPTER(dev) \
+	((struct atl_adapter *)(dev)->data->dev_private)
+
+
 /*
  * Structure to store private data for each driver instance (for each port).
  */
@@ -24,9 +28,24 @@ struct atl_adapter {
 /*
  * RX/TX function prototypes
  */
+void atl_rx_queue_release(void *rxq);
+
+int atl_rx_queue_setup(struct rte_eth_dev *dev, uint16_t rx_queue_id,
+		uint16_t nb_rx_desc, unsigned int socket_id,
+		const struct rte_eth_rxconf *rx_conf,
+		struct rte_mempool *mb_pool);
+
 int atl_rx_init(struct rte_eth_dev *dev);
 int atl_tx_init(struct rte_eth_dev *dev);
 
+int atl_start_queues(struct rte_eth_dev *dev);
+int atl_stop_queues(struct rte_eth_dev *dev);
+void atl_free_queues(struct rte_eth_dev *dev);
+
+int atl_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id);
+int atl_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id);
+
+
 uint16_t atl_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 		uint16_t nb_pkts);
 
drivers/net/atlantic/atl_rxtx.c +617 -5

649 lines not on this page · raw message

Signature · 1 line
2.7.4
#15 lore raw

PATCH v4 10/22 net/atlantic: TX side structures and implementation

In reply to Igor Russkikh

From: Pavel Belous <[email protected]>

---
 drivers/net/atlantic/atl_ethdev.c |  28 ++
 drivers/net/atlantic/atl_ethdev.h |   7 +
 drivers/net/atlantic/atl_rxtx.c   | 536 +++++++++++++++++++++++++++++++++++++-
 3 files changed, 562 insertions(+), 9 deletions(-)
drivers/net/atlantic/atl_ethdev.c +28 -0
index 53f687b5f748..7bd64a08dd1d 100644
@@ -82,12 +82,27 @@ static struct rte_pci_driver rte_atl_pmd = {
 			| DEV_RX_OFFLOAD_TCP_CKSUM \
 			| DEV_RX_OFFLOAD_JUMBO_FRAME)
 
+#define ATL_TX_OFFLOADS (DEV_TX_OFFLOAD_VLAN_INSERT \
+			| DEV_TX_OFFLOAD_IPV4_CKSUM \
+			| DEV_TX_OFFLOAD_UDP_CKSUM \
+			| DEV_TX_OFFLOAD_TCP_CKSUM \
+			| DEV_TX_OFFLOAD_TCP_TSO \
+			| DEV_TX_OFFLOAD_MULTI_SEGS)
+
 static const struct rte_eth_desc_lim rx_desc_lim = {
 	.nb_max = ATL_MAX_RING_DESC,
 	.nb_min = ATL_MIN_RING_DESC,
 	.nb_align = ATL_RXD_ALIGN,
 };
 
+static const struct rte_eth_desc_lim tx_desc_lim = {
+	.nb_max = ATL_MAX_RING_DESC,
+	.nb_min = ATL_MIN_RING_DESC,
+	.nb_align = ATL_TXD_ALIGN,
+	.nb_seg_max = ATL_TX_MAX_SEG,
+	.nb_mtu_seg_max = ATL_TX_MAX_SEG,
+};
+
 static const struct eth_dev_ops atl_eth_dev_ops = {
 	.dev_configure	      = atl_dev_configure,
 	.dev_start	      = atl_dev_start,
@@ -104,6 +119,11 @@ static const struct eth_dev_ops atl_eth_dev_ops = {
 	.rx_queue_stop	      = atl_rx_queue_stop,
 	.rx_queue_setup       = atl_rx_queue_setup,
 	.rx_queue_release     = atl_rx_queue_release,
+
+	.tx_queue_start	      = atl_tx_queue_start,
+	.tx_queue_stop	      = atl_tx_queue_stop,
+	.tx_queue_setup       = atl_tx_queue_setup,
+	.tx_queue_release     = atl_tx_queue_release,
 };
 
 static inline int32_t
@@ -369,11 +389,19 @@ atl_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 
 	dev_info->rx_offload_capa = ATL_RX_OFFLOADS;
 
+	dev_info->tx_offload_capa = ATL_TX_OFFLOADS;
+
+
 	dev_info->default_rxconf = (struct rte_eth_rxconf) {
 		.rx_free_thresh = ATL_DEFAULT_RX_FREE_THRESH,
 	};
 
+	dev_info->default_txconf = (struct rte_eth_txconf) {
+		.tx_free_thresh = ATL_DEFAULT_TX_FREE_THRESH,
+	};
+
 	dev_info->rx_desc_lim = rx_desc_lim;
+	dev_info->tx_desc_lim = tx_desc_lim;
 }
 
 static const uint32_t *
drivers/net/atlantic/atl_ethdev.h +7 -0
index a9a9fc8fe7ff..92bb302ffe55 100644
@@ -29,12 +29,17 @@ struct atl_adapter {
  * RX/TX function prototypes
  */
 void atl_rx_queue_release(void *rxq);
+void atl_tx_queue_release(void *txq);
 
 int atl_rx_queue_setup(struct rte_eth_dev *dev, uint16_t rx_queue_id,
 		uint16_t nb_rx_desc, unsigned int socket_id,
 		const struct rte_eth_rxconf *rx_conf,
 		struct rte_mempool *mb_pool);
 
+int atl_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
+		uint16_t nb_tx_desc, unsigned int socket_id,
+		const struct rte_eth_txconf *tx_conf);
+
 int atl_rx_init(struct rte_eth_dev *dev);
 int atl_tx_init(struct rte_eth_dev *dev);
 
@@ -45,6 +50,8 @@ void atl_free_queues(struct rte_eth_dev *dev);
 int atl_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id);
 int atl_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id);
 
+int atl_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id);
+int atl_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id);
 
 uint16_t atl_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 		uint16_t nb_pkts);
drivers/net/atlantic/atl_rxtx.c +527 -9

615 lines not on this page · raw message

Signature · 1 line
2.7.4
#16 lore raw

PATCH v4 11/22 net/atlantic: link status and interrupt management

In reply to Igor Russkikh

From: Pavel Belous <[email protected]>

Implement link interrupt, link info, link polling.

---
 drivers/net/atlantic/atl_ethdev.c | 463 +++++++++++++++++++++++++++++++++++++-
 drivers/net/atlantic/atl_ethdev.h |  16 ++
 drivers/net/atlantic/atl_rxtx.c   |  36 +++
 drivers/net/atlantic/atl_types.h  |   2 +
 4 files changed, 515 insertions(+), 2 deletions(-)
drivers/net/atlantic/atl_ethdev.c +461 -2
index 7bd64a08dd1d..89e23be50ec9 100644
@@ -18,8 +18,11 @@ static int eth_atl_dev_uninit(struct rte_eth_dev *eth_dev);
 static int  atl_dev_configure(struct rte_eth_dev *dev);
 static int  atl_dev_start(struct rte_eth_dev *dev);
 static void atl_dev_stop(struct rte_eth_dev *dev);
+static int  atl_dev_set_link_up(struct rte_eth_dev *dev);
+static int  atl_dev_set_link_down(struct rte_eth_dev *dev);
 static void atl_dev_close(struct rte_eth_dev *dev);
 static int  atl_dev_reset(struct rte_eth_dev *dev);
+static int  atl_dev_link_update(struct rte_eth_dev *dev, int wait);
 
 static int atl_fw_version_get(struct rte_eth_dev *dev, char *fw_version,
 			      size_t fw_size);
@@ -29,6 +32,16 @@ static void atl_dev_info_get(struct rte_eth_dev *dev,
 
 static const uint32_t *atl_dev_supported_ptypes_get(struct rte_eth_dev *dev);
 
+static void atl_dev_link_status_print(struct rte_eth_dev *dev);
+
+/* Interrupts */
+static int atl_dev_rxq_interrupt_setup(struct rte_eth_dev *dev);
+static int atl_dev_lsc_interrupt_setup(struct rte_eth_dev *dev, uint8_t on);
+static int atl_dev_interrupt_get_status(struct rte_eth_dev *dev);
+static int atl_dev_interrupt_action(struct rte_eth_dev *dev,
+				    struct rte_intr_handle *handle);
+static void atl_dev_interrupt_handler(void *param);
+
 static int eth_atl_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 	struct rte_pci_device *pci_dev);
 static int eth_atl_pci_remove(struct rte_pci_device *pci_dev);
@@ -70,7 +83,7 @@ static const struct rte_pci_id pci_id_atl_map[] = {
 
 static struct rte_pci_driver rte_atl_pmd = {
 	.id_table = pci_id_atl_map,
-	.drv_flags = RTE_PCI_DRV_NEED_MAPPING |
+	.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC |
 		     RTE_PCI_DRV_IOVA_AS_VA,
 	.probe = eth_atl_pci_probe,
 	.remove = eth_atl_pci_remove,
@@ -107,9 +120,14 @@ static const struct eth_dev_ops atl_eth_dev_ops = {
 	.dev_configure	      = atl_dev_configure,
 	.dev_start	      = atl_dev_start,
 	.dev_stop	      = atl_dev_stop,
+	.dev_set_link_up      = atl_dev_set_link_up,
+	.dev_set_link_down    = atl_dev_set_link_down,
 	.dev_close	      = atl_dev_close,
 	.dev_reset	      = atl_dev_reset,
 
+	/* Link */
+	.link_update	      = atl_dev_link_update,
+
 	.fw_version_get       = atl_fw_version_get,
 	.dev_infos_get	      = atl_dev_info_get,
 	.dev_supported_ptypes_get = atl_dev_supported_ptypes_get,
@@ -124,14 +142,85 @@ static const struct eth_dev_ops atl_eth_dev_ops = {
 	.tx_queue_stop	      = atl_tx_queue_stop,
 	.tx_queue_setup       = atl_tx_queue_setup,
 	.tx_queue_release     = atl_tx_queue_release,
+
+	.rx_queue_intr_enable = atl_dev_rx_queue_intr_enable,
+	.rx_queue_intr_disable = atl_dev_rx_queue_intr_disable,
 };
 
+
+/**
+ * Atomically reads the link status information from global
+ * structure rte_eth_dev.
+ *
+ * @param dev
+ *   - Pointer to the structure rte_eth_dev to read from.
+ *   - Pointer to the buffer to be saved with the link status.
+ *
+ * @return
+ *   - On success, zero.
+ *   - On failure, negative value.
+ */
+static inline int
+rte_atl_dev_atomic_read_link_status(struct rte_eth_dev *dev,
+				struct rte_eth_link *link)
+{
+	struct rte_eth_link *dst = link;
+	struct rte_eth_link *src = &dev->data->dev_link;
+
+	if (rte_atomic64_cmpset((uint64_t *)dst, *(uint64_t *)dst,
+					*(uint64_t *)src) == 0)
+		return -1;
+
+	return 0;
+}
+
+/**
+ * Atomically writes the link status information into global
+ * structure rte_eth_dev.
+ *
+ * @param dev
+ *   - Pointer to the structure rte_eth_dev to read from.
+ *   - Pointer to the buffer to be saved with the link status.
+ *
+ * @return
+ *   - On success, zero.
+ *   - On failure, negative value.
+ */
+static inline int
+rte_atl_dev_atomic_write_link_status(struct rte_eth_dev *dev,
+				struct rte_eth_link *link)
+{
+	struct rte_eth_link *dst = &dev->data->dev_link;
+	struct rte_eth_link *src = link;
+
+	if (rte_atomic64_cmpset((uint64_t *)dst, *(uint64_t *)dst,
+					*(uint64_t *)src) == 0)
+		return -1;
+
+	return 0;
+}
+
 static inline int32_t
 atl_reset_hw(struct aq_hw_s *hw)
 {
 	return hw_atl_b0_hw_reset(hw);
 }
 
+static inline void
+atl_enable_intr(struct rte_eth_dev *dev)
+{
+	struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+	hw_atl_itr_irq_msk_setlsw_set(hw, 0xffffffff);
+}
+
+static void
+atl_disable_intr(struct aq_hw_s *hw)
+{
+	PMD_INIT_FUNC_TRACE();
+	hw_atl_itr_irq_msk_clearlsw_set(hw, 0xffffffff);
+}
+
 static void
 atl_print_adapter_info(struct aq_hw_s *hw __rte_unused)
 {
@@ -148,6 +237,7 @@ eth_atl_dev_init(struct rte_eth_dev *eth_dev)
 	struct atl_adapter *adapter =
 		(struct atl_adapter *)eth_dev->data->dev_private;
 	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
+	struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
 	struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
 	int err = 0;
 
@@ -172,9 +262,17 @@ eth_atl_dev_init(struct rte_eth_dev *eth_dev)
 	/* Hardware configuration - hardcode */
 	adapter->hw_cfg.is_lro = false;
 	adapter->hw_cfg.wol = false;
+	adapter->hw_cfg.link_speed_msk = AQ_NIC_RATE_10G |
+			  AQ_NIC_RATE_5G |
+			  AQ_NIC_RATE_2G5 |
+			  AQ_NIC_RATE_1G |
+			  AQ_NIC_RATE_100M;
 
 	hw->aq_nic_cfg = &adapter->hw_cfg;
 
+	/* disable interrupt */
+	atl_disable_intr(hw);
+
 	/* Allocate memory for storing MAC addresses */
 	eth_dev->data->mac_addrs = rte_zmalloc("atlantic", ETHER_ADDR_LEN, 0);
 	if (eth_dev->data->mac_addrs == NULL) {
@@ -191,12 +289,23 @@ eth_atl_dev_init(struct rte_eth_dev *eth_dev)
 			(u8 *)&eth_dev->data->mac_addrs[0]) != 0)
 		return -EINVAL;
 
+	rte_intr_callback_register(intr_handle,
+				   atl_dev_interrupt_handler, eth_dev);
+
+	/* enable uio/vfio intr/eventfd mapping */
+	rte_intr_enable(intr_handle);
+
+	/* enable support intr */
+	atl_enable_intr(eth_dev);
+
 	return err;
 }
 
 static int
 eth_atl_dev_uninit(struct rte_eth_dev *eth_dev)
 {
+	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
+	struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
 	struct aq_hw_s *hw;
 
 	PMD_INIT_FUNC_TRACE();
@@ -213,6 +322,11 @@ eth_atl_dev_uninit(struct rte_eth_dev *eth_dev)
 	eth_dev->rx_pkt_burst = NULL;
 	eth_dev->tx_pkt_burst = NULL;
 
+	/* disable uio intr before callback unregister */
+	rte_intr_disable(intr_handle);
+	rte_intr_callback_unregister(intr_handle,
+				     atl_dev_interrupt_handler, eth_dev);
+
 	rte_free(eth_dev->data->mac_addrs);
 	eth_dev->data->mac_addrs = NULL;
 
@@ -238,8 +352,16 @@ eth_atl_pci_remove(struct rte_pci_device *pci_dev)
 }
 
 static int
-atl_dev_configure(struct rte_eth_dev *dev __rte_unused)
+atl_dev_configure(struct rte_eth_dev *dev)
 {
+	struct atl_interrupt *intr =
+		ATL_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
+
+	PMD_INIT_FUNC_TRACE();
+
+	/* set flag to update link status after init */
+	intr->flags |= ATL_FLAG_NEED_LINK_UPDATE;
+
 	return 0;
 }
 
@@ -251,11 +373,26 @@ static int
 atl_dev_start(struct rte_eth_dev *dev)
 {
 	struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
+	struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
+	uint32_t intr_vector = 0;
+	uint32_t *link_speeds;
+	uint32_t speed = 0;
 	int status;
 	int err;
 
 	PMD_INIT_FUNC_TRACE();
 
+	if (dev->data->dev_conf.link_speeds & ETH_LINK_SPEED_FIXED) {
+		PMD_INIT_LOG(ERR,
+		"Invalid link_speeds for port %u, fix speed not supported",
+				dev->data->port_id);
+		return -EINVAL;
+	}
+
+	/* disable uio/vfio intr/eventfd mapping */
+	rte_intr_disable(intr_handle);
+
 	/* stop adapter */
 	hw->adapter_stopped = 0;
 
@@ -269,6 +406,32 @@ atl_dev_start(struct rte_eth_dev *dev)
 	err = hw_atl_b0_hw_init(hw, (uint8_t *)dev->data->mac_addrs);
 
 	hw_atl_b0_hw_start(hw);
+	/* check and configure queue intr-vector mapping */
+	if ((rte_intr_cap_multiple(intr_handle) ||
+	    !RTE_ETH_DEV_SRIOV(dev).active) &&
+	    dev->data->dev_conf.intr_conf.rxq != 0) {
+		intr_vector = dev->data->nb_rx_queues;
+		if (intr_vector > ATL_MAX_INTR_QUEUE_NUM) {
+			PMD_INIT_LOG(ERR, "At most %d intr queues supported",
+					ATL_MAX_INTR_QUEUE_NUM);
+			return -ENOTSUP;
+		}
+		if (rte_intr_efd_enable(intr_handle, intr_vector)) {
+			PMD_INIT_LOG(ERR, "rte_intr_efd_enable failed");
+			return -1;
+		}
+	}
+
+	if (rte_intr_dp_is_en(intr_handle) && !intr_handle->intr_vec) {
+		intr_handle->intr_vec = rte_zmalloc("intr_vec",
+				    dev->data->nb_rx_queues * sizeof(int), 0);
+		if (intr_handle->intr_vec == NULL) {
+			PMD_INIT_LOG(ERR, "Failed to allocate %d rx_queues"
+				     " intr_vec", dev->data->nb_rx_queues);
+			return -ENOMEM;
+		}
+	}
+
 	/* initialize transmission unit */
 	atl_tx_init(dev);
 
@@ -285,6 +448,61 @@ atl_dev_start(struct rte_eth_dev *dev)
 		goto error;
 	}
 
+	err = hw->aq_fw_ops->update_link_status(hw);
+
+	if (err)
+		goto error;
+
+	dev->data->dev_link.link_status = hw->aq_link_status.mbps != 0;
+
+	link_speeds = &dev->data->dev_conf.link_speeds;
+
+	speed = 0x0;
+
+	if (*link_speeds == ETH_LINK_SPEED_AUTONEG) {
+		speed = hw->aq_nic_cfg->link_speed_msk;
+	} else {
+		if (*link_speeds & ETH_LINK_SPEED_10G)
+			speed |= AQ_NIC_RATE_10G;
+		if (*link_speeds & ETH_LINK_SPEED_5G)
+			speed |= AQ_NIC_RATE_5G;
+		if (*link_speeds & ETH_LINK_SPEED_1G)
+			speed |= AQ_NIC_RATE_1G;
+		if (*link_speeds & ETH_LINK_SPEED_2_5G)
+			speed |=  AQ_NIC_RATE_2G5;
+		if (*link_speeds & ETH_LINK_SPEED_100M)
+			speed |= AQ_NIC_RATE_100M;
+	}
+
+	err = hw->aq_fw_ops->set_link_speed(hw, speed);
+	if (err)
+		goto error;
+
+	if (rte_intr_allow_others(intr_handle)) {
+		/* check if lsc interrupt is enabled */
+		if (dev->data->dev_conf.intr_conf.lsc != 0)
+			atl_dev_lsc_interrupt_setup(dev, true);
+		else
+			atl_dev_lsc_interrupt_setup(dev, false);
+	} else {
+		rte_intr_callback_unregister(intr_handle,
+					     atl_dev_interrupt_handler, dev);
+		if (dev->data->dev_conf.intr_conf.lsc != 0)
+			PMD_INIT_LOG(INFO, "lsc won't enable because of"
+				     " no intr multiplex");
+	}
+
+	/* check if rxq interrupt is enabled */
+	if (dev->data->dev_conf.intr_conf.rxq != 0 &&
+	    rte_intr_dp_is_en(intr_handle))
+		atl_dev_rxq_interrupt_setup(dev);
+
+	/* enable uio/vfio intr/eventfd mapping */
+	rte_intr_enable(intr_handle);
+
+	/* resume enabled intr since hw reset */
+	atl_enable_intr(dev);
+
 	atl_print_adapter_info(hw);
 
 	return 0;
@@ -301,8 +519,16 @@ atl_dev_start(struct rte_eth_dev *dev)
 static void
 atl_dev_stop(struct rte_eth_dev *dev)
 {
+	struct rte_eth_link link;
 	struct aq_hw_s *hw =
 		ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
+	struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
+
+	PMD_INIT_FUNC_TRACE();
+
+	/* disable interrupts */
+	atl_disable_intr(hw);
 
 	/* reset the NIC */
 	atl_reset_hw(hw);
@@ -314,6 +540,45 @@ atl_dev_stop(struct rte_eth_dev *dev)
 	dev->data->scattered_rx = 0;
 	dev->data->lro = 0;
 
+	/* Clear recorded link status */
+	memset(&link, 0, sizeof(link));
+	rte_atl_dev_atomic_write_link_status(dev, &link);
+
+	if (!rte_intr_allow_others(intr_handle))
+		/* resume to the default handler */
+		rte_intr_callback_register(intr_handle,
+					   atl_dev_interrupt_handler,
+					   (void *)dev);
+
+	/* Clean datapath event and queue/vec mapping */
+	rte_intr_efd_disable(intr_handle);
+	if (intr_handle->intr_vec != NULL) {
+		rte_free(intr_handle->intr_vec);
+		intr_handle->intr_vec = NULL;
+	}
+}
+
+/*
+ * Set device link up: enable tx.
+ */
+static int
+atl_dev_set_link_up(struct rte_eth_dev *dev)
+{
+	struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+	return hw->aq_fw_ops->set_link_speed(hw,
+			hw->aq_nic_cfg->link_speed_msk);
+}
+
+/*
+ * Set device link down: disable tx.
+ */
+static int
+atl_dev_set_link_down(struct rte_eth_dev *dev)
+{
+	struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+	return hw->aq_fw_ops->set_link_speed(hw, 0);
 }
 
 /*
@@ -402,6 +667,11 @@ atl_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 
 	dev_info->rx_desc_lim = rx_desc_lim;
 	dev_info->tx_desc_lim = tx_desc_lim;
+
+	dev_info->speed_capa = ETH_LINK_SPEED_1G | ETH_LINK_SPEED_10G;
+	dev_info->speed_capa |= ETH_LINK_SPEED_100M;
+	dev_info->speed_capa |= ETH_LINK_SPEED_2_5G;
+	dev_info->speed_capa |= ETH_LINK_SPEED_5G;
 }
 
 static const uint32_t *
@@ -426,6 +696,195 @@ atl_dev_supported_ptypes_get(struct rte_eth_dev *dev)
 	return NULL;
 }
 
+/* return 0 means link status changed, -1 means not changed */
+static int
+atl_dev_link_update(struct rte_eth_dev *dev, int wait __rte_unused)
+{
+	struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct atl_interrupt *intr =
+		ATL_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
+	struct rte_eth_link link, old;
+	int err = 0;
+
+	link.link_status = ETH_LINK_DOWN;
+	link.link_speed = 0;
+	link.link_duplex = ETH_LINK_FULL_DUPLEX;
+	link.link_autoneg = hw->is_autoneg ? ETH_LINK_AUTONEG : ETH_LINK_FIXED;
+	memset(&old, 0, sizeof(old));
+
+	/* load old link status */
+	rte_atl_dev_atomic_read_link_status(dev, &old);
+
+	/* read current link status */
+	err = hw->aq_fw_ops->update_link_status(hw);
+
+	if (err)
+		return 0;
+
+	if (hw->aq_link_status.mbps == 0) {
+		/* write default (down) link status */
+		rte_atl_dev_atomic_write_link_status(dev, &link);
+		if (link.link_status == old.link_status)
+			return -1;
+		return 0;
+	}
+
+	intr->flags &= ~ATL_FLAG_NEED_LINK_CONFIG;
+
+	link.link_status = ETH_LINK_UP;
+	link.link_duplex = ETH_LINK_FULL_DUPLEX;
+	link.link_speed = hw->aq_link_status.mbps;
+
+	rte_atl_dev_atomic_write_link_status(dev, &link);
+
+	if (link.link_status == old.link_status)
+		return -1;
+
+	return 0;
+}
+
+
+/**
+ * It clears the interrupt causes and enables the interrupt.
+ * It will be called once only during nic initialized.
+ *
+ * @param dev
+ *  Pointer to struct rte_eth_dev.
+ * @param on
+ *  Enable or Disable.
+ *
+ * @return
+ *  - On success, zero.
+ *  - On failure, a negative value.
+ */
+
+static int
+atl_dev_lsc_interrupt_setup(struct rte_eth_dev *dev, uint8_t on __rte_unused)
+{
+	atl_dev_link_status_print(dev);
+	return 0;
+}
+
+static int
+atl_dev_rxq_interrupt_setup(struct rte_eth_dev *dev __rte_unused)
+{
+	return 0;
+}
+
+
+static int
+atl_dev_interrupt_get_status(struct rte_eth_dev *dev)
+{
+	struct atl_interrupt *intr =
+		ATL_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
+	struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	u64 cause = 0;
+
+	hw_atl_b0_hw_irq_read(hw, &cause);
+
+	atl_disable_intr(hw);
+	intr->flags = cause & BIT(ATL_IRQ_CAUSE_LINK) ?
+			ATL_FLAG_NEED_LINK_UPDATE : 0;
+
+	return 0;
+}
+
+/**
+ * It gets and then prints the link status.
+ *
+ * @param dev
+ *  Pointer to struct rte_eth_dev.
+ *
+ * @return
+ *  - On success, zero.
+ *  - On failure, a negative value.
+ */
+static void
+atl_dev_link_status_print(struct rte_eth_dev *dev)
+{
+	struct rte_eth_link link;
+
+	memset(&link, 0, sizeof(link));
+	rte_atl_dev_atomic_read_link_status(dev, &link);
+	if (link.link_status) {
+		PMD_DRV_LOG(INFO, "Port %d: Link Up - speed %u Mbps - %s",
+					(int)(dev->data->port_id),
+					(unsigned int)link.link_speed,
+			link.link_duplex == ETH_LINK_FULL_DUPLEX ?
+					"full-duplex" : "half-duplex");
+	} else {
+		PMD_DRV_LOG(INFO, " Port %d: Link Down",
+				(int)(dev->data->port_id));
+	}
+
+
+#ifdef DEBUG
+{
+	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
+
+	PMD_DRV_LOG(DEBUG, "PCI Address: " PCI_PRI_FMT,
+				pci_dev->addr.domain,
+				pci_dev->addr.bus,
+				pci_dev->addr.devid,
+				pci_dev->addr.function);
+}
+#endif
+
+	PMD_DRV_LOG(INFO, "Link speed:%d", link.link_speed);
+}
+
+/*
+ * It executes link_update after knowing an interrupt occurred.
+ *
+ * @param dev
+ *  Pointer to struct rte_eth_dev.
+ *
+ * @return
+ *  - On success, zero.
+ *  - On failure, a negative value.
+ */
+static int
+atl_dev_interrupt_action(struct rte_eth_dev *dev,
+			   struct rte_intr_handle *intr_handle)
+{
+	struct atl_interrupt *intr =
+		ATL_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
+
+	if (intr->flags & ATL_FLAG_NEED_LINK_UPDATE) {
+		atl_dev_link_update(dev, 0);
+		intr->flags &= ~ATL_FLAG_NEED_LINK_UPDATE;
+		atl_dev_link_status_print(dev);
+		_rte_eth_dev_callback_process(dev,
+			RTE_ETH_EVENT_INTR_LSC, NULL);
+	}
+
+	atl_enable_intr(dev);
+	rte_intr_enable(intr_handle);
+
+	return 0;
+}
+
+/**
+ * Interrupt handler triggered by NIC  for handling
+ * specific interrupt.
+ *
+ * @param handle
+ *  Pointer to interrupt handle.
+ * @param param
+ *  The address of parameter (struct rte_eth_dev *) regsitered before.
+ *
+ * @return
+ *  void
+ */
+static void
+atl_dev_interrupt_handler(void *param)
+{
+	struct rte_eth_dev *dev = (struct rte_eth_dev *)param;
+
+	atl_dev_interrupt_get_status(dev);
+	atl_dev_interrupt_action(dev, dev->intr_handle);
+}
+
 RTE_PMD_REGISTER_PCI(net_atlantic, rte_atl_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_atlantic, pci_id_atl_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_atlantic, "* igb_uio | uio_pci_generic");
drivers/net/atlantic/atl_ethdev.h +16 -0
index 92bb302ffe55..55a7e0d6188c 100644
@@ -16,6 +16,16 @@
 #define ATL_DEV_TO_ADAPTER(dev) \
 	((struct atl_adapter *)(dev)->data->dev_private)
 
+#define ATL_DEV_PRIVATE_TO_INTR(adapter) \
+	(&((struct atl_adapter *)adapter)->intr)
+
+#define ATL_FLAG_NEED_LINK_UPDATE (uint32_t)(1 << 0)
+#define ATL_FLAG_NEED_LINK_CONFIG (uint32_t)(4 << 0)
+
+struct atl_interrupt {
+	uint32_t flags;
+	uint32_t mask;
+};
 
 /*
  * Structure to store private data for each driver instance (for each port).
@@ -23,6 +33,7 @@
 struct atl_adapter {
 	struct aq_hw_s             hw;
 	struct aq_hw_cfg_s         hw_cfg;
+	struct atl_interrupt       intr;
 };
 
 /*
@@ -40,6 +51,11 @@ int atl_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
 		uint16_t nb_tx_desc, unsigned int socket_id,
 		const struct rte_eth_txconf *tx_conf);
 
+int atl_dev_rx_queue_intr_enable(struct rte_eth_dev *eth_dev,
+				 uint16_t queue_id);
+int atl_dev_rx_queue_intr_disable(struct rte_eth_dev *eth_dev,
+				  uint16_t queue_id);
+
 int atl_rx_init(struct rte_eth_dev *dev);
 int atl_tx_init(struct rte_eth_dev *dev);
 
drivers/net/atlantic/atl_rxtx.c +36 -0
index 4708b32730ef..4bacea198766 100644
@@ -632,6 +632,42 @@ atl_stop_queues(struct rte_eth_dev *dev)
 	return 0;
 }
 
+static int
+atl_rx_enable_intr(struct rte_eth_dev *dev, uint16_t queue_id, bool enable)
+{
+	struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct atl_rx_queue *rxq;
+
+	PMD_INIT_FUNC_TRACE();
+
+	if (queue_id >= dev->data->nb_rx_queues) {
+		PMD_DRV_LOG(ERR, "Invalid RX queue id=%d", queue_id);
+		return -EINVAL;
+	}
+
+	rxq = dev->data->rx_queues[queue_id];
+
+	if (rxq == NULL)
+		return 0;
+
+	/* Mapping interrupt vector */
+	hw_atl_itr_irq_map_en_rx_set(hw, enable, queue_id);
+
+	return 0;
+}
+
+int
+atl_dev_rx_queue_intr_enable(struct rte_eth_dev *eth_dev, uint16_t queue_id)
+{
+	return atl_rx_enable_intr(eth_dev, queue_id, true);
+}
+
+int
+atl_dev_rx_queue_intr_disable(struct rte_eth_dev *eth_dev, uint16_t queue_id)
+{
+	return atl_rx_enable_intr(eth_dev, queue_id, false);
+}
+
 uint16_t
 atl_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts,
 	      uint16_t nb_pkts)
drivers/net/atlantic/atl_types.h +2 -0
index 37ad43a110f0..e636464955e3 100644
@@ -86,11 +86,13 @@ struct aq_hw_s {
 	void *mmio;
 
 	struct aq_hw_link_status_s aq_link_status;
+	bool is_autoneg;
 
 	struct hw_aq_atl_utils_mbox mbox;
 	struct hw_atl_stats_s last_stats;
 	struct aq_stats_s curr_stats;
 
+	u64 speed;
 	unsigned int chip_features;
 	u32 fw_ver_actual;
 	u32 mbox_addr;
Signature · 1 line
2.7.4
#18 lore raw

PATCH v4 12/22 net/atlantic: device statistics, xstats

In reply to Igor Russkikh

From: Pavel Belous <[email protected]>

---
 drivers/net/atlantic/atl_ethdev.c | 154 ++++++++++++++++++++++++++++++++++++++
 drivers/net/atlantic/atl_ethdev.h |   1 +
 drivers/net/atlantic/atl_rxtx.c   |  11 ++-
 drivers/net/atlantic/atl_types.h  |  41 ++++++++++
 4 files changed, 206 insertions(+), 1 deletion(-)
drivers/net/atlantic/atl_ethdev.c +154 -0
index 89e23be50ec9..30a800da0209 100644
@@ -24,6 +24,24 @@ static void atl_dev_close(struct rte_eth_dev *dev);
 static int  atl_dev_reset(struct rte_eth_dev *dev);
 static int  atl_dev_link_update(struct rte_eth_dev *dev, int wait);
 
+static int atl_dev_xstats_get_names(struct rte_eth_dev *dev __rte_unused,
+				    struct rte_eth_xstat_name *xstats_names,
+				    unsigned int size);
+
+static int atl_dev_stats_get(struct rte_eth_dev *dev,
+				struct rte_eth_stats *stats);
+
+static int atl_dev_xstats_get(struct rte_eth_dev *dev,
+			      struct rte_eth_xstat *stats, unsigned int n);
+
+static void atl_dev_stats_reset(struct rte_eth_dev *dev);
+static void atl_dev_xstats_reset(struct rte_eth_dev *dev);
+
+static int atl_dev_queue_stats_mapping_set(struct rte_eth_dev *eth_dev,
+					     uint16_t queue_id,
+					     uint8_t stat_idx,
+					     uint8_t is_rx);
+
 static int atl_fw_version_get(struct rte_eth_dev *dev, char *fw_version,
 			      size_t fw_size);
 
@@ -116,6 +134,33 @@ static const struct rte_eth_desc_lim tx_desc_lim = {
 	.nb_mtu_seg_max = ATL_TX_MAX_SEG,
 };
 
+#define ATL_XSTATS_FIELD(name) { \
+	#name, \
+	offsetof(struct aq_stats_s, name) \
+}
+
+struct atl_xstats_tbl_s {
+	const char *name;
+	unsigned int offset;
+};
+
+static struct atl_xstats_tbl_s atl_xstats_tbl[] = {
+	ATL_XSTATS_FIELD(uprc),
+	ATL_XSTATS_FIELD(mprc),
+	ATL_XSTATS_FIELD(bprc),
+	ATL_XSTATS_FIELD(erpt),
+	ATL_XSTATS_FIELD(uptc),
+	ATL_XSTATS_FIELD(mptc),
+	ATL_XSTATS_FIELD(bptc),
+	ATL_XSTATS_FIELD(erpr),
+	ATL_XSTATS_FIELD(ubrc),
+	ATL_XSTATS_FIELD(ubtc),
+	ATL_XSTATS_FIELD(mbrc),
+	ATL_XSTATS_FIELD(mbtc),
+	ATL_XSTATS_FIELD(bbrc),
+	ATL_XSTATS_FIELD(bbtc),
+};
+
 static const struct eth_dev_ops atl_eth_dev_ops = {
 	.dev_configure	      = atl_dev_configure,
 	.dev_start	      = atl_dev_start,
@@ -128,6 +173,14 @@ static const struct eth_dev_ops atl_eth_dev_ops = {
 	/* Link */
 	.link_update	      = atl_dev_link_update,
 
+	/* Stats */
+	.stats_get	      = atl_dev_stats_get,
+	.xstats_get	      = atl_dev_xstats_get,
+	.xstats_get_names     = atl_dev_xstats_get_names,
+	.stats_reset	      = atl_dev_stats_reset,
+	.xstats_reset	      = atl_dev_xstats_reset,
+	.queue_stats_mapping_set = atl_dev_queue_stats_mapping_set,
+
 	.fw_version_get       = atl_fw_version_get,
 	.dev_infos_get	      = atl_dev_info_get,
 	.dev_supported_ptypes_get = atl_dev_supported_ptypes_get,
@@ -289,6 +342,9 @@ eth_atl_dev_init(struct rte_eth_dev *eth_dev)
 			(u8 *)&eth_dev->data->mac_addrs[0]) != 0)
 		return -EINVAL;
 
+	/* Reset the hw statistics */
+	atl_dev_stats_reset(eth_dev);
+
 	rte_intr_callback_register(intr_handle,
 				   atl_dev_interrupt_handler, eth_dev);
 
@@ -613,6 +669,104 @@ atl_dev_reset(struct rte_eth_dev *dev)
 	return ret;
 }
 
+
+static int
+atl_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
+{
+	struct atl_adapter *adapter =
+		(struct atl_adapter *)dev->data->dev_private;
+	struct aq_hw_s *hw = &adapter->hw;
+	struct atl_sw_stats *swstats = &adapter->sw_stats;
+	unsigned int i;
+
+	hw->aq_fw_ops->update_stats(hw);
+
+	/* Fill out the rte_eth_stats statistics structure */
+	stats->ipackets = hw->curr_stats.dma_pkt_rc;
+	stats->ibytes = hw->curr_stats.dma_oct_rc;
+	stats->imissed = hw->curr_stats.dpc;
+	stats->ierrors = hw->curr_stats.erpt;
+
+	stats->opackets = hw->curr_stats.dma_pkt_tc;
+	stats->obytes = hw->curr_stats.dma_oct_tc;
+	stats->oerrors = 0;
+
+	stats->rx_nombuf = swstats->rx_nombuf;
+
+	for (i = 0; i < RTE_ETHDEV_QUEUE_STAT_CNTRS; i++) {
+		stats->q_ipackets[i] = swstats->q_ipackets[i];
+		stats->q_opackets[i] = swstats->q_opackets[i];
+		stats->q_ibytes[i] = swstats->q_ibytes[i];
+		stats->q_obytes[i] = swstats->q_obytes[i];
+		stats->q_errors[i] = swstats->q_errors[i];
+	}
+	return 0;
+}
+
+static void
+atl_dev_stats_reset(struct rte_eth_dev *dev)
+{
+	struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+	hw->aq_fw_ops->update_stats(hw);
+
+	/* Reset software totals */
+	memset(&hw->curr_stats, 0, sizeof(hw->curr_stats));
+}
+
+static int
+atl_dev_xstats_get_names(struct rte_eth_dev *dev __rte_unused,
+			 struct rte_eth_xstat_name *xstats_names,
+			 unsigned int size)
+{
+	unsigned int i;
+
+	if (!xstats_names)
+		return RTE_DIM(atl_xstats_tbl);
+
+	for (i = 0; i < size && i < RTE_DIM(atl_xstats_tbl); i++)
+		snprintf(xstats_names[i].name, RTE_ETH_XSTATS_NAME_SIZE, "%s",
+			atl_xstats_tbl[i].name);
+
+	return size;
+}
+
+static int
+atl_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *stats,
+		   unsigned int n)
+{
+	struct atl_adapter *adapter =
+		(struct atl_adapter *)dev->data->dev_private;
+	struct aq_hw_s *hw = &adapter->hw;
+	unsigned int i;
+
+	if (!stats)
+		return 0;
+
+	for (i = 0; i < n && i < RTE_DIM(atl_xstats_tbl); i++) {
+		stats[i].id = i;
+		stats[i].value = *(u64 *)((uint8_t *)&hw->curr_stats +
+					atl_xstats_tbl[i].offset);
+	}
+
+	return n;
+}
+
+static void
+atl_dev_xstats_reset(struct rte_eth_dev *dev __rte_unused)
+{
+}
+
+static int
+atl_dev_queue_stats_mapping_set(struct rte_eth_dev *eth_dev __rte_unused,
+					     uint16_t queue_id __rte_unused,
+					     uint8_t stat_idx __rte_unused,
+					     uint8_t is_rx __rte_unused)
+{
+	/* The mapping is hardcoded: queue 0 -> stat 0, etc */
+	return 0;
+}
+
 static int
 atl_fw_version_get(struct rte_eth_dev *dev, char *fw_version, size_t fw_size)
 {
drivers/net/atlantic/atl_ethdev.h +1 -0
index 55a7e0d6188c..dc48c134b7b8 100644
@@ -33,6 +33,7 @@ struct atl_interrupt {
 struct atl_adapter {
 	struct aq_hw_s             hw;
 	struct aq_hw_cfg_s         hw_cfg;
+	struct atl_sw_stats        sw_stats;
 	struct atl_interrupt       intr;
 };
 
drivers/net/atlantic/atl_rxtx.c +10 -1
index 4bacea198766..e9be6d85e647 100644
@@ -855,7 +855,8 @@ atl_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
 				   "queue_id=%u", (unsigned int)rxq->port_id,
 				   (unsigned int)rxq->queue_id);
 				dev->data->rx_mbuf_alloc_failed++;
-						goto err_stop;
+				adapter->sw_stats.rx_nombuf++;
+				goto err_stop;
 			}
 
 			nb_hold++;
@@ -938,6 +939,9 @@ atl_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
 		 * of returned packets.
 		 */
 		rx_pkts[nb_rx++] = rx_mbuf_first;
+		adapter->sw_stats.q_ipackets[rxq->queue_id]++;
+		adapter->sw_stats.q_ibytes[rxq->queue_id] +=
+			rx_mbuf_first->pkt_len;
 
 		PMD_RX_LOG(ERR, "add mbuf segs=%d pkt_len=%d",
 			rx_mbuf_first->nb_segs,
@@ -1083,6 +1087,8 @@ static inline void
 atl_xmit_pkt(struct aq_hw_s *hw, struct atl_tx_queue *txq,
 	     struct rte_mbuf *tx_pkt)
 {
+	struct atl_adapter *adapter =
+		ATL_DEV_TO_ADAPTER(&rte_eth_devices[txq->port_id]);
 	uint32_t pay_len = 0;
 	int tail = 0;
 	struct atl_tx_entry *tx_entry;
@@ -1163,6 +1169,9 @@ atl_xmit_pkt(struct aq_hw_s *hw, struct atl_tx_queue *txq,
 	txq->tx_tail = tail;
 
 	txq->tx_free -= desc_count;
+
+	adapter->sw_stats.q_opackets[txq->queue_id]++;
+	adapter->sw_stats.q_obytes[txq->queue_id] += pay_len;
 }
 
 uint16_t
drivers/net/atlantic/atl_types.h +41 -0

45 lines not on this page · raw message

Signature · 1 line
2.7.4
#20 lore raw

PATCH v4 13/22 net/atlantic: support for RX/TX descriptors information

In reply to Igor Russkikh

From: Pavel Belous <[email protected]>

---
 drivers/net/atlantic/atl_ethdev.c |   8 +++
 drivers/net/atlantic/atl_ethdev.h |  12 ++++
 drivers/net/atlantic/atl_rxtx.c   | 125 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 145 insertions(+)
drivers/net/atlantic/atl_ethdev.c +8 -0
index 30a800da0209..afae232cb22c 100644
@@ -198,6 +198,14 @@ static const struct eth_dev_ops atl_eth_dev_ops = {
 
 	.rx_queue_intr_enable = atl_dev_rx_queue_intr_enable,
 	.rx_queue_intr_disable = atl_dev_rx_queue_intr_disable,
+
+	.rx_queue_count       = atl_rx_queue_count,
+	.rx_descriptor_done   = atl_dev_rx_descriptor_done,
+	.rx_descriptor_status = atl_dev_rx_descriptor_status,
+	.tx_descriptor_status = atl_dev_tx_descriptor_status,
+
+	.rxq_info_get	      = atl_rxq_info_get,
+	.txq_info_get	      = atl_txq_info_get,
 };
 
 
drivers/net/atlantic/atl_ethdev.h +12 -0
index dc48c134b7b8..dbb42140816b 100644
@@ -52,6 +52,12 @@ int atl_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
 		uint16_t nb_tx_desc, unsigned int socket_id,
 		const struct rte_eth_txconf *tx_conf);
 
+uint32_t atl_rx_queue_count(struct rte_eth_dev *dev, uint16_t rx_queue_id);
+
+int atl_dev_rx_descriptor_done(void *rx_queue, uint16_t offset);
+int atl_dev_rx_descriptor_status(void *rx_queue, uint16_t offset);
+int atl_dev_tx_descriptor_status(void *tx_queue, uint16_t offset);
+
 int atl_dev_rx_queue_intr_enable(struct rte_eth_dev *eth_dev,
 				 uint16_t queue_id);
 int atl_dev_rx_queue_intr_disable(struct rte_eth_dev *eth_dev,
@@ -70,6 +76,12 @@ int atl_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id);
 int atl_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id);
 int atl_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id);
 
+void atl_rxq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
+	struct rte_eth_rxq_info *qinfo);
+
+void atl_txq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
+	struct rte_eth_txq_info *qinfo);
+
 uint16_t atl_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 		uint16_t nb_pkts);
 
drivers/net/atlantic/atl_rxtx.c +125 -0

131 lines not on this page · raw message

Signature · 1 line
2.7.4
#21 lore raw

PATCH v4 14/22 net/atlantic: promisc and allmulti configuration

In reply to Igor Russkikh

From: Pavel Belous <[email protected]>

---
 drivers/net/atlantic/atl_ethdev.c | 44 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)
drivers/net/atlantic/atl_ethdev.c +44 -0
index afae232cb22c..a6ce2c47e0d7 100644
@@ -22,6 +22,10 @@ static int  atl_dev_set_link_up(struct rte_eth_dev *dev);
 static int  atl_dev_set_link_down(struct rte_eth_dev *dev);
 static void atl_dev_close(struct rte_eth_dev *dev);
 static int  atl_dev_reset(struct rte_eth_dev *dev);
+static void atl_dev_promiscuous_enable(struct rte_eth_dev *dev);
+static void atl_dev_promiscuous_disable(struct rte_eth_dev *dev);
+static void atl_dev_allmulticast_enable(struct rte_eth_dev *dev);
+static void atl_dev_allmulticast_disable(struct rte_eth_dev *dev);
 static int  atl_dev_link_update(struct rte_eth_dev *dev, int wait);
 
 static int atl_dev_xstats_get_names(struct rte_eth_dev *dev __rte_unused,
@@ -170,6 +174,12 @@ static const struct eth_dev_ops atl_eth_dev_ops = {
 	.dev_close	      = atl_dev_close,
 	.dev_reset	      = atl_dev_reset,
 
+	/* PROMISC */
+	.promiscuous_enable   = atl_dev_promiscuous_enable,
+	.promiscuous_disable  = atl_dev_promiscuous_disable,
+	.allmulticast_enable  = atl_dev_allmulticast_enable,
+	.allmulticast_disable = atl_dev_allmulticast_disable,
+
 	/* Link */
 	.link_update	      = atl_dev_link_update,
 
@@ -905,6 +915,40 @@ atl_dev_link_update(struct rte_eth_dev *dev, int wait __rte_unused)
 	return 0;
 }
 
+static void
+atl_dev_promiscuous_enable(struct rte_eth_dev *dev)
+{
+	struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+	hw_atl_rpfl2promiscuous_mode_en_set(hw, true);
+}
+
+static void
+atl_dev_promiscuous_disable(struct rte_eth_dev *dev)
+{
+	struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+	hw_atl_rpfl2promiscuous_mode_en_set(hw, false);
+}
+
+static void
+atl_dev_allmulticast_enable(struct rte_eth_dev *dev)
+{
+	struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+	hw_atl_rpfl2_accept_all_mc_packets_set(hw, true);
+}
+
+static void
+atl_dev_allmulticast_disable(struct rte_eth_dev *dev)
+{
+	struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+	if (dev->data->promiscuous == 1)
+		return; /* must remain in all_multicast mode */
+
+	hw_atl_rpfl2_accept_all_mc_packets_set(hw, false);
+}
 
 /**
  * It clears the interrupt causes and enables the interrupt.
Signature · 1 line
2.7.4
#22 lore raw

PATCH v4 15/22 net/atlantic: RSS and RETA manipulation API

In reply to Igor Russkikh
---
 drivers/net/atlantic/atl_ethdev.c | 107 ++++++++++++++++++++++++++++++++++++++
 drivers/net/atlantic/atl_ethdev.h |  14 +++++
 drivers/net/atlantic/atl_rxtx.c   |   5 ++
 3 files changed, 126 insertions(+)
drivers/net/atlantic/atl_ethdev.c +107 -0
index a6ce2c47e0d7..d6ec20d19a9a 100644
@@ -64,6 +64,19 @@ static int atl_dev_interrupt_action(struct rte_eth_dev *dev,
 				    struct rte_intr_handle *handle);
 static void atl_dev_interrupt_handler(void *param);
 
+/* RSS */
+static int atl_reta_update(struct rte_eth_dev *dev,
+			     struct rte_eth_rss_reta_entry64 *reta_conf,
+			     uint16_t reta_size);
+static int atl_reta_query(struct rte_eth_dev *dev,
+			    struct rte_eth_rss_reta_entry64 *reta_conf,
+			    uint16_t reta_size);
+static int atl_rss_hash_update(struct rte_eth_dev *dev,
+				 struct rte_eth_rss_conf *rss_conf);
+static int atl_rss_hash_conf_get(struct rte_eth_dev *dev,
+				   struct rte_eth_rss_conf *rss_conf);
+
+
 static int eth_atl_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 	struct rte_pci_device *pci_dev);
 static int eth_atl_pci_remove(struct rte_pci_device *pci_dev);
@@ -216,6 +229,11 @@ static const struct eth_dev_ops atl_eth_dev_ops = {
 
 	.rxq_info_get	      = atl_rxq_info_get,
 	.txq_info_get	      = atl_txq_info_get,
+
+	.reta_update          = atl_reta_update,
+	.reta_query           = atl_reta_query,
+	.rss_hash_update      = atl_rss_hash_update,
+	.rss_hash_conf_get    = atl_rss_hash_conf_get,
 };
 
 
@@ -333,12 +351,18 @@ eth_atl_dev_init(struct rte_eth_dev *eth_dev)
 	/* Hardware configuration - hardcode */
 	adapter->hw_cfg.is_lro = false;
 	adapter->hw_cfg.wol = false;
+	adapter->hw_cfg.is_rss = false;
+	adapter->hw_cfg.num_rss_queues = HW_ATL_B0_RSS_MAX;
+
 	adapter->hw_cfg.link_speed_msk = AQ_NIC_RATE_10G |
 			  AQ_NIC_RATE_5G |
 			  AQ_NIC_RATE_2G5 |
 			  AQ_NIC_RATE_1G |
 			  AQ_NIC_RATE_100M;
 
+	adapter->hw_cfg.aq_rss.indirection_table_size =
+		HW_ATL_B0_RSS_REDIRECTION_MAX;
+
 	hw->aq_nic_cfg = &adapter->hw_cfg;
 
 	/* disable interrupt */
@@ -840,6 +864,10 @@ atl_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 	dev_info->rx_desc_lim = rx_desc_lim;
 	dev_info->tx_desc_lim = tx_desc_lim;
 
+	dev_info->hash_key_size = HW_ATL_B0_RSS_HASHKEY_BITS / 8;
+	dev_info->reta_size = HW_ATL_B0_RSS_REDIRECTION_MAX;
+	dev_info->flow_type_rss_offloads = ATL_RSS_OFFLOAD_ALL;
+
 	dev_info->speed_capa = ETH_LINK_SPEED_1G | ETH_LINK_SPEED_10G;
 	dev_info->speed_capa |= ETH_LINK_SPEED_100M;
 	dev_info->speed_capa |= ETH_LINK_SPEED_2_5G;
@@ -1091,6 +1119,85 @@ atl_dev_interrupt_handler(void *param)
 	atl_dev_interrupt_action(dev, dev->intr_handle);
 }
 
+static int
+atl_reta_update(struct rte_eth_dev *dev,
+		   struct rte_eth_rss_reta_entry64 *reta_conf,
+		   uint16_t reta_size)
+{
+	int i;
+	struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct aq_hw_cfg_s *cf = ATL_DEV_PRIVATE_TO_CFG(dev->data->dev_private);
+
+	for (i = 0; i < reta_size && i < cf->aq_rss.indirection_table_size; i++)
+		cf->aq_rss.indirection_table[i] = min(reta_conf->reta[i],
+					dev->data->nb_rx_queues - 1);
+
+	hw_atl_b0_hw_rss_set(hw, &cf->aq_rss);
+	return 0;
+}
+
+static int
+atl_reta_query(struct rte_eth_dev *dev,
+		    struct rte_eth_rss_reta_entry64 *reta_conf,
+		    uint16_t reta_size)
+{
+	int i;
+	struct aq_hw_cfg_s *cf = ATL_DEV_PRIVATE_TO_CFG(dev->data->dev_private);
+
+	for (i = 0; i < reta_size && i < cf->aq_rss.indirection_table_size; i++)
+		reta_conf->reta[i] = cf->aq_rss.indirection_table[i];
+	reta_conf->mask = ~0U;
+	return 0;
+}
+
+static int
+atl_rss_hash_update(struct rte_eth_dev *dev,
+				 struct rte_eth_rss_conf *rss_conf)
+{
+	struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct aq_hw_cfg_s *cfg =
+		ATL_DEV_PRIVATE_TO_CFG(dev->data->dev_private);
+	static u8 def_rss_key[40] = {
+		0x1e, 0xad, 0x71, 0x87, 0x65, 0xfc, 0x26, 0x7d,
+		0x0d, 0x45, 0x67, 0x74, 0xcd, 0x06, 0x1a, 0x18,
+		0xb6, 0xc1, 0xf0, 0xc7, 0xbb, 0x18, 0xbe, 0xf8,
+		0x19, 0x13, 0x4b, 0xa9, 0xd0, 0x3e, 0xfe, 0x70,
+		0x25, 0x03, 0xab, 0x50, 0x6a, 0x8b, 0x82, 0x0c
+	};
+
+	cfg->is_rss = !!rss_conf->rss_hf;
+	if (rss_conf->rss_key) {
+		memcpy(cfg->aq_rss.hash_secret_key, rss_conf->rss_key,
+		       rss_conf->rss_key_len);
+		cfg->aq_rss.hash_secret_key_size = rss_conf->rss_key_len;
+	} else {
+		memcpy(cfg->aq_rss.hash_secret_key, def_rss_key,
+		       sizeof(def_rss_key));
+		cfg->aq_rss.hash_secret_key_size = sizeof(def_rss_key);
+	}
+
+	hw_atl_b0_hw_rss_set(hw, &cfg->aq_rss);
+	hw_atl_b0_hw_rss_hash_set(hw, &cfg->aq_rss);
+	return 0;
+}
+
+static int
+atl_rss_hash_conf_get(struct rte_eth_dev *dev,
+				 struct rte_eth_rss_conf *rss_conf)
+{
+	struct aq_hw_cfg_s *cfg =
+		ATL_DEV_PRIVATE_TO_CFG(dev->data->dev_private);
+
+	rss_conf->rss_hf = cfg->is_rss ? ATL_RSS_OFFLOAD_ALL : 0;
+	if (rss_conf->rss_key) {
+		rss_conf->rss_key_len = cfg->aq_rss.hash_secret_key_size;
+		memcpy(rss_conf->rss_key, cfg->aq_rss.hash_secret_key,
+		       rss_conf->rss_key_len);
+	}
+
+	return 0;
+}
+
 RTE_PMD_REGISTER_PCI(net_atlantic, rte_atl_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_atlantic, pci_id_atl_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_atlantic, "* igb_uio | uio_pci_generic");
drivers/net/atlantic/atl_ethdev.h +14 -0
index dbb42140816b..f0854e0f1d9f 100644
@@ -10,6 +10,17 @@
 #include "atl_types.h"
 #include "hw_atl/hw_atl_utils.h"
 
+#define ATL_RSS_OFFLOAD_ALL ( \
+	ETH_RSS_IPV4 | \
+	ETH_RSS_NONFRAG_IPV4_TCP | \
+	ETH_RSS_NONFRAG_IPV4_UDP | \
+	ETH_RSS_IPV6 | \
+	ETH_RSS_NONFRAG_IPV6_TCP | \
+	ETH_RSS_NONFRAG_IPV6_UDP | \
+	ETH_RSS_IPV6_EX | \
+	ETH_RSS_IPV6_TCP_EX | \
+	ETH_RSS_IPV6_UDP_EX)
+
 #define ATL_DEV_PRIVATE_TO_HW(adapter) \
 	(&((struct atl_adapter *)adapter)->hw)
 
@@ -19,6 +30,9 @@
 #define ATL_DEV_PRIVATE_TO_INTR(adapter) \
 	(&((struct atl_adapter *)adapter)->intr)
 
+#define ATL_DEV_PRIVATE_TO_CFG(adapter) \
+	(&((struct atl_adapter *)adapter)->hw_cfg)
+
 #define ATL_FLAG_NEED_LINK_UPDATE (uint32_t)(1 << 0)
 #define ATL_FLAG_NEED_LINK_CONFIG (uint32_t)(4 << 0)
 
drivers/net/atlantic/atl_rxtx.c +5 -0
index 88801822262f..582832457cdf 100644
@@ -327,6 +327,7 @@ int
 atl_rx_init(struct rte_eth_dev *eth_dev)
 {
 	struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
+	struct aq_rss_parameters *rss_params = &hw->aq_nic_cfg->aq_rss;
 	struct atl_rx_queue *rxq;
 	uint64_t base_addr = 0;
 	int i = 0;
@@ -370,6 +371,10 @@ atl_rx_init(struct rte_eth_dev *eth_dev)
 		}
 	}
 
+	for (i = rss_params->indirection_table_size; i--;)
+		rss_params->indirection_table[i] = i &
+			(eth_dev->data->nb_rx_queues - 1);
+	hw_atl_b0_hw_rss_set(hw, rss_params);
 	return err;
 }
 
Signature · 1 line
2.7.4
#23 lore raw

PATCH v4 16/22 net/atlantic: flow control configuration

In reply to Igor Russkikh

From: Pavel Belous <[email protected]>

---
 drivers/net/atlantic/atl_ethdev.c | 54 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 54 insertions(+)
drivers/net/atlantic/atl_ethdev.c +54 -0
index d6ec20d19a9a..efdd83fb4d6b 100644
@@ -54,6 +54,12 @@ static void atl_dev_info_get(struct rte_eth_dev *dev,
 
 static const uint32_t *atl_dev_supported_ptypes_get(struct rte_eth_dev *dev);
 
+/* Flow control */
+static int atl_flow_ctrl_get(struct rte_eth_dev *dev,
+			       struct rte_eth_fc_conf *fc_conf);
+static int atl_flow_ctrl_set(struct rte_eth_dev *dev,
+			       struct rte_eth_fc_conf *fc_conf);
+
 static void atl_dev_link_status_print(struct rte_eth_dev *dev);
 
 /* Interrupts */
@@ -227,6 +233,10 @@ static const struct eth_dev_ops atl_eth_dev_ops = {
 	.rx_descriptor_status = atl_dev_rx_descriptor_status,
 	.tx_descriptor_status = atl_dev_tx_descriptor_status,
 
+	/* Flow Control */
+	.flow_ctrl_get	      = atl_flow_ctrl_get,
+	.flow_ctrl_set	      = atl_flow_ctrl_set,
+
 	.rxq_info_get	      = atl_rxq_info_get,
 	.txq_info_get	      = atl_txq_info_get,
 
@@ -360,6 +370,7 @@ eth_atl_dev_init(struct rte_eth_dev *eth_dev)
 			  AQ_NIC_RATE_1G |
 			  AQ_NIC_RATE_100M;
 
+	adapter->hw_cfg.flow_control = (AQ_NIC_FC_RX | AQ_NIC_FC_TX);
 	adapter->hw_cfg.aq_rss.indirection_table_size =
 		HW_ATL_B0_RSS_REDIRECTION_MAX;
 
@@ -1119,6 +1130,49 @@ atl_dev_interrupt_handler(void *param)
 	atl_dev_interrupt_action(dev, dev->intr_handle);
 }
 
+
+static int
+atl_flow_ctrl_get(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
+{
+	struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+	if (hw->aq_nic_cfg->flow_control == AQ_NIC_FC_OFF)
+		fc_conf->mode = RTE_FC_NONE;
+	else if (hw->aq_nic_cfg->flow_control & (AQ_NIC_FC_RX | AQ_NIC_FC_TX))
+		fc_conf->mode = RTE_FC_FULL;
+	else if (hw->aq_nic_cfg->flow_control & AQ_NIC_FC_RX)
+		fc_conf->mode = RTE_FC_RX_PAUSE;
+	else if (hw->aq_nic_cfg->flow_control & AQ_NIC_FC_RX)
+		fc_conf->mode = RTE_FC_TX_PAUSE;
+
+	return 0;
+}
+
+static int
+atl_flow_ctrl_set(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
+{
+	struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	uint32_t old_flow_control = hw->aq_nic_cfg->flow_control;
+
+
+	if (hw->aq_fw_ops->set_flow_control == NULL)
+		return -ENOTSUP;
+
+	if (fc_conf->mode == RTE_FC_NONE)
+		hw->aq_nic_cfg->flow_control = AQ_NIC_FC_OFF;
+	else if (fc_conf->mode == RTE_FC_RX_PAUSE)
+		hw->aq_nic_cfg->flow_control = AQ_NIC_FC_RX;
+	else if (fc_conf->mode == RTE_FC_TX_PAUSE)
+		hw->aq_nic_cfg->flow_control = AQ_NIC_FC_TX;
+	else if (fc_conf->mode == RTE_FC_FULL)
+		hw->aq_nic_cfg->flow_control = (AQ_NIC_FC_RX | AQ_NIC_FC_TX);
+
+	if (old_flow_control != hw->aq_nic_cfg->flow_control)
+		return hw->aq_fw_ops->set_flow_control(hw);
+
+	return 0;
+}
+
 static int
 atl_reta_update(struct rte_eth_dev *dev,
 		   struct rte_eth_rss_reta_entry64 *reta_conf,
Signature · 1 line
2.7.4
#24 lore raw

PATCH v4 17/22 net/atlantic: MAC address manipulations

In reply to Igor Russkikh

From: Pavel Belous <[email protected]>

---
 drivers/net/atlantic/atl_ethdev.c | 126 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 126 insertions(+)
drivers/net/atlantic/atl_ethdev.c +126 -0
index efdd83fb4d6b..3f0d2e26d7da 100644
@@ -54,6 +54,8 @@ static void atl_dev_info_get(struct rte_eth_dev *dev,
 
 static const uint32_t *atl_dev_supported_ptypes_get(struct rte_eth_dev *dev);
 
+static int atl_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu);
+
 /* Flow control */
 static int atl_flow_ctrl_get(struct rte_eth_dev *dev,
 			       struct rte_eth_fc_conf *fc_conf);
@@ -70,6 +72,18 @@ static int atl_dev_interrupt_action(struct rte_eth_dev *dev,
 				    struct rte_intr_handle *handle);
 static void atl_dev_interrupt_handler(void *param);
 
+
+static int atl_add_mac_addr(struct rte_eth_dev *dev,
+			    struct ether_addr *mac_addr,
+			    uint32_t index, uint32_t pool);
+static void atl_remove_mac_addr(struct rte_eth_dev *dev, uint32_t index);
+static int atl_set_default_mac_addr(struct rte_eth_dev *dev,
+					   struct ether_addr *mac_addr);
+
+static int atl_dev_set_mc_addr_list(struct rte_eth_dev *dev,
+				    struct ether_addr *mc_addr_set,
+				    uint32_t nb_mc_addr);
+
 /* RSS */
 static int atl_reta_update(struct rte_eth_dev *dev,
 			     struct rte_eth_rss_reta_entry64 *reta_conf,
@@ -214,6 +228,8 @@ static const struct eth_dev_ops atl_eth_dev_ops = {
 	.dev_infos_get	      = atl_dev_info_get,
 	.dev_supported_ptypes_get = atl_dev_supported_ptypes_get,
 
+	.mtu_set	      = atl_dev_mtu_set,
+
 	/* Queue Control */
 	.rx_queue_start	      = atl_rx_queue_start,
 	.rx_queue_stop	      = atl_rx_queue_stop,
@@ -237,6 +253,11 @@ static const struct eth_dev_ops atl_eth_dev_ops = {
 	.flow_ctrl_get	      = atl_flow_ctrl_get,
 	.flow_ctrl_set	      = atl_flow_ctrl_set,
 
+	/* MAC */
+	.mac_addr_add	      = atl_add_mac_addr,
+	.mac_addr_remove      = atl_remove_mac_addr,
+	.mac_addr_set	      = atl_set_default_mac_addr,
+	.set_mc_addr_list     = atl_dev_set_mc_addr_list,
 	.rxq_info_get	      = atl_rxq_info_get,
 	.txq_info_get	      = atl_txq_info_get,
 
@@ -1174,6 +1195,111 @@ atl_flow_ctrl_set(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
 }
 
 static int
+atl_update_mac_addr(struct rte_eth_dev *dev, uint32_t index,
+		    u8 *mac_addr, bool enable)
+{
+	struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	unsigned int h = 0U;
+	unsigned int l = 0U;
+	int err;
+
+	if (mac_addr) {
+		h = (mac_addr[0] << 8) | (mac_addr[1]);
+		l = (mac_addr[2] << 24) | (mac_addr[3] << 16) |
+			(mac_addr[4] << 8) | mac_addr[5];
+	}
+
+	hw_atl_rpfl2_uc_flr_en_set(hw, 0U, index);
+	hw_atl_rpfl2unicast_dest_addresslsw_set(hw, l, index);
+	hw_atl_rpfl2unicast_dest_addressmsw_set(hw, h, index);
+
+	if (enable)
+		hw_atl_rpfl2_uc_flr_en_set(hw, 1U, index);
+
+	err = aq_hw_err_from_flags(hw);
+
+	return err;
+}
+
+static int
+atl_add_mac_addr(struct rte_eth_dev *dev, struct ether_addr *mac_addr,
+			uint32_t index __rte_unused, uint32_t pool __rte_unused)
+{
+	if (is_zero_ether_addr(mac_addr)) {
+		PMD_DRV_LOG(ERR, "Invalid Ethernet Address");
+		return -EINVAL;
+	}
+
+	return atl_update_mac_addr(dev, index, (u8 *)mac_addr, true);
+}
+
+static void
+atl_remove_mac_addr(struct rte_eth_dev *dev, uint32_t index)
+{
+	atl_update_mac_addr(dev, index, NULL, false);
+}
+
+static int
+atl_set_default_mac_addr(struct rte_eth_dev *dev, struct ether_addr *addr)
+{
+	atl_remove_mac_addr(dev, 0);
+	atl_add_mac_addr(dev, addr, 0, 0);
+	return 0;
+}
+
+static int
+atl_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
+{
+	struct rte_eth_dev_info dev_info;
+	uint32_t frame_size = mtu + ETHER_HDR_LEN + ETHER_CRC_LEN;
+
+	atl_dev_info_get(dev, &dev_info);
+
+	if ((mtu < ETHER_MIN_MTU) || (frame_size > dev_info.max_rx_pktlen))
+		return -EINVAL;
+
+	/* update max frame size */
+	dev->data->dev_conf.rxmode.max_rx_pkt_len = frame_size;
+
+	return 0;
+}
+
+static int
+atl_dev_set_mc_addr_list(struct rte_eth_dev *dev,
+			  struct ether_addr *mc_addr_set,
+			  uint32_t nb_mc_addr)
+{
+	struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	u32 i;
+
+	if (nb_mc_addr > AQ_HW_MULTICAST_ADDRESS_MAX - HW_ATL_B0_MAC_MIN)
+		return -EINVAL;
+
+	/* Update whole uc filters table */
+	for (i = 0; i < AQ_HW_MULTICAST_ADDRESS_MAX - HW_ATL_B0_MAC_MIN; i++) {
+		u8 *mac_addr = NULL;
+		u32 l = 0, h = 0;
+
+		if (i < nb_mc_addr) {
+			mac_addr = mc_addr_set[i].addr_bytes;
+			l = (mac_addr[2] << 24) | (mac_addr[3] << 16) |
+				(mac_addr[4] << 8) | mac_addr[5];
+			h = (mac_addr[0] << 8) | mac_addr[1];
+		}
+
+		hw_atl_rpfl2_uc_flr_en_set(hw, 0U, HW_ATL_B0_MAC_MIN + i);
+		hw_atl_rpfl2unicast_dest_addresslsw_set(hw, l,
+							HW_ATL_B0_MAC_MIN + i);
+		hw_atl_rpfl2unicast_dest_addressmsw_set(hw, h,
+							HW_ATL_B0_MAC_MIN + i);
+		hw_atl_rpfl2_uc_flr_en_set(hw, !!mac_addr,
+					   HW_ATL_B0_MAC_MIN + i);
+	}
+
+	return 0;
+}
+
+static int
 atl_reta_update(struct rte_eth_dev *dev,
 		   struct rte_eth_rss_reta_entry64 *reta_conf,
 		   uint16_t reta_size)
Signature · 1 line
2.7.4
#26 lore raw

PATCH v4 18/22 net/atlantic: VLAN filters and offloads

In reply to Igor Russkikh

From: Pavel Belous <[email protected]>

---
 drivers/net/atlantic/atl_ethdev.c | 161 ++++++++++++++++++++++++++++++++++++++
 drivers/net/atlantic/atl_types.h  |   2 +
 2 files changed, 163 insertions(+)
drivers/net/atlantic/atl_ethdev.c +161 -0
index 3f0d2e26d7da..46377b482ab2 100644
@@ -56,6 +56,20 @@ static const uint32_t *atl_dev_supported_ptypes_get(struct rte_eth_dev *dev);
 
 static int atl_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu);
 
+
+/* VLAN stuff */
+static int atl_vlan_filter_set(struct rte_eth_dev *dev,
+		uint16_t vlan_id, int on);
+
+static int atl_vlan_offload_set(struct rte_eth_dev *dev, int mask);
+
+static void atl_vlan_strip_queue_set(struct rte_eth_dev *dev,
+				     uint16_t queue_id, int on);
+
+static int atl_vlan_tpid_set(struct rte_eth_dev *dev,
+			     enum rte_vlan_type vlan_type, uint16_t tpid);
+
+
 /* Flow control */
 static int atl_flow_ctrl_get(struct rte_eth_dev *dev,
 			       struct rte_eth_fc_conf *fc_conf);
@@ -230,6 +244,12 @@ static const struct eth_dev_ops atl_eth_dev_ops = {
 
 	.mtu_set	      = atl_dev_mtu_set,
 
+	/* VLAN */
+	.vlan_filter_set      = atl_vlan_filter_set,
+	.vlan_offload_set     = atl_vlan_offload_set,
+	.vlan_tpid_set        = atl_vlan_tpid_set,
+	.vlan_strip_queue_set = atl_vlan_strip_queue_set,
+
 	/* Queue Control */
 	.rx_queue_start	      = atl_rx_queue_start,
 	.rx_queue_stop	      = atl_rx_queue_stop,
@@ -1265,6 +1285,147 @@ atl_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
 }
 
 static int
+atl_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
+{
+	struct aq_hw_cfg_s *cfg =
+		ATL_DEV_PRIVATE_TO_CFG(dev->data->dev_private);
+	struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	int err = 0;
+	int i = 0;
+
+	PMD_INIT_FUNC_TRACE();
+
+	for (i = 0; i < HW_ATL_B0_MAX_VLAN_IDS; i++) {
+		if (cfg->vlan_filter[i] == vlan_id) {
+			if (!on) {
+				/* Disable VLAN filter. */
+				hw_atl_rpf_vlan_flr_en_set(hw, 0U, i);
+
+				/* Clear VLAN filter entry */
+				cfg->vlan_filter[i] = 0;
+			}
+			break;
+		}
+	}
+
+	/* VLAN_ID was not found. So, nothing to delete. */
+	if (i == HW_ATL_B0_MAX_VLAN_IDS && !on)
+		goto exit;
+
+	/* VLAN_ID already exist, or already removed above. Nothing to do. */
+	if (i != HW_ATL_B0_MAX_VLAN_IDS)
+		goto exit;
+
+	/* Try to found free VLAN filter to add new VLAN_ID */
+	for (i = 0; i < HW_ATL_B0_MAX_VLAN_IDS; i++) {
+		if (cfg->vlan_filter[i] == 0)
+			break;
+	}
+
+	if (i == HW_ATL_B0_MAX_VLAN_IDS) {
+		/* We have no free VLAN filter to add new VLAN_ID*/
+		err = -ENOMEM;
+		goto exit;
+	}
+
+	cfg->vlan_filter[i] = vlan_id;
+	hw_atl_rpf_vlan_flr_act_set(hw, 1U, i);
+	hw_atl_rpf_vlan_id_flr_set(hw, vlan_id, i);
+	hw_atl_rpf_vlan_flr_en_set(hw, 1U, i);
+
+exit:
+	/* Enable VLAN promisc mode if vlan_filter empty  */
+	for (i = 0; i < HW_ATL_B0_MAX_VLAN_IDS; i++) {
+		if (cfg->vlan_filter[i] != 0)
+			break;
+	}
+
+	hw_atl_rpf_vlan_prom_mode_en_set(hw, i == HW_ATL_B0_MAX_VLAN_IDS);
+
+	return err;
+}
+
+static int
+atl_enable_vlan_filter(struct rte_eth_dev *dev, int en)
+{
+	struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct aq_hw_cfg_s *cfg =
+		ATL_DEV_PRIVATE_TO_CFG(dev->data->dev_private);
+	int i;
+
+	PMD_INIT_FUNC_TRACE();
+
+	for (i = 0; i < HW_ATL_B0_MAX_VLAN_IDS; i++) {
+		if (cfg->vlan_filter[i])
+			hw_atl_rpf_vlan_flr_en_set(hw, en, i);
+	}
+	return 0;
+}
+
+static int
+atl_vlan_offload_set(struct rte_eth_dev *dev, int mask)
+{
+	struct aq_hw_cfg_s *cfg =
+		ATL_DEV_PRIVATE_TO_CFG(dev->data->dev_private);
+	struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	int ret = 0;
+	int i;
+
+	PMD_INIT_FUNC_TRACE();
+
+	ret = atl_enable_vlan_filter(dev, mask & ETH_VLAN_FILTER_MASK);
+
+	cfg->vlan_strip = !!(mask & ETH_VLAN_STRIP_MASK);
+
+	for (i = 0; i < dev->data->nb_rx_queues; i++)
+		hw_atl_rpo_rx_desc_vlan_stripping_set(hw, cfg->vlan_strip, i);
+
+	if (mask & ETH_VLAN_EXTEND_MASK)
+		ret = -ENOTSUP;
+
+	return ret;
+}
+
+static int
+atl_vlan_tpid_set(struct rte_eth_dev *dev, enum rte_vlan_type vlan_type,
+		  uint16_t tpid)
+{
+	struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	int err = 0;
+
+	PMD_INIT_FUNC_TRACE();
+
+	switch (vlan_type) {
+	case ETH_VLAN_TYPE_INNER:
+		hw_atl_rpf_vlan_inner_etht_set(hw, tpid);
+		break;
+	case ETH_VLAN_TYPE_OUTER:
+		hw_atl_rpf_vlan_outer_etht_set(hw, tpid);
+		break;
+	default:
+		PMD_DRV_LOG(ERR, "Unsupported VLAN type");
+		err = -ENOTSUP;
+	}
+
+	return err;
+}
+
+static void
+atl_vlan_strip_queue_set(struct rte_eth_dev *dev, uint16_t queue_id, int on)
+{
+	struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+	PMD_INIT_FUNC_TRACE();
+
+	if (queue_id > dev->data->nb_rx_queues) {
+		PMD_DRV_LOG(ERR, "Invalid queue id");
+		return;
+	}
+
+	hw_atl_rpo_rx_desc_vlan_stripping_set(hw, on, queue_id);
+}
+
+static int
 atl_dev_set_mc_addr_list(struct rte_eth_dev *dev,
 			  struct ether_addr *mc_addr_set,
 			  uint32_t nb_mc_addr)
drivers/net/atlantic/atl_types.h +2 -0
index 56887b14d6f8..3d90f6caefc2 100644
@@ -70,6 +70,8 @@ struct aq_hw_cfg_s {
 	int irq_mask;
 	unsigned int vecs;
 
+	bool vlan_strip;
+	uint32_t vlan_filter[HW_ATL_B0_MAX_VLAN_IDS];
 	uint32_t flow_control;
 
 	struct aq_rss_parameters aq_rss;
Signature · 1 line
2.7.4
#27 lore raw

PATCH v4 19/22 net/atlantic: eeprom and register manipulation routines

In reply to Igor Russkikh

From: Pavel Belous <[email protected]>

---
 drivers/net/atlantic/atl_ethdev.c | 47 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)
drivers/net/atlantic/atl_ethdev.c +47 -0
index 46377b482ab2..323769db8087 100644
@@ -69,6 +69,13 @@ static void atl_vlan_strip_queue_set(struct rte_eth_dev *dev,
 static int atl_vlan_tpid_set(struct rte_eth_dev *dev,
 			     enum rte_vlan_type vlan_type, uint16_t tpid);
 
+/* EEPROM */
+static int atl_dev_get_eeprom_length(struct rte_eth_dev *dev);
+static int atl_dev_get_eeprom(struct rte_eth_dev *dev,
+			      struct rte_dev_eeprom_info *eeprom);
+static int atl_dev_set_eeprom(struct rte_eth_dev *dev,
+			      struct rte_dev_eeprom_info *eeprom);
+
 
 /* Flow control */
 static int atl_flow_ctrl_get(struct rte_eth_dev *dev,
@@ -269,6 +276,11 @@ static const struct eth_dev_ops atl_eth_dev_ops = {
 	.rx_descriptor_status = atl_dev_rx_descriptor_status,
 	.tx_descriptor_status = atl_dev_tx_descriptor_status,
 
+	/* EEPROM */
+	.get_eeprom_length    = atl_dev_get_eeprom_length,
+	.get_eeprom           = atl_dev_get_eeprom,
+	.set_eeprom           = atl_dev_set_eeprom,
+
 	/* Flow Control */
 	.flow_ctrl_get	      = atl_flow_ctrl_get,
 	.flow_ctrl_set	      = atl_flow_ctrl_set,
@@ -1171,6 +1183,41 @@ atl_dev_interrupt_handler(void *param)
 	atl_dev_interrupt_action(dev, dev->intr_handle);
 }
 
+#define SFP_EEPROM_SIZE 0xff
+
+static int
+atl_dev_get_eeprom_length(struct rte_eth_dev *dev __rte_unused)
+{
+	return SFP_EEPROM_SIZE;
+}
+
+static int
+atl_dev_get_eeprom(struct rte_eth_dev *dev, struct rte_dev_eeprom_info *eeprom)
+{
+	struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+	if (hw->aq_fw_ops->get_eeprom == NULL)
+		return -ENOTSUP;
+
+	if (eeprom->length != SFP_EEPROM_SIZE || eeprom->data == NULL)
+		return -EINVAL;
+
+	return hw->aq_fw_ops->get_eeprom(hw, eeprom->data, eeprom->length);
+}
+
+static int
+atl_dev_set_eeprom(struct rte_eth_dev *dev, struct rte_dev_eeprom_info *eeprom)
+{
+	struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+	if (hw->aq_fw_ops->set_eeprom == NULL)
+		return -ENOTSUP;
+
+	if (eeprom->length != SFP_EEPROM_SIZE || eeprom->data == NULL)
+		return -EINVAL;
+
+	return hw->aq_fw_ops->set_eeprom(hw, eeprom->data, eeprom->length);
+}
 
 static int
 atl_flow_ctrl_get(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
Signature · 1 line
2.7.4
#28 lore raw

PATCH v4 20/22 net/atlantic: LED control DPDK and private APIs

In reply to Igor Russkikh
---
 drivers/net/atlantic/Makefile           |  4 +++
 drivers/net/atlantic/atl_ethdev.c       | 53 +++++++++++++++++++++++++++++++++
 drivers/net/atlantic/atl_ethdev.h       |  3 ++
 drivers/net/atlantic/meson.build        |  3 ++
 drivers/net/atlantic/rte_pmd_atlantic.c | 19 ++++++++++++
 drivers/net/atlantic/rte_pmd_atlantic.h | 44 +++++++++++++++++++++++++++
 6 files changed, 126 insertions(+)
 create mode 100644 drivers/net/atlantic/rte_pmd_atlantic.c
 create mode 100644 drivers/net/atlantic/rte_pmd_atlantic.h
drivers/net/atlantic/Makefile +4 -0
index 62dcdbffa69c..6e821e013af9 100644
@@ -31,5 +31,9 @@ SRCS-$(CONFIG_RTE_LIBRTE_ATLANTIC_PMD) += hw_atl_utils.c
 SRCS-$(CONFIG_RTE_LIBRTE_ATLANTIC_PMD) += hw_atl_llh.c
 SRCS-$(CONFIG_RTE_LIBRTE_ATLANTIC_PMD) += hw_atl_utils_fw2x.c
 SRCS-$(CONFIG_RTE_LIBRTE_ATLANTIC_PMD) += hw_atl_b0.c
+SRCS-$(CONFIG_RTE_LIBRTE_ATLANTIC_PMD) += rte_pmd_atlantic.c
+
+# install this header file
+SYMLINK-$(CONFIG_RTE_LIBRTE_ATLANTIC_PMD)-include := rte_pmd_atlantic.h
 
 include $(RTE_SDK)/mk/rte.lib.mk
drivers/net/atlantic/atl_ethdev.c +53 -0

71 lines not on this page · raw message

drivers/net/atlantic/atl_ethdev.h +3 -0
index f0854e0f1d9f..538359ac3f6f 100644
@@ -105,4 +105,7 @@ uint16_t atl_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 uint16_t atl_prep_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 		uint16_t nb_pkts);
 
+int
+atl_dev_led_control(struct rte_eth_dev *dev, int control);
+
 #endif /* _ATLANTIC_ETHDEV_H_ */
drivers/net/atlantic/meson.build +3 -0
index 28fb97cace6e..c6f39d8a7b0a 100644
@@ -9,4 +9,7 @@ sources = files(
 	'hw_atl/hw_atl_llh.c',
 	'hw_atl/hw_atl_utils_fw2x.c',
 	'hw_atl/hw_atl_utils.c',
+	'rte_pmd_atlantic.c',
 )
+
+install_headers('rte_pmd_atlantic.h')
drivers/net/atlantic/rte_pmd_atlantic.c new file +19 -0
new file mode 100644
index 000000000000..4cb09baf2afc
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2018 Aquantia Corporation
+ */
+
+#include <rte_ethdev_driver.h>
+
+#include "rte_pmd_atlantic.h"
+#include "atl_ethdev.h"
+
+int rte_pmd_atl_dev_led_control(int port, int control)
+{
+	struct rte_eth_dev *dev;
+
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
+
+	dev = &rte_eth_devices[port];
+
+	return atl_dev_led_control(dev, control);
+}
drivers/net/atlantic/rte_pmd_atlantic.h new file +44 -0

44 lines not on this page · raw message

Signature · 1 line
2.7.4
#32 lore raw

PATCH v4 21/22 net/atlantic: support for read MAC registers for debug purposes

In reply to Igor Russkikh

From: Pavel Belous <[email protected]>

---
 drivers/net/atlantic/atl_ethdev.c | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)
drivers/net/atlantic/atl_ethdev.c +31 -0
index fb23dc89f88c..97977dee3d3b 100644
@@ -80,6 +80,9 @@ static int atl_dev_get_eeprom(struct rte_eth_dev *dev,
 static int atl_dev_set_eeprom(struct rte_eth_dev *dev,
 			      struct rte_dev_eeprom_info *eeprom);
 
+/* Regs */
+static int atl_dev_get_regs(struct rte_eth_dev *dev,
+			    struct rte_dev_reg_info *regs);
 
 /* Flow control */
 static int atl_flow_ctrl_get(struct rte_eth_dev *dev,
@@ -241,6 +244,8 @@ static const struct eth_dev_ops atl_eth_dev_ops = {
 	/* Link */
 	.link_update	      = atl_dev_link_update,
 
+	.get_reg              = atl_dev_get_regs,
+
 	/* Stats */
 	.stats_get	      = atl_dev_stats_get,
 	.xstats_get	      = atl_dev_xstats_get,
@@ -1273,6 +1278,32 @@ atl_dev_set_eeprom(struct rte_eth_dev *dev, struct rte_dev_eeprom_info *eeprom)
 }
 
 static int
+atl_dev_get_regs(struct rte_eth_dev *dev, struct rte_dev_reg_info *regs)
+{
+	struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	u32 mif_id;
+	int err;
+
+	if (regs->data == NULL) {
+		regs->length = hw_atl_utils_hw_get_reg_length();
+		regs->width = sizeof(u32);
+		return 0;
+	}
+
+	/* Only full register dump is supported */
+	if (regs->length && regs->length != hw_atl_utils_hw_get_reg_length())
+		return -ENOTSUP;
+
+	err = hw_atl_utils_hw_get_regs(hw, regs->data);
+
+	/* Device version */
+	mif_id = hw_atl_reg_glb_mif_id_get(hw);
+	regs->version = mif_id & 0xFFU;
+
+	return err;
+}
+
+static int
 atl_flow_ctrl_get(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
 {
 	struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private);
Signature · 1 line
2.7.4
#33 lore raw

PATCH v4 22/22 net/atlantic: documentation and rel notes

In reply to Igor Russkikh
---
 doc/guides/nics/atlantic.rst           | 53 ++++++++++++++++++++++++++++++++++
 doc/guides/nics/features/atlantic.ini  | 37 ++++++++++++++++++++++++
 doc/guides/nics/index.rst              |  1 +
 doc/guides/rel_notes/release_18_11.rst |  5 ++++
 4 files changed, 96 insertions(+)
 create mode 100644 doc/guides/nics/atlantic.rst
 create mode 100644 doc/guides/nics/features/atlantic.ini
doc/guides/nics/atlantic.rst new file +53 -0
new file mode 100644
index 000000000000..88939359d942
@@ -0,0 +1,53 @@
+..  SPDX-License-Identifier: BSD-3-Clause
+    Copyright(c) 2018 Aquantia Corporation.
+
+Aquantia Atlantic DPDK Driver
+=============================
+
+Atlantic DPDK driver provides DPDK support for Aquantia's AQtion family of chipsets: AQC107/AQC108/AQC109
+
+Supported features
+^^^^^^^^^^^^^^^^^^
+
+
+- Base L2 features
+- Promiscuous mode
+- Port statistics
+- Multicast mode
+- RSS (Receive Side Scaling)
+- Checksum offload
+- Jumbo Frame upto 16K
+
+Configuration Information
+^^^^^^^^^^^^^^^^^^^^^^^^^
+
+- ``CONFIG_RTE_LIBRTE_ATLANTIC_PMD`` (default ``y``)
+
+Not yet supported features
+^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+NOP
+
+Application Programming Interface
+---------------------------------
+
+Atlantic NIC supports custom LED pin configuration interface.
+For details, refer rte_pmd_atlantic.h header file
+
+Limitations or Known issues
+---------------------------
+
+Statistics
+~~~~~~~~~~
+
+MTU setting
+~~~~~~~~~~~
+
+Atlantic NIC supports up to 16K jumbo frame size
+
+Supported Chipsets and NICs
+---------------------------
+
+- Aquantia AQtion AQC107 10 Gigabit Ethernet Controller
+- Aquantia AQtion AQC108 5 Gigabit Ethernet Controller
+- Aquantia AQtion AQC109 2.5 Gigabit Ethernet Controller
doc/guides/nics/features/atlantic.ini new file +37 -0
new file mode 100644
index 000000000000..2d943ce13212
@@ -0,0 +1,37 @@
+;
+; Supported features of the 'atlantic' network poll mode driver.
+;
+; Refer to default.ini for the full list of available PMD features.
+;
+[Features]
+Speed capabilities   = Y
+Link status          = Y
+Link status event    = Y
+MTU update           = Y
+Jumbo frame          = Y
+Promiscuous mode     = Y
+Allmulticast mode    = Y
+Unicast MAC filter   = Y
+VLAN filter          = Y
+Flow control         = Y
+CRC offload          = Y
+VLAN offload         = Y
+L3 checksum offload  = Y
+L4 checksum offload  = Y
+Rx descriptor status = Y
+Tx descriptor status = Y
+Basic stats          = Y
+Extended stats       = Y
+Stats per queue      = Y
+Linux UIO            = Y
+x86-32               = Y
+x86-64               = Y
+Queue start/stop     = Y
+RSS hash             = Y
+RSS key update       = Y
+RSS reta update      = Y
+Packet type parsing  = Y
+FW version           = Y
+EEPROM dump          = Y
+Registers dump       = Y
+LED                  = Y
doc/guides/nics/index.rst +1 -0
index 59f6063dce92..7925c2bd86ff 100644
@@ -12,6 +12,7 @@ Network Interface Controller Drivers
     features
     build_and_test
     ark
+    atlantic
     avp
     axgbe
     bnx2x
doc/guides/rel_notes/release_18_11.rst +5 -0
index 2133a5b9bb2e..643ec4d9103d 100644
@@ -104,6 +104,11 @@ New Features
   the specified port. The port must be stopped before the command call in order
   to reconfigure queues.
 
+* **Added Ethernet poll mode driver for Aquantia aQtion family of 10G devices.**
+
+  Added the new ``atlantic`` ethernet poll mode driver for Aquantia XGBE devices.
+  See the :doc:`../nics/atlantic` nic driver guide for more details on this
+  driver.
 
 API Changes
 -----------
Signature · 1 line
2.7.4
#4 lore raw

Re: [PATCH v4 02/22] net/atlantic: logging macroes and some typedefs

In reply to Igor Russkikh
Quoted 2 lines · Igor Russkikh

<...>

drivers/net/atlantic/atl_ethdev.c atl_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) · line 177

Quoted 8 lines
drivers/net/atlantic/atl_ethdev.c +4 -0
@@ -168,3 +171,16 @@ atl_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 RTE_PMD_REGISTER_PCI(net_atlantic, rte_atl_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_atlantic, pci_id_atl_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_atlantic, "* igb_uio | uio_pci_generic");
+
+RTE_INIT(atl_init_log);
+static void
+atl_init_log(void)

You can merge these two:

RTE_INIT(atl_init_log)
{
....
}

drivers/net/atlantic/atl_ethdev.c atl_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) · line 179

Quoted 2 lines
drivers/net/atlantic/atl_ethdev.c +2 -0
+{
+	atl_logtype_init = rte_log_register("pmd.atlantic.init");

Log type string format is "pmd.net.atlantic.init"

drivers/net/atlantic/atl_ethdev.c atl_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) · line 182

Quoted 3 lines
drivers/net/atlantic/atl_ethdev.c +3 -0
+	if (atl_logtype_init >= 0)
+		rte_log_set_level(atl_logtype_init, RTE_LOG_DEBUG);
+	atl_logtype_driver = rte_log_register("pmd.atlantic.driver");

same here related to format.

#11 lore raw

Re: [PATCH v4 07/22] net/atlantic: rte device start, stop, initial configuration

In reply to Igor Russkikh
Quoted 8 lines · Igor Russkikh

From: Pavel Belous <[email protected]>

Start, stop and reset are all done via hw_atl layer. Link interrupt configuration is also done here.

<...>

drivers/net/atlantic/atl_ethdev.c static const struct eth_dev_ops atl_eth_dev_ops = { · line 96

Quoted 2 lines
drivers/net/atlantic/atl_ethdev.c +2 -0
+static void
+atl_print_adapter_info(struct aq_hw_s *hw __rte_unused)

"hw" is used below, you can drop __rte_unused

<...>

drivers/net/atlantic/atl_ethdev.c static const struct eth_dev_ops atl_eth_dev_ops = { · line 122

Quoted 5 lines
drivers/net/atlantic/atl_ethdev.c +5 -0
+	/* For secondary processes, the primary process has done all the work */
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+		return 0;
+
+	rte_eth_copy_pci_info(eth_dev, pci_dev);

This shouldn't be required, done in rte_eth_dev_pci_allocate() just before calling this function, can you please double check?

<...>

drivers/net/atlantic/atl_ethdev.c static const struct eth_dev_ops atl_eth_dev_ops = { · line 148

Quoted 3 lines
drivers/net/atlantic/atl_ethdev.c +3 -0
+	/* Copy the permanent MAC address */
+	if (hw->aq_fw_ops->get_mac_permanent(hw,
+			(u8 *)&eth_dev->data->mac_addrs[0]) != 0)

You can use "eth_dev->data->mac_addrs->addr_bytes" to prevent casting but both same eventually

<...>

drivers/net/atlantic/atl_ethdev.c static const struct eth_dev_ops atl_eth_dev_ops = { · line 176

Quoted 3 lines
drivers/net/atlantic/atl_ethdev.c +3 -0
+#ifdef RTE_LIBRTE_SECURITY
+	rte_free(eth_dev->security_ctx);
+#endif

I think "eth_dev->security_ctx" should be allocated in the driver, if you are not allocating it, you don't need to free it.

<...>

drivers/net/atlantic/atl_ethdev.c atl_dev_configure(struct rte_eth_dev *dev __rte_unused) · line 244

Quoted 10 lines

static void

drivers/net/atlantic/atl_ethdev.c +7 -1
-atl_dev_stop(struct rte_eth_dev *dev __rte_unused)
+atl_dev_stop(struct rte_eth_dev *dev)
 {
+	struct aq_hw_s *hw =
+		ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+	/* reset the NIC */
+	atl_reset_hw(hw);
+	hw->adapter_stopped = 0;

Just to double check, below in close() there is an "atl_dev_stop(dev);" called, which look like for stop, should it be called here too?

And the state "hw->adapter_stopped", should it be "0" or "1" when device stopped?

<...>

drivers/net/atlantic/atl_ethdev.c atl_dev_reset(struct rte_eth_dev *dev) · line 287

Quoted 10 lines
drivers/net/atlantic/atl_ethdev.c +10 -0
+static int
+atl_fw_version_get(struct rte_eth_dev *dev, char *fw_version, size_t fw_size)
+{
+	struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	uint32_t fw_ver = 0;
+	unsigned int ret = 0;
+
+	ret = hw_atl_utils_get_fw_version(hw, &fw_ver);
+	if (ret)
+		return 0;

Why not return error for this case?

#17 lore raw

Re: [PATCH v4 11/22] net/atlantic: link status and interrupt management

In reply to Igor Russkikh
Quoted 6 lines · Igor Russkikh

From: Pavel Belous <[email protected]>

Implement link interrupt, link info, link polling.

<...>

Quoted 41 lines
drivers/net/atlantic/atl_ethdev.c +41 -0
+/**
+ * Atomically reads the link status information from global
+ * structure rte_eth_dev.
+ *
+ * @param dev
+ *   - Pointer to the structure rte_eth_dev to read from.
+ *   - Pointer to the buffer to be saved with the link status.
+ *
+ * @return
+ *   - On success, zero.
+ *   - On failure, negative value.
+ */
+static inline int
+rte_atl_dev_atomic_read_link_status(struct rte_eth_dev *dev,
+				struct rte_eth_link *link)
+{
+	struct rte_eth_link *dst = link;
+	struct rte_eth_link *src = &dev->data->dev_link;
+
+	if (rte_atomic64_cmpset((uint64_t *)dst, *(uint64_t *)dst,
+					*(uint64_t *)src) == 0)
+		return -1;
+
+	return 0;
+}
+
+/**
+ * Atomically writes the link status information into global
+ * structure rte_eth_dev.
+ *
+ * @param dev
+ *   - Pointer to the structure rte_eth_dev to read from.
+ *   - Pointer to the buffer to be saved with the link status.
+ *
+ * @return
+ *   - On success, zero.
+ *   - On failure, negative value.
+ */
+static inline int
+rte_atl_dev_atomic_write_link_status(struct rte_eth_dev *dev,
+				struct rte_eth_link *link)

drivers/net/atlantic/atl_ethdev.c static const struct eth_dev_ops atl_eth_dev_ops = { · line 201

Quoted 10 lines
drivers/net/atlantic/atl_ethdev.c +10 -0
+{
+	struct rte_eth_link *dst = &dev->data->dev_link;
+	struct rte_eth_link *src = link;
+
+	if (rte_atomic64_cmpset((uint64_t *)dst, *(uint64_t *)dst,
+					*(uint64_t *)src) == 0)
+		return -1;
+
+	return 0;
+}

No need to implement atomic link status read/writes in PMDs anymore, new common functions for it added:
rte_eth_linkstatus_get()
rte_eth_linkstatus_set()

#19 lore raw

Re: [PATCH v4 12/22] net/atlantic: device statistics, xstats

In reply to Igor Russkikh
Quoted 4 lines · Igor Russkikh

From: Pavel Belous <[email protected]>

<...>

drivers/net/atlantic/atl_ethdev.c atl_dev_reset(struct rte_eth_dev *dev) · line 714

Quoted 9 lines
drivers/net/atlantic/atl_ethdev.c +9 -0
+static void
+atl_dev_stats_reset(struct rte_eth_dev *dev)
+{
+	struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+	hw->aq_fw_ops->update_stats(hw);
+
+	/* Reset software totals */
+	memset(&hw->curr_stats, 0, sizeof(hw->curr_stats));

Where "adapter->sw_stats" reset?

<...>

drivers/net/atlantic/atl_ethdev.c atl_dev_reset(struct rte_eth_dev *dev) · line 758

Quoted 4 lines
drivers/net/atlantic/atl_ethdev.c +4 -0
+static void
+atl_dev_xstats_reset(struct rte_eth_dev *dev __rte_unused)
+{
+}

Shouldn't this reset the hw->curr_stats? Instead of implementing this fucntion you can reuse atl_dev_stats_reset() as ".xstats_reset" since it seems there is not specific need for xstats_reset

drivers/net/atlantic/atl_ethdev.c atl_dev_reset(struct rte_eth_dev *dev) · line 768

Quoted 10 lines
drivers/net/atlantic/atl_ethdev.c +10 -0
+
+static int
+atl_dev_queue_stats_mapping_set(struct rte_eth_dev *eth_dev __rte_unused,
+					     uint16_t queue_id __rte_unused,
+					     uint8_t stat_idx __rte_unused,
+					     uint8_t is_rx __rte_unused)
+{
+	/* The mapping is hardcoded: queue 0 -> stat 0, etc */
+	return 0;
+}

No need to add this function if there is no specific mapping requirement.

#25 lore raw

Re: [PATCH v4 17/22] net/atlantic: MAC address manipulations

In reply to Igor Russkikh
Quoted 13 lines · Igor Russkikh

From: Pavel Belous <[email protected]>

---
 drivers/net/atlantic/atl_ethdev.c | 126 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 126 insertions(+)
drivers/net/atlantic/atl_ethdev.c +0 -0
index efdd83fb4d6b..3f0d2e26d7da 100644

drivers/net/atlantic/atl_ethdev.c static void atl_dev_info_get(struct rte_eth_dev *dev, · line 57

Quoted 4 lines
drivers/net/atlantic/atl_ethdev.c +1 -0
@@ -54,6 +54,8 @@ static void atl_dev_info_get(struct rte_eth_dev *dev,
 
 static const uint32_t *atl_dev_supported_ptypes_get(struct rte_eth_dev *dev);
 
+static int atl_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu);

You can separate adding MTU support on its own patch.

#14 lore raw

Re: [PATCH v4 09/22] net/atlantic: RX side structures and implementation

In reply to Igor Russkikh
Quoted 2 lines · Igor Russkikh

<...>

drivers/net/atlantic/atl_rxtx.c atl_prep_pkts(void *tx_queue __rte_unused, · line 353

Quoted 10 lines
drivers/net/atlantic/atl_rxtx.c +9 -0
+int
+atl_start_queues(struct rte_eth_dev *dev)
 {
+	int i;
+
+	PMD_INIT_FUNC_TRACE();
+
+	for (i = 0; i < dev->data->nb_rx_queues; i++) {
+		if (atl_rx_queue_start(dev, i) != 0) {
+			PMD_DRV_LOG(ERR, "Start Rx queue %d failed", i);

When there are multiple port it can be hard to find out queue of which port, you may want to add port_id information too in logs.

This comment is valid for multiple places.

#34 lore raw

Re: [PATCH v4 22/22] net/atlantic: documentation and rel notes

In reply to Igor Russkikh
Quoted 2 lines · Igor Russkikh

<...>

doc/guides/nics/atlantic.rst line 7

Quoted 8 lines
doc/guides/nics/atlantic.rst new file +7 -0
@@ -0,0 +1,53 @@
+..  SPDX-License-Identifier: BSD-3-Clause
+    Copyright(c) 2018 Aquantia Corporation.
+
+Aquantia Atlantic DPDK Driver
+=============================
+
+Atlantic DPDK driver provides DPDK support for Aquantia's AQtion family of chipsets: AQC107/AQC108/AQC109

Can you please provide links to the devices mentioned?

<...>

Quoted 28 lines
doc/guides/nics/features/atlantic.ini new file +27 -0
@@ -0,0 +1,37 @@
+;
+; Supported features of the 'atlantic' network poll mode driver.
+;
+; Refer to default.ini for the full list of available PMD features.
+;
+[Features]
+Speed capabilities   = Y
+Link status          = Y
+Link status event    = Y
+MTU update           = Y
+Jumbo frame          = Y
+Promiscuous mode     = Y
+Allmulticast mode    = Y
+Unicast MAC filter   = Y
+VLAN filter          = Y
+Flow control         = Y
+CRC offload          = Y
+VLAN offload         = Y
+L3 checksum offload  = Y
+L4 checksum offload  = Y
+Rx descriptor status = Y
+Tx descriptor status = Y
+Basic stats          = Y
+Extended stats       = Y
+Stats per queue      = Y
+Linux UIO            = Y
+x86-32               = Y

doc/guides/nics/features/atlantic.ini line 37

Quoted 10 lines
doc/guides/nics/features/atlantic.ini new file +10 -0
+x86-64               = Y
+Queue start/stop     = Y
+RSS hash             = Y
+RSS key update       = Y
+RSS reta update      = Y
+Packet type parsing  = Y
+FW version           = Y
+EEPROM dump          = Y
+Registers dump       = Y
+LED                  = Y

Can you please distribute this file to the patchset, update the relevant item in the patch that enables this feature, so that it becomes kind of documentation and help to track the code which enabled a feature.

And please keep the order of the default.ini

#2 lore raw

Re: [PATCH v4 01/22] net/atlantic: atlantic PMD driver skeleton

In reply to Igor Russkikh
Quoted 7 lines · Igor Russkikh

From: Pavel Belous <[email protected]>

Makefile/meson build infrastructure, atl_ethdev minimal skeleton, header with aquantia aQtion NIC device and vendor IDs.

Quoted 12 lines
---
 config/common_base                                |   5 +
 config/defconfig_ppc_64-power8-linuxapp-gcc       |   1 +
 drivers/net/Makefile                              |   1 +
 drivers/net/atlantic/Makefile                     |  27 ++++
 drivers/net/atlantic/atl_common.h                 |  96 ++++++++++++
 drivers/net/atlantic/atl_ethdev.c                 | 170 ++++++++++++++++++++++
 drivers/net/atlantic/atl_ethdev.h                 |  15 ++
 drivers/net/atlantic/meson.build                  |   6 +
 drivers/net/atlantic/rte_pmd_atlantic_version.map |   4 +
 drivers/net/meson.build                           |   1 +
 mk/rte.app.mk                                     |   1 +

Need to update MAINTAINERS file to add new PMD and maintainer and files of it.

#7 lore raw

Re: [PATCH v4 04/22] net/atlantic: hw_atl register declarations

In reply to Igor Russkikh
Quoted 5 lines · Igor Russkikh

This hw_atl layer is maintained in sync with linux kernel driver. It will generally be in sync with linux upstream.

<...>

drivers/net/atlantic/hw_atl/hw_atl_llh.h line 711

Quoted 2 lines
drivers/net/atlantic/hw_atl/hw_atl_llh.h new file +2 -0
+/* set uP Force Interrupt */
+void mcp_up_force_intr_set(struct aq_hw_s *aq_hw, u32 up_force_intr);

This one doesn't have hw_atl prefix as others do, it seems this only non-static function with a prefix, can be possible to add a prefix to this one too?

#29 lore raw

Re: [PATCH v4 20/22] net/atlantic: LED control DPDK and private APIs

In reply to Igor Russkikh
Quoted 2 lines · Igor Russkikh

<...>

Quoted 11 lines
drivers/net/atlantic/rte_pmd_atlantic.h new file +11 -0
+/**
+ * This is a custom API for adapter's LED controls.
+ *
+ * @param dev
+ *   Ethernet device to apply control to
+ * @param control
+ *   6 bit value (3 leds each 2bit):
+ *   - bits 0-1: LED0 control
+ *   - bits 2-3: LED1 control
+ *   - bits 4-5: LED2 control
+ *   Each two bit control value is:

drivers/net/atlantic/rte_pmd_atlantic.h line 41

Quoted 10 lines
drivers/net/atlantic/rte_pmd_atlantic.h new file +10 -0
+ *   - 0: Firmware manages this LED activity
+ *   - 1: Permanent ON
+ *   - 2: Blinking
+ *   - 3: Permanent OFF
+ *
+ * @return
+ *   - (0) if successful.
+ *   - (-ENOTSUP) if hardware doesn't support.
+ */
+int rte_pmd_atl_dev_led_control(int port, int control);

What is the intention here, making PMD specific public API? If so .map file is missing but we discourage using PMD specific APIs,

can't it be possible to extend exiting led related dev_ops in a generic way to cover your use case?

#35 lore raw
In reply to Igor Russkikh
Quoted 49 lines · Igor Russkikh

Hello DPDK community!

Aquantia would like to contribute PMD for aQtion AQC10X NIC family:
https://www.aquantia.com/products/aqtion/chips/
These are 10G ethernet NICs with various features.

We do base this work on parts of the existing native linux kernel driver source (atlantic). Shared code is hw_atl hardware and registers access module.

We'd like to target this driver for 18.11 DPDK release timeline, it'd be good to hear comments from the community on how feasible is this.

This patchset implements basic driver infrastructure, vlan offloads, checksumm offloads, rss control, multiring, jumbo frames and other features.

Later on, we plan to share HW MACSEC offloads, rxflows and other features.

version 4 changes:
- fixed build errors with -Werror on gcc7
- validated build on arm64, freebsd x86_64
- PPC marked as unsupported arch
- stdbool.h is used instead of bool redefines

version 3 changes:
- patchset fixed to be incrementally buildable
- extra includes removed and cleaned up
- license changed to dual GPL-BSD for pieces shared with linux
- removed extra logging #defines
- misc comments from previous review session

version 2 changes:
- fixed build on freebsd (no ETIME const)
- fixed a bunch of checkpatch failures and warnings
- removed extra CFLAGS disabled warning
- making static arrays const

Igor Russkikh (9):
net/atlantic: logging macroes and some typedefs net/atlantic: hardware register access routines net/atlantic: hw_atl register declarations net/atlantic: firmware operations layer net/atlantic: b0 hardware layer main logic net/atlantic: RX side structures and implementation net/atlantic: RSS and RETA manipulation API net/atlantic: LED control DPDK and private APIs net/atlantic: documentation and rel notes

Quoted 14 lines

Pavel Belous (13):
net/atlantic: atlantic PMD driver skeleton net/atlantic: rte device start, stop, initial configuration net/atlantic: TX/RX function prototypes
net/atlantic: TX side structures and implementation net/atlantic: link status and interrupt management net/atlantic: device statistics, xstats
net/atlantic: support for RX/TX descriptors information net/atlantic: promisc and allmulti configuration net/atlantic: flow control configuration net/atlantic: MAC address manipulations
net/atlantic: VLAN filters and offloads
net/atlantic: eeprom and register manipulation routines net/atlantic: support for read MAC registers for debug purposes

Hi Igor,

I put some comments on individual patches, please check them.

Also can you please run "./devtools/check-git-log.sh -22" and fix reported warnings there?

Thanks,
ferruh

#36 lore raw
Quoted 6 lines · Ferruh Yigit

Hi Igor,

I put some comments on individual patches, please check them.

Also can you please run "./devtools/check-git-log.sh -22" and fix reported warnings there?

Hi Ferruh,

Thanks alot for the detailed review and comments, we'll rework the patchset soon.

Regards,
Igor

#30 lore raw

Re: [PATCH v4 20/22] net/atlantic: LED control DPDK and private APIs

In reply to Ferruh Yigit

Hi Ferruh,

Quoted 7 lines
Quoted 1 line

+int rte_pmd_atl_dev_led_control(int port, int control);

What is the intention here, making PMD specific public API? If so .map file is missing but we discourage using PMD specific APIs,

can't it be possible to extend exiting led related dev_ops in a generic way to cover your use case?

This API was specially requested by our customer.

I'm honestly not sure if such a functionality will be useful as a generic dev_ops. I'm not aware of any other NIC allowing detailed led control.

Maybe its better to drop this API from the patchset for now and resubmit later on as a separate feature patchset.

Is this ok with you?

Regards,
Igor

#31 lore raw

Re: [PATCH v4 20/22] net/atlantic: LED control DPDK and private APIs

Quoted 12 lines · Igor Russkikh

Hi Ferruh,

Quoted 7 lines
Quoted 1 line

+int rte_pmd_atl_dev_led_control(int port, int control);

What is the intention here, making PMD specific public API? If so .map file is missing but we discourage using PMD specific APIs,

can't it be possible to extend exiting led related dev_ops in a generic way to cover your use case?

This API was specially requested by our customer.

Quoted 7 lines

I'm honestly not sure if such a functionality will be useful as a generic dev_ops. I'm not aware of any other NIC allowing detailed led control.

Maybe its better to drop this API from the patchset for now and resubmit later on as a separate feature patchset.

Is this ok with you?

+1, I think better to have it as separate patch.