X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=lib%2Flibrte_ether%2Frte_ethdev.h;h=e8df027965b4fb67e22d51617a0fa9a951c84510;hb=ef7d28668505a04afe0f93f097f58614679c0f9f;hp=cea230e0484826af4fc07b051d524e6845fdfcc1;hpb=6c6829475b051c729e9d05695720f89d5263ec92;p=dpdk.git diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h index cea230e048..e8df027965 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -175,6 +175,8 @@ extern "C" { #include #include #include +#include +#include #include #include "rte_ether.h" #include "rte_eth_ctrl.h" @@ -1382,33 +1384,52 @@ struct eth_dev_ops { }; /** - * Function type used for callbacks for processing packets on RX and TX + * Function type used for RX packet processing packet callbacks. * - * If configured for RX, it is called with a burst of packets that have just - * been received on the given port and queue. On TX, it is called with a burst - * of packets immediately before those packets are put onto the hardware queue - * for transmission. + * The callback function is called on RX with a burst of packets that have + * been received on the given port and queue. * * @param port - * The ethernet port on which rx or tx is being performed + * The Ethernet port on which RX is being performed. * @param queue - * The queue on the ethernet port which is being used to receive or transmit - * the packets. + * The queue on the Ethernet port which is being used to receive the packets. * @param pkts - * The burst of packets on which processing is to be done. On RX, these - * packets have just been received. On TX, they are about to be transmitted. + * The burst of packets that have just been received. * @param nb_pkts - * The number of packets in the burst pointed to by "pkts" + * The number of packets in the burst pointed to by "pkts". + * @param max_pkts + * The max number of packets that can be stored in the "pkts" array. * @param user_param * The arbitrary user parameter passed in by the application when the callback * was originally configured. * @return - * The number of packets remaining in pkts are processing. - * * On RX, this will be returned to the user as the return value from - * rte_eth_rx_burst. - * * On TX, this will be the number of packets actually written to the NIC. + * The number of packets returned to the user. */ -typedef uint16_t (*rte_rxtx_callback_fn)(uint8_t port, uint16_t queue, +typedef uint16_t (*rte_rx_callback_fn)(uint8_t port, uint16_t queue, + struct rte_mbuf *pkts[], uint16_t nb_pkts, uint16_t max_pkts, + void *user_param); + +/** + * Function type used for TX packet processing packet callbacks. + * + * The callback function is called on TX with a burst of packets immediately + * before the packets are put onto the hardware queue for transmission. + * + * @param port + * The Ethernet port on which TX is being performed. + * @param queue + * The queue on the Ethernet port which is being used to transmit the packets. + * @param pkts + * The burst of packets that are about to be transmitted. + * @param nb_pkts + * The number of packets in the burst pointed to by "pkts". + * @param user_param + * The arbitrary user parameter passed in by the application when the callback + * was originally configured. + * @return + * The number of packets to be written to the NIC. + */ +typedef uint16_t (*rte_tx_callback_fn)(uint8_t port, uint16_t queue, struct rte_mbuf *pkts[], uint16_t nb_pkts, void *user_param); /** @@ -1418,10 +1439,24 @@ typedef uint16_t (*rte_rxtx_callback_fn)(uint8_t port, uint16_t queue, */ struct rte_eth_rxtx_callback { struct rte_eth_rxtx_callback *next; - rte_rxtx_callback_fn fn; + union{ + rte_rx_callback_fn rx; + rte_tx_callback_fn tx; + } fn; void *param; }; +/* + * The eth device type + */ +enum rte_eth_dev_type { + RTE_ETH_DEV_UNKNOWN, /**< unknown device type */ + RTE_ETH_DEV_PCI, + /**< Physical function and Virtual function of PCI devices */ + RTE_ETH_DEV_VIRTUAL, /**< non hardware device */ + RTE_ETH_DEV_MAX /**< max value of this enum */ +}; + /** * @internal * The generic data structure associated with each ethernet device. @@ -1445,13 +1480,14 @@ struct rte_eth_dev { * User-supplied functions called from rx_burst to post-process * received packets before passing them to the user */ - struct rte_eth_rxtx_callback **post_rx_burst_cbs; + struct rte_eth_rxtx_callback *post_rx_burst_cbs[RTE_MAX_QUEUES_PER_PORT]; /** * User-supplied functions called from tx_burst to pre-process * received packets before passing them to the driver for transmission. */ - struct rte_eth_rxtx_callback **pre_tx_burst_cbs; + struct rte_eth_rxtx_callback *pre_tx_burst_cbs[RTE_MAX_QUEUES_PER_PORT]; uint8_t attached; /**< Flag indicating the port is attached */ + enum rte_eth_dev_type dev_type; /**< Flag indicating the device type */ }; struct rte_eth_dev_sriov { @@ -1527,6 +1563,16 @@ extern struct rte_eth_dev rte_eth_devices[]; */ extern uint8_t rte_eth_dev_count(void); +/** + * Function for internal use by port hotplug functions. + * Returns a ethdev slot specified by the unique identifier name. + * @param name + * The pointer to the Unique identifier name for each Ethernet device + * @return + * - The pointer to the ethdev slot, on success. NULL on error + */ +extern struct rte_eth_dev *rte_eth_dev_allocated(const char *name); + /** * Function for internal use by dummy drivers primarily, e.g. ring-based * driver. @@ -1534,10 +1580,12 @@ extern uint8_t rte_eth_dev_count(void); * to that slot for the driver to use. * * @param name Unique identifier name for each Ethernet device + * @param type Device type of this Ethernet device * @return * - Slot in the rte_dev_devices array for a new device; */ -struct rte_eth_dev *rte_eth_dev_allocate(const char *name); +struct rte_eth_dev *rte_eth_dev_allocate(const char *name, + enum rte_eth_dev_type type); /** * Function for internal use by dummy drivers primarily, e.g. ring-based @@ -1551,15 +1599,38 @@ struct rte_eth_dev *rte_eth_dev_allocate(const char *name); */ int rte_eth_dev_release_port(struct rte_eth_dev *eth_dev); +/** + * Attach a new Ethernet device specified by aruguments. + * + * @param devargs + * A pointer to a strings array describing the new device + * to be attached. The strings should be a pci address like + * '0000:01:00.0' or virtual device name like 'eth_pcap0'. + * @param port_id + * A pointer to a port identifier actually attached. + * @return + * 0 on success and port_id is filled, negative on error + */ +int rte_eth_dev_attach(const char *devargs, uint8_t *port_id); + +/** + * Detach a Ethernet device specified by port identifier. + * + * @param port_id + * The port identifier of the device to detach. + * @param addr + * A pointer to a device name actually detached. + * @return + * 0 on success and devname is filled, negative on error + */ +int rte_eth_dev_detach(uint8_t port_id, char *devname); + struct eth_driver; /** * @internal * Initialization function of an Ethernet driver invoked for each matching * Ethernet PCI device detected during the PCI probing phase. * - * @param eth_drv - * The pointer to the [matching] Ethernet driver structure supplied by - * the PMD when it registered itself. * @param eth_dev * The *eth_dev* pointer is the address of the *rte_eth_dev* structure * associated with the matching device and which have been [automatically] @@ -1570,6 +1641,8 @@ struct eth_driver; * - *pci_dev*: Holds the pointers to the *rte_pci_device* structure which * contains the generic PCI information of the matching device. * + * - *driver*: Holds the pointer to the *eth_driver* structure. + * * - *dev_private*: Holds a pointer to the device private data structure. * * - *mtu*: Contains the default Ethernet maximum frame length (1500). @@ -1583,17 +1656,13 @@ struct eth_driver; * of the *eth_dev* structure. * - <0: Error code of the device initialization failure. */ -typedef int (*eth_dev_init_t)(struct eth_driver *eth_drv, - struct rte_eth_dev *eth_dev); +typedef int (*eth_dev_init_t)(struct rte_eth_dev *eth_dev); /** * @internal * Finalization function of an Ethernet driver invoked for each matching * Ethernet PCI device detected during the PCI closing phase. * - * @param eth_drv - * The pointer to the [matching] Ethernet driver structure supplied by - * the PMD when it registered itself. * @param eth_dev * The *eth_dev* pointer is the address of the *rte_eth_dev* structure * associated with the matching device and which have been [automatically] @@ -1604,8 +1673,7 @@ typedef int (*eth_dev_init_t)(struct eth_driver *eth_drv, * of the *eth_dev* structure. * - <0: Error code of the device initialization failure. */ -typedef int (*eth_dev_uninit_t)(const struct eth_driver *eth_drv, - struct rte_eth_dev *eth_dev); +typedef int (*eth_dev_uninit_t)(struct rte_eth_dev *eth_dev); /** * @internal @@ -2340,28 +2408,28 @@ extern uint16_t rte_eth_rx_burst(uint8_t port_id, uint16_t queue_id, #else static inline uint16_t rte_eth_rx_burst(uint8_t port_id, uint16_t queue_id, - struct rte_mbuf **rx_pkts, uint16_t nb_pkts) + struct rte_mbuf **rx_pkts, const uint16_t nb_pkts) { struct rte_eth_dev *dev; dev = &rte_eth_devices[port_id]; - nb_pkts = (*dev->rx_pkt_burst)(dev->data->rx_queues[queue_id], rx_pkts, - nb_pkts); + int16_t nb_rx = (*dev->rx_pkt_burst)(dev->data->rx_queues[queue_id], + rx_pkts, nb_pkts); #ifdef RTE_ETHDEV_RXTX_CALLBACKS struct rte_eth_rxtx_callback *cb = dev->post_rx_burst_cbs[queue_id]; if (unlikely(cb != NULL)) { do { - nb_pkts = cb->fn(port_id, queue_id, rx_pkts, nb_pkts, - cb->param); + nb_rx = cb->fn.rx(port_id, queue_id, rx_pkts, nb_rx, + nb_pkts, cb->param); cb = cb->next; } while (cb != NULL); } #endif - return nb_pkts; + return nb_rx; } #endif @@ -2494,7 +2562,7 @@ rte_eth_tx_burst(uint8_t port_id, uint16_t queue_id, if (unlikely(cb != NULL)) { do { - nb_pkts = cb->fn(port_id, queue_id, tx_pkts, nb_pkts, + nb_pkts = cb->fn.tx(port_id, queue_id, tx_pkts, nb_pkts, cb->param); cb = cb->next; } while (cb != NULL); @@ -3444,7 +3512,7 @@ int rte_eth_dev_filter_ctrl(uint8_t port_id, enum rte_filter_type filter_type, * On success, a pointer value which can later be used to remove the callback. */ void *rte_eth_add_rx_callback(uint8_t port_id, uint16_t queue_id, - rte_rxtx_callback_fn fn, void *user_param); + rte_rx_callback_fn fn, void *user_param); /** * Add a callback to be called on packet TX on a given port and queue. @@ -3469,7 +3537,7 @@ void *rte_eth_add_rx_callback(uint8_t port_id, uint16_t queue_id, * On success, a pointer value which can later be used to remove the callback. */ void *rte_eth_add_tx_callback(uint8_t port_id, uint16_t queue_id, - rte_rxtx_callback_fn fn, void *user_param); + rte_tx_callback_fn fn, void *user_param); /** * Remove an RX packet callback from a given port and queue.