Skip to contentSkip to conversation

net/softnic: sw fall-back for traffic management

PATCH Superseded Jasvinder Singh 6 participants 79 messages May 26, 2017 – Oct 12, 2017 Network drivers

lore
Share & tools
lore
#0 lore raw

cover net/softnic: sw fall-back for traffic management

The SoftNIC PMD provides SW fall-back option for the NICs not supporting the Traffic Management (TM) features.

SoftNIC PMD overview:
- The SW fall-back is based on the existing librte_sched DPDK library.
- The TM-agnostic port (the underlay device) is wrapped into a TM-aware softnic port (the overlay device).
- Once the overlay device (virtual device) is created, the configuration of the underlay device is taking place through the overlay device.
- The SoftNIC PMD is generic, i.e. it works for any underlay device PMD that implements the ethdev API.

Similarly to Ring PMD, the SoftNIC virtual device can be created in two
different ways:
1. Through EAL command line (--vdev option)�
2.�Through the rte_eth_softnic_create() API function called by the application

SoftNIC PMD params:
- iface (mandatory): the ethdev port name (i.e. PCI address or vdev name) for the underlay device
- txq_id (optional, default = 0): tx queue id of the underlay device
- deq_bsz (optional, default = 24): traffic manager dequeue burst size
- Example:� --vdev 'net_softnic0,iface=0000:04:00.1,txq_id=0,deq_bsz=28'

SoftNIC PMD build instructions:
- To build SoftNIC PMD, the following parameter needs to be set on config/common_base file: CONFIG_RTE_LIBRTE_PMD_SOFTNIC=y
- The SoftNIC PMD depends on the TM API [1] and therefore is initially targeted for the tm-next repository

Patch 1 adds softnic device PMD for traffic management. Patch 2 adds traffic management ops to the softnic device suggested in generic ethdev API for traffic management[1].

[1] TM API version 4:�
http://www.dpdk.org/dev/patchwork/patch/24411/,
http://www.dpdk.org/dev/patchwork/patch/24412/

Jasvinder Singh (2):
net/softnic: add softnic PMD for traffic management net/softnic: add traffic management ops

 MAINTAINERS                                     |    5 +
 config/common_base                              |    5 +
 drivers/net/Makefile                            |    5 +
 drivers/net/softnic/Makefile                    |   58 ++
 drivers/net/softnic/rte_eth_softnic.c           |  578 ++++++++++++
 drivers/net/softnic/rte_eth_softnic.h           |   99 ++
 drivers/net/softnic/rte_eth_softnic_default.c   | 1104 +++++++++++++++++++++++
 drivers/net/softnic/rte_eth_softnic_internals.h |   93 ++
 drivers/net/softnic/rte_eth_softnic_tm.c        |  235 +++++
 drivers/net/softnic/rte_eth_softnic_version.map |    7 +
 mk/rte.app.mk                                   |    5 +-
 11 files changed, 2193 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/softnic/Makefile
 create mode 100644 drivers/net/softnic/rte_eth_softnic.c
 create mode 100644 drivers/net/softnic/rte_eth_softnic.h
 create mode 100644 drivers/net/softnic/rte_eth_softnic_default.c
 create mode 100644 drivers/net/softnic/rte_eth_softnic_internals.h
 create mode 100644 drivers/net/softnic/rte_eth_softnic_tm.c
 create mode 100644 drivers/net/softnic/rte_eth_softnic_version.map
Signature · 1 line
2.9.3
#1 lore raw

PATCH 1/2 net/softnic: add softnic PMD for traffic management

Softnic PMD implements HQoS scheduler as software fallback solution for the hardware with no HQoS support. When application call rx function on this device, it simply invokes underlay device rx function. On the egress path, softnic tx funtion enqueues the packets into QoS scheduler. The packets are dequeued from the QoS scheduler and sent to the underlay device through the rte_eth_softnic_run() API.

---
 MAINTAINERS                                     |    5 +
 config/common_base                              |    5 +
 drivers/net/Makefile                            |    5 +
 drivers/net/softnic/Makefile                    |   57 ++
 drivers/net/softnic/rte_eth_softnic.c           |  535 +++++++++++
 drivers/net/softnic/rte_eth_softnic.h           |   99 ++
 drivers/net/softnic/rte_eth_softnic_default.c   | 1104 +++++++++++++++++++++++
 drivers/net/softnic/rte_eth_softnic_internals.h |   67 ++
 drivers/net/softnic/rte_eth_softnic_version.map |    7 +
 mk/rte.app.mk                                   |    5 +-
 10 files changed, 1888 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/softnic/Makefile
 create mode 100644 drivers/net/softnic/rte_eth_softnic.c
 create mode 100644 drivers/net/softnic/rte_eth_softnic.h
 create mode 100644 drivers/net/softnic/rte_eth_softnic_default.c
 create mode 100644 drivers/net/softnic/rte_eth_softnic_internals.h
 create mode 100644 drivers/net/softnic/rte_eth_softnic_version.map
MAINTAINERS +5 -0
index cdaf2ac..16a53de 100644
@@ -490,6 +490,11 @@ M: Tetsuya Mukawa <[email protected]>
 F: drivers/net/null/
 F: doc/guides/nics/features/null.ini
 
+Softnic PMD
+M: Jasvinder Singh <[email protected]>
+M: Cristian Dumitrescu <[email protected]>
+F: drivers/net/softnic
+
 
 Crypto Drivers
 --------------
config/common_base +5 -0
index 8907bea..f526b90 100644
@@ -273,6 +273,11 @@ CONFIG_RTE_LIBRTE_SFC_EFX_PMD=y
 CONFIG_RTE_LIBRTE_SFC_EFX_DEBUG=n
 
 #
+# Compile SOFTNIC PMD
+#
+CONFIG_RTE_LIBRTE_PMD_SOFTNIC=y
+
+#
 # Compile software PMD backed by SZEDATA2 device
 #
 CONFIG_RTE_LIBRTE_PMD_SZEDATA2=n
drivers/net/Makefile +5 -0
index 35ed813..db73d33 100644
@@ -108,4 +108,9 @@ DIRS-$(CONFIG_RTE_LIBRTE_PMD_VHOST) += vhost
 endif # $(CONFIG_RTE_LIBRTE_VHOST)
 DEPDIRS-vhost = $(core-libs) librte_vhost
 
+ifeq ($(CONFIG_RTE_LIBRTE_SCHED),y)
+DIRS-$(CONFIG_RTE_LIBRTE_PMD_SOFTNIC) += softnic
+endif # $(CONFIG_RTE_LIBRTE_SCHED)
+DEPDIRS-sched = $(core-libs) librte_sched
+
 include $(RTE_SDK)/mk/rte.subdir.mk
drivers/net/softnic/Makefile new file +57 -0

57 lines not on this page · raw message

drivers/net/softnic/rte_eth_softnic.c new file +535 -0

535 lines not on this page · raw message

drivers/net/softnic/rte_eth_softnic.h new file +99 -0

99 lines not on this page · raw message

drivers/net/softnic/rte_eth_softnic_default.c new file +1104 -0

1,104 lines not on this page · raw message

drivers/net/softnic/rte_eth_softnic_internals.h new file +67 -0

67 lines not on this page · raw message

drivers/net/softnic/rte_eth_softnic_version.map new file +7 -0
new file mode 100644
index 0000000..bb730e5
@@ -0,0 +1,7 @@
+DPDK_17.08 {
+	global:
+	rte_eth_softnic_create;
+	rte_eth_softnic_run;
+
+	local: *;
+};
mk/rte.app.mk +4 -1
index bcaf1b3..be13730 100644
@@ -66,7 +66,6 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_PDUMP)          += -lrte_pdump
 _LDLIBS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR)    += -lrte_distributor
 _LDLIBS-$(CONFIG_RTE_LIBRTE_IP_FRAG)        += -lrte_ip_frag
 _LDLIBS-$(CONFIG_RTE_LIBRTE_METER)          += -lrte_meter
-_LDLIBS-$(CONFIG_RTE_LIBRTE_SCHED)          += -lrte_sched
 _LDLIBS-$(CONFIG_RTE_LIBRTE_LPM)            += -lrte_lpm
 # librte_acl needs --whole-archive because of weak functions
 _LDLIBS-$(CONFIG_RTE_LIBRTE_ACL)            += --whole-archive
@@ -98,6 +97,7 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_RING)           += -lrte_ring
 _LDLIBS-$(CONFIG_RTE_LIBRTE_EAL)            += -lrte_eal
 _LDLIBS-$(CONFIG_RTE_LIBRTE_CMDLINE)        += -lrte_cmdline
 _LDLIBS-$(CONFIG_RTE_LIBRTE_REORDER)        += -lrte_reorder
+_LDLIBS-$(CONFIG_RTE_LIBRTE_SCHED)          += -lrte_sched
 
 ifeq ($(CONFIG_RTE_EXEC_ENV_LINUXAPP),y)
 _LDLIBS-$(CONFIG_RTE_LIBRTE_KNI)            += -lrte_kni
@@ -133,6 +133,9 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_NULL)       += -lrte_pmd_null
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_PCAP)       += -lrte_pmd_pcap -lpcap
 _LDLIBS-$(CONFIG_RTE_LIBRTE_QEDE_PMD)       += -lrte_pmd_qede
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_RING)       += -lrte_pmd_ring
+ifeq ($(CONFIG_RTE_LIBRTE_SCHED),y)
+_LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_SCHED)      += -lrte_pmd_sched
+endif
 _LDLIBS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD)    += -lrte_pmd_sfc_efx
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_SZEDATA2)   += -lrte_pmd_szedata2 -lsze2
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_TAP)        += -lrte_pmd_tap
Signature · 1 line
2.9.3
#2 lore raw

v2 cover net/softnic: sw fall-back for traffic management

The SoftNIC PMD provides SW fall-back option for the NICs not supporting the Traffic Management (TM) features.

SoftNIC PMD overview:
- The SW fall-back is based on the existing librte_sched DPDK library.
- The TM-agnostic port (the underlay device) is wrapped into a TM-aware softnic port (the overlay device).
- Once the overlay device (virtual device) is created, the configuration of the underlay device is taking place through the overlay device.
- The SoftNIC PMD is generic, i.e. it works for any underlay device PMD that implements the ethdev API.

Similarly to Ring PMD, the SoftNIC virtual device can be created in two different ways:
1. Through EAL command line (--vdev option)�
2.�Through the rte_eth_softnic_create() API function called by the
application.

SoftNIC PMD params:
- iface (mandatory): the ethdev port name (i.e. PCI address or vdev name) for the underlay device
- txq_id (optional, default = 0): tx queue id of the underlay device
- deq_bsz (optional, default = 24): traffic manager dequeue burst size
- Example:� --vdev 'net_softnic0,iface=0000:04:00.1,txq_id=0,deq_bsz=28'

SoftNIC PMD build instructions:
- To build SoftNIC PMD, the following parameter needs to be set on config/common_base file: CONFIG_RTE_LIBRTE_PMD_SOFTNIC=y
- The SoftNIC PMD depends on the TM API [1] and therefore is initially targeted for the tm-next repository

Patch 1 adds softnic device PMD for traffic management. Patch 2 adds traffic management ops to the softnic device suggested in generic ethdev API for traffic management[1].

[1] TM API version 6:�
http://dpdk.org/dev/patchwork/patch/25275/
http://dpdk.org/dev/patchwork/patch/25276/

Jasvinder Singh (2):
net/softnic: add softnic PMD for traffic management net/softnic: add traffic management ops

 MAINTAINERS                                     |    5 +
 config/common_base                              |    5 +
 drivers/net/Makefile                            |    5 +
 drivers/net/softnic/Makefile                    |   58 ++
 drivers/net/softnic/rte_eth_softnic.c           |  580 ++++++++++++
 drivers/net/softnic/rte_eth_softnic.h           |   99 ++
 drivers/net/softnic/rte_eth_softnic_default.c   | 1108 ++++++++++++++++++++++
 drivers/net/softnic/rte_eth_softnic_internals.h |  148 +++
 drivers/net/softnic/rte_eth_softnic_tm.c        | 1145 +++++++++++++++++++++++
 drivers/net/softnic/rte_eth_softnic_version.map |    7 +
 mk/rte.app.mk                                   |    5 +-
 11 files changed, 3164 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/softnic/Makefile
 create mode 100644 drivers/net/softnic/rte_eth_softnic.c
 create mode 100644 drivers/net/softnic/rte_eth_softnic.h
 create mode 100644 drivers/net/softnic/rte_eth_softnic_default.c
 create mode 100644 drivers/net/softnic/rte_eth_softnic_internals.h
 create mode 100644 drivers/net/softnic/rte_eth_softnic_tm.c
 create mode 100644 drivers/net/softnic/rte_eth_softnic_version.map
Signature · 1 line
2.9.3
#3 lore raw

PATCH v2 1/2 net/softnic: add softnic PMD for traffic management

Softnic PMD implements HQoS scheduler as software fallback solution for the hardware with no HQoS support. When application call rx function on this device, it simply invokes underlay device rx function. On the egress path, softnic tx function enqueues the packets into QoS scheduler. The packets are dequeued from the QoS scheduler and sent to the underlay device through the rte_eth_softnic_run() API.

---
v2 changes:
- fix build errors
- rebased to TM APIs v6 plus dpdk master

 MAINTAINERS                                     |    5 +
 config/common_base                              |    5 +
 drivers/net/Makefile                            |    5 +
 drivers/net/softnic/Makefile                    |   57 ++
 drivers/net/softnic/rte_eth_softnic.c           |  534 +++++++++++
 drivers/net/softnic/rte_eth_softnic.h           |   99 ++
 drivers/net/softnic/rte_eth_softnic_default.c   | 1108 +++++++++++++++++++++++
 drivers/net/softnic/rte_eth_softnic_internals.h |   67 ++
 drivers/net/softnic/rte_eth_softnic_version.map |    7 +
 mk/rte.app.mk                                   |    5 +-
 10 files changed, 1891 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/softnic/Makefile
 create mode 100644 drivers/net/softnic/rte_eth_softnic.c
 create mode 100644 drivers/net/softnic/rte_eth_softnic.h
 create mode 100644 drivers/net/softnic/rte_eth_softnic_default.c
 create mode 100644 drivers/net/softnic/rte_eth_softnic_internals.h
 create mode 100644 drivers/net/softnic/rte_eth_softnic_version.map
MAINTAINERS +5 -0
index 3c7414f..7136fde 100644
@@ -491,6 +491,11 @@ M: Tetsuya Mukawa <[email protected]>
 F: drivers/net/null/
 F: doc/guides/nics/features/null.ini
 
+Softnic PMD
+M: Jasvinder Singh <[email protected]>
+M: Cristian Dumitrescu <[email protected]>
+F: drivers/net/softnic
+
 
 Crypto Drivers
 --------------
config/common_base +5 -0
index f6aafd1..f4d33e0 100644
@@ -271,6 +271,11 @@ CONFIG_RTE_LIBRTE_SFC_EFX_PMD=y
 CONFIG_RTE_LIBRTE_SFC_EFX_DEBUG=n
 
 #
+# Compile SOFTNIC PMD
+#
+CONFIG_RTE_LIBRTE_PMD_SOFTNIC=y
+
+#
 # Compile software PMD backed by SZEDATA2 device
 #
 CONFIG_RTE_LIBRTE_PMD_SZEDATA2=n
drivers/net/Makefile +5 -0
index 35ed813..d3cba67 100644
@@ -108,4 +108,9 @@ DIRS-$(CONFIG_RTE_LIBRTE_PMD_VHOST) += vhost
 endif # $(CONFIG_RTE_LIBRTE_VHOST)
 DEPDIRS-vhost = $(core-libs) librte_vhost
 
+ifeq ($(CONFIG_RTE_LIBRTE_SCHED),y)
+DIRS-$(CONFIG_RTE_LIBRTE_PMD_SOFTNIC) += softnic
+endif # $(CONFIG_RTE_LIBRTE_SCHED)
+DEPDIRS-softnic = $(core-libs) librte_sched
+
 include $(RTE_SDK)/mk/rte.subdir.mk
drivers/net/softnic/Makefile new file +57 -0

57 lines not on this page · raw message

drivers/net/softnic/rte_eth_softnic.c new file +534 -0

534 lines not on this page · raw message

drivers/net/softnic/rte_eth_softnic.h new file +99 -0

99 lines not on this page · raw message

drivers/net/softnic/rte_eth_softnic_default.c new file +1108 -0

1,108 lines not on this page · raw message

drivers/net/softnic/rte_eth_softnic_internals.h new file +67 -0

67 lines not on this page · raw message

drivers/net/softnic/rte_eth_softnic_version.map new file +7 -0
new file mode 100644
index 0000000..bb730e5
@@ -0,0 +1,7 @@
+DPDK_17.08 {
+	global:
+	rte_eth_softnic_create;
+	rte_eth_softnic_run;
+
+	local: *;
+};
mk/rte.app.mk +4 -1
index bcaf1b3..de633cd 100644
@@ -66,7 +66,6 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_PDUMP)          += -lrte_pdump
 _LDLIBS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR)    += -lrte_distributor
 _LDLIBS-$(CONFIG_RTE_LIBRTE_IP_FRAG)        += -lrte_ip_frag
 _LDLIBS-$(CONFIG_RTE_LIBRTE_METER)          += -lrte_meter
-_LDLIBS-$(CONFIG_RTE_LIBRTE_SCHED)          += -lrte_sched
 _LDLIBS-$(CONFIG_RTE_LIBRTE_LPM)            += -lrte_lpm
 # librte_acl needs --whole-archive because of weak functions
 _LDLIBS-$(CONFIG_RTE_LIBRTE_ACL)            += --whole-archive
@@ -98,6 +97,7 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_RING)           += -lrte_ring
 _LDLIBS-$(CONFIG_RTE_LIBRTE_EAL)            += -lrte_eal
 _LDLIBS-$(CONFIG_RTE_LIBRTE_CMDLINE)        += -lrte_cmdline
 _LDLIBS-$(CONFIG_RTE_LIBRTE_REORDER)        += -lrte_reorder
+_LDLIBS-$(CONFIG_RTE_LIBRTE_SCHED)          += -lrte_sched
 
 ifeq ($(CONFIG_RTE_EXEC_ENV_LINUXAPP),y)
 _LDLIBS-$(CONFIG_RTE_LIBRTE_KNI)            += -lrte_kni
@@ -133,6 +133,9 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_NULL)       += -lrte_pmd_null
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_PCAP)       += -lrte_pmd_pcap -lpcap
 _LDLIBS-$(CONFIG_RTE_LIBRTE_QEDE_PMD)       += -lrte_pmd_qede
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_RING)       += -lrte_pmd_ring
+ifeq ($(CONFIG_RTE_LIBRTE_SCHED),y)
+_LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_SOFTNIC)    += -lrte_pmd_softnic
+endif
 _LDLIBS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD)    += -lrte_pmd_sfc_efx
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_SZEDATA2)   += -lrte_pmd_szedata2 -lsze2
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_TAP)        += -lrte_pmd_tap
Signature · 1 line
2.9.3
#4 lore raw

v3 cover net/softnic: sw fall-back pmd for traffic mgmt and others

The SoftNIC PMD is intended to provide SW fall-back options for specific ethdev APIs in a generic way to the NICs not supporting those features.

Currently, the only implemented ethdev API is Traffic Management (TM), but other ethdev APIs such as rte_flow, traffic metering & policing, etc can be easily implemented.

Overview:
* Generic: The SoftNIC PMD works with any "hard" PMD that implements the ethdev API. It does not change the "hard" PMD in any way.
* Creation: For any given "hard" ethdev port, the user can decide to create an associated "soft" ethdev port to drive the "hard" port. The "soft" port is a virtual device that can be created at app start-up through EAL vdev arg or later through the virtual device API.
* Configuration: The app explicitly decides which features are to be enabled on the "soft" port and which features are still to be used from the "hard" port. The app continues to explicitly configure both the "hard" and the "soft" ports after the creation of the "soft" port.
* RX/TX: The app reads packets from/writes packets to the "soft" port instead of the "hard" port. The RX and TX queues of the "soft" port are thread safe, as any ethdev.
* Execution: The "soft" port is a feature-rich NIC implemented by the CPU, so the run function of the "soft" port has to be executed by the CPU in order to get packets moving between "hard" port and the app.
* Meets the NFV vision: The app should be (almost) agnostic about the NIC implementation (different vendors/models, HW-SW mix), the app should not require changes to use different NICs, the app should use the same API for all NICs. If a NIC does not implement a specific feature, the HW should be augmented with SW to meet the functionality while still preserving the same API.

Traffic Management SW fall-back overview:
* Implements the ethdev traffic management API (rte_tm.h).
* Based on the existing librte_sched DPDK library.

Example: Create "soft" port for "hard" port "0000:04:00.1", enable the TM feature with default settings:

          --vdev 'net_softnic0,hard_name=0000:04:00.1,soft_tm=on' 

Q1: Why generic name, if only TM is supported (for now)?
A1: The intention is to have SoftNIC PMD implement many other (all?)
ethdev APIs under a single "ideal" ethdev, hence the generic name. The initial motivation is TM API, but the mechanism is generic and can be used for many other ethdev APIs. Somebody looking to provide SW fall-back for other ethdev API is likely to end up inventing the same, hence it would be good to consolidate all under a single PMD and have the user explicitly enable/disable the features it needs for each "soft" device.

Q2: Are there any performance requirements for SoftNIC?
A2: Yes, performance should be great/decent for every feature, otherwise
the SW fall-back is unusable, thus useless.

Q3: Why not change the "hard" device (and keep a single device) instead of
creating a new "soft" device (and thus having two devices)?
A3: This is not possible with the current librte_ether ethdev
implementation. The ethdev->dev_ops are defined as constant structure, so it cannot be changed per device (nor per PMD). The new ops also need memory space to store their context data structures, which requires updating the ethdev->data->dev_private of the existing device; at best, maybe a resize of ethdev->data->dev_private could be done, assuming that librte_ether will introduce a way to find out its size, but this cannot be done while device is running. Other side effects might exist, as the changes are very intrusive, plus it likely needs more changes in librte_ether.

Q4: Why not call the SW fall-back dev_ops directly in librte_ether for
devices which do not support the specific feature? If the device supports the capability, let's call its dev_ops, otherwise call the SW fall-back dev_ops.
A4: First, similar reasons to Q&A3. This fixes the need to change
ethdev->dev_ops of the device, but it does not do anything to fix the other significant issue of where to store the context data structures needed by the SW fall-back functions (which, in this approach, are called implicitly by librte_ether).
Second, the SW fall-back options should not be restricted arbitrarily by the librte_ether library, the decision should belong to the app. For example, the TM SW fall-back should not be limited to only librte_sched, which (like any SW fall-back) is limited to a specific hierarchy and feature set, it cannot do any possible hierarchy. If alternatives exist, the one to use should be picked by the app, not by the ethdev layer.

Q5: Why is the app required to continue to configure both the "hard" and
the "soft" devices even after the "soft" device has been created? Why not hiding the "hard" device under the "soft" device and have the "soft" device configure the "hard" device under the hood?
A5: This was the approach tried in the V2 of this patch set (overlay
"soft" device taking over the configuration of the underlay "hard" device) and eventually dropped due to increased complexity of having to keep the configuration of two distinct devices in sync with librte_ether implementation that is not friendly towards such approach. Basically, each ethdev API call for the overlay device needs to configure the overlay device, invoke the same configuration with possibly modified parameters for the underlay device, then resume the configuration of overlay device, turning this into a device emulation project.
V2 minuses: increased complexity (deal with two devices at same time); need to implement every ethdev API, even those not needed for the scope of SW fall-back; intrusive; sometimes have to silently take decisions that should be left to the app.
V3 pluses: lower complexity (only one device); only need to implement those APIs that are in scope of the SW fall-back; non-intrusive (deal with "hard" device through ethdev API); app decisions taken by the app in an explicit way.

Q6: Why expose the SW fall-back in a PMD and not in a SW library?
A6: The SW fall-back for an ethdev API has to implement that specific
ethdev API, (hence expose an ethdev object through a PMD), as opposed to providing a different API. This approach allows the app to use the same API (NFV vision). For example, we already have a library for TM SW fall-back (librte_sched) that can be called directly by the apps that need to call it outside of ethdev context (use-cases exist), but an app that works with TM-aware NICs through the ethdev TM API would have to be changed significantly in order to work with different TM-agnostic NICs through the librte_sched API.

Q7: Why have all the SW fall-backs in a single PMD? Why not develop
the SW fall-back for each different ethdev API in a separate PMD, then create a chain of "soft" devices for each "hard" device? Potentially, this results in smaller size PMDs that are easier to maintain.
A7: Arguments for single ethdev/PMD and against chain of ethdevs/PMDs:
1. All the existing PMDs for HW NICs implement a lot of features under the same PMD, so there is no reason for single PMD approach to break code modularity. See the V3 code, a lot of care has been taken for code modularity.
2. We should avoid the proliferation of SW PMDs.
3. A single device should be handled by a single PMD.
4. People are used with feature-rich PMDs, not with single-feature PMDs, so we change of mindset?
5. [Configuration nightmare] A chain of "soft" devices attached to single "hard" device requires the app to be aware that the N "soft" devices in the chain plus the "hard" device refer to the same HW device, and which device should be invoked to configure which feature. Also the length of the chain and functionality of each link is different for each HW device. This breaks the requirement of preserving the same API while working with different NICs (NFV). This most likely results in a configuration nightmare, nobody is going to seriously use this.
6. [Feature inter-dependecy] Sometimes different features need to be configured and executed together (e.g. share the same set of resources, are inter-dependent, etc), so it is better and more performant to do them in the same ethdev/PMD.
7. [Code duplication] There is a lot of duplication in the configuration code for the chain of ethdevs approach. The ethdev dev_configure, rx_queue_setup, tx_queue_setup API functions have to be implemented per device, and they become meaningless/inconsistent with the chain approach.
8. [Data structure duplication] The per device data structures have to be duplicated and read repeatedly for each "soft" ethdev. The ethdev device, dev_private, data, per RX/TX queue data structures have to be replicated per "soft" device. They have to be re-read for each stage, so the same cache misses are now multiplied with the number of stages in the chain.
9. [rte_ring proliferation] Thread safety requirements for ethdev RX/TXqueues require an rte_ring to be used for every RX/TX queue of each "soft" ethdev. This rte_ring proliferation unnecessarily increases the memory footprint and lowers performance, especially when each "soft" ethdev ends up on a different CPU core (ping-pong of cache lines).
10.[Meta-data proliferation] A chain of ethdevs is likely to result
in proliferation of meta-data that has to be passed between the ethdevs (e.g. policing needs the output of flow classification), which results in more cache line ping-pong between cores, hence performance drops.

Cristian Dumitrescu (4):
Jasvinder Singh (4):
net/softnic: add softnic PMD
net/softnic: add traffic management support
net/softnic: add TM capabilities ops
net/softnic: add TM hierarchy related ops

 MAINTAINERS                                     |    5 +
 config/common_base                              |    5 +
 drivers/net/Makefile                            |    5 +
 drivers/net/softnic/Makefile                    |   57 +
 drivers/net/softnic/rte_eth_softnic.c           |  867 ++++++
 drivers/net/softnic/rte_eth_softnic.h           |   70 +
 drivers/net/softnic/rte_eth_softnic_internals.h |  291 ++
 drivers/net/softnic/rte_eth_softnic_tm.c        | 3446 +++++++++++++++++++++++
 drivers/net/softnic/rte_eth_softnic_version.map |    7 +
 mk/rte.app.mk                                   |    5 +-
 10 files changed, 4757 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/softnic/Makefile
 create mode 100644 drivers/net/softnic/rte_eth_softnic.c
 create mode 100644 drivers/net/softnic/rte_eth_softnic.h
 create mode 100644 drivers/net/softnic/rte_eth_softnic_internals.h
 create mode 100644 drivers/net/softnic/rte_eth_softnic_tm.c
 create mode 100644 drivers/net/softnic/rte_eth_softnic_version.map
Signature · 1 line
2.9.3
#5 lore raw

PATCH v3 1/4 net/softnic: add softnic PMD

Add SoftNIC PMD to provide SW fall-back for ethdev APIs.

---
v3 changes:
- rebase to dpdk17.08 release

v2 changes:
- fix build errors
- rebased to TM APIs v6 plus dpdk master

 MAINTAINERS                                     |   5 +
 config/common_base                              |   5 +
 drivers/net/Makefile                            |   5 +
 drivers/net/softnic/Makefile                    |  56 +++
 drivers/net/softnic/rte_eth_softnic.c           | 609 ++++++++++++++++++++++++
 drivers/net/softnic/rte_eth_softnic.h           |  54 +++
 drivers/net/softnic/rte_eth_softnic_internals.h | 114 +++++
 drivers/net/softnic/rte_eth_softnic_version.map |   7 +
 mk/rte.app.mk                                   |   5 +-
 9 files changed, 859 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/softnic/Makefile
 create mode 100644 drivers/net/softnic/rte_eth_softnic.c
 create mode 100644 drivers/net/softnic/rte_eth_softnic.h
 create mode 100644 drivers/net/softnic/rte_eth_softnic_internals.h
 create mode 100644 drivers/net/softnic/rte_eth_softnic_version.map
MAINTAINERS +5 -0
index a0cd75e..b6b738d 100644
@@ -511,6 +511,11 @@ M: Gaetan Rivet <[email protected]>
 F: drivers/net/failsafe/
 F: doc/guides/nics/fail_safe.rst
 
+Softnic PMD
+M: Jasvinder Singh <[email protected]>
+M: Cristian Dumitrescu <[email protected]>
+F: drivers/net/softnic
+
 
 Crypto Drivers
 --------------
config/common_base +5 -0
index 5e97a08..1a0c77d 100644
@@ -273,6 +273,11 @@ CONFIG_RTE_LIBRTE_SFC_EFX_PMD=y
 CONFIG_RTE_LIBRTE_SFC_EFX_DEBUG=n
 
 #
+# Compile SOFTNIC PMD
+#
+CONFIG_RTE_LIBRTE_PMD_SOFTNIC=y
+
+#
 # Compile software PMD backed by SZEDATA2 device
 #
 CONFIG_RTE_LIBRTE_PMD_SZEDATA2=n
drivers/net/Makefile +5 -0
index d33c959..b552a51 100644
@@ -110,4 +110,9 @@ DIRS-$(CONFIG_RTE_LIBRTE_PMD_VHOST) += vhost
 endif # $(CONFIG_RTE_LIBRTE_VHOST)
 DEPDIRS-vhost = $(core-libs) librte_vhost
 
+ifeq ($(CONFIG_RTE_LIBRTE_SCHED),y)
+DIRS-$(CONFIG_RTE_LIBRTE_PMD_SOFTNIC) += softnic
+endif # $(CONFIG_RTE_LIBRTE_SCHED)
+DEPDIRS-softnic = $(core-libs) librte_sched
+
 include $(RTE_SDK)/mk/rte.subdir.mk
drivers/net/softnic/Makefile new file +56 -0

56 lines not on this page · raw message

drivers/net/softnic/rte_eth_softnic.c new file +609 -0

609 lines not on this page · raw message

drivers/net/softnic/rte_eth_softnic.h new file +54 -0

54 lines not on this page · raw message

drivers/net/softnic/rte_eth_softnic_internals.h new file +114 -0

114 lines not on this page · raw message

drivers/net/softnic/rte_eth_softnic_version.map new file +7 -0
new file mode 100644
index 0000000..fb2cb68
@@ -0,0 +1,7 @@
+DPDK_17.11 {
+	global:
+
+	rte_pmd_softnic_run;
+
+	local: *;
+};
mk/rte.app.mk +4 -1
index c25fdd9..3dc82fb 100644
@@ -67,7 +67,6 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR)    += -lrte_distributor
 _LDLIBS-$(CONFIG_RTE_LIBRTE_IP_FRAG)        += -lrte_ip_frag
 _LDLIBS-$(CONFIG_RTE_LIBRTE_GRO)            += -lrte_gro
 _LDLIBS-$(CONFIG_RTE_LIBRTE_METER)          += -lrte_meter
-_LDLIBS-$(CONFIG_RTE_LIBRTE_SCHED)          += -lrte_sched
 _LDLIBS-$(CONFIG_RTE_LIBRTE_LPM)            += -lrte_lpm
 # librte_acl needs --whole-archive because of weak functions
 _LDLIBS-$(CONFIG_RTE_LIBRTE_ACL)            += --whole-archive
@@ -99,6 +98,7 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_RING)           += -lrte_ring
 _LDLIBS-$(CONFIG_RTE_LIBRTE_EAL)            += -lrte_eal
 _LDLIBS-$(CONFIG_RTE_LIBRTE_CMDLINE)        += -lrte_cmdline
 _LDLIBS-$(CONFIG_RTE_LIBRTE_REORDER)        += -lrte_reorder
+_LDLIBS-$(CONFIG_RTE_LIBRTE_SCHED)          += -lrte_sched
 
 ifeq ($(CONFIG_RTE_EXEC_ENV_LINUXAPP),y)
 _LDLIBS-$(CONFIG_RTE_LIBRTE_KNI)            += -lrte_kni
@@ -135,6 +135,9 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_NULL)       += -lrte_pmd_null
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_PCAP)       += -lrte_pmd_pcap -lpcap
 _LDLIBS-$(CONFIG_RTE_LIBRTE_QEDE_PMD)       += -lrte_pmd_qede
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_RING)       += -lrte_pmd_ring
+ifeq ($(CONFIG_RTE_LIBRTE_SCHED),y)
+_LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_SOFTNIC)      += -lrte_pmd_softnic
+endif
 _LDLIBS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD)    += -lrte_pmd_sfc_efx
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_SZEDATA2)   += -lrte_pmd_szedata2 -lsze2
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_TAP)        += -lrte_pmd_tap
Signature · 1 line
2.9.3
#6 lore raw

Re: [PATCH v3 1/4] net/softnic: add softnic PMD

Quoted 12 lines · Jasvinder Singh

Add SoftNIC PMD to provide SW fall-back for ethdev APIs.

---
v3 changes:
- rebase to dpdk17.08 release

v2 changes:
- fix build errors
- rebased to TM APIs v6 plus dpdk master

Quoted 9 lines
 MAINTAINERS                                     |   5 +
 config/common_base                              |   5 +
 drivers/net/Makefile                            |   5 +
 drivers/net/softnic/Makefile                    |  56 +++
 drivers/net/softnic/rte_eth_softnic.c           | 609 ++++++++++++++++++++++++
 drivers/net/softnic/rte_eth_softnic.h           |  54 +++
 drivers/net/softnic/rte_eth_softnic_internals.h | 114 +++++
 drivers/net/softnic/rte_eth_softnic_version.map |   7 +
 mk/rte.app.mk                                   |   5 +-

Also documentation updates are required:
- .ini file
- PMD documentation .rst file
- I believe it is good to update release note about new PMD
- release notes library version info, since this has public API

<...>

Quoted 1 line

+EXPORT_MAP := rte_eth_softnic_version.map

rte_pmd_... to be consistent.

<...>

drivers/net/softnic/Makefile line 54

Quoted 4 lines
drivers/net/softnic/Makefile new file +4 -0
+#
+# Export include files
+#
+SYMLINK-y-include +=rte_eth_softnic.h

space after +=

<...>

Quoted 1 line
drivers/net/softnic/rte_eth_softnic.c +0 -0

<...>

drivers/net/softnic/rte_eth_softnic.c

Quoted 2 lines
drivers/net/softnic/rte_eth_softnic.c +2 -0
+
+static struct rte_vdev_driver pmd_drv;

Why this is required, already defined below.
And for naming, pmd=poll mode driver, drv=driver, makes "poll mode driver driver"

<...>

Quoted 7 lines
drivers/net/softnic/rte_eth_softnic.c +7 -0
+static int
+pmd_rx_queue_setup(struct rte_eth_dev *dev,
+	uint16_t rx_queue_id,
+	uint16_t nb_rx_desc __rte_unused,
+	unsigned int socket_id,
+	const struct rte_eth_rxconf *rx_conf __rte_unused,
+	struct rte_mempool *mb_pool __rte_unused)

drivers/net/softnic/rte_eth_softnic.c line 115

Quoted 10 lines
drivers/net/softnic/rte_eth_softnic.c +10 -0
+{
+	struct pmd_internals *p = dev->data->dev_private;
+
+	if (p->params.soft.intrusive == 0) {
+		struct pmd_rx_queue *rxq;
+
+		rxq = rte_zmalloc_socket(p->params.soft.name,
+			sizeof(struct pmd_rx_queue), 0, socket_id);
+		if (rxq == NULL)
+			return -1;

return -ENOMEM ?

drivers/net/softnic/rte_eth_softnic.c line 128

Quoted 12 lines
drivers/net/softnic/rte_eth_softnic.c +12 -0
+
+		rxq->hard.port_id = p->hard.port_id;
+		rxq->hard.rx_queue_id = rx_queue_id;
+		dev->data->rx_queues[rx_queue_id] = rxq;
+	} else {
+		struct rte_eth_dev *hard_dev =
+			&rte_eth_devices[p->hard.port_id];> +		void *rxq = hard_dev->data->rx_queues[rx_queue_id];
+
+		if (rxq == NULL)
+			return -1;
+
+		dev->data->rx_queues[rx_queue_id] = rxq;

This assigns underlying hw queue as this soft PMD queue, what happens if two different cores, one polls the actual hw device and other polls the this virtual device, since both are indeed same queues?

Quoted 4 lines
drivers/net/softnic/rte_eth_softnic.c +4 -0
+	}
+	return 0;
+}
+

<...>

Quoted 25 lines
drivers/net/softnic/rte_eth_softnic.c +25 -0
+static __rte_always_inline int
+rte_pmd_softnic_run_default(struct rte_eth_dev *dev)
+{
+	struct pmd_internals *p = dev->data->dev_private;
+
+	/* Persistent context: Read Only (update not required) */
+	struct rte_mbuf **pkts = p->soft.def.pkts;
+	uint16_t nb_tx_queues = dev->data->nb_tx_queues;
+
+	/* Persistent context: Read - Write (update required) */
+	uint32_t txq_pos = p->soft.def.txq_pos;
+	uint32_t pkts_len = p->soft.def.pkts_len;
+	uint32_t flush_count = p->soft.def.flush_count;
+
+	/* Not part of the persistent context */
+	uint32_t pos;
+	uint16_t i;
+
+	/* Soft device TXQ read, Hard device TXQ write */
+	for (i = 0; i < nb_tx_queues; i++) {
+		struct rte_ring *txq = dev->data->tx_queues[txq_pos];
+
+		/* Read soft device TXQ burst to packet enqueue buffer */
+		pkts_len += rte_ring_sc_dequeue_burst(txq,
+			(void **) &pkts[pkts_len],

drivers/net/softnic/rte_eth_softnic.c line 266

Quoted 10 lines
drivers/net/softnic/rte_eth_softnic.c +10 -0
+			DEFAULT_BURST_SIZE,
+			NULL);
+
+		/* Increment soft device TXQ */
+		txq_pos++;
+		if (txq_pos >= nb_tx_queues)
+			txq_pos = 0;
+
+		/* Hard device TXQ write when complete burst is available */
+		if (pkts_len >= DEFAULT_BURST_SIZE) {

There questions:
1- When there are multiple tx_queues of softnic, and assume all will be processed by a core, this core will be reading from all into single HW queue, won' this create a bottle neck?

2- This logic reads from all queues as BURST_SIZE and merges them, if queues split with a RSS or similar, that clasiffication will be lost, will it be problem?

3- If there is not enough packets in the queues ( < DEFAULT_BURST_SIZE) those packets won't be transmitted unless more is comming, will this create latency for those cases?

drivers/net/softnic/rte_eth_softnic.c line 279

Quoted 13 lines
drivers/net/softnic/rte_eth_softnic.c +13 -0
+			for (pos = 0; pos < pkts_len; )
+				pos += rte_eth_tx_burst(p->hard.port_id,
+					p->params.hard.tx_queue_id,
+					&pkts[pos],
+					(uint16_t) (pkts_len - pos));
+
+			pkts_len = 0;
+			flush_count = 0;
+			break;
+		}
+	}
+
+	if (flush_count >= FLUSH_COUNT_THRESHOLD) {

FLUSH_COUNT_THRESHOLD is (1 << 17), and if no packet is sent, flash count incremented by one, just want to confirm the treshold value?

And why this flush exists?

Quoted 11 lines
drivers/net/softnic/rte_eth_softnic.c +11 -0
+		for (pos = 0; pos < pkts_len; )
+			pos += rte_eth_tx_burst(p->hard.port_id,
+				p->params.hard.tx_queue_id,
+				&pkts[pos],
+				(uint16_t) (pkts_len - pos));
+
+		pkts_len = 0;
+		flush_count = 0;
+	}
+
+	p->soft.def.txq_pos = txq_pos;

drivers/net/softnic/rte_eth_softnic.c line 300

Quoted 10 lines
drivers/net/softnic/rte_eth_softnic.c +10 -0
+	p->soft.def.pkts_len = pkts_len;
+	p->soft.def.flush_count = flush_count + 1;
+
+	return 0;
+}
+
+int
+rte_pmd_softnic_run(uint8_t port_id)
+{
+	struct rte_eth_dev *dev = &rte_eth_devices[port_id];

It can be possible to create a macro for this.

<...>

drivers/net/softnic/rte_eth_softnic.c line 337

Quoted 2 lines
drivers/net/softnic/rte_eth_softnic.c +2 -0
+static int
+default_init(struct pmd_internals *p,

default_mbufs_init()? default_init() on its own in not that clear.

<...>

drivers/net/softnic/rte_eth_softnic.c line 353

Quoted 2 lines
drivers/net/softnic/rte_eth_softnic.c +2 -0
+static void
+default_free(struct pmd_internals *p)

default_mbufs_free()?

<...>

Quoted 5 lines
drivers/net/softnic/rte_eth_softnic.c +5 -0
+static void *
+pmd_init(struct pmd_params *params, int numa_node)
+{
+	struct pmd_internals *p;
+	int status;

drivers/net/softnic/rte_eth_softnic.c line 372

Quoted 10 lines
drivers/net/softnic/rte_eth_softnic.c +10 -0
+
+	p = rte_zmalloc_socket(params->soft.name,
+		sizeof(struct pmd_internals),
+		0,
+		numa_node);
+	if (p == NULL)
+		return NULL;
+
+	memcpy(&p->params, params, sizeof(p->params));
+	rte_eth_dev_get_port_by_name(params->hard.name, &p->hard.port_id);

You may want to check return value of this.

Quoted 5 lines
drivers/net/softnic/rte_eth_softnic.c +5 -0
+
+	/* Default */
+	status = default_init(p, params, numa_node);
+	if (status) {
+		rte_free(p);

drivers/net/softnic/rte_eth_softnic.c line 387

Quoted 10 lines
drivers/net/softnic/rte_eth_softnic.c +10 -0
+		return NULL;
+	}
+
+	return p;
+}
+
+static void
+pmd_free(struct pmd_internals *p)
+{
+	default_free(p);

p->hard.name also needs to be freed here.

Quoted 28 lines
drivers/net/softnic/rte_eth_softnic.c +28 -0
+
+	rte_free(p);
+}
+
+static int
+pmd_ethdev_register(struct rte_vdev_device *vdev,
+	struct pmd_params *params,
+	void *dev_private)
+{
+	struct rte_eth_dev_info hard_info;
+	struct rte_eth_dev *soft_dev;
+	struct rte_eth_dev_data *soft_data;
+	uint32_t hard_speed;
+	int numa_node;
+	uint8_t hard_port_id;
+
+	rte_eth_dev_get_port_by_name(params->hard.name, &hard_port_id);
+	rte_eth_dev_info_get(hard_port_id, &hard_info);
+	hard_speed = eth_dev_speed_max_mbps(hard_info.speed_capa);
+	numa_node = rte_eth_dev_socket_id(hard_port_id);
+
+	/* Memory allocation */
+	soft_data = rte_zmalloc_socket(params->soft.name,
+		sizeof(*soft_data), 0, numa_node);
+	if (!soft_data)
+		return -ENOMEM;
+
+	/* Ethdev entry allocation */

drivers/net/softnic/rte_eth_softnic.c line 425

Quoted 10 lines
drivers/net/softnic/rte_eth_softnic.c +10 -0
+	soft_dev = rte_eth_dev_allocate(params->soft.name);
+	if (!soft_dev) {
+		rte_free(soft_data);
+		return -ENOMEM;
+	}
+
+	/* Connect dev->data */
+	memmove(soft_data->name,
+		soft_dev->data->name,
+		sizeof(soft_data->name));

I guess this is redundant here, allocating soft_data and rest, it is possible to use soft_dev->data directly.

Quoted 9 lines
drivers/net/softnic/rte_eth_softnic.c +9 -0
+	soft_data->port_id = soft_dev->data->port_id;
+	soft_data->mtu = soft_dev->data->mtu;
+	soft_dev->data = soft_data;
+
+	/* dev */
+	soft_dev->rx_pkt_burst = (params->soft.intrusive) ?
+		NULL : /* set up later */
+		pmd_rx_pkt_burst;
+	soft_dev->tx_pkt_burst = pmd_tx_pkt_burst;

drivers/net/softnic/rte_eth_softnic.c line 444

Quoted 10 lines
drivers/net/softnic/rte_eth_softnic.c +10 -0
+	soft_dev->tx_pkt_prepare = NULL;
+	soft_dev->dev_ops = &pmd_ops;
+	soft_dev->device = &vdev->device;
+
+	/* dev->data */
+	soft_dev->data->dev_private = dev_private;
+	soft_dev->data->dev_link.link_speed = hard_speed;
+	soft_dev->data->dev_link.link_duplex = ETH_LINK_FULL_DUPLEX;
+	soft_dev->data->dev_link.link_autoneg = ETH_LINK_SPEED_FIXED;
+	soft_dev->data->dev_link.link_status = ETH_LINK_DOWN;

For simplity, it is possible to have a static struct rte_eth_link, and assing it to data->dev_link, as done in null pmd.

drivers/net/softnic/rte_eth_softnic.c line 448

Quoted 4 lines
drivers/net/softnic/rte_eth_softnic.c +4 -0
+	soft_dev->data->mac_addrs = &eth_addr;
+	soft_dev->data->promiscuous = 1;
+	soft_dev->data->kdrv = RTE_KDRV_NONE;
+	soft_dev->data->numa_node = numa_node;

If pmd is detachable, need following flag:
data->dev_flags = RTE_ETH_DEV_DETACHABLE;

Quoted 4 lines
drivers/net/softnic/rte_eth_softnic.c +4 -0
+
+	return 0;
+}
+

<...>

Quoted 4 lines
drivers/net/softnic/rte_eth_softnic.c +4 -0
+static int
+pmd_probe(struct rte_vdev_device *vdev)
+{
+	struct pmd_params p;

drivers/net/softnic/rte_eth_softnic.c line 531

Quoted 10 lines
drivers/net/softnic/rte_eth_softnic.c +10 -0
+	const char *params;
+	int status;
+
+	struct rte_eth_dev_info hard_info;
+	uint8_t hard_port_id;
+	int numa_node;
+	void *dev_private;
+
+	if (!vdev)
+		return -EINVAL;

This check is not required, eal won't call this function with NULL vdev.

<...>

Quoted 1 line
drivers/net/softnic/rte_eth_softnic.h +0 -0

<...>

drivers/net/softnic/rte_eth_softnic.h line 48

Quoted 2 lines
drivers/net/softnic/rte_eth_softnic.h +2 -0
+int
+rte_pmd_softnic_run(uint8_t port_id);

Since this is public API, this needs to be commented properly, with doxygen comment.

Btw, since there is API in this PMD perhaps api documentation also needs to be updated to include this.

<...>

#7 lore raw

Re: [PATCH v3 1/4] net/softnic: add softnic PMD

Hi Ferruh,

Thank you for the review and feedback. Please see inline response;

Quoted 32 lines

-----Original Message-----
From: Yigit, Ferruh
Sent: Tuesday, September 5, 2017 3:53 PM
To: Singh, Jasvinder <[email protected]>; [email protected]
Cc: Dumitrescu, Cristian <[email protected]>; [email protected]
Subject: Re: [PATCH v3 1/4] net/softnic: add softnic PMD

Quoted 12 lines · Jasvinder Singh

Add SoftNIC PMD to provide SW fall-back for ethdev APIs.

---
v3 changes:
- rebase to dpdk17.08 release

v2 changes:
- fix build errors
- rebased to TM APIs v6 plus dpdk master

Quoted 5 lines
 MAINTAINERS                                     |   5 +
 config/common_base                              |   5 +
 drivers/net/Makefile                            |   5 +
 drivers/net/softnic/Makefile                    |  56 +++
 drivers/net/softnic/rte_eth_softnic.c           | 609

++++++++++++++++++++++++

Quoted 4 lines
 drivers/net/softnic/rte_eth_softnic.h           |  54 +++
 drivers/net/softnic/rte_eth_softnic_internals.h | 114 +++++
 drivers/net/softnic/rte_eth_softnic_version.map |   7 +
 mk/rte.app.mk                                   |   5 +-
Quoted 5 lines

Also documentation updates are required:
- .ini file
- PMD documentation .rst file
- I believe it is good to update release note about new PMD
- release notes library version info, since this has public API

Will send documentation patch.

Quoted 7 lines

<...>

Quoted 1 line

+EXPORT_MAP := rte_eth_softnic_version.map

rte_pmd_... to be consistent.

<...>

Will do.

Quoted 7 lines

drivers/net/softnic/Makefile line 54

Quoted 4 lines
drivers/net/softnic/Makefile new file +4 -0
+#
+# Export include files
+#
+SYMLINK-y-include +=rte_eth_softnic.h

space after +=

Will add space.

Quoted 11 lines
Quoted 3 lines
drivers/net/softnic/rte_eth_softnic.c +0 -0

<...>

drivers/net/softnic/rte_eth_softnic.c

Quoted 2 lines
drivers/net/softnic/rte_eth_softnic.c +2 -0
+
+static struct rte_vdev_driver pmd_drv;

Why this is required, already defined below.
And for naming, pmd=poll mode driver, drv=driver, makes "poll mode driver driver"

Ok. will correct this.

Quoted 12 lines

<...>

Quoted 10 lines
drivers/net/softnic/rte_eth_softnic.c +10 -0
+static int
+pmd_rx_queue_setup(struct rte_eth_dev *dev,
+	uint16_t rx_queue_id,
+	uint16_t nb_rx_desc __rte_unused,
+	unsigned int socket_id,
+	const struct rte_eth_rxconf *rx_conf __rte_unused,
+	struct rte_mempool *mb_pool __rte_unused) {
+	struct pmd_internals *p = dev->data->dev_private;
+
+	if (p->params.soft.intrusive == 0) {
Quoted 8 lines

drivers/net/softnic/rte_eth_softnic.c line 115

Quoted 6 lines
drivers/net/softnic/rte_eth_softnic.c +6 -0
+		struct pmd_rx_queue *rxq;
+
+		rxq = rte_zmalloc_socket(p->params.soft.name,
+			sizeof(struct pmd_rx_queue), 0, socket_id);
+		if (rxq == NULL)
+			return -1;

return -ENOMEM ?

Ok.

Quoted 8 lines

drivers/net/softnic/rte_eth_softnic.c

Quoted 7 lines
drivers/net/softnic/rte_eth_softnic.c +7 -0
+
+		rxq->hard.port_id = p->hard.port_id;
+		rxq->hard.rx_queue_id = rx_queue_id;
+		dev->data->rx_queues[rx_queue_id] = rxq;
+	} else {
+		struct rte_eth_dev *hard_dev =
+			&rte_eth_devices[p->hard.port_id];> +
	void *rxq = hard_dev->data->rx_queues[rx_queue_id];
Quoted 9 lines

drivers/net/softnic/rte_eth_softnic.c line 119

Quoted 5 lines
drivers/net/softnic/rte_eth_softnic.c +5 -0
+
+		if (rxq == NULL)
+			return -1;
+
+		dev->data->rx_queues[rx_queue_id] = rxq;

This assigns underlying hw queue as this soft PMD queue, what happens if two different cores, one polls the actual hw device and other polls the this virtual device, since both are indeed same queues?

Once soft device is created and attached to hard device, application has to reads packets from/writes packets to the "soft" port instead of the "hard" port as soft device is feature rich version of the hard device (See Cover letter notes). The RX and TX queues of the "soft" port are thread safe, as any ethdev.

Quoted 38 lines
Quoted 4 lines
drivers/net/softnic/rte_eth_softnic.c +4 -0
+	}
+	return 0;
+}
+

<...>

Quoted 31 lines
drivers/net/softnic/rte_eth_softnic.c +31 -0
+static __rte_always_inline int
+rte_pmd_softnic_run_default(struct rte_eth_dev *dev) {
+	struct pmd_internals *p = dev->data->dev_private;
+
+	/* Persistent context: Read Only (update not required) */
+	struct rte_mbuf **pkts = p->soft.def.pkts;
+	uint16_t nb_tx_queues = dev->data->nb_tx_queues;
+
+	/* Persistent context: Read - Write (update required) */
+	uint32_t txq_pos = p->soft.def.txq_pos;
+	uint32_t pkts_len = p->soft.def.pkts_len;
+	uint32_t flush_count = p->soft.def.flush_count;
+
+	/* Not part of the persistent context */
+	uint32_t pos;
+	uint16_t i;
+
+	/* Soft device TXQ read, Hard device TXQ write */
+	for (i = 0; i < nb_tx_queues; i++) {
+		struct rte_ring *txq = dev->data->tx_queues[txq_pos];
+
+		/* Read soft device TXQ burst to packet enqueue buffer */
+		pkts_len += rte_ring_sc_dequeue_burst(txq,
+			(void **) &pkts[pkts_len],
+			DEFAULT_BURST_SIZE,
+			NULL);
+
+		/* Increment soft device TXQ */
+		txq_pos++;
+		if (txq_pos >= nb_tx_queues)
+			txq_pos = 0;
Quoted 8 lines

drivers/net/softnic/rte_eth_softnic.c line 266

Quoted 3 lines
drivers/net/softnic/rte_eth_softnic.c +3 -0
+
+		/* Hard device TXQ write when complete burst is available */
+		if (pkts_len >= DEFAULT_BURST_SIZE) {

There questions:
1- When there are multiple tx_queues of softnic, and assume all will be processed by a core, this core will be reading from all into single HW queue, won' this create a bottle neck?

I am not sure if I understand correctly. As per QoS sched library implementation, the number of tx queues of the softnic depend upon the number of users sending their traffic and configurable via one of the input
argument for device creation. There doesn't exist any mapping between the softnic tx queues and hard device tx queues. The softnic device receives the packets in its scheduling queues (tx queues) and prioritizes their transmission and transmit them accordingly to specific queue of the hard device(can be specified as an input argument). It would be redundant for thread implementing the QoS scheduler to distribute the packets among the hard device tx queues which actually doesn't serve any purpose.

Quoted 3 lines

2- This logic reads from all queues as BURST_SIZE and merges them, if queues split with a RSS or similar, that clasiffication will be lost, will it be problem?

I don't think so. The QoS scheduler sits on the tx side just before the transmission stage and receives the packet burst destined for the specific network interface to which it is attached. Thus, it schedules the packets egressing through the specific port instead of merging the packets going to different interfaces.

Quoted 3 lines

3- If there is not enough packets in the queues ( < DEFAULT_BURST_SIZE) those packets won't be transmitted unless more is comming, will this create latency for those cases?

In case of low traffic rate situation, packets will be automatically flushed at specific interval as discussed below.

Quoted 18 lines
Quoted 4 lines
drivers/net/softnic/rte_eth_softnic.c +3 -0
+			for (pos = 0; pos < pkts_len; )
+				pos += rte_eth_tx_burst(p->hard.port_id,
+					p->params.hard.tx_queue_id,

drivers/net/softnic/rte_eth_softnic.c line 279

Quoted 10 lines
drivers/net/softnic/rte_eth_softnic.c +10 -0
+					&pkts[pos],
+					(uint16_t) (pkts_len - pos));
+
+			pkts_len = 0;
+			flush_count = 0;
+			break;
+		}
+	}
+
+	if (flush_count >= FLUSH_COUNT_THRESHOLD) {

FLUSH_COUNT_THRESHOLD is (1 << 17), and if no packet is sent, flash count incremented by one, just want to confirm the treshold value?

Quoted 1 line

And why this flush exists?

Flush mechanism comes in play when traffic rate is very low. In such instance, packet flush will be triggered once threshold value is satisfied. For example, cpu core spining at 2.0 GHz, as per current setting, the packet flush will happen at ~65us interval in case of packet burst size is less than set value.

Quoted 15 lines
Quoted 15 lines
drivers/net/softnic/rte_eth_softnic.c +15 -0
+		for (pos = 0; pos < pkts_len; )
+			pos += rte_eth_tx_burst(p->hard.port_id,
+				p->params.hard.tx_queue_id,
+				&pkts[pos],
+				(uint16_t) (pkts_len - pos));
+
+		pkts_len = 0;
+		flush_count = 0;
+	}
+
+	p->soft.def.txq_pos = txq_pos;
+	p->soft.def.pkts_len = pkts_len;
+	p->soft.def.flush_count = flush_count + 1;
+
+	return 0;
Quoted 8 lines

drivers/net/softnic/rte_eth_softnic.c line 300

Quoted 6 lines
drivers/net/softnic/rte_eth_softnic.c +6 -0
+}
+
+int
+rte_pmd_softnic_run(uint8_t port_id)
+{
+	struct rte_eth_dev *dev = &rte_eth_devices[port_id];

It can be possible to create a macro for this.

Ok. Will do.

Quoted 7 lines

<...>

drivers/net/softnic/rte_eth_softnic.c line 337

Quoted 2 lines
drivers/net/softnic/rte_eth_softnic.c +2 -0
+static int
+default_init(struct pmd_internals *p,

default_mbufs_init()? default_init() on its own in not that clear.

Quoted 6 lines

<...>

drivers/net/softnic/rte_eth_softnic.c line 353

Quoted 2 lines
drivers/net/softnic/rte_eth_softnic.c +2 -0
+static void
+default_free(struct pmd_internals *p)

default_mbufs_free()?

The generic name is chosen if we initialize and free more parameters than mbufs.

Quoted 11 lines

<...>

Quoted 9 lines
drivers/net/softnic/rte_eth_softnic.c +9 -0
+static void *
+pmd_init(struct pmd_params *params, int numa_node) {
+	struct pmd_internals *p;
+	int status;
+
+	p = rte_zmalloc_socket(params->soft.name,
+		sizeof(struct pmd_internals),
+		0,
+		numa_node);
Quoted 8 lines
Quoted 6 lines
drivers/net/softnic/rte_eth_softnic.c +5 -0
+	if (p == NULL)
+		return NULL;
+
+	memcpy(&p->params, params, sizeof(p->params));
+	rte_eth_dev_get_port_by_name(params->hard.name, &p-

hard.port_id);

You may want to check return value of this.

Will add check.

Quoted 9 lines
Quoted 9 lines
drivers/net/softnic/rte_eth_softnic.c +9 -0
+
+	/* Default */
+	status = default_init(p, params, numa_node);
+	if (status) {
+		rte_free(p);
+		return NULL;
+	}
+
+	return p;
Quoted 8 lines

drivers/net/softnic/rte_eth_softnic.c line 387

Quoted 6 lines
drivers/net/softnic/rte_eth_softnic.c +6 -0
+}
+
+static void
+pmd_free(struct pmd_internals *p)
+{
+	default_free(p);

p->hard.name also needs to be freed here.

No, we don't allocate any memory to this varibale as it points to the value retrieved from the rte_eth_dev_get_port_by_name();

Quoted 34 lines
Quoted 7 lines
drivers/net/softnic/rte_eth_softnic.c +7 -0
+
+	rte_free(p);
+}
+
+static int
+pmd_ethdev_register(struct rte_vdev_device *vdev,
+	struct pmd_params *params,

drivers/net/softnic/rte_eth_softnic.c

Quoted 10 lines
drivers/net/softnic/rte_eth_softnic.c +10 -0
+	void *dev_private)
+{
+	struct rte_eth_dev_info hard_info;
+	struct rte_eth_dev *soft_dev;
+	struct rte_eth_dev_data *soft_data;
+	uint32_t hard_speed;
+	int numa_node;
+	uint8_t hard_port_id;
+
+	rte_eth_dev_get_port_by_name(params->hard.name,

&hard_port_id);

Quoted 16 lines
drivers/net/softnic/rte_eth_softnic.c +16 -0
+	rte_eth_dev_info_get(hard_port_id, &hard_info);
+	hard_speed = eth_dev_speed_max_mbps(hard_info.speed_capa);
+	numa_node = rte_eth_dev_socket_id(hard_port_id);
+
+	/* Memory allocation */
+	soft_data = rte_zmalloc_socket(params->soft.name,
+		sizeof(*soft_data), 0, numa_node);
+	if (!soft_data)
+		return -ENOMEM;
+
+	/* Ethdev entry allocation */
+	soft_dev = rte_eth_dev_allocate(params->soft.name);
+	if (!soft_dev) {
+		rte_free(soft_data);
+		return -ENOMEM;
+	}
Quoted 8 lines

drivers/net/softnic/rte_eth_softnic.c line 425

Quoted 5 lines
drivers/net/softnic/rte_eth_softnic.c +5 -0
+
+	/* Connect dev->data */
+	memmove(soft_data->name,
+		soft_dev->data->name,
+		sizeof(soft_data->name));

I guess this is redundant here, allocating soft_data and rest, it is possible to use soft_dev->data directly.

Yes, will correct this.

Quoted 14 lines
Quoted 14 lines
drivers/net/softnic/rte_eth_softnic.c +14 -0
+	soft_data->port_id = soft_dev->data->port_id;
+	soft_data->mtu = soft_dev->data->mtu;
+	soft_dev->data = soft_data;
+
+	/* dev */
+	soft_dev->rx_pkt_burst = (params->soft.intrusive) ?
+		NULL : /* set up later */
+		pmd_rx_pkt_burst;
+	soft_dev->tx_pkt_burst = pmd_tx_pkt_burst;
+	soft_dev->tx_pkt_prepare = NULL;
+	soft_dev->dev_ops = &pmd_ops;
+	soft_dev->device = &vdev->device;
+
+	/* dev->data */
Quoted 8 lines

drivers/net/softnic/rte_eth_softnic.c line 444

Quoted 5 lines
drivers/net/softnic/rte_eth_softnic.c +5 -0
+	soft_dev->data->dev_private = dev_private;
+	soft_dev->data->dev_link.link_speed = hard_speed;
+	soft_dev->data->dev_link.link_duplex = ETH_LINK_FULL_DUPLEX;
+	soft_dev->data->dev_link.link_autoneg = ETH_LINK_SPEED_FIXED;
+	soft_dev->data->dev_link.link_status = ETH_LINK_DOWN;

For simplity, it is possible to have a static struct rte_eth_link, and assing it to data->dev_link, as done in null pmd.

The device speed is determined from that of hard device, so thought to assign value explicitly here.

Quoted 7 lines

drivers/net/softnic/rte_eth_softnic.c line 448

Quoted 4 lines
drivers/net/softnic/rte_eth_softnic.c +4 -0
+	soft_dev->data->mac_addrs = &eth_addr;
+	soft_dev->data->promiscuous = 1;
+	soft_dev->data->kdrv = RTE_KDRV_NONE;
+	soft_dev->data->numa_node = numa_node;

If pmd is detachable, need following flag:
data->dev_flags = RTE_ETH_DEV_DETACHABLE;

Ok. Will do that.

Quoted 7 lines
Quoted 4 lines
drivers/net/softnic/rte_eth_softnic.c +4 -0
+
+	return 0;
+}
+

<...>

Quoted 15 lines

drivers/net/softnic/rte_eth_softnic.c line 531

Quoted 13 lines
drivers/net/softnic/rte_eth_softnic.c +13 -0
+static int
+pmd_probe(struct rte_vdev_device *vdev) {
+	struct pmd_params p;
+	const char *params;
+	int status;
+
+	struct rte_eth_dev_info hard_info;
+	uint8_t hard_port_id;
+	int numa_node;
+	void *dev_private;
+
+	if (!vdev)
+		return -EINVAL;

This check is not required, eal won't call this function with NULL vdev.

Ok. Will correct this.

Quoted 5 lines

<...>

Quoted 2 lines
drivers/net/softnic/rte_eth_softnic.h +0 -0

<...>

Quoted 8 lines

drivers/net/softnic/rte_eth_softnic.h line 48

Quoted 2 lines
drivers/net/softnic/rte_eth_softnic.h +2 -0
+int
+rte_pmd_softnic_run(uint8_t port_id);

Since this is public API, this needs to be commented properly, with doxygen comment.

Btw, since there is API in this PMD perhaps api documentation also needs to be updated to include this.

Yes, will add documentation.

Quoted 1 line

<...>

#8 lore raw

Re: [PATCH v3 1/4] net/softnic: add softnic PMD

Quoted 17 lines · Jasvinder

Hi Ferruh,

Thank you for the review and feedback. Please see inline response;

Quoted 13 lines

-----Original Message-----
From: Yigit, Ferruh
Sent: Tuesday, September 5, 2017 3:53 PM
To: Singh, Jasvinder <[email protected]>; [email protected]
Cc: Dumitrescu, Cristian <[email protected]>; [email protected]
Subject: Re: [PATCH v3 1/4] net/softnic: add softnic PMD

Quoted 4 lines · Jasvinder Singh

Add SoftNIC PMD to provide SW fall-back for ethdev APIs.

<...>

Quoted 18 lines
Quoted 9 lines
Quoted 9 lines
drivers/net/softnic/rte_eth_softnic.c new file +9 -0
+
+	/* Default */
+	status = default_init(p, params, numa_node);
+	if (status) {
+		rte_free(p);
+		return NULL;
+	}
+
+	return p;
Quoted 8 lines

drivers/net/softnic/rte_eth_softnic.c line 387

Quoted 6 lines
drivers/net/softnic/rte_eth_softnic.c new file +6 -0
+}
+
+static void
+pmd_free(struct pmd_internals *p)
+{
+	default_free(p);

p->hard.name also needs to be freed here.

Quoted 1 line

No, we don't allocate any memory to this varibale as it points to the value retrieved from the rte_eth_dev_get_port_by_name();

I guess it is otherway around, the rte_eth_dev_get_port_by_name() uses hard.name to get and store the port_id of the underlying hw.

how hard.name set, if I don't miss anything, it is strdup from devargs:

--
ret = rte_kvargs_process(kvlist, PMD_PARAM_HARD_NAME, &get_string, &p->hard.name);
--
get_string()

	*(char **)extra_args = strdup(value);

--

#9 lore raw

Re: [PATCH v3 1/4] net/softnic: add softnic PMD

Quoted 57 lines

-----Original Message-----
From: Yigit, Ferruh
Sent: Friday, September 8, 2017 10:49 AM
To: Singh, Jasvinder <[email protected]>; [email protected]
Cc: Dumitrescu, Cristian <[email protected]>; [email protected]
Subject: Re: [PATCH v3 1/4] net/softnic: add softnic PMD

Quoted 17 lines · Jasvinder

Hi Ferruh,

Thank you for the review and feedback. Please see inline response;

Quoted 13 lines

-----Original Message-----
From: Yigit, Ferruh
Sent: Tuesday, September 5, 2017 3:53 PM
To: Singh, Jasvinder <[email protected]>; [email protected]
Cc: Dumitrescu, Cristian <[email protected]>; [email protected]
Subject: Re: [PATCH v3 1/4] net/softnic: add softnic PMD

Quoted 4 lines · Jasvinder Singh

Add SoftNIC PMD to provide SW fall-back for ethdev APIs.

<...>

Quoted 18 lines
Quoted 9 lines
Quoted 9 lines
drivers/net/softnic/rte_eth_softnic.c new file +9 -0
+
+	/* Default */
+	status = default_init(p, params, numa_node);
+	if (status) {
+		rte_free(p);
+		return NULL;
+	}
+
+	return p;
Quoted 8 lines

drivers/net/softnic/rte_eth_softnic.c line 387

Quoted 6 lines
drivers/net/softnic/rte_eth_softnic.c new file +6 -0
+}
+
+static void
+pmd_free(struct pmd_internals *p)
+{
+	default_free(p);

p->hard.name also needs to be freed here.

Quoted 2 lines

No, we don't allocate any memory to this varibale as it points to the value retrieved from the rte_eth_dev_get_port_by_name();

I guess it is otherway around, the rte_eth_dev_get_port_by_name() uses hard.name to get and store the port_id of the underlying hw.

how hard.name set, if I don't miss anything, it is strdup from devargs:

Quoted 7 lines

--
ret = rte_kvargs_process(kvlist, PMD_PARAM_HARD_NAME, &get_string, &p->hard.name);
--
get_string()

	*(char **)extra_args = strdup(value);

--

Yes, it is set using above, will correct that. Thanks.

#10 lore raw

v4 cover net/softnic: sw fall-back pmd for traffic mgmt and others

In reply to Jasvinder Singh

The SoftNIC PMD is intended to provide SW fall-back options for specific ethdev APIs in a generic way to the NICs not supporting those features.

Currently, the only implemented ethdev API is Traffic Management (TM), but other ethdev APIs such as rte_flow, traffic metering & policing, etc can be easily implemented.

Overview:
* Generic: The SoftNIC PMD works with any "hard" PMD that implements the ethdev API. It does not change the "hard" PMD in any way.
* Creation: For any given "hard" ethdev port, the user can decide to create an associated "soft" ethdev port to drive the "hard" port. The "soft" port is a virtual device that can be created at app start-up through EAL vdev arg or later through the virtual device API.
* Configuration: The app explicitly decides which features are to be enabled on the "soft" port and which features are still to be used from the "hard" port. The app continues to explicitly configure both the "hard" and the "soft" ports after the creation of the "soft" port.
* RX/TX: The app reads packets from/writes packets to the "soft" port instead of the "hard" port. The RX and TX queues of the "soft" port are thread safe, as any ethdev.
* Execution: The "soft" port is a feature-rich NIC implemented by the CPU, so the run function of the "soft" port has to be executed by the CPU in order to get packets moving between "hard" port and the app.
* Meets the NFV vision: The app should be (almost) agnostic about the NIC implementation (different vendors/models, HW-SW mix), the app should not require changes to use different NICs, the app should use the same API for all NICs. If a NIC does not implement a specific feature, the HW should be augmented with SW to meet the functionality while still preserving the same API.

Traffic Management SW fall-back overview:
* Implements the ethdev traffic management API (rte_tm.h).
* Based on the existing librte_sched DPDK library.

Example: Create "soft" port for "hard" port "0000:04:00.1", enable the TM feature with default settings:

          --vdev 'net_softnic0,hard_name=0000:04:00.1,soft_tm=on' 

Q1: Why generic name, if only TM is supported (for now)?
A1: The intention is to have SoftNIC PMD implement many other (all?)
ethdev APIs under a single "ideal" ethdev, hence the generic name. The initial motivation is TM API, but the mechanism is generic and can be used for many other ethdev APIs. Somebody looking to provide SW fall-back for other ethdev API is likely to end up inventing the same, hence it would be good to consolidate all under a single PMD and have the user explicitly enable/disable the features it needs for each "soft" device.

Q2: Are there any performance requirements for SoftNIC?
A2: Yes, performance should be great/decent for every feature, otherwise
the SW fall-back is unusable, thus useless.

Q3: Why not change the "hard" device (and keep a single device) instead of
creating a new "soft" device (and thus having two devices)?
A3: This is not possible with the current librte_ether ethdev
implementation. The ethdev->dev_ops are defined as constant structure, so it cannot be changed per device (nor per PMD). The new ops also need memory space to store their context data structures, which requires updating the ethdev->data->dev_private of the existing device; at best, maybe a resize of ethdev->data->dev_private could be done, assuming that librte_ether will introduce a way to find out its size, but this cannot be done while device is running. Other side effects might exist, as the changes are very intrusive, plus it likely needs more changes in librte_ether.

Q4: Why not call the SW fall-back dev_ops directly in librte_ether for
devices which do not support the specific feature? If the device supports the capability, let's call its dev_ops, otherwise call the SW fall-back dev_ops.
A4: First, similar reasons to Q&A3. This fixes the need to change
ethdev->dev_ops of the device, but it does not do anything to fix the other significant issue of where to store the context data structures needed by the SW fall-back functions (which, in this approach, are called implicitly by librte_ether).
Second, the SW fall-back options should not be restricted arbitrarily by the librte_ether library, the decision should belong to the app. For example, the TM SW fall-back should not be limited to only librte_sched, which (like any SW fall-back) is limited to a specific hierarchy and feature set, it cannot do any possible hierarchy. If alternatives exist, the one to use should be picked by the app, not by the ethdev layer.

Q5: Why is the app required to continue to configure both the "hard" and
the "soft" devices even after the "soft" device has been created? Why not hiding the "hard" device under the "soft" device and have the "soft" device configure the "hard" device under the hood?
A5: This was the approach tried in the V2 of this patch set (overlay
"soft" device taking over the configuration of the underlay "hard" device) and eventually dropped due to increased complexity of having to keep the configuration of two distinct devices in sync with librte_ether implementation that is not friendly towards such approach. Basically, each ethdev API call for the overlay device needs to configure the overlay device, invoke the same configuration with possibly modified parameters for the underlay device, then resume the configuration of overlay device, turning this into a device emulation project.
V2 minuses: increased complexity (deal with two devices at same time); need to implement every ethdev API, even those not needed for the scope of SW fall-back; intrusive; sometimes have to silently take decisions that should be left to the app.
V3 pluses: lower complexity (only one device); only need to implement those APIs that are in scope of the SW fall-back; non-intrusive (deal with "hard" device through ethdev API); app decisions taken by the app in an explicit way.

Q6: Why expose the SW fall-back in a PMD and not in a SW library?
A6: The SW fall-back for an ethdev API has to implement that specific
ethdev API, (hence expose an ethdev object through a PMD), as opposed to providing a different API. This approach allows the app to use the same API (NFV vision). For example, we already have a library for TM SW fall-back (librte_sched) that can be called directly by the apps that need to call it outside of ethdev context (use-cases exist), but an app that works with TM-aware NICs through the ethdev TM API would have to be changed significantly in order to work with different TM-agnostic NICs through the librte_sched API.

Q7: Why have all the SW fall-backs in a single PMD? Why not develop
the SW fall-back for each different ethdev API in a separate PMD, then create a chain of "soft" devices for each "hard" device? Potentially, this results in smaller size PMDs that are easier to maintain.
A7: Arguments for single ethdev/PMD and against chain of ethdevs/PMDs:
1. All the existing PMDs for HW NICs implement a lot of features under the same PMD, so there is no reason for single PMD approach to break code modularity. See the V3 code, a lot of care has been taken for code modularity.
2. We should avoid the proliferation of SW PMDs.
3. A single device should be handled by a single PMD.
4. People are used with feature-rich PMDs, not with single-feature PMDs, so we change of mindset?
5. [Configuration nightmare] A chain of "soft" devices attached to single "hard" device requires the app to be aware that the N "soft" devices in the chain plus the "hard" device refer to the same HW device, and which device should be invoked to configure which feature. Also the length of the chain and functionality of each link is different for each HW device. This breaks the requirement of preserving the same API while working with different NICs (NFV). This most likely results in a configuration nightmare, nobody is going to seriously use this.
6. [Feature inter-dependecy] Sometimes different features need to be configured and executed together (e.g. share the same set of resources, are inter-dependent, etc), so it is better and more performant to do them in the same ethdev/PMD.
7. [Code duplication] There is a lot of duplication in the configuration code for the chain of ethdevs approach. The ethdev dev_configure, rx_queue_setup, tx_queue_setup API functions have to be implemented per device, and they become meaningless/inconsistent with the chain approach.
8. [Data structure duplication] The per device data structures have to be duplicated and read repeatedly for each "soft" ethdev. The ethdev device, dev_private, data, per RX/TX queue data structures have to be replicated per "soft" device. They have to be re-read for each stage, so the same cache misses are now multiplied with the number of stages in the chain.
9. [rte_ring proliferation] Thread safety requirements for ethdev RX/TXqueues require an rte_ring to be used for every RX/TX queue of each "soft" ethdev. This rte_ring proliferation unnecessarily increases the memory footprint and lowers performance, especially when each "soft" ethdev ends up on a different CPU core (ping-pong of cache lines).
10.[Meta-data proliferation] A chain of ethdevs is likely to result
in proliferation of meta-data that has to be passed between the ethdevs (e.g. policing needs the output of flow classification), which results in more cache line ping-pong between cores, hence performance drops.

Cristian Dumitrescu (4):
Jasvinder Singh (4):
net/softnic: add softnic PMD
net/softnic: add traffic management support
net/softnic: add TM capabilities ops
net/softnic: add TM hierarchy related ops

 MAINTAINERS                                        |    5 +
 config/common_base                                 |    5 +
 doc/api/doxy-api-index.md                          |    3 +-
 doc/api/doxy-api.conf                              |    1 +
 doc/guides/rel_notes/release_17_11.rst             |    6 +
 drivers/net/Makefile                               |    5 +
 drivers/net/softnic/Makefile                       |   57 +
 drivers/net/softnic/rte_eth_softnic.c              |  853 +++++
 drivers/net/softnic/rte_eth_softnic.h              |   83 +
 drivers/net/softnic/rte_eth_softnic_internals.h    |  291 ++
 drivers/net/softnic/rte_eth_softnic_tm.c           | 3449 ++++++++++++++++++++
 .../net/softnic/rte_pmd_eth_softnic_version.map    |    7 +
 mk/rte.app.mk                                      |    5 +-
 13 files changed, 4768 insertions(+), 2 deletions(-)
 create mode 100644 drivers/net/softnic/Makefile
 create mode 100644 drivers/net/softnic/rte_eth_softnic.c
 create mode 100644 drivers/net/softnic/rte_eth_softnic.h
 create mode 100644 drivers/net/softnic/rte_eth_softnic_internals.h
 create mode 100644 drivers/net/softnic/rte_eth_softnic_tm.c
 create mode 100644 drivers/net/softnic/rte_pmd_eth_softnic_version.map
Signature · 1 line
2.9.3
#11 lore raw

PATCH v4 1/4 net/softnic: add softnic PMD

Add SoftNIC PMD to provide SW fall-back for ethdev APIs.

---
v4 changes:
- Implemented feedback from Ferruh [1]
- rename map file to rte_pmd_eth_softnic_version.map
- add release notes library version info
- doxygen: fix hooks in doc/api/doxy-api-index.md
- add doxygen comment for rte_pmd_softnic_run()
- free device name memory
- remove soft_dev param in pmd_ethdev_register()
- fix checkpatch warnings

v3 changes:
- rebase to dpdk17.08 release

v2 changes:
- fix build errors
- rebased to TM APIs v6 plus dpdk master

[1] Ferruh�s feedback on v3: http://dpdk.org/ml/archives/dev/2017-September/074576.html

 MAINTAINERS                                        |   5 +
 config/common_base                                 |   5 +
 doc/api/doxy-api-index.md                          |   3 +-
 doc/api/doxy-api.conf                              |   1 +
 doc/guides/rel_notes/release_17_11.rst             |   6 +
 drivers/net/Makefile                               |   5 +
 drivers/net/softnic/Makefile                       |  56 ++
 drivers/net/softnic/rte_eth_softnic.c              | 595 +++++++++++++++++++++
 drivers/net/softnic/rte_eth_softnic.h              |  67 +++
 drivers/net/softnic/rte_eth_softnic_internals.h    | 114 ++++
 .../net/softnic/rte_pmd_eth_softnic_version.map    |   7 +
 mk/rte.app.mk                                      |   5 +-
 12 files changed, 867 insertions(+), 2 deletions(-)
 create mode 100644 drivers/net/softnic/Makefile
 create mode 100644 drivers/net/softnic/rte_eth_softnic.c
 create mode 100644 drivers/net/softnic/rte_eth_softnic.h
 create mode 100644 drivers/net/softnic/rte_eth_softnic_internals.h
 create mode 100644 drivers/net/softnic/rte_pmd_eth_softnic_version.map
MAINTAINERS +5 -0
index a0cd75e..b6b738d 100644
@@ -511,6 +511,11 @@ M: Gaetan Rivet <[email protected]>
 F: drivers/net/failsafe/
 F: doc/guides/nics/fail_safe.rst
 
+Softnic PMD
+M: Jasvinder Singh <[email protected]>
+M: Cristian Dumitrescu <[email protected]>
+F: drivers/net/softnic
+
 
 Crypto Drivers
 --------------
config/common_base +5 -0
index 5e97a08..1a0c77d 100644
@@ -273,6 +273,11 @@ CONFIG_RTE_LIBRTE_SFC_EFX_PMD=y
 CONFIG_RTE_LIBRTE_SFC_EFX_DEBUG=n
 
 #
+# Compile SOFTNIC PMD
+#
+CONFIG_RTE_LIBRTE_PMD_SOFTNIC=y
+
+#
 # Compile software PMD backed by SZEDATA2 device
 #
 CONFIG_RTE_LIBRTE_PMD_SZEDATA2=n
doc/api/doxy-api-index.md +2 -1
index 19e0d4f..626ab51 100644
@@ -55,7 +55,8 @@ The public API headers are grouped by topics:
   [KNI]                (@ref rte_kni.h),
   [ixgbe]              (@ref rte_pmd_ixgbe.h),
   [i40e]               (@ref rte_pmd_i40e.h),
-  [crypto_scheduler]   (@ref rte_cryptodev_scheduler.h)
+  [crypto_scheduler]   (@ref rte_cryptodev_scheduler.h),
+  [softnic]            (@ref rte_eth_softnic.h)
 
 - **memory**:
   [memseg]             (@ref rte_memory.h),
doc/api/doxy-api.conf +1 -0
index 823554f..b27755d 100644
@@ -32,6 +32,7 @@ PROJECT_NAME            = DPDK
 INPUT                   = doc/api/doxy-api-index.md \
                           drivers/crypto/scheduler \
                           drivers/net/bonding \
+                          drivers/net/softnic \
                           drivers/net/i40e \
                           drivers/net/ixgbe \
                           lib/librte_eal/common/include \
doc/guides/rel_notes/release_17_11.rst +6 -0
index 170f4f9..d5a760b 100644
@@ -41,6 +41,11 @@ New Features
      Also, make sure to start the actual text at the margin.
      =========================================================
 
+* **Added SoftNIC PMD.**
+
+  Added new SoftNIC PMD. This virtual device offers applications a software
+  fallback support for traffic management.
+
 
 Resolved Issues
 ---------------
@@ -170,6 +175,7 @@ The libraries prepended with a plus sign were incremented in this version.
      librte_pipeline.so.3
      librte_pmd_bond.so.1
      librte_pmd_ring.so.2
+   + librte_pmd_softnic.so.1
      librte_port.so.3
      librte_power.so.1
      librte_reorder.so.1
drivers/net/Makefile +5 -0
index d33c959..b552a51 100644
@@ -110,4 +110,9 @@ DIRS-$(CONFIG_RTE_LIBRTE_PMD_VHOST) += vhost
 endif # $(CONFIG_RTE_LIBRTE_VHOST)
 DEPDIRS-vhost = $(core-libs) librte_vhost
 
+ifeq ($(CONFIG_RTE_LIBRTE_SCHED),y)
+DIRS-$(CONFIG_RTE_LIBRTE_PMD_SOFTNIC) += softnic
+endif # $(CONFIG_RTE_LIBRTE_SCHED)
+DEPDIRS-softnic = $(core-libs) librte_sched
+
 include $(RTE_SDK)/mk/rte.subdir.mk
drivers/net/softnic/Makefile new file +56 -0

56 lines not on this page · raw message

drivers/net/softnic/rte_eth_softnic.c new file +595 -0

595 lines not on this page · raw message

drivers/net/softnic/rte_eth_softnic.h new file +67 -0

67 lines not on this page · raw message

drivers/net/softnic/rte_eth_softnic_internals.h new file +114 -0

114 lines not on this page · raw message

drivers/net/softnic/rte_pmd_eth_softnic_version.map new file +7 -0
new file mode 100644
index 0000000..fb2cb68
@@ -0,0 +1,7 @@
+DPDK_17.11 {
+	global:
+
+	rte_pmd_softnic_run;
+
+	local: *;
+};
mk/rte.app.mk +4 -1
index c25fdd9..3dc82fb 100644
@@ -67,7 +67,6 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR)    += -lrte_distributor
 _LDLIBS-$(CONFIG_RTE_LIBRTE_IP_FRAG)        += -lrte_ip_frag
 _LDLIBS-$(CONFIG_RTE_LIBRTE_GRO)            += -lrte_gro
 _LDLIBS-$(CONFIG_RTE_LIBRTE_METER)          += -lrte_meter
-_LDLIBS-$(CONFIG_RTE_LIBRTE_SCHED)          += -lrte_sched
 _LDLIBS-$(CONFIG_RTE_LIBRTE_LPM)            += -lrte_lpm
 # librte_acl needs --whole-archive because of weak functions
 _LDLIBS-$(CONFIG_RTE_LIBRTE_ACL)            += --whole-archive
@@ -99,6 +98,7 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_RING)           += -lrte_ring
 _LDLIBS-$(CONFIG_RTE_LIBRTE_EAL)            += -lrte_eal
 _LDLIBS-$(CONFIG_RTE_LIBRTE_CMDLINE)        += -lrte_cmdline
 _LDLIBS-$(CONFIG_RTE_LIBRTE_REORDER)        += -lrte_reorder
+_LDLIBS-$(CONFIG_RTE_LIBRTE_SCHED)          += -lrte_sched
 
 ifeq ($(CONFIG_RTE_EXEC_ENV_LINUXAPP),y)
 _LDLIBS-$(CONFIG_RTE_LIBRTE_KNI)            += -lrte_kni
@@ -135,6 +135,9 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_NULL)       += -lrte_pmd_null
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_PCAP)       += -lrte_pmd_pcap -lpcap
 _LDLIBS-$(CONFIG_RTE_LIBRTE_QEDE_PMD)       += -lrte_pmd_qede
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_RING)       += -lrte_pmd_ring
+ifeq ($(CONFIG_RTE_LIBRTE_SCHED),y)
+_LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_SOFTNIC)      += -lrte_pmd_softnic
+endif
 _LDLIBS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD)    += -lrte_pmd_sfc_efx
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_SZEDATA2)   += -lrte_pmd_szedata2 -lsze2
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_TAP)        += -lrte_pmd_tap
Signature · 1 line
2.9.3
#12 lore raw

Re: [PATCH v4 1/4] net/softnic: add softnic PMD

Hi Thomas,

I don't see this patch in patchwork, although it is present in email archive. Any guess why it is not showing up there?

Thank you,
Jasvinder

Quoted 1,094 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Jasvinder Singh
Sent: Monday, September 18, 2017 10:10 AM
To: [email protected]
Cc: Dumitrescu, Cristian <[email protected]>; Yigit, Ferruh <[email protected]>; [email protected]
Subject: [dpdk-dev] [PATCH v4 1/4] net/softnic: add softnic PMD

Add SoftNIC PMD to provide SW fall-back for ethdev APIs.

---
v4 changes:
- Implemented feedback from Ferruh [1]
- rename map file to rte_pmd_eth_softnic_version.map
- add release notes library version info
- doxygen: fix hooks in doc/api/doxy-api-index.md
- add doxygen comment for rte_pmd_softnic_run()
- free device name memory
- remove soft_dev param in pmd_ethdev_register()
- fix checkpatch warnings

v3 changes:
- rebase to dpdk17.08 release

v2 changes:
- fix build errors
- rebased to TM APIs v6 plus dpdk master

[1] Ferruh s feedback on v3: http://dpdk.org/ml/archives/dev/2017-
September/074576.html

 MAINTAINERS                                        |   5 +
 config/common_base                                 |   5 +
 doc/api/doxy-api-index.md                          |   3 +-
 doc/api/doxy-api.conf                              |   1 +
 doc/guides/rel_notes/release_17_11.rst             |   6 +
 drivers/net/Makefile                               |   5 +
 drivers/net/softnic/Makefile                       |  56 ++
 drivers/net/softnic/rte_eth_softnic.c              | 595 +++++++++++++++++++++
 drivers/net/softnic/rte_eth_softnic.h              |  67 +++
 drivers/net/softnic/rte_eth_softnic_internals.h    | 114 ++++
 .../net/softnic/rte_pmd_eth_softnic_version.map    |   7 +
 mk/rte.app.mk                                      |   5 +-
 12 files changed, 867 insertions(+), 2 deletions(-)  create mode 100644
drivers/net/softnic/Makefile  create mode 100644
drivers/net/softnic/rte_eth_softnic.c
 create mode 100644 drivers/net/softnic/rte_eth_softnic.h
 create mode 100644 drivers/net/softnic/rte_eth_softnic_internals.h
 create mode 100644 drivers/net/softnic/rte_pmd_eth_softnic_version.map
MAINTAINERS +5 -0
index a0cd75e..b6b738d 100644
@@ -511,6 +511,11 @@ M: Gaetan Rivet <[email protected]>
 F: drivers/net/failsafe/
 F: doc/guides/nics/fail_safe.rst
 
+Softnic PMD
+M: Jasvinder Singh <[email protected]>
+M: Cristian Dumitrescu <[email protected]>
+F: drivers/net/softnic
+
 
 Crypto Drivers
 --------------
config/common_base index renamed from config/common_base +0 -0

5e97a08..1a0c77d 100644

config/common_base +0 -0
@@ -273,6 +273,11 @@ CONFIG_RTE_LIBRTE_SFC_EFX_PMD=y

CONFIG_RTE_LIBRTE_SFC_EFX_DEBUG=n

#

config/common_base +5 -0
+# Compile SOFTNIC PMD
+#
+CONFIG_RTE_LIBRTE_PMD_SOFTNIC=y
+
+#
 # Compile software PMD backed by SZEDATA2 device  #

CONFIG_RTE_LIBRTE_PMD_SZEDATA2=n diff --git a/doc/api/doxy-api- index.md b/doc/api/doxy-api-index.md index 19e0d4f..626ab51 100644

doc/api/doxy-api-index.md +2 -1
@@ -55,7 +55,8 @@ The public API headers are grouped by topics:
   [KNI]                (@ref rte_kni.h),
   [ixgbe]              (@ref rte_pmd_ixgbe.h),
   [i40e]               (@ref rte_pmd_i40e.h),
-  [crypto_scheduler]   (@ref rte_cryptodev_scheduler.h)
+  [crypto_scheduler]   (@ref rte_cryptodev_scheduler.h),
+  [softnic]            (@ref rte_eth_softnic.h)
 
 - **memory**:
   [memseg]             (@ref rte_memory.h),
doc/api/doxy-api.conf index renamed from doc/api/doxy-api.conf +0 -0

823554f..b27755d 100644

doc/api/doxy-api.conf +1 -0
@@ -32,6 +32,7 @@ PROJECT_NAME            = DPDK
 INPUT                   = doc/api/doxy-api-index.md \
                           drivers/crypto/scheduler \
                           drivers/net/bonding \
+                          drivers/net/softnic \
                           drivers/net/i40e \
                           drivers/net/ixgbe \
                           lib/librte_eal/common/include \ diff --git

a/doc/guides/rel_notes/release_17_11.rst
b/doc/guides/rel_notes/release_17_11.rst
index 170f4f9..d5a760b 100644

doc/guides/rel_notes/release_17_11.rst +5 -0
@@ -41,6 +41,11 @@ New Features
      Also, make sure to start the actual text at the margin.
      =========================================================
 
+* **Added SoftNIC PMD.**
+
+  Added new SoftNIC PMD. This virtual device offers applications a
+ software  fallback support for traffic management.
+
 
 Resolved Issues
 ---------------
@@ -170,6 +175,7 @@ The libraries prepended with a plus sign were

incremented in this version.
librte_pipeline.so.3
librte_pmd_bond.so.1
librte_pmd_ring.so.2

doc/guides/rel_notes/release_17_11.rst +1 -0
+   + librte_pmd_softnic.so.1
      librte_port.so.3
      librte_power.so.1
      librte_reorder.so.1
drivers/net/Makefile index renamed from drivers/net/Makefile +0 -0

d33c959..b552a51 100644

drivers/net/Makefile +0 -0
@@ -110,4 +110,9 @@ DIRS-$(CONFIG_RTE_LIBRTE_PMD_VHOST) += vhost
 endif # $(CONFIG_RTE_LIBRTE_VHOST)  DEPDIRS-vhost = $(core-libs)

librte_vhost

drivers/net/Makefile +4 -0
+ifeq ($(CONFIG_RTE_LIBRTE_SCHED),y)
+DIRS-$(CONFIG_RTE_LIBRTE_PMD_SOFTNIC) += softnic endif #
+$(CONFIG_RTE_LIBRTE_SCHED) DEPDIRS-softnic = $(core-libs) librte_sched
+
 include $(RTE_SDK)/mk/rte.subdir.mk
drivers/net/softnic/Makefile new renamed from drivers/net/softnic/Makefile +0 -0

file mode 100644 index 0000000..c2f42ef

drivers/net/softnic/Makefile new file +20 -0
@@ -0,0 +1,56 @@
+#   BSD LICENSE
+#
+#   Copyright(c) 2017 Intel Corporation. All rights reserved.
+#   All rights reserved.
+#
+#   Redistribution and use in source and binary forms, with or without
+#   modification, are permitted provided that the following conditions
+#   are met:
+#
+#     * Redistributions of source code must retain the above copyright
+#       notice, this list of conditions and the following disclaimer.
+#     * Redistributions in binary form must reproduce the above copyright
+#       notice, this list of conditions and the following disclaimer in
+#       the documentation and/or other materials provided with the
+#       distribution.
+#     * Neither the name of Intel Corporation nor the names of its
+#       contributors may be used to endorse or promote products derived
+#       from this software without specific prior written permission.
+#
+#   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND

CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT
NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.

drivers/net/softnic/Makefile new file +26 -0
+
+include $(RTE_SDK)/mk/rte.vars.mk
+
+#
+# library name
+#
+LIB = librte_pmd_softnic.a
+
+CFLAGS += -O3
+CFLAGS += $(WERROR_FLAGS)
+
+EXPORT_MAP := rte_pmd_eth_softnic_version.map
+
+LIBABIVER := 1
+
+#
+# all source are stored in SRCS-y
+#
+SRCS-$(CONFIG_RTE_LIBRTE_PMD_SOFTNIC) += rte_eth_softnic.c
+
+#
+# Export include files
+#
+SYMLINK-y-include += rte_eth_softnic.h
+
+include $(RTE_SDK)/mk/rte.lib.mk
drivers/net/softnic/rte_eth_softnic.c new file +21 -0
new file mode 100644
index 0000000..792e7ea
@@ -0,0 +1,595 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2017 Intel Corporation. All rights reserved.
+ *   All rights reserved.
+ *
+ *   Redistribution and use in source and binary forms, with or without
+ *   modification, are permitted provided that the following conditions
+ *   are met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in
+ *       the documentation and/or other materials provided with the
+ *       distribution.
+ *     * Neither the name of Intel Corporation nor the names of its
+ *       contributors may be used to endorse or promote products derived
+ *       from this software without specific prior written permission.
+ *
+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND

CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT
NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.
+ */

drivers/net/softnic/rte_eth_softnic.c new file +20 -0
+
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <rte_ethdev.h>
+#include <rte_ethdev_vdev.h>
+#include <rte_malloc.h>
+#include <rte_vdev.h>
+#include <rte_kvargs.h>
+#include <rte_errno.h>
+#include <rte_ring.h>
+
+#include "rte_eth_softnic.h"
+#include "rte_eth_softnic_internals.h"
+
+#define PRIV_TO_HARD_DEV(p)					\
+	(&rte_eth_devices[p->hard.port_id])
+
+#define PMD_PARAM_HARD_NAME
	"hard_name"
+#define PMD_PARAM_HARD_TX_QUEUE_ID
	"hard_tx_queue_id"
drivers/net/softnic/rte_eth_softnic.c new file +344 -0
+
+static const char *pmd_valid_args[] = {
+	PMD_PARAM_HARD_NAME,
+	PMD_PARAM_HARD_TX_QUEUE_ID,
+	NULL
+};
+
+static const struct rte_eth_dev_info pmd_dev_info = {
+	.min_rx_bufsize = 0,
+	.max_rx_pktlen = UINT32_MAX,
+	.max_rx_queues = UINT16_MAX,
+	.max_tx_queues = UINT16_MAX,
+	.rx_desc_lim = {
+		.nb_max = UINT16_MAX,
+		.nb_min = 0,
+		.nb_align = 1,
+	},
+	.tx_desc_lim = {
+		.nb_max = UINT16_MAX,
+		.nb_min = 0,
+		.nb_align = 1,
+	},
+};
+
+static void
+pmd_dev_infos_get(struct rte_eth_dev *dev __rte_unused,
+	struct rte_eth_dev_info *dev_info)
+{
+	memcpy(dev_info, &pmd_dev_info, sizeof(*dev_info)); }
+
+static int
+pmd_dev_configure(struct rte_eth_dev *dev) {
+	struct pmd_internals *p = dev->data->dev_private;
+	struct rte_eth_dev *hard_dev = PRIV_TO_HARD_DEV(p);
+
+	if (dev->data->nb_rx_queues > hard_dev->data->nb_rx_queues)
+		return -1;
+
+	if (p->params.hard.tx_queue_id >= hard_dev->data->nb_tx_queues)
+		return -1;
+
+	return 0;
+}
+
+static int
+pmd_rx_queue_setup(struct rte_eth_dev *dev,
+	uint16_t rx_queue_id,
+	uint16_t nb_rx_desc __rte_unused,
+	unsigned int socket_id,
+	const struct rte_eth_rxconf *rx_conf __rte_unused,
+	struct rte_mempool *mb_pool __rte_unused) {
+	struct pmd_internals *p = dev->data->dev_private;
+
+	if (p->params.soft.intrusive == 0) {
+		struct pmd_rx_queue *rxq;
+
+		rxq = rte_zmalloc_socket(p->params.soft.name,
+			sizeof(struct pmd_rx_queue), 0, socket_id);
+		if (rxq == NULL)
+			return -ENOMEM;
+
+		rxq->hard.port_id = p->hard.port_id;
+		rxq->hard.rx_queue_id = rx_queue_id;
+		dev->data->rx_queues[rx_queue_id] = rxq;
+	} else {
+		struct rte_eth_dev *hard_dev = PRIV_TO_HARD_DEV(p);
+		void *rxq = hard_dev->data->rx_queues[rx_queue_id];
+
+		if (rxq == NULL)
+			return -1;
+
+		dev->data->rx_queues[rx_queue_id] = rxq;
+	}
+	return 0;
+}
+
+static int
+pmd_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 __rte_unused) {
+	uint32_t size = RTE_ETH_NAME_MAX_LEN + strlen("_txq") + 4;
+	char name[size];
+	struct rte_ring *r;
+
+	snprintf(name, sizeof(name), "%s_txq%04x",
+		dev->data->name, tx_queue_id);
+	r = rte_ring_create(name, nb_tx_desc, socket_id,
+		RING_F_SP_ENQ | RING_F_SC_DEQ);
+	if (r == NULL)
+		return -1;
+
+	dev->data->tx_queues[tx_queue_id] = r;
+	return 0;
+}
+
+static int
+pmd_dev_start(struct rte_eth_dev *dev)
+{
+	struct pmd_internals *p = dev->data->dev_private;
+
+	dev->data->dev_link.link_status = ETH_LINK_UP;
+
+	if (p->params.soft.intrusive) {
+		struct rte_eth_dev *hard_dev = PRIV_TO_HARD_DEV(p);
+
+		/* The hard_dev->rx_pkt_burst should be stable by now */
+		dev->rx_pkt_burst = hard_dev->rx_pkt_burst;
+	}
+
+	return 0;
+}
+
+static void
+pmd_dev_stop(struct rte_eth_dev *dev)
+{
+	dev->data->dev_link.link_status = ETH_LINK_DOWN; }
+
+static void
+pmd_dev_close(struct rte_eth_dev *dev)
+{
+	uint32_t i;
+
+	/* TX queues */
+	for (i = 0; i < dev->data->nb_tx_queues; i++)
+		rte_ring_free((struct rte_ring *)dev->data->tx_queues[i]); }
+
+static int
+pmd_link_update(struct rte_eth_dev *dev __rte_unused,
+	int wait_to_complete __rte_unused)
+{
+	return 0;
+}
+
+static const struct eth_dev_ops pmd_ops = {
+	.dev_configure = pmd_dev_configure,
+	.dev_start = pmd_dev_start,
+	.dev_stop = pmd_dev_stop,
+	.dev_close = pmd_dev_close,
+	.link_update = pmd_link_update,
+	.dev_infos_get = pmd_dev_infos_get,
+	.rx_queue_setup = pmd_rx_queue_setup,
+	.tx_queue_setup = pmd_tx_queue_setup,
+	.tm_ops_get = NULL,
+};
+
+static uint16_t
+pmd_rx_pkt_burst(void *rxq,
+	struct rte_mbuf **rx_pkts,
+	uint16_t nb_pkts)
+{
+	struct pmd_rx_queue *rx_queue = rxq;
+
+	return rte_eth_rx_burst(rx_queue->hard.port_id,
+		rx_queue->hard.rx_queue_id,
+		rx_pkts,
+		nb_pkts);
+}
+
+static uint16_t
+pmd_tx_pkt_burst(void *txq,
+	struct rte_mbuf **tx_pkts,
+	uint16_t nb_pkts)
+{
+	return (uint16_t)rte_ring_enqueue_burst(txq,
+		(void **)tx_pkts,
+		nb_pkts,
+		NULL);
+}
+
+static __rte_always_inline int
+rte_pmd_softnic_run_default(struct rte_eth_dev *dev) {
+	struct pmd_internals *p = dev->data->dev_private;
+
+	/* Persistent context: Read Only (update not required) */
+	struct rte_mbuf **pkts = p->soft.def.pkts;
+	uint16_t nb_tx_queues = dev->data->nb_tx_queues;
+
+	/* Persistent context: Read - Write (update required) */
+	uint32_t txq_pos = p->soft.def.txq_pos;
+	uint32_t pkts_len = p->soft.def.pkts_len;
+	uint32_t flush_count = p->soft.def.flush_count;
+
+	/* Not part of the persistent context */
+	uint32_t pos;
+	uint16_t i;
+
+	/* Soft device TXQ read, Hard device TXQ write */
+	for (i = 0; i < nb_tx_queues; i++) {
+		struct rte_ring *txq = dev->data->tx_queues[txq_pos];
+
+		/* Read soft device TXQ burst to packet enqueue buffer */
+		pkts_len += rte_ring_sc_dequeue_burst(txq,
+			(void **)&pkts[pkts_len],
+			DEFAULT_BURST_SIZE,
+			NULL);
+
+		/* Increment soft device TXQ */
+		txq_pos++;
+		if (txq_pos >= nb_tx_queues)
+			txq_pos = 0;
+
+		/* Hard device TXQ write when complete burst is available */
+		if (pkts_len >= DEFAULT_BURST_SIZE) {
+			for (pos = 0; pos < pkts_len; )
+				pos += rte_eth_tx_burst(p->hard.port_id,
+					p->params.hard.tx_queue_id,
+					&pkts[pos],
+					(uint16_t)(pkts_len - pos));
+
+			pkts_len = 0;
+			flush_count = 0;
+			break;
+		}
+	}
+
+	if (flush_count >= FLUSH_COUNT_THRESHOLD) {
+		for (pos = 0; pos < pkts_len; )
+			pos += rte_eth_tx_burst(p->hard.port_id,
+				p->params.hard.tx_queue_id,
+				&pkts[pos],
+				(uint16_t)(pkts_len - pos));
+
+		pkts_len = 0;
+		flush_count = 0;
+	}
+
+	p->soft.def.txq_pos = txq_pos;
+	p->soft.def.pkts_len = pkts_len;
+	p->soft.def.flush_count = flush_count + 1;
+
+	return 0;
+}
+
+int
+rte_pmd_softnic_run(uint8_t port_id)
+{
+	struct rte_eth_dev *dev = &rte_eth_devices[port_id];
+
+#ifdef RTE_LIBRTE_ETHDEV_DEBUG
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, 0); #endif
+
+	return rte_pmd_softnic_run_default(dev); }
+
+static struct ether_addr eth_addr = { .addr_bytes = {0} };
+
+static uint32_t
+eth_dev_speed_max_mbps(uint32_t speed_capa) {
+	uint32_t rate_mbps[32] = {
+		ETH_SPEED_NUM_NONE,
+		ETH_SPEED_NUM_10M,
+		ETH_SPEED_NUM_10M,
+		ETH_SPEED_NUM_100M,
+		ETH_SPEED_NUM_100M,
+		ETH_SPEED_NUM_1G,
+		ETH_SPEED_NUM_2_5G,
+		ETH_SPEED_NUM_5G,
+		ETH_SPEED_NUM_10G,
+		ETH_SPEED_NUM_20G,
+		ETH_SPEED_NUM_25G,
+		ETH_SPEED_NUM_40G,
+		ETH_SPEED_NUM_50G,
+		ETH_SPEED_NUM_56G,
+		ETH_SPEED_NUM_100G,
+	};
+
+	uint32_t pos = (speed_capa) ? (31 - __builtin_clz(speed_capa)) : 0;
+	return rate_mbps[pos];
+}
+
+static int
+default_init(struct pmd_internals *p,
+	struct pmd_params *params,
+	int numa_node)
+{
+	p->soft.def.pkts = rte_zmalloc_socket(params->soft.name,
+		2 * DEFAULT_BURST_SIZE * sizeof(struct rte_mbuf *),
+		0,
+		numa_node);
+
+	if (p->soft.def.pkts == NULL)
+		return -ENOMEM;
+
+	return 0;
+}
+
+static void
+default_free(struct pmd_internals *p)
+{
+	free((void *)p->params.hard.name);
+	rte_free(p->soft.def.pkts);
+}
+
+static void *
+pmd_init(struct pmd_params *params, int numa_node) {
+	struct pmd_internals *p;
+	int status;
+
+	p = rte_zmalloc_socket(params->soft.name,
+		sizeof(struct pmd_internals),
+		0,
+		numa_node);
+	if (p == NULL)
+		return NULL;
+
+	memcpy(&p->params, params, sizeof(p->params));
+	status = rte_eth_dev_get_port_by_name(params->hard.name,
+		&p->hard.port_id);
+	if (status) {
+		rte_free(p);
+		return NULL;
+	}
+
+	/* Default */
+	status = default_init(p, params, numa_node);
+	if (status) {
+		rte_free(p);
+		return NULL;
+	}
+
+	return p;
+}
+
+static void
+pmd_free(struct pmd_internals *p)
+{
+	default_free(p);
+
+	rte_free(p);
+}
+
+static int
+pmd_ethdev_register(struct rte_vdev_device *vdev,
+	struct pmd_params *params,
+	void *dev_private)
+{
+	struct rte_eth_dev_info hard_info;
+	struct rte_eth_dev *soft_dev;
+	uint32_t hard_speed;
+	int numa_node;
+	uint8_t hard_port_id;
+
+	rte_eth_dev_get_port_by_name(params->hard.name,

&hard_port_id);

drivers/net/softnic/rte_eth_softnic.c new file +87 -0
+	rte_eth_dev_info_get(hard_port_id, &hard_info);
+	hard_speed = eth_dev_speed_max_mbps(hard_info.speed_capa);
+	numa_node = rte_eth_dev_socket_id(hard_port_id);
+
+	/* Ethdev entry allocation */
+	soft_dev = rte_eth_dev_allocate(params->soft.name);
+	if (!soft_dev)
+		return -ENOMEM;
+
+	/* dev */
+	soft_dev->rx_pkt_burst = (params->soft.intrusive) ?
+		NULL : /* set up later */
+		pmd_rx_pkt_burst;
+	soft_dev->tx_pkt_burst = pmd_tx_pkt_burst;
+	soft_dev->tx_pkt_prepare = NULL;
+	soft_dev->dev_ops = &pmd_ops;
+	soft_dev->device = &vdev->device;
+
+	/* dev->data */
+	soft_dev->data->dev_private = dev_private;
+	soft_dev->data->dev_link.link_speed = hard_speed;
+	soft_dev->data->dev_link.link_duplex = ETH_LINK_FULL_DUPLEX;
+	soft_dev->data->dev_link.link_autoneg = ETH_LINK_SPEED_FIXED;
+	soft_dev->data->dev_link.link_status = ETH_LINK_DOWN;
+	soft_dev->data->mac_addrs = &eth_addr;
+	soft_dev->data->promiscuous = 1;
+	soft_dev->data->kdrv = RTE_KDRV_NONE;
+	soft_dev->data->numa_node = numa_node;
+	soft_dev->data->dev_flags = RTE_ETH_DEV_DETACHABLE;
+
+	return 0;
+}
+
+static int
+get_string(const char *key __rte_unused, const char *value, void
+*extra_args) {
+	if (!value || !extra_args)
+		return -EINVAL;
+
+	*(char **)extra_args = strdup(value);
+
+	if (!*(char **)extra_args)
+		return -ENOMEM;
+
+	return 0;
+}
+
+static int
+get_uint32(const char *key __rte_unused, const char *value, void
+*extra_args) {
+	if (!value || !extra_args)
+		return -EINVAL;
+
+	*(uint32_t *)extra_args = strtoull(value, NULL, 0);
+
+	return 0;
+}
+
+static int
+pmd_parse_args(struct pmd_params *p, const char *name, const char
+*params) {
+	struct rte_kvargs *kvlist;
+	int ret;
+
+	kvlist = rte_kvargs_parse(params, pmd_valid_args);
+	if (kvlist == NULL)
+		return -EINVAL;
+
+	/* Set default values */
+	memset(p, 0, sizeof(*p));
+	p->soft.name = name;
+	p->soft.intrusive = INTRUSIVE;
+	p->hard.tx_queue_id = SOFTNIC_HARD_TX_QUEUE_ID;
+
+	/* HARD: name (mandatory) */
+	if (rte_kvargs_count(kvlist, PMD_PARAM_HARD_NAME) == 1) {
+		ret = rte_kvargs_process(kvlist, PMD_PARAM_HARD_NAME,
+			&get_string, &p->hard.name);
+		if (ret < 0)
+			goto out_free;
+	} else {
+		ret = -EINVAL;
+		goto out_free;
+	}
+
+	/* HARD: tx_queue_id (optional) */
+	if (rte_kvargs_count(kvlist, PMD_PARAM_HARD_TX_QUEUE_ID) == 1)

{

drivers/net/softnic/rte_eth_softnic.c new file +1 -0
+		ret = rte_kvargs_process(kvlist,

PMD_PARAM_HARD_TX_QUEUE_ID,

drivers/net/softnic/rte_eth_softnic.c new file +31 -0
+			&get_uint32, &p->hard.tx_queue_id);
+		if (ret < 0)
+			goto out_free;
+	}
+
+out_free:
+	rte_kvargs_free(kvlist);
+	return ret;
+}
+
+static int
+pmd_probe(struct rte_vdev_device *vdev) {
+	struct pmd_params p;
+	const char *params;
+	int status;
+
+	struct rte_eth_dev_info hard_info;
+	uint8_t hard_port_id;
+	int numa_node;
+	void *dev_private;
+
+	RTE_LOG(INFO, PMD,
+		"Probing device \"%s\"\n",
+		rte_vdev_device_name(vdev));
+
+	/* Parse input arguments */
+	params = rte_vdev_device_args(vdev);
+	if (!params)
+		return -EINVAL;
+
+	status = pmd_parse_args(&p, rte_vdev_device_name(vdev),

params);

drivers/net/softnic/rte_eth_softnic.c new file +66 -0
+	if (status)
+		return status;
+
+	/* Check input arguments */
+	if (rte_eth_dev_get_port_by_name(p.hard.name, &hard_port_id))
+		return -EINVAL;
+
+	rte_eth_dev_info_get(hard_port_id, &hard_info);
+	numa_node = rte_eth_dev_socket_id(hard_port_id);
+
+	if (p.hard.tx_queue_id >= hard_info.max_tx_queues)
+		return -EINVAL;
+
+	/* Allocate and initialize soft ethdev private data */
+	dev_private = pmd_init(&p, numa_node);
+	if (dev_private == NULL)
+		return -ENOMEM;
+
+	/* Register soft ethdev */
+	RTE_LOG(INFO, PMD,
+		"Creating soft ethdev \"%s\" for hard ethdev \"%s\"\n",
+		p.soft.name, p.hard.name);
+
+	status = pmd_ethdev_register(vdev, &p, dev_private);
+	if (status) {
+		pmd_free(dev_private);
+		return status;
+	}
+
+	return 0;
+}
+
+static int
+pmd_remove(struct rte_vdev_device *vdev) {
+	struct rte_eth_dev *dev = NULL;
+	struct pmd_internals *p;
+
+	if (!vdev)
+		return -EINVAL;
+
+	RTE_LOG(INFO, PMD, "Removing device \"%s\"\n",
+		rte_vdev_device_name(vdev));
+
+	/* Find the ethdev entry */
+	dev = rte_eth_dev_allocated(rte_vdev_device_name(vdev));
+	if (dev == NULL)
+		return -ENODEV;
+	p = dev->data->dev_private;
+
+	/* Free device data structures*/
+	pmd_free(p);
+	rte_free(dev->data);
+	rte_eth_dev_release_port(dev);
+
+	return 0;
+}
+
+static struct rte_vdev_driver pmd_softnic_drv = {
+	.probe = pmd_probe,
+	.remove = pmd_remove,
+};
+
+RTE_PMD_REGISTER_VDEV(net_softnic, pmd_softnic_drv);
+RTE_PMD_REGISTER_PARAM_STRING(net_softnic,
+	PMD_PARAM_HARD_NAME "=<string> "
+	PMD_PARAM_HARD_TX_QUEUE_ID "=<int>");
drivers/net/softnic/rte_eth_softnic.h new file +21 -0
new file mode 100644
index 0000000..e6996f3
@@ -0,0 +1,67 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2017 Intel Corporation. All rights reserved.
+ *   All rights reserved.
+ *
+ *   Redistribution and use in source and binary forms, with or without
+ *   modification, are permitted provided that the following conditions
+ *   are met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in
+ *       the documentation and/or other materials provided with the
+ *       distribution.
+ *     * Neither the name of Intel Corporation nor the names of its
+ *       contributors may be used to endorse or promote products derived
+ *       from this software without specific prior written permission.
+ *
+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND

CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT
NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.
+ */

drivers/net/softnic/rte_eth_softnic.h new file +37 -0
+
+#ifndef __INCLUDE_RTE_ETH_SOFTNIC_H__
+#define __INCLUDE_RTE_ETH_SOFTNIC_H__
+
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef SOFTNIC_HARD_TX_QUEUE_ID
+#define SOFTNIC_HARD_TX_QUEUE_ID			0
+#endif
+
+/**
+ * Run the traffic management function on the softnic device
+ *
+ * This function read the packets from the softnic input queues, insert
+into
+ * QoS scheduler queues based on mbuf sched field value and transmit
+the
+ * scheduled packets out through the hard device interface.
+ *
+ * @param portid
+ *    port id of the soft device.
+ * @return
+ *    zero.
+ */
+
+int
+rte_pmd_softnic_run(uint8_t port_id);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __INCLUDE_RTE_ETH_SOFTNIC_H__ */
drivers/net/softnic/rte_eth_softnic_internals.h new file +21 -0
new file mode 100644
index 0000000..96995b5
@@ -0,0 +1,114 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2017 Intel Corporation. All rights reserved.
+ *   All rights reserved.
+ *
+ *   Redistribution and use in source and binary forms, with or without
+ *   modification, are permitted provided that the following conditions
+ *   are met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in
+ *       the documentation and/or other materials provided with the
+ *       distribution.
+ *     * Neither the name of Intel Corporation nor the names of its
+ *       contributors may be used to endorse or promote products derived
+ *       from this software without specific prior written permission.
+ *
+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND

CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT
NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.
+ */

drivers/net/softnic/rte_eth_softnic_internals.h new file +22 -0
+
+#ifndef __INCLUDE_RTE_ETH_SOFTNIC_INTERNALS_H__
+#define __INCLUDE_RTE_ETH_SOFTNIC_INTERNALS_H__
+
+#include <stdint.h>
+
+#include <rte_mbuf.h>
+#include <rte_ethdev.h>
+
+#include "rte_eth_softnic.h"
+
+#ifndef INTRUSIVE
+#define INTRUSIVE					0
+#endif
+
+struct pmd_params {
+	/** Parameters for the soft device (to be created) */
+	struct {
+		const char *name; /**< Name */
+		uint32_t flags; /**< Flags */
+
+		/** 0 = Access hard device though API only (potentially

slower,

drivers/net/softnic/rte_eth_softnic_internals.h new file +60 -0
+		 *      but safer);
+		 *  1 = Access hard device private data structures is allowed
+		 *      (potentially faster).
+		 */
+		int intrusive;
+	} soft;
+
+	/** Parameters for the hard device (existing) */
+	struct {
+		char *name; /**< Name */
+		uint16_t tx_queue_id; /**< TX queue ID */
+	} hard;
+};
+
+/**
+ * Default Internals
+ */
+
+#ifndef DEFAULT_BURST_SIZE
+#define DEFAULT_BURST_SIZE				32
+#endif
+
+#ifndef FLUSH_COUNT_THRESHOLD
+#define FLUSH_COUNT_THRESHOLD			(1 << 17)
+#endif
+
+struct default_internals {
+	struct rte_mbuf **pkts;
+	uint32_t pkts_len;
+	uint32_t txq_pos;
+	uint32_t flush_count;
+};
+
+/**
+ * PMD Internals
+ */
+struct pmd_internals {
+	/** Params */
+	struct pmd_params params;
+
+	/** Soft device */
+	struct {
+		struct default_internals def; /**< Default */
+	} soft;
+
+	/** Hard device */
+	struct {
+		uint8_t port_id;
+	} hard;
+};
+
+struct pmd_rx_queue {
+	/** Hard device */
+	struct {
+		uint8_t port_id;
+		uint16_t rx_queue_id;
+	} hard;
+};
+
+#endif /* __INCLUDE_RTE_ETH_SOFTNIC_INTERNALS_H__ */
drivers/net/softnic/rte_pmd_eth_softnic_version.map new file +7 -0
new file mode 100644
index 0000000..fb2cb68
@@ -0,0 +1,7 @@
+DPDK_17.11 {
+	global:
+
+	rte_pmd_softnic_run;
+
+	local: *;
+};
mk/rte.app.mk +0 -0
@@ -67,7 +67,6 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR)    += -

lrte_distributor

 _LDLIBS-$(CONFIG_RTE_LIBRTE_IP_FRAG)        += -lrte_ip_frag
 _LDLIBS-$(CONFIG_RTE_LIBRTE_GRO)            += -lrte_gro
 _LDLIBS-$(CONFIG_RTE_LIBRTE_METER)          += -lrte_meter
mk/rte.app.mk +0 -1
-_LDLIBS-$(CONFIG_RTE_LIBRTE_SCHED)          += -lrte_sched
 _LDLIBS-$(CONFIG_RTE_LIBRTE_LPM)            += -lrte_lpm
 # librte_acl needs --whole-archive because of weak functions
 _LDLIBS-$(CONFIG_RTE_LIBRTE_ACL)            += --whole-archive
@@ -99,6 +98,7 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_RING)           += -

lrte_ring

 _LDLIBS-$(CONFIG_RTE_LIBRTE_EAL)            += -lrte_eal
 _LDLIBS-$(CONFIG_RTE_LIBRTE_CMDLINE)        += -lrte_cmdline
 _LDLIBS-$(CONFIG_RTE_LIBRTE_REORDER)        += -lrte_reorder
mk/rte.app.mk +1 -0
+_LDLIBS-$(CONFIG_RTE_LIBRTE_SCHED)          += -lrte_sched
 
 ifeq ($(CONFIG_RTE_EXEC_ENV_LINUXAPP),y)
 _LDLIBS-$(CONFIG_RTE_LIBRTE_KNI)            += -lrte_kni
@@ -135,6 +135,9 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_NULL)       += -

lrte_pmd_null

 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_PCAP)       += -lrte_pmd_pcap -lpcap
 _LDLIBS-$(CONFIG_RTE_LIBRTE_QEDE_PMD)       += -lrte_pmd_qede
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_RING)       += -lrte_pmd_ring
mk/rte.app.mk +3 -0
+ifeq ($(CONFIG_RTE_LIBRTE_SCHED),y)
+_LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_SOFTNIC)      += -lrte_pmd_softnic
+endif
 _LDLIBS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD)    += -lrte_pmd_sfc_efx
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_SZEDATA2)   += -lrte_pmd_szedata2 -

lsze2
_LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_TAP) += -lrte_pmd_tap
--
2.9.3

#13 lore raw

Re: [PATCH v4 1/4] net/softnic: add softnic PMD

18/09/2017 18:58, Singh, Jasvinder:

Quoted 3 lines

Hi Thomas,

I don't see this patch in patchwork, although it is present in email archive. Any guess why it is not showing up there?

No idea.
Not a big deal, others are there.

#14 lore raw

PATCH v4 2/4 net/softnic: add traffic management support

In reply to Jasvinder Singh

Add ethdev Traffic Management API support to SoftNIC PMD.

---
v3 changes:
- add more confguration parameters (tm rate, tm queue sizes)

 drivers/net/softnic/Makefile                    |   1 +
 drivers/net/softnic/rte_eth_softnic.c           | 252 +++++++++++++++++++++++-
 drivers/net/softnic/rte_eth_softnic.h           |  16 ++
 drivers/net/softnic/rte_eth_softnic_internals.h | 106 +++++++++-
 drivers/net/softnic/rte_eth_softnic_tm.c        | 181 +++++++++++++++++
 5 files changed, 553 insertions(+), 3 deletions(-)
 create mode 100644 drivers/net/softnic/rte_eth_softnic_tm.c
drivers/net/softnic/Makefile +1 -0
index c2f42ef..8b848a9 100644
@@ -47,6 +47,7 @@ LIBABIVER := 1
 # all source are stored in SRCS-y
 #
 SRCS-$(CONFIG_RTE_LIBRTE_PMD_SOFTNIC) += rte_eth_softnic.c
+SRCS-$(CONFIG_RTE_LIBRTE_PMD_SOFTNIC) += rte_eth_softnic_tm.c
 
 #
 # Export include files
drivers/net/softnic/rte_eth_softnic.c +250 -2

341 lines not on this page · raw message

drivers/net/softnic/rte_eth_softnic.h +16 -0
index e6996f3..517b96a 100644
@@ -40,6 +40,22 @@
 extern "C" {
 #endif
 
+#ifndef SOFTNIC_SOFT_TM_NB_QUEUES
+#define SOFTNIC_SOFT_TM_NB_QUEUES			65536
+#endif
+
+#ifndef SOFTNIC_SOFT_TM_QUEUE_SIZE
+#define SOFTNIC_SOFT_TM_QUEUE_SIZE			64
+#endif
+
+#ifndef SOFTNIC_SOFT_TM_ENQ_BSZ
+#define SOFTNIC_SOFT_TM_ENQ_BSZ				32
+#endif
+
+#ifndef SOFTNIC_SOFT_TM_DEQ_BSZ
+#define SOFTNIC_SOFT_TM_DEQ_BSZ				24
+#endif
+
 #ifndef SOFTNIC_HARD_TX_QUEUE_ID
 #define SOFTNIC_HARD_TX_QUEUE_ID			0
 #endif
drivers/net/softnic/rte_eth_softnic_internals.h +105 -1

144 lines not on this page · raw message

drivers/net/softnic/rte_eth_softnic_tm.c new file +181 -0

181 lines not on this page · raw message

Signature · 1 line
2.9.3
#15 lore raw

Re: [PATCH v4 2/4] net/softnic: add traffic management support

Hi Jasvinder,

Quoted 31 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Jasvinder Singh
Sent: Monday, September 18, 2017 5:10 PM
To: [email protected]
Cc: Dumitrescu, Cristian <[email protected]>; Yigit, Ferruh <[email protected]>; [email protected]
Subject: [dpdk-dev] [PATCH v4 2/4] net/softnic: add traffic management support

Add ethdev Traffic Management API support to SoftNIC PMD.

---
v3 changes:
- add more confguration parameters (tm rate, tm queue sizes)

 drivers/net/softnic/Makefile                    |   1 +
 drivers/net/softnic/rte_eth_softnic.c           | 252
+++++++++++++++++++++++-
 drivers/net/softnic/rte_eth_softnic.h           |  16 ++
 drivers/net/softnic/rte_eth_softnic_internals.h | 106 +++++++++-
 drivers/net/softnic/rte_eth_softnic_tm.c        | 181 +++++++++++++++++
 5 files changed, 553 insertions(+), 3 deletions(-)  create mode 100644

drivers/net/softnic/rte_eth_softnic_tm.c

static void

drivers/net/softnic/rte_eth_softnic.c rte_pmd_softnic_run_default(struct rte_eth_dev · line 330

Quoted 6 lines
drivers/net/softnic/rte_eth_softnic.c +2 -0
@@ -293,6 +325,77 @@ rte_pmd_softnic_run_default(struct rte_eth_dev
 *dev)
 	return 0;
 }
 
+static __rte_always_inline int
+rte_pmd_softnic_run_tm(struct rte_eth_dev *dev) {

This function name seems a little misleading. If it's a inline function not an API, better just name it 'softnic_run_tm".
And a common comments for the names, like, pmd_feature, tm_params_check, tm_init ... if they're only for soft nic, better add the prefix 'softnc_' for them.

#16 lore raw

Re: [PATCH v4 2/4] net/softnic: add traffic management support

Quoted 38 lines

Hi Jasvinder,

Quoted 35 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Jasvinder Singh
Sent: Monday, September 18, 2017 5:10 PM
To: [email protected]
Cc: Dumitrescu, Cristian <[email protected]>; Yigit, Ferruh <[email protected]>; [email protected]
Subject: [dpdk-dev] [PATCH v4 2/4] net/softnic: add traffic management support

Add ethdev Traffic Management API support to SoftNIC PMD.

---
v3 changes:
- add more confguration parameters (tm rate, tm queue sizes)

 drivers/net/softnic/Makefile                    |   1 +
 drivers/net/softnic/rte_eth_softnic.c           | 252
+++++++++++++++++++++++-
 drivers/net/softnic/rte_eth_softnic.h           |  16 ++
 drivers/net/softnic/rte_eth_softnic_internals.h | 106 +++++++++-
 drivers/net/softnic/rte_eth_softnic_tm.c        | 181 +++++++++++++++++
 5 files changed, 553 insertions(+), 3 deletions(-)  create mode

100644 drivers/net/softnic/rte_eth_softnic_tm.c

static void

drivers/net/softnic/rte_eth_softnic.c +0 -0
@@ -293,6 +325,77 @@ rte_pmd_softnic_run_default(struct rte_eth_dev
 *dev)
 	return 0;
 }
 
Quoted 7 lines

Review rte_pmd_softnic_run_default(struct rte_eth_dev · line 330

Quoted 2 lines
(quoted diff) +2 -0
+static __rte_always_inline int
+rte_pmd_softnic_run_tm(struct rte_eth_dev *dev) {

This function name seems a little misleading. If it's a inline function not an API, better just name it 'softnic_run_tm".
And a common comments for the names, like, pmd_feature, tm_params_check, tm_init ... if they're only for soft nic, better add the prefix 'softnc_' for them.

Ok, will change the above function name for clarity. Thanks.

#17 lore raw

v5 cover net/softnic: sw fall-back pmd for traffic mgmt and others

In reply to Jasvinder Singh

The SoftNIC PMD is intended to provide SW fall-back options for specific ethdev APIs in a generic way to the NICs not supporting those features.

Currently, the only implemented ethdev API is Traffic Management (TM), but other ethdev APIs such as rte_flow, traffic metering & policing, etc can be easily implemented.

Overview:
* Generic: The SoftNIC PMD works with any "hard" PMD that implements the ethdev API. It does not change the "hard" PMD in any way.
* Creation: For any given "hard" ethdev port, the user can decide to create an associated "soft" ethdev port to drive the "hard" port. The "soft" port is a virtual device that can be created at app start-up through EAL vdev arg or later through the virtual device API.
* Configuration: The app explicitly decides which features are to be enabled on the "soft" port and which features are still to be used from the "hard" port. The app continues to explicitly configure both the "hard" and the "soft" ports after the creation of the "soft" port.
* RX/TX: The app reads packets from/writes packets to the "soft" port instead of the "hard" port. The RX and TX queues of the "soft" port are thread safe, as any ethdev.
* Execution: The "soft" port is a feature-rich NIC implemented by the CPU, so the run function of the "soft" port has to be executed by the CPU in order to get packets moving between "hard" port and the app.
* Meets the NFV vision: The app should be (almost) agnostic about the NIC implementation (different vendors/models, HW-SW mix), the app should not require changes to use different NICs, the app should use the same API for all NICs. If a NIC does not implement a specific feature, the HW should be augmented with SW to meet the functionality while still preserving the same API.

Traffic Management SW fall-back overview:
* Implements the ethdev traffic management API (rte_tm.h).
* Based on the existing librte_sched DPDK library.

Example: Create "soft" port for "hard" port "0000:04:00.1", enable the TM feature with default settings:

          --vdev 'net_softnic0,hard_name=0000:04:00.1,soft_tm=on' 

Q1: Why generic name, if only TM is supported (for now)?
A1: The intention is to have SoftNIC PMD implement many other (all?)
ethdev APIs under a single "ideal" ethdev, hence the generic name. The initial motivation is TM API, but the mechanism is generic and can be used for many other ethdev APIs. Somebody looking to provide SW fall-back for other ethdev API is likely to end up inventing the same, hence it would be good to consolidate all under a single PMD and have the user explicitly enable/disable the features it needs for each "soft" device.

Q2: Are there any performance requirements for SoftNIC?
A2: Yes, performance should be great/decent for every feature, otherwise
the SW fall-back is unusable, thus useless.

Q3: Why not change the "hard" device (and keep a single device) instead of
creating a new "soft" device (and thus having two devices)?
A3: This is not possible with the current librte_ether ethdev
implementation. The ethdev->dev_ops are defined as constant structure, so it cannot be changed per device (nor per PMD). The new ops also need memory space to store their context data structures, which requires updating the ethdev->data->dev_private of the existing device; at best, maybe a resize of ethdev->data->dev_private could be done, assuming that librte_ether will introduce a way to find out its size, but this cannot be done while device is running. Other side effects might exist, as the changes are very intrusive, plus it likely needs more changes in librte_ether.

Q4: Why not call the SW fall-back dev_ops directly in librte_ether for
devices which do not support the specific feature? If the device supports the capability, let's call its dev_ops, otherwise call the SW fall-back dev_ops.
A4: First, similar reasons to Q&A3. This fixes the need to change
ethdev->dev_ops of the device, but it does not do anything to fix the other significant issue of where to store the context data structures needed by the SW fall-back functions (which, in this approach, are called implicitly by librte_ether).
Second, the SW fall-back options should not be restricted arbitrarily by the librte_ether library, the decision should belong to the app. For example, the TM SW fall-back should not be limited to only librte_sched, which (like any SW fall-back) is limited to a specific hierarchy and feature set, it cannot do any possible hierarchy. If alternatives exist, the one to use should be picked by the app, not by the ethdev layer.

Q5: Why is the app required to continue to configure both the "hard" and
the "soft" devices even after the "soft" device has been created? Why not hiding the "hard" device under the "soft" device and have the "soft" device configure the "hard" device under the hood?
A5: This was the approach tried in the V2 of this patch set (overlay
"soft" device taking over the configuration of the underlay "hard" device) and eventually dropped due to increased complexity of having to keep the configuration of two distinct devices in sync with librte_ether implementation that is not friendly towards such approach. Basically, each ethdev API call for the overlay device needs to configure the overlay device, invoke the same configuration with possibly modified parameters for the underlay device, then resume the configuration of overlay device, turning this into a device emulation project.
V2 minuses: increased complexity (deal with two devices at same time); need to implement every ethdev API, even those not needed for the scope of SW fall-back; intrusive; sometimes have to silently take decisions that should be left to the app.
V3 pluses: lower complexity (only one device); only need to implement those APIs that are in scope of the SW fall-back; non-intrusive (deal with "hard" device through ethdev API); app decisions taken by the app in an explicit way.

Q6: Why expose the SW fall-back in a PMD and not in a SW library?
A6: The SW fall-back for an ethdev API has to implement that specific
ethdev API, (hence expose an ethdev object through a PMD), as opposed to providing a different API. This approach allows the app to use the same API (NFV vision). For example, we already have a library for TM SW fall-back (librte_sched) that can be called directly by the apps that need to call it outside of ethdev context (use-cases exist), but an app that works with TM-aware NICs through the ethdev TM API would have to be changed significantly in order to work with different TM-agnostic NICs through the librte_sched API.

Q7: Why have all the SW fall-backs in a single PMD? Why not develop
the SW fall-back for each different ethdev API in a separate PMD, then create a chain of "soft" devices for each "hard" device? Potentially, this results in smaller size PMDs that are easier to maintain.
A7: Arguments for single ethdev/PMD and against chain of ethdevs/PMDs:
1. All the existing PMDs for HW NICs implement a lot of features under the same PMD, so there is no reason for single PMD approach to break code modularity. See the V3 code, a lot of care has been taken for code modularity.
2. We should avoid the proliferation of SW PMDs.
3. A single device should be handled by a single PMD.
4. People are used with feature-rich PMDs, not with single-feature PMDs, so we change of mindset?
5. [Configuration nightmare] A chain of "soft" devices attached to single "hard" device requires the app to be aware that the N "soft" devices in the chain plus the "hard" device refer to the same HW device, and which device should be invoked to configure which feature. Also the length of the chain and functionality of each link is different for each HW device. This breaks the requirement of preserving the same API while working with different NICs (NFV). This most likely results in a configuration nightmare, nobody is going to seriously use this.
6. [Feature inter-dependecy] Sometimes different features need to be configured and executed together (e.g. share the same set of resources, are inter-dependent, etc), so it is better and more performant to do them in the same ethdev/PMD.
7. [Code duplication] There is a lot of duplication in the configuration code for the chain of ethdevs approach. The ethdev dev_configure, rx_queue_setup, tx_queue_setup API functions have to be implemented per device, and they become meaningless/inconsistent with the chain approach.
8. [Data structure duplication] The per device data structures have to be duplicated and read repeatedly for each "soft" ethdev. The ethdev device, dev_private, data, per RX/TX queue data structures have to be replicated per "soft" device. They have to be re-read for each stage, so the same cache misses are now multiplied with the number of stages in the chain.
9. [rte_ring proliferation] Thread safety requirements for ethdev RX/TXqueues require an rte_ring to be used for every RX/TX queue of each "soft" ethdev. This rte_ring proliferation unnecessarily increases the memory footprint and lowers performance, especially when each "soft" ethdev ends up on a different CPU core (ping-pong of cache lines).
10.[Meta-data proliferation] A chain of ethdevs is likely to result
in proliferation of meta-data that has to be passed between the ethdevs (e.g. policing needs the output of flow classification), which results in more cache line ping-pong between cores, hence performance drops.

Cristian Dumitrescu (4):
Jasvinder Singh (4):
net/softnic: add softnic PMD
net/softnic: add traffic management support
net/softnic: add TM capabilities ops
net/softnic: add TM hierarchy related ops

Jasvinder Singh (1):
app/testpmd: add traffic management forwarding mode

 MAINTAINERS                                        |    5 +
 app/test-pmd/Makefile                              |    8 +
 app/test-pmd/cmdline.c                             |   88 +
 app/test-pmd/testpmd.c                             |   15 +
 app/test-pmd/testpmd.h                             |   46 +
 app/test-pmd/tm.c                                  |  865 +++++
 config/common_base                                 |    5 +
 doc/api/doxy-api-index.md                          |    3 +-
 doc/api/doxy-api.conf                              |    1 +
 doc/guides/rel_notes/release_17_11.rst             |    6 +
 drivers/net/Makefile                               |    5 +
 drivers/net/softnic/Makefile                       |   57 +
 drivers/net/softnic/rte_eth_softnic.c              |  852 +++++
 drivers/net/softnic/rte_eth_softnic.h              |   83 +
 drivers/net/softnic/rte_eth_softnic_internals.h    |  291 ++
 drivers/net/softnic/rte_eth_softnic_tm.c           | 3452 ++++++++++++++++++++
 .../net/softnic/rte_pmd_eth_softnic_version.map    |    7 +
 mk/rte.app.mk                                      |    5 +-
 18 files changed, 5792 insertions(+), 2 deletions(-)
 create mode 100644 app/test-pmd/tm.c
 create mode 100644 drivers/net/softnic/Makefile
 create mode 100644 drivers/net/softnic/rte_eth_softnic.c
 create mode 100644 drivers/net/softnic/rte_eth_softnic.h
 create mode 100644 drivers/net/softnic/rte_eth_softnic_internals.h
 create mode 100644 drivers/net/softnic/rte_eth_softnic_tm.c
 create mode 100644 drivers/net/softnic/rte_pmd_eth_softnic_version.map

Series Acked-by: Cristian Dumitrescu <[email protected]>

Signature · 1 line
2.9.3
#18 lore raw

PATCH v5 1/5 net/softnic: add softnic PMD

Add SoftNIC PMD to provide SW fall-back for ethdev APIs.

---
v5 changes:
- change function name rte_pmd_softnic_run_default() to run_default()

v4 changes:
- Implemented feedback from Ferruh [1]
- rename map file to rte_pmd_eth_softnic_version.map
- add release notes library version info
- doxygen: fix hooks in doc/api/doxy-api-index.md
- add doxygen comment for rte_pmd_softnic_run()
- free device name memory
- remove soft_dev param in pmd_ethdev_register()
- fix checkpatch warnings

v3 changes:
- rebase to dpdk17.08 release

v2 changes:
- fix build errors
- rebased to TM APIs v6 plus dpdk master

[1] Ferruh�s feedback on v3: http://dpdk.org/ml/archives/dev/2017-September/074576.html

 MAINTAINERS                                        |   5 +
 config/common_base                                 |   5 +
 doc/api/doxy-api-index.md                          |   3 +-
 doc/api/doxy-api.conf                              |   1 +
 doc/guides/rel_notes/release_17_11.rst             |   6 +
 drivers/net/Makefile                               |   5 +
 drivers/net/softnic/Makefile                       |  56 ++
 drivers/net/softnic/rte_eth_softnic.c              | 591 +++++++++++++++++++++
 drivers/net/softnic/rte_eth_softnic.h              |  67 +++
 drivers/net/softnic/rte_eth_softnic_internals.h    | 114 ++++
 .../net/softnic/rte_pmd_eth_softnic_version.map    |   7 +
 mk/rte.app.mk                                      |   5 +-
 12 files changed, 863 insertions(+), 2 deletions(-)
 create mode 100644 drivers/net/softnic/Makefile
 create mode 100644 drivers/net/softnic/rte_eth_softnic.c
 create mode 100644 drivers/net/softnic/rte_eth_softnic.h
 create mode 100644 drivers/net/softnic/rte_eth_softnic_internals.h
 create mode 100644 drivers/net/softnic/rte_pmd_eth_softnic_version.map
MAINTAINERS +5 -0
index 8df2a7f..8719e5f 100644
@@ -514,6 +514,11 @@ M: Gaetan Rivet <[email protected]>
 F: drivers/net/failsafe/
 F: doc/guides/nics/fail_safe.rst
 
+Softnic PMD
+M: Jasvinder Singh <[email protected]>
+M: Cristian Dumitrescu <[email protected]>
+F: drivers/net/softnic
+
 
 Crypto Drivers
 --------------
config/common_base +5 -0
index 12f6be9..76ef2b9 100644
@@ -274,6 +274,11 @@ CONFIG_RTE_LIBRTE_SFC_EFX_PMD=y
 CONFIG_RTE_LIBRTE_SFC_EFX_DEBUG=n
 
 #
+# Compile SOFTNIC PMD
+#
+CONFIG_RTE_LIBRTE_PMD_SOFTNIC=y
+
+#
 # Compile software PMD backed by SZEDATA2 device
 #
 CONFIG_RTE_LIBRTE_PMD_SZEDATA2=n
doc/api/doxy-api-index.md +2 -1
index 19e0d4f..626ab51 100644
@@ -55,7 +55,8 @@ The public API headers are grouped by topics:
   [KNI]                (@ref rte_kni.h),
   [ixgbe]              (@ref rte_pmd_ixgbe.h),
   [i40e]               (@ref rte_pmd_i40e.h),
-  [crypto_scheduler]   (@ref rte_cryptodev_scheduler.h)
+  [crypto_scheduler]   (@ref rte_cryptodev_scheduler.h),
+  [softnic]            (@ref rte_eth_softnic.h)
 
 - **memory**:
   [memseg]             (@ref rte_memory.h),
doc/api/doxy-api.conf +1 -0
index 823554f..b27755d 100644
@@ -32,6 +32,7 @@ PROJECT_NAME            = DPDK
 INPUT                   = doc/api/doxy-api-index.md \
                           drivers/crypto/scheduler \
                           drivers/net/bonding \
+                          drivers/net/softnic \
                           drivers/net/i40e \
                           drivers/net/ixgbe \
                           lib/librte_eal/common/include \
doc/guides/rel_notes/release_17_11.rst +6 -0
index 8bf91bd..32d3af3 100644
@@ -41,6 +41,11 @@ New Features
      Also, make sure to start the actual text at the margin.
      =========================================================
 
+* **Added SoftNIC PMD.**
+
+  Added new SoftNIC PMD. This virtual device offers applications a software
+  fallback support for traffic management.
+
 
 Resolved Issues
 ---------------
@@ -190,6 +195,7 @@ The libraries prepended with a plus sign were incremented in this version.
      librte_pipeline.so.3
      librte_pmd_bond.so.1
      librte_pmd_ring.so.2
+   + librte_pmd_softnic.so.1
      librte_port.so.3
      librte_power.so.1
      librte_reorder.so.1
drivers/net/Makefile +5 -0
index d33c959..b552a51 100644
@@ -110,4 +110,9 @@ DIRS-$(CONFIG_RTE_LIBRTE_PMD_VHOST) += vhost
 endif # $(CONFIG_RTE_LIBRTE_VHOST)
 DEPDIRS-vhost = $(core-libs) librte_vhost
 
+ifeq ($(CONFIG_RTE_LIBRTE_SCHED),y)
+DIRS-$(CONFIG_RTE_LIBRTE_PMD_SOFTNIC) += softnic
+endif # $(CONFIG_RTE_LIBRTE_SCHED)
+DEPDIRS-softnic = $(core-libs) librte_sched
+
 include $(RTE_SDK)/mk/rte.subdir.mk
drivers/net/softnic/Makefile new file +56 -0

56 lines not on this page · raw message

drivers/net/softnic/rte_eth_softnic.c new file +591 -0

591 lines not on this page · raw message

drivers/net/softnic/rte_eth_softnic.h new file +67 -0

67 lines not on this page · raw message

drivers/net/softnic/rte_eth_softnic_internals.h new file +114 -0

114 lines not on this page · raw message

drivers/net/softnic/rte_pmd_eth_softnic_version.map new file +7 -0
new file mode 100644
index 0000000..fb2cb68
@@ -0,0 +1,7 @@
+DPDK_17.11 {
+	global:
+
+	rte_pmd_softnic_run;
+
+	local: *;
+};
mk/rte.app.mk +4 -1
index c25fdd9..3dc82fb 100644
@@ -67,7 +67,6 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR)    += -lrte_distributor
 _LDLIBS-$(CONFIG_RTE_LIBRTE_IP_FRAG)        += -lrte_ip_frag
 _LDLIBS-$(CONFIG_RTE_LIBRTE_GRO)            += -lrte_gro
 _LDLIBS-$(CONFIG_RTE_LIBRTE_METER)          += -lrte_meter
-_LDLIBS-$(CONFIG_RTE_LIBRTE_SCHED)          += -lrte_sched
 _LDLIBS-$(CONFIG_RTE_LIBRTE_LPM)            += -lrte_lpm
 # librte_acl needs --whole-archive because of weak functions
 _LDLIBS-$(CONFIG_RTE_LIBRTE_ACL)            += --whole-archive
@@ -99,6 +98,7 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_RING)           += -lrte_ring
 _LDLIBS-$(CONFIG_RTE_LIBRTE_EAL)            += -lrte_eal
 _LDLIBS-$(CONFIG_RTE_LIBRTE_CMDLINE)        += -lrte_cmdline
 _LDLIBS-$(CONFIG_RTE_LIBRTE_REORDER)        += -lrte_reorder
+_LDLIBS-$(CONFIG_RTE_LIBRTE_SCHED)          += -lrte_sched
 
 ifeq ($(CONFIG_RTE_EXEC_ENV_LINUXAPP),y)
 _LDLIBS-$(CONFIG_RTE_LIBRTE_KNI)            += -lrte_kni
@@ -135,6 +135,9 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_NULL)       += -lrte_pmd_null
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_PCAP)       += -lrte_pmd_pcap -lpcap
 _LDLIBS-$(CONFIG_RTE_LIBRTE_QEDE_PMD)       += -lrte_pmd_qede
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_RING)       += -lrte_pmd_ring
+ifeq ($(CONFIG_RTE_LIBRTE_SCHED),y)
+_LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_SOFTNIC)      += -lrte_pmd_softnic
+endif
 _LDLIBS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD)    += -lrte_pmd_sfc_efx
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_SZEDATA2)   += -lrte_pmd_szedata2 -lsze2
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_TAP)        += -lrte_pmd_tap
Signature · 1 line
2.9.3
#19 lore raw

PATCH v5 2/5 net/softnic: add traffic management support

In reply to Jasvinder Singh

Add ethdev Traffic Management API support to SoftNIC PMD.

---
v5 changes:
- change function name rte_pmd_softnic_run_tm() to run_tm()

v3 changes:
- add more confguration parameters (tm rate, tm queue sizes)

 drivers/net/softnic/Makefile                    |   1 +
 drivers/net/softnic/rte_eth_softnic.c           | 255 +++++++++++++++++++++++-
 drivers/net/softnic/rte_eth_softnic.h           |  16 ++
 drivers/net/softnic/rte_eth_softnic_internals.h | 104 ++++++++++
 drivers/net/softnic/rte_eth_softnic_tm.c        | 181 +++++++++++++++++
 5 files changed, 555 insertions(+), 2 deletions(-)
 create mode 100644 drivers/net/softnic/rte_eth_softnic_tm.c
drivers/net/softnic/Makefile +1 -0
index c2f42ef..8b848a9 100644
@@ -47,6 +47,7 @@ LIBABIVER := 1
 # all source are stored in SRCS-y
 #
 SRCS-$(CONFIG_RTE_LIBRTE_PMD_SOFTNIC) += rte_eth_softnic.c
+SRCS-$(CONFIG_RTE_LIBRTE_PMD_SOFTNIC) += rte_eth_softnic_tm.c
 
 #
 # Export include files
drivers/net/softnic/rte_eth_softnic.c +253 -2

344 lines not on this page · raw message

drivers/net/softnic/rte_eth_softnic.h +16 -0
index e6996f3..517b96a 100644
@@ -40,6 +40,22 @@
 extern "C" {
 #endif
 
+#ifndef SOFTNIC_SOFT_TM_NB_QUEUES
+#define SOFTNIC_SOFT_TM_NB_QUEUES			65536
+#endif
+
+#ifndef SOFTNIC_SOFT_TM_QUEUE_SIZE
+#define SOFTNIC_SOFT_TM_QUEUE_SIZE			64
+#endif
+
+#ifndef SOFTNIC_SOFT_TM_ENQ_BSZ
+#define SOFTNIC_SOFT_TM_ENQ_BSZ				32
+#endif
+
+#ifndef SOFTNIC_SOFT_TM_DEQ_BSZ
+#define SOFTNIC_SOFT_TM_DEQ_BSZ				24
+#endif
+
 #ifndef SOFTNIC_HARD_TX_QUEUE_ID
 #define SOFTNIC_HARD_TX_QUEUE_ID			0
 #endif
drivers/net/softnic/rte_eth_softnic_internals.h +104 -0

136 lines not on this page · raw message

drivers/net/softnic/rte_eth_softnic_tm.c new file +181 -0

181 lines not on this page · raw message

Signature · 1 line
2.9.3
#20 lore raw

v6 cover net/softnic: sw fall-back pmd for traffic mgmt and others

The SoftNIC PMD is intended to provide SW fall-back options for specific ethdev APIs in a generic way to the NICs not supporting those features.

Currently, the only implemented ethdev API is Traffic Management (TM), but other ethdev APIs such as rte_flow, traffic metering & policing, etc can be easily implemented.

Overview:
* Generic: The SoftNIC PMD works with any "hard" PMD that implements the ethdev API. It does not change the "hard" PMD in any way.
* Creation: For any given "hard" ethdev port, the user can decide to create an associated "soft" ethdev port to drive the "hard" port. The "soft" port is a virtual device that can be created at app start-up through EAL vdev arg or later through the virtual device API.
* Configuration: The app explicitly decides which features are to be enabled on the "soft" port and which features are still to be used from the "hard" port. The app continues to explicitly configure both the "hard" and the "soft" ports after the creation of the "soft" port.
* RX/TX: The app reads packets from/writes packets to the "soft" port instead of the "hard" port. The RX and TX queues of the "soft" port are thread safe, as any ethdev.
* Execution: The "soft" port is a feature-rich NIC implemented by the CPU, so the run function of the "soft" port has to be executed by the CPU in order to get packets moving between "hard" port and the app.
* Meets the NFV vision: The app should be (almost) agnostic about the NIC implementation (different vendors/models, HW-SW mix), the app should not require changes to use different NICs, the app should use the same API for all NICs. If a NIC does not implement a specific feature, the HW should be augmented with SW to meet the functionality while still preserving the same API.

Traffic Management SW fall-back overview:
* Implements the ethdev traffic management API (rte_tm.h).
* Based on the existing librte_sched DPDK library.

Example: Create "soft" port for "hard" port "0000:04:00.1", enable the TM feature with default settings:

          --vdev 'net_softnic0,hard_name=0000:04:00.1,soft_tm=on' 

Q1: Why generic name, if only TM is supported (for now)?
A1: The intention is to have SoftNIC PMD implement many other (all?)
ethdev APIs under a single "ideal" ethdev, hence the generic name. The initial motivation is TM API, but the mechanism is generic and can be used for many other ethdev APIs. Somebody looking to provide SW fall-back for other ethdev API is likely to end up inventing the same, hence it would be good to consolidate all under a single PMD and have the user explicitly enable/disable the features it needs for each "soft" device.

Q2: Are there any performance requirements for SoftNIC?
A2: Yes, performance should be great/decent for every feature, otherwise
the SW fall-back is unusable, thus useless.

Q3: Why not change the "hard" device (and keep a single device) instead of
creating a new "soft" device (and thus having two devices)?
A3: This is not possible with the current librte_ether ethdev
implementation. The ethdev->dev_ops are defined as constant structure, so it cannot be changed per device (nor per PMD). The new ops also need memory space to store their context data structures, which requires updating the ethdev->data->dev_private of the existing device; at best, maybe a resize of ethdev->data->dev_private could be done, assuming that librte_ether will introduce a way to find out its size, but this cannot be done while device is running. Other side effects might exist, as the changes are very intrusive, plus it likely needs more changes in librte_ether.

Q4: Why not call the SW fall-back dev_ops directly in librte_ether for
devices which do not support the specific feature? If the device supports the capability, let's call its dev_ops, otherwise call the SW fall-back dev_ops.
A4: First, similar reasons to Q&A3. This fixes the need to change
ethdev->dev_ops of the device, but it does not do anything to fix the other significant issue of where to store the context data structures needed by the SW fall-back functions (which, in this approach, are called implicitly by librte_ether).
Second, the SW fall-back options should not be restricted arbitrarily by the librte_ether library, the decision should belong to the app. For example, the TM SW fall-back should not be limited to only librte_sched, which (like any SW fall-back) is limited to a specific hierarchy and feature set, it cannot do any possible hierarchy. If alternatives exist, the one to use should be picked by the app, not by the ethdev layer.

Q5: Why is the app required to continue to configure both the "hard" and
the "soft" devices even after the "soft" device has been created? Why not hiding the "hard" device under the "soft" device and have the "soft" device configure the "hard" device under the hood?
A5: This was the approach tried in the V2 of this patch set (overlay
"soft" device taking over the configuration of the underlay "hard" device) and eventually dropped due to increased complexity of having to keep the configuration of two distinct devices in sync with librte_ether implementation that is not friendly towards such approach. Basically, each ethdev API call for the overlay device needs to configure the overlay device, invoke the same configuration with possibly modified parameters for the underlay device, then resume the configuration of overlay device, turning this into a device emulation project.
V2 minuses: increased complexity (deal with two devices at same time); need to implement every ethdev API, even those not needed for the scope of SW fall-back; intrusive; sometimes have to silently take decisions that should be left to the app.
V3 pluses: lower complexity (only one device); only need to implement those APIs that are in scope of the SW fall-back; non-intrusive (deal with "hard" device through ethdev API); app decisions taken by the app in an explicit way.

Q6: Why expose the SW fall-back in a PMD and not in a SW library?
A6: The SW fall-back for an ethdev API has to implement that specific
ethdev API, (hence expose an ethdev object through a PMD), as opposed to providing a different API. This approach allows the app to use the same API (NFV vision). For example, we already have a library for TM SW fall-back (librte_sched) that can be called directly by the apps that need to call it outside of ethdev context (use-cases exist), but an app that works with TM-aware NICs through the ethdev TM API would have to be changed significantly in order to work with different TM-agnostic NICs through the librte_sched API.

Q7: Why have all the SW fall-backs in a single PMD? Why not develop
the SW fall-back for each different ethdev API in a separate PMD, then create a chain of "soft" devices for each "hard" device? Potentially, this results in smaller size PMDs that are easier to maintain.
A7: Arguments for single ethdev/PMD and against chain of ethdevs/PMDs:
1. All the existing PMDs for HW NICs implement a lot of features under the same PMD, so there is no reason for single PMD approach to break code modularity. See the V3 code, a lot of care has been taken for code modularity.
2. We should avoid the proliferation of SW PMDs.
3. A single device should be handled by a single PMD.
4. People are used with feature-rich PMDs, not with single-feature PMDs, so we change of mindset?
5. [Configuration nightmare] A chain of "soft" devices attached to single "hard" device requires the app to be aware that the N "soft" devices in the chain plus the "hard" device refer to the same HW device, and which device should be invoked to configure which feature. Also the length of the chain and functionality of each link is different for each HW device. This breaks the requirement of preserving the same API while working with different NICs (NFV). This most likely results in a configuration nightmare, nobody is going to seriously use this.
6. [Feature inter-dependecy] Sometimes different features need to be configured and executed together (e.g. share the same set of resources, are inter-dependent, etc), so it is better and more performant to do them in the same ethdev/PMD.
7. [Code duplication] There is a lot of duplication in the configuration code for the chain of ethdevs approach. The ethdev dev_configure, rx_queue_setup, tx_queue_setup API functions have to be implemented per device, and they become meaningless/inconsistent with the chain approach.
8. [Data structure duplication] The per device data structures have to be duplicated and read repeatedly for each "soft" ethdev. The ethdev device, dev_private, data, per RX/TX queue data structures have to be replicated per "soft" device. They have to be re-read for each stage, so the same cache misses are now multiplied with the number of stages in the chain.
9. [rte_ring proliferation] Thread safety requirements for ethdev RX/TXqueues require an rte_ring to be used for every RX/TX queue of each "soft" ethdev. This rte_ring proliferation unnecessarily increases the memory footprint and lowers performance, especially when each "soft" ethdev ends up on a different CPU core (ping-pong of cache lines).
10.[Meta-data proliferation] A chain of ethdevs is likely to result
in proliferation of meta-data that has to be passed between the ethdevs (e.g. policing needs the output of flow classification), which results in more cache line ping-pong between cores, hence performance drops.

Cristian Dumitrescu (4):
Jasvinder Singh (4):
net/softnic: add softnic PMD
net/softnic: add traffic management support
net/softnic: add TM capabilities ops
net/softnic: add TM hierarchy related ops

Jasvinder Singh (1):
app/testpmd: add traffic management forwarding mode

 MAINTAINERS                                        |    5 +
 app/test-pmd/Makefile                              |    8 +
 app/test-pmd/cmdline.c                             |   88 +
 app/test-pmd/testpmd.c                             |   15 +
 app/test-pmd/testpmd.h                             |   46 +
 app/test-pmd/tm.c                                  |  865 +++++
 config/common_base                                 |    5 +
 doc/api/doxy-api-index.md                          |    3 +-
 doc/api/doxy-api.conf                              |    1 +
 doc/guides/rel_notes/release_17_11.rst             |    6 +
 drivers/net/Makefile                               |    5 +
 drivers/net/softnic/Makefile                       |   57 +
 drivers/net/softnic/rte_eth_softnic.c              |  852 +++++
 drivers/net/softnic/rte_eth_softnic.h              |   83 +
 drivers/net/softnic/rte_eth_softnic_internals.h    |  291 ++
 drivers/net/softnic/rte_eth_softnic_tm.c           | 3452 ++++++++++++++++++++
 .../net/softnic/rte_pmd_eth_softnic_version.map    |    7 +
 mk/rte.app.mk                                      |    5 +-
 18 files changed, 5792 insertions(+), 2 deletions(-)
 create mode 100644 app/test-pmd/tm.c
 create mode 100644 drivers/net/softnic/Makefile
 create mode 100644 drivers/net/softnic/rte_eth_softnic.c
 create mode 100644 drivers/net/softnic/rte_eth_softnic.h
 create mode 100644 drivers/net/softnic/rte_eth_softnic_internals.h
 create mode 100644 drivers/net/softnic/rte_eth_softnic_tm.c
 create mode 100644 drivers/net/softnic/rte_pmd_eth_softnic_version.map

Series Acked-by: Cristian Dumitrescu <[email protected]> Series Acked-by: Thomas Monjalon <[email protected]>

Signature · 1 line
2.9.3
#21 lore raw

PATCH v6 1/5 net/softnic: add softnic PMD

Add SoftNIC PMD to provide SW fall-back for ethdev APIs.

---
v5 changes:
- change function name rte_pmd_softnic_run_default() to run_default()

v4 changes:
- Implemented feedback from Ferruh [1]
- rename map file to rte_pmd_eth_softnic_version.map
- add release notes library version info
- doxygen: fix hooks in doc/api/doxy-api-index.md
- add doxygen comment for rte_pmd_softnic_run()
- free device name memory
- remove soft_dev param in pmd_ethdev_register()
- fix checkpatch warnings

v3 changes:
- rebase to dpdk17.08 release

v2 changes:
- fix build errors
- rebased to TM APIs v6 plus dpdk master

[1] Feedback from Ferruh on v3: http://dpdk.org/ml/archives/dev/2017-September/074576.html

 MAINTAINERS                                        |   5 +
 config/common_base                                 |   5 +
 doc/api/doxy-api-index.md                          |   3 +-
 doc/api/doxy-api.conf                              |   1 +
 doc/guides/rel_notes/release_17_11.rst             |   6 +
 drivers/net/Makefile                               |   5 +
 drivers/net/softnic/Makefile                       |  56 ++
 drivers/net/softnic/rte_eth_softnic.c              | 591 +++++++++++++++++++++
 drivers/net/softnic/rte_eth_softnic.h              |  67 +++
 drivers/net/softnic/rte_eth_softnic_internals.h    | 114 ++++
 .../net/softnic/rte_pmd_eth_softnic_version.map    |   7 +
 mk/rte.app.mk                                      |   5 +-
 12 files changed, 863 insertions(+), 2 deletions(-)
 create mode 100644 drivers/net/softnic/Makefile
 create mode 100644 drivers/net/softnic/rte_eth_softnic.c
 create mode 100644 drivers/net/softnic/rte_eth_softnic.h
 create mode 100644 drivers/net/softnic/rte_eth_softnic_internals.h
 create mode 100644 drivers/net/softnic/rte_pmd_eth_softnic_version.map
MAINTAINERS +5 -0
index cd0d6bc..91b8afe 100644
@@ -524,6 +524,11 @@ M: Gaetan Rivet <[email protected]>
 F: drivers/net/failsafe/
 F: doc/guides/nics/fail_safe.rst
 
+Softnic PMD
+M: Jasvinder Singh <[email protected]>
+M: Cristian Dumitrescu <[email protected]>
+F: drivers/net/softnic
+
 
 Crypto Drivers
 --------------
config/common_base +5 -0
index ca47615..3d10c37 100644
@@ -271,6 +271,11 @@ CONFIG_RTE_LIBRTE_SFC_EFX_PMD=y
 CONFIG_RTE_LIBRTE_SFC_EFX_DEBUG=n
 
 #
+# Compile SOFTNIC PMD
+#
+CONFIG_RTE_LIBRTE_PMD_SOFTNIC=y
+
+#
 # Compile software PMD backed by SZEDATA2 device
 #
 CONFIG_RTE_LIBRTE_PMD_SZEDATA2=n
doc/api/doxy-api-index.md +2 -1
index 19e0d4f..626ab51 100644
@@ -55,7 +55,8 @@ The public API headers are grouped by topics:
   [KNI]                (@ref rte_kni.h),
   [ixgbe]              (@ref rte_pmd_ixgbe.h),
   [i40e]               (@ref rte_pmd_i40e.h),
-  [crypto_scheduler]   (@ref rte_cryptodev_scheduler.h)
+  [crypto_scheduler]   (@ref rte_cryptodev_scheduler.h),
+  [softnic]            (@ref rte_eth_softnic.h)
 
 - **memory**:
   [memseg]             (@ref rte_memory.h),
doc/api/doxy-api.conf +1 -0
index 823554f..b27755d 100644
@@ -32,6 +32,7 @@ PROJECT_NAME            = DPDK
 INPUT                   = doc/api/doxy-api-index.md \
                           drivers/crypto/scheduler \
                           drivers/net/bonding \
+                          drivers/net/softnic \
                           drivers/net/i40e \
                           drivers/net/ixgbe \
                           lib/librte_eal/common/include \
doc/guides/rel_notes/release_17_11.rst +6 -0
index 60f7097..91879f7 100644
@@ -58,6 +58,11 @@ New Features
    * Support for Flow API
    * Support for Tx and Rx descriptor status functions
 
+* **Added SoftNIC PMD.**
+
+  Added new SoftNIC PMD. This virtual device offers applications a software
+  fallback support for traffic management.
+
 
 Resolved Issues
 ---------------
@@ -211,6 +216,7 @@ The libraries prepended with a plus sign were incremented in this version.
      librte_pmd_ixgbe.so.1
      librte_pmd_ring.so.2
      librte_pmd_vhost.so.1
+   + librte_pmd_softnic.so.1
      librte_port.so.3
      librte_power.so.1
      librte_reorder.so.1
drivers/net/Makefile +5 -0
index 2bd42f8..218dd3c 100644
@@ -112,4 +112,9 @@ DIRS-$(CONFIG_RTE_LIBRTE_PMD_VHOST) += vhost
 endif # $(CONFIG_RTE_LIBRTE_VHOST)
 DEPDIRS-vhost = $(core-libs) librte_vhost
 
+ifeq ($(CONFIG_RTE_LIBRTE_SCHED),y)
+DIRS-$(CONFIG_RTE_LIBRTE_PMD_SOFTNIC) += softnic
+endif # $(CONFIG_RTE_LIBRTE_SCHED)
+DEPDIRS-softnic = $(core-libs) librte_sched
+
 include $(RTE_SDK)/mk/rte.subdir.mk
drivers/net/softnic/Makefile new file +56 -0

56 lines not on this page · raw message

drivers/net/softnic/rte_eth_softnic.c new file +591 -0

591 lines not on this page · raw message

drivers/net/softnic/rte_eth_softnic.h new file +67 -0

67 lines not on this page · raw message

drivers/net/softnic/rte_eth_softnic_internals.h new file +114 -0

114 lines not on this page · raw message

drivers/net/softnic/rte_pmd_eth_softnic_version.map new file +7 -0
new file mode 100644
index 0000000..fb2cb68
@@ -0,0 +1,7 @@
+DPDK_17.11 {
+	global:
+
+	rte_pmd_softnic_run;
+
+	local: *;
+};
mk/rte.app.mk +4 -1
index 29507dc..443a3ab 100644
@@ -67,7 +67,6 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR)    += -lrte_distributor
 _LDLIBS-$(CONFIG_RTE_LIBRTE_IP_FRAG)        += -lrte_ip_frag
 _LDLIBS-$(CONFIG_RTE_LIBRTE_GRO)            += -lrte_gro
 _LDLIBS-$(CONFIG_RTE_LIBRTE_METER)          += -lrte_meter
-_LDLIBS-$(CONFIG_RTE_LIBRTE_SCHED)          += -lrte_sched
 _LDLIBS-$(CONFIG_RTE_LIBRTE_LPM)            += -lrte_lpm
 # librte_acl needs --whole-archive because of weak functions
 _LDLIBS-$(CONFIG_RTE_LIBRTE_ACL)            += --whole-archive
@@ -99,6 +98,7 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_RING)           += -lrte_ring
 _LDLIBS-$(CONFIG_RTE_LIBRTE_EAL)            += -lrte_eal
 _LDLIBS-$(CONFIG_RTE_LIBRTE_CMDLINE)        += -lrte_cmdline
 _LDLIBS-$(CONFIG_RTE_LIBRTE_REORDER)        += -lrte_reorder
+_LDLIBS-$(CONFIG_RTE_LIBRTE_SCHED)          += -lrte_sched
 
 ifeq ($(CONFIG_RTE_EXEC_ENV_LINUXAPP),y)
 _LDLIBS-$(CONFIG_RTE_LIBRTE_KNI)            += -lrte_kni
@@ -140,6 +140,9 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_NULL)       += -lrte_pmd_null
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_PCAP)       += -lrte_pmd_pcap -lpcap
 _LDLIBS-$(CONFIG_RTE_LIBRTE_QEDE_PMD)       += -lrte_pmd_qede
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_RING)       += -lrte_pmd_ring
+ifeq ($(CONFIG_RTE_LIBRTE_SCHED),y)
+_LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_SOFTNIC)      += -lrte_pmd_softnic
+endif
 _LDLIBS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD)    += -lrte_pmd_sfc_efx
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_SZEDATA2)   += -lrte_pmd_szedata2 -lsze2
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_TAP)        += -lrte_pmd_tap
Signature · 1 line
2.9.3
#22 lore raw

v7 cover net/softnic: sw fall-back pmd for traffic mgmt and others

The SoftNIC PMD is intended to provide SW fall-back options for specific ethdev APIs in a generic way to the NICs not supporting those features.

Currently, the only implemented ethdev API is Traffic Management (TM), but other ethdev APIs such as rte_flow, traffic metering & policing, etc can be easily implemented.

Overview:
* Generic: The SoftNIC PMD works with any "hard" PMD that implements the ethdev API. It does not change the "hard" PMD in any way.
* Creation: For any given "hard" ethdev port, the user can decide to create an associated "soft" ethdev port to drive the "hard" port. The "soft" port is a virtual device that can be created at app start-up through EAL vdev arg or later through the virtual device API.
* Configuration: The app explicitly decides which features are to be enabled on the "soft" port and which features are still to be used from the "hard" port. The app continues to explicitly configure both the "hard" and the "soft" ports after the creation of the "soft" port.
* RX/TX: The app reads packets from/writes packets to the "soft" port instead of the "hard" port. The RX and TX queues of the "soft" port are thread safe, as any ethdev.
* Execution: The "soft" port is a feature-rich NIC implemented by the CPU, so the run function of the "soft" port has to be executed by the CPU in order to get packets moving between "hard" port and the app.
* Meets the NFV vision: The app should be (almost) agnostic about the NIC implementation (different vendors/models, HW-SW mix), the app should not require changes to use different NICs, the app should use the same API for all NICs. If a NIC does not implement a specific feature, the HW should be augmented with SW to meet the functionality while still preserving the same API.

Traffic Management SW fall-back overview:
* Implements the ethdev traffic management API (rte_tm.h).
* Based on the existing librte_sched DPDK library.

Example: Create "soft" port for "hard" port "0000:04:00.1", enable the TM feature with default settings:

          --vdev 'net_softnic0,hard_name=0000:04:00.1,soft_tm=on' 

Q1: Why generic name, if only TM is supported (for now)?
A1: The intention is to have SoftNIC PMD implement many other (all?)
ethdev APIs under a single "ideal" ethdev, hence the generic name. The initial motivation is TM API, but the mechanism is generic and can be used for many other ethdev APIs. Somebody looking to provide SW fall-back for other ethdev API is likely to end up inventing the same, hence it would be good to consolidate all under a single PMD and have the user explicitly enable/disable the features it needs for each "soft" device.

Q2: Are there any performance requirements for SoftNIC?
A2: Yes, performance should be great/decent for every feature, otherwise
the SW fall-back is unusable, thus useless.

Q3: Why not change the "hard" device (and keep a single device) instead of
creating a new "soft" device (and thus having two devices)?
A3: This is not possible with the current librte_ether ethdev
implementation. The ethdev->dev_ops are defined as constant structure, so it cannot be changed per device (nor per PMD). The new ops also need memory space to store their context data structures, which requires updating the ethdev->data->dev_private of the existing device; at best, maybe a resize of ethdev->data->dev_private could be done, assuming that librte_ether will introduce a way to find out its size, but this cannot be done while device is running. Other side effects might exist, as the changes are very intrusive, plus it likely needs more changes in librte_ether.

Q4: Why not call the SW fall-back dev_ops directly in librte_ether for
devices which do not support the specific feature? If the device supports the capability, let's call its dev_ops, otherwise call the SW fall-back dev_ops.
A4: First, similar reasons to Q&A3. This fixes the need to change
ethdev->dev_ops of the device, but it does not do anything to fix the other significant issue of where to store the context data structures needed by the SW fall-back functions (which, in this approach, are called implicitly by librte_ether).
Second, the SW fall-back options should not be restricted arbitrarily by the librte_ether library, the decision should belong to the app. For example, the TM SW fall-back should not be limited to only librte_sched, which (like any SW fall-back) is limited to a specific hierarchy and feature set, it cannot do any possible hierarchy. If alternatives exist, the one to use should be picked by the app, not by the ethdev layer.

Q5: Why is the app required to continue to configure both the "hard" and
the "soft" devices even after the "soft" device has been created? Why not hiding the "hard" device under the "soft" device and have the "soft" device configure the "hard" device under the hood?
A5: This was the approach tried in the V2 of this patch set (overlay
"soft" device taking over the configuration of the underlay "hard" device) and eventually dropped due to increased complexity of having to keep the configuration of two distinct devices in sync with librte_ether implementation that is not friendly towards such approach. Basically, each ethdev API call for the overlay device needs to configure the overlay device, invoke the same configuration with possibly modified parameters for the underlay device, then resume the configuration of overlay device, turning this into a device emulation project.
V2 minuses: increased complexity (deal with two devices at same time); need to implement every ethdev API, even those not needed for the scope of SW fall-back; intrusive; sometimes have to silently take decisions that should be left to the app.
V3 pluses: lower complexity (only one device); only need to implement those APIs that are in scope of the SW fall-back; non-intrusive (deal with "hard" device through ethdev API); app decisions taken by the app in an explicit way.

Q6: Why expose the SW fall-back in a PMD and not in a SW library?
A6: The SW fall-back for an ethdev API has to implement that specific
ethdev API, (hence expose an ethdev object through a PMD), as opposed to providing a different API. This approach allows the app to use the same API (NFV vision). For example, we already have a library for TM SW fall-back (librte_sched) that can be called directly by the apps that need to call it outside of ethdev context (use-cases exist), but an app that works with TM-aware NICs through the ethdev TM API would have to be changed significantly in order to work with different TM-agnostic NICs through the librte_sched API.

Q7: Why have all the SW fall-backs in a single PMD? Why not develop
the SW fall-back for each different ethdev API in a separate PMD, then create a chain of "soft" devices for each "hard" device? Potentially, this results in smaller size PMDs that are easier to maintain.
A7: Arguments for single ethdev/PMD and against chain of ethdevs/PMDs:
1. All the existing PMDs for HW NICs implement a lot of features under the same PMD, so there is no reason for single PMD approach to break code modularity. See the V3 code, a lot of care has been taken for code modularity.
2. We should avoid the proliferation of SW PMDs.
3. A single device should be handled by a single PMD.
4. People are used with feature-rich PMDs, not with single-feature PMDs, so we change of mindset?
5. [Configuration nightmare] A chain of "soft" devices attached to single "hard" device requires the app to be aware that the N "soft" devices in the chain plus the "hard" device refer to the same HW device, and which device should be invoked to configure which feature. Also the length of the chain and functionality of each link is different for each HW device. This breaks the requirement of preserving the same API while working with different NICs (NFV). This most likely results in a configuration nightmare, nobody is going to seriously use this.
6. [Feature inter-dependecy] Sometimes different features need to be configured and executed together (e.g. share the same set of resources, are inter-dependent, etc), so it is better and more performant to do them in the same ethdev/PMD.
7. [Code duplication] There is a lot of duplication in the configuration code for the chain of ethdevs approach. The ethdev dev_configure, rx_queue_setup, tx_queue_setup API functions have to be implemented per device, and they become meaningless/inconsistent with the chain approach.
8. [Data structure duplication] The per device data structures have to be duplicated and read repeatedly for each "soft" ethdev. The ethdev device, dev_private, data, per RX/TX queue data structures have to be replicated per "soft" device. They have to be re-read for each stage, so the same cache misses are now multiplied with the number of stages in the chain.
9. [rte_ring proliferation] Thread safety requirements for ethdev RX/TXqueues require an rte_ring to be used for every RX/TX queue of each "soft" ethdev. This rte_ring proliferation unnecessarily increases the memory footprint and lowers performance, especially when each "soft" ethdev ends up on a different CPU core (ping-pong of cache lines).
10.[Meta-data proliferation] A chain of ethdevs is likely to result
in proliferation of meta-data that has to be passed between the ethdevs (e.g. policing needs the output of flow classification), which results in more cache line ping-pong between cores, hence performance drops.

Cristian Dumitrescu (4):
Jasvinder Singh (4):
net/softnic: add softnic PMD
net/softnic: add traffic management support
net/softnic: add TM capabilities ops
net/softnic: add TM hierarchy related ops

Jasvinder Singh (1):
app/testpmd: add traffic management forwarding mode

 MAINTAINERS                                        |    5 +
 app/test-pmd/Makefile                              |   12 +
 app/test-pmd/cmdline.c                             |   88 +
 app/test-pmd/testpmd.c                             |   15 +
 app/test-pmd/testpmd.h                             |   46 +
 app/test-pmd/tm.c                                  |  865 +++++
 config/common_base                                 |    5 +
 doc/api/doxy-api-index.md                          |    3 +-
 doc/api/doxy-api.conf                              |    1 +
 doc/guides/rel_notes/release_17_11.rst             |    8 +
 drivers/net/Makefile                               |    5 +
 drivers/net/softnic/Makefile                       |   57 +
 drivers/net/softnic/rte_eth_softnic.c              |  852 +++++
 drivers/net/softnic/rte_eth_softnic.h              |   83 +
 drivers/net/softnic/rte_eth_softnic_internals.h    |  291 ++
 drivers/net/softnic/rte_eth_softnic_tm.c           | 3452 ++++++++++++++++++++
 .../net/softnic/rte_pmd_eth_softnic_version.map    |    7 +
 mk/rte.app.mk                                      |    5 +-
 18 files changed, 5798 insertions(+), 2 deletions(-)
 create mode 100644 app/test-pmd/tm.c
 create mode 100644 drivers/net/softnic/Makefile
 create mode 100644 drivers/net/softnic/rte_eth_softnic.c
 create mode 100644 drivers/net/softnic/rte_eth_softnic.h
 create mode 100644 drivers/net/softnic/rte_eth_softnic_internals.h
 create mode 100644 drivers/net/softnic/rte_eth_softnic_tm.c
 create mode 100644 drivers/net/softnic/rte_pmd_eth_softnic_version.map

Series Acked-by: Cristian Dumitrescu <[email protected]> Series Acked-by: Thomas Monjalon <[email protected]>

Signature · 1 line
2.9.3
#23 lore raw

PATCH v7 1/5 net/softnic: add softnic PMD

Add SoftNIC PMD to provide SW fall-back for ethdev APIs.

---
v7 changes:
- rebase on dpdk-next-net
- change port_id type to uint16_t

v5 changes:
- change function name rte_pmd_softnic_run_default() to run_default()

v4 changes:
- Implemented feedback from Ferruh [1]
- rename map file to rte_pmd_eth_softnic_version.map
- add release notes library version info
- doxygen: fix hooks in doc/api/doxy-api-index.md
- add doxygen comment for rte_pmd_softnic_run()
- free device name memory
- remove soft_dev param in pmd_ethdev_register()
- fix checkpatch warnings

v3 changes:
- rebase to dpdk17.08 release

v2 changes:
- fix build errors
- rebased to TM APIs v6 plus dpdk master

[1] Feedback from Ferruh on v3: http://dpdk.org/ml/archives/dev/2017-September/074576.html

 MAINTAINERS                                        |   5 +
 config/common_base                                 |   5 +
 doc/api/doxy-api-index.md                          |   3 +-
 doc/api/doxy-api.conf                              |   1 +
 doc/guides/rel_notes/release_17_11.rst             |   8 +
 drivers/net/Makefile                               |   5 +
 drivers/net/softnic/Makefile                       |  56 ++
 drivers/net/softnic/rte_eth_softnic.c              | 591 +++++++++++++++++++++
 drivers/net/softnic/rte_eth_softnic.h              |  67 +++
 drivers/net/softnic/rte_eth_softnic_internals.h    | 114 ++++
 .../net/softnic/rte_pmd_eth_softnic_version.map    |   7 +
 mk/rte.app.mk                                      |   5 +-
 12 files changed, 865 insertions(+), 2 deletions(-)
 create mode 100644 drivers/net/softnic/Makefile
 create mode 100644 drivers/net/softnic/rte_eth_softnic.c
 create mode 100644 drivers/net/softnic/rte_eth_softnic.h
 create mode 100644 drivers/net/softnic/rte_eth_softnic_internals.h
 create mode 100644 drivers/net/softnic/rte_pmd_eth_softnic_version.map
MAINTAINERS +5 -0
index a6bb061..fff80c4 100644
@@ -526,6 +526,11 @@ M: Gaetan Rivet <[email protected]>
 F: drivers/net/failsafe/
 F: doc/guides/nics/fail_safe.rst
 
+Softnic PMD
+M: Jasvinder Singh <[email protected]>
+M: Cristian Dumitrescu <[email protected]>
+F: drivers/net/softnic
+
 
 Crypto Drivers
 --------------
config/common_base +5 -0
index 9ebe589..75b63a6 100644
@@ -271,6 +271,11 @@ CONFIG_RTE_LIBRTE_SFC_EFX_PMD=y
 CONFIG_RTE_LIBRTE_SFC_EFX_DEBUG=n
 
 #
+# Compile SOFTNIC PMD
+#
+CONFIG_RTE_LIBRTE_PMD_SOFTNIC=y
+
+#
 # Compile software PMD backed by SZEDATA2 device
 #
 CONFIG_RTE_LIBRTE_PMD_SZEDATA2=n
doc/api/doxy-api-index.md +2 -1
index e032ae1..950a553 100644
@@ -56,7 +56,8 @@ The public API headers are grouped by topics:
   [ixgbe]              (@ref rte_pmd_ixgbe.h),
   [i40e]               (@ref rte_pmd_i40e.h),
   [bnxt]               (@ref rte_pmd_bnxt.h),
-  [crypto_scheduler]   (@ref rte_cryptodev_scheduler.h)
+  [crypto_scheduler]   (@ref rte_cryptodev_scheduler.h),
+  [softnic]            (@ref rte_eth_softnic.h)
 
 - **memory**:
   [memseg]             (@ref rte_memory.h),
doc/api/doxy-api.conf +1 -0
index 63fe6cb..1310dc7 100644
@@ -32,6 +32,7 @@ PROJECT_NAME            = DPDK
 INPUT                   = doc/api/doxy-api-index.md \
                           drivers/crypto/scheduler \
                           drivers/net/bonding \
+                          drivers/net/softnic \
                           drivers/net/i40e \
                           drivers/net/ixgbe \
                           drivers/net/bnxt \
doc/guides/rel_notes/release_17_11.rst +8 -0
index 36139e5..6057a1a 100644
@@ -81,6 +81,7 @@ New Features
   See the :ref:`Membership Library <Member_Library>` documentation in
   the Programmers Guide document, for more information.
 
+<<<<<<< a3dabd30369bd73017fa367725fb1b455074a2ca
 * **Added the Generic Segmentation Offload Library.**
 
   Added the Generic Segmentation Offload (GSO) library to enable
@@ -96,6 +97,12 @@ New Features
   The GSO library doesn't check if the input packets have correct
   checksums, and doesn't update checksums for output packets.
   Additionally, the GSO library doesn't process IP fragmented packets.
+=======
+* **Added SoftNIC PMD.**
+
+  Added new SoftNIC PMD. This virtual device offers applications a software
+  fallback support for traffic management.
+>>>>>>> net/softnic: add softnic PMD
 
 
 Resolved Issues
@@ -267,6 +274,7 @@ The libraries prepended with a plus sign were incremented in this version.
      librte_pmd_ixgbe.so.2
      librte_pmd_ring.so.2
      librte_pmd_vhost.so.2
+   + librte_pmd_softnic.so.1
      librte_port.so.3
      librte_power.so.1
      librte_reorder.so.1
drivers/net/Makefile +5 -0
index 1daa87f..9480c51 100644
@@ -112,4 +112,9 @@ DIRS-$(CONFIG_RTE_LIBRTE_PMD_VHOST) += vhost
 endif # $(CONFIG_RTE_LIBRTE_VHOST)
 DEPDIRS-vhost = $(core-libs) librte_vhost
 
+ifeq ($(CONFIG_RTE_LIBRTE_SCHED),y)
+DIRS-$(CONFIG_RTE_LIBRTE_PMD_SOFTNIC) += softnic
+endif # $(CONFIG_RTE_LIBRTE_SCHED)
+DEPDIRS-softnic = $(core-libs) librte_sched
+
 include $(RTE_SDK)/mk/rte.subdir.mk
drivers/net/softnic/Makefile new file +56 -0

56 lines not on this page · raw message

drivers/net/softnic/rte_eth_softnic.c new file +591 -0

591 lines not on this page · raw message

drivers/net/softnic/rte_eth_softnic.h new file +67 -0

67 lines not on this page · raw message

drivers/net/softnic/rte_eth_softnic_internals.h new file +114 -0

114 lines not on this page · raw message

drivers/net/softnic/rte_pmd_eth_softnic_version.map new file +7 -0
new file mode 100644
index 0000000..fb2cb68
@@ -0,0 +1,7 @@
+DPDK_17.11 {
+	global:
+
+	rte_pmd_softnic_run;
+
+	local: *;
+};
mk/rte.app.mk +4 -1
index 83c952e..54e6268 100644
@@ -68,7 +68,6 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_IP_FRAG)        += -lrte_ip_frag
 _LDLIBS-$(CONFIG_RTE_LIBRTE_GRO)            += -lrte_gro
 _LDLIBS-$(CONFIG_RTE_LIBRTE_GSO)            += -lrte_gso
 _LDLIBS-$(CONFIG_RTE_LIBRTE_METER)          += -lrte_meter
-_LDLIBS-$(CONFIG_RTE_LIBRTE_SCHED)          += -lrte_sched
 _LDLIBS-$(CONFIG_RTE_LIBRTE_LPM)            += -lrte_lpm
 # librte_acl needs --whole-archive because of weak functions
 _LDLIBS-$(CONFIG_RTE_LIBRTE_ACL)            += --whole-archive
@@ -101,6 +100,7 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_RING)           += -lrte_ring
 _LDLIBS-$(CONFIG_RTE_LIBRTE_EAL)            += -lrte_eal
 _LDLIBS-$(CONFIG_RTE_LIBRTE_CMDLINE)        += -lrte_cmdline
 _LDLIBS-$(CONFIG_RTE_LIBRTE_REORDER)        += -lrte_reorder
+_LDLIBS-$(CONFIG_RTE_LIBRTE_SCHED)          += -lrte_sched
 
 ifeq ($(CONFIG_RTE_EXEC_ENV_LINUXAPP),y)
 _LDLIBS-$(CONFIG_RTE_LIBRTE_KNI)            += -lrte_kni
@@ -142,6 +142,9 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_NULL)       += -lrte_pmd_null
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_PCAP)       += -lrte_pmd_pcap -lpcap
 _LDLIBS-$(CONFIG_RTE_LIBRTE_QEDE_PMD)       += -lrte_pmd_qede
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_RING)       += -lrte_pmd_ring
+ifeq ($(CONFIG_RTE_LIBRTE_SCHED),y)
+_LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_SOFTNIC)      += -lrte_pmd_softnic
+endif
 _LDLIBS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD)    += -lrte_pmd_sfc_efx
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_SZEDATA2)   += -lrte_pmd_szedata2 -lsze2
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_TAP)        += -lrte_pmd_tap
Signature · 1 line
2.9.3
#24 lore raw

Re: [PATCH v7 1/5] net/softnic: add softnic PMD

Quoted 7 lines · Jasvinder Singh

Add SoftNIC PMD to provide SW fall-back for ethdev APIs.

<...>

Quoted 11 lines
doc/guides/rel_notes/release_17_11.rst +1 -0
@@ -81,6 +81,7 @@ New Features
   See the :ref:`Membership Library <Member_Library>` documentation in
   the Programmers Guide document, for more information.
 
+<<<<<<< a3dabd30369bd73017fa367725fb1b455074a2ca
 * **Added the Generic Segmentation Offload Library.**
 
   Added the Generic Segmentation Offload (GSO) library to enable

doc/guides/rel_notes/release_17_11.rst New Features · line 105

Quoted 9 lines
doc/guides/rel_notes/release_17_11.rst +6 -0
@@ -96,6 +97,12 @@ New Features
   The GSO library doesn't check if the input packets have correct
   checksums, and doesn't update checksums for output packets.
   Additionally, the GSO library doesn't process IP fragmented packets.
+=======
+* **Added SoftNIC PMD.**
+
+  Added new SoftNIC PMD. This virtual device offers applications a software
+  fallback support for traffic management.
+>>>>>>> net/softnic: add softnic PMD

This looks like merge artifact, can you please fix this?

#25 lore raw

Re: [PATCH v7 1/5] net/softnic: add softnic PMD

Quoted 11 lines

<...>

Quoted 9 lines
doc/guides/rel_notes/release_17_11.rst +1 -0
@@ -81,6 +81,7 @@ New Features
   See the :ref:`Membership Library <Member_Library>` documentation in
   the Programmers Guide document, for more information.
 
+<<<<<<< a3dabd30369bd73017fa367725fb1b455074a2ca
 * **Added the Generic Segmentation Offload Library.**
 
Quoted 13 lines

doc/guides/rel_notes/release_17_11.rst New Features · line 105

Quoted 11 lines
doc/guides/rel_notes/release_17_11.rst +6 -1
   Added the Generic Segmentation Offload (GSO) library to enable @@
-96,6 +97,12 @@ New Features
   The GSO library doesn't check if the input packets have correct
   checksums, and doesn't update checksums for output packets.
   Additionally, the GSO library doesn't process IP fragmented packets.
+=======
+* **Added SoftNIC PMD.**
+
+  Added new SoftNIC PMD. This virtual device offers applications a
+ software  fallback support for traffic management.
+>>>>>>> net/softnic: add softnic PMD

This looks like merge artifact, can you please fix this?

Fixed in the next version. Thanks.

#26 lore raw

v8 cover net/softnic: sw fall-back pmd for traffic mgmt and others

In reply to Jasvinder Singh

The SoftNIC PMD is intended to provide SW fall-back options for specific ethdev APIs in a generic way to the NICs not supporting those features.

Currently, the only implemented ethdev API is Traffic Management (TM), but other ethdev APIs such as rte_flow, traffic metering & policing, etc can be easily implemented.

Overview:
* Generic: The SoftNIC PMD works with any "hard" PMD that implements the ethdev API. It does not change the "hard" PMD in any way.
* Creation: For any given "hard" ethdev port, the user can decide to create an associated "soft" ethdev port to drive the "hard" port. The "soft" port is a virtual device that can be created at app start-up through EAL vdev arg or later through the virtual device API.
* Configuration: The app explicitly decides which features are to be enabled on the "soft" port and which features are still to be used from the "hard" port. The app continues to explicitly configure both the "hard" and the "soft" ports after the creation of the "soft" port.
* RX/TX: The app reads packets from/writes packets to the "soft" port instead of the "hard" port. The RX and TX queues of the "soft" port are thread safe, as any ethdev.
* Execution: The "soft" port is a feature-rich NIC implemented by the CPU, so the run function of the "soft" port has to be executed by the CPU in order to get packets moving between "hard" port and the app.
* Meets the NFV vision: The app should be (almost) agnostic about the NIC implementation (different vendors/models, HW-SW mix), the app should not require changes to use different NICs, the app should use the same API for all NICs. If a NIC does not implement a specific feature, the HW should be augmented with SW to meet the functionality while still preserving the same API.

Traffic Management SW fall-back overview:
* Implements the ethdev traffic management API (rte_tm.h).
* Based on the existing librte_sched DPDK library.

Example: Create "soft" port for "hard" port "0000:04:00.1", enable the TM feature with default settings:

          --vdev 'net_softnic0,hard_name=0000:04:00.1,soft_tm=on' 

Q1: Why generic name, if only TM is supported (for now)?
A1: The intention is to have SoftNIC PMD implement many other (all?)
ethdev APIs under a single "ideal" ethdev, hence the generic name. The initial motivation is TM API, but the mechanism is generic and can be used for many other ethdev APIs. Somebody looking to provide SW fall-back for other ethdev API is likely to end up inventing the same, hence it would be good to consolidate all under a single PMD and have the user explicitly enable/disable the features it needs for each "soft" device.

Q2: Are there any performance requirements for SoftNIC?
A2: Yes, performance should be great/decent for every feature, otherwise
the SW fall-back is unusable, thus useless.

Q3: Why not change the "hard" device (and keep a single device) instead of
creating a new "soft" device (and thus having two devices)?
A3: This is not possible with the current librte_ether ethdev
implementation. The ethdev->dev_ops are defined as constant structure, so it cannot be changed per device (nor per PMD). The new ops also need memory space to store their context data structures, which requires updating the ethdev->data->dev_private of the existing device; at best, maybe a resize of ethdev->data->dev_private could be done, assuming that librte_ether will introduce a way to find out its size, but this cannot be done while device is running. Other side effects might exist, as the changes are very intrusive, plus it likely needs more changes in librte_ether.

Q4: Why not call the SW fall-back dev_ops directly in librte_ether for
devices which do not support the specific feature? If the device supports the capability, let's call its dev_ops, otherwise call the SW fall-back dev_ops.
A4: First, similar reasons to Q&A3. This fixes the need to change
ethdev->dev_ops of the device, but it does not do anything to fix the other significant issue of where to store the context data structures needed by the SW fall-back functions (which, in this approach, are called implicitly by librte_ether).
Second, the SW fall-back options should not be restricted arbitrarily by the librte_ether library, the decision should belong to the app. For example, the TM SW fall-back should not be limited to only librte_sched, which (like any SW fall-back) is limited to a specific hierarchy and feature set, it cannot do any possible hierarchy. If alternatives exist, the one to use should be picked by the app, not by the ethdev layer.

Q5: Why is the app required to continue to configure both the "hard" and
the "soft" devices even after the "soft" device has been created? Why not hiding the "hard" device under the "soft" device and have the "soft" device configure the "hard" device under the hood?
A5: This was the approach tried in the V2 of this patch set (overlay
"soft" device taking over the configuration of the underlay "hard" device) and eventually dropped due to increased complexity of having to keep the configuration of two distinct devices in sync with librte_ether implementation that is not friendly towards such approach. Basically, each ethdev API call for the overlay device needs to configure the overlay device, invoke the same configuration with possibly modified parameters for the underlay device, then resume the configuration of overlay device, turning this into a device emulation project.
V2 minuses: increased complexity (deal with two devices at same time); need to implement every ethdev API, even those not needed for the scope of SW fall-back; intrusive; sometimes have to silently take decisions that should be left to the app.
V3 pluses: lower complexity (only one device); only need to implement those APIs that are in scope of the SW fall-back; non-intrusive (deal with "hard" device through ethdev API); app decisions taken by the app in an explicit way.

Q6: Why expose the SW fall-back in a PMD and not in a SW library?
A6: The SW fall-back for an ethdev API has to implement that specific
ethdev API, (hence expose an ethdev object through a PMD), as opposed to providing a different API. This approach allows the app to use the same API (NFV vision). For example, we already have a library for TM SW fall-back (librte_sched) that can be called directly by the apps that need to call it outside of ethdev context (use-cases exist), but an app that works with TM-aware NICs through the ethdev TM API would have to be changed significantly in order to work with different TM-agnostic NICs through the librte_sched API.

Q7: Why have all the SW fall-backs in a single PMD? Why not develop
the SW fall-back for each different ethdev API in a separate PMD, then create a chain of "soft" devices for each "hard" device? Potentially, this results in smaller size PMDs that are easier to maintain.
A7: Arguments for single ethdev/PMD and against chain of ethdevs/PMDs:
1. All the existing PMDs for HW NICs implement a lot of features under the same PMD, so there is no reason for single PMD approach to break code modularity. See the V3 code, a lot of care has been taken for code modularity.
2. We should avoid the proliferation of SW PMDs.
3. A single device should be handled by a single PMD.
4. People are used with feature-rich PMDs, not with single-feature PMDs, so we change of mindset?
5. [Configuration nightmare] A chain of "soft" devices attached to single "hard" device requires the app to be aware that the N "soft" devices in the chain plus the "hard" device refer to the same HW device, and which device should be invoked to configure which feature. Also the length of the chain and functionality of each link is different for each HW device. This breaks the requirement of preserving the same API while working with different NICs (NFV). This most likely results in a configuration nightmare, nobody is going to seriously use this.
6. [Feature inter-dependecy] Sometimes different features need to be configured and executed together (e.g. share the same set of resources, are inter-dependent, etc), so it is better and more performant to do them in the same ethdev/PMD.
7. [Code duplication] There is a lot of duplication in the configuration code for the chain of ethdevs approach. The ethdev dev_configure, rx_queue_setup, tx_queue_setup API functions have to be implemented per device, and they become meaningless/inconsistent with the chain approach.
8. [Data structure duplication] The per device data structures have to be duplicated and read repeatedly for each "soft" ethdev. The ethdev device, dev_private, data, per RX/TX queue data structures have to be replicated per "soft" device. They have to be re-read for each stage, so the same cache misses are now multiplied with the number of stages in the chain.
9. [rte_ring proliferation] Thread safety requirements for ethdev RX/TXqueues require an rte_ring to be used for every RX/TX queue of each "soft" ethdev. This rte_ring proliferation unnecessarily increases the memory footprint and lowers performance, especially when each "soft" ethdev ends up on a different CPU core (ping-pong of cache lines).
10.[Meta-data proliferation] A chain of ethdevs is likely to result
in proliferation of meta-data that has to be passed between the ethdevs (e.g. policing needs the output of flow classification), which results in more cache line ping-pong between cores, hence performance drops.

Cristian Dumitrescu (4):
Jasvinder Singh (4):
net/softnic: add softnic PMD
net/softnic: add traffic management support
net/softnic: add TM capabilities ops
net/softnic: add TM hierarchy related ops

Jasvinder Singh (1):
app/testpmd: add traffic management forwarding mode

 MAINTAINERS                                        |    5 +
 app/test-pmd/Makefile                              |   12 +
 app/test-pmd/cmdline.c                             |   88 +
 app/test-pmd/testpmd.c                             |   15 +
 app/test-pmd/testpmd.h                             |   46 +
 app/test-pmd/tm.c                                  |  865 +++++
 config/common_base                                 |    5 +
 doc/api/doxy-api-index.md                          |    3 +-
 doc/api/doxy-api.conf                              |    1 +
 doc/guides/rel_notes/release_17_11.rst             |    6 +
 drivers/net/Makefile                               |    5 +
 drivers/net/softnic/Makefile                       |   57 +
 drivers/net/softnic/rte_eth_softnic.c              |  852 +++++
 drivers/net/softnic/rte_eth_softnic.h              |   83 +
 drivers/net/softnic/rte_eth_softnic_internals.h    |  291 ++
 drivers/net/softnic/rte_eth_softnic_tm.c           | 3452 ++++++++++++++++++++
 .../net/softnic/rte_pmd_eth_softnic_version.map    |    7 +
 mk/rte.app.mk                                      |    5 +-
 18 files changed, 5796 insertions(+), 2 deletions(-)
 create mode 100644 app/test-pmd/tm.c
 create mode 100644 drivers/net/softnic/Makefile
 create mode 100644 drivers/net/softnic/rte_eth_softnic.c
 create mode 100644 drivers/net/softnic/rte_eth_softnic.h
 create mode 100644 drivers/net/softnic/rte_eth_softnic_internals.h
 create mode 100644 drivers/net/softnic/rte_eth_softnic_tm.c
 create mode 100644 drivers/net/softnic/rte_pmd_eth_softnic_version.map

Series Acked-by: Cristian Dumitrescu <[email protected]> Series Acked-by: Thomas Monjalon <[email protected]>

Signature · 1 line
2.9.3
#27 lore raw

PATCH v8 1/5 net/softnic: add softnic PMD

Add SoftNIC PMD to provide SW fall-back for ethdev APIs.

---
v8 changes:
- rebase on dpdk-next-net
- fix merge conflict

v7 changes:
- rebase on dpdk-next-net
- change port_id type to uint16_t

v5 changes:
- change function name rte_pmd_softnic_run_default() to run_default()

v4 changes:
- Implemented feedback from Ferruh [1]
- rename map file to rte_pmd_eth_softnic_version.map
- add release notes library version info
- doxygen: fix hooks in doc/api/doxy-api-index.md
- add doxygen comment for rte_pmd_softnic_run()
- free device name memory
- remove soft_dev param in pmd_ethdev_register()
- fix checkpatch warnings

v3 changes:
- rebase to dpdk17.08 release

v2 changes:
- fix build errors
- rebased to TM APIs v6 plus dpdk master

[1] Feedback from Ferruh on v3: http://dpdk.org/ml/archives/dev/2017-September/074576.html

 MAINTAINERS                                        |   5 +
 config/common_base                                 |   5 +
 doc/api/doxy-api-index.md                          |   3 +-
 doc/api/doxy-api.conf                              |   1 +
 doc/guides/rel_notes/release_17_11.rst             |   6 +
 drivers/net/Makefile                               |   5 +
 drivers/net/softnic/Makefile                       |  56 ++
 drivers/net/softnic/rte_eth_softnic.c              | 591 +++++++++++++++++++++
 drivers/net/softnic/rte_eth_softnic.h              |  67 +++
 drivers/net/softnic/rte_eth_softnic_internals.h    | 114 ++++
 .../net/softnic/rte_pmd_eth_softnic_version.map    |   7 +
 mk/rte.app.mk                                      |   5 +-
 12 files changed, 863 insertions(+), 2 deletions(-)
 create mode 100644 drivers/net/softnic/Makefile
 create mode 100644 drivers/net/softnic/rte_eth_softnic.c
 create mode 100644 drivers/net/softnic/rte_eth_softnic.h
 create mode 100644 drivers/net/softnic/rte_eth_softnic_internals.h
 create mode 100644 drivers/net/softnic/rte_pmd_eth_softnic_version.map
MAINTAINERS +5 -0
index 84e0464..acab15e 100644
@@ -536,6 +536,11 @@ M: Gaetan Rivet <[email protected]>
 F: drivers/net/failsafe/
 F: doc/guides/nics/fail_safe.rst
 
+Softnic PMD
+M: Jasvinder Singh <[email protected]>
+M: Cristian Dumitrescu <[email protected]>
+F: drivers/net/softnic
+
 
 Crypto Drivers
 --------------
config/common_base +5 -0
index 4648943..dc4da9a 100644
@@ -279,6 +279,11 @@ CONFIG_RTE_LIBRTE_SFC_EFX_PMD=y
 CONFIG_RTE_LIBRTE_SFC_EFX_DEBUG=n
 
 #
+# Compile SOFTNIC PMD
+#
+CONFIG_RTE_LIBRTE_PMD_SOFTNIC=y
+
+#
 # Compile software PMD backed by SZEDATA2 device
 #
 CONFIG_RTE_LIBRTE_PMD_SZEDATA2=n
doc/api/doxy-api-index.md +2 -1
index e032ae1..950a553 100644
@@ -56,7 +56,8 @@ The public API headers are grouped by topics:
   [ixgbe]              (@ref rte_pmd_ixgbe.h),
   [i40e]               (@ref rte_pmd_i40e.h),
   [bnxt]               (@ref rte_pmd_bnxt.h),
-  [crypto_scheduler]   (@ref rte_cryptodev_scheduler.h)
+  [crypto_scheduler]   (@ref rte_cryptodev_scheduler.h),
+  [softnic]            (@ref rte_eth_softnic.h)
 
 - **memory**:
   [memseg]             (@ref rte_memory.h),
doc/api/doxy-api.conf +1 -0
index 63fe6cb..1310dc7 100644
@@ -32,6 +32,7 @@ PROJECT_NAME            = DPDK
 INPUT                   = doc/api/doxy-api-index.md \
                           drivers/crypto/scheduler \
                           drivers/net/bonding \
+                          drivers/net/softnic \
                           drivers/net/i40e \
                           drivers/net/ixgbe \
                           drivers/net/bnxt \
doc/guides/rel_notes/release_17_11.rst +6 -0
index 10c240c..c184f1e 100644
@@ -87,6 +87,11 @@ New Features
   See the :ref:`Membership Library <Member_Library>` documentation in
   the Programmers Guide document, for more information.
 
+* **Added SoftNIC PMD.**
+
+  Added new SoftNIC PMD. This virtual device offers applications a software
+  fallback support for traffic management.
+
 * **Added the Generic Segmentation Offload Library.**
 
   Added the Generic Segmentation Offload (GSO) library to enable
@@ -279,6 +284,7 @@ The libraries prepended with a plus sign were incremented in this version.
      librte_pmd_ixgbe.so.2
      librte_pmd_ring.so.2
      librte_pmd_vhost.so.2
+   + librte_pmd_softnic.so.1
      librte_port.so.3
      librte_power.so.1
      librte_reorder.so.1
drivers/net/Makefile +5 -0
index aa5edf8..5d2ad2f 100644
@@ -109,6 +109,11 @@ DIRS-$(CONFIG_RTE_LIBRTE_PMD_KNI) += kni
 endif
 DEPDIRS-kni = $(core-libs) librte_kni
 
+ifeq ($(CONFIG_RTE_LIBRTE_SCHED),y)
+DIRS-$(CONFIG_RTE_LIBRTE_PMD_SOFTNIC) += softnic
+endif # $(CONFIG_RTE_LIBRTE_SCHED)
+DEPDIRS-softnic = $(core-libs) librte_sched
+
 ifeq ($(CONFIG_RTE_LIBRTE_VHOST),y)
 DIRS-$(CONFIG_RTE_LIBRTE_PMD_VHOST) += vhost
 endif # $(CONFIG_RTE_LIBRTE_VHOST)
drivers/net/softnic/Makefile new file +56 -0

56 lines not on this page · raw message

drivers/net/softnic/rte_eth_softnic.c new file +591 -0

591 lines not on this page · raw message

drivers/net/softnic/rte_eth_softnic.h new file +67 -0

67 lines not on this page · raw message

drivers/net/softnic/rte_eth_softnic_internals.h new file +114 -0

114 lines not on this page · raw message

drivers/net/softnic/rte_pmd_eth_softnic_version.map new file +7 -0
new file mode 100644
index 0000000..fb2cb68
@@ -0,0 +1,7 @@
+DPDK_17.11 {
+	global:
+
+	rte_pmd_softnic_run;
+
+	local: *;
+};
mk/rte.app.mk +4 -1
index cee21ea..0b8f612 100644
@@ -68,7 +68,6 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_IP_FRAG)        += -lrte_ip_frag
 _LDLIBS-$(CONFIG_RTE_LIBRTE_GRO)            += -lrte_gro
 _LDLIBS-$(CONFIG_RTE_LIBRTE_GSO)            += -lrte_gso
 _LDLIBS-$(CONFIG_RTE_LIBRTE_METER)          += -lrte_meter
-_LDLIBS-$(CONFIG_RTE_LIBRTE_SCHED)          += -lrte_sched
 _LDLIBS-$(CONFIG_RTE_LIBRTE_LPM)            += -lrte_lpm
 # librte_acl needs --whole-archive because of weak functions
 _LDLIBS-$(CONFIG_RTE_LIBRTE_ACL)            += --whole-archive
@@ -101,6 +100,7 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_RING)           += -lrte_ring
 _LDLIBS-$(CONFIG_RTE_LIBRTE_EAL)            += -lrte_eal
 _LDLIBS-$(CONFIG_RTE_LIBRTE_CMDLINE)        += -lrte_cmdline
 _LDLIBS-$(CONFIG_RTE_LIBRTE_REORDER)        += -lrte_reorder
+_LDLIBS-$(CONFIG_RTE_LIBRTE_SCHED)          += -lrte_sched
 
 ifeq ($(CONFIG_RTE_EXEC_ENV_LINUXAPP),y)
 _LDLIBS-$(CONFIG_RTE_LIBRTE_KNI)            += -lrte_kni
@@ -143,6 +143,9 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_NULL)       += -lrte_pmd_null
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_PCAP)       += -lrte_pmd_pcap -lpcap
 _LDLIBS-$(CONFIG_RTE_LIBRTE_QEDE_PMD)       += -lrte_pmd_qede
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_RING)       += -lrte_pmd_ring
+ifeq ($(CONFIG_RTE_LIBRTE_SCHED),y)
+_LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_SOFTNIC)      += -lrte_pmd_softnic
+endif
 _LDLIBS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD)    += -lrte_pmd_sfc_efx
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_SZEDATA2)   += -lrte_pmd_szedata2 -lsze2
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_TAP)        += -lrte_pmd_tap
Signature · 1 line
2.9.3
#28 lore raw

Re: [PATCH v8 1/5] net/softnic: add softnic PMD

10/10/2017 12:18, Jasvinder Singh:

mk/rte.app.mk _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_NULL) += -lrte_pmd_null · line 148

Quoted 3 lines
mk/rte.app.mk +3 -0
+ifeq ($(CONFIG_RTE_LIBRTE_SCHED),y)
+_LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_SOFTNIC)      += -lrte_pmd_softnic
+endif

Why linking softnic only if sched is enabled?

Please, can you fix it for RC2?

#29 lore raw

Re: [PATCH v8 1/5] net/softnic: add softnic PMD

Quoted 11 lines

-----Original Message-----
From: Thomas Monjalon [mailto:[email protected]]
Sent: Thursday, October 12, 2017 12:18 AM
To: Singh, Jasvinder <[email protected]>; Dumitrescu, Cristian <[email protected]>
Cc: [email protected]; Yigit, Ferruh <[email protected]>; Lu, Wenzhuo <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v8 1/5] net/softnic: add softnic PMD

Quoted 8 lines

10/10/2017 12:18, Jasvinder Singh:

mk/rte.app.mk _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_NULL) += -lrte_pmd_null · line 148

Quoted 3 lines
mk/rte.app.mk +3 -0
+ifeq ($(CONFIG_RTE_LIBRTE_SCHED),y)
+_LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_SOFTNIC)      += -lrte_pmd_softnic
+endif

Why linking softnic only if sched is enabled?

Please, can you fix it for RC2?

Yes, will fix this. Thanks.

#30 lore raw

PATCH v8 2/5 net/softnic: add traffic management support

In reply to Jasvinder Singh

Add ethdev Traffic Management API support to SoftNIC PMD.

---
v7 changes:
- fix checkpatch warning

v5 changes:
- change function name rte_pmd_softnic_run_tm() to run_tm()

v3 changes:
- add more confguration parameters (tm rate, tm queue sizes)

 drivers/net/softnic/Makefile                    |   1 +
 drivers/net/softnic/rte_eth_softnic.c           | 255 +++++++++++++++++++++++-
 drivers/net/softnic/rte_eth_softnic.h           |  16 ++
 drivers/net/softnic/rte_eth_softnic_internals.h | 104 ++++++++++
 drivers/net/softnic/rte_eth_softnic_tm.c        | 181 +++++++++++++++++
 5 files changed, 555 insertions(+), 2 deletions(-)
 create mode 100644 drivers/net/softnic/rte_eth_softnic_tm.c
drivers/net/softnic/Makefile +1 -0
index c2f42ef..8b848a9 100644
@@ -47,6 +47,7 @@ LIBABIVER := 1
 # all source are stored in SRCS-y
 #
 SRCS-$(CONFIG_RTE_LIBRTE_PMD_SOFTNIC) += rte_eth_softnic.c
+SRCS-$(CONFIG_RTE_LIBRTE_PMD_SOFTNIC) += rte_eth_softnic_tm.c
 
 #
 # Export include files
drivers/net/softnic/rte_eth_softnic.c +253 -2

344 lines not on this page · raw message

drivers/net/softnic/rte_eth_softnic.h +16 -0
index 566490a..b49e582 100644
@@ -40,6 +40,22 @@
 extern "C" {
 #endif
 
+#ifndef SOFTNIC_SOFT_TM_NB_QUEUES
+#define SOFTNIC_SOFT_TM_NB_QUEUES			65536
+#endif
+
+#ifndef SOFTNIC_SOFT_TM_QUEUE_SIZE
+#define SOFTNIC_SOFT_TM_QUEUE_SIZE			64
+#endif
+
+#ifndef SOFTNIC_SOFT_TM_ENQ_BSZ
+#define SOFTNIC_SOFT_TM_ENQ_BSZ				32
+#endif
+
+#ifndef SOFTNIC_SOFT_TM_DEQ_BSZ
+#define SOFTNIC_SOFT_TM_DEQ_BSZ				24
+#endif
+
 #ifndef SOFTNIC_HARD_TX_QUEUE_ID
 #define SOFTNIC_HARD_TX_QUEUE_ID			0
 #endif
drivers/net/softnic/rte_eth_softnic_internals.h +104 -0

136 lines not on this page · raw message

drivers/net/softnic/rte_eth_softnic_tm.c new file +181 -0

181 lines not on this page · raw message

Signature · 1 line
2.9.3
#31 lore raw

PATCH v8 3/5 net/softnic: add TM capabilities ops

In reply to Jasvinder Singh

Implement ethdev TM capability APIs in SoftNIC PMD.

---
 drivers/net/softnic/rte_eth_softnic.c           |  12 +-
 drivers/net/softnic/rte_eth_softnic_internals.h |  32 ++
 drivers/net/softnic/rte_eth_softnic_tm.c        | 500 ++++++++++++++++++++++++
 3 files changed, 543 insertions(+), 1 deletion(-)
drivers/net/softnic/rte_eth_softnic.c +11 -1
index 2f19159..34dceae 100644
@@ -43,6 +43,7 @@
 #include <rte_errno.h>
 #include <rte_ring.h>
 #include <rte_sched.h>
+#include <rte_tm_driver.h>
 
 #include "rte_eth_softnic.h"
 #include "rte_eth_softnic_internals.h"
@@ -224,6 +225,15 @@ pmd_link_update(struct rte_eth_dev *dev __rte_unused,
 	return 0;
 }
 
+static int
+pmd_tm_ops_get(struct rte_eth_dev *dev, void *arg)
+{
+	*(const struct rte_tm_ops **)arg =
+		(tm_enabled(dev)) ? &pmd_tm_ops : NULL;
+
+	return 0;
+}
+
 static const struct eth_dev_ops pmd_ops = {
 	.dev_configure = pmd_dev_configure,
 	.dev_start = pmd_dev_start,
@@ -233,7 +243,7 @@ static const struct eth_dev_ops pmd_ops = {
 	.dev_infos_get = pmd_dev_infos_get,
 	.rx_queue_setup = pmd_rx_queue_setup,
 	.tx_queue_setup = pmd_tx_queue_setup,
-	.tm_ops_get = NULL,
+	.tm_ops_get = pmd_tm_ops_get,
 };
 
 static uint16_t
drivers/net/softnic/rte_eth_softnic_internals.h +32 -0
index fd9cbbe..75d9387 100644
@@ -39,6 +39,7 @@
 #include <rte_mbuf.h>
 #include <rte_sched.h>
 #include <rte_ethdev.h>
+#include <rte_tm_driver.h>
 
 #include "rte_eth_softnic.h"
 
@@ -137,8 +138,26 @@ enum tm_node_level {
 	TM_NODE_LEVEL_MAX,
 };
 
+/* TM Node */
+struct tm_node {
+	TAILQ_ENTRY(tm_node) node;
+	uint32_t node_id;
+	uint32_t parent_node_id;
+	uint32_t priority;
+	uint32_t weight;
+	uint32_t level;
+	struct tm_node *parent_node;
+	struct rte_tm_node_params params;
+	struct rte_tm_node_stats stats;
+	uint32_t n_children;
+};
+
+TAILQ_HEAD(tm_node_list, tm_node);
+
 /* TM Hierarchy Specification */
 struct tm_hierarchy {
+	struct tm_node_list nodes;
+
 	uint32_t n_tm_nodes[TM_NODE_LEVEL_MAX];
 };
 
@@ -191,6 +210,11 @@ struct pmd_rx_queue {
 	} hard;
 };
 
+/**
+ * Traffic Management (TM) Operation
+ */
+extern const struct rte_tm_ops pmd_tm_ops;
+
 int
 tm_params_check(struct pmd_params *params, uint32_t hard_rate);
 
@@ -207,6 +231,14 @@ void
 tm_stop(struct pmd_internals *p);
 
 static inline int
+tm_enabled(struct rte_eth_dev *dev)
+{
+	struct pmd_internals *p = dev->data->dev_private;
+
+	return (p->params.soft.flags & PMD_FEATURE_TM);
+}
+
+static inline int
 tm_used(struct rte_eth_dev *dev)
 {
 	struct pmd_internals *p = dev->data->dev_private;
drivers/net/softnic/rte_eth_softnic_tm.c +500 -0

503 lines not on this page · raw message

Signature · 1 line
2.9.3
#32 lore raw

PATCH v8 4/5 net/softnic: add TM hierarchy related ops

In reply to Jasvinder Singh

Implement ethdev TM hierarchy related APIs in SoftNIC PMD.

---
v7 change:
- fix checkpatch warnings

v5 change:
- add macro for the tc period
- add more comments

 drivers/net/softnic/rte_eth_softnic_internals.h |   41 +
 drivers/net/softnic/rte_eth_softnic_tm.c        | 2781 ++++++++++++++++++++++-
 2 files changed, 2817 insertions(+), 5 deletions(-)
drivers/net/softnic/rte_eth_softnic_internals.h +41 -0
index 75d9387..1f75806 100644
@@ -138,6 +138,36 @@ enum tm_node_level {
 	TM_NODE_LEVEL_MAX,
 };
 
+/* TM Shaper Profile */
+struct tm_shaper_profile {
+	TAILQ_ENTRY(tm_shaper_profile) node;
+	uint32_t shaper_profile_id;
+	uint32_t n_users;
+	struct rte_tm_shaper_params params;
+};
+
+TAILQ_HEAD(tm_shaper_profile_list, tm_shaper_profile);
+
+/* TM Shared Shaper */
+struct tm_shared_shaper {
+	TAILQ_ENTRY(tm_shared_shaper) node;
+	uint32_t shared_shaper_id;
+	uint32_t n_users;
+	uint32_t shaper_profile_id;
+};
+
+TAILQ_HEAD(tm_shared_shaper_list, tm_shared_shaper);
+
+/* TM WRED Profile */
+struct tm_wred_profile {
+	TAILQ_ENTRY(tm_wred_profile) node;
+	uint32_t wred_profile_id;
+	uint32_t n_users;
+	struct rte_tm_wred_params params;
+};
+
+TAILQ_HEAD(tm_wred_profile_list, tm_wred_profile);
+
 /* TM Node */
 struct tm_node {
 	TAILQ_ENTRY(tm_node) node;
@@ -147,6 +177,8 @@ struct tm_node {
 	uint32_t weight;
 	uint32_t level;
 	struct tm_node *parent_node;
+	struct tm_shaper_profile *shaper_profile;
+	struct tm_wred_profile *wred_profile;
 	struct rte_tm_node_params params;
 	struct rte_tm_node_stats stats;
 	uint32_t n_children;
@@ -156,8 +188,16 @@ TAILQ_HEAD(tm_node_list, tm_node);
 
 /* TM Hierarchy Specification */
 struct tm_hierarchy {
+	struct tm_shaper_profile_list shaper_profiles;
+	struct tm_shared_shaper_list shared_shapers;
+	struct tm_wred_profile_list wred_profiles;
 	struct tm_node_list nodes;
 
+	uint32_t n_shaper_profiles;
+	uint32_t n_shared_shapers;
+	uint32_t n_wred_profiles;
+	uint32_t n_nodes;
+
 	uint32_t n_tm_nodes[TM_NODE_LEVEL_MAX];
 };
 
@@ -170,6 +210,7 @@ struct tm_internals {
 	 *      sense to keep the hierarchy frozen after the port is started.
 	 */
 	struct tm_hierarchy h;
+	int hierarchy_frozen;
 
 	/** Blueprints */
 	struct tm_params params;
drivers/net/softnic/rte_eth_softnic_tm.c +2776 -5

2,833 lines not on this page · raw message

Signature · 1 line
2.9.3
#33 lore raw

PATCH v8 5/5 app/testpmd: add traffic management forwarding mode

In reply to Jasvinder Singh

This commit extends the testpmd application with new forwarding engine that demonstrates the use of ethdev traffic management APIs and softnic PMD for QoS traffic management.

In this mode, 5-level hierarchical tree of the QoS scheduler is built with the help of ethdev TM APIs such as shaper profile add/delete, shared shaper add/update, node add/delete, hierarchy commit, etc. The hierarchical tree has following nodes; root node(x1, level 0), subport node(x1, level 1), pipe node(x4096, level 2),
tc node(x16348, level 3), queue node(x65536, level 4).

During runtime, each received packet is first classified by mapping the packet fields information to 5-tuples (HQoS subport, pipe, traffic class, queue within traffic class, and color) and storing it in the packet mbuf sched field. After classification, each packet is sent to softnic port which prioritizes the transmission of the received packets, and accordingly sends them on to the output interface.

To enable traffic management mode, following testpmd command is used;

$ ./testpmd -c c -n 4 --vdev
	'net_softnic0,hard_name=0000:06:00.1,soft_tm=on' -- -i
	--forward-mode=tm

---
v8 change:
- fix compilation warning on uninitialsed parameter

v7 change:
- change port_id type to uint16_t
- rebase on dpdk-next-net

v5 change:
- add CLI to enable default tm hierarchy

v3 change:
- Implements feedback from Pablo[1]
- add flag to check required librte_sched lib and softnic pmd
- code cleanup

v2 change:
- change file name softnictm.c to tm.c
- change forward mode name to "tm"
- code clean up

[1] http://dpdk.org/ml/archives/dev/2017-September/075744.html

 app/test-pmd/Makefile  |  12 +
 app/test-pmd/cmdline.c |  88 +++++
 app/test-pmd/testpmd.c |  15 +
 app/test-pmd/testpmd.h |  46 +++
 app/test-pmd/tm.c      | 865 +++++++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 1026 insertions(+)
 create mode 100644 app/test-pmd/tm.c
app/test-pmd/Makefile +12 -0
index b6e80dd..2c50f68 100644
@@ -59,6 +59,10 @@ SRCS-y += csumonly.c
 SRCS-y += icmpecho.c
 SRCS-$(CONFIG_RTE_LIBRTE_IEEE1588) += ieee1588fwd.c
 
+ifeq ($(CONFIG_RTE_LIBRTE_PMD_SOFTNIC)$(CONFIG_RTE_LIBRTE_SCHED),yy)
+SRCS-y += tm.c
+endif
+
 ifeq ($(CONFIG_RTE_BUILD_SHARED_LIB),y)
 
 ifeq ($(CONFIG_RTE_LIBRTE_PMD_BOND),y)
@@ -77,6 +81,14 @@ ifeq ($(CONFIG_RTE_LIBRTE_BNXT_PMD),y)
 LDLIBS += -lrte_pmd_bnxt
 endif
 
+ifeq ($(CONFIG_RTE_LIBRTE_PMD_XENVIRT),y)
+LDLIBS += -lrte_pmd_xenvirt
+endif
+
+ifeq ($(CONFIG_RTE_LIBRTE_PMD_SOFTNIC),y)
+LDLIBS += -lrte_pmd_softnic
+endif
+
 endif
 
 CFLAGS_cmdline.o := -D_GNU_SOURCE
app/test-pmd/cmdline.c +88 -0

106 lines not on this page · raw message

app/test-pmd/testpmd.c +15 -0
index 667c228..23352be 100644
@@ -164,6 +164,10 @@ struct fwd_engine * fwd_engines[] = {
 	&tx_only_engine,
 	&csum_fwd_engine,
 	&icmp_echo_engine,
+#if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
+	&softnic_tm_engine,
+	&softnic_tm_bypass_engine,
+#endif
 #ifdef RTE_LIBRTE_IEEE1588
 	&ieee1588_fwd_engine,
 #endif
@@ -2109,6 +2113,17 @@ init_port_config(void)
 		    (rte_eth_devices[pid].data->dev_flags &
 		     RTE_ETH_DEV_INTR_RMV))
 			port->dev_conf.intr_conf.rmv = 1;
+
+#if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
+		/* Detect softnic port */
+		if (!strcmp(port->dev_info.driver_name, "net_softnic")) {
+			port->softnic_enable = 1;
+			memset(&port->softport, 0, sizeof(struct softnic_port));
+
+			if (!strcmp(cur_fwd_eng->fwd_mode_name, "tm"))
+				port->softport.tm_flag = 1;
+		}
+#endif
 	}
 }
 
app/test-pmd/testpmd.h +46 -0

70 lines not on this page · raw message

app/test-pmd/tm.c new file +865 -0

865 lines not on this page · raw message

Signature · 1 line
2.9.3
#34 lore raw

Re: [PATCH v8 5/5] app/testpmd: add traffic management forwarding mode

Quoted 49 lines · Jasvinder Singh

This commit extends the testpmd application with new forwarding engine that demonstrates the use of ethdev traffic management APIs and softnic PMD for QoS traffic management.

In this mode, 5-level hierarchical tree of the QoS scheduler is built with the help of ethdev TM APIs such as shaper profile add/delete, shared shaper add/update, node add/delete, hierarchy commit, etc. The hierarchical tree has following nodes; root node(x1, level 0), subport node(x1, level 1), pipe node(x4096, level 2),
tc node(x16348, level 3), queue node(x65536, level 4).

During runtime, each received packet is first classified by mapping the packet fields information to 5-tuples (HQoS subport, pipe, traffic class, queue within traffic class, and color) and storing it in the packet mbuf sched field. After classification, each packet is sent to softnic port which prioritizes the transmission of the received packets, and accordingly sends them on to the output interface.

To enable traffic management mode, following testpmd command is used;

$ ./testpmd -c c -n 4 --vdev
	'net_softnic0,hard_name=0000:06:00.1,soft_tm=on' -- -i
	--forward-mode=tm

---
v8 change:
- fix compilation warning on uninitialsed parameter

v7 change:
- change port_id type to uint16_t
- rebase on dpdk-next-net

v5 change:
- add CLI to enable default tm hierarchy

v3 change:
- Implements feedback from Pablo[1]
- add flag to check required librte_sched lib and softnic pmd
- code cleanup

v2 change:
- change file name softnictm.c to tm.c
- change forward mode name to "tm"
- code clean up

Quoted 7 lines

[1] http://dpdk.org/ml/archives/dev/2017-September/075744.html

 app/test-pmd/Makefile  |  12 +
 app/test-pmd/cmdline.c |  88 +++++
 app/test-pmd/testpmd.c |  15 +
 app/test-pmd/testpmd.h |  46 +++
 app/test-pmd/tm.c      | 865 +++++++++++++++++++++++++++++++++++++++++++++++++

Testpmd documentation [1] is missing, can you please send a separate patch to update it? I can squash it later into this patch.

[1]
doc/guides/testpmd_app_ug/testpmd_funcs.rst

#35 lore raw

Re: [PATCH v8 0/5] net/softnic: sw fall-back pmd for traffic mgmt and others

In reply to Jasvinder Singh
Quoted 173 lines · Jasvinder Singh

The SoftNIC PMD is intended to provide SW fall-back options for specific ethdev APIs in a generic way to the NICs not supporting those features.

Currently, the only implemented ethdev API is Traffic Management (TM), but other ethdev APIs such as rte_flow, traffic metering & policing, etc can be easily implemented.

Overview:
* Generic: The SoftNIC PMD works with any "hard" PMD that implements the ethdev API. It does not change the "hard" PMD in any way.
* Creation: For any given "hard" ethdev port, the user can decide to create an associated "soft" ethdev port to drive the "hard" port. The "soft" port is a virtual device that can be created at app start-up through EAL vdev arg or later through the virtual device API.
* Configuration: The app explicitly decides which features are to be enabled on the "soft" port and which features are still to be used from the "hard" port. The app continues to explicitly configure both the "hard" and the "soft" ports after the creation of the "soft" port.
* RX/TX: The app reads packets from/writes packets to the "soft" port instead of the "hard" port. The RX and TX queues of the "soft" port are thread safe, as any ethdev.
* Execution: The "soft" port is a feature-rich NIC implemented by the CPU, so the run function of the "soft" port has to be executed by the CPU in order to get packets moving between "hard" port and the app.
* Meets the NFV vision: The app should be (almost) agnostic about the NIC implementation (different vendors/models, HW-SW mix), the app should not require changes to use different NICs, the app should use the same API for all NICs. If a NIC does not implement a specific feature, the HW should be augmented with SW to meet the functionality while still preserving the same API.

Traffic Management SW fall-back overview:
* Implements the ethdev traffic management API (rte_tm.h).
* Based on the existing librte_sched DPDK library.

Example: Create "soft" port for "hard" port "0000:04:00.1", enable the TM feature with default settings:

          --vdev 'net_softnic0,hard_name=0000:04:00.1,soft_tm=on' 

Q1: Why generic name, if only TM is supported (for now)?
A1: The intention is to have SoftNIC PMD implement many other (all?)
ethdev APIs under a single "ideal" ethdev, hence the generic name. The initial motivation is TM API, but the mechanism is generic and can be used for many other ethdev APIs. Somebody looking to provide SW fall-back for other ethdev API is likely to end up inventing the same, hence it would be good to consolidate all under a single PMD and have the user explicitly enable/disable the features it needs for each "soft" device.

Q2: Are there any performance requirements for SoftNIC?
A2: Yes, performance should be great/decent for every feature, otherwise
the SW fall-back is unusable, thus useless.

Q3: Why not change the "hard" device (and keep a single device) instead of
creating a new "soft" device (and thus having two devices)?
A3: This is not possible with the current librte_ether ethdev
implementation. The ethdev->dev_ops are defined as constant structure, so it cannot be changed per device (nor per PMD). The new ops also need memory space to store their context data structures, which requires updating the ethdev->data->dev_private of the existing device; at best, maybe a resize of ethdev->data->dev_private could be done, assuming that librte_ether will introduce a way to find out its size, but this cannot be done while device is running. Other side effects might exist, as the changes are very intrusive, plus it likely needs more changes in librte_ether.

Q4: Why not call the SW fall-back dev_ops directly in librte_ether for
devices which do not support the specific feature? If the device supports the capability, let's call its dev_ops, otherwise call the SW fall-back dev_ops.
A4: First, similar reasons to Q&A3. This fixes the need to change
ethdev->dev_ops of the device, but it does not do anything to fix the other significant issue of where to store the context data structures needed by the SW fall-back functions (which, in this approach, are called implicitly by librte_ether).
Second, the SW fall-back options should not be restricted arbitrarily by the librte_ether library, the decision should belong to the app. For example, the TM SW fall-back should not be limited to only librte_sched, which (like any SW fall-back) is limited to a specific hierarchy and feature set, it cannot do any possible hierarchy. If alternatives exist, the one to use should be picked by the app, not by the ethdev layer.

Q5: Why is the app required to continue to configure both the "hard" and
the "soft" devices even after the "soft" device has been created? Why not hiding the "hard" device under the "soft" device and have the "soft" device configure the "hard" device under the hood?
A5: This was the approach tried in the V2 of this patch set (overlay
"soft" device taking over the configuration of the underlay "hard" device) and eventually dropped due to increased complexity of having to keep the configuration of two distinct devices in sync with librte_ether implementation that is not friendly towards such approach. Basically, each ethdev API call for the overlay device needs to configure the overlay device, invoke the same configuration with possibly modified parameters for the underlay device, then resume the configuration of overlay device, turning this into a device emulation project.
V2 minuses: increased complexity (deal with two devices at same time); need to implement every ethdev API, even those not needed for the scope of SW fall-back; intrusive; sometimes have to silently take decisions that should be left to the app.
V3 pluses: lower complexity (only one device); only need to implement those APIs that are in scope of the SW fall-back; non-intrusive (deal with "hard" device through ethdev API); app decisions taken by the app in an explicit way.

Q6: Why expose the SW fall-back in a PMD and not in a SW library?
A6: The SW fall-back for an ethdev API has to implement that specific
ethdev API, (hence expose an ethdev object through a PMD), as opposed to providing a different API. This approach allows the app to use the same API (NFV vision). For example, we already have a library for TM SW fall-back (librte_sched) that can be called directly by the apps that need to call it outside of ethdev context (use-cases exist), but an app that works with TM-aware NICs through the ethdev TM API would have to be changed significantly in order to work with different TM-agnostic NICs through the librte_sched API.

Q7: Why have all the SW fall-backs in a single PMD? Why not develop
the SW fall-back for each different ethdev API in a separate PMD, then create a chain of "soft" devices for each "hard" device? Potentially, this results in smaller size PMDs that are easier to maintain.
A7: Arguments for single ethdev/PMD and against chain of ethdevs/PMDs:
1. All the existing PMDs for HW NICs implement a lot of features under the same PMD, so there is no reason for single PMD approach to break code modularity. See the V3 code, a lot of care has been taken for code modularity.
2. We should avoid the proliferation of SW PMDs.
3. A single device should be handled by a single PMD.
4. People are used with feature-rich PMDs, not with single-feature PMDs, so we change of mindset?
5. [Configuration nightmare] A chain of "soft" devices attached to single "hard" device requires the app to be aware that the N "soft" devices in the chain plus the "hard" device refer to the same HW device, and which device should be invoked to configure which feature. Also the length of the chain and functionality of each link is different for each HW device. This breaks the requirement of preserving the same API while working with different NICs (NFV). This most likely results in a configuration nightmare, nobody is going to seriously use this.
6. [Feature inter-dependecy] Sometimes different features need to be configured and executed together (e.g. share the same set of resources, are inter-dependent, etc), so it is better and more performant to do them in the same ethdev/PMD.
7. [Code duplication] There is a lot of duplication in the configuration code for the chain of ethdevs approach. The ethdev dev_configure, rx_queue_setup, tx_queue_setup API functions have to be implemented per device, and they become meaningless/inconsistent with the chain approach.
8. [Data structure duplication] The per device data structures have to be duplicated and read repeatedly for each "soft" ethdev. The ethdev device, dev_private, data, per RX/TX queue data structures have to be replicated per "soft" device. They have to be re-read for each stage, so the same cache misses are now multiplied with the number of stages in the chain.
9. [rte_ring proliferation] Thread safety requirements for ethdev RX/TXqueues require an rte_ring to be used for every RX/TX queue of each "soft" ethdev. This rte_ring proliferation unnecessarily increases the memory footprint and lowers performance, especially when each "soft" ethdev ends up on a different CPU core (ping-pong of cache lines).
10.[Meta-data proliferation] A chain of ethdevs is likely to result
in proliferation of meta-data that has to be passed between the ethdevs (e.g. policing needs the output of flow classification), which results in more cache line ping-pong between cores, hence performance drops.

Cristian Dumitrescu (4):
Jasvinder Singh (4):
net/softnic: add softnic PMD
net/softnic: add traffic management support
net/softnic: add TM capabilities ops
net/softnic: add TM hierarchy related ops

Quoted 2 lines

Jasvinder Singh (1):
app/testpmd: add traffic management forwarding mode

Series applied to dpdk-next-net/master, thanks.

(Was getting same build error from previous version, fixed while applying please confirm the pushed commit.
Also waiting for testpmd document to squash this set later)

#36 lore raw

Re: [PATCH v8 0/5] net/softnic: sw fall-back pmd for traffic mgmt and others

Quoted 190 lines

-----Original Message-----
From: Yigit, Ferruh
Sent: Tuesday, October 10, 2017 7:31 PM
To: Singh, Jasvinder <[email protected]>; [email protected]
Cc: Dumitrescu, Cristian <[email protected]>; [email protected]; Lu, Wenzhuo <[email protected]>
Subject: Re: [PATCH v8 0/5] net/softnic: sw fall-back pmd for traffic mgmt and others

Quoted 2 lines · Jasvinder Singh

The SoftNIC PMD is intended to provide SW fall-back options for specific ethdev APIs in a generic way to the NICs not supporting those

features.

Quoted 7 lines

Currently, the only implemented ethdev API is Traffic Management (TM), but other ethdev APIs such as rte_flow, traffic metering & policing, etc can be easily implemented.

Overview:
* Generic: The SoftNIC PMD works with any "hard" PMD that implements

the

Quoted 9 lines

ethdev API. It does not change the "hard" PMD in any way.
* Creation: For any given "hard" ethdev port, the user can decide to create an associated "soft" ethdev port to drive the "hard" port. The "soft" port is a virtual device that can be created at app start-up through EAL vdev arg or later through the virtual device API.
* Configuration: The app explicitly decides which features are to be enabled on the "soft" port and which features are still to be used from the "hard" port. The app continues to explicitly configure both the "hard" and the "soft" ports after the creation of the "soft" port.

Quoted 8 lines

* RX/TX: The app reads packets from/writes packets to the "soft" port instead of the "hard" port. The RX and TX queues of the "soft" port are thread safe, as any ethdev.
* Execution: The "soft" port is a feature-rich NIC implemented by the CPU, so the run function of the "soft" port has to be executed by the CPU in order to get packets moving between "hard" port and the app.
* Meets the NFV vision: The app should be (almost) agnostic about the NIC implementation (different vendors/models, HW-SW mix), the app should

not

Quoted 57 lines

require changes to use different NICs, the app should use the same API for all NICs. If a NIC does not implement a specific feature, the HW should be augmented with SW to meet the functionality while still preserving the same API.

Traffic Management SW fall-back overview:
* Implements the ethdev traffic management API (rte_tm.h).
* Based on the existing librte_sched DPDK library.

Example: Create "soft" port for "hard" port "0000:04:00.1", enable the TM feature with default settings:

          --vdev 'net_softnic0,hard_name=0000:04:00.1,soft_tm=on'

Q1: Why generic name, if only TM is supported (for now)?
A1: The intention is to have SoftNIC PMD implement many other (all?)
ethdev APIs under a single "ideal" ethdev, hence the generic name. The initial motivation is TM API, but the mechanism is generic and can be used for many other ethdev APIs. Somebody looking to provide SW fall-back for other ethdev API is likely to end up inventing the same, hence it would be good to consolidate all under a single PMD and have the user explicitly enable/disable the features it needs for each "soft" device.

Q2: Are there any performance requirements for SoftNIC?
A2: Yes, performance should be great/decent for every feature, otherwise
the SW fall-back is unusable, thus useless.

Q3: Why not change the "hard" device (and keep a single device) instead of
creating a new "soft" device (and thus having two devices)?
A3: This is not possible with the current librte_ether ethdev
implementation. The ethdev->dev_ops are defined as constant structure, so it cannot be changed per device (nor per PMD). The new ops also need memory space to store their context data structures, which requires updating the ethdev->data->dev_private of the existing device; at best, maybe a resize of ethdev->data->dev_private could be done, assuming that librte_ether will introduce a way to find out its size, but this cannot be done while device is running. Other side effects might exist, as the changes are very intrusive, plus it likely needs more changes in librte_ether.

Q4: Why not call the SW fall-back dev_ops directly in librte_ether for
devices which do not support the specific feature? If the device supports the capability, let's call its dev_ops, otherwise call the SW fall-back dev_ops.
A4: First, similar reasons to Q&A3. This fixes the need to change
ethdev->dev_ops of the device, but it does not do anything to fix the other significant issue of where to store the context data structures needed by the SW fall-back functions (which, in this approach, are called implicitly by librte_ether).
Second, the SW fall-back options should not be restricted arbitrarily by the librte_ether library, the decision should belong to the app. For example, the TM SW fall-back should not be limited to only librte_sched, which (like any SW fall-back) is limited to a specific hierarchy and feature set, it cannot do any possible hierarchy. If alternatives exist, the one to use should be picked by the app, not by the ethdev layer.

Quoted 16 lines

Q5: Why is the app required to continue to configure both the "hard" and
the "soft" devices even after the "soft" device has been created? Why not hiding the "hard" device under the "soft" device and have the "soft" device configure the "hard" device under the hood?
A5: This was the approach tried in the V2 of this patch set (overlay
"soft" device taking over the configuration of the underlay "hard" device) and eventually dropped due to increased complexity of having to keep the configuration of two distinct devices in sync with librte_ether implementation that is not friendly towards such approach. Basically, each ethdev API call for the overlay device needs to configure the overlay device, invoke the same configuration with possibly modified parameters for the underlay device, then resume the configuration of overlay device, turning this into a device emulation project.
V2 minuses: increased complexity (deal with two devices at same time); need to implement every ethdev API, even those not needed for the

scope

Quoted 40 lines

of SW fall-back; intrusive; sometimes have to silently take decisions that should be left to the app.
V3 pluses: lower complexity (only one device); only need to implement those APIs that are in scope of the SW fall-back; non-intrusive (deal with "hard" device through ethdev API); app decisions taken by the app in an explicit way.

Q6: Why expose the SW fall-back in a PMD and not in a SW library?
A6: The SW fall-back for an ethdev API has to implement that specific
ethdev API, (hence expose an ethdev object through a PMD), as opposed to providing a different API. This approach allows the app to use the same API (NFV vision). For example, we already have a library for TM SW fall-back (librte_sched) that can be called directly by the apps that need to call it outside of ethdev context (use-cases exist), but an app that works with TM-aware NICs through the ethdev TM API would have to be changed significantly in order to work with different TM-agnostic NICs through the librte_sched API.

Q7: Why have all the SW fall-backs in a single PMD? Why not develop
the SW fall-back for each different ethdev API in a separate PMD, then create a chain of "soft" devices for each "hard" device? Potentially, this results in smaller size PMDs that are easier to maintain.
A7: Arguments for single ethdev/PMD and against chain of ethdevs/PMDs:
1. All the existing PMDs for HW NICs implement a lot of features under the same PMD, so there is no reason for single PMD approach to break code modularity. See the V3 code, a lot of care has been taken for code modularity.
2. We should avoid the proliferation of SW PMDs.
3. A single device should be handled by a single PMD.
4. People are used with feature-rich PMDs, not with single-feature PMDs, so we change of mindset?
5. [Configuration nightmare] A chain of "soft" devices attached to single "hard" device requires the app to be aware that the N "soft" devices in the chain plus the "hard" device refer to the same HW device, and which device should be invoked to configure which feature. Also the length of the chain and functionality of each link is different for each HW device. This breaks the requirement of preserving the same API while working with different NICs (NFV). This most likely results in a configuration nightmare, nobody is going to seriously use this.

Quoted 8 lines

6. [Feature inter-dependecy] Sometimes different features need to be configured and executed together (e.g. share the same set of resources, are inter-dependent, etc), so it is better and more performant to do them in the same ethdev/PMD.
7. [Code duplication] There is a lot of duplication in the configuration code for the chain of ethdevs approach. The ethdev dev_configure, rx_queue_setup, tx_queue_setup API functions have to be implemented per device, and they become

meaningless/inconsistent

Quoted 26 lines

with the chain approach.
8. [Data structure duplication] The per device data structures have to be duplicated and read repeatedly for each "soft" ethdev. The ethdev device, dev_private, data, per RX/TX queue data structures have to be replicated per "soft" device. They have to be re-read for each stage, so the same cache misses are now multiplied with the number of stages in the chain.
9. [rte_ring proliferation] Thread safety requirements for ethdev RX/TXqueues require an rte_ring to be used for every RX/TX queue of each "soft" ethdev. This rte_ring proliferation unnecessarily increases the memory footprint and lowers performance, especially when each "soft" ethdev ends up on a different CPU core (ping-pong of cache lines).
10.[Meta-data proliferation] A chain of ethdevs is likely to result
in proliferation of meta-data that has to be passed between the ethdevs (e.g. policing needs the output of flow classification), which results in more cache line ping-pong between cores, hence performance drops.

Cristian Dumitrescu (4):
Jasvinder Singh (4):
net/softnic: add softnic PMD
net/softnic: add traffic management support
net/softnic: add TM capabilities ops
net/softnic: add TM hierarchy related ops

Quoted 8 lines
Quoted 2 lines

Jasvinder Singh (1):
app/testpmd: add traffic management forwarding mode

Series applied to dpdk-next-net/master, thanks.

(Was getting same build error from previous version, fixed while applying please confirm the pushed commit.
Also waiting for testpmd document to squash this set later)

I have pushed the documentation patch. Thanks.

#37 lore raw

PATCH v7 2/5 net/softnic: add traffic management support

In reply to Jasvinder Singh

Add ethdev Traffic Management API support to SoftNIC PMD.

---
v7 changes:
- fix checkpatch warning

v5 changes:
- change function name rte_pmd_softnic_run_tm() to run_tm()

v3 changes:
- add more confguration parameters (tm rate, tm queue sizes)

 drivers/net/softnic/Makefile                    |   1 +
 drivers/net/softnic/rte_eth_softnic.c           | 255 +++++++++++++++++++++++-
 drivers/net/softnic/rte_eth_softnic.h           |  16 ++
 drivers/net/softnic/rte_eth_softnic_internals.h | 104 ++++++++++
 drivers/net/softnic/rte_eth_softnic_tm.c        | 181 +++++++++++++++++
 5 files changed, 555 insertions(+), 2 deletions(-)
 create mode 100644 drivers/net/softnic/rte_eth_softnic_tm.c
drivers/net/softnic/Makefile +1 -0
index c2f42ef..8b848a9 100644
@@ -47,6 +47,7 @@ LIBABIVER := 1
 # all source are stored in SRCS-y
 #
 SRCS-$(CONFIG_RTE_LIBRTE_PMD_SOFTNIC) += rte_eth_softnic.c
+SRCS-$(CONFIG_RTE_LIBRTE_PMD_SOFTNIC) += rte_eth_softnic_tm.c
 
 #
 # Export include files
drivers/net/softnic/rte_eth_softnic.c +253 -2

344 lines not on this page · raw message

drivers/net/softnic/rte_eth_softnic.h +16 -0
index 566490a..b49e582 100644
@@ -40,6 +40,22 @@
 extern "C" {
 #endif
 
+#ifndef SOFTNIC_SOFT_TM_NB_QUEUES
+#define SOFTNIC_SOFT_TM_NB_QUEUES			65536
+#endif
+
+#ifndef SOFTNIC_SOFT_TM_QUEUE_SIZE
+#define SOFTNIC_SOFT_TM_QUEUE_SIZE			64
+#endif
+
+#ifndef SOFTNIC_SOFT_TM_ENQ_BSZ
+#define SOFTNIC_SOFT_TM_ENQ_BSZ				32
+#endif
+
+#ifndef SOFTNIC_SOFT_TM_DEQ_BSZ
+#define SOFTNIC_SOFT_TM_DEQ_BSZ				24
+#endif
+
 #ifndef SOFTNIC_HARD_TX_QUEUE_ID
 #define SOFTNIC_HARD_TX_QUEUE_ID			0
 #endif
drivers/net/softnic/rte_eth_softnic_internals.h +104 -0

136 lines not on this page · raw message

drivers/net/softnic/rte_eth_softnic_tm.c new file +181 -0

181 lines not on this page · raw message

Signature · 1 line
2.9.3
#38 lore raw

PATCH v7 3/5 net/softnic: add TM capabilities ops

In reply to Jasvinder Singh

Implement ethdev TM capability APIs in SoftNIC PMD.

---
 drivers/net/softnic/rte_eth_softnic.c           |  12 +-
 drivers/net/softnic/rte_eth_softnic_internals.h |  32 ++
 drivers/net/softnic/rte_eth_softnic_tm.c        | 500 ++++++++++++++++++++++++
 3 files changed, 543 insertions(+), 1 deletion(-)
drivers/net/softnic/rte_eth_softnic.c +11 -1
index 2f19159..34dceae 100644
@@ -43,6 +43,7 @@
 #include <rte_errno.h>
 #include <rte_ring.h>
 #include <rte_sched.h>
+#include <rte_tm_driver.h>
 
 #include "rte_eth_softnic.h"
 #include "rte_eth_softnic_internals.h"
@@ -224,6 +225,15 @@ pmd_link_update(struct rte_eth_dev *dev __rte_unused,
 	return 0;
 }
 
+static int
+pmd_tm_ops_get(struct rte_eth_dev *dev, void *arg)
+{
+	*(const struct rte_tm_ops **)arg =
+		(tm_enabled(dev)) ? &pmd_tm_ops : NULL;
+
+	return 0;
+}
+
 static const struct eth_dev_ops pmd_ops = {
 	.dev_configure = pmd_dev_configure,
 	.dev_start = pmd_dev_start,
@@ -233,7 +243,7 @@ static const struct eth_dev_ops pmd_ops = {
 	.dev_infos_get = pmd_dev_infos_get,
 	.rx_queue_setup = pmd_rx_queue_setup,
 	.tx_queue_setup = pmd_tx_queue_setup,
-	.tm_ops_get = NULL,
+	.tm_ops_get = pmd_tm_ops_get,
 };
 
 static uint16_t
drivers/net/softnic/rte_eth_softnic_internals.h +32 -0
index fd9cbbe..75d9387 100644
@@ -39,6 +39,7 @@
 #include <rte_mbuf.h>
 #include <rte_sched.h>
 #include <rte_ethdev.h>
+#include <rte_tm_driver.h>
 
 #include "rte_eth_softnic.h"
 
@@ -137,8 +138,26 @@ enum tm_node_level {
 	TM_NODE_LEVEL_MAX,
 };
 
+/* TM Node */
+struct tm_node {
+	TAILQ_ENTRY(tm_node) node;
+	uint32_t node_id;
+	uint32_t parent_node_id;
+	uint32_t priority;
+	uint32_t weight;
+	uint32_t level;
+	struct tm_node *parent_node;
+	struct rte_tm_node_params params;
+	struct rte_tm_node_stats stats;
+	uint32_t n_children;
+};
+
+TAILQ_HEAD(tm_node_list, tm_node);
+
 /* TM Hierarchy Specification */
 struct tm_hierarchy {
+	struct tm_node_list nodes;
+
 	uint32_t n_tm_nodes[TM_NODE_LEVEL_MAX];
 };
 
@@ -191,6 +210,11 @@ struct pmd_rx_queue {
 	} hard;
 };
 
+/**
+ * Traffic Management (TM) Operation
+ */
+extern const struct rte_tm_ops pmd_tm_ops;
+
 int
 tm_params_check(struct pmd_params *params, uint32_t hard_rate);
 
@@ -207,6 +231,14 @@ void
 tm_stop(struct pmd_internals *p);
 
 static inline int
+tm_enabled(struct rte_eth_dev *dev)
+{
+	struct pmd_internals *p = dev->data->dev_private;
+
+	return (p->params.soft.flags & PMD_FEATURE_TM);
+}
+
+static inline int
 tm_used(struct rte_eth_dev *dev)
 {
 	struct pmd_internals *p = dev->data->dev_private;
drivers/net/softnic/rte_eth_softnic_tm.c +500 -0

503 lines not on this page · raw message

Signature · 1 line
2.9.3
#39 lore raw

PATCH v7 4/5 net/softnic: add TM hierarchy related ops

In reply to Jasvinder Singh

Implement ethdev TM hierarchy related APIs in SoftNIC PMD.

---
v7 change:
- fix checkpatch warnings

v5 change:
- add macro for the tc period
- add more comments

 drivers/net/softnic/rte_eth_softnic_internals.h |   41 +
 drivers/net/softnic/rte_eth_softnic_tm.c        | 2781 ++++++++++++++++++++++-
 2 files changed, 2817 insertions(+), 5 deletions(-)
drivers/net/softnic/rte_eth_softnic_internals.h +41 -0
index 75d9387..1f75806 100644
@@ -138,6 +138,36 @@ enum tm_node_level {
 	TM_NODE_LEVEL_MAX,
 };
 
+/* TM Shaper Profile */
+struct tm_shaper_profile {
+	TAILQ_ENTRY(tm_shaper_profile) node;
+	uint32_t shaper_profile_id;
+	uint32_t n_users;
+	struct rte_tm_shaper_params params;
+};
+
+TAILQ_HEAD(tm_shaper_profile_list, tm_shaper_profile);
+
+/* TM Shared Shaper */
+struct tm_shared_shaper {
+	TAILQ_ENTRY(tm_shared_shaper) node;
+	uint32_t shared_shaper_id;
+	uint32_t n_users;
+	uint32_t shaper_profile_id;
+};
+
+TAILQ_HEAD(tm_shared_shaper_list, tm_shared_shaper);
+
+/* TM WRED Profile */
+struct tm_wred_profile {
+	TAILQ_ENTRY(tm_wred_profile) node;
+	uint32_t wred_profile_id;
+	uint32_t n_users;
+	struct rte_tm_wred_params params;
+};
+
+TAILQ_HEAD(tm_wred_profile_list, tm_wred_profile);
+
 /* TM Node */
 struct tm_node {
 	TAILQ_ENTRY(tm_node) node;
@@ -147,6 +177,8 @@ struct tm_node {
 	uint32_t weight;
 	uint32_t level;
 	struct tm_node *parent_node;
+	struct tm_shaper_profile *shaper_profile;
+	struct tm_wred_profile *wred_profile;
 	struct rte_tm_node_params params;
 	struct rte_tm_node_stats stats;
 	uint32_t n_children;
@@ -156,8 +188,16 @@ TAILQ_HEAD(tm_node_list, tm_node);
 
 /* TM Hierarchy Specification */
 struct tm_hierarchy {
+	struct tm_shaper_profile_list shaper_profiles;
+	struct tm_shared_shaper_list shared_shapers;
+	struct tm_wred_profile_list wred_profiles;
 	struct tm_node_list nodes;
 
+	uint32_t n_shaper_profiles;
+	uint32_t n_shared_shapers;
+	uint32_t n_wred_profiles;
+	uint32_t n_nodes;
+
 	uint32_t n_tm_nodes[TM_NODE_LEVEL_MAX];
 };
 
@@ -170,6 +210,7 @@ struct tm_internals {
 	 *      sense to keep the hierarchy frozen after the port is started.
 	 */
 	struct tm_hierarchy h;
+	int hierarchy_frozen;
 
 	/** Blueprints */
 	struct tm_params params;
drivers/net/softnic/rte_eth_softnic_tm.c +2776 -5

2,833 lines not on this page · raw message

Signature · 1 line
2.9.3
#40 lore raw

PATCH v7 5/5 app/testpmd: add traffic management forwarding mode

In reply to Jasvinder Singh

This commit extends the testpmd application with new forwarding engine that demonstrates the use of ethdev traffic management APIs and softnic PMD for QoS traffic management.

In this mode, 5-level hierarchical tree of the QoS scheduler is built with the help of ethdev TM APIs such as shaper profile add/delete, shared shaper add/update, node add/delete, hierarchy commit, etc. The hierarchical tree has following nodes; root node(x1, level 0), subport node(x1, level 1), pipe node(x4096, level 2),
tc node(x16348, level 3), queue node(x65536, level 4).

During runtime, each received packet is first classified by mapping the packet fields information to 5-tuples (HQoS subport, pipe, traffic class, queue within traffic class, and color) and storing it in the packet mbuf sched field. After classification, each packet is sent to softnic port which prioritizes the transmission of the received packets, and accordingly sends them on to the output interface.

To enable traffic management mode, following testpmd command is used;

$ ./testpmd -c c -n 4 --vdev
	'net_softnic0,hard_name=0000:06:00.1,soft_tm=on' -- -i
	--forward-mode=tm

---
v7 change:
- change port_id type to uint16_t
- rebase on dpdk-next-net

v5 change:
- add CLI to enable default tm hierarchy

v3 change:
- Implements feedback from Pablo[1]
- add flag to check required librte_sched lib and softnic pmd
- code cleanup

v2 change:
- change file name softnictm.c to tm.c
- change forward mode name to "tm"
- code clean up

[1] http://dpdk.org/ml/archives/dev/2017-September/075744.html

 app/test-pmd/Makefile  |  12 +
 app/test-pmd/cmdline.c |  88 +++++
 app/test-pmd/testpmd.c |  15 +
 app/test-pmd/testpmd.h |  46 +++
 app/test-pmd/tm.c      | 865 +++++++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 1026 insertions(+)
 create mode 100644 app/test-pmd/tm.c
app/test-pmd/Makefile +12 -0
index b6e80dd..2c50f68 100644
@@ -59,6 +59,10 @@ SRCS-y += csumonly.c
 SRCS-y += icmpecho.c
 SRCS-$(CONFIG_RTE_LIBRTE_IEEE1588) += ieee1588fwd.c
 
+ifeq ($(CONFIG_RTE_LIBRTE_PMD_SOFTNIC)$(CONFIG_RTE_LIBRTE_SCHED),yy)
+SRCS-y += tm.c
+endif
+
 ifeq ($(CONFIG_RTE_BUILD_SHARED_LIB),y)
 
 ifeq ($(CONFIG_RTE_LIBRTE_PMD_BOND),y)
@@ -77,6 +81,14 @@ ifeq ($(CONFIG_RTE_LIBRTE_BNXT_PMD),y)
 LDLIBS += -lrte_pmd_bnxt
 endif
 
+ifeq ($(CONFIG_RTE_LIBRTE_PMD_XENVIRT),y)
+LDLIBS += -lrte_pmd_xenvirt
+endif
+
+ifeq ($(CONFIG_RTE_LIBRTE_PMD_SOFTNIC),y)
+LDLIBS += -lrte_pmd_softnic
+endif
+
 endif
 
 CFLAGS_cmdline.o := -D_GNU_SOURCE
app/test-pmd/cmdline.c +88 -0

106 lines not on this page · raw message

app/test-pmd/testpmd.c +15 -0
index 3dcc325..552abdf 100644
@@ -163,6 +163,10 @@ struct fwd_engine * fwd_engines[] = {
 	&tx_only_engine,
 	&csum_fwd_engine,
 	&icmp_echo_engine,
+#if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
+	&softnic_tm_engine,
+	&softnic_tm_bypass_engine,
+#endif
 #ifdef RTE_LIBRTE_IEEE1588
 	&ieee1588_fwd_engine,
 #endif
@@ -2108,6 +2112,17 @@ init_port_config(void)
 		    (rte_eth_devices[pid].data->dev_flags &
 		     RTE_ETH_DEV_INTR_RMV))
 			port->dev_conf.intr_conf.rmv = 1;
+
+#if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
+		/* Detect softnic port */
+		if (!strcmp(port->dev_info.driver_name, "net_softnic")) {
+			port->softnic_enable = 1;
+			memset(&port->softport, 0, sizeof(struct softnic_port));
+
+			if (!strcmp(cur_fwd_eng->fwd_mode_name, "tm"))
+				port->softport.tm_flag = 1;
+		}
+#endif
 	}
 }
 
app/test-pmd/testpmd.h +46 -0

70 lines not on this page · raw message

app/test-pmd/tm.c new file +865 -0

865 lines not on this page · raw message

Signature · 1 line
2.9.3
#41 lore raw

Re: [PATCH v7 5/5] app/testpmd: add traffic management forwarding mode

Quoted 27 lines · Jasvinder Singh

This commit extends the testpmd application with new forwarding engine that demonstrates the use of ethdev traffic management APIs and softnic PMD for QoS traffic management.

In this mode, 5-level hierarchical tree of the QoS scheduler is built with the help of ethdev TM APIs such as shaper profile add/delete, shared shaper add/update, node add/delete, hierarchy commit, etc. The hierarchical tree has following nodes; root node(x1, level 0), subport node(x1, level 1), pipe node(x4096, level 2),
tc node(x16348, level 3), queue node(x65536, level 4).

During runtime, each received packet is first classified by mapping the packet fields information to 5-tuples (HQoS subport, pipe, traffic class, queue within traffic class, and color) and storing it in the packet mbuf sched field. After classification, each packet is sent to softnic port which prioritizes the transmission of the received packets, and accordingly sends them on to the output interface.

To enable traffic management mode, following testpmd command is used;

$ ./testpmd -c c -n 4 --vdev
	'net_softnic0,hard_name=0000:06:00.1,soft_tm=on' -- -i
	--forward-mode=tm

<...>

Quoted 48 lines
app/test-pmd/tm.c new file +48 -0
+static int
+softport_tm_subport_node_add(portid_t port_id, struct tm_hierarchy *h,
+	struct rte_tm_error *error)
+{
+	uint32_t subport_parent_node_id, subport_node_id;
+	struct rte_tm_node_params snp;
+	struct rte_tm_shaper_params ssp;
+	uint32_t priority, weight, level_id, shaper_profile_id;
+	uint32_t i;
+
+	memset(&ssp, 0, sizeof(struct rte_tm_shaper_params));
+	memset(&snp, 0, sizeof(struct rte_tm_node_params));
+
+	shaper_profile_id = h->n_shapers;
+
+	/* Add Shaper Profile to TM Hierarchy */
+	for (i = 0; i < SUBPORT_NODES_PER_PORT; i++) {
+		ssp.peak.rate = h->subport_node_shaper_rate;
+		ssp.peak.size = TOKEN_BUCKET_SIZE;
+		ssp.pkt_length_adjust = RTE_TM_ETH_FRAMING_OVERHEAD_FCS;
+
+		if (rte_tm_shaper_profile_add(port_id, shaper_profile_id,
+			&ssp, error)) {
+			printf("%s ERROR(%d)-%s!(shaper_id %u)\n ",
+				__func__, error->type, error->message,
+				shaper_profile_id);
+			return -1;
+		}
+
+		/* Node Parameters */
+		h->subport_node_id[i] = SUBPORT_NODES_START_ID + i;
+		subport_parent_node_id = h->root_node_id;
+		weight = 1;
+		priority = 0;
+		level_id = TM_NODE_LEVEL_SUBPORT;
+		snp.shaper_profile_id = shaper_profile_id;
+		snp.nonleaf.n_sp_priorities = 1;
+		snp.stats_mask = STATS_MASK_DEFAULT;
+
+		/* Add Node to TM Hiearchy */
+		if (rte_tm_node_add(port_id,
+				h->subport_node_id[i],
+				subport_parent_node_id,
+				priority, weight,
+				level_id,
+				&snp,
+				error)) {
+			printf("%s ERROR(%d)-%s!(node %u,parent %u,level %u)\n",

app/test-pmd/tm.c line 462

Quoted 10 lines
app/test-pmd/tm.c new file +10 -0
+					__func__,
+					error->type,
+					error->message,
+					h->subport_node_id[i],
+					subport_parent_node_id,
+					level_id);
+			return -1;
+		}
+		shaper_profile_id++;
+		subport_node_id++;

This is causing following build error:

.../dpdk/app/test-pmd/tm.c:462:3: error: variable 'subport_node_id' is uninitialized when used here [-Werror,-Wuninitialized]

                subport_node_id++;
                ^~~~~~~~~~~~~~~
.../dpdk/app/test-pmd/tm.c:409:50: note: initialize the variable
'subport_node_id' to silence this warning
        uint32_t subport_parent_node_id, subport_node_id;
                                                        ^
                                                         = 0
#42 lore raw

Re: [PATCH v7 5/5] app/testpmd: add traffic management forwarding mode

<snip>

Quoted 67 lines

Review

Quoted 3 lines
(quoted diff) +2 -0
+static int
+softport_tm_subport_node_add(portid_t port_id, struct tm_hierarchy

*h,

Quoted 8 lines
app/test-pmd/tm.c new file +8 -0
+	struct rte_tm_error *error)
+{
+	uint32_t subport_parent_node_id, subport_node_id;
+	struct rte_tm_node_params snp;
+	struct rte_tm_shaper_params ssp;
+	uint32_t priority, weight, level_id, shaper_profile_id;
+	uint32_t i;
+

app/test-pmd/tm.c

Quoted 10 lines
app/test-pmd/tm.c new file +10 -0
+	memset(&ssp, 0, sizeof(struct rte_tm_shaper_params));
+	memset(&snp, 0, sizeof(struct rte_tm_node_params));
+
+	shaper_profile_id = h->n_shapers;
+
+	/* Add Shaper Profile to TM Hierarchy */
+	for (i = 0; i < SUBPORT_NODES_PER_PORT; i++) {
+		ssp.peak.rate = h->subport_node_shaper_rate;
+		ssp.peak.size = TOKEN_BUCKET_SIZE;
+		ssp.pkt_length_adjust =

RTE_TM_ETH_FRAMING_OVERHEAD_FCS;

Quoted 18 lines
app/test-pmd/tm.c new file +18 -0
+
+		if (rte_tm_shaper_profile_add(port_id, shaper_profile_id,
+			&ssp, error)) {
+			printf("%s ERROR(%d)-%s!(shaper_id %u)\n ",
+				__func__, error->type, error->message,
+				shaper_profile_id);
+			return -1;
+		}
+
+		/* Node Parameters */
+		h->subport_node_id[i] = SUBPORT_NODES_START_ID + i;
+		subport_parent_node_id = h->root_node_id;
+		weight = 1;
+		priority = 0;
+		level_id = TM_NODE_LEVEL_SUBPORT;
+		snp.shaper_profile_id = shaper_profile_id;
+		snp.nonleaf.n_sp_priorities = 1;
+		snp.stats_mask = STATS_MASK_DEFAULT;

app/test-pmd/tm.c

Quoted 10 lines
app/test-pmd/tm.c new file +10 -0
+
+		/* Add Node to TM Hiearchy */
+		if (rte_tm_node_add(port_id,
+				h->subport_node_id[i],
+				subport_parent_node_id,
+				priority, weight,
+				level_id,
+				&snp,
+				error)) {
+			printf("%s ERROR(%d)-%s!(node %u,parent %u,level

%u)\n",

app/test-pmd/tm.c line 462

Quoted 10 lines
app/test-pmd/tm.c new file +10 -0
+					__func__,
+					error->type,
+					error->message,
+					h->subport_node_id[i],
+					subport_parent_node_id,
+					level_id);
+			return -1;
+		}
+		shaper_profile_id++;
+		subport_node_id++;

This is causing following build error:

.../dpdk/app/test-pmd/tm.c:462:3: error: variable 'subport_node_id' is uninitialized when used here [-Werror,-Wuninitialized]

Quoted 7 lines
                subport_node_id++;
                ^~~~~~~~~~~~~~~
.../dpdk/app/test-pmd/tm.c:409:50: note: initialize the variable
'subport_node_id' to silence this warning
        uint32_t subport_parent_node_id, subport_node_id;
                                                        ^
                                                         = 0

Fixed in the next version. Thanks.

#43 lore raw

PATCH v6 2/5 net/softnic: add traffic management support

In reply to Jasvinder Singh

Add ethdev Traffic Management API support to SoftNIC PMD.

---
v5 changes:
- change function name rte_pmd_softnic_run_tm() to run_tm()

v3 changes:
- add more confguration parameters (tm rate, tm queue sizes)

 drivers/net/softnic/Makefile                    |   1 +
 drivers/net/softnic/rte_eth_softnic.c           | 255 +++++++++++++++++++++++-
 drivers/net/softnic/rte_eth_softnic.h           |  16 ++
 drivers/net/softnic/rte_eth_softnic_internals.h | 104 ++++++++++
 drivers/net/softnic/rte_eth_softnic_tm.c        | 181 +++++++++++++++++
 5 files changed, 555 insertions(+), 2 deletions(-)
 create mode 100644 drivers/net/softnic/rte_eth_softnic_tm.c
drivers/net/softnic/Makefile +1 -0
index c2f42ef..8b848a9 100644
@@ -47,6 +47,7 @@ LIBABIVER := 1
 # all source are stored in SRCS-y
 #
 SRCS-$(CONFIG_RTE_LIBRTE_PMD_SOFTNIC) += rte_eth_softnic.c
+SRCS-$(CONFIG_RTE_LIBRTE_PMD_SOFTNIC) += rte_eth_softnic_tm.c
 
 #
 # Export include files
drivers/net/softnic/rte_eth_softnic.c +253 -2

344 lines not on this page · raw message

drivers/net/softnic/rte_eth_softnic.h +16 -0
index e6996f3..517b96a 100644
@@ -40,6 +40,22 @@
 extern "C" {
 #endif
 
+#ifndef SOFTNIC_SOFT_TM_NB_QUEUES
+#define SOFTNIC_SOFT_TM_NB_QUEUES			65536
+#endif
+
+#ifndef SOFTNIC_SOFT_TM_QUEUE_SIZE
+#define SOFTNIC_SOFT_TM_QUEUE_SIZE			64
+#endif
+
+#ifndef SOFTNIC_SOFT_TM_ENQ_BSZ
+#define SOFTNIC_SOFT_TM_ENQ_BSZ				32
+#endif
+
+#ifndef SOFTNIC_SOFT_TM_DEQ_BSZ
+#define SOFTNIC_SOFT_TM_DEQ_BSZ				24
+#endif
+
 #ifndef SOFTNIC_HARD_TX_QUEUE_ID
 #define SOFTNIC_HARD_TX_QUEUE_ID			0
 #endif
drivers/net/softnic/rte_eth_softnic_internals.h +104 -0

136 lines not on this page · raw message

drivers/net/softnic/rte_eth_softnic_tm.c new file +181 -0

181 lines not on this page · raw message

Signature · 1 line
2.9.3
#44 lore raw

PATCH v6 3/5 net/softnic: add TM capabilities ops

In reply to Jasvinder Singh

Implement ethdev TM capability APIs in SoftNIC PMD.

---
 drivers/net/softnic/rte_eth_softnic.c           |  12 +-
 drivers/net/softnic/rte_eth_softnic_internals.h |  32 ++
 drivers/net/softnic/rte_eth_softnic_tm.c        | 500 ++++++++++++++++++++++++
 3 files changed, 543 insertions(+), 1 deletion(-)
drivers/net/softnic/rte_eth_softnic.c +11 -1
index ab26948..4d70ebf 100644
@@ -43,6 +43,7 @@
 #include <rte_errno.h>
 #include <rte_ring.h>
 #include <rte_sched.h>
+#include <rte_tm_driver.h>
 
 #include "rte_eth_softnic.h"
 #include "rte_eth_softnic_internals.h"
@@ -224,6 +225,15 @@ pmd_link_update(struct rte_eth_dev *dev __rte_unused,
 	return 0;
 }
 
+static int
+pmd_tm_ops_get(struct rte_eth_dev *dev, void *arg)
+{
+	*(const struct rte_tm_ops **)arg =
+		(tm_enabled(dev)) ? &pmd_tm_ops : NULL;
+
+	return 0;
+}
+
 static const struct eth_dev_ops pmd_ops = {
 	.dev_configure = pmd_dev_configure,
 	.dev_start = pmd_dev_start,
@@ -233,7 +243,7 @@ static const struct eth_dev_ops pmd_ops = {
 	.dev_infos_get = pmd_dev_infos_get,
 	.rx_queue_setup = pmd_rx_queue_setup,
 	.tx_queue_setup = pmd_tx_queue_setup,
-	.tm_ops_get = NULL,
+	.tm_ops_get = pmd_tm_ops_get,
 };
 
 static uint16_t
drivers/net/softnic/rte_eth_softnic_internals.h +32 -0
index 11f88d8..9b313d0 100644
@@ -39,6 +39,7 @@
 #include <rte_mbuf.h>
 #include <rte_sched.h>
 #include <rte_ethdev.h>
+#include <rte_tm_driver.h>
 
 #include "rte_eth_softnic.h"
 
@@ -137,8 +138,26 @@ enum tm_node_level {
 	TM_NODE_LEVEL_MAX,
 };
 
+/* TM Node */
+struct tm_node {
+	TAILQ_ENTRY(tm_node) node;
+	uint32_t node_id;
+	uint32_t parent_node_id;
+	uint32_t priority;
+	uint32_t weight;
+	uint32_t level;
+	struct tm_node *parent_node;
+	struct rte_tm_node_params params;
+	struct rte_tm_node_stats stats;
+	uint32_t n_children;
+};
+
+TAILQ_HEAD(tm_node_list, tm_node);
+
 /* TM Hierarchy Specification */
 struct tm_hierarchy {
+	struct tm_node_list nodes;
+
 	uint32_t n_tm_nodes[TM_NODE_LEVEL_MAX];
 };
 
@@ -191,6 +210,11 @@ struct pmd_rx_queue {
 	} hard;
 };
 
+/**
+ * Traffic Management (TM) Operation
+ */
+extern const struct rte_tm_ops pmd_tm_ops;
+
 int
 tm_params_check(struct pmd_params *params, uint32_t hard_rate);
 
@@ -207,6 +231,14 @@ void
 tm_stop(struct pmd_internals *p);
 
 static inline int
+tm_enabled(struct rte_eth_dev *dev)
+{
+	struct pmd_internals *p = dev->data->dev_private;
+
+	return (p->params.soft.flags & PMD_FEATURE_TM);
+}
+
+static inline int
 tm_used(struct rte_eth_dev *dev)
 {
 	struct pmd_internals *p = dev->data->dev_private;
drivers/net/softnic/rte_eth_softnic_tm.c +500 -0

503 lines not on this page · raw message

Signature · 1 line
2.9.3
#45 lore raw

PATCH v6 4/5 net/softnic: add TM hierarchy related ops

In reply to Jasvinder Singh

Implement ethdev TM hierarchy related APIs in SoftNIC PMD.

---
v5 change:
- add macro for the tc period
- add more comments

 drivers/net/softnic/rte_eth_softnic_internals.h |   41 +
 drivers/net/softnic/rte_eth_softnic_tm.c        | 2781 ++++++++++++++++++++++-
 2 files changed, 2817 insertions(+), 5 deletions(-)
drivers/net/softnic/rte_eth_softnic_internals.h +41 -0
index 9b313d0..a2675e0 100644
@@ -138,6 +138,36 @@ enum tm_node_level {
 	TM_NODE_LEVEL_MAX,
 };
 
+/* TM Shaper Profile */
+struct tm_shaper_profile {
+	TAILQ_ENTRY(tm_shaper_profile) node;
+	uint32_t shaper_profile_id;
+	uint32_t n_users;
+	struct rte_tm_shaper_params params;
+};
+
+TAILQ_HEAD(tm_shaper_profile_list, tm_shaper_profile);
+
+/* TM Shared Shaper */
+struct tm_shared_shaper {
+	TAILQ_ENTRY(tm_shared_shaper) node;
+	uint32_t shared_shaper_id;
+	uint32_t n_users;
+	uint32_t shaper_profile_id;
+};
+
+TAILQ_HEAD(tm_shared_shaper_list, tm_shared_shaper);
+
+/* TM WRED Profile */
+struct tm_wred_profile {
+	TAILQ_ENTRY(tm_wred_profile) node;
+	uint32_t wred_profile_id;
+	uint32_t n_users;
+	struct rte_tm_wred_params params;
+};
+
+TAILQ_HEAD(tm_wred_profile_list, tm_wred_profile);
+
 /* TM Node */
 struct tm_node {
 	TAILQ_ENTRY(tm_node) node;
@@ -147,6 +177,8 @@ struct tm_node {
 	uint32_t weight;
 	uint32_t level;
 	struct tm_node *parent_node;
+	struct tm_shaper_profile *shaper_profile;
+	struct tm_wred_profile *wred_profile;
 	struct rte_tm_node_params params;
 	struct rte_tm_node_stats stats;
 	uint32_t n_children;
@@ -156,8 +188,16 @@ TAILQ_HEAD(tm_node_list, tm_node);
 
 /* TM Hierarchy Specification */
 struct tm_hierarchy {
+	struct tm_shaper_profile_list shaper_profiles;
+	struct tm_shared_shaper_list shared_shapers;
+	struct tm_wred_profile_list wred_profiles;
 	struct tm_node_list nodes;
 
+	uint32_t n_shaper_profiles;
+	uint32_t n_shared_shapers;
+	uint32_t n_wred_profiles;
+	uint32_t n_nodes;
+
 	uint32_t n_tm_nodes[TM_NODE_LEVEL_MAX];
 };
 
@@ -170,6 +210,7 @@ struct tm_internals {
 	 *      sense to keep the hierarchy frozen after the port is started.
 	 */
 	struct tm_hierarchy h;
+	int hierarchy_frozen;
 
 	/** Blueprints */
 	struct tm_params params;
drivers/net/softnic/rte_eth_softnic_tm.c +2776 -5

2,833 lines not on this page · raw message

Signature · 1 line
2.9.3
#46 lore raw

PATCH v6 5/5 app/testpmd: add traffic management forwarding mode

In reply to Jasvinder Singh

This commit extends the testpmd application with new forwarding engine that demonstrates the use of ethdev traffic management APIs and softnic PMD for QoS traffic management.

In this mode, 5-level hierarchical tree of the QoS scheduler is built with the help of ethdev TM APIs such as shaper profile add/delete, shared shaper add/update, node add/delete, hierarchy commit, etc. The hierarchical tree has following nodes; root node(x1, level 0), subport node(x1, level 1), pipe node(x4096, level 2),
tc node(x16348, level 3), queue node(x65536, level 4).

During runtime, each received packet is first classified by mapping the packet fields information to 5-tuples (HQoS subport, pipe, traffic class, queue within traffic class, and color) and storing it in the packet mbuf sched field. After classification, each packet is sent to softnic port which prioritizes the transmission of the received packets, and accordingly sends them on to the output interface.

To enable traffic management mode, following testpmd command is used;

$ ./testpmd -c c -n 4 --vdev
	'net_softnic0,hard_name=0000:06:00.1,soft_tm=on' -- -i
	--forward-mode=tm

---
v5 change:
- add CLI to enable default tm hierarchy

v3 change:
- Implements feedback from Pablo[1]
- add flag to check required librte_sched lib and softnic pmd
- code cleanup

v2 change:
- change file name softnictm.c to tm.c
- change forward mode name to "tm"
- code clean up

[1] http://dpdk.org/ml/archives/dev/2017-September/075744.html

 app/test-pmd/Makefile  |   8 +
 app/test-pmd/cmdline.c |  88 +++++
 app/test-pmd/testpmd.c |  15 +
 app/test-pmd/testpmd.h |  46 +++
 app/test-pmd/tm.c      | 865 +++++++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 1022 insertions(+)
 create mode 100644 app/test-pmd/tm.c
app/test-pmd/Makefile +8 -0
index c36be19..2c50f68 100644
@@ -59,6 +59,10 @@ SRCS-y += csumonly.c
 SRCS-y += icmpecho.c
 SRCS-$(CONFIG_RTE_LIBRTE_IEEE1588) += ieee1588fwd.c
 
+ifeq ($(CONFIG_RTE_LIBRTE_PMD_SOFTNIC)$(CONFIG_RTE_LIBRTE_SCHED),yy)
+SRCS-y += tm.c
+endif
+
 ifeq ($(CONFIG_RTE_BUILD_SHARED_LIB),y)
 
 ifeq ($(CONFIG_RTE_LIBRTE_PMD_BOND),y)
@@ -81,6 +85,10 @@ ifeq ($(CONFIG_RTE_LIBRTE_PMD_XENVIRT),y)
 LDLIBS += -lrte_pmd_xenvirt
 endif
 
+ifeq ($(CONFIG_RTE_LIBRTE_PMD_SOFTNIC),y)
+LDLIBS += -lrte_pmd_softnic
+endif
+
 endif
 
 CFLAGS_cmdline.o := -D_GNU_SOURCE
app/test-pmd/cmdline.c +88 -0

106 lines not on this page · raw message

app/test-pmd/testpmd.c +15 -0
index 5507c0f..b900675 100644
@@ -167,6 +167,10 @@ struct fwd_engine * fwd_engines[] = {
 	&tx_only_engine,
 	&csum_fwd_engine,
 	&icmp_echo_engine,
+#if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
+	&softnic_tm_engine,
+	&softnic_tm_bypass_engine,
+#endif
 #ifdef RTE_LIBRTE_IEEE1588
 	&ieee1588_fwd_engine,
 #endif
@@ -2085,6 +2089,17 @@ init_port_config(void)
 		    (rte_eth_devices[pid].data->dev_flags &
 		     RTE_ETH_DEV_INTR_RMV))
 			port->dev_conf.intr_conf.rmv = 1;
+
+#if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
+		/* Detect softnic port */
+		if (!strcmp(port->dev_info.driver_name, "net_softnic")) {
+			port->softnic_enable = 1;
+			memset(&port->softport, 0, sizeof(struct softnic_port));
+
+			if (!strcmp(cur_fwd_eng->fwd_mode_name, "tm"))
+				port->softport.tm_flag = 1;
+		}
+#endif
 	}
 }
 
app/test-pmd/testpmd.h +46 -0

70 lines not on this page · raw message

app/test-pmd/tm.c new file +865 -0

865 lines not on this page · raw message

Signature · 1 line
2.9.3
#47 lore raw

Re: [PATCH v6 0/5] net/softnic: sw fall-back pmd for traffic mgmt and others

In reply to Jasvinder Singh
Quoted 6 lines · Jasvinder Singh

The SoftNIC PMD is intended to provide SW fall-back options for specific ethdev APIs in a generic way to the NICs not supporting those features.

Currently, the only implemented ethdev API is Traffic Management (TM), but other ethdev APIs such as rte_flow, traffic metering & policing, etc can be easily implemented.

<...>

Quoted 9 lines

Cristian Dumitrescu (4):
Jasvinder Singh (4):
net/softnic: add softnic PMD
net/softnic: add traffic management support
net/softnic: add TM capabilities ops
net/softnic: add TM hierarchy related ops

Jasvinder Singh (1):
app/testpmd: add traffic management forwarding mode

Hi Jasvinder,

There is a patchset has been merged into main and next-net repo to convert port_id from 8bits to 16bits.
This PMD also should reflect this conversion, can you please rebase PMD on top of latest next-net?

Please keep existing Acks in next version.

Also there are lots of UNNECESSARY_PARENTHESES checkpatch warnings, can you please fix them?

Quoted 2 lines
 MAINTAINERS                                        |    5 +

Checkpatch also gives warning about MAINTAINERS file updates, not sure why, can you please check this?

<...>

#48 lore raw

Re: [PATCH v6 0/5] net/softnic: sw fall-back pmd for traffic mgmt and others

Quoted 32 lines

-----Original Message-----
From: Yigit, Ferruh
Sent: Friday, October 6, 2017 7:57 PM
To: Singh, Jasvinder <[email protected]>; [email protected]
Cc: Dumitrescu, Cristian <[email protected]>; [email protected]; Lu, Wenzhuo <[email protected]>
Subject: Re: [PATCH v6 0/5] net/softnic: sw fall-back pmd for traffic mgmt and others

Quoted 2 lines · Jasvinder Singh

The SoftNIC PMD is intended to provide SW fall-back options for specific ethdev APIs in a generic way to the NICs not supporting those

features.

Quoted 4 lines

Currently, the only implemented ethdev API is Traffic Management (TM), but other ethdev APIs such as rte_flow, traffic metering & policing, etc can be easily implemented.

<...>

Quoted 9 lines

Cristian Dumitrescu (4):
Jasvinder Singh (4):
net/softnic: add softnic PMD
net/softnic: add traffic management support
net/softnic: add TM capabilities ops
net/softnic: add TM hierarchy related ops

Jasvinder Singh (1):
app/testpmd: add traffic management forwarding mode

Quoted 8 lines

Hi Jasvinder,

There is a patchset has been merged into main and next-net repo to convert port_id from 8bits to 16bits.
This PMD also should reflect this conversion, can you please rebase PMD on top of latest next-net?

Please keep existing Acks in next version.

Ok, will do in the next version.

Quoted 2 lines

Also there are lots of UNNECESSARY_PARENTHESES checkpatch warnings, can you please fix them?

Ok, will fix them.

Quoted 6 lines
Quoted 2 lines
 MAINTAINERS                                        |    5 +

Checkpatch also gives warning about MAINTAINERS file updates, not sure why, can you please check this?

The latest checkpatch script issues warning on the use of "space" instead of "Tab" for defining the type. The existing pattern in the MAINTEINERS files doesn't follow this. "Space" is used for each Type everywhere instead of "Tab", that's why I ignored this warning.

#49 lore raw

PATCH v5 3/5 net/softnic: add TM capabilities ops

In reply to Jasvinder Singh

Implement ethdev TM capability APIs in SoftNIC PMD.

---
 drivers/net/softnic/rte_eth_softnic.c           |  12 +-
 drivers/net/softnic/rte_eth_softnic_internals.h |  32 ++
 drivers/net/softnic/rte_eth_softnic_tm.c        | 500 ++++++++++++++++++++++++
 3 files changed, 543 insertions(+), 1 deletion(-)
drivers/net/softnic/rte_eth_softnic.c +11 -1
index ab26948..4d70ebf 100644
@@ -43,6 +43,7 @@
 #include <rte_errno.h>
 #include <rte_ring.h>
 #include <rte_sched.h>
+#include <rte_tm_driver.h>
 
 #include "rte_eth_softnic.h"
 #include "rte_eth_softnic_internals.h"
@@ -224,6 +225,15 @@ pmd_link_update(struct rte_eth_dev *dev __rte_unused,
 	return 0;
 }
 
+static int
+pmd_tm_ops_get(struct rte_eth_dev *dev, void *arg)
+{
+	*(const struct rte_tm_ops **)arg =
+		(tm_enabled(dev)) ? &pmd_tm_ops : NULL;
+
+	return 0;
+}
+
 static const struct eth_dev_ops pmd_ops = {
 	.dev_configure = pmd_dev_configure,
 	.dev_start = pmd_dev_start,
@@ -233,7 +243,7 @@ static const struct eth_dev_ops pmd_ops = {
 	.dev_infos_get = pmd_dev_infos_get,
 	.rx_queue_setup = pmd_rx_queue_setup,
 	.tx_queue_setup = pmd_tx_queue_setup,
-	.tm_ops_get = NULL,
+	.tm_ops_get = pmd_tm_ops_get,
 };
 
 static uint16_t
drivers/net/softnic/rte_eth_softnic_internals.h +32 -0
index 11f88d8..9b313d0 100644
@@ -39,6 +39,7 @@
 #include <rte_mbuf.h>
 #include <rte_sched.h>
 #include <rte_ethdev.h>
+#include <rte_tm_driver.h>
 
 #include "rte_eth_softnic.h"
 
@@ -137,8 +138,26 @@ enum tm_node_level {
 	TM_NODE_LEVEL_MAX,
 };
 
+/* TM Node */
+struct tm_node {
+	TAILQ_ENTRY(tm_node) node;
+	uint32_t node_id;
+	uint32_t parent_node_id;
+	uint32_t priority;
+	uint32_t weight;
+	uint32_t level;
+	struct tm_node *parent_node;
+	struct rte_tm_node_params params;
+	struct rte_tm_node_stats stats;
+	uint32_t n_children;
+};
+
+TAILQ_HEAD(tm_node_list, tm_node);
+
 /* TM Hierarchy Specification */
 struct tm_hierarchy {
+	struct tm_node_list nodes;
+
 	uint32_t n_tm_nodes[TM_NODE_LEVEL_MAX];
 };
 
@@ -191,6 +210,11 @@ struct pmd_rx_queue {
 	} hard;
 };
 
+/**
+ * Traffic Management (TM) Operation
+ */
+extern const struct rte_tm_ops pmd_tm_ops;
+
 int
 tm_params_check(struct pmd_params *params, uint32_t hard_rate);
 
@@ -207,6 +231,14 @@ void
 tm_stop(struct pmd_internals *p);
 
 static inline int
+tm_enabled(struct rte_eth_dev *dev)
+{
+	struct pmd_internals *p = dev->data->dev_private;
+
+	return (p->params.soft.flags & PMD_FEATURE_TM);
+}
+
+static inline int
 tm_used(struct rte_eth_dev *dev)
 {
 	struct pmd_internals *p = dev->data->dev_private;
drivers/net/softnic/rte_eth_softnic_tm.c +500 -0

503 lines not on this page · raw message

Signature · 1 line
2.9.3
#50 lore raw

PATCH v5 4/5 net/softnic: add TM hierarchy related ops

In reply to Jasvinder Singh

Implement ethdev TM hierarchy related APIs in SoftNIC PMD.

---
v5 change:
- add macro for the tc period
- add more comments

 drivers/net/softnic/rte_eth_softnic_internals.h |   41 +
 drivers/net/softnic/rte_eth_softnic_tm.c        | 2781 ++++++++++++++++++++++-
 2 files changed, 2817 insertions(+), 5 deletions(-)
drivers/net/softnic/rte_eth_softnic_internals.h +41 -0
index 9b313d0..a2675e0 100644
@@ -138,6 +138,36 @@ enum tm_node_level {
 	TM_NODE_LEVEL_MAX,
 };
 
+/* TM Shaper Profile */
+struct tm_shaper_profile {
+	TAILQ_ENTRY(tm_shaper_profile) node;
+	uint32_t shaper_profile_id;
+	uint32_t n_users;
+	struct rte_tm_shaper_params params;
+};
+
+TAILQ_HEAD(tm_shaper_profile_list, tm_shaper_profile);
+
+/* TM Shared Shaper */
+struct tm_shared_shaper {
+	TAILQ_ENTRY(tm_shared_shaper) node;
+	uint32_t shared_shaper_id;
+	uint32_t n_users;
+	uint32_t shaper_profile_id;
+};
+
+TAILQ_HEAD(tm_shared_shaper_list, tm_shared_shaper);
+
+/* TM WRED Profile */
+struct tm_wred_profile {
+	TAILQ_ENTRY(tm_wred_profile) node;
+	uint32_t wred_profile_id;
+	uint32_t n_users;
+	struct rte_tm_wred_params params;
+};
+
+TAILQ_HEAD(tm_wred_profile_list, tm_wred_profile);
+
 /* TM Node */
 struct tm_node {
 	TAILQ_ENTRY(tm_node) node;
@@ -147,6 +177,8 @@ struct tm_node {
 	uint32_t weight;
 	uint32_t level;
 	struct tm_node *parent_node;
+	struct tm_shaper_profile *shaper_profile;
+	struct tm_wred_profile *wred_profile;
 	struct rte_tm_node_params params;
 	struct rte_tm_node_stats stats;
 	uint32_t n_children;
@@ -156,8 +188,16 @@ TAILQ_HEAD(tm_node_list, tm_node);
 
 /* TM Hierarchy Specification */
 struct tm_hierarchy {
+	struct tm_shaper_profile_list shaper_profiles;
+	struct tm_shared_shaper_list shared_shapers;
+	struct tm_wred_profile_list wred_profiles;
 	struct tm_node_list nodes;
 
+	uint32_t n_shaper_profiles;
+	uint32_t n_shared_shapers;
+	uint32_t n_wred_profiles;
+	uint32_t n_nodes;
+
 	uint32_t n_tm_nodes[TM_NODE_LEVEL_MAX];
 };
 
@@ -170,6 +210,7 @@ struct tm_internals {
 	 *      sense to keep the hierarchy frozen after the port is started.
 	 */
 	struct tm_hierarchy h;
+	int hierarchy_frozen;
 
 	/** Blueprints */
 	struct tm_params params;
drivers/net/softnic/rte_eth_softnic_tm.c +2776 -5

2,833 lines not on this page · raw message

Signature · 1 line
2.9.3
#51 lore raw

PATCH v5 5/5 app/testpmd: add traffic management forwarding mode

In reply to Jasvinder Singh

This commit extends the testpmd application with new forwarding engine that demonstrates the use of ethdev traffic management APIs and softnic PMD for QoS traffic management.

In this mode, 5-level hierarchical tree of the QoS scheduler is built with the help of ethdev TM APIs such as shaper profile add/delete, shared shaper add/update, node add/delete, hierarchy commit, etc. The hierarchical tree has following nodes; root node(x1, level 0), subport node(x1, level 1), pipe node(x4096, level 2),
tc node(x16348, level 3), queue node(x65536, level 4).

During runtime, each received packet is first classified by mapping the packet fields information to 5-tuples (HQoS subport, pipe, traffic class, queue within traffic class, and color) and storing it in the packet mbuf sched field. After classification, each packet is sent to softnic port which prioritizes the transmission of the received packets, and accordingly sends them on to the output interface.

To enable traffic management mode, following testpmd command is used;

$ ./testpmd -c c -n 4 --vdev
	'net_softnic0,hard_name=0000:06:00.1,soft_tm=on' -- -i
	--forward-mode=tm

---
v5 change:
- add CLI to enable default tm hierarchy

v3 change:
- Implements feedback from Pablo[1]
- add flag to check required librte_sched lib and softnic pmd
- code cleanup

v2 change:
- change file name softnictm.c to tm.c
- change forward mode name to "tm"
- code clean up

[1] http://dpdk.org/ml/archives/dev/2017-September/075744.html

 app/test-pmd/Makefile  |   8 +
 app/test-pmd/cmdline.c |  88 +++++
 app/test-pmd/testpmd.c |  15 +
 app/test-pmd/testpmd.h |  46 +++
 app/test-pmd/tm.c      | 865 +++++++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 1022 insertions(+)
 create mode 100644 app/test-pmd/tm.c
app/test-pmd/Makefile +8 -0
index c36be19..2c50f68 100644
@@ -59,6 +59,10 @@ SRCS-y += csumonly.c
 SRCS-y += icmpecho.c
 SRCS-$(CONFIG_RTE_LIBRTE_IEEE1588) += ieee1588fwd.c
 
+ifeq ($(CONFIG_RTE_LIBRTE_PMD_SOFTNIC)$(CONFIG_RTE_LIBRTE_SCHED),yy)
+SRCS-y += tm.c
+endif
+
 ifeq ($(CONFIG_RTE_BUILD_SHARED_LIB),y)
 
 ifeq ($(CONFIG_RTE_LIBRTE_PMD_BOND),y)
@@ -81,6 +85,10 @@ ifeq ($(CONFIG_RTE_LIBRTE_PMD_XENVIRT),y)
 LDLIBS += -lrte_pmd_xenvirt
 endif
 
+ifeq ($(CONFIG_RTE_LIBRTE_PMD_SOFTNIC),y)
+LDLIBS += -lrte_pmd_softnic
+endif
+
 endif
 
 CFLAGS_cmdline.o := -D_GNU_SOURCE
app/test-pmd/cmdline.c +88 -0

106 lines not on this page · raw message

app/test-pmd/testpmd.c +15 -0
index e097ee0..d729267 100644
@@ -167,6 +167,10 @@ struct fwd_engine * fwd_engines[] = {
 	&tx_only_engine,
 	&csum_fwd_engine,
 	&icmp_echo_engine,
+#if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
+	&softnic_tm_engine,
+	&softnic_tm_bypass_engine,
+#endif
 #ifdef RTE_LIBRTE_IEEE1588
 	&ieee1588_fwd_engine,
 #endif
@@ -2085,6 +2089,17 @@ init_port_config(void)
 		    (rte_eth_devices[pid].data->dev_flags &
 		     RTE_ETH_DEV_INTR_RMV))
 			port->dev_conf.intr_conf.rmv = 1;
+
+#if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
+		/* Detect softnic port */
+		if (!strcmp(port->dev_info.driver_name, "net_softnic")) {
+			port->softnic_enable = 1;
+			memset(&port->softport, 0, sizeof(struct softnic_port));
+
+			if (!strcmp(cur_fwd_eng->fwd_mode_name, "tm"))
+				port->softport.tm_flag = 1;
+		}
+#endif
 	}
 }
 
app/test-pmd/testpmd.h +46 -0

70 lines not on this page · raw message

app/test-pmd/tm.c new file +865 -0

865 lines not on this page · raw message

Signature · 1 line
2.9.3
#52 lore raw

PATCH v4 3/4 net/softnic: add TM capabilities ops

In reply to Jasvinder Singh

Implement ethdev TM capability APIs in SoftNIC PMD.

---
 drivers/net/softnic/rte_eth_softnic.c           |  12 +-
 drivers/net/softnic/rte_eth_softnic_internals.h |  32 ++
 drivers/net/softnic/rte_eth_softnic_tm.c        | 500 ++++++++++++++++++++++++
 3 files changed, 543 insertions(+), 1 deletion(-)
drivers/net/softnic/rte_eth_softnic.c +11 -1
index 28b5155..d0b5550 100644
@@ -43,6 +43,7 @@
 #include <rte_errno.h>
 #include <rte_ring.h>
 #include <rte_sched.h>
+#include <rte_tm_driver.h>
 
 #include "rte_eth_softnic.h"
 #include "rte_eth_softnic_internals.h"
@@ -224,6 +225,15 @@ pmd_link_update(struct rte_eth_dev *dev __rte_unused,
 	return 0;
 }
 
+static int
+pmd_tm_ops_get(struct rte_eth_dev *dev, void *arg)
+{
+	*(const struct rte_tm_ops **)arg =
+		(tm_enabled(dev)) ? &pmd_tm_ops : NULL;
+
+	return 0;
+}
+
 static const struct eth_dev_ops pmd_ops = {
 	.dev_configure = pmd_dev_configure,
 	.dev_start = pmd_dev_start,
@@ -233,7 +243,7 @@ static const struct eth_dev_ops pmd_ops = {
 	.dev_infos_get = pmd_dev_infos_get,
 	.rx_queue_setup = pmd_rx_queue_setup,
 	.tx_queue_setup = pmd_tx_queue_setup,
-	.tm_ops_get = NULL,
+	.tm_ops_get = pmd_tm_ops_get,
 };
 
 static uint16_t
drivers/net/softnic/rte_eth_softnic_internals.h +32 -0
index f9e2177..5e93f71 100644
@@ -39,6 +39,7 @@
 #include <rte_mbuf.h>
 #include <rte_sched.h>
 #include <rte_ethdev.h>
+#include <rte_tm_driver.h>
 
 #include "rte_eth_softnic.h"
 
@@ -137,8 +138,26 @@ enum tm_node_level {
 	TM_NODE_LEVEL_MAX,
 };
 
+/* TM Node */
+struct tm_node {
+	TAILQ_ENTRY(tm_node) node;
+	uint32_t node_id;
+	uint32_t parent_node_id;
+	uint32_t priority;
+	uint32_t weight;
+	uint32_t level;
+	struct tm_node *parent_node;
+	struct rte_tm_node_params params;
+	struct rte_tm_node_stats stats;
+	uint32_t n_children;
+};
+
+TAILQ_HEAD(tm_node_list, tm_node);
+
 /* TM Hierarchy Specification */
 struct tm_hierarchy {
+	struct tm_node_list nodes;
+
 	uint32_t n_tm_nodes[TM_NODE_LEVEL_MAX];
 };
 
@@ -191,6 +210,11 @@ struct pmd_rx_queue {
 	} hard;
 };
 
+/**
+ * Traffic Management (TM) Operation
+ */
+extern const struct rte_tm_ops pmd_tm_ops;
+
 int
 tm_params_check(struct pmd_params *params, uint32_t hard_rate);
 
@@ -207,6 +231,14 @@ void
 tm_stop(struct pmd_internals *p);
 
 static inline int
+tm_enabled(struct rte_eth_dev *dev)
+{
+	struct pmd_internals *p = dev->data->dev_private;
+
+	return (p->params.soft.flags & PMD_FEATURE_TM);
+}
+
+static inline int
 tm_used(struct rte_eth_dev *dev)
 {
 	struct pmd_internals *p = dev->data->dev_private;
drivers/net/softnic/rte_eth_softnic_tm.c +500 -0

503 lines not on this page · raw message

Signature · 1 line
2.9.3
#53 lore raw

Re: [PATCH v4 3/4] net/softnic: add TM capabilities ops

Hi Jasvinder,

Quoted 10 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Jasvinder Singh
Sent: Monday, September 18, 2017 5:10 PM
To: [email protected]
Cc: Dumitrescu, Cristian <[email protected]>; Yigit, Ferruh <[email protected]>; [email protected]
Subject: [dpdk-dev] [PATCH v4 3/4] net/softnic: add TM capabilities ops

Implement ethdev TM capability APIs in SoftNIC PMD.

Quoted 8 lines
---
 drivers/net/softnic/rte_eth_softnic.c           |  12 +-
 drivers/net/softnic/rte_eth_softnic_internals.h |  32 ++
 drivers/net/softnic/rte_eth_softnic_tm.c        | 500
++++++++++++++++++++++++
 3 files changed, 543 insertions(+), 1 deletion(-)

The same concern of the naming as patch 2.The function and structure names are too common. Better add the prefix 'softnic_' too. Except that, the patch looks good to me.

#54 lore raw

Re: [PATCH v4 3/4] net/softnic: add TM capabilities ops

Quoted 22 lines

Hi Jasvinder,

Quoted 11 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Jasvinder Singh
Sent: Monday, September 18, 2017 5:10 PM
To: [email protected]
Cc: Dumitrescu, Cristian <[email protected]>; Yigit, Ferruh <[email protected]>; [email protected]
Subject: [dpdk-dev] [PATCH v4 3/4] net/softnic: add TM capabilities ops

Implement ethdev TM capability APIs in SoftNIC PMD.

Quoted 8 lines
---
 drivers/net/softnic/rte_eth_softnic.c           |  12 +-
 drivers/net/softnic/rte_eth_softnic_internals.h |  32 ++
 drivers/net/softnic/rte_eth_softnic_tm.c        | 500
++++++++++++++++++++++++
 3 files changed, 543 insertions(+), 1 deletion(-)
Quoted 3 lines

The same concern of the naming as patch 2.The function and structure names are too common. Better add the prefix 'softnic_' too. Except that, the patch looks good to me.

Ok, Thanks. Will clarity and add comments as well.

#55 lore raw

PATCH v4 4/4 net/softnic: add TM hierarchy related ops

In reply to Jasvinder Singh

Implement ethdev TM hierarchy related APIs in SoftNIC PMD.

---
 drivers/net/softnic/rte_eth_softnic_internals.h |   41 +
 drivers/net/softnic/rte_eth_softnic_tm.c        | 2776 ++++++++++++++++++++++-
 2 files changed, 2813 insertions(+), 4 deletions(-)
drivers/net/softnic/rte_eth_softnic_internals.h +41 -0
index 5e93f71..317cb08 100644
@@ -138,6 +138,36 @@ enum tm_node_level {
 	TM_NODE_LEVEL_MAX,
 };
 
+/* TM Shaper Profile */
+struct tm_shaper_profile {
+	TAILQ_ENTRY(tm_shaper_profile) node;
+	uint32_t shaper_profile_id;
+	uint32_t n_users;
+	struct rte_tm_shaper_params params;
+};
+
+TAILQ_HEAD(tm_shaper_profile_list, tm_shaper_profile);
+
+/* TM Shared Shaper */
+struct tm_shared_shaper {
+	TAILQ_ENTRY(tm_shared_shaper) node;
+	uint32_t shared_shaper_id;
+	uint32_t n_users;
+	uint32_t shaper_profile_id;
+};
+
+TAILQ_HEAD(tm_shared_shaper_list, tm_shared_shaper);
+
+/* TM WRED Profile */
+struct tm_wred_profile {
+	TAILQ_ENTRY(tm_wred_profile) node;
+	uint32_t wred_profile_id;
+	uint32_t n_users;
+	struct rte_tm_wred_params params;
+};
+
+TAILQ_HEAD(tm_wred_profile_list, tm_wred_profile);
+
 /* TM Node */
 struct tm_node {
 	TAILQ_ENTRY(tm_node) node;
@@ -147,6 +177,8 @@ struct tm_node {
 	uint32_t weight;
 	uint32_t level;
 	struct tm_node *parent_node;
+	struct tm_shaper_profile *shaper_profile;
+	struct tm_wred_profile *wred_profile;
 	struct rte_tm_node_params params;
 	struct rte_tm_node_stats stats;
 	uint32_t n_children;
@@ -156,8 +188,16 @@ TAILQ_HEAD(tm_node_list, tm_node);
 
 /* TM Hierarchy Specification */
 struct tm_hierarchy {
+	struct tm_shaper_profile_list shaper_profiles;
+	struct tm_shared_shaper_list shared_shapers;
+	struct tm_wred_profile_list wred_profiles;
 	struct tm_node_list nodes;
 
+	uint32_t n_shaper_profiles;
+	uint32_t n_shared_shapers;
+	uint32_t n_wred_profiles;
+	uint32_t n_nodes;
+
 	uint32_t n_tm_nodes[TM_NODE_LEVEL_MAX];
 };
 
@@ -170,6 +210,7 @@ struct tm_internals {
 	 *      sense to keep the hierarchy frozen after the port is started.
 	 */
 	struct tm_hierarchy h;
+	int hierarchy_frozen;
 
 	/** Blueprints */
 	struct tm_params params;
drivers/net/softnic/rte_eth_softnic_tm.c +2772 -4

2,822 lines not on this page · raw message

Signature · 1 line
2.9.3
#56 lore raw

Re: [PATCH v4 4/4] net/softnic: add TM hierarchy related ops

Hi Jasvinder,

Quoted 31 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Jasvinder Singh
Sent: Monday, September 18, 2017 5:10 PM
To: [email protected]
Cc: Dumitrescu, Cristian <[email protected]>; Yigit, Ferruh <[email protected]>; [email protected]
Subject: [dpdk-dev] [PATCH v4 4/4] net/softnic: add TM hierarchy related ops

Implement ethdev TM hierarchy related APIs in SoftNIC PMD.

---
 drivers/net/softnic/rte_eth_softnic_internals.h |   41 +
 drivers/net/softnic/rte_eth_softnic_tm.c        | 2776
++++++++++++++++++++++-
 2 files changed, 2813 insertions(+), 4 deletions(-)
drivers/net/softnic/rte_eth_softnic_tm.c +3 -0
+
+static uint32_t
+tm_node_subport_id(struct rte_eth_dev *dev, struct tm_node

*subport_node)

drivers/net/softnic/rte_eth_softnic_tm.c +8 -0
+{
+	struct pmd_internals *p = dev->data->dev_private;
+	struct tm_node_list *nl = &p->soft.tm.h.nodes;
+	struct tm_node *ns;
+	uint32_t subport_id;
+
+	subport_id = 0;
+	TAILQ_FOREACH(ns, nl, node) {

drivers/net/softnic/rte_eth_softnic_tm.c tm_node_search(struct rte_eth_dev *dev, uint32_t node_id) · line 355

Quoted 10 lines
drivers/net/softnic/rte_eth_softnic_tm.c +10 -0
+		if (ns->level != TM_NODE_LEVEL_SUBPORT)
+			continue;
+
+		if (ns->node_id == subport_node->node_id)
+			return subport_id;
+
+		subport_id++;
+	}
+
+	return UINT32_MAX;

UINT32_MAX means invalid number, right? Better define a specific MACRO for the invalid number in case you may not want to use 0xff.. or uint32. The same suggestion for the below functions.

Quoted 22 lines
drivers/net/softnic/rte_eth_softnic_tm.c +22 -0
+static int
+shaper_profile_check(struct rte_eth_dev *dev,
+	uint32_t shaper_profile_id,
+	struct rte_tm_shaper_params *profile,
+	struct rte_tm_error *error)
+{
+	struct tm_shaper_profile *sp;
+
+	/* Shaper profile ID must not be NONE. */
+	if (shaper_profile_id == RTE_TM_SHAPER_PROFILE_ID_NONE)
+		return -rte_tm_error_set(error,
+			EINVAL,
+			RTE_TM_ERROR_TYPE_SHAPER_PROFILE_ID,
+			NULL,
+			rte_strerror(EINVAL));
+
+	/* Shaper profile must not exist. */
+	sp = tm_shaper_profile_search(dev, shaper_profile_id);
+	if (sp)
+		return -rte_tm_error_set(error,
+			EEXIST,
+			RTE_TM_ERROR_TYPE_SHAPER_PROFILE_ID,

drivers/net/softnic/rte_eth_softnic_tm.c pmd_tm_node_capabilities_get(struct rte_eth_dev *dev __rte_unused, · line 950

Quoted 10 lines
drivers/net/softnic/rte_eth_softnic_tm.c +10 -0
+			NULL,
+			rte_strerror(EEXIST));
+
+	/* Profile must not be NULL. */
+	if (profile == NULL)
+		return -rte_tm_error_set(error,
+			EINVAL,
+			RTE_TM_ERROR_TYPE_SHAPER_PROFILE,
+			NULL,
+			rte_strerror(EINVAL));

A slight suggestion. We can do the easiest check at first.

Quoted 10 lines
drivers/net/softnic/rte_eth_softnic_tm.c +10 -0
+
+/* Traffic manager shaper profile add */
+static int
+pmd_tm_shaper_profile_add(struct rte_eth_dev *dev,
+	uint32_t shaper_profile_id,
+	struct rte_tm_shaper_params *profile,
+	struct rte_tm_error *error)
+{
+	struct pmd_internals *p = dev->data->dev_private;
+	struct tm_shaper_profile_list *spl = &p->soft.tm.h.shaper_profiles;

drivers/net/softnic/rte_eth_softnic_tm.c pmd_tm_node_capabilities_get(struct rte_eth_dev *dev __rte_unused, · line 1007

Quoted 10 lines
drivers/net/softnic/rte_eth_softnic_tm.c +10 -0
+	struct tm_shaper_profile *sp;
+	int status;
+
+	/* Check input params */
+	status = shaper_profile_check(dev, shaper_profile_id, profile, error);
+	if (status)
+		return status;
+
+	/* Memory allocation */
+	sp = calloc(1, sizeof(struct tm_shaper_profile));

Just curious, why not use rte_zmalloc?

Quoted 32 lines
drivers/net/softnic/rte_eth_softnic_tm.c +31 -0
+	if (sp == NULL)
+		return -rte_tm_error_set(error,
+			ENOMEM,
+			RTE_TM_ERROR_TYPE_UNSPECIFIED,
+			NULL,
+			rte_strerror(ENOMEM));
+
+	/* Fill in */
+	sp->shaper_profile_id = shaper_profile_id;
+	memcpy(&sp->params, profile, sizeof(sp->params));
+
+	/* Add to list */
+	TAILQ_INSERT_TAIL(spl, sp, node);
+	p->soft.tm.h.n_shaper_profiles++;
+
+	return 0;
+}
+
 
+
+static struct tm_node *
+tm_shared_shaper_get_tc(struct rte_eth_dev *dev,
+	struct tm_shared_shaper *ss)
+{
+	struct pmd_internals *p = dev->data->dev_private;
+	struct tm_node_list *nl = &p->soft.tm.h.nodes;
+	struct tm_node *n;
+
+	TAILQ_FOREACH(n, nl, node) {
+		if ((n->level != TM_NODE_LEVEL_TC) ||
+			(n->params.n_shared_shapers == 0) ||
+			(n->params.shared_shaper_id[0] != ss-
Quoted 1 line
Quoted 1 line

shared_shaper_id))

According to node_add_check_tc, only one shared shaper supported, right? Better adding some comments here?

Quoted 19 lines
drivers/net/softnic/rte_eth_softnic_tm.c +16 -0
+			continue;
+
+		return n;
+	}
+
+	return NULL;
+}
 
 
 
+
+static void
+pipe_profile_build(struct rte_eth_dev *dev,
+	struct tm_node *np,
+	struct rte_sched_pipe_params *pp)
+{
+	struct pmd_internals *p = dev->data->dev_private;
+	struct tm_hierarchy *h = &p->soft.tm.h;
+	struct tm_node_list *nl = &h->nodes;

drivers/net/softnic/rte_eth_softnic_tm.c pmd_tm_node_capabilities_get(struct rte_eth_dev *dev __rte_unused, · line 2058

Quoted 10 lines
drivers/net/softnic/rte_eth_softnic_tm.c +10 -0
+	struct tm_node *nt, *nq;
+
+	memset(pp, 0, sizeof(*pp));
+
+	/* Pipe */
+	pp->tb_rate = np->shaper_profile->params.peak.rate;
+	pp->tb_size = np->shaper_profile->params.peak.size;
+
+	/* Traffic Class (TC) */
+	pp->tc_period = 40;

40 means? A MACRO is better?

drivers/net/softnic/rte_eth_softnic_tm.c pmd_tm_node_capabilities_get(struct rte_eth_dev *dev __rte_unused, · line 2100

Quoted 11 lines
drivers/net/softnic/rte_eth_softnic_tm.c +11 -0
+
+static int
+pipe_profile_free_exists(struct rte_eth_dev *dev,
+	uint32_t *pipe_profile_id)
+{
+	struct pmd_internals *p = dev->data->dev_private;
+	struct tm_params *t = &p->soft.tm.params;
+
+	if (t->n_pipe_profiles < RTE_SCHED_PIPE_PROFILES_PER_PORT) {
+		*pipe_profile_id = t->n_pipe_profiles;
+		return 1;

Returning true or false is easier to understand?

Also the same concern of the naming as patch 3.

#57 lore raw

Re: [PATCH v4 4/4] net/softnic: add TM hierarchy related ops

Quoted 40 lines

Hi Jasvinder,

Quoted 37 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Jasvinder Singh
Sent: Monday, September 18, 2017 5:10 PM
To: [email protected]
Cc: Dumitrescu, Cristian <[email protected]>; Yigit, Ferruh <[email protected]>; [email protected]
Subject: [dpdk-dev] [PATCH v4 4/4] net/softnic: add TM hierarchy related ops

Implement ethdev TM hierarchy related APIs in SoftNIC PMD.

---
 drivers/net/softnic/rte_eth_softnic_internals.h |   41 +
 drivers/net/softnic/rte_eth_softnic_tm.c        | 2776
++++++++++++++++++++++-
 2 files changed, 2813 insertions(+), 4 deletions(-)
drivers/net/softnic/rte_eth_softnic_tm.c +3 -0
+
+static uint32_t
+tm_node_subport_id(struct rte_eth_dev *dev, struct tm_node

*subport_node)

drivers/net/softnic/rte_eth_softnic_tm.c +13 -0
+{
+	struct pmd_internals *p = dev->data->dev_private;
+	struct tm_node_list *nl = &p->soft.tm.h.nodes;
+	struct tm_node *ns;
+	uint32_t subport_id;
+
+	subport_id = 0;
+	TAILQ_FOREACH(ns, nl, node) {
+		if (ns->level != TM_NODE_LEVEL_SUBPORT)
+			continue;
+
+		if (ns->node_id == subport_node->node_id)
+			return subport_id;
Quoted 8 lines

drivers/net/softnic/rte_eth_softnic_tm.c tm_node_search(struct rte_eth_dev *dev, uint32_t node_id) · line 355

Quoted 5 lines
drivers/net/softnic/rte_eth_softnic_tm.c +5 -0
+
+		subport_id++;
+	}
+
+	return UINT32_MAX;

UINT32_MAX means invalid number, right? Better define a specific MACRO for the invalid number in case you may not want to use 0xff.. or uint32. The same suggestion for the below functions.

Ok.

Quoted 25 lines
Quoted 25 lines
drivers/net/softnic/rte_eth_softnic_tm.c +25 -0
+static int
+shaper_profile_check(struct rte_eth_dev *dev,
+	uint32_t shaper_profile_id,
+	struct rte_tm_shaper_params *profile,
+	struct rte_tm_error *error)
+{
+	struct tm_shaper_profile *sp;
+
+	/* Shaper profile ID must not be NONE. */
+	if (shaper_profile_id == RTE_TM_SHAPER_PROFILE_ID_NONE)
+		return -rte_tm_error_set(error,
+			EINVAL,
+			RTE_TM_ERROR_TYPE_SHAPER_PROFILE_ID,
+			NULL,
+			rte_strerror(EINVAL));
+
+	/* Shaper profile must not exist. */
+	sp = tm_shaper_profile_search(dev, shaper_profile_id);
+	if (sp)
+		return -rte_tm_error_set(error,
+			EEXIST,
+			RTE_TM_ERROR_TYPE_SHAPER_PROFILE_ID,
+			NULL,
+			rte_strerror(EEXIST));
+
Quoted 8 lines

drivers/net/softnic/rte_eth_softnic_tm.c pmd_tm_node_capabilities_get(struct rte_eth_dev *dev __rte_unused, · line 950

Quoted 7 lines
drivers/net/softnic/rte_eth_softnic_tm.c +7 -0
+	/* Profile must not be NULL. */
+	if (profile == NULL)
+		return -rte_tm_error_set(error,
+			EINVAL,
+			RTE_TM_ERROR_TYPE_SHAPER_PROFILE,
+			NULL,
+			rte_strerror(EINVAL));

A slight suggestion. We can do the easiest check at first.

We preferred to perform checks as per the arguments order specified in the function definition so that all the parameter could be scanned in a systematic manner instead of picking them randomly.

Quoted 12 lines
Quoted 12 lines
drivers/net/softnic/rte_eth_softnic_tm.c +12 -0
+
+/* Traffic manager shaper profile add */ static int
+pmd_tm_shaper_profile_add(struct rte_eth_dev *dev,
+	uint32_t shaper_profile_id,
+	struct rte_tm_shaper_params *profile,
+	struct rte_tm_error *error)
+{
+	struct pmd_internals *p = dev->data->dev_private;
+	struct tm_shaper_profile_list *spl = &p->soft.tm.h.shaper_profiles;
+	struct tm_shaper_profile *sp;
+	int status;
+
Quoted 8 lines

drivers/net/softnic/rte_eth_softnic_tm.c pmd_tm_node_capabilities_get(struct rte_eth_dev *dev __rte_unused, · line 1007

Quoted 7 lines
drivers/net/softnic/rte_eth_softnic_tm.c +7 -0
+	/* Check input params */
+	status = shaper_profile_check(dev, shaper_profile_id, profile, error);
+	if (status)
+		return status;
+
+	/* Memory allocation */
+	sp = calloc(1, sizeof(struct tm_shaper_profile));

Just curious, why not use rte_zmalloc?

This relates to high level hierarchy specification objects which doesn't need to be allocated on specific numa node as it is not used once the hierarchy is committed. All these objects gets eventually translated into TM implementation (librte_sched) specific objects. These objects are allocated using rte_zmalloc and needs lots of memory (approx. 2M mbufs for single instance of TM hierarchy ports) on specific numa node.

Quoted 32 lines
Quoted 32 lines
drivers/net/softnic/rte_eth_softnic_tm.c +31 -0
+	if (sp == NULL)
+		return -rte_tm_error_set(error,
+			ENOMEM,
+			RTE_TM_ERROR_TYPE_UNSPECIFIED,
+			NULL,
+			rte_strerror(ENOMEM));
+
+	/* Fill in */
+	sp->shaper_profile_id = shaper_profile_id;
+	memcpy(&sp->params, profile, sizeof(sp->params));
+
+	/* Add to list */
+	TAILQ_INSERT_TAIL(spl, sp, node);
+	p->soft.tm.h.n_shaper_profiles++;
+
+	return 0;
+}
+
 
+
+static struct tm_node *
+tm_shared_shaper_get_tc(struct rte_eth_dev *dev,
+	struct tm_shared_shaper *ss)
+{
+	struct pmd_internals *p = dev->data->dev_private;
+	struct tm_node_list *nl = &p->soft.tm.h.nodes;
+	struct tm_node *n;
+
+	TAILQ_FOREACH(n, nl, node) {
+		if ((n->level != TM_NODE_LEVEL_TC) ||
+			(n->params.n_shared_shapers == 0) ||
+			(n->params.shared_shaper_id[0] != ss-
Quoted 3 lines
Quoted 1 line
Quoted 1 line

shared_shaper_id))

According to node_add_check_tc, only one shared shaper supported, right? Better adding some comments here?

The subport has 4 shared shapers for each of the pipe traffic classes. Will add comment.

Quoted 22 lines
Quoted 22 lines
drivers/net/softnic/rte_eth_softnic_tm.c +19 -0
+			continue;
+
+		return n;
+	}
+
+	return NULL;
+}
 
 
 
+
+static void
+pipe_profile_build(struct rte_eth_dev *dev,
+	struct tm_node *np,
+	struct rte_sched_pipe_params *pp)
+{
+	struct pmd_internals *p = dev->data->dev_private;
+	struct tm_hierarchy *h = &p->soft.tm.h;
+	struct tm_node_list *nl = &h->nodes;
+	struct tm_node *nt, *nq;
+
+	memset(pp, 0, sizeof(*pp));
Quoted 8 lines

drivers/net/softnic/rte_eth_softnic_tm.c pmd_tm_node_capabilities_get(struct rte_eth_dev *dev __rte_unused, · line 2058

Quoted 7 lines
drivers/net/softnic/rte_eth_softnic_tm.c +7 -0
+
+	/* Pipe */
+	pp->tb_rate = np->shaper_profile->params.peak.rate;
+	pp->tb_size = np->shaper_profile->params.peak.size;
+
+	/* Traffic Class (TC) */
+	pp->tc_period = 40;

40 means? A MACRO is better?

will add macro. Thanks.

Quoted 4 lines
Quoted 4 lines
drivers/net/softnic/rte_eth_softnic_tm.c +4 -0
+
+static int
+pipe_profile_free_exists(struct rte_eth_dev *dev,
+	uint32_t *pipe_profile_id)
Quoted 8 lines

drivers/net/softnic/rte_eth_softnic_tm.c pmd_tm_node_capabilities_get(struct rte_eth_dev *dev __rte_unused, · line 2100

Quoted 7 lines
drivers/net/softnic/rte_eth_softnic_tm.c +7 -0
+{
+	struct pmd_internals *p = dev->data->dev_private;
+	struct tm_params *t = &p->soft.tm.params;
+
+	if (t->n_pipe_profiles < RTE_SCHED_PIPE_PROFILES_PER_PORT) {
+		*pipe_profile_id = t->n_pipe_profiles;
+		return 1;

Returning true or false is easier to understand?

Ok.

Quoted 1 line

Also the same concern of the naming as patch 3.

Ok. Will bring clarity in the names.

Thanks for the comments and time.

#58 lore raw

Re: [PATCH v4 0/4] net/softnic: sw fall-back pmd for traffic mgmt and others

In reply to Jasvinder Singh

Hi,

18/09/2017 11:10, Jasvinder Singh:

Quoted 2 lines

The SoftNIC PMD is intended to provide SW fall-back options for specific ethdev APIs in a generic way to the NICs not supporting those features.

I agree it is important to have a solution in DPDK to better manage SW fallbacks. One question is to know whether we can implement and maintain many solutions. We probably must choose only one solution.

I have not read the code. I am just interested in the design for now. I think it is a smart idea but maybe less convenient than calling fallback from ethdev API glue code. My opinion has not changed since v1. Thanks for the detailed explanations. Let's discuss below.

[...]

Quoted 3 lines

* RX/TX: The app reads packets from/writes packets to the "soft" port instead of the "hard" port. The RX and TX queues of the "soft" port are thread safe, as any ethdev.

"thread safe as any ethdev"?
I would say the ethdev queues are not thread safe.

[...]

Quoted 6 lines

* Meets the NFV vision: The app should be (almost) agnostic about the NIC implementation (different vendors/models, HW-SW mix), the app should not require changes to use different NICs, the app should use the same API for all NICs. If a NIC does not implement a specific feature, the HW should be augmented with SW to meet the functionality while still preserving the same API.

This goal could also be achieved by adding the SW capability to the API. After getting capabilities of a hardware, the app could set the capability of some driver features to "SW fallback".
So the capability would become a tristate:
- not supported
- HW supported
- SW supported

The unique API goal is failed if we must manage two ports, the HW port for some features and the softnic port for other features. You explain it in A5 below.

[...]

Quoted 3 lines

Example: Create "soft" port for "hard" port "0000:04:00.1", enable the TM feature with default settings:

          --vdev 'net_softnic0,hard_name=0000:04:00.1,soft_tm=on' 

So the app will use only the vdev net_softnic0 which will forward packets to 0000:04:00.1?
Can we say in this example that net_softnic0 owns 0000:04:00.1? Probably not, because the config of the HW must be done separately (cf. Q5). See my "ownership proposal":

	http://dpdk.org/ml/archives/dev/2017-September/074656.html

The issue I see in this example is that we must define how to enable every features. It should be equivalent to defining the ethdev capabilities. In this example, the option soft_tm=on is probably not enough fine-grain. We could support some parts of TM API in HW and other parts in SW.

[...]

Quoted 4 lines

Q3: Why not change the "hard" device (and keep a single device) instead of
creating a new "soft" device (and thus having two devices)?
A3: This is not possible with the current librte_ether ethdev
implementation. The ethdev->dev_ops are defined as constant structure,

Quoted 8 lines

so it cannot be changed per device (nor per PMD). The new ops also need memory space to store their context data structures, which requires updating the ethdev->data->dev_private of the existing device; at best, maybe a resize of ethdev->data->dev_private could be done, assuming that librte_ether will introduce a way to find out its size, but this cannot be done while device is running. Other side effects might exist, as the changes are very intrusive, plus it likely needs more changes in librte_ether.

Q3 is about calling SW fallback from the driver code, right?

We must not implement fallbacks in drivers because it would hide it to the application.
If a feature is not available in hardware, the application can choose to bypass this feature or integrate the fallback in its own workflow.

Quoted 8 lines

Q4: Why not call the SW fall-back dev_ops directly in librte_ether for
devices which do not support the specific feature? If the device supports the capability, let's call its dev_ops, otherwise call the SW fall-back dev_ops.
A4: First, similar reasons to Q&A3. This fixes the need to change
ethdev->dev_ops of the device, but it does not do anything to fix the other significant issue of where to store the context data structures needed by the SW fall-back functions (which, in this approach, are

Quoted 8 lines

called implicitly by librte_ether).
Second, the SW fall-back options should not be restricted arbitrarily by the librte_ether library, the decision should belong to the app. For example, the TM SW fall-back should not be limited to only librte_sched, which (like any SW fall-back) is limited to a specific hierarchy and feature set, it cannot do any possible hierarchy. If alternatives exist, the one to use should be picked by the app, not by the ethdev layer.

Q4 is about calling SW callback from the API glue code, right?

We could summarize Q3/Q4 as "it could be done but we propose another way". I think we must consider the pros and cons of both approaches from a user perspective.
I agree the application must decide which fallback to use.
We could propose one fallback in ethdev which can be enabled explicitly (see my tristate capabilities proposal above).

Quoted 14 lines

Q5: Why is the app required to continue to configure both the "hard" and
the "soft" devices even after the "soft" device has been created? Why not hiding the "hard" device under the "soft" device and have the "soft" device configure the "hard" device under the hood?
A5: This was the approach tried in the V2 of this patch set (overlay
"soft" device taking over the configuration of the underlay "hard" device) and eventually dropped due to increased complexity of having to keep the configuration of two distinct devices in sync with librte_ether implementation that is not friendly towards such approach. Basically, each ethdev API call for the overlay device needs to configure the overlay device, invoke the same configuration with possibly modified parameters for the underlay device, then resume the configuration of overlay device, turning this into a device emulation project.

Quoted 8 lines

V2 minuses: increased complexity (deal with two devices at same time); need to implement every ethdev API, even those not needed for the scope of SW fall-back; intrusive; sometimes have to silently take decisions that should be left to the app.
V3 pluses: lower complexity (only one device); only need to implement those APIs that are in scope of the SW fall-back; non-intrusive (deal with "hard" device through ethdev API); app decisions taken by the app in an explicit way.

I think it is breaking what you call the NFV vision in several places.

[...]

Quoted 6 lines

9. [rte_ring proliferation] Thread safety requirements for ethdev RX/TXqueues require an rte_ring to be used for every RX/TX queue of each "soft" ethdev. This rte_ring proliferation unnecessarily increases the memory footprint and lowers performance, especially when each "soft" ethdev ends up on a different CPU core (ping-pong of cache lines).

I am curious to understand why you consider thread safety as a requirement for queues. No need to reply here, the question is already asked at the beginning of this email ;)

#59 lore raw

Re: [PATCH v4 0/4] net/softnic: sw fall-back pmd for traffic mgmt and others

Hi Thomas,

Quoted 16 lines

-----Original Message-----
From: Thomas Monjalon [mailto:[email protected]]
Sent: Wednesday, September 20, 2017 4:36 PM
To: Singh, Jasvinder <[email protected]>; Dumitrescu, Cristian <[email protected]>
Cc: [email protected]; Yigit, Ferruh <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v4 0/4] net/softnic: sw fall-back pmd for traffic mgmt and others

Hi,

18/09/2017 11:10, Jasvinder Singh:

Quoted 2 lines

The SoftNIC PMD is intended to provide SW fall-back options for specific ethdev APIs in a generic way to the NICs not supporting those

features.

Quoted 7 lines

I agree it is important to have a solution in DPDK to better manage SW fallbacks. One question is to know whether we can implement and maintain many solutions. We probably must choose only one solution.

I have not read the code. I am just interested in the design for now. I think it is a smart idea but maybe less convenient than calling fallback from ethdev API glue code. My opinion has not changed since v1.

IMHO, Calling fallback from ethdev API glue code suffers from scalability issue. Let's assume the scenario of having another sw fallback implementation for TM or its specific feature is available. What will be the approach when we already have something glued in TM API? The softnic could be considered as a placeholder for adding and enabling more features at any granularity in addition
to having complete TM feature.

Quoted 9 lines

Thanks for the detailed explanations. Let's discuss below.

[...]

Quoted 3 lines

* RX/TX: The app reads packets from/writes packets to the "soft" port instead of the "hard" port. The RX and TX queues of the "soft" port are thread safe, as any ethdev.

"thread safe as any ethdev"?
I would say the ethdev queues are not thread safe.

[Jasvinder] Agree.

Quoted 17 lines

[...]

Quoted 2 lines

* Meets the NFV vision: The app should be (almost) agnostic about the NIC implementation (different vendors/models, HW-SW mix), the app should

not

Quoted 4 lines

require changes to use different NICs, the app should use the same API for all NICs. If a NIC does not implement a specific feature, the HW should be augmented with SW to meet the functionality while still preserving the same API.

This goal could also be achieved by adding the SW capability to the API. After getting capabilities of a hardware, the app could set the capability of some driver features to "SW fallback".
So the capability would become a tristate:
- not supported
- HW supported
- SW supported

Quoted 3 lines

The unique API goal is failed if we must manage two ports, the HW port for some features and the softnic port for other features.
You explain it in A5 below.

[Jasvinder] TM API is agnostic to underlying implementation and allows applications to implement
solution on SW, HW or hybrid of HW and SW at any granularity, and on any number of devices depending
upon the availability of features. No Restriction. Thus, managing and configuring number of devices (physical and virtual) using high level api is at the disposal of application level framework. When softnic device is enabled, application sends and receives packet from soft device instead of hard device as soft device implements the features missing in hard device. It deosn't mean that softnic device should hide the hard device. However, it doesn't restrict application to communicate directly with hard device. If desired, application can bypass the softnic device and send tx packet straight to hard device through the queues not used by soft device.

Quoted 10 lines

[...]

Quoted 3 lines

Example: Create "soft" port for "hard" port "0000:04:00.1", enable the TM feature with default settings:

          --vdev 'net_softnic0,hard_name=0000:04:00.1,soft_tm=on'

So the app will use only the vdev net_softnic0 which will forward packets to 0000:04:00.1?
Can we say in this example that net_softnic0 owns 0000:04:00.1? Probably not, because the config of the HW must be done separately (cf. Q5). See my "ownership proposal":

Quoted 7 lines
	http://dpdk.org/ml/archives/dev/2017-September/074656.html

The issue I see in this example is that we must define how to enable every features. It should be equivalent to defining the ethdev capabilities. In this example, the option soft_tm=on is probably not enough fine-grain. We could support some parts of TM API in HW and other parts in SW.

[Jasvinder] - This is one instance where the complete hierarchical scheduler is presented as software fallback. But the approach doesn't restrict to add more features (at any granularity) to softnic and enable them altogether naming arguments during device creation.

Quoted 14 lines

[...]

Quoted 4 lines

Q3: Why not change the "hard" device (and keep a single device) instead of
creating a new "soft" device (and thus having two devices)?
A3: This is not possible with the current librte_ether ethdev
implementation. The ethdev->dev_ops are defined as constant structure,

Quoted 8 lines

so it cannot be changed per device (nor per PMD). The new ops also need memory space to store their context data structures, which requires updating the ethdev->data->dev_private of the existing device; at best, maybe a resize of ethdev->data->dev_private could be done, assuming that librte_ether will introduce a way to find out its size, but this cannot be done while device is running. Other side effects might exist, as the changes are very intrusive, plus it likely needs more changes in librte_ether.

Quoted 6 lines

Q3 is about calling SW fallback from the driver code, right?

We must not implement fallbacks in drivers because it would hide it to the application.
If a feature is not available in hardware, the application can choose to bypass this feature or integrate the fallback in its own workflow.

[Jasvinder]: Naturally, if hard device has the TM feature, then TM specific ops which are invoked API function are implemented by its pmd. Similar approach has been followed in sw fallback solution as softnic port that complements the hard device.

Quoted 19 lines
Quoted 8 lines

Q4: Why not call the SW fall-back dev_ops directly in librte_ether for
devices which do not support the specific feature? If the device supports the capability, let's call its dev_ops, otherwise call the SW fall-back dev_ops.
A4: First, similar reasons to Q&A3. This fixes the need to change
ethdev->dev_ops of the device, but it does not do anything to fix the other significant issue of where to store the context data structures needed by the SW fall-back functions (which, in this approach, are

Quoted 8 lines

called implicitly by librte_ether).
Second, the SW fall-back options should not be restricted arbitrarily by the librte_ether library, the decision should belong to the app. For example, the TM SW fall-back should not be limited to only librte_sched, which (like any SW fall-back) is limited to a specific hierarchy and feature set, it cannot do any possible hierarchy. If alternatives exist, the one to use should be picked by the app, not by the ethdev layer.

Q4 is about calling SW callback from the API glue code, right?

Quoted 7 lines

We could summarize Q3/Q4 as "it could be done but we propose another way".
I think we must consider the pros and cons of both approaches from a user perspective.
I agree the application must decide which fallback to use.
We could propose one fallback in ethdev which can be enabled explicitly (see my tristate capabilities proposal above).

[Jasvinder] As explained above as well, the approach of sticking sw solution with API will create issue of scalability. How two different SW solution will coexist or for instance N software solutions. That's why the softnic (virtual device) is proposed as an alternative which could be extended to include and enable features.

Quoted 17 lines
Quoted 8 lines

Q5: Why is the app required to continue to configure both the "hard" and
the "soft" devices even after the "soft" device has been created? Why not hiding the "hard" device under the "soft" device and have the "soft" device configure the "hard" device under the hood?
A5: This was the approach tried in the V2 of this patch set (overlay
"soft" device taking over the configuration of the underlay "hard" device) and eventually dropped due to increased complexity of having to keep the configuration of two distinct devices in sync with

Quoted 8 lines

librte_ether implementation that is not friendly towards such approach. Basically, each ethdev API call for the overlay device needs to configure the overlay device, invoke the same configuration with possibly modified parameters for the underlay device, then resume the configuration of overlay device, turning this into a device emulation project.
V2 minuses: increased complexity (deal with two devices at same time); need to implement every ethdev API, even those not needed for the

scope

Quoted 8 lines
Quoted 6 lines

of SW fall-back; intrusive; sometimes have to silently take decisions that should be left to the app.
V3 pluses: lower complexity (only one device); only need to implement those APIs that are in scope of the SW fall-back; non-intrusive (deal with "hard" device through ethdev API); app decisions taken by the app in an explicit way.

I think it is breaking what you call the NFV vision in several places.

[Jasvinder] Mentioning nfv vision is about hiding heterogeneous implementation (HW,SW, HW-SW hybrid) under the abstraction layer provided by TM API instead of restricting app to use API for specific port.

Quoted 12 lines

[...]

Quoted 6 lines

9. [rte_ring proliferation] Thread safety requirements for ethdev RX/TXqueues require an rte_ring to be used for every RX/TX queue of each "soft" ethdev. This rte_ring proliferation unnecessarily increases the memory footprint and lowers performance, especially when each "soft" ethdev ends up on a different CPU core (ping-pong of cache lines).

I am curious to understand why you consider thread safety as a requirement for queues. No need to reply here, the question is already asked at the beginning of this email ;)

#60 lore raw

Re: [PATCH v4 0/4] net/softnic: sw fall-back pmd for traffic mgmt and others

In reply to Thomas Monjalon

Hi Thomas,

Thanks for taking the time to read through our rationale and provide quality comments on a topic where usually people are shouting but not listening!

Quoted 15 lines

-----Original Message-----
From: Thomas Monjalon [mailto:[email protected]]
Sent: Wednesday, September 20, 2017 4:36 PM
To: Singh, Jasvinder <[email protected]>; Dumitrescu, Cristian <[email protected]>
Cc: [email protected]; Yigit, Ferruh <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v4 0/4] net/softnic: sw fall-back pmd for traffic mgmt and others

Hi,

18/09/2017 11:10, Jasvinder Singh:

Quoted 2 lines

The SoftNIC PMD is intended to provide SW fall-back options for specific ethdev APIs in a generic way to the NICs not supporting those features.

Quoted 9 lines

I agree it is important to have a solution in DPDK to better manage SW fallbacks. One question is to know whether we can implement and maintain many solutions. We probably must choose only one solution.

I have not read the code. I am just interested in the design for now. I think it is a smart idea but maybe less convenient than calling fallback from ethdev API glue code. My opinion has not changed since v1. Thanks for the detailed explanations. Let's discuss below.

Don't understand me wrong, I would also like to have the single device solution (hard NIC augmented with SW-implemented features) as opposed to the current proposal, which requires two devices (hard device and soft device acting as app front-end for the hard device).

The problem is that right now the single device solution is not an option with the current librte_ether, as there simply a lot of changes required that need more time to think through and get agreement, and likely several incremental stages are required to make it happen. As detailed in the Dublin presentation, they mostly refer to:
- the need of the SW fall-back to maintain its owns data structures and functions (per device, per RX queue, per TX queue)
- coexistence of all the features together
- how to bind an ethdev to one (or several) SW threads
- thread safety requirements between ethdev SW thread and app threads

Per our Dublin discussion, here is my proposal:
1. Get Soft NIC PMD into release 17.11.
a) It is the imperfect 2-device solution, but it works and provides an interim solution.
b) It allows us to make progress on the development for a few key features such as traffic management (on TX) and hopefully flow & metering (on RX) and get feedback on this code that we can later restructure into the final single-device solution.
c) It is purely yet another PMD which we can melt away into the final solution later.
2. Start an RFC on librte_ether required changes to get the single-device solution in place.
a) I can spend some time to summarize the objectives, requirements, current issues and potential approaches and send the first draft of this RFC in the next week or two?
b) We can then discuss, poll for more ideas and hopefully draft an incremental path forward

What do you think?

Quoted 9 lines

[...]

Quoted 3 lines

* RX/TX: The app reads packets from/writes packets to the "soft" port instead of the "hard" port. The RX and TX queues of the "soft" port are thread safe, as any ethdev.

"thread safe as any ethdev"?
I would say the ethdev queues are not thread safe.

[...]

Yes, per the Dublin presentation, the thread safety mentioned here is between the Soft NIC thread and the application thread(s).

Quoted 16 lines
Quoted 2 lines

* Meets the NFV vision: The app should be (almost) agnostic about the NIC implementation (different vendors/models, HW-SW mix), the app should

not

Quoted 4 lines

require changes to use different NICs, the app should use the same API for all NICs. If a NIC does not implement a specific feature, the HW should be augmented with SW to meet the functionality while still preserving the same API.

This goal could also be achieved by adding the SW capability to the API. After getting capabilities of a hardware, the app could set the capability of some driver features to "SW fallback".
So the capability would become a tristate:
- not supported
- HW supported
- SW supported

Quoted 4 lines

The unique API goal is failed if we must manage two ports, the HW port for some features and the softnic port for other features. You explain it in A5 below.

Yes, agree that 2-device solution is not fully meeting this goal, but IMHO this is the best we can do today; hopefully we can come up with a path forward for the single-device solution.

Quoted 11 lines

[...]

Quoted 3 lines

Example: Create "soft" port for "hard" port "0000:04:00.1", enable the TM feature with default settings:

          --vdev 'net_softnic0,hard_name=0000:04:00.1,soft_tm=on'

So the app will use only the vdev net_softnic0 which will forward packets to 0000:04:00.1?
Can we say in this example that net_softnic0 owns 0000:04:00.1? Probably not, because the config of the HW must be done separately (cf. Q5).
See my "ownership proposal":

Quoted 7 lines
	http://dpdk.org/ml/archives/dev/2017-September/074656.html

The issue I see in this example is that we must define how to enable every features. It should be equivalent to defining the ethdev capabilities. In this example, the option soft_tm=on is probably not enough fine-grain. We could support some parts of TM API in HW and other parts in SW.

There are optional parameters for each feature (i.e. only TM at this point) that are left on their default value for this simple example; they can easily be added on the command line for fine grained tuning of each feature.

Quoted 15 lines

[...]

Quoted 4 lines

Q3: Why not change the "hard" device (and keep a single device) instead of
creating a new "soft" device (and thus having two devices)?
A3: This is not possible with the current librte_ether ethdev

    implementation. The ethdev->dev_ops are defined as constant

structure,

Quoted 8 lines

so it cannot be changed per device (nor per PMD). The new ops also need memory space to store their context data structures, which requires updating the ethdev->data->dev_private of the existing device; at best, maybe a resize of ethdev->data->dev_private could be done, assuming that librte_ether will introduce a way to find out its size, but this cannot be done while device is running. Other side effects might exist, as the changes are very intrusive, plus it likely needs more changes in librte_ether.

Quoted 2 lines

Q3 is about calling SW fallback from the driver code, right?

Yes, correct, but the answer is applicable to the Q4 as well.

Quoted 5 lines

We must not implement fallbacks in drivers because it would hide it to the application.
If a feature is not available in hardware, the application can choose to bypass this feature or integrate the fallback in its own workflow.

I agree.

Quoted 17 lines
Quoted 8 lines

Q4: Why not call the SW fall-back dev_ops directly in librte_ether for
devices which do not support the specific feature? If the device supports the capability, let's call its dev_ops, otherwise call the SW fall-back dev_ops.
A4: First, similar reasons to Q&A3. This fixes the need to change
ethdev->dev_ops of the device, but it does not do anything to fix the other significant issue of where to store the context data structures needed by the SW fall-back functions (which, in this approach, are

Quoted 8 lines

called implicitly by librte_ether).
Second, the SW fall-back options should not be restricted arbitrarily by the librte_ether library, the decision should belong to the app. For example, the TM SW fall-back should not be limited to only librte_sched, which (like any SW fall-back) is limited to a specific hierarchy and feature set, it cannot do any possible hierarchy. If alternatives exist, the one to use should be picked by the app, not by the ethdev layer.

Quoted 2 lines

Q4 is about calling SW callback from the API glue code, right?

Yes.

Quoted 8 lines

We could summarize Q3/Q4 as "it could be done but we propose another way".
I think we must consider the pros and cons of both approaches from a user perspective.
I agree the application must decide which fallback to use. We could propose one fallback in ethdev which can be enabled explicitly (see my tristate capabilities proposal above).

My summary would be: it would be great to do it this way, but significant road blocks exist that need to be lifted first.

Quoted 17 lines
Quoted 8 lines

Q5: Why is the app required to continue to configure both the "hard" and
the "soft" devices even after the "soft" device has been created? Why not hiding the "hard" device under the "soft" device and have the "soft" device configure the "hard" device under the hood?
A5: This was the approach tried in the V2 of this patch set (overlay
"soft" device taking over the configuration of the underlay "hard" device) and eventually dropped due to increased complexity of having to keep the configuration of two distinct devices in sync with

Quoted 8 lines

librte_ether implementation that is not friendly towards such approach. Basically, each ethdev API call for the overlay device needs to configure the overlay device, invoke the same configuration with possibly modified parameters for the underlay device, then resume the configuration of overlay device, turning this into a device emulation project.
V2 minuses: increased complexity (deal with two devices at same time); need to implement every ethdev API, even those not needed for the

scope

Quoted 9 lines
Quoted 6 lines

of SW fall-back; intrusive; sometimes have to silently take decisions that should be left to the app.
V3 pluses: lower complexity (only one device); only need to implement those APIs that are in scope of the SW fall-back; non-intrusive (deal with "hard" device through ethdev API); app decisions taken by the app in an explicit way.

I think it is breaking what you call the NFV vision in several places.

Personally, I also agree with you here.

Quoted 11 lines

[...]

Quoted 6 lines

9. [rte_ring proliferation] Thread safety requirements for ethdev RX/TXqueues require an rte_ring to be used for every RX/TX queue of each "soft" ethdev. This rte_ring proliferation unnecessarily increases the memory footprint and lowers performance, especially when each "soft" ethdev ends up on a different CPU core (ping-pong of cache lines).

I am curious to understand why you consider thread safety as a requirement for queues. No need to reply here, the question is already asked at the beginning of this email ;)

Regards,
Cristian

#61 lore raw

Re: [PATCH v4 0/4] net/softnic: sw fall-back pmd for traffic mgmt and others

06/10/2017 12:40, Dumitrescu, Cristian:

Quoted 32 lines

From: Thomas Monjalon [mailto:[email protected]]

Quoted 4 lines

18/09/2017 11:10, Jasvinder Singh:

Quoted 2 lines

The SoftNIC PMD is intended to provide SW fall-back options for specific ethdev APIs in a generic way to the NICs not supporting those features.

Quoted 9 lines

I agree it is important to have a solution in DPDK to better manage SW fallbacks. One question is to know whether we can implement and maintain many solutions. We probably must choose only one solution.

I have not read the code. I am just interested in the design for now. I think it is a smart idea but maybe less convenient than calling fallback from ethdev API glue code. My opinion has not changed since v1. Thanks for the detailed explanations. Let's discuss below.

Don't understand me wrong, I would also like to have the single device solution (hard NIC augmented with SW-implemented features) as opposed to the current proposal, which requires two devices (hard device and soft device acting as app front-end for the hard device).

The problem is that right now the single device solution is not an option with the current librte_ether, as there simply a lot of changes required that need more time to think through and get agreement, and likely several incremental stages are required to make it happen. As detailed in the Dublin presentation, they mostly refer to:
- the need of the SW fall-back to maintain its owns data structures and functions (per device, per RX queue, per TX queue)
- coexistence of all the features together
- how to bind an ethdev to one (or several) SW threads
- thread safety requirements between ethdev SW thread and app threads

Per our Dublin discussion, here is my proposal:
1. Get Soft NIC PMD into release 17.11.
a) It is the imperfect 2-device solution, but it works and provides an interim solution.
b) It allows us to make progress on the development for a few key features such as traffic management (on TX) and hopefully flow & metering (on RX) and get feedback on this code that we can later restructure into the final single-device solution.
c) It is purely yet another PMD which we can melt away into the final solution later.
2. Start an RFC on librte_ether required changes to get the single-device solution in place.
a) I can spend some time to summarize the objectives, requirements, current issues and potential approaches and send the first draft of this RFC in the next week or two?
b) We can then discuss, poll for more ideas and hopefully draft an incremental path forward

Quoted 1 line

What do you think?

I think temporary solutions (which often become definitive) must be avoided, especially when it implies new API.
In the case of softnic, there is no new API really, just a new workflow for applications and some new driver parameters.
So my conclusion is that we should merge and experience it.
It does not prevent from working on another solution, as you suggest.

PS: thank you for having given your opinion on other questions

#62 lore raw

PATCH v3 2/4 net/softnic: add traffic management support

In reply to Jasvinder Singh

Add ethdev Traffic Management API support to SoftNIC PMD.

---
v3 changes:
- add more confguration parameters (tm rate, tm queue sizes)

 drivers/net/softnic/Makefile                    |   1 +
 drivers/net/softnic/rte_eth_softnic.c           | 252 +++++++++++++++++++++++-
 drivers/net/softnic/rte_eth_softnic.h           |  16 ++
 drivers/net/softnic/rte_eth_softnic_internals.h | 106 +++++++++-
 drivers/net/softnic/rte_eth_softnic_tm.c        | 180 +++++++++++++++++
 5 files changed, 552 insertions(+), 3 deletions(-)
 create mode 100644 drivers/net/softnic/rte_eth_softnic_tm.c
drivers/net/softnic/Makefile +1 -0
index 8d00656..eea76ca 100644
@@ -47,6 +47,7 @@ LIBABIVER := 1
 # all source are stored in SRCS-y
 #
 SRCS-$(CONFIG_RTE_LIBRTE_PMD_SOFTNIC) += rte_eth_softnic.c
+SRCS-$(CONFIG_RTE_LIBRTE_PMD_SOFTNIC) += rte_eth_softnic_tm.c
 
 #
 # Export include files
drivers/net/softnic/rte_eth_softnic.c +250 -2

339 lines not on this page · raw message

drivers/net/softnic/rte_eth_softnic.h +16 -0
index f840345..4388dc5 100644
@@ -40,6 +40,22 @@
 extern "C" {
 #endif
 
+#ifndef SOFTNIC_SOFT_TM_NB_QUEUES
+#define SOFTNIC_SOFT_TM_NB_QUEUES			65536
+#endif
+
+#ifndef SOFTNIC_SOFT_TM_QUEUE_SIZE
+#define SOFTNIC_SOFT_TM_QUEUE_SIZE			64
+#endif
+
+#ifndef SOFTNIC_SOFT_TM_ENQ_BSZ
+#define SOFTNIC_SOFT_TM_ENQ_BSZ				32
+#endif
+
+#ifndef SOFTNIC_SOFT_TM_DEQ_BSZ
+#define SOFTNIC_SOFT_TM_DEQ_BSZ				24
+#endif
+
 #ifndef SOFTNIC_HARD_TX_QUEUE_ID
 #define SOFTNIC_HARD_TX_QUEUE_ID			0
 #endif
drivers/net/softnic/rte_eth_softnic_internals.h +105 -1

144 lines not on this page · raw message

drivers/net/softnic/rte_eth_softnic_tm.c new file +180 -0

180 lines not on this page · raw message

Signature · 1 line
2.9.3
#63 lore raw

PATCH v3 3/4 net/softnic: add TM capabilities ops

In reply to Jasvinder Singh

Implement ethdev TM capability APIs in SoftNIC PMD.

---
 drivers/net/softnic/rte_eth_softnic.c           |  12 +-
 drivers/net/softnic/rte_eth_softnic_internals.h |  32 ++
 drivers/net/softnic/rte_eth_softnic_tm.c        | 500 ++++++++++++++++++++++++
 3 files changed, 543 insertions(+), 1 deletion(-)
drivers/net/softnic/rte_eth_softnic.c +11 -1
index f1906af..f113f32 100644
@@ -43,6 +43,7 @@
 #include <rte_errno.h>
 #include <rte_ring.h>
 #include <rte_sched.h>
+#include <rte_tm_driver.h>
 
 #include "rte_eth_softnic.h"
 #include "rte_eth_softnic_internals.h"
@@ -225,6 +226,15 @@ pmd_link_update(struct rte_eth_dev *dev __rte_unused,
 	return 0;
 }
 
+static int
+pmd_tm_ops_get(struct rte_eth_dev *dev, void *arg)
+{
+	*(const struct rte_tm_ops **)arg =
+		(tm_enabled(dev)) ? &pmd_tm_ops : NULL;
+
+	return 0;
+}
+
 static const struct eth_dev_ops pmd_ops = {
 	.dev_configure = pmd_dev_configure,
 	.dev_start = pmd_dev_start,
@@ -234,7 +244,7 @@ static const struct eth_dev_ops pmd_ops = {
 	.dev_infos_get = pmd_dev_infos_get,
 	.rx_queue_setup = pmd_rx_queue_setup,
 	.tx_queue_setup = pmd_tx_queue_setup,
-	.tm_ops_get = NULL,
+	.tm_ops_get = pmd_tm_ops_get,
 };
 
 static uint16_t
drivers/net/softnic/rte_eth_softnic_internals.h +32 -0
index c3c41cc..a43aef9 100644
@@ -39,6 +39,7 @@
 #include <rte_mbuf.h>
 #include <rte_sched.h>
 #include <rte_ethdev.h>
+#include <rte_tm_driver.h>
 
 #include "rte_eth_softnic.h"
 
@@ -137,8 +138,26 @@ enum tm_node_level {
 	TM_NODE_LEVEL_MAX,
 };
 
+/* TM Node */
+struct tm_node {
+	TAILQ_ENTRY(tm_node) node;
+	uint32_t node_id;
+	uint32_t parent_node_id;
+	uint32_t priority;
+	uint32_t weight;
+	uint32_t level;
+	struct tm_node *parent_node;
+	struct rte_tm_node_params params;
+	struct rte_tm_node_stats stats;
+	uint32_t n_children;
+};
+
+TAILQ_HEAD(tm_node_list, tm_node);
+
 /* TM Hierarchy Specification */
 struct tm_hierarchy {
+	struct tm_node_list nodes;
+
 	uint32_t n_tm_nodes[TM_NODE_LEVEL_MAX];
 };
 
@@ -191,6 +210,11 @@ struct pmd_rx_queue {
 	} hard;
 };
 
+/**
+ * Traffic Management (TM) Operation
+ */
+extern const struct rte_tm_ops pmd_tm_ops;
+
 int
 tm_params_check(struct pmd_params *params, uint32_t hard_rate);
 
@@ -207,6 +231,14 @@ void
 tm_stop(struct pmd_internals *p);
 
 static inline int
+tm_enabled(struct rte_eth_dev *dev)
+{
+	struct pmd_internals *p = dev->data->dev_private;
+
+	return (p->params.soft.flags & PMD_FEATURE_TM);
+}
+
+static inline int
 tm_used(struct rte_eth_dev *dev)
 {
 	struct pmd_internals *p = dev->data->dev_private;
drivers/net/softnic/rte_eth_softnic_tm.c +500 -0

503 lines not on this page · raw message

Signature · 1 line
2.9.3
#64 lore raw

PATCH v3 4/4 net/softnic: add TM hierarchy related ops

In reply to Jasvinder Singh

Implement ethdev TM hierarchy related APIs in SoftNIC PMD.

---
v3 changes:
- add dynamnic update ops, tm stats ops
- add wred congestion mangement ops
- imporve hierarchy commit ops implementation
- add more checks to all the ops

v2 changes:
- add TM functions for hierarchical QoS scheduler

 drivers/net/softnic/rte_eth_softnic_internals.h |   41 +
 drivers/net/softnic/rte_eth_softnic_tm.c        | 2774 ++++++++++++++++++++++-
 2 files changed, 2811 insertions(+), 4 deletions(-)
drivers/net/softnic/rte_eth_softnic_internals.h +41 -0
index a43aef9..4c3cac8 100644
@@ -138,6 +138,36 @@ enum tm_node_level {
 	TM_NODE_LEVEL_MAX,
 };
 
+/* TM Shaper Profile */
+struct tm_shaper_profile {
+	TAILQ_ENTRY(tm_shaper_profile) node;
+	uint32_t shaper_profile_id;
+	uint32_t n_users;
+	struct rte_tm_shaper_params params;
+};
+
+TAILQ_HEAD(tm_shaper_profile_list, tm_shaper_profile);
+
+/* TM Shared Shaper */
+struct tm_shared_shaper {
+	TAILQ_ENTRY(tm_shared_shaper) node;
+	uint32_t shared_shaper_id;
+	uint32_t n_users;
+	uint32_t shaper_profile_id;
+};
+
+TAILQ_HEAD(tm_shared_shaper_list, tm_shared_shaper);
+
+/* TM WRED Profile */
+struct tm_wred_profile {
+	TAILQ_ENTRY(tm_wred_profile) node;
+	uint32_t wred_profile_id;
+	uint32_t n_users;
+	struct rte_tm_wred_params params;
+};
+
+TAILQ_HEAD(tm_wred_profile_list, tm_wred_profile);
+
 /* TM Node */
 struct tm_node {
 	TAILQ_ENTRY(tm_node) node;
@@ -147,6 +177,8 @@ struct tm_node {
 	uint32_t weight;
 	uint32_t level;
 	struct tm_node *parent_node;
+	struct tm_shaper_profile *shaper_profile;
+	struct tm_wred_profile *wred_profile;
 	struct rte_tm_node_params params;
 	struct rte_tm_node_stats stats;
 	uint32_t n_children;
@@ -156,8 +188,16 @@ TAILQ_HEAD(tm_node_list, tm_node);
 
 /* TM Hierarchy Specification */
 struct tm_hierarchy {
+	struct tm_shaper_profile_list shaper_profiles;
+	struct tm_shared_shaper_list shared_shapers;
+	struct tm_wred_profile_list wred_profiles;
 	struct tm_node_list nodes;
 
+	uint32_t n_shaper_profiles;
+	uint32_t n_shared_shapers;
+	uint32_t n_wred_profiles;
+	uint32_t n_nodes;
+
 	uint32_t n_tm_nodes[TM_NODE_LEVEL_MAX];
 };
 
@@ -170,6 +210,7 @@ struct tm_internals {
 	 *      sense to keep the hierarchy frozen after the port is started.
 	 */
 	struct tm_hierarchy h;
+	int hierarchy_frozen;
 
 	/** Blueprints */
 	struct tm_params params;
drivers/net/softnic/rte_eth_softnic_tm.c +2770 -4

2,820 lines not on this page · raw message

Signature · 1 line
2.9.3
#65 lore raw

Re: [PATCH v3 0/4] net/softnic: sw fall-back pmd for traffic mgmt and others

In reply to Jasvinder Singh
Quoted 206 lines

-----Original Message-----
From: Singh, Jasvinder
Sent: Friday, August 11, 2017 1:49 PM
To: [email protected]
Cc: Dumitrescu, Cristian <[email protected]>; Yigit, Ferruh <[email protected]>; [email protected]
Subject: [PATCH v3 0/4] net/softnic: sw fall-back pmd for traffic mgmt and others

The SoftNIC PMD is intended to provide SW fall-back options for specific ethdev APIs in a generic way to the NICs not supporting those features.

Currently, the only implemented ethdev API is Traffic Management (TM), but other ethdev APIs such as rte_flow, traffic metering & policing, etc can be easily implemented.

Overview:
* Generic: The SoftNIC PMD works with any "hard" PMD that implements the
ethdev API. It does not change the "hard" PMD in any way.
* Creation: For any given "hard" ethdev port, the user can decide to create an associated "soft" ethdev port to drive the "hard" port. The "soft" port is a virtual device that can be created at app start-up through EAL vdev arg or later through the virtual device API.
* Configuration: The app explicitly decides which features are to be enabled on the "soft" port and which features are still to be used from the "hard" port. The app continues to explicitly configure both the "hard" and the "soft" ports after the creation of the "soft" port.
* RX/TX: The app reads packets from/writes packets to the "soft" port instead of the "hard" port. The RX and TX queues of the "soft" port are thread safe, as any ethdev.
* Execution: The "soft" port is a feature-rich NIC implemented by the CPU, so the run function of the "soft" port has to be executed by the CPU in order to get packets moving between "hard" port and the app.
* Meets the NFV vision: The app should be (almost) agnostic about the NIC implementation (different vendors/models, HW-SW mix), the app should
not
require changes to use different NICs, the app should use the same API for all NICs. If a NIC does not implement a specific feature, the HW should be augmented with SW to meet the functionality while still preserving the same API.

Traffic Management SW fall-back overview:
* Implements the ethdev traffic management API (rte_tm.h).
* Based on the existing librte_sched DPDK library.

Example: Create "soft" port for "hard" port "0000:04:00.1", enable the TM feature with default settings:

          --vdev 'net_softnic0,hard_name=0000:04:00.1,soft_tm=on'

Q1: Why generic name, if only TM is supported (for now)?
A1: The intention is to have SoftNIC PMD implement many other (all?)
ethdev APIs under a single "ideal" ethdev, hence the generic name. The initial motivation is TM API, but the mechanism is generic and can be used for many other ethdev APIs. Somebody looking to provide SW fall-back for other ethdev API is likely to end up inventing the same, hence it would be good to consolidate all under a single PMD and have the user explicitly enable/disable the features it needs for each "soft" device.

Q2: Are there any performance requirements for SoftNIC?
A2: Yes, performance should be great/decent for every feature, otherwise
the SW fall-back is unusable, thus useless.

Q3: Why not change the "hard" device (and keep a single device) instead of
creating a new "soft" device (and thus having two devices)?
A3: This is not possible with the current librte_ether ethdev
implementation. The ethdev->dev_ops are defined as constant structure, so it cannot be changed per device (nor per PMD). The new ops also need memory space to store their context data structures, which requires updating the ethdev->data->dev_private of the existing device; at best, maybe a resize of ethdev->data->dev_private could be done, assuming that librte_ether will introduce a way to find out its size, but this cannot be done while device is running. Other side effects might exist, as the changes are very intrusive, plus it likely needs more changes in librte_ether.

Q4: Why not call the SW fall-back dev_ops directly in librte_ether for
devices which do not support the specific feature? If the device supports the capability, let's call its dev_ops, otherwise call the SW fall-back dev_ops.
A4: First, similar reasons to Q&A3. This fixes the need to change
ethdev->dev_ops of the device, but it does not do anything to fix the other significant issue of where to store the context data structures needed by the SW fall-back functions (which, in this approach, are called implicitly by librte_ether).
Second, the SW fall-back options should not be restricted arbitrarily by the librte_ether library, the decision should belong to the app. For example, the TM SW fall-back should not be limited to only librte_sched, which (like any SW fall-back) is limited to a specific hierarchy and feature set, it cannot do any possible hierarchy. If alternatives exist, the one to use should be picked by the app, not by the ethdev layer.

Q5: Why is the app required to continue to configure both the "hard" and
the "soft" devices even after the "soft" device has been created? Why not hiding the "hard" device under the "soft" device and have the "soft" device configure the "hard" device under the hood?
A5: This was the approach tried in the V2 of this patch set (overlay
"soft" device taking over the configuration of the underlay "hard" device) and eventually dropped due to increased complexity of having to keep the configuration of two distinct devices in sync with librte_ether implementation that is not friendly towards such approach. Basically, each ethdev API call for the overlay device needs to configure the overlay device, invoke the same configuration with possibly modified parameters for the underlay device, then resume the configuration of overlay device, turning this into a device emulation project.
V2 minuses: increased complexity (deal with two devices at same time); need to implement every ethdev API, even those not needed for the
scope
of SW fall-back; intrusive; sometimes have to silently take decisions that should be left to the app.
V3 pluses: lower complexity (only one device); only need to implement those APIs that are in scope of the SW fall-back; non-intrusive (deal with "hard" device through ethdev API); app decisions taken by the app in an explicit way.

Q6: Why expose the SW fall-back in a PMD and not in a SW library?
A6: The SW fall-back for an ethdev API has to implement that specific
ethdev API, (hence expose an ethdev object through a PMD), as opposed to providing a different API. This approach allows the app to use the same API (NFV vision). For example, we already have a library for TM SW fall-back (librte_sched) that can be called directly by the apps that need to call it outside of ethdev context (use-cases exist), but an app that works with TM-aware NICs through the ethdev TM API would have to be changed significantly in order to work with different TM-agnostic NICs through the librte_sched API.

Q7: Why have all the SW fall-backs in a single PMD? Why not develop
the SW fall-back for each different ethdev API in a separate PMD, then create a chain of "soft" devices for each "hard" device? Potentially, this results in smaller size PMDs that are easier to maintain.
A7: Arguments for single ethdev/PMD and against chain of ethdevs/PMDs:
1. All the existing PMDs for HW NICs implement a lot of features under the same PMD, so there is no reason for single PMD approach to break code modularity. See the V3 code, a lot of care has been taken for code modularity.
2. We should avoid the proliferation of SW PMDs.
3. A single device should be handled by a single PMD.
4. People are used with feature-rich PMDs, not with single-feature PMDs, so we change of mindset?
5. [Configuration nightmare] A chain of "soft" devices attached to single "hard" device requires the app to be aware that the N "soft" devices in the chain plus the "hard" device refer to the same HW device, and which device should be invoked to configure which feature. Also the length of the chain and functionality of each link is different for each HW device. This breaks the requirement of preserving the same API while working with different NICs (NFV). This most likely results in a configuration nightmare, nobody is going to seriously use this.
6. [Feature inter-dependecy] Sometimes different features need to be configured and executed together (e.g. share the same set of resources, are inter-dependent, etc), so it is better and more performant to do them in the same ethdev/PMD.
7. [Code duplication] There is a lot of duplication in the configuration code for the chain of ethdevs approach. The ethdev dev_configure, rx_queue_setup, tx_queue_setup API functions have to be implemented per device, and they become meaningless/inconsistent with the chain approach.
8. [Data structure duplication] The per device data structures have to be duplicated and read repeatedly for each "soft" ethdev. The ethdev device, dev_private, data, per RX/TX queue data structures have to be replicated per "soft" device. They have to be re-read for each stage, so the same cache misses are now multiplied with the number of stages in the chain.
9. [rte_ring proliferation] Thread safety requirements for ethdev RX/TXqueues require an rte_ring to be used for every RX/TX queue of each "soft" ethdev. This rte_ring proliferation unnecessarily increases the memory footprint and lowers performance, especially when each "soft" ethdev ends up on a different CPU core (ping-pong of cache lines).
10.[Meta-data proliferation] A chain of ethdevs is likely to result
in proliferation of meta-data that has to be passed between the ethdevs (e.g. policing needs the output of flow classification), which results in more cache line ping-pong between cores, hence performance drops.

Cristian Dumitrescu (4):
Jasvinder Singh (4):
net/softnic: add softnic PMD
net/softnic: add traffic management support
net/softnic: add TM capabilities ops
net/softnic: add TM hierarchy related ops

 MAINTAINERS                                     |    5 +
 config/common_base                              |    5 +
 drivers/net/Makefile                            |    5 +
 drivers/net/softnic/Makefile                    |   57 +
 drivers/net/softnic/rte_eth_softnic.c           |  867 ++++++
 drivers/net/softnic/rte_eth_softnic.h           |   70 +
 drivers/net/softnic/rte_eth_softnic_internals.h |  291 ++
 drivers/net/softnic/rte_eth_softnic_tm.c        | 3446
+++++++++++++++++++++++
 drivers/net/softnic/rte_eth_softnic_version.map |    7 +
 mk/rte.app.mk                                   |    5 +-
 10 files changed, 4757 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/softnic/Makefile
 create mode 100644 drivers/net/softnic/rte_eth_softnic.c
 create mode 100644 drivers/net/softnic/rte_eth_softnic.h
 create mode 100644 drivers/net/softnic/rte_eth_softnic_internals.h
 create mode 100644 drivers/net/softnic/rte_eth_softnic_tm.c
 create mode 100644 drivers/net/softnic/rte_eth_softnic_version.map
Quoted 2 lines

--
2.9.3

Ping Thomas and Stephen.

You guys previously had some comments looking to suggest the approach of augmenting the "hard" device as opposed to creating "soft" device for the "hard" device. We tried to address these comments in the Q& A list below (see Q&As 3 and 4).

Have your comments been addressed or do we need to talk more on them?

Thanks,
Cristian

#66 lore raw

PATCH v2 2/2 net/softnic: add traffic management ops

In reply to Jasvinder Singh

The traffic management specific functions of the softnic driver are supplied through set of pointers contained in the generic structure of type 'rte_tm_ops'. These functions help to build and manage the hierarchical QoS scheduler for traffic management.

---
v2 changes:
- add TM functions for hierarchical QoS scheduler

 drivers/net/softnic/Makefile                    |    1 +
 drivers/net/softnic/rte_eth_softnic.c           |   48 +-
 drivers/net/softnic/rte_eth_softnic_internals.h |   81 ++
 drivers/net/softnic/rte_eth_softnic_tm.c        | 1145 +++++++++++++++++++++++
 4 files changed, 1274 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/softnic/rte_eth_softnic_tm.c
drivers/net/softnic/Makefile +1 -0
index 809112c..e59766d 100644
@@ -47,6 +47,7 @@ LIBABIVER := 1
 # all source are stored in SRCS-y
 #
 SRCS-$(CONFIG_RTE_LIBRTE_PMD_SOFTNIC) += rte_eth_softnic.c
+SRCS-$(CONFIG_RTE_LIBRTE_PMD_SOFTNIC) += rte_eth_softnic_tm.c
 SRCS-$(CONFIG_RTE_LIBRTE_PMD_SOFTNIC) += rte_eth_softnic_default.c
 
 #
drivers/net/softnic/rte_eth_softnic.c +47 -1

95 lines not on this page · raw message

drivers/net/softnic/rte_eth_softnic_internals.h +81 -0

100 lines not on this page · raw message

drivers/net/softnic/rte_eth_softnic_tm.c new file +1145 -0

1,145 lines not on this page · raw message

Signature · 1 line
2.9.3
#67 lore raw

PATCH 2/2 net/softnic: add traffic management ops

In reply to Jasvinder Singh

The traffic management specific functions of the softnic driver are supplied through set of pointers contained in the generic structure of type 'rte_tm_ops'. These functions help to build and manage the hierarchical QoS scheduler for traffic management.

---
 drivers/net/softnic/Makefile                    |   1 +
 drivers/net/softnic/rte_eth_softnic.c           |  47 ++++-
 drivers/net/softnic/rte_eth_softnic_internals.h |  26 +++
 drivers/net/softnic/rte_eth_softnic_tm.c        | 235 ++++++++++++++++++++++++
 4 files changed, 307 insertions(+), 2 deletions(-)
 create mode 100644 drivers/net/softnic/rte_eth_softnic_tm.c
drivers/net/softnic/Makefile +1 -0
index c0374fa..e847907 100644
@@ -47,6 +47,7 @@ LIBABIVER := 1
 # all source are stored in SRCS-y
 #
 SRCS-$(CONFIG_RTE_LIBRTE_PMD_SOFTNIC) += rte_eth_softnic.c
+SRCS-$(CONFIG_RTE_LIBRTE_PMD_SOFTNIC) += rte_eth_softnic_tm.c
 SRCS-$(CONFIG_RTE_LIBRTE_PMD_SOFTNIC) += rte_eth_softnic_default.c
 
 #
drivers/net/softnic/rte_eth_softnic.c +45 -2

94 lines not on this page · raw message

drivers/net/softnic/rte_eth_softnic_internals.h +26 -0
index d456a54..2d725b4 100644
@@ -38,9 +38,25 @@
 
 #include <rte_mbuf.h>
 #include <rte_ethdev.h>
+#include <rte_sched.h>
 
 #include "rte_eth_softnic.h"
 
+#ifndef TM_MAX_SUBPORTS
+#define TM_MAX_SUBPORTS					8
+#endif
+
+#ifndef TM_MAX_PIPES_PER_SUBPORT
+#define TM_MAX_PIPES_PER_SUBPORT				4096
+#endif
+
+struct tm_params {
+	struct rte_sched_port_params port_params;
+	struct rte_sched_subport_params subport_params[TM_MAX_SUBPORTS];
+	struct rte_sched_pipe_params pipe_profiles[RTE_SCHED_PIPE_PROFILES_PER_PORT];
+	int pipe_to_profile[TM_MAX_SUBPORTS * TM_MAX_PIPES_PER_SUBPORT];
+};
+
 struct pmd_internals {
 	/* Devices */
 	struct rte_eth_dev *odev;
@@ -54,10 +70,20 @@ struct pmd_internals {
 
 	/* Operation */
 	struct rte_mbuf *pkts[RTE_ETH_SOFTNIC_DEQ_BSZ_MAX];
+	struct tm_params tm_params;
+	struct rte_sched_port *sched;
 	uint32_t deq_bsz;
 	uint32_t txq_id;
 };
 
+extern const struct rte_tm_ops pmd_tm_ops;
+
+int
+tm_init(struct pmd_internals *p);
+
+void
+tm_free(struct pmd_internals *p);
+
 void
 pmd_ops_inherit(struct eth_dev_ops *o, const struct eth_dev_ops *u);
 
drivers/net/softnic/rte_eth_softnic_tm.c new file +235 -0

235 lines not on this page · raw message

Signature · 1 line
2.9.3
#68 lore raw
In reply to Jasvinder Singh

Hi Jasvinder,

26/05/2017 20:11, Jasvinder Singh:

Quoted 2 lines

The SoftNIC PMD provides SW fall-back option for the NICs not supporting the Traffic Management (TM) features.

Do you mean that you want to stack PMDs in order to offer some fallbacks? It means the user needs to instantiate this PMD for each HW which does not support traffic management, instead of normal hardware probing?

Quoted 8 lines

SoftNIC PMD overview:
- The SW fall-back is based on the existing librte_sched DPDK library.
- The TM-agnostic port (the underlay device) is wrapped into a TM-aware softnic port (the overlay device).
- Once the overlay device (virtual device) is created, the configuration of the underlay device is taking place through the overlay device.
- The SoftNIC PMD is generic, i.e. it works for any underlay device PMD that implements the ethdev API.

Why not calling librte_sched directly in ethdev for PMDs which do not implement hardware offload?
Am I missing something obvious?

#69 lore raw

Hi Thomas,

Thanks for reviewing this patch set!

Quoted 13 lines

-----Original Message-----
From: Thomas Monjalon [mailto:[email protected]]
Sent: Wednesday, June 7, 2017 3:32 PM
To: Singh, Jasvinder <[email protected]>
Cc: [email protected]; Dumitrescu, Cristian <[email protected]>; Yigit, Ferruh <[email protected]>; [email protected]; [email protected]; Lu, Wenzhuo <[email protected]>
Subject: Re: [dpdk-dev] [PATCH 0/2] net/softnic: sw fall-back for traffic management

Hi Jasvinder,

Quoted 8 lines

26/05/2017 20:11, Jasvinder Singh:

Quoted 2 lines

The SoftNIC PMD provides SW fall-back option for the NICs not supporting the Traffic Management (TM) features.

Do you mean that you want to stack PMDs in order to offer some fallbacks? It means the user needs to instantiate this PMD for each HW which does not support traffic management, instead of normal hardware probing?

No, the normal HW probing still takes place for the HW device. Then if QoS "probing" fails, the user can decide to create a new virtual device on top of the HW device.

Quoted 9 lines
Quoted 8 lines

SoftNIC PMD overview:
- The SW fall-back is based on the existing librte_sched DPDK library.
- The TM-agnostic port (the underlay device) is wrapped into a TM-aware softnic port (the overlay device).
- Once the overlay device (virtual device) is created, the configuration of the underlay device is taking place through the overlay device.
- The SoftNIC PMD is generic, i.e. it works for any underlay device PMD that implements the ethdev API.

Quoted 3 lines

Why not calling librte_sched directly in ethdev for PMDs which do not implement hardware offload?
Am I missing something obvious?

Yes, we are calling the librte_sched in ethdev, but how else can we do it?
- We cannot change the ethdev ops of the HW device PMD because same might be used by other HW devices in the system where TM feature is not required.
- We cannot change the ethdev ops of the current HW device, as on-the-fly changes of the ops structure are not allowed, right?
- We can create a new virtual device on top of existing HW device to inherit most of the ethdev ops of the HW device and patch some specific ethdev ops with librte_sched.

IMHO there aren't two different ways to do this.

Regards,
Cristian

#70 lore raw

08/06/2017 15:27, Dumitrescu, Cristian:

Quoted 12 lines

Hi Thomas,

Thanks for reviewing this patch set!

From: Thomas Monjalon [mailto:[email protected]]

Quoted 7 lines

Hi Jasvinder,

26/05/2017 20:11, Jasvinder Singh:

Quoted 2 lines

The SoftNIC PMD provides SW fall-back option for the NICs not supporting the Traffic Management (TM) features.

Quoted 6 lines
Quoted 4 lines

Do you mean that you want to stack PMDs in order to offer some fallbacks? It means the user needs to instantiate this PMD for each HW which does not support traffic management, instead of normal hardware probing?

No, the normal HW probing still takes place for the HW device. Then if QoS "probing" fails, the user can decide to create a new virtual device on top of the HW device.

What do you mean by "QoS probing"?

Quoted 9 lines
Quoted 9 lines
Quoted 8 lines

SoftNIC PMD overview:
- The SW fall-back is based on the existing librte_sched DPDK library.
- The TM-agnostic port (the underlay device) is wrapped into a TM-aware softnic port (the overlay device).
- Once the overlay device (virtual device) is created, the configuration of the underlay device is taking place through the overlay device.
- The SoftNIC PMD is generic, i.e. it works for any underlay device PMD that implements the ethdev API.

Quoted 5 lines
Quoted 3 lines

Why not calling librte_sched directly in ethdev for PMDs which do not implement hardware offload?
Am I missing something obvious?

Yes, we are calling the librte_sched in ethdev, but how else can we do it?

If you call librte_sched from ethdev, that's fine. We don't need more, do we?

Quoted 2 lines

- We cannot change the ethdev ops of the HW device PMD because same might be used by other HW devices in the system where TM feature is not required.
- We cannot change the ethdev ops of the current HW device, as on-the-fly changes of the ops structure are not allowed, right?

Right

Quoted 3 lines

- We can create a new virtual device on top of existing HW device to inherit most of the ethdev ops of the HW device and patch some specific ethdev ops with librte_sched.

IMHO there aren't two different ways to do this.

When initializing a HW device, it can (should) reports its TM capabilities. Then ethdev can decide to use a SW fallback if a capability is missing.

#71 lore raw
Quoted 33 lines

-----Original Message-----
From: Thomas Monjalon [mailto:[email protected]]
Sent: Thursday, June 8, 2017 3:00 PM
To: Dumitrescu, Cristian <[email protected]>
Cc: Singh, Jasvinder <[email protected]>; [email protected]; Yigit, Ferruh <[email protected]>; [email protected]; [email protected]; Lu, Wenzhuo <[email protected]>
Subject: Re: [dpdk-dev] [PATCH 0/2] net/softnic: sw fall-back for traffic management

08/06/2017 15:27, Dumitrescu, Cristian:

Quoted 10 lines

Hi Thomas,

Thanks for reviewing this patch set!

From: Thomas Monjalon [mailto:[email protected]]

Quoted 5 lines

Hi Jasvinder,

26/05/2017 20:11, Jasvinder Singh:

Quoted 1 line

The SoftNIC PMD provides SW fall-back option for the NICs not

supporting

Quoted 3 lines
Quoted 3 lines
Quoted 1 line

the Traffic Management (TM) features.

Do you mean that you want to stack PMDs in order to offer some

fallbacks?

Quoted 4 lines
Quoted 3 lines

It means the user needs to instantiate this PMD for each HW which does not support traffic management, instead of normal hardware probing?

Quoted 5 lines
Quoted 1 line

No, the normal HW probing still takes place for the HW device. Then if QoS

"probing" fails, the user can decide to create a new virtual device on top of the HW device.

What do you mean by "QoS probing"?

Check if the hierarchy specified by the user can be met by the HW device.

Quoted 13 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

SoftNIC PMD overview:
- The SW fall-back is based on the existing librte_sched DPDK library.
- The TM-agnostic port (the underlay device) is wrapped into a TM-

aware

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

softnic port (the overlay device).
- Once the overlay device (virtual device) is created, the configuration

of

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

the underlay device is taking place through the overlay device.
- The SoftNIC PMD is generic, i.e. it works for any underlay device PMD

that

Quoted 2 lines
Quoted 2 lines
Quoted 1 line

implements the ethdev API.

Quoted 9 lines
Quoted 5 lines
Quoted 3 lines

Why not calling librte_sched directly in ethdev for PMDs which do not implement hardware offload?
Am I missing something obvious?

Yes, we are calling the librte_sched in ethdev, but how else can we do it?

If you call librte_sched from ethdev, that's fine. We don't need more, do we?

We also need to make sure the other non-patched functionality is working as provided by the underlying HW device. E.g. we patch TX to enable TM, but we don't patch RX and RX should still be working.

Quoted 8 lines
Quoted 1 line

- We cannot change the ethdev ops of the HW device PMD because

same might be used by other HW devices in the system where TM feature is not required.

Quoted 1 line

- We cannot change the ethdev ops of the current HW device, as on-

the-fly changes of the ops structure are not allowed, right?

Right

Quoted 8 lines
Quoted 1 line

- We can create a new virtual device on top of existing HW device to

inherit most of the ethdev ops of the HW device and patch some specific ethdev ops with librte_sched.

Quoted 2 lines

IMHO there aren't two different ways to do this.

When initializing a HW device, it can (should) reports its TM capabilities. Then ethdev can decide to use a SW fallback if a capability is missing.

Unfortunately, having the ethdev taking this decision is not possible with the current librte_ether, as this means the changing the ethdev ops on the fly, which you also agreed is currently not allowed.

This is why we have to leave this decision to the application, which creates the virtual device on top of the existing HW when it wants the SW fall-back to be enabled.

#72 lore raw

08/06/2017 17:27, Dumitrescu, Cristian:

Quoted 66 lines

From: Thomas Monjalon [mailto:[email protected]]

Quoted 20 lines

08/06/2017 15:27, Dumitrescu, Cristian:

Quoted 10 lines

Hi Thomas,

Thanks for reviewing this patch set!

From: Thomas Monjalon [mailto:[email protected]]

Quoted 5 lines

Hi Jasvinder,

26/05/2017 20:11, Jasvinder Singh:

Quoted 1 line

The SoftNIC PMD provides SW fall-back option for the NICs not

supporting

Quoted 3 lines
Quoted 3 lines
Quoted 1 line

the Traffic Management (TM) features.

Do you mean that you want to stack PMDs in order to offer some

fallbacks?

Quoted 4 lines
Quoted 3 lines

It means the user needs to instantiate this PMD for each HW which does not support traffic management, instead of normal hardware probing?

Quoted 5 lines
Quoted 1 line

No, the normal HW probing still takes place for the HW device. Then if QoS

"probing" fails, the user can decide to create a new virtual device on top of the HW device.

What do you mean by "QoS probing"?

Check if the hierarchy specified by the user can be met by the HW device.

Quoted 13 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

SoftNIC PMD overview:
- The SW fall-back is based on the existing librte_sched DPDK library.
- The TM-agnostic port (the underlay device) is wrapped into a TM-

aware

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

softnic port (the overlay device).
- Once the overlay device (virtual device) is created, the configuration

of

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

the underlay device is taking place through the overlay device.
- The SoftNIC PMD is generic, i.e. it works for any underlay device PMD

that

Quoted 2 lines
Quoted 2 lines
Quoted 1 line

implements the ethdev API.

Quoted 9 lines
Quoted 5 lines
Quoted 3 lines

Why not calling librte_sched directly in ethdev for PMDs which do not implement hardware offload?
Am I missing something obvious?

Yes, we are calling the librte_sched in ethdev, but how else can we do it?

If you call librte_sched from ethdev, that's fine. We don't need more, do we?

We also need to make sure the other non-patched functionality is working as provided by the underlying HW device. E.g. we patch TX to enable TM, but we don't patch RX and RX should still be working.

Quoted 12 lines
Quoted 1 line

- We cannot change the ethdev ops of the HW device PMD because

same might be used by other HW devices in the system where TM feature is not required.

Quoted 1 line

- We cannot change the ethdev ops of the current HW device, as on-

the-fly changes of the ops structure are not allowed, right?

Right

Quoted 1 line

- We can create a new virtual device on top of existing HW device to

inherit most of the ethdev ops of the HW device and patch some specific ethdev ops with librte_sched.

Quoted 1 line
Quoted 6 lines
Quoted 4 lines
Quoted 1 line

IMHO there aren't two different ways to do this.

When initializing a HW device, it can (should) reports its TM capabilities. Then ethdev can decide to use a SW fallback if a capability is missing.

Unfortunately, having the ethdev taking this decision is not possible with the current librte_ether, as this means the changing the ethdev ops on the fly, which you also agreed is currently not allowed.

I'm sure I'm missing something.
In my understanding, we do not need to change the ops:
- if the device offers the capability, let's call the ops
- else call the software fallback function

Quoted 1 line

This is why we have to leave this decision to the application, which creates the virtual device on top of the existing HW when it wants the SW fall-back to be enabled.

#73 lore raw

<snip> ...

Quoted 6 lines

I'm sure I'm missing something.
In my understanding, we do not need to change the ops:
- if the device offers the capability, let's call the ops
- else call the software fallback function

What you might be missing is the observation that the approach you're describing requires changing each and every PMD. The changes are also intrusive: need to change the ops that need the SW fall-back patching, also need to change the private data of each PMD (as assigned to the opaque dev->data->dev_private) to add the context data needed by the patched ops. Therefore, this approach is a no-go.

We are looking for a generic approach that can gracefully and transparently work with any PMD.

#74 lore raw

08/06/2017 18:43, Dumitrescu, Cristian:

Quoted 11 lines

<snip> ...

Quoted 6 lines

I'm sure I'm missing something.
In my understanding, we do not need to change the ops:
- if the device offers the capability, let's call the ops
- else call the software fallback function

What you might be missing is the observation that the approach you're describing requires changing each and every PMD. The changes are also intrusive: need to change the ops that need the SW fall-back patching, also need to change the private data of each PMD (as assigned to the opaque dev->data->dev_private) to add the context data needed by the patched ops. Therefore, this approach is a no-go.

We are looking for a generic approach that can gracefully and transparently work with any PMD.

Nobody is participating in this discussion.
Can we discuss how to proceed in the technical board meeting?

#75 lore raw
Quoted 29 lines

-----Original Message-----
From: Thomas Monjalon [mailto:[email protected]]
Sent: Wednesday, July 5, 2017 12:48 AM
To: Dumitrescu, Cristian <[email protected]>
Cc: [email protected]; Singh, Jasvinder <[email protected]>; Yigit, Ferruh <[email protected]>; [email protected]; [email protected]; Lu, Wenzhuo <[email protected]>; [email protected]
Subject: Re: [dpdk-dev] [PATCH 0/2] net/softnic: sw fall-back for traffic management

08/06/2017 18:43, Dumitrescu, Cristian:

Quoted 9 lines

<snip> ...

Quoted 6 lines

I'm sure I'm missing something.
In my understanding, we do not need to change the ops:
- if the device offers the capability, let's call the ops
- else call the software fallback function

What you might be missing is the observation that the approach you're

describing requires changing each and every PMD. The changes are also
intrusive: need to change the ops that need the SW fall-back patching, also need to change the private data of each PMD (as assigned to the opaque dev->data->dev_private) to add the context data needed by the patched ops. Therefore, this approach is a no-go.

Quoted 1 line
Quoted 5 lines
Quoted 1 line

We are looking for a generic approach that can gracefully and transparently

work with any PMD.

Nobody is participating in this discussion.
Can we discuss how to proceed in the technical board meeting?

Hi Thomas,

We are working to finalize a new version of the Soft NIC PMD which has a much simplified/straightforward design (we'll explain in the cover letter). We expect to send it in the next few days, hopefully we can target RC2.

I propose you take another look at this version and then decide if we need TB involvement or not?

Regards,
Cristian

#76 lore raw

05/07/2017 11:32, Dumitrescu, Cristian:

Quoted 29 lines
Quoted 29 lines

-----Original Message-----
From: Thomas Monjalon [mailto:[email protected]]
Sent: Wednesday, July 5, 2017 12:48 AM
To: Dumitrescu, Cristian <[email protected]>
Cc: [email protected]; Singh, Jasvinder <[email protected]>; Yigit, Ferruh <[email protected]>; [email protected]; [email protected]; Lu, Wenzhuo <[email protected]>; [email protected]
Subject: Re: [dpdk-dev] [PATCH 0/2] net/softnic: sw fall-back for traffic management

08/06/2017 18:43, Dumitrescu, Cristian:

Quoted 9 lines

<snip> ...

Quoted 6 lines

I'm sure I'm missing something.
In my understanding, we do not need to change the ops:
- if the device offers the capability, let's call the ops
- else call the software fallback function

What you might be missing is the observation that the approach you're

describing requires changing each and every PMD. The changes are also
intrusive: need to change the ops that need the SW fall-back patching, also need to change the private data of each PMD (as assigned to the opaque dev->data->dev_private) to add the context data needed by the patched ops. Therefore, this approach is a no-go.

Quoted 2 lines

We are looking for a generic approach that can gracefully and transparently

Quoted 8 lines
Quoted 4 lines

work with any PMD.

Nobody is participating in this discussion.
Can we discuss how to proceed in the technical board meeting?

Hi Thomas,

We are working to finalize a new version of the Soft NIC PMD which has a much simplified/straightforward design (we'll explain in the cover letter). We expect to send it in the next few days, hopefully we can target RC2.

Thanks for continuing to work on it.
We will probably avoid a last minute integration of this new design in 17.08. So it could become a priority topic for 17.11.

Quoted 1 line

I propose you take another look at this version and then decide if we need TB involvement or not?

OK, let's wait this version.

#77 lore raw
In reply to Jasvinder Singh
Quoted 55 lines · On Fri, 26 May 2017 19:11:47 +0100 Jasvinder Singh <[email protected]>…

The SoftNIC PMD provides SW fall-back option for the NICs not supporting the Traffic Management (TM) features.

SoftNIC PMD overview:
- The SW fall-back is based on the existing librte_sched DPDK library.
- The TM-agnostic port (the underlay device) is wrapped into a TM-aware softnic port (the overlay device).
- Once the overlay device (virtual device) is created, the configuration of the underlay device is taking place through the overlay device.
- The SoftNIC PMD is generic, i.e. it works for any underlay device PMD that implements the ethdev API.

Similarly to Ring PMD, the SoftNIC virtual device can be created in two
different ways:
1. Through EAL command line (--vdev option)_
2._Through the rte_eth_softnic_create() API function called by the application

SoftNIC PMD params:
- iface (mandatory): the ethdev port name (i.e. PCI address or vdev name) for the underlay device
- txq_id (optional, default = 0): tx queue id of the underlay device
- deq_bsz (optional, default = 24): traffic manager dequeue burst size
- Example:_ --vdev 'net_softnic0,iface=0000:04:00.1,txq_id=0,deq_bsz=28'

SoftNIC PMD build instructions:
- To build SoftNIC PMD, the following parameter needs to be set on config/common_base file: CONFIG_RTE_LIBRTE_PMD_SOFTNIC=y
- The SoftNIC PMD depends on the TM API [1] and therefore is initially targeted for the tm-next repository

Patch 1 adds softnic device PMD for traffic management. Patch 2 adds traffic management ops to the softnic device suggested in generic ethdev API for traffic management[1].

[1] TM API version 4:_
http://www.dpdk.org/dev/patchwork/patch/24411/,
http://www.dpdk.org/dev/patchwork/patch/24412/

Jasvinder Singh (2):
net/softnic: add softnic PMD for traffic management net/softnic: add traffic management ops

 MAINTAINERS                                     |    5 +
 config/common_base                              |    5 +
 drivers/net/Makefile                            |    5 +
 drivers/net/softnic/Makefile                    |   58 ++
 drivers/net/softnic/rte_eth_softnic.c           |  578 ++++++++++++
 drivers/net/softnic/rte_eth_softnic.h           |   99 ++
 drivers/net/softnic/rte_eth_softnic_default.c   | 1104 +++++++++++++++++++++++
 drivers/net/softnic/rte_eth_softnic_internals.h |   93 ++
 drivers/net/softnic/rte_eth_softnic_tm.c        |  235 +++++
 drivers/net/softnic/rte_eth_softnic_version.map |    7 +
 mk/rte.app.mk                                   |    5 +-
Quoted 9 lines
 11 files changed, 2193 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/softnic/Makefile
 create mode 100644 drivers/net/softnic/rte_eth_softnic.c
 create mode 100644 drivers/net/softnic/rte_eth_softnic.h
 create mode 100644 drivers/net/softnic/rte_eth_softnic_default.c
 create mode 100644 drivers/net/softnic/rte_eth_softnic_internals.h
 create mode 100644 drivers/net/softnic/rte_eth_softnic_tm.c
 create mode 100644 drivers/net/softnic/rte_eth_softnic_version.map

Setting up a softnic plus hardware NIC is significantly more effort for applications than just using ethdev. Also, it puts the burden on the application to decide which hardware device needs softnic and which does not; putting hardware knowledge in the application is the wrong architectural direction.

Why not just the simple method of putting an new field in ethdev_ops for TM. If it is NULL, then rte_ethdev TM would just fallback to doing the SoftNIC processing?

Also, eth_dev_ops doesn't always have to be const. Aren't there some PMD's that insert different values based on configuration or CPU?

#78 lore raw
Quoted 92 lines

-----Original Message-----
From: Stephen Hemminger [mailto:[email protected]]
Sent: Friday, August 11, 2017 4:28 PM
To: Singh, Jasvinder <[email protected]>
Cc: [email protected]; Dumitrescu, Cristian <[email protected]>; Yigit, Ferruh <[email protected]>; [email protected]; [email protected]; Lu, Wenzhuo <[email protected]>
Subject: Re: [dpdk-dev] [PATCH 0/2] net/softnic: sw fall-back for traffic management

Quoted 12 lines · On Fri, 26 May 2017 19:11:47 +0100 Jasvinder Singh <[email protected]>…

The SoftNIC PMD provides SW fall-back option for the NICs not supporting the Traffic Management (TM) features.

SoftNIC PMD overview:
- The SW fall-back is based on the existing librte_sched DPDK library.
- The TM-agnostic port (the underlay device) is wrapped into a TM-aware softnic port (the overlay device).
- Once the overlay device (virtual device) is created, the configuration of the underlay device is taking place through the overlay device.
- The SoftNIC PMD is generic, i.e. it works for any underlay device PMD that implements the ethdev API.

Quoted 4 lines

Similarly to Ring PMD, the SoftNIC virtual device can be created in two
different ways:
1. Through EAL command line (--vdev option)_
2._Through the rte_eth_softnic_create() API function called by the

application

Quoted 3 lines

SoftNIC PMD params:
- iface (mandatory): the ethdev port name (i.e. PCI address or vdev name)

for

Quoted 25 lines

the underlay device
- txq_id (optional, default = 0): tx queue id of the underlay device
- deq_bsz (optional, default = 24): traffic manager dequeue burst size
- Example:_ --vdev 'net_softnic0,iface=0000:04:00.1,txq_id=0,deq_bsz=28'

SoftNIC PMD build instructions:
- To build SoftNIC PMD, the following parameter needs to be set on config/common_base file: CONFIG_RTE_LIBRTE_PMD_SOFTNIC=y
- The SoftNIC PMD depends on the TM API [1] and therefore is initially targeted for the tm-next repository

Patch 1 adds softnic device PMD for traffic management. Patch 2 adds traffic management ops to the softnic device suggested in generic ethdev API for traffic management[1].

[1] TM API version 4:_
http://www.dpdk.org/dev/patchwork/patch/24411/,
http://www.dpdk.org/dev/patchwork/patch/24412/

Jasvinder Singh (2):
net/softnic: add softnic PMD for traffic management net/softnic: add traffic management ops

Quoted 7 lines
 MAINTAINERS                                     |    5 +
 config/common_base                              |    5 +
 drivers/net/Makefile                            |    5 +
 drivers/net/softnic/Makefile                    |   58 ++
 drivers/net/softnic/rte_eth_softnic.c           |  578 ++++++++++++
 drivers/net/softnic/rte_eth_softnic.h           |   99 ++
 drivers/net/softnic/rte_eth_softnic_default.c   | 1104

+++++++++++++++++++++++

Quoted 4 lines
 drivers/net/softnic/rte_eth_softnic_internals.h |   93 ++
 drivers/net/softnic/rte_eth_softnic_tm.c        |  235 +++++
 drivers/net/softnic/rte_eth_softnic_version.map |    7 +
 mk/rte.app.mk                                   |    5 +-
Quoted 9 lines
 11 files changed, 2193 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/softnic/Makefile
 create mode 100644 drivers/net/softnic/rte_eth_softnic.c
 create mode 100644 drivers/net/softnic/rte_eth_softnic.h
 create mode 100644 drivers/net/softnic/rte_eth_softnic_default.c
 create mode 100644 drivers/net/softnic/rte_eth_softnic_internals.h
 create mode 100644 drivers/net/softnic/rte_eth_softnic_tm.c
 create mode 100644 drivers/net/softnic/rte_eth_softnic_version.map

Setting up a softnic plus hardware NIC is significantly more effort for applications
than just using ethdev. Also, it puts the burden on the application to decide which
hardware device needs softnic and which does not; putting hardware knowledge in the
application is the wrong architectural direction.

Quoted 8 lines

Why not just the simple method of putting an new field in ethdev_ops for TM.
If it is NULL, then rte_ethdev TM would just fallback to doing the SoftNIC processing?

Also, eth_dev_ops doesn't always have to be const. Aren't there some PMD's that
insert different values based on configuration or CPU?

Hi Stephen,

Can you please review V3 and not V1?

Code is very much improved, and we have a list of Q&As that address your questions straight away.

Thanks,
Cristian