mbox series

[RFC,0/2] RAW Device Support

Message ID 1510162854-10171-1-git-send-email-hemant.agrawal@nxp.com
Headers show
Series RAW Device Support | expand

Message

Hemant Agrawal Nov. 8, 2017, 5:40 p.m. UTC
Rawdevice Support in DPDK
-------------------------

This RFC describes support for rawdevices or generic device support in DPDK.
It is supported by following writeup accompanied by skeleton header file with
declarations.

Motivation
==========

In terms of device flavor (type) support, DPDK currently has ethernet
(lib_ether), cryptodev (libcryptodev), eventdev (libeventdev) and vdev
(virtual device) support.

For a new type of device, for example an accelerator, there are not many
options except either:
1. create another lib/librte_MySpecialDev, driver/MySpecialDrv and use it
through Bus/PMD model.
2. Or, create a vdev and implement necessary custom APIs which are directly
exposed from driver layer. However this may still require changes in bus code
in DPDK.

Either method is unclean (touching lib for specific context) and possibly
non-upstreamable (custom APIs). Applications and customers prefers uniform
device view and programming model.


Scope
=====

The rawdevice implementation is targetted towards various accelerator use cases
which cannot be generalized within existing device models. Aim is to provided a
generalized structure at the cost of portability guarantee. Specific PMDs may
also expose any specific config APIs. Applications built over such devices are
special use-cases involving IP blocks.

The rawdevice  may also connect to other standard devices using adapter or other
methods e.g. eventdev – single place to get all events.

Proposed Solution
=================

Defining a very generic super-set of device type and its device operations that
can be exposed such that any new/upcoming/experimental device can be layered
over it. This RFC names it 'rawdevice' to signify that the device doesn't have
any flavor/type associated with it which is advertised (like net, crypto etc).

A *rte_rawdevice* is a raw/generic device without any standard configuration
or input/output method assumption.

Thus, driver for a new accelerator block, which requires operations for
start/stop/enqueue/dequeue, can be quickly strapped over this rawdevice layer.
Thereafter, any appropriate bus can scan for it (assuming device is discoverable
over the Linux interfaces like sysfs) and match it against registered drivers.

Similarly, for a new accelerator or a wireless device, which doesn't fit the eth
type, a driver can be registered with a bus (on which its device would be
scannable) and use this layer for configuring the device.

It can also serve as a staging area for new type of devices till they
find some commonality and can be standardized.

The outline of this proposed library is same as existing ether/crypto devices.

     +-----------------------------------------------------------+
     |                     Application(s)                        |
     +------------------------------.----------------------------+
                                    |
                                    |
     +------------------------------'----------------------------+
     |                       DPDK Framework (APIs)               |
     +--------------|----|-----------------|---------------------+
                   /      \                 \
            (crypto ops)  (eth ops)      (rawdev ops)        +----+
            /               \                 \              |DrvA|
     +-----'---+        +----`----+        +---'-----+       +----+
     | crypto  |        | ethdev  |        | raw     |
     +--/------+        +---/-----+        +----/----+       +----+
       /\                __/\                  /   ..........|DrvB|
      /  \              /    \                / ../    \     +----+
  +====+ +====+    +====+ +====+            +==/=+      ```Bus Probe 
  |DevA| |DevB|    |DevC| |DevD|            |DevF|
  +====+ +====+    +====+ +====+            +====+
    |      |        |      |                 |    
  ``|``````|````````|``````|`````````````````|````````Bus Scan
   (PCI)   |       (PCI)  (PCI)            (PCI)
         (BusA)

 * It is assumed above that DrvB is a PCI type driver which registers itself
   with PCI Bus
 * Thereafter, when the PCI scan is done, during probe DrvB would match the
   rawdev DevF ID and take control of device
 * Applications can then continue using the device through rawdev API interfaces


Proposed Interfaces
===================

Following broad API categories are exposed by the rawdevice:

1) Device State Operations (start/stop/reset)
2) Communication Channel setup/teardown (queue)
3) Stat Operations (xstats)
4) Enqueue/Dequeue Operations
5) Firmware Operations (Load/unload)

Notes:
For (1), other than standard start/stop, reset has been added extra. This is for
cases where device power cycle has various definitions. Semantics of what
stop->start and what reset would mean are still open-ended.

For (2), though currently `queue` has been used a semantic, it would be possible
in implementation to use this with other methods like internally hosted rte_ring.

For (3), Reason for choosing xstats is to allow for the device to define its own
stats. Being a generic layer, it doesn't provide any existing fields.

For (4), Aim is to allow applications to post buffers (which can be arbit data)
to the device. It is device's responsibility to interpret and handle the buffer.
It can also be expanded to synchronous and async methods of posting buffer.
That would provide broader use-cases.

For (5), Aim is to allow for most basic device firmware management. In this, as
well as other operations, it is expected that those which are not implemneted
would return ENOTSUP allow the application to fail gracefully.

Future Work
===========
1. Support for hotplugging and interrupt handling
2. Support for adding dynamic operations (~IOCTLs)
3. Support for callbacks for enqueue and dequeue of buffers
4. Interfacing with Eth/Crypto/Event type devices for inline offloading

Hemant Agrawal (2):
  lib: introduce raw device library
  config: enable compilation of raw device library

 config/common_base                       |   7 +
 lib/Makefile                             |   3 +
 lib/librte_rawdev/Makefile               |  53 +++
 lib/librte_rawdev/rte_rawdev.c           | 626 +++++++++++++++++++++++++++++++
 lib/librte_rawdev/rte_rawdev.h           | 524 ++++++++++++++++++++++++++
 lib/librte_rawdev/rte_rawdev_pmd.h       | 540 ++++++++++++++++++++++++++
 lib/librte_rawdev/rte_rawdev_version.map |  28 ++
 7 files changed, 1781 insertions(+)
 create mode 100644 lib/librte_rawdev/Makefile
 create mode 100644 lib/librte_rawdev/rte_rawdev.c
 create mode 100644 lib/librte_rawdev/rte_rawdev.h
 create mode 100644 lib/librte_rawdev/rte_rawdev_pmd.h
 create mode 100644 lib/librte_rawdev/rte_rawdev_version.map

-- 
2.7.4