New upstream version 18.02
[deb_dpdk.git] / lib / librte_ether / rte_ethdev_driver.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2017 Intel Corporation
3  */
4
5 #ifndef _RTE_ETHDEV_DRIVER_H_
6 #define _RTE_ETHDEV_DRIVER_H_
7
8 /**
9  * @file
10  *
11  * RTE Ethernet Device PMD API
12  *
13  * These APIs for the use from Ethernet drivers, user applications shouldn't
14  * use them.
15  *
16  */
17
18 #include <rte_ethdev.h>
19
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23
24 /**
25  * @internal
26  * Returns a ethdev slot specified by the unique identifier name.
27  *
28  * @param       name
29  *  The pointer to the Unique identifier name for each Ethernet device
30  * @return
31  *   - The pointer to the ethdev slot, on success. NULL on error
32  */
33 struct rte_eth_dev *rte_eth_dev_allocated(const char *name);
34
35 /**
36  * @internal
37  * Allocates a new ethdev slot for an ethernet device and returns the pointer
38  * to that slot for the driver to use.
39  *
40  * @param       name    Unique identifier name for each Ethernet device
41  * @param       type    Device type of this Ethernet device
42  * @return
43  *   - Slot in the rte_dev_devices array for a new device;
44  */
45 struct rte_eth_dev *rte_eth_dev_allocate(const char *name);
46
47 /**
48  * @internal
49  * Attach to the ethdev already initialized by the primary
50  * process.
51  *
52  * @param       name    Ethernet device's name.
53  * @return
54  *   - Success: Slot in the rte_dev_devices array for attached
55  *        device.
56  *   - Error: Null pointer.
57  */
58 struct rte_eth_dev *rte_eth_dev_attach_secondary(const char *name);
59
60 /**
61  * @internal
62  * Release the specified ethdev port.
63  *
64  * @param eth_dev
65  * The *eth_dev* pointer is the address of the *rte_eth_dev* structure.
66  * @return
67  *   - 0 on success, negative on error
68  */
69 int rte_eth_dev_release_port(struct rte_eth_dev *eth_dev);
70
71 /**
72  * @internal
73  * Release device queues and clear its configuration to force the user
74  * application to reconfigure it. It is for internal use only.
75  *
76  * @param dev
77  *  Pointer to struct rte_eth_dev.
78  *
79  * @return
80  *  void
81  */
82 void _rte_eth_dev_reset(struct rte_eth_dev *dev);
83
84 /**
85  * @internal Executes all the user application registered callbacks for
86  * the specific device. It is for DPDK internal user only. User
87  * application should not call it directly.
88  *
89  * @param dev
90  *  Pointer to struct rte_eth_dev.
91  * @param event
92  *  Eth device interrupt event type.
93  * @param ret_param
94  *  To pass data back to user application.
95  *  This allows the user application to decide if a particular function
96  *  is permitted or not.
97  *
98  * @return
99  *  int
100  */
101 int _rte_eth_dev_callback_process(struct rte_eth_dev *dev,
102                 enum rte_eth_event_type event, void *ret_param);
103
104 /**
105  * Create memzone for HW rings.
106  * malloc can't be used as the physical address is needed.
107  * If the memzone is already created, then this function returns a ptr
108  * to the old one.
109  *
110  * @param eth_dev
111  *   The *eth_dev* pointer is the address of the *rte_eth_dev* structure
112  * @param name
113  *   The name of the memory zone
114  * @param queue_id
115  *   The index of the queue to add to name
116  * @param size
117  *   The sizeof of the memory area
118  * @param align
119  *   Alignment for resulting memzone. Must be a power of 2.
120  * @param socket_id
121  *   The *socket_id* argument is the socket identifier in case of NUMA.
122  */
123 const struct rte_memzone *
124 rte_eth_dma_zone_reserve(const struct rte_eth_dev *eth_dev, const char *name,
125                          uint16_t queue_id, size_t size,
126                          unsigned align, int socket_id);
127
128 #ifdef __cplusplus
129 }
130 #endif
131
132 #endif /* _RTE_ETHDEV_DRIVER_H_ */