From: "Chen Jing D(Mark)" <jing.d.chen@intel.com>
To: dev@dpdk.org
Cc: keith.wiles@intel.com, gerald.rogers@intel.com,
"Chen Jing D(Mark)" <jing.d.chen@intel.com>
Subject: [dpdk-dev] [RFC 2/2] prgdev: introduce generic prgdev API
Date: Fri, 20 Jan 2017 11:21:38 +0800 [thread overview]
Message-ID: <1484882498-18653-3-git-send-email-jing.d.chen@intel.com> (raw)
In-Reply-To: <1484882498-18653-1-git-send-email-jing.d.chen@intel.com>
A new file to define prgdev API prototype and corresponding data
structures.
Signed-off-by: Chen Jing D(Mark) <jing.d.chen@intel.com>
---
lib/librte_prgdev/rte_prgdev.h | 242 ++++++++++++++++++++++++++++++++++++++++
1 files changed, 242 insertions(+), 0 deletions(-)
create mode 100644 lib/librte_prgdev/rte_prgdev.h
diff --git a/lib/librte_prgdev/rte_prgdev.h b/lib/librte_prgdev/rte_prgdev.h
new file mode 100644
index 0000000..849aba4
--- /dev/null
+++ b/lib/librte_prgdev/rte_prgdev.h
@@ -0,0 +1,242 @@
+/*-
+ * BSD LICENSE
+ *
+ * Copyright(c) 2016-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.
+ */
+
+#ifndef _RTE_PRGDEV_H_
+#define _RTE_PRGDEV_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * reflect the device status
+ */
+enum rte_prg_devstat {
+ RTE_PRGDEV_STAT_UNKNOWN = 0, /** Device in a unkown state */
+ RTE_PRGDEV_STAT_READY, /** Device is ready to be programming. */
+ RTE_PRGDEV_STAT_ERASING, /** Device is ready being programmed. */
+ /** Device is performing functionalities and can't be programmed. */
+ RTE_PRGDEV_STAT_RUNNING,
+};
+
+/* Reflect the function block attributes */
+/* Block is readable */
+#define RTE_PGR_FUNC_ATTR_RD 0x00000001
+/* Block is writable */
+#define RTE_PGR_FUNC_ATTR_WR 0x00000002
+/* Block is readable and writable */
+#define RTE_PGR_FUNC_ATTR_RDWR (RTE_PGR_FUNC_ATTR_RD & RTE_PGR_FUNC_ATTR_WR)
+
+struct rte_prg_blk_info {
+ unsigned int size; /* the block size in bytes */
+ unsigned int version; /* It's optional */
+ unsigned int flags; /* Flags to indicate block isreadable/writable */
+};
+
+#define MAX_SIGNATURE_LEN 256
+#define MAX_BLK_NUM 256
+
+struct rte_prg_dev_info {
+ struct rte_pci_device *pci_dev; /**< Device PCI information. */
+ const char *driver_name; /**< Device Driver name. */
+ unsigned int devid; /**< Index to bound host interface, or 0 if none. */
+ /* Programable device HW version number. it's possible that app
+ * have dependency to HW version.
+ */
+ uint16_t hw_ver_major; /* major version number */
+ uint16_t hw_ver_minor; /* minor version number */
+
+ /* A array to store hardware, firmware, running image info.Each device
+ * can define and interpret the info. For example, a device can define
+ * byte[3:0] as signature for on-die personality, byte[5:4] is the major
+ * version, byte[7:6] is minor version. if 0xFFEA1000 is a signature for
+ * virtio personality, major version is 0x0001, minor version is 0x0004.
+ * then signature can be defined :
+ * sig_num = 8;
+ * signature[7:0]= {00, 0x10, 0xEA, 0xFF, 0x00, 0x01, 0x00, 0x04};
+ */
+ unsigned int sig_num; /** < the valid signature length in bytes> */
+ char signature[MAX_SIGNATURE_LEN];
+ enum rte_prg_devstat status;
+
+ /* number of blocks within device */
+ unsigned int blk_num;
+ /* block info */
+ struct rte_prg_blk_info blk_info[MAX_BLK_NUM];
+};
+
+struct rte_prg_dev {
+ struct rte_prg_dev_info prg_dev_info;
+} __rte_cache_aligned;
+
+/*
+* prg_dev_init routine
+*
+* returns : 0 success, non zero failure.
+*/
+
+typedef int (*prg_dev_init_t)(struct rte_prg_dev *prg_dev);
+
+/*
+* prg_dev_uninit routine
+*
+* returns : 0 success, non zero failure.
+*/
+
+
+typedef int (*prg_dev_uninit_t)(struct rte_prg_dev *prg_dev);
+
+/**
+ * @internal
+ * The structure associated with a programmable driver.
+ *
+ * Each prg driver acts as a PCI driver and is represented by a generic
+ * eth_driver* structure that holds:
+ *
+ * - An *rte_pci_driver* structure (which must be the first field).
+ *
+ * - The *prg_dev_init_t* function invoked for each matching PCI device.
+ *
+ * - The *prg_dev_remove* function invoked for each matching PCI device.
+ *
+ * - The size of the private data to allocate for each matching device.
+ */
+
+struct prg_driver {
+ struct rte_pci_driver pci_drv; /**< The PRG is also a PCI driver. */
+ prg_dev_init_t prg_dev_probe; /**< Device probe function. */
+ prg_dev_uninit_t prg_dev_remove; /**< Device remove function. */
+ unsigned int dev_private_size; /**< Size of device private data. */
+};
+
+
+/*
+* Query what personality is in the device.
+*
+* @param device_id
+* The port identifier of the programmable device.
+* @param info
+* A pointer to a structure of type *rte_prg_dev_info* to be filled with
+* the information of the programmable device.
+*/
+
+int rte_prgdev_get_info(uint8_t device_id,
+ struct rte_prg_dev_info *info);
+
+/*
+* Open device for programming, acquiring on-die image, etc.
+* Need to call this function first
+* prior to calling other functionalities.
+* In case the device is performing some tasks, it's device's decision on
+* what result is returned.
+*/
+
+int rte_prgdev_open(uint8_t device_id);
+
+
+/*
+* Download image from host to programmable device.
+*
+* @param device_id
+* The port identifier of the programmable device.
+* @param buffer_ptr
+* A pointer to a buffer that stored the image ready downloading to device
+* @param buf_len
+* the total image length in bytes.
+*/
+
+int rte_prgdev_img_download(uint8_t device_id,
+ uint8_t *buffer_ptr, uint32_t buf_len);
+
+/*
+* Upload image from programmable device to host.
+*
+* @param device_id
+* The port identifier of the programmable device.
+* @param buffer_ptr
+* A pointer to a buffer that store uploaded image
+* @param buf_len
+* the total buffer length in bytes.
+* @param act_len
+* pointer to the actual image length in bytes.
+*/
+
+int rte_prgdev_img_upload(uint8_t device_id, uint8_t *buffer_ptr,
+ uint32_t buf_len,uint32_t *act_len);
+
+/*
+ * reflect the device status
+ */
+
+enum rte_prg_fwstat {
+ RTE_PRGDEV_FWSTAT_OK = 0, /** Image are running well */
+ RTE_PRGDEV_FWSTAT_ERR = -1, /** Image has error. */
+ RTE_PRGDEV_FWSTAT_ERR_VALID = -2, /** Image is not valid. */
+ RTE_PRGDEV_FWSTAT_ERR_CKSUM = -3, /** Image checksum is not correct. */
+ RTE_PRGDEV_FWSTAT_ERR_LEN = -4, /** Image length is not correct. */
+};
+
+/*
+* Check if the downloaded image running on die works in expected way, optional
+* function.
+* @param device_id
+* The port identifier of the programmable device.
+*/
+int rte_prgdev_check_stat(uint8_t device_id, enum rte_prg_fwstat *stat);
+
+/*
+* Called to free up resources or whatever to do to hardware
+* after an erase or load of the program.
+* @param device_id
+* The port identifier of the programmable device.
+*/
+int rte_prgdev_close(uint8_t device_id);
+
+/*
+* Called to bind a programmable device to drivers after close function is called.
+* @param device_id
+* The port identifier of the programmable device.
+*/
+int rte_prgdev_bind(uint8_t device_id);
+/*
+* Called to unbind all functions except prgdev from drivers.
+* @param device_id
+* The port identifier of the programmable device.
+*/
+rte_prgdev_unbind(uint8_t device_id);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _RTE_PRGDEV_H_ */
--
1.7.7.6
next prev parent reply other threads:[~2017-01-20 10:24 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-20 3:21 [dpdk-dev] [RFC 0/2] Prgdev API Chen Jing D(Mark)
2017-01-20 3:21 ` [dpdk-dev] [RFC 1/2] doc: introduction to prgdev Chen Jing D(Mark)
2017-02-01 11:41 ` Jan Blunck
2017-02-03 9:21 ` Liang, Cunming
2017-02-06 9:16 ` Chen, Jing D
2017-02-08 3:30 ` Liang, Cunming
2017-01-20 3:21 ` Chen Jing D(Mark) [this message]
2017-02-08 22:49 ` [dpdk-dev] [RFC 2/2] prgdev: introduce generic prgdev API Stephen Hemminger
2017-02-08 23:06 ` Wiles, Keith
2017-02-09 2:23 ` Chen, Jing D
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1484882498-18653-3-git-send-email-jing.d.chen@intel.com \
--to=jing.d.chen@intel.com \
--cc=dev@dpdk.org \
--cc=gerald.rogers@intel.com \
--cc=keith.wiles@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).