From: Intel Date: Wed, 19 Dec 2012 23:00:00 +0000 (+0100) Subject: ethdev: add priority flow control configuration X-Git-Tag: spdx-start~11365 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=92e16314207228595adecd7bb5bc9a2083806426;p=dpdk.git ethdev: add priority flow control configuration Signed-off-by: Intel --- diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index 7aadbd3159..db013e586a 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -1381,13 +1381,30 @@ rte_eth_dev_flow_ctrl_set(uint8_t port_id, struct rte_eth_fc_conf *fc_conf) } dev = &rte_eth_devices[port_id]; - - /* High water, low water validation are device specific */ FUNC_PTR_OR_ERR_RET(*dev->dev_ops->flow_ctrl_set, -ENOTSUP); - if (*dev->dev_ops->flow_ctrl_set) - return (*dev->dev_ops->flow_ctrl_set)(dev, fc_conf); + return (*dev->dev_ops->flow_ctrl_set)(dev, fc_conf); +} - return -ENOTSUP; +int +rte_eth_dev_priority_flow_ctrl_set(uint8_t port_id, struct rte_eth_pfc_conf *pfc_conf) +{ + struct rte_eth_dev *dev; + + if (port_id >= nb_ports) { + PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id); + return (-ENODEV); + } + + if (pfc_conf->priority > (ETH_DCB_NUM_USER_PRIORITIES - 1)) { + PMD_DEBUG_TRACE("Invalid priority, only 0-7 allowed\n"); + return (-EINVAL); + } + + dev = &rte_eth_devices[port_id]; + /* High water, low water validation are device specific */ + if (*dev->dev_ops->priority_flow_ctrl_set) + return (*dev->dev_ops->priority_flow_ctrl_set)(dev, pfc_conf); + return (-ENOTSUP); } int diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h index 1cfb76a61a..4e57af8f9e 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -439,6 +439,16 @@ struct rte_eth_fc_conf { enum rte_eth_fc_mode mode; /**< Link flow control mode */ }; +/** + * A structure used to configure Ethernet priority flow control parameter. + * These parameters will be configured into the register of the NIC. + * Please refer to the corresponding data sheet for proper value. + */ +struct rte_eth_pfc_conf { + struct rte_eth_fc_conf fc; /**< General flow control parameter. */ + uint8_t priority; /**< VLAN User Priority. */ +}; + /** * Flow Director setting modes: none (default), signature or perfect. */ @@ -791,6 +801,10 @@ typedef int (*flow_ctrl_set_t)(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf); /**< @internal Setup flow control parameter on an Ethernet device */ +typedef int (*priority_flow_ctrl_set_t)(struct rte_eth_dev *dev, + struct rte_eth_pfc_conf *pfc_conf); +/**< @internal Setup priority flow control parameter on an Ethernet device */ + typedef int (*eth_dev_led_on_t)(struct rte_eth_dev *dev); /**< @internal Turn on SW controllable LED on an Ethernet device */ @@ -835,6 +849,7 @@ struct eth_dev_ops { eth_dev_led_on_t dev_led_on; /**< Turn on LED. */ eth_dev_led_off_t dev_led_off; /**< Turn off LED. */ flow_ctrl_set_t flow_ctrl_set; /**< Setup flow control. */ + priority_flow_ctrl_set_t priority_flow_ctrl_set; /**< Setup priority flow control.*/ eth_mac_addr_remove_t mac_addr_remove; /**< Remove MAC address */ eth_mac_addr_add_t mac_addr_add; /**< Add a MAC address */ @@ -2016,6 +2031,24 @@ int rte_eth_led_off(uint8_t port_id); int rte_eth_dev_flow_ctrl_set(uint8_t port_id, struct rte_eth_fc_conf *fc_conf); +/** + * Configure the Ethernet priority flow control under DCB environment + * for Ethernet device. + * + * @param port_id + * The port identifier of the Ethernet device. + * @param pfc_conf + * The pointer to the structure of the priority flow control parameters. + * @return + * - (0) if successful. + * - (-ENOTSUP) if hardware doesn't support priority flow control mode. + * - (-ENODEV) if *port_id* invalid. + * - (-EINVAL) if bad parameter + * - (-EIO) if flow control setup failure + */ +int rte_eth_dev_priority_flow_ctrl_set(uint8_t port_id, + struct rte_eth_pfc_conf *pfc_conf); + /** * Add a MAC address to an internal array of addresses used to enable whitelist * filtering to accept packets only if the destination MAC address matches.