From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id 9D8D368F2 for ; Fri, 16 Sep 2016 13:05:47 +0200 (CEST) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga105.fm.intel.com with ESMTP; 16 Sep 2016 04:05:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.30,344,1470726000"; d="scan'208";a="169411015" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by fmsmga004.fm.intel.com with ESMTP; 16 Sep 2016 04:05:45 -0700 Received: from sivswdev01.ir.intel.com (sivswdev01.ir.intel.com [10.237.217.45]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id u8GB5i26005638; Fri, 16 Sep 2016 12:05:44 +0100 Received: from sivswdev01.ir.intel.com (localhost [127.0.0.1]) by sivswdev01.ir.intel.com with ESMTP id u8GB5dw6013858; Fri, 16 Sep 2016 12:05:39 +0100 Received: (from bairemon@localhost) by sivswdev01.ir.intel.com with œ id u8GB5dcB013854; Fri, 16 Sep 2016 12:05:39 +0100 From: Bernard Iremonger To: dev@dpdk.org, rahul.r.shah@intel.com, wenzhuo.lu@intel.com, az5157@att.com Cc: Bernard Iremonger , azelezniak Date: Fri, 16 Sep 2016 12:05:32 +0100 Message-Id: <1474023934-13513-2-git-send-email-bernard.iremonger@intel.com> X-Mailer: git-send-email 1.7.0.7 In-Reply-To: <1472202620-20487-1-git-send-email-bernard.iremonger@intel.com> References: <1472202620-20487-1-git-send-email-bernard.iremonger@intel.com> Subject: [dpdk-dev] [PATCH v3 1/3] librte_ether: add API's for VF management X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Sep 2016 11:05:48 -0000 Add new API functions to configure and manage VF's on a NIC. add rte_eth_dev_vf_ping function. add rte_eth_dev_set_vf_vlan_anti_spoof function. add rte_eth_dev_set_vf_mac_anti_spoof function. add rte_eth_dev_set_vf_vlan_strip function. Signed-off-by: azelezniak add rte_eth_dev_set_vf_vlan_insert function. add rte_eth_dev_set_loopback function. add rte_eth_dev_set_all_queues_drop function. add rte_eth_dev_set_vf_split_drop_en function add rte_eth_dev_set_vf_mac_addr function. Signed-off-by: Bernard Iremonger --- lib/librte_ether/rte_ethdev.c | 192 +++++++++++++++++++++++++++++ lib/librte_ether/rte_ethdev.h | 217 ++++++++++++++++++++++++++++++++- lib/librte_ether/rte_ether_version.map | 14 +++ 3 files changed, 422 insertions(+), 1 deletion(-) diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index 382c959..4f83c29 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -2305,6 +2305,30 @@ rte_eth_dev_default_mac_addr_set(uint8_t port_id, struct ether_addr *addr) } int +rte_eth_dev_set_vf_mac_addr(uint8_t port_id, uint16_t vf, struct ether_addr *addr) +{ + struct rte_eth_dev *dev; + struct rte_eth_dev_info dev_info; + + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); + + if (!is_valid_assigned_ether_addr(addr)) + return -EINVAL; + + dev = &rte_eth_devices[port_id]; + rte_eth_dev_info_get(port_id, &dev_info); + + if (vf >= dev_info.max_vfs) { + RTE_PMD_DEBUG_TRACE("set VF mac addr: invalid VF %d\n", vf); + return -EINVAL; + } + + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->set_vf_mac_addr, -ENOTSUP); + + return (*dev->dev_ops->set_vf_mac_addr)(dev, vf, addr); +} + +int rte_eth_dev_set_vf_rxmode(uint8_t port_id, uint16_t vf, uint16_t rx_mode, uint8_t on) { @@ -2489,6 +2513,174 @@ rte_eth_dev_set_vf_vlan_filter(uint8_t port_id, uint16_t vlan_id, vf_mask, vlan_on); } +int +rte_eth_dev_set_vf_vlan_anti_spoof(uint8_t port_id, + uint16_t vf, uint8_t on) +{ + struct rte_eth_dev *dev; + struct rte_eth_dev_info dev_info; + + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); + + dev = &rte_eth_devices[port_id]; + rte_eth_dev_info_get(port_id, &dev_info); + + if (vf >= dev_info.max_vfs) { + RTE_PMD_DEBUG_TRACE("set VF VLAN anti spoof: invalid VF %d\n", vf); + return -EINVAL; + } + + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->set_vf_vlan_anti_spoof, -ENOTSUP); + (*dev->dev_ops->set_vf_vlan_anti_spoof)(dev, vf, on); + return 0; +} + +int +rte_eth_dev_set_vf_mac_anti_spoof(uint8_t port_id, + uint16_t vf, uint8_t on) +{ + struct rte_eth_dev *dev; + struct rte_eth_dev_info dev_info; + + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); + + dev = &rte_eth_devices[port_id]; + rte_eth_dev_info_get(port_id, &dev_info); + + if (vf >= dev_info.max_vfs) { + RTE_PMD_DEBUG_TRACE("set VF MAC anti spoof:invalid VF %d\n", vf); + return -EINVAL; + } + + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->set_vf_mac_anti_spoof, -ENOTSUP); + (*dev->dev_ops->set_vf_mac_anti_spoof)(dev, vf, on); + return 0; +} + +int +rte_eth_dev_vf_ping(uint8_t port_id, int32_t vf) +{ + struct rte_eth_dev *dev; + struct rte_eth_dev_info dev_info; + + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); + + dev = &rte_eth_devices[port_id]; + rte_eth_dev_info_get(port_id, &dev_info); + + if (vf >= dev_info.max_vfs) { + RTE_PMD_DEBUG_TRACE("VF ping: invalid VF %d\n", vf); + return -EINVAL; + } else if (vf < -1) { + RTE_PMD_DEBUG_TRACE("VF ping: invalid value %d\n", vf); + return -EINVAL; + } + + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->vf_ping, -ENOTSUP); + return (*dev->dev_ops->vf_ping)(dev, vf); +} + +int +rte_eth_dev_set_vf_vlan_strip(uint8_t port_id, uint16_t vf, int on) +{ + struct rte_eth_dev *dev; + struct rte_eth_dev_info dev_info; + uint16_t queues_per_pool; + uint32_t q; + + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); + + dev = &rte_eth_devices[port_id]; + rte_eth_dev_info_get(port_id, &dev_info); + + if (vf >= dev_info.max_vfs) { + RTE_PMD_DEBUG_TRACE("set VF vlan strip: invalid VF %d\n", vf); + return -EINVAL; + } + + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->vlan_strip_queue_set, -ENOTSUP); + + queues_per_pool = dev_info.vmdq_queue_num/dev_info.max_vmdq_pools; + + for (q = 0; q < queues_per_pool; q++) + (*dev->dev_ops->vlan_strip_queue_set)(dev, q + vf * queues_per_pool, on); + return 0; +} + +int +rte_eth_dev_set_vf_vlan_insert(uint8_t port_id, uint16_t vf, int on) +{ + struct rte_eth_dev *dev; + struct rte_eth_dev_info dev_info; + + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); + + dev = &rte_eth_devices[port_id]; + rte_eth_dev_info_get(port_id, &dev_info); + + if (vf >= dev_info.max_vfs) { + RTE_PMD_DEBUG_TRACE("set VF vlan insert: invalid VF %d\n", vf); + return -EINVAL; + } + + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->set_vf_vlan_insert, -ENOTSUP); + + (*dev->dev_ops->set_vf_vlan_insert)(dev, vf, on); + return 0; +} + +int +rte_eth_dev_set_tx_loopback(uint8_t port_id, int on) +{ + struct rte_eth_dev *dev; + + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); + + dev = &rte_eth_devices[port_id]; + + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->set_tx_loopback, -ENOTSUP); + + (*dev->dev_ops->set_tx_loopback)(dev, on); + return 0; +} + +int +rte_eth_dev_set_all_queues_drop_en(uint8_t port_id, int state) +{ + struct rte_eth_dev *dev; + + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); + + dev = &rte_eth_devices[port_id]; + + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->set_all_queues_drop_en, -ENOTSUP); + + (*dev->dev_ops->set_all_queues_drop_en)(dev, state); + return 0; +} + +int +rte_eth_dev_set_vf_split_drop_en(uint8_t port_id, uint16_t vf, int state) +{ + struct rte_eth_dev *dev; + struct rte_eth_dev_info dev_info; + + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); + + dev = &rte_eth_devices[port_id]; + rte_eth_dev_info_get(port_id, &dev_info); + + if (vf >= dev_info.max_vfs) { + RTE_PMD_DEBUG_TRACE("set VF split drop enable: invalid VF %d\n", vf); + return -EINVAL; + } + + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->set_vf_split_drop_en, -ENOTSUP); + + (*dev->dev_ops->set_vf_split_drop_en)(dev, vf, state); + return 0; +} + int rte_eth_set_queue_rate_limit(uint8_t port_id, uint16_t queue_idx, uint16_t tx_rate) { diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h index 96575e8..68b477f 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -1233,6 +1233,11 @@ typedef void (*eth_mac_addr_set_t)(struct rte_eth_dev *dev, struct ether_addr *mac_addr); /**< @internal Set a MAC address into Receive Address Address Register */ +typedef int (*eth_set_vf_mac_addr_t)(struct rte_eth_dev *dev, + uint16_t vf, + struct ether_addr *mac_addr); +/**< @internal Set VF address into Receive Address Address Register */ + typedef int (*eth_uc_hash_table_set_t)(struct rte_eth_dev *dev, struct ether_addr *mac_addr, uint8_t on); @@ -1264,6 +1269,38 @@ typedef int (*eth_set_vf_vlan_filter_t)(struct rte_eth_dev *dev, uint8_t vlan_on); /**< @internal Set VF VLAN pool filter */ +typedef void (*eth_set_vf_vlan_anti_spoof_t)(struct rte_eth_dev *dev, + uint16_t vf, + uint8_t on); +/**< @internal Set VF VLAN anti spoof */ + +typedef void (*eth_set_vf_mac_anti_spoof_t)(struct rte_eth_dev *dev, + uint16_t vf, + uint8_t on); +/**< @internal Set VF MAC anti spoof */ + +typedef int (*eth_vf_ping_t)(struct rte_eth_dev *dev, + int32_t vf); +/**< @internal ping one or all vf's */ + +typedef void (*eth_set_vf_vlan_insert_t)(struct rte_eth_dev *dev, + uint16_t vf, + int vlan); +/**< @internal Set VF vlan insert */ + +typedef void (*eth_set_tx_loopback_t)(struct rte_eth_dev *dev, + int on); +/**< @internal Set tx loopback */ + +typedef void (*eth_set_all_queues_drop_en_t)(struct rte_eth_dev *dev, + int state); +/**< @internal Set all queues drop */ + +typedef void (*eth_set_vf_split_drop_en_t)(struct rte_eth_dev *dev, + uint16_t vf, + int state); +/**< @internal Set the enable drop bit in the VF split rx control register */ + typedef int (*eth_set_queue_rate_limit_t)(struct rte_eth_dev *dev, uint16_t queue_idx, uint16_t tx_rate); @@ -1468,6 +1505,7 @@ struct eth_dev_ops { eth_mac_addr_remove_t mac_addr_remove; /**< Remove MAC address */ eth_mac_addr_add_t mac_addr_add; /**< Add a MAC address */ eth_mac_addr_set_t mac_addr_set; /**< Set a MAC address */ + eth_set_vf_mac_addr_t set_vf_mac_addr; /**< Set a VF MAC address */ eth_uc_hash_table_set_t uc_hash_table_set; /**< Set Unicast Table Array */ eth_uc_all_hash_table_set_t uc_all_hash_table_set; /**< Set Unicast hash bitmap */ eth_mirror_rule_set_t mirror_rule_set; /**< Add a traffic mirror rule.*/ @@ -1476,6 +1514,13 @@ struct eth_dev_ops { eth_set_vf_rx_t set_vf_rx; /**< enable/disable a VF receive */ eth_set_vf_tx_t set_vf_tx; /**< enable/disable a VF transmit */ eth_set_vf_vlan_filter_t set_vf_vlan_filter; /**< Set VF VLAN filter */ + eth_set_vf_vlan_anti_spoof_t set_vf_vlan_anti_spoof; /**< Set VF VLAN anti spoof */ + eth_set_vf_mac_anti_spoof_t set_vf_mac_anti_spoof; /**< Set VF MAC anti spoof */ + eth_vf_ping_t vf_ping; /**< Ping one or all VF's */ + eth_set_vf_vlan_insert_t set_vf_vlan_insert; /**